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
690 mdt_index=$($LFS getstripe -M $WDIR)
691 mdt_index=$((mdt_index+1))
695 #fail mds will wait the failover finish then set
696 #following fail_loc to avoid interfer the recovery process.
699 #define OBD_FAIL_OSD_LMA_INCOMPAT 0x194
700 do_facet mds${mdt_index} lctl set_param fail_loc=0x194
701 ls -l $WDIR/$tfile && rc=1
702 do_facet mds${mdt_index} lctl set_param fail_loc=0
703 [[ $rc -ne 0 ]] && error "stat file should fail"
706 run_test 17o "stat file with incompat LMA feature"
709 touch $DIR/$tfile || error "Failed to touch $DIR/$tfile: $?"
710 ls $DIR || error "Failed to ls $DIR: $?"
712 run_test 18 "touch .../f ; ls ... =============================="
718 $CHECKSTAT -a $DIR/$tfile || error "$tfile was not removed"
720 run_test 19a "touch .../f19 ; ls -l ... ; rm .../f19 ==========="
723 ls -l $DIR/$tfile && error "ls -l $tfile failed"|| true
725 run_test 19b "ls -l .../f19 (should return error) =============="
728 [ $RUNAS_ID -eq $UID ] &&
729 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
730 $RUNAS touch $DIR/$tfile && error "create non-root file failed" || true
732 run_test 19c "$RUNAS touch .../f19 (should return error) =="
735 cat $DIR/f19 && error || true
737 run_test 19d "cat .../f19 (should return error) =============="
749 $CHECKSTAT -a $DIR/$tfile || error "$tfile was not removed"
751 run_test 20 "touch .../f ; ls -l ... ==========================="
754 test_mkdir -p $DIR/$tdir
755 [ -f $DIR/$tdir/dangle ] && rm -f $DIR/$tdir/dangle
756 ln -s dangle $DIR/$tdir/link
757 echo foo >> $DIR/$tdir/link
758 cat $DIR/$tdir/dangle
759 $CHECKSTAT -t link $DIR/$tdir/link || error "$tdir/link not a link"
760 $CHECKSTAT -f -t file $DIR/$tdir/link ||
761 error "$tdir/link not linked to a file"
763 run_test 21 "write to dangling link ============================"
767 test_mkdir -p $DIR/$tdir
768 chown $RUNAS_ID:$RUNAS_GID $WDIR
769 (cd $WDIR || error "cd $WDIR failed";
770 $RUNAS tar cf - /etc/hosts /etc/sysconfig/network | \
772 ls -lR $WDIR/etc || error "ls -lR $WDIR/etc failed"
773 $CHECKSTAT -t dir $WDIR/etc || error "checkstat -t dir failed"
774 $CHECKSTAT -u \#$RUNAS_ID -g \#$RUNAS_GID $WDIR/etc || error "checkstat -u failed"
776 run_test 22 "unpack tar archive as non-root user ==============="
780 test_mkdir -p $DIR/$tdir
781 local file=$DIR/$tdir/$tfile
783 openfile -f O_CREAT:O_EXCL $file || error "$file create failed"
784 openfile -f O_CREAT:O_EXCL $file &&
785 error "$file recreate succeeded" || true
787 run_test 23a "O_CREAT|O_EXCL in subdir =========================="
789 test_23b() { # bug 18988
790 test_mkdir -p $DIR/$tdir
791 local file=$DIR/$tdir/$tfile
794 echo foo > $file || error "write filed"
795 echo bar >> $file || error "append filed"
796 $CHECKSTAT -s 8 $file || error "wrong size"
799 run_test 23b "O_APPEND check =========================="
803 echo '-- same directory rename'
804 test_mkdir $DIR/$tdir
805 touch $DIR/$tdir/$tfile.1
806 mv $DIR/$tdir/$tfile.1 $DIR/$tdir/$tfile.2
807 $CHECKSTAT -t file $DIR/$tdir/$tfile.2 || error "$tfile.2 not a file"
809 run_test 24a "rename file to non-existent target"
812 test_mkdir $DIR/$tdir
813 touch $DIR/$tdir/$tfile.{1,2}
814 mv $DIR/$tdir/$tfile.1 $DIR/$tdir/$tfile.2
815 $CHECKSTAT -a $DIR/$tdir/$tfile.1 || error "$tfile.1 exists"
816 $CHECKSTAT -t file $DIR/$tdir/$tfile.2 || error "$tfile.2 not a file"
818 run_test 24b "rename file to existing target"
821 test_mkdir $DIR/$tdir
822 test_mkdir $DIR/$tdir/d$testnum.1
823 mv $DIR/$tdir/d$testnum.1 $DIR/$tdir/d$testnum.2
824 $CHECKSTAT -a $DIR/$tdir/d$testnum.1 || error "d$testnum.1 exists"
825 $CHECKSTAT -t dir $DIR/$tdir/d$testnum.2 || error "d$testnum.2 not dir"
827 run_test 24c "rename directory to non-existent target"
830 test_mkdir -c1 $DIR/$tdir
831 test_mkdir -c1 $DIR/$tdir/d$testnum.1
832 test_mkdir -c1 $DIR/$tdir/d$testnum.2
833 mrename $DIR/$tdir/d$testnum.1 $DIR/$tdir/d$testnum.2
834 $CHECKSTAT -a $DIR/$tdir/d$testnum.1 || error "d$testnum.1 exists"
835 $CHECKSTAT -t dir $DIR/$tdir/d$testnum.2 || error "d$testnum.2 not dir"
837 run_test 24d "rename directory to existing target"
840 echo '-- cross directory renames --'
844 mv $DIR/R5a/f $DIR/R5b/g
845 $CHECKSTAT -a $DIR/R5a/f || error
846 $CHECKSTAT -t file $DIR/R5b/g || error
848 run_test 24e "touch .../R5a/f; rename .../R5a/f .../R5b/g ======"
853 touch $DIR/R6a/f $DIR/R6b/g
854 mv $DIR/R6a/f $DIR/R6b/g
855 $CHECKSTAT -a $DIR/R6a/f || error
856 $CHECKSTAT -t file $DIR/R6b/g || error
858 run_test 24f "touch .../R6a/f R6b/g; mv .../R6a/f .../R6b/g ===="
863 test_mkdir $DIR/R7a/d
864 mv $DIR/R7a/d $DIR/R7b/e
865 $CHECKSTAT -a $DIR/R7a/d || error
866 $CHECKSTAT -t dir $DIR/R7b/e || error
868 run_test 24g "mkdir .../R7{a,b}/d; mv .../R7a/d .../R7b/e ======"
871 test_mkdir -c1 $DIR/R8a
872 test_mkdir -c1 $DIR/R8b
873 test_mkdir -c1 $DIR/R8a/d
874 test_mkdir -c1 $DIR/R8b/e
875 mrename $DIR/R8a/d $DIR/R8b/e
876 $CHECKSTAT -a $DIR/R8a/d || error
877 $CHECKSTAT -t dir $DIR/R8b/e || error
879 run_test 24h "mkdir .../R8{a,b}/{d,e}; rename .../R8a/d .../R8b/e"
882 echo "-- rename error cases"
886 mrename $DIR/R9/f $DIR/R9/a
887 $CHECKSTAT -t file $DIR/R9/f || error
888 $CHECKSTAT -t dir $DIR/R9/a || error
889 $CHECKSTAT -a $DIR/R9/a/f || error
891 run_test 24i "rename file to dir error: touch f ; mkdir a ; rename f a"
895 mrename $DIR/R10/f $DIR/R10/g
896 $CHECKSTAT -t dir $DIR/R10 || error
897 $CHECKSTAT -a $DIR/R10/f || error
898 $CHECKSTAT -a $DIR/R10/g || error
900 run_test 24j "source does not exist ============================"
904 test_mkdir $DIR/R11a/d
906 mv $DIR/R11a/f $DIR/R11a/d
907 $CHECKSTAT -a $DIR/R11a/f || error
908 $CHECKSTAT -t file $DIR/R11a/d/f || error
910 run_test 24k "touch .../R11a/f; mv .../R11a/f .../R11a/d ======="
912 # bug 2429 - rename foo foo foo creates invalid file
915 $MULTIOP $f OcNs || error
917 run_test 24l "Renaming a file to itself ========================"
921 $MULTIOP $f OcLN ${f}2 ${f}2 || error "link ${f}2 ${f}2 failed"
922 # on ext3 this does not remove either the source or target files
923 # though the "expected" operation would be to remove the source
924 $CHECKSTAT -t file ${f} || error "${f} missing"
925 $CHECKSTAT -t file ${f}2 || error "${f}2 missing"
927 run_test 24m "Renaming a file to a hard link to itself ========="
931 # this stats the old file after it was renamed, so it should fail
935 $CHECKSTAT ${f}.rename
938 run_test 24n "Statting the old file after renaming (Posix rename 2)"
941 test_mkdir -p $DIR/d24o
942 rename_many -s random -v -n 10 $DIR/d24o
944 run_test 24o "rename of files during htree split ==============="
949 DIRINO=`ls -lid $DIR/R12a | awk '{ print $1 }'`
950 mrename $DIR/R12a $DIR/R12b
951 $CHECKSTAT -a $DIR/R12a || error
952 $CHECKSTAT -t dir $DIR/R12b || error
953 DIRINO2=`ls -lid $DIR/R12b | awk '{ print $1 }'`
954 [ "$DIRINO" = "$DIRINO2" ] || error "R12a $DIRINO != R12b $DIRINO2"
956 run_test 24p "mkdir .../R12{a,b}; rename .../R12a .../R12b"
958 cleanup_multiop_pause() {
964 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
967 local DIRINO=$(ls -lid $DIR/R13a | awk '{ print $1 }')
968 multiop_bg_pause $DIR/R13b D_c || error "multiop failed to start"
971 trap cleanup_multiop_pause EXIT
972 mrename $DIR/R13a $DIR/R13b
973 $CHECKSTAT -a $DIR/R13a || error "R13a still exists"
974 $CHECKSTAT -t dir $DIR/R13b || error "R13b does not exist"
975 local DIRINO2=$(ls -lid $DIR/R13b | awk '{ print $1 }')
976 [ "$DIRINO" = "$DIRINO2" ] || error "R13a $DIRINO != R13b $DIRINO2"
977 cleanup_multiop_pause
978 wait $MULTIPID || error "multiop close failed"
980 run_test 24q "mkdir .../R13{a,b}; open R13b rename R13a R13b ==="
982 test_24r() { #bug 3789
984 test_mkdir $DIR/R14a/b
985 mrename $DIR/R14a $DIR/R14a/b && error "rename to subdir worked!"
986 $CHECKSTAT -t dir $DIR/R14a || error "$DIR/R14a missing"
987 $CHECKSTAT -t dir $DIR/R14a/b || error "$DIR/R14a/b missing"
989 run_test 24r "mkdir .../R14a/b; rename .../R14a .../R14a/b ====="
993 test_mkdir $DIR/R15a/b
994 test_mkdir $DIR/R15a/b/c
995 mrename $DIR/R15a $DIR/R15a/b/c && error "rename to sub-subdir worked!"
996 $CHECKSTAT -t dir $DIR/R15a || error "$DIR/R15a missing"
997 $CHECKSTAT -t dir $DIR/R15a/b/c || error "$DIR/R15a/b/c missing"
999 run_test 24s "mkdir .../R15a/b/c; rename .../R15a .../R15a/b/c ="
1001 test_mkdir $DIR/R16a
1002 test_mkdir $DIR/R16a/b
1003 test_mkdir $DIR/R16a/b/c
1004 mrename $DIR/R16a/b/c $DIR/R16a && error "rename to sub-subdir worked!"
1005 $CHECKSTAT -t dir $DIR/R16a || error "$DIR/R16a missing"
1006 $CHECKSTAT -t dir $DIR/R16a/b/c || error "$DIR/R16a/b/c missing"
1008 run_test 24t "mkdir .../R16a/b/c; rename .../R16a/b/c .../R16a ="
1010 test_24u() { # bug12192
1011 $MULTIOP $DIR/$tfile C2w$((2048 * 1024))c || error
1012 $CHECKSTAT -s $((2048 * 1024)) $DIR/$tfile || error "wrong file size"
1014 run_test 24u "create stripe file"
1020 simple_cleanup_common() {
1023 wait_delete_completed
1026 max_pages_per_rpc() {
1027 $LCTL get_param -n mdc.*.max_pages_per_rpc | head -n1
1031 local NRFILES=100000
1032 local FREE_INODES=$(mdt_free_inodes 0)
1033 [[ $FREE_INODES -lt $NRFILES ]] &&
1034 skip "not enough free inodes $FREE_INODES required $NRFILES" &&
1037 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1038 trap simple_cleanup_common EXIT
1040 # Performance issue on ZFS see LU-4072 (c.f. LU-2887)
1041 [ $(facet_fstype $SINGLEMDS) = "zfs" ] && NRFILES=10000
1044 createmany -m $DIR/$tdir/$tfile $NRFILES
1046 cancel_lru_locks mdc
1047 lctl set_param mdc.*.stats clear
1049 ls $DIR/$tdir >/dev/null || error "error in listing large dir"
1051 # LU-5 large readdir
1052 # DIRENT_SIZE = 32 bytes for sizeof(struct lu_dirent) +
1053 # 8 bytes for name(filename is mostly 5 in this test) +
1054 # 8 bytes for luda_type
1055 # take into account of overhead in lu_dirpage header and end mark in
1056 # each page, plus one in RPC_NUM calculation.
1058 RPC_SIZE=$(($(max_pages_per_rpc) * $(page_size)))
1059 RPC_NUM=$(((NRFILES * DIRENT_SIZE + RPC_SIZE - 1) / RPC_SIZE + 1))
1060 mds_readpage=$(lctl get_param mdc.*MDT0000*.stats |
1061 awk '/^mds_readpage/ {print $2}')
1062 [[ $mds_readpage -gt $RPC_NUM ]] &&
1063 error "large readdir doesn't take effect"
1065 simple_cleanup_common
1067 run_test 24v "list directory with large files (handle hash collision, bug: 17560)"
1069 test_24w() { # bug21506
1071 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=4096 || return 1
1072 dd if=/dev/zero bs=$SZ1 count=1 >> $DIR/$tfile || return 2
1073 dd if=$DIR/$tfile of=$DIR/${tfile}_left bs=1M skip=4097 || return 3
1074 SZ2=`ls -l $DIR/${tfile}_left | awk '{print $5}'`
1075 [[ "$SZ1" -eq "$SZ2" ]] ||
1076 error "Error reading at the end of the file $tfile"
1078 run_test 24w "Reading a file larger than 4Gb"
1081 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 2 MDTs" && return
1082 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1084 local remote_dir=$DIR/$tdir/remote_dir
1087 $LFS mkdir -i $MDTIDX $remote_dir ||
1088 error "create remote directory failed"
1090 mkdir -p $DIR/$tdir/src_dir
1091 touch $DIR/$tdir/src_file
1092 mkdir -p $remote_dir/tgt_dir
1093 touch $remote_dir/tgt_file
1095 mrename $remote_dir $DIR/ &&
1096 error "rename dir cross MDT works!"
1098 mrename $DIR/$tdir/src_dir $remote_dir/tgt_dir &&
1099 error "rename dir cross MDT works!"
1101 mrename $DIR/$tdir/src_file $remote_dir/tgt_file &&
1102 error "rename file cross MDT works!"
1104 ln $DIR/$tdir/src_file $remote_dir/tgt_file1 &&
1105 error "ln file cross MDT should not work!"
1107 rm -rf $DIR/$tdir || error "Can not delete directories"
1109 run_test 24x "cross rename/link should be failed"
1112 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 2 MDTs" && return
1113 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1115 local remote_dir=$DIR/$tdir/remote_dir
1118 $LFS mkdir -i $MDTIDX $remote_dir ||
1119 error "create remote directory failed"
1121 mkdir -p $remote_dir/src_dir
1122 touch $remote_dir/src_file
1123 mkdir -p $remote_dir/tgt_dir
1124 touch $remote_dir/tgt_file
1126 mrename $remote_dir/src_dir $remote_dir/tgt_dir ||
1127 error "rename subdir in the same remote dir failed!"
1129 mrename $remote_dir/src_file $remote_dir/tgt_file ||
1130 error "rename files in the same remote dir failed!"
1132 ln $remote_dir/tgt_file $remote_dir/tgt_file1 ||
1133 error "link files in the same remote dir failed!"
1135 rm -rf $DIR/$tdir || error "Can not delete directories"
1137 run_test 24y "rename/link on the same dir should succeed"
1140 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 2 MDTs" && return
1141 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1143 local remote_src=$DIR/$tdir/remote_dir
1144 local remote_tgt=$DIR/$tdir/remote_tgt
1147 $LFS mkdir -i $MDTIDX $remote_src ||
1148 error "create remote directory failed"
1150 $LFS mkdir -i $MDTIDX $remote_tgt ||
1151 error "create remote directory failed"
1153 mrename $remote_src $remote_tgt &&
1154 error "rename remote dirs should not work!"
1156 # If target dir does not exists, it should succeed
1158 mrename $remote_src $remote_tgt ||
1159 error "rename remote dirs(tgt dir does not exists) failed!"
1161 rm -rf $DIR/$tdir || error "Can not delete directories"
1163 run_test 24z "rename one remote dir to another remote dir should fail"
1165 test_24A() { # LU-3182
1170 createmany -m $DIR/$tdir/$tfile $NFILES
1171 local t=$(ls $DIR/$tdir | wc -l)
1172 local u=$(ls $DIR/$tdir | sort -u | wc -l)
1173 local v=$(ls -ai $DIR/$tdir | sort -u | wc -l)
1174 if [ $t -ne $NFILES -o $u -ne $NFILES -o $v -ne $((NFILES + 2)) ] ; then
1175 error "Expected $NFILES files, got $t ($u unique $v .&..)"
1178 rm -rf $DIR/$tdir || error "Can not delete directories"
1180 run_test 24A "readdir() returns correct number of entries."
1182 test_24B() { # LU-4805
1183 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
1187 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR/$tdir/striped_dir ||
1188 error "create striped dir failed"
1190 count=$(ls -ai $DIR/$tdir/striped_dir | wc -l)
1191 [ $count -eq 2 ] || error "Expected 2, got $count"
1193 touch $DIR/$tdir/striped_dir/a
1195 count=$(ls -ai $DIR/$tdir/striped_dir | wc -l)
1196 [ $count -eq 3 ] || error "Expected 3, got $count"
1198 touch $DIR/$tdir/striped_dir/.f
1200 count=$(ls -ai $DIR/$tdir/striped_dir | wc -l)
1201 [ $count -eq 4 ] || error "Expected 4, got $count"
1203 rm -rf $DIR/$tdir || error "Can not delete directories"
1205 run_test 24B "readdir for striped dir return correct number of entries"
1208 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
1214 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR/$tdir/d0/striped_dir ||
1215 error "create striped dir failed"
1217 cd $DIR/$tdir/d0/striped_dir
1219 local d0_ino=$(ls -i -l -a $DIR/$tdir | grep "d0" | awk '{print $1}')
1220 local d1_ino=$(ls -i -l -a $DIR/$tdir | grep "d1" | awk '{print $1}')
1221 local parent_ino=$(ls -i -l -a | grep "\.\." | awk '{print $1}')
1223 [ "$d0_ino" = "$parent_ino" ] ||
1224 error ".. wrong, expect $d0_ino, get $parent_ino"
1226 mv $DIR/$tdir/d0/striped_dir $DIR/$tdir/d1/ ||
1227 error "mv striped dir failed"
1229 parent_ino=$(ls -i -l -a | grep "\.\." | awk '{print $1}')
1231 [ "$d1_ino" = "$parent_ino" ] ||
1232 error ".. wrong after mv, expect $d1_ino, get $parent_ino"
1234 run_test 24C "check .. in striped dir"
1236 test_24D() { # LU-6101
1241 createmany -m $DIR/$tdir/$tfile $NFILES
1242 local t=$(ls $DIR/$tdir | wc -l)
1243 local u=$(ls $DIR/$tdir | sort -u | wc -l)
1244 local v=$(ls -ai $DIR/$tdir | sort -u | wc -l)
1245 if [ $t -ne $NFILES -o $u -ne $NFILES -o $v -ne $((NFILES + 2)) ] ; then
1246 error "Expected $NFILES files, got $t ($u unique $v .&..)"
1249 rm -rf $DIR/$tdir || error "Can not delete directories"
1251 run_test 24D "readdir() returns correct number of entries after cursor reload"
1254 echo '== symlink sanity ============================================='
1258 touch $DIR/s25/foo || error
1260 run_test 25a "create file in symlinked directory ==============="
1263 [ ! -d $DIR/d25 ] && test_25a
1264 $CHECKSTAT -t file $DIR/s25/foo || error
1266 run_test 25b "lookup file in symlinked directory ==============="
1270 test_mkdir $DIR/d26/d26-2
1271 ln -s d26/d26-2 $DIR/s26
1272 touch $DIR/s26/foo || error
1274 run_test 26a "multiple component symlink ======================="
1277 test_mkdir -p $DIR/d26b/d26-2
1278 ln -s d26b/d26-2/foo $DIR/s26-2
1279 touch $DIR/s26-2 || error
1281 run_test 26b "multiple component symlink at end of lookup ======"
1284 test_mkdir $DIR/d26.2
1285 touch $DIR/d26.2/foo
1286 ln -s d26.2 $DIR/s26.2-1
1287 ln -s s26.2-1 $DIR/s26.2-2
1288 ln -s s26.2-2 $DIR/s26.2-3
1289 chmod 0666 $DIR/s26.2-3/foo
1291 run_test 26c "chain of symlinks ================================"
1293 # recursive symlinks (bug 439)
1295 ln -s d26-3/foo $DIR/d26-3
1297 run_test 26d "create multiple component recursive symlink ======"
1300 [ ! -h $DIR/d26-3 ] && test_26d
1303 run_test 26e "unlink multiple component recursive symlink ======"
1305 # recursive symlinks (bug 7022)
1307 test_mkdir -p $DIR/$tdir
1308 test_mkdir $DIR/$tdir/$tfile || error "mkdir $DIR/$tdir/$tfile failed"
1309 cd $DIR/$tdir/$tfile || error "cd $DIR/$tdir/$tfile failed"
1310 test_mkdir -p lndir/bar1 || error "mkdir lndir/bar1 failed"
1311 test_mkdir $DIR/$tdir/$tfile/$tfile || error "mkdir $tfile failed"
1312 cd $tfile || error "cd $tfile failed"
1313 ln -s .. dotdot || error "ln dotdot failed"
1314 ln -s dotdot/lndir lndir || error "ln lndir failed"
1315 cd $DIR/$tdir || error "cd $DIR/$tdir failed"
1316 output=`ls $tfile/$tfile/lndir/bar1`
1317 [ "$output" = bar1 ] && error "unexpected output"
1318 rm -r $tfile || error "rm $tfile failed"
1319 $CHECKSTAT -a $DIR/$tfile || error "$tfile not gone"
1321 run_test 26f "rm -r of a directory which has recursive symlink ="
1324 echo '== stripe sanity =============================================='
1325 test_mkdir -p $DIR/d27 || error "mkdir failed"
1327 $SETSTRIPE -c 1 $DIR/d27/f0 || error "setstripe failed"
1328 $CHECKSTAT -t file $DIR/d27/f0 || error "checkstat failed"
1329 log "== test_27a: write to one stripe file ========================="
1330 cp /etc/hosts $DIR/d27/f0 || error
1332 run_test 27a "one stripe file =================================="
1335 [[ $OSTCOUNT -lt 2 ]] && skip_env "skipping 2-stripe test" && return
1336 test_mkdir -p $DIR/d27
1337 $SETSTRIPE -c 2 $DIR/d27/f01 || error "setstripe failed"
1338 $GETSTRIPE -c $DIR/d27/f01
1339 [ $($GETSTRIPE -c $DIR/d27/f01) -eq 2 ] ||
1340 error "two-stripe file doesn't have two stripes"
1342 dd if=/dev/zero of=$DIR/d27/f01 bs=4k count=4 || error "dd failed"
1344 run_test 27b "create and write to two stripe file"
1347 test_mkdir -p $DIR/d27
1348 $SETSTRIPE -c 0 -i -1 -S 0 $DIR/d27/fdef || error "setstripe failed"
1349 $CHECKSTAT -t file $DIR/d27/fdef || error "checkstat failed"
1350 dd if=/dev/zero of=$DIR/d27/fdef bs=4k count=4 || error
1352 run_test 27d "create file with default settings ================"
1355 test_mkdir -p $DIR/d27
1356 $SETSTRIPE -c 2 $DIR/d27/f12 || error "setstripe failed"
1357 $SETSTRIPE -c 2 $DIR/d27/f12 && error "setstripe succeeded twice"
1358 $CHECKSTAT -t file $DIR/d27/f12 || error "checkstat failed"
1360 run_test 27e "setstripe existing file (should return error) ======"
1363 test_mkdir $DIR/$tdir
1364 $SETSTRIPE -S 100 -i 0 -c 1 $DIR/$tdir/$tfile &&
1365 error "$SETSTRIPE $DIR/$tdir/$tfile failed"
1366 $CHECKSTAT -t file $DIR/$tdir/$tfile &&
1367 error "$CHECKSTAT -t file $DIR/$tdir/$tfile should fail"
1368 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=4k count=4 || error "dd failed"
1369 $GETSTRIPE $DIR/$tdir/$tfile || error "$GETSTRIPE failed"
1371 run_test 27f "setstripe with bad stripe size (should return error)"
1374 test_mkdir -p $DIR/d27
1375 $MCREATE $DIR/d27/fnone || error "mcreate failed"
1376 $GETSTRIPE $DIR/d27/fnone 2>&1 | grep "no stripe info" ||
1377 error "$DIR/d27/fnone has object"
1379 run_test 27g "$GETSTRIPE with no objects"
1382 test_mkdir $DIR/$tdir
1383 touch $DIR/$tdir/$tfile || error "touch failed"
1384 [[ $($GETSTRIPE -c $DIR/$tdir/$tfile) -gt 0 ]] ||
1385 error "missing objects"
1387 run_test 27i "$GETSTRIPE with some objects"
1390 test_mkdir -p $DIR/d27
1391 $SETSTRIPE -i $OSTCOUNT $DIR/d27/f27j && error "setstripe failed"||true
1393 run_test 27j "setstripe with bad stripe offset (should return error)"
1395 test_27k() { # bug 2844
1396 test_mkdir -p $DIR/d27
1398 LL_MAX_BLKSIZE=$((4 * 1024 * 1024))
1399 [ ! -d $DIR/d27 ] && test_mkdir -p $DIR d27
1400 $SETSTRIPE -S 67108864 $FILE || error "setstripe failed"
1401 BLKSIZE=`stat $FILE | awk '/IO Block:/ { print $7 }'`
1402 [ $BLKSIZE -le $LL_MAX_BLKSIZE ] || error "1:$BLKSIZE > $LL_MAX_BLKSIZE"
1403 dd if=/dev/zero of=$FILE bs=4k count=1
1404 BLKSIZE=`stat $FILE | awk '/IO Block:/ { print $7 }'`
1405 [ $BLKSIZE -le $LL_MAX_BLKSIZE ] || error "2:$BLKSIZE > $LL_MAX_BLKSIZE"
1407 run_test 27k "limit i_blksize for broken user apps ============="
1410 test_mkdir -p $DIR/d27
1411 mcreate $DIR/f27l || error "creating file"
1412 $RUNAS $SETSTRIPE -c 1 $DIR/f27l && \
1413 error "setstripe should have failed" || true
1415 run_test 27l "check setstripe permissions (should return error)"
1418 [[ $OSTCOUNT -lt 2 ]] && skip_env "$OSTCOUNT < 2 OSTs -- skipping" &&
1420 if [[ $ORIGFREE -gt $MAXFREE ]]; then
1421 skip "$ORIGFREE > $MAXFREE skipping out-of-space test on OST0"
1424 trap simple_cleanup_common EXIT
1425 test_mkdir -p $DIR/$tdir
1426 $SETSTRIPE -i 0 -c 1 $DIR/$tdir/f27m_1
1427 dd if=/dev/zero of=$DIR/$tdir/f27m_1 bs=1024 count=$MAXFREE &&
1428 error "dd should fill OST0"
1430 while $SETSTRIPE -i 0 -c 1 $DIR/$tdir/f27m_$i; do
1432 [ $i -gt 256 ] && break
1435 touch $DIR/$tdir/f27m_$i
1436 [ `$GETSTRIPE $DIR/$tdir/f27m_$i | grep -A 10 obdidx | awk '{print $1}'| grep -w "0"` ] &&
1437 error "OST0 was full but new created file still use it"
1439 touch $DIR/$tdir/f27m_$i
1440 [ `$GETSTRIPE $DIR/$tdir/f27m_$i | grep -A 10 obdidx | awk '{print $1}'| grep -w "0"` ] &&
1441 error "OST0 was full but new created file still use it"
1442 simple_cleanup_common
1444 run_test 27m "create file while OST0 was full =================="
1447 local DELAY=$(do_facet $SINGLEMDS lctl get_param -n lov.*.qos_maxage | head -n 1 | awk '{print $1 * 2}')
1451 # OSCs keep a NOSPC flag that will be reset after ~5s (qos_maxage)
1452 # if the OST isn't full anymore.
1454 local OSTIDX=${1:-""}
1456 local list=$(comma_list $(osts_nodes))
1457 [ "$OSTIDX" ] && list=$(facet_host ost$((OSTIDX + 1)))
1459 do_nodes $list lctl set_param fail_loc=0
1460 sync # initiate all OST_DESTROYs from MDS to OST
1464 exhaust_precreations() {
1467 local FAILIDX=${3:-$OSTIDX}
1468 local ofacet=ost$((OSTIDX + 1))
1470 test_mkdir -p -c1 $DIR/$tdir
1471 local mdtidx=$($LFS getstripe -M $DIR/$tdir)
1472 local mfacet=mds$((mdtidx + 1))
1473 echo OSTIDX=$OSTIDX MDTIDX=$mdtidx
1475 local OST=$(ostname_from_index $OSTIDX)
1478 local mdtosc_proc1=$(get_mdtosc_proc_path $mfacet $OST)
1479 local last_id=$(do_facet $mfacet lctl get_param -n \
1480 osc.$mdtosc_proc1.prealloc_last_id)
1481 local next_id=$(do_facet $mfacet lctl get_param -n \
1482 osc.$mdtosc_proc1.prealloc_next_id)
1484 local mdtosc_proc2=$(get_mdtosc_proc_path $mfacet)
1485 do_facet $mfacet lctl get_param osc.$mdtosc_proc2.prealloc*
1487 test_mkdir -p $DIR/$tdir/${OST}
1488 $SETSTRIPE -i $OSTIDX -c 1 $DIR/$tdir/${OST}
1489 #define OBD_FAIL_OST_ENOSPC 0x215
1490 do_facet $ofacet lctl set_param fail_val=$FAILIDX fail_loc=0x215
1491 echo "Creating to objid $last_id on ost $OST..."
1492 createmany -o $DIR/$tdir/${OST}/f $next_id $((last_id - next_id + 2))
1493 do_facet $mfacet lctl get_param osc.$mdtosc_proc2.prealloc*
1494 do_facet $ofacet lctl set_param fail_loc=$FAILLOC
1498 exhaust_all_precreations() {
1500 for (( i=0; i < OSTCOUNT; i++ )) ; do
1501 exhaust_precreations $i $1 -1
1506 [[ $OSTCOUNT -lt 2 ]] && skip_env "too few OSTs" && return
1507 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1508 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1509 remote_ost_nodsh && skip "remote OST with nodsh" && return
1512 rm -f $DIR/$tdir/$tfile
1513 exhaust_precreations 0 0x80000215
1514 $SETSTRIPE -c -1 $DIR/$tdir
1515 touch $DIR/$tdir/$tfile || error
1516 $GETSTRIPE $DIR/$tdir/$tfile
1519 run_test 27n "create file with some full OSTs =================="
1522 [[ $OSTCOUNT -lt 2 ]] && skip_env "too few OSTs" && return
1523 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1524 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1525 remote_ost_nodsh && skip "remote OST with nodsh" && return
1528 rm -f $DIR/$tdir/$tfile
1529 exhaust_all_precreations 0x215
1531 touch $DIR/$tdir/$tfile && error "able to create $DIR/$tdir/$tfile"
1536 run_test 27o "create file with all full OSTs (should error) ===="
1539 [[ $OSTCOUNT -lt 2 ]] && skip_env "too few OSTs" && return
1540 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1541 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1542 remote_ost_nodsh && skip "remote OST with nodsh" && return
1545 rm -f $DIR/$tdir/$tfile
1546 test_mkdir -p $DIR/$tdir
1548 $MCREATE $DIR/$tdir/$tfile || error "mcreate failed"
1549 $TRUNCATE $DIR/$tdir/$tfile 80000000 || error "truncate failed"
1550 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat failed"
1552 exhaust_precreations 0 0x80000215
1553 echo foo >> $DIR/$tdir/$tfile || error "append failed"
1554 $CHECKSTAT -s 80000004 $DIR/$tdir/$tfile || error "checkstat failed"
1555 $GETSTRIPE $DIR/$tdir/$tfile
1559 run_test 27p "append to a truncated file with some full OSTs ==="
1562 [[ $OSTCOUNT -lt 2 ]] && skip_env "too few OSTs" && return
1563 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1564 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1565 remote_ost_nodsh && skip "remote OST with nodsh" && return
1568 rm -f $DIR/$tdir/$tfile
1570 test_mkdir -p $DIR/$tdir
1571 $MCREATE $DIR/$tdir/$tfile || error "mcreate $DIR/$tdir/$tfile failed"
1572 $TRUNCATE $DIR/$tdir/$tfile 80000000 ||error "truncate $DIR/$tdir/$tfile failed"
1573 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat failed"
1575 exhaust_all_precreations 0x215
1577 echo foo >> $DIR/$tdir/$tfile && error "append succeeded"
1578 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat 2 failed"
1582 run_test 27q "append to truncated file with all OSTs full (should error) ==="
1585 [[ $OSTCOUNT -lt 2 ]] && skip_env "too few OSTs" && return
1586 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1587 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1588 remote_ost_nodsh && skip "remote OST with nodsh" && return
1591 rm -f $DIR/$tdir/$tfile
1592 exhaust_precreations 0 0x80000215
1594 $SETSTRIPE -i 0 -c 2 $DIR/$tdir/$tfile # && error
1598 run_test 27r "stripe file with some full OSTs (shouldn't LBUG) ="
1600 test_27s() { # bug 10725
1601 test_mkdir -p $DIR/$tdir
1602 local stripe_size=$((4096 * 1024 * 1024)) # 2^32
1603 local stripe_count=0
1604 [ $OSTCOUNT -eq 1 ] || stripe_count=2
1605 $SETSTRIPE -S $stripe_size -c $stripe_count $DIR/$tdir &&
1606 error "stripe width >= 2^32 succeeded" || true
1609 run_test 27s "lsm_xfersize overflow (should error) (bug 10725)"
1611 test_27t() { # bug 10864
1616 $WLFS getstripe $tfile
1619 run_test 27t "check that utils parse path correctly"
1621 test_27u() { # bug 4900
1622 [[ $OSTCOUNT -lt 2 ]] && skip_env "too few OSTs" && return
1623 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1625 local list=$(comma_list $(mdts_nodes))
1627 #define OBD_FAIL_MDS_OSC_PRECREATE 0x139
1628 do_nodes $list $LCTL set_param fail_loc=0x139
1629 test_mkdir -p $DIR/$tdir
1631 createmany -o $DIR/$tdir/t- 1000
1632 do_nodes $list $LCTL set_param fail_loc=0
1634 TLOG=$DIR/$tfile.getstripe
1635 $GETSTRIPE $DIR/$tdir > $TLOG
1636 OBJS=$(awk -vobj=0 '($1 == 0) { obj += 1 } END { print obj; }' $TLOG)
1637 unlinkmany $DIR/$tdir/t- 1000
1638 [[ $OBJS -gt 0 ]] &&
1639 error "$OBJS objects created on OST-0. See $TLOG" || pass
1641 run_test 27u "skip object creation on OSC w/o objects =========="
1643 test_27v() { # bug 4900
1644 [[ $OSTCOUNT -lt 2 ]] && skip_env "too few OSTs" && return
1645 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1646 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1647 remote_ost_nodsh && skip "remote OST with nodsh" && return
1649 exhaust_all_precreations 0x215
1652 test_mkdir -p $DIR/$tdir
1653 $SETSTRIPE -c 1 $DIR/$tdir # 1 stripe / file
1655 touch $DIR/$tdir/$tfile
1656 #define OBD_FAIL_TGT_DELAY_PRECREATE 0x705
1658 for (( i=1; i < OSTCOUNT; i++ )); do
1659 do_facet ost$i lctl set_param fail_loc=0x705
1661 local START=`date +%s`
1662 createmany -o $DIR/$tdir/$tfile 32
1664 local FINISH=`date +%s`
1665 local TIMEOUT=`lctl get_param -n timeout`
1666 local PROCESS=$((FINISH - START))
1667 [ $PROCESS -ge $((TIMEOUT / 2)) ] && \
1668 error "$FINISH - $START >= $TIMEOUT / 2"
1669 sleep $((TIMEOUT / 2 - PROCESS))
1672 run_test 27v "skip object creation on slow OST ================="
1674 test_27w() { # bug 10997
1675 test_mkdir -p $DIR/$tdir || error "mkdir failed"
1676 $SETSTRIPE -S 65536 $DIR/$tdir/f0 || error "setstripe failed"
1677 [ $($GETSTRIPE -S $DIR/$tdir/f0) -ne 65536 ] &&
1678 error "stripe size $size != 65536" || true
1679 [ $($GETSTRIPE -d $DIR/$tdir | grep -c "stripe_count") -ne 1 ] &&
1680 error "$GETSTRIPE -d $DIR/$tdir failed" || true
1682 run_test 27w "check $SETSTRIPE -S option"
1685 [[ $OSTCOUNT -lt 2 ]] &&
1686 skip_env "skipping multiple stripe count/offset test" && return
1688 test_mkdir -p $DIR/$tdir || error "mkdir failed"
1689 for i in $(seq 1 $OSTCOUNT); do
1691 $SETSTRIPE -c $i -i $offset $DIR/$tdir/f$i ||
1692 error "setstripe -c $i -i $offset failed"
1693 count=$($GETSTRIPE -c $DIR/$tdir/f$i)
1694 index=$($GETSTRIPE -i $DIR/$tdir/f$i)
1695 [ $count -ne $i ] && error "stripe count $count != $i" || true
1696 [ $index -ne $offset ] &&
1697 error "stripe offset $index != $offset" || true
1700 run_test 27wa "check $SETSTRIPE -c -i options"
1703 remote_ost_nodsh && skip "remote OST with nodsh" && return
1704 [[ $OSTCOUNT -lt 2 ]] && skip_env "$OSTCOUNT < 2 OSTs" && return
1705 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1706 OFFSET=$(($OSTCOUNT - 1))
1708 local OST=$(ostname_from_index $OSTIDX)
1710 test_mkdir -p $DIR/$tdir
1711 $SETSTRIPE -c 1 $DIR/$tdir # 1 stripe per file
1712 do_facet ost$((OSTIDX + 1)) lctl set_param -n obdfilter.$OST.degraded 1
1714 createmany -o $DIR/$tdir/$tfile $OSTCOUNT
1715 for i in `seq 0 $OFFSET`; do
1716 [ `$GETSTRIPE $DIR/$tdir/$tfile$i | grep -A 10 obdidx | awk '{print $1}' | grep -w "$OSTIDX"` ] &&
1717 error "OST0 was degraded but new created file still use it"
1719 do_facet ost$((OSTIDX + 1)) lctl set_param -n obdfilter.$OST.degraded 0
1721 run_test 27x "create files while OST0 is degraded"
1724 [[ $OSTCOUNT -lt 2 ]] &&
1725 skip_env "$OSTCOUNT < 2 OSTs -- skipping" && return
1726 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1727 remote_ost_nodsh && skip "remote OST with nodsh" && return
1728 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1730 local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS $FSNAME-OST0000)
1731 local last_id=$(do_facet $SINGLEMDS lctl get_param -n \
1732 osc.$mdtosc.prealloc_last_id)
1733 local next_id=$(do_facet $SINGLEMDS lctl get_param -n \
1734 osc.$mdtosc.prealloc_next_id)
1735 local fcount=$((last_id - next_id))
1736 [[ $fcount -eq 0 ]] && skip "not enough space on OST0" && return
1737 [[ $fcount -gt $OSTCOUNT ]] && fcount=$OSTCOUNT
1739 local MDS_OSCS=$(do_facet $SINGLEMDS lctl dl |
1740 awk '/[oO][sS][cC].*md[ts]/ { print $4 }')
1741 local OST_DEACTIVE_IDX=-1
1746 for OSC in $MDS_OSCS; do
1747 OST=$(osc_to_ost $OSC)
1748 OSTIDX=$(index_from_ostuuid $OST)
1749 if [ $OST_DEACTIVE_IDX == -1 ]; then
1750 OST_DEACTIVE_IDX=$OSTIDX
1752 if [ $OSTIDX != $OST_DEACTIVE_IDX ]; then
1753 echo $OSC "is Deactivated:"
1754 do_facet $SINGLEMDS lctl --device %$OSC deactivate
1758 OSTIDX=$(index_from_ostuuid $OST)
1760 $SETSTRIPE -c 1 $DIR/$tdir # 1 stripe / file
1762 for OSC in $MDS_OSCS; do
1763 OST=$(osc_to_ost $OSC)
1764 OSTIDX=$(index_from_ostuuid $OST)
1765 if [ $OSTIDX == $OST_DEACTIVE_IDX ]; then
1766 echo $OST "is degraded:"
1767 do_facet ost$((OSTIDX+1)) lctl set_param -n \
1768 obdfilter.$OST.degraded=1
1773 createmany -o $DIR/$tdir/$tfile $fcount
1775 for OSC in $MDS_OSCS; do
1776 OST=$(osc_to_ost $OSC)
1777 OSTIDX=$(index_from_ostuuid $OST)
1778 if [ $OSTIDX == $OST_DEACTIVE_IDX ]; then
1779 echo $OST "is recovered from degraded:"
1780 do_facet ost$((OSTIDX+1)) lctl set_param -n \
1781 obdfilter.$OST.degraded=0
1783 do_facet $SINGLEMDS lctl --device %$OSC activate
1787 # all osp devices get activated, hence -1 stripe count restored
1790 # sleep 2*lod_qos_maxage seconds waiting for lod qos to notice osp
1791 # devices get activated.
1793 $SETSTRIPE -c -1 $DIR/$tfile
1794 stripecnt=$($GETSTRIPE -c $DIR/$tfile)
1796 [ $stripecnt -ne $OSTCOUNT ] &&
1797 error "Of $OSTCOUNT OSTs, only $stripecnt is available"
1800 run_test 27y "create files while OST0 is degraded and the rest inactive"
1806 lmm_count=$($GETSTRIPE -c $1)
1807 lmm_seq=$($GETSTRIPE -v $1 | awk '/lmm_seq/ { print $2 }')
1808 lmm_oid=$($GETSTRIPE -v $1 | awk '/lmm_object_id/ { print $2 }')
1810 local old_ifs="$IFS"
1812 fid=($($LFS path2fid $1))
1815 log "FID seq ${fid[1]}, oid ${fid[2]} ver ${fid[3]}"
1816 log "LOV seq $lmm_seq, oid $lmm_oid, count: $lmm_count"
1818 # compare lmm_seq and lu_fid->f_seq
1819 [ $lmm_seq = ${fid[1]} ] || { error "SEQ mismatch"; return 1; }
1820 # compare lmm_object_id and lu_fid->oid
1821 [ $lmm_oid = ${fid[2]} ] || { error "OID mismatch"; return 2; }
1823 # check the trusted.fid attribute of the OST objects of the file
1824 local have_obdidx=false
1826 $GETSTRIPE $1 | while read obdidx oid hex seq; do
1827 # skip lines up to and including "obdidx"
1828 [ -z "$obdidx" ] && break
1829 [ "$obdidx" = "obdidx" ] && have_obdidx=true && continue
1830 $have_obdidx || continue
1832 local ost=$((obdidx + 1))
1833 local dev=$(ostdevname $ost)
1836 log "want: stripe:$stripe_nr ost:$obdidx oid:$oid/$hex seq:$seq"
1838 seq=$(echo $seq | sed -e "s/^0x//g")
1839 if [ $seq == 0 ]; then
1840 oid_hex=$(echo $oid)
1842 oid_hex=$(echo $hex | sed -e "s/^0x//g")
1844 local obj_file="O/$seq/d$((oid %32))/$oid_hex"
1848 # Don't unmount/remount the OSTs if we don't need to do that.
1849 # LU-2577 changes filter_fid to be smaller, so debugfs needs
1850 # update too, until that use mount/ll_decode_filter_fid/mount.
1851 # Re-enable when debugfs will understand new filter_fid.
1853 if false && [ $(facet_fstype ost$ost) == ldiskfs ]; then
1854 ff=$(do_facet ost$ost "$DEBUGFS -c -R 'stat $obj_file' \
1855 $dev 2>/dev/null" | grep "parent=")
1858 mount_fstype ost$ost
1859 ff=$(do_facet ost$ost $LL_DECODE_FILTER_FID \
1860 $(facet_mntpt ost$ost)/$obj_file)
1861 unmount_fstype ost$ost
1862 start ost$ost $dev $OST_MOUNT_OPTS
1865 [ -z "$ff" ] && error "$obj_file: no filter_fid info"
1867 echo "$ff" | sed -e 's#.*objid=#got: objid=#'
1869 # /mnt/O/0/d23/23: objid=23 seq=0 parent=[0x200000400:0x1e:0x1]
1870 # fid: objid=23 seq=0 parent=[0x200000400:0x1e:0x0] stripe=1
1871 local ff_parent=$(echo $ff|sed -e 's/.*parent=.//')
1872 local ff_pseq=$(echo $ff_parent | cut -d: -f1)
1873 local ff_poid=$(echo $ff_parent | cut -d: -f2)
1875 if echo $ff_parent | grep -q 'stripe='; then
1876 ff_pstripe=$(echo $ff_parent | sed -e 's/.*stripe=//')
1879 # $LL_DECODE_FILTER_FID does not print "stripe="; look
1880 # into f_ver in this case. See the comment on
1883 ff_pstripe=$(echo $ff_parent | cut -d: -f3 |
1887 # compare lmm_seq and filter_fid->ff_parent.f_seq
1888 [ $ff_pseq = $lmm_seq ] ||
1889 error "FF parent SEQ $ff_pseq != $lmm_seq"
1890 # compare lmm_object_id and filter_fid->ff_parent.f_oid
1891 [ $ff_poid = $lmm_oid ] ||
1892 error "FF parent OID $ff_poid != $lmm_oid"
1893 (($ff_pstripe == $stripe_nr)) ||
1894 error "FF stripe $ff_pstripe != $stripe_nr"
1896 stripe_nr=$((stripe_nr + 1))
1901 remote_ost_nodsh && skip "remote OST with nodsh" && return
1902 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1903 test_mkdir -p $DIR/$tdir
1905 $SETSTRIPE -c 1 -i 0 -S 64k $DIR/$tdir/$tfile-1 ||
1906 { error "setstripe -c -1 failed"; return 1; }
1907 # We need to send a write to every object to get parent FID info set.
1908 # This _should_ also work for setattr, but does not currently.
1909 # touch $DIR/$tdir/$tfile-1 ||
1910 dd if=/dev/zero of=$DIR/$tdir/$tfile-1 bs=1M count=1 ||
1911 { error "dd $tfile-1 failed"; return 2; }
1912 $SETSTRIPE -c -1 -i $((OSTCOUNT - 1)) -S 1M $DIR/$tdir/$tfile-2 ||
1913 { error "setstripe -c -1 failed"; return 3; }
1914 dd if=/dev/zero of=$DIR/$tdir/$tfile-2 bs=1M count=$OSTCOUNT ||
1915 { error "dd $tfile-2 failed"; return 4; }
1917 # make sure write RPCs have been sent to OSTs
1920 check_seq_oid $DIR/$tdir/$tfile-1 || return 5
1921 check_seq_oid $DIR/$tdir/$tfile-2 || return 6
1923 run_test 27z "check SEQ/OID on the MDT and OST filesystems"
1925 test_27A() { # b=19102
1926 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1927 local restore_size=$($GETSTRIPE -S $MOUNT)
1928 local restore_count=$($GETSTRIPE -c $MOUNT)
1929 local restore_offset=$($GETSTRIPE -i $MOUNT)
1930 $SETSTRIPE -c 0 -i -1 -S 0 $MOUNT
1931 wait_update $HOSTNAME "$GETSTRIPE -c $MOUNT | sed 's/ *//g'" "1" 20 ||
1932 error "stripe count $($GETSTRIPE -c $MOUNT) != 1"
1933 local default_size=$($GETSTRIPE -S $MOUNT)
1934 local default_offset=$($GETSTRIPE -i $MOUNT)
1935 local dsize=$((1024 * 1024))
1936 [ $default_size -eq $dsize ] ||
1937 error "stripe size $default_size != $dsize"
1938 [ $default_offset -eq -1 ] ||error "stripe offset $default_offset != -1"
1939 $SETSTRIPE -c $restore_count -i $restore_offset -S $restore_size $MOUNT
1941 run_test 27A "check filesystem-wide default LOV EA values"
1943 test_27B() { # LU-2523
1944 test_mkdir -p $DIR/$tdir
1945 rm -f $DIR/$tdir/f0 $DIR/$tdir/f1
1947 # open f1 with O_LOV_DELAY_CREATE
1949 # call setstripe ioctl on open file descriptor for f1
1951 multiop $DIR/$tdir/f1 oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:nB1c \
1955 # open f1 with O_LOV_DELAY_CREATE
1957 # call setstripe ioctl on open file descriptor for f1
1959 multiop $DIR/$tdir/f1 oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:uB1c
1961 # Allow multiop to fail in imitation of NFS's busted semantics.
1964 run_test 27B "call setstripe on open unlinked file/rename victim"
1966 test_27C() { #LU-2871
1967 [[ $OSTCOUNT -lt 2 ]] && skip "needs >= 2 OSTs" && return
1975 test_mkdir -p $DIR/$tdir
1977 for i in $(seq 0 $((OSTCOUNT - 1))); do
1978 # set stripe across all OSTs starting from OST$i
1979 $SETSTRIPE -i $i -c -1 $tfile$i
1980 # get striping information
1981 ost_idx=($($GETSTRIPE $tfile$i |
1982 tail -n $((OSTCOUNT + 1)) | awk '{print $1}'))
1986 [ ${#ost_idx[@]} -eq $OSTCOUNT ] ||
1987 error "${#ost_idx[@]} != $OSTCOUNT"
1989 for index in $(seq 0 $((OSTCOUNT - 1))); do
1991 for j in $(echo ${ost_idx[@]}); do
1992 if [ $index -eq $j ]; then
1998 error "Can not find $index in ${ost_idx[@]}"
2002 run_test 27C "check full striping across all OSTs"
2005 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs" && return
2006 local POOL=${POOL:-testpool}
2008 local last_ost=$(($OSTCOUNT - 1))
2010 local ost_list=$(seq $first_ost $ost_step $last_ost)
2011 local ost_range="$first_ost $last_ost $ost_step"
2014 pool_add $POOL || error "pool_add failed"
2015 pool_add_targets $POOL $ost_range || error "pool_add_targets failed"
2016 llapi_layout_test -d$DIR/$tdir -p$POOL -o$OSTCOUNT ||
2017 error "llapi_layout_test failed"
2018 cleanup_pools || error "cleanup_pools failed"
2020 run_test 27D "validate llapi_layout API"
2022 # Verify that default_easize is increased from its initial value after
2023 # accessing a widely striped file.
2025 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs" && return
2027 # 72 bytes is the minimum space required to store striping
2028 # information for a file striped across one OST:
2029 # (sizeof(struct lov_user_md_v3) +
2030 # sizeof(struct lov_user_ost_data_v1))
2032 $LCTL set_param -n llite.*.default_easize $min_easize ||
2033 error "lctl set_param failed"
2034 local easize=$($LCTL get_param -n llite.*.default_easize)
2036 [ $easize -eq $min_easize ] ||
2037 error "failed to set default_easize"
2039 $LFS setstripe -c $OSTCOUNT $DIR/$tfile ||
2040 error "setstripe failed"
2044 easize=$($LCTL get_param -n llite.*.default_easize)
2046 [ $easize -gt $min_easize ] ||
2047 error "default_easize not updated"
2049 run_test 27E "check that default extended attribute size properly increases"
2051 # createtest also checks that device nodes are created and
2052 # then visible correctly (#2091)
2053 test_28() { # bug 2091
2055 $CREATETEST $DIR/d28/ct || error
2057 run_test 28 "create/mknod/mkdir with bad file types ============"
2060 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2061 cancel_lru_locks mdc
2067 declare -i LOCKCOUNTORIG=0
2068 for lock_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_count); do
2069 let LOCKCOUNTORIG=$LOCKCOUNTORIG+$lock_count
2071 [ $LOCKCOUNTORIG -eq 0 ] && echo "No mdc lock count" && return 1
2073 declare -i LOCKUNUSEDCOUNTORIG=0
2074 for unused_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_unused_count); do
2075 let LOCKUNUSEDCOUNTORIG=$LOCKUNUSEDCOUNTORIG+$unused_count
2082 declare -i LOCKCOUNTCURRENT=0
2083 for lock_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_count); do
2084 let LOCKCOUNTCURRENT=$LOCKCOUNTCURRENT+$lock_count
2087 declare -i LOCKUNUSEDCOUNTCURRENT=0
2088 for unused_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_unused_count); do
2089 let LOCKUNUSEDCOUNTCURRENT=$LOCKUNUSEDCOUNTCURRENT+$unused_count
2092 if [[ $LOCKCOUNTCURRENT -gt $LOCKCOUNTORIG ]]; then
2093 $LCTL set_param -n ldlm.dump_namespaces ""
2094 error "CURRENT: $LOCKCOUNTCURRENT > $LOCKCOUNTORIG"
2095 $LCTL dk | sort -k4 -t: > $TMP/test_29.dk
2096 log "dumped log to $TMP/test_29.dk (bug 5793)"
2099 if [[ $LOCKUNUSEDCOUNTCURRENT -gt $LOCKUNUSEDCOUNTORIG ]]; then
2100 error "UNUSED: $LOCKUNUSEDCOUNTCURRENT > $LOCKUNUSEDCOUNTORIG"
2101 $LCTL dk | sort -k4 -t: > $TMP/test_29.dk
2102 log "dumped log to $TMP/test_29.dk (bug 5793)"
2106 run_test 29 "IT_GETATTR regression ============================"
2108 test_30a() { # was test_30
2109 cp $(which ls) $DIR || cp /bin/ls $DIR
2113 run_test 30a "execute binary from Lustre (execve) =============="
2116 cp `which ls` $DIR || cp /bin/ls $DIR
2118 $RUNAS $DIR/ls / || error
2121 run_test 30b "execute binary from Lustre as non-root ==========="
2123 test_30c() { # b=22376
2124 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2125 cp `which ls` $DIR || cp /bin/ls $DIR
2127 cancel_lru_locks mdc
2128 cancel_lru_locks osc
2129 $RUNAS $DIR/ls / || error
2132 run_test 30c "execute binary from Lustre without read perms ===="
2135 $OPENUNLINK $DIR/f31 $DIR/f31 || error
2136 $CHECKSTAT -a $DIR/f31 || error
2138 run_test 31a "open-unlink file =================================="
2141 touch $DIR/f31 || error
2142 ln $DIR/f31 $DIR/f31b || error
2143 $MULTIOP $DIR/f31b Ouc || error
2144 $CHECKSTAT -t file $DIR/f31 || error
2146 run_test 31b "unlink file with multiple links while open ======="
2149 touch $DIR/f31 || error
2150 ln $DIR/f31 $DIR/f31c || error
2151 multiop_bg_pause $DIR/f31 O_uc || return 1
2153 $MULTIOP $DIR/f31c Ouc
2154 kill -USR1 $MULTIPID
2157 run_test 31c "open-unlink file with multiple links ============="
2160 opendirunlink $DIR/d31d $DIR/d31d || error
2161 $CHECKSTAT -a $DIR/d31d || error
2163 run_test 31d "remove of open directory ========================="
2165 test_31e() { # bug 2904
2166 openfilleddirunlink $DIR/d31e || error
2168 run_test 31e "remove of open non-empty directory ==============="
2170 test_31f() { # bug 4554
2171 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2173 test_mkdir $DIR/d31f
2174 $SETSTRIPE -S 1048576 -c 1 $DIR/d31f
2175 cp /etc/hosts $DIR/d31f
2177 $GETSTRIPE $DIR/d31f/hosts
2178 multiop_bg_pause $DIR/d31f D_c || return 1
2181 rm -rv $DIR/d31f || error "first of $DIR/d31f"
2182 test_mkdir $DIR/d31f
2183 $SETSTRIPE -S 1048576 -c 1 $DIR/d31f
2184 cp /etc/hosts $DIR/d31f
2186 $GETSTRIPE $DIR/d31f/hosts
2187 multiop_bg_pause $DIR/d31f D_c || return 1
2190 kill -USR1 $MULTIPID || error "first opendir $MULTIPID not running"
2191 wait $MULTIPID || error "first opendir $MULTIPID failed"
2195 kill -USR1 $MULTIPID2 || error "second opendir $MULTIPID not running"
2196 wait $MULTIPID2 || error "second opendir $MULTIPID2 failed"
2199 run_test 31f "remove of open directory with open-unlink file ==="
2202 echo "-- cross directory link --"
2203 test_mkdir -c1 $DIR/${tdir}ga
2204 test_mkdir -c1 $DIR/${tdir}gb
2205 touch $DIR/${tdir}ga/f
2206 ln $DIR/${tdir}ga/f $DIR/${tdir}gb/g
2207 $CHECKSTAT -t file $DIR/${tdir}ga/f || error "source"
2208 [ `stat -c%h $DIR/${tdir}ga/f` == '2' ] || error "source nlink"
2209 $CHECKSTAT -t file $DIR/${tdir}gb/g || error "target"
2210 [ `stat -c%h $DIR/${tdir}gb/g` == '2' ] || error "target nlink"
2212 run_test 31g "cross directory link==============="
2215 echo "-- cross directory link --"
2216 test_mkdir -c1 $DIR/${tdir}
2217 test_mkdir -c1 $DIR/${tdir}/dir
2218 touch $DIR/${tdir}/f
2219 ln $DIR/${tdir}/f $DIR/${tdir}/dir/g
2220 $CHECKSTAT -t file $DIR/${tdir}/f || error "source"
2221 [ `stat -c%h $DIR/${tdir}/f` == '2' ] || error "source nlink"
2222 $CHECKSTAT -t file $DIR/${tdir}/dir/g || error "target"
2223 [ `stat -c%h $DIR/${tdir}/dir/g` == '2' ] || error "target nlink"
2225 run_test 31h "cross directory link under child==============="
2228 echo "-- cross directory link --"
2229 test_mkdir -c1 $DIR/$tdir
2230 test_mkdir -c1 $DIR/$tdir/dir
2231 touch $DIR/$tdir/dir/f
2232 ln $DIR/$tdir/dir/f $DIR/$tdir/g
2233 $CHECKSTAT -t file $DIR/$tdir/dir/f || error "source"
2234 [ `stat -c%h $DIR/$tdir/dir/f` == '2' ] || error "source nlink"
2235 $CHECKSTAT -t file $DIR/$tdir/g || error "target"
2236 [ `stat -c%h $DIR/$tdir/g` == '2' ] || error "target nlink"
2238 run_test 31i "cross directory link under parent==============="
2241 test_mkdir -c1 -p $DIR/$tdir
2242 test_mkdir -c1 -p $DIR/$tdir/dir1
2243 ln $DIR/$tdir/dir1 $DIR/$tdir/dir2 && error "ln for dir"
2244 link $DIR/$tdir/dir1 $DIR/$tdir/dir3 && error "link for dir"
2245 mlink $DIR/$tdir/dir1 $DIR/$tdir/dir4 && error "mlink for dir"
2246 mlink $DIR/$tdir/dir1 $DIR/$tdir/dir1 && error "mlink to the same dir"
2249 run_test 31j "link for directory==============="
2252 test_mkdir -c1 -p $DIR/$tdir
2254 touch $DIR/$tdir/exist
2255 mlink $DIR/$tdir/s $DIR/$tdir/t || error "mlink"
2256 mlink $DIR/$tdir/s $DIR/$tdir/exist && error "mlink to exist file"
2257 mlink $DIR/$tdir/s $DIR/$tdir/s && error "mlink to the same file"
2258 mlink $DIR/$tdir/s $DIR/$tdir && error "mlink to parent dir"
2259 mlink $DIR/$tdir $DIR/$tdir/s && error "mlink parent dir to target"
2260 mlink $DIR/$tdir/not-exist $DIR/$tdir/foo && error "mlink non-existing to new"
2261 mlink $DIR/$tdir/not-exist $DIR/$tdir/s && error "mlink non-existing to exist"
2264 run_test 31k "link to file: the same, non-existing, dir==============="
2270 touch $DIR/d31m2/exist
2271 mlink $DIR/d31m/s $DIR/d31m2/t || error "mlink"
2272 mlink $DIR/d31m/s $DIR/d31m2/exist && error "mlink to exist file"
2273 mlink $DIR/d31m/s $DIR/d31m2 && error "mlink to parent dir"
2274 mlink $DIR/d31m2 $DIR/d31m/s && error "mlink parent dir to target"
2275 mlink $DIR/d31m/not-exist $DIR/d31m2/foo && error "mlink non-existing to new"
2276 mlink $DIR/d31m/not-exist $DIR/d31m2/s && error "mlink non-existing to exist"
2279 run_test 31m "link to file: the same, non-existing, dir==============="
2282 touch $DIR/$tfile || error "cannot create '$DIR/$tfile'"
2283 nlink=$(stat --format=%h $DIR/$tfile)
2284 [ ${nlink:--1} -eq 1 ] || error "nlink is $nlink, expected 1"
2286 local cmd="exec $fd<$DIR/$tfile"
2289 trap "eval $cmd" EXIT
2290 nlink=$(stat --dereference --format=%h /proc/self/fd/$fd)
2291 [ ${nlink:--1} -eq 1 ] || error "nlink is $nlink, expected 1"
2292 rm $DIR/$tfile || error "cannot remove '$DIR/$tfile'"
2293 nlink=$(stat --dereference --format=%h /proc/self/fd/$fd)
2294 [ ${nlink:--1} -eq 0 ] || error "nlink is $nlink, expected 0"
2297 run_test 31n "check link count of unlinked file"
2300 local TEMPNAME=$(mktemp $1_XXXXXX)
2301 mlink $TEMPNAME $1 2> /dev/null &&
2302 echo "$BASHPID: link $TEMPNAME to $1 succeeded"
2306 test_31o() { # LU-2901
2308 for LOOP in $(seq 100); do
2309 rm -f $DIR/$tdir/$tfile*
2310 for THREAD in $(seq 8); do
2311 link_one $DIR/$tdir/$tfile.$LOOP &
2314 local LINKS=$(ls -1 $DIR/$tdir | grep -c $tfile.$LOOP)
2315 [[ $LINKS -gt 1 ]] && ls $DIR/$tdir &&
2316 error "$LINKS duplicate links to $tfile.$LOOP" &&
2320 run_test 31o "duplicate hard links with same filename"
2323 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2326 $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
2327 $LFS setdirstripe -D -c2 -t all_char $DIR/$tdir/striped_dir
2329 opendirunlink $DIR/$tdir/striped_dir/test1 ||
2330 error "open unlink test1 failed"
2331 opendirunlink $DIR/$tdir/striped_dir/test2 ||
2332 error "open unlink test2 failed"
2334 $CHECKSTAT -a $DIR/$tdir/striped_dir/test1 ||
2335 error "test1 still exists"
2336 $CHECKSTAT -a $DIR/$tdir/striped_dir/test2 ||
2337 error "test2 still exists"
2339 run_test 31p "remove of open striped directory"
2341 cleanup_test32_mount() {
2343 $UMOUNT -d $DIR/$tdir/ext2-mountpoint
2347 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2348 echo "== more mountpoints and symlinks ================="
2349 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2350 trap cleanup_test32_mount EXIT
2351 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2352 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2353 $CHECKSTAT -t dir $DIR/$tdir/ext2-mountpoint/.. || error
2354 cleanup_test32_mount
2356 run_test 32a "stat d32a/ext2-mountpoint/.. ====================="
2359 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2360 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2361 trap cleanup_test32_mount EXIT
2362 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2363 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2364 ls -al $DIR/$tdir/ext2-mountpoint/.. || error
2365 cleanup_test32_mount
2367 run_test 32b "open d32b/ext2-mountpoint/.. ====================="
2370 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2371 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2372 trap cleanup_test32_mount EXIT
2373 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2374 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2375 test_mkdir -p $DIR/$tdir/d2/test_dir
2376 $CHECKSTAT -t dir $DIR/$tdir/ext2-mountpoint/../d2/test_dir || error
2377 cleanup_test32_mount
2379 run_test 32c "stat d32c/ext2-mountpoint/../d2/test_dir ========="
2382 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2383 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2384 trap cleanup_test32_mount EXIT
2385 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2386 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2387 test_mkdir -p $DIR/$tdir/d2/test_dir
2388 ls -al $DIR/$tdir/ext2-mountpoint/../d2/test_dir || error
2389 cleanup_test32_mount
2391 run_test 32d "open d32d/ext2-mountpoint/../d2/test_dir ========="
2394 [ -e $DIR/d32e ] && rm -fr $DIR/d32e
2395 test_mkdir -p $DIR/d32e/tmp
2396 TMP_DIR=$DIR/d32e/tmp
2397 ln -s $DIR/d32e $TMP_DIR/symlink11
2398 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
2399 $CHECKSTAT -t link $DIR/d32e/tmp/symlink11 || error
2400 $CHECKSTAT -t link $DIR/d32e/symlink01 || error
2402 run_test 32e "stat d32e/symlink->tmp/symlink->lustre-subdir ===="
2405 [ -e $DIR/d32f ] && rm -fr $DIR/d32f
2406 test_mkdir -p $DIR/d32f/tmp
2407 TMP_DIR=$DIR/d32f/tmp
2408 ln -s $DIR/d32f $TMP_DIR/symlink11
2409 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
2410 ls $DIR/d32f/tmp/symlink11 || error
2411 ls $DIR/d32f/symlink01 || error
2413 run_test 32f "open d32f/symlink->tmp/symlink->lustre-subdir ===="
2416 TMP_DIR=$DIR/$tdir/tmp
2417 test_mkdir -p $DIR/$tdir/tmp
2418 test_mkdir $DIR/${tdir}2
2419 ln -s $DIR/${tdir}2 $TMP_DIR/symlink12
2420 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
2421 $CHECKSTAT -t link $TMP_DIR/symlink12 || error
2422 $CHECKSTAT -t link $DIR/$tdir/symlink02 || error
2423 $CHECKSTAT -t dir -f $TMP_DIR/symlink12 || error
2424 $CHECKSTAT -t dir -f $DIR/$tdir/symlink02 || error
2426 run_test 32g "stat d32g/symlink->tmp/symlink->lustre-subdir/${tdir}2"
2429 rm -fr $DIR/$tdir $DIR/${tdir}2
2430 TMP_DIR=$DIR/$tdir/tmp
2431 test_mkdir -p $DIR/$tdir/tmp
2432 test_mkdir $DIR/${tdir}2
2433 ln -s $DIR/${tdir}2 $TMP_DIR/symlink12
2434 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
2435 ls $TMP_DIR/symlink12 || error
2436 ls $DIR/$tdir/symlink02 || error
2438 run_test 32h "open d32h/symlink->tmp/symlink->lustre-subdir/${tdir}2"
2441 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2442 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2443 trap cleanup_test32_mount EXIT
2444 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2445 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2446 touch $DIR/$tdir/test_file
2447 $CHECKSTAT -t file $DIR/$tdir/ext2-mountpoint/../test_file || error
2448 cleanup_test32_mount
2450 run_test 32i "stat d32i/ext2-mountpoint/../test_file ==========="
2453 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2454 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2455 trap cleanup_test32_mount EXIT
2456 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2457 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2458 touch $DIR/$tdir/test_file
2459 cat $DIR/$tdir/ext2-mountpoint/../test_file || error
2460 cleanup_test32_mount
2462 run_test 32j "open d32j/ext2-mountpoint/../test_file ==========="
2465 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2467 trap cleanup_test32_mount EXIT
2468 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2469 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint
2470 test_mkdir -p $DIR/$tdir/d2
2471 touch $DIR/$tdir/d2/test_file || error
2472 $CHECKSTAT -t file $DIR/$tdir/ext2-mountpoint/../d2/test_file || error
2473 cleanup_test32_mount
2475 run_test 32k "stat d32k/ext2-mountpoint/../d2/test_file ========"
2478 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2480 trap cleanup_test32_mount EXIT
2481 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2482 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2483 test_mkdir -p $DIR/$tdir/d2
2484 touch $DIR/$tdir/d2/test_file
2485 cat $DIR/$tdir/ext2-mountpoint/../d2/test_file || error
2486 cleanup_test32_mount
2488 run_test 32l "open d32l/ext2-mountpoint/../d2/test_file ========"
2492 test_mkdir -p $DIR/d32m/tmp
2493 TMP_DIR=$DIR/d32m/tmp
2494 ln -s $DIR $TMP_DIR/symlink11
2495 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
2496 $CHECKSTAT -t link $DIR/d32m/tmp/symlink11 || error
2497 $CHECKSTAT -t link $DIR/d32m/symlink01 || error
2499 run_test 32m "stat d32m/symlink->tmp/symlink->lustre-root ======"
2503 test_mkdir -p $DIR/d32n/tmp
2504 TMP_DIR=$DIR/d32n/tmp
2505 ln -s $DIR $TMP_DIR/symlink11
2506 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
2507 ls -l $DIR/d32n/tmp/symlink11 || error
2508 ls -l $DIR/d32n/symlink01 || error
2510 run_test 32n "open d32n/symlink->tmp/symlink->lustre-root ======"
2514 test_mkdir -p $DIR/d32o/tmp
2515 TMP_DIR=$DIR/d32o/tmp
2516 ln -s $DIR/$tfile $TMP_DIR/symlink12
2517 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
2518 $CHECKSTAT -t link $DIR/d32o/tmp/symlink12 || error
2519 $CHECKSTAT -t link $DIR/d32o/symlink02 || error
2520 $CHECKSTAT -t file -f $DIR/d32o/tmp/symlink12 || error
2521 $CHECKSTAT -t file -f $DIR/d32o/symlink02 || error
2523 run_test 32o "stat d32o/symlink->tmp/symlink->lustre-root/$tfile"
2533 test_mkdir -p $DIR/d32p/tmp
2535 TMP_DIR=$DIR/d32p/tmp
2537 ln -s $DIR/$tfile $TMP_DIR/symlink12
2539 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
2541 cat $DIR/d32p/tmp/symlink12 || error
2543 cat $DIR/d32p/symlink02 || error
2546 run_test 32p "open d32p/symlink->tmp/symlink->lustre-root/$tfile"
2548 cleanup_testdir_mount() {
2550 $UMOUNT -d $DIR/$tdir
2554 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2555 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2556 trap cleanup_testdir_mount EXIT
2557 test_mkdir -p $DIR/$tdir
2558 touch $DIR/$tdir/under_the_mount
2559 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir
2560 ls $DIR/$tdir | grep "\<under_the_mount\>" && error
2561 cleanup_testdir_mount
2563 run_test 32q "stat follows mountpoints in Lustre (should return error)"
2566 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2567 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2568 trap cleanup_testdir_mount EXIT
2569 test_mkdir -p $DIR/$tdir
2570 touch $DIR/$tdir/under_the_mount
2571 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir
2572 ls $DIR/$tdir | grep -q under_the_mount && error || true
2573 cleanup_testdir_mount
2575 run_test 32r "opendir follows mountpoints in Lustre (should return error)"
2580 chmod 444 $DIR/$tfile
2581 chown $RUNAS_ID $DIR/$tfile
2583 $RUNAS $OPENFILE -f O_RDWR $DIR/$tfile && error || true
2586 run_test 33aa "write file with mode 444 (should return error) ===="
2590 test_mkdir -p $DIR/d33
2591 chown $RUNAS_ID $DIR/d33
2592 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $DIR/d33/f33|| error "create"
2593 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $DIR/d33/f33 && \
2594 error "open RDWR" || true
2596 run_test 33a "test open file(mode=0444) with O_RDWR (should return error)"
2600 test_mkdir -p $DIR/d33
2601 chown $RUNAS_ID $DIR/d33
2602 $RUNAS $OPENFILE -f 1286739555 $DIR/d33/f33 || true
2604 run_test 33b "test open file with malformed flags (No panic)"
2607 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2613 remote_ost_nodsh && skip "remote OST with nodsh" && return
2616 test_mkdir -p $DIR/d33
2617 # Read: 0, Write: 4, create/destroy: 2/0, stat: 1, punch: 0
2620 for ostnum in $(seq $OSTCOUNT); do
2621 # test-framework's OST numbering is one-based, while Lustre's
2623 ostname=$(printf "$FSNAME-OST%.4x" $((ostnum - 1)))
2624 # Parsing llobdstat's output sucks; we could grep the /proc
2625 # path, but that's likely to not be as portable as using the
2626 # llobdstat utility. So we parse lctl output instead.
2627 write_bytes=$(do_facet ost$ostnum lctl get_param -n \
2628 obdfilter/$ostname/stats |
2629 awk '/^write_bytes/ {print $7}' )
2630 echo "baseline_write_bytes@$OSTnum/$ostname=$write_bytes"
2631 if (( ${write_bytes:-0} > 0 ))
2638 $all_zeros || return 0
2641 echo foo > $DIR/d33/bar
2645 # Total up write_bytes after writing. We'd better find non-zeros.
2646 for ostnum in $(seq $OSTCOUNT); do
2647 ostname=$(printf "$FSNAME-OST%.4x" $((ostnum - 1)))
2648 write_bytes=$(do_facet ost$ostnum lctl get_param -n \
2649 obdfilter/$ostname/stats |
2650 awk '/^write_bytes/ {print $7}' )
2651 echo "write_bytes@$OSTnum/$ostname=$write_bytes"
2652 if (( ${write_bytes:-0} > 0 ))
2661 for ostnum in $(seq $OSTCOUNT); do
2662 ostname=$(printf "$FSNAME-OST%.4x" $((ostnum - 1)))
2663 echo "Check that write_bytes is present in obdfilter/*/stats:"
2664 do_facet ost$ostnum lctl get_param -n \
2665 obdfilter/$ostname/stats
2667 error "OST not keeping write_bytes stats (b22312)"
2670 run_test 33c "test llobdstat and write_bytes"
2673 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 2 MDTs" && return
2674 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2676 local remote_dir=$DIR/$tdir/remote_dir
2679 $LFS mkdir -i $MDTIDX $remote_dir ||
2680 error "create remote directory failed"
2682 touch $remote_dir/$tfile
2683 chmod 444 $remote_dir/$tfile
2684 chown $RUNAS_ID $remote_dir/$tfile
2686 $RUNAS $OPENFILE -f O_RDWR $DIR/$tfile && error || true
2688 chown $RUNAS_ID $remote_dir
2689 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $remote_dir/f33 ||
2690 error "create" || true
2691 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $remote_dir/f33 &&
2692 error "open RDWR" || true
2693 $RUNAS $OPENFILE -f 1286739555 $remote_dir/f33 &&
2694 error "create" || true
2696 run_test 33d "openfile with 444 modes and malformed flags under remote dir"
2699 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2703 $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
2704 $LFS setdirstripe -i1 -c2 $DIR/$tdir/striped_dir1
2705 mkdir $DIR/$tdir/local_dir
2707 local s0_mode=$(stat -c%f $DIR/$tdir/striped_dir)
2708 local s1_mode=$(stat -c%f $DIR/$tdir/striped_dir1)
2709 local l_mode=$(stat -c%f $DIR/$tdir/local_dir)
2711 [ "$l_mode" = "$s0_mode" -a "$l_mode" = "$s1_mode" ] ||
2712 error "mkdir $l_mode striped0 $s0_mode striped1 $s1_mode"
2714 rmdir $DIR/$tdir/* || error "rmdir failed"
2717 $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
2718 $LFS setdirstripe -i1 -c2 $DIR/$tdir/striped_dir1
2719 mkdir $DIR/$tdir/local_dir
2721 s0_mode=$(stat -c%f $DIR/$tdir/striped_dir)
2722 s1_mode=$(stat -c%f $DIR/$tdir/striped_dir1)
2723 l_mode=$(stat -c%f $DIR/$tdir/local_dir)
2725 [ "$l_mode" = "$s0_mode" -a "$l_mode" = "$s1_mode" ] ||
2726 error "mkdir $l_mode striped0 $s0_mode striped1 $s1_mode 777"
2728 rmdir $DIR/$tdir/* || error "rmdir(umask 777) failed"
2731 $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
2732 $LFS setdirstripe -i1 -c2 $DIR/$tdir/striped_dir1
2733 mkdir $DIR/$tdir/local_dir
2735 s0_mode=$(stat -c%f $DIR/$tdir/striped_dir)
2736 s1_mode=$(stat -c%f $DIR/$tdir/striped_dir1)
2737 l_mode=$(stat -c%f $DIR/$tdir/local_dir)
2739 [ "$l_mode" = "$s0_mode" -a "$l_mode" = "$s1_mode" ] ||
2740 error "mkdir $l_mode striped0 $s0_mode striped1 $s1_mode 0"
2742 run_test 33e "mkdir and striped directory should have same mode"
2746 do_facet $SINGLEMDS $LCTL set_param mdt.*.enable_remote_dir_gid=0
2750 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2753 chmod go+rwx $DIR/$tdir
2754 do_facet $SINGLEMDS $LCTL set_param mdt.*.enable_remote_dir_gid=-1
2755 trap cleanup_33f EXIT
2757 $RUNAS lfs mkdir -c$MDSCOUNT $DIR/$tdir/striped_dir ||
2758 error "cannot create striped directory"
2760 $RUNAS touch $DIR/$tdir/striped_dir/{0..16} ||
2761 error "cannot create files in striped directory"
2763 $RUNAS rm $DIR/$tdir/striped_dir/{0..16} ||
2764 error "cannot remove files in striped directory"
2766 $RUNAS rmdir $DIR/$tdir/striped_dir ||
2767 error "cannot remove striped directory"
2771 run_test 33f "nonroot user can create, access, and remove a striped directory"
2773 TEST_34_SIZE=${TEST_34_SIZE:-2000000000000}
2776 $MCREATE $DIR/f34 || error
2777 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" || error
2778 $TRUNCATE $DIR/f34 $TEST_34_SIZE || error
2779 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" || error
2780 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2782 run_test 34a "truncate file that has not been opened ==========="
2785 [ ! -f $DIR/f34 ] && test_34a
2786 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2787 $OPENFILE -f O_RDONLY $DIR/f34
2788 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" || error
2789 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2791 run_test 34b "O_RDONLY opening file doesn't create objects ====="
2794 [ ! -f $DIR/f34 ] && test_34a
2795 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2796 $OPENFILE -f O_RDWR $DIR/f34
2797 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" && error
2798 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2800 run_test 34c "O_RDWR opening file-with-size works =============="
2803 [ ! -f $DIR/f34 ] && test_34a
2804 dd if=/dev/zero of=$DIR/f34 conv=notrunc bs=4k count=1 || error
2805 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2808 run_test 34d "write to sparse file ============================="
2812 $MCREATE $DIR/f34e || error
2813 $TRUNCATE $DIR/f34e 1000 || error
2814 $CHECKSTAT -s 1000 $DIR/f34e || error
2815 $OPENFILE -f O_RDWR $DIR/f34e
2816 $CHECKSTAT -s 1000 $DIR/f34e || error
2818 run_test 34e "create objects, some with size and some without =="
2820 test_34f() { # bug 6242, 6243
2821 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2824 $MCREATE $DIR/f34f || error
2825 $TRUNCATE $DIR/f34f $SIZE34F || error "truncating $DIR/f3f to $SIZE34F"
2826 dd if=$DIR/f34f of=$TMP/f34f
2827 $CHECKSTAT -s $SIZE34F $TMP/f34f || error "$TMP/f34f not $SIZE34F bytes"
2828 dd if=/dev/zero of=$TMP/f34fzero bs=$SIZE34F count=1
2829 cmp $DIR/f34f $TMP/f34fzero || error "$DIR/f34f not all zero"
2830 cmp $TMP/f34f $TMP/f34fzero || error "$TMP/f34f not all zero"
2831 rm $TMP/f34f $TMP/f34fzero $DIR/f34f
2833 run_test 34f "read from a file with no objects until EOF ======="
2836 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2837 dd if=/dev/zero of=$DIR/$tfile bs=1 count=100 seek=$TEST_34_SIZE || error
2838 $TRUNCATE $DIR/$tfile $((TEST_34_SIZE / 2))|| error
2839 $CHECKSTAT -s $((TEST_34_SIZE / 2)) $DIR/$tfile || error "truncate failed"
2840 cancel_lru_locks osc
2841 $CHECKSTAT -s $((TEST_34_SIZE / 2)) $DIR/$tfile || \
2842 error "wrong size after lock cancel"
2844 $TRUNCATE $DIR/$tfile $TEST_34_SIZE || error
2845 $CHECKSTAT -s $TEST_34_SIZE $DIR/$tfile || \
2846 error "expanding truncate failed"
2847 cancel_lru_locks osc
2848 $CHECKSTAT -s $TEST_34_SIZE $DIR/$tfile || \
2849 error "wrong expanded size after lock cancel"
2851 run_test 34g "truncate long file ==============================="
2854 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2858 dd if=/dev/zero of=$DIR/$tfile bs=1M count=10 || error
2859 sync # Flush the cache so that multiop below does not block on cache
2860 # flush when getting the group lock
2861 $MULTIOP $DIR/$tfile OG${gid}T${sz}g${gid}c &
2864 # Since just timed wait is not good enough, let's do a sync write
2865 # that way we are sure enough time for a roundtrip + processing
2866 # passed + 2 seconds of extra margin.
2867 dd if=/dev/zero of=$DIR/${tfile}-1 bs=4096 oflag=direct count=1
2871 if [[ `ps h -o comm -p $MULTIPID` == "multiop" ]]; then
2872 error "Multiop blocked on ftruncate, pid=$MULTIPID"
2876 local nsz=`stat -c %s $DIR/$tfile`
2877 [[ $nsz == $sz ]] || error "New size wrong $nsz != $sz"
2879 run_test 34h "ftruncate file under grouplock should not block"
2882 cp /bin/sh $DIR/f35a
2884 chown $RUNAS_ID $DIR/f35a
2885 $RUNAS $DIR/f35a && error || true
2888 run_test 35a "exec file with mode 444 (should return and not leak) ====="
2892 utime $DIR/f36 || error
2894 run_test 36a "MDS utime check (mknod, utime) ==================="
2898 utime $DIR/f36 || error
2900 run_test 36b "OST utime check (open, utime) ===================="
2905 chown $RUNAS_ID $DIR/d36
2906 $RUNAS utime $DIR/d36/f36 || error
2908 run_test 36c "non-root MDS utime check (mknod, utime) =========="
2911 [ ! -d $DIR/d36 ] && test_36c
2912 echo "" > $DIR/d36/f36
2913 $RUNAS utime $DIR/d36/f36 || error
2915 run_test 36d "non-root OST utime check (open, utime) ==========="
2918 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID -- skipping" && return
2919 test_mkdir -p $DIR/$tdir
2920 touch $DIR/$tdir/$tfile
2921 $RUNAS utime $DIR/$tdir/$tfile && \
2922 error "utime worked, expected failure" || true
2924 run_test 36e "utime on non-owned file (should return error) ===="
2928 local LANG_SAVE=$LANG
2929 local LC_LANG_SAVE=$LC_LANG
2930 export LANG=C LC_LANG=C # for date language
2932 DATESTR="Dec 20 2000"
2933 test_mkdir -p $DIR/$tdir
2934 lctl set_param fail_loc=$fl
2936 cp /etc/hosts $DIR/$tdir/$tfile
2937 sync & # write RPC generated with "current" inode timestamp, but delayed
2939 touch --date="$DATESTR" $DIR/$tdir/$tfile # setattr timestamp in past
2940 LS_BEFORE="`ls -l $DIR/$tdir/$tfile`" # old timestamp from client cache
2941 cancel_lru_locks osc
2942 LS_AFTER="`ls -l $DIR/$tdir/$tfile`" # timestamp from OST object
2944 [ "$LS_BEFORE" != "$LS_AFTER" ] && \
2945 echo "BEFORE: $LS_BEFORE" && \
2946 echo "AFTER : $LS_AFTER" && \
2947 echo "WANT : $DATESTR" && \
2948 error "$DIR/$tdir/$tfile timestamps changed" || true
2950 export LANG=$LANG_SAVE LC_LANG=$LC_LANG_SAVE
2954 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2955 #define OBD_FAIL_OST_BRW_PAUSE_BULK 0x214
2956 subr_36fh "0x80000214"
2958 run_test 36f "utime on file racing with OST BRW write =========="
2961 remote_ost_nodsh && skip "remote OST with nodsh" && return
2962 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2967 test_mkdir -p $DIR/$tdir
2968 fmd_max_age=$(do_facet ost1 \
2969 "lctl get_param -n obdfilter.*.client_cache_seconds 2> /dev/null | \
2972 fmd_before=$(do_facet ost1 \
2973 "awk '/ll_fmd_cache/ {print \\\$2}' /proc/slabinfo")
2974 touch $DIR/$tdir/$tfile
2975 sleep $((fmd_max_age + 12))
2976 fmd_after=$(do_facet ost1 \
2977 "awk '/ll_fmd_cache/ {print \\\$2}' /proc/slabinfo")
2979 echo "fmd_before: $fmd_before"
2980 echo "fmd_after: $fmd_after"
2981 [[ $fmd_after -gt $fmd_before ]] &&
2982 echo "AFTER: $fmd_after > BEFORE: $fmd_before" &&
2983 error "fmd didn't expire after ping" || true
2985 run_test 36g "filter mod data cache expiry ====================="
2988 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2989 #define OBD_FAIL_OST_BRW_PAUSE_BULK2 0x227
2990 subr_36fh "0x80000227"
2992 run_test 36h "utime on file racing with OST BRW write =========="
2995 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2998 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR/$tdir/striped_dir
3000 local mtime=$(stat -c%Y $DIR/$tdir/striped_dir)
3001 local new_mtime=$((mtime + 200))
3003 #change Modify time of striped dir
3004 touch -m -d @$new_mtime $DIR/$tdir/striped_dir ||
3005 error "change mtime failed"
3007 local got=$(stat -c%Y $DIR/$tdir/striped_dir)
3009 [ "$new_mtime" = "$got" ] || error "expect $new_mtime got $got"
3011 run_test 36i "change mtime on striped directory"
3013 # test_37 - duplicate with tests 32q 32r
3016 local file=$DIR/$tfile
3018 openfile -f O_DIRECTORY $file
3021 [ $RC -eq 0 ] && error "opened file $file with O_DIRECTORY" || true
3022 [ $RC -eq $ENOTDIR ] || error "error $RC should be ENOTDIR ($ENOTDIR)"
3024 run_test 38 "open a regular file with O_DIRECTORY should return -ENOTDIR ==="
3028 touch $DIR/${tfile}2
3029 # ls -l $DIR/$tfile $DIR/${tfile}2
3030 # ls -lu $DIR/$tfile $DIR/${tfile}2
3031 # ls -lc $DIR/$tfile $DIR/${tfile}2
3033 $OPENFILE -f O_CREAT:O_TRUNC:O_WRONLY $DIR/${tfile}2
3034 if [ ! $DIR/${tfile}2 -nt $DIR/$tfile ]; then
3036 ls -l --full-time $DIR/$tfile $DIR/${tfile}2
3038 ls -lu --full-time $DIR/$tfile $DIR/${tfile}2
3040 ls -lc --full-time $DIR/$tfile $DIR/${tfile}2
3041 error "O_TRUNC didn't change timestamps"
3044 run_test 39 "mtime changed on create ==========================="
3047 test_mkdir -p -c1 $DIR/$tdir
3048 cp -p /etc/passwd $DIR/$tdir/fopen
3049 cp -p /etc/passwd $DIR/$tdir/flink
3050 cp -p /etc/passwd $DIR/$tdir/funlink
3051 cp -p /etc/passwd $DIR/$tdir/frename
3052 ln $DIR/$tdir/funlink $DIR/$tdir/funlink2
3055 echo "aaaaaa" >> $DIR/$tdir/fopen
3056 echo "aaaaaa" >> $DIR/$tdir/flink
3057 echo "aaaaaa" >> $DIR/$tdir/funlink
3058 echo "aaaaaa" >> $DIR/$tdir/frename
3060 local open_new=`stat -c %Y $DIR/$tdir/fopen`
3061 local link_new=`stat -c %Y $DIR/$tdir/flink`
3062 local unlink_new=`stat -c %Y $DIR/$tdir/funlink`
3063 local rename_new=`stat -c %Y $DIR/$tdir/frename`
3065 cat $DIR/$tdir/fopen > /dev/null
3066 ln $DIR/$tdir/flink $DIR/$tdir/flink2
3067 rm -f $DIR/$tdir/funlink2
3068 mv -f $DIR/$tdir/frename $DIR/$tdir/frename2
3070 for (( i=0; i < 2; i++ )) ; do
3071 local open_new2=`stat -c %Y $DIR/$tdir/fopen`
3072 local link_new2=`stat -c %Y $DIR/$tdir/flink`
3073 local unlink_new2=`stat -c %Y $DIR/$tdir/funlink`
3074 local rename_new2=`stat -c %Y $DIR/$tdir/frename2`
3076 [ $open_new2 -eq $open_new ] || error "open file reverses mtime"
3077 [ $link_new2 -eq $link_new ] || error "link file reverses mtime"
3078 [ $unlink_new2 -eq $unlink_new ] || error "unlink file reverses mtime"
3079 [ $rename_new2 -eq $rename_new ] || error "rename file reverses mtime"
3081 cancel_lru_locks osc
3082 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3085 run_test 39b "mtime change on open, link, unlink, rename ======"
3087 # this should be set to past
3088 TEST_39_MTIME=`date -d "1 year ago" +%s`
3094 local mtime0=`stat -c %Y $DIR1/$tfile`
3096 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3097 local mtime1=`stat -c %Y $DIR1/$tfile`
3098 [ "$mtime1" = $TEST_39_MTIME ] || \
3099 error "mtime is not set to past: $mtime1, should be $TEST_39_MTIME"
3102 echo hello >> $DIR1/$tfile
3104 local mtime2=`stat -c %Y $DIR1/$tfile`
3105 [ "$mtime2" -ge "$d1" ] && [ "$mtime2" -le "$d2" ] || \
3106 error "mtime is not updated on write: $d1 <= $mtime2 <= $d2"
3108 mv $DIR1/$tfile $DIR1/$tfile-1
3110 for (( i=0; i < 2; i++ )) ; do
3111 local mtime3=`stat -c %Y $DIR1/$tfile-1`
3112 [ "$mtime2" = "$mtime3" ] || \
3113 error "mtime ($mtime2) changed (to $mtime3) on rename"
3115 cancel_lru_locks osc
3116 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3119 run_test 39c "mtime change on rename ==========================="
3123 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3126 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3128 for (( i=0; i < 2; i++ )) ; do
3129 local mtime=`stat -c %Y $DIR1/$tfile`
3130 [ $mtime = $TEST_39_MTIME ] || \
3131 error "mtime($mtime) is not set to $TEST_39_MTIME"
3133 cancel_lru_locks osc
3134 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3137 run_test 39d "create, utime, stat =============================="
3141 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3143 local mtime1=`stat -c %Y $DIR1/$tfile`
3145 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3147 for (( i=0; i < 2; i++ )) ; do
3148 local mtime2=`stat -c %Y $DIR1/$tfile`
3149 [ $mtime2 = $TEST_39_MTIME ] || \
3150 error "mtime($mtime2) is not set to $TEST_39_MTIME"
3152 cancel_lru_locks osc
3153 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3156 run_test 39e "create, stat, utime, stat ========================"
3160 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3162 mtime1=`stat -c %Y $DIR1/$tfile`
3165 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3167 for (( i=0; i < 2; i++ )) ; do
3168 local mtime2=`stat -c %Y $DIR1/$tfile`
3169 [ $mtime2 = $TEST_39_MTIME ] || \
3170 error "mtime($mtime2) is not set to $TEST_39_MTIME"
3172 cancel_lru_locks osc
3173 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3176 run_test 39f "create, stat, sleep, utime, stat ================="
3180 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3181 echo hello >> $DIR1/$tfile
3182 local mtime1=`stat -c %Y $DIR1/$tfile`
3185 chmod o+r $DIR1/$tfile
3187 for (( i=0; i < 2; i++ )) ; do
3188 local mtime2=`stat -c %Y $DIR1/$tfile`
3189 [ "$mtime1" = "$mtime2" ] || \
3190 error "lost mtime: $mtime2, should be $mtime1"
3192 cancel_lru_locks osc
3193 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3196 run_test 39g "write, chmod, stat ==============================="
3200 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3205 echo hello >> $DIR1/$tfile
3206 local mtime1=`stat -c %Y $DIR1/$tfile`
3208 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3210 if [ "$d1" != "$d2" ]; then
3211 echo "write and touch not within one second"
3213 for (( i=0; i < 2; i++ )) ; do
3214 local mtime2=`stat -c %Y $DIR1/$tfile`
3215 [ "$mtime2" = $TEST_39_MTIME ] || \
3216 error "lost mtime: $mtime2, should be $TEST_39_MTIME"
3218 cancel_lru_locks osc
3219 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3223 run_test 39h "write, utime within one second, stat ============="
3226 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3230 echo hello >> $DIR1/$tfile
3231 local mtime1=`stat -c %Y $DIR1/$tfile`
3233 mv $DIR1/$tfile $DIR1/$tfile-1
3235 for (( i=0; i < 2; i++ )) ; do
3236 local mtime2=`stat -c %Y $DIR1/$tfile-1`
3238 [ "$mtime1" = "$mtime2" ] || \
3239 error "lost mtime: $mtime2, should be $mtime1"
3241 cancel_lru_locks osc
3242 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3245 run_test 39i "write, rename, stat =============================="
3248 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3249 start_full_debug_logging
3253 #define OBD_FAIL_OSC_DELAY_SETTIME 0x412
3254 lctl set_param fail_loc=0x80000412
3255 multiop_bg_pause $DIR1/$tfile oO_RDWR:w2097152_c ||
3256 error "multiop failed"
3258 local mtime1=`stat -c %Y $DIR1/$tfile`
3260 mv $DIR1/$tfile $DIR1/$tfile-1
3262 kill -USR1 $multipid
3263 wait $multipid || error "multiop close failed"
3265 for (( i=0; i < 2; i++ )) ; do
3266 local mtime2=`stat -c %Y $DIR1/$tfile-1`
3267 [ "$mtime1" = "$mtime2" ] ||
3268 error "mtime is lost on close: $mtime2, " \
3271 cancel_lru_locks osc
3272 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3274 lctl set_param fail_loc=0
3275 stop_full_debug_logging
3277 run_test 39j "write, rename, close, stat ======================="
3280 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3284 multiop_bg_pause $DIR1/$tfile oO_RDWR:w2097152_c || error "multiop failed"
3286 local mtime1=`stat -c %Y $DIR1/$tfile`
3288 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3290 kill -USR1 $multipid
3291 wait $multipid || error "multiop close failed"
3293 for (( i=0; i < 2; i++ )) ; do
3294 local mtime2=`stat -c %Y $DIR1/$tfile`
3296 [ "$mtime2" = $TEST_39_MTIME ] || \
3297 error "mtime is lost on close: $mtime2, should be $TEST_39_MTIME"
3299 cancel_lru_locks osc
3300 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3303 run_test 39k "write, utime, close, stat ========================"
3305 # this should be set to future
3306 TEST_39_ATIME=`date -d "1 year" +%s`
3309 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3310 remote_mds_nodsh && skip "remote MDS with nodsh" && return
3311 local atime_diff=$(do_facet $SINGLEMDS \
3312 lctl get_param -n mdd.*MDT0000*.atime_diff)
3316 # test setting directory atime to future
3317 touch -a -d @$TEST_39_ATIME $DIR/$tdir
3318 local atime=$(stat -c %X $DIR/$tdir)
3319 [ "$atime" = $TEST_39_ATIME ] || \
3320 error "atime is not set to future: $atime, $TEST_39_ATIME"
3322 # test setting directory atime from future to now
3323 local d1=$(date +%s)
3325 local d2=$(date +%s)
3327 cancel_lru_locks mdc
3328 atime=$(stat -c %X $DIR/$tdir)
3329 [ "$atime" -ge "$d1" -a "$atime" -le "$d2" ] || \
3330 error "atime is not updated from future: $atime, $d1<atime<$d2"
3332 do_facet $SINGLEMDS lctl set_param -n mdd.*MDT0000*.atime_diff=2
3335 # test setting directory atime when now > dir atime + atime_diff
3339 cancel_lru_locks mdc
3340 atime=$(stat -c %X $DIR/$tdir)
3341 [ "$atime" -ge "$d1" -a "$atime" -le "$d2" ] || \
3342 error "atime is not updated : $atime, should be $d2"
3344 do_facet $SINGLEMDS lctl set_param -n mdd.*MDT0000*.atime_diff=60
3347 # test not setting directory atime when now < dir atime + atime_diff
3349 cancel_lru_locks mdc
3350 atime=$(stat -c %X $DIR/$tdir)
3351 [ "$atime" -ge "$d1" -a "$atime" -le "$d2" ] || \
3352 error "atime is updated to $atime, should remain $d1<atime<$d2"
3354 do_facet $SINGLEMDS \
3355 lctl set_param -n mdd.*MDT0000*.atime_diff=$atime_diff
3357 run_test 39l "directory atime update ==========================="
3360 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3363 local far_past_mtime=$(date -d "May 29 1953" +%s)
3364 local far_past_atime=$(date -d "Dec 17 1903" +%s)
3366 touch -m -d @$far_past_mtime $DIR1/$tfile
3367 touch -a -d @$far_past_atime $DIR1/$tfile
3369 for (( i=0; i < 2; i++ )) ; do
3370 local timestamps=$(stat -c "%X %Y" $DIR1/$tfile)
3371 [ "$timestamps" = "$far_past_atime $far_past_mtime" ] || \
3372 error "atime or mtime set incorrectly"
3374 cancel_lru_locks osc
3375 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3378 run_test 39m "test atime and mtime before 1970"
3380 test_39n() { # LU-3832
3381 local atime_diff=$(do_facet $SINGLEMDS \
3382 lctl get_param -n mdd.*MDT0000*.atime_diff)
3387 do_facet $SINGLEMDS lctl set_param -n mdd.*MDT0000*.atime_diff=1
3390 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 status=noxfer
3391 atime0=$(stat -c %X $DIR/$tfile)
3394 $MULTIOP $DIR/$tfile oO_RDONLY:O_NOATIME:r4096c
3395 atime1=$(stat -c %X $DIR/$tfile)
3398 cancel_lru_locks mdc
3399 cancel_lru_locks osc
3400 $MULTIOP $DIR/$tfile oO_RDONLY:O_NOATIME:r4096c
3401 atime2=$(stat -c %X $DIR/$tfile)
3403 do_facet $SINGLEMDS \
3404 lctl set_param -n mdd.*MDT0000*.atime_diff=$atime_diff
3406 [ "$atime0" -eq "$atime1" ] || error "atime0 $atime0 != atime1 $atime1"
3407 [ "$atime1" -eq "$atime2" ] || error "atime0 $atime0 != atime1 $atime1"
3409 run_test 39n "check that O_NOATIME is honored"
3412 TESTDIR=$DIR/$tdir/$tfile
3413 [ -e $TESTDIR ] && rm -rf $TESTDIR
3414 test_mkdir -p $TESTDIR
3420 links2=$(stat -c %h .)
3421 [ $(($links1 + 2)) != $links2 ] &&
3422 error "wrong links count $(($links1 + 2)) != $links2"
3424 links3=$(stat -c %h .)
3425 [ $(($links1 + 1)) != $links3 ] &&
3426 error "wrong links count $links1 != $links3"
3429 run_test 39o "directory cached attributes updated after create ========"
3432 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 2 MDTs" && return
3434 TESTDIR=$DIR/$tdir/$tfile
3435 [ -e $TESTDIR ] && rm -rf $TESTDIR
3440 $LFS mkdir -i $MDTIDX $TESTDIR/remote_dir1
3441 $LFS mkdir -i $MDTIDX $TESTDIR/remote_dir2
3443 links2=$(stat -c %h .)
3444 [ $(($links1 + 2)) != $links2 ] &&
3445 error "wrong links count $(($links1 + 2)) != $links2"
3447 links3=$(stat -c %h .)
3448 [ $(($links1 + 1)) != $links3 ] &&
3449 error "wrong links count $links1 != $links3"
3452 run_test 39p "remote directory cached attributes updated after create ========"
3456 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1
3457 $RUNAS $OPENFILE -f O_WRONLY:O_TRUNC $DIR/$tfile &&
3458 error "openfile O_WRONLY:O_TRUNC $tfile failed"
3459 $CHECKSTAT -t file -s 4096 $DIR/$tfile ||
3460 error "$tfile is not 4096 bytes in size"
3462 run_test 40 "failed open(O_TRUNC) doesn't truncate ============="
3466 small_write $DIR/f41 18
3468 run_test 41 "test small file write + fstat ====================="
3470 count_ost_writes() {
3471 lctl get_param -n osc.*.stats |
3472 awk -vwrites=0 '/ost_write/ { writes += $2 } \
3473 END { printf("%0.0f", writes) }'
3480 BG_DIRTY_RATIO_SAVE=10
3481 MAX_BG_DIRTY_RATIO=25
3485 # in 2.6, restore /proc/sys/vm/dirty_writeback_centisecs,
3486 # dirty_ratio, dirty_background_ratio
3487 if [ -f /proc/sys/vm/dirty_writeback_centisecs ]; then
3488 sysctl -w vm.dirty_writeback_centisecs=$WRITEBACK_SAVE
3489 sysctl -w vm.dirty_background_ratio=$BG_DIRTY_RATIO_SAVE
3490 sysctl -w vm.dirty_ratio=$DIRTY_RATIO_SAVE
3492 # if file not here, we are a 2.4 kernel
3493 kill -CONT `pidof kupdated`
3498 # setup the trap first, so someone cannot exit the test at the
3499 # exact wrong time and mess up a machine
3500 trap start_writeback EXIT
3501 # in 2.6, save and 0 /proc/sys/vm/dirty_writeback_centisecs
3502 if [ -f /proc/sys/vm/dirty_writeback_centisecs ]; then
3503 WRITEBACK_SAVE=`sysctl -n vm.dirty_writeback_centisecs`
3504 sysctl -w vm.dirty_writeback_centisecs=0
3505 sysctl -w vm.dirty_writeback_centisecs=0
3506 # save and increase /proc/sys/vm/dirty_ratio
3507 DIRTY_RATIO_SAVE=`sysctl -n vm.dirty_ratio`
3508 sysctl -w vm.dirty_ratio=$MAX_DIRTY_RATIO
3509 # save and increase /proc/sys/vm/dirty_background_ratio
3510 BG_DIRTY_RATIO_SAVE=`sysctl -n vm.dirty_background_ratio`
3511 sysctl -w vm.dirty_background_ratio=$MAX_BG_DIRTY_RATIO
3513 # if file not here, we are a 2.4 kernel
3514 kill -STOP `pidof kupdated`
3518 # ensure that all stripes have some grant before we test client-side cache
3520 for i in `seq -f $DIR/f42-%g 1 $OSTCOUNT`; do
3521 dd if=/dev/zero of=$i bs=4k count=1
3526 # Tests 42* verify that our behaviour is correct WRT caching, file closure,
3527 # file truncation, and file removal.
3529 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3531 cancel_lru_locks osc
3533 sync; sleep 1; sync # just to be safe
3534 BEFOREWRITES=`count_ost_writes`
3535 lctl get_param -n osc.*[oO][sS][cC][_-]*.cur_grant_bytes | grep "[0-9]"
3536 dd if=/dev/zero of=$DIR/f42a bs=1024 count=100
3537 AFTERWRITES=`count_ost_writes`
3538 [ $BEFOREWRITES -eq $AFTERWRITES ] || \
3539 error "$BEFOREWRITES < $AFTERWRITES"
3542 run_test 42a "ensure that we don't flush on close =============="
3545 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3547 cancel_lru_locks osc
3550 dd if=/dev/zero of=$DIR/f42b bs=1024 count=100
3551 BEFOREWRITES=$(count_ost_writes)
3552 $MUNLINK $DIR/f42b || error "$MUNLINK $DIR/f42b: $?"
3553 AFTERWRITES=$(count_ost_writes)
3554 if [[ $BEFOREWRITES -lt $AFTERWRITES ]]; then
3555 error "$BEFOREWRITES < $AFTERWRITES on unlink"
3557 BEFOREWRITES=$(count_ost_writes)
3558 sync || error "sync: $?"
3559 AFTERWRITES=$(count_ost_writes)
3560 if [[ $BEFOREWRITES -lt $AFTERWRITES ]]; then
3561 error "$BEFOREWRITES < $AFTERWRITES on sync"
3563 dmesg | grep 'error from obd_brw_async' && error 'error writing back'
3567 run_test 42b "test destroy of file with cached dirty data ======"
3569 # if these tests just want to test the effect of truncation,
3570 # they have to be very careful. consider:
3571 # - the first open gets a {0,EOF}PR lock
3572 # - the first write conflicts and gets a {0, count-1}PW
3573 # - the rest of the writes are under {count,EOF}PW
3574 # - the open for truncate tries to match a {0,EOF}PR
3575 # for the filesize and cancels the PWs.
3576 # any number of fixes (don't get {0,EOF} on open, match
3577 # composite locks, do smarter file size management) fix
3578 # this, but for now we want these tests to verify that
3579 # the cancellation with truncate intent works, so we
3580 # start the file with a full-file pw lock to match against
3581 # until the truncate.
3586 cancel_lru_locks osc
3588 # prime the file with 0,EOF PW to match
3592 # now the real test..
3593 dd if=/dev/zero of=$file bs=1024 count=100
3594 BEFOREWRITES=`count_ost_writes`
3595 $TRUNCATE $file $offset
3596 cancel_lru_locks osc
3597 AFTERWRITES=`count_ost_writes`
3602 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3604 [ $BEFOREWRITES -eq $AFTERWRITES ] && \
3605 error "beforewrites $BEFOREWRITES == afterwrites $AFTERWRITES on truncate"
3608 run_test 42c "test partial truncate of file with cached dirty data"
3611 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3613 [ $BEFOREWRITES -eq $AFTERWRITES ] || \
3614 error "beforewrites $BEFOREWRITES != afterwrites $AFTERWRITES on truncate"
3617 run_test 42d "test complete truncate of file with cached dirty data"
3619 test_42e() { # bug22074
3620 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3621 local TDIR=$DIR/${tdir}e
3622 local pagesz=$(page_size)
3623 local pages=16 # hardcoded 16 pages, don't change it.
3624 local files=$((OSTCOUNT * 500)) # hopefully 500 files on each OST
3625 local proc_osc0="osc.${FSNAME}-OST0000-osc-[^MDT]*"
3629 test_mkdir -p $DIR/${tdir}e
3630 $SETSTRIPE -c 1 $TDIR
3631 createmany -o $TDIR/f $files
3633 max_dirty_mb=$($LCTL get_param -n $proc_osc0/max_dirty_mb)
3635 # we assume that with $OSTCOUNT files, at least one of them will
3636 # be allocated on OST0.
3637 warmup_files=$((OSTCOUNT * max_dirty_mb))
3638 createmany -o $TDIR/w $warmup_files
3640 # write a large amount of data into one file and sync, to get good
3641 # avail_grant number from OST.
3642 for ((i=0; i<$warmup_files; i++)); do
3643 idx=$($GETSTRIPE -i $TDIR/w$i)
3644 [ $idx -ne 0 ] && continue
3645 dd if=/dev/zero of=$TDIR/w$i bs="$max_dirty_mb"M count=1
3648 [[ $i -gt $warmup_files ]] && error "OST0 is still cold"
3650 $LCTL get_param $proc_osc0/cur_dirty_bytes
3651 $LCTL get_param $proc_osc0/cur_grant_bytes
3653 # create as much dirty pages as we can while not to trigger the actual
3654 # RPCs directly. but depends on the env, VFS may trigger flush during this
3655 # period, hopefully we are good.
3656 for ((i=0; i<$warmup_files; i++)); do
3657 idx=$($GETSTRIPE -i $TDIR/w$i)
3658 [ $idx -ne 0 ] && continue
3659 dd if=/dev/zero of=$TDIR/w$i bs=1M count=1 2>/dev/null
3661 $LCTL get_param $proc_osc0/cur_dirty_bytes
3662 $LCTL get_param $proc_osc0/cur_grant_bytes
3664 # perform the real test
3665 $LCTL set_param $proc_osc0/rpc_stats 0
3666 for ((;i<$files; i++)); do
3667 [ $($GETSTRIPE -i $TDIR/f$i) -eq 0 ] || continue
3668 dd if=/dev/zero of=$TDIR/f$i bs=$pagesz count=$pages 2>/dev/null
3671 $LCTL get_param $proc_osc0/rpc_stats
3674 local have_ppr=false
3675 $LCTL get_param $proc_osc0/rpc_stats |
3676 while read PPR RRPC RPCT RCUM BAR WRPC WPCT WCUM; do
3677 # skip lines until we are at the RPC histogram data
3678 [ "$PPR" == "pages" ] && have_ppr=true && continue
3679 $have_ppr || continue
3681 # we only want the percent stat for < 16 pages
3682 [[ $(echo $PPR | tr -d ':') -ge $pages ]] && break
3684 percent=$((percent + WPCT))
3685 if [[ $percent -gt 15 ]]; then
3686 error "less than 16-pages write RPCs" \
3693 run_test 42e "verify sub-RPC writes are not done synchronously"
3696 test_mkdir -p $DIR/$tdir
3697 cp -p /bin/ls $DIR/$tdir/$tfile
3698 $MULTIOP $DIR/$tdir/$tfile Ow_c &
3700 # give multiop a chance to open
3703 $DIR/$tdir/$tfile && error || true
3706 run_test 43 "execution of file opened for write should return -ETXTBSY"
3709 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3710 test_mkdir -p $DIR/$tdir
3711 cp -p `which $MULTIOP` $DIR/$tdir/multiop ||
3712 cp -p multiop $DIR/$tdir/multiop
3713 MULTIOP_PROG=$DIR/$tdir/multiop multiop_bg_pause $TMP/$tfile.junk O_c ||
3716 $MULTIOP $DIR/$tdir/multiop Oc && error "expected error, got success"
3717 kill -USR1 $MULTIOP_PID || return 2
3718 wait $MULTIOP_PID || return 3
3719 rm $TMP/$tfile.junk $DIR/$tdir/multiop
3721 run_test 43a "open(RDWR) of file being executed should return -ETXTBSY"
3724 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3725 test_mkdir -p $DIR/$tdir
3726 cp -p `which $MULTIOP` $DIR/$tdir/multiop ||
3727 cp -p multiop $DIR/$tdir/multiop
3728 MULTIOP_PROG=$DIR/$tdir/multiop multiop_bg_pause $TMP/$tfile.junk O_c ||
3731 $TRUNCATE $DIR/$tdir/multiop 0 && error "expected error, got success"
3732 kill -USR1 $MULTIOP_PID || return 2
3733 wait $MULTIOP_PID || return 3
3734 rm $TMP/$tfile.junk $DIR/$tdir/multiop
3736 run_test 43b "truncate of file being executed should return -ETXTBSY"
3739 local testdir="$DIR/$tdir"
3740 test_mkdir -p $DIR/$tdir
3742 ( cd $(dirname $SHELL) && md5sum $(basename $SHELL) ) | \
3743 ( cd $testdir && md5sum -c)
3745 run_test 43c "md5sum of copy into lustre========================"
3748 [[ $OSTCOUNT -lt 2 ]] && skip_env "skipping 2-stripe test" && return
3749 dd if=/dev/zero of=$DIR/f1 bs=4k count=1 seek=1023
3750 dd if=$DIR/f1 bs=4k count=1 > /dev/null
3752 run_test 44 "zero length read from a sparse stripe ============="
3755 local nstripe=$($LCTL lov_getconfig $DIR | grep default_stripe_count: |
3757 [ -z "$nstripe" ] && skip "can't get stripe info" && return
3758 [[ $nstripe -gt $OSTCOUNT ]] &&
3759 skip "Wrong default_stripe_count: $nstripe (OSTCOUNT: $OSTCOUNT)" &&
3761 local stride=$($LCTL lov_getconfig $DIR | grep default_stripe_size: |
3763 if [[ $nstripe -eq 0 || $nstripe -eq -1 ]]; then
3764 nstripe=$($LCTL lov_getconfig $DIR | grep obd_count: |
3768 OFFSETS="0 $((stride/2)) $((stride-1))"
3769 for offset in $OFFSETS; do
3770 for i in $(seq 0 $((nstripe-1))); do
3771 local GLOBALOFFSETS=""
3773 local size=$((((i + 2 * $nstripe )*$stride + $offset)))
3774 local myfn=$DIR/d44a-$size
3775 echo "--------writing $myfn at $size"
3776 ll_sparseness_write $myfn $size ||
3777 error "ll_sparseness_write"
3778 GLOBALOFFSETS="$GLOBALOFFSETS $size"
3779 ll_sparseness_verify $myfn $GLOBALOFFSETS ||
3780 error "ll_sparseness_verify $GLOBALOFFSETS"
3782 for j in $(seq 0 $((nstripe-1))); do
3784 size=$((((j + $nstripe )*$stride + $offset)))
3785 ll_sparseness_write $myfn $size ||
3786 error "ll_sparseness_write"
3787 GLOBALOFFSETS="$GLOBALOFFSETS $size"
3789 ll_sparseness_verify $myfn $GLOBALOFFSETS ||
3790 error "ll_sparseness_verify $GLOBALOFFSETS"
3795 run_test 44a "test sparse pwrite ==============================="
3799 for d in `lctl get_param -n osc.*.cur_dirty_bytes`; do
3805 before=`dirty_osc_total`
3806 echo executing "\"$*\""
3808 after=`dirty_osc_total`
3809 echo before $before, after $after
3812 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3814 # Obtain grants from OST if it supports it
3815 echo blah > ${f}_grant
3818 do_dirty_record "echo blah > $f"
3819 [[ $before -eq $after ]] && error "write wasn't cached"
3820 do_dirty_record "> $f"
3821 [[ $before -gt $after ]] || error "truncate didn't lower dirty count"
3822 do_dirty_record "echo blah > $f"
3823 [[ $before -eq $after ]] && error "write wasn't cached"
3824 do_dirty_record "sync"
3825 [[ $before -gt $after ]] || error "writeback didn't lower dirty count"
3826 do_dirty_record "echo blah > $f"
3827 [[ $before -eq $after ]] && error "write wasn't cached"
3828 do_dirty_record "cancel_lru_locks osc"
3829 [[ $before -gt $after ]] ||
3830 error "lock cancellation didn't lower dirty count"
3833 run_test 45 "osc io page accounting ============================"
3835 # in a 2 stripe file (lov.sh), page 1023 maps to page 511 in its object. this
3836 # test tickles a bug where re-dirtying a page was failing to be mapped to the
3837 # objects offset and an assert hit when an rpc was built with 1023's mapped
3838 # offset 511 and 511's raw 511 offset. it also found general redirtying bugs.
3840 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3844 dd if=/dev/zero of=$f bs=`page_size` seek=511 count=1
3846 dd conv=notrunc if=/dev/zero of=$f bs=`page_size` seek=1023 count=1
3847 dd conv=notrunc if=/dev/zero of=$f bs=`page_size` seek=511 count=1
3851 run_test 46 "dirtying a previously written page ================"
3853 # test_47 is removed "Device nodes check" is moved to test_28
3855 test_48a() { # bug 2399
3856 [ $(facet_fstype $SINGLEMDS) = "zfs" ] &&
3857 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.3.63) ] &&
3858 skip "MDS prior to 2.3.63 handle ZFS dir .. incorrectly" &&
3860 test_mkdir $DIR/$tdir
3862 mv $DIR/$tdir $DIR/$tdir.new || error "move directory failed"
3863 test_mkdir $DIR/$tdir || error "recreate directory failed"
3864 touch foo || error "'touch foo' failed after recreating cwd"
3865 test_mkdir bar || error "'mkdir foo' failed after recreating cwd"
3866 touch .foo || error "'touch .foo' failed after recreating cwd"
3867 test_mkdir .bar || error "'mkdir .foo' failed after recreating cwd"
3868 ls . > /dev/null || error "'ls .' failed after recreating cwd"
3869 ls .. > /dev/null || error "'ls ..' failed after removing cwd"
3870 cd . || error "'cd .' failed after recreating cwd"
3871 test_mkdir . && error "'mkdir .' worked after recreating cwd"
3872 rmdir . && error "'rmdir .' worked after recreating cwd"
3873 ln -s . baz || error "'ln -s .' failed after recreating cwd"
3874 cd .. || error "'cd ..' failed after recreating cwd"
3876 run_test 48a "Access renamed working dir (should return errors)="
3878 test_48b() { # bug 2399
3880 test_mkdir $DIR/$tdir
3882 rmdir $DIR/$tdir || error "remove cwd $DIR/$tdir failed"
3883 touch foo && error "'touch foo' worked after removing cwd"
3884 test_mkdir foo && error "'mkdir foo' worked after removing cwd"
3885 touch .foo && error "'touch .foo' worked after removing cwd"
3886 test_mkdir .foo && error "'mkdir .foo' worked after removing cwd"
3887 ls . > /dev/null && error "'ls .' worked after removing cwd"
3888 ls .. > /dev/null || error "'ls ..' failed after removing cwd"
3889 is_patchless || ( cd . && error "'cd .' worked after removing cwd" )
3890 test_mkdir . && error "'mkdir .' worked after removing cwd"
3891 rmdir . && error "'rmdir .' worked after removing cwd"
3892 ln -s . foo && error "'ln -s .' worked after removing cwd"
3893 cd .. || echo "'cd ..' failed after removing cwd `pwd`" #bug 3517
3895 run_test 48b "Access removed working dir (should return errors)="
3897 test_48c() { # bug 2350
3898 #lctl set_param debug=-1
3901 test_mkdir -p $DIR/$tdir/dir
3903 $TRACE rmdir $DIR/$tdir/dir || error "remove cwd $DIR/$tdir/dir failed"
3904 $TRACE touch foo && error "touch foo worked after removing cwd"
3905 $TRACE test_mkdir foo && error "'mkdir foo' worked after removing cwd"
3906 touch .foo && error "touch .foo worked after removing cwd"
3907 test_mkdir .foo && error "mkdir .foo worked after removing cwd"
3908 $TRACE ls . && error "'ls .' worked after removing cwd"
3909 $TRACE ls .. || error "'ls ..' failed after removing cwd"
3910 is_patchless || ( $TRACE cd . &&
3911 error "'cd .' worked after removing cwd" )
3912 $TRACE test_mkdir . && error "'mkdir .' worked after removing cwd"
3913 $TRACE rmdir . && error "'rmdir .' worked after removing cwd"
3914 $TRACE ln -s . foo && error "'ln -s .' worked after removing cwd"
3915 $TRACE cd .. || echo "'cd ..' failed after removing cwd `pwd`" #bug 3415
3917 run_test 48c "Access removed working subdir (should return errors)"
3919 test_48d() { # bug 2350
3920 #lctl set_param debug=-1
3923 test_mkdir -p $DIR/$tdir/dir
3925 $TRACE rmdir $DIR/$tdir/dir || error "remove cwd $DIR/$tdir/dir failed"
3926 $TRACE rmdir $DIR/$tdir || error "remove parent $DIR/$tdir failed"
3927 $TRACE touch foo && error "'touch foo' worked after removing parent"
3928 $TRACE test_mkdir foo && error "mkdir foo worked after removing parent"
3929 touch .foo && error "'touch .foo' worked after removing parent"
3930 test_mkdir .foo && error "mkdir .foo worked after removing parent"
3931 $TRACE ls . && error "'ls .' worked after removing parent"
3932 $TRACE ls .. && error "'ls ..' worked after removing parent"
3933 is_patchless || ( $TRACE cd . &&
3934 error "'cd .' worked after recreate parent" )
3935 $TRACE test_mkdir . && error "'mkdir .' worked after removing parent"
3936 $TRACE rmdir . && error "'rmdir .' worked after removing parent"
3937 $TRACE ln -s . foo && error "'ln -s .' worked after removing parent"
3938 is_patchless || ( $TRACE cd .. &&
3939 error "'cd ..' worked after removing parent" || true )
3941 run_test 48d "Access removed parent subdir (should return errors)"
3943 test_48e() { # bug 4134
3944 #lctl set_param debug=-1
3947 test_mkdir -p $DIR/$tdir/dir
3949 $TRACE rmdir $DIR/$tdir/dir || error "remove cwd $DIR/$tdir/dir failed"
3950 $TRACE rmdir $DIR/$tdir || error "remove parent $DIR/$tdir failed"
3951 $TRACE touch $DIR/$tdir || error "'touch $DIR/$tdir' failed"
3952 $TRACE chmod +x $DIR/$tdir || error "'chmod +x $DIR/$tdir' failed"
3953 # On a buggy kernel addition of "touch foo" after cd .. will
3954 # produce kernel oops in lookup_hash_it
3955 touch ../foo && error "'cd ..' worked after recreate parent"
3957 $TRACE rm $DIR/$tdir || error "rm '$DIR/$tdir' failed"
3959 run_test 48e "Access to recreated parent subdir (should return errors)"
3961 test_49() { # LU-1030
3962 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3963 # get ost1 size - lustre-OST0000
3964 ost1_size=$(do_facet ost1 $LFS df | grep ${ost1_svc} |
3966 # write 800M at maximum
3967 [[ $ost1_size -lt 2 ]] && ost1_size=2
3968 [[ $ost1_size -gt 819200 ]] && ost1_size=819200
3970 $SETSTRIPE -c 1 -i 0 $DIR/$tfile
3971 dd if=/dev/zero of=$DIR/$tfile bs=4k count=$((ost1_size >> 2)) &
3974 # change max_pages_per_rpc while writing the file
3975 local osc1_mppc=osc.$(get_osc_import_name client ost1).max_pages_per_rpc
3976 local orig_mppc=$($LCTL get_param -n $osc1_mppc)
3977 # loop until dd process exits
3978 while ps ax -opid | grep -wq $dd_pid; do
3979 $LCTL set_param $osc1_mppc=$((RANDOM % 256 + 1))
3980 sleep $((RANDOM % 5 + 1))
3982 # restore original max_pages_per_rpc
3983 $LCTL set_param $osc1_mppc=$orig_mppc
3984 rm $DIR/$tfile || error "rm $DIR/$tfile failed"
3986 run_test 49 "Change max_pages_per_rpc won't break osc extent"
3990 test_mkdir $DIR/$tdir
3992 ls /proc/$$/cwd || error "ls /proc/$$/cwd failed"
3994 run_test 50 "special situations: /proc symlinks ==============="
3996 test_51a() { # was test_51
3997 # bug 1516 - create an empty entry right after ".." then split dir
3998 test_mkdir -c1 $DIR/$tdir
3999 touch $DIR/$tdir/foo
4000 $MCREATE $DIR/$tdir/bar
4002 createmany -m $DIR/$tdir/longfile 201
4004 while [[ $(ls -sd $DIR/$tdir | awk '{ print $1 }') -eq 4 ]]; do
4005 $MCREATE $DIR/$tdir/longfile$FNUM
4010 ls -l $DIR/$tdir > /dev/null || error "ls -l $DIR/$tdir failed"
4012 run_test 51a "special situations: split htree with empty entry =="
4014 export NUMTEST=70000
4016 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4017 local BASE=$DIR/d${base}.${TESTSUITE}
4019 # cleanup the directory
4022 test_mkdir -p -c1 $BASE
4026 local mdtidx=$(printf "%04x" $($LFS getstripe -M $BASE))
4027 local numfree=$(lctl get_param -n mdc.$FSNAME-MDT$mdtidx*.filesfree)
4028 [[ $numfree -lt 21000 ]] &&
4029 skip "not enough free inodes ($numfree) on MDT$mdtidx" &&
4032 [[ $numfree -lt $NUMTEST ]] && NUMTEST=$(($numfree - 50)) &&
4033 echo "reduced count to $NUMTEST due to inodes on MDT$mdtidx"
4035 # need to check free space for the directories as well
4036 local blkfree=$(lctl get_param -n mdc.$FSNAME-MDT$mdtidx*.kbytesavail)
4037 numfree=$((blkfree / 4))
4038 [[ $numfree -lt $NUMTEST ]] && NUMTEST=$((numfree - 50)) &&
4039 echo "reduced count to $NUMTEST due to blocks on MDT$mdtidx"
4041 createmany -d $BASE/d $NUMTEST && echo $NUMTEST > $BASE/fnum ||
4045 echo "failed" > $BASE/fnum
4046 error "failed to create $NUMTEST subdirs in MDT$mdtidx:$BASE"
4049 run_test 51b "exceed 64k subdirectory nlink limit"
4051 test_51ba() { # LU-993
4052 local BASE=$DIR/d${base}.${TESTSUITE}
4053 # unlink all but 100 subdirectories, then check it still works
4055 [ -f $BASE/fnum ] && local NUMPREV=$(cat $BASE/fnum) && rm $BASE/fnum
4057 [ "$NUMPREV" != "failed" ] && NUMTEST=$NUMPREV
4058 local DELETE=$((NUMTEST - LEFT))
4060 # continue on to run this test even if 51b didn't finish,
4061 # just to delete the many subdirectories created.
4062 [ ! -d "${BASE}/d1" ] && skip "test_51b() not run" && return 0
4064 # for ldiskfs the nlink count should be 1, but this is OSD specific
4065 # and so this is listed for informational purposes only
4066 echo "nlink before: $(stat -c %h $BASE), created before: $NUMTEST"
4067 unlinkmany -d $BASE/d $DELETE
4070 if [ $RC -ne 0 ]; then
4071 if [ "$NUMPREV" == "failed" ]; then
4072 skip "previous setup failed"
4075 error "unlink of first $DELETE subdirs failed"
4080 echo "nlink between: $(stat -c %h $BASE)"
4081 # trim the first line of ls output
4082 local FOUND=$(($(ls -l ${BASE} | wc -l) - 1))
4083 [ $FOUND -ne $LEFT ] &&
4084 error "can't find subdirs: found only $FOUND/$LEFT"
4086 unlinkmany -d $BASE/d $DELETE $LEFT ||
4087 error "unlink of second $LEFT subdirs failed"
4088 # regardless of whether the backing filesystem tracks nlink accurately
4089 # or not, the nlink count shouldn't be more than "." and ".." here
4090 local AFTER=$(stat -c %h $BASE)
4091 [[ $AFTER -gt 2 ]] && error "nlink after: $AFTER > 2" ||
4092 echo "nlink after: $AFTER"
4094 run_test 51ba "verify nlink for many subdirectory cleanup"
4097 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4098 [[ $OSTCOUNT -lt 3 ]] &&
4099 skip_env "skipping test with few OSTs" && return
4100 test_mkdir -p $DIR/$tdir
4101 createmany -o $DIR/$tdir/t- 1000
4102 $GETSTRIPE $DIR/$tdir > $TMP/files
4103 for N in $(seq 0 $((OSTCOUNT - 1))); do
4104 OBJS[$N]=$(awk -vobjs=0 '($1 == '$N') { objs += 1 } \
4105 END { printf("%0.0f", objs) }' $TMP/files)
4106 OBJS0[$N]=$(grep -A 1 idx $TMP/files | awk -vobjs=0 \
4107 '($1 == '$N') { objs += 1 } \
4108 END { printf("%0.0f", objs) }')
4109 log "OST$N has ${OBJS[$N]} objects, ${OBJS0[$N]} are index 0"
4111 unlinkmany $DIR/$tdir/t- 1000
4114 for N in $(seq 1 $((OSTCOUNT - 1))); do
4115 [[ ${OBJS[$N]} -lt $((${OBJS[$NLAST]} - 20)) ]] &&
4116 error "OST $N has less objects vs OST $NLAST" \
4117 " (${OBJS[$N]} < ${OBJS[$NLAST]}"
4118 [[ ${OBJS[$N]} -gt $((${OBJS[$NLAST]} + 20)) ]] &&
4119 error "OST $N has less objects vs OST $NLAST" \
4120 " (${OBJS[$N]} < ${OBJS[$NLAST]}"
4122 [[ ${OBJS0[$N]} -lt $((${OBJS0[$NLAST]} - 20)) ]] &&
4123 error "OST $N has less #0 objects vs OST $NLAST" \
4124 " (${OBJS0[$N]} < ${OBJS0[$NLAST]}"
4125 [[ ${OBJS0[$N]} -gt $((${OBJS0[$NLAST]} + 20)) ]] &&
4126 error "OST $N has less #0 objects vs OST $NLAST" \
4127 " (${OBJS0[$N]} < ${OBJS0[$NLAST]}"
4131 run_test 51d "check object distribution ===================="
4134 if [ "$(facet_fstype $SINGLEMDS)" != ldiskfs ]; then
4135 skip "Only applicable to ldiskfs-based MDTs"
4139 test_mkdir -c1 $DIR/$tdir || error "create $tdir failed"
4140 test_mkdir -c1 $DIR/$tdir/d0 || error "create d0 failed"
4142 touch $DIR/$tdir/d0/foo
4143 createmany -l $DIR/$tdir/d0/foo $DIR/$tdir/d0/f- 65001 &&
4144 error "file exceed 65000 nlink limit!"
4145 unlinkmany $DIR/$tdir/d0/f- 65001
4148 run_test 51e "check file nlink limit"
4151 [ -f $DIR/$tdir/foo ] && chattr -a $DIR/$tdir/foo
4152 test_mkdir -p $DIR/$tdir
4153 touch $DIR/$tdir/foo
4154 chattr +a $DIR/$tdir/foo || error "chattr +a failed"
4155 echo bar >> $DIR/$tdir/foo || error "append bar failed"
4156 cp /etc/hosts $DIR/$tdir/foo && error "cp worked"
4157 rm -f $DIR/$tdir/foo 2>/dev/null && error "rm worked"
4158 link $DIR/$tdir/foo $DIR/$tdir/foo_link 2>/dev/null &&
4160 echo foo >> $DIR/$tdir/foo || error "append foo failed"
4161 mrename $DIR/$tdir/foo $DIR/$tdir/foo_ren && error "rename worked"
4162 lsattr $DIR/$tdir/foo | egrep -q "^-+a[-e]+ $DIR/$tdir/foo" ||
4164 chattr -a $DIR/$tdir/foo || error "chattr -a failed"
4165 cp -r $DIR/$tdir /tmp/
4166 rm -fr $DIR/$tdir || error "cleanup rm failed"
4168 run_test 52a "append-only flag test (should return errors) ====="
4171 [ -f $DIR/$tdir/foo ] && chattr -i $DIR/$tdir/foo
4172 test_mkdir -p $DIR/$tdir
4173 touch $DIR/$tdir/foo
4174 chattr +i $DIR/$tdir/foo || error "chattr +i failed"
4175 cat test > $DIR/$tdir/foo && error "cat test worked"
4176 cp /etc/hosts $DIR/$tdir/foo && error "cp worked"
4177 rm -f $DIR/$tdir/foo 2>/dev/null && error "rm worked"
4178 link $DIR/$tdir/foo $DIR/$tdir/foo_link 2>/dev/null &&
4180 echo foo >> $DIR/$tdir/foo && error "echo worked"
4181 mrename $DIR/$tdir/foo $DIR/$tdir/foo_ren && error "rename worked"
4182 [ -f $DIR/$tdir/foo ] || error "$tdir/foo is not a file"
4183 [ -f $DIR/$tdir/foo_ren ] && error "$tdir/foo_ren is not a file"
4184 lsattr $DIR/$tdir/foo | egrep -q "^-+i[-e]+ $DIR/$tdir/foo" ||
4186 chattr -i $DIR/$tdir/foo || error "chattr failed"
4188 rm -fr $DIR/$tdir || error "unable to remove $DIR/$tdir"
4190 run_test 52b "immutable flag test (should return errors) ======="
4193 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4194 remote_mds_nodsh && skip "remote MDS with nodsh" && return
4195 remote_ost_nodsh && skip "remote OST with nodsh" && return
4208 local support_last_seq=true
4210 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.3.60) ]] ||
4211 support_last_seq=false
4214 local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS)
4216 for value in $(do_facet $SINGLEMDS \
4217 $LCTL get_param osc.$mdtosc.prealloc_last_id) ; do
4218 param=$(echo ${value[0]} | cut -d "=" -f1)
4219 ostname=$(echo $param | cut -d "." -f2 | cut -d - -f 1-2)
4221 if $support_last_seq; then
4222 param_seq=$(echo $param |
4223 sed -e s/prealloc_last_id/prealloc_last_seq/g)
4224 mds_last_seq=$(do_facet $SINGLEMDS \
4225 $LCTL get_param -n $param_seq)
4227 mds_last=$(do_facet $SINGLEMDS $LCTL get_param -n $param)
4229 ostnum=$(index_from_ostuuid ${ostname}_UUID)
4230 node=$(facet_active_host ost$((ostnum+1)))
4231 param="obdfilter.$ostname.last_id"
4232 for ost_last in $(do_node $node $LCTL get_param -n $param) ; do
4233 echo "$ostname.last_id=$ost_last; MDS.last_id=$mds_last"
4234 ost_last_id=$ost_last
4236 if $support_last_seq; then
4237 ost_last_id=$(echo $ost_last |
4238 awk -F':' '{print $2}' |
4240 ost_last_seq=$(echo $ost_last |
4241 awk -F':' '{print $1}')
4242 [[ $ost_last_seq = $mds_last_seq ]] || continue
4245 if [[ $ost_last_id != $mds_last ]]; then
4246 error "$ost_last_id != $mds_last"
4253 $found || error "can not match last_seq/last_id for $mdtosc"
4256 run_test 53 "verify that MDS and OSTs agree on pre-creation ===="
4259 $SOCKETSERVER $DIR/socket ||
4260 error "$SOCKETSERVER $DIR/socket failed: $?"
4261 $SOCKETCLIENT $DIR/socket ||
4262 error "$SOCKETCLIENT $DIR/socket failed: $?"
4263 $MUNLINK $DIR/socket || error "$MUNLINK $DIR/socket failed: $?"
4265 run_test 54a "unix domain socket test =========================="
4271 dd if=/dev/zero of=$f bs=$(page_size) count=1
4273 run_test 54b "char device works in lustre ======================"
4276 [ -b /dev/loop/0 ] && LOOPBASE=/dev/loop/
4277 [ -b /dev/loop0 ] && LOOPBASE=/dev/loop
4278 [ -z "$LOOPBASE" ] && echo "/dev/loop/0 and /dev/loop0 gone?" && return
4280 for i in $(seq 3 7); do
4281 losetup $LOOPBASE$i > /dev/null 2>&1 && continue
4289 loopdev="$DIR/loop54c"
4292 $UMOUNT -d $DIR/$tdir || rc=$?
4293 losetup -d $loopdev || true
4294 losetup -d $LOOPDEV || true
4295 rm -rf $loopdev $DIR/$tfile $DIR/$tdir
4300 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4301 loopdev="$DIR/loop54c"
4304 [ -z "$LOOPNUM" ] && echo "couldn't find empty loop device" && return
4305 trap cleanup_54c EXIT
4306 mknod $loopdev b 7 $LOOPNUM
4307 echo "make a loop file system with $DIR/$tfile on $loopdev ($LOOPNUM)."
4308 dd if=/dev/zero of=$DIR/$tfile bs=$(get_page_size client) seek=1024 count=1 > /dev/null
4309 losetup $loopdev $DIR/$tfile ||
4310 error "can't set up $loopdev for $DIR/$tfile"
4311 mkfs.ext2 $loopdev || error "mke2fs on $loopdev"
4312 test_mkdir -p $DIR/$tdir
4313 mount -t ext2 $loopdev $DIR/$tdir ||
4314 error "error mounting $loopdev on $DIR/$tdir"
4315 dd if=/dev/zero of=$DIR/$tdir/tmp bs=$(get_page_size client) count=30 ||
4318 dd if=$DIR/$tdir/tmp of=/dev/zero bs=$(get_page_size client) count=30 ||
4322 run_test 54c "block device works in lustre ====================="
4328 [ "$string" = $(echo $string > $f | cat $f) ] || error "$f != $string"
4330 run_test 54d "fifo device works in lustre ======================"
4335 cp -aL /dev/console $f
4336 echo $string > $f || error "echo $string to $f failed"
4338 run_test 54e "console/tty device works in lustre ======================"
4340 #The test_55 used to be iopen test and it was removed by bz#24037.
4341 #run_test 55 "check iopen_connect_dentry() ======================"
4343 test_56a() { # was test_56
4346 test_mkdir -p $DIR/$tdir/dir
4348 NUMFILESx2=$(($NUMFILES * 2))
4349 for i in $(seq 1 $NUMFILES); do
4350 touch $DIR/$tdir/file$i
4351 touch $DIR/$tdir/dir/file$i
4354 # test lfs getstripe with --recursive
4355 FILENUM=$($GETSTRIPE --recursive $DIR/$tdir | grep -c obdidx)
4356 [[ $FILENUM -eq $NUMFILESx2 ]] ||
4357 error "$GETSTRIPE --recursive: found $FILENUM, not $NUMFILESx2"
4358 FILENUM=$($GETSTRIPE $DIR/$tdir | grep -c obdidx)
4359 [[ $FILENUM -eq $NUMFILES ]] ||
4360 error "$GETSTRIPE $DIR/$tdir: found $FILENUM, not $NUMFILES"
4361 echo "$GETSTRIPE --recursive passed."
4363 # test lfs getstripe with file instead of dir
4364 FILENUM=$($GETSTRIPE $DIR/$tdir/file1 | grep -c obdidx)
4365 [[ $FILENUM -eq 1 ]] ||
4366 error "$GETSTRIPE $DIR/$tdir/file1: found $FILENUM, not 1"
4367 echo "$GETSTRIPE file1 passed."
4369 #test lfs getstripe with --verbose
4370 [[ $($GETSTRIPE --verbose $DIR/$tdir |
4371 grep -c lmm_magic) -eq $NUMFILES ]] ||
4372 error "$GETSTRIPE --verbose $DIR/$tdir: want $NUMFILES"
4373 [[ $($GETSTRIPE $DIR/$tdir | grep -c lmm_magic) -eq 0 ]] ||
4374 rror "$GETSTRIPE $DIR/$tdir: showed lmm_magic"
4375 echo "$GETSTRIPE --verbose passed."
4377 #test lfs getstripe with --obd
4378 $GETSTRIPE --obd wrong_uuid $DIR/$tdir 2>&1 |
4379 grep -q "unknown obduuid" ||
4380 error "$GETSTRIPE --obd wrong_uuid should return error message"
4382 [[ $OSTCOUNT -lt 2 ]] &&
4383 skip_env "skipping other $GETSTRIPE --obd test" && return
4386 OBDUUID=$(ostuuid_from_index $OSTIDX)
4387 FILENUM=$($GETSTRIPE -ir $DIR/$tdir | grep "^$OSTIDX\$" | wc -l)
4388 FOUND=$($GETSTRIPE -r --obd $OBDUUID $DIR/$tdir | grep obdidx | wc -l)
4389 [[ $FOUND -eq $FILENUM ]] ||
4390 error "$GETSTRIPE --obd wrong: found $FOUND, expected $FILENUM"
4391 [[ $($GETSTRIPE -r -v --obd $OBDUUID $DIR/$tdir |
4392 sed '/^[ ]*'${OSTIDX}'[ ]/d' |
4393 sed -n '/^[ ]*[0-9][0-9]*[ ]/p' | wc -l) -eq 0 ]] ||
4394 error "$GETSTRIPE --obd: should not show file on other obd"
4395 echo "$GETSTRIPE --obd passed"
4397 run_test 56a "check $GETSTRIPE"
4402 local LOCAL_NUMFILES="$1"
4403 local LOCAL_NUMDIRS="$2"
4404 local MKDIR_PARAMS="$3"
4405 local DIR_STRIPE_PARAMS="$4"
4407 if [ ! -d "$TDIR" ] ; then
4408 test_mkdir -p $DIR_STRIPE_PARAMS $TDIR
4409 [ "$MKDIR_PARAMS" ] && $SETSTRIPE $MKDIR_PARAMS $TDIR
4410 for i in `seq 1 $LOCAL_NUMFILES` ; do
4413 for i in `seq 1 $LOCAL_NUMDIRS` ; do
4414 test_mkdir $DIR_STRIPE_PARAMS $TDIR/dir$i
4415 for j in `seq 1 $LOCAL_NUMFILES` ; do
4416 touch $TDIR/dir$i/file$j
4422 setup_56_special() {
4426 if [ ! -e "$TDIR/loop1b" ] ; then
4427 for i in `seq 1 $LOCAL_NUMFILES` ; do
4428 mknod $TDIR/loop${i}b b 7 $i
4429 mknod $TDIR/null${i}c c 1 3
4430 ln -s $TDIR/file1 $TDIR/link${i}l
4432 for i in `seq 1 $LOCAL_NUMDIRS` ; do
4433 mknod $TDIR/dir$i/loop${i}b b 7 $i
4434 mknod $TDIR/dir$i/null${i}c c 1 3
4435 ln -s $TDIR/dir$i/file1 $TDIR/dir$i/link${i}l
4444 setup_56 $NUMFILES $NUMDIRS
4446 EXPECTED=$(($NUMDIRS + 2))
4447 # test lfs find with -name
4448 for i in $(seq 1 $NUMFILES) ; do
4449 NUMS=$($LFIND -name "*$i" $TDIR | wc -l)
4450 [ $NUMS -eq $EXPECTED ] ||
4451 error "lfs find -name \"*$i\" $TDIR wrong: "\
4452 "found $NUMS, expected $EXPECTED"
4455 run_test 56g "check lfs find -name ============================="
4461 setup_56 $NUMFILES $NUMDIRS
4463 EXPECTED=$(((NUMDIRS + 1) * (NUMFILES - 1) + NUMFILES))
4464 # test lfs find with ! -name
4465 for i in $(seq 1 $NUMFILES) ; do
4466 NUMS=$($LFIND ! -name "*$i" $TDIR | wc -l)
4467 [ $NUMS -eq $EXPECTED ] ||
4468 error "lfs find ! -name \"*$i\" $TDIR wrong: "\
4469 "found $NUMS, expected $EXPECTED"
4472 run_test 56h "check lfs find ! -name ============================="
4476 test_mkdir -p $DIR/$tdir
4477 UUID=$(ostuuid_from_index 0 $DIR/$tdir)
4478 CMD="$LFIND -ost $UUID $DIR/$tdir"
4480 [ -z "$OUT" ] || error "\"$CMD\" returned directory '$OUT'"
4482 run_test 56i "check 'lfs find -ost UUID' skips directories ======="
4486 setup_56_special $NUMFILES $NUMDIRS
4488 EXPECTED=$((NUMDIRS + 1))
4489 CMD="$LFIND -type d $TDIR"
4490 NUMS=$($CMD | wc -l)
4491 [ $NUMS -eq $EXPECTED ] ||
4492 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4494 run_test 56j "check lfs find -type d ============================="
4498 setup_56_special $NUMFILES $NUMDIRS
4500 EXPECTED=$(((NUMDIRS + 1) * NUMFILES))
4501 CMD="$LFIND -type f $TDIR"
4502 NUMS=$($CMD | wc -l)
4503 [ $NUMS -eq $EXPECTED ] ||
4504 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4506 run_test 56k "check lfs find -type f ============================="
4510 setup_56_special $NUMFILES $NUMDIRS
4512 EXPECTED=$((NUMDIRS + NUMFILES))
4513 CMD="$LFIND -type b $TDIR"
4514 NUMS=$($CMD | wc -l)
4515 [ $NUMS -eq $EXPECTED ] ||
4516 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4518 run_test 56l "check lfs find -type b ============================="
4522 setup_56_special $NUMFILES $NUMDIRS
4524 EXPECTED=$((NUMDIRS + NUMFILES))
4525 CMD="$LFIND -type c $TDIR"
4526 NUMS=$($CMD | wc -l)
4527 [ $NUMS -eq $EXPECTED ] ||
4528 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4530 run_test 56m "check lfs find -type c ============================="
4534 setup_56_special $NUMFILES $NUMDIRS
4536 EXPECTED=$((NUMDIRS + NUMFILES))
4537 CMD="$LFIND -type l $TDIR"
4538 NUMS=$($CMD | wc -l)
4539 [ $NUMS -eq $EXPECTED ] ||
4540 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4542 run_test 56n "check lfs find -type l ============================="
4546 setup_56 $NUMFILES $NUMDIRS
4547 utime $TDIR/file1 > /dev/null || error "utime (1)"
4548 utime $TDIR/file2 > /dev/null || error "utime (2)"
4549 utime $TDIR/dir1 > /dev/null || error "utime (3)"
4550 utime $TDIR/dir2 > /dev/null || error "utime (4)"
4551 utime $TDIR/dir1/file1 > /dev/null || error "utime (5)"
4552 dd if=/dev/zero count=1 >> $TDIR/dir1/file1 && sync
4555 NUMS=`$LFIND -mtime +0 $TDIR | wc -l`
4556 [ $NUMS -eq $EXPECTED ] || \
4557 error "lfs find -mtime +0 $TDIR wrong: found $NUMS, expected $EXPECTED"
4560 CMD="$LFIND -mtime 0 $TDIR"
4561 NUMS=$($CMD | wc -l)
4562 [ $NUMS -eq $EXPECTED ] ||
4563 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4565 run_test 56o "check lfs find -mtime for old files =========================="
4568 [ $RUNAS_ID -eq $UID ] &&
4569 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
4572 setup_56 $NUMFILES $NUMDIRS
4574 chown $RUNAS_ID $TDIR/file* || error "chown $DIR/${tdir}g/file$i failed"
4576 CMD="$LFIND -uid $RUNAS_ID $TDIR"
4577 NUMS=$($CMD | wc -l)
4578 [ $NUMS -eq $EXPECTED ] || \
4579 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4581 EXPECTED=$(((NUMFILES + 1) * NUMDIRS + 1))
4582 CMD="$LFIND ! -uid $RUNAS_ID $TDIR"
4583 NUMS=$($CMD | wc -l)
4584 [ $NUMS -eq $EXPECTED ] || \
4585 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4587 run_test 56p "check lfs find -uid and ! -uid ==============================="
4590 [ $RUNAS_ID -eq $UID ] &&
4591 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
4594 setup_56 $NUMFILES $NUMDIRS
4596 chgrp $RUNAS_GID $TDIR/file* || error "chown $TDIR/file$i failed"
4599 CMD="$LFIND -gid $RUNAS_GID $TDIR"
4600 NUMS=$($CMD | wc -l)
4601 [ $NUMS -eq $EXPECTED ] ||
4602 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4604 EXPECTED=$(( ($NUMFILES+1) * $NUMDIRS + 1))
4605 CMD="$LFIND ! -gid $RUNAS_GID $TDIR"
4606 NUMS=$($CMD | wc -l)
4607 [ $NUMS -eq $EXPECTED ] ||
4608 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4610 run_test 56q "check lfs find -gid and ! -gid ==============================="
4614 setup_56 $NUMFILES $NUMDIRS
4617 CMD="$LFIND -size 0 -type f $TDIR"
4618 NUMS=$($CMD | wc -l)
4619 [ $NUMS -eq $EXPECTED ] ||
4620 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4622 CMD="$LFIND ! -size 0 -type f $TDIR"
4623 NUMS=$($CMD | wc -l)
4624 [ $NUMS -eq $EXPECTED ] ||
4625 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4626 echo "test" > $TDIR/$tfile
4627 echo "test2" > $TDIR/$tfile.2 && sync
4629 CMD="$LFIND -size 5 -type f $TDIR"
4630 NUMS=$($CMD | wc -l)
4631 [ $NUMS -eq $EXPECTED ] ||
4632 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4634 CMD="$LFIND -size +5 -type f $TDIR"
4635 NUMS=$($CMD | wc -l)
4636 [ $NUMS -eq $EXPECTED ] ||
4637 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4639 CMD="$LFIND -size +0 -type f $TDIR"
4640 NUMS=$($CMD | wc -l)
4641 [ $NUMS -eq $EXPECTED ] ||
4642 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4644 CMD="$LFIND ! -size -5 -type f $TDIR"
4645 NUMS=$($CMD | wc -l)
4646 [ $NUMS -eq $EXPECTED ] ||
4647 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4649 CMD="$LFIND -size -5 -type f $TDIR"
4650 NUMS=$($CMD | wc -l)
4651 [ $NUMS -eq $EXPECTED ] ||
4652 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4654 run_test 56r "check lfs find -size works =========================="
4656 test_56s() { # LU-611
4658 setup_56 $NUMFILES $NUMDIRS "-c $OSTCOUNT"
4660 if [[ $OSTCOUNT -gt 1 ]]; then
4661 $SETSTRIPE -c 1 $TDIR/$tfile.{0,1,2,3}
4665 ONESTRIPE=$(((NUMDIRS + 1) * NUMFILES))
4669 EXPECTED=$(((NUMDIRS + 1) * NUMFILES))
4670 CMD="$LFIND -stripe-count $OSTCOUNT -type f $TDIR"
4671 NUMS=$($CMD | wc -l)
4672 [ $NUMS -eq $EXPECTED ] || {
4674 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4677 EXPECTED=$(((NUMDIRS + 1) * NUMFILES + EXTRA))
4678 CMD="$LFIND -stripe-count +0 -type f $TDIR"
4679 NUMS=$($CMD | wc -l)
4680 [ $NUMS -eq $EXPECTED ] || {
4682 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4686 CMD="$LFIND -stripe-count 1 -type f $TDIR"
4687 NUMS=$($CMD | wc -l)
4688 [ $NUMS -eq $EXPECTED ] || {
4690 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4693 CMD="$LFIND -stripe-count -2 -type f $TDIR"
4694 NUMS=$($CMD | wc -l)
4695 [ $NUMS -eq $EXPECTED ] || {
4697 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4701 CMD="$LFIND -stripe-count $((OSTCOUNT + 1)) -type f $TDIR"
4702 NUMS=$($CMD | wc -l)
4703 [ $NUMS -eq $EXPECTED ] || {
4705 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4708 run_test 56s "check lfs find -stripe-count works"
4710 test_56t() { # LU-611
4712 setup_56 $NUMFILES $NUMDIRS "-s 512k"
4714 $SETSTRIPE -S 256k $TDIR/$tfile.{0,1,2,3}
4716 EXPECTED=$(((NUMDIRS + 1) * NUMFILES))
4717 CMD="$LFIND -stripe-size 512k -type f $TDIR"
4718 NUMS=$($CMD | wc -l)
4719 [ $NUMS -eq $EXPECTED ] ||
4720 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4722 CMD="$LFIND -stripe-size +320k -type f $TDIR"
4723 NUMS=$($CMD | wc -l)
4724 [ $NUMS -eq $EXPECTED ] ||
4725 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4727 EXPECTED=$(((NUMDIRS + 1) * NUMFILES + 4))
4728 CMD="$LFIND -stripe-size +200k -type f $TDIR"
4729 NUMS=$($CMD | wc -l)
4730 [ $NUMS -eq $EXPECTED ] ||
4731 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4733 CMD="$LFIND -stripe-size -640k -type f $TDIR"
4734 NUMS=$($CMD | wc -l)
4735 [ $NUMS -eq $EXPECTED ] ||
4736 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4739 CMD="$LFIND -stripe-size 256k -type f $TDIR"
4740 NUMS=$($CMD | wc -l)
4741 [ $NUMS -eq $EXPECTED ] ||
4742 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4744 CMD="$LFIND -stripe-size -320k -type f $TDIR"
4745 NUMS=$($CMD | wc -l)
4746 [ $NUMS -eq $EXPECTED ] ||
4747 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4750 CMD="$LFIND -stripe-size 1024k -type f $TDIR"
4751 NUMS=$($CMD | wc -l)
4752 [ $NUMS -eq $EXPECTED ] ||
4753 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4755 run_test 56t "check lfs find -stripe-size works"
4757 test_56u() { # LU-611
4759 setup_56 $NUMFILES $NUMDIRS "-i 0"
4761 if [[ $OSTCOUNT -gt 1 ]]; then
4762 $SETSTRIPE -i 1 $TDIR/$tfile.{0,1,2,3}
4768 EXPECTED=$(((NUMDIRS + 1) * NUMFILES))
4769 CMD="$LFIND -stripe-index 0 -type f $TDIR"
4770 NUMS=$($CMD | wc -l)
4771 [ $NUMS -eq $EXPECTED ] ||
4772 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4775 CMD="$LFIND -stripe-index 1 -type f $TDIR"
4776 NUMS=$($CMD | wc -l)
4777 [ $NUMS -eq $EXPECTED ] ||
4778 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4780 CMD="$LFIND ! -stripe-index 0 -type f $TDIR"
4781 NUMS=$($CMD | wc -l)
4782 [ $NUMS -eq $EXPECTED ] ||
4783 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4786 # This should produce an error and not return any files
4787 CMD="$LFIND -stripe-index $OSTCOUNT -type f $TDIR"
4788 NUMS=$($CMD 2>/dev/null | wc -l)
4789 [ $NUMS -eq $EXPECTED ] ||
4790 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4792 if [[ $OSTCOUNT -gt 1 ]]; then
4793 EXPECTED=$(((NUMDIRS + 1) * NUMFILES + ONESTRIPE))
4794 CMD="$LFIND -stripe-index 0,1 -type f $TDIR"
4795 NUMS=$($CMD | wc -l)
4796 [ $NUMS -eq $EXPECTED ] ||
4797 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4800 run_test 56u "check lfs find -stripe-index works"
4807 setup_56 $NUMFILES $NUMDIRS
4809 UUID=$(mdtuuid_from_index $MDT_IDX $TDIR)
4810 [ -z "$UUID" ] && error "mdtuuid_from_index cannot find MDT index $MDT_IDX"
4812 for file in $($LFIND -mdt $UUID $TDIR); do
4813 file_mdt_idx=$($GETSTRIPE -M $file)
4814 [ $file_mdt_idx -eq $MDT_IDX ] ||
4815 error "'lfind -mdt $UUID' != 'getstripe -M' ($file_mdt_idx)"
4818 run_test 56v "check 'lfs find -mdt match with lfs getstripe -M' ======="
4821 [[ $OSTCOUNT -lt 2 ]] && skip_env "$OSTCOUNT < 2 OSTs -- skipping" &&
4823 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4826 rm -rf $TDIR || error "remove $TDIR failed"
4827 setup_56 $NUMFILES $NUMDIRS "-c $OSTCOUNT" "-c1"
4830 stripe_size=$($GETSTRIPE -S -d $TDIR) ||
4831 error "$GETSTRIPE -S -d $TDIR failed"
4832 stripe_size=${stripe_size%% *}
4834 local file_size=$((stripe_size * OSTCOUNT))
4835 local file_num=$((NUMDIRS * NUMFILES + NUMFILES))
4836 local required_space=$((file_num * file_size))
4837 local free_space=$($LCTL get_param -n lov.$LOVNAME.kbytesavail)
4838 [[ $free_space -le $((required_space / 1024)) ]] &&
4839 skip_env "need at least $required_space bytes free space," \
4840 "have $free_space kbytes" && return
4843 local dd_count=$((file_size / dd_bs))
4845 # write data into the files
4849 for i in $(seq 1 $NUMFILES); do
4851 yes | dd bs=$dd_bs count=$dd_count of=$file >/dev/null 2>&1 ||
4852 error "write data into $file failed"
4854 for i in $(seq 1 $NUMDIRS); do
4855 for j in $(seq 1 $NUMFILES); do
4856 file=$TDIR/dir$i/file$j
4857 yes | dd bs=$dd_bs count=$dd_count of=$file \
4859 error "write data into $file failed"
4864 [[ $OSTCOUNT -gt 1 ]] && expected=$((OSTCOUNT - 1))
4867 local cmd="$LFS_MIGRATE -y -c $expected $TDIR/file1"
4869 eval $cmd || error "$cmd failed"
4871 check_stripe_count $TDIR/file1 $expected
4873 if [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.6.90) ];
4875 # lfs_migrate file onto OST 0 if it is on OST 1, or onto
4876 # OST 1 if it is on OST 0. This file is small enough to
4877 # be on only one stripe.
4878 file=$TDIR/migr_1_ost
4879 dd bs=$dd_bs count=1 if=/dev/urandom of=$file >/dev/null 2>&1 ||
4880 error "write data into $file failed"
4881 local obdidx=$($LFS getstripe -i $file)
4882 local oldmd5=$(md5sum $file)
4884 [[ $obdidx -eq 0 ]] && newobdidx=1
4885 cmd="$LFS migrate -i $newobdidx $file"
4887 eval $cmd || error "$cmd failed"
4888 local realobdix=$($LFS getstripe -i $file)
4889 local newmd5=$(md5sum $file)
4890 [[ $newobdidx -ne $realobdix ]] &&
4891 error "new OST is different (was=$obdidx, wanted=$newobdidx, got=$realobdix)"
4892 [[ "$oldmd5" != "$newmd5" ]] &&
4893 error "md5sum differ: $oldmd5, $newmd5"
4897 cmd="$LFS_MIGRATE -y -c $expected $TDIR/dir1"
4899 eval $cmd || error "$cmd failed"
4901 for j in $(seq 1 $NUMFILES); do
4902 check_stripe_count $TDIR/dir1/file$j $expected
4905 # lfs_migrate works with lfs find
4906 cmd="$LFIND -stripe_count $OSTCOUNT -type f $TDIR |
4907 $LFS_MIGRATE -y -c $expected"
4909 eval $cmd || error "$cmd failed"
4911 for i in $(seq 2 $NUMFILES); do
4912 check_stripe_count $TDIR/file$i $expected
4914 for i in $(seq 2 $NUMDIRS); do
4915 for j in $(seq 1 $NUMFILES); do
4916 check_stripe_count $TDIR/dir$i/file$j $expected
4920 run_test 56w "check lfs_migrate -c stripe_count works"
4923 check_swap_layouts_support && return 0
4924 [[ $OSTCOUNT -lt 2 ]] &&
4925 skip_env "need 2 OST, skipping test" && return
4927 local dir0=$DIR/$tdir/$testnum
4928 mkdir -p $dir0 || error "creating dir $dir0"
4930 local ref1=/etc/passwd
4931 local file1=$dir0/file1
4933 $SETSTRIPE -c 2 $file1
4935 $LFS migrate -c 1 $file1 || error "migrate failed rc = $?"
4936 stripe=$($GETSTRIPE -c $file1)
4937 [[ $stripe == 1 ]] || error "stripe of $file1 is $stripe != 1"
4938 cmp $file1 $ref1 || error "content mismatch $file1 differs from $ref1"
4943 run_test 56x "lfs migration support"
4946 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.53) ] &&
4947 skip "No HSM $(lustre_build_version $SINGLEMDS) MDS < 2.4.53" &&
4951 local dir0=$DIR/$tdir/$testnum
4952 mkdir -p $dir0 || error "creating dir $dir0"
4953 local f1=$dir0/file1
4954 local f2=$dir0/file2
4956 touch $f1 || error "creating std file $f1"
4957 $MULTIOP $f2 H2c || error "creating released file $f2"
4959 # a directory can be raid0, so ask only for files
4960 res=$($LFIND $dir0 -L raid0 -type f | wc -l)
4961 [[ $res == 2 ]] || error "search raid0: found $res files != 2"
4963 res=$($LFIND $dir0 \! -L raid0 -type f | wc -l)
4964 [[ $res == 0 ]] || error "search !raid0: found $res files != 0"
4966 # only files can be released, so no need to force file search
4967 res=$($LFIND $dir0 -L released)
4968 [[ $res == $f2 ]] || error "search released: found $res != $f2"
4970 res=$($LFIND $dir0 \! -L released)
4971 [[ $res == $f1 ]] || error "search !released: found $res != $f1"
4974 run_test 56y "lfs find -L raid0|released"
4976 test_56z() { # LU-4824
4977 # This checks to make sure 'lfs find' continues after errors
4978 # There are two classes of errors that should be caught:
4979 # - If multiple paths are provided, all should be searched even if one
4981 # - If errors are encountered during the search, it should not terminate
4984 test_mkdir $DIR/$tdir
4985 for i in d{0..9}; do
4986 test_mkdir $DIR/$tdir/$i
4988 touch $DIR/$tdir/d{0..9}/$tfile
4989 $LFS find $DIR/non_existent_dir $DIR/$tdir &&
4990 error "$LFS find did not return an error"
4991 # Make a directory unsearchable. This should NOT be the last entry in
4992 # directory order. Arbitrarily pick the 6th entry
4993 chmod 700 $($LFS find $DIR/$tdir -type d | sed '6!d')
4994 local count=$($RUNAS $LFS find $DIR/non_existent $DIR/$tdir | wc -l)
4995 # The user should be able to see 10 directories and 9 files
4996 [ $count == 19 ] || error "$LFS find did not continue after error"
4998 run_test 56z "lfs find should continue after an error"
5000 test_56aa() { # LU-5937
5001 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
5004 $LFS setdirstripe -c$MDSCOUNT $DIR/$tdir/striped_dir
5006 createmany -o $DIR/$tdir/striped_dir/${tfile}- 1024
5007 local dirs=$(lfs find --size +8k $DIR/$tdir/)
5009 [ -n "$dirs" ] || error "lfs find --size wrong under striped dir"
5011 run_test 56aa "lfs find --size under striped dir"
5014 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5015 # note test will not do anything if MDS is not local
5016 if [ "$(facet_fstype $SINGLEMDS)" != ldiskfs ]; then
5017 skip "Only applicable to ldiskfs-based MDTs"
5021 remote_mds_nodsh && skip "remote MDS with nodsh" && return
5022 local MNTDEV="osd*.*MDT*.mntdev"
5023 DEV=$(do_facet $SINGLEMDS lctl get_param -n $MNTDEV)
5024 [ -z "$DEV" ] && error "can't access $MNTDEV"
5025 for DEV in $(do_facet $SINGLEMDS lctl get_param -n $MNTDEV); do
5026 do_facet $SINGLEMDS $DUMPE2FS -h $DEV > $TMP/t57a.dump ||
5027 error "can't access $DEV"
5028 DEVISIZE=$(awk '/Inode size:/ { print $3 }' $TMP/t57a.dump)
5029 [[ $DEVISIZE -gt 128 ]] || error "inode size $DEVISIZE"
5033 run_test 57a "verify MDS filesystem created with large inodes =="
5036 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5037 if [ "$(facet_fstype $SINGLEMDS)" != ldiskfs ]; then
5038 skip "Only applicable to ldiskfs-based MDTs"
5042 remote_mds_nodsh && skip "remote MDS with nodsh" && return
5043 local dir=$DIR/$tdir
5047 local FILEN=$dir/f$FILECOUNT
5049 rm -rf $dir || error "removing $dir"
5050 test_mkdir -p -c1 $dir || error "creating $dir"
5051 local mdtidx=$($LFS getstripe -M $dir)
5052 local mdtname=MDT$(printf %04x $mdtidx)
5053 local facet=mds$((mdtidx + 1))
5055 echo "mcreating $FILECOUNT files"
5056 createmany -m $dir/f 1 $FILECOUNT || \
5057 error "creating files in $dir"
5059 # verify that files do not have EAs yet
5060 $GETSTRIPE $FILE1 2>&1 | grep -q "no stripe" || error "$FILE1 has an EA"
5061 $GETSTRIPE $FILEN 2>&1 | grep -q "no stripe" || error "$FILEN has an EA"
5065 df $dir #make sure we get new statfs data
5066 local MDSFREE=$(do_facet $facet \
5067 lctl get_param -n osd*.*$mdtname.kbytesfree)
5068 local MDCFREE=$(lctl get_param -n mdc.*$mdtname-mdc-*.kbytesfree)
5069 echo "opening files to create objects/EAs"
5071 for FILE in `seq -f $dir/f%g 1 $FILECOUNT`; do
5072 $OPENFILE -f O_RDWR $FILE > /dev/null 2>&1 || error "opening $FILE"
5075 # verify that files have EAs now
5076 $GETSTRIPE $FILE1 | grep -q "obdidx" || error "$FILE1 missing EA"
5077 $GETSTRIPE $FILEN | grep -q "obdidx" || error "$FILEN missing EA"
5079 sleep 1 #make sure we get new statfs data
5081 local MDSFREE2=$(do_facet $facet \
5082 lctl get_param -n osd*.*$mdtname.kbytesfree)
5083 local MDCFREE2=$(lctl get_param -n mdc.*$mdtname-mdc-*.kbytesfree)
5084 if [[ $MDCFREE2 -lt $((MDCFREE - 16)) ]]; then
5085 if [ "$MDSFREE" != "$MDSFREE2" ]; then
5086 error "MDC before $MDCFREE != after $MDCFREE2"
5088 echo "MDC before $MDCFREE != after $MDCFREE2"
5089 echo "unable to confirm if MDS has large inodes"
5094 run_test 57b "default LOV EAs are stored inside large inodes ==="
5097 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5098 [ -z "$(which wiretest 2>/dev/null)" ] &&
5099 skip_env "could not find wiretest" && return
5102 run_test 58 "verify cross-platform wire constants =============="
5105 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5106 echo "touch 130 files"
5107 createmany -o $DIR/f59- 130
5109 unlinkmany $DIR/f59- 130
5111 # wait for commitment of removal
5112 wait_delete_completed
5114 run_test 59 "verify cancellation of llog records async ========="
5116 TEST60_HEAD="test_60 run $RANDOM"
5118 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5119 remote_mgs_nodsh && skip "remote MGS with nodsh" && return
5120 do_facet mgs "! which run-llog.sh &> /dev/null" &&
5121 skip_env "missing subtest run-llog.sh" && return
5122 log "$TEST60_HEAD - from kernel mode"
5123 do_facet mgs sh run-llog.sh
5125 run_test 60a "llog sanity tests run from kernel module =========="
5127 test_60b() { # bug 6411
5128 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5130 LLOG_COUNT=`dmesg | awk "/$TEST60_HEAD/{marker = 1; from_marker = 0;}
5142 [[ $LLOG_COUNT -gt 50 ]] &&
5143 error "CDEBUG_LIMIT not limiting messages ($LLOG_COUNT)" || true
5145 run_test 60b "limit repeated messages from CERROR/CWARN ========"
5148 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5149 echo "create 5000 files"
5150 createmany -o $DIR/f60c- 5000
5151 #define OBD_FAIL_MDS_LLOG_CREATE_FAILED 0x137
5152 lctl set_param fail_loc=0x80000137
5153 unlinkmany $DIR/f60c- 5000
5154 lctl set_param fail_loc=0
5156 run_test 60c "unlink file when mds full"
5159 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5160 SAVEPRINTK=$(lctl get_param -n printk)
5162 # verify "lctl mark" is even working"
5163 MESSAGE="test message ID $RANDOM $$"
5164 $LCTL mark "$MESSAGE" || error "$LCTL mark failed"
5165 dmesg | grep -q "$MESSAGE" || error "didn't find debug marker in log"
5167 lctl set_param printk=0 || error "set lnet.printk failed"
5168 lctl get_param -n printk | grep emerg || error "lnet.printk dropped emerg"
5169 MESSAGE="new test message ID $RANDOM $$"
5170 # Assume here that libcfs_debug_mark_buffer() uses D_WARNING
5171 $LCTL mark "$MESSAGE" || error "$LCTL mark failed"
5172 dmesg | grep -q "$MESSAGE" && error "D_WARNING wasn't masked" || true
5174 lctl set_param -n printk="$SAVEPRINTK"
5176 run_test 60d "test printk console message masking"
5179 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5181 dd if=/dev/zero of=$f bs=$(page_size) count=1 || error "dd $f failed"
5182 cancel_lru_locks osc
5183 $MULTIOP $f OSMWUc || error "$MULTIOP $f failed"
5186 run_test 61 "mmap() writes don't make sync hang ================"
5188 # bug 2330 - insufficient obd_match error checking causes LBUG
5190 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5193 cancel_lru_locks osc
5194 lctl set_param fail_loc=0x405
5195 cat $f && error "cat succeeded, expect -EIO"
5196 lctl set_param fail_loc=0
5198 # This test is now irrelevant (as of bug 10718 inclusion), we no longer
5199 # match every page all of the time.
5200 #run_test 62 "verify obd_match failure doesn't LBUG (should -EIO)"
5202 # bug 2319 - oig_wait() interrupted causes crash because of invalid waitq.
5203 # Though this test is irrelevant anymore, it helped to reveal some
5204 # other grant bugs (LU-4482), let's keep it.
5205 test_63a() { # was test_63
5206 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5207 MAX_DIRTY_MB=`lctl get_param -n osc.*.max_dirty_mb | head -n 1`
5208 for i in `seq 10` ; do
5209 dd if=/dev/zero of=$DIR/f63 bs=8k &
5215 rm -f $DIR/f63 || true
5217 run_test 63a "Verify oig_wait interruption does not crash ======="
5219 # bug 2248 - async write errors didn't return to application on sync
5220 # bug 3677 - async write errors left page locked
5222 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5224 lctl set_param debug=-1
5226 # ensure we have a grant to do async writes
5227 dd if=/dev/zero of=$DIR/$tfile bs=4k count=1
5230 sync # sync lest earlier test intercept the fail_loc
5232 #define OBD_FAIL_OSC_BRW_PREP_REQ 0x406
5233 lctl set_param fail_loc=0x80000406
5234 $MULTIOP $DIR/$tfile Owy && \
5235 error "sync didn't return ENOMEM"
5236 sync; sleep 2; sync # do a real sync this time to flush page
5237 lctl get_param -n llite.*.dump_page_cache | grep locked && \
5238 error "locked page left in cache after async error" || true
5241 run_test 63b "async write errors should be returned to fsync ==="
5244 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5246 lctl get_param -n osc.*[oO][sS][cC][_-]*.cur* | grep "[0-9]"
5248 run_test 64a "verify filter grant calculations (in kernel) ====="
5251 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5252 sh oos.sh $MOUNT || error "oos.sh failed: $?"
5254 run_test 64b "check out-of-space detection on client ==========="
5257 $LCTL set_param osc.*OST0000-osc-[^mM]*.cur_grant_bytes=0
5259 run_test 64c "verify grant shrink ========================------"
5261 # bug 1414 - set/get directories' stripe info
5263 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5264 test_mkdir -p $DIR/$tdir
5266 $LVERIFY $DIR/$tdir $DIR/$tdir/f1 || error "lverify failed"
5268 run_test 65a "directory with no stripe info ===================="
5271 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5272 test_mkdir -p $DIR/$tdir
5273 $SETSTRIPE -S $((STRIPESIZE * 2)) -i 0 -c 1 $DIR/$tdir ||
5276 $LVERIFY $DIR/$tdir $DIR/$tdir/f2 || error "lverify failed"
5278 run_test 65b "directory setstripe -S $((STRIPESIZE * 2)) -i 0 -c 1"
5281 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5282 if [[ $OSTCOUNT -gt 1 ]]; then
5283 test_mkdir -p $DIR/$tdir
5284 $SETSTRIPE -S $(($STRIPESIZE * 4)) -i 1 \
5285 -c $(($OSTCOUNT - 1)) $DIR/$tdir || error "setstripe"
5287 $LVERIFY $DIR/$tdir $DIR/$tdir/f3 || error "lverify failed"
5290 run_test 65c "directory setstripe -S $((STRIPESIZE*4)) -i 1 -c $((OSTCOUNT-1))"
5293 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5294 test_mkdir -p $DIR/$tdir
5295 if [[ $STRIPECOUNT -le 0 ]]; then
5297 elif [[ $STRIPECOUNT -gt 2000 ]]; then
5298 #LOV_MAX_STRIPE_COUNT is 2000
5299 [[ $OSTCOUNT -gt 2000 ]] && sc=2000 || sc=$(($OSTCOUNT - 1))
5301 sc=$(($STRIPECOUNT - 1))
5303 $SETSTRIPE -S $STRIPESIZE -c $sc $DIR/$tdir || error "setstripe"
5304 touch $DIR/$tdir/f4 $DIR/$tdir/f5
5305 $LVERIFY $DIR/$tdir $DIR/$tdir/f4 $DIR/$tdir/f5 ||
5306 error "lverify failed"
5308 run_test 65d "directory setstripe -S $STRIPESIZE -c stripe_count"
5311 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5312 test_mkdir -p $DIR/$tdir
5314 $SETSTRIPE $DIR/$tdir || error "setstripe"
5315 $GETSTRIPE -v $DIR/$tdir | grep "Default" ||
5316 error "no stripe info failed"
5318 $LVERIFY $DIR/$tdir $DIR/$tdir/f6 || error "lverify failed"
5320 run_test 65e "directory setstripe defaults ======================="
5323 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5324 test_mkdir -p $DIR/${tdir}f
5325 $RUNAS $SETSTRIPE $DIR/${tdir}f && error "setstripe succeeded" || true
5327 run_test 65f "dir setstripe permission (should return error) ==="
5330 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5331 test_mkdir -p $DIR/$tdir
5332 $SETSTRIPE -S $((STRIPESIZE * 2)) -i 0 -c 1 $DIR/$tdir ||
5334 $SETSTRIPE -d $DIR/$tdir || error "setstripe"
5335 $GETSTRIPE -v $DIR/$tdir | grep "Default" ||
5336 error "delete default stripe failed"
5338 run_test 65g "directory setstripe -d ==========================="
5341 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5342 test_mkdir -p $DIR/$tdir
5343 $SETSTRIPE -S $((STRIPESIZE * 2)) -i 0 -c 1 $DIR/$tdir ||
5345 test_mkdir -p $DIR/$tdir/dd1
5346 [ $($GETSTRIPE -c $DIR/$tdir) == $($GETSTRIPE -c $DIR/$tdir/dd1) ] ||
5347 error "stripe info inherit failed"
5349 run_test 65h "directory stripe info inherit ===================="
5351 test_65i() { # bug6367
5352 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5353 $SETSTRIPE -S 65536 -c -1 $MOUNT
5355 run_test 65i "set non-default striping on root directory (bug 6367)="
5357 test_65ia() { # bug12836
5358 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5359 $GETSTRIPE $MOUNT || error "getstripe $MOUNT failed"
5361 run_test 65ia "getstripe on -1 default directory striping"
5363 test_65ib() { # bug12836
5364 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5365 $GETSTRIPE -v $MOUNT || error "getstripe -v $MOUNT failed"
5367 run_test 65ib "getstripe -v on -1 default directory striping"
5369 test_65ic() { # bug12836
5370 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5371 $LFS find -mtime -1 $MOUNT > /dev/null || error "find $MOUNT failed"
5373 run_test 65ic "new find on -1 default directory striping"
5375 test_65j() { # bug6367
5376 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5378 # if we aren't already remounting for each test, do so for this test
5379 if [ "$CLEANUP" = ":" -a "$I_MOUNTED" = "yes" ]; then
5380 cleanup || error "failed to unmount"
5383 $SETSTRIPE -d $MOUNT || error "setstripe failed"
5385 run_test 65j "set default striping on root directory (bug 6367)="
5387 test_65k() { # bug11679
5388 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5389 [[ $OSTCOUNT -lt 2 ]] && skip_env "too few OSTs" && return
5390 remote_mds_nodsh && skip "remote MDS with nodsh" && return
5392 echo "Check OST status: "
5393 local MDS_OSCS=`do_facet $SINGLEMDS lctl dl |
5394 awk '/[oO][sS][cC].*md[ts]/ { print $4 }'`
5396 for OSC in $MDS_OSCS; do
5397 echo $OSC "is activate"
5398 do_facet $SINGLEMDS lctl --device %$OSC activate
5402 for INACTIVE_OSC in $MDS_OSCS; do
5403 echo "Deactivate: " $INACTIVE_OSC
5404 do_facet $SINGLEMDS lctl --device %$INACTIVE_OSC deactivate
5405 for STRIPE_OSC in $MDS_OSCS; do
5406 OST=`osc_to_ost $STRIPE_OSC`
5407 IDX=`do_facet $SINGLEMDS lctl get_param -n lov.*md*.target_obd |
5408 awk -F: /$OST/'{ print $1 }' | head -n 1`
5410 [ -f $DIR/$tdir/$IDX ] && continue
5411 echo "$SETSTRIPE -i $IDX -c 1 $DIR/$tdir/$IDX"
5412 $SETSTRIPE -i $IDX -c 1 $DIR/$tdir/$IDX
5414 [ $RC -ne 0 ] && error "setstripe should have succeeded"
5417 echo $INACTIVE_OSC "is Activate."
5418 do_facet $SINGLEMDS lctl --device %$INACTIVE_OSC activate
5421 run_test 65k "validate manual striping works properly with deactivated OSCs"
5423 test_65l() { # bug 12836
5424 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5425 test_mkdir -p $DIR/$tdir/test_dir
5426 $SETSTRIPE -c -1 $DIR/$tdir/test_dir
5427 $LFS find -mtime -1 $DIR/$tdir >/dev/null
5429 run_test 65l "lfs find on -1 stripe dir ========================"
5431 # bug 2543 - update blocks count on client
5433 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5435 dd if=/dev/zero of=$DIR/f66 bs=1k count=$COUNT
5436 sync; sync_all_data; sync; sync_all_data
5437 cancel_lru_locks osc
5438 BLOCKS=`ls -s $DIR/f66 | awk '{ print $1 }'`
5439 [ $BLOCKS -ge $COUNT ] || error "$DIR/f66 blocks $BLOCKS < $COUNT"
5441 run_test 66 "update inode blocks count on client ==============="
5446 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5448 if [ ! -z "$LLOOP" ]; then
5449 if swapon -s | grep -q $LLOOP; then
5450 swapoff $LLOOP || error "swapoff failed"
5453 $LCTL blockdev_detach $LLOOP || error "detach failed"
5457 if [ ! -z "$LLITELOOPLOAD" ]; then
5465 awk '($1 == "'$1':") { print $2 }' /proc/meminfo
5469 swapon -s | awk '($1 == "'$1'") { print $4 }'
5472 # test case for lloop driver, basic function
5474 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5475 [ "$UID" != 0 ] && skip_env "must run as root" && return
5476 llite_lloop_enabled || \
5477 { skip_env "llite_lloop module disabled" && return; }
5479 trap cleanup_68 EXIT
5481 if ! module_loaded llite_lloop; then
5482 if load_module llite/llite_lloop; then
5485 skip_env "can't find module llite_lloop"
5490 LLOOP=$TMP/lloop.`date +%s`.`date +%N`
5491 dd if=/dev/zero of=$DIR/f68a bs=4k count=1024
5492 $LCTL blockdev_attach $DIR/f68a $LLOOP || error "attach failed"
5494 directio rdwr $LLOOP 0 1024 4096 || error "direct write failed"
5495 directio rdwr $LLOOP 0 1025 4096 && error "direct write should fail"
5499 run_test 68a "lloop driver - basic test ========================"
5501 # excercise swapping to lustre by adding a high priority swapfile entry
5502 # and then consuming memory until it is used.
5503 test_68b() { # was test_68
5504 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5505 [ "$UID" != 0 ] && skip_env "must run as root" && return
5506 lctl get_param -n devices | grep -q obdfilter && \
5507 skip "local OST" && return
5509 grep -q llite_lloop /proc/modules
5510 [ $? -ne 0 ] && skip "can't find module llite_lloop" && return
5512 [ -z "`$LCTL list_nids | grep -v tcp`" ] && \
5513 skip "can't reliably test swap with TCP" && return
5515 MEMTOTAL=`meminfo MemTotal`
5516 NR_BLOCKS=$((MEMTOTAL>>8))
5517 [[ $NR_BLOCKS -le 2048 ]] && NR_BLOCKS=2048
5519 LLOOP=$TMP/lloop.`date +%s`.`date +%N`
5520 dd if=/dev/zero of=$DIR/f68b bs=64k seek=$NR_BLOCKS count=1
5523 $LCTL blockdev_attach $DIR/f68b $LLOOP || error "attach failed"
5525 trap cleanup_68 EXIT
5527 swapon -p 32767 $LLOOP || error "swapon $LLOOP failed"
5529 echo "before: `swapon -s | grep $LLOOP`"
5530 $MEMHOG $MEMTOTAL || error "error allocating $MEMTOTAL kB"
5531 echo "after: `swapon -s | grep $LLOOP`"
5532 SWAPUSED=`swap_used $LLOOP`
5536 [ $SWAPUSED -eq 0 ] && echo "no swap used???" || true
5538 run_test 68b "support swapping to Lustre ========================"
5540 # bug5265, obdfilter oa2dentry return -ENOENT
5541 # #define OBD_FAIL_OST_ENOENT 0x217
5543 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5544 remote_ost_nodsh && skip "remote OST with nodsh" && return
5547 $SETSTRIPE -c 1 -i 0 $f
5549 $DIRECTIO write ${f}.2 0 1 || error "directio write error"
5551 do_facet ost1 lctl set_param fail_loc=0x217
5552 $TRUNCATE $f 1 # vmtruncate() will ignore truncate() error.
5553 $DIRECTIO write $f 0 2 && error "write succeeded, expect -ENOENT"
5555 do_facet ost1 lctl set_param fail_loc=0
5556 $DIRECTIO write $f 0 2 || error "write error"
5558 cancel_lru_locks osc
5559 $DIRECTIO read $f 0 1 || error "read error"
5561 do_facet ost1 lctl set_param fail_loc=0x217
5562 $DIRECTIO read $f 1 1 && error "read succeeded, expect -ENOENT"
5564 do_facet ost1 lctl set_param fail_loc=0
5567 run_test 69 "verify oa2dentry return -ENOENT doesn't LBUG ======"
5570 test_mkdir -p $DIR/$tdir
5571 sh rundbench -C -D $DIR/$tdir 2 || error "dbench failed!"
5573 run_test 71 "Running dbench on lustre (don't segment fault) ===="
5575 test_72a() { # bug 5695 - Test that on 2.6 remove_suid works properly
5576 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5577 [ "$RUNAS_ID" = "$UID" ] &&
5578 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
5580 # Check that testing environment is properly set up. Skip if not
5581 FAIL_ON_ERROR=false check_runas_id_ret $RUNAS_ID $RUNAS_GID $RUNAS || {
5582 skip_env "User $RUNAS_ID does not exist - skipping"
5586 chmod 777 $DIR/$tfile
5587 chmod ug+s $DIR/$tfile
5588 $RUNAS dd if=/dev/zero of=$DIR/$tfile bs=512 count=1 ||
5589 error "$RUNAS dd $DIR/$tfile failed"
5590 # See if we are still setuid/sgid
5591 test -u $DIR/$tfile -o -g $DIR/$tfile &&
5592 error "S/gid is not dropped on write"
5593 # Now test that MDS is updated too
5594 cancel_lru_locks mdc
5595 test -u $DIR/$tfile -o -g $DIR/$tfile &&
5596 error "S/gid is not dropped on MDS"
5599 run_test 72a "Test that remove suid works properly (bug5695) ===="
5601 test_72b() { # bug 24226 -- keep mode setting when size is not changing
5604 [ "$RUNAS_ID" = "$UID" ] && \
5605 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
5606 [ "$RUNAS_ID" -eq 0 ] && \
5607 skip_env "RUNAS_ID = 0 -- skipping" && return
5609 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5610 # Check that testing environment is properly set up. Skip if not
5611 FAIL_ON_ERROR=false check_runas_id_ret $RUNAS_ID $RUNAS_ID $RUNAS || {
5612 skip_env "User $RUNAS_ID does not exist - skipping"
5615 touch $DIR/${tfile}-f{g,u}
5616 test_mkdir $DIR/${tfile}-dg
5617 test_mkdir $DIR/${tfile}-du
5618 chmod 770 $DIR/${tfile}-{f,d}{g,u}
5619 chmod g+s $DIR/${tfile}-{f,d}g
5620 chmod u+s $DIR/${tfile}-{f,d}u
5621 for perm in 777 2777 4777; do
5622 $RUNAS chmod $perm $DIR/${tfile}-fg && error "S/gid file allowed improper chmod to $perm"
5623 $RUNAS chmod $perm $DIR/${tfile}-fu && error "S/uid file allowed improper chmod to $perm"
5624 $RUNAS chmod $perm $DIR/${tfile}-dg && error "S/gid dir allowed improper chmod to $perm"
5625 $RUNAS chmod $perm $DIR/${tfile}-du && error "S/uid dir allowed improper chmod to $perm"
5629 run_test 72b "Test that we keep mode setting if without file data changed (bug 24226)"
5631 # bug 3462 - multiple simultaneous MDC requests
5633 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5634 test_mkdir $DIR/d73-1
5635 test_mkdir $DIR/d73-2
5636 multiop_bg_pause $DIR/d73-1/f73-1 O_c || return 1
5639 lctl set_param fail_loc=0x80000129
5640 $MULTIOP $DIR/d73-1/f73-2 Oc &
5642 lctl set_param fail_loc=0
5644 $MULTIOP $DIR/d73-2/f73-3 Oc &
5648 wait $pid1 || return 1
5652 $CHECKSTAT -t file $DIR/d73-1/f73-1 || return 4
5653 $CHECKSTAT -t file $DIR/d73-1/f73-2 || return 5
5654 $CHECKSTAT -t file $DIR/d73-2/f73-3 || return 6
5658 run_test 73 "multiple MDC requests (should not deadlock)"
5660 test_74a() { # bug 6149, 6184
5661 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5662 #define OBD_FAIL_LDLM_ENQUEUE_OLD_EXPORT 0x30e
5664 # very important to OR with OBD_FAIL_ONCE (0x80000000) -- otherwise it
5665 # will spin in a tight reconnection loop
5667 $LCTL set_param fail_loc=0x8000030e
5668 # get any lock that won't be difficult - lookup works.
5670 $LCTL set_param fail_loc=0
5674 run_test 74a "ldlm_enqueue freed-export error path, ls (shouldn't LBUG)"
5676 test_74b() { # bug 13310
5677 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5678 #define OBD_FAIL_LDLM_ENQUEUE_OLD_EXPORT 0x30e
5680 # very important to OR with OBD_FAIL_ONCE (0x80000000) -- otherwise it
5681 # will spin in a tight reconnection loop
5682 $LCTL set_param fail_loc=0x8000030e
5683 # get a "difficult" lock
5685 $LCTL set_param fail_loc=0
5689 run_test 74b "ldlm_enqueue freed-export error path, touch (shouldn't LBUG)"
5692 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5693 #define OBD_FAIL_LDLM_NEW_LOCK
5694 $LCTL set_param fail_loc=0x319
5695 touch $DIR/$tfile && error "touch successful"
5696 $LCTL set_param fail_loc=0
5699 run_test 74c "ldlm_lock_create error path, (shouldn't LBUG)"
5702 awk '/lustre_inode_cache/ {print $2; exit}' /proc/slabinfo
5705 get_inode_slab_tunables() {
5706 awk '/lustre_inode_cache/ {print $9," ",$10," ",$11; exit}' /proc/slabinfo
5709 set_inode_slab_tunables() {
5710 echo "lustre_inode_cache $1" > /proc/slabinfo
5713 test_76() { # Now for bug 20433, added originally in bug 1443
5714 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5715 local SLAB_SETTINGS=`get_inode_slab_tunables`
5716 local CPUS=`getconf _NPROCESSORS_ONLN`
5717 # we cannot set limit below 1 which means 1 inode in each
5718 # per-cpu cache is still allowed
5719 set_inode_slab_tunables "1 1 0"
5720 cancel_lru_locks osc
5721 BEFORE_INODES=$(num_inodes)
5722 echo "before inodes: $BEFORE_INODES"
5724 [ "$SLOW" = "no" ] && COUNT=100
5725 for i in $(seq $COUNT); do
5729 cancel_lru_locks osc
5730 AFTER_INODES=$(num_inodes)
5731 echo "after inodes: $AFTER_INODES"
5733 while [[ $((AFTER_INODES-1*CPUS)) -gt $BEFORE_INODES ]]; do
5735 AFTER_INODES=$(num_inodes)
5737 echo "wait $wait seconds inodes: $AFTER_INODES"
5738 if [ $wait -gt 30 ]; then
5739 error "inode slab grew from $BEFORE_INODES to $AFTER_INODES"
5742 set_inode_slab_tunables "$SLAB_SETTINGS"
5744 run_test 76 "confirm clients recycle inodes properly ===="
5750 # Note: in sptlrpc modes which enable its own bulk checksum, the
5751 # original crc32_le bulk checksum will be automatically disabled,
5752 # and the OBD_FAIL_OSC_CHECKSUM_SEND/OBD_FAIL_OSC_CHECKSUM_RECEIVE
5753 # will be checked by sptlrpc code against sptlrpc bulk checksum.
5754 # In this case set_checksums() will not be no-op, because sptlrpc
5755 # bulk checksum will be enabled all through the test.
5757 [ "$ORIG_CSUM" ] || ORIG_CSUM=`lctl get_param -n osc.*.checksums | head -n1`
5758 lctl set_param -n osc.*.checksums $1
5762 export ORIG_CSUM_TYPE="`lctl get_param -n osc.*osc-[^mM]*.checksum_type |
5763 sed 's/.*\[\(.*\)\].*/\1/g' | head -n1`"
5764 CKSUM_TYPES=${CKSUM_TYPES:-"crc32 adler"}
5765 [ "$ORIG_CSUM_TYPE" = "crc32c" ] && CKSUM_TYPES="$CKSUM_TYPES crc32c"
5768 lctl set_param -n osc.*osc-[^mM]*.checksum_type $1
5769 log "set checksum type to $1"
5772 F77_TMP=$TMP/f77-temp
5775 dd if=/dev/urandom of=$F77_TMP bs=1M count=$F77SZ || \
5776 error "error writing to $F77_TMP"
5779 test_77a() { # bug 10889
5780 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5781 $GSS && skip "could not run with gss" && return
5782 [ ! -f $F77_TMP ] && setup_f77
5784 dd if=$F77_TMP of=$DIR/$tfile bs=1M count=$F77SZ || error "dd error"
5788 run_test 77a "normal checksum read/write operation"
5790 test_77b() { # bug 10889
5791 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5792 $GSS && skip "could not run with gss" && return
5793 [ ! -f $F77_TMP ] && setup_f77
5794 #define OBD_FAIL_OSC_CHECKSUM_SEND 0x409
5795 $LCTL set_param fail_loc=0x80000409
5798 dd if=$F77_TMP of=$DIR/$tfile bs=1M count=$F77SZ conv=sync ||
5799 error "dd error: $?"
5800 $LCTL set_param fail_loc=0
5802 for algo in $CKSUM_TYPES; do
5803 cancel_lru_locks osc
5804 set_checksum_type $algo
5805 #define OBD_FAIL_OSC_CHECKSUM_RECEIVE 0x408
5806 $LCTL set_param fail_loc=0x80000408
5807 cmp $F77_TMP $DIR/$tfile || error "file compare failed"
5808 $LCTL set_param fail_loc=0
5811 set_checksum_type $ORIG_CSUM_TYPE
5814 run_test 77b "checksum error on client write, read"
5816 test_77d() { # bug 10889
5817 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5818 $GSS && skip "could not run with gss" && return
5819 #define OBD_FAIL_OSC_CHECKSUM_SEND 0x409
5820 $LCTL set_param fail_loc=0x80000409
5822 $DIRECTIO write $DIR/$tfile 0 $F77SZ $((1024 * 1024)) ||
5823 error "direct write: rc=$?"
5824 $LCTL set_param fail_loc=0
5827 #define OBD_FAIL_OSC_CHECKSUM_RECEIVE 0x408
5828 $LCTL set_param fail_loc=0x80000408
5830 cancel_lru_locks osc
5831 $DIRECTIO read $DIR/$tfile 0 $F77SZ $((1024 * 1024)) ||
5832 error "direct read: rc=$?"
5833 $LCTL set_param fail_loc=0
5836 run_test 77d "checksum error on OST direct write, read"
5838 test_77f() { # bug 10889
5839 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5840 $GSS && skip "could not run with gss" && return
5842 for algo in $CKSUM_TYPES; do
5843 cancel_lru_locks osc
5844 set_checksum_type $algo
5845 #define OBD_FAIL_OSC_CHECKSUM_SEND 0x409
5846 $LCTL set_param fail_loc=0x409
5847 $DIRECTIO write $DIR/$tfile 0 $F77SZ $((1024 * 1024)) &&
5848 error "direct write succeeded"
5849 $LCTL set_param fail_loc=0
5851 set_checksum_type $ORIG_CSUM_TYPE
5854 run_test 77f "repeat checksum error on write (expect error)"
5856 test_77g() { # bug 10889
5857 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5858 $GSS && skip "could not run with gss" && return
5859 remote_ost_nodsh && skip "remote OST with nodsh" && return
5861 [ ! -f $F77_TMP ] && setup_f77
5863 $SETSTRIPE -c 1 -i 0 $DIR/$tfile
5864 #define OBD_FAIL_OST_CHECKSUM_RECEIVE 0x21a
5865 do_facet ost1 lctl set_param fail_loc=0x8000021a
5867 dd if=$F77_TMP of=$DIR/$tfile bs=1M count=$F77SZ ||
5868 error "write error: rc=$?"
5869 do_facet ost1 lctl set_param fail_loc=0
5872 cancel_lru_locks osc
5873 #define OBD_FAIL_OST_CHECKSUM_SEND 0x21b
5874 do_facet ost1 lctl set_param fail_loc=0x8000021b
5876 cmp $F77_TMP $DIR/$tfile || error "file compare failed"
5877 do_facet ost1 lctl set_param fail_loc=0
5880 run_test 77g "checksum error on OST write, read"
5882 test_77i() { # bug 13805
5883 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5884 $GSS && skip "could not run with gss" && return
5885 #define OBD_FAIL_OSC_CONNECT_CKSUM 0x40b
5886 lctl set_param fail_loc=0x40b
5887 remount_client $MOUNT
5888 lctl set_param fail_loc=0
5889 for VALUE in `lctl get_param osc.*osc-[^mM]*.checksum_type`; do
5890 PARAM=`echo ${VALUE[0]} | cut -d "=" -f1`
5891 algo=`lctl get_param -n $PARAM | sed 's/.*\[\(.*\)\].*/\1/g'`
5892 [ "$algo" = "adler" ] || error "algo set to $algo instead of adler"
5894 remount_client $MOUNT
5896 run_test 77i "client not supporting OSD_CONNECT_CKSUM"
5898 test_77j() { # bug 13805
5899 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5900 $GSS && skip "could not run with gss" && return
5901 #define OBD_FAIL_OSC_CKSUM_ADLER_ONLY 0x40c
5902 lctl set_param fail_loc=0x40c
5903 remount_client $MOUNT
5904 lctl set_param fail_loc=0
5905 sleep 2 # wait async osc connect to finish
5906 for VALUE in `lctl get_param osc.*osc-[^mM]*.checksum_type`; do
5907 PARAM=`echo ${VALUE[0]} | cut -d "=" -f1`
5908 algo=`lctl get_param -n $PARAM | sed 's/.*\[\(.*\)\].*/\1/g'`
5909 [ "$algo" = "adler" ] || error "algo set to $algo instead of adler"
5911 remount_client $MOUNT
5913 run_test 77j "client only supporting ADLER32"
5915 [ "$ORIG_CSUM" ] && set_checksums $ORIG_CSUM || true
5919 test_78() { # bug 10901
5920 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5921 remote_ost || { skip_env "local OST" && return; }
5924 F78SIZE=$(($(awk '/MemFree:/ { print $2 }' /proc/meminfo) / 1024))
5925 echo "MemFree: $F78SIZE, Max file size: $MAXFREE"
5926 MEMTOTAL=$(($(awk '/MemTotal:/ { print $2 }' /proc/meminfo) / 1024))
5927 echo "MemTotal: $MEMTOTAL"
5929 # reserve 256MB of memory for the kernel and other running processes,
5930 # and then take 1/2 of the remaining memory for the read/write buffers.
5931 if [ $MEMTOTAL -gt 512 ] ;then
5932 MEMTOTAL=$(((MEMTOTAL - 256 ) / 2))
5934 # for those poor memory-starved high-end clusters...
5935 MEMTOTAL=$((MEMTOTAL / 2))
5937 echo "Mem to use for directio: $MEMTOTAL"
5939 [[ $F78SIZE -gt $MEMTOTAL ]] && F78SIZE=$MEMTOTAL
5940 [[ $F78SIZE -gt 512 ]] && F78SIZE=512
5941 [[ $F78SIZE -gt $((MAXFREE / 1024)) ]] && F78SIZE=$((MAXFREE / 1024))
5942 SMALLESTOST=$($LFS df $DIR | grep OST | awk '{ print $4 }' | sort -n |
5944 echo "Smallest OST: $SMALLESTOST"
5945 [[ $SMALLESTOST -lt 10240 ]] &&
5946 skip "too small OSTSIZE, useless to run large O_DIRECT test" && return 0
5948 [[ $F78SIZE -gt $((SMALLESTOST * $OSTCOUNT / 1024 - 80)) ]] &&
5949 F78SIZE=$((SMALLESTOST * $OSTCOUNT / 1024 - 80))
5951 [ "$SLOW" = "no" ] && NSEQ=1 && [ $F78SIZE -gt 32 ] && F78SIZE=32
5952 echo "File size: $F78SIZE"
5953 $SETSTRIPE -c $OSTCOUNT $DIR/$tfile || error "setstripe failed"
5954 for i in $(seq 1 $NSEQ); do
5955 FSIZE=$(($F78SIZE / ($NSEQ - $i + 1)))
5956 echo directIO rdwr round $i of $NSEQ
5957 $DIRECTIO rdwr $DIR/$tfile 0 $FSIZE 1048576||error "rdwr failed"
5962 run_test 78 "handle large O_DIRECT writes correctly ============"
5964 test_79() { # bug 12743
5965 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5966 wait_delete_completed
5968 BKTOTAL=$(calc_osc_kbytes kbytestotal)
5969 BKFREE=$(calc_osc_kbytes kbytesfree)
5970 BKAVAIL=$(calc_osc_kbytes kbytesavail)
5972 STRING=`df -P $MOUNT | tail -n 1 | awk '{print $2","$3","$4}'`
5973 DFTOTAL=`echo $STRING | cut -d, -f1`
5974 DFUSED=`echo $STRING | cut -d, -f2`
5975 DFAVAIL=`echo $STRING | cut -d, -f3`
5976 DFFREE=$(($DFTOTAL - $DFUSED))
5978 ALLOWANCE=$((64 * $OSTCOUNT))
5980 if [ $DFTOTAL -lt $(($BKTOTAL - $ALLOWANCE)) ] ||
5981 [ $DFTOTAL -gt $(($BKTOTAL + $ALLOWANCE)) ] ; then
5982 error "df total($DFTOTAL) mismatch OST total($BKTOTAL)"
5984 if [ $DFFREE -lt $(($BKFREE - $ALLOWANCE)) ] ||
5985 [ $DFFREE -gt $(($BKFREE + $ALLOWANCE)) ] ; then
5986 error "df free($DFFREE) mismatch OST free($BKFREE)"
5988 if [ $DFAVAIL -lt $(($BKAVAIL - $ALLOWANCE)) ] ||
5989 [ $DFAVAIL -gt $(($BKAVAIL + $ALLOWANCE)) ] ; then
5990 error "df avail($DFAVAIL) mismatch OST avail($BKAVAIL)"
5993 run_test 79 "df report consistency check ======================="
5995 test_80() { # bug 10718
5996 remote_ost_nodsh && skip "remote OST with nodsh" && return
5997 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5998 # relax strong synchronous semantics for slow backends like ZFS
5999 local soc="obdfilter.*.sync_on_lock_cancel"
6000 local soc_old=$(do_facet ost1 lctl get_param -n $soc | head -n1)
6002 if [ "$soc_old" != "never" -a "$(facet_fstype ost1)" != "ldiskfs" ]; then
6003 hosts=$(for host in $(seq -f "ost%g" 1 $OSTCOUNT); do
6004 facet_active_host $host; done | sort -u)
6005 do_nodes $hosts lctl set_param $soc=never
6008 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=1M
6010 local BEFORE=`date +%s`
6011 cancel_lru_locks osc
6012 local AFTER=`date +%s`
6013 local DIFF=$((AFTER-BEFORE))
6014 if [ $DIFF -gt 1 ] ; then
6015 error "elapsed for 1M@1T = $DIFF"
6018 [ -n "$hosts" ] && do_nodes $hosts lctl set_param $soc=$soc_old
6022 run_test 80 "Page eviction is equally fast at high offsets too ===="
6024 test_81a() { # LU-456
6025 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6026 remote_ost_nodsh && skip "remote OST with nodsh" && return
6027 # define OBD_FAIL_OST_MAPBLK_ENOSPC 0x228
6028 # MUST OR with the OBD_FAIL_ONCE (0x80000000)
6029 do_facet ost1 lctl set_param fail_loc=0x80000228
6031 # write should trigger a retry and success
6032 $SETSTRIPE -i 0 -c 1 $DIR/$tfile
6033 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
6035 if [ $RC -ne 0 ] ; then
6036 error "write should success, but failed for $RC"
6039 run_test 81a "OST should retry write when get -ENOSPC ==============="
6041 test_81b() { # LU-456
6042 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6043 remote_ost_nodsh && skip "remote OST with nodsh" && return
6044 # define OBD_FAIL_OST_MAPBLK_ENOSPC 0x228
6045 # Don't OR with the OBD_FAIL_ONCE (0x80000000)
6046 do_facet ost1 lctl set_param fail_loc=0x228
6048 # write should retry several times and return -ENOSPC finally
6049 $SETSTRIPE -i 0 -c 1 $DIR/$tfile
6050 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
6053 if [ $RC -ne $ENOSPC ] ; then
6054 error "dd should fail for -ENOSPC, but succeed."
6057 run_test 81b "OST should return -ENOSPC when retry still fails ======="
6059 test_82() { # LU-1031
6060 dd if=/dev/zero of=$DIR/$tfile bs=1M count=10
6064 multiop_bg_pause $DIR/$tfile OG${gid1}_g${gid1}c || return 1
6066 multiop_bg_pause $DIR/$tfile O_G${gid2}r10g${gid2}c || return 2
6068 kill -USR1 $MULTIPID2
6070 if [[ `ps h -o comm -p $MULTIPID2` == "" ]]; then
6071 error "First grouplock does not block second one"
6073 echo "Second grouplock blocks first one"
6075 kill -USR1 $MULTIPID1
6079 run_test 82 "Basic grouplock test ==============================="
6082 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" &&
6084 test_mkdir -p $DIR/d99cvsroot
6085 chown $RUNAS_ID $DIR/d99cvsroot
6086 local oldPWD=$PWD # bug 13584, use $TMP as working dir
6089 $RUNAS cvs -d $DIR/d99cvsroot init || error "cvs init failed"
6092 run_test 99a "cvs init ========================================="
6095 [ -z "$(which cvs 2>/dev/null)" ] &&
6096 skip_env "could not find cvs" && return
6097 [ ! -d $DIR/d99cvsroot ] && test_99a
6099 # some versions of cvs import exit(1) when asked to import links or
6100 # files they can't read. ignore those files.
6101 TOIGNORE=$(find . -type l -printf '-I %f\n' -o \
6102 ! -perm +4 -printf '-I %f\n')
6103 $RUNAS cvs -d $DIR/d99cvsroot import -m "nomesg" $TOIGNORE \
6104 d99reposname vtag rtag
6106 run_test 99b "cvs import ======================================="
6109 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" && return
6110 [ ! -d $DIR/d99cvsroot ] && test_99b
6112 test_mkdir -p $DIR/d99reposname
6113 chown $RUNAS_ID $DIR/d99reposname
6114 $RUNAS cvs -d $DIR/d99cvsroot co d99reposname
6116 run_test 99c "cvs checkout ====================================="
6119 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" && return
6120 [ ! -d $DIR/d99cvsroot ] && test_99c
6121 cd $DIR/d99reposname
6123 $RUNAS cvs add -m 'addmsg' foo99
6125 run_test 99d "cvs add =========================================="
6128 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" && return
6129 [ ! -d $DIR/d99cvsroot ] && test_99c
6130 cd $DIR/d99reposname
6133 run_test 99e "cvs update ======================================="
6136 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" && return
6137 [ ! -d $DIR/d99cvsroot ] && test_99d
6138 cd $DIR/d99reposname
6139 $RUNAS cvs commit -m 'nomsg' foo99
6140 rm -fr $DIR/d99cvsroot
6142 run_test 99f "cvs commit ======================================="
6145 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6146 [ "$NETTYPE" = tcp ] || \
6147 { skip "TCP secure port test, not useful for NETTYPE=$NETTYPE" && \
6150 remote_ost_nodsh && skip "remote OST with nodsh" && return
6151 remote_mds_nodsh && skip "remote MDS with nodsh" && return
6153 { skip "useless for local single node setup" && return; }
6155 netstat -tna | ( rc=1; while read PROT SND RCV LOCAL REMOTE STAT; do
6156 [ "$PROT" != "tcp" ] && continue
6157 RPORT=$(echo $REMOTE | cut -d: -f2)
6158 [ "$RPORT" != "$ACCEPTOR_PORT" ] && continue
6161 LPORT=`echo $LOCAL | cut -d: -f2`
6162 if [ $LPORT -ge 1024 ]; then
6163 echo "bad: $PROT $SND $RCV $LOCAL $REMOTE $STAT"
6165 error_exit "local: $LPORT > 1024, remote: $RPORT"
6168 [ "$rc" = 0 ] || error_exit "privileged port not found" )
6170 run_test 100 "check local port using privileged port ==========="
6172 function get_named_value()
6181 echo $line | sed "s/^$tag[ ]*//"
6188 export CACHE_MAX=$($LCTL get_param -n llite.*.max_cached_mb |
6189 awk '/^max_cached_mb/ { print $2 }')
6192 $LCTL set_param -n llite.*.max_cached_mb $CACHE_MAX
6197 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6198 [ $MDSCOUNT -ge 2 ] && skip "skip now for >= 2 MDTs" && return #LU-4322
6202 local cache_limit=32
6204 $LCTL set_param -n osc.*-osc*.rpc_stats 0
6205 trap cleanup_101a EXIT
6206 $LCTL set_param -n llite.*.read_ahead_stats 0
6207 $LCTL set_param -n llite.*.max_cached_mb $cache_limit
6210 # randomly read 10000 of 64K chunks from file 3x 32MB in size
6212 echo "nreads: $nreads file size: $((cache_limit * 3))MB"
6213 $READS -f $DIR/$tfile -s$((cache_limit * 3192 * 1024)) -b65536 -C -n$nreads -t 180
6216 for s in $($LCTL get_param -n llite.*.read_ahead_stats |
6217 get_named_value 'read but discarded' | cut -d" " -f1); do
6218 discard=$(($discard + $s))
6222 if [[ $(($discard * 10)) -gt $nreads ]]; then
6223 $LCTL get_param osc.*-osc*.rpc_stats
6224 $LCTL get_param llite.*.read_ahead_stats
6225 error "too many ($discard) discarded pages"
6227 rm -f $DIR/$tfile || true
6229 run_test 101a "check read-ahead for random reads ================"
6232 test_mkdir -p $DIR/$tdir
6233 local STRIPE_SIZE=$1
6234 local FILE_LENGTH=$2
6237 local FILE_SIZE_MB=$((FILE_LENGTH / STRIPE_SIZE))
6239 local list=$(comma_list $(osts_nodes))
6240 set_osd_param $list '' read_cache_enable 0
6241 set_osd_param $list '' writethrough_cache_enable 0
6243 trap cleanup_test101bc EXIT
6244 # prepare the read-ahead file
6245 $SETSTRIPE -S $STRIPE_SIZE -i $STRIPE_OFFSET -c $OSTCOUNT $DIR/$tfile
6247 dd if=/dev/zero of=$DIR/$tfile bs=$STRIPE_SIZE \
6248 count=$FILE_SIZE_MB 2> /dev/null
6252 cleanup_test101bc() {
6257 local list=$(comma_list $(osts_nodes))
6258 set_osd_param $list '' read_cache_enable 1
6259 set_osd_param $list '' writethrough_cache_enable 1
6263 awk 'BEGIN{total=0}; {total+=$1}; END{print total}'
6268 local STRIPE_SIZE=$2
6269 local FILE_LENGTH=$3
6270 local RA_INC=1048576
6271 local STRIDE_LENGTH=$((STRIPE_SIZE/READ_SIZE))
6272 local discard_limit=$((((STRIDE_LENGTH - 1)*3/(STRIDE_LENGTH*OSTCOUNT))* \
6273 (STRIDE_LENGTH*OSTCOUNT - STRIDE_LENGTH)))
6274 DISCARD=$($LCTL get_param -n llite.*.read_ahead_stats |
6275 get_named_value 'read but discarded' |
6276 cut -d" " -f1 | calc_total)
6277 if [[ $DISCARD -gt $discard_limit ]]; then
6278 $LCTL get_param llite.*.read_ahead_stats
6279 error "Too many ($DISCARD) discarded pages with size (${READ_SIZE})"
6281 echo "Read-ahead success for size ${READ_SIZE}"
6286 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6287 [[ $OSTCOUNT -lt 2 ]] &&
6288 skip_env "skipping stride IO stride-ahead test" && return
6289 local STRIPE_SIZE=1048576
6290 local STRIDE_SIZE=$((STRIPE_SIZE*OSTCOUNT))
6291 if [ $SLOW == "yes" ]; then
6292 local FILE_LENGTH=$((STRIDE_SIZE * 64))
6294 local FILE_LENGTH=$((STRIDE_SIZE * 8))
6297 local ITERATION=$((FILE_LENGTH / STRIDE_SIZE))
6299 # prepare the read-ahead file
6300 setup_test101bc $STRIPE_SIZE $FILE_LENGTH
6301 cancel_lru_locks osc
6302 for BIDX in 2 4 8 16 32 64 128 256
6304 local BSIZE=$((BIDX*4096))
6305 local READ_COUNT=$((STRIPE_SIZE/BSIZE))
6306 local STRIDE_LENGTH=$((STRIDE_SIZE/BSIZE))
6307 local OFFSET=$((STRIPE_SIZE/BSIZE*(OSTCOUNT - 1)))
6308 $LCTL set_param -n llite.*.read_ahead_stats 0
6309 $READS -f $DIR/$tfile -l $STRIDE_LENGTH -o $OFFSET \
6310 -s $FILE_LENGTH -b $STRIPE_SIZE -a $READ_COUNT -n $ITERATION
6311 cancel_lru_locks osc
6312 ra_check_101 $BSIZE $STRIPE_SIZE $FILE_LENGTH
6317 run_test 101b "check stride-io mode read-ahead ================="
6320 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6321 local STRIPE_SIZE=1048576
6322 local FILE_LENGTH=$((STRIPE_SIZE*100))
6326 setup_test101bc $STRIPE_SIZE $FILE_LENGTH
6328 cancel_lru_locks osc
6329 $LCTL set_param osc.*.rpc_stats 0
6330 $READS -f $DIR/$tfile -s$FILE_LENGTH -b65536 -n$nreads -t 180
6331 for osc_rpc_stats in $($LCTL get_param -N osc.*.rpc_stats); do
6332 local stats=$($LCTL get_param -n $osc_rpc_stats)
6333 local lines=$(echo "$stats" | awk 'END {print NR;}')
6336 if [ $lines -le 20 ]; then
6339 for size in 1 2 4 8; do
6340 local rpc=$(echo "$stats" |
6341 awk '($1 == "'$size':") {print $2; exit; }')
6343 error "Small $((size*4))k read IO $rpc !"
6345 echo "$osc_rpc_stats check passed!"
6350 run_test 101c "check stripe_size aligned read-ahead ================="
6353 $LCTL get_param -n llite.*.max_read_ahead_mb | head -n 1
6354 $LCTL set_param -n llite.*.max_read_ahead_mb $1 > /dev/null 2>&1
6358 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6359 local file=$DIR/$tfile
6360 local sz_MB=${FILESIZE_101d:-500}
6361 local ra_MB=${READAHEAD_MB:-40}
6363 local free_MB=$(($(df -P $DIR | tail -n 1 | awk '{ print $4 }') / 1024))
6364 [ $free_MB -lt $sz_MB ] &&
6365 skip "Need free space ${sz_MB}M, have ${free_MB}M" && return
6367 echo "Create test file $file size ${sz_MB}M, ${free_MB}M free"
6368 $SETSTRIPE -c -1 $file || error "setstripe failed"
6370 dd if=/dev/zero of=$file bs=1M count=$sz_MB || error "dd failed"
6371 echo Cancel LRU locks on lustre client to flush the client cache
6372 cancel_lru_locks osc
6374 echo Disable read-ahead
6375 local old_READAHEAD=$(set_read_ahead 0)
6377 echo Reading the test file $file with read-ahead disabled
6378 local raOFF=$(do_and_time "dd if=$file of=/dev/null bs=1M count=$sz_MB")
6380 echo Cancel LRU locks on lustre client to flush the client cache
6381 cancel_lru_locks osc
6382 echo Enable read-ahead with ${ra_MB}MB
6383 set_read_ahead $ra_MB
6385 echo Reading the test file $file with read-ahead enabled
6386 local raON=$(do_and_time "dd if=$file of=/dev/null bs=1M count=$sz_MB")
6388 echo "read-ahead disabled time read $raOFF"
6389 echo "read-ahead enabled time read $raON"
6391 set_read_ahead $old_READAHEAD
6393 wait_delete_completed
6395 [ $raOFF -le 1 -o $raON -lt $raOFF ] ||
6396 error "readahead ${raON}s > no-readahead ${raOFF}s ${sz_MB}M"
6398 run_test 101d "file read with and without read-ahead enabled"
6401 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6402 local file=$DIR/$tfile
6403 local size_KB=500 #KB
6407 local free_KB=$(df -P $DIR | tail -n 1 | awk '{ print $4 }')
6408 local need_KB=$((count * size_KB))
6409 [[ $free_KB -le $need_KB ]] &&
6410 skip_env "Need free space $need_KB, have $free_KB" && return
6412 echo "Creating $count ${size_KB}K test files"
6413 for ((i = 0; i < $count; i++)); do
6414 dd if=/dev/zero of=$file.$i bs=$bsize count=$size_KB 2>/dev/null
6417 echo "Cancel LRU locks on lustre client to flush the client cache"
6418 cancel_lru_locks osc
6420 echo "Reset readahead stats"
6421 $LCTL set_param -n llite.*.read_ahead_stats 0
6423 for ((i = 0; i < $count; i++)); do
6424 dd if=$file.$i of=/dev/null bs=$bsize count=$size_KB 2>/dev/null
6427 local miss=$($LCTL get_param -n llite.*.read_ahead_stats |
6428 get_named_value 'misses' | cut -d" " -f1 | calc_total)
6430 for ((i = 0; i < $count; i++)); do
6431 rm -rf $file.$i 2>/dev/null
6434 #10000 means 20% reads are missing in readahead
6435 [[ $miss -lt 10000 ]] || error "misses too much for small reads"
6437 run_test 101e "check read-ahead for small read(1k) for small files(500k)"
6439 cleanup_test101f() {
6441 $LCTL set_param -n llite.*.max_read_ahead_whole_mb $MAX_WHOLE_MB
6442 rm -rf $DIR/$tfile 2>/dev/null
6446 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6447 local file=$DIR/$tfile
6450 MAX_WHOLE_MB=$($LCTL get_param -n llite.*.max_read_ahead_whole_mb)
6451 $LCTL set_param -n llite.*.max_read_ahead_whole_mb 2
6452 dd if=/dev/zero of=${file} bs=2097152 count=1 2>/dev/null
6453 trap cleanup_test101f EXIT
6455 echo Cancel LRU locks on lustre client to flush the client cache
6456 cancel_lru_locks osc
6458 echo Reset readahead stats
6459 $LCTL set_param -n llite.*.read_ahead_stats 0
6460 # Random read in a 2M file, because max_read_ahead_whole_mb = 2M,
6461 # readahead should read in 2M file on second read, so only miss
6463 echo Random 4K reads on 2M file for 1000 times
6464 $READS -f $file -s 2097152 -b 4096 -n $nreads
6466 echo checking missing pages
6467 local miss=$($LCTL get_param -n llite.*.read_ahead_stats |
6468 get_named_value 'misses' | cut -d" " -f1 | calc_total)
6470 [ $miss -lt 3 ] || error "misses too much pages!"
6473 run_test 101f "check read-ahead for max_read_ahead_whole_mb"
6476 test_mkdir -p $DIR/$tdir
6477 chown $RUNAS_ID $DIR/$tdir
6480 STRIPE_COUNT=$OSTCOUNT
6481 [[ $OSTCOUNT -gt 4 ]] && STRIPE_COUNT=4
6483 trap cleanup_test102 EXIT
6485 $1 $SETSTRIPE -S $STRIPE_SIZE -i $STRIPE_OFFSET -c $STRIPE_COUNT $tdir
6487 for num in 1 2 3 4; do
6488 for count in $(seq 1 $STRIPE_COUNT); do
6489 for idx in $(seq 0 $[$STRIPE_COUNT - 1]); do
6490 local size=`expr $STRIPE_SIZE \* $num`
6491 local file=file"$num-$idx-$count"
6492 $1 $SETSTRIPE -S $size -i $idx -c $count $file
6498 $1 $TAR cf $TMP/f102.tar $tdir --xattrs
6504 rm -rf $DIR/d0.sanity/d102
6508 local testfile=$DIR/$tfile
6512 [ "$UID" != 0 ] && skip_env "must run as root" && return
6513 [ -z "$(lctl get_param -n mdc.*-mdc-*.connect_flags | grep xattr)" ] &&
6514 skip_env "must have user_xattr" && return
6516 [ -z "$(which setfattr 2>/dev/null)" ] &&
6517 skip_env "could not find setfattr" && return
6519 echo "set/get xattr..."
6520 setfattr -n trusted.name1 -v value1 $testfile ||
6521 error "setfattr -n trusted.name1=value1 $testfile failed"
6522 getfattr -n trusted.name1 $testfile 2> /dev/null |
6523 grep "trusted.name1=.value1" ||
6524 error "$testfile missing trusted.name1=value1"
6526 setfattr -n user.author1 -v author1 $testfile ||
6527 error "setfattr -n user.author1=author1 $testfile failed"
6528 getfattr -n user.author1 $testfile 2> /dev/null |
6529 grep "user.author1=.author1" ||
6530 error "$testfile missing trusted.author1=author1"
6533 setfattr -n trusted.name2 -v value2 $testfile ||
6534 error "$testfile unable to set trusted.name2"
6535 setfattr -n trusted.name3 -v value3 $testfile ||
6536 error "$testfile unable to set trusted.name3"
6537 [ $(getfattr -d -m "^trusted" $testfile 2> /dev/null |
6538 grep "trusted.name" | wc -l) -eq 3 ] ||
6539 error "$testfile missing 3 trusted.name xattrs"
6541 setfattr -n user.author2 -v author2 $testfile ||
6542 error "$testfile unable to set user.author2"
6543 setfattr -n user.author3 -v author3 $testfile ||
6544 error "$testfile unable to set user.author3"
6545 [ $(getfattr -d -m "^user" $testfile 2> /dev/null |
6546 grep "user.author" | wc -l) -eq 3 ] ||
6547 error "$testfile missing 3 user.author xattrs"
6549 echo "remove xattr..."
6550 setfattr -x trusted.name1 $testfile ||
6551 error "$testfile error deleting trusted.name1"
6552 getfattr -d -m trusted $testfile 2> /dev/null | grep "trusted.name1" &&
6553 error "$testfile did not delete trusted.name1 xattr"
6555 setfattr -x user.author1 $testfile ||
6556 error "$testfile error deleting user.author1"
6557 getfattr -d -m user $testfile 2> /dev/null | grep "user.author1" &&
6558 error "$testfile did not delete trusted.name1 xattr"
6560 # b10667: setting lustre special xattr be silently discarded
6561 echo "set lustre special xattr ..."
6562 setfattr -n "trusted.lov" -v "invalid value" $testfile ||
6563 error "$testfile allowed setting trusted.lov"
6565 run_test 102a "user xattr test =================================="
6568 [ -z "$(which setfattr 2>/dev/null)" ] &&
6569 skip_env "could not find setfattr" && return
6571 # b10930: get/set/list trusted.lov xattr
6572 echo "get/set/list trusted.lov xattr ..."
6573 [[ $OSTCOUNT -lt 2 ]] && skip_env "skipping 2-stripe test" && return
6574 local testfile=$DIR/$tfile
6575 $SETSTRIPE -S 65536 -i 1 -c $OSTCOUNT $testfile ||
6576 error "setstripe failed"
6577 local STRIPECOUNT=$($GETSTRIPE -c $testfile) ||
6578 error "getstripe failed"
6579 getfattr -d -m "^trusted" $testfile 2>/dev/null | grep "trusted.lov" ||
6580 error "can't get trusted.lov from $testfile"
6582 local testfile2=${testfile}2
6583 local value=$(getfattr -n trusted.lov $testfile 2>/dev/null |
6584 grep "trusted.lov" | sed -e 's/[^=]\+=//')
6587 setfattr -n trusted.lov -v $value $testfile2
6588 local stripe_size=$($GETSTRIPE -S $testfile2)
6589 local stripe_count=$($GETSTRIPE -c $testfile2)
6590 [[ $stripe_size -eq 65536 ]] ||
6591 error "stripe size $stripe_size != 65536"
6592 [[ $stripe_count -eq $STRIPECOUNT ]] ||
6593 error "stripe count $stripe_count != $STRIPECOUNT"
6596 run_test 102b "getfattr/setfattr for trusted.lov EAs ============"
6599 [ -z "$(which setfattr 2>/dev/null)" ] &&
6600 skip_env "could not find setfattr" && return
6602 # b10930: get/set/list lustre.lov xattr
6603 echo "get/set/list lustre.lov xattr ..."
6604 [[ $OSTCOUNT -lt 2 ]] && skip_env "skipping 2-stripe test" && return
6605 test_mkdir -p $DIR/$tdir
6606 chown $RUNAS_ID $DIR/$tdir
6607 local testfile=$DIR/$tdir/$tfile
6608 $RUNAS $SETSTRIPE -S 65536 -i 1 -c $OSTCOUNT $testfile ||
6609 error "setstripe failed"
6610 local STRIPECOUNT=$($RUNAS $GETSTRIPE -c $testfile) ||
6611 error "getstripe failed"
6612 $RUNAS getfattr -d -m "^lustre" $testfile 2> /dev/null | \
6613 grep "lustre.lov" || error "can't get lustre.lov from $testfile"
6615 local testfile2=${testfile}2
6616 local value=`getfattr -n lustre.lov $testfile 2> /dev/null | \
6617 grep "lustre.lov" |sed -e 's/[^=]\+=//' `
6619 $RUNAS $MCREATE $testfile2
6620 $RUNAS setfattr -n lustre.lov -v $value $testfile2
6621 local stripe_size=$($RUNAS $GETSTRIPE -S $testfile2)
6622 local stripe_count=$($RUNAS $GETSTRIPE -c $testfile2)
6623 [ $stripe_size -eq 65536 ] || error "stripe size $stripe_size != 65536"
6624 [ $stripe_count -eq $STRIPECOUNT ] ||
6625 error "stripe count $stripe_count != $STRIPECOUNT"
6627 run_test 102c "non-root getfattr/setfattr for lustre.lov EAs ==========="
6629 compare_stripe_info1() {
6630 local stripe_index_all_zero=true
6632 for num in 1 2 3 4; do
6633 for count in $(seq 1 $STRIPE_COUNT); do
6634 for offset in $(seq 0 $[$STRIPE_COUNT - 1]); do
6635 local size=$((STRIPE_SIZE * num))
6636 local file=file"$num-$offset-$count"
6637 stripe_size=$($LFS getstripe -S $PWD/$file)
6638 [[ $stripe_size -ne $size ]] &&
6639 error "$file: size $stripe_size != $size"
6640 stripe_count=$($LFS getstripe -c $PWD/$file)
6641 # allow fewer stripes to be created, ORI-601
6642 [[ $stripe_count -lt $(((3 * count + 3) / 4)) ]] &&
6643 error "$file: count $stripe_count != $count"
6644 stripe_index=$($LFS getstripe -i $PWD/$file)
6645 [[ $stripe_index -ne 0 ]] &&
6646 stripe_index_all_zero=false
6650 $stripe_index_all_zero &&
6651 error "all files are being extracted starting from OST index 0"
6656 [ -n "$(which tar 2>/dev/null)" ] &&
6657 strings $(which tar) | grep -q "lustre" && echo tar
6661 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6662 # b10930: tar test for trusted.lov xattr
6663 TAR=$(find_lustre_tar)
6664 [ -z "$TAR" ] && skip_env "lustre-aware tar is not installed" && return
6665 [[ $OSTCOUNT -lt 2 ]] && skip_env "skipping N-stripe test" && return
6667 test_mkdir -p $DIR/d102d
6668 $TAR xf $TMP/f102.tar -C $DIR/d102d --xattrs
6670 compare_stripe_info1
6672 run_test 102d "tar restore stripe info from tarfile,not keep osts ==========="
6675 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6676 # b10930: tar test for trusted.lov xattr
6677 TAR=$(find_lustre_tar)
6678 [ -z "$TAR" ] && skip_env "lustre-aware tar is not installed" && return
6679 [[ $OSTCOUNT -lt 2 ]] && skip_env "skipping N-stripe test" && return
6681 test_mkdir -p $DIR/d102f
6683 $TAR cf - --xattrs $tdir | $TAR xf - --xattrs -C $DIR/d102f
6685 compare_stripe_info1
6687 run_test 102f "tar copy files, not keep osts ==========="
6690 local xsize=${1:-1024} # in bytes
6691 local file=$DIR/$tfile
6693 [ -z $(lctl get_param -n mdc.*.connect_flags | grep xattr) ] &&
6694 skip "must have user_xattr" && return 0
6695 [ -z "$(which setfattr 2>/dev/null)" ] &&
6696 skip_env "could not find setfattr" && return 0
6697 [ -z "$(which getfattr 2>/dev/null)" ] &&
6698 skip_env "could not find getfattr" && return 0
6702 local value="$(generate_string $xsize)"
6704 local xbig=trusted.big
6705 log "save $xbig on $file"
6706 setfattr -n $xbig -v $value $file ||
6707 error "saving $xbig on $file failed"
6709 local orig=$(get_xattr_value $xbig $file)
6710 [[ "$orig" != "$value" ]] && error "$xbig different after saving $xbig"
6712 local xsml=trusted.sml
6713 log "save $xsml on $file"
6714 setfattr -n $xsml -v val $file || error "saving $xsml on $file failed"
6716 local new=$(get_xattr_value $xbig $file)
6717 [[ "$new" != "$orig" ]] && error "$xbig different after saving $xsml"
6719 log "grow $xsml on $file"
6720 setfattr -n $xsml -v "$value" $file ||
6721 error "growing $xsml on $file failed"
6723 new=$(get_xattr_value $xbig $file)
6724 [[ "$new" != "$orig" ]] && error "$xbig different after growing $xsml"
6725 log "$xbig still valid after growing $xsml"
6730 test_102h() { # bug 15777
6733 run_test 102h "grow xattr from inside inode to external block"
6736 large_xattr_enabled || { skip "large_xattr disabled" && return; }
6737 grow_xattr $(max_xattr_size)
6739 run_test 102ha "grow xattr from inside inode to external inode"
6741 test_102i() { # bug 17038
6742 [ -z "$(which getfattr 2>/dev/null)" ] &&
6743 skip "could not find getfattr" && return
6745 ln -s $DIR/$tfile $DIR/${tfile}link
6746 getfattr -n trusted.lov $DIR/$tfile ||
6747 error "lgetxattr on $DIR/$tfile failed"
6748 getfattr -h -n trusted.lov $DIR/${tfile}link 2>&1 |
6749 grep -i "no such attr" ||
6750 error "error for lgetxattr on $DIR/${tfile}link is not ENODATA"
6751 rm -f $DIR/$tfile $DIR/${tfile}link
6753 run_test 102i "lgetxattr test on symbolic link ============"
6756 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6757 TAR=$(find_lustre_tar)
6758 [ -z "$TAR" ] && skip_env "lustre-aware tar is not installed" && return
6759 [[ $OSTCOUNT -lt 2 ]] && skip_env "skipping N-stripe test" && return
6760 setup_test102 "$RUNAS"
6761 test_mkdir -p $DIR/d102j
6762 chown $RUNAS_ID $DIR/d102j
6763 $RUNAS $TAR xf $TMP/f102.tar -C $DIR/d102j --xattrs
6765 compare_stripe_info1 "$RUNAS"
6767 run_test 102j "non-root tar restore stripe info from tarfile, not keep osts ==="
6770 [ -z "$(which setfattr 2>/dev/null)" ] &&
6771 skip "could not find setfattr" && return
6773 # b22187 just check that does not crash for regular file.
6774 setfattr -n trusted.lov $DIR/$tfile
6775 # b22187 'setfattr -n trusted.lov' should work as remove LOV EA for directories
6776 local test_kdir=$DIR/d102k
6777 test_mkdir $test_kdir
6778 local default_size=`$GETSTRIPE -S $test_kdir`
6779 local default_count=`$GETSTRIPE -c $test_kdir`
6780 local default_offset=`$GETSTRIPE -i $test_kdir`
6781 $SETSTRIPE -S 65536 -i 0 -c $OSTCOUNT $test_kdir ||
6782 error 'dir setstripe failed'
6783 setfattr -n trusted.lov $test_kdir
6784 local stripe_size=`$GETSTRIPE -S $test_kdir`
6785 local stripe_count=`$GETSTRIPE -c $test_kdir`
6786 local stripe_offset=`$GETSTRIPE -i $test_kdir`
6787 [ $stripe_size -eq $default_size ] ||
6788 error "stripe size $stripe_size != $default_size"
6789 [ $stripe_count -eq $default_count ] ||
6790 error "stripe count $stripe_count != $default_count"
6791 [ $stripe_offset -eq $default_offset ] ||
6792 error "stripe offset $stripe_offset != $default_offset"
6793 rm -rf $DIR/$tfile $test_kdir
6795 run_test 102k "setfattr without parameter of value shouldn't cause a crash"
6798 [ -z "$(which getfattr 2>/dev/null)" ] &&
6799 skip "could not find getfattr" && return
6801 # LU-532 trusted. xattr is invisible to non-root
6802 local testfile=$DIR/$tfile
6806 echo "listxattr as user..."
6807 chown $RUNAS_ID $testfile
6808 $RUNAS getfattr -d -m '.*' $testfile 2>&1 |
6809 grep -q "trusted" &&
6810 error "$testfile trusted xattrs are user visible"
6814 run_test 102l "listxattr size test =================================="
6816 test_102m() { # LU-3403 llite: error of listxattr when buffer is small
6817 local path=$DIR/$tfile
6820 listxattr_size_check $path || error "listattr_size_check $path failed"
6822 run_test 102m "Ensure listxattr fails on small bufffer ========"
6826 getxattr() { # getxattr path name
6827 # Return the base64 encoding of the value of xattr name on path.
6831 # # getfattr --absolute-names --encoding=base64 --name=trusted.lov $path
6833 # trusted.lov=0s0AvRCwEAAAAGAAAAAAAAAAAEAAACAAAAAAAQAAEAA...AAAAAAAAA=
6835 # We print just 0s0AvRCwEAAAAGAAAAAAAAAAAEAAACAAAAAAAQAAEAA...AAAAAAAAA=
6837 getfattr --absolute-names --encoding=base64 --name=$name $path |
6838 awk -F= -v name=$name '$1 == name {
6839 print substr($0, index($0, "=") + 1);
6843 test_102n() { # LU-4101 mdt: protect internal xattrs
6844 local file0=$DIR/$tfile.0
6845 local file1=$DIR/$tfile.1
6846 local xattr0=$TMP/$tfile.0
6847 local xattr1=$TMP/$tfile.1
6851 [ -z "$(which setfattr 2>/dev/null)" ] &&
6852 skip "could not find setfattr" && return
6854 if [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.5.50) ]
6856 skip "MDT < 2.5.50 allows setxattr on internal trusted xattrs"
6860 rm -rf $file0 $file1 $xattr0 $xattr1
6863 # Get 'before' xattrs of $file1.
6864 getfattr --absolute-names --dump --match=- $file1 > $xattr0
6866 for name in lov lma lmv link fid version som hsm lfsck_namespace; do
6867 # Try to copy xattr from $file0 to $file1.
6868 value=$(getxattr $file0 trusted.$name 2> /dev/null)
6870 setfattr --name=trusted.$name --value="$value" $file1 ||
6871 error "setxattr 'trusted.$name' failed"
6873 # Try to set a garbage xattr.
6874 value=0sVGhlIHF1aWNrIGJyb3duIGZveCBqdW1wcyBvdmVyIGl0c2VsZi4=
6876 setfattr --name=trusted.$name --value="$value" $file1 ||
6877 error "setxattr 'trusted.$name' failed"
6879 # Try to remove the xattr from $file1. We don't care if this
6880 # appears to succeed or fail, we just don't want there to be
6881 # any changes or crashes.
6882 setfattr --remove=$trusted.$name $file1 2> /dev/null
6885 if [ $(lustre_version_code $SINGLEMDS) -gt $(version_code 2.6.50) ]
6888 # Try to copy xattr from $file0 to $file1.
6889 value=$(getxattr $file0 trusted.$name 2> /dev/null)
6891 setfattr --name=trusted.$name --value="$value" $file1 ||
6892 error "setxattr 'trusted.$name' failed"
6894 # Try to set a garbage xattr.
6895 value=0sVGhlIHF1aWNrIGJyb3duIGZveCBqdW1wcyBvdmVyIGl0c2VsZi4=
6897 setfattr --name=trusted.$name --value="$value" $file1 ||
6898 error "setxattr 'trusted.$name' failed"
6900 # Try to remove the xattr from $file1. We don't care if this
6901 # appears to succeed or fail, we just don't want there to be
6902 # any changes or crashes.
6903 setfattr --remove=$trusted.$name $file1 2> /dev/null
6906 # Get 'after' xattrs of file1.
6907 getfattr --absolute-names --dump --match=- $file1 > $xattr1
6909 if ! diff $xattr0 $xattr1; then
6910 error "before and after xattrs of '$file1' differ"
6913 rm -rf $file0 $file1 $xattr0 $xattr1
6917 run_test 102n "silently ignore setxattr on internal trusted xattrs"
6919 test_102p() { # LU-4703 setxattr did not check ownership
6920 local testfile=$DIR/$tfile
6922 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.5.56) ] &&
6923 skip "MDS needs to be at least 2.5.56" && return
6927 echo "setfacl as user..."
6928 $RUNAS setfacl -m "u:$RUNAS_ID:rwx" $testfile
6929 [ $? -ne 0 ] || error "setfacl by $RUNAS_ID was allowed on $testfile"
6931 echo "setfattr as user..."
6932 setfacl -m "u:$RUNAS_ID:---" $testfile
6933 $RUNAS setfattr -x system.posix_acl_access $testfile
6934 [ $? -ne 0 ] || error "setfattr by $RUNAS_ID was allowed on $testfile"
6936 run_test 102p "check setxattr(2) correctly fails without permission"
6939 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.6.92) ] &&
6940 skip "MDS needs to be at least 2.6.92" && return
6941 orphan_linkea_check $DIR/$tfile || error "orphan_linkea_check"
6943 run_test 102q "flistxattr should not return trusted.link EAs for orphans"
6946 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.6.93) ] &&
6947 skip "MDS needs to be at least 2.6.93" && return
6948 touch $DIR/$tfile || error "touch"
6949 setfattr -n user.$(basename $tfile) $DIR/$tfile || error "setfattr"
6950 getfattr -n user.$(basename $tfile) $DIR/$tfile || error "getfattr"
6951 rm $DIR/$tfile || error "rm"
6954 mkdir -p $DIR/$tdir || error "mkdir"
6955 setfattr -n user.$(basename $tdir) $DIR/$tdir || error "setfattr dir"
6956 getfattr -n user.$(basename $tdir) $DIR/$tdir || error "getfattr dir"
6957 setfattr -x user.$(basename $tdir) $DIR/$tdir ||
6958 error "$testfile error deleting user.author1"
6959 getfattr -d -m user.$(basename $tdir) 2> /dev/null |
6960 grep "user.$(basename $tdir)" &&
6961 error "$tdir did not delete user.$(basename $tdir)"
6962 rmdir $DIR/$tdir || error "rmdir"
6965 test_mkdir -p $DIR/$tdir || error "make striped dir"
6966 setfattr -n user.$(basename $tdir) $DIR/$tdir || error "setfattr dir"
6967 getfattr -n user.$(basename $tdir) $DIR/$tdir || error "getfattr dir"
6968 setfattr -x user.$(basename $tdir) $DIR/$tdir ||
6969 error "$testfile error deleting user.author1"
6970 getfattr -d -m user.$(basename $tdir) 2> /dev/null |
6971 grep "user.$(basename $tdir)" &&
6972 error "$tdir did not delete user.$(basename $tdir)"
6973 rmdir $DIR/$tdir || error "rm striped dir"
6975 run_test 102r "set EAs with empty values"
6979 $LUSTRE/tests/acl/run $LUSTRE/tests/acl/$1.test
6984 [ "$UID" != 0 ] && skip_env "must run as root" && return
6985 [ -z "$(lctl get_param -n mdc.*-mdc-*.connect_flags | grep acl)" ] &&
6986 skip "must have acl enabled" && return
6987 [ -z "$(which setfacl 2>/dev/null)" ] &&
6988 skip_env "could not find setfacl" && return
6989 $GSS && skip "could not run under gss" && return
6991 gpasswd -a daemon bin # LU-5641
6992 do_facet $SINGLEMDS gpasswd -a daemon bin # LU-5641
6994 declare -a identity_old
6996 for num in $(seq $MDSCOUNT); do
6997 switch_identity $num true || identity_old[$num]=$?
7004 echo "performing cp ..."
7005 run_acl_subtest cp || error "run_acl_subtest cp failed"
7006 echo "performing getfacl-noacl..."
7007 run_acl_subtest getfacl-noacl || error "getfacl-noacl test failed"
7008 echo "performing misc..."
7009 run_acl_subtest misc || error "misc test failed"
7010 echo "performing permissions..."
7011 run_acl_subtest permissions || error "permissions failed"
7012 echo "performing setfacl..."
7013 run_acl_subtest setfacl || error "setfacl test failed"
7015 # inheritance test got from HP
7016 echo "performing inheritance..."
7017 cp $LUSTRE/tests/acl/make-tree . || error "cannot copy make-tree"
7018 chmod +x make-tree || error "chmod +x failed"
7019 run_acl_subtest inheritance || error "inheritance test failed"
7022 echo "LU-974 ignore umask when acl is enabled..."
7023 run_acl_subtest 974 || error "LU-974 umask test failed"
7024 if [ $MDSCOUNT -ge 2 ]; then
7025 run_acl_subtest 974_remote ||
7026 error "LU-974 umask test failed under remote dir"
7029 echo "LU-2561 newly created file is same size as directory..."
7030 if [ $(facet_fstype $SINGLEMDS) != "zfs" ]; then
7031 run_acl_subtest 2561 || error "LU-2561 test failed"
7033 run_acl_subtest 2561_zfs || error "LU-2561 zfs test failed"
7036 run_acl_subtest 4924 || error "LU-4924 test failed"
7041 for num in $(seq $MDSCOUNT); do
7042 if [ "${identity_old[$num]}" = 1 ]; then
7043 switch_identity $num false || identity_old[$num]=$?
7047 run_test 103a "acl test ========================================="
7051 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
7052 local mountopts=$MDS_MOUNT_OPTS
7054 if [[ "$MDS_MOUNT_OPTS" =~ "noacl" ]]; then
7058 stop $SINGLEMDS || error "failed to stop MDT."
7060 if [ -z "$MDS_MOUNT_OPTS" ]; then
7061 MDS_MOUNT_OPTS="-o noacl"
7063 MDS_MOUNT_OPTS="${MDS_MOUNT_OPTS},noacl"
7065 start $SINGLEMDS $MDT_DEV $MDS_MOUNT_OPTS ||
7066 error "failed to start MDT."
7067 MDS_MOUNT_OPTS=$mountopts
7071 setfacl -m u:bin:rw $DIR/$tfile && error "setfacl should fail"
7075 stop $SINGLEMDS || error "failed to stop MDT."
7077 start $SINGLEMDS $MDT_DEV $MDS_MOUNT_OPTS ||
7078 error "failed to start MDT."
7083 run_test 103b "MDS mount option 'noacl'"
7087 cp -rp $DIR/$tdir $DIR/$tdir.bak
7089 [ -n "$(getfattr -d -m. $DIR/$tdir | grep posix_acl_default)" ] &&
7090 error "$DIR/$tdir shouldn't contain default ACL"
7091 [ -n "$(getfattr -d -m. $DIR/$tdir.bak | grep posix_acl_default)" ] &&
7092 error "$DIR/$tdir.bak shouldn't contain default ACL"
7095 run_test 103c "'cp -rp' won't set empty acl"
7098 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7100 lfs df || error "lfs df failed"
7101 lfs df -ih || error "lfs df -ih failed"
7102 lfs df -h $DIR || error "lfs df -h $DIR failed"
7103 lfs df -i $DIR || error "lfs df -i $DIR failed"
7104 lfs df $DIR/$tfile || error "lfs df $DIR/$tfile failed"
7105 lfs df -ih $DIR/$tfile || error "lfs df -ih $DIR/$tfile failed"
7107 local OSC=$(lctl dl | grep OST0000-osc-[^M] | awk '{ print $4 }')
7108 lctl --device %$OSC deactivate
7109 lfs df || error "lfs df with deactivated OSC failed"
7110 lctl --device %$OSC activate
7111 # wait the osc back to normal
7112 wait_osc_import_state client ost FULL
7114 lfs df || error "lfs df with reactivated OSC failed"
7117 run_test 104a "lfs df [-ih] [path] test ========================="
7120 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7121 [ $RUNAS_ID -eq $UID ] &&
7122 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
7124 denied_cnt=$(($($RUNAS $LFS check servers 2>&1 |
7125 grep "Permission denied" | wc -l)))
7126 if [ $denied_cnt -ne 0 ]; then
7127 error "lfs check servers test failed"
7130 run_test 104b "$RUNAS lfs check servers test ===================="
7133 # doesn't work on 2.4 kernels
7135 if $(flock_is_enabled); then
7136 flocks_test 1 on -f $DIR/$tfile || error "fail flock on"
7138 flocks_test 1 off -f $DIR/$tfile || error "fail flock off"
7142 run_test 105a "flock when mounted without -o flock test ========"
7146 if $(flock_is_enabled); then
7147 flocks_test 1 on -c $DIR/$tfile || error "fail flock on"
7149 flocks_test 1 off -c $DIR/$tfile || error "fail flock off"
7153 run_test 105b "fcntl when mounted without -o flock test ========"
7157 if $(flock_is_enabled); then
7158 flocks_test 1 on -l $DIR/$tfile || error "fail flock on"
7160 flocks_test 1 off -l $DIR/$tfile || error "fail flock off"
7164 run_test 105c "lockf when mounted without -o flock test ========"
7166 test_105d() { # bug 15924
7167 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7168 test_mkdir -p $DIR/$tdir
7169 flock_is_enabled || { skip "mount w/o flock enabled" && return; }
7170 #define OBD_FAIL_LDLM_CP_CB_WAIT 0x315
7171 $LCTL set_param fail_loc=0x80000315
7172 flocks_test 2 $DIR/$tdir
7174 run_test 105d "flock race (should not freeze) ========"
7176 test_105e() { # bug 22660 && 22040
7177 flock_is_enabled || { skip "mount w/o flock enabled" && return; }
7179 flocks_test 3 $DIR/$tfile
7181 run_test 105e "Two conflicting flocks from same process ======="
7183 test_106() { #bug 10921
7184 test_mkdir -p $DIR/$tdir
7185 $DIR/$tdir && error "exec $DIR/$tdir succeeded"
7186 chmod 777 $DIR/$tdir || error "chmod $DIR/$tdir failed"
7188 run_test 106 "attempt exec of dir followed by chown of that dir"
7191 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7198 local save_pattern=$(sysctl -n kernel.core_pattern)
7199 local save_uses_pid=$(sysctl -n kernel.core_uses_pid)
7200 sysctl -w kernel.core_pattern=$file
7201 sysctl -w kernel.core_uses_pid=0
7209 kill -s 11 $SLEEPPID
7211 if [ -e $file ]; then
7212 size=`stat -c%s $file`
7213 [ $size -eq 0 ] && error "Fail to create core file $file"
7215 error "Fail to create core file $file"
7218 sysctl -w kernel.core_pattern=$save_pattern
7219 sysctl -w kernel.core_uses_pid=$save_uses_pid
7222 run_test 107 "Coredump on SIG"
7225 test_mkdir -p $DIR/$tdir
7226 test_mkdir $DIR/$tdir/$(str_repeat 'a' 255) ||
7227 error "mkdir with 255 char failed"
7228 test_mkdir $DIR/$tdir/$(str_repeat 'b' 256) &&
7229 error "mkdir with 256 char should fail, but did not"
7230 touch $DIR/$tdir/$(str_repeat 'x' 255) ||
7231 error "create with 255 char failed"
7232 touch $DIR/$tdir/$(str_repeat 'y' 256) &&
7233 error "create with 256 char should fail, but did not"
7238 run_test 110 "filename length checking"
7241 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7242 OSTIO_pre=$(ps -e | grep ll_ost_io | awk '{ print $4 }'| sort -n |
7243 tail -1 | cut -c11-20)
7244 [ -z "$OSTIO_pre" ] && skip "no OSS threads" && return
7245 echo "Starting with $OSTIO_pre threads"
7248 NUMFREE=$(df -i -P $DIR | tail -n 1 | awk '{ print $4 }')
7249 [[ $NUMFREE -lt $NUMTEST ]] && NUMTEST=$(($NUMFREE - 1000))
7250 echo "$NUMTEST creates/unlinks"
7251 test_mkdir -p $DIR/$tdir
7252 createmany -o $DIR/$tdir/$tfile $NUMTEST
7253 unlinkmany $DIR/$tdir/$tfile $NUMTEST
7255 OSTIO_post=$(ps -e | grep ll_ost_io | awk '{ print $4 }' | sort -n |
7256 tail -1 | cut -c11-20)
7258 # don't return an error
7259 [ $OSTIO_post == $OSTIO_pre ] && echo \
7260 "WARNING: No new ll_ost_io threads were created ($OSTIO_pre)" &&
7261 echo "This may be fine, depending on what ran before this test" &&
7262 echo "and how fast this system is." && return
7264 echo "Started with $OSTIO_pre threads, ended with $OSTIO_post"
7266 run_test 115 "verify dynamic thread creation===================="
7269 wait_delete_completed
7270 AVAIL=($(lctl get_param -n osc.*[oO][sS][cC]-[^M]*.kbytesavail))
7271 echo OST kbytes available: ${AVAIL[@]}
7272 MAXI=0; MAXV=${AVAIL[0]}
7273 MINI=0; MINV=${AVAIL[0]}
7274 for ((i = 0; i < ${#AVAIL[@]}; i++)); do
7275 #echo OST $i: ${AVAIL[i]}kb
7276 if [[ ${AVAIL[i]} -gt $MAXV ]]; then
7277 MAXV=${AVAIL[i]}; MAXI=$i
7279 if [[ ${AVAIL[i]} -lt $MINV ]]; then
7280 MINV=${AVAIL[i]}; MINI=$i
7283 echo Min free space: OST $MINI: $MINV
7284 echo Max free space: OST $MAXI: $MAXV
7287 test_116a() { # was previously test_116()
7288 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7289 [[ $OSTCOUNT -lt 2 ]] && skip_env "$OSTCOUNT < 2 OSTs" && return
7291 echo -n "Free space priority "
7292 do_facet $SINGLEMDS lctl get_param -n lo*.*-mdtlov.qos_prio_free |
7297 [ $MINV -eq 0 ] && skip "no free space in OST$MINI, skip" && return
7298 [ $MINV -gt 10000000 ] && skip "too much free space in OST$MINI, skip" \
7300 trap simple_cleanup_common EXIT
7303 # Check if we need to generate uneven OSTs
7304 test_mkdir -p $DIR/$tdir/OST${MINI}
7305 local FILL=$(($MINV / 4))
7306 local DIFF=$(($MAXV - $MINV))
7307 local DIFF2=$(($DIFF * 100 / $MINV))
7309 local threshold=$(do_facet $SINGLEMDS \
7310 lctl get_param -n *.*MDT0000-mdtlov.qos_threshold_rr | head -n1)
7311 threshold=${threshold%%%}
7312 echo -n "Check for uneven OSTs: "
7313 echo -n "diff=${DIFF}KB (${DIFF2}%) must be > ${threshold}% ..."
7315 if [[ $DIFF2 -gt $threshold ]]; then
7317 echo "Don't need to fill OST$MINI"
7319 # generate uneven OSTs. Write 2% over the QOS threshold value
7321 DIFF=$(($threshold - $DIFF2 + 2))
7322 DIFF2=$(( ($MINV * $DIFF)/100 ))
7323 echo "Fill ${DIFF}% remaining space in OST${MINI} with ${DIFF2}KB"
7324 $SETSTRIPE -i $MINI -c 1 $DIR/$tdir/OST${MINI} ||
7325 error "setstripe failed"
7326 DIFF=$(($DIFF2 / 2048))
7328 while [ $i -lt $DIFF ]; do
7330 dd if=/dev/zero of=$DIR/$tdir/OST${MINI}/$tfile-$i \
7331 bs=2M count=1 2>/dev/null
7340 DIFF=$(($MAXV - $MINV))
7341 DIFF2=$(($DIFF * 100 / $MINV))
7342 echo -n "diff=${DIFF}=${DIFF2}% must be > ${threshold}% for QOS mode..."
7343 if [[ $DIFF2 -gt $threshold ]]; then
7346 echo "failed - QOS mode won't be used"
7347 skip "QOS imbalance criteria not met"
7348 simple_cleanup_common
7352 MINI1=$MINI; MINV1=$MINV
7353 MAXI1=$MAXI; MAXV1=$MAXV
7355 # now fill using QOS
7356 $SETSTRIPE -c 1 $DIR/$tdir
7357 FILL=$(($FILL / 200))
7358 if [ $FILL -gt 600 ]; then
7361 echo "writing $FILL files to QOS-assigned OSTs"
7363 while [ $i -lt $FILL ]; do
7365 dd if=/dev/zero of=$DIR/$tdir/$tfile-$i bs=200k \
7369 echo "wrote $i 200k files"
7373 echo "Note: free space may not be updated, so measurements might be off"
7375 DIFF2=$(($MAXV - $MINV))
7376 echo "free space delta: orig $DIFF final $DIFF2"
7377 [ $DIFF2 -gt $DIFF ] && echo "delta got worse!"
7378 DIFF=$(($MINV1 - ${AVAIL[$MINI1]}))
7379 echo "Wrote ${DIFF}KB to smaller OST $MINI1"
7380 DIFF2=$(($MAXV1 - ${AVAIL[$MAXI1]}))
7381 echo "Wrote ${DIFF2}KB to larger OST $MAXI1"
7382 FILL=$(($DIFF2 * 100 / $DIFF - 100))
7384 echo "Wrote ${FILL}% more data to larger OST $MAXI1"
7386 # Figure out which files were written where
7387 UUID=$(lctl get_param -n lov.${FSNAME}-clilov-*.target_obd |
7388 awk '/'$MINI1': / {print $2; exit}')
7390 MINC=$($GETSTRIPE --ost $UUID $DIR/$tdir | grep $DIR | wc -l)
7391 echo "$MINC files created on smaller OST $MINI1"
7392 UUID=$(lctl get_param -n lov.${FSNAME}-clilov-*.target_obd |
7393 awk '/'$MAXI1': / {print $2; exit}')
7395 MAXC=$($GETSTRIPE --ost $UUID $DIR/$tdir | grep $DIR | wc -l)
7396 echo "$MAXC files created on larger OST $MAXI1"
7397 FILL=$(($MAXC * 100 / $MINC - 100))
7398 [[ $MINC -gt 0 ]] &&
7399 echo "Wrote ${FILL}% more files to larger OST $MAXI1"
7400 [[ $MAXC -gt $MINC ]] ||
7401 error_ignore LU-9 "stripe QOS didn't balance free space"
7402 simple_cleanup_common
7404 run_test 116a "stripe QOS: free space balance ==================="
7406 test_116b() { # LU-2093
7407 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7408 #define OBD_FAIL_MDS_OSC_CREATE_FAIL 0x147
7409 local old_rr=$(do_facet $SINGLEMDS lctl get_param -n \
7410 lo*.$FSNAME-MDT0000-mdtlov.qos_threshold_rr | head -1)
7411 [ -z "$old_rr" ] && skip "no QOS" && return 0
7412 do_facet $SINGLEMDS lctl set_param \
7413 lo*.$FSNAME-MDT0000-mdtlov.qos_threshold_rr=0
7415 do_facet $SINGLEMDS lctl set_param fail_loc=0x147
7416 createmany -o $DIR/$tdir/f- 20 || error "can't create"
7417 do_facet $SINGLEMDS lctl set_param fail_loc=0
7419 do_facet $SINGLEMDS lctl set_param \
7420 lo*.$FSNAME-MDT0000-mdtlov.qos_threshold_rr=$old_rr
7422 run_test 116b "QoS shouldn't LBUG if not enough OSTs found on the 2nd pass"
7424 test_117() # bug 10891
7426 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7427 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1
7428 #define OBD_FAIL_OST_SETATTR_CREDITS 0x21e
7429 lctl set_param fail_loc=0x21e
7430 > $DIR/$tfile || error "truncate failed"
7431 lctl set_param fail_loc=0
7432 echo "Truncate succeeded."
7435 run_test 117 "verify osd extend =========="
7437 NO_SLOW_RESENDCOUNT=4
7438 export OLD_RESENDCOUNT=""
7439 set_resend_count () {
7440 local PROC_RESENDCOUNT="osc.${FSNAME}-OST*-osc-*.resend_count"
7441 OLD_RESENDCOUNT=$(lctl get_param -n $PROC_RESENDCOUNT | head -n1)
7442 lctl set_param -n $PROC_RESENDCOUNT $1
7443 echo resend_count is set to $(lctl get_param -n $PROC_RESENDCOUNT)
7446 # for reduce test_118* time (b=14842)
7447 [ "$SLOW" = "no" ] && set_resend_count $NO_SLOW_RESENDCOUNT
7449 # Reset async IO behavior after error case
7451 FILE=$DIR/reset_async
7453 # Ensure all OSCs are cleared
7454 $SETSTRIPE -c -1 $FILE
7455 dd if=/dev/zero of=$FILE bs=64k count=$OSTCOUNT
7460 test_118a() #bug 11710
7462 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7465 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
7466 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
7467 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
7469 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
7470 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
7475 run_test 118a "verify O_SYNC works =========="
7479 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7480 remote_ost_nodsh && skip "remote OST with nodsh" && return
7484 #define OBD_FAIL_OST_ENOENT 0x217
7485 set_nodes_failloc "$(osts_nodes)" 0x217
7486 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
7488 set_nodes_failloc "$(osts_nodes)" 0
7489 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
7490 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
7493 if [[ $RC -eq 0 ]]; then
7494 error "Must return error due to dropped pages, rc=$RC"
7498 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
7499 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
7503 echo "Dirty pages not leaked on ENOENT"
7505 # Due to the above error the OSC will issue all RPCs syncronously
7506 # until a subsequent RPC completes successfully without error.
7507 $MULTIOP $DIR/$tfile Ow4096yc
7512 run_test 118b "Reclaim dirty pages on fatal error =========="
7516 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7518 # for 118c, restore the original resend count, LU-1940
7519 [ "$SLOW" = "no" ] && [ -n "$OLD_RESENDCOUNT" ] &&
7520 set_resend_count $OLD_RESENDCOUNT
7521 remote_ost_nodsh && skip "remote OST with nodsh" && return
7525 #define OBD_FAIL_OST_EROFS 0x216
7526 set_nodes_failloc "$(osts_nodes)" 0x216
7528 # multiop should block due to fsync until pages are written
7529 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
7533 if [[ `ps h -o comm -p $MULTIPID` != "multiop" ]]; then
7534 error "Multiop failed to block on fsync, pid=$MULTIPID"
7537 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
7539 if [[ $WRITEBACK -eq 0 ]]; then
7540 error "No page in writeback, writeback=$WRITEBACK"
7543 set_nodes_failloc "$(osts_nodes)" 0
7546 if [[ $RC -ne 0 ]]; then
7547 error "Multiop fsync failed, rc=$RC"
7550 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
7551 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
7553 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
7554 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
7558 echo "Dirty pages flushed via fsync on EROFS"
7561 run_test 118c "Fsync blocks on EROFS until dirty pages are flushed =========="
7563 # continue to use small resend count to reduce test_118* time (b=14842)
7564 [ "$SLOW" = "no" ] && set_resend_count $NO_SLOW_RESENDCOUNT
7568 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7569 remote_ost_nodsh && skip "remote OST with nodsh" && return
7573 #define OBD_FAIL_OST_BRW_PAUSE_BULK
7574 set_nodes_failloc "$(osts_nodes)" 0x214
7575 # multiop should block due to fsync until pages are written
7576 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
7580 if [[ `ps h -o comm -p $MULTIPID` != "multiop" ]]; then
7581 error "Multiop failed to block on fsync, pid=$MULTIPID"
7584 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
7586 if [[ $WRITEBACK -eq 0 ]]; then
7587 error "No page in writeback, writeback=$WRITEBACK"
7590 wait $MULTIPID || error "Multiop fsync failed, rc=$?"
7591 set_nodes_failloc "$(osts_nodes)" 0
7593 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
7594 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
7596 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
7597 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
7601 echo "Dirty pages gaurenteed flushed via fsync"
7604 run_test 118d "Fsync validation inject a delay of the bulk =========="
7607 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7610 #define OBD_FAIL_OSC_BRW_PREP_REQ2 0x40a
7611 lctl set_param fail_loc=0x8000040a
7613 # Should simulate EINVAL error which is fatal
7614 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
7616 if [[ $RC -eq 0 ]]; then
7617 error "Must return error due to dropped pages, rc=$RC"
7620 lctl set_param fail_loc=0x0
7622 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
7623 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
7624 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
7626 if [[ $LOCKED -ne 0 ]]; then
7627 error "Locked pages remain in cache, locked=$LOCKED"
7630 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
7631 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
7635 echo "No pages locked after fsync"
7640 run_test 118f "Simulate unrecoverable OSC side error =========="
7643 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7646 #define OBD_FAIL_OSC_BRW_PREP_REQ 0x406
7647 lctl set_param fail_loc=0x406
7649 # simulate local -ENOMEM
7650 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
7653 lctl set_param fail_loc=0
7654 if [[ $RC -eq 0 ]]; then
7655 error "Must return error due to dropped pages, rc=$RC"
7658 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
7659 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
7660 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
7662 if [[ $LOCKED -ne 0 ]]; then
7663 error "Locked pages remain in cache, locked=$LOCKED"
7666 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
7667 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
7671 echo "No pages locked after fsync"
7676 run_test 118g "Don't stay in wait if we got local -ENOMEM =========="
7679 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7680 remote_ost_nodsh && skip "remote OST with nodsh" && return
7684 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
7685 set_nodes_failloc "$(osts_nodes)" 0x20e
7686 # Should simulate ENOMEM error which is recoverable and should be handled by timeout
7687 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
7690 set_nodes_failloc "$(osts_nodes)" 0
7691 if [[ $RC -eq 0 ]]; then
7692 error "Must return error due to dropped pages, rc=$RC"
7695 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
7696 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
7697 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
7699 if [[ $LOCKED -ne 0 ]]; then
7700 error "Locked pages remain in cache, locked=$LOCKED"
7703 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
7704 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
7708 echo "No pages locked after fsync"
7712 run_test 118h "Verify timeout in handling recoverables errors =========="
7714 [ "$SLOW" = "no" ] && [ -n "$OLD_RESENDCOUNT" ] && set_resend_count $OLD_RESENDCOUNT
7717 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7718 remote_ost_nodsh && skip "remote OST with nodsh" && return
7722 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
7723 set_nodes_failloc "$(osts_nodes)" 0x20e
7725 # Should simulate ENOMEM error which is recoverable and should be handled by timeout
7726 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
7729 set_nodes_failloc "$(osts_nodes)" 0
7733 if [[ $RC -ne 0 ]]; then
7734 error "got error, but should be not, rc=$RC"
7737 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
7738 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
7739 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
7740 if [[ $LOCKED -ne 0 ]]; then
7741 error "Locked pages remain in cache, locked=$LOCKED"
7744 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
7745 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
7749 echo "No pages locked after fsync"
7753 run_test 118i "Fix error before timeout in recoverable error =========="
7755 [ "$SLOW" = "no" ] && set_resend_count 4
7758 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7759 remote_ost_nodsh && skip "remote OST with nodsh" && return
7763 #define OBD_FAIL_OST_BRW_WRITE_BULK2 0x220
7764 set_nodes_failloc "$(osts_nodes)" 0x220
7766 # return -EIO from OST
7767 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
7769 set_nodes_failloc "$(osts_nodes)" 0x0
7770 if [[ $RC -eq 0 ]]; then
7771 error "Must return error due to dropped pages, rc=$RC"
7774 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
7775 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
7776 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
7777 if [[ $LOCKED -ne 0 ]]; then
7778 error "Locked pages remain in cache, locked=$LOCKED"
7781 # in recoverable error on OST we want resend and stay until it finished
7782 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
7783 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
7787 echo "No pages locked after fsync"
7791 run_test 118j "Simulate unrecoverable OST side error =========="
7795 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7796 remote_ost_nodsh && skip "remote OSTs with nodsh" && return
7798 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
7799 set_nodes_failloc "$(osts_nodes)" 0x20e
7800 test_mkdir -p $DIR/$tdir
7802 for ((i=0;i<10;i++)); do
7803 (dd if=/dev/zero of=$DIR/$tdir/$tfile-$i bs=1M count=10 || \
7804 error "dd to $DIR/$tdir/$tfile-$i failed" )&
7811 set_nodes_failloc "$(osts_nodes)" 0
7814 run_test 118k "bio alloc -ENOMEM and IO TERM handling ========="
7818 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7820 test_mkdir -p $DIR/$tdir
7821 $MULTIOP $DIR/$tdir Dy || error "fsync dir failed"
7824 run_test 118l "fsync dir ========="
7826 test_118m() # LU-3066
7828 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7829 test_mkdir -p $DIR/$tdir
7830 $MULTIOP $DIR/$tdir DY || error "fdatasync dir failed"
7833 run_test 118m "fdatasync dir ========="
7835 [ "$SLOW" = "no" ] && [ -n "$OLD_RESENDCOUNT" ] && set_resend_count $OLD_RESENDCOUNT
7837 test_119a() # bug 11737
7839 BSIZE=$((512 * 1024))
7840 directio write $DIR/$tfile 0 1 $BSIZE
7841 # We ask to read two blocks, which is more than a file size.
7842 # directio will indicate an error when requested and actual
7843 # sizes aren't equeal (a normal situation in this case) and
7844 # print actual read amount.
7845 NOB=`directio read $DIR/$tfile 0 2 $BSIZE | awk '/error/ {print $6}'`
7846 if [ "$NOB" != "$BSIZE" ]; then
7847 error "read $NOB bytes instead of $BSIZE"
7851 run_test 119a "Short directIO read must return actual read amount"
7853 test_119b() # bug 11737
7855 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping 2-stripe test" && return
7857 $SETSTRIPE -c 2 $DIR/$tfile || error "setstripe failed"
7858 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=1 || error "dd failed"
7860 $MULTIOP $DIR/$tfile oO_RDONLY:O_DIRECT:r$((2048 * 1024)) || \
7861 error "direct read failed"
7864 run_test 119b "Sparse directIO read must return actual read amount"
7866 test_119c() # bug 13099
7869 directio write $DIR/$tfile 3 1 $BSIZE || error "direct write failed"
7870 directio readhole $DIR/$tfile 0 2 $BSIZE || error "reading hole failed"
7873 run_test 119c "Testing for direct read hitting hole"
7875 test_119d() # bug 15950
7877 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7878 MAX_RPCS_IN_FLIGHT=`$LCTL get_param -n osc.*OST0000-osc-[^mM]*.max_rpcs_in_flight`
7879 $LCTL set_param -n osc.*OST0000-osc-[^mM]*.max_rpcs_in_flight 1
7881 $SETSTRIPE $DIR/$tfile -i 0 -c 1 || error "setstripe failed"
7882 $DIRECTIO write $DIR/$tfile 0 1 $BSIZE || error "first directio failed"
7883 #define OBD_FAIL_OSC_DIO_PAUSE 0x40d
7884 lctl set_param fail_loc=0x40d
7885 $DIRECTIO write $DIR/$tfile 1 4 $BSIZE &
7888 cat $DIR/$tfile > /dev/null &
7889 lctl set_param fail_loc=0
7892 log "the DIO writes have completed, now wait for the reads (should not block very long)"
7894 [ -n "`ps h -p $pid_reads -o comm`" ] && \
7895 error "the read rpcs have not completed in 2s"
7897 $LCTL set_param -n osc.*OST0000-osc-[^mM]*.max_rpcs_in_flight $MAX_RPCS_IN_FLIGHT
7899 run_test 119d "The DIO path should try to send a new rpc once one is completed"
7902 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7903 test_mkdir -p $DIR/$tdir
7904 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
7905 skip "no early lock cancel on server" && return 0
7907 lru_resize_disable mdc
7908 lru_resize_disable osc
7909 cancel_lru_locks mdc
7910 # asynchronous object destroy at MDT could cause bl ast to client
7911 cancel_lru_locks osc
7913 stat $DIR/$tdir > /dev/null
7914 can1=$(do_facet $SINGLEMDS \
7915 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
7916 awk '/ldlm_cancel/ {print $2}')
7917 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
7918 awk '/ldlm_bl_callback/ {print $2}')
7919 test_mkdir -c1 $DIR/$tdir/d1
7920 can2=$(do_facet $SINGLEMDS \
7921 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
7922 awk '/ldlm_cancel/ {print $2}')
7923 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
7924 awk '/ldlm_bl_callback/ {print $2}')
7925 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
7926 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
7927 lru_resize_enable mdc
7928 lru_resize_enable osc
7930 run_test 120a "Early Lock Cancel: mkdir test"
7933 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7934 test_mkdir $DIR/$tdir
7935 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel)" ] && \
7936 skip "no early lock cancel on server" && return 0
7937 lru_resize_disable mdc
7938 lru_resize_disable osc
7939 cancel_lru_locks mdc
7940 stat $DIR/$tdir > /dev/null
7941 can1=$(do_facet $SINGLEMDS \
7942 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
7943 awk '/ldlm_cancel/ {print $2}')
7944 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
7945 awk '/ldlm_bl_callback/ {print $2}')
7947 can2=$(do_facet $SINGLEMDS \
7948 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
7949 awk '/ldlm_cancel/ {print $2}')
7950 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
7951 awk '/ldlm_bl_callback/ {print $2}')
7952 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
7953 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
7954 lru_resize_enable mdc
7955 lru_resize_enable osc
7957 run_test 120b "Early Lock Cancel: create test"
7960 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7961 test_mkdir -c1 $DIR/$tdir
7962 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel)" ] && \
7963 skip "no early lock cancel on server" && return 0
7964 lru_resize_disable mdc
7965 lru_resize_disable osc
7966 test_mkdir -p -c1 $DIR/$tdir/d1
7967 test_mkdir -p -c1 $DIR/$tdir/d2
7968 touch $DIR/$tdir/d1/f1
7969 cancel_lru_locks mdc
7970 stat $DIR/$tdir/d1 $DIR/$tdir/d2 $DIR/$tdir/d1/f1 > /dev/null
7971 can1=$(do_facet $SINGLEMDS \
7972 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
7973 awk '/ldlm_cancel/ {print $2}')
7974 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
7975 awk '/ldlm_bl_callback/ {print $2}')
7976 ln $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2
7977 can2=$(do_facet $SINGLEMDS \
7978 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
7979 awk '/ldlm_cancel/ {print $2}')
7980 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
7981 awk '/ldlm_bl_callback/ {print $2}')
7982 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
7983 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
7984 lru_resize_enable mdc
7985 lru_resize_enable osc
7987 run_test 120c "Early Lock Cancel: link test"
7990 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7991 test_mkdir -p -c1 $DIR/$tdir
7992 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel)" ] && \
7993 skip "no early lock cancel on server" && return 0
7994 lru_resize_disable mdc
7995 lru_resize_disable osc
7997 cancel_lru_locks mdc
7998 stat $DIR/$tdir > /dev/null
7999 can1=$(do_facet $SINGLEMDS \
8000 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8001 awk '/ldlm_cancel/ {print $2}')
8002 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8003 awk '/ldlm_bl_callback/ {print $2}')
8004 chmod a+x $DIR/$tdir
8005 can2=$(do_facet $SINGLEMDS \
8006 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8007 awk '/ldlm_cancel/ {print $2}')
8008 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8009 awk '/ldlm_bl_callback/ {print $2}')
8010 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
8011 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
8012 lru_resize_enable mdc
8013 lru_resize_enable osc
8015 run_test 120d "Early Lock Cancel: setattr test"
8018 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8019 test_mkdir -p -c1 $DIR/$tdir
8020 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
8021 skip "no early lock cancel on server" && return 0
8022 lru_resize_disable mdc
8023 lru_resize_disable osc
8024 dd if=/dev/zero of=$DIR/$tdir/f1 count=1
8025 cancel_lru_locks mdc
8026 cancel_lru_locks osc
8027 dd if=$DIR/$tdir/f1 of=/dev/null
8028 stat $DIR/$tdir $DIR/$tdir/f1 > /dev/null
8029 # XXX client can not do early lock cancel of OST lock
8030 # during unlink (LU-4206), so cancel osc lock now.
8031 cancel_lru_locks osc
8032 can1=$(do_facet $SINGLEMDS \
8033 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8034 awk '/ldlm_cancel/ {print $2}')
8035 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8036 awk '/ldlm_bl_callback/ {print $2}')
8037 unlink $DIR/$tdir/f1
8039 can2=$(do_facet $SINGLEMDS \
8040 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8041 awk '/ldlm_cancel/ {print $2}')
8042 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8043 awk '/ldlm_bl_callback/ {print $2}')
8044 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
8045 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
8046 lru_resize_enable mdc
8047 lru_resize_enable osc
8049 run_test 120e "Early Lock Cancel: unlink test"
8052 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8053 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
8054 skip "no early lock cancel on server" && return 0
8055 test_mkdir -p -c1 $DIR/$tdir
8056 lru_resize_disable mdc
8057 lru_resize_disable osc
8058 test_mkdir -p -c1 $DIR/$tdir/d1
8059 test_mkdir -p -c1 $DIR/$tdir/d2
8060 dd if=/dev/zero of=$DIR/$tdir/d1/f1 count=1
8061 dd if=/dev/zero of=$DIR/$tdir/d2/f2 count=1
8062 cancel_lru_locks mdc
8063 cancel_lru_locks osc
8064 dd if=$DIR/$tdir/d1/f1 of=/dev/null
8065 dd if=$DIR/$tdir/d2/f2 of=/dev/null
8066 stat $DIR/$tdir/d1 $DIR/$tdir/d2 $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2 > /dev/null
8067 # XXX client can not do early lock cancel of OST lock
8068 # during rename (LU-4206), so cancel osc lock now.
8069 cancel_lru_locks osc
8070 can1=$(do_facet $SINGLEMDS \
8071 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8072 awk '/ldlm_cancel/ {print $2}')
8073 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8074 awk '/ldlm_bl_callback/ {print $2}')
8075 mrename $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2
8077 can2=$(do_facet $SINGLEMDS \
8078 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8079 awk '/ldlm_cancel/ {print $2}')
8080 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8081 awk '/ldlm_bl_callback/ {print $2}')
8082 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
8083 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
8084 lru_resize_enable mdc
8085 lru_resize_enable osc
8087 run_test 120f "Early Lock Cancel: rename test"
8090 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8091 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
8092 skip "no early lock cancel on server" && return 0
8093 lru_resize_disable mdc
8094 lru_resize_disable osc
8096 echo create $count files
8097 test_mkdir -p $DIR/$tdir
8098 cancel_lru_locks mdc
8099 cancel_lru_locks osc
8102 can0=$(do_facet $SINGLEMDS \
8103 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8104 awk '/ldlm_cancel/ {print $2}')
8105 blk0=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8106 awk '/ldlm_bl_callback/ {print $2}')
8107 createmany -o $DIR/$tdir/f $count
8109 can1=$(do_facet $SINGLEMDS \
8110 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8111 awk '/ldlm_cancel/ {print $2}')
8112 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8113 awk '/ldlm_bl_callback/ {print $2}')
8115 echo total: $((can1-can0)) cancels, $((blk1-blk0)) blockings
8116 echo rm $count files
8119 can2=$(do_facet $SINGLEMDS \
8120 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8121 awk '/ldlm_cancel/ {print $2}')
8122 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8123 awk '/ldlm_bl_callback/ {print $2}')
8125 echo total: $count removes in $((t2-t1))
8126 echo total: $((can2-can1)) cancels, $((blk2-blk1)) blockings
8128 # wait for commitment of removal
8129 lru_resize_enable mdc
8130 lru_resize_enable osc
8132 run_test 120g "Early Lock Cancel: performance test"
8134 test_121() { #bug #10589
8135 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8137 writes=$(LANG=C dd if=/dev/zero of=$DIR/$tfile count=1 2>&1 | awk -F '+' '/out$/ {print $1}')
8138 #define OBD_FAIL_LDLM_CANCEL_RACE 0x310
8139 lctl set_param fail_loc=0x310
8140 cancel_lru_locks osc > /dev/null
8141 reads=$(LANG=C dd if=$DIR/$tfile of=/dev/null 2>&1 | awk -F '+' '/in$/ {print $1}')
8142 lctl set_param fail_loc=0
8143 [[ $reads -eq $writes ]] ||
8144 error "read $reads blocks, must be $writes blocks"
8146 run_test 121 "read cancel race ========="
8148 test_123a() { # was test 123, statahead(bug 11401)
8149 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8151 if [ -z "$(grep "processor.*: 1" /proc/cpuinfo)" ]; then
8152 log "testing on UP system. Performance may be not as good as expected."
8157 test_mkdir -p $DIR/$tdir
8158 NUMFREE=$(df -i -P $DIR | tail -n 1 | awk '{ print $4 }')
8159 [[ $NUMFREE -gt 100000 ]] && NUMFREE=100000 || NUMFREE=$((NUMFREE-1000))
8161 for ((i=100, j=0; i<=$NUMFREE; j=$i, i=$((i * MULT)) )); do
8162 createmany -o $DIR/$tdir/$tfile $j $((i - j))
8164 max=`lctl get_param -n llite.*.statahead_max | head -n 1`
8165 lctl set_param -n llite.*.statahead_max 0
8166 lctl get_param llite.*.statahead_max
8167 cancel_lru_locks mdc
8168 cancel_lru_locks osc
8170 time ls -l $DIR/$tdir | wc -l
8172 delta=$((etime - stime))
8173 log "ls $i files without statahead: $delta sec"
8174 lctl set_param llite.*.statahead_max=$max
8176 swrong=`lctl get_param -n llite.*.statahead_stats | grep "statahead wrong:" | awk '{print $3}'`
8177 lctl get_param -n llite.*.statahead_max | grep '[0-9]'
8178 cancel_lru_locks mdc
8179 cancel_lru_locks osc
8181 time ls -l $DIR/$tdir | wc -l
8183 delta_sa=$((etime - stime))
8184 log "ls $i files with statahead: $delta_sa sec"
8185 lctl get_param -n llite.*.statahead_stats
8186 ewrong=`lctl get_param -n llite.*.statahead_stats | grep "statahead wrong:" | awk '{print $3}'`
8188 [[ $swrong -lt $ewrong ]] &&
8189 log "statahead was stopped, maybe too many locks held!"
8190 [[ $delta -eq 0 || $delta_sa -eq 0 ]] && continue
8192 if [ $((delta_sa * 100)) -gt $((delta * 105)) -a $delta_sa -gt $((delta + 2)) ]; then
8193 max=`lctl get_param -n llite.*.statahead_max | head -n 1`
8194 lctl set_param -n llite.*.statahead_max 0
8195 lctl get_param llite.*.statahead_max
8196 cancel_lru_locks mdc
8197 cancel_lru_locks osc
8199 time ls -l $DIR/$tdir | wc -l
8201 delta=$((etime - stime))
8202 log "ls $i files again without statahead: $delta sec"
8203 lctl set_param llite.*.statahead_max=$max
8204 if [ $((delta_sa * 100)) -gt $((delta * 105)) -a $delta_sa -gt $((delta + 2)) ]; then
8205 if [ $SLOWOK -eq 0 ]; then
8206 error "ls $i files is slower with statahead!"
8208 log "ls $i files is slower with statahead!"
8214 [ $delta -gt 20 ] && break
8215 [ $delta -gt 8 ] && MULT=$((50 / delta))
8216 [ "$SLOW" = "no" -a $delta -gt 5 ] && break
8224 delta=$((etime - stime))
8225 log "rm -r $DIR/$tdir/: $delta seconds"
8227 lctl get_param -n llite.*.statahead_stats
8229 run_test 123a "verify statahead work"
8231 test_123b () { # statahead(bug 15027)
8232 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8233 test_mkdir -p $DIR/$tdir
8234 createmany -o $DIR/$tdir/$tfile-%d 1000
8236 cancel_lru_locks mdc
8237 cancel_lru_locks osc
8239 #define OBD_FAIL_MDC_GETATTR_ENQUEUE 0x803
8240 lctl set_param fail_loc=0x80000803
8241 ls -lR $DIR/$tdir > /dev/null
8243 lctl set_param fail_loc=0x0
8244 lctl get_param -n llite.*.statahead_stats
8249 run_test 123b "not panic with network error in statahead enqueue (bug 15027)"
8252 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8253 [ -z "$($LCTL get_param -n mdc.*.connect_flags | grep lru_resize)" ] &&
8254 skip "no lru resize on server" && return 0
8256 test_mkdir -p $DIR/$tdir || error "failed to create $DIR/$tdir"
8258 log "create $NR files at $DIR/$tdir"
8259 createmany -o $DIR/$tdir/f $NR ||
8260 error "failed to create $NR files in $DIR/$tdir"
8262 cancel_lru_locks mdc
8263 ls -l $DIR/$tdir > /dev/null
8267 for VALUE in $($LCTL get_param ldlm.namespaces.*mdc-*.lru_size); do
8268 local PARAM=$(echo ${VALUE[0]} | cut -d "=" -f1)
8269 LRU_SIZE=$($LCTL get_param -n $PARAM)
8270 if [[ $LRU_SIZE -gt $(default_lru_size) ]]; then
8271 NSDIR=$(echo $PARAM | cut -d "." -f1-3)
8273 log "NS=$(basename $NSDIR)"
8278 if [[ -z "$NSDIR" || $LRU_SIZE -lt $(default_lru_size) ]]; then
8279 skip "Not enough cached locks created!"
8286 # We know that lru resize allows one client to hold $LIMIT locks
8287 # for 10h. After that locks begin to be killed by client.
8289 local LIMIT=$($LCTL get_param -n $NSDIR.pool.limit)
8291 if [ $LIMIT -lt $LRU_SIZE ]; then
8292 skip "Limit is too small $LIMIT"
8296 # Make LVF so higher that sleeping for $SLEEP is enough to _start_
8297 # killing locks. Some time was spent for creating locks. This means
8298 # that up to the moment of sleep finish we must have killed some of
8299 # them (10-100 locks). This depends on how fast ther were created.
8300 # Many of them were touched in almost the same moment and thus will
8301 # be killed in groups.
8302 local LVF=$(($MAX_HRS * 60 * 60 / $SLEEP * $LIMIT / $LRU_SIZE))
8304 # Use $LRU_SIZE_B here to take into account real number of locks
8305 # created in the case of CMD, LRU_SIZE_B != $NR in most of cases
8306 local LRU_SIZE_B=$LRU_SIZE
8308 local OLD_LVF=$($LCTL get_param -n $NSDIR.pool.lock_volume_factor)
8309 log "OLD_LVF=$OLD_LVF"
8310 $LCTL set_param -n $NSDIR.pool.lock_volume_factor $LVF
8312 # Let's make sure that we really have some margin. Client checks
8313 # cached locks every 10 sec.
8315 log "Sleep ${SLEEP} sec"
8317 while ((SEC<$SLEEP)); do
8321 LRU_SIZE=$($LCTL get_param -n $NSDIR/lru_size)
8325 $LCTL set_param -n $NSDIR.pool.lock_volume_factor $OLD_LVF
8326 local LRU_SIZE_A=$($LCTL get_param -n $NSDIR.lru_size)
8328 [[ $LRU_SIZE_B -gt $LRU_SIZE_A ]] || {
8329 error "No locks dropped in ${SLEEP}s. LRU size: $LRU_SIZE_A"
8330 unlinkmany $DIR/$tdir/f $NR
8334 log "Dropped "$((LRU_SIZE_B-LRU_SIZE_A))" locks in ${SLEEP}s"
8335 log "unlink $NR files at $DIR/$tdir"
8336 unlinkmany $DIR/$tdir/f $NR
8338 run_test 124a "lru resize ======================================="
8340 get_max_pool_limit()
8342 local limit=$($LCTL get_param \
8343 -n ldlm.namespaces.*-MDT0000-mdc-*.pool.limit)
8346 if [[ $l -gt $max ]]; then
8354 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8355 [ -z "$($LCTL get_param -n mdc.*.connect_flags | grep lru_resize)" ] &&
8356 skip "no lru resize on server" && return 0
8358 LIMIT=$(get_max_pool_limit)
8360 NR=$(($(default_lru_size)*20))
8361 if [[ $NR -gt $LIMIT ]]; then
8362 log "Limit lock number by $LIMIT locks"
8365 lru_resize_disable mdc
8366 test_mkdir -p $DIR/$tdir/disable_lru_resize ||
8367 error "failed to create $DIR/$tdir/disable_lru_resize"
8369 createmany -o $DIR/$tdir/disable_lru_resize/f $NR
8370 log "doing ls -la $DIR/$tdir/disable_lru_resize 3 times"
8371 cancel_lru_locks mdc
8374 ls -la $DIR/$tdir/disable_lru_resize > /dev/null &
8377 ls -la $DIR/$tdir/disable_lru_resize > /dev/null &
8380 ls -la $DIR/$tdir/disable_lru_resize > /dev/null &
8384 nolruresize_delta=$((etime-stime))
8385 log "ls -la time: $nolruresize_delta seconds"
8386 log "lru_size = $(lctl get_param -n ldlm.namespaces.*mdc*.lru_size)"
8387 unlinkmany $DIR/$tdir/disable_lru_resize/f $NR
8389 lru_resize_enable mdc
8390 test_mkdir -p $DIR/$tdir/enable_lru_resize ||
8391 error "failed to create $DIR/$tdir/enable_lru_resize"
8393 createmany -o $DIR/$tdir/enable_lru_resize/f $NR
8394 log "doing ls -la $DIR/$tdir/enable_lru_resize 3 times"
8395 cancel_lru_locks mdc
8398 ls -la $DIR/$tdir/enable_lru_resize > /dev/null &
8401 ls -la $DIR/$tdir/enable_lru_resize > /dev/null &
8404 ls -la $DIR/$tdir/enable_lru_resize > /dev/null &
8408 lruresize_delta=$((etime-stime))
8409 log "ls -la time: $lruresize_delta seconds"
8410 log "lru_size = $(lctl get_param -n ldlm.namespaces.*mdc*.lru_size)"
8412 if [ $lruresize_delta -gt $nolruresize_delta ]; then
8413 log "ls -la is $(((lruresize_delta - $nolruresize_delta) * 100 / $nolruresize_delta))% slower with lru resize enabled"
8414 elif [ $nolruresize_delta -gt $lruresize_delta ]; then
8415 log "ls -la is $(((nolruresize_delta - $lruresize_delta) * 100 / $nolruresize_delta))% faster with lru resize enabled"
8417 log "lru resize performs the same with no lru resize"
8419 unlinkmany $DIR/$tdir/enable_lru_resize/f $NR
8421 run_test 124b "lru resize (performance test) ======================="
8424 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8425 [ -z "$($LCTL get_param -n mdc.*.connect_flags | grep lru_resize)" ] &&
8426 skip "no lru resize on server" && return 0
8428 # cache ununsed locks on client
8430 cancel_lru_locks mdc
8431 test_mkdir -p $DIR/$tdir || error "failed to create $DIR/$tdir"
8432 createmany -o $DIR/$tdir/f $nr ||
8433 error "failed to create $nr files in $DIR/$tdir"
8434 ls -l $DIR/$tdir > /dev/null
8436 local nsdir="ldlm.namespaces.*-MDT0000-mdc-*"
8437 local unused=$($LCTL get_param -n $nsdir.lock_unused_count)
8438 local max_age=$($LCTL get_param -n $nsdir.lru_max_age)
8439 local recalc_p=$($LCTL get_param -n $nsdir.pool.recalc_period)
8440 echo "unused=$unused, max_age=$max_age, recalc_p=$recalc_p"
8442 # set lru_max_age to 1 sec
8443 $LCTL set_param $nsdir.lru_max_age=1000 # jiffies
8444 echo "sleep $((recalc_p * 2)) seconds..."
8445 sleep $((recalc_p * 2))
8447 local remaining=$($LCTL get_param -n $nsdir.lock_unused_count)
8448 # restore lru_max_age
8449 $LCTL set_param -n $nsdir.lru_max_age $max_age
8450 [ $remaining -eq 0 ] || error "$remaining locks are not canceled"
8451 unlinkmany $DIR/$tdir/f $nr
8453 run_test 124c "LRUR cancel very aged locks"
8455 test_125() { # 13358
8456 [ -z "$(lctl get_param -n llite.*.client_type | grep local)" ] && skip "must run as local client" && return
8457 [ -z "$(lctl get_param -n mdc.*-mdc-*.connect_flags | grep acl)" ] && skip "must have acl enabled" && return
8458 [ -z "$(which setfacl)" ] && skip "must have setfacl tool" && return
8459 test_mkdir -p $DIR/d125 || error "mkdir failed"
8460 $SETSTRIPE -S 65536 -c -1 $DIR/d125 || error "setstripe failed"
8461 setfacl -R -m u:bin:rwx $DIR/d125 || error "setfacl $DIR/d125 failed"
8462 ls -ld $DIR/d125 || error "cannot access $DIR/d125"
8464 run_test 125 "don't return EPROTO when a dir has a non-default striping and ACLs"
8466 test_126() { # bug 12829/13455
8467 [ -z "$(lctl get_param -n llite.*.client_type | grep local)" ] && skip "must run as local client" && return
8468 [ "$UID" != 0 ] && skip_env "skipping $TESTNAME (must run as root)" && return
8469 $GSS && skip "must run as gss disabled" && return
8471 $RUNAS -u 0 -g 1 touch $DIR/$tfile || error "touch failed"
8472 gid=`ls -n $DIR/$tfile | awk '{print $4}'`
8474 [ $gid -eq "1" ] || error "gid is set to" $gid "instead of 1"
8476 run_test 126 "check that the fsgid provided by the client is taken into account"
8478 test_127a() { # bug 15521
8479 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8480 $SETSTRIPE -i 0 -c 1 $DIR/$tfile || error "setstripe failed"
8481 $LCTL set_param osc.*.stats=0
8482 FSIZE=$((2048 * 1024))
8483 dd if=/dev/zero of=$DIR/$tfile bs=$FSIZE count=1
8484 cancel_lru_locks osc
8485 dd if=$DIR/$tfile of=/dev/null bs=$FSIZE
8487 $LCTL get_param osc.*0000-osc-*.stats | grep samples > $DIR/${tfile}.tmp
8488 while read NAME COUNT SAMP UNIT MIN MAX SUM SUMSQ; do
8489 echo "got $COUNT $NAME"
8490 [ ! $MIN ] && error "Missing min value for $NAME proc entry"
8491 eval $NAME=$COUNT || error "Wrong proc format"
8494 read_bytes|write_bytes)
8495 [ $MIN -lt 4096 ] && error "min is too small: $MIN"
8496 [ $MIN -gt $FSIZE ] && error "min is too big: $MIN"
8497 [ $MAX -lt 4096 ] && error "max is too small: $MAX"
8498 [ $MAX -gt $FSIZE ] && error "max is too big: $MAX"
8499 [ $SUM -ne $FSIZE ] && error "sum is wrong: $SUM"
8500 [ $SUMSQ -lt $(((FSIZE /4096) * (4096 * 4096))) ] &&
8501 error "sumsquare is too small: $SUMSQ"
8502 [ $SUMSQ -gt $((FSIZE * FSIZE)) ] &&
8503 error "sumsquare is too big: $SUMSQ"
8507 done < $DIR/${tfile}.tmp
8509 #check that we actually got some stats
8510 [ "$read_bytes" ] || error "Missing read_bytes stats"
8511 [ "$write_bytes" ] || error "Missing write_bytes stats"
8512 [ "$read_bytes" != 0 ] || error "no read done"
8513 [ "$write_bytes" != 0 ] || error "no write done"
8515 run_test 127a "verify the client stats are sane"
8517 test_127b() { # bug LU-333
8518 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8519 $LCTL set_param llite.*.stats=0
8520 FSIZE=65536 # sized fixed to match PAGE_SIZE for most clients
8521 # perform 2 reads and writes so MAX is different from SUM.
8522 dd if=/dev/zero of=$DIR/$tfile bs=$FSIZE count=1
8523 dd if=/dev/zero of=$DIR/$tfile bs=$FSIZE count=1
8524 cancel_lru_locks osc
8525 dd if=$DIR/$tfile of=/dev/null bs=$FSIZE count=1
8526 dd if=$DIR/$tfile of=/dev/null bs=$FSIZE count=1
8528 $LCTL get_param llite.*.stats | grep samples > $TMP/${tfile}.tmp
8529 while read NAME COUNT SAMP UNIT MIN MAX SUM SUMSQ; do
8530 echo "got $COUNT $NAME"
8531 eval $NAME=$COUNT || error "Wrong proc format"
8535 [ $COUNT -ne 2 ] && error "count is not 2: $COUNT"
8536 [ $MIN -ne $FSIZE ] && error "min is not $FSIZE: $MIN"
8537 [ $MAX -ne $FSIZE ] && error "max is incorrect: $MAX"
8538 [ $SUM -ne $((FSIZE * 2)) ] && error "sum is wrong: $SUM"
8541 [ $COUNT -ne 2 ] && error "count is not 2: $COUNT"
8542 [ $MIN -ne $FSIZE ] && error "min is not $FSIZE: $MIN"
8543 [ $MAX -ne $FSIZE ] && error "max is incorrect: $MAX"
8544 [ $SUM -ne $((FSIZE * 2)) ] && error "sum is wrong: $SUM"
8548 done < $TMP/${tfile}.tmp
8550 #check that we actually got some stats
8551 [ "$read_bytes" ] || error "Missing read_bytes stats"
8552 [ "$write_bytes" ] || error "Missing write_bytes stats"
8553 [ "$read_bytes" != 0 ] || error "no read done"
8554 [ "$write_bytes" != 0 ] || error "no write done"
8556 run_test 127b "verify the llite client stats are sane"
8558 test_128() { # bug 15212
8560 $LFS 2>&1 <<-EOF | tee $TMP/$tfile.log
8565 result=$(grep error $TMP/$tfile.log)
8567 [ -z "$result" ] || error "consecutive find's under interactive lfs failed"
8569 run_test 128 "interactive lfs for 2 consecutive find's"
8576 local LDPROC=/proc/fs/ldiskfs
8577 local facets=$(get_facets MDS)
8579 for facet in ${facets//,/ }; do
8580 canondev=$(ldiskfs_canon \
8581 *.$(convert_facet2label $facet).mntdev $facet)
8582 do_facet $facet "test -e $LDPROC/$canondev/max_dir_size" ||
8583 LDPROC=/sys/fs/ldiskfs
8584 do_facet $facet "echo $1 >$LDPROC/$canondev/max_dir_size"
8589 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8590 if [ "$(facet_fstype $SINGLEMDS)" != ldiskfs ]; then
8591 skip "Only applicable to ldiskfs-based MDTs"
8594 remote_mds_nodsh && skip "remote MDS with nodsh" && return
8599 test_mkdir -p $DIR/$tdir
8601 # block size of mds1
8602 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
8603 local MDSBLOCKSIZE=$($LCTL get_param -n mdc.*MDT0000*.blocksize)
8604 local MAX=$((MDSBLOCKSIZE * 3))
8606 local I=$(stat -c%s "$DIR/$tdir")
8608 local STRIPE_COUNT=1
8609 [[ $MDSCOUNT -ge 2 ]] && STRIPE_COUNT=$($LFS getdirstripe -c $DIR/$tdir)
8610 MAX=$((MAX*STRIPE_COUNT))
8611 while [[ $I -le $MAX ]]; do
8612 $MULTIOP $DIR/$tdir/$J Oc
8614 #check two errors ENOSPC for new version of ext4 max_dir_size patch
8615 #mainline kernel commit df981d03eeff7971ac7e6ff37000bfa702327ef1
8616 #and EFBIG for previous versions
8617 if [ $rc -eq $EFBIG -o $rc -eq $ENOSPC ]; then
8619 echo "return code $rc received as expected"
8620 multiop $DIR/$tdir/$J Oc ||
8621 error_exit "multiop failed w/o dir size limit"
8623 I=$(stat -c%s "$DIR/$tdir")
8625 if [ $(lustre_version_code $SINGLEMDS) -lt \
8626 $(version_code 2.4.51) ]
8628 [[ $I -eq $MAX ]] && return 0
8630 [[ $I -gt $MAX ]] && return 0
8632 error_exit "current dir size $I, previous limit $MAX"
8633 elif [ $rc -ne 0 ]; then
8635 error_exit "return code $rc received instead of expected " \
8636 "$EFBIG or $ENOSPC, files in dir $I"
8639 I=$(stat -c%s "$DIR/$tdir")
8643 error "exceeded dir size limit $MAX($MDSCOUNT) : $I bytes"
8645 run_test 129 "test directory size limit ========================"
8654 local filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
8655 [ -n "$filefrag_op" ] && skip_env "filefrag does not support FIEMAP" &&
8658 trap cleanup_130 EXIT RETURN
8660 local fm_file=$DIR/$tfile
8661 $SETSTRIPE -S 65536 -c 1 $fm_file || error "setstripe on $fm_file"
8662 dd if=/dev/zero of=$fm_file bs=65536 count=1 ||
8663 error "dd failed for $fm_file"
8665 # LU-1795: test filefrag/FIEMAP once, even if unsupported
8666 filefrag -ves $fm_file
8668 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
8669 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
8670 [ $RC != 0 ] && error "filefrag $fm_file failed"
8672 filefrag_op=$(filefrag -ve $fm_file | grep -A 100 "ext:" |
8673 grep -v "ext:" | grep -v "found")
8674 lun=$($GETSTRIPE -i $fm_file)
8676 start_blk=`echo $filefrag_op | cut -d: -f2 | cut -d. -f1`
8679 for line in $filefrag_op
8681 frag_lun=`echo $line | cut -d: -f5`
8682 ext_len=`echo $line | cut -d: -f4`
8683 if (( $frag_lun != $lun )); then
8685 error "FIEMAP on 1-stripe file($fm_file) failed"
8688 (( tot_len += ext_len ))
8691 if (( lun != frag_lun || start_blk != 0 || tot_len != 64 )); then
8693 error "FIEMAP on 1-stripe file($fm_file) failed;"
8699 echo "FIEMAP on single striped file succeeded"
8701 run_test 130a "FIEMAP (1-stripe file)"
8704 [ "$OSTCOUNT" -lt "2" ] &&
8705 skip_env "skipping FIEMAP on 2-stripe file test" && return
8707 [ "$OSTCOUNT" -ge "10" ] &&
8708 skip_env "skipping FIEMAP with >= 10 OSTs" && return
8710 local filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
8711 [ -n "$filefrag_op" ] && skip_env "filefrag does not support FIEMAP" &&
8714 trap cleanup_130 EXIT RETURN
8716 local fm_file=$DIR/$tfile
8717 $SETSTRIPE -S 65536 -c 2 $fm_file || error "setstripe on $fm_file"
8718 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
8719 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
8721 dd if=/dev/zero of=$fm_file bs=1M count=2 ||
8722 error "dd failed on $fm_file"
8724 filefrag -ves $fm_file || error "filefrag $fm_file failed"
8725 filefrag_op=$(filefrag -ve $fm_file | grep -A 100 "ext:" |
8726 grep -v "ext:" | grep -v "found")
8728 last_lun=$(echo $filefrag_op | cut -d: -f5)
8733 for line in $filefrag_op
8735 frag_lun=`echo $line | cut -d: -f5`
8736 ext_len=`echo $line | cut -d: -f4`
8737 if (( $frag_lun != $last_lun )); then
8738 if (( tot_len != 1024 )); then
8740 error "FIEMAP on $fm_file failed; returned len $tot_len for OST $last_lun instead of 256"
8747 (( tot_len += ext_len ))
8750 if (( num_luns != 2 || tot_len != 1024 )); then
8752 error "FIEMAP on $fm_file failed; returned wrong number of luns or wrong len for OST $last_lun"
8758 echo "FIEMAP on 2-stripe file succeeded"
8760 run_test 130b "FIEMAP (2-stripe file)"
8763 [ "$OSTCOUNT" -lt "2" ] &&
8764 skip_env "skipping FIEMAP on 2-stripe file" && return
8766 [ "$OSTCOUNT" -ge "10" ] &&
8767 skip_env "skipping FIEMAP with >= 10 OSTs" && return
8769 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
8770 [ -n "$filefrag_op" ] && skip "filefrag does not support FIEMAP" &&
8773 trap cleanup_130 EXIT RETURN
8775 local fm_file=$DIR/$tfile
8776 $SETSTRIPE -S 65536 -c 2 $fm_file || error "setstripe on $fm_file"
8777 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
8778 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
8780 dd if=/dev/zero of=$fm_file seek=1 bs=1M count=1 || error "dd failed on $fm_file"
8782 filefrag -ves $fm_file || error "filefrag $fm_file failed"
8783 filefrag_op=`filefrag -ve $fm_file | grep -A 100 "ext:" | grep -v "ext:" | grep -v "found"`
8785 last_lun=`echo $filefrag_op | cut -d: -f5`
8790 for line in $filefrag_op
8792 frag_lun=`echo $line | cut -d: -f5`
8793 ext_len=`echo $line | cut -d: -f4`
8794 if (( $frag_lun != $last_lun )); then
8795 logical=`echo $line | cut -d: -f2 | cut -d. -f1`
8796 if (( logical != 512 )); then
8798 error "FIEMAP on $fm_file failed; returned logical start for lun $logical instead of 512"
8801 if (( tot_len != 512 )); then
8803 error "FIEMAP on $fm_file failed; returned len $tot_len for OST $last_lun instead of 1024"
8810 (( tot_len += ext_len ))
8813 if (( num_luns != 2 || tot_len != 512 )); then
8815 error "FIEMAP on $fm_file failed; returned wrong number of luns or wrong len for OST $last_lun"
8821 echo "FIEMAP on 2-stripe file with hole succeeded"
8823 run_test 130c "FIEMAP (2-stripe file with hole)"
8826 [ "$OSTCOUNT" -lt "3" ] && skip_env "skipping FIEMAP on N-stripe file test" && return
8828 [ "$OSTCOUNT" -ge "10" ] &&
8829 skip_env "skipping FIEMAP with >= 10 OSTs" && return
8831 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
8832 [ -n "$filefrag_op" ] && skip "filefrag does not support FIEMAP" && return
8834 trap cleanup_130 EXIT RETURN
8836 local fm_file=$DIR/$tfile
8837 $SETSTRIPE -S 65536 -c $OSTCOUNT $fm_file||error "setstripe on $fm_file"
8838 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
8839 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
8841 local actual_stripecnt=$($GETSTRIPE -c $fm_file)
8842 dd if=/dev/zero of=$fm_file bs=1M count=$actual_stripecnt ||
8843 error "dd failed on $fm_file"
8845 filefrag -ves $fm_file || error "filefrag $fm_file failed"
8846 filefrag_op=`filefrag -ve $fm_file | grep -A 100 "ext:" |
8847 grep -v "ext:" | grep -v "found"`
8849 last_lun=`echo $filefrag_op | cut -d: -f5`
8854 for line in $filefrag_op
8856 frag_lun=`echo $line | cut -d: -f5`
8857 ext_len=`echo $line | cut -d: -f4`
8858 if (( $frag_lun != $last_lun )); then
8859 if (( tot_len != 1024 )); then
8861 error "FIEMAP on $fm_file failed; returned len $tot_len for OST $last_lun instead of 1024"
8868 (( tot_len += ext_len ))
8871 if (( num_luns != actual_stripecnt || tot_len != 1024 )); then
8873 error "FIEMAP on $fm_file failed; returned wrong number of luns or wrong len for OST $last_lun"
8879 echo "FIEMAP on N-stripe file succeeded"
8881 run_test 130d "FIEMAP (N-stripe file)"
8884 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping continuation FIEMAP test" && return
8886 [ "$OSTCOUNT" -ge "10" ] &&
8887 skip_env "skipping FIEMAP with >= 10 OSTs" && return
8889 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
8890 [ -n "$filefrag_op" ] && skip "filefrag does not support FIEMAP" && return
8892 trap cleanup_130 EXIT RETURN
8894 local fm_file=$DIR/$tfile
8895 $SETSTRIPE -S 131072 -c 2 $fm_file || error "setstripe on $fm_file"
8896 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
8897 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
8900 EXPECTED_LEN=$(( (NUM_BLKS / 2) * 64 ))
8901 for ((i = 0; i < $NUM_BLKS; i++))
8903 dd if=/dev/zero of=$fm_file count=1 bs=64k seek=$((2*$i)) conv=notrunc > /dev/null 2>&1
8906 filefrag -ves $fm_file || error "filefrag $fm_file failed"
8907 filefrag_op=`filefrag -ve $fm_file | grep -A 12000 "ext:" | grep -v "ext:" | grep -v "found"`
8909 last_lun=`echo $filefrag_op | cut -d: -f5`
8914 for line in $filefrag_op
8916 frag_lun=`echo $line | cut -d: -f5`
8917 ext_len=`echo $line | cut -d: -f4`
8918 if (( $frag_lun != $last_lun )); then
8919 if (( tot_len != $EXPECTED_LEN )); then
8921 error "FIEMAP on $fm_file failed; returned len $tot_len for OST $last_lun instead of $EXPECTED_LEN"
8928 (( tot_len += ext_len ))
8931 if (( num_luns != 2 || tot_len != $EXPECTED_LEN )); then
8933 error "FIEMAP on $fm_file failed; returned wrong number of luns or wrong len for OST $last_lun"
8939 echo "FIEMAP with continuation calls succeeded"
8941 run_test 130e "FIEMAP (test continuation FIEMAP calls)"
8943 # Test for writev/readv
8945 rwv -f $DIR/$tfile -w -n 3 524288 1048576 1572864 || \
8946 error "writev test failed"
8947 rwv -f $DIR/$tfile -r -v -n 2 1572864 1048576 || \
8948 error "readv failed"
8951 run_test 131a "test iov's crossing stripe boundary for writev/readv"
8954 rwv -f $DIR/$tfile -w -a -n 3 524288 1048576 1572864 || \
8955 error "append writev test failed"
8956 rwv -f $DIR/$tfile -w -a -n 2 1572864 1048576 || \
8957 error "append writev test failed"
8960 run_test 131b "test append writev"
8963 rwv -f $DIR/$tfile -w -d -n 1 1048576 || return 0
8966 run_test 131c "test read/write on file w/o objects"
8969 rwv -f $DIR/$tfile -w -n 1 1572864
8970 NOB=`rwv -f $DIR/$tfile -r -n 3 524288 524288 1048576 | awk '/error/ {print $6}'`
8971 if [ "$NOB" != 1572864 ]; then
8972 error "Short read filed: read $NOB bytes instead of 1572864"
8976 run_test 131d "test short read"
8979 rwv -f $DIR/$tfile -w -s 1048576 -n 1 1048576
8980 rwv -f $DIR/$tfile -r -z -s 0 -n 1 524288 || \
8981 error "read hitting hole failed"
8984 run_test 131e "test read hitting hole"
8990 $SINGLEMDS) res=`do_facet $SINGLEMDS $LCTL get_param mdt.$FSNAME-MDT0000.md_stats | grep "$2"`
8992 ost) res=`do_facet ost1 $LCTL get_param obdfilter.$FSNAME-OST0000.stats | grep "$2"`
8994 *) error "Wrong argument $1" ;;
8997 [ -z "$res" ] && error "The counter for $2 on $1 was not incremented"
8998 # if the argument $3 is zero, it means any stat increment is ok.
8999 if [[ $3 -gt 0 ]]; then
9000 count=$(echo $res | awk '{ print $2 }')
9001 [[ $count -ne $3 ]] &&
9002 error "The $2 counter on $1 is wrong - expected $3"
9007 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9008 remote_ost_nodsh && skip "remote OST with nodsh" && return
9009 remote_mds_nodsh && skip "remote MDS with nodsh" && return
9011 do_facet $SINGLEMDS $LCTL list_param mdt.*.rename_stats ||
9012 { skip "MDS doesn't support rename stats"; return; }
9013 local testdir=$DIR/${tdir}/stats_testdir
9014 mkdir -p $DIR/${tdir}
9017 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
9018 do_facet ost1 $LCTL set_param obdfilter.*.stats=clear
9020 # verify mdt stats first.
9021 mkdir ${testdir} || error "mkdir failed"
9022 check_stats $SINGLEMDS "mkdir" 1
9023 touch ${testdir}/${tfile} || "touch failed"
9024 check_stats $SINGLEMDS "open" 1
9025 check_stats $SINGLEMDS "close" 1
9026 mknod ${testdir}/${tfile}-pipe p || "mknod failed"
9027 check_stats $SINGLEMDS "mknod" 1
9028 rm -f ${testdir}/${tfile}-pipe || "pipe remove failed"
9029 check_stats $SINGLEMDS "unlink" 1
9030 rm -f ${testdir}/${tfile} || error "file remove failed"
9031 check_stats $SINGLEMDS "unlink" 2
9033 # remove working dir and check mdt stats again.
9034 rmdir ${testdir} || error "rmdir failed"
9035 check_stats $SINGLEMDS "rmdir" 1
9037 local testdir1=$DIR/${tdir}/stats_testdir1
9039 mkdir -p ${testdir1}
9040 touch ${testdir1}/test1
9041 mv ${testdir1}/test1 ${testdir} || error "file crossdir rename"
9042 check_stats $SINGLEMDS "crossdir_rename" 1
9044 mv ${testdir}/test1 ${testdir}/test0 || error "file samedir rename"
9045 check_stats $SINGLEMDS "samedir_rename" 1
9049 run_test 133a "Verifying MDT stats ========================================"
9052 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9053 remote_ost_nodsh && skip "remote OST with nodsh" && return
9054 remote_mds_nodsh && skip "remote MDS with nodsh" && return
9055 local testdir=$DIR/${tdir}/stats_testdir
9056 mkdir -p ${testdir} || error "mkdir failed"
9057 touch ${testdir}/${tfile} || "touch failed"
9058 cancel_lru_locks mdc
9061 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
9062 do_facet ost1 $LCTL set_param obdfilter.*.stats=clear
9064 # extra mdt stats verification.
9065 chmod 444 ${testdir}/${tfile} || error "chmod failed"
9066 check_stats $SINGLEMDS "setattr" 1
9067 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
9068 if [ $(lustre_version_code $SINGLEMDS) -ne $(version_code 2.2.0) ]
9070 ls -l ${testdir}/${tfile} > /dev/null|| error "ls failed"
9071 check_stats $SINGLEMDS "getattr" 1
9073 $LFS df || error "lfs failed"
9074 check_stats $SINGLEMDS "statfs" 1
9078 run_test 133b "Verifying extra MDT stats =================================="
9081 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9082 remote_ost_nodsh && skip "remote OST with nodsh" && return
9083 remote_mds_nodsh && skip "remote MDS with nodsh" && return
9084 local testdir=$DIR/${tdir}/stats_testdir
9085 test_mkdir -p ${testdir} || error "mkdir failed"
9087 # verify obdfilter stats.
9088 $SETSTRIPE -c 1 -i 0 ${testdir}/${tfile}
9090 cancel_lru_locks osc
9091 wait_delete_completed
9094 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
9095 do_facet ost1 $LCTL set_param obdfilter.*.stats=clear
9097 dd if=/dev/zero of=${testdir}/${tfile} conv=notrunc bs=512k count=1 || error "dd failed"
9099 cancel_lru_locks osc
9100 check_stats ost "write" 1
9102 dd if=${testdir}/${tfile} of=/dev/null bs=1k count=1 || error "dd failed"
9103 check_stats ost "read" 1
9105 > ${testdir}/${tfile} || error "truncate failed"
9106 check_stats ost "punch" 1
9108 rm -f ${testdir}/${tfile} || error "file remove failed"
9109 wait_delete_completed
9110 check_stats ost "destroy" 1
9114 run_test 133c "Verifying OST stats ========================================"
9121 while [ $value -ge 2 ]; do
9126 if [ $orig -gt $order ]; then
9134 local size=('K' 'M' 'G' 'T');
9136 local size_string=$value
9138 while [ $value -ge 1024 ]; do
9139 if [ $i -gt 3 ]; then
9140 #T is the biggest unit we get here, if that is bigger,
9142 size_string=${value}T
9145 value=$((value >> 10))
9146 if [ $value -lt 1024 ]; then
9147 size_string=${value}${size[$i]}
9158 local context=${2:-.}
9159 local sample=$(do_facet $SINGLEMDS $LCTL get_param mdt.*.rename_stats |
9161 awk '/ '${size}'/ {print $4}' | sed -e "s/,//g")
9166 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9167 remote_ost_nodsh && skip "remote OST with nodsh" && return
9168 remote_mds_nodsh && skip "remote MDS with nodsh" && return
9169 do_facet $SINGLEMDS $LCTL list_param mdt.*.rename_stats ||
9170 { skip "MDS doesn't support rename stats"; return; }
9172 local testdir1=$DIR/${tdir}/stats_testdir1
9173 local testdir2=$DIR/${tdir}/stats_testdir2
9175 do_facet $SINGLEMDS $LCTL set_param mdt.*.rename_stats=clear
9177 mkdir -p ${testdir1} || error "mkdir failed"
9178 mkdir -p ${testdir2} || error "mkdir failed"
9180 createmany -o $testdir1/test 512 || error "createmany failed"
9182 # check samedir rename size
9183 mv ${testdir1}/test0 ${testdir1}/test_0
9185 local testdir1_size=$(ls -l $DIR/${tdir} |
9186 awk '/stats_testdir1/ {print $5}')
9187 local testdir2_size=$(ls -l $DIR/${tdir} |
9188 awk '/stats_testdir2/ {print $5}')
9190 testdir1_size=$(order_2 $testdir1_size)
9191 testdir2_size=$(order_2 $testdir2_size)
9193 testdir1_size=$(size_in_KMGT $testdir1_size)
9194 testdir2_size=$(size_in_KMGT $testdir2_size)
9196 echo "source rename dir size: ${testdir1_size}"
9197 echo "target rename dir size: ${testdir2_size}"
9199 local cmd="do_facet $SINGLEMDS $LCTL get_param mdt.*.rename_stats"
9200 eval $cmd || error "$cmd failed"
9201 local samedir=$($cmd | grep 'same_dir')
9202 local same_sample=$(get_rename_size $testdir1_size)
9203 [ -z "$samedir" ] && error "samedir_rename_size count error"
9204 [[ $same_sample -eq 1 ]] ||
9205 error "samedir_rename_size error $same_sample"
9206 echo "Check same dir rename stats success"
9208 do_facet $SINGLEMDS $LCTL set_param mdt.*.rename_stats=clear
9210 # check crossdir rename size
9211 mv ${testdir1}/test_0 ${testdir2}/test_0
9213 testdir1_size=$(ls -l $DIR/${tdir} |
9214 awk '/stats_testdir1/ {print $5}')
9215 testdir2_size=$(ls -l $DIR/${tdir} |
9216 awk '/stats_testdir2/ {print $5}')
9218 testdir1_size=$(order_2 $testdir1_size)
9219 testdir2_size=$(order_2 $testdir2_size)
9221 testdir1_size=$(size_in_KMGT $testdir1_size)
9222 testdir2_size=$(size_in_KMGT $testdir2_size)
9224 echo "source rename dir size: ${testdir1_size}"
9225 echo "target rename dir size: ${testdir2_size}"
9227 eval $cmd || error "$cmd failed"
9228 local crossdir=$($cmd | grep 'crossdir')
9229 local src_sample=$(get_rename_size $testdir1_size crossdir_src)
9230 local tgt_sample=$(get_rename_size $testdir2_size crossdir_tgt)
9231 [ -z "$crossdir" ] && error "crossdir_rename_size count error"
9232 [[ $src_sample -eq 1 ]] ||
9233 error "crossdir_rename_size error $src_sample"
9234 [[ $tgt_sample -eq 1 ]] ||
9235 error "crossdir_rename_size error $tgt_sample"
9236 echo "Check cross dir rename stats success"
9239 run_test 133d "Verifying rename_stats ========================================"
9242 remote_mds_nodsh && skip "remote MDS with nodsh" && return
9243 remote_ost_nodsh && skip "remote OST with nodsh" && return
9244 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9245 local testdir=$DIR/${tdir}/stats_testdir
9246 local ctr f0 f1 bs=32768 count=42 sum
9248 mkdir -p ${testdir} || error "mkdir failed"
9250 $SETSTRIPE -c 1 -i 0 ${testdir}/${tfile}
9252 for ctr in {write,read}_bytes; do
9254 cancel_lru_locks osc
9256 do_facet ost1 $LCTL set_param -n \
9257 "obdfilter.*.exports.clear=clear"
9259 if [ $ctr = write_bytes ]; then
9261 f1=${testdir}/${tfile}
9263 f0=${testdir}/${tfile}
9267 dd if=$f0 of=$f1 conv=notrunc bs=$bs count=$count || \
9270 cancel_lru_locks osc
9272 sum=$(do_facet ost1 $LCTL get_param \
9273 "obdfilter.*.exports.*.stats" |
9274 awk -v ctr=$ctr 'BEGIN { sum = 0 }
9275 $1 == ctr { sum += $7 }
9276 END { printf("%0.0f", sum) }')
9278 if ((sum != bs * count)); then
9279 error "Bad $ctr sum, expected $((bs * count)), got $sum"
9285 run_test 133e "Verifying OST {read,write}_bytes nid stats ================="
9290 local dirs="/proc/fs/lustre/ /proc/sys/lnet/ /proc/sys/lustre/ \
9291 /sys/fs/lustre/ /sys/fs/lnet/"
9293 for dir in $dirs; do
9294 if [ -d $dir ]; then
9295 proc_dirs="$proc_dirs $dir"
9301 remote_mds_nodsh && skip "remote MDS with nodsh" && return
9302 remote_ost_nodsh && skip "remote OST with nodsh" && return
9303 # First without trusting modes.
9304 find $proc_dirs -exec cat '{}' \; &> /dev/null
9306 # Second verifying readability.
9309 -exec cat '{}' \; &> /dev/null ||
9310 error "proc file read failed"
9312 for facet in $SINGLEMDS ost1; do
9313 do_facet $facet find $proc_dirs \
9314 ! -name req_history \
9315 -exec cat '{}' \\\; &> /dev/null
9317 do_facet $facet find $proc_dirs \
9318 ! -name req_history \
9320 -exec cat '{}' \\\; &> /dev/null ||
9321 error "proc file read failed"
9324 run_test 133f "Check for LBUGs/Oopses/unreadable files in /proc"
9329 local dirs="/proc/fs/lustre/ /proc/sys/lnet/ /proc/sys/lustre/ \
9330 /sys/fs/lustre/ /sys/fs/lnet/"
9332 for dir in $dirs; do
9333 if [ -d $dir ]; then
9334 proc_dirs="$proc_dirs $dir"
9340 # Second verifying readability.
9343 -not -name force_lbug \
9344 -not -name changelog_mask \
9345 -exec badarea_io '{}' \; &> /dev/null ||
9346 error "find $proc_dirs failed"
9348 [ $(lustre_version_code $SINGLEMDS) -le $(version_code 2.5.54) ] &&
9349 skip "Too old lustre on MDS" && return
9351 [ $(lustre_version_code ost1) -le $(version_code 2.5.54) ] &&
9352 skip "Too old lustre on ost1" && return
9354 for facet in $SINGLEMDS ost1; do
9355 do_facet $facet find $proc_dirs \
9357 -not -name force_lbug \
9358 -not -name changelog_mask \
9359 -exec badarea_io '{}' \\\; &> /dev/null ||
9360 error "$facet find $proc_dirs failed"
9364 # remount the FS in case writes/reads /proc break the FS
9365 cleanup || error "failed to unmount"
9366 setup || error "failed to setup"
9369 run_test 133g "Check for Oopses on bad io area writes/reads in /proc"
9371 test_140() { #bug-17379
9372 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9373 test_mkdir -p $DIR/$tdir || error "Creating dir $DIR/$tdir"
9374 cd $DIR/$tdir || error "Changing to $DIR/$tdir"
9375 cp /usr/bin/stat . || error "Copying stat to $DIR/$tdir"
9377 # VFS limits max symlink depth to 5(4KSTACK) or 7(8KSTACK) or 8
9378 # For kernel > 3.5, bellow only tests consecutive symlink (MAX 40)
9380 while i=`expr $i + 1`; do
9381 test_mkdir -p $i || error "Creating dir $i"
9382 cd $i || error "Changing to $i"
9383 ln -s ../stat stat || error "Creating stat symlink"
9384 # Read the symlink until ELOOP present,
9385 # not LBUGing the system is considered success,
9386 # we didn't overrun the stack.
9387 $OPENFILE -f O_RDONLY stat >/dev/null 2>&1; ret=$?
9389 if [ $ret -eq 40 ]; then
9392 error "Open stat symlink"
9398 echo "The symlink depth = $i"
9399 [ $i -eq 5 -o $i -eq 7 -o $i -eq 8 -o $i -eq 40 ] ||
9400 error "Invalid symlink depth"
9402 # Test recursive symlink
9403 ln -s symlink_self symlink_self
9404 $OPENFILE -f O_RDONLY symlink_self >/dev/null 2>&1; ret=$?
9405 echo "open symlink_self returns $ret"
9406 [ $ret -eq 40 ] || error "recursive symlink doesn't return -ELOOP"
9408 run_test 140 "Check reasonable stack depth (shouldn't LBUG) ===="
9411 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9412 local TF="$TMP/$tfile"
9414 dd if=/dev/urandom of=$TF bs=6096 count=1 || error "dd failed"
9416 cancel_lru_locks osc
9417 cmp $TF $DIR/$tfile || error "$TMP/$tfile $DIR/$tfile differ"
9418 remount_client $MOUNT
9420 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (remount)"
9423 $TRUNCATE $DIR/$tfile 6000
9424 cancel_lru_locks osc
9425 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (truncate1)"
9428 echo "12345" >>$DIR/$tfile
9429 cancel_lru_locks osc
9430 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (append1)"
9433 echo "12345" >>$DIR/$tfile
9434 cancel_lru_locks osc
9435 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (append2)"
9440 run_test 150 "truncate/append tests"
9442 #LU-2902 roc_hit was not able to read all values from lproc
9443 function roc_hit_init() {
9444 local list=$(comma_list $(osts_nodes))
9445 local dir=$DIR/$tdir-check
9446 local file=$dir/file
9452 #use setstripe to do a write to every ost
9453 for i in $(seq 0 $((OSTCOUNT-1))); do
9454 $SETSTRIPE -c 1 -i $i $dir || error "$SETSTRIPE $file failed"
9455 dd if=/dev/urandom of=$file bs=4k count=4 2>&1 > /dev/null
9456 idx=$(printf %04x $i)
9457 BEFORE=$(get_osd_param $list *OST*$idx stats |
9458 awk '$1 == "cache_access" {sum += $7}
9459 END { printf("%0.0f", sum) }')
9461 cancel_lru_locks osc
9462 cat $file >/dev/null
9464 AFTER=$(get_osd_param $list *OST*$idx stats |
9465 awk '$1 == "cache_access" {sum += $7}
9466 END { printf("%0.0f", sum) }')
9468 echo BEFORE:$BEFORE AFTER:$AFTER
9469 if ! let "AFTER - BEFORE == 4"; then
9471 error "roc_hit is not safe to use"
9479 function roc_hit() {
9480 local list=$(comma_list $(osts_nodes))
9481 echo $(get_osd_param $list '' stats |
9482 awk '$1 == "cache_hit" {sum += $7}
9483 END { printf("%0.0f", sum) }')
9486 function set_cache() {
9489 if [ "$2" == "off" ]; then
9492 local list=$(comma_list $(osts_nodes))
9493 set_osd_param $list '' $1_cache_enable $on
9495 cancel_lru_locks osc
9499 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9500 remote_ost_nodsh && skip "remote OST with nodsh" && return
9503 local list=$(comma_list $(osts_nodes))
9505 # check whether obdfilter is cache capable at all
9506 if ! get_osd_param $list '' read_cache_enable >/dev/null; then
9507 echo "not cache-capable obdfilter"
9511 # check cache is enabled on all obdfilters
9512 if get_osd_param $list '' read_cache_enable | grep 0; then
9513 echo "oss cache is disabled"
9517 set_osd_param $list '' writethrough_cache_enable 1
9519 # check write cache is enabled on all obdfilters
9520 if get_osd_param $list '' writethrough_cache_enable | grep 0; then
9521 echo "oss write cache is NOT enabled"
9527 #define OBD_FAIL_OBD_NO_LRU 0x609
9528 do_nodes $list $LCTL set_param fail_loc=0x609
9530 # pages should be in the case right after write
9531 dd if=/dev/urandom of=$DIR/$tfile bs=4k count=$CPAGES ||
9534 local BEFORE=$(roc_hit)
9535 cancel_lru_locks osc
9536 cat $DIR/$tfile >/dev/null
9537 local AFTER=$(roc_hit)
9539 do_nodes $list $LCTL set_param fail_loc=0
9541 if ! let "AFTER - BEFORE == CPAGES"; then
9542 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
9545 # the following read invalidates the cache
9546 cancel_lru_locks osc
9547 set_osd_param $list '' read_cache_enable 0
9548 cat $DIR/$tfile >/dev/null
9550 # now data shouldn't be found in the cache
9552 cancel_lru_locks osc
9553 cat $DIR/$tfile >/dev/null
9555 if let "AFTER - BEFORE != 0"; then
9556 error "IN CACHE: before: $BEFORE, after: $AFTER"
9559 set_osd_param $list '' read_cache_enable 1
9562 run_test 151 "test cache on oss and controls ==============================="
9565 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9566 local TF="$TMP/$tfile"
9568 # simulate ENOMEM during write
9569 #define OBD_FAIL_OST_NOMEM 0x226
9570 lctl set_param fail_loc=0x80000226
9571 dd if=/dev/urandom of=$TF bs=6096 count=1 || error "dd failed"
9573 sync || error "sync failed"
9574 lctl set_param fail_loc=0
9576 # discard client's cache
9577 cancel_lru_locks osc
9579 # simulate ENOMEM during read
9580 lctl set_param fail_loc=0x80000226
9581 cmp $TF $DIR/$tfile || error "cmp failed"
9582 lctl set_param fail_loc=0
9586 run_test 152 "test read/write with enomem ============================"
9589 $MULTIOP $DIR/$tfile Ow4096Ycu || error "multiop failed"
9591 run_test 153 "test if fdatasync does not crash ======================="
9593 dot_lustre_fid_permission_check() {
9595 local ffid=$MOUNT/.lustre/fid/$fid
9598 echo "stat fid $fid"
9599 stat $ffid > /dev/null || error "stat $ffid failed."
9600 echo "touch fid $fid"
9601 touch $ffid || error "touch $ffid failed."
9602 echo "write to fid $fid"
9603 cat /etc/hosts > $ffid || error "write $ffid failed."
9604 echo "read fid $fid"
9605 diff /etc/hosts $ffid || error "read $ffid failed."
9606 echo "append write to fid $fid"
9607 cat /etc/hosts >> $ffid || error "append write $ffid failed."
9608 echo "rename fid $fid"
9609 mv $ffid $test_dir/$tfile.1 &&
9610 error "rename $ffid to $tfile.1 should fail."
9611 touch $test_dir/$tfile.1
9612 mv $test_dir/$tfile.1 $ffid &&
9613 error "rename $tfile.1 to $ffid should fail."
9614 rm -f $test_dir/$tfile.1
9615 echo "truncate fid $fid"
9616 $TRUNCATE $ffid 777 || error "truncate $ffid failed."
9617 if [ $MDSCOUNT -lt 2 ]; then #FIXME when cross-MDT hard link is working
9618 echo "link fid $fid"
9619 ln -f $ffid $test_dir/tfile.lnk || error "link $ffid failed."
9621 if [ -n $(lctl get_param -n mdc.*-mdc-*.connect_flags | grep acl) ]; then
9622 echo "setfacl fid $fid"
9623 setfacl -R -m u:bin:rwx $ffid || error "setfacl $ffid failed."
9624 echo "getfacl fid $fid"
9625 getfacl $ffid >/dev/null || error "getfacl $ffid failed."
9627 echo "unlink fid $fid"
9628 unlink $MOUNT/.lustre/fid/$fid && error "unlink $ffid should fail."
9629 echo "mknod fid $fid"
9630 mknod $ffid c 1 3 && error "mknod $ffid should fail."
9632 fid=[0xf00000400:0x1:0x0]
9633 ffid=$MOUNT/.lustre/fid/$fid
9635 echo "stat non-exist fid $fid"
9636 stat $ffid > /dev/null && error "stat non-exist $ffid should fail."
9637 echo "write to non-exist fid $fid"
9638 cat /etc/hosts > $ffid && error "write non-exist $ffid should fail."
9639 echo "link new fid $fid"
9640 ln $test_dir/$tfile $ffid && error "link $ffid should fail."
9642 mkdir -p $test_dir/$tdir
9643 touch $test_dir/$tdir/$tfile
9644 fid=$($LFS path2fid $test_dir/$tdir)
9647 error "error: could not get fid for $test_dir/$dir/$tfile."
9649 ffid=$MOUNT/.lustre/fid/$fid
9652 ls $ffid > /dev/null || error "ls $ffid failed."
9653 echo "touch $fid/$tfile.1"
9654 touch $ffid/$tfile.1 || error "touch $ffid/$tfile.1 failed."
9656 echo "touch $MOUNT/.lustre/fid/$tfile"
9657 touch $MOUNT/.lustre/fid/$tfile && \
9658 error "touch $MOUNT/.lustre/fid/$tfile should fail."
9660 echo "setxattr to $MOUNT/.lustre/fid"
9661 setfattr -n trusted.name1 -v value1 $MOUNT/.lustre/fid
9663 echo "listxattr for $MOUNT/.lustre/fid"
9664 getfattr -d -m "^trusted" $MOUNT/.lustre/fid
9666 echo "delxattr from $MOUNT/.lustre/fid"
9667 setfattr -x trusted.name1 $MOUNT/.lustre/fid
9669 echo "touch invalid fid: $MOUNT/.lustre/fid/[0x200000400:0x2:0x3]"
9670 touch $MOUNT/.lustre/fid/[0x200000400:0x2:0x3] &&
9671 error "touch invalid fid should fail."
9673 echo "touch non-normal fid: $MOUNT/.lustre/fid/[0x1:0x2:0x0]"
9674 touch $MOUNT/.lustre/fid/[0x1:0x2:0x0] &&
9675 error "touch non-normal fid should fail."
9677 echo "rename $tdir to $MOUNT/.lustre/fid"
9678 mrename $test_dir/$tdir $MOUNT/.lustre/fid &&
9679 error "rename to $MOUNT/.lustre/fid should fail."
9681 if [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.3.51) ]
9683 local old_obf_mode=$(stat --format="%a" $DIR/.lustre/fid)
9684 local new_obf_mode=777
9686 echo "change mode of $DIR/.lustre/fid to $new_obf_mode"
9687 chmod $new_obf_mode $DIR/.lustre/fid ||
9688 error "chmod $new_obf_mode $DIR/.lustre/fid failed"
9690 local obf_mode=$(stat --format=%a $DIR/.lustre/fid)
9691 [ $obf_mode -eq $new_obf_mode ] ||
9692 error "stat $DIR/.lustre/fid returned wrong mode $obf_mode"
9694 echo "restore mode of $DIR/.lustre/fid to $old_obf_mode"
9695 chmod $old_obf_mode $DIR/.lustre/fid ||
9696 error "chmod $old_obf_mode $DIR/.lustre/fid failed"
9699 $OPENFILE -f O_LOV_DELAY_CREATE:O_CREAT $test_dir/$tfile-2
9700 fid=$($LFS path2fid $test_dir/$tfile-2)
9702 if [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.6.50) ]
9704 echo "cp /etc/passwd $MOUNT/.lustre/fid/$fid"
9705 cp /etc/passwd $MOUNT/.lustre/fid/$fid ||
9706 error "create lov data thru .lustre failed"
9708 echo "cp /etc/passwd $test_dir/$tfile-2"
9709 cp /etc/passwd $test_dir/$tfile-2 ||
9710 error "copy to $test_dir/$tfile-2 failed."
9711 echo "diff /etc/passwd $MOUNT/.lustre/fid/$fid"
9712 diff /etc/passwd $MOUNT/.lustre/fid/$fid ||
9713 error "diff /etc/passwd $MOUNT/.lustre/fid/$fid failed."
9715 rm -rf $test_dir/tfile.lnk
9716 rm -rf $test_dir/$tfile-2
9720 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.1) ]] &&
9721 skip "Need MDS version at least 2.4.1" && return
9724 local FID=$($LFS path2fid $DIR/$tfile)
9725 [ -z "$FID" ] && error "path2fid unable to get $DIR/$tfile FID"
9727 # check that we get the same pathname back
9728 local FOUND=$($LFS fid2path $MOUNT "$FID")
9729 [ -z "$FOUND" ] && error "fid2path unable to get $FID path"
9730 [ "$FOUND" != "$DIR/$tfile" ] &&
9731 error "fid2path(path2fid($DIR/$tfile)) = $FOUND != $DIR/$tfile"
9735 run_test 154A "lfs path2fid and fid2path basic checks"
9738 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9739 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.51) ]] ||
9740 { skip "Need MDS version at least 2.2.51"; return 0; }
9741 [ -z "$(which setfacl)" ] && skip "must have setfacl tool" && return
9743 cp /etc/hosts $DIR/$tfile
9745 fid=$($LFS path2fid $DIR/$tfile)
9747 [ $rc -ne 0 ] && error "error: could not get fid for $DIR/$tfile."
9749 dot_lustre_fid_permission_check "$fid" $DIR ||
9750 error "dot lustre permission check $fid failed"
9752 rm -rf $MOUNT/.lustre && error ".lustre is not allowed to be unlinked"
9754 touch $MOUNT/.lustre/file &&
9755 error "creation is not allowed under .lustre"
9757 mkdir $MOUNT/.lustre/dir &&
9758 error "mkdir is not allowed under .lustre"
9762 run_test 154a "Open-by-FID"
9765 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9766 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.51) ]] ||
9767 { skip "Need MDS version at least 2.2.51"; return 0; }
9769 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
9771 local remote_dir=$DIR/$tdir/remote_dir
9776 $LFS mkdir -i $MDTIDX $remote_dir ||
9777 error "create remote directory failed"
9779 cp /etc/hosts $remote_dir/$tfile
9781 fid=$($LFS path2fid $remote_dir/$tfile)
9783 [ $rc -ne 0 ] && error "error: could not get fid for $remote_dir/$tfile"
9785 dot_lustre_fid_permission_check "$fid" $remote_dir ||
9786 error "dot lustre permission check $fid failed"
9789 run_test 154b "Open-by-FID for remote directory"
9792 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.1) ]] &&
9793 skip "Need MDS version at least 2.4.1" && return
9795 touch $DIR/$tfile.1 $DIR/$tfile.2 $DIR/$tfile.3
9796 local FID1=$($LFS path2fid $DIR/$tfile.1)
9797 local FID2=$($LFS path2fid $DIR/$tfile.2)
9798 local FID3=$($LFS path2fid $DIR/$tfile.3)
9801 $LFS path2fid $DIR/$tfile.[123] | while read PATHNAME FID; do
9802 [ "$PATHNAME" = "$DIR/$tfile.$N:" ] ||
9803 error "path2fid pathname $PATHNAME != $DIR/$tfile.$N:"
9805 [ "$FID" = "${!want}" ] ||
9806 error "path2fid $PATHNAME FID $FID != FID$N ${!want}"
9810 $LFS fid2path $MOUNT "$FID1" "$FID2" "$FID3" | while read PATHNAME;
9812 [ "$PATHNAME" = "$DIR/$tfile.$N" ] ||
9813 error "fid2path pathname $PATHNAME != $DIR/$tfile.$N:"
9817 run_test 154c "lfs path2fid and fid2path multiple arguments"
9820 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.5.53) ]] &&
9821 skip "Need MDS version at least 2.5.53" && return
9824 nid=$($LCTL list_nids | sed "s/\./\\\./g")
9828 local proc_ofile="mdt.*.exports.'$nid'.open_files"
9835 local fid=$($LFS path2fid $DIR/$tfile)
9838 cmd="exec $fd<$DIR/$tfile"
9840 local fid_list=$(do_facet $SINGLEMDS $LCTL get_param $proc_ofile)
9841 echo "$fid_list" | grep "$fid"
9844 cmd="exec $fd>/dev/null"
9846 if [ $rc -ne 0 ]; then
9847 error "FID $fid not found in open files list $fid_list"
9850 run_test 154d "Verify open file fid"
9854 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.6.50) ]] &&
9855 skip "Need MDS version at least 2.6.50" && return
9857 if ls -a $MOUNT | grep -q '^\.lustre$'; then
9858 error ".lustre returned by readdir"
9861 run_test 154e ".lustre is not returned by readdir"
9864 # create parent directory on a single MDT to avoid cross-MDT hardlinks
9865 test_mkdir -p -c1 $DIR/$tdir/d
9866 # test dirs inherit from its stripe
9867 mkdir -p $DIR/$tdir/d/foo1 || error "mkdir error"
9868 mkdir -p $DIR/$tdir/d/foo2 || error "mkdir error"
9869 cp /etc/hosts $DIR/$tdir/d/foo1/$tfile
9870 ln $DIR/$tdir/d/foo1/$tfile $DIR/$tdir/d/foo2/link
9873 # get fid of parents
9874 local FID0=$($LFS path2fid $DIR/$tdir/d)
9875 local FID1=$($LFS path2fid $DIR/$tdir/d/foo1)
9876 local FID2=$($LFS path2fid $DIR/$tdir/d/foo2)
9877 local FID3=$($LFS path2fid $DIR)
9879 # check that path2fid --parents returns expected <parent_fid>/name
9880 # 1) test for a directory (single parent)
9881 local parent=$($LFS path2fid --parents $DIR/$tdir/d/foo1)
9882 [ "$parent" == "$FID0/foo1" ] ||
9883 error "expected parent: $FID0/foo1, got: $parent"
9885 # 2) test for a file with nlink > 1 (multiple parents)
9886 parent=$($LFS path2fid --parents $DIR/$tdir/d/foo1/$tfile)
9887 echo "$parent" | grep -F "$FID1/$tfile" ||
9888 error "$FID1/$tfile not returned in parent list"
9889 echo "$parent" | grep -F "$FID2/link" ||
9890 error "$FID2/link not returned in parent list"
9892 # 3) get parent by fid
9893 local file_fid=$($LFS path2fid $DIR/$tdir/d/foo1/$tfile)
9894 parent=$($LFS path2fid --parents $MOUNT/.lustre/fid/$file_fid)
9895 echo "$parent" | grep -F "$FID1/$tfile" ||
9896 error "$FID1/$tfile not returned in parent list (by fid)"
9897 echo "$parent" | grep -F "$FID2/link" ||
9898 error "$FID2/link not returned in parent list (by fid)"
9900 # 4) test for entry in root directory
9901 parent=$($LFS path2fid --parents $DIR/f)
9902 echo "$parent" | grep -F "$FID3/f" ||
9903 error "$FID3/f not returned in parent list"
9905 # 5) test it on root directory
9906 [ -z "$($LFS path2fid --parents $MOUNT 2>/dev/null)" ] ||
9907 error "$MOUNT should not have parents"
9909 # enable xattr caching and check that linkea is correctly updated
9910 local save="$TMP/$TESTSUITE-$TESTNAME.parameters"
9911 save_lustre_params client "llite.*.xattr_cache" > $save
9912 lctl set_param llite.*.xattr_cache 1
9914 # 6.1) linkea update on rename
9915 mv $DIR/$tdir/d/foo1/$tfile $DIR/$tdir/d/foo2/$tfile.moved
9917 # get parents by fid
9918 parent=$($LFS path2fid --parents $MOUNT/.lustre/fid/$file_fid)
9919 # foo1 should no longer be returned in parent list
9920 echo "$parent" | grep -F "$FID1" &&
9921 error "$FID1 should no longer be in parent list"
9922 # the new path should appear
9923 echo "$parent" | grep -F "$FID2/$tfile.moved" ||
9924 error "$FID2/$tfile.moved is not in parent list"
9926 # 6.2) linkea update on unlink
9927 rm -f $DIR/$tdir/d/foo2/link
9928 parent=$($LFS path2fid --parents $MOUNT/.lustre/fid/$file_fid)
9929 # foo2/link should no longer be returned in parent list
9930 echo "$parent" | grep -F "$FID2/link" &&
9931 error "$FID2/link should no longer be in parent list"
9935 restore_lustre_params < $save
9937 run_test 154f "get parent fids by reading link ea"
9941 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.6.92) ]] ||
9942 { skip "Need MDS version at least 2.6.92"; return 0; }
9945 llapi_fid_test -d $DIR/$tdir
9947 run_test 154g "various llapi FID tests"
9949 test_155_small_load() {
9950 local temp=$TMP/$tfile
9951 local file=$DIR/$tfile
9953 dd if=/dev/urandom of=$temp bs=6096 count=1 || \
9954 error "dd of=$temp bs=6096 count=1 failed"
9956 cancel_lru_locks osc
9957 cmp $temp $file || error "$temp $file differ"
9959 $TRUNCATE $temp 6000
9960 $TRUNCATE $file 6000
9961 cmp $temp $file || error "$temp $file differ (truncate1)"
9963 echo "12345" >>$temp
9964 echo "12345" >>$file
9965 cmp $temp $file || error "$temp $file differ (append1)"
9967 echo "12345" >>$temp
9968 echo "12345" >>$file
9969 cmp $temp $file || error "$temp $file differ (append2)"
9975 test_155_big_load() {
9976 remote_ost_nodsh && skip "remote OST with nodsh" && return
9977 local temp=$TMP/$tfile
9978 local file=$DIR/$tfile
9981 local cache_size=$(do_facet ost$((MAXI+1)) \
9982 "awk '/cache/ {sum+=\\\$4} END {print sum}' /proc/cpuinfo")
9983 local large_file_size=$((cache_size * 2))
9985 echo "OSS cache size: $cache_size KB"
9986 echo "Large file size: $large_file_size KB"
9988 [ $MAXV -le $large_file_size ] && \
9989 skip_env "max available OST size needs > $large_file_size KB" && \
9992 $SETSTRIPE $file -c 1 -i $MAXI || error "$SETSTRIPE $file failed"
9994 dd if=/dev/urandom of=$temp bs=$large_file_size count=1k || \
9995 error "dd of=$temp bs=$large_file_size count=1k failed"
9998 cancel_lru_locks osc
9999 cmp $temp $file || error "$temp $file differ"
10006 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10008 set_cache writethrough on
10009 test_155_small_load
10011 run_test 155a "Verify small file correctness: read cache:on write_cache:on"
10014 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10016 set_cache writethrough off
10017 test_155_small_load
10019 run_test 155b "Verify small file correctness: read cache:on write_cache:off"
10022 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10024 set_cache writethrough on
10025 test_155_small_load
10027 run_test 155c "Verify small file correctness: read cache:off write_cache:on"
10030 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10032 set_cache writethrough off
10033 test_155_small_load
10035 run_test 155d "Verify small file correctness: read cache:off write_cache:off"
10038 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10040 set_cache writethrough on
10043 run_test 155e "Verify big file correctness: read cache:on write_cache:on"
10046 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10048 set_cache writethrough off
10051 run_test 155f "Verify big file correctness: read cache:on write_cache:off"
10054 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10056 set_cache writethrough on
10059 run_test 155g "Verify big file correctness: read cache:off write_cache:on"
10062 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10064 set_cache writethrough off
10067 run_test 155h "Verify big file correctness: read cache:off write_cache:off"
10070 remote_ost_nodsh && skip "remote OST with nodsh" && return
10071 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10075 local file="$DIR/$tfile"
10077 [ "$(facet_fstype ost1)" = "zfs" ] &&
10078 skip "LU-1956/LU-2261: stats unimplemented on OSD ZFS" &&
10083 log "Turn on read and write cache"
10085 set_cache writethrough on
10087 log "Write data and read it back."
10088 log "Read should be satisfied from the cache."
10089 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
10091 cancel_lru_locks osc
10092 cat $file >/dev/null
10094 if ! let "AFTER - BEFORE == CPAGES"; then
10095 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
10097 log "cache hits:: before: $BEFORE, after: $AFTER"
10100 log "Read again; it should be satisfied from the cache."
10102 cancel_lru_locks osc
10103 cat $file >/dev/null
10105 if ! let "AFTER - BEFORE == CPAGES"; then
10106 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
10108 log "cache hits:: before: $BEFORE, after: $AFTER"
10112 log "Turn off the read cache and turn on the write cache"
10114 set_cache writethrough on
10116 log "Read again; it should be satisfied from the cache."
10118 cancel_lru_locks osc
10119 cat $file >/dev/null
10121 if ! let "AFTER - BEFORE == CPAGES"; then
10122 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
10124 log "cache hits:: before: $BEFORE, after: $AFTER"
10127 log "Read again; it should not be satisfied from the cache."
10129 cancel_lru_locks osc
10130 cat $file >/dev/null
10132 if ! let "AFTER - BEFORE == 0"; then
10133 error "IN CACHE: before: $BEFORE, after: $AFTER"
10135 log "cache hits:: before: $BEFORE, after: $AFTER"
10138 log "Write data and read it back."
10139 log "Read should be satisfied from the cache."
10140 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
10142 cancel_lru_locks osc
10143 cat $file >/dev/null
10145 if ! let "AFTER - BEFORE == CPAGES"; then
10146 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
10148 log "cache hits:: before: $BEFORE, after: $AFTER"
10151 log "Read again; it should not be satisfied from the cache."
10153 cancel_lru_locks osc
10154 cat $file >/dev/null
10156 if ! let "AFTER - BEFORE == 0"; then
10157 error "IN CACHE: before: $BEFORE, after: $AFTER"
10159 log "cache hits:: before: $BEFORE, after: $AFTER"
10163 log "Turn off read and write cache"
10165 set_cache writethrough off
10167 log "Write data and read it back"
10168 log "It should not be satisfied from the cache."
10170 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
10171 cancel_lru_locks osc
10173 cat $file >/dev/null
10175 if ! let "AFTER - BEFORE == 0"; then
10176 error_ignore bz20762 "IN CACHE: before: $BEFORE, after: $AFTER"
10178 log "cache hits:: before: $BEFORE, after: $AFTER"
10181 log "Turn on the read cache and turn off the write cache"
10183 set_cache writethrough off
10185 log "Write data and read it back"
10186 log "It should not be satisfied from the cache."
10188 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
10190 cancel_lru_locks osc
10191 cat $file >/dev/null
10193 if ! let "AFTER - BEFORE == 0"; then
10194 error_ignore bz20762 "IN CACHE: before: $BEFORE, after: $AFTER"
10196 log "cache hits:: before: $BEFORE, after: $AFTER"
10199 log "Read again; it should be satisfied from the cache."
10201 cancel_lru_locks osc
10202 cat $file >/dev/null
10204 if ! let "AFTER - BEFORE == CPAGES"; then
10205 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
10207 log "cache hits:: before: $BEFORE, after: $AFTER"
10212 run_test 156 "Verification of tunables ============================"
10216 if [[ $MDSCOUNT -gt 1 ]]; then
10217 error_ignore bz17935 $*
10225 local CL_MASK_PARAM="mdd.$MDT0.changelog_mask"
10227 MASK=$(do_facet $SINGLEMDS $LCTL get_param $CL_MASK_PARAM| grep -c "$1")
10229 if [ $MASK -eq 1 ]; then
10230 do_facet $SINGLEMDS $LCTL set_param $CL_MASK_PARAM="-$1"
10232 do_facet $SINGLEMDS $LCTL set_param $CL_MASK_PARAM="+$1"
10236 changelog_extract_field() {
10240 local identifier=$4
10242 $LFS changelog $mdt | gawk "/$cltype.*$file$/ {
10243 print gensub(/^.* "$identifier'(\[[^\]]*\]).*$/,"\\1",1)}' |
10248 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10249 remote_mds_nodsh && skip "remote MDS with nodsh" && return
10250 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] ||
10251 { skip "Need MDS version at least 2.2.0"; return; }
10253 local CL_USERS="mdd.$MDT0.changelog_users"
10254 local GET_CL_USERS="do_facet $SINGLEMDS $LCTL get_param -n $CL_USERS"
10255 USER=$(do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_register -n)
10256 echo "Registered as changelog user $USER"
10257 $GET_CL_USERS | grep -q $USER ||
10258 error "User $USER not found in changelog_users"
10261 test_mkdir -p $DIR/$tdir/pics/2008/zachy
10262 touch $DIR/$tdir/pics/2008/zachy/timestamp
10263 cp /etc/hosts $DIR/$tdir/pics/2008/zachy/pic1.jpg
10264 mv $DIR/$tdir/pics/2008/zachy $DIR/$tdir/pics/zach
10265 ln $DIR/$tdir/pics/zach/pic1.jpg $DIR/$tdir/pics/2008/portland.jpg
10266 ln -s $DIR/$tdir/pics/2008/portland.jpg $DIR/$tdir/pics/desktop.jpg
10267 rm $DIR/$tdir/pics/desktop.jpg
10269 $LFS changelog $MDT0 | tail -5
10271 echo "verifying changelog mask"
10272 changelog_chmask "MKDIR"
10273 changelog_chmask "CLOSE"
10275 test_mkdir -p $DIR/$tdir/pics/zach/sofia
10276 echo "zzzzzz" > $DIR/$tdir/pics/zach/file
10278 changelog_chmask "MKDIR"
10279 changelog_chmask "CLOSE"
10281 test_mkdir -p $DIR/$tdir/pics/2008/sofia
10282 echo "zzzzzz" > $DIR/$tdir/pics/zach/file
10284 $LFS changelog $MDT0
10285 MKDIRS=$($LFS changelog $MDT0 | tail -5 | grep -c "MKDIR")
10286 CLOSES=$($LFS changelog $MDT0 | tail -5 | grep -c "CLOSE")
10287 [ $MKDIRS -eq 1 ] || err17935 "MKDIR changelog mask count $DIRS != 1"
10288 [ $CLOSES -eq 1 ] || err17935 "CLOSE changelog mask count $DIRS != 1"
10291 echo "verifying target fid"
10292 fidc=$(changelog_extract_field $MDT0 "CREAT" "timestamp" "t=")
10293 fidf=$($LFS path2fid $DIR/$tdir/pics/zach/timestamp)
10294 [ "$fidc" == "$fidf" ] ||
10295 err17935 "fid in changelog $fidc != file fid $fidf"
10296 echo "verifying parent fid"
10297 fidc=$(changelog_extract_field $MDT0 "CREAT" "timestamp" "p=")
10298 fidf=$($LFS path2fid $DIR/$tdir/pics/zach)
10299 [ "$fidc" == "$fidf" ] ||
10300 err17935 "pfid in changelog $fidc != dir fid $fidf"
10302 USER_REC1=$($GET_CL_USERS | awk "\$1 == \"$USER\" {print \$2}")
10303 $LFS changelog_clear $MDT0 $USER $(($USER_REC1 + 5))
10304 USER_REC2=$($GET_CL_USERS | awk "\$1 == \"$USER\" {print \$2}")
10305 echo "verifying user clear: $(( $USER_REC1 + 5 )) == $USER_REC2"
10306 [ $USER_REC2 == $(($USER_REC1 + 5)) ] ||
10307 err17935 "user index expected $(($USER_REC1 + 5)) is $USER_REC2"
10309 MIN_REC=$($GET_CL_USERS |
10310 awk 'min == "" || $2 < min {min = $2}; END {print min}')
10311 FIRST_REC=$($LFS changelog $MDT0 | head -n1 | awk '{print $1}')
10312 echo "verifying min purge: $(( $MIN_REC + 1 )) == $FIRST_REC"
10313 [ $FIRST_REC == $(($MIN_REC + 1)) ] ||
10314 err17935 "first index should be $(($MIN_REC + 1)) is $FIRST_REC"
10316 # LU-3446 changelog index reset on MDT restart
10317 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
10318 CUR_REC1=$($GET_CL_USERS | head -n1 | cut -f3 -d' ')
10319 $LFS changelog_clear $MDT0 $USER 0
10320 stop $SINGLEMDS || error "Fail to stop MDT."
10321 start $SINGLEMDS $MDT_DEV $MDS_MOUNT_OPTS || error "Fail to start MDT."
10322 CUR_REC2=$($GET_CL_USERS | head -n1 | cut -f3 -d' ')
10323 echo "verifying index survives MDT restart: $CUR_REC1 == $CUR_REC2"
10324 [ $CUR_REC1 == $CUR_REC2 ] ||
10325 err17935 "current index should be $CUR_REC1 is $CUR_REC2"
10327 echo "verifying user deregister"
10328 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister $USER
10329 $GET_CL_USERS | grep -q $USER &&
10330 error "User $USER still in changelog_users"
10332 USERS=$(( $($GET_CL_USERS | wc -l) - 2 ))
10333 if [ $USERS -eq 0 ]; then
10334 LAST_REC1=$($GET_CL_USERS | head -n1 | cut -f3 -d' ')
10335 touch $DIR/$tdir/chloe
10336 LAST_REC2=$($GET_CL_USERS | head -n1 | cut -f3 -d' ')
10337 echo "verify changelogs are off: $LAST_REC1 == $LAST_REC2"
10338 [ $LAST_REC1 == $LAST_REC2 ] || error "changelogs not off"
10340 echo "$USERS other changelog users; can't verify off"
10343 run_test 160a "changelog sanity"
10345 test_160b() { # LU-3587
10346 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10347 remote_mds_nodsh && skip "remote MDS with nodsh" && return
10348 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] ||
10349 { skip "Need MDS version at least 2.2.0"; return; }
10351 local CL_USERS="mdd.$MDT0.changelog_users"
10352 local GET_CL_USERS="do_facet $SINGLEMDS $LCTL get_param -n $CL_USERS"
10353 USER=$(do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_register -n)
10354 echo "Registered as changelog user $USER"
10355 $GET_CL_USERS | grep -q $USER ||
10356 error "User $USER not found in changelog_users"
10358 local LONGNAME1=$(str_repeat a 255)
10359 local LONGNAME2=$(str_repeat b 255)
10362 echo "creating very long named file"
10363 touch $LONGNAME1 || error "create of $LONGNAME1 failed"
10364 echo "moving very long named file"
10365 mv $LONGNAME1 $LONGNAME2
10367 $LFS changelog $MDT0 | grep RENME
10369 echo "deregistering $USER"
10370 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister $USER
10374 run_test 160b "Verify that very long rename doesn't crash in changelog"
10378 local server_version=$(lustre_version_code $SINGLEMDS)
10380 [[ $server_version -gt $(version_code 2.5.57) ]] ||
10381 [[ $server_version -gt $(version_code 2.5.1) &&
10382 $server_version -lt $(version_code 2.5.50) ]] ||
10383 { skip "Need MDS version at least 2.5.58 or 2.5.2+"; return; }
10384 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10386 # Registration step
10387 local USER=$(do_facet $SINGLEMDS $LCTL --device $MDT0 \
10388 changelog_register -n)
10391 mkdir -p $DIR/$tdir
10392 $MCREATE $DIR/$tdir/foo_160c
10393 changelog_chmask "TRUNC"
10394 $TRUNCATE $DIR/$tdir/foo_160c 200
10395 changelog_chmask "TRUNC"
10396 $TRUNCATE $DIR/$tdir/foo_160c 199
10397 $LFS changelog $MDT0
10398 TRUNCS=$($LFS changelog $MDT0 | tail -5 | grep -c "TRUNC")
10399 [ $TRUNCS -eq 1 ] || err17935 "TRUNC changelog mask count $TRUNCS != 1"
10400 $LFS changelog_clear $MDT0 $USER 0
10402 # Deregistration step
10403 echo "deregistering $USER"
10404 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister $USER
10406 run_test 160c "verify that changelog log catch the truncate event"
10409 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10410 test_mkdir -p -c1 $DIR/$tdir
10411 cp /etc/hosts $DIR/$tdir/$tfile
10412 test_mkdir -c1 $DIR/$tdir/foo1
10413 test_mkdir -c1 $DIR/$tdir/foo2
10414 ln $DIR/$tdir/$tfile $DIR/$tdir/foo1/sofia
10415 ln $DIR/$tdir/$tfile $DIR/$tdir/foo2/zachary
10416 ln $DIR/$tdir/$tfile $DIR/$tdir/foo1/luna
10417 ln $DIR/$tdir/$tfile $DIR/$tdir/foo2/thor
10418 local FID=$($LFS path2fid $DIR/$tdir/$tfile | tr -d '[]')
10419 if [ "$($LFS fid2path $DIR $FID | wc -l)" != "5" ]; then
10420 $LFS fid2path $DIR $FID
10421 err17935 "bad link ea"
10424 rm $DIR/$tdir/foo2/zachary
10426 rm $DIR/$tdir/foo2/thor
10428 rm $DIR/$tdir/$tfile
10430 mv $DIR/$tdir/foo1/sofia $DIR/$tdir/foo2/maggie
10431 if [ "$($LFS fid2path $FSNAME --link 1 $FID)" != "$tdir/foo2/maggie" ]
10433 $LFS fid2path $DIR $FID
10434 err17935 "bad link rename"
10436 rm $DIR/$tdir/foo2/maggie
10439 local longname=filename_avg_len_is_thirty_two_
10440 createmany -l$DIR/$tdir/foo1/luna $DIR/$tdir/foo2/$longname 1000 ||
10441 error "failed to hardlink many files"
10442 links=$($LFS fid2path $DIR $FID | wc -l)
10443 echo -n "${links}/1000 links in link EA"
10444 [[ $links -gt 60 ]] ||
10445 err17935 "expected at least 60 links in link EA"
10446 unlinkmany $DIR/$tdir/foo2/$longname 1000 ||
10447 error "failed to unlink many hardlinks"
10449 run_test 161a "link ea sanity"
10452 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10453 [ $MDSCOUNT -lt 2 ] &&
10454 skip "skipping remote directory test" && return
10456 local remote_dir=$DIR/$tdir/remote_dir
10458 mkdir -p $DIR/$tdir
10459 $LFS mkdir -i $MDTIDX $remote_dir ||
10460 error "create remote directory failed"
10462 cp /etc/hosts $remote_dir/$tfile
10463 mkdir -p $remote_dir/foo1
10464 mkdir -p $remote_dir/foo2
10465 ln $remote_dir/$tfile $remote_dir/foo1/sofia
10466 ln $remote_dir/$tfile $remote_dir/foo2/zachary
10467 ln $remote_dir/$tfile $remote_dir/foo1/luna
10468 ln $remote_dir/$tfile $remote_dir/foo2/thor
10470 local FID=$($LFS path2fid $remote_dir/$tfile | tr -d '[' |
10472 if [ "$($LFS fid2path $DIR $FID | wc -l)" != "5" ]; then
10473 $LFS fid2path $DIR $FID
10474 err17935 "bad link ea"
10477 rm $remote_dir/foo2/zachary
10479 rm $remote_dir/foo2/thor
10481 rm $remote_dir/$tfile
10483 mv $remote_dir/foo1/sofia $remote_dir/foo2/maggie
10484 local link_path=$($LFS fid2path $FSNAME --link 1 $FID)
10485 if [ "$DIR/$link_path" != "$remote_dir/foo2/maggie" ]; then
10486 $LFS fid2path $DIR $FID
10487 err17935 "bad link rename"
10489 rm $remote_dir/foo2/maggie
10492 local longname=filename_avg_len_is_thirty_two_
10493 createmany -l$remote_dir/foo1/luna $remote_dir/foo2/$longname 1000 ||
10494 error "failed to hardlink many files"
10495 links=$($LFS fid2path $DIR $FID | wc -l)
10496 echo -n "${links}/1000 links in link EA"
10497 [[ ${links} -gt 60 ]] ||
10498 err17935 "expected at least 60 links in link EA"
10499 unlinkmany $remote_dir/foo2/$longname 1000 ||
10500 error "failed to unlink many hardlinks"
10502 run_test 161b "link ea sanity under remote directory"
10505 remote_mds_nodsh && skip "remote MDS with nodsh" && return
10506 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10507 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.1.5) ]] &&
10508 skip "Need MDS version at least 2.1.5" && return
10510 # define CLF_RENAME_LAST 0x0001
10511 # rename overwrite a target having nlink = 1 (changelog flag 0x1)
10512 local USER=$(do_facet $SINGLEMDS $LCTL --device $MDT0 \
10513 changelog_register -n)
10515 mkdir -p $DIR/$tdir
10516 touch $DIR/$tdir/foo_161c
10517 touch $DIR/$tdir/bar_161c
10518 mv -f $DIR/$tdir/foo_161c $DIR/$tdir/bar_161c
10519 $LFS changelog $MDT0 | grep RENME
10520 local flags=$($LFS changelog $MDT0 | grep RENME | tail -1 | \
10522 $LFS changelog_clear $MDT0 $USER 0
10523 if [ x$flags != "x0x1" ]; then
10524 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister \
10526 error "flag $flags is not 0x1"
10528 echo "rename overwrite a target having nlink = 1," \
10529 "changelog record has flags of $flags"
10531 # rename overwrite a target having nlink > 1 (changelog flag 0x0)
10532 touch $DIR/$tdir/foo_161c
10533 touch $DIR/$tdir/bar_161c
10534 ln $DIR/$tdir/bar_161c $DIR/$tdir/foobar_161c
10535 mv -f $DIR/$tdir/foo_161c $DIR/$tdir/bar_161c
10536 $LFS changelog $MDT0 | grep RENME
10537 flags=$($LFS changelog $MDT0 | grep RENME | tail -1 | cut -f5 -d' ')
10538 $LFS changelog_clear $MDT0 $USER 0
10539 if [ x$flags != "x0x0" ]; then
10540 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister \
10542 error "flag $flags is not 0x0"
10544 echo "rename overwrite a target having nlink > 1," \
10545 "changelog record has flags of $flags"
10547 # rename doesn't overwrite a target (changelog flag 0x0)
10548 touch $DIR/$tdir/foo_161c
10549 mv -f $DIR/$tdir/foo_161c $DIR/$tdir/foo2_161c
10550 $LFS changelog $MDT0 | grep RENME
10551 flags=$($LFS changelog $MDT0 | grep RENME | tail -1 | cut -f5 -d' ')
10552 $LFS changelog_clear $MDT0 $USER 0
10553 if [ x$flags != "x0x0" ]; then
10554 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister \
10556 error "flag $flags is not 0x0"
10558 echo "rename doesn't overwrite a target," \
10559 "changelog record has flags of $flags"
10561 # define CLF_UNLINK_LAST 0x0001
10562 # unlink a file having nlink = 1 (changelog flag 0x1)
10563 rm -f $DIR/$tdir/foo2_161c
10564 $LFS changelog $MDT0 | grep UNLNK
10565 flags=$($LFS changelog $MDT0 | grep UNLNK | tail -1 | cut -f5 -d' ')
10566 $LFS changelog_clear $MDT0 $USER 0
10567 if [ x$flags != "x0x1" ]; then
10568 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister \
10570 error "flag $flags is not 0x1"
10572 echo "unlink a file having nlink = 1," \
10573 "changelog record has flags of $flags"
10575 # unlink a file having nlink > 1 (changelog flag 0x0)
10576 ln -f $DIR/$tdir/bar_161c $DIR/$tdir/foobar_161c
10577 rm -f $DIR/$tdir/foobar_161c
10578 $LFS changelog $MDT0 | grep UNLNK
10579 flags=$($LFS changelog $MDT0 | grep UNLNK | tail -1 | cut -f5 -d' ')
10580 $LFS changelog_clear $MDT0 $USER 0
10581 if [ x$flags != "x0x0" ]; then
10582 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister \
10584 error "flag $flags is not 0x0"
10586 echo "unlink a file having nlink > 1," \
10587 "changelog record has flags of $flags"
10588 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister $USER
10590 run_test 161c "check CL_RENME[UNLINK] changelog record flags"
10597 local path=$(${LFS} fid2path $*)
10598 # Remove the '//' indicating a remote directory
10599 path=$(echo $path | sed 's#//#/#g')
10602 if [ $RC -ne 0 ]; then
10603 err17935 "path looked up of $expected failed. Error $RC"
10605 elif [ "${path}" != "${expected}" ]; then
10606 err17935 "path looked up \"${path}\" instead of \"${expected}\""
10609 echo "fid $fid resolves to path $path (expected $expected)"
10613 # Make changes to filesystem
10614 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10615 test_mkdir -p -c1 $DIR/$tdir/d2
10616 touch $DIR/$tdir/d2/$tfile
10617 touch $DIR/$tdir/d2/x1
10618 touch $DIR/$tdir/d2/x2
10619 test_mkdir -p -c1 $DIR/$tdir/d2/a/b/c
10620 test_mkdir -p -c1 $DIR/$tdir/d2/p/q/r
10622 FID=$($LFS path2fid $DIR/$tdir/d2/$tfile | tr -d '[]')
10623 check_path "$tdir/d2/$tfile" $FSNAME $FID --link 0 ||
10624 error "check path $tdir/d2/$tfile failed"
10627 ln -s $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/p/q/r/slink
10628 FID=$($LFS path2fid $DIR/$tdir/d2/p/q/r/slink | tr -d '[]')
10629 check_path "$tdir/d2/p/q/r/slink" $FSNAME $FID --link 0 ||
10630 error "check path $tdir/d2/p/q/r/slink failed"
10632 # softlink to wrong file
10633 ln -s /this/is/garbage $DIR/$tdir/d2/p/q/r/slink.wrong
10634 FID=$($LFS path2fid $DIR/$tdir/d2/p/q/r/slink.wrong | tr -d '[]')
10635 check_path "$tdir/d2/p/q/r/slink.wrong" $FSNAME $FID --link 0 ||
10636 error "check path $tdir/d2/p/q/r/slink.wrong failed"
10639 ln $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/p/q/r/hlink
10640 mv $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/a/b/c/new_file
10641 FID=$($LFS path2fid $DIR/$tdir/d2/a/b/c/new_file | tr -d '[]')
10642 # fid2path dir/fsname should both work
10643 check_path "$tdir/d2/a/b/c/new_file" $FSNAME $FID --link 1 ||
10644 error "check path $tdir/d2/a/b/c/new_file failed"
10645 check_path "$DIR/$tdir/d2/p/q/r/hlink" $DIR $FID --link 0 ||
10646 error "check path $DIR/$tdir/d2/p/q/r/hlink failed"
10648 # hardlink count: check that there are 2 links
10649 # Doesnt work with CMD yet: 17935
10650 ${LFS} fid2path $DIR $FID | wc -l | grep -q 2 || \
10651 err17935 "expected 2 links"
10653 # hardlink indexing: remove the first link
10654 rm $DIR/$tdir/d2/p/q/r/hlink
10655 check_path "$tdir/d2/a/b/c/new_file" $FSNAME $FID --link 0 ||
10656 error "check path $DIR/$tdir/d2/a/b/c/new_file failed"
10660 run_test 162 "path lookup sanity"
10663 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10664 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
10667 $LFS setdirstripe -i0 -c$MDSCOUNT -t all_char $DIR/$tdir/striped_dir ||
10668 error "create striped dir failed"
10670 local FID=$($LFS getdirstripe $DIR/$tdir/striped_dir |
10671 tail -n 1 | awk '{print $2}')
10672 stat $MOUNT/.lustre/fid/$FID && error "sub_stripe can be accessed"
10674 touch $DIR/$tdir/striped_dir/f{0..4} || error "touch f0..4 failed"
10675 mkdir $DIR/$tdir/striped_dir/d{0..4} || error "mkdir d0..4 failed"
10678 for ((i=0;i<5;i++)); do
10679 FID=$($LFS path2fid $DIR/$tdir/striped_dir/f$i | tr -d '[]') ||
10680 error "get fid for f$i failed"
10681 check_path "$tdir/striped_dir/f$i" $FSNAME $FID --link 0 ||
10682 error "check path $tdir/striped_dir/f$i failed"
10684 FID=$($LFS path2fid $DIR/$tdir/striped_dir/d$i | tr -d '[]') ||
10685 error "get fid for d$i failed"
10686 check_path "$tdir/striped_dir/d$i" $FSNAME $FID --link 0 ||
10687 error "check path $tdir/striped_dir/d$i failed"
10692 run_test 162b "striped directory path lookup sanity"
10694 # LU-4239: Verify fid2path works with paths 100 or more directories deep
10696 test_mkdir $DIR/$tdir.local
10697 test_mkdir $DIR/$tdir.remote
10698 local lpath=$tdir.local
10699 local rpath=$tdir.remote
10701 for ((i = 0; i <= 101; i++)); do
10704 FID=$($LFS path2fid $DIR/$lpath | tr -d '[]') ||
10705 error "get fid for local directory $DIR/$lpath failed"
10706 check_path "$DIR/$lpath" $MOUNT $FID --link 0 ||
10707 error "check path for local directory $DIR/$lpath failed"
10710 test_mkdir $DIR/$rpath
10711 FID=$($LFS path2fid $DIR/$rpath | tr -d '[]') ||
10712 error "get fid for remote directory $DIR/$rpath failed"
10713 check_path "$DIR/$rpath" $MOUNT $FID --link 0 ||
10714 error "check path for remote directory $DIR/$rpath failed"
10719 run_test 162c "fid2path works with paths 100 or more directories deep"
10722 # do directio so as not to populate the page cache
10723 log "creating a 10 Mb file"
10724 $MULTIOP $DIR/$tfile oO_CREAT:O_DIRECT:O_RDWR:w$((10*1048576))c || error "multiop failed while creating a file"
10725 log "starting reads"
10726 dd if=$DIR/$tfile of=/dev/null bs=4096 &
10727 log "truncating the file"
10728 $MULTIOP $DIR/$tfile oO_TRUNC:c || error "multiop failed while truncating the file"
10730 kill %+ || true # reads might have finished
10731 echo "wait until dd is finished"
10733 log "removing the temporary file"
10734 rm -rf $DIR/$tfile || error "tmp file removal failed"
10736 run_test 169 "parallel read and truncate should not deadlock"
10739 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10740 $LCTL clear # bug 18514
10741 $LCTL debug_daemon start $TMP/${tfile}_log_good
10743 $LCTL debug_daemon stop
10744 sed -e "s/^...../a/g" $TMP/${tfile}_log_good > $TMP/${tfile}_log_bad ||
10745 error "sed failed to read log_good"
10747 $LCTL debug_daemon start $TMP/${tfile}_log_good
10749 $LCTL debug_daemon stop
10751 $LCTL df $TMP/${tfile}_log_bad > $TMP/${tfile}_log_bad.out 2>&1 ||
10752 error "lctl df log_bad failed"
10754 local bad_line=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $9}')
10755 local good_line1=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $5}')
10757 $LCTL df $TMP/${tfile}_log_good > $TMP/${tfile}_log_good.out 2>&1
10758 local good_line2=$(tail -n 1 $TMP/${tfile}_log_good.out | awk '{print $5}')
10760 [ "$bad_line" ] && [ "$good_line1" ] && [ "$good_line2" ] ||
10761 error "bad_line good_line1 good_line2 are empty"
10763 cat $TMP/${tfile}_log_good >> $TMP/${tfile}_logs_corrupt
10764 cat $TMP/${tfile}_log_bad >> $TMP/${tfile}_logs_corrupt
10765 cat $TMP/${tfile}_log_good >> $TMP/${tfile}_logs_corrupt
10767 $LCTL df $TMP/${tfile}_logs_corrupt > $TMP/${tfile}_log_bad.out 2>&1
10768 local bad_line_new=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $9}')
10769 local good_line_new=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $5}')
10771 [ "$bad_line_new" ] && [ "$good_line_new" ] ||
10772 error "bad_line_new good_line_new are empty"
10774 local expected_good=$((good_line1 + good_line2*2))
10776 rm -f $TMP/${tfile}*
10777 # LU-231, short malformed line may not be counted into bad lines
10778 if [ $bad_line -ne $bad_line_new ] &&
10779 [ $bad_line -ne $((bad_line_new - 1)) ]; then
10780 error "expected $bad_line bad lines, but got $bad_line_new"
10784 if [ $expected_good -ne $good_line_new ]; then
10785 error "expected $expected_good good lines, but got $good_line_new"
10790 run_test 170 "test lctl df to handle corrupted log ====================="
10792 test_171() { # bug20592
10793 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10794 #define OBD_FAIL_PTLRPC_DUMP_LOG 0x50e
10795 $LCTL set_param fail_loc=0x50e
10796 $LCTL set_param fail_val=3000
10797 multiop_bg_pause $DIR/$tfile O_s || true
10799 kill -USR1 $MULTIPID
10803 if dmesg | grep "recursive fault"; then
10804 error "caught a recursive fault"
10806 $LCTL set_param fail_loc=0
10809 run_test 171 "test libcfs_debug_dumplog_thread stuck in do_exit() ======"
10811 # it would be good to share it with obdfilter-survey/iokit-libecho code
10812 setup_obdecho_osc () {
10815 local obdfilter_name=$2
10816 echo "Creating new osc for $obdfilter_name on $ost_nid"
10817 # make sure we can find loopback nid
10818 $LCTL add_uuid $ost_nid $ost_nid >/dev/null 2>&1
10820 [ $rc -eq 0 ] && { $LCTL attach osc ${obdfilter_name}_osc \
10821 ${obdfilter_name}_osc_UUID || rc=2; }
10822 [ $rc -eq 0 ] && { $LCTL --device ${obdfilter_name}_osc setup \
10823 ${obdfilter_name}_UUID $ost_nid || rc=3; }
10827 cleanup_obdecho_osc () {
10828 local obdfilter_name=$1
10829 $LCTL --device ${obdfilter_name}_osc cleanup >/dev/null
10830 $LCTL --device ${obdfilter_name}_osc detach >/dev/null
10837 local pages=${3:-64}
10842 local obd_size=$(get_obd_size $node $OBD)
10843 local page_size=$(get_page_size $node)
10844 if [[ -n "$obd_size" ]]; then
10845 local new_count=$((obd_size / (pages * page_size / 1024)))
10846 [[ $new_count -ge $count ]] || count=$new_count
10849 do_facet $node "$LCTL attach echo_client ec ec_uuid" || rc=1
10850 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec setup $OBD" ||
10852 if [ $rc -eq 0 ]; then
10853 id=$(do_facet $node "$LCTL --device ec create 1" | awk '/object id/ {print $6}')
10854 [ ${PIPESTATUS[0]} -eq 0 -a -n "$id" ] || rc=3
10856 echo "New object id is $id"
10857 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec getattr $id" ||
10859 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec " \
10860 "test_brw $count w v $pages $id" || rc=4; }
10861 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec destroy $id 1" ||
10863 [ $rc -eq 0 -o $rc -gt 2 ] && { do_facet $node "$LCTL --device ec " \
10864 "cleanup" || rc=5; }
10865 [ $rc -eq 0 -o $rc -gt 1 ] && { do_facet $node "$LCTL --device ec " \
10866 "detach" || rc=6; }
10867 [ $rc -ne 0 ] && echo "obecho_create_test failed: $rc"
10872 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10873 remote_ost_nodsh && skip "remote OST with nodsh" && return
10875 local rmmod_local=0
10877 if ! module_loaded obdecho; then
10878 load_module obdecho/obdecho
10882 local osc=$($LCTL dl | grep -v mdt | awk '$3 == "osc" {print $4; exit}')
10883 local host=$(lctl get_param -n osc.$osc.import |
10884 awk '/current_connection:/ {print $2}' )
10885 local target=$(lctl get_param -n osc.$osc.import |
10886 awk '/target:/ {print $2}' )
10887 target=${target%_UUID}
10889 [[ -n $target ]] && { setup_obdecho_osc $host $target || rc=1; } || rc=1
10890 [ $rc -eq 0 ] && { obdecho_test ${target}_osc client || rc=2; }
10891 [[ -n $target ]] && cleanup_obdecho_osc $target
10892 [ $rmmod_local -eq 1 ] && rmmod obdecho
10895 run_test 180a "test obdecho on osc"
10898 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10899 remote_ost_nodsh && skip "remote OST with nodsh" && return
10901 local rmmod_remote=0
10903 do_facet ost1 "lsmod | grep -q obdecho || " \
10904 "{ insmod ${LUSTRE}/obdecho/obdecho.ko || " \
10905 "modprobe obdecho; }" && rmmod_remote=1
10906 target=$(do_facet ost1 $LCTL dl | awk '/obdfilter/ {print $4;exit}')
10907 [[ -n $target ]] && { obdecho_test $target ost1 || rc=1; }
10908 [ $rmmod_remote -eq 1 ] && do_facet ost1 "rmmod obdecho"
10911 run_test 180b "test obdecho directly on obdfilter"
10913 test_180c() { # LU-2598
10914 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10915 remote_ost_nodsh && skip "remote OST with nodsh" && return
10916 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.0) ]] &&
10917 skip "Need MDS version at least 2.4.0" && return
10920 local rmmod_remote=false
10921 local pages=16384 # 64MB bulk I/O RPC size
10924 do_rpc_nodes $(facet_active_host ost1) load_module obdecho/obdecho &&
10925 rmmod_remote=true || error "failed to load module obdecho"
10927 target=$(do_facet ost1 $LCTL dl | awk '/obdfilter/ { print $4 }' |
10929 if [ -n "$target" ]; then
10930 obdecho_test "$target" ost1 "$pages" || rc=${PIPESTATUS[0]}
10932 echo "there is no obdfilter target on ost1"
10935 $rmmod_remote && do_facet ost1 "rmmod obdecho" || true
10938 run_test 180c "test huge bulk I/O size on obdfilter, don't LASSERT"
10940 test_181() { # bug 22177
10941 test_mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
10942 # create enough files to index the directory
10943 createmany -o $DIR/$tdir/foobar 4000
10944 # print attributes for debug purpose
10947 multiop_bg_pause $DIR/$tdir D_Sc || return 1
10949 # remove the files & current working dir
10950 unlinkmany $DIR/$tdir/foobar 4000
10952 kill -USR1 $MULTIPID
10954 stat $DIR/$tdir && error "open-unlinked dir was not removed!"
10957 run_test 181 "Test open-unlinked dir ========================"
10960 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10961 # disable MDC RPC lock wouldn't crash client
10965 mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
10966 #define OBD_FAIL_MDC_RPCS_SEM 0x804
10967 $LCTL set_param fail_loc=0x804
10969 for (( i=0; i < $tcount; i++ )) ; do
10970 mkdir $DIR/$tdir/$i
10971 createmany -o $DIR/$tdir/$i/f- $fcount &
10975 for (( i=0; i < $tcount; i++ )) ; do
10976 unlinkmany $DIR/$tdir/$i/f- $fcount &
10982 $LCTL set_param fail_loc=0
10984 run_test 182 "Disable MDC RPCs semaphore wouldn't crash client ================"
10986 test_183() { # LU-2275
10987 remote_mds_nodsh && skip "remote MDS with nodsh" && return
10988 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.3.56) ]] &&
10989 skip "Need MDS version at least 2.3.56" && return
10991 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10992 mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
10993 echo aaa > $DIR/$tdir/$tfile
10995 #define OBD_FAIL_MDS_NEGATIVE_POSITIVE 0x148
10996 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x148
10998 ls -l $DIR/$tdir && error "ls succeeded, should have failed"
10999 cat $DIR/$tdir/$tfile && error "cat succeeded, should have failed"
11001 do_facet $SINGLEMDS $LCTL set_param fail_loc=0
11003 # Flush negative dentry cache
11004 touch $DIR/$tdir/$tfile
11006 # We are not checking for any leaked references here, they'll
11007 # become evident next time we do cleanup with module unload.
11010 run_test 183 "No crash or request leak in case of strange dispositions ========"
11012 # test suite 184 is for LU-2016, LU-2017
11014 check_swap_layouts_support && return 0
11016 dir0=$DIR/$tdir/$testnum
11017 test_mkdir -p -c1 $dir0 || error "creating dir $dir0"
11022 $SETSTRIPE -c1 $file1
11024 $SETSTRIPE -c2 $file2
11026 gen1=$($GETSTRIPE -g $file1)
11027 gen2=$($GETSTRIPE -g $file2)
11029 $LFS swap_layouts $file1 $file2 || error "swap of file layout failed"
11030 gen=$($GETSTRIPE -g $file1)
11031 [[ $gen1 != $gen ]] ||
11032 "Layout generation on $file1 does not change"
11033 gen=$($GETSTRIPE -g $file2)
11034 [[ $gen2 != $gen ]] ||
11035 "Layout generation on $file2 does not change"
11037 cmp $ref1 $file2 || error "content compare failed ($ref1 != $file2)"
11038 cmp $ref2 $file1 || error "content compare failed ($ref2 != $file1)"
11040 run_test 184a "Basic layout swap"
11043 check_swap_layouts_support && return 0
11045 dir0=$DIR/$tdir/$testnum
11046 mkdir -p $dir0 || error "creating dir $dir0"
11053 $SETSTRIPE -c1 $file1
11054 $SETSTRIPE -c2 $file2
11055 $SETSTRIPE -c1 $file3
11056 chown $RUNAS_ID $file3
11057 gen1=$($GETSTRIPE -g $file1)
11058 gen2=$($GETSTRIPE -g $file2)
11060 $LFS swap_layouts $dir1 $dir2 &&
11061 error "swap of directories layouts should fail"
11062 $LFS swap_layouts $dir1 $file1 &&
11063 error "swap of directory and file layouts should fail"
11064 $RUNAS $LFS swap_layouts $file1 $file2 &&
11065 error "swap of file we cannot write should fail"
11066 $LFS swap_layouts $file1 $file3 &&
11067 error "swap of file with different owner should fail"
11068 /bin/true # to clear error code
11070 run_test 184b "Forbidden layout swap (will generate errors)"
11073 check_swap_layouts_support && return 0
11075 local dir0=$DIR/$tdir/$testnum
11076 mkdir -p $dir0 || error "creating dir $dir0"
11078 local ref1=$dir0/ref1
11079 local ref2=$dir0/ref2
11080 local file1=$dir0/file1
11081 local file2=$dir0/file2
11082 # create a file large enough for the concurrent test
11083 dd if=/dev/urandom of=$ref1 bs=1M count=$((RANDOM % 50 + 20))
11084 dd if=/dev/urandom of=$ref2 bs=1M count=$((RANDOM % 50 + 20))
11085 echo "ref file size: ref1($(stat -c %s $ref1))," \
11086 "ref2($(stat -c %s $ref2))"
11089 dd if=$ref1 of=$file1 bs=16k &
11092 # Make sure dd starts to copy file
11093 while [ ! -f $file1 ]; do sleep 0.1; done
11095 $LFS swap_layouts $file1 $file2
11098 [[ $? == 0 ]] || error "concurrent write on $file1 failed"
11099 [[ $rc == 0 ]] || error "swap of $file1 and $file2 failed"
11101 # how many bytes copied before swapping layout
11102 local copied=$(stat -c %s $file2)
11103 local remaining=$(stat -c %s $ref1)
11104 remaining=$((remaining - copied))
11105 echo "Copied $copied bytes before swapping layout..."
11107 cmp -n $copied $file1 $ref2 | grep differ &&
11108 error "Content mismatch [0, $copied) of ref2 and file1"
11109 cmp -n $copied $file2 $ref1 ||
11110 error "Content mismatch [0, $copied) of ref1 and file2"
11111 cmp -i $copied:$copied -n $remaining $file1 $ref1 ||
11112 error "Content mismatch [$copied, EOF) of ref1 and file1"
11115 rm -f $ref1 $ref2 $file1 $file2
11117 run_test 184c "Concurrent write and layout swap"
11120 check_swap_layouts_support && return 0
11121 [ -z "$(which getfattr 2>/dev/null)" ] &&
11122 skip "no getfattr command" && return 0
11124 local file1=$DIR/$tdir/$tfile-1
11125 local file2=$DIR/$tdir/$tfile-2
11126 local file3=$DIR/$tdir/$tfile-3
11130 mkdir -p $DIR/$tdir
11131 touch $file1 || error "create $file1 failed"
11132 $OPENFILE -f O_CREAT:O_LOV_DELAY_CREATE $file2 ||
11133 error "create $file2 failed"
11134 $OPENFILE -f O_CREAT:O_LOV_DELAY_CREATE $file3 ||
11135 error "create $file3 failed"
11136 lovea1=$($LFS getstripe $file1 | sed 1d)
11138 $LFS swap_layouts $file2 $file3 ||
11139 error "swap $file2 $file3 layouts failed"
11140 $LFS swap_layouts $file1 $file2 ||
11141 error "swap $file1 $file2 layouts failed"
11143 lovea2=$($LFS getstripe $file2 | sed 1d)
11144 [ "$lovea1" == "$lovea2" ] || error "lovea $lovea1 != $lovea2"
11146 lovea1=$(getfattr -n trusted.lov $file1 | grep ^trusted)
11147 [[ -z "$lovea1" ]] || error "$file1 shouldn't have lovea"
11149 run_test 184d "allow stripeless layouts swap"
11152 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.6.94) ]] ||
11153 { skip "Need MDS version at least 2.6.94"; return 0; }
11154 check_swap_layouts_support && return 0
11155 [ -z "$(which getfattr 2>/dev/null)" ] &&
11156 skip "no getfattr command" && return 0
11158 local file1=$DIR/$tdir/$tfile-1
11159 local file2=$DIR/$tdir/$tfile-2
11160 local file3=$DIR/$tdir/$tfile-3
11163 mkdir -p $DIR/$tdir
11164 touch $file1 || error "create $file1 failed"
11165 $OPENFILE -f O_CREAT:O_LOV_DELAY_CREATE $file2 ||
11166 error "create $file2 failed"
11167 $OPENFILE -f O_CREAT:O_LOV_DELAY_CREATE $file3 ||
11168 error "create $file3 failed"
11170 $LFS swap_layouts $file1 $file2 ||
11171 error "swap $file1 $file2 layouts failed"
11173 lovea=$(getfattr -n trusted.lov $file1 | grep ^trusted)
11174 [[ -z "$lovea" ]] || error "$file1 shouldn't have lovea"
11176 echo 123 > $file1 || error "Should be able to write into $file1"
11178 $LFS swap_layouts $file1 $file3 ||
11179 error "swap $file1 $file3 layouts failed"
11181 echo 123 > $file1 || error "Should be able to write into $file1"
11183 rm -rf $file1 $file2 $file3
11185 run_test 184e "Recreate layout after stripeless layout swaps"
11187 test_185() { # LU-2441
11188 # LU-3553 - no volatile file support in old servers
11189 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.3.60) ]] ||
11190 { skip "Need MDS version at least 2.3.60"; return 0; }
11192 mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
11193 touch $DIR/$tdir/spoo
11194 local mtime1=$(stat -c "%Y" $DIR/$tdir)
11195 local fid=$($MULTIOP $DIR/$tdir VFw4096c) ||
11196 error "cannot create/write a volatile file"
11197 $CHECKSTAT -t file $MOUNT/.lustre/fid/$fid 2>/dev/null &&
11198 error "FID is still valid after close"
11200 multiop_bg_pause $DIR/$tdir vVw4096_c
11207 # assume that the next FID for this client is sequential, since stdout
11208 # is unfortunately eaten by multiop_bg_pause
11209 local n=$((${fidv[1]} + 1))
11210 local next_fid="${fidv[0]}:$(printf "0x%x" $n):${fidv[2]}"
11211 $CHECKSTAT -t file $MOUNT/.lustre/fid/$next_fid ||
11212 error "FID is missing before close"
11213 kill -USR1 $multi_pid
11214 # 1 second delay, so if mtime change we will see it
11216 local mtime2=$(stat -c "%Y" $DIR/$tdir)
11217 [[ $mtime1 == $mtime2 ]] || error "mtime has changed"
11219 run_test 185 "Volatile file support"
11222 local dir0=$DIR/$tdir/$testnum
11223 mkdir -p $dir0 || error "creating dir $dir0"
11225 local file=$dir0/file1
11226 dd if=/dev/urandom of=$file count=10 bs=1M conv=fsync
11227 local dv1=$($LFS data_version $file)
11228 dd if=/dev/urandom of=$file seek=10 count=1 bs=1M conv=fsync
11229 local dv2=$($LFS data_version $file)
11230 [[ $dv1 != $dv2 ]] ||
11231 error "data version did not change on write $dv1 == $dv2"
11236 run_test 187a "Test data version change"
11239 local dir0=$DIR/$tdir/$testnum
11240 mkdir -p $dir0 || error "creating dir $dir0"
11242 declare -a DV=$($MULTIOP $dir0 Vw1000xYw1000xY | cut -f3 -d" ")
11243 [[ ${DV[0]} != ${DV[1]} ]] ||
11244 error "data version did not change on write"\
11245 " ${DV[0]} == ${DV[1]}"
11250 run_test 187b "Test data version change on volatile file"
11253 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11254 remote_mgs_nodsh && skip "remote MGS with nodsh" && return
11256 local POOL=${POOL:-cea1}
11257 local POOL_ROOT=${POOL_ROOT:-$DIR/d200.pools}
11258 local POOL_DIR_NAME=${POOL_DIR_NAME:-dir_tst}
11261 local last_ost=$(($OSTCOUNT - 1))
11263 local ost_list=$(seq $first_ost $ost_step $last_ost)
11264 local ost_range="$first_ost $last_ost $ost_step"
11265 local test_path=$POOL_ROOT/$POOL_DIR_NAME
11266 local file_dir=$POOL_ROOT/file_tst
11267 local subdir=$test_path/subdir
11271 # former test_200a test_200b
11272 pool_add $POOL || { rc=$? ; break; }
11273 pool_add_targets $POOL $ost_range || { rc=$? ; break; }
11274 # former test_200c test_200d
11275 mkdir -p $test_path
11276 pool_set_dir $POOL $test_path || { rc=$? ; break; }
11277 pool_check_dir $POOL $test_path || { rc=$? ; break; }
11279 pool_check_dir $POOL $subdir || { rc=$? ; break; }
11280 pool_dir_rel_path $POOL $POOL_DIR_NAME $POOL_ROOT \
11281 || { rc=$? ; break; }
11282 # former test_200e test_200f
11283 local files=$((OSTCOUNT*3))
11284 pool_alloc_files $POOL $test_path $files "$ost_list" \
11285 || { rc=$? ; break; }
11286 pool_create_files $POOL $file_dir $files "$ost_list" \
11287 || { rc=$? ; break; }
11288 # former test_200g test_200h
11289 pool_lfs_df $POOL || { rc=$? ; break; }
11290 pool_file_rel_path $POOL $test_path || { rc=$? ; break; }
11292 # former test_201a test_201b test_201c
11293 pool_remove_first_target $POOL || { rc=$? ; break; }
11295 local f=$test_path/$tfile
11296 pool_remove_all_targets $POOL $f || { rc=$? ; break; }
11297 pool_remove $POOL $f || { rc=$? ; break; }
11304 run_test 200 "OST pools"
11306 # usage: default_attr <count | size | offset>
11308 $LCTL get_param -n lov.$FSNAME-clilov-\*.stripe${1}
11311 # usage: check_default_stripe_attr
11312 check_default_stripe_attr() {
11313 ACTUAL=$($GETSTRIPE $* $DIR/$tdir)
11315 --stripe-count|--count)
11316 [ -n "$2" ] && EXPECTED=0 || EXPECTED=$(default_attr count);;
11317 --stripe-size|--size)
11318 [ -n "$2" ] && EXPECTED=0 || EXPECTED=$(default_attr size);;
11319 --stripe-index|--index)
11322 error "unknown getstripe attr '$1'"
11325 [ $ACTUAL != $EXPECTED ] &&
11326 error "$DIR/$tdir has $1 '$ACTUAL', not '$EXPECTED'"
11330 test_mkdir -p $DIR/$tdir
11331 $SETSTRIPE --stripe-count 0 --stripe-size 0 --stripe-index -1 $DIR/$tdir
11333 check_default_stripe_attr --stripe-count
11334 check_default_stripe_attr --stripe-size
11335 check_default_stripe_attr --stripe-index
11339 run_test 204a "Print default stripe attributes ================="
11342 test_mkdir -p $DIR/$tdir
11343 $SETSTRIPE --stripe-count 1 $DIR/$tdir
11345 check_default_stripe_attr --stripe-size
11346 check_default_stripe_attr --stripe-index
11350 run_test 204b "Print default stripe size and offset ==========="
11353 test_mkdir -p $DIR/$tdir
11354 $SETSTRIPE --stripe-size 65536 $DIR/$tdir
11356 check_default_stripe_attr --stripe-count
11357 check_default_stripe_attr --stripe-index
11361 run_test 204c "Print default stripe count and offset ==========="
11364 test_mkdir -p $DIR/$tdir
11365 $SETSTRIPE --stripe-index 0 $DIR/$tdir
11367 check_default_stripe_attr --stripe-count
11368 check_default_stripe_attr --stripe-size
11372 run_test 204d "Print default stripe count and size ============="
11375 test_mkdir -p $DIR/$tdir
11376 $SETSTRIPE -d $DIR/$tdir
11378 check_default_stripe_attr --stripe-count --raw
11379 check_default_stripe_attr --stripe-size --raw
11380 check_default_stripe_attr --stripe-index --raw
11384 run_test 204e "Print raw stripe attributes ================="
11387 test_mkdir -p $DIR/$tdir
11388 $SETSTRIPE --stripe-count 1 $DIR/$tdir
11390 check_default_stripe_attr --stripe-size --raw
11391 check_default_stripe_attr --stripe-index --raw
11395 run_test 204f "Print raw stripe size and offset ==========="
11398 test_mkdir -p $DIR/$tdir
11399 $SETSTRIPE --stripe-size 65536 $DIR/$tdir
11401 check_default_stripe_attr --stripe-count --raw
11402 check_default_stripe_attr --stripe-index --raw
11406 run_test 204g "Print raw stripe count and offset ==========="
11409 test_mkdir -p $DIR/$tdir
11410 $SETSTRIPE --stripe-index 0 $DIR/$tdir
11412 check_default_stripe_attr --stripe-count --raw
11413 check_default_stripe_attr --stripe-size --raw
11417 run_test 204h "Print raw stripe count and size ============="
11419 # Figure out which job scheduler is being used, if any,
11420 # or use a fake one
11421 if [ -n "$SLURM_JOB_ID" ]; then # SLURM
11422 JOBENV=SLURM_JOB_ID
11423 elif [ -n "$LSB_JOBID" ]; then # Load Sharing Facility
11425 elif [ -n "$PBS_JOBID" ]; then # PBS/Maui/Moab
11427 elif [ -n "$LOADL_STEPID" ]; then # LoadLeveller
11428 JOBENV=LOADL_STEP_ID
11429 elif [ -n "$JOB_ID" ]; then # Sun Grid Engine
11435 verify_jobstats() {
11439 # clear old jobstats
11440 do_facet $SINGLEMDS lctl set_param mdt.*.job_stats="clear"
11441 do_facet ost1 lctl set_param obdfilter.*.job_stats="clear"
11443 # use a new JobID for this test, or we might see an old one
11444 [ "$JOBENV" = "FAKE_JOBID" ] && FAKE_JOBID=test_id.$testnum.$RANDOM
11448 log "Using JobID environment variable $JOBENV=$JOBVAL"
11450 if [ $JOBENV = "FAKE_JOBID" ]; then
11451 FAKE_JOBID=$JOBVAL $cmd
11456 if [ "$target" = "mdt" -o "$target" = "both" ]; then
11457 FACET="$SINGLEMDS" # will need to get MDS number for DNE
11458 do_facet $FACET lctl get_param mdt.*.job_stats |
11459 grep $JOBVAL || error "No job stats found on MDT $FACET"
11461 if [ "$target" = "ost" -o "$target" = "both" ]; then
11463 do_facet $FACET lctl get_param obdfilter.*.job_stats |
11464 grep $JOBVAL || error "No job stats found on OST $FACET"
11470 NEW_JOBENV=${1:-$OLD_JOBENV}
11471 do_facet mgs $LCTL conf_param $FSNAME.sys.jobid_var=$NEW_JOBENV
11472 wait_update $HOSTNAME "$LCTL get_param -n jobid_var" $NEW_JOBENV
11475 test_205() { # Job stats
11476 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11477 remote_mgs_nodsh && skip "remote MGS with nodsh" && return
11478 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep jobstats)" ] &&
11479 skip "Server doesn't support jobstats" && return 0
11480 [[ $JOBID_VAR = disable ]] && skip "jobstats is disabled" && return
11483 OLD_JOBENV=$($LCTL get_param -n jobid_var)
11484 if [ $OLD_JOBENV != $JOBENV ]; then
11485 jobstats_set $JOBENV
11486 trap jobstats_set EXIT
11489 local user=$(do_facet $SINGLEMDS $LCTL --device $MDT0 \
11490 changelog_register -n)
11491 echo "Registered as changelog user $user"
11494 cmd="mkdir $DIR/$tfile"
11495 verify_jobstats "$cmd" "mdt"
11497 cmd="rm -fr $DIR/$tfile"
11498 verify_jobstats "$cmd" "mdt"
11500 cmd="mknod $DIR/$tfile c 1 3"
11501 verify_jobstats "$cmd" "mdt"
11503 cmd="rm -f $DIR/$tfile"
11504 verify_jobstats "$cmd" "mdt"
11506 cmd="$SETSTRIPE -i 0 -c 1 $DIR/$tfile"
11507 verify_jobstats "$cmd" "mdt"
11509 cmd="touch $DIR/$tfile"
11510 verify_jobstats "$cmd" "both"
11512 cmd="dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 oflag=sync"
11513 verify_jobstats "$cmd" "ost"
11515 cmd="dd if=$DIR/$tfile of=/dev/null bs=1M count=1 iflag=direct"
11516 verify_jobstats "$cmd" "ost"
11518 cmd="$TRUNCATE $DIR/$tfile 0"
11519 verify_jobstats "$cmd" "both"
11521 cmd="mv -f $DIR/$tfile $DIR/jobstats_test_rename"
11522 verify_jobstats "$cmd" "mdt"
11524 # Ensure that jobid are present in changelog (if supported by MDS)
11525 if [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.6.52) ]
11527 $LFS changelog $MDT0 | tail -9
11528 jobids=$($LFS changelog $MDT0 | tail -9 | grep -c "j=")
11529 [ $jobids -eq 9 ] ||
11530 error "Wrong changelog jobid count $jobids != 9"
11534 jobstats_set $JOBENV
11536 $LFS changelog $MDT0 | tail -1
11537 jobids=$($LFS changelog $MDT0 | tail -1 | grep -c "j=")
11538 [ $jobids -eq 0 ] ||
11539 error "Unexpected jobids when jobid_var=$JOBENV"
11543 rm -f $DIR/jobstats_test_rename
11545 [ $OLD_JOBENV != $JOBENV ] && jobstats_set $OLD_JOBENV
11547 run_test 205 "Verify job stats"
11549 # LU-1480, LU-1773 and LU-1657
11551 mkdir -p $DIR/$tdir
11552 $SETSTRIPE -c -1 $DIR/$tdir
11553 #define OBD_FAIL_LOV_INIT 0x1403
11554 $LCTL set_param fail_loc=0xa0001403
11555 $LCTL set_param fail_val=1
11556 touch $DIR/$tdir/$tfile || true
11558 run_test 206 "fail lov_init_raid0() doesn't lbug"
11561 dd if=/dev/zero of=$DIR/$tfile bs=4k count=$((RANDOM%10+1))
11562 local fsz=`stat -c %s $DIR/$tfile`
11563 cancel_lru_locks mdc
11565 # do not return layout in getattr intent
11566 #define OBD_FAIL_MDS_NO_LL_GETATTR 0x170
11567 $LCTL set_param fail_loc=0x170
11568 local sz=`stat -c %s $DIR/$tfile`
11570 [ $fsz -eq $sz ] || error "file size expected $fsz, actual $sz"
11574 run_test 207a "can refresh layout at glimpse"
11577 dd if=/dev/zero of=$DIR/$tfile bs=4k count=$((RANDOM%10+1))
11578 local cksum=`md5sum $DIR/$tfile`
11579 local fsz=`stat -c %s $DIR/$tfile`
11580 cancel_lru_locks mdc
11581 cancel_lru_locks osc
11583 # do not return layout in getattr intent
11584 #define OBD_FAIL_MDS_NO_LL_OPEN 0x171
11585 $LCTL set_param fail_loc=0x171
11587 # it will refresh layout after the file is opened but before read issues
11588 echo checksum is "$cksum"
11589 echo "$cksum" |md5sum -c --quiet || error "file differs"
11593 run_test 207b "can refresh layout at open"
11596 # FIXME: in this test suite, only RD lease is used. This is okay
11597 # for now as only exclusive open is supported. After generic lease
11598 # is done, this test suite should be revised. - Jinshan
11600 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.4.52) ]] ||
11601 { skip "Need MDS version at least 2.4.52"; return 0; }
11602 remote_mds_nodsh && skip "remote MDS with nodsh" && return
11604 echo "==== test 1: verify get lease work"
11605 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:eRE+eU || error "get lease error"
11607 echo "==== test 2: verify lease can be broken by upcoming open"
11608 $MULTIOP $DIR/$tfile oO_RDONLY:eR_E-eUc &
11612 $MULTIOP $DIR/$tfile oO_RDONLY:c
11613 kill -USR1 $PID && wait $PID || error "break lease error"
11615 echo "==== test 3: verify lease can't be granted if an open already exists"
11616 $MULTIOP $DIR/$tfile oO_RDONLY:_c &
11620 $MULTIOP $DIR/$tfile oO_RDONLY:eReUc && error "apply lease should fail"
11621 kill -USR1 $PID && wait $PID || error "open file error"
11623 echo "==== test 4: lease can sustain over recovery"
11624 $MULTIOP $DIR/$tfile oO_RDONLY:eR_E+eUc &
11630 kill -USR1 $PID && wait $PID || error "lease broken over recovery"
11632 echo "==== test 5: lease broken can't be regained by replay"
11633 $MULTIOP $DIR/$tfile oO_RDONLY:eR_E-eUc &
11637 # open file to break lease and then recovery
11638 $MULTIOP $DIR/$tfile oO_RDWR:c || error "open file error"
11641 kill -USR1 $PID && wait $PID || error "lease not broken over recovery"
11645 run_test 208 "Exclusive open"
11648 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep disp_stripe)" ] &&
11649 skip_env "must have disp_stripe" && return
11652 sync; sleep 5; sync;
11654 echo 3 > /proc/sys/vm/drop_caches
11655 req_before=$(awk '/ptlrpc_cache / { print $2 }' /proc/slabinfo)
11657 # open/close 500 times
11658 for i in $(seq 500); do
11662 echo 3 > /proc/sys/vm/drop_caches
11663 req_after=$(awk '/ptlrpc_cache / { print $2 }' /proc/slabinfo)
11665 echo "before: $req_before, after: $req_after"
11666 [ $((req_after - req_before)) -ge 300 ] &&
11667 error "open/close requests are not freed"
11670 run_test 209 "read-only open/close requests should be freed promptly"
11674 size=$((size % 8192 + 1))
11675 dd if=/dev/urandom of=$DIR/f212 bs=1k count=$size
11676 sendfile $DIR/f212 $DIR/f212.xyz || error "sendfile wrong"
11677 rm -f $DIR/f212 $DIR/f212.xyz
11679 run_test 212 "Sendfile test ============================================"
11682 dd if=/dev/zero of=$DIR/$tfile bs=4k count=4
11683 cancel_lru_locks osc
11684 lctl set_param fail_loc=0x8000040f
11685 # generate a read lock
11686 cat $DIR/$tfile > /dev/null
11687 # write to the file, it will try to cancel the above read lock.
11688 cat /etc/hosts >> $DIR/$tfile
11690 run_test 213 "OSC lock completion and cancel race don't crash - bug 18829"
11692 test_214() { # for bug 20133
11693 mkdir -p $DIR/$tdir/d214c || error "mkdir $DIR/$tdir/d214c failed"
11694 for (( i=0; i < 340; i++ )) ; do
11695 touch $DIR/$tdir/d214c/a$i
11698 ls -l $DIR/$tdir || error "ls -l $DIR/d214p failed"
11699 mv $DIR/$tdir/d214c $DIR/ || error "mv $DIR/d214p/d214c $DIR/ failed"
11700 ls $DIR/d214c || error "ls $DIR/d214c failed"
11701 rm -rf $DIR/$tdir || error "rm -rf $DIR/d214* failed"
11702 rm -rf $DIR/d214* || error "rm -rf $DIR/d214* failed"
11704 run_test 214 "hash-indexed directory test - bug 20133"
11706 # having "abc" as 1st arg, creates $TMP/lnet_abc.out and $TMP/lnet_abc.sys
11707 create_lnet_proc_files() {
11708 lctl get_param -n $1 >$TMP/lnet_$1.out || error "cannot read lnet.$1"
11709 sysctl lnet.$1 >$TMP/lnet_$1.sys_tmp || error "cannot read lnet.$1"
11711 sed "s/^lnet.$1\ =\ //g" "$TMP/lnet_$1.sys_tmp" >$TMP/lnet_$1.sys
11712 rm -f "$TMP/lnet_$1.sys_tmp"
11715 # counterpart of create_lnet_proc_files
11716 remove_lnet_proc_files() {
11717 rm -f $TMP/lnet_$1.out $TMP/lnet_$1.sys
11720 # uses 1st arg as trailing part of filename, 2nd arg as description for reports,
11721 # 3rd arg as regexp for body
11722 check_lnet_proc_stats() {
11723 local l=$(cat "$TMP/lnet_$1" |wc -l)
11724 [ $l = 1 ] || (cat "$TMP/lnet_$1" && error "$2 is not of 1 line: $l")
11726 grep -E "$3" "$TMP/lnet_$1" || (cat "$TMP/lnet_$1" && error "$2 misformatted")
11729 # uses 1st arg as trailing part of filename, 2nd arg as description for reports,
11730 # 3rd arg as regexp for body, 4th arg as regexp for 1st line, 5th arg is
11731 # optional and can be regexp for 2nd line (lnet.routes case)
11732 check_lnet_proc_entry() {
11733 local blp=2 # blp stands for 'position of 1st line of body'
11734 [ -z "$5" ] || blp=3 # lnet.routes case
11736 local l=$(cat "$TMP/lnet_$1" |wc -l)
11737 # subtracting one from $blp because the body can be empty
11738 [ "$l" -ge "$(($blp - 1))" ] || (cat "$TMP/lnet_$1" && error "$2 is too short: $l")
11740 sed -n '1 p' "$TMP/lnet_$1" |grep -E "$4" >/dev/null ||
11741 (cat "$TMP/lnet_$1" && error "1st line of $2 misformatted")
11743 [ "$5" = "" ] || sed -n '2 p' "$TMP/lnet_$1" |grep -E "$5" >/dev/null ||
11744 (cat "$TMP/lnet_$1" && error "2nd line of $2 misformatted")
11746 # bail out if any unexpected line happened
11747 sed -n "$blp p" "$TMP/lnet_$1" | grep -Ev "$3"
11748 [ "$?" != 0 ] || error "$2 misformatted"
11751 test_215() { # for bugs 18102, 21079, 21517
11752 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11753 local N='(0|[1-9][0-9]*)' # non-negative numeric
11754 local P='[1-9][0-9]*' # positive numeric
11755 local I='(0|-?[1-9][0-9]*|NA)' # any numeric (0 | >0 | <0) or NA if no value
11756 local NET='[a-z][a-z0-9]*' # LNET net like o2ib2
11757 local ADDR='[0-9.]+' # LNET addr like 10.0.0.1
11758 local NID="$ADDR@$NET" # LNET nid like 10.0.0.1@o2ib2
11760 local L1 # regexp for 1st line
11761 local L2 # regexp for 2nd line (optional)
11762 local BR # regexp for the rest (body)
11764 # lnet.stats should look as 11 space-separated non-negative numerics
11765 BR="^$N $N $N $N $N $N $N $N $N $N $N$"
11766 create_lnet_proc_files "stats"
11767 check_lnet_proc_stats "stats.sys" "lnet.stats" "$BR"
11768 remove_lnet_proc_files "stats"
11770 # lnet.routes should look like this:
11771 # Routing disabled/enabled
11772 # net hops priority state router
11773 # where net is a string like tcp0, hops > 0, priority >= 0,
11774 # state is up/down,
11775 # router is a string like 192.168.1.1@tcp2
11776 L1="^Routing (disabled|enabled)$"
11777 L2="^net +hops +priority +state +router$"
11778 BR="^$NET +$N +(0|1) +(up|down) +$NID$"
11779 create_lnet_proc_files "routes"
11780 check_lnet_proc_entry "routes.sys" "lnet.routes" "$BR" "$L1" "$L2"
11781 remove_lnet_proc_files "routes"
11783 # lnet.routers should look like this:
11784 # ref rtr_ref alive_cnt state last_ping ping_sent deadline down_ni router
11785 # where ref > 0, rtr_ref > 0, alive_cnt >= 0, state is up/down,
11786 # last_ping >= 0, ping_sent is boolean (0/1), deadline and down_ni are
11787 # numeric (0 or >0 or <0), router is a string like 192.168.1.1@tcp2
11788 L1="^ref +rtr_ref +alive_cnt +state +last_ping +ping_sent +deadline +down_ni +router$"
11789 BR="^$P +$P +$N +(up|down) +$N +(0|1) +$I +$I +$NID$"
11790 create_lnet_proc_files "routers"
11791 check_lnet_proc_entry "routers.sys" "lnet.routers" "$BR" "$L1"
11792 remove_lnet_proc_files "routers"
11794 # lnet.peers should look like this:
11795 # nid refs state last max rtr min tx min queue
11796 # where nid is a string like 192.168.1.1@tcp2, refs > 0,
11797 # state is up/down/NA, max >= 0. last, rtr, min, tx, min are
11798 # numeric (0 or >0 or <0), queue >= 0.
11799 L1="^nid +refs +state +last +max +rtr +min +tx +min +queue$"
11800 BR="^$NID +$P +(up|down|NA) +$I +$N +$I +$I +$I +$I +$N$"
11801 create_lnet_proc_files "peers"
11802 check_lnet_proc_entry "peers.sys" "lnet.peers" "$BR" "$L1"
11803 remove_lnet_proc_files "peers"
11805 # lnet.buffers should look like this:
11806 # pages count credits min
11807 # where pages >=0, count >=0, credits and min are numeric (0 or >0 or <0)
11808 L1="^pages +count +credits +min$"
11809 BR="^ +$N +$N +$I +$I$"
11810 create_lnet_proc_files "buffers"
11811 check_lnet_proc_entry "buffers.sys" "lnet.buffers" "$BR" "$L1"
11812 remove_lnet_proc_files "buffers"
11814 # lnet.nis should look like this:
11815 # nid status alive refs peer rtr max tx min
11816 # where nid is a string like 192.168.1.1@tcp2, status is up/down,
11817 # alive is numeric (0 or >0 or <0), refs >= 0, peer >= 0,
11818 # rtr >= 0, max >=0, tx and min are numeric (0 or >0 or <0).
11819 L1="^nid +status +alive +refs +peer +rtr +max +tx +min$"
11820 BR="^$NID +(up|down) +$I +$N +$N +$N +$N +$I +$I$"
11821 create_lnet_proc_files "nis"
11822 check_lnet_proc_entry "nis.sys" "lnet.nis" "$BR" "$L1"
11823 remove_lnet_proc_files "nis"
11825 # can we successfully write to lnet.stats?
11826 lctl set_param -n stats=0 || error "cannot write to lnet.stats"
11827 sysctl -w lnet.stats=0 || error "cannot write to lnet.stats"
11829 run_test 215 "lnet exists and has proper content - bugs 18102, 21079, 21517"
11831 test_216() { # bug 20317
11832 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11833 remote_ost_nodsh && skip "remote OST with nodsh" && return
11836 local facets=$(get_facets OST)
11837 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
11839 save_lustre_params client "osc.*.contention_seconds" > $p
11840 save_lustre_params $facets \
11841 "ldlm.namespaces.filter-*.max_nolock_bytes" >> $p
11842 save_lustre_params $facets \
11843 "ldlm.namespaces.filter-*.contended_locks" >> $p
11844 save_lustre_params $facets \
11845 "ldlm.namespaces.filter-*.contention_seconds" >> $p
11848 # agressive lockless i/o settings
11849 for node in $(osts_nodes); do
11850 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'
11852 lctl set_param -n osc.*.contention_seconds 60
11854 $DIRECTIO write $DIR/$tfile 0 10 4096
11855 $CHECKSTAT -s 40960 $DIR/$tfile
11857 # disable lockless i/o
11858 for node in $(osts_nodes); do
11859 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'
11861 lctl set_param -n osc.*.contention_seconds 0
11864 dd if=/dev/zero of=$DIR/$tfile count=0
11865 $CHECKSTAT -s 0 $DIR/$tfile
11867 restore_lustre_params <$p
11871 run_test 216 "check lockless direct write works and updates file size and kms correctly"
11873 test_217() { # bug 22430
11874 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11878 for node in $(nodes_list); do
11879 nid=$(host_nids_address $node $NETTYPE)
11880 if [[ $nid = *-* ]] ; then
11881 echo "lctl ping $nid@$NETTYPE"
11882 lctl ping $nid@$NETTYPE
11884 echo "skipping $node (no hyphen detected)"
11888 run_test 217 "check lctl ping for hostnames with hiphen ('-')"
11891 # do directio so as not to populate the page cache
11892 log "creating a 10 Mb file"
11893 $MULTIOP $DIR/$tfile oO_CREAT:O_DIRECT:O_RDWR:w$((10*1048576))c || error "multiop failed while creating a file"
11894 log "starting reads"
11895 dd if=$DIR/$tfile of=/dev/null bs=4096 &
11896 log "truncating the file"
11897 $MULTIOP $DIR/$tfile oO_TRUNC:c || error "multiop failed while truncating the file"
11899 kill %+ || true # reads might have finished
11900 echo "wait until dd is finished"
11902 log "removing the temporary file"
11903 rm -rf $DIR/$tfile || error "tmp file removal failed"
11905 run_test 218 "parallel read and truncate should not deadlock ======================="
11908 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11909 # write one partial page
11910 dd if=/dev/zero of=$DIR/$tfile bs=1024 count=1
11911 # set no grant so vvp_io_commit_write will do sync write
11912 $LCTL set_param fail_loc=0x411
11913 # write a full page at the end of file
11914 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 seek=1 conv=notrunc
11916 $LCTL set_param fail_loc=0
11917 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 seek=3
11918 $LCTL set_param fail_loc=0x411
11919 dd if=/dev/zero of=$DIR/$tfile bs=1024 count=1 seek=2 conv=notrunc
11922 dd if=/dev/zero of=$DIR/$tfile-2 bs=1024 count=1
11923 $CHECKSTAT -s 1024 $DIR/$tfile-2 || error "checkstat wrong size"
11925 run_test 219 "LU-394: Write partial won't cause uncontiguous pages vec at LND"
11927 test_220() { #LU-325
11928 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11929 remote_ost_nodsh && skip "remote OST with nodsh" && return
11932 test_mkdir -p $DIR/$tdir
11933 local OST=$($LFS osts | grep ${OSTIDX}": " | \
11934 awk '{print $2}' | sed -e 's/_UUID$//')
11937 local mdtosc_proc1=$(get_mdtosc_proc_path $SINGLEMDS $OST)
11938 local last_id=$(do_facet $SINGLEMDS lctl get_param -n \
11939 osc.$mdtosc_proc1.prealloc_last_id)
11940 local next_id=$(do_facet $SINGLEMDS lctl get_param -n \
11941 osc.$mdtosc_proc1.prealloc_next_id)
11945 do_facet ost$((OSTIDX + 1)) lctl set_param fail_val=-1
11946 #define OBD_FAIL_OST_ENOINO 0x229
11947 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=0x229
11948 do_facet mgs $LCTL pool_new $FSNAME.$TESTNAME || return 1
11949 do_facet mgs $LCTL pool_add $FSNAME.$TESTNAME $OST || return 2
11951 $SETSTRIPE $DIR/$tdir -i $OSTIDX -c 1 -p $FSNAME.$TESTNAME
11953 MDSOBJS=$((last_id - next_id))
11954 echo "preallocated objects on MDS is $MDSOBJS" "($last_id - $next_id)"
11956 blocks=$($LFS df $MOUNT | awk '($1 == '$OSTIDX') { print $4 }')
11957 echo "OST still has $count kbytes free"
11959 echo "create $MDSOBJS files @next_id..."
11960 createmany -o $DIR/$tdir/f $MDSOBJS || return 3
11962 local last_id2=$(do_facet mds${MDSIDX} lctl get_param -n \
11963 osc.$mdtosc_proc1.prealloc_last_id)
11964 local next_id2=$(do_facet mds${MDSIDX} lctl get_param -n \
11965 osc.$mdtosc_proc1.prealloc_next_id)
11967 echo "after creation, last_id=$last_id2, next_id=$next_id2"
11972 do_facet ost$((OSTIDX + 1)) lctl set_param fail_val=0
11973 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=0
11975 do_facet mgs $LCTL pool_remove $FSNAME.$TESTNAME $OST || return 4
11976 do_facet mgs $LCTL pool_destroy $FSNAME.$TESTNAME || return 5
11977 echo "unlink $MDSOBJS files @$next_id..."
11978 unlinkmany $DIR/$tdir/f $MDSOBJS || return 6
11980 run_test 220 "preallocated MDS objects still used if ENOSPC from OST"
11983 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11984 dd if=`which date` of=$MOUNT/date oflag=sync
11985 chmod +x $MOUNT/date
11987 #define OBD_FAIL_LLITE_FAULT_TRUNC_RACE 0x1401
11988 $LCTL set_param fail_loc=0x80001401
11990 $MOUNT/date > /dev/null
11993 run_test 221 "make sure fault and truncate race to not cause OOM"
11996 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11998 test_mkdir -p $DIR/$tdir
11999 $SETSTRIPE -c 1 -i 0 $DIR/$tdir
12000 createmany -o $DIR/$tdir/$tfile 10
12001 cancel_lru_locks mdc
12002 cancel_lru_locks osc
12003 #define OBD_FAIL_LDLM_AGL_DELAY 0x31a
12004 $LCTL set_param fail_loc=0x31a
12005 ls -l $DIR/$tdir > /dev/null || error "AGL for ls failed"
12006 $LCTL set_param fail_loc=0
12009 run_test 222a "AGL for ls should not trigger CLIO lock failure ================"
12012 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12014 test_mkdir -p $DIR/$tdir
12015 $SETSTRIPE -c 1 -i 0 $DIR/$tdir
12016 createmany -o $DIR/$tdir/$tfile 10
12017 cancel_lru_locks mdc
12018 cancel_lru_locks osc
12019 #define OBD_FAIL_LDLM_AGL_DELAY 0x31a
12020 $LCTL set_param fail_loc=0x31a
12021 rm -r $DIR/$tdir || "AGL for rmdir failed"
12022 $LCTL set_param fail_loc=0
12024 run_test 222b "AGL for rmdir should not trigger CLIO lock failure ============="
12027 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12029 test_mkdir -p $DIR/$tdir
12030 $SETSTRIPE -c 1 -i 0 $DIR/$tdir
12031 createmany -o $DIR/$tdir/$tfile 10
12032 cancel_lru_locks mdc
12033 cancel_lru_locks osc
12034 #define OBD_FAIL_LDLM_AGL_NOLOCK 0x31b
12035 $LCTL set_param fail_loc=0x31b
12036 ls -l $DIR/$tdir > /dev/null || error "reenqueue failed"
12037 $LCTL set_param fail_loc=0
12040 run_test 223 "osc reenqueue if without AGL lock granted ======================="
12042 test_224a() { # LU-1039, MRP-303
12043 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12044 #define OBD_FAIL_PTLRPC_CLIENT_BULK_CB 0x508
12045 $LCTL set_param fail_loc=0x508
12046 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 conv=fsync
12047 $LCTL set_param fail_loc=0
12050 run_test 224a "Don't panic on bulk IO failure"
12052 test_224b() { # LU-1039, MRP-303
12053 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12054 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1
12055 cancel_lru_locks osc
12056 #define OBD_FAIL_PTLRPC_CLIENT_BULK_CB2 0x515
12057 $LCTL set_param fail_loc=0x515
12058 dd of=/dev/null if=$DIR/$tfile bs=4096 count=1
12059 $LCTL set_param fail_loc=0
12062 run_test 224b "Don't panic on bulk IO failure"
12064 test_224c() { # LU-6441
12065 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12066 local pages_per_rpc=$($LCTL get_param \
12067 osc.*.max_pages_per_rpc)
12068 local at_max=$($LCTL get_param -n at_max)
12069 local timeout=$($LCTL get_param -n timeout)
12070 local test_at="$LCTL get_param -n at_max"
12071 local param_at="$FSNAME.sys.at_max"
12072 local test_timeout="$LCTL get_param -n timeout"
12073 local param_timeout="$FSNAME.sys.timeout"
12075 $LCTL set_param -n osc.*.max_pages_per_rpc=1024
12077 set_conf_param_and_check client "$test_at" "$param_at" 0 ||
12078 error "conf_param at_max=0 failed"
12079 set_conf_param_and_check client "$test_timeout" "$param_timeout" 5 ||
12080 error "conf_param timeout=5 failed"
12082 #define OBD_FAIL_PTLRPC_CLIENT_BULK_CB3 0x520
12083 $LCTL set_param fail_loc=0x520
12084 dd if=/dev/zero of=$DIR/$tfile bs=8MB count=1
12086 $LCTL set_param fail_loc=0
12088 set_conf_param_and_check client "$test_at" "$param_at" $at_max ||
12089 error "conf_param at_max=$at_max failed"
12090 set_conf_param_and_check client "$test_timeout" "$param_timeout" \
12091 $timeout || error "conf_param timeout=$timeout failed"
12093 $LCTL set_param -n $pages_per_rpc
12095 run_test 224c "Don't hang if one of md lost during large bulk RPC"
12097 MDSSURVEY=${MDSSURVEY:-$(which mds-survey 2>/dev/null || true)}
12099 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12100 if [ -z ${MDSSURVEY} ]; then
12101 skip_env "mds-survey not found" && return
12104 [ $MDSCOUNT -ge 2 ] &&
12105 skip "skipping now for more than one MDT" && return
12107 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.51) ] ||
12108 { skip "Need MDS version at least 2.2.51"; return; }
12110 local mds=$(facet_host $SINGLEMDS)
12111 local target=$(do_nodes $mds 'lctl dl' | \
12112 awk "{if (\$2 == \"UP\" && \$3 == \"mdt\") {print \$4}}")
12114 local cmd1="file_count=1000 thrhi=4"
12115 local cmd2="dir_count=2 layer=mdd stripe_count=0"
12116 local cmd3="rslt_loc=${TMP} targets=\"$mds:$target\" $MDSSURVEY"
12117 local cmd="$cmd1 $cmd2 $cmd3"
12119 rm -f ${TMP}/mds_survey*
12121 eval $cmd || error "mds-survey with zero-stripe failed"
12122 cat ${TMP}/mds_survey*
12123 rm -f ${TMP}/mds_survey*
12125 run_test 225a "Metadata survey sanity with zero-stripe"
12128 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12130 if [ -z ${MDSSURVEY} ]; then
12131 skip_env "mds-survey not found" && return
12133 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.51) ] ||
12134 { skip "Need MDS version at least 2.2.51"; return; }
12136 if [ $($LCTL dl | grep -c osc) -eq 0 ]; then
12137 skip_env "Need to mount OST to test" && return
12140 [ $MDSCOUNT -ge 2 ] &&
12141 skip "skipping now for more than one MDT" && return
12142 local mds=$(facet_host $SINGLEMDS)
12143 local target=$(do_nodes $mds 'lctl dl' | \
12144 awk "{if (\$2 == \"UP\" && \$3 == \"mdt\") {print \$4}}")
12146 local cmd1="file_count=1000 thrhi=4"
12147 local cmd2="dir_count=2 layer=mdd stripe_count=1"
12148 local cmd3="rslt_loc=${TMP} targets=\"$mds:$target\" $MDSSURVEY"
12149 local cmd="$cmd1 $cmd2 $cmd3"
12151 rm -f ${TMP}/mds_survey*
12153 eval $cmd || error "mds-survey with stripe_count failed"
12154 cat ${TMP}/mds_survey*
12155 rm -f ${TMP}/mds_survey*
12157 run_test 225b "Metadata survey sanity with stripe_count = 1"
12159 mcreate_path2fid () {
12165 local path=$DIR/$tdir/$name
12170 $MCREATE --mode=$1 --major=$2 --minor=$3 $path ||
12171 error "cannot create $desc"
12173 fid=$($LFS path2fid $path | tr -d '[' | tr -d ']')
12175 [ $rc -ne 0 ] && error "cannot get fid of a $desc"
12177 fid_path=$($LFS fid2path $MOUNT $fid)
12179 [ $rc -ne 0 ] && error "cannot get path of $desc by $DIR $path $fid"
12181 [ "$path" == "$fid_path" ] ||
12182 error "fid2path returned $fid_path, expected $path"
12184 echo "pass with $path and $fid"
12189 mkdir -p $DIR/$tdir
12191 mcreate_path2fid 0010666 0 0 fifo "FIFO"
12192 mcreate_path2fid 0020666 1 3 null "character special file (null)"
12193 mcreate_path2fid 0020666 1 255 none "character special file (no device)"
12194 mcreate_path2fid 0040666 0 0 dir "directory"
12195 mcreate_path2fid 0060666 7 0 loop0 "block special file (loop)"
12196 mcreate_path2fid 0100666 0 0 file "regular file"
12197 mcreate_path2fid 0120666 0 0 link "symbolic link"
12198 mcreate_path2fid 0140666 0 0 sock "socket"
12200 run_test 226a "call path2fid and fid2path on files of all type"
12203 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
12207 mkdir -p $DIR/$tdir
12208 $LFS setdirstripe -i $MDTIDX $DIR/$tdir/remote_dir ||
12209 error "create remote directory failed"
12210 mcreate_path2fid 0010666 0 0 "remote_dir/fifo" "FIFO"
12211 mcreate_path2fid 0020666 1 3 "remote_dir/null" \
12212 "character special file (null)"
12213 mcreate_path2fid 0020666 1 255 "remote_dir/none" \
12214 "character special file (no device)"
12215 mcreate_path2fid 0040666 0 0 "remote_dir/dir" "directory"
12216 mcreate_path2fid 0060666 7 0 "remote_dir/loop0" \
12217 "block special file (loop)"
12218 mcreate_path2fid 0100666 0 0 "remote_dir/file" "regular file"
12219 mcreate_path2fid 0120666 0 0 "remote_dir/link" "symbolic link"
12220 mcreate_path2fid 0140666 0 0 "remote_dir/sock" "socket"
12222 run_test 226b "call path2fid and fid2path on files of all type under remote dir"
12224 # LU-1299 Executing or running ldd on a truncated executable does not
12225 # cause an out-of-memory condition.
12227 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12228 [ -z "$(which ldd)" ] && skip "should have ldd tool" && return
12229 dd if=$(which date) of=$MOUNT/date bs=1k count=1
12230 chmod +x $MOUNT/date
12232 $MOUNT/date > /dev/null
12233 ldd $MOUNT/date > /dev/null
12236 run_test 227 "running truncated executable does not cause OOM"
12238 # LU-1512 try to reuse idle OI blocks
12240 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12241 remote_mds_nodsh && skip "remote MDS with nodsh" && return
12242 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
12243 skip "non-ldiskfs backend" && return
12245 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
12246 local myDIR=$DIR/$tdir
12249 #define OBD_FAIL_SEQ_EXHAUST 0x1002
12250 $LCTL set_param fail_loc=0x80001002
12251 createmany -o $myDIR/t- 10000
12252 $LCTL set_param fail_loc=0
12253 # The guard is current the largest FID holder
12255 local SEQ=$($LFS path2fid $myDIR/guard | awk -F ':' '{print $1}' |
12257 local IDX=$(($SEQ % 64))
12259 do_facet $SINGLEMDS sync
12260 # Make sure journal flushed.
12262 local blk1=$(do_facet $SINGLEMDS \
12263 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
12264 grep Blockcount | awk '{print $4}')
12266 # Remove old files, some OI blocks will become idle.
12267 unlinkmany $myDIR/t- 10000
12268 # Create new files, idle OI blocks should be reused.
12269 createmany -o $myDIR/t- 2000
12270 do_facet $SINGLEMDS sync
12271 # Make sure journal flushed.
12273 local blk2=$(do_facet $SINGLEMDS \
12274 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
12275 grep Blockcount | awk '{print $4}')
12277 [ $blk1 == $blk2 ] || error "old blk1=$blk1, new blk2=$blk2, unmatched!"
12279 run_test 228a "try to reuse idle OI blocks"
12282 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12283 remote_mds_nodsh && skip "remote MDS with nodsh" && return
12284 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
12285 skip "non-ldiskfs backend" && return
12287 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
12288 local myDIR=$DIR/$tdir
12291 #define OBD_FAIL_SEQ_EXHAUST 0x1002
12292 $LCTL set_param fail_loc=0x80001002
12293 createmany -o $myDIR/t- 10000
12294 $LCTL set_param fail_loc=0
12295 # The guard is current the largest FID holder
12297 local SEQ=$($LFS path2fid $myDIR/guard | awk -F ':' '{print $1}' |
12299 local IDX=$(($SEQ % 64))
12301 do_facet $SINGLEMDS sync
12302 # Make sure journal flushed.
12304 local blk1=$(do_facet $SINGLEMDS \
12305 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
12306 grep Blockcount | awk '{print $4}')
12308 # Remove old files, some OI blocks will become idle.
12309 unlinkmany $myDIR/t- 10000
12312 stop $SINGLEMDS || error "Fail to stop MDT."
12314 start $SINGLEMDS $MDT_DEV $MDS_MOUNT_OPTS || error "Fail to start MDT."
12316 df $MOUNT || error "Fail to df."
12317 # Create new files, idle OI blocks should be reused.
12318 createmany -o $myDIR/t- 2000
12319 do_facet $SINGLEMDS sync
12320 # Make sure journal flushed.
12322 local blk2=$(do_facet $SINGLEMDS \
12323 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
12324 grep Blockcount | awk '{print $4}')
12326 [ $blk1 == $blk2 ] || error "old blk1=$blk1, new blk2=$blk2, unmatched!"
12328 run_test 228b "idle OI blocks can be reused after MDT restart"
12332 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12333 remote_mds_nodsh && skip "remote MDS with nodsh" && return
12334 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
12335 skip "non-ldiskfs backend" && return
12337 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
12338 local myDIR=$DIR/$tdir
12341 #define OBD_FAIL_SEQ_EXHAUST 0x1002
12342 $LCTL set_param fail_loc=0x80001002
12343 # 20000 files can guarantee there are index nodes in the OI file
12344 createmany -o $myDIR/t- 20000
12345 $LCTL set_param fail_loc=0
12346 # The guard is current the largest FID holder
12348 local SEQ=$($LFS path2fid $myDIR/guard | awk -F ':' '{print $1}' |
12350 local IDX=$(($SEQ % 64))
12352 do_facet $SINGLEMDS sync
12353 # Make sure journal flushed.
12355 local blk1=$(do_facet $SINGLEMDS \
12356 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
12357 grep Blockcount | awk '{print $4}')
12359 # Remove old files, some OI blocks will become idle.
12360 unlinkmany $myDIR/t- 20000
12362 # The OI file should become empty now
12364 # Create new files, idle OI blocks should be reused.
12365 createmany -o $myDIR/t- 2000
12366 do_facet $SINGLEMDS sync
12367 # Make sure journal flushed.
12369 local blk2=$(do_facet $SINGLEMDS \
12370 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
12371 grep Blockcount | awk '{print $4}')
12373 [ $blk1 == $blk2 ] || error "old blk1=$blk1, new blk2=$blk2, unmatched!"
12375 run_test 228c "NOT shrink the last entry in OI index node to recycle idle leaf"
12377 test_229() { # LU-2482, LU-3448
12378 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.53) ] &&
12379 skip "No HSM $(lustre_build_version $SINGLEMDS) MDS < 2.4.53" &&
12381 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12382 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs" && return
12386 # Create a file with a released layout and stripe count 2.
12387 $MULTIOP $DIR/$tfile H2c ||
12388 error "failed to create file with released layout"
12390 $GETSTRIPE -v $DIR/$tfile
12392 local pattern=$($GETSTRIPE -L $DIR/$tfile)
12393 [ X"$pattern" = X"80000001" ] || error "pattern error ($pattern)"
12395 local stripe_count=$($GETSTRIPE -c $DIR/$tfile) || error "getstripe"
12396 [ $stripe_count -eq 2 ] || error "stripe count not 2 ($stripe_count)"
12397 stat $DIR/$tfile || error "failed to stat released file"
12399 chown $RUNAS_ID $DIR/$tfile ||
12400 error "chown $RUNAS_ID $DIR/$tfile failed"
12402 chgrp $RUNAS_ID $DIR/$tfile ||
12403 error "chgrp $RUNAS_ID $DIR/$tfile failed"
12405 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
12406 rm $DIR/$tfile || error "failed to remove released file"
12408 run_test 229 "getstripe/stat/rm/attr changes work on released files"
12411 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12412 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
12415 test_mkdir $DIR/$tdir
12416 test_mkdir -i0 -c1 $DIR/$tdir/test_230_local
12417 local mdt_idx=$($GETSTRIPE -M $DIR/$tdir/test_230_local)
12418 [ $mdt_idx -ne 0 ] &&
12419 error "create local directory on wrong MDT $mdt_idx"
12421 $LFS mkdir -i $MDTIDX $DIR/$tdir/test_230 ||
12422 error "create remote directory failed"
12423 local mdt_idx=$($GETSTRIPE -M $DIR/$tdir/test_230)
12424 [ $mdt_idx -ne $MDTIDX ] &&
12425 error "create remote directory on wrong MDT $mdt_idx"
12427 createmany -o $DIR/$tdir/test_230/t- 10 ||
12428 error "create files on remote directory failed"
12429 mdt_idx=$($GETSTRIPE -M $DIR/$tdir/test_230/t-0)
12430 [ $mdt_idx -ne $MDTIDX ] && error "create files on wrong MDT $mdt_idx"
12431 rm -r $DIR/$tdir || error "unlink remote directory failed"
12433 run_test 230a "Create remote directory and files under the remote directory"
12436 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12437 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
12444 local migrate_dir=$DIR/$tdir/migrate_dir
12445 local other_dir=$DIR/$tdir/other_dir
12447 test_mkdir $DIR/$tdir
12448 test_mkdir -i0 -c1 $migrate_dir
12449 test_mkdir -i0 -c1 $other_dir
12450 for ((i=0; i<10; i++)); do
12451 mkdir -p $migrate_dir/dir_${i}
12452 createmany -o $migrate_dir/dir_${i}/f 10 ||
12453 error "create files under remote dir failed $i"
12456 cp /etc/passwd $migrate_dir/$tfile
12457 cp /etc/passwd $other_dir/$tfile
12458 chattr +SAD $migrate_dir
12459 chattr +SAD $migrate_dir/$tfile
12461 local old_dir_flag=$(lsattr -a $migrate_dir | awk '/\/\.$/ {print $1}')
12462 local old_file_flag=$(lsattr $migrate_dir/$tfile | awk '{print $1}')
12463 local old_dir_mode=$(stat -c%f $migrate_dir)
12464 local old_file_mode=$(stat -c%f $migrate_dir/$tfile)
12466 mkdir -p $migrate_dir/dir_default_stripe2
12467 $SETSTRIPE -c 2 $migrate_dir/dir_default_stripe2
12468 $SETSTRIPE -c 2 $migrate_dir/${tfile}_stripe2
12470 mkdir -p $other_dir
12471 ln $migrate_dir/$tfile $other_dir/luna
12472 ln $migrate_dir/$tfile $migrate_dir/sofia
12473 ln $other_dir/$tfile $migrate_dir/david
12474 ln -s $migrate_dir/$tfile $other_dir/zachary
12475 ln -s $migrate_dir/$tfile $migrate_dir/${tfile}_ln
12476 ln -s $other_dir/$tfile $migrate_dir/${tfile}_ln_other
12478 $LFS mv -v -M $MDTIDX $migrate_dir ||
12479 error "migrate remote dir error"
12481 echo "migratate to MDT1, then checking.."
12482 for ((i = 0; i < 10; i++)); do
12483 for file in $(find $migrate_dir/dir_${i}); do
12484 mdt_index=$($LFS getstripe -M $file)
12485 [ $mdt_index == $MDTIDX ] ||
12486 error "$file is not on MDT${MDTIDX}"
12490 # the multiple link file should still in MDT0
12491 mdt_index=$($LFS getstripe -M $migrate_dir/$tfile)
12492 [ $mdt_index == 0 ] ||
12493 error "$file is not on MDT${MDTIDX}"
12495 local new_dir_flag=$(lsattr -a $migrate_dir | awk '/\/\.$/ {print $1}')
12496 [ "$old_dir_flag" = "$new_dir_flag" ] ||
12497 error " expect $old_dir_flag get $new_dir_flag"
12499 local new_file_flag=$(lsattr $migrate_dir/$tfile | awk '{print $1}')
12500 [ "$old_file_flag" = "$new_file_flag" ] ||
12501 error " expect $old_file_flag get $new_file_flag"
12503 local new_dir_mode=$(stat -c%f $migrate_dir)
12504 [ "$old_dir_mode" = "$new_dir_mode" ] ||
12505 error "expect mode $old_dir_mode get $new_dir_mode"
12507 local new_file_mode=$(stat -c%f $migrate_dir/$tfile)
12508 [ "$old_file_mode" = "$new_file_mode" ] ||
12509 error "expect mode $old_file_mode get $new_file_mode"
12511 diff /etc/passwd $migrate_dir/$tfile ||
12512 error "$tfile different after migration"
12514 diff /etc/passwd $other_dir/luna ||
12515 error "luna different after migration"
12517 diff /etc/passwd $migrate_dir/sofia ||
12518 error "sofia different after migration"
12520 diff /etc/passwd $migrate_dir/david ||
12521 error "david different after migration"
12523 diff /etc/passwd $other_dir/zachary ||
12524 error "zachary different after migration"
12526 diff /etc/passwd $migrate_dir/${tfile}_ln ||
12527 error "${tfile}_ln different after migration"
12529 diff /etc/passwd $migrate_dir/${tfile}_ln_other ||
12530 error "${tfile}_ln_other different after migration"
12532 stripe_count=$($LFS getstripe -c $migrate_dir/dir_default_stripe2)
12533 [ $stripe_count = 2 ] ||
12534 error "dir strpe_count $d != 2 after migration."
12536 stripe_count=$($LFS getstripe -c $migrate_dir/${tfile}_stripe2)
12537 [ $stripe_count = 2 ] ||
12538 error "file strpe_count $d != 2 after migration."
12540 #migrate back to MDT0
12542 $LFS mv -v -M $MDTIDX $migrate_dir ||
12543 error "migrate remote dir error"
12545 echo "migrate back to MDT0, checking.."
12546 for file in $(find $migrate_dir); do
12547 mdt_index=$($LFS getstripe -M $file)
12548 [ $mdt_index == $MDTIDX ] ||
12549 error "$file is not on MDT${MDTIDX}"
12552 local new_dir_flag=$(lsattr -a $migrate_dir | awk '/\/\.$/ {print $1}')
12553 [ "$old_dir_flag" = "$new_dir_flag" ] ||
12554 error " expect $old_dir_flag get $new_dir_flag"
12556 local new_file_flag=$(lsattr $migrate_dir/$tfile | awk '{print $1}')
12557 [ "$old_file_flag" = "$new_file_flag" ] ||
12558 error " expect $old_file_flag get $new_file_flag"
12560 local new_dir_mode=$(stat -c%f $migrate_dir)
12561 [ "$old_dir_mode" = "$new_dir_mode" ] ||
12562 error "expect mode $old_dir_mode get $new_dir_mode"
12564 local new_file_mode=$(stat -c%f $migrate_dir/$tfile)
12565 [ "$old_file_mode" = "$new_file_mode" ] ||
12566 error "expect mode $old_file_mode get $new_file_mode"
12568 diff /etc/passwd ${migrate_dir}/$tfile ||
12569 error "$tfile different after migration"
12571 diff /etc/passwd ${other_dir}/luna ||
12572 error "luna different after migration"
12574 diff /etc/passwd ${migrate_dir}/sofia ||
12575 error "sofia different after migration"
12577 diff /etc/passwd ${other_dir}/zachary ||
12578 error "zachary different after migration"
12580 diff /etc/passwd $migrate_dir/${tfile}_ln ||
12581 error "${tfile}_ln different after migration"
12583 diff /etc/passwd $migrate_dir/${tfile}_ln_other ||
12584 error "${tfile}_ln_other different after migration"
12586 stripe_count=$($LFS getstripe -c ${migrate_dir}/dir_default_stripe2)
12587 [ $stripe_count = 2 ] ||
12588 error "dir strpe_count $d != 2 after migration."
12590 stripe_count=$($LFS getstripe -c ${migrate_dir}/${tfile}_stripe2)
12591 [ $stripe_count = 2 ] ||
12592 error "file strpe_count $d != 2 after migration."
12594 rm -rf $DIR/$tdir || error "rm dir failed after migration"
12596 run_test 230b "migrate directory"
12599 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12600 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
12604 local migrate_dir=$DIR/$tdir/migrate_dir
12606 #If migrating directory fails in the middle, all entries of
12607 #the directory is still accessiable.
12608 test_mkdir $DIR/$tdir
12609 test_mkdir -i0 -c1 $migrate_dir
12611 createmany -o $migrate_dir/f 10 ||
12612 error "create files under ${migrate_dir} failed"
12614 #failed after migrating 5 entries
12615 #OBD_FAIL_MIGRATE_ENTRIES 0x1801
12616 do_facet mds1 lctl set_param fail_loc=0x20001801
12617 do_facet mds1 lctl set_param fail_val=5
12618 local t=$(ls $migrate_dir | wc -l)
12619 $LFS mv --mdt-index $MDTIDX $migrate_dir &&
12620 error "migrate should fail after 5 entries"
12621 local u=$(ls $migrate_dir | wc -l)
12622 [ "$u" == "$t" ] || error "$u != $t during migration"
12624 for file in $(find $migrate_dir); do
12625 stat $file || error "stat $file failed"
12628 do_facet mds1 lctl set_param fail_loc=0
12629 do_facet mds1 lctl set_param fail_val=0
12631 $LFS mv -M $MDTIDX $migrate_dir ||
12632 error "migrate open files should failed with open files"
12634 echo "Finish migration, then checking.."
12635 for file in $(find $migrate_dir); do
12636 mdt_index=$($LFS getstripe -M $file)
12637 [ $mdt_index == $MDTIDX ] ||
12638 error "$file is not on MDT${MDTIDX}"
12641 rm -rf $DIR/$tdir || error "rm dir failed after migration"
12643 run_test 230c "check directory accessiblity if migration is failed"
12646 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12647 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
12650 local migrate_dir=$DIR/$tdir/migrate_dir
12654 test_mkdir $DIR/$tdir
12655 test_mkdir -i0 -c1 $migrate_dir
12657 for ((i=0; i<100; i++)); do
12658 test_mkdir -i0 -c1 $migrate_dir/dir_${i}
12659 createmany -o $migrate_dir/dir_${i}/f 100 ||
12660 error "create files under remote dir failed $i"
12663 $LFS mv -M $MDTIDX -v $migrate_dir || error "migrate remote dir error"
12665 echo "Finish migration, then checking.."
12666 for file in $(find $migrate_dir); do
12667 mdt_index=$($LFS getstripe -M $file)
12668 [ $mdt_index == $MDTIDX ] ||
12669 error "$file is not on MDT${MDTIDX}"
12672 rm -rf $DIR/$tdir || error "rm dir failed after migration"
12674 run_test 230d "check migrate big directory"
12678 # For simplicity this test assumes that max_pages_per_rpc
12679 # is the same across all OSCs
12680 local max_pages=$($LCTL get_param -n osc.*.max_pages_per_rpc | head -n1)
12681 local bulk_size=$((max_pages * 4096))
12683 mkdir -p $DIR/$tdir
12685 # clear the OSC stats
12686 $LCTL set_param osc.*.stats=0 &>/dev/null
12688 # Client writes $bulk_size - there must be 1 rpc for $max_pages.
12689 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=$bulk_size count=1 \
12690 oflag=direct &>/dev/null || error "dd failed"
12692 local nrpcs=$($LCTL get_param osc.*.stats |awk '/ost_write/ {print $2}')
12693 if [ x$nrpcs != "x1" ]; then
12694 error "found $nrpc ost_write RPCs, not 1 as expected"
12697 # Drop the OSC cache, otherwise we will read from it
12698 cancel_lru_locks osc
12700 # clear the OSC stats
12701 $LCTL set_param osc.*.stats=0 &>/dev/null
12703 # Client reads $bulk_size.
12704 dd if=$DIR/$tdir/$tfile of=/dev/null bs=$bulk_size count=1 \
12705 iflag=direct &>/dev/null || error "dd failed"
12707 nrpcs=$($LCTL get_param osc.*.stats | awk '/ost_read/ { print $2 }')
12708 if [ x$nrpcs != "x1" ]; then
12709 error "found $nrpc ost_read RPCs, not 1 as expected"
12712 run_test 231a "checking that reading/writing of BRW RPC size results in one RPC"
12715 mkdir -p $DIR/$tdir
12717 for i in {0..1023}; do
12718 dd if=/dev/zero of=$DIR/$tdir/$tfile conv=notrunc \
12719 seek=$((2 * i)) bs=4096 count=1 &>/dev/null ||
12720 error "dd of=$DIR/$tdir/$tfile seek=$((2 * i)) failed"
12724 run_test 231b "must not assert on fully utilized OST request buffer"
12727 mkdir -p $DIR/$tdir
12728 #define OBD_FAIL_LDLM_OST_LVB 0x31c
12729 $LCTL set_param fail_loc=0x31c
12731 # ignore dd failure
12732 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=1 || true
12734 $LCTL set_param fail_loc=0
12735 umount_client $MOUNT || error "umount failed"
12736 mount_client $MOUNT || error "mount failed"
12738 run_test 232 "failed lock should not block umount"
12741 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.3.64) ] ||
12742 { skip "Need MDS version at least 2.3.64"; return; }
12744 local fid=$($LFS path2fid $MOUNT)
12745 stat $MOUNT/.lustre/fid/$fid > /dev/null ||
12746 error "cannot access $MOUNT using its FID '$fid'"
12748 run_test 233a "checking that OBF of the FS root succeeds"
12751 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.5.90) ] ||
12752 { skip "Need MDS version at least 2.5.90"; return; }
12754 local fid=$($LFS path2fid $MOUNT/.lustre)
12755 stat $MOUNT/.lustre/fid/$fid > /dev/null ||
12756 error "cannot access $MOUNT/.lustre using its FID '$fid'"
12758 fid=$($LFS path2fid $MOUNT/.lustre/fid)
12759 stat $MOUNT/.lustre/fid/$fid > /dev/null ||
12760 error "cannot access $MOUNT/.lustre/fid using its FID '$fid'"
12762 run_test 233b "checking that OBF of the FS .lustre succeeds"
12765 local p="$TMP/sanityN-$TESTNAME.parameters"
12766 save_lustre_params client "llite.*.xattr_cache" > $p
12767 lctl set_param llite.*.xattr_cache 1 ||
12768 { skip "xattr cache is not supported"; return 0; }
12770 mkdir -p $DIR/$tdir || error "mkdir failed"
12771 touch $DIR/$tdir/$tfile || error "touch failed"
12772 # OBD_FAIL_LLITE_XATTR_ENOMEM
12773 $LCTL set_param fail_loc=0x1405
12774 # output of the form: attr 2 4 44 3 fc13 x86_64
12775 V=($(IFS=".-" rpm -q attr))
12776 if [[ ${V[1]} > 2 || ${V[2]} > 4 || ${V[3]} > 44 ||
12777 ${V[1]} = 2 && ${V[2]} = 4 && ${V[3]} = 44 && ${V[4]} > 6 ]]; then
12778 # attr pre-2.4.44-7 had a bug with rc
12779 # LU-3703 - SLES 11 and FC13 clients have older attr
12780 getfattr -n user.attr $DIR/$tdir/$tfile &&
12781 error "getfattr should have failed with ENOMEM"
12783 skip "LU-3703: attr version $(getfattr --version) too old"
12785 $LCTL set_param fail_loc=0x0
12788 restore_lustre_params < $p
12791 run_test 234 "xattr cache should not crash on ENOMEM"
12794 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.52) ] &&
12795 skip "Need MDS version at least 2.4.52" && return
12796 flock_deadlock $DIR/$tfile
12801 124) error "process hangs on a deadlock"
12803 *) error "error executing flock_deadlock $DIR/$tfile"
12807 run_test 235 "LU-1715: flock deadlock detection does not work properly"
12811 check_swap_layouts_support && return 0
12812 test_mkdir -p -c1 $DIR/$tdir || error "mkdir $tdir failed"
12814 local ref1=/etc/passwd
12815 local ref2=/etc/group
12816 local file1=$DIR/$tdir/f1
12817 local file2=$DIR/$tdir/f2
12819 $SETSTRIPE -c 1 $file1 || error "cannot setstripe on '$file1': rc = $?"
12820 cp $ref1 $file1 || error "cp $ref1 $file1 failed: rc = $?"
12821 $SETSTRIPE -c 2 $file2 || error "cannot setstripe on '$file2': rc = $?"
12822 cp $ref2 $file2 || error "cp $ref2 $file2 failed: rc = $?"
12823 local fd=$(free_fd)
12824 local cmd="exec $fd<>$file2"
12827 $LFS swap_layouts $file1 /proc/self/fd/${fd} ||
12828 error "cannot swap layouts of '$file1' and /proc/self/fd/${fd}"
12831 cmp $ref2 $file1 || error "content compare failed ($ref2 != $file1)"
12836 run_test 236 "Layout swap on open unlinked file"
12838 # test to verify file handle related system calls
12839 # (name_to_handle_at/open_by_handle_at)
12840 # The new system calls are supported in glibc >= 2.14.
12843 echo "Test file_handle syscalls" > $DIR/$tfile ||
12844 error "write failed"
12845 check_fhandle_syscalls $DIR/$tfile ||
12846 error "check_fhandle_syscalls failed"
12848 run_test 237 "Verify name_to_handle_at/open_by_handle_at syscalls"
12850 # LU-4659 linkea consistency
12852 local server_version=$(lustre_version_code $SINGLEMDS)
12854 [[ $server_version -gt $(version_code 2.5.57) ]] ||
12855 [[ $server_version -gt $(version_code 2.5.1) &&
12856 $server_version -lt $(version_code 2.5.50) ]] ||
12857 { skip "Need MDS version at least 2.5.58 or 2.5.2+"; return; }
12860 ln $DIR/$tfile $DIR/$tfile.lnk
12861 touch $DIR/$tfile.new
12862 mv $DIR/$tfile.new $DIR/$tfile
12863 local fid1=$($LFS path2fid $DIR/$tfile)
12864 local fid2=$($LFS path2fid $DIR/$tfile.lnk)
12865 local path1=$($LFS fid2path $FSNAME "$fid1")
12866 [ $tfile == $path1 ] || error "linkea inconsistent: $tfile $fid1 $path1"
12867 local path2=$($LFS fid2path $FSNAME "$fid2")
12868 [ $tfile.lnk == $path2 ] ||
12869 error "linkea inconsistent: $tfile.lnk $fid2 $path2!"
12872 run_test 238 "Verify linkea consistency"
12875 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.5.60) ] &&
12876 skip "Need MDS version at least 2.5.60" && return
12877 local list=$(comma_list $(mdts_nodes))
12879 mkdir -p $DIR/$tdir
12880 createmany -o $DIR/$tdir/f- 5000
12881 unlinkmany $DIR/$tdir/f- 5000
12882 do_nodes $list "lctl set_param -n osp*.*.sync_changes 1"
12883 changes=$(do_nodes $list "lctl get_param -n osc.*MDT*.sync_changes \
12884 osc.*MDT*.sync_in_flight" | calc_sum)
12885 [ "$changes" -eq 0 ] || error "$changes not synced"
12887 run_test 239 "osp_sync test"
12890 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
12892 mkdir -p $DIR/$tdir
12894 $LFS mkdir -i 0 $DIR/$tdir/d0 ||
12895 error "failed to mkdir $DIR/$tdir/d0 on MDT0"
12896 $LFS mkdir -i 1 $DIR/$tdir/d0/d1 ||
12897 error "failed to mkdir $DIR/$tdir/d0/d1 on MDT1"
12899 umount_client $MOUNT || error "umount failed"
12900 #define OBD_FAIL_TGT_DELAY_CONDITIONAL 0x713
12901 do_facet mds2 lctl set_param fail_loc=0x713 fail_val=1
12902 mount_client $MOUNT || error "failed to mount client"
12904 echo "stat $DIR/$tdir/d0/d1, should not fail/ASSERT"
12905 stat $DIR/$tdir/d0/d1 || error "fail to stat $DIR/$tdir/d0/d1"
12907 run_test 240 "race between ldlm enqueue and the connection RPC (no ASSERT)"
12910 for LOOP in $(seq $1); do
12911 dd if=$DIR/$tfile of=/dev/null bs=40960 count=1 2>/dev/null
12912 cancel_lru_locks osc
12917 for LOOP in $(seq $1); do
12918 dd if=$DIR/$tfile of=/dev/null bs=40960 count=1 \
12919 iflag=direct 2>/dev/null
12924 dd if=/dev/zero of=$DIR/$tfile count=1 bs=40960
12926 cancel_lru_locks osc
12927 test_241_bio 1000 &
12932 run_test 241 "bio vs dio"
12935 dd if=/dev/zero of=$DIR/$tfile count=1 bs=40960
12937 test_241_dio 1000 &
12942 run_test 241b "dio vs dio"
12945 mkdir -p $DIR/$tdir
12946 touch $DIR/$tdir/$tfile
12948 #define OBD_FAIL_MDS_READPAGE_PACK 0x105
12949 do_facet mds1 lctl set_param fail_loc=0x105
12950 /bin/ls $DIR/$tdir && error "ls $DIR/$tdir should fail"
12952 do_facet mds1 lctl set_param fail_loc=0
12953 /bin/ls $DIR/$tdir || error "ls $DIR/$tdir failed"
12955 run_test 242 "mdt_readpage failure should not cause directory unreadable"
12959 test_mkdir -p $DIR/$tdir
12960 group_lock_test -d $DIR/$tdir || error "A group lock test failed"
12962 run_test 243 "various group lock tests"
12966 test_mkdir -p $DIR/$tdir
12967 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=35
12968 sendfile_grouplock $DIR/$tdir/$tfile || \
12969 error "sendfile+grouplock failed"
12972 run_test 244 "sendfile with group lock tests"
12975 [ "$(facet_fstype ost$(($($GETSTRIPE -i $DIR/$tfile) + 1)))" = "zfs" ] \
12976 && skip "no 16TB file size limit on ZFS" && return
12978 $SETSTRIPE -c 1 $DIR/$tfile
12979 # ldiskfs extent file size limit is (16TB - 4KB - 1) bytes
12980 local size=$((16 * 1024 * 1024 * 1024 * 1024 - 4096 - 1))
12981 $TRUNCATE $DIR/$tfile $size || error "truncate $tfile to $size failed"
12982 dd if=/dev/zero of=$DIR/$tfile bs=10 count=1 oflag=append \
12983 conv=notrunc,fsync && error "append succeeded"
12986 run_test 250 "Write above 16T limit"
12989 $SETSTRIPE -c -1 -S 1048576 $DIR/$tfile
12991 #define OBD_FAIL_LLITE_LOST_LAYOUT 0x1407
12992 #Skip once - writing the first stripe will succeed
12993 $LCTL set_param fail_loc=0xa0001407 fail_val=1
12994 $MULTIOP $DIR/$tfile o:O_RDWR:w2097152c 2>&1 | grep -q "short write" &&
12995 error "short write happened"
12997 $LCTL set_param fail_loc=0xa0001407 fail_val=1
12998 $MULTIOP $DIR/$tfile or2097152c 2>&1 | grep -q "short read" &&
12999 error "short read happened"
13003 run_test 251 "Handling short read and write correctly"
13005 cleanup_test_300() {
13009 test_striped_dir() {
13014 mkdir -p $DIR/$tdir
13016 SAVE_UMASK=$(umask)
13017 trap cleanup_test_300 RETURN EXIT
13019 $LFS setdirstripe -i $mdt_index -c 2 -t all_char -m 755 \
13020 $DIR/$tdir/striped_dir ||
13021 error "set striped dir error"
13023 local mode=$(stat -c%a $DIR/$tdir/striped_dir)
13024 [ "$mode" = "755" ] || error "expect 755 got $mode"
13026 stripe_count=$($LFS getdirstripe -c $DIR/$tdir/striped_dir)
13027 if [ "$stripe_count" != "2" ]; then
13028 error "stripe_count is $stripe_count, expect 2"
13031 stripe_index=$($LFS getdirstripe -i $DIR/$tdir/striped_dir)
13032 if [ "$stripe_index" != "$mdt_index" ]; then
13033 error "stripe_index is $stripe_index, expect $mdt_index"
13036 [ $(stat -c%h $DIR/$tdir/striped_dir) == '2' ] ||
13037 error "nlink error after create striped dir"
13039 mkdir $DIR/$tdir/striped_dir/a
13040 mkdir $DIR/$tdir/striped_dir/b
13042 stat $DIR/$tdir/striped_dir/a ||
13043 error "create dir under striped dir failed"
13044 stat $DIR/$tdir/striped_dir/b ||
13045 error "create dir under striped dir failed"
13047 [ $(stat -c%h $DIR/$tdir/striped_dir) == '4' ] ||
13048 error "nlink error after mkdir"
13050 rmdir $DIR/$tdir/striped_dir/a
13051 [ $(stat -c%h $DIR/$tdir/striped_dir) == '3' ] ||
13052 error "nlink error after rmdir"
13054 rmdir $DIR/$tdir/striped_dir/b
13055 [ $(stat -c%h $DIR/$tdir/striped_dir) == '2' ] ||
13056 error "nlink error after rmdir"
13058 chattr +i $DIR/$tdir/striped_dir
13059 createmany -o $DIR/$tdir/striped_dir/f 10 &&
13060 error "immutable flags not working under striped dir!"
13061 chattr -i $DIR/$tdir/striped_dir
13063 rmdir $DIR/$tdir/striped_dir ||
13064 error "rmdir striped dir error"
13072 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13073 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
13075 test_striped_dir 0 || error "failed on striped dir on MDT0"
13076 test_striped_dir 1 || error "failed on striped dir on MDT0"
13078 run_test 300a "basic striped dir sanity test"
13081 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13082 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
13088 test_mkdir $DIR/$tdir || error "mkdir fail"
13089 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir ||
13090 error "set striped dir error"
13091 for ((i=0; i<10; i++)); do
13092 mtime1=$(stat -c %Y $DIR/$tdir/striped_dir)
13094 touch $DIR/$tdir/striped_dir/file_$i ||
13095 error "touch error $i"
13096 mtime2=$(stat -c %Y $DIR/$tdir/striped_dir)
13097 [ $mtime1 -eq $mtime2 ] &&
13098 error "mtime not change after create"
13100 rm -f $DIR/$tdir/striped_dir/file_$i ||
13101 error "unlink error $i"
13102 mtime3=$(stat -c %Y $DIR/$tdir/striped_dir)
13103 [ $mtime2 -eq $mtime3 ] &&
13104 error "mtime did not change after unlink"
13108 run_test 300b "check ctime/mtime for striped dir"
13111 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13112 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
13115 mkdir -p $DIR/$tdir
13116 $LFS setdirstripe -i 0 -c 2 $DIR/$tdir/striped_dir ||
13117 error "set striped dir error"
13119 chown $RUNAS_ID:$RUNAS_GID $DIR/$tdir/striped_dir ||
13120 error "chown striped dir failed"
13122 $RUNAS createmany -o $DIR/$tdir/striped_dir/f 5000 ||
13123 error "create 5k files failed"
13125 file_count=$(ls $DIR/$tdir/striped_dir | wc -l)
13127 [ "$file_count" = 5000 ] || error "file count $file_count != 5000"
13131 run_test 300c "chown && check ls under striped directory"
13134 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13135 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
13139 mkdir -p $DIR/$tdir
13140 $SETSTRIPE -c 2 $DIR/$tdir
13142 #local striped directory
13143 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir ||
13144 error "set striped dir error"
13145 createmany -o $DIR/$tdir/striped_dir/f 10 ||
13146 error "create 10 files failed"
13148 #remote striped directory
13149 $LFS setdirstripe -i 1 -c 2 $DIR/$tdir/remote_striped_dir ||
13150 error "set striped dir error"
13151 createmany -o $DIR/$tdir/remote_striped_dir/f 10 ||
13152 error "create 10 files failed"
13154 for file in $(find $DIR/$tdir); do
13155 stripe_count=$($GETSTRIPE -c $file)
13156 [ $stripe_count -eq 2 ] ||
13157 error "wrong stripe $stripe_count for $file"
13162 run_test 300d "check default stripe under striped directory"
13165 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13166 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
13170 mkdir -p $DIR/$tdir
13172 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir ||
13173 error "set striped dir error"
13175 touch $DIR/$tdir/striped_dir/a
13176 touch $DIR/$tdir/striped_dir/b
13177 touch $DIR/$tdir/striped_dir/c
13179 mkdir $DIR/$tdir/striped_dir/dir_a
13180 mkdir $DIR/$tdir/striped_dir/dir_b
13181 mkdir $DIR/$tdir/striped_dir/dir_c
13183 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir/stp_a ||
13184 error "set striped dir under striped dir error"
13186 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir/stp_b ||
13187 error "set striped dir under striped dir error"
13189 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir/stp_c ||
13190 error "set striped dir under striped dir error"
13192 mrename $DIR/$tdir/striped_dir/a $DIR/$tdir/striped_dir/b &&
13193 error "rename file under striped dir should fail"
13195 mrename $DIR/$tdir/striped_dir/dir_a $DIR/$tdir/striped_dir/dir_b &&
13196 error "rename dir under striped dir should fail"
13198 mrename $DIR/$tdir/striped_dir/stp_a $DIR/$tdir/striped_dir/stp_b &&
13199 error "rename dir under different stripes should fail"
13201 mrename $DIR/$tdir/striped_dir/a $DIR/$tdir/striped_dir/c ||
13202 error "rename file under striped dir should succeed"
13204 mrename $DIR/$tdir/striped_dir/dir_a $DIR/$tdir/striped_dir/dir_c ||
13205 error "rename dir under striped dir should succeed"
13209 run_test 300e "check rename under striped directory"
13212 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13213 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
13218 mkdir -p $DIR/$tdir
13220 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir ||
13221 error "set striped dir error"
13223 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir1 ||
13224 error "set striped dir error"
13226 touch $DIR/$tdir/striped_dir/a
13227 mkdir $DIR/$tdir/striped_dir/dir_a
13228 $LFS setdirstripe -i 0 -c 2 $DIR/$tdir/striped_dir/stp_a ||
13229 error "create striped dir under striped dir fails"
13231 touch $DIR/$tdir/striped_dir1/b
13232 mkdir $DIR/$tdir/striped_dir1/dir_b
13233 $LFS setdirstripe -i 0 -c 2 $DIR/$tdir/striped_dir/stp_b ||
13234 error "create striped dir under striped dir fails"
13236 mrename $DIR/$tdir/striped_dir/a $DIR/$tdir/striped_dir1/b &&
13237 error "rename file under different striped dir should fail"
13239 mrename $DIR/$tdir/striped_dir/dir_a $DIR/$tdir/striped_dir1/dir_b &&
13240 error "rename dir under different striped dir should fail"
13242 mrename $DIR/$tdir/striped_dir/stp_a $DIR/$tdir/striped_dir1/stp_b &&
13243 error "rename striped dir under diff striped dir should fail"
13245 mrename $DIR/$tdir/striped_dir/a $DIR/$tdir/striped_dir1/a ||
13246 error "rename file under diff striped dirs fails"
13248 mrename $DIR/$tdir/striped_dir/dir_a $DIR/$tdir/striped_dir1/dir_a ||
13249 error "rename dir under diff striped dirs fails"
13253 run_test 300f "check rename cross striped directory"
13255 test_300_check_default_striped_dir()
13258 local default_count=$2
13259 local default_index=$3
13262 local dir_stripe_index
13265 echo "checking $dirname $default_count $default_index"
13266 $LFS setdirstripe -D -c $default_count -i $default_index \
13267 -t all_char $DIR/$tdir/$dirname ||
13268 error "set default stripe on striped dir error"
13269 stripe_count=$($LFS getdirstripe -D -c $DIR/$tdir/$dirname)
13270 [ $stripe_count -eq $default_count ] ||
13271 error "expect $default_count get $stripe_count for $dirname"
13273 stripe_index=$($LFS getdirstripe -D -i $DIR/$tdir/$dirname)
13274 [ $stripe_index -eq $default_index ] ||
13275 error "expect $default_index get $stripe_index for $dirname"
13277 mkdir $DIR/$tdir/$dirname/{test1,test2,test3,test4} ||
13278 error "create dirs failed"
13280 createmany -o $DIR/$tdir/$dirname/f- 10 || error "create files failed"
13281 unlinkmany $DIR/$tdir/$dirname/f- 10 || error "unlink files failed"
13282 for dir in $(find $DIR/$tdir/$dirname/*); do
13283 stripe_count=$($LFS getdirstripe -c $dir)
13284 [ $stripe_count -eq $default_count ] ||
13285 error "stripe count $default_count != $stripe_count for $dir"
13287 stripe_index=$($LFS getdirstripe -i $dir)
13288 [ $default_index -eq -1 -o $stripe_index -eq $default_index ] ||
13289 error "$stripe_index != $default_index for $dir"
13291 #check default stripe
13292 stripe_count=$($LFS getdirstripe -D -c $dir)
13293 [ $stripe_count -eq $default_count ] ||
13294 error "default count $default_count != $stripe_count for $dir"
13296 stripe_index=$($LFS getdirstripe -D -i $dir)
13297 [ $stripe_index -eq $default_index ] ||
13298 error "default index $default_index != $stripe_index for $dir"
13300 rmdir $DIR/$tdir/$dirname/* || error "rmdir failed"
13304 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
13310 mkdir $DIR/$tdir/normal_dir
13312 test_300_check_default_striped_dir normal_dir $MDSCOUNT 1
13313 test_300_check_default_striped_dir normal_dir 1 0
13314 test_300_check_default_striped_dir normal_dir 2 1
13315 test_300_check_default_striped_dir normal_dir 2 -1
13317 #delete default stripe information
13318 echo "delete default stripeEA"
13319 $LFS setdirstripe -d $DIR/$tdir/normal_dir ||
13320 error "set default stripe on striped dir error"
13322 mkdir -p $DIR/$tdir/normal_dir/{test1,test2,test3,test4}
13323 for dir in $(find $DIR/$tdir/normal_dir/*); do
13324 stripe_count=$($LFS getdirstripe -c $dir)
13325 [ $stripe_count -eq 0 ] ||
13326 error "expect 1 get $stripe_count for $dir"
13327 stripe_index=$($LFS getdirstripe -i $dir)
13328 [ $stripe_index -eq 0 ] ||
13329 error "expect 0 get $stripe_index for $dir"
13332 run_test 300g "check default striped directory for normal directory"
13335 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
13340 $LFS setdirstripe -i 0 -c $MDSCOUNT -t all_char \
13341 $DIR/$tdir/striped_dir ||
13342 error "set striped dir error"
13344 test_300_check_default_striped_dir striped_dir $MDSCOUNT 1
13345 test_300_check_default_striped_dir striped_dir 1 0
13346 test_300_check_default_striped_dir striped_dir 2 1
13347 test_300_check_default_striped_dir striped_dir 2 -1
13349 #delete default stripe information
13350 $LFS setdirstripe -d $DIR/$tdir/striped_dir ||
13351 error "set default stripe on striped dir error"
13353 mkdir -p $DIR/$tdir/striped_dir/{test1,test2,test3,test4}
13354 for dir in $(find $DIR/$tdir/striped_dir/*); do
13355 stripe_count=$($LFS getdirstripe -c $dir)
13356 [ $stripe_count -eq 0 ] ||
13357 error "expect 1 get $stripe_count for $dir"
13360 run_test 300h "check default striped directory for striped directory"
13363 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13364 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
13370 $LFS setdirstripe -i 0 -c$MDSCOUNT -t all_char $DIR/$tdir/striped_dir ||
13371 error "set striped dir error"
13373 createmany -o $DIR/$tdir/striped_dir/f- 10 ||
13374 error "create files under striped dir failed"
13376 # unfortunately, we need to umount to clear dir layout cache for now
13377 # once we fully implement dir layout, we can drop this
13378 umount_client $MOUNT || error "umount failed"
13379 mount_client $MOUNT || error "mount failed"
13381 #set the stripe to be unknown hash type
13382 #define OBD_FAIL_UNKNOWN_LMV_STRIPE 0x1901
13383 $LCTL set_param fail_loc=0x1901
13384 for ((i = 0; i < 10; i++)); do
13385 $CHECKSTAT -t file $DIR/$tdir/striped_dir/f-$i ||
13386 error "stat f-$i failed"
13387 rm $DIR/$tdir/striped_dir/f-$i || error "unlink f-$i failed"
13390 touch $DIR/$tdir/striped_dir/f0 &&
13391 error "create under striped dir with unknown hash should fail"
13393 $LCTL set_param fail_loc=0
13395 umount_client $MOUNT || error "umount failed"
13396 mount_client $MOUNT || error "mount failed"
13400 run_test 300i "client handle unknown hash type striped directory"
13402 test_400a() { # LU-1606, was conf-sanity test_74
13403 local extra_flags=''
13404 local out=$TMP/$tfile
13405 local prefix=/usr/include/lustre
13408 if ! which $CC > /dev/null 2>&1; then
13409 skip_env "$CC is not installed"
13413 if ! [[ -d $prefix ]]; then
13414 # Assume we're running in tree and fixup the include path.
13415 extra_flags+=" -I$LUSTRE/../libcfs/include"
13416 extra_flags+=" -I$LUSTRE/include"
13417 extra_flags+=" -L$LUSTRE/utils"
13420 for prog in $LUSTRE_TESTS_API_DIR/*.c; do
13421 $CC -Wall -Werror $extra_flags -llustreapi -o $out $prog ||
13422 error "client api broken"
13425 run_test 400a "Lustre client api program can compile and link"
13427 test_400b() { # LU-1606, LU-5011
13429 local out=$TMP/$tfile
13430 local prefix=/usr/include/lustre
13432 # We use a hard coded prefix so that this test will not fail
13433 # when run in tree. There are headers in lustre/include/lustre/
13434 # that are not packaged (like lustre_idl.h) and have more
13435 # complicated include dependencies (like config.h and lnet/types.h).
13436 # Since this test about correct packaging we just skip them when
13437 # they don't exist (see below) rather than try to fixup cppflags.
13439 if ! which $CC > /dev/null 2>&1; then
13440 skip_env "$CC is not installed"
13444 for header in $prefix/*.h; do
13445 if ! [[ -f "$header" ]]; then
13449 if [[ "$(basename $header)" == liblustreapi.h ]]; then
13450 continue # liblustreapi.h is deprecated.
13453 $CC -Wall -Werror -include $header -c -x c /dev/null -o $out ||
13454 error "cannot compile '$header'"
13457 run_test 400b "packaged headers can be compiled"
13460 # tests that do cleanup/setup should be run at the end
13464 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13466 #define OBD_FAIL_MGC_PAUSE_PROCESS_LOG 0x903
13467 $LCTL set_param fail_loc=0x903
13469 cancel_lru_locks MGC
13471 FAIL_ON_ERROR=true cleanup
13472 FAIL_ON_ERROR=true setup
13474 run_test 900 "umount should not race with any mgc requeue thread"
13477 [ -f $EXT2_DEV ] && rm $EXT2_DEV || true
13478 check_and_cleanup_lustre
13479 if [ "$I_MOUNTED" != "yes" ]; then
13480 lctl set_param debug="$OLDDEBUG" 2> /dev/null || true