2 # -*- tab-width: 8; indent-tabs-mode: t; -*-
4 # Run select tests by setting ONLY, or as arguments to the script.
5 # Skip specific tests by setting EXCEPT.
7 # e.g. ONLY="22 23" or ONLY="`seq 32 39`" or EXCEPT="31"
11 # bug number for skipped test: 13297 2108 9789 3637 9789 3561 12622 5188
12 ALWAYS_EXCEPT=" 42a 42b 42c 42d 45 51d 68b $SANITY_EXCEPT"
13 # UPDATE THE COMMENT ABOVE WITH BUG NUMBERS WHEN CHANGING ALWAYS_EXCEPT!
15 # with LOD/OSP landing
16 # bug number for skipped tests: LU-2036
17 ALWAYS_EXCEPT=" 76 $ALWAYS_EXCEPT"
21 if [ -r /etc/SuSE-release ]
23 local vers=$(grep VERSION /etc/SuSE-release | awk '{print $3}')
24 local patchlev=$(grep PATCHLEVEL /etc/SuSE-release |
26 if [ $vers -eq 11 ] && [ $patchlev -ge 3 ]; then
33 if is_sles11; then # LU-4341
34 ALWAYS_EXCEPT="$ALWAYS_EXCEPT 170"
37 SRCDIR=$(cd $(dirname $0); echo $PWD)
38 export PATH=$PATH:/sbin
43 CHECKSTAT=${CHECKSTAT:-"checkstat -v"}
44 CREATETEST=${CREATETEST:-createtest}
46 LFIND=${LFIND:-"$LFS find"}
47 LVERIFY=${LVERIFY:-ll_dirstripe_verify}
49 OPENFILE=${OPENFILE:-openfile}
50 OPENUNLINK=${OPENUNLINK:-openunlink}
51 export MULTIOP=${MULTIOP:-multiop}
52 READS=${READS:-"reads"}
53 MUNLINK=${MUNLINK:-munlink}
54 SOCKETSERVER=${SOCKETSERVER:-socketserver}
55 SOCKETCLIENT=${SOCKETCLIENT:-socketclient}
56 MEMHOG=${MEMHOG:-memhog}
57 DIRECTIO=${DIRECTIO:-directio}
58 ACCEPTOR_PORT=${ACCEPTOR_PORT:-988}
60 CHECK_GRANT=${CHECK_GRANT:-"yes"}
61 GRANT_CHECK_LIST=${GRANT_CHECK_LIST:-""}
62 export PARALLEL=${PARALLEL:-"no"}
64 export NAME=${NAME:-local}
71 LUSTRE=${LUSTRE:-$(cd $(dirname $0)/..; echo $PWD)}
72 LUSTRE_TESTS_API_DIR=${LUSTRE_TESTS_API_DIR:-${LUSTRE}/tests/clientapi}
73 . $LUSTRE/tests/test-framework.sh
75 . ${CONFIG:=$LUSTRE/tests/cfg/${NAME}.sh}
78 [ "$SLOW" = "no" ] && EXCEPT_SLOW="24o 24D 27m 64b 68 71 77f 78 115 124b 300o"
80 if [ $(facet_fstype $SINGLEMDS) = "zfs" ]; then
81 # bug number for skipped test: LU-4536 LU-1957 LU-2805
82 ALWAYS_EXCEPT="$ALWAYS_EXCEPT 65ic 180 184c"
83 [ "$SLOW" = "no" ] && EXCEPT_SLOW="$EXCEPT_SLOW 51b 51ba"
90 pgrep ll_sa > /dev/null && { echo "There are ll_sa thread not exit!"; exit 20; }
91 cleanupall ${FORCE} $* || { echo "FAILed to clean up"; exit 20; }
100 check_swap_layouts_support()
102 $LCTL get_param -n llite.*.sbi_flags | grep -q layout ||
103 { skip "Does not support layout lock."; return 0; }
107 check_and_setup_lustre
112 MDT0=$($LCTL get_param -n mdc.*.mds_server_uuid |
113 awk '{ gsub(/_UUID/,""); print $1 }' | head -n1)
114 LOVNAME=$($LCTL get_param -n llite.*.lov.common_name | tail -n 1)
115 OSTCOUNT=$($LCTL get_param -n lov.$LOVNAME.numobd)
116 STRIPECOUNT=$($LCTL get_param -n lov.$LOVNAME.stripecount)
117 STRIPESIZE=$($LCTL get_param -n lov.$LOVNAME.stripesize)
118 ORIGFREE=$($LCTL get_param -n lov.$LOVNAME.kbytesavail)
119 MAXFREE=${MAXFREE:-$((200000 * $OSTCOUNT))}
121 [ -f $DIR/d52a/foo ] && chattr -a $DIR/d52a/foo
122 [ -f $DIR/d52b/foo ] && chattr -i $DIR/d52b/foo
123 rm -rf $DIR/[Rdfs][0-9]*
125 # $RUNAS_ID may get set incorrectly somewhere else
126 [ $UID -eq 0 -a $RUNAS_ID -eq 0 ] && error "\$RUNAS_ID set to 0, but \$UID is also 0!"
128 check_runas_id $RUNAS_ID $RUNAS_GID $RUNAS
132 if [ "${ONLY}" = "MOUNT" ] ; then
133 echo "Lustre is up, please go on"
137 echo "preparing for tests involving mounts"
138 EXT2_DEV=${EXT2_DEV:-$TMP/SANITY.LOOP}
140 mke2fs -j -F $EXT2_DEV 8000 > /dev/null
141 echo # add a newline after mke2fs.
145 OLDDEBUG=$(lctl get_param -n debug 2> /dev/null)
146 lctl set_param debug=-1 2> /dev/null || true
149 $CHECKSTAT -t file $DIR/$tfile || error "$tfile is not a file"
151 $CHECKSTAT -a $DIR/$tfile || error "$tfile was not removed"
153 run_test 0a "touch; rm ====================="
156 chmod 0755 $DIR || error "chmod 0755 $DIR failed"
157 $CHECKSTAT -p 0755 $DIR || error "$DIR permission is not 0755"
159 run_test 0b "chmod 0755 $DIR ============================="
162 $LCTL get_param mdc.*.import | grep "state: FULL" ||
163 error "import not FULL"
164 $LCTL get_param mdc.*.import | grep "target: $FSNAME-MDT" ||
167 run_test 0c "check import proc ============================="
170 test_mkdir -p $DIR/$tdir || error "mkdir $tdir failed"
171 test_mkdir -p $DIR/$tdir/d2 || error "mkdir $tdir/d2 failed"
172 test_mkdir $DIR/$tdir/d2 && error "we expect EEXIST, but not returned"
173 $CHECKSTAT -t dir $DIR/$tdir/d2 || error "$tdir/d2 is not a dir"
176 $CHECKSTAT -a $DIR/$tdir || error "$tdir was not removed"
178 run_test 1 "mkdir; remkdir; rmdir =============================="
181 test_mkdir -p $DIR/$tdir || error "mkdir $tdir failed"
182 touch $DIR/$tdir/$tfile || error "touch $tdir/$tfile failed"
183 $CHECKSTAT -t file $DIR/$tdir/$tfile || error "$tdir/$tfile not a file"
185 $CHECKSTAT -a $DIR/$tdir/$tfile || error "$tdir/$file is not removed"
187 run_test 2 "mkdir; touch; rmdir; check file ===================="
190 test_mkdir -p $DIR/$tdir || error "mkdir $tdir failed"
191 $CHECKSTAT -t dir $DIR/$tdir || error "$tdir is not a directory"
192 touch $DIR/$tdir/$tfile
193 $CHECKSTAT -t file $DIR/$tdir/$tfile || error "$tdir/$tfile not a file"
195 $CHECKSTAT -a $DIR/$tdir || error "$tdir is not removed"
197 run_test 3 "mkdir; touch; rmdir; check dir ====================="
199 # LU-4471 - failed rmdir on remote directories still removes directory on MDT0
203 test_mkdir $DIR/$tdir ||
204 error "Create remote directory failed"
206 touch $DIR/$tdir/$tfile ||
207 error "Create file under remote directory failed"
210 error "Expect error removing in-use dir $DIR/$tdir"
212 test -d $DIR/$tdir || error "Remote directory disappeared"
214 rm -rf $DIR/$tdir || error "remove remote dir error"
216 run_test 4 "mkdir; touch dir/file; rmdir; checkdir (expect error)"
219 test_mkdir -p $DIR/$tdir || error "mkdir $tdir failed"
220 test_mkdir $DIR/$tdir/d2 || error "mkdir $tdir/d2 failed"
221 chmod 0707 $DIR/$tdir/d2 || error "chmod 0707 $tdir/d2 failed"
222 $CHECKSTAT -t dir -p 0707 $DIR/$tdir/d2 || error "$tdir/d2 not mode 707"
223 $CHECKSTAT -t dir $DIR/$tdir/d2 || error "$tdir/d2 is not a directory"
225 run_test 5 "mkdir .../d5 .../d5/d2; chmod .../d5/d2 ============"
228 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
229 chmod 0666 $DIR/$tfile || error "chmod 0666 $tfile failed"
230 $CHECKSTAT -t file -p 0666 -u \#$UID $DIR/$tfile ||
231 error "$tfile does not have perm 0666 or UID $UID"
232 $RUNAS chmod 0444 $DIR/$tfile && error "chmod $tfile worked on UID $UID"
233 $CHECKSTAT -t file -p 0666 -u \#$UID $DIR/$tfile ||
234 error "$tfile should be 0666 and owned by UID $UID"
236 run_test 6a "touch f6a; chmod f6a; $RUNAS chmod f6a (should return error) =="
239 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID" && return
241 chown $RUNAS_ID $DIR/$tfile || error "chown $RUNAS_ID $file failed"
242 $CHECKSTAT -t file -u \#$RUNAS_ID $DIR/$tfile ||
243 error "$tfile should be owned by UID $RUNAS_ID"
244 $RUNAS chown $UID $DIR/$tfile && error "chown $UID $file succeeded"
245 $CHECKSTAT -t file -u \#$RUNAS_ID $DIR/$tfile ||
246 error "$tfile should be owned by UID $RUNAS_ID"
248 run_test 6c "touch f6c; chown f6c; $RUNAS chown f6c (should return error) =="
251 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID" && return
253 chgrp $RUNAS_ID $DIR/$tfile || error "chgrp $RUNAS_ID $file failed"
254 $CHECKSTAT -t file -u \#$UID -g \#$RUNAS_ID $DIR/$tfile ||
255 error "$tfile should be owned by GID $UID"
256 $RUNAS chgrp $UID $DIR/$tfile && error "chgrp $UID $file succeeded"
257 $CHECKSTAT -t file -u \#$UID -g \#$RUNAS_ID $DIR/$tfile ||
258 error "$tfile should be owned by UID $UID and GID $RUNAS_ID"
260 run_test 6e "touch f6e; chgrp f6e; $RUNAS chgrp f6e (should return error) =="
263 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID" && return
264 test_mkdir $DIR/$tdir || error "mkdir $tfile failed"
265 chmod 777 $DIR/$tdir || error "chmod 0777 $tdir failed"
266 $RUNAS mkdir $DIR/$tdir/d || error "mkdir $tdir/d failed"
267 chmod g+s $DIR/$tdir/d || error "chmod g+s $tdir/d failed"
268 test_mkdir $DIR/$tdir/d/subdir || error "mkdir $tdir/d/subdir failed"
269 $CHECKSTAT -g \#$RUNAS_GID $DIR/$tdir/d/subdir ||
270 error "$tdir/d/subdir should be GID $RUNAS_GID"
272 run_test 6g "Is new dir in sgid dir inheriting group?"
274 test_6h() { # bug 7331
275 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID" && return
276 touch $DIR/$tfile || error "touch failed"
277 chown $RUNAS_ID:$RUNAS_GID $DIR/$tfile || error "initial chown failed"
278 $RUNAS -G$RUNAS_GID chown $RUNAS_ID:0 $DIR/$tfile &&
279 error "chown $RUNAS_ID:0 $tfile worked as GID $RUNAS_GID"
280 $CHECKSTAT -t file -u \#$RUNAS_ID -g \#$RUNAS_GID $DIR/$tfile ||
281 error "$tdir/$tfile should be UID $RUNAS_UID GID $RUNAS_GID"
283 run_test 6h "$RUNAS chown RUNAS_ID.0 .../f6h (should return error)"
286 test_mkdir $DIR/$tdir
287 $MCREATE $DIR/$tdir/$tfile
288 chmod 0666 $DIR/$tdir/$tfile
289 $CHECKSTAT -t file -p 0666 $DIR/$tdir/$tfile ||
290 error "$tdir/$tfile should be mode 0666"
292 run_test 7a "mkdir .../d7; mcreate .../d7/f; chmod .../d7/f ===="
295 if [ ! -d $DIR/$tdir ]; then
296 test_mkdir $DIR/$tdir
298 $MCREATE $DIR/$tdir/$tfile
299 echo -n foo > $DIR/$tdir/$tfile
300 [ "$(cat $DIR/$tdir/$tfile)" = "foo" ] || error "$tdir/$tfile not 'foo'"
301 $CHECKSTAT -t file -s 3 $DIR/$tdir/$tfile || error "$tfile size not 3"
303 run_test 7b "mkdir .../d7; mcreate d7/f2; echo foo > d7/f2 ====="
306 test_mkdir $DIR/$tdir
307 touch $DIR/$tdir/$tfile
308 chmod 0666 $DIR/$tdir/$tfile
309 $CHECKSTAT -t file -p 0666 $DIR/$tdir/$tfile ||
310 error "$tfile mode not 0666"
312 run_test 8 "mkdir .../d8; touch .../d8/f; chmod .../d8/f ======="
315 test_mkdir $DIR/$tdir
316 test_mkdir $DIR/$tdir/d2
317 test_mkdir $DIR/$tdir/d2/d3
318 $CHECKSTAT -t dir $DIR/$tdir/d2/d3 || error "$tdir/d2/d3 not a dir"
320 run_test 9 "mkdir .../d9 .../d9/d2 .../d9/d2/d3 ================"
323 test_mkdir $DIR/$tdir
324 test_mkdir $DIR/$tdir/d2
325 touch $DIR/$tdir/d2/$tfile
326 $CHECKSTAT -t file $DIR/$tdir/d2/$tfile ||
327 error "$tdir/d2/$tfile not a file"
329 run_test 10 "mkdir .../d10 .../d10/d2; touch .../d10/d2/f ======"
332 test_mkdir $DIR/$tdir
333 test_mkdir $DIR/$tdir/d2
334 chmod 0666 $DIR/$tdir/d2
335 chmod 0705 $DIR/$tdir/d2
336 $CHECKSTAT -t dir -p 0705 $DIR/$tdir/d2 ||
337 error "$tdir/d2 mode not 0705"
339 run_test 11 "mkdir .../d11 d11/d2; chmod .../d11/d2 ============"
342 test_mkdir $DIR/$tdir
343 touch $DIR/$tdir/$tfile
344 chmod 0666 $DIR/$tdir/$tfile
345 chmod 0654 $DIR/$tdir/$tfile
346 $CHECKSTAT -t file -p 0654 $DIR/$tdir/$tfile ||
347 error "$tdir/d2 mode not 0654"
349 run_test 12 "touch .../d12/f; chmod .../d12/f .../d12/f ========"
352 test_mkdir $DIR/$tdir
353 dd if=/dev/zero of=$DIR/$tdir/$tfile count=10
355 $CHECKSTAT -t file -s 0 $DIR/$tdir/$tfile ||
356 error "$tdir/$tfile size not 0 after truncate"
358 run_test 13 "creat .../d13/f; dd .../d13/f; > .../d13/f ========"
361 test_mkdir $DIR/$tdir
362 touch $DIR/$tdir/$tfile
364 $CHECKSTAT -a $DIR/$tdir/$tfile || error "$tdir/$tfile not removed"
366 run_test 14 "touch .../d14/f; rm .../d14/f; rm .../d14/f ======="
369 test_mkdir $DIR/$tdir
370 touch $DIR/$tdir/$tfile
371 mv $DIR/$tdir/$tfile $DIR/$tdir/${tfile}_2
372 $CHECKSTAT -t file $DIR/$tdir/${tfile}_2 ||
373 error "$tdir/${tfile_2} not a file after rename"
374 rm $DIR/$tdir/${tfile}_2 || error "unlink failed after rename"
376 run_test 15 "touch .../d15/f; mv .../d15/f .../d15/f2 =========="
379 test_mkdir $DIR/$tdir
380 touch $DIR/$tdir/$tfile
381 rm -rf $DIR/$tdir/$tfile
382 $CHECKSTAT -a $DIR/$tdir/$tfile || error "$tdir/$tfile not removed"
384 run_test 16 "touch .../d16/f; rm -rf .../d16/f ================="
387 test_mkdir -p $DIR/$tdir
388 touch $DIR/$tdir/$tfile
389 ln -s $DIR/$tdir/$tfile $DIR/$tdir/l-exist
391 $CHECKSTAT -l $DIR/$tdir/$tfile $DIR/$tdir/l-exist ||
392 error "$tdir/l-exist not a symlink"
393 $CHECKSTAT -f -t f $DIR/$tdir/l-exist ||
394 error "$tdir/l-exist not referencing a file"
395 rm -f $DIR/$tdir/l-exist
396 $CHECKSTAT -a $DIR/$tdir/l-exist || error "$tdir/l-exist not removed"
398 run_test 17a "symlinks: create, remove (real) =================="
401 test_mkdir -p $DIR/$tdir
402 ln -s no-such-file $DIR/$tdir/l-dangle
404 $CHECKSTAT -l no-such-file $DIR/$tdir/l-dangle ||
405 error "$tdir/l-dangle not referencing no-such-file"
406 $CHECKSTAT -fa $DIR/$tdir/l-dangle ||
407 error "$tdir/l-dangle not referencing non-existent file"
408 rm -f $DIR/$tdir/l-dangle
409 $CHECKSTAT -a $DIR/$tdir/l-dangle || error "$tdir/l-dangle not removed"
411 run_test 17b "symlinks: create, remove (dangling) =============="
413 test_17c() { # bug 3440 - don't save failed open RPC for replay
414 test_mkdir -p $DIR/$tdir
415 ln -s foo $DIR/$tdir/$tfile
416 cat $DIR/$tdir/$tfile && error "opened non-existent symlink" || true
418 run_test 17c "symlinks: open dangling (should return error) ===="
421 test_mkdir -p $DIR/$tdir
422 ln -s foo $DIR/$tdir/$tfile
423 touch $DIR/$tdir/$tfile || error "creating to new symlink"
425 run_test 17d "symlinks: create dangling ========================"
428 test_mkdir -p $DIR/$tdir
429 local foo=$DIR/$tdir/$tfile
430 ln -s $foo $foo || error "create symlink failed"
431 ls -l $foo || error "ls -l failed"
432 ls $foo && error "ls not failed" || true
434 run_test 17e "symlinks: create recursive symlink (should return error) ===="
437 test_mkdir -p $DIR/$tdir
438 ln -s 1234567890/2234567890/3234567890/4234567890 $DIR/$tdir/111
439 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890 $DIR/$tdir/222
440 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890 $DIR/$tdir/333
441 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890/9234567890/a234567890/b234567890 $DIR/$tdir/444
442 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890/9234567890/a234567890/b234567890/c234567890/d234567890/f234567890 $DIR/$tdir/555
443 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
446 run_test 17f "symlinks: long and very long symlink name ========================"
448 # str_repeat(S, N) generate a string that is string S repeated N times
453 while [ $((n -= 1)) -ge 0 ]; do
459 # Long symlinks and LU-2241
461 test_mkdir -p $DIR/$tdir
462 local TESTS="59 60 61 4094 4095"
464 # Fix for inode size boundary in 2.1.4
465 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.1.4) ] &&
468 # Patch not applied to 2.2 or 2.3 branches
469 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] &&
470 [ $(lustre_version_code $SINGLEMDS) -le $(version_code 2.3.55) ] &&
473 # skip long symlink name for rhel6.5.
474 # rhel6.5 has a limit (PATH_MAX - sizeof(struct filename))
475 grep -q '6.5' /etc/redhat-release &>/dev/null &&
476 TESTS="59 60 61 4062 4063"
479 local SYMNAME=$(str_repeat 'x' $i)
480 ln -s $SYMNAME $DIR/$tdir/f$i || error "failed $i-char symlink"
481 readlink $DIR/$tdir/f$i || error "failed $i-char readlink"
484 run_test 17g "symlinks: really long symlink name and inode boundaries"
486 test_17h() { #bug 17378
487 remote_mds_nodsh && skip "remote MDS with nodsh" && return
488 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
490 test_mkdir -p $DIR/$tdir
491 if [[ $MDSCOUNT -gt 1 ]]; then
492 mdt_idx=$($LFS getdirstripe -i $DIR/$tdir)
496 $SETSTRIPE -c -1 $DIR/$tdir
497 #define OBD_FAIL_MDS_LOV_PREP_CREATE 0x141
498 do_facet mds$((mdt_idx + 1)) lctl set_param fail_loc=0x80000141
499 touch $DIR/$tdir/$tfile || true
501 run_test 17h "create objects: lov_free_memmd() doesn't lbug"
503 test_17i() { #bug 20018
504 remote_mds_nodsh && skip "remote MDS with nodsh" && return
505 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
506 test_mkdir -c1 $DIR/$tdir
507 local foo=$DIR/$tdir/$tfile
509 if [[ $MDSCOUNT -gt 1 ]]; then
510 mdt_idx=$($LFS getdirstripe -i $DIR/$tdir)
514 ln -s $foo $foo || error "create symlink failed"
515 #define OBD_FAIL_MDS_READLINK_EPROTO 0x143
516 do_facet mds$((mdt_idx + 1)) lctl set_param fail_loc=0x80000143
517 ls -l $foo && error "error not detected"
520 run_test 17i "don't panic on short symlink"
522 test_17k() { #bug 22301
523 [[ -z "$(which rsync 2>/dev/null)" ]] &&
524 skip "no rsync command" && return 0
525 rsync --help | grep -q xattr ||
526 skip_env "$(rsync --version | head -n1) does not support xattrs"
527 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return 0
528 test_mkdir -p $DIR/$tdir
529 test_mkdir -p $DIR/$tdir.new
530 touch $DIR/$tdir/$tfile
531 ln -s $DIR/$tdir/$tfile $DIR/$tdir/$tfile.lnk
532 rsync -av -X $DIR/$tdir/ $DIR/$tdir.new ||
533 error "rsync failed with xattrs enabled"
535 run_test 17k "symlinks: rsync with xattrs enabled ========================="
537 test_17l() { # LU-279
538 [[ -z "$(which getfattr 2>/dev/null)" ]] &&
539 skip "no getfattr command" && return 0
540 test_mkdir -p $DIR/$tdir
541 touch $DIR/$tdir/$tfile
542 ln -s $DIR/$tdir/$tfile $DIR/$tdir/$tfile.lnk
543 for path in "$DIR/$tdir" "$DIR/$tdir/$tfile" "$DIR/$tdir/$tfile.lnk"; do
544 # -h to not follow symlinks. -m '' to list all the xattrs.
545 # grep to remove first line: '# file: $path'.
546 for xattr in `getfattr -hm '' $path 2>/dev/null | grep -v '^#'`;
548 lgetxattr_size_check $path $xattr ||
549 error "lgetxattr_size_check $path $xattr failed"
553 run_test 17l "Ensure lgetxattr's returned xattr size is consistent ========"
557 local short_sym="0123456789"
558 local WDIR=$DIR/${tdir}m
565 remote_mds_nodsh && skip "remote MDS with nodsh" && return
566 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] &&
567 [ $(lustre_version_code $SINGLEMDS) -le $(version_code 2.2.93) ] &&
568 skip "MDS 2.2.0-2.2.93 do not NUL-terminate symlinks" && return
570 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
571 skip "only for ldiskfs MDT" && return 0
573 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
577 # create a long symlink file
578 for ((i = 0; i < 4; ++i)); do
579 long_sym=${long_sym}${long_sym}
582 echo "create 512 short and long symlink files under $WDIR"
583 for ((i = 0; i < 256; ++i)); do
584 ln -sf ${long_sym}"a5a5" $WDIR/long-$i
585 ln -sf ${short_sym}"a5a5" $WDIR/short-$i
591 wait_delete_completed
593 echo "recreate the 512 symlink files with a shorter string"
594 for ((i = 0; i < 512; ++i)); do
595 # rewrite the symlink file with a shorter string
596 ln -sf ${long_sym} $WDIR/long-$i
597 ln -sf ${short_sym} $WDIR/short-$i
600 mds_index=$($LFS getstripe -M $WDIR)
601 mds_index=$((mds_index+1))
602 devname=$(mdsdevname $mds_index)
603 cmd="$E2FSCK -fnvd $devname"
605 echo "stop and checking mds${mds_index}: $cmd"
606 # e2fsck should not return error
608 do_facet mds${mds_index} $cmd || rc=$?
610 start mds${mds_index} $devname $MDS_MOUNT_OPTS || error "start failed"
611 df $MOUNT > /dev/null 2>&1
612 [ $rc -ne 0 ] && error "e2fsck should not report error upon "\
613 "short/long symlink MDT: rc=$rc"
616 run_test 17m "run e2fsck against MDT which contains short/long symlink"
618 check_fs_consistency_17n() {
624 # create/unlink in 17n only change 2 MDTs(MDT1/MDT2),
625 # so it only check MDT1/MDT2 instead of all of MDTs.
626 for mdt_index in $(seq 1 2); do
627 devname=$(mdsdevname $mdt_index)
628 cmd="$E2FSCK -fnvd $devname"
630 echo "stop and checking mds${mdt_index}: $cmd"
631 # e2fsck should not return error
633 do_facet mds${mdt_index} $cmd || rc=$?
635 start mds${mdt_index} $devname $MDS_MOUNT_OPTS ||
636 error "mount mds${mdt_index} failed"
637 df $MOUNT > /dev/null 2>&1
638 [ $rc -ne 0 ] && break
646 remote_mds_nodsh && skip "remote MDS with nodsh" && return
647 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] &&
648 [ $(lustre_version_code $SINGLEMDS) -le $(version_code 2.2.93) ] &&
649 skip "MDS 2.2.0-2.2.93 do not NUL-terminate symlinks" && return
651 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
652 skip "only for ldiskfs MDT" && return 0
654 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 2 MDTs" && return
656 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
658 test_mkdir $DIR/$tdir
659 for ((i=0; i<10; i++)); do
660 $LFS mkdir -i1 -c2 $DIR/$tdir/remote_dir_${i} ||
661 error "create remote dir error $i"
662 createmany -o $DIR/$tdir/remote_dir_${i}/f 10 ||
663 error "create files under remote dir failed $i"
666 check_fs_consistency_17n ||
667 error "e2fsck report error after create files under remote dir"
669 for ((i = 0; i < 10; i++)); do
670 rm -rf $DIR/$tdir/remote_dir_${i} ||
671 error "destroy remote dir error $i"
674 check_fs_consistency_17n ||
675 error "e2fsck report error after unlink files under remote dir"
677 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.50) ] &&
678 skip "lustre < 2.4.50 does not support migrate mv " && return
680 for ((i = 0; i < 10; i++)); do
681 mkdir -p $DIR/$tdir/remote_dir_${i}
682 createmany -o $DIR/$tdir/remote_dir_${i}/f 10 ||
683 error "create files under remote dir failed $i"
684 $LFS migrate --mdt-index 1 $DIR/$tdir/remote_dir_${i} ||
685 error "migrate remote dir error $i"
687 check_fs_consistency_17n || error "e2fsck report error after migration"
689 for ((i = 0; i < 10; i++)); do
690 rm -rf $DIR/$tdir/remote_dir_${i} ||
691 error "destroy remote dir error $i"
694 check_fs_consistency_17n || error "e2fsck report error after unlink"
696 run_test 17n "run e2fsck against master/slave MDT which contains remote dir"
699 remote_mds_nodsh && skip "remote MDS with nodsh" && return
700 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.3.64) ] &&
701 skip "Need MDS version at least 2.3.64" && return
703 local WDIR=$DIR/${tdir}o
708 mdt_index=$($LFS getstripe -M $WDIR)
709 mdt_index=$((mdt_index+1))
713 #fail mds will wait the failover finish then set
714 #following fail_loc to avoid interfer the recovery process.
717 #define OBD_FAIL_OSD_LMA_INCOMPAT 0x194
718 do_facet mds${mdt_index} lctl set_param fail_loc=0x194
719 ls -l $WDIR/$tfile && rc=1
720 do_facet mds${mdt_index} lctl set_param fail_loc=0
721 [[ $rc -ne 0 ]] && error "stat file should fail"
724 run_test 17o "stat file with incompat LMA feature"
727 touch $DIR/$tfile || error "Failed to touch $DIR/$tfile: $?"
728 ls $DIR || error "Failed to ls $DIR: $?"
730 run_test 18 "touch .../f ; ls ... =============================="
736 $CHECKSTAT -a $DIR/$tfile || error "$tfile was not removed"
738 run_test 19a "touch .../f19 ; ls -l ... ; rm .../f19 ==========="
741 ls -l $DIR/$tfile && error "ls -l $tfile failed"|| true
743 run_test 19b "ls -l .../f19 (should return error) =============="
746 [ $RUNAS_ID -eq $UID ] &&
747 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
748 $RUNAS touch $DIR/$tfile && error "create non-root file failed" || true
750 run_test 19c "$RUNAS touch .../f19 (should return error) =="
753 cat $DIR/f19 && error || true
755 run_test 19d "cat .../f19 (should return error) =============="
767 $CHECKSTAT -a $DIR/$tfile || error "$tfile was not removed"
769 run_test 20 "touch .../f ; ls -l ... ==========================="
772 test_mkdir -p $DIR/$tdir
773 [ -f $DIR/$tdir/dangle ] && rm -f $DIR/$tdir/dangle
774 ln -s dangle $DIR/$tdir/link
775 echo foo >> $DIR/$tdir/link
776 cat $DIR/$tdir/dangle
777 $CHECKSTAT -t link $DIR/$tdir/link || error "$tdir/link not a link"
778 $CHECKSTAT -f -t file $DIR/$tdir/link ||
779 error "$tdir/link not linked to a file"
781 run_test 21 "write to dangling link ============================"
785 test_mkdir -p $DIR/$tdir
786 chown $RUNAS_ID:$RUNAS_GID $WDIR
787 (cd $WDIR || error "cd $WDIR failed";
788 $RUNAS tar cf - /etc/hosts /etc/sysconfig/network | \
790 ls -lR $WDIR/etc || error "ls -lR $WDIR/etc failed"
791 $CHECKSTAT -t dir $WDIR/etc || error "checkstat -t dir failed"
792 $CHECKSTAT -u \#$RUNAS_ID -g \#$RUNAS_GID $WDIR/etc || error "checkstat -u failed"
794 run_test 22 "unpack tar archive as non-root user ==============="
798 test_mkdir -p $DIR/$tdir
799 local file=$DIR/$tdir/$tfile
801 openfile -f O_CREAT:O_EXCL $file || error "$file create failed"
802 openfile -f O_CREAT:O_EXCL $file &&
803 error "$file recreate succeeded" || true
805 run_test 23a "O_CREAT|O_EXCL in subdir =========================="
807 test_23b() { # bug 18988
808 test_mkdir -p $DIR/$tdir
809 local file=$DIR/$tdir/$tfile
812 echo foo > $file || error "write filed"
813 echo bar >> $file || error "append filed"
814 $CHECKSTAT -s 8 $file || error "wrong size"
817 run_test 23b "O_APPEND check =========================="
821 echo '-- same directory rename'
822 test_mkdir $DIR/$tdir
823 touch $DIR/$tdir/$tfile.1
824 mv $DIR/$tdir/$tfile.1 $DIR/$tdir/$tfile.2
825 $CHECKSTAT -t file $DIR/$tdir/$tfile.2 || error "$tfile.2 not a file"
827 run_test 24a "rename file to non-existent target"
830 test_mkdir $DIR/$tdir
831 touch $DIR/$tdir/$tfile.{1,2}
832 mv $DIR/$tdir/$tfile.1 $DIR/$tdir/$tfile.2
833 $CHECKSTAT -a $DIR/$tdir/$tfile.1 || error "$tfile.1 exists"
834 $CHECKSTAT -t file $DIR/$tdir/$tfile.2 || error "$tfile.2 not a file"
836 run_test 24b "rename file to existing target"
839 test_mkdir $DIR/$tdir
840 test_mkdir $DIR/$tdir/d$testnum.1
841 mv $DIR/$tdir/d$testnum.1 $DIR/$tdir/d$testnum.2
842 $CHECKSTAT -a $DIR/$tdir/d$testnum.1 || error "d$testnum.1 exists"
843 $CHECKSTAT -t dir $DIR/$tdir/d$testnum.2 || error "d$testnum.2 not dir"
845 run_test 24c "rename directory to non-existent target"
848 test_mkdir -c1 $DIR/$tdir
849 test_mkdir -c1 $DIR/$tdir/d$testnum.1
850 test_mkdir -c1 $DIR/$tdir/d$testnum.2
851 mrename $DIR/$tdir/d$testnum.1 $DIR/$tdir/d$testnum.2
852 $CHECKSTAT -a $DIR/$tdir/d$testnum.1 || error "d$testnum.1 exists"
853 $CHECKSTAT -t dir $DIR/$tdir/d$testnum.2 || error "d$testnum.2 not dir"
855 run_test 24d "rename directory to existing target"
858 echo '-- cross directory renames --'
862 mv $DIR/R5a/f $DIR/R5b/g
863 $CHECKSTAT -a $DIR/R5a/f || error
864 $CHECKSTAT -t file $DIR/R5b/g || error
866 run_test 24e "touch .../R5a/f; rename .../R5a/f .../R5b/g ======"
871 touch $DIR/R6a/f $DIR/R6b/g
872 mv $DIR/R6a/f $DIR/R6b/g
873 $CHECKSTAT -a $DIR/R6a/f || error
874 $CHECKSTAT -t file $DIR/R6b/g || error
876 run_test 24f "touch .../R6a/f R6b/g; mv .../R6a/f .../R6b/g ===="
881 test_mkdir $DIR/R7a/d
882 mv $DIR/R7a/d $DIR/R7b/e
883 $CHECKSTAT -a $DIR/R7a/d || error
884 $CHECKSTAT -t dir $DIR/R7b/e || error
886 run_test 24g "mkdir .../R7{a,b}/d; mv .../R7a/d .../R7b/e ======"
889 test_mkdir -c1 $DIR/R8a
890 test_mkdir -c1 $DIR/R8b
891 test_mkdir -c1 $DIR/R8a/d
892 test_mkdir -c1 $DIR/R8b/e
893 mrename $DIR/R8a/d $DIR/R8b/e
894 $CHECKSTAT -a $DIR/R8a/d || error
895 $CHECKSTAT -t dir $DIR/R8b/e || error
897 run_test 24h "mkdir .../R8{a,b}/{d,e}; rename .../R8a/d .../R8b/e"
900 echo "-- rename error cases"
904 mrename $DIR/R9/f $DIR/R9/a
905 $CHECKSTAT -t file $DIR/R9/f || error
906 $CHECKSTAT -t dir $DIR/R9/a || error
907 $CHECKSTAT -a $DIR/R9/a/f || error
909 run_test 24i "rename file to dir error: touch f ; mkdir a ; rename f a"
913 mrename $DIR/R10/f $DIR/R10/g
914 $CHECKSTAT -t dir $DIR/R10 || error
915 $CHECKSTAT -a $DIR/R10/f || error
916 $CHECKSTAT -a $DIR/R10/g || error
918 run_test 24j "source does not exist ============================"
922 test_mkdir $DIR/R11a/d
924 mv $DIR/R11a/f $DIR/R11a/d
925 $CHECKSTAT -a $DIR/R11a/f || error
926 $CHECKSTAT -t file $DIR/R11a/d/f || error
928 run_test 24k "touch .../R11a/f; mv .../R11a/f .../R11a/d ======="
930 # bug 2429 - rename foo foo foo creates invalid file
933 $MULTIOP $f OcNs || error
935 run_test 24l "Renaming a file to itself ========================"
939 $MULTIOP $f OcLN ${f}2 ${f}2 || error "link ${f}2 ${f}2 failed"
940 # on ext3 this does not remove either the source or target files
941 # though the "expected" operation would be to remove the source
942 $CHECKSTAT -t file ${f} || error "${f} missing"
943 $CHECKSTAT -t file ${f}2 || error "${f}2 missing"
945 run_test 24m "Renaming a file to a hard link to itself ========="
949 # this stats the old file after it was renamed, so it should fail
953 $CHECKSTAT ${f}.rename
956 run_test 24n "Statting the old file after renaming (Posix rename 2)"
959 test_mkdir -p $DIR/d24o
960 rename_many -s random -v -n 10 $DIR/d24o
962 run_test 24o "rename of files during htree split ==============="
967 DIRINO=`ls -lid $DIR/R12a | awk '{ print $1 }'`
968 mrename $DIR/R12a $DIR/R12b
969 $CHECKSTAT -a $DIR/R12a || error
970 $CHECKSTAT -t dir $DIR/R12b || error
971 DIRINO2=`ls -lid $DIR/R12b | awk '{ print $1 }'`
972 [ "$DIRINO" = "$DIRINO2" ] || error "R12a $DIRINO != R12b $DIRINO2"
974 run_test 24p "mkdir .../R12{a,b}; rename .../R12a .../R12b"
976 cleanup_multiop_pause() {
982 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
985 local DIRINO=$(ls -lid $DIR/R13a | awk '{ print $1 }')
986 multiop_bg_pause $DIR/R13b D_c || error "multiop failed to start"
989 trap cleanup_multiop_pause EXIT
990 mrename $DIR/R13a $DIR/R13b
991 $CHECKSTAT -a $DIR/R13a || error "R13a still exists"
992 $CHECKSTAT -t dir $DIR/R13b || error "R13b does not exist"
993 local DIRINO2=$(ls -lid $DIR/R13b | awk '{ print $1 }')
994 [ "$DIRINO" = "$DIRINO2" ] || error "R13a $DIRINO != R13b $DIRINO2"
995 cleanup_multiop_pause
996 wait $MULTIPID || error "multiop close failed"
998 run_test 24q "mkdir .../R13{a,b}; open R13b rename R13a R13b ==="
1000 test_24r() { #bug 3789
1001 test_mkdir $DIR/R14a
1002 test_mkdir $DIR/R14a/b
1003 mrename $DIR/R14a $DIR/R14a/b && error "rename to subdir worked!"
1004 $CHECKSTAT -t dir $DIR/R14a || error "$DIR/R14a missing"
1005 $CHECKSTAT -t dir $DIR/R14a/b || error "$DIR/R14a/b missing"
1007 run_test 24r "mkdir .../R14a/b; rename .../R14a .../R14a/b ====="
1010 test_mkdir $DIR/R15a
1011 test_mkdir $DIR/R15a/b
1012 test_mkdir $DIR/R15a/b/c
1013 mrename $DIR/R15a $DIR/R15a/b/c && error "rename to sub-subdir worked!"
1014 $CHECKSTAT -t dir $DIR/R15a || error "$DIR/R15a missing"
1015 $CHECKSTAT -t dir $DIR/R15a/b/c || error "$DIR/R15a/b/c missing"
1017 run_test 24s "mkdir .../R15a/b/c; rename .../R15a .../R15a/b/c ="
1019 test_mkdir $DIR/R16a
1020 test_mkdir $DIR/R16a/b
1021 test_mkdir $DIR/R16a/b/c
1022 mrename $DIR/R16a/b/c $DIR/R16a && error "rename to sub-subdir worked!"
1023 $CHECKSTAT -t dir $DIR/R16a || error "$DIR/R16a missing"
1024 $CHECKSTAT -t dir $DIR/R16a/b/c || error "$DIR/R16a/b/c missing"
1026 run_test 24t "mkdir .../R16a/b/c; rename .../R16a/b/c .../R16a ="
1028 test_24u() { # bug12192
1029 $MULTIOP $DIR/$tfile C2w$((2048 * 1024))c || error
1030 $CHECKSTAT -s $((2048 * 1024)) $DIR/$tfile || error "wrong file size"
1032 run_test 24u "create stripe file"
1038 simple_cleanup_common() {
1041 wait_delete_completed
1044 max_pages_per_rpc() {
1045 $LCTL get_param -n mdc.*.max_pages_per_rpc | head -n1
1049 local NRFILES=100000
1050 local FREE_INODES=$(mdt_free_inodes 0)
1051 [[ $FREE_INODES -lt $NRFILES ]] &&
1052 skip "not enough free inodes $FREE_INODES required $NRFILES" &&
1055 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1056 trap simple_cleanup_common EXIT
1058 # Performance issue on ZFS see LU-4072 (c.f. LU-2887)
1059 [ $(facet_fstype $SINGLEMDS) = "zfs" ] && NRFILES=10000
1061 test_mkdir -p $DIR/$tdir
1062 createmany -m $DIR/$tdir/$tfile $NRFILES
1064 cancel_lru_locks mdc
1065 lctl set_param mdc.*.stats clear
1067 ls $DIR/$tdir >/dev/null || error "error in listing large dir"
1069 # LU-5 large readdir
1070 # DIRENT_SIZE = 32 bytes for sizeof(struct lu_dirent) +
1071 # 8 bytes for name(filename is mostly 5 in this test) +
1072 # 8 bytes for luda_type
1073 # take into account of overhead in lu_dirpage header and end mark in
1074 # each page, plus one in RPC_NUM calculation.
1076 RPC_SIZE=$(($(max_pages_per_rpc) * $(page_size)))
1077 RPC_NUM=$(((NRFILES * DIRENT_SIZE + RPC_SIZE - 1) / RPC_SIZE + 1))
1078 mds_readpage=$(lctl get_param mdc.*MDT0000*.stats |
1079 awk '/^mds_readpage/ {print $2}')
1080 [[ $mds_readpage -gt $RPC_NUM ]] &&
1081 error "large readdir doesn't take effect"
1083 simple_cleanup_common
1085 run_test 24v "list directory with large files (handle hash collision, bug: 17560)"
1087 test_24w() { # bug21506
1089 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=4096 || return 1
1090 dd if=/dev/zero bs=$SZ1 count=1 >> $DIR/$tfile || return 2
1091 dd if=$DIR/$tfile of=$DIR/${tfile}_left bs=1M skip=4097 || return 3
1092 SZ2=`ls -l $DIR/${tfile}_left | awk '{print $5}'`
1093 [[ "$SZ1" -eq "$SZ2" ]] ||
1094 error "Error reading at the end of the file $tfile"
1096 run_test 24w "Reading a file larger than 4Gb"
1099 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 2 MDTs" && return
1100 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1102 local remote_dir=$DIR/$tdir/remote_dir
1104 test_mkdir -p $DIR/$tdir
1105 $LFS mkdir -i $MDTIDX $remote_dir ||
1106 error "create remote directory failed"
1108 test_mkdir -p $DIR/$tdir/src_dir
1109 touch $DIR/$tdir/src_file
1110 test_mkdir -p $remote_dir/tgt_dir
1111 touch $remote_dir/tgt_file
1113 mrename $DIR/$tdir/src_dir $remote_dir/tgt_dir ||
1114 error "rename dir cross MDT failed!"
1116 mrename $DIR/$tdir/src_file $remote_dir/tgt_file ||
1117 error "rename file cross MDT failed!"
1119 touch $DIR/$tdir/ln_file
1120 ln $DIR/$tdir/ln_file $remote_dir/ln_name ||
1121 error "ln file cross MDT failed"
1123 rm -rf $DIR/$tdir || error "Can not delete directories"
1125 run_test 24x "cross MDT rename/link"
1128 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 2 MDTs" && return
1129 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1131 local remote_dir=$DIR/$tdir/remote_dir
1133 test_mkdir -p $DIR/$tdir
1134 $LFS mkdir -i $MDTIDX $remote_dir ||
1135 error "create remote directory failed"
1137 test_mkdir -p $remote_dir/src_dir
1138 touch $remote_dir/src_file
1139 test_mkdir -p $remote_dir/tgt_dir
1140 touch $remote_dir/tgt_file
1142 mrename $remote_dir/src_dir $remote_dir/tgt_dir ||
1143 error "rename subdir in the same remote dir failed!"
1145 mrename $remote_dir/src_file $remote_dir/tgt_file ||
1146 error "rename files in the same remote dir failed!"
1148 ln $remote_dir/tgt_file $remote_dir/tgt_file1 ||
1149 error "link files in the same remote dir failed!"
1151 rm -rf $DIR/$tdir || error "Can not delete directories"
1153 run_test 24y "rename/link on the same dir should succeed"
1155 test_24A() { # LU-3182
1159 test_mkdir -p $DIR/$tdir
1160 createmany -m $DIR/$tdir/$tfile $NFILES
1161 local t=$(ls $DIR/$tdir | wc -l)
1162 local u=$(ls $DIR/$tdir | sort -u | wc -l)
1163 local v=$(ls -ai $DIR/$tdir | sort -u | wc -l)
1164 if [ $t -ne $NFILES -o $u -ne $NFILES -o $v -ne $((NFILES + 2)) ] ; then
1165 error "Expected $NFILES files, got $t ($u unique $v .&..)"
1168 rm -rf $DIR/$tdir || error "Can not delete directories"
1170 run_test 24A "readdir() returns correct number of entries."
1172 test_24B() { # LU-4805
1173 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
1176 test_mkdir $DIR/$tdir
1177 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR/$tdir/striped_dir ||
1178 error "create striped dir failed"
1180 count=$(ls -ai $DIR/$tdir/striped_dir | wc -l)
1181 [ $count -eq 2 ] || error "Expected 2, got $count"
1183 touch $DIR/$tdir/striped_dir/a
1185 count=$(ls -ai $DIR/$tdir/striped_dir | wc -l)
1186 [ $count -eq 3 ] || error "Expected 3, got $count"
1188 touch $DIR/$tdir/striped_dir/.f
1190 count=$(ls -ai $DIR/$tdir/striped_dir | wc -l)
1191 [ $count -eq 4 ] || error "Expected 4, got $count"
1193 rm -rf $DIR/$tdir || error "Can not delete directories"
1195 run_test 24B "readdir for striped dir return correct number of entries"
1198 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
1204 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR/$tdir/d0/striped_dir ||
1205 error "create striped dir failed"
1207 cd $DIR/$tdir/d0/striped_dir
1209 local d0_ino=$(ls -i -l -a $DIR/$tdir | grep "d0" | awk '{print $1}')
1210 local d1_ino=$(ls -i -l -a $DIR/$tdir | grep "d1" | awk '{print $1}')
1211 local parent_ino=$(ls -i -l -a | grep "\.\." | awk '{print $1}')
1213 [ "$d0_ino" = "$parent_ino" ] ||
1214 error ".. wrong, expect $d0_ino, get $parent_ino"
1216 mv $DIR/$tdir/d0/striped_dir $DIR/$tdir/d1/ ||
1217 error "mv striped dir failed"
1219 parent_ino=$(ls -i -l -a | grep "\.\." | awk '{print $1}')
1221 [ "$d1_ino" = "$parent_ino" ] ||
1222 error ".. wrong after mv, expect $d1_ino, get $parent_ino"
1224 run_test 24C "check .. in striped dir"
1226 test_24D() { # LU-6101
1231 createmany -m $DIR/$tdir/$tfile $NFILES
1232 local t=$(ls $DIR/$tdir | wc -l)
1233 local u=$(ls $DIR/$tdir | sort -u | wc -l)
1234 local v=$(ls -ai $DIR/$tdir | sort -u | wc -l)
1235 if [ $t -ne $NFILES -o $u -ne $NFILES -o $v -ne $((NFILES + 2)) ] ; then
1236 error "Expected $NFILES files, got $t ($u unique $v .&..)"
1239 rm -rf $DIR/$tdir || error "Can not delete directories"
1241 run_test 24D "readdir() returns correct number of entries after cursor reload"
1244 [[ $MDSCOUNT -lt 4 ]] && skip "needs >= 4 MDTs" && return
1245 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1248 mkdir $DIR/$tdir/src_dir
1249 $LFS mkdir -i 1 $DIR/$tdir/src_dir/src_child ||
1250 error "create remote source failed"
1252 touch $DIR/$tdir/src_dir/src_child/a
1254 $LFS mkdir -i 2 $DIR/$tdir/tgt_dir ||
1255 error "create remote target dir failed"
1257 $LFS mkdir -i 3 $DIR/$tdir/tgt_dir/tgt_child ||
1258 error "create remote target child failed"
1260 mrename $DIR/$tdir/src_dir/src_child $DIR/$tdir/tgt_dir/tgt_child ||
1261 error "rename dir cross MDT failed!"
1265 $CHECKSTAT -t dir $DIR/$tdir/src_dir/src_child &&
1266 error "src_child still exists after rename"
1268 $CHECKSTAT -t file $DIR/$tdir/tgt_dir/tgt_child/a ||
1269 error "missing file(a) after rename"
1271 rm -rf $DIR/$tdir || error "Can not delete directories"
1273 run_test 24E "cross MDT rename/link"
1276 echo '== symlink sanity ============================================='
1280 touch $DIR/s25/foo || error
1282 run_test 25a "create file in symlinked directory ==============="
1285 [ ! -d $DIR/d25 ] && test_25a
1286 $CHECKSTAT -t file $DIR/s25/foo || error
1288 run_test 25b "lookup file in symlinked directory ==============="
1292 test_mkdir $DIR/d26/d26-2
1293 ln -s d26/d26-2 $DIR/s26
1294 touch $DIR/s26/foo || error
1296 run_test 26a "multiple component symlink ======================="
1299 test_mkdir -p $DIR/d26b/d26-2
1300 ln -s d26b/d26-2/foo $DIR/s26-2
1301 touch $DIR/s26-2 || error
1303 run_test 26b "multiple component symlink at end of lookup ======"
1306 test_mkdir $DIR/d26.2
1307 touch $DIR/d26.2/foo
1308 ln -s d26.2 $DIR/s26.2-1
1309 ln -s s26.2-1 $DIR/s26.2-2
1310 ln -s s26.2-2 $DIR/s26.2-3
1311 chmod 0666 $DIR/s26.2-3/foo
1313 run_test 26c "chain of symlinks ================================"
1315 # recursive symlinks (bug 439)
1317 ln -s d26-3/foo $DIR/d26-3
1319 run_test 26d "create multiple component recursive symlink ======"
1322 [ ! -h $DIR/d26-3 ] && test_26d
1325 run_test 26e "unlink multiple component recursive symlink ======"
1327 # recursive symlinks (bug 7022)
1329 test_mkdir -p $DIR/$tdir
1330 test_mkdir $DIR/$tdir/$tfile || error "mkdir $DIR/$tdir/$tfile failed"
1331 cd $DIR/$tdir/$tfile || error "cd $DIR/$tdir/$tfile failed"
1332 test_mkdir -p lndir/bar1 || error "mkdir lndir/bar1 failed"
1333 test_mkdir $DIR/$tdir/$tfile/$tfile || error "mkdir $tfile failed"
1334 cd $tfile || error "cd $tfile failed"
1335 ln -s .. dotdot || error "ln dotdot failed"
1336 ln -s dotdot/lndir lndir || error "ln lndir failed"
1337 cd $DIR/$tdir || error "cd $DIR/$tdir failed"
1338 output=`ls $tfile/$tfile/lndir/bar1`
1339 [ "$output" = bar1 ] && error "unexpected output"
1340 rm -r $tfile || error "rm $tfile failed"
1341 $CHECKSTAT -a $DIR/$tfile || error "$tfile not gone"
1343 run_test 26f "rm -r of a directory which has recursive symlink ="
1346 echo '== stripe sanity =============================================='
1347 test_mkdir -p $DIR/d27 || error "mkdir failed"
1349 $SETSTRIPE -c 1 $DIR/d27/f0 || error "setstripe failed"
1350 $CHECKSTAT -t file $DIR/d27/f0 || error "checkstat failed"
1351 log "== test_27a: write to one stripe file ========================="
1352 cp /etc/hosts $DIR/d27/f0 || error
1354 run_test 27a "one stripe file =================================="
1357 [[ $OSTCOUNT -lt 2 ]] && skip_env "skipping 2-stripe test" && return
1358 test_mkdir -p $DIR/d27
1359 $SETSTRIPE -c 2 $DIR/d27/f01 || error "setstripe failed"
1360 $GETSTRIPE -c $DIR/d27/f01
1361 [ $($GETSTRIPE -c $DIR/d27/f01) -eq 2 ] ||
1362 error "two-stripe file doesn't have two stripes"
1364 dd if=/dev/zero of=$DIR/d27/f01 bs=4k count=4 || error "dd failed"
1366 run_test 27b "create and write to two stripe file"
1369 test_mkdir -p $DIR/d27
1370 $SETSTRIPE -c 0 -i -1 -S 0 $DIR/d27/fdef || error "setstripe failed"
1371 $CHECKSTAT -t file $DIR/d27/fdef || error "checkstat failed"
1372 dd if=/dev/zero of=$DIR/d27/fdef bs=4k count=4 || error
1374 run_test 27d "create file with default settings ================"
1377 # LU-5839 adds check for existed layout before setting it
1378 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.56) ]] &&
1379 skip "Need MDS version at least 2.7.56" && return
1380 test_mkdir -p $DIR/d27
1381 $SETSTRIPE -c 2 $DIR/d27/f12 || error "setstripe failed"
1382 $SETSTRIPE -c 2 $DIR/d27/f12 && error "setstripe succeeded twice"
1383 $CHECKSTAT -t file $DIR/d27/f12 || error "checkstat failed"
1385 run_test 27e "setstripe existing file (should return error) ======"
1388 test_mkdir $DIR/$tdir
1389 $SETSTRIPE -S 100 -i 0 -c 1 $DIR/$tdir/$tfile &&
1390 error "$SETSTRIPE $DIR/$tdir/$tfile failed"
1391 $CHECKSTAT -t file $DIR/$tdir/$tfile &&
1392 error "$CHECKSTAT -t file $DIR/$tdir/$tfile should fail"
1393 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=4k count=4 || error "dd failed"
1394 $GETSTRIPE $DIR/$tdir/$tfile || error "$GETSTRIPE failed"
1396 run_test 27f "setstripe with bad stripe size (should return error)"
1399 test_mkdir -p $DIR/d27
1400 $MCREATE $DIR/d27/fnone || error "mcreate failed"
1401 $GETSTRIPE $DIR/d27/fnone 2>&1 | grep "no stripe info" ||
1402 error "$DIR/d27/fnone has object"
1404 run_test 27g "$GETSTRIPE with no objects"
1407 test_mkdir $DIR/$tdir
1408 touch $DIR/$tdir/$tfile || error "touch failed"
1409 [[ $($GETSTRIPE -c $DIR/$tdir/$tfile) -gt 0 ]] ||
1410 error "missing objects"
1412 run_test 27i "$GETSTRIPE with some objects"
1415 test_mkdir -p $DIR/d27
1416 $SETSTRIPE -i $OSTCOUNT $DIR/d27/f27j && error "setstripe failed"||true
1418 run_test 27j "setstripe with bad stripe offset (should return error)"
1420 test_27k() { # bug 2844
1421 test_mkdir -p $DIR/d27
1423 LL_MAX_BLKSIZE=$((4 * 1024 * 1024))
1424 [ ! -d $DIR/d27 ] && test_mkdir -p $DIR d27
1425 $SETSTRIPE -S 67108864 $FILE || error "setstripe failed"
1426 BLKSIZE=`stat $FILE | awk '/IO Block:/ { print $7 }'`
1427 [ $BLKSIZE -le $LL_MAX_BLKSIZE ] || error "1:$BLKSIZE > $LL_MAX_BLKSIZE"
1428 dd if=/dev/zero of=$FILE bs=4k count=1
1429 BLKSIZE=`stat $FILE | awk '/IO Block:/ { print $7 }'`
1430 [ $BLKSIZE -le $LL_MAX_BLKSIZE ] || error "2:$BLKSIZE > $LL_MAX_BLKSIZE"
1432 run_test 27k "limit i_blksize for broken user apps ============="
1435 test_mkdir -p $DIR/d27
1436 mcreate $DIR/f27l || error "creating file"
1437 $RUNAS $SETSTRIPE -c 1 $DIR/f27l && \
1438 error "setstripe should have failed" || true
1440 run_test 27l "check setstripe permissions (should return error)"
1443 [[ $OSTCOUNT -lt 2 ]] && skip_env "$OSTCOUNT < 2 OSTs -- skipping" &&
1445 if [[ $ORIGFREE -gt $MAXFREE ]]; then
1446 skip "$ORIGFREE > $MAXFREE skipping out-of-space test on OST0"
1449 trap simple_cleanup_common EXIT
1450 test_mkdir -p $DIR/$tdir
1451 $SETSTRIPE -i 0 -c 1 $DIR/$tdir/f27m_1
1452 dd if=/dev/zero of=$DIR/$tdir/f27m_1 bs=1024 count=$MAXFREE &&
1453 error "dd should fill OST0"
1455 while $SETSTRIPE -i 0 -c 1 $DIR/$tdir/f27m_$i; do
1457 [ $i -gt 256 ] && break
1460 touch $DIR/$tdir/f27m_$i
1461 [ `$GETSTRIPE $DIR/$tdir/f27m_$i | grep -A 10 obdidx | awk '{print $1}'| grep -w "0"` ] &&
1462 error "OST0 was full but new created file still use it"
1464 touch $DIR/$tdir/f27m_$i
1465 [ `$GETSTRIPE $DIR/$tdir/f27m_$i | grep -A 10 obdidx | awk '{print $1}'| grep -w "0"` ] &&
1466 error "OST0 was full but new created file still use it"
1467 simple_cleanup_common
1469 run_test 27m "create file while OST0 was full =================="
1472 local DELAY=$(do_facet $SINGLEMDS lctl get_param -n lov.*.qos_maxage | head -n 1 | awk '{print $1 * 2}')
1476 # OSCs keep a NOSPC flag that will be reset after ~5s (qos_maxage)
1477 # if the OST isn't full anymore.
1479 local OSTIDX=${1:-""}
1481 local list=$(comma_list $(osts_nodes))
1482 [ "$OSTIDX" ] && list=$(facet_host ost$((OSTIDX + 1)))
1484 do_nodes $list lctl set_param fail_loc=0
1485 sync # initiate all OST_DESTROYs from MDS to OST
1489 exhaust_precreations() {
1492 local FAILIDX=${3:-$OSTIDX}
1493 local ofacet=ost$((OSTIDX + 1))
1495 test_mkdir -p -c1 $DIR/$tdir
1496 local mdtidx=$($LFS getstripe -M $DIR/$tdir)
1497 local mfacet=mds$((mdtidx + 1))
1498 echo OSTIDX=$OSTIDX MDTIDX=$mdtidx
1500 local OST=$(ostname_from_index $OSTIDX)
1503 local mdtosc_proc1=$(get_mdtosc_proc_path $mfacet $OST)
1504 local last_id=$(do_facet $mfacet lctl get_param -n \
1505 osc.$mdtosc_proc1.prealloc_last_id)
1506 local next_id=$(do_facet $mfacet lctl get_param -n \
1507 osc.$mdtosc_proc1.prealloc_next_id)
1509 local mdtosc_proc2=$(get_mdtosc_proc_path $mfacet)
1510 do_facet $mfacet lctl get_param osc.$mdtosc_proc2.prealloc*
1512 test_mkdir -p $DIR/$tdir/${OST}
1513 $SETSTRIPE -i $OSTIDX -c 1 $DIR/$tdir/${OST}
1514 #define OBD_FAIL_OST_ENOSPC 0x215
1515 do_facet $ofacet lctl set_param fail_val=$FAILIDX fail_loc=0x215
1516 echo "Creating to objid $last_id on ost $OST..."
1517 createmany -o $DIR/$tdir/${OST}/f $next_id $((last_id - next_id + 2))
1518 do_facet $mfacet lctl get_param osc.$mdtosc_proc2.prealloc*
1519 do_facet $ofacet lctl set_param fail_loc=$FAILLOC
1523 exhaust_all_precreations() {
1525 for (( i=0; i < OSTCOUNT; i++ )) ; do
1526 exhaust_precreations $i $1 -1
1531 [[ $OSTCOUNT -lt 2 ]] && skip_env "too few OSTs" && return
1532 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1533 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1534 remote_ost_nodsh && skip "remote OST with nodsh" && return
1537 rm -f $DIR/$tdir/$tfile
1538 exhaust_precreations 0 0x80000215
1539 $SETSTRIPE -c -1 $DIR/$tdir
1540 touch $DIR/$tdir/$tfile || error
1541 $GETSTRIPE $DIR/$tdir/$tfile
1544 run_test 27n "create file with some full OSTs =================="
1547 [[ $OSTCOUNT -lt 2 ]] && skip_env "too few OSTs" && return
1548 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1549 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1550 remote_ost_nodsh && skip "remote OST with nodsh" && return
1553 rm -f $DIR/$tdir/$tfile
1554 exhaust_all_precreations 0x215
1556 touch $DIR/$tdir/$tfile && error "able to create $DIR/$tdir/$tfile"
1561 run_test 27o "create file with all full OSTs (should error) ===="
1564 [[ $OSTCOUNT -lt 2 ]] && skip_env "too few OSTs" && return
1565 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1566 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1567 remote_ost_nodsh && skip "remote OST with nodsh" && return
1570 rm -f $DIR/$tdir/$tfile
1571 test_mkdir -p $DIR/$tdir
1573 $MCREATE $DIR/$tdir/$tfile || error "mcreate failed"
1574 $TRUNCATE $DIR/$tdir/$tfile 80000000 || error "truncate failed"
1575 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat failed"
1577 exhaust_precreations 0 0x80000215
1578 echo foo >> $DIR/$tdir/$tfile || error "append failed"
1579 $CHECKSTAT -s 80000004 $DIR/$tdir/$tfile || error "checkstat failed"
1580 $GETSTRIPE $DIR/$tdir/$tfile
1584 run_test 27p "append to a truncated file with some full OSTs ==="
1587 [[ $OSTCOUNT -lt 2 ]] && skip_env "too few OSTs" && return
1588 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1589 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1590 remote_ost_nodsh && skip "remote OST with nodsh" && return
1593 rm -f $DIR/$tdir/$tfile
1595 test_mkdir -p $DIR/$tdir
1596 $MCREATE $DIR/$tdir/$tfile || error "mcreate $DIR/$tdir/$tfile failed"
1597 $TRUNCATE $DIR/$tdir/$tfile 80000000 ||error "truncate $DIR/$tdir/$tfile failed"
1598 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat failed"
1600 exhaust_all_precreations 0x215
1602 echo foo >> $DIR/$tdir/$tfile && error "append succeeded"
1603 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat 2 failed"
1607 run_test 27q "append to truncated file with all OSTs full (should error) ==="
1610 [[ $OSTCOUNT -lt 2 ]] && skip_env "too few OSTs" && return
1611 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1612 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1613 remote_ost_nodsh && skip "remote OST with nodsh" && return
1616 rm -f $DIR/$tdir/$tfile
1617 exhaust_precreations 0 0x80000215
1619 $SETSTRIPE -i 0 -c 2 $DIR/$tdir/$tfile # && error
1623 run_test 27r "stripe file with some full OSTs (shouldn't LBUG) ="
1625 test_27s() { # bug 10725
1626 test_mkdir -p $DIR/$tdir
1627 local stripe_size=$((4096 * 1024 * 1024)) # 2^32
1628 local stripe_count=0
1629 [ $OSTCOUNT -eq 1 ] || stripe_count=2
1630 $SETSTRIPE -S $stripe_size -c $stripe_count $DIR/$tdir &&
1631 error "stripe width >= 2^32 succeeded" || true
1634 run_test 27s "lsm_xfersize overflow (should error) (bug 10725)"
1636 test_27t() { # bug 10864
1641 $WLFS getstripe $tfile
1644 run_test 27t "check that utils parse path correctly"
1646 test_27u() { # bug 4900
1647 [[ $OSTCOUNT -lt 2 ]] && skip_env "too few OSTs" && return
1648 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1650 local list=$(comma_list $(mdts_nodes))
1652 #define OBD_FAIL_MDS_OSC_PRECREATE 0x139
1653 do_nodes $list $LCTL set_param fail_loc=0x139
1654 test_mkdir -p $DIR/$tdir
1656 createmany -o $DIR/$tdir/t- 1000
1657 do_nodes $list $LCTL set_param fail_loc=0
1659 TLOG=$DIR/$tfile.getstripe
1660 $GETSTRIPE $DIR/$tdir > $TLOG
1661 OBJS=$(awk -vobj=0 '($1 == 0) { obj += 1 } END { print obj; }' $TLOG)
1662 unlinkmany $DIR/$tdir/t- 1000
1663 [[ $OBJS -gt 0 ]] &&
1664 error "$OBJS objects created on OST-0. See $TLOG" || pass
1666 run_test 27u "skip object creation on OSC w/o objects =========="
1668 test_27v() { # bug 4900
1669 [[ $OSTCOUNT -lt 2 ]] && skip_env "too few OSTs" && return
1670 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1671 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1672 remote_ost_nodsh && skip "remote OST with nodsh" && return
1674 exhaust_all_precreations 0x215
1677 test_mkdir -p $DIR/$tdir
1678 $SETSTRIPE -c 1 $DIR/$tdir # 1 stripe / file
1680 touch $DIR/$tdir/$tfile
1681 #define OBD_FAIL_TGT_DELAY_PRECREATE 0x705
1683 for (( i=1; i < OSTCOUNT; i++ )); do
1684 do_facet ost$i lctl set_param fail_loc=0x705
1686 local START=`date +%s`
1687 createmany -o $DIR/$tdir/$tfile 32
1689 local FINISH=`date +%s`
1690 local TIMEOUT=`lctl get_param -n timeout`
1691 local PROCESS=$((FINISH - START))
1692 [ $PROCESS -ge $((TIMEOUT / 2)) ] && \
1693 error "$FINISH - $START >= $TIMEOUT / 2"
1694 sleep $((TIMEOUT / 2 - PROCESS))
1697 run_test 27v "skip object creation on slow OST ================="
1699 test_27w() { # bug 10997
1700 test_mkdir -p $DIR/$tdir || error "mkdir failed"
1701 $SETSTRIPE -S 65536 $DIR/$tdir/f0 || error "setstripe failed"
1702 [ $($GETSTRIPE -S $DIR/$tdir/f0) -ne 65536 ] &&
1703 error "stripe size $size != 65536" || true
1704 [ $($GETSTRIPE -d $DIR/$tdir | grep -c "stripe_count") -ne 1 ] &&
1705 error "$GETSTRIPE -d $DIR/$tdir failed" || true
1707 run_test 27w "check $SETSTRIPE -S option"
1710 [[ $OSTCOUNT -lt 2 ]] &&
1711 skip_env "skipping multiple stripe count/offset test" && return
1713 test_mkdir -p $DIR/$tdir || error "mkdir failed"
1714 for i in $(seq 1 $OSTCOUNT); do
1716 $SETSTRIPE -c $i -i $offset $DIR/$tdir/f$i ||
1717 error "setstripe -c $i -i $offset failed"
1718 count=$($GETSTRIPE -c $DIR/$tdir/f$i)
1719 index=$($GETSTRIPE -i $DIR/$tdir/f$i)
1720 [ $count -ne $i ] && error "stripe count $count != $i" || true
1721 [ $index -ne $offset ] &&
1722 error "stripe offset $index != $offset" || true
1725 run_test 27wa "check $SETSTRIPE -c -i options"
1728 remote_ost_nodsh && skip "remote OST with nodsh" && return
1729 [[ $OSTCOUNT -lt 2 ]] && skip_env "$OSTCOUNT < 2 OSTs" && return
1730 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1731 OFFSET=$(($OSTCOUNT - 1))
1733 local OST=$(ostname_from_index $OSTIDX)
1735 test_mkdir -p $DIR/$tdir
1736 $SETSTRIPE -c 1 $DIR/$tdir # 1 stripe per file
1737 do_facet ost$((OSTIDX + 1)) lctl set_param -n obdfilter.$OST.degraded 1
1739 createmany -o $DIR/$tdir/$tfile $OSTCOUNT
1740 for i in `seq 0 $OFFSET`; do
1741 [ `$GETSTRIPE $DIR/$tdir/$tfile$i | grep -A 10 obdidx | awk '{print $1}' | grep -w "$OSTIDX"` ] &&
1742 error "OST0 was degraded but new created file still use it"
1744 do_facet ost$((OSTIDX + 1)) lctl set_param -n obdfilter.$OST.degraded 0
1746 run_test 27x "create files while OST0 is degraded"
1749 [[ $OSTCOUNT -lt 2 ]] &&
1750 skip_env "$OSTCOUNT < 2 OSTs -- skipping" && return
1751 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1752 remote_ost_nodsh && skip "remote OST with nodsh" && return
1753 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1755 local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS $FSNAME-OST0000)
1756 local last_id=$(do_facet $SINGLEMDS lctl get_param -n \
1757 osc.$mdtosc.prealloc_last_id)
1758 local next_id=$(do_facet $SINGLEMDS lctl get_param -n \
1759 osc.$mdtosc.prealloc_next_id)
1760 local fcount=$((last_id - next_id))
1761 [[ $fcount -eq 0 ]] && skip "not enough space on OST0" && return
1762 [[ $fcount -gt $OSTCOUNT ]] && fcount=$OSTCOUNT
1764 local MDS_OSCS=$(do_facet $SINGLEMDS lctl dl |
1765 awk '/[oO][sS][cC].*md[ts]/ { print $4 }')
1766 local OST_DEACTIVE_IDX=-1
1771 for OSC in $MDS_OSCS; do
1772 OST=$(osc_to_ost $OSC)
1773 OSTIDX=$(index_from_ostuuid $OST)
1774 if [ $OST_DEACTIVE_IDX == -1 ]; then
1775 OST_DEACTIVE_IDX=$OSTIDX
1777 if [ $OSTIDX != $OST_DEACTIVE_IDX ]; then
1778 echo $OSC "is Deactivated:"
1779 do_facet $SINGLEMDS lctl --device %$OSC deactivate
1783 OSTIDX=$(index_from_ostuuid $OST)
1784 test_mkdir -p $DIR/$tdir
1785 $SETSTRIPE -c 1 $DIR/$tdir # 1 stripe / file
1787 for OSC in $MDS_OSCS; do
1788 OST=$(osc_to_ost $OSC)
1789 OSTIDX=$(index_from_ostuuid $OST)
1790 if [ $OSTIDX == $OST_DEACTIVE_IDX ]; then
1791 echo $OST "is degraded:"
1792 do_facet ost$((OSTIDX+1)) lctl set_param -n \
1793 obdfilter.$OST.degraded=1
1798 createmany -o $DIR/$tdir/$tfile $fcount
1800 for OSC in $MDS_OSCS; do
1801 OST=$(osc_to_ost $OSC)
1802 OSTIDX=$(index_from_ostuuid $OST)
1803 if [ $OSTIDX == $OST_DEACTIVE_IDX ]; then
1804 echo $OST "is recovered from degraded:"
1805 do_facet ost$((OSTIDX+1)) lctl set_param -n \
1806 obdfilter.$OST.degraded=0
1808 do_facet $SINGLEMDS lctl --device %$OSC activate
1812 # all osp devices get activated, hence -1 stripe count restored
1815 # sleep 2*lod_qos_maxage seconds waiting for lod qos to notice osp
1816 # devices get activated.
1818 $SETSTRIPE -c -1 $DIR/$tfile
1819 stripecnt=$($GETSTRIPE -c $DIR/$tfile)
1821 [ $stripecnt -ne $OSTCOUNT ] &&
1822 error "Of $OSTCOUNT OSTs, only $stripecnt is available"
1825 run_test 27y "create files while OST0 is degraded and the rest inactive"
1831 lmm_count=$($GETSTRIPE -c $1)
1832 lmm_seq=$($GETSTRIPE -v $1 | awk '/lmm_seq/ { print $2 }')
1833 lmm_oid=$($GETSTRIPE -v $1 | awk '/lmm_object_id/ { print $2 }')
1835 local old_ifs="$IFS"
1837 fid=($($LFS path2fid $1))
1840 log "FID seq ${fid[1]}, oid ${fid[2]} ver ${fid[3]}"
1841 log "LOV seq $lmm_seq, oid $lmm_oid, count: $lmm_count"
1843 # compare lmm_seq and lu_fid->f_seq
1844 [ $lmm_seq = ${fid[1]} ] || { error "SEQ mismatch"; return 1; }
1845 # compare lmm_object_id and lu_fid->oid
1846 [ $lmm_oid = ${fid[2]} ] || { error "OID mismatch"; return 2; }
1848 # check the trusted.fid attribute of the OST objects of the file
1849 local have_obdidx=false
1851 $GETSTRIPE $1 | while read obdidx oid hex seq; do
1852 # skip lines up to and including "obdidx"
1853 [ -z "$obdidx" ] && break
1854 [ "$obdidx" = "obdidx" ] && have_obdidx=true && continue
1855 $have_obdidx || continue
1857 local ost=$((obdidx + 1))
1858 local dev=$(ostdevname $ost)
1861 log "want: stripe:$stripe_nr ost:$obdidx oid:$oid/$hex seq:$seq"
1863 seq=$(echo $seq | sed -e "s/^0x//g")
1864 if [ $seq == 0 ] || [ $(facet_fstype ost$ost) == zfs ]; then
1865 oid_hex=$(echo $oid)
1867 oid_hex=$(echo $hex | sed -e "s/^0x//g")
1869 local obj_file="O/$seq/d$((oid %32))/$oid_hex"
1873 # Don't unmount/remount the OSTs if we don't need to do that.
1874 # LU-2577 changes filter_fid to be smaller, so debugfs needs
1875 # update too, until that use mount/ll_decode_filter_fid/mount.
1876 # Re-enable when debugfs will understand new filter_fid.
1878 if false && [ $(facet_fstype ost$ost) == ldiskfs ]; then
1879 ff=$(do_facet ost$ost "$DEBUGFS -c -R 'stat $obj_file' \
1880 $dev 2>/dev/null" | grep "parent=")
1883 mount_fstype ost$ost
1884 ff=$(do_facet ost$ost $LL_DECODE_FILTER_FID \
1885 $(facet_mntpt ost$ost)/$obj_file)
1886 unmount_fstype ost$ost
1887 start ost$ost $dev $OST_MOUNT_OPTS
1890 [ -z "$ff" ] && error "$obj_file: no filter_fid info"
1892 echo "$ff" | sed -e 's#.*objid=#got: objid=#'
1894 # /mnt/O/0/d23/23: objid=23 seq=0 parent=[0x200000400:0x1e:0x1]
1895 # fid: objid=23 seq=0 parent=[0x200000400:0x1e:0x0] stripe=1
1896 local ff_parent=$(echo $ff|sed -e 's/.*parent=.//')
1897 local ff_pseq=$(echo $ff_parent | cut -d: -f1)
1898 local ff_poid=$(echo $ff_parent | cut -d: -f2)
1900 if echo $ff_parent | grep -q 'stripe='; then
1901 ff_pstripe=$(echo $ff_parent | sed -e 's/.*stripe=//')
1904 # $LL_DECODE_FILTER_FID does not print "stripe="; look
1905 # into f_ver in this case. See the comment on
1908 ff_pstripe=$(echo $ff_parent | cut -d: -f3 |
1912 # compare lmm_seq and filter_fid->ff_parent.f_seq
1913 [ $ff_pseq = $lmm_seq ] ||
1914 error "FF parent SEQ $ff_pseq != $lmm_seq"
1915 # compare lmm_object_id and filter_fid->ff_parent.f_oid
1916 [ $ff_poid = $lmm_oid ] ||
1917 error "FF parent OID $ff_poid != $lmm_oid"
1918 (($ff_pstripe == $stripe_nr)) ||
1919 error "FF stripe $ff_pstripe != $stripe_nr"
1921 stripe_nr=$((stripe_nr + 1))
1926 remote_ost_nodsh && skip "remote OST with nodsh" && return
1927 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1928 test_mkdir -p $DIR/$tdir
1930 $SETSTRIPE -c 1 -i 0 -S 64k $DIR/$tdir/$tfile-1 ||
1931 { error "setstripe -c -1 failed"; return 1; }
1932 # We need to send a write to every object to get parent FID info set.
1933 # This _should_ also work for setattr, but does not currently.
1934 # touch $DIR/$tdir/$tfile-1 ||
1935 dd if=/dev/zero of=$DIR/$tdir/$tfile-1 bs=1M count=1 ||
1936 { error "dd $tfile-1 failed"; return 2; }
1937 $SETSTRIPE -c -1 -i $((OSTCOUNT - 1)) -S 1M $DIR/$tdir/$tfile-2 ||
1938 { error "setstripe -c -1 failed"; return 3; }
1939 dd if=/dev/zero of=$DIR/$tdir/$tfile-2 bs=1M count=$OSTCOUNT ||
1940 { error "dd $tfile-2 failed"; return 4; }
1942 # make sure write RPCs have been sent to OSTs
1945 check_seq_oid $DIR/$tdir/$tfile-1 || return 5
1946 check_seq_oid $DIR/$tdir/$tfile-2 || return 6
1948 run_test 27z "check SEQ/OID on the MDT and OST filesystems"
1950 test_27A() { # b=19102
1951 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1952 local restore_size=$($GETSTRIPE -S $MOUNT)
1953 local restore_count=$($GETSTRIPE -c $MOUNT)
1954 local restore_offset=$($GETSTRIPE -i $MOUNT)
1955 $SETSTRIPE -c 0 -i -1 -S 0 $MOUNT
1956 wait_update $HOSTNAME "$GETSTRIPE -c $MOUNT | sed 's/ *//g'" "1" 20 ||
1957 error "stripe count $($GETSTRIPE -c $MOUNT) != 1"
1958 local default_size=$($GETSTRIPE -S $MOUNT)
1959 local default_offset=$($GETSTRIPE -i $MOUNT)
1960 local dsize=$((1024 * 1024))
1961 [ $default_size -eq $dsize ] ||
1962 error "stripe size $default_size != $dsize"
1963 [ $default_offset -eq -1 ] ||error "stripe offset $default_offset != -1"
1964 $SETSTRIPE -c $restore_count -i $restore_offset -S $restore_size $MOUNT
1966 run_test 27A "check filesystem-wide default LOV EA values"
1968 test_27B() { # LU-2523
1969 test_mkdir -p $DIR/$tdir
1970 rm -f $DIR/$tdir/f0 $DIR/$tdir/f1
1972 # open f1 with O_LOV_DELAY_CREATE
1974 # call setstripe ioctl on open file descriptor for f1
1976 multiop $DIR/$tdir/f1 oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:nB1c \
1980 # open f1 with O_LOV_DELAY_CREATE
1982 # call setstripe ioctl on open file descriptor for f1
1984 multiop $DIR/$tdir/f1 oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:uB1c
1986 # Allow multiop to fail in imitation of NFS's busted semantics.
1989 run_test 27B "call setstripe on open unlinked file/rename victim"
1991 test_27C() { #LU-2871
1992 [[ $OSTCOUNT -lt 2 ]] && skip "needs >= 2 OSTs" && return
2000 test_mkdir -p $DIR/$tdir
2002 for i in $(seq 0 $((OSTCOUNT - 1))); do
2003 # set stripe across all OSTs starting from OST$i
2004 $SETSTRIPE -i $i -c -1 $tfile$i
2005 # get striping information
2006 ost_idx=($($GETSTRIPE $tfile$i |
2007 tail -n $((OSTCOUNT + 1)) | awk '{print $1}'))
2011 [ ${#ost_idx[@]} -eq $OSTCOUNT ] ||
2012 error "${#ost_idx[@]} != $OSTCOUNT"
2014 for index in $(seq 0 $((OSTCOUNT - 1))); do
2016 for j in $(echo ${ost_idx[@]}); do
2017 if [ $index -eq $j ]; then
2023 error "Can not find $index in ${ost_idx[@]}"
2027 run_test 27C "check full striping across all OSTs"
2030 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs" && return
2031 local POOL=${POOL:-testpool}
2033 local last_ost=$(($OSTCOUNT - 1))
2035 local ost_list=$(seq $first_ost $ost_step $last_ost)
2036 local ost_range="$first_ost $last_ost $ost_step"
2038 test_mkdir -p $DIR/$tdir
2039 pool_add $POOL || error "pool_add failed"
2040 pool_add_targets $POOL $ost_range || error "pool_add_targets failed"
2041 llapi_layout_test -d$DIR/$tdir -p$POOL -o$OSTCOUNT ||
2042 error "llapi_layout_test failed"
2043 cleanup_pools || error "cleanup_pools failed"
2045 run_test 27D "validate llapi_layout API"
2047 # Verify that default_easize is increased from its initial value after
2048 # accessing a widely striped file.
2050 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs" && return
2052 # 72 bytes is the minimum space required to store striping
2053 # information for a file striped across one OST:
2054 # (sizeof(struct lov_user_md_v3) +
2055 # sizeof(struct lov_user_ost_data_v1))
2057 $LCTL set_param -n llite.*.default_easize $min_easize ||
2058 error "lctl set_param failed"
2059 local easize=$($LCTL get_param -n llite.*.default_easize)
2061 [ $easize -eq $min_easize ] ||
2062 error "failed to set default_easize"
2064 $LFS setstripe -c $OSTCOUNT $DIR/$tfile ||
2065 error "setstripe failed"
2069 easize=$($LCTL get_param -n llite.*.default_easize)
2071 [ $easize -gt $min_easize ] ||
2072 error "default_easize not updated"
2074 run_test 27E "check that default extended attribute size properly increases"
2076 # createtest also checks that device nodes are created and
2077 # then visible correctly (#2091)
2078 test_28() { # bug 2091
2080 $CREATETEST $DIR/d28/ct || error
2082 run_test 28 "create/mknod/mkdir with bad file types ============"
2085 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2086 cancel_lru_locks mdc
2092 declare -i LOCKCOUNTORIG=0
2093 for lock_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_count); do
2094 let LOCKCOUNTORIG=$LOCKCOUNTORIG+$lock_count
2096 [ $LOCKCOUNTORIG -eq 0 ] && echo "No mdc lock count" && return 1
2098 declare -i LOCKUNUSEDCOUNTORIG=0
2099 for unused_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_unused_count); do
2100 let LOCKUNUSEDCOUNTORIG=$LOCKUNUSEDCOUNTORIG+$unused_count
2107 declare -i LOCKCOUNTCURRENT=0
2108 for lock_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_count); do
2109 let LOCKCOUNTCURRENT=$LOCKCOUNTCURRENT+$lock_count
2112 declare -i LOCKUNUSEDCOUNTCURRENT=0
2113 for unused_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_unused_count); do
2114 let LOCKUNUSEDCOUNTCURRENT=$LOCKUNUSEDCOUNTCURRENT+$unused_count
2117 if [[ $LOCKCOUNTCURRENT -gt $LOCKCOUNTORIG ]]; then
2118 $LCTL set_param -n ldlm.dump_namespaces ""
2119 error "CURRENT: $LOCKCOUNTCURRENT > $LOCKCOUNTORIG"
2120 $LCTL dk | sort -k4 -t: > $TMP/test_29.dk
2121 log "dumped log to $TMP/test_29.dk (bug 5793)"
2124 if [[ $LOCKUNUSEDCOUNTCURRENT -gt $LOCKUNUSEDCOUNTORIG ]]; then
2125 error "UNUSED: $LOCKUNUSEDCOUNTCURRENT > $LOCKUNUSEDCOUNTORIG"
2126 $LCTL dk | sort -k4 -t: > $TMP/test_29.dk
2127 log "dumped log to $TMP/test_29.dk (bug 5793)"
2131 run_test 29 "IT_GETATTR regression ============================"
2133 test_30a() { # was test_30
2134 cp $(which ls) $DIR || cp /bin/ls $DIR
2138 run_test 30a "execute binary from Lustre (execve) =============="
2141 cp `which ls` $DIR || cp /bin/ls $DIR
2143 $RUNAS $DIR/ls / || error
2146 run_test 30b "execute binary from Lustre as non-root ==========="
2148 test_30c() { # b=22376
2149 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2150 cp `which ls` $DIR || cp /bin/ls $DIR
2152 cancel_lru_locks mdc
2153 cancel_lru_locks osc
2154 $RUNAS $DIR/ls / || error
2157 run_test 30c "execute binary from Lustre without read perms ===="
2160 $OPENUNLINK $DIR/f31 $DIR/f31 || error
2161 $CHECKSTAT -a $DIR/f31 || error
2163 run_test 31a "open-unlink file =================================="
2166 touch $DIR/f31 || error
2167 ln $DIR/f31 $DIR/f31b || error
2168 $MULTIOP $DIR/f31b Ouc || error
2169 $CHECKSTAT -t file $DIR/f31 || error
2171 run_test 31b "unlink file with multiple links while open ======="
2174 touch $DIR/f31 || error
2175 ln $DIR/f31 $DIR/f31c || error
2176 multiop_bg_pause $DIR/f31 O_uc || return 1
2178 $MULTIOP $DIR/f31c Ouc
2179 kill -USR1 $MULTIPID
2182 run_test 31c "open-unlink file with multiple links ============="
2185 opendirunlink $DIR/d31d $DIR/d31d || error
2186 $CHECKSTAT -a $DIR/d31d || error
2188 run_test 31d "remove of open directory ========================="
2190 test_31e() { # bug 2904
2191 openfilleddirunlink $DIR/d31e || error
2193 run_test 31e "remove of open non-empty directory ==============="
2195 test_31f() { # bug 4554
2196 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2198 test_mkdir $DIR/d31f
2199 $SETSTRIPE -S 1048576 -c 1 $DIR/d31f
2200 cp /etc/hosts $DIR/d31f
2202 $GETSTRIPE $DIR/d31f/hosts
2203 multiop_bg_pause $DIR/d31f D_c || return 1
2206 rm -rv $DIR/d31f || error "first of $DIR/d31f"
2207 test_mkdir $DIR/d31f
2208 $SETSTRIPE -S 1048576 -c 1 $DIR/d31f
2209 cp /etc/hosts $DIR/d31f
2211 $GETSTRIPE $DIR/d31f/hosts
2212 multiop_bg_pause $DIR/d31f D_c || return 1
2215 kill -USR1 $MULTIPID || error "first opendir $MULTIPID not running"
2216 wait $MULTIPID || error "first opendir $MULTIPID failed"
2220 kill -USR1 $MULTIPID2 || error "second opendir $MULTIPID not running"
2221 wait $MULTIPID2 || error "second opendir $MULTIPID2 failed"
2224 run_test 31f "remove of open directory with open-unlink file ==="
2227 echo "-- cross directory link --"
2228 test_mkdir -c1 $DIR/${tdir}ga
2229 test_mkdir -c1 $DIR/${tdir}gb
2230 touch $DIR/${tdir}ga/f
2231 ln $DIR/${tdir}ga/f $DIR/${tdir}gb/g
2232 $CHECKSTAT -t file $DIR/${tdir}ga/f || error "source"
2233 [ `stat -c%h $DIR/${tdir}ga/f` == '2' ] || error "source nlink"
2234 $CHECKSTAT -t file $DIR/${tdir}gb/g || error "target"
2235 [ `stat -c%h $DIR/${tdir}gb/g` == '2' ] || error "target nlink"
2237 run_test 31g "cross directory link==============="
2240 echo "-- cross directory link --"
2241 test_mkdir -c1 $DIR/${tdir}
2242 test_mkdir -c1 $DIR/${tdir}/dir
2243 touch $DIR/${tdir}/f
2244 ln $DIR/${tdir}/f $DIR/${tdir}/dir/g
2245 $CHECKSTAT -t file $DIR/${tdir}/f || error "source"
2246 [ `stat -c%h $DIR/${tdir}/f` == '2' ] || error "source nlink"
2247 $CHECKSTAT -t file $DIR/${tdir}/dir/g || error "target"
2248 [ `stat -c%h $DIR/${tdir}/dir/g` == '2' ] || error "target nlink"
2250 run_test 31h "cross directory link under child==============="
2253 echo "-- cross directory link --"
2254 test_mkdir -c1 $DIR/$tdir
2255 test_mkdir -c1 $DIR/$tdir/dir
2256 touch $DIR/$tdir/dir/f
2257 ln $DIR/$tdir/dir/f $DIR/$tdir/g
2258 $CHECKSTAT -t file $DIR/$tdir/dir/f || error "source"
2259 [ `stat -c%h $DIR/$tdir/dir/f` == '2' ] || error "source nlink"
2260 $CHECKSTAT -t file $DIR/$tdir/g || error "target"
2261 [ `stat -c%h $DIR/$tdir/g` == '2' ] || error "target nlink"
2263 run_test 31i "cross directory link under parent==============="
2266 test_mkdir -c1 -p $DIR/$tdir
2267 test_mkdir -c1 -p $DIR/$tdir/dir1
2268 ln $DIR/$tdir/dir1 $DIR/$tdir/dir2 && error "ln for dir"
2269 link $DIR/$tdir/dir1 $DIR/$tdir/dir3 && error "link for dir"
2270 mlink $DIR/$tdir/dir1 $DIR/$tdir/dir4 && error "mlink for dir"
2271 mlink $DIR/$tdir/dir1 $DIR/$tdir/dir1 && error "mlink to the same dir"
2274 run_test 31j "link for directory==============="
2277 test_mkdir -c1 -p $DIR/$tdir
2279 touch $DIR/$tdir/exist
2280 mlink $DIR/$tdir/s $DIR/$tdir/t || error "mlink"
2281 mlink $DIR/$tdir/s $DIR/$tdir/exist && error "mlink to exist file"
2282 mlink $DIR/$tdir/s $DIR/$tdir/s && error "mlink to the same file"
2283 mlink $DIR/$tdir/s $DIR/$tdir && error "mlink to parent dir"
2284 mlink $DIR/$tdir $DIR/$tdir/s && error "mlink parent dir to target"
2285 mlink $DIR/$tdir/not-exist $DIR/$tdir/foo && error "mlink non-existing to new"
2286 mlink $DIR/$tdir/not-exist $DIR/$tdir/s && error "mlink non-existing to exist"
2289 run_test 31k "link to file: the same, non-existing, dir==============="
2295 touch $DIR/d31m2/exist
2296 mlink $DIR/d31m/s $DIR/d31m2/t || error "mlink"
2297 mlink $DIR/d31m/s $DIR/d31m2/exist && error "mlink to exist file"
2298 mlink $DIR/d31m/s $DIR/d31m2 && error "mlink to parent dir"
2299 mlink $DIR/d31m2 $DIR/d31m/s && error "mlink parent dir to target"
2300 mlink $DIR/d31m/not-exist $DIR/d31m2/foo && error "mlink non-existing to new"
2301 mlink $DIR/d31m/not-exist $DIR/d31m2/s && error "mlink non-existing to exist"
2304 run_test 31m "link to file: the same, non-existing, dir==============="
2307 touch $DIR/$tfile || error "cannot create '$DIR/$tfile'"
2308 nlink=$(stat --format=%h $DIR/$tfile)
2309 [ ${nlink:--1} -eq 1 ] || error "nlink is $nlink, expected 1"
2311 local cmd="exec $fd<$DIR/$tfile"
2314 trap "eval $cmd" EXIT
2315 nlink=$(stat --dereference --format=%h /proc/self/fd/$fd)
2316 [ ${nlink:--1} -eq 1 ] || error "nlink is $nlink, expected 1"
2317 rm $DIR/$tfile || error "cannot remove '$DIR/$tfile'"
2318 nlink=$(stat --dereference --format=%h /proc/self/fd/$fd)
2319 [ ${nlink:--1} -eq 0 ] || error "nlink is $nlink, expected 0"
2322 run_test 31n "check link count of unlinked file"
2325 local TEMPNAME=$(mktemp $1_XXXXXX)
2326 mlink $TEMPNAME $1 2> /dev/null &&
2327 echo "$BASHPID: link $TEMPNAME to $1 succeeded"
2331 test_31o() { # LU-2901
2332 test_mkdir -p $DIR/$tdir
2333 for LOOP in $(seq 100); do
2334 rm -f $DIR/$tdir/$tfile*
2335 for THREAD in $(seq 8); do
2336 link_one $DIR/$tdir/$tfile.$LOOP &
2339 local LINKS=$(ls -1 $DIR/$tdir | grep -c $tfile.$LOOP)
2340 [[ $LINKS -gt 1 ]] && ls $DIR/$tdir &&
2341 error "$LINKS duplicate links to $tfile.$LOOP" &&
2345 run_test 31o "duplicate hard links with same filename"
2348 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2350 test_mkdir $DIR/$tdir
2351 $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
2352 $LFS setdirstripe -D -c2 -t all_char $DIR/$tdir/striped_dir
2354 opendirunlink $DIR/$tdir/striped_dir/test1 ||
2355 error "open unlink test1 failed"
2356 opendirunlink $DIR/$tdir/striped_dir/test2 ||
2357 error "open unlink test2 failed"
2359 $CHECKSTAT -a $DIR/$tdir/striped_dir/test1 ||
2360 error "test1 still exists"
2361 $CHECKSTAT -a $DIR/$tdir/striped_dir/test2 ||
2362 error "test2 still exists"
2364 run_test 31p "remove of open striped directory"
2366 cleanup_test32_mount() {
2368 $UMOUNT $DIR/$tdir/ext2-mountpoint
2372 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2373 echo "== more mountpoints and symlinks ================="
2374 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2375 trap cleanup_test32_mount EXIT
2376 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2377 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2378 $CHECKSTAT -t dir $DIR/$tdir/ext2-mountpoint/.. || error
2379 cleanup_test32_mount
2381 run_test 32a "stat d32a/ext2-mountpoint/.. ====================="
2384 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2385 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2386 trap cleanup_test32_mount EXIT
2387 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2388 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2389 ls -al $DIR/$tdir/ext2-mountpoint/.. || error
2390 cleanup_test32_mount
2392 run_test 32b "open d32b/ext2-mountpoint/.. ====================="
2395 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2396 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2397 trap cleanup_test32_mount EXIT
2398 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2399 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2400 test_mkdir -p $DIR/$tdir/d2/test_dir
2401 $CHECKSTAT -t dir $DIR/$tdir/ext2-mountpoint/../d2/test_dir || error
2402 cleanup_test32_mount
2404 run_test 32c "stat d32c/ext2-mountpoint/../d2/test_dir ========="
2407 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2408 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2409 trap cleanup_test32_mount EXIT
2410 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2411 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2412 test_mkdir -p $DIR/$tdir/d2/test_dir
2413 ls -al $DIR/$tdir/ext2-mountpoint/../d2/test_dir || error
2414 cleanup_test32_mount
2416 run_test 32d "open d32d/ext2-mountpoint/../d2/test_dir ========="
2419 [ -e $DIR/d32e ] && rm -fr $DIR/d32e
2420 test_mkdir -p $DIR/d32e/tmp
2421 TMP_DIR=$DIR/d32e/tmp
2422 ln -s $DIR/d32e $TMP_DIR/symlink11
2423 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
2424 $CHECKSTAT -t link $DIR/d32e/tmp/symlink11 || error
2425 $CHECKSTAT -t link $DIR/d32e/symlink01 || error
2427 run_test 32e "stat d32e/symlink->tmp/symlink->lustre-subdir ===="
2430 [ -e $DIR/d32f ] && rm -fr $DIR/d32f
2431 test_mkdir -p $DIR/d32f/tmp
2432 TMP_DIR=$DIR/d32f/tmp
2433 ln -s $DIR/d32f $TMP_DIR/symlink11
2434 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
2435 ls $DIR/d32f/tmp/symlink11 || error
2436 ls $DIR/d32f/symlink01 || error
2438 run_test 32f "open d32f/symlink->tmp/symlink->lustre-subdir ===="
2441 TMP_DIR=$DIR/$tdir/tmp
2442 test_mkdir -p $DIR/$tdir/tmp
2443 test_mkdir $DIR/${tdir}2
2444 ln -s $DIR/${tdir}2 $TMP_DIR/symlink12
2445 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
2446 $CHECKSTAT -t link $TMP_DIR/symlink12 || error
2447 $CHECKSTAT -t link $DIR/$tdir/symlink02 || error
2448 $CHECKSTAT -t dir -f $TMP_DIR/symlink12 || error
2449 $CHECKSTAT -t dir -f $DIR/$tdir/symlink02 || error
2451 run_test 32g "stat d32g/symlink->tmp/symlink->lustre-subdir/${tdir}2"
2454 rm -fr $DIR/$tdir $DIR/${tdir}2
2455 TMP_DIR=$DIR/$tdir/tmp
2456 test_mkdir -p $DIR/$tdir/tmp
2457 test_mkdir $DIR/${tdir}2
2458 ln -s $DIR/${tdir}2 $TMP_DIR/symlink12
2459 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
2460 ls $TMP_DIR/symlink12 || error
2461 ls $DIR/$tdir/symlink02 || error
2463 run_test 32h "open d32h/symlink->tmp/symlink->lustre-subdir/${tdir}2"
2466 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2467 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2468 trap cleanup_test32_mount EXIT
2469 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2470 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2471 touch $DIR/$tdir/test_file
2472 $CHECKSTAT -t file $DIR/$tdir/ext2-mountpoint/../test_file || error
2473 cleanup_test32_mount
2475 run_test 32i "stat d32i/ext2-mountpoint/../test_file ==========="
2478 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2479 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
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 touch $DIR/$tdir/test_file
2484 cat $DIR/$tdir/ext2-mountpoint/../test_file || error
2485 cleanup_test32_mount
2487 run_test 32j "open d32j/ext2-mountpoint/../test_file ==========="
2490 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2492 trap cleanup_test32_mount EXIT
2493 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2494 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint
2495 test_mkdir -p $DIR/$tdir/d2
2496 touch $DIR/$tdir/d2/test_file || error
2497 $CHECKSTAT -t file $DIR/$tdir/ext2-mountpoint/../d2/test_file || error
2498 cleanup_test32_mount
2500 run_test 32k "stat d32k/ext2-mountpoint/../d2/test_file ========"
2503 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2505 trap cleanup_test32_mount EXIT
2506 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2507 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2508 test_mkdir -p $DIR/$tdir/d2
2509 touch $DIR/$tdir/d2/test_file
2510 cat $DIR/$tdir/ext2-mountpoint/../d2/test_file || error
2511 cleanup_test32_mount
2513 run_test 32l "open d32l/ext2-mountpoint/../d2/test_file ========"
2517 test_mkdir -p $DIR/d32m/tmp
2518 TMP_DIR=$DIR/d32m/tmp
2519 ln -s $DIR $TMP_DIR/symlink11
2520 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
2521 $CHECKSTAT -t link $DIR/d32m/tmp/symlink11 || error
2522 $CHECKSTAT -t link $DIR/d32m/symlink01 || error
2524 run_test 32m "stat d32m/symlink->tmp/symlink->lustre-root ======"
2528 test_mkdir -p $DIR/d32n/tmp
2529 TMP_DIR=$DIR/d32n/tmp
2530 ln -s $DIR $TMP_DIR/symlink11
2531 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
2532 ls -l $DIR/d32n/tmp/symlink11 || error
2533 ls -l $DIR/d32n/symlink01 || error
2535 run_test 32n "open d32n/symlink->tmp/symlink->lustre-root ======"
2539 test_mkdir -p $DIR/d32o/tmp
2540 TMP_DIR=$DIR/d32o/tmp
2541 ln -s $DIR/$tfile $TMP_DIR/symlink12
2542 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
2543 $CHECKSTAT -t link $DIR/d32o/tmp/symlink12 || error
2544 $CHECKSTAT -t link $DIR/d32o/symlink02 || error
2545 $CHECKSTAT -t file -f $DIR/d32o/tmp/symlink12 || error
2546 $CHECKSTAT -t file -f $DIR/d32o/symlink02 || error
2548 run_test 32o "stat d32o/symlink->tmp/symlink->lustre-root/$tfile"
2558 test_mkdir -p $DIR/d32p/tmp
2560 TMP_DIR=$DIR/d32p/tmp
2562 ln -s $DIR/$tfile $TMP_DIR/symlink12
2564 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
2566 cat $DIR/d32p/tmp/symlink12 || error
2568 cat $DIR/d32p/symlink02 || error
2571 run_test 32p "open d32p/symlink->tmp/symlink->lustre-root/$tfile"
2573 cleanup_testdir_mount() {
2579 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2580 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2581 trap cleanup_testdir_mount EXIT
2582 test_mkdir -p $DIR/$tdir
2583 touch $DIR/$tdir/under_the_mount
2584 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir
2585 ls $DIR/$tdir | grep "\<under_the_mount\>" && error
2586 cleanup_testdir_mount
2588 run_test 32q "stat follows mountpoints in Lustre (should return error)"
2591 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2592 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2593 trap cleanup_testdir_mount EXIT
2594 test_mkdir -p $DIR/$tdir
2595 touch $DIR/$tdir/under_the_mount
2596 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir
2597 ls $DIR/$tdir | grep -q under_the_mount && error || true
2598 cleanup_testdir_mount
2600 run_test 32r "opendir follows mountpoints in Lustre (should return error)"
2605 chmod 444 $DIR/$tfile
2606 chown $RUNAS_ID $DIR/$tfile
2608 $RUNAS $OPENFILE -f O_RDWR $DIR/$tfile && error || true
2611 run_test 33aa "write file with mode 444 (should return error) ===="
2615 test_mkdir -p $DIR/d33
2616 chown $RUNAS_ID $DIR/d33
2617 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $DIR/d33/f33|| error "create"
2618 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $DIR/d33/f33 && \
2619 error "open RDWR" || true
2621 run_test 33a "test open file(mode=0444) with O_RDWR (should return error)"
2625 test_mkdir -p $DIR/d33
2626 chown $RUNAS_ID $DIR/d33
2627 $RUNAS $OPENFILE -f 1286739555 $DIR/d33/f33 || true
2629 run_test 33b "test open file with malformed flags (No panic)"
2632 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2638 remote_ost_nodsh && skip "remote OST with nodsh" && return
2641 test_mkdir -p $DIR/d33
2642 # Read: 0, Write: 4, create/destroy: 2/0, stat: 1, punch: 0
2645 for ostnum in $(seq $OSTCOUNT); do
2646 # test-framework's OST numbering is one-based, while Lustre's
2648 ostname=$(printf "$FSNAME-OST%.4x" $((ostnum - 1)))
2649 # Parsing llobdstat's output sucks; we could grep the /proc
2650 # path, but that's likely to not be as portable as using the
2651 # llobdstat utility. So we parse lctl output instead.
2652 write_bytes=$(do_facet ost$ostnum lctl get_param -n \
2653 obdfilter/$ostname/stats |
2654 awk '/^write_bytes/ {print $7}' )
2655 echo "baseline_write_bytes@$OSTnum/$ostname=$write_bytes"
2656 if (( ${write_bytes:-0} > 0 ))
2663 $all_zeros || return 0
2666 echo foo > $DIR/d33/bar
2670 # Total up write_bytes after writing. We'd better find non-zeros.
2671 for ostnum in $(seq $OSTCOUNT); do
2672 ostname=$(printf "$FSNAME-OST%.4x" $((ostnum - 1)))
2673 write_bytes=$(do_facet ost$ostnum lctl get_param -n \
2674 obdfilter/$ostname/stats |
2675 awk '/^write_bytes/ {print $7}' )
2676 echo "write_bytes@$OSTnum/$ostname=$write_bytes"
2677 if (( ${write_bytes:-0} > 0 ))
2686 for ostnum in $(seq $OSTCOUNT); do
2687 ostname=$(printf "$FSNAME-OST%.4x" $((ostnum - 1)))
2688 echo "Check that write_bytes is present in obdfilter/*/stats:"
2689 do_facet ost$ostnum lctl get_param -n \
2690 obdfilter/$ostname/stats
2692 error "OST not keeping write_bytes stats (b22312)"
2695 run_test 33c "test llobdstat and write_bytes"
2698 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 2 MDTs" && return
2699 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2701 local remote_dir=$DIR/$tdir/remote_dir
2703 test_mkdir -p $DIR/$tdir
2704 $LFS mkdir -i $MDTIDX $remote_dir ||
2705 error "create remote directory failed"
2707 touch $remote_dir/$tfile
2708 chmod 444 $remote_dir/$tfile
2709 chown $RUNAS_ID $remote_dir/$tfile
2711 $RUNAS $OPENFILE -f O_RDWR $DIR/$tfile && error || true
2713 chown $RUNAS_ID $remote_dir
2714 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $remote_dir/f33 ||
2715 error "create" || true
2716 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $remote_dir/f33 &&
2717 error "open RDWR" || true
2718 $RUNAS $OPENFILE -f 1286739555 $remote_dir/f33 || true
2720 run_test 33d "openfile with 444 modes and malformed flags under remote dir"
2723 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2727 $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
2728 $LFS setdirstripe -i1 -c2 $DIR/$tdir/striped_dir1
2729 mkdir $DIR/$tdir/local_dir
2731 local s0_mode=$(stat -c%f $DIR/$tdir/striped_dir)
2732 local s1_mode=$(stat -c%f $DIR/$tdir/striped_dir1)
2733 local l_mode=$(stat -c%f $DIR/$tdir/local_dir)
2735 [ "$l_mode" = "$s0_mode" -a "$l_mode" = "$s1_mode" ] ||
2736 error "mkdir $l_mode striped0 $s0_mode striped1 $s1_mode"
2738 rmdir $DIR/$tdir/* || error "rmdir failed"
2741 $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
2742 $LFS setdirstripe -i1 -c2 $DIR/$tdir/striped_dir1
2743 mkdir $DIR/$tdir/local_dir
2745 s0_mode=$(stat -c%f $DIR/$tdir/striped_dir)
2746 s1_mode=$(stat -c%f $DIR/$tdir/striped_dir1)
2747 l_mode=$(stat -c%f $DIR/$tdir/local_dir)
2749 [ "$l_mode" = "$s0_mode" -a "$l_mode" = "$s1_mode" ] ||
2750 error "mkdir $l_mode striped0 $s0_mode striped1 $s1_mode 777"
2752 rmdir $DIR/$tdir/* || error "rmdir(umask 777) failed"
2755 $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
2756 $LFS setdirstripe -i1 -c2 $DIR/$tdir/striped_dir1
2757 mkdir $DIR/$tdir/local_dir
2759 s0_mode=$(stat -c%f $DIR/$tdir/striped_dir)
2760 s1_mode=$(stat -c%f $DIR/$tdir/striped_dir1)
2761 l_mode=$(stat -c%f $DIR/$tdir/local_dir)
2763 [ "$l_mode" = "$s0_mode" -a "$l_mode" = "$s1_mode" ] ||
2764 error "mkdir $l_mode striped0 $s0_mode striped1 $s1_mode 0"
2766 run_test 33e "mkdir and striped directory should have same mode"
2770 do_facet $SINGLEMDS $LCTL set_param mdt.*.enable_remote_dir_gid=0
2774 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2777 chmod go+rwx $DIR/$tdir
2778 do_facet $SINGLEMDS $LCTL set_param mdt.*.enable_remote_dir_gid=-1
2779 trap cleanup_33f EXIT
2781 $RUNAS lfs mkdir -c$MDSCOUNT $DIR/$tdir/striped_dir ||
2782 error "cannot create striped directory"
2784 $RUNAS touch $DIR/$tdir/striped_dir/{0..16} ||
2785 error "cannot create files in striped directory"
2787 $RUNAS rm $DIR/$tdir/striped_dir/{0..16} ||
2788 error "cannot remove files in striped directory"
2790 $RUNAS rmdir $DIR/$tdir/striped_dir ||
2791 error "cannot remove striped directory"
2795 run_test 33f "nonroot user can create, access, and remove a striped directory"
2797 TEST_34_SIZE=${TEST_34_SIZE:-2000000000000}
2800 $MCREATE $DIR/f34 || error
2801 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" || error
2802 $TRUNCATE $DIR/f34 $TEST_34_SIZE || error
2803 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" || error
2804 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2806 run_test 34a "truncate file that has not been opened ==========="
2809 [ ! -f $DIR/f34 ] && test_34a
2810 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2811 $OPENFILE -f O_RDONLY $DIR/f34
2812 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" || error
2813 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2815 run_test 34b "O_RDONLY opening file doesn't create objects ====="
2818 [ ! -f $DIR/f34 ] && test_34a
2819 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2820 $OPENFILE -f O_RDWR $DIR/f34
2821 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" && error
2822 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2824 run_test 34c "O_RDWR opening file-with-size works =============="
2827 [ ! -f $DIR/f34 ] && test_34a
2828 dd if=/dev/zero of=$DIR/f34 conv=notrunc bs=4k count=1 || error
2829 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2832 run_test 34d "write to sparse file ============================="
2836 $MCREATE $DIR/f34e || error
2837 $TRUNCATE $DIR/f34e 1000 || error
2838 $CHECKSTAT -s 1000 $DIR/f34e || error
2839 $OPENFILE -f O_RDWR $DIR/f34e
2840 $CHECKSTAT -s 1000 $DIR/f34e || error
2842 run_test 34e "create objects, some with size and some without =="
2844 test_34f() { # bug 6242, 6243
2845 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2848 $MCREATE $DIR/f34f || error
2849 $TRUNCATE $DIR/f34f $SIZE34F || error "truncating $DIR/f3f to $SIZE34F"
2850 dd if=$DIR/f34f of=$TMP/f34f
2851 $CHECKSTAT -s $SIZE34F $TMP/f34f || error "$TMP/f34f not $SIZE34F bytes"
2852 dd if=/dev/zero of=$TMP/f34fzero bs=$SIZE34F count=1
2853 cmp $DIR/f34f $TMP/f34fzero || error "$DIR/f34f not all zero"
2854 cmp $TMP/f34f $TMP/f34fzero || error "$TMP/f34f not all zero"
2855 rm $TMP/f34f $TMP/f34fzero $DIR/f34f
2857 run_test 34f "read from a file with no objects until EOF ======="
2860 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2861 dd if=/dev/zero of=$DIR/$tfile bs=1 count=100 seek=$TEST_34_SIZE || error
2862 $TRUNCATE $DIR/$tfile $((TEST_34_SIZE / 2))|| error
2863 $CHECKSTAT -s $((TEST_34_SIZE / 2)) $DIR/$tfile || error "truncate failed"
2864 cancel_lru_locks osc
2865 $CHECKSTAT -s $((TEST_34_SIZE / 2)) $DIR/$tfile || \
2866 error "wrong size after lock cancel"
2868 $TRUNCATE $DIR/$tfile $TEST_34_SIZE || error
2869 $CHECKSTAT -s $TEST_34_SIZE $DIR/$tfile || \
2870 error "expanding truncate failed"
2871 cancel_lru_locks osc
2872 $CHECKSTAT -s $TEST_34_SIZE $DIR/$tfile || \
2873 error "wrong expanded size after lock cancel"
2875 run_test 34g "truncate long file ==============================="
2878 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2882 dd if=/dev/zero of=$DIR/$tfile bs=1M count=10 || error
2883 sync # Flush the cache so that multiop below does not block on cache
2884 # flush when getting the group lock
2885 $MULTIOP $DIR/$tfile OG${gid}T${sz}g${gid}c &
2888 # Since just timed wait is not good enough, let's do a sync write
2889 # that way we are sure enough time for a roundtrip + processing
2890 # passed + 2 seconds of extra margin.
2891 dd if=/dev/zero of=$DIR/${tfile}-1 bs=4096 oflag=direct count=1
2895 if [[ `ps h -o comm -p $MULTIPID` == "multiop" ]]; then
2896 error "Multiop blocked on ftruncate, pid=$MULTIPID"
2900 local nsz=`stat -c %s $DIR/$tfile`
2901 [[ $nsz == $sz ]] || error "New size wrong $nsz != $sz"
2903 run_test 34h "ftruncate file under grouplock should not block"
2906 cp /bin/sh $DIR/f35a
2908 chown $RUNAS_ID $DIR/f35a
2909 $RUNAS $DIR/f35a && error || true
2912 run_test 35a "exec file with mode 444 (should return and not leak) ====="
2916 utime $DIR/f36 || error
2918 run_test 36a "MDS utime check (mknod, utime) ==================="
2922 utime $DIR/f36 || error
2924 run_test 36b "OST utime check (open, utime) ===================="
2929 chown $RUNAS_ID $DIR/d36
2930 $RUNAS utime $DIR/d36/f36 || error
2932 run_test 36c "non-root MDS utime check (mknod, utime) =========="
2935 [ ! -d $DIR/d36 ] && test_36c
2936 echo "" > $DIR/d36/f36
2937 $RUNAS utime $DIR/d36/f36 || error
2939 run_test 36d "non-root OST utime check (open, utime) ==========="
2942 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID -- skipping" && return
2943 test_mkdir -p $DIR/$tdir
2944 touch $DIR/$tdir/$tfile
2945 $RUNAS utime $DIR/$tdir/$tfile && \
2946 error "utime worked, expected failure" || true
2948 run_test 36e "utime on non-owned file (should return error) ===="
2952 local LANG_SAVE=$LANG
2953 local LC_LANG_SAVE=$LC_LANG
2954 export LANG=C LC_LANG=C # for date language
2956 DATESTR="Dec 20 2000"
2957 test_mkdir -p $DIR/$tdir
2958 lctl set_param fail_loc=$fl
2960 cp /etc/hosts $DIR/$tdir/$tfile
2961 sync & # write RPC generated with "current" inode timestamp, but delayed
2963 touch --date="$DATESTR" $DIR/$tdir/$tfile # setattr timestamp in past
2964 LS_BEFORE="`ls -l $DIR/$tdir/$tfile`" # old timestamp from client cache
2965 cancel_lru_locks osc
2966 LS_AFTER="`ls -l $DIR/$tdir/$tfile`" # timestamp from OST object
2968 [ "$LS_BEFORE" != "$LS_AFTER" ] && \
2969 echo "BEFORE: $LS_BEFORE" && \
2970 echo "AFTER : $LS_AFTER" && \
2971 echo "WANT : $DATESTR" && \
2972 error "$DIR/$tdir/$tfile timestamps changed" || true
2974 export LANG=$LANG_SAVE LC_LANG=$LC_LANG_SAVE
2978 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2979 #define OBD_FAIL_OST_BRW_PAUSE_BULK 0x214
2980 subr_36fh "0x80000214"
2982 run_test 36f "utime on file racing with OST BRW write =========="
2985 remote_ost_nodsh && skip "remote OST with nodsh" && return
2986 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2991 test_mkdir -p $DIR/$tdir
2992 fmd_max_age=$(do_facet ost1 \
2993 "lctl get_param -n obdfilter.*.client_cache_seconds 2> /dev/null | \
2996 fmd_before=$(do_facet ost1 \
2997 "awk '/ll_fmd_cache/ {print \\\$2}' /proc/slabinfo")
2998 touch $DIR/$tdir/$tfile
2999 sleep $((fmd_max_age + 12))
3000 fmd_after=$(do_facet ost1 \
3001 "awk '/ll_fmd_cache/ {print \\\$2}' /proc/slabinfo")
3003 echo "fmd_before: $fmd_before"
3004 echo "fmd_after: $fmd_after"
3005 [[ $fmd_after -gt $fmd_before ]] &&
3006 echo "AFTER: $fmd_after > BEFORE: $fmd_before" &&
3007 error "fmd didn't expire after ping" || true
3009 run_test 36g "filter mod data cache expiry ====================="
3012 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3013 #define OBD_FAIL_OST_BRW_PAUSE_BULK2 0x227
3014 subr_36fh "0x80000227"
3016 run_test 36h "utime on file racing with OST BRW write =========="
3019 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
3021 test_mkdir $DIR/$tdir
3022 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR/$tdir/striped_dir
3024 local mtime=$(stat -c%Y $DIR/$tdir/striped_dir)
3025 local new_mtime=$((mtime + 200))
3027 #change Modify time of striped dir
3028 touch -m -d @$new_mtime $DIR/$tdir/striped_dir ||
3029 error "change mtime failed"
3031 local got=$(stat -c%Y $DIR/$tdir/striped_dir)
3033 [ "$new_mtime" = "$got" ] || error "expect $new_mtime got $got"
3035 run_test 36i "change mtime on striped directory"
3037 # test_37 - duplicate with tests 32q 32r
3040 local file=$DIR/$tfile
3042 openfile -f O_DIRECTORY $file
3045 [ $RC -eq 0 ] && error "opened file $file with O_DIRECTORY" || true
3046 [ $RC -eq $ENOTDIR ] || error "error $RC should be ENOTDIR ($ENOTDIR)"
3048 run_test 38 "open a regular file with O_DIRECTORY should return -ENOTDIR ==="
3052 touch $DIR/${tfile}2
3053 # ls -l $DIR/$tfile $DIR/${tfile}2
3054 # ls -lu $DIR/$tfile $DIR/${tfile}2
3055 # ls -lc $DIR/$tfile $DIR/${tfile}2
3057 $OPENFILE -f O_CREAT:O_TRUNC:O_WRONLY $DIR/${tfile}2
3058 if [ ! $DIR/${tfile}2 -nt $DIR/$tfile ]; then
3060 ls -l --full-time $DIR/$tfile $DIR/${tfile}2
3062 ls -lu --full-time $DIR/$tfile $DIR/${tfile}2
3064 ls -lc --full-time $DIR/$tfile $DIR/${tfile}2
3065 error "O_TRUNC didn't change timestamps"
3068 run_test 39 "mtime changed on create ==========================="
3071 test_mkdir -p -c1 $DIR/$tdir
3072 cp -p /etc/passwd $DIR/$tdir/fopen
3073 cp -p /etc/passwd $DIR/$tdir/flink
3074 cp -p /etc/passwd $DIR/$tdir/funlink
3075 cp -p /etc/passwd $DIR/$tdir/frename
3076 ln $DIR/$tdir/funlink $DIR/$tdir/funlink2
3079 echo "aaaaaa" >> $DIR/$tdir/fopen
3080 echo "aaaaaa" >> $DIR/$tdir/flink
3081 echo "aaaaaa" >> $DIR/$tdir/funlink
3082 echo "aaaaaa" >> $DIR/$tdir/frename
3084 local open_new=`stat -c %Y $DIR/$tdir/fopen`
3085 local link_new=`stat -c %Y $DIR/$tdir/flink`
3086 local unlink_new=`stat -c %Y $DIR/$tdir/funlink`
3087 local rename_new=`stat -c %Y $DIR/$tdir/frename`
3089 cat $DIR/$tdir/fopen > /dev/null
3090 ln $DIR/$tdir/flink $DIR/$tdir/flink2
3091 rm -f $DIR/$tdir/funlink2
3092 mv -f $DIR/$tdir/frename $DIR/$tdir/frename2
3094 for (( i=0; i < 2; i++ )) ; do
3095 local open_new2=`stat -c %Y $DIR/$tdir/fopen`
3096 local link_new2=`stat -c %Y $DIR/$tdir/flink`
3097 local unlink_new2=`stat -c %Y $DIR/$tdir/funlink`
3098 local rename_new2=`stat -c %Y $DIR/$tdir/frename2`
3100 [ $open_new2 -eq $open_new ] || error "open file reverses mtime"
3101 [ $link_new2 -eq $link_new ] || error "link file reverses mtime"
3102 [ $unlink_new2 -eq $unlink_new ] || error "unlink file reverses mtime"
3103 [ $rename_new2 -eq $rename_new ] || error "rename file reverses mtime"
3105 cancel_lru_locks osc
3106 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3109 run_test 39b "mtime change on open, link, unlink, rename ======"
3111 # this should be set to past
3112 TEST_39_MTIME=`date -d "1 year ago" +%s`
3118 local mtime0=`stat -c %Y $DIR1/$tfile`
3120 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3121 local mtime1=`stat -c %Y $DIR1/$tfile`
3122 [ "$mtime1" = $TEST_39_MTIME ] || \
3123 error "mtime is not set to past: $mtime1, should be $TEST_39_MTIME"
3126 echo hello >> $DIR1/$tfile
3128 local mtime2=`stat -c %Y $DIR1/$tfile`
3129 [ "$mtime2" -ge "$d1" ] && [ "$mtime2" -le "$d2" ] || \
3130 error "mtime is not updated on write: $d1 <= $mtime2 <= $d2"
3132 mv $DIR1/$tfile $DIR1/$tfile-1
3134 for (( i=0; i < 2; i++ )) ; do
3135 local mtime3=`stat -c %Y $DIR1/$tfile-1`
3136 [ "$mtime2" = "$mtime3" ] || \
3137 error "mtime ($mtime2) changed (to $mtime3) on rename"
3139 cancel_lru_locks osc
3140 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3143 run_test 39c "mtime change on rename ==========================="
3147 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3150 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3152 for (( i=0; i < 2; i++ )) ; do
3153 local mtime=`stat -c %Y $DIR1/$tfile`
3154 [ $mtime = $TEST_39_MTIME ] || \
3155 error "mtime($mtime) is not set to $TEST_39_MTIME"
3157 cancel_lru_locks osc
3158 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3161 run_test 39d "create, utime, stat =============================="
3165 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3167 local mtime1=`stat -c %Y $DIR1/$tfile`
3169 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3171 for (( i=0; i < 2; i++ )) ; do
3172 local mtime2=`stat -c %Y $DIR1/$tfile`
3173 [ $mtime2 = $TEST_39_MTIME ] || \
3174 error "mtime($mtime2) is not set to $TEST_39_MTIME"
3176 cancel_lru_locks osc
3177 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3180 run_test 39e "create, stat, utime, stat ========================"
3184 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3186 mtime1=`stat -c %Y $DIR1/$tfile`
3189 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3191 for (( i=0; i < 2; i++ )) ; do
3192 local mtime2=`stat -c %Y $DIR1/$tfile`
3193 [ $mtime2 = $TEST_39_MTIME ] || \
3194 error "mtime($mtime2) is not set to $TEST_39_MTIME"
3196 cancel_lru_locks osc
3197 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3200 run_test 39f "create, stat, sleep, utime, stat ================="
3204 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3205 echo hello >> $DIR1/$tfile
3206 local mtime1=`stat -c %Y $DIR1/$tfile`
3209 chmod o+r $DIR1/$tfile
3211 for (( i=0; i < 2; i++ )) ; do
3212 local mtime2=`stat -c %Y $DIR1/$tfile`
3213 [ "$mtime1" = "$mtime2" ] || \
3214 error "lost mtime: $mtime2, should be $mtime1"
3216 cancel_lru_locks osc
3217 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3220 run_test 39g "write, chmod, stat ==============================="
3224 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3229 echo hello >> $DIR1/$tfile
3230 local mtime1=`stat -c %Y $DIR1/$tfile`
3232 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3234 if [ "$d1" != "$d2" ]; then
3235 echo "write and touch not within one second"
3237 for (( i=0; i < 2; i++ )) ; do
3238 local mtime2=`stat -c %Y $DIR1/$tfile`
3239 [ "$mtime2" = $TEST_39_MTIME ] || \
3240 error "lost mtime: $mtime2, should be $TEST_39_MTIME"
3242 cancel_lru_locks osc
3243 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3247 run_test 39h "write, utime within one second, stat ============="
3250 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3254 echo hello >> $DIR1/$tfile
3255 local mtime1=`stat -c %Y $DIR1/$tfile`
3257 mv $DIR1/$tfile $DIR1/$tfile-1
3259 for (( i=0; i < 2; i++ )) ; do
3260 local mtime2=`stat -c %Y $DIR1/$tfile-1`
3262 [ "$mtime1" = "$mtime2" ] || \
3263 error "lost mtime: $mtime2, should be $mtime1"
3265 cancel_lru_locks osc
3266 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3269 run_test 39i "write, rename, stat =============================="
3272 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3273 start_full_debug_logging
3277 #define OBD_FAIL_OSC_DELAY_SETTIME 0x412
3278 lctl set_param fail_loc=0x80000412
3279 multiop_bg_pause $DIR1/$tfile oO_RDWR:w2097152_c ||
3280 error "multiop failed"
3282 local mtime1=`stat -c %Y $DIR1/$tfile`
3284 mv $DIR1/$tfile $DIR1/$tfile-1
3286 kill -USR1 $multipid
3287 wait $multipid || error "multiop close failed"
3289 for (( i=0; i < 2; i++ )) ; do
3290 local mtime2=`stat -c %Y $DIR1/$tfile-1`
3291 [ "$mtime1" = "$mtime2" ] ||
3292 error "mtime is lost on close: $mtime2, " \
3295 cancel_lru_locks osc
3296 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3298 lctl set_param fail_loc=0
3299 stop_full_debug_logging
3301 run_test 39j "write, rename, close, stat ======================="
3304 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3308 multiop_bg_pause $DIR1/$tfile oO_RDWR:w2097152_c || error "multiop failed"
3310 local mtime1=`stat -c %Y $DIR1/$tfile`
3312 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3314 kill -USR1 $multipid
3315 wait $multipid || error "multiop close failed"
3317 for (( i=0; i < 2; i++ )) ; do
3318 local mtime2=`stat -c %Y $DIR1/$tfile`
3320 [ "$mtime2" = $TEST_39_MTIME ] || \
3321 error "mtime is lost on close: $mtime2, should be $TEST_39_MTIME"
3323 cancel_lru_locks osc
3324 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3327 run_test 39k "write, utime, close, stat ========================"
3329 # this should be set to future
3330 TEST_39_ATIME=`date -d "1 year" +%s`
3333 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3334 remote_mds_nodsh && skip "remote MDS with nodsh" && return
3335 local atime_diff=$(do_facet $SINGLEMDS \
3336 lctl get_param -n mdd.*MDT0000*.atime_diff)
3340 # test setting directory atime to future
3341 touch -a -d @$TEST_39_ATIME $DIR/$tdir
3342 local atime=$(stat -c %X $DIR/$tdir)
3343 [ "$atime" = $TEST_39_ATIME ] || \
3344 error "atime is not set to future: $atime, $TEST_39_ATIME"
3346 # test setting directory atime from future to now
3347 local d1=$(date +%s)
3349 local d2=$(date +%s)
3351 cancel_lru_locks mdc
3352 atime=$(stat -c %X $DIR/$tdir)
3353 [ "$atime" -ge "$d1" -a "$atime" -le "$d2" ] || \
3354 error "atime is not updated from future: $atime, $d1<atime<$d2"
3356 do_facet $SINGLEMDS lctl set_param -n mdd.*MDT0000*.atime_diff=2
3359 # test setting directory atime when now > dir atime + atime_diff
3363 cancel_lru_locks mdc
3364 atime=$(stat -c %X $DIR/$tdir)
3365 [ "$atime" -ge "$d1" -a "$atime" -le "$d2" ] || \
3366 error "atime is not updated : $atime, should be $d2"
3368 do_facet $SINGLEMDS lctl set_param -n mdd.*MDT0000*.atime_diff=60
3371 # test not setting directory atime when now < dir atime + atime_diff
3373 cancel_lru_locks mdc
3374 atime=$(stat -c %X $DIR/$tdir)
3375 [ "$atime" -ge "$d1" -a "$atime" -le "$d2" ] || \
3376 error "atime is updated to $atime, should remain $d1<atime<$d2"
3378 do_facet $SINGLEMDS \
3379 lctl set_param -n mdd.*MDT0000*.atime_diff=$atime_diff
3381 run_test 39l "directory atime update ==========================="
3384 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3387 local far_past_mtime=$(date -d "May 29 1953" +%s)
3388 local far_past_atime=$(date -d "Dec 17 1903" +%s)
3390 touch -m -d @$far_past_mtime $DIR1/$tfile
3391 touch -a -d @$far_past_atime $DIR1/$tfile
3393 for (( i=0; i < 2; i++ )) ; do
3394 local timestamps=$(stat -c "%X %Y" $DIR1/$tfile)
3395 [ "$timestamps" = "$far_past_atime $far_past_mtime" ] || \
3396 error "atime or mtime set incorrectly"
3398 cancel_lru_locks osc
3399 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3402 run_test 39m "test atime and mtime before 1970"
3404 test_39n() { # LU-3832
3405 local atime_diff=$(do_facet $SINGLEMDS \
3406 lctl get_param -n mdd.*MDT0000*.atime_diff)
3411 do_facet $SINGLEMDS lctl set_param -n mdd.*MDT0000*.atime_diff=1
3414 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 status=noxfer
3415 atime0=$(stat -c %X $DIR/$tfile)
3418 $MULTIOP $DIR/$tfile oO_RDONLY:O_NOATIME:r4096c
3419 atime1=$(stat -c %X $DIR/$tfile)
3422 cancel_lru_locks mdc
3423 cancel_lru_locks osc
3424 $MULTIOP $DIR/$tfile oO_RDONLY:O_NOATIME:r4096c
3425 atime2=$(stat -c %X $DIR/$tfile)
3427 do_facet $SINGLEMDS \
3428 lctl set_param -n mdd.*MDT0000*.atime_diff=$atime_diff
3430 [ "$atime0" -eq "$atime1" ] || error "atime0 $atime0 != atime1 $atime1"
3431 [ "$atime1" -eq "$atime2" ] || error "atime0 $atime0 != atime1 $atime1"
3433 run_test 39n "check that O_NOATIME is honored"
3436 TESTDIR=$DIR/$tdir/$tfile
3437 [ -e $TESTDIR ] && rm -rf $TESTDIR
3444 links2=$(stat -c %h .)
3445 [ $(($links1 + 2)) != $links2 ] &&
3446 error "wrong links count $(($links1 + 2)) != $links2"
3448 links3=$(stat -c %h .)
3449 [ $(($links1 + 1)) != $links3 ] &&
3450 error "wrong links count $links1 != $links3"
3453 run_test 39o "directory cached attributes updated after create ========"
3456 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 2 MDTs" && return
3458 TESTDIR=$DIR/$tdir/$tfile
3459 [ -e $TESTDIR ] && rm -rf $TESTDIR
3460 test_mkdir -p $TESTDIR
3464 $LFS mkdir -i $MDTIDX $TESTDIR/remote_dir1
3465 $LFS mkdir -i $MDTIDX $TESTDIR/remote_dir2
3467 links2=$(stat -c %h .)
3468 [ $(($links1 + 2)) != $links2 ] &&
3469 error "wrong links count $(($links1 + 2)) != $links2"
3471 links3=$(stat -c %h .)
3472 [ $(($links1 + 1)) != $links3 ] &&
3473 error "wrong links count $links1 != $links3"
3476 run_test 39p "remote directory cached attributes updated after create ========"
3480 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1
3481 $RUNAS $OPENFILE -f O_WRONLY:O_TRUNC $DIR/$tfile &&
3482 error "openfile O_WRONLY:O_TRUNC $tfile failed"
3483 $CHECKSTAT -t file -s 4096 $DIR/$tfile ||
3484 error "$tfile is not 4096 bytes in size"
3486 run_test 40 "failed open(O_TRUNC) doesn't truncate ============="
3490 small_write $DIR/f41 18
3492 run_test 41 "test small file write + fstat ====================="
3494 count_ost_writes() {
3495 lctl get_param -n osc.*.stats |
3496 awk -vwrites=0 '/ost_write/ { writes += $2 } \
3497 END { printf("%0.0f", writes) }'
3504 BG_DIRTY_RATIO_SAVE=10
3505 MAX_BG_DIRTY_RATIO=25
3509 # in 2.6, restore /proc/sys/vm/dirty_writeback_centisecs,
3510 # dirty_ratio, dirty_background_ratio
3511 if [ -f /proc/sys/vm/dirty_writeback_centisecs ]; then
3512 sysctl -w vm.dirty_writeback_centisecs=$WRITEBACK_SAVE
3513 sysctl -w vm.dirty_background_ratio=$BG_DIRTY_RATIO_SAVE
3514 sysctl -w vm.dirty_ratio=$DIRTY_RATIO_SAVE
3516 # if file not here, we are a 2.4 kernel
3517 kill -CONT `pidof kupdated`
3522 # setup the trap first, so someone cannot exit the test at the
3523 # exact wrong time and mess up a machine
3524 trap start_writeback EXIT
3525 # in 2.6, save and 0 /proc/sys/vm/dirty_writeback_centisecs
3526 if [ -f /proc/sys/vm/dirty_writeback_centisecs ]; then
3527 WRITEBACK_SAVE=`sysctl -n vm.dirty_writeback_centisecs`
3528 sysctl -w vm.dirty_writeback_centisecs=0
3529 sysctl -w vm.dirty_writeback_centisecs=0
3530 # save and increase /proc/sys/vm/dirty_ratio
3531 DIRTY_RATIO_SAVE=`sysctl -n vm.dirty_ratio`
3532 sysctl -w vm.dirty_ratio=$MAX_DIRTY_RATIO
3533 # save and increase /proc/sys/vm/dirty_background_ratio
3534 BG_DIRTY_RATIO_SAVE=`sysctl -n vm.dirty_background_ratio`
3535 sysctl -w vm.dirty_background_ratio=$MAX_BG_DIRTY_RATIO
3537 # if file not here, we are a 2.4 kernel
3538 kill -STOP `pidof kupdated`
3542 # ensure that all stripes have some grant before we test client-side cache
3544 for i in `seq -f $DIR/f42-%g 1 $OSTCOUNT`; do
3545 dd if=/dev/zero of=$i bs=4k count=1
3550 # Tests 42* verify that our behaviour is correct WRT caching, file closure,
3551 # file truncation, and file removal.
3553 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3555 cancel_lru_locks osc
3557 sync; sleep 1; sync # just to be safe
3558 BEFOREWRITES=`count_ost_writes`
3559 lctl get_param -n osc.*[oO][sS][cC][_-]*.cur_grant_bytes | grep "[0-9]"
3560 dd if=/dev/zero of=$DIR/f42a bs=1024 count=100
3561 AFTERWRITES=`count_ost_writes`
3562 [ $BEFOREWRITES -eq $AFTERWRITES ] || \
3563 error "$BEFOREWRITES < $AFTERWRITES"
3566 run_test 42a "ensure that we don't flush on close =============="
3569 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3571 cancel_lru_locks osc
3574 dd if=/dev/zero of=$DIR/f42b bs=1024 count=100
3575 BEFOREWRITES=$(count_ost_writes)
3576 $MUNLINK $DIR/f42b || error "$MUNLINK $DIR/f42b: $?"
3577 AFTERWRITES=$(count_ost_writes)
3578 if [[ $BEFOREWRITES -lt $AFTERWRITES ]]; then
3579 error "$BEFOREWRITES < $AFTERWRITES on unlink"
3581 BEFOREWRITES=$(count_ost_writes)
3582 sync || error "sync: $?"
3583 AFTERWRITES=$(count_ost_writes)
3584 if [[ $BEFOREWRITES -lt $AFTERWRITES ]]; then
3585 error "$BEFOREWRITES < $AFTERWRITES on sync"
3587 dmesg | grep 'error from obd_brw_async' && error 'error writing back'
3591 run_test 42b "test destroy of file with cached dirty data ======"
3593 # if these tests just want to test the effect of truncation,
3594 # they have to be very careful. consider:
3595 # - the first open gets a {0,EOF}PR lock
3596 # - the first write conflicts and gets a {0, count-1}PW
3597 # - the rest of the writes are under {count,EOF}PW
3598 # - the open for truncate tries to match a {0,EOF}PR
3599 # for the filesize and cancels the PWs.
3600 # any number of fixes (don't get {0,EOF} on open, match
3601 # composite locks, do smarter file size management) fix
3602 # this, but for now we want these tests to verify that
3603 # the cancellation with truncate intent works, so we
3604 # start the file with a full-file pw lock to match against
3605 # until the truncate.
3610 cancel_lru_locks osc
3612 # prime the file with 0,EOF PW to match
3616 # now the real test..
3617 dd if=/dev/zero of=$file bs=1024 count=100
3618 BEFOREWRITES=`count_ost_writes`
3619 $TRUNCATE $file $offset
3620 cancel_lru_locks osc
3621 AFTERWRITES=`count_ost_writes`
3626 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3628 [ $BEFOREWRITES -eq $AFTERWRITES ] && \
3629 error "beforewrites $BEFOREWRITES == afterwrites $AFTERWRITES on truncate"
3632 run_test 42c "test partial truncate of file with cached dirty data"
3635 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3637 [ $BEFOREWRITES -eq $AFTERWRITES ] || \
3638 error "beforewrites $BEFOREWRITES != afterwrites $AFTERWRITES on truncate"
3641 run_test 42d "test complete truncate of file with cached dirty data"
3643 test_42e() { # bug22074
3644 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3645 local TDIR=$DIR/${tdir}e
3646 local pagesz=$(page_size)
3647 local pages=16 # hardcoded 16 pages, don't change it.
3648 local files=$((OSTCOUNT * 500)) # hopefully 500 files on each OST
3649 local proc_osc0="osc.${FSNAME}-OST0000-osc-[^MDT]*"
3653 test_mkdir -p $DIR/${tdir}e
3654 $SETSTRIPE -c 1 $TDIR
3655 createmany -o $TDIR/f $files
3657 max_dirty_mb=$($LCTL get_param -n $proc_osc0/max_dirty_mb)
3659 # we assume that with $OSTCOUNT files, at least one of them will
3660 # be allocated on OST0.
3661 warmup_files=$((OSTCOUNT * max_dirty_mb))
3662 createmany -o $TDIR/w $warmup_files
3664 # write a large amount of data into one file and sync, to get good
3665 # avail_grant number from OST.
3666 for ((i=0; i<$warmup_files; i++)); do
3667 idx=$($GETSTRIPE -i $TDIR/w$i)
3668 [ $idx -ne 0 ] && continue
3669 dd if=/dev/zero of=$TDIR/w$i bs="$max_dirty_mb"M count=1
3672 [[ $i -gt $warmup_files ]] && error "OST0 is still cold"
3674 $LCTL get_param $proc_osc0/cur_dirty_bytes
3675 $LCTL get_param $proc_osc0/cur_grant_bytes
3677 # create as much dirty pages as we can while not to trigger the actual
3678 # RPCs directly. but depends on the env, VFS may trigger flush during this
3679 # period, hopefully we are good.
3680 for ((i=0; i<$warmup_files; i++)); do
3681 idx=$($GETSTRIPE -i $TDIR/w$i)
3682 [ $idx -ne 0 ] && continue
3683 dd if=/dev/zero of=$TDIR/w$i bs=1M count=1 2>/dev/null
3685 $LCTL get_param $proc_osc0/cur_dirty_bytes
3686 $LCTL get_param $proc_osc0/cur_grant_bytes
3688 # perform the real test
3689 $LCTL set_param $proc_osc0/rpc_stats 0
3690 for ((;i<$files; i++)); do
3691 [ $($GETSTRIPE -i $TDIR/f$i) -eq 0 ] || continue
3692 dd if=/dev/zero of=$TDIR/f$i bs=$pagesz count=$pages 2>/dev/null
3695 $LCTL get_param $proc_osc0/rpc_stats
3698 local have_ppr=false
3699 $LCTL get_param $proc_osc0/rpc_stats |
3700 while read PPR RRPC RPCT RCUM BAR WRPC WPCT WCUM; do
3701 # skip lines until we are at the RPC histogram data
3702 [ "$PPR" == "pages" ] && have_ppr=true && continue
3703 $have_ppr || continue
3705 # we only want the percent stat for < 16 pages
3706 [[ $(echo $PPR | tr -d ':') -ge $pages ]] && break
3708 percent=$((percent + WPCT))
3709 if [[ $percent -gt 15 ]]; then
3710 error "less than 16-pages write RPCs" \
3717 run_test 42e "verify sub-RPC writes are not done synchronously"
3720 test_mkdir -p $DIR/$tdir
3721 cp -p /bin/ls $DIR/$tdir/$tfile
3722 $MULTIOP $DIR/$tdir/$tfile Ow_c &
3724 # give multiop a chance to open
3727 $DIR/$tdir/$tfile && error || true
3730 run_test 43 "execution of file opened for write should return -ETXTBSY"
3733 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3734 test_mkdir -p $DIR/$tdir
3735 cp -p `which $MULTIOP` $DIR/$tdir/multiop ||
3736 cp -p multiop $DIR/$tdir/multiop
3737 MULTIOP_PROG=$DIR/$tdir/multiop multiop_bg_pause $TMP/$tfile.junk O_c ||
3740 $MULTIOP $DIR/$tdir/multiop Oc && error "expected error, got success"
3741 kill -USR1 $MULTIOP_PID || return 2
3742 wait $MULTIOP_PID || return 3
3743 rm $TMP/$tfile.junk $DIR/$tdir/multiop
3745 run_test 43a "open(RDWR) of file being executed should return -ETXTBSY"
3748 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3749 test_mkdir -p $DIR/$tdir
3750 cp -p `which $MULTIOP` $DIR/$tdir/multiop ||
3751 cp -p multiop $DIR/$tdir/multiop
3752 MULTIOP_PROG=$DIR/$tdir/multiop multiop_bg_pause $TMP/$tfile.junk O_c ||
3755 $TRUNCATE $DIR/$tdir/multiop 0 && error "expected error, got success"
3756 kill -USR1 $MULTIOP_PID || return 2
3757 wait $MULTIOP_PID || return 3
3758 rm $TMP/$tfile.junk $DIR/$tdir/multiop
3760 run_test 43b "truncate of file being executed should return -ETXTBSY"
3763 local testdir="$DIR/$tdir"
3764 test_mkdir -p $DIR/$tdir
3766 ( cd $(dirname $SHELL) && md5sum $(basename $SHELL) ) | \
3767 ( cd $testdir && md5sum -c)
3769 run_test 43c "md5sum of copy into lustre========================"
3772 [[ $OSTCOUNT -lt 2 ]] && skip_env "skipping 2-stripe test" && return
3773 dd if=/dev/zero of=$DIR/f1 bs=4k count=1 seek=1023
3774 dd if=$DIR/f1 bs=4k count=1 > /dev/null
3776 run_test 44 "zero length read from a sparse stripe ============="
3779 local nstripe=$($LCTL lov_getconfig $DIR | grep default_stripe_count: |
3781 [ -z "$nstripe" ] && skip "can't get stripe info" && return
3782 [[ $nstripe -gt $OSTCOUNT ]] &&
3783 skip "Wrong default_stripe_count: $nstripe (OSTCOUNT: $OSTCOUNT)" &&
3785 local stride=$($LCTL lov_getconfig $DIR | grep default_stripe_size: |
3787 if [[ $nstripe -eq 0 || $nstripe -eq -1 ]]; then
3788 nstripe=$($LCTL lov_getconfig $DIR | grep obd_count: |
3792 OFFSETS="0 $((stride/2)) $((stride-1))"
3793 for offset in $OFFSETS; do
3794 for i in $(seq 0 $((nstripe-1))); do
3795 local GLOBALOFFSETS=""
3797 local size=$((((i + 2 * $nstripe )*$stride + $offset)))
3798 local myfn=$DIR/d44a-$size
3799 echo "--------writing $myfn at $size"
3800 ll_sparseness_write $myfn $size ||
3801 error "ll_sparseness_write"
3802 GLOBALOFFSETS="$GLOBALOFFSETS $size"
3803 ll_sparseness_verify $myfn $GLOBALOFFSETS ||
3804 error "ll_sparseness_verify $GLOBALOFFSETS"
3806 for j in $(seq 0 $((nstripe-1))); do
3808 size=$((((j + $nstripe )*$stride + $offset)))
3809 ll_sparseness_write $myfn $size ||
3810 error "ll_sparseness_write"
3811 GLOBALOFFSETS="$GLOBALOFFSETS $size"
3813 ll_sparseness_verify $myfn $GLOBALOFFSETS ||
3814 error "ll_sparseness_verify $GLOBALOFFSETS"
3819 run_test 44a "test sparse pwrite ==============================="
3823 for d in `lctl get_param -n osc.*.cur_dirty_bytes`; do
3829 before=`dirty_osc_total`
3830 echo executing "\"$*\""
3832 after=`dirty_osc_total`
3833 echo before $before, after $after
3836 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3838 # Obtain grants from OST if it supports it
3839 echo blah > ${f}_grant
3842 do_dirty_record "echo blah > $f"
3843 [[ $before -eq $after ]] && error "write wasn't cached"
3844 do_dirty_record "> $f"
3845 [[ $before -gt $after ]] || error "truncate didn't lower dirty count"
3846 do_dirty_record "echo blah > $f"
3847 [[ $before -eq $after ]] && error "write wasn't cached"
3848 do_dirty_record "sync"
3849 [[ $before -gt $after ]] || error "writeback didn't lower dirty count"
3850 do_dirty_record "echo blah > $f"
3851 [[ $before -eq $after ]] && error "write wasn't cached"
3852 do_dirty_record "cancel_lru_locks osc"
3853 [[ $before -gt $after ]] ||
3854 error "lock cancellation didn't lower dirty count"
3857 run_test 45 "osc io page accounting ============================"
3859 # in a 2 stripe file (lov.sh), page 1023 maps to page 511 in its object. this
3860 # test tickles a bug where re-dirtying a page was failing to be mapped to the
3861 # objects offset and an assert hit when an rpc was built with 1023's mapped
3862 # offset 511 and 511's raw 511 offset. it also found general redirtying bugs.
3864 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3868 dd if=/dev/zero of=$f bs=`page_size` seek=511 count=1
3870 dd conv=notrunc if=/dev/zero of=$f bs=`page_size` seek=1023 count=1
3871 dd conv=notrunc if=/dev/zero of=$f bs=`page_size` seek=511 count=1
3875 run_test 46 "dirtying a previously written page ================"
3877 # test_47 is removed "Device nodes check" is moved to test_28
3879 test_48a() { # bug 2399
3880 [ $(facet_fstype $SINGLEMDS) = "zfs" ] &&
3881 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.3.63) ] &&
3882 skip "MDS prior to 2.3.63 handle ZFS dir .. incorrectly" &&
3884 test_mkdir $DIR/$tdir
3886 mv $DIR/$tdir $DIR/$tdir.new || error "move directory failed"
3887 test_mkdir $DIR/$tdir || error "recreate directory failed"
3888 touch foo || error "'touch foo' failed after recreating cwd"
3889 test_mkdir bar || error "'mkdir foo' failed after recreating cwd"
3890 touch .foo || error "'touch .foo' failed after recreating cwd"
3891 test_mkdir .bar || error "'mkdir .foo' failed after recreating cwd"
3892 ls . > /dev/null || error "'ls .' failed after recreating cwd"
3893 ls .. > /dev/null || error "'ls ..' failed after removing cwd"
3894 cd . || error "'cd .' failed after recreating cwd"
3895 test_mkdir . && error "'mkdir .' worked after recreating cwd"
3896 rmdir . && error "'rmdir .' worked after recreating cwd"
3897 ln -s . baz || error "'ln -s .' failed after recreating cwd"
3898 cd .. || error "'cd ..' failed after recreating cwd"
3900 run_test 48a "Access renamed working dir (should return errors)="
3902 test_48b() { # bug 2399
3904 test_mkdir $DIR/$tdir
3906 rmdir $DIR/$tdir || error "remove cwd $DIR/$tdir failed"
3907 touch foo && error "'touch foo' worked after removing cwd"
3908 test_mkdir foo && error "'mkdir foo' worked after removing cwd"
3909 touch .foo && error "'touch .foo' worked after removing cwd"
3910 test_mkdir .foo && error "'mkdir .foo' worked after removing cwd"
3911 ls . > /dev/null && error "'ls .' worked after removing cwd"
3912 ls .. > /dev/null || error "'ls ..' failed after removing cwd"
3913 is_patchless || ( cd . && error "'cd .' worked after removing cwd" )
3914 test_mkdir . && error "'mkdir .' worked after removing cwd"
3915 rmdir . && error "'rmdir .' worked after removing cwd"
3916 ln -s . foo && error "'ln -s .' worked after removing cwd"
3917 cd .. || echo "'cd ..' failed after removing cwd `pwd`" #bug 3517
3919 run_test 48b "Access removed working dir (should return errors)="
3921 test_48c() { # bug 2350
3922 #lctl set_param debug=-1
3925 test_mkdir -p $DIR/$tdir/dir
3927 $TRACE rmdir $DIR/$tdir/dir || error "remove cwd $DIR/$tdir/dir failed"
3928 $TRACE touch foo && error "touch foo worked after removing cwd"
3929 $TRACE test_mkdir foo && error "'mkdir foo' worked after removing cwd"
3930 touch .foo && error "touch .foo worked after removing cwd"
3931 test_mkdir .foo && error "mkdir .foo worked after removing cwd"
3932 $TRACE ls . && error "'ls .' worked after removing cwd"
3933 $TRACE ls .. || error "'ls ..' failed after removing cwd"
3934 is_patchless || ( $TRACE cd . &&
3935 error "'cd .' worked after removing cwd" )
3936 $TRACE test_mkdir . && error "'mkdir .' worked after removing cwd"
3937 $TRACE rmdir . && error "'rmdir .' worked after removing cwd"
3938 $TRACE ln -s . foo && error "'ln -s .' worked after removing cwd"
3939 $TRACE cd .. || echo "'cd ..' failed after removing cwd `pwd`" #bug 3415
3941 run_test 48c "Access removed working subdir (should return errors)"
3943 test_48d() { # bug 2350
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 foo && error "'touch foo' worked after removing parent"
3952 $TRACE test_mkdir foo && error "mkdir foo worked after removing parent"
3953 touch .foo && error "'touch .foo' worked after removing parent"
3954 test_mkdir .foo && error "mkdir .foo worked after removing parent"
3955 $TRACE ls . && error "'ls .' worked after removing parent"
3956 $TRACE ls .. && error "'ls ..' worked after removing parent"
3957 is_patchless || ( $TRACE cd . &&
3958 error "'cd .' worked after recreate parent" )
3959 $TRACE test_mkdir . && error "'mkdir .' worked after removing parent"
3960 $TRACE rmdir . && error "'rmdir .' worked after removing parent"
3961 $TRACE ln -s . foo && error "'ln -s .' worked after removing parent"
3962 is_patchless || ( $TRACE cd .. &&
3963 error "'cd ..' worked after removing parent" || true )
3965 run_test 48d "Access removed parent subdir (should return errors)"
3967 test_48e() { # bug 4134
3968 #lctl set_param debug=-1
3971 test_mkdir -p $DIR/$tdir/dir
3973 $TRACE rmdir $DIR/$tdir/dir || error "remove cwd $DIR/$tdir/dir failed"
3974 $TRACE rmdir $DIR/$tdir || error "remove parent $DIR/$tdir failed"
3975 $TRACE touch $DIR/$tdir || error "'touch $DIR/$tdir' failed"
3976 $TRACE chmod +x $DIR/$tdir || error "'chmod +x $DIR/$tdir' failed"
3977 # On a buggy kernel addition of "touch foo" after cd .. will
3978 # produce kernel oops in lookup_hash_it
3979 touch ../foo && error "'cd ..' worked after recreate parent"
3981 $TRACE rm $DIR/$tdir || error "rm '$DIR/$tdir' failed"
3983 run_test 48e "Access to recreated parent subdir (should return errors)"
3985 test_49() { # LU-1030
3986 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3987 # get ost1 size - lustre-OST0000
3988 ost1_size=$(do_facet ost1 $LFS df | grep ${ost1_svc} |
3990 # write 800M at maximum
3991 [[ $ost1_size -lt 2 ]] && ost1_size=2
3992 [[ $ost1_size -gt 819200 ]] && ost1_size=819200
3994 $SETSTRIPE -c 1 -i 0 $DIR/$tfile
3995 dd if=/dev/zero of=$DIR/$tfile bs=4k count=$((ost1_size >> 2)) &
3998 # change max_pages_per_rpc while writing the file
3999 local osc1_mppc=osc.$(get_osc_import_name client ost1).max_pages_per_rpc
4000 local orig_mppc=$($LCTL get_param -n $osc1_mppc)
4001 # loop until dd process exits
4002 while ps ax -opid | grep -wq $dd_pid; do
4003 $LCTL set_param $osc1_mppc=$((RANDOM % 256 + 1))
4004 sleep $((RANDOM % 5 + 1))
4006 # restore original max_pages_per_rpc
4007 $LCTL set_param $osc1_mppc=$orig_mppc
4008 rm $DIR/$tfile || error "rm $DIR/$tfile failed"
4010 run_test 49 "Change max_pages_per_rpc won't break osc extent"
4014 test_mkdir $DIR/$tdir
4016 ls /proc/$$/cwd || error "ls /proc/$$/cwd failed"
4018 run_test 50 "special situations: /proc symlinks ==============="
4020 test_51a() { # was test_51
4021 # bug 1516 - create an empty entry right after ".." then split dir
4022 test_mkdir -c1 $DIR/$tdir
4023 touch $DIR/$tdir/foo
4024 $MCREATE $DIR/$tdir/bar
4026 createmany -m $DIR/$tdir/longfile 201
4028 while [[ $(ls -sd $DIR/$tdir | awk '{ print $1 }') -eq 4 ]]; do
4029 $MCREATE $DIR/$tdir/longfile$FNUM
4034 ls -l $DIR/$tdir > /dev/null || error "ls -l $DIR/$tdir failed"
4036 run_test 51a "special situations: split htree with empty entry =="
4038 export NUMTEST=70000
4040 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4041 local BASE=$DIR/d${base}.${TESTSUITE}
4043 # cleanup the directory
4046 test_mkdir -p -c1 $BASE
4050 local mdtidx=$(printf "%04x" $($LFS getstripe -M $BASE))
4051 local numfree=$(lctl get_param -n mdc.$FSNAME-MDT$mdtidx*.filesfree)
4052 [[ $numfree -lt 21000 ]] &&
4053 skip "not enough free inodes ($numfree) on MDT$mdtidx" &&
4056 [[ $numfree -lt $NUMTEST ]] && NUMTEST=$(($numfree - 50)) &&
4057 echo "reduced count to $NUMTEST due to inodes on MDT$mdtidx"
4059 # need to check free space for the directories as well
4060 local blkfree=$(lctl get_param -n mdc.$FSNAME-MDT$mdtidx*.kbytesavail)
4061 numfree=$((blkfree / 4))
4062 [[ $numfree -lt $NUMTEST ]] && NUMTEST=$((numfree - 50)) &&
4063 echo "reduced count to $NUMTEST due to blocks on MDT$mdtidx"
4065 createmany -d $BASE/d $NUMTEST && echo $NUMTEST > $BASE/fnum ||
4069 echo "failed" > $BASE/fnum
4070 error "failed to create $NUMTEST subdirs in MDT$mdtidx:$BASE"
4073 run_test 51b "exceed 64k subdirectory nlink limit"
4075 test_51ba() { # LU-993
4076 local BASE=$DIR/d${base}.${TESTSUITE}
4077 # unlink all but 100 subdirectories, then check it still works
4079 [ -f $BASE/fnum ] && local NUMPREV=$(cat $BASE/fnum) && rm $BASE/fnum
4081 [ "$NUMPREV" != "failed" ] && NUMTEST=$NUMPREV
4082 local DELETE=$((NUMTEST - LEFT))
4084 # continue on to run this test even if 51b didn't finish,
4085 # just to delete the many subdirectories created.
4086 [ ! -d "${BASE}/d1" ] && skip "test_51b() not run" && return 0
4088 # for ldiskfs the nlink count should be 1, but this is OSD specific
4089 # and so this is listed for informational purposes only
4090 echo "nlink before: $(stat -c %h $BASE), created before: $NUMTEST"
4091 unlinkmany -d $BASE/d $DELETE
4094 if [ $RC -ne 0 ]; then
4095 if [ "$NUMPREV" == "failed" ]; then
4096 skip "previous setup failed"
4099 error "unlink of first $DELETE subdirs failed"
4104 echo "nlink between: $(stat -c %h $BASE)"
4105 # trim the first line of ls output
4106 local FOUND=$(($(ls -l ${BASE} | wc -l) - 1))
4107 [ $FOUND -ne $LEFT ] &&
4108 error "can't find subdirs: found only $FOUND/$LEFT"
4110 unlinkmany -d $BASE/d $DELETE $LEFT ||
4111 error "unlink of second $LEFT subdirs failed"
4112 # regardless of whether the backing filesystem tracks nlink accurately
4113 # or not, the nlink count shouldn't be more than "." and ".." here
4114 local AFTER=$(stat -c %h $BASE)
4115 [[ $AFTER -gt 2 ]] && error "nlink after: $AFTER > 2" ||
4116 echo "nlink after: $AFTER"
4118 run_test 51ba "verify nlink for many subdirectory cleanup"
4121 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4122 [[ $OSTCOUNT -lt 3 ]] &&
4123 skip_env "skipping test with few OSTs" && return
4124 test_mkdir -p $DIR/$tdir
4125 createmany -o $DIR/$tdir/t- 1000
4126 $GETSTRIPE $DIR/$tdir > $TMP/files
4127 for N in $(seq 0 $((OSTCOUNT - 1))); do
4128 OBJS[$N]=$(awk -vobjs=0 '($1 == '$N') { objs += 1 } \
4129 END { printf("%0.0f", objs) }' $TMP/files)
4130 OBJS0[$N]=$(grep -A 1 idx $TMP/files | awk -vobjs=0 \
4131 '($1 == '$N') { objs += 1 } \
4132 END { printf("%0.0f", objs) }')
4133 log "OST$N has ${OBJS[$N]} objects, ${OBJS0[$N]} are index 0"
4135 unlinkmany $DIR/$tdir/t- 1000
4138 for N in $(seq 1 $((OSTCOUNT - 1))); do
4139 [[ ${OBJS[$N]} -lt $((${OBJS[$NLAST]} - 20)) ]] &&
4140 error "OST $N has less objects vs OST $NLAST" \
4141 " (${OBJS[$N]} < ${OBJS[$NLAST]}"
4142 [[ ${OBJS[$N]} -gt $((${OBJS[$NLAST]} + 20)) ]] &&
4143 error "OST $N has less objects vs OST $NLAST" \
4144 " (${OBJS[$N]} < ${OBJS[$NLAST]}"
4146 [[ ${OBJS0[$N]} -lt $((${OBJS0[$NLAST]} - 20)) ]] &&
4147 error "OST $N has less #0 objects vs OST $NLAST" \
4148 " (${OBJS0[$N]} < ${OBJS0[$NLAST]}"
4149 [[ ${OBJS0[$N]} -gt $((${OBJS0[$NLAST]} + 20)) ]] &&
4150 error "OST $N has less #0 objects vs OST $NLAST" \
4151 " (${OBJS0[$N]} < ${OBJS0[$NLAST]}"
4155 run_test 51d "check object distribution ===================="
4158 if [ "$(facet_fstype $SINGLEMDS)" != ldiskfs ]; then
4159 skip "Only applicable to ldiskfs-based MDTs"
4163 test_mkdir -c1 $DIR/$tdir || error "create $tdir failed"
4164 test_mkdir -c1 $DIR/$tdir/d0 || error "create d0 failed"
4166 touch $DIR/$tdir/d0/foo
4167 createmany -l $DIR/$tdir/d0/foo $DIR/$tdir/d0/f- 65001 &&
4168 error "file exceed 65000 nlink limit!"
4169 unlinkmany $DIR/$tdir/d0/f- 65001
4172 run_test 51e "check file nlink limit"
4175 [ -f $DIR/$tdir/foo ] && chattr -a $DIR/$tdir/foo
4176 test_mkdir -p $DIR/$tdir
4177 touch $DIR/$tdir/foo
4178 chattr +a $DIR/$tdir/foo || error "chattr +a failed"
4179 echo bar >> $DIR/$tdir/foo || error "append bar failed"
4180 cp /etc/hosts $DIR/$tdir/foo && error "cp worked"
4181 rm -f $DIR/$tdir/foo 2>/dev/null && error "rm worked"
4182 link $DIR/$tdir/foo $DIR/$tdir/foo_link 2>/dev/null &&
4184 echo foo >> $DIR/$tdir/foo || error "append foo failed"
4185 mrename $DIR/$tdir/foo $DIR/$tdir/foo_ren && error "rename worked"
4186 lsattr $DIR/$tdir/foo | egrep -q "^-+a[-e]+ $DIR/$tdir/foo" ||
4188 chattr -a $DIR/$tdir/foo || error "chattr -a failed"
4189 cp -r $DIR/$tdir /tmp/
4190 rm -fr $DIR/$tdir || error "cleanup rm failed"
4192 run_test 52a "append-only flag test (should return errors) ====="
4195 [ -f $DIR/$tdir/foo ] && chattr -i $DIR/$tdir/foo
4196 test_mkdir -p $DIR/$tdir
4197 touch $DIR/$tdir/foo
4198 chattr +i $DIR/$tdir/foo || error "chattr +i failed"
4199 cat test > $DIR/$tdir/foo && error "cat test worked"
4200 cp /etc/hosts $DIR/$tdir/foo && error "cp worked"
4201 rm -f $DIR/$tdir/foo 2>/dev/null && error "rm worked"
4202 link $DIR/$tdir/foo $DIR/$tdir/foo_link 2>/dev/null &&
4204 echo foo >> $DIR/$tdir/foo && error "echo worked"
4205 mrename $DIR/$tdir/foo $DIR/$tdir/foo_ren && error "rename worked"
4206 [ -f $DIR/$tdir/foo ] || error "$tdir/foo is not a file"
4207 [ -f $DIR/$tdir/foo_ren ] && error "$tdir/foo_ren is not a file"
4208 lsattr $DIR/$tdir/foo | egrep -q "^-+i[-e]+ $DIR/$tdir/foo" ||
4210 chattr -i $DIR/$tdir/foo || error "chattr failed"
4212 rm -fr $DIR/$tdir || error "unable to remove $DIR/$tdir"
4214 run_test 52b "immutable flag test (should return errors) ======="
4217 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4218 remote_mds_nodsh && skip "remote MDS with nodsh" && return
4219 remote_ost_nodsh && skip "remote OST with nodsh" && return
4232 local support_last_seq=true
4234 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.3.60) ]] ||
4235 support_last_seq=false
4238 local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS)
4240 for value in $(do_facet $SINGLEMDS \
4241 $LCTL get_param osc.$mdtosc.prealloc_last_id) ; do
4242 param=$(echo ${value[0]} | cut -d "=" -f1)
4243 ostname=$(echo $param | cut -d "." -f2 | cut -d - -f 1-2)
4245 if $support_last_seq; then
4246 param_seq=$(echo $param |
4247 sed -e s/prealloc_last_id/prealloc_last_seq/g)
4248 mds_last_seq=$(do_facet $SINGLEMDS \
4249 $LCTL get_param -n $param_seq)
4251 mds_last=$(do_facet $SINGLEMDS $LCTL get_param -n $param)
4253 ostnum=$(index_from_ostuuid ${ostname}_UUID)
4254 node=$(facet_active_host ost$((ostnum+1)))
4255 param="obdfilter.$ostname.last_id"
4256 for ost_last in $(do_node $node $LCTL get_param -n $param) ; do
4257 echo "$ostname.last_id=$ost_last; MDS.last_id=$mds_last"
4258 ost_last_id=$ost_last
4260 if $support_last_seq; then
4261 ost_last_id=$(echo $ost_last |
4262 awk -F':' '{print $2}' |
4264 ost_last_seq=$(echo $ost_last |
4265 awk -F':' '{print $1}')
4266 [[ $ost_last_seq = $mds_last_seq ]] || continue
4269 if [[ $ost_last_id != $mds_last ]]; then
4270 error "$ost_last_id != $mds_last"
4277 $found || error "can not match last_seq/last_id for $mdtosc"
4280 run_test 53 "verify that MDS and OSTs agree on pre-creation ===="
4283 $SOCKETSERVER $DIR/socket ||
4284 error "$SOCKETSERVER $DIR/socket failed: $?"
4285 $SOCKETCLIENT $DIR/socket ||
4286 error "$SOCKETCLIENT $DIR/socket failed: $?"
4287 $MUNLINK $DIR/socket || error "$MUNLINK $DIR/socket failed: $?"
4289 run_test 54a "unix domain socket test =========================="
4295 dd if=/dev/zero of=$f bs=$(page_size) count=1
4297 run_test 54b "char device works in lustre ======================"
4300 [ -b /dev/loop/0 ] && LOOPBASE=/dev/loop/
4301 [ -b /dev/loop0 ] && LOOPBASE=/dev/loop
4302 [ -z "$LOOPBASE" ] && echo "/dev/loop/0 and /dev/loop0 gone?" && return
4304 for i in $(seq 3 7); do
4305 losetup $LOOPBASE$i > /dev/null 2>&1 && continue
4313 loopdev="$DIR/loop54c"
4316 $UMOUNT $DIR/$tdir || rc=$?
4317 losetup -d $loopdev || true
4318 losetup -d $LOOPDEV || true
4319 rm -rf $loopdev $DIR/$tfile $DIR/$tdir
4324 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4325 loopdev="$DIR/loop54c"
4328 [ -z "$LOOPNUM" ] && echo "couldn't find empty loop device" && return
4329 trap cleanup_54c EXIT
4330 mknod $loopdev b 7 $LOOPNUM
4331 echo "make a loop file system with $DIR/$tfile on $loopdev ($LOOPNUM)."
4332 dd if=/dev/zero of=$DIR/$tfile bs=$(get_page_size client) seek=1024 count=1 > /dev/null
4333 losetup $loopdev $DIR/$tfile ||
4334 error "can't set up $loopdev for $DIR/$tfile"
4335 mkfs.ext2 $loopdev || error "mke2fs on $loopdev"
4336 test_mkdir -p $DIR/$tdir
4337 mount -t ext2 $loopdev $DIR/$tdir ||
4338 error "error mounting $loopdev on $DIR/$tdir"
4339 dd if=/dev/zero of=$DIR/$tdir/tmp bs=$(get_page_size client) count=30 ||
4342 dd if=$DIR/$tdir/tmp of=/dev/zero bs=$(get_page_size client) count=30 ||
4346 run_test 54c "block device works in lustre ====================="
4352 [ "$string" = $(echo $string > $f | cat $f) ] || error "$f != $string"
4354 run_test 54d "fifo device works in lustre ======================"
4359 cp -aL /dev/console $f
4360 echo $string > $f || error "echo $string to $f failed"
4362 run_test 54e "console/tty device works in lustre ======================"
4364 #The test_55 used to be iopen test and it was removed by bz#24037.
4365 #run_test 55 "check iopen_connect_dentry() ======================"
4367 test_56a() { # was test_56
4370 test_mkdir -p $DIR/$tdir/dir
4372 NUMFILESx2=$(($NUMFILES * 2))
4373 for i in $(seq 1 $NUMFILES); do
4374 touch $DIR/$tdir/file$i
4375 touch $DIR/$tdir/dir/file$i
4378 # test lfs getstripe with --recursive
4379 FILENUM=$($GETSTRIPE --recursive $DIR/$tdir | grep -c obdidx)
4380 [[ $FILENUM -eq $NUMFILESx2 ]] ||
4381 error "$GETSTRIPE --recursive: found $FILENUM, not $NUMFILESx2"
4382 FILENUM=$($GETSTRIPE $DIR/$tdir | grep -c obdidx)
4383 [[ $FILENUM -eq $NUMFILES ]] ||
4384 error "$GETSTRIPE $DIR/$tdir: found $FILENUM, not $NUMFILES"
4385 echo "$GETSTRIPE --recursive passed."
4387 # test lfs getstripe with file instead of dir
4388 FILENUM=$($GETSTRIPE $DIR/$tdir/file1 | grep -c obdidx)
4389 [[ $FILENUM -eq 1 ]] ||
4390 error "$GETSTRIPE $DIR/$tdir/file1: found $FILENUM, not 1"
4391 echo "$GETSTRIPE file1 passed."
4393 #test lfs getstripe with --verbose
4394 [[ $($GETSTRIPE --verbose $DIR/$tdir |
4395 grep -c lmm_magic) -eq $NUMFILES ]] ||
4396 error "$GETSTRIPE --verbose $DIR/$tdir: want $NUMFILES"
4397 [[ $($GETSTRIPE $DIR/$tdir | grep -c lmm_magic) -eq 0 ]] ||
4398 rror "$GETSTRIPE $DIR/$tdir: showed lmm_magic"
4399 echo "$GETSTRIPE --verbose passed."
4401 #test lfs getstripe with --obd
4402 $GETSTRIPE --obd wrong_uuid $DIR/$tdir 2>&1 |
4403 grep -q "unknown obduuid" ||
4404 error "$GETSTRIPE --obd wrong_uuid should return error message"
4406 [[ $OSTCOUNT -lt 2 ]] &&
4407 skip_env "skipping other $GETSTRIPE --obd test" && return
4410 OBDUUID=$(ostuuid_from_index $OSTIDX)
4411 FILENUM=$($GETSTRIPE -ir $DIR/$tdir | grep "^$OSTIDX\$" | wc -l)
4412 FOUND=$($GETSTRIPE -r --obd $OBDUUID $DIR/$tdir | grep obdidx | wc -l)
4413 [[ $FOUND -eq $FILENUM ]] ||
4414 error "$GETSTRIPE --obd wrong: found $FOUND, expected $FILENUM"
4415 [[ $($GETSTRIPE -r -v --obd $OBDUUID $DIR/$tdir |
4416 sed '/^[ ]*'${OSTIDX}'[ ]/d' |
4417 sed -n '/^[ ]*[0-9][0-9]*[ ]/p' | wc -l) -eq 0 ]] ||
4418 error "$GETSTRIPE --obd: should not show file on other obd"
4419 echo "$GETSTRIPE --obd passed"
4421 run_test 56a "check $GETSTRIPE"
4426 local LOCAL_NUMFILES="$1"
4427 local LOCAL_NUMDIRS="$2"
4428 local MKDIR_PARAMS="$3"
4429 local DIR_STRIPE_PARAMS="$4"
4431 if [ ! -d "$TDIR" ] ; then
4432 test_mkdir -p $DIR_STRIPE_PARAMS $TDIR
4433 [ "$MKDIR_PARAMS" ] && $SETSTRIPE $MKDIR_PARAMS $TDIR
4434 for i in `seq 1 $LOCAL_NUMFILES` ; do
4437 for i in `seq 1 $LOCAL_NUMDIRS` ; do
4438 test_mkdir $DIR_STRIPE_PARAMS $TDIR/dir$i
4439 for j in `seq 1 $LOCAL_NUMFILES` ; do
4440 touch $TDIR/dir$i/file$j
4446 setup_56_special() {
4450 if [ ! -e "$TDIR/loop1b" ] ; then
4451 for i in `seq 1 $LOCAL_NUMFILES` ; do
4452 mknod $TDIR/loop${i}b b 7 $i
4453 mknod $TDIR/null${i}c c 1 3
4454 ln -s $TDIR/file1 $TDIR/link${i}l
4456 for i in `seq 1 $LOCAL_NUMDIRS` ; do
4457 mknod $TDIR/dir$i/loop${i}b b 7 $i
4458 mknod $TDIR/dir$i/null${i}c c 1 3
4459 ln -s $TDIR/dir$i/file1 $TDIR/dir$i/link${i}l
4468 setup_56 $NUMFILES $NUMDIRS
4470 EXPECTED=$(($NUMDIRS + 2))
4471 # test lfs find with -name
4472 for i in $(seq 1 $NUMFILES) ; do
4473 NUMS=$($LFIND -name "*$i" $TDIR | wc -l)
4474 [ $NUMS -eq $EXPECTED ] ||
4475 error "lfs find -name \"*$i\" $TDIR wrong: "\
4476 "found $NUMS, expected $EXPECTED"
4479 run_test 56g "check lfs find -name ============================="
4485 setup_56 $NUMFILES $NUMDIRS
4487 EXPECTED=$(((NUMDIRS + 1) * (NUMFILES - 1) + NUMFILES))
4488 # test lfs find with ! -name
4489 for i in $(seq 1 $NUMFILES) ; do
4490 NUMS=$($LFIND ! -name "*$i" $TDIR | wc -l)
4491 [ $NUMS -eq $EXPECTED ] ||
4492 error "lfs find ! -name \"*$i\" $TDIR wrong: "\
4493 "found $NUMS, expected $EXPECTED"
4496 run_test 56h "check lfs find ! -name ============================="
4500 test_mkdir -p $DIR/$tdir
4501 UUID=$(ostuuid_from_index 0 $DIR/$tdir)
4502 CMD="$LFIND -ost $UUID $DIR/$tdir"
4504 [ -z "$OUT" ] || error "\"$CMD\" returned directory '$OUT'"
4506 run_test 56i "check 'lfs find -ost UUID' skips directories ======="
4510 setup_56_special $NUMFILES $NUMDIRS
4512 EXPECTED=$((NUMDIRS + 1))
4513 CMD="$LFIND -type d $TDIR"
4514 NUMS=$($CMD | wc -l)
4515 [ $NUMS -eq $EXPECTED ] ||
4516 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4518 run_test 56j "check lfs find -type d ============================="
4522 setup_56_special $NUMFILES $NUMDIRS
4524 EXPECTED=$(((NUMDIRS + 1) * NUMFILES))
4525 CMD="$LFIND -type f $TDIR"
4526 NUMS=$($CMD | wc -l)
4527 [ $NUMS -eq $EXPECTED ] ||
4528 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4530 run_test 56k "check lfs find -type f ============================="
4534 setup_56_special $NUMFILES $NUMDIRS
4536 EXPECTED=$((NUMDIRS + NUMFILES))
4537 CMD="$LFIND -type b $TDIR"
4538 NUMS=$($CMD | wc -l)
4539 [ $NUMS -eq $EXPECTED ] ||
4540 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4542 run_test 56l "check lfs find -type b ============================="
4546 setup_56_special $NUMFILES $NUMDIRS
4548 EXPECTED=$((NUMDIRS + NUMFILES))
4549 CMD="$LFIND -type c $TDIR"
4550 NUMS=$($CMD | wc -l)
4551 [ $NUMS -eq $EXPECTED ] ||
4552 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4554 run_test 56m "check lfs find -type c ============================="
4558 setup_56_special $NUMFILES $NUMDIRS
4560 EXPECTED=$((NUMDIRS + NUMFILES))
4561 CMD="$LFIND -type l $TDIR"
4562 NUMS=$($CMD | wc -l)
4563 [ $NUMS -eq $EXPECTED ] ||
4564 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4566 run_test 56n "check lfs find -type l ============================="
4570 setup_56 $NUMFILES $NUMDIRS
4571 utime $TDIR/file1 > /dev/null || error "utime (1)"
4572 utime $TDIR/file2 > /dev/null || error "utime (2)"
4573 utime $TDIR/dir1 > /dev/null || error "utime (3)"
4574 utime $TDIR/dir2 > /dev/null || error "utime (4)"
4575 utime $TDIR/dir1/file1 > /dev/null || error "utime (5)"
4576 dd if=/dev/zero count=1 >> $TDIR/dir1/file1 && sync
4579 NUMS=`$LFIND -mtime +0 $TDIR | wc -l`
4580 [ $NUMS -eq $EXPECTED ] || \
4581 error "lfs find -mtime +0 $TDIR wrong: found $NUMS, expected $EXPECTED"
4584 CMD="$LFIND -mtime 0 $TDIR"
4585 NUMS=$($CMD | wc -l)
4586 [ $NUMS -eq $EXPECTED ] ||
4587 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4589 run_test 56o "check lfs find -mtime for old files =========================="
4592 [ $RUNAS_ID -eq $UID ] &&
4593 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
4596 setup_56 $NUMFILES $NUMDIRS
4598 chown $RUNAS_ID $TDIR/file* || error "chown $DIR/${tdir}g/file$i failed"
4600 CMD="$LFIND -uid $RUNAS_ID $TDIR"
4601 NUMS=$($CMD | wc -l)
4602 [ $NUMS -eq $EXPECTED ] || \
4603 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4605 EXPECTED=$(((NUMFILES + 1) * NUMDIRS + 1))
4606 CMD="$LFIND ! -uid $RUNAS_ID $TDIR"
4607 NUMS=$($CMD | wc -l)
4608 [ $NUMS -eq $EXPECTED ] || \
4609 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4611 run_test 56p "check lfs find -uid and ! -uid ==============================="
4614 [ $RUNAS_ID -eq $UID ] &&
4615 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
4618 setup_56 $NUMFILES $NUMDIRS
4620 chgrp $RUNAS_GID $TDIR/file* || error "chown $TDIR/file$i failed"
4623 CMD="$LFIND -gid $RUNAS_GID $TDIR"
4624 NUMS=$($CMD | wc -l)
4625 [ $NUMS -eq $EXPECTED ] ||
4626 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4628 EXPECTED=$(( ($NUMFILES+1) * $NUMDIRS + 1))
4629 CMD="$LFIND ! -gid $RUNAS_GID $TDIR"
4630 NUMS=$($CMD | wc -l)
4631 [ $NUMS -eq $EXPECTED ] ||
4632 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4634 run_test 56q "check lfs find -gid and ! -gid ==============================="
4638 setup_56 $NUMFILES $NUMDIRS
4641 CMD="$LFIND -size 0 -type f $TDIR"
4642 NUMS=$($CMD | wc -l)
4643 [ $NUMS -eq $EXPECTED ] ||
4644 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4646 CMD="$LFIND ! -size 0 -type f $TDIR"
4647 NUMS=$($CMD | wc -l)
4648 [ $NUMS -eq $EXPECTED ] ||
4649 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4650 echo "test" > $TDIR/$tfile
4651 echo "test2" > $TDIR/$tfile.2 && sync
4653 CMD="$LFIND -size 5 -type f $TDIR"
4654 NUMS=$($CMD | wc -l)
4655 [ $NUMS -eq $EXPECTED ] ||
4656 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4658 CMD="$LFIND -size +5 -type f $TDIR"
4659 NUMS=$($CMD | wc -l)
4660 [ $NUMS -eq $EXPECTED ] ||
4661 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4663 CMD="$LFIND -size +0 -type f $TDIR"
4664 NUMS=$($CMD | wc -l)
4665 [ $NUMS -eq $EXPECTED ] ||
4666 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4668 CMD="$LFIND ! -size -5 -type f $TDIR"
4669 NUMS=$($CMD | wc -l)
4670 [ $NUMS -eq $EXPECTED ] ||
4671 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4673 CMD="$LFIND -size -5 -type f $TDIR"
4674 NUMS=$($CMD | wc -l)
4675 [ $NUMS -eq $EXPECTED ] ||
4676 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4678 run_test 56r "check lfs find -size works =========================="
4680 test_56s() { # LU-611
4682 setup_56 $NUMFILES $NUMDIRS "-c $OSTCOUNT"
4684 if [[ $OSTCOUNT -gt 1 ]]; then
4685 $SETSTRIPE -c 1 $TDIR/$tfile.{0,1,2,3}
4689 ONESTRIPE=$(((NUMDIRS + 1) * NUMFILES))
4693 EXPECTED=$(((NUMDIRS + 1) * NUMFILES))
4694 CMD="$LFIND -stripe-count $OSTCOUNT -type f $TDIR"
4695 NUMS=$($CMD | wc -l)
4696 [ $NUMS -eq $EXPECTED ] || {
4698 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4701 EXPECTED=$(((NUMDIRS + 1) * NUMFILES + EXTRA))
4702 CMD="$LFIND -stripe-count +0 -type f $TDIR"
4703 NUMS=$($CMD | wc -l)
4704 [ $NUMS -eq $EXPECTED ] || {
4706 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4710 CMD="$LFIND -stripe-count 1 -type f $TDIR"
4711 NUMS=$($CMD | wc -l)
4712 [ $NUMS -eq $EXPECTED ] || {
4714 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4717 CMD="$LFIND -stripe-count -2 -type f $TDIR"
4718 NUMS=$($CMD | wc -l)
4719 [ $NUMS -eq $EXPECTED ] || {
4721 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4725 CMD="$LFIND -stripe-count $((OSTCOUNT + 1)) -type f $TDIR"
4726 NUMS=$($CMD | wc -l)
4727 [ $NUMS -eq $EXPECTED ] || {
4729 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4732 run_test 56s "check lfs find -stripe-count works"
4734 test_56t() { # LU-611
4736 setup_56 $NUMFILES $NUMDIRS "-s 512k"
4738 $SETSTRIPE -S 256k $TDIR/$tfile.{0,1,2,3}
4740 EXPECTED=$(((NUMDIRS + 1) * NUMFILES))
4741 CMD="$LFIND -stripe-size 512k -type f $TDIR"
4742 NUMS=$($CMD | wc -l)
4743 [ $NUMS -eq $EXPECTED ] ||
4744 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4746 CMD="$LFIND -stripe-size +320k -type f $TDIR"
4747 NUMS=$($CMD | wc -l)
4748 [ $NUMS -eq $EXPECTED ] ||
4749 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4751 EXPECTED=$(((NUMDIRS + 1) * NUMFILES + 4))
4752 CMD="$LFIND -stripe-size +200k -type f $TDIR"
4753 NUMS=$($CMD | wc -l)
4754 [ $NUMS -eq $EXPECTED ] ||
4755 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4757 CMD="$LFIND -stripe-size -640k -type f $TDIR"
4758 NUMS=$($CMD | wc -l)
4759 [ $NUMS -eq $EXPECTED ] ||
4760 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4763 CMD="$LFIND -stripe-size 256k -type f $TDIR"
4764 NUMS=$($CMD | wc -l)
4765 [ $NUMS -eq $EXPECTED ] ||
4766 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4768 CMD="$LFIND -stripe-size -320k -type f $TDIR"
4769 NUMS=$($CMD | wc -l)
4770 [ $NUMS -eq $EXPECTED ] ||
4771 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4774 CMD="$LFIND -stripe-size 1024k -type f $TDIR"
4775 NUMS=$($CMD | wc -l)
4776 [ $NUMS -eq $EXPECTED ] ||
4777 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4779 run_test 56t "check lfs find -stripe-size works"
4781 test_56u() { # LU-611
4783 setup_56 $NUMFILES $NUMDIRS "-i 0"
4785 if [[ $OSTCOUNT -gt 1 ]]; then
4786 $SETSTRIPE -i 1 $TDIR/$tfile.{0,1,2,3}
4792 EXPECTED=$(((NUMDIRS + 1) * NUMFILES))
4793 CMD="$LFIND -stripe-index 0 -type f $TDIR"
4794 NUMS=$($CMD | wc -l)
4795 [ $NUMS -eq $EXPECTED ] ||
4796 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4799 CMD="$LFIND -stripe-index 1 -type f $TDIR"
4800 NUMS=$($CMD | wc -l)
4801 [ $NUMS -eq $EXPECTED ] ||
4802 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4804 CMD="$LFIND ! -stripe-index 0 -type f $TDIR"
4805 NUMS=$($CMD | wc -l)
4806 [ $NUMS -eq $EXPECTED ] ||
4807 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4810 # This should produce an error and not return any files
4811 CMD="$LFIND -stripe-index $OSTCOUNT -type f $TDIR"
4812 NUMS=$($CMD 2>/dev/null | wc -l)
4813 [ $NUMS -eq $EXPECTED ] ||
4814 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4816 if [[ $OSTCOUNT -gt 1 ]]; then
4817 EXPECTED=$(((NUMDIRS + 1) * NUMFILES + ONESTRIPE))
4818 CMD="$LFIND -stripe-index 0,1 -type f $TDIR"
4819 NUMS=$($CMD | wc -l)
4820 [ $NUMS -eq $EXPECTED ] ||
4821 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4824 run_test 56u "check lfs find -stripe-index works"
4831 setup_56 $NUMFILES $NUMDIRS
4833 UUID=$(mdtuuid_from_index $MDT_IDX $TDIR)
4834 [ -z "$UUID" ] && error "mdtuuid_from_index cannot find MDT index $MDT_IDX"
4836 for file in $($LFIND -mdt $UUID $TDIR); do
4837 file_mdt_idx=$($GETSTRIPE -M $file)
4838 [ $file_mdt_idx -eq $MDT_IDX ] ||
4839 error "'lfind -mdt $UUID' != 'getstripe -M' ($file_mdt_idx)"
4842 run_test 56v "check 'lfs find -mdt match with lfs getstripe -M' ======="
4845 [[ $OSTCOUNT -lt 2 ]] && skip_env "$OSTCOUNT < 2 OSTs -- skipping" &&
4847 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4850 rm -rf $TDIR || error "remove $TDIR failed"
4851 setup_56 $NUMFILES $NUMDIRS "-c $OSTCOUNT" "-c1"
4854 stripe_size=$($GETSTRIPE -S -d $TDIR) ||
4855 error "$GETSTRIPE -S -d $TDIR failed"
4856 stripe_size=${stripe_size%% *}
4858 local file_size=$((stripe_size * OSTCOUNT))
4859 local file_num=$((NUMDIRS * NUMFILES + NUMFILES))
4860 local required_space=$((file_num * file_size))
4861 local free_space=$($LCTL get_param -n lov.$LOVNAME.kbytesavail)
4862 [[ $free_space -le $((required_space / 1024)) ]] &&
4863 skip_env "need at least $required_space bytes free space," \
4864 "have $free_space kbytes" && return
4867 local dd_count=$((file_size / dd_bs))
4869 # write data into the files
4873 for i in $(seq 1 $NUMFILES); do
4875 yes | dd bs=$dd_bs count=$dd_count of=$file >/dev/null 2>&1 ||
4876 error "write data into $file failed"
4878 for i in $(seq 1 $NUMDIRS); do
4879 for j in $(seq 1 $NUMFILES); do
4880 file=$TDIR/dir$i/file$j
4881 yes | dd bs=$dd_bs count=$dd_count of=$file \
4883 error "write data into $file failed"
4888 [[ $OSTCOUNT -gt 1 ]] && expected=$((OSTCOUNT - 1))
4891 local cmd="$LFS_MIGRATE -y -c $expected $TDIR/file1"
4893 eval $cmd || error "$cmd failed"
4895 check_stripe_count $TDIR/file1 $expected
4897 if [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.6.90) ];
4899 # lfs_migrate file onto OST 0 if it is on OST 1, or onto
4900 # OST 1 if it is on OST 0. This file is small enough to
4901 # be on only one stripe.
4902 file=$TDIR/migr_1_ost
4903 dd bs=$dd_bs count=1 if=/dev/urandom of=$file >/dev/null 2>&1 ||
4904 error "write data into $file failed"
4905 local obdidx=$($LFS getstripe -i $file)
4906 local oldmd5=$(md5sum $file)
4908 [[ $obdidx -eq 0 ]] && newobdidx=1
4909 cmd="$LFS migrate -i $newobdidx $file"
4911 eval $cmd || error "$cmd failed"
4912 local realobdix=$($LFS getstripe -i $file)
4913 local newmd5=$(md5sum $file)
4914 [[ $newobdidx -ne $realobdix ]] &&
4915 error "new OST is different (was=$obdidx, wanted=$newobdidx, got=$realobdix)"
4916 [[ "$oldmd5" != "$newmd5" ]] &&
4917 error "md5sum differ: $oldmd5, $newmd5"
4921 cmd="$LFS_MIGRATE -y -c $expected $TDIR/dir1"
4923 eval $cmd || error "$cmd failed"
4925 for j in $(seq 1 $NUMFILES); do
4926 check_stripe_count $TDIR/dir1/file$j $expected
4929 # lfs_migrate works with lfs find
4930 cmd="$LFIND -stripe_count $OSTCOUNT -type f $TDIR |
4931 $LFS_MIGRATE -y -c $expected"
4933 eval $cmd || error "$cmd failed"
4935 for i in $(seq 2 $NUMFILES); do
4936 check_stripe_count $TDIR/file$i $expected
4938 for i in $(seq 2 $NUMDIRS); do
4939 for j in $(seq 1 $NUMFILES); do
4940 check_stripe_count $TDIR/dir$i/file$j $expected
4944 run_test 56w "check lfs_migrate -c stripe_count works"
4947 check_swap_layouts_support && return 0
4948 [[ $OSTCOUNT -lt 2 ]] &&
4949 skip_env "need 2 OST, skipping test" && return
4951 local dir0=$DIR/$tdir/$testnum
4952 test_mkdir -p $dir0 || error "creating dir $dir0"
4954 local ref1=/etc/passwd
4955 local file1=$dir0/file1
4957 $SETSTRIPE -c 2 $file1
4959 $LFS migrate -c 1 $file1 || error "migrate failed rc = $?"
4960 stripe=$($GETSTRIPE -c $file1)
4961 [[ $stripe == 1 ]] || error "stripe of $file1 is $stripe != 1"
4962 cmp $file1 $ref1 || error "content mismatch $file1 differs from $ref1"
4967 run_test 56x "lfs migration support"
4970 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.53) ] &&
4971 skip "No HSM $(lustre_build_version $SINGLEMDS) MDS < 2.4.53" &&
4975 local dir0=$DIR/$tdir/$testnum
4976 test_mkdir -p $dir0 || error "creating dir $dir0"
4977 local f1=$dir0/file1
4978 local f2=$dir0/file2
4980 touch $f1 || error "creating std file $f1"
4981 $MULTIOP $f2 H2c || error "creating released file $f2"
4983 # a directory can be raid0, so ask only for files
4984 res=$($LFIND $dir0 -L raid0 -type f | wc -l)
4985 [[ $res == 2 ]] || error "search raid0: found $res files != 2"
4987 res=$($LFIND $dir0 \! -L raid0 -type f | wc -l)
4988 [[ $res == 0 ]] || error "search !raid0: found $res files != 0"
4990 # only files can be released, so no need to force file search
4991 res=$($LFIND $dir0 -L released)
4992 [[ $res == $f2 ]] || error "search released: found $res != $f2"
4994 res=$($LFIND $dir0 \! -L released)
4995 [[ $res == $f1 ]] || error "search !released: found $res != $f1"
4998 run_test 56y "lfs find -L raid0|released"
5000 test_56z() { # LU-4824
5001 # This checks to make sure 'lfs find' continues after errors
5002 # There are two classes of errors that should be caught:
5003 # - If multiple paths are provided, all should be searched even if one
5005 # - If errors are encountered during the search, it should not terminate
5008 test_mkdir $DIR/$tdir
5009 for i in d{0..9}; do
5010 test_mkdir $DIR/$tdir/$i
5012 touch $DIR/$tdir/d{0..9}/$tfile
5013 $LFS find $DIR/non_existent_dir $DIR/$tdir &&
5014 error "$LFS find did not return an error"
5015 # Make a directory unsearchable. This should NOT be the last entry in
5016 # directory order. Arbitrarily pick the 6th entry
5017 chmod 700 $($LFS find $DIR/$tdir -type d | sed '6!d')
5018 local count=$($RUNAS $LFS find $DIR/non_existent $DIR/$tdir | wc -l)
5019 # The user should be able to see 10 directories and 9 files
5020 [ $count == 19 ] || error "$LFS find did not continue after error"
5022 run_test 56z "lfs find should continue after an error"
5024 test_56aa() { # LU-5937
5025 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
5028 $LFS setdirstripe -c$MDSCOUNT $DIR/$tdir/striped_dir
5030 createmany -o $DIR/$tdir/striped_dir/${tfile}- 1024
5031 local dirs=$(lfs find --size +8k $DIR/$tdir/)
5033 [ -n "$dirs" ] || error "lfs find --size wrong under striped dir"
5035 run_test 56aa "lfs find --size under striped dir"
5038 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5039 # note test will not do anything if MDS is not local
5040 if [ "$(facet_fstype $SINGLEMDS)" != ldiskfs ]; then
5041 skip "Only applicable to ldiskfs-based MDTs"
5045 remote_mds_nodsh && skip "remote MDS with nodsh" && return
5046 local MNTDEV="osd*.*MDT*.mntdev"
5047 DEV=$(do_facet $SINGLEMDS lctl get_param -n $MNTDEV)
5048 [ -z "$DEV" ] && error "can't access $MNTDEV"
5049 for DEV in $(do_facet $SINGLEMDS lctl get_param -n $MNTDEV); do
5050 do_facet $SINGLEMDS $DUMPE2FS -h $DEV > $TMP/t57a.dump ||
5051 error "can't access $DEV"
5052 DEVISIZE=$(awk '/Inode size:/ { print $3 }' $TMP/t57a.dump)
5053 [[ $DEVISIZE -gt 128 ]] || error "inode size $DEVISIZE"
5057 run_test 57a "verify MDS filesystem created with large inodes =="
5060 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5061 if [ "$(facet_fstype $SINGLEMDS)" != ldiskfs ]; then
5062 skip "Only applicable to ldiskfs-based MDTs"
5066 remote_mds_nodsh && skip "remote MDS with nodsh" && return
5067 local dir=$DIR/$tdir
5071 local FILEN=$dir/f$FILECOUNT
5073 rm -rf $dir || error "removing $dir"
5074 test_mkdir -p -c1 $dir || error "creating $dir"
5075 local mdtidx=$($LFS getstripe -M $dir)
5076 local mdtname=MDT$(printf %04x $mdtidx)
5077 local facet=mds$((mdtidx + 1))
5079 echo "mcreating $FILECOUNT files"
5080 createmany -m $dir/f 1 $FILECOUNT || \
5081 error "creating files in $dir"
5083 # verify that files do not have EAs yet
5084 $GETSTRIPE $FILE1 2>&1 | grep -q "no stripe" || error "$FILE1 has an EA"
5085 $GETSTRIPE $FILEN 2>&1 | grep -q "no stripe" || error "$FILEN has an EA"
5089 df $dir #make sure we get new statfs data
5090 local MDSFREE=$(do_facet $facet \
5091 lctl get_param -n osd*.*$mdtname.kbytesfree)
5092 local MDCFREE=$(lctl get_param -n mdc.*$mdtname-mdc-*.kbytesfree)
5093 echo "opening files to create objects/EAs"
5095 for FILE in `seq -f $dir/f%g 1 $FILECOUNT`; do
5096 $OPENFILE -f O_RDWR $FILE > /dev/null 2>&1 || error "opening $FILE"
5099 # verify that files have EAs now
5100 $GETSTRIPE $FILE1 | grep -q "obdidx" || error "$FILE1 missing EA"
5101 $GETSTRIPE $FILEN | grep -q "obdidx" || error "$FILEN missing EA"
5103 sleep 1 #make sure we get new statfs data
5105 local MDSFREE2=$(do_facet $facet \
5106 lctl get_param -n osd*.*$mdtname.kbytesfree)
5107 local MDCFREE2=$(lctl get_param -n mdc.*$mdtname-mdc-*.kbytesfree)
5108 if [[ $MDCFREE2 -lt $((MDCFREE - 16)) ]]; then
5109 if [ "$MDSFREE" != "$MDSFREE2" ]; then
5110 error "MDC before $MDCFREE != after $MDCFREE2"
5112 echo "MDC before $MDCFREE != after $MDCFREE2"
5113 echo "unable to confirm if MDS has large inodes"
5118 run_test 57b "default LOV EAs are stored inside large inodes ==="
5121 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5122 [ -z "$(which wiretest 2>/dev/null)" ] &&
5123 skip_env "could not find wiretest" && return
5126 run_test 58 "verify cross-platform wire constants =============="
5129 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5130 echo "touch 130 files"
5131 createmany -o $DIR/f59- 130
5133 unlinkmany $DIR/f59- 130
5135 # wait for commitment of removal
5136 wait_delete_completed
5138 run_test 59 "verify cancellation of llog records async ========="
5140 TEST60_HEAD="test_60 run $RANDOM"
5142 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5143 remote_mgs_nodsh && skip "remote MGS with nodsh" && return
5144 do_facet mgs "! which run-llog.sh &> /dev/null" &&
5145 do_facet mgs "! ls run-llog.sh &> /dev/null" &&
5146 skip_env "missing subtest run-llog.sh" && return
5148 log "$TEST60_HEAD - from kernel mode"
5149 do_facet mgs "$LCTL set_param debug=warning; $LCTL dk > /dev/null"
5150 do_facet mgs sh run-llog.sh
5151 do_facet mgs $LCTL dk > $TMP/$tfile
5153 # LU-6388: test llog_reader
5154 local llog_reader=$(do_facet mgs "which llog_reader 2> /dev/null")
5155 llog_reader=${llog_reader:-$LUSTRE/utils/llog_reader}
5156 [ -z $(do_facet mgs ls -d $llog_reader 2> /dev/null) ] &&
5157 skip_env "missing llog_reader" && return
5158 local fstype=$(facet_fstype mgs)
5159 [ $fstype != ldiskfs -a $fstype != zfs ] &&
5160 skip_env "Only for ldiskfs or zfs type mgs" && return
5162 local mntpt=$(facet_mntpt mgs)
5163 local mgsdev=$(mgsdevname 1)
5175 #get fid and record list
5176 fid_list=($(awk '/9_sub.*record/ { print $NF }' /$TMP/$tfile |
5178 rec_list=($(awk '/9_sub.*record/ { print $((NF-3)) }' /$TMP/$tfile |
5180 #remount mgs as ldiskfs or zfs type
5181 stop mgs || error "stop mgs failed"
5182 mount_fstype mgs || error "remount mgs failed"
5183 for ((i = 0; i < ${#fid_list[@]}; i++)); do
5186 seq=$(echo $fid | awk -F ':' '{ print $1 }' | sed -e "s/^0x//g")
5187 oid=$(echo $fid | awk -F ':' '{ print $2 }' | sed -e "s/^0x//g")
5192 obj_file=$mntpt/O/$seq/d$((oid%32))/$oid ;;
5194 obj_file=$mntpt/oi.$(($((16#$seq))&127))/$fid ;;
5196 echo "obj_file is $obj_file"
5197 do_facet mgs $llog_reader $obj_file
5199 rec_type=$(do_facet mgs $llog_reader $obj_file | grep "type=" |
5200 awk '{ print $3 }' | sed -e "s/^type=//g")
5201 if [ $rec_type != $rec ]; then
5202 echo "FAILED test_60a wrong record type $rec_type," \
5208 #check obj path if record type is LLOG_LOGID_MAGIC
5209 if [ "$rec" == "1064553b" ]; then
5210 path=$(do_facet mgs $llog_reader $obj_file |
5211 grep "path=" | awk '{ print $NF }' |
5212 sed -e "s/^path=//g")
5213 if [ $obj_file != $mntpt/$path ]; then
5214 echo "FAILED test_60a wrong obj path" \
5215 "$montpt/$path, should be $obj_file"
5222 #restart mgs before "error", otherwise it will block the next test
5223 stop mgs || error "stop mgs failed"
5224 start mgs $(mgsdevname) $MGS_MOUNT_OPTS || error "start mgs failed"
5225 $pass || error "test failed, see FAILED test_60a messages for specifics"
5227 run_test 60a "llog_test run from kernel module and test llog_reader =========="
5229 test_60b() { # bug 6411
5230 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5232 LLOG_COUNT=`dmesg | awk "/$TEST60_HEAD/{marker = 1; from_marker = 0;}
5244 [[ $LLOG_COUNT -gt 50 ]] &&
5245 error "CDEBUG_LIMIT not limiting messages ($LLOG_COUNT)" || true
5247 run_test 60b "limit repeated messages from CERROR/CWARN ========"
5250 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5251 echo "create 5000 files"
5252 createmany -o $DIR/f60c- 5000
5253 #define OBD_FAIL_MDS_LLOG_CREATE_FAILED 0x137
5254 lctl set_param fail_loc=0x80000137
5255 unlinkmany $DIR/f60c- 5000
5256 lctl set_param fail_loc=0
5258 run_test 60c "unlink file when mds full"
5261 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5262 SAVEPRINTK=$(lctl get_param -n printk)
5264 # verify "lctl mark" is even working"
5265 MESSAGE="test message ID $RANDOM $$"
5266 $LCTL mark "$MESSAGE" || error "$LCTL mark failed"
5267 dmesg | grep -q "$MESSAGE" || error "didn't find debug marker in log"
5269 lctl set_param printk=0 || error "set lnet.printk failed"
5270 lctl get_param -n printk | grep emerg || error "lnet.printk dropped emerg"
5271 MESSAGE="new test message ID $RANDOM $$"
5272 # Assume here that libcfs_debug_mark_buffer() uses D_WARNING
5273 $LCTL mark "$MESSAGE" || error "$LCTL mark failed"
5274 dmesg | grep -q "$MESSAGE" && error "D_WARNING wasn't masked" || true
5276 lctl set_param -n printk="$SAVEPRINTK"
5278 run_test 60d "test printk console message masking"
5281 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5283 dd if=/dev/zero of=$f bs=$(page_size) count=1 || error "dd $f failed"
5284 cancel_lru_locks osc
5285 $MULTIOP $f OSMWUc || error "$MULTIOP $f failed"
5288 run_test 61 "mmap() writes don't make sync hang ================"
5290 # bug 2330 - insufficient obd_match error checking causes LBUG
5292 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5295 cancel_lru_locks osc
5296 lctl set_param fail_loc=0x405
5297 cat $f && error "cat succeeded, expect -EIO"
5298 lctl set_param fail_loc=0
5300 # This test is now irrelevant (as of bug 10718 inclusion), we no longer
5301 # match every page all of the time.
5302 #run_test 62 "verify obd_match failure doesn't LBUG (should -EIO)"
5304 # bug 2319 - oig_wait() interrupted causes crash because of invalid waitq.
5305 # Though this test is irrelevant anymore, it helped to reveal some
5306 # other grant bugs (LU-4482), let's keep it.
5307 test_63a() { # was test_63
5308 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5309 MAX_DIRTY_MB=`lctl get_param -n osc.*.max_dirty_mb | head -n 1`
5310 for i in `seq 10` ; do
5311 dd if=/dev/zero of=$DIR/f63 bs=8k &
5317 rm -f $DIR/f63 || true
5319 run_test 63a "Verify oig_wait interruption does not crash ======="
5321 # bug 2248 - async write errors didn't return to application on sync
5322 # bug 3677 - async write errors left page locked
5324 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5326 lctl set_param debug=-1
5328 # ensure we have a grant to do async writes
5329 dd if=/dev/zero of=$DIR/$tfile bs=4k count=1
5332 sync # sync lest earlier test intercept the fail_loc
5334 #define OBD_FAIL_OSC_BRW_PREP_REQ 0x406
5335 lctl set_param fail_loc=0x80000406
5336 $MULTIOP $DIR/$tfile Owy && \
5337 error "sync didn't return ENOMEM"
5338 sync; sleep 2; sync # do a real sync this time to flush page
5339 lctl get_param -n llite.*.dump_page_cache | grep locked && \
5340 error "locked page left in cache after async error" || true
5343 run_test 63b "async write errors should be returned to fsync ==="
5346 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5348 lctl get_param -n osc.*[oO][sS][cC][_-]*.cur* | grep "[0-9]"
5350 run_test 64a "verify filter grant calculations (in kernel) ====="
5353 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5354 sh oos.sh $MOUNT || error "oos.sh failed: $?"
5356 run_test 64b "check out-of-space detection on client ==========="
5359 $LCTL set_param osc.*OST0000-osc-[^mM]*.cur_grant_bytes=0
5361 run_test 64c "verify grant shrink ========================------"
5363 # bug 1414 - set/get directories' stripe info
5365 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5366 test_mkdir -p $DIR/$tdir
5368 $LVERIFY $DIR/$tdir $DIR/$tdir/f1 || error "lverify failed"
5370 run_test 65a "directory with no stripe info ===================="
5373 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5374 test_mkdir -p $DIR/$tdir
5375 $SETSTRIPE -S $((STRIPESIZE * 2)) -i 0 -c 1 $DIR/$tdir ||
5378 $LVERIFY $DIR/$tdir $DIR/$tdir/f2 || error "lverify failed"
5380 run_test 65b "directory setstripe -S $((STRIPESIZE * 2)) -i 0 -c 1"
5383 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5384 if [[ $OSTCOUNT -gt 1 ]]; then
5385 test_mkdir -p $DIR/$tdir
5386 $SETSTRIPE -S $(($STRIPESIZE * 4)) -i 1 \
5387 -c $(($OSTCOUNT - 1)) $DIR/$tdir || error "setstripe"
5389 $LVERIFY $DIR/$tdir $DIR/$tdir/f3 || error "lverify failed"
5392 run_test 65c "directory setstripe -S $((STRIPESIZE*4)) -i 1 -c $((OSTCOUNT-1))"
5395 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5396 test_mkdir -p $DIR/$tdir
5397 if [[ $STRIPECOUNT -le 0 ]]; then
5399 elif [[ $STRIPECOUNT -gt 2000 ]]; then
5400 #LOV_MAX_STRIPE_COUNT is 2000
5401 [[ $OSTCOUNT -gt 2000 ]] && sc=2000 || sc=$(($OSTCOUNT - 1))
5403 sc=$(($STRIPECOUNT - 1))
5405 $SETSTRIPE -S $STRIPESIZE -c $sc $DIR/$tdir || error "setstripe"
5406 touch $DIR/$tdir/f4 $DIR/$tdir/f5
5407 $LVERIFY $DIR/$tdir $DIR/$tdir/f4 $DIR/$tdir/f5 ||
5408 error "lverify failed"
5410 run_test 65d "directory setstripe -S $STRIPESIZE -c stripe_count"
5413 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5414 test_mkdir -p $DIR/$tdir
5416 $SETSTRIPE $DIR/$tdir || error "setstripe"
5417 $GETSTRIPE -v $DIR/$tdir | grep "Default" ||
5418 error "no stripe info failed"
5420 $LVERIFY $DIR/$tdir $DIR/$tdir/f6 || error "lverify failed"
5422 run_test 65e "directory setstripe defaults ======================="
5425 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5426 test_mkdir -p $DIR/${tdir}f
5427 $RUNAS $SETSTRIPE $DIR/${tdir}f && error "setstripe succeeded" || true
5429 run_test 65f "dir setstripe permission (should return error) ==="
5432 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5433 test_mkdir -p $DIR/$tdir
5434 $SETSTRIPE -S $((STRIPESIZE * 2)) -i 0 -c 1 $DIR/$tdir ||
5436 $SETSTRIPE -d $DIR/$tdir || error "setstripe"
5437 $GETSTRIPE -v $DIR/$tdir | grep "Default" ||
5438 error "delete default stripe failed"
5440 run_test 65g "directory setstripe -d ==========================="
5443 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5444 test_mkdir -p $DIR/$tdir
5445 $SETSTRIPE -S $((STRIPESIZE * 2)) -i 0 -c 1 $DIR/$tdir ||
5447 test_mkdir -p $DIR/$tdir/dd1
5448 [ $($GETSTRIPE -c $DIR/$tdir) == $($GETSTRIPE -c $DIR/$tdir/dd1) ] ||
5449 error "stripe info inherit failed"
5451 run_test 65h "directory stripe info inherit ===================="
5453 test_65i() { # bug6367
5454 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5455 $SETSTRIPE -S 65536 -c -1 $MOUNT
5457 run_test 65i "set non-default striping on root directory (bug 6367)="
5459 test_65ia() { # bug12836
5460 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5461 $GETSTRIPE $MOUNT || error "getstripe $MOUNT failed"
5463 run_test 65ia "getstripe on -1 default directory striping"
5465 test_65ib() { # bug12836
5466 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5467 $GETSTRIPE -v $MOUNT || error "getstripe -v $MOUNT failed"
5469 run_test 65ib "getstripe -v on -1 default directory striping"
5471 test_65ic() { # bug12836
5472 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5473 $LFS find -mtime -1 $MOUNT > /dev/null || error "find $MOUNT failed"
5475 run_test 65ic "new find on -1 default directory striping"
5477 test_65j() { # bug6367
5478 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5480 # if we aren't already remounting for each test, do so for this test
5481 if [ "$CLEANUP" = ":" -a "$I_MOUNTED" = "yes" ]; then
5482 cleanup || error "failed to unmount"
5485 $SETSTRIPE -d $MOUNT || error "setstripe failed"
5487 run_test 65j "set default striping on root directory (bug 6367)="
5489 test_65k() { # bug11679
5490 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5491 [[ $OSTCOUNT -lt 2 ]] && skip_env "too few OSTs" && return
5492 remote_mds_nodsh && skip "remote MDS with nodsh" && return
5494 echo "Check OST status: "
5495 local MDS_OSCS=`do_facet $SINGLEMDS lctl dl |
5496 awk '/[oO][sS][cC].*md[ts]/ { print $4 }'`
5498 for OSC in $MDS_OSCS; do
5499 echo $OSC "is activate"
5500 do_facet $SINGLEMDS lctl --device %$OSC activate
5504 for INACTIVE_OSC in $MDS_OSCS; do
5505 echo "Deactivate: " $INACTIVE_OSC
5506 do_facet $SINGLEMDS lctl --device %$INACTIVE_OSC deactivate
5507 for STRIPE_OSC in $MDS_OSCS; do
5508 OST=`osc_to_ost $STRIPE_OSC`
5509 IDX=`do_facet $SINGLEMDS lctl get_param -n lov.*md*.target_obd |
5510 awk -F: /$OST/'{ print $1 }' | head -n 1`
5512 [ -f $DIR/$tdir/$IDX ] && continue
5513 echo "$SETSTRIPE -i $IDX -c 1 $DIR/$tdir/$IDX"
5514 $SETSTRIPE -i $IDX -c 1 $DIR/$tdir/$IDX
5516 [ $RC -ne 0 ] && error "setstripe should have succeeded"
5519 echo $INACTIVE_OSC "is Activate."
5520 do_facet $SINGLEMDS lctl --device %$INACTIVE_OSC activate
5523 run_test 65k "validate manual striping works properly with deactivated OSCs"
5525 test_65l() { # bug 12836
5526 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5527 test_mkdir -p $DIR/$tdir/test_dir
5528 $SETSTRIPE -c -1 $DIR/$tdir/test_dir
5529 $LFS find -mtime -1 $DIR/$tdir >/dev/null
5531 run_test 65l "lfs find on -1 stripe dir ========================"
5533 # bug 2543 - update blocks count on client
5535 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5537 dd if=/dev/zero of=$DIR/f66 bs=1k count=$COUNT
5538 sync; sync_all_data; sync; sync_all_data
5539 cancel_lru_locks osc
5540 BLOCKS=`ls -s $DIR/f66 | awk '{ print $1 }'`
5541 [ $BLOCKS -ge $COUNT ] || error "$DIR/f66 blocks $BLOCKS < $COUNT"
5543 run_test 66 "update inode blocks count on client ==============="
5548 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5550 if [ ! -z "$LLOOP" ]; then
5551 if swapon -s | grep -q $LLOOP; then
5552 swapoff $LLOOP || error "swapoff failed"
5555 $LCTL blockdev_detach $LLOOP || error "detach failed"
5559 if [ ! -z "$LLITELOOPLOAD" ]; then
5567 awk '($1 == "'$1':") { print $2 }' /proc/meminfo
5571 swapon -s | awk '($1 == "'$1'") { print $4 }'
5574 # test case for lloop driver, basic function
5576 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5577 [ "$UID" != 0 ] && skip_env "must run as root" && return
5578 llite_lloop_enabled || \
5579 { skip_env "llite_lloop module disabled" && return; }
5581 trap cleanup_68 EXIT
5583 if ! module_loaded llite_lloop; then
5584 if load_module llite/llite_lloop; then
5587 skip_env "can't find module llite_lloop"
5592 LLOOP=$TMP/lloop.`date +%s`.`date +%N`
5593 dd if=/dev/zero of=$DIR/f68a bs=4k count=1024
5594 $LCTL blockdev_attach $DIR/f68a $LLOOP || error "attach failed"
5596 directio rdwr $LLOOP 0 1024 4096 || error "direct write failed"
5597 directio rdwr $LLOOP 0 1025 4096 && error "direct write should fail"
5601 run_test 68a "lloop driver - basic test ========================"
5603 # excercise swapping to lustre by adding a high priority swapfile entry
5604 # and then consuming memory until it is used.
5605 test_68b() { # was test_68
5606 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5607 [ "$UID" != 0 ] && skip_env "must run as root" && return
5608 lctl get_param -n devices | grep -q obdfilter && \
5609 skip "local OST" && return
5611 grep -q llite_lloop /proc/modules
5612 [ $? -ne 0 ] && skip "can't find module llite_lloop" && return
5614 [ -z "`$LCTL list_nids | grep -v tcp`" ] && \
5615 skip "can't reliably test swap with TCP" && return
5617 MEMTOTAL=`meminfo MemTotal`
5618 NR_BLOCKS=$((MEMTOTAL>>8))
5619 [[ $NR_BLOCKS -le 2048 ]] && NR_BLOCKS=2048
5621 LLOOP=$TMP/lloop.`date +%s`.`date +%N`
5622 dd if=/dev/zero of=$DIR/f68b bs=64k seek=$NR_BLOCKS count=1
5625 $LCTL blockdev_attach $DIR/f68b $LLOOP || error "attach failed"
5627 trap cleanup_68 EXIT
5629 swapon -p 32767 $LLOOP || error "swapon $LLOOP failed"
5631 echo "before: `swapon -s | grep $LLOOP`"
5632 $MEMHOG $MEMTOTAL || error "error allocating $MEMTOTAL kB"
5633 echo "after: `swapon -s | grep $LLOOP`"
5634 SWAPUSED=`swap_used $LLOOP`
5638 [ $SWAPUSED -eq 0 ] && echo "no swap used???" || true
5640 run_test 68b "support swapping to Lustre ========================"
5642 # bug5265, obdfilter oa2dentry return -ENOENT
5643 # #define OBD_FAIL_OST_ENOENT 0x217
5645 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5646 remote_ost_nodsh && skip "remote OST with nodsh" && return
5649 $SETSTRIPE -c 1 -i 0 $f
5651 $DIRECTIO write ${f}.2 0 1 || error "directio write error"
5653 do_facet ost1 lctl set_param fail_loc=0x217
5654 $TRUNCATE $f 1 # vmtruncate() will ignore truncate() error.
5655 $DIRECTIO write $f 0 2 && error "write succeeded, expect -ENOENT"
5657 do_facet ost1 lctl set_param fail_loc=0
5658 $DIRECTIO write $f 0 2 || error "write error"
5660 cancel_lru_locks osc
5661 $DIRECTIO read $f 0 1 || error "read error"
5663 do_facet ost1 lctl set_param fail_loc=0x217
5664 $DIRECTIO read $f 1 1 && error "read succeeded, expect -ENOENT"
5666 do_facet ost1 lctl set_param fail_loc=0
5669 run_test 69 "verify oa2dentry return -ENOENT doesn't LBUG ======"
5672 test_mkdir -p $DIR/$tdir
5673 $LFS setdirstripe -D -c$MDSCOUNT $DIR/$tdir
5674 sh rundbench -C -D $DIR/$tdir 2 || error "dbench failed!"
5676 run_test 71 "Running dbench on lustre (don't segment fault) ===="
5678 test_72a() { # bug 5695 - Test that on 2.6 remove_suid works properly
5679 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5680 [ "$RUNAS_ID" = "$UID" ] &&
5681 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
5683 # Check that testing environment is properly set up. Skip if not
5684 FAIL_ON_ERROR=false check_runas_id_ret $RUNAS_ID $RUNAS_GID $RUNAS || {
5685 skip_env "User $RUNAS_ID does not exist - skipping"
5689 chmod 777 $DIR/$tfile
5690 chmod ug+s $DIR/$tfile
5691 $RUNAS dd if=/dev/zero of=$DIR/$tfile bs=512 count=1 ||
5692 error "$RUNAS dd $DIR/$tfile failed"
5693 # See if we are still setuid/sgid
5694 test -u $DIR/$tfile -o -g $DIR/$tfile &&
5695 error "S/gid is not dropped on write"
5696 # Now test that MDS is updated too
5697 cancel_lru_locks mdc
5698 test -u $DIR/$tfile -o -g $DIR/$tfile &&
5699 error "S/gid is not dropped on MDS"
5702 run_test 72a "Test that remove suid works properly (bug5695) ===="
5704 test_72b() { # bug 24226 -- keep mode setting when size is not changing
5707 [ "$RUNAS_ID" = "$UID" ] && \
5708 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
5709 [ "$RUNAS_ID" -eq 0 ] && \
5710 skip_env "RUNAS_ID = 0 -- skipping" && return
5712 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5713 # Check that testing environment is properly set up. Skip if not
5714 FAIL_ON_ERROR=false check_runas_id_ret $RUNAS_ID $RUNAS_ID $RUNAS || {
5715 skip_env "User $RUNAS_ID does not exist - skipping"
5718 touch $DIR/${tfile}-f{g,u}
5719 test_mkdir $DIR/${tfile}-dg
5720 test_mkdir $DIR/${tfile}-du
5721 chmod 770 $DIR/${tfile}-{f,d}{g,u}
5722 chmod g+s $DIR/${tfile}-{f,d}g
5723 chmod u+s $DIR/${tfile}-{f,d}u
5724 for perm in 777 2777 4777; do
5725 $RUNAS chmod $perm $DIR/${tfile}-fg && error "S/gid file allowed improper chmod to $perm"
5726 $RUNAS chmod $perm $DIR/${tfile}-fu && error "S/uid file allowed improper chmod to $perm"
5727 $RUNAS chmod $perm $DIR/${tfile}-dg && error "S/gid dir allowed improper chmod to $perm"
5728 $RUNAS chmod $perm $DIR/${tfile}-du && error "S/uid dir allowed improper chmod to $perm"
5732 run_test 72b "Test that we keep mode setting if without file data changed (bug 24226)"
5734 # bug 3462 - multiple simultaneous MDC requests
5736 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5737 test_mkdir $DIR/d73-1
5738 test_mkdir $DIR/d73-2
5739 multiop_bg_pause $DIR/d73-1/f73-1 O_c || return 1
5742 lctl set_param fail_loc=0x80000129
5743 $MULTIOP $DIR/d73-1/f73-2 Oc &
5745 lctl set_param fail_loc=0
5747 $MULTIOP $DIR/d73-2/f73-3 Oc &
5751 wait $pid1 || return 1
5755 $CHECKSTAT -t file $DIR/d73-1/f73-1 || return 4
5756 $CHECKSTAT -t file $DIR/d73-1/f73-2 || return 5
5757 $CHECKSTAT -t file $DIR/d73-2/f73-3 || return 6
5761 run_test 73 "multiple MDC requests (should not deadlock)"
5763 test_74a() { # bug 6149, 6184
5764 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5765 #define OBD_FAIL_LDLM_ENQUEUE_OLD_EXPORT 0x30e
5767 # very important to OR with OBD_FAIL_ONCE (0x80000000) -- otherwise it
5768 # will spin in a tight reconnection loop
5770 $LCTL set_param fail_loc=0x8000030e
5771 # get any lock that won't be difficult - lookup works.
5773 $LCTL set_param fail_loc=0
5777 run_test 74a "ldlm_enqueue freed-export error path, ls (shouldn't LBUG)"
5779 test_74b() { # bug 13310
5780 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5781 #define OBD_FAIL_LDLM_ENQUEUE_OLD_EXPORT 0x30e
5783 # very important to OR with OBD_FAIL_ONCE (0x80000000) -- otherwise it
5784 # will spin in a tight reconnection loop
5785 $LCTL set_param fail_loc=0x8000030e
5786 # get a "difficult" lock
5788 $LCTL set_param fail_loc=0
5792 run_test 74b "ldlm_enqueue freed-export error path, touch (shouldn't LBUG)"
5795 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5796 #define OBD_FAIL_LDLM_NEW_LOCK
5797 $LCTL set_param fail_loc=0x319
5798 touch $DIR/$tfile && error "touch successful"
5799 $LCTL set_param fail_loc=0
5802 run_test 74c "ldlm_lock_create error path, (shouldn't LBUG)"
5805 awk '/lustre_inode_cache/ {print $2; exit}' /proc/slabinfo
5808 get_inode_slab_tunables() {
5809 awk '/lustre_inode_cache/ {print $9," ",$10," ",$11; exit}' /proc/slabinfo
5812 set_inode_slab_tunables() {
5813 echo "lustre_inode_cache $1" > /proc/slabinfo
5816 test_76() { # Now for bug 20433, added originally in bug 1443
5817 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5818 local SLAB_SETTINGS=`get_inode_slab_tunables`
5819 local CPUS=`getconf _NPROCESSORS_ONLN`
5820 # we cannot set limit below 1 which means 1 inode in each
5821 # per-cpu cache is still allowed
5822 set_inode_slab_tunables "1 1 0"
5823 cancel_lru_locks osc
5824 BEFORE_INODES=$(num_inodes)
5825 echo "before inodes: $BEFORE_INODES"
5827 [ "$SLOW" = "no" ] && COUNT=100
5828 for i in $(seq $COUNT); do
5832 cancel_lru_locks osc
5833 AFTER_INODES=$(num_inodes)
5834 echo "after inodes: $AFTER_INODES"
5836 while [[ $((AFTER_INODES-1*CPUS)) -gt $BEFORE_INODES ]]; do
5838 AFTER_INODES=$(num_inodes)
5840 echo "wait $wait seconds inodes: $AFTER_INODES"
5841 if [ $wait -gt 30 ]; then
5842 error "inode slab grew from $BEFORE_INODES to $AFTER_INODES"
5845 set_inode_slab_tunables "$SLAB_SETTINGS"
5847 run_test 76 "confirm clients recycle inodes properly ===="
5853 # Note: in sptlrpc modes which enable its own bulk checksum, the
5854 # original crc32_le bulk checksum will be automatically disabled,
5855 # and the OBD_FAIL_OSC_CHECKSUM_SEND/OBD_FAIL_OSC_CHECKSUM_RECEIVE
5856 # will be checked by sptlrpc code against sptlrpc bulk checksum.
5857 # In this case set_checksums() will not be no-op, because sptlrpc
5858 # bulk checksum will be enabled all through the test.
5860 [ "$ORIG_CSUM" ] || ORIG_CSUM=`lctl get_param -n osc.*.checksums | head -n1`
5861 lctl set_param -n osc.*.checksums $1
5865 export ORIG_CSUM_TYPE="`lctl get_param -n osc.*osc-[^mM]*.checksum_type |
5866 sed 's/.*\[\(.*\)\].*/\1/g' | head -n1`"
5867 CKSUM_TYPES=${CKSUM_TYPES:-"crc32 adler"}
5868 [ "$ORIG_CSUM_TYPE" = "crc32c" ] && CKSUM_TYPES="$CKSUM_TYPES crc32c"
5871 lctl set_param -n osc.*osc-[^mM]*.checksum_type $1
5872 log "set checksum type to $1"
5875 F77_TMP=$TMP/f77-temp
5878 dd if=/dev/urandom of=$F77_TMP bs=1M count=$F77SZ || \
5879 error "error writing to $F77_TMP"
5882 test_77a() { # bug 10889
5883 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5884 $GSS && skip "could not run with gss" && return
5885 [ ! -f $F77_TMP ] && setup_f77
5887 dd if=$F77_TMP of=$DIR/$tfile bs=1M count=$F77SZ || error "dd error"
5891 run_test 77a "normal checksum read/write operation"
5893 test_77b() { # bug 10889
5894 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5895 $GSS && skip "could not run with gss" && return
5896 [ ! -f $F77_TMP ] && setup_f77
5897 #define OBD_FAIL_OSC_CHECKSUM_SEND 0x409
5898 $LCTL set_param fail_loc=0x80000409
5901 dd if=$F77_TMP of=$DIR/$tfile bs=1M count=$F77SZ conv=sync ||
5902 error "dd error: $?"
5903 $LCTL set_param fail_loc=0
5905 for algo in $CKSUM_TYPES; do
5906 cancel_lru_locks osc
5907 set_checksum_type $algo
5908 #define OBD_FAIL_OSC_CHECKSUM_RECEIVE 0x408
5909 $LCTL set_param fail_loc=0x80000408
5910 cmp $F77_TMP $DIR/$tfile || error "file compare failed"
5911 $LCTL set_param fail_loc=0
5914 set_checksum_type $ORIG_CSUM_TYPE
5917 run_test 77b "checksum error on client write, read"
5919 test_77d() { # bug 10889
5920 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5921 $GSS && skip "could not run with gss" && return
5922 #define OBD_FAIL_OSC_CHECKSUM_SEND 0x409
5923 $LCTL set_param fail_loc=0x80000409
5925 $DIRECTIO write $DIR/$tfile 0 $F77SZ $((1024 * 1024)) ||
5926 error "direct write: rc=$?"
5927 $LCTL set_param fail_loc=0
5930 #define OBD_FAIL_OSC_CHECKSUM_RECEIVE 0x408
5931 $LCTL set_param fail_loc=0x80000408
5933 cancel_lru_locks osc
5934 $DIRECTIO read $DIR/$tfile 0 $F77SZ $((1024 * 1024)) ||
5935 error "direct read: rc=$?"
5936 $LCTL set_param fail_loc=0
5939 run_test 77d "checksum error on OST direct write, read"
5941 test_77f() { # bug 10889
5942 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5943 $GSS && skip "could not run with gss" && return
5945 for algo in $CKSUM_TYPES; do
5946 cancel_lru_locks osc
5947 set_checksum_type $algo
5948 #define OBD_FAIL_OSC_CHECKSUM_SEND 0x409
5949 $LCTL set_param fail_loc=0x409
5950 $DIRECTIO write $DIR/$tfile 0 $F77SZ $((1024 * 1024)) &&
5951 error "direct write succeeded"
5952 $LCTL set_param fail_loc=0
5954 set_checksum_type $ORIG_CSUM_TYPE
5957 run_test 77f "repeat checksum error on write (expect error)"
5959 test_77g() { # bug 10889
5960 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5961 $GSS && skip "could not run with gss" && return
5962 remote_ost_nodsh && skip "remote OST with nodsh" && return
5964 [ ! -f $F77_TMP ] && setup_f77
5966 $SETSTRIPE -c 1 -i 0 $DIR/$tfile
5967 #define OBD_FAIL_OST_CHECKSUM_RECEIVE 0x21a
5968 do_facet ost1 lctl set_param fail_loc=0x8000021a
5970 dd if=$F77_TMP of=$DIR/$tfile bs=1M count=$F77SZ ||
5971 error "write error: rc=$?"
5972 do_facet ost1 lctl set_param fail_loc=0
5975 cancel_lru_locks osc
5976 #define OBD_FAIL_OST_CHECKSUM_SEND 0x21b
5977 do_facet ost1 lctl set_param fail_loc=0x8000021b
5979 cmp $F77_TMP $DIR/$tfile || error "file compare failed"
5980 do_facet ost1 lctl set_param fail_loc=0
5983 run_test 77g "checksum error on OST write, read"
5985 test_77i() { # bug 13805
5986 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5987 $GSS && skip "could not run with gss" && return
5988 #define OBD_FAIL_OSC_CONNECT_CKSUM 0x40b
5989 lctl set_param fail_loc=0x40b
5990 remount_client $MOUNT
5991 lctl set_param fail_loc=0
5992 for VALUE in `lctl get_param osc.*osc-[^mM]*.checksum_type`; do
5993 PARAM=`echo ${VALUE[0]} | cut -d "=" -f1`
5994 algo=`lctl get_param -n $PARAM | sed 's/.*\[\(.*\)\].*/\1/g'`
5995 [ "$algo" = "adler" ] || error "algo set to $algo instead of adler"
5997 remount_client $MOUNT
5999 run_test 77i "client not supporting OSD_CONNECT_CKSUM"
6001 test_77j() { # bug 13805
6002 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6003 $GSS && skip "could not run with gss" && return
6004 #define OBD_FAIL_OSC_CKSUM_ADLER_ONLY 0x40c
6005 lctl set_param fail_loc=0x40c
6006 remount_client $MOUNT
6007 lctl set_param fail_loc=0
6008 sleep 2 # wait async osc connect to finish
6009 for VALUE in `lctl get_param osc.*osc-[^mM]*.checksum_type`; do
6010 PARAM=`echo ${VALUE[0]} | cut -d "=" -f1`
6011 algo=`lctl get_param -n $PARAM | sed 's/.*\[\(.*\)\].*/\1/g'`
6012 [ "$algo" = "adler" ] || error "algo set to $algo instead of adler"
6014 remount_client $MOUNT
6016 run_test 77j "client only supporting ADLER32"
6018 [ "$ORIG_CSUM" ] && set_checksums $ORIG_CSUM || true
6022 test_78() { # bug 10901
6023 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6024 remote_ost || { skip_env "local OST" && return; }
6027 F78SIZE=$(($(awk '/MemFree:/ { print $2 }' /proc/meminfo) / 1024))
6028 echo "MemFree: $F78SIZE, Max file size: $MAXFREE"
6029 MEMTOTAL=$(($(awk '/MemTotal:/ { print $2 }' /proc/meminfo) / 1024))
6030 echo "MemTotal: $MEMTOTAL"
6032 # reserve 256MB of memory for the kernel and other running processes,
6033 # and then take 1/2 of the remaining memory for the read/write buffers.
6034 if [ $MEMTOTAL -gt 512 ] ;then
6035 MEMTOTAL=$(((MEMTOTAL - 256 ) / 2))
6037 # for those poor memory-starved high-end clusters...
6038 MEMTOTAL=$((MEMTOTAL / 2))
6040 echo "Mem to use for directio: $MEMTOTAL"
6042 [[ $F78SIZE -gt $MEMTOTAL ]] && F78SIZE=$MEMTOTAL
6043 [[ $F78SIZE -gt 512 ]] && F78SIZE=512
6044 [[ $F78SIZE -gt $((MAXFREE / 1024)) ]] && F78SIZE=$((MAXFREE / 1024))
6045 SMALLESTOST=$($LFS df $DIR | grep OST | awk '{ print $4 }' | sort -n |
6047 echo "Smallest OST: $SMALLESTOST"
6048 [[ $SMALLESTOST -lt 10240 ]] &&
6049 skip "too small OSTSIZE, useless to run large O_DIRECT test" && return 0
6051 [[ $F78SIZE -gt $((SMALLESTOST * $OSTCOUNT / 1024 - 80)) ]] &&
6052 F78SIZE=$((SMALLESTOST * $OSTCOUNT / 1024 - 80))
6054 [ "$SLOW" = "no" ] && NSEQ=1 && [ $F78SIZE -gt 32 ] && F78SIZE=32
6055 echo "File size: $F78SIZE"
6056 $SETSTRIPE -c $OSTCOUNT $DIR/$tfile || error "setstripe failed"
6057 for i in $(seq 1 $NSEQ); do
6058 FSIZE=$(($F78SIZE / ($NSEQ - $i + 1)))
6059 echo directIO rdwr round $i of $NSEQ
6060 $DIRECTIO rdwr $DIR/$tfile 0 $FSIZE 1048576||error "rdwr failed"
6065 run_test 78 "handle large O_DIRECT writes correctly ============"
6067 test_79() { # bug 12743
6068 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6069 wait_delete_completed
6071 BKTOTAL=$(calc_osc_kbytes kbytestotal)
6072 BKFREE=$(calc_osc_kbytes kbytesfree)
6073 BKAVAIL=$(calc_osc_kbytes kbytesavail)
6075 STRING=`df -P $MOUNT | tail -n 1 | awk '{print $2","$3","$4}'`
6076 DFTOTAL=`echo $STRING | cut -d, -f1`
6077 DFUSED=`echo $STRING | cut -d, -f2`
6078 DFAVAIL=`echo $STRING | cut -d, -f3`
6079 DFFREE=$(($DFTOTAL - $DFUSED))
6081 ALLOWANCE=$((64 * $OSTCOUNT))
6083 if [ $DFTOTAL -lt $(($BKTOTAL - $ALLOWANCE)) ] ||
6084 [ $DFTOTAL -gt $(($BKTOTAL + $ALLOWANCE)) ] ; then
6085 error "df total($DFTOTAL) mismatch OST total($BKTOTAL)"
6087 if [ $DFFREE -lt $(($BKFREE - $ALLOWANCE)) ] ||
6088 [ $DFFREE -gt $(($BKFREE + $ALLOWANCE)) ] ; then
6089 error "df free($DFFREE) mismatch OST free($BKFREE)"
6091 if [ $DFAVAIL -lt $(($BKAVAIL - $ALLOWANCE)) ] ||
6092 [ $DFAVAIL -gt $(($BKAVAIL + $ALLOWANCE)) ] ; then
6093 error "df avail($DFAVAIL) mismatch OST avail($BKAVAIL)"
6096 run_test 79 "df report consistency check ======================="
6098 test_80() { # bug 10718
6099 remote_ost_nodsh && skip "remote OST with nodsh" && return
6100 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6101 # relax strong synchronous semantics for slow backends like ZFS
6102 local soc="obdfilter.*.sync_on_lock_cancel"
6103 local soc_old=$(do_facet ost1 lctl get_param -n $soc | head -n1)
6105 if [ "$soc_old" != "never" -a "$(facet_fstype ost1)" != "ldiskfs" ]; then
6106 hosts=$(for host in $(seq -f "ost%g" 1 $OSTCOUNT); do
6107 facet_active_host $host; done | sort -u)
6108 do_nodes $hosts lctl set_param $soc=never
6111 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=1M
6113 local BEFORE=`date +%s`
6114 cancel_lru_locks osc
6115 local AFTER=`date +%s`
6116 local DIFF=$((AFTER-BEFORE))
6117 if [ $DIFF -gt 1 ] ; then
6118 error "elapsed for 1M@1T = $DIFF"
6121 [ -n "$hosts" ] && do_nodes $hosts lctl set_param $soc=$soc_old
6125 run_test 80 "Page eviction is equally fast at high offsets too ===="
6127 test_81a() { # LU-456
6128 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6129 remote_ost_nodsh && skip "remote OST with nodsh" && return
6130 # define OBD_FAIL_OST_MAPBLK_ENOSPC 0x228
6131 # MUST OR with the OBD_FAIL_ONCE (0x80000000)
6132 do_facet ost1 lctl set_param fail_loc=0x80000228
6134 # write should trigger a retry and success
6135 $SETSTRIPE -i 0 -c 1 $DIR/$tfile
6136 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
6138 if [ $RC -ne 0 ] ; then
6139 error "write should success, but failed for $RC"
6142 run_test 81a "OST should retry write when get -ENOSPC ==============="
6144 test_81b() { # LU-456
6145 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6146 remote_ost_nodsh && skip "remote OST with nodsh" && return
6147 # define OBD_FAIL_OST_MAPBLK_ENOSPC 0x228
6148 # Don't OR with the OBD_FAIL_ONCE (0x80000000)
6149 do_facet ost1 lctl set_param fail_loc=0x228
6151 # write should retry several times and return -ENOSPC finally
6152 $SETSTRIPE -i 0 -c 1 $DIR/$tfile
6153 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
6156 if [ $RC -ne $ENOSPC ] ; then
6157 error "dd should fail for -ENOSPC, but succeed."
6160 run_test 81b "OST should return -ENOSPC when retry still fails ======="
6162 test_82() { # LU-1031
6163 dd if=/dev/zero of=$DIR/$tfile bs=1M count=10
6167 multiop_bg_pause $DIR/$tfile OG${gid1}_g${gid1}c || return 1
6169 multiop_bg_pause $DIR/$tfile O_G${gid2}r10g${gid2}c || return 2
6171 kill -USR1 $MULTIPID2
6173 if [[ `ps h -o comm -p $MULTIPID2` == "" ]]; then
6174 error "First grouplock does not block second one"
6176 echo "Second grouplock blocks first one"
6178 kill -USR1 $MULTIPID1
6182 run_test 82 "Basic grouplock test ==============================="
6185 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" &&
6187 test_mkdir -p $DIR/d99cvsroot
6188 chown $RUNAS_ID $DIR/d99cvsroot
6189 local oldPWD=$PWD # bug 13584, use $TMP as working dir
6192 $RUNAS cvs -d $DIR/d99cvsroot init || error "cvs init failed"
6195 run_test 99a "cvs init ========================================="
6198 [ -z "$(which cvs 2>/dev/null)" ] &&
6199 skip_env "could not find cvs" && return
6200 [ ! -d $DIR/d99cvsroot ] && test_99a
6202 # some versions of cvs import exit(1) when asked to import links or
6203 # files they can't read. ignore those files.
6204 TOIGNORE=$(find . -type l -printf '-I %f\n' -o \
6205 ! -perm +4 -printf '-I %f\n')
6206 $RUNAS cvs -d $DIR/d99cvsroot import -m "nomesg" $TOIGNORE \
6207 d99reposname vtag rtag
6209 run_test 99b "cvs import ======================================="
6212 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" && return
6213 [ ! -d $DIR/d99cvsroot ] && test_99b
6215 test_mkdir -p $DIR/d99reposname
6216 chown $RUNAS_ID $DIR/d99reposname
6217 $RUNAS cvs -d $DIR/d99cvsroot co d99reposname
6219 run_test 99c "cvs checkout ====================================="
6222 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" && return
6223 [ ! -d $DIR/d99cvsroot ] && test_99c
6224 cd $DIR/d99reposname
6226 $RUNAS cvs add -m 'addmsg' foo99
6228 run_test 99d "cvs add =========================================="
6231 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" && return
6232 [ ! -d $DIR/d99cvsroot ] && test_99c
6233 cd $DIR/d99reposname
6236 run_test 99e "cvs update ======================================="
6239 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" && return
6240 [ ! -d $DIR/d99cvsroot ] && test_99d
6241 cd $DIR/d99reposname
6242 $RUNAS cvs commit -m 'nomsg' foo99
6243 rm -fr $DIR/d99cvsroot
6245 run_test 99f "cvs commit ======================================="
6248 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6249 [ "$NETTYPE" = tcp ] || \
6250 { skip "TCP secure port test, not useful for NETTYPE=$NETTYPE" && \
6253 remote_ost_nodsh && skip "remote OST with nodsh" && return
6254 remote_mds_nodsh && skip "remote MDS with nodsh" && return
6256 { skip "useless for local single node setup" && return; }
6258 netstat -tna | ( rc=1; while read PROT SND RCV LOCAL REMOTE STAT; do
6259 [ "$PROT" != "tcp" ] && continue
6260 RPORT=$(echo $REMOTE | cut -d: -f2)
6261 [ "$RPORT" != "$ACCEPTOR_PORT" ] && continue
6264 LPORT=`echo $LOCAL | cut -d: -f2`
6265 if [ $LPORT -ge 1024 ]; then
6266 echo "bad: $PROT $SND $RCV $LOCAL $REMOTE $STAT"
6268 error_exit "local: $LPORT > 1024, remote: $RPORT"
6271 [ "$rc" = 0 ] || error_exit "privileged port not found" )
6273 run_test 100 "check local port using privileged port ==========="
6275 function get_named_value()
6284 echo $line | sed "s/^$tag[ ]*//"
6291 export CACHE_MAX=$($LCTL get_param -n llite.*.max_cached_mb |
6292 awk '/^max_cached_mb/ { print $2 }')
6295 $LCTL set_param -n llite.*.max_cached_mb $CACHE_MAX
6300 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6301 [ $MDSCOUNT -ge 2 ] && skip "skip now for >= 2 MDTs" && return #LU-4322
6305 local cache_limit=32
6307 $LCTL set_param -n osc.*-osc*.rpc_stats 0
6308 trap cleanup_101a EXIT
6309 $LCTL set_param -n llite.*.read_ahead_stats 0
6310 $LCTL set_param -n llite.*.max_cached_mb $cache_limit
6313 # randomly read 10000 of 64K chunks from file 3x 32MB in size
6315 echo "nreads: $nreads file size: $((cache_limit * 3))MB"
6316 $READS -f $DIR/$tfile -s$((cache_limit * 3192 * 1024)) -b65536 -C -n$nreads -t 180
6319 for s in $($LCTL get_param -n llite.*.read_ahead_stats |
6320 get_named_value 'read but discarded' | cut -d" " -f1); do
6321 discard=$(($discard + $s))
6325 if [[ $(($discard * 10)) -gt $nreads ]]; then
6326 $LCTL get_param osc.*-osc*.rpc_stats
6327 $LCTL get_param llite.*.read_ahead_stats
6328 error "too many ($discard) discarded pages"
6330 rm -f $DIR/$tfile || true
6332 run_test 101a "check read-ahead for random reads ================"
6335 test_mkdir -p $DIR/$tdir
6336 local STRIPE_SIZE=$1
6337 local FILE_LENGTH=$2
6340 local FILE_SIZE_MB=$((FILE_LENGTH / STRIPE_SIZE))
6342 local list=$(comma_list $(osts_nodes))
6343 set_osd_param $list '' read_cache_enable 0
6344 set_osd_param $list '' writethrough_cache_enable 0
6346 trap cleanup_test101bc EXIT
6347 # prepare the read-ahead file
6348 $SETSTRIPE -S $STRIPE_SIZE -i $STRIPE_OFFSET -c $OSTCOUNT $DIR/$tfile
6350 dd if=/dev/zero of=$DIR/$tfile bs=$STRIPE_SIZE \
6351 count=$FILE_SIZE_MB 2> /dev/null
6355 cleanup_test101bc() {
6360 local list=$(comma_list $(osts_nodes))
6361 set_osd_param $list '' read_cache_enable 1
6362 set_osd_param $list '' writethrough_cache_enable 1
6366 awk 'BEGIN{total=0}; {total+=$1}; END{print total}'
6371 local STRIPE_SIZE=$2
6372 local FILE_LENGTH=$3
6373 local RA_INC=1048576
6374 local STRIDE_LENGTH=$((STRIPE_SIZE/READ_SIZE))
6375 local discard_limit=$((((STRIDE_LENGTH - 1)*3/(STRIDE_LENGTH*OSTCOUNT))* \
6376 (STRIDE_LENGTH*OSTCOUNT - STRIDE_LENGTH)))
6377 DISCARD=$($LCTL get_param -n llite.*.read_ahead_stats |
6378 get_named_value 'read but discarded' |
6379 cut -d" " -f1 | calc_total)
6380 if [[ $DISCARD -gt $discard_limit ]]; then
6381 $LCTL get_param llite.*.read_ahead_stats
6382 error "Too many ($DISCARD) discarded pages with size (${READ_SIZE})"
6384 echo "Read-ahead success for size ${READ_SIZE}"
6389 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6390 [[ $OSTCOUNT -lt 2 ]] &&
6391 skip_env "skipping stride IO stride-ahead test" && return
6392 local STRIPE_SIZE=1048576
6393 local STRIDE_SIZE=$((STRIPE_SIZE*OSTCOUNT))
6394 if [ $SLOW == "yes" ]; then
6395 local FILE_LENGTH=$((STRIDE_SIZE * 64))
6397 local FILE_LENGTH=$((STRIDE_SIZE * 8))
6400 local ITERATION=$((FILE_LENGTH / STRIDE_SIZE))
6402 # prepare the read-ahead file
6403 setup_test101bc $STRIPE_SIZE $FILE_LENGTH
6404 cancel_lru_locks osc
6405 for BIDX in 2 4 8 16 32 64 128 256
6407 local BSIZE=$((BIDX*4096))
6408 local READ_COUNT=$((STRIPE_SIZE/BSIZE))
6409 local STRIDE_LENGTH=$((STRIDE_SIZE/BSIZE))
6410 local OFFSET=$((STRIPE_SIZE/BSIZE*(OSTCOUNT - 1)))
6411 $LCTL set_param -n llite.*.read_ahead_stats 0
6412 $READS -f $DIR/$tfile -l $STRIDE_LENGTH -o $OFFSET \
6413 -s $FILE_LENGTH -b $STRIPE_SIZE -a $READ_COUNT -n $ITERATION
6414 cancel_lru_locks osc
6415 ra_check_101 $BSIZE $STRIPE_SIZE $FILE_LENGTH
6420 run_test 101b "check stride-io mode read-ahead ================="
6423 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6424 local STRIPE_SIZE=1048576
6425 local FILE_LENGTH=$((STRIPE_SIZE*100))
6429 setup_test101bc $STRIPE_SIZE $FILE_LENGTH
6431 cancel_lru_locks osc
6432 $LCTL set_param osc.*.rpc_stats 0
6433 $READS -f $DIR/$tfile -s$FILE_LENGTH -b65536 -n$nreads -t 180
6434 for osc_rpc_stats in $($LCTL get_param -N osc.*.rpc_stats); do
6435 local stats=$($LCTL get_param -n $osc_rpc_stats)
6436 local lines=$(echo "$stats" | awk 'END {print NR;}')
6439 if [ $lines -le 20 ]; then
6442 for size in 1 2 4 8; do
6443 local rpc=$(echo "$stats" |
6444 awk '($1 == "'$size':") {print $2; exit; }')
6446 error "Small $((size*4))k read IO $rpc !"
6448 echo "$osc_rpc_stats check passed!"
6453 run_test 101c "check stripe_size aligned read-ahead ================="
6456 $LCTL get_param -n llite.*.max_read_ahead_mb | head -n 1
6457 $LCTL set_param -n llite.*.max_read_ahead_mb $1 > /dev/null 2>&1
6461 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6462 local file=$DIR/$tfile
6463 local sz_MB=${FILESIZE_101d:-500}
6464 local ra_MB=${READAHEAD_MB:-40}
6466 local free_MB=$(($(df -P $DIR | tail -n 1 | awk '{ print $4 }') / 1024))
6467 [ $free_MB -lt $sz_MB ] &&
6468 skip "Need free space ${sz_MB}M, have ${free_MB}M" && return
6470 echo "Create test file $file size ${sz_MB}M, ${free_MB}M free"
6471 $SETSTRIPE -c -1 $file || error "setstripe failed"
6473 dd if=/dev/zero of=$file bs=1M count=$sz_MB || error "dd failed"
6474 echo Cancel LRU locks on lustre client to flush the client cache
6475 cancel_lru_locks osc
6477 echo Disable read-ahead
6478 local old_READAHEAD=$(set_read_ahead 0)
6480 echo Reading the test file $file with read-ahead disabled
6481 local raOFF=$(do_and_time "dd if=$file of=/dev/null bs=1M count=$sz_MB")
6483 echo Cancel LRU locks on lustre client to flush the client cache
6484 cancel_lru_locks osc
6485 echo Enable read-ahead with ${ra_MB}MB
6486 set_read_ahead $ra_MB
6488 echo Reading the test file $file with read-ahead enabled
6489 local raON=$(do_and_time "dd if=$file of=/dev/null bs=1M count=$sz_MB")
6491 echo "read-ahead disabled time read $raOFF"
6492 echo "read-ahead enabled time read $raON"
6494 set_read_ahead $old_READAHEAD
6496 wait_delete_completed
6498 [ $raOFF -le 1 -o $raON -lt $raOFF ] ||
6499 error "readahead ${raON}s > no-readahead ${raOFF}s ${sz_MB}M"
6501 run_test 101d "file read with and without read-ahead enabled"
6504 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6505 local file=$DIR/$tfile
6506 local size_KB=500 #KB
6510 local free_KB=$(df -P $DIR | tail -n 1 | awk '{ print $4 }')
6511 local need_KB=$((count * size_KB))
6512 [[ $free_KB -le $need_KB ]] &&
6513 skip_env "Need free space $need_KB, have $free_KB" && return
6515 echo "Creating $count ${size_KB}K test files"
6516 for ((i = 0; i < $count; i++)); do
6517 dd if=/dev/zero of=$file.$i bs=$bsize count=$size_KB 2>/dev/null
6520 echo "Cancel LRU locks on lustre client to flush the client cache"
6521 cancel_lru_locks osc
6523 echo "Reset readahead stats"
6524 $LCTL set_param -n llite.*.read_ahead_stats 0
6526 for ((i = 0; i < $count; i++)); do
6527 dd if=$file.$i of=/dev/null bs=$bsize count=$size_KB 2>/dev/null
6530 local miss=$($LCTL get_param -n llite.*.read_ahead_stats |
6531 get_named_value 'misses' | cut -d" " -f1 | calc_total)
6533 for ((i = 0; i < $count; i++)); do
6534 rm -rf $file.$i 2>/dev/null
6537 #10000 means 20% reads are missing in readahead
6538 [[ $miss -lt 10000 ]] || error "misses too much for small reads"
6540 run_test 101e "check read-ahead for small read(1k) for small files(500k)"
6542 cleanup_test101f() {
6544 $LCTL set_param -n llite.*.max_read_ahead_whole_mb $MAX_WHOLE_MB
6545 rm -rf $DIR/$tfile 2>/dev/null
6549 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6550 local file=$DIR/$tfile
6553 MAX_WHOLE_MB=$($LCTL get_param -n llite.*.max_read_ahead_whole_mb)
6554 $LCTL set_param -n llite.*.max_read_ahead_whole_mb 2
6555 dd if=/dev/zero of=${file} bs=2097152 count=1 2>/dev/null
6556 trap cleanup_test101f EXIT
6558 echo Cancel LRU locks on lustre client to flush the client cache
6559 cancel_lru_locks osc
6561 echo Reset readahead stats
6562 $LCTL set_param -n llite.*.read_ahead_stats 0
6563 # Random read in a 2M file, because max_read_ahead_whole_mb = 2M,
6564 # readahead should read in 2M file on second read, so only miss
6566 echo Random 4K reads on 2M file for 1000 times
6567 $READS -f $file -s 2097152 -b 4096 -n $nreads
6569 echo checking missing pages
6570 local miss=$($LCTL get_param -n llite.*.read_ahead_stats |
6571 get_named_value 'misses' | cut -d" " -f1 | calc_total)
6573 [ $miss -lt 3 ] || error "misses too much pages!"
6576 run_test 101f "check read-ahead for max_read_ahead_whole_mb"
6579 test_mkdir -p $DIR/$tdir
6580 chown $RUNAS_ID $DIR/$tdir
6583 STRIPE_COUNT=$OSTCOUNT
6584 [[ $OSTCOUNT -gt 4 ]] && STRIPE_COUNT=4
6586 trap cleanup_test102 EXIT
6588 $1 $SETSTRIPE -S $STRIPE_SIZE -i $STRIPE_OFFSET -c $STRIPE_COUNT $tdir
6590 for num in 1 2 3 4; do
6591 for count in $(seq 1 $STRIPE_COUNT); do
6592 for idx in $(seq 0 $[$STRIPE_COUNT - 1]); do
6593 local size=`expr $STRIPE_SIZE \* $num`
6594 local file=file"$num-$idx-$count"
6595 $1 $SETSTRIPE -S $size -i $idx -c $count $file
6601 $1 $TAR cf $TMP/f102.tar $tdir --xattrs
6607 rm -rf $DIR/d0.sanity/d102
6611 local testfile=$DIR/$tfile
6615 [ "$UID" != 0 ] && skip_env "must run as root" && return
6616 [ -z "$(lctl get_param -n mdc.*-mdc-*.connect_flags | grep xattr)" ] &&
6617 skip_env "must have user_xattr" && return
6619 [ -z "$(which setfattr 2>/dev/null)" ] &&
6620 skip_env "could not find setfattr" && return
6622 echo "set/get xattr..."
6623 setfattr -n trusted.name1 -v value1 $testfile ||
6624 error "setfattr -n trusted.name1=value1 $testfile failed"
6625 getfattr -n trusted.name1 $testfile 2> /dev/null |
6626 grep "trusted.name1=.value1" ||
6627 error "$testfile missing trusted.name1=value1"
6629 setfattr -n user.author1 -v author1 $testfile ||
6630 error "setfattr -n user.author1=author1 $testfile failed"
6631 getfattr -n user.author1 $testfile 2> /dev/null |
6632 grep "user.author1=.author1" ||
6633 error "$testfile missing trusted.author1=author1"
6636 setfattr -n trusted.name2 -v value2 $testfile ||
6637 error "$testfile unable to set trusted.name2"
6638 setfattr -n trusted.name3 -v value3 $testfile ||
6639 error "$testfile unable to set trusted.name3"
6640 [ $(getfattr -d -m "^trusted" $testfile 2> /dev/null |
6641 grep "trusted.name" | wc -l) -eq 3 ] ||
6642 error "$testfile missing 3 trusted.name xattrs"
6644 setfattr -n user.author2 -v author2 $testfile ||
6645 error "$testfile unable to set user.author2"
6646 setfattr -n user.author3 -v author3 $testfile ||
6647 error "$testfile unable to set user.author3"
6648 [ $(getfattr -d -m "^user" $testfile 2> /dev/null |
6649 grep "user.author" | wc -l) -eq 3 ] ||
6650 error "$testfile missing 3 user.author xattrs"
6652 echo "remove xattr..."
6653 setfattr -x trusted.name1 $testfile ||
6654 error "$testfile error deleting trusted.name1"
6655 getfattr -d -m trusted $testfile 2> /dev/null | grep "trusted.name1" &&
6656 error "$testfile did not delete trusted.name1 xattr"
6658 setfattr -x user.author1 $testfile ||
6659 error "$testfile error deleting user.author1"
6660 getfattr -d -m user $testfile 2> /dev/null | grep "user.author1" &&
6661 error "$testfile did not delete trusted.name1 xattr"
6663 # b10667: setting lustre special xattr be silently discarded
6664 echo "set lustre special xattr ..."
6665 setfattr -n "trusted.lov" -v "invalid value" $testfile ||
6666 error "$testfile allowed setting trusted.lov"
6668 run_test 102a "user xattr test =================================="
6671 [ -z "$(which setfattr 2>/dev/null)" ] &&
6672 skip_env "could not find setfattr" && return
6674 # b10930: get/set/list trusted.lov xattr
6675 echo "get/set/list trusted.lov xattr ..."
6676 [[ $OSTCOUNT -lt 2 ]] && skip_env "skipping 2-stripe test" && return
6677 local testfile=$DIR/$tfile
6678 $SETSTRIPE -S 65536 -i 1 -c $OSTCOUNT $testfile ||
6679 error "setstripe failed"
6680 local STRIPECOUNT=$($GETSTRIPE -c $testfile) ||
6681 error "getstripe failed"
6682 getfattr -d -m "^trusted" $testfile 2>/dev/null | grep "trusted.lov" ||
6683 error "can't get trusted.lov from $testfile"
6685 local testfile2=${testfile}2
6686 local value=$(getfattr -n trusted.lov $testfile 2>/dev/null |
6687 grep "trusted.lov" | sed -e 's/[^=]\+=//')
6690 setfattr -n trusted.lov -v $value $testfile2
6691 local stripe_size=$($GETSTRIPE -S $testfile2)
6692 local stripe_count=$($GETSTRIPE -c $testfile2)
6693 [[ $stripe_size -eq 65536 ]] ||
6694 error "stripe size $stripe_size != 65536"
6695 [[ $stripe_count -eq $STRIPECOUNT ]] ||
6696 error "stripe count $stripe_count != $STRIPECOUNT"
6699 run_test 102b "getfattr/setfattr for trusted.lov EAs ============"
6702 [ -z "$(which setfattr 2>/dev/null)" ] &&
6703 skip_env "could not find setfattr" && return
6705 # b10930: get/set/list lustre.lov xattr
6706 echo "get/set/list lustre.lov xattr ..."
6707 [[ $OSTCOUNT -lt 2 ]] && skip_env "skipping 2-stripe test" && return
6708 test_mkdir -p $DIR/$tdir
6709 chown $RUNAS_ID $DIR/$tdir
6710 local testfile=$DIR/$tdir/$tfile
6711 $RUNAS $SETSTRIPE -S 65536 -i 1 -c $OSTCOUNT $testfile ||
6712 error "setstripe failed"
6713 local STRIPECOUNT=$($RUNAS $GETSTRIPE -c $testfile) ||
6714 error "getstripe failed"
6715 $RUNAS getfattr -d -m "^lustre" $testfile 2> /dev/null | \
6716 grep "lustre.lov" || error "can't get lustre.lov from $testfile"
6718 local testfile2=${testfile}2
6719 local value=`getfattr -n lustre.lov $testfile 2> /dev/null | \
6720 grep "lustre.lov" |sed -e 's/[^=]\+=//' `
6722 $RUNAS $MCREATE $testfile2
6723 $RUNAS setfattr -n lustre.lov -v $value $testfile2
6724 local stripe_size=$($RUNAS $GETSTRIPE -S $testfile2)
6725 local stripe_count=$($RUNAS $GETSTRIPE -c $testfile2)
6726 [ $stripe_size -eq 65536 ] || error "stripe size $stripe_size != 65536"
6727 [ $stripe_count -eq $STRIPECOUNT ] ||
6728 error "stripe count $stripe_count != $STRIPECOUNT"
6730 run_test 102c "non-root getfattr/setfattr for lustre.lov EAs ==========="
6732 compare_stripe_info1() {
6733 local stripe_index_all_zero=true
6735 for num in 1 2 3 4; do
6736 for count in $(seq 1 $STRIPE_COUNT); do
6737 for offset in $(seq 0 $[$STRIPE_COUNT - 1]); do
6738 local size=$((STRIPE_SIZE * num))
6739 local file=file"$num-$offset-$count"
6740 stripe_size=$($LFS getstripe -S $PWD/$file)
6741 [[ $stripe_size -ne $size ]] &&
6742 error "$file: size $stripe_size != $size"
6743 stripe_count=$($LFS getstripe -c $PWD/$file)
6744 # allow fewer stripes to be created, ORI-601
6745 [[ $stripe_count -lt $(((3 * count + 3) / 4)) ]] &&
6746 error "$file: count $stripe_count != $count"
6747 stripe_index=$($LFS getstripe -i $PWD/$file)
6748 [[ $stripe_index -ne 0 ]] &&
6749 stripe_index_all_zero=false
6753 $stripe_index_all_zero &&
6754 error "all files are being extracted starting from OST index 0"
6759 [ -n "$(which tar 2>/dev/null)" ] &&
6760 strings $(which tar) | grep -q "lustre" && echo tar
6764 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6765 # b10930: tar test for trusted.lov xattr
6766 TAR=$(find_lustre_tar)
6767 [ -z "$TAR" ] && skip_env "lustre-aware tar is not installed" && return
6768 [[ $OSTCOUNT -lt 2 ]] && skip_env "skipping N-stripe test" && return
6770 test_mkdir -p $DIR/d102d
6771 $TAR xf $TMP/f102.tar -C $DIR/d102d --xattrs
6773 compare_stripe_info1
6775 run_test 102d "tar restore stripe info from tarfile,not keep osts ==========="
6778 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6779 # b10930: tar test for trusted.lov xattr
6780 TAR=$(find_lustre_tar)
6781 [ -z "$TAR" ] && skip_env "lustre-aware tar is not installed" && return
6782 [[ $OSTCOUNT -lt 2 ]] && skip_env "skipping N-stripe test" && return
6784 test_mkdir -p $DIR/d102f
6786 $TAR cf - --xattrs $tdir | $TAR xf - --xattrs -C $DIR/d102f
6788 compare_stripe_info1
6790 run_test 102f "tar copy files, not keep osts ==========="
6793 local xsize=${1:-1024} # in bytes
6794 local file=$DIR/$tfile
6796 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep xattr)" ] &&
6797 skip "must have user_xattr" && return 0
6798 [ -z "$(which setfattr 2>/dev/null)" ] &&
6799 skip_env "could not find setfattr" && return 0
6800 [ -z "$(which getfattr 2>/dev/null)" ] &&
6801 skip_env "could not find getfattr" && return 0
6805 local value="$(generate_string $xsize)"
6807 local xbig=trusted.big
6808 log "save $xbig on $file"
6809 setfattr -n $xbig -v $value $file ||
6810 error "saving $xbig on $file failed"
6812 local orig=$(get_xattr_value $xbig $file)
6813 [[ "$orig" != "$value" ]] && error "$xbig different after saving $xbig"
6815 local xsml=trusted.sml
6816 log "save $xsml on $file"
6817 setfattr -n $xsml -v val $file || error "saving $xsml on $file failed"
6819 local new=$(get_xattr_value $xbig $file)
6820 [[ "$new" != "$orig" ]] && error "$xbig different after saving $xsml"
6822 log "grow $xsml on $file"
6823 setfattr -n $xsml -v "$value" $file ||
6824 error "growing $xsml on $file failed"
6826 new=$(get_xattr_value $xbig $file)
6827 [[ "$new" != "$orig" ]] && error "$xbig different after growing $xsml"
6828 log "$xbig still valid after growing $xsml"
6833 test_102h() { # bug 15777
6836 run_test 102h "grow xattr from inside inode to external block"
6839 large_xattr_enabled || { skip "large_xattr disabled" && return; }
6840 grow_xattr $(max_xattr_size)
6842 run_test 102ha "grow xattr from inside inode to external inode"
6844 test_102i() { # bug 17038
6845 [ -z "$(which getfattr 2>/dev/null)" ] &&
6846 skip "could not find getfattr" && return
6848 ln -s $DIR/$tfile $DIR/${tfile}link
6849 getfattr -n trusted.lov $DIR/$tfile ||
6850 error "lgetxattr on $DIR/$tfile failed"
6851 getfattr -h -n trusted.lov $DIR/${tfile}link 2>&1 |
6852 grep -i "no such attr" ||
6853 error "error for lgetxattr on $DIR/${tfile}link is not ENODATA"
6854 rm -f $DIR/$tfile $DIR/${tfile}link
6856 run_test 102i "lgetxattr test on symbolic link ============"
6859 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6860 TAR=$(find_lustre_tar)
6861 [ -z "$TAR" ] && skip_env "lustre-aware tar is not installed" && return
6862 [[ $OSTCOUNT -lt 2 ]] && skip_env "skipping N-stripe test" && return
6863 setup_test102 "$RUNAS"
6864 test_mkdir -p $DIR/d102j
6865 chown $RUNAS_ID $DIR/d102j
6866 $RUNAS $TAR xf $TMP/f102.tar -C $DIR/d102j --xattrs
6868 compare_stripe_info1 "$RUNAS"
6870 run_test 102j "non-root tar restore stripe info from tarfile, not keep osts ==="
6873 [ -z "$(which setfattr 2>/dev/null)" ] &&
6874 skip "could not find setfattr" && return
6876 # b22187 just check that does not crash for regular file.
6877 setfattr -n trusted.lov $DIR/$tfile
6878 # b22187 'setfattr -n trusted.lov' should work as remove LOV EA for directories
6879 local test_kdir=$DIR/d102k
6880 test_mkdir $test_kdir
6881 local default_size=`$GETSTRIPE -S $test_kdir`
6882 local default_count=`$GETSTRIPE -c $test_kdir`
6883 local default_offset=`$GETSTRIPE -i $test_kdir`
6884 $SETSTRIPE -S 65536 -i 0 -c $OSTCOUNT $test_kdir ||
6885 error 'dir setstripe failed'
6886 setfattr -n trusted.lov $test_kdir
6887 local stripe_size=`$GETSTRIPE -S $test_kdir`
6888 local stripe_count=`$GETSTRIPE -c $test_kdir`
6889 local stripe_offset=`$GETSTRIPE -i $test_kdir`
6890 [ $stripe_size -eq $default_size ] ||
6891 error "stripe size $stripe_size != $default_size"
6892 [ $stripe_count -eq $default_count ] ||
6893 error "stripe count $stripe_count != $default_count"
6894 [ $stripe_offset -eq $default_offset ] ||
6895 error "stripe offset $stripe_offset != $default_offset"
6896 rm -rf $DIR/$tfile $test_kdir
6898 run_test 102k "setfattr without parameter of value shouldn't cause a crash"
6901 [ -z "$(which getfattr 2>/dev/null)" ] &&
6902 skip "could not find getfattr" && return
6904 # LU-532 trusted. xattr is invisible to non-root
6905 local testfile=$DIR/$tfile
6909 echo "listxattr as user..."
6910 chown $RUNAS_ID $testfile
6911 $RUNAS getfattr -d -m '.*' $testfile 2>&1 |
6912 grep -q "trusted" &&
6913 error "$testfile trusted xattrs are user visible"
6917 run_test 102l "listxattr size test =================================="
6919 test_102m() { # LU-3403 llite: error of listxattr when buffer is small
6920 local path=$DIR/$tfile
6923 listxattr_size_check $path || error "listattr_size_check $path failed"
6925 run_test 102m "Ensure listxattr fails on small bufffer ========"
6929 getxattr() { # getxattr path name
6930 # Return the base64 encoding of the value of xattr name on path.
6934 # # getfattr --absolute-names --encoding=base64 --name=trusted.lov $path
6936 # trusted.lov=0s0AvRCwEAAAAGAAAAAAAAAAAEAAACAAAAAAAQAAEAA...AAAAAAAAA=
6938 # We print just 0s0AvRCwEAAAAGAAAAAAAAAAAEAAACAAAAAAAQAAEAA...AAAAAAAAA=
6940 getfattr --absolute-names --encoding=base64 --name=$name $path |
6941 awk -F= -v name=$name '$1 == name {
6942 print substr($0, index($0, "=") + 1);
6946 test_102n() { # LU-4101 mdt: protect internal xattrs
6947 local file0=$DIR/$tfile.0
6948 local file1=$DIR/$tfile.1
6949 local xattr0=$TMP/$tfile.0
6950 local xattr1=$TMP/$tfile.1
6954 [ -z "$(which setfattr 2>/dev/null)" ] &&
6955 skip "could not find setfattr" && return
6957 if [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.5.50) ]
6959 skip "MDT < 2.5.50 allows setxattr on internal trusted xattrs"
6963 rm -rf $file0 $file1 $xattr0 $xattr1
6966 # Get 'before' xattrs of $file1.
6967 getfattr --absolute-names --dump --match=- $file1 > $xattr0
6969 for name in lov lma lmv link fid version som hsm lfsck_namespace; do
6970 # Try to copy xattr from $file0 to $file1.
6971 value=$(getxattr $file0 trusted.$name 2> /dev/null)
6973 setfattr --name=trusted.$name --value="$value" $file1 ||
6974 error "setxattr 'trusted.$name' failed"
6976 # Try to set a garbage xattr.
6977 value=0sVGhlIHF1aWNrIGJyb3duIGZveCBqdW1wcyBvdmVyIGl0c2VsZi4=
6979 setfattr --name=trusted.$name --value="$value" $file1 ||
6980 error "setxattr 'trusted.$name' failed"
6982 # Try to remove the xattr from $file1. We don't care if this
6983 # appears to succeed or fail, we just don't want there to be
6984 # any changes or crashes.
6985 setfattr --remove=$trusted.$name $file1 2> /dev/null
6988 if [ $(lustre_version_code $SINGLEMDS) -gt $(version_code 2.6.50) ]
6991 # Try to copy xattr from $file0 to $file1.
6992 value=$(getxattr $file0 trusted.$name 2> /dev/null)
6994 setfattr --name=trusted.$name --value="$value" $file1 ||
6995 error "setxattr 'trusted.$name' failed"
6997 # Try to set a garbage xattr.
6998 value=0sVGhlIHF1aWNrIGJyb3duIGZveCBqdW1wcyBvdmVyIGl0c2VsZi4=
7000 setfattr --name=trusted.$name --value="$value" $file1 ||
7001 error "setxattr 'trusted.$name' failed"
7003 # Try to remove the xattr from $file1. We don't care if this
7004 # appears to succeed or fail, we just don't want there to be
7005 # any changes or crashes.
7006 setfattr --remove=$trusted.$name $file1 2> /dev/null
7009 # Get 'after' xattrs of file1.
7010 getfattr --absolute-names --dump --match=- $file1 > $xattr1
7012 if ! diff $xattr0 $xattr1; then
7013 error "before and after xattrs of '$file1' differ"
7016 rm -rf $file0 $file1 $xattr0 $xattr1
7020 run_test 102n "silently ignore setxattr on internal trusted xattrs"
7022 test_102p() { # LU-4703 setxattr did not check ownership
7023 local testfile=$DIR/$tfile
7025 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.5.56) ] &&
7026 skip "MDS needs to be at least 2.5.56" && return
7030 echo "setfacl as user..."
7031 $RUNAS setfacl -m "u:$RUNAS_ID:rwx" $testfile
7032 [ $? -ne 0 ] || error "setfacl by $RUNAS_ID was allowed on $testfile"
7034 echo "setfattr as user..."
7035 setfacl -m "u:$RUNAS_ID:---" $testfile
7036 $RUNAS setfattr -x system.posix_acl_access $testfile
7037 [ $? -ne 0 ] || error "setfattr by $RUNAS_ID was allowed on $testfile"
7039 run_test 102p "check setxattr(2) correctly fails without permission"
7042 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.6.92) ] &&
7043 skip "MDS needs to be at least 2.6.92" && return
7044 orphan_linkea_check $DIR/$tfile || error "orphan_linkea_check"
7046 run_test 102q "flistxattr should not return trusted.link EAs for orphans"
7049 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.6.93) ] &&
7050 skip "MDS needs to be at least 2.6.93" && return
7051 touch $DIR/$tfile || error "touch"
7052 setfattr -n user.$(basename $tfile) $DIR/$tfile || error "setfattr"
7053 getfattr -n user.$(basename $tfile) $DIR/$tfile || error "getfattr"
7054 rm $DIR/$tfile || error "rm"
7057 mkdir -p $DIR/$tdir || error "mkdir"
7058 setfattr -n user.$(basename $tdir) $DIR/$tdir || error "setfattr dir"
7059 getfattr -n user.$(basename $tdir) $DIR/$tdir || error "getfattr dir"
7060 setfattr -x user.$(basename $tdir) $DIR/$tdir ||
7061 error "$testfile error deleting user.author1"
7062 getfattr -d -m user.$(basename $tdir) 2> /dev/null |
7063 grep "user.$(basename $tdir)" &&
7064 error "$tdir did not delete user.$(basename $tdir)"
7065 rmdir $DIR/$tdir || error "rmdir"
7068 test_mkdir -p $DIR/$tdir || error "make striped dir"
7069 setfattr -n user.$(basename $tdir) $DIR/$tdir || error "setfattr dir"
7070 getfattr -n user.$(basename $tdir) $DIR/$tdir || error "getfattr dir"
7071 setfattr -x user.$(basename $tdir) $DIR/$tdir ||
7072 error "$testfile error deleting user.author1"
7073 getfattr -d -m user.$(basename $tdir) 2> /dev/null |
7074 grep "user.$(basename $tdir)" &&
7075 error "$tdir did not delete user.$(basename $tdir)"
7076 rmdir $DIR/$tdir || error "rm striped dir"
7078 run_test 102r "set EAs with empty values"
7082 $LUSTRE/tests/acl/run $LUSTRE/tests/acl/$1.test
7087 [ "$UID" != 0 ] && skip_env "must run as root" && return
7088 [ -z "$(lctl get_param -n mdc.*-mdc-*.connect_flags | grep acl)" ] &&
7089 skip "must have acl enabled" && return
7090 [ -z "$(which setfacl 2>/dev/null)" ] &&
7091 skip_env "could not find setfacl" && return
7092 $GSS && skip "could not run under gss" && return
7094 gpasswd -a daemon bin # LU-5641
7095 do_facet $SINGLEMDS gpasswd -a daemon bin # LU-5641
7097 declare -a identity_old
7099 for num in $(seq $MDSCOUNT); do
7100 switch_identity $num true || identity_old[$num]=$?
7107 echo "performing cp ..."
7108 run_acl_subtest cp || error "run_acl_subtest cp failed"
7109 echo "performing getfacl-noacl..."
7110 run_acl_subtest getfacl-noacl || error "getfacl-noacl test failed"
7111 echo "performing misc..."
7112 run_acl_subtest misc || error "misc test failed"
7113 echo "performing permissions..."
7114 run_acl_subtest permissions || error "permissions failed"
7115 echo "performing setfacl..."
7116 run_acl_subtest setfacl || error "setfacl test failed"
7118 # inheritance test got from HP
7119 echo "performing inheritance..."
7120 cp $LUSTRE/tests/acl/make-tree . || error "cannot copy make-tree"
7121 chmod +x make-tree || error "chmod +x failed"
7122 run_acl_subtest inheritance || error "inheritance test failed"
7125 echo "LU-974 ignore umask when acl is enabled..."
7126 run_acl_subtest 974 || error "LU-974 umask test failed"
7127 if [ $MDSCOUNT -ge 2 ]; then
7128 run_acl_subtest 974_remote ||
7129 error "LU-974 umask test failed under remote dir"
7132 echo "LU-2561 newly created file is same size as directory..."
7133 if [ $(facet_fstype $SINGLEMDS) != "zfs" ]; then
7134 run_acl_subtest 2561 || error "LU-2561 test failed"
7136 run_acl_subtest 2561_zfs || error "LU-2561 zfs test failed"
7139 run_acl_subtest 4924 || error "LU-4924 test failed"
7144 for num in $(seq $MDSCOUNT); do
7145 if [ "${identity_old[$num]}" = 1 ]; then
7146 switch_identity $num false || identity_old[$num]=$?
7150 run_test 103a "acl test ========================================="
7154 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
7155 local mountopts=$MDS_MOUNT_OPTS
7157 if [[ "$MDS_MOUNT_OPTS" =~ "noacl" ]]; then
7161 stop $SINGLEMDS || error "failed to stop MDT."
7163 if [ -z "$MDS_MOUNT_OPTS" ]; then
7164 MDS_MOUNT_OPTS="-o noacl"
7166 MDS_MOUNT_OPTS="${MDS_MOUNT_OPTS},noacl"
7168 start $SINGLEMDS $MDT_DEV $MDS_MOUNT_OPTS ||
7169 error "failed to start MDT."
7170 MDS_MOUNT_OPTS=$mountopts
7174 setfacl -m u:bin:rw $DIR/$tfile && error "setfacl should fail"
7178 stop $SINGLEMDS || error "failed to stop MDT."
7180 start $SINGLEMDS $MDT_DEV $MDS_MOUNT_OPTS ||
7181 error "failed to start MDT."
7186 run_test 103b "MDS mount option 'noacl'"
7190 cp -rp $DIR/$tdir $DIR/$tdir.bak
7192 [ -n "$(getfattr -d -m. $DIR/$tdir | grep posix_acl_default)" ] &&
7193 error "$DIR/$tdir shouldn't contain default ACL"
7194 [ -n "$(getfattr -d -m. $DIR/$tdir.bak | grep posix_acl_default)" ] &&
7195 error "$DIR/$tdir.bak shouldn't contain default ACL"
7198 run_test 103c "'cp -rp' won't set empty acl"
7201 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7203 lfs df || error "lfs df failed"
7204 lfs df -ih || error "lfs df -ih failed"
7205 lfs df -h $DIR || error "lfs df -h $DIR failed"
7206 lfs df -i $DIR || error "lfs df -i $DIR failed"
7207 lfs df $DIR/$tfile || error "lfs df $DIR/$tfile failed"
7208 lfs df -ih $DIR/$tfile || error "lfs df -ih $DIR/$tfile failed"
7210 local OSC=$(lctl dl | grep OST0000-osc-[^M] | awk '{ print $4 }')
7211 lctl --device %$OSC deactivate
7212 lfs df || error "lfs df with deactivated OSC failed"
7213 lctl --device %$OSC activate
7214 # wait the osc back to normal
7215 wait_osc_import_state client ost FULL
7217 lfs df || error "lfs df with reactivated OSC failed"
7220 run_test 104a "lfs df [-ih] [path] test ========================="
7223 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7224 [ $RUNAS_ID -eq $UID ] &&
7225 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
7227 denied_cnt=$(($($RUNAS $LFS check servers 2>&1 |
7228 grep "Permission denied" | wc -l)))
7229 if [ $denied_cnt -ne 0 ]; then
7230 error "lfs check servers test failed"
7233 run_test 104b "$RUNAS lfs check servers test ===================="
7236 # doesn't work on 2.4 kernels
7238 if $(flock_is_enabled); then
7239 flocks_test 1 on -f $DIR/$tfile || error "fail flock on"
7241 flocks_test 1 off -f $DIR/$tfile || error "fail flock off"
7245 run_test 105a "flock when mounted without -o flock test ========"
7249 if $(flock_is_enabled); then
7250 flocks_test 1 on -c $DIR/$tfile || error "fail flock on"
7252 flocks_test 1 off -c $DIR/$tfile || error "fail flock off"
7256 run_test 105b "fcntl when mounted without -o flock test ========"
7260 if $(flock_is_enabled); then
7261 flocks_test 1 on -l $DIR/$tfile || error "fail flock on"
7263 flocks_test 1 off -l $DIR/$tfile || error "fail flock off"
7267 run_test 105c "lockf when mounted without -o flock test ========"
7269 test_105d() { # bug 15924
7270 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7271 test_mkdir -p $DIR/$tdir
7272 flock_is_enabled || { skip "mount w/o flock enabled" && return; }
7273 #define OBD_FAIL_LDLM_CP_CB_WAIT 0x315
7274 $LCTL set_param fail_loc=0x80000315
7275 flocks_test 2 $DIR/$tdir
7277 run_test 105d "flock race (should not freeze) ========"
7279 test_105e() { # bug 22660 && 22040
7280 flock_is_enabled || { skip "mount w/o flock enabled" && return; }
7282 flocks_test 3 $DIR/$tfile
7284 run_test 105e "Two conflicting flocks from same process ======="
7286 test_106() { #bug 10921
7287 test_mkdir -p $DIR/$tdir
7288 $DIR/$tdir && error "exec $DIR/$tdir succeeded"
7289 chmod 777 $DIR/$tdir || error "chmod $DIR/$tdir failed"
7291 run_test 106 "attempt exec of dir followed by chown of that dir"
7294 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7301 local save_pattern=$(sysctl -n kernel.core_pattern)
7302 local save_uses_pid=$(sysctl -n kernel.core_uses_pid)
7303 sysctl -w kernel.core_pattern=$file
7304 sysctl -w kernel.core_uses_pid=0
7312 kill -s 11 $SLEEPPID
7314 if [ -e $file ]; then
7315 size=`stat -c%s $file`
7316 [ $size -eq 0 ] && error "Fail to create core file $file"
7318 error "Fail to create core file $file"
7321 sysctl -w kernel.core_pattern=$save_pattern
7322 sysctl -w kernel.core_uses_pid=$save_uses_pid
7325 run_test 107 "Coredump on SIG"
7328 test_mkdir -p $DIR/$tdir
7329 test_mkdir $DIR/$tdir/$(str_repeat 'a' 255) ||
7330 error "mkdir with 255 char failed"
7331 test_mkdir $DIR/$tdir/$(str_repeat 'b' 256) &&
7332 error "mkdir with 256 char should fail, but did not"
7333 touch $DIR/$tdir/$(str_repeat 'x' 255) ||
7334 error "create with 255 char failed"
7335 touch $DIR/$tdir/$(str_repeat 'y' 256) &&
7336 error "create with 256 char should fail, but did not"
7341 run_test 110 "filename length checking"
7344 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7345 OSTIO_pre=$(ps -e | grep ll_ost_io | awk '{ print $4 }'| sort -n |
7346 tail -1 | cut -c11-20)
7347 [ -z "$OSTIO_pre" ] && skip "no OSS threads" && return
7348 echo "Starting with $OSTIO_pre threads"
7351 NUMFREE=$(df -i -P $DIR | tail -n 1 | awk '{ print $4 }')
7352 [[ $NUMFREE -lt $NUMTEST ]] && NUMTEST=$(($NUMFREE - 1000))
7353 echo "$NUMTEST creates/unlinks"
7354 test_mkdir -p $DIR/$tdir
7355 createmany -o $DIR/$tdir/$tfile $NUMTEST
7356 unlinkmany $DIR/$tdir/$tfile $NUMTEST
7358 OSTIO_post=$(ps -e | grep ll_ost_io | awk '{ print $4 }' | sort -n |
7359 tail -1 | cut -c11-20)
7361 # don't return an error
7362 [ $OSTIO_post == $OSTIO_pre ] && echo \
7363 "WARNING: No new ll_ost_io threads were created ($OSTIO_pre)" &&
7364 echo "This may be fine, depending on what ran before this test" &&
7365 echo "and how fast this system is." && return
7367 echo "Started with $OSTIO_pre threads, ended with $OSTIO_post"
7369 run_test 115 "verify dynamic thread creation===================="
7372 wait_delete_completed
7373 AVAIL=($(lctl get_param -n osc.*[oO][sS][cC]-[^M]*.kbytesavail))
7374 echo OST kbytes available: ${AVAIL[@]}
7375 MAXI=0; MAXV=${AVAIL[0]}
7376 MINI=0; MINV=${AVAIL[0]}
7377 for ((i = 0; i < ${#AVAIL[@]}; i++)); do
7378 #echo OST $i: ${AVAIL[i]}kb
7379 if [[ ${AVAIL[i]} -gt $MAXV ]]; then
7380 MAXV=${AVAIL[i]}; MAXI=$i
7382 if [[ ${AVAIL[i]} -lt $MINV ]]; then
7383 MINV=${AVAIL[i]}; MINI=$i
7386 echo Min free space: OST $MINI: $MINV
7387 echo Max free space: OST $MAXI: $MAXV
7390 test_116a() { # was previously test_116()
7391 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7392 remote_mds_nodsh && skip "remote MDS with nodsh" && return
7394 [[ $OSTCOUNT -lt 2 ]] && skip_env "$OSTCOUNT < 2 OSTs" && return
7396 echo -n "Free space priority "
7397 do_facet $SINGLEMDS lctl get_param -n lo*.*-mdtlov.qos_prio_free |
7402 [ $MINV -eq 0 ] && skip "no free space in OST$MINI, skip" && return
7403 [ $MINV -gt 10000000 ] && skip "too much free space in OST$MINI, skip" \
7405 trap simple_cleanup_common EXIT
7408 # Check if we need to generate uneven OSTs
7409 test_mkdir -p $DIR/$tdir/OST${MINI}
7410 local FILL=$(($MINV / 4))
7411 local DIFF=$(($MAXV - $MINV))
7412 local DIFF2=$(($DIFF * 100 / $MINV))
7414 local threshold=$(do_facet $SINGLEMDS \
7415 lctl get_param -n *.*MDT0000-mdtlov.qos_threshold_rr | head -n1)
7416 threshold=${threshold%%%}
7417 echo -n "Check for uneven OSTs: "
7418 echo -n "diff=${DIFF}KB (${DIFF2}%) must be > ${threshold}% ..."
7420 if [[ $DIFF2 -gt $threshold ]]; then
7422 echo "Don't need to fill OST$MINI"
7424 # generate uneven OSTs. Write 2% over the QOS threshold value
7426 DIFF=$(($threshold - $DIFF2 + 2))
7427 DIFF2=$(( ($MINV * $DIFF)/100 ))
7428 echo "Fill ${DIFF}% remaining space in OST${MINI} with ${DIFF2}KB"
7429 $SETSTRIPE -i $MINI -c 1 $DIR/$tdir/OST${MINI} ||
7430 error "setstripe failed"
7431 DIFF=$(($DIFF2 / 2048))
7433 while [ $i -lt $DIFF ]; do
7435 dd if=/dev/zero of=$DIR/$tdir/OST${MINI}/$tfile-$i \
7436 bs=2M count=1 2>/dev/null
7445 DIFF=$(($MAXV - $MINV))
7446 DIFF2=$(($DIFF * 100 / $MINV))
7447 echo -n "diff=${DIFF}=${DIFF2}% must be > ${threshold}% for QOS mode..."
7448 if [[ $DIFF2 -gt $threshold ]]; then
7451 echo "failed - QOS mode won't be used"
7452 skip "QOS imbalance criteria not met"
7453 simple_cleanup_common
7457 MINI1=$MINI; MINV1=$MINV
7458 MAXI1=$MAXI; MAXV1=$MAXV
7460 # now fill using QOS
7461 $SETSTRIPE -c 1 $DIR/$tdir
7462 FILL=$(($FILL / 200))
7463 if [ $FILL -gt 600 ]; then
7466 echo "writing $FILL files to QOS-assigned OSTs"
7468 while [ $i -lt $FILL ]; do
7470 dd if=/dev/zero of=$DIR/$tdir/$tfile-$i bs=200k \
7474 echo "wrote $i 200k files"
7478 echo "Note: free space may not be updated, so measurements might be off"
7480 DIFF2=$(($MAXV - $MINV))
7481 echo "free space delta: orig $DIFF final $DIFF2"
7482 [ $DIFF2 -gt $DIFF ] && echo "delta got worse!"
7483 DIFF=$(($MINV1 - ${AVAIL[$MINI1]}))
7484 echo "Wrote ${DIFF}KB to smaller OST $MINI1"
7485 DIFF2=$(($MAXV1 - ${AVAIL[$MAXI1]}))
7486 echo "Wrote ${DIFF2}KB to larger OST $MAXI1"
7487 FILL=$(($DIFF2 * 100 / $DIFF - 100))
7489 echo "Wrote ${FILL}% more data to larger OST $MAXI1"
7491 # Figure out which files were written where
7492 UUID=$(lctl get_param -n lov.${FSNAME}-clilov-*.target_obd |
7493 awk '/'$MINI1': / {print $2; exit}')
7495 MINC=$($GETSTRIPE --ost $UUID $DIR/$tdir | grep $DIR | wc -l)
7496 echo "$MINC files created on smaller OST $MINI1"
7497 UUID=$(lctl get_param -n lov.${FSNAME}-clilov-*.target_obd |
7498 awk '/'$MAXI1': / {print $2; exit}')
7500 MAXC=$($GETSTRIPE --ost $UUID $DIR/$tdir | grep $DIR | wc -l)
7501 echo "$MAXC files created on larger OST $MAXI1"
7502 FILL=$(($MAXC * 100 / $MINC - 100))
7503 [[ $MINC -gt 0 ]] &&
7504 echo "Wrote ${FILL}% more files to larger OST $MAXI1"
7505 [[ $MAXC -gt $MINC ]] ||
7506 error_ignore LU-9 "stripe QOS didn't balance free space"
7507 simple_cleanup_common
7509 run_test 116a "stripe QOS: free space balance ==================="
7511 test_116b() { # LU-2093
7512 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7513 remote_mds_nodsh && skip "remote MDS with nodsh" && return
7515 #define OBD_FAIL_MDS_OSC_CREATE_FAIL 0x147
7516 local old_rr=$(do_facet $SINGLEMDS lctl get_param -n \
7517 lo*.$FSNAME-MDT0000-mdtlov.qos_threshold_rr | head -1)
7518 [ -z "$old_rr" ] && skip "no QOS" && return 0
7519 do_facet $SINGLEMDS lctl set_param \
7520 lo*.$FSNAME-MDT0000-mdtlov.qos_threshold_rr=0
7522 do_facet $SINGLEMDS lctl set_param fail_loc=0x147
7523 createmany -o $DIR/$tdir/f- 20 || error "can't create"
7524 do_facet $SINGLEMDS lctl set_param fail_loc=0
7526 do_facet $SINGLEMDS lctl set_param \
7527 lo*.$FSNAME-MDT0000-mdtlov.qos_threshold_rr=$old_rr
7529 run_test 116b "QoS shouldn't LBUG if not enough OSTs found on the 2nd pass"
7531 test_117() # bug 10891
7533 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7534 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1
7535 #define OBD_FAIL_OST_SETATTR_CREDITS 0x21e
7536 lctl set_param fail_loc=0x21e
7537 > $DIR/$tfile || error "truncate failed"
7538 lctl set_param fail_loc=0
7539 echo "Truncate succeeded."
7542 run_test 117 "verify osd extend =========="
7544 NO_SLOW_RESENDCOUNT=4
7545 export OLD_RESENDCOUNT=""
7546 set_resend_count () {
7547 local PROC_RESENDCOUNT="osc.${FSNAME}-OST*-osc-*.resend_count"
7548 OLD_RESENDCOUNT=$(lctl get_param -n $PROC_RESENDCOUNT | head -n1)
7549 lctl set_param -n $PROC_RESENDCOUNT $1
7550 echo resend_count is set to $(lctl get_param -n $PROC_RESENDCOUNT)
7553 # for reduce test_118* time (b=14842)
7554 [ "$SLOW" = "no" ] && set_resend_count $NO_SLOW_RESENDCOUNT
7556 # Reset async IO behavior after error case
7558 FILE=$DIR/reset_async
7560 # Ensure all OSCs are cleared
7561 $SETSTRIPE -c -1 $FILE
7562 dd if=/dev/zero of=$FILE bs=64k count=$OSTCOUNT
7567 test_118a() #bug 11710
7569 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7572 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
7573 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
7574 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
7576 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
7577 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
7582 run_test 118a "verify O_SYNC works =========="
7586 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7587 remote_ost_nodsh && skip "remote OST with nodsh" && return
7591 #define OBD_FAIL_OST_ENOENT 0x217
7592 set_nodes_failloc "$(osts_nodes)" 0x217
7593 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
7595 set_nodes_failloc "$(osts_nodes)" 0
7596 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
7597 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
7600 if [[ $RC -eq 0 ]]; then
7601 error "Must return error due to dropped pages, rc=$RC"
7605 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
7606 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
7610 echo "Dirty pages not leaked on ENOENT"
7612 # Due to the above error the OSC will issue all RPCs syncronously
7613 # until a subsequent RPC completes successfully without error.
7614 $MULTIOP $DIR/$tfile Ow4096yc
7619 run_test 118b "Reclaim dirty pages on fatal error =========="
7623 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7625 # for 118c, restore the original resend count, LU-1940
7626 [ "$SLOW" = "no" ] && [ -n "$OLD_RESENDCOUNT" ] &&
7627 set_resend_count $OLD_RESENDCOUNT
7628 remote_ost_nodsh && skip "remote OST with nodsh" && return
7632 #define OBD_FAIL_OST_EROFS 0x216
7633 set_nodes_failloc "$(osts_nodes)" 0x216
7635 # multiop should block due to fsync until pages are written
7636 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
7640 if [[ `ps h -o comm -p $MULTIPID` != "multiop" ]]; then
7641 error "Multiop failed to block on fsync, pid=$MULTIPID"
7644 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
7646 if [[ $WRITEBACK -eq 0 ]]; then
7647 error "No page in writeback, writeback=$WRITEBACK"
7650 set_nodes_failloc "$(osts_nodes)" 0
7653 if [[ $RC -ne 0 ]]; then
7654 error "Multiop fsync failed, rc=$RC"
7657 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
7658 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
7660 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
7661 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
7665 echo "Dirty pages flushed via fsync on EROFS"
7668 run_test 118c "Fsync blocks on EROFS until dirty pages are flushed =========="
7670 # continue to use small resend count to reduce test_118* time (b=14842)
7671 [ "$SLOW" = "no" ] && set_resend_count $NO_SLOW_RESENDCOUNT
7675 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7676 remote_ost_nodsh && skip "remote OST with nodsh" && return
7680 #define OBD_FAIL_OST_BRW_PAUSE_BULK
7681 set_nodes_failloc "$(osts_nodes)" 0x214
7682 # multiop should block due to fsync until pages are written
7683 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
7687 if [[ `ps h -o comm -p $MULTIPID` != "multiop" ]]; then
7688 error "Multiop failed to block on fsync, pid=$MULTIPID"
7691 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
7693 if [[ $WRITEBACK -eq 0 ]]; then
7694 error "No page in writeback, writeback=$WRITEBACK"
7697 wait $MULTIPID || error "Multiop fsync failed, rc=$?"
7698 set_nodes_failloc "$(osts_nodes)" 0
7700 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
7701 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
7703 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
7704 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
7708 echo "Dirty pages gaurenteed flushed via fsync"
7711 run_test 118d "Fsync validation inject a delay of the bulk =========="
7714 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7717 #define OBD_FAIL_OSC_BRW_PREP_REQ2 0x40a
7718 lctl set_param fail_loc=0x8000040a
7720 # Should simulate EINVAL error which is fatal
7721 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
7723 if [[ $RC -eq 0 ]]; then
7724 error "Must return error due to dropped pages, rc=$RC"
7727 lctl set_param fail_loc=0x0
7729 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
7730 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
7731 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
7733 if [[ $LOCKED -ne 0 ]]; then
7734 error "Locked pages remain in cache, locked=$LOCKED"
7737 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
7738 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
7742 echo "No pages locked after fsync"
7747 run_test 118f "Simulate unrecoverable OSC side error =========="
7750 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7753 #define OBD_FAIL_OSC_BRW_PREP_REQ 0x406
7754 lctl set_param fail_loc=0x406
7756 # simulate local -ENOMEM
7757 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
7760 lctl set_param fail_loc=0
7761 if [[ $RC -eq 0 ]]; then
7762 error "Must return error due to dropped pages, rc=$RC"
7765 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
7766 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
7767 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
7769 if [[ $LOCKED -ne 0 ]]; then
7770 error "Locked pages remain in cache, locked=$LOCKED"
7773 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
7774 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
7778 echo "No pages locked after fsync"
7783 run_test 118g "Don't stay in wait if we got local -ENOMEM =========="
7786 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7787 remote_ost_nodsh && skip "remote OST with nodsh" && return
7791 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
7792 set_nodes_failloc "$(osts_nodes)" 0x20e
7793 # Should simulate ENOMEM error which is recoverable and should be handled by timeout
7794 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
7797 set_nodes_failloc "$(osts_nodes)" 0
7798 if [[ $RC -eq 0 ]]; then
7799 error "Must return error due to dropped pages, rc=$RC"
7802 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
7803 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
7804 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
7806 if [[ $LOCKED -ne 0 ]]; then
7807 error "Locked pages remain in cache, locked=$LOCKED"
7810 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
7811 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
7815 echo "No pages locked after fsync"
7819 run_test 118h "Verify timeout in handling recoverables errors =========="
7821 [ "$SLOW" = "no" ] && [ -n "$OLD_RESENDCOUNT" ] && set_resend_count $OLD_RESENDCOUNT
7824 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7825 remote_ost_nodsh && skip "remote OST with nodsh" && return
7829 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
7830 set_nodes_failloc "$(osts_nodes)" 0x20e
7832 # Should simulate ENOMEM error which is recoverable and should be handled by timeout
7833 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
7836 set_nodes_failloc "$(osts_nodes)" 0
7840 if [[ $RC -ne 0 ]]; then
7841 error "got error, but should be not, rc=$RC"
7844 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
7845 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
7846 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
7847 if [[ $LOCKED -ne 0 ]]; then
7848 error "Locked pages remain in cache, locked=$LOCKED"
7851 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
7852 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
7856 echo "No pages locked after fsync"
7860 run_test 118i "Fix error before timeout in recoverable error =========="
7862 [ "$SLOW" = "no" ] && set_resend_count 4
7865 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7866 remote_ost_nodsh && skip "remote OST with nodsh" && return
7870 #define OBD_FAIL_OST_BRW_WRITE_BULK2 0x220
7871 set_nodes_failloc "$(osts_nodes)" 0x220
7873 # return -EIO from OST
7874 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
7876 set_nodes_failloc "$(osts_nodes)" 0x0
7877 if [[ $RC -eq 0 ]]; then
7878 error "Must return error due to dropped pages, rc=$RC"
7881 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
7882 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
7883 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
7884 if [[ $LOCKED -ne 0 ]]; then
7885 error "Locked pages remain in cache, locked=$LOCKED"
7888 # in recoverable error on OST we want resend and stay until it finished
7889 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
7890 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
7894 echo "No pages locked after fsync"
7898 run_test 118j "Simulate unrecoverable OST side error =========="
7902 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7903 remote_ost_nodsh && skip "remote OSTs with nodsh" && return
7905 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
7906 set_nodes_failloc "$(osts_nodes)" 0x20e
7907 test_mkdir -p $DIR/$tdir
7909 for ((i=0;i<10;i++)); do
7910 (dd if=/dev/zero of=$DIR/$tdir/$tfile-$i bs=1M count=10 || \
7911 error "dd to $DIR/$tdir/$tfile-$i failed" )&
7918 set_nodes_failloc "$(osts_nodes)" 0
7921 run_test 118k "bio alloc -ENOMEM and IO TERM handling ========="
7925 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7927 test_mkdir -p $DIR/$tdir
7928 $MULTIOP $DIR/$tdir Dy || error "fsync dir failed"
7931 run_test 118l "fsync dir ========="
7933 test_118m() # LU-3066
7935 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7936 test_mkdir -p $DIR/$tdir
7937 $MULTIOP $DIR/$tdir DY || error "fdatasync dir failed"
7940 run_test 118m "fdatasync dir ========="
7942 [ "$SLOW" = "no" ] && [ -n "$OLD_RESENDCOUNT" ] && set_resend_count $OLD_RESENDCOUNT
7944 test_119a() # bug 11737
7946 BSIZE=$((512 * 1024))
7947 directio write $DIR/$tfile 0 1 $BSIZE
7948 # We ask to read two blocks, which is more than a file size.
7949 # directio will indicate an error when requested and actual
7950 # sizes aren't equeal (a normal situation in this case) and
7951 # print actual read amount.
7952 NOB=`directio read $DIR/$tfile 0 2 $BSIZE | awk '/error/ {print $6}'`
7953 if [ "$NOB" != "$BSIZE" ]; then
7954 error "read $NOB bytes instead of $BSIZE"
7958 run_test 119a "Short directIO read must return actual read amount"
7960 test_119b() # bug 11737
7962 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping 2-stripe test" && return
7964 $SETSTRIPE -c 2 $DIR/$tfile || error "setstripe failed"
7965 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=1 || error "dd failed"
7967 $MULTIOP $DIR/$tfile oO_RDONLY:O_DIRECT:r$((2048 * 1024)) || \
7968 error "direct read failed"
7971 run_test 119b "Sparse directIO read must return actual read amount"
7973 test_119c() # bug 13099
7976 directio write $DIR/$tfile 3 1 $BSIZE || error "direct write failed"
7977 directio readhole $DIR/$tfile 0 2 $BSIZE || error "reading hole failed"
7980 run_test 119c "Testing for direct read hitting hole"
7982 test_119d() # bug 15950
7984 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7985 MAX_RPCS_IN_FLIGHT=`$LCTL get_param -n osc.*OST0000-osc-[^mM]*.max_rpcs_in_flight`
7986 $LCTL set_param -n osc.*OST0000-osc-[^mM]*.max_rpcs_in_flight 1
7988 $SETSTRIPE $DIR/$tfile -i 0 -c 1 || error "setstripe failed"
7989 $DIRECTIO write $DIR/$tfile 0 1 $BSIZE || error "first directio failed"
7990 #define OBD_FAIL_OSC_DIO_PAUSE 0x40d
7991 lctl set_param fail_loc=0x40d
7992 $DIRECTIO write $DIR/$tfile 1 4 $BSIZE &
7995 cat $DIR/$tfile > /dev/null &
7996 lctl set_param fail_loc=0
7999 log "the DIO writes have completed, now wait for the reads (should not block very long)"
8001 [ -n "`ps h -p $pid_reads -o comm`" ] && \
8002 error "the read rpcs have not completed in 2s"
8004 $LCTL set_param -n osc.*OST0000-osc-[^mM]*.max_rpcs_in_flight $MAX_RPCS_IN_FLIGHT
8006 run_test 119d "The DIO path should try to send a new rpc once one is completed"
8009 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8010 test_mkdir -p $DIR/$tdir
8011 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
8012 skip "no early lock cancel on server" && return 0
8014 lru_resize_disable mdc
8015 lru_resize_disable osc
8016 cancel_lru_locks mdc
8017 # asynchronous object destroy at MDT could cause bl ast to client
8018 cancel_lru_locks osc
8020 stat $DIR/$tdir > /dev/null
8021 can1=$(do_facet $SINGLEMDS \
8022 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8023 awk '/ldlm_cancel/ {print $2}')
8024 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8025 awk '/ldlm_bl_callback/ {print $2}')
8026 test_mkdir -c1 $DIR/$tdir/d1
8027 can2=$(do_facet $SINGLEMDS \
8028 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8029 awk '/ldlm_cancel/ {print $2}')
8030 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8031 awk '/ldlm_bl_callback/ {print $2}')
8032 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
8033 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
8034 lru_resize_enable mdc
8035 lru_resize_enable osc
8037 run_test 120a "Early Lock Cancel: mkdir test"
8040 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8041 test_mkdir $DIR/$tdir
8042 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel)" ] && \
8043 skip "no early lock cancel on server" && return 0
8044 lru_resize_disable mdc
8045 lru_resize_disable osc
8046 cancel_lru_locks mdc
8047 stat $DIR/$tdir > /dev/null
8048 can1=$(do_facet $SINGLEMDS \
8049 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8050 awk '/ldlm_cancel/ {print $2}')
8051 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8052 awk '/ldlm_bl_callback/ {print $2}')
8054 can2=$(do_facet $SINGLEMDS \
8055 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8056 awk '/ldlm_cancel/ {print $2}')
8057 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8058 awk '/ldlm_bl_callback/ {print $2}')
8059 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
8060 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
8061 lru_resize_enable mdc
8062 lru_resize_enable osc
8064 run_test 120b "Early Lock Cancel: create test"
8067 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8068 test_mkdir -c1 $DIR/$tdir
8069 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel)" ] && \
8070 skip "no early lock cancel on server" && return 0
8071 lru_resize_disable mdc
8072 lru_resize_disable osc
8073 test_mkdir -p -c1 $DIR/$tdir/d1
8074 test_mkdir -p -c1 $DIR/$tdir/d2
8075 touch $DIR/$tdir/d1/f1
8076 cancel_lru_locks mdc
8077 stat $DIR/$tdir/d1 $DIR/$tdir/d2 $DIR/$tdir/d1/f1 > /dev/null
8078 can1=$(do_facet $SINGLEMDS \
8079 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8080 awk '/ldlm_cancel/ {print $2}')
8081 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8082 awk '/ldlm_bl_callback/ {print $2}')
8083 ln $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2
8084 can2=$(do_facet $SINGLEMDS \
8085 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8086 awk '/ldlm_cancel/ {print $2}')
8087 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8088 awk '/ldlm_bl_callback/ {print $2}')
8089 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
8090 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
8091 lru_resize_enable mdc
8092 lru_resize_enable osc
8094 run_test 120c "Early Lock Cancel: link test"
8097 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8098 test_mkdir -p -c1 $DIR/$tdir
8099 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel)" ] && \
8100 skip "no early lock cancel on server" && return 0
8101 lru_resize_disable mdc
8102 lru_resize_disable osc
8104 cancel_lru_locks mdc
8105 stat $DIR/$tdir > /dev/null
8106 can1=$(do_facet $SINGLEMDS \
8107 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8108 awk '/ldlm_cancel/ {print $2}')
8109 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8110 awk '/ldlm_bl_callback/ {print $2}')
8111 chmod a+x $DIR/$tdir
8112 can2=$(do_facet $SINGLEMDS \
8113 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8114 awk '/ldlm_cancel/ {print $2}')
8115 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8116 awk '/ldlm_bl_callback/ {print $2}')
8117 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
8118 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
8119 lru_resize_enable mdc
8120 lru_resize_enable osc
8122 run_test 120d "Early Lock Cancel: setattr test"
8125 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8126 test_mkdir -p -c1 $DIR/$tdir
8127 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
8128 skip "no early lock cancel on server" && return 0
8129 lru_resize_disable mdc
8130 lru_resize_disable osc
8131 dd if=/dev/zero of=$DIR/$tdir/f1 count=1
8132 cancel_lru_locks mdc
8133 cancel_lru_locks osc
8134 dd if=$DIR/$tdir/f1 of=/dev/null
8135 stat $DIR/$tdir $DIR/$tdir/f1 > /dev/null
8136 # XXX client can not do early lock cancel of OST lock
8137 # during unlink (LU-4206), so cancel osc lock now.
8138 cancel_lru_locks osc
8139 can1=$(do_facet $SINGLEMDS \
8140 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8141 awk '/ldlm_cancel/ {print $2}')
8142 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8143 awk '/ldlm_bl_callback/ {print $2}')
8144 unlink $DIR/$tdir/f1
8146 can2=$(do_facet $SINGLEMDS \
8147 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8148 awk '/ldlm_cancel/ {print $2}')
8149 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8150 awk '/ldlm_bl_callback/ {print $2}')
8151 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
8152 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
8153 lru_resize_enable mdc
8154 lru_resize_enable osc
8156 run_test 120e "Early Lock Cancel: unlink test"
8159 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8160 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
8161 skip "no early lock cancel on server" && return 0
8162 test_mkdir -p -c1 $DIR/$tdir
8163 lru_resize_disable mdc
8164 lru_resize_disable osc
8165 test_mkdir -p -c1 $DIR/$tdir/d1
8166 test_mkdir -p -c1 $DIR/$tdir/d2
8167 dd if=/dev/zero of=$DIR/$tdir/d1/f1 count=1
8168 dd if=/dev/zero of=$DIR/$tdir/d2/f2 count=1
8169 cancel_lru_locks mdc
8170 cancel_lru_locks osc
8171 dd if=$DIR/$tdir/d1/f1 of=/dev/null
8172 dd if=$DIR/$tdir/d2/f2 of=/dev/null
8173 stat $DIR/$tdir/d1 $DIR/$tdir/d2 $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2 > /dev/null
8174 # XXX client can not do early lock cancel of OST lock
8175 # during rename (LU-4206), so cancel osc lock now.
8176 cancel_lru_locks osc
8177 can1=$(do_facet $SINGLEMDS \
8178 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8179 awk '/ldlm_cancel/ {print $2}')
8180 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8181 awk '/ldlm_bl_callback/ {print $2}')
8182 mrename $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2
8184 can2=$(do_facet $SINGLEMDS \
8185 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8186 awk '/ldlm_cancel/ {print $2}')
8187 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8188 awk '/ldlm_bl_callback/ {print $2}')
8189 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
8190 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
8191 lru_resize_enable mdc
8192 lru_resize_enable osc
8194 run_test 120f "Early Lock Cancel: rename test"
8197 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8198 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
8199 skip "no early lock cancel on server" && return 0
8200 lru_resize_disable mdc
8201 lru_resize_disable osc
8203 echo create $count files
8204 test_mkdir -p $DIR/$tdir
8205 cancel_lru_locks mdc
8206 cancel_lru_locks osc
8209 can0=$(do_facet $SINGLEMDS \
8210 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8211 awk '/ldlm_cancel/ {print $2}')
8212 blk0=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8213 awk '/ldlm_bl_callback/ {print $2}')
8214 createmany -o $DIR/$tdir/f $count
8216 can1=$(do_facet $SINGLEMDS \
8217 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8218 awk '/ldlm_cancel/ {print $2}')
8219 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8220 awk '/ldlm_bl_callback/ {print $2}')
8222 echo total: $((can1-can0)) cancels, $((blk1-blk0)) blockings
8223 echo rm $count files
8226 can2=$(do_facet $SINGLEMDS \
8227 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8228 awk '/ldlm_cancel/ {print $2}')
8229 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8230 awk '/ldlm_bl_callback/ {print $2}')
8232 echo total: $count removes in $((t2-t1))
8233 echo total: $((can2-can1)) cancels, $((blk2-blk1)) blockings
8235 # wait for commitment of removal
8236 lru_resize_enable mdc
8237 lru_resize_enable osc
8239 run_test 120g "Early Lock Cancel: performance test"
8241 test_121() { #bug #10589
8242 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8244 writes=$(LANG=C dd if=/dev/zero of=$DIR/$tfile count=1 2>&1 | awk -F '+' '/out$/ {print $1}')
8245 #define OBD_FAIL_LDLM_CANCEL_RACE 0x310
8246 lctl set_param fail_loc=0x310
8247 cancel_lru_locks osc > /dev/null
8248 reads=$(LANG=C dd if=$DIR/$tfile of=/dev/null 2>&1 | awk -F '+' '/in$/ {print $1}')
8249 lctl set_param fail_loc=0
8250 [[ $reads -eq $writes ]] ||
8251 error "read $reads blocks, must be $writes blocks"
8253 run_test 121 "read cancel race ========="
8255 test_123a() { # was test 123, statahead(bug 11401)
8256 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8258 if [ -z "$(grep "processor.*: 1" /proc/cpuinfo)" ]; then
8259 log "testing on UP system. Performance may be not as good as expected."
8264 test_mkdir -p $DIR/$tdir
8265 NUMFREE=$(df -i -P $DIR | tail -n 1 | awk '{ print $4 }')
8266 [[ $NUMFREE -gt 100000 ]] && NUMFREE=100000 || NUMFREE=$((NUMFREE-1000))
8268 for ((i=100, j=0; i<=$NUMFREE; j=$i, i=$((i * MULT)) )); do
8269 createmany -o $DIR/$tdir/$tfile $j $((i - j))
8271 max=`lctl get_param -n llite.*.statahead_max | head -n 1`
8272 lctl set_param -n llite.*.statahead_max 0
8273 lctl get_param llite.*.statahead_max
8274 cancel_lru_locks mdc
8275 cancel_lru_locks osc
8277 time ls -l $DIR/$tdir | wc -l
8279 delta=$((etime - stime))
8280 log "ls $i files without statahead: $delta sec"
8281 lctl set_param llite.*.statahead_max=$max
8283 swrong=`lctl get_param -n llite.*.statahead_stats | grep "statahead wrong:" | awk '{print $3}'`
8284 lctl get_param -n llite.*.statahead_max | grep '[0-9]'
8285 cancel_lru_locks mdc
8286 cancel_lru_locks osc
8288 time ls -l $DIR/$tdir | wc -l
8290 delta_sa=$((etime - stime))
8291 log "ls $i files with statahead: $delta_sa sec"
8292 lctl get_param -n llite.*.statahead_stats
8293 ewrong=`lctl get_param -n llite.*.statahead_stats | grep "statahead wrong:" | awk '{print $3}'`
8295 [[ $swrong -lt $ewrong ]] &&
8296 log "statahead was stopped, maybe too many locks held!"
8297 [[ $delta -eq 0 || $delta_sa -eq 0 ]] && continue
8299 if [ $((delta_sa * 100)) -gt $((delta * 105)) -a $delta_sa -gt $((delta + 2)) ]; then
8300 max=`lctl get_param -n llite.*.statahead_max | head -n 1`
8301 lctl set_param -n llite.*.statahead_max 0
8302 lctl get_param llite.*.statahead_max
8303 cancel_lru_locks mdc
8304 cancel_lru_locks osc
8306 time ls -l $DIR/$tdir | wc -l
8308 delta=$((etime - stime))
8309 log "ls $i files again without statahead: $delta sec"
8310 lctl set_param llite.*.statahead_max=$max
8311 if [ $((delta_sa * 100)) -gt $((delta * 105)) -a $delta_sa -gt $((delta + 2)) ]; then
8312 if [ $SLOWOK -eq 0 ]; then
8313 error "ls $i files is slower with statahead!"
8315 log "ls $i files is slower with statahead!"
8321 [ $delta -gt 20 ] && break
8322 [ $delta -gt 8 ] && MULT=$((50 / delta))
8323 [ "$SLOW" = "no" -a $delta -gt 5 ] && break
8331 delta=$((etime - stime))
8332 log "rm -r $DIR/$tdir/: $delta seconds"
8334 lctl get_param -n llite.*.statahead_stats
8336 run_test 123a "verify statahead work"
8338 test_123b () { # statahead(bug 15027)
8339 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8340 test_mkdir -p $DIR/$tdir
8341 createmany -o $DIR/$tdir/$tfile-%d 1000
8343 cancel_lru_locks mdc
8344 cancel_lru_locks osc
8346 #define OBD_FAIL_MDC_GETATTR_ENQUEUE 0x803
8347 lctl set_param fail_loc=0x80000803
8348 ls -lR $DIR/$tdir > /dev/null
8350 lctl set_param fail_loc=0x0
8351 lctl get_param -n llite.*.statahead_stats
8356 run_test 123b "not panic with network error in statahead enqueue (bug 15027)"
8359 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8360 [ -z "$($LCTL get_param -n mdc.*.connect_flags | grep lru_resize)" ] &&
8361 skip "no lru resize on server" && return 0
8363 test_mkdir -p $DIR/$tdir || error "failed to create $DIR/$tdir"
8365 log "create $NR files at $DIR/$tdir"
8366 createmany -o $DIR/$tdir/f $NR ||
8367 error "failed to create $NR files in $DIR/$tdir"
8369 cancel_lru_locks mdc
8370 ls -l $DIR/$tdir > /dev/null
8374 for VALUE in $($LCTL get_param ldlm.namespaces.*mdc-*.lru_size); do
8375 local PARAM=$(echo ${VALUE[0]} | cut -d "=" -f1)
8376 LRU_SIZE=$($LCTL get_param -n $PARAM)
8377 if [[ $LRU_SIZE -gt $(default_lru_size) ]]; then
8378 NSDIR=$(echo $PARAM | cut -d "." -f1-3)
8380 log "NS=$(basename $NSDIR)"
8385 if [[ -z "$NSDIR" || $LRU_SIZE -lt $(default_lru_size) ]]; then
8386 skip "Not enough cached locks created!"
8393 # We know that lru resize allows one client to hold $LIMIT locks
8394 # for 10h. After that locks begin to be killed by client.
8396 local LIMIT=$($LCTL get_param -n $NSDIR.pool.limit)
8398 if [ $LIMIT -lt $LRU_SIZE ]; then
8399 skip "Limit is too small $LIMIT"
8403 # Make LVF so higher that sleeping for $SLEEP is enough to _start_
8404 # killing locks. Some time was spent for creating locks. This means
8405 # that up to the moment of sleep finish we must have killed some of
8406 # them (10-100 locks). This depends on how fast ther were created.
8407 # Many of them were touched in almost the same moment and thus will
8408 # be killed in groups.
8409 local LVF=$(($MAX_HRS * 60 * 60 / $SLEEP * $LIMIT / $LRU_SIZE))
8411 # Use $LRU_SIZE_B here to take into account real number of locks
8412 # created in the case of CMD, LRU_SIZE_B != $NR in most of cases
8413 local LRU_SIZE_B=$LRU_SIZE
8415 local OLD_LVF=$($LCTL get_param -n $NSDIR.pool.lock_volume_factor)
8416 log "OLD_LVF=$OLD_LVF"
8417 $LCTL set_param -n $NSDIR.pool.lock_volume_factor $LVF
8419 # Let's make sure that we really have some margin. Client checks
8420 # cached locks every 10 sec.
8422 log "Sleep ${SLEEP} sec"
8424 while ((SEC<$SLEEP)); do
8428 LRU_SIZE=$($LCTL get_param -n $NSDIR/lru_size)
8432 $LCTL set_param -n $NSDIR.pool.lock_volume_factor $OLD_LVF
8433 local LRU_SIZE_A=$($LCTL get_param -n $NSDIR.lru_size)
8435 [[ $LRU_SIZE_B -gt $LRU_SIZE_A ]] || {
8436 error "No locks dropped in ${SLEEP}s. LRU size: $LRU_SIZE_A"
8437 unlinkmany $DIR/$tdir/f $NR
8441 log "Dropped "$((LRU_SIZE_B-LRU_SIZE_A))" locks in ${SLEEP}s"
8442 log "unlink $NR files at $DIR/$tdir"
8443 unlinkmany $DIR/$tdir/f $NR
8445 run_test 124a "lru resize ======================================="
8447 get_max_pool_limit()
8449 local limit=$($LCTL get_param \
8450 -n ldlm.namespaces.*-MDT0000-mdc-*.pool.limit)
8453 if [[ $l -gt $max ]]; then
8461 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8462 [ -z "$($LCTL get_param -n mdc.*.connect_flags | grep lru_resize)" ] &&
8463 skip "no lru resize on server" && return 0
8465 LIMIT=$(get_max_pool_limit)
8467 NR=$(($(default_lru_size)*20))
8468 if [[ $NR -gt $LIMIT ]]; then
8469 log "Limit lock number by $LIMIT locks"
8472 lru_resize_disable mdc
8473 test_mkdir -p $DIR/$tdir/disable_lru_resize ||
8474 error "failed to create $DIR/$tdir/disable_lru_resize"
8476 createmany -o $DIR/$tdir/disable_lru_resize/f $NR
8477 log "doing ls -la $DIR/$tdir/disable_lru_resize 3 times"
8478 cancel_lru_locks mdc
8481 ls -la $DIR/$tdir/disable_lru_resize > /dev/null &
8484 ls -la $DIR/$tdir/disable_lru_resize > /dev/null &
8487 ls -la $DIR/$tdir/disable_lru_resize > /dev/null &
8491 nolruresize_delta=$((etime-stime))
8492 log "ls -la time: $nolruresize_delta seconds"
8493 log "lru_size = $(lctl get_param -n ldlm.namespaces.*mdc*.lru_size)"
8494 unlinkmany $DIR/$tdir/disable_lru_resize/f $NR
8496 lru_resize_enable mdc
8497 test_mkdir -p $DIR/$tdir/enable_lru_resize ||
8498 error "failed to create $DIR/$tdir/enable_lru_resize"
8500 createmany -o $DIR/$tdir/enable_lru_resize/f $NR
8501 log "doing ls -la $DIR/$tdir/enable_lru_resize 3 times"
8502 cancel_lru_locks mdc
8505 ls -la $DIR/$tdir/enable_lru_resize > /dev/null &
8508 ls -la $DIR/$tdir/enable_lru_resize > /dev/null &
8511 ls -la $DIR/$tdir/enable_lru_resize > /dev/null &
8515 lruresize_delta=$((etime-stime))
8516 log "ls -la time: $lruresize_delta seconds"
8517 log "lru_size = $(lctl get_param -n ldlm.namespaces.*mdc*.lru_size)"
8519 if [ $lruresize_delta -gt $nolruresize_delta ]; then
8520 log "ls -la is $(((lruresize_delta - $nolruresize_delta) * 100 / $nolruresize_delta))% slower with lru resize enabled"
8521 elif [ $nolruresize_delta -gt $lruresize_delta ]; then
8522 log "ls -la is $(((nolruresize_delta - $lruresize_delta) * 100 / $nolruresize_delta))% faster with lru resize enabled"
8524 log "lru resize performs the same with no lru resize"
8526 unlinkmany $DIR/$tdir/enable_lru_resize/f $NR
8528 run_test 124b "lru resize (performance test) ======================="
8531 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8532 [ -z "$($LCTL get_param -n mdc.*.connect_flags | grep lru_resize)" ] &&
8533 skip "no lru resize on server" && return 0
8535 # cache ununsed locks on client
8537 cancel_lru_locks mdc
8538 test_mkdir -p $DIR/$tdir || error "failed to create $DIR/$tdir"
8539 createmany -o $DIR/$tdir/f $nr ||
8540 error "failed to create $nr files in $DIR/$tdir"
8541 ls -l $DIR/$tdir > /dev/null
8543 local nsdir="ldlm.namespaces.*-MDT0000-mdc-*"
8544 local unused=$($LCTL get_param -n $nsdir.lock_unused_count)
8545 local max_age=$($LCTL get_param -n $nsdir.lru_max_age)
8546 local recalc_p=$($LCTL get_param -n $nsdir.pool.recalc_period)
8547 echo "unused=$unused, max_age=$max_age, recalc_p=$recalc_p"
8549 # set lru_max_age to 1 sec
8550 $LCTL set_param $nsdir.lru_max_age=1000 # jiffies
8551 echo "sleep $((recalc_p * 2)) seconds..."
8552 sleep $((recalc_p * 2))
8554 local remaining=$($LCTL get_param -n $nsdir.lock_unused_count)
8555 # restore lru_max_age
8556 $LCTL set_param -n $nsdir.lru_max_age $max_age
8557 [ $remaining -eq 0 ] || error "$remaining locks are not canceled"
8558 unlinkmany $DIR/$tdir/f $nr
8560 run_test 124c "LRUR cancel very aged locks"
8562 test_125() { # 13358
8563 [ -z "$(lctl get_param -n llite.*.client_type | grep local)" ] && skip "must run as local client" && return
8564 [ -z "$(lctl get_param -n mdc.*-mdc-*.connect_flags | grep acl)" ] && skip "must have acl enabled" && return
8565 [ -z "$(which setfacl)" ] && skip "must have setfacl tool" && return
8566 test_mkdir -p $DIR/d125 || error "mkdir failed"
8567 $SETSTRIPE -S 65536 -c -1 $DIR/d125 || error "setstripe failed"
8568 setfacl -R -m u:bin:rwx $DIR/d125 || error "setfacl $DIR/d125 failed"
8569 ls -ld $DIR/d125 || error "cannot access $DIR/d125"
8571 run_test 125 "don't return EPROTO when a dir has a non-default striping and ACLs"
8573 test_126() { # bug 12829/13455
8574 [ -z "$(lctl get_param -n llite.*.client_type | grep local)" ] && skip "must run as local client" && return
8575 [ "$UID" != 0 ] && skip_env "skipping $TESTNAME (must run as root)" && return
8576 $GSS && skip "must run as gss disabled" && return
8578 $RUNAS -u 0 -g 1 touch $DIR/$tfile || error "touch failed"
8579 gid=`ls -n $DIR/$tfile | awk '{print $4}'`
8581 [ $gid -eq "1" ] || error "gid is set to" $gid "instead of 1"
8583 run_test 126 "check that the fsgid provided by the client is taken into account"
8585 test_127a() { # bug 15521
8586 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8587 $SETSTRIPE -i 0 -c 1 $DIR/$tfile || error "setstripe failed"
8588 $LCTL set_param osc.*.stats=0
8589 FSIZE=$((2048 * 1024))
8590 dd if=/dev/zero of=$DIR/$tfile bs=$FSIZE count=1
8591 cancel_lru_locks osc
8592 dd if=$DIR/$tfile of=/dev/null bs=$FSIZE
8594 $LCTL get_param osc.*0000-osc-*.stats | grep samples > $DIR/${tfile}.tmp
8595 while read NAME COUNT SAMP UNIT MIN MAX SUM SUMSQ; do
8596 echo "got $COUNT $NAME"
8597 [ ! $MIN ] && error "Missing min value for $NAME proc entry"
8598 eval $NAME=$COUNT || error "Wrong proc format"
8601 read_bytes|write_bytes)
8602 [ $MIN -lt 4096 ] && error "min is too small: $MIN"
8603 [ $MIN -gt $FSIZE ] && error "min is too big: $MIN"
8604 [ $MAX -lt 4096 ] && error "max is too small: $MAX"
8605 [ $MAX -gt $FSIZE ] && error "max is too big: $MAX"
8606 [ $SUM -ne $FSIZE ] && error "sum is wrong: $SUM"
8607 [ $SUMSQ -lt $(((FSIZE /4096) * (4096 * 4096))) ] &&
8608 error "sumsquare is too small: $SUMSQ"
8609 [ $SUMSQ -gt $((FSIZE * FSIZE)) ] &&
8610 error "sumsquare is too big: $SUMSQ"
8614 done < $DIR/${tfile}.tmp
8616 #check that we actually got some stats
8617 [ "$read_bytes" ] || error "Missing read_bytes stats"
8618 [ "$write_bytes" ] || error "Missing write_bytes stats"
8619 [ "$read_bytes" != 0 ] || error "no read done"
8620 [ "$write_bytes" != 0 ] || error "no write done"
8622 run_test 127a "verify the client stats are sane"
8624 test_127b() { # bug LU-333
8625 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8626 $LCTL set_param llite.*.stats=0
8627 FSIZE=65536 # sized fixed to match PAGE_SIZE for most clients
8628 # perform 2 reads and writes so MAX is different from SUM.
8629 dd if=/dev/zero of=$DIR/$tfile bs=$FSIZE count=1
8630 dd if=/dev/zero of=$DIR/$tfile bs=$FSIZE count=1
8631 cancel_lru_locks osc
8632 dd if=$DIR/$tfile of=/dev/null bs=$FSIZE count=1
8633 dd if=$DIR/$tfile of=/dev/null bs=$FSIZE count=1
8635 $LCTL get_param llite.*.stats | grep samples > $TMP/${tfile}.tmp
8636 while read NAME COUNT SAMP UNIT MIN MAX SUM SUMSQ; do
8637 echo "got $COUNT $NAME"
8638 eval $NAME=$COUNT || error "Wrong proc format"
8642 [ $COUNT -ne 2 ] && error "count is not 2: $COUNT"
8643 [ $MIN -ne $FSIZE ] && error "min is not $FSIZE: $MIN"
8644 [ $MAX -ne $FSIZE ] && error "max is incorrect: $MAX"
8645 [ $SUM -ne $((FSIZE * 2)) ] && error "sum is wrong: $SUM"
8648 [ $COUNT -ne 2 ] && error "count is not 2: $COUNT"
8649 [ $MIN -ne $FSIZE ] && error "min is not $FSIZE: $MIN"
8650 [ $MAX -ne $FSIZE ] && error "max is incorrect: $MAX"
8651 [ $SUM -ne $((FSIZE * 2)) ] && error "sum is wrong: $SUM"
8655 done < $TMP/${tfile}.tmp
8657 #check that we actually got some stats
8658 [ "$read_bytes" ] || error "Missing read_bytes stats"
8659 [ "$write_bytes" ] || error "Missing write_bytes stats"
8660 [ "$read_bytes" != 0 ] || error "no read done"
8661 [ "$write_bytes" != 0 ] || error "no write done"
8663 run_test 127b "verify the llite client stats are sane"
8665 test_128() { # bug 15212
8667 $LFS 2>&1 <<-EOF | tee $TMP/$tfile.log
8672 result=$(grep error $TMP/$tfile.log)
8674 [ -z "$result" ] || error "consecutive find's under interactive lfs failed"
8676 run_test 128 "interactive lfs for 2 consecutive find's"
8683 local LDPROC=/proc/fs/ldiskfs
8684 local facets=$(get_facets MDS)
8686 for facet in ${facets//,/ }; do
8687 canondev=$(ldiskfs_canon \
8688 *.$(convert_facet2label $facet).mntdev $facet)
8689 do_facet $facet "test -e $LDPROC/$canondev/max_dir_size" ||
8690 LDPROC=/sys/fs/ldiskfs
8691 do_facet $facet "echo $1 >$LDPROC/$canondev/max_dir_size"
8696 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8697 if [ "$(facet_fstype $SINGLEMDS)" != ldiskfs ]; then
8698 skip "Only applicable to ldiskfs-based MDTs"
8701 remote_mds_nodsh && skip "remote MDS with nodsh" && return
8706 test_mkdir -p $DIR/$tdir
8708 # block size of mds1
8709 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
8710 local MDSBLOCKSIZE=$($LCTL get_param -n mdc.*MDT0000*.blocksize)
8711 local MAX=$((MDSBLOCKSIZE * 3))
8713 local I=$(stat -c%s "$DIR/$tdir")
8715 local STRIPE_COUNT=1
8716 [[ $MDSCOUNT -ge 2 ]] && STRIPE_COUNT=$($LFS getdirstripe -c $DIR/$tdir)
8717 MAX=$((MAX*STRIPE_COUNT))
8718 while [[ $I -le $MAX ]]; do
8719 $MULTIOP $DIR/$tdir/$J Oc
8721 #check two errors ENOSPC for new version of ext4 max_dir_size patch
8722 #mainline kernel commit df981d03eeff7971ac7e6ff37000bfa702327ef1
8723 #and EFBIG for previous versions
8724 if [ $rc -eq $EFBIG -o $rc -eq $ENOSPC ]; then
8726 echo "return code $rc received as expected"
8727 multiop $DIR/$tdir/$J Oc ||
8728 error_exit "multiop failed w/o dir size limit"
8730 I=$(stat -c%s "$DIR/$tdir")
8732 if [ $(lustre_version_code $SINGLEMDS) -lt \
8733 $(version_code 2.4.51) ]
8735 [[ $I -eq $MAX ]] && return 0
8737 [[ $I -gt $MAX ]] && return 0
8739 error_exit "current dir size $I, previous limit $MAX"
8740 elif [ $rc -ne 0 ]; then
8742 error_exit "return code $rc received instead of expected " \
8743 "$EFBIG or $ENOSPC, files in dir $I"
8746 I=$(stat -c%s "$DIR/$tdir")
8750 error "exceeded dir size limit $MAX($MDSCOUNT) : $I bytes"
8752 run_test 129 "test directory size limit ========================"
8761 local filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
8762 [ -n "$filefrag_op" ] && skip_env "filefrag does not support FIEMAP" &&
8765 trap cleanup_130 EXIT RETURN
8767 local fm_file=$DIR/$tfile
8768 $SETSTRIPE -S 65536 -c 1 $fm_file || error "setstripe on $fm_file"
8769 dd if=/dev/zero of=$fm_file bs=65536 count=1 ||
8770 error "dd failed for $fm_file"
8772 # LU-1795: test filefrag/FIEMAP once, even if unsupported
8773 filefrag -ves $fm_file
8775 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
8776 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
8777 [ $RC != 0 ] && error "filefrag $fm_file failed"
8779 filefrag_op=$(filefrag -ve $fm_file | grep -A 100 "ext:" |
8780 grep -v "ext:" | grep -v "found")
8781 lun=$($GETSTRIPE -i $fm_file)
8783 start_blk=`echo $filefrag_op | cut -d: -f2 | cut -d. -f1`
8786 for line in $filefrag_op
8788 frag_lun=`echo $line | cut -d: -f5`
8789 ext_len=`echo $line | cut -d: -f4`
8790 if (( $frag_lun != $lun )); then
8792 error "FIEMAP on 1-stripe file($fm_file) failed"
8795 (( tot_len += ext_len ))
8798 if (( lun != frag_lun || start_blk != 0 || tot_len != 64 )); then
8800 error "FIEMAP on 1-stripe file($fm_file) failed;"
8806 echo "FIEMAP on single striped file succeeded"
8808 run_test 130a "FIEMAP (1-stripe file)"
8811 [ "$OSTCOUNT" -lt "2" ] &&
8812 skip_env "skipping FIEMAP on 2-stripe file test" && return
8814 [ "$OSTCOUNT" -ge "10" ] &&
8815 skip_env "skipping FIEMAP with >= 10 OSTs" && return
8817 local filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
8818 [ -n "$filefrag_op" ] && skip_env "filefrag does not support FIEMAP" &&
8821 trap cleanup_130 EXIT RETURN
8823 local fm_file=$DIR/$tfile
8824 $SETSTRIPE -S 65536 -c 2 $fm_file || error "setstripe on $fm_file"
8825 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
8826 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
8828 dd if=/dev/zero of=$fm_file bs=1M count=2 ||
8829 error "dd failed on $fm_file"
8831 filefrag -ves $fm_file || error "filefrag $fm_file failed"
8832 filefrag_op=$(filefrag -ve $fm_file | grep -A 100 "ext:" |
8833 grep -v "ext:" | grep -v "found")
8835 last_lun=$(echo $filefrag_op | cut -d: -f5)
8840 for line in $filefrag_op
8842 frag_lun=`echo $line | cut -d: -f5`
8843 ext_len=`echo $line | cut -d: -f4`
8844 if (( $frag_lun != $last_lun )); then
8845 if (( tot_len != 1024 )); then
8847 error "FIEMAP on $fm_file failed; returned len $tot_len for OST $last_lun instead of 256"
8854 (( tot_len += ext_len ))
8857 if (( num_luns != 2 || tot_len != 1024 )); then
8859 error "FIEMAP on $fm_file failed; returned wrong number of luns or wrong len for OST $last_lun"
8865 echo "FIEMAP on 2-stripe file succeeded"
8867 run_test 130b "FIEMAP (2-stripe file)"
8870 [ "$OSTCOUNT" -lt "2" ] &&
8871 skip_env "skipping FIEMAP on 2-stripe file" && return
8873 [ "$OSTCOUNT" -ge "10" ] &&
8874 skip_env "skipping FIEMAP with >= 10 OSTs" && return
8876 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
8877 [ -n "$filefrag_op" ] && skip "filefrag does not support FIEMAP" &&
8880 trap cleanup_130 EXIT RETURN
8882 local fm_file=$DIR/$tfile
8883 $SETSTRIPE -S 65536 -c 2 $fm_file || error "setstripe on $fm_file"
8884 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
8885 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
8887 dd if=/dev/zero of=$fm_file seek=1 bs=1M count=1 || error "dd failed on $fm_file"
8889 filefrag -ves $fm_file || error "filefrag $fm_file failed"
8890 filefrag_op=`filefrag -ve $fm_file | grep -A 100 "ext:" | grep -v "ext:" | grep -v "found"`
8892 last_lun=`echo $filefrag_op | cut -d: -f5`
8897 for line in $filefrag_op
8899 frag_lun=`echo $line | cut -d: -f5`
8900 ext_len=`echo $line | cut -d: -f4`
8901 if (( $frag_lun != $last_lun )); then
8902 logical=`echo $line | cut -d: -f2 | cut -d. -f1`
8903 if (( logical != 512 )); then
8905 error "FIEMAP on $fm_file failed; returned logical start for lun $logical instead of 512"
8908 if (( tot_len != 512 )); then
8910 error "FIEMAP on $fm_file failed; returned len $tot_len for OST $last_lun instead of 1024"
8917 (( tot_len += ext_len ))
8920 if (( num_luns != 2 || tot_len != 512 )); then
8922 error "FIEMAP on $fm_file failed; returned wrong number of luns or wrong len for OST $last_lun"
8928 echo "FIEMAP on 2-stripe file with hole succeeded"
8930 run_test 130c "FIEMAP (2-stripe file with hole)"
8933 [ "$OSTCOUNT" -lt "3" ] && skip_env "skipping FIEMAP on N-stripe file test" && return
8935 [ "$OSTCOUNT" -ge "10" ] &&
8936 skip_env "skipping FIEMAP with >= 10 OSTs" && return
8938 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
8939 [ -n "$filefrag_op" ] && skip "filefrag does not support FIEMAP" && return
8941 trap cleanup_130 EXIT RETURN
8943 local fm_file=$DIR/$tfile
8944 $SETSTRIPE -S 65536 -c $OSTCOUNT $fm_file||error "setstripe on $fm_file"
8945 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
8946 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
8948 local actual_stripecnt=$($GETSTRIPE -c $fm_file)
8949 dd if=/dev/zero of=$fm_file bs=1M count=$actual_stripecnt ||
8950 error "dd failed on $fm_file"
8952 filefrag -ves $fm_file || error "filefrag $fm_file failed"
8953 filefrag_op=`filefrag -ve $fm_file | grep -A 100 "ext:" |
8954 grep -v "ext:" | grep -v "found"`
8956 last_lun=`echo $filefrag_op | cut -d: -f5`
8961 for line in $filefrag_op
8963 frag_lun=`echo $line | cut -d: -f5`
8964 ext_len=`echo $line | cut -d: -f4`
8965 if (( $frag_lun != $last_lun )); then
8966 if (( tot_len != 1024 )); then
8968 error "FIEMAP on $fm_file failed; returned len $tot_len for OST $last_lun instead of 1024"
8975 (( tot_len += ext_len ))
8978 if (( num_luns != actual_stripecnt || tot_len != 1024 )); then
8980 error "FIEMAP on $fm_file failed; returned wrong number of luns or wrong len for OST $last_lun"
8986 echo "FIEMAP on N-stripe file succeeded"
8988 run_test 130d "FIEMAP (N-stripe file)"
8991 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping continuation FIEMAP test" && return
8993 [ "$OSTCOUNT" -ge "10" ] &&
8994 skip_env "skipping FIEMAP with >= 10 OSTs" && return
8996 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
8997 [ -n "$filefrag_op" ] && skip "filefrag does not support FIEMAP" && return
8999 trap cleanup_130 EXIT RETURN
9001 local fm_file=$DIR/$tfile
9002 $SETSTRIPE -S 131072 -c 2 $fm_file || error "setstripe on $fm_file"
9003 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
9004 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
9007 EXPECTED_LEN=$(( (NUM_BLKS / 2) * 64 ))
9008 for ((i = 0; i < $NUM_BLKS; i++))
9010 dd if=/dev/zero of=$fm_file count=1 bs=64k seek=$((2*$i)) conv=notrunc > /dev/null 2>&1
9013 filefrag -ves $fm_file || error "filefrag $fm_file failed"
9014 filefrag_op=`filefrag -ve $fm_file | grep -A 12000 "ext:" | grep -v "ext:" | grep -v "found"`
9016 last_lun=`echo $filefrag_op | cut -d: -f5`
9021 for line in $filefrag_op
9023 frag_lun=`echo $line | cut -d: -f5`
9024 ext_len=`echo $line | cut -d: -f4`
9025 if (( $frag_lun != $last_lun )); then
9026 if (( tot_len != $EXPECTED_LEN )); then
9028 error "FIEMAP on $fm_file failed; returned len $tot_len for OST $last_lun instead of $EXPECTED_LEN"
9035 (( tot_len += ext_len ))
9038 if (( num_luns != 2 || tot_len != $EXPECTED_LEN )); then
9040 error "FIEMAP on $fm_file failed; returned wrong number of luns or wrong len for OST $last_lun"
9046 echo "FIEMAP with continuation calls succeeded"
9048 run_test 130e "FIEMAP (test continuation FIEMAP calls)"
9050 # Test for writev/readv
9052 rwv -f $DIR/$tfile -w -n 3 524288 1048576 1572864 || \
9053 error "writev test failed"
9054 rwv -f $DIR/$tfile -r -v -n 2 1572864 1048576 || \
9055 error "readv failed"
9058 run_test 131a "test iov's crossing stripe boundary for writev/readv"
9061 rwv -f $DIR/$tfile -w -a -n 3 524288 1048576 1572864 || \
9062 error "append writev test failed"
9063 rwv -f $DIR/$tfile -w -a -n 2 1572864 1048576 || \
9064 error "append writev test failed"
9067 run_test 131b "test append writev"
9070 rwv -f $DIR/$tfile -w -d -n 1 1048576 || return 0
9073 run_test 131c "test read/write on file w/o objects"
9076 rwv -f $DIR/$tfile -w -n 1 1572864
9077 NOB=`rwv -f $DIR/$tfile -r -n 3 524288 524288 1048576 | awk '/error/ {print $6}'`
9078 if [ "$NOB" != 1572864 ]; then
9079 error "Short read filed: read $NOB bytes instead of 1572864"
9083 run_test 131d "test short read"
9086 rwv -f $DIR/$tfile -w -s 1048576 -n 1 1048576
9087 rwv -f $DIR/$tfile -r -z -s 0 -n 1 524288 || \
9088 error "read hitting hole failed"
9091 run_test 131e "test read hitting hole"
9097 $SINGLEMDS) res=`do_facet $SINGLEMDS $LCTL get_param mdt.$FSNAME-MDT0000.md_stats | grep "$2"`
9099 ost) res=`do_facet ost1 $LCTL get_param obdfilter.$FSNAME-OST0000.stats | grep "$2"`
9101 *) error "Wrong argument $1" ;;
9104 [ -z "$res" ] && error "The counter for $2 on $1 was not incremented"
9105 # if the argument $3 is zero, it means any stat increment is ok.
9106 if [[ $3 -gt 0 ]]; then
9107 count=$(echo $res | awk '{ print $2 }')
9108 [[ $count -ne $3 ]] &&
9109 error "The $2 counter on $1 is wrong - expected $3"
9114 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9115 remote_ost_nodsh && skip "remote OST with nodsh" && return
9116 remote_mds_nodsh && skip "remote MDS with nodsh" && return
9118 do_facet $SINGLEMDS $LCTL list_param mdt.*.rename_stats ||
9119 { skip "MDS doesn't support rename stats"; return; }
9120 local testdir=$DIR/${tdir}/stats_testdir
9121 mkdir -p $DIR/${tdir}
9124 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
9125 do_facet ost1 $LCTL set_param obdfilter.*.stats=clear
9127 # verify mdt stats first.
9128 mkdir ${testdir} || error "mkdir failed"
9129 check_stats $SINGLEMDS "mkdir" 1
9130 touch ${testdir}/${tfile} || "touch failed"
9131 check_stats $SINGLEMDS "open" 1
9132 check_stats $SINGLEMDS "close" 1
9133 mknod ${testdir}/${tfile}-pipe p || "mknod failed"
9134 check_stats $SINGLEMDS "mknod" 1
9135 rm -f ${testdir}/${tfile}-pipe || "pipe remove failed"
9136 check_stats $SINGLEMDS "unlink" 1
9137 rm -f ${testdir}/${tfile} || error "file remove failed"
9138 check_stats $SINGLEMDS "unlink" 2
9140 # remove working dir and check mdt stats again.
9141 rmdir ${testdir} || error "rmdir failed"
9142 check_stats $SINGLEMDS "rmdir" 1
9144 local testdir1=$DIR/${tdir}/stats_testdir1
9146 mkdir -p ${testdir1}
9147 touch ${testdir1}/test1
9148 mv ${testdir1}/test1 ${testdir} || error "file crossdir rename"
9149 check_stats $SINGLEMDS "crossdir_rename" 1
9151 mv ${testdir}/test1 ${testdir}/test0 || error "file samedir rename"
9152 check_stats $SINGLEMDS "samedir_rename" 1
9156 run_test 133a "Verifying MDT stats ========================================"
9159 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9160 remote_ost_nodsh && skip "remote OST with nodsh" && return
9161 remote_mds_nodsh && skip "remote MDS with nodsh" && return
9162 local testdir=$DIR/${tdir}/stats_testdir
9163 mkdir -p ${testdir} || error "mkdir failed"
9164 touch ${testdir}/${tfile} || "touch failed"
9165 cancel_lru_locks mdc
9168 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
9169 do_facet ost1 $LCTL set_param obdfilter.*.stats=clear
9171 # extra mdt stats verification.
9172 chmod 444 ${testdir}/${tfile} || error "chmod failed"
9173 check_stats $SINGLEMDS "setattr" 1
9174 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
9175 if [ $(lustre_version_code $SINGLEMDS) -ne $(version_code 2.2.0) ]
9177 ls -l ${testdir}/${tfile} > /dev/null|| error "ls failed"
9178 check_stats $SINGLEMDS "getattr" 1
9180 $LFS df || error "lfs failed"
9181 check_stats $SINGLEMDS "statfs" 1
9185 run_test 133b "Verifying extra MDT stats =================================="
9188 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9189 remote_ost_nodsh && skip "remote OST with nodsh" && return
9190 remote_mds_nodsh && skip "remote MDS with nodsh" && return
9191 local testdir=$DIR/${tdir}/stats_testdir
9192 test_mkdir -p ${testdir} || error "mkdir failed"
9194 # verify obdfilter stats.
9195 $SETSTRIPE -c 1 -i 0 ${testdir}/${tfile}
9197 cancel_lru_locks osc
9198 wait_delete_completed
9201 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
9202 do_facet ost1 $LCTL set_param obdfilter.*.stats=clear
9204 dd if=/dev/zero of=${testdir}/${tfile} conv=notrunc bs=512k count=1 || error "dd failed"
9206 cancel_lru_locks osc
9207 check_stats ost "write" 1
9209 dd if=${testdir}/${tfile} of=/dev/null bs=1k count=1 || error "dd failed"
9210 check_stats ost "read" 1
9212 > ${testdir}/${tfile} || error "truncate failed"
9213 check_stats ost "punch" 1
9215 rm -f ${testdir}/${tfile} || error "file remove failed"
9216 wait_delete_completed
9217 check_stats ost "destroy" 1
9221 run_test 133c "Verifying OST stats ========================================"
9228 while [ $value -ge 2 ]; do
9233 if [ $orig -gt $order ]; then
9241 local size=('K' 'M' 'G' 'T');
9243 local size_string=$value
9245 while [ $value -ge 1024 ]; do
9246 if [ $i -gt 3 ]; then
9247 #T is the biggest unit we get here, if that is bigger,
9249 size_string=${value}T
9252 value=$((value >> 10))
9253 if [ $value -lt 1024 ]; then
9254 size_string=${value}${size[$i]}
9265 local context=${2:-.}
9266 local sample=$(do_facet $SINGLEMDS $LCTL get_param mdt.*.rename_stats |
9268 awk '/ '${size}'/ {print $4}' | sed -e "s/,//g")
9273 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9274 remote_ost_nodsh && skip "remote OST with nodsh" && return
9275 remote_mds_nodsh && skip "remote MDS with nodsh" && return
9276 do_facet $SINGLEMDS $LCTL list_param mdt.*.rename_stats ||
9277 { skip "MDS doesn't support rename stats"; return; }
9279 local testdir1=$DIR/${tdir}/stats_testdir1
9280 local testdir2=$DIR/${tdir}/stats_testdir2
9282 do_facet $SINGLEMDS $LCTL set_param mdt.*.rename_stats=clear
9284 mkdir -p ${testdir1} || error "mkdir failed"
9285 mkdir -p ${testdir2} || error "mkdir failed"
9287 createmany -o $testdir1/test 512 || error "createmany failed"
9289 # check samedir rename size
9290 mv ${testdir1}/test0 ${testdir1}/test_0
9292 local testdir1_size=$(ls -l $DIR/${tdir} |
9293 awk '/stats_testdir1/ {print $5}')
9294 local testdir2_size=$(ls -l $DIR/${tdir} |
9295 awk '/stats_testdir2/ {print $5}')
9297 testdir1_size=$(order_2 $testdir1_size)
9298 testdir2_size=$(order_2 $testdir2_size)
9300 testdir1_size=$(size_in_KMGT $testdir1_size)
9301 testdir2_size=$(size_in_KMGT $testdir2_size)
9303 echo "source rename dir size: ${testdir1_size}"
9304 echo "target rename dir size: ${testdir2_size}"
9306 local cmd="do_facet $SINGLEMDS $LCTL get_param mdt.*.rename_stats"
9307 eval $cmd || error "$cmd failed"
9308 local samedir=$($cmd | grep 'same_dir')
9309 local same_sample=$(get_rename_size $testdir1_size)
9310 [ -z "$samedir" ] && error "samedir_rename_size count error"
9311 [[ $same_sample -eq 1 ]] ||
9312 error "samedir_rename_size error $same_sample"
9313 echo "Check same dir rename stats success"
9315 do_facet $SINGLEMDS $LCTL set_param mdt.*.rename_stats=clear
9317 # check crossdir rename size
9318 mv ${testdir1}/test_0 ${testdir2}/test_0
9320 testdir1_size=$(ls -l $DIR/${tdir} |
9321 awk '/stats_testdir1/ {print $5}')
9322 testdir2_size=$(ls -l $DIR/${tdir} |
9323 awk '/stats_testdir2/ {print $5}')
9325 testdir1_size=$(order_2 $testdir1_size)
9326 testdir2_size=$(order_2 $testdir2_size)
9328 testdir1_size=$(size_in_KMGT $testdir1_size)
9329 testdir2_size=$(size_in_KMGT $testdir2_size)
9331 echo "source rename dir size: ${testdir1_size}"
9332 echo "target rename dir size: ${testdir2_size}"
9334 eval $cmd || error "$cmd failed"
9335 local crossdir=$($cmd | grep 'crossdir')
9336 local src_sample=$(get_rename_size $testdir1_size crossdir_src)
9337 local tgt_sample=$(get_rename_size $testdir2_size crossdir_tgt)
9338 [ -z "$crossdir" ] && error "crossdir_rename_size count error"
9339 [[ $src_sample -eq 1 ]] ||
9340 error "crossdir_rename_size error $src_sample"
9341 [[ $tgt_sample -eq 1 ]] ||
9342 error "crossdir_rename_size error $tgt_sample"
9343 echo "Check cross dir rename stats success"
9346 run_test 133d "Verifying rename_stats ========================================"
9349 remote_mds_nodsh && skip "remote MDS with nodsh" && return
9350 remote_ost_nodsh && skip "remote OST with nodsh" && return
9351 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9352 local testdir=$DIR/${tdir}/stats_testdir
9353 local ctr f0 f1 bs=32768 count=42 sum
9355 mkdir -p ${testdir} || error "mkdir failed"
9357 $SETSTRIPE -c 1 -i 0 ${testdir}/${tfile}
9359 for ctr in {write,read}_bytes; do
9361 cancel_lru_locks osc
9363 do_facet ost1 $LCTL set_param -n \
9364 "obdfilter.*.exports.clear=clear"
9366 if [ $ctr = write_bytes ]; then
9368 f1=${testdir}/${tfile}
9370 f0=${testdir}/${tfile}
9374 dd if=$f0 of=$f1 conv=notrunc bs=$bs count=$count || \
9377 cancel_lru_locks osc
9379 sum=$(do_facet ost1 $LCTL get_param \
9380 "obdfilter.*.exports.*.stats" |
9381 awk -v ctr=$ctr 'BEGIN { sum = 0 }
9382 $1 == ctr { sum += $7 }
9383 END { printf("%0.0f", sum) }')
9385 if ((sum != bs * count)); then
9386 error "Bad $ctr sum, expected $((bs * count)), got $sum"
9392 run_test 133e "Verifying OST {read,write}_bytes nid stats ================="
9397 local dirs="/proc/fs/lustre/ /proc/sys/lnet/ /proc/sys/lustre/ \
9398 /sys/fs/lustre/ /sys/fs/lnet/"
9400 for dir in $dirs; do
9401 if [ -d $dir ]; then
9402 proc_dirs="$proc_dirs $dir"
9408 remote_mds_nodsh && skip "remote MDS with nodsh" && return
9409 remote_ost_nodsh && skip "remote OST with nodsh" && return
9410 # First without trusting modes.
9411 find $proc_dirs -exec cat '{}' \; &> /dev/null
9413 # Second verifying readability.
9416 -exec cat '{}' \; &> /dev/null ||
9417 error "proc file read failed"
9419 for facet in $SINGLEMDS ost1; do
9420 do_facet $facet find $proc_dirs \
9421 ! -name req_history \
9422 -exec cat '{}' \\\; &> /dev/null
9424 do_facet $facet find $proc_dirs \
9425 ! -name req_history \
9427 -exec cat '{}' \\\; &> /dev/null ||
9428 error "proc file read failed"
9431 run_test 133f "Check for LBUGs/Oopses/unreadable files in /proc"
9436 local dirs="/proc/fs/lustre/ /proc/sys/lnet/ /proc/sys/lustre/ \
9437 /sys/fs/lustre/ /sys/fs/lnet/"
9439 for dir in $dirs; do
9440 if [ -d $dir ]; then
9441 proc_dirs="$proc_dirs $dir"
9447 # Second verifying readability.
9450 -not -name force_lbug \
9451 -not -name changelog_mask \
9452 -exec badarea_io '{}' \; &> /dev/null ||
9453 error "find $proc_dirs failed"
9455 [ $(lustre_version_code $SINGLEMDS) -le $(version_code 2.5.54) ] &&
9456 skip "Too old lustre on MDS" && return
9458 [ $(lustre_version_code ost1) -le $(version_code 2.5.54) ] &&
9459 skip "Too old lustre on ost1" && return
9461 for facet in $SINGLEMDS ost1; do
9462 do_facet $facet find $proc_dirs \
9464 -not -name force_lbug \
9465 -not -name changelog_mask \
9466 -exec badarea_io '{}' \\\; &> /dev/null ||
9467 error "$facet find $proc_dirs failed"
9471 # remount the FS in case writes/reads /proc break the FS
9472 cleanup || error "failed to unmount"
9473 setup || error "failed to setup"
9476 run_test 133g "Check for Oopses on bad io area writes/reads in /proc"
9479 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.54) ]] &&
9480 skip "Need MDS version at least 2.7.54" && return
9482 mkdir -p $DIR/$tdir || error "failed to create $DIR/$tdir"
9483 cancel_lru_locks mdc
9485 local nsdir="ldlm.namespaces.*-MDT0000-mdc-*"
9486 local unused=$($LCTL get_param -n $nsdir.lock_unused_count)
9487 [ $unused -eq 0 ] || "$unused locks are not cleared"
9490 createmany -o $DIR/$tdir/f $nr ||
9491 error "failed to create $nr files in $DIR/$tdir"
9492 unused=$($LCTL get_param -n $nsdir.lock_unused_count)
9494 #define OBD_FAIL_LDLM_WATERMARK_LOW 0x327
9495 do_facet mds1 $LCTL set_param fail_loc=0x327
9496 do_facet mds1 $LCTL set_param fail_val=500
9499 echo "sleep 10 seconds ..."
9501 local lck_cnt=$($LCTL get_param -n $nsdir.lock_unused_count)
9503 do_facet mds1 $LCTL set_param fail_loc=0
9504 do_facet mds1 $LCTL set_param fail_val=0
9505 [ $lck_cnt -lt $unused ] ||
9506 error "No locks reclaimed, before:$unused, after:$lck_cnt"
9509 unlinkmany $DIR/$tdir/f $nr
9511 run_test 134a "Server reclaims locks when reaching lock_reclaim_threshold"
9514 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.54) ]] &&
9515 skip "Need MDS version at least 2.7.54" && return
9517 mkdir -p $DIR/$tdir || error "failed to create $DIR/$tdir"
9518 cancel_lru_locks mdc
9520 local low_wm=$(do_facet mds1 $LCTL get_param -n \
9521 ldlm.lock_reclaim_threshold_mb)
9522 # disable reclaim temporarily
9523 do_facet mds1 $LCTL set_param ldlm.lock_reclaim_threshold_mb=0
9525 #define OBD_FAIL_LDLM_WATERMARK_HIGH 0x328
9526 do_facet mds1 $LCTL set_param fail_loc=0x328
9527 do_facet mds1 $LCTL set_param fail_val=500
9529 $LCTL set_param debug=+trace
9532 createmany -o $DIR/$tdir/f $nr &
9535 echo "Sleep $TIMEOUT seconds ..."
9537 if ! ps -p $create_pid > /dev/null 2>&1; then
9538 do_facet mds1 $LCTL set_param fail_loc=0
9539 do_facet mds1 $LCTL set_param fail_val=0
9540 do_facet mds1 $LCTL set_param \
9541 ldlm.lock_reclaim_threshold_mb=${low_wm}m
9542 error "createmany finished incorrectly!"
9544 do_facet mds1 $LCTL set_param fail_loc=0
9545 do_facet mds1 $LCTL set_param fail_val=0
9546 do_facet mds1 $LCTL set_param ldlm.lock_reclaim_threshold_mb=${low_wm}m
9547 wait $create_pid || return 1
9549 unlinkmany $DIR/$tdir/f $nr
9551 run_test 134b "Server rejects lock request when reaching lock_limit_mb"
9553 test_140() { #bug-17379
9554 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9555 test_mkdir -p $DIR/$tdir || error "Creating dir $DIR/$tdir"
9556 cd $DIR/$tdir || error "Changing to $DIR/$tdir"
9557 cp /usr/bin/stat . || error "Copying stat to $DIR/$tdir"
9559 # VFS limits max symlink depth to 5(4KSTACK) or 7(8KSTACK) or 8
9560 # For kernel > 3.5, bellow only tests consecutive symlink (MAX 40)
9562 while i=`expr $i + 1`; do
9563 test_mkdir -p $i || error "Creating dir $i"
9564 cd $i || error "Changing to $i"
9565 ln -s ../stat stat || error "Creating stat symlink"
9566 # Read the symlink until ELOOP present,
9567 # not LBUGing the system is considered success,
9568 # we didn't overrun the stack.
9569 $OPENFILE -f O_RDONLY stat >/dev/null 2>&1; ret=$?
9571 if [ $ret -eq 40 ]; then
9574 error "Open stat symlink"
9580 echo "The symlink depth = $i"
9581 [ $i -eq 5 -o $i -eq 7 -o $i -eq 8 -o $i -eq 40 ] ||
9582 error "Invalid symlink depth"
9584 # Test recursive symlink
9585 ln -s symlink_self symlink_self
9586 $OPENFILE -f O_RDONLY symlink_self >/dev/null 2>&1; ret=$?
9587 echo "open symlink_self returns $ret"
9588 [ $ret -eq 40 ] || error "recursive symlink doesn't return -ELOOP"
9590 run_test 140 "Check reasonable stack depth (shouldn't LBUG) ===="
9593 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9594 local TF="$TMP/$tfile"
9596 dd if=/dev/urandom of=$TF bs=6096 count=1 || error "dd failed"
9598 cancel_lru_locks osc
9599 cmp $TF $DIR/$tfile || error "$TMP/$tfile $DIR/$tfile differ"
9600 remount_client $MOUNT
9602 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (remount)"
9605 $TRUNCATE $DIR/$tfile 6000
9606 cancel_lru_locks osc
9607 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (truncate1)"
9610 echo "12345" >>$DIR/$tfile
9611 cancel_lru_locks osc
9612 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (append1)"
9615 echo "12345" >>$DIR/$tfile
9616 cancel_lru_locks osc
9617 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (append2)"
9622 run_test 150 "truncate/append tests"
9624 #LU-2902 roc_hit was not able to read all values from lproc
9625 function roc_hit_init() {
9626 local list=$(comma_list $(osts_nodes))
9627 local dir=$DIR/$tdir-check
9628 local file=$dir/file
9634 #use setstripe to do a write to every ost
9635 for i in $(seq 0 $((OSTCOUNT-1))); do
9636 $SETSTRIPE -c 1 -i $i $dir || error "$SETSTRIPE $file failed"
9637 dd if=/dev/urandom of=$file bs=4k count=4 2>&1 > /dev/null
9638 idx=$(printf %04x $i)
9639 BEFORE=$(get_osd_param $list *OST*$idx stats |
9640 awk '$1 == "cache_access" {sum += $7}
9641 END { printf("%0.0f", sum) }')
9643 cancel_lru_locks osc
9644 cat $file >/dev/null
9646 AFTER=$(get_osd_param $list *OST*$idx stats |
9647 awk '$1 == "cache_access" {sum += $7}
9648 END { printf("%0.0f", sum) }')
9650 echo BEFORE:$BEFORE AFTER:$AFTER
9651 if ! let "AFTER - BEFORE == 4"; then
9653 error "roc_hit is not safe to use"
9661 function roc_hit() {
9662 local list=$(comma_list $(osts_nodes))
9663 echo $(get_osd_param $list '' stats |
9664 awk '$1 == "cache_hit" {sum += $7}
9665 END { printf("%0.0f", sum) }')
9668 function set_cache() {
9671 if [ "$2" == "off" ]; then
9674 local list=$(comma_list $(osts_nodes))
9675 set_osd_param $list '' $1_cache_enable $on
9677 cancel_lru_locks osc
9681 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9682 remote_ost_nodsh && skip "remote OST with nodsh" && return
9685 local list=$(comma_list $(osts_nodes))
9687 # check whether obdfilter is cache capable at all
9688 if ! get_osd_param $list '' read_cache_enable >/dev/null; then
9689 echo "not cache-capable obdfilter"
9693 # check cache is enabled on all obdfilters
9694 if get_osd_param $list '' read_cache_enable | grep 0; then
9695 echo "oss cache is disabled"
9699 set_osd_param $list '' writethrough_cache_enable 1
9701 # check write cache is enabled on all obdfilters
9702 if get_osd_param $list '' writethrough_cache_enable | grep 0; then
9703 echo "oss write cache is NOT enabled"
9709 #define OBD_FAIL_OBD_NO_LRU 0x609
9710 do_nodes $list $LCTL set_param fail_loc=0x609
9712 # pages should be in the case right after write
9713 dd if=/dev/urandom of=$DIR/$tfile bs=4k count=$CPAGES ||
9716 local BEFORE=$(roc_hit)
9717 cancel_lru_locks osc
9718 cat $DIR/$tfile >/dev/null
9719 local AFTER=$(roc_hit)
9721 do_nodes $list $LCTL set_param fail_loc=0
9723 if ! let "AFTER - BEFORE == CPAGES"; then
9724 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
9727 # the following read invalidates the cache
9728 cancel_lru_locks osc
9729 set_osd_param $list '' read_cache_enable 0
9730 cat $DIR/$tfile >/dev/null
9732 # now data shouldn't be found in the cache
9734 cancel_lru_locks osc
9735 cat $DIR/$tfile >/dev/null
9737 if let "AFTER - BEFORE != 0"; then
9738 error "IN CACHE: before: $BEFORE, after: $AFTER"
9741 set_osd_param $list '' read_cache_enable 1
9744 run_test 151 "test cache on oss and controls ==============================="
9747 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9748 local TF="$TMP/$tfile"
9750 # simulate ENOMEM during write
9751 #define OBD_FAIL_OST_NOMEM 0x226
9752 lctl set_param fail_loc=0x80000226
9753 dd if=/dev/urandom of=$TF bs=6096 count=1 || error "dd failed"
9755 sync || error "sync failed"
9756 lctl set_param fail_loc=0
9758 # discard client's cache
9759 cancel_lru_locks osc
9761 # simulate ENOMEM during read
9762 lctl set_param fail_loc=0x80000226
9763 cmp $TF $DIR/$tfile || error "cmp failed"
9764 lctl set_param fail_loc=0
9768 run_test 152 "test read/write with enomem ============================"
9771 $MULTIOP $DIR/$tfile Ow4096Ycu || error "multiop failed"
9773 run_test 153 "test if fdatasync does not crash ======================="
9775 dot_lustre_fid_permission_check() {
9777 local ffid=$MOUNT/.lustre/fid/$fid
9780 echo "stat fid $fid"
9781 stat $ffid > /dev/null || error "stat $ffid failed."
9782 echo "touch fid $fid"
9783 touch $ffid || error "touch $ffid failed."
9784 echo "write to fid $fid"
9785 cat /etc/hosts > $ffid || error "write $ffid failed."
9786 echo "read fid $fid"
9787 diff /etc/hosts $ffid || error "read $ffid failed."
9788 echo "append write to fid $fid"
9789 cat /etc/hosts >> $ffid || error "append write $ffid failed."
9790 echo "rename fid $fid"
9791 mv $ffid $test_dir/$tfile.1 &&
9792 error "rename $ffid to $tfile.1 should fail."
9793 touch $test_dir/$tfile.1
9794 mv $test_dir/$tfile.1 $ffid &&
9795 error "rename $tfile.1 to $ffid should fail."
9796 rm -f $test_dir/$tfile.1
9797 echo "truncate fid $fid"
9798 $TRUNCATE $ffid 777 || error "truncate $ffid failed."
9799 if [ $MDSCOUNT -lt 2 ]; then #FIXME when cross-MDT hard link is working
9800 echo "link fid $fid"
9801 ln -f $ffid $test_dir/tfile.lnk || error "link $ffid failed."
9803 if [ -n $(lctl get_param -n mdc.*-mdc-*.connect_flags | grep acl) ]; then
9804 echo "setfacl fid $fid"
9805 setfacl -R -m u:bin:rwx $ffid || error "setfacl $ffid failed."
9806 echo "getfacl fid $fid"
9807 getfacl $ffid >/dev/null || error "getfacl $ffid failed."
9809 echo "unlink fid $fid"
9810 unlink $MOUNT/.lustre/fid/$fid && error "unlink $ffid should fail."
9811 echo "mknod fid $fid"
9812 mknod $ffid c 1 3 && error "mknod $ffid should fail."
9814 fid=[0xf00000400:0x1:0x0]
9815 ffid=$MOUNT/.lustre/fid/$fid
9817 echo "stat non-exist fid $fid"
9818 stat $ffid > /dev/null && error "stat non-exist $ffid should fail."
9819 echo "write to non-exist fid $fid"
9820 cat /etc/hosts > $ffid && error "write non-exist $ffid should fail."
9821 echo "link new fid $fid"
9822 ln $test_dir/$tfile $ffid && error "link $ffid should fail."
9824 mkdir -p $test_dir/$tdir
9825 touch $test_dir/$tdir/$tfile
9826 fid=$($LFS path2fid $test_dir/$tdir)
9829 error "error: could not get fid for $test_dir/$dir/$tfile."
9831 ffid=$MOUNT/.lustre/fid/$fid
9834 ls $ffid > /dev/null || error "ls $ffid failed."
9835 echo "touch $fid/$tfile.1"
9836 touch $ffid/$tfile.1 || error "touch $ffid/$tfile.1 failed."
9838 echo "touch $MOUNT/.lustre/fid/$tfile"
9839 touch $MOUNT/.lustre/fid/$tfile && \
9840 error "touch $MOUNT/.lustre/fid/$tfile should fail."
9842 echo "setxattr to $MOUNT/.lustre/fid"
9843 setfattr -n trusted.name1 -v value1 $MOUNT/.lustre/fid
9845 echo "listxattr for $MOUNT/.lustre/fid"
9846 getfattr -d -m "^trusted" $MOUNT/.lustre/fid
9848 echo "delxattr from $MOUNT/.lustre/fid"
9849 setfattr -x trusted.name1 $MOUNT/.lustre/fid
9851 echo "touch invalid fid: $MOUNT/.lustre/fid/[0x200000400:0x2:0x3]"
9852 touch $MOUNT/.lustre/fid/[0x200000400:0x2:0x3] &&
9853 error "touch invalid fid should fail."
9855 echo "touch non-normal fid: $MOUNT/.lustre/fid/[0x1:0x2:0x0]"
9856 touch $MOUNT/.lustre/fid/[0x1:0x2:0x0] &&
9857 error "touch non-normal fid should fail."
9859 echo "rename $tdir to $MOUNT/.lustre/fid"
9860 mrename $test_dir/$tdir $MOUNT/.lustre/fid &&
9861 error "rename to $MOUNT/.lustre/fid should fail."
9863 if [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.3.51) ]
9865 local old_obf_mode=$(stat --format="%a" $DIR/.lustre/fid)
9866 local new_obf_mode=777
9868 echo "change mode of $DIR/.lustre/fid to $new_obf_mode"
9869 chmod $new_obf_mode $DIR/.lustre/fid ||
9870 error "chmod $new_obf_mode $DIR/.lustre/fid failed"
9872 local obf_mode=$(stat --format=%a $DIR/.lustre/fid)
9873 [ $obf_mode -eq $new_obf_mode ] ||
9874 error "stat $DIR/.lustre/fid returned wrong mode $obf_mode"
9876 echo "restore mode of $DIR/.lustre/fid to $old_obf_mode"
9877 chmod $old_obf_mode $DIR/.lustre/fid ||
9878 error "chmod $old_obf_mode $DIR/.lustre/fid failed"
9881 $OPENFILE -f O_LOV_DELAY_CREATE:O_CREAT $test_dir/$tfile-2
9882 fid=$($LFS path2fid $test_dir/$tfile-2)
9884 if [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.6.50) ]
9886 echo "cp /etc/passwd $MOUNT/.lustre/fid/$fid"
9887 cp /etc/passwd $MOUNT/.lustre/fid/$fid ||
9888 error "create lov data thru .lustre failed"
9890 echo "cp /etc/passwd $test_dir/$tfile-2"
9891 cp /etc/passwd $test_dir/$tfile-2 ||
9892 error "copy to $test_dir/$tfile-2 failed."
9893 echo "diff /etc/passwd $MOUNT/.lustre/fid/$fid"
9894 diff /etc/passwd $MOUNT/.lustre/fid/$fid ||
9895 error "diff /etc/passwd $MOUNT/.lustre/fid/$fid failed."
9897 rm -rf $test_dir/tfile.lnk
9898 rm -rf $test_dir/$tfile-2
9902 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.1) ]] &&
9903 skip "Need MDS version at least 2.4.1" && return
9906 local FID=$($LFS path2fid $DIR/$tfile)
9907 [ -z "$FID" ] && error "path2fid unable to get $DIR/$tfile FID"
9909 # check that we get the same pathname back
9910 local FOUND=$($LFS fid2path $MOUNT "$FID")
9911 [ -z "$FOUND" ] && error "fid2path unable to get $FID path"
9912 [ "$FOUND" != "$DIR/$tfile" ] &&
9913 error "fid2path(path2fid($DIR/$tfile)) = $FOUND != $DIR/$tfile"
9917 run_test 154A "lfs path2fid and fid2path basic checks"
9920 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9921 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.51) ]] ||
9922 { skip "Need MDS version at least 2.2.51"; return 0; }
9923 [ -z "$(which setfacl)" ] && skip "must have setfacl tool" && return
9925 cp /etc/hosts $DIR/$tfile
9927 fid=$($LFS path2fid $DIR/$tfile)
9929 [ $rc -ne 0 ] && error "error: could not get fid for $DIR/$tfile."
9931 dot_lustre_fid_permission_check "$fid" $DIR ||
9932 error "dot lustre permission check $fid failed"
9934 rm -rf $MOUNT/.lustre && error ".lustre is not allowed to be unlinked"
9936 touch $MOUNT/.lustre/file &&
9937 error "creation is not allowed under .lustre"
9939 mkdir $MOUNT/.lustre/dir &&
9940 error "mkdir is not allowed under .lustre"
9944 run_test 154a "Open-by-FID"
9947 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9948 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.51) ]] ||
9949 { skip "Need MDS version at least 2.2.51"; return 0; }
9951 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
9953 local remote_dir=$DIR/$tdir/remote_dir
9958 $LFS mkdir -i $MDTIDX $remote_dir ||
9959 error "create remote directory failed"
9961 cp /etc/hosts $remote_dir/$tfile
9963 fid=$($LFS path2fid $remote_dir/$tfile)
9965 [ $rc -ne 0 ] && error "error: could not get fid for $remote_dir/$tfile"
9967 dot_lustre_fid_permission_check "$fid" $remote_dir ||
9968 error "dot lustre permission check $fid failed"
9971 run_test 154b "Open-by-FID for remote directory"
9974 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.1) ]] &&
9975 skip "Need MDS version at least 2.4.1" && return
9977 touch $DIR/$tfile.1 $DIR/$tfile.2 $DIR/$tfile.3
9978 local FID1=$($LFS path2fid $DIR/$tfile.1)
9979 local FID2=$($LFS path2fid $DIR/$tfile.2)
9980 local FID3=$($LFS path2fid $DIR/$tfile.3)
9983 $LFS path2fid $DIR/$tfile.[123] | while read PATHNAME FID; do
9984 [ "$PATHNAME" = "$DIR/$tfile.$N:" ] ||
9985 error "path2fid pathname $PATHNAME != $DIR/$tfile.$N:"
9987 [ "$FID" = "${!want}" ] ||
9988 error "path2fid $PATHNAME FID $FID != FID$N ${!want}"
9992 $LFS fid2path $MOUNT "$FID1" "$FID2" "$FID3" | while read PATHNAME;
9994 [ "$PATHNAME" = "$DIR/$tfile.$N" ] ||
9995 error "fid2path pathname $PATHNAME != $DIR/$tfile.$N:"
9999 run_test 154c "lfs path2fid and fid2path multiple arguments"
10002 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.5.53) ]] &&
10003 skip "Need MDS version at least 2.5.53" && return
10005 if remote_mds; then
10006 nid=$($LCTL list_nids | sed "s/\./\\\./g")
10010 local proc_ofile="mdt.*.exports.'$nid'.open_files"
10017 local fid=$($LFS path2fid $DIR/$tfile)
10020 cmd="exec $fd<$DIR/$tfile"
10022 local fid_list=$(do_facet $SINGLEMDS $LCTL get_param $proc_ofile)
10023 echo "$fid_list" | grep "$fid"
10026 cmd="exec $fd>/dev/null"
10028 if [ $rc -ne 0 ]; then
10029 error "FID $fid not found in open files list $fid_list"
10032 run_test 154d "Verify open file fid"
10036 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.6.50) ]] &&
10037 skip "Need MDS version at least 2.6.50" && return
10039 if ls -a $MOUNT | grep -q '^\.lustre$'; then
10040 error ".lustre returned by readdir"
10043 run_test 154e ".lustre is not returned by readdir"
10046 # create parent directory on a single MDT to avoid cross-MDT hardlinks
10047 test_mkdir -p -c1 $DIR/$tdir/d
10048 # test dirs inherit from its stripe
10049 mkdir -p $DIR/$tdir/d/foo1 || error "mkdir error"
10050 mkdir -p $DIR/$tdir/d/foo2 || error "mkdir error"
10051 cp /etc/hosts $DIR/$tdir/d/foo1/$tfile
10052 ln $DIR/$tdir/d/foo1/$tfile $DIR/$tdir/d/foo2/link
10055 # get fid of parents
10056 local FID0=$($LFS path2fid $DIR/$tdir/d)
10057 local FID1=$($LFS path2fid $DIR/$tdir/d/foo1)
10058 local FID2=$($LFS path2fid $DIR/$tdir/d/foo2)
10059 local FID3=$($LFS path2fid $DIR)
10061 # check that path2fid --parents returns expected <parent_fid>/name
10062 # 1) test for a directory (single parent)
10063 local parent=$($LFS path2fid --parents $DIR/$tdir/d/foo1)
10064 [ "$parent" == "$FID0/foo1" ] ||
10065 error "expected parent: $FID0/foo1, got: $parent"
10067 # 2) test for a file with nlink > 1 (multiple parents)
10068 parent=$($LFS path2fid --parents $DIR/$tdir/d/foo1/$tfile)
10069 echo "$parent" | grep -F "$FID1/$tfile" ||
10070 error "$FID1/$tfile not returned in parent list"
10071 echo "$parent" | grep -F "$FID2/link" ||
10072 error "$FID2/link not returned in parent list"
10074 # 3) get parent by fid
10075 local file_fid=$($LFS path2fid $DIR/$tdir/d/foo1/$tfile)
10076 parent=$($LFS path2fid --parents $MOUNT/.lustre/fid/$file_fid)
10077 echo "$parent" | grep -F "$FID1/$tfile" ||
10078 error "$FID1/$tfile not returned in parent list (by fid)"
10079 echo "$parent" | grep -F "$FID2/link" ||
10080 error "$FID2/link not returned in parent list (by fid)"
10082 # 4) test for entry in root directory
10083 parent=$($LFS path2fid --parents $DIR/f)
10084 echo "$parent" | grep -F "$FID3/f" ||
10085 error "$FID3/f not returned in parent list"
10087 # 5) test it on root directory
10088 [ -z "$($LFS path2fid --parents $MOUNT 2>/dev/null)" ] ||
10089 error "$MOUNT should not have parents"
10091 # enable xattr caching and check that linkea is correctly updated
10092 local save="$TMP/$TESTSUITE-$TESTNAME.parameters"
10093 save_lustre_params client "llite.*.xattr_cache" > $save
10094 lctl set_param llite.*.xattr_cache 1
10096 # 6.1) linkea update on rename
10097 mv $DIR/$tdir/d/foo1/$tfile $DIR/$tdir/d/foo2/$tfile.moved
10099 # get parents by fid
10100 parent=$($LFS path2fid --parents $MOUNT/.lustre/fid/$file_fid)
10101 # foo1 should no longer be returned in parent list
10102 echo "$parent" | grep -F "$FID1" &&
10103 error "$FID1 should no longer be in parent list"
10104 # the new path should appear
10105 echo "$parent" | grep -F "$FID2/$tfile.moved" ||
10106 error "$FID2/$tfile.moved is not in parent list"
10108 # 6.2) linkea update on unlink
10109 rm -f $DIR/$tdir/d/foo2/link
10110 parent=$($LFS path2fid --parents $MOUNT/.lustre/fid/$file_fid)
10111 # foo2/link should no longer be returned in parent list
10112 echo "$parent" | grep -F "$FID2/link" &&
10113 error "$FID2/link should no longer be in parent list"
10117 restore_lustre_params < $save
10119 run_test 154f "get parent fids by reading link ea"
10123 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.6.92) ]] ||
10124 { skip "Need MDS version at least 2.6.92"; return 0; }
10126 mkdir -p $DIR/$tdir
10127 llapi_fid_test -d $DIR/$tdir
10129 run_test 154g "various llapi FID tests"
10131 test_155_small_load() {
10132 local temp=$TMP/$tfile
10133 local file=$DIR/$tfile
10135 dd if=/dev/urandom of=$temp bs=6096 count=1 || \
10136 error "dd of=$temp bs=6096 count=1 failed"
10138 cancel_lru_locks osc
10139 cmp $temp $file || error "$temp $file differ"
10141 $TRUNCATE $temp 6000
10142 $TRUNCATE $file 6000
10143 cmp $temp $file || error "$temp $file differ (truncate1)"
10145 echo "12345" >>$temp
10146 echo "12345" >>$file
10147 cmp $temp $file || error "$temp $file differ (append1)"
10149 echo "12345" >>$temp
10150 echo "12345" >>$file
10151 cmp $temp $file || error "$temp $file differ (append2)"
10157 test_155_big_load() {
10158 remote_ost_nodsh && skip "remote OST with nodsh" && return
10159 local temp=$TMP/$tfile
10160 local file=$DIR/$tfile
10163 local cache_size=$(do_facet ost$((MAXI+1)) \
10164 "awk '/cache/ {sum+=\\\$4} END {print sum}' /proc/cpuinfo")
10165 local large_file_size=$((cache_size * 2))
10167 echo "OSS cache size: $cache_size KB"
10168 echo "Large file size: $large_file_size KB"
10170 [ $MAXV -le $large_file_size ] && \
10171 skip_env "max available OST size needs > $large_file_size KB" && \
10174 $SETSTRIPE $file -c 1 -i $MAXI || error "$SETSTRIPE $file failed"
10176 dd if=/dev/urandom of=$temp bs=$large_file_size count=1k || \
10177 error "dd of=$temp bs=$large_file_size count=1k failed"
10180 cancel_lru_locks osc
10181 cmp $temp $file || error "$temp $file differ"
10188 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10190 set_cache writethrough on
10191 test_155_small_load
10193 run_test 155a "Verify small file correctness: read cache:on write_cache:on"
10196 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10198 set_cache writethrough off
10199 test_155_small_load
10201 run_test 155b "Verify small file correctness: read cache:on write_cache:off"
10204 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10206 set_cache writethrough on
10207 test_155_small_load
10209 run_test 155c "Verify small file correctness: read cache:off write_cache:on"
10212 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10214 set_cache writethrough off
10215 test_155_small_load
10217 run_test 155d "Verify small file correctness: read cache:off write_cache:off"
10220 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10222 set_cache writethrough on
10225 run_test 155e "Verify big file correctness: read cache:on write_cache:on"
10228 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10230 set_cache writethrough off
10233 run_test 155f "Verify big file correctness: read cache:on write_cache:off"
10236 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10238 set_cache writethrough on
10241 run_test 155g "Verify big file correctness: read cache:off write_cache:on"
10244 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10246 set_cache writethrough off
10249 run_test 155h "Verify big file correctness: read cache:off write_cache:off"
10252 remote_ost_nodsh && skip "remote OST with nodsh" && return
10253 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10257 local file="$DIR/$tfile"
10259 [ "$(facet_fstype ost1)" = "zfs" -a \
10260 $(lustre_version_code ost1 -lt $(version_code 2.6.93)) ] &&
10261 skip "LU-1956/LU-2261: stats not implemented on OSD ZFS" &&
10266 log "Turn on read and write cache"
10268 set_cache writethrough on
10270 log "Write data and read it back."
10271 log "Read should be satisfied from the cache."
10272 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
10274 cancel_lru_locks osc
10275 cat $file >/dev/null
10277 if ! let "AFTER - BEFORE == CPAGES"; then
10278 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
10280 log "cache hits:: before: $BEFORE, after: $AFTER"
10283 log "Read again; it should be satisfied from the cache."
10285 cancel_lru_locks osc
10286 cat $file >/dev/null
10288 if ! let "AFTER - BEFORE == CPAGES"; then
10289 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
10291 log "cache hits:: before: $BEFORE, after: $AFTER"
10294 log "Turn off the read cache and turn on the write cache"
10296 set_cache writethrough on
10298 log "Read again; it should be satisfied from the cache."
10300 cancel_lru_locks osc
10301 cat $file >/dev/null
10303 if ! let "AFTER - BEFORE == CPAGES"; then
10304 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
10306 log "cache hits:: before: $BEFORE, after: $AFTER"
10309 log "Read again; it should not be satisfied from the cache."
10311 cancel_lru_locks osc
10312 cat $file >/dev/null
10314 if ! let "AFTER - BEFORE == 0"; then
10315 error "IN CACHE: before: $BEFORE, after: $AFTER"
10317 log "cache hits:: before: $BEFORE, after: $AFTER"
10320 log "Write data and read it back."
10321 log "Read should be satisfied from the cache."
10322 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
10324 cancel_lru_locks osc
10325 cat $file >/dev/null
10327 if ! let "AFTER - BEFORE == CPAGES"; then
10328 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
10330 log "cache hits:: before: $BEFORE, after: $AFTER"
10333 log "Read again; it should not be satisfied from the cache."
10335 cancel_lru_locks osc
10336 cat $file >/dev/null
10338 if ! let "AFTER - BEFORE == 0"; then
10339 error "IN CACHE: before: $BEFORE, after: $AFTER"
10341 log "cache hits:: before: $BEFORE, after: $AFTER"
10344 log "Turn off read and write cache"
10346 set_cache writethrough off
10348 log "Write data and read it back"
10349 log "It should not be satisfied from the cache."
10351 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
10352 cancel_lru_locks osc
10354 cat $file >/dev/null
10356 if ! let "AFTER - BEFORE == 0"; then
10357 error_ignore bz20762 "IN CACHE: before: $BEFORE, after: $AFTER"
10359 log "cache hits:: before: $BEFORE, after: $AFTER"
10362 log "Turn on the read cache and turn off the write cache"
10364 set_cache writethrough off
10366 log "Write data and read it back"
10367 log "It should not be satisfied from the cache."
10369 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
10371 cancel_lru_locks osc
10372 cat $file >/dev/null
10374 if ! let "AFTER - BEFORE == 0"; then
10375 error_ignore bz20762 "IN CACHE: before: $BEFORE, after: $AFTER"
10377 log "cache hits:: before: $BEFORE, after: $AFTER"
10380 log "Read again; it should be satisfied from the cache."
10382 cancel_lru_locks osc
10383 cat $file >/dev/null
10385 if ! let "AFTER - BEFORE == CPAGES"; then
10386 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
10388 log "cache hits:: before: $BEFORE, after: $AFTER"
10393 run_test 156 "Verification of tunables"
10397 if [[ $MDSCOUNT -gt 1 ]]; then
10398 error_ignore bz17935 $*
10406 local CL_MASK_PARAM="mdd.$MDT0.changelog_mask"
10408 MASK=$(do_facet $SINGLEMDS $LCTL get_param $CL_MASK_PARAM| grep -c "$1")
10410 if [ $MASK -eq 1 ]; then
10411 do_facet $SINGLEMDS $LCTL set_param $CL_MASK_PARAM="-$1"
10413 do_facet $SINGLEMDS $LCTL set_param $CL_MASK_PARAM="+$1"
10417 changelog_extract_field() {
10421 local identifier=$4
10423 $LFS changelog $mdt | gawk "/$cltype.*$file$/ {
10424 print gensub(/^.* "$identifier'(\[[^\]]*\]).*$/,"\\1",1)}' |
10429 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10430 remote_mds_nodsh && skip "remote MDS with nodsh" && return
10431 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] ||
10432 { skip "Need MDS version at least 2.2.0"; return; }
10434 local CL_USERS="mdd.$MDT0.changelog_users"
10435 local GET_CL_USERS="do_facet $SINGLEMDS $LCTL get_param -n $CL_USERS"
10436 USER=$(do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_register -n)
10437 echo "Registered as changelog user $USER"
10438 $GET_CL_USERS | grep -q $USER ||
10439 error "User $USER not found in changelog_users"
10442 test_mkdir -p $DIR/$tdir/pics/2008/zachy
10443 touch $DIR/$tdir/pics/2008/zachy/timestamp
10444 cp /etc/hosts $DIR/$tdir/pics/2008/zachy/pic1.jpg
10445 mv $DIR/$tdir/pics/2008/zachy $DIR/$tdir/pics/zach
10446 ln $DIR/$tdir/pics/zach/pic1.jpg $DIR/$tdir/pics/2008/portland.jpg
10447 ln -s $DIR/$tdir/pics/2008/portland.jpg $DIR/$tdir/pics/desktop.jpg
10448 rm $DIR/$tdir/pics/desktop.jpg
10450 $LFS changelog $MDT0 | tail -5
10452 echo "verifying changelog mask"
10453 changelog_chmask "MKDIR"
10454 changelog_chmask "CLOSE"
10456 test_mkdir -p $DIR/$tdir/pics/zach/sofia
10457 echo "zzzzzz" > $DIR/$tdir/pics/zach/file
10459 changelog_chmask "MKDIR"
10460 changelog_chmask "CLOSE"
10462 test_mkdir -p $DIR/$tdir/pics/2008/sofia
10463 echo "zzzzzz" > $DIR/$tdir/pics/zach/file
10465 $LFS changelog $MDT0
10466 MKDIRS=$($LFS changelog $MDT0 | tail -5 | grep -c "MKDIR")
10467 CLOSES=$($LFS changelog $MDT0 | tail -5 | grep -c "CLOSE")
10468 [ $MKDIRS -eq 1 ] || err17935 "MKDIR changelog mask count $DIRS != 1"
10469 [ $CLOSES -eq 1 ] || err17935 "CLOSE changelog mask count $DIRS != 1"
10472 echo "verifying target fid"
10473 fidc=$(changelog_extract_field $MDT0 "CREAT" "timestamp" "t=")
10474 fidf=$($LFS path2fid $DIR/$tdir/pics/zach/timestamp)
10475 [ "$fidc" == "$fidf" ] ||
10476 err17935 "fid in changelog $fidc != file fid $fidf"
10477 echo "verifying parent fid"
10478 fidc=$(changelog_extract_field $MDT0 "CREAT" "timestamp" "p=")
10479 fidf=$($LFS path2fid $DIR/$tdir/pics/zach)
10480 [ "$fidc" == "$fidf" ] ||
10481 err17935 "pfid in changelog $fidc != dir fid $fidf"
10483 USER_REC1=$($GET_CL_USERS | awk "\$1 == \"$USER\" {print \$2}")
10484 $LFS changelog_clear $MDT0 $USER $(($USER_REC1 + 5))
10485 USER_REC2=$($GET_CL_USERS | awk "\$1 == \"$USER\" {print \$2}")
10486 echo "verifying user clear: $(( $USER_REC1 + 5 )) == $USER_REC2"
10487 [ $USER_REC2 == $(($USER_REC1 + 5)) ] ||
10488 err17935 "user index expected $(($USER_REC1 + 5)) is $USER_REC2"
10490 MIN_REC=$($GET_CL_USERS |
10491 awk 'min == "" || $2 < min {min = $2}; END {print min}')
10492 FIRST_REC=$($LFS changelog $MDT0 | head -n1 | awk '{print $1}')
10493 echo "verifying min purge: $(( $MIN_REC + 1 )) == $FIRST_REC"
10494 [ $FIRST_REC == $(($MIN_REC + 1)) ] ||
10495 err17935 "first index should be $(($MIN_REC + 1)) is $FIRST_REC"
10497 # LU-3446 changelog index reset on MDT restart
10498 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
10499 CUR_REC1=$($GET_CL_USERS | head -n1 | cut -f3 -d' ')
10500 $LFS changelog_clear $MDT0 $USER 0
10501 stop $SINGLEMDS || error "Fail to stop MDT."
10502 start $SINGLEMDS $MDT_DEV $MDS_MOUNT_OPTS || error "Fail to start MDT."
10503 CUR_REC2=$($GET_CL_USERS | head -n1 | cut -f3 -d' ')
10504 echo "verifying index survives MDT restart: $CUR_REC1 == $CUR_REC2"
10505 [ $CUR_REC1 == $CUR_REC2 ] ||
10506 err17935 "current index should be $CUR_REC1 is $CUR_REC2"
10508 echo "verifying user deregister"
10509 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister $USER
10510 $GET_CL_USERS | grep -q $USER &&
10511 error "User $USER still in changelog_users"
10513 USERS=$(( $($GET_CL_USERS | wc -l) - 2 ))
10514 if [ $USERS -eq 0 ]; then
10515 LAST_REC1=$($GET_CL_USERS | head -n1 | cut -f3 -d' ')
10516 touch $DIR/$tdir/chloe
10517 LAST_REC2=$($GET_CL_USERS | head -n1 | cut -f3 -d' ')
10518 echo "verify changelogs are off: $LAST_REC1 == $LAST_REC2"
10519 [ $LAST_REC1 == $LAST_REC2 ] || error "changelogs not off"
10521 echo "$USERS other changelog users; can't verify off"
10524 run_test 160a "changelog sanity"
10526 test_160b() { # LU-3587
10527 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10528 remote_mds_nodsh && skip "remote MDS with nodsh" && return
10529 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] ||
10530 { skip "Need MDS version at least 2.2.0"; return; }
10532 local CL_USERS="mdd.$MDT0.changelog_users"
10533 local GET_CL_USERS="do_facet $SINGLEMDS $LCTL get_param -n $CL_USERS"
10534 USER=$(do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_register -n)
10535 echo "Registered as changelog user $USER"
10536 $GET_CL_USERS | grep -q $USER ||
10537 error "User $USER not found in changelog_users"
10539 local LONGNAME1=$(str_repeat a 255)
10540 local LONGNAME2=$(str_repeat b 255)
10543 echo "creating very long named file"
10544 touch $LONGNAME1 || error "create of $LONGNAME1 failed"
10545 echo "moving very long named file"
10546 mv $LONGNAME1 $LONGNAME2
10548 $LFS changelog $MDT0 | grep RENME
10550 echo "deregistering $USER"
10551 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister $USER
10555 run_test 160b "Verify that very long rename doesn't crash in changelog"
10558 remote_mds_nodsh && skip "remote MDS with nodsh" && return
10561 local server_version=$(lustre_version_code $SINGLEMDS)
10563 [[ $server_version -gt $(version_code 2.5.57) ]] ||
10564 [[ $server_version -gt $(version_code 2.5.1) &&
10565 $server_version -lt $(version_code 2.5.50) ]] ||
10566 { skip "Need MDS version at least 2.5.58 or 2.5.2+"; return; }
10567 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10569 # Registration step
10570 local USER=$(do_facet $SINGLEMDS $LCTL --device $MDT0 \
10571 changelog_register -n)
10574 mkdir -p $DIR/$tdir
10575 $MCREATE $DIR/$tdir/foo_160c
10576 changelog_chmask "TRUNC"
10577 $TRUNCATE $DIR/$tdir/foo_160c 200
10578 changelog_chmask "TRUNC"
10579 $TRUNCATE $DIR/$tdir/foo_160c 199
10580 $LFS changelog $MDT0
10581 TRUNCS=$($LFS changelog $MDT0 | tail -5 | grep -c "TRUNC")
10582 [ $TRUNCS -eq 1 ] || err17935 "TRUNC changelog mask count $TRUNCS != 1"
10583 $LFS changelog_clear $MDT0 $USER 0
10585 # Deregistration step
10586 echo "deregistering $USER"
10587 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister $USER
10589 run_test 160c "verify that changelog log catch the truncate event"
10592 remote_mds_nodsh && skip "remote MDS with nodsh" && return
10593 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
10595 local server_version=$(lustre_version_code mds1)
10596 local CL_MASK_PARAM="mdd.$MDT0.changelog_mask"
10598 [[ $server_version -ge $(version_code 2.7.60) ]] ||
10599 { skip "Need MDS version at least 2.7.60+"; return; }
10600 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10602 # Registration step
10603 local USER=$(do_facet mds1 $LCTL --device $MDT0 \
10604 changelog_register -n)
10606 mkdir -p $DIR/$tdir/migrate_dir
10607 $LFS changelog_clear $MDT0 $USER 0
10609 $LFS migrate -m 1 $DIR/$tdir/migrate_dir || error "migrate fails"
10610 $LFS changelog $MDT0
10611 MIGRATES=$($LFS changelog $MDT0 | tail -5 | grep -c "MIGRT")
10612 $LFS changelog_clear $MDT0 $USER 0
10613 [ $MIGRATES -eq 1 ] ||
10614 error "MIGRATE changelog mask count $MIGRATES != 1"
10616 # Deregistration step
10617 do_facet mds1 $LCTL --device $MDT0 changelog_deregister $USER
10619 run_test 160d "verify that changelog log catch the migrate event"
10622 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10623 test_mkdir -p -c1 $DIR/$tdir
10624 cp /etc/hosts $DIR/$tdir/$tfile
10625 test_mkdir -c1 $DIR/$tdir/foo1
10626 test_mkdir -c1 $DIR/$tdir/foo2
10627 ln $DIR/$tdir/$tfile $DIR/$tdir/foo1/sofia
10628 ln $DIR/$tdir/$tfile $DIR/$tdir/foo2/zachary
10629 ln $DIR/$tdir/$tfile $DIR/$tdir/foo1/luna
10630 ln $DIR/$tdir/$tfile $DIR/$tdir/foo2/thor
10631 local FID=$($LFS path2fid $DIR/$tdir/$tfile | tr -d '[]')
10632 if [ "$($LFS fid2path $DIR $FID | wc -l)" != "5" ]; then
10633 $LFS fid2path $DIR $FID
10634 err17935 "bad link ea"
10637 rm $DIR/$tdir/foo2/zachary
10639 rm $DIR/$tdir/foo2/thor
10641 rm $DIR/$tdir/$tfile
10643 mv $DIR/$tdir/foo1/sofia $DIR/$tdir/foo2/maggie
10644 if [ "$($LFS fid2path $FSNAME --link 1 $FID)" != "$tdir/foo2/maggie" ]
10646 $LFS fid2path $DIR $FID
10647 err17935 "bad link rename"
10649 rm $DIR/$tdir/foo2/maggie
10652 local longname=filename_avg_len_is_thirty_two_
10653 createmany -l$DIR/$tdir/foo1/luna $DIR/$tdir/foo2/$longname 1000 ||
10654 error "failed to hardlink many files"
10655 links=$($LFS fid2path $DIR $FID | wc -l)
10656 echo -n "${links}/1000 links in link EA"
10657 [[ $links -gt 60 ]] ||
10658 err17935 "expected at least 60 links in link EA"
10659 unlinkmany $DIR/$tdir/foo2/$longname 1000 ||
10660 error "failed to unlink many hardlinks"
10662 run_test 161a "link ea sanity"
10665 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10666 [ $MDSCOUNT -lt 2 ] &&
10667 skip "skipping remote directory test" && return
10669 local remote_dir=$DIR/$tdir/remote_dir
10671 mkdir -p $DIR/$tdir
10672 $LFS mkdir -i $MDTIDX $remote_dir ||
10673 error "create remote directory failed"
10675 cp /etc/hosts $remote_dir/$tfile
10676 mkdir -p $remote_dir/foo1
10677 mkdir -p $remote_dir/foo2
10678 ln $remote_dir/$tfile $remote_dir/foo1/sofia
10679 ln $remote_dir/$tfile $remote_dir/foo2/zachary
10680 ln $remote_dir/$tfile $remote_dir/foo1/luna
10681 ln $remote_dir/$tfile $remote_dir/foo2/thor
10683 local FID=$($LFS path2fid $remote_dir/$tfile | tr -d '[' |
10685 if [ "$($LFS fid2path $DIR $FID | wc -l)" != "5" ]; then
10686 $LFS fid2path $DIR $FID
10687 err17935 "bad link ea"
10690 rm $remote_dir/foo2/zachary
10692 rm $remote_dir/foo2/thor
10694 rm $remote_dir/$tfile
10696 mv $remote_dir/foo1/sofia $remote_dir/foo2/maggie
10697 local link_path=$($LFS fid2path $FSNAME --link 1 $FID)
10698 if [ "$DIR/$link_path" != "$remote_dir/foo2/maggie" ]; then
10699 $LFS fid2path $DIR $FID
10700 err17935 "bad link rename"
10702 rm $remote_dir/foo2/maggie
10705 local longname=filename_avg_len_is_thirty_two_
10706 createmany -l$remote_dir/foo1/luna $remote_dir/foo2/$longname 1000 ||
10707 error "failed to hardlink many files"
10708 links=$($LFS fid2path $DIR $FID | wc -l)
10709 echo -n "${links}/1000 links in link EA"
10710 [[ ${links} -gt 60 ]] ||
10711 err17935 "expected at least 60 links in link EA"
10712 unlinkmany $remote_dir/foo2/$longname 1000 ||
10713 error "failed to unlink many hardlinks"
10715 run_test 161b "link ea sanity under remote directory"
10718 remote_mds_nodsh && skip "remote MDS with nodsh" && return
10719 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10720 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.1.5) ]] &&
10721 skip "Need MDS version at least 2.1.5" && return
10723 # define CLF_RENAME_LAST 0x0001
10724 # rename overwrite a target having nlink = 1 (changelog flag 0x1)
10725 local USER=$(do_facet $SINGLEMDS $LCTL --device $MDT0 \
10726 changelog_register -n)
10728 mkdir -p $DIR/$tdir
10729 touch $DIR/$tdir/foo_161c
10730 touch $DIR/$tdir/bar_161c
10731 mv -f $DIR/$tdir/foo_161c $DIR/$tdir/bar_161c
10732 $LFS changelog $MDT0 | grep RENME
10733 local flags=$($LFS changelog $MDT0 | grep RENME | tail -1 | \
10735 $LFS changelog_clear $MDT0 $USER 0
10736 if [ x$flags != "x0x1" ]; then
10737 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister \
10739 error "flag $flags is not 0x1"
10741 echo "rename overwrite a target having nlink = 1," \
10742 "changelog record has flags of $flags"
10744 # rename overwrite a target having nlink > 1 (changelog flag 0x0)
10745 touch $DIR/$tdir/foo_161c
10746 touch $DIR/$tdir/bar_161c
10747 ln $DIR/$tdir/bar_161c $DIR/$tdir/foobar_161c
10748 mv -f $DIR/$tdir/foo_161c $DIR/$tdir/bar_161c
10749 $LFS changelog $MDT0 | grep RENME
10750 flags=$($LFS changelog $MDT0 | grep RENME | tail -1 | cut -f5 -d' ')
10751 $LFS changelog_clear $MDT0 $USER 0
10752 if [ x$flags != "x0x0" ]; then
10753 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister \
10755 error "flag $flags is not 0x0"
10757 echo "rename overwrite a target having nlink > 1," \
10758 "changelog record has flags of $flags"
10760 # rename doesn't overwrite a target (changelog flag 0x0)
10761 touch $DIR/$tdir/foo_161c
10762 mv -f $DIR/$tdir/foo_161c $DIR/$tdir/foo2_161c
10763 $LFS changelog $MDT0 | grep RENME
10764 flags=$($LFS changelog $MDT0 | grep RENME | tail -1 | cut -f5 -d' ')
10765 $LFS changelog_clear $MDT0 $USER 0
10766 if [ x$flags != "x0x0" ]; then
10767 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister \
10769 error "flag $flags is not 0x0"
10771 echo "rename doesn't overwrite a target," \
10772 "changelog record has flags of $flags"
10774 # define CLF_UNLINK_LAST 0x0001
10775 # unlink a file having nlink = 1 (changelog flag 0x1)
10776 rm -f $DIR/$tdir/foo2_161c
10777 $LFS changelog $MDT0 | grep UNLNK
10778 flags=$($LFS changelog $MDT0 | grep UNLNK | tail -1 | cut -f5 -d' ')
10779 $LFS changelog_clear $MDT0 $USER 0
10780 if [ x$flags != "x0x1" ]; then
10781 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister \
10783 error "flag $flags is not 0x1"
10785 echo "unlink a file having nlink = 1," \
10786 "changelog record has flags of $flags"
10788 # unlink a file having nlink > 1 (changelog flag 0x0)
10789 ln -f $DIR/$tdir/bar_161c $DIR/$tdir/foobar_161c
10790 rm -f $DIR/$tdir/foobar_161c
10791 $LFS changelog $MDT0 | grep UNLNK
10792 flags=$($LFS changelog $MDT0 | grep UNLNK | tail -1 | cut -f5 -d' ')
10793 $LFS changelog_clear $MDT0 $USER 0
10794 if [ x$flags != "x0x0" ]; then
10795 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister \
10797 error "flag $flags is not 0x0"
10799 echo "unlink a file having nlink > 1," \
10800 "changelog record has flags of $flags"
10801 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister $USER
10803 run_test 161c "check CL_RENME[UNLINK] changelog record flags"
10810 local path=$(${LFS} fid2path $*)
10811 # Remove the '//' indicating a remote directory
10812 path=$(echo $path | sed 's#//#/#g')
10815 if [ $RC -ne 0 ]; then
10816 err17935 "path looked up of $expected failed. Error $RC"
10818 elif [ "${path}" != "${expected}" ]; then
10819 err17935 "path looked up \"${path}\" instead of \"${expected}\""
10822 echo "fid $fid resolves to path $path (expected $expected)"
10825 test_162a() { # was test_162
10826 # Make changes to filesystem
10827 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10828 test_mkdir -p -c1 $DIR/$tdir/d2
10829 touch $DIR/$tdir/d2/$tfile
10830 touch $DIR/$tdir/d2/x1
10831 touch $DIR/$tdir/d2/x2
10832 test_mkdir -p -c1 $DIR/$tdir/d2/a/b/c
10833 test_mkdir -p -c1 $DIR/$tdir/d2/p/q/r
10835 FID=$($LFS path2fid $DIR/$tdir/d2/$tfile | tr -d '[]')
10836 check_path "$tdir/d2/$tfile" $FSNAME $FID --link 0 ||
10837 error "check path $tdir/d2/$tfile failed"
10840 ln -s $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/p/q/r/slink
10841 FID=$($LFS path2fid $DIR/$tdir/d2/p/q/r/slink | tr -d '[]')
10842 check_path "$tdir/d2/p/q/r/slink" $FSNAME $FID --link 0 ||
10843 error "check path $tdir/d2/p/q/r/slink failed"
10845 # softlink to wrong file
10846 ln -s /this/is/garbage $DIR/$tdir/d2/p/q/r/slink.wrong
10847 FID=$($LFS path2fid $DIR/$tdir/d2/p/q/r/slink.wrong | tr -d '[]')
10848 check_path "$tdir/d2/p/q/r/slink.wrong" $FSNAME $FID --link 0 ||
10849 error "check path $tdir/d2/p/q/r/slink.wrong failed"
10852 ln $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/p/q/r/hlink
10853 mv $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/a/b/c/new_file
10854 FID=$($LFS path2fid $DIR/$tdir/d2/a/b/c/new_file | tr -d '[]')
10855 # fid2path dir/fsname should both work
10856 check_path "$tdir/d2/a/b/c/new_file" $FSNAME $FID --link 1 ||
10857 error "check path $tdir/d2/a/b/c/new_file failed"
10858 check_path "$DIR/$tdir/d2/p/q/r/hlink" $DIR $FID --link 0 ||
10859 error "check path $DIR/$tdir/d2/p/q/r/hlink failed"
10861 # hardlink count: check that there are 2 links
10862 # Doesnt work with CMD yet: 17935
10863 ${LFS} fid2path $DIR $FID | wc -l | grep -q 2 || \
10864 err17935 "expected 2 links"
10866 # hardlink indexing: remove the first link
10867 rm $DIR/$tdir/d2/p/q/r/hlink
10868 check_path "$tdir/d2/a/b/c/new_file" $FSNAME $FID --link 0 ||
10869 error "check path $DIR/$tdir/d2/a/b/c/new_file failed"
10873 run_test 162a "path lookup sanity"
10876 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10877 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
10880 $LFS setdirstripe -i0 -c$MDSCOUNT -t all_char $DIR/$tdir/striped_dir ||
10881 error "create striped dir failed"
10883 local FID=$($LFS getdirstripe $DIR/$tdir/striped_dir |
10884 tail -n 1 | awk '{print $2}')
10885 stat $MOUNT/.lustre/fid/$FID && error "sub_stripe can be accessed"
10887 touch $DIR/$tdir/striped_dir/f{0..4} || error "touch f0..4 failed"
10888 mkdir $DIR/$tdir/striped_dir/d{0..4} || error "mkdir d0..4 failed"
10891 for ((i=0;i<5;i++)); do
10892 FID=$($LFS path2fid $DIR/$tdir/striped_dir/f$i | tr -d '[]') ||
10893 error "get fid for f$i failed"
10894 check_path "$tdir/striped_dir/f$i" $FSNAME $FID --link 0 ||
10895 error "check path $tdir/striped_dir/f$i failed"
10897 FID=$($LFS path2fid $DIR/$tdir/striped_dir/d$i | tr -d '[]') ||
10898 error "get fid for d$i failed"
10899 check_path "$tdir/striped_dir/d$i" $FSNAME $FID --link 0 ||
10900 error "check path $tdir/striped_dir/d$i failed"
10905 run_test 162b "striped directory path lookup sanity"
10907 # LU-4239: Verify fid2path works with paths 100 or more directories deep
10909 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.51) ]] &&
10910 skip "Need MDS version at least 2.7.51" && return
10911 test_mkdir $DIR/$tdir.local
10912 test_mkdir $DIR/$tdir.remote
10913 local lpath=$tdir.local
10914 local rpath=$tdir.remote
10916 for ((i = 0; i <= 101; i++)); do
10919 FID=$($LFS path2fid $DIR/$lpath | tr -d '[]') ||
10920 error "get fid for local directory $DIR/$lpath failed"
10921 check_path "$DIR/$lpath" $MOUNT $FID --link 0 ||
10922 error "check path for local directory $DIR/$lpath failed"
10925 test_mkdir $DIR/$rpath
10926 FID=$($LFS path2fid $DIR/$rpath | tr -d '[]') ||
10927 error "get fid for remote directory $DIR/$rpath failed"
10928 check_path "$DIR/$rpath" $MOUNT $FID --link 0 ||
10929 error "check path for remote directory $DIR/$rpath failed"
10934 run_test 162c "fid2path works with paths 100 or more directories deep"
10937 # do directio so as not to populate the page cache
10938 log "creating a 10 Mb file"
10939 $MULTIOP $DIR/$tfile oO_CREAT:O_DIRECT:O_RDWR:w$((10*1048576))c || error "multiop failed while creating a file"
10940 log "starting reads"
10941 dd if=$DIR/$tfile of=/dev/null bs=4096 &
10942 log "truncating the file"
10943 $MULTIOP $DIR/$tfile oO_TRUNC:c || error "multiop failed while truncating the file"
10945 kill %+ || true # reads might have finished
10946 echo "wait until dd is finished"
10948 log "removing the temporary file"
10949 rm -rf $DIR/$tfile || error "tmp file removal failed"
10951 run_test 169 "parallel read and truncate should not deadlock"
10954 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10955 $LCTL clear # bug 18514
10956 $LCTL debug_daemon start $TMP/${tfile}_log_good
10958 $LCTL debug_daemon stop
10959 sed -e "s/^...../a/g" $TMP/${tfile}_log_good > $TMP/${tfile}_log_bad ||
10960 error "sed failed to read log_good"
10962 $LCTL debug_daemon start $TMP/${tfile}_log_good
10964 $LCTL debug_daemon stop
10966 $LCTL df $TMP/${tfile}_log_bad > $TMP/${tfile}_log_bad.out 2>&1 ||
10967 error "lctl df log_bad failed"
10969 local bad_line=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $9}')
10970 local good_line1=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $5}')
10972 $LCTL df $TMP/${tfile}_log_good > $TMP/${tfile}_log_good.out 2>&1
10973 local good_line2=$(tail -n 1 $TMP/${tfile}_log_good.out | awk '{print $5}')
10975 [ "$bad_line" ] && [ "$good_line1" ] && [ "$good_line2" ] ||
10976 error "bad_line good_line1 good_line2 are empty"
10978 cat $TMP/${tfile}_log_good >> $TMP/${tfile}_logs_corrupt
10979 cat $TMP/${tfile}_log_bad >> $TMP/${tfile}_logs_corrupt
10980 cat $TMP/${tfile}_log_good >> $TMP/${tfile}_logs_corrupt
10982 $LCTL df $TMP/${tfile}_logs_corrupt > $TMP/${tfile}_log_bad.out 2>&1
10983 local bad_line_new=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $9}')
10984 local good_line_new=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $5}')
10986 [ "$bad_line_new" ] && [ "$good_line_new" ] ||
10987 error "bad_line_new good_line_new are empty"
10989 local expected_good=$((good_line1 + good_line2*2))
10991 rm -f $TMP/${tfile}*
10992 # LU-231, short malformed line may not be counted into bad lines
10993 if [ $bad_line -ne $bad_line_new ] &&
10994 [ $bad_line -ne $((bad_line_new - 1)) ]; then
10995 error "expected $bad_line bad lines, but got $bad_line_new"
10999 if [ $expected_good -ne $good_line_new ]; then
11000 error "expected $expected_good good lines, but got $good_line_new"
11005 run_test 170 "test lctl df to handle corrupted log ====================="
11007 test_171() { # bug20592
11008 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11009 #define OBD_FAIL_PTLRPC_DUMP_LOG 0x50e
11010 $LCTL set_param fail_loc=0x50e
11011 $LCTL set_param fail_val=3000
11012 multiop_bg_pause $DIR/$tfile O_s || true
11014 kill -USR1 $MULTIPID
11018 if dmesg | grep "recursive fault"; then
11019 error "caught a recursive fault"
11021 $LCTL set_param fail_loc=0
11024 run_test 171 "test libcfs_debug_dumplog_thread stuck in do_exit() ======"
11026 # it would be good to share it with obdfilter-survey/iokit-libecho code
11027 setup_obdecho_osc () {
11030 local obdfilter_name=$2
11031 echo "Creating new osc for $obdfilter_name on $ost_nid"
11032 # make sure we can find loopback nid
11033 $LCTL add_uuid $ost_nid $ost_nid >/dev/null 2>&1
11035 [ $rc -eq 0 ] && { $LCTL attach osc ${obdfilter_name}_osc \
11036 ${obdfilter_name}_osc_UUID || rc=2; }
11037 [ $rc -eq 0 ] && { $LCTL --device ${obdfilter_name}_osc setup \
11038 ${obdfilter_name}_UUID $ost_nid || rc=3; }
11042 cleanup_obdecho_osc () {
11043 local obdfilter_name=$1
11044 $LCTL --device ${obdfilter_name}_osc cleanup >/dev/null
11045 $LCTL --device ${obdfilter_name}_osc detach >/dev/null
11052 local pages=${3:-64}
11057 local obd_size=$(get_obd_size $node $OBD)
11058 local page_size=$(get_page_size $node)
11059 if [[ -n "$obd_size" ]]; then
11060 local new_count=$((obd_size / (pages * page_size / 1024)))
11061 [[ $new_count -ge $count ]] || count=$new_count
11064 do_facet $node "$LCTL attach echo_client ec ec_uuid" || rc=1
11065 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec setup $OBD" ||
11067 if [ $rc -eq 0 ]; then
11068 id=$(do_facet $node "$LCTL --device ec create 1" | awk '/object id/ {print $6}')
11069 [ ${PIPESTATUS[0]} -eq 0 -a -n "$id" ] || rc=3
11071 echo "New object id is $id"
11072 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec getattr $id" ||
11074 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec " \
11075 "test_brw $count w v $pages $id" || rc=4; }
11076 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec destroy $id 1" ||
11078 [ $rc -eq 0 -o $rc -gt 2 ] && { do_facet $node "$LCTL --device ec " \
11079 "cleanup" || rc=5; }
11080 [ $rc -eq 0 -o $rc -gt 1 ] && { do_facet $node "$LCTL --device ec " \
11081 "detach" || rc=6; }
11082 [ $rc -ne 0 ] && echo "obecho_create_test failed: $rc"
11087 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11088 remote_ost_nodsh && skip "remote OST with nodsh" && return
11090 local rmmod_local=0
11092 if ! module_loaded obdecho; then
11093 load_module obdecho/obdecho
11097 local osc=$($LCTL dl | grep -v mdt | awk '$3 == "osc" {print $4; exit}')
11098 local host=$(lctl get_param -n osc.$osc.import |
11099 awk '/current_connection:/ {print $2}' )
11100 local target=$(lctl get_param -n osc.$osc.import |
11101 awk '/target:/ {print $2}' )
11102 target=${target%_UUID}
11104 [[ -n $target ]] && { setup_obdecho_osc $host $target || rc=1; } || rc=1
11105 [ $rc -eq 0 ] && { obdecho_test ${target}_osc client || rc=2; }
11106 [[ -n $target ]] && cleanup_obdecho_osc $target
11107 [ $rmmod_local -eq 1 ] && rmmod obdecho
11110 run_test 180a "test obdecho on osc"
11113 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11114 remote_ost_nodsh && skip "remote OST with nodsh" && return
11116 local rmmod_remote=0
11118 do_facet ost1 "lsmod | grep -q obdecho || " \
11119 "{ insmod ${LUSTRE}/obdecho/obdecho.ko || " \
11120 "modprobe obdecho; }" && rmmod_remote=1
11121 target=$(do_facet ost1 $LCTL dl | awk '/obdfilter/ {print $4;exit}')
11122 [[ -n $target ]] && { obdecho_test $target ost1 || rc=1; }
11123 [ $rmmod_remote -eq 1 ] && do_facet ost1 "rmmod obdecho"
11126 run_test 180b "test obdecho directly on obdfilter"
11128 test_180c() { # LU-2598
11129 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11130 remote_ost_nodsh && skip "remote OST with nodsh" && return
11131 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.0) ]] &&
11132 skip "Need MDS version at least 2.4.0" && return
11135 local rmmod_remote=false
11136 local pages=16384 # 64MB bulk I/O RPC size
11139 do_rpc_nodes $(facet_active_host ost1) load_module obdecho/obdecho &&
11140 rmmod_remote=true || error "failed to load module obdecho"
11142 target=$(do_facet ost1 $LCTL dl | awk '/obdfilter/ { print $4 }' |
11144 if [ -n "$target" ]; then
11145 obdecho_test "$target" ost1 "$pages" || rc=${PIPESTATUS[0]}
11147 echo "there is no obdfilter target on ost1"
11150 $rmmod_remote && do_facet ost1 "rmmod obdecho" || true
11153 run_test 180c "test huge bulk I/O size on obdfilter, don't LASSERT"
11155 test_181() { # bug 22177
11156 test_mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
11157 # create enough files to index the directory
11158 createmany -o $DIR/$tdir/foobar 4000
11159 # print attributes for debug purpose
11162 multiop_bg_pause $DIR/$tdir D_Sc || return 1
11164 # remove the files & current working dir
11165 unlinkmany $DIR/$tdir/foobar 4000
11167 kill -USR1 $MULTIPID
11169 stat $DIR/$tdir && error "open-unlinked dir was not removed!"
11172 run_test 181 "Test open-unlinked dir ========================"
11178 mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
11180 $LCTL set_param mdc.*.rpc_stats=clear
11182 for (( i = 0; i < $tcount; i++ )) ; do
11183 mkdir $DIR/$tdir/$i
11186 for (( i = 0; i < $tcount; i++ )) ; do
11187 createmany -o $DIR/$tdir/$i/f- $fcount &
11191 for (( i = 0; i < $tcount; i++ )) ; do
11192 unlinkmany $DIR/$tdir/$i/f- $fcount &
11196 $LCTL get_param mdc.*.rpc_stats
11200 run_test 182 "Test parallel modify metadata operations ================"
11202 test_183() { # LU-2275
11203 remote_mds_nodsh && skip "remote MDS with nodsh" && return
11204 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.3.56) ]] &&
11205 skip "Need MDS version at least 2.3.56" && return
11207 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11208 mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
11209 echo aaa > $DIR/$tdir/$tfile
11211 #define OBD_FAIL_MDS_NEGATIVE_POSITIVE 0x148
11212 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x148
11214 ls -l $DIR/$tdir && error "ls succeeded, should have failed"
11215 cat $DIR/$tdir/$tfile && error "cat succeeded, should have failed"
11217 do_facet $SINGLEMDS $LCTL set_param fail_loc=0
11219 # Flush negative dentry cache
11220 touch $DIR/$tdir/$tfile
11222 # We are not checking for any leaked references here, they'll
11223 # become evident next time we do cleanup with module unload.
11226 run_test 183 "No crash or request leak in case of strange dispositions ========"
11228 # test suite 184 is for LU-2016, LU-2017
11230 check_swap_layouts_support && return 0
11232 dir0=$DIR/$tdir/$testnum
11233 test_mkdir -p -c1 $dir0 || error "creating dir $dir0"
11238 $SETSTRIPE -c1 $file1
11240 $SETSTRIPE -c2 $file2
11242 gen1=$($GETSTRIPE -g $file1)
11243 gen2=$($GETSTRIPE -g $file2)
11245 $LFS swap_layouts $file1 $file2 || error "swap of file layout failed"
11246 gen=$($GETSTRIPE -g $file1)
11247 [[ $gen1 != $gen ]] ||
11248 "Layout generation on $file1 does not change"
11249 gen=$($GETSTRIPE -g $file2)
11250 [[ $gen2 != $gen ]] ||
11251 "Layout generation on $file2 does not change"
11253 cmp $ref1 $file2 || error "content compare failed ($ref1 != $file2)"
11254 cmp $ref2 $file1 || error "content compare failed ($ref2 != $file1)"
11256 run_test 184a "Basic layout swap"
11259 check_swap_layouts_support && return 0
11261 dir0=$DIR/$tdir/$testnum
11262 mkdir -p $dir0 || error "creating dir $dir0"
11269 $SETSTRIPE -c1 $file1
11270 $SETSTRIPE -c2 $file2
11271 $SETSTRIPE -c1 $file3
11272 chown $RUNAS_ID $file3
11273 gen1=$($GETSTRIPE -g $file1)
11274 gen2=$($GETSTRIPE -g $file2)
11276 $LFS swap_layouts $dir1 $dir2 &&
11277 error "swap of directories layouts should fail"
11278 $LFS swap_layouts $dir1 $file1 &&
11279 error "swap of directory and file layouts should fail"
11280 $RUNAS $LFS swap_layouts $file1 $file2 &&
11281 error "swap of file we cannot write should fail"
11282 $LFS swap_layouts $file1 $file3 &&
11283 error "swap of file with different owner should fail"
11284 /bin/true # to clear error code
11286 run_test 184b "Forbidden layout swap (will generate errors)"
11289 check_swap_layouts_support && return 0
11291 local dir0=$DIR/$tdir/$testnum
11292 mkdir -p $dir0 || error "creating dir $dir0"
11294 local ref1=$dir0/ref1
11295 local ref2=$dir0/ref2
11296 local file1=$dir0/file1
11297 local file2=$dir0/file2
11298 # create a file large enough for the concurrent test
11299 dd if=/dev/urandom of=$ref1 bs=1M count=$((RANDOM % 50 + 20))
11300 dd if=/dev/urandom of=$ref2 bs=1M count=$((RANDOM % 50 + 20))
11301 echo "ref file size: ref1($(stat -c %s $ref1))," \
11302 "ref2($(stat -c %s $ref2))"
11305 dd if=$ref1 of=$file1 bs=16k &
11308 # Make sure dd starts to copy file
11309 while [ ! -f $file1 ]; do sleep 0.1; done
11311 $LFS swap_layouts $file1 $file2
11314 [[ $? == 0 ]] || error "concurrent write on $file1 failed"
11315 [[ $rc == 0 ]] || error "swap of $file1 and $file2 failed"
11317 # how many bytes copied before swapping layout
11318 local copied=$(stat -c %s $file2)
11319 local remaining=$(stat -c %s $ref1)
11320 remaining=$((remaining - copied))
11321 echo "Copied $copied bytes before swapping layout..."
11323 cmp -n $copied $file1 $ref2 | grep differ &&
11324 error "Content mismatch [0, $copied) of ref2 and file1"
11325 cmp -n $copied $file2 $ref1 ||
11326 error "Content mismatch [0, $copied) of ref1 and file2"
11327 cmp -i $copied:$copied -n $remaining $file1 $ref1 ||
11328 error "Content mismatch [$copied, EOF) of ref1 and file1"
11331 rm -f $ref1 $ref2 $file1 $file2
11333 run_test 184c "Concurrent write and layout swap"
11336 check_swap_layouts_support && return 0
11337 [ -z "$(which getfattr 2>/dev/null)" ] &&
11338 skip "no getfattr command" && return 0
11340 local file1=$DIR/$tdir/$tfile-1
11341 local file2=$DIR/$tdir/$tfile-2
11342 local file3=$DIR/$tdir/$tfile-3
11346 mkdir -p $DIR/$tdir
11347 touch $file1 || error "create $file1 failed"
11348 $OPENFILE -f O_CREAT:O_LOV_DELAY_CREATE $file2 ||
11349 error "create $file2 failed"
11350 $OPENFILE -f O_CREAT:O_LOV_DELAY_CREATE $file3 ||
11351 error "create $file3 failed"
11352 lovea1=$($LFS getstripe $file1 | sed 1d)
11354 $LFS swap_layouts $file2 $file3 ||
11355 error "swap $file2 $file3 layouts failed"
11356 $LFS swap_layouts $file1 $file2 ||
11357 error "swap $file1 $file2 layouts failed"
11359 lovea2=$($LFS getstripe $file2 | sed 1d)
11360 [ "$lovea1" == "$lovea2" ] || error "lovea $lovea1 != $lovea2"
11362 lovea1=$(getfattr -n trusted.lov $file1 | grep ^trusted)
11363 [[ -z "$lovea1" ]] || error "$file1 shouldn't have lovea"
11365 run_test 184d "allow stripeless layouts swap"
11368 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.6.94) ]] ||
11369 { skip "Need MDS version at least 2.6.94"; return 0; }
11370 check_swap_layouts_support && return 0
11371 [ -z "$(which getfattr 2>/dev/null)" ] &&
11372 skip "no getfattr command" && return 0
11374 local file1=$DIR/$tdir/$tfile-1
11375 local file2=$DIR/$tdir/$tfile-2
11376 local file3=$DIR/$tdir/$tfile-3
11379 mkdir -p $DIR/$tdir
11380 touch $file1 || error "create $file1 failed"
11381 $OPENFILE -f O_CREAT:O_LOV_DELAY_CREATE $file2 ||
11382 error "create $file2 failed"
11383 $OPENFILE -f O_CREAT:O_LOV_DELAY_CREATE $file3 ||
11384 error "create $file3 failed"
11386 $LFS swap_layouts $file1 $file2 ||
11387 error "swap $file1 $file2 layouts failed"
11389 lovea=$(getfattr -n trusted.lov $file1 | grep ^trusted)
11390 [[ -z "$lovea" ]] || error "$file1 shouldn't have lovea"
11392 echo 123 > $file1 || error "Should be able to write into $file1"
11394 $LFS swap_layouts $file1 $file3 ||
11395 error "swap $file1 $file3 layouts failed"
11397 echo 123 > $file1 || error "Should be able to write into $file1"
11399 rm -rf $file1 $file2 $file3
11401 run_test 184e "Recreate layout after stripeless layout swaps"
11403 test_185() { # LU-2441
11404 # LU-3553 - no volatile file support in old servers
11405 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.3.60) ]] ||
11406 { skip "Need MDS version at least 2.3.60"; return 0; }
11408 mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
11409 touch $DIR/$tdir/spoo
11410 local mtime1=$(stat -c "%Y" $DIR/$tdir)
11411 local fid=$($MULTIOP $DIR/$tdir VFw4096c) ||
11412 error "cannot create/write a volatile file"
11413 $CHECKSTAT -t file $MOUNT/.lustre/fid/$fid 2>/dev/null &&
11414 error "FID is still valid after close"
11416 multiop_bg_pause $DIR/$tdir vVw4096_c
11423 # assume that the next FID for this client is sequential, since stdout
11424 # is unfortunately eaten by multiop_bg_pause
11425 local n=$((${fidv[1]} + 1))
11426 local next_fid="${fidv[0]}:$(printf "0x%x" $n):${fidv[2]}"
11427 $CHECKSTAT -t file $MOUNT/.lustre/fid/$next_fid ||
11428 error "FID is missing before close"
11429 kill -USR1 $multi_pid
11430 # 1 second delay, so if mtime change we will see it
11432 local mtime2=$(stat -c "%Y" $DIR/$tdir)
11433 [[ $mtime1 == $mtime2 ]] || error "mtime has changed"
11435 run_test 185 "Volatile file support"
11438 remote_mds_nodsh && skip "remote MDS with nodsh" && return
11439 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.3.0) ] &&
11440 skip "Need MDS version at least 2.3.0" && return
11442 local dir0=$DIR/$tdir/$testnum
11443 mkdir -p $dir0 || error "creating dir $dir0"
11445 local file=$dir0/file1
11446 dd if=/dev/urandom of=$file count=10 bs=1M conv=fsync
11447 local dv1=$($LFS data_version $file)
11448 dd if=/dev/urandom of=$file seek=10 count=1 bs=1M conv=fsync
11449 local dv2=$($LFS data_version $file)
11450 [[ $dv1 != $dv2 ]] ||
11451 error "data version did not change on write $dv1 == $dv2"
11456 run_test 187a "Test data version change"
11459 remote_mds_nodsh && skip "remote MDS with nodsh" && return
11460 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.3.0) ] &&
11461 skip "Need MDS version at least 2.3.0" && return
11463 local dir0=$DIR/$tdir/$testnum
11464 mkdir -p $dir0 || error "creating dir $dir0"
11466 declare -a DV=$($MULTIOP $dir0 Vw1000xYw1000xY | cut -f3 -d" ")
11467 [[ ${DV[0]} != ${DV[1]} ]] ||
11468 error "data version did not change on write"\
11469 " ${DV[0]} == ${DV[1]}"
11474 run_test 187b "Test data version change on volatile file"
11477 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11478 remote_mgs_nodsh && skip "remote MGS with nodsh" && return
11480 local POOL=${POOL:-cea1}
11481 local POOL_ROOT=${POOL_ROOT:-$DIR/d200.pools}
11482 local POOL_DIR_NAME=${POOL_DIR_NAME:-dir_tst}
11485 local last_ost=$(($OSTCOUNT - 1))
11487 local ost_list=$(seq $first_ost $ost_step $last_ost)
11488 local ost_range="$first_ost $last_ost $ost_step"
11489 local test_path=$POOL_ROOT/$POOL_DIR_NAME
11490 local file_dir=$POOL_ROOT/file_tst
11491 local subdir=$test_path/subdir
11495 # former test_200a test_200b
11496 pool_add $POOL || { rc=$? ; break; }
11497 pool_add_targets $POOL $ost_range || { rc=$? ; break; }
11498 # former test_200c test_200d
11499 mkdir -p $test_path
11500 pool_set_dir $POOL $test_path || { rc=$? ; break; }
11501 pool_check_dir $POOL $test_path || { rc=$? ; break; }
11503 pool_check_dir $POOL $subdir || { rc=$? ; break; }
11504 pool_dir_rel_path $POOL $POOL_DIR_NAME $POOL_ROOT \
11505 || { rc=$? ; break; }
11506 # former test_200e test_200f
11507 local files=$((OSTCOUNT*3))
11508 pool_alloc_files $POOL $test_path $files "$ost_list" \
11509 || { rc=$? ; break; }
11510 pool_create_files $POOL $file_dir $files "$ost_list" \
11511 || { rc=$? ; break; }
11512 # former test_200g test_200h
11513 pool_lfs_df $POOL || { rc=$? ; break; }
11514 pool_file_rel_path $POOL $test_path || { rc=$? ; break; }
11516 # former test_201a test_201b test_201c
11517 pool_remove_first_target $POOL || { rc=$? ; break; }
11519 local f=$test_path/$tfile
11520 pool_remove_all_targets $POOL $f || { rc=$? ; break; }
11521 pool_remove $POOL $f || { rc=$? ; break; }
11528 run_test 200 "OST pools"
11530 # usage: default_attr <count | size | offset>
11532 $LCTL get_param -n lov.$FSNAME-clilov-\*.stripe${1}
11535 # usage: check_default_stripe_attr
11536 check_default_stripe_attr() {
11537 ACTUAL=$($GETSTRIPE $* $DIR/$tdir)
11539 --stripe-count|--count)
11540 [ -n "$2" ] && EXPECTED=0 || EXPECTED=$(default_attr count);;
11541 --stripe-size|--size)
11542 [ -n "$2" ] && EXPECTED=0 || EXPECTED=$(default_attr size);;
11543 --stripe-index|--index)
11546 error "unknown getstripe attr '$1'"
11549 [ $ACTUAL != $EXPECTED ] &&
11550 error "$DIR/$tdir has $1 '$ACTUAL', not '$EXPECTED'"
11554 test_mkdir -p $DIR/$tdir
11555 $SETSTRIPE --stripe-count 0 --stripe-size 0 --stripe-index -1 $DIR/$tdir
11557 check_default_stripe_attr --stripe-count
11558 check_default_stripe_attr --stripe-size
11559 check_default_stripe_attr --stripe-index
11563 run_test 204a "Print default stripe attributes ================="
11566 test_mkdir -p $DIR/$tdir
11567 $SETSTRIPE --stripe-count 1 $DIR/$tdir
11569 check_default_stripe_attr --stripe-size
11570 check_default_stripe_attr --stripe-index
11574 run_test 204b "Print default stripe size and offset ==========="
11577 test_mkdir -p $DIR/$tdir
11578 $SETSTRIPE --stripe-size 65536 $DIR/$tdir
11580 check_default_stripe_attr --stripe-count
11581 check_default_stripe_attr --stripe-index
11585 run_test 204c "Print default stripe count and offset ==========="
11588 test_mkdir -p $DIR/$tdir
11589 $SETSTRIPE --stripe-index 0 $DIR/$tdir
11591 check_default_stripe_attr --stripe-count
11592 check_default_stripe_attr --stripe-size
11596 run_test 204d "Print default stripe count and size ============="
11599 test_mkdir -p $DIR/$tdir
11600 $SETSTRIPE -d $DIR/$tdir
11602 check_default_stripe_attr --stripe-count --raw
11603 check_default_stripe_attr --stripe-size --raw
11604 check_default_stripe_attr --stripe-index --raw
11608 run_test 204e "Print raw stripe attributes ================="
11611 test_mkdir -p $DIR/$tdir
11612 $SETSTRIPE --stripe-count 1 $DIR/$tdir
11614 check_default_stripe_attr --stripe-size --raw
11615 check_default_stripe_attr --stripe-index --raw
11619 run_test 204f "Print raw stripe size and offset ==========="
11622 test_mkdir -p $DIR/$tdir
11623 $SETSTRIPE --stripe-size 65536 $DIR/$tdir
11625 check_default_stripe_attr --stripe-count --raw
11626 check_default_stripe_attr --stripe-index --raw
11630 run_test 204g "Print raw stripe count and offset ==========="
11633 test_mkdir -p $DIR/$tdir
11634 $SETSTRIPE --stripe-index 0 $DIR/$tdir
11636 check_default_stripe_attr --stripe-count --raw
11637 check_default_stripe_attr --stripe-size --raw
11641 run_test 204h "Print raw stripe count and size ============="
11643 # Figure out which job scheduler is being used, if any,
11644 # or use a fake one
11645 if [ -n "$SLURM_JOB_ID" ]; then # SLURM
11646 JOBENV=SLURM_JOB_ID
11647 elif [ -n "$LSB_JOBID" ]; then # Load Sharing Facility
11649 elif [ -n "$PBS_JOBID" ]; then # PBS/Maui/Moab
11651 elif [ -n "$LOADL_STEPID" ]; then # LoadLeveller
11652 JOBENV=LOADL_STEP_ID
11653 elif [ -n "$JOB_ID" ]; then # Sun Grid Engine
11656 $LCTL list_param jobid_name > /dev/null 2>&1
11657 if [ $? -eq 0 ]; then
11664 verify_jobstats() {
11669 # we don't really need to clear the stats for this test to work, since each
11670 # command has a unique jobid, but it makes debugging easier if needed.
11671 # for facet in $facets; do
11672 # local dev=$(convert_facet2label $facet)
11673 # # clear old jobstats
11674 # do_facet $facet lctl set_param *.$dev.job_stats="clear"
11677 # use a new JobID for each test, or we might see an old one
11678 [ "$JOBENV" = "FAKE_JOBID" ] &&
11679 FAKE_JOBID=id.$testnum.$(basename ${cmd[0]}).$RANDOM
11683 [ "$JOBENV" = "nodelocal" ] && {
11684 FAKE_JOBID=id.$testnum.$(basename ${cmd[0]}).$RANDOM
11685 $LCTL set_param jobid_name=$FAKE_JOBID
11689 log "Test: ${cmd[*]}"
11690 log "Using JobID environment variable $JOBENV=$JOBVAL"
11692 if [ $JOBENV = "FAKE_JOBID" ]; then
11693 FAKE_JOBID=$JOBVAL ${cmd[*]}
11698 # all files are created on OST0000
11699 for facet in $facets; do
11700 local stats="*.$(convert_facet2label $facet).job_stats"
11701 if [ $(do_facet $facet lctl get_param $stats |
11702 grep -c $JOBVAL) -ne 1 ]; then
11703 do_facet $facet lctl get_param $stats
11704 error "No jobstats for $JOBVAL found on $facet::$stats"
11711 NEW_JOBENV=${1:-$OLD_JOBENV}
11712 do_facet mgs $LCTL conf_param $FSNAME.sys.jobid_var=$NEW_JOBENV
11713 wait_update $HOSTNAME "$LCTL get_param -n jobid_var" $NEW_JOBENV
11717 do_facet $SINGLEMDS \
11718 $LCTL set_param mdt.*.job_cleanup_interval=$OLD_INTERVAL
11719 [ $OLD_JOBENV != $JOBENV ] && jobstats_set $OLD_JOBENV
11720 do_facet $SINGLEMDS lctl --device $MDT0 changelog_deregister $CL_USER
11723 test_205() { # Job stats
11724 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11725 remote_mgs_nodsh && skip "remote MGS with nodsh" && return
11726 remote_mds_nodsh && skip "remote MDS with nodsh" && return
11727 remote_ost_nodsh && skip "remote OST with nodsh" && return
11729 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep jobstats)" ] &&
11730 skip "Server doesn't support jobstats" && return 0
11731 [[ $JOBID_VAR = disable ]] && skip "jobstats is disabled" && return
11733 OLD_JOBENV=$($LCTL get_param -n jobid_var)
11734 if [ $OLD_JOBENV != $JOBENV ]; then
11735 jobstats_set $JOBENV
11736 trap cleanup_205 EXIT
11739 CL_USER=$(do_facet $SINGLEMDS lctl --device $MDT0 changelog_register -n)
11740 echo "Registered as changelog user $CL_USER"
11742 OLD_INTERVAL=$(do_facet $SINGLEMDS \
11743 lctl get_param -n mdt.*.job_cleanup_interval)
11744 local interval_new=5
11745 do_facet $SINGLEMDS \
11746 $LCTL set_param mdt.*.job_cleanup_interval=$interval_new
11747 local start=$SECONDS
11751 cmd="mkdir $DIR/$tdir"
11752 verify_jobstats "$cmd" "$SINGLEMDS"
11754 cmd="rmdir $DIR/$tdir"
11755 verify_jobstats "$cmd" "$SINGLEMDS"
11756 # mkdir on secondary MDT
11757 if [ $MDSCOUNT -gt 1 ]; then
11758 cmd="lfs mkdir -i 1 $DIR/$tdir.remote"
11759 verify_jobstats "$cmd" "mds2"
11762 cmd="mknod $DIR/$tfile c 1 3"
11763 verify_jobstats "$cmd" "$SINGLEMDS"
11765 cmd="rm -f $DIR/$tfile"
11766 verify_jobstats "$cmd" "$SINGLEMDS"
11767 # create all files on OST0000 so verify_jobstats can find OST stats
11769 cmd="$SETSTRIPE -i 0 -c 1 $DIR/$tfile"
11770 verify_jobstats "$cmd" "$SINGLEMDS"
11772 cmd="touch $DIR/$tfile"
11773 verify_jobstats "$cmd" "$SINGLEMDS ost1"
11775 cmd="dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 oflag=sync"
11776 verify_jobstats "$cmd" "ost1"
11778 cmd="dd if=$DIR/$tfile of=/dev/null bs=1M count=1 iflag=direct"
11779 verify_jobstats "$cmd" "ost1"
11781 cmd="$TRUNCATE $DIR/$tfile 0"
11782 verify_jobstats "$cmd" "$SINGLEMDS ost1"
11784 cmd="mv -f $DIR/$tfile $DIR/$tdir.rename"
11785 verify_jobstats "$cmd" "$SINGLEMDS"
11786 # jobstats expiry - sleep until old stats should be expired
11787 local left=$((interval_new + 2 - (SECONDS - start)))
11788 [ $left -ge 0 ] && echo "sleep $left for expiry" && sleep $((left + 1))
11789 cmd="mkdir $DIR/$tdir.expire"
11790 verify_jobstats "$cmd" "$SINGLEMDS"
11791 [ $(do_facet $SINGLEMDS lctl get_param *.*.job_stats |
11792 grep -c "job_id.*mkdir") -gt 1 ] && error "old jobstats not expired"
11794 # Ensure that jobid are present in changelog (if supported by MDS)
11795 if [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.6.52) ]
11797 $LFS changelog $MDT0 | tail -9
11798 jobids=$($LFS changelog $MDT0 | tail -9 | grep -c "j=")
11799 [ $jobids -eq 9 ] ||
11800 error "Wrong changelog jobid count $jobids != 9"
11804 jobstats_set $JOBENV
11806 $LFS changelog $MDT0 | tail -1
11807 jobids=$($LFS changelog $MDT0 | tail -1 | grep -c "j=")
11808 [ $jobids -eq 0 ] ||
11809 error "Unexpected jobids when jobid_var=$JOBENV"
11814 run_test 205 "Verify job stats"
11816 # LU-1480, LU-1773 and LU-1657
11818 mkdir -p $DIR/$tdir
11819 $SETSTRIPE -c -1 $DIR/$tdir
11820 #define OBD_FAIL_LOV_INIT 0x1403
11821 $LCTL set_param fail_loc=0xa0001403
11822 $LCTL set_param fail_val=1
11823 touch $DIR/$tdir/$tfile || true
11825 run_test 206 "fail lov_init_raid0() doesn't lbug"
11828 dd if=/dev/zero of=$DIR/$tfile bs=4k count=$((RANDOM%10+1))
11829 local fsz=`stat -c %s $DIR/$tfile`
11830 cancel_lru_locks mdc
11832 # do not return layout in getattr intent
11833 #define OBD_FAIL_MDS_NO_LL_GETATTR 0x170
11834 $LCTL set_param fail_loc=0x170
11835 local sz=`stat -c %s $DIR/$tfile`
11837 [ $fsz -eq $sz ] || error "file size expected $fsz, actual $sz"
11841 run_test 207a "can refresh layout at glimpse"
11844 dd if=/dev/zero of=$DIR/$tfile bs=4k count=$((RANDOM%10+1))
11845 local cksum=`md5sum $DIR/$tfile`
11846 local fsz=`stat -c %s $DIR/$tfile`
11847 cancel_lru_locks mdc
11848 cancel_lru_locks osc
11850 # do not return layout in getattr intent
11851 #define OBD_FAIL_MDS_NO_LL_OPEN 0x171
11852 $LCTL set_param fail_loc=0x171
11854 # it will refresh layout after the file is opened but before read issues
11855 echo checksum is "$cksum"
11856 echo "$cksum" |md5sum -c --quiet || error "file differs"
11860 run_test 207b "can refresh layout at open"
11863 # FIXME: in this test suite, only RD lease is used. This is okay
11864 # for now as only exclusive open is supported. After generic lease
11865 # is done, this test suite should be revised. - Jinshan
11867 remote_mds_nodsh && skip "remote MDS with nodsh" && return
11868 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.4.52) ]] ||
11869 { skip "Need MDS version at least 2.4.52"; return 0; }
11871 echo "==== test 1: verify get lease work"
11872 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:eRE+eU || error "get lease error"
11874 echo "==== test 2: verify lease can be broken by upcoming open"
11875 $MULTIOP $DIR/$tfile oO_RDONLY:eR_E-eUc &
11879 $MULTIOP $DIR/$tfile oO_RDONLY:c
11880 kill -USR1 $PID && wait $PID || error "break lease error"
11882 echo "==== test 3: verify lease can't be granted if an open already exists"
11883 $MULTIOP $DIR/$tfile oO_RDONLY:_c &
11887 $MULTIOP $DIR/$tfile oO_RDONLY:eReUc && error "apply lease should fail"
11888 kill -USR1 $PID && wait $PID || error "open file error"
11890 echo "==== test 4: lease can sustain over recovery"
11891 $MULTIOP $DIR/$tfile oO_RDONLY:eR_E+eUc &
11897 kill -USR1 $PID && wait $PID || error "lease broken over recovery"
11899 echo "==== test 5: lease broken can't be regained by replay"
11900 $MULTIOP $DIR/$tfile oO_RDONLY:eR_E-eUc &
11904 # open file to break lease and then recovery
11905 $MULTIOP $DIR/$tfile oO_RDWR:c || error "open file error"
11908 kill -USR1 $PID && wait $PID || error "lease not broken over recovery"
11912 run_test 208 "Exclusive open"
11915 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep disp_stripe)" ] &&
11916 skip_env "must have disp_stripe" && return
11919 sync; sleep 5; sync;
11921 echo 3 > /proc/sys/vm/drop_caches
11922 req_before=$(awk '/ptlrpc_cache / { print $2 }' /proc/slabinfo)
11924 # open/close 500 times
11925 for i in $(seq 500); do
11929 echo 3 > /proc/sys/vm/drop_caches
11930 req_after=$(awk '/ptlrpc_cache / { print $2 }' /proc/slabinfo)
11932 echo "before: $req_before, after: $req_after"
11933 [ $((req_after - req_before)) -ge 300 ] &&
11934 error "open/close requests are not freed"
11937 run_test 209 "read-only open/close requests should be freed promptly"
11941 size=$((size % 8192 + 1))
11942 dd if=/dev/urandom of=$DIR/f212 bs=1k count=$size
11943 sendfile $DIR/f212 $DIR/f212.xyz || error "sendfile wrong"
11944 rm -f $DIR/f212 $DIR/f212.xyz
11946 run_test 212 "Sendfile test ============================================"
11949 dd if=/dev/zero of=$DIR/$tfile bs=4k count=4
11950 cancel_lru_locks osc
11951 lctl set_param fail_loc=0x8000040f
11952 # generate a read lock
11953 cat $DIR/$tfile > /dev/null
11954 # write to the file, it will try to cancel the above read lock.
11955 cat /etc/hosts >> $DIR/$tfile
11957 run_test 213 "OSC lock completion and cancel race don't crash - bug 18829"
11959 test_214() { # for bug 20133
11960 mkdir -p $DIR/$tdir/d214c || error "mkdir $DIR/$tdir/d214c failed"
11961 for (( i=0; i < 340; i++ )) ; do
11962 touch $DIR/$tdir/d214c/a$i
11965 ls -l $DIR/$tdir || error "ls -l $DIR/d214p failed"
11966 mv $DIR/$tdir/d214c $DIR/ || error "mv $DIR/d214p/d214c $DIR/ failed"
11967 ls $DIR/d214c || error "ls $DIR/d214c failed"
11968 rm -rf $DIR/$tdir || error "rm -rf $DIR/d214* failed"
11969 rm -rf $DIR/d214* || error "rm -rf $DIR/d214* failed"
11971 run_test 214 "hash-indexed directory test - bug 20133"
11973 # having "abc" as 1st arg, creates $TMP/lnet_abc.out and $TMP/lnet_abc.sys
11974 create_lnet_proc_files() {
11975 lctl get_param -n $1 >$TMP/lnet_$1.out || error "cannot read lnet.$1"
11976 sysctl lnet.$1 >$TMP/lnet_$1.sys_tmp || error "cannot read lnet.$1"
11978 sed "s/^lnet.$1\ =\ //g" "$TMP/lnet_$1.sys_tmp" >$TMP/lnet_$1.sys
11979 rm -f "$TMP/lnet_$1.sys_tmp"
11982 # counterpart of create_lnet_proc_files
11983 remove_lnet_proc_files() {
11984 rm -f $TMP/lnet_$1.out $TMP/lnet_$1.sys
11987 # uses 1st arg as trailing part of filename, 2nd arg as description for reports,
11988 # 3rd arg as regexp for body
11989 check_lnet_proc_stats() {
11990 local l=$(cat "$TMP/lnet_$1" |wc -l)
11991 [ $l = 1 ] || (cat "$TMP/lnet_$1" && error "$2 is not of 1 line: $l")
11993 grep -E "$3" "$TMP/lnet_$1" || (cat "$TMP/lnet_$1" && error "$2 misformatted")
11996 # uses 1st arg as trailing part of filename, 2nd arg as description for reports,
11997 # 3rd arg as regexp for body, 4th arg as regexp for 1st line, 5th arg is
11998 # optional and can be regexp for 2nd line (lnet.routes case)
11999 check_lnet_proc_entry() {
12000 local blp=2 # blp stands for 'position of 1st line of body'
12001 [ -z "$5" ] || blp=3 # lnet.routes case
12003 local l=$(cat "$TMP/lnet_$1" |wc -l)
12004 # subtracting one from $blp because the body can be empty
12005 [ "$l" -ge "$(($blp - 1))" ] || (cat "$TMP/lnet_$1" && error "$2 is too short: $l")
12007 sed -n '1 p' "$TMP/lnet_$1" |grep -E "$4" >/dev/null ||
12008 (cat "$TMP/lnet_$1" && error "1st line of $2 misformatted")
12010 [ "$5" = "" ] || sed -n '2 p' "$TMP/lnet_$1" |grep -E "$5" >/dev/null ||
12011 (cat "$TMP/lnet_$1" && error "2nd line of $2 misformatted")
12013 # bail out if any unexpected line happened
12014 sed -n "$blp p" "$TMP/lnet_$1" | grep -Ev "$3"
12015 [ "$?" != 0 ] || error "$2 misformatted"
12018 test_215() { # for bugs 18102, 21079, 21517
12019 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12020 local N='(0|[1-9][0-9]*)' # non-negative numeric
12021 local P='[1-9][0-9]*' # positive numeric
12022 local I='(0|-?[1-9][0-9]*|NA)' # any numeric (0 | >0 | <0) or NA if no value
12023 local NET='[a-z][a-z0-9]*' # LNET net like o2ib2
12024 local ADDR='[0-9.]+' # LNET addr like 10.0.0.1
12025 local NID="$ADDR@$NET" # LNET nid like 10.0.0.1@o2ib2
12027 local L1 # regexp for 1st line
12028 local L2 # regexp for 2nd line (optional)
12029 local BR # regexp for the rest (body)
12031 # lnet.stats should look as 11 space-separated non-negative numerics
12032 BR="^$N $N $N $N $N $N $N $N $N $N $N$"
12033 create_lnet_proc_files "stats"
12034 check_lnet_proc_stats "stats.sys" "lnet.stats" "$BR"
12035 remove_lnet_proc_files "stats"
12037 # lnet.routes should look like this:
12038 # Routing disabled/enabled
12039 # net hops priority state router
12040 # where net is a string like tcp0, hops > 0, priority >= 0,
12041 # state is up/down,
12042 # router is a string like 192.168.1.1@tcp2
12043 L1="^Routing (disabled|enabled)$"
12044 L2="^net +hops +priority +state +router$"
12045 BR="^$NET +$N +(0|1) +(up|down) +$NID$"
12046 create_lnet_proc_files "routes"
12047 check_lnet_proc_entry "routes.sys" "lnet.routes" "$BR" "$L1" "$L2"
12048 remove_lnet_proc_files "routes"
12050 # lnet.routers should look like this:
12051 # ref rtr_ref alive_cnt state last_ping ping_sent deadline down_ni router
12052 # where ref > 0, rtr_ref > 0, alive_cnt >= 0, state is up/down,
12053 # last_ping >= 0, ping_sent is boolean (0/1), deadline and down_ni are
12054 # numeric (0 or >0 or <0), router is a string like 192.168.1.1@tcp2
12055 L1="^ref +rtr_ref +alive_cnt +state +last_ping +ping_sent +deadline +down_ni +router$"
12056 BR="^$P +$P +$N +(up|down) +$N +(0|1) +$I +$I +$NID$"
12057 create_lnet_proc_files "routers"
12058 check_lnet_proc_entry "routers.sys" "lnet.routers" "$BR" "$L1"
12059 remove_lnet_proc_files "routers"
12061 # lnet.peers should look like this:
12062 # nid refs state last max rtr min tx min queue
12063 # where nid is a string like 192.168.1.1@tcp2, refs > 0,
12064 # state is up/down/NA, max >= 0. last, rtr, min, tx, min are
12065 # numeric (0 or >0 or <0), queue >= 0.
12066 L1="^nid +refs +state +last +max +rtr +min +tx +min +queue$"
12067 BR="^$NID +$P +(up|down|NA) +$I +$N +$I +$I +$I +$I +$N$"
12068 create_lnet_proc_files "peers"
12069 check_lnet_proc_entry "peers.sys" "lnet.peers" "$BR" "$L1"
12070 remove_lnet_proc_files "peers"
12072 # lnet.buffers should look like this:
12073 # pages count credits min
12074 # where pages >=0, count >=0, credits and min are numeric (0 or >0 or <0)
12075 L1="^pages +count +credits +min$"
12076 BR="^ +$N +$N +$I +$I$"
12077 create_lnet_proc_files "buffers"
12078 check_lnet_proc_entry "buffers.sys" "lnet.buffers" "$BR" "$L1"
12079 remove_lnet_proc_files "buffers"
12081 # lnet.nis should look like this:
12082 # nid status alive refs peer rtr max tx min
12083 # where nid is a string like 192.168.1.1@tcp2, status is up/down,
12084 # alive is numeric (0 or >0 or <0), refs >= 0, peer >= 0,
12085 # rtr >= 0, max >=0, tx and min are numeric (0 or >0 or <0).
12086 L1="^nid +status +alive +refs +peer +rtr +max +tx +min$"
12087 BR="^$NID +(up|down) +$I +$N +$N +$N +$N +$I +$I$"
12088 create_lnet_proc_files "nis"
12089 check_lnet_proc_entry "nis.sys" "lnet.nis" "$BR" "$L1"
12090 remove_lnet_proc_files "nis"
12092 # can we successfully write to lnet.stats?
12093 lctl set_param -n stats=0 || error "cannot write to lnet.stats"
12094 sysctl -w lnet.stats=0 || error "cannot write to lnet.stats"
12096 run_test 215 "lnet exists and has proper content - bugs 18102, 21079, 21517"
12098 test_216() { # bug 20317
12099 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12100 remote_ost_nodsh && skip "remote OST with nodsh" && return
12103 local facets=$(get_facets OST)
12104 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
12106 save_lustre_params client "osc.*.contention_seconds" > $p
12107 save_lustre_params $facets \
12108 "ldlm.namespaces.filter-*.max_nolock_bytes" >> $p
12109 save_lustre_params $facets \
12110 "ldlm.namespaces.filter-*.contended_locks" >> $p
12111 save_lustre_params $facets \
12112 "ldlm.namespaces.filter-*.contention_seconds" >> $p
12115 # agressive lockless i/o settings
12116 for node in $(osts_nodes); do
12117 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'
12119 lctl set_param -n osc.*.contention_seconds 60
12121 $DIRECTIO write $DIR/$tfile 0 10 4096
12122 $CHECKSTAT -s 40960 $DIR/$tfile
12124 # disable lockless i/o
12125 for node in $(osts_nodes); do
12126 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'
12128 lctl set_param -n osc.*.contention_seconds 0
12131 dd if=/dev/zero of=$DIR/$tfile count=0
12132 $CHECKSTAT -s 0 $DIR/$tfile
12134 restore_lustre_params <$p
12138 run_test 216 "check lockless direct write works and updates file size and kms correctly"
12140 test_217() { # bug 22430
12141 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12145 for node in $(nodes_list); do
12146 nid=$(host_nids_address $node $NETTYPE)
12147 if [[ $nid = *-* ]] ; then
12148 echo "lctl ping $nid@$NETTYPE"
12149 lctl ping $nid@$NETTYPE
12151 echo "skipping $node (no hyphen detected)"
12155 run_test 217 "check lctl ping for hostnames with hiphen ('-')"
12158 # do directio so as not to populate the page cache
12159 log "creating a 10 Mb file"
12160 $MULTIOP $DIR/$tfile oO_CREAT:O_DIRECT:O_RDWR:w$((10*1048576))c || error "multiop failed while creating a file"
12161 log "starting reads"
12162 dd if=$DIR/$tfile of=/dev/null bs=4096 &
12163 log "truncating the file"
12164 $MULTIOP $DIR/$tfile oO_TRUNC:c || error "multiop failed while truncating the file"
12166 kill %+ || true # reads might have finished
12167 echo "wait until dd is finished"
12169 log "removing the temporary file"
12170 rm -rf $DIR/$tfile || error "tmp file removal failed"
12172 run_test 218 "parallel read and truncate should not deadlock ======================="
12175 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12176 # write one partial page
12177 dd if=/dev/zero of=$DIR/$tfile bs=1024 count=1
12178 # set no grant so vvp_io_commit_write will do sync write
12179 $LCTL set_param fail_loc=0x411
12180 # write a full page at the end of file
12181 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 seek=1 conv=notrunc
12183 $LCTL set_param fail_loc=0
12184 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 seek=3
12185 $LCTL set_param fail_loc=0x411
12186 dd if=/dev/zero of=$DIR/$tfile bs=1024 count=1 seek=2 conv=notrunc
12189 dd if=/dev/zero of=$DIR/$tfile-2 bs=1024 count=1
12190 $CHECKSTAT -s 1024 $DIR/$tfile-2 || error "checkstat wrong size"
12192 run_test 219 "LU-394: Write partial won't cause uncontiguous pages vec at LND"
12194 test_220() { #LU-325
12195 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12196 remote_ost_nodsh && skip "remote OST with nodsh" && return
12197 remote_mds_nodsh && skip "remote MDS with nodsh" && return
12198 remote_mgs_nodsh && skip "remote MGS with nodsh" && return
12201 # create on MDT0000 so the last_id and next_id are correct
12203 local OST=$($LFS df $DIR | awk '/OST:'$OSTIDX'/ { print $1 }')
12207 local mdtosc_proc1=$(get_mdtosc_proc_path $SINGLEMDS $OST)
12208 local last_id=$(do_facet $SINGLEMDS lctl get_param -n \
12209 osc.$mdtosc_proc1.prealloc_last_id)
12210 local next_id=$(do_facet $SINGLEMDS lctl get_param -n \
12211 osc.$mdtosc_proc1.prealloc_next_id)
12215 do_facet ost$((OSTIDX + 1)) lctl set_param fail_val=-1
12216 #define OBD_FAIL_OST_ENOINO 0x229
12217 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=0x229
12218 do_facet mgs $LCTL pool_new $FSNAME.$TESTNAME || return 1
12219 do_facet mgs $LCTL pool_add $FSNAME.$TESTNAME $OST || return 2
12221 $SETSTRIPE $DIR/$tdir -i $OSTIDX -c 1 -p $FSNAME.$TESTNAME
12223 MDSOBJS=$((last_id - next_id))
12224 echo "preallocated objects on MDS is $MDSOBJS" "($last_id - $next_id)"
12226 blocks=$($LFS df $MOUNT | awk '($1 == '$OSTIDX') { print $4 }')
12227 echo "OST still has $count kbytes free"
12229 echo "create $MDSOBJS files @next_id..."
12230 createmany -o $DIR/$tdir/f $MDSOBJS || return 3
12232 local last_id2=$(do_facet mds${MDSIDX} lctl get_param -n \
12233 osc.$mdtosc_proc1.prealloc_last_id)
12234 local next_id2=$(do_facet mds${MDSIDX} lctl get_param -n \
12235 osc.$mdtosc_proc1.prealloc_next_id)
12237 echo "after creation, last_id=$last_id2, next_id=$next_id2"
12242 do_facet ost$((OSTIDX + 1)) lctl set_param fail_val=0
12243 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=0
12245 do_facet mgs $LCTL pool_remove $FSNAME.$TESTNAME $OST || return 4
12246 do_facet mgs $LCTL pool_destroy $FSNAME.$TESTNAME || return 5
12247 echo "unlink $MDSOBJS files @$next_id..."
12248 unlinkmany $DIR/$tdir/f $MDSOBJS || return 6
12250 run_test 220 "preallocated MDS objects still used if ENOSPC from OST"
12253 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12254 dd if=`which date` of=$MOUNT/date oflag=sync
12255 chmod +x $MOUNT/date
12257 #define OBD_FAIL_LLITE_FAULT_TRUNC_RACE 0x1401
12258 $LCTL set_param fail_loc=0x80001401
12260 $MOUNT/date > /dev/null
12263 run_test 221 "make sure fault and truncate race to not cause OOM"
12266 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12268 test_mkdir -p $DIR/$tdir
12269 $SETSTRIPE -c 1 -i 0 $DIR/$tdir
12270 createmany -o $DIR/$tdir/$tfile 10
12271 cancel_lru_locks mdc
12272 cancel_lru_locks osc
12273 #define OBD_FAIL_LDLM_AGL_DELAY 0x31a
12274 $LCTL set_param fail_loc=0x31a
12275 ls -l $DIR/$tdir > /dev/null || error "AGL for ls failed"
12276 $LCTL set_param fail_loc=0
12279 run_test 222a "AGL for ls should not trigger CLIO lock failure ================"
12282 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12284 test_mkdir -p $DIR/$tdir
12285 $SETSTRIPE -c 1 -i 0 $DIR/$tdir
12286 createmany -o $DIR/$tdir/$tfile 10
12287 cancel_lru_locks mdc
12288 cancel_lru_locks osc
12289 #define OBD_FAIL_LDLM_AGL_DELAY 0x31a
12290 $LCTL set_param fail_loc=0x31a
12291 rm -r $DIR/$tdir || "AGL for rmdir failed"
12292 $LCTL set_param fail_loc=0
12294 run_test 222b "AGL for rmdir should not trigger CLIO lock failure ============="
12297 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12299 test_mkdir -p $DIR/$tdir
12300 $SETSTRIPE -c 1 -i 0 $DIR/$tdir
12301 createmany -o $DIR/$tdir/$tfile 10
12302 cancel_lru_locks mdc
12303 cancel_lru_locks osc
12304 #define OBD_FAIL_LDLM_AGL_NOLOCK 0x31b
12305 $LCTL set_param fail_loc=0x31b
12306 ls -l $DIR/$tdir > /dev/null || error "reenqueue failed"
12307 $LCTL set_param fail_loc=0
12310 run_test 223 "osc reenqueue if without AGL lock granted ======================="
12312 test_224a() { # LU-1039, MRP-303
12313 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12314 #define OBD_FAIL_PTLRPC_CLIENT_BULK_CB 0x508
12315 $LCTL set_param fail_loc=0x508
12316 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 conv=fsync
12317 $LCTL set_param fail_loc=0
12320 run_test 224a "Don't panic on bulk IO failure"
12322 test_224b() { # LU-1039, MRP-303
12323 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12324 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1
12325 cancel_lru_locks osc
12326 #define OBD_FAIL_PTLRPC_CLIENT_BULK_CB2 0x515
12327 $LCTL set_param fail_loc=0x515
12328 dd of=/dev/null if=$DIR/$tfile bs=4096 count=1
12329 $LCTL set_param fail_loc=0
12332 run_test 224b "Don't panic on bulk IO failure"
12334 test_224c() { # LU-6441
12335 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12336 local pages_per_rpc=$($LCTL get_param \
12337 osc.*.max_pages_per_rpc)
12338 local at_max=$($LCTL get_param -n at_max)
12339 local timeout=$($LCTL get_param -n timeout)
12340 local test_at="$LCTL get_param -n at_max"
12341 local param_at="$FSNAME.sys.at_max"
12342 local test_timeout="$LCTL get_param -n timeout"
12343 local param_timeout="$FSNAME.sys.timeout"
12345 $LCTL set_param -n osc.*.max_pages_per_rpc=1024
12347 set_conf_param_and_check client "$test_at" "$param_at" 0 ||
12348 error "conf_param at_max=0 failed"
12349 set_conf_param_and_check client "$test_timeout" "$param_timeout" 5 ||
12350 error "conf_param timeout=5 failed"
12352 #define OBD_FAIL_PTLRPC_CLIENT_BULK_CB3 0x520
12353 $LCTL set_param fail_loc=0x520
12354 dd if=/dev/zero of=$DIR/$tfile bs=8MB count=1
12356 $LCTL set_param fail_loc=0
12358 set_conf_param_and_check client "$test_at" "$param_at" $at_max ||
12359 error "conf_param at_max=$at_max failed"
12360 set_conf_param_and_check client "$test_timeout" "$param_timeout" \
12361 $timeout || error "conf_param timeout=$timeout failed"
12363 $LCTL set_param -n $pages_per_rpc
12365 run_test 224c "Don't hang if one of md lost during large bulk RPC"
12367 MDSSURVEY=${MDSSURVEY:-$(which mds-survey 2>/dev/null || true)}
12369 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12370 remote_mds_nodsh && skip "remote MDS with nodsh" && return
12371 if [ -z ${MDSSURVEY} ]; then
12372 skip_env "mds-survey not found" && return
12375 [ $MDSCOUNT -ge 2 ] &&
12376 skip "skipping now for more than one MDT" && return
12378 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.51) ] ||
12379 { skip "Need MDS version at least 2.2.51"; return; }
12381 local mds=$(facet_host $SINGLEMDS)
12382 local target=$(do_nodes $mds 'lctl dl' | \
12383 awk "{if (\$2 == \"UP\" && \$3 == \"mdt\") {print \$4}}")
12385 local cmd1="file_count=1000 thrhi=4"
12386 local cmd2="dir_count=2 layer=mdd stripe_count=0"
12387 local cmd3="rslt_loc=${TMP} targets=\"$mds:$target\" $MDSSURVEY"
12388 local cmd="$cmd1 $cmd2 $cmd3"
12390 rm -f ${TMP}/mds_survey*
12392 eval $cmd || error "mds-survey with zero-stripe failed"
12393 cat ${TMP}/mds_survey*
12394 rm -f ${TMP}/mds_survey*
12396 run_test 225a "Metadata survey sanity with zero-stripe"
12399 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12400 remote_mds_nodsh && skip "remote MDS with nodsh" && return
12401 if [ -z ${MDSSURVEY} ]; then
12402 skip_env "mds-survey not found" && return
12404 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.51) ] ||
12405 { skip "Need MDS version at least 2.2.51"; return; }
12407 if [ $($LCTL dl | grep -c osc) -eq 0 ]; then
12408 skip_env "Need to mount OST to test" && return
12411 [ $MDSCOUNT -ge 2 ] &&
12412 skip "skipping now for more than one MDT" && return
12413 local mds=$(facet_host $SINGLEMDS)
12414 local target=$(do_nodes $mds 'lctl dl' | \
12415 awk "{if (\$2 == \"UP\" && \$3 == \"mdt\") {print \$4}}")
12417 local cmd1="file_count=1000 thrhi=4"
12418 local cmd2="dir_count=2 layer=mdd stripe_count=1"
12419 local cmd3="rslt_loc=${TMP} targets=\"$mds:$target\" $MDSSURVEY"
12420 local cmd="$cmd1 $cmd2 $cmd3"
12422 rm -f ${TMP}/mds_survey*
12424 eval $cmd || error "mds-survey with stripe_count failed"
12425 cat ${TMP}/mds_survey*
12426 rm -f ${TMP}/mds_survey*
12428 run_test 225b "Metadata survey sanity with stripe_count = 1"
12430 mcreate_path2fid () {
12436 local path=$DIR/$tdir/$name
12441 $MCREATE --mode=$1 --major=$2 --minor=$3 $path ||
12442 error "cannot create $desc"
12444 fid=$($LFS path2fid $path | tr -d '[' | tr -d ']')
12446 [ $rc -ne 0 ] && error "cannot get fid of a $desc"
12448 fid_path=$($LFS fid2path $MOUNT $fid)
12450 [ $rc -ne 0 ] && error "cannot get path of $desc by $DIR $path $fid"
12452 [ "$path" == "$fid_path" ] ||
12453 error "fid2path returned $fid_path, expected $path"
12455 echo "pass with $path and $fid"
12460 mkdir -p $DIR/$tdir
12462 mcreate_path2fid 0010666 0 0 fifo "FIFO"
12463 mcreate_path2fid 0020666 1 3 null "character special file (null)"
12464 mcreate_path2fid 0020666 1 255 none "character special file (no device)"
12465 mcreate_path2fid 0040666 0 0 dir "directory"
12466 mcreate_path2fid 0060666 7 0 loop0 "block special file (loop)"
12467 mcreate_path2fid 0100666 0 0 file "regular file"
12468 mcreate_path2fid 0120666 0 0 link "symbolic link"
12469 mcreate_path2fid 0140666 0 0 sock "socket"
12471 run_test 226a "call path2fid and fid2path on files of all type"
12474 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
12478 mkdir -p $DIR/$tdir
12479 $LFS setdirstripe -i $MDTIDX $DIR/$tdir/remote_dir ||
12480 error "create remote directory failed"
12481 mcreate_path2fid 0010666 0 0 "remote_dir/fifo" "FIFO"
12482 mcreate_path2fid 0020666 1 3 "remote_dir/null" \
12483 "character special file (null)"
12484 mcreate_path2fid 0020666 1 255 "remote_dir/none" \
12485 "character special file (no device)"
12486 mcreate_path2fid 0040666 0 0 "remote_dir/dir" "directory"
12487 mcreate_path2fid 0060666 7 0 "remote_dir/loop0" \
12488 "block special file (loop)"
12489 mcreate_path2fid 0100666 0 0 "remote_dir/file" "regular file"
12490 mcreate_path2fid 0120666 0 0 "remote_dir/link" "symbolic link"
12491 mcreate_path2fid 0140666 0 0 "remote_dir/sock" "socket"
12493 run_test 226b "call path2fid and fid2path on files of all type under remote dir"
12495 # LU-1299 Executing or running ldd on a truncated executable does not
12496 # cause an out-of-memory condition.
12498 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12499 [ -z "$(which ldd)" ] && skip "should have ldd tool" && return
12500 dd if=$(which date) of=$MOUNT/date bs=1k count=1
12501 chmod +x $MOUNT/date
12503 $MOUNT/date > /dev/null
12504 ldd $MOUNT/date > /dev/null
12507 run_test 227 "running truncated executable does not cause OOM"
12509 # LU-1512 try to reuse idle OI blocks
12511 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12512 remote_mds_nodsh && skip "remote MDS with nodsh" && return
12513 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
12514 skip "non-ldiskfs backend" && return
12516 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
12517 local myDIR=$DIR/$tdir
12520 #define OBD_FAIL_SEQ_EXHAUST 0x1002
12521 $LCTL set_param fail_loc=0x80001002
12522 createmany -o $myDIR/t- 10000
12523 $LCTL set_param fail_loc=0
12524 # The guard is current the largest FID holder
12526 local SEQ=$($LFS path2fid $myDIR/guard | awk -F ':' '{print $1}' |
12528 local IDX=$(($SEQ % 64))
12530 do_facet $SINGLEMDS sync
12531 # Make sure journal flushed.
12533 local blk1=$(do_facet $SINGLEMDS \
12534 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
12535 grep Blockcount | awk '{print $4}')
12537 # Remove old files, some OI blocks will become idle.
12538 unlinkmany $myDIR/t- 10000
12539 # Create new files, idle OI blocks should be reused.
12540 createmany -o $myDIR/t- 2000
12541 do_facet $SINGLEMDS sync
12542 # Make sure journal flushed.
12544 local blk2=$(do_facet $SINGLEMDS \
12545 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
12546 grep Blockcount | awk '{print $4}')
12548 [ $blk1 == $blk2 ] || error "old blk1=$blk1, new blk2=$blk2, unmatched!"
12550 run_test 228a "try to reuse idle OI blocks"
12553 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12554 remote_mds_nodsh && skip "remote MDS with nodsh" && return
12555 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
12556 skip "non-ldiskfs backend" && return
12558 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
12559 local myDIR=$DIR/$tdir
12562 #define OBD_FAIL_SEQ_EXHAUST 0x1002
12563 $LCTL set_param fail_loc=0x80001002
12564 createmany -o $myDIR/t- 10000
12565 $LCTL set_param fail_loc=0
12566 # The guard is current the largest FID holder
12568 local SEQ=$($LFS path2fid $myDIR/guard | awk -F ':' '{print $1}' |
12570 local IDX=$(($SEQ % 64))
12572 do_facet $SINGLEMDS sync
12573 # Make sure journal flushed.
12575 local blk1=$(do_facet $SINGLEMDS \
12576 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
12577 grep Blockcount | awk '{print $4}')
12579 # Remove old files, some OI blocks will become idle.
12580 unlinkmany $myDIR/t- 10000
12583 stop $SINGLEMDS || error "Fail to stop MDT."
12585 start $SINGLEMDS $MDT_DEV $MDS_MOUNT_OPTS || error "Fail to start MDT."
12587 df $MOUNT || error "Fail to df."
12588 # Create new files, idle OI blocks should be reused.
12589 createmany -o $myDIR/t- 2000
12590 do_facet $SINGLEMDS sync
12591 # Make sure journal flushed.
12593 local blk2=$(do_facet $SINGLEMDS \
12594 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
12595 grep Blockcount | awk '{print $4}')
12597 [ $blk1 == $blk2 ] || error "old blk1=$blk1, new blk2=$blk2, unmatched!"
12599 run_test 228b "idle OI blocks can be reused after MDT restart"
12603 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12604 remote_mds_nodsh && skip "remote MDS with nodsh" && return
12605 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
12606 skip "non-ldiskfs backend" && return
12608 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
12609 local myDIR=$DIR/$tdir
12612 #define OBD_FAIL_SEQ_EXHAUST 0x1002
12613 $LCTL set_param fail_loc=0x80001002
12614 # 20000 files can guarantee there are index nodes in the OI file
12615 createmany -o $myDIR/t- 20000
12616 $LCTL set_param fail_loc=0
12617 # The guard is current the largest FID holder
12619 local SEQ=$($LFS path2fid $myDIR/guard | awk -F ':' '{print $1}' |
12621 local IDX=$(($SEQ % 64))
12623 do_facet $SINGLEMDS sync
12624 # Make sure journal flushed.
12626 local blk1=$(do_facet $SINGLEMDS \
12627 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
12628 grep Blockcount | awk '{print $4}')
12630 # Remove old files, some OI blocks will become idle.
12631 unlinkmany $myDIR/t- 20000
12633 # The OI file should become empty now
12635 # Create new files, idle OI blocks should be reused.
12636 createmany -o $myDIR/t- 2000
12637 do_facet $SINGLEMDS sync
12638 # Make sure journal flushed.
12640 local blk2=$(do_facet $SINGLEMDS \
12641 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
12642 grep Blockcount | awk '{print $4}')
12644 [ $blk1 == $blk2 ] || error "old blk1=$blk1, new blk2=$blk2, unmatched!"
12646 run_test 228c "NOT shrink the last entry in OI index node to recycle idle leaf"
12648 test_229() { # LU-2482, LU-3448
12649 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.53) ] &&
12650 skip "No HSM $(lustre_build_version $SINGLEMDS) MDS < 2.4.53" &&
12652 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12653 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs" && return
12657 # Create a file with a released layout and stripe count 2.
12658 $MULTIOP $DIR/$tfile H2c ||
12659 error "failed to create file with released layout"
12661 $GETSTRIPE -v $DIR/$tfile
12663 local pattern=$($GETSTRIPE -L $DIR/$tfile)
12664 [ X"$pattern" = X"80000001" ] || error "pattern error ($pattern)"
12666 local stripe_count=$($GETSTRIPE -c $DIR/$tfile) || error "getstripe"
12667 [ $stripe_count -eq 2 ] || error "stripe count not 2 ($stripe_count)"
12668 stat $DIR/$tfile || error "failed to stat released file"
12670 chown $RUNAS_ID $DIR/$tfile ||
12671 error "chown $RUNAS_ID $DIR/$tfile failed"
12673 chgrp $RUNAS_ID $DIR/$tfile ||
12674 error "chgrp $RUNAS_ID $DIR/$tfile failed"
12676 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
12677 rm $DIR/$tfile || error "failed to remove released file"
12679 run_test 229 "getstripe/stat/rm/attr changes work on released files"
12682 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12683 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
12686 test_mkdir $DIR/$tdir
12687 test_mkdir -i0 -c1 $DIR/$tdir/test_230_local
12688 local mdt_idx=$($GETSTRIPE -M $DIR/$tdir/test_230_local)
12689 [ $mdt_idx -ne 0 ] &&
12690 error "create local directory on wrong MDT $mdt_idx"
12692 $LFS mkdir -i $MDTIDX $DIR/$tdir/test_230 ||
12693 error "create remote directory failed"
12694 local mdt_idx=$($GETSTRIPE -M $DIR/$tdir/test_230)
12695 [ $mdt_idx -ne $MDTIDX ] &&
12696 error "create remote directory on wrong MDT $mdt_idx"
12698 createmany -o $DIR/$tdir/test_230/t- 10 ||
12699 error "create files on remote directory failed"
12700 mdt_idx=$($GETSTRIPE -M $DIR/$tdir/test_230/t-0)
12701 [ $mdt_idx -ne $MDTIDX ] && error "create files on wrong MDT $mdt_idx"
12702 rm -r $DIR/$tdir || error "unlink remote directory failed"
12704 run_test 230a "Create remote directory and files under the remote directory"
12707 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12708 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
12715 local migrate_dir=$DIR/$tdir/migrate_dir
12716 local other_dir=$DIR/$tdir/other_dir
12718 test_mkdir $DIR/$tdir
12719 test_mkdir -i0 -c1 $migrate_dir
12720 test_mkdir -i0 -c1 $other_dir
12721 for ((i=0; i<10; i++)); do
12722 mkdir -p $migrate_dir/dir_${i}
12723 createmany -o $migrate_dir/dir_${i}/f 10 ||
12724 error "create files under remote dir failed $i"
12727 cp /etc/passwd $migrate_dir/$tfile
12728 cp /etc/passwd $other_dir/$tfile
12729 chattr +SAD $migrate_dir
12730 chattr +SAD $migrate_dir/$tfile
12732 local old_dir_flag=$(lsattr -a $migrate_dir | awk '/\/\.$/ {print $1}')
12733 local old_file_flag=$(lsattr $migrate_dir/$tfile | awk '{print $1}')
12734 local old_dir_mode=$(stat -c%f $migrate_dir)
12735 local old_file_mode=$(stat -c%f $migrate_dir/$tfile)
12737 mkdir -p $migrate_dir/dir_default_stripe2
12738 $SETSTRIPE -c 2 $migrate_dir/dir_default_stripe2
12739 $SETSTRIPE -c 2 $migrate_dir/${tfile}_stripe2
12741 mkdir -p $other_dir
12742 ln $migrate_dir/$tfile $other_dir/luna
12743 ln $migrate_dir/$tfile $migrate_dir/sofia
12744 ln $other_dir/$tfile $migrate_dir/david
12745 ln -s $migrate_dir/$tfile $other_dir/zachary
12746 ln -s $migrate_dir/$tfile $migrate_dir/${tfile}_ln
12747 ln -s $other_dir/$tfile $migrate_dir/${tfile}_ln_other
12749 $LFS migrate -m $MDTIDX $migrate_dir ||
12750 error "fails on migrating remote dir to MDT1"
12752 echo "migratate to MDT1, then checking.."
12753 for ((i = 0; i < 10; i++)); do
12754 for file in $(find $migrate_dir/dir_${i}); do
12755 mdt_index=$($LFS getstripe -M $file)
12756 [ $mdt_index == $MDTIDX ] ||
12757 error "$file is not on MDT${MDTIDX}"
12761 # the multiple link file should still in MDT0
12762 mdt_index=$($LFS getstripe -M $migrate_dir/$tfile)
12763 [ $mdt_index == 0 ] ||
12764 error "$file is not on MDT${MDTIDX}"
12766 local new_dir_flag=$(lsattr -a $migrate_dir | awk '/\/\.$/ {print $1}')
12767 [ "$old_dir_flag" = "$new_dir_flag" ] ||
12768 error " expect $old_dir_flag get $new_dir_flag"
12770 local new_file_flag=$(lsattr $migrate_dir/$tfile | awk '{print $1}')
12771 [ "$old_file_flag" = "$new_file_flag" ] ||
12772 error " expect $old_file_flag get $new_file_flag"
12774 local new_dir_mode=$(stat -c%f $migrate_dir)
12775 [ "$old_dir_mode" = "$new_dir_mode" ] ||
12776 error "expect mode $old_dir_mode get $new_dir_mode"
12778 local new_file_mode=$(stat -c%f $migrate_dir/$tfile)
12779 [ "$old_file_mode" = "$new_file_mode" ] ||
12780 error "expect mode $old_file_mode get $new_file_mode"
12782 diff /etc/passwd $migrate_dir/$tfile ||
12783 error "$tfile different after migration"
12785 diff /etc/passwd $other_dir/luna ||
12786 error "luna different after migration"
12788 diff /etc/passwd $migrate_dir/sofia ||
12789 error "sofia different after migration"
12791 diff /etc/passwd $migrate_dir/david ||
12792 error "david different after migration"
12794 diff /etc/passwd $other_dir/zachary ||
12795 error "zachary different after migration"
12797 diff /etc/passwd $migrate_dir/${tfile}_ln ||
12798 error "${tfile}_ln different after migration"
12800 diff /etc/passwd $migrate_dir/${tfile}_ln_other ||
12801 error "${tfile}_ln_other different after migration"
12803 stripe_count=$($LFS getstripe -c $migrate_dir/dir_default_stripe2)
12804 [ $stripe_count = 2 ] ||
12805 error "dir strpe_count $d != 2 after migration."
12807 stripe_count=$($LFS getstripe -c $migrate_dir/${tfile}_stripe2)
12808 [ $stripe_count = 2 ] ||
12809 error "file strpe_count $d != 2 after migration."
12811 #migrate back to MDT0
12814 $LFS migrate -m $MDTIDX $migrate_dir ||
12815 error "fails on migrating remote dir to MDT0"
12817 echo "migrate back to MDT0, checking.."
12818 for file in $(find $migrate_dir); do
12819 mdt_index=$($LFS getstripe -M $file)
12820 [ $mdt_index == $MDTIDX ] ||
12821 error "$file is not on MDT${MDTIDX}"
12824 local new_dir_flag=$(lsattr -a $migrate_dir | awk '/\/\.$/ {print $1}')
12825 [ "$old_dir_flag" = "$new_dir_flag" ] ||
12826 error " expect $old_dir_flag get $new_dir_flag"
12828 local new_file_flag=$(lsattr $migrate_dir/$tfile | awk '{print $1}')
12829 [ "$old_file_flag" = "$new_file_flag" ] ||
12830 error " expect $old_file_flag get $new_file_flag"
12832 local new_dir_mode=$(stat -c%f $migrate_dir)
12833 [ "$old_dir_mode" = "$new_dir_mode" ] ||
12834 error "expect mode $old_dir_mode get $new_dir_mode"
12836 local new_file_mode=$(stat -c%f $migrate_dir/$tfile)
12837 [ "$old_file_mode" = "$new_file_mode" ] ||
12838 error "expect mode $old_file_mode get $new_file_mode"
12840 diff /etc/passwd ${migrate_dir}/$tfile ||
12841 error "$tfile different after migration"
12843 diff /etc/passwd ${other_dir}/luna ||
12844 error "luna different after migration"
12846 diff /etc/passwd ${migrate_dir}/sofia ||
12847 error "sofia different after migration"
12849 diff /etc/passwd ${other_dir}/zachary ||
12850 error "zachary different after migration"
12852 diff /etc/passwd $migrate_dir/${tfile}_ln ||
12853 error "${tfile}_ln different after migration"
12855 diff /etc/passwd $migrate_dir/${tfile}_ln_other ||
12856 error "${tfile}_ln_other different after migration"
12858 stripe_count=$($LFS getstripe -c ${migrate_dir}/dir_default_stripe2)
12859 [ $stripe_count = 2 ] ||
12860 error "dir strpe_count $d != 2 after migration."
12862 stripe_count=$($LFS getstripe -c ${migrate_dir}/${tfile}_stripe2)
12863 [ $stripe_count = 2 ] ||
12864 error "file strpe_count $d != 2 after migration."
12866 rm -rf $DIR/$tdir || error "rm dir failed after migration"
12868 run_test 230b "migrate directory"
12871 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12872 remote_mds_nodsh && skip "remote MDS with nodsh" && return
12873 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
12877 local migrate_dir=$DIR/$tdir/migrate_dir
12879 #If migrating directory fails in the middle, all entries of
12880 #the directory is still accessiable.
12881 test_mkdir $DIR/$tdir
12882 test_mkdir -i0 -c1 $migrate_dir
12884 createmany -o $migrate_dir/f 10 ||
12885 error "create files under ${migrate_dir} failed"
12887 #failed after migrating 5 entries
12888 #OBD_FAIL_MIGRATE_ENTRIES 0x1801
12889 do_facet mds1 lctl set_param fail_loc=0x20001801
12890 do_facet mds1 lctl set_param fail_val=5
12891 local t=$(ls $migrate_dir | wc -l)
12892 $LFS migrate --mdt-index $MDTIDX $migrate_dir &&
12893 error "migrate should fail after 5 entries"
12895 mkdir $migrate_dir/dir &&
12896 error "mkdir succeeds under migrating directory"
12897 touch $migrate_dir/file &&
12898 error "touch file succeeds under migrating directory"
12900 local u=$(ls $migrate_dir | wc -l)
12901 [ "$u" == "$t" ] || error "$u != $t during migration"
12903 for file in $(find $migrate_dir); do
12904 stat $file || error "stat $file failed"
12907 do_facet mds1 lctl set_param fail_loc=0
12908 do_facet mds1 lctl set_param fail_val=0
12910 $LFS migrate -m $MDTIDX $migrate_dir ||
12911 error "migrate open files should failed with open files"
12913 echo "Finish migration, then checking.."
12914 for file in $(find $migrate_dir); do
12915 mdt_index=$($LFS getstripe -M $file)
12916 [ $mdt_index == $MDTIDX ] ||
12917 error "$file is not on MDT${MDTIDX}"
12920 rm -rf $DIR/$tdir || error "rm dir failed after migration"
12922 run_test 230c "check directory accessiblity if migration is failed"
12925 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12926 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
12929 local migrate_dir=$DIR/$tdir/migrate_dir
12933 test_mkdir $DIR/$tdir
12934 test_mkdir -i0 -c1 $migrate_dir
12936 for ((i=0; i<100; i++)); do
12937 test_mkdir -i0 -c1 $migrate_dir/dir_${i}
12938 createmany -o $migrate_dir/dir_${i}/f 100 ||
12939 error "create files under remote dir failed $i"
12942 $LFS migrate -m $MDTIDX $migrate_dir ||
12943 error "migrate remote dir error"
12945 echo "Finish migration, then checking.."
12946 for file in $(find $migrate_dir); do
12947 mdt_index=$($LFS getstripe -M $file)
12948 [ $mdt_index == $MDTIDX ] ||
12949 error "$file is not on MDT${MDTIDX}"
12952 rm -rf $DIR/$tdir || error "rm dir failed after migration"
12954 run_test 230d "check migrate big directory"
12957 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12958 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
12964 mkdir -p $DIR/$tdir
12965 mkdir $DIR/$tdir/migrate_dir
12966 mkdir $DIR/$tdir/other_dir
12967 touch $DIR/$tdir/migrate_dir/a
12968 ln $DIR/$tdir/migrate_dir/a $DIR/$tdir/other_dir/b
12970 $LFS migrate -m 1 $DIR/$tdir/migrate_dir ||
12971 error "migrate dir fails"
12973 mdt_index=$($LFS getstripe -M $DIR/$tdir/migrate_dir)
12974 [ $mdt_index == 1 ] || error "migrate_dir is not on MDT1"
12976 mdt_index=$($LFS getstripe -M $DIR/$tdir/migrate_dir/a)
12977 [ $mdt_index == 0 ] || error "a is not on MDT0"
12979 $LFS migrate -m 1 $DIR/$tdir/other_dir ||
12980 error "migrate dir fails"
12982 mdt_index=$($LFS getstripe -M $DIR/$tdir/other_dir)
12983 [ $mdt_index == 1 ] || error "other_dir is not on MDT1"
12985 mdt_index=$($LFS getstripe -M $DIR/$tdir/migrate_dir/a)
12986 [ $mdt_index == 1 ] || error "a is not on MDT1"
12988 mdt_index=$($LFS getstripe -M $DIR/$tdir/other_dir/b)
12989 [ $mdt_index == 1 ] || error "b is not on MDT1"
12991 a_fid=$($LFS path2fid $DIR/$tdir/migrate_dir/a)
12992 b_fid=$($LFS path2fid $DIR/$tdir/other_dir/b)
12994 [ "$a_fid" = "$b_fid" ] || error "different fid after migration"
12996 rm -rf $DIR/$tdir || error "rm dir failed after migration"
12998 run_test 230e "migrate mulitple local link files"
13001 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13002 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
13006 mkdir -p $DIR/$tdir
13007 mkdir $DIR/$tdir/migrate_dir
13008 $LFS mkdir -i1 $DIR/$tdir/other_dir
13009 touch $DIR/$tdir/migrate_dir/a
13010 ln $DIR/$tdir/migrate_dir/a $DIR/$tdir/other_dir/ln1
13011 ln $DIR/$tdir/migrate_dir/a $DIR/$tdir/other_dir/ln2
13013 # a should be migrated to MDT1, since no other links on MDT0
13014 $LFS migrate -m 1 $DIR/$tdir/migrate_dir ||
13015 error "migrate dir fails"
13016 mdt_index=$($LFS getstripe -M $DIR/$tdir/migrate_dir)
13017 [ $mdt_index == 1 ] || error "migrate_dir is not on MDT1"
13018 mdt_index=$($LFS getstripe -M $DIR/$tdir/migrate_dir/a)
13019 [ $mdt_index == 1 ] || error "a is not on MDT1"
13021 # a should stay on MDT1, because it is a mulitple link file
13022 $LFS migrate -m 0 $DIR/$tdir/migrate_dir ||
13023 error "migrate dir fails"
13024 mdt_index=$($LFS getstripe -M $DIR/$tdir/migrate_dir/a)
13025 [ $mdt_index == 1 ] || error "a is not on MDT1"
13027 $LFS migrate -m 1 $DIR/$tdir/migrate_dir ||
13028 error "migrate dir fails"
13030 a_fid=$($LFS path2fid $DIR/$tdir/migrate_dir/a)
13031 ln_fid=$($LFS path2fid $DIR/$tdir/other_dir/ln1)
13032 [ "$a_fid" = "$ln_fid" ] || error "different fid after migrate to MDT1"
13034 rm -rf $DIR/$tdir/other_dir/ln1 || error "unlink ln1 fails"
13035 rm -rf $DIR/$tdir/other_dir/ln2 || error "unlink ln2 fails"
13037 # a should be migrated to MDT0, since no other links on MDT1
13038 $LFS migrate -m 0 $DIR/$tdir/migrate_dir ||
13039 error "migrate dir fails"
13040 mdt_index=$($LFS getstripe -M $DIR/$tdir/migrate_dir/a)
13041 [ $mdt_index == 0 ] || error "a is not on MDT0"
13043 rm -rf $DIR/$tdir || error "rm dir failed after migration"
13045 run_test 230f "migrate mulitple remote link files"
13049 # For simplicity this test assumes that max_pages_per_rpc
13050 # is the same across all OSCs
13051 local max_pages=$($LCTL get_param -n osc.*.max_pages_per_rpc | head -n1)
13052 local bulk_size=$((max_pages * 4096))
13054 mkdir -p $DIR/$tdir
13056 # clear the OSC stats
13057 $LCTL set_param osc.*.stats=0 &>/dev/null
13059 # Client writes $bulk_size - there must be 1 rpc for $max_pages.
13060 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=$bulk_size count=1 \
13061 oflag=direct &>/dev/null || error "dd failed"
13063 local nrpcs=$($LCTL get_param osc.*.stats |awk '/ost_write/ {print $2}')
13064 if [ x$nrpcs != "x1" ]; then
13065 error "found $nrpc ost_write RPCs, not 1 as expected"
13068 # Drop the OSC cache, otherwise we will read from it
13069 cancel_lru_locks osc
13071 # clear the OSC stats
13072 $LCTL set_param osc.*.stats=0 &>/dev/null
13074 # Client reads $bulk_size.
13075 dd if=$DIR/$tdir/$tfile of=/dev/null bs=$bulk_size count=1 \
13076 iflag=direct &>/dev/null || error "dd failed"
13078 nrpcs=$($LCTL get_param osc.*.stats | awk '/ost_read/ { print $2 }')
13079 if [ x$nrpcs != "x1" ]; then
13080 error "found $nrpc ost_read RPCs, not 1 as expected"
13083 run_test 231a "checking that reading/writing of BRW RPC size results in one RPC"
13086 mkdir -p $DIR/$tdir
13088 for i in {0..1023}; do
13089 dd if=/dev/zero of=$DIR/$tdir/$tfile conv=notrunc \
13090 seek=$((2 * i)) bs=4096 count=1 &>/dev/null ||
13091 error "dd of=$DIR/$tdir/$tfile seek=$((2 * i)) failed"
13095 run_test 231b "must not assert on fully utilized OST request buffer"
13098 mkdir -p $DIR/$tdir
13099 #define OBD_FAIL_LDLM_OST_LVB 0x31c
13100 $LCTL set_param fail_loc=0x31c
13102 # ignore dd failure
13103 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=1 || true
13105 $LCTL set_param fail_loc=0
13106 umount_client $MOUNT || error "umount failed"
13107 mount_client $MOUNT || error "mount failed"
13109 run_test 232 "failed lock should not block umount"
13112 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.3.64) ] ||
13113 { skip "Need MDS version at least 2.3.64"; return; }
13115 local fid=$($LFS path2fid $MOUNT)
13116 stat $MOUNT/.lustre/fid/$fid > /dev/null ||
13117 error "cannot access $MOUNT using its FID '$fid'"
13119 run_test 233a "checking that OBF of the FS root succeeds"
13122 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.5.90) ] ||
13123 { skip "Need MDS version at least 2.5.90"; return; }
13125 local fid=$($LFS path2fid $MOUNT/.lustre)
13126 stat $MOUNT/.lustre/fid/$fid > /dev/null ||
13127 error "cannot access $MOUNT/.lustre using its FID '$fid'"
13129 fid=$($LFS path2fid $MOUNT/.lustre/fid)
13130 stat $MOUNT/.lustre/fid/$fid > /dev/null ||
13131 error "cannot access $MOUNT/.lustre/fid using its FID '$fid'"
13133 run_test 233b "checking that OBF of the FS .lustre succeeds"
13136 local p="$TMP/sanityN-$TESTNAME.parameters"
13137 save_lustre_params client "llite.*.xattr_cache" > $p
13138 lctl set_param llite.*.xattr_cache 1 ||
13139 { skip "xattr cache is not supported"; return 0; }
13141 mkdir -p $DIR/$tdir || error "mkdir failed"
13142 touch $DIR/$tdir/$tfile || error "touch failed"
13143 # OBD_FAIL_LLITE_XATTR_ENOMEM
13144 $LCTL set_param fail_loc=0x1405
13145 # output of the form: attr 2 4 44 3 fc13 x86_64
13146 V=($(IFS=".-" rpm -q attr))
13147 if [[ ${V[1]} > 2 || ${V[2]} > 4 || ${V[3]} > 44 ||
13148 ${V[1]} = 2 && ${V[2]} = 4 && ${V[3]} = 44 && ${V[4]} > 6 ]]; then
13149 # attr pre-2.4.44-7 had a bug with rc
13150 # LU-3703 - SLES 11 and FC13 clients have older attr
13151 getfattr -n user.attr $DIR/$tdir/$tfile &&
13152 error "getfattr should have failed with ENOMEM"
13154 skip "LU-3703: attr version $(getfattr --version) too old"
13156 $LCTL set_param fail_loc=0x0
13159 restore_lustre_params < $p
13162 run_test 234 "xattr cache should not crash on ENOMEM"
13165 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.52) ] &&
13166 skip "Need MDS version at least 2.4.52" && return
13167 flock_deadlock $DIR/$tfile
13172 124) error "process hangs on a deadlock"
13174 *) error "error executing flock_deadlock $DIR/$tfile"
13178 run_test 235 "LU-1715: flock deadlock detection does not work properly"
13182 check_swap_layouts_support && return 0
13183 test_mkdir -p -c1 $DIR/$tdir || error "mkdir $tdir failed"
13185 local ref1=/etc/passwd
13186 local ref2=/etc/group
13187 local file1=$DIR/$tdir/f1
13188 local file2=$DIR/$tdir/f2
13190 $SETSTRIPE -c 1 $file1 || error "cannot setstripe on '$file1': rc = $?"
13191 cp $ref1 $file1 || error "cp $ref1 $file1 failed: rc = $?"
13192 $SETSTRIPE -c 2 $file2 || error "cannot setstripe on '$file2': rc = $?"
13193 cp $ref2 $file2 || error "cp $ref2 $file2 failed: rc = $?"
13194 local fd=$(free_fd)
13195 local cmd="exec $fd<>$file2"
13198 $LFS swap_layouts $file1 /proc/self/fd/${fd} ||
13199 error "cannot swap layouts of '$file1' and /proc/self/fd/${fd}"
13202 cmp $ref2 $file1 || error "content compare failed ($ref2 != $file1)"
13207 run_test 236 "Layout swap on open unlinked file"
13209 # test to verify file handle related system calls
13210 # (name_to_handle_at/open_by_handle_at)
13211 # The new system calls are supported in glibc >= 2.14.
13214 echo "Test file_handle syscalls" > $DIR/$tfile ||
13215 error "write failed"
13216 check_fhandle_syscalls $DIR/$tfile ||
13217 error "check_fhandle_syscalls failed"
13219 run_test 237 "Verify name_to_handle_at/open_by_handle_at syscalls"
13221 # LU-4659 linkea consistency
13223 local server_version=$(lustre_version_code $SINGLEMDS)
13225 [[ $server_version -gt $(version_code 2.5.57) ]] ||
13226 [[ $server_version -gt $(version_code 2.5.1) &&
13227 $server_version -lt $(version_code 2.5.50) ]] ||
13228 { skip "Need MDS version at least 2.5.58 or 2.5.2+"; return; }
13231 ln $DIR/$tfile $DIR/$tfile.lnk
13232 touch $DIR/$tfile.new
13233 mv $DIR/$tfile.new $DIR/$tfile
13234 local fid1=$($LFS path2fid $DIR/$tfile)
13235 local fid2=$($LFS path2fid $DIR/$tfile.lnk)
13236 local path1=$($LFS fid2path $FSNAME "$fid1")
13237 [ $tfile == $path1 ] || error "linkea inconsistent: $tfile $fid1 $path1"
13238 local path2=$($LFS fid2path $FSNAME "$fid2")
13239 [ $tfile.lnk == $path2 ] ||
13240 error "linkea inconsistent: $tfile.lnk $fid2 $path2!"
13243 run_test 238 "Verify linkea consistency"
13246 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.5.60) ] &&
13247 skip "Need MDS version at least 2.5.60" && return
13248 local list=$(comma_list $(mdts_nodes))
13250 mkdir -p $DIR/$tdir
13251 createmany -o $DIR/$tdir/f- 5000
13252 unlinkmany $DIR/$tdir/f- 5000
13253 do_nodes $list "lctl set_param -n osp*.*.sync_changes 1"
13254 changes=$(do_nodes $list "lctl get_param -n osc.*MDT*.sync_changes \
13255 osc.*MDT*.sync_in_flight" | calc_sum)
13256 [ "$changes" -eq 0 ] || error "$changes not synced"
13258 run_test 239 "osp_sync test"
13260 test_239a() { #LU-5297
13262 #define OBD_FAIL_OSP_CHECK_INVALID_REC 0x2100
13263 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x2100
13264 chgrp $RUNAS_GID $DIR/$tfile
13265 wait_delete_completed
13267 run_test 239a "process invalid osp sync record correctly"
13269 test_239b() { #LU-5297
13271 #define OBD_FAIL_OSP_CHECK_ENOMEM 0x2101
13272 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x2101
13273 chgrp $RUNAS_GID $DIR/$tfile1
13274 wait_delete_completed
13275 do_facet $SINGLEMDS $LCTL set_param fail_loc=0
13277 chgrp $RUNAS_GID $DIR/$tfile2
13278 wait_delete_completed
13280 run_test 239b "process osp sync record with ENOMEM error correctly"
13283 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
13285 mkdir -p $DIR/$tdir
13287 $LFS mkdir -i 0 $DIR/$tdir/d0 ||
13288 error "failed to mkdir $DIR/$tdir/d0 on MDT0"
13289 $LFS mkdir -i 1 $DIR/$tdir/d0/d1 ||
13290 error "failed to mkdir $DIR/$tdir/d0/d1 on MDT1"
13292 umount_client $MOUNT || error "umount failed"
13293 #define OBD_FAIL_TGT_DELAY_CONDITIONAL 0x713
13294 do_facet mds2 lctl set_param fail_loc=0x713 fail_val=1
13295 mount_client $MOUNT || error "failed to mount client"
13297 echo "stat $DIR/$tdir/d0/d1, should not fail/ASSERT"
13298 stat $DIR/$tdir/d0/d1 || error "fail to stat $DIR/$tdir/d0/d1"
13300 run_test 240 "race between ldlm enqueue and the connection RPC (no ASSERT)"
13303 for LOOP in $(seq $1); do
13304 dd if=$DIR/$tfile of=/dev/null bs=40960 count=1 2>/dev/null
13305 cancel_lru_locks osc
13310 for LOOP in $(seq $1); do
13311 dd if=$DIR/$tfile of=/dev/null bs=40960 count=1 \
13312 iflag=direct 2>/dev/null
13317 dd if=/dev/zero of=$DIR/$tfile count=1 bs=40960
13319 cancel_lru_locks osc
13320 test_241_bio 1000 &
13325 run_test 241 "bio vs dio"
13328 dd if=/dev/zero of=$DIR/$tfile count=1 bs=40960
13330 test_241_dio 1000 &
13335 run_test 241b "dio vs dio"
13338 mkdir -p $DIR/$tdir
13339 touch $DIR/$tdir/$tfile
13341 #define OBD_FAIL_MDS_READPAGE_PACK 0x105
13342 do_facet mds1 lctl set_param fail_loc=0x105
13343 /bin/ls $DIR/$tdir && error "ls $DIR/$tdir should fail"
13345 do_facet mds1 lctl set_param fail_loc=0
13346 /bin/ls $DIR/$tdir || error "ls $DIR/$tdir failed"
13348 run_test 242 "mdt_readpage failure should not cause directory unreadable"
13352 test_mkdir -p $DIR/$tdir
13353 group_lock_test -d $DIR/$tdir || error "A group lock test failed"
13355 run_test 243 "various group lock tests"
13359 test_mkdir -p $DIR/$tdir
13360 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=35
13361 sendfile_grouplock $DIR/$tdir/$tfile || \
13362 error "sendfile+grouplock failed"
13365 run_test 244 "sendfile with group lock tests"
13368 local flagname="multi_mod_rpcs"
13369 local connect_data_name="max_mod_rpcs"
13372 # check if multiple modify RPCs flag is set
13373 out=$($LCTL get_param mdc.$FSNAME-MDT0000-*.import |
13374 grep "connect_flags:")
13377 echo "$out" | grep -qw $flagname
13378 if [ $? -ne 0 ]; then
13379 echo "connect flag $flagname is not set"
13383 # check if multiple modify RPCs data is set
13384 out=$($LCTL get_param mdc.$FSNAME-MDT0000-*.import)
13387 echo "$out" | grep -qw $connect_data_name ||
13388 error "import should have connect data $connect_data_name"
13390 run_test 245 "check mdc connection flag/data: multiple modify RPCs"
13393 [ "$(facet_fstype ost$(($($GETSTRIPE -i $DIR/$tfile) + 1)))" = "zfs" ] \
13394 && skip "no 16TB file size limit on ZFS" && return
13396 $SETSTRIPE -c 1 $DIR/$tfile
13397 # ldiskfs extent file size limit is (16TB - 4KB - 1) bytes
13398 local size=$((16 * 1024 * 1024 * 1024 * 1024 - 4096 - 1))
13399 $TRUNCATE $DIR/$tfile $size || error "truncate $tfile to $size failed"
13400 dd if=/dev/zero of=$DIR/$tfile bs=10 count=1 oflag=append \
13401 conv=notrunc,fsync && error "append succeeded"
13404 run_test 250 "Write above 16T limit"
13407 $SETSTRIPE -c -1 -S 1048576 $DIR/$tfile
13409 #define OBD_FAIL_LLITE_LOST_LAYOUT 0x1407
13410 #Skip once - writing the first stripe will succeed
13411 $LCTL set_param fail_loc=0xa0001407 fail_val=1
13412 $MULTIOP $DIR/$tfile o:O_RDWR:w2097152c 2>&1 | grep -q "short write" &&
13413 error "short write happened"
13415 $LCTL set_param fail_loc=0xa0001407 fail_val=1
13416 $MULTIOP $DIR/$tfile or2097152c 2>&1 | grep -q "short read" &&
13417 error "short read happened"
13421 run_test 251 "Handling short read and write correctly"
13431 if [ "$(facet_fstype ost1)" != "ldiskfs" -o \
13432 "$(facet_fstype mds1)" != "ldiskfs" ]; then
13433 skip "can only run lr_reader on ldiskfs target"
13437 # check lr_reader on OST0000
13439 dev=$(facet_device $tgt)
13440 out=$(do_facet $tgt $LR_READER $dev)
13441 [ $? -eq 0 ] || error "$LR_READER failed on target $tgt device $dev"
13443 uuid=$(echo "$out" | grep -i uuid | awk '{ print $2 }')
13444 [ "$uuid" == "$(ostuuid_from_index 0)" ] ||
13445 error "Invalid uuid returned by $LR_READER on target $tgt"
13446 echo -e "uuid returned by $LR_READER is '$uuid'\n"
13448 # check lr_reader -c on MDT0000
13450 dev=$(facet_device $tgt)
13451 if ! do_facet $tgt $LR_READER -h | grep -q OPTIONS; then
13452 echo "$LR_READER does not support additional options"
13455 out=$(do_facet $tgt $LR_READER -c $dev)
13456 [ $? -eq 0 ] || error "$LR_READER failed on target $tgt device $dev"
13458 num=$(echo "$out" | grep -c "mdtlov")
13459 [ "$num" -eq $((MDSCOUNT - 1)) ] ||
13460 error "Invalid number of mdtlov clients returned by $LR_READER"
13461 echo -e "Number of mdtlov clients returned by $LR_READER is '$num'\n"
13463 # check lr_reader -cr on MDT0000
13464 out=$(do_facet $tgt $LR_READER -cr $dev)
13465 [ $? -eq 0 ] || error "$LR_READER failed on target $tgt device $dev"
13467 echo "$out" | grep -q "^reply_data:$" ||
13468 error "$LR_READER should have returned 'reply_data' section"
13469 num=$(echo "$out" | grep -c "client_generation")
13470 echo -e "Number of reply data returned by $LR_READER is '$num'\n"
13472 run_test 252 "check lr_reader tool"
13475 cleanup_test_300() {
13479 test_striped_dir() {
13484 mkdir -p $DIR/$tdir
13486 SAVE_UMASK=$(umask)
13487 trap cleanup_test_300 RETURN EXIT
13489 $LFS setdirstripe -i $mdt_index -c 2 -t all_char -m 755 \
13490 $DIR/$tdir/striped_dir ||
13491 error "set striped dir error"
13493 local mode=$(stat -c%a $DIR/$tdir/striped_dir)
13494 [ "$mode" = "755" ] || error "expect 755 got $mode"
13496 $LFS getdirstripe $DIR/$tdir/striped_dir > /dev/null 2>&1 ||
13497 error "getdirstripe failed"
13498 stripe_count=$($LFS getdirstripe -c $DIR/$tdir/striped_dir)
13499 if [ "$stripe_count" != "2" ]; then
13500 error "stripe_count is $stripe_count, expect 2"
13503 stripe_index=$($LFS getdirstripe -i $DIR/$tdir/striped_dir)
13504 if [ "$stripe_index" != "$mdt_index" ]; then
13505 error "stripe_index is $stripe_index, expect $mdt_index"
13508 [ $(stat -c%h $DIR/$tdir/striped_dir) == '2' ] ||
13509 error "nlink error after create striped dir"
13511 mkdir $DIR/$tdir/striped_dir/a
13512 mkdir $DIR/$tdir/striped_dir/b
13514 stat $DIR/$tdir/striped_dir/a ||
13515 error "create dir under striped dir failed"
13516 stat $DIR/$tdir/striped_dir/b ||
13517 error "create dir under striped dir failed"
13519 [ $(stat -c%h $DIR/$tdir/striped_dir) == '4' ] ||
13520 error "nlink error after mkdir"
13522 rmdir $DIR/$tdir/striped_dir/a
13523 [ $(stat -c%h $DIR/$tdir/striped_dir) == '3' ] ||
13524 error "nlink error after rmdir"
13526 rmdir $DIR/$tdir/striped_dir/b
13527 [ $(stat -c%h $DIR/$tdir/striped_dir) == '2' ] ||
13528 error "nlink error after rmdir"
13530 chattr +i $DIR/$tdir/striped_dir
13531 createmany -o $DIR/$tdir/striped_dir/f 10 &&
13532 error "immutable flags not working under striped dir!"
13533 chattr -i $DIR/$tdir/striped_dir
13535 rmdir $DIR/$tdir/striped_dir ||
13536 error "rmdir striped dir error"
13544 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13545 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
13547 test_striped_dir 0 || error "failed on striped dir on MDT0"
13548 test_striped_dir 1 || error "failed on striped dir on MDT0"
13550 run_test 300a "basic striped dir sanity test"
13553 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13554 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
13560 test_mkdir $DIR/$tdir || error "mkdir fail"
13561 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir ||
13562 error "set striped dir error"
13563 for ((i=0; i<10; i++)); do
13564 mtime1=$(stat -c %Y $DIR/$tdir/striped_dir)
13566 touch $DIR/$tdir/striped_dir/file_$i ||
13567 error "touch error $i"
13568 mtime2=$(stat -c %Y $DIR/$tdir/striped_dir)
13569 [ $mtime1 -eq $mtime2 ] &&
13570 error "mtime not change after create"
13572 rm -f $DIR/$tdir/striped_dir/file_$i ||
13573 error "unlink error $i"
13574 mtime3=$(stat -c %Y $DIR/$tdir/striped_dir)
13575 [ $mtime2 -eq $mtime3 ] &&
13576 error "mtime did not change after unlink"
13580 run_test 300b "check ctime/mtime for striped dir"
13583 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13584 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
13587 mkdir -p $DIR/$tdir
13588 $LFS setdirstripe -i 0 -c 2 $DIR/$tdir/striped_dir ||
13589 error "set striped dir error"
13591 chown $RUNAS_ID:$RUNAS_GID $DIR/$tdir/striped_dir ||
13592 error "chown striped dir failed"
13594 $RUNAS createmany -o $DIR/$tdir/striped_dir/f 5000 ||
13595 error "create 5k files failed"
13597 file_count=$(ls $DIR/$tdir/striped_dir | wc -l)
13599 [ "$file_count" = 5000 ] || error "file count $file_count != 5000"
13603 run_test 300c "chown && check ls under striped directory"
13606 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13607 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
13611 mkdir -p $DIR/$tdir
13612 $SETSTRIPE -c 2 $DIR/$tdir
13614 #local striped directory
13615 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir ||
13616 error "set striped dir error"
13617 createmany -o $DIR/$tdir/striped_dir/f 10 ||
13618 error "create 10 files failed"
13620 #remote striped directory
13621 $LFS setdirstripe -i 1 -c 2 $DIR/$tdir/remote_striped_dir ||
13622 error "set striped dir error"
13623 createmany -o $DIR/$tdir/remote_striped_dir/f 10 ||
13624 error "create 10 files failed"
13626 for file in $(find $DIR/$tdir); do
13627 stripe_count=$($GETSTRIPE -c $file)
13628 [ $stripe_count -eq 2 ] ||
13629 error "wrong stripe $stripe_count for $file"
13634 run_test 300d "check default stripe under striped directory"
13637 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
13638 skip "Need MDS version at least 2.7.55" && return
13639 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13640 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
13644 mkdir -p $DIR/$tdir
13646 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir ||
13647 error "set striped dir error"
13649 touch $DIR/$tdir/striped_dir/a
13650 touch $DIR/$tdir/striped_dir/b
13651 touch $DIR/$tdir/striped_dir/c
13653 mkdir $DIR/$tdir/striped_dir/dir_a
13654 mkdir $DIR/$tdir/striped_dir/dir_b
13655 mkdir $DIR/$tdir/striped_dir/dir_c
13657 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir/stp_a ||
13658 error "set striped dir under striped dir error"
13660 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir/stp_b ||
13661 error "set striped dir under striped dir error"
13663 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir/stp_c ||
13664 error "set striped dir under striped dir error"
13666 mrename $DIR/$tdir/striped_dir/dir_a $DIR/$tdir/striped_dir/dir_b ||
13667 error "rename dir under striped dir fails"
13669 mrename $DIR/$tdir/striped_dir/stp_a $DIR/$tdir/striped_dir/stp_b ||
13670 error "rename dir under different stripes fails"
13672 mrename $DIR/$tdir/striped_dir/a $DIR/$tdir/striped_dir/c ||
13673 error "rename file under striped dir should succeed"
13675 mrename $DIR/$tdir/striped_dir/dir_b $DIR/$tdir/striped_dir/dir_c ||
13676 error "rename dir under striped dir should succeed"
13680 run_test 300e "check rename under striped directory"
13683 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
13684 skip "Need MDS version at least 2.7.55" && return
13685 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13686 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
13691 mkdir -p $DIR/$tdir
13693 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir ||
13694 error "set striped dir error"
13696 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir1 ||
13697 error "set striped dir error"
13699 touch $DIR/$tdir/striped_dir/a
13700 mkdir $DIR/$tdir/striped_dir/dir_a
13701 $LFS setdirstripe -i 0 -c 2 $DIR/$tdir/striped_dir/stp_a ||
13702 error "create striped dir under striped dir fails"
13704 touch $DIR/$tdir/striped_dir1/b
13705 mkdir $DIR/$tdir/striped_dir1/dir_b
13706 $LFS setdirstripe -i 0 -c 2 $DIR/$tdir/striped_dir/stp_b ||
13707 error "create striped dir under striped dir fails"
13709 mrename $DIR/$tdir/striped_dir/dir_a $DIR/$tdir/striped_dir1/dir_b ||
13710 error "rename dir under different striped dir should fail"
13712 mrename $DIR/$tdir/striped_dir/stp_a $DIR/$tdir/striped_dir1/stp_b ||
13713 error "rename striped dir under diff striped dir should fail"
13715 mrename $DIR/$tdir/striped_dir/a $DIR/$tdir/striped_dir1/a ||
13716 error "rename file under diff striped dirs fails"
13720 run_test 300f "check rename cross striped directory"
13722 test_300_check_default_striped_dir()
13725 local default_count=$2
13726 local default_index=$3
13729 local dir_stripe_index
13732 echo "checking $dirname $default_count $default_index"
13733 $LFS setdirstripe -D -c $default_count -i $default_index \
13734 -t all_char $DIR/$tdir/$dirname ||
13735 error "set default stripe on striped dir error"
13736 stripe_count=$($LFS getdirstripe -D -c $DIR/$tdir/$dirname)
13737 [ $stripe_count -eq $default_count ] ||
13738 error "expect $default_count get $stripe_count for $dirname"
13740 stripe_index=$($LFS getdirstripe -D -i $DIR/$tdir/$dirname)
13741 [ $stripe_index -eq $default_index ] ||
13742 error "expect $default_index get $stripe_index for $dirname"
13744 mkdir $DIR/$tdir/$dirname/{test1,test2,test3,test4} ||
13745 error "create dirs failed"
13747 createmany -o $DIR/$tdir/$dirname/f- 10 || error "create files failed"
13748 unlinkmany $DIR/$tdir/$dirname/f- 10 || error "unlink files failed"
13749 for dir in $(find $DIR/$tdir/$dirname/*); do
13750 stripe_count=$($LFS getdirstripe -c $dir)
13751 [ $stripe_count -eq $default_count ] ||
13752 [ $stripe_count -eq 0 -o $default_count -eq 1 ] ||
13753 error "stripe count $default_count != $stripe_count for $dir"
13755 stripe_index=$($LFS getdirstripe -i $dir)
13756 [ $default_index -eq -1 -o $stripe_index -eq $default_index ] ||
13757 error "$stripe_index != $default_index for $dir"
13759 #check default stripe
13760 stripe_count=$($LFS getdirstripe -D -c $dir)
13761 [ $stripe_count -eq $default_count ] ||
13762 error "default count $default_count != $stripe_count for $dir"
13764 stripe_index=$($LFS getdirstripe -D -i $dir)
13765 [ $stripe_index -eq $default_index ] ||
13766 error "default index $default_index != $stripe_index for $dir"
13768 rmdir $DIR/$tdir/$dirname/* || error "rmdir failed"
13772 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
13773 skip "Need MDS version at least 2.7.55" && return
13774 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
13780 mkdir $DIR/$tdir/normal_dir
13782 test_300_check_default_striped_dir normal_dir $MDSCOUNT 1
13783 test_300_check_default_striped_dir normal_dir 1 0
13784 test_300_check_default_striped_dir normal_dir 2 1
13785 test_300_check_default_striped_dir normal_dir 2 -1
13787 #delete default stripe information
13788 echo "delete default stripeEA"
13789 $LFS setdirstripe -d $DIR/$tdir/normal_dir ||
13790 error "set default stripe on striped dir error"
13792 mkdir -p $DIR/$tdir/normal_dir/{test1,test2,test3,test4}
13793 for dir in $(find $DIR/$tdir/normal_dir/*); do
13794 stripe_count=$($LFS getdirstripe -c $dir)
13795 [ $stripe_count -eq 0 ] ||
13796 error "expect 1 get $stripe_count for $dir"
13797 stripe_index=$($LFS getdirstripe -i $dir)
13798 [ $stripe_index -eq 0 ] ||
13799 error "expect 0 get $stripe_index for $dir"
13802 run_test 300g "check default striped directory for normal directory"
13805 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
13806 skip "Need MDS version at least 2.7.55" && return
13807 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
13812 $LFS setdirstripe -i 0 -c $MDSCOUNT -t all_char \
13813 $DIR/$tdir/striped_dir ||
13814 error "set striped dir error"
13816 test_300_check_default_striped_dir striped_dir $MDSCOUNT 1
13817 test_300_check_default_striped_dir striped_dir 1 0
13818 test_300_check_default_striped_dir striped_dir 2 1
13819 test_300_check_default_striped_dir striped_dir 2 -1
13821 #delete default stripe information
13822 $LFS setdirstripe -d $DIR/$tdir/striped_dir ||
13823 error "set default stripe on striped dir error"
13825 mkdir -p $DIR/$tdir/striped_dir/{test1,test2,test3,test4}
13826 for dir in $(find $DIR/$tdir/striped_dir/*); do
13827 stripe_count=$($LFS getdirstripe -c $dir)
13828 [ $stripe_count -eq 0 ] ||
13829 error "expect 1 get $stripe_count for $dir"
13832 run_test 300h "check default striped directory for striped directory"
13835 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
13836 skip "Need MDS version at least 2.7.55" && return
13837 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13838 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
13844 $LFS setdirstripe -i 0 -c$MDSCOUNT -t all_char $DIR/$tdir/striped_dir ||
13845 error "set striped dir error"
13847 createmany -o $DIR/$tdir/striped_dir/f- 10 ||
13848 error "create files under striped dir failed"
13850 # unfortunately, we need to umount to clear dir layout cache for now
13851 # once we fully implement dir layout, we can drop this
13852 umount_client $MOUNT || error "umount failed"
13853 mount_client $MOUNT || error "mount failed"
13855 #set the stripe to be unknown hash type
13856 #define OBD_FAIL_UNKNOWN_LMV_STRIPE 0x1901
13857 $LCTL set_param fail_loc=0x1901
13858 for ((i = 0; i < 10; i++)); do
13859 $CHECKSTAT -t file $DIR/$tdir/striped_dir/f-$i ||
13860 error "stat f-$i failed"
13861 rm $DIR/$tdir/striped_dir/f-$i || error "unlink f-$i failed"
13864 touch $DIR/$tdir/striped_dir/f0 &&
13865 error "create under striped dir with unknown hash should fail"
13867 $LCTL set_param fail_loc=0
13869 umount_client $MOUNT || error "umount failed"
13870 mount_client $MOUNT || error "mount failed"
13874 run_test 300i "client handle unknown hash type striped directory"
13877 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13878 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
13879 skip "Need MDS version at least 2.7.55" && return
13880 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
13886 #define OBD_FAIL_SPLIT_UPDATE_REC 0x1702
13887 $LCTL set_param fail_loc=0x1702
13888 $LFS setdirstripe -i 0 -c$MDSCOUNT -t all_char $DIR/$tdir/striped_dir ||
13889 error "set striped dir error"
13891 createmany -o $DIR/$tdir/striped_dir/f- 10 ||
13892 error "create files under striped dir failed"
13894 $LCTL set_param fail_loc=0
13896 rm -rf $DIR/$tdir || error "unlink striped dir fails"
13900 run_test 300j "test large update record"
13903 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
13904 skip "Need MDS version at least 2.7.55" && return
13905 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13906 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
13912 #define OBD_FAIL_LARGE_STRIPE 0x1703
13913 $LCTL set_param fail_loc=0x1703
13914 $LFS setdirstripe -i 0 -c512 $DIR/$tdir/striped_dir ||
13915 error "set striped dir error"
13916 $LCTL set_param fail_loc=0
13918 $LFS getdirstripe $DIR/$tdir/striped_dir ||
13919 error "getstripeddir fails"
13920 rm -rf $DIR/$tdir/striped_dir ||
13921 error "unlink striped dir fails"
13925 run_test 300k "test large striped directory"
13928 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
13929 skip "Need MDS version at least 2.7.55" && return
13930 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13931 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
13934 test_mkdir -p $DIR/$tdir/striped_dir
13935 chown $RUNAS_ID $DIR/$tdir/striped_dir ||
13936 error "chown $RUNAS_ID failed"
13937 $LFS setdirstripe -i 1 -D $DIR/$tdir/striped_dir ||
13938 error "set default striped dir failed"
13940 #define OBD_FAIL_MDS_STALE_DIR_LAYOUT 0x158
13941 $LCTL set_param fail_loc=0x80000158
13942 $RUNAS mkdir $DIR/$tdir/striped_dir/test_dir || error "create dir fails"
13944 stripe_index=$($LFS getdirstripe -i $DIR/$tdir/striped_dir/test_dir)
13945 [ $stripe_index -eq 1 ] ||
13946 error "expect 1 get $stripe_index for $dir"
13948 run_test 300l "non-root user to create dir under striped dir with stale layout"
13951 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
13952 skip "Need MDS version at least 2.7.55" && return
13953 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13954 [ $MDSCOUNT -ge 2 ] && skip "Only for single MDT" && return
13956 mkdir -p $DIR/$tdir/striped_dir
13957 $LFS setdirstripe -D -c 1 $DIR/$tdir/striped_dir ||
13958 error "set default stripes dir error"
13960 mkdir $DIR/$tdir/striped_dir/a || error "mkdir a fails"
13962 stripe_count=$($LFS getdirstripe -c $DIR/$tdir/striped_dir/a)
13963 [ $stripe_count -eq 0 ] ||
13964 error "expect 0 get $stripe_count for a"
13966 $LFS setdirstripe -D -c 2 $DIR/$tdir/striped_dir ||
13967 error "set default stripes dir error"
13969 mkdir $DIR/$tdir/striped_dir/b || error "mkdir b fails"
13971 stripe_count=$($LFS getdirstripe -c $DIR/$tdir/striped_dir/b)
13972 [ $stripe_count -eq 0 ] ||
13973 error "expect 0 get $stripe_count for b"
13975 $LFS setdirstripe -D -c1 -i2 $DIR/$tdir/striped_dir ||
13976 error "set default stripes dir error"
13978 mkdir $DIR/$tdir/striped_dir/c &&
13979 error "default stripe_index is invalid, mkdir c should fails"
13981 rm -rf $DIR/$tdir || error "rmdir fails"
13983 run_test 300m "setstriped directory on single MDT FS"
13986 local list=$(comma_list $(mdts_nodes))
13989 do_nodes $list $LCTL set_param -n mdt.*.enable_remote_dir_gid=0
13993 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
13994 skip "Need MDS version at least 2.7.55" && return
13995 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13996 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
13998 local list=$(comma_list $(mdts_nodes))
14000 trap cleanup_300n RETURN EXIT
14001 mkdir -p $DIR/$tdir
14002 chmod 777 $DIR/$tdir
14003 $RUNAS $LFS setdirstripe -i0 -c$MDSCOUNT \
14004 $DIR/$tdir/striped_dir > /dev/null 2>&1 &&
14005 error "create striped dir succeeds with gid=0"
14007 do_nodes $list $LCTL set_param -n mdt.*.enable_remote_dir_gid=-1
14008 $RUNAS $LFS setdirstripe -i0 -c$MDSCOUNT $DIR/$tdir/striped_dir ||
14009 error "create striped dir fails with gid=-1"
14011 do_nodes $list $LCTL set_param -n mdt.*.enable_remote_dir_gid=0
14012 $RUNAS $LFS setdirstripe -i 1 -c$MDSCOUNT -D \
14013 $DIR/$tdir/striped_dir > /dev/null 2>&1 &&
14014 error "set default striped dir succeeds with gid=0"
14017 do_nodes $list $LCTL set_param -n mdt.*.enable_remote_dir_gid=-1
14018 $RUNAS $LFS setdirstripe -i 1 -c$MDSCOUNT -D $DIR/$tdir/striped_dir ||
14019 error "set default striped dir fails with gid=-1"
14022 do_nodes $list $LCTL set_param -n mdt.*.enable_remote_dir_gid=0
14023 $RUNAS mkdir $DIR/$tdir/striped_dir/test_dir ||
14024 error "create test_dir fails"
14025 $RUNAS mkdir $DIR/$tdir/striped_dir/test_dir1 ||
14026 error "create test_dir1 fails"
14027 $RUNAS mkdir $DIR/$tdir/striped_dir/test_dir2 ||
14028 error "create test_dir2 fails"
14031 run_test 300n "non-root user to create dir under striped dir with default EA"
14034 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
14035 skip "Need MDS version at least 2.7.55" && return
14036 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
14037 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
14041 mkdir -p $DIR/$tdir
14043 numfree1=$(lctl get_param -n mdc.*MDT0000*.filesfree)
14044 numfree2=$(lctl get_param -n mdc.*MDT0001*.filesfree)
14045 if [ $numfree1 -lt 66000 -o $numfree2 -lt 66000 ]; then
14046 skip "not enough free inodes $numfree1 $numfree2"
14050 numfree1=$(lctl get_param -n mdc.*MDT0000-mdc-*.kbytesfree)
14051 numfree2=$(lctl get_param -n mdc.*MDT0001-mdc-*.kbytesfree)
14052 if [ $numfree1 -lt 300000 -o $numfree2 -lt 300000 ]; then
14053 skip "not enough free space $numfree1 $numfree2"
14057 $LFS setdirstripe -c2 $DIR/$tdir/striped_dir ||
14058 error "setdirstripe fails"
14060 createmany -d $DIR/$tdir/striped_dir/d 131000 ||
14061 error "create dirs fails"
14063 $LCTL set_param ldlm.namespaces.*mdc-*.lru_size=0
14064 ls $DIR/$tdir/striped_dir > /dev/null ||
14065 error "ls striped dir fails"
14066 unlinkmany -d $DIR/$tdir/striped_dir/d 131000 ||
14067 error "unlink big striped dir fails"
14069 run_test 300o "unlink big sub stripe(> 65000 subdirs)"
14071 prepare_remote_file() {
14072 mkdir $DIR/$tdir/src_dir ||
14073 error "create remote source failed"
14075 cp /etc/hosts $DIR/$tdir/src_dir/a || error
14076 touch $DIR/$tdir/src_dir/a
14078 $LFS mkdir -i 1 $DIR/$tdir/tgt_dir ||
14079 error "create remote target dir failed"
14081 touch $DIR/$tdir/tgt_dir/b
14083 mrename $DIR/$tdir/src_dir/a $DIR/$tdir/tgt_dir/b ||
14084 error "rename dir cross MDT failed!"
14086 $CHECKSTAT -t file $DIR/$tdir/src_dir/a &&
14087 error "src_child still exists after rename"
14089 $CHECKSTAT -t file $DIR/$tdir/tgt_dir/b ||
14090 error "missing file(a) after rename"
14092 diff /etc/hosts $DIR/$tdir/tgt_dir/b ||
14093 error "diff after rename"
14097 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 4 MDTs" && return
14098 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
14099 local remote_file=$DIR/$tdir/tgt_dir/b
14101 mkdir -p $DIR/$tdir
14103 prepare_remote_file || error "prepare remote file failed"
14106 $OPENUNLINK $remote_file $remote_file || error
14107 $CHECKSTAT -a $remote_file || error
14109 run_test 310a "open unlink remote file"
14112 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 4 MDTs" && return
14113 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
14114 local remote_file=$DIR/$tdir/tgt_dir/b
14116 mkdir -p $DIR/$tdir
14118 prepare_remote_file || error "prepare remote file failed"
14120 ln $remote_file $DIR/$tfile || error "link failed for remote file"
14121 $MULTIOP $DIR/$tfile Ouc || error "mulitop failed"
14122 $CHECKSTAT -t file $remote_file || error "check file failed"
14124 run_test 310b "unlink remote file with multiple links while open"
14127 [[ $MDSCOUNT -lt 4 ]] && skip "needs >= 4 MDTs" && return
14128 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
14129 local remote_file=$DIR/$tdir/tgt_dir/b
14131 mkdir -p $DIR/$tdir
14133 prepare_remote_file || error "prepare remote file failed"
14135 ln $remote_file $DIR/$tfile || error "link failed for remote file"
14136 multiop_bg_pause $remote_file O_uc ||
14137 error "mulitop failed for remote file"
14139 $MULTIOP $DIR/$tfile Ouc
14140 kill -USR1 $MULTIPID
14143 run_test 310c "open-unlink remote file with multiple links"
14145 test_400a() { # LU-1606, was conf-sanity test_74
14146 local extra_flags=''
14147 local out=$TMP/$tfile
14148 local prefix=/usr/include/lustre
14151 if ! which $CC > /dev/null 2>&1; then
14152 skip_env "$CC is not installed"
14156 if ! [[ -d $prefix ]]; then
14157 # Assume we're running in tree and fixup the include path.
14158 extra_flags+=" -I$LUSTRE/../libcfs/include"
14159 extra_flags+=" -I$LUSTRE/include"
14160 extra_flags+=" -L$LUSTRE/utils"
14163 for prog in $LUSTRE_TESTS_API_DIR/*.c; do
14164 $CC -Wall -Werror $extra_flags -llustreapi -o $out $prog ||
14165 error "client api broken"
14168 run_test 400a "Lustre client api program can compile and link"
14170 test_400b() { # LU-1606, LU-5011
14172 local out=$TMP/$tfile
14173 local prefix=/usr/include/lustre
14175 # We use a hard coded prefix so that this test will not fail
14176 # when run in tree. There are headers in lustre/include/lustre/
14177 # that are not packaged (like lustre_idl.h) and have more
14178 # complicated include dependencies (like config.h and lnet/types.h).
14179 # Since this test about correct packaging we just skip them when
14180 # they don't exist (see below) rather than try to fixup cppflags.
14182 if ! which $CC > /dev/null 2>&1; then
14183 skip_env "$CC is not installed"
14187 for header in $prefix/*.h; do
14188 if ! [[ -f "$header" ]]; then
14192 if [[ "$(basename $header)" == liblustreapi.h ]]; then
14193 continue # liblustreapi.h is deprecated.
14196 $CC -Wall -Werror -include $header -c -x c /dev/null -o $out ||
14197 error "cannot compile '$header'"
14200 run_test 400b "packaged headers can be compiled"
14203 # tests that do cleanup/setup should be run at the end
14207 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
14209 #define OBD_FAIL_MGC_PAUSE_PROCESS_LOG 0x903
14210 $LCTL set_param fail_loc=0x903
14212 cancel_lru_locks MGC
14214 FAIL_ON_ERROR=true cleanup
14215 FAIL_ON_ERROR=true setup
14217 run_test 900 "umount should not race with any mgc requeue thread"
14220 [ -f $EXT2_DEV ] && rm $EXT2_DEV || true
14221 check_and_cleanup_lustre
14222 if [ "$I_MOUNTED" != "yes" ]; then
14223 lctl set_param debug="$OLDDEBUG" 2> /dev/null || true