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
561 remote_mds_nodsh && skip "remote MDS with nodsh" && return
562 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] &&
563 [ $(lustre_version_code $SINGLEMDS) -le $(version_code 2.2.93) ] &&
564 skip "MDS 2.2.0-2.2.93 do not NUL-terminate symlinks" && return
566 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
567 skip "only for ldiskfs MDT" && return 0
569 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
573 # create a long symlink file
574 for ((i = 0; i < 4; ++i)); do
575 long_sym=${long_sym}${long_sym}
578 echo "create 512 short and long symlink files under $WDIR"
579 for ((i = 0; i < 256; ++i)); do
580 ln -sf ${long_sym}"a5a5" $WDIR/long-$i
581 ln -sf ${short_sym}"a5a5" $WDIR/short-$i
587 wait_delete_completed
589 echo "recreate the 512 symlink files with a shorter string"
590 for ((i = 0; i < 512; ++i)); do
591 # rewrite the symlink file with a shorter string
592 ln -sf ${long_sym} $WDIR/long-$i || error "long_sym failed"
593 ln -sf ${short_sym} $WDIR/short-$i || error "short_sym failed"
596 local mds_index=$(($($LFS getstripe -M $WDIR) + 1))
597 local devname=$(mdsdevname $mds_index)
599 echo "stop and checking mds${mds_index}:"
600 # e2fsck should not return error
602 run_e2fsck $(facet_active_host mds${mds_index}) $devname -n
605 start mds${mds_index} $devname $MDS_MOUNT_OPTS || error "start failed"
606 df $MOUNT > /dev/null 2>&1
608 error "e2fsck detected error for short/long symlink: rc=$rc"
610 run_test 17m "run e2fsck against MDT which contains short/long symlink"
612 check_fs_consistency_17n() {
616 # create/unlink in 17n only change 2 MDTs(MDT1/MDT2),
617 # so it only check MDT1/MDT2 instead of all of MDTs.
618 for mdt_index in 1 2; do
619 local devname=$(mdsdevname $mdt_index)
620 # e2fsck should not return error
622 run_e2fsck $(facet_active_host mds$mdt_index) $devname -n ||
625 start mds${mdt_index} $devname $MDS_MOUNT_OPTS ||
626 error "mount mds$mdt_index failed"
627 df $MOUNT > /dev/null 2>&1
635 remote_mds_nodsh && skip "remote MDS with nodsh" && return
636 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] &&
637 [ $(lustre_version_code $SINGLEMDS) -le $(version_code 2.2.93) ] &&
638 skip "MDS 2.2.0-2.2.93 do not NUL-terminate symlinks" && return
640 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
641 skip "only for ldiskfs MDT" && return 0
643 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 2 MDTs" && return
645 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
647 test_mkdir $DIR/$tdir
648 for ((i=0; i<10; i++)); do
649 $LFS mkdir -i1 -c2 $DIR/$tdir/remote_dir_${i} ||
650 error "create remote dir error $i"
651 createmany -o $DIR/$tdir/remote_dir_${i}/f 10 ||
652 error "create files under remote dir failed $i"
655 check_fs_consistency_17n ||
656 error "e2fsck report error after create files under remote dir"
658 for ((i = 0; i < 10; i++)); do
659 rm -rf $DIR/$tdir/remote_dir_${i} ||
660 error "destroy remote dir error $i"
663 check_fs_consistency_17n ||
664 error "e2fsck report error after unlink files under remote dir"
666 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.50) ] &&
667 skip "lustre < 2.4.50 does not support migrate mv " && return
669 for ((i = 0; i < 10; i++)); do
670 mkdir -p $DIR/$tdir/remote_dir_${i}
671 createmany -o $DIR/$tdir/remote_dir_${i}/f 10 ||
672 error "create files under remote dir failed $i"
673 $LFS migrate --mdt-index 1 $DIR/$tdir/remote_dir_${i} ||
674 error "migrate remote dir error $i"
676 check_fs_consistency_17n || error "e2fsck report error after migration"
678 for ((i = 0; i < 10; i++)); do
679 rm -rf $DIR/$tdir/remote_dir_${i} ||
680 error "destroy remote dir error $i"
683 check_fs_consistency_17n || error "e2fsck report error after unlink"
685 run_test 17n "run e2fsck against master/slave MDT which contains remote dir"
688 remote_mds_nodsh && skip "remote MDS with nodsh" && return
689 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.3.64) ] &&
690 skip "Need MDS version at least 2.3.64" && return
692 local WDIR=$DIR/${tdir}o
697 mdt_index=$($LFS getstripe -M $WDIR)
698 mdt_index=$((mdt_index+1))
702 #fail mds will wait the failover finish then set
703 #following fail_loc to avoid interfer the recovery process.
706 #define OBD_FAIL_OSD_LMA_INCOMPAT 0x194
707 do_facet mds${mdt_index} lctl set_param fail_loc=0x194
708 ls -l $WDIR/$tfile && rc=1
709 do_facet mds${mdt_index} lctl set_param fail_loc=0
710 [[ $rc -ne 0 ]] && error "stat file should fail"
713 run_test 17o "stat file with incompat LMA feature"
716 touch $DIR/$tfile || error "Failed to touch $DIR/$tfile: $?"
717 ls $DIR || error "Failed to ls $DIR: $?"
719 run_test 18 "touch .../f ; ls ... =============================="
725 $CHECKSTAT -a $DIR/$tfile || error "$tfile was not removed"
727 run_test 19a "touch .../f19 ; ls -l ... ; rm .../f19 ==========="
730 ls -l $DIR/$tfile && error "ls -l $tfile failed"|| true
732 run_test 19b "ls -l .../f19 (should return error) =============="
735 [ $RUNAS_ID -eq $UID ] &&
736 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
737 $RUNAS touch $DIR/$tfile && error "create non-root file failed" || true
739 run_test 19c "$RUNAS touch .../f19 (should return error) =="
742 cat $DIR/f19 && error || true
744 run_test 19d "cat .../f19 (should return error) =============="
756 $CHECKSTAT -a $DIR/$tfile || error "$tfile was not removed"
758 run_test 20 "touch .../f ; ls -l ... ==========================="
761 test_mkdir -p $DIR/$tdir
762 [ -f $DIR/$tdir/dangle ] && rm -f $DIR/$tdir/dangle
763 ln -s dangle $DIR/$tdir/link
764 echo foo >> $DIR/$tdir/link
765 cat $DIR/$tdir/dangle
766 $CHECKSTAT -t link $DIR/$tdir/link || error "$tdir/link not a link"
767 $CHECKSTAT -f -t file $DIR/$tdir/link ||
768 error "$tdir/link not linked to a file"
770 run_test 21 "write to dangling link ============================"
774 test_mkdir -p $DIR/$tdir
775 chown $RUNAS_ID:$RUNAS_GID $WDIR
776 (cd $WDIR || error "cd $WDIR failed";
777 $RUNAS tar cf - /etc/hosts /etc/sysconfig/network | \
779 ls -lR $WDIR/etc || error "ls -lR $WDIR/etc failed"
780 $CHECKSTAT -t dir $WDIR/etc || error "checkstat -t dir failed"
781 $CHECKSTAT -u \#$RUNAS_ID -g \#$RUNAS_GID $WDIR/etc || error "checkstat -u failed"
783 run_test 22 "unpack tar archive as non-root user ==============="
787 test_mkdir -p $DIR/$tdir
788 local file=$DIR/$tdir/$tfile
790 openfile -f O_CREAT:O_EXCL $file || error "$file create failed"
791 openfile -f O_CREAT:O_EXCL $file &&
792 error "$file recreate succeeded" || true
794 run_test 23a "O_CREAT|O_EXCL in subdir =========================="
796 test_23b() { # bug 18988
797 test_mkdir -p $DIR/$tdir
798 local file=$DIR/$tdir/$tfile
801 echo foo > $file || error "write filed"
802 echo bar >> $file || error "append filed"
803 $CHECKSTAT -s 8 $file || error "wrong size"
806 run_test 23b "O_APPEND check =========================="
810 echo '-- same directory rename'
811 test_mkdir $DIR/$tdir
812 touch $DIR/$tdir/$tfile.1
813 mv $DIR/$tdir/$tfile.1 $DIR/$tdir/$tfile.2
814 $CHECKSTAT -t file $DIR/$tdir/$tfile.2 || error "$tfile.2 not a file"
816 run_test 24a "rename file to non-existent target"
819 test_mkdir $DIR/$tdir
820 touch $DIR/$tdir/$tfile.{1,2}
821 mv $DIR/$tdir/$tfile.1 $DIR/$tdir/$tfile.2
822 $CHECKSTAT -a $DIR/$tdir/$tfile.1 || error "$tfile.1 exists"
823 $CHECKSTAT -t file $DIR/$tdir/$tfile.2 || error "$tfile.2 not a file"
825 run_test 24b "rename file to existing target"
828 test_mkdir $DIR/$tdir
829 test_mkdir $DIR/$tdir/d$testnum.1
830 mv $DIR/$tdir/d$testnum.1 $DIR/$tdir/d$testnum.2
831 $CHECKSTAT -a $DIR/$tdir/d$testnum.1 || error "d$testnum.1 exists"
832 $CHECKSTAT -t dir $DIR/$tdir/d$testnum.2 || error "d$testnum.2 not dir"
834 run_test 24c "rename directory to non-existent target"
837 test_mkdir -c1 $DIR/$tdir
838 test_mkdir -c1 $DIR/$tdir/d$testnum.1
839 test_mkdir -c1 $DIR/$tdir/d$testnum.2
840 mrename $DIR/$tdir/d$testnum.1 $DIR/$tdir/d$testnum.2
841 $CHECKSTAT -a $DIR/$tdir/d$testnum.1 || error "d$testnum.1 exists"
842 $CHECKSTAT -t dir $DIR/$tdir/d$testnum.2 || error "d$testnum.2 not dir"
844 run_test 24d "rename directory to existing target"
847 echo '-- cross directory renames --'
851 mv $DIR/R5a/f $DIR/R5b/g
852 $CHECKSTAT -a $DIR/R5a/f || error
853 $CHECKSTAT -t file $DIR/R5b/g || error
855 run_test 24e "touch .../R5a/f; rename .../R5a/f .../R5b/g ======"
860 touch $DIR/R6a/f $DIR/R6b/g
861 mv $DIR/R6a/f $DIR/R6b/g
862 $CHECKSTAT -a $DIR/R6a/f || error
863 $CHECKSTAT -t file $DIR/R6b/g || error
865 run_test 24f "touch .../R6a/f R6b/g; mv .../R6a/f .../R6b/g ===="
870 test_mkdir $DIR/R7a/d
871 mv $DIR/R7a/d $DIR/R7b/e
872 $CHECKSTAT -a $DIR/R7a/d || error
873 $CHECKSTAT -t dir $DIR/R7b/e || error
875 run_test 24g "mkdir .../R7{a,b}/d; mv .../R7a/d .../R7b/e ======"
878 test_mkdir -c1 $DIR/R8a
879 test_mkdir -c1 $DIR/R8b
880 test_mkdir -c1 $DIR/R8a/d
881 test_mkdir -c1 $DIR/R8b/e
882 mrename $DIR/R8a/d $DIR/R8b/e
883 $CHECKSTAT -a $DIR/R8a/d || error
884 $CHECKSTAT -t dir $DIR/R8b/e || error
886 run_test 24h "mkdir .../R8{a,b}/{d,e}; rename .../R8a/d .../R8b/e"
889 echo "-- rename error cases"
893 mrename $DIR/R9/f $DIR/R9/a
894 $CHECKSTAT -t file $DIR/R9/f || error
895 $CHECKSTAT -t dir $DIR/R9/a || error
896 $CHECKSTAT -a $DIR/R9/a/f || error
898 run_test 24i "rename file to dir error: touch f ; mkdir a ; rename f a"
902 mrename $DIR/R10/f $DIR/R10/g
903 $CHECKSTAT -t dir $DIR/R10 || error
904 $CHECKSTAT -a $DIR/R10/f || error
905 $CHECKSTAT -a $DIR/R10/g || error
907 run_test 24j "source does not exist ============================"
911 test_mkdir $DIR/R11a/d
913 mv $DIR/R11a/f $DIR/R11a/d
914 $CHECKSTAT -a $DIR/R11a/f || error
915 $CHECKSTAT -t file $DIR/R11a/d/f || error
917 run_test 24k "touch .../R11a/f; mv .../R11a/f .../R11a/d ======="
919 # bug 2429 - rename foo foo foo creates invalid file
922 $MULTIOP $f OcNs || error
924 run_test 24l "Renaming a file to itself ========================"
928 $MULTIOP $f OcLN ${f}2 ${f}2 || error "link ${f}2 ${f}2 failed"
929 # on ext3 this does not remove either the source or target files
930 # though the "expected" operation would be to remove the source
931 $CHECKSTAT -t file ${f} || error "${f} missing"
932 $CHECKSTAT -t file ${f}2 || error "${f}2 missing"
934 run_test 24m "Renaming a file to a hard link to itself ========="
938 # this stats the old file after it was renamed, so it should fail
942 $CHECKSTAT ${f}.rename
945 run_test 24n "Statting the old file after renaming (Posix rename 2)"
948 test_mkdir -p $DIR/d24o
949 rename_many -s random -v -n 10 $DIR/d24o
951 run_test 24o "rename of files during htree split ==============="
956 DIRINO=`ls -lid $DIR/R12a | awk '{ print $1 }'`
957 mrename $DIR/R12a $DIR/R12b
958 $CHECKSTAT -a $DIR/R12a || error
959 $CHECKSTAT -t dir $DIR/R12b || error
960 DIRINO2=`ls -lid $DIR/R12b | awk '{ print $1 }'`
961 [ "$DIRINO" = "$DIRINO2" ] || error "R12a $DIRINO != R12b $DIRINO2"
963 run_test 24p "mkdir .../R12{a,b}; rename .../R12a .../R12b"
965 cleanup_multiop_pause() {
971 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
974 local DIRINO=$(ls -lid $DIR/R13a | awk '{ print $1 }')
975 multiop_bg_pause $DIR/R13b D_c || error "multiop failed to start"
978 trap cleanup_multiop_pause EXIT
979 mrename $DIR/R13a $DIR/R13b
980 $CHECKSTAT -a $DIR/R13a || error "R13a still exists"
981 $CHECKSTAT -t dir $DIR/R13b || error "R13b does not exist"
982 local DIRINO2=$(ls -lid $DIR/R13b | awk '{ print $1 }')
983 [ "$DIRINO" = "$DIRINO2" ] || error "R13a $DIRINO != R13b $DIRINO2"
984 cleanup_multiop_pause
985 wait $MULTIPID || error "multiop close failed"
987 run_test 24q "mkdir .../R13{a,b}; open R13b rename R13a R13b ==="
989 test_24r() { #bug 3789
991 test_mkdir $DIR/R14a/b
992 mrename $DIR/R14a $DIR/R14a/b && error "rename to subdir worked!"
993 $CHECKSTAT -t dir $DIR/R14a || error "$DIR/R14a missing"
994 $CHECKSTAT -t dir $DIR/R14a/b || error "$DIR/R14a/b missing"
996 run_test 24r "mkdir .../R14a/b; rename .../R14a .../R14a/b ====="
1000 test_mkdir $DIR/R15a/b
1001 test_mkdir $DIR/R15a/b/c
1002 mrename $DIR/R15a $DIR/R15a/b/c && error "rename to sub-subdir worked!"
1003 $CHECKSTAT -t dir $DIR/R15a || error "$DIR/R15a missing"
1004 $CHECKSTAT -t dir $DIR/R15a/b/c || error "$DIR/R15a/b/c missing"
1006 run_test 24s "mkdir .../R15a/b/c; rename .../R15a .../R15a/b/c ="
1008 test_mkdir $DIR/R16a
1009 test_mkdir $DIR/R16a/b
1010 test_mkdir $DIR/R16a/b/c
1011 mrename $DIR/R16a/b/c $DIR/R16a && error "rename to sub-subdir worked!"
1012 $CHECKSTAT -t dir $DIR/R16a || error "$DIR/R16a missing"
1013 $CHECKSTAT -t dir $DIR/R16a/b/c || error "$DIR/R16a/b/c missing"
1015 run_test 24t "mkdir .../R16a/b/c; rename .../R16a/b/c .../R16a ="
1017 test_24u() { # bug12192
1018 $MULTIOP $DIR/$tfile C2w$((2048 * 1024))c || error
1019 $CHECKSTAT -s $((2048 * 1024)) $DIR/$tfile || error "wrong file size"
1021 run_test 24u "create stripe file"
1027 simple_cleanup_common() {
1030 wait_delete_completed
1033 max_pages_per_rpc() {
1034 $LCTL get_param -n mdc.*.max_pages_per_rpc | head -n1
1038 local NRFILES=100000
1039 local FREE_INODES=$(mdt_free_inodes 0)
1040 [[ $FREE_INODES -lt $NRFILES ]] &&
1041 skip "not enough free inodes $FREE_INODES required $NRFILES" &&
1044 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1045 trap simple_cleanup_common EXIT
1047 # Performance issue on ZFS see LU-4072 (c.f. LU-2887)
1048 [ $(facet_fstype $SINGLEMDS) = "zfs" ] && NRFILES=10000
1050 test_mkdir -p $DIR/$tdir
1051 createmany -m $DIR/$tdir/$tfile $NRFILES
1053 cancel_lru_locks mdc
1054 lctl set_param mdc.*.stats clear
1056 ls $DIR/$tdir >/dev/null || error "error in listing large dir"
1058 # LU-5 large readdir
1059 # DIRENT_SIZE = 32 bytes for sizeof(struct lu_dirent) +
1060 # 8 bytes for name(filename is mostly 5 in this test) +
1061 # 8 bytes for luda_type
1062 # take into account of overhead in lu_dirpage header and end mark in
1063 # each page, plus one in RPC_NUM calculation.
1065 RPC_SIZE=$(($(max_pages_per_rpc) * $(page_size)))
1066 RPC_NUM=$(((NRFILES * DIRENT_SIZE + RPC_SIZE - 1) / RPC_SIZE + 1))
1067 mds_readpage=$(lctl get_param mdc.*MDT0000*.stats |
1068 awk '/^mds_readpage/ {print $2}')
1069 [[ $mds_readpage -gt $RPC_NUM ]] &&
1070 error "large readdir doesn't take effect"
1072 simple_cleanup_common
1074 run_test 24v "list directory with large files (handle hash collision, bug: 17560)"
1076 test_24w() { # bug21506
1078 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=4096 || return 1
1079 dd if=/dev/zero bs=$SZ1 count=1 >> $DIR/$tfile || return 2
1080 dd if=$DIR/$tfile of=$DIR/${tfile}_left bs=1M skip=4097 || return 3
1081 SZ2=`ls -l $DIR/${tfile}_left | awk '{print $5}'`
1082 [[ "$SZ1" -eq "$SZ2" ]] ||
1083 error "Error reading at the end of the file $tfile"
1085 run_test 24w "Reading a file larger than 4Gb"
1088 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 2 MDTs" && return
1089 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1091 local remote_dir=$DIR/$tdir/remote_dir
1093 test_mkdir -p $DIR/$tdir
1094 $LFS mkdir -i $MDTIDX $remote_dir ||
1095 error "create remote directory failed"
1097 test_mkdir -p $DIR/$tdir/src_dir
1098 touch $DIR/$tdir/src_file
1099 test_mkdir -p $remote_dir/tgt_dir
1100 touch $remote_dir/tgt_file
1102 mrename $DIR/$tdir/src_dir $remote_dir/tgt_dir ||
1103 error "rename dir cross MDT failed!"
1105 mrename $DIR/$tdir/src_file $remote_dir/tgt_file ||
1106 error "rename file cross MDT failed!"
1108 touch $DIR/$tdir/ln_file
1109 ln $DIR/$tdir/ln_file $remote_dir/ln_name ||
1110 error "ln file cross MDT failed"
1112 rm -rf $DIR/$tdir || error "Can not delete directories"
1114 run_test 24x "cross MDT rename/link"
1117 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 2 MDTs" && return
1118 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1120 local remote_dir=$DIR/$tdir/remote_dir
1122 test_mkdir -p $DIR/$tdir
1123 $LFS mkdir -i $MDTIDX $remote_dir ||
1124 error "create remote directory failed"
1126 test_mkdir -p $remote_dir/src_dir
1127 touch $remote_dir/src_file
1128 test_mkdir -p $remote_dir/tgt_dir
1129 touch $remote_dir/tgt_file
1131 mrename $remote_dir/src_dir $remote_dir/tgt_dir ||
1132 error "rename subdir in the same remote dir failed!"
1134 mrename $remote_dir/src_file $remote_dir/tgt_file ||
1135 error "rename files in the same remote dir failed!"
1137 ln $remote_dir/tgt_file $remote_dir/tgt_file1 ||
1138 error "link files in the same remote dir failed!"
1140 rm -rf $DIR/$tdir || error "Can not delete directories"
1142 run_test 24y "rename/link on the same dir should succeed"
1144 test_24A() { # LU-3182
1148 test_mkdir -p $DIR/$tdir
1149 createmany -m $DIR/$tdir/$tfile $NFILES
1150 local t=$(ls $DIR/$tdir | wc -l)
1151 local u=$(ls $DIR/$tdir | sort -u | wc -l)
1152 local v=$(ls -ai $DIR/$tdir | sort -u | wc -l)
1153 if [ $t -ne $NFILES -o $u -ne $NFILES -o $v -ne $((NFILES + 2)) ] ; then
1154 error "Expected $NFILES files, got $t ($u unique $v .&..)"
1157 rm -rf $DIR/$tdir || error "Can not delete directories"
1159 run_test 24A "readdir() returns correct number of entries."
1161 test_24B() { # LU-4805
1162 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
1165 test_mkdir $DIR/$tdir
1166 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR/$tdir/striped_dir ||
1167 error "create striped dir failed"
1169 count=$(ls -ai $DIR/$tdir/striped_dir | wc -l)
1170 [ $count -eq 2 ] || error "Expected 2, got $count"
1172 touch $DIR/$tdir/striped_dir/a
1174 count=$(ls -ai $DIR/$tdir/striped_dir | wc -l)
1175 [ $count -eq 3 ] || error "Expected 3, got $count"
1177 touch $DIR/$tdir/striped_dir/.f
1179 count=$(ls -ai $DIR/$tdir/striped_dir | wc -l)
1180 [ $count -eq 4 ] || error "Expected 4, got $count"
1182 rm -rf $DIR/$tdir || error "Can not delete directories"
1184 run_test 24B "readdir for striped dir return correct number of entries"
1187 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
1193 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR/$tdir/d0/striped_dir ||
1194 error "create striped dir failed"
1196 cd $DIR/$tdir/d0/striped_dir
1198 local d0_ino=$(ls -i -l -a $DIR/$tdir | grep "d0" | awk '{print $1}')
1199 local d1_ino=$(ls -i -l -a $DIR/$tdir | grep "d1" | awk '{print $1}')
1200 local parent_ino=$(ls -i -l -a | grep "\.\." | awk '{print $1}')
1202 [ "$d0_ino" = "$parent_ino" ] ||
1203 error ".. wrong, expect $d0_ino, get $parent_ino"
1205 mv $DIR/$tdir/d0/striped_dir $DIR/$tdir/d1/ ||
1206 error "mv striped dir failed"
1208 parent_ino=$(ls -i -l -a | grep "\.\." | awk '{print $1}')
1210 [ "$d1_ino" = "$parent_ino" ] ||
1211 error ".. wrong after mv, expect $d1_ino, get $parent_ino"
1213 run_test 24C "check .. in striped dir"
1215 test_24D() { # LU-6101
1220 createmany -m $DIR/$tdir/$tfile $NFILES
1221 local t=$(ls $DIR/$tdir | wc -l)
1222 local u=$(ls $DIR/$tdir | sort -u | wc -l)
1223 local v=$(ls -ai $DIR/$tdir | sort -u | wc -l)
1224 if [ $t -ne $NFILES -o $u -ne $NFILES -o $v -ne $((NFILES + 2)) ] ; then
1225 error "Expected $NFILES files, got $t ($u unique $v .&..)"
1228 rm -rf $DIR/$tdir || error "Can not delete directories"
1230 run_test 24D "readdir() returns correct number of entries after cursor reload"
1233 [[ $MDSCOUNT -lt 4 ]] && skip "needs >= 4 MDTs" && return
1234 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1237 mkdir $DIR/$tdir/src_dir
1238 $LFS mkdir -i 1 $DIR/$tdir/src_dir/src_child ||
1239 error "create remote source failed"
1241 touch $DIR/$tdir/src_dir/src_child/a
1243 $LFS mkdir -i 2 $DIR/$tdir/tgt_dir ||
1244 error "create remote target dir failed"
1246 $LFS mkdir -i 3 $DIR/$tdir/tgt_dir/tgt_child ||
1247 error "create remote target child failed"
1249 mrename $DIR/$tdir/src_dir/src_child $DIR/$tdir/tgt_dir/tgt_child ||
1250 error "rename dir cross MDT failed!"
1254 $CHECKSTAT -t dir $DIR/$tdir/src_dir/src_child &&
1255 error "src_child still exists after rename"
1257 $CHECKSTAT -t file $DIR/$tdir/tgt_dir/tgt_child/a ||
1258 error "missing file(a) after rename"
1260 rm -rf $DIR/$tdir || error "Can not delete directories"
1262 run_test 24E "cross MDT rename/link"
1265 echo '== symlink sanity ============================================='
1269 touch $DIR/s25/foo || error
1271 run_test 25a "create file in symlinked directory ==============="
1274 [ ! -d $DIR/d25 ] && test_25a
1275 $CHECKSTAT -t file $DIR/s25/foo || error
1277 run_test 25b "lookup file in symlinked directory ==============="
1281 test_mkdir $DIR/d26/d26-2
1282 ln -s d26/d26-2 $DIR/s26
1283 touch $DIR/s26/foo || error
1285 run_test 26a "multiple component symlink ======================="
1288 test_mkdir -p $DIR/d26b/d26-2
1289 ln -s d26b/d26-2/foo $DIR/s26-2
1290 touch $DIR/s26-2 || error
1292 run_test 26b "multiple component symlink at end of lookup ======"
1295 test_mkdir $DIR/d26.2
1296 touch $DIR/d26.2/foo
1297 ln -s d26.2 $DIR/s26.2-1
1298 ln -s s26.2-1 $DIR/s26.2-2
1299 ln -s s26.2-2 $DIR/s26.2-3
1300 chmod 0666 $DIR/s26.2-3/foo
1302 run_test 26c "chain of symlinks ================================"
1304 # recursive symlinks (bug 439)
1306 ln -s d26-3/foo $DIR/d26-3
1308 run_test 26d "create multiple component recursive symlink ======"
1311 [ ! -h $DIR/d26-3 ] && test_26d
1314 run_test 26e "unlink multiple component recursive symlink ======"
1316 # recursive symlinks (bug 7022)
1318 test_mkdir -p $DIR/$tdir
1319 test_mkdir $DIR/$tdir/$tfile || error "mkdir $DIR/$tdir/$tfile failed"
1320 cd $DIR/$tdir/$tfile || error "cd $DIR/$tdir/$tfile failed"
1321 test_mkdir -p lndir/bar1 || error "mkdir lndir/bar1 failed"
1322 test_mkdir $DIR/$tdir/$tfile/$tfile || error "mkdir $tfile failed"
1323 cd $tfile || error "cd $tfile failed"
1324 ln -s .. dotdot || error "ln dotdot failed"
1325 ln -s dotdot/lndir lndir || error "ln lndir failed"
1326 cd $DIR/$tdir || error "cd $DIR/$tdir failed"
1327 output=`ls $tfile/$tfile/lndir/bar1`
1328 [ "$output" = bar1 ] && error "unexpected output"
1329 rm -r $tfile || error "rm $tfile failed"
1330 $CHECKSTAT -a $DIR/$tfile || error "$tfile not gone"
1332 run_test 26f "rm -r of a directory which has recursive symlink ="
1335 echo '== stripe sanity =============================================='
1336 test_mkdir -p $DIR/d27 || error "mkdir failed"
1338 $SETSTRIPE -c 1 $DIR/d27/f0 || error "setstripe failed"
1339 $CHECKSTAT -t file $DIR/d27/f0 || error "checkstat failed"
1340 log "== test_27a: write to one stripe file ========================="
1341 cp /etc/hosts $DIR/d27/f0 || error
1343 run_test 27a "one stripe file =================================="
1346 [[ $OSTCOUNT -lt 2 ]] && skip_env "skipping 2-stripe test" && return
1347 test_mkdir -p $DIR/d27
1348 $SETSTRIPE -c 2 $DIR/d27/f01 || error "setstripe failed"
1349 $GETSTRIPE -c $DIR/d27/f01
1350 [ $($GETSTRIPE -c $DIR/d27/f01) -eq 2 ] ||
1351 error "two-stripe file doesn't have two stripes"
1353 dd if=/dev/zero of=$DIR/d27/f01 bs=4k count=4 || error "dd failed"
1355 run_test 27b "create and write to two stripe file"
1358 test_mkdir -p $DIR/d27
1359 $SETSTRIPE -c 0 -i -1 -S 0 $DIR/d27/fdef || error "setstripe failed"
1360 $CHECKSTAT -t file $DIR/d27/fdef || error "checkstat failed"
1361 dd if=/dev/zero of=$DIR/d27/fdef bs=4k count=4 || error
1363 run_test 27d "create file with default settings ================"
1366 # LU-5839 adds check for existed layout before setting it
1367 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.56) ]] &&
1368 skip "Need MDS version at least 2.7.56" && return
1369 test_mkdir -p $DIR/d27
1370 $SETSTRIPE -c 2 $DIR/d27/f12 || error "setstripe failed"
1371 $SETSTRIPE -c 2 $DIR/d27/f12 && error "setstripe succeeded twice"
1372 $CHECKSTAT -t file $DIR/d27/f12 || error "checkstat failed"
1374 run_test 27e "setstripe existing file (should return error) ======"
1377 test_mkdir $DIR/$tdir
1378 $SETSTRIPE -S 100 -i 0 -c 1 $DIR/$tdir/$tfile &&
1379 error "$SETSTRIPE $DIR/$tdir/$tfile failed"
1380 $CHECKSTAT -t file $DIR/$tdir/$tfile &&
1381 error "$CHECKSTAT -t file $DIR/$tdir/$tfile should fail"
1382 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=4k count=4 || error "dd failed"
1383 $GETSTRIPE $DIR/$tdir/$tfile || error "$GETSTRIPE failed"
1385 run_test 27f "setstripe with bad stripe size (should return error)"
1388 test_mkdir -p $DIR/d27
1389 $MCREATE $DIR/d27/fnone || error "mcreate failed"
1390 $GETSTRIPE $DIR/d27/fnone 2>&1 | grep "no stripe info" ||
1391 error "$DIR/d27/fnone has object"
1393 run_test 27g "$GETSTRIPE with no objects"
1396 test_mkdir $DIR/$tdir
1397 touch $DIR/$tdir/$tfile || error "touch failed"
1398 [[ $($GETSTRIPE -c $DIR/$tdir/$tfile) -gt 0 ]] ||
1399 error "missing objects"
1401 run_test 27i "$GETSTRIPE with some objects"
1404 test_mkdir -p $DIR/d27
1405 $SETSTRIPE -i $OSTCOUNT $DIR/d27/f27j && error "setstripe failed"||true
1407 run_test 27j "setstripe with bad stripe offset (should return error)"
1409 test_27k() { # bug 2844
1410 test_mkdir -p $DIR/d27
1412 LL_MAX_BLKSIZE=$((4 * 1024 * 1024))
1413 [ ! -d $DIR/d27 ] && test_mkdir -p $DIR d27
1414 $SETSTRIPE -S 67108864 $FILE || error "setstripe failed"
1415 BLKSIZE=`stat $FILE | awk '/IO Block:/ { print $7 }'`
1416 [ $BLKSIZE -le $LL_MAX_BLKSIZE ] || error "1:$BLKSIZE > $LL_MAX_BLKSIZE"
1417 dd if=/dev/zero of=$FILE bs=4k count=1
1418 BLKSIZE=`stat $FILE | awk '/IO Block:/ { print $7 }'`
1419 [ $BLKSIZE -le $LL_MAX_BLKSIZE ] || error "2:$BLKSIZE > $LL_MAX_BLKSIZE"
1421 run_test 27k "limit i_blksize for broken user apps ============="
1424 test_mkdir -p $DIR/d27
1425 mcreate $DIR/f27l || error "creating file"
1426 $RUNAS $SETSTRIPE -c 1 $DIR/f27l && \
1427 error "setstripe should have failed" || true
1429 run_test 27l "check setstripe permissions (should return error)"
1432 [[ $OSTCOUNT -lt 2 ]] && skip_env "$OSTCOUNT < 2 OSTs -- skipping" &&
1434 if [[ $ORIGFREE -gt $MAXFREE ]]; then
1435 skip "$ORIGFREE > $MAXFREE skipping out-of-space test on OST0"
1438 trap simple_cleanup_common EXIT
1439 test_mkdir -p $DIR/$tdir
1440 $SETSTRIPE -i 0 -c 1 $DIR/$tdir/f27m_1
1441 dd if=/dev/zero of=$DIR/$tdir/f27m_1 bs=1024 count=$MAXFREE &&
1442 error "dd should fill OST0"
1444 while $SETSTRIPE -i 0 -c 1 $DIR/$tdir/f27m_$i; do
1446 [ $i -gt 256 ] && break
1449 touch $DIR/$tdir/f27m_$i
1450 [ `$GETSTRIPE $DIR/$tdir/f27m_$i | grep -A 10 obdidx | awk '{print $1}'| grep -w "0"` ] &&
1451 error "OST0 was full but new created file still use it"
1453 touch $DIR/$tdir/f27m_$i
1454 [ `$GETSTRIPE $DIR/$tdir/f27m_$i | grep -A 10 obdidx | awk '{print $1}'| grep -w "0"` ] &&
1455 error "OST0 was full but new created file still use it"
1456 simple_cleanup_common
1458 run_test 27m "create file while OST0 was full =================="
1461 local DELAY=$(do_facet $SINGLEMDS lctl get_param -n lov.*.qos_maxage | head -n 1 | awk '{print $1 * 2}')
1465 # OSCs keep a NOSPC flag that will be reset after ~5s (qos_maxage)
1466 # if the OST isn't full anymore.
1468 local OSTIDX=${1:-""}
1470 local list=$(comma_list $(osts_nodes))
1471 [ "$OSTIDX" ] && list=$(facet_host ost$((OSTIDX + 1)))
1473 do_nodes $list lctl set_param fail_loc=0
1474 sync # initiate all OST_DESTROYs from MDS to OST
1478 exhaust_precreations() {
1481 local FAILIDX=${3:-$OSTIDX}
1482 local ofacet=ost$((OSTIDX + 1))
1484 test_mkdir -p -c1 $DIR/$tdir
1485 local mdtidx=$($LFS getstripe -M $DIR/$tdir)
1486 local mfacet=mds$((mdtidx + 1))
1487 echo OSTIDX=$OSTIDX MDTIDX=$mdtidx
1489 local OST=$(ostname_from_index $OSTIDX)
1492 local mdtosc_proc1=$(get_mdtosc_proc_path $mfacet $OST)
1493 local last_id=$(do_facet $mfacet lctl get_param -n \
1494 osc.$mdtosc_proc1.prealloc_last_id)
1495 local next_id=$(do_facet $mfacet lctl get_param -n \
1496 osc.$mdtosc_proc1.prealloc_next_id)
1498 local mdtosc_proc2=$(get_mdtosc_proc_path $mfacet)
1499 do_facet $mfacet lctl get_param osc.$mdtosc_proc2.prealloc*
1501 test_mkdir -p $DIR/$tdir/${OST}
1502 $SETSTRIPE -i $OSTIDX -c 1 $DIR/$tdir/${OST}
1503 #define OBD_FAIL_OST_ENOSPC 0x215
1504 do_facet $ofacet lctl set_param fail_val=$FAILIDX fail_loc=0x215
1505 echo "Creating to objid $last_id on ost $OST..."
1506 createmany -o $DIR/$tdir/${OST}/f $next_id $((last_id - next_id + 2))
1507 do_facet $mfacet lctl get_param osc.$mdtosc_proc2.prealloc*
1508 do_facet $ofacet lctl set_param fail_loc=$FAILLOC
1512 exhaust_all_precreations() {
1514 for (( i=0; i < OSTCOUNT; i++ )) ; do
1515 exhaust_precreations $i $1 -1
1520 [[ $OSTCOUNT -lt 2 ]] && skip_env "too few OSTs" && return
1521 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1522 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1523 remote_ost_nodsh && skip "remote OST with nodsh" && return
1526 rm -f $DIR/$tdir/$tfile
1527 exhaust_precreations 0 0x80000215
1528 $SETSTRIPE -c -1 $DIR/$tdir
1529 touch $DIR/$tdir/$tfile || error
1530 $GETSTRIPE $DIR/$tdir/$tfile
1533 run_test 27n "create file with some full OSTs =================="
1536 [[ $OSTCOUNT -lt 2 ]] && skip_env "too few OSTs" && return
1537 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1538 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1539 remote_ost_nodsh && skip "remote OST with nodsh" && return
1542 rm -f $DIR/$tdir/$tfile
1543 exhaust_all_precreations 0x215
1545 touch $DIR/$tdir/$tfile && error "able to create $DIR/$tdir/$tfile"
1550 run_test 27o "create file with all full OSTs (should error) ===="
1553 [[ $OSTCOUNT -lt 2 ]] && skip_env "too few OSTs" && return
1554 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1555 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1556 remote_ost_nodsh && skip "remote OST with nodsh" && return
1559 rm -f $DIR/$tdir/$tfile
1560 test_mkdir -p $DIR/$tdir
1562 $MCREATE $DIR/$tdir/$tfile || error "mcreate failed"
1563 $TRUNCATE $DIR/$tdir/$tfile 80000000 || error "truncate failed"
1564 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat failed"
1566 exhaust_precreations 0 0x80000215
1567 echo foo >> $DIR/$tdir/$tfile || error "append failed"
1568 $CHECKSTAT -s 80000004 $DIR/$tdir/$tfile || error "checkstat failed"
1569 $GETSTRIPE $DIR/$tdir/$tfile
1573 run_test 27p "append to a truncated file with some full OSTs ==="
1576 [[ $OSTCOUNT -lt 2 ]] && skip_env "too few OSTs" && return
1577 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1578 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1579 remote_ost_nodsh && skip "remote OST with nodsh" && return
1582 rm -f $DIR/$tdir/$tfile
1584 test_mkdir -p $DIR/$tdir
1585 $MCREATE $DIR/$tdir/$tfile || error "mcreate $DIR/$tdir/$tfile failed"
1586 $TRUNCATE $DIR/$tdir/$tfile 80000000 ||error "truncate $DIR/$tdir/$tfile failed"
1587 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat failed"
1589 exhaust_all_precreations 0x215
1591 echo foo >> $DIR/$tdir/$tfile && error "append succeeded"
1592 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat 2 failed"
1596 run_test 27q "append to truncated file with all OSTs full (should error) ==="
1599 [[ $OSTCOUNT -lt 2 ]] && skip_env "too few OSTs" && return
1600 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1601 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1602 remote_ost_nodsh && skip "remote OST with nodsh" && return
1605 rm -f $DIR/$tdir/$tfile
1606 exhaust_precreations 0 0x80000215
1608 $SETSTRIPE -i 0 -c 2 $DIR/$tdir/$tfile # && error
1612 run_test 27r "stripe file with some full OSTs (shouldn't LBUG) ="
1614 test_27s() { # bug 10725
1615 test_mkdir -p $DIR/$tdir
1616 local stripe_size=$((4096 * 1024 * 1024)) # 2^32
1617 local stripe_count=0
1618 [ $OSTCOUNT -eq 1 ] || stripe_count=2
1619 $SETSTRIPE -S $stripe_size -c $stripe_count $DIR/$tdir &&
1620 error "stripe width >= 2^32 succeeded" || true
1623 run_test 27s "lsm_xfersize overflow (should error) (bug 10725)"
1625 test_27t() { # bug 10864
1630 $WLFS getstripe $tfile
1633 run_test 27t "check that utils parse path correctly"
1635 test_27u() { # bug 4900
1636 [[ $OSTCOUNT -lt 2 ]] && skip_env "too few OSTs" && return
1637 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1639 local list=$(comma_list $(mdts_nodes))
1641 #define OBD_FAIL_MDS_OSC_PRECREATE 0x139
1642 do_nodes $list $LCTL set_param fail_loc=0x139
1643 test_mkdir -p $DIR/$tdir
1645 createmany -o $DIR/$tdir/t- 1000
1646 do_nodes $list $LCTL set_param fail_loc=0
1648 TLOG=$DIR/$tfile.getstripe
1649 $GETSTRIPE $DIR/$tdir > $TLOG
1650 OBJS=$(awk -vobj=0 '($1 == 0) { obj += 1 } END { print obj; }' $TLOG)
1651 unlinkmany $DIR/$tdir/t- 1000
1652 [[ $OBJS -gt 0 ]] &&
1653 error "$OBJS objects created on OST-0. See $TLOG" || pass
1655 run_test 27u "skip object creation on OSC w/o objects =========="
1657 test_27v() { # bug 4900
1658 [[ $OSTCOUNT -lt 2 ]] && skip_env "too few OSTs" && return
1659 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1660 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1661 remote_ost_nodsh && skip "remote OST with nodsh" && return
1663 exhaust_all_precreations 0x215
1666 test_mkdir -p $DIR/$tdir
1667 $SETSTRIPE -c 1 $DIR/$tdir # 1 stripe / file
1669 touch $DIR/$tdir/$tfile
1670 #define OBD_FAIL_TGT_DELAY_PRECREATE 0x705
1672 for (( i=1; i < OSTCOUNT; i++ )); do
1673 do_facet ost$i lctl set_param fail_loc=0x705
1675 local START=`date +%s`
1676 createmany -o $DIR/$tdir/$tfile 32
1678 local FINISH=`date +%s`
1679 local TIMEOUT=`lctl get_param -n timeout`
1680 local PROCESS=$((FINISH - START))
1681 [ $PROCESS -ge $((TIMEOUT / 2)) ] && \
1682 error "$FINISH - $START >= $TIMEOUT / 2"
1683 sleep $((TIMEOUT / 2 - PROCESS))
1686 run_test 27v "skip object creation on slow OST ================="
1688 test_27w() { # bug 10997
1689 test_mkdir -p $DIR/$tdir || error "mkdir failed"
1690 $SETSTRIPE -S 65536 $DIR/$tdir/f0 || error "setstripe failed"
1691 [ $($GETSTRIPE -S $DIR/$tdir/f0) -ne 65536 ] &&
1692 error "stripe size $size != 65536" || true
1693 [ $($GETSTRIPE -d $DIR/$tdir | grep -c "stripe_count") -ne 1 ] &&
1694 error "$GETSTRIPE -d $DIR/$tdir failed" || true
1696 run_test 27w "check $SETSTRIPE -S option"
1699 [[ $OSTCOUNT -lt 2 ]] &&
1700 skip_env "skipping multiple stripe count/offset test" && return
1702 test_mkdir -p $DIR/$tdir || error "mkdir failed"
1703 for i in $(seq 1 $OSTCOUNT); do
1705 $SETSTRIPE -c $i -i $offset $DIR/$tdir/f$i ||
1706 error "setstripe -c $i -i $offset failed"
1707 count=$($GETSTRIPE -c $DIR/$tdir/f$i)
1708 index=$($GETSTRIPE -i $DIR/$tdir/f$i)
1709 [ $count -ne $i ] && error "stripe count $count != $i" || true
1710 [ $index -ne $offset ] &&
1711 error "stripe offset $index != $offset" || true
1714 run_test 27wa "check $SETSTRIPE -c -i options"
1717 remote_ost_nodsh && skip "remote OST with nodsh" && return
1718 [[ $OSTCOUNT -lt 2 ]] && skip_env "$OSTCOUNT < 2 OSTs" && return
1719 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1720 OFFSET=$(($OSTCOUNT - 1))
1722 local OST=$(ostname_from_index $OSTIDX)
1724 test_mkdir -p $DIR/$tdir
1725 $SETSTRIPE -c 1 $DIR/$tdir # 1 stripe per file
1726 do_facet ost$((OSTIDX + 1)) lctl set_param -n obdfilter.$OST.degraded 1
1728 createmany -o $DIR/$tdir/$tfile $OSTCOUNT
1729 for i in `seq 0 $OFFSET`; do
1730 [ `$GETSTRIPE $DIR/$tdir/$tfile$i | grep -A 10 obdidx | awk '{print $1}' | grep -w "$OSTIDX"` ] &&
1731 error "OST0 was degraded but new created file still use it"
1733 do_facet ost$((OSTIDX + 1)) lctl set_param -n obdfilter.$OST.degraded 0
1735 run_test 27x "create files while OST0 is degraded"
1738 [[ $OSTCOUNT -lt 2 ]] &&
1739 skip_env "$OSTCOUNT < 2 OSTs -- skipping" && return
1740 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1741 remote_ost_nodsh && skip "remote OST with nodsh" && return
1742 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1744 local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS $FSNAME-OST0000)
1745 local last_id=$(do_facet $SINGLEMDS lctl get_param -n \
1746 osc.$mdtosc.prealloc_last_id)
1747 local next_id=$(do_facet $SINGLEMDS lctl get_param -n \
1748 osc.$mdtosc.prealloc_next_id)
1749 local fcount=$((last_id - next_id))
1750 [[ $fcount -eq 0 ]] && skip "not enough space on OST0" && return
1751 [[ $fcount -gt $OSTCOUNT ]] && fcount=$OSTCOUNT
1753 local MDS_OSCS=$(do_facet $SINGLEMDS lctl dl |
1754 awk '/[oO][sS][cC].*md[ts]/ { print $4 }')
1755 local OST_DEACTIVE_IDX=-1
1760 for OSC in $MDS_OSCS; do
1761 OST=$(osc_to_ost $OSC)
1762 OSTIDX=$(index_from_ostuuid $OST)
1763 if [ $OST_DEACTIVE_IDX == -1 ]; then
1764 OST_DEACTIVE_IDX=$OSTIDX
1766 if [ $OSTIDX != $OST_DEACTIVE_IDX ]; then
1767 echo $OSC "is Deactivated:"
1768 do_facet $SINGLEMDS lctl --device %$OSC deactivate
1772 OSTIDX=$(index_from_ostuuid $OST)
1773 test_mkdir -p $DIR/$tdir
1774 $SETSTRIPE -c 1 $DIR/$tdir # 1 stripe / file
1776 for OSC in $MDS_OSCS; do
1777 OST=$(osc_to_ost $OSC)
1778 OSTIDX=$(index_from_ostuuid $OST)
1779 if [ $OSTIDX == $OST_DEACTIVE_IDX ]; then
1780 echo $OST "is degraded:"
1781 do_facet ost$((OSTIDX+1)) lctl set_param -n \
1782 obdfilter.$OST.degraded=1
1787 createmany -o $DIR/$tdir/$tfile $fcount
1789 for OSC in $MDS_OSCS; do
1790 OST=$(osc_to_ost $OSC)
1791 OSTIDX=$(index_from_ostuuid $OST)
1792 if [ $OSTIDX == $OST_DEACTIVE_IDX ]; then
1793 echo $OST "is recovered from degraded:"
1794 do_facet ost$((OSTIDX+1)) lctl set_param -n \
1795 obdfilter.$OST.degraded=0
1797 do_facet $SINGLEMDS lctl --device %$OSC activate
1801 # all osp devices get activated, hence -1 stripe count restored
1804 # sleep 2*lod_qos_maxage seconds waiting for lod qos to notice osp
1805 # devices get activated.
1807 $SETSTRIPE -c -1 $DIR/$tfile
1808 stripecnt=$($GETSTRIPE -c $DIR/$tfile)
1810 [ $stripecnt -ne $OSTCOUNT ] &&
1811 error "Of $OSTCOUNT OSTs, only $stripecnt is available"
1814 run_test 27y "create files while OST0 is degraded and the rest inactive"
1820 lmm_count=$($GETSTRIPE -c $1)
1821 lmm_seq=$($GETSTRIPE -v $1 | awk '/lmm_seq/ { print $2 }')
1822 lmm_oid=$($GETSTRIPE -v $1 | awk '/lmm_object_id/ { print $2 }')
1824 local old_ifs="$IFS"
1826 fid=($($LFS path2fid $1))
1829 log "FID seq ${fid[1]}, oid ${fid[2]} ver ${fid[3]}"
1830 log "LOV seq $lmm_seq, oid $lmm_oid, count: $lmm_count"
1832 # compare lmm_seq and lu_fid->f_seq
1833 [ $lmm_seq = ${fid[1]} ] || { error "SEQ mismatch"; return 1; }
1834 # compare lmm_object_id and lu_fid->oid
1835 [ $lmm_oid = ${fid[2]} ] || { error "OID mismatch"; return 2; }
1837 # check the trusted.fid attribute of the OST objects of the file
1838 local have_obdidx=false
1840 $GETSTRIPE $1 | while read obdidx oid hex seq; do
1841 # skip lines up to and including "obdidx"
1842 [ -z "$obdidx" ] && break
1843 [ "$obdidx" = "obdidx" ] && have_obdidx=true && continue
1844 $have_obdidx || continue
1846 local ost=$((obdidx + 1))
1847 local dev=$(ostdevname $ost)
1850 log "want: stripe:$stripe_nr ost:$obdidx oid:$oid/$hex seq:$seq"
1852 seq=$(echo $seq | sed -e "s/^0x//g")
1853 if [ $seq == 0 ] || [ $(facet_fstype ost$ost) == zfs ]; then
1854 oid_hex=$(echo $oid)
1856 oid_hex=$(echo $hex | sed -e "s/^0x//g")
1858 local obj_file="O/$seq/d$((oid %32))/$oid_hex"
1862 # Don't unmount/remount the OSTs if we don't need to do that.
1863 # LU-2577 changes filter_fid to be smaller, so debugfs needs
1864 # update too, until that use mount/ll_decode_filter_fid/mount.
1865 # Re-enable when debugfs will understand new filter_fid.
1867 if false && [ $(facet_fstype ost$ost) == ldiskfs ]; then
1868 ff=$(do_facet ost$ost "$DEBUGFS -c -R 'stat $obj_file' \
1869 $dev 2>/dev/null" | grep "parent=")
1872 mount_fstype ost$ost
1873 ff=$(do_facet ost$ost $LL_DECODE_FILTER_FID \
1874 $(facet_mntpt ost$ost)/$obj_file)
1875 unmount_fstype ost$ost
1876 start ost$ost $dev $OST_MOUNT_OPTS
1879 [ -z "$ff" ] && error "$obj_file: no filter_fid info"
1881 echo "$ff" | sed -e 's#.*objid=#got: objid=#'
1883 # /mnt/O/0/d23/23: objid=23 seq=0 parent=[0x200000400:0x1e:0x1]
1884 # fid: objid=23 seq=0 parent=[0x200000400:0x1e:0x0] stripe=1
1885 local ff_parent=$(echo $ff|sed -e 's/.*parent=.//')
1886 local ff_pseq=$(echo $ff_parent | cut -d: -f1)
1887 local ff_poid=$(echo $ff_parent | cut -d: -f2)
1889 if echo $ff_parent | grep -q 'stripe='; then
1890 ff_pstripe=$(echo $ff_parent | sed -e 's/.*stripe=//')
1893 # $LL_DECODE_FILTER_FID does not print "stripe="; look
1894 # into f_ver in this case. See the comment on
1897 ff_pstripe=$(echo $ff_parent | cut -d: -f3 |
1901 # compare lmm_seq and filter_fid->ff_parent.f_seq
1902 [ $ff_pseq = $lmm_seq ] ||
1903 error "FF parent SEQ $ff_pseq != $lmm_seq"
1904 # compare lmm_object_id and filter_fid->ff_parent.f_oid
1905 [ $ff_poid = $lmm_oid ] ||
1906 error "FF parent OID $ff_poid != $lmm_oid"
1907 (($ff_pstripe == $stripe_nr)) ||
1908 error "FF stripe $ff_pstripe != $stripe_nr"
1910 stripe_nr=$((stripe_nr + 1))
1915 remote_ost_nodsh && skip "remote OST with nodsh" && return
1916 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1917 test_mkdir -p $DIR/$tdir
1919 $SETSTRIPE -c 1 -i 0 -S 64k $DIR/$tdir/$tfile-1 ||
1920 { error "setstripe -c -1 failed"; return 1; }
1921 # We need to send a write to every object to get parent FID info set.
1922 # This _should_ also work for setattr, but does not currently.
1923 # touch $DIR/$tdir/$tfile-1 ||
1924 dd if=/dev/zero of=$DIR/$tdir/$tfile-1 bs=1M count=1 ||
1925 { error "dd $tfile-1 failed"; return 2; }
1926 $SETSTRIPE -c -1 -i $((OSTCOUNT - 1)) -S 1M $DIR/$tdir/$tfile-2 ||
1927 { error "setstripe -c -1 failed"; return 3; }
1928 dd if=/dev/zero of=$DIR/$tdir/$tfile-2 bs=1M count=$OSTCOUNT ||
1929 { error "dd $tfile-2 failed"; return 4; }
1931 # make sure write RPCs have been sent to OSTs
1934 check_seq_oid $DIR/$tdir/$tfile-1 || return 5
1935 check_seq_oid $DIR/$tdir/$tfile-2 || return 6
1937 run_test 27z "check SEQ/OID on the MDT and OST filesystems"
1939 test_27A() { # b=19102
1940 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1941 local restore_size=$($GETSTRIPE -S $MOUNT)
1942 local restore_count=$($GETSTRIPE -c $MOUNT)
1943 local restore_offset=$($GETSTRIPE -i $MOUNT)
1944 $SETSTRIPE -c 0 -i -1 -S 0 $MOUNT
1945 wait_update $HOSTNAME "$GETSTRIPE -c $MOUNT | sed 's/ *//g'" "1" 20 ||
1946 error "stripe count $($GETSTRIPE -c $MOUNT) != 1"
1947 local default_size=$($GETSTRIPE -S $MOUNT)
1948 local default_offset=$($GETSTRIPE -i $MOUNT)
1949 local dsize=$((1024 * 1024))
1950 [ $default_size -eq $dsize ] ||
1951 error "stripe size $default_size != $dsize"
1952 [ $default_offset -eq -1 ] ||error "stripe offset $default_offset != -1"
1953 $SETSTRIPE -c $restore_count -i $restore_offset -S $restore_size $MOUNT
1955 run_test 27A "check filesystem-wide default LOV EA values"
1957 test_27B() { # LU-2523
1958 test_mkdir -p $DIR/$tdir
1959 rm -f $DIR/$tdir/f0 $DIR/$tdir/f1
1961 # open f1 with O_LOV_DELAY_CREATE
1963 # call setstripe ioctl on open file descriptor for f1
1965 multiop $DIR/$tdir/f1 oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:nB1c \
1969 # open f1 with O_LOV_DELAY_CREATE
1971 # call setstripe ioctl on open file descriptor for f1
1973 multiop $DIR/$tdir/f1 oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:uB1c
1975 # Allow multiop to fail in imitation of NFS's busted semantics.
1978 run_test 27B "call setstripe on open unlinked file/rename victim"
1980 test_27C() { #LU-2871
1981 [[ $OSTCOUNT -lt 2 ]] && skip "needs >= 2 OSTs" && return
1989 test_mkdir -p $DIR/$tdir
1991 for i in $(seq 0 $((OSTCOUNT - 1))); do
1992 # set stripe across all OSTs starting from OST$i
1993 $SETSTRIPE -i $i -c -1 $tfile$i
1994 # get striping information
1995 ost_idx=($($GETSTRIPE $tfile$i |
1996 tail -n $((OSTCOUNT + 1)) | awk '{print $1}'))
2000 [ ${#ost_idx[@]} -eq $OSTCOUNT ] ||
2001 error "${#ost_idx[@]} != $OSTCOUNT"
2003 for index in $(seq 0 $((OSTCOUNT - 1))); do
2005 for j in $(echo ${ost_idx[@]}); do
2006 if [ $index -eq $j ]; then
2012 error "Can not find $index in ${ost_idx[@]}"
2016 run_test 27C "check full striping across all OSTs"
2019 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs" && return
2020 local POOL=${POOL:-testpool}
2022 local last_ost=$(($OSTCOUNT - 1))
2024 local ost_list=$(seq $first_ost $ost_step $last_ost)
2025 local ost_range="$first_ost $last_ost $ost_step"
2027 test_mkdir -p $DIR/$tdir
2028 pool_add $POOL || error "pool_add failed"
2029 pool_add_targets $POOL $ost_range || error "pool_add_targets failed"
2030 llapi_layout_test -d$DIR/$tdir -p$POOL -o$OSTCOUNT ||
2031 error "llapi_layout_test failed"
2032 cleanup_pools || error "cleanup_pools failed"
2034 run_test 27D "validate llapi_layout API"
2036 # Verify that default_easize is increased from its initial value after
2037 # accessing a widely striped file.
2039 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs" && return
2041 # 72 bytes is the minimum space required to store striping
2042 # information for a file striped across one OST:
2043 # (sizeof(struct lov_user_md_v3) +
2044 # sizeof(struct lov_user_ost_data_v1))
2046 $LCTL set_param -n llite.*.default_easize $min_easize ||
2047 error "lctl set_param failed"
2048 local easize=$($LCTL get_param -n llite.*.default_easize)
2050 [ $easize -eq $min_easize ] ||
2051 error "failed to set default_easize"
2053 $LFS setstripe -c $OSTCOUNT $DIR/$tfile ||
2054 error "setstripe failed"
2058 easize=$($LCTL get_param -n llite.*.default_easize)
2060 [ $easize -gt $min_easize ] ||
2061 error "default_easize not updated"
2063 run_test 27E "check that default extended attribute size properly increases"
2065 # createtest also checks that device nodes are created and
2066 # then visible correctly (#2091)
2067 test_28() { # bug 2091
2069 $CREATETEST $DIR/d28/ct || error
2071 run_test 28 "create/mknod/mkdir with bad file types ============"
2074 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2075 cancel_lru_locks mdc
2081 declare -i LOCKCOUNTORIG=0
2082 for lock_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_count); do
2083 let LOCKCOUNTORIG=$LOCKCOUNTORIG+$lock_count
2085 [ $LOCKCOUNTORIG -eq 0 ] && echo "No mdc lock count" && return 1
2087 declare -i LOCKUNUSEDCOUNTORIG=0
2088 for unused_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_unused_count); do
2089 let LOCKUNUSEDCOUNTORIG=$LOCKUNUSEDCOUNTORIG+$unused_count
2096 declare -i LOCKCOUNTCURRENT=0
2097 for lock_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_count); do
2098 let LOCKCOUNTCURRENT=$LOCKCOUNTCURRENT+$lock_count
2101 declare -i LOCKUNUSEDCOUNTCURRENT=0
2102 for unused_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_unused_count); do
2103 let LOCKUNUSEDCOUNTCURRENT=$LOCKUNUSEDCOUNTCURRENT+$unused_count
2106 if [[ $LOCKCOUNTCURRENT -gt $LOCKCOUNTORIG ]]; then
2107 $LCTL set_param -n ldlm.dump_namespaces ""
2108 error "CURRENT: $LOCKCOUNTCURRENT > $LOCKCOUNTORIG"
2109 $LCTL dk | sort -k4 -t: > $TMP/test_29.dk
2110 log "dumped log to $TMP/test_29.dk (bug 5793)"
2113 if [[ $LOCKUNUSEDCOUNTCURRENT -gt $LOCKUNUSEDCOUNTORIG ]]; then
2114 error "UNUSED: $LOCKUNUSEDCOUNTCURRENT > $LOCKUNUSEDCOUNTORIG"
2115 $LCTL dk | sort -k4 -t: > $TMP/test_29.dk
2116 log "dumped log to $TMP/test_29.dk (bug 5793)"
2120 run_test 29 "IT_GETATTR regression ============================"
2122 test_30a() { # was test_30
2123 cp $(which ls) $DIR || cp /bin/ls $DIR
2127 run_test 30a "execute binary from Lustre (execve) =============="
2130 cp `which ls` $DIR || cp /bin/ls $DIR
2132 $RUNAS $DIR/ls / || error
2135 run_test 30b "execute binary from Lustre as non-root ==========="
2137 test_30c() { # b=22376
2138 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2139 cp `which ls` $DIR || cp /bin/ls $DIR
2141 cancel_lru_locks mdc
2142 cancel_lru_locks osc
2143 $RUNAS $DIR/ls / || error
2146 run_test 30c "execute binary from Lustre without read perms ===="
2149 $OPENUNLINK $DIR/f31 $DIR/f31 || error
2150 $CHECKSTAT -a $DIR/f31 || error
2152 run_test 31a "open-unlink file =================================="
2155 touch $DIR/f31 || error
2156 ln $DIR/f31 $DIR/f31b || error
2157 $MULTIOP $DIR/f31b Ouc || error
2158 $CHECKSTAT -t file $DIR/f31 || error
2160 run_test 31b "unlink file with multiple links while open ======="
2163 touch $DIR/f31 || error
2164 ln $DIR/f31 $DIR/f31c || error
2165 multiop_bg_pause $DIR/f31 O_uc || return 1
2167 $MULTIOP $DIR/f31c Ouc
2168 kill -USR1 $MULTIPID
2171 run_test 31c "open-unlink file with multiple links ============="
2174 opendirunlink $DIR/d31d $DIR/d31d || error
2175 $CHECKSTAT -a $DIR/d31d || error
2177 run_test 31d "remove of open directory ========================="
2179 test_31e() { # bug 2904
2180 openfilleddirunlink $DIR/d31e || error
2182 run_test 31e "remove of open non-empty directory ==============="
2184 test_31f() { # bug 4554
2185 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2187 test_mkdir $DIR/d31f
2188 $SETSTRIPE -S 1048576 -c 1 $DIR/d31f
2189 cp /etc/hosts $DIR/d31f
2191 $GETSTRIPE $DIR/d31f/hosts
2192 multiop_bg_pause $DIR/d31f D_c || return 1
2195 rm -rv $DIR/d31f || error "first of $DIR/d31f"
2196 test_mkdir $DIR/d31f
2197 $SETSTRIPE -S 1048576 -c 1 $DIR/d31f
2198 cp /etc/hosts $DIR/d31f
2200 $GETSTRIPE $DIR/d31f/hosts
2201 multiop_bg_pause $DIR/d31f D_c || return 1
2204 kill -USR1 $MULTIPID || error "first opendir $MULTIPID not running"
2205 wait $MULTIPID || error "first opendir $MULTIPID failed"
2209 kill -USR1 $MULTIPID2 || error "second opendir $MULTIPID not running"
2210 wait $MULTIPID2 || error "second opendir $MULTIPID2 failed"
2213 run_test 31f "remove of open directory with open-unlink file ==="
2216 echo "-- cross directory link --"
2217 test_mkdir -c1 $DIR/${tdir}ga
2218 test_mkdir -c1 $DIR/${tdir}gb
2219 touch $DIR/${tdir}ga/f
2220 ln $DIR/${tdir}ga/f $DIR/${tdir}gb/g
2221 $CHECKSTAT -t file $DIR/${tdir}ga/f || error "source"
2222 [ `stat -c%h $DIR/${tdir}ga/f` == '2' ] || error "source nlink"
2223 $CHECKSTAT -t file $DIR/${tdir}gb/g || error "target"
2224 [ `stat -c%h $DIR/${tdir}gb/g` == '2' ] || error "target nlink"
2226 run_test 31g "cross directory link==============="
2229 echo "-- cross directory link --"
2230 test_mkdir -c1 $DIR/${tdir}
2231 test_mkdir -c1 $DIR/${tdir}/dir
2232 touch $DIR/${tdir}/f
2233 ln $DIR/${tdir}/f $DIR/${tdir}/dir/g
2234 $CHECKSTAT -t file $DIR/${tdir}/f || error "source"
2235 [ `stat -c%h $DIR/${tdir}/f` == '2' ] || error "source nlink"
2236 $CHECKSTAT -t file $DIR/${tdir}/dir/g || error "target"
2237 [ `stat -c%h $DIR/${tdir}/dir/g` == '2' ] || error "target nlink"
2239 run_test 31h "cross directory link under child==============="
2242 echo "-- cross directory link --"
2243 test_mkdir -c1 $DIR/$tdir
2244 test_mkdir -c1 $DIR/$tdir/dir
2245 touch $DIR/$tdir/dir/f
2246 ln $DIR/$tdir/dir/f $DIR/$tdir/g
2247 $CHECKSTAT -t file $DIR/$tdir/dir/f || error "source"
2248 [ `stat -c%h $DIR/$tdir/dir/f` == '2' ] || error "source nlink"
2249 $CHECKSTAT -t file $DIR/$tdir/g || error "target"
2250 [ `stat -c%h $DIR/$tdir/g` == '2' ] || error "target nlink"
2252 run_test 31i "cross directory link under parent==============="
2255 test_mkdir -c1 -p $DIR/$tdir
2256 test_mkdir -c1 -p $DIR/$tdir/dir1
2257 ln $DIR/$tdir/dir1 $DIR/$tdir/dir2 && error "ln for dir"
2258 link $DIR/$tdir/dir1 $DIR/$tdir/dir3 && error "link for dir"
2259 mlink $DIR/$tdir/dir1 $DIR/$tdir/dir4 && error "mlink for dir"
2260 mlink $DIR/$tdir/dir1 $DIR/$tdir/dir1 && error "mlink to the same dir"
2263 run_test 31j "link for directory==============="
2266 test_mkdir -c1 -p $DIR/$tdir
2268 touch $DIR/$tdir/exist
2269 mlink $DIR/$tdir/s $DIR/$tdir/t || error "mlink"
2270 mlink $DIR/$tdir/s $DIR/$tdir/exist && error "mlink to exist file"
2271 mlink $DIR/$tdir/s $DIR/$tdir/s && error "mlink to the same file"
2272 mlink $DIR/$tdir/s $DIR/$tdir && error "mlink to parent dir"
2273 mlink $DIR/$tdir $DIR/$tdir/s && error "mlink parent dir to target"
2274 mlink $DIR/$tdir/not-exist $DIR/$tdir/foo && error "mlink non-existing to new"
2275 mlink $DIR/$tdir/not-exist $DIR/$tdir/s && error "mlink non-existing to exist"
2278 run_test 31k "link to file: the same, non-existing, dir==============="
2284 touch $DIR/d31m2/exist
2285 mlink $DIR/d31m/s $DIR/d31m2/t || error "mlink"
2286 mlink $DIR/d31m/s $DIR/d31m2/exist && error "mlink to exist file"
2287 mlink $DIR/d31m/s $DIR/d31m2 && error "mlink to parent dir"
2288 mlink $DIR/d31m2 $DIR/d31m/s && error "mlink parent dir to target"
2289 mlink $DIR/d31m/not-exist $DIR/d31m2/foo && error "mlink non-existing to new"
2290 mlink $DIR/d31m/not-exist $DIR/d31m2/s && error "mlink non-existing to exist"
2293 run_test 31m "link to file: the same, non-existing, dir==============="
2296 touch $DIR/$tfile || error "cannot create '$DIR/$tfile'"
2297 nlink=$(stat --format=%h $DIR/$tfile)
2298 [ ${nlink:--1} -eq 1 ] || error "nlink is $nlink, expected 1"
2300 local cmd="exec $fd<$DIR/$tfile"
2303 trap "eval $cmd" EXIT
2304 nlink=$(stat --dereference --format=%h /proc/self/fd/$fd)
2305 [ ${nlink:--1} -eq 1 ] || error "nlink is $nlink, expected 1"
2306 rm $DIR/$tfile || error "cannot remove '$DIR/$tfile'"
2307 nlink=$(stat --dereference --format=%h /proc/self/fd/$fd)
2308 [ ${nlink:--1} -eq 0 ] || error "nlink is $nlink, expected 0"
2311 run_test 31n "check link count of unlinked file"
2314 local TEMPNAME=$(mktemp $1_XXXXXX)
2315 mlink $TEMPNAME $1 2> /dev/null &&
2316 echo "$BASHPID: link $TEMPNAME to $1 succeeded"
2320 test_31o() { # LU-2901
2321 test_mkdir -p $DIR/$tdir
2322 for LOOP in $(seq 100); do
2323 rm -f $DIR/$tdir/$tfile*
2324 for THREAD in $(seq 8); do
2325 link_one $DIR/$tdir/$tfile.$LOOP &
2328 local LINKS=$(ls -1 $DIR/$tdir | grep -c $tfile.$LOOP)
2329 [[ $LINKS -gt 1 ]] && ls $DIR/$tdir &&
2330 error "$LINKS duplicate links to $tfile.$LOOP" &&
2334 run_test 31o "duplicate hard links with same filename"
2337 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2339 test_mkdir $DIR/$tdir
2340 $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
2341 $LFS setdirstripe -D -c2 -t all_char $DIR/$tdir/striped_dir
2343 opendirunlink $DIR/$tdir/striped_dir/test1 ||
2344 error "open unlink test1 failed"
2345 opendirunlink $DIR/$tdir/striped_dir/test2 ||
2346 error "open unlink test2 failed"
2348 $CHECKSTAT -a $DIR/$tdir/striped_dir/test1 ||
2349 error "test1 still exists"
2350 $CHECKSTAT -a $DIR/$tdir/striped_dir/test2 ||
2351 error "test2 still exists"
2353 run_test 31p "remove of open striped directory"
2355 cleanup_test32_mount() {
2357 $UMOUNT $DIR/$tdir/ext2-mountpoint
2361 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2362 echo "== more mountpoints and symlinks ================="
2363 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2364 trap cleanup_test32_mount EXIT
2365 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2366 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2367 $CHECKSTAT -t dir $DIR/$tdir/ext2-mountpoint/.. || error
2368 cleanup_test32_mount
2370 run_test 32a "stat d32a/ext2-mountpoint/.. ====================="
2373 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
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 ls -al $DIR/$tdir/ext2-mountpoint/.. || error
2379 cleanup_test32_mount
2381 run_test 32b "open d32b/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 test_mkdir -p $DIR/$tdir/d2/test_dir
2390 $CHECKSTAT -t dir $DIR/$tdir/ext2-mountpoint/../d2/test_dir || error
2391 cleanup_test32_mount
2393 run_test 32c "stat d32c/ext2-mountpoint/../d2/test_dir ========="
2396 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2397 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2398 trap cleanup_test32_mount EXIT
2399 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2400 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2401 test_mkdir -p $DIR/$tdir/d2/test_dir
2402 ls -al $DIR/$tdir/ext2-mountpoint/../d2/test_dir || error
2403 cleanup_test32_mount
2405 run_test 32d "open d32d/ext2-mountpoint/../d2/test_dir ========="
2408 [ -e $DIR/d32e ] && rm -fr $DIR/d32e
2409 test_mkdir -p $DIR/d32e/tmp
2410 TMP_DIR=$DIR/d32e/tmp
2411 ln -s $DIR/d32e $TMP_DIR/symlink11
2412 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
2413 $CHECKSTAT -t link $DIR/d32e/tmp/symlink11 || error
2414 $CHECKSTAT -t link $DIR/d32e/symlink01 || error
2416 run_test 32e "stat d32e/symlink->tmp/symlink->lustre-subdir ===="
2419 [ -e $DIR/d32f ] && rm -fr $DIR/d32f
2420 test_mkdir -p $DIR/d32f/tmp
2421 TMP_DIR=$DIR/d32f/tmp
2422 ln -s $DIR/d32f $TMP_DIR/symlink11
2423 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
2424 ls $DIR/d32f/tmp/symlink11 || error
2425 ls $DIR/d32f/symlink01 || error
2427 run_test 32f "open d32f/symlink->tmp/symlink->lustre-subdir ===="
2430 TMP_DIR=$DIR/$tdir/tmp
2431 test_mkdir -p $DIR/$tdir/tmp
2432 test_mkdir $DIR/${tdir}2
2433 ln -s $DIR/${tdir}2 $TMP_DIR/symlink12
2434 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
2435 $CHECKSTAT -t link $TMP_DIR/symlink12 || error
2436 $CHECKSTAT -t link $DIR/$tdir/symlink02 || error
2437 $CHECKSTAT -t dir -f $TMP_DIR/symlink12 || error
2438 $CHECKSTAT -t dir -f $DIR/$tdir/symlink02 || error
2440 run_test 32g "stat d32g/symlink->tmp/symlink->lustre-subdir/${tdir}2"
2443 rm -fr $DIR/$tdir $DIR/${tdir}2
2444 TMP_DIR=$DIR/$tdir/tmp
2445 test_mkdir -p $DIR/$tdir/tmp
2446 test_mkdir $DIR/${tdir}2
2447 ln -s $DIR/${tdir}2 $TMP_DIR/symlink12
2448 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
2449 ls $TMP_DIR/symlink12 || error
2450 ls $DIR/$tdir/symlink02 || error
2452 run_test 32h "open d32h/symlink->tmp/symlink->lustre-subdir/${tdir}2"
2455 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2456 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2457 trap cleanup_test32_mount EXIT
2458 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2459 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2460 touch $DIR/$tdir/test_file
2461 $CHECKSTAT -t file $DIR/$tdir/ext2-mountpoint/../test_file || error
2462 cleanup_test32_mount
2464 run_test 32i "stat d32i/ext2-mountpoint/../test_file ==========="
2467 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2468 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2469 trap cleanup_test32_mount EXIT
2470 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2471 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2472 touch $DIR/$tdir/test_file
2473 cat $DIR/$tdir/ext2-mountpoint/../test_file || error
2474 cleanup_test32_mount
2476 run_test 32j "open d32j/ext2-mountpoint/../test_file ==========="
2479 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2481 trap cleanup_test32_mount EXIT
2482 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2483 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint
2484 test_mkdir -p $DIR/$tdir/d2
2485 touch $DIR/$tdir/d2/test_file || error
2486 $CHECKSTAT -t file $DIR/$tdir/ext2-mountpoint/../d2/test_file || error
2487 cleanup_test32_mount
2489 run_test 32k "stat d32k/ext2-mountpoint/../d2/test_file ========"
2492 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2494 trap cleanup_test32_mount EXIT
2495 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2496 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2497 test_mkdir -p $DIR/$tdir/d2
2498 touch $DIR/$tdir/d2/test_file
2499 cat $DIR/$tdir/ext2-mountpoint/../d2/test_file || error
2500 cleanup_test32_mount
2502 run_test 32l "open d32l/ext2-mountpoint/../d2/test_file ========"
2506 test_mkdir -p $DIR/d32m/tmp
2507 TMP_DIR=$DIR/d32m/tmp
2508 ln -s $DIR $TMP_DIR/symlink11
2509 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
2510 $CHECKSTAT -t link $DIR/d32m/tmp/symlink11 || error
2511 $CHECKSTAT -t link $DIR/d32m/symlink01 || error
2513 run_test 32m "stat d32m/symlink->tmp/symlink->lustre-root ======"
2517 test_mkdir -p $DIR/d32n/tmp
2518 TMP_DIR=$DIR/d32n/tmp
2519 ln -s $DIR $TMP_DIR/symlink11
2520 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
2521 ls -l $DIR/d32n/tmp/symlink11 || error
2522 ls -l $DIR/d32n/symlink01 || error
2524 run_test 32n "open d32n/symlink->tmp/symlink->lustre-root ======"
2528 test_mkdir -p $DIR/d32o/tmp
2529 TMP_DIR=$DIR/d32o/tmp
2530 ln -s $DIR/$tfile $TMP_DIR/symlink12
2531 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
2532 $CHECKSTAT -t link $DIR/d32o/tmp/symlink12 || error
2533 $CHECKSTAT -t link $DIR/d32o/symlink02 || error
2534 $CHECKSTAT -t file -f $DIR/d32o/tmp/symlink12 || error
2535 $CHECKSTAT -t file -f $DIR/d32o/symlink02 || error
2537 run_test 32o "stat d32o/symlink->tmp/symlink->lustre-root/$tfile"
2547 test_mkdir -p $DIR/d32p/tmp
2549 TMP_DIR=$DIR/d32p/tmp
2551 ln -s $DIR/$tfile $TMP_DIR/symlink12
2553 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
2555 cat $DIR/d32p/tmp/symlink12 || error
2557 cat $DIR/d32p/symlink02 || error
2560 run_test 32p "open d32p/symlink->tmp/symlink->lustre-root/$tfile"
2562 cleanup_testdir_mount() {
2568 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2569 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2570 trap cleanup_testdir_mount EXIT
2571 test_mkdir -p $DIR/$tdir
2572 touch $DIR/$tdir/under_the_mount
2573 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir
2574 ls $DIR/$tdir | grep "\<under_the_mount\>" && error
2575 cleanup_testdir_mount
2577 run_test 32q "stat follows mountpoints in Lustre (should return error)"
2580 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2581 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2582 trap cleanup_testdir_mount EXIT
2583 test_mkdir -p $DIR/$tdir
2584 touch $DIR/$tdir/under_the_mount
2585 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir
2586 ls $DIR/$tdir | grep -q under_the_mount && error || true
2587 cleanup_testdir_mount
2589 run_test 32r "opendir follows mountpoints in Lustre (should return error)"
2594 chmod 444 $DIR/$tfile
2595 chown $RUNAS_ID $DIR/$tfile
2597 $RUNAS $OPENFILE -f O_RDWR $DIR/$tfile && error || true
2600 run_test 33aa "write file with mode 444 (should return error) ===="
2604 test_mkdir -p $DIR/d33
2605 chown $RUNAS_ID $DIR/d33
2606 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $DIR/d33/f33|| error "create"
2607 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $DIR/d33/f33 && \
2608 error "open RDWR" || true
2610 run_test 33a "test open file(mode=0444) with O_RDWR (should return error)"
2614 test_mkdir -p $DIR/d33
2615 chown $RUNAS_ID $DIR/d33
2616 $RUNAS $OPENFILE -f 1286739555 $DIR/d33/f33 || true
2618 run_test 33b "test open file with malformed flags (No panic)"
2621 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2627 remote_ost_nodsh && skip "remote OST with nodsh" && return
2630 test_mkdir -p $DIR/d33
2631 # Read: 0, Write: 4, create/destroy: 2/0, stat: 1, punch: 0
2634 for ostnum in $(seq $OSTCOUNT); do
2635 # test-framework's OST numbering is one-based, while Lustre's
2637 ostname=$(printf "$FSNAME-OST%.4x" $((ostnum - 1)))
2638 # Parsing llobdstat's output sucks; we could grep the /proc
2639 # path, but that's likely to not be as portable as using the
2640 # llobdstat utility. So we parse lctl output instead.
2641 write_bytes=$(do_facet ost$ostnum lctl get_param -n \
2642 obdfilter/$ostname/stats |
2643 awk '/^write_bytes/ {print $7}' )
2644 echo "baseline_write_bytes@$OSTnum/$ostname=$write_bytes"
2645 if (( ${write_bytes:-0} > 0 ))
2652 $all_zeros || return 0
2655 echo foo > $DIR/d33/bar
2659 # Total up write_bytes after writing. We'd better find non-zeros.
2660 for ostnum in $(seq $OSTCOUNT); do
2661 ostname=$(printf "$FSNAME-OST%.4x" $((ostnum - 1)))
2662 write_bytes=$(do_facet ost$ostnum lctl get_param -n \
2663 obdfilter/$ostname/stats |
2664 awk '/^write_bytes/ {print $7}' )
2665 echo "write_bytes@$OSTnum/$ostname=$write_bytes"
2666 if (( ${write_bytes:-0} > 0 ))
2675 for ostnum in $(seq $OSTCOUNT); do
2676 ostname=$(printf "$FSNAME-OST%.4x" $((ostnum - 1)))
2677 echo "Check that write_bytes is present in obdfilter/*/stats:"
2678 do_facet ost$ostnum lctl get_param -n \
2679 obdfilter/$ostname/stats
2681 error "OST not keeping write_bytes stats (b22312)"
2684 run_test 33c "test llobdstat and write_bytes"
2687 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 2 MDTs" && return
2688 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2690 local remote_dir=$DIR/$tdir/remote_dir
2692 test_mkdir -p $DIR/$tdir
2693 $LFS mkdir -i $MDTIDX $remote_dir ||
2694 error "create remote directory failed"
2696 touch $remote_dir/$tfile
2697 chmod 444 $remote_dir/$tfile
2698 chown $RUNAS_ID $remote_dir/$tfile
2700 $RUNAS $OPENFILE -f O_RDWR $DIR/$tfile && error || true
2702 chown $RUNAS_ID $remote_dir
2703 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $remote_dir/f33 ||
2704 error "create" || true
2705 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $remote_dir/f33 &&
2706 error "open RDWR" || true
2707 $RUNAS $OPENFILE -f 1286739555 $remote_dir/f33 || true
2709 run_test 33d "openfile with 444 modes and malformed flags under remote dir"
2712 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2716 $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
2717 $LFS setdirstripe -i1 -c2 $DIR/$tdir/striped_dir1
2718 mkdir $DIR/$tdir/local_dir
2720 local s0_mode=$(stat -c%f $DIR/$tdir/striped_dir)
2721 local s1_mode=$(stat -c%f $DIR/$tdir/striped_dir1)
2722 local l_mode=$(stat -c%f $DIR/$tdir/local_dir)
2724 [ "$l_mode" = "$s0_mode" -a "$l_mode" = "$s1_mode" ] ||
2725 error "mkdir $l_mode striped0 $s0_mode striped1 $s1_mode"
2727 rmdir $DIR/$tdir/* || error "rmdir failed"
2730 $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
2731 $LFS setdirstripe -i1 -c2 $DIR/$tdir/striped_dir1
2732 mkdir $DIR/$tdir/local_dir
2734 s0_mode=$(stat -c%f $DIR/$tdir/striped_dir)
2735 s1_mode=$(stat -c%f $DIR/$tdir/striped_dir1)
2736 l_mode=$(stat -c%f $DIR/$tdir/local_dir)
2738 [ "$l_mode" = "$s0_mode" -a "$l_mode" = "$s1_mode" ] ||
2739 error "mkdir $l_mode striped0 $s0_mode striped1 $s1_mode 777"
2741 rmdir $DIR/$tdir/* || error "rmdir(umask 777) failed"
2744 $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
2745 $LFS setdirstripe -i1 -c2 $DIR/$tdir/striped_dir1
2746 mkdir $DIR/$tdir/local_dir
2748 s0_mode=$(stat -c%f $DIR/$tdir/striped_dir)
2749 s1_mode=$(stat -c%f $DIR/$tdir/striped_dir1)
2750 l_mode=$(stat -c%f $DIR/$tdir/local_dir)
2752 [ "$l_mode" = "$s0_mode" -a "$l_mode" = "$s1_mode" ] ||
2753 error "mkdir $l_mode striped0 $s0_mode striped1 $s1_mode 0"
2755 run_test 33e "mkdir and striped directory should have same mode"
2759 do_facet $SINGLEMDS $LCTL set_param mdt.*.enable_remote_dir_gid=0
2763 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2766 chmod go+rwx $DIR/$tdir
2767 do_facet $SINGLEMDS $LCTL set_param mdt.*.enable_remote_dir_gid=-1
2768 trap cleanup_33f EXIT
2770 $RUNAS lfs mkdir -c$MDSCOUNT $DIR/$tdir/striped_dir ||
2771 error "cannot create striped directory"
2773 $RUNAS touch $DIR/$tdir/striped_dir/{0..16} ||
2774 error "cannot create files in striped directory"
2776 $RUNAS rm $DIR/$tdir/striped_dir/{0..16} ||
2777 error "cannot remove files in striped directory"
2779 $RUNAS rmdir $DIR/$tdir/striped_dir ||
2780 error "cannot remove striped directory"
2784 run_test 33f "nonroot user can create, access, and remove a striped directory"
2786 TEST_34_SIZE=${TEST_34_SIZE:-2000000000000}
2789 $MCREATE $DIR/f34 || error
2790 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" || error
2791 $TRUNCATE $DIR/f34 $TEST_34_SIZE || error
2792 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" || error
2793 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2795 run_test 34a "truncate file that has not been opened ==========="
2798 [ ! -f $DIR/f34 ] && test_34a
2799 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2800 $OPENFILE -f O_RDONLY $DIR/f34
2801 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" || error
2802 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2804 run_test 34b "O_RDONLY opening file doesn't create objects ====="
2807 [ ! -f $DIR/f34 ] && test_34a
2808 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2809 $OPENFILE -f O_RDWR $DIR/f34
2810 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" && error
2811 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2813 run_test 34c "O_RDWR opening file-with-size works =============="
2816 [ ! -f $DIR/f34 ] && test_34a
2817 dd if=/dev/zero of=$DIR/f34 conv=notrunc bs=4k count=1 || error
2818 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2821 run_test 34d "write to sparse file ============================="
2825 $MCREATE $DIR/f34e || error
2826 $TRUNCATE $DIR/f34e 1000 || error
2827 $CHECKSTAT -s 1000 $DIR/f34e || error
2828 $OPENFILE -f O_RDWR $DIR/f34e
2829 $CHECKSTAT -s 1000 $DIR/f34e || error
2831 run_test 34e "create objects, some with size and some without =="
2833 test_34f() { # bug 6242, 6243
2834 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2837 $MCREATE $DIR/f34f || error
2838 $TRUNCATE $DIR/f34f $SIZE34F || error "truncating $DIR/f3f to $SIZE34F"
2839 dd if=$DIR/f34f of=$TMP/f34f
2840 $CHECKSTAT -s $SIZE34F $TMP/f34f || error "$TMP/f34f not $SIZE34F bytes"
2841 dd if=/dev/zero of=$TMP/f34fzero bs=$SIZE34F count=1
2842 cmp $DIR/f34f $TMP/f34fzero || error "$DIR/f34f not all zero"
2843 cmp $TMP/f34f $TMP/f34fzero || error "$TMP/f34f not all zero"
2844 rm $TMP/f34f $TMP/f34fzero $DIR/f34f
2846 run_test 34f "read from a file with no objects until EOF ======="
2849 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2850 dd if=/dev/zero of=$DIR/$tfile bs=1 count=100 seek=$TEST_34_SIZE || error
2851 $TRUNCATE $DIR/$tfile $((TEST_34_SIZE / 2))|| error
2852 $CHECKSTAT -s $((TEST_34_SIZE / 2)) $DIR/$tfile || error "truncate failed"
2853 cancel_lru_locks osc
2854 $CHECKSTAT -s $((TEST_34_SIZE / 2)) $DIR/$tfile || \
2855 error "wrong size after lock cancel"
2857 $TRUNCATE $DIR/$tfile $TEST_34_SIZE || error
2858 $CHECKSTAT -s $TEST_34_SIZE $DIR/$tfile || \
2859 error "expanding truncate failed"
2860 cancel_lru_locks osc
2861 $CHECKSTAT -s $TEST_34_SIZE $DIR/$tfile || \
2862 error "wrong expanded size after lock cancel"
2864 run_test 34g "truncate long file ==============================="
2867 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2871 dd if=/dev/zero of=$DIR/$tfile bs=1M count=10 || error
2872 sync # Flush the cache so that multiop below does not block on cache
2873 # flush when getting the group lock
2874 $MULTIOP $DIR/$tfile OG${gid}T${sz}g${gid}c &
2877 # Since just timed wait is not good enough, let's do a sync write
2878 # that way we are sure enough time for a roundtrip + processing
2879 # passed + 2 seconds of extra margin.
2880 dd if=/dev/zero of=$DIR/${tfile}-1 bs=4096 oflag=direct count=1
2884 if [[ `ps h -o comm -p $MULTIPID` == "multiop" ]]; then
2885 error "Multiop blocked on ftruncate, pid=$MULTIPID"
2889 local nsz=`stat -c %s $DIR/$tfile`
2890 [[ $nsz == $sz ]] || error "New size wrong $nsz != $sz"
2892 run_test 34h "ftruncate file under grouplock should not block"
2895 cp /bin/sh $DIR/f35a
2897 chown $RUNAS_ID $DIR/f35a
2898 $RUNAS $DIR/f35a && error || true
2901 run_test 35a "exec file with mode 444 (should return and not leak) ====="
2905 utime $DIR/f36 || error
2907 run_test 36a "MDS utime check (mknod, utime) ==================="
2911 utime $DIR/f36 || error
2913 run_test 36b "OST utime check (open, utime) ===================="
2918 chown $RUNAS_ID $DIR/d36
2919 $RUNAS utime $DIR/d36/f36 || error
2921 run_test 36c "non-root MDS utime check (mknod, utime) =========="
2924 [ ! -d $DIR/d36 ] && test_36c
2925 echo "" > $DIR/d36/f36
2926 $RUNAS utime $DIR/d36/f36 || error
2928 run_test 36d "non-root OST utime check (open, utime) ==========="
2931 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID -- skipping" && return
2932 test_mkdir -p $DIR/$tdir
2933 touch $DIR/$tdir/$tfile
2934 $RUNAS utime $DIR/$tdir/$tfile && \
2935 error "utime worked, expected failure" || true
2937 run_test 36e "utime on non-owned file (should return error) ===="
2941 local LANG_SAVE=$LANG
2942 local LC_LANG_SAVE=$LC_LANG
2943 export LANG=C LC_LANG=C # for date language
2945 DATESTR="Dec 20 2000"
2946 test_mkdir -p $DIR/$tdir
2947 lctl set_param fail_loc=$fl
2949 cp /etc/hosts $DIR/$tdir/$tfile
2950 sync & # write RPC generated with "current" inode timestamp, but delayed
2952 touch --date="$DATESTR" $DIR/$tdir/$tfile # setattr timestamp in past
2953 LS_BEFORE="`ls -l $DIR/$tdir/$tfile`" # old timestamp from client cache
2954 cancel_lru_locks osc
2955 LS_AFTER="`ls -l $DIR/$tdir/$tfile`" # timestamp from OST object
2957 [ "$LS_BEFORE" != "$LS_AFTER" ] && \
2958 echo "BEFORE: $LS_BEFORE" && \
2959 echo "AFTER : $LS_AFTER" && \
2960 echo "WANT : $DATESTR" && \
2961 error "$DIR/$tdir/$tfile timestamps changed" || true
2963 export LANG=$LANG_SAVE LC_LANG=$LC_LANG_SAVE
2967 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2968 #define OBD_FAIL_OST_BRW_PAUSE_BULK 0x214
2969 subr_36fh "0x80000214"
2971 run_test 36f "utime on file racing with OST BRW write =========="
2974 remote_ost_nodsh && skip "remote OST with nodsh" && return
2975 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2980 test_mkdir -p $DIR/$tdir
2981 fmd_max_age=$(do_facet ost1 \
2982 "lctl get_param -n obdfilter.*.client_cache_seconds 2> /dev/null | \
2985 fmd_before=$(do_facet ost1 \
2986 "awk '/ll_fmd_cache/ {print \\\$2}' /proc/slabinfo")
2987 touch $DIR/$tdir/$tfile
2988 sleep $((fmd_max_age + 12))
2989 fmd_after=$(do_facet ost1 \
2990 "awk '/ll_fmd_cache/ {print \\\$2}' /proc/slabinfo")
2992 echo "fmd_before: $fmd_before"
2993 echo "fmd_after: $fmd_after"
2994 [[ $fmd_after -gt $fmd_before ]] &&
2995 echo "AFTER: $fmd_after > BEFORE: $fmd_before" &&
2996 error "fmd didn't expire after ping" || true
2998 run_test 36g "filter mod data cache expiry ====================="
3001 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3002 #define OBD_FAIL_OST_BRW_PAUSE_BULK2 0x227
3003 subr_36fh "0x80000227"
3005 run_test 36h "utime on file racing with OST BRW write =========="
3008 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
3010 test_mkdir $DIR/$tdir
3011 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR/$tdir/striped_dir
3013 local mtime=$(stat -c%Y $DIR/$tdir/striped_dir)
3014 local new_mtime=$((mtime + 200))
3016 #change Modify time of striped dir
3017 touch -m -d @$new_mtime $DIR/$tdir/striped_dir ||
3018 error "change mtime failed"
3020 local got=$(stat -c%Y $DIR/$tdir/striped_dir)
3022 [ "$new_mtime" = "$got" ] || error "expect $new_mtime got $got"
3024 run_test 36i "change mtime on striped directory"
3026 # test_37 - duplicate with tests 32q 32r
3029 local file=$DIR/$tfile
3031 openfile -f O_DIRECTORY $file
3034 [ $RC -eq 0 ] && error "opened file $file with O_DIRECTORY" || true
3035 [ $RC -eq $ENOTDIR ] || error "error $RC should be ENOTDIR ($ENOTDIR)"
3037 run_test 38 "open a regular file with O_DIRECTORY should return -ENOTDIR ==="
3041 touch $DIR/${tfile}2
3042 # ls -l $DIR/$tfile $DIR/${tfile}2
3043 # ls -lu $DIR/$tfile $DIR/${tfile}2
3044 # ls -lc $DIR/$tfile $DIR/${tfile}2
3046 $OPENFILE -f O_CREAT:O_TRUNC:O_WRONLY $DIR/${tfile}2
3047 if [ ! $DIR/${tfile}2 -nt $DIR/$tfile ]; then
3049 ls -l --full-time $DIR/$tfile $DIR/${tfile}2
3051 ls -lu --full-time $DIR/$tfile $DIR/${tfile}2
3053 ls -lc --full-time $DIR/$tfile $DIR/${tfile}2
3054 error "O_TRUNC didn't change timestamps"
3057 run_test 39 "mtime changed on create ==========================="
3060 test_mkdir -p -c1 $DIR/$tdir
3061 cp -p /etc/passwd $DIR/$tdir/fopen
3062 cp -p /etc/passwd $DIR/$tdir/flink
3063 cp -p /etc/passwd $DIR/$tdir/funlink
3064 cp -p /etc/passwd $DIR/$tdir/frename
3065 ln $DIR/$tdir/funlink $DIR/$tdir/funlink2
3068 echo "aaaaaa" >> $DIR/$tdir/fopen
3069 echo "aaaaaa" >> $DIR/$tdir/flink
3070 echo "aaaaaa" >> $DIR/$tdir/funlink
3071 echo "aaaaaa" >> $DIR/$tdir/frename
3073 local open_new=`stat -c %Y $DIR/$tdir/fopen`
3074 local link_new=`stat -c %Y $DIR/$tdir/flink`
3075 local unlink_new=`stat -c %Y $DIR/$tdir/funlink`
3076 local rename_new=`stat -c %Y $DIR/$tdir/frename`
3078 cat $DIR/$tdir/fopen > /dev/null
3079 ln $DIR/$tdir/flink $DIR/$tdir/flink2
3080 rm -f $DIR/$tdir/funlink2
3081 mv -f $DIR/$tdir/frename $DIR/$tdir/frename2
3083 for (( i=0; i < 2; i++ )) ; do
3084 local open_new2=`stat -c %Y $DIR/$tdir/fopen`
3085 local link_new2=`stat -c %Y $DIR/$tdir/flink`
3086 local unlink_new2=`stat -c %Y $DIR/$tdir/funlink`
3087 local rename_new2=`stat -c %Y $DIR/$tdir/frename2`
3089 [ $open_new2 -eq $open_new ] || error "open file reverses mtime"
3090 [ $link_new2 -eq $link_new ] || error "link file reverses mtime"
3091 [ $unlink_new2 -eq $unlink_new ] || error "unlink file reverses mtime"
3092 [ $rename_new2 -eq $rename_new ] || error "rename file reverses mtime"
3094 cancel_lru_locks osc
3095 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3098 run_test 39b "mtime change on open, link, unlink, rename ======"
3100 # this should be set to past
3101 TEST_39_MTIME=`date -d "1 year ago" +%s`
3107 local mtime0=`stat -c %Y $DIR1/$tfile`
3109 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3110 local mtime1=`stat -c %Y $DIR1/$tfile`
3111 [ "$mtime1" = $TEST_39_MTIME ] || \
3112 error "mtime is not set to past: $mtime1, should be $TEST_39_MTIME"
3115 echo hello >> $DIR1/$tfile
3117 local mtime2=`stat -c %Y $DIR1/$tfile`
3118 [ "$mtime2" -ge "$d1" ] && [ "$mtime2" -le "$d2" ] || \
3119 error "mtime is not updated on write: $d1 <= $mtime2 <= $d2"
3121 mv $DIR1/$tfile $DIR1/$tfile-1
3123 for (( i=0; i < 2; i++ )) ; do
3124 local mtime3=`stat -c %Y $DIR1/$tfile-1`
3125 [ "$mtime2" = "$mtime3" ] || \
3126 error "mtime ($mtime2) changed (to $mtime3) on rename"
3128 cancel_lru_locks osc
3129 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3132 run_test 39c "mtime change on rename ==========================="
3136 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3139 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3141 for (( i=0; i < 2; i++ )) ; do
3142 local mtime=`stat -c %Y $DIR1/$tfile`
3143 [ $mtime = $TEST_39_MTIME ] || \
3144 error "mtime($mtime) is not set to $TEST_39_MTIME"
3146 cancel_lru_locks osc
3147 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3150 run_test 39d "create, utime, stat =============================="
3154 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3156 local mtime1=`stat -c %Y $DIR1/$tfile`
3158 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3160 for (( i=0; i < 2; i++ )) ; do
3161 local mtime2=`stat -c %Y $DIR1/$tfile`
3162 [ $mtime2 = $TEST_39_MTIME ] || \
3163 error "mtime($mtime2) is not set to $TEST_39_MTIME"
3165 cancel_lru_locks osc
3166 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3169 run_test 39e "create, stat, utime, stat ========================"
3173 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3175 mtime1=`stat -c %Y $DIR1/$tfile`
3178 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3180 for (( i=0; i < 2; i++ )) ; do
3181 local mtime2=`stat -c %Y $DIR1/$tfile`
3182 [ $mtime2 = $TEST_39_MTIME ] || \
3183 error "mtime($mtime2) is not set to $TEST_39_MTIME"
3185 cancel_lru_locks osc
3186 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3189 run_test 39f "create, stat, sleep, utime, stat ================="
3193 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3194 echo hello >> $DIR1/$tfile
3195 local mtime1=`stat -c %Y $DIR1/$tfile`
3198 chmod o+r $DIR1/$tfile
3200 for (( i=0; i < 2; i++ )) ; do
3201 local mtime2=`stat -c %Y $DIR1/$tfile`
3202 [ "$mtime1" = "$mtime2" ] || \
3203 error "lost mtime: $mtime2, should be $mtime1"
3205 cancel_lru_locks osc
3206 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3209 run_test 39g "write, chmod, stat ==============================="
3213 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3218 echo hello >> $DIR1/$tfile
3219 local mtime1=`stat -c %Y $DIR1/$tfile`
3221 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3223 if [ "$d1" != "$d2" ]; then
3224 echo "write and touch not within one second"
3226 for (( i=0; i < 2; i++ )) ; do
3227 local mtime2=`stat -c %Y $DIR1/$tfile`
3228 [ "$mtime2" = $TEST_39_MTIME ] || \
3229 error "lost mtime: $mtime2, should be $TEST_39_MTIME"
3231 cancel_lru_locks osc
3232 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3236 run_test 39h "write, utime within one second, stat ============="
3239 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3243 echo hello >> $DIR1/$tfile
3244 local mtime1=`stat -c %Y $DIR1/$tfile`
3246 mv $DIR1/$tfile $DIR1/$tfile-1
3248 for (( i=0; i < 2; i++ )) ; do
3249 local mtime2=`stat -c %Y $DIR1/$tfile-1`
3251 [ "$mtime1" = "$mtime2" ] || \
3252 error "lost mtime: $mtime2, should be $mtime1"
3254 cancel_lru_locks osc
3255 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3258 run_test 39i "write, rename, stat =============================="
3261 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3262 start_full_debug_logging
3266 #define OBD_FAIL_OSC_DELAY_SETTIME 0x412
3267 lctl set_param fail_loc=0x80000412
3268 multiop_bg_pause $DIR1/$tfile oO_RDWR:w2097152_c ||
3269 error "multiop failed"
3271 local mtime1=`stat -c %Y $DIR1/$tfile`
3273 mv $DIR1/$tfile $DIR1/$tfile-1
3275 kill -USR1 $multipid
3276 wait $multipid || error "multiop close failed"
3278 for (( i=0; i < 2; i++ )) ; do
3279 local mtime2=`stat -c %Y $DIR1/$tfile-1`
3280 [ "$mtime1" = "$mtime2" ] ||
3281 error "mtime is lost on close: $mtime2, " \
3284 cancel_lru_locks osc
3285 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3287 lctl set_param fail_loc=0
3288 stop_full_debug_logging
3290 run_test 39j "write, rename, close, stat ======================="
3293 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3297 multiop_bg_pause $DIR1/$tfile oO_RDWR:w2097152_c || error "multiop failed"
3299 local mtime1=`stat -c %Y $DIR1/$tfile`
3301 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3303 kill -USR1 $multipid
3304 wait $multipid || error "multiop close failed"
3306 for (( i=0; i < 2; i++ )) ; do
3307 local mtime2=`stat -c %Y $DIR1/$tfile`
3309 [ "$mtime2" = $TEST_39_MTIME ] || \
3310 error "mtime is lost on close: $mtime2, should be $TEST_39_MTIME"
3312 cancel_lru_locks osc
3313 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3316 run_test 39k "write, utime, close, stat ========================"
3318 # this should be set to future
3319 TEST_39_ATIME=`date -d "1 year" +%s`
3322 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3323 remote_mds_nodsh && skip "remote MDS with nodsh" && return
3324 local atime_diff=$(do_facet $SINGLEMDS \
3325 lctl get_param -n mdd.*MDT0000*.atime_diff)
3329 # test setting directory atime to future
3330 touch -a -d @$TEST_39_ATIME $DIR/$tdir
3331 local atime=$(stat -c %X $DIR/$tdir)
3332 [ "$atime" = $TEST_39_ATIME ] || \
3333 error "atime is not set to future: $atime, $TEST_39_ATIME"
3335 # test setting directory atime from future to now
3336 local d1=$(date +%s)
3338 local d2=$(date +%s)
3340 cancel_lru_locks mdc
3341 atime=$(stat -c %X $DIR/$tdir)
3342 [ "$atime" -ge "$d1" -a "$atime" -le "$d2" ] || \
3343 error "atime is not updated from future: $atime, $d1<atime<$d2"
3345 do_facet $SINGLEMDS lctl set_param -n mdd.*MDT0000*.atime_diff=2
3348 # test setting directory atime when now > dir atime + atime_diff
3352 cancel_lru_locks mdc
3353 atime=$(stat -c %X $DIR/$tdir)
3354 [ "$atime" -ge "$d1" -a "$atime" -le "$d2" ] || \
3355 error "atime is not updated : $atime, should be $d2"
3357 do_facet $SINGLEMDS lctl set_param -n mdd.*MDT0000*.atime_diff=60
3360 # test not setting directory atime when now < dir atime + atime_diff
3362 cancel_lru_locks mdc
3363 atime=$(stat -c %X $DIR/$tdir)
3364 [ "$atime" -ge "$d1" -a "$atime" -le "$d2" ] || \
3365 error "atime is updated to $atime, should remain $d1<atime<$d2"
3367 do_facet $SINGLEMDS \
3368 lctl set_param -n mdd.*MDT0000*.atime_diff=$atime_diff
3370 run_test 39l "directory atime update ==========================="
3373 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3376 local far_past_mtime=$(date -d "May 29 1953" +%s)
3377 local far_past_atime=$(date -d "Dec 17 1903" +%s)
3379 touch -m -d @$far_past_mtime $DIR1/$tfile
3380 touch -a -d @$far_past_atime $DIR1/$tfile
3382 for (( i=0; i < 2; i++ )) ; do
3383 local timestamps=$(stat -c "%X %Y" $DIR1/$tfile)
3384 [ "$timestamps" = "$far_past_atime $far_past_mtime" ] || \
3385 error "atime or mtime set incorrectly"
3387 cancel_lru_locks osc
3388 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3391 run_test 39m "test atime and mtime before 1970"
3393 test_39n() { # LU-3832
3394 local atime_diff=$(do_facet $SINGLEMDS \
3395 lctl get_param -n mdd.*MDT0000*.atime_diff)
3400 do_facet $SINGLEMDS lctl set_param -n mdd.*MDT0000*.atime_diff=1
3403 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 status=noxfer
3404 atime0=$(stat -c %X $DIR/$tfile)
3407 $MULTIOP $DIR/$tfile oO_RDONLY:O_NOATIME:r4096c
3408 atime1=$(stat -c %X $DIR/$tfile)
3411 cancel_lru_locks mdc
3412 cancel_lru_locks osc
3413 $MULTIOP $DIR/$tfile oO_RDONLY:O_NOATIME:r4096c
3414 atime2=$(stat -c %X $DIR/$tfile)
3416 do_facet $SINGLEMDS \
3417 lctl set_param -n mdd.*MDT0000*.atime_diff=$atime_diff
3419 [ "$atime0" -eq "$atime1" ] || error "atime0 $atime0 != atime1 $atime1"
3420 [ "$atime1" -eq "$atime2" ] || error "atime0 $atime0 != atime1 $atime1"
3422 run_test 39n "check that O_NOATIME is honored"
3425 TESTDIR=$DIR/$tdir/$tfile
3426 [ -e $TESTDIR ] && rm -rf $TESTDIR
3433 links2=$(stat -c %h .)
3434 [ $(($links1 + 2)) != $links2 ] &&
3435 error "wrong links count $(($links1 + 2)) != $links2"
3437 links3=$(stat -c %h .)
3438 [ $(($links1 + 1)) != $links3 ] &&
3439 error "wrong links count $links1 != $links3"
3442 run_test 39o "directory cached attributes updated after create ========"
3445 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 2 MDTs" && return
3447 TESTDIR=$DIR/$tdir/$tfile
3448 [ -e $TESTDIR ] && rm -rf $TESTDIR
3449 test_mkdir -p $TESTDIR
3453 $LFS mkdir -i $MDTIDX $TESTDIR/remote_dir1
3454 $LFS mkdir -i $MDTIDX $TESTDIR/remote_dir2
3456 links2=$(stat -c %h .)
3457 [ $(($links1 + 2)) != $links2 ] &&
3458 error "wrong links count $(($links1 + 2)) != $links2"
3460 links3=$(stat -c %h .)
3461 [ $(($links1 + 1)) != $links3 ] &&
3462 error "wrong links count $links1 != $links3"
3465 run_test 39p "remote directory cached attributes updated after create ========"
3469 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1
3470 $RUNAS $OPENFILE -f O_WRONLY:O_TRUNC $DIR/$tfile &&
3471 error "openfile O_WRONLY:O_TRUNC $tfile failed"
3472 $CHECKSTAT -t file -s 4096 $DIR/$tfile ||
3473 error "$tfile is not 4096 bytes in size"
3475 run_test 40 "failed open(O_TRUNC) doesn't truncate ============="
3479 small_write $DIR/f41 18
3481 run_test 41 "test small file write + fstat ====================="
3483 count_ost_writes() {
3484 lctl get_param -n osc.*.stats |
3485 awk -vwrites=0 '/ost_write/ { writes += $2 } \
3486 END { printf("%0.0f", writes) }'
3493 BG_DIRTY_RATIO_SAVE=10
3494 MAX_BG_DIRTY_RATIO=25
3498 # in 2.6, restore /proc/sys/vm/dirty_writeback_centisecs,
3499 # dirty_ratio, dirty_background_ratio
3500 if [ -f /proc/sys/vm/dirty_writeback_centisecs ]; then
3501 sysctl -w vm.dirty_writeback_centisecs=$WRITEBACK_SAVE
3502 sysctl -w vm.dirty_background_ratio=$BG_DIRTY_RATIO_SAVE
3503 sysctl -w vm.dirty_ratio=$DIRTY_RATIO_SAVE
3505 # if file not here, we are a 2.4 kernel
3506 kill -CONT `pidof kupdated`
3511 # setup the trap first, so someone cannot exit the test at the
3512 # exact wrong time and mess up a machine
3513 trap start_writeback EXIT
3514 # in 2.6, save and 0 /proc/sys/vm/dirty_writeback_centisecs
3515 if [ -f /proc/sys/vm/dirty_writeback_centisecs ]; then
3516 WRITEBACK_SAVE=`sysctl -n vm.dirty_writeback_centisecs`
3517 sysctl -w vm.dirty_writeback_centisecs=0
3518 sysctl -w vm.dirty_writeback_centisecs=0
3519 # save and increase /proc/sys/vm/dirty_ratio
3520 DIRTY_RATIO_SAVE=`sysctl -n vm.dirty_ratio`
3521 sysctl -w vm.dirty_ratio=$MAX_DIRTY_RATIO
3522 # save and increase /proc/sys/vm/dirty_background_ratio
3523 BG_DIRTY_RATIO_SAVE=`sysctl -n vm.dirty_background_ratio`
3524 sysctl -w vm.dirty_background_ratio=$MAX_BG_DIRTY_RATIO
3526 # if file not here, we are a 2.4 kernel
3527 kill -STOP `pidof kupdated`
3531 # ensure that all stripes have some grant before we test client-side cache
3533 for i in `seq -f $DIR/f42-%g 1 $OSTCOUNT`; do
3534 dd if=/dev/zero of=$i bs=4k count=1
3539 # Tests 42* verify that our behaviour is correct WRT caching, file closure,
3540 # file truncation, and file removal.
3542 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3544 cancel_lru_locks osc
3546 sync; sleep 1; sync # just to be safe
3547 BEFOREWRITES=`count_ost_writes`
3548 lctl get_param -n osc.*[oO][sS][cC][_-]*.cur_grant_bytes | grep "[0-9]"
3549 dd if=/dev/zero of=$DIR/f42a bs=1024 count=100
3550 AFTERWRITES=`count_ost_writes`
3551 [ $BEFOREWRITES -eq $AFTERWRITES ] || \
3552 error "$BEFOREWRITES < $AFTERWRITES"
3555 run_test 42a "ensure that we don't flush on close =============="
3558 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3560 cancel_lru_locks osc
3563 dd if=/dev/zero of=$DIR/f42b bs=1024 count=100
3564 BEFOREWRITES=$(count_ost_writes)
3565 $MUNLINK $DIR/f42b || error "$MUNLINK $DIR/f42b: $?"
3566 AFTERWRITES=$(count_ost_writes)
3567 if [[ $BEFOREWRITES -lt $AFTERWRITES ]]; then
3568 error "$BEFOREWRITES < $AFTERWRITES on unlink"
3570 BEFOREWRITES=$(count_ost_writes)
3571 sync || error "sync: $?"
3572 AFTERWRITES=$(count_ost_writes)
3573 if [[ $BEFOREWRITES -lt $AFTERWRITES ]]; then
3574 error "$BEFOREWRITES < $AFTERWRITES on sync"
3576 dmesg | grep 'error from obd_brw_async' && error 'error writing back'
3580 run_test 42b "test destroy of file with cached dirty data ======"
3582 # if these tests just want to test the effect of truncation,
3583 # they have to be very careful. consider:
3584 # - the first open gets a {0,EOF}PR lock
3585 # - the first write conflicts and gets a {0, count-1}PW
3586 # - the rest of the writes are under {count,EOF}PW
3587 # - the open for truncate tries to match a {0,EOF}PR
3588 # for the filesize and cancels the PWs.
3589 # any number of fixes (don't get {0,EOF} on open, match
3590 # composite locks, do smarter file size management) fix
3591 # this, but for now we want these tests to verify that
3592 # the cancellation with truncate intent works, so we
3593 # start the file with a full-file pw lock to match against
3594 # until the truncate.
3599 cancel_lru_locks osc
3601 # prime the file with 0,EOF PW to match
3605 # now the real test..
3606 dd if=/dev/zero of=$file bs=1024 count=100
3607 BEFOREWRITES=`count_ost_writes`
3608 $TRUNCATE $file $offset
3609 cancel_lru_locks osc
3610 AFTERWRITES=`count_ost_writes`
3615 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3617 [ $BEFOREWRITES -eq $AFTERWRITES ] && \
3618 error "beforewrites $BEFOREWRITES == afterwrites $AFTERWRITES on truncate"
3621 run_test 42c "test partial truncate of file with cached dirty data"
3624 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3626 [ $BEFOREWRITES -eq $AFTERWRITES ] || \
3627 error "beforewrites $BEFOREWRITES != afterwrites $AFTERWRITES on truncate"
3630 run_test 42d "test complete truncate of file with cached dirty data"
3632 test_42e() { # bug22074
3633 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3634 local TDIR=$DIR/${tdir}e
3635 local pagesz=$(page_size)
3636 local pages=16 # hardcoded 16 pages, don't change it.
3637 local files=$((OSTCOUNT * 500)) # hopefully 500 files on each OST
3638 local proc_osc0="osc.${FSNAME}-OST0000-osc-[^MDT]*"
3642 test_mkdir -p $DIR/${tdir}e
3643 $SETSTRIPE -c 1 $TDIR
3644 createmany -o $TDIR/f $files
3646 max_dirty_mb=$($LCTL get_param -n $proc_osc0/max_dirty_mb)
3648 # we assume that with $OSTCOUNT files, at least one of them will
3649 # be allocated on OST0.
3650 warmup_files=$((OSTCOUNT * max_dirty_mb))
3651 createmany -o $TDIR/w $warmup_files
3653 # write a large amount of data into one file and sync, to get good
3654 # avail_grant number from OST.
3655 for ((i=0; i<$warmup_files; i++)); do
3656 idx=$($GETSTRIPE -i $TDIR/w$i)
3657 [ $idx -ne 0 ] && continue
3658 dd if=/dev/zero of=$TDIR/w$i bs="$max_dirty_mb"M count=1
3661 [[ $i -gt $warmup_files ]] && error "OST0 is still cold"
3663 $LCTL get_param $proc_osc0/cur_dirty_bytes
3664 $LCTL get_param $proc_osc0/cur_grant_bytes
3666 # create as much dirty pages as we can while not to trigger the actual
3667 # RPCs directly. but depends on the env, VFS may trigger flush during this
3668 # period, hopefully we are good.
3669 for ((i=0; i<$warmup_files; i++)); do
3670 idx=$($GETSTRIPE -i $TDIR/w$i)
3671 [ $idx -ne 0 ] && continue
3672 dd if=/dev/zero of=$TDIR/w$i bs=1M count=1 2>/dev/null
3674 $LCTL get_param $proc_osc0/cur_dirty_bytes
3675 $LCTL get_param $proc_osc0/cur_grant_bytes
3677 # perform the real test
3678 $LCTL set_param $proc_osc0/rpc_stats 0
3679 for ((;i<$files; i++)); do
3680 [ $($GETSTRIPE -i $TDIR/f$i) -eq 0 ] || continue
3681 dd if=/dev/zero of=$TDIR/f$i bs=$pagesz count=$pages 2>/dev/null
3684 $LCTL get_param $proc_osc0/rpc_stats
3687 local have_ppr=false
3688 $LCTL get_param $proc_osc0/rpc_stats |
3689 while read PPR RRPC RPCT RCUM BAR WRPC WPCT WCUM; do
3690 # skip lines until we are at the RPC histogram data
3691 [ "$PPR" == "pages" ] && have_ppr=true && continue
3692 $have_ppr || continue
3694 # we only want the percent stat for < 16 pages
3695 [[ $(echo $PPR | tr -d ':') -ge $pages ]] && break
3697 percent=$((percent + WPCT))
3698 if [[ $percent -gt 15 ]]; then
3699 error "less than 16-pages write RPCs" \
3706 run_test 42e "verify sub-RPC writes are not done synchronously"
3709 test_mkdir -p $DIR/$tdir
3710 cp -p /bin/ls $DIR/$tdir/$tfile
3711 $MULTIOP $DIR/$tdir/$tfile Ow_c &
3713 # give multiop a chance to open
3716 $DIR/$tdir/$tfile && error || true
3719 run_test 43 "execution of file opened for write should return -ETXTBSY"
3722 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3723 test_mkdir -p $DIR/$tdir
3724 cp -p `which $MULTIOP` $DIR/$tdir/multiop ||
3725 cp -p multiop $DIR/$tdir/multiop
3726 MULTIOP_PROG=$DIR/$tdir/multiop multiop_bg_pause $TMP/$tfile.junk O_c ||
3729 $MULTIOP $DIR/$tdir/multiop Oc && error "expected error, got success"
3730 kill -USR1 $MULTIOP_PID || return 2
3731 wait $MULTIOP_PID || return 3
3732 rm $TMP/$tfile.junk $DIR/$tdir/multiop
3734 run_test 43a "open(RDWR) of file being executed should return -ETXTBSY"
3737 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3738 test_mkdir -p $DIR/$tdir
3739 cp -p `which $MULTIOP` $DIR/$tdir/multiop ||
3740 cp -p multiop $DIR/$tdir/multiop
3741 MULTIOP_PROG=$DIR/$tdir/multiop multiop_bg_pause $TMP/$tfile.junk O_c ||
3744 $TRUNCATE $DIR/$tdir/multiop 0 && error "expected error, got success"
3745 kill -USR1 $MULTIOP_PID || return 2
3746 wait $MULTIOP_PID || return 3
3747 rm $TMP/$tfile.junk $DIR/$tdir/multiop
3749 run_test 43b "truncate of file being executed should return -ETXTBSY"
3752 local testdir="$DIR/$tdir"
3753 test_mkdir -p $DIR/$tdir
3755 ( cd $(dirname $SHELL) && md5sum $(basename $SHELL) ) | \
3756 ( cd $testdir && md5sum -c)
3758 run_test 43c "md5sum of copy into lustre========================"
3761 [[ $OSTCOUNT -lt 2 ]] && skip_env "skipping 2-stripe test" && return
3762 dd if=/dev/zero of=$DIR/f1 bs=4k count=1 seek=1023
3763 dd if=$DIR/f1 bs=4k count=1 > /dev/null
3765 run_test 44 "zero length read from a sparse stripe ============="
3768 local nstripe=$($LCTL lov_getconfig $DIR | grep default_stripe_count: |
3770 [ -z "$nstripe" ] && skip "can't get stripe info" && return
3771 [[ $nstripe -gt $OSTCOUNT ]] &&
3772 skip "Wrong default_stripe_count: $nstripe (OSTCOUNT: $OSTCOUNT)" &&
3774 local stride=$($LCTL lov_getconfig $DIR | grep default_stripe_size: |
3776 if [[ $nstripe -eq 0 || $nstripe -eq -1 ]]; then
3777 nstripe=$($LCTL lov_getconfig $DIR | grep obd_count: |
3781 OFFSETS="0 $((stride/2)) $((stride-1))"
3782 for offset in $OFFSETS; do
3783 for i in $(seq 0 $((nstripe-1))); do
3784 local GLOBALOFFSETS=""
3786 local size=$((((i + 2 * $nstripe )*$stride + $offset)))
3787 local myfn=$DIR/d44a-$size
3788 echo "--------writing $myfn at $size"
3789 ll_sparseness_write $myfn $size ||
3790 error "ll_sparseness_write"
3791 GLOBALOFFSETS="$GLOBALOFFSETS $size"
3792 ll_sparseness_verify $myfn $GLOBALOFFSETS ||
3793 error "ll_sparseness_verify $GLOBALOFFSETS"
3795 for j in $(seq 0 $((nstripe-1))); do
3797 size=$((((j + $nstripe )*$stride + $offset)))
3798 ll_sparseness_write $myfn $size ||
3799 error "ll_sparseness_write"
3800 GLOBALOFFSETS="$GLOBALOFFSETS $size"
3802 ll_sparseness_verify $myfn $GLOBALOFFSETS ||
3803 error "ll_sparseness_verify $GLOBALOFFSETS"
3808 run_test 44a "test sparse pwrite ==============================="
3812 for d in `lctl get_param -n osc.*.cur_dirty_bytes`; do
3818 before=`dirty_osc_total`
3819 echo executing "\"$*\""
3821 after=`dirty_osc_total`
3822 echo before $before, after $after
3825 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3827 # Obtain grants from OST if it supports it
3828 echo blah > ${f}_grant
3831 do_dirty_record "echo blah > $f"
3832 [[ $before -eq $after ]] && error "write wasn't cached"
3833 do_dirty_record "> $f"
3834 [[ $before -gt $after ]] || error "truncate didn't lower dirty count"
3835 do_dirty_record "echo blah > $f"
3836 [[ $before -eq $after ]] && error "write wasn't cached"
3837 do_dirty_record "sync"
3838 [[ $before -gt $after ]] || error "writeback didn't lower dirty count"
3839 do_dirty_record "echo blah > $f"
3840 [[ $before -eq $after ]] && error "write wasn't cached"
3841 do_dirty_record "cancel_lru_locks osc"
3842 [[ $before -gt $after ]] ||
3843 error "lock cancellation didn't lower dirty count"
3846 run_test 45 "osc io page accounting ============================"
3848 # in a 2 stripe file (lov.sh), page 1023 maps to page 511 in its object. this
3849 # test tickles a bug where re-dirtying a page was failing to be mapped to the
3850 # objects offset and an assert hit when an rpc was built with 1023's mapped
3851 # offset 511 and 511's raw 511 offset. it also found general redirtying bugs.
3853 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3857 dd if=/dev/zero of=$f bs=`page_size` seek=511 count=1
3859 dd conv=notrunc if=/dev/zero of=$f bs=`page_size` seek=1023 count=1
3860 dd conv=notrunc if=/dev/zero of=$f bs=`page_size` seek=511 count=1
3864 run_test 46 "dirtying a previously written page ================"
3866 # test_47 is removed "Device nodes check" is moved to test_28
3868 test_48a() { # bug 2399
3869 [ $(facet_fstype $SINGLEMDS) = "zfs" ] &&
3870 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.3.63) ] &&
3871 skip "MDS prior to 2.3.63 handle ZFS dir .. incorrectly" &&
3873 test_mkdir $DIR/$tdir
3875 mv $DIR/$tdir $DIR/$tdir.new || error "move directory failed"
3876 test_mkdir $DIR/$tdir || error "recreate directory failed"
3877 touch foo || error "'touch foo' failed after recreating cwd"
3878 test_mkdir bar || error "'mkdir foo' failed after recreating cwd"
3879 touch .foo || error "'touch .foo' failed after recreating cwd"
3880 test_mkdir .bar || error "'mkdir .foo' failed after recreating cwd"
3881 ls . > /dev/null || error "'ls .' failed after recreating cwd"
3882 ls .. > /dev/null || error "'ls ..' failed after removing cwd"
3883 cd . || error "'cd .' failed after recreating cwd"
3884 test_mkdir . && error "'mkdir .' worked after recreating cwd"
3885 rmdir . && error "'rmdir .' worked after recreating cwd"
3886 ln -s . baz || error "'ln -s .' failed after recreating cwd"
3887 cd .. || error "'cd ..' failed after recreating cwd"
3889 run_test 48a "Access renamed working dir (should return errors)="
3891 test_48b() { # bug 2399
3893 test_mkdir $DIR/$tdir
3895 rmdir $DIR/$tdir || error "remove cwd $DIR/$tdir failed"
3896 touch foo && error "'touch foo' worked after removing cwd"
3897 test_mkdir foo && error "'mkdir foo' worked after removing cwd"
3898 touch .foo && error "'touch .foo' worked after removing cwd"
3899 test_mkdir .foo && error "'mkdir .foo' worked after removing cwd"
3900 ls . > /dev/null && error "'ls .' worked after removing cwd"
3901 ls .. > /dev/null || error "'ls ..' failed after removing cwd"
3902 is_patchless || ( cd . && error "'cd .' worked after removing cwd" )
3903 test_mkdir . && error "'mkdir .' worked after removing cwd"
3904 rmdir . && error "'rmdir .' worked after removing cwd"
3905 ln -s . foo && error "'ln -s .' worked after removing cwd"
3906 cd .. || echo "'cd ..' failed after removing cwd `pwd`" #bug 3517
3908 run_test 48b "Access removed working dir (should return errors)="
3910 test_48c() { # bug 2350
3911 #lctl set_param debug=-1
3914 test_mkdir -p $DIR/$tdir/dir
3916 $TRACE rmdir $DIR/$tdir/dir || error "remove cwd $DIR/$tdir/dir failed"
3917 $TRACE touch foo && error "touch foo worked after removing cwd"
3918 $TRACE test_mkdir foo && error "'mkdir foo' worked after removing cwd"
3919 touch .foo && error "touch .foo worked after removing cwd"
3920 test_mkdir .foo && error "mkdir .foo worked after removing cwd"
3921 $TRACE ls . && error "'ls .' worked after removing cwd"
3922 $TRACE ls .. || error "'ls ..' failed after removing cwd"
3923 is_patchless || ( $TRACE cd . &&
3924 error "'cd .' worked after removing cwd" )
3925 $TRACE test_mkdir . && error "'mkdir .' worked after removing cwd"
3926 $TRACE rmdir . && error "'rmdir .' worked after removing cwd"
3927 $TRACE ln -s . foo && error "'ln -s .' worked after removing cwd"
3928 $TRACE cd .. || echo "'cd ..' failed after removing cwd `pwd`" #bug 3415
3930 run_test 48c "Access removed working subdir (should return errors)"
3932 test_48d() { # bug 2350
3933 #lctl set_param debug=-1
3936 test_mkdir -p $DIR/$tdir/dir
3938 $TRACE rmdir $DIR/$tdir/dir || error "remove cwd $DIR/$tdir/dir failed"
3939 $TRACE rmdir $DIR/$tdir || error "remove parent $DIR/$tdir failed"
3940 $TRACE touch foo && error "'touch foo' worked after removing parent"
3941 $TRACE test_mkdir foo && error "mkdir foo worked after removing parent"
3942 touch .foo && error "'touch .foo' worked after removing parent"
3943 test_mkdir .foo && error "mkdir .foo worked after removing parent"
3944 $TRACE ls . && error "'ls .' worked after removing parent"
3945 $TRACE ls .. && error "'ls ..' worked after removing parent"
3946 is_patchless || ( $TRACE cd . &&
3947 error "'cd .' worked after recreate parent" )
3948 $TRACE test_mkdir . && error "'mkdir .' worked after removing parent"
3949 $TRACE rmdir . && error "'rmdir .' worked after removing parent"
3950 $TRACE ln -s . foo && error "'ln -s .' worked after removing parent"
3951 is_patchless || ( $TRACE cd .. &&
3952 error "'cd ..' worked after removing parent" || true )
3954 run_test 48d "Access removed parent subdir (should return errors)"
3956 test_48e() { # bug 4134
3957 #lctl set_param debug=-1
3960 test_mkdir -p $DIR/$tdir/dir
3962 $TRACE rmdir $DIR/$tdir/dir || error "remove cwd $DIR/$tdir/dir failed"
3963 $TRACE rmdir $DIR/$tdir || error "remove parent $DIR/$tdir failed"
3964 $TRACE touch $DIR/$tdir || error "'touch $DIR/$tdir' failed"
3965 $TRACE chmod +x $DIR/$tdir || error "'chmod +x $DIR/$tdir' failed"
3966 # On a buggy kernel addition of "touch foo" after cd .. will
3967 # produce kernel oops in lookup_hash_it
3968 touch ../foo && error "'cd ..' worked after recreate parent"
3970 $TRACE rm $DIR/$tdir || error "rm '$DIR/$tdir' failed"
3972 run_test 48e "Access to recreated parent subdir (should return errors)"
3974 test_49() { # LU-1030
3975 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3976 # get ost1 size - lustre-OST0000
3977 ost1_size=$(do_facet ost1 $LFS df | grep ${ost1_svc} |
3979 # write 800M at maximum
3980 [[ $ost1_size -lt 2 ]] && ost1_size=2
3981 [[ $ost1_size -gt 819200 ]] && ost1_size=819200
3983 $SETSTRIPE -c 1 -i 0 $DIR/$tfile
3984 dd if=/dev/zero of=$DIR/$tfile bs=4k count=$((ost1_size >> 2)) &
3987 # change max_pages_per_rpc while writing the file
3988 local osc1_mppc=osc.$(get_osc_import_name client ost1).max_pages_per_rpc
3989 local orig_mppc=$($LCTL get_param -n $osc1_mppc)
3990 # loop until dd process exits
3991 while ps ax -opid | grep -wq $dd_pid; do
3992 $LCTL set_param $osc1_mppc=$((RANDOM % 256 + 1))
3993 sleep $((RANDOM % 5 + 1))
3995 # restore original max_pages_per_rpc
3996 $LCTL set_param $osc1_mppc=$orig_mppc
3997 rm $DIR/$tfile || error "rm $DIR/$tfile failed"
3999 run_test 49 "Change max_pages_per_rpc won't break osc extent"
4003 test_mkdir $DIR/$tdir
4005 ls /proc/$$/cwd || error "ls /proc/$$/cwd failed"
4007 run_test 50 "special situations: /proc symlinks ==============="
4009 test_51a() { # was test_51
4010 # bug 1516 - create an empty entry right after ".." then split dir
4011 test_mkdir -c1 $DIR/$tdir
4012 touch $DIR/$tdir/foo
4013 $MCREATE $DIR/$tdir/bar
4015 createmany -m $DIR/$tdir/longfile 201
4017 while [[ $(ls -sd $DIR/$tdir | awk '{ print $1 }') -eq 4 ]]; do
4018 $MCREATE $DIR/$tdir/longfile$FNUM
4023 ls -l $DIR/$tdir > /dev/null || error "ls -l $DIR/$tdir failed"
4025 run_test 51a "special situations: split htree with empty entry =="
4027 export NUMTEST=70000
4029 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4030 local BASE=$DIR/d${base}.${TESTSUITE}
4032 # cleanup the directory
4035 test_mkdir -p -c1 $BASE
4039 local mdtidx=$(printf "%04x" $($LFS getstripe -M $BASE))
4040 local numfree=$(lctl get_param -n mdc.$FSNAME-MDT$mdtidx*.filesfree)
4041 [[ $numfree -lt 21000 ]] &&
4042 skip "not enough free inodes ($numfree) on MDT$mdtidx" &&
4045 [[ $numfree -lt $NUMTEST ]] && NUMTEST=$(($numfree - 50)) &&
4046 echo "reduced count to $NUMTEST due to inodes on MDT$mdtidx"
4048 # need to check free space for the directories as well
4049 local blkfree=$(lctl get_param -n mdc.$FSNAME-MDT$mdtidx*.kbytesavail)
4050 numfree=$((blkfree / 4))
4051 [[ $numfree -lt $NUMTEST ]] && NUMTEST=$((numfree - 50)) &&
4052 echo "reduced count to $NUMTEST due to blocks on MDT$mdtidx"
4054 createmany -d $BASE/d $NUMTEST && echo $NUMTEST > $BASE/fnum ||
4058 echo "failed" > $BASE/fnum
4059 error "failed to create $NUMTEST subdirs in MDT$mdtidx:$BASE"
4062 run_test 51b "exceed 64k subdirectory nlink limit"
4064 test_51ba() { # LU-993
4065 local BASE=$DIR/d${base}.${TESTSUITE}
4066 # unlink all but 100 subdirectories, then check it still works
4068 [ -f $BASE/fnum ] && local NUMPREV=$(cat $BASE/fnum) && rm $BASE/fnum
4070 [ "$NUMPREV" != "failed" ] && NUMTEST=$NUMPREV
4071 local DELETE=$((NUMTEST - LEFT))
4073 # continue on to run this test even if 51b didn't finish,
4074 # just to delete the many subdirectories created.
4075 [ ! -d "${BASE}/d1" ] && skip "test_51b() not run" && return 0
4077 # for ldiskfs the nlink count should be 1, but this is OSD specific
4078 # and so this is listed for informational purposes only
4079 echo "nlink before: $(stat -c %h $BASE), created before: $NUMTEST"
4080 unlinkmany -d $BASE/d $DELETE
4083 if [ $RC -ne 0 ]; then
4084 if [ "$NUMPREV" == "failed" ]; then
4085 skip "previous setup failed"
4088 error "unlink of first $DELETE subdirs failed"
4093 echo "nlink between: $(stat -c %h $BASE)"
4094 # trim the first line of ls output
4095 local FOUND=$(($(ls -l ${BASE} | wc -l) - 1))
4096 [ $FOUND -ne $LEFT ] &&
4097 error "can't find subdirs: found only $FOUND/$LEFT"
4099 unlinkmany -d $BASE/d $DELETE $LEFT ||
4100 error "unlink of second $LEFT subdirs failed"
4101 # regardless of whether the backing filesystem tracks nlink accurately
4102 # or not, the nlink count shouldn't be more than "." and ".." here
4103 local AFTER=$(stat -c %h $BASE)
4104 [[ $AFTER -gt 2 ]] && error "nlink after: $AFTER > 2" ||
4105 echo "nlink after: $AFTER"
4107 run_test 51ba "verify nlink for many subdirectory cleanup"
4110 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4111 [[ $OSTCOUNT -lt 3 ]] &&
4112 skip_env "skipping test with few OSTs" && return
4113 test_mkdir -p $DIR/$tdir
4114 createmany -o $DIR/$tdir/t- 1000
4115 $GETSTRIPE $DIR/$tdir > $TMP/files
4116 for N in $(seq 0 $((OSTCOUNT - 1))); do
4117 OBJS[$N]=$(awk -vobjs=0 '($1 == '$N') { objs += 1 } \
4118 END { printf("%0.0f", objs) }' $TMP/files)
4119 OBJS0[$N]=$(grep -A 1 idx $TMP/files | awk -vobjs=0 \
4120 '($1 == '$N') { objs += 1 } \
4121 END { printf("%0.0f", objs) }')
4122 log "OST$N has ${OBJS[$N]} objects, ${OBJS0[$N]} are index 0"
4124 unlinkmany $DIR/$tdir/t- 1000
4127 for N in $(seq 1 $((OSTCOUNT - 1))); do
4128 [[ ${OBJS[$N]} -lt $((${OBJS[$NLAST]} - 20)) ]] &&
4129 error "OST $N has less objects vs OST $NLAST" \
4130 " (${OBJS[$N]} < ${OBJS[$NLAST]}"
4131 [[ ${OBJS[$N]} -gt $((${OBJS[$NLAST]} + 20)) ]] &&
4132 error "OST $N has less objects vs OST $NLAST" \
4133 " (${OBJS[$N]} < ${OBJS[$NLAST]}"
4135 [[ ${OBJS0[$N]} -lt $((${OBJS0[$NLAST]} - 20)) ]] &&
4136 error "OST $N has less #0 objects vs OST $NLAST" \
4137 " (${OBJS0[$N]} < ${OBJS0[$NLAST]}"
4138 [[ ${OBJS0[$N]} -gt $((${OBJS0[$NLAST]} + 20)) ]] &&
4139 error "OST $N has less #0 objects vs OST $NLAST" \
4140 " (${OBJS0[$N]} < ${OBJS0[$NLAST]}"
4144 run_test 51d "check object distribution ===================="
4147 if [ "$(facet_fstype $SINGLEMDS)" != ldiskfs ]; then
4148 skip "Only applicable to ldiskfs-based MDTs"
4152 test_mkdir -c1 $DIR/$tdir || error "create $tdir failed"
4153 test_mkdir -c1 $DIR/$tdir/d0 || error "create d0 failed"
4155 touch $DIR/$tdir/d0/foo
4156 createmany -l $DIR/$tdir/d0/foo $DIR/$tdir/d0/f- 65001 &&
4157 error "file exceed 65000 nlink limit!"
4158 unlinkmany $DIR/$tdir/d0/f- 65001
4161 run_test 51e "check file nlink limit"
4164 [ -f $DIR/$tdir/foo ] && chattr -a $DIR/$tdir/foo
4165 test_mkdir -p $DIR/$tdir
4166 touch $DIR/$tdir/foo
4167 chattr +a $DIR/$tdir/foo || error "chattr +a failed"
4168 echo bar >> $DIR/$tdir/foo || error "append bar failed"
4169 cp /etc/hosts $DIR/$tdir/foo && error "cp worked"
4170 rm -f $DIR/$tdir/foo 2>/dev/null && error "rm worked"
4171 link $DIR/$tdir/foo $DIR/$tdir/foo_link 2>/dev/null &&
4173 echo foo >> $DIR/$tdir/foo || error "append foo failed"
4174 mrename $DIR/$tdir/foo $DIR/$tdir/foo_ren && error "rename worked"
4175 lsattr $DIR/$tdir/foo | egrep -q "^-+a[-e]+ $DIR/$tdir/foo" ||
4177 chattr -a $DIR/$tdir/foo || error "chattr -a failed"
4178 cp -r $DIR/$tdir /tmp/
4179 rm -fr $DIR/$tdir || error "cleanup rm failed"
4181 run_test 52a "append-only flag test (should return errors) ====="
4184 [ -f $DIR/$tdir/foo ] && chattr -i $DIR/$tdir/foo
4185 test_mkdir -p $DIR/$tdir
4186 touch $DIR/$tdir/foo
4187 chattr +i $DIR/$tdir/foo || error "chattr +i failed"
4188 cat test > $DIR/$tdir/foo && error "cat test worked"
4189 cp /etc/hosts $DIR/$tdir/foo && error "cp worked"
4190 rm -f $DIR/$tdir/foo 2>/dev/null && error "rm worked"
4191 link $DIR/$tdir/foo $DIR/$tdir/foo_link 2>/dev/null &&
4193 echo foo >> $DIR/$tdir/foo && error "echo worked"
4194 mrename $DIR/$tdir/foo $DIR/$tdir/foo_ren && error "rename worked"
4195 [ -f $DIR/$tdir/foo ] || error "$tdir/foo is not a file"
4196 [ -f $DIR/$tdir/foo_ren ] && error "$tdir/foo_ren is not a file"
4197 lsattr $DIR/$tdir/foo | egrep -q "^-+i[-e]+ $DIR/$tdir/foo" ||
4199 chattr -i $DIR/$tdir/foo || error "chattr failed"
4201 rm -fr $DIR/$tdir || error "unable to remove $DIR/$tdir"
4203 run_test 52b "immutable flag test (should return errors) ======="
4206 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4207 remote_mds_nodsh && skip "remote MDS with nodsh" && return
4208 remote_ost_nodsh && skip "remote OST with nodsh" && return
4221 local support_last_seq=true
4223 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.3.60) ]] ||
4224 support_last_seq=false
4227 local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS)
4229 for value in $(do_facet $SINGLEMDS \
4230 $LCTL get_param osc.$mdtosc.prealloc_last_id) ; do
4231 param=$(echo ${value[0]} | cut -d "=" -f1)
4232 ostname=$(echo $param | cut -d "." -f2 | cut -d - -f 1-2)
4234 if $support_last_seq; then
4235 param_seq=$(echo $param |
4236 sed -e s/prealloc_last_id/prealloc_last_seq/g)
4237 mds_last_seq=$(do_facet $SINGLEMDS \
4238 $LCTL get_param -n $param_seq)
4240 mds_last=$(do_facet $SINGLEMDS $LCTL get_param -n $param)
4242 ostnum=$(index_from_ostuuid ${ostname}_UUID)
4243 node=$(facet_active_host ost$((ostnum+1)))
4244 param="obdfilter.$ostname.last_id"
4245 for ost_last in $(do_node $node $LCTL get_param -n $param) ; do
4246 echo "$ostname.last_id=$ost_last; MDS.last_id=$mds_last"
4247 ost_last_id=$ost_last
4249 if $support_last_seq; then
4250 ost_last_id=$(echo $ost_last |
4251 awk -F':' '{print $2}' |
4253 ost_last_seq=$(echo $ost_last |
4254 awk -F':' '{print $1}')
4255 [[ $ost_last_seq = $mds_last_seq ]] || continue
4258 if [[ $ost_last_id != $mds_last ]]; then
4259 error "$ost_last_id != $mds_last"
4266 $found || error "can not match last_seq/last_id for $mdtosc"
4269 run_test 53 "verify that MDS and OSTs agree on pre-creation ===="
4272 $SOCKETSERVER $DIR/socket ||
4273 error "$SOCKETSERVER $DIR/socket failed: $?"
4274 $SOCKETCLIENT $DIR/socket ||
4275 error "$SOCKETCLIENT $DIR/socket failed: $?"
4276 $MUNLINK $DIR/socket || error "$MUNLINK $DIR/socket failed: $?"
4278 run_test 54a "unix domain socket test =========================="
4284 dd if=/dev/zero of=$f bs=$(page_size) count=1
4286 run_test 54b "char device works in lustre ======================"
4289 [ -b /dev/loop/0 ] && LOOPBASE=/dev/loop/
4290 [ -b /dev/loop0 ] && LOOPBASE=/dev/loop
4291 [ -z "$LOOPBASE" ] && echo "/dev/loop/0 and /dev/loop0 gone?" && return
4293 for i in $(seq 3 7); do
4294 losetup $LOOPBASE$i > /dev/null 2>&1 && continue
4302 loopdev="$DIR/loop54c"
4305 $UMOUNT $DIR/$tdir || rc=$?
4306 losetup -d $loopdev || true
4307 losetup -d $LOOPDEV || true
4308 rm -rf $loopdev $DIR/$tfile $DIR/$tdir
4313 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4314 loopdev="$DIR/loop54c"
4317 [ -z "$LOOPNUM" ] && echo "couldn't find empty loop device" && return
4318 trap cleanup_54c EXIT
4319 mknod $loopdev b 7 $LOOPNUM
4320 echo "make a loop file system with $DIR/$tfile on $loopdev ($LOOPNUM)."
4321 dd if=/dev/zero of=$DIR/$tfile bs=$(get_page_size client) seek=1024 count=1 > /dev/null
4322 losetup $loopdev $DIR/$tfile ||
4323 error "can't set up $loopdev for $DIR/$tfile"
4324 mkfs.ext2 $loopdev || error "mke2fs on $loopdev"
4325 test_mkdir -p $DIR/$tdir
4326 mount -t ext2 $loopdev $DIR/$tdir ||
4327 error "error mounting $loopdev on $DIR/$tdir"
4328 dd if=/dev/zero of=$DIR/$tdir/tmp bs=$(get_page_size client) count=30 ||
4331 dd if=$DIR/$tdir/tmp of=/dev/zero bs=$(get_page_size client) count=30 ||
4335 run_test 54c "block device works in lustre ====================="
4341 [ "$string" = $(echo $string > $f | cat $f) ] || error "$f != $string"
4343 run_test 54d "fifo device works in lustre ======================"
4348 cp -aL /dev/console $f
4349 echo $string > $f || error "echo $string to $f failed"
4351 run_test 54e "console/tty device works in lustre ======================"
4353 #The test_55 used to be iopen test and it was removed by bz#24037.
4354 #run_test 55 "check iopen_connect_dentry() ======================"
4356 test_56a() { # was test_56
4359 test_mkdir -p $DIR/$tdir/dir
4361 NUMFILESx2=$(($NUMFILES * 2))
4362 for i in $(seq 1 $NUMFILES); do
4363 touch $DIR/$tdir/file$i
4364 touch $DIR/$tdir/dir/file$i
4367 # test lfs getstripe with --recursive
4368 FILENUM=$($GETSTRIPE --recursive $DIR/$tdir | grep -c obdidx)
4369 [[ $FILENUM -eq $NUMFILESx2 ]] ||
4370 error "$GETSTRIPE --recursive: found $FILENUM, not $NUMFILESx2"
4371 FILENUM=$($GETSTRIPE $DIR/$tdir | grep -c obdidx)
4372 [[ $FILENUM -eq $NUMFILES ]] ||
4373 error "$GETSTRIPE $DIR/$tdir: found $FILENUM, not $NUMFILES"
4374 echo "$GETSTRIPE --recursive passed."
4376 # test lfs getstripe with file instead of dir
4377 FILENUM=$($GETSTRIPE $DIR/$tdir/file1 | grep -c obdidx)
4378 [[ $FILENUM -eq 1 ]] ||
4379 error "$GETSTRIPE $DIR/$tdir/file1: found $FILENUM, not 1"
4380 echo "$GETSTRIPE file1 passed."
4382 #test lfs getstripe with --verbose
4383 [[ $($GETSTRIPE --verbose $DIR/$tdir |
4384 grep -c lmm_magic) -eq $NUMFILES ]] ||
4385 error "$GETSTRIPE --verbose $DIR/$tdir: want $NUMFILES"
4386 [[ $($GETSTRIPE $DIR/$tdir | grep -c lmm_magic) -eq 0 ]] ||
4387 rror "$GETSTRIPE $DIR/$tdir: showed lmm_magic"
4388 echo "$GETSTRIPE --verbose passed."
4390 #test lfs getstripe with --obd
4391 $GETSTRIPE --obd wrong_uuid $DIR/$tdir 2>&1 |
4392 grep -q "unknown obduuid" ||
4393 error "$GETSTRIPE --obd wrong_uuid should return error message"
4395 [[ $OSTCOUNT -lt 2 ]] &&
4396 skip_env "skipping other $GETSTRIPE --obd test" && return
4399 OBDUUID=$(ostuuid_from_index $OSTIDX)
4400 FILENUM=$($GETSTRIPE -ir $DIR/$tdir | grep "^$OSTIDX\$" | wc -l)
4401 FOUND=$($GETSTRIPE -r --obd $OBDUUID $DIR/$tdir | grep obdidx | wc -l)
4402 [[ $FOUND -eq $FILENUM ]] ||
4403 error "$GETSTRIPE --obd wrong: found $FOUND, expected $FILENUM"
4404 [[ $($GETSTRIPE -r -v --obd $OBDUUID $DIR/$tdir |
4405 sed '/^[ ]*'${OSTIDX}'[ ]/d' |
4406 sed -n '/^[ ]*[0-9][0-9]*[ ]/p' | wc -l) -eq 0 ]] ||
4407 error "$GETSTRIPE --obd: should not show file on other obd"
4408 echo "$GETSTRIPE --obd passed"
4410 run_test 56a "check $GETSTRIPE"
4415 local LOCAL_NUMFILES="$1"
4416 local LOCAL_NUMDIRS="$2"
4417 local MKDIR_PARAMS="$3"
4418 local DIR_STRIPE_PARAMS="$4"
4420 if [ ! -d "$TDIR" ] ; then
4421 test_mkdir -p $DIR_STRIPE_PARAMS $TDIR
4422 [ "$MKDIR_PARAMS" ] && $SETSTRIPE $MKDIR_PARAMS $TDIR
4423 for i in `seq 1 $LOCAL_NUMFILES` ; do
4426 for i in `seq 1 $LOCAL_NUMDIRS` ; do
4427 test_mkdir $DIR_STRIPE_PARAMS $TDIR/dir$i
4428 for j in `seq 1 $LOCAL_NUMFILES` ; do
4429 touch $TDIR/dir$i/file$j
4435 setup_56_special() {
4439 if [ ! -e "$TDIR/loop1b" ] ; then
4440 for i in `seq 1 $LOCAL_NUMFILES` ; do
4441 mknod $TDIR/loop${i}b b 7 $i
4442 mknod $TDIR/null${i}c c 1 3
4443 ln -s $TDIR/file1 $TDIR/link${i}l
4445 for i in `seq 1 $LOCAL_NUMDIRS` ; do
4446 mknod $TDIR/dir$i/loop${i}b b 7 $i
4447 mknod $TDIR/dir$i/null${i}c c 1 3
4448 ln -s $TDIR/dir$i/file1 $TDIR/dir$i/link${i}l
4457 setup_56 $NUMFILES $NUMDIRS
4459 EXPECTED=$(($NUMDIRS + 2))
4460 # test lfs find with -name
4461 for i in $(seq 1 $NUMFILES) ; do
4462 NUMS=$($LFIND -name "*$i" $TDIR | wc -l)
4463 [ $NUMS -eq $EXPECTED ] ||
4464 error "lfs find -name \"*$i\" $TDIR wrong: "\
4465 "found $NUMS, expected $EXPECTED"
4468 run_test 56g "check lfs find -name ============================="
4474 setup_56 $NUMFILES $NUMDIRS
4476 EXPECTED=$(((NUMDIRS + 1) * (NUMFILES - 1) + NUMFILES))
4477 # test lfs find with ! -name
4478 for i in $(seq 1 $NUMFILES) ; do
4479 NUMS=$($LFIND ! -name "*$i" $TDIR | wc -l)
4480 [ $NUMS -eq $EXPECTED ] ||
4481 error "lfs find ! -name \"*$i\" $TDIR wrong: "\
4482 "found $NUMS, expected $EXPECTED"
4485 run_test 56h "check lfs find ! -name ============================="
4489 test_mkdir -p $DIR/$tdir
4490 UUID=$(ostuuid_from_index 0 $DIR/$tdir)
4491 CMD="$LFIND -ost $UUID $DIR/$tdir"
4493 [ -z "$OUT" ] || error "\"$CMD\" returned directory '$OUT'"
4495 run_test 56i "check 'lfs find -ost UUID' skips directories ======="
4499 setup_56_special $NUMFILES $NUMDIRS
4501 EXPECTED=$((NUMDIRS + 1))
4502 CMD="$LFIND -type d $TDIR"
4503 NUMS=$($CMD | wc -l)
4504 [ $NUMS -eq $EXPECTED ] ||
4505 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4507 run_test 56j "check lfs find -type d ============================="
4511 setup_56_special $NUMFILES $NUMDIRS
4513 EXPECTED=$(((NUMDIRS + 1) * NUMFILES))
4514 CMD="$LFIND -type f $TDIR"
4515 NUMS=$($CMD | wc -l)
4516 [ $NUMS -eq $EXPECTED ] ||
4517 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4519 run_test 56k "check lfs find -type f ============================="
4523 setup_56_special $NUMFILES $NUMDIRS
4525 EXPECTED=$((NUMDIRS + NUMFILES))
4526 CMD="$LFIND -type b $TDIR"
4527 NUMS=$($CMD | wc -l)
4528 [ $NUMS -eq $EXPECTED ] ||
4529 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4531 run_test 56l "check lfs find -type b ============================="
4535 setup_56_special $NUMFILES $NUMDIRS
4537 EXPECTED=$((NUMDIRS + NUMFILES))
4538 CMD="$LFIND -type c $TDIR"
4539 NUMS=$($CMD | wc -l)
4540 [ $NUMS -eq $EXPECTED ] ||
4541 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4543 run_test 56m "check lfs find -type c ============================="
4547 setup_56_special $NUMFILES $NUMDIRS
4549 EXPECTED=$((NUMDIRS + NUMFILES))
4550 CMD="$LFIND -type l $TDIR"
4551 NUMS=$($CMD | wc -l)
4552 [ $NUMS -eq $EXPECTED ] ||
4553 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4555 run_test 56n "check lfs find -type l ============================="
4559 setup_56 $NUMFILES $NUMDIRS
4560 utime $TDIR/file1 > /dev/null || error "utime (1)"
4561 utime $TDIR/file2 > /dev/null || error "utime (2)"
4562 utime $TDIR/dir1 > /dev/null || error "utime (3)"
4563 utime $TDIR/dir2 > /dev/null || error "utime (4)"
4564 utime $TDIR/dir1/file1 > /dev/null || error "utime (5)"
4565 dd if=/dev/zero count=1 >> $TDIR/dir1/file1 && sync
4568 NUMS=`$LFIND -mtime +0 $TDIR | wc -l`
4569 [ $NUMS -eq $EXPECTED ] || \
4570 error "lfs find -mtime +0 $TDIR wrong: found $NUMS, expected $EXPECTED"
4573 CMD="$LFIND -mtime 0 $TDIR"
4574 NUMS=$($CMD | wc -l)
4575 [ $NUMS -eq $EXPECTED ] ||
4576 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4578 run_test 56o "check lfs find -mtime for old files =========================="
4581 [ $RUNAS_ID -eq $UID ] &&
4582 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
4585 setup_56 $NUMFILES $NUMDIRS
4587 chown $RUNAS_ID $TDIR/file* || error "chown $DIR/${tdir}g/file$i failed"
4589 CMD="$LFIND -uid $RUNAS_ID $TDIR"
4590 NUMS=$($CMD | wc -l)
4591 [ $NUMS -eq $EXPECTED ] || \
4592 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4594 EXPECTED=$(((NUMFILES + 1) * NUMDIRS + 1))
4595 CMD="$LFIND ! -uid $RUNAS_ID $TDIR"
4596 NUMS=$($CMD | wc -l)
4597 [ $NUMS -eq $EXPECTED ] || \
4598 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4600 run_test 56p "check lfs find -uid and ! -uid ==============================="
4603 [ $RUNAS_ID -eq $UID ] &&
4604 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
4607 setup_56 $NUMFILES $NUMDIRS
4609 chgrp $RUNAS_GID $TDIR/file* || error "chown $TDIR/file$i failed"
4612 CMD="$LFIND -gid $RUNAS_GID $TDIR"
4613 NUMS=$($CMD | wc -l)
4614 [ $NUMS -eq $EXPECTED ] ||
4615 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4617 EXPECTED=$(( ($NUMFILES+1) * $NUMDIRS + 1))
4618 CMD="$LFIND ! -gid $RUNAS_GID $TDIR"
4619 NUMS=$($CMD | wc -l)
4620 [ $NUMS -eq $EXPECTED ] ||
4621 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4623 run_test 56q "check lfs find -gid and ! -gid ==============================="
4627 setup_56 $NUMFILES $NUMDIRS
4630 CMD="$LFIND -size 0 -type f $TDIR"
4631 NUMS=$($CMD | wc -l)
4632 [ $NUMS -eq $EXPECTED ] ||
4633 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4635 CMD="$LFIND ! -size 0 -type f $TDIR"
4636 NUMS=$($CMD | wc -l)
4637 [ $NUMS -eq $EXPECTED ] ||
4638 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4639 echo "test" > $TDIR/$tfile
4640 echo "test2" > $TDIR/$tfile.2 && sync
4642 CMD="$LFIND -size 5 -type f $TDIR"
4643 NUMS=$($CMD | wc -l)
4644 [ $NUMS -eq $EXPECTED ] ||
4645 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4647 CMD="$LFIND -size +5 -type f $TDIR"
4648 NUMS=$($CMD | wc -l)
4649 [ $NUMS -eq $EXPECTED ] ||
4650 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4652 CMD="$LFIND -size +0 -type f $TDIR"
4653 NUMS=$($CMD | wc -l)
4654 [ $NUMS -eq $EXPECTED ] ||
4655 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4657 CMD="$LFIND ! -size -5 -type f $TDIR"
4658 NUMS=$($CMD | wc -l)
4659 [ $NUMS -eq $EXPECTED ] ||
4660 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4662 CMD="$LFIND -size -5 -type f $TDIR"
4663 NUMS=$($CMD | wc -l)
4664 [ $NUMS -eq $EXPECTED ] ||
4665 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4667 run_test 56r "check lfs find -size works =========================="
4669 test_56s() { # LU-611
4671 setup_56 $NUMFILES $NUMDIRS "-c $OSTCOUNT"
4673 if [[ $OSTCOUNT -gt 1 ]]; then
4674 $SETSTRIPE -c 1 $TDIR/$tfile.{0,1,2,3}
4678 ONESTRIPE=$(((NUMDIRS + 1) * NUMFILES))
4682 EXPECTED=$(((NUMDIRS + 1) * NUMFILES))
4683 CMD="$LFIND -stripe-count $OSTCOUNT -type f $TDIR"
4684 NUMS=$($CMD | wc -l)
4685 [ $NUMS -eq $EXPECTED ] || {
4687 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4690 EXPECTED=$(((NUMDIRS + 1) * NUMFILES + EXTRA))
4691 CMD="$LFIND -stripe-count +0 -type f $TDIR"
4692 NUMS=$($CMD | wc -l)
4693 [ $NUMS -eq $EXPECTED ] || {
4695 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4699 CMD="$LFIND -stripe-count 1 -type f $TDIR"
4700 NUMS=$($CMD | wc -l)
4701 [ $NUMS -eq $EXPECTED ] || {
4703 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4706 CMD="$LFIND -stripe-count -2 -type f $TDIR"
4707 NUMS=$($CMD | wc -l)
4708 [ $NUMS -eq $EXPECTED ] || {
4710 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4714 CMD="$LFIND -stripe-count $((OSTCOUNT + 1)) -type f $TDIR"
4715 NUMS=$($CMD | wc -l)
4716 [ $NUMS -eq $EXPECTED ] || {
4718 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4721 run_test 56s "check lfs find -stripe-count works"
4723 test_56t() { # LU-611
4725 setup_56 $NUMFILES $NUMDIRS "-s 512k"
4727 $SETSTRIPE -S 256k $TDIR/$tfile.{0,1,2,3}
4729 EXPECTED=$(((NUMDIRS + 1) * NUMFILES))
4730 CMD="$LFIND -stripe-size 512k -type f $TDIR"
4731 NUMS=$($CMD | wc -l)
4732 [ $NUMS -eq $EXPECTED ] ||
4733 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4735 CMD="$LFIND -stripe-size +320k -type f $TDIR"
4736 NUMS=$($CMD | wc -l)
4737 [ $NUMS -eq $EXPECTED ] ||
4738 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4740 EXPECTED=$(((NUMDIRS + 1) * NUMFILES + 4))
4741 CMD="$LFIND -stripe-size +200k -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 -640k -type f $TDIR"
4747 NUMS=$($CMD | wc -l)
4748 [ $NUMS -eq $EXPECTED ] ||
4749 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4752 CMD="$LFIND -stripe-size 256k -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 -320k -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 1024k -type f $TDIR"
4764 NUMS=$($CMD | wc -l)
4765 [ $NUMS -eq $EXPECTED ] ||
4766 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4768 run_test 56t "check lfs find -stripe-size works"
4770 test_56u() { # LU-611
4772 setup_56 $NUMFILES $NUMDIRS "-i 0"
4774 if [[ $OSTCOUNT -gt 1 ]]; then
4775 $SETSTRIPE -i 1 $TDIR/$tfile.{0,1,2,3}
4781 EXPECTED=$(((NUMDIRS + 1) * NUMFILES))
4782 CMD="$LFIND -stripe-index 0 -type f $TDIR"
4783 NUMS=$($CMD | wc -l)
4784 [ $NUMS -eq $EXPECTED ] ||
4785 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4788 CMD="$LFIND -stripe-index 1 -type f $TDIR"
4789 NUMS=$($CMD | wc -l)
4790 [ $NUMS -eq $EXPECTED ] ||
4791 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
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 # This should produce an error and not return any files
4800 CMD="$LFIND -stripe-index $OSTCOUNT -type f $TDIR"
4801 NUMS=$($CMD 2>/dev/null | wc -l)
4802 [ $NUMS -eq $EXPECTED ] ||
4803 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4805 if [[ $OSTCOUNT -gt 1 ]]; then
4806 EXPECTED=$(((NUMDIRS + 1) * NUMFILES + ONESTRIPE))
4807 CMD="$LFIND -stripe-index 0,1 -type f $TDIR"
4808 NUMS=$($CMD | wc -l)
4809 [ $NUMS -eq $EXPECTED ] ||
4810 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4813 run_test 56u "check lfs find -stripe-index works"
4820 setup_56 $NUMFILES $NUMDIRS
4822 UUID=$(mdtuuid_from_index $MDT_IDX $TDIR)
4823 [ -z "$UUID" ] && error "mdtuuid_from_index cannot find MDT index $MDT_IDX"
4825 for file in $($LFIND -mdt $UUID $TDIR); do
4826 file_mdt_idx=$($GETSTRIPE -M $file)
4827 [ $file_mdt_idx -eq $MDT_IDX ] ||
4828 error "'lfind -mdt $UUID' != 'getstripe -M' ($file_mdt_idx)"
4831 run_test 56v "check 'lfs find -mdt match with lfs getstripe -M' ======="
4834 [[ $OSTCOUNT -lt 2 ]] && skip_env "$OSTCOUNT < 2 OSTs -- skipping" &&
4836 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4839 rm -rf $TDIR || error "remove $TDIR failed"
4840 setup_56 $NUMFILES $NUMDIRS "-c $OSTCOUNT" "-c1"
4843 stripe_size=$($GETSTRIPE -S -d $TDIR) ||
4844 error "$GETSTRIPE -S -d $TDIR failed"
4845 stripe_size=${stripe_size%% *}
4847 local file_size=$((stripe_size * OSTCOUNT))
4848 local file_num=$((NUMDIRS * NUMFILES + NUMFILES))
4849 local required_space=$((file_num * file_size))
4850 local free_space=$($LCTL get_param -n lov.$LOVNAME.kbytesavail)
4851 [[ $free_space -le $((required_space / 1024)) ]] &&
4852 skip_env "need at least $required_space bytes free space," \
4853 "have $free_space kbytes" && return
4856 local dd_count=$((file_size / dd_bs))
4858 # write data into the files
4862 for i in $(seq 1 $NUMFILES); do
4864 yes | dd bs=$dd_bs count=$dd_count of=$file >/dev/null 2>&1 ||
4865 error "write data into $file failed"
4867 for i in $(seq 1 $NUMDIRS); do
4868 for j in $(seq 1 $NUMFILES); do
4869 file=$TDIR/dir$i/file$j
4870 yes | dd bs=$dd_bs count=$dd_count of=$file \
4872 error "write data into $file failed"
4877 [[ $OSTCOUNT -gt 1 ]] && expected=$((OSTCOUNT - 1))
4880 local cmd="$LFS_MIGRATE -y -c $expected $TDIR/file1"
4882 eval $cmd || error "$cmd failed"
4884 check_stripe_count $TDIR/file1 $expected
4886 if [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.6.90) ];
4888 # lfs_migrate file onto OST 0 if it is on OST 1, or onto
4889 # OST 1 if it is on OST 0. This file is small enough to
4890 # be on only one stripe.
4891 file=$TDIR/migr_1_ost
4892 dd bs=$dd_bs count=1 if=/dev/urandom of=$file >/dev/null 2>&1 ||
4893 error "write data into $file failed"
4894 local obdidx=$($LFS getstripe -i $file)
4895 local oldmd5=$(md5sum $file)
4897 [[ $obdidx -eq 0 ]] && newobdidx=1
4898 cmd="$LFS migrate -i $newobdidx $file"
4900 eval $cmd || error "$cmd failed"
4901 local realobdix=$($LFS getstripe -i $file)
4902 local newmd5=$(md5sum $file)
4903 [[ $newobdidx -ne $realobdix ]] &&
4904 error "new OST is different (was=$obdidx, wanted=$newobdidx, got=$realobdix)"
4905 [[ "$oldmd5" != "$newmd5" ]] &&
4906 error "md5sum differ: $oldmd5, $newmd5"
4910 cmd="$LFS_MIGRATE -y -c $expected $TDIR/dir1"
4912 eval $cmd || error "$cmd failed"
4914 for j in $(seq 1 $NUMFILES); do
4915 check_stripe_count $TDIR/dir1/file$j $expected
4918 # lfs_migrate works with lfs find
4919 cmd="$LFIND -stripe_count $OSTCOUNT -type f $TDIR |
4920 $LFS_MIGRATE -y -c $expected"
4922 eval $cmd || error "$cmd failed"
4924 for i in $(seq 2 $NUMFILES); do
4925 check_stripe_count $TDIR/file$i $expected
4927 for i in $(seq 2 $NUMDIRS); do
4928 for j in $(seq 1 $NUMFILES); do
4929 check_stripe_count $TDIR/dir$i/file$j $expected
4933 run_test 56w "check lfs_migrate -c stripe_count works"
4936 check_swap_layouts_support && return 0
4937 [[ $OSTCOUNT -lt 2 ]] &&
4938 skip_env "need 2 OST, skipping test" && return
4940 local dir0=$DIR/$tdir/$testnum
4941 test_mkdir -p $dir0 || error "creating dir $dir0"
4943 local ref1=/etc/passwd
4944 local file1=$dir0/file1
4946 $SETSTRIPE -c 2 $file1
4948 $LFS migrate -c 1 $file1 || error "migrate failed rc = $?"
4949 stripe=$($GETSTRIPE -c $file1)
4950 [[ $stripe == 1 ]] || error "stripe of $file1 is $stripe != 1"
4951 cmp $file1 $ref1 || error "content mismatch $file1 differs from $ref1"
4956 run_test 56x "lfs migration support"
4959 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.53) ] &&
4960 skip "No HSM $(lustre_build_version $SINGLEMDS) MDS < 2.4.53" &&
4964 local dir0=$DIR/$tdir/$testnum
4965 test_mkdir -p $dir0 || error "creating dir $dir0"
4966 local f1=$dir0/file1
4967 local f2=$dir0/file2
4969 touch $f1 || error "creating std file $f1"
4970 $MULTIOP $f2 H2c || error "creating released file $f2"
4972 # a directory can be raid0, so ask only for files
4973 res=$($LFIND $dir0 -L raid0 -type f | wc -l)
4974 [[ $res == 2 ]] || error "search raid0: found $res files != 2"
4976 res=$($LFIND $dir0 \! -L raid0 -type f | wc -l)
4977 [[ $res == 0 ]] || error "search !raid0: found $res files != 0"
4979 # only files can be released, so no need to force file search
4980 res=$($LFIND $dir0 -L released)
4981 [[ $res == $f2 ]] || error "search released: found $res != $f2"
4983 res=$($LFIND $dir0 \! -L released)
4984 [[ $res == $f1 ]] || error "search !released: found $res != $f1"
4987 run_test 56y "lfs find -L raid0|released"
4989 test_56z() { # LU-4824
4990 # This checks to make sure 'lfs find' continues after errors
4991 # There are two classes of errors that should be caught:
4992 # - If multiple paths are provided, all should be searched even if one
4994 # - If errors are encountered during the search, it should not terminate
4997 test_mkdir $DIR/$tdir
4998 for i in d{0..9}; do
4999 test_mkdir $DIR/$tdir/$i
5001 touch $DIR/$tdir/d{0..9}/$tfile
5002 $LFS find $DIR/non_existent_dir $DIR/$tdir &&
5003 error "$LFS find did not return an error"
5004 # Make a directory unsearchable. This should NOT be the last entry in
5005 # directory order. Arbitrarily pick the 6th entry
5006 chmod 700 $($LFS find $DIR/$tdir -type d | sed '6!d')
5007 local count=$($RUNAS $LFS find $DIR/non_existent $DIR/$tdir | wc -l)
5008 # The user should be able to see 10 directories and 9 files
5009 [ $count == 19 ] || error "$LFS find did not continue after error"
5011 run_test 56z "lfs find should continue after an error"
5013 test_56aa() { # LU-5937
5014 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
5017 $LFS setdirstripe -c$MDSCOUNT $DIR/$tdir/striped_dir
5019 createmany -o $DIR/$tdir/striped_dir/${tfile}- 1024
5020 local dirs=$(lfs find --size +8k $DIR/$tdir/)
5022 [ -n "$dirs" ] || error "lfs find --size wrong under striped dir"
5024 run_test 56aa "lfs find --size under striped dir"
5027 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5028 # note test will not do anything if MDS is not local
5029 if [ "$(facet_fstype $SINGLEMDS)" != ldiskfs ]; then
5030 skip "Only applicable to ldiskfs-based MDTs"
5034 remote_mds_nodsh && skip "remote MDS with nodsh" && return
5035 local MNTDEV="osd*.*MDT*.mntdev"
5036 DEV=$(do_facet $SINGLEMDS lctl get_param -n $MNTDEV)
5037 [ -z "$DEV" ] && error "can't access $MNTDEV"
5038 for DEV in $(do_facet $SINGLEMDS lctl get_param -n $MNTDEV); do
5039 do_facet $SINGLEMDS $DUMPE2FS -h $DEV > $TMP/t57a.dump ||
5040 error "can't access $DEV"
5041 DEVISIZE=$(awk '/Inode size:/ { print $3 }' $TMP/t57a.dump)
5042 [[ $DEVISIZE -gt 128 ]] || error "inode size $DEVISIZE"
5046 run_test 57a "verify MDS filesystem created with large inodes =="
5049 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5050 if [ "$(facet_fstype $SINGLEMDS)" != ldiskfs ]; then
5051 skip "Only applicable to ldiskfs-based MDTs"
5055 remote_mds_nodsh && skip "remote MDS with nodsh" && return
5056 local dir=$DIR/$tdir
5060 local FILEN=$dir/f$FILECOUNT
5062 rm -rf $dir || error "removing $dir"
5063 test_mkdir -p -c1 $dir || error "creating $dir"
5064 local mdtidx=$($LFS getstripe -M $dir)
5065 local mdtname=MDT$(printf %04x $mdtidx)
5066 local facet=mds$((mdtidx + 1))
5068 echo "mcreating $FILECOUNT files"
5069 createmany -m $dir/f 1 $FILECOUNT || \
5070 error "creating files in $dir"
5072 # verify that files do not have EAs yet
5073 $GETSTRIPE $FILE1 2>&1 | grep -q "no stripe" || error "$FILE1 has an EA"
5074 $GETSTRIPE $FILEN 2>&1 | grep -q "no stripe" || error "$FILEN has an EA"
5078 df $dir #make sure we get new statfs data
5079 local MDSFREE=$(do_facet $facet \
5080 lctl get_param -n osd*.*$mdtname.kbytesfree)
5081 local MDCFREE=$(lctl get_param -n mdc.*$mdtname-mdc-*.kbytesfree)
5082 echo "opening files to create objects/EAs"
5084 for FILE in `seq -f $dir/f%g 1 $FILECOUNT`; do
5085 $OPENFILE -f O_RDWR $FILE > /dev/null 2>&1 || error "opening $FILE"
5088 # verify that files have EAs now
5089 $GETSTRIPE $FILE1 | grep -q "obdidx" || error "$FILE1 missing EA"
5090 $GETSTRIPE $FILEN | grep -q "obdidx" || error "$FILEN missing EA"
5092 sleep 1 #make sure we get new statfs data
5094 local MDSFREE2=$(do_facet $facet \
5095 lctl get_param -n osd*.*$mdtname.kbytesfree)
5096 local MDCFREE2=$(lctl get_param -n mdc.*$mdtname-mdc-*.kbytesfree)
5097 if [[ $MDCFREE2 -lt $((MDCFREE - 16)) ]]; then
5098 if [ "$MDSFREE" != "$MDSFREE2" ]; then
5099 error "MDC before $MDCFREE != after $MDCFREE2"
5101 echo "MDC before $MDCFREE != after $MDCFREE2"
5102 echo "unable to confirm if MDS has large inodes"
5107 run_test 57b "default LOV EAs are stored inside large inodes ==="
5110 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5111 [ -z "$(which wiretest 2>/dev/null)" ] &&
5112 skip_env "could not find wiretest" && return
5115 run_test 58 "verify cross-platform wire constants =============="
5118 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5119 echo "touch 130 files"
5120 createmany -o $DIR/f59- 130
5122 unlinkmany $DIR/f59- 130
5124 # wait for commitment of removal
5125 wait_delete_completed
5127 run_test 59 "verify cancellation of llog records async ========="
5129 TEST60_HEAD="test_60 run $RANDOM"
5131 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5132 remote_mgs_nodsh && skip "remote MGS with nodsh" && return
5133 do_facet mgs "! which run-llog.sh &> /dev/null" &&
5134 do_facet mgs "! ls run-llog.sh &> /dev/null" &&
5135 skip_env "missing subtest run-llog.sh" && return
5137 log "$TEST60_HEAD - from kernel mode"
5138 do_facet mgs "$LCTL set_param debug=warning; $LCTL dk > /dev/null"
5139 do_facet mgs sh run-llog.sh
5140 do_facet mgs $LCTL dk > $TMP/$tfile
5142 # LU-6388: test llog_reader
5143 local llog_reader=$(do_facet mgs "which llog_reader 2> /dev/null")
5144 llog_reader=${llog_reader:-$LUSTRE/utils/llog_reader}
5145 [ -z $(do_facet mgs ls -d $llog_reader 2> /dev/null) ] &&
5146 skip_env "missing llog_reader" && return
5147 local fstype=$(facet_fstype mgs)
5148 [ $fstype != ldiskfs -a $fstype != zfs ] &&
5149 skip_env "Only for ldiskfs or zfs type mgs" && return
5151 local mntpt=$(facet_mntpt mgs)
5152 local mgsdev=$(mgsdevname 1)
5164 #get fid and record list
5165 fid_list=($(awk '/9_sub.*record/ { print $NF }' /$TMP/$tfile |
5167 rec_list=($(awk '/9_sub.*record/ { print $((NF-3)) }' /$TMP/$tfile |
5169 #remount mgs as ldiskfs or zfs type
5170 stop mgs || error "stop mgs failed"
5171 mount_fstype mgs || error "remount mgs failed"
5172 for ((i = 0; i < ${#fid_list[@]}; i++)); do
5175 seq=$(echo $fid | awk -F ':' '{ print $1 }' | sed -e "s/^0x//g")
5176 oid=$(echo $fid | awk -F ':' '{ print $2 }' | sed -e "s/^0x//g")
5181 obj_file=$mntpt/O/$seq/d$((oid%32))/$oid ;;
5183 obj_file=$mntpt/oi.$(($((16#$seq))&127))/$fid ;;
5185 echo "obj_file is $obj_file"
5186 do_facet mgs $llog_reader $obj_file
5188 rec_type=$(do_facet mgs $llog_reader $obj_file | grep "type=" |
5189 awk '{ print $3 }' | sed -e "s/^type=//g")
5190 if [ $rec_type != $rec ]; then
5191 echo "FAILED test_60a wrong record type $rec_type," \
5197 #check obj path if record type is LLOG_LOGID_MAGIC
5198 if [ "$rec" == "1064553b" ]; then
5199 path=$(do_facet mgs $llog_reader $obj_file |
5200 grep "path=" | awk '{ print $NF }' |
5201 sed -e "s/^path=//g")
5202 if [ $obj_file != $mntpt/$path ]; then
5203 echo "FAILED test_60a wrong obj path" \
5204 "$montpt/$path, should be $obj_file"
5211 #restart mgs before "error", otherwise it will block the next test
5212 stop mgs || error "stop mgs failed"
5213 start mgs $(mgsdevname) $MGS_MOUNT_OPTS || error "start mgs failed"
5214 $pass || error "test failed, see FAILED test_60a messages for specifics"
5216 run_test 60a "llog_test run from kernel module and test llog_reader =========="
5218 test_60b() { # bug 6411
5219 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5221 LLOG_COUNT=`dmesg | awk "/$TEST60_HEAD/{marker = 1; from_marker = 0;}
5233 [[ $LLOG_COUNT -gt 50 ]] &&
5234 error "CDEBUG_LIMIT not limiting messages ($LLOG_COUNT)" || true
5236 run_test 60b "limit repeated messages from CERROR/CWARN ========"
5239 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5240 echo "create 5000 files"
5241 createmany -o $DIR/f60c- 5000
5242 #define OBD_FAIL_MDS_LLOG_CREATE_FAILED 0x137
5243 lctl set_param fail_loc=0x80000137
5244 unlinkmany $DIR/f60c- 5000
5245 lctl set_param fail_loc=0
5247 run_test 60c "unlink file when mds full"
5250 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5251 SAVEPRINTK=$(lctl get_param -n printk)
5253 # verify "lctl mark" is even working"
5254 MESSAGE="test message ID $RANDOM $$"
5255 $LCTL mark "$MESSAGE" || error "$LCTL mark failed"
5256 dmesg | grep -q "$MESSAGE" || error "didn't find debug marker in log"
5258 lctl set_param printk=0 || error "set lnet.printk failed"
5259 lctl get_param -n printk | grep emerg || error "lnet.printk dropped emerg"
5260 MESSAGE="new test message ID $RANDOM $$"
5261 # Assume here that libcfs_debug_mark_buffer() uses D_WARNING
5262 $LCTL mark "$MESSAGE" || error "$LCTL mark failed"
5263 dmesg | grep -q "$MESSAGE" && error "D_WARNING wasn't masked" || true
5265 lctl set_param -n printk="$SAVEPRINTK"
5267 run_test 60d "test printk console message masking"
5270 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5272 #define OBD_FAIL_MDS_LLOG_CREATE_FAILED2 0x15b
5273 do_facet mds1 lctl set_param fail_loc=0x15b
5276 run_test 60e "no space while new llog is being created"
5279 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5281 dd if=/dev/zero of=$f bs=$(page_size) count=1 || error "dd $f failed"
5282 cancel_lru_locks osc
5283 $MULTIOP $f OSMWUc || error "$MULTIOP $f failed"
5286 run_test 61 "mmap() writes don't make sync hang ================"
5288 # bug 2330 - insufficient obd_match error checking causes LBUG
5290 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5293 cancel_lru_locks osc
5294 lctl set_param fail_loc=0x405
5295 cat $f && error "cat succeeded, expect -EIO"
5296 lctl set_param fail_loc=0
5298 # This test is now irrelevant (as of bug 10718 inclusion), we no longer
5299 # match every page all of the time.
5300 #run_test 62 "verify obd_match failure doesn't LBUG (should -EIO)"
5302 # bug 2319 - oig_wait() interrupted causes crash because of invalid waitq.
5303 # Though this test is irrelevant anymore, it helped to reveal some
5304 # other grant bugs (LU-4482), let's keep it.
5305 test_63a() { # was test_63
5306 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5307 MAX_DIRTY_MB=`lctl get_param -n osc.*.max_dirty_mb | head -n 1`
5308 for i in `seq 10` ; do
5309 dd if=/dev/zero of=$DIR/f63 bs=8k &
5315 rm -f $DIR/f63 || true
5317 run_test 63a "Verify oig_wait interruption does not crash ======="
5319 # bug 2248 - async write errors didn't return to application on sync
5320 # bug 3677 - async write errors left page locked
5322 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5324 lctl set_param debug=-1
5326 # ensure we have a grant to do async writes
5327 dd if=/dev/zero of=$DIR/$tfile bs=4k count=1
5330 sync # sync lest earlier test intercept the fail_loc
5332 #define OBD_FAIL_OSC_BRW_PREP_REQ 0x406
5333 lctl set_param fail_loc=0x80000406
5334 $MULTIOP $DIR/$tfile Owy && \
5335 error "sync didn't return ENOMEM"
5336 sync; sleep 2; sync # do a real sync this time to flush page
5337 lctl get_param -n llite.*.dump_page_cache | grep locked && \
5338 error "locked page left in cache after async error" || true
5341 run_test 63b "async write errors should be returned to fsync ==="
5344 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5346 lctl get_param -n osc.*[oO][sS][cC][_-]*.cur* | grep "[0-9]"
5348 run_test 64a "verify filter grant calculations (in kernel) ====="
5351 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5352 sh oos.sh $MOUNT || error "oos.sh failed: $?"
5354 run_test 64b "check out-of-space detection on client ==========="
5357 $LCTL set_param osc.*OST0000-osc-[^mM]*.cur_grant_bytes=0
5359 run_test 64c "verify grant shrink ========================------"
5361 # bug 1414 - set/get directories' stripe info
5363 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5364 test_mkdir -p $DIR/$tdir
5366 $LVERIFY $DIR/$tdir $DIR/$tdir/f1 || error "lverify failed"
5368 run_test 65a "directory with no stripe info ===================="
5371 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5372 test_mkdir -p $DIR/$tdir
5373 $SETSTRIPE -S $((STRIPESIZE * 2)) -i 0 -c 1 $DIR/$tdir ||
5376 $LVERIFY $DIR/$tdir $DIR/$tdir/f2 || error "lverify failed"
5378 run_test 65b "directory setstripe -S $((STRIPESIZE * 2)) -i 0 -c 1"
5381 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5382 if [[ $OSTCOUNT -gt 1 ]]; then
5383 test_mkdir -p $DIR/$tdir
5384 $SETSTRIPE -S $(($STRIPESIZE * 4)) -i 1 \
5385 -c $(($OSTCOUNT - 1)) $DIR/$tdir || error "setstripe"
5387 $LVERIFY $DIR/$tdir $DIR/$tdir/f3 || error "lverify failed"
5390 run_test 65c "directory setstripe -S $((STRIPESIZE*4)) -i 1 -c $((OSTCOUNT-1))"
5393 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5394 test_mkdir -p $DIR/$tdir
5395 if [[ $STRIPECOUNT -le 0 ]]; then
5397 elif [[ $STRIPECOUNT -gt 2000 ]]; then
5398 #LOV_MAX_STRIPE_COUNT is 2000
5399 [[ $OSTCOUNT -gt 2000 ]] && sc=2000 || sc=$(($OSTCOUNT - 1))
5401 sc=$(($STRIPECOUNT - 1))
5403 $SETSTRIPE -S $STRIPESIZE -c $sc $DIR/$tdir || error "setstripe"
5404 touch $DIR/$tdir/f4 $DIR/$tdir/f5
5405 $LVERIFY $DIR/$tdir $DIR/$tdir/f4 $DIR/$tdir/f5 ||
5406 error "lverify failed"
5408 run_test 65d "directory setstripe -S $STRIPESIZE -c stripe_count"
5411 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5412 test_mkdir -p $DIR/$tdir
5414 $SETSTRIPE $DIR/$tdir || error "setstripe"
5415 $GETSTRIPE -v $DIR/$tdir | grep "Default" ||
5416 error "no stripe info failed"
5418 $LVERIFY $DIR/$tdir $DIR/$tdir/f6 || error "lverify failed"
5420 run_test 65e "directory setstripe defaults ======================="
5423 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5424 test_mkdir -p $DIR/${tdir}f
5425 $RUNAS $SETSTRIPE $DIR/${tdir}f && error "setstripe succeeded" || true
5427 run_test 65f "dir setstripe permission (should return error) ==="
5430 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5431 test_mkdir -p $DIR/$tdir
5432 $SETSTRIPE -S $((STRIPESIZE * 2)) -i 0 -c 1 $DIR/$tdir ||
5434 $SETSTRIPE -d $DIR/$tdir || error "setstripe"
5435 $GETSTRIPE -v $DIR/$tdir | grep "Default" ||
5436 error "delete default stripe failed"
5438 run_test 65g "directory setstripe -d ==========================="
5441 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5442 test_mkdir -p $DIR/$tdir
5443 $SETSTRIPE -S $((STRIPESIZE * 2)) -i 0 -c 1 $DIR/$tdir ||
5445 test_mkdir -p $DIR/$tdir/dd1
5446 [ $($GETSTRIPE -c $DIR/$tdir) == $($GETSTRIPE -c $DIR/$tdir/dd1) ] ||
5447 error "stripe info inherit failed"
5449 run_test 65h "directory stripe info inherit ===================="
5451 test_65i() { # bug6367
5452 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5453 $SETSTRIPE -S 65536 -c -1 $MOUNT
5455 run_test 65i "set non-default striping on root directory (bug 6367)="
5457 test_65ia() { # bug12836
5458 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5459 $GETSTRIPE $MOUNT || error "getstripe $MOUNT failed"
5461 run_test 65ia "getstripe on -1 default directory striping"
5463 test_65ib() { # bug12836
5464 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5465 $GETSTRIPE -v $MOUNT || error "getstripe -v $MOUNT failed"
5467 run_test 65ib "getstripe -v on -1 default directory striping"
5469 test_65ic() { # bug12836
5470 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5471 $LFS find -mtime -1 $MOUNT > /dev/null || error "find $MOUNT failed"
5473 run_test 65ic "new find on -1 default directory striping"
5475 test_65j() { # bug6367
5476 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5478 # if we aren't already remounting for each test, do so for this test
5479 if [ "$CLEANUP" = ":" -a "$I_MOUNTED" = "yes" ]; then
5480 cleanup || error "failed to unmount"
5483 $SETSTRIPE -d $MOUNT || error "setstripe failed"
5485 run_test 65j "set default striping on root directory (bug 6367)="
5487 test_65k() { # bug11679
5488 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5489 [[ $OSTCOUNT -lt 2 ]] && skip_env "too few OSTs" && return
5490 remote_mds_nodsh && skip "remote MDS with nodsh" && return
5492 echo "Check OST status: "
5493 local MDS_OSCS=`do_facet $SINGLEMDS lctl dl |
5494 awk '/[oO][sS][cC].*md[ts]/ { print $4 }'`
5496 for OSC in $MDS_OSCS; do
5497 echo $OSC "is activate"
5498 do_facet $SINGLEMDS lctl --device %$OSC activate
5502 for INACTIVE_OSC in $MDS_OSCS; do
5503 echo "Deactivate: " $INACTIVE_OSC
5504 do_facet $SINGLEMDS lctl --device %$INACTIVE_OSC deactivate
5505 for STRIPE_OSC in $MDS_OSCS; do
5506 OST=`osc_to_ost $STRIPE_OSC`
5507 IDX=`do_facet $SINGLEMDS lctl get_param -n lov.*md*.target_obd |
5508 awk -F: /$OST/'{ print $1 }' | head -n 1`
5510 [ -f $DIR/$tdir/$IDX ] && continue
5511 echo "$SETSTRIPE -i $IDX -c 1 $DIR/$tdir/$IDX"
5512 $SETSTRIPE -i $IDX -c 1 $DIR/$tdir/$IDX
5514 [ $RC -ne 0 ] && error "setstripe should have succeeded"
5517 echo $INACTIVE_OSC "is Activate."
5518 do_facet $SINGLEMDS lctl --device %$INACTIVE_OSC activate
5521 run_test 65k "validate manual striping works properly with deactivated OSCs"
5523 test_65l() { # bug 12836
5524 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5525 test_mkdir -p $DIR/$tdir/test_dir
5526 $SETSTRIPE -c -1 $DIR/$tdir/test_dir
5527 $LFS find -mtime -1 $DIR/$tdir >/dev/null
5529 run_test 65l "lfs find on -1 stripe dir ========================"
5531 # bug 2543 - update blocks count on client
5533 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5535 dd if=/dev/zero of=$DIR/f66 bs=1k count=$COUNT
5536 sync; sync_all_data; sync; sync_all_data
5537 cancel_lru_locks osc
5538 BLOCKS=`ls -s $DIR/f66 | awk '{ print $1 }'`
5539 [ $BLOCKS -ge $COUNT ] || error "$DIR/f66 blocks $BLOCKS < $COUNT"
5541 run_test 66 "update inode blocks count on client ==============="
5546 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5548 if [ ! -z "$LLOOP" ]; then
5549 if swapon -s | grep -q $LLOOP; then
5550 swapoff $LLOOP || error "swapoff failed"
5553 $LCTL blockdev_detach $LLOOP || error "detach failed"
5557 if [ ! -z "$LLITELOOPLOAD" ]; then
5565 awk '($1 == "'$1':") { print $2 }' /proc/meminfo
5569 swapon -s | awk '($1 == "'$1'") { print $4 }'
5572 # test case for lloop driver, basic function
5574 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5575 [ "$UID" != 0 ] && skip_env "must run as root" && return
5576 llite_lloop_enabled || \
5577 { skip_env "llite_lloop module disabled" && return; }
5579 trap cleanup_68 EXIT
5581 if ! module_loaded llite_lloop; then
5582 if load_module llite/llite_lloop; then
5585 skip_env "can't find module llite_lloop"
5590 LLOOP=$TMP/lloop.`date +%s`.`date +%N`
5591 dd if=/dev/zero of=$DIR/f68a bs=4k count=1024
5592 $LCTL blockdev_attach $DIR/f68a $LLOOP || error "attach failed"
5594 directio rdwr $LLOOP 0 1024 4096 || error "direct write failed"
5595 directio rdwr $LLOOP 0 1025 4096 && error "direct write should fail"
5599 run_test 68a "lloop driver - basic test ========================"
5601 # excercise swapping to lustre by adding a high priority swapfile entry
5602 # and then consuming memory until it is used.
5603 test_68b() { # was test_68
5604 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5605 [ "$UID" != 0 ] && skip_env "must run as root" && return
5606 lctl get_param -n devices | grep -q obdfilter && \
5607 skip "local OST" && return
5609 grep -q llite_lloop /proc/modules
5610 [ $? -ne 0 ] && skip "can't find module llite_lloop" && return
5612 [ -z "`$LCTL list_nids | grep -v tcp`" ] && \
5613 skip "can't reliably test swap with TCP" && return
5615 MEMTOTAL=`meminfo MemTotal`
5616 NR_BLOCKS=$((MEMTOTAL>>8))
5617 [[ $NR_BLOCKS -le 2048 ]] && NR_BLOCKS=2048
5619 LLOOP=$TMP/lloop.`date +%s`.`date +%N`
5620 dd if=/dev/zero of=$DIR/f68b bs=64k seek=$NR_BLOCKS count=1
5623 $LCTL blockdev_attach $DIR/f68b $LLOOP || error "attach failed"
5625 trap cleanup_68 EXIT
5627 swapon -p 32767 $LLOOP || error "swapon $LLOOP failed"
5629 echo "before: `swapon -s | grep $LLOOP`"
5630 $MEMHOG $MEMTOTAL || error "error allocating $MEMTOTAL kB"
5631 echo "after: `swapon -s | grep $LLOOP`"
5632 SWAPUSED=`swap_used $LLOOP`
5636 [ $SWAPUSED -eq 0 ] && echo "no swap used???" || true
5638 run_test 68b "support swapping to Lustre ========================"
5640 # bug5265, obdfilter oa2dentry return -ENOENT
5641 # #define OBD_FAIL_SRV_ENOENT 0x217
5643 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5644 remote_ost_nodsh && skip "remote OST with nodsh" && return
5647 $SETSTRIPE -c 1 -i 0 $f
5649 $DIRECTIO write ${f}.2 0 1 || error "directio write error"
5651 do_facet ost1 lctl set_param fail_loc=0x217
5652 $TRUNCATE $f 1 # vmtruncate() will ignore truncate() error.
5653 $DIRECTIO write $f 0 2 && error "write succeeded, expect -ENOENT"
5655 do_facet ost1 lctl set_param fail_loc=0
5656 $DIRECTIO write $f 0 2 || error "write error"
5658 cancel_lru_locks osc
5659 $DIRECTIO read $f 0 1 || error "read error"
5661 do_facet ost1 lctl set_param fail_loc=0x217
5662 $DIRECTIO read $f 1 1 && error "read succeeded, expect -ENOENT"
5664 do_facet ost1 lctl set_param fail_loc=0
5667 run_test 69 "verify oa2dentry return -ENOENT doesn't LBUG ======"
5670 test_mkdir -p $DIR/$tdir
5671 $LFS setdirstripe -D -c$MDSCOUNT $DIR/$tdir
5672 sh rundbench -C -D $DIR/$tdir 2 || error "dbench failed!"
5674 run_test 71 "Running dbench on lustre (don't segment fault) ===="
5676 test_72a() { # bug 5695 - Test that on 2.6 remove_suid works properly
5677 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5678 [ "$RUNAS_ID" = "$UID" ] &&
5679 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
5681 # Check that testing environment is properly set up. Skip if not
5682 FAIL_ON_ERROR=false check_runas_id_ret $RUNAS_ID $RUNAS_GID $RUNAS || {
5683 skip_env "User $RUNAS_ID does not exist - skipping"
5687 chmod 777 $DIR/$tfile
5688 chmod ug+s $DIR/$tfile
5689 $RUNAS dd if=/dev/zero of=$DIR/$tfile bs=512 count=1 ||
5690 error "$RUNAS dd $DIR/$tfile failed"
5691 # See if we are still setuid/sgid
5692 test -u $DIR/$tfile -o -g $DIR/$tfile &&
5693 error "S/gid is not dropped on write"
5694 # Now test that MDS is updated too
5695 cancel_lru_locks mdc
5696 test -u $DIR/$tfile -o -g $DIR/$tfile &&
5697 error "S/gid is not dropped on MDS"
5700 run_test 72a "Test that remove suid works properly (bug5695) ===="
5702 test_72b() { # bug 24226 -- keep mode setting when size is not changing
5705 [ "$RUNAS_ID" = "$UID" ] && \
5706 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
5707 [ "$RUNAS_ID" -eq 0 ] && \
5708 skip_env "RUNAS_ID = 0 -- skipping" && return
5710 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5711 # Check that testing environment is properly set up. Skip if not
5712 FAIL_ON_ERROR=false check_runas_id_ret $RUNAS_ID $RUNAS_ID $RUNAS || {
5713 skip_env "User $RUNAS_ID does not exist - skipping"
5716 touch $DIR/${tfile}-f{g,u}
5717 test_mkdir $DIR/${tfile}-dg
5718 test_mkdir $DIR/${tfile}-du
5719 chmod 770 $DIR/${tfile}-{f,d}{g,u}
5720 chmod g+s $DIR/${tfile}-{f,d}g
5721 chmod u+s $DIR/${tfile}-{f,d}u
5722 for perm in 777 2777 4777; do
5723 $RUNAS chmod $perm $DIR/${tfile}-fg && error "S/gid file allowed improper chmod to $perm"
5724 $RUNAS chmod $perm $DIR/${tfile}-fu && error "S/uid file allowed improper chmod to $perm"
5725 $RUNAS chmod $perm $DIR/${tfile}-dg && error "S/gid dir allowed improper chmod to $perm"
5726 $RUNAS chmod $perm $DIR/${tfile}-du && error "S/uid dir allowed improper chmod to $perm"
5730 run_test 72b "Test that we keep mode setting if without file data changed (bug 24226)"
5732 # bug 3462 - multiple simultaneous MDC requests
5734 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5735 test_mkdir $DIR/d73-1
5736 test_mkdir $DIR/d73-2
5737 multiop_bg_pause $DIR/d73-1/f73-1 O_c || return 1
5740 lctl set_param fail_loc=0x80000129
5741 $MULTIOP $DIR/d73-1/f73-2 Oc &
5743 lctl set_param fail_loc=0
5745 $MULTIOP $DIR/d73-2/f73-3 Oc &
5749 wait $pid1 || return 1
5753 $CHECKSTAT -t file $DIR/d73-1/f73-1 || return 4
5754 $CHECKSTAT -t file $DIR/d73-1/f73-2 || return 5
5755 $CHECKSTAT -t file $DIR/d73-2/f73-3 || return 6
5759 run_test 73 "multiple MDC requests (should not deadlock)"
5761 test_74a() { # bug 6149, 6184
5762 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5763 #define OBD_FAIL_LDLM_ENQUEUE_OLD_EXPORT 0x30e
5765 # very important to OR with OBD_FAIL_ONCE (0x80000000) -- otherwise it
5766 # will spin in a tight reconnection loop
5768 $LCTL set_param fail_loc=0x8000030e
5769 # get any lock that won't be difficult - lookup works.
5771 $LCTL set_param fail_loc=0
5775 run_test 74a "ldlm_enqueue freed-export error path, ls (shouldn't LBUG)"
5777 test_74b() { # bug 13310
5778 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5779 #define OBD_FAIL_LDLM_ENQUEUE_OLD_EXPORT 0x30e
5781 # very important to OR with OBD_FAIL_ONCE (0x80000000) -- otherwise it
5782 # will spin in a tight reconnection loop
5783 $LCTL set_param fail_loc=0x8000030e
5784 # get a "difficult" lock
5786 $LCTL set_param fail_loc=0
5790 run_test 74b "ldlm_enqueue freed-export error path, touch (shouldn't LBUG)"
5793 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5794 #define OBD_FAIL_LDLM_NEW_LOCK
5795 $LCTL set_param fail_loc=0x319
5796 touch $DIR/$tfile && error "touch successful"
5797 $LCTL set_param fail_loc=0
5800 run_test 74c "ldlm_lock_create error path, (shouldn't LBUG)"
5803 awk '/lustre_inode_cache/ {print $2; exit}' /proc/slabinfo
5806 get_inode_slab_tunables() {
5807 awk '/lustre_inode_cache/ {print $9," ",$10," ",$11; exit}' /proc/slabinfo
5810 set_inode_slab_tunables() {
5811 echo "lustre_inode_cache $1" > /proc/slabinfo
5814 test_76() { # Now for bug 20433, added originally in bug 1443
5815 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5816 local SLAB_SETTINGS=`get_inode_slab_tunables`
5817 local CPUS=`getconf _NPROCESSORS_ONLN`
5818 # we cannot set limit below 1 which means 1 inode in each
5819 # per-cpu cache is still allowed
5820 set_inode_slab_tunables "1 1 0"
5821 cancel_lru_locks osc
5822 BEFORE_INODES=$(num_inodes)
5823 echo "before inodes: $BEFORE_INODES"
5825 [ "$SLOW" = "no" ] && COUNT=100
5826 for i in $(seq $COUNT); do
5830 cancel_lru_locks osc
5831 AFTER_INODES=$(num_inodes)
5832 echo "after inodes: $AFTER_INODES"
5834 while [[ $((AFTER_INODES-1*CPUS)) -gt $BEFORE_INODES ]]; do
5836 AFTER_INODES=$(num_inodes)
5838 echo "wait $wait seconds inodes: $AFTER_INODES"
5839 if [ $wait -gt 30 ]; then
5840 error "inode slab grew from $BEFORE_INODES to $AFTER_INODES"
5843 set_inode_slab_tunables "$SLAB_SETTINGS"
5845 run_test 76 "confirm clients recycle inodes properly ===="
5851 # Note: in sptlrpc modes which enable its own bulk checksum, the
5852 # original crc32_le bulk checksum will be automatically disabled,
5853 # and the OBD_FAIL_OSC_CHECKSUM_SEND/OBD_FAIL_OSC_CHECKSUM_RECEIVE
5854 # will be checked by sptlrpc code against sptlrpc bulk checksum.
5855 # In this case set_checksums() will not be no-op, because sptlrpc
5856 # bulk checksum will be enabled all through the test.
5858 [ "$ORIG_CSUM" ] || ORIG_CSUM=`lctl get_param -n osc.*.checksums | head -n1`
5859 lctl set_param -n osc.*.checksums $1
5863 export ORIG_CSUM_TYPE="`lctl get_param -n osc.*osc-[^mM]*.checksum_type |
5864 sed 's/.*\[\(.*\)\].*/\1/g' | head -n1`"
5865 CKSUM_TYPES=${CKSUM_TYPES:-"crc32 adler"}
5866 [ "$ORIG_CSUM_TYPE" = "crc32c" ] && CKSUM_TYPES="$CKSUM_TYPES crc32c"
5869 lctl set_param -n osc.*osc-[^mM]*.checksum_type $1
5870 log "set checksum type to $1"
5873 F77_TMP=$TMP/f77-temp
5876 dd if=/dev/urandom of=$F77_TMP bs=1M count=$F77SZ || \
5877 error "error writing to $F77_TMP"
5880 test_77a() { # bug 10889
5881 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5882 $GSS && skip "could not run with gss" && return
5883 [ ! -f $F77_TMP ] && setup_f77
5885 dd if=$F77_TMP of=$DIR/$tfile bs=1M count=$F77SZ || error "dd error"
5889 run_test 77a "normal checksum read/write operation"
5891 test_77b() { # bug 10889
5892 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5893 $GSS && skip "could not run with gss" && return
5894 [ ! -f $F77_TMP ] && setup_f77
5895 #define OBD_FAIL_OSC_CHECKSUM_SEND 0x409
5896 $LCTL set_param fail_loc=0x80000409
5899 dd if=$F77_TMP of=$DIR/$tfile bs=1M count=$F77SZ conv=sync ||
5900 error "dd error: $?"
5901 $LCTL set_param fail_loc=0
5903 for algo in $CKSUM_TYPES; do
5904 cancel_lru_locks osc
5905 set_checksum_type $algo
5906 #define OBD_FAIL_OSC_CHECKSUM_RECEIVE 0x408
5907 $LCTL set_param fail_loc=0x80000408
5908 cmp $F77_TMP $DIR/$tfile || error "file compare failed"
5909 $LCTL set_param fail_loc=0
5912 set_checksum_type $ORIG_CSUM_TYPE
5915 run_test 77b "checksum error on client write, read"
5917 test_77d() { # bug 10889
5918 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5919 $GSS && skip "could not run with gss" && return
5920 #define OBD_FAIL_OSC_CHECKSUM_SEND 0x409
5921 $LCTL set_param fail_loc=0x80000409
5923 $DIRECTIO write $DIR/$tfile 0 $F77SZ $((1024 * 1024)) ||
5924 error "direct write: rc=$?"
5925 $LCTL set_param fail_loc=0
5928 #define OBD_FAIL_OSC_CHECKSUM_RECEIVE 0x408
5929 $LCTL set_param fail_loc=0x80000408
5931 cancel_lru_locks osc
5932 $DIRECTIO read $DIR/$tfile 0 $F77SZ $((1024 * 1024)) ||
5933 error "direct read: rc=$?"
5934 $LCTL set_param fail_loc=0
5937 run_test 77d "checksum error on OST direct write, read"
5939 test_77f() { # bug 10889
5940 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5941 $GSS && skip "could not run with gss" && return
5943 for algo in $CKSUM_TYPES; do
5944 cancel_lru_locks osc
5945 set_checksum_type $algo
5946 #define OBD_FAIL_OSC_CHECKSUM_SEND 0x409
5947 $LCTL set_param fail_loc=0x409
5948 $DIRECTIO write $DIR/$tfile 0 $F77SZ $((1024 * 1024)) &&
5949 error "direct write succeeded"
5950 $LCTL set_param fail_loc=0
5952 set_checksum_type $ORIG_CSUM_TYPE
5955 run_test 77f "repeat checksum error on write (expect error)"
5957 test_77g() { # bug 10889
5958 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5959 $GSS && skip "could not run with gss" && return
5960 remote_ost_nodsh && skip "remote OST with nodsh" && return
5962 [ ! -f $F77_TMP ] && setup_f77
5964 $SETSTRIPE -c 1 -i 0 $DIR/$tfile
5965 #define OBD_FAIL_OST_CHECKSUM_RECEIVE 0x21a
5966 do_facet ost1 lctl set_param fail_loc=0x8000021a
5968 dd if=$F77_TMP of=$DIR/$tfile bs=1M count=$F77SZ ||
5969 error "write error: rc=$?"
5970 do_facet ost1 lctl set_param fail_loc=0
5973 cancel_lru_locks osc
5974 #define OBD_FAIL_OST_CHECKSUM_SEND 0x21b
5975 do_facet ost1 lctl set_param fail_loc=0x8000021b
5977 cmp $F77_TMP $DIR/$tfile || error "file compare failed"
5978 do_facet ost1 lctl set_param fail_loc=0
5981 run_test 77g "checksum error on OST write, read"
5983 test_77i() { # bug 13805
5984 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5985 $GSS && skip "could not run with gss" && return
5986 #define OBD_FAIL_OSC_CONNECT_CKSUM 0x40b
5987 lctl set_param fail_loc=0x40b
5988 remount_client $MOUNT
5989 lctl set_param fail_loc=0
5990 for VALUE in `lctl get_param osc.*osc-[^mM]*.checksum_type`; do
5991 PARAM=`echo ${VALUE[0]} | cut -d "=" -f1`
5992 algo=`lctl get_param -n $PARAM | sed 's/.*\[\(.*\)\].*/\1/g'`
5993 [ "$algo" = "adler" ] || error "algo set to $algo instead of adler"
5995 remount_client $MOUNT
5997 run_test 77i "client not supporting OSD_CONNECT_CKSUM"
5999 test_77j() { # bug 13805
6000 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6001 $GSS && skip "could not run with gss" && return
6002 #define OBD_FAIL_OSC_CKSUM_ADLER_ONLY 0x40c
6003 lctl set_param fail_loc=0x40c
6004 remount_client $MOUNT
6005 lctl set_param fail_loc=0
6006 sleep 2 # wait async osc connect to finish
6007 for VALUE in `lctl get_param osc.*osc-[^mM]*.checksum_type`; do
6008 PARAM=`echo ${VALUE[0]} | cut -d "=" -f1`
6009 algo=`lctl get_param -n $PARAM | sed 's/.*\[\(.*\)\].*/\1/g'`
6010 [ "$algo" = "adler" ] || error "algo set to $algo instead of adler"
6012 remount_client $MOUNT
6014 run_test 77j "client only supporting ADLER32"
6016 [ "$ORIG_CSUM" ] && set_checksums $ORIG_CSUM || true
6020 test_78() { # bug 10901
6021 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6022 remote_ost || { skip_env "local OST" && return; }
6025 F78SIZE=$(($(awk '/MemFree:/ { print $2 }' /proc/meminfo) / 1024))
6026 echo "MemFree: $F78SIZE, Max file size: $MAXFREE"
6027 MEMTOTAL=$(($(awk '/MemTotal:/ { print $2 }' /proc/meminfo) / 1024))
6028 echo "MemTotal: $MEMTOTAL"
6030 # reserve 256MB of memory for the kernel and other running processes,
6031 # and then take 1/2 of the remaining memory for the read/write buffers.
6032 if [ $MEMTOTAL -gt 512 ] ;then
6033 MEMTOTAL=$(((MEMTOTAL - 256 ) / 2))
6035 # for those poor memory-starved high-end clusters...
6036 MEMTOTAL=$((MEMTOTAL / 2))
6038 echo "Mem to use for directio: $MEMTOTAL"
6040 [[ $F78SIZE -gt $MEMTOTAL ]] && F78SIZE=$MEMTOTAL
6041 [[ $F78SIZE -gt 512 ]] && F78SIZE=512
6042 [[ $F78SIZE -gt $((MAXFREE / 1024)) ]] && F78SIZE=$((MAXFREE / 1024))
6043 SMALLESTOST=$($LFS df $DIR | grep OST | awk '{ print $4 }' | sort -n |
6045 echo "Smallest OST: $SMALLESTOST"
6046 [[ $SMALLESTOST -lt 10240 ]] &&
6047 skip "too small OSTSIZE, useless to run large O_DIRECT test" && return 0
6049 [[ $F78SIZE -gt $((SMALLESTOST * $OSTCOUNT / 1024 - 80)) ]] &&
6050 F78SIZE=$((SMALLESTOST * $OSTCOUNT / 1024 - 80))
6052 [ "$SLOW" = "no" ] && NSEQ=1 && [ $F78SIZE -gt 32 ] && F78SIZE=32
6053 echo "File size: $F78SIZE"
6054 $SETSTRIPE -c $OSTCOUNT $DIR/$tfile || error "setstripe failed"
6055 for i in $(seq 1 $NSEQ); do
6056 FSIZE=$(($F78SIZE / ($NSEQ - $i + 1)))
6057 echo directIO rdwr round $i of $NSEQ
6058 $DIRECTIO rdwr $DIR/$tfile 0 $FSIZE 1048576||error "rdwr failed"
6063 run_test 78 "handle large O_DIRECT writes correctly ============"
6065 test_79() { # bug 12743
6066 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6067 wait_delete_completed
6069 BKTOTAL=$(calc_osc_kbytes kbytestotal)
6070 BKFREE=$(calc_osc_kbytes kbytesfree)
6071 BKAVAIL=$(calc_osc_kbytes kbytesavail)
6073 STRING=`df -P $MOUNT | tail -n 1 | awk '{print $2","$3","$4}'`
6074 DFTOTAL=`echo $STRING | cut -d, -f1`
6075 DFUSED=`echo $STRING | cut -d, -f2`
6076 DFAVAIL=`echo $STRING | cut -d, -f3`
6077 DFFREE=$(($DFTOTAL - $DFUSED))
6079 ALLOWANCE=$((64 * $OSTCOUNT))
6081 if [ $DFTOTAL -lt $(($BKTOTAL - $ALLOWANCE)) ] ||
6082 [ $DFTOTAL -gt $(($BKTOTAL + $ALLOWANCE)) ] ; then
6083 error "df total($DFTOTAL) mismatch OST total($BKTOTAL)"
6085 if [ $DFFREE -lt $(($BKFREE - $ALLOWANCE)) ] ||
6086 [ $DFFREE -gt $(($BKFREE + $ALLOWANCE)) ] ; then
6087 error "df free($DFFREE) mismatch OST free($BKFREE)"
6089 if [ $DFAVAIL -lt $(($BKAVAIL - $ALLOWANCE)) ] ||
6090 [ $DFAVAIL -gt $(($BKAVAIL + $ALLOWANCE)) ] ; then
6091 error "df avail($DFAVAIL) mismatch OST avail($BKAVAIL)"
6094 run_test 79 "df report consistency check ======================="
6096 test_80() { # bug 10718
6097 remote_ost_nodsh && skip "remote OST with nodsh" && return
6098 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6099 # relax strong synchronous semantics for slow backends like ZFS
6100 local soc="obdfilter.*.sync_on_lock_cancel"
6101 local soc_old=$(do_facet ost1 lctl get_param -n $soc | head -n1)
6103 if [ "$soc_old" != "never" -a "$(facet_fstype ost1)" != "ldiskfs" ]; then
6104 hosts=$(for host in $(seq -f "ost%g" 1 $OSTCOUNT); do
6105 facet_active_host $host; done | sort -u)
6106 do_nodes $hosts lctl set_param $soc=never
6109 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=1M
6111 local BEFORE=`date +%s`
6112 cancel_lru_locks osc
6113 local AFTER=`date +%s`
6114 local DIFF=$((AFTER-BEFORE))
6115 if [ $DIFF -gt 1 ] ; then
6116 error "elapsed for 1M@1T = $DIFF"
6119 [ -n "$hosts" ] && do_nodes $hosts lctl set_param $soc=$soc_old
6123 run_test 80 "Page eviction is equally fast at high offsets too ===="
6125 test_81a() { # LU-456
6126 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6127 remote_ost_nodsh && skip "remote OST with nodsh" && return
6128 # define OBD_FAIL_OST_MAPBLK_ENOSPC 0x228
6129 # MUST OR with the OBD_FAIL_ONCE (0x80000000)
6130 do_facet ost1 lctl set_param fail_loc=0x80000228
6132 # write should trigger a retry and success
6133 $SETSTRIPE -i 0 -c 1 $DIR/$tfile
6134 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
6136 if [ $RC -ne 0 ] ; then
6137 error "write should success, but failed for $RC"
6140 run_test 81a "OST should retry write when get -ENOSPC ==============="
6142 test_81b() { # LU-456
6143 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6144 remote_ost_nodsh && skip "remote OST with nodsh" && return
6145 # define OBD_FAIL_OST_MAPBLK_ENOSPC 0x228
6146 # Don't OR with the OBD_FAIL_ONCE (0x80000000)
6147 do_facet ost1 lctl set_param fail_loc=0x228
6149 # write should retry several times and return -ENOSPC finally
6150 $SETSTRIPE -i 0 -c 1 $DIR/$tfile
6151 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
6154 if [ $RC -ne $ENOSPC ] ; then
6155 error "dd should fail for -ENOSPC, but succeed."
6158 run_test 81b "OST should return -ENOSPC when retry still fails ======="
6160 test_82() { # LU-1031
6161 dd if=/dev/zero of=$DIR/$tfile bs=1M count=10
6165 multiop_bg_pause $DIR/$tfile OG${gid1}_g${gid1}c || return 1
6167 multiop_bg_pause $DIR/$tfile O_G${gid2}r10g${gid2}c || return 2
6169 kill -USR1 $MULTIPID2
6171 if [[ `ps h -o comm -p $MULTIPID2` == "" ]]; then
6172 error "First grouplock does not block second one"
6174 echo "Second grouplock blocks first one"
6176 kill -USR1 $MULTIPID1
6180 run_test 82 "Basic grouplock test ==============================="
6183 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" &&
6185 test_mkdir -p $DIR/d99cvsroot
6186 chown $RUNAS_ID $DIR/d99cvsroot
6187 local oldPWD=$PWD # bug 13584, use $TMP as working dir
6190 $RUNAS cvs -d $DIR/d99cvsroot init || error "cvs init failed"
6193 run_test 99a "cvs init ========================================="
6196 [ -z "$(which cvs 2>/dev/null)" ] &&
6197 skip_env "could not find cvs" && return
6198 [ ! -d $DIR/d99cvsroot ] && test_99a
6200 # some versions of cvs import exit(1) when asked to import links or
6201 # files they can't read. ignore those files.
6202 TOIGNORE=$(find . -type l -printf '-I %f\n' -o \
6203 ! -perm +4 -printf '-I %f\n')
6204 $RUNAS cvs -d $DIR/d99cvsroot import -m "nomesg" $TOIGNORE \
6205 d99reposname vtag rtag
6207 run_test 99b "cvs import ======================================="
6210 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" && return
6211 [ ! -d $DIR/d99cvsroot ] && test_99b
6213 test_mkdir -p $DIR/d99reposname
6214 chown $RUNAS_ID $DIR/d99reposname
6215 $RUNAS cvs -d $DIR/d99cvsroot co d99reposname
6217 run_test 99c "cvs checkout ====================================="
6220 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" && return
6221 [ ! -d $DIR/d99cvsroot ] && test_99c
6222 cd $DIR/d99reposname
6224 $RUNAS cvs add -m 'addmsg' foo99
6226 run_test 99d "cvs add =========================================="
6229 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" && return
6230 [ ! -d $DIR/d99cvsroot ] && test_99c
6231 cd $DIR/d99reposname
6234 run_test 99e "cvs update ======================================="
6237 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" && return
6238 [ ! -d $DIR/d99cvsroot ] && test_99d
6239 cd $DIR/d99reposname
6240 $RUNAS cvs commit -m 'nomsg' foo99
6241 rm -fr $DIR/d99cvsroot
6243 run_test 99f "cvs commit ======================================="
6246 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6247 [ "$NETTYPE" = tcp ] || \
6248 { skip "TCP secure port test, not useful for NETTYPE=$NETTYPE" && \
6251 remote_ost_nodsh && skip "remote OST with nodsh" && return
6252 remote_mds_nodsh && skip "remote MDS with nodsh" && return
6254 { skip "useless for local single node setup" && return; }
6256 netstat -tna | ( rc=1; while read PROT SND RCV LOCAL REMOTE STAT; do
6257 [ "$PROT" != "tcp" ] && continue
6258 RPORT=$(echo $REMOTE | cut -d: -f2)
6259 [ "$RPORT" != "$ACCEPTOR_PORT" ] && continue
6262 LPORT=`echo $LOCAL | cut -d: -f2`
6263 if [ $LPORT -ge 1024 ]; then
6264 echo "bad: $PROT $SND $RCV $LOCAL $REMOTE $STAT"
6266 error_exit "local: $LPORT > 1024, remote: $RPORT"
6269 [ "$rc" = 0 ] || error_exit "privileged port not found" )
6271 run_test 100 "check local port using privileged port ==========="
6273 function get_named_value()
6282 echo $line | sed "s/^$tag[ ]*//"
6289 export CACHE_MAX=$($LCTL get_param -n llite.*.max_cached_mb |
6290 awk '/^max_cached_mb/ { print $2 }')
6293 $LCTL set_param -n llite.*.max_cached_mb $CACHE_MAX
6298 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6299 [ $MDSCOUNT -ge 2 ] && skip "skip now for >= 2 MDTs" && return #LU-4322
6303 local cache_limit=32
6305 $LCTL set_param -n osc.*-osc*.rpc_stats 0
6306 trap cleanup_101a EXIT
6307 $LCTL set_param -n llite.*.read_ahead_stats 0
6308 $LCTL set_param -n llite.*.max_cached_mb $cache_limit
6311 # randomly read 10000 of 64K chunks from file 3x 32MB in size
6313 echo "nreads: $nreads file size: $((cache_limit * 3))MB"
6314 $READS -f $DIR/$tfile -s$((cache_limit * 3192 * 1024)) -b65536 -C -n$nreads -t 180
6317 for s in $($LCTL get_param -n llite.*.read_ahead_stats |
6318 get_named_value 'read but discarded' | cut -d" " -f1); do
6319 discard=$(($discard + $s))
6323 if [[ $(($discard * 10)) -gt $nreads ]]; then
6324 $LCTL get_param osc.*-osc*.rpc_stats
6325 $LCTL get_param llite.*.read_ahead_stats
6326 error "too many ($discard) discarded pages"
6328 rm -f $DIR/$tfile || true
6330 run_test 101a "check read-ahead for random reads ================"
6333 test_mkdir -p $DIR/$tdir
6334 local STRIPE_SIZE=$1
6335 local FILE_LENGTH=$2
6338 local FILE_SIZE_MB=$((FILE_LENGTH / STRIPE_SIZE))
6340 local list=$(comma_list $(osts_nodes))
6341 set_osd_param $list '' read_cache_enable 0
6342 set_osd_param $list '' writethrough_cache_enable 0
6344 trap cleanup_test101bc EXIT
6345 # prepare the read-ahead file
6346 $SETSTRIPE -S $STRIPE_SIZE -i $STRIPE_OFFSET -c $OSTCOUNT $DIR/$tfile
6348 dd if=/dev/zero of=$DIR/$tfile bs=$STRIPE_SIZE \
6349 count=$FILE_SIZE_MB 2> /dev/null
6353 cleanup_test101bc() {
6358 local list=$(comma_list $(osts_nodes))
6359 set_osd_param $list '' read_cache_enable 1
6360 set_osd_param $list '' writethrough_cache_enable 1
6364 awk 'BEGIN{total=0}; {total+=$1}; END{print total}'
6369 local STRIPE_SIZE=$2
6370 local FILE_LENGTH=$3
6371 local RA_INC=1048576
6372 local STRIDE_LENGTH=$((STRIPE_SIZE/READ_SIZE))
6373 local discard_limit=$((((STRIDE_LENGTH - 1)*3/(STRIDE_LENGTH*OSTCOUNT))* \
6374 (STRIDE_LENGTH*OSTCOUNT - STRIDE_LENGTH)))
6375 DISCARD=$($LCTL get_param -n llite.*.read_ahead_stats |
6376 get_named_value 'read but discarded' |
6377 cut -d" " -f1 | calc_total)
6378 if [[ $DISCARD -gt $discard_limit ]]; then
6379 $LCTL get_param llite.*.read_ahead_stats
6380 error "Too many ($DISCARD) discarded pages with size (${READ_SIZE})"
6382 echo "Read-ahead success for size ${READ_SIZE}"
6387 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6388 [[ $OSTCOUNT -lt 2 ]] &&
6389 skip_env "skipping stride IO stride-ahead test" && return
6390 local STRIPE_SIZE=1048576
6391 local STRIDE_SIZE=$((STRIPE_SIZE*OSTCOUNT))
6392 if [ $SLOW == "yes" ]; then
6393 local FILE_LENGTH=$((STRIDE_SIZE * 64))
6395 local FILE_LENGTH=$((STRIDE_SIZE * 8))
6398 local ITERATION=$((FILE_LENGTH / STRIDE_SIZE))
6400 # prepare the read-ahead file
6401 setup_test101bc $STRIPE_SIZE $FILE_LENGTH
6402 cancel_lru_locks osc
6403 for BIDX in 2 4 8 16 32 64 128 256
6405 local BSIZE=$((BIDX*4096))
6406 local READ_COUNT=$((STRIPE_SIZE/BSIZE))
6407 local STRIDE_LENGTH=$((STRIDE_SIZE/BSIZE))
6408 local OFFSET=$((STRIPE_SIZE/BSIZE*(OSTCOUNT - 1)))
6409 $LCTL set_param -n llite.*.read_ahead_stats 0
6410 $READS -f $DIR/$tfile -l $STRIDE_LENGTH -o $OFFSET \
6411 -s $FILE_LENGTH -b $STRIPE_SIZE -a $READ_COUNT -n $ITERATION
6412 cancel_lru_locks osc
6413 ra_check_101 $BSIZE $STRIPE_SIZE $FILE_LENGTH
6418 run_test 101b "check stride-io mode read-ahead ================="
6421 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6422 local STRIPE_SIZE=1048576
6423 local FILE_LENGTH=$((STRIPE_SIZE*100))
6427 setup_test101bc $STRIPE_SIZE $FILE_LENGTH
6429 cancel_lru_locks osc
6430 $LCTL set_param osc.*.rpc_stats 0
6431 $READS -f $DIR/$tfile -s$FILE_LENGTH -b65536 -n$nreads -t 180
6432 for osc_rpc_stats in $($LCTL get_param -N osc.*.rpc_stats); do
6433 local stats=$($LCTL get_param -n $osc_rpc_stats)
6434 local lines=$(echo "$stats" | awk 'END {print NR;}')
6437 if [ $lines -le 20 ]; then
6440 for size in 1 2 4 8; do
6441 local rpc=$(echo "$stats" |
6442 awk '($1 == "'$size':") {print $2; exit; }')
6444 error "Small $((size*4))k read IO $rpc !"
6446 echo "$osc_rpc_stats check passed!"
6451 run_test 101c "check stripe_size aligned read-ahead ================="
6454 $LCTL get_param -n llite.*.max_read_ahead_mb | head -n 1
6455 $LCTL set_param -n llite.*.max_read_ahead_mb $1 > /dev/null 2>&1
6459 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6460 local file=$DIR/$tfile
6461 local sz_MB=${FILESIZE_101d:-500}
6462 local ra_MB=${READAHEAD_MB:-40}
6464 local free_MB=$(($(df -P $DIR | tail -n 1 | awk '{ print $4 }') / 1024))
6465 [ $free_MB -lt $sz_MB ] &&
6466 skip "Need free space ${sz_MB}M, have ${free_MB}M" && return
6468 echo "Create test file $file size ${sz_MB}M, ${free_MB}M free"
6469 $SETSTRIPE -c -1 $file || error "setstripe failed"
6471 dd if=/dev/zero of=$file bs=1M count=$sz_MB || error "dd failed"
6472 echo Cancel LRU locks on lustre client to flush the client cache
6473 cancel_lru_locks osc
6475 echo Disable read-ahead
6476 local old_READAHEAD=$(set_read_ahead 0)
6478 echo Reading the test file $file with read-ahead disabled
6479 local raOFF=$(do_and_time "dd if=$file of=/dev/null bs=1M count=$sz_MB")
6481 echo Cancel LRU locks on lustre client to flush the client cache
6482 cancel_lru_locks osc
6483 echo Enable read-ahead with ${ra_MB}MB
6484 set_read_ahead $ra_MB
6486 echo Reading the test file $file with read-ahead enabled
6487 local raON=$(do_and_time "dd if=$file of=/dev/null bs=1M count=$sz_MB")
6489 echo "read-ahead disabled time read $raOFF"
6490 echo "read-ahead enabled time read $raON"
6492 set_read_ahead $old_READAHEAD
6494 wait_delete_completed
6496 [ $raOFF -le 1 -o $raON -lt $raOFF ] ||
6497 error "readahead ${raON}s > no-readahead ${raOFF}s ${sz_MB}M"
6499 run_test 101d "file read with and without read-ahead enabled"
6502 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6503 local file=$DIR/$tfile
6504 local size_KB=500 #KB
6508 local free_KB=$(df -P $DIR | tail -n 1 | awk '{ print $4 }')
6509 local need_KB=$((count * size_KB))
6510 [[ $free_KB -le $need_KB ]] &&
6511 skip_env "Need free space $need_KB, have $free_KB" && return
6513 echo "Creating $count ${size_KB}K test files"
6514 for ((i = 0; i < $count; i++)); do
6515 dd if=/dev/zero of=$file.$i bs=$bsize count=$size_KB 2>/dev/null
6518 echo "Cancel LRU locks on lustre client to flush the client cache"
6519 cancel_lru_locks osc
6521 echo "Reset readahead stats"
6522 $LCTL set_param -n llite.*.read_ahead_stats 0
6524 for ((i = 0; i < $count; i++)); do
6525 dd if=$file.$i of=/dev/null bs=$bsize count=$size_KB 2>/dev/null
6528 local miss=$($LCTL get_param -n llite.*.read_ahead_stats |
6529 get_named_value 'misses' | cut -d" " -f1 | calc_total)
6531 for ((i = 0; i < $count; i++)); do
6532 rm -rf $file.$i 2>/dev/null
6535 #10000 means 20% reads are missing in readahead
6536 [[ $miss -lt 10000 ]] || error "misses too much for small reads"
6538 run_test 101e "check read-ahead for small read(1k) for small files(500k)"
6540 cleanup_test101f() {
6542 $LCTL set_param -n llite.*.max_read_ahead_whole_mb $MAX_WHOLE_MB
6543 rm -rf $DIR/$tfile 2>/dev/null
6547 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6548 local file=$DIR/$tfile
6551 MAX_WHOLE_MB=$($LCTL get_param -n llite.*.max_read_ahead_whole_mb)
6552 $LCTL set_param -n llite.*.max_read_ahead_whole_mb 2
6553 dd if=/dev/zero of=${file} bs=2097152 count=1 2>/dev/null
6554 trap cleanup_test101f EXIT
6556 echo Cancel LRU locks on lustre client to flush the client cache
6557 cancel_lru_locks osc
6559 echo Reset readahead stats
6560 $LCTL set_param -n llite.*.read_ahead_stats 0
6561 # Random read in a 2M file, because max_read_ahead_whole_mb = 2M,
6562 # readahead should read in 2M file on second read, so only miss
6564 echo Random 4K reads on 2M file for 1000 times
6565 $READS -f $file -s 2097152 -b 4096 -n $nreads
6567 echo checking missing pages
6568 local miss=$($LCTL get_param -n llite.*.read_ahead_stats |
6569 get_named_value 'misses' | cut -d" " -f1 | calc_total)
6571 [ $miss -lt 3 ] || error "misses too much pages!"
6574 run_test 101f "check read-ahead for max_read_ahead_whole_mb"
6577 test_mkdir -p $DIR/$tdir
6578 chown $RUNAS_ID $DIR/$tdir
6581 STRIPE_COUNT=$OSTCOUNT
6582 [[ $OSTCOUNT -gt 4 ]] && STRIPE_COUNT=4
6584 trap cleanup_test102 EXIT
6586 $1 $SETSTRIPE -S $STRIPE_SIZE -i $STRIPE_OFFSET -c $STRIPE_COUNT $tdir
6588 for num in 1 2 3 4; do
6589 for count in $(seq 1 $STRIPE_COUNT); do
6590 for idx in $(seq 0 $[$STRIPE_COUNT - 1]); do
6591 local size=`expr $STRIPE_SIZE \* $num`
6592 local file=file"$num-$idx-$count"
6593 $1 $SETSTRIPE -S $size -i $idx -c $count $file
6599 $1 $TAR cf $TMP/f102.tar $tdir --xattrs
6605 rm -rf $DIR/d0.sanity/d102
6609 local testfile=$DIR/$tfile
6613 [ "$UID" != 0 ] && skip_env "must run as root" && return
6614 [ -z "$(lctl get_param -n mdc.*-mdc-*.connect_flags | grep xattr)" ] &&
6615 skip_env "must have user_xattr" && return
6617 [ -z "$(which setfattr 2>/dev/null)" ] &&
6618 skip_env "could not find setfattr" && return
6620 echo "set/get xattr..."
6621 setfattr -n trusted.name1 -v value1 $testfile ||
6622 error "setfattr -n trusted.name1=value1 $testfile failed"
6623 getfattr -n trusted.name1 $testfile 2> /dev/null |
6624 grep "trusted.name1=.value1" ||
6625 error "$testfile missing trusted.name1=value1"
6627 setfattr -n user.author1 -v author1 $testfile ||
6628 error "setfattr -n user.author1=author1 $testfile failed"
6629 getfattr -n user.author1 $testfile 2> /dev/null |
6630 grep "user.author1=.author1" ||
6631 error "$testfile missing trusted.author1=author1"
6634 setfattr -n trusted.name2 -v value2 $testfile ||
6635 error "$testfile unable to set trusted.name2"
6636 setfattr -n trusted.name3 -v value3 $testfile ||
6637 error "$testfile unable to set trusted.name3"
6638 [ $(getfattr -d -m "^trusted" $testfile 2> /dev/null |
6639 grep "trusted.name" | wc -l) -eq 3 ] ||
6640 error "$testfile missing 3 trusted.name xattrs"
6642 setfattr -n user.author2 -v author2 $testfile ||
6643 error "$testfile unable to set user.author2"
6644 setfattr -n user.author3 -v author3 $testfile ||
6645 error "$testfile unable to set user.author3"
6646 [ $(getfattr -d -m "^user" $testfile 2> /dev/null |
6647 grep "user.author" | wc -l) -eq 3 ] ||
6648 error "$testfile missing 3 user.author xattrs"
6650 echo "remove xattr..."
6651 setfattr -x trusted.name1 $testfile ||
6652 error "$testfile error deleting trusted.name1"
6653 getfattr -d -m trusted $testfile 2> /dev/null | grep "trusted.name1" &&
6654 error "$testfile did not delete trusted.name1 xattr"
6656 setfattr -x user.author1 $testfile ||
6657 error "$testfile error deleting user.author1"
6658 getfattr -d -m user $testfile 2> /dev/null | grep "user.author1" &&
6659 error "$testfile did not delete trusted.name1 xattr"
6661 # b10667: setting lustre special xattr be silently discarded
6662 echo "set lustre special xattr ..."
6663 setfattr -n "trusted.lov" -v "invalid value" $testfile ||
6664 error "$testfile allowed setting trusted.lov"
6666 run_test 102a "user xattr test =================================="
6669 [ -z "$(which setfattr 2>/dev/null)" ] &&
6670 skip_env "could not find setfattr" && return
6672 # b10930: get/set/list trusted.lov xattr
6673 echo "get/set/list trusted.lov xattr ..."
6674 [[ $OSTCOUNT -lt 2 ]] && skip_env "skipping 2-stripe test" && return
6675 local testfile=$DIR/$tfile
6676 $SETSTRIPE -S 65536 -i 1 -c $OSTCOUNT $testfile ||
6677 error "setstripe failed"
6678 local STRIPECOUNT=$($GETSTRIPE -c $testfile) ||
6679 error "getstripe failed"
6680 getfattr -d -m "^trusted" $testfile 2>/dev/null | grep "trusted.lov" ||
6681 error "can't get trusted.lov from $testfile"
6683 local testfile2=${testfile}2
6684 local value=$(getfattr -n trusted.lov $testfile 2>/dev/null |
6685 grep "trusted.lov" | sed -e 's/[^=]\+=//')
6688 setfattr -n trusted.lov -v $value $testfile2
6689 local stripe_size=$($GETSTRIPE -S $testfile2)
6690 local stripe_count=$($GETSTRIPE -c $testfile2)
6691 [[ $stripe_size -eq 65536 ]] ||
6692 error "stripe size $stripe_size != 65536"
6693 [[ $stripe_count -eq $STRIPECOUNT ]] ||
6694 error "stripe count $stripe_count != $STRIPECOUNT"
6697 run_test 102b "getfattr/setfattr for trusted.lov EAs ============"
6700 [ -z "$(which setfattr 2>/dev/null)" ] &&
6701 skip_env "could not find setfattr" && return
6703 # b10930: get/set/list lustre.lov xattr
6704 echo "get/set/list lustre.lov xattr ..."
6705 [[ $OSTCOUNT -lt 2 ]] && skip_env "skipping 2-stripe test" && return
6706 test_mkdir -p $DIR/$tdir
6707 chown $RUNAS_ID $DIR/$tdir
6708 local testfile=$DIR/$tdir/$tfile
6709 $RUNAS $SETSTRIPE -S 65536 -i 1 -c $OSTCOUNT $testfile ||
6710 error "setstripe failed"
6711 local STRIPECOUNT=$($RUNAS $GETSTRIPE -c $testfile) ||
6712 error "getstripe failed"
6713 $RUNAS getfattr -d -m "^lustre" $testfile 2> /dev/null | \
6714 grep "lustre.lov" || error "can't get lustre.lov from $testfile"
6716 local testfile2=${testfile}2
6717 local value=`getfattr -n lustre.lov $testfile 2> /dev/null | \
6718 grep "lustre.lov" |sed -e 's/[^=]\+=//' `
6720 $RUNAS $MCREATE $testfile2
6721 $RUNAS setfattr -n lustre.lov -v $value $testfile2
6722 local stripe_size=$($RUNAS $GETSTRIPE -S $testfile2)
6723 local stripe_count=$($RUNAS $GETSTRIPE -c $testfile2)
6724 [ $stripe_size -eq 65536 ] || error "stripe size $stripe_size != 65536"
6725 [ $stripe_count -eq $STRIPECOUNT ] ||
6726 error "stripe count $stripe_count != $STRIPECOUNT"
6728 run_test 102c "non-root getfattr/setfattr for lustre.lov EAs ==========="
6730 compare_stripe_info1() {
6731 local stripe_index_all_zero=true
6733 for num in 1 2 3 4; do
6734 for count in $(seq 1 $STRIPE_COUNT); do
6735 for offset in $(seq 0 $[$STRIPE_COUNT - 1]); do
6736 local size=$((STRIPE_SIZE * num))
6737 local file=file"$num-$offset-$count"
6738 stripe_size=$($LFS getstripe -S $PWD/$file)
6739 [[ $stripe_size -ne $size ]] &&
6740 error "$file: size $stripe_size != $size"
6741 stripe_count=$($LFS getstripe -c $PWD/$file)
6742 # allow fewer stripes to be created, ORI-601
6743 [[ $stripe_count -lt $(((3 * count + 3) / 4)) ]] &&
6744 error "$file: count $stripe_count != $count"
6745 stripe_index=$($LFS getstripe -i $PWD/$file)
6746 [[ $stripe_index -ne 0 ]] &&
6747 stripe_index_all_zero=false
6751 $stripe_index_all_zero &&
6752 error "all files are being extracted starting from OST index 0"
6757 [ -n "$(which tar 2>/dev/null)" ] &&
6758 strings $(which tar) | grep -q "lustre" && echo tar
6762 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6763 # b10930: tar test for trusted.lov xattr
6764 TAR=$(find_lustre_tar)
6765 [ -z "$TAR" ] && skip_env "lustre-aware tar is not installed" && return
6766 [[ $OSTCOUNT -lt 2 ]] && skip_env "skipping N-stripe test" && return
6768 test_mkdir -p $DIR/d102d
6769 $TAR xf $TMP/f102.tar -C $DIR/d102d --xattrs
6771 compare_stripe_info1
6773 run_test 102d "tar restore stripe info from tarfile,not keep osts ==========="
6776 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6777 # b10930: tar test for trusted.lov xattr
6778 TAR=$(find_lustre_tar)
6779 [ -z "$TAR" ] && skip_env "lustre-aware tar is not installed" && return
6780 [[ $OSTCOUNT -lt 2 ]] && skip_env "skipping N-stripe test" && return
6782 test_mkdir -p $DIR/d102f
6784 $TAR cf - --xattrs $tdir | $TAR xf - --xattrs -C $DIR/d102f
6786 compare_stripe_info1
6788 run_test 102f "tar copy files, not keep osts ==========="
6791 local xsize=${1:-1024} # in bytes
6792 local file=$DIR/$tfile
6794 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep xattr)" ] &&
6795 skip "must have user_xattr" && return 0
6796 [ -z "$(which setfattr 2>/dev/null)" ] &&
6797 skip_env "could not find setfattr" && return 0
6798 [ -z "$(which getfattr 2>/dev/null)" ] &&
6799 skip_env "could not find getfattr" && return 0
6803 local value="$(generate_string $xsize)"
6805 local xbig=trusted.big
6806 log "save $xbig on $file"
6807 setfattr -n $xbig -v $value $file ||
6808 error "saving $xbig on $file failed"
6810 local orig=$(get_xattr_value $xbig $file)
6811 [[ "$orig" != "$value" ]] && error "$xbig different after saving $xbig"
6813 local xsml=trusted.sml
6814 log "save $xsml on $file"
6815 setfattr -n $xsml -v val $file || error "saving $xsml on $file failed"
6817 local new=$(get_xattr_value $xbig $file)
6818 [[ "$new" != "$orig" ]] && error "$xbig different after saving $xsml"
6820 log "grow $xsml on $file"
6821 setfattr -n $xsml -v "$value" $file ||
6822 error "growing $xsml on $file failed"
6824 new=$(get_xattr_value $xbig $file)
6825 [[ "$new" != "$orig" ]] && error "$xbig different after growing $xsml"
6826 log "$xbig still valid after growing $xsml"
6831 test_102h() { # bug 15777
6834 run_test 102h "grow xattr from inside inode to external block"
6837 large_xattr_enabled || { skip "large_xattr disabled" && return; }
6838 grow_xattr $(max_xattr_size)
6840 run_test 102ha "grow xattr from inside inode to external inode"
6842 test_102i() { # bug 17038
6843 [ -z "$(which getfattr 2>/dev/null)" ] &&
6844 skip "could not find getfattr" && return
6846 ln -s $DIR/$tfile $DIR/${tfile}link
6847 getfattr -n trusted.lov $DIR/$tfile ||
6848 error "lgetxattr on $DIR/$tfile failed"
6849 getfattr -h -n trusted.lov $DIR/${tfile}link 2>&1 |
6850 grep -i "no such attr" ||
6851 error "error for lgetxattr on $DIR/${tfile}link is not ENODATA"
6852 rm -f $DIR/$tfile $DIR/${tfile}link
6854 run_test 102i "lgetxattr test on symbolic link ============"
6857 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6858 TAR=$(find_lustre_tar)
6859 [ -z "$TAR" ] && skip_env "lustre-aware tar is not installed" && return
6860 [[ $OSTCOUNT -lt 2 ]] && skip_env "skipping N-stripe test" && return
6861 setup_test102 "$RUNAS"
6862 test_mkdir -p $DIR/d102j
6863 chown $RUNAS_ID $DIR/d102j
6864 $RUNAS $TAR xf $TMP/f102.tar -C $DIR/d102j --xattrs
6866 compare_stripe_info1 "$RUNAS"
6868 run_test 102j "non-root tar restore stripe info from tarfile, not keep osts ==="
6871 [ -z "$(which setfattr 2>/dev/null)" ] &&
6872 skip "could not find setfattr" && return
6874 # b22187 just check that does not crash for regular file.
6875 setfattr -n trusted.lov $DIR/$tfile
6876 # b22187 'setfattr -n trusted.lov' should work as remove LOV EA for directories
6877 local test_kdir=$DIR/d102k
6878 test_mkdir $test_kdir
6879 local default_size=`$GETSTRIPE -S $test_kdir`
6880 local default_count=`$GETSTRIPE -c $test_kdir`
6881 local default_offset=`$GETSTRIPE -i $test_kdir`
6882 $SETSTRIPE -S 65536 -i 0 -c $OSTCOUNT $test_kdir ||
6883 error 'dir setstripe failed'
6884 setfattr -n trusted.lov $test_kdir
6885 local stripe_size=`$GETSTRIPE -S $test_kdir`
6886 local stripe_count=`$GETSTRIPE -c $test_kdir`
6887 local stripe_offset=`$GETSTRIPE -i $test_kdir`
6888 [ $stripe_size -eq $default_size ] ||
6889 error "stripe size $stripe_size != $default_size"
6890 [ $stripe_count -eq $default_count ] ||
6891 error "stripe count $stripe_count != $default_count"
6892 [ $stripe_offset -eq $default_offset ] ||
6893 error "stripe offset $stripe_offset != $default_offset"
6894 rm -rf $DIR/$tfile $test_kdir
6896 run_test 102k "setfattr without parameter of value shouldn't cause a crash"
6899 [ -z "$(which getfattr 2>/dev/null)" ] &&
6900 skip "could not find getfattr" && return
6902 # LU-532 trusted. xattr is invisible to non-root
6903 local testfile=$DIR/$tfile
6907 echo "listxattr as user..."
6908 chown $RUNAS_ID $testfile
6909 $RUNAS getfattr -d -m '.*' $testfile 2>&1 |
6910 grep -q "trusted" &&
6911 error "$testfile trusted xattrs are user visible"
6915 run_test 102l "listxattr size test =================================="
6917 test_102m() { # LU-3403 llite: error of listxattr when buffer is small
6918 local path=$DIR/$tfile
6921 listxattr_size_check $path || error "listattr_size_check $path failed"
6923 run_test 102m "Ensure listxattr fails on small bufffer ========"
6927 getxattr() { # getxattr path name
6928 # Return the base64 encoding of the value of xattr name on path.
6932 # # getfattr --absolute-names --encoding=base64 --name=trusted.lov $path
6934 # trusted.lov=0s0AvRCwEAAAAGAAAAAAAAAAAEAAACAAAAAAAQAAEAA...AAAAAAAAA=
6936 # We print just 0s0AvRCwEAAAAGAAAAAAAAAAAEAAACAAAAAAAQAAEAA...AAAAAAAAA=
6938 getfattr --absolute-names --encoding=base64 --name=$name $path |
6939 awk -F= -v name=$name '$1 == name {
6940 print substr($0, index($0, "=") + 1);
6944 test_102n() { # LU-4101 mdt: protect internal xattrs
6945 local file0=$DIR/$tfile.0
6946 local file1=$DIR/$tfile.1
6947 local xattr0=$TMP/$tfile.0
6948 local xattr1=$TMP/$tfile.1
6952 [ -z "$(which setfattr 2>/dev/null)" ] &&
6953 skip "could not find setfattr" && return
6955 if [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.5.50) ]
6957 skip "MDT < 2.5.50 allows setxattr on internal trusted xattrs"
6961 rm -rf $file0 $file1 $xattr0 $xattr1
6964 # Get 'before' xattrs of $file1.
6965 getfattr --absolute-names --dump --match=- $file1 > $xattr0
6967 for name in lov lma lmv link fid version som hsm lfsck_namespace; do
6968 # Try to copy xattr from $file0 to $file1.
6969 value=$(getxattr $file0 trusted.$name 2> /dev/null)
6971 setfattr --name=trusted.$name --value="$value" $file1 ||
6972 error "setxattr 'trusted.$name' failed"
6974 # Try to set a garbage xattr.
6975 value=0sVGhlIHF1aWNrIGJyb3duIGZveCBqdW1wcyBvdmVyIGl0c2VsZi4=
6977 setfattr --name=trusted.$name --value="$value" $file1 ||
6978 error "setxattr 'trusted.$name' failed"
6980 # Try to remove the xattr from $file1. We don't care if this
6981 # appears to succeed or fail, we just don't want there to be
6982 # any changes or crashes.
6983 setfattr --remove=$trusted.$name $file1 2> /dev/null
6986 if [ $(lustre_version_code $SINGLEMDS) -gt $(version_code 2.6.50) ]
6989 # Try to copy xattr from $file0 to $file1.
6990 value=$(getxattr $file0 trusted.$name 2> /dev/null)
6992 setfattr --name=trusted.$name --value="$value" $file1 ||
6993 error "setxattr 'trusted.$name' failed"
6995 # Try to set a garbage xattr.
6996 value=0sVGhlIHF1aWNrIGJyb3duIGZveCBqdW1wcyBvdmVyIGl0c2VsZi4=
6998 setfattr --name=trusted.$name --value="$value" $file1 ||
6999 error "setxattr 'trusted.$name' failed"
7001 # Try to remove the xattr from $file1. We don't care if this
7002 # appears to succeed or fail, we just don't want there to be
7003 # any changes or crashes.
7004 setfattr --remove=$trusted.$name $file1 2> /dev/null
7007 # Get 'after' xattrs of file1.
7008 getfattr --absolute-names --dump --match=- $file1 > $xattr1
7010 if ! diff $xattr0 $xattr1; then
7011 error "before and after xattrs of '$file1' differ"
7014 rm -rf $file0 $file1 $xattr0 $xattr1
7018 run_test 102n "silently ignore setxattr on internal trusted xattrs"
7020 test_102p() { # LU-4703 setxattr did not check ownership
7021 local testfile=$DIR/$tfile
7023 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.5.56) ] &&
7024 skip "MDS needs to be at least 2.5.56" && return
7028 echo "setfacl as user..."
7029 $RUNAS setfacl -m "u:$RUNAS_ID:rwx" $testfile
7030 [ $? -ne 0 ] || error "setfacl by $RUNAS_ID was allowed on $testfile"
7032 echo "setfattr as user..."
7033 setfacl -m "u:$RUNAS_ID:---" $testfile
7034 $RUNAS setfattr -x system.posix_acl_access $testfile
7035 [ $? -ne 0 ] || error "setfattr by $RUNAS_ID was allowed on $testfile"
7037 run_test 102p "check setxattr(2) correctly fails without permission"
7040 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.6.92) ] &&
7041 skip "MDS needs to be at least 2.6.92" && return
7042 orphan_linkea_check $DIR/$tfile || error "orphan_linkea_check"
7044 run_test 102q "flistxattr should not return trusted.link EAs for orphans"
7047 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.6.93) ] &&
7048 skip "MDS needs to be at least 2.6.93" && return
7049 touch $DIR/$tfile || error "touch"
7050 setfattr -n user.$(basename $tfile) $DIR/$tfile || error "setfattr"
7051 getfattr -n user.$(basename $tfile) $DIR/$tfile || error "getfattr"
7052 rm $DIR/$tfile || error "rm"
7055 mkdir -p $DIR/$tdir || error "mkdir"
7056 setfattr -n user.$(basename $tdir) $DIR/$tdir || error "setfattr dir"
7057 getfattr -n user.$(basename $tdir) $DIR/$tdir || error "getfattr dir"
7058 setfattr -x user.$(basename $tdir) $DIR/$tdir ||
7059 error "$testfile error deleting user.author1"
7060 getfattr -d -m user.$(basename $tdir) 2> /dev/null |
7061 grep "user.$(basename $tdir)" &&
7062 error "$tdir did not delete user.$(basename $tdir)"
7063 rmdir $DIR/$tdir || error "rmdir"
7066 test_mkdir -p $DIR/$tdir || error "make striped dir"
7067 setfattr -n user.$(basename $tdir) $DIR/$tdir || error "setfattr dir"
7068 getfattr -n user.$(basename $tdir) $DIR/$tdir || error "getfattr dir"
7069 setfattr -x user.$(basename $tdir) $DIR/$tdir ||
7070 error "$testfile error deleting user.author1"
7071 getfattr -d -m user.$(basename $tdir) 2> /dev/null |
7072 grep "user.$(basename $tdir)" &&
7073 error "$tdir did not delete user.$(basename $tdir)"
7074 rmdir $DIR/$tdir || error "rm striped dir"
7076 run_test 102r "set EAs with empty values"
7080 $LUSTRE/tests/acl/run $LUSTRE/tests/acl/$1.test
7085 [ "$UID" != 0 ] && skip_env "must run as root" && return
7086 [ -z "$(lctl get_param -n mdc.*-mdc-*.connect_flags | grep acl)" ] &&
7087 skip "must have acl enabled" && return
7088 [ -z "$(which setfacl 2>/dev/null)" ] &&
7089 skip_env "could not find setfacl" && return
7090 $GSS && skip "could not run under gss" && return
7092 gpasswd -a daemon bin # LU-5641
7093 do_facet $SINGLEMDS gpasswd -a daemon bin # LU-5641
7095 declare -a identity_old
7097 for num in $(seq $MDSCOUNT); do
7098 switch_identity $num true || identity_old[$num]=$?
7105 echo "performing cp ..."
7106 run_acl_subtest cp || error "run_acl_subtest cp failed"
7107 echo "performing getfacl-noacl..."
7108 run_acl_subtest getfacl-noacl || error "getfacl-noacl test failed"
7109 echo "performing misc..."
7110 run_acl_subtest misc || error "misc test failed"
7111 echo "performing permissions..."
7112 run_acl_subtest permissions || error "permissions failed"
7113 echo "performing setfacl..."
7114 run_acl_subtest setfacl || error "setfacl test failed"
7116 # inheritance test got from HP
7117 echo "performing inheritance..."
7118 cp $LUSTRE/tests/acl/make-tree . || error "cannot copy make-tree"
7119 chmod +x make-tree || error "chmod +x failed"
7120 run_acl_subtest inheritance || error "inheritance test failed"
7123 echo "LU-974 ignore umask when acl is enabled..."
7124 run_acl_subtest 974 || error "LU-974 umask test failed"
7125 if [ $MDSCOUNT -ge 2 ]; then
7126 run_acl_subtest 974_remote ||
7127 error "LU-974 umask test failed under remote dir"
7130 echo "LU-2561 newly created file is same size as directory..."
7131 if [ $(facet_fstype $SINGLEMDS) != "zfs" ]; then
7132 run_acl_subtest 2561 || error "LU-2561 test failed"
7134 run_acl_subtest 2561_zfs || error "LU-2561 zfs test failed"
7137 run_acl_subtest 4924 || error "LU-4924 test failed"
7142 for num in $(seq $MDSCOUNT); do
7143 if [ "${identity_old[$num]}" = 1 ]; then
7144 switch_identity $num false || identity_old[$num]=$?
7148 run_test 103a "acl test ========================================="
7152 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
7153 local mountopts=$MDS_MOUNT_OPTS
7155 if [[ "$MDS_MOUNT_OPTS" =~ "noacl" ]]; then
7159 stop $SINGLEMDS || error "failed to stop MDT."
7161 if [ -z "$MDS_MOUNT_OPTS" ]; then
7162 MDS_MOUNT_OPTS="-o noacl"
7164 MDS_MOUNT_OPTS="${MDS_MOUNT_OPTS},noacl"
7166 start $SINGLEMDS $MDT_DEV $MDS_MOUNT_OPTS ||
7167 error "failed to start MDT."
7168 MDS_MOUNT_OPTS=$mountopts
7172 setfacl -m u:bin:rw $DIR/$tfile && error "setfacl should fail"
7176 stop $SINGLEMDS || error "failed to stop MDT."
7178 start $SINGLEMDS $MDT_DEV $MDS_MOUNT_OPTS ||
7179 error "failed to start MDT."
7184 run_test 103b "MDS mount option 'noacl'"
7188 cp -rp $DIR/$tdir $DIR/$tdir.bak
7190 [ -n "$(getfattr -d -m. $DIR/$tdir | grep posix_acl_default)" ] &&
7191 error "$DIR/$tdir shouldn't contain default ACL"
7192 [ -n "$(getfattr -d -m. $DIR/$tdir.bak | grep posix_acl_default)" ] &&
7193 error "$DIR/$tdir.bak shouldn't contain default ACL"
7196 run_test 103c "'cp -rp' won't set empty acl"
7199 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7201 lfs df || error "lfs df failed"
7202 lfs df -ih || error "lfs df -ih failed"
7203 lfs df -h $DIR || error "lfs df -h $DIR failed"
7204 lfs df -i $DIR || error "lfs df -i $DIR failed"
7205 lfs df $DIR/$tfile || error "lfs df $DIR/$tfile failed"
7206 lfs df -ih $DIR/$tfile || error "lfs df -ih $DIR/$tfile failed"
7208 local OSC=$(lctl dl | grep OST0000-osc-[^M] | awk '{ print $4 }')
7209 lctl --device %$OSC deactivate
7210 lfs df || error "lfs df with deactivated OSC failed"
7211 lctl --device %$OSC activate
7212 # wait the osc back to normal
7213 wait_osc_import_state client ost FULL
7215 lfs df || error "lfs df with reactivated OSC failed"
7218 run_test 104a "lfs df [-ih] [path] test ========================="
7221 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7222 [ $RUNAS_ID -eq $UID ] &&
7223 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
7225 denied_cnt=$(($($RUNAS $LFS check servers 2>&1 |
7226 grep "Permission denied" | wc -l)))
7227 if [ $denied_cnt -ne 0 ]; then
7228 error "lfs check servers test failed"
7231 run_test 104b "$RUNAS lfs check servers test ===================="
7234 # doesn't work on 2.4 kernels
7236 if $(flock_is_enabled); then
7237 flocks_test 1 on -f $DIR/$tfile || error "fail flock on"
7239 flocks_test 1 off -f $DIR/$tfile || error "fail flock off"
7243 run_test 105a "flock when mounted without -o flock test ========"
7247 if $(flock_is_enabled); then
7248 flocks_test 1 on -c $DIR/$tfile || error "fail flock on"
7250 flocks_test 1 off -c $DIR/$tfile || error "fail flock off"
7254 run_test 105b "fcntl when mounted without -o flock test ========"
7258 if $(flock_is_enabled); then
7259 flocks_test 1 on -l $DIR/$tfile || error "fail flock on"
7261 flocks_test 1 off -l $DIR/$tfile || error "fail flock off"
7265 run_test 105c "lockf when mounted without -o flock test ========"
7267 test_105d() { # bug 15924
7268 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7269 test_mkdir -p $DIR/$tdir
7270 flock_is_enabled || { skip "mount w/o flock enabled" && return; }
7271 #define OBD_FAIL_LDLM_CP_CB_WAIT 0x315
7272 $LCTL set_param fail_loc=0x80000315
7273 flocks_test 2 $DIR/$tdir
7275 run_test 105d "flock race (should not freeze) ========"
7277 test_105e() { # bug 22660 && 22040
7278 flock_is_enabled || { skip "mount w/o flock enabled" && return; }
7280 flocks_test 3 $DIR/$tfile
7282 run_test 105e "Two conflicting flocks from same process ======="
7284 test_106() { #bug 10921
7285 test_mkdir -p $DIR/$tdir
7286 $DIR/$tdir && error "exec $DIR/$tdir succeeded"
7287 chmod 777 $DIR/$tdir || error "chmod $DIR/$tdir failed"
7289 run_test 106 "attempt exec of dir followed by chown of that dir"
7292 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7299 local save_pattern=$(sysctl -n kernel.core_pattern)
7300 local save_uses_pid=$(sysctl -n kernel.core_uses_pid)
7301 sysctl -w kernel.core_pattern=$file
7302 sysctl -w kernel.core_uses_pid=0
7310 kill -s 11 $SLEEPPID
7312 if [ -e $file ]; then
7313 size=`stat -c%s $file`
7314 [ $size -eq 0 ] && error "Fail to create core file $file"
7316 error "Fail to create core file $file"
7319 sysctl -w kernel.core_pattern=$save_pattern
7320 sysctl -w kernel.core_uses_pid=$save_uses_pid
7323 run_test 107 "Coredump on SIG"
7326 test_mkdir -p $DIR/$tdir
7327 test_mkdir $DIR/$tdir/$(str_repeat 'a' 255) ||
7328 error "mkdir with 255 char failed"
7329 test_mkdir $DIR/$tdir/$(str_repeat 'b' 256) &&
7330 error "mkdir with 256 char should fail, but did not"
7331 touch $DIR/$tdir/$(str_repeat 'x' 255) ||
7332 error "create with 255 char failed"
7333 touch $DIR/$tdir/$(str_repeat 'y' 256) &&
7334 error "create with 256 char should fail, but did not"
7339 run_test 110 "filename length checking"
7342 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7343 OSTIO_pre=$(ps -e | grep ll_ost_io | awk '{ print $4 }'| sort -n |
7344 tail -1 | cut -c11-20)
7345 [ -z "$OSTIO_pre" ] && skip "no OSS threads" && return
7346 echo "Starting with $OSTIO_pre threads"
7349 NUMFREE=$(df -i -P $DIR | tail -n 1 | awk '{ print $4 }')
7350 [[ $NUMFREE -lt $NUMTEST ]] && NUMTEST=$(($NUMFREE - 1000))
7351 echo "$NUMTEST creates/unlinks"
7352 test_mkdir -p $DIR/$tdir
7353 createmany -o $DIR/$tdir/$tfile $NUMTEST
7354 unlinkmany $DIR/$tdir/$tfile $NUMTEST
7356 OSTIO_post=$(ps -e | grep ll_ost_io | awk '{ print $4 }' | sort -n |
7357 tail -1 | cut -c11-20)
7359 # don't return an error
7360 [ $OSTIO_post == $OSTIO_pre ] && echo \
7361 "WARNING: No new ll_ost_io threads were created ($OSTIO_pre)" &&
7362 echo "This may be fine, depending on what ran before this test" &&
7363 echo "and how fast this system is." && return
7365 echo "Started with $OSTIO_pre threads, ended with $OSTIO_post"
7367 run_test 115 "verify dynamic thread creation===================="
7370 wait_delete_completed
7371 AVAIL=($(lctl get_param -n osc.*[oO][sS][cC]-[^M]*.kbytesavail))
7372 echo OST kbytes available: ${AVAIL[@]}
7373 MAXI=0; MAXV=${AVAIL[0]}
7374 MINI=0; MINV=${AVAIL[0]}
7375 for ((i = 0; i < ${#AVAIL[@]}; i++)); do
7376 #echo OST $i: ${AVAIL[i]}kb
7377 if [[ ${AVAIL[i]} -gt $MAXV ]]; then
7378 MAXV=${AVAIL[i]}; MAXI=$i
7380 if [[ ${AVAIL[i]} -lt $MINV ]]; then
7381 MINV=${AVAIL[i]}; MINI=$i
7384 echo Min free space: OST $MINI: $MINV
7385 echo Max free space: OST $MAXI: $MAXV
7388 test_116a() { # was previously test_116()
7389 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7390 remote_mds_nodsh && skip "remote MDS with nodsh" && return
7392 [[ $OSTCOUNT -lt 2 ]] && skip_env "$OSTCOUNT < 2 OSTs" && return
7394 echo -n "Free space priority "
7395 do_facet $SINGLEMDS lctl get_param -n lo*.*-mdtlov.qos_prio_free |
7400 [ $MINV -eq 0 ] && skip "no free space in OST$MINI, skip" && return
7401 [ $MINV -gt 10000000 ] && skip "too much free space in OST$MINI, skip" \
7403 trap simple_cleanup_common EXIT
7406 # Check if we need to generate uneven OSTs
7407 test_mkdir -p $DIR/$tdir/OST${MINI}
7408 local FILL=$(($MINV / 4))
7409 local DIFF=$(($MAXV - $MINV))
7410 local DIFF2=$(($DIFF * 100 / $MINV))
7412 local threshold=$(do_facet $SINGLEMDS \
7413 lctl get_param -n *.*MDT0000-mdtlov.qos_threshold_rr | head -n1)
7414 threshold=${threshold%%%}
7415 echo -n "Check for uneven OSTs: "
7416 echo -n "diff=${DIFF}KB (${DIFF2}%) must be > ${threshold}% ..."
7418 if [[ $DIFF2 -gt $threshold ]]; then
7420 echo "Don't need to fill OST$MINI"
7422 # generate uneven OSTs. Write 2% over the QOS threshold value
7424 DIFF=$(($threshold - $DIFF2 + 2))
7425 DIFF2=$(( ($MINV * $DIFF)/100 ))
7426 echo "Fill ${DIFF}% remaining space in OST${MINI} with ${DIFF2}KB"
7427 $SETSTRIPE -i $MINI -c 1 $DIR/$tdir/OST${MINI} ||
7428 error "setstripe failed"
7429 DIFF=$(($DIFF2 / 2048))
7431 while [ $i -lt $DIFF ]; do
7433 dd if=/dev/zero of=$DIR/$tdir/OST${MINI}/$tfile-$i \
7434 bs=2M count=1 2>/dev/null
7443 DIFF=$(($MAXV - $MINV))
7444 DIFF2=$(($DIFF * 100 / $MINV))
7445 echo -n "diff=${DIFF}=${DIFF2}% must be > ${threshold}% for QOS mode..."
7446 if [[ $DIFF2 -gt $threshold ]]; then
7449 echo "failed - QOS mode won't be used"
7450 skip "QOS imbalance criteria not met"
7451 simple_cleanup_common
7455 MINI1=$MINI; MINV1=$MINV
7456 MAXI1=$MAXI; MAXV1=$MAXV
7458 # now fill using QOS
7459 $SETSTRIPE -c 1 $DIR/$tdir
7460 FILL=$(($FILL / 200))
7461 if [ $FILL -gt 600 ]; then
7464 echo "writing $FILL files to QOS-assigned OSTs"
7466 while [ $i -lt $FILL ]; do
7468 dd if=/dev/zero of=$DIR/$tdir/$tfile-$i bs=200k \
7472 echo "wrote $i 200k files"
7476 echo "Note: free space may not be updated, so measurements might be off"
7478 DIFF2=$(($MAXV - $MINV))
7479 echo "free space delta: orig $DIFF final $DIFF2"
7480 [ $DIFF2 -gt $DIFF ] && echo "delta got worse!"
7481 DIFF=$(($MINV1 - ${AVAIL[$MINI1]}))
7482 echo "Wrote ${DIFF}KB to smaller OST $MINI1"
7483 DIFF2=$(($MAXV1 - ${AVAIL[$MAXI1]}))
7484 echo "Wrote ${DIFF2}KB to larger OST $MAXI1"
7485 FILL=$(($DIFF2 * 100 / $DIFF - 100))
7487 echo "Wrote ${FILL}% more data to larger OST $MAXI1"
7489 # Figure out which files were written where
7490 UUID=$(lctl get_param -n lov.${FSNAME}-clilov-*.target_obd |
7491 awk '/'$MINI1': / {print $2; exit}')
7493 MINC=$($GETSTRIPE --ost $UUID $DIR/$tdir | grep $DIR | wc -l)
7494 echo "$MINC files created on smaller OST $MINI1"
7495 UUID=$(lctl get_param -n lov.${FSNAME}-clilov-*.target_obd |
7496 awk '/'$MAXI1': / {print $2; exit}')
7498 MAXC=$($GETSTRIPE --ost $UUID $DIR/$tdir | grep $DIR | wc -l)
7499 echo "$MAXC files created on larger OST $MAXI1"
7500 FILL=$(($MAXC * 100 / $MINC - 100))
7501 [[ $MINC -gt 0 ]] &&
7502 echo "Wrote ${FILL}% more files to larger OST $MAXI1"
7503 [[ $MAXC -gt $MINC ]] ||
7504 error_ignore LU-9 "stripe QOS didn't balance free space"
7505 simple_cleanup_common
7507 run_test 116a "stripe QOS: free space balance ==================="
7509 test_116b() { # LU-2093
7510 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7511 remote_mds_nodsh && skip "remote MDS with nodsh" && return
7513 #define OBD_FAIL_MDS_OSC_CREATE_FAIL 0x147
7514 local old_rr=$(do_facet $SINGLEMDS lctl get_param -n \
7515 lo*.$FSNAME-MDT0000-mdtlov.qos_threshold_rr | head -1)
7516 [ -z "$old_rr" ] && skip "no QOS" && return 0
7517 do_facet $SINGLEMDS lctl set_param \
7518 lo*.$FSNAME-MDT0000-mdtlov.qos_threshold_rr=0
7520 do_facet $SINGLEMDS lctl set_param fail_loc=0x147
7521 createmany -o $DIR/$tdir/f- 20 || error "can't create"
7522 do_facet $SINGLEMDS lctl set_param fail_loc=0
7524 do_facet $SINGLEMDS lctl set_param \
7525 lo*.$FSNAME-MDT0000-mdtlov.qos_threshold_rr=$old_rr
7527 run_test 116b "QoS shouldn't LBUG if not enough OSTs found on the 2nd pass"
7529 test_117() # bug 10891
7531 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7532 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1
7533 #define OBD_FAIL_OST_SETATTR_CREDITS 0x21e
7534 lctl set_param fail_loc=0x21e
7535 > $DIR/$tfile || error "truncate failed"
7536 lctl set_param fail_loc=0
7537 echo "Truncate succeeded."
7540 run_test 117 "verify osd extend =========="
7542 NO_SLOW_RESENDCOUNT=4
7543 export OLD_RESENDCOUNT=""
7544 set_resend_count () {
7545 local PROC_RESENDCOUNT="osc.${FSNAME}-OST*-osc-*.resend_count"
7546 OLD_RESENDCOUNT=$(lctl get_param -n $PROC_RESENDCOUNT | head -n1)
7547 lctl set_param -n $PROC_RESENDCOUNT $1
7548 echo resend_count is set to $(lctl get_param -n $PROC_RESENDCOUNT)
7551 # for reduce test_118* time (b=14842)
7552 [ "$SLOW" = "no" ] && set_resend_count $NO_SLOW_RESENDCOUNT
7554 # Reset async IO behavior after error case
7556 FILE=$DIR/reset_async
7558 # Ensure all OSCs are cleared
7559 $SETSTRIPE -c -1 $FILE
7560 dd if=/dev/zero of=$FILE bs=64k count=$OSTCOUNT
7565 test_118a() #bug 11710
7567 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7570 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
7571 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
7572 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
7574 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
7575 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
7580 run_test 118a "verify O_SYNC works =========="
7584 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7585 remote_ost_nodsh && skip "remote OST with nodsh" && return
7589 #define OBD_FAIL_SRV_ENOENT 0x217
7590 set_nodes_failloc "$(osts_nodes)" 0x217
7591 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
7593 set_nodes_failloc "$(osts_nodes)" 0
7594 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
7595 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
7598 if [[ $RC -eq 0 ]]; then
7599 error "Must return error due to dropped pages, rc=$RC"
7603 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
7604 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
7608 echo "Dirty pages not leaked on ENOENT"
7610 # Due to the above error the OSC will issue all RPCs syncronously
7611 # until a subsequent RPC completes successfully without error.
7612 $MULTIOP $DIR/$tfile Ow4096yc
7617 run_test 118b "Reclaim dirty pages on fatal error =========="
7621 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7623 # for 118c, restore the original resend count, LU-1940
7624 [ "$SLOW" = "no" ] && [ -n "$OLD_RESENDCOUNT" ] &&
7625 set_resend_count $OLD_RESENDCOUNT
7626 remote_ost_nodsh && skip "remote OST with nodsh" && return
7630 #define OBD_FAIL_OST_EROFS 0x216
7631 set_nodes_failloc "$(osts_nodes)" 0x216
7633 # multiop should block due to fsync until pages are written
7634 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
7638 if [[ `ps h -o comm -p $MULTIPID` != "multiop" ]]; then
7639 error "Multiop failed to block on fsync, pid=$MULTIPID"
7642 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
7644 if [[ $WRITEBACK -eq 0 ]]; then
7645 error "No page in writeback, writeback=$WRITEBACK"
7648 set_nodes_failloc "$(osts_nodes)" 0
7651 if [[ $RC -ne 0 ]]; then
7652 error "Multiop fsync failed, rc=$RC"
7655 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
7656 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
7658 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
7659 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
7663 echo "Dirty pages flushed via fsync on EROFS"
7666 run_test 118c "Fsync blocks on EROFS until dirty pages are flushed =========="
7668 # continue to use small resend count to reduce test_118* time (b=14842)
7669 [ "$SLOW" = "no" ] && set_resend_count $NO_SLOW_RESENDCOUNT
7673 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7674 remote_ost_nodsh && skip "remote OST with nodsh" && return
7678 #define OBD_FAIL_OST_BRW_PAUSE_BULK
7679 set_nodes_failloc "$(osts_nodes)" 0x214
7680 # multiop should block due to fsync until pages are written
7681 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
7685 if [[ `ps h -o comm -p $MULTIPID` != "multiop" ]]; then
7686 error "Multiop failed to block on fsync, pid=$MULTIPID"
7689 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
7691 if [[ $WRITEBACK -eq 0 ]]; then
7692 error "No page in writeback, writeback=$WRITEBACK"
7695 wait $MULTIPID || error "Multiop fsync failed, rc=$?"
7696 set_nodes_failloc "$(osts_nodes)" 0
7698 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
7699 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
7701 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
7702 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
7706 echo "Dirty pages gaurenteed flushed via fsync"
7709 run_test 118d "Fsync validation inject a delay of the bulk =========="
7712 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7715 #define OBD_FAIL_OSC_BRW_PREP_REQ2 0x40a
7716 lctl set_param fail_loc=0x8000040a
7718 # Should simulate EINVAL error which is fatal
7719 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
7721 if [[ $RC -eq 0 ]]; then
7722 error "Must return error due to dropped pages, rc=$RC"
7725 lctl set_param fail_loc=0x0
7727 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
7728 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
7729 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
7731 if [[ $LOCKED -ne 0 ]]; then
7732 error "Locked pages remain in cache, locked=$LOCKED"
7735 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
7736 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
7740 echo "No pages locked after fsync"
7745 run_test 118f "Simulate unrecoverable OSC side error =========="
7748 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7751 #define OBD_FAIL_OSC_BRW_PREP_REQ 0x406
7752 lctl set_param fail_loc=0x406
7754 # simulate local -ENOMEM
7755 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
7758 lctl set_param fail_loc=0
7759 if [[ $RC -eq 0 ]]; then
7760 error "Must return error due to dropped pages, rc=$RC"
7763 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
7764 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
7765 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
7767 if [[ $LOCKED -ne 0 ]]; then
7768 error "Locked pages remain in cache, locked=$LOCKED"
7771 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
7772 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
7776 echo "No pages locked after fsync"
7781 run_test 118g "Don't stay in wait if we got local -ENOMEM =========="
7784 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7785 remote_ost_nodsh && skip "remote OST with nodsh" && return
7789 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
7790 set_nodes_failloc "$(osts_nodes)" 0x20e
7791 # Should simulate ENOMEM error which is recoverable and should be handled by timeout
7792 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
7795 set_nodes_failloc "$(osts_nodes)" 0
7796 if [[ $RC -eq 0 ]]; then
7797 error "Must return error due to dropped pages, rc=$RC"
7800 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
7801 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
7802 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
7804 if [[ $LOCKED -ne 0 ]]; then
7805 error "Locked pages remain in cache, locked=$LOCKED"
7808 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
7809 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
7813 echo "No pages locked after fsync"
7817 run_test 118h "Verify timeout in handling recoverables errors =========="
7819 [ "$SLOW" = "no" ] && [ -n "$OLD_RESENDCOUNT" ] && set_resend_count $OLD_RESENDCOUNT
7822 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7823 remote_ost_nodsh && skip "remote OST with nodsh" && return
7827 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
7828 set_nodes_failloc "$(osts_nodes)" 0x20e
7830 # Should simulate ENOMEM error which is recoverable and should be handled by timeout
7831 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
7834 set_nodes_failloc "$(osts_nodes)" 0
7838 if [[ $RC -ne 0 ]]; then
7839 error "got error, but should be not, rc=$RC"
7842 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
7843 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
7844 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
7845 if [[ $LOCKED -ne 0 ]]; then
7846 error "Locked pages remain in cache, locked=$LOCKED"
7849 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
7850 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
7854 echo "No pages locked after fsync"
7858 run_test 118i "Fix error before timeout in recoverable error =========="
7860 [ "$SLOW" = "no" ] && set_resend_count 4
7863 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7864 remote_ost_nodsh && skip "remote OST with nodsh" && return
7868 #define OBD_FAIL_OST_BRW_WRITE_BULK2 0x220
7869 set_nodes_failloc "$(osts_nodes)" 0x220
7871 # return -EIO from OST
7872 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
7874 set_nodes_failloc "$(osts_nodes)" 0x0
7875 if [[ $RC -eq 0 ]]; then
7876 error "Must return error due to dropped pages, rc=$RC"
7879 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
7880 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
7881 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
7882 if [[ $LOCKED -ne 0 ]]; then
7883 error "Locked pages remain in cache, locked=$LOCKED"
7886 # in recoverable error on OST we want resend and stay until it finished
7887 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
7888 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
7892 echo "No pages locked after fsync"
7896 run_test 118j "Simulate unrecoverable OST side error =========="
7900 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7901 remote_ost_nodsh && skip "remote OSTs with nodsh" && return
7903 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
7904 set_nodes_failloc "$(osts_nodes)" 0x20e
7905 test_mkdir -p $DIR/$tdir
7907 for ((i=0;i<10;i++)); do
7908 (dd if=/dev/zero of=$DIR/$tdir/$tfile-$i bs=1M count=10 || \
7909 error "dd to $DIR/$tdir/$tfile-$i failed" )&
7916 set_nodes_failloc "$(osts_nodes)" 0
7919 run_test 118k "bio alloc -ENOMEM and IO TERM handling ========="
7923 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7925 test_mkdir -p $DIR/$tdir
7926 $MULTIOP $DIR/$tdir Dy || error "fsync dir failed"
7929 run_test 118l "fsync dir ========="
7931 test_118m() # LU-3066
7933 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7934 test_mkdir -p $DIR/$tdir
7935 $MULTIOP $DIR/$tdir DY || error "fdatasync dir failed"
7938 run_test 118m "fdatasync dir ========="
7940 [ "$SLOW" = "no" ] && [ -n "$OLD_RESENDCOUNT" ] && set_resend_count $OLD_RESENDCOUNT
7942 test_119a() # bug 11737
7944 BSIZE=$((512 * 1024))
7945 directio write $DIR/$tfile 0 1 $BSIZE
7946 # We ask to read two blocks, which is more than a file size.
7947 # directio will indicate an error when requested and actual
7948 # sizes aren't equeal (a normal situation in this case) and
7949 # print actual read amount.
7950 NOB=`directio read $DIR/$tfile 0 2 $BSIZE | awk '/error/ {print $6}'`
7951 if [ "$NOB" != "$BSIZE" ]; then
7952 error "read $NOB bytes instead of $BSIZE"
7956 run_test 119a "Short directIO read must return actual read amount"
7958 test_119b() # bug 11737
7960 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping 2-stripe test" && return
7962 $SETSTRIPE -c 2 $DIR/$tfile || error "setstripe failed"
7963 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=1 || error "dd failed"
7965 $MULTIOP $DIR/$tfile oO_RDONLY:O_DIRECT:r$((2048 * 1024)) || \
7966 error "direct read failed"
7969 run_test 119b "Sparse directIO read must return actual read amount"
7971 test_119c() # bug 13099
7974 directio write $DIR/$tfile 3 1 $BSIZE || error "direct write failed"
7975 directio readhole $DIR/$tfile 0 2 $BSIZE || error "reading hole failed"
7978 run_test 119c "Testing for direct read hitting hole"
7980 test_119d() # bug 15950
7982 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7983 MAX_RPCS_IN_FLIGHT=`$LCTL get_param -n osc.*OST0000-osc-[^mM]*.max_rpcs_in_flight`
7984 $LCTL set_param -n osc.*OST0000-osc-[^mM]*.max_rpcs_in_flight 1
7986 $SETSTRIPE $DIR/$tfile -i 0 -c 1 || error "setstripe failed"
7987 $DIRECTIO write $DIR/$tfile 0 1 $BSIZE || error "first directio failed"
7988 #define OBD_FAIL_OSC_DIO_PAUSE 0x40d
7989 lctl set_param fail_loc=0x40d
7990 $DIRECTIO write $DIR/$tfile 1 4 $BSIZE &
7993 cat $DIR/$tfile > /dev/null &
7994 lctl set_param fail_loc=0
7997 log "the DIO writes have completed, now wait for the reads (should not block very long)"
7999 [ -n "`ps h -p $pid_reads -o comm`" ] && \
8000 error "the read rpcs have not completed in 2s"
8002 $LCTL set_param -n osc.*OST0000-osc-[^mM]*.max_rpcs_in_flight $MAX_RPCS_IN_FLIGHT
8004 run_test 119d "The DIO path should try to send a new rpc once one is completed"
8007 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8008 test_mkdir -p $DIR/$tdir
8009 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
8010 skip "no early lock cancel on server" && return 0
8012 lru_resize_disable mdc
8013 lru_resize_disable osc
8014 cancel_lru_locks mdc
8015 # asynchronous object destroy at MDT could cause bl ast to client
8016 cancel_lru_locks osc
8018 stat $DIR/$tdir > /dev/null
8019 can1=$(do_facet $SINGLEMDS \
8020 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8021 awk '/ldlm_cancel/ {print $2}')
8022 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8023 awk '/ldlm_bl_callback/ {print $2}')
8024 test_mkdir -c1 $DIR/$tdir/d1
8025 can2=$(do_facet $SINGLEMDS \
8026 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8027 awk '/ldlm_cancel/ {print $2}')
8028 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8029 awk '/ldlm_bl_callback/ {print $2}')
8030 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
8031 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
8032 lru_resize_enable mdc
8033 lru_resize_enable osc
8035 run_test 120a "Early Lock Cancel: mkdir test"
8038 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8039 test_mkdir $DIR/$tdir
8040 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel)" ] && \
8041 skip "no early lock cancel on server" && return 0
8042 lru_resize_disable mdc
8043 lru_resize_disable osc
8044 cancel_lru_locks mdc
8045 stat $DIR/$tdir > /dev/null
8046 can1=$(do_facet $SINGLEMDS \
8047 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8048 awk '/ldlm_cancel/ {print $2}')
8049 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8050 awk '/ldlm_bl_callback/ {print $2}')
8052 can2=$(do_facet $SINGLEMDS \
8053 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8054 awk '/ldlm_cancel/ {print $2}')
8055 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8056 awk '/ldlm_bl_callback/ {print $2}')
8057 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
8058 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
8059 lru_resize_enable mdc
8060 lru_resize_enable osc
8062 run_test 120b "Early Lock Cancel: create test"
8065 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8066 test_mkdir -c1 $DIR/$tdir
8067 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel)" ] && \
8068 skip "no early lock cancel on server" && return 0
8069 lru_resize_disable mdc
8070 lru_resize_disable osc
8071 test_mkdir -p -c1 $DIR/$tdir/d1
8072 test_mkdir -p -c1 $DIR/$tdir/d2
8073 touch $DIR/$tdir/d1/f1
8074 cancel_lru_locks mdc
8075 stat $DIR/$tdir/d1 $DIR/$tdir/d2 $DIR/$tdir/d1/f1 > /dev/null
8076 can1=$(do_facet $SINGLEMDS \
8077 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8078 awk '/ldlm_cancel/ {print $2}')
8079 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8080 awk '/ldlm_bl_callback/ {print $2}')
8081 ln $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2
8082 can2=$(do_facet $SINGLEMDS \
8083 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8084 awk '/ldlm_cancel/ {print $2}')
8085 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8086 awk '/ldlm_bl_callback/ {print $2}')
8087 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
8088 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
8089 lru_resize_enable mdc
8090 lru_resize_enable osc
8092 run_test 120c "Early Lock Cancel: link test"
8095 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8096 test_mkdir -p -c1 $DIR/$tdir
8097 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel)" ] && \
8098 skip "no early lock cancel on server" && return 0
8099 lru_resize_disable mdc
8100 lru_resize_disable osc
8102 cancel_lru_locks mdc
8103 stat $DIR/$tdir > /dev/null
8104 can1=$(do_facet $SINGLEMDS \
8105 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8106 awk '/ldlm_cancel/ {print $2}')
8107 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8108 awk '/ldlm_bl_callback/ {print $2}')
8109 chmod a+x $DIR/$tdir
8110 can2=$(do_facet $SINGLEMDS \
8111 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8112 awk '/ldlm_cancel/ {print $2}')
8113 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8114 awk '/ldlm_bl_callback/ {print $2}')
8115 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
8116 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
8117 lru_resize_enable mdc
8118 lru_resize_enable osc
8120 run_test 120d "Early Lock Cancel: setattr test"
8123 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8124 test_mkdir -p -c1 $DIR/$tdir
8125 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
8126 skip "no early lock cancel on server" && return 0
8127 lru_resize_disable mdc
8128 lru_resize_disable osc
8129 dd if=/dev/zero of=$DIR/$tdir/f1 count=1
8130 cancel_lru_locks mdc
8131 cancel_lru_locks osc
8132 dd if=$DIR/$tdir/f1 of=/dev/null
8133 stat $DIR/$tdir $DIR/$tdir/f1 > /dev/null
8134 # XXX client can not do early lock cancel of OST lock
8135 # during unlink (LU-4206), so cancel osc lock now.
8136 cancel_lru_locks osc
8137 can1=$(do_facet $SINGLEMDS \
8138 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8139 awk '/ldlm_cancel/ {print $2}')
8140 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8141 awk '/ldlm_bl_callback/ {print $2}')
8142 unlink $DIR/$tdir/f1
8144 can2=$(do_facet $SINGLEMDS \
8145 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8146 awk '/ldlm_cancel/ {print $2}')
8147 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8148 awk '/ldlm_bl_callback/ {print $2}')
8149 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
8150 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
8151 lru_resize_enable mdc
8152 lru_resize_enable osc
8154 run_test 120e "Early Lock Cancel: unlink test"
8157 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8158 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
8159 skip "no early lock cancel on server" && return 0
8160 test_mkdir -p -c1 $DIR/$tdir
8161 lru_resize_disable mdc
8162 lru_resize_disable osc
8163 test_mkdir -p -c1 $DIR/$tdir/d1
8164 test_mkdir -p -c1 $DIR/$tdir/d2
8165 dd if=/dev/zero of=$DIR/$tdir/d1/f1 count=1
8166 dd if=/dev/zero of=$DIR/$tdir/d2/f2 count=1
8167 cancel_lru_locks mdc
8168 cancel_lru_locks osc
8169 dd if=$DIR/$tdir/d1/f1 of=/dev/null
8170 dd if=$DIR/$tdir/d2/f2 of=/dev/null
8171 stat $DIR/$tdir/d1 $DIR/$tdir/d2 $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2 > /dev/null
8172 # XXX client can not do early lock cancel of OST lock
8173 # during rename (LU-4206), so cancel osc lock now.
8174 cancel_lru_locks osc
8175 can1=$(do_facet $SINGLEMDS \
8176 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8177 awk '/ldlm_cancel/ {print $2}')
8178 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8179 awk '/ldlm_bl_callback/ {print $2}')
8180 mrename $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2
8182 can2=$(do_facet $SINGLEMDS \
8183 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8184 awk '/ldlm_cancel/ {print $2}')
8185 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8186 awk '/ldlm_bl_callback/ {print $2}')
8187 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
8188 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
8189 lru_resize_enable mdc
8190 lru_resize_enable osc
8192 run_test 120f "Early Lock Cancel: rename test"
8195 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8196 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
8197 skip "no early lock cancel on server" && return 0
8198 lru_resize_disable mdc
8199 lru_resize_disable osc
8201 echo create $count files
8202 test_mkdir -p $DIR/$tdir
8203 cancel_lru_locks mdc
8204 cancel_lru_locks osc
8207 can0=$(do_facet $SINGLEMDS \
8208 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8209 awk '/ldlm_cancel/ {print $2}')
8210 blk0=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8211 awk '/ldlm_bl_callback/ {print $2}')
8212 createmany -o $DIR/$tdir/f $count
8214 can1=$(do_facet $SINGLEMDS \
8215 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8216 awk '/ldlm_cancel/ {print $2}')
8217 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8218 awk '/ldlm_bl_callback/ {print $2}')
8220 echo total: $((can1-can0)) cancels, $((blk1-blk0)) blockings
8221 echo rm $count files
8224 can2=$(do_facet $SINGLEMDS \
8225 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8226 awk '/ldlm_cancel/ {print $2}')
8227 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8228 awk '/ldlm_bl_callback/ {print $2}')
8230 echo total: $count removes in $((t2-t1))
8231 echo total: $((can2-can1)) cancels, $((blk2-blk1)) blockings
8233 # wait for commitment of removal
8234 lru_resize_enable mdc
8235 lru_resize_enable osc
8237 run_test 120g "Early Lock Cancel: performance test"
8239 test_121() { #bug #10589
8240 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8242 writes=$(LANG=C dd if=/dev/zero of=$DIR/$tfile count=1 2>&1 | awk -F '+' '/out$/ {print $1}')
8243 #define OBD_FAIL_LDLM_CANCEL_RACE 0x310
8244 lctl set_param fail_loc=0x310
8245 cancel_lru_locks osc > /dev/null
8246 reads=$(LANG=C dd if=$DIR/$tfile of=/dev/null 2>&1 | awk -F '+' '/in$/ {print $1}')
8247 lctl set_param fail_loc=0
8248 [[ $reads -eq $writes ]] ||
8249 error "read $reads blocks, must be $writes blocks"
8251 run_test 121 "read cancel race ========="
8253 test_123a() { # was test 123, statahead(bug 11401)
8254 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8256 if [ -z "$(grep "processor.*: 1" /proc/cpuinfo)" ]; then
8257 log "testing on UP system. Performance may be not as good as expected."
8262 test_mkdir -p $DIR/$tdir
8263 NUMFREE=$(df -i -P $DIR | tail -n 1 | awk '{ print $4 }')
8264 [[ $NUMFREE -gt 100000 ]] && NUMFREE=100000 || NUMFREE=$((NUMFREE-1000))
8266 for ((i=100, j=0; i<=$NUMFREE; j=$i, i=$((i * MULT)) )); do
8267 createmany -o $DIR/$tdir/$tfile $j $((i - j))
8269 max=`lctl get_param -n llite.*.statahead_max | head -n 1`
8270 lctl set_param -n llite.*.statahead_max 0
8271 lctl get_param llite.*.statahead_max
8272 cancel_lru_locks mdc
8273 cancel_lru_locks osc
8275 time ls -l $DIR/$tdir | wc -l
8277 delta=$((etime - stime))
8278 log "ls $i files without statahead: $delta sec"
8279 lctl set_param llite.*.statahead_max=$max
8281 swrong=`lctl get_param -n llite.*.statahead_stats | grep "statahead wrong:" | awk '{print $3}'`
8282 lctl get_param -n llite.*.statahead_max | grep '[0-9]'
8283 cancel_lru_locks mdc
8284 cancel_lru_locks osc
8286 time ls -l $DIR/$tdir | wc -l
8288 delta_sa=$((etime - stime))
8289 log "ls $i files with statahead: $delta_sa sec"
8290 lctl get_param -n llite.*.statahead_stats
8291 ewrong=`lctl get_param -n llite.*.statahead_stats | grep "statahead wrong:" | awk '{print $3}'`
8293 [[ $swrong -lt $ewrong ]] &&
8294 log "statahead was stopped, maybe too many locks held!"
8295 [[ $delta -eq 0 || $delta_sa -eq 0 ]] && continue
8297 if [ $((delta_sa * 100)) -gt $((delta * 105)) -a $delta_sa -gt $((delta + 2)) ]; then
8298 max=`lctl get_param -n llite.*.statahead_max | head -n 1`
8299 lctl set_param -n llite.*.statahead_max 0
8300 lctl get_param llite.*.statahead_max
8301 cancel_lru_locks mdc
8302 cancel_lru_locks osc
8304 time ls -l $DIR/$tdir | wc -l
8306 delta=$((etime - stime))
8307 log "ls $i files again without statahead: $delta sec"
8308 lctl set_param llite.*.statahead_max=$max
8309 if [ $((delta_sa * 100)) -gt $((delta * 105)) -a $delta_sa -gt $((delta + 2)) ]; then
8310 if [ $SLOWOK -eq 0 ]; then
8311 error "ls $i files is slower with statahead!"
8313 log "ls $i files is slower with statahead!"
8319 [ $delta -gt 20 ] && break
8320 [ $delta -gt 8 ] && MULT=$((50 / delta))
8321 [ "$SLOW" = "no" -a $delta -gt 5 ] && break
8329 delta=$((etime - stime))
8330 log "rm -r $DIR/$tdir/: $delta seconds"
8332 lctl get_param -n llite.*.statahead_stats
8334 run_test 123a "verify statahead work"
8336 test_123b () { # statahead(bug 15027)
8337 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8338 test_mkdir -p $DIR/$tdir
8339 createmany -o $DIR/$tdir/$tfile-%d 1000
8341 cancel_lru_locks mdc
8342 cancel_lru_locks osc
8344 #define OBD_FAIL_MDC_GETATTR_ENQUEUE 0x803
8345 lctl set_param fail_loc=0x80000803
8346 ls -lR $DIR/$tdir > /dev/null
8348 lctl set_param fail_loc=0x0
8349 lctl get_param -n llite.*.statahead_stats
8354 run_test 123b "not panic with network error in statahead enqueue (bug 15027)"
8357 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8358 [ -z "$($LCTL get_param -n mdc.*.connect_flags | grep lru_resize)" ] &&
8359 skip "no lru resize on server" && return 0
8361 test_mkdir -p $DIR/$tdir || error "failed to create $DIR/$tdir"
8363 log "create $NR files at $DIR/$tdir"
8364 createmany -o $DIR/$tdir/f $NR ||
8365 error "failed to create $NR files in $DIR/$tdir"
8367 cancel_lru_locks mdc
8368 ls -l $DIR/$tdir > /dev/null
8372 for VALUE in $($LCTL get_param ldlm.namespaces.*mdc-*.lru_size); do
8373 local PARAM=$(echo ${VALUE[0]} | cut -d "=" -f1)
8374 LRU_SIZE=$($LCTL get_param -n $PARAM)
8375 if [[ $LRU_SIZE -gt $(default_lru_size) ]]; then
8376 NSDIR=$(echo $PARAM | cut -d "." -f1-3)
8378 log "NS=$(basename $NSDIR)"
8383 if [[ -z "$NSDIR" || $LRU_SIZE -lt $(default_lru_size) ]]; then
8384 skip "Not enough cached locks created!"
8391 # We know that lru resize allows one client to hold $LIMIT locks
8392 # for 10h. After that locks begin to be killed by client.
8394 local LIMIT=$($LCTL get_param -n $NSDIR.pool.limit)
8396 if [ $LIMIT -lt $LRU_SIZE ]; then
8397 skip "Limit is too small $LIMIT"
8401 # Make LVF so higher that sleeping for $SLEEP is enough to _start_
8402 # killing locks. Some time was spent for creating locks. This means
8403 # that up to the moment of sleep finish we must have killed some of
8404 # them (10-100 locks). This depends on how fast ther were created.
8405 # Many of them were touched in almost the same moment and thus will
8406 # be killed in groups.
8407 local LVF=$(($MAX_HRS * 60 * 60 / $SLEEP * $LIMIT / $LRU_SIZE))
8409 # Use $LRU_SIZE_B here to take into account real number of locks
8410 # created in the case of CMD, LRU_SIZE_B != $NR in most of cases
8411 local LRU_SIZE_B=$LRU_SIZE
8413 local OLD_LVF=$($LCTL get_param -n $NSDIR.pool.lock_volume_factor)
8414 log "OLD_LVF=$OLD_LVF"
8415 $LCTL set_param -n $NSDIR.pool.lock_volume_factor $LVF
8417 # Let's make sure that we really have some margin. Client checks
8418 # cached locks every 10 sec.
8420 log "Sleep ${SLEEP} sec"
8422 while ((SEC<$SLEEP)); do
8426 LRU_SIZE=$($LCTL get_param -n $NSDIR/lru_size)
8430 $LCTL set_param -n $NSDIR.pool.lock_volume_factor $OLD_LVF
8431 local LRU_SIZE_A=$($LCTL get_param -n $NSDIR.lru_size)
8433 [[ $LRU_SIZE_B -gt $LRU_SIZE_A ]] || {
8434 error "No locks dropped in ${SLEEP}s. LRU size: $LRU_SIZE_A"
8435 unlinkmany $DIR/$tdir/f $NR
8439 log "Dropped "$((LRU_SIZE_B-LRU_SIZE_A))" locks in ${SLEEP}s"
8440 log "unlink $NR files at $DIR/$tdir"
8441 unlinkmany $DIR/$tdir/f $NR
8443 run_test 124a "lru resize ======================================="
8445 get_max_pool_limit()
8447 local limit=$($LCTL get_param \
8448 -n ldlm.namespaces.*-MDT0000-mdc-*.pool.limit)
8451 if [[ $l -gt $max ]]; then
8459 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8460 [ -z "$($LCTL get_param -n mdc.*.connect_flags | grep lru_resize)" ] &&
8461 skip "no lru resize on server" && return 0
8463 LIMIT=$(get_max_pool_limit)
8465 NR=$(($(default_lru_size)*20))
8466 if [[ $NR -gt $LIMIT ]]; then
8467 log "Limit lock number by $LIMIT locks"
8470 lru_resize_disable mdc
8471 test_mkdir -p $DIR/$tdir/disable_lru_resize ||
8472 error "failed to create $DIR/$tdir/disable_lru_resize"
8474 createmany -o $DIR/$tdir/disable_lru_resize/f $NR
8475 log "doing ls -la $DIR/$tdir/disable_lru_resize 3 times"
8476 cancel_lru_locks mdc
8479 ls -la $DIR/$tdir/disable_lru_resize > /dev/null &
8482 ls -la $DIR/$tdir/disable_lru_resize > /dev/null &
8485 ls -la $DIR/$tdir/disable_lru_resize > /dev/null &
8489 nolruresize_delta=$((etime-stime))
8490 log "ls -la time: $nolruresize_delta seconds"
8491 log "lru_size = $(lctl get_param -n ldlm.namespaces.*mdc*.lru_size)"
8492 unlinkmany $DIR/$tdir/disable_lru_resize/f $NR
8494 lru_resize_enable mdc
8495 test_mkdir -p $DIR/$tdir/enable_lru_resize ||
8496 error "failed to create $DIR/$tdir/enable_lru_resize"
8498 createmany -o $DIR/$tdir/enable_lru_resize/f $NR
8499 log "doing ls -la $DIR/$tdir/enable_lru_resize 3 times"
8500 cancel_lru_locks mdc
8503 ls -la $DIR/$tdir/enable_lru_resize > /dev/null &
8506 ls -la $DIR/$tdir/enable_lru_resize > /dev/null &
8509 ls -la $DIR/$tdir/enable_lru_resize > /dev/null &
8513 lruresize_delta=$((etime-stime))
8514 log "ls -la time: $lruresize_delta seconds"
8515 log "lru_size = $(lctl get_param -n ldlm.namespaces.*mdc*.lru_size)"
8517 if [ $lruresize_delta -gt $nolruresize_delta ]; then
8518 log "ls -la is $(((lruresize_delta - $nolruresize_delta) * 100 / $nolruresize_delta))% slower with lru resize enabled"
8519 elif [ $nolruresize_delta -gt $lruresize_delta ]; then
8520 log "ls -la is $(((nolruresize_delta - $lruresize_delta) * 100 / $nolruresize_delta))% faster with lru resize enabled"
8522 log "lru resize performs the same with no lru resize"
8524 unlinkmany $DIR/$tdir/enable_lru_resize/f $NR
8526 run_test 124b "lru resize (performance test) ======================="
8529 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8530 [ -z "$($LCTL get_param -n mdc.*.connect_flags | grep lru_resize)" ] &&
8531 skip "no lru resize on server" && return 0
8533 # cache ununsed locks on client
8535 cancel_lru_locks mdc
8536 test_mkdir -p $DIR/$tdir || error "failed to create $DIR/$tdir"
8537 createmany -o $DIR/$tdir/f $nr ||
8538 error "failed to create $nr files in $DIR/$tdir"
8539 ls -l $DIR/$tdir > /dev/null
8541 local nsdir="ldlm.namespaces.*-MDT0000-mdc-*"
8542 local unused=$($LCTL get_param -n $nsdir.lock_unused_count)
8543 local max_age=$($LCTL get_param -n $nsdir.lru_max_age)
8544 local recalc_p=$($LCTL get_param -n $nsdir.pool.recalc_period)
8545 echo "unused=$unused, max_age=$max_age, recalc_p=$recalc_p"
8547 # set lru_max_age to 1 sec
8548 $LCTL set_param $nsdir.lru_max_age=1000 # jiffies
8549 echo "sleep $((recalc_p * 2)) seconds..."
8550 sleep $((recalc_p * 2))
8552 local remaining=$($LCTL get_param -n $nsdir.lock_unused_count)
8553 # restore lru_max_age
8554 $LCTL set_param -n $nsdir.lru_max_age $max_age
8555 [ $remaining -eq 0 ] || error "$remaining locks are not canceled"
8556 unlinkmany $DIR/$tdir/f $nr
8558 run_test 124c "LRUR cancel very aged locks"
8560 test_125() { # 13358
8561 [ -z "$(lctl get_param -n llite.*.client_type | grep local)" ] && skip "must run as local client" && return
8562 [ -z "$(lctl get_param -n mdc.*-mdc-*.connect_flags | grep acl)" ] && skip "must have acl enabled" && return
8563 [ -z "$(which setfacl)" ] && skip "must have setfacl tool" && return
8564 test_mkdir -p $DIR/d125 || error "mkdir failed"
8565 $SETSTRIPE -S 65536 -c -1 $DIR/d125 || error "setstripe failed"
8566 setfacl -R -m u:bin:rwx $DIR/d125 || error "setfacl $DIR/d125 failed"
8567 ls -ld $DIR/d125 || error "cannot access $DIR/d125"
8569 run_test 125 "don't return EPROTO when a dir has a non-default striping and ACLs"
8571 test_126() { # bug 12829/13455
8572 [ -z "$(lctl get_param -n llite.*.client_type | grep local)" ] && skip "must run as local client" && return
8573 [ "$UID" != 0 ] && skip_env "skipping $TESTNAME (must run as root)" && return
8574 $GSS && skip "must run as gss disabled" && return
8576 $RUNAS -u 0 -g 1 touch $DIR/$tfile || error "touch failed"
8577 gid=`ls -n $DIR/$tfile | awk '{print $4}'`
8579 [ $gid -eq "1" ] || error "gid is set to" $gid "instead of 1"
8581 run_test 126 "check that the fsgid provided by the client is taken into account"
8583 test_127a() { # bug 15521
8584 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8585 $SETSTRIPE -i 0 -c 1 $DIR/$tfile || error "setstripe failed"
8586 $LCTL set_param osc.*.stats=0
8587 FSIZE=$((2048 * 1024))
8588 dd if=/dev/zero of=$DIR/$tfile bs=$FSIZE count=1
8589 cancel_lru_locks osc
8590 dd if=$DIR/$tfile of=/dev/null bs=$FSIZE
8592 $LCTL get_param osc.*0000-osc-*.stats | grep samples > $DIR/${tfile}.tmp
8593 while read NAME COUNT SAMP UNIT MIN MAX SUM SUMSQ; do
8594 echo "got $COUNT $NAME"
8595 [ ! $MIN ] && error "Missing min value for $NAME proc entry"
8596 eval $NAME=$COUNT || error "Wrong proc format"
8599 read_bytes|write_bytes)
8600 [ $MIN -lt 4096 ] && error "min is too small: $MIN"
8601 [ $MIN -gt $FSIZE ] && error "min is too big: $MIN"
8602 [ $MAX -lt 4096 ] && error "max is too small: $MAX"
8603 [ $MAX -gt $FSIZE ] && error "max is too big: $MAX"
8604 [ $SUM -ne $FSIZE ] && error "sum is wrong: $SUM"
8605 [ $SUMSQ -lt $(((FSIZE /4096) * (4096 * 4096))) ] &&
8606 error "sumsquare is too small: $SUMSQ"
8607 [ $SUMSQ -gt $((FSIZE * FSIZE)) ] &&
8608 error "sumsquare is too big: $SUMSQ"
8612 done < $DIR/${tfile}.tmp
8614 #check that we actually got some stats
8615 [ "$read_bytes" ] || error "Missing read_bytes stats"
8616 [ "$write_bytes" ] || error "Missing write_bytes stats"
8617 [ "$read_bytes" != 0 ] || error "no read done"
8618 [ "$write_bytes" != 0 ] || error "no write done"
8620 run_test 127a "verify the client stats are sane"
8622 test_127b() { # bug LU-333
8623 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8624 $LCTL set_param llite.*.stats=0
8625 FSIZE=65536 # sized fixed to match PAGE_SIZE for most clients
8626 # perform 2 reads and writes so MAX is different from SUM.
8627 dd if=/dev/zero of=$DIR/$tfile bs=$FSIZE count=1
8628 dd if=/dev/zero of=$DIR/$tfile bs=$FSIZE count=1
8629 cancel_lru_locks osc
8630 dd if=$DIR/$tfile of=/dev/null bs=$FSIZE count=1
8631 dd if=$DIR/$tfile of=/dev/null bs=$FSIZE count=1
8633 $LCTL get_param llite.*.stats | grep samples > $TMP/${tfile}.tmp
8634 while read NAME COUNT SAMP UNIT MIN MAX SUM SUMSQ; do
8635 echo "got $COUNT $NAME"
8636 eval $NAME=$COUNT || error "Wrong proc format"
8640 [ $COUNT -ne 2 ] && error "count is not 2: $COUNT"
8641 [ $MIN -ne $FSIZE ] && error "min is not $FSIZE: $MIN"
8642 [ $MAX -ne $FSIZE ] && error "max is incorrect: $MAX"
8643 [ $SUM -ne $((FSIZE * 2)) ] && error "sum is wrong: $SUM"
8646 [ $COUNT -ne 2 ] && error "count is not 2: $COUNT"
8647 [ $MIN -ne $FSIZE ] && error "min is not $FSIZE: $MIN"
8648 [ $MAX -ne $FSIZE ] && error "max is incorrect: $MAX"
8649 [ $SUM -ne $((FSIZE * 2)) ] && error "sum is wrong: $SUM"
8653 done < $TMP/${tfile}.tmp
8655 #check that we actually got some stats
8656 [ "$read_bytes" ] || error "Missing read_bytes stats"
8657 [ "$write_bytes" ] || error "Missing write_bytes stats"
8658 [ "$read_bytes" != 0 ] || error "no read done"
8659 [ "$write_bytes" != 0 ] || error "no write done"
8661 run_test 127b "verify the llite client stats are sane"
8663 test_128() { # bug 15212
8665 $LFS 2>&1 <<-EOF | tee $TMP/$tfile.log
8670 result=$(grep error $TMP/$tfile.log)
8672 [ -z "$result" ] || error "consecutive find's under interactive lfs failed"
8674 run_test 128 "interactive lfs for 2 consecutive find's"
8681 local LDPROC=/proc/fs/ldiskfs
8682 local facets=$(get_facets MDS)
8684 for facet in ${facets//,/ }; do
8685 canondev=$(ldiskfs_canon \
8686 *.$(convert_facet2label $facet).mntdev $facet)
8687 do_facet $facet "test -e $LDPROC/$canondev/max_dir_size" ||
8688 LDPROC=/sys/fs/ldiskfs
8689 do_facet $facet "echo $1 >$LDPROC/$canondev/max_dir_size"
8694 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8695 if [ "$(facet_fstype $SINGLEMDS)" != ldiskfs ]; then
8696 skip "Only applicable to ldiskfs-based MDTs"
8699 remote_mds_nodsh && skip "remote MDS with nodsh" && return
8704 test_mkdir -p $DIR/$tdir
8706 # block size of mds1
8707 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
8708 local MDSBLOCKSIZE=$($LCTL get_param -n mdc.*MDT0000*.blocksize)
8709 local MAX=$((MDSBLOCKSIZE * 3))
8711 local I=$(stat -c%s "$DIR/$tdir")
8713 local STRIPE_COUNT=1
8714 [[ $MDSCOUNT -ge 2 ]] && STRIPE_COUNT=$($LFS getdirstripe -c $DIR/$tdir)
8715 MAX=$((MAX*STRIPE_COUNT))
8716 while [[ $I -le $MAX ]]; do
8717 $MULTIOP $DIR/$tdir/$J Oc
8719 #check two errors ENOSPC for new version of ext4 max_dir_size patch
8720 #mainline kernel commit df981d03eeff7971ac7e6ff37000bfa702327ef1
8721 #and EFBIG for previous versions
8722 if [ $rc -eq $EFBIG -o $rc -eq $ENOSPC ]; then
8724 echo "return code $rc received as expected"
8725 multiop $DIR/$tdir/$J Oc ||
8726 error_exit "multiop failed w/o dir size limit"
8728 I=$(stat -c%s "$DIR/$tdir")
8730 if [ $(lustre_version_code $SINGLEMDS) -lt \
8731 $(version_code 2.4.51) ]
8733 [[ $I -eq $MAX ]] && return 0
8735 [[ $I -gt $MAX ]] && return 0
8737 error_exit "current dir size $I, previous limit $MAX"
8738 elif [ $rc -ne 0 ]; then
8740 error_exit "return code $rc received instead of expected " \
8741 "$EFBIG or $ENOSPC, files in dir $I"
8744 I=$(stat -c%s "$DIR/$tdir")
8748 error "exceeded dir size limit $MAX($MDSCOUNT) : $I bytes"
8750 run_test 129 "test directory size limit ========================"
8759 local filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
8760 [ -n "$filefrag_op" ] && skip_env "filefrag does not support FIEMAP" &&
8763 trap cleanup_130 EXIT RETURN
8765 local fm_file=$DIR/$tfile
8766 $SETSTRIPE -S 65536 -c 1 $fm_file || error "setstripe on $fm_file"
8767 dd if=/dev/zero of=$fm_file bs=65536 count=1 ||
8768 error "dd failed for $fm_file"
8770 # LU-1795: test filefrag/FIEMAP once, even if unsupported
8771 filefrag -ves $fm_file
8773 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
8774 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
8775 [ $RC != 0 ] && error "filefrag $fm_file failed"
8777 filefrag_op=$(filefrag -ve $fm_file | grep -A 100 "ext:" |
8778 grep -v "ext:" | grep -v "found")
8779 lun=$($GETSTRIPE -i $fm_file)
8781 start_blk=`echo $filefrag_op | cut -d: -f2 | cut -d. -f1`
8784 for line in $filefrag_op
8786 frag_lun=`echo $line | cut -d: -f5`
8787 ext_len=`echo $line | cut -d: -f4`
8788 if (( $frag_lun != $lun )); then
8790 error "FIEMAP on 1-stripe file($fm_file) failed"
8793 (( tot_len += ext_len ))
8796 if (( lun != frag_lun || start_blk != 0 || tot_len != 64 )); then
8798 error "FIEMAP on 1-stripe file($fm_file) failed;"
8804 echo "FIEMAP on single striped file succeeded"
8806 run_test 130a "FIEMAP (1-stripe file)"
8809 [ "$OSTCOUNT" -lt "2" ] &&
8810 skip_env "skipping FIEMAP on 2-stripe file test" && return
8812 [ "$OSTCOUNT" -ge "10" ] &&
8813 skip_env "skipping FIEMAP with >= 10 OSTs" && return
8815 local filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
8816 [ -n "$filefrag_op" ] && skip_env "filefrag does not support FIEMAP" &&
8819 trap cleanup_130 EXIT RETURN
8821 local fm_file=$DIR/$tfile
8822 $SETSTRIPE -S 65536 -c 2 $fm_file || error "setstripe on $fm_file"
8823 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
8824 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
8826 dd if=/dev/zero of=$fm_file bs=1M count=2 ||
8827 error "dd failed on $fm_file"
8829 filefrag -ves $fm_file || error "filefrag $fm_file failed"
8830 filefrag_op=$(filefrag -ve $fm_file | grep -A 100 "ext:" |
8831 grep -v "ext:" | grep -v "found")
8833 last_lun=$(echo $filefrag_op | cut -d: -f5)
8838 for line in $filefrag_op
8840 frag_lun=`echo $line | cut -d: -f5`
8841 ext_len=`echo $line | cut -d: -f4`
8842 if (( $frag_lun != $last_lun )); then
8843 if (( tot_len != 1024 )); then
8845 error "FIEMAP on $fm_file failed; returned len $tot_len for OST $last_lun instead of 256"
8852 (( tot_len += ext_len ))
8855 if (( num_luns != 2 || tot_len != 1024 )); then
8857 error "FIEMAP on $fm_file failed; returned wrong number of luns or wrong len for OST $last_lun"
8863 echo "FIEMAP on 2-stripe file succeeded"
8865 run_test 130b "FIEMAP (2-stripe file)"
8868 [ "$OSTCOUNT" -lt "2" ] &&
8869 skip_env "skipping FIEMAP on 2-stripe file" && return
8871 [ "$OSTCOUNT" -ge "10" ] &&
8872 skip_env "skipping FIEMAP with >= 10 OSTs" && return
8874 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
8875 [ -n "$filefrag_op" ] && skip "filefrag does not support FIEMAP" &&
8878 trap cleanup_130 EXIT RETURN
8880 local fm_file=$DIR/$tfile
8881 $SETSTRIPE -S 65536 -c 2 $fm_file || error "setstripe on $fm_file"
8882 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
8883 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
8885 dd if=/dev/zero of=$fm_file seek=1 bs=1M count=1 || error "dd failed on $fm_file"
8887 filefrag -ves $fm_file || error "filefrag $fm_file failed"
8888 filefrag_op=`filefrag -ve $fm_file | grep -A 100 "ext:" | grep -v "ext:" | grep -v "found"`
8890 last_lun=`echo $filefrag_op | cut -d: -f5`
8895 for line in $filefrag_op
8897 frag_lun=`echo $line | cut -d: -f5`
8898 ext_len=`echo $line | cut -d: -f4`
8899 if (( $frag_lun != $last_lun )); then
8900 logical=`echo $line | cut -d: -f2 | cut -d. -f1`
8901 if (( logical != 512 )); then
8903 error "FIEMAP on $fm_file failed; returned logical start for lun $logical instead of 512"
8906 if (( tot_len != 512 )); then
8908 error "FIEMAP on $fm_file failed; returned len $tot_len for OST $last_lun instead of 1024"
8915 (( tot_len += ext_len ))
8918 if (( num_luns != 2 || tot_len != 512 )); then
8920 error "FIEMAP on $fm_file failed; returned wrong number of luns or wrong len for OST $last_lun"
8926 echo "FIEMAP on 2-stripe file with hole succeeded"
8928 run_test 130c "FIEMAP (2-stripe file with hole)"
8931 [ "$OSTCOUNT" -lt "3" ] && skip_env "skipping FIEMAP on N-stripe file test" && return
8933 [ "$OSTCOUNT" -ge "10" ] &&
8934 skip_env "skipping FIEMAP with >= 10 OSTs" && return
8936 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
8937 [ -n "$filefrag_op" ] && skip "filefrag does not support FIEMAP" && return
8939 trap cleanup_130 EXIT RETURN
8941 local fm_file=$DIR/$tfile
8942 $SETSTRIPE -S 65536 -c $OSTCOUNT $fm_file||error "setstripe on $fm_file"
8943 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
8944 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
8946 local actual_stripecnt=$($GETSTRIPE -c $fm_file)
8947 dd if=/dev/zero of=$fm_file bs=1M count=$actual_stripecnt ||
8948 error "dd failed on $fm_file"
8950 filefrag -ves $fm_file || error "filefrag $fm_file failed"
8951 filefrag_op=`filefrag -ve $fm_file | grep -A 100 "ext:" |
8952 grep -v "ext:" | grep -v "found"`
8954 last_lun=`echo $filefrag_op | cut -d: -f5`
8959 for line in $filefrag_op
8961 frag_lun=`echo $line | cut -d: -f5`
8962 ext_len=`echo $line | cut -d: -f4`
8963 if (( $frag_lun != $last_lun )); then
8964 if (( tot_len != 1024 )); then
8966 error "FIEMAP on $fm_file failed; returned len $tot_len for OST $last_lun instead of 1024"
8973 (( tot_len += ext_len ))
8976 if (( num_luns != actual_stripecnt || tot_len != 1024 )); then
8978 error "FIEMAP on $fm_file failed; returned wrong number of luns or wrong len for OST $last_lun"
8984 echo "FIEMAP on N-stripe file succeeded"
8986 run_test 130d "FIEMAP (N-stripe file)"
8989 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping continuation FIEMAP test" && return
8991 [ "$OSTCOUNT" -ge "10" ] &&
8992 skip_env "skipping FIEMAP with >= 10 OSTs" && return
8994 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
8995 [ -n "$filefrag_op" ] && skip "filefrag does not support FIEMAP" && return
8997 trap cleanup_130 EXIT RETURN
8999 local fm_file=$DIR/$tfile
9000 $SETSTRIPE -S 131072 -c 2 $fm_file || error "setstripe on $fm_file"
9001 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
9002 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
9005 EXPECTED_LEN=$(( (NUM_BLKS / 2) * 64 ))
9006 for ((i = 0; i < $NUM_BLKS; i++))
9008 dd if=/dev/zero of=$fm_file count=1 bs=64k seek=$((2*$i)) conv=notrunc > /dev/null 2>&1
9011 filefrag -ves $fm_file || error "filefrag $fm_file failed"
9012 filefrag_op=`filefrag -ve $fm_file | grep -A 12000 "ext:" | grep -v "ext:" | grep -v "found"`
9014 last_lun=`echo $filefrag_op | cut -d: -f5`
9019 for line in $filefrag_op
9021 frag_lun=`echo $line | cut -d: -f5`
9022 ext_len=`echo $line | cut -d: -f4`
9023 if (( $frag_lun != $last_lun )); then
9024 if (( tot_len != $EXPECTED_LEN )); then
9026 error "FIEMAP on $fm_file failed; returned len $tot_len for OST $last_lun instead of $EXPECTED_LEN"
9033 (( tot_len += ext_len ))
9036 if (( num_luns != 2 || tot_len != $EXPECTED_LEN )); then
9038 error "FIEMAP on $fm_file failed; returned wrong number of luns or wrong len for OST $last_lun"
9044 echo "FIEMAP with continuation calls succeeded"
9046 run_test 130e "FIEMAP (test continuation FIEMAP calls)"
9048 # Test for writev/readv
9050 rwv -f $DIR/$tfile -w -n 3 524288 1048576 1572864 || \
9051 error "writev test failed"
9052 rwv -f $DIR/$tfile -r -v -n 2 1572864 1048576 || \
9053 error "readv failed"
9056 run_test 131a "test iov's crossing stripe boundary for writev/readv"
9059 rwv -f $DIR/$tfile -w -a -n 3 524288 1048576 1572864 || \
9060 error "append writev test failed"
9061 rwv -f $DIR/$tfile -w -a -n 2 1572864 1048576 || \
9062 error "append writev test failed"
9065 run_test 131b "test append writev"
9068 rwv -f $DIR/$tfile -w -d -n 1 1048576 || return 0
9071 run_test 131c "test read/write on file w/o objects"
9074 rwv -f $DIR/$tfile -w -n 1 1572864
9075 NOB=`rwv -f $DIR/$tfile -r -n 3 524288 524288 1048576 | awk '/error/ {print $6}'`
9076 if [ "$NOB" != 1572864 ]; then
9077 error "Short read filed: read $NOB bytes instead of 1572864"
9081 run_test 131d "test short read"
9084 rwv -f $DIR/$tfile -w -s 1048576 -n 1 1048576
9085 rwv -f $DIR/$tfile -r -z -s 0 -n 1 524288 || \
9086 error "read hitting hole failed"
9089 run_test 131e "test read hitting hole"
9095 $SINGLEMDS) res=`do_facet $SINGLEMDS $LCTL get_param mdt.$FSNAME-MDT0000.md_stats | grep "$2"`
9097 ost) res=`do_facet ost1 $LCTL get_param obdfilter.$FSNAME-OST0000.stats | grep "$2"`
9099 *) error "Wrong argument $1" ;;
9102 [ -z "$res" ] && error "The counter for $2 on $1 was not incremented"
9103 # if the argument $3 is zero, it means any stat increment is ok.
9104 if [[ $3 -gt 0 ]]; then
9105 count=$(echo $res | awk '{ print $2 }')
9106 [[ $count -ne $3 ]] &&
9107 error "The $2 counter on $1 is wrong - expected $3"
9112 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9113 remote_ost_nodsh && skip "remote OST with nodsh" && return
9114 remote_mds_nodsh && skip "remote MDS with nodsh" && return
9116 do_facet $SINGLEMDS $LCTL list_param mdt.*.rename_stats ||
9117 { skip "MDS doesn't support rename stats"; return; }
9118 local testdir=$DIR/${tdir}/stats_testdir
9119 mkdir -p $DIR/${tdir}
9122 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
9123 do_facet ost1 $LCTL set_param obdfilter.*.stats=clear
9125 # verify mdt stats first.
9126 mkdir ${testdir} || error "mkdir failed"
9127 check_stats $SINGLEMDS "mkdir" 1
9128 touch ${testdir}/${tfile} || "touch failed"
9129 check_stats $SINGLEMDS "open" 1
9130 check_stats $SINGLEMDS "close" 1
9131 mknod ${testdir}/${tfile}-pipe p || "mknod failed"
9132 check_stats $SINGLEMDS "mknod" 1
9133 rm -f ${testdir}/${tfile}-pipe || "pipe remove failed"
9134 check_stats $SINGLEMDS "unlink" 1
9135 rm -f ${testdir}/${tfile} || error "file remove failed"
9136 check_stats $SINGLEMDS "unlink" 2
9138 # remove working dir and check mdt stats again.
9139 rmdir ${testdir} || error "rmdir failed"
9140 check_stats $SINGLEMDS "rmdir" 1
9142 local testdir1=$DIR/${tdir}/stats_testdir1
9144 mkdir -p ${testdir1}
9145 touch ${testdir1}/test1
9146 mv ${testdir1}/test1 ${testdir} || error "file crossdir rename"
9147 check_stats $SINGLEMDS "crossdir_rename" 1
9149 mv ${testdir}/test1 ${testdir}/test0 || error "file samedir rename"
9150 check_stats $SINGLEMDS "samedir_rename" 1
9154 run_test 133a "Verifying MDT stats ========================================"
9157 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9158 remote_ost_nodsh && skip "remote OST with nodsh" && return
9159 remote_mds_nodsh && skip "remote MDS with nodsh" && return
9160 local testdir=$DIR/${tdir}/stats_testdir
9161 mkdir -p ${testdir} || error "mkdir failed"
9162 touch ${testdir}/${tfile} || "touch failed"
9163 cancel_lru_locks mdc
9166 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
9167 do_facet ost1 $LCTL set_param obdfilter.*.stats=clear
9169 # extra mdt stats verification.
9170 chmod 444 ${testdir}/${tfile} || error "chmod failed"
9171 check_stats $SINGLEMDS "setattr" 1
9172 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
9173 if [ $(lustre_version_code $SINGLEMDS) -ne $(version_code 2.2.0) ]
9175 ls -l ${testdir}/${tfile} > /dev/null|| error "ls failed"
9176 check_stats $SINGLEMDS "getattr" 1
9178 $LFS df || error "lfs failed"
9179 check_stats $SINGLEMDS "statfs" 1
9183 run_test 133b "Verifying extra MDT stats =================================="
9186 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9187 remote_ost_nodsh && skip "remote OST with nodsh" && return
9188 remote_mds_nodsh && skip "remote MDS with nodsh" && return
9189 local testdir=$DIR/${tdir}/stats_testdir
9190 test_mkdir -p ${testdir} || error "mkdir failed"
9192 # verify obdfilter stats.
9193 $SETSTRIPE -c 1 -i 0 ${testdir}/${tfile}
9195 cancel_lru_locks osc
9196 wait_delete_completed
9199 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
9200 do_facet ost1 $LCTL set_param obdfilter.*.stats=clear
9202 dd if=/dev/zero of=${testdir}/${tfile} conv=notrunc bs=512k count=1 || error "dd failed"
9204 cancel_lru_locks osc
9205 check_stats ost "write" 1
9207 dd if=${testdir}/${tfile} of=/dev/null bs=1k count=1 || error "dd failed"
9208 check_stats ost "read" 1
9210 > ${testdir}/${tfile} || error "truncate failed"
9211 check_stats ost "punch" 1
9213 rm -f ${testdir}/${tfile} || error "file remove failed"
9214 wait_delete_completed
9215 check_stats ost "destroy" 1
9219 run_test 133c "Verifying OST stats ========================================"
9226 while [ $value -ge 2 ]; do
9231 if [ $orig -gt $order ]; then
9239 local size=('K' 'M' 'G' 'T');
9241 local size_string=$value
9243 while [ $value -ge 1024 ]; do
9244 if [ $i -gt 3 ]; then
9245 #T is the biggest unit we get here, if that is bigger,
9247 size_string=${value}T
9250 value=$((value >> 10))
9251 if [ $value -lt 1024 ]; then
9252 size_string=${value}${size[$i]}
9263 local context=${2:-.}
9264 local sample=$(do_facet $SINGLEMDS $LCTL get_param mdt.*.rename_stats |
9266 awk '/ '${size}'/ {print $4}' | sed -e "s/,//g")
9271 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9272 remote_ost_nodsh && skip "remote OST with nodsh" && return
9273 remote_mds_nodsh && skip "remote MDS with nodsh" && return
9274 do_facet $SINGLEMDS $LCTL list_param mdt.*.rename_stats ||
9275 { skip "MDS doesn't support rename stats"; return; }
9277 local testdir1=$DIR/${tdir}/stats_testdir1
9278 local testdir2=$DIR/${tdir}/stats_testdir2
9280 do_facet $SINGLEMDS $LCTL set_param mdt.*.rename_stats=clear
9282 mkdir -p ${testdir1} || error "mkdir failed"
9283 mkdir -p ${testdir2} || error "mkdir failed"
9285 createmany -o $testdir1/test 512 || error "createmany failed"
9287 # check samedir rename size
9288 mv ${testdir1}/test0 ${testdir1}/test_0
9290 local testdir1_size=$(ls -l $DIR/${tdir} |
9291 awk '/stats_testdir1/ {print $5}')
9292 local testdir2_size=$(ls -l $DIR/${tdir} |
9293 awk '/stats_testdir2/ {print $5}')
9295 testdir1_size=$(order_2 $testdir1_size)
9296 testdir2_size=$(order_2 $testdir2_size)
9298 testdir1_size=$(size_in_KMGT $testdir1_size)
9299 testdir2_size=$(size_in_KMGT $testdir2_size)
9301 echo "source rename dir size: ${testdir1_size}"
9302 echo "target rename dir size: ${testdir2_size}"
9304 local cmd="do_facet $SINGLEMDS $LCTL get_param mdt.*.rename_stats"
9305 eval $cmd || error "$cmd failed"
9306 local samedir=$($cmd | grep 'same_dir')
9307 local same_sample=$(get_rename_size $testdir1_size)
9308 [ -z "$samedir" ] && error "samedir_rename_size count error"
9309 [[ $same_sample -eq 1 ]] ||
9310 error "samedir_rename_size error $same_sample"
9311 echo "Check same dir rename stats success"
9313 do_facet $SINGLEMDS $LCTL set_param mdt.*.rename_stats=clear
9315 # check crossdir rename size
9316 mv ${testdir1}/test_0 ${testdir2}/test_0
9318 testdir1_size=$(ls -l $DIR/${tdir} |
9319 awk '/stats_testdir1/ {print $5}')
9320 testdir2_size=$(ls -l $DIR/${tdir} |
9321 awk '/stats_testdir2/ {print $5}')
9323 testdir1_size=$(order_2 $testdir1_size)
9324 testdir2_size=$(order_2 $testdir2_size)
9326 testdir1_size=$(size_in_KMGT $testdir1_size)
9327 testdir2_size=$(size_in_KMGT $testdir2_size)
9329 echo "source rename dir size: ${testdir1_size}"
9330 echo "target rename dir size: ${testdir2_size}"
9332 eval $cmd || error "$cmd failed"
9333 local crossdir=$($cmd | grep 'crossdir')
9334 local src_sample=$(get_rename_size $testdir1_size crossdir_src)
9335 local tgt_sample=$(get_rename_size $testdir2_size crossdir_tgt)
9336 [ -z "$crossdir" ] && error "crossdir_rename_size count error"
9337 [[ $src_sample -eq 1 ]] ||
9338 error "crossdir_rename_size error $src_sample"
9339 [[ $tgt_sample -eq 1 ]] ||
9340 error "crossdir_rename_size error $tgt_sample"
9341 echo "Check cross dir rename stats success"
9344 run_test 133d "Verifying rename_stats ========================================"
9347 remote_mds_nodsh && skip "remote MDS with nodsh" && return
9348 remote_ost_nodsh && skip "remote OST with nodsh" && return
9349 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9350 local testdir=$DIR/${tdir}/stats_testdir
9351 local ctr f0 f1 bs=32768 count=42 sum
9353 mkdir -p ${testdir} || error "mkdir failed"
9355 $SETSTRIPE -c 1 -i 0 ${testdir}/${tfile}
9357 for ctr in {write,read}_bytes; do
9359 cancel_lru_locks osc
9361 do_facet ost1 $LCTL set_param -n \
9362 "obdfilter.*.exports.clear=clear"
9364 if [ $ctr = write_bytes ]; then
9366 f1=${testdir}/${tfile}
9368 f0=${testdir}/${tfile}
9372 dd if=$f0 of=$f1 conv=notrunc bs=$bs count=$count || \
9375 cancel_lru_locks osc
9377 sum=$(do_facet ost1 $LCTL get_param \
9378 "obdfilter.*.exports.*.stats" |
9379 awk -v ctr=$ctr 'BEGIN { sum = 0 }
9380 $1 == ctr { sum += $7 }
9381 END { printf("%0.0f", sum) }')
9383 if ((sum != bs * count)); then
9384 error "Bad $ctr sum, expected $((bs * count)), got $sum"
9390 run_test 133e "Verifying OST {read,write}_bytes nid stats ================="
9395 local dirs="/proc/fs/lustre/ /proc/sys/lnet/ /proc/sys/lustre/ \
9396 /sys/fs/lustre/ /sys/fs/lnet/"
9398 for dir in $dirs; do
9399 if [ -d $dir ]; then
9400 proc_dirs="$proc_dirs $dir"
9406 remote_mds_nodsh && skip "remote MDS with nodsh" && return
9407 remote_ost_nodsh && skip "remote OST with nodsh" && return
9408 # First without trusting modes.
9409 find $proc_dirs -exec cat '{}' \; &> /dev/null
9411 # Second verifying readability.
9414 -exec cat '{}' \; &> /dev/null ||
9415 error "proc file read failed"
9417 for facet in $SINGLEMDS ost1; do
9418 do_facet $facet find $proc_dirs \
9419 ! -name req_history \
9420 -exec cat '{}' \\\; &> /dev/null
9422 do_facet $facet find $proc_dirs \
9423 ! -name req_history \
9425 -exec cat '{}' \\\; &> /dev/null ||
9426 error "proc file read failed"
9429 run_test 133f "Check for LBUGs/Oopses/unreadable files in /proc"
9434 local dirs="/proc/fs/lustre/ /proc/sys/lnet/ /proc/sys/lustre/ \
9435 /sys/fs/lustre/ /sys/fs/lnet/"
9437 for dir in $dirs; do
9438 if [ -d $dir ]; then
9439 proc_dirs="$proc_dirs $dir"
9445 # Second verifying readability.
9448 -not -name force_lbug \
9449 -not -name changelog_mask \
9450 -exec badarea_io '{}' \; &> /dev/null ||
9451 error "find $proc_dirs failed"
9453 [ $(lustre_version_code $SINGLEMDS) -le $(version_code 2.5.54) ] &&
9454 skip "Too old lustre on MDS" && return
9456 [ $(lustre_version_code ost1) -le $(version_code 2.5.54) ] &&
9457 skip "Too old lustre on ost1" && return
9459 for facet in $SINGLEMDS ost1; do
9460 do_facet $facet find $proc_dirs \
9462 -not -name force_lbug \
9463 -not -name changelog_mask \
9464 -exec badarea_io '{}' \\\; &> /dev/null ||
9465 error "$facet find $proc_dirs failed"
9469 # remount the FS in case writes/reads /proc break the FS
9470 cleanup || error "failed to unmount"
9471 setup || error "failed to setup"
9474 run_test 133g "Check for Oopses on bad io area writes/reads in /proc"
9477 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.54) ]] &&
9478 skip "Need MDS version at least 2.7.54" && return
9480 mkdir -p $DIR/$tdir || error "failed to create $DIR/$tdir"
9481 cancel_lru_locks mdc
9483 local nsdir="ldlm.namespaces.*-MDT0000-mdc-*"
9484 local unused=$($LCTL get_param -n $nsdir.lock_unused_count)
9485 [ $unused -eq 0 ] || "$unused locks are not cleared"
9488 createmany -o $DIR/$tdir/f $nr ||
9489 error "failed to create $nr files in $DIR/$tdir"
9490 unused=$($LCTL get_param -n $nsdir.lock_unused_count)
9492 #define OBD_FAIL_LDLM_WATERMARK_LOW 0x327
9493 do_facet mds1 $LCTL set_param fail_loc=0x327
9494 do_facet mds1 $LCTL set_param fail_val=500
9497 echo "sleep 10 seconds ..."
9499 local lck_cnt=$($LCTL get_param -n $nsdir.lock_unused_count)
9501 do_facet mds1 $LCTL set_param fail_loc=0
9502 do_facet mds1 $LCTL set_param fail_val=0
9503 [ $lck_cnt -lt $unused ] ||
9504 error "No locks reclaimed, before:$unused, after:$lck_cnt"
9507 unlinkmany $DIR/$tdir/f $nr
9509 run_test 134a "Server reclaims locks when reaching lock_reclaim_threshold"
9512 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.54) ]] &&
9513 skip "Need MDS version at least 2.7.54" && return
9515 mkdir -p $DIR/$tdir || error "failed to create $DIR/$tdir"
9516 cancel_lru_locks mdc
9518 local low_wm=$(do_facet mds1 $LCTL get_param -n \
9519 ldlm.lock_reclaim_threshold_mb)
9520 # disable reclaim temporarily
9521 do_facet mds1 $LCTL set_param ldlm.lock_reclaim_threshold_mb=0
9523 #define OBD_FAIL_LDLM_WATERMARK_HIGH 0x328
9524 do_facet mds1 $LCTL set_param fail_loc=0x328
9525 do_facet mds1 $LCTL set_param fail_val=500
9527 $LCTL set_param debug=+trace
9530 createmany -o $DIR/$tdir/f $nr &
9533 echo "Sleep $TIMEOUT seconds ..."
9535 if ! ps -p $create_pid > /dev/null 2>&1; then
9536 do_facet mds1 $LCTL set_param fail_loc=0
9537 do_facet mds1 $LCTL set_param fail_val=0
9538 do_facet mds1 $LCTL set_param \
9539 ldlm.lock_reclaim_threshold_mb=${low_wm}m
9540 error "createmany finished incorrectly!"
9542 do_facet mds1 $LCTL set_param fail_loc=0
9543 do_facet mds1 $LCTL set_param fail_val=0
9544 do_facet mds1 $LCTL set_param ldlm.lock_reclaim_threshold_mb=${low_wm}m
9545 wait $create_pid || return 1
9547 unlinkmany $DIR/$tdir/f $nr
9549 run_test 134b "Server rejects lock request when reaching lock_limit_mb"
9551 test_140() { #bug-17379
9552 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9553 test_mkdir -p $DIR/$tdir || error "Creating dir $DIR/$tdir"
9554 cd $DIR/$tdir || error "Changing to $DIR/$tdir"
9555 cp /usr/bin/stat . || error "Copying stat to $DIR/$tdir"
9557 # VFS limits max symlink depth to 5(4KSTACK) or 7(8KSTACK) or 8
9558 # For kernel > 3.5, bellow only tests consecutive symlink (MAX 40)
9560 while i=`expr $i + 1`; do
9561 test_mkdir -p $i || error "Creating dir $i"
9562 cd $i || error "Changing to $i"
9563 ln -s ../stat stat || error "Creating stat symlink"
9564 # Read the symlink until ELOOP present,
9565 # not LBUGing the system is considered success,
9566 # we didn't overrun the stack.
9567 $OPENFILE -f O_RDONLY stat >/dev/null 2>&1; ret=$?
9569 if [ $ret -eq 40 ]; then
9572 error "Open stat symlink"
9578 echo "The symlink depth = $i"
9579 [ $i -eq 5 -o $i -eq 7 -o $i -eq 8 -o $i -eq 40 ] ||
9580 error "Invalid symlink depth"
9582 # Test recursive symlink
9583 ln -s symlink_self symlink_self
9584 $OPENFILE -f O_RDONLY symlink_self >/dev/null 2>&1; ret=$?
9585 echo "open symlink_self returns $ret"
9586 [ $ret -eq 40 ] || error "recursive symlink doesn't return -ELOOP"
9588 run_test 140 "Check reasonable stack depth (shouldn't LBUG) ===="
9591 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9592 local TF="$TMP/$tfile"
9594 dd if=/dev/urandom of=$TF bs=6096 count=1 || error "dd failed"
9596 cancel_lru_locks osc
9597 cmp $TF $DIR/$tfile || error "$TMP/$tfile $DIR/$tfile differ"
9598 remount_client $MOUNT
9600 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (remount)"
9603 $TRUNCATE $DIR/$tfile 6000
9604 cancel_lru_locks osc
9605 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (truncate1)"
9608 echo "12345" >>$DIR/$tfile
9609 cancel_lru_locks osc
9610 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (append1)"
9613 echo "12345" >>$DIR/$tfile
9614 cancel_lru_locks osc
9615 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (append2)"
9620 run_test 150 "truncate/append tests"
9622 #LU-2902 roc_hit was not able to read all values from lproc
9623 function roc_hit_init() {
9624 local list=$(comma_list $(osts_nodes))
9625 local dir=$DIR/$tdir-check
9626 local file=$dir/file
9632 #use setstripe to do a write to every ost
9633 for i in $(seq 0 $((OSTCOUNT-1))); do
9634 $SETSTRIPE -c 1 -i $i $dir || error "$SETSTRIPE $file failed"
9635 dd if=/dev/urandom of=$file bs=4k count=4 2>&1 > /dev/null
9636 idx=$(printf %04x $i)
9637 BEFORE=$(get_osd_param $list *OST*$idx stats |
9638 awk '$1 == "cache_access" {sum += $7}
9639 END { printf("%0.0f", sum) }')
9641 cancel_lru_locks osc
9642 cat $file >/dev/null
9644 AFTER=$(get_osd_param $list *OST*$idx stats |
9645 awk '$1 == "cache_access" {sum += $7}
9646 END { printf("%0.0f", sum) }')
9648 echo BEFORE:$BEFORE AFTER:$AFTER
9649 if ! let "AFTER - BEFORE == 4"; then
9651 error "roc_hit is not safe to use"
9659 function roc_hit() {
9660 local list=$(comma_list $(osts_nodes))
9661 echo $(get_osd_param $list '' stats |
9662 awk '$1 == "cache_hit" {sum += $7}
9663 END { printf("%0.0f", sum) }')
9666 function set_cache() {
9669 if [ "$2" == "off" ]; then
9672 local list=$(comma_list $(osts_nodes))
9673 set_osd_param $list '' $1_cache_enable $on
9675 cancel_lru_locks osc
9679 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9680 remote_ost_nodsh && skip "remote OST with nodsh" && return
9683 local list=$(comma_list $(osts_nodes))
9685 # check whether obdfilter is cache capable at all
9686 if ! get_osd_param $list '' read_cache_enable >/dev/null; then
9687 echo "not cache-capable obdfilter"
9691 # check cache is enabled on all obdfilters
9692 if get_osd_param $list '' read_cache_enable | grep 0; then
9693 echo "oss cache is disabled"
9697 set_osd_param $list '' writethrough_cache_enable 1
9699 # check write cache is enabled on all obdfilters
9700 if get_osd_param $list '' writethrough_cache_enable | grep 0; then
9701 echo "oss write cache is NOT enabled"
9707 #define OBD_FAIL_OBD_NO_LRU 0x609
9708 do_nodes $list $LCTL set_param fail_loc=0x609
9710 # pages should be in the case right after write
9711 dd if=/dev/urandom of=$DIR/$tfile bs=4k count=$CPAGES ||
9714 local BEFORE=$(roc_hit)
9715 cancel_lru_locks osc
9716 cat $DIR/$tfile >/dev/null
9717 local AFTER=$(roc_hit)
9719 do_nodes $list $LCTL set_param fail_loc=0
9721 if ! let "AFTER - BEFORE == CPAGES"; then
9722 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
9725 # the following read invalidates the cache
9726 cancel_lru_locks osc
9727 set_osd_param $list '' read_cache_enable 0
9728 cat $DIR/$tfile >/dev/null
9730 # now data shouldn't be found in the cache
9732 cancel_lru_locks osc
9733 cat $DIR/$tfile >/dev/null
9735 if let "AFTER - BEFORE != 0"; then
9736 error "IN CACHE: before: $BEFORE, after: $AFTER"
9739 set_osd_param $list '' read_cache_enable 1
9742 run_test 151 "test cache on oss and controls ==============================="
9745 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9746 local TF="$TMP/$tfile"
9748 # simulate ENOMEM during write
9749 #define OBD_FAIL_OST_NOMEM 0x226
9750 lctl set_param fail_loc=0x80000226
9751 dd if=/dev/urandom of=$TF bs=6096 count=1 || error "dd failed"
9753 sync || error "sync failed"
9754 lctl set_param fail_loc=0
9756 # discard client's cache
9757 cancel_lru_locks osc
9759 # simulate ENOMEM during read
9760 lctl set_param fail_loc=0x80000226
9761 cmp $TF $DIR/$tfile || error "cmp failed"
9762 lctl set_param fail_loc=0
9766 run_test 152 "test read/write with enomem ============================"
9769 $MULTIOP $DIR/$tfile Ow4096Ycu || error "multiop failed"
9771 run_test 153 "test if fdatasync does not crash ======================="
9773 dot_lustre_fid_permission_check() {
9775 local ffid=$MOUNT/.lustre/fid/$fid
9778 echo "stat fid $fid"
9779 stat $ffid > /dev/null || error "stat $ffid failed."
9780 echo "touch fid $fid"
9781 touch $ffid || error "touch $ffid failed."
9782 echo "write to fid $fid"
9783 cat /etc/hosts > $ffid || error "write $ffid failed."
9784 echo "read fid $fid"
9785 diff /etc/hosts $ffid || error "read $ffid failed."
9786 echo "append write to fid $fid"
9787 cat /etc/hosts >> $ffid || error "append write $ffid failed."
9788 echo "rename fid $fid"
9789 mv $ffid $test_dir/$tfile.1 &&
9790 error "rename $ffid to $tfile.1 should fail."
9791 touch $test_dir/$tfile.1
9792 mv $test_dir/$tfile.1 $ffid &&
9793 error "rename $tfile.1 to $ffid should fail."
9794 rm -f $test_dir/$tfile.1
9795 echo "truncate fid $fid"
9796 $TRUNCATE $ffid 777 || error "truncate $ffid failed."
9797 if [ $MDSCOUNT -lt 2 ]; then #FIXME when cross-MDT hard link is working
9798 echo "link fid $fid"
9799 ln -f $ffid $test_dir/tfile.lnk || error "link $ffid failed."
9801 if [ -n $(lctl get_param -n mdc.*-mdc-*.connect_flags | grep acl) ]; then
9802 echo "setfacl fid $fid"
9803 setfacl -R -m u:bin:rwx $ffid || error "setfacl $ffid failed."
9804 echo "getfacl fid $fid"
9805 getfacl $ffid >/dev/null || error "getfacl $ffid failed."
9807 echo "unlink fid $fid"
9808 unlink $MOUNT/.lustre/fid/$fid && error "unlink $ffid should fail."
9809 echo "mknod fid $fid"
9810 mknod $ffid c 1 3 && error "mknod $ffid should fail."
9812 fid=[0xf00000400:0x1:0x0]
9813 ffid=$MOUNT/.lustre/fid/$fid
9815 echo "stat non-exist fid $fid"
9816 stat $ffid > /dev/null && error "stat non-exist $ffid should fail."
9817 echo "write to non-exist fid $fid"
9818 cat /etc/hosts > $ffid && error "write non-exist $ffid should fail."
9819 echo "link new fid $fid"
9820 ln $test_dir/$tfile $ffid && error "link $ffid should fail."
9822 mkdir -p $test_dir/$tdir
9823 touch $test_dir/$tdir/$tfile
9824 fid=$($LFS path2fid $test_dir/$tdir)
9827 error "error: could not get fid for $test_dir/$dir/$tfile."
9829 ffid=$MOUNT/.lustre/fid/$fid
9832 ls $ffid > /dev/null || error "ls $ffid failed."
9833 echo "touch $fid/$tfile.1"
9834 touch $ffid/$tfile.1 || error "touch $ffid/$tfile.1 failed."
9836 echo "touch $MOUNT/.lustre/fid/$tfile"
9837 touch $MOUNT/.lustre/fid/$tfile && \
9838 error "touch $MOUNT/.lustre/fid/$tfile should fail."
9840 echo "setxattr to $MOUNT/.lustre/fid"
9841 setfattr -n trusted.name1 -v value1 $MOUNT/.lustre/fid
9843 echo "listxattr for $MOUNT/.lustre/fid"
9844 getfattr -d -m "^trusted" $MOUNT/.lustre/fid
9846 echo "delxattr from $MOUNT/.lustre/fid"
9847 setfattr -x trusted.name1 $MOUNT/.lustre/fid
9849 echo "touch invalid fid: $MOUNT/.lustre/fid/[0x200000400:0x2:0x3]"
9850 touch $MOUNT/.lustre/fid/[0x200000400:0x2:0x3] &&
9851 error "touch invalid fid should fail."
9853 echo "touch non-normal fid: $MOUNT/.lustre/fid/[0x1:0x2:0x0]"
9854 touch $MOUNT/.lustre/fid/[0x1:0x2:0x0] &&
9855 error "touch non-normal fid should fail."
9857 echo "rename $tdir to $MOUNT/.lustre/fid"
9858 mrename $test_dir/$tdir $MOUNT/.lustre/fid &&
9859 error "rename to $MOUNT/.lustre/fid should fail."
9861 if [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.3.51) ]
9863 local old_obf_mode=$(stat --format="%a" $DIR/.lustre/fid)
9864 local new_obf_mode=777
9866 echo "change mode of $DIR/.lustre/fid to $new_obf_mode"
9867 chmod $new_obf_mode $DIR/.lustre/fid ||
9868 error "chmod $new_obf_mode $DIR/.lustre/fid failed"
9870 local obf_mode=$(stat --format=%a $DIR/.lustre/fid)
9871 [ $obf_mode -eq $new_obf_mode ] ||
9872 error "stat $DIR/.lustre/fid returned wrong mode $obf_mode"
9874 echo "restore mode of $DIR/.lustre/fid to $old_obf_mode"
9875 chmod $old_obf_mode $DIR/.lustre/fid ||
9876 error "chmod $old_obf_mode $DIR/.lustre/fid failed"
9879 $OPENFILE -f O_LOV_DELAY_CREATE:O_CREAT $test_dir/$tfile-2
9880 fid=$($LFS path2fid $test_dir/$tfile-2)
9882 if [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.6.50) ]
9884 echo "cp /etc/passwd $MOUNT/.lustre/fid/$fid"
9885 cp /etc/passwd $MOUNT/.lustre/fid/$fid ||
9886 error "create lov data thru .lustre failed"
9888 echo "cp /etc/passwd $test_dir/$tfile-2"
9889 cp /etc/passwd $test_dir/$tfile-2 ||
9890 error "copy to $test_dir/$tfile-2 failed."
9891 echo "diff /etc/passwd $MOUNT/.lustre/fid/$fid"
9892 diff /etc/passwd $MOUNT/.lustre/fid/$fid ||
9893 error "diff /etc/passwd $MOUNT/.lustre/fid/$fid failed."
9895 rm -rf $test_dir/tfile.lnk
9896 rm -rf $test_dir/$tfile-2
9900 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.1) ]] &&
9901 skip "Need MDS version at least 2.4.1" && return
9904 local FID=$($LFS path2fid $DIR/$tfile)
9905 [ -z "$FID" ] && error "path2fid unable to get $DIR/$tfile FID"
9907 # check that we get the same pathname back
9908 local FOUND=$($LFS fid2path $MOUNT "$FID")
9909 [ -z "$FOUND" ] && error "fid2path unable to get $FID path"
9910 [ "$FOUND" != "$DIR/$tfile" ] &&
9911 error "fid2path(path2fid($DIR/$tfile)) = $FOUND != $DIR/$tfile"
9915 run_test 154A "lfs path2fid and fid2path basic checks"
9918 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9919 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.51) ]] ||
9920 { skip "Need MDS version at least 2.2.51"; return 0; }
9921 [ -z "$(which setfacl)" ] && skip "must have setfacl tool" && return
9923 cp /etc/hosts $DIR/$tfile
9925 fid=$($LFS path2fid $DIR/$tfile)
9927 [ $rc -ne 0 ] && error "error: could not get fid for $DIR/$tfile."
9929 dot_lustre_fid_permission_check "$fid" $DIR ||
9930 error "dot lustre permission check $fid failed"
9932 rm -rf $MOUNT/.lustre && error ".lustre is not allowed to be unlinked"
9934 touch $MOUNT/.lustre/file &&
9935 error "creation is not allowed under .lustre"
9937 mkdir $MOUNT/.lustre/dir &&
9938 error "mkdir is not allowed under .lustre"
9942 run_test 154a "Open-by-FID"
9945 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9946 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.51) ]] ||
9947 { skip "Need MDS version at least 2.2.51"; return 0; }
9949 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
9951 local remote_dir=$DIR/$tdir/remote_dir
9956 $LFS mkdir -i $MDTIDX $remote_dir ||
9957 error "create remote directory failed"
9959 cp /etc/hosts $remote_dir/$tfile
9961 fid=$($LFS path2fid $remote_dir/$tfile)
9963 [ $rc -ne 0 ] && error "error: could not get fid for $remote_dir/$tfile"
9965 dot_lustre_fid_permission_check "$fid" $remote_dir ||
9966 error "dot lustre permission check $fid failed"
9969 run_test 154b "Open-by-FID for remote directory"
9972 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.1) ]] &&
9973 skip "Need MDS version at least 2.4.1" && return
9975 touch $DIR/$tfile.1 $DIR/$tfile.2 $DIR/$tfile.3
9976 local FID1=$($LFS path2fid $DIR/$tfile.1)
9977 local FID2=$($LFS path2fid $DIR/$tfile.2)
9978 local FID3=$($LFS path2fid $DIR/$tfile.3)
9981 $LFS path2fid $DIR/$tfile.[123] | while read PATHNAME FID; do
9982 [ "$PATHNAME" = "$DIR/$tfile.$N:" ] ||
9983 error "path2fid pathname $PATHNAME != $DIR/$tfile.$N:"
9985 [ "$FID" = "${!want}" ] ||
9986 error "path2fid $PATHNAME FID $FID != FID$N ${!want}"
9990 $LFS fid2path $MOUNT "$FID1" "$FID2" "$FID3" | while read PATHNAME;
9992 [ "$PATHNAME" = "$DIR/$tfile.$N" ] ||
9993 error "fid2path pathname $PATHNAME != $DIR/$tfile.$N:"
9997 run_test 154c "lfs path2fid and fid2path multiple arguments"
10000 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.5.53) ]] &&
10001 skip "Need MDS version at least 2.5.53" && return
10003 if remote_mds; then
10004 nid=$($LCTL list_nids | sed "s/\./\\\./g")
10008 local proc_ofile="mdt.*.exports.'$nid'.open_files"
10015 local fid=$($LFS path2fid $DIR/$tfile)
10018 cmd="exec $fd<$DIR/$tfile"
10020 local fid_list=$(do_facet $SINGLEMDS $LCTL get_param $proc_ofile)
10021 echo "$fid_list" | grep "$fid"
10024 cmd="exec $fd>/dev/null"
10026 if [ $rc -ne 0 ]; then
10027 error "FID $fid not found in open files list $fid_list"
10030 run_test 154d "Verify open file fid"
10034 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.6.50) ]] &&
10035 skip "Need MDS version at least 2.6.50" && return
10037 if ls -a $MOUNT | grep -q '^\.lustre$'; then
10038 error ".lustre returned by readdir"
10041 run_test 154e ".lustre is not returned by readdir"
10044 # create parent directory on a single MDT to avoid cross-MDT hardlinks
10045 test_mkdir -p -c1 $DIR/$tdir/d
10046 # test dirs inherit from its stripe
10047 mkdir -p $DIR/$tdir/d/foo1 || error "mkdir error"
10048 mkdir -p $DIR/$tdir/d/foo2 || error "mkdir error"
10049 cp /etc/hosts $DIR/$tdir/d/foo1/$tfile
10050 ln $DIR/$tdir/d/foo1/$tfile $DIR/$tdir/d/foo2/link
10053 # get fid of parents
10054 local FID0=$($LFS path2fid $DIR/$tdir/d)
10055 local FID1=$($LFS path2fid $DIR/$tdir/d/foo1)
10056 local FID2=$($LFS path2fid $DIR/$tdir/d/foo2)
10057 local FID3=$($LFS path2fid $DIR)
10059 # check that path2fid --parents returns expected <parent_fid>/name
10060 # 1) test for a directory (single parent)
10061 local parent=$($LFS path2fid --parents $DIR/$tdir/d/foo1)
10062 [ "$parent" == "$FID0/foo1" ] ||
10063 error "expected parent: $FID0/foo1, got: $parent"
10065 # 2) test for a file with nlink > 1 (multiple parents)
10066 parent=$($LFS path2fid --parents $DIR/$tdir/d/foo1/$tfile)
10067 echo "$parent" | grep -F "$FID1/$tfile" ||
10068 error "$FID1/$tfile not returned in parent list"
10069 echo "$parent" | grep -F "$FID2/link" ||
10070 error "$FID2/link not returned in parent list"
10072 # 3) get parent by fid
10073 local file_fid=$($LFS path2fid $DIR/$tdir/d/foo1/$tfile)
10074 parent=$($LFS path2fid --parents $MOUNT/.lustre/fid/$file_fid)
10075 echo "$parent" | grep -F "$FID1/$tfile" ||
10076 error "$FID1/$tfile not returned in parent list (by fid)"
10077 echo "$parent" | grep -F "$FID2/link" ||
10078 error "$FID2/link not returned in parent list (by fid)"
10080 # 4) test for entry in root directory
10081 parent=$($LFS path2fid --parents $DIR/f)
10082 echo "$parent" | grep -F "$FID3/f" ||
10083 error "$FID3/f not returned in parent list"
10085 # 5) test it on root directory
10086 [ -z "$($LFS path2fid --parents $MOUNT 2>/dev/null)" ] ||
10087 error "$MOUNT should not have parents"
10089 # enable xattr caching and check that linkea is correctly updated
10090 local save="$TMP/$TESTSUITE-$TESTNAME.parameters"
10091 save_lustre_params client "llite.*.xattr_cache" > $save
10092 lctl set_param llite.*.xattr_cache 1
10094 # 6.1) linkea update on rename
10095 mv $DIR/$tdir/d/foo1/$tfile $DIR/$tdir/d/foo2/$tfile.moved
10097 # get parents by fid
10098 parent=$($LFS path2fid --parents $MOUNT/.lustre/fid/$file_fid)
10099 # foo1 should no longer be returned in parent list
10100 echo "$parent" | grep -F "$FID1" &&
10101 error "$FID1 should no longer be in parent list"
10102 # the new path should appear
10103 echo "$parent" | grep -F "$FID2/$tfile.moved" ||
10104 error "$FID2/$tfile.moved is not in parent list"
10106 # 6.2) linkea update on unlink
10107 rm -f $DIR/$tdir/d/foo2/link
10108 parent=$($LFS path2fid --parents $MOUNT/.lustre/fid/$file_fid)
10109 # foo2/link should no longer be returned in parent list
10110 echo "$parent" | grep -F "$FID2/link" &&
10111 error "$FID2/link should no longer be in parent list"
10115 restore_lustre_params < $save
10117 run_test 154f "get parent fids by reading link ea"
10121 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.6.92) ]] ||
10122 { skip "Need MDS version at least 2.6.92"; return 0; }
10124 mkdir -p $DIR/$tdir
10125 llapi_fid_test -d $DIR/$tdir
10127 run_test 154g "various llapi FID tests"
10129 test_155_small_load() {
10130 local temp=$TMP/$tfile
10131 local file=$DIR/$tfile
10133 dd if=/dev/urandom of=$temp bs=6096 count=1 || \
10134 error "dd of=$temp bs=6096 count=1 failed"
10136 cancel_lru_locks osc
10137 cmp $temp $file || error "$temp $file differ"
10139 $TRUNCATE $temp 6000
10140 $TRUNCATE $file 6000
10141 cmp $temp $file || error "$temp $file differ (truncate1)"
10143 echo "12345" >>$temp
10144 echo "12345" >>$file
10145 cmp $temp $file || error "$temp $file differ (append1)"
10147 echo "12345" >>$temp
10148 echo "12345" >>$file
10149 cmp $temp $file || error "$temp $file differ (append2)"
10155 test_155_big_load() {
10156 remote_ost_nodsh && skip "remote OST with nodsh" && return
10157 local temp=$TMP/$tfile
10158 local file=$DIR/$tfile
10161 local cache_size=$(do_facet ost$((MAXI+1)) \
10162 "awk '/cache/ {sum+=\\\$4} END {print sum}' /proc/cpuinfo")
10163 local large_file_size=$((cache_size * 2))
10165 echo "OSS cache size: $cache_size KB"
10166 echo "Large file size: $large_file_size KB"
10168 [ $MAXV -le $large_file_size ] && \
10169 skip_env "max available OST size needs > $large_file_size KB" && \
10172 $SETSTRIPE $file -c 1 -i $MAXI || error "$SETSTRIPE $file failed"
10174 dd if=/dev/urandom of=$temp bs=$large_file_size count=1k || \
10175 error "dd of=$temp bs=$large_file_size count=1k failed"
10178 cancel_lru_locks osc
10179 cmp $temp $file || error "$temp $file differ"
10186 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10188 set_cache writethrough on
10189 test_155_small_load
10191 run_test 155a "Verify small file correctness: read cache:on write_cache:on"
10194 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10196 set_cache writethrough off
10197 test_155_small_load
10199 run_test 155b "Verify small file correctness: read cache:on write_cache:off"
10202 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10204 set_cache writethrough on
10205 test_155_small_load
10207 run_test 155c "Verify small file correctness: read cache:off write_cache:on"
10210 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10212 set_cache writethrough off
10213 test_155_small_load
10215 run_test 155d "Verify small file correctness: read cache:off write_cache:off"
10218 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10220 set_cache writethrough on
10223 run_test 155e "Verify big file correctness: read cache:on write_cache:on"
10226 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10228 set_cache writethrough off
10231 run_test 155f "Verify big file correctness: read cache:on write_cache:off"
10234 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10236 set_cache writethrough on
10239 run_test 155g "Verify big file correctness: read cache:off write_cache:on"
10242 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10244 set_cache writethrough off
10247 run_test 155h "Verify big file correctness: read cache:off write_cache:off"
10250 remote_ost_nodsh && skip "remote OST with nodsh" && return
10251 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10255 local file="$DIR/$tfile"
10257 [ "$(facet_fstype ost1)" = "zfs" -a \
10258 $(lustre_version_code ost1 -lt $(version_code 2.6.93)) ] &&
10259 skip "LU-1956/LU-2261: stats not implemented on OSD ZFS" &&
10264 log "Turn on read and write cache"
10266 set_cache writethrough on
10268 log "Write data and read it back."
10269 log "Read should be satisfied from the cache."
10270 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
10272 cancel_lru_locks osc
10273 cat $file >/dev/null
10275 if ! let "AFTER - BEFORE == CPAGES"; then
10276 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
10278 log "cache hits:: before: $BEFORE, after: $AFTER"
10281 log "Read again; it should be satisfied from the cache."
10283 cancel_lru_locks osc
10284 cat $file >/dev/null
10286 if ! let "AFTER - BEFORE == CPAGES"; then
10287 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
10289 log "cache hits:: before: $BEFORE, after: $AFTER"
10292 log "Turn off the read cache and turn on the write cache"
10294 set_cache writethrough on
10296 log "Read again; it should be satisfied from the cache."
10298 cancel_lru_locks osc
10299 cat $file >/dev/null
10301 if ! let "AFTER - BEFORE == CPAGES"; then
10302 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
10304 log "cache hits:: before: $BEFORE, after: $AFTER"
10307 log "Read again; it should not be satisfied from the cache."
10309 cancel_lru_locks osc
10310 cat $file >/dev/null
10312 if ! let "AFTER - BEFORE == 0"; then
10313 error "IN CACHE: before: $BEFORE, after: $AFTER"
10315 log "cache hits:: before: $BEFORE, after: $AFTER"
10318 log "Write data and read it back."
10319 log "Read should be satisfied from the cache."
10320 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
10322 cancel_lru_locks osc
10323 cat $file >/dev/null
10325 if ! let "AFTER - BEFORE == CPAGES"; then
10326 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
10328 log "cache hits:: before: $BEFORE, after: $AFTER"
10331 log "Read again; it should not be satisfied from the cache."
10333 cancel_lru_locks osc
10334 cat $file >/dev/null
10336 if ! let "AFTER - BEFORE == 0"; then
10337 error "IN CACHE: before: $BEFORE, after: $AFTER"
10339 log "cache hits:: before: $BEFORE, after: $AFTER"
10342 log "Turn off read and write cache"
10344 set_cache writethrough off
10346 log "Write data and read it back"
10347 log "It should not be satisfied from the cache."
10349 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
10350 cancel_lru_locks osc
10352 cat $file >/dev/null
10354 if ! let "AFTER - BEFORE == 0"; then
10355 error_ignore bz20762 "IN CACHE: before: $BEFORE, after: $AFTER"
10357 log "cache hits:: before: $BEFORE, after: $AFTER"
10360 log "Turn on the read cache and turn off the write cache"
10362 set_cache writethrough off
10364 log "Write data and read it back"
10365 log "It should not be satisfied from the cache."
10367 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
10369 cancel_lru_locks osc
10370 cat $file >/dev/null
10372 if ! let "AFTER - BEFORE == 0"; then
10373 error_ignore bz20762 "IN CACHE: before: $BEFORE, after: $AFTER"
10375 log "cache hits:: before: $BEFORE, after: $AFTER"
10378 log "Read again; it should be satisfied from the cache."
10380 cancel_lru_locks osc
10381 cat $file >/dev/null
10383 if ! let "AFTER - BEFORE == CPAGES"; then
10384 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
10386 log "cache hits:: before: $BEFORE, after: $AFTER"
10391 run_test 156 "Verification of tunables"
10395 if [[ $MDSCOUNT -gt 1 ]]; then
10396 error_ignore bz17935 $*
10404 local CL_MASK_PARAM="mdd.$MDT0.changelog_mask"
10406 MASK=$(do_facet $SINGLEMDS $LCTL get_param $CL_MASK_PARAM| grep -c "$1")
10408 if [ $MASK -eq 1 ]; then
10409 do_facet $SINGLEMDS $LCTL set_param $CL_MASK_PARAM="-$1"
10411 do_facet $SINGLEMDS $LCTL set_param $CL_MASK_PARAM="+$1"
10415 changelog_extract_field() {
10419 local identifier=$4
10421 $LFS changelog $mdt | gawk "/$cltype.*$file$/ {
10422 print gensub(/^.* "$identifier'(\[[^\]]*\]).*$/,"\\1",1)}' |
10427 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10428 remote_mds_nodsh && skip "remote MDS with nodsh" && return
10429 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] ||
10430 { skip "Need MDS version at least 2.2.0"; return; }
10432 local CL_USERS="mdd.$MDT0.changelog_users"
10433 local GET_CL_USERS="do_facet $SINGLEMDS $LCTL get_param -n $CL_USERS"
10434 USER=$(do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_register -n)
10435 echo "Registered as changelog user $USER"
10436 $GET_CL_USERS | grep -q $USER ||
10437 error "User $USER not found in changelog_users"
10440 test_mkdir -p $DIR/$tdir/pics/2008/zachy
10441 touch $DIR/$tdir/pics/2008/zachy/timestamp
10442 cp /etc/hosts $DIR/$tdir/pics/2008/zachy/pic1.jpg
10443 mv $DIR/$tdir/pics/2008/zachy $DIR/$tdir/pics/zach
10444 ln $DIR/$tdir/pics/zach/pic1.jpg $DIR/$tdir/pics/2008/portland.jpg
10445 ln -s $DIR/$tdir/pics/2008/portland.jpg $DIR/$tdir/pics/desktop.jpg
10446 rm $DIR/$tdir/pics/desktop.jpg
10448 $LFS changelog $MDT0 | tail -5
10450 echo "verifying changelog mask"
10451 changelog_chmask "MKDIR"
10452 changelog_chmask "CLOSE"
10454 test_mkdir -p $DIR/$tdir/pics/zach/sofia
10455 echo "zzzzzz" > $DIR/$tdir/pics/zach/file
10457 changelog_chmask "MKDIR"
10458 changelog_chmask "CLOSE"
10460 test_mkdir -p $DIR/$tdir/pics/2008/sofia
10461 echo "zzzzzz" > $DIR/$tdir/pics/zach/file
10463 $LFS changelog $MDT0
10464 MKDIRS=$($LFS changelog $MDT0 | tail -5 | grep -c "MKDIR")
10465 CLOSES=$($LFS changelog $MDT0 | tail -5 | grep -c "CLOSE")
10466 [ $MKDIRS -eq 1 ] || err17935 "MKDIR changelog mask count $DIRS != 1"
10467 [ $CLOSES -eq 1 ] || err17935 "CLOSE changelog mask count $DIRS != 1"
10470 echo "verifying target fid"
10471 fidc=$(changelog_extract_field $MDT0 "CREAT" "timestamp" "t=")
10472 fidf=$($LFS path2fid $DIR/$tdir/pics/zach/timestamp)
10473 [ "$fidc" == "$fidf" ] ||
10474 err17935 "fid in changelog $fidc != file fid $fidf"
10475 echo "verifying parent fid"
10476 fidc=$(changelog_extract_field $MDT0 "CREAT" "timestamp" "p=")
10477 fidf=$($LFS path2fid $DIR/$tdir/pics/zach)
10478 [ "$fidc" == "$fidf" ] ||
10479 err17935 "pfid in changelog $fidc != dir fid $fidf"
10481 USER_REC1=$($GET_CL_USERS | awk "\$1 == \"$USER\" {print \$2}")
10482 $LFS changelog_clear $MDT0 $USER $(($USER_REC1 + 5))
10483 USER_REC2=$($GET_CL_USERS | awk "\$1 == \"$USER\" {print \$2}")
10484 echo "verifying user clear: $(( $USER_REC1 + 5 )) == $USER_REC2"
10485 [ $USER_REC2 == $(($USER_REC1 + 5)) ] ||
10486 err17935 "user index expected $(($USER_REC1 + 5)) is $USER_REC2"
10488 MIN_REC=$($GET_CL_USERS |
10489 awk 'min == "" || $2 < min {min = $2}; END {print min}')
10490 FIRST_REC=$($LFS changelog $MDT0 | head -n1 | awk '{print $1}')
10491 echo "verifying min purge: $(( $MIN_REC + 1 )) == $FIRST_REC"
10492 [ $FIRST_REC == $(($MIN_REC + 1)) ] ||
10493 err17935 "first index should be $(($MIN_REC + 1)) is $FIRST_REC"
10495 # LU-3446 changelog index reset on MDT restart
10496 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
10497 CUR_REC1=$($GET_CL_USERS | head -n1 | cut -f3 -d' ')
10498 $LFS changelog_clear $MDT0 $USER 0
10499 stop $SINGLEMDS || error "Fail to stop MDT."
10500 start $SINGLEMDS $MDT_DEV $MDS_MOUNT_OPTS || error "Fail to start MDT."
10501 CUR_REC2=$($GET_CL_USERS | head -n1 | cut -f3 -d' ')
10502 echo "verifying index survives MDT restart: $CUR_REC1 == $CUR_REC2"
10503 [ $CUR_REC1 == $CUR_REC2 ] ||
10504 err17935 "current index should be $CUR_REC1 is $CUR_REC2"
10506 echo "verifying user deregister"
10507 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister $USER
10508 $GET_CL_USERS | grep -q $USER &&
10509 error "User $USER still in changelog_users"
10511 USERS=$(( $($GET_CL_USERS | wc -l) - 2 ))
10512 if [ $USERS -eq 0 ]; then
10513 LAST_REC1=$($GET_CL_USERS | head -n1 | cut -f3 -d' ')
10514 touch $DIR/$tdir/chloe
10515 LAST_REC2=$($GET_CL_USERS | head -n1 | cut -f3 -d' ')
10516 echo "verify changelogs are off: $LAST_REC1 == $LAST_REC2"
10517 [ $LAST_REC1 == $LAST_REC2 ] || error "changelogs not off"
10519 echo "$USERS other changelog users; can't verify off"
10522 run_test 160a "changelog sanity"
10524 test_160b() { # LU-3587
10525 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10526 remote_mds_nodsh && skip "remote MDS with nodsh" && return
10527 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] ||
10528 { skip "Need MDS version at least 2.2.0"; return; }
10530 local CL_USERS="mdd.$MDT0.changelog_users"
10531 local GET_CL_USERS="do_facet $SINGLEMDS $LCTL get_param -n $CL_USERS"
10532 USER=$(do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_register -n)
10533 echo "Registered as changelog user $USER"
10534 $GET_CL_USERS | grep -q $USER ||
10535 error "User $USER not found in changelog_users"
10537 local LONGNAME1=$(str_repeat a 255)
10538 local LONGNAME2=$(str_repeat b 255)
10541 echo "creating very long named file"
10542 touch $LONGNAME1 || error "create of $LONGNAME1 failed"
10543 echo "moving very long named file"
10544 mv $LONGNAME1 $LONGNAME2
10546 $LFS changelog $MDT0 | grep RENME
10548 echo "deregistering $USER"
10549 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister $USER
10553 run_test 160b "Verify that very long rename doesn't crash in changelog"
10556 remote_mds_nodsh && skip "remote MDS with nodsh" && return
10559 local server_version=$(lustre_version_code $SINGLEMDS)
10561 [[ $server_version -gt $(version_code 2.5.57) ]] ||
10562 [[ $server_version -gt $(version_code 2.5.1) &&
10563 $server_version -lt $(version_code 2.5.50) ]] ||
10564 { skip "Need MDS version at least 2.5.58 or 2.5.2+"; return; }
10565 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10567 # Registration step
10568 local USER=$(do_facet $SINGLEMDS $LCTL --device $MDT0 \
10569 changelog_register -n)
10572 mkdir -p $DIR/$tdir
10573 $MCREATE $DIR/$tdir/foo_160c
10574 changelog_chmask "TRUNC"
10575 $TRUNCATE $DIR/$tdir/foo_160c 200
10576 changelog_chmask "TRUNC"
10577 $TRUNCATE $DIR/$tdir/foo_160c 199
10578 $LFS changelog $MDT0
10579 TRUNCS=$($LFS changelog $MDT0 | tail -5 | grep -c "TRUNC")
10580 [ $TRUNCS -eq 1 ] || err17935 "TRUNC changelog mask count $TRUNCS != 1"
10581 $LFS changelog_clear $MDT0 $USER 0
10583 # Deregistration step
10584 echo "deregistering $USER"
10585 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister $USER
10587 run_test 160c "verify that changelog log catch the truncate event"
10590 remote_mds_nodsh && skip "remote MDS with nodsh" && return
10591 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
10593 local server_version=$(lustre_version_code mds1)
10594 local CL_MASK_PARAM="mdd.$MDT0.changelog_mask"
10596 [[ $server_version -ge $(version_code 2.7.60) ]] ||
10597 { skip "Need MDS version at least 2.7.60+"; return; }
10598 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10600 # Registration step
10601 local USER=$(do_facet mds1 $LCTL --device $MDT0 \
10602 changelog_register -n)
10604 mkdir -p $DIR/$tdir/migrate_dir
10605 $LFS changelog_clear $MDT0 $USER 0
10607 $LFS migrate -m 1 $DIR/$tdir/migrate_dir || error "migrate fails"
10608 $LFS changelog $MDT0
10609 MIGRATES=$($LFS changelog $MDT0 | tail -5 | grep -c "MIGRT")
10610 $LFS changelog_clear $MDT0 $USER 0
10611 [ $MIGRATES -eq 1 ] ||
10612 error "MIGRATE changelog mask count $MIGRATES != 1"
10614 # Deregistration step
10615 do_facet mds1 $LCTL --device $MDT0 changelog_deregister $USER
10617 run_test 160d "verify that changelog log catch the migrate event"
10620 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10621 test_mkdir -p -c1 $DIR/$tdir
10622 cp /etc/hosts $DIR/$tdir/$tfile
10623 test_mkdir -c1 $DIR/$tdir/foo1
10624 test_mkdir -c1 $DIR/$tdir/foo2
10625 ln $DIR/$tdir/$tfile $DIR/$tdir/foo1/sofia
10626 ln $DIR/$tdir/$tfile $DIR/$tdir/foo2/zachary
10627 ln $DIR/$tdir/$tfile $DIR/$tdir/foo1/luna
10628 ln $DIR/$tdir/$tfile $DIR/$tdir/foo2/thor
10629 local FID=$($LFS path2fid $DIR/$tdir/$tfile | tr -d '[]')
10630 if [ "$($LFS fid2path $DIR $FID | wc -l)" != "5" ]; then
10631 $LFS fid2path $DIR $FID
10632 err17935 "bad link ea"
10635 rm $DIR/$tdir/foo2/zachary
10637 rm $DIR/$tdir/foo2/thor
10639 rm $DIR/$tdir/$tfile
10641 mv $DIR/$tdir/foo1/sofia $DIR/$tdir/foo2/maggie
10642 if [ "$($LFS fid2path $FSNAME --link 1 $FID)" != "$tdir/foo2/maggie" ]
10644 $LFS fid2path $DIR $FID
10645 err17935 "bad link rename"
10647 rm $DIR/$tdir/foo2/maggie
10650 local longname=filename_avg_len_is_thirty_two_
10651 createmany -l$DIR/$tdir/foo1/luna $DIR/$tdir/foo2/$longname 1000 ||
10652 error "failed to hardlink many files"
10653 links=$($LFS fid2path $DIR $FID | wc -l)
10654 echo -n "${links}/1000 links in link EA"
10655 [[ $links -gt 60 ]] ||
10656 err17935 "expected at least 60 links in link EA"
10657 unlinkmany $DIR/$tdir/foo2/$longname 1000 ||
10658 error "failed to unlink many hardlinks"
10660 run_test 161a "link ea sanity"
10663 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10664 [ $MDSCOUNT -lt 2 ] &&
10665 skip "skipping remote directory test" && return
10667 local remote_dir=$DIR/$tdir/remote_dir
10669 mkdir -p $DIR/$tdir
10670 $LFS mkdir -i $MDTIDX $remote_dir ||
10671 error "create remote directory failed"
10673 cp /etc/hosts $remote_dir/$tfile
10674 mkdir -p $remote_dir/foo1
10675 mkdir -p $remote_dir/foo2
10676 ln $remote_dir/$tfile $remote_dir/foo1/sofia
10677 ln $remote_dir/$tfile $remote_dir/foo2/zachary
10678 ln $remote_dir/$tfile $remote_dir/foo1/luna
10679 ln $remote_dir/$tfile $remote_dir/foo2/thor
10681 local FID=$($LFS path2fid $remote_dir/$tfile | tr -d '[' |
10683 if [ "$($LFS fid2path $DIR $FID | wc -l)" != "5" ]; then
10684 $LFS fid2path $DIR $FID
10685 err17935 "bad link ea"
10688 rm $remote_dir/foo2/zachary
10690 rm $remote_dir/foo2/thor
10692 rm $remote_dir/$tfile
10694 mv $remote_dir/foo1/sofia $remote_dir/foo2/maggie
10695 local link_path=$($LFS fid2path $FSNAME --link 1 $FID)
10696 if [ "$DIR/$link_path" != "$remote_dir/foo2/maggie" ]; then
10697 $LFS fid2path $DIR $FID
10698 err17935 "bad link rename"
10700 rm $remote_dir/foo2/maggie
10703 local longname=filename_avg_len_is_thirty_two_
10704 createmany -l$remote_dir/foo1/luna $remote_dir/foo2/$longname 1000 ||
10705 error "failed to hardlink many files"
10706 links=$($LFS fid2path $DIR $FID | wc -l)
10707 echo -n "${links}/1000 links in link EA"
10708 [[ ${links} -gt 60 ]] ||
10709 err17935 "expected at least 60 links in link EA"
10710 unlinkmany $remote_dir/foo2/$longname 1000 ||
10711 error "failed to unlink many hardlinks"
10713 run_test 161b "link ea sanity under remote directory"
10716 remote_mds_nodsh && skip "remote MDS with nodsh" && return
10717 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10718 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.1.5) ]] &&
10719 skip "Need MDS version at least 2.1.5" && return
10721 # define CLF_RENAME_LAST 0x0001
10722 # rename overwrite a target having nlink = 1 (changelog flag 0x1)
10723 local USER=$(do_facet $SINGLEMDS $LCTL --device $MDT0 \
10724 changelog_register -n)
10726 mkdir -p $DIR/$tdir
10727 touch $DIR/$tdir/foo_161c
10728 touch $DIR/$tdir/bar_161c
10729 mv -f $DIR/$tdir/foo_161c $DIR/$tdir/bar_161c
10730 $LFS changelog $MDT0 | grep RENME
10731 local flags=$($LFS changelog $MDT0 | grep RENME | tail -1 | \
10733 $LFS changelog_clear $MDT0 $USER 0
10734 if [ x$flags != "x0x1" ]; then
10735 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister \
10737 error "flag $flags is not 0x1"
10739 echo "rename overwrite a target having nlink = 1," \
10740 "changelog record has flags of $flags"
10742 # rename overwrite a target having nlink > 1 (changelog flag 0x0)
10743 touch $DIR/$tdir/foo_161c
10744 touch $DIR/$tdir/bar_161c
10745 ln $DIR/$tdir/bar_161c $DIR/$tdir/foobar_161c
10746 mv -f $DIR/$tdir/foo_161c $DIR/$tdir/bar_161c
10747 $LFS changelog $MDT0 | grep RENME
10748 flags=$($LFS changelog $MDT0 | grep RENME | tail -1 | cut -f5 -d' ')
10749 $LFS changelog_clear $MDT0 $USER 0
10750 if [ x$flags != "x0x0" ]; then
10751 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister \
10753 error "flag $flags is not 0x0"
10755 echo "rename overwrite a target having nlink > 1," \
10756 "changelog record has flags of $flags"
10758 # rename doesn't overwrite a target (changelog flag 0x0)
10759 touch $DIR/$tdir/foo_161c
10760 mv -f $DIR/$tdir/foo_161c $DIR/$tdir/foo2_161c
10761 $LFS changelog $MDT0 | grep RENME
10762 flags=$($LFS changelog $MDT0 | grep RENME | tail -1 | cut -f5 -d' ')
10763 $LFS changelog_clear $MDT0 $USER 0
10764 if [ x$flags != "x0x0" ]; then
10765 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister \
10767 error "flag $flags is not 0x0"
10769 echo "rename doesn't overwrite a target," \
10770 "changelog record has flags of $flags"
10772 # define CLF_UNLINK_LAST 0x0001
10773 # unlink a file having nlink = 1 (changelog flag 0x1)
10774 rm -f $DIR/$tdir/foo2_161c
10775 $LFS changelog $MDT0 | grep UNLNK
10776 flags=$($LFS changelog $MDT0 | grep UNLNK | tail -1 | cut -f5 -d' ')
10777 $LFS changelog_clear $MDT0 $USER 0
10778 if [ x$flags != "x0x1" ]; then
10779 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister \
10781 error "flag $flags is not 0x1"
10783 echo "unlink a file having nlink = 1," \
10784 "changelog record has flags of $flags"
10786 # unlink a file having nlink > 1 (changelog flag 0x0)
10787 ln -f $DIR/$tdir/bar_161c $DIR/$tdir/foobar_161c
10788 rm -f $DIR/$tdir/foobar_161c
10789 $LFS changelog $MDT0 | grep UNLNK
10790 flags=$($LFS changelog $MDT0 | grep UNLNK | tail -1 | cut -f5 -d' ')
10791 $LFS changelog_clear $MDT0 $USER 0
10792 if [ x$flags != "x0x0" ]; then
10793 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister \
10795 error "flag $flags is not 0x0"
10797 echo "unlink a file having nlink > 1," \
10798 "changelog record has flags of $flags"
10799 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister $USER
10801 run_test 161c "check CL_RENME[UNLINK] changelog record flags"
10808 local path=$(${LFS} fid2path $*)
10809 # Remove the '//' indicating a remote directory
10810 path=$(echo $path | sed 's#//#/#g')
10813 if [ $RC -ne 0 ]; then
10814 err17935 "path looked up of $expected failed. Error $RC"
10816 elif [ "${path}" != "${expected}" ]; then
10817 err17935 "path looked up \"${path}\" instead of \"${expected}\""
10820 echo "fid $fid resolves to path $path (expected $expected)"
10823 test_162a() { # was test_162
10824 # Make changes to filesystem
10825 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10826 test_mkdir -p -c1 $DIR/$tdir/d2
10827 touch $DIR/$tdir/d2/$tfile
10828 touch $DIR/$tdir/d2/x1
10829 touch $DIR/$tdir/d2/x2
10830 test_mkdir -p -c1 $DIR/$tdir/d2/a/b/c
10831 test_mkdir -p -c1 $DIR/$tdir/d2/p/q/r
10833 FID=$($LFS path2fid $DIR/$tdir/d2/$tfile | tr -d '[]')
10834 check_path "$tdir/d2/$tfile" $FSNAME $FID --link 0 ||
10835 error "check path $tdir/d2/$tfile failed"
10838 ln -s $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/p/q/r/slink
10839 FID=$($LFS path2fid $DIR/$tdir/d2/p/q/r/slink | tr -d '[]')
10840 check_path "$tdir/d2/p/q/r/slink" $FSNAME $FID --link 0 ||
10841 error "check path $tdir/d2/p/q/r/slink failed"
10843 # softlink to wrong file
10844 ln -s /this/is/garbage $DIR/$tdir/d2/p/q/r/slink.wrong
10845 FID=$($LFS path2fid $DIR/$tdir/d2/p/q/r/slink.wrong | tr -d '[]')
10846 check_path "$tdir/d2/p/q/r/slink.wrong" $FSNAME $FID --link 0 ||
10847 error "check path $tdir/d2/p/q/r/slink.wrong failed"
10850 ln $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/p/q/r/hlink
10851 mv $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/a/b/c/new_file
10852 FID=$($LFS path2fid $DIR/$tdir/d2/a/b/c/new_file | tr -d '[]')
10853 # fid2path dir/fsname should both work
10854 check_path "$tdir/d2/a/b/c/new_file" $FSNAME $FID --link 1 ||
10855 error "check path $tdir/d2/a/b/c/new_file failed"
10856 check_path "$DIR/$tdir/d2/p/q/r/hlink" $DIR $FID --link 0 ||
10857 error "check path $DIR/$tdir/d2/p/q/r/hlink failed"
10859 # hardlink count: check that there are 2 links
10860 # Doesnt work with CMD yet: 17935
10861 ${LFS} fid2path $DIR $FID | wc -l | grep -q 2 || \
10862 err17935 "expected 2 links"
10864 # hardlink indexing: remove the first link
10865 rm $DIR/$tdir/d2/p/q/r/hlink
10866 check_path "$tdir/d2/a/b/c/new_file" $FSNAME $FID --link 0 ||
10867 error "check path $DIR/$tdir/d2/a/b/c/new_file failed"
10871 run_test 162a "path lookup sanity"
10874 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10875 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
10878 $LFS setdirstripe -i0 -c$MDSCOUNT -t all_char $DIR/$tdir/striped_dir ||
10879 error "create striped dir failed"
10881 local FID=$($LFS getdirstripe $DIR/$tdir/striped_dir |
10882 tail -n 1 | awk '{print $2}')
10883 stat $MOUNT/.lustre/fid/$FID && error "sub_stripe can be accessed"
10885 touch $DIR/$tdir/striped_dir/f{0..4} || error "touch f0..4 failed"
10886 mkdir $DIR/$tdir/striped_dir/d{0..4} || error "mkdir d0..4 failed"
10889 for ((i=0;i<5;i++)); do
10890 FID=$($LFS path2fid $DIR/$tdir/striped_dir/f$i | tr -d '[]') ||
10891 error "get fid for f$i failed"
10892 check_path "$tdir/striped_dir/f$i" $FSNAME $FID --link 0 ||
10893 error "check path $tdir/striped_dir/f$i failed"
10895 FID=$($LFS path2fid $DIR/$tdir/striped_dir/d$i | tr -d '[]') ||
10896 error "get fid for d$i failed"
10897 check_path "$tdir/striped_dir/d$i" $FSNAME $FID --link 0 ||
10898 error "check path $tdir/striped_dir/d$i failed"
10903 run_test 162b "striped directory path lookup sanity"
10905 # LU-4239: Verify fid2path works with paths 100 or more directories deep
10907 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.51) ]] &&
10908 skip "Need MDS version at least 2.7.51" && return
10909 test_mkdir $DIR/$tdir.local
10910 test_mkdir $DIR/$tdir.remote
10911 local lpath=$tdir.local
10912 local rpath=$tdir.remote
10914 for ((i = 0; i <= 101; i++)); do
10917 FID=$($LFS path2fid $DIR/$lpath | tr -d '[]') ||
10918 error "get fid for local directory $DIR/$lpath failed"
10919 check_path "$DIR/$lpath" $MOUNT $FID --link 0 ||
10920 error "check path for local directory $DIR/$lpath failed"
10923 test_mkdir $DIR/$rpath
10924 FID=$($LFS path2fid $DIR/$rpath | tr -d '[]') ||
10925 error "get fid for remote directory $DIR/$rpath failed"
10926 check_path "$DIR/$rpath" $MOUNT $FID --link 0 ||
10927 error "check path for remote directory $DIR/$rpath failed"
10932 run_test 162c "fid2path works with paths 100 or more directories deep"
10935 # do directio so as not to populate the page cache
10936 log "creating a 10 Mb file"
10937 $MULTIOP $DIR/$tfile oO_CREAT:O_DIRECT:O_RDWR:w$((10*1048576))c || error "multiop failed while creating a file"
10938 log "starting reads"
10939 dd if=$DIR/$tfile of=/dev/null bs=4096 &
10940 log "truncating the file"
10941 $MULTIOP $DIR/$tfile oO_TRUNC:c || error "multiop failed while truncating the file"
10943 kill %+ || true # reads might have finished
10944 echo "wait until dd is finished"
10946 log "removing the temporary file"
10947 rm -rf $DIR/$tfile || error "tmp file removal failed"
10949 run_test 169 "parallel read and truncate should not deadlock"
10952 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10953 $LCTL clear # bug 18514
10954 $LCTL debug_daemon start $TMP/${tfile}_log_good
10956 $LCTL debug_daemon stop
10957 sed -e "s/^...../a/g" $TMP/${tfile}_log_good > $TMP/${tfile}_log_bad ||
10958 error "sed failed to read log_good"
10960 $LCTL debug_daemon start $TMP/${tfile}_log_good
10962 $LCTL debug_daemon stop
10964 $LCTL df $TMP/${tfile}_log_bad > $TMP/${tfile}_log_bad.out 2>&1 ||
10965 error "lctl df log_bad failed"
10967 local bad_line=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $9}')
10968 local good_line1=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $5}')
10970 $LCTL df $TMP/${tfile}_log_good > $TMP/${tfile}_log_good.out 2>&1
10971 local good_line2=$(tail -n 1 $TMP/${tfile}_log_good.out | awk '{print $5}')
10973 [ "$bad_line" ] && [ "$good_line1" ] && [ "$good_line2" ] ||
10974 error "bad_line good_line1 good_line2 are empty"
10976 cat $TMP/${tfile}_log_good >> $TMP/${tfile}_logs_corrupt
10977 cat $TMP/${tfile}_log_bad >> $TMP/${tfile}_logs_corrupt
10978 cat $TMP/${tfile}_log_good >> $TMP/${tfile}_logs_corrupt
10980 $LCTL df $TMP/${tfile}_logs_corrupt > $TMP/${tfile}_log_bad.out 2>&1
10981 local bad_line_new=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $9}')
10982 local good_line_new=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $5}')
10984 [ "$bad_line_new" ] && [ "$good_line_new" ] ||
10985 error "bad_line_new good_line_new are empty"
10987 local expected_good=$((good_line1 + good_line2*2))
10989 rm -f $TMP/${tfile}*
10990 # LU-231, short malformed line may not be counted into bad lines
10991 if [ $bad_line -ne $bad_line_new ] &&
10992 [ $bad_line -ne $((bad_line_new - 1)) ]; then
10993 error "expected $bad_line bad lines, but got $bad_line_new"
10997 if [ $expected_good -ne $good_line_new ]; then
10998 error "expected $expected_good good lines, but got $good_line_new"
11003 run_test 170 "test lctl df to handle corrupted log ====================="
11005 test_171() { # bug20592
11006 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11007 #define OBD_FAIL_PTLRPC_DUMP_LOG 0x50e
11008 $LCTL set_param fail_loc=0x50e
11009 $LCTL set_param fail_val=3000
11010 multiop_bg_pause $DIR/$tfile O_s || true
11012 kill -USR1 $MULTIPID
11016 if dmesg | grep "recursive fault"; then
11017 error "caught a recursive fault"
11019 $LCTL set_param fail_loc=0
11022 run_test 171 "test libcfs_debug_dumplog_thread stuck in do_exit() ======"
11024 # it would be good to share it with obdfilter-survey/iokit-libecho code
11025 setup_obdecho_osc () {
11028 local obdfilter_name=$2
11029 echo "Creating new osc for $obdfilter_name on $ost_nid"
11030 # make sure we can find loopback nid
11031 $LCTL add_uuid $ost_nid $ost_nid >/dev/null 2>&1
11033 [ $rc -eq 0 ] && { $LCTL attach osc ${obdfilter_name}_osc \
11034 ${obdfilter_name}_osc_UUID || rc=2; }
11035 [ $rc -eq 0 ] && { $LCTL --device ${obdfilter_name}_osc setup \
11036 ${obdfilter_name}_UUID $ost_nid || rc=3; }
11040 cleanup_obdecho_osc () {
11041 local obdfilter_name=$1
11042 $LCTL --device ${obdfilter_name}_osc cleanup >/dev/null
11043 $LCTL --device ${obdfilter_name}_osc detach >/dev/null
11050 local pages=${3:-64}
11055 local obd_size=$(get_obd_size $node $OBD)
11056 local page_size=$(get_page_size $node)
11057 if [[ -n "$obd_size" ]]; then
11058 local new_count=$((obd_size / (pages * page_size / 1024)))
11059 [[ $new_count -ge $count ]] || count=$new_count
11062 do_facet $node "$LCTL attach echo_client ec ec_uuid" || rc=1
11063 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec setup $OBD" ||
11065 if [ $rc -eq 0 ]; then
11066 id=$(do_facet $node "$LCTL --device ec create 1" | awk '/object id/ {print $6}')
11067 [ ${PIPESTATUS[0]} -eq 0 -a -n "$id" ] || rc=3
11069 echo "New object id is $id"
11070 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec getattr $id" ||
11072 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec " \
11073 "test_brw $count w v $pages $id" || rc=4; }
11074 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec destroy $id 1" ||
11076 [ $rc -eq 0 -o $rc -gt 2 ] && { do_facet $node "$LCTL --device ec " \
11077 "cleanup" || rc=5; }
11078 [ $rc -eq 0 -o $rc -gt 1 ] && { do_facet $node "$LCTL --device ec " \
11079 "detach" || rc=6; }
11080 [ $rc -ne 0 ] && echo "obecho_create_test failed: $rc"
11085 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11086 remote_ost_nodsh && skip "remote OST with nodsh" && return
11088 local rmmod_local=0
11090 if ! module_loaded obdecho; then
11091 load_module obdecho/obdecho
11095 local osc=$($LCTL dl | grep -v mdt | awk '$3 == "osc" {print $4; exit}')
11096 local host=$(lctl get_param -n osc.$osc.import |
11097 awk '/current_connection:/ {print $2}' )
11098 local target=$(lctl get_param -n osc.$osc.import |
11099 awk '/target:/ {print $2}' )
11100 target=${target%_UUID}
11102 [[ -n $target ]] && { setup_obdecho_osc $host $target || rc=1; } || rc=1
11103 [ $rc -eq 0 ] && { obdecho_test ${target}_osc client || rc=2; }
11104 [[ -n $target ]] && cleanup_obdecho_osc $target
11105 [ $rmmod_local -eq 1 ] && rmmod obdecho
11108 run_test 180a "test obdecho on osc"
11111 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11112 remote_ost_nodsh && skip "remote OST with nodsh" && return
11114 local rmmod_remote=0
11116 do_facet ost1 "lsmod | grep -q obdecho || " \
11117 "{ insmod ${LUSTRE}/obdecho/obdecho.ko || " \
11118 "modprobe obdecho; }" && rmmod_remote=1
11119 target=$(do_facet ost1 $LCTL dl | awk '/obdfilter/ {print $4;exit}')
11120 [[ -n $target ]] && { obdecho_test $target ost1 || rc=1; }
11121 [ $rmmod_remote -eq 1 ] && do_facet ost1 "rmmod obdecho"
11124 run_test 180b "test obdecho directly on obdfilter"
11126 test_180c() { # LU-2598
11127 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11128 remote_ost_nodsh && skip "remote OST with nodsh" && return
11129 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.0) ]] &&
11130 skip "Need MDS version at least 2.4.0" && return
11133 local rmmod_remote=false
11134 local pages=16384 # 64MB bulk I/O RPC size
11137 do_rpc_nodes $(facet_active_host ost1) load_module obdecho/obdecho &&
11138 rmmod_remote=true || error "failed to load module obdecho"
11140 target=$(do_facet ost1 $LCTL dl | awk '/obdfilter/ { print $4 }' |
11142 if [ -n "$target" ]; then
11143 obdecho_test "$target" ost1 "$pages" || rc=${PIPESTATUS[0]}
11145 echo "there is no obdfilter target on ost1"
11148 $rmmod_remote && do_facet ost1 "rmmod obdecho" || true
11151 run_test 180c "test huge bulk I/O size on obdfilter, don't LASSERT"
11153 test_181() { # bug 22177
11154 test_mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
11155 # create enough files to index the directory
11156 createmany -o $DIR/$tdir/foobar 4000
11157 # print attributes for debug purpose
11160 multiop_bg_pause $DIR/$tdir D_Sc || return 1
11162 # remove the files & current working dir
11163 unlinkmany $DIR/$tdir/foobar 4000
11165 kill -USR1 $MULTIPID
11167 stat $DIR/$tdir && error "open-unlinked dir was not removed!"
11170 run_test 181 "Test open-unlinked dir ========================"
11176 mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
11178 $LCTL set_param mdc.*.rpc_stats=clear
11180 for (( i = 0; i < $tcount; i++ )) ; do
11181 mkdir $DIR/$tdir/$i
11184 for (( i = 0; i < $tcount; i++ )) ; do
11185 createmany -o $DIR/$tdir/$i/f- $fcount &
11189 for (( i = 0; i < $tcount; i++ )) ; do
11190 unlinkmany $DIR/$tdir/$i/f- $fcount &
11194 $LCTL get_param mdc.*.rpc_stats
11198 run_test 182 "Test parallel modify metadata operations ================"
11200 test_183() { # LU-2275
11201 remote_mds_nodsh && skip "remote MDS with nodsh" && return
11202 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.3.56) ]] &&
11203 skip "Need MDS version at least 2.3.56" && return
11205 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11206 mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
11207 echo aaa > $DIR/$tdir/$tfile
11209 #define OBD_FAIL_MDS_NEGATIVE_POSITIVE 0x148
11210 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x148
11212 ls -l $DIR/$tdir && error "ls succeeded, should have failed"
11213 cat $DIR/$tdir/$tfile && error "cat succeeded, should have failed"
11215 do_facet $SINGLEMDS $LCTL set_param fail_loc=0
11217 # Flush negative dentry cache
11218 touch $DIR/$tdir/$tfile
11220 # We are not checking for any leaked references here, they'll
11221 # become evident next time we do cleanup with module unload.
11224 run_test 183 "No crash or request leak in case of strange dispositions ========"
11226 # test suite 184 is for LU-2016, LU-2017
11228 check_swap_layouts_support && return 0
11230 dir0=$DIR/$tdir/$testnum
11231 test_mkdir -p -c1 $dir0 || error "creating dir $dir0"
11236 $SETSTRIPE -c1 $file1
11238 $SETSTRIPE -c2 $file2
11240 gen1=$($GETSTRIPE -g $file1)
11241 gen2=$($GETSTRIPE -g $file2)
11243 $LFS swap_layouts $file1 $file2 || error "swap of file layout failed"
11244 gen=$($GETSTRIPE -g $file1)
11245 [[ $gen1 != $gen ]] ||
11246 "Layout generation on $file1 does not change"
11247 gen=$($GETSTRIPE -g $file2)
11248 [[ $gen2 != $gen ]] ||
11249 "Layout generation on $file2 does not change"
11251 cmp $ref1 $file2 || error "content compare failed ($ref1 != $file2)"
11252 cmp $ref2 $file1 || error "content compare failed ($ref2 != $file1)"
11254 run_test 184a "Basic layout swap"
11257 check_swap_layouts_support && return 0
11259 dir0=$DIR/$tdir/$testnum
11260 mkdir -p $dir0 || error "creating dir $dir0"
11267 $SETSTRIPE -c1 $file1
11268 $SETSTRIPE -c2 $file2
11269 $SETSTRIPE -c1 $file3
11270 chown $RUNAS_ID $file3
11271 gen1=$($GETSTRIPE -g $file1)
11272 gen2=$($GETSTRIPE -g $file2)
11274 $LFS swap_layouts $dir1 $dir2 &&
11275 error "swap of directories layouts should fail"
11276 $LFS swap_layouts $dir1 $file1 &&
11277 error "swap of directory and file layouts should fail"
11278 $RUNAS $LFS swap_layouts $file1 $file2 &&
11279 error "swap of file we cannot write should fail"
11280 $LFS swap_layouts $file1 $file3 &&
11281 error "swap of file with different owner should fail"
11282 /bin/true # to clear error code
11284 run_test 184b "Forbidden layout swap (will generate errors)"
11287 check_swap_layouts_support && return 0
11289 local dir0=$DIR/$tdir/$testnum
11290 mkdir -p $dir0 || error "creating dir $dir0"
11292 local ref1=$dir0/ref1
11293 local ref2=$dir0/ref2
11294 local file1=$dir0/file1
11295 local file2=$dir0/file2
11296 # create a file large enough for the concurrent test
11297 dd if=/dev/urandom of=$ref1 bs=1M count=$((RANDOM % 50 + 20))
11298 dd if=/dev/urandom of=$ref2 bs=1M count=$((RANDOM % 50 + 20))
11299 echo "ref file size: ref1($(stat -c %s $ref1))," \
11300 "ref2($(stat -c %s $ref2))"
11303 dd if=$ref1 of=$file1 bs=16k &
11306 # Make sure dd starts to copy file
11307 while [ ! -f $file1 ]; do sleep 0.1; done
11309 $LFS swap_layouts $file1 $file2
11312 [[ $? == 0 ]] || error "concurrent write on $file1 failed"
11313 [[ $rc == 0 ]] || error "swap of $file1 and $file2 failed"
11315 # how many bytes copied before swapping layout
11316 local copied=$(stat -c %s $file2)
11317 local remaining=$(stat -c %s $ref1)
11318 remaining=$((remaining - copied))
11319 echo "Copied $copied bytes before swapping layout..."
11321 cmp -n $copied $file1 $ref2 | grep differ &&
11322 error "Content mismatch [0, $copied) of ref2 and file1"
11323 cmp -n $copied $file2 $ref1 ||
11324 error "Content mismatch [0, $copied) of ref1 and file2"
11325 cmp -i $copied:$copied -n $remaining $file1 $ref1 ||
11326 error "Content mismatch [$copied, EOF) of ref1 and file1"
11329 rm -f $ref1 $ref2 $file1 $file2
11331 run_test 184c "Concurrent write and layout swap"
11334 check_swap_layouts_support && return 0
11335 [ -z "$(which getfattr 2>/dev/null)" ] &&
11336 skip "no getfattr command" && return 0
11338 local file1=$DIR/$tdir/$tfile-1
11339 local file2=$DIR/$tdir/$tfile-2
11340 local file3=$DIR/$tdir/$tfile-3
11344 mkdir -p $DIR/$tdir
11345 touch $file1 || error "create $file1 failed"
11346 $OPENFILE -f O_CREAT:O_LOV_DELAY_CREATE $file2 ||
11347 error "create $file2 failed"
11348 $OPENFILE -f O_CREAT:O_LOV_DELAY_CREATE $file3 ||
11349 error "create $file3 failed"
11350 lovea1=$($LFS getstripe $file1 | sed 1d)
11352 $LFS swap_layouts $file2 $file3 ||
11353 error "swap $file2 $file3 layouts failed"
11354 $LFS swap_layouts $file1 $file2 ||
11355 error "swap $file1 $file2 layouts failed"
11357 lovea2=$($LFS getstripe $file2 | sed 1d)
11358 [ "$lovea1" == "$lovea2" ] || error "lovea $lovea1 != $lovea2"
11360 lovea1=$(getfattr -n trusted.lov $file1 | grep ^trusted)
11361 [[ -z "$lovea1" ]] || error "$file1 shouldn't have lovea"
11363 run_test 184d "allow stripeless layouts swap"
11366 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.6.94) ]] ||
11367 { skip "Need MDS version at least 2.6.94"; return 0; }
11368 check_swap_layouts_support && return 0
11369 [ -z "$(which getfattr 2>/dev/null)" ] &&
11370 skip "no getfattr command" && return 0
11372 local file1=$DIR/$tdir/$tfile-1
11373 local file2=$DIR/$tdir/$tfile-2
11374 local file3=$DIR/$tdir/$tfile-3
11377 mkdir -p $DIR/$tdir
11378 touch $file1 || error "create $file1 failed"
11379 $OPENFILE -f O_CREAT:O_LOV_DELAY_CREATE $file2 ||
11380 error "create $file2 failed"
11381 $OPENFILE -f O_CREAT:O_LOV_DELAY_CREATE $file3 ||
11382 error "create $file3 failed"
11384 $LFS swap_layouts $file1 $file2 ||
11385 error "swap $file1 $file2 layouts failed"
11387 lovea=$(getfattr -n trusted.lov $file1 | grep ^trusted)
11388 [[ -z "$lovea" ]] || error "$file1 shouldn't have lovea"
11390 echo 123 > $file1 || error "Should be able to write into $file1"
11392 $LFS swap_layouts $file1 $file3 ||
11393 error "swap $file1 $file3 layouts failed"
11395 echo 123 > $file1 || error "Should be able to write into $file1"
11397 rm -rf $file1 $file2 $file3
11399 run_test 184e "Recreate layout after stripeless layout swaps"
11401 test_185() { # LU-2441
11402 # LU-3553 - no volatile file support in old servers
11403 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.3.60) ]] ||
11404 { skip "Need MDS version at least 2.3.60"; return 0; }
11406 mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
11407 touch $DIR/$tdir/spoo
11408 local mtime1=$(stat -c "%Y" $DIR/$tdir)
11409 local fid=$($MULTIOP $DIR/$tdir VFw4096c) ||
11410 error "cannot create/write a volatile file"
11411 $CHECKSTAT -t file $MOUNT/.lustre/fid/$fid 2>/dev/null &&
11412 error "FID is still valid after close"
11414 multiop_bg_pause $DIR/$tdir vVw4096_c
11421 # assume that the next FID for this client is sequential, since stdout
11422 # is unfortunately eaten by multiop_bg_pause
11423 local n=$((${fidv[1]} + 1))
11424 local next_fid="${fidv[0]}:$(printf "0x%x" $n):${fidv[2]}"
11425 $CHECKSTAT -t file $MOUNT/.lustre/fid/$next_fid ||
11426 error "FID is missing before close"
11427 kill -USR1 $multi_pid
11428 # 1 second delay, so if mtime change we will see it
11430 local mtime2=$(stat -c "%Y" $DIR/$tdir)
11431 [[ $mtime1 == $mtime2 ]] || error "mtime has changed"
11433 run_test 185 "Volatile file support"
11436 remote_mds_nodsh && skip "remote MDS with nodsh" && return
11437 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.3.0) ] &&
11438 skip "Need MDS version at least 2.3.0" && return
11440 local dir0=$DIR/$tdir/$testnum
11441 mkdir -p $dir0 || error "creating dir $dir0"
11443 local file=$dir0/file1
11444 dd if=/dev/urandom of=$file count=10 bs=1M conv=fsync
11445 local dv1=$($LFS data_version $file)
11446 dd if=/dev/urandom of=$file seek=10 count=1 bs=1M conv=fsync
11447 local dv2=$($LFS data_version $file)
11448 [[ $dv1 != $dv2 ]] ||
11449 error "data version did not change on write $dv1 == $dv2"
11454 run_test 187a "Test data version change"
11457 remote_mds_nodsh && skip "remote MDS with nodsh" && return
11458 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.3.0) ] &&
11459 skip "Need MDS version at least 2.3.0" && return
11461 local dir0=$DIR/$tdir/$testnum
11462 mkdir -p $dir0 || error "creating dir $dir0"
11464 declare -a DV=$($MULTIOP $dir0 Vw1000xYw1000xY | cut -f3 -d" ")
11465 [[ ${DV[0]} != ${DV[1]} ]] ||
11466 error "data version did not change on write"\
11467 " ${DV[0]} == ${DV[1]}"
11472 run_test 187b "Test data version change on volatile file"
11475 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11476 remote_mgs_nodsh && skip "remote MGS with nodsh" && return
11478 local POOL=${POOL:-cea1}
11479 local POOL_ROOT=${POOL_ROOT:-$DIR/d200.pools}
11480 local POOL_DIR_NAME=${POOL_DIR_NAME:-dir_tst}
11483 local last_ost=$(($OSTCOUNT - 1))
11485 local ost_list=$(seq $first_ost $ost_step $last_ost)
11486 local ost_range="$first_ost $last_ost $ost_step"
11487 local test_path=$POOL_ROOT/$POOL_DIR_NAME
11488 local file_dir=$POOL_ROOT/file_tst
11489 local subdir=$test_path/subdir
11493 # former test_200a test_200b
11494 pool_add $POOL || { rc=$? ; break; }
11495 pool_add_targets $POOL $ost_range || { rc=$? ; break; }
11496 # former test_200c test_200d
11497 mkdir -p $test_path
11498 pool_set_dir $POOL $test_path || { rc=$? ; break; }
11499 pool_check_dir $POOL $test_path || { rc=$? ; break; }
11501 pool_check_dir $POOL $subdir || { rc=$? ; break; }
11502 pool_dir_rel_path $POOL $POOL_DIR_NAME $POOL_ROOT \
11503 || { rc=$? ; break; }
11504 # former test_200e test_200f
11505 local files=$((OSTCOUNT*3))
11506 pool_alloc_files $POOL $test_path $files "$ost_list" \
11507 || { rc=$? ; break; }
11508 pool_create_files $POOL $file_dir $files "$ost_list" \
11509 || { rc=$? ; break; }
11510 # former test_200g test_200h
11511 pool_lfs_df $POOL || { rc=$? ; break; }
11512 pool_file_rel_path $POOL $test_path || { rc=$? ; break; }
11514 # former test_201a test_201b test_201c
11515 pool_remove_first_target $POOL || { rc=$? ; break; }
11517 local f=$test_path/$tfile
11518 pool_remove_all_targets $POOL $f || { rc=$? ; break; }
11519 pool_remove $POOL $f || { rc=$? ; break; }
11526 run_test 200 "OST pools"
11528 # usage: default_attr <count | size | offset>
11530 $LCTL get_param -n lov.$FSNAME-clilov-\*.stripe${1}
11533 # usage: check_default_stripe_attr
11534 check_default_stripe_attr() {
11535 ACTUAL=$($GETSTRIPE $* $DIR/$tdir)
11537 --stripe-count|--count)
11538 [ -n "$2" ] && EXPECTED=0 || EXPECTED=$(default_attr count);;
11539 --stripe-size|--size)
11540 [ -n "$2" ] && EXPECTED=0 || EXPECTED=$(default_attr size);;
11541 --stripe-index|--index)
11544 error "unknown getstripe attr '$1'"
11547 [ $ACTUAL != $EXPECTED ] &&
11548 error "$DIR/$tdir has $1 '$ACTUAL', not '$EXPECTED'"
11552 test_mkdir -p $DIR/$tdir
11553 $SETSTRIPE --stripe-count 0 --stripe-size 0 --stripe-index -1 $DIR/$tdir
11555 check_default_stripe_attr --stripe-count
11556 check_default_stripe_attr --stripe-size
11557 check_default_stripe_attr --stripe-index
11561 run_test 204a "Print default stripe attributes ================="
11564 test_mkdir -p $DIR/$tdir
11565 $SETSTRIPE --stripe-count 1 $DIR/$tdir
11567 check_default_stripe_attr --stripe-size
11568 check_default_stripe_attr --stripe-index
11572 run_test 204b "Print default stripe size and offset ==========="
11575 test_mkdir -p $DIR/$tdir
11576 $SETSTRIPE --stripe-size 65536 $DIR/$tdir
11578 check_default_stripe_attr --stripe-count
11579 check_default_stripe_attr --stripe-index
11583 run_test 204c "Print default stripe count and offset ==========="
11586 test_mkdir -p $DIR/$tdir
11587 $SETSTRIPE --stripe-index 0 $DIR/$tdir
11589 check_default_stripe_attr --stripe-count
11590 check_default_stripe_attr --stripe-size
11594 run_test 204d "Print default stripe count and size ============="
11597 test_mkdir -p $DIR/$tdir
11598 $SETSTRIPE -d $DIR/$tdir
11600 check_default_stripe_attr --stripe-count --raw
11601 check_default_stripe_attr --stripe-size --raw
11602 check_default_stripe_attr --stripe-index --raw
11606 run_test 204e "Print raw stripe attributes ================="
11609 test_mkdir -p $DIR/$tdir
11610 $SETSTRIPE --stripe-count 1 $DIR/$tdir
11612 check_default_stripe_attr --stripe-size --raw
11613 check_default_stripe_attr --stripe-index --raw
11617 run_test 204f "Print raw stripe size and offset ==========="
11620 test_mkdir -p $DIR/$tdir
11621 $SETSTRIPE --stripe-size 65536 $DIR/$tdir
11623 check_default_stripe_attr --stripe-count --raw
11624 check_default_stripe_attr --stripe-index --raw
11628 run_test 204g "Print raw stripe count and offset ==========="
11631 test_mkdir -p $DIR/$tdir
11632 $SETSTRIPE --stripe-index 0 $DIR/$tdir
11634 check_default_stripe_attr --stripe-count --raw
11635 check_default_stripe_attr --stripe-size --raw
11639 run_test 204h "Print raw stripe count and size ============="
11641 # Figure out which job scheduler is being used, if any,
11642 # or use a fake one
11643 if [ -n "$SLURM_JOB_ID" ]; then # SLURM
11644 JOBENV=SLURM_JOB_ID
11645 elif [ -n "$LSB_JOBID" ]; then # Load Sharing Facility
11647 elif [ -n "$PBS_JOBID" ]; then # PBS/Maui/Moab
11649 elif [ -n "$LOADL_STEPID" ]; then # LoadLeveller
11650 JOBENV=LOADL_STEP_ID
11651 elif [ -n "$JOB_ID" ]; then # Sun Grid Engine
11654 $LCTL list_param jobid_name > /dev/null 2>&1
11655 if [ $? -eq 0 ]; then
11662 verify_jobstats() {
11667 # we don't really need to clear the stats for this test to work, since each
11668 # command has a unique jobid, but it makes debugging easier if needed.
11669 # for facet in $facets; do
11670 # local dev=$(convert_facet2label $facet)
11671 # # clear old jobstats
11672 # do_facet $facet lctl set_param *.$dev.job_stats="clear"
11675 # use a new JobID for each test, or we might see an old one
11676 [ "$JOBENV" = "FAKE_JOBID" ] &&
11677 FAKE_JOBID=id.$testnum.$(basename ${cmd[0]}).$RANDOM
11681 [ "$JOBENV" = "nodelocal" ] && {
11682 FAKE_JOBID=id.$testnum.$(basename ${cmd[0]}).$RANDOM
11683 $LCTL set_param jobid_name=$FAKE_JOBID
11687 log "Test: ${cmd[*]}"
11688 log "Using JobID environment variable $JOBENV=$JOBVAL"
11690 if [ $JOBENV = "FAKE_JOBID" ]; then
11691 FAKE_JOBID=$JOBVAL ${cmd[*]}
11696 # all files are created on OST0000
11697 for facet in $facets; do
11698 local stats="*.$(convert_facet2label $facet).job_stats"
11699 if [ $(do_facet $facet lctl get_param $stats |
11700 grep -c $JOBVAL) -ne 1 ]; then
11701 do_facet $facet lctl get_param $stats
11702 error "No jobstats for $JOBVAL found on $facet::$stats"
11709 NEW_JOBENV=${1:-$OLD_JOBENV}
11710 do_facet mgs $LCTL conf_param $FSNAME.sys.jobid_var=$NEW_JOBENV
11711 wait_update $HOSTNAME "$LCTL get_param -n jobid_var" $NEW_JOBENV
11715 do_facet $SINGLEMDS \
11716 $LCTL set_param mdt.*.job_cleanup_interval=$OLD_INTERVAL
11717 [ $OLD_JOBENV != $JOBENV ] && jobstats_set $OLD_JOBENV
11718 do_facet $SINGLEMDS lctl --device $MDT0 changelog_deregister $CL_USER
11721 test_205() { # Job stats
11722 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11723 remote_mgs_nodsh && skip "remote MGS with nodsh" && return
11724 remote_mds_nodsh && skip "remote MDS with nodsh" && return
11725 remote_ost_nodsh && skip "remote OST with nodsh" && return
11727 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep jobstats)" ] &&
11728 skip "Server doesn't support jobstats" && return 0
11729 [[ $JOBID_VAR = disable ]] && skip "jobstats is disabled" && return
11731 OLD_JOBENV=$($LCTL get_param -n jobid_var)
11732 if [ $OLD_JOBENV != $JOBENV ]; then
11733 jobstats_set $JOBENV
11734 trap cleanup_205 EXIT
11737 CL_USER=$(do_facet $SINGLEMDS lctl --device $MDT0 changelog_register -n)
11738 echo "Registered as changelog user $CL_USER"
11740 OLD_INTERVAL=$(do_facet $SINGLEMDS \
11741 lctl get_param -n mdt.*.job_cleanup_interval)
11742 local interval_new=5
11743 do_facet $SINGLEMDS \
11744 $LCTL set_param mdt.*.job_cleanup_interval=$interval_new
11745 local start=$SECONDS
11749 cmd="mkdir $DIR/$tdir"
11750 verify_jobstats "$cmd" "$SINGLEMDS"
11752 cmd="rmdir $DIR/$tdir"
11753 verify_jobstats "$cmd" "$SINGLEMDS"
11754 # mkdir on secondary MDT
11755 if [ $MDSCOUNT -gt 1 ]; then
11756 cmd="lfs mkdir -i 1 $DIR/$tdir.remote"
11757 verify_jobstats "$cmd" "mds2"
11760 cmd="mknod $DIR/$tfile c 1 3"
11761 verify_jobstats "$cmd" "$SINGLEMDS"
11763 cmd="rm -f $DIR/$tfile"
11764 verify_jobstats "$cmd" "$SINGLEMDS"
11765 # create all files on OST0000 so verify_jobstats can find OST stats
11767 cmd="$SETSTRIPE -i 0 -c 1 $DIR/$tfile"
11768 verify_jobstats "$cmd" "$SINGLEMDS"
11770 cmd="touch $DIR/$tfile"
11771 verify_jobstats "$cmd" "$SINGLEMDS ost1"
11773 cmd="dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 oflag=sync"
11774 verify_jobstats "$cmd" "ost1"
11776 cmd="dd if=$DIR/$tfile of=/dev/null bs=1M count=1 iflag=direct"
11777 verify_jobstats "$cmd" "ost1"
11779 cmd="$TRUNCATE $DIR/$tfile 0"
11780 verify_jobstats "$cmd" "$SINGLEMDS ost1"
11782 cmd="mv -f $DIR/$tfile $DIR/$tdir.rename"
11783 verify_jobstats "$cmd" "$SINGLEMDS"
11784 # jobstats expiry - sleep until old stats should be expired
11785 local left=$((interval_new + 2 - (SECONDS - start)))
11786 [ $left -ge 0 ] && echo "sleep $left for expiry" && sleep $((left + 1))
11787 cmd="mkdir $DIR/$tdir.expire"
11788 verify_jobstats "$cmd" "$SINGLEMDS"
11789 [ $(do_facet $SINGLEMDS lctl get_param *.*.job_stats |
11790 grep -c "job_id.*mkdir") -gt 1 ] && error "old jobstats not expired"
11792 # Ensure that jobid are present in changelog (if supported by MDS)
11793 if [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.6.52) ]
11795 $LFS changelog $MDT0 | tail -9
11796 jobids=$($LFS changelog $MDT0 | tail -9 | grep -c "j=")
11797 [ $jobids -eq 9 ] ||
11798 error "Wrong changelog jobid count $jobids != 9"
11802 jobstats_set $JOBENV
11804 $LFS changelog $MDT0 | tail -1
11805 jobids=$($LFS changelog $MDT0 | tail -1 | grep -c "j=")
11806 [ $jobids -eq 0 ] ||
11807 error "Unexpected jobids when jobid_var=$JOBENV"
11812 run_test 205 "Verify job stats"
11814 # LU-1480, LU-1773 and LU-1657
11816 mkdir -p $DIR/$tdir
11817 $SETSTRIPE -c -1 $DIR/$tdir
11818 #define OBD_FAIL_LOV_INIT 0x1403
11819 $LCTL set_param fail_loc=0xa0001403
11820 $LCTL set_param fail_val=1
11821 touch $DIR/$tdir/$tfile || true
11823 run_test 206 "fail lov_init_raid0() doesn't lbug"
11826 dd if=/dev/zero of=$DIR/$tfile bs=4k count=$((RANDOM%10+1))
11827 local fsz=`stat -c %s $DIR/$tfile`
11828 cancel_lru_locks mdc
11830 # do not return layout in getattr intent
11831 #define OBD_FAIL_MDS_NO_LL_GETATTR 0x170
11832 $LCTL set_param fail_loc=0x170
11833 local sz=`stat -c %s $DIR/$tfile`
11835 [ $fsz -eq $sz ] || error "file size expected $fsz, actual $sz"
11839 run_test 207a "can refresh layout at glimpse"
11842 dd if=/dev/zero of=$DIR/$tfile bs=4k count=$((RANDOM%10+1))
11843 local cksum=`md5sum $DIR/$tfile`
11844 local fsz=`stat -c %s $DIR/$tfile`
11845 cancel_lru_locks mdc
11846 cancel_lru_locks osc
11848 # do not return layout in getattr intent
11849 #define OBD_FAIL_MDS_NO_LL_OPEN 0x171
11850 $LCTL set_param fail_loc=0x171
11852 # it will refresh layout after the file is opened but before read issues
11853 echo checksum is "$cksum"
11854 echo "$cksum" |md5sum -c --quiet || error "file differs"
11858 run_test 207b "can refresh layout at open"
11861 # FIXME: in this test suite, only RD lease is used. This is okay
11862 # for now as only exclusive open is supported. After generic lease
11863 # is done, this test suite should be revised. - Jinshan
11865 remote_mds_nodsh && skip "remote MDS with nodsh" && return
11866 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.4.52) ]] ||
11867 { skip "Need MDS version at least 2.4.52"; return 0; }
11869 echo "==== test 1: verify get lease work"
11870 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:eRE+eU || error "get lease error"
11872 echo "==== test 2: verify lease can be broken by upcoming open"
11873 $MULTIOP $DIR/$tfile oO_RDONLY:eR_E-eUc &
11877 $MULTIOP $DIR/$tfile oO_RDONLY:c
11878 kill -USR1 $PID && wait $PID || error "break lease error"
11880 echo "==== test 3: verify lease can't be granted if an open already exists"
11881 $MULTIOP $DIR/$tfile oO_RDONLY:_c &
11885 $MULTIOP $DIR/$tfile oO_RDONLY:eReUc && error "apply lease should fail"
11886 kill -USR1 $PID && wait $PID || error "open file error"
11888 echo "==== test 4: lease can sustain over recovery"
11889 $MULTIOP $DIR/$tfile oO_RDONLY:eR_E+eUc &
11895 kill -USR1 $PID && wait $PID || error "lease broken over recovery"
11897 echo "==== test 5: lease broken can't be regained by replay"
11898 $MULTIOP $DIR/$tfile oO_RDONLY:eR_E-eUc &
11902 # open file to break lease and then recovery
11903 $MULTIOP $DIR/$tfile oO_RDWR:c || error "open file error"
11906 kill -USR1 $PID && wait $PID || error "lease not broken over recovery"
11910 run_test 208 "Exclusive open"
11913 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep disp_stripe)" ] &&
11914 skip_env "must have disp_stripe" && return
11917 sync; sleep 5; sync;
11919 echo 3 > /proc/sys/vm/drop_caches
11920 req_before=$(awk '/ptlrpc_cache / { print $2 }' /proc/slabinfo)
11922 # open/close 500 times
11923 for i in $(seq 500); do
11927 echo 3 > /proc/sys/vm/drop_caches
11928 req_after=$(awk '/ptlrpc_cache / { print $2 }' /proc/slabinfo)
11930 echo "before: $req_before, after: $req_after"
11931 [ $((req_after - req_before)) -ge 300 ] &&
11932 error "open/close requests are not freed"
11935 run_test 209 "read-only open/close requests should be freed promptly"
11939 size=$((size % 8192 + 1))
11940 dd if=/dev/urandom of=$DIR/f212 bs=1k count=$size
11941 sendfile $DIR/f212 $DIR/f212.xyz || error "sendfile wrong"
11942 rm -f $DIR/f212 $DIR/f212.xyz
11944 run_test 212 "Sendfile test ============================================"
11947 dd if=/dev/zero of=$DIR/$tfile bs=4k count=4
11948 cancel_lru_locks osc
11949 lctl set_param fail_loc=0x8000040f
11950 # generate a read lock
11951 cat $DIR/$tfile > /dev/null
11952 # write to the file, it will try to cancel the above read lock.
11953 cat /etc/hosts >> $DIR/$tfile
11955 run_test 213 "OSC lock completion and cancel race don't crash - bug 18829"
11957 test_214() { # for bug 20133
11958 mkdir -p $DIR/$tdir/d214c || error "mkdir $DIR/$tdir/d214c failed"
11959 for (( i=0; i < 340; i++ )) ; do
11960 touch $DIR/$tdir/d214c/a$i
11963 ls -l $DIR/$tdir || error "ls -l $DIR/d214p failed"
11964 mv $DIR/$tdir/d214c $DIR/ || error "mv $DIR/d214p/d214c $DIR/ failed"
11965 ls $DIR/d214c || error "ls $DIR/d214c failed"
11966 rm -rf $DIR/$tdir || error "rm -rf $DIR/d214* failed"
11967 rm -rf $DIR/d214* || error "rm -rf $DIR/d214* failed"
11969 run_test 214 "hash-indexed directory test - bug 20133"
11971 # having "abc" as 1st arg, creates $TMP/lnet_abc.out and $TMP/lnet_abc.sys
11972 create_lnet_proc_files() {
11973 lctl get_param -n $1 >$TMP/lnet_$1.out || error "cannot read lnet.$1"
11974 sysctl lnet.$1 >$TMP/lnet_$1.sys_tmp || error "cannot read lnet.$1"
11976 sed "s/^lnet.$1\ =\ //g" "$TMP/lnet_$1.sys_tmp" >$TMP/lnet_$1.sys
11977 rm -f "$TMP/lnet_$1.sys_tmp"
11980 # counterpart of create_lnet_proc_files
11981 remove_lnet_proc_files() {
11982 rm -f $TMP/lnet_$1.out $TMP/lnet_$1.sys
11985 # uses 1st arg as trailing part of filename, 2nd arg as description for reports,
11986 # 3rd arg as regexp for body
11987 check_lnet_proc_stats() {
11988 local l=$(cat "$TMP/lnet_$1" |wc -l)
11989 [ $l = 1 ] || (cat "$TMP/lnet_$1" && error "$2 is not of 1 line: $l")
11991 grep -E "$3" "$TMP/lnet_$1" || (cat "$TMP/lnet_$1" && error "$2 misformatted")
11994 # uses 1st arg as trailing part of filename, 2nd arg as description for reports,
11995 # 3rd arg as regexp for body, 4th arg as regexp for 1st line, 5th arg is
11996 # optional and can be regexp for 2nd line (lnet.routes case)
11997 check_lnet_proc_entry() {
11998 local blp=2 # blp stands for 'position of 1st line of body'
11999 [ -z "$5" ] || blp=3 # lnet.routes case
12001 local l=$(cat "$TMP/lnet_$1" |wc -l)
12002 # subtracting one from $blp because the body can be empty
12003 [ "$l" -ge "$(($blp - 1))" ] || (cat "$TMP/lnet_$1" && error "$2 is too short: $l")
12005 sed -n '1 p' "$TMP/lnet_$1" |grep -E "$4" >/dev/null ||
12006 (cat "$TMP/lnet_$1" && error "1st line of $2 misformatted")
12008 [ "$5" = "" ] || sed -n '2 p' "$TMP/lnet_$1" |grep -E "$5" >/dev/null ||
12009 (cat "$TMP/lnet_$1" && error "2nd line of $2 misformatted")
12011 # bail out if any unexpected line happened
12012 sed -n "$blp p" "$TMP/lnet_$1" | grep -Ev "$3"
12013 [ "$?" != 0 ] || error "$2 misformatted"
12016 test_215() { # for bugs 18102, 21079, 21517
12017 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12018 local N='(0|[1-9][0-9]*)' # non-negative numeric
12019 local P='[1-9][0-9]*' # positive numeric
12020 local I='(0|-?[1-9][0-9]*|NA)' # any numeric (0 | >0 | <0) or NA if no value
12021 local NET='[a-z][a-z0-9]*' # LNET net like o2ib2
12022 local ADDR='[0-9.]+' # LNET addr like 10.0.0.1
12023 local NID="$ADDR@$NET" # LNET nid like 10.0.0.1@o2ib2
12025 local L1 # regexp for 1st line
12026 local L2 # regexp for 2nd line (optional)
12027 local BR # regexp for the rest (body)
12029 # lnet.stats should look as 11 space-separated non-negative numerics
12030 BR="^$N $N $N $N $N $N $N $N $N $N $N$"
12031 create_lnet_proc_files "stats"
12032 check_lnet_proc_stats "stats.sys" "lnet.stats" "$BR"
12033 remove_lnet_proc_files "stats"
12035 # lnet.routes should look like this:
12036 # Routing disabled/enabled
12037 # net hops priority state router
12038 # where net is a string like tcp0, hops > 0, priority >= 0,
12039 # state is up/down,
12040 # router is a string like 192.168.1.1@tcp2
12041 L1="^Routing (disabled|enabled)$"
12042 L2="^net +hops +priority +state +router$"
12043 BR="^$NET +$N +(0|1) +(up|down) +$NID$"
12044 create_lnet_proc_files "routes"
12045 check_lnet_proc_entry "routes.sys" "lnet.routes" "$BR" "$L1" "$L2"
12046 remove_lnet_proc_files "routes"
12048 # lnet.routers should look like this:
12049 # ref rtr_ref alive_cnt state last_ping ping_sent deadline down_ni router
12050 # where ref > 0, rtr_ref > 0, alive_cnt >= 0, state is up/down,
12051 # last_ping >= 0, ping_sent is boolean (0/1), deadline and down_ni are
12052 # numeric (0 or >0 or <0), router is a string like 192.168.1.1@tcp2
12053 L1="^ref +rtr_ref +alive_cnt +state +last_ping +ping_sent +deadline +down_ni +router$"
12054 BR="^$P +$P +$N +(up|down) +$N +(0|1) +$I +$I +$NID$"
12055 create_lnet_proc_files "routers"
12056 check_lnet_proc_entry "routers.sys" "lnet.routers" "$BR" "$L1"
12057 remove_lnet_proc_files "routers"
12059 # lnet.peers should look like this:
12060 # nid refs state last max rtr min tx min queue
12061 # where nid is a string like 192.168.1.1@tcp2, refs > 0,
12062 # state is up/down/NA, max >= 0. last, rtr, min, tx, min are
12063 # numeric (0 or >0 or <0), queue >= 0.
12064 L1="^nid +refs +state +last +max +rtr +min +tx +min +queue$"
12065 BR="^$NID +$P +(up|down|NA) +$I +$N +$I +$I +$I +$I +$N$"
12066 create_lnet_proc_files "peers"
12067 check_lnet_proc_entry "peers.sys" "lnet.peers" "$BR" "$L1"
12068 remove_lnet_proc_files "peers"
12070 # lnet.buffers should look like this:
12071 # pages count credits min
12072 # where pages >=0, count >=0, credits and min are numeric (0 or >0 or <0)
12073 L1="^pages +count +credits +min$"
12074 BR="^ +$N +$N +$I +$I$"
12075 create_lnet_proc_files "buffers"
12076 check_lnet_proc_entry "buffers.sys" "lnet.buffers" "$BR" "$L1"
12077 remove_lnet_proc_files "buffers"
12079 # lnet.nis should look like this:
12080 # nid status alive refs peer rtr max tx min
12081 # where nid is a string like 192.168.1.1@tcp2, status is up/down,
12082 # alive is numeric (0 or >0 or <0), refs >= 0, peer >= 0,
12083 # rtr >= 0, max >=0, tx and min are numeric (0 or >0 or <0).
12084 L1="^nid +status +alive +refs +peer +rtr +max +tx +min$"
12085 BR="^$NID +(up|down) +$I +$N +$N +$N +$N +$I +$I$"
12086 create_lnet_proc_files "nis"
12087 check_lnet_proc_entry "nis.sys" "lnet.nis" "$BR" "$L1"
12088 remove_lnet_proc_files "nis"
12090 # can we successfully write to lnet.stats?
12091 lctl set_param -n stats=0 || error "cannot write to lnet.stats"
12092 sysctl -w lnet.stats=0 || error "cannot write to lnet.stats"
12094 run_test 215 "lnet exists and has proper content - bugs 18102, 21079, 21517"
12096 test_216() { # bug 20317
12097 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12098 remote_ost_nodsh && skip "remote OST with nodsh" && return
12101 local facets=$(get_facets OST)
12102 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
12104 save_lustre_params client "osc.*.contention_seconds" > $p
12105 save_lustre_params $facets \
12106 "ldlm.namespaces.filter-*.max_nolock_bytes" >> $p
12107 save_lustre_params $facets \
12108 "ldlm.namespaces.filter-*.contended_locks" >> $p
12109 save_lustre_params $facets \
12110 "ldlm.namespaces.filter-*.contention_seconds" >> $p
12113 # agressive lockless i/o settings
12114 for node in $(osts_nodes); do
12115 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'
12117 lctl set_param -n osc.*.contention_seconds 60
12119 $DIRECTIO write $DIR/$tfile 0 10 4096
12120 $CHECKSTAT -s 40960 $DIR/$tfile
12122 # disable lockless i/o
12123 for node in $(osts_nodes); do
12124 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'
12126 lctl set_param -n osc.*.contention_seconds 0
12129 dd if=/dev/zero of=$DIR/$tfile count=0
12130 $CHECKSTAT -s 0 $DIR/$tfile
12132 restore_lustre_params <$p
12136 run_test 216 "check lockless direct write works and updates file size and kms correctly"
12138 test_217() { # bug 22430
12139 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12143 for node in $(nodes_list); do
12144 nid=$(host_nids_address $node $NETTYPE)
12145 if [[ $nid = *-* ]] ; then
12146 echo "lctl ping $nid@$NETTYPE"
12147 lctl ping $nid@$NETTYPE
12149 echo "skipping $node (no hyphen detected)"
12153 run_test 217 "check lctl ping for hostnames with hiphen ('-')"
12156 # do directio so as not to populate the page cache
12157 log "creating a 10 Mb file"
12158 $MULTIOP $DIR/$tfile oO_CREAT:O_DIRECT:O_RDWR:w$((10*1048576))c || error "multiop failed while creating a file"
12159 log "starting reads"
12160 dd if=$DIR/$tfile of=/dev/null bs=4096 &
12161 log "truncating the file"
12162 $MULTIOP $DIR/$tfile oO_TRUNC:c || error "multiop failed while truncating the file"
12164 kill %+ || true # reads might have finished
12165 echo "wait until dd is finished"
12167 log "removing the temporary file"
12168 rm -rf $DIR/$tfile || error "tmp file removal failed"
12170 run_test 218 "parallel read and truncate should not deadlock ======================="
12173 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12174 # write one partial page
12175 dd if=/dev/zero of=$DIR/$tfile bs=1024 count=1
12176 # set no grant so vvp_io_commit_write will do sync write
12177 $LCTL set_param fail_loc=0x411
12178 # write a full page at the end of file
12179 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 seek=1 conv=notrunc
12181 $LCTL set_param fail_loc=0
12182 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 seek=3
12183 $LCTL set_param fail_loc=0x411
12184 dd if=/dev/zero of=$DIR/$tfile bs=1024 count=1 seek=2 conv=notrunc
12187 dd if=/dev/zero of=$DIR/$tfile-2 bs=1024 count=1
12188 $CHECKSTAT -s 1024 $DIR/$tfile-2 || error "checkstat wrong size"
12190 run_test 219 "LU-394: Write partial won't cause uncontiguous pages vec at LND"
12192 test_220() { #LU-325
12193 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12194 remote_ost_nodsh && skip "remote OST with nodsh" && return
12195 remote_mds_nodsh && skip "remote MDS with nodsh" && return
12196 remote_mgs_nodsh && skip "remote MGS with nodsh" && return
12199 # create on MDT0000 so the last_id and next_id are correct
12201 local OST=$($LFS df $DIR | awk '/OST:'$OSTIDX'/ { print $1 }')
12205 local mdtosc_proc1=$(get_mdtosc_proc_path $SINGLEMDS $OST)
12206 local last_id=$(do_facet $SINGLEMDS lctl get_param -n \
12207 osc.$mdtosc_proc1.prealloc_last_id)
12208 local next_id=$(do_facet $SINGLEMDS lctl get_param -n \
12209 osc.$mdtosc_proc1.prealloc_next_id)
12213 do_facet ost$((OSTIDX + 1)) lctl set_param fail_val=-1
12214 #define OBD_FAIL_OST_ENOINO 0x229
12215 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=0x229
12216 do_facet mgs $LCTL pool_new $FSNAME.$TESTNAME || return 1
12217 do_facet mgs $LCTL pool_add $FSNAME.$TESTNAME $OST || return 2
12219 $SETSTRIPE $DIR/$tdir -i $OSTIDX -c 1 -p $FSNAME.$TESTNAME
12221 MDSOBJS=$((last_id - next_id))
12222 echo "preallocated objects on MDS is $MDSOBJS" "($last_id - $next_id)"
12224 blocks=$($LFS df $MOUNT | awk '($1 == '$OSTIDX') { print $4 }')
12225 echo "OST still has $count kbytes free"
12227 echo "create $MDSOBJS files @next_id..."
12228 createmany -o $DIR/$tdir/f $MDSOBJS || return 3
12230 local last_id2=$(do_facet mds${MDSIDX} lctl get_param -n \
12231 osc.$mdtosc_proc1.prealloc_last_id)
12232 local next_id2=$(do_facet mds${MDSIDX} lctl get_param -n \
12233 osc.$mdtosc_proc1.prealloc_next_id)
12235 echo "after creation, last_id=$last_id2, next_id=$next_id2"
12240 do_facet ost$((OSTIDX + 1)) lctl set_param fail_val=0
12241 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=0
12243 do_facet mgs $LCTL pool_remove $FSNAME.$TESTNAME $OST || return 4
12244 do_facet mgs $LCTL pool_destroy $FSNAME.$TESTNAME || return 5
12245 echo "unlink $MDSOBJS files @$next_id..."
12246 unlinkmany $DIR/$tdir/f $MDSOBJS || return 6
12248 run_test 220 "preallocated MDS objects still used if ENOSPC from OST"
12251 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12252 dd if=`which date` of=$MOUNT/date oflag=sync
12253 chmod +x $MOUNT/date
12255 #define OBD_FAIL_LLITE_FAULT_TRUNC_RACE 0x1401
12256 $LCTL set_param fail_loc=0x80001401
12258 $MOUNT/date > /dev/null
12261 run_test 221 "make sure fault and truncate race to not cause OOM"
12264 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12266 test_mkdir -p $DIR/$tdir
12267 $SETSTRIPE -c 1 -i 0 $DIR/$tdir
12268 createmany -o $DIR/$tdir/$tfile 10
12269 cancel_lru_locks mdc
12270 cancel_lru_locks osc
12271 #define OBD_FAIL_LDLM_AGL_DELAY 0x31a
12272 $LCTL set_param fail_loc=0x31a
12273 ls -l $DIR/$tdir > /dev/null || error "AGL for ls failed"
12274 $LCTL set_param fail_loc=0
12277 run_test 222a "AGL for ls should not trigger CLIO lock failure ================"
12280 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12282 test_mkdir -p $DIR/$tdir
12283 $SETSTRIPE -c 1 -i 0 $DIR/$tdir
12284 createmany -o $DIR/$tdir/$tfile 10
12285 cancel_lru_locks mdc
12286 cancel_lru_locks osc
12287 #define OBD_FAIL_LDLM_AGL_DELAY 0x31a
12288 $LCTL set_param fail_loc=0x31a
12289 rm -r $DIR/$tdir || "AGL for rmdir failed"
12290 $LCTL set_param fail_loc=0
12292 run_test 222b "AGL for rmdir should not trigger CLIO lock failure ============="
12295 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12297 test_mkdir -p $DIR/$tdir
12298 $SETSTRIPE -c 1 -i 0 $DIR/$tdir
12299 createmany -o $DIR/$tdir/$tfile 10
12300 cancel_lru_locks mdc
12301 cancel_lru_locks osc
12302 #define OBD_FAIL_LDLM_AGL_NOLOCK 0x31b
12303 $LCTL set_param fail_loc=0x31b
12304 ls -l $DIR/$tdir > /dev/null || error "reenqueue failed"
12305 $LCTL set_param fail_loc=0
12308 run_test 223 "osc reenqueue if without AGL lock granted ======================="
12310 test_224a() { # LU-1039, MRP-303
12311 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12312 #define OBD_FAIL_PTLRPC_CLIENT_BULK_CB 0x508
12313 $LCTL set_param fail_loc=0x508
12314 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 conv=fsync
12315 $LCTL set_param fail_loc=0
12318 run_test 224a "Don't panic on bulk IO failure"
12320 test_224b() { # LU-1039, MRP-303
12321 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12322 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1
12323 cancel_lru_locks osc
12324 #define OBD_FAIL_PTLRPC_CLIENT_BULK_CB2 0x515
12325 $LCTL set_param fail_loc=0x515
12326 dd of=/dev/null if=$DIR/$tfile bs=4096 count=1
12327 $LCTL set_param fail_loc=0
12330 run_test 224b "Don't panic on bulk IO failure"
12332 test_224c() { # LU-6441
12333 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12334 local pages_per_rpc=$($LCTL get_param \
12335 osc.*.max_pages_per_rpc)
12336 local at_max=$($LCTL get_param -n at_max)
12337 local timeout=$($LCTL get_param -n timeout)
12338 local test_at="$LCTL get_param -n at_max"
12339 local param_at="$FSNAME.sys.at_max"
12340 local test_timeout="$LCTL get_param -n timeout"
12341 local param_timeout="$FSNAME.sys.timeout"
12343 $LCTL set_param -n osc.*.max_pages_per_rpc=1024
12345 set_conf_param_and_check client "$test_at" "$param_at" 0 ||
12346 error "conf_param at_max=0 failed"
12347 set_conf_param_and_check client "$test_timeout" "$param_timeout" 5 ||
12348 error "conf_param timeout=5 failed"
12350 #define OBD_FAIL_PTLRPC_CLIENT_BULK_CB3 0x520
12351 $LCTL set_param fail_loc=0x520
12352 dd if=/dev/zero of=$DIR/$tfile bs=8MB count=1
12354 $LCTL set_param fail_loc=0
12356 set_conf_param_and_check client "$test_at" "$param_at" $at_max ||
12357 error "conf_param at_max=$at_max failed"
12358 set_conf_param_and_check client "$test_timeout" "$param_timeout" \
12359 $timeout || error "conf_param timeout=$timeout failed"
12361 $LCTL set_param -n $pages_per_rpc
12363 run_test 224c "Don't hang if one of md lost during large bulk RPC"
12365 MDSSURVEY=${MDSSURVEY:-$(which mds-survey 2>/dev/null || true)}
12367 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12368 remote_mds_nodsh && skip "remote MDS with nodsh" && return
12369 if [ -z ${MDSSURVEY} ]; then
12370 skip_env "mds-survey not found" && return
12373 [ $MDSCOUNT -ge 2 ] &&
12374 skip "skipping now for more than one MDT" && return
12376 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.51) ] ||
12377 { skip "Need MDS version at least 2.2.51"; return; }
12379 local mds=$(facet_host $SINGLEMDS)
12380 local target=$(do_nodes $mds 'lctl dl' | \
12381 awk "{if (\$2 == \"UP\" && \$3 == \"mdt\") {print \$4}}")
12383 local cmd1="file_count=1000 thrhi=4"
12384 local cmd2="dir_count=2 layer=mdd stripe_count=0"
12385 local cmd3="rslt_loc=${TMP} targets=\"$mds:$target\" $MDSSURVEY"
12386 local cmd="$cmd1 $cmd2 $cmd3"
12388 rm -f ${TMP}/mds_survey*
12390 eval $cmd || error "mds-survey with zero-stripe failed"
12391 cat ${TMP}/mds_survey*
12392 rm -f ${TMP}/mds_survey*
12394 run_test 225a "Metadata survey sanity with zero-stripe"
12397 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12398 remote_mds_nodsh && skip "remote MDS with nodsh" && return
12399 if [ -z ${MDSSURVEY} ]; then
12400 skip_env "mds-survey not found" && return
12402 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.51) ] ||
12403 { skip "Need MDS version at least 2.2.51"; return; }
12405 if [ $($LCTL dl | grep -c osc) -eq 0 ]; then
12406 skip_env "Need to mount OST to test" && return
12409 [ $MDSCOUNT -ge 2 ] &&
12410 skip "skipping now for more than one MDT" && return
12411 local mds=$(facet_host $SINGLEMDS)
12412 local target=$(do_nodes $mds 'lctl dl' | \
12413 awk "{if (\$2 == \"UP\" && \$3 == \"mdt\") {print \$4}}")
12415 local cmd1="file_count=1000 thrhi=4"
12416 local cmd2="dir_count=2 layer=mdd stripe_count=1"
12417 local cmd3="rslt_loc=${TMP} targets=\"$mds:$target\" $MDSSURVEY"
12418 local cmd="$cmd1 $cmd2 $cmd3"
12420 rm -f ${TMP}/mds_survey*
12422 eval $cmd || error "mds-survey with stripe_count failed"
12423 cat ${TMP}/mds_survey*
12424 rm -f ${TMP}/mds_survey*
12426 run_test 225b "Metadata survey sanity with stripe_count = 1"
12428 mcreate_path2fid () {
12434 local path=$DIR/$tdir/$name
12439 $MCREATE --mode=$1 --major=$2 --minor=$3 $path ||
12440 error "cannot create $desc"
12442 fid=$($LFS path2fid $path | tr -d '[' | tr -d ']')
12444 [ $rc -ne 0 ] && error "cannot get fid of a $desc"
12446 fid_path=$($LFS fid2path $MOUNT $fid)
12448 [ $rc -ne 0 ] && error "cannot get path of $desc by $DIR $path $fid"
12450 [ "$path" == "$fid_path" ] ||
12451 error "fid2path returned $fid_path, expected $path"
12453 echo "pass with $path and $fid"
12458 mkdir -p $DIR/$tdir
12460 mcreate_path2fid 0010666 0 0 fifo "FIFO"
12461 mcreate_path2fid 0020666 1 3 null "character special file (null)"
12462 mcreate_path2fid 0020666 1 255 none "character special file (no device)"
12463 mcreate_path2fid 0040666 0 0 dir "directory"
12464 mcreate_path2fid 0060666 7 0 loop0 "block special file (loop)"
12465 mcreate_path2fid 0100666 0 0 file "regular file"
12466 mcreate_path2fid 0120666 0 0 link "symbolic link"
12467 mcreate_path2fid 0140666 0 0 sock "socket"
12469 run_test 226a "call path2fid and fid2path on files of all type"
12472 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
12476 mkdir -p $DIR/$tdir
12477 $LFS setdirstripe -i $MDTIDX $DIR/$tdir/remote_dir ||
12478 error "create remote directory failed"
12479 mcreate_path2fid 0010666 0 0 "remote_dir/fifo" "FIFO"
12480 mcreate_path2fid 0020666 1 3 "remote_dir/null" \
12481 "character special file (null)"
12482 mcreate_path2fid 0020666 1 255 "remote_dir/none" \
12483 "character special file (no device)"
12484 mcreate_path2fid 0040666 0 0 "remote_dir/dir" "directory"
12485 mcreate_path2fid 0060666 7 0 "remote_dir/loop0" \
12486 "block special file (loop)"
12487 mcreate_path2fid 0100666 0 0 "remote_dir/file" "regular file"
12488 mcreate_path2fid 0120666 0 0 "remote_dir/link" "symbolic link"
12489 mcreate_path2fid 0140666 0 0 "remote_dir/sock" "socket"
12491 run_test 226b "call path2fid and fid2path on files of all type under remote dir"
12493 # LU-1299 Executing or running ldd on a truncated executable does not
12494 # cause an out-of-memory condition.
12496 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12497 [ -z "$(which ldd)" ] && skip "should have ldd tool" && return
12498 dd if=$(which date) of=$MOUNT/date bs=1k count=1
12499 chmod +x $MOUNT/date
12501 $MOUNT/date > /dev/null
12502 ldd $MOUNT/date > /dev/null
12505 run_test 227 "running truncated executable does not cause OOM"
12507 # LU-1512 try to reuse idle OI blocks
12509 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12510 remote_mds_nodsh && skip "remote MDS with nodsh" && return
12511 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
12512 skip "non-ldiskfs backend" && return
12514 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
12515 local myDIR=$DIR/$tdir
12518 #define OBD_FAIL_SEQ_EXHAUST 0x1002
12519 $LCTL set_param fail_loc=0x80001002
12520 createmany -o $myDIR/t- 10000
12521 $LCTL set_param fail_loc=0
12522 # The guard is current the largest FID holder
12524 local SEQ=$($LFS path2fid $myDIR/guard | awk -F ':' '{print $1}' |
12526 local IDX=$(($SEQ % 64))
12528 do_facet $SINGLEMDS sync
12529 # Make sure journal flushed.
12531 local blk1=$(do_facet $SINGLEMDS \
12532 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
12533 grep Blockcount | awk '{print $4}')
12535 # Remove old files, some OI blocks will become idle.
12536 unlinkmany $myDIR/t- 10000
12537 # Create new files, idle OI blocks should be reused.
12538 createmany -o $myDIR/t- 2000
12539 do_facet $SINGLEMDS sync
12540 # Make sure journal flushed.
12542 local blk2=$(do_facet $SINGLEMDS \
12543 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
12544 grep Blockcount | awk '{print $4}')
12546 [ $blk1 == $blk2 ] || error "old blk1=$blk1, new blk2=$blk2, unmatched!"
12548 run_test 228a "try to reuse idle OI blocks"
12551 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12552 remote_mds_nodsh && skip "remote MDS with nodsh" && return
12553 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
12554 skip "non-ldiskfs backend" && return
12556 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
12557 local myDIR=$DIR/$tdir
12560 #define OBD_FAIL_SEQ_EXHAUST 0x1002
12561 $LCTL set_param fail_loc=0x80001002
12562 createmany -o $myDIR/t- 10000
12563 $LCTL set_param fail_loc=0
12564 # The guard is current the largest FID holder
12566 local SEQ=$($LFS path2fid $myDIR/guard | awk -F ':' '{print $1}' |
12568 local IDX=$(($SEQ % 64))
12570 do_facet $SINGLEMDS sync
12571 # Make sure journal flushed.
12573 local blk1=$(do_facet $SINGLEMDS \
12574 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
12575 grep Blockcount | awk '{print $4}')
12577 # Remove old files, some OI blocks will become idle.
12578 unlinkmany $myDIR/t- 10000
12581 stop $SINGLEMDS || error "Fail to stop MDT."
12583 start $SINGLEMDS $MDT_DEV $MDS_MOUNT_OPTS || error "Fail to start MDT."
12585 df $MOUNT || error "Fail to df."
12586 # Create new files, idle OI blocks should be reused.
12587 createmany -o $myDIR/t- 2000
12588 do_facet $SINGLEMDS sync
12589 # Make sure journal flushed.
12591 local blk2=$(do_facet $SINGLEMDS \
12592 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
12593 grep Blockcount | awk '{print $4}')
12595 [ $blk1 == $blk2 ] || error "old blk1=$blk1, new blk2=$blk2, unmatched!"
12597 run_test 228b "idle OI blocks can be reused after MDT restart"
12601 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12602 remote_mds_nodsh && skip "remote MDS with nodsh" && return
12603 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
12604 skip "non-ldiskfs backend" && return
12606 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
12607 local myDIR=$DIR/$tdir
12610 #define OBD_FAIL_SEQ_EXHAUST 0x1002
12611 $LCTL set_param fail_loc=0x80001002
12612 # 20000 files can guarantee there are index nodes in the OI file
12613 createmany -o $myDIR/t- 20000
12614 $LCTL set_param fail_loc=0
12615 # The guard is current the largest FID holder
12617 local SEQ=$($LFS path2fid $myDIR/guard | awk -F ':' '{print $1}' |
12619 local IDX=$(($SEQ % 64))
12621 do_facet $SINGLEMDS sync
12622 # Make sure journal flushed.
12624 local blk1=$(do_facet $SINGLEMDS \
12625 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
12626 grep Blockcount | awk '{print $4}')
12628 # Remove old files, some OI blocks will become idle.
12629 unlinkmany $myDIR/t- 20000
12631 # The OI file should become empty now
12633 # Create new files, idle OI blocks should be reused.
12634 createmany -o $myDIR/t- 2000
12635 do_facet $SINGLEMDS sync
12636 # Make sure journal flushed.
12638 local blk2=$(do_facet $SINGLEMDS \
12639 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
12640 grep Blockcount | awk '{print $4}')
12642 [ $blk1 == $blk2 ] || error "old blk1=$blk1, new blk2=$blk2, unmatched!"
12644 run_test 228c "NOT shrink the last entry in OI index node to recycle idle leaf"
12646 test_229() { # LU-2482, LU-3448
12647 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.53) ] &&
12648 skip "No HSM $(lustre_build_version $SINGLEMDS) MDS < 2.4.53" &&
12650 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12651 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs" && return
12655 # Create a file with a released layout and stripe count 2.
12656 $MULTIOP $DIR/$tfile H2c ||
12657 error "failed to create file with released layout"
12659 $GETSTRIPE -v $DIR/$tfile
12661 local pattern=$($GETSTRIPE -L $DIR/$tfile)
12662 [ X"$pattern" = X"80000001" ] || error "pattern error ($pattern)"
12664 local stripe_count=$($GETSTRIPE -c $DIR/$tfile) || error "getstripe"
12665 [ $stripe_count -eq 2 ] || error "stripe count not 2 ($stripe_count)"
12666 stat $DIR/$tfile || error "failed to stat released file"
12668 chown $RUNAS_ID $DIR/$tfile ||
12669 error "chown $RUNAS_ID $DIR/$tfile failed"
12671 chgrp $RUNAS_ID $DIR/$tfile ||
12672 error "chgrp $RUNAS_ID $DIR/$tfile failed"
12674 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
12675 rm $DIR/$tfile || error "failed to remove released file"
12677 run_test 229 "getstripe/stat/rm/attr changes work on released files"
12680 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12681 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
12684 test_mkdir $DIR/$tdir
12685 test_mkdir -i0 -c1 $DIR/$tdir/test_230_local
12686 local mdt_idx=$($GETSTRIPE -M $DIR/$tdir/test_230_local)
12687 [ $mdt_idx -ne 0 ] &&
12688 error "create local directory on wrong MDT $mdt_idx"
12690 $LFS mkdir -i $MDTIDX $DIR/$tdir/test_230 ||
12691 error "create remote directory failed"
12692 local mdt_idx=$($GETSTRIPE -M $DIR/$tdir/test_230)
12693 [ $mdt_idx -ne $MDTIDX ] &&
12694 error "create remote directory on wrong MDT $mdt_idx"
12696 createmany -o $DIR/$tdir/test_230/t- 10 ||
12697 error "create files on remote directory failed"
12698 mdt_idx=$($GETSTRIPE -M $DIR/$tdir/test_230/t-0)
12699 [ $mdt_idx -ne $MDTIDX ] && error "create files on wrong MDT $mdt_idx"
12700 rm -r $DIR/$tdir || error "unlink remote directory failed"
12702 run_test 230a "Create remote directory and files under the remote directory"
12705 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12706 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
12713 local migrate_dir=$DIR/$tdir/migrate_dir
12714 local other_dir=$DIR/$tdir/other_dir
12716 test_mkdir $DIR/$tdir
12717 test_mkdir -i0 -c1 $migrate_dir
12718 test_mkdir -i0 -c1 $other_dir
12719 for ((i=0; i<10; i++)); do
12720 mkdir -p $migrate_dir/dir_${i}
12721 createmany -o $migrate_dir/dir_${i}/f 10 ||
12722 error "create files under remote dir failed $i"
12725 cp /etc/passwd $migrate_dir/$tfile
12726 cp /etc/passwd $other_dir/$tfile
12727 chattr +SAD $migrate_dir
12728 chattr +SAD $migrate_dir/$tfile
12730 local old_dir_flag=$(lsattr -a $migrate_dir | awk '/\/\.$/ {print $1}')
12731 local old_file_flag=$(lsattr $migrate_dir/$tfile | awk '{print $1}')
12732 local old_dir_mode=$(stat -c%f $migrate_dir)
12733 local old_file_mode=$(stat -c%f $migrate_dir/$tfile)
12735 mkdir -p $migrate_dir/dir_default_stripe2
12736 $SETSTRIPE -c 2 $migrate_dir/dir_default_stripe2
12737 $SETSTRIPE -c 2 $migrate_dir/${tfile}_stripe2
12739 mkdir -p $other_dir
12740 ln $migrate_dir/$tfile $other_dir/luna
12741 ln $migrate_dir/$tfile $migrate_dir/sofia
12742 ln $other_dir/$tfile $migrate_dir/david
12743 ln -s $migrate_dir/$tfile $other_dir/zachary
12744 ln -s $migrate_dir/$tfile $migrate_dir/${tfile}_ln
12745 ln -s $other_dir/$tfile $migrate_dir/${tfile}_ln_other
12747 $LFS migrate -m $MDTIDX $migrate_dir ||
12748 error "fails on migrating remote dir to MDT1"
12750 echo "migratate to MDT1, then checking.."
12751 for ((i = 0; i < 10; i++)); do
12752 for file in $(find $migrate_dir/dir_${i}); do
12753 mdt_index=$($LFS getstripe -M $file)
12754 [ $mdt_index == $MDTIDX ] ||
12755 error "$file is not on MDT${MDTIDX}"
12759 # the multiple link file should still in MDT0
12760 mdt_index=$($LFS getstripe -M $migrate_dir/$tfile)
12761 [ $mdt_index == 0 ] ||
12762 error "$file is not on MDT${MDTIDX}"
12764 local new_dir_flag=$(lsattr -a $migrate_dir | awk '/\/\.$/ {print $1}')
12765 [ "$old_dir_flag" = "$new_dir_flag" ] ||
12766 error " expect $old_dir_flag get $new_dir_flag"
12768 local new_file_flag=$(lsattr $migrate_dir/$tfile | awk '{print $1}')
12769 [ "$old_file_flag" = "$new_file_flag" ] ||
12770 error " expect $old_file_flag get $new_file_flag"
12772 local new_dir_mode=$(stat -c%f $migrate_dir)
12773 [ "$old_dir_mode" = "$new_dir_mode" ] ||
12774 error "expect mode $old_dir_mode get $new_dir_mode"
12776 local new_file_mode=$(stat -c%f $migrate_dir/$tfile)
12777 [ "$old_file_mode" = "$new_file_mode" ] ||
12778 error "expect mode $old_file_mode get $new_file_mode"
12780 diff /etc/passwd $migrate_dir/$tfile ||
12781 error "$tfile different after migration"
12783 diff /etc/passwd $other_dir/luna ||
12784 error "luna different after migration"
12786 diff /etc/passwd $migrate_dir/sofia ||
12787 error "sofia different after migration"
12789 diff /etc/passwd $migrate_dir/david ||
12790 error "david different after migration"
12792 diff /etc/passwd $other_dir/zachary ||
12793 error "zachary different after migration"
12795 diff /etc/passwd $migrate_dir/${tfile}_ln ||
12796 error "${tfile}_ln different after migration"
12798 diff /etc/passwd $migrate_dir/${tfile}_ln_other ||
12799 error "${tfile}_ln_other different after migration"
12801 stripe_count=$($LFS getstripe -c $migrate_dir/dir_default_stripe2)
12802 [ $stripe_count = 2 ] ||
12803 error "dir strpe_count $d != 2 after migration."
12805 stripe_count=$($LFS getstripe -c $migrate_dir/${tfile}_stripe2)
12806 [ $stripe_count = 2 ] ||
12807 error "file strpe_count $d != 2 after migration."
12809 #migrate back to MDT0
12812 $LFS migrate -m $MDTIDX $migrate_dir ||
12813 error "fails on migrating remote dir to MDT0"
12815 echo "migrate back to MDT0, checking.."
12816 for file in $(find $migrate_dir); do
12817 mdt_index=$($LFS getstripe -M $file)
12818 [ $mdt_index == $MDTIDX ] ||
12819 error "$file is not on MDT${MDTIDX}"
12822 local new_dir_flag=$(lsattr -a $migrate_dir | awk '/\/\.$/ {print $1}')
12823 [ "$old_dir_flag" = "$new_dir_flag" ] ||
12824 error " expect $old_dir_flag get $new_dir_flag"
12826 local new_file_flag=$(lsattr $migrate_dir/$tfile | awk '{print $1}')
12827 [ "$old_file_flag" = "$new_file_flag" ] ||
12828 error " expect $old_file_flag get $new_file_flag"
12830 local new_dir_mode=$(stat -c%f $migrate_dir)
12831 [ "$old_dir_mode" = "$new_dir_mode" ] ||
12832 error "expect mode $old_dir_mode get $new_dir_mode"
12834 local new_file_mode=$(stat -c%f $migrate_dir/$tfile)
12835 [ "$old_file_mode" = "$new_file_mode" ] ||
12836 error "expect mode $old_file_mode get $new_file_mode"
12838 diff /etc/passwd ${migrate_dir}/$tfile ||
12839 error "$tfile different after migration"
12841 diff /etc/passwd ${other_dir}/luna ||
12842 error "luna different after migration"
12844 diff /etc/passwd ${migrate_dir}/sofia ||
12845 error "sofia different after migration"
12847 diff /etc/passwd ${other_dir}/zachary ||
12848 error "zachary different after migration"
12850 diff /etc/passwd $migrate_dir/${tfile}_ln ||
12851 error "${tfile}_ln different after migration"
12853 diff /etc/passwd $migrate_dir/${tfile}_ln_other ||
12854 error "${tfile}_ln_other different after migration"
12856 stripe_count=$($LFS getstripe -c ${migrate_dir}/dir_default_stripe2)
12857 [ $stripe_count = 2 ] ||
12858 error "dir strpe_count $d != 2 after migration."
12860 stripe_count=$($LFS getstripe -c ${migrate_dir}/${tfile}_stripe2)
12861 [ $stripe_count = 2 ] ||
12862 error "file strpe_count $d != 2 after migration."
12864 rm -rf $DIR/$tdir || error "rm dir failed after migration"
12866 run_test 230b "migrate directory"
12869 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12870 remote_mds_nodsh && skip "remote MDS with nodsh" && return
12871 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
12875 local migrate_dir=$DIR/$tdir/migrate_dir
12877 #If migrating directory fails in the middle, all entries of
12878 #the directory is still accessiable.
12879 test_mkdir $DIR/$tdir
12880 test_mkdir -i0 -c1 $migrate_dir
12882 createmany -o $migrate_dir/f 10 ||
12883 error "create files under ${migrate_dir} failed"
12885 #failed after migrating 5 entries
12886 #OBD_FAIL_MIGRATE_ENTRIES 0x1801
12887 do_facet mds1 lctl set_param fail_loc=0x20001801
12888 do_facet mds1 lctl set_param fail_val=5
12889 local t=$(ls $migrate_dir | wc -l)
12890 $LFS migrate --mdt-index $MDTIDX $migrate_dir &&
12891 error "migrate should fail after 5 entries"
12893 mkdir $migrate_dir/dir &&
12894 error "mkdir succeeds under migrating directory"
12895 touch $migrate_dir/file &&
12896 error "touch file succeeds under migrating directory"
12898 local u=$(ls $migrate_dir | wc -l)
12899 [ "$u" == "$t" ] || error "$u != $t during migration"
12901 for file in $(find $migrate_dir); do
12902 stat $file || error "stat $file failed"
12905 do_facet mds1 lctl set_param fail_loc=0
12906 do_facet mds1 lctl set_param fail_val=0
12908 $LFS migrate -m $MDTIDX $migrate_dir ||
12909 error "migrate open files should failed with open files"
12911 echo "Finish migration, then checking.."
12912 for file in $(find $migrate_dir); do
12913 mdt_index=$($LFS getstripe -M $file)
12914 [ $mdt_index == $MDTIDX ] ||
12915 error "$file is not on MDT${MDTIDX}"
12918 rm -rf $DIR/$tdir || error "rm dir failed after migration"
12920 run_test 230c "check directory accessiblity if migration is failed"
12923 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12924 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
12927 local migrate_dir=$DIR/$tdir/migrate_dir
12931 test_mkdir $DIR/$tdir
12932 test_mkdir -i0 -c1 $migrate_dir
12934 for ((i=0; i<100; i++)); do
12935 test_mkdir -i0 -c1 $migrate_dir/dir_${i}
12936 createmany -o $migrate_dir/dir_${i}/f 100 ||
12937 error "create files under remote dir failed $i"
12940 $LFS migrate -m $MDTIDX $migrate_dir ||
12941 error "migrate remote dir error"
12943 echo "Finish migration, then checking.."
12944 for file in $(find $migrate_dir); do
12945 mdt_index=$($LFS getstripe -M $file)
12946 [ $mdt_index == $MDTIDX ] ||
12947 error "$file is not on MDT${MDTIDX}"
12950 rm -rf $DIR/$tdir || error "rm dir failed after migration"
12952 run_test 230d "check migrate big directory"
12955 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12956 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
12962 mkdir -p $DIR/$tdir
12963 mkdir $DIR/$tdir/migrate_dir
12964 mkdir $DIR/$tdir/other_dir
12965 touch $DIR/$tdir/migrate_dir/a
12966 ln $DIR/$tdir/migrate_dir/a $DIR/$tdir/other_dir/b
12967 ls $DIR/$tdir/other_dir
12969 $LFS migrate -m 1 $DIR/$tdir/migrate_dir ||
12970 error "migrate dir fails"
12972 mdt_index=$($LFS getstripe -M $DIR/$tdir/migrate_dir)
12973 [ $mdt_index == 1 ] || error "migrate_dir is not on MDT1"
12975 mdt_index=$($LFS getstripe -M $DIR/$tdir/migrate_dir/a)
12976 [ $mdt_index == 0 ] || error "a is not on MDT0"
12978 $LFS migrate -m 1 $DIR/$tdir/other_dir ||
12979 error "migrate dir fails"
12981 mdt_index=$($LFS getstripe -M $DIR/$tdir/other_dir)
12982 [ $mdt_index == 1 ] || error "other_dir is not on MDT1"
12984 mdt_index=$($LFS getstripe -M $DIR/$tdir/migrate_dir/a)
12985 [ $mdt_index == 1 ] || error "a is not on MDT1"
12987 mdt_index=$($LFS getstripe -M $DIR/$tdir/other_dir/b)
12988 [ $mdt_index == 1 ] || error "b is not on MDT1"
12990 a_fid=$($LFS path2fid $DIR/$tdir/migrate_dir/a)
12991 b_fid=$($LFS path2fid $DIR/$tdir/other_dir/b)
12993 [ "$a_fid" = "$b_fid" ] || error "different fid after migration"
12995 rm -rf $DIR/$tdir || error "rm dir failed after migration"
12997 run_test 230e "migrate mulitple local link files"
13000 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13001 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
13005 mkdir -p $DIR/$tdir
13006 mkdir $DIR/$tdir/migrate_dir
13007 $LFS mkdir -i1 $DIR/$tdir/other_dir
13008 touch $DIR/$tdir/migrate_dir/a
13009 ln $DIR/$tdir/migrate_dir/a $DIR/$tdir/other_dir/ln1
13010 ln $DIR/$tdir/migrate_dir/a $DIR/$tdir/other_dir/ln2
13011 ls $DIR/$tdir/other_dir
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"
13048 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13049 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
13051 mkdir -p $DIR/$tdir/migrate_dir
13053 $LFS migrate -m 1000 $DIR/$tdir/migrate_dir &&
13054 error "migrating dir to non-exist MDT succeeds"
13057 run_test 230g "migrate dir to non-exist MDT"
13061 # For simplicity this test assumes that max_pages_per_rpc
13062 # is the same across all OSCs
13063 local max_pages=$($LCTL get_param -n osc.*.max_pages_per_rpc | head -n1)
13064 local bulk_size=$((max_pages * 4096))
13066 mkdir -p $DIR/$tdir
13068 # clear the OSC stats
13069 $LCTL set_param osc.*.stats=0 &>/dev/null
13071 # Client writes $bulk_size - there must be 1 rpc for $max_pages.
13072 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=$bulk_size count=1 \
13073 oflag=direct &>/dev/null || error "dd failed"
13075 local nrpcs=$($LCTL get_param osc.*.stats |awk '/ost_write/ {print $2}')
13076 if [ x$nrpcs != "x1" ]; then
13077 error "found $nrpc ost_write RPCs, not 1 as expected"
13080 # Drop the OSC cache, otherwise we will read from it
13081 cancel_lru_locks osc
13083 # clear the OSC stats
13084 $LCTL set_param osc.*.stats=0 &>/dev/null
13086 # Client reads $bulk_size.
13087 dd if=$DIR/$tdir/$tfile of=/dev/null bs=$bulk_size count=1 \
13088 iflag=direct &>/dev/null || error "dd failed"
13090 nrpcs=$($LCTL get_param osc.*.stats | awk '/ost_read/ { print $2 }')
13091 if [ x$nrpcs != "x1" ]; then
13092 error "found $nrpc ost_read RPCs, not 1 as expected"
13095 run_test 231a "checking that reading/writing of BRW RPC size results in one RPC"
13098 mkdir -p $DIR/$tdir
13100 for i in {0..1023}; do
13101 dd if=/dev/zero of=$DIR/$tdir/$tfile conv=notrunc \
13102 seek=$((2 * i)) bs=4096 count=1 &>/dev/null ||
13103 error "dd of=$DIR/$tdir/$tfile seek=$((2 * i)) failed"
13107 run_test 231b "must not assert on fully utilized OST request buffer"
13110 mkdir -p $DIR/$tdir
13111 #define OBD_FAIL_LDLM_OST_LVB 0x31c
13112 $LCTL set_param fail_loc=0x31c
13114 # ignore dd failure
13115 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=1 || true
13117 $LCTL set_param fail_loc=0
13118 umount_client $MOUNT || error "umount failed"
13119 mount_client $MOUNT || error "mount failed"
13121 run_test 232 "failed lock should not block umount"
13124 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.3.64) ] ||
13125 { skip "Need MDS version at least 2.3.64"; return; }
13127 local fid=$($LFS path2fid $MOUNT)
13128 stat $MOUNT/.lustre/fid/$fid > /dev/null ||
13129 error "cannot access $MOUNT using its FID '$fid'"
13131 run_test 233a "checking that OBF of the FS root succeeds"
13134 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.5.90) ] ||
13135 { skip "Need MDS version at least 2.5.90"; return; }
13137 local fid=$($LFS path2fid $MOUNT/.lustre)
13138 stat $MOUNT/.lustre/fid/$fid > /dev/null ||
13139 error "cannot access $MOUNT/.lustre using its FID '$fid'"
13141 fid=$($LFS path2fid $MOUNT/.lustre/fid)
13142 stat $MOUNT/.lustre/fid/$fid > /dev/null ||
13143 error "cannot access $MOUNT/.lustre/fid using its FID '$fid'"
13145 run_test 233b "checking that OBF of the FS .lustre succeeds"
13148 local p="$TMP/sanityN-$TESTNAME.parameters"
13149 save_lustre_params client "llite.*.xattr_cache" > $p
13150 lctl set_param llite.*.xattr_cache 1 ||
13151 { skip "xattr cache is not supported"; return 0; }
13153 mkdir -p $DIR/$tdir || error "mkdir failed"
13154 touch $DIR/$tdir/$tfile || error "touch failed"
13155 # OBD_FAIL_LLITE_XATTR_ENOMEM
13156 $LCTL set_param fail_loc=0x1405
13157 # output of the form: attr 2 4 44 3 fc13 x86_64
13158 V=($(IFS=".-" rpm -q attr))
13159 if [[ ${V[1]} > 2 || ${V[2]} > 4 || ${V[3]} > 44 ||
13160 ${V[1]} = 2 && ${V[2]} = 4 && ${V[3]} = 44 && ${V[4]} > 6 ]]; then
13161 # attr pre-2.4.44-7 had a bug with rc
13162 # LU-3703 - SLES 11 and FC13 clients have older attr
13163 getfattr -n user.attr $DIR/$tdir/$tfile &&
13164 error "getfattr should have failed with ENOMEM"
13166 skip "LU-3703: attr version $(getfattr --version) too old"
13168 $LCTL set_param fail_loc=0x0
13171 restore_lustre_params < $p
13174 run_test 234 "xattr cache should not crash on ENOMEM"
13177 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.52) ] &&
13178 skip "Need MDS version at least 2.4.52" && return
13179 flock_deadlock $DIR/$tfile
13184 124) error "process hangs on a deadlock"
13186 *) error "error executing flock_deadlock $DIR/$tfile"
13190 run_test 235 "LU-1715: flock deadlock detection does not work properly"
13194 check_swap_layouts_support && return 0
13195 test_mkdir -p -c1 $DIR/$tdir || error "mkdir $tdir failed"
13197 local ref1=/etc/passwd
13198 local ref2=/etc/group
13199 local file1=$DIR/$tdir/f1
13200 local file2=$DIR/$tdir/f2
13202 $SETSTRIPE -c 1 $file1 || error "cannot setstripe on '$file1': rc = $?"
13203 cp $ref1 $file1 || error "cp $ref1 $file1 failed: rc = $?"
13204 $SETSTRIPE -c 2 $file2 || error "cannot setstripe on '$file2': rc = $?"
13205 cp $ref2 $file2 || error "cp $ref2 $file2 failed: rc = $?"
13206 local fd=$(free_fd)
13207 local cmd="exec $fd<>$file2"
13210 $LFS swap_layouts $file1 /proc/self/fd/${fd} ||
13211 error "cannot swap layouts of '$file1' and /proc/self/fd/${fd}"
13214 cmp $ref2 $file1 || error "content compare failed ($ref2 != $file1)"
13219 run_test 236 "Layout swap on open unlinked file"
13221 # test to verify file handle related system calls
13222 # (name_to_handle_at/open_by_handle_at)
13223 # The new system calls are supported in glibc >= 2.14.
13226 echo "Test file_handle syscalls" > $DIR/$tfile ||
13227 error "write failed"
13228 check_fhandle_syscalls $DIR/$tfile ||
13229 error "check_fhandle_syscalls failed"
13231 run_test 237 "Verify name_to_handle_at/open_by_handle_at syscalls"
13233 # LU-4659 linkea consistency
13235 local server_version=$(lustre_version_code $SINGLEMDS)
13237 [[ $server_version -gt $(version_code 2.5.57) ]] ||
13238 [[ $server_version -gt $(version_code 2.5.1) &&
13239 $server_version -lt $(version_code 2.5.50) ]] ||
13240 { skip "Need MDS version at least 2.5.58 or 2.5.2+"; return; }
13243 ln $DIR/$tfile $DIR/$tfile.lnk
13244 touch $DIR/$tfile.new
13245 mv $DIR/$tfile.new $DIR/$tfile
13246 local fid1=$($LFS path2fid $DIR/$tfile)
13247 local fid2=$($LFS path2fid $DIR/$tfile.lnk)
13248 local path1=$($LFS fid2path $FSNAME "$fid1")
13249 [ $tfile == $path1 ] || error "linkea inconsistent: $tfile $fid1 $path1"
13250 local path2=$($LFS fid2path $FSNAME "$fid2")
13251 [ $tfile.lnk == $path2 ] ||
13252 error "linkea inconsistent: $tfile.lnk $fid2 $path2!"
13255 run_test 238 "Verify linkea consistency"
13258 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.5.60) ] &&
13259 skip "Need MDS version at least 2.5.60" && return
13260 local list=$(comma_list $(mdts_nodes))
13262 mkdir -p $DIR/$tdir
13263 createmany -o $DIR/$tdir/f- 5000
13264 unlinkmany $DIR/$tdir/f- 5000
13265 do_nodes $list "lctl set_param -n osp*.*.sync_changes 1"
13266 changes=$(do_nodes $list "lctl get_param -n osc.*MDT*.sync_changes \
13267 osc.*MDT*.sync_in_flight" | calc_sum)
13268 [ "$changes" -eq 0 ] || error "$changes not synced"
13270 run_test 239 "osp_sync test"
13272 test_239a() { #LU-5297
13274 #define OBD_FAIL_OSP_CHECK_INVALID_REC 0x2100
13275 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x2100
13276 chgrp $RUNAS_GID $DIR/$tfile
13277 wait_delete_completed
13279 run_test 239a "process invalid osp sync record correctly"
13281 test_239b() { #LU-5297
13283 #define OBD_FAIL_OSP_CHECK_ENOMEM 0x2101
13284 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x2101
13285 chgrp $RUNAS_GID $DIR/$tfile1
13286 wait_delete_completed
13287 do_facet $SINGLEMDS $LCTL set_param fail_loc=0
13289 chgrp $RUNAS_GID $DIR/$tfile2
13290 wait_delete_completed
13292 run_test 239b "process osp sync record with ENOMEM error correctly"
13295 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
13297 mkdir -p $DIR/$tdir
13299 $LFS mkdir -i 0 $DIR/$tdir/d0 ||
13300 error "failed to mkdir $DIR/$tdir/d0 on MDT0"
13301 $LFS mkdir -i 1 $DIR/$tdir/d0/d1 ||
13302 error "failed to mkdir $DIR/$tdir/d0/d1 on MDT1"
13304 umount_client $MOUNT || error "umount failed"
13305 #define OBD_FAIL_TGT_DELAY_CONDITIONAL 0x713
13306 do_facet mds2 lctl set_param fail_loc=0x713 fail_val=1
13307 mount_client $MOUNT || error "failed to mount client"
13309 echo "stat $DIR/$tdir/d0/d1, should not fail/ASSERT"
13310 stat $DIR/$tdir/d0/d1 || error "fail to stat $DIR/$tdir/d0/d1"
13312 run_test 240 "race between ldlm enqueue and the connection RPC (no ASSERT)"
13315 for LOOP in $(seq $1); do
13316 dd if=$DIR/$tfile of=/dev/null bs=40960 count=1 2>/dev/null
13317 cancel_lru_locks osc
13322 for LOOP in $(seq $1); do
13323 dd if=$DIR/$tfile of=/dev/null bs=40960 count=1 \
13324 iflag=direct 2>/dev/null
13329 dd if=/dev/zero of=$DIR/$tfile count=1 bs=40960
13331 cancel_lru_locks osc
13332 test_241_bio 1000 &
13337 run_test 241 "bio vs dio"
13340 dd if=/dev/zero of=$DIR/$tfile count=1 bs=40960
13342 test_241_dio 1000 &
13347 run_test 241b "dio vs dio"
13350 mkdir -p $DIR/$tdir
13351 touch $DIR/$tdir/$tfile
13353 #define OBD_FAIL_MDS_READPAGE_PACK 0x105
13354 do_facet mds1 lctl set_param fail_loc=0x105
13355 /bin/ls $DIR/$tdir && error "ls $DIR/$tdir should fail"
13357 do_facet mds1 lctl set_param fail_loc=0
13358 /bin/ls $DIR/$tdir || error "ls $DIR/$tdir failed"
13360 run_test 242 "mdt_readpage failure should not cause directory unreadable"
13364 test_mkdir -p $DIR/$tdir
13365 group_lock_test -d $DIR/$tdir || error "A group lock test failed"
13367 run_test 243 "various group lock tests"
13371 test_mkdir -p $DIR/$tdir
13372 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=35
13373 sendfile_grouplock $DIR/$tdir/$tfile || \
13374 error "sendfile+grouplock failed"
13377 run_test 244 "sendfile with group lock tests"
13380 local flagname="multi_mod_rpcs"
13381 local connect_data_name="max_mod_rpcs"
13384 # check if multiple modify RPCs flag is set
13385 out=$($LCTL get_param mdc.$FSNAME-MDT0000-*.import |
13386 grep "connect_flags:")
13389 echo "$out" | grep -qw $flagname
13390 if [ $? -ne 0 ]; then
13391 echo "connect flag $flagname is not set"
13395 # check if multiple modify RPCs data is set
13396 out=$($LCTL get_param mdc.$FSNAME-MDT0000-*.import)
13399 echo "$out" | grep -qw $connect_data_name ||
13400 error "import should have connect data $connect_data_name"
13402 run_test 245 "check mdc connection flag/data: multiple modify RPCs"
13404 test_246() { # LU-7371
13405 [ $(lustre_version_code ost1) -lt $(version_code 2.7.62) ] &&
13406 skip "Need OST version >= 2.7.62" && return 0
13407 do_facet ost1 $LCTL set_param fail_val=4095
13408 #define OBD_FAIL_OST_READ_SIZE 0x234
13409 do_facet ost1 $LCTL set_param fail_loc=0x234
13410 $LFS setstripe $DIR/$tfile -i 0 -c 1
13411 dd if=/dev/zero of=$DIR/$tfile bs=4095 count=1 > /dev/null 2>&1
13412 cancel_lru_locks $FSNAME-OST0000
13413 dd if=$DIR/$tfile of=/dev/null bs=1048576 || error "Read failed"
13415 run_test 246 "Read file of size 4095 should return right length"
13418 [ "$(facet_fstype ost$(($($GETSTRIPE -i $DIR/$tfile) + 1)))" = "zfs" ] \
13419 && skip "no 16TB file size limit on ZFS" && return
13421 $SETSTRIPE -c 1 $DIR/$tfile
13422 # ldiskfs extent file size limit is (16TB - 4KB - 1) bytes
13423 local size=$((16 * 1024 * 1024 * 1024 * 1024 - 4096 - 1))
13424 $TRUNCATE $DIR/$tfile $size || error "truncate $tfile to $size failed"
13425 dd if=/dev/zero of=$DIR/$tfile bs=10 count=1 oflag=append \
13426 conv=notrunc,fsync && error "append succeeded"
13429 run_test 250 "Write above 16T limit"
13432 $SETSTRIPE -c -1 -S 1048576 $DIR/$tfile
13434 #define OBD_FAIL_LLITE_LOST_LAYOUT 0x1407
13435 #Skip once - writing the first stripe will succeed
13436 $LCTL set_param fail_loc=0xa0001407 fail_val=1
13437 $MULTIOP $DIR/$tfile o:O_RDWR:w2097152c 2>&1 | grep -q "short write" &&
13438 error "short write happened"
13440 $LCTL set_param fail_loc=0xa0001407 fail_val=1
13441 $MULTIOP $DIR/$tfile or2097152c 2>&1 | grep -q "short read" &&
13442 error "short read happened"
13446 run_test 251 "Handling short read and write correctly"
13456 if [ "$(facet_fstype ost1)" != "ldiskfs" -o \
13457 "$(facet_fstype mds1)" != "ldiskfs" ]; then
13458 skip "can only run lr_reader on ldiskfs target"
13462 # check lr_reader on OST0000
13464 dev=$(facet_device $tgt)
13465 out=$(do_facet $tgt $LR_READER $dev)
13466 [ $? -eq 0 ] || error "$LR_READER failed on target $tgt device $dev"
13468 uuid=$(echo "$out" | grep -i uuid | awk '{ print $2 }')
13469 [ "$uuid" == "$(ostuuid_from_index 0)" ] ||
13470 error "Invalid uuid returned by $LR_READER on target $tgt"
13471 echo -e "uuid returned by $LR_READER is '$uuid'\n"
13473 # check lr_reader -c on MDT0000
13475 dev=$(facet_device $tgt)
13476 if ! do_facet $tgt $LR_READER -h | grep -q OPTIONS; then
13477 echo "$LR_READER does not support additional options"
13480 out=$(do_facet $tgt $LR_READER -c $dev)
13481 [ $? -eq 0 ] || error "$LR_READER failed on target $tgt device $dev"
13483 num=$(echo "$out" | grep -c "mdtlov")
13484 [ "$num" -eq $((MDSCOUNT - 1)) ] ||
13485 error "Invalid number of mdtlov clients returned by $LR_READER"
13486 echo -e "Number of mdtlov clients returned by $LR_READER is '$num'\n"
13488 # check lr_reader -cr on MDT0000
13489 out=$(do_facet $tgt $LR_READER -cr $dev)
13490 [ $? -eq 0 ] || error "$LR_READER failed on target $tgt device $dev"
13492 echo "$out" | grep -q "^reply_data:$" ||
13493 error "$LR_READER should have returned 'reply_data' section"
13494 num=$(echo "$out" | grep -c "client_generation")
13495 echo -e "Number of reply data returned by $LR_READER is '$num'\n"
13497 run_test 252 "check lr_reader tool"
13500 cleanup_test_300() {
13504 test_striped_dir() {
13509 mkdir -p $DIR/$tdir
13511 SAVE_UMASK=$(umask)
13512 trap cleanup_test_300 RETURN EXIT
13514 $LFS setdirstripe -i $mdt_index -c 2 -t all_char -m 755 \
13515 $DIR/$tdir/striped_dir ||
13516 error "set striped dir error"
13518 local mode=$(stat -c%a $DIR/$tdir/striped_dir)
13519 [ "$mode" = "755" ] || error "expect 755 got $mode"
13521 $LFS getdirstripe $DIR/$tdir/striped_dir > /dev/null 2>&1 ||
13522 error "getdirstripe failed"
13523 stripe_count=$($LFS getdirstripe -c $DIR/$tdir/striped_dir)
13524 if [ "$stripe_count" != "2" ]; then
13525 error "stripe_count is $stripe_count, expect 2"
13528 stripe_index=$($LFS getdirstripe -i $DIR/$tdir/striped_dir)
13529 if [ "$stripe_index" != "$mdt_index" ]; then
13530 error "stripe_index is $stripe_index, expect $mdt_index"
13533 [ $(stat -c%h $DIR/$tdir/striped_dir) == '2' ] ||
13534 error "nlink error after create striped dir"
13536 mkdir $DIR/$tdir/striped_dir/a
13537 mkdir $DIR/$tdir/striped_dir/b
13539 stat $DIR/$tdir/striped_dir/a ||
13540 error "create dir under striped dir failed"
13541 stat $DIR/$tdir/striped_dir/b ||
13542 error "create dir under striped dir failed"
13544 [ $(stat -c%h $DIR/$tdir/striped_dir) == '4' ] ||
13545 error "nlink error after mkdir"
13547 rmdir $DIR/$tdir/striped_dir/a
13548 [ $(stat -c%h $DIR/$tdir/striped_dir) == '3' ] ||
13549 error "nlink error after rmdir"
13551 rmdir $DIR/$tdir/striped_dir/b
13552 [ $(stat -c%h $DIR/$tdir/striped_dir) == '2' ] ||
13553 error "nlink error after rmdir"
13555 chattr +i $DIR/$tdir/striped_dir
13556 createmany -o $DIR/$tdir/striped_dir/f 10 &&
13557 error "immutable flags not working under striped dir!"
13558 chattr -i $DIR/$tdir/striped_dir
13560 rmdir $DIR/$tdir/striped_dir ||
13561 error "rmdir striped dir error"
13569 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13570 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
13572 test_striped_dir 0 || error "failed on striped dir on MDT0"
13573 test_striped_dir 1 || error "failed on striped dir on MDT0"
13575 run_test 300a "basic striped dir sanity test"
13578 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13579 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
13585 test_mkdir $DIR/$tdir || error "mkdir fail"
13586 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir ||
13587 error "set striped dir error"
13588 for ((i=0; i<10; i++)); do
13589 mtime1=$(stat -c %Y $DIR/$tdir/striped_dir)
13591 touch $DIR/$tdir/striped_dir/file_$i ||
13592 error "touch error $i"
13593 mtime2=$(stat -c %Y $DIR/$tdir/striped_dir)
13594 [ $mtime1 -eq $mtime2 ] &&
13595 error "mtime not change after create"
13597 rm -f $DIR/$tdir/striped_dir/file_$i ||
13598 error "unlink error $i"
13599 mtime3=$(stat -c %Y $DIR/$tdir/striped_dir)
13600 [ $mtime2 -eq $mtime3 ] &&
13601 error "mtime did not change after unlink"
13605 run_test 300b "check ctime/mtime for striped dir"
13608 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13609 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
13612 mkdir -p $DIR/$tdir
13613 $LFS setdirstripe -i 0 -c 2 $DIR/$tdir/striped_dir ||
13614 error "set striped dir error"
13616 chown $RUNAS_ID:$RUNAS_GID $DIR/$tdir/striped_dir ||
13617 error "chown striped dir failed"
13619 $RUNAS createmany -o $DIR/$tdir/striped_dir/f 5000 ||
13620 error "create 5k files failed"
13622 file_count=$(ls $DIR/$tdir/striped_dir | wc -l)
13624 [ "$file_count" = 5000 ] || error "file count $file_count != 5000"
13628 run_test 300c "chown && check ls under striped directory"
13631 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13632 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
13636 mkdir -p $DIR/$tdir
13637 $SETSTRIPE -c 2 $DIR/$tdir
13639 #local striped directory
13640 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir ||
13641 error "set striped dir error"
13642 createmany -o $DIR/$tdir/striped_dir/f 10 ||
13643 error "create 10 files failed"
13645 #remote striped directory
13646 $LFS setdirstripe -i 1 -c 2 $DIR/$tdir/remote_striped_dir ||
13647 error "set striped dir error"
13648 createmany -o $DIR/$tdir/remote_striped_dir/f 10 ||
13649 error "create 10 files failed"
13651 for file in $(find $DIR/$tdir); do
13652 stripe_count=$($GETSTRIPE -c $file)
13653 [ $stripe_count -eq 2 ] ||
13654 error "wrong stripe $stripe_count for $file"
13659 run_test 300d "check default stripe under striped directory"
13662 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
13663 skip "Need MDS version at least 2.7.55" && return
13664 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13665 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
13669 mkdir -p $DIR/$tdir
13671 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir ||
13672 error "set striped dir error"
13674 touch $DIR/$tdir/striped_dir/a
13675 touch $DIR/$tdir/striped_dir/b
13676 touch $DIR/$tdir/striped_dir/c
13678 mkdir $DIR/$tdir/striped_dir/dir_a
13679 mkdir $DIR/$tdir/striped_dir/dir_b
13680 mkdir $DIR/$tdir/striped_dir/dir_c
13682 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir/stp_a ||
13683 error "set striped dir under striped dir error"
13685 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir/stp_b ||
13686 error "set striped dir under striped dir error"
13688 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir/stp_c ||
13689 error "set striped dir under striped dir error"
13691 mrename $DIR/$tdir/striped_dir/dir_a $DIR/$tdir/striped_dir/dir_b ||
13692 error "rename dir under striped dir fails"
13694 mrename $DIR/$tdir/striped_dir/stp_a $DIR/$tdir/striped_dir/stp_b ||
13695 error "rename dir under different stripes fails"
13697 mrename $DIR/$tdir/striped_dir/a $DIR/$tdir/striped_dir/c ||
13698 error "rename file under striped dir should succeed"
13700 mrename $DIR/$tdir/striped_dir/dir_b $DIR/$tdir/striped_dir/dir_c ||
13701 error "rename dir under striped dir should succeed"
13705 run_test 300e "check rename under striped directory"
13708 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
13709 skip "Need MDS version at least 2.7.55" && return
13710 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13711 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
13716 mkdir -p $DIR/$tdir
13718 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir ||
13719 error "set striped dir error"
13721 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir1 ||
13722 error "set striped dir error"
13724 touch $DIR/$tdir/striped_dir/a
13725 mkdir $DIR/$tdir/striped_dir/dir_a
13726 $LFS setdirstripe -i 0 -c 2 $DIR/$tdir/striped_dir/stp_a ||
13727 error "create striped dir under striped dir fails"
13729 touch $DIR/$tdir/striped_dir1/b
13730 mkdir $DIR/$tdir/striped_dir1/dir_b
13731 $LFS setdirstripe -i 0 -c 2 $DIR/$tdir/striped_dir/stp_b ||
13732 error "create striped dir under striped dir fails"
13734 mrename $DIR/$tdir/striped_dir/dir_a $DIR/$tdir/striped_dir1/dir_b ||
13735 error "rename dir under different striped dir should fail"
13737 mrename $DIR/$tdir/striped_dir/stp_a $DIR/$tdir/striped_dir1/stp_b ||
13738 error "rename striped dir under diff striped dir should fail"
13740 mrename $DIR/$tdir/striped_dir/a $DIR/$tdir/striped_dir1/a ||
13741 error "rename file under diff striped dirs fails"
13745 run_test 300f "check rename cross striped directory"
13747 test_300_check_default_striped_dir()
13750 local default_count=$2
13751 local default_index=$3
13754 local dir_stripe_index
13757 echo "checking $dirname $default_count $default_index"
13758 $LFS setdirstripe -D -c $default_count -i $default_index \
13759 -t all_char $DIR/$tdir/$dirname ||
13760 error "set default stripe on striped dir error"
13761 stripe_count=$($LFS getdirstripe -D -c $DIR/$tdir/$dirname)
13762 [ $stripe_count -eq $default_count ] ||
13763 error "expect $default_count get $stripe_count for $dirname"
13765 stripe_index=$($LFS getdirstripe -D -i $DIR/$tdir/$dirname)
13766 [ $stripe_index -eq $default_index ] ||
13767 error "expect $default_index get $stripe_index for $dirname"
13769 mkdir $DIR/$tdir/$dirname/{test1,test2,test3,test4} ||
13770 error "create dirs failed"
13772 createmany -o $DIR/$tdir/$dirname/f- 10 || error "create files failed"
13773 unlinkmany $DIR/$tdir/$dirname/f- 10 || error "unlink files failed"
13774 for dir in $(find $DIR/$tdir/$dirname/*); do
13775 stripe_count=$($LFS getdirstripe -c $dir)
13776 [ $stripe_count -eq $default_count ] ||
13777 [ $stripe_count -eq 0 -o $default_count -eq 1 ] ||
13778 error "stripe count $default_count != $stripe_count for $dir"
13780 stripe_index=$($LFS getdirstripe -i $dir)
13781 [ $default_index -eq -1 -o $stripe_index -eq $default_index ] ||
13782 error "$stripe_index != $default_index for $dir"
13784 #check default stripe
13785 stripe_count=$($LFS getdirstripe -D -c $dir)
13786 [ $stripe_count -eq $default_count ] ||
13787 error "default count $default_count != $stripe_count for $dir"
13789 stripe_index=$($LFS getdirstripe -D -i $dir)
13790 [ $stripe_index -eq $default_index ] ||
13791 error "default index $default_index != $stripe_index for $dir"
13793 rmdir $DIR/$tdir/$dirname/* || error "rmdir failed"
13797 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
13798 skip "Need MDS version at least 2.7.55" && return
13799 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
13805 mkdir $DIR/$tdir/normal_dir
13807 test_300_check_default_striped_dir normal_dir $MDSCOUNT 1
13808 test_300_check_default_striped_dir normal_dir 1 0
13809 test_300_check_default_striped_dir normal_dir 2 1
13810 test_300_check_default_striped_dir normal_dir 2 -1
13812 #delete default stripe information
13813 echo "delete default stripeEA"
13814 $LFS setdirstripe -d $DIR/$tdir/normal_dir ||
13815 error "set default stripe on striped dir error"
13817 mkdir -p $DIR/$tdir/normal_dir/{test1,test2,test3,test4}
13818 for dir in $(find $DIR/$tdir/normal_dir/*); do
13819 stripe_count=$($LFS getdirstripe -c $dir)
13820 [ $stripe_count -eq 0 ] ||
13821 error "expect 1 get $stripe_count for $dir"
13822 stripe_index=$($LFS getdirstripe -i $dir)
13823 [ $stripe_index -eq 0 ] ||
13824 error "expect 0 get $stripe_index for $dir"
13827 run_test 300g "check default striped directory for normal directory"
13830 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
13831 skip "Need MDS version at least 2.7.55" && return
13832 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
13837 $LFS setdirstripe -i 0 -c $MDSCOUNT -t all_char \
13838 $DIR/$tdir/striped_dir ||
13839 error "set striped dir error"
13841 test_300_check_default_striped_dir striped_dir $MDSCOUNT 1
13842 test_300_check_default_striped_dir striped_dir 1 0
13843 test_300_check_default_striped_dir striped_dir 2 1
13844 test_300_check_default_striped_dir striped_dir 2 -1
13846 #delete default stripe information
13847 $LFS setdirstripe -d $DIR/$tdir/striped_dir ||
13848 error "set default stripe on striped dir error"
13850 mkdir -p $DIR/$tdir/striped_dir/{test1,test2,test3,test4}
13851 for dir in $(find $DIR/$tdir/striped_dir/*); do
13852 stripe_count=$($LFS getdirstripe -c $dir)
13853 [ $stripe_count -eq 0 ] ||
13854 error "expect 1 get $stripe_count for $dir"
13857 run_test 300h "check default striped directory for striped directory"
13860 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
13861 skip "Need MDS version at least 2.7.55" && return
13862 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13863 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
13869 $LFS setdirstripe -i 0 -c$MDSCOUNT -t all_char $DIR/$tdir/striped_dir ||
13870 error "set striped dir error"
13872 createmany -o $DIR/$tdir/striped_dir/f- 10 ||
13873 error "create files under striped dir failed"
13875 # unfortunately, we need to umount to clear dir layout cache for now
13876 # once we fully implement dir layout, we can drop this
13877 umount_client $MOUNT || error "umount failed"
13878 mount_client $MOUNT || error "mount failed"
13880 #set the stripe to be unknown hash type
13881 #define OBD_FAIL_UNKNOWN_LMV_STRIPE 0x1901
13882 $LCTL set_param fail_loc=0x1901
13883 for ((i = 0; i < 10; i++)); do
13884 $CHECKSTAT -t file $DIR/$tdir/striped_dir/f-$i ||
13885 error "stat f-$i failed"
13886 rm $DIR/$tdir/striped_dir/f-$i || error "unlink f-$i failed"
13889 touch $DIR/$tdir/striped_dir/f0 &&
13890 error "create under striped dir with unknown hash should fail"
13892 $LCTL set_param fail_loc=0
13894 umount_client $MOUNT || error "umount failed"
13895 mount_client $MOUNT || error "mount failed"
13899 run_test 300i "client handle unknown hash type striped directory"
13902 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13903 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
13904 skip "Need MDS version at least 2.7.55" && return
13905 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
13911 #define OBD_FAIL_SPLIT_UPDATE_REC 0x1702
13912 $LCTL set_param fail_loc=0x1702
13913 $LFS setdirstripe -i 0 -c$MDSCOUNT -t all_char $DIR/$tdir/striped_dir ||
13914 error "set striped dir error"
13916 createmany -o $DIR/$tdir/striped_dir/f- 10 ||
13917 error "create files under striped dir failed"
13919 $LCTL set_param fail_loc=0
13921 rm -rf $DIR/$tdir || error "unlink striped dir fails"
13925 run_test 300j "test large update record"
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
13937 #define OBD_FAIL_LARGE_STRIPE 0x1703
13938 $LCTL set_param fail_loc=0x1703
13939 $LFS setdirstripe -i 0 -c512 $DIR/$tdir/striped_dir ||
13940 error "set striped dir error"
13941 $LCTL set_param fail_loc=0
13943 $LFS getdirstripe $DIR/$tdir/striped_dir ||
13944 error "getstripeddir fails"
13945 rm -rf $DIR/$tdir/striped_dir ||
13946 error "unlink striped dir fails"
13950 run_test 300k "test large striped directory"
13953 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
13954 skip "Need MDS version at least 2.7.55" && return
13955 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13956 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
13959 test_mkdir -p $DIR/$tdir/striped_dir
13960 chown $RUNAS_ID $DIR/$tdir/striped_dir ||
13961 error "chown $RUNAS_ID failed"
13962 $LFS setdirstripe -i 1 -D $DIR/$tdir/striped_dir ||
13963 error "set default striped dir failed"
13965 #define OBD_FAIL_MDS_STALE_DIR_LAYOUT 0x158
13966 $LCTL set_param fail_loc=0x80000158
13967 $RUNAS mkdir $DIR/$tdir/striped_dir/test_dir || error "create dir fails"
13969 stripe_index=$($LFS getdirstripe -i $DIR/$tdir/striped_dir/test_dir)
13970 [ $stripe_index -eq 1 ] ||
13971 error "expect 1 get $stripe_index for $dir"
13973 run_test 300l "non-root user to create dir under striped dir with stale layout"
13976 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
13977 skip "Need MDS version at least 2.7.55" && return
13978 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13979 [ $MDSCOUNT -ge 2 ] && skip "Only for single MDT" && return
13981 mkdir -p $DIR/$tdir/striped_dir
13982 $LFS setdirstripe -D -c 1 $DIR/$tdir/striped_dir ||
13983 error "set default stripes dir error"
13985 mkdir $DIR/$tdir/striped_dir/a || error "mkdir a fails"
13987 stripe_count=$($LFS getdirstripe -c $DIR/$tdir/striped_dir/a)
13988 [ $stripe_count -eq 0 ] ||
13989 error "expect 0 get $stripe_count for a"
13991 $LFS setdirstripe -D -c 2 $DIR/$tdir/striped_dir ||
13992 error "set default stripes dir error"
13994 mkdir $DIR/$tdir/striped_dir/b || error "mkdir b fails"
13996 stripe_count=$($LFS getdirstripe -c $DIR/$tdir/striped_dir/b)
13997 [ $stripe_count -eq 0 ] ||
13998 error "expect 0 get $stripe_count for b"
14000 $LFS setdirstripe -D -c1 -i2 $DIR/$tdir/striped_dir ||
14001 error "set default stripes dir error"
14003 mkdir $DIR/$tdir/striped_dir/c &&
14004 error "default stripe_index is invalid, mkdir c should fails"
14006 rm -rf $DIR/$tdir || error "rmdir fails"
14008 run_test 300m "setstriped directory on single MDT FS"
14011 local list=$(comma_list $(mdts_nodes))
14014 do_nodes $list $LCTL set_param -n mdt.*.enable_remote_dir_gid=0
14018 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
14019 skip "Need MDS version at least 2.7.55" && return
14020 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
14021 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
14023 local list=$(comma_list $(mdts_nodes))
14025 trap cleanup_300n RETURN EXIT
14026 mkdir -p $DIR/$tdir
14027 chmod 777 $DIR/$tdir
14028 $RUNAS $LFS setdirstripe -i0 -c$MDSCOUNT \
14029 $DIR/$tdir/striped_dir > /dev/null 2>&1 &&
14030 error "create striped dir succeeds with gid=0"
14032 do_nodes $list $LCTL set_param -n mdt.*.enable_remote_dir_gid=-1
14033 $RUNAS $LFS setdirstripe -i0 -c$MDSCOUNT $DIR/$tdir/striped_dir ||
14034 error "create striped dir fails with gid=-1"
14036 do_nodes $list $LCTL set_param -n mdt.*.enable_remote_dir_gid=0
14037 $RUNAS $LFS setdirstripe -i 1 -c$MDSCOUNT -D \
14038 $DIR/$tdir/striped_dir > /dev/null 2>&1 &&
14039 error "set default striped dir succeeds with gid=0"
14042 do_nodes $list $LCTL set_param -n mdt.*.enable_remote_dir_gid=-1
14043 $RUNAS $LFS setdirstripe -i 1 -c$MDSCOUNT -D $DIR/$tdir/striped_dir ||
14044 error "set default striped dir fails with gid=-1"
14047 do_nodes $list $LCTL set_param -n mdt.*.enable_remote_dir_gid=0
14048 $RUNAS mkdir $DIR/$tdir/striped_dir/test_dir ||
14049 error "create test_dir fails"
14050 $RUNAS mkdir $DIR/$tdir/striped_dir/test_dir1 ||
14051 error "create test_dir1 fails"
14052 $RUNAS mkdir $DIR/$tdir/striped_dir/test_dir2 ||
14053 error "create test_dir2 fails"
14056 run_test 300n "non-root user to create dir under striped dir with default EA"
14059 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
14060 skip "Need MDS version at least 2.7.55" && return
14061 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
14062 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
14066 mkdir -p $DIR/$tdir
14068 numfree1=$(lctl get_param -n mdc.*MDT0000*.filesfree)
14069 numfree2=$(lctl get_param -n mdc.*MDT0001*.filesfree)
14070 if [ $numfree1 -lt 66000 -o $numfree2 -lt 66000 ]; then
14071 skip "not enough free inodes $numfree1 $numfree2"
14075 numfree1=$(lctl get_param -n mdc.*MDT0000-mdc-*.kbytesfree)
14076 numfree2=$(lctl get_param -n mdc.*MDT0001-mdc-*.kbytesfree)
14077 if [ $numfree1 -lt 300000 -o $numfree2 -lt 300000 ]; then
14078 skip "not enough free space $numfree1 $numfree2"
14082 $LFS setdirstripe -c2 $DIR/$tdir/striped_dir ||
14083 error "setdirstripe fails"
14085 createmany -d $DIR/$tdir/striped_dir/d 131000 ||
14086 error "create dirs fails"
14088 $LCTL set_param ldlm.namespaces.*mdc-*.lru_size=0
14089 ls $DIR/$tdir/striped_dir > /dev/null ||
14090 error "ls striped dir fails"
14091 unlinkmany -d $DIR/$tdir/striped_dir/d 131000 ||
14092 error "unlink big striped dir fails"
14094 run_test 300o "unlink big sub stripe(> 65000 subdirs)"
14097 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
14098 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
14100 mkdir -p $DIR/$tdir
14102 #define OBD_FAIL_OUT_ENOSPC 0x1704
14103 do_facet mds2 lctl set_param fail_loc=0x80001704
14104 $LFS setdirstripe -c2 $DIR/$tdir/bad_striped_dir > /dev/null 2>&1 &&
14105 error "create striped directory should fail"
14107 [ -e $DIR/$tdir/bad_striped_dir ] && error "striped dir exists"
14110 run_test 300p "create striped directory without space"
14112 prepare_remote_file() {
14113 mkdir $DIR/$tdir/src_dir ||
14114 error "create remote source failed"
14116 cp /etc/hosts $DIR/$tdir/src_dir/a || error
14117 touch $DIR/$tdir/src_dir/a
14119 $LFS mkdir -i 1 $DIR/$tdir/tgt_dir ||
14120 error "create remote target dir failed"
14122 touch $DIR/$tdir/tgt_dir/b
14124 mrename $DIR/$tdir/src_dir/a $DIR/$tdir/tgt_dir/b ||
14125 error "rename dir cross MDT failed!"
14127 $CHECKSTAT -t file $DIR/$tdir/src_dir/a &&
14128 error "src_child still exists after rename"
14130 $CHECKSTAT -t file $DIR/$tdir/tgt_dir/b ||
14131 error "missing file(a) after rename"
14133 diff /etc/hosts $DIR/$tdir/tgt_dir/b ||
14134 error "diff after rename"
14138 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 4 MDTs" && return
14139 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
14140 local remote_file=$DIR/$tdir/tgt_dir/b
14142 mkdir -p $DIR/$tdir
14144 prepare_remote_file || error "prepare remote file failed"
14147 $OPENUNLINK $remote_file $remote_file || error
14148 $CHECKSTAT -a $remote_file || error
14150 run_test 310a "open unlink remote file"
14153 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 4 MDTs" && return
14154 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
14155 local remote_file=$DIR/$tdir/tgt_dir/b
14157 mkdir -p $DIR/$tdir
14159 prepare_remote_file || error "prepare remote file failed"
14161 ln $remote_file $DIR/$tfile || error "link failed for remote file"
14162 $MULTIOP $DIR/$tfile Ouc || error "mulitop failed"
14163 $CHECKSTAT -t file $remote_file || error "check file failed"
14165 run_test 310b "unlink remote file with multiple links while open"
14168 [[ $MDSCOUNT -lt 4 ]] && skip "needs >= 4 MDTs" && return
14169 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
14170 local remote_file=$DIR/$tdir/tgt_dir/b
14172 mkdir -p $DIR/$tdir
14174 prepare_remote_file || error "prepare remote file failed"
14176 ln $remote_file $DIR/$tfile || error "link failed for remote file"
14177 multiop_bg_pause $remote_file O_uc ||
14178 error "mulitop failed for remote file"
14180 $MULTIOP $DIR/$tfile Ouc
14181 kill -USR1 $MULTIPID
14184 run_test 310c "open-unlink remote file with multiple links"
14186 test_400a() { # LU-1606, was conf-sanity test_74
14187 local extra_flags=''
14188 local out=$TMP/$tfile
14189 local prefix=/usr/include/lustre
14192 if ! which $CC > /dev/null 2>&1; then
14193 skip_env "$CC is not installed"
14197 if ! [[ -d $prefix ]]; then
14198 # Assume we're running in tree and fixup the include path.
14199 extra_flags+=" -I$LUSTRE/../libcfs/include"
14200 extra_flags+=" -I$LUSTRE/include"
14201 extra_flags+=" -L$LUSTRE/utils"
14204 for prog in $LUSTRE_TESTS_API_DIR/*.c; do
14205 $CC -Wall -Werror $extra_flags -llustreapi -o $out $prog ||
14206 error "client api broken"
14209 run_test 400a "Lustre client api program can compile and link"
14211 test_400b() { # LU-1606, LU-5011
14213 local out=$TMP/$tfile
14214 local prefix=/usr/include/lustre
14216 # We use a hard coded prefix so that this test will not fail
14217 # when run in tree. There are headers in lustre/include/lustre/
14218 # that are not packaged (like lustre_idl.h) and have more
14219 # complicated include dependencies (like config.h and lnet/types.h).
14220 # Since this test about correct packaging we just skip them when
14221 # they don't exist (see below) rather than try to fixup cppflags.
14223 if ! which $CC > /dev/null 2>&1; then
14224 skip_env "$CC is not installed"
14228 for header in $prefix/*.h; do
14229 if ! [[ -f "$header" ]]; then
14233 if [[ "$(basename $header)" == liblustreapi.h ]]; then
14234 continue # liblustreapi.h is deprecated.
14237 $CC -Wall -Werror -include $header -c -x c /dev/null -o $out ||
14238 error "cannot compile '$header'"
14241 run_test 400b "packaged headers can be compiled"
14243 test_401() { #LU-7437
14247 #count the number of parameters by "list_param -R"
14248 params=$($LCTL list_param -R '*' 2>/dev/null | wc -l)
14249 #count the number of parameters by listing proc files
14250 ls -lRL /proc/{fs,sys}/{lnet,lustre} 2>/dev/null |
14251 grep -v "^t" | grep -v "^d" > $TMP/$tfile
14252 #Since there is no /proc/fs/lnet, we need to remove other
14253 #3 directories, /proc/{fs,sys}/lustre and /proc/sys/lnet.
14254 procs=$(($(sed /^$/d $TMP/$tfile | wc -l)-3))
14256 [ $params -eq $procs ] ||
14257 error "found $params parameters vs. $procs proc files"
14261 run_test 401 "Verify if 'lctl list_param -R' can list parameters recursively"
14264 # tests that do cleanup/setup should be run at the end
14268 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
14270 #define OBD_FAIL_MGC_PAUSE_PROCESS_LOG 0x903
14271 $LCTL set_param fail_loc=0x903
14273 cancel_lru_locks MGC
14275 FAIL_ON_ERROR=true cleanup
14276 FAIL_ON_ERROR=true setup
14278 run_test 900 "umount should not race with any mgc requeue thread"
14281 [ -f $EXT2_DEV ] && rm $EXT2_DEV || true
14282 check_and_cleanup_lustre
14283 if [ "$I_MOUNTED" != "yes" ]; then
14284 lctl set_param debug="$OLDDEBUG" 2> /dev/null || true