2 # -*- tab-width: 8; indent-tabs-mode: t; -*-
4 # Run select tests by setting ONLY, or as arguments to the script.
5 # Skip specific tests by setting EXCEPT.
7 # e.g. ONLY="22 23" or ONLY="`seq 32 39`" or EXCEPT="31"
11 # bug number for skipped test: 13297 2108 9789 3637 9789 3561 12622 5188
12 ALWAYS_EXCEPT=" 42a 42b 42c 42d 45 51d 68b $SANITY_EXCEPT"
13 # UPDATE THE COMMENT ABOVE WITH BUG NUMBERS WHEN CHANGING ALWAYS_EXCEPT!
15 # with LOD/OSP landing
16 # bug number for skipped tests: LU-2036
17 ALWAYS_EXCEPT=" 76 $ALWAYS_EXCEPT"
21 if [ -r /etc/SuSE-release ]
23 local vers=$(grep VERSION /etc/SuSE-release | awk '{print $3}')
24 local patchlev=$(grep PATCHLEVEL /etc/SuSE-release |
26 if [ $vers -eq 11 ] && [ $patchlev -ge 3 ]; then
33 if is_sles11; then # LU-4341
34 ALWAYS_EXCEPT="$ALWAYS_EXCEPT 170"
37 SRCDIR=$(cd $(dirname $0); echo $PWD)
38 export PATH=$PATH:/sbin
43 CHECKSTAT=${CHECKSTAT:-"checkstat -v"}
44 CREATETEST=${CREATETEST:-createtest}
46 LFIND=${LFIND:-"$LFS find"}
47 LVERIFY=${LVERIFY:-ll_dirstripe_verify}
49 OPENFILE=${OPENFILE:-openfile}
50 OPENUNLINK=${OPENUNLINK:-openunlink}
51 export MULTIOP=${MULTIOP:-multiop}
52 READS=${READS:-"reads"}
53 MUNLINK=${MUNLINK:-munlink}
54 SOCKETSERVER=${SOCKETSERVER:-socketserver}
55 SOCKETCLIENT=${SOCKETCLIENT:-socketclient}
56 MEMHOG=${MEMHOG:-memhog}
57 DIRECTIO=${DIRECTIO:-directio}
58 ACCEPTOR_PORT=${ACCEPTOR_PORT:-988}
60 CHECK_GRANT=${CHECK_GRANT:-"yes"}
61 GRANT_CHECK_LIST=${GRANT_CHECK_LIST:-""}
62 export PARALLEL=${PARALLEL:-"no"}
64 export NAME=${NAME:-local}
71 LUSTRE=${LUSTRE:-$(cd $(dirname $0)/..; echo $PWD)}
72 LUSTRE_TESTS_API_DIR=${LUSTRE_TESTS_API_DIR:-${LUSTRE}/tests/clientapi}
73 . $LUSTRE/tests/test-framework.sh
75 . ${CONFIG:=$LUSTRE/tests/cfg/${NAME}.sh}
78 [ "$SLOW" = "no" ] && EXCEPT_SLOW="24o 24D 27m 64b 68 71 77f 78 115 124b 300o"
80 if [ $(facet_fstype $SINGLEMDS) = "zfs" ]; then
81 # bug number for skipped test: LU-4536 LU-1957 LU-2805
82 ALWAYS_EXCEPT="$ALWAYS_EXCEPT 65ic 180 184c"
83 [ "$SLOW" = "no" ] && EXCEPT_SLOW="$EXCEPT_SLOW 51b 51ba"
90 pgrep ll_sa > /dev/null && { echo "There are ll_sa thread not exit!"; exit 20; }
91 cleanupall ${FORCE} $* || { echo "FAILed to clean up"; exit 20; }
100 check_swap_layouts_support()
102 $LCTL get_param -n llite.*.sbi_flags | grep -q layout ||
103 { skip "Does not support layout lock."; return 0; }
107 check_and_setup_lustre
112 MDT0=$($LCTL get_param -n mdc.*.mds_server_uuid |
113 awk '{ gsub(/_UUID/,""); print $1 }' | head -n1)
114 LOVNAME=$($LCTL get_param -n llite.*.lov.common_name | tail -n 1)
115 OSTCOUNT=$($LCTL get_param -n lov.$LOVNAME.numobd)
116 STRIPECOUNT=$($LCTL get_param -n lov.$LOVNAME.stripecount)
117 STRIPESIZE=$($LCTL get_param -n lov.$LOVNAME.stripesize)
118 ORIGFREE=$($LCTL get_param -n lov.$LOVNAME.kbytesavail)
119 MAXFREE=${MAXFREE:-$((200000 * $OSTCOUNT))}
121 [ -f $DIR/d52a/foo ] && chattr -a $DIR/d52a/foo
122 [ -f $DIR/d52b/foo ] && chattr -i $DIR/d52b/foo
123 rm -rf $DIR/[Rdfs][0-9]*
125 # $RUNAS_ID may get set incorrectly somewhere else
126 [ $UID -eq 0 -a $RUNAS_ID -eq 0 ] && error "\$RUNAS_ID set to 0, but \$UID is also 0!"
128 check_runas_id $RUNAS_ID $RUNAS_GID $RUNAS
132 if [ "${ONLY}" = "MOUNT" ] ; then
133 echo "Lustre is up, please go on"
137 echo "preparing for tests involving mounts"
138 EXT2_DEV=${EXT2_DEV:-$TMP/SANITY.LOOP}
140 mke2fs -j -F $EXT2_DEV 8000 > /dev/null
141 echo # add a newline after mke2fs.
145 OLDDEBUG=$(lctl get_param -n debug 2> /dev/null)
146 lctl set_param debug=-1 2> /dev/null || true
149 $CHECKSTAT -t file $DIR/$tfile || error "$tfile is not a file"
151 $CHECKSTAT -a $DIR/$tfile || error "$tfile was not removed"
153 run_test 0a "touch; rm ====================="
156 chmod 0755 $DIR || error "chmod 0755 $DIR failed"
157 $CHECKSTAT -p 0755 $DIR || error "$DIR permission is not 0755"
159 run_test 0b "chmod 0755 $DIR ============================="
162 $LCTL get_param mdc.*.import | grep "state: FULL" ||
163 error "import not FULL"
164 $LCTL get_param mdc.*.import | grep "target: $FSNAME-MDT" ||
167 run_test 0c "check import proc ============================="
170 test_mkdir -p $DIR/$tdir || error "mkdir $tdir failed"
171 test_mkdir -p $DIR/$tdir/d2 || error "mkdir $tdir/d2 failed"
172 test_mkdir $DIR/$tdir/d2 && error "we expect EEXIST, but not returned"
173 $CHECKSTAT -t dir $DIR/$tdir/d2 || error "$tdir/d2 is not a dir"
176 $CHECKSTAT -a $DIR/$tdir || error "$tdir was not removed"
178 run_test 1 "mkdir; remkdir; rmdir =============================="
181 test_mkdir -p $DIR/$tdir || error "mkdir $tdir failed"
182 touch $DIR/$tdir/$tfile || error "touch $tdir/$tfile failed"
183 $CHECKSTAT -t file $DIR/$tdir/$tfile || error "$tdir/$tfile not a file"
185 $CHECKSTAT -a $DIR/$tdir/$tfile || error "$tdir/$file is not removed"
187 run_test 2 "mkdir; touch; rmdir; check file ===================="
190 test_mkdir -p $DIR/$tdir || error "mkdir $tdir failed"
191 $CHECKSTAT -t dir $DIR/$tdir || error "$tdir is not a directory"
192 touch $DIR/$tdir/$tfile
193 $CHECKSTAT -t file $DIR/$tdir/$tfile || error "$tdir/$tfile not a file"
195 $CHECKSTAT -a $DIR/$tdir || error "$tdir is not removed"
197 run_test 3 "mkdir; touch; rmdir; check dir ====================="
199 # LU-4471 - failed rmdir on remote directories still removes directory on MDT0
203 test_mkdir $DIR/$tdir ||
204 error "Create remote directory failed"
206 touch $DIR/$tdir/$tfile ||
207 error "Create file under remote directory failed"
210 error "Expect error removing in-use dir $DIR/$tdir"
212 test -d $DIR/$tdir || error "Remote directory disappeared"
214 rm -rf $DIR/$tdir || error "remove remote dir error"
216 run_test 4 "mkdir; touch dir/file; rmdir; checkdir (expect error)"
219 test_mkdir -p $DIR/$tdir || error "mkdir $tdir failed"
220 test_mkdir $DIR/$tdir/d2 || error "mkdir $tdir/d2 failed"
221 chmod 0707 $DIR/$tdir/d2 || error "chmod 0707 $tdir/d2 failed"
222 $CHECKSTAT -t dir -p 0707 $DIR/$tdir/d2 || error "$tdir/d2 not mode 707"
223 $CHECKSTAT -t dir $DIR/$tdir/d2 || error "$tdir/d2 is not a directory"
225 run_test 5 "mkdir .../d5 .../d5/d2; chmod .../d5/d2 ============"
228 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
229 chmod 0666 $DIR/$tfile || error "chmod 0666 $tfile failed"
230 $CHECKSTAT -t file -p 0666 -u \#$UID $DIR/$tfile ||
231 error "$tfile does not have perm 0666 or UID $UID"
232 $RUNAS chmod 0444 $DIR/$tfile && error "chmod $tfile worked on UID $UID"
233 $CHECKSTAT -t file -p 0666 -u \#$UID $DIR/$tfile ||
234 error "$tfile should be 0666 and owned by UID $UID"
236 run_test 6a "touch f6a; chmod f6a; $RUNAS chmod f6a (should return error) =="
239 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID" && return
241 chown $RUNAS_ID $DIR/$tfile || error "chown $RUNAS_ID $file failed"
242 $CHECKSTAT -t file -u \#$RUNAS_ID $DIR/$tfile ||
243 error "$tfile should be owned by UID $RUNAS_ID"
244 $RUNAS chown $UID $DIR/$tfile && error "chown $UID $file succeeded"
245 $CHECKSTAT -t file -u \#$RUNAS_ID $DIR/$tfile ||
246 error "$tfile should be owned by UID $RUNAS_ID"
248 run_test 6c "touch f6c; chown f6c; $RUNAS chown f6c (should return error) =="
251 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID" && return
253 chgrp $RUNAS_ID $DIR/$tfile || error "chgrp $RUNAS_ID $file failed"
254 $CHECKSTAT -t file -u \#$UID -g \#$RUNAS_ID $DIR/$tfile ||
255 error "$tfile should be owned by GID $UID"
256 $RUNAS chgrp $UID $DIR/$tfile && error "chgrp $UID $file succeeded"
257 $CHECKSTAT -t file -u \#$UID -g \#$RUNAS_ID $DIR/$tfile ||
258 error "$tfile should be owned by UID $UID and GID $RUNAS_ID"
260 run_test 6e "touch f6e; chgrp f6e; $RUNAS chgrp f6e (should return error) =="
263 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID" && return
264 test_mkdir $DIR/$tdir || error "mkdir $tfile failed"
265 chmod 777 $DIR/$tdir || error "chmod 0777 $tdir failed"
266 $RUNAS mkdir $DIR/$tdir/d || error "mkdir $tdir/d failed"
267 chmod g+s $DIR/$tdir/d || error "chmod g+s $tdir/d failed"
268 test_mkdir $DIR/$tdir/d/subdir || error "mkdir $tdir/d/subdir failed"
269 $CHECKSTAT -g \#$RUNAS_GID $DIR/$tdir/d/subdir ||
270 error "$tdir/d/subdir should be GID $RUNAS_GID"
272 run_test 6g "Is new dir in sgid dir inheriting group?"
274 test_6h() { # bug 7331
275 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID" && return
276 touch $DIR/$tfile || error "touch failed"
277 chown $RUNAS_ID:$RUNAS_GID $DIR/$tfile || error "initial chown failed"
278 $RUNAS -G$RUNAS_GID chown $RUNAS_ID:0 $DIR/$tfile &&
279 error "chown $RUNAS_ID:0 $tfile worked as GID $RUNAS_GID"
280 $CHECKSTAT -t file -u \#$RUNAS_ID -g \#$RUNAS_GID $DIR/$tfile ||
281 error "$tdir/$tfile should be UID $RUNAS_UID GID $RUNAS_GID"
283 run_test 6h "$RUNAS chown RUNAS_ID.0 .../f6h (should return error)"
286 test_mkdir $DIR/$tdir
287 $MCREATE $DIR/$tdir/$tfile
288 chmod 0666 $DIR/$tdir/$tfile
289 $CHECKSTAT -t file -p 0666 $DIR/$tdir/$tfile ||
290 error "$tdir/$tfile should be mode 0666"
292 run_test 7a "mkdir .../d7; mcreate .../d7/f; chmod .../d7/f ===="
295 if [ ! -d $DIR/$tdir ]; then
296 test_mkdir $DIR/$tdir
298 $MCREATE $DIR/$tdir/$tfile
299 echo -n foo > $DIR/$tdir/$tfile
300 [ "$(cat $DIR/$tdir/$tfile)" = "foo" ] || error "$tdir/$tfile not 'foo'"
301 $CHECKSTAT -t file -s 3 $DIR/$tdir/$tfile || error "$tfile size not 3"
303 run_test 7b "mkdir .../d7; mcreate d7/f2; echo foo > d7/f2 ====="
306 test_mkdir $DIR/$tdir
307 touch $DIR/$tdir/$tfile
308 chmod 0666 $DIR/$tdir/$tfile
309 $CHECKSTAT -t file -p 0666 $DIR/$tdir/$tfile ||
310 error "$tfile mode not 0666"
312 run_test 8 "mkdir .../d8; touch .../d8/f; chmod .../d8/f ======="
315 test_mkdir $DIR/$tdir
316 test_mkdir $DIR/$tdir/d2
317 test_mkdir $DIR/$tdir/d2/d3
318 $CHECKSTAT -t dir $DIR/$tdir/d2/d3 || error "$tdir/d2/d3 not a dir"
320 run_test 9 "mkdir .../d9 .../d9/d2 .../d9/d2/d3 ================"
323 test_mkdir $DIR/$tdir
324 test_mkdir $DIR/$tdir/d2
325 touch $DIR/$tdir/d2/$tfile
326 $CHECKSTAT -t file $DIR/$tdir/d2/$tfile ||
327 error "$tdir/d2/$tfile not a file"
329 run_test 10 "mkdir .../d10 .../d10/d2; touch .../d10/d2/f ======"
332 test_mkdir $DIR/$tdir
333 test_mkdir $DIR/$tdir/d2
334 chmod 0666 $DIR/$tdir/d2
335 chmod 0705 $DIR/$tdir/d2
336 $CHECKSTAT -t dir -p 0705 $DIR/$tdir/d2 ||
337 error "$tdir/d2 mode not 0705"
339 run_test 11 "mkdir .../d11 d11/d2; chmod .../d11/d2 ============"
342 test_mkdir $DIR/$tdir
343 touch $DIR/$tdir/$tfile
344 chmod 0666 $DIR/$tdir/$tfile
345 chmod 0654 $DIR/$tdir/$tfile
346 $CHECKSTAT -t file -p 0654 $DIR/$tdir/$tfile ||
347 error "$tdir/d2 mode not 0654"
349 run_test 12 "touch .../d12/f; chmod .../d12/f .../d12/f ========"
352 test_mkdir $DIR/$tdir
353 dd if=/dev/zero of=$DIR/$tdir/$tfile count=10
355 $CHECKSTAT -t file -s 0 $DIR/$tdir/$tfile ||
356 error "$tdir/$tfile size not 0 after truncate"
358 run_test 13 "creat .../d13/f; dd .../d13/f; > .../d13/f ========"
361 test_mkdir $DIR/$tdir
362 touch $DIR/$tdir/$tfile
364 $CHECKSTAT -a $DIR/$tdir/$tfile || error "$tdir/$tfile not removed"
366 run_test 14 "touch .../d14/f; rm .../d14/f; rm .../d14/f ======="
369 test_mkdir $DIR/$tdir
370 touch $DIR/$tdir/$tfile
371 mv $DIR/$tdir/$tfile $DIR/$tdir/${tfile}_2
372 $CHECKSTAT -t file $DIR/$tdir/${tfile}_2 ||
373 error "$tdir/${tfile_2} not a file after rename"
374 rm $DIR/$tdir/${tfile}_2 || error "unlink failed after rename"
376 run_test 15 "touch .../d15/f; mv .../d15/f .../d15/f2 =========="
379 test_mkdir $DIR/$tdir
380 touch $DIR/$tdir/$tfile
381 rm -rf $DIR/$tdir/$tfile
382 $CHECKSTAT -a $DIR/$tdir/$tfile || error "$tdir/$tfile not removed"
384 run_test 16 "touch .../d16/f; rm -rf .../d16/f ================="
387 test_mkdir -p $DIR/$tdir
388 touch $DIR/$tdir/$tfile
389 ln -s $DIR/$tdir/$tfile $DIR/$tdir/l-exist
391 $CHECKSTAT -l $DIR/$tdir/$tfile $DIR/$tdir/l-exist ||
392 error "$tdir/l-exist not a symlink"
393 $CHECKSTAT -f -t f $DIR/$tdir/l-exist ||
394 error "$tdir/l-exist not referencing a file"
395 rm -f $DIR/$tdir/l-exist
396 $CHECKSTAT -a $DIR/$tdir/l-exist || error "$tdir/l-exist not removed"
398 run_test 17a "symlinks: create, remove (real) =================="
401 test_mkdir -p $DIR/$tdir
402 ln -s no-such-file $DIR/$tdir/l-dangle
404 $CHECKSTAT -l no-such-file $DIR/$tdir/l-dangle ||
405 error "$tdir/l-dangle not referencing no-such-file"
406 $CHECKSTAT -fa $DIR/$tdir/l-dangle ||
407 error "$tdir/l-dangle not referencing non-existent file"
408 rm -f $DIR/$tdir/l-dangle
409 $CHECKSTAT -a $DIR/$tdir/l-dangle || error "$tdir/l-dangle not removed"
411 run_test 17b "symlinks: create, remove (dangling) =============="
413 test_17c() { # bug 3440 - don't save failed open RPC for replay
414 test_mkdir -p $DIR/$tdir
415 ln -s foo $DIR/$tdir/$tfile
416 cat $DIR/$tdir/$tfile && error "opened non-existent symlink" || true
418 run_test 17c "symlinks: open dangling (should return error) ===="
421 test_mkdir -p $DIR/$tdir
422 ln -s foo $DIR/$tdir/$tfile
423 touch $DIR/$tdir/$tfile || error "creating to new symlink"
425 run_test 17d "symlinks: create dangling ========================"
428 test_mkdir -p $DIR/$tdir
429 local foo=$DIR/$tdir/$tfile
430 ln -s $foo $foo || error "create symlink failed"
431 ls -l $foo || error "ls -l failed"
432 ls $foo && error "ls not failed" || true
434 run_test 17e "symlinks: create recursive symlink (should return error) ===="
437 test_mkdir -p $DIR/$tdir
438 ln -s 1234567890/2234567890/3234567890/4234567890 $DIR/$tdir/111
439 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890 $DIR/$tdir/222
440 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890 $DIR/$tdir/333
441 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890/9234567890/a234567890/b234567890 $DIR/$tdir/444
442 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890/9234567890/a234567890/b234567890/c234567890/d234567890/f234567890 $DIR/$tdir/555
443 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890/9234567890/a234567890/b234567890/c234567890/d234567890/f234567890/aaaaaaaaaa/bbbbbbbbbb/cccccccccc/dddddddddd/eeeeeeeeee/ffffffffff/ $DIR/$tdir/666
446 run_test 17f "symlinks: long and very long symlink name ========================"
448 # str_repeat(S, N) generate a string that is string S repeated N times
453 while [ $((n -= 1)) -ge 0 ]; do
459 # Long symlinks and LU-2241
461 test_mkdir -p $DIR/$tdir
462 local TESTS="59 60 61 4094 4095"
464 # Fix for inode size boundary in 2.1.4
465 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.1.4) ] &&
468 # Patch not applied to 2.2 or 2.3 branches
469 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] &&
470 [ $(lustre_version_code $SINGLEMDS) -le $(version_code 2.3.55) ] &&
473 # skip long symlink name for rhel6.5.
474 # rhel6.5 has a limit (PATH_MAX - sizeof(struct filename))
475 grep -q '6.5' /etc/redhat-release &>/dev/null &&
476 TESTS="59 60 61 4062 4063"
479 local SYMNAME=$(str_repeat 'x' $i)
480 ln -s $SYMNAME $DIR/$tdir/f$i || error "failed $i-char symlink"
481 readlink $DIR/$tdir/f$i || error "failed $i-char readlink"
484 run_test 17g "symlinks: really long symlink name and inode boundaries"
486 test_17h() { #bug 17378
487 remote_mds_nodsh && skip "remote MDS with nodsh" && return
488 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
490 test_mkdir -p $DIR/$tdir
491 if [[ $MDSCOUNT -gt 1 ]]; then
492 mdt_idx=$($LFS getdirstripe -i $DIR/$tdir)
496 $SETSTRIPE -c -1 $DIR/$tdir
497 #define OBD_FAIL_MDS_LOV_PREP_CREATE 0x141
498 do_facet mds$((mdt_idx + 1)) lctl set_param fail_loc=0x80000141
499 touch $DIR/$tdir/$tfile || true
501 run_test 17h "create objects: lov_free_memmd() doesn't lbug"
503 test_17i() { #bug 20018
504 remote_mds_nodsh && skip "remote MDS with nodsh" && return
505 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
506 test_mkdir -c1 $DIR/$tdir
507 local foo=$DIR/$tdir/$tfile
509 if [[ $MDSCOUNT -gt 1 ]]; then
510 mdt_idx=$($LFS getdirstripe -i $DIR/$tdir)
514 ln -s $foo $foo || error "create symlink failed"
515 #define OBD_FAIL_MDS_READLINK_EPROTO 0x143
516 do_facet mds$((mdt_idx + 1)) lctl set_param fail_loc=0x80000143
517 ls -l $foo && error "error not detected"
520 run_test 17i "don't panic on short symlink"
522 test_17k() { #bug 22301
523 [[ -z "$(which rsync 2>/dev/null)" ]] &&
524 skip "no rsync command" && return 0
525 rsync --help | grep -q xattr ||
526 skip_env "$(rsync --version | head -n1) does not support xattrs"
527 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return 0
528 test_mkdir -p $DIR/$tdir
529 test_mkdir -p $DIR/$tdir.new
530 touch $DIR/$tdir/$tfile
531 ln -s $DIR/$tdir/$tfile $DIR/$tdir/$tfile.lnk
532 rsync -av -X $DIR/$tdir/ $DIR/$tdir.new ||
533 error "rsync failed with xattrs enabled"
535 run_test 17k "symlinks: rsync with xattrs enabled ========================="
537 test_17l() { # LU-279
538 [[ -z "$(which getfattr 2>/dev/null)" ]] &&
539 skip "no getfattr command" && return 0
540 test_mkdir -p $DIR/$tdir
541 touch $DIR/$tdir/$tfile
542 ln -s $DIR/$tdir/$tfile $DIR/$tdir/$tfile.lnk
543 for path in "$DIR/$tdir" "$DIR/$tdir/$tfile" "$DIR/$tdir/$tfile.lnk"; do
544 # -h to not follow symlinks. -m '' to list all the xattrs.
545 # grep to remove first line: '# file: $path'.
546 for xattr in `getfattr -hm '' $path 2>/dev/null | grep -v '^#'`;
548 lgetxattr_size_check $path $xattr ||
549 error "lgetxattr_size_check $path $xattr failed"
553 run_test 17l "Ensure lgetxattr's returned xattr size is consistent ========"
557 local short_sym="0123456789"
558 local WDIR=$DIR/${tdir}m
565 remote_mds_nodsh && skip "remote MDS with nodsh" && return
566 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] &&
567 [ $(lustre_version_code $SINGLEMDS) -le $(version_code 2.2.93) ] &&
568 skip "MDS 2.2.0-2.2.93 do not NUL-terminate symlinks" && return
570 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
571 skip "only for ldiskfs MDT" && return 0
573 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
577 # create a long symlink file
578 for ((i = 0; i < 4; ++i)); do
579 long_sym=${long_sym}${long_sym}
582 echo "create 512 short and long symlink files under $WDIR"
583 for ((i = 0; i < 256; ++i)); do
584 ln -sf ${long_sym}"a5a5" $WDIR/long-$i
585 ln -sf ${short_sym}"a5a5" $WDIR/short-$i
591 wait_delete_completed
593 echo "recreate the 512 symlink files with a shorter string"
594 for ((i = 0; i < 512; ++i)); do
595 # rewrite the symlink file with a shorter string
596 ln -sf ${long_sym} $WDIR/long-$i
597 ln -sf ${short_sym} $WDIR/short-$i
600 mds_index=$($LFS getstripe -M $WDIR)
601 mds_index=$((mds_index+1))
602 devname=$(mdsdevname $mds_index)
603 cmd="$E2FSCK -fnvd $devname"
605 echo "stop and checking mds${mds_index}: $cmd"
606 # e2fsck should not return error
608 do_facet mds${mds_index} $cmd || rc=$?
610 start mds${mds_index} $devname $MDS_MOUNT_OPTS || error "start failed"
611 df $MOUNT > /dev/null 2>&1
612 [ $rc -ne 0 ] && error "e2fsck should not report error upon "\
613 "short/long symlink MDT: rc=$rc"
616 run_test 17m "run e2fsck against MDT which contains short/long symlink"
618 check_fs_consistency_17n() {
624 # create/unlink in 17n only change 2 MDTs(MDT1/MDT2),
625 # so it only check MDT1/MDT2 instead of all of MDTs.
626 for mdt_index in $(seq 1 2); do
627 devname=$(mdsdevname $mdt_index)
628 cmd="$E2FSCK -fnvd $devname"
630 echo "stop and checking mds${mdt_index}: $cmd"
631 # e2fsck should not return error
633 do_facet mds${mdt_index} $cmd || rc=$?
635 start mds${mdt_index} $devname $MDS_MOUNT_OPTS ||
636 error "mount mds${mdt_index} failed"
637 df $MOUNT > /dev/null 2>&1
638 [ $rc -ne 0 ] && break
646 remote_mds_nodsh && skip "remote MDS with nodsh" && return
647 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] &&
648 [ $(lustre_version_code $SINGLEMDS) -le $(version_code 2.2.93) ] &&
649 skip "MDS 2.2.0-2.2.93 do not NUL-terminate symlinks" && return
651 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
652 skip "only for ldiskfs MDT" && return 0
654 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 2 MDTs" && return
656 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
658 test_mkdir $DIR/$tdir
659 for ((i=0; i<10; i++)); do
660 $LFS mkdir -i1 -c2 $DIR/$tdir/remote_dir_${i} ||
661 error "create remote dir error $i"
662 createmany -o $DIR/$tdir/remote_dir_${i}/f 10 ||
663 error "create files under remote dir failed $i"
666 check_fs_consistency_17n ||
667 error "e2fsck report error after create files under remote dir"
669 for ((i = 0; i < 10; i++)); do
670 rm -rf $DIR/$tdir/remote_dir_${i} ||
671 error "destroy remote dir error $i"
674 check_fs_consistency_17n ||
675 error "e2fsck report error after unlink files under remote dir"
677 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.50) ] &&
678 skip "lustre < 2.4.50 does not support migrate mv " && return
680 for ((i = 0; i < 10; i++)); do
681 mkdir -p $DIR/$tdir/remote_dir_${i}
682 createmany -o $DIR/$tdir/remote_dir_${i}/f 10 ||
683 error "create files under remote dir failed $i"
684 $LFS migrate --mdt-index 1 $DIR/$tdir/remote_dir_${i} ||
685 error "migrate remote dir error $i"
687 check_fs_consistency_17n || error "e2fsck report error after migration"
689 for ((i = 0; i < 10; i++)); do
690 rm -rf $DIR/$tdir/remote_dir_${i} ||
691 error "destroy remote dir error $i"
694 check_fs_consistency_17n || error "e2fsck report error after unlink"
696 run_test 17n "run e2fsck against master/slave MDT which contains remote dir"
699 remote_mds_nodsh && skip "remote MDS with nodsh" && return
700 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.3.64) ] &&
701 skip "Need MDS version at least 2.3.64" && return
703 local WDIR=$DIR/${tdir}o
708 mdt_index=$($LFS getstripe -M $WDIR)
709 mdt_index=$((mdt_index+1))
713 #fail mds will wait the failover finish then set
714 #following fail_loc to avoid interfer the recovery process.
717 #define OBD_FAIL_OSD_LMA_INCOMPAT 0x194
718 do_facet mds${mdt_index} lctl set_param fail_loc=0x194
719 ls -l $WDIR/$tfile && rc=1
720 do_facet mds${mdt_index} lctl set_param fail_loc=0
721 [[ $rc -ne 0 ]] && error "stat file should fail"
724 run_test 17o "stat file with incompat LMA feature"
727 touch $DIR/$tfile || error "Failed to touch $DIR/$tfile: $?"
728 ls $DIR || error "Failed to ls $DIR: $?"
730 run_test 18 "touch .../f ; ls ... =============================="
736 $CHECKSTAT -a $DIR/$tfile || error "$tfile was not removed"
738 run_test 19a "touch .../f19 ; ls -l ... ; rm .../f19 ==========="
741 ls -l $DIR/$tfile && error "ls -l $tfile failed"|| true
743 run_test 19b "ls -l .../f19 (should return error) =============="
746 [ $RUNAS_ID -eq $UID ] &&
747 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
748 $RUNAS touch $DIR/$tfile && error "create non-root file failed" || true
750 run_test 19c "$RUNAS touch .../f19 (should return error) =="
753 cat $DIR/f19 && error || true
755 run_test 19d "cat .../f19 (should return error) =============="
767 $CHECKSTAT -a $DIR/$tfile || error "$tfile was not removed"
769 run_test 20 "touch .../f ; ls -l ... ==========================="
772 test_mkdir -p $DIR/$tdir
773 [ -f $DIR/$tdir/dangle ] && rm -f $DIR/$tdir/dangle
774 ln -s dangle $DIR/$tdir/link
775 echo foo >> $DIR/$tdir/link
776 cat $DIR/$tdir/dangle
777 $CHECKSTAT -t link $DIR/$tdir/link || error "$tdir/link not a link"
778 $CHECKSTAT -f -t file $DIR/$tdir/link ||
779 error "$tdir/link not linked to a file"
781 run_test 21 "write to dangling link ============================"
785 test_mkdir -p $DIR/$tdir
786 chown $RUNAS_ID:$RUNAS_GID $WDIR
787 (cd $WDIR || error "cd $WDIR failed";
788 $RUNAS tar cf - /etc/hosts /etc/sysconfig/network | \
790 ls -lR $WDIR/etc || error "ls -lR $WDIR/etc failed"
791 $CHECKSTAT -t dir $WDIR/etc || error "checkstat -t dir failed"
792 $CHECKSTAT -u \#$RUNAS_ID -g \#$RUNAS_GID $WDIR/etc || error "checkstat -u failed"
794 run_test 22 "unpack tar archive as non-root user ==============="
798 test_mkdir -p $DIR/$tdir
799 local file=$DIR/$tdir/$tfile
801 openfile -f O_CREAT:O_EXCL $file || error "$file create failed"
802 openfile -f O_CREAT:O_EXCL $file &&
803 error "$file recreate succeeded" || true
805 run_test 23a "O_CREAT|O_EXCL in subdir =========================="
807 test_23b() { # bug 18988
808 test_mkdir -p $DIR/$tdir
809 local file=$DIR/$tdir/$tfile
812 echo foo > $file || error "write filed"
813 echo bar >> $file || error "append filed"
814 $CHECKSTAT -s 8 $file || error "wrong size"
817 run_test 23b "O_APPEND check =========================="
821 echo '-- same directory rename'
822 test_mkdir $DIR/$tdir
823 touch $DIR/$tdir/$tfile.1
824 mv $DIR/$tdir/$tfile.1 $DIR/$tdir/$tfile.2
825 $CHECKSTAT -t file $DIR/$tdir/$tfile.2 || error "$tfile.2 not a file"
827 run_test 24a "rename file to non-existent target"
830 test_mkdir $DIR/$tdir
831 touch $DIR/$tdir/$tfile.{1,2}
832 mv $DIR/$tdir/$tfile.1 $DIR/$tdir/$tfile.2
833 $CHECKSTAT -a $DIR/$tdir/$tfile.1 || error "$tfile.1 exists"
834 $CHECKSTAT -t file $DIR/$tdir/$tfile.2 || error "$tfile.2 not a file"
836 run_test 24b "rename file to existing target"
839 test_mkdir $DIR/$tdir
840 test_mkdir $DIR/$tdir/d$testnum.1
841 mv $DIR/$tdir/d$testnum.1 $DIR/$tdir/d$testnum.2
842 $CHECKSTAT -a $DIR/$tdir/d$testnum.1 || error "d$testnum.1 exists"
843 $CHECKSTAT -t dir $DIR/$tdir/d$testnum.2 || error "d$testnum.2 not dir"
845 run_test 24c "rename directory to non-existent target"
848 test_mkdir -c1 $DIR/$tdir
849 test_mkdir -c1 $DIR/$tdir/d$testnum.1
850 test_mkdir -c1 $DIR/$tdir/d$testnum.2
851 mrename $DIR/$tdir/d$testnum.1 $DIR/$tdir/d$testnum.2
852 $CHECKSTAT -a $DIR/$tdir/d$testnum.1 || error "d$testnum.1 exists"
853 $CHECKSTAT -t dir $DIR/$tdir/d$testnum.2 || error "d$testnum.2 not dir"
855 run_test 24d "rename directory to existing target"
858 echo '-- cross directory renames --'
862 mv $DIR/R5a/f $DIR/R5b/g
863 $CHECKSTAT -a $DIR/R5a/f || error
864 $CHECKSTAT -t file $DIR/R5b/g || error
866 run_test 24e "touch .../R5a/f; rename .../R5a/f .../R5b/g ======"
871 touch $DIR/R6a/f $DIR/R6b/g
872 mv $DIR/R6a/f $DIR/R6b/g
873 $CHECKSTAT -a $DIR/R6a/f || error
874 $CHECKSTAT -t file $DIR/R6b/g || error
876 run_test 24f "touch .../R6a/f R6b/g; mv .../R6a/f .../R6b/g ===="
881 test_mkdir $DIR/R7a/d
882 mv $DIR/R7a/d $DIR/R7b/e
883 $CHECKSTAT -a $DIR/R7a/d || error
884 $CHECKSTAT -t dir $DIR/R7b/e || error
886 run_test 24g "mkdir .../R7{a,b}/d; mv .../R7a/d .../R7b/e ======"
889 test_mkdir -c1 $DIR/R8a
890 test_mkdir -c1 $DIR/R8b
891 test_mkdir -c1 $DIR/R8a/d
892 test_mkdir -c1 $DIR/R8b/e
893 mrename $DIR/R8a/d $DIR/R8b/e
894 $CHECKSTAT -a $DIR/R8a/d || error
895 $CHECKSTAT -t dir $DIR/R8b/e || error
897 run_test 24h "mkdir .../R8{a,b}/{d,e}; rename .../R8a/d .../R8b/e"
900 echo "-- rename error cases"
904 mrename $DIR/R9/f $DIR/R9/a
905 $CHECKSTAT -t file $DIR/R9/f || error
906 $CHECKSTAT -t dir $DIR/R9/a || error
907 $CHECKSTAT -a $DIR/R9/a/f || error
909 run_test 24i "rename file to dir error: touch f ; mkdir a ; rename f a"
913 mrename $DIR/R10/f $DIR/R10/g
914 $CHECKSTAT -t dir $DIR/R10 || error
915 $CHECKSTAT -a $DIR/R10/f || error
916 $CHECKSTAT -a $DIR/R10/g || error
918 run_test 24j "source does not exist ============================"
922 test_mkdir $DIR/R11a/d
924 mv $DIR/R11a/f $DIR/R11a/d
925 $CHECKSTAT -a $DIR/R11a/f || error
926 $CHECKSTAT -t file $DIR/R11a/d/f || error
928 run_test 24k "touch .../R11a/f; mv .../R11a/f .../R11a/d ======="
930 # bug 2429 - rename foo foo foo creates invalid file
933 $MULTIOP $f OcNs || error
935 run_test 24l "Renaming a file to itself ========================"
939 $MULTIOP $f OcLN ${f}2 ${f}2 || error "link ${f}2 ${f}2 failed"
940 # on ext3 this does not remove either the source or target files
941 # though the "expected" operation would be to remove the source
942 $CHECKSTAT -t file ${f} || error "${f} missing"
943 $CHECKSTAT -t file ${f}2 || error "${f}2 missing"
945 run_test 24m "Renaming a file to a hard link to itself ========="
949 # this stats the old file after it was renamed, so it should fail
953 $CHECKSTAT ${f}.rename
956 run_test 24n "Statting the old file after renaming (Posix rename 2)"
959 test_mkdir -p $DIR/d24o
960 rename_many -s random -v -n 10 $DIR/d24o
962 run_test 24o "rename of files during htree split ==============="
967 DIRINO=`ls -lid $DIR/R12a | awk '{ print $1 }'`
968 mrename $DIR/R12a $DIR/R12b
969 $CHECKSTAT -a $DIR/R12a || error
970 $CHECKSTAT -t dir $DIR/R12b || error
971 DIRINO2=`ls -lid $DIR/R12b | awk '{ print $1 }'`
972 [ "$DIRINO" = "$DIRINO2" ] || error "R12a $DIRINO != R12b $DIRINO2"
974 run_test 24p "mkdir .../R12{a,b}; rename .../R12a .../R12b"
976 cleanup_multiop_pause() {
982 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
985 local DIRINO=$(ls -lid $DIR/R13a | awk '{ print $1 }')
986 multiop_bg_pause $DIR/R13b D_c || error "multiop failed to start"
989 trap cleanup_multiop_pause EXIT
990 mrename $DIR/R13a $DIR/R13b
991 $CHECKSTAT -a $DIR/R13a || error "R13a still exists"
992 $CHECKSTAT -t dir $DIR/R13b || error "R13b does not exist"
993 local DIRINO2=$(ls -lid $DIR/R13b | awk '{ print $1 }')
994 [ "$DIRINO" = "$DIRINO2" ] || error "R13a $DIRINO != R13b $DIRINO2"
995 cleanup_multiop_pause
996 wait $MULTIPID || error "multiop close failed"
998 run_test 24q "mkdir .../R13{a,b}; open R13b rename R13a R13b ==="
1000 test_24r() { #bug 3789
1001 test_mkdir $DIR/R14a
1002 test_mkdir $DIR/R14a/b
1003 mrename $DIR/R14a $DIR/R14a/b && error "rename to subdir worked!"
1004 $CHECKSTAT -t dir $DIR/R14a || error "$DIR/R14a missing"
1005 $CHECKSTAT -t dir $DIR/R14a/b || error "$DIR/R14a/b missing"
1007 run_test 24r "mkdir .../R14a/b; rename .../R14a .../R14a/b ====="
1010 test_mkdir $DIR/R15a
1011 test_mkdir $DIR/R15a/b
1012 test_mkdir $DIR/R15a/b/c
1013 mrename $DIR/R15a $DIR/R15a/b/c && error "rename to sub-subdir worked!"
1014 $CHECKSTAT -t dir $DIR/R15a || error "$DIR/R15a missing"
1015 $CHECKSTAT -t dir $DIR/R15a/b/c || error "$DIR/R15a/b/c missing"
1017 run_test 24s "mkdir .../R15a/b/c; rename .../R15a .../R15a/b/c ="
1019 test_mkdir $DIR/R16a
1020 test_mkdir $DIR/R16a/b
1021 test_mkdir $DIR/R16a/b/c
1022 mrename $DIR/R16a/b/c $DIR/R16a && error "rename to sub-subdir worked!"
1023 $CHECKSTAT -t dir $DIR/R16a || error "$DIR/R16a missing"
1024 $CHECKSTAT -t dir $DIR/R16a/b/c || error "$DIR/R16a/b/c missing"
1026 run_test 24t "mkdir .../R16a/b/c; rename .../R16a/b/c .../R16a ="
1028 test_24u() { # bug12192
1029 $MULTIOP $DIR/$tfile C2w$((2048 * 1024))c || error
1030 $CHECKSTAT -s $((2048 * 1024)) $DIR/$tfile || error "wrong file size"
1032 run_test 24u "create stripe file"
1038 simple_cleanup_common() {
1041 wait_delete_completed
1044 max_pages_per_rpc() {
1045 $LCTL get_param -n mdc.*.max_pages_per_rpc | head -n1
1049 local NRFILES=100000
1050 local FREE_INODES=$(mdt_free_inodes 0)
1051 [[ $FREE_INODES -lt $NRFILES ]] &&
1052 skip "not enough free inodes $FREE_INODES required $NRFILES" &&
1055 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1056 trap simple_cleanup_common EXIT
1058 # Performance issue on ZFS see LU-4072 (c.f. LU-2887)
1059 [ $(facet_fstype $SINGLEMDS) = "zfs" ] && NRFILES=10000
1061 test_mkdir -p $DIR/$tdir
1062 createmany -m $DIR/$tdir/$tfile $NRFILES
1064 cancel_lru_locks mdc
1065 lctl set_param mdc.*.stats clear
1067 ls $DIR/$tdir >/dev/null || error "error in listing large dir"
1069 # LU-5 large readdir
1070 # DIRENT_SIZE = 32 bytes for sizeof(struct lu_dirent) +
1071 # 8 bytes for name(filename is mostly 5 in this test) +
1072 # 8 bytes for luda_type
1073 # take into account of overhead in lu_dirpage header and end mark in
1074 # each page, plus one in RPC_NUM calculation.
1076 RPC_SIZE=$(($(max_pages_per_rpc) * $(page_size)))
1077 RPC_NUM=$(((NRFILES * DIRENT_SIZE + RPC_SIZE - 1) / RPC_SIZE + 1))
1078 mds_readpage=$(lctl get_param mdc.*MDT0000*.stats |
1079 awk '/^mds_readpage/ {print $2}')
1080 [[ $mds_readpage -gt $RPC_NUM ]] &&
1081 error "large readdir doesn't take effect"
1083 simple_cleanup_common
1085 run_test 24v "list directory with large files (handle hash collision, bug: 17560)"
1087 test_24w() { # bug21506
1089 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=4096 || return 1
1090 dd if=/dev/zero bs=$SZ1 count=1 >> $DIR/$tfile || return 2
1091 dd if=$DIR/$tfile of=$DIR/${tfile}_left bs=1M skip=4097 || return 3
1092 SZ2=`ls -l $DIR/${tfile}_left | awk '{print $5}'`
1093 [[ "$SZ1" -eq "$SZ2" ]] ||
1094 error "Error reading at the end of the file $tfile"
1096 run_test 24w "Reading a file larger than 4Gb"
1099 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 2 MDTs" && return
1100 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1102 local remote_dir=$DIR/$tdir/remote_dir
1104 test_mkdir -p $DIR/$tdir
1105 $LFS mkdir -i $MDTIDX $remote_dir ||
1106 error "create remote directory failed"
1108 test_mkdir -p $DIR/$tdir/src_dir
1109 touch $DIR/$tdir/src_file
1110 test_mkdir -p $remote_dir/tgt_dir
1111 touch $remote_dir/tgt_file
1113 mrename $DIR/$tdir/src_dir $remote_dir/tgt_dir ||
1114 error "rename dir cross MDT failed!"
1116 mrename $DIR/$tdir/src_file $remote_dir/tgt_file ||
1117 error "rename file cross MDT failed!"
1119 touch $DIR/$tdir/ln_file
1120 ln $DIR/$tdir/ln_file $remote_dir/ln_name ||
1121 error "ln file cross MDT failed"
1123 rm -rf $DIR/$tdir || error "Can not delete directories"
1125 run_test 24x "cross MDT rename/link"
1128 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 2 MDTs" && return
1129 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1131 local remote_dir=$DIR/$tdir/remote_dir
1133 test_mkdir -p $DIR/$tdir
1134 $LFS mkdir -i $MDTIDX $remote_dir ||
1135 error "create remote directory failed"
1137 test_mkdir -p $remote_dir/src_dir
1138 touch $remote_dir/src_file
1139 test_mkdir -p $remote_dir/tgt_dir
1140 touch $remote_dir/tgt_file
1142 mrename $remote_dir/src_dir $remote_dir/tgt_dir ||
1143 error "rename subdir in the same remote dir failed!"
1145 mrename $remote_dir/src_file $remote_dir/tgt_file ||
1146 error "rename files in the same remote dir failed!"
1148 ln $remote_dir/tgt_file $remote_dir/tgt_file1 ||
1149 error "link files in the same remote dir failed!"
1151 rm -rf $DIR/$tdir || error "Can not delete directories"
1153 run_test 24y "rename/link on the same dir should succeed"
1155 test_24A() { # LU-3182
1159 test_mkdir -p $DIR/$tdir
1160 createmany -m $DIR/$tdir/$tfile $NFILES
1161 local t=$(ls $DIR/$tdir | wc -l)
1162 local u=$(ls $DIR/$tdir | sort -u | wc -l)
1163 local v=$(ls -ai $DIR/$tdir | sort -u | wc -l)
1164 if [ $t -ne $NFILES -o $u -ne $NFILES -o $v -ne $((NFILES + 2)) ] ; then
1165 error "Expected $NFILES files, got $t ($u unique $v .&..)"
1168 rm -rf $DIR/$tdir || error "Can not delete directories"
1170 run_test 24A "readdir() returns correct number of entries."
1172 test_24B() { # LU-4805
1173 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
1176 test_mkdir $DIR/$tdir
1177 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR/$tdir/striped_dir ||
1178 error "create striped dir failed"
1180 count=$(ls -ai $DIR/$tdir/striped_dir | wc -l)
1181 [ $count -eq 2 ] || error "Expected 2, got $count"
1183 touch $DIR/$tdir/striped_dir/a
1185 count=$(ls -ai $DIR/$tdir/striped_dir | wc -l)
1186 [ $count -eq 3 ] || error "Expected 3, got $count"
1188 touch $DIR/$tdir/striped_dir/.f
1190 count=$(ls -ai $DIR/$tdir/striped_dir | wc -l)
1191 [ $count -eq 4 ] || error "Expected 4, got $count"
1193 rm -rf $DIR/$tdir || error "Can not delete directories"
1195 run_test 24B "readdir for striped dir return correct number of entries"
1198 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
1204 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR/$tdir/d0/striped_dir ||
1205 error "create striped dir failed"
1207 cd $DIR/$tdir/d0/striped_dir
1209 local d0_ino=$(ls -i -l -a $DIR/$tdir | grep "d0" | awk '{print $1}')
1210 local d1_ino=$(ls -i -l -a $DIR/$tdir | grep "d1" | awk '{print $1}')
1211 local parent_ino=$(ls -i -l -a | grep "\.\." | awk '{print $1}')
1213 [ "$d0_ino" = "$parent_ino" ] ||
1214 error ".. wrong, expect $d0_ino, get $parent_ino"
1216 mv $DIR/$tdir/d0/striped_dir $DIR/$tdir/d1/ ||
1217 error "mv striped dir failed"
1219 parent_ino=$(ls -i -l -a | grep "\.\." | awk '{print $1}')
1221 [ "$d1_ino" = "$parent_ino" ] ||
1222 error ".. wrong after mv, expect $d1_ino, get $parent_ino"
1224 run_test 24C "check .. in striped dir"
1226 test_24D() { # LU-6101
1231 createmany -m $DIR/$tdir/$tfile $NFILES
1232 local t=$(ls $DIR/$tdir | wc -l)
1233 local u=$(ls $DIR/$tdir | sort -u | wc -l)
1234 local v=$(ls -ai $DIR/$tdir | sort -u | wc -l)
1235 if [ $t -ne $NFILES -o $u -ne $NFILES -o $v -ne $((NFILES + 2)) ] ; then
1236 error "Expected $NFILES files, got $t ($u unique $v .&..)"
1239 rm -rf $DIR/$tdir || error "Can not delete directories"
1241 run_test 24D "readdir() returns correct number of entries after cursor reload"
1244 [[ $MDSCOUNT -lt 4 ]] && skip "needs >= 4 MDTs" && return
1245 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1248 mkdir $DIR/$tdir/src_dir
1249 $LFS mkdir -i 1 $DIR/$tdir/src_dir/src_child ||
1250 error "create remote source failed"
1252 touch $DIR/$tdir/src_dir/src_child/a
1254 $LFS mkdir -i 2 $DIR/$tdir/tgt_dir ||
1255 error "create remote target dir failed"
1257 $LFS mkdir -i 3 $DIR/$tdir/tgt_dir/tgt_child ||
1258 error "create remote target child failed"
1260 mrename $DIR/$tdir/src_dir/src_child $DIR/$tdir/tgt_dir/tgt_child ||
1261 error "rename dir cross MDT failed!"
1265 $CHECKSTAT -t dir $DIR/$tdir/src_dir/src_child &&
1266 error "src_child still exists after rename"
1268 $CHECKSTAT -t file $DIR/$tdir/tgt_dir/tgt_child/a ||
1269 error "missing file(a) after rename"
1271 rm -rf $DIR/$tdir || error "Can not delete directories"
1273 run_test 24E "cross MDT rename/link"
1276 echo '== symlink sanity ============================================='
1280 touch $DIR/s25/foo || error
1282 run_test 25a "create file in symlinked directory ==============="
1285 [ ! -d $DIR/d25 ] && test_25a
1286 $CHECKSTAT -t file $DIR/s25/foo || error
1288 run_test 25b "lookup file in symlinked directory ==============="
1292 test_mkdir $DIR/d26/d26-2
1293 ln -s d26/d26-2 $DIR/s26
1294 touch $DIR/s26/foo || error
1296 run_test 26a "multiple component symlink ======================="
1299 test_mkdir -p $DIR/d26b/d26-2
1300 ln -s d26b/d26-2/foo $DIR/s26-2
1301 touch $DIR/s26-2 || error
1303 run_test 26b "multiple component symlink at end of lookup ======"
1306 test_mkdir $DIR/d26.2
1307 touch $DIR/d26.2/foo
1308 ln -s d26.2 $DIR/s26.2-1
1309 ln -s s26.2-1 $DIR/s26.2-2
1310 ln -s s26.2-2 $DIR/s26.2-3
1311 chmod 0666 $DIR/s26.2-3/foo
1313 run_test 26c "chain of symlinks ================================"
1315 # recursive symlinks (bug 439)
1317 ln -s d26-3/foo $DIR/d26-3
1319 run_test 26d "create multiple component recursive symlink ======"
1322 [ ! -h $DIR/d26-3 ] && test_26d
1325 run_test 26e "unlink multiple component recursive symlink ======"
1327 # recursive symlinks (bug 7022)
1329 test_mkdir -p $DIR/$tdir
1330 test_mkdir $DIR/$tdir/$tfile || error "mkdir $DIR/$tdir/$tfile failed"
1331 cd $DIR/$tdir/$tfile || error "cd $DIR/$tdir/$tfile failed"
1332 test_mkdir -p lndir/bar1 || error "mkdir lndir/bar1 failed"
1333 test_mkdir $DIR/$tdir/$tfile/$tfile || error "mkdir $tfile failed"
1334 cd $tfile || error "cd $tfile failed"
1335 ln -s .. dotdot || error "ln dotdot failed"
1336 ln -s dotdot/lndir lndir || error "ln lndir failed"
1337 cd $DIR/$tdir || error "cd $DIR/$tdir failed"
1338 output=`ls $tfile/$tfile/lndir/bar1`
1339 [ "$output" = bar1 ] && error "unexpected output"
1340 rm -r $tfile || error "rm $tfile failed"
1341 $CHECKSTAT -a $DIR/$tfile || error "$tfile not gone"
1343 run_test 26f "rm -r of a directory which has recursive symlink ="
1346 echo '== stripe sanity =============================================='
1347 test_mkdir -p $DIR/d27 || error "mkdir failed"
1349 $SETSTRIPE -c 1 $DIR/d27/f0 || error "setstripe failed"
1350 $CHECKSTAT -t file $DIR/d27/f0 || error "checkstat failed"
1351 log "== test_27a: write to one stripe file ========================="
1352 cp /etc/hosts $DIR/d27/f0 || error
1354 run_test 27a "one stripe file =================================="
1357 [[ $OSTCOUNT -lt 2 ]] && skip_env "skipping 2-stripe test" && return
1358 test_mkdir -p $DIR/d27
1359 $SETSTRIPE -c 2 $DIR/d27/f01 || error "setstripe failed"
1360 $GETSTRIPE -c $DIR/d27/f01
1361 [ $($GETSTRIPE -c $DIR/d27/f01) -eq 2 ] ||
1362 error "two-stripe file doesn't have two stripes"
1364 dd if=/dev/zero of=$DIR/d27/f01 bs=4k count=4 || error "dd failed"
1366 run_test 27b "create and write to two stripe file"
1369 test_mkdir -p $DIR/d27
1370 $SETSTRIPE -c 0 -i -1 -S 0 $DIR/d27/fdef || error "setstripe failed"
1371 $CHECKSTAT -t file $DIR/d27/fdef || error "checkstat failed"
1372 dd if=/dev/zero of=$DIR/d27/fdef bs=4k count=4 || error
1374 run_test 27d "create file with default settings ================"
1377 # LU-5839 adds check for existed layout before setting it
1378 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.56) ]] &&
1379 skip "Need MDS version at least 2.7.56" && return
1380 test_mkdir -p $DIR/d27
1381 $SETSTRIPE -c 2 $DIR/d27/f12 || error "setstripe failed"
1382 $SETSTRIPE -c 2 $DIR/d27/f12 && error "setstripe succeeded twice"
1383 $CHECKSTAT -t file $DIR/d27/f12 || error "checkstat failed"
1385 run_test 27e "setstripe existing file (should return error) ======"
1388 test_mkdir $DIR/$tdir
1389 $SETSTRIPE -S 100 -i 0 -c 1 $DIR/$tdir/$tfile &&
1390 error "$SETSTRIPE $DIR/$tdir/$tfile failed"
1391 $CHECKSTAT -t file $DIR/$tdir/$tfile &&
1392 error "$CHECKSTAT -t file $DIR/$tdir/$tfile should fail"
1393 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=4k count=4 || error "dd failed"
1394 $GETSTRIPE $DIR/$tdir/$tfile || error "$GETSTRIPE failed"
1396 run_test 27f "setstripe with bad stripe size (should return error)"
1399 test_mkdir -p $DIR/d27
1400 $MCREATE $DIR/d27/fnone || error "mcreate failed"
1401 $GETSTRIPE $DIR/d27/fnone 2>&1 | grep "no stripe info" ||
1402 error "$DIR/d27/fnone has object"
1404 run_test 27g "$GETSTRIPE with no objects"
1407 test_mkdir $DIR/$tdir
1408 touch $DIR/$tdir/$tfile || error "touch failed"
1409 [[ $($GETSTRIPE -c $DIR/$tdir/$tfile) -gt 0 ]] ||
1410 error "missing objects"
1412 run_test 27i "$GETSTRIPE with some objects"
1415 test_mkdir -p $DIR/d27
1416 $SETSTRIPE -i $OSTCOUNT $DIR/d27/f27j && error "setstripe failed"||true
1418 run_test 27j "setstripe with bad stripe offset (should return error)"
1420 test_27k() { # bug 2844
1421 test_mkdir -p $DIR/d27
1423 LL_MAX_BLKSIZE=$((4 * 1024 * 1024))
1424 [ ! -d $DIR/d27 ] && test_mkdir -p $DIR d27
1425 $SETSTRIPE -S 67108864 $FILE || error "setstripe failed"
1426 BLKSIZE=`stat $FILE | awk '/IO Block:/ { print $7 }'`
1427 [ $BLKSIZE -le $LL_MAX_BLKSIZE ] || error "1:$BLKSIZE > $LL_MAX_BLKSIZE"
1428 dd if=/dev/zero of=$FILE bs=4k count=1
1429 BLKSIZE=`stat $FILE | awk '/IO Block:/ { print $7 }'`
1430 [ $BLKSIZE -le $LL_MAX_BLKSIZE ] || error "2:$BLKSIZE > $LL_MAX_BLKSIZE"
1432 run_test 27k "limit i_blksize for broken user apps ============="
1435 test_mkdir -p $DIR/d27
1436 mcreate $DIR/f27l || error "creating file"
1437 $RUNAS $SETSTRIPE -c 1 $DIR/f27l && \
1438 error "setstripe should have failed" || true
1440 run_test 27l "check setstripe permissions (should return error)"
1443 [[ $OSTCOUNT -lt 2 ]] && skip_env "$OSTCOUNT < 2 OSTs -- skipping" &&
1445 if [[ $ORIGFREE -gt $MAXFREE ]]; then
1446 skip "$ORIGFREE > $MAXFREE skipping out-of-space test on OST0"
1449 trap simple_cleanup_common EXIT
1450 test_mkdir -p $DIR/$tdir
1451 $SETSTRIPE -i 0 -c 1 $DIR/$tdir/f27m_1
1452 dd if=/dev/zero of=$DIR/$tdir/f27m_1 bs=1024 count=$MAXFREE &&
1453 error "dd should fill OST0"
1455 while $SETSTRIPE -i 0 -c 1 $DIR/$tdir/f27m_$i; do
1457 [ $i -gt 256 ] && break
1460 touch $DIR/$tdir/f27m_$i
1461 [ `$GETSTRIPE $DIR/$tdir/f27m_$i | grep -A 10 obdidx | awk '{print $1}'| grep -w "0"` ] &&
1462 error "OST0 was full but new created file still use it"
1464 touch $DIR/$tdir/f27m_$i
1465 [ `$GETSTRIPE $DIR/$tdir/f27m_$i | grep -A 10 obdidx | awk '{print $1}'| grep -w "0"` ] &&
1466 error "OST0 was full but new created file still use it"
1467 simple_cleanup_common
1469 run_test 27m "create file while OST0 was full =================="
1472 local DELAY=$(do_facet $SINGLEMDS lctl get_param -n lov.*.qos_maxage | head -n 1 | awk '{print $1 * 2}')
1476 # OSCs keep a NOSPC flag that will be reset after ~5s (qos_maxage)
1477 # if the OST isn't full anymore.
1479 local OSTIDX=${1:-""}
1481 local list=$(comma_list $(osts_nodes))
1482 [ "$OSTIDX" ] && list=$(facet_host ost$((OSTIDX + 1)))
1484 do_nodes $list lctl set_param fail_loc=0
1485 sync # initiate all OST_DESTROYs from MDS to OST
1489 exhaust_precreations() {
1492 local FAILIDX=${3:-$OSTIDX}
1493 local ofacet=ost$((OSTIDX + 1))
1495 test_mkdir -p -c1 $DIR/$tdir
1496 local mdtidx=$($LFS getstripe -M $DIR/$tdir)
1497 local mfacet=mds$((mdtidx + 1))
1498 echo OSTIDX=$OSTIDX MDTIDX=$mdtidx
1500 local OST=$(ostname_from_index $OSTIDX)
1503 local mdtosc_proc1=$(get_mdtosc_proc_path $mfacet $OST)
1504 local last_id=$(do_facet $mfacet lctl get_param -n \
1505 osc.$mdtosc_proc1.prealloc_last_id)
1506 local next_id=$(do_facet $mfacet lctl get_param -n \
1507 osc.$mdtosc_proc1.prealloc_next_id)
1509 local mdtosc_proc2=$(get_mdtosc_proc_path $mfacet)
1510 do_facet $mfacet lctl get_param osc.$mdtosc_proc2.prealloc*
1512 test_mkdir -p $DIR/$tdir/${OST}
1513 $SETSTRIPE -i $OSTIDX -c 1 $DIR/$tdir/${OST}
1514 #define OBD_FAIL_OST_ENOSPC 0x215
1515 do_facet $ofacet lctl set_param fail_val=$FAILIDX fail_loc=0x215
1516 echo "Creating to objid $last_id on ost $OST..."
1517 createmany -o $DIR/$tdir/${OST}/f $next_id $((last_id - next_id + 2))
1518 do_facet $mfacet lctl get_param osc.$mdtosc_proc2.prealloc*
1519 do_facet $ofacet lctl set_param fail_loc=$FAILLOC
1523 exhaust_all_precreations() {
1525 for (( i=0; i < OSTCOUNT; i++ )) ; do
1526 exhaust_precreations $i $1 -1
1531 [[ $OSTCOUNT -lt 2 ]] && skip_env "too few OSTs" && return
1532 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1533 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1534 remote_ost_nodsh && skip "remote OST with nodsh" && return
1537 rm -f $DIR/$tdir/$tfile
1538 exhaust_precreations 0 0x80000215
1539 $SETSTRIPE -c -1 $DIR/$tdir
1540 touch $DIR/$tdir/$tfile || error
1541 $GETSTRIPE $DIR/$tdir/$tfile
1544 run_test 27n "create file with some full OSTs =================="
1547 [[ $OSTCOUNT -lt 2 ]] && skip_env "too few OSTs" && return
1548 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1549 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1550 remote_ost_nodsh && skip "remote OST with nodsh" && return
1553 rm -f $DIR/$tdir/$tfile
1554 exhaust_all_precreations 0x215
1556 touch $DIR/$tdir/$tfile && error "able to create $DIR/$tdir/$tfile"
1561 run_test 27o "create file with all full OSTs (should error) ===="
1564 [[ $OSTCOUNT -lt 2 ]] && skip_env "too few OSTs" && return
1565 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1566 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1567 remote_ost_nodsh && skip "remote OST with nodsh" && return
1570 rm -f $DIR/$tdir/$tfile
1571 test_mkdir -p $DIR/$tdir
1573 $MCREATE $DIR/$tdir/$tfile || error "mcreate failed"
1574 $TRUNCATE $DIR/$tdir/$tfile 80000000 || error "truncate failed"
1575 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat failed"
1577 exhaust_precreations 0 0x80000215
1578 echo foo >> $DIR/$tdir/$tfile || error "append failed"
1579 $CHECKSTAT -s 80000004 $DIR/$tdir/$tfile || error "checkstat failed"
1580 $GETSTRIPE $DIR/$tdir/$tfile
1584 run_test 27p "append to a truncated file with some full OSTs ==="
1587 [[ $OSTCOUNT -lt 2 ]] && skip_env "too few OSTs" && return
1588 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1589 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1590 remote_ost_nodsh && skip "remote OST with nodsh" && return
1593 rm -f $DIR/$tdir/$tfile
1595 test_mkdir -p $DIR/$tdir
1596 $MCREATE $DIR/$tdir/$tfile || error "mcreate $DIR/$tdir/$tfile failed"
1597 $TRUNCATE $DIR/$tdir/$tfile 80000000 ||error "truncate $DIR/$tdir/$tfile failed"
1598 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat failed"
1600 exhaust_all_precreations 0x215
1602 echo foo >> $DIR/$tdir/$tfile && error "append succeeded"
1603 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat 2 failed"
1607 run_test 27q "append to truncated file with all OSTs full (should error) ==="
1610 [[ $OSTCOUNT -lt 2 ]] && skip_env "too few OSTs" && return
1611 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1612 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1613 remote_ost_nodsh && skip "remote OST with nodsh" && return
1616 rm -f $DIR/$tdir/$tfile
1617 exhaust_precreations 0 0x80000215
1619 $SETSTRIPE -i 0 -c 2 $DIR/$tdir/$tfile # && error
1623 run_test 27r "stripe file with some full OSTs (shouldn't LBUG) ="
1625 test_27s() { # bug 10725
1626 test_mkdir -p $DIR/$tdir
1627 local stripe_size=$((4096 * 1024 * 1024)) # 2^32
1628 local stripe_count=0
1629 [ $OSTCOUNT -eq 1 ] || stripe_count=2
1630 $SETSTRIPE -S $stripe_size -c $stripe_count $DIR/$tdir &&
1631 error "stripe width >= 2^32 succeeded" || true
1634 run_test 27s "lsm_xfersize overflow (should error) (bug 10725)"
1636 test_27t() { # bug 10864
1641 $WLFS getstripe $tfile
1644 run_test 27t "check that utils parse path correctly"
1646 test_27u() { # bug 4900
1647 [[ $OSTCOUNT -lt 2 ]] && skip_env "too few OSTs" && return
1648 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1650 local list=$(comma_list $(mdts_nodes))
1652 #define OBD_FAIL_MDS_OSC_PRECREATE 0x139
1653 do_nodes $list $LCTL set_param fail_loc=0x139
1654 test_mkdir -p $DIR/$tdir
1656 createmany -o $DIR/$tdir/t- 1000
1657 do_nodes $list $LCTL set_param fail_loc=0
1659 TLOG=$DIR/$tfile.getstripe
1660 $GETSTRIPE $DIR/$tdir > $TLOG
1661 OBJS=$(awk -vobj=0 '($1 == 0) { obj += 1 } END { print obj; }' $TLOG)
1662 unlinkmany $DIR/$tdir/t- 1000
1663 [[ $OBJS -gt 0 ]] &&
1664 error "$OBJS objects created on OST-0. See $TLOG" || pass
1666 run_test 27u "skip object creation on OSC w/o objects =========="
1668 test_27v() { # bug 4900
1669 [[ $OSTCOUNT -lt 2 ]] && skip_env "too few OSTs" && return
1670 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1671 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1672 remote_ost_nodsh && skip "remote OST with nodsh" && return
1674 exhaust_all_precreations 0x215
1677 test_mkdir -p $DIR/$tdir
1678 $SETSTRIPE -c 1 $DIR/$tdir # 1 stripe / file
1680 touch $DIR/$tdir/$tfile
1681 #define OBD_FAIL_TGT_DELAY_PRECREATE 0x705
1683 for (( i=1; i < OSTCOUNT; i++ )); do
1684 do_facet ost$i lctl set_param fail_loc=0x705
1686 local START=`date +%s`
1687 createmany -o $DIR/$tdir/$tfile 32
1689 local FINISH=`date +%s`
1690 local TIMEOUT=`lctl get_param -n timeout`
1691 local PROCESS=$((FINISH - START))
1692 [ $PROCESS -ge $((TIMEOUT / 2)) ] && \
1693 error "$FINISH - $START >= $TIMEOUT / 2"
1694 sleep $((TIMEOUT / 2 - PROCESS))
1697 run_test 27v "skip object creation on slow OST ================="
1699 test_27w() { # bug 10997
1700 test_mkdir -p $DIR/$tdir || error "mkdir failed"
1701 $SETSTRIPE -S 65536 $DIR/$tdir/f0 || error "setstripe failed"
1702 [ $($GETSTRIPE -S $DIR/$tdir/f0) -ne 65536 ] &&
1703 error "stripe size $size != 65536" || true
1704 [ $($GETSTRIPE -d $DIR/$tdir | grep -c "stripe_count") -ne 1 ] &&
1705 error "$GETSTRIPE -d $DIR/$tdir failed" || true
1707 run_test 27w "check $SETSTRIPE -S option"
1710 [[ $OSTCOUNT -lt 2 ]] &&
1711 skip_env "skipping multiple stripe count/offset test" && return
1713 test_mkdir -p $DIR/$tdir || error "mkdir failed"
1714 for i in $(seq 1 $OSTCOUNT); do
1716 $SETSTRIPE -c $i -i $offset $DIR/$tdir/f$i ||
1717 error "setstripe -c $i -i $offset failed"
1718 count=$($GETSTRIPE -c $DIR/$tdir/f$i)
1719 index=$($GETSTRIPE -i $DIR/$tdir/f$i)
1720 [ $count -ne $i ] && error "stripe count $count != $i" || true
1721 [ $index -ne $offset ] &&
1722 error "stripe offset $index != $offset" || true
1725 run_test 27wa "check $SETSTRIPE -c -i options"
1728 remote_ost_nodsh && skip "remote OST with nodsh" && return
1729 [[ $OSTCOUNT -lt 2 ]] && skip_env "$OSTCOUNT < 2 OSTs" && return
1730 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1731 OFFSET=$(($OSTCOUNT - 1))
1733 local OST=$(ostname_from_index $OSTIDX)
1735 test_mkdir -p $DIR/$tdir
1736 $SETSTRIPE -c 1 $DIR/$tdir # 1 stripe per file
1737 do_facet ost$((OSTIDX + 1)) lctl set_param -n obdfilter.$OST.degraded 1
1739 createmany -o $DIR/$tdir/$tfile $OSTCOUNT
1740 for i in `seq 0 $OFFSET`; do
1741 [ `$GETSTRIPE $DIR/$tdir/$tfile$i | grep -A 10 obdidx | awk '{print $1}' | grep -w "$OSTIDX"` ] &&
1742 error "OST0 was degraded but new created file still use it"
1744 do_facet ost$((OSTIDX + 1)) lctl set_param -n obdfilter.$OST.degraded 0
1746 run_test 27x "create files while OST0 is degraded"
1749 [[ $OSTCOUNT -lt 2 ]] &&
1750 skip_env "$OSTCOUNT < 2 OSTs -- skipping" && return
1751 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1752 remote_ost_nodsh && skip "remote OST with nodsh" && return
1753 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1755 local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS $FSNAME-OST0000)
1756 local last_id=$(do_facet $SINGLEMDS lctl get_param -n \
1757 osc.$mdtosc.prealloc_last_id)
1758 local next_id=$(do_facet $SINGLEMDS lctl get_param -n \
1759 osc.$mdtosc.prealloc_next_id)
1760 local fcount=$((last_id - next_id))
1761 [[ $fcount -eq 0 ]] && skip "not enough space on OST0" && return
1762 [[ $fcount -gt $OSTCOUNT ]] && fcount=$OSTCOUNT
1764 local MDS_OSCS=$(do_facet $SINGLEMDS lctl dl |
1765 awk '/[oO][sS][cC].*md[ts]/ { print $4 }')
1766 local OST_DEACTIVE_IDX=-1
1771 for OSC in $MDS_OSCS; do
1772 OST=$(osc_to_ost $OSC)
1773 OSTIDX=$(index_from_ostuuid $OST)
1774 if [ $OST_DEACTIVE_IDX == -1 ]; then
1775 OST_DEACTIVE_IDX=$OSTIDX
1777 if [ $OSTIDX != $OST_DEACTIVE_IDX ]; then
1778 echo $OSC "is Deactivated:"
1779 do_facet $SINGLEMDS lctl --device %$OSC deactivate
1783 OSTIDX=$(index_from_ostuuid $OST)
1784 test_mkdir -p $DIR/$tdir
1785 $SETSTRIPE -c 1 $DIR/$tdir # 1 stripe / file
1787 for OSC in $MDS_OSCS; do
1788 OST=$(osc_to_ost $OSC)
1789 OSTIDX=$(index_from_ostuuid $OST)
1790 if [ $OSTIDX == $OST_DEACTIVE_IDX ]; then
1791 echo $OST "is degraded:"
1792 do_facet ost$((OSTIDX+1)) lctl set_param -n \
1793 obdfilter.$OST.degraded=1
1798 createmany -o $DIR/$tdir/$tfile $fcount
1800 for OSC in $MDS_OSCS; do
1801 OST=$(osc_to_ost $OSC)
1802 OSTIDX=$(index_from_ostuuid $OST)
1803 if [ $OSTIDX == $OST_DEACTIVE_IDX ]; then
1804 echo $OST "is recovered from degraded:"
1805 do_facet ost$((OSTIDX+1)) lctl set_param -n \
1806 obdfilter.$OST.degraded=0
1808 do_facet $SINGLEMDS lctl --device %$OSC activate
1812 # all osp devices get activated, hence -1 stripe count restored
1815 # sleep 2*lod_qos_maxage seconds waiting for lod qos to notice osp
1816 # devices get activated.
1818 $SETSTRIPE -c -1 $DIR/$tfile
1819 stripecnt=$($GETSTRIPE -c $DIR/$tfile)
1821 [ $stripecnt -ne $OSTCOUNT ] &&
1822 error "Of $OSTCOUNT OSTs, only $stripecnt is available"
1825 run_test 27y "create files while OST0 is degraded and the rest inactive"
1831 lmm_count=$($GETSTRIPE -c $1)
1832 lmm_seq=$($GETSTRIPE -v $1 | awk '/lmm_seq/ { print $2 }')
1833 lmm_oid=$($GETSTRIPE -v $1 | awk '/lmm_object_id/ { print $2 }')
1835 local old_ifs="$IFS"
1837 fid=($($LFS path2fid $1))
1840 log "FID seq ${fid[1]}, oid ${fid[2]} ver ${fid[3]}"
1841 log "LOV seq $lmm_seq, oid $lmm_oid, count: $lmm_count"
1843 # compare lmm_seq and lu_fid->f_seq
1844 [ $lmm_seq = ${fid[1]} ] || { error "SEQ mismatch"; return 1; }
1845 # compare lmm_object_id and lu_fid->oid
1846 [ $lmm_oid = ${fid[2]} ] || { error "OID mismatch"; return 2; }
1848 # check the trusted.fid attribute of the OST objects of the file
1849 local have_obdidx=false
1851 $GETSTRIPE $1 | while read obdidx oid hex seq; do
1852 # skip lines up to and including "obdidx"
1853 [ -z "$obdidx" ] && break
1854 [ "$obdidx" = "obdidx" ] && have_obdidx=true && continue
1855 $have_obdidx || continue
1857 local ost=$((obdidx + 1))
1858 local dev=$(ostdevname $ost)
1861 log "want: stripe:$stripe_nr ost:$obdidx oid:$oid/$hex seq:$seq"
1863 seq=$(echo $seq | sed -e "s/^0x//g")
1864 if [ $seq == 0 ] || [ $(facet_fstype ost$ost) == zfs ]; then
1865 oid_hex=$(echo $oid)
1867 oid_hex=$(echo $hex | sed -e "s/^0x//g")
1869 local obj_file="O/$seq/d$((oid %32))/$oid_hex"
1873 # Don't unmount/remount the OSTs if we don't need to do that.
1874 # LU-2577 changes filter_fid to be smaller, so debugfs needs
1875 # update too, until that use mount/ll_decode_filter_fid/mount.
1876 # Re-enable when debugfs will understand new filter_fid.
1878 if false && [ $(facet_fstype ost$ost) == ldiskfs ]; then
1879 ff=$(do_facet ost$ost "$DEBUGFS -c -R 'stat $obj_file' \
1880 $dev 2>/dev/null" | grep "parent=")
1883 mount_fstype ost$ost
1884 ff=$(do_facet ost$ost $LL_DECODE_FILTER_FID \
1885 $(facet_mntpt ost$ost)/$obj_file)
1886 unmount_fstype ost$ost
1887 start ost$ost $dev $OST_MOUNT_OPTS
1890 [ -z "$ff" ] && error "$obj_file: no filter_fid info"
1892 echo "$ff" | sed -e 's#.*objid=#got: objid=#'
1894 # /mnt/O/0/d23/23: objid=23 seq=0 parent=[0x200000400:0x1e:0x1]
1895 # fid: objid=23 seq=0 parent=[0x200000400:0x1e:0x0] stripe=1
1896 local ff_parent=$(echo $ff|sed -e 's/.*parent=.//')
1897 local ff_pseq=$(echo $ff_parent | cut -d: -f1)
1898 local ff_poid=$(echo $ff_parent | cut -d: -f2)
1900 if echo $ff_parent | grep -q 'stripe='; then
1901 ff_pstripe=$(echo $ff_parent | sed -e 's/.*stripe=//')
1904 # $LL_DECODE_FILTER_FID does not print "stripe="; look
1905 # into f_ver in this case. See the comment on
1908 ff_pstripe=$(echo $ff_parent | cut -d: -f3 |
1912 # compare lmm_seq and filter_fid->ff_parent.f_seq
1913 [ $ff_pseq = $lmm_seq ] ||
1914 error "FF parent SEQ $ff_pseq != $lmm_seq"
1915 # compare lmm_object_id and filter_fid->ff_parent.f_oid
1916 [ $ff_poid = $lmm_oid ] ||
1917 error "FF parent OID $ff_poid != $lmm_oid"
1918 (($ff_pstripe == $stripe_nr)) ||
1919 error "FF stripe $ff_pstripe != $stripe_nr"
1921 stripe_nr=$((stripe_nr + 1))
1926 remote_ost_nodsh && skip "remote OST with nodsh" && return
1927 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1928 test_mkdir -p $DIR/$tdir
1930 $SETSTRIPE -c 1 -i 0 -S 64k $DIR/$tdir/$tfile-1 ||
1931 { error "setstripe -c -1 failed"; return 1; }
1932 # We need to send a write to every object to get parent FID info set.
1933 # This _should_ also work for setattr, but does not currently.
1934 # touch $DIR/$tdir/$tfile-1 ||
1935 dd if=/dev/zero of=$DIR/$tdir/$tfile-1 bs=1M count=1 ||
1936 { error "dd $tfile-1 failed"; return 2; }
1937 $SETSTRIPE -c -1 -i $((OSTCOUNT - 1)) -S 1M $DIR/$tdir/$tfile-2 ||
1938 { error "setstripe -c -1 failed"; return 3; }
1939 dd if=/dev/zero of=$DIR/$tdir/$tfile-2 bs=1M count=$OSTCOUNT ||
1940 { error "dd $tfile-2 failed"; return 4; }
1942 # make sure write RPCs have been sent to OSTs
1945 check_seq_oid $DIR/$tdir/$tfile-1 || return 5
1946 check_seq_oid $DIR/$tdir/$tfile-2 || return 6
1948 run_test 27z "check SEQ/OID on the MDT and OST filesystems"
1950 test_27A() { # b=19102
1951 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1952 local restore_size=$($GETSTRIPE -S $MOUNT)
1953 local restore_count=$($GETSTRIPE -c $MOUNT)
1954 local restore_offset=$($GETSTRIPE -i $MOUNT)
1955 $SETSTRIPE -c 0 -i -1 -S 0 $MOUNT
1956 wait_update $HOSTNAME "$GETSTRIPE -c $MOUNT | sed 's/ *//g'" "1" 20 ||
1957 error "stripe count $($GETSTRIPE -c $MOUNT) != 1"
1958 local default_size=$($GETSTRIPE -S $MOUNT)
1959 local default_offset=$($GETSTRIPE -i $MOUNT)
1960 local dsize=$((1024 * 1024))
1961 [ $default_size -eq $dsize ] ||
1962 error "stripe size $default_size != $dsize"
1963 [ $default_offset -eq -1 ] ||error "stripe offset $default_offset != -1"
1964 $SETSTRIPE -c $restore_count -i $restore_offset -S $restore_size $MOUNT
1966 run_test 27A "check filesystem-wide default LOV EA values"
1968 test_27B() { # LU-2523
1969 test_mkdir -p $DIR/$tdir
1970 rm -f $DIR/$tdir/f0 $DIR/$tdir/f1
1972 # open f1 with O_LOV_DELAY_CREATE
1974 # call setstripe ioctl on open file descriptor for f1
1976 multiop $DIR/$tdir/f1 oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:nB1c \
1980 # open f1 with O_LOV_DELAY_CREATE
1982 # call setstripe ioctl on open file descriptor for f1
1984 multiop $DIR/$tdir/f1 oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:uB1c
1986 # Allow multiop to fail in imitation of NFS's busted semantics.
1989 run_test 27B "call setstripe on open unlinked file/rename victim"
1991 test_27C() { #LU-2871
1992 [[ $OSTCOUNT -lt 2 ]] && skip "needs >= 2 OSTs" && return
2000 test_mkdir -p $DIR/$tdir
2002 for i in $(seq 0 $((OSTCOUNT - 1))); do
2003 # set stripe across all OSTs starting from OST$i
2004 $SETSTRIPE -i $i -c -1 $tfile$i
2005 # get striping information
2006 ost_idx=($($GETSTRIPE $tfile$i |
2007 tail -n $((OSTCOUNT + 1)) | awk '{print $1}'))
2011 [ ${#ost_idx[@]} -eq $OSTCOUNT ] ||
2012 error "${#ost_idx[@]} != $OSTCOUNT"
2014 for index in $(seq 0 $((OSTCOUNT - 1))); do
2016 for j in $(echo ${ost_idx[@]}); do
2017 if [ $index -eq $j ]; then
2023 error "Can not find $index in ${ost_idx[@]}"
2027 run_test 27C "check full striping across all OSTs"
2030 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs" && return
2031 local POOL=${POOL:-testpool}
2033 local last_ost=$(($OSTCOUNT - 1))
2035 local ost_list=$(seq $first_ost $ost_step $last_ost)
2036 local ost_range="$first_ost $last_ost $ost_step"
2038 test_mkdir -p $DIR/$tdir
2039 pool_add $POOL || error "pool_add failed"
2040 pool_add_targets $POOL $ost_range || error "pool_add_targets failed"
2041 llapi_layout_test -d$DIR/$tdir -p$POOL -o$OSTCOUNT ||
2042 error "llapi_layout_test failed"
2043 cleanup_pools || error "cleanup_pools failed"
2045 run_test 27D "validate llapi_layout API"
2047 # Verify that default_easize is increased from its initial value after
2048 # accessing a widely striped file.
2050 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs" && return
2052 # 72 bytes is the minimum space required to store striping
2053 # information for a file striped across one OST:
2054 # (sizeof(struct lov_user_md_v3) +
2055 # sizeof(struct lov_user_ost_data_v1))
2057 $LCTL set_param -n llite.*.default_easize $min_easize ||
2058 error "lctl set_param failed"
2059 local easize=$($LCTL get_param -n llite.*.default_easize)
2061 [ $easize -eq $min_easize ] ||
2062 error "failed to set default_easize"
2064 $LFS setstripe -c $OSTCOUNT $DIR/$tfile ||
2065 error "setstripe failed"
2069 easize=$($LCTL get_param -n llite.*.default_easize)
2071 [ $easize -gt $min_easize ] ||
2072 error "default_easize not updated"
2074 run_test 27E "check that default extended attribute size properly increases"
2076 # createtest also checks that device nodes are created and
2077 # then visible correctly (#2091)
2078 test_28() { # bug 2091
2080 $CREATETEST $DIR/d28/ct || error
2082 run_test 28 "create/mknod/mkdir with bad file types ============"
2085 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2086 cancel_lru_locks mdc
2092 declare -i LOCKCOUNTORIG=0
2093 for lock_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_count); do
2094 let LOCKCOUNTORIG=$LOCKCOUNTORIG+$lock_count
2096 [ $LOCKCOUNTORIG -eq 0 ] && echo "No mdc lock count" && return 1
2098 declare -i LOCKUNUSEDCOUNTORIG=0
2099 for unused_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_unused_count); do
2100 let LOCKUNUSEDCOUNTORIG=$LOCKUNUSEDCOUNTORIG+$unused_count
2107 declare -i LOCKCOUNTCURRENT=0
2108 for lock_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_count); do
2109 let LOCKCOUNTCURRENT=$LOCKCOUNTCURRENT+$lock_count
2112 declare -i LOCKUNUSEDCOUNTCURRENT=0
2113 for unused_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_unused_count); do
2114 let LOCKUNUSEDCOUNTCURRENT=$LOCKUNUSEDCOUNTCURRENT+$unused_count
2117 if [[ $LOCKCOUNTCURRENT -gt $LOCKCOUNTORIG ]]; then
2118 $LCTL set_param -n ldlm.dump_namespaces ""
2119 error "CURRENT: $LOCKCOUNTCURRENT > $LOCKCOUNTORIG"
2120 $LCTL dk | sort -k4 -t: > $TMP/test_29.dk
2121 log "dumped log to $TMP/test_29.dk (bug 5793)"
2124 if [[ $LOCKUNUSEDCOUNTCURRENT -gt $LOCKUNUSEDCOUNTORIG ]]; then
2125 error "UNUSED: $LOCKUNUSEDCOUNTCURRENT > $LOCKUNUSEDCOUNTORIG"
2126 $LCTL dk | sort -k4 -t: > $TMP/test_29.dk
2127 log "dumped log to $TMP/test_29.dk (bug 5793)"
2131 run_test 29 "IT_GETATTR regression ============================"
2133 test_30a() { # was test_30
2134 cp $(which ls) $DIR || cp /bin/ls $DIR
2138 run_test 30a "execute binary from Lustre (execve) =============="
2141 cp `which ls` $DIR || cp /bin/ls $DIR
2143 $RUNAS $DIR/ls / || error
2146 run_test 30b "execute binary from Lustre as non-root ==========="
2148 test_30c() { # b=22376
2149 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2150 cp `which ls` $DIR || cp /bin/ls $DIR
2152 cancel_lru_locks mdc
2153 cancel_lru_locks osc
2154 $RUNAS $DIR/ls / || error
2157 run_test 30c "execute binary from Lustre without read perms ===="
2160 $OPENUNLINK $DIR/f31 $DIR/f31 || error
2161 $CHECKSTAT -a $DIR/f31 || error
2163 run_test 31a "open-unlink file =================================="
2166 touch $DIR/f31 || error
2167 ln $DIR/f31 $DIR/f31b || error
2168 $MULTIOP $DIR/f31b Ouc || error
2169 $CHECKSTAT -t file $DIR/f31 || error
2171 run_test 31b "unlink file with multiple links while open ======="
2174 touch $DIR/f31 || error
2175 ln $DIR/f31 $DIR/f31c || error
2176 multiop_bg_pause $DIR/f31 O_uc || return 1
2178 $MULTIOP $DIR/f31c Ouc
2179 kill -USR1 $MULTIPID
2182 run_test 31c "open-unlink file with multiple links ============="
2185 opendirunlink $DIR/d31d $DIR/d31d || error
2186 $CHECKSTAT -a $DIR/d31d || error
2188 run_test 31d "remove of open directory ========================="
2190 test_31e() { # bug 2904
2191 openfilleddirunlink $DIR/d31e || error
2193 run_test 31e "remove of open non-empty directory ==============="
2195 test_31f() { # bug 4554
2196 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2198 test_mkdir $DIR/d31f
2199 $SETSTRIPE -S 1048576 -c 1 $DIR/d31f
2200 cp /etc/hosts $DIR/d31f
2202 $GETSTRIPE $DIR/d31f/hosts
2203 multiop_bg_pause $DIR/d31f D_c || return 1
2206 rm -rv $DIR/d31f || error "first of $DIR/d31f"
2207 test_mkdir $DIR/d31f
2208 $SETSTRIPE -S 1048576 -c 1 $DIR/d31f
2209 cp /etc/hosts $DIR/d31f
2211 $GETSTRIPE $DIR/d31f/hosts
2212 multiop_bg_pause $DIR/d31f D_c || return 1
2215 kill -USR1 $MULTIPID || error "first opendir $MULTIPID not running"
2216 wait $MULTIPID || error "first opendir $MULTIPID failed"
2220 kill -USR1 $MULTIPID2 || error "second opendir $MULTIPID not running"
2221 wait $MULTIPID2 || error "second opendir $MULTIPID2 failed"
2224 run_test 31f "remove of open directory with open-unlink file ==="
2227 echo "-- cross directory link --"
2228 test_mkdir -c1 $DIR/${tdir}ga
2229 test_mkdir -c1 $DIR/${tdir}gb
2230 touch $DIR/${tdir}ga/f
2231 ln $DIR/${tdir}ga/f $DIR/${tdir}gb/g
2232 $CHECKSTAT -t file $DIR/${tdir}ga/f || error "source"
2233 [ `stat -c%h $DIR/${tdir}ga/f` == '2' ] || error "source nlink"
2234 $CHECKSTAT -t file $DIR/${tdir}gb/g || error "target"
2235 [ `stat -c%h $DIR/${tdir}gb/g` == '2' ] || error "target nlink"
2237 run_test 31g "cross directory link==============="
2240 echo "-- cross directory link --"
2241 test_mkdir -c1 $DIR/${tdir}
2242 test_mkdir -c1 $DIR/${tdir}/dir
2243 touch $DIR/${tdir}/f
2244 ln $DIR/${tdir}/f $DIR/${tdir}/dir/g
2245 $CHECKSTAT -t file $DIR/${tdir}/f || error "source"
2246 [ `stat -c%h $DIR/${tdir}/f` == '2' ] || error "source nlink"
2247 $CHECKSTAT -t file $DIR/${tdir}/dir/g || error "target"
2248 [ `stat -c%h $DIR/${tdir}/dir/g` == '2' ] || error "target nlink"
2250 run_test 31h "cross directory link under child==============="
2253 echo "-- cross directory link --"
2254 test_mkdir -c1 $DIR/$tdir
2255 test_mkdir -c1 $DIR/$tdir/dir
2256 touch $DIR/$tdir/dir/f
2257 ln $DIR/$tdir/dir/f $DIR/$tdir/g
2258 $CHECKSTAT -t file $DIR/$tdir/dir/f || error "source"
2259 [ `stat -c%h $DIR/$tdir/dir/f` == '2' ] || error "source nlink"
2260 $CHECKSTAT -t file $DIR/$tdir/g || error "target"
2261 [ `stat -c%h $DIR/$tdir/g` == '2' ] || error "target nlink"
2263 run_test 31i "cross directory link under parent==============="
2266 test_mkdir -c1 -p $DIR/$tdir
2267 test_mkdir -c1 -p $DIR/$tdir/dir1
2268 ln $DIR/$tdir/dir1 $DIR/$tdir/dir2 && error "ln for dir"
2269 link $DIR/$tdir/dir1 $DIR/$tdir/dir3 && error "link for dir"
2270 mlink $DIR/$tdir/dir1 $DIR/$tdir/dir4 && error "mlink for dir"
2271 mlink $DIR/$tdir/dir1 $DIR/$tdir/dir1 && error "mlink to the same dir"
2274 run_test 31j "link for directory==============="
2277 test_mkdir -c1 -p $DIR/$tdir
2279 touch $DIR/$tdir/exist
2280 mlink $DIR/$tdir/s $DIR/$tdir/t || error "mlink"
2281 mlink $DIR/$tdir/s $DIR/$tdir/exist && error "mlink to exist file"
2282 mlink $DIR/$tdir/s $DIR/$tdir/s && error "mlink to the same file"
2283 mlink $DIR/$tdir/s $DIR/$tdir && error "mlink to parent dir"
2284 mlink $DIR/$tdir $DIR/$tdir/s && error "mlink parent dir to target"
2285 mlink $DIR/$tdir/not-exist $DIR/$tdir/foo && error "mlink non-existing to new"
2286 mlink $DIR/$tdir/not-exist $DIR/$tdir/s && error "mlink non-existing to exist"
2289 run_test 31k "link to file: the same, non-existing, dir==============="
2295 touch $DIR/d31m2/exist
2296 mlink $DIR/d31m/s $DIR/d31m2/t || error "mlink"
2297 mlink $DIR/d31m/s $DIR/d31m2/exist && error "mlink to exist file"
2298 mlink $DIR/d31m/s $DIR/d31m2 && error "mlink to parent dir"
2299 mlink $DIR/d31m2 $DIR/d31m/s && error "mlink parent dir to target"
2300 mlink $DIR/d31m/not-exist $DIR/d31m2/foo && error "mlink non-existing to new"
2301 mlink $DIR/d31m/not-exist $DIR/d31m2/s && error "mlink non-existing to exist"
2304 run_test 31m "link to file: the same, non-existing, dir==============="
2307 touch $DIR/$tfile || error "cannot create '$DIR/$tfile'"
2308 nlink=$(stat --format=%h $DIR/$tfile)
2309 [ ${nlink:--1} -eq 1 ] || error "nlink is $nlink, expected 1"
2311 local cmd="exec $fd<$DIR/$tfile"
2314 trap "eval $cmd" EXIT
2315 nlink=$(stat --dereference --format=%h /proc/self/fd/$fd)
2316 [ ${nlink:--1} -eq 1 ] || error "nlink is $nlink, expected 1"
2317 rm $DIR/$tfile || error "cannot remove '$DIR/$tfile'"
2318 nlink=$(stat --dereference --format=%h /proc/self/fd/$fd)
2319 [ ${nlink:--1} -eq 0 ] || error "nlink is $nlink, expected 0"
2322 run_test 31n "check link count of unlinked file"
2325 local TEMPNAME=$(mktemp $1_XXXXXX)
2326 mlink $TEMPNAME $1 2> /dev/null &&
2327 echo "$BASHPID: link $TEMPNAME to $1 succeeded"
2331 test_31o() { # LU-2901
2332 test_mkdir -p $DIR/$tdir
2333 for LOOP in $(seq 100); do
2334 rm -f $DIR/$tdir/$tfile*
2335 for THREAD in $(seq 8); do
2336 link_one $DIR/$tdir/$tfile.$LOOP &
2339 local LINKS=$(ls -1 $DIR/$tdir | grep -c $tfile.$LOOP)
2340 [[ $LINKS -gt 1 ]] && ls $DIR/$tdir &&
2341 error "$LINKS duplicate links to $tfile.$LOOP" &&
2345 run_test 31o "duplicate hard links with same filename"
2348 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2350 test_mkdir $DIR/$tdir
2351 $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
2352 $LFS setdirstripe -D -c2 -t all_char $DIR/$tdir/striped_dir
2354 opendirunlink $DIR/$tdir/striped_dir/test1 ||
2355 error "open unlink test1 failed"
2356 opendirunlink $DIR/$tdir/striped_dir/test2 ||
2357 error "open unlink test2 failed"
2359 $CHECKSTAT -a $DIR/$tdir/striped_dir/test1 ||
2360 error "test1 still exists"
2361 $CHECKSTAT -a $DIR/$tdir/striped_dir/test2 ||
2362 error "test2 still exists"
2364 run_test 31p "remove of open striped directory"
2366 cleanup_test32_mount() {
2368 $UMOUNT $DIR/$tdir/ext2-mountpoint
2372 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2373 echo "== more mountpoints and symlinks ================="
2374 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2375 trap cleanup_test32_mount EXIT
2376 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2377 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2378 $CHECKSTAT -t dir $DIR/$tdir/ext2-mountpoint/.. || error
2379 cleanup_test32_mount
2381 run_test 32a "stat d32a/ext2-mountpoint/.. ====================="
2384 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2385 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2386 trap cleanup_test32_mount EXIT
2387 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2388 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2389 ls -al $DIR/$tdir/ext2-mountpoint/.. || error
2390 cleanup_test32_mount
2392 run_test 32b "open d32b/ext2-mountpoint/.. ====================="
2395 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2396 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2397 trap cleanup_test32_mount EXIT
2398 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2399 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2400 test_mkdir -p $DIR/$tdir/d2/test_dir
2401 $CHECKSTAT -t dir $DIR/$tdir/ext2-mountpoint/../d2/test_dir || error
2402 cleanup_test32_mount
2404 run_test 32c "stat d32c/ext2-mountpoint/../d2/test_dir ========="
2407 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2408 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2409 trap cleanup_test32_mount EXIT
2410 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2411 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2412 test_mkdir -p $DIR/$tdir/d2/test_dir
2413 ls -al $DIR/$tdir/ext2-mountpoint/../d2/test_dir || error
2414 cleanup_test32_mount
2416 run_test 32d "open d32d/ext2-mountpoint/../d2/test_dir ========="
2419 [ -e $DIR/d32e ] && rm -fr $DIR/d32e
2420 test_mkdir -p $DIR/d32e/tmp
2421 TMP_DIR=$DIR/d32e/tmp
2422 ln -s $DIR/d32e $TMP_DIR/symlink11
2423 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
2424 $CHECKSTAT -t link $DIR/d32e/tmp/symlink11 || error
2425 $CHECKSTAT -t link $DIR/d32e/symlink01 || error
2427 run_test 32e "stat d32e/symlink->tmp/symlink->lustre-subdir ===="
2430 [ -e $DIR/d32f ] && rm -fr $DIR/d32f
2431 test_mkdir -p $DIR/d32f/tmp
2432 TMP_DIR=$DIR/d32f/tmp
2433 ln -s $DIR/d32f $TMP_DIR/symlink11
2434 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
2435 ls $DIR/d32f/tmp/symlink11 || error
2436 ls $DIR/d32f/symlink01 || error
2438 run_test 32f "open d32f/symlink->tmp/symlink->lustre-subdir ===="
2441 TMP_DIR=$DIR/$tdir/tmp
2442 test_mkdir -p $DIR/$tdir/tmp
2443 test_mkdir $DIR/${tdir}2
2444 ln -s $DIR/${tdir}2 $TMP_DIR/symlink12
2445 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
2446 $CHECKSTAT -t link $TMP_DIR/symlink12 || error
2447 $CHECKSTAT -t link $DIR/$tdir/symlink02 || error
2448 $CHECKSTAT -t dir -f $TMP_DIR/symlink12 || error
2449 $CHECKSTAT -t dir -f $DIR/$tdir/symlink02 || error
2451 run_test 32g "stat d32g/symlink->tmp/symlink->lustre-subdir/${tdir}2"
2454 rm -fr $DIR/$tdir $DIR/${tdir}2
2455 TMP_DIR=$DIR/$tdir/tmp
2456 test_mkdir -p $DIR/$tdir/tmp
2457 test_mkdir $DIR/${tdir}2
2458 ln -s $DIR/${tdir}2 $TMP_DIR/symlink12
2459 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
2460 ls $TMP_DIR/symlink12 || error
2461 ls $DIR/$tdir/symlink02 || error
2463 run_test 32h "open d32h/symlink->tmp/symlink->lustre-subdir/${tdir}2"
2466 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2467 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2468 trap cleanup_test32_mount EXIT
2469 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2470 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2471 touch $DIR/$tdir/test_file
2472 $CHECKSTAT -t file $DIR/$tdir/ext2-mountpoint/../test_file || error
2473 cleanup_test32_mount
2475 run_test 32i "stat d32i/ext2-mountpoint/../test_file ==========="
2478 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2479 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2480 trap cleanup_test32_mount EXIT
2481 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2482 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2483 touch $DIR/$tdir/test_file
2484 cat $DIR/$tdir/ext2-mountpoint/../test_file || error
2485 cleanup_test32_mount
2487 run_test 32j "open d32j/ext2-mountpoint/../test_file ==========="
2490 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2492 trap cleanup_test32_mount EXIT
2493 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2494 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint
2495 test_mkdir -p $DIR/$tdir/d2
2496 touch $DIR/$tdir/d2/test_file || error
2497 $CHECKSTAT -t file $DIR/$tdir/ext2-mountpoint/../d2/test_file || error
2498 cleanup_test32_mount
2500 run_test 32k "stat d32k/ext2-mountpoint/../d2/test_file ========"
2503 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2505 trap cleanup_test32_mount EXIT
2506 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2507 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2508 test_mkdir -p $DIR/$tdir/d2
2509 touch $DIR/$tdir/d2/test_file
2510 cat $DIR/$tdir/ext2-mountpoint/../d2/test_file || error
2511 cleanup_test32_mount
2513 run_test 32l "open d32l/ext2-mountpoint/../d2/test_file ========"
2517 test_mkdir -p $DIR/d32m/tmp
2518 TMP_DIR=$DIR/d32m/tmp
2519 ln -s $DIR $TMP_DIR/symlink11
2520 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
2521 $CHECKSTAT -t link $DIR/d32m/tmp/symlink11 || error
2522 $CHECKSTAT -t link $DIR/d32m/symlink01 || error
2524 run_test 32m "stat d32m/symlink->tmp/symlink->lustre-root ======"
2528 test_mkdir -p $DIR/d32n/tmp
2529 TMP_DIR=$DIR/d32n/tmp
2530 ln -s $DIR $TMP_DIR/symlink11
2531 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
2532 ls -l $DIR/d32n/tmp/symlink11 || error
2533 ls -l $DIR/d32n/symlink01 || error
2535 run_test 32n "open d32n/symlink->tmp/symlink->lustre-root ======"
2539 test_mkdir -p $DIR/d32o/tmp
2540 TMP_DIR=$DIR/d32o/tmp
2541 ln -s $DIR/$tfile $TMP_DIR/symlink12
2542 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
2543 $CHECKSTAT -t link $DIR/d32o/tmp/symlink12 || error
2544 $CHECKSTAT -t link $DIR/d32o/symlink02 || error
2545 $CHECKSTAT -t file -f $DIR/d32o/tmp/symlink12 || error
2546 $CHECKSTAT -t file -f $DIR/d32o/symlink02 || error
2548 run_test 32o "stat d32o/symlink->tmp/symlink->lustre-root/$tfile"
2558 test_mkdir -p $DIR/d32p/tmp
2560 TMP_DIR=$DIR/d32p/tmp
2562 ln -s $DIR/$tfile $TMP_DIR/symlink12
2564 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
2566 cat $DIR/d32p/tmp/symlink12 || error
2568 cat $DIR/d32p/symlink02 || error
2571 run_test 32p "open d32p/symlink->tmp/symlink->lustre-root/$tfile"
2573 cleanup_testdir_mount() {
2579 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2580 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2581 trap cleanup_testdir_mount EXIT
2582 test_mkdir -p $DIR/$tdir
2583 touch $DIR/$tdir/under_the_mount
2584 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir
2585 ls $DIR/$tdir | grep "\<under_the_mount\>" && error
2586 cleanup_testdir_mount
2588 run_test 32q "stat follows mountpoints in Lustre (should return error)"
2591 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2592 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2593 trap cleanup_testdir_mount EXIT
2594 test_mkdir -p $DIR/$tdir
2595 touch $DIR/$tdir/under_the_mount
2596 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir
2597 ls $DIR/$tdir | grep -q under_the_mount && error || true
2598 cleanup_testdir_mount
2600 run_test 32r "opendir follows mountpoints in Lustre (should return error)"
2605 chmod 444 $DIR/$tfile
2606 chown $RUNAS_ID $DIR/$tfile
2608 $RUNAS $OPENFILE -f O_RDWR $DIR/$tfile && error || true
2611 run_test 33aa "write file with mode 444 (should return error) ===="
2615 test_mkdir -p $DIR/d33
2616 chown $RUNAS_ID $DIR/d33
2617 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $DIR/d33/f33|| error "create"
2618 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $DIR/d33/f33 && \
2619 error "open RDWR" || true
2621 run_test 33a "test open file(mode=0444) with O_RDWR (should return error)"
2625 test_mkdir -p $DIR/d33
2626 chown $RUNAS_ID $DIR/d33
2627 $RUNAS $OPENFILE -f 1286739555 $DIR/d33/f33 || true
2629 run_test 33b "test open file with malformed flags (No panic)"
2632 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2638 remote_ost_nodsh && skip "remote OST with nodsh" && return
2641 test_mkdir -p $DIR/d33
2642 # Read: 0, Write: 4, create/destroy: 2/0, stat: 1, punch: 0
2645 for ostnum in $(seq $OSTCOUNT); do
2646 # test-framework's OST numbering is one-based, while Lustre's
2648 ostname=$(printf "$FSNAME-OST%.4x" $((ostnum - 1)))
2649 # Parsing llobdstat's output sucks; we could grep the /proc
2650 # path, but that's likely to not be as portable as using the
2651 # llobdstat utility. So we parse lctl output instead.
2652 write_bytes=$(do_facet ost$ostnum lctl get_param -n \
2653 obdfilter/$ostname/stats |
2654 awk '/^write_bytes/ {print $7}' )
2655 echo "baseline_write_bytes@$OSTnum/$ostname=$write_bytes"
2656 if (( ${write_bytes:-0} > 0 ))
2663 $all_zeros || return 0
2666 echo foo > $DIR/d33/bar
2670 # Total up write_bytes after writing. We'd better find non-zeros.
2671 for ostnum in $(seq $OSTCOUNT); do
2672 ostname=$(printf "$FSNAME-OST%.4x" $((ostnum - 1)))
2673 write_bytes=$(do_facet ost$ostnum lctl get_param -n \
2674 obdfilter/$ostname/stats |
2675 awk '/^write_bytes/ {print $7}' )
2676 echo "write_bytes@$OSTnum/$ostname=$write_bytes"
2677 if (( ${write_bytes:-0} > 0 ))
2686 for ostnum in $(seq $OSTCOUNT); do
2687 ostname=$(printf "$FSNAME-OST%.4x" $((ostnum - 1)))
2688 echo "Check that write_bytes is present in obdfilter/*/stats:"
2689 do_facet ost$ostnum lctl get_param -n \
2690 obdfilter/$ostname/stats
2692 error "OST not keeping write_bytes stats (b22312)"
2695 run_test 33c "test llobdstat and write_bytes"
2698 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 2 MDTs" && return
2699 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2701 local remote_dir=$DIR/$tdir/remote_dir
2703 test_mkdir -p $DIR/$tdir
2704 $LFS mkdir -i $MDTIDX $remote_dir ||
2705 error "create remote directory failed"
2707 touch $remote_dir/$tfile
2708 chmod 444 $remote_dir/$tfile
2709 chown $RUNAS_ID $remote_dir/$tfile
2711 $RUNAS $OPENFILE -f O_RDWR $DIR/$tfile && error || true
2713 chown $RUNAS_ID $remote_dir
2714 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $remote_dir/f33 ||
2715 error "create" || true
2716 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $remote_dir/f33 &&
2717 error "open RDWR" || true
2718 $RUNAS $OPENFILE -f 1286739555 $remote_dir/f33 || true
2720 run_test 33d "openfile with 444 modes and malformed flags under remote dir"
2723 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2727 $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
2728 $LFS setdirstripe -i1 -c2 $DIR/$tdir/striped_dir1
2729 mkdir $DIR/$tdir/local_dir
2731 local s0_mode=$(stat -c%f $DIR/$tdir/striped_dir)
2732 local s1_mode=$(stat -c%f $DIR/$tdir/striped_dir1)
2733 local l_mode=$(stat -c%f $DIR/$tdir/local_dir)
2735 [ "$l_mode" = "$s0_mode" -a "$l_mode" = "$s1_mode" ] ||
2736 error "mkdir $l_mode striped0 $s0_mode striped1 $s1_mode"
2738 rmdir $DIR/$tdir/* || error "rmdir failed"
2741 $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
2742 $LFS setdirstripe -i1 -c2 $DIR/$tdir/striped_dir1
2743 mkdir $DIR/$tdir/local_dir
2745 s0_mode=$(stat -c%f $DIR/$tdir/striped_dir)
2746 s1_mode=$(stat -c%f $DIR/$tdir/striped_dir1)
2747 l_mode=$(stat -c%f $DIR/$tdir/local_dir)
2749 [ "$l_mode" = "$s0_mode" -a "$l_mode" = "$s1_mode" ] ||
2750 error "mkdir $l_mode striped0 $s0_mode striped1 $s1_mode 777"
2752 rmdir $DIR/$tdir/* || error "rmdir(umask 777) failed"
2755 $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
2756 $LFS setdirstripe -i1 -c2 $DIR/$tdir/striped_dir1
2757 mkdir $DIR/$tdir/local_dir
2759 s0_mode=$(stat -c%f $DIR/$tdir/striped_dir)
2760 s1_mode=$(stat -c%f $DIR/$tdir/striped_dir1)
2761 l_mode=$(stat -c%f $DIR/$tdir/local_dir)
2763 [ "$l_mode" = "$s0_mode" -a "$l_mode" = "$s1_mode" ] ||
2764 error "mkdir $l_mode striped0 $s0_mode striped1 $s1_mode 0"
2766 run_test 33e "mkdir and striped directory should have same mode"
2770 do_facet $SINGLEMDS $LCTL set_param mdt.*.enable_remote_dir_gid=0
2774 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2777 chmod go+rwx $DIR/$tdir
2778 do_facet $SINGLEMDS $LCTL set_param mdt.*.enable_remote_dir_gid=-1
2779 trap cleanup_33f EXIT
2781 $RUNAS lfs mkdir -c$MDSCOUNT $DIR/$tdir/striped_dir ||
2782 error "cannot create striped directory"
2784 $RUNAS touch $DIR/$tdir/striped_dir/{0..16} ||
2785 error "cannot create files in striped directory"
2787 $RUNAS rm $DIR/$tdir/striped_dir/{0..16} ||
2788 error "cannot remove files in striped directory"
2790 $RUNAS rmdir $DIR/$tdir/striped_dir ||
2791 error "cannot remove striped directory"
2795 run_test 33f "nonroot user can create, access, and remove a striped directory"
2797 TEST_34_SIZE=${TEST_34_SIZE:-2000000000000}
2800 $MCREATE $DIR/f34 || error
2801 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" || error
2802 $TRUNCATE $DIR/f34 $TEST_34_SIZE || error
2803 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" || error
2804 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2806 run_test 34a "truncate file that has not been opened ==========="
2809 [ ! -f $DIR/f34 ] && test_34a
2810 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2811 $OPENFILE -f O_RDONLY $DIR/f34
2812 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" || error
2813 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2815 run_test 34b "O_RDONLY opening file doesn't create objects ====="
2818 [ ! -f $DIR/f34 ] && test_34a
2819 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2820 $OPENFILE -f O_RDWR $DIR/f34
2821 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" && error
2822 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2824 run_test 34c "O_RDWR opening file-with-size works =============="
2827 [ ! -f $DIR/f34 ] && test_34a
2828 dd if=/dev/zero of=$DIR/f34 conv=notrunc bs=4k count=1 || error
2829 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2832 run_test 34d "write to sparse file ============================="
2836 $MCREATE $DIR/f34e || error
2837 $TRUNCATE $DIR/f34e 1000 || error
2838 $CHECKSTAT -s 1000 $DIR/f34e || error
2839 $OPENFILE -f O_RDWR $DIR/f34e
2840 $CHECKSTAT -s 1000 $DIR/f34e || error
2842 run_test 34e "create objects, some with size and some without =="
2844 test_34f() { # bug 6242, 6243
2845 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2848 $MCREATE $DIR/f34f || error
2849 $TRUNCATE $DIR/f34f $SIZE34F || error "truncating $DIR/f3f to $SIZE34F"
2850 dd if=$DIR/f34f of=$TMP/f34f
2851 $CHECKSTAT -s $SIZE34F $TMP/f34f || error "$TMP/f34f not $SIZE34F bytes"
2852 dd if=/dev/zero of=$TMP/f34fzero bs=$SIZE34F count=1
2853 cmp $DIR/f34f $TMP/f34fzero || error "$DIR/f34f not all zero"
2854 cmp $TMP/f34f $TMP/f34fzero || error "$TMP/f34f not all zero"
2855 rm $TMP/f34f $TMP/f34fzero $DIR/f34f
2857 run_test 34f "read from a file with no objects until EOF ======="
2860 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2861 dd if=/dev/zero of=$DIR/$tfile bs=1 count=100 seek=$TEST_34_SIZE || error
2862 $TRUNCATE $DIR/$tfile $((TEST_34_SIZE / 2))|| error
2863 $CHECKSTAT -s $((TEST_34_SIZE / 2)) $DIR/$tfile || error "truncate failed"
2864 cancel_lru_locks osc
2865 $CHECKSTAT -s $((TEST_34_SIZE / 2)) $DIR/$tfile || \
2866 error "wrong size after lock cancel"
2868 $TRUNCATE $DIR/$tfile $TEST_34_SIZE || error
2869 $CHECKSTAT -s $TEST_34_SIZE $DIR/$tfile || \
2870 error "expanding truncate failed"
2871 cancel_lru_locks osc
2872 $CHECKSTAT -s $TEST_34_SIZE $DIR/$tfile || \
2873 error "wrong expanded size after lock cancel"
2875 run_test 34g "truncate long file ==============================="
2878 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2882 dd if=/dev/zero of=$DIR/$tfile bs=1M count=10 || error
2883 sync # Flush the cache so that multiop below does not block on cache
2884 # flush when getting the group lock
2885 $MULTIOP $DIR/$tfile OG${gid}T${sz}g${gid}c &
2888 # Since just timed wait is not good enough, let's do a sync write
2889 # that way we are sure enough time for a roundtrip + processing
2890 # passed + 2 seconds of extra margin.
2891 dd if=/dev/zero of=$DIR/${tfile}-1 bs=4096 oflag=direct count=1
2895 if [[ `ps h -o comm -p $MULTIPID` == "multiop" ]]; then
2896 error "Multiop blocked on ftruncate, pid=$MULTIPID"
2900 local nsz=`stat -c %s $DIR/$tfile`
2901 [[ $nsz == $sz ]] || error "New size wrong $nsz != $sz"
2903 run_test 34h "ftruncate file under grouplock should not block"
2906 cp /bin/sh $DIR/f35a
2908 chown $RUNAS_ID $DIR/f35a
2909 $RUNAS $DIR/f35a && error || true
2912 run_test 35a "exec file with mode 444 (should return and not leak) ====="
2916 utime $DIR/f36 || error
2918 run_test 36a "MDS utime check (mknod, utime) ==================="
2922 utime $DIR/f36 || error
2924 run_test 36b "OST utime check (open, utime) ===================="
2929 chown $RUNAS_ID $DIR/d36
2930 $RUNAS utime $DIR/d36/f36 || error
2932 run_test 36c "non-root MDS utime check (mknod, utime) =========="
2935 [ ! -d $DIR/d36 ] && test_36c
2936 echo "" > $DIR/d36/f36
2937 $RUNAS utime $DIR/d36/f36 || error
2939 run_test 36d "non-root OST utime check (open, utime) ==========="
2942 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID -- skipping" && return
2943 test_mkdir -p $DIR/$tdir
2944 touch $DIR/$tdir/$tfile
2945 $RUNAS utime $DIR/$tdir/$tfile && \
2946 error "utime worked, expected failure" || true
2948 run_test 36e "utime on non-owned file (should return error) ===="
2952 local LANG_SAVE=$LANG
2953 local LC_LANG_SAVE=$LC_LANG
2954 export LANG=C LC_LANG=C # for date language
2956 DATESTR="Dec 20 2000"
2957 test_mkdir -p $DIR/$tdir
2958 lctl set_param fail_loc=$fl
2960 cp /etc/hosts $DIR/$tdir/$tfile
2961 sync & # write RPC generated with "current" inode timestamp, but delayed
2963 touch --date="$DATESTR" $DIR/$tdir/$tfile # setattr timestamp in past
2964 LS_BEFORE="`ls -l $DIR/$tdir/$tfile`" # old timestamp from client cache
2965 cancel_lru_locks osc
2966 LS_AFTER="`ls -l $DIR/$tdir/$tfile`" # timestamp from OST object
2968 [ "$LS_BEFORE" != "$LS_AFTER" ] && \
2969 echo "BEFORE: $LS_BEFORE" && \
2970 echo "AFTER : $LS_AFTER" && \
2971 echo "WANT : $DATESTR" && \
2972 error "$DIR/$tdir/$tfile timestamps changed" || true
2974 export LANG=$LANG_SAVE LC_LANG=$LC_LANG_SAVE
2978 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2979 #define OBD_FAIL_OST_BRW_PAUSE_BULK 0x214
2980 subr_36fh "0x80000214"
2982 run_test 36f "utime on file racing with OST BRW write =========="
2985 remote_ost_nodsh && skip "remote OST with nodsh" && return
2986 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2991 test_mkdir -p $DIR/$tdir
2992 fmd_max_age=$(do_facet ost1 \
2993 "lctl get_param -n obdfilter.*.client_cache_seconds 2> /dev/null | \
2996 fmd_before=$(do_facet ost1 \
2997 "awk '/ll_fmd_cache/ {print \\\$2}' /proc/slabinfo")
2998 touch $DIR/$tdir/$tfile
2999 sleep $((fmd_max_age + 12))
3000 fmd_after=$(do_facet ost1 \
3001 "awk '/ll_fmd_cache/ {print \\\$2}' /proc/slabinfo")
3003 echo "fmd_before: $fmd_before"
3004 echo "fmd_after: $fmd_after"
3005 [[ $fmd_after -gt $fmd_before ]] &&
3006 echo "AFTER: $fmd_after > BEFORE: $fmd_before" &&
3007 error "fmd didn't expire after ping" || true
3009 run_test 36g "filter mod data cache expiry ====================="
3012 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3013 #define OBD_FAIL_OST_BRW_PAUSE_BULK2 0x227
3014 subr_36fh "0x80000227"
3016 run_test 36h "utime on file racing with OST BRW write =========="
3019 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
3021 test_mkdir $DIR/$tdir
3022 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR/$tdir/striped_dir
3024 local mtime=$(stat -c%Y $DIR/$tdir/striped_dir)
3025 local new_mtime=$((mtime + 200))
3027 #change Modify time of striped dir
3028 touch -m -d @$new_mtime $DIR/$tdir/striped_dir ||
3029 error "change mtime failed"
3031 local got=$(stat -c%Y $DIR/$tdir/striped_dir)
3033 [ "$new_mtime" = "$got" ] || error "expect $new_mtime got $got"
3035 run_test 36i "change mtime on striped directory"
3037 # test_37 - duplicate with tests 32q 32r
3040 local file=$DIR/$tfile
3042 openfile -f O_DIRECTORY $file
3045 [ $RC -eq 0 ] && error "opened file $file with O_DIRECTORY" || true
3046 [ $RC -eq $ENOTDIR ] || error "error $RC should be ENOTDIR ($ENOTDIR)"
3048 run_test 38 "open a regular file with O_DIRECTORY should return -ENOTDIR ==="
3052 touch $DIR/${tfile}2
3053 # ls -l $DIR/$tfile $DIR/${tfile}2
3054 # ls -lu $DIR/$tfile $DIR/${tfile}2
3055 # ls -lc $DIR/$tfile $DIR/${tfile}2
3057 $OPENFILE -f O_CREAT:O_TRUNC:O_WRONLY $DIR/${tfile}2
3058 if [ ! $DIR/${tfile}2 -nt $DIR/$tfile ]; then
3060 ls -l --full-time $DIR/$tfile $DIR/${tfile}2
3062 ls -lu --full-time $DIR/$tfile $DIR/${tfile}2
3064 ls -lc --full-time $DIR/$tfile $DIR/${tfile}2
3065 error "O_TRUNC didn't change timestamps"
3068 run_test 39 "mtime changed on create ==========================="
3071 test_mkdir -p -c1 $DIR/$tdir
3072 cp -p /etc/passwd $DIR/$tdir/fopen
3073 cp -p /etc/passwd $DIR/$tdir/flink
3074 cp -p /etc/passwd $DIR/$tdir/funlink
3075 cp -p /etc/passwd $DIR/$tdir/frename
3076 ln $DIR/$tdir/funlink $DIR/$tdir/funlink2
3079 echo "aaaaaa" >> $DIR/$tdir/fopen
3080 echo "aaaaaa" >> $DIR/$tdir/flink
3081 echo "aaaaaa" >> $DIR/$tdir/funlink
3082 echo "aaaaaa" >> $DIR/$tdir/frename
3084 local open_new=`stat -c %Y $DIR/$tdir/fopen`
3085 local link_new=`stat -c %Y $DIR/$tdir/flink`
3086 local unlink_new=`stat -c %Y $DIR/$tdir/funlink`
3087 local rename_new=`stat -c %Y $DIR/$tdir/frename`
3089 cat $DIR/$tdir/fopen > /dev/null
3090 ln $DIR/$tdir/flink $DIR/$tdir/flink2
3091 rm -f $DIR/$tdir/funlink2
3092 mv -f $DIR/$tdir/frename $DIR/$tdir/frename2
3094 for (( i=0; i < 2; i++ )) ; do
3095 local open_new2=`stat -c %Y $DIR/$tdir/fopen`
3096 local link_new2=`stat -c %Y $DIR/$tdir/flink`
3097 local unlink_new2=`stat -c %Y $DIR/$tdir/funlink`
3098 local rename_new2=`stat -c %Y $DIR/$tdir/frename2`
3100 [ $open_new2 -eq $open_new ] || error "open file reverses mtime"
3101 [ $link_new2 -eq $link_new ] || error "link file reverses mtime"
3102 [ $unlink_new2 -eq $unlink_new ] || error "unlink file reverses mtime"
3103 [ $rename_new2 -eq $rename_new ] || error "rename file reverses mtime"
3105 cancel_lru_locks osc
3106 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3109 run_test 39b "mtime change on open, link, unlink, rename ======"
3111 # this should be set to past
3112 TEST_39_MTIME=`date -d "1 year ago" +%s`
3118 local mtime0=`stat -c %Y $DIR1/$tfile`
3120 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3121 local mtime1=`stat -c %Y $DIR1/$tfile`
3122 [ "$mtime1" = $TEST_39_MTIME ] || \
3123 error "mtime is not set to past: $mtime1, should be $TEST_39_MTIME"
3126 echo hello >> $DIR1/$tfile
3128 local mtime2=`stat -c %Y $DIR1/$tfile`
3129 [ "$mtime2" -ge "$d1" ] && [ "$mtime2" -le "$d2" ] || \
3130 error "mtime is not updated on write: $d1 <= $mtime2 <= $d2"
3132 mv $DIR1/$tfile $DIR1/$tfile-1
3134 for (( i=0; i < 2; i++ )) ; do
3135 local mtime3=`stat -c %Y $DIR1/$tfile-1`
3136 [ "$mtime2" = "$mtime3" ] || \
3137 error "mtime ($mtime2) changed (to $mtime3) on rename"
3139 cancel_lru_locks osc
3140 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3143 run_test 39c "mtime change on rename ==========================="
3147 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3150 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3152 for (( i=0; i < 2; i++ )) ; do
3153 local mtime=`stat -c %Y $DIR1/$tfile`
3154 [ $mtime = $TEST_39_MTIME ] || \
3155 error "mtime($mtime) is not set to $TEST_39_MTIME"
3157 cancel_lru_locks osc
3158 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3161 run_test 39d "create, utime, stat =============================="
3165 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3167 local mtime1=`stat -c %Y $DIR1/$tfile`
3169 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3171 for (( i=0; i < 2; i++ )) ; do
3172 local mtime2=`stat -c %Y $DIR1/$tfile`
3173 [ $mtime2 = $TEST_39_MTIME ] || \
3174 error "mtime($mtime2) is not set to $TEST_39_MTIME"
3176 cancel_lru_locks osc
3177 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3180 run_test 39e "create, stat, utime, stat ========================"
3184 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3186 mtime1=`stat -c %Y $DIR1/$tfile`
3189 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3191 for (( i=0; i < 2; i++ )) ; do
3192 local mtime2=`stat -c %Y $DIR1/$tfile`
3193 [ $mtime2 = $TEST_39_MTIME ] || \
3194 error "mtime($mtime2) is not set to $TEST_39_MTIME"
3196 cancel_lru_locks osc
3197 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3200 run_test 39f "create, stat, sleep, utime, stat ================="
3204 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3205 echo hello >> $DIR1/$tfile
3206 local mtime1=`stat -c %Y $DIR1/$tfile`
3209 chmod o+r $DIR1/$tfile
3211 for (( i=0; i < 2; i++ )) ; do
3212 local mtime2=`stat -c %Y $DIR1/$tfile`
3213 [ "$mtime1" = "$mtime2" ] || \
3214 error "lost mtime: $mtime2, should be $mtime1"
3216 cancel_lru_locks osc
3217 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3220 run_test 39g "write, chmod, stat ==============================="
3224 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3229 echo hello >> $DIR1/$tfile
3230 local mtime1=`stat -c %Y $DIR1/$tfile`
3232 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3234 if [ "$d1" != "$d2" ]; then
3235 echo "write and touch not within one second"
3237 for (( i=0; i < 2; i++ )) ; do
3238 local mtime2=`stat -c %Y $DIR1/$tfile`
3239 [ "$mtime2" = $TEST_39_MTIME ] || \
3240 error "lost mtime: $mtime2, should be $TEST_39_MTIME"
3242 cancel_lru_locks osc
3243 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3247 run_test 39h "write, utime within one second, stat ============="
3250 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3254 echo hello >> $DIR1/$tfile
3255 local mtime1=`stat -c %Y $DIR1/$tfile`
3257 mv $DIR1/$tfile $DIR1/$tfile-1
3259 for (( i=0; i < 2; i++ )) ; do
3260 local mtime2=`stat -c %Y $DIR1/$tfile-1`
3262 [ "$mtime1" = "$mtime2" ] || \
3263 error "lost mtime: $mtime2, should be $mtime1"
3265 cancel_lru_locks osc
3266 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3269 run_test 39i "write, rename, stat =============================="
3272 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3273 start_full_debug_logging
3277 #define OBD_FAIL_OSC_DELAY_SETTIME 0x412
3278 lctl set_param fail_loc=0x80000412
3279 multiop_bg_pause $DIR1/$tfile oO_RDWR:w2097152_c ||
3280 error "multiop failed"
3282 local mtime1=`stat -c %Y $DIR1/$tfile`
3284 mv $DIR1/$tfile $DIR1/$tfile-1
3286 kill -USR1 $multipid
3287 wait $multipid || error "multiop close failed"
3289 for (( i=0; i < 2; i++ )) ; do
3290 local mtime2=`stat -c %Y $DIR1/$tfile-1`
3291 [ "$mtime1" = "$mtime2" ] ||
3292 error "mtime is lost on close: $mtime2, " \
3295 cancel_lru_locks osc
3296 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3298 lctl set_param fail_loc=0
3299 stop_full_debug_logging
3301 run_test 39j "write, rename, close, stat ======================="
3304 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3308 multiop_bg_pause $DIR1/$tfile oO_RDWR:w2097152_c || error "multiop failed"
3310 local mtime1=`stat -c %Y $DIR1/$tfile`
3312 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3314 kill -USR1 $multipid
3315 wait $multipid || error "multiop close failed"
3317 for (( i=0; i < 2; i++ )) ; do
3318 local mtime2=`stat -c %Y $DIR1/$tfile`
3320 [ "$mtime2" = $TEST_39_MTIME ] || \
3321 error "mtime is lost on close: $mtime2, should be $TEST_39_MTIME"
3323 cancel_lru_locks osc
3324 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3327 run_test 39k "write, utime, close, stat ========================"
3329 # this should be set to future
3330 TEST_39_ATIME=`date -d "1 year" +%s`
3333 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3334 remote_mds_nodsh && skip "remote MDS with nodsh" && return
3335 local atime_diff=$(do_facet $SINGLEMDS \
3336 lctl get_param -n mdd.*MDT0000*.atime_diff)
3340 # test setting directory atime to future
3341 touch -a -d @$TEST_39_ATIME $DIR/$tdir
3342 local atime=$(stat -c %X $DIR/$tdir)
3343 [ "$atime" = $TEST_39_ATIME ] || \
3344 error "atime is not set to future: $atime, $TEST_39_ATIME"
3346 # test setting directory atime from future to now
3347 local d1=$(date +%s)
3349 local d2=$(date +%s)
3351 cancel_lru_locks mdc
3352 atime=$(stat -c %X $DIR/$tdir)
3353 [ "$atime" -ge "$d1" -a "$atime" -le "$d2" ] || \
3354 error "atime is not updated from future: $atime, $d1<atime<$d2"
3356 do_facet $SINGLEMDS lctl set_param -n mdd.*MDT0000*.atime_diff=2
3359 # test setting directory atime when now > dir atime + atime_diff
3363 cancel_lru_locks mdc
3364 atime=$(stat -c %X $DIR/$tdir)
3365 [ "$atime" -ge "$d1" -a "$atime" -le "$d2" ] || \
3366 error "atime is not updated : $atime, should be $d2"
3368 do_facet $SINGLEMDS lctl set_param -n mdd.*MDT0000*.atime_diff=60
3371 # test not setting directory atime when now < dir atime + atime_diff
3373 cancel_lru_locks mdc
3374 atime=$(stat -c %X $DIR/$tdir)
3375 [ "$atime" -ge "$d1" -a "$atime" -le "$d2" ] || \
3376 error "atime is updated to $atime, should remain $d1<atime<$d2"
3378 do_facet $SINGLEMDS \
3379 lctl set_param -n mdd.*MDT0000*.atime_diff=$atime_diff
3381 run_test 39l "directory atime update ==========================="
3384 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3387 local far_past_mtime=$(date -d "May 29 1953" +%s)
3388 local far_past_atime=$(date -d "Dec 17 1903" +%s)
3390 touch -m -d @$far_past_mtime $DIR1/$tfile
3391 touch -a -d @$far_past_atime $DIR1/$tfile
3393 for (( i=0; i < 2; i++ )) ; do
3394 local timestamps=$(stat -c "%X %Y" $DIR1/$tfile)
3395 [ "$timestamps" = "$far_past_atime $far_past_mtime" ] || \
3396 error "atime or mtime set incorrectly"
3398 cancel_lru_locks osc
3399 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3402 run_test 39m "test atime and mtime before 1970"
3404 test_39n() { # LU-3832
3405 local atime_diff=$(do_facet $SINGLEMDS \
3406 lctl get_param -n mdd.*MDT0000*.atime_diff)
3411 do_facet $SINGLEMDS lctl set_param -n mdd.*MDT0000*.atime_diff=1
3414 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 status=noxfer
3415 atime0=$(stat -c %X $DIR/$tfile)
3418 $MULTIOP $DIR/$tfile oO_RDONLY:O_NOATIME:r4096c
3419 atime1=$(stat -c %X $DIR/$tfile)
3422 cancel_lru_locks mdc
3423 cancel_lru_locks osc
3424 $MULTIOP $DIR/$tfile oO_RDONLY:O_NOATIME:r4096c
3425 atime2=$(stat -c %X $DIR/$tfile)
3427 do_facet $SINGLEMDS \
3428 lctl set_param -n mdd.*MDT0000*.atime_diff=$atime_diff
3430 [ "$atime0" -eq "$atime1" ] || error "atime0 $atime0 != atime1 $atime1"
3431 [ "$atime1" -eq "$atime2" ] || error "atime0 $atime0 != atime1 $atime1"
3433 run_test 39n "check that O_NOATIME is honored"
3436 TESTDIR=$DIR/$tdir/$tfile
3437 [ -e $TESTDIR ] && rm -rf $TESTDIR
3444 links2=$(stat -c %h .)
3445 [ $(($links1 + 2)) != $links2 ] &&
3446 error "wrong links count $(($links1 + 2)) != $links2"
3448 links3=$(stat -c %h .)
3449 [ $(($links1 + 1)) != $links3 ] &&
3450 error "wrong links count $links1 != $links3"
3453 run_test 39o "directory cached attributes updated after create ========"
3456 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 2 MDTs" && return
3458 TESTDIR=$DIR/$tdir/$tfile
3459 [ -e $TESTDIR ] && rm -rf $TESTDIR
3460 test_mkdir -p $TESTDIR
3464 $LFS mkdir -i $MDTIDX $TESTDIR/remote_dir1
3465 $LFS mkdir -i $MDTIDX $TESTDIR/remote_dir2
3467 links2=$(stat -c %h .)
3468 [ $(($links1 + 2)) != $links2 ] &&
3469 error "wrong links count $(($links1 + 2)) != $links2"
3471 links3=$(stat -c %h .)
3472 [ $(($links1 + 1)) != $links3 ] &&
3473 error "wrong links count $links1 != $links3"
3476 run_test 39p "remote directory cached attributes updated after create ========"
3480 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1
3481 $RUNAS $OPENFILE -f O_WRONLY:O_TRUNC $DIR/$tfile &&
3482 error "openfile O_WRONLY:O_TRUNC $tfile failed"
3483 $CHECKSTAT -t file -s 4096 $DIR/$tfile ||
3484 error "$tfile is not 4096 bytes in size"
3486 run_test 40 "failed open(O_TRUNC) doesn't truncate ============="
3490 small_write $DIR/f41 18
3492 run_test 41 "test small file write + fstat ====================="
3494 count_ost_writes() {
3495 lctl get_param -n osc.*.stats |
3496 awk -vwrites=0 '/ost_write/ { writes += $2 } \
3497 END { printf("%0.0f", writes) }'
3504 BG_DIRTY_RATIO_SAVE=10
3505 MAX_BG_DIRTY_RATIO=25
3509 # in 2.6, restore /proc/sys/vm/dirty_writeback_centisecs,
3510 # dirty_ratio, dirty_background_ratio
3511 if [ -f /proc/sys/vm/dirty_writeback_centisecs ]; then
3512 sysctl -w vm.dirty_writeback_centisecs=$WRITEBACK_SAVE
3513 sysctl -w vm.dirty_background_ratio=$BG_DIRTY_RATIO_SAVE
3514 sysctl -w vm.dirty_ratio=$DIRTY_RATIO_SAVE
3516 # if file not here, we are a 2.4 kernel
3517 kill -CONT `pidof kupdated`
3522 # setup the trap first, so someone cannot exit the test at the
3523 # exact wrong time and mess up a machine
3524 trap start_writeback EXIT
3525 # in 2.6, save and 0 /proc/sys/vm/dirty_writeback_centisecs
3526 if [ -f /proc/sys/vm/dirty_writeback_centisecs ]; then
3527 WRITEBACK_SAVE=`sysctl -n vm.dirty_writeback_centisecs`
3528 sysctl -w vm.dirty_writeback_centisecs=0
3529 sysctl -w vm.dirty_writeback_centisecs=0
3530 # save and increase /proc/sys/vm/dirty_ratio
3531 DIRTY_RATIO_SAVE=`sysctl -n vm.dirty_ratio`
3532 sysctl -w vm.dirty_ratio=$MAX_DIRTY_RATIO
3533 # save and increase /proc/sys/vm/dirty_background_ratio
3534 BG_DIRTY_RATIO_SAVE=`sysctl -n vm.dirty_background_ratio`
3535 sysctl -w vm.dirty_background_ratio=$MAX_BG_DIRTY_RATIO
3537 # if file not here, we are a 2.4 kernel
3538 kill -STOP `pidof kupdated`
3542 # ensure that all stripes have some grant before we test client-side cache
3544 for i in `seq -f $DIR/f42-%g 1 $OSTCOUNT`; do
3545 dd if=/dev/zero of=$i bs=4k count=1
3550 # Tests 42* verify that our behaviour is correct WRT caching, file closure,
3551 # file truncation, and file removal.
3553 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3555 cancel_lru_locks osc
3557 sync; sleep 1; sync # just to be safe
3558 BEFOREWRITES=`count_ost_writes`
3559 lctl get_param -n osc.*[oO][sS][cC][_-]*.cur_grant_bytes | grep "[0-9]"
3560 dd if=/dev/zero of=$DIR/f42a bs=1024 count=100
3561 AFTERWRITES=`count_ost_writes`
3562 [ $BEFOREWRITES -eq $AFTERWRITES ] || \
3563 error "$BEFOREWRITES < $AFTERWRITES"
3566 run_test 42a "ensure that we don't flush on close =============="
3569 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3571 cancel_lru_locks osc
3574 dd if=/dev/zero of=$DIR/f42b bs=1024 count=100
3575 BEFOREWRITES=$(count_ost_writes)
3576 $MUNLINK $DIR/f42b || error "$MUNLINK $DIR/f42b: $?"
3577 AFTERWRITES=$(count_ost_writes)
3578 if [[ $BEFOREWRITES -lt $AFTERWRITES ]]; then
3579 error "$BEFOREWRITES < $AFTERWRITES on unlink"
3581 BEFOREWRITES=$(count_ost_writes)
3582 sync || error "sync: $?"
3583 AFTERWRITES=$(count_ost_writes)
3584 if [[ $BEFOREWRITES -lt $AFTERWRITES ]]; then
3585 error "$BEFOREWRITES < $AFTERWRITES on sync"
3587 dmesg | grep 'error from obd_brw_async' && error 'error writing back'
3591 run_test 42b "test destroy of file with cached dirty data ======"
3593 # if these tests just want to test the effect of truncation,
3594 # they have to be very careful. consider:
3595 # - the first open gets a {0,EOF}PR lock
3596 # - the first write conflicts and gets a {0, count-1}PW
3597 # - the rest of the writes are under {count,EOF}PW
3598 # - the open for truncate tries to match a {0,EOF}PR
3599 # for the filesize and cancels the PWs.
3600 # any number of fixes (don't get {0,EOF} on open, match
3601 # composite locks, do smarter file size management) fix
3602 # this, but for now we want these tests to verify that
3603 # the cancellation with truncate intent works, so we
3604 # start the file with a full-file pw lock to match against
3605 # until the truncate.
3610 cancel_lru_locks osc
3612 # prime the file with 0,EOF PW to match
3616 # now the real test..
3617 dd if=/dev/zero of=$file bs=1024 count=100
3618 BEFOREWRITES=`count_ost_writes`
3619 $TRUNCATE $file $offset
3620 cancel_lru_locks osc
3621 AFTERWRITES=`count_ost_writes`
3626 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3628 [ $BEFOREWRITES -eq $AFTERWRITES ] && \
3629 error "beforewrites $BEFOREWRITES == afterwrites $AFTERWRITES on truncate"
3632 run_test 42c "test partial truncate of file with cached dirty data"
3635 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3637 [ $BEFOREWRITES -eq $AFTERWRITES ] || \
3638 error "beforewrites $BEFOREWRITES != afterwrites $AFTERWRITES on truncate"
3641 run_test 42d "test complete truncate of file with cached dirty data"
3643 test_42e() { # bug22074
3644 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3645 local TDIR=$DIR/${tdir}e
3646 local pagesz=$(page_size)
3647 local pages=16 # hardcoded 16 pages, don't change it.
3648 local files=$((OSTCOUNT * 500)) # hopefully 500 files on each OST
3649 local proc_osc0="osc.${FSNAME}-OST0000-osc-[^MDT]*"
3653 test_mkdir -p $DIR/${tdir}e
3654 $SETSTRIPE -c 1 $TDIR
3655 createmany -o $TDIR/f $files
3657 max_dirty_mb=$($LCTL get_param -n $proc_osc0/max_dirty_mb)
3659 # we assume that with $OSTCOUNT files, at least one of them will
3660 # be allocated on OST0.
3661 warmup_files=$((OSTCOUNT * max_dirty_mb))
3662 createmany -o $TDIR/w $warmup_files
3664 # write a large amount of data into one file and sync, to get good
3665 # avail_grant number from OST.
3666 for ((i=0; i<$warmup_files; i++)); do
3667 idx=$($GETSTRIPE -i $TDIR/w$i)
3668 [ $idx -ne 0 ] && continue
3669 dd if=/dev/zero of=$TDIR/w$i bs="$max_dirty_mb"M count=1
3672 [[ $i -gt $warmup_files ]] && error "OST0 is still cold"
3674 $LCTL get_param $proc_osc0/cur_dirty_bytes
3675 $LCTL get_param $proc_osc0/cur_grant_bytes
3677 # create as much dirty pages as we can while not to trigger the actual
3678 # RPCs directly. but depends on the env, VFS may trigger flush during this
3679 # period, hopefully we are good.
3680 for ((i=0; i<$warmup_files; i++)); do
3681 idx=$($GETSTRIPE -i $TDIR/w$i)
3682 [ $idx -ne 0 ] && continue
3683 dd if=/dev/zero of=$TDIR/w$i bs=1M count=1 2>/dev/null
3685 $LCTL get_param $proc_osc0/cur_dirty_bytes
3686 $LCTL get_param $proc_osc0/cur_grant_bytes
3688 # perform the real test
3689 $LCTL set_param $proc_osc0/rpc_stats 0
3690 for ((;i<$files; i++)); do
3691 [ $($GETSTRIPE -i $TDIR/f$i) -eq 0 ] || continue
3692 dd if=/dev/zero of=$TDIR/f$i bs=$pagesz count=$pages 2>/dev/null
3695 $LCTL get_param $proc_osc0/rpc_stats
3698 local have_ppr=false
3699 $LCTL get_param $proc_osc0/rpc_stats |
3700 while read PPR RRPC RPCT RCUM BAR WRPC WPCT WCUM; do
3701 # skip lines until we are at the RPC histogram data
3702 [ "$PPR" == "pages" ] && have_ppr=true && continue
3703 $have_ppr || continue
3705 # we only want the percent stat for < 16 pages
3706 [[ $(echo $PPR | tr -d ':') -ge $pages ]] && break
3708 percent=$((percent + WPCT))
3709 if [[ $percent -gt 15 ]]; then
3710 error "less than 16-pages write RPCs" \
3717 run_test 42e "verify sub-RPC writes are not done synchronously"
3720 test_mkdir -p $DIR/$tdir
3721 cp -p /bin/ls $DIR/$tdir/$tfile
3722 $MULTIOP $DIR/$tdir/$tfile Ow_c &
3724 # give multiop a chance to open
3727 $DIR/$tdir/$tfile && error || true
3730 run_test 43 "execution of file opened for write should return -ETXTBSY"
3733 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3734 test_mkdir -p $DIR/$tdir
3735 cp -p `which $MULTIOP` $DIR/$tdir/multiop ||
3736 cp -p multiop $DIR/$tdir/multiop
3737 MULTIOP_PROG=$DIR/$tdir/multiop multiop_bg_pause $TMP/$tfile.junk O_c ||
3740 $MULTIOP $DIR/$tdir/multiop Oc && error "expected error, got success"
3741 kill -USR1 $MULTIOP_PID || return 2
3742 wait $MULTIOP_PID || return 3
3743 rm $TMP/$tfile.junk $DIR/$tdir/multiop
3745 run_test 43a "open(RDWR) of file being executed should return -ETXTBSY"
3748 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3749 test_mkdir -p $DIR/$tdir
3750 cp -p `which $MULTIOP` $DIR/$tdir/multiop ||
3751 cp -p multiop $DIR/$tdir/multiop
3752 MULTIOP_PROG=$DIR/$tdir/multiop multiop_bg_pause $TMP/$tfile.junk O_c ||
3755 $TRUNCATE $DIR/$tdir/multiop 0 && error "expected error, got success"
3756 kill -USR1 $MULTIOP_PID || return 2
3757 wait $MULTIOP_PID || return 3
3758 rm $TMP/$tfile.junk $DIR/$tdir/multiop
3760 run_test 43b "truncate of file being executed should return -ETXTBSY"
3763 local testdir="$DIR/$tdir"
3764 test_mkdir -p $DIR/$tdir
3766 ( cd $(dirname $SHELL) && md5sum $(basename $SHELL) ) | \
3767 ( cd $testdir && md5sum -c)
3769 run_test 43c "md5sum of copy into lustre========================"
3772 [[ $OSTCOUNT -lt 2 ]] && skip_env "skipping 2-stripe test" && return
3773 dd if=/dev/zero of=$DIR/f1 bs=4k count=1 seek=1023
3774 dd if=$DIR/f1 bs=4k count=1 > /dev/null
3776 run_test 44 "zero length read from a sparse stripe ============="
3779 local nstripe=$($LCTL lov_getconfig $DIR | grep default_stripe_count: |
3781 [ -z "$nstripe" ] && skip "can't get stripe info" && return
3782 [[ $nstripe -gt $OSTCOUNT ]] &&
3783 skip "Wrong default_stripe_count: $nstripe (OSTCOUNT: $OSTCOUNT)" &&
3785 local stride=$($LCTL lov_getconfig $DIR | grep default_stripe_size: |
3787 if [[ $nstripe -eq 0 || $nstripe -eq -1 ]]; then
3788 nstripe=$($LCTL lov_getconfig $DIR | grep obd_count: |
3792 OFFSETS="0 $((stride/2)) $((stride-1))"
3793 for offset in $OFFSETS; do
3794 for i in $(seq 0 $((nstripe-1))); do
3795 local GLOBALOFFSETS=""
3797 local size=$((((i + 2 * $nstripe )*$stride + $offset)))
3798 local myfn=$DIR/d44a-$size
3799 echo "--------writing $myfn at $size"
3800 ll_sparseness_write $myfn $size ||
3801 error "ll_sparseness_write"
3802 GLOBALOFFSETS="$GLOBALOFFSETS $size"
3803 ll_sparseness_verify $myfn $GLOBALOFFSETS ||
3804 error "ll_sparseness_verify $GLOBALOFFSETS"
3806 for j in $(seq 0 $((nstripe-1))); do
3808 size=$((((j + $nstripe )*$stride + $offset)))
3809 ll_sparseness_write $myfn $size ||
3810 error "ll_sparseness_write"
3811 GLOBALOFFSETS="$GLOBALOFFSETS $size"
3813 ll_sparseness_verify $myfn $GLOBALOFFSETS ||
3814 error "ll_sparseness_verify $GLOBALOFFSETS"
3819 run_test 44a "test sparse pwrite ==============================="
3823 for d in `lctl get_param -n osc.*.cur_dirty_bytes`; do
3829 before=`dirty_osc_total`
3830 echo executing "\"$*\""
3832 after=`dirty_osc_total`
3833 echo before $before, after $after
3836 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3838 # Obtain grants from OST if it supports it
3839 echo blah > ${f}_grant
3842 do_dirty_record "echo blah > $f"
3843 [[ $before -eq $after ]] && error "write wasn't cached"
3844 do_dirty_record "> $f"
3845 [[ $before -gt $after ]] || error "truncate didn't lower dirty count"
3846 do_dirty_record "echo blah > $f"
3847 [[ $before -eq $after ]] && error "write wasn't cached"
3848 do_dirty_record "sync"
3849 [[ $before -gt $after ]] || error "writeback didn't lower dirty count"
3850 do_dirty_record "echo blah > $f"
3851 [[ $before -eq $after ]] && error "write wasn't cached"
3852 do_dirty_record "cancel_lru_locks osc"
3853 [[ $before -gt $after ]] ||
3854 error "lock cancellation didn't lower dirty count"
3857 run_test 45 "osc io page accounting ============================"
3859 # in a 2 stripe file (lov.sh), page 1023 maps to page 511 in its object. this
3860 # test tickles a bug where re-dirtying a page was failing to be mapped to the
3861 # objects offset and an assert hit when an rpc was built with 1023's mapped
3862 # offset 511 and 511's raw 511 offset. it also found general redirtying bugs.
3864 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3868 dd if=/dev/zero of=$f bs=`page_size` seek=511 count=1
3870 dd conv=notrunc if=/dev/zero of=$f bs=`page_size` seek=1023 count=1
3871 dd conv=notrunc if=/dev/zero of=$f bs=`page_size` seek=511 count=1
3875 run_test 46 "dirtying a previously written page ================"
3877 # test_47 is removed "Device nodes check" is moved to test_28
3879 test_48a() { # bug 2399
3880 [ $(facet_fstype $SINGLEMDS) = "zfs" ] &&
3881 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.3.63) ] &&
3882 skip "MDS prior to 2.3.63 handle ZFS dir .. incorrectly" &&
3884 test_mkdir $DIR/$tdir
3886 mv $DIR/$tdir $DIR/$tdir.new || error "move directory failed"
3887 test_mkdir $DIR/$tdir || error "recreate directory failed"
3888 touch foo || error "'touch foo' failed after recreating cwd"
3889 test_mkdir bar || error "'mkdir foo' failed after recreating cwd"
3890 touch .foo || error "'touch .foo' failed after recreating cwd"
3891 test_mkdir .bar || error "'mkdir .foo' failed after recreating cwd"
3892 ls . > /dev/null || error "'ls .' failed after recreating cwd"
3893 ls .. > /dev/null || error "'ls ..' failed after removing cwd"
3894 cd . || error "'cd .' failed after recreating cwd"
3895 test_mkdir . && error "'mkdir .' worked after recreating cwd"
3896 rmdir . && error "'rmdir .' worked after recreating cwd"
3897 ln -s . baz || error "'ln -s .' failed after recreating cwd"
3898 cd .. || error "'cd ..' failed after recreating cwd"
3900 run_test 48a "Access renamed working dir (should return errors)="
3902 test_48b() { # bug 2399
3904 test_mkdir $DIR/$tdir
3906 rmdir $DIR/$tdir || error "remove cwd $DIR/$tdir failed"
3907 touch foo && error "'touch foo' worked after removing cwd"
3908 test_mkdir foo && error "'mkdir foo' worked after removing cwd"
3909 touch .foo && error "'touch .foo' worked after removing cwd"
3910 test_mkdir .foo && error "'mkdir .foo' worked after removing cwd"
3911 ls . > /dev/null && error "'ls .' worked after removing cwd"
3912 ls .. > /dev/null || error "'ls ..' failed after removing cwd"
3913 is_patchless || ( cd . && error "'cd .' worked after removing cwd" )
3914 test_mkdir . && error "'mkdir .' worked after removing cwd"
3915 rmdir . && error "'rmdir .' worked after removing cwd"
3916 ln -s . foo && error "'ln -s .' worked after removing cwd"
3917 cd .. || echo "'cd ..' failed after removing cwd `pwd`" #bug 3517
3919 run_test 48b "Access removed working dir (should return errors)="
3921 test_48c() { # bug 2350
3922 #lctl set_param debug=-1
3925 test_mkdir -p $DIR/$tdir/dir
3927 $TRACE rmdir $DIR/$tdir/dir || error "remove cwd $DIR/$tdir/dir failed"
3928 $TRACE touch foo && error "touch foo worked after removing cwd"
3929 $TRACE test_mkdir foo && error "'mkdir foo' worked after removing cwd"
3930 touch .foo && error "touch .foo worked after removing cwd"
3931 test_mkdir .foo && error "mkdir .foo worked after removing cwd"
3932 $TRACE ls . && error "'ls .' worked after removing cwd"
3933 $TRACE ls .. || error "'ls ..' failed after removing cwd"
3934 is_patchless || ( $TRACE cd . &&
3935 error "'cd .' worked after removing cwd" )
3936 $TRACE test_mkdir . && error "'mkdir .' worked after removing cwd"
3937 $TRACE rmdir . && error "'rmdir .' worked after removing cwd"
3938 $TRACE ln -s . foo && error "'ln -s .' worked after removing cwd"
3939 $TRACE cd .. || echo "'cd ..' failed after removing cwd `pwd`" #bug 3415
3941 run_test 48c "Access removed working subdir (should return errors)"
3943 test_48d() { # bug 2350
3944 #lctl set_param debug=-1
3947 test_mkdir -p $DIR/$tdir/dir
3949 $TRACE rmdir $DIR/$tdir/dir || error "remove cwd $DIR/$tdir/dir failed"
3950 $TRACE rmdir $DIR/$tdir || error "remove parent $DIR/$tdir failed"
3951 $TRACE touch foo && error "'touch foo' worked after removing parent"
3952 $TRACE test_mkdir foo && error "mkdir foo worked after removing parent"
3953 touch .foo && error "'touch .foo' worked after removing parent"
3954 test_mkdir .foo && error "mkdir .foo worked after removing parent"
3955 $TRACE ls . && error "'ls .' worked after removing parent"
3956 $TRACE ls .. && error "'ls ..' worked after removing parent"
3957 is_patchless || ( $TRACE cd . &&
3958 error "'cd .' worked after recreate parent" )
3959 $TRACE test_mkdir . && error "'mkdir .' worked after removing parent"
3960 $TRACE rmdir . && error "'rmdir .' worked after removing parent"
3961 $TRACE ln -s . foo && error "'ln -s .' worked after removing parent"
3962 is_patchless || ( $TRACE cd .. &&
3963 error "'cd ..' worked after removing parent" || true )
3965 run_test 48d "Access removed parent subdir (should return errors)"
3967 test_48e() { # bug 4134
3968 #lctl set_param debug=-1
3971 test_mkdir -p $DIR/$tdir/dir
3973 $TRACE rmdir $DIR/$tdir/dir || error "remove cwd $DIR/$tdir/dir failed"
3974 $TRACE rmdir $DIR/$tdir || error "remove parent $DIR/$tdir failed"
3975 $TRACE touch $DIR/$tdir || error "'touch $DIR/$tdir' failed"
3976 $TRACE chmod +x $DIR/$tdir || error "'chmod +x $DIR/$tdir' failed"
3977 # On a buggy kernel addition of "touch foo" after cd .. will
3978 # produce kernel oops in lookup_hash_it
3979 touch ../foo && error "'cd ..' worked after recreate parent"
3981 $TRACE rm $DIR/$tdir || error "rm '$DIR/$tdir' failed"
3983 run_test 48e "Access to recreated parent subdir (should return errors)"
3985 test_49() { # LU-1030
3986 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3987 # get ost1 size - lustre-OST0000
3988 ost1_size=$(do_facet ost1 $LFS df | grep ${ost1_svc} |
3990 # write 800M at maximum
3991 [[ $ost1_size -lt 2 ]] && ost1_size=2
3992 [[ $ost1_size -gt 819200 ]] && ost1_size=819200
3994 $SETSTRIPE -c 1 -i 0 $DIR/$tfile
3995 dd if=/dev/zero of=$DIR/$tfile bs=4k count=$((ost1_size >> 2)) &
3998 # change max_pages_per_rpc while writing the file
3999 local osc1_mppc=osc.$(get_osc_import_name client ost1).max_pages_per_rpc
4000 local orig_mppc=$($LCTL get_param -n $osc1_mppc)
4001 # loop until dd process exits
4002 while ps ax -opid | grep -wq $dd_pid; do
4003 $LCTL set_param $osc1_mppc=$((RANDOM % 256 + 1))
4004 sleep $((RANDOM % 5 + 1))
4006 # restore original max_pages_per_rpc
4007 $LCTL set_param $osc1_mppc=$orig_mppc
4008 rm $DIR/$tfile || error "rm $DIR/$tfile failed"
4010 run_test 49 "Change max_pages_per_rpc won't break osc extent"
4014 test_mkdir $DIR/$tdir
4016 ls /proc/$$/cwd || error "ls /proc/$$/cwd failed"
4018 run_test 50 "special situations: /proc symlinks ==============="
4020 test_51a() { # was test_51
4021 # bug 1516 - create an empty entry right after ".." then split dir
4022 test_mkdir -c1 $DIR/$tdir
4023 touch $DIR/$tdir/foo
4024 $MCREATE $DIR/$tdir/bar
4026 createmany -m $DIR/$tdir/longfile 201
4028 while [[ $(ls -sd $DIR/$tdir | awk '{ print $1 }') -eq 4 ]]; do
4029 $MCREATE $DIR/$tdir/longfile$FNUM
4034 ls -l $DIR/$tdir > /dev/null || error "ls -l $DIR/$tdir failed"
4036 run_test 51a "special situations: split htree with empty entry =="
4038 export NUMTEST=70000
4040 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4041 local BASE=$DIR/d${base}.${TESTSUITE}
4043 # cleanup the directory
4046 test_mkdir -p -c1 $BASE
4050 local mdtidx=$(printf "%04x" $($LFS getstripe -M $BASE))
4051 local numfree=$(lctl get_param -n mdc.$FSNAME-MDT$mdtidx*.filesfree)
4052 [[ $numfree -lt 21000 ]] &&
4053 skip "not enough free inodes ($numfree) on MDT$mdtidx" &&
4056 [[ $numfree -lt $NUMTEST ]] && NUMTEST=$(($numfree - 50)) &&
4057 echo "reduced count to $NUMTEST due to inodes on MDT$mdtidx"
4059 # need to check free space for the directories as well
4060 local blkfree=$(lctl get_param -n mdc.$FSNAME-MDT$mdtidx*.kbytesavail)
4061 numfree=$((blkfree / 4))
4062 [[ $numfree -lt $NUMTEST ]] && NUMTEST=$((numfree - 50)) &&
4063 echo "reduced count to $NUMTEST due to blocks on MDT$mdtidx"
4065 createmany -d $BASE/d $NUMTEST && echo $NUMTEST > $BASE/fnum ||
4069 echo "failed" > $BASE/fnum
4070 error "failed to create $NUMTEST subdirs in MDT$mdtidx:$BASE"
4073 run_test 51b "exceed 64k subdirectory nlink limit"
4075 test_51ba() { # LU-993
4076 local BASE=$DIR/d${base}.${TESTSUITE}
4077 # unlink all but 100 subdirectories, then check it still works
4079 [ -f $BASE/fnum ] && local NUMPREV=$(cat $BASE/fnum) && rm $BASE/fnum
4081 [ "$NUMPREV" != "failed" ] && NUMTEST=$NUMPREV
4082 local DELETE=$((NUMTEST - LEFT))
4084 # continue on to run this test even if 51b didn't finish,
4085 # just to delete the many subdirectories created.
4086 [ ! -d "${BASE}/d1" ] && skip "test_51b() not run" && return 0
4088 # for ldiskfs the nlink count should be 1, but this is OSD specific
4089 # and so this is listed for informational purposes only
4090 echo "nlink before: $(stat -c %h $BASE), created before: $NUMTEST"
4091 unlinkmany -d $BASE/d $DELETE
4094 if [ $RC -ne 0 ]; then
4095 if [ "$NUMPREV" == "failed" ]; then
4096 skip "previous setup failed"
4099 error "unlink of first $DELETE subdirs failed"
4104 echo "nlink between: $(stat -c %h $BASE)"
4105 # trim the first line of ls output
4106 local FOUND=$(($(ls -l ${BASE} | wc -l) - 1))
4107 [ $FOUND -ne $LEFT ] &&
4108 error "can't find subdirs: found only $FOUND/$LEFT"
4110 unlinkmany -d $BASE/d $DELETE $LEFT ||
4111 error "unlink of second $LEFT subdirs failed"
4112 # regardless of whether the backing filesystem tracks nlink accurately
4113 # or not, the nlink count shouldn't be more than "." and ".." here
4114 local AFTER=$(stat -c %h $BASE)
4115 [[ $AFTER -gt 2 ]] && error "nlink after: $AFTER > 2" ||
4116 echo "nlink after: $AFTER"
4118 run_test 51ba "verify nlink for many subdirectory cleanup"
4121 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4122 [[ $OSTCOUNT -lt 3 ]] &&
4123 skip_env "skipping test with few OSTs" && return
4124 test_mkdir -p $DIR/$tdir
4125 createmany -o $DIR/$tdir/t- 1000
4126 $GETSTRIPE $DIR/$tdir > $TMP/files
4127 for N in $(seq 0 $((OSTCOUNT - 1))); do
4128 OBJS[$N]=$(awk -vobjs=0 '($1 == '$N') { objs += 1 } \
4129 END { printf("%0.0f", objs) }' $TMP/files)
4130 OBJS0[$N]=$(grep -A 1 idx $TMP/files | awk -vobjs=0 \
4131 '($1 == '$N') { objs += 1 } \
4132 END { printf("%0.0f", objs) }')
4133 log "OST$N has ${OBJS[$N]} objects, ${OBJS0[$N]} are index 0"
4135 unlinkmany $DIR/$tdir/t- 1000
4138 for N in $(seq 1 $((OSTCOUNT - 1))); do
4139 [[ ${OBJS[$N]} -lt $((${OBJS[$NLAST]} - 20)) ]] &&
4140 error "OST $N has less objects vs OST $NLAST" \
4141 " (${OBJS[$N]} < ${OBJS[$NLAST]}"
4142 [[ ${OBJS[$N]} -gt $((${OBJS[$NLAST]} + 20)) ]] &&
4143 error "OST $N has less objects vs OST $NLAST" \
4144 " (${OBJS[$N]} < ${OBJS[$NLAST]}"
4146 [[ ${OBJS0[$N]} -lt $((${OBJS0[$NLAST]} - 20)) ]] &&
4147 error "OST $N has less #0 objects vs OST $NLAST" \
4148 " (${OBJS0[$N]} < ${OBJS0[$NLAST]}"
4149 [[ ${OBJS0[$N]} -gt $((${OBJS0[$NLAST]} + 20)) ]] &&
4150 error "OST $N has less #0 objects vs OST $NLAST" \
4151 " (${OBJS0[$N]} < ${OBJS0[$NLAST]}"
4155 run_test 51d "check object distribution ===================="
4158 if [ "$(facet_fstype $SINGLEMDS)" != ldiskfs ]; then
4159 skip "Only applicable to ldiskfs-based MDTs"
4163 test_mkdir -c1 $DIR/$tdir || error "create $tdir failed"
4164 test_mkdir -c1 $DIR/$tdir/d0 || error "create d0 failed"
4166 touch $DIR/$tdir/d0/foo
4167 createmany -l $DIR/$tdir/d0/foo $DIR/$tdir/d0/f- 65001 &&
4168 error "file exceed 65000 nlink limit!"
4169 unlinkmany $DIR/$tdir/d0/f- 65001
4172 run_test 51e "check file nlink limit"
4175 [ -f $DIR/$tdir/foo ] && chattr -a $DIR/$tdir/foo
4176 test_mkdir -p $DIR/$tdir
4177 touch $DIR/$tdir/foo
4178 chattr +a $DIR/$tdir/foo || error "chattr +a failed"
4179 echo bar >> $DIR/$tdir/foo || error "append bar failed"
4180 cp /etc/hosts $DIR/$tdir/foo && error "cp worked"
4181 rm -f $DIR/$tdir/foo 2>/dev/null && error "rm worked"
4182 link $DIR/$tdir/foo $DIR/$tdir/foo_link 2>/dev/null &&
4184 echo foo >> $DIR/$tdir/foo || error "append foo failed"
4185 mrename $DIR/$tdir/foo $DIR/$tdir/foo_ren && error "rename worked"
4186 lsattr $DIR/$tdir/foo | egrep -q "^-+a[-e]+ $DIR/$tdir/foo" ||
4188 chattr -a $DIR/$tdir/foo || error "chattr -a failed"
4189 cp -r $DIR/$tdir /tmp/
4190 rm -fr $DIR/$tdir || error "cleanup rm failed"
4192 run_test 52a "append-only flag test (should return errors) ====="
4195 [ -f $DIR/$tdir/foo ] && chattr -i $DIR/$tdir/foo
4196 test_mkdir -p $DIR/$tdir
4197 touch $DIR/$tdir/foo
4198 chattr +i $DIR/$tdir/foo || error "chattr +i failed"
4199 cat test > $DIR/$tdir/foo && error "cat test worked"
4200 cp /etc/hosts $DIR/$tdir/foo && error "cp worked"
4201 rm -f $DIR/$tdir/foo 2>/dev/null && error "rm worked"
4202 link $DIR/$tdir/foo $DIR/$tdir/foo_link 2>/dev/null &&
4204 echo foo >> $DIR/$tdir/foo && error "echo worked"
4205 mrename $DIR/$tdir/foo $DIR/$tdir/foo_ren && error "rename worked"
4206 [ -f $DIR/$tdir/foo ] || error "$tdir/foo is not a file"
4207 [ -f $DIR/$tdir/foo_ren ] && error "$tdir/foo_ren is not a file"
4208 lsattr $DIR/$tdir/foo | egrep -q "^-+i[-e]+ $DIR/$tdir/foo" ||
4210 chattr -i $DIR/$tdir/foo || error "chattr failed"
4212 rm -fr $DIR/$tdir || error "unable to remove $DIR/$tdir"
4214 run_test 52b "immutable flag test (should return errors) ======="
4217 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4218 remote_mds_nodsh && skip "remote MDS with nodsh" && return
4219 remote_ost_nodsh && skip "remote OST with nodsh" && return
4232 local support_last_seq=true
4234 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.3.60) ]] ||
4235 support_last_seq=false
4238 local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS)
4240 for value in $(do_facet $SINGLEMDS \
4241 $LCTL get_param osc.$mdtosc.prealloc_last_id) ; do
4242 param=$(echo ${value[0]} | cut -d "=" -f1)
4243 ostname=$(echo $param | cut -d "." -f2 | cut -d - -f 1-2)
4245 if $support_last_seq; then
4246 param_seq=$(echo $param |
4247 sed -e s/prealloc_last_id/prealloc_last_seq/g)
4248 mds_last_seq=$(do_facet $SINGLEMDS \
4249 $LCTL get_param -n $param_seq)
4251 mds_last=$(do_facet $SINGLEMDS $LCTL get_param -n $param)
4253 ostnum=$(index_from_ostuuid ${ostname}_UUID)
4254 node=$(facet_active_host ost$((ostnum+1)))
4255 param="obdfilter.$ostname.last_id"
4256 for ost_last in $(do_node $node $LCTL get_param -n $param) ; do
4257 echo "$ostname.last_id=$ost_last; MDS.last_id=$mds_last"
4258 ost_last_id=$ost_last
4260 if $support_last_seq; then
4261 ost_last_id=$(echo $ost_last |
4262 awk -F':' '{print $2}' |
4264 ost_last_seq=$(echo $ost_last |
4265 awk -F':' '{print $1}')
4266 [[ $ost_last_seq = $mds_last_seq ]] || continue
4269 if [[ $ost_last_id != $mds_last ]]; then
4270 error "$ost_last_id != $mds_last"
4277 $found || error "can not match last_seq/last_id for $mdtosc"
4280 run_test 53 "verify that MDS and OSTs agree on pre-creation ===="
4283 $SOCKETSERVER $DIR/socket ||
4284 error "$SOCKETSERVER $DIR/socket failed: $?"
4285 $SOCKETCLIENT $DIR/socket ||
4286 error "$SOCKETCLIENT $DIR/socket failed: $?"
4287 $MUNLINK $DIR/socket || error "$MUNLINK $DIR/socket failed: $?"
4289 run_test 54a "unix domain socket test =========================="
4295 dd if=/dev/zero of=$f bs=$(page_size) count=1
4297 run_test 54b "char device works in lustre ======================"
4300 [ -b /dev/loop/0 ] && LOOPBASE=/dev/loop/
4301 [ -b /dev/loop0 ] && LOOPBASE=/dev/loop
4302 [ -z "$LOOPBASE" ] && echo "/dev/loop/0 and /dev/loop0 gone?" && return
4304 for i in $(seq 3 7); do
4305 losetup $LOOPBASE$i > /dev/null 2>&1 && continue
4313 loopdev="$DIR/loop54c"
4316 $UMOUNT $DIR/$tdir || rc=$?
4317 losetup -d $loopdev || true
4318 losetup -d $LOOPDEV || true
4319 rm -rf $loopdev $DIR/$tfile $DIR/$tdir
4324 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4325 loopdev="$DIR/loop54c"
4328 [ -z "$LOOPNUM" ] && echo "couldn't find empty loop device" && return
4329 trap cleanup_54c EXIT
4330 mknod $loopdev b 7 $LOOPNUM
4331 echo "make a loop file system with $DIR/$tfile on $loopdev ($LOOPNUM)."
4332 dd if=/dev/zero of=$DIR/$tfile bs=$(get_page_size client) seek=1024 count=1 > /dev/null
4333 losetup $loopdev $DIR/$tfile ||
4334 error "can't set up $loopdev for $DIR/$tfile"
4335 mkfs.ext2 $loopdev || error "mke2fs on $loopdev"
4336 test_mkdir -p $DIR/$tdir
4337 mount -t ext2 $loopdev $DIR/$tdir ||
4338 error "error mounting $loopdev on $DIR/$tdir"
4339 dd if=/dev/zero of=$DIR/$tdir/tmp bs=$(get_page_size client) count=30 ||
4342 dd if=$DIR/$tdir/tmp of=/dev/zero bs=$(get_page_size client) count=30 ||
4346 run_test 54c "block device works in lustre ====================="
4352 [ "$string" = $(echo $string > $f | cat $f) ] || error "$f != $string"
4354 run_test 54d "fifo device works in lustre ======================"
4359 cp -aL /dev/console $f
4360 echo $string > $f || error "echo $string to $f failed"
4362 run_test 54e "console/tty device works in lustre ======================"
4364 #The test_55 used to be iopen test and it was removed by bz#24037.
4365 #run_test 55 "check iopen_connect_dentry() ======================"
4367 test_56a() { # was test_56
4370 test_mkdir -p $DIR/$tdir/dir
4372 NUMFILESx2=$(($NUMFILES * 2))
4373 for i in $(seq 1 $NUMFILES); do
4374 touch $DIR/$tdir/file$i
4375 touch $DIR/$tdir/dir/file$i
4378 # test lfs getstripe with --recursive
4379 FILENUM=$($GETSTRIPE --recursive $DIR/$tdir | grep -c obdidx)
4380 [[ $FILENUM -eq $NUMFILESx2 ]] ||
4381 error "$GETSTRIPE --recursive: found $FILENUM, not $NUMFILESx2"
4382 FILENUM=$($GETSTRIPE $DIR/$tdir | grep -c obdidx)
4383 [[ $FILENUM -eq $NUMFILES ]] ||
4384 error "$GETSTRIPE $DIR/$tdir: found $FILENUM, not $NUMFILES"
4385 echo "$GETSTRIPE --recursive passed."
4387 # test lfs getstripe with file instead of dir
4388 FILENUM=$($GETSTRIPE $DIR/$tdir/file1 | grep -c obdidx)
4389 [[ $FILENUM -eq 1 ]] ||
4390 error "$GETSTRIPE $DIR/$tdir/file1: found $FILENUM, not 1"
4391 echo "$GETSTRIPE file1 passed."
4393 #test lfs getstripe with --verbose
4394 [[ $($GETSTRIPE --verbose $DIR/$tdir |
4395 grep -c lmm_magic) -eq $NUMFILES ]] ||
4396 error "$GETSTRIPE --verbose $DIR/$tdir: want $NUMFILES"
4397 [[ $($GETSTRIPE $DIR/$tdir | grep -c lmm_magic) -eq 0 ]] ||
4398 rror "$GETSTRIPE $DIR/$tdir: showed lmm_magic"
4399 echo "$GETSTRIPE --verbose passed."
4401 #test lfs getstripe with --obd
4402 $GETSTRIPE --obd wrong_uuid $DIR/$tdir 2>&1 |
4403 grep -q "unknown obduuid" ||
4404 error "$GETSTRIPE --obd wrong_uuid should return error message"
4406 [[ $OSTCOUNT -lt 2 ]] &&
4407 skip_env "skipping other $GETSTRIPE --obd test" && return
4410 OBDUUID=$(ostuuid_from_index $OSTIDX)
4411 FILENUM=$($GETSTRIPE -ir $DIR/$tdir | grep "^$OSTIDX\$" | wc -l)
4412 FOUND=$($GETSTRIPE -r --obd $OBDUUID $DIR/$tdir | grep obdidx | wc -l)
4413 [[ $FOUND -eq $FILENUM ]] ||
4414 error "$GETSTRIPE --obd wrong: found $FOUND, expected $FILENUM"
4415 [[ $($GETSTRIPE -r -v --obd $OBDUUID $DIR/$tdir |
4416 sed '/^[ ]*'${OSTIDX}'[ ]/d' |
4417 sed -n '/^[ ]*[0-9][0-9]*[ ]/p' | wc -l) -eq 0 ]] ||
4418 error "$GETSTRIPE --obd: should not show file on other obd"
4419 echo "$GETSTRIPE --obd passed"
4421 run_test 56a "check $GETSTRIPE"
4426 local LOCAL_NUMFILES="$1"
4427 local LOCAL_NUMDIRS="$2"
4428 local MKDIR_PARAMS="$3"
4429 local DIR_STRIPE_PARAMS="$4"
4431 if [ ! -d "$TDIR" ] ; then
4432 test_mkdir -p $DIR_STRIPE_PARAMS $TDIR
4433 [ "$MKDIR_PARAMS" ] && $SETSTRIPE $MKDIR_PARAMS $TDIR
4434 for i in `seq 1 $LOCAL_NUMFILES` ; do
4437 for i in `seq 1 $LOCAL_NUMDIRS` ; do
4438 test_mkdir $DIR_STRIPE_PARAMS $TDIR/dir$i
4439 for j in `seq 1 $LOCAL_NUMFILES` ; do
4440 touch $TDIR/dir$i/file$j
4446 setup_56_special() {
4450 if [ ! -e "$TDIR/loop1b" ] ; then
4451 for i in `seq 1 $LOCAL_NUMFILES` ; do
4452 mknod $TDIR/loop${i}b b 7 $i
4453 mknod $TDIR/null${i}c c 1 3
4454 ln -s $TDIR/file1 $TDIR/link${i}l
4456 for i in `seq 1 $LOCAL_NUMDIRS` ; do
4457 mknod $TDIR/dir$i/loop${i}b b 7 $i
4458 mknod $TDIR/dir$i/null${i}c c 1 3
4459 ln -s $TDIR/dir$i/file1 $TDIR/dir$i/link${i}l
4468 setup_56 $NUMFILES $NUMDIRS
4470 EXPECTED=$(($NUMDIRS + 2))
4471 # test lfs find with -name
4472 for i in $(seq 1 $NUMFILES) ; do
4473 NUMS=$($LFIND -name "*$i" $TDIR | wc -l)
4474 [ $NUMS -eq $EXPECTED ] ||
4475 error "lfs find -name \"*$i\" $TDIR wrong: "\
4476 "found $NUMS, expected $EXPECTED"
4479 run_test 56g "check lfs find -name ============================="
4485 setup_56 $NUMFILES $NUMDIRS
4487 EXPECTED=$(((NUMDIRS + 1) * (NUMFILES - 1) + NUMFILES))
4488 # test lfs find with ! -name
4489 for i in $(seq 1 $NUMFILES) ; do
4490 NUMS=$($LFIND ! -name "*$i" $TDIR | wc -l)
4491 [ $NUMS -eq $EXPECTED ] ||
4492 error "lfs find ! -name \"*$i\" $TDIR wrong: "\
4493 "found $NUMS, expected $EXPECTED"
4496 run_test 56h "check lfs find ! -name ============================="
4500 test_mkdir -p $DIR/$tdir
4501 UUID=$(ostuuid_from_index 0 $DIR/$tdir)
4502 CMD="$LFIND -ost $UUID $DIR/$tdir"
4504 [ -z "$OUT" ] || error "\"$CMD\" returned directory '$OUT'"
4506 run_test 56i "check 'lfs find -ost UUID' skips directories ======="
4510 setup_56_special $NUMFILES $NUMDIRS
4512 EXPECTED=$((NUMDIRS + 1))
4513 CMD="$LFIND -type d $TDIR"
4514 NUMS=$($CMD | wc -l)
4515 [ $NUMS -eq $EXPECTED ] ||
4516 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4518 run_test 56j "check lfs find -type d ============================="
4522 setup_56_special $NUMFILES $NUMDIRS
4524 EXPECTED=$(((NUMDIRS + 1) * NUMFILES))
4525 CMD="$LFIND -type f $TDIR"
4526 NUMS=$($CMD | wc -l)
4527 [ $NUMS -eq $EXPECTED ] ||
4528 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4530 run_test 56k "check lfs find -type f ============================="
4534 setup_56_special $NUMFILES $NUMDIRS
4536 EXPECTED=$((NUMDIRS + NUMFILES))
4537 CMD="$LFIND -type b $TDIR"
4538 NUMS=$($CMD | wc -l)
4539 [ $NUMS -eq $EXPECTED ] ||
4540 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4542 run_test 56l "check lfs find -type b ============================="
4546 setup_56_special $NUMFILES $NUMDIRS
4548 EXPECTED=$((NUMDIRS + NUMFILES))
4549 CMD="$LFIND -type c $TDIR"
4550 NUMS=$($CMD | wc -l)
4551 [ $NUMS -eq $EXPECTED ] ||
4552 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4554 run_test 56m "check lfs find -type c ============================="
4558 setup_56_special $NUMFILES $NUMDIRS
4560 EXPECTED=$((NUMDIRS + NUMFILES))
4561 CMD="$LFIND -type l $TDIR"
4562 NUMS=$($CMD | wc -l)
4563 [ $NUMS -eq $EXPECTED ] ||
4564 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4566 run_test 56n "check lfs find -type l ============================="
4570 setup_56 $NUMFILES $NUMDIRS
4571 utime $TDIR/file1 > /dev/null || error "utime (1)"
4572 utime $TDIR/file2 > /dev/null || error "utime (2)"
4573 utime $TDIR/dir1 > /dev/null || error "utime (3)"
4574 utime $TDIR/dir2 > /dev/null || error "utime (4)"
4575 utime $TDIR/dir1/file1 > /dev/null || error "utime (5)"
4576 dd if=/dev/zero count=1 >> $TDIR/dir1/file1 && sync
4579 NUMS=`$LFIND -mtime +0 $TDIR | wc -l`
4580 [ $NUMS -eq $EXPECTED ] || \
4581 error "lfs find -mtime +0 $TDIR wrong: found $NUMS, expected $EXPECTED"
4584 CMD="$LFIND -mtime 0 $TDIR"
4585 NUMS=$($CMD | wc -l)
4586 [ $NUMS -eq $EXPECTED ] ||
4587 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4589 run_test 56o "check lfs find -mtime for old files =========================="
4592 [ $RUNAS_ID -eq $UID ] &&
4593 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
4596 setup_56 $NUMFILES $NUMDIRS
4598 chown $RUNAS_ID $TDIR/file* || error "chown $DIR/${tdir}g/file$i failed"
4600 CMD="$LFIND -uid $RUNAS_ID $TDIR"
4601 NUMS=$($CMD | wc -l)
4602 [ $NUMS -eq $EXPECTED ] || \
4603 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4605 EXPECTED=$(((NUMFILES + 1) * NUMDIRS + 1))
4606 CMD="$LFIND ! -uid $RUNAS_ID $TDIR"
4607 NUMS=$($CMD | wc -l)
4608 [ $NUMS -eq $EXPECTED ] || \
4609 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4611 run_test 56p "check lfs find -uid and ! -uid ==============================="
4614 [ $RUNAS_ID -eq $UID ] &&
4615 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
4618 setup_56 $NUMFILES $NUMDIRS
4620 chgrp $RUNAS_GID $TDIR/file* || error "chown $TDIR/file$i failed"
4623 CMD="$LFIND -gid $RUNAS_GID $TDIR"
4624 NUMS=$($CMD | wc -l)
4625 [ $NUMS -eq $EXPECTED ] ||
4626 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4628 EXPECTED=$(( ($NUMFILES+1) * $NUMDIRS + 1))
4629 CMD="$LFIND ! -gid $RUNAS_GID $TDIR"
4630 NUMS=$($CMD | wc -l)
4631 [ $NUMS -eq $EXPECTED ] ||
4632 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4634 run_test 56q "check lfs find -gid and ! -gid ==============================="
4638 setup_56 $NUMFILES $NUMDIRS
4641 CMD="$LFIND -size 0 -type f $TDIR"
4642 NUMS=$($CMD | wc -l)
4643 [ $NUMS -eq $EXPECTED ] ||
4644 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4646 CMD="$LFIND ! -size 0 -type f $TDIR"
4647 NUMS=$($CMD | wc -l)
4648 [ $NUMS -eq $EXPECTED ] ||
4649 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4650 echo "test" > $TDIR/$tfile
4651 echo "test2" > $TDIR/$tfile.2 && sync
4653 CMD="$LFIND -size 5 -type f $TDIR"
4654 NUMS=$($CMD | wc -l)
4655 [ $NUMS -eq $EXPECTED ] ||
4656 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4658 CMD="$LFIND -size +5 -type f $TDIR"
4659 NUMS=$($CMD | wc -l)
4660 [ $NUMS -eq $EXPECTED ] ||
4661 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4663 CMD="$LFIND -size +0 -type f $TDIR"
4664 NUMS=$($CMD | wc -l)
4665 [ $NUMS -eq $EXPECTED ] ||
4666 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4668 CMD="$LFIND ! -size -5 -type f $TDIR"
4669 NUMS=$($CMD | wc -l)
4670 [ $NUMS -eq $EXPECTED ] ||
4671 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4673 CMD="$LFIND -size -5 -type f $TDIR"
4674 NUMS=$($CMD | wc -l)
4675 [ $NUMS -eq $EXPECTED ] ||
4676 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4678 run_test 56r "check lfs find -size works =========================="
4680 test_56s() { # LU-611
4682 setup_56 $NUMFILES $NUMDIRS "-c $OSTCOUNT"
4684 if [[ $OSTCOUNT -gt 1 ]]; then
4685 $SETSTRIPE -c 1 $TDIR/$tfile.{0,1,2,3}
4689 ONESTRIPE=$(((NUMDIRS + 1) * NUMFILES))
4693 EXPECTED=$(((NUMDIRS + 1) * NUMFILES))
4694 CMD="$LFIND -stripe-count $OSTCOUNT -type f $TDIR"
4695 NUMS=$($CMD | wc -l)
4696 [ $NUMS -eq $EXPECTED ] || {
4698 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4701 EXPECTED=$(((NUMDIRS + 1) * NUMFILES + EXTRA))
4702 CMD="$LFIND -stripe-count +0 -type f $TDIR"
4703 NUMS=$($CMD | wc -l)
4704 [ $NUMS -eq $EXPECTED ] || {
4706 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4710 CMD="$LFIND -stripe-count 1 -type f $TDIR"
4711 NUMS=$($CMD | wc -l)
4712 [ $NUMS -eq $EXPECTED ] || {
4714 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4717 CMD="$LFIND -stripe-count -2 -type f $TDIR"
4718 NUMS=$($CMD | wc -l)
4719 [ $NUMS -eq $EXPECTED ] || {
4721 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4725 CMD="$LFIND -stripe-count $((OSTCOUNT + 1)) -type f $TDIR"
4726 NUMS=$($CMD | wc -l)
4727 [ $NUMS -eq $EXPECTED ] || {
4729 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4732 run_test 56s "check lfs find -stripe-count works"
4734 test_56t() { # LU-611
4736 setup_56 $NUMFILES $NUMDIRS "-s 512k"
4738 $SETSTRIPE -S 256k $TDIR/$tfile.{0,1,2,3}
4740 EXPECTED=$(((NUMDIRS + 1) * NUMFILES))
4741 CMD="$LFIND -stripe-size 512k -type f $TDIR"
4742 NUMS=$($CMD | wc -l)
4743 [ $NUMS -eq $EXPECTED ] ||
4744 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4746 CMD="$LFIND -stripe-size +320k -type f $TDIR"
4747 NUMS=$($CMD | wc -l)
4748 [ $NUMS -eq $EXPECTED ] ||
4749 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4751 EXPECTED=$(((NUMDIRS + 1) * NUMFILES + 4))
4752 CMD="$LFIND -stripe-size +200k -type f $TDIR"
4753 NUMS=$($CMD | wc -l)
4754 [ $NUMS -eq $EXPECTED ] ||
4755 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4757 CMD="$LFIND -stripe-size -640k -type f $TDIR"
4758 NUMS=$($CMD | wc -l)
4759 [ $NUMS -eq $EXPECTED ] ||
4760 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4763 CMD="$LFIND -stripe-size 256k -type f $TDIR"
4764 NUMS=$($CMD | wc -l)
4765 [ $NUMS -eq $EXPECTED ] ||
4766 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4768 CMD="$LFIND -stripe-size -320k -type f $TDIR"
4769 NUMS=$($CMD | wc -l)
4770 [ $NUMS -eq $EXPECTED ] ||
4771 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4774 CMD="$LFIND -stripe-size 1024k -type f $TDIR"
4775 NUMS=$($CMD | wc -l)
4776 [ $NUMS -eq $EXPECTED ] ||
4777 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4779 run_test 56t "check lfs find -stripe-size works"
4781 test_56u() { # LU-611
4783 setup_56 $NUMFILES $NUMDIRS "-i 0"
4785 if [[ $OSTCOUNT -gt 1 ]]; then
4786 $SETSTRIPE -i 1 $TDIR/$tfile.{0,1,2,3}
4792 EXPECTED=$(((NUMDIRS + 1) * NUMFILES))
4793 CMD="$LFIND -stripe-index 0 -type f $TDIR"
4794 NUMS=$($CMD | wc -l)
4795 [ $NUMS -eq $EXPECTED ] ||
4796 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4799 CMD="$LFIND -stripe-index 1 -type f $TDIR"
4800 NUMS=$($CMD | wc -l)
4801 [ $NUMS -eq $EXPECTED ] ||
4802 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4804 CMD="$LFIND ! -stripe-index 0 -type f $TDIR"
4805 NUMS=$($CMD | wc -l)
4806 [ $NUMS -eq $EXPECTED ] ||
4807 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4810 # This should produce an error and not return any files
4811 CMD="$LFIND -stripe-index $OSTCOUNT -type f $TDIR"
4812 NUMS=$($CMD 2>/dev/null | wc -l)
4813 [ $NUMS -eq $EXPECTED ] ||
4814 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4816 if [[ $OSTCOUNT -gt 1 ]]; then
4817 EXPECTED=$(((NUMDIRS + 1) * NUMFILES + ONESTRIPE))
4818 CMD="$LFIND -stripe-index 0,1 -type f $TDIR"
4819 NUMS=$($CMD | wc -l)
4820 [ $NUMS -eq $EXPECTED ] ||
4821 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4824 run_test 56u "check lfs find -stripe-index works"
4831 setup_56 $NUMFILES $NUMDIRS
4833 UUID=$(mdtuuid_from_index $MDT_IDX $TDIR)
4834 [ -z "$UUID" ] && error "mdtuuid_from_index cannot find MDT index $MDT_IDX"
4836 for file in $($LFIND -mdt $UUID $TDIR); do
4837 file_mdt_idx=$($GETSTRIPE -M $file)
4838 [ $file_mdt_idx -eq $MDT_IDX ] ||
4839 error "'lfind -mdt $UUID' != 'getstripe -M' ($file_mdt_idx)"
4842 run_test 56v "check 'lfs find -mdt match with lfs getstripe -M' ======="
4845 [[ $OSTCOUNT -lt 2 ]] && skip_env "$OSTCOUNT < 2 OSTs -- skipping" &&
4847 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4850 rm -rf $TDIR || error "remove $TDIR failed"
4851 setup_56 $NUMFILES $NUMDIRS "-c $OSTCOUNT" "-c1"
4854 stripe_size=$($GETSTRIPE -S -d $TDIR) ||
4855 error "$GETSTRIPE -S -d $TDIR failed"
4856 stripe_size=${stripe_size%% *}
4858 local file_size=$((stripe_size * OSTCOUNT))
4859 local file_num=$((NUMDIRS * NUMFILES + NUMFILES))
4860 local required_space=$((file_num * file_size))
4861 local free_space=$($LCTL get_param -n lov.$LOVNAME.kbytesavail)
4862 [[ $free_space -le $((required_space / 1024)) ]] &&
4863 skip_env "need at least $required_space bytes free space," \
4864 "have $free_space kbytes" && return
4867 local dd_count=$((file_size / dd_bs))
4869 # write data into the files
4873 for i in $(seq 1 $NUMFILES); do
4875 yes | dd bs=$dd_bs count=$dd_count of=$file >/dev/null 2>&1 ||
4876 error "write data into $file failed"
4878 for i in $(seq 1 $NUMDIRS); do
4879 for j in $(seq 1 $NUMFILES); do
4880 file=$TDIR/dir$i/file$j
4881 yes | dd bs=$dd_bs count=$dd_count of=$file \
4883 error "write data into $file failed"
4888 [[ $OSTCOUNT -gt 1 ]] && expected=$((OSTCOUNT - 1))
4891 local cmd="$LFS_MIGRATE -y -c $expected $TDIR/file1"
4893 eval $cmd || error "$cmd failed"
4895 check_stripe_count $TDIR/file1 $expected
4897 if [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.6.90) ];
4899 # lfs_migrate file onto OST 0 if it is on OST 1, or onto
4900 # OST 1 if it is on OST 0. This file is small enough to
4901 # be on only one stripe.
4902 file=$TDIR/migr_1_ost
4903 dd bs=$dd_bs count=1 if=/dev/urandom of=$file >/dev/null 2>&1 ||
4904 error "write data into $file failed"
4905 local obdidx=$($LFS getstripe -i $file)
4906 local oldmd5=$(md5sum $file)
4908 [[ $obdidx -eq 0 ]] && newobdidx=1
4909 cmd="$LFS migrate -i $newobdidx $file"
4911 eval $cmd || error "$cmd failed"
4912 local realobdix=$($LFS getstripe -i $file)
4913 local newmd5=$(md5sum $file)
4914 [[ $newobdidx -ne $realobdix ]] &&
4915 error "new OST is different (was=$obdidx, wanted=$newobdidx, got=$realobdix)"
4916 [[ "$oldmd5" != "$newmd5" ]] &&
4917 error "md5sum differ: $oldmd5, $newmd5"
4921 cmd="$LFS_MIGRATE -y -c $expected $TDIR/dir1"
4923 eval $cmd || error "$cmd failed"
4925 for j in $(seq 1 $NUMFILES); do
4926 check_stripe_count $TDIR/dir1/file$j $expected
4929 # lfs_migrate works with lfs find
4930 cmd="$LFIND -stripe_count $OSTCOUNT -type f $TDIR |
4931 $LFS_MIGRATE -y -c $expected"
4933 eval $cmd || error "$cmd failed"
4935 for i in $(seq 2 $NUMFILES); do
4936 check_stripe_count $TDIR/file$i $expected
4938 for i in $(seq 2 $NUMDIRS); do
4939 for j in $(seq 1 $NUMFILES); do
4940 check_stripe_count $TDIR/dir$i/file$j $expected
4944 run_test 56w "check lfs_migrate -c stripe_count works"
4947 check_swap_layouts_support && return 0
4948 [[ $OSTCOUNT -lt 2 ]] &&
4949 skip_env "need 2 OST, skipping test" && return
4951 local dir0=$DIR/$tdir/$testnum
4952 test_mkdir -p $dir0 || error "creating dir $dir0"
4954 local ref1=/etc/passwd
4955 local file1=$dir0/file1
4957 $SETSTRIPE -c 2 $file1
4959 $LFS migrate -c 1 $file1 || error "migrate failed rc = $?"
4960 stripe=$($GETSTRIPE -c $file1)
4961 [[ $stripe == 1 ]] || error "stripe of $file1 is $stripe != 1"
4962 cmp $file1 $ref1 || error "content mismatch $file1 differs from $ref1"
4967 run_test 56x "lfs migration support"
4970 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.53) ] &&
4971 skip "No HSM $(lustre_build_version $SINGLEMDS) MDS < 2.4.53" &&
4975 local dir0=$DIR/$tdir/$testnum
4976 test_mkdir -p $dir0 || error "creating dir $dir0"
4977 local f1=$dir0/file1
4978 local f2=$dir0/file2
4980 touch $f1 || error "creating std file $f1"
4981 $MULTIOP $f2 H2c || error "creating released file $f2"
4983 # a directory can be raid0, so ask only for files
4984 res=$($LFIND $dir0 -L raid0 -type f | wc -l)
4985 [[ $res == 2 ]] || error "search raid0: found $res files != 2"
4987 res=$($LFIND $dir0 \! -L raid0 -type f | wc -l)
4988 [[ $res == 0 ]] || error "search !raid0: found $res files != 0"
4990 # only files can be released, so no need to force file search
4991 res=$($LFIND $dir0 -L released)
4992 [[ $res == $f2 ]] || error "search released: found $res != $f2"
4994 res=$($LFIND $dir0 \! -L released)
4995 [[ $res == $f1 ]] || error "search !released: found $res != $f1"
4998 run_test 56y "lfs find -L raid0|released"
5000 test_56z() { # LU-4824
5001 # This checks to make sure 'lfs find' continues after errors
5002 # There are two classes of errors that should be caught:
5003 # - If multiple paths are provided, all should be searched even if one
5005 # - If errors are encountered during the search, it should not terminate
5008 test_mkdir $DIR/$tdir
5009 for i in d{0..9}; do
5010 test_mkdir $DIR/$tdir/$i
5012 touch $DIR/$tdir/d{0..9}/$tfile
5013 $LFS find $DIR/non_existent_dir $DIR/$tdir &&
5014 error "$LFS find did not return an error"
5015 # Make a directory unsearchable. This should NOT be the last entry in
5016 # directory order. Arbitrarily pick the 6th entry
5017 chmod 700 $($LFS find $DIR/$tdir -type d | sed '6!d')
5018 local count=$($RUNAS $LFS find $DIR/non_existent $DIR/$tdir | wc -l)
5019 # The user should be able to see 10 directories and 9 files
5020 [ $count == 19 ] || error "$LFS find did not continue after error"
5022 run_test 56z "lfs find should continue after an error"
5024 test_56aa() { # LU-5937
5025 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
5028 $LFS setdirstripe -c$MDSCOUNT $DIR/$tdir/striped_dir
5030 createmany -o $DIR/$tdir/striped_dir/${tfile}- 1024
5031 local dirs=$(lfs find --size +8k $DIR/$tdir/)
5033 [ -n "$dirs" ] || error "lfs find --size wrong under striped dir"
5035 run_test 56aa "lfs find --size under striped dir"
5038 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5039 # note test will not do anything if MDS is not local
5040 if [ "$(facet_fstype $SINGLEMDS)" != ldiskfs ]; then
5041 skip "Only applicable to ldiskfs-based MDTs"
5045 remote_mds_nodsh && skip "remote MDS with nodsh" && return
5046 local MNTDEV="osd*.*MDT*.mntdev"
5047 DEV=$(do_facet $SINGLEMDS lctl get_param -n $MNTDEV)
5048 [ -z "$DEV" ] && error "can't access $MNTDEV"
5049 for DEV in $(do_facet $SINGLEMDS lctl get_param -n $MNTDEV); do
5050 do_facet $SINGLEMDS $DUMPE2FS -h $DEV > $TMP/t57a.dump ||
5051 error "can't access $DEV"
5052 DEVISIZE=$(awk '/Inode size:/ { print $3 }' $TMP/t57a.dump)
5053 [[ $DEVISIZE -gt 128 ]] || error "inode size $DEVISIZE"
5057 run_test 57a "verify MDS filesystem created with large inodes =="
5060 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5061 if [ "$(facet_fstype $SINGLEMDS)" != ldiskfs ]; then
5062 skip "Only applicable to ldiskfs-based MDTs"
5066 remote_mds_nodsh && skip "remote MDS with nodsh" && return
5067 local dir=$DIR/$tdir
5071 local FILEN=$dir/f$FILECOUNT
5073 rm -rf $dir || error "removing $dir"
5074 test_mkdir -p -c1 $dir || error "creating $dir"
5075 local mdtidx=$($LFS getstripe -M $dir)
5076 local mdtname=MDT$(printf %04x $mdtidx)
5077 local facet=mds$((mdtidx + 1))
5079 echo "mcreating $FILECOUNT files"
5080 createmany -m $dir/f 1 $FILECOUNT || \
5081 error "creating files in $dir"
5083 # verify that files do not have EAs yet
5084 $GETSTRIPE $FILE1 2>&1 | grep -q "no stripe" || error "$FILE1 has an EA"
5085 $GETSTRIPE $FILEN 2>&1 | grep -q "no stripe" || error "$FILEN has an EA"
5089 df $dir #make sure we get new statfs data
5090 local MDSFREE=$(do_facet $facet \
5091 lctl get_param -n osd*.*$mdtname.kbytesfree)
5092 local MDCFREE=$(lctl get_param -n mdc.*$mdtname-mdc-*.kbytesfree)
5093 echo "opening files to create objects/EAs"
5095 for FILE in `seq -f $dir/f%g 1 $FILECOUNT`; do
5096 $OPENFILE -f O_RDWR $FILE > /dev/null 2>&1 || error "opening $FILE"
5099 # verify that files have EAs now
5100 $GETSTRIPE $FILE1 | grep -q "obdidx" || error "$FILE1 missing EA"
5101 $GETSTRIPE $FILEN | grep -q "obdidx" || error "$FILEN missing EA"
5103 sleep 1 #make sure we get new statfs data
5105 local MDSFREE2=$(do_facet $facet \
5106 lctl get_param -n osd*.*$mdtname.kbytesfree)
5107 local MDCFREE2=$(lctl get_param -n mdc.*$mdtname-mdc-*.kbytesfree)
5108 if [[ $MDCFREE2 -lt $((MDCFREE - 16)) ]]; then
5109 if [ "$MDSFREE" != "$MDSFREE2" ]; then
5110 error "MDC before $MDCFREE != after $MDCFREE2"
5112 echo "MDC before $MDCFREE != after $MDCFREE2"
5113 echo "unable to confirm if MDS has large inodes"
5118 run_test 57b "default LOV EAs are stored inside large inodes ==="
5121 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5122 [ -z "$(which wiretest 2>/dev/null)" ] &&
5123 skip_env "could not find wiretest" && return
5126 run_test 58 "verify cross-platform wire constants =============="
5129 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5130 echo "touch 130 files"
5131 createmany -o $DIR/f59- 130
5133 unlinkmany $DIR/f59- 130
5135 # wait for commitment of removal
5136 wait_delete_completed
5138 run_test 59 "verify cancellation of llog records async ========="
5140 TEST60_HEAD="test_60 run $RANDOM"
5142 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5143 remote_mgs_nodsh && skip "remote MGS with nodsh" && return
5144 do_facet mgs "! which run-llog.sh &> /dev/null" &&
5145 do_facet mgs "! ls run-llog.sh &> /dev/null" &&
5146 skip_env "missing subtest run-llog.sh" && return
5148 log "$TEST60_HEAD - from kernel mode"
5149 do_facet mgs "$LCTL set_param debug=warning; $LCTL dk > /dev/null"
5150 do_facet mgs sh run-llog.sh
5151 do_facet mgs $LCTL dk > $TMP/$tfile
5153 # LU-6388: test llog_reader
5154 local llog_reader=$(do_facet mgs "which llog_reader 2> /dev/null")
5155 llog_reader=${llog_reader:-$LUSTRE/utils/llog_reader}
5156 [ -z $(do_facet mgs ls -d $llog_reader 2> /dev/null) ] &&
5157 skip_env "missing llog_reader" && return
5158 local fstype=$(facet_fstype mgs)
5159 [ $fstype != ldiskfs -a $fstype != zfs ] &&
5160 skip_env "Only for ldiskfs or zfs type mgs" && return
5162 local mntpt=$(facet_mntpt mgs)
5163 local mgsdev=$(mgsdevname 1)
5175 #get fid and record list
5176 fid_list=($(awk '/9_sub.*record/ { print $NF }' /$TMP/$tfile |
5178 rec_list=($(awk '/9_sub.*record/ { print $((NF-3)) }' /$TMP/$tfile |
5180 #remount mgs as ldiskfs or zfs type
5181 stop mgs || error "stop mgs failed"
5182 mount_fstype mgs || error "remount mgs failed"
5183 for ((i = 0; i < ${#fid_list[@]}; i++)); do
5186 seq=$(echo $fid | awk -F ':' '{ print $1 }' | sed -e "s/^0x//g")
5187 oid=$(echo $fid | awk -F ':' '{ print $2 }' | sed -e "s/^0x//g")
5192 obj_file=$mntpt/O/$seq/d$((oid%32))/$oid ;;
5194 obj_file=$mntpt/oi.$(($((16#$seq))&127))/$fid ;;
5196 echo "obj_file is $obj_file"
5197 do_facet mgs $llog_reader $obj_file
5199 rec_type=$(do_facet mgs $llog_reader $obj_file | grep "type=" |
5200 awk '{ print $3 }' | sed -e "s/^type=//g")
5201 if [ $rec_type != $rec ]; then
5202 echo "FAILED test_60a wrong record type $rec_type," \
5208 #check obj path if record type is LLOG_LOGID_MAGIC
5209 if [ "$rec" == "1064553b" ]; then
5210 path=$(do_facet mgs $llog_reader $obj_file |
5211 grep "path=" | awk '{ print $NF }' |
5212 sed -e "s/^path=//g")
5213 if [ $obj_file != $mntpt/$path ]; then
5214 echo "FAILED test_60a wrong obj path" \
5215 "$montpt/$path, should be $obj_file"
5222 #restart mgs before "error", otherwise it will block the next test
5223 stop mgs || error "stop mgs failed"
5224 start mgs $(mgsdevname) $MGS_MOUNT_OPTS || error "start mgs failed"
5225 $pass || error "test failed, see FAILED test_60a messages for specifics"
5227 run_test 60a "llog_test run from kernel module and test llog_reader =========="
5229 test_60b() { # bug 6411
5230 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5232 LLOG_COUNT=`dmesg | awk "/$TEST60_HEAD/{marker = 1; from_marker = 0;}
5244 [[ $LLOG_COUNT -gt 50 ]] &&
5245 error "CDEBUG_LIMIT not limiting messages ($LLOG_COUNT)" || true
5247 run_test 60b "limit repeated messages from CERROR/CWARN ========"
5250 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5251 echo "create 5000 files"
5252 createmany -o $DIR/f60c- 5000
5253 #define OBD_FAIL_MDS_LLOG_CREATE_FAILED 0x137
5254 lctl set_param fail_loc=0x80000137
5255 unlinkmany $DIR/f60c- 5000
5256 lctl set_param fail_loc=0
5258 run_test 60c "unlink file when mds full"
5261 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5262 SAVEPRINTK=$(lctl get_param -n printk)
5264 # verify "lctl mark" is even working"
5265 MESSAGE="test message ID $RANDOM $$"
5266 $LCTL mark "$MESSAGE" || error "$LCTL mark failed"
5267 dmesg | grep -q "$MESSAGE" || error "didn't find debug marker in log"
5269 lctl set_param printk=0 || error "set lnet.printk failed"
5270 lctl get_param -n printk | grep emerg || error "lnet.printk dropped emerg"
5271 MESSAGE="new test message ID $RANDOM $$"
5272 # Assume here that libcfs_debug_mark_buffer() uses D_WARNING
5273 $LCTL mark "$MESSAGE" || error "$LCTL mark failed"
5274 dmesg | grep -q "$MESSAGE" && error "D_WARNING wasn't masked" || true
5276 lctl set_param -n printk="$SAVEPRINTK"
5278 run_test 60d "test printk console message masking"
5281 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5283 #define OBD_FAIL_MDS_LLOG_CREATE_FAILED2 0x15b
5284 do_facet mds1 lctl set_param fail_loc=0x15b
5287 run_test 60e "no space while new llog is being created"
5290 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5292 dd if=/dev/zero of=$f bs=$(page_size) count=1 || error "dd $f failed"
5293 cancel_lru_locks osc
5294 $MULTIOP $f OSMWUc || error "$MULTIOP $f failed"
5297 run_test 61 "mmap() writes don't make sync hang ================"
5299 # bug 2330 - insufficient obd_match error checking causes LBUG
5301 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5304 cancel_lru_locks osc
5305 lctl set_param fail_loc=0x405
5306 cat $f && error "cat succeeded, expect -EIO"
5307 lctl set_param fail_loc=0
5309 # This test is now irrelevant (as of bug 10718 inclusion), we no longer
5310 # match every page all of the time.
5311 #run_test 62 "verify obd_match failure doesn't LBUG (should -EIO)"
5313 # bug 2319 - oig_wait() interrupted causes crash because of invalid waitq.
5314 # Though this test is irrelevant anymore, it helped to reveal some
5315 # other grant bugs (LU-4482), let's keep it.
5316 test_63a() { # was test_63
5317 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5318 MAX_DIRTY_MB=`lctl get_param -n osc.*.max_dirty_mb | head -n 1`
5319 for i in `seq 10` ; do
5320 dd if=/dev/zero of=$DIR/f63 bs=8k &
5326 rm -f $DIR/f63 || true
5328 run_test 63a "Verify oig_wait interruption does not crash ======="
5330 # bug 2248 - async write errors didn't return to application on sync
5331 # bug 3677 - async write errors left page locked
5333 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5335 lctl set_param debug=-1
5337 # ensure we have a grant to do async writes
5338 dd if=/dev/zero of=$DIR/$tfile bs=4k count=1
5341 sync # sync lest earlier test intercept the fail_loc
5343 #define OBD_FAIL_OSC_BRW_PREP_REQ 0x406
5344 lctl set_param fail_loc=0x80000406
5345 $MULTIOP $DIR/$tfile Owy && \
5346 error "sync didn't return ENOMEM"
5347 sync; sleep 2; sync # do a real sync this time to flush page
5348 lctl get_param -n llite.*.dump_page_cache | grep locked && \
5349 error "locked page left in cache after async error" || true
5352 run_test 63b "async write errors should be returned to fsync ==="
5355 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5357 lctl get_param -n osc.*[oO][sS][cC][_-]*.cur* | grep "[0-9]"
5359 run_test 64a "verify filter grant calculations (in kernel) ====="
5362 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5363 sh oos.sh $MOUNT || error "oos.sh failed: $?"
5365 run_test 64b "check out-of-space detection on client ==========="
5368 $LCTL set_param osc.*OST0000-osc-[^mM]*.cur_grant_bytes=0
5370 run_test 64c "verify grant shrink ========================------"
5372 # bug 1414 - set/get directories' stripe info
5374 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5375 test_mkdir -p $DIR/$tdir
5377 $LVERIFY $DIR/$tdir $DIR/$tdir/f1 || error "lverify failed"
5379 run_test 65a "directory with no stripe info ===================="
5382 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5383 test_mkdir -p $DIR/$tdir
5384 $SETSTRIPE -S $((STRIPESIZE * 2)) -i 0 -c 1 $DIR/$tdir ||
5387 $LVERIFY $DIR/$tdir $DIR/$tdir/f2 || error "lverify failed"
5389 run_test 65b "directory setstripe -S $((STRIPESIZE * 2)) -i 0 -c 1"
5392 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5393 if [[ $OSTCOUNT -gt 1 ]]; then
5394 test_mkdir -p $DIR/$tdir
5395 $SETSTRIPE -S $(($STRIPESIZE * 4)) -i 1 \
5396 -c $(($OSTCOUNT - 1)) $DIR/$tdir || error "setstripe"
5398 $LVERIFY $DIR/$tdir $DIR/$tdir/f3 || error "lverify failed"
5401 run_test 65c "directory setstripe -S $((STRIPESIZE*4)) -i 1 -c $((OSTCOUNT-1))"
5404 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5405 test_mkdir -p $DIR/$tdir
5406 if [[ $STRIPECOUNT -le 0 ]]; then
5408 elif [[ $STRIPECOUNT -gt 2000 ]]; then
5409 #LOV_MAX_STRIPE_COUNT is 2000
5410 [[ $OSTCOUNT -gt 2000 ]] && sc=2000 || sc=$(($OSTCOUNT - 1))
5412 sc=$(($STRIPECOUNT - 1))
5414 $SETSTRIPE -S $STRIPESIZE -c $sc $DIR/$tdir || error "setstripe"
5415 touch $DIR/$tdir/f4 $DIR/$tdir/f5
5416 $LVERIFY $DIR/$tdir $DIR/$tdir/f4 $DIR/$tdir/f5 ||
5417 error "lverify failed"
5419 run_test 65d "directory setstripe -S $STRIPESIZE -c stripe_count"
5422 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5423 test_mkdir -p $DIR/$tdir
5425 $SETSTRIPE $DIR/$tdir || error "setstripe"
5426 $GETSTRIPE -v $DIR/$tdir | grep "Default" ||
5427 error "no stripe info failed"
5429 $LVERIFY $DIR/$tdir $DIR/$tdir/f6 || error "lverify failed"
5431 run_test 65e "directory setstripe defaults ======================="
5434 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5435 test_mkdir -p $DIR/${tdir}f
5436 $RUNAS $SETSTRIPE $DIR/${tdir}f && error "setstripe succeeded" || true
5438 run_test 65f "dir setstripe permission (should return error) ==="
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 $SETSTRIPE -d $DIR/$tdir || error "setstripe"
5446 $GETSTRIPE -v $DIR/$tdir | grep "Default" ||
5447 error "delete default stripe failed"
5449 run_test 65g "directory setstripe -d ==========================="
5452 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5453 test_mkdir -p $DIR/$tdir
5454 $SETSTRIPE -S $((STRIPESIZE * 2)) -i 0 -c 1 $DIR/$tdir ||
5456 test_mkdir -p $DIR/$tdir/dd1
5457 [ $($GETSTRIPE -c $DIR/$tdir) == $($GETSTRIPE -c $DIR/$tdir/dd1) ] ||
5458 error "stripe info inherit failed"
5460 run_test 65h "directory stripe info inherit ===================="
5462 test_65i() { # bug6367
5463 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5464 $SETSTRIPE -S 65536 -c -1 $MOUNT
5466 run_test 65i "set non-default striping on root directory (bug 6367)="
5468 test_65ia() { # bug12836
5469 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5470 $GETSTRIPE $MOUNT || error "getstripe $MOUNT failed"
5472 run_test 65ia "getstripe on -1 default directory striping"
5474 test_65ib() { # bug12836
5475 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5476 $GETSTRIPE -v $MOUNT || error "getstripe -v $MOUNT failed"
5478 run_test 65ib "getstripe -v on -1 default directory striping"
5480 test_65ic() { # bug12836
5481 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5482 $LFS find -mtime -1 $MOUNT > /dev/null || error "find $MOUNT failed"
5484 run_test 65ic "new find on -1 default directory striping"
5486 test_65j() { # bug6367
5487 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5489 # if we aren't already remounting for each test, do so for this test
5490 if [ "$CLEANUP" = ":" -a "$I_MOUNTED" = "yes" ]; then
5491 cleanup || error "failed to unmount"
5494 $SETSTRIPE -d $MOUNT || error "setstripe failed"
5496 run_test 65j "set default striping on root directory (bug 6367)="
5498 test_65k() { # bug11679
5499 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5500 [[ $OSTCOUNT -lt 2 ]] && skip_env "too few OSTs" && return
5501 remote_mds_nodsh && skip "remote MDS with nodsh" && return
5503 echo "Check OST status: "
5504 local MDS_OSCS=`do_facet $SINGLEMDS lctl dl |
5505 awk '/[oO][sS][cC].*md[ts]/ { print $4 }'`
5507 for OSC in $MDS_OSCS; do
5508 echo $OSC "is activate"
5509 do_facet $SINGLEMDS lctl --device %$OSC activate
5513 for INACTIVE_OSC in $MDS_OSCS; do
5514 echo "Deactivate: " $INACTIVE_OSC
5515 do_facet $SINGLEMDS lctl --device %$INACTIVE_OSC deactivate
5516 for STRIPE_OSC in $MDS_OSCS; do
5517 OST=`osc_to_ost $STRIPE_OSC`
5518 IDX=`do_facet $SINGLEMDS lctl get_param -n lov.*md*.target_obd |
5519 awk -F: /$OST/'{ print $1 }' | head -n 1`
5521 [ -f $DIR/$tdir/$IDX ] && continue
5522 echo "$SETSTRIPE -i $IDX -c 1 $DIR/$tdir/$IDX"
5523 $SETSTRIPE -i $IDX -c 1 $DIR/$tdir/$IDX
5525 [ $RC -ne 0 ] && error "setstripe should have succeeded"
5528 echo $INACTIVE_OSC "is Activate."
5529 do_facet $SINGLEMDS lctl --device %$INACTIVE_OSC activate
5532 run_test 65k "validate manual striping works properly with deactivated OSCs"
5534 test_65l() { # bug 12836
5535 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5536 test_mkdir -p $DIR/$tdir/test_dir
5537 $SETSTRIPE -c -1 $DIR/$tdir/test_dir
5538 $LFS find -mtime -1 $DIR/$tdir >/dev/null
5540 run_test 65l "lfs find on -1 stripe dir ========================"
5542 # bug 2543 - update blocks count on client
5544 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5546 dd if=/dev/zero of=$DIR/f66 bs=1k count=$COUNT
5547 sync; sync_all_data; sync; sync_all_data
5548 cancel_lru_locks osc
5549 BLOCKS=`ls -s $DIR/f66 | awk '{ print $1 }'`
5550 [ $BLOCKS -ge $COUNT ] || error "$DIR/f66 blocks $BLOCKS < $COUNT"
5552 run_test 66 "update inode blocks count on client ==============="
5557 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5559 if [ ! -z "$LLOOP" ]; then
5560 if swapon -s | grep -q $LLOOP; then
5561 swapoff $LLOOP || error "swapoff failed"
5564 $LCTL blockdev_detach $LLOOP || error "detach failed"
5568 if [ ! -z "$LLITELOOPLOAD" ]; then
5576 awk '($1 == "'$1':") { print $2 }' /proc/meminfo
5580 swapon -s | awk '($1 == "'$1'") { print $4 }'
5583 # test case for lloop driver, basic function
5585 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5586 [ "$UID" != 0 ] && skip_env "must run as root" && return
5587 llite_lloop_enabled || \
5588 { skip_env "llite_lloop module disabled" && return; }
5590 trap cleanup_68 EXIT
5592 if ! module_loaded llite_lloop; then
5593 if load_module llite/llite_lloop; then
5596 skip_env "can't find module llite_lloop"
5601 LLOOP=$TMP/lloop.`date +%s`.`date +%N`
5602 dd if=/dev/zero of=$DIR/f68a bs=4k count=1024
5603 $LCTL blockdev_attach $DIR/f68a $LLOOP || error "attach failed"
5605 directio rdwr $LLOOP 0 1024 4096 || error "direct write failed"
5606 directio rdwr $LLOOP 0 1025 4096 && error "direct write should fail"
5610 run_test 68a "lloop driver - basic test ========================"
5612 # excercise swapping to lustre by adding a high priority swapfile entry
5613 # and then consuming memory until it is used.
5614 test_68b() { # was test_68
5615 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5616 [ "$UID" != 0 ] && skip_env "must run as root" && return
5617 lctl get_param -n devices | grep -q obdfilter && \
5618 skip "local OST" && return
5620 grep -q llite_lloop /proc/modules
5621 [ $? -ne 0 ] && skip "can't find module llite_lloop" && return
5623 [ -z "`$LCTL list_nids | grep -v tcp`" ] && \
5624 skip "can't reliably test swap with TCP" && return
5626 MEMTOTAL=`meminfo MemTotal`
5627 NR_BLOCKS=$((MEMTOTAL>>8))
5628 [[ $NR_BLOCKS -le 2048 ]] && NR_BLOCKS=2048
5630 LLOOP=$TMP/lloop.`date +%s`.`date +%N`
5631 dd if=/dev/zero of=$DIR/f68b bs=64k seek=$NR_BLOCKS count=1
5634 $LCTL blockdev_attach $DIR/f68b $LLOOP || error "attach failed"
5636 trap cleanup_68 EXIT
5638 swapon -p 32767 $LLOOP || error "swapon $LLOOP failed"
5640 echo "before: `swapon -s | grep $LLOOP`"
5641 $MEMHOG $MEMTOTAL || error "error allocating $MEMTOTAL kB"
5642 echo "after: `swapon -s | grep $LLOOP`"
5643 SWAPUSED=`swap_used $LLOOP`
5647 [ $SWAPUSED -eq 0 ] && echo "no swap used???" || true
5649 run_test 68b "support swapping to Lustre ========================"
5651 # bug5265, obdfilter oa2dentry return -ENOENT
5652 # #define OBD_FAIL_OST_ENOENT 0x217
5654 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5655 remote_ost_nodsh && skip "remote OST with nodsh" && return
5658 $SETSTRIPE -c 1 -i 0 $f
5660 $DIRECTIO write ${f}.2 0 1 || error "directio write error"
5662 do_facet ost1 lctl set_param fail_loc=0x217
5663 $TRUNCATE $f 1 # vmtruncate() will ignore truncate() error.
5664 $DIRECTIO write $f 0 2 && error "write succeeded, expect -ENOENT"
5666 do_facet ost1 lctl set_param fail_loc=0
5667 $DIRECTIO write $f 0 2 || error "write error"
5669 cancel_lru_locks osc
5670 $DIRECTIO read $f 0 1 || error "read error"
5672 do_facet ost1 lctl set_param fail_loc=0x217
5673 $DIRECTIO read $f 1 1 && error "read succeeded, expect -ENOENT"
5675 do_facet ost1 lctl set_param fail_loc=0
5678 run_test 69 "verify oa2dentry return -ENOENT doesn't LBUG ======"
5681 test_mkdir -p $DIR/$tdir
5682 $LFS setdirstripe -D -c$MDSCOUNT $DIR/$tdir
5683 sh rundbench -C -D $DIR/$tdir 2 || error "dbench failed!"
5685 run_test 71 "Running dbench on lustre (don't segment fault) ===="
5687 test_72a() { # bug 5695 - Test that on 2.6 remove_suid works properly
5688 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5689 [ "$RUNAS_ID" = "$UID" ] &&
5690 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
5692 # Check that testing environment is properly set up. Skip if not
5693 FAIL_ON_ERROR=false check_runas_id_ret $RUNAS_ID $RUNAS_GID $RUNAS || {
5694 skip_env "User $RUNAS_ID does not exist - skipping"
5698 chmod 777 $DIR/$tfile
5699 chmod ug+s $DIR/$tfile
5700 $RUNAS dd if=/dev/zero of=$DIR/$tfile bs=512 count=1 ||
5701 error "$RUNAS dd $DIR/$tfile failed"
5702 # See if we are still setuid/sgid
5703 test -u $DIR/$tfile -o -g $DIR/$tfile &&
5704 error "S/gid is not dropped on write"
5705 # Now test that MDS is updated too
5706 cancel_lru_locks mdc
5707 test -u $DIR/$tfile -o -g $DIR/$tfile &&
5708 error "S/gid is not dropped on MDS"
5711 run_test 72a "Test that remove suid works properly (bug5695) ===="
5713 test_72b() { # bug 24226 -- keep mode setting when size is not changing
5716 [ "$RUNAS_ID" = "$UID" ] && \
5717 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
5718 [ "$RUNAS_ID" -eq 0 ] && \
5719 skip_env "RUNAS_ID = 0 -- skipping" && return
5721 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5722 # Check that testing environment is properly set up. Skip if not
5723 FAIL_ON_ERROR=false check_runas_id_ret $RUNAS_ID $RUNAS_ID $RUNAS || {
5724 skip_env "User $RUNAS_ID does not exist - skipping"
5727 touch $DIR/${tfile}-f{g,u}
5728 test_mkdir $DIR/${tfile}-dg
5729 test_mkdir $DIR/${tfile}-du
5730 chmod 770 $DIR/${tfile}-{f,d}{g,u}
5731 chmod g+s $DIR/${tfile}-{f,d}g
5732 chmod u+s $DIR/${tfile}-{f,d}u
5733 for perm in 777 2777 4777; do
5734 $RUNAS chmod $perm $DIR/${tfile}-fg && error "S/gid file allowed improper chmod to $perm"
5735 $RUNAS chmod $perm $DIR/${tfile}-fu && error "S/uid file allowed improper chmod to $perm"
5736 $RUNAS chmod $perm $DIR/${tfile}-dg && error "S/gid dir allowed improper chmod to $perm"
5737 $RUNAS chmod $perm $DIR/${tfile}-du && error "S/uid dir allowed improper chmod to $perm"
5741 run_test 72b "Test that we keep mode setting if without file data changed (bug 24226)"
5743 # bug 3462 - multiple simultaneous MDC requests
5745 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5746 test_mkdir $DIR/d73-1
5747 test_mkdir $DIR/d73-2
5748 multiop_bg_pause $DIR/d73-1/f73-1 O_c || return 1
5751 lctl set_param fail_loc=0x80000129
5752 $MULTIOP $DIR/d73-1/f73-2 Oc &
5754 lctl set_param fail_loc=0
5756 $MULTIOP $DIR/d73-2/f73-3 Oc &
5760 wait $pid1 || return 1
5764 $CHECKSTAT -t file $DIR/d73-1/f73-1 || return 4
5765 $CHECKSTAT -t file $DIR/d73-1/f73-2 || return 5
5766 $CHECKSTAT -t file $DIR/d73-2/f73-3 || return 6
5770 run_test 73 "multiple MDC requests (should not deadlock)"
5772 test_74a() { # bug 6149, 6184
5773 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5774 #define OBD_FAIL_LDLM_ENQUEUE_OLD_EXPORT 0x30e
5776 # very important to OR with OBD_FAIL_ONCE (0x80000000) -- otherwise it
5777 # will spin in a tight reconnection loop
5779 $LCTL set_param fail_loc=0x8000030e
5780 # get any lock that won't be difficult - lookup works.
5782 $LCTL set_param fail_loc=0
5786 run_test 74a "ldlm_enqueue freed-export error path, ls (shouldn't LBUG)"
5788 test_74b() { # bug 13310
5789 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5790 #define OBD_FAIL_LDLM_ENQUEUE_OLD_EXPORT 0x30e
5792 # very important to OR with OBD_FAIL_ONCE (0x80000000) -- otherwise it
5793 # will spin in a tight reconnection loop
5794 $LCTL set_param fail_loc=0x8000030e
5795 # get a "difficult" lock
5797 $LCTL set_param fail_loc=0
5801 run_test 74b "ldlm_enqueue freed-export error path, touch (shouldn't LBUG)"
5804 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5805 #define OBD_FAIL_LDLM_NEW_LOCK
5806 $LCTL set_param fail_loc=0x319
5807 touch $DIR/$tfile && error "touch successful"
5808 $LCTL set_param fail_loc=0
5811 run_test 74c "ldlm_lock_create error path, (shouldn't LBUG)"
5814 awk '/lustre_inode_cache/ {print $2; exit}' /proc/slabinfo
5817 get_inode_slab_tunables() {
5818 awk '/lustre_inode_cache/ {print $9," ",$10," ",$11; exit}' /proc/slabinfo
5821 set_inode_slab_tunables() {
5822 echo "lustre_inode_cache $1" > /proc/slabinfo
5825 test_76() { # Now for bug 20433, added originally in bug 1443
5826 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5827 local SLAB_SETTINGS=`get_inode_slab_tunables`
5828 local CPUS=`getconf _NPROCESSORS_ONLN`
5829 # we cannot set limit below 1 which means 1 inode in each
5830 # per-cpu cache is still allowed
5831 set_inode_slab_tunables "1 1 0"
5832 cancel_lru_locks osc
5833 BEFORE_INODES=$(num_inodes)
5834 echo "before inodes: $BEFORE_INODES"
5836 [ "$SLOW" = "no" ] && COUNT=100
5837 for i in $(seq $COUNT); do
5841 cancel_lru_locks osc
5842 AFTER_INODES=$(num_inodes)
5843 echo "after inodes: $AFTER_INODES"
5845 while [[ $((AFTER_INODES-1*CPUS)) -gt $BEFORE_INODES ]]; do
5847 AFTER_INODES=$(num_inodes)
5849 echo "wait $wait seconds inodes: $AFTER_INODES"
5850 if [ $wait -gt 30 ]; then
5851 error "inode slab grew from $BEFORE_INODES to $AFTER_INODES"
5854 set_inode_slab_tunables "$SLAB_SETTINGS"
5856 run_test 76 "confirm clients recycle inodes properly ===="
5862 # Note: in sptlrpc modes which enable its own bulk checksum, the
5863 # original crc32_le bulk checksum will be automatically disabled,
5864 # and the OBD_FAIL_OSC_CHECKSUM_SEND/OBD_FAIL_OSC_CHECKSUM_RECEIVE
5865 # will be checked by sptlrpc code against sptlrpc bulk checksum.
5866 # In this case set_checksums() will not be no-op, because sptlrpc
5867 # bulk checksum will be enabled all through the test.
5869 [ "$ORIG_CSUM" ] || ORIG_CSUM=`lctl get_param -n osc.*.checksums | head -n1`
5870 lctl set_param -n osc.*.checksums $1
5874 export ORIG_CSUM_TYPE="`lctl get_param -n osc.*osc-[^mM]*.checksum_type |
5875 sed 's/.*\[\(.*\)\].*/\1/g' | head -n1`"
5876 CKSUM_TYPES=${CKSUM_TYPES:-"crc32 adler"}
5877 [ "$ORIG_CSUM_TYPE" = "crc32c" ] && CKSUM_TYPES="$CKSUM_TYPES crc32c"
5880 lctl set_param -n osc.*osc-[^mM]*.checksum_type $1
5881 log "set checksum type to $1"
5884 F77_TMP=$TMP/f77-temp
5887 dd if=/dev/urandom of=$F77_TMP bs=1M count=$F77SZ || \
5888 error "error writing to $F77_TMP"
5891 test_77a() { # 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
5896 dd if=$F77_TMP of=$DIR/$tfile bs=1M count=$F77SZ || error "dd error"
5900 run_test 77a "normal checksum read/write operation"
5902 test_77b() { # bug 10889
5903 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5904 $GSS && skip "could not run with gss" && return
5905 [ ! -f $F77_TMP ] && setup_f77
5906 #define OBD_FAIL_OSC_CHECKSUM_SEND 0x409
5907 $LCTL set_param fail_loc=0x80000409
5910 dd if=$F77_TMP of=$DIR/$tfile bs=1M count=$F77SZ conv=sync ||
5911 error "dd error: $?"
5912 $LCTL set_param fail_loc=0
5914 for algo in $CKSUM_TYPES; do
5915 cancel_lru_locks osc
5916 set_checksum_type $algo
5917 #define OBD_FAIL_OSC_CHECKSUM_RECEIVE 0x408
5918 $LCTL set_param fail_loc=0x80000408
5919 cmp $F77_TMP $DIR/$tfile || error "file compare failed"
5920 $LCTL set_param fail_loc=0
5923 set_checksum_type $ORIG_CSUM_TYPE
5926 run_test 77b "checksum error on client write, read"
5928 test_77d() { # bug 10889
5929 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5930 $GSS && skip "could not run with gss" && return
5931 #define OBD_FAIL_OSC_CHECKSUM_SEND 0x409
5932 $LCTL set_param fail_loc=0x80000409
5934 $DIRECTIO write $DIR/$tfile 0 $F77SZ $((1024 * 1024)) ||
5935 error "direct write: rc=$?"
5936 $LCTL set_param fail_loc=0
5939 #define OBD_FAIL_OSC_CHECKSUM_RECEIVE 0x408
5940 $LCTL set_param fail_loc=0x80000408
5942 cancel_lru_locks osc
5943 $DIRECTIO read $DIR/$tfile 0 $F77SZ $((1024 * 1024)) ||
5944 error "direct read: rc=$?"
5945 $LCTL set_param fail_loc=0
5948 run_test 77d "checksum error on OST direct write, read"
5950 test_77f() { # bug 10889
5951 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5952 $GSS && skip "could not run with gss" && return
5954 for algo in $CKSUM_TYPES; do
5955 cancel_lru_locks osc
5956 set_checksum_type $algo
5957 #define OBD_FAIL_OSC_CHECKSUM_SEND 0x409
5958 $LCTL set_param fail_loc=0x409
5959 $DIRECTIO write $DIR/$tfile 0 $F77SZ $((1024 * 1024)) &&
5960 error "direct write succeeded"
5961 $LCTL set_param fail_loc=0
5963 set_checksum_type $ORIG_CSUM_TYPE
5966 run_test 77f "repeat checksum error on write (expect error)"
5968 test_77g() { # bug 10889
5969 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5970 $GSS && skip "could not run with gss" && return
5971 remote_ost_nodsh && skip "remote OST with nodsh" && return
5973 [ ! -f $F77_TMP ] && setup_f77
5975 $SETSTRIPE -c 1 -i 0 $DIR/$tfile
5976 #define OBD_FAIL_OST_CHECKSUM_RECEIVE 0x21a
5977 do_facet ost1 lctl set_param fail_loc=0x8000021a
5979 dd if=$F77_TMP of=$DIR/$tfile bs=1M count=$F77SZ ||
5980 error "write error: rc=$?"
5981 do_facet ost1 lctl set_param fail_loc=0
5984 cancel_lru_locks osc
5985 #define OBD_FAIL_OST_CHECKSUM_SEND 0x21b
5986 do_facet ost1 lctl set_param fail_loc=0x8000021b
5988 cmp $F77_TMP $DIR/$tfile || error "file compare failed"
5989 do_facet ost1 lctl set_param fail_loc=0
5992 run_test 77g "checksum error on OST write, read"
5994 test_77i() { # bug 13805
5995 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5996 $GSS && skip "could not run with gss" && return
5997 #define OBD_FAIL_OSC_CONNECT_CKSUM 0x40b
5998 lctl set_param fail_loc=0x40b
5999 remount_client $MOUNT
6000 lctl set_param fail_loc=0
6001 for VALUE in `lctl get_param osc.*osc-[^mM]*.checksum_type`; do
6002 PARAM=`echo ${VALUE[0]} | cut -d "=" -f1`
6003 algo=`lctl get_param -n $PARAM | sed 's/.*\[\(.*\)\].*/\1/g'`
6004 [ "$algo" = "adler" ] || error "algo set to $algo instead of adler"
6006 remount_client $MOUNT
6008 run_test 77i "client not supporting OSD_CONNECT_CKSUM"
6010 test_77j() { # bug 13805
6011 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6012 $GSS && skip "could not run with gss" && return
6013 #define OBD_FAIL_OSC_CKSUM_ADLER_ONLY 0x40c
6014 lctl set_param fail_loc=0x40c
6015 remount_client $MOUNT
6016 lctl set_param fail_loc=0
6017 sleep 2 # wait async osc connect to finish
6018 for VALUE in `lctl get_param osc.*osc-[^mM]*.checksum_type`; do
6019 PARAM=`echo ${VALUE[0]} | cut -d "=" -f1`
6020 algo=`lctl get_param -n $PARAM | sed 's/.*\[\(.*\)\].*/\1/g'`
6021 [ "$algo" = "adler" ] || error "algo set to $algo instead of adler"
6023 remount_client $MOUNT
6025 run_test 77j "client only supporting ADLER32"
6027 [ "$ORIG_CSUM" ] && set_checksums $ORIG_CSUM || true
6031 test_78() { # bug 10901
6032 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6033 remote_ost || { skip_env "local OST" && return; }
6036 F78SIZE=$(($(awk '/MemFree:/ { print $2 }' /proc/meminfo) / 1024))
6037 echo "MemFree: $F78SIZE, Max file size: $MAXFREE"
6038 MEMTOTAL=$(($(awk '/MemTotal:/ { print $2 }' /proc/meminfo) / 1024))
6039 echo "MemTotal: $MEMTOTAL"
6041 # reserve 256MB of memory for the kernel and other running processes,
6042 # and then take 1/2 of the remaining memory for the read/write buffers.
6043 if [ $MEMTOTAL -gt 512 ] ;then
6044 MEMTOTAL=$(((MEMTOTAL - 256 ) / 2))
6046 # for those poor memory-starved high-end clusters...
6047 MEMTOTAL=$((MEMTOTAL / 2))
6049 echo "Mem to use for directio: $MEMTOTAL"
6051 [[ $F78SIZE -gt $MEMTOTAL ]] && F78SIZE=$MEMTOTAL
6052 [[ $F78SIZE -gt 512 ]] && F78SIZE=512
6053 [[ $F78SIZE -gt $((MAXFREE / 1024)) ]] && F78SIZE=$((MAXFREE / 1024))
6054 SMALLESTOST=$($LFS df $DIR | grep OST | awk '{ print $4 }' | sort -n |
6056 echo "Smallest OST: $SMALLESTOST"
6057 [[ $SMALLESTOST -lt 10240 ]] &&
6058 skip "too small OSTSIZE, useless to run large O_DIRECT test" && return 0
6060 [[ $F78SIZE -gt $((SMALLESTOST * $OSTCOUNT / 1024 - 80)) ]] &&
6061 F78SIZE=$((SMALLESTOST * $OSTCOUNT / 1024 - 80))
6063 [ "$SLOW" = "no" ] && NSEQ=1 && [ $F78SIZE -gt 32 ] && F78SIZE=32
6064 echo "File size: $F78SIZE"
6065 $SETSTRIPE -c $OSTCOUNT $DIR/$tfile || error "setstripe failed"
6066 for i in $(seq 1 $NSEQ); do
6067 FSIZE=$(($F78SIZE / ($NSEQ - $i + 1)))
6068 echo directIO rdwr round $i of $NSEQ
6069 $DIRECTIO rdwr $DIR/$tfile 0 $FSIZE 1048576||error "rdwr failed"
6074 run_test 78 "handle large O_DIRECT writes correctly ============"
6076 test_79() { # bug 12743
6077 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6078 wait_delete_completed
6080 BKTOTAL=$(calc_osc_kbytes kbytestotal)
6081 BKFREE=$(calc_osc_kbytes kbytesfree)
6082 BKAVAIL=$(calc_osc_kbytes kbytesavail)
6084 STRING=`df -P $MOUNT | tail -n 1 | awk '{print $2","$3","$4}'`
6085 DFTOTAL=`echo $STRING | cut -d, -f1`
6086 DFUSED=`echo $STRING | cut -d, -f2`
6087 DFAVAIL=`echo $STRING | cut -d, -f3`
6088 DFFREE=$(($DFTOTAL - $DFUSED))
6090 ALLOWANCE=$((64 * $OSTCOUNT))
6092 if [ $DFTOTAL -lt $(($BKTOTAL - $ALLOWANCE)) ] ||
6093 [ $DFTOTAL -gt $(($BKTOTAL + $ALLOWANCE)) ] ; then
6094 error "df total($DFTOTAL) mismatch OST total($BKTOTAL)"
6096 if [ $DFFREE -lt $(($BKFREE - $ALLOWANCE)) ] ||
6097 [ $DFFREE -gt $(($BKFREE + $ALLOWANCE)) ] ; then
6098 error "df free($DFFREE) mismatch OST free($BKFREE)"
6100 if [ $DFAVAIL -lt $(($BKAVAIL - $ALLOWANCE)) ] ||
6101 [ $DFAVAIL -gt $(($BKAVAIL + $ALLOWANCE)) ] ; then
6102 error "df avail($DFAVAIL) mismatch OST avail($BKAVAIL)"
6105 run_test 79 "df report consistency check ======================="
6107 test_80() { # bug 10718
6108 remote_ost_nodsh && skip "remote OST with nodsh" && return
6109 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6110 # relax strong synchronous semantics for slow backends like ZFS
6111 local soc="obdfilter.*.sync_on_lock_cancel"
6112 local soc_old=$(do_facet ost1 lctl get_param -n $soc | head -n1)
6114 if [ "$soc_old" != "never" -a "$(facet_fstype ost1)" != "ldiskfs" ]; then
6115 hosts=$(for host in $(seq -f "ost%g" 1 $OSTCOUNT); do
6116 facet_active_host $host; done | sort -u)
6117 do_nodes $hosts lctl set_param $soc=never
6120 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=1M
6122 local BEFORE=`date +%s`
6123 cancel_lru_locks osc
6124 local AFTER=`date +%s`
6125 local DIFF=$((AFTER-BEFORE))
6126 if [ $DIFF -gt 1 ] ; then
6127 error "elapsed for 1M@1T = $DIFF"
6130 [ -n "$hosts" ] && do_nodes $hosts lctl set_param $soc=$soc_old
6134 run_test 80 "Page eviction is equally fast at high offsets too ===="
6136 test_81a() { # LU-456
6137 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6138 remote_ost_nodsh && skip "remote OST with nodsh" && return
6139 # define OBD_FAIL_OST_MAPBLK_ENOSPC 0x228
6140 # MUST OR with the OBD_FAIL_ONCE (0x80000000)
6141 do_facet ost1 lctl set_param fail_loc=0x80000228
6143 # write should trigger a retry and success
6144 $SETSTRIPE -i 0 -c 1 $DIR/$tfile
6145 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
6147 if [ $RC -ne 0 ] ; then
6148 error "write should success, but failed for $RC"
6151 run_test 81a "OST should retry write when get -ENOSPC ==============="
6153 test_81b() { # LU-456
6154 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6155 remote_ost_nodsh && skip "remote OST with nodsh" && return
6156 # define OBD_FAIL_OST_MAPBLK_ENOSPC 0x228
6157 # Don't OR with the OBD_FAIL_ONCE (0x80000000)
6158 do_facet ost1 lctl set_param fail_loc=0x228
6160 # write should retry several times and return -ENOSPC finally
6161 $SETSTRIPE -i 0 -c 1 $DIR/$tfile
6162 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
6165 if [ $RC -ne $ENOSPC ] ; then
6166 error "dd should fail for -ENOSPC, but succeed."
6169 run_test 81b "OST should return -ENOSPC when retry still fails ======="
6171 test_82() { # LU-1031
6172 dd if=/dev/zero of=$DIR/$tfile bs=1M count=10
6176 multiop_bg_pause $DIR/$tfile OG${gid1}_g${gid1}c || return 1
6178 multiop_bg_pause $DIR/$tfile O_G${gid2}r10g${gid2}c || return 2
6180 kill -USR1 $MULTIPID2
6182 if [[ `ps h -o comm -p $MULTIPID2` == "" ]]; then
6183 error "First grouplock does not block second one"
6185 echo "Second grouplock blocks first one"
6187 kill -USR1 $MULTIPID1
6191 run_test 82 "Basic grouplock test ==============================="
6194 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" &&
6196 test_mkdir -p $DIR/d99cvsroot
6197 chown $RUNAS_ID $DIR/d99cvsroot
6198 local oldPWD=$PWD # bug 13584, use $TMP as working dir
6201 $RUNAS cvs -d $DIR/d99cvsroot init || error "cvs init failed"
6204 run_test 99a "cvs init ========================================="
6207 [ -z "$(which cvs 2>/dev/null)" ] &&
6208 skip_env "could not find cvs" && return
6209 [ ! -d $DIR/d99cvsroot ] && test_99a
6211 # some versions of cvs import exit(1) when asked to import links or
6212 # files they can't read. ignore those files.
6213 TOIGNORE=$(find . -type l -printf '-I %f\n' -o \
6214 ! -perm +4 -printf '-I %f\n')
6215 $RUNAS cvs -d $DIR/d99cvsroot import -m "nomesg" $TOIGNORE \
6216 d99reposname vtag rtag
6218 run_test 99b "cvs import ======================================="
6221 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" && return
6222 [ ! -d $DIR/d99cvsroot ] && test_99b
6224 test_mkdir -p $DIR/d99reposname
6225 chown $RUNAS_ID $DIR/d99reposname
6226 $RUNAS cvs -d $DIR/d99cvsroot co d99reposname
6228 run_test 99c "cvs checkout ====================================="
6231 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" && return
6232 [ ! -d $DIR/d99cvsroot ] && test_99c
6233 cd $DIR/d99reposname
6235 $RUNAS cvs add -m 'addmsg' foo99
6237 run_test 99d "cvs add =========================================="
6240 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" && return
6241 [ ! -d $DIR/d99cvsroot ] && test_99c
6242 cd $DIR/d99reposname
6245 run_test 99e "cvs update ======================================="
6248 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" && return
6249 [ ! -d $DIR/d99cvsroot ] && test_99d
6250 cd $DIR/d99reposname
6251 $RUNAS cvs commit -m 'nomsg' foo99
6252 rm -fr $DIR/d99cvsroot
6254 run_test 99f "cvs commit ======================================="
6257 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6258 [ "$NETTYPE" = tcp ] || \
6259 { skip "TCP secure port test, not useful for NETTYPE=$NETTYPE" && \
6262 remote_ost_nodsh && skip "remote OST with nodsh" && return
6263 remote_mds_nodsh && skip "remote MDS with nodsh" && return
6265 { skip "useless for local single node setup" && return; }
6267 netstat -tna | ( rc=1; while read PROT SND RCV LOCAL REMOTE STAT; do
6268 [ "$PROT" != "tcp" ] && continue
6269 RPORT=$(echo $REMOTE | cut -d: -f2)
6270 [ "$RPORT" != "$ACCEPTOR_PORT" ] && continue
6273 LPORT=`echo $LOCAL | cut -d: -f2`
6274 if [ $LPORT -ge 1024 ]; then
6275 echo "bad: $PROT $SND $RCV $LOCAL $REMOTE $STAT"
6277 error_exit "local: $LPORT > 1024, remote: $RPORT"
6280 [ "$rc" = 0 ] || error_exit "privileged port not found" )
6282 run_test 100 "check local port using privileged port ==========="
6284 function get_named_value()
6293 echo $line | sed "s/^$tag[ ]*//"
6300 export CACHE_MAX=$($LCTL get_param -n llite.*.max_cached_mb |
6301 awk '/^max_cached_mb/ { print $2 }')
6304 $LCTL set_param -n llite.*.max_cached_mb $CACHE_MAX
6309 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6310 [ $MDSCOUNT -ge 2 ] && skip "skip now for >= 2 MDTs" && return #LU-4322
6314 local cache_limit=32
6316 $LCTL set_param -n osc.*-osc*.rpc_stats 0
6317 trap cleanup_101a EXIT
6318 $LCTL set_param -n llite.*.read_ahead_stats 0
6319 $LCTL set_param -n llite.*.max_cached_mb $cache_limit
6322 # randomly read 10000 of 64K chunks from file 3x 32MB in size
6324 echo "nreads: $nreads file size: $((cache_limit * 3))MB"
6325 $READS -f $DIR/$tfile -s$((cache_limit * 3192 * 1024)) -b65536 -C -n$nreads -t 180
6328 for s in $($LCTL get_param -n llite.*.read_ahead_stats |
6329 get_named_value 'read but discarded' | cut -d" " -f1); do
6330 discard=$(($discard + $s))
6334 if [[ $(($discard * 10)) -gt $nreads ]]; then
6335 $LCTL get_param osc.*-osc*.rpc_stats
6336 $LCTL get_param llite.*.read_ahead_stats
6337 error "too many ($discard) discarded pages"
6339 rm -f $DIR/$tfile || true
6341 run_test 101a "check read-ahead for random reads ================"
6344 test_mkdir -p $DIR/$tdir
6345 local STRIPE_SIZE=$1
6346 local FILE_LENGTH=$2
6349 local FILE_SIZE_MB=$((FILE_LENGTH / STRIPE_SIZE))
6351 local list=$(comma_list $(osts_nodes))
6352 set_osd_param $list '' read_cache_enable 0
6353 set_osd_param $list '' writethrough_cache_enable 0
6355 trap cleanup_test101bc EXIT
6356 # prepare the read-ahead file
6357 $SETSTRIPE -S $STRIPE_SIZE -i $STRIPE_OFFSET -c $OSTCOUNT $DIR/$tfile
6359 dd if=/dev/zero of=$DIR/$tfile bs=$STRIPE_SIZE \
6360 count=$FILE_SIZE_MB 2> /dev/null
6364 cleanup_test101bc() {
6369 local list=$(comma_list $(osts_nodes))
6370 set_osd_param $list '' read_cache_enable 1
6371 set_osd_param $list '' writethrough_cache_enable 1
6375 awk 'BEGIN{total=0}; {total+=$1}; END{print total}'
6380 local STRIPE_SIZE=$2
6381 local FILE_LENGTH=$3
6382 local RA_INC=1048576
6383 local STRIDE_LENGTH=$((STRIPE_SIZE/READ_SIZE))
6384 local discard_limit=$((((STRIDE_LENGTH - 1)*3/(STRIDE_LENGTH*OSTCOUNT))* \
6385 (STRIDE_LENGTH*OSTCOUNT - STRIDE_LENGTH)))
6386 DISCARD=$($LCTL get_param -n llite.*.read_ahead_stats |
6387 get_named_value 'read but discarded' |
6388 cut -d" " -f1 | calc_total)
6389 if [[ $DISCARD -gt $discard_limit ]]; then
6390 $LCTL get_param llite.*.read_ahead_stats
6391 error "Too many ($DISCARD) discarded pages with size (${READ_SIZE})"
6393 echo "Read-ahead success for size ${READ_SIZE}"
6398 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6399 [[ $OSTCOUNT -lt 2 ]] &&
6400 skip_env "skipping stride IO stride-ahead test" && return
6401 local STRIPE_SIZE=1048576
6402 local STRIDE_SIZE=$((STRIPE_SIZE*OSTCOUNT))
6403 if [ $SLOW == "yes" ]; then
6404 local FILE_LENGTH=$((STRIDE_SIZE * 64))
6406 local FILE_LENGTH=$((STRIDE_SIZE * 8))
6409 local ITERATION=$((FILE_LENGTH / STRIDE_SIZE))
6411 # prepare the read-ahead file
6412 setup_test101bc $STRIPE_SIZE $FILE_LENGTH
6413 cancel_lru_locks osc
6414 for BIDX in 2 4 8 16 32 64 128 256
6416 local BSIZE=$((BIDX*4096))
6417 local READ_COUNT=$((STRIPE_SIZE/BSIZE))
6418 local STRIDE_LENGTH=$((STRIDE_SIZE/BSIZE))
6419 local OFFSET=$((STRIPE_SIZE/BSIZE*(OSTCOUNT - 1)))
6420 $LCTL set_param -n llite.*.read_ahead_stats 0
6421 $READS -f $DIR/$tfile -l $STRIDE_LENGTH -o $OFFSET \
6422 -s $FILE_LENGTH -b $STRIPE_SIZE -a $READ_COUNT -n $ITERATION
6423 cancel_lru_locks osc
6424 ra_check_101 $BSIZE $STRIPE_SIZE $FILE_LENGTH
6429 run_test 101b "check stride-io mode read-ahead ================="
6432 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6433 local STRIPE_SIZE=1048576
6434 local FILE_LENGTH=$((STRIPE_SIZE*100))
6438 setup_test101bc $STRIPE_SIZE $FILE_LENGTH
6440 cancel_lru_locks osc
6441 $LCTL set_param osc.*.rpc_stats 0
6442 $READS -f $DIR/$tfile -s$FILE_LENGTH -b65536 -n$nreads -t 180
6443 for osc_rpc_stats in $($LCTL get_param -N osc.*.rpc_stats); do
6444 local stats=$($LCTL get_param -n $osc_rpc_stats)
6445 local lines=$(echo "$stats" | awk 'END {print NR;}')
6448 if [ $lines -le 20 ]; then
6451 for size in 1 2 4 8; do
6452 local rpc=$(echo "$stats" |
6453 awk '($1 == "'$size':") {print $2; exit; }')
6455 error "Small $((size*4))k read IO $rpc !"
6457 echo "$osc_rpc_stats check passed!"
6462 run_test 101c "check stripe_size aligned read-ahead ================="
6465 $LCTL get_param -n llite.*.max_read_ahead_mb | head -n 1
6466 $LCTL set_param -n llite.*.max_read_ahead_mb $1 > /dev/null 2>&1
6470 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6471 local file=$DIR/$tfile
6472 local sz_MB=${FILESIZE_101d:-500}
6473 local ra_MB=${READAHEAD_MB:-40}
6475 local free_MB=$(($(df -P $DIR | tail -n 1 | awk '{ print $4 }') / 1024))
6476 [ $free_MB -lt $sz_MB ] &&
6477 skip "Need free space ${sz_MB}M, have ${free_MB}M" && return
6479 echo "Create test file $file size ${sz_MB}M, ${free_MB}M free"
6480 $SETSTRIPE -c -1 $file || error "setstripe failed"
6482 dd if=/dev/zero of=$file bs=1M count=$sz_MB || error "dd failed"
6483 echo Cancel LRU locks on lustre client to flush the client cache
6484 cancel_lru_locks osc
6486 echo Disable read-ahead
6487 local old_READAHEAD=$(set_read_ahead 0)
6489 echo Reading the test file $file with read-ahead disabled
6490 local raOFF=$(do_and_time "dd if=$file of=/dev/null bs=1M count=$sz_MB")
6492 echo Cancel LRU locks on lustre client to flush the client cache
6493 cancel_lru_locks osc
6494 echo Enable read-ahead with ${ra_MB}MB
6495 set_read_ahead $ra_MB
6497 echo Reading the test file $file with read-ahead enabled
6498 local raON=$(do_and_time "dd if=$file of=/dev/null bs=1M count=$sz_MB")
6500 echo "read-ahead disabled time read $raOFF"
6501 echo "read-ahead enabled time read $raON"
6503 set_read_ahead $old_READAHEAD
6505 wait_delete_completed
6507 [ $raOFF -le 1 -o $raON -lt $raOFF ] ||
6508 error "readahead ${raON}s > no-readahead ${raOFF}s ${sz_MB}M"
6510 run_test 101d "file read with and without read-ahead enabled"
6513 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6514 local file=$DIR/$tfile
6515 local size_KB=500 #KB
6519 local free_KB=$(df -P $DIR | tail -n 1 | awk '{ print $4 }')
6520 local need_KB=$((count * size_KB))
6521 [[ $free_KB -le $need_KB ]] &&
6522 skip_env "Need free space $need_KB, have $free_KB" && return
6524 echo "Creating $count ${size_KB}K test files"
6525 for ((i = 0; i < $count; i++)); do
6526 dd if=/dev/zero of=$file.$i bs=$bsize count=$size_KB 2>/dev/null
6529 echo "Cancel LRU locks on lustre client to flush the client cache"
6530 cancel_lru_locks osc
6532 echo "Reset readahead stats"
6533 $LCTL set_param -n llite.*.read_ahead_stats 0
6535 for ((i = 0; i < $count; i++)); do
6536 dd if=$file.$i of=/dev/null bs=$bsize count=$size_KB 2>/dev/null
6539 local miss=$($LCTL get_param -n llite.*.read_ahead_stats |
6540 get_named_value 'misses' | cut -d" " -f1 | calc_total)
6542 for ((i = 0; i < $count; i++)); do
6543 rm -rf $file.$i 2>/dev/null
6546 #10000 means 20% reads are missing in readahead
6547 [[ $miss -lt 10000 ]] || error "misses too much for small reads"
6549 run_test 101e "check read-ahead for small read(1k) for small files(500k)"
6551 cleanup_test101f() {
6553 $LCTL set_param -n llite.*.max_read_ahead_whole_mb $MAX_WHOLE_MB
6554 rm -rf $DIR/$tfile 2>/dev/null
6558 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6559 local file=$DIR/$tfile
6562 MAX_WHOLE_MB=$($LCTL get_param -n llite.*.max_read_ahead_whole_mb)
6563 $LCTL set_param -n llite.*.max_read_ahead_whole_mb 2
6564 dd if=/dev/zero of=${file} bs=2097152 count=1 2>/dev/null
6565 trap cleanup_test101f EXIT
6567 echo Cancel LRU locks on lustre client to flush the client cache
6568 cancel_lru_locks osc
6570 echo Reset readahead stats
6571 $LCTL set_param -n llite.*.read_ahead_stats 0
6572 # Random read in a 2M file, because max_read_ahead_whole_mb = 2M,
6573 # readahead should read in 2M file on second read, so only miss
6575 echo Random 4K reads on 2M file for 1000 times
6576 $READS -f $file -s 2097152 -b 4096 -n $nreads
6578 echo checking missing pages
6579 local miss=$($LCTL get_param -n llite.*.read_ahead_stats |
6580 get_named_value 'misses' | cut -d" " -f1 | calc_total)
6582 [ $miss -lt 3 ] || error "misses too much pages!"
6585 run_test 101f "check read-ahead for max_read_ahead_whole_mb"
6588 test_mkdir -p $DIR/$tdir
6589 chown $RUNAS_ID $DIR/$tdir
6592 STRIPE_COUNT=$OSTCOUNT
6593 [[ $OSTCOUNT -gt 4 ]] && STRIPE_COUNT=4
6595 trap cleanup_test102 EXIT
6597 $1 $SETSTRIPE -S $STRIPE_SIZE -i $STRIPE_OFFSET -c $STRIPE_COUNT $tdir
6599 for num in 1 2 3 4; do
6600 for count in $(seq 1 $STRIPE_COUNT); do
6601 for idx in $(seq 0 $[$STRIPE_COUNT - 1]); do
6602 local size=`expr $STRIPE_SIZE \* $num`
6603 local file=file"$num-$idx-$count"
6604 $1 $SETSTRIPE -S $size -i $idx -c $count $file
6610 $1 $TAR cf $TMP/f102.tar $tdir --xattrs
6616 rm -rf $DIR/d0.sanity/d102
6620 local testfile=$DIR/$tfile
6624 [ "$UID" != 0 ] && skip_env "must run as root" && return
6625 [ -z "$(lctl get_param -n mdc.*-mdc-*.connect_flags | grep xattr)" ] &&
6626 skip_env "must have user_xattr" && return
6628 [ -z "$(which setfattr 2>/dev/null)" ] &&
6629 skip_env "could not find setfattr" && return
6631 echo "set/get xattr..."
6632 setfattr -n trusted.name1 -v value1 $testfile ||
6633 error "setfattr -n trusted.name1=value1 $testfile failed"
6634 getfattr -n trusted.name1 $testfile 2> /dev/null |
6635 grep "trusted.name1=.value1" ||
6636 error "$testfile missing trusted.name1=value1"
6638 setfattr -n user.author1 -v author1 $testfile ||
6639 error "setfattr -n user.author1=author1 $testfile failed"
6640 getfattr -n user.author1 $testfile 2> /dev/null |
6641 grep "user.author1=.author1" ||
6642 error "$testfile missing trusted.author1=author1"
6645 setfattr -n trusted.name2 -v value2 $testfile ||
6646 error "$testfile unable to set trusted.name2"
6647 setfattr -n trusted.name3 -v value3 $testfile ||
6648 error "$testfile unable to set trusted.name3"
6649 [ $(getfattr -d -m "^trusted" $testfile 2> /dev/null |
6650 grep "trusted.name" | wc -l) -eq 3 ] ||
6651 error "$testfile missing 3 trusted.name xattrs"
6653 setfattr -n user.author2 -v author2 $testfile ||
6654 error "$testfile unable to set user.author2"
6655 setfattr -n user.author3 -v author3 $testfile ||
6656 error "$testfile unable to set user.author3"
6657 [ $(getfattr -d -m "^user" $testfile 2> /dev/null |
6658 grep "user.author" | wc -l) -eq 3 ] ||
6659 error "$testfile missing 3 user.author xattrs"
6661 echo "remove xattr..."
6662 setfattr -x trusted.name1 $testfile ||
6663 error "$testfile error deleting trusted.name1"
6664 getfattr -d -m trusted $testfile 2> /dev/null | grep "trusted.name1" &&
6665 error "$testfile did not delete trusted.name1 xattr"
6667 setfattr -x user.author1 $testfile ||
6668 error "$testfile error deleting user.author1"
6669 getfattr -d -m user $testfile 2> /dev/null | grep "user.author1" &&
6670 error "$testfile did not delete trusted.name1 xattr"
6672 # b10667: setting lustre special xattr be silently discarded
6673 echo "set lustre special xattr ..."
6674 setfattr -n "trusted.lov" -v "invalid value" $testfile ||
6675 error "$testfile allowed setting trusted.lov"
6677 run_test 102a "user xattr test =================================="
6680 [ -z "$(which setfattr 2>/dev/null)" ] &&
6681 skip_env "could not find setfattr" && return
6683 # b10930: get/set/list trusted.lov xattr
6684 echo "get/set/list trusted.lov xattr ..."
6685 [[ $OSTCOUNT -lt 2 ]] && skip_env "skipping 2-stripe test" && return
6686 local testfile=$DIR/$tfile
6687 $SETSTRIPE -S 65536 -i 1 -c $OSTCOUNT $testfile ||
6688 error "setstripe failed"
6689 local STRIPECOUNT=$($GETSTRIPE -c $testfile) ||
6690 error "getstripe failed"
6691 getfattr -d -m "^trusted" $testfile 2>/dev/null | grep "trusted.lov" ||
6692 error "can't get trusted.lov from $testfile"
6694 local testfile2=${testfile}2
6695 local value=$(getfattr -n trusted.lov $testfile 2>/dev/null |
6696 grep "trusted.lov" | sed -e 's/[^=]\+=//')
6699 setfattr -n trusted.lov -v $value $testfile2
6700 local stripe_size=$($GETSTRIPE -S $testfile2)
6701 local stripe_count=$($GETSTRIPE -c $testfile2)
6702 [[ $stripe_size -eq 65536 ]] ||
6703 error "stripe size $stripe_size != 65536"
6704 [[ $stripe_count -eq $STRIPECOUNT ]] ||
6705 error "stripe count $stripe_count != $STRIPECOUNT"
6708 run_test 102b "getfattr/setfattr for trusted.lov EAs ============"
6711 [ -z "$(which setfattr 2>/dev/null)" ] &&
6712 skip_env "could not find setfattr" && return
6714 # b10930: get/set/list lustre.lov xattr
6715 echo "get/set/list lustre.lov xattr ..."
6716 [[ $OSTCOUNT -lt 2 ]] && skip_env "skipping 2-stripe test" && return
6717 test_mkdir -p $DIR/$tdir
6718 chown $RUNAS_ID $DIR/$tdir
6719 local testfile=$DIR/$tdir/$tfile
6720 $RUNAS $SETSTRIPE -S 65536 -i 1 -c $OSTCOUNT $testfile ||
6721 error "setstripe failed"
6722 local STRIPECOUNT=$($RUNAS $GETSTRIPE -c $testfile) ||
6723 error "getstripe failed"
6724 $RUNAS getfattr -d -m "^lustre" $testfile 2> /dev/null | \
6725 grep "lustre.lov" || error "can't get lustre.lov from $testfile"
6727 local testfile2=${testfile}2
6728 local value=`getfattr -n lustre.lov $testfile 2> /dev/null | \
6729 grep "lustre.lov" |sed -e 's/[^=]\+=//' `
6731 $RUNAS $MCREATE $testfile2
6732 $RUNAS setfattr -n lustre.lov -v $value $testfile2
6733 local stripe_size=$($RUNAS $GETSTRIPE -S $testfile2)
6734 local stripe_count=$($RUNAS $GETSTRIPE -c $testfile2)
6735 [ $stripe_size -eq 65536 ] || error "stripe size $stripe_size != 65536"
6736 [ $stripe_count -eq $STRIPECOUNT ] ||
6737 error "stripe count $stripe_count != $STRIPECOUNT"
6739 run_test 102c "non-root getfattr/setfattr for lustre.lov EAs ==========="
6741 compare_stripe_info1() {
6742 local stripe_index_all_zero=true
6744 for num in 1 2 3 4; do
6745 for count in $(seq 1 $STRIPE_COUNT); do
6746 for offset in $(seq 0 $[$STRIPE_COUNT - 1]); do
6747 local size=$((STRIPE_SIZE * num))
6748 local file=file"$num-$offset-$count"
6749 stripe_size=$($LFS getstripe -S $PWD/$file)
6750 [[ $stripe_size -ne $size ]] &&
6751 error "$file: size $stripe_size != $size"
6752 stripe_count=$($LFS getstripe -c $PWD/$file)
6753 # allow fewer stripes to be created, ORI-601
6754 [[ $stripe_count -lt $(((3 * count + 3) / 4)) ]] &&
6755 error "$file: count $stripe_count != $count"
6756 stripe_index=$($LFS getstripe -i $PWD/$file)
6757 [[ $stripe_index -ne 0 ]] &&
6758 stripe_index_all_zero=false
6762 $stripe_index_all_zero &&
6763 error "all files are being extracted starting from OST index 0"
6768 [ -n "$(which tar 2>/dev/null)" ] &&
6769 strings $(which tar) | grep -q "lustre" && echo tar
6773 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6774 # b10930: tar test for trusted.lov xattr
6775 TAR=$(find_lustre_tar)
6776 [ -z "$TAR" ] && skip_env "lustre-aware tar is not installed" && return
6777 [[ $OSTCOUNT -lt 2 ]] && skip_env "skipping N-stripe test" && return
6779 test_mkdir -p $DIR/d102d
6780 $TAR xf $TMP/f102.tar -C $DIR/d102d --xattrs
6782 compare_stripe_info1
6784 run_test 102d "tar restore stripe info from tarfile,not keep osts ==========="
6787 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6788 # b10930: tar test for trusted.lov xattr
6789 TAR=$(find_lustre_tar)
6790 [ -z "$TAR" ] && skip_env "lustre-aware tar is not installed" && return
6791 [[ $OSTCOUNT -lt 2 ]] && skip_env "skipping N-stripe test" && return
6793 test_mkdir -p $DIR/d102f
6795 $TAR cf - --xattrs $tdir | $TAR xf - --xattrs -C $DIR/d102f
6797 compare_stripe_info1
6799 run_test 102f "tar copy files, not keep osts ==========="
6802 local xsize=${1:-1024} # in bytes
6803 local file=$DIR/$tfile
6805 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep xattr)" ] &&
6806 skip "must have user_xattr" && return 0
6807 [ -z "$(which setfattr 2>/dev/null)" ] &&
6808 skip_env "could not find setfattr" && return 0
6809 [ -z "$(which getfattr 2>/dev/null)" ] &&
6810 skip_env "could not find getfattr" && return 0
6814 local value="$(generate_string $xsize)"
6816 local xbig=trusted.big
6817 log "save $xbig on $file"
6818 setfattr -n $xbig -v $value $file ||
6819 error "saving $xbig on $file failed"
6821 local orig=$(get_xattr_value $xbig $file)
6822 [[ "$orig" != "$value" ]] && error "$xbig different after saving $xbig"
6824 local xsml=trusted.sml
6825 log "save $xsml on $file"
6826 setfattr -n $xsml -v val $file || error "saving $xsml on $file failed"
6828 local new=$(get_xattr_value $xbig $file)
6829 [[ "$new" != "$orig" ]] && error "$xbig different after saving $xsml"
6831 log "grow $xsml on $file"
6832 setfattr -n $xsml -v "$value" $file ||
6833 error "growing $xsml on $file failed"
6835 new=$(get_xattr_value $xbig $file)
6836 [[ "$new" != "$orig" ]] && error "$xbig different after growing $xsml"
6837 log "$xbig still valid after growing $xsml"
6842 test_102h() { # bug 15777
6845 run_test 102h "grow xattr from inside inode to external block"
6848 large_xattr_enabled || { skip "large_xattr disabled" && return; }
6849 grow_xattr $(max_xattr_size)
6851 run_test 102ha "grow xattr from inside inode to external inode"
6853 test_102i() { # bug 17038
6854 [ -z "$(which getfattr 2>/dev/null)" ] &&
6855 skip "could not find getfattr" && return
6857 ln -s $DIR/$tfile $DIR/${tfile}link
6858 getfattr -n trusted.lov $DIR/$tfile ||
6859 error "lgetxattr on $DIR/$tfile failed"
6860 getfattr -h -n trusted.lov $DIR/${tfile}link 2>&1 |
6861 grep -i "no such attr" ||
6862 error "error for lgetxattr on $DIR/${tfile}link is not ENODATA"
6863 rm -f $DIR/$tfile $DIR/${tfile}link
6865 run_test 102i "lgetxattr test on symbolic link ============"
6868 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6869 TAR=$(find_lustre_tar)
6870 [ -z "$TAR" ] && skip_env "lustre-aware tar is not installed" && return
6871 [[ $OSTCOUNT -lt 2 ]] && skip_env "skipping N-stripe test" && return
6872 setup_test102 "$RUNAS"
6873 test_mkdir -p $DIR/d102j
6874 chown $RUNAS_ID $DIR/d102j
6875 $RUNAS $TAR xf $TMP/f102.tar -C $DIR/d102j --xattrs
6877 compare_stripe_info1 "$RUNAS"
6879 run_test 102j "non-root tar restore stripe info from tarfile, not keep osts ==="
6882 [ -z "$(which setfattr 2>/dev/null)" ] &&
6883 skip "could not find setfattr" && return
6885 # b22187 just check that does not crash for regular file.
6886 setfattr -n trusted.lov $DIR/$tfile
6887 # b22187 'setfattr -n trusted.lov' should work as remove LOV EA for directories
6888 local test_kdir=$DIR/d102k
6889 test_mkdir $test_kdir
6890 local default_size=`$GETSTRIPE -S $test_kdir`
6891 local default_count=`$GETSTRIPE -c $test_kdir`
6892 local default_offset=`$GETSTRIPE -i $test_kdir`
6893 $SETSTRIPE -S 65536 -i 0 -c $OSTCOUNT $test_kdir ||
6894 error 'dir setstripe failed'
6895 setfattr -n trusted.lov $test_kdir
6896 local stripe_size=`$GETSTRIPE -S $test_kdir`
6897 local stripe_count=`$GETSTRIPE -c $test_kdir`
6898 local stripe_offset=`$GETSTRIPE -i $test_kdir`
6899 [ $stripe_size -eq $default_size ] ||
6900 error "stripe size $stripe_size != $default_size"
6901 [ $stripe_count -eq $default_count ] ||
6902 error "stripe count $stripe_count != $default_count"
6903 [ $stripe_offset -eq $default_offset ] ||
6904 error "stripe offset $stripe_offset != $default_offset"
6905 rm -rf $DIR/$tfile $test_kdir
6907 run_test 102k "setfattr without parameter of value shouldn't cause a crash"
6910 [ -z "$(which getfattr 2>/dev/null)" ] &&
6911 skip "could not find getfattr" && return
6913 # LU-532 trusted. xattr is invisible to non-root
6914 local testfile=$DIR/$tfile
6918 echo "listxattr as user..."
6919 chown $RUNAS_ID $testfile
6920 $RUNAS getfattr -d -m '.*' $testfile 2>&1 |
6921 grep -q "trusted" &&
6922 error "$testfile trusted xattrs are user visible"
6926 run_test 102l "listxattr size test =================================="
6928 test_102m() { # LU-3403 llite: error of listxattr when buffer is small
6929 local path=$DIR/$tfile
6932 listxattr_size_check $path || error "listattr_size_check $path failed"
6934 run_test 102m "Ensure listxattr fails on small bufffer ========"
6938 getxattr() { # getxattr path name
6939 # Return the base64 encoding of the value of xattr name on path.
6943 # # getfattr --absolute-names --encoding=base64 --name=trusted.lov $path
6945 # trusted.lov=0s0AvRCwEAAAAGAAAAAAAAAAAEAAACAAAAAAAQAAEAA...AAAAAAAAA=
6947 # We print just 0s0AvRCwEAAAAGAAAAAAAAAAAEAAACAAAAAAAQAAEAA...AAAAAAAAA=
6949 getfattr --absolute-names --encoding=base64 --name=$name $path |
6950 awk -F= -v name=$name '$1 == name {
6951 print substr($0, index($0, "=") + 1);
6955 test_102n() { # LU-4101 mdt: protect internal xattrs
6956 local file0=$DIR/$tfile.0
6957 local file1=$DIR/$tfile.1
6958 local xattr0=$TMP/$tfile.0
6959 local xattr1=$TMP/$tfile.1
6963 [ -z "$(which setfattr 2>/dev/null)" ] &&
6964 skip "could not find setfattr" && return
6966 if [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.5.50) ]
6968 skip "MDT < 2.5.50 allows setxattr on internal trusted xattrs"
6972 rm -rf $file0 $file1 $xattr0 $xattr1
6975 # Get 'before' xattrs of $file1.
6976 getfattr --absolute-names --dump --match=- $file1 > $xattr0
6978 for name in lov lma lmv link fid version som hsm lfsck_namespace; do
6979 # Try to copy xattr from $file0 to $file1.
6980 value=$(getxattr $file0 trusted.$name 2> /dev/null)
6982 setfattr --name=trusted.$name --value="$value" $file1 ||
6983 error "setxattr 'trusted.$name' failed"
6985 # Try to set a garbage xattr.
6986 value=0sVGhlIHF1aWNrIGJyb3duIGZveCBqdW1wcyBvdmVyIGl0c2VsZi4=
6988 setfattr --name=trusted.$name --value="$value" $file1 ||
6989 error "setxattr 'trusted.$name' failed"
6991 # Try to remove the xattr from $file1. We don't care if this
6992 # appears to succeed or fail, we just don't want there to be
6993 # any changes or crashes.
6994 setfattr --remove=$trusted.$name $file1 2> /dev/null
6997 if [ $(lustre_version_code $SINGLEMDS) -gt $(version_code 2.6.50) ]
7000 # Try to copy xattr from $file0 to $file1.
7001 value=$(getxattr $file0 trusted.$name 2> /dev/null)
7003 setfattr --name=trusted.$name --value="$value" $file1 ||
7004 error "setxattr 'trusted.$name' failed"
7006 # Try to set a garbage xattr.
7007 value=0sVGhlIHF1aWNrIGJyb3duIGZveCBqdW1wcyBvdmVyIGl0c2VsZi4=
7009 setfattr --name=trusted.$name --value="$value" $file1 ||
7010 error "setxattr 'trusted.$name' failed"
7012 # Try to remove the xattr from $file1. We don't care if this
7013 # appears to succeed or fail, we just don't want there to be
7014 # any changes or crashes.
7015 setfattr --remove=$trusted.$name $file1 2> /dev/null
7018 # Get 'after' xattrs of file1.
7019 getfattr --absolute-names --dump --match=- $file1 > $xattr1
7021 if ! diff $xattr0 $xattr1; then
7022 error "before and after xattrs of '$file1' differ"
7025 rm -rf $file0 $file1 $xattr0 $xattr1
7029 run_test 102n "silently ignore setxattr on internal trusted xattrs"
7031 test_102p() { # LU-4703 setxattr did not check ownership
7032 local testfile=$DIR/$tfile
7034 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.5.56) ] &&
7035 skip "MDS needs to be at least 2.5.56" && return
7039 echo "setfacl as user..."
7040 $RUNAS setfacl -m "u:$RUNAS_ID:rwx" $testfile
7041 [ $? -ne 0 ] || error "setfacl by $RUNAS_ID was allowed on $testfile"
7043 echo "setfattr as user..."
7044 setfacl -m "u:$RUNAS_ID:---" $testfile
7045 $RUNAS setfattr -x system.posix_acl_access $testfile
7046 [ $? -ne 0 ] || error "setfattr by $RUNAS_ID was allowed on $testfile"
7048 run_test 102p "check setxattr(2) correctly fails without permission"
7051 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.6.92) ] &&
7052 skip "MDS needs to be at least 2.6.92" && return
7053 orphan_linkea_check $DIR/$tfile || error "orphan_linkea_check"
7055 run_test 102q "flistxattr should not return trusted.link EAs for orphans"
7058 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.6.93) ] &&
7059 skip "MDS needs to be at least 2.6.93" && return
7060 touch $DIR/$tfile || error "touch"
7061 setfattr -n user.$(basename $tfile) $DIR/$tfile || error "setfattr"
7062 getfattr -n user.$(basename $tfile) $DIR/$tfile || error "getfattr"
7063 rm $DIR/$tfile || error "rm"
7066 mkdir -p $DIR/$tdir || error "mkdir"
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 "rmdir"
7077 test_mkdir -p $DIR/$tdir || error "make striped dir"
7078 setfattr -n user.$(basename $tdir) $DIR/$tdir || error "setfattr dir"
7079 getfattr -n user.$(basename $tdir) $DIR/$tdir || error "getfattr dir"
7080 setfattr -x user.$(basename $tdir) $DIR/$tdir ||
7081 error "$testfile error deleting user.author1"
7082 getfattr -d -m user.$(basename $tdir) 2> /dev/null |
7083 grep "user.$(basename $tdir)" &&
7084 error "$tdir did not delete user.$(basename $tdir)"
7085 rmdir $DIR/$tdir || error "rm striped dir"
7087 run_test 102r "set EAs with empty values"
7091 $LUSTRE/tests/acl/run $LUSTRE/tests/acl/$1.test
7096 [ "$UID" != 0 ] && skip_env "must run as root" && return
7097 [ -z "$(lctl get_param -n mdc.*-mdc-*.connect_flags | grep acl)" ] &&
7098 skip "must have acl enabled" && return
7099 [ -z "$(which setfacl 2>/dev/null)" ] &&
7100 skip_env "could not find setfacl" && return
7101 $GSS && skip "could not run under gss" && return
7103 gpasswd -a daemon bin # LU-5641
7104 do_facet $SINGLEMDS gpasswd -a daemon bin # LU-5641
7106 declare -a identity_old
7108 for num in $(seq $MDSCOUNT); do
7109 switch_identity $num true || identity_old[$num]=$?
7116 echo "performing cp ..."
7117 run_acl_subtest cp || error "run_acl_subtest cp failed"
7118 echo "performing getfacl-noacl..."
7119 run_acl_subtest getfacl-noacl || error "getfacl-noacl test failed"
7120 echo "performing misc..."
7121 run_acl_subtest misc || error "misc test failed"
7122 echo "performing permissions..."
7123 run_acl_subtest permissions || error "permissions failed"
7124 echo "performing setfacl..."
7125 run_acl_subtest setfacl || error "setfacl test failed"
7127 # inheritance test got from HP
7128 echo "performing inheritance..."
7129 cp $LUSTRE/tests/acl/make-tree . || error "cannot copy make-tree"
7130 chmod +x make-tree || error "chmod +x failed"
7131 run_acl_subtest inheritance || error "inheritance test failed"
7134 echo "LU-974 ignore umask when acl is enabled..."
7135 run_acl_subtest 974 || error "LU-974 umask test failed"
7136 if [ $MDSCOUNT -ge 2 ]; then
7137 run_acl_subtest 974_remote ||
7138 error "LU-974 umask test failed under remote dir"
7141 echo "LU-2561 newly created file is same size as directory..."
7142 if [ $(facet_fstype $SINGLEMDS) != "zfs" ]; then
7143 run_acl_subtest 2561 || error "LU-2561 test failed"
7145 run_acl_subtest 2561_zfs || error "LU-2561 zfs test failed"
7148 run_acl_subtest 4924 || error "LU-4924 test failed"
7153 for num in $(seq $MDSCOUNT); do
7154 if [ "${identity_old[$num]}" = 1 ]; then
7155 switch_identity $num false || identity_old[$num]=$?
7159 run_test 103a "acl test ========================================="
7163 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
7164 local mountopts=$MDS_MOUNT_OPTS
7166 if [[ "$MDS_MOUNT_OPTS" =~ "noacl" ]]; then
7170 stop $SINGLEMDS || error "failed to stop MDT."
7172 if [ -z "$MDS_MOUNT_OPTS" ]; then
7173 MDS_MOUNT_OPTS="-o noacl"
7175 MDS_MOUNT_OPTS="${MDS_MOUNT_OPTS},noacl"
7177 start $SINGLEMDS $MDT_DEV $MDS_MOUNT_OPTS ||
7178 error "failed to start MDT."
7179 MDS_MOUNT_OPTS=$mountopts
7183 setfacl -m u:bin:rw $DIR/$tfile && error "setfacl should fail"
7187 stop $SINGLEMDS || error "failed to stop MDT."
7189 start $SINGLEMDS $MDT_DEV $MDS_MOUNT_OPTS ||
7190 error "failed to start MDT."
7195 run_test 103b "MDS mount option 'noacl'"
7199 cp -rp $DIR/$tdir $DIR/$tdir.bak
7201 [ -n "$(getfattr -d -m. $DIR/$tdir | grep posix_acl_default)" ] &&
7202 error "$DIR/$tdir shouldn't contain default ACL"
7203 [ -n "$(getfattr -d -m. $DIR/$tdir.bak | grep posix_acl_default)" ] &&
7204 error "$DIR/$tdir.bak shouldn't contain default ACL"
7207 run_test 103c "'cp -rp' won't set empty acl"
7210 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7212 lfs df || error "lfs df failed"
7213 lfs df -ih || error "lfs df -ih failed"
7214 lfs df -h $DIR || error "lfs df -h $DIR failed"
7215 lfs df -i $DIR || error "lfs df -i $DIR failed"
7216 lfs df $DIR/$tfile || error "lfs df $DIR/$tfile failed"
7217 lfs df -ih $DIR/$tfile || error "lfs df -ih $DIR/$tfile failed"
7219 local OSC=$(lctl dl | grep OST0000-osc-[^M] | awk '{ print $4 }')
7220 lctl --device %$OSC deactivate
7221 lfs df || error "lfs df with deactivated OSC failed"
7222 lctl --device %$OSC activate
7223 # wait the osc back to normal
7224 wait_osc_import_state client ost FULL
7226 lfs df || error "lfs df with reactivated OSC failed"
7229 run_test 104a "lfs df [-ih] [path] test ========================="
7232 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7233 [ $RUNAS_ID -eq $UID ] &&
7234 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
7236 denied_cnt=$(($($RUNAS $LFS check servers 2>&1 |
7237 grep "Permission denied" | wc -l)))
7238 if [ $denied_cnt -ne 0 ]; then
7239 error "lfs check servers test failed"
7242 run_test 104b "$RUNAS lfs check servers test ===================="
7245 # doesn't work on 2.4 kernels
7247 if $(flock_is_enabled); then
7248 flocks_test 1 on -f $DIR/$tfile || error "fail flock on"
7250 flocks_test 1 off -f $DIR/$tfile || error "fail flock off"
7254 run_test 105a "flock when mounted without -o flock test ========"
7258 if $(flock_is_enabled); then
7259 flocks_test 1 on -c $DIR/$tfile || error "fail flock on"
7261 flocks_test 1 off -c $DIR/$tfile || error "fail flock off"
7265 run_test 105b "fcntl when mounted without -o flock test ========"
7269 if $(flock_is_enabled); then
7270 flocks_test 1 on -l $DIR/$tfile || error "fail flock on"
7272 flocks_test 1 off -l $DIR/$tfile || error "fail flock off"
7276 run_test 105c "lockf when mounted without -o flock test ========"
7278 test_105d() { # bug 15924
7279 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7280 test_mkdir -p $DIR/$tdir
7281 flock_is_enabled || { skip "mount w/o flock enabled" && return; }
7282 #define OBD_FAIL_LDLM_CP_CB_WAIT 0x315
7283 $LCTL set_param fail_loc=0x80000315
7284 flocks_test 2 $DIR/$tdir
7286 run_test 105d "flock race (should not freeze) ========"
7288 test_105e() { # bug 22660 && 22040
7289 flock_is_enabled || { skip "mount w/o flock enabled" && return; }
7291 flocks_test 3 $DIR/$tfile
7293 run_test 105e "Two conflicting flocks from same process ======="
7295 test_106() { #bug 10921
7296 test_mkdir -p $DIR/$tdir
7297 $DIR/$tdir && error "exec $DIR/$tdir succeeded"
7298 chmod 777 $DIR/$tdir || error "chmod $DIR/$tdir failed"
7300 run_test 106 "attempt exec of dir followed by chown of that dir"
7303 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7310 local save_pattern=$(sysctl -n kernel.core_pattern)
7311 local save_uses_pid=$(sysctl -n kernel.core_uses_pid)
7312 sysctl -w kernel.core_pattern=$file
7313 sysctl -w kernel.core_uses_pid=0
7321 kill -s 11 $SLEEPPID
7323 if [ -e $file ]; then
7324 size=`stat -c%s $file`
7325 [ $size -eq 0 ] && error "Fail to create core file $file"
7327 error "Fail to create core file $file"
7330 sysctl -w kernel.core_pattern=$save_pattern
7331 sysctl -w kernel.core_uses_pid=$save_uses_pid
7334 run_test 107 "Coredump on SIG"
7337 test_mkdir -p $DIR/$tdir
7338 test_mkdir $DIR/$tdir/$(str_repeat 'a' 255) ||
7339 error "mkdir with 255 char failed"
7340 test_mkdir $DIR/$tdir/$(str_repeat 'b' 256) &&
7341 error "mkdir with 256 char should fail, but did not"
7342 touch $DIR/$tdir/$(str_repeat 'x' 255) ||
7343 error "create with 255 char failed"
7344 touch $DIR/$tdir/$(str_repeat 'y' 256) &&
7345 error "create with 256 char should fail, but did not"
7350 run_test 110 "filename length checking"
7353 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7354 OSTIO_pre=$(ps -e | grep ll_ost_io | awk '{ print $4 }'| sort -n |
7355 tail -1 | cut -c11-20)
7356 [ -z "$OSTIO_pre" ] && skip "no OSS threads" && return
7357 echo "Starting with $OSTIO_pre threads"
7360 NUMFREE=$(df -i -P $DIR | tail -n 1 | awk '{ print $4 }')
7361 [[ $NUMFREE -lt $NUMTEST ]] && NUMTEST=$(($NUMFREE - 1000))
7362 echo "$NUMTEST creates/unlinks"
7363 test_mkdir -p $DIR/$tdir
7364 createmany -o $DIR/$tdir/$tfile $NUMTEST
7365 unlinkmany $DIR/$tdir/$tfile $NUMTEST
7367 OSTIO_post=$(ps -e | grep ll_ost_io | awk '{ print $4 }' | sort -n |
7368 tail -1 | cut -c11-20)
7370 # don't return an error
7371 [ $OSTIO_post == $OSTIO_pre ] && echo \
7372 "WARNING: No new ll_ost_io threads were created ($OSTIO_pre)" &&
7373 echo "This may be fine, depending on what ran before this test" &&
7374 echo "and how fast this system is." && return
7376 echo "Started with $OSTIO_pre threads, ended with $OSTIO_post"
7378 run_test 115 "verify dynamic thread creation===================="
7381 wait_delete_completed
7382 AVAIL=($(lctl get_param -n osc.*[oO][sS][cC]-[^M]*.kbytesavail))
7383 echo OST kbytes available: ${AVAIL[@]}
7384 MAXI=0; MAXV=${AVAIL[0]}
7385 MINI=0; MINV=${AVAIL[0]}
7386 for ((i = 0; i < ${#AVAIL[@]}; i++)); do
7387 #echo OST $i: ${AVAIL[i]}kb
7388 if [[ ${AVAIL[i]} -gt $MAXV ]]; then
7389 MAXV=${AVAIL[i]}; MAXI=$i
7391 if [[ ${AVAIL[i]} -lt $MINV ]]; then
7392 MINV=${AVAIL[i]}; MINI=$i
7395 echo Min free space: OST $MINI: $MINV
7396 echo Max free space: OST $MAXI: $MAXV
7399 test_116a() { # was previously test_116()
7400 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7401 remote_mds_nodsh && skip "remote MDS with nodsh" && return
7403 [[ $OSTCOUNT -lt 2 ]] && skip_env "$OSTCOUNT < 2 OSTs" && return
7405 echo -n "Free space priority "
7406 do_facet $SINGLEMDS lctl get_param -n lo*.*-mdtlov.qos_prio_free |
7411 [ $MINV -eq 0 ] && skip "no free space in OST$MINI, skip" && return
7412 [ $MINV -gt 10000000 ] && skip "too much free space in OST$MINI, skip" \
7414 trap simple_cleanup_common EXIT
7417 # Check if we need to generate uneven OSTs
7418 test_mkdir -p $DIR/$tdir/OST${MINI}
7419 local FILL=$(($MINV / 4))
7420 local DIFF=$(($MAXV - $MINV))
7421 local DIFF2=$(($DIFF * 100 / $MINV))
7423 local threshold=$(do_facet $SINGLEMDS \
7424 lctl get_param -n *.*MDT0000-mdtlov.qos_threshold_rr | head -n1)
7425 threshold=${threshold%%%}
7426 echo -n "Check for uneven OSTs: "
7427 echo -n "diff=${DIFF}KB (${DIFF2}%) must be > ${threshold}% ..."
7429 if [[ $DIFF2 -gt $threshold ]]; then
7431 echo "Don't need to fill OST$MINI"
7433 # generate uneven OSTs. Write 2% over the QOS threshold value
7435 DIFF=$(($threshold - $DIFF2 + 2))
7436 DIFF2=$(( ($MINV * $DIFF)/100 ))
7437 echo "Fill ${DIFF}% remaining space in OST${MINI} with ${DIFF2}KB"
7438 $SETSTRIPE -i $MINI -c 1 $DIR/$tdir/OST${MINI} ||
7439 error "setstripe failed"
7440 DIFF=$(($DIFF2 / 2048))
7442 while [ $i -lt $DIFF ]; do
7444 dd if=/dev/zero of=$DIR/$tdir/OST${MINI}/$tfile-$i \
7445 bs=2M count=1 2>/dev/null
7454 DIFF=$(($MAXV - $MINV))
7455 DIFF2=$(($DIFF * 100 / $MINV))
7456 echo -n "diff=${DIFF}=${DIFF2}% must be > ${threshold}% for QOS mode..."
7457 if [[ $DIFF2 -gt $threshold ]]; then
7460 echo "failed - QOS mode won't be used"
7461 skip "QOS imbalance criteria not met"
7462 simple_cleanup_common
7466 MINI1=$MINI; MINV1=$MINV
7467 MAXI1=$MAXI; MAXV1=$MAXV
7469 # now fill using QOS
7470 $SETSTRIPE -c 1 $DIR/$tdir
7471 FILL=$(($FILL / 200))
7472 if [ $FILL -gt 600 ]; then
7475 echo "writing $FILL files to QOS-assigned OSTs"
7477 while [ $i -lt $FILL ]; do
7479 dd if=/dev/zero of=$DIR/$tdir/$tfile-$i bs=200k \
7483 echo "wrote $i 200k files"
7487 echo "Note: free space may not be updated, so measurements might be off"
7489 DIFF2=$(($MAXV - $MINV))
7490 echo "free space delta: orig $DIFF final $DIFF2"
7491 [ $DIFF2 -gt $DIFF ] && echo "delta got worse!"
7492 DIFF=$(($MINV1 - ${AVAIL[$MINI1]}))
7493 echo "Wrote ${DIFF}KB to smaller OST $MINI1"
7494 DIFF2=$(($MAXV1 - ${AVAIL[$MAXI1]}))
7495 echo "Wrote ${DIFF2}KB to larger OST $MAXI1"
7496 FILL=$(($DIFF2 * 100 / $DIFF - 100))
7498 echo "Wrote ${FILL}% more data to larger OST $MAXI1"
7500 # Figure out which files were written where
7501 UUID=$(lctl get_param -n lov.${FSNAME}-clilov-*.target_obd |
7502 awk '/'$MINI1': / {print $2; exit}')
7504 MINC=$($GETSTRIPE --ost $UUID $DIR/$tdir | grep $DIR | wc -l)
7505 echo "$MINC files created on smaller OST $MINI1"
7506 UUID=$(lctl get_param -n lov.${FSNAME}-clilov-*.target_obd |
7507 awk '/'$MAXI1': / {print $2; exit}')
7509 MAXC=$($GETSTRIPE --ost $UUID $DIR/$tdir | grep $DIR | wc -l)
7510 echo "$MAXC files created on larger OST $MAXI1"
7511 FILL=$(($MAXC * 100 / $MINC - 100))
7512 [[ $MINC -gt 0 ]] &&
7513 echo "Wrote ${FILL}% more files to larger OST $MAXI1"
7514 [[ $MAXC -gt $MINC ]] ||
7515 error_ignore LU-9 "stripe QOS didn't balance free space"
7516 simple_cleanup_common
7518 run_test 116a "stripe QOS: free space balance ==================="
7520 test_116b() { # LU-2093
7521 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7522 remote_mds_nodsh && skip "remote MDS with nodsh" && return
7524 #define OBD_FAIL_MDS_OSC_CREATE_FAIL 0x147
7525 local old_rr=$(do_facet $SINGLEMDS lctl get_param -n \
7526 lo*.$FSNAME-MDT0000-mdtlov.qos_threshold_rr | head -1)
7527 [ -z "$old_rr" ] && skip "no QOS" && return 0
7528 do_facet $SINGLEMDS lctl set_param \
7529 lo*.$FSNAME-MDT0000-mdtlov.qos_threshold_rr=0
7531 do_facet $SINGLEMDS lctl set_param fail_loc=0x147
7532 createmany -o $DIR/$tdir/f- 20 || error "can't create"
7533 do_facet $SINGLEMDS lctl set_param fail_loc=0
7535 do_facet $SINGLEMDS lctl set_param \
7536 lo*.$FSNAME-MDT0000-mdtlov.qos_threshold_rr=$old_rr
7538 run_test 116b "QoS shouldn't LBUG if not enough OSTs found on the 2nd pass"
7540 test_117() # bug 10891
7542 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7543 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1
7544 #define OBD_FAIL_OST_SETATTR_CREDITS 0x21e
7545 lctl set_param fail_loc=0x21e
7546 > $DIR/$tfile || error "truncate failed"
7547 lctl set_param fail_loc=0
7548 echo "Truncate succeeded."
7551 run_test 117 "verify osd extend =========="
7553 NO_SLOW_RESENDCOUNT=4
7554 export OLD_RESENDCOUNT=""
7555 set_resend_count () {
7556 local PROC_RESENDCOUNT="osc.${FSNAME}-OST*-osc-*.resend_count"
7557 OLD_RESENDCOUNT=$(lctl get_param -n $PROC_RESENDCOUNT | head -n1)
7558 lctl set_param -n $PROC_RESENDCOUNT $1
7559 echo resend_count is set to $(lctl get_param -n $PROC_RESENDCOUNT)
7562 # for reduce test_118* time (b=14842)
7563 [ "$SLOW" = "no" ] && set_resend_count $NO_SLOW_RESENDCOUNT
7565 # Reset async IO behavior after error case
7567 FILE=$DIR/reset_async
7569 # Ensure all OSCs are cleared
7570 $SETSTRIPE -c -1 $FILE
7571 dd if=/dev/zero of=$FILE bs=64k count=$OSTCOUNT
7576 test_118a() #bug 11710
7578 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7581 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
7582 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
7583 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
7585 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
7586 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
7591 run_test 118a "verify O_SYNC works =========="
7595 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7596 remote_ost_nodsh && skip "remote OST with nodsh" && return
7600 #define OBD_FAIL_OST_ENOENT 0x217
7601 set_nodes_failloc "$(osts_nodes)" 0x217
7602 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
7604 set_nodes_failloc "$(osts_nodes)" 0
7605 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
7606 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
7609 if [[ $RC -eq 0 ]]; then
7610 error "Must return error due to dropped pages, rc=$RC"
7614 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
7615 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
7619 echo "Dirty pages not leaked on ENOENT"
7621 # Due to the above error the OSC will issue all RPCs syncronously
7622 # until a subsequent RPC completes successfully without error.
7623 $MULTIOP $DIR/$tfile Ow4096yc
7628 run_test 118b "Reclaim dirty pages on fatal error =========="
7632 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7634 # for 118c, restore the original resend count, LU-1940
7635 [ "$SLOW" = "no" ] && [ -n "$OLD_RESENDCOUNT" ] &&
7636 set_resend_count $OLD_RESENDCOUNT
7637 remote_ost_nodsh && skip "remote OST with nodsh" && return
7641 #define OBD_FAIL_OST_EROFS 0x216
7642 set_nodes_failloc "$(osts_nodes)" 0x216
7644 # multiop should block due to fsync until pages are written
7645 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
7649 if [[ `ps h -o comm -p $MULTIPID` != "multiop" ]]; then
7650 error "Multiop failed to block on fsync, pid=$MULTIPID"
7653 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
7655 if [[ $WRITEBACK -eq 0 ]]; then
7656 error "No page in writeback, writeback=$WRITEBACK"
7659 set_nodes_failloc "$(osts_nodes)" 0
7662 if [[ $RC -ne 0 ]]; then
7663 error "Multiop fsync failed, rc=$RC"
7666 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
7667 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
7669 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
7670 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
7674 echo "Dirty pages flushed via fsync on EROFS"
7677 run_test 118c "Fsync blocks on EROFS until dirty pages are flushed =========="
7679 # continue to use small resend count to reduce test_118* time (b=14842)
7680 [ "$SLOW" = "no" ] && set_resend_count $NO_SLOW_RESENDCOUNT
7684 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7685 remote_ost_nodsh && skip "remote OST with nodsh" && return
7689 #define OBD_FAIL_OST_BRW_PAUSE_BULK
7690 set_nodes_failloc "$(osts_nodes)" 0x214
7691 # multiop should block due to fsync until pages are written
7692 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
7696 if [[ `ps h -o comm -p $MULTIPID` != "multiop" ]]; then
7697 error "Multiop failed to block on fsync, pid=$MULTIPID"
7700 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
7702 if [[ $WRITEBACK -eq 0 ]]; then
7703 error "No page in writeback, writeback=$WRITEBACK"
7706 wait $MULTIPID || error "Multiop fsync failed, rc=$?"
7707 set_nodes_failloc "$(osts_nodes)" 0
7709 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
7710 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
7712 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
7713 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
7717 echo "Dirty pages gaurenteed flushed via fsync"
7720 run_test 118d "Fsync validation inject a delay of the bulk =========="
7723 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7726 #define OBD_FAIL_OSC_BRW_PREP_REQ2 0x40a
7727 lctl set_param fail_loc=0x8000040a
7729 # Should simulate EINVAL error which is fatal
7730 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
7732 if [[ $RC -eq 0 ]]; then
7733 error "Must return error due to dropped pages, rc=$RC"
7736 lctl set_param fail_loc=0x0
7738 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
7739 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
7740 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
7742 if [[ $LOCKED -ne 0 ]]; then
7743 error "Locked pages remain in cache, locked=$LOCKED"
7746 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
7747 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
7751 echo "No pages locked after fsync"
7756 run_test 118f "Simulate unrecoverable OSC side error =========="
7759 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7762 #define OBD_FAIL_OSC_BRW_PREP_REQ 0x406
7763 lctl set_param fail_loc=0x406
7765 # simulate local -ENOMEM
7766 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
7769 lctl set_param fail_loc=0
7770 if [[ $RC -eq 0 ]]; then
7771 error "Must return error due to dropped pages, rc=$RC"
7774 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
7775 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
7776 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
7778 if [[ $LOCKED -ne 0 ]]; then
7779 error "Locked pages remain in cache, locked=$LOCKED"
7782 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
7783 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
7787 echo "No pages locked after fsync"
7792 run_test 118g "Don't stay in wait if we got local -ENOMEM =========="
7795 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7796 remote_ost_nodsh && skip "remote OST with nodsh" && return
7800 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
7801 set_nodes_failloc "$(osts_nodes)" 0x20e
7802 # Should simulate ENOMEM error which is recoverable and should be handled by timeout
7803 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
7806 set_nodes_failloc "$(osts_nodes)" 0
7807 if [[ $RC -eq 0 ]]; then
7808 error "Must return error due to dropped pages, rc=$RC"
7811 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
7812 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
7813 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
7815 if [[ $LOCKED -ne 0 ]]; then
7816 error "Locked pages remain in cache, locked=$LOCKED"
7819 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
7820 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
7824 echo "No pages locked after fsync"
7828 run_test 118h "Verify timeout in handling recoverables errors =========="
7830 [ "$SLOW" = "no" ] && [ -n "$OLD_RESENDCOUNT" ] && set_resend_count $OLD_RESENDCOUNT
7833 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7834 remote_ost_nodsh && skip "remote OST with nodsh" && return
7838 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
7839 set_nodes_failloc "$(osts_nodes)" 0x20e
7841 # Should simulate ENOMEM error which is recoverable and should be handled by timeout
7842 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
7845 set_nodes_failloc "$(osts_nodes)" 0
7849 if [[ $RC -ne 0 ]]; then
7850 error "got error, but should be not, rc=$RC"
7853 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
7854 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
7855 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
7856 if [[ $LOCKED -ne 0 ]]; then
7857 error "Locked pages remain in cache, locked=$LOCKED"
7860 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
7861 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
7865 echo "No pages locked after fsync"
7869 run_test 118i "Fix error before timeout in recoverable error =========="
7871 [ "$SLOW" = "no" ] && set_resend_count 4
7874 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7875 remote_ost_nodsh && skip "remote OST with nodsh" && return
7879 #define OBD_FAIL_OST_BRW_WRITE_BULK2 0x220
7880 set_nodes_failloc "$(osts_nodes)" 0x220
7882 # return -EIO from OST
7883 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
7885 set_nodes_failloc "$(osts_nodes)" 0x0
7886 if [[ $RC -eq 0 ]]; then
7887 error "Must return error due to dropped pages, rc=$RC"
7890 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
7891 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
7892 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
7893 if [[ $LOCKED -ne 0 ]]; then
7894 error "Locked pages remain in cache, locked=$LOCKED"
7897 # in recoverable error on OST we want resend and stay until it finished
7898 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
7899 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
7903 echo "No pages locked after fsync"
7907 run_test 118j "Simulate unrecoverable OST side error =========="
7911 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7912 remote_ost_nodsh && skip "remote OSTs with nodsh" && return
7914 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
7915 set_nodes_failloc "$(osts_nodes)" 0x20e
7916 test_mkdir -p $DIR/$tdir
7918 for ((i=0;i<10;i++)); do
7919 (dd if=/dev/zero of=$DIR/$tdir/$tfile-$i bs=1M count=10 || \
7920 error "dd to $DIR/$tdir/$tfile-$i failed" )&
7927 set_nodes_failloc "$(osts_nodes)" 0
7930 run_test 118k "bio alloc -ENOMEM and IO TERM handling ========="
7934 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7936 test_mkdir -p $DIR/$tdir
7937 $MULTIOP $DIR/$tdir Dy || error "fsync dir failed"
7940 run_test 118l "fsync dir ========="
7942 test_118m() # LU-3066
7944 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7945 test_mkdir -p $DIR/$tdir
7946 $MULTIOP $DIR/$tdir DY || error "fdatasync dir failed"
7949 run_test 118m "fdatasync dir ========="
7951 [ "$SLOW" = "no" ] && [ -n "$OLD_RESENDCOUNT" ] && set_resend_count $OLD_RESENDCOUNT
7953 test_119a() # bug 11737
7955 BSIZE=$((512 * 1024))
7956 directio write $DIR/$tfile 0 1 $BSIZE
7957 # We ask to read two blocks, which is more than a file size.
7958 # directio will indicate an error when requested and actual
7959 # sizes aren't equeal (a normal situation in this case) and
7960 # print actual read amount.
7961 NOB=`directio read $DIR/$tfile 0 2 $BSIZE | awk '/error/ {print $6}'`
7962 if [ "$NOB" != "$BSIZE" ]; then
7963 error "read $NOB bytes instead of $BSIZE"
7967 run_test 119a "Short directIO read must return actual read amount"
7969 test_119b() # bug 11737
7971 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping 2-stripe test" && return
7973 $SETSTRIPE -c 2 $DIR/$tfile || error "setstripe failed"
7974 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=1 || error "dd failed"
7976 $MULTIOP $DIR/$tfile oO_RDONLY:O_DIRECT:r$((2048 * 1024)) || \
7977 error "direct read failed"
7980 run_test 119b "Sparse directIO read must return actual read amount"
7982 test_119c() # bug 13099
7985 directio write $DIR/$tfile 3 1 $BSIZE || error "direct write failed"
7986 directio readhole $DIR/$tfile 0 2 $BSIZE || error "reading hole failed"
7989 run_test 119c "Testing for direct read hitting hole"
7991 test_119d() # bug 15950
7993 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7994 MAX_RPCS_IN_FLIGHT=`$LCTL get_param -n osc.*OST0000-osc-[^mM]*.max_rpcs_in_flight`
7995 $LCTL set_param -n osc.*OST0000-osc-[^mM]*.max_rpcs_in_flight 1
7997 $SETSTRIPE $DIR/$tfile -i 0 -c 1 || error "setstripe failed"
7998 $DIRECTIO write $DIR/$tfile 0 1 $BSIZE || error "first directio failed"
7999 #define OBD_FAIL_OSC_DIO_PAUSE 0x40d
8000 lctl set_param fail_loc=0x40d
8001 $DIRECTIO write $DIR/$tfile 1 4 $BSIZE &
8004 cat $DIR/$tfile > /dev/null &
8005 lctl set_param fail_loc=0
8008 log "the DIO writes have completed, now wait for the reads (should not block very long)"
8010 [ -n "`ps h -p $pid_reads -o comm`" ] && \
8011 error "the read rpcs have not completed in 2s"
8013 $LCTL set_param -n osc.*OST0000-osc-[^mM]*.max_rpcs_in_flight $MAX_RPCS_IN_FLIGHT
8015 run_test 119d "The DIO path should try to send a new rpc once one is completed"
8018 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8019 test_mkdir -p $DIR/$tdir
8020 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
8021 skip "no early lock cancel on server" && return 0
8023 lru_resize_disable mdc
8024 lru_resize_disable osc
8025 cancel_lru_locks mdc
8026 # asynchronous object destroy at MDT could cause bl ast to client
8027 cancel_lru_locks osc
8029 stat $DIR/$tdir > /dev/null
8030 can1=$(do_facet $SINGLEMDS \
8031 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8032 awk '/ldlm_cancel/ {print $2}')
8033 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8034 awk '/ldlm_bl_callback/ {print $2}')
8035 test_mkdir -c1 $DIR/$tdir/d1
8036 can2=$(do_facet $SINGLEMDS \
8037 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8038 awk '/ldlm_cancel/ {print $2}')
8039 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8040 awk '/ldlm_bl_callback/ {print $2}')
8041 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
8042 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
8043 lru_resize_enable mdc
8044 lru_resize_enable osc
8046 run_test 120a "Early Lock Cancel: mkdir test"
8049 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8050 test_mkdir $DIR/$tdir
8051 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel)" ] && \
8052 skip "no early lock cancel on server" && return 0
8053 lru_resize_disable mdc
8054 lru_resize_disable osc
8055 cancel_lru_locks mdc
8056 stat $DIR/$tdir > /dev/null
8057 can1=$(do_facet $SINGLEMDS \
8058 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8059 awk '/ldlm_cancel/ {print $2}')
8060 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8061 awk '/ldlm_bl_callback/ {print $2}')
8063 can2=$(do_facet $SINGLEMDS \
8064 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8065 awk '/ldlm_cancel/ {print $2}')
8066 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8067 awk '/ldlm_bl_callback/ {print $2}')
8068 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
8069 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
8070 lru_resize_enable mdc
8071 lru_resize_enable osc
8073 run_test 120b "Early Lock Cancel: create test"
8076 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8077 test_mkdir -c1 $DIR/$tdir
8078 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel)" ] && \
8079 skip "no early lock cancel on server" && return 0
8080 lru_resize_disable mdc
8081 lru_resize_disable osc
8082 test_mkdir -p -c1 $DIR/$tdir/d1
8083 test_mkdir -p -c1 $DIR/$tdir/d2
8084 touch $DIR/$tdir/d1/f1
8085 cancel_lru_locks mdc
8086 stat $DIR/$tdir/d1 $DIR/$tdir/d2 $DIR/$tdir/d1/f1 > /dev/null
8087 can1=$(do_facet $SINGLEMDS \
8088 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8089 awk '/ldlm_cancel/ {print $2}')
8090 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8091 awk '/ldlm_bl_callback/ {print $2}')
8092 ln $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2
8093 can2=$(do_facet $SINGLEMDS \
8094 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8095 awk '/ldlm_cancel/ {print $2}')
8096 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8097 awk '/ldlm_bl_callback/ {print $2}')
8098 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
8099 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
8100 lru_resize_enable mdc
8101 lru_resize_enable osc
8103 run_test 120c "Early Lock Cancel: link test"
8106 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8107 test_mkdir -p -c1 $DIR/$tdir
8108 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel)" ] && \
8109 skip "no early lock cancel on server" && return 0
8110 lru_resize_disable mdc
8111 lru_resize_disable osc
8113 cancel_lru_locks mdc
8114 stat $DIR/$tdir > /dev/null
8115 can1=$(do_facet $SINGLEMDS \
8116 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8117 awk '/ldlm_cancel/ {print $2}')
8118 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8119 awk '/ldlm_bl_callback/ {print $2}')
8120 chmod a+x $DIR/$tdir
8121 can2=$(do_facet $SINGLEMDS \
8122 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8123 awk '/ldlm_cancel/ {print $2}')
8124 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8125 awk '/ldlm_bl_callback/ {print $2}')
8126 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
8127 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
8128 lru_resize_enable mdc
8129 lru_resize_enable osc
8131 run_test 120d "Early Lock Cancel: setattr test"
8134 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8135 test_mkdir -p -c1 $DIR/$tdir
8136 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
8137 skip "no early lock cancel on server" && return 0
8138 lru_resize_disable mdc
8139 lru_resize_disable osc
8140 dd if=/dev/zero of=$DIR/$tdir/f1 count=1
8141 cancel_lru_locks mdc
8142 cancel_lru_locks osc
8143 dd if=$DIR/$tdir/f1 of=/dev/null
8144 stat $DIR/$tdir $DIR/$tdir/f1 > /dev/null
8145 # XXX client can not do early lock cancel of OST lock
8146 # during unlink (LU-4206), so cancel osc lock now.
8147 cancel_lru_locks osc
8148 can1=$(do_facet $SINGLEMDS \
8149 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8150 awk '/ldlm_cancel/ {print $2}')
8151 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8152 awk '/ldlm_bl_callback/ {print $2}')
8153 unlink $DIR/$tdir/f1
8155 can2=$(do_facet $SINGLEMDS \
8156 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8157 awk '/ldlm_cancel/ {print $2}')
8158 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8159 awk '/ldlm_bl_callback/ {print $2}')
8160 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
8161 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
8162 lru_resize_enable mdc
8163 lru_resize_enable osc
8165 run_test 120e "Early Lock Cancel: unlink test"
8168 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8169 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
8170 skip "no early lock cancel on server" && return 0
8171 test_mkdir -p -c1 $DIR/$tdir
8172 lru_resize_disable mdc
8173 lru_resize_disable osc
8174 test_mkdir -p -c1 $DIR/$tdir/d1
8175 test_mkdir -p -c1 $DIR/$tdir/d2
8176 dd if=/dev/zero of=$DIR/$tdir/d1/f1 count=1
8177 dd if=/dev/zero of=$DIR/$tdir/d2/f2 count=1
8178 cancel_lru_locks mdc
8179 cancel_lru_locks osc
8180 dd if=$DIR/$tdir/d1/f1 of=/dev/null
8181 dd if=$DIR/$tdir/d2/f2 of=/dev/null
8182 stat $DIR/$tdir/d1 $DIR/$tdir/d2 $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2 > /dev/null
8183 # XXX client can not do early lock cancel of OST lock
8184 # during rename (LU-4206), so cancel osc lock now.
8185 cancel_lru_locks osc
8186 can1=$(do_facet $SINGLEMDS \
8187 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8188 awk '/ldlm_cancel/ {print $2}')
8189 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8190 awk '/ldlm_bl_callback/ {print $2}')
8191 mrename $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2
8193 can2=$(do_facet $SINGLEMDS \
8194 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8195 awk '/ldlm_cancel/ {print $2}')
8196 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8197 awk '/ldlm_bl_callback/ {print $2}')
8198 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
8199 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
8200 lru_resize_enable mdc
8201 lru_resize_enable osc
8203 run_test 120f "Early Lock Cancel: rename test"
8206 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8207 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
8208 skip "no early lock cancel on server" && return 0
8209 lru_resize_disable mdc
8210 lru_resize_disable osc
8212 echo create $count files
8213 test_mkdir -p $DIR/$tdir
8214 cancel_lru_locks mdc
8215 cancel_lru_locks osc
8218 can0=$(do_facet $SINGLEMDS \
8219 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8220 awk '/ldlm_cancel/ {print $2}')
8221 blk0=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8222 awk '/ldlm_bl_callback/ {print $2}')
8223 createmany -o $DIR/$tdir/f $count
8225 can1=$(do_facet $SINGLEMDS \
8226 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8227 awk '/ldlm_cancel/ {print $2}')
8228 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8229 awk '/ldlm_bl_callback/ {print $2}')
8231 echo total: $((can1-can0)) cancels, $((blk1-blk0)) blockings
8232 echo rm $count files
8235 can2=$(do_facet $SINGLEMDS \
8236 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8237 awk '/ldlm_cancel/ {print $2}')
8238 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8239 awk '/ldlm_bl_callback/ {print $2}')
8241 echo total: $count removes in $((t2-t1))
8242 echo total: $((can2-can1)) cancels, $((blk2-blk1)) blockings
8244 # wait for commitment of removal
8245 lru_resize_enable mdc
8246 lru_resize_enable osc
8248 run_test 120g "Early Lock Cancel: performance test"
8250 test_121() { #bug #10589
8251 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8253 writes=$(LANG=C dd if=/dev/zero of=$DIR/$tfile count=1 2>&1 | awk -F '+' '/out$/ {print $1}')
8254 #define OBD_FAIL_LDLM_CANCEL_RACE 0x310
8255 lctl set_param fail_loc=0x310
8256 cancel_lru_locks osc > /dev/null
8257 reads=$(LANG=C dd if=$DIR/$tfile of=/dev/null 2>&1 | awk -F '+' '/in$/ {print $1}')
8258 lctl set_param fail_loc=0
8259 [[ $reads -eq $writes ]] ||
8260 error "read $reads blocks, must be $writes blocks"
8262 run_test 121 "read cancel race ========="
8264 test_123a() { # was test 123, statahead(bug 11401)
8265 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8267 if [ -z "$(grep "processor.*: 1" /proc/cpuinfo)" ]; then
8268 log "testing on UP system. Performance may be not as good as expected."
8273 test_mkdir -p $DIR/$tdir
8274 NUMFREE=$(df -i -P $DIR | tail -n 1 | awk '{ print $4 }')
8275 [[ $NUMFREE -gt 100000 ]] && NUMFREE=100000 || NUMFREE=$((NUMFREE-1000))
8277 for ((i=100, j=0; i<=$NUMFREE; j=$i, i=$((i * MULT)) )); do
8278 createmany -o $DIR/$tdir/$tfile $j $((i - j))
8280 max=`lctl get_param -n llite.*.statahead_max | head -n 1`
8281 lctl set_param -n llite.*.statahead_max 0
8282 lctl get_param llite.*.statahead_max
8283 cancel_lru_locks mdc
8284 cancel_lru_locks osc
8286 time ls -l $DIR/$tdir | wc -l
8288 delta=$((etime - stime))
8289 log "ls $i files without statahead: $delta sec"
8290 lctl set_param llite.*.statahead_max=$max
8292 swrong=`lctl get_param -n llite.*.statahead_stats | grep "statahead wrong:" | awk '{print $3}'`
8293 lctl get_param -n llite.*.statahead_max | grep '[0-9]'
8294 cancel_lru_locks mdc
8295 cancel_lru_locks osc
8297 time ls -l $DIR/$tdir | wc -l
8299 delta_sa=$((etime - stime))
8300 log "ls $i files with statahead: $delta_sa sec"
8301 lctl get_param -n llite.*.statahead_stats
8302 ewrong=`lctl get_param -n llite.*.statahead_stats | grep "statahead wrong:" | awk '{print $3}'`
8304 [[ $swrong -lt $ewrong ]] &&
8305 log "statahead was stopped, maybe too many locks held!"
8306 [[ $delta -eq 0 || $delta_sa -eq 0 ]] && continue
8308 if [ $((delta_sa * 100)) -gt $((delta * 105)) -a $delta_sa -gt $((delta + 2)) ]; then
8309 max=`lctl get_param -n llite.*.statahead_max | head -n 1`
8310 lctl set_param -n llite.*.statahead_max 0
8311 lctl get_param llite.*.statahead_max
8312 cancel_lru_locks mdc
8313 cancel_lru_locks osc
8315 time ls -l $DIR/$tdir | wc -l
8317 delta=$((etime - stime))
8318 log "ls $i files again without statahead: $delta sec"
8319 lctl set_param llite.*.statahead_max=$max
8320 if [ $((delta_sa * 100)) -gt $((delta * 105)) -a $delta_sa -gt $((delta + 2)) ]; then
8321 if [ $SLOWOK -eq 0 ]; then
8322 error "ls $i files is slower with statahead!"
8324 log "ls $i files is slower with statahead!"
8330 [ $delta -gt 20 ] && break
8331 [ $delta -gt 8 ] && MULT=$((50 / delta))
8332 [ "$SLOW" = "no" -a $delta -gt 5 ] && break
8340 delta=$((etime - stime))
8341 log "rm -r $DIR/$tdir/: $delta seconds"
8343 lctl get_param -n llite.*.statahead_stats
8345 run_test 123a "verify statahead work"
8347 test_123b () { # statahead(bug 15027)
8348 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8349 test_mkdir -p $DIR/$tdir
8350 createmany -o $DIR/$tdir/$tfile-%d 1000
8352 cancel_lru_locks mdc
8353 cancel_lru_locks osc
8355 #define OBD_FAIL_MDC_GETATTR_ENQUEUE 0x803
8356 lctl set_param fail_loc=0x80000803
8357 ls -lR $DIR/$tdir > /dev/null
8359 lctl set_param fail_loc=0x0
8360 lctl get_param -n llite.*.statahead_stats
8365 run_test 123b "not panic with network error in statahead enqueue (bug 15027)"
8368 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8369 [ -z "$($LCTL get_param -n mdc.*.connect_flags | grep lru_resize)" ] &&
8370 skip "no lru resize on server" && return 0
8372 test_mkdir -p $DIR/$tdir || error "failed to create $DIR/$tdir"
8374 log "create $NR files at $DIR/$tdir"
8375 createmany -o $DIR/$tdir/f $NR ||
8376 error "failed to create $NR files in $DIR/$tdir"
8378 cancel_lru_locks mdc
8379 ls -l $DIR/$tdir > /dev/null
8383 for VALUE in $($LCTL get_param ldlm.namespaces.*mdc-*.lru_size); do
8384 local PARAM=$(echo ${VALUE[0]} | cut -d "=" -f1)
8385 LRU_SIZE=$($LCTL get_param -n $PARAM)
8386 if [[ $LRU_SIZE -gt $(default_lru_size) ]]; then
8387 NSDIR=$(echo $PARAM | cut -d "." -f1-3)
8389 log "NS=$(basename $NSDIR)"
8394 if [[ -z "$NSDIR" || $LRU_SIZE -lt $(default_lru_size) ]]; then
8395 skip "Not enough cached locks created!"
8402 # We know that lru resize allows one client to hold $LIMIT locks
8403 # for 10h. After that locks begin to be killed by client.
8405 local LIMIT=$($LCTL get_param -n $NSDIR.pool.limit)
8407 if [ $LIMIT -lt $LRU_SIZE ]; then
8408 skip "Limit is too small $LIMIT"
8412 # Make LVF so higher that sleeping for $SLEEP is enough to _start_
8413 # killing locks. Some time was spent for creating locks. This means
8414 # that up to the moment of sleep finish we must have killed some of
8415 # them (10-100 locks). This depends on how fast ther were created.
8416 # Many of them were touched in almost the same moment and thus will
8417 # be killed in groups.
8418 local LVF=$(($MAX_HRS * 60 * 60 / $SLEEP * $LIMIT / $LRU_SIZE))
8420 # Use $LRU_SIZE_B here to take into account real number of locks
8421 # created in the case of CMD, LRU_SIZE_B != $NR in most of cases
8422 local LRU_SIZE_B=$LRU_SIZE
8424 local OLD_LVF=$($LCTL get_param -n $NSDIR.pool.lock_volume_factor)
8425 log "OLD_LVF=$OLD_LVF"
8426 $LCTL set_param -n $NSDIR.pool.lock_volume_factor $LVF
8428 # Let's make sure that we really have some margin. Client checks
8429 # cached locks every 10 sec.
8431 log "Sleep ${SLEEP} sec"
8433 while ((SEC<$SLEEP)); do
8437 LRU_SIZE=$($LCTL get_param -n $NSDIR/lru_size)
8441 $LCTL set_param -n $NSDIR.pool.lock_volume_factor $OLD_LVF
8442 local LRU_SIZE_A=$($LCTL get_param -n $NSDIR.lru_size)
8444 [[ $LRU_SIZE_B -gt $LRU_SIZE_A ]] || {
8445 error "No locks dropped in ${SLEEP}s. LRU size: $LRU_SIZE_A"
8446 unlinkmany $DIR/$tdir/f $NR
8450 log "Dropped "$((LRU_SIZE_B-LRU_SIZE_A))" locks in ${SLEEP}s"
8451 log "unlink $NR files at $DIR/$tdir"
8452 unlinkmany $DIR/$tdir/f $NR
8454 run_test 124a "lru resize ======================================="
8456 get_max_pool_limit()
8458 local limit=$($LCTL get_param \
8459 -n ldlm.namespaces.*-MDT0000-mdc-*.pool.limit)
8462 if [[ $l -gt $max ]]; then
8470 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8471 [ -z "$($LCTL get_param -n mdc.*.connect_flags | grep lru_resize)" ] &&
8472 skip "no lru resize on server" && return 0
8474 LIMIT=$(get_max_pool_limit)
8476 NR=$(($(default_lru_size)*20))
8477 if [[ $NR -gt $LIMIT ]]; then
8478 log "Limit lock number by $LIMIT locks"
8481 lru_resize_disable mdc
8482 test_mkdir -p $DIR/$tdir/disable_lru_resize ||
8483 error "failed to create $DIR/$tdir/disable_lru_resize"
8485 createmany -o $DIR/$tdir/disable_lru_resize/f $NR
8486 log "doing ls -la $DIR/$tdir/disable_lru_resize 3 times"
8487 cancel_lru_locks mdc
8490 ls -la $DIR/$tdir/disable_lru_resize > /dev/null &
8493 ls -la $DIR/$tdir/disable_lru_resize > /dev/null &
8496 ls -la $DIR/$tdir/disable_lru_resize > /dev/null &
8500 nolruresize_delta=$((etime-stime))
8501 log "ls -la time: $nolruresize_delta seconds"
8502 log "lru_size = $(lctl get_param -n ldlm.namespaces.*mdc*.lru_size)"
8503 unlinkmany $DIR/$tdir/disable_lru_resize/f $NR
8505 lru_resize_enable mdc
8506 test_mkdir -p $DIR/$tdir/enable_lru_resize ||
8507 error "failed to create $DIR/$tdir/enable_lru_resize"
8509 createmany -o $DIR/$tdir/enable_lru_resize/f $NR
8510 log "doing ls -la $DIR/$tdir/enable_lru_resize 3 times"
8511 cancel_lru_locks mdc
8514 ls -la $DIR/$tdir/enable_lru_resize > /dev/null &
8517 ls -la $DIR/$tdir/enable_lru_resize > /dev/null &
8520 ls -la $DIR/$tdir/enable_lru_resize > /dev/null &
8524 lruresize_delta=$((etime-stime))
8525 log "ls -la time: $lruresize_delta seconds"
8526 log "lru_size = $(lctl get_param -n ldlm.namespaces.*mdc*.lru_size)"
8528 if [ $lruresize_delta -gt $nolruresize_delta ]; then
8529 log "ls -la is $(((lruresize_delta - $nolruresize_delta) * 100 / $nolruresize_delta))% slower with lru resize enabled"
8530 elif [ $nolruresize_delta -gt $lruresize_delta ]; then
8531 log "ls -la is $(((nolruresize_delta - $lruresize_delta) * 100 / $nolruresize_delta))% faster with lru resize enabled"
8533 log "lru resize performs the same with no lru resize"
8535 unlinkmany $DIR/$tdir/enable_lru_resize/f $NR
8537 run_test 124b "lru resize (performance test) ======================="
8540 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8541 [ -z "$($LCTL get_param -n mdc.*.connect_flags | grep lru_resize)" ] &&
8542 skip "no lru resize on server" && return 0
8544 # cache ununsed locks on client
8546 cancel_lru_locks mdc
8547 test_mkdir -p $DIR/$tdir || error "failed to create $DIR/$tdir"
8548 createmany -o $DIR/$tdir/f $nr ||
8549 error "failed to create $nr files in $DIR/$tdir"
8550 ls -l $DIR/$tdir > /dev/null
8552 local nsdir="ldlm.namespaces.*-MDT0000-mdc-*"
8553 local unused=$($LCTL get_param -n $nsdir.lock_unused_count)
8554 local max_age=$($LCTL get_param -n $nsdir.lru_max_age)
8555 local recalc_p=$($LCTL get_param -n $nsdir.pool.recalc_period)
8556 echo "unused=$unused, max_age=$max_age, recalc_p=$recalc_p"
8558 # set lru_max_age to 1 sec
8559 $LCTL set_param $nsdir.lru_max_age=1000 # jiffies
8560 echo "sleep $((recalc_p * 2)) seconds..."
8561 sleep $((recalc_p * 2))
8563 local remaining=$($LCTL get_param -n $nsdir.lock_unused_count)
8564 # restore lru_max_age
8565 $LCTL set_param -n $nsdir.lru_max_age $max_age
8566 [ $remaining -eq 0 ] || error "$remaining locks are not canceled"
8567 unlinkmany $DIR/$tdir/f $nr
8569 run_test 124c "LRUR cancel very aged locks"
8571 test_125() { # 13358
8572 [ -z "$(lctl get_param -n llite.*.client_type | grep local)" ] && skip "must run as local client" && return
8573 [ -z "$(lctl get_param -n mdc.*-mdc-*.connect_flags | grep acl)" ] && skip "must have acl enabled" && return
8574 [ -z "$(which setfacl)" ] && skip "must have setfacl tool" && return
8575 test_mkdir -p $DIR/d125 || error "mkdir failed"
8576 $SETSTRIPE -S 65536 -c -1 $DIR/d125 || error "setstripe failed"
8577 setfacl -R -m u:bin:rwx $DIR/d125 || error "setfacl $DIR/d125 failed"
8578 ls -ld $DIR/d125 || error "cannot access $DIR/d125"
8580 run_test 125 "don't return EPROTO when a dir has a non-default striping and ACLs"
8582 test_126() { # bug 12829/13455
8583 [ -z "$(lctl get_param -n llite.*.client_type | grep local)" ] && skip "must run as local client" && return
8584 [ "$UID" != 0 ] && skip_env "skipping $TESTNAME (must run as root)" && return
8585 $GSS && skip "must run as gss disabled" && return
8587 $RUNAS -u 0 -g 1 touch $DIR/$tfile || error "touch failed"
8588 gid=`ls -n $DIR/$tfile | awk '{print $4}'`
8590 [ $gid -eq "1" ] || error "gid is set to" $gid "instead of 1"
8592 run_test 126 "check that the fsgid provided by the client is taken into account"
8594 test_127a() { # bug 15521
8595 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8596 $SETSTRIPE -i 0 -c 1 $DIR/$tfile || error "setstripe failed"
8597 $LCTL set_param osc.*.stats=0
8598 FSIZE=$((2048 * 1024))
8599 dd if=/dev/zero of=$DIR/$tfile bs=$FSIZE count=1
8600 cancel_lru_locks osc
8601 dd if=$DIR/$tfile of=/dev/null bs=$FSIZE
8603 $LCTL get_param osc.*0000-osc-*.stats | grep samples > $DIR/${tfile}.tmp
8604 while read NAME COUNT SAMP UNIT MIN MAX SUM SUMSQ; do
8605 echo "got $COUNT $NAME"
8606 [ ! $MIN ] && error "Missing min value for $NAME proc entry"
8607 eval $NAME=$COUNT || error "Wrong proc format"
8610 read_bytes|write_bytes)
8611 [ $MIN -lt 4096 ] && error "min is too small: $MIN"
8612 [ $MIN -gt $FSIZE ] && error "min is too big: $MIN"
8613 [ $MAX -lt 4096 ] && error "max is too small: $MAX"
8614 [ $MAX -gt $FSIZE ] && error "max is too big: $MAX"
8615 [ $SUM -ne $FSIZE ] && error "sum is wrong: $SUM"
8616 [ $SUMSQ -lt $(((FSIZE /4096) * (4096 * 4096))) ] &&
8617 error "sumsquare is too small: $SUMSQ"
8618 [ $SUMSQ -gt $((FSIZE * FSIZE)) ] &&
8619 error "sumsquare is too big: $SUMSQ"
8623 done < $DIR/${tfile}.tmp
8625 #check that we actually got some stats
8626 [ "$read_bytes" ] || error "Missing read_bytes stats"
8627 [ "$write_bytes" ] || error "Missing write_bytes stats"
8628 [ "$read_bytes" != 0 ] || error "no read done"
8629 [ "$write_bytes" != 0 ] || error "no write done"
8631 run_test 127a "verify the client stats are sane"
8633 test_127b() { # bug LU-333
8634 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8635 $LCTL set_param llite.*.stats=0
8636 FSIZE=65536 # sized fixed to match PAGE_SIZE for most clients
8637 # perform 2 reads and writes so MAX is different from SUM.
8638 dd if=/dev/zero of=$DIR/$tfile bs=$FSIZE count=1
8639 dd if=/dev/zero of=$DIR/$tfile bs=$FSIZE count=1
8640 cancel_lru_locks osc
8641 dd if=$DIR/$tfile of=/dev/null bs=$FSIZE count=1
8642 dd if=$DIR/$tfile of=/dev/null bs=$FSIZE count=1
8644 $LCTL get_param llite.*.stats | grep samples > $TMP/${tfile}.tmp
8645 while read NAME COUNT SAMP UNIT MIN MAX SUM SUMSQ; do
8646 echo "got $COUNT $NAME"
8647 eval $NAME=$COUNT || error "Wrong proc format"
8651 [ $COUNT -ne 2 ] && error "count is not 2: $COUNT"
8652 [ $MIN -ne $FSIZE ] && error "min is not $FSIZE: $MIN"
8653 [ $MAX -ne $FSIZE ] && error "max is incorrect: $MAX"
8654 [ $SUM -ne $((FSIZE * 2)) ] && error "sum is wrong: $SUM"
8657 [ $COUNT -ne 2 ] && error "count is not 2: $COUNT"
8658 [ $MIN -ne $FSIZE ] && error "min is not $FSIZE: $MIN"
8659 [ $MAX -ne $FSIZE ] && error "max is incorrect: $MAX"
8660 [ $SUM -ne $((FSIZE * 2)) ] && error "sum is wrong: $SUM"
8664 done < $TMP/${tfile}.tmp
8666 #check that we actually got some stats
8667 [ "$read_bytes" ] || error "Missing read_bytes stats"
8668 [ "$write_bytes" ] || error "Missing write_bytes stats"
8669 [ "$read_bytes" != 0 ] || error "no read done"
8670 [ "$write_bytes" != 0 ] || error "no write done"
8672 run_test 127b "verify the llite client stats are sane"
8674 test_128() { # bug 15212
8676 $LFS 2>&1 <<-EOF | tee $TMP/$tfile.log
8681 result=$(grep error $TMP/$tfile.log)
8683 [ -z "$result" ] || error "consecutive find's under interactive lfs failed"
8685 run_test 128 "interactive lfs for 2 consecutive find's"
8692 local LDPROC=/proc/fs/ldiskfs
8693 local facets=$(get_facets MDS)
8695 for facet in ${facets//,/ }; do
8696 canondev=$(ldiskfs_canon \
8697 *.$(convert_facet2label $facet).mntdev $facet)
8698 do_facet $facet "test -e $LDPROC/$canondev/max_dir_size" ||
8699 LDPROC=/sys/fs/ldiskfs
8700 do_facet $facet "echo $1 >$LDPROC/$canondev/max_dir_size"
8705 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8706 if [ "$(facet_fstype $SINGLEMDS)" != ldiskfs ]; then
8707 skip "Only applicable to ldiskfs-based MDTs"
8710 remote_mds_nodsh && skip "remote MDS with nodsh" && return
8715 test_mkdir -p $DIR/$tdir
8717 # block size of mds1
8718 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
8719 local MDSBLOCKSIZE=$($LCTL get_param -n mdc.*MDT0000*.blocksize)
8720 local MAX=$((MDSBLOCKSIZE * 3))
8722 local I=$(stat -c%s "$DIR/$tdir")
8724 local STRIPE_COUNT=1
8725 [[ $MDSCOUNT -ge 2 ]] && STRIPE_COUNT=$($LFS getdirstripe -c $DIR/$tdir)
8726 MAX=$((MAX*STRIPE_COUNT))
8727 while [[ $I -le $MAX ]]; do
8728 $MULTIOP $DIR/$tdir/$J Oc
8730 #check two errors ENOSPC for new version of ext4 max_dir_size patch
8731 #mainline kernel commit df981d03eeff7971ac7e6ff37000bfa702327ef1
8732 #and EFBIG for previous versions
8733 if [ $rc -eq $EFBIG -o $rc -eq $ENOSPC ]; then
8735 echo "return code $rc received as expected"
8736 multiop $DIR/$tdir/$J Oc ||
8737 error_exit "multiop failed w/o dir size limit"
8739 I=$(stat -c%s "$DIR/$tdir")
8741 if [ $(lustre_version_code $SINGLEMDS) -lt \
8742 $(version_code 2.4.51) ]
8744 [[ $I -eq $MAX ]] && return 0
8746 [[ $I -gt $MAX ]] && return 0
8748 error_exit "current dir size $I, previous limit $MAX"
8749 elif [ $rc -ne 0 ]; then
8751 error_exit "return code $rc received instead of expected " \
8752 "$EFBIG or $ENOSPC, files in dir $I"
8755 I=$(stat -c%s "$DIR/$tdir")
8759 error "exceeded dir size limit $MAX($MDSCOUNT) : $I bytes"
8761 run_test 129 "test directory size limit ========================"
8770 local filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
8771 [ -n "$filefrag_op" ] && skip_env "filefrag does not support FIEMAP" &&
8774 trap cleanup_130 EXIT RETURN
8776 local fm_file=$DIR/$tfile
8777 $SETSTRIPE -S 65536 -c 1 $fm_file || error "setstripe on $fm_file"
8778 dd if=/dev/zero of=$fm_file bs=65536 count=1 ||
8779 error "dd failed for $fm_file"
8781 # LU-1795: test filefrag/FIEMAP once, even if unsupported
8782 filefrag -ves $fm_file
8784 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
8785 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
8786 [ $RC != 0 ] && error "filefrag $fm_file failed"
8788 filefrag_op=$(filefrag -ve $fm_file | grep -A 100 "ext:" |
8789 grep -v "ext:" | grep -v "found")
8790 lun=$($GETSTRIPE -i $fm_file)
8792 start_blk=`echo $filefrag_op | cut -d: -f2 | cut -d. -f1`
8795 for line in $filefrag_op
8797 frag_lun=`echo $line | cut -d: -f5`
8798 ext_len=`echo $line | cut -d: -f4`
8799 if (( $frag_lun != $lun )); then
8801 error "FIEMAP on 1-stripe file($fm_file) failed"
8804 (( tot_len += ext_len ))
8807 if (( lun != frag_lun || start_blk != 0 || tot_len != 64 )); then
8809 error "FIEMAP on 1-stripe file($fm_file) failed;"
8815 echo "FIEMAP on single striped file succeeded"
8817 run_test 130a "FIEMAP (1-stripe file)"
8820 [ "$OSTCOUNT" -lt "2" ] &&
8821 skip_env "skipping FIEMAP on 2-stripe file test" && return
8823 [ "$OSTCOUNT" -ge "10" ] &&
8824 skip_env "skipping FIEMAP with >= 10 OSTs" && return
8826 local filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
8827 [ -n "$filefrag_op" ] && skip_env "filefrag does not support FIEMAP" &&
8830 trap cleanup_130 EXIT RETURN
8832 local fm_file=$DIR/$tfile
8833 $SETSTRIPE -S 65536 -c 2 $fm_file || error "setstripe on $fm_file"
8834 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
8835 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
8837 dd if=/dev/zero of=$fm_file bs=1M count=2 ||
8838 error "dd failed on $fm_file"
8840 filefrag -ves $fm_file || error "filefrag $fm_file failed"
8841 filefrag_op=$(filefrag -ve $fm_file | grep -A 100 "ext:" |
8842 grep -v "ext:" | grep -v "found")
8844 last_lun=$(echo $filefrag_op | cut -d: -f5)
8849 for line in $filefrag_op
8851 frag_lun=`echo $line | cut -d: -f5`
8852 ext_len=`echo $line | cut -d: -f4`
8853 if (( $frag_lun != $last_lun )); then
8854 if (( tot_len != 1024 )); then
8856 error "FIEMAP on $fm_file failed; returned len $tot_len for OST $last_lun instead of 256"
8863 (( tot_len += ext_len ))
8866 if (( num_luns != 2 || tot_len != 1024 )); then
8868 error "FIEMAP on $fm_file failed; returned wrong number of luns or wrong len for OST $last_lun"
8874 echo "FIEMAP on 2-stripe file succeeded"
8876 run_test 130b "FIEMAP (2-stripe file)"
8879 [ "$OSTCOUNT" -lt "2" ] &&
8880 skip_env "skipping FIEMAP on 2-stripe file" && return
8882 [ "$OSTCOUNT" -ge "10" ] &&
8883 skip_env "skipping FIEMAP with >= 10 OSTs" && return
8885 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
8886 [ -n "$filefrag_op" ] && skip "filefrag does not support FIEMAP" &&
8889 trap cleanup_130 EXIT RETURN
8891 local fm_file=$DIR/$tfile
8892 $SETSTRIPE -S 65536 -c 2 $fm_file || error "setstripe on $fm_file"
8893 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
8894 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
8896 dd if=/dev/zero of=$fm_file seek=1 bs=1M count=1 || error "dd failed on $fm_file"
8898 filefrag -ves $fm_file || error "filefrag $fm_file failed"
8899 filefrag_op=`filefrag -ve $fm_file | grep -A 100 "ext:" | grep -v "ext:" | grep -v "found"`
8901 last_lun=`echo $filefrag_op | cut -d: -f5`
8906 for line in $filefrag_op
8908 frag_lun=`echo $line | cut -d: -f5`
8909 ext_len=`echo $line | cut -d: -f4`
8910 if (( $frag_lun != $last_lun )); then
8911 logical=`echo $line | cut -d: -f2 | cut -d. -f1`
8912 if (( logical != 512 )); then
8914 error "FIEMAP on $fm_file failed; returned logical start for lun $logical instead of 512"
8917 if (( tot_len != 512 )); then
8919 error "FIEMAP on $fm_file failed; returned len $tot_len for OST $last_lun instead of 1024"
8926 (( tot_len += ext_len ))
8929 if (( num_luns != 2 || tot_len != 512 )); then
8931 error "FIEMAP on $fm_file failed; returned wrong number of luns or wrong len for OST $last_lun"
8937 echo "FIEMAP on 2-stripe file with hole succeeded"
8939 run_test 130c "FIEMAP (2-stripe file with hole)"
8942 [ "$OSTCOUNT" -lt "3" ] && skip_env "skipping FIEMAP on N-stripe file test" && return
8944 [ "$OSTCOUNT" -ge "10" ] &&
8945 skip_env "skipping FIEMAP with >= 10 OSTs" && return
8947 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
8948 [ -n "$filefrag_op" ] && skip "filefrag does not support FIEMAP" && return
8950 trap cleanup_130 EXIT RETURN
8952 local fm_file=$DIR/$tfile
8953 $SETSTRIPE -S 65536 -c $OSTCOUNT $fm_file||error "setstripe on $fm_file"
8954 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
8955 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
8957 local actual_stripecnt=$($GETSTRIPE -c $fm_file)
8958 dd if=/dev/zero of=$fm_file bs=1M count=$actual_stripecnt ||
8959 error "dd failed on $fm_file"
8961 filefrag -ves $fm_file || error "filefrag $fm_file failed"
8962 filefrag_op=`filefrag -ve $fm_file | grep -A 100 "ext:" |
8963 grep -v "ext:" | grep -v "found"`
8965 last_lun=`echo $filefrag_op | cut -d: -f5`
8970 for line in $filefrag_op
8972 frag_lun=`echo $line | cut -d: -f5`
8973 ext_len=`echo $line | cut -d: -f4`
8974 if (( $frag_lun != $last_lun )); then
8975 if (( tot_len != 1024 )); then
8977 error "FIEMAP on $fm_file failed; returned len $tot_len for OST $last_lun instead of 1024"
8984 (( tot_len += ext_len ))
8987 if (( num_luns != actual_stripecnt || tot_len != 1024 )); then
8989 error "FIEMAP on $fm_file failed; returned wrong number of luns or wrong len for OST $last_lun"
8995 echo "FIEMAP on N-stripe file succeeded"
8997 run_test 130d "FIEMAP (N-stripe file)"
9000 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping continuation FIEMAP test" && return
9002 [ "$OSTCOUNT" -ge "10" ] &&
9003 skip_env "skipping FIEMAP with >= 10 OSTs" && return
9005 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
9006 [ -n "$filefrag_op" ] && skip "filefrag does not support FIEMAP" && return
9008 trap cleanup_130 EXIT RETURN
9010 local fm_file=$DIR/$tfile
9011 $SETSTRIPE -S 131072 -c 2 $fm_file || error "setstripe on $fm_file"
9012 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
9013 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
9016 EXPECTED_LEN=$(( (NUM_BLKS / 2) * 64 ))
9017 for ((i = 0; i < $NUM_BLKS; i++))
9019 dd if=/dev/zero of=$fm_file count=1 bs=64k seek=$((2*$i)) conv=notrunc > /dev/null 2>&1
9022 filefrag -ves $fm_file || error "filefrag $fm_file failed"
9023 filefrag_op=`filefrag -ve $fm_file | grep -A 12000 "ext:" | grep -v "ext:" | grep -v "found"`
9025 last_lun=`echo $filefrag_op | cut -d: -f5`
9030 for line in $filefrag_op
9032 frag_lun=`echo $line | cut -d: -f5`
9033 ext_len=`echo $line | cut -d: -f4`
9034 if (( $frag_lun != $last_lun )); then
9035 if (( tot_len != $EXPECTED_LEN )); then
9037 error "FIEMAP on $fm_file failed; returned len $tot_len for OST $last_lun instead of $EXPECTED_LEN"
9044 (( tot_len += ext_len ))
9047 if (( num_luns != 2 || tot_len != $EXPECTED_LEN )); then
9049 error "FIEMAP on $fm_file failed; returned wrong number of luns or wrong len for OST $last_lun"
9055 echo "FIEMAP with continuation calls succeeded"
9057 run_test 130e "FIEMAP (test continuation FIEMAP calls)"
9059 # Test for writev/readv
9061 rwv -f $DIR/$tfile -w -n 3 524288 1048576 1572864 || \
9062 error "writev test failed"
9063 rwv -f $DIR/$tfile -r -v -n 2 1572864 1048576 || \
9064 error "readv failed"
9067 run_test 131a "test iov's crossing stripe boundary for writev/readv"
9070 rwv -f $DIR/$tfile -w -a -n 3 524288 1048576 1572864 || \
9071 error "append writev test failed"
9072 rwv -f $DIR/$tfile -w -a -n 2 1572864 1048576 || \
9073 error "append writev test failed"
9076 run_test 131b "test append writev"
9079 rwv -f $DIR/$tfile -w -d -n 1 1048576 || return 0
9082 run_test 131c "test read/write on file w/o objects"
9085 rwv -f $DIR/$tfile -w -n 1 1572864
9086 NOB=`rwv -f $DIR/$tfile -r -n 3 524288 524288 1048576 | awk '/error/ {print $6}'`
9087 if [ "$NOB" != 1572864 ]; then
9088 error "Short read filed: read $NOB bytes instead of 1572864"
9092 run_test 131d "test short read"
9095 rwv -f $DIR/$tfile -w -s 1048576 -n 1 1048576
9096 rwv -f $DIR/$tfile -r -z -s 0 -n 1 524288 || \
9097 error "read hitting hole failed"
9100 run_test 131e "test read hitting hole"
9106 $SINGLEMDS) res=`do_facet $SINGLEMDS $LCTL get_param mdt.$FSNAME-MDT0000.md_stats | grep "$2"`
9108 ost) res=`do_facet ost1 $LCTL get_param obdfilter.$FSNAME-OST0000.stats | grep "$2"`
9110 *) error "Wrong argument $1" ;;
9113 [ -z "$res" ] && error "The counter for $2 on $1 was not incremented"
9114 # if the argument $3 is zero, it means any stat increment is ok.
9115 if [[ $3 -gt 0 ]]; then
9116 count=$(echo $res | awk '{ print $2 }')
9117 [[ $count -ne $3 ]] &&
9118 error "The $2 counter on $1 is wrong - expected $3"
9123 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9124 remote_ost_nodsh && skip "remote OST with nodsh" && return
9125 remote_mds_nodsh && skip "remote MDS with nodsh" && return
9127 do_facet $SINGLEMDS $LCTL list_param mdt.*.rename_stats ||
9128 { skip "MDS doesn't support rename stats"; return; }
9129 local testdir=$DIR/${tdir}/stats_testdir
9130 mkdir -p $DIR/${tdir}
9133 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
9134 do_facet ost1 $LCTL set_param obdfilter.*.stats=clear
9136 # verify mdt stats first.
9137 mkdir ${testdir} || error "mkdir failed"
9138 check_stats $SINGLEMDS "mkdir" 1
9139 touch ${testdir}/${tfile} || "touch failed"
9140 check_stats $SINGLEMDS "open" 1
9141 check_stats $SINGLEMDS "close" 1
9142 mknod ${testdir}/${tfile}-pipe p || "mknod failed"
9143 check_stats $SINGLEMDS "mknod" 1
9144 rm -f ${testdir}/${tfile}-pipe || "pipe remove failed"
9145 check_stats $SINGLEMDS "unlink" 1
9146 rm -f ${testdir}/${tfile} || error "file remove failed"
9147 check_stats $SINGLEMDS "unlink" 2
9149 # remove working dir and check mdt stats again.
9150 rmdir ${testdir} || error "rmdir failed"
9151 check_stats $SINGLEMDS "rmdir" 1
9153 local testdir1=$DIR/${tdir}/stats_testdir1
9155 mkdir -p ${testdir1}
9156 touch ${testdir1}/test1
9157 mv ${testdir1}/test1 ${testdir} || error "file crossdir rename"
9158 check_stats $SINGLEMDS "crossdir_rename" 1
9160 mv ${testdir}/test1 ${testdir}/test0 || error "file samedir rename"
9161 check_stats $SINGLEMDS "samedir_rename" 1
9165 run_test 133a "Verifying MDT stats ========================================"
9168 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9169 remote_ost_nodsh && skip "remote OST with nodsh" && return
9170 remote_mds_nodsh && skip "remote MDS with nodsh" && return
9171 local testdir=$DIR/${tdir}/stats_testdir
9172 mkdir -p ${testdir} || error "mkdir failed"
9173 touch ${testdir}/${tfile} || "touch failed"
9174 cancel_lru_locks mdc
9177 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
9178 do_facet ost1 $LCTL set_param obdfilter.*.stats=clear
9180 # extra mdt stats verification.
9181 chmod 444 ${testdir}/${tfile} || error "chmod failed"
9182 check_stats $SINGLEMDS "setattr" 1
9183 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
9184 if [ $(lustre_version_code $SINGLEMDS) -ne $(version_code 2.2.0) ]
9186 ls -l ${testdir}/${tfile} > /dev/null|| error "ls failed"
9187 check_stats $SINGLEMDS "getattr" 1
9189 $LFS df || error "lfs failed"
9190 check_stats $SINGLEMDS "statfs" 1
9194 run_test 133b "Verifying extra MDT stats =================================="
9197 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9198 remote_ost_nodsh && skip "remote OST with nodsh" && return
9199 remote_mds_nodsh && skip "remote MDS with nodsh" && return
9200 local testdir=$DIR/${tdir}/stats_testdir
9201 test_mkdir -p ${testdir} || error "mkdir failed"
9203 # verify obdfilter stats.
9204 $SETSTRIPE -c 1 -i 0 ${testdir}/${tfile}
9206 cancel_lru_locks osc
9207 wait_delete_completed
9210 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
9211 do_facet ost1 $LCTL set_param obdfilter.*.stats=clear
9213 dd if=/dev/zero of=${testdir}/${tfile} conv=notrunc bs=512k count=1 || error "dd failed"
9215 cancel_lru_locks osc
9216 check_stats ost "write" 1
9218 dd if=${testdir}/${tfile} of=/dev/null bs=1k count=1 || error "dd failed"
9219 check_stats ost "read" 1
9221 > ${testdir}/${tfile} || error "truncate failed"
9222 check_stats ost "punch" 1
9224 rm -f ${testdir}/${tfile} || error "file remove failed"
9225 wait_delete_completed
9226 check_stats ost "destroy" 1
9230 run_test 133c "Verifying OST stats ========================================"
9237 while [ $value -ge 2 ]; do
9242 if [ $orig -gt $order ]; then
9250 local size=('K' 'M' 'G' 'T');
9252 local size_string=$value
9254 while [ $value -ge 1024 ]; do
9255 if [ $i -gt 3 ]; then
9256 #T is the biggest unit we get here, if that is bigger,
9258 size_string=${value}T
9261 value=$((value >> 10))
9262 if [ $value -lt 1024 ]; then
9263 size_string=${value}${size[$i]}
9274 local context=${2:-.}
9275 local sample=$(do_facet $SINGLEMDS $LCTL get_param mdt.*.rename_stats |
9277 awk '/ '${size}'/ {print $4}' | sed -e "s/,//g")
9282 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9283 remote_ost_nodsh && skip "remote OST with nodsh" && return
9284 remote_mds_nodsh && skip "remote MDS with nodsh" && return
9285 do_facet $SINGLEMDS $LCTL list_param mdt.*.rename_stats ||
9286 { skip "MDS doesn't support rename stats"; return; }
9288 local testdir1=$DIR/${tdir}/stats_testdir1
9289 local testdir2=$DIR/${tdir}/stats_testdir2
9291 do_facet $SINGLEMDS $LCTL set_param mdt.*.rename_stats=clear
9293 mkdir -p ${testdir1} || error "mkdir failed"
9294 mkdir -p ${testdir2} || error "mkdir failed"
9296 createmany -o $testdir1/test 512 || error "createmany failed"
9298 # check samedir rename size
9299 mv ${testdir1}/test0 ${testdir1}/test_0
9301 local testdir1_size=$(ls -l $DIR/${tdir} |
9302 awk '/stats_testdir1/ {print $5}')
9303 local testdir2_size=$(ls -l $DIR/${tdir} |
9304 awk '/stats_testdir2/ {print $5}')
9306 testdir1_size=$(order_2 $testdir1_size)
9307 testdir2_size=$(order_2 $testdir2_size)
9309 testdir1_size=$(size_in_KMGT $testdir1_size)
9310 testdir2_size=$(size_in_KMGT $testdir2_size)
9312 echo "source rename dir size: ${testdir1_size}"
9313 echo "target rename dir size: ${testdir2_size}"
9315 local cmd="do_facet $SINGLEMDS $LCTL get_param mdt.*.rename_stats"
9316 eval $cmd || error "$cmd failed"
9317 local samedir=$($cmd | grep 'same_dir')
9318 local same_sample=$(get_rename_size $testdir1_size)
9319 [ -z "$samedir" ] && error "samedir_rename_size count error"
9320 [[ $same_sample -eq 1 ]] ||
9321 error "samedir_rename_size error $same_sample"
9322 echo "Check same dir rename stats success"
9324 do_facet $SINGLEMDS $LCTL set_param mdt.*.rename_stats=clear
9326 # check crossdir rename size
9327 mv ${testdir1}/test_0 ${testdir2}/test_0
9329 testdir1_size=$(ls -l $DIR/${tdir} |
9330 awk '/stats_testdir1/ {print $5}')
9331 testdir2_size=$(ls -l $DIR/${tdir} |
9332 awk '/stats_testdir2/ {print $5}')
9334 testdir1_size=$(order_2 $testdir1_size)
9335 testdir2_size=$(order_2 $testdir2_size)
9337 testdir1_size=$(size_in_KMGT $testdir1_size)
9338 testdir2_size=$(size_in_KMGT $testdir2_size)
9340 echo "source rename dir size: ${testdir1_size}"
9341 echo "target rename dir size: ${testdir2_size}"
9343 eval $cmd || error "$cmd failed"
9344 local crossdir=$($cmd | grep 'crossdir')
9345 local src_sample=$(get_rename_size $testdir1_size crossdir_src)
9346 local tgt_sample=$(get_rename_size $testdir2_size crossdir_tgt)
9347 [ -z "$crossdir" ] && error "crossdir_rename_size count error"
9348 [[ $src_sample -eq 1 ]] ||
9349 error "crossdir_rename_size error $src_sample"
9350 [[ $tgt_sample -eq 1 ]] ||
9351 error "crossdir_rename_size error $tgt_sample"
9352 echo "Check cross dir rename stats success"
9355 run_test 133d "Verifying rename_stats ========================================"
9358 remote_mds_nodsh && skip "remote MDS with nodsh" && return
9359 remote_ost_nodsh && skip "remote OST with nodsh" && return
9360 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9361 local testdir=$DIR/${tdir}/stats_testdir
9362 local ctr f0 f1 bs=32768 count=42 sum
9364 mkdir -p ${testdir} || error "mkdir failed"
9366 $SETSTRIPE -c 1 -i 0 ${testdir}/${tfile}
9368 for ctr in {write,read}_bytes; do
9370 cancel_lru_locks osc
9372 do_facet ost1 $LCTL set_param -n \
9373 "obdfilter.*.exports.clear=clear"
9375 if [ $ctr = write_bytes ]; then
9377 f1=${testdir}/${tfile}
9379 f0=${testdir}/${tfile}
9383 dd if=$f0 of=$f1 conv=notrunc bs=$bs count=$count || \
9386 cancel_lru_locks osc
9388 sum=$(do_facet ost1 $LCTL get_param \
9389 "obdfilter.*.exports.*.stats" |
9390 awk -v ctr=$ctr 'BEGIN { sum = 0 }
9391 $1 == ctr { sum += $7 }
9392 END { printf("%0.0f", sum) }')
9394 if ((sum != bs * count)); then
9395 error "Bad $ctr sum, expected $((bs * count)), got $sum"
9401 run_test 133e "Verifying OST {read,write}_bytes nid stats ================="
9406 local dirs="/proc/fs/lustre/ /proc/sys/lnet/ /proc/sys/lustre/ \
9407 /sys/fs/lustre/ /sys/fs/lnet/"
9409 for dir in $dirs; do
9410 if [ -d $dir ]; then
9411 proc_dirs="$proc_dirs $dir"
9417 remote_mds_nodsh && skip "remote MDS with nodsh" && return
9418 remote_ost_nodsh && skip "remote OST with nodsh" && return
9419 # First without trusting modes.
9420 find $proc_dirs -exec cat '{}' \; &> /dev/null
9422 # Second verifying readability.
9425 -exec cat '{}' \; &> /dev/null ||
9426 error "proc file read failed"
9428 for facet in $SINGLEMDS ost1; do
9429 do_facet $facet find $proc_dirs \
9430 ! -name req_history \
9431 -exec cat '{}' \\\; &> /dev/null
9433 do_facet $facet find $proc_dirs \
9434 ! -name req_history \
9436 -exec cat '{}' \\\; &> /dev/null ||
9437 error "proc file read failed"
9440 run_test 133f "Check for LBUGs/Oopses/unreadable files in /proc"
9445 local dirs="/proc/fs/lustre/ /proc/sys/lnet/ /proc/sys/lustre/ \
9446 /sys/fs/lustre/ /sys/fs/lnet/"
9448 for dir in $dirs; do
9449 if [ -d $dir ]; then
9450 proc_dirs="$proc_dirs $dir"
9456 # Second verifying readability.
9459 -not -name force_lbug \
9460 -not -name changelog_mask \
9461 -exec badarea_io '{}' \; &> /dev/null ||
9462 error "find $proc_dirs failed"
9464 [ $(lustre_version_code $SINGLEMDS) -le $(version_code 2.5.54) ] &&
9465 skip "Too old lustre on MDS" && return
9467 [ $(lustre_version_code ost1) -le $(version_code 2.5.54) ] &&
9468 skip "Too old lustre on ost1" && return
9470 for facet in $SINGLEMDS ost1; do
9471 do_facet $facet find $proc_dirs \
9473 -not -name force_lbug \
9474 -not -name changelog_mask \
9475 -exec badarea_io '{}' \\\; &> /dev/null ||
9476 error "$facet find $proc_dirs failed"
9480 # remount the FS in case writes/reads /proc break the FS
9481 cleanup || error "failed to unmount"
9482 setup || error "failed to setup"
9485 run_test 133g "Check for Oopses on bad io area writes/reads in /proc"
9488 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.54) ]] &&
9489 skip "Need MDS version at least 2.7.54" && return
9491 mkdir -p $DIR/$tdir || error "failed to create $DIR/$tdir"
9492 cancel_lru_locks mdc
9494 local nsdir="ldlm.namespaces.*-MDT0000-mdc-*"
9495 local unused=$($LCTL get_param -n $nsdir.lock_unused_count)
9496 [ $unused -eq 0 ] || "$unused locks are not cleared"
9499 createmany -o $DIR/$tdir/f $nr ||
9500 error "failed to create $nr files in $DIR/$tdir"
9501 unused=$($LCTL get_param -n $nsdir.lock_unused_count)
9503 #define OBD_FAIL_LDLM_WATERMARK_LOW 0x327
9504 do_facet mds1 $LCTL set_param fail_loc=0x327
9505 do_facet mds1 $LCTL set_param fail_val=500
9508 echo "sleep 10 seconds ..."
9510 local lck_cnt=$($LCTL get_param -n $nsdir.lock_unused_count)
9512 do_facet mds1 $LCTL set_param fail_loc=0
9513 do_facet mds1 $LCTL set_param fail_val=0
9514 [ $lck_cnt -lt $unused ] ||
9515 error "No locks reclaimed, before:$unused, after:$lck_cnt"
9518 unlinkmany $DIR/$tdir/f $nr
9520 run_test 134a "Server reclaims locks when reaching lock_reclaim_threshold"
9523 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.54) ]] &&
9524 skip "Need MDS version at least 2.7.54" && return
9526 mkdir -p $DIR/$tdir || error "failed to create $DIR/$tdir"
9527 cancel_lru_locks mdc
9529 local low_wm=$(do_facet mds1 $LCTL get_param -n \
9530 ldlm.lock_reclaim_threshold_mb)
9531 # disable reclaim temporarily
9532 do_facet mds1 $LCTL set_param ldlm.lock_reclaim_threshold_mb=0
9534 #define OBD_FAIL_LDLM_WATERMARK_HIGH 0x328
9535 do_facet mds1 $LCTL set_param fail_loc=0x328
9536 do_facet mds1 $LCTL set_param fail_val=500
9538 $LCTL set_param debug=+trace
9541 createmany -o $DIR/$tdir/f $nr &
9544 echo "Sleep $TIMEOUT seconds ..."
9546 if ! ps -p $create_pid > /dev/null 2>&1; then
9547 do_facet mds1 $LCTL set_param fail_loc=0
9548 do_facet mds1 $LCTL set_param fail_val=0
9549 do_facet mds1 $LCTL set_param \
9550 ldlm.lock_reclaim_threshold_mb=${low_wm}m
9551 error "createmany finished incorrectly!"
9553 do_facet mds1 $LCTL set_param fail_loc=0
9554 do_facet mds1 $LCTL set_param fail_val=0
9555 do_facet mds1 $LCTL set_param ldlm.lock_reclaim_threshold_mb=${low_wm}m
9556 wait $create_pid || return 1
9558 unlinkmany $DIR/$tdir/f $nr
9560 run_test 134b "Server rejects lock request when reaching lock_limit_mb"
9562 test_140() { #bug-17379
9563 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9564 test_mkdir -p $DIR/$tdir || error "Creating dir $DIR/$tdir"
9565 cd $DIR/$tdir || error "Changing to $DIR/$tdir"
9566 cp /usr/bin/stat . || error "Copying stat to $DIR/$tdir"
9568 # VFS limits max symlink depth to 5(4KSTACK) or 7(8KSTACK) or 8
9569 # For kernel > 3.5, bellow only tests consecutive symlink (MAX 40)
9571 while i=`expr $i + 1`; do
9572 test_mkdir -p $i || error "Creating dir $i"
9573 cd $i || error "Changing to $i"
9574 ln -s ../stat stat || error "Creating stat symlink"
9575 # Read the symlink until ELOOP present,
9576 # not LBUGing the system is considered success,
9577 # we didn't overrun the stack.
9578 $OPENFILE -f O_RDONLY stat >/dev/null 2>&1; ret=$?
9580 if [ $ret -eq 40 ]; then
9583 error "Open stat symlink"
9589 echo "The symlink depth = $i"
9590 [ $i -eq 5 -o $i -eq 7 -o $i -eq 8 -o $i -eq 40 ] ||
9591 error "Invalid symlink depth"
9593 # Test recursive symlink
9594 ln -s symlink_self symlink_self
9595 $OPENFILE -f O_RDONLY symlink_self >/dev/null 2>&1; ret=$?
9596 echo "open symlink_self returns $ret"
9597 [ $ret -eq 40 ] || error "recursive symlink doesn't return -ELOOP"
9599 run_test 140 "Check reasonable stack depth (shouldn't LBUG) ===="
9602 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9603 local TF="$TMP/$tfile"
9605 dd if=/dev/urandom of=$TF bs=6096 count=1 || error "dd failed"
9607 cancel_lru_locks osc
9608 cmp $TF $DIR/$tfile || error "$TMP/$tfile $DIR/$tfile differ"
9609 remount_client $MOUNT
9611 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (remount)"
9614 $TRUNCATE $DIR/$tfile 6000
9615 cancel_lru_locks osc
9616 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (truncate1)"
9619 echo "12345" >>$DIR/$tfile
9620 cancel_lru_locks osc
9621 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (append1)"
9624 echo "12345" >>$DIR/$tfile
9625 cancel_lru_locks osc
9626 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (append2)"
9631 run_test 150 "truncate/append tests"
9633 #LU-2902 roc_hit was not able to read all values from lproc
9634 function roc_hit_init() {
9635 local list=$(comma_list $(osts_nodes))
9636 local dir=$DIR/$tdir-check
9637 local file=$dir/file
9643 #use setstripe to do a write to every ost
9644 for i in $(seq 0 $((OSTCOUNT-1))); do
9645 $SETSTRIPE -c 1 -i $i $dir || error "$SETSTRIPE $file failed"
9646 dd if=/dev/urandom of=$file bs=4k count=4 2>&1 > /dev/null
9647 idx=$(printf %04x $i)
9648 BEFORE=$(get_osd_param $list *OST*$idx stats |
9649 awk '$1 == "cache_access" {sum += $7}
9650 END { printf("%0.0f", sum) }')
9652 cancel_lru_locks osc
9653 cat $file >/dev/null
9655 AFTER=$(get_osd_param $list *OST*$idx stats |
9656 awk '$1 == "cache_access" {sum += $7}
9657 END { printf("%0.0f", sum) }')
9659 echo BEFORE:$BEFORE AFTER:$AFTER
9660 if ! let "AFTER - BEFORE == 4"; then
9662 error "roc_hit is not safe to use"
9670 function roc_hit() {
9671 local list=$(comma_list $(osts_nodes))
9672 echo $(get_osd_param $list '' stats |
9673 awk '$1 == "cache_hit" {sum += $7}
9674 END { printf("%0.0f", sum) }')
9677 function set_cache() {
9680 if [ "$2" == "off" ]; then
9683 local list=$(comma_list $(osts_nodes))
9684 set_osd_param $list '' $1_cache_enable $on
9686 cancel_lru_locks osc
9690 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9691 remote_ost_nodsh && skip "remote OST with nodsh" && return
9694 local list=$(comma_list $(osts_nodes))
9696 # check whether obdfilter is cache capable at all
9697 if ! get_osd_param $list '' read_cache_enable >/dev/null; then
9698 echo "not cache-capable obdfilter"
9702 # check cache is enabled on all obdfilters
9703 if get_osd_param $list '' read_cache_enable | grep 0; then
9704 echo "oss cache is disabled"
9708 set_osd_param $list '' writethrough_cache_enable 1
9710 # check write cache is enabled on all obdfilters
9711 if get_osd_param $list '' writethrough_cache_enable | grep 0; then
9712 echo "oss write cache is NOT enabled"
9718 #define OBD_FAIL_OBD_NO_LRU 0x609
9719 do_nodes $list $LCTL set_param fail_loc=0x609
9721 # pages should be in the case right after write
9722 dd if=/dev/urandom of=$DIR/$tfile bs=4k count=$CPAGES ||
9725 local BEFORE=$(roc_hit)
9726 cancel_lru_locks osc
9727 cat $DIR/$tfile >/dev/null
9728 local AFTER=$(roc_hit)
9730 do_nodes $list $LCTL set_param fail_loc=0
9732 if ! let "AFTER - BEFORE == CPAGES"; then
9733 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
9736 # the following read invalidates the cache
9737 cancel_lru_locks osc
9738 set_osd_param $list '' read_cache_enable 0
9739 cat $DIR/$tfile >/dev/null
9741 # now data shouldn't be found in the cache
9743 cancel_lru_locks osc
9744 cat $DIR/$tfile >/dev/null
9746 if let "AFTER - BEFORE != 0"; then
9747 error "IN CACHE: before: $BEFORE, after: $AFTER"
9750 set_osd_param $list '' read_cache_enable 1
9753 run_test 151 "test cache on oss and controls ==============================="
9756 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9757 local TF="$TMP/$tfile"
9759 # simulate ENOMEM during write
9760 #define OBD_FAIL_OST_NOMEM 0x226
9761 lctl set_param fail_loc=0x80000226
9762 dd if=/dev/urandom of=$TF bs=6096 count=1 || error "dd failed"
9764 sync || error "sync failed"
9765 lctl set_param fail_loc=0
9767 # discard client's cache
9768 cancel_lru_locks osc
9770 # simulate ENOMEM during read
9771 lctl set_param fail_loc=0x80000226
9772 cmp $TF $DIR/$tfile || error "cmp failed"
9773 lctl set_param fail_loc=0
9777 run_test 152 "test read/write with enomem ============================"
9780 $MULTIOP $DIR/$tfile Ow4096Ycu || error "multiop failed"
9782 run_test 153 "test if fdatasync does not crash ======================="
9784 dot_lustre_fid_permission_check() {
9786 local ffid=$MOUNT/.lustre/fid/$fid
9789 echo "stat fid $fid"
9790 stat $ffid > /dev/null || error "stat $ffid failed."
9791 echo "touch fid $fid"
9792 touch $ffid || error "touch $ffid failed."
9793 echo "write to fid $fid"
9794 cat /etc/hosts > $ffid || error "write $ffid failed."
9795 echo "read fid $fid"
9796 diff /etc/hosts $ffid || error "read $ffid failed."
9797 echo "append write to fid $fid"
9798 cat /etc/hosts >> $ffid || error "append write $ffid failed."
9799 echo "rename fid $fid"
9800 mv $ffid $test_dir/$tfile.1 &&
9801 error "rename $ffid to $tfile.1 should fail."
9802 touch $test_dir/$tfile.1
9803 mv $test_dir/$tfile.1 $ffid &&
9804 error "rename $tfile.1 to $ffid should fail."
9805 rm -f $test_dir/$tfile.1
9806 echo "truncate fid $fid"
9807 $TRUNCATE $ffid 777 || error "truncate $ffid failed."
9808 if [ $MDSCOUNT -lt 2 ]; then #FIXME when cross-MDT hard link is working
9809 echo "link fid $fid"
9810 ln -f $ffid $test_dir/tfile.lnk || error "link $ffid failed."
9812 if [ -n $(lctl get_param -n mdc.*-mdc-*.connect_flags | grep acl) ]; then
9813 echo "setfacl fid $fid"
9814 setfacl -R -m u:bin:rwx $ffid || error "setfacl $ffid failed."
9815 echo "getfacl fid $fid"
9816 getfacl $ffid >/dev/null || error "getfacl $ffid failed."
9818 echo "unlink fid $fid"
9819 unlink $MOUNT/.lustre/fid/$fid && error "unlink $ffid should fail."
9820 echo "mknod fid $fid"
9821 mknod $ffid c 1 3 && error "mknod $ffid should fail."
9823 fid=[0xf00000400:0x1:0x0]
9824 ffid=$MOUNT/.lustre/fid/$fid
9826 echo "stat non-exist fid $fid"
9827 stat $ffid > /dev/null && error "stat non-exist $ffid should fail."
9828 echo "write to non-exist fid $fid"
9829 cat /etc/hosts > $ffid && error "write non-exist $ffid should fail."
9830 echo "link new fid $fid"
9831 ln $test_dir/$tfile $ffid && error "link $ffid should fail."
9833 mkdir -p $test_dir/$tdir
9834 touch $test_dir/$tdir/$tfile
9835 fid=$($LFS path2fid $test_dir/$tdir)
9838 error "error: could not get fid for $test_dir/$dir/$tfile."
9840 ffid=$MOUNT/.lustre/fid/$fid
9843 ls $ffid > /dev/null || error "ls $ffid failed."
9844 echo "touch $fid/$tfile.1"
9845 touch $ffid/$tfile.1 || error "touch $ffid/$tfile.1 failed."
9847 echo "touch $MOUNT/.lustre/fid/$tfile"
9848 touch $MOUNT/.lustre/fid/$tfile && \
9849 error "touch $MOUNT/.lustre/fid/$tfile should fail."
9851 echo "setxattr to $MOUNT/.lustre/fid"
9852 setfattr -n trusted.name1 -v value1 $MOUNT/.lustre/fid
9854 echo "listxattr for $MOUNT/.lustre/fid"
9855 getfattr -d -m "^trusted" $MOUNT/.lustre/fid
9857 echo "delxattr from $MOUNT/.lustre/fid"
9858 setfattr -x trusted.name1 $MOUNT/.lustre/fid
9860 echo "touch invalid fid: $MOUNT/.lustre/fid/[0x200000400:0x2:0x3]"
9861 touch $MOUNT/.lustre/fid/[0x200000400:0x2:0x3] &&
9862 error "touch invalid fid should fail."
9864 echo "touch non-normal fid: $MOUNT/.lustre/fid/[0x1:0x2:0x0]"
9865 touch $MOUNT/.lustre/fid/[0x1:0x2:0x0] &&
9866 error "touch non-normal fid should fail."
9868 echo "rename $tdir to $MOUNT/.lustre/fid"
9869 mrename $test_dir/$tdir $MOUNT/.lustre/fid &&
9870 error "rename to $MOUNT/.lustre/fid should fail."
9872 if [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.3.51) ]
9874 local old_obf_mode=$(stat --format="%a" $DIR/.lustre/fid)
9875 local new_obf_mode=777
9877 echo "change mode of $DIR/.lustre/fid to $new_obf_mode"
9878 chmod $new_obf_mode $DIR/.lustre/fid ||
9879 error "chmod $new_obf_mode $DIR/.lustre/fid failed"
9881 local obf_mode=$(stat --format=%a $DIR/.lustre/fid)
9882 [ $obf_mode -eq $new_obf_mode ] ||
9883 error "stat $DIR/.lustre/fid returned wrong mode $obf_mode"
9885 echo "restore mode of $DIR/.lustre/fid to $old_obf_mode"
9886 chmod $old_obf_mode $DIR/.lustre/fid ||
9887 error "chmod $old_obf_mode $DIR/.lustre/fid failed"
9890 $OPENFILE -f O_LOV_DELAY_CREATE:O_CREAT $test_dir/$tfile-2
9891 fid=$($LFS path2fid $test_dir/$tfile-2)
9893 if [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.6.50) ]
9895 echo "cp /etc/passwd $MOUNT/.lustre/fid/$fid"
9896 cp /etc/passwd $MOUNT/.lustre/fid/$fid ||
9897 error "create lov data thru .lustre failed"
9899 echo "cp /etc/passwd $test_dir/$tfile-2"
9900 cp /etc/passwd $test_dir/$tfile-2 ||
9901 error "copy to $test_dir/$tfile-2 failed."
9902 echo "diff /etc/passwd $MOUNT/.lustre/fid/$fid"
9903 diff /etc/passwd $MOUNT/.lustre/fid/$fid ||
9904 error "diff /etc/passwd $MOUNT/.lustre/fid/$fid failed."
9906 rm -rf $test_dir/tfile.lnk
9907 rm -rf $test_dir/$tfile-2
9911 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.1) ]] &&
9912 skip "Need MDS version at least 2.4.1" && return
9915 local FID=$($LFS path2fid $DIR/$tfile)
9916 [ -z "$FID" ] && error "path2fid unable to get $DIR/$tfile FID"
9918 # check that we get the same pathname back
9919 local FOUND=$($LFS fid2path $MOUNT "$FID")
9920 [ -z "$FOUND" ] && error "fid2path unable to get $FID path"
9921 [ "$FOUND" != "$DIR/$tfile" ] &&
9922 error "fid2path(path2fid($DIR/$tfile)) = $FOUND != $DIR/$tfile"
9926 run_test 154A "lfs path2fid and fid2path basic checks"
9929 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9930 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.51) ]] ||
9931 { skip "Need MDS version at least 2.2.51"; return 0; }
9932 [ -z "$(which setfacl)" ] && skip "must have setfacl tool" && return
9934 cp /etc/hosts $DIR/$tfile
9936 fid=$($LFS path2fid $DIR/$tfile)
9938 [ $rc -ne 0 ] && error "error: could not get fid for $DIR/$tfile."
9940 dot_lustre_fid_permission_check "$fid" $DIR ||
9941 error "dot lustre permission check $fid failed"
9943 rm -rf $MOUNT/.lustre && error ".lustre is not allowed to be unlinked"
9945 touch $MOUNT/.lustre/file &&
9946 error "creation is not allowed under .lustre"
9948 mkdir $MOUNT/.lustre/dir &&
9949 error "mkdir is not allowed under .lustre"
9953 run_test 154a "Open-by-FID"
9956 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9957 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.51) ]] ||
9958 { skip "Need MDS version at least 2.2.51"; return 0; }
9960 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
9962 local remote_dir=$DIR/$tdir/remote_dir
9967 $LFS mkdir -i $MDTIDX $remote_dir ||
9968 error "create remote directory failed"
9970 cp /etc/hosts $remote_dir/$tfile
9972 fid=$($LFS path2fid $remote_dir/$tfile)
9974 [ $rc -ne 0 ] && error "error: could not get fid for $remote_dir/$tfile"
9976 dot_lustre_fid_permission_check "$fid" $remote_dir ||
9977 error "dot lustre permission check $fid failed"
9980 run_test 154b "Open-by-FID for remote directory"
9983 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.1) ]] &&
9984 skip "Need MDS version at least 2.4.1" && return
9986 touch $DIR/$tfile.1 $DIR/$tfile.2 $DIR/$tfile.3
9987 local FID1=$($LFS path2fid $DIR/$tfile.1)
9988 local FID2=$($LFS path2fid $DIR/$tfile.2)
9989 local FID3=$($LFS path2fid $DIR/$tfile.3)
9992 $LFS path2fid $DIR/$tfile.[123] | while read PATHNAME FID; do
9993 [ "$PATHNAME" = "$DIR/$tfile.$N:" ] ||
9994 error "path2fid pathname $PATHNAME != $DIR/$tfile.$N:"
9996 [ "$FID" = "${!want}" ] ||
9997 error "path2fid $PATHNAME FID $FID != FID$N ${!want}"
10001 $LFS fid2path $MOUNT "$FID1" "$FID2" "$FID3" | while read PATHNAME;
10003 [ "$PATHNAME" = "$DIR/$tfile.$N" ] ||
10004 error "fid2path pathname $PATHNAME != $DIR/$tfile.$N:"
10008 run_test 154c "lfs path2fid and fid2path multiple arguments"
10011 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.5.53) ]] &&
10012 skip "Need MDS version at least 2.5.53" && return
10014 if remote_mds; then
10015 nid=$($LCTL list_nids | sed "s/\./\\\./g")
10019 local proc_ofile="mdt.*.exports.'$nid'.open_files"
10026 local fid=$($LFS path2fid $DIR/$tfile)
10029 cmd="exec $fd<$DIR/$tfile"
10031 local fid_list=$(do_facet $SINGLEMDS $LCTL get_param $proc_ofile)
10032 echo "$fid_list" | grep "$fid"
10035 cmd="exec $fd>/dev/null"
10037 if [ $rc -ne 0 ]; then
10038 error "FID $fid not found in open files list $fid_list"
10041 run_test 154d "Verify open file fid"
10045 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.6.50) ]] &&
10046 skip "Need MDS version at least 2.6.50" && return
10048 if ls -a $MOUNT | grep -q '^\.lustre$'; then
10049 error ".lustre returned by readdir"
10052 run_test 154e ".lustre is not returned by readdir"
10055 # create parent directory on a single MDT to avoid cross-MDT hardlinks
10056 test_mkdir -p -c1 $DIR/$tdir/d
10057 # test dirs inherit from its stripe
10058 mkdir -p $DIR/$tdir/d/foo1 || error "mkdir error"
10059 mkdir -p $DIR/$tdir/d/foo2 || error "mkdir error"
10060 cp /etc/hosts $DIR/$tdir/d/foo1/$tfile
10061 ln $DIR/$tdir/d/foo1/$tfile $DIR/$tdir/d/foo2/link
10064 # get fid of parents
10065 local FID0=$($LFS path2fid $DIR/$tdir/d)
10066 local FID1=$($LFS path2fid $DIR/$tdir/d/foo1)
10067 local FID2=$($LFS path2fid $DIR/$tdir/d/foo2)
10068 local FID3=$($LFS path2fid $DIR)
10070 # check that path2fid --parents returns expected <parent_fid>/name
10071 # 1) test for a directory (single parent)
10072 local parent=$($LFS path2fid --parents $DIR/$tdir/d/foo1)
10073 [ "$parent" == "$FID0/foo1" ] ||
10074 error "expected parent: $FID0/foo1, got: $parent"
10076 # 2) test for a file with nlink > 1 (multiple parents)
10077 parent=$($LFS path2fid --parents $DIR/$tdir/d/foo1/$tfile)
10078 echo "$parent" | grep -F "$FID1/$tfile" ||
10079 error "$FID1/$tfile not returned in parent list"
10080 echo "$parent" | grep -F "$FID2/link" ||
10081 error "$FID2/link not returned in parent list"
10083 # 3) get parent by fid
10084 local file_fid=$($LFS path2fid $DIR/$tdir/d/foo1/$tfile)
10085 parent=$($LFS path2fid --parents $MOUNT/.lustre/fid/$file_fid)
10086 echo "$parent" | grep -F "$FID1/$tfile" ||
10087 error "$FID1/$tfile not returned in parent list (by fid)"
10088 echo "$parent" | grep -F "$FID2/link" ||
10089 error "$FID2/link not returned in parent list (by fid)"
10091 # 4) test for entry in root directory
10092 parent=$($LFS path2fid --parents $DIR/f)
10093 echo "$parent" | grep -F "$FID3/f" ||
10094 error "$FID3/f not returned in parent list"
10096 # 5) test it on root directory
10097 [ -z "$($LFS path2fid --parents $MOUNT 2>/dev/null)" ] ||
10098 error "$MOUNT should not have parents"
10100 # enable xattr caching and check that linkea is correctly updated
10101 local save="$TMP/$TESTSUITE-$TESTNAME.parameters"
10102 save_lustre_params client "llite.*.xattr_cache" > $save
10103 lctl set_param llite.*.xattr_cache 1
10105 # 6.1) linkea update on rename
10106 mv $DIR/$tdir/d/foo1/$tfile $DIR/$tdir/d/foo2/$tfile.moved
10108 # get parents by fid
10109 parent=$($LFS path2fid --parents $MOUNT/.lustre/fid/$file_fid)
10110 # foo1 should no longer be returned in parent list
10111 echo "$parent" | grep -F "$FID1" &&
10112 error "$FID1 should no longer be in parent list"
10113 # the new path should appear
10114 echo "$parent" | grep -F "$FID2/$tfile.moved" ||
10115 error "$FID2/$tfile.moved is not in parent list"
10117 # 6.2) linkea update on unlink
10118 rm -f $DIR/$tdir/d/foo2/link
10119 parent=$($LFS path2fid --parents $MOUNT/.lustre/fid/$file_fid)
10120 # foo2/link should no longer be returned in parent list
10121 echo "$parent" | grep -F "$FID2/link" &&
10122 error "$FID2/link should no longer be in parent list"
10126 restore_lustre_params < $save
10128 run_test 154f "get parent fids by reading link ea"
10132 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.6.92) ]] ||
10133 { skip "Need MDS version at least 2.6.92"; return 0; }
10135 mkdir -p $DIR/$tdir
10136 llapi_fid_test -d $DIR/$tdir
10138 run_test 154g "various llapi FID tests"
10140 test_155_small_load() {
10141 local temp=$TMP/$tfile
10142 local file=$DIR/$tfile
10144 dd if=/dev/urandom of=$temp bs=6096 count=1 || \
10145 error "dd of=$temp bs=6096 count=1 failed"
10147 cancel_lru_locks osc
10148 cmp $temp $file || error "$temp $file differ"
10150 $TRUNCATE $temp 6000
10151 $TRUNCATE $file 6000
10152 cmp $temp $file || error "$temp $file differ (truncate1)"
10154 echo "12345" >>$temp
10155 echo "12345" >>$file
10156 cmp $temp $file || error "$temp $file differ (append1)"
10158 echo "12345" >>$temp
10159 echo "12345" >>$file
10160 cmp $temp $file || error "$temp $file differ (append2)"
10166 test_155_big_load() {
10167 remote_ost_nodsh && skip "remote OST with nodsh" && return
10168 local temp=$TMP/$tfile
10169 local file=$DIR/$tfile
10172 local cache_size=$(do_facet ost$((MAXI+1)) \
10173 "awk '/cache/ {sum+=\\\$4} END {print sum}' /proc/cpuinfo")
10174 local large_file_size=$((cache_size * 2))
10176 echo "OSS cache size: $cache_size KB"
10177 echo "Large file size: $large_file_size KB"
10179 [ $MAXV -le $large_file_size ] && \
10180 skip_env "max available OST size needs > $large_file_size KB" && \
10183 $SETSTRIPE $file -c 1 -i $MAXI || error "$SETSTRIPE $file failed"
10185 dd if=/dev/urandom of=$temp bs=$large_file_size count=1k || \
10186 error "dd of=$temp bs=$large_file_size count=1k failed"
10189 cancel_lru_locks osc
10190 cmp $temp $file || error "$temp $file differ"
10197 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10199 set_cache writethrough on
10200 test_155_small_load
10202 run_test 155a "Verify small file correctness: read cache:on write_cache:on"
10205 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10207 set_cache writethrough off
10208 test_155_small_load
10210 run_test 155b "Verify small file correctness: read cache:on write_cache:off"
10213 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10215 set_cache writethrough on
10216 test_155_small_load
10218 run_test 155c "Verify small file correctness: read cache:off write_cache:on"
10221 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10223 set_cache writethrough off
10224 test_155_small_load
10226 run_test 155d "Verify small file correctness: read cache:off write_cache:off"
10229 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10231 set_cache writethrough on
10234 run_test 155e "Verify big file correctness: read cache:on write_cache:on"
10237 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10239 set_cache writethrough off
10242 run_test 155f "Verify big file correctness: read cache:on write_cache:off"
10245 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10247 set_cache writethrough on
10250 run_test 155g "Verify big file correctness: read cache:off write_cache:on"
10253 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10255 set_cache writethrough off
10258 run_test 155h "Verify big file correctness: read cache:off write_cache:off"
10261 remote_ost_nodsh && skip "remote OST with nodsh" && return
10262 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10266 local file="$DIR/$tfile"
10268 [ "$(facet_fstype ost1)" = "zfs" -a \
10269 $(lustre_version_code ost1 -lt $(version_code 2.6.93)) ] &&
10270 skip "LU-1956/LU-2261: stats not implemented on OSD ZFS" &&
10275 log "Turn on read and write cache"
10277 set_cache writethrough on
10279 log "Write data and read it back."
10280 log "Read should be satisfied from the cache."
10281 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
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 "Read again; it should be satisfied from the cache."
10294 cancel_lru_locks osc
10295 cat $file >/dev/null
10297 if ! let "AFTER - BEFORE == CPAGES"; then
10298 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
10300 log "cache hits:: before: $BEFORE, after: $AFTER"
10303 log "Turn off the read cache and turn on the write cache"
10305 set_cache writethrough on
10307 log "Read again; it should be satisfied from the cache."
10309 cancel_lru_locks osc
10310 cat $file >/dev/null
10312 if ! let "AFTER - BEFORE == CPAGES"; then
10313 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
10315 log "cache hits:: before: $BEFORE, after: $AFTER"
10318 log "Read again; it should not be satisfied from the cache."
10320 cancel_lru_locks osc
10321 cat $file >/dev/null
10323 if ! let "AFTER - BEFORE == 0"; then
10324 error "IN CACHE: before: $BEFORE, after: $AFTER"
10326 log "cache hits:: before: $BEFORE, after: $AFTER"
10329 log "Write data and read it back."
10330 log "Read should be satisfied from the cache."
10331 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
10333 cancel_lru_locks osc
10334 cat $file >/dev/null
10336 if ! let "AFTER - BEFORE == CPAGES"; then
10337 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
10339 log "cache hits:: before: $BEFORE, after: $AFTER"
10342 log "Read again; it should not be satisfied from the cache."
10344 cancel_lru_locks osc
10345 cat $file >/dev/null
10347 if ! let "AFTER - BEFORE == 0"; then
10348 error "IN CACHE: before: $BEFORE, after: $AFTER"
10350 log "cache hits:: before: $BEFORE, after: $AFTER"
10353 log "Turn off read and write cache"
10355 set_cache writethrough off
10357 log "Write data and read it back"
10358 log "It should not be satisfied from the cache."
10360 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
10361 cancel_lru_locks osc
10363 cat $file >/dev/null
10365 if ! let "AFTER - BEFORE == 0"; then
10366 error_ignore bz20762 "IN CACHE: before: $BEFORE, after: $AFTER"
10368 log "cache hits:: before: $BEFORE, after: $AFTER"
10371 log "Turn on the read cache and turn off the write cache"
10373 set_cache writethrough off
10375 log "Write data and read it back"
10376 log "It should not be satisfied from the cache."
10378 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
10380 cancel_lru_locks osc
10381 cat $file >/dev/null
10383 if ! let "AFTER - BEFORE == 0"; then
10384 error_ignore bz20762 "IN CACHE: before: $BEFORE, after: $AFTER"
10386 log "cache hits:: before: $BEFORE, after: $AFTER"
10389 log "Read again; it should be satisfied from the cache."
10391 cancel_lru_locks osc
10392 cat $file >/dev/null
10394 if ! let "AFTER - BEFORE == CPAGES"; then
10395 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
10397 log "cache hits:: before: $BEFORE, after: $AFTER"
10402 run_test 156 "Verification of tunables"
10406 if [[ $MDSCOUNT -gt 1 ]]; then
10407 error_ignore bz17935 $*
10415 local CL_MASK_PARAM="mdd.$MDT0.changelog_mask"
10417 MASK=$(do_facet $SINGLEMDS $LCTL get_param $CL_MASK_PARAM| grep -c "$1")
10419 if [ $MASK -eq 1 ]; then
10420 do_facet $SINGLEMDS $LCTL set_param $CL_MASK_PARAM="-$1"
10422 do_facet $SINGLEMDS $LCTL set_param $CL_MASK_PARAM="+$1"
10426 changelog_extract_field() {
10430 local identifier=$4
10432 $LFS changelog $mdt | gawk "/$cltype.*$file$/ {
10433 print gensub(/^.* "$identifier'(\[[^\]]*\]).*$/,"\\1",1)}' |
10438 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10439 remote_mds_nodsh && skip "remote MDS with nodsh" && return
10440 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] ||
10441 { skip "Need MDS version at least 2.2.0"; return; }
10443 local CL_USERS="mdd.$MDT0.changelog_users"
10444 local GET_CL_USERS="do_facet $SINGLEMDS $LCTL get_param -n $CL_USERS"
10445 USER=$(do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_register -n)
10446 echo "Registered as changelog user $USER"
10447 $GET_CL_USERS | grep -q $USER ||
10448 error "User $USER not found in changelog_users"
10451 test_mkdir -p $DIR/$tdir/pics/2008/zachy
10452 touch $DIR/$tdir/pics/2008/zachy/timestamp
10453 cp /etc/hosts $DIR/$tdir/pics/2008/zachy/pic1.jpg
10454 mv $DIR/$tdir/pics/2008/zachy $DIR/$tdir/pics/zach
10455 ln $DIR/$tdir/pics/zach/pic1.jpg $DIR/$tdir/pics/2008/portland.jpg
10456 ln -s $DIR/$tdir/pics/2008/portland.jpg $DIR/$tdir/pics/desktop.jpg
10457 rm $DIR/$tdir/pics/desktop.jpg
10459 $LFS changelog $MDT0 | tail -5
10461 echo "verifying changelog mask"
10462 changelog_chmask "MKDIR"
10463 changelog_chmask "CLOSE"
10465 test_mkdir -p $DIR/$tdir/pics/zach/sofia
10466 echo "zzzzzz" > $DIR/$tdir/pics/zach/file
10468 changelog_chmask "MKDIR"
10469 changelog_chmask "CLOSE"
10471 test_mkdir -p $DIR/$tdir/pics/2008/sofia
10472 echo "zzzzzz" > $DIR/$tdir/pics/zach/file
10474 $LFS changelog $MDT0
10475 MKDIRS=$($LFS changelog $MDT0 | tail -5 | grep -c "MKDIR")
10476 CLOSES=$($LFS changelog $MDT0 | tail -5 | grep -c "CLOSE")
10477 [ $MKDIRS -eq 1 ] || err17935 "MKDIR changelog mask count $DIRS != 1"
10478 [ $CLOSES -eq 1 ] || err17935 "CLOSE changelog mask count $DIRS != 1"
10481 echo "verifying target fid"
10482 fidc=$(changelog_extract_field $MDT0 "CREAT" "timestamp" "t=")
10483 fidf=$($LFS path2fid $DIR/$tdir/pics/zach/timestamp)
10484 [ "$fidc" == "$fidf" ] ||
10485 err17935 "fid in changelog $fidc != file fid $fidf"
10486 echo "verifying parent fid"
10487 fidc=$(changelog_extract_field $MDT0 "CREAT" "timestamp" "p=")
10488 fidf=$($LFS path2fid $DIR/$tdir/pics/zach)
10489 [ "$fidc" == "$fidf" ] ||
10490 err17935 "pfid in changelog $fidc != dir fid $fidf"
10492 USER_REC1=$($GET_CL_USERS | awk "\$1 == \"$USER\" {print \$2}")
10493 $LFS changelog_clear $MDT0 $USER $(($USER_REC1 + 5))
10494 USER_REC2=$($GET_CL_USERS | awk "\$1 == \"$USER\" {print \$2}")
10495 echo "verifying user clear: $(( $USER_REC1 + 5 )) == $USER_REC2"
10496 [ $USER_REC2 == $(($USER_REC1 + 5)) ] ||
10497 err17935 "user index expected $(($USER_REC1 + 5)) is $USER_REC2"
10499 MIN_REC=$($GET_CL_USERS |
10500 awk 'min == "" || $2 < min {min = $2}; END {print min}')
10501 FIRST_REC=$($LFS changelog $MDT0 | head -n1 | awk '{print $1}')
10502 echo "verifying min purge: $(( $MIN_REC + 1 )) == $FIRST_REC"
10503 [ $FIRST_REC == $(($MIN_REC + 1)) ] ||
10504 err17935 "first index should be $(($MIN_REC + 1)) is $FIRST_REC"
10506 # LU-3446 changelog index reset on MDT restart
10507 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
10508 CUR_REC1=$($GET_CL_USERS | head -n1 | cut -f3 -d' ')
10509 $LFS changelog_clear $MDT0 $USER 0
10510 stop $SINGLEMDS || error "Fail to stop MDT."
10511 start $SINGLEMDS $MDT_DEV $MDS_MOUNT_OPTS || error "Fail to start MDT."
10512 CUR_REC2=$($GET_CL_USERS | head -n1 | cut -f3 -d' ')
10513 echo "verifying index survives MDT restart: $CUR_REC1 == $CUR_REC2"
10514 [ $CUR_REC1 == $CUR_REC2 ] ||
10515 err17935 "current index should be $CUR_REC1 is $CUR_REC2"
10517 echo "verifying user deregister"
10518 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister $USER
10519 $GET_CL_USERS | grep -q $USER &&
10520 error "User $USER still in changelog_users"
10522 USERS=$(( $($GET_CL_USERS | wc -l) - 2 ))
10523 if [ $USERS -eq 0 ]; then
10524 LAST_REC1=$($GET_CL_USERS | head -n1 | cut -f3 -d' ')
10525 touch $DIR/$tdir/chloe
10526 LAST_REC2=$($GET_CL_USERS | head -n1 | cut -f3 -d' ')
10527 echo "verify changelogs are off: $LAST_REC1 == $LAST_REC2"
10528 [ $LAST_REC1 == $LAST_REC2 ] || error "changelogs not off"
10530 echo "$USERS other changelog users; can't verify off"
10533 run_test 160a "changelog sanity"
10535 test_160b() { # LU-3587
10536 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10537 remote_mds_nodsh && skip "remote MDS with nodsh" && return
10538 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] ||
10539 { skip "Need MDS version at least 2.2.0"; return; }
10541 local CL_USERS="mdd.$MDT0.changelog_users"
10542 local GET_CL_USERS="do_facet $SINGLEMDS $LCTL get_param -n $CL_USERS"
10543 USER=$(do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_register -n)
10544 echo "Registered as changelog user $USER"
10545 $GET_CL_USERS | grep -q $USER ||
10546 error "User $USER not found in changelog_users"
10548 local LONGNAME1=$(str_repeat a 255)
10549 local LONGNAME2=$(str_repeat b 255)
10552 echo "creating very long named file"
10553 touch $LONGNAME1 || error "create of $LONGNAME1 failed"
10554 echo "moving very long named file"
10555 mv $LONGNAME1 $LONGNAME2
10557 $LFS changelog $MDT0 | grep RENME
10559 echo "deregistering $USER"
10560 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister $USER
10564 run_test 160b "Verify that very long rename doesn't crash in changelog"
10567 remote_mds_nodsh && skip "remote MDS with nodsh" && return
10570 local server_version=$(lustre_version_code $SINGLEMDS)
10572 [[ $server_version -gt $(version_code 2.5.57) ]] ||
10573 [[ $server_version -gt $(version_code 2.5.1) &&
10574 $server_version -lt $(version_code 2.5.50) ]] ||
10575 { skip "Need MDS version at least 2.5.58 or 2.5.2+"; return; }
10576 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10578 # Registration step
10579 local USER=$(do_facet $SINGLEMDS $LCTL --device $MDT0 \
10580 changelog_register -n)
10583 mkdir -p $DIR/$tdir
10584 $MCREATE $DIR/$tdir/foo_160c
10585 changelog_chmask "TRUNC"
10586 $TRUNCATE $DIR/$tdir/foo_160c 200
10587 changelog_chmask "TRUNC"
10588 $TRUNCATE $DIR/$tdir/foo_160c 199
10589 $LFS changelog $MDT0
10590 TRUNCS=$($LFS changelog $MDT0 | tail -5 | grep -c "TRUNC")
10591 [ $TRUNCS -eq 1 ] || err17935 "TRUNC changelog mask count $TRUNCS != 1"
10592 $LFS changelog_clear $MDT0 $USER 0
10594 # Deregistration step
10595 echo "deregistering $USER"
10596 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister $USER
10598 run_test 160c "verify that changelog log catch the truncate event"
10601 remote_mds_nodsh && skip "remote MDS with nodsh" && return
10602 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
10604 local server_version=$(lustre_version_code mds1)
10605 local CL_MASK_PARAM="mdd.$MDT0.changelog_mask"
10607 [[ $server_version -ge $(version_code 2.7.60) ]] ||
10608 { skip "Need MDS version at least 2.7.60+"; return; }
10609 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10611 # Registration step
10612 local USER=$(do_facet mds1 $LCTL --device $MDT0 \
10613 changelog_register -n)
10615 mkdir -p $DIR/$tdir/migrate_dir
10616 $LFS changelog_clear $MDT0 $USER 0
10618 $LFS migrate -m 1 $DIR/$tdir/migrate_dir || error "migrate fails"
10619 $LFS changelog $MDT0
10620 MIGRATES=$($LFS changelog $MDT0 | tail -5 | grep -c "MIGRT")
10621 $LFS changelog_clear $MDT0 $USER 0
10622 [ $MIGRATES -eq 1 ] ||
10623 error "MIGRATE changelog mask count $MIGRATES != 1"
10625 # Deregistration step
10626 do_facet mds1 $LCTL --device $MDT0 changelog_deregister $USER
10628 run_test 160d "verify that changelog log catch the migrate event"
10631 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10632 test_mkdir -p -c1 $DIR/$tdir
10633 cp /etc/hosts $DIR/$tdir/$tfile
10634 test_mkdir -c1 $DIR/$tdir/foo1
10635 test_mkdir -c1 $DIR/$tdir/foo2
10636 ln $DIR/$tdir/$tfile $DIR/$tdir/foo1/sofia
10637 ln $DIR/$tdir/$tfile $DIR/$tdir/foo2/zachary
10638 ln $DIR/$tdir/$tfile $DIR/$tdir/foo1/luna
10639 ln $DIR/$tdir/$tfile $DIR/$tdir/foo2/thor
10640 local FID=$($LFS path2fid $DIR/$tdir/$tfile | tr -d '[]')
10641 if [ "$($LFS fid2path $DIR $FID | wc -l)" != "5" ]; then
10642 $LFS fid2path $DIR $FID
10643 err17935 "bad link ea"
10646 rm $DIR/$tdir/foo2/zachary
10648 rm $DIR/$tdir/foo2/thor
10650 rm $DIR/$tdir/$tfile
10652 mv $DIR/$tdir/foo1/sofia $DIR/$tdir/foo2/maggie
10653 if [ "$($LFS fid2path $FSNAME --link 1 $FID)" != "$tdir/foo2/maggie" ]
10655 $LFS fid2path $DIR $FID
10656 err17935 "bad link rename"
10658 rm $DIR/$tdir/foo2/maggie
10661 local longname=filename_avg_len_is_thirty_two_
10662 createmany -l$DIR/$tdir/foo1/luna $DIR/$tdir/foo2/$longname 1000 ||
10663 error "failed to hardlink many files"
10664 links=$($LFS fid2path $DIR $FID | wc -l)
10665 echo -n "${links}/1000 links in link EA"
10666 [[ $links -gt 60 ]] ||
10667 err17935 "expected at least 60 links in link EA"
10668 unlinkmany $DIR/$tdir/foo2/$longname 1000 ||
10669 error "failed to unlink many hardlinks"
10671 run_test 161a "link ea sanity"
10674 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10675 [ $MDSCOUNT -lt 2 ] &&
10676 skip "skipping remote directory test" && return
10678 local remote_dir=$DIR/$tdir/remote_dir
10680 mkdir -p $DIR/$tdir
10681 $LFS mkdir -i $MDTIDX $remote_dir ||
10682 error "create remote directory failed"
10684 cp /etc/hosts $remote_dir/$tfile
10685 mkdir -p $remote_dir/foo1
10686 mkdir -p $remote_dir/foo2
10687 ln $remote_dir/$tfile $remote_dir/foo1/sofia
10688 ln $remote_dir/$tfile $remote_dir/foo2/zachary
10689 ln $remote_dir/$tfile $remote_dir/foo1/luna
10690 ln $remote_dir/$tfile $remote_dir/foo2/thor
10692 local FID=$($LFS path2fid $remote_dir/$tfile | tr -d '[' |
10694 if [ "$($LFS fid2path $DIR $FID | wc -l)" != "5" ]; then
10695 $LFS fid2path $DIR $FID
10696 err17935 "bad link ea"
10699 rm $remote_dir/foo2/zachary
10701 rm $remote_dir/foo2/thor
10703 rm $remote_dir/$tfile
10705 mv $remote_dir/foo1/sofia $remote_dir/foo2/maggie
10706 local link_path=$($LFS fid2path $FSNAME --link 1 $FID)
10707 if [ "$DIR/$link_path" != "$remote_dir/foo2/maggie" ]; then
10708 $LFS fid2path $DIR $FID
10709 err17935 "bad link rename"
10711 rm $remote_dir/foo2/maggie
10714 local longname=filename_avg_len_is_thirty_two_
10715 createmany -l$remote_dir/foo1/luna $remote_dir/foo2/$longname 1000 ||
10716 error "failed to hardlink many files"
10717 links=$($LFS fid2path $DIR $FID | wc -l)
10718 echo -n "${links}/1000 links in link EA"
10719 [[ ${links} -gt 60 ]] ||
10720 err17935 "expected at least 60 links in link EA"
10721 unlinkmany $remote_dir/foo2/$longname 1000 ||
10722 error "failed to unlink many hardlinks"
10724 run_test 161b "link ea sanity under remote directory"
10727 remote_mds_nodsh && skip "remote MDS with nodsh" && return
10728 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10729 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.1.5) ]] &&
10730 skip "Need MDS version at least 2.1.5" && return
10732 # define CLF_RENAME_LAST 0x0001
10733 # rename overwrite a target having nlink = 1 (changelog flag 0x1)
10734 local USER=$(do_facet $SINGLEMDS $LCTL --device $MDT0 \
10735 changelog_register -n)
10737 mkdir -p $DIR/$tdir
10738 touch $DIR/$tdir/foo_161c
10739 touch $DIR/$tdir/bar_161c
10740 mv -f $DIR/$tdir/foo_161c $DIR/$tdir/bar_161c
10741 $LFS changelog $MDT0 | grep RENME
10742 local flags=$($LFS changelog $MDT0 | grep RENME | tail -1 | \
10744 $LFS changelog_clear $MDT0 $USER 0
10745 if [ x$flags != "x0x1" ]; then
10746 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister \
10748 error "flag $flags is not 0x1"
10750 echo "rename overwrite a target having nlink = 1," \
10751 "changelog record has flags of $flags"
10753 # rename overwrite a target having nlink > 1 (changelog flag 0x0)
10754 touch $DIR/$tdir/foo_161c
10755 touch $DIR/$tdir/bar_161c
10756 ln $DIR/$tdir/bar_161c $DIR/$tdir/foobar_161c
10757 mv -f $DIR/$tdir/foo_161c $DIR/$tdir/bar_161c
10758 $LFS changelog $MDT0 | grep RENME
10759 flags=$($LFS changelog $MDT0 | grep RENME | tail -1 | cut -f5 -d' ')
10760 $LFS changelog_clear $MDT0 $USER 0
10761 if [ x$flags != "x0x0" ]; then
10762 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister \
10764 error "flag $flags is not 0x0"
10766 echo "rename overwrite a target having nlink > 1," \
10767 "changelog record has flags of $flags"
10769 # rename doesn't overwrite a target (changelog flag 0x0)
10770 touch $DIR/$tdir/foo_161c
10771 mv -f $DIR/$tdir/foo_161c $DIR/$tdir/foo2_161c
10772 $LFS changelog $MDT0 | grep RENME
10773 flags=$($LFS changelog $MDT0 | grep RENME | tail -1 | cut -f5 -d' ')
10774 $LFS changelog_clear $MDT0 $USER 0
10775 if [ x$flags != "x0x0" ]; then
10776 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister \
10778 error "flag $flags is not 0x0"
10780 echo "rename doesn't overwrite a target," \
10781 "changelog record has flags of $flags"
10783 # define CLF_UNLINK_LAST 0x0001
10784 # unlink a file having nlink = 1 (changelog flag 0x1)
10785 rm -f $DIR/$tdir/foo2_161c
10786 $LFS changelog $MDT0 | grep UNLNK
10787 flags=$($LFS changelog $MDT0 | grep UNLNK | tail -1 | cut -f5 -d' ')
10788 $LFS changelog_clear $MDT0 $USER 0
10789 if [ x$flags != "x0x1" ]; then
10790 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister \
10792 error "flag $flags is not 0x1"
10794 echo "unlink a file having nlink = 1," \
10795 "changelog record has flags of $flags"
10797 # unlink a file having nlink > 1 (changelog flag 0x0)
10798 ln -f $DIR/$tdir/bar_161c $DIR/$tdir/foobar_161c
10799 rm -f $DIR/$tdir/foobar_161c
10800 $LFS changelog $MDT0 | grep UNLNK
10801 flags=$($LFS changelog $MDT0 | grep UNLNK | tail -1 | cut -f5 -d' ')
10802 $LFS changelog_clear $MDT0 $USER 0
10803 if [ x$flags != "x0x0" ]; then
10804 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister \
10806 error "flag $flags is not 0x0"
10808 echo "unlink a file having nlink > 1," \
10809 "changelog record has flags of $flags"
10810 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister $USER
10812 run_test 161c "check CL_RENME[UNLINK] changelog record flags"
10819 local path=$(${LFS} fid2path $*)
10820 # Remove the '//' indicating a remote directory
10821 path=$(echo $path | sed 's#//#/#g')
10824 if [ $RC -ne 0 ]; then
10825 err17935 "path looked up of $expected failed. Error $RC"
10827 elif [ "${path}" != "${expected}" ]; then
10828 err17935 "path looked up \"${path}\" instead of \"${expected}\""
10831 echo "fid $fid resolves to path $path (expected $expected)"
10834 test_162a() { # was test_162
10835 # Make changes to filesystem
10836 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10837 test_mkdir -p -c1 $DIR/$tdir/d2
10838 touch $DIR/$tdir/d2/$tfile
10839 touch $DIR/$tdir/d2/x1
10840 touch $DIR/$tdir/d2/x2
10841 test_mkdir -p -c1 $DIR/$tdir/d2/a/b/c
10842 test_mkdir -p -c1 $DIR/$tdir/d2/p/q/r
10844 FID=$($LFS path2fid $DIR/$tdir/d2/$tfile | tr -d '[]')
10845 check_path "$tdir/d2/$tfile" $FSNAME $FID --link 0 ||
10846 error "check path $tdir/d2/$tfile failed"
10849 ln -s $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/p/q/r/slink
10850 FID=$($LFS path2fid $DIR/$tdir/d2/p/q/r/slink | tr -d '[]')
10851 check_path "$tdir/d2/p/q/r/slink" $FSNAME $FID --link 0 ||
10852 error "check path $tdir/d2/p/q/r/slink failed"
10854 # softlink to wrong file
10855 ln -s /this/is/garbage $DIR/$tdir/d2/p/q/r/slink.wrong
10856 FID=$($LFS path2fid $DIR/$tdir/d2/p/q/r/slink.wrong | tr -d '[]')
10857 check_path "$tdir/d2/p/q/r/slink.wrong" $FSNAME $FID --link 0 ||
10858 error "check path $tdir/d2/p/q/r/slink.wrong failed"
10861 ln $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/p/q/r/hlink
10862 mv $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/a/b/c/new_file
10863 FID=$($LFS path2fid $DIR/$tdir/d2/a/b/c/new_file | tr -d '[]')
10864 # fid2path dir/fsname should both work
10865 check_path "$tdir/d2/a/b/c/new_file" $FSNAME $FID --link 1 ||
10866 error "check path $tdir/d2/a/b/c/new_file failed"
10867 check_path "$DIR/$tdir/d2/p/q/r/hlink" $DIR $FID --link 0 ||
10868 error "check path $DIR/$tdir/d2/p/q/r/hlink failed"
10870 # hardlink count: check that there are 2 links
10871 # Doesnt work with CMD yet: 17935
10872 ${LFS} fid2path $DIR $FID | wc -l | grep -q 2 || \
10873 err17935 "expected 2 links"
10875 # hardlink indexing: remove the first link
10876 rm $DIR/$tdir/d2/p/q/r/hlink
10877 check_path "$tdir/d2/a/b/c/new_file" $FSNAME $FID --link 0 ||
10878 error "check path $DIR/$tdir/d2/a/b/c/new_file failed"
10882 run_test 162a "path lookup sanity"
10885 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10886 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
10889 $LFS setdirstripe -i0 -c$MDSCOUNT -t all_char $DIR/$tdir/striped_dir ||
10890 error "create striped dir failed"
10892 local FID=$($LFS getdirstripe $DIR/$tdir/striped_dir |
10893 tail -n 1 | awk '{print $2}')
10894 stat $MOUNT/.lustre/fid/$FID && error "sub_stripe can be accessed"
10896 touch $DIR/$tdir/striped_dir/f{0..4} || error "touch f0..4 failed"
10897 mkdir $DIR/$tdir/striped_dir/d{0..4} || error "mkdir d0..4 failed"
10900 for ((i=0;i<5;i++)); do
10901 FID=$($LFS path2fid $DIR/$tdir/striped_dir/f$i | tr -d '[]') ||
10902 error "get fid for f$i failed"
10903 check_path "$tdir/striped_dir/f$i" $FSNAME $FID --link 0 ||
10904 error "check path $tdir/striped_dir/f$i failed"
10906 FID=$($LFS path2fid $DIR/$tdir/striped_dir/d$i | tr -d '[]') ||
10907 error "get fid for d$i failed"
10908 check_path "$tdir/striped_dir/d$i" $FSNAME $FID --link 0 ||
10909 error "check path $tdir/striped_dir/d$i failed"
10914 run_test 162b "striped directory path lookup sanity"
10916 # LU-4239: Verify fid2path works with paths 100 or more directories deep
10918 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.51) ]] &&
10919 skip "Need MDS version at least 2.7.51" && return
10920 test_mkdir $DIR/$tdir.local
10921 test_mkdir $DIR/$tdir.remote
10922 local lpath=$tdir.local
10923 local rpath=$tdir.remote
10925 for ((i = 0; i <= 101; i++)); do
10928 FID=$($LFS path2fid $DIR/$lpath | tr -d '[]') ||
10929 error "get fid for local directory $DIR/$lpath failed"
10930 check_path "$DIR/$lpath" $MOUNT $FID --link 0 ||
10931 error "check path for local directory $DIR/$lpath failed"
10934 test_mkdir $DIR/$rpath
10935 FID=$($LFS path2fid $DIR/$rpath | tr -d '[]') ||
10936 error "get fid for remote directory $DIR/$rpath failed"
10937 check_path "$DIR/$rpath" $MOUNT $FID --link 0 ||
10938 error "check path for remote directory $DIR/$rpath failed"
10943 run_test 162c "fid2path works with paths 100 or more directories deep"
10946 # do directio so as not to populate the page cache
10947 log "creating a 10 Mb file"
10948 $MULTIOP $DIR/$tfile oO_CREAT:O_DIRECT:O_RDWR:w$((10*1048576))c || error "multiop failed while creating a file"
10949 log "starting reads"
10950 dd if=$DIR/$tfile of=/dev/null bs=4096 &
10951 log "truncating the file"
10952 $MULTIOP $DIR/$tfile oO_TRUNC:c || error "multiop failed while truncating the file"
10954 kill %+ || true # reads might have finished
10955 echo "wait until dd is finished"
10957 log "removing the temporary file"
10958 rm -rf $DIR/$tfile || error "tmp file removal failed"
10960 run_test 169 "parallel read and truncate should not deadlock"
10963 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10964 $LCTL clear # bug 18514
10965 $LCTL debug_daemon start $TMP/${tfile}_log_good
10967 $LCTL debug_daemon stop
10968 sed -e "s/^...../a/g" $TMP/${tfile}_log_good > $TMP/${tfile}_log_bad ||
10969 error "sed failed to read log_good"
10971 $LCTL debug_daemon start $TMP/${tfile}_log_good
10973 $LCTL debug_daemon stop
10975 $LCTL df $TMP/${tfile}_log_bad > $TMP/${tfile}_log_bad.out 2>&1 ||
10976 error "lctl df log_bad failed"
10978 local bad_line=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $9}')
10979 local good_line1=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $5}')
10981 $LCTL df $TMP/${tfile}_log_good > $TMP/${tfile}_log_good.out 2>&1
10982 local good_line2=$(tail -n 1 $TMP/${tfile}_log_good.out | awk '{print $5}')
10984 [ "$bad_line" ] && [ "$good_line1" ] && [ "$good_line2" ] ||
10985 error "bad_line good_line1 good_line2 are empty"
10987 cat $TMP/${tfile}_log_good >> $TMP/${tfile}_logs_corrupt
10988 cat $TMP/${tfile}_log_bad >> $TMP/${tfile}_logs_corrupt
10989 cat $TMP/${tfile}_log_good >> $TMP/${tfile}_logs_corrupt
10991 $LCTL df $TMP/${tfile}_logs_corrupt > $TMP/${tfile}_log_bad.out 2>&1
10992 local bad_line_new=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $9}')
10993 local good_line_new=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $5}')
10995 [ "$bad_line_new" ] && [ "$good_line_new" ] ||
10996 error "bad_line_new good_line_new are empty"
10998 local expected_good=$((good_line1 + good_line2*2))
11000 rm -f $TMP/${tfile}*
11001 # LU-231, short malformed line may not be counted into bad lines
11002 if [ $bad_line -ne $bad_line_new ] &&
11003 [ $bad_line -ne $((bad_line_new - 1)) ]; then
11004 error "expected $bad_line bad lines, but got $bad_line_new"
11008 if [ $expected_good -ne $good_line_new ]; then
11009 error "expected $expected_good good lines, but got $good_line_new"
11014 run_test 170 "test lctl df to handle corrupted log ====================="
11016 test_171() { # bug20592
11017 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11018 #define OBD_FAIL_PTLRPC_DUMP_LOG 0x50e
11019 $LCTL set_param fail_loc=0x50e
11020 $LCTL set_param fail_val=3000
11021 multiop_bg_pause $DIR/$tfile O_s || true
11023 kill -USR1 $MULTIPID
11027 if dmesg | grep "recursive fault"; then
11028 error "caught a recursive fault"
11030 $LCTL set_param fail_loc=0
11033 run_test 171 "test libcfs_debug_dumplog_thread stuck in do_exit() ======"
11035 # it would be good to share it with obdfilter-survey/iokit-libecho code
11036 setup_obdecho_osc () {
11039 local obdfilter_name=$2
11040 echo "Creating new osc for $obdfilter_name on $ost_nid"
11041 # make sure we can find loopback nid
11042 $LCTL add_uuid $ost_nid $ost_nid >/dev/null 2>&1
11044 [ $rc -eq 0 ] && { $LCTL attach osc ${obdfilter_name}_osc \
11045 ${obdfilter_name}_osc_UUID || rc=2; }
11046 [ $rc -eq 0 ] && { $LCTL --device ${obdfilter_name}_osc setup \
11047 ${obdfilter_name}_UUID $ost_nid || rc=3; }
11051 cleanup_obdecho_osc () {
11052 local obdfilter_name=$1
11053 $LCTL --device ${obdfilter_name}_osc cleanup >/dev/null
11054 $LCTL --device ${obdfilter_name}_osc detach >/dev/null
11061 local pages=${3:-64}
11066 local obd_size=$(get_obd_size $node $OBD)
11067 local page_size=$(get_page_size $node)
11068 if [[ -n "$obd_size" ]]; then
11069 local new_count=$((obd_size / (pages * page_size / 1024)))
11070 [[ $new_count -ge $count ]] || count=$new_count
11073 do_facet $node "$LCTL attach echo_client ec ec_uuid" || rc=1
11074 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec setup $OBD" ||
11076 if [ $rc -eq 0 ]; then
11077 id=$(do_facet $node "$LCTL --device ec create 1" | awk '/object id/ {print $6}')
11078 [ ${PIPESTATUS[0]} -eq 0 -a -n "$id" ] || rc=3
11080 echo "New object id is $id"
11081 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec getattr $id" ||
11083 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec " \
11084 "test_brw $count w v $pages $id" || rc=4; }
11085 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec destroy $id 1" ||
11087 [ $rc -eq 0 -o $rc -gt 2 ] && { do_facet $node "$LCTL --device ec " \
11088 "cleanup" || rc=5; }
11089 [ $rc -eq 0 -o $rc -gt 1 ] && { do_facet $node "$LCTL --device ec " \
11090 "detach" || rc=6; }
11091 [ $rc -ne 0 ] && echo "obecho_create_test failed: $rc"
11096 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11097 remote_ost_nodsh && skip "remote OST with nodsh" && return
11099 local rmmod_local=0
11101 if ! module_loaded obdecho; then
11102 load_module obdecho/obdecho
11106 local osc=$($LCTL dl | grep -v mdt | awk '$3 == "osc" {print $4; exit}')
11107 local host=$(lctl get_param -n osc.$osc.import |
11108 awk '/current_connection:/ {print $2}' )
11109 local target=$(lctl get_param -n osc.$osc.import |
11110 awk '/target:/ {print $2}' )
11111 target=${target%_UUID}
11113 [[ -n $target ]] && { setup_obdecho_osc $host $target || rc=1; } || rc=1
11114 [ $rc -eq 0 ] && { obdecho_test ${target}_osc client || rc=2; }
11115 [[ -n $target ]] && cleanup_obdecho_osc $target
11116 [ $rmmod_local -eq 1 ] && rmmod obdecho
11119 run_test 180a "test obdecho on osc"
11122 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11123 remote_ost_nodsh && skip "remote OST with nodsh" && return
11125 local rmmod_remote=0
11127 do_facet ost1 "lsmod | grep -q obdecho || " \
11128 "{ insmod ${LUSTRE}/obdecho/obdecho.ko || " \
11129 "modprobe obdecho; }" && rmmod_remote=1
11130 target=$(do_facet ost1 $LCTL dl | awk '/obdfilter/ {print $4;exit}')
11131 [[ -n $target ]] && { obdecho_test $target ost1 || rc=1; }
11132 [ $rmmod_remote -eq 1 ] && do_facet ost1 "rmmod obdecho"
11135 run_test 180b "test obdecho directly on obdfilter"
11137 test_180c() { # LU-2598
11138 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11139 remote_ost_nodsh && skip "remote OST with nodsh" && return
11140 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.0) ]] &&
11141 skip "Need MDS version at least 2.4.0" && return
11144 local rmmod_remote=false
11145 local pages=16384 # 64MB bulk I/O RPC size
11148 do_rpc_nodes $(facet_active_host ost1) load_module obdecho/obdecho &&
11149 rmmod_remote=true || error "failed to load module obdecho"
11151 target=$(do_facet ost1 $LCTL dl | awk '/obdfilter/ { print $4 }' |
11153 if [ -n "$target" ]; then
11154 obdecho_test "$target" ost1 "$pages" || rc=${PIPESTATUS[0]}
11156 echo "there is no obdfilter target on ost1"
11159 $rmmod_remote && do_facet ost1 "rmmod obdecho" || true
11162 run_test 180c "test huge bulk I/O size on obdfilter, don't LASSERT"
11164 test_181() { # bug 22177
11165 test_mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
11166 # create enough files to index the directory
11167 createmany -o $DIR/$tdir/foobar 4000
11168 # print attributes for debug purpose
11171 multiop_bg_pause $DIR/$tdir D_Sc || return 1
11173 # remove the files & current working dir
11174 unlinkmany $DIR/$tdir/foobar 4000
11176 kill -USR1 $MULTIPID
11178 stat $DIR/$tdir && error "open-unlinked dir was not removed!"
11181 run_test 181 "Test open-unlinked dir ========================"
11187 mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
11189 $LCTL set_param mdc.*.rpc_stats=clear
11191 for (( i = 0; i < $tcount; i++ )) ; do
11192 mkdir $DIR/$tdir/$i
11195 for (( i = 0; i < $tcount; i++ )) ; do
11196 createmany -o $DIR/$tdir/$i/f- $fcount &
11200 for (( i = 0; i < $tcount; i++ )) ; do
11201 unlinkmany $DIR/$tdir/$i/f- $fcount &
11205 $LCTL get_param mdc.*.rpc_stats
11209 run_test 182 "Test parallel modify metadata operations ================"
11211 test_183() { # LU-2275
11212 remote_mds_nodsh && skip "remote MDS with nodsh" && return
11213 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.3.56) ]] &&
11214 skip "Need MDS version at least 2.3.56" && return
11216 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11217 mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
11218 echo aaa > $DIR/$tdir/$tfile
11220 #define OBD_FAIL_MDS_NEGATIVE_POSITIVE 0x148
11221 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x148
11223 ls -l $DIR/$tdir && error "ls succeeded, should have failed"
11224 cat $DIR/$tdir/$tfile && error "cat succeeded, should have failed"
11226 do_facet $SINGLEMDS $LCTL set_param fail_loc=0
11228 # Flush negative dentry cache
11229 touch $DIR/$tdir/$tfile
11231 # We are not checking for any leaked references here, they'll
11232 # become evident next time we do cleanup with module unload.
11235 run_test 183 "No crash or request leak in case of strange dispositions ========"
11237 # test suite 184 is for LU-2016, LU-2017
11239 check_swap_layouts_support && return 0
11241 dir0=$DIR/$tdir/$testnum
11242 test_mkdir -p -c1 $dir0 || error "creating dir $dir0"
11247 $SETSTRIPE -c1 $file1
11249 $SETSTRIPE -c2 $file2
11251 gen1=$($GETSTRIPE -g $file1)
11252 gen2=$($GETSTRIPE -g $file2)
11254 $LFS swap_layouts $file1 $file2 || error "swap of file layout failed"
11255 gen=$($GETSTRIPE -g $file1)
11256 [[ $gen1 != $gen ]] ||
11257 "Layout generation on $file1 does not change"
11258 gen=$($GETSTRIPE -g $file2)
11259 [[ $gen2 != $gen ]] ||
11260 "Layout generation on $file2 does not change"
11262 cmp $ref1 $file2 || error "content compare failed ($ref1 != $file2)"
11263 cmp $ref2 $file1 || error "content compare failed ($ref2 != $file1)"
11265 run_test 184a "Basic layout swap"
11268 check_swap_layouts_support && return 0
11270 dir0=$DIR/$tdir/$testnum
11271 mkdir -p $dir0 || error "creating dir $dir0"
11278 $SETSTRIPE -c1 $file1
11279 $SETSTRIPE -c2 $file2
11280 $SETSTRIPE -c1 $file3
11281 chown $RUNAS_ID $file3
11282 gen1=$($GETSTRIPE -g $file1)
11283 gen2=$($GETSTRIPE -g $file2)
11285 $LFS swap_layouts $dir1 $dir2 &&
11286 error "swap of directories layouts should fail"
11287 $LFS swap_layouts $dir1 $file1 &&
11288 error "swap of directory and file layouts should fail"
11289 $RUNAS $LFS swap_layouts $file1 $file2 &&
11290 error "swap of file we cannot write should fail"
11291 $LFS swap_layouts $file1 $file3 &&
11292 error "swap of file with different owner should fail"
11293 /bin/true # to clear error code
11295 run_test 184b "Forbidden layout swap (will generate errors)"
11298 check_swap_layouts_support && return 0
11300 local dir0=$DIR/$tdir/$testnum
11301 mkdir -p $dir0 || error "creating dir $dir0"
11303 local ref1=$dir0/ref1
11304 local ref2=$dir0/ref2
11305 local file1=$dir0/file1
11306 local file2=$dir0/file2
11307 # create a file large enough for the concurrent test
11308 dd if=/dev/urandom of=$ref1 bs=1M count=$((RANDOM % 50 + 20))
11309 dd if=/dev/urandom of=$ref2 bs=1M count=$((RANDOM % 50 + 20))
11310 echo "ref file size: ref1($(stat -c %s $ref1))," \
11311 "ref2($(stat -c %s $ref2))"
11314 dd if=$ref1 of=$file1 bs=16k &
11317 # Make sure dd starts to copy file
11318 while [ ! -f $file1 ]; do sleep 0.1; done
11320 $LFS swap_layouts $file1 $file2
11323 [[ $? == 0 ]] || error "concurrent write on $file1 failed"
11324 [[ $rc == 0 ]] || error "swap of $file1 and $file2 failed"
11326 # how many bytes copied before swapping layout
11327 local copied=$(stat -c %s $file2)
11328 local remaining=$(stat -c %s $ref1)
11329 remaining=$((remaining - copied))
11330 echo "Copied $copied bytes before swapping layout..."
11332 cmp -n $copied $file1 $ref2 | grep differ &&
11333 error "Content mismatch [0, $copied) of ref2 and file1"
11334 cmp -n $copied $file2 $ref1 ||
11335 error "Content mismatch [0, $copied) of ref1 and file2"
11336 cmp -i $copied:$copied -n $remaining $file1 $ref1 ||
11337 error "Content mismatch [$copied, EOF) of ref1 and file1"
11340 rm -f $ref1 $ref2 $file1 $file2
11342 run_test 184c "Concurrent write and layout swap"
11345 check_swap_layouts_support && return 0
11346 [ -z "$(which getfattr 2>/dev/null)" ] &&
11347 skip "no getfattr command" && return 0
11349 local file1=$DIR/$tdir/$tfile-1
11350 local file2=$DIR/$tdir/$tfile-2
11351 local file3=$DIR/$tdir/$tfile-3
11355 mkdir -p $DIR/$tdir
11356 touch $file1 || error "create $file1 failed"
11357 $OPENFILE -f O_CREAT:O_LOV_DELAY_CREATE $file2 ||
11358 error "create $file2 failed"
11359 $OPENFILE -f O_CREAT:O_LOV_DELAY_CREATE $file3 ||
11360 error "create $file3 failed"
11361 lovea1=$($LFS getstripe $file1 | sed 1d)
11363 $LFS swap_layouts $file2 $file3 ||
11364 error "swap $file2 $file3 layouts failed"
11365 $LFS swap_layouts $file1 $file2 ||
11366 error "swap $file1 $file2 layouts failed"
11368 lovea2=$($LFS getstripe $file2 | sed 1d)
11369 [ "$lovea1" == "$lovea2" ] || error "lovea $lovea1 != $lovea2"
11371 lovea1=$(getfattr -n trusted.lov $file1 | grep ^trusted)
11372 [[ -z "$lovea1" ]] || error "$file1 shouldn't have lovea"
11374 run_test 184d "allow stripeless layouts swap"
11377 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.6.94) ]] ||
11378 { skip "Need MDS version at least 2.6.94"; return 0; }
11379 check_swap_layouts_support && return 0
11380 [ -z "$(which getfattr 2>/dev/null)" ] &&
11381 skip "no getfattr command" && return 0
11383 local file1=$DIR/$tdir/$tfile-1
11384 local file2=$DIR/$tdir/$tfile-2
11385 local file3=$DIR/$tdir/$tfile-3
11388 mkdir -p $DIR/$tdir
11389 touch $file1 || error "create $file1 failed"
11390 $OPENFILE -f O_CREAT:O_LOV_DELAY_CREATE $file2 ||
11391 error "create $file2 failed"
11392 $OPENFILE -f O_CREAT:O_LOV_DELAY_CREATE $file3 ||
11393 error "create $file3 failed"
11395 $LFS swap_layouts $file1 $file2 ||
11396 error "swap $file1 $file2 layouts failed"
11398 lovea=$(getfattr -n trusted.lov $file1 | grep ^trusted)
11399 [[ -z "$lovea" ]] || error "$file1 shouldn't have lovea"
11401 echo 123 > $file1 || error "Should be able to write into $file1"
11403 $LFS swap_layouts $file1 $file3 ||
11404 error "swap $file1 $file3 layouts failed"
11406 echo 123 > $file1 || error "Should be able to write into $file1"
11408 rm -rf $file1 $file2 $file3
11410 run_test 184e "Recreate layout after stripeless layout swaps"
11412 test_185() { # LU-2441
11413 # LU-3553 - no volatile file support in old servers
11414 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.3.60) ]] ||
11415 { skip "Need MDS version at least 2.3.60"; return 0; }
11417 mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
11418 touch $DIR/$tdir/spoo
11419 local mtime1=$(stat -c "%Y" $DIR/$tdir)
11420 local fid=$($MULTIOP $DIR/$tdir VFw4096c) ||
11421 error "cannot create/write a volatile file"
11422 $CHECKSTAT -t file $MOUNT/.lustre/fid/$fid 2>/dev/null &&
11423 error "FID is still valid after close"
11425 multiop_bg_pause $DIR/$tdir vVw4096_c
11432 # assume that the next FID for this client is sequential, since stdout
11433 # is unfortunately eaten by multiop_bg_pause
11434 local n=$((${fidv[1]} + 1))
11435 local next_fid="${fidv[0]}:$(printf "0x%x" $n):${fidv[2]}"
11436 $CHECKSTAT -t file $MOUNT/.lustre/fid/$next_fid ||
11437 error "FID is missing before close"
11438 kill -USR1 $multi_pid
11439 # 1 second delay, so if mtime change we will see it
11441 local mtime2=$(stat -c "%Y" $DIR/$tdir)
11442 [[ $mtime1 == $mtime2 ]] || error "mtime has changed"
11444 run_test 185 "Volatile file support"
11447 remote_mds_nodsh && skip "remote MDS with nodsh" && return
11448 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.3.0) ] &&
11449 skip "Need MDS version at least 2.3.0" && return
11451 local dir0=$DIR/$tdir/$testnum
11452 mkdir -p $dir0 || error "creating dir $dir0"
11454 local file=$dir0/file1
11455 dd if=/dev/urandom of=$file count=10 bs=1M conv=fsync
11456 local dv1=$($LFS data_version $file)
11457 dd if=/dev/urandom of=$file seek=10 count=1 bs=1M conv=fsync
11458 local dv2=$($LFS data_version $file)
11459 [[ $dv1 != $dv2 ]] ||
11460 error "data version did not change on write $dv1 == $dv2"
11465 run_test 187a "Test data version change"
11468 remote_mds_nodsh && skip "remote MDS with nodsh" && return
11469 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.3.0) ] &&
11470 skip "Need MDS version at least 2.3.0" && return
11472 local dir0=$DIR/$tdir/$testnum
11473 mkdir -p $dir0 || error "creating dir $dir0"
11475 declare -a DV=$($MULTIOP $dir0 Vw1000xYw1000xY | cut -f3 -d" ")
11476 [[ ${DV[0]} != ${DV[1]} ]] ||
11477 error "data version did not change on write"\
11478 " ${DV[0]} == ${DV[1]}"
11483 run_test 187b "Test data version change on volatile file"
11486 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11487 remote_mgs_nodsh && skip "remote MGS with nodsh" && return
11489 local POOL=${POOL:-cea1}
11490 local POOL_ROOT=${POOL_ROOT:-$DIR/d200.pools}
11491 local POOL_DIR_NAME=${POOL_DIR_NAME:-dir_tst}
11494 local last_ost=$(($OSTCOUNT - 1))
11496 local ost_list=$(seq $first_ost $ost_step $last_ost)
11497 local ost_range="$first_ost $last_ost $ost_step"
11498 local test_path=$POOL_ROOT/$POOL_DIR_NAME
11499 local file_dir=$POOL_ROOT/file_tst
11500 local subdir=$test_path/subdir
11504 # former test_200a test_200b
11505 pool_add $POOL || { rc=$? ; break; }
11506 pool_add_targets $POOL $ost_range || { rc=$? ; break; }
11507 # former test_200c test_200d
11508 mkdir -p $test_path
11509 pool_set_dir $POOL $test_path || { rc=$? ; break; }
11510 pool_check_dir $POOL $test_path || { rc=$? ; break; }
11512 pool_check_dir $POOL $subdir || { rc=$? ; break; }
11513 pool_dir_rel_path $POOL $POOL_DIR_NAME $POOL_ROOT \
11514 || { rc=$? ; break; }
11515 # former test_200e test_200f
11516 local files=$((OSTCOUNT*3))
11517 pool_alloc_files $POOL $test_path $files "$ost_list" \
11518 || { rc=$? ; break; }
11519 pool_create_files $POOL $file_dir $files "$ost_list" \
11520 || { rc=$? ; break; }
11521 # former test_200g test_200h
11522 pool_lfs_df $POOL || { rc=$? ; break; }
11523 pool_file_rel_path $POOL $test_path || { rc=$? ; break; }
11525 # former test_201a test_201b test_201c
11526 pool_remove_first_target $POOL || { rc=$? ; break; }
11528 local f=$test_path/$tfile
11529 pool_remove_all_targets $POOL $f || { rc=$? ; break; }
11530 pool_remove $POOL $f || { rc=$? ; break; }
11537 run_test 200 "OST pools"
11539 # usage: default_attr <count | size | offset>
11541 $LCTL get_param -n lov.$FSNAME-clilov-\*.stripe${1}
11544 # usage: check_default_stripe_attr
11545 check_default_stripe_attr() {
11546 ACTUAL=$($GETSTRIPE $* $DIR/$tdir)
11548 --stripe-count|--count)
11549 [ -n "$2" ] && EXPECTED=0 || EXPECTED=$(default_attr count);;
11550 --stripe-size|--size)
11551 [ -n "$2" ] && EXPECTED=0 || EXPECTED=$(default_attr size);;
11552 --stripe-index|--index)
11555 error "unknown getstripe attr '$1'"
11558 [ $ACTUAL != $EXPECTED ] &&
11559 error "$DIR/$tdir has $1 '$ACTUAL', not '$EXPECTED'"
11563 test_mkdir -p $DIR/$tdir
11564 $SETSTRIPE --stripe-count 0 --stripe-size 0 --stripe-index -1 $DIR/$tdir
11566 check_default_stripe_attr --stripe-count
11567 check_default_stripe_attr --stripe-size
11568 check_default_stripe_attr --stripe-index
11572 run_test 204a "Print default stripe attributes ================="
11575 test_mkdir -p $DIR/$tdir
11576 $SETSTRIPE --stripe-count 1 $DIR/$tdir
11578 check_default_stripe_attr --stripe-size
11579 check_default_stripe_attr --stripe-index
11583 run_test 204b "Print default stripe size and offset ==========="
11586 test_mkdir -p $DIR/$tdir
11587 $SETSTRIPE --stripe-size 65536 $DIR/$tdir
11589 check_default_stripe_attr --stripe-count
11590 check_default_stripe_attr --stripe-index
11594 run_test 204c "Print default stripe count and offset ==========="
11597 test_mkdir -p $DIR/$tdir
11598 $SETSTRIPE --stripe-index 0 $DIR/$tdir
11600 check_default_stripe_attr --stripe-count
11601 check_default_stripe_attr --stripe-size
11605 run_test 204d "Print default stripe count and size ============="
11608 test_mkdir -p $DIR/$tdir
11609 $SETSTRIPE -d $DIR/$tdir
11611 check_default_stripe_attr --stripe-count --raw
11612 check_default_stripe_attr --stripe-size --raw
11613 check_default_stripe_attr --stripe-index --raw
11617 run_test 204e "Print raw stripe attributes ================="
11620 test_mkdir -p $DIR/$tdir
11621 $SETSTRIPE --stripe-count 1 $DIR/$tdir
11623 check_default_stripe_attr --stripe-size --raw
11624 check_default_stripe_attr --stripe-index --raw
11628 run_test 204f "Print raw stripe size and offset ==========="
11631 test_mkdir -p $DIR/$tdir
11632 $SETSTRIPE --stripe-size 65536 $DIR/$tdir
11634 check_default_stripe_attr --stripe-count --raw
11635 check_default_stripe_attr --stripe-index --raw
11639 run_test 204g "Print raw stripe count and offset ==========="
11642 test_mkdir -p $DIR/$tdir
11643 $SETSTRIPE --stripe-index 0 $DIR/$tdir
11645 check_default_stripe_attr --stripe-count --raw
11646 check_default_stripe_attr --stripe-size --raw
11650 run_test 204h "Print raw stripe count and size ============="
11652 # Figure out which job scheduler is being used, if any,
11653 # or use a fake one
11654 if [ -n "$SLURM_JOB_ID" ]; then # SLURM
11655 JOBENV=SLURM_JOB_ID
11656 elif [ -n "$LSB_JOBID" ]; then # Load Sharing Facility
11658 elif [ -n "$PBS_JOBID" ]; then # PBS/Maui/Moab
11660 elif [ -n "$LOADL_STEPID" ]; then # LoadLeveller
11661 JOBENV=LOADL_STEP_ID
11662 elif [ -n "$JOB_ID" ]; then # Sun Grid Engine
11665 $LCTL list_param jobid_name > /dev/null 2>&1
11666 if [ $? -eq 0 ]; then
11673 verify_jobstats() {
11678 # we don't really need to clear the stats for this test to work, since each
11679 # command has a unique jobid, but it makes debugging easier if needed.
11680 # for facet in $facets; do
11681 # local dev=$(convert_facet2label $facet)
11682 # # clear old jobstats
11683 # do_facet $facet lctl set_param *.$dev.job_stats="clear"
11686 # use a new JobID for each test, or we might see an old one
11687 [ "$JOBENV" = "FAKE_JOBID" ] &&
11688 FAKE_JOBID=id.$testnum.$(basename ${cmd[0]}).$RANDOM
11692 [ "$JOBENV" = "nodelocal" ] && {
11693 FAKE_JOBID=id.$testnum.$(basename ${cmd[0]}).$RANDOM
11694 $LCTL set_param jobid_name=$FAKE_JOBID
11698 log "Test: ${cmd[*]}"
11699 log "Using JobID environment variable $JOBENV=$JOBVAL"
11701 if [ $JOBENV = "FAKE_JOBID" ]; then
11702 FAKE_JOBID=$JOBVAL ${cmd[*]}
11707 # all files are created on OST0000
11708 for facet in $facets; do
11709 local stats="*.$(convert_facet2label $facet).job_stats"
11710 if [ $(do_facet $facet lctl get_param $stats |
11711 grep -c $JOBVAL) -ne 1 ]; then
11712 do_facet $facet lctl get_param $stats
11713 error "No jobstats for $JOBVAL found on $facet::$stats"
11720 NEW_JOBENV=${1:-$OLD_JOBENV}
11721 do_facet mgs $LCTL conf_param $FSNAME.sys.jobid_var=$NEW_JOBENV
11722 wait_update $HOSTNAME "$LCTL get_param -n jobid_var" $NEW_JOBENV
11726 do_facet $SINGLEMDS \
11727 $LCTL set_param mdt.*.job_cleanup_interval=$OLD_INTERVAL
11728 [ $OLD_JOBENV != $JOBENV ] && jobstats_set $OLD_JOBENV
11729 do_facet $SINGLEMDS lctl --device $MDT0 changelog_deregister $CL_USER
11732 test_205() { # Job stats
11733 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11734 remote_mgs_nodsh && skip "remote MGS with nodsh" && return
11735 remote_mds_nodsh && skip "remote MDS with nodsh" && return
11736 remote_ost_nodsh && skip "remote OST with nodsh" && return
11738 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep jobstats)" ] &&
11739 skip "Server doesn't support jobstats" && return 0
11740 [[ $JOBID_VAR = disable ]] && skip "jobstats is disabled" && return
11742 OLD_JOBENV=$($LCTL get_param -n jobid_var)
11743 if [ $OLD_JOBENV != $JOBENV ]; then
11744 jobstats_set $JOBENV
11745 trap cleanup_205 EXIT
11748 CL_USER=$(do_facet $SINGLEMDS lctl --device $MDT0 changelog_register -n)
11749 echo "Registered as changelog user $CL_USER"
11751 OLD_INTERVAL=$(do_facet $SINGLEMDS \
11752 lctl get_param -n mdt.*.job_cleanup_interval)
11753 local interval_new=5
11754 do_facet $SINGLEMDS \
11755 $LCTL set_param mdt.*.job_cleanup_interval=$interval_new
11756 local start=$SECONDS
11760 cmd="mkdir $DIR/$tdir"
11761 verify_jobstats "$cmd" "$SINGLEMDS"
11763 cmd="rmdir $DIR/$tdir"
11764 verify_jobstats "$cmd" "$SINGLEMDS"
11765 # mkdir on secondary MDT
11766 if [ $MDSCOUNT -gt 1 ]; then
11767 cmd="lfs mkdir -i 1 $DIR/$tdir.remote"
11768 verify_jobstats "$cmd" "mds2"
11771 cmd="mknod $DIR/$tfile c 1 3"
11772 verify_jobstats "$cmd" "$SINGLEMDS"
11774 cmd="rm -f $DIR/$tfile"
11775 verify_jobstats "$cmd" "$SINGLEMDS"
11776 # create all files on OST0000 so verify_jobstats can find OST stats
11778 cmd="$SETSTRIPE -i 0 -c 1 $DIR/$tfile"
11779 verify_jobstats "$cmd" "$SINGLEMDS"
11781 cmd="touch $DIR/$tfile"
11782 verify_jobstats "$cmd" "$SINGLEMDS ost1"
11784 cmd="dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 oflag=sync"
11785 verify_jobstats "$cmd" "ost1"
11787 cmd="dd if=$DIR/$tfile of=/dev/null bs=1M count=1 iflag=direct"
11788 verify_jobstats "$cmd" "ost1"
11790 cmd="$TRUNCATE $DIR/$tfile 0"
11791 verify_jobstats "$cmd" "$SINGLEMDS ost1"
11793 cmd="mv -f $DIR/$tfile $DIR/$tdir.rename"
11794 verify_jobstats "$cmd" "$SINGLEMDS"
11795 # jobstats expiry - sleep until old stats should be expired
11796 local left=$((interval_new + 2 - (SECONDS - start)))
11797 [ $left -ge 0 ] && echo "sleep $left for expiry" && sleep $((left + 1))
11798 cmd="mkdir $DIR/$tdir.expire"
11799 verify_jobstats "$cmd" "$SINGLEMDS"
11800 [ $(do_facet $SINGLEMDS lctl get_param *.*.job_stats |
11801 grep -c "job_id.*mkdir") -gt 1 ] && error "old jobstats not expired"
11803 # Ensure that jobid are present in changelog (if supported by MDS)
11804 if [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.6.52) ]
11806 $LFS changelog $MDT0 | tail -9
11807 jobids=$($LFS changelog $MDT0 | tail -9 | grep -c "j=")
11808 [ $jobids -eq 9 ] ||
11809 error "Wrong changelog jobid count $jobids != 9"
11813 jobstats_set $JOBENV
11815 $LFS changelog $MDT0 | tail -1
11816 jobids=$($LFS changelog $MDT0 | tail -1 | grep -c "j=")
11817 [ $jobids -eq 0 ] ||
11818 error "Unexpected jobids when jobid_var=$JOBENV"
11823 run_test 205 "Verify job stats"
11825 # LU-1480, LU-1773 and LU-1657
11827 mkdir -p $DIR/$tdir
11828 $SETSTRIPE -c -1 $DIR/$tdir
11829 #define OBD_FAIL_LOV_INIT 0x1403
11830 $LCTL set_param fail_loc=0xa0001403
11831 $LCTL set_param fail_val=1
11832 touch $DIR/$tdir/$tfile || true
11834 run_test 206 "fail lov_init_raid0() doesn't lbug"
11837 dd if=/dev/zero of=$DIR/$tfile bs=4k count=$((RANDOM%10+1))
11838 local fsz=`stat -c %s $DIR/$tfile`
11839 cancel_lru_locks mdc
11841 # do not return layout in getattr intent
11842 #define OBD_FAIL_MDS_NO_LL_GETATTR 0x170
11843 $LCTL set_param fail_loc=0x170
11844 local sz=`stat -c %s $DIR/$tfile`
11846 [ $fsz -eq $sz ] || error "file size expected $fsz, actual $sz"
11850 run_test 207a "can refresh layout at glimpse"
11853 dd if=/dev/zero of=$DIR/$tfile bs=4k count=$((RANDOM%10+1))
11854 local cksum=`md5sum $DIR/$tfile`
11855 local fsz=`stat -c %s $DIR/$tfile`
11856 cancel_lru_locks mdc
11857 cancel_lru_locks osc
11859 # do not return layout in getattr intent
11860 #define OBD_FAIL_MDS_NO_LL_OPEN 0x171
11861 $LCTL set_param fail_loc=0x171
11863 # it will refresh layout after the file is opened but before read issues
11864 echo checksum is "$cksum"
11865 echo "$cksum" |md5sum -c --quiet || error "file differs"
11869 run_test 207b "can refresh layout at open"
11872 # FIXME: in this test suite, only RD lease is used. This is okay
11873 # for now as only exclusive open is supported. After generic lease
11874 # is done, this test suite should be revised. - Jinshan
11876 remote_mds_nodsh && skip "remote MDS with nodsh" && return
11877 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.4.52) ]] ||
11878 { skip "Need MDS version at least 2.4.52"; return 0; }
11880 echo "==== test 1: verify get lease work"
11881 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:eRE+eU || error "get lease error"
11883 echo "==== test 2: verify lease can be broken by upcoming open"
11884 $MULTIOP $DIR/$tfile oO_RDONLY:eR_E-eUc &
11888 $MULTIOP $DIR/$tfile oO_RDONLY:c
11889 kill -USR1 $PID && wait $PID || error "break lease error"
11891 echo "==== test 3: verify lease can't be granted if an open already exists"
11892 $MULTIOP $DIR/$tfile oO_RDONLY:_c &
11896 $MULTIOP $DIR/$tfile oO_RDONLY:eReUc && error "apply lease should fail"
11897 kill -USR1 $PID && wait $PID || error "open file error"
11899 echo "==== test 4: lease can sustain over recovery"
11900 $MULTIOP $DIR/$tfile oO_RDONLY:eR_E+eUc &
11906 kill -USR1 $PID && wait $PID || error "lease broken over recovery"
11908 echo "==== test 5: lease broken can't be regained by replay"
11909 $MULTIOP $DIR/$tfile oO_RDONLY:eR_E-eUc &
11913 # open file to break lease and then recovery
11914 $MULTIOP $DIR/$tfile oO_RDWR:c || error "open file error"
11917 kill -USR1 $PID && wait $PID || error "lease not broken over recovery"
11921 run_test 208 "Exclusive open"
11924 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep disp_stripe)" ] &&
11925 skip_env "must have disp_stripe" && return
11928 sync; sleep 5; sync;
11930 echo 3 > /proc/sys/vm/drop_caches
11931 req_before=$(awk '/ptlrpc_cache / { print $2 }' /proc/slabinfo)
11933 # open/close 500 times
11934 for i in $(seq 500); do
11938 echo 3 > /proc/sys/vm/drop_caches
11939 req_after=$(awk '/ptlrpc_cache / { print $2 }' /proc/slabinfo)
11941 echo "before: $req_before, after: $req_after"
11942 [ $((req_after - req_before)) -ge 300 ] &&
11943 error "open/close requests are not freed"
11946 run_test 209 "read-only open/close requests should be freed promptly"
11950 size=$((size % 8192 + 1))
11951 dd if=/dev/urandom of=$DIR/f212 bs=1k count=$size
11952 sendfile $DIR/f212 $DIR/f212.xyz || error "sendfile wrong"
11953 rm -f $DIR/f212 $DIR/f212.xyz
11955 run_test 212 "Sendfile test ============================================"
11958 dd if=/dev/zero of=$DIR/$tfile bs=4k count=4
11959 cancel_lru_locks osc
11960 lctl set_param fail_loc=0x8000040f
11961 # generate a read lock
11962 cat $DIR/$tfile > /dev/null
11963 # write to the file, it will try to cancel the above read lock.
11964 cat /etc/hosts >> $DIR/$tfile
11966 run_test 213 "OSC lock completion and cancel race don't crash - bug 18829"
11968 test_214() { # for bug 20133
11969 mkdir -p $DIR/$tdir/d214c || error "mkdir $DIR/$tdir/d214c failed"
11970 for (( i=0; i < 340; i++ )) ; do
11971 touch $DIR/$tdir/d214c/a$i
11974 ls -l $DIR/$tdir || error "ls -l $DIR/d214p failed"
11975 mv $DIR/$tdir/d214c $DIR/ || error "mv $DIR/d214p/d214c $DIR/ failed"
11976 ls $DIR/d214c || error "ls $DIR/d214c failed"
11977 rm -rf $DIR/$tdir || error "rm -rf $DIR/d214* failed"
11978 rm -rf $DIR/d214* || error "rm -rf $DIR/d214* failed"
11980 run_test 214 "hash-indexed directory test - bug 20133"
11982 # having "abc" as 1st arg, creates $TMP/lnet_abc.out and $TMP/lnet_abc.sys
11983 create_lnet_proc_files() {
11984 lctl get_param -n $1 >$TMP/lnet_$1.out || error "cannot read lnet.$1"
11985 sysctl lnet.$1 >$TMP/lnet_$1.sys_tmp || error "cannot read lnet.$1"
11987 sed "s/^lnet.$1\ =\ //g" "$TMP/lnet_$1.sys_tmp" >$TMP/lnet_$1.sys
11988 rm -f "$TMP/lnet_$1.sys_tmp"
11991 # counterpart of create_lnet_proc_files
11992 remove_lnet_proc_files() {
11993 rm -f $TMP/lnet_$1.out $TMP/lnet_$1.sys
11996 # uses 1st arg as trailing part of filename, 2nd arg as description for reports,
11997 # 3rd arg as regexp for body
11998 check_lnet_proc_stats() {
11999 local l=$(cat "$TMP/lnet_$1" |wc -l)
12000 [ $l = 1 ] || (cat "$TMP/lnet_$1" && error "$2 is not of 1 line: $l")
12002 grep -E "$3" "$TMP/lnet_$1" || (cat "$TMP/lnet_$1" && error "$2 misformatted")
12005 # uses 1st arg as trailing part of filename, 2nd arg as description for reports,
12006 # 3rd arg as regexp for body, 4th arg as regexp for 1st line, 5th arg is
12007 # optional and can be regexp for 2nd line (lnet.routes case)
12008 check_lnet_proc_entry() {
12009 local blp=2 # blp stands for 'position of 1st line of body'
12010 [ -z "$5" ] || blp=3 # lnet.routes case
12012 local l=$(cat "$TMP/lnet_$1" |wc -l)
12013 # subtracting one from $blp because the body can be empty
12014 [ "$l" -ge "$(($blp - 1))" ] || (cat "$TMP/lnet_$1" && error "$2 is too short: $l")
12016 sed -n '1 p' "$TMP/lnet_$1" |grep -E "$4" >/dev/null ||
12017 (cat "$TMP/lnet_$1" && error "1st line of $2 misformatted")
12019 [ "$5" = "" ] || sed -n '2 p' "$TMP/lnet_$1" |grep -E "$5" >/dev/null ||
12020 (cat "$TMP/lnet_$1" && error "2nd line of $2 misformatted")
12022 # bail out if any unexpected line happened
12023 sed -n "$blp p" "$TMP/lnet_$1" | grep -Ev "$3"
12024 [ "$?" != 0 ] || error "$2 misformatted"
12027 test_215() { # for bugs 18102, 21079, 21517
12028 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12029 local N='(0|[1-9][0-9]*)' # non-negative numeric
12030 local P='[1-9][0-9]*' # positive numeric
12031 local I='(0|-?[1-9][0-9]*|NA)' # any numeric (0 | >0 | <0) or NA if no value
12032 local NET='[a-z][a-z0-9]*' # LNET net like o2ib2
12033 local ADDR='[0-9.]+' # LNET addr like 10.0.0.1
12034 local NID="$ADDR@$NET" # LNET nid like 10.0.0.1@o2ib2
12036 local L1 # regexp for 1st line
12037 local L2 # regexp for 2nd line (optional)
12038 local BR # regexp for the rest (body)
12040 # lnet.stats should look as 11 space-separated non-negative numerics
12041 BR="^$N $N $N $N $N $N $N $N $N $N $N$"
12042 create_lnet_proc_files "stats"
12043 check_lnet_proc_stats "stats.sys" "lnet.stats" "$BR"
12044 remove_lnet_proc_files "stats"
12046 # lnet.routes should look like this:
12047 # Routing disabled/enabled
12048 # net hops priority state router
12049 # where net is a string like tcp0, hops > 0, priority >= 0,
12050 # state is up/down,
12051 # router is a string like 192.168.1.1@tcp2
12052 L1="^Routing (disabled|enabled)$"
12053 L2="^net +hops +priority +state +router$"
12054 BR="^$NET +$N +(0|1) +(up|down) +$NID$"
12055 create_lnet_proc_files "routes"
12056 check_lnet_proc_entry "routes.sys" "lnet.routes" "$BR" "$L1" "$L2"
12057 remove_lnet_proc_files "routes"
12059 # lnet.routers should look like this:
12060 # ref rtr_ref alive_cnt state last_ping ping_sent deadline down_ni router
12061 # where ref > 0, rtr_ref > 0, alive_cnt >= 0, state is up/down,
12062 # last_ping >= 0, ping_sent is boolean (0/1), deadline and down_ni are
12063 # numeric (0 or >0 or <0), router is a string like 192.168.1.1@tcp2
12064 L1="^ref +rtr_ref +alive_cnt +state +last_ping +ping_sent +deadline +down_ni +router$"
12065 BR="^$P +$P +$N +(up|down) +$N +(0|1) +$I +$I +$NID$"
12066 create_lnet_proc_files "routers"
12067 check_lnet_proc_entry "routers.sys" "lnet.routers" "$BR" "$L1"
12068 remove_lnet_proc_files "routers"
12070 # lnet.peers should look like this:
12071 # nid refs state last max rtr min tx min queue
12072 # where nid is a string like 192.168.1.1@tcp2, refs > 0,
12073 # state is up/down/NA, max >= 0. last, rtr, min, tx, min are
12074 # numeric (0 or >0 or <0), queue >= 0.
12075 L1="^nid +refs +state +last +max +rtr +min +tx +min +queue$"
12076 BR="^$NID +$P +(up|down|NA) +$I +$N +$I +$I +$I +$I +$N$"
12077 create_lnet_proc_files "peers"
12078 check_lnet_proc_entry "peers.sys" "lnet.peers" "$BR" "$L1"
12079 remove_lnet_proc_files "peers"
12081 # lnet.buffers should look like this:
12082 # pages count credits min
12083 # where pages >=0, count >=0, credits and min are numeric (0 or >0 or <0)
12084 L1="^pages +count +credits +min$"
12085 BR="^ +$N +$N +$I +$I$"
12086 create_lnet_proc_files "buffers"
12087 check_lnet_proc_entry "buffers.sys" "lnet.buffers" "$BR" "$L1"
12088 remove_lnet_proc_files "buffers"
12090 # lnet.nis should look like this:
12091 # nid status alive refs peer rtr max tx min
12092 # where nid is a string like 192.168.1.1@tcp2, status is up/down,
12093 # alive is numeric (0 or >0 or <0), refs >= 0, peer >= 0,
12094 # rtr >= 0, max >=0, tx and min are numeric (0 or >0 or <0).
12095 L1="^nid +status +alive +refs +peer +rtr +max +tx +min$"
12096 BR="^$NID +(up|down) +$I +$N +$N +$N +$N +$I +$I$"
12097 create_lnet_proc_files "nis"
12098 check_lnet_proc_entry "nis.sys" "lnet.nis" "$BR" "$L1"
12099 remove_lnet_proc_files "nis"
12101 # can we successfully write to lnet.stats?
12102 lctl set_param -n stats=0 || error "cannot write to lnet.stats"
12103 sysctl -w lnet.stats=0 || error "cannot write to lnet.stats"
12105 run_test 215 "lnet exists and has proper content - bugs 18102, 21079, 21517"
12107 test_216() { # bug 20317
12108 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12109 remote_ost_nodsh && skip "remote OST with nodsh" && return
12112 local facets=$(get_facets OST)
12113 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
12115 save_lustre_params client "osc.*.contention_seconds" > $p
12116 save_lustre_params $facets \
12117 "ldlm.namespaces.filter-*.max_nolock_bytes" >> $p
12118 save_lustre_params $facets \
12119 "ldlm.namespaces.filter-*.contended_locks" >> $p
12120 save_lustre_params $facets \
12121 "ldlm.namespaces.filter-*.contention_seconds" >> $p
12124 # agressive lockless i/o settings
12125 for node in $(osts_nodes); do
12126 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'
12128 lctl set_param -n osc.*.contention_seconds 60
12130 $DIRECTIO write $DIR/$tfile 0 10 4096
12131 $CHECKSTAT -s 40960 $DIR/$tfile
12133 # disable lockless i/o
12134 for node in $(osts_nodes); do
12135 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'
12137 lctl set_param -n osc.*.contention_seconds 0
12140 dd if=/dev/zero of=$DIR/$tfile count=0
12141 $CHECKSTAT -s 0 $DIR/$tfile
12143 restore_lustre_params <$p
12147 run_test 216 "check lockless direct write works and updates file size and kms correctly"
12149 test_217() { # bug 22430
12150 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12154 for node in $(nodes_list); do
12155 nid=$(host_nids_address $node $NETTYPE)
12156 if [[ $nid = *-* ]] ; then
12157 echo "lctl ping $nid@$NETTYPE"
12158 lctl ping $nid@$NETTYPE
12160 echo "skipping $node (no hyphen detected)"
12164 run_test 217 "check lctl ping for hostnames with hiphen ('-')"
12167 # do directio so as not to populate the page cache
12168 log "creating a 10 Mb file"
12169 $MULTIOP $DIR/$tfile oO_CREAT:O_DIRECT:O_RDWR:w$((10*1048576))c || error "multiop failed while creating a file"
12170 log "starting reads"
12171 dd if=$DIR/$tfile of=/dev/null bs=4096 &
12172 log "truncating the file"
12173 $MULTIOP $DIR/$tfile oO_TRUNC:c || error "multiop failed while truncating the file"
12175 kill %+ || true # reads might have finished
12176 echo "wait until dd is finished"
12178 log "removing the temporary file"
12179 rm -rf $DIR/$tfile || error "tmp file removal failed"
12181 run_test 218 "parallel read and truncate should not deadlock ======================="
12184 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12185 # write one partial page
12186 dd if=/dev/zero of=$DIR/$tfile bs=1024 count=1
12187 # set no grant so vvp_io_commit_write will do sync write
12188 $LCTL set_param fail_loc=0x411
12189 # write a full page at the end of file
12190 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 seek=1 conv=notrunc
12192 $LCTL set_param fail_loc=0
12193 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 seek=3
12194 $LCTL set_param fail_loc=0x411
12195 dd if=/dev/zero of=$DIR/$tfile bs=1024 count=1 seek=2 conv=notrunc
12198 dd if=/dev/zero of=$DIR/$tfile-2 bs=1024 count=1
12199 $CHECKSTAT -s 1024 $DIR/$tfile-2 || error "checkstat wrong size"
12201 run_test 219 "LU-394: Write partial won't cause uncontiguous pages vec at LND"
12203 test_220() { #LU-325
12204 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12205 remote_ost_nodsh && skip "remote OST with nodsh" && return
12206 remote_mds_nodsh && skip "remote MDS with nodsh" && return
12207 remote_mgs_nodsh && skip "remote MGS with nodsh" && return
12210 # create on MDT0000 so the last_id and next_id are correct
12212 local OST=$($LFS df $DIR | awk '/OST:'$OSTIDX'/ { print $1 }')
12216 local mdtosc_proc1=$(get_mdtosc_proc_path $SINGLEMDS $OST)
12217 local last_id=$(do_facet $SINGLEMDS lctl get_param -n \
12218 osc.$mdtosc_proc1.prealloc_last_id)
12219 local next_id=$(do_facet $SINGLEMDS lctl get_param -n \
12220 osc.$mdtosc_proc1.prealloc_next_id)
12224 do_facet ost$((OSTIDX + 1)) lctl set_param fail_val=-1
12225 #define OBD_FAIL_OST_ENOINO 0x229
12226 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=0x229
12227 do_facet mgs $LCTL pool_new $FSNAME.$TESTNAME || return 1
12228 do_facet mgs $LCTL pool_add $FSNAME.$TESTNAME $OST || return 2
12230 $SETSTRIPE $DIR/$tdir -i $OSTIDX -c 1 -p $FSNAME.$TESTNAME
12232 MDSOBJS=$((last_id - next_id))
12233 echo "preallocated objects on MDS is $MDSOBJS" "($last_id - $next_id)"
12235 blocks=$($LFS df $MOUNT | awk '($1 == '$OSTIDX') { print $4 }')
12236 echo "OST still has $count kbytes free"
12238 echo "create $MDSOBJS files @next_id..."
12239 createmany -o $DIR/$tdir/f $MDSOBJS || return 3
12241 local last_id2=$(do_facet mds${MDSIDX} lctl get_param -n \
12242 osc.$mdtosc_proc1.prealloc_last_id)
12243 local next_id2=$(do_facet mds${MDSIDX} lctl get_param -n \
12244 osc.$mdtosc_proc1.prealloc_next_id)
12246 echo "after creation, last_id=$last_id2, next_id=$next_id2"
12251 do_facet ost$((OSTIDX + 1)) lctl set_param fail_val=0
12252 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=0
12254 do_facet mgs $LCTL pool_remove $FSNAME.$TESTNAME $OST || return 4
12255 do_facet mgs $LCTL pool_destroy $FSNAME.$TESTNAME || return 5
12256 echo "unlink $MDSOBJS files @$next_id..."
12257 unlinkmany $DIR/$tdir/f $MDSOBJS || return 6
12259 run_test 220 "preallocated MDS objects still used if ENOSPC from OST"
12262 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12263 dd if=`which date` of=$MOUNT/date oflag=sync
12264 chmod +x $MOUNT/date
12266 #define OBD_FAIL_LLITE_FAULT_TRUNC_RACE 0x1401
12267 $LCTL set_param fail_loc=0x80001401
12269 $MOUNT/date > /dev/null
12272 run_test 221 "make sure fault and truncate race to not cause OOM"
12275 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12277 test_mkdir -p $DIR/$tdir
12278 $SETSTRIPE -c 1 -i 0 $DIR/$tdir
12279 createmany -o $DIR/$tdir/$tfile 10
12280 cancel_lru_locks mdc
12281 cancel_lru_locks osc
12282 #define OBD_FAIL_LDLM_AGL_DELAY 0x31a
12283 $LCTL set_param fail_loc=0x31a
12284 ls -l $DIR/$tdir > /dev/null || error "AGL for ls failed"
12285 $LCTL set_param fail_loc=0
12288 run_test 222a "AGL for ls should not trigger CLIO lock failure ================"
12291 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12293 test_mkdir -p $DIR/$tdir
12294 $SETSTRIPE -c 1 -i 0 $DIR/$tdir
12295 createmany -o $DIR/$tdir/$tfile 10
12296 cancel_lru_locks mdc
12297 cancel_lru_locks osc
12298 #define OBD_FAIL_LDLM_AGL_DELAY 0x31a
12299 $LCTL set_param fail_loc=0x31a
12300 rm -r $DIR/$tdir || "AGL for rmdir failed"
12301 $LCTL set_param fail_loc=0
12303 run_test 222b "AGL for rmdir should not trigger CLIO lock failure ============="
12306 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12308 test_mkdir -p $DIR/$tdir
12309 $SETSTRIPE -c 1 -i 0 $DIR/$tdir
12310 createmany -o $DIR/$tdir/$tfile 10
12311 cancel_lru_locks mdc
12312 cancel_lru_locks osc
12313 #define OBD_FAIL_LDLM_AGL_NOLOCK 0x31b
12314 $LCTL set_param fail_loc=0x31b
12315 ls -l $DIR/$tdir > /dev/null || error "reenqueue failed"
12316 $LCTL set_param fail_loc=0
12319 run_test 223 "osc reenqueue if without AGL lock granted ======================="
12321 test_224a() { # LU-1039, MRP-303
12322 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12323 #define OBD_FAIL_PTLRPC_CLIENT_BULK_CB 0x508
12324 $LCTL set_param fail_loc=0x508
12325 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 conv=fsync
12326 $LCTL set_param fail_loc=0
12329 run_test 224a "Don't panic on bulk IO failure"
12331 test_224b() { # LU-1039, MRP-303
12332 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12333 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1
12334 cancel_lru_locks osc
12335 #define OBD_FAIL_PTLRPC_CLIENT_BULK_CB2 0x515
12336 $LCTL set_param fail_loc=0x515
12337 dd of=/dev/null if=$DIR/$tfile bs=4096 count=1
12338 $LCTL set_param fail_loc=0
12341 run_test 224b "Don't panic on bulk IO failure"
12343 test_224c() { # LU-6441
12344 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12345 local pages_per_rpc=$($LCTL get_param \
12346 osc.*.max_pages_per_rpc)
12347 local at_max=$($LCTL get_param -n at_max)
12348 local timeout=$($LCTL get_param -n timeout)
12349 local test_at="$LCTL get_param -n at_max"
12350 local param_at="$FSNAME.sys.at_max"
12351 local test_timeout="$LCTL get_param -n timeout"
12352 local param_timeout="$FSNAME.sys.timeout"
12354 $LCTL set_param -n osc.*.max_pages_per_rpc=1024
12356 set_conf_param_and_check client "$test_at" "$param_at" 0 ||
12357 error "conf_param at_max=0 failed"
12358 set_conf_param_and_check client "$test_timeout" "$param_timeout" 5 ||
12359 error "conf_param timeout=5 failed"
12361 #define OBD_FAIL_PTLRPC_CLIENT_BULK_CB3 0x520
12362 $LCTL set_param fail_loc=0x520
12363 dd if=/dev/zero of=$DIR/$tfile bs=8MB count=1
12365 $LCTL set_param fail_loc=0
12367 set_conf_param_and_check client "$test_at" "$param_at" $at_max ||
12368 error "conf_param at_max=$at_max failed"
12369 set_conf_param_and_check client "$test_timeout" "$param_timeout" \
12370 $timeout || error "conf_param timeout=$timeout failed"
12372 $LCTL set_param -n $pages_per_rpc
12374 run_test 224c "Don't hang if one of md lost during large bulk RPC"
12376 MDSSURVEY=${MDSSURVEY:-$(which mds-survey 2>/dev/null || true)}
12378 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12379 remote_mds_nodsh && skip "remote MDS with nodsh" && return
12380 if [ -z ${MDSSURVEY} ]; then
12381 skip_env "mds-survey not found" && return
12384 [ $MDSCOUNT -ge 2 ] &&
12385 skip "skipping now for more than one MDT" && return
12387 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.51) ] ||
12388 { skip "Need MDS version at least 2.2.51"; return; }
12390 local mds=$(facet_host $SINGLEMDS)
12391 local target=$(do_nodes $mds 'lctl dl' | \
12392 awk "{if (\$2 == \"UP\" && \$3 == \"mdt\") {print \$4}}")
12394 local cmd1="file_count=1000 thrhi=4"
12395 local cmd2="dir_count=2 layer=mdd stripe_count=0"
12396 local cmd3="rslt_loc=${TMP} targets=\"$mds:$target\" $MDSSURVEY"
12397 local cmd="$cmd1 $cmd2 $cmd3"
12399 rm -f ${TMP}/mds_survey*
12401 eval $cmd || error "mds-survey with zero-stripe failed"
12402 cat ${TMP}/mds_survey*
12403 rm -f ${TMP}/mds_survey*
12405 run_test 225a "Metadata survey sanity with zero-stripe"
12408 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12409 remote_mds_nodsh && skip "remote MDS with nodsh" && return
12410 if [ -z ${MDSSURVEY} ]; then
12411 skip_env "mds-survey not found" && return
12413 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.51) ] ||
12414 { skip "Need MDS version at least 2.2.51"; return; }
12416 if [ $($LCTL dl | grep -c osc) -eq 0 ]; then
12417 skip_env "Need to mount OST to test" && return
12420 [ $MDSCOUNT -ge 2 ] &&
12421 skip "skipping now for more than one MDT" && return
12422 local mds=$(facet_host $SINGLEMDS)
12423 local target=$(do_nodes $mds 'lctl dl' | \
12424 awk "{if (\$2 == \"UP\" && \$3 == \"mdt\") {print \$4}}")
12426 local cmd1="file_count=1000 thrhi=4"
12427 local cmd2="dir_count=2 layer=mdd stripe_count=1"
12428 local cmd3="rslt_loc=${TMP} targets=\"$mds:$target\" $MDSSURVEY"
12429 local cmd="$cmd1 $cmd2 $cmd3"
12431 rm -f ${TMP}/mds_survey*
12433 eval $cmd || error "mds-survey with stripe_count failed"
12434 cat ${TMP}/mds_survey*
12435 rm -f ${TMP}/mds_survey*
12437 run_test 225b "Metadata survey sanity with stripe_count = 1"
12439 mcreate_path2fid () {
12445 local path=$DIR/$tdir/$name
12450 $MCREATE --mode=$1 --major=$2 --minor=$3 $path ||
12451 error "cannot create $desc"
12453 fid=$($LFS path2fid $path | tr -d '[' | tr -d ']')
12455 [ $rc -ne 0 ] && error "cannot get fid of a $desc"
12457 fid_path=$($LFS fid2path $MOUNT $fid)
12459 [ $rc -ne 0 ] && error "cannot get path of $desc by $DIR $path $fid"
12461 [ "$path" == "$fid_path" ] ||
12462 error "fid2path returned $fid_path, expected $path"
12464 echo "pass with $path and $fid"
12469 mkdir -p $DIR/$tdir
12471 mcreate_path2fid 0010666 0 0 fifo "FIFO"
12472 mcreate_path2fid 0020666 1 3 null "character special file (null)"
12473 mcreate_path2fid 0020666 1 255 none "character special file (no device)"
12474 mcreate_path2fid 0040666 0 0 dir "directory"
12475 mcreate_path2fid 0060666 7 0 loop0 "block special file (loop)"
12476 mcreate_path2fid 0100666 0 0 file "regular file"
12477 mcreate_path2fid 0120666 0 0 link "symbolic link"
12478 mcreate_path2fid 0140666 0 0 sock "socket"
12480 run_test 226a "call path2fid and fid2path on files of all type"
12483 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
12487 mkdir -p $DIR/$tdir
12488 $LFS setdirstripe -i $MDTIDX $DIR/$tdir/remote_dir ||
12489 error "create remote directory failed"
12490 mcreate_path2fid 0010666 0 0 "remote_dir/fifo" "FIFO"
12491 mcreate_path2fid 0020666 1 3 "remote_dir/null" \
12492 "character special file (null)"
12493 mcreate_path2fid 0020666 1 255 "remote_dir/none" \
12494 "character special file (no device)"
12495 mcreate_path2fid 0040666 0 0 "remote_dir/dir" "directory"
12496 mcreate_path2fid 0060666 7 0 "remote_dir/loop0" \
12497 "block special file (loop)"
12498 mcreate_path2fid 0100666 0 0 "remote_dir/file" "regular file"
12499 mcreate_path2fid 0120666 0 0 "remote_dir/link" "symbolic link"
12500 mcreate_path2fid 0140666 0 0 "remote_dir/sock" "socket"
12502 run_test 226b "call path2fid and fid2path on files of all type under remote dir"
12504 # LU-1299 Executing or running ldd on a truncated executable does not
12505 # cause an out-of-memory condition.
12507 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12508 [ -z "$(which ldd)" ] && skip "should have ldd tool" && return
12509 dd if=$(which date) of=$MOUNT/date bs=1k count=1
12510 chmod +x $MOUNT/date
12512 $MOUNT/date > /dev/null
12513 ldd $MOUNT/date > /dev/null
12516 run_test 227 "running truncated executable does not cause OOM"
12518 # LU-1512 try to reuse idle OI blocks
12520 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12521 remote_mds_nodsh && skip "remote MDS with nodsh" && return
12522 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
12523 skip "non-ldiskfs backend" && return
12525 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
12526 local myDIR=$DIR/$tdir
12529 #define OBD_FAIL_SEQ_EXHAUST 0x1002
12530 $LCTL set_param fail_loc=0x80001002
12531 createmany -o $myDIR/t- 10000
12532 $LCTL set_param fail_loc=0
12533 # The guard is current the largest FID holder
12535 local SEQ=$($LFS path2fid $myDIR/guard | awk -F ':' '{print $1}' |
12537 local IDX=$(($SEQ % 64))
12539 do_facet $SINGLEMDS sync
12540 # Make sure journal flushed.
12542 local blk1=$(do_facet $SINGLEMDS \
12543 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
12544 grep Blockcount | awk '{print $4}')
12546 # Remove old files, some OI blocks will become idle.
12547 unlinkmany $myDIR/t- 10000
12548 # Create new files, idle OI blocks should be reused.
12549 createmany -o $myDIR/t- 2000
12550 do_facet $SINGLEMDS sync
12551 # Make sure journal flushed.
12553 local blk2=$(do_facet $SINGLEMDS \
12554 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
12555 grep Blockcount | awk '{print $4}')
12557 [ $blk1 == $blk2 ] || error "old blk1=$blk1, new blk2=$blk2, unmatched!"
12559 run_test 228a "try to reuse idle OI blocks"
12562 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12563 remote_mds_nodsh && skip "remote MDS with nodsh" && return
12564 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
12565 skip "non-ldiskfs backend" && return
12567 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
12568 local myDIR=$DIR/$tdir
12571 #define OBD_FAIL_SEQ_EXHAUST 0x1002
12572 $LCTL set_param fail_loc=0x80001002
12573 createmany -o $myDIR/t- 10000
12574 $LCTL set_param fail_loc=0
12575 # The guard is current the largest FID holder
12577 local SEQ=$($LFS path2fid $myDIR/guard | awk -F ':' '{print $1}' |
12579 local IDX=$(($SEQ % 64))
12581 do_facet $SINGLEMDS sync
12582 # Make sure journal flushed.
12584 local blk1=$(do_facet $SINGLEMDS \
12585 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
12586 grep Blockcount | awk '{print $4}')
12588 # Remove old files, some OI blocks will become idle.
12589 unlinkmany $myDIR/t- 10000
12592 stop $SINGLEMDS || error "Fail to stop MDT."
12594 start $SINGLEMDS $MDT_DEV $MDS_MOUNT_OPTS || error "Fail to start MDT."
12596 df $MOUNT || error "Fail to df."
12597 # Create new files, idle OI blocks should be reused.
12598 createmany -o $myDIR/t- 2000
12599 do_facet $SINGLEMDS sync
12600 # Make sure journal flushed.
12602 local blk2=$(do_facet $SINGLEMDS \
12603 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
12604 grep Blockcount | awk '{print $4}')
12606 [ $blk1 == $blk2 ] || error "old blk1=$blk1, new blk2=$blk2, unmatched!"
12608 run_test 228b "idle OI blocks can be reused after MDT restart"
12612 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12613 remote_mds_nodsh && skip "remote MDS with nodsh" && return
12614 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
12615 skip "non-ldiskfs backend" && return
12617 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
12618 local myDIR=$DIR/$tdir
12621 #define OBD_FAIL_SEQ_EXHAUST 0x1002
12622 $LCTL set_param fail_loc=0x80001002
12623 # 20000 files can guarantee there are index nodes in the OI file
12624 createmany -o $myDIR/t- 20000
12625 $LCTL set_param fail_loc=0
12626 # The guard is current the largest FID holder
12628 local SEQ=$($LFS path2fid $myDIR/guard | awk -F ':' '{print $1}' |
12630 local IDX=$(($SEQ % 64))
12632 do_facet $SINGLEMDS sync
12633 # Make sure journal flushed.
12635 local blk1=$(do_facet $SINGLEMDS \
12636 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
12637 grep Blockcount | awk '{print $4}')
12639 # Remove old files, some OI blocks will become idle.
12640 unlinkmany $myDIR/t- 20000
12642 # The OI file should become empty now
12644 # Create new files, idle OI blocks should be reused.
12645 createmany -o $myDIR/t- 2000
12646 do_facet $SINGLEMDS sync
12647 # Make sure journal flushed.
12649 local blk2=$(do_facet $SINGLEMDS \
12650 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
12651 grep Blockcount | awk '{print $4}')
12653 [ $blk1 == $blk2 ] || error "old blk1=$blk1, new blk2=$blk2, unmatched!"
12655 run_test 228c "NOT shrink the last entry in OI index node to recycle idle leaf"
12657 test_229() { # LU-2482, LU-3448
12658 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.53) ] &&
12659 skip "No HSM $(lustre_build_version $SINGLEMDS) MDS < 2.4.53" &&
12661 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12662 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs" && return
12666 # Create a file with a released layout and stripe count 2.
12667 $MULTIOP $DIR/$tfile H2c ||
12668 error "failed to create file with released layout"
12670 $GETSTRIPE -v $DIR/$tfile
12672 local pattern=$($GETSTRIPE -L $DIR/$tfile)
12673 [ X"$pattern" = X"80000001" ] || error "pattern error ($pattern)"
12675 local stripe_count=$($GETSTRIPE -c $DIR/$tfile) || error "getstripe"
12676 [ $stripe_count -eq 2 ] || error "stripe count not 2 ($stripe_count)"
12677 stat $DIR/$tfile || error "failed to stat released file"
12679 chown $RUNAS_ID $DIR/$tfile ||
12680 error "chown $RUNAS_ID $DIR/$tfile failed"
12682 chgrp $RUNAS_ID $DIR/$tfile ||
12683 error "chgrp $RUNAS_ID $DIR/$tfile failed"
12685 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
12686 rm $DIR/$tfile || error "failed to remove released file"
12688 run_test 229 "getstripe/stat/rm/attr changes work on released files"
12691 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12692 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
12695 test_mkdir $DIR/$tdir
12696 test_mkdir -i0 -c1 $DIR/$tdir/test_230_local
12697 local mdt_idx=$($GETSTRIPE -M $DIR/$tdir/test_230_local)
12698 [ $mdt_idx -ne 0 ] &&
12699 error "create local directory on wrong MDT $mdt_idx"
12701 $LFS mkdir -i $MDTIDX $DIR/$tdir/test_230 ||
12702 error "create remote directory failed"
12703 local mdt_idx=$($GETSTRIPE -M $DIR/$tdir/test_230)
12704 [ $mdt_idx -ne $MDTIDX ] &&
12705 error "create remote directory on wrong MDT $mdt_idx"
12707 createmany -o $DIR/$tdir/test_230/t- 10 ||
12708 error "create files on remote directory failed"
12709 mdt_idx=$($GETSTRIPE -M $DIR/$tdir/test_230/t-0)
12710 [ $mdt_idx -ne $MDTIDX ] && error "create files on wrong MDT $mdt_idx"
12711 rm -r $DIR/$tdir || error "unlink remote directory failed"
12713 run_test 230a "Create remote directory and files under the remote directory"
12716 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12717 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
12724 local migrate_dir=$DIR/$tdir/migrate_dir
12725 local other_dir=$DIR/$tdir/other_dir
12727 test_mkdir $DIR/$tdir
12728 test_mkdir -i0 -c1 $migrate_dir
12729 test_mkdir -i0 -c1 $other_dir
12730 for ((i=0; i<10; i++)); do
12731 mkdir -p $migrate_dir/dir_${i}
12732 createmany -o $migrate_dir/dir_${i}/f 10 ||
12733 error "create files under remote dir failed $i"
12736 cp /etc/passwd $migrate_dir/$tfile
12737 cp /etc/passwd $other_dir/$tfile
12738 chattr +SAD $migrate_dir
12739 chattr +SAD $migrate_dir/$tfile
12741 local old_dir_flag=$(lsattr -a $migrate_dir | awk '/\/\.$/ {print $1}')
12742 local old_file_flag=$(lsattr $migrate_dir/$tfile | awk '{print $1}')
12743 local old_dir_mode=$(stat -c%f $migrate_dir)
12744 local old_file_mode=$(stat -c%f $migrate_dir/$tfile)
12746 mkdir -p $migrate_dir/dir_default_stripe2
12747 $SETSTRIPE -c 2 $migrate_dir/dir_default_stripe2
12748 $SETSTRIPE -c 2 $migrate_dir/${tfile}_stripe2
12750 mkdir -p $other_dir
12751 ln $migrate_dir/$tfile $other_dir/luna
12752 ln $migrate_dir/$tfile $migrate_dir/sofia
12753 ln $other_dir/$tfile $migrate_dir/david
12754 ln -s $migrate_dir/$tfile $other_dir/zachary
12755 ln -s $migrate_dir/$tfile $migrate_dir/${tfile}_ln
12756 ln -s $other_dir/$tfile $migrate_dir/${tfile}_ln_other
12758 $LFS migrate -m $MDTIDX $migrate_dir ||
12759 error "fails on migrating remote dir to MDT1"
12761 echo "migratate to MDT1, then checking.."
12762 for ((i = 0; i < 10; i++)); do
12763 for file in $(find $migrate_dir/dir_${i}); do
12764 mdt_index=$($LFS getstripe -M $file)
12765 [ $mdt_index == $MDTIDX ] ||
12766 error "$file is not on MDT${MDTIDX}"
12770 # the multiple link file should still in MDT0
12771 mdt_index=$($LFS getstripe -M $migrate_dir/$tfile)
12772 [ $mdt_index == 0 ] ||
12773 error "$file is not on MDT${MDTIDX}"
12775 local new_dir_flag=$(lsattr -a $migrate_dir | awk '/\/\.$/ {print $1}')
12776 [ "$old_dir_flag" = "$new_dir_flag" ] ||
12777 error " expect $old_dir_flag get $new_dir_flag"
12779 local new_file_flag=$(lsattr $migrate_dir/$tfile | awk '{print $1}')
12780 [ "$old_file_flag" = "$new_file_flag" ] ||
12781 error " expect $old_file_flag get $new_file_flag"
12783 local new_dir_mode=$(stat -c%f $migrate_dir)
12784 [ "$old_dir_mode" = "$new_dir_mode" ] ||
12785 error "expect mode $old_dir_mode get $new_dir_mode"
12787 local new_file_mode=$(stat -c%f $migrate_dir/$tfile)
12788 [ "$old_file_mode" = "$new_file_mode" ] ||
12789 error "expect mode $old_file_mode get $new_file_mode"
12791 diff /etc/passwd $migrate_dir/$tfile ||
12792 error "$tfile different after migration"
12794 diff /etc/passwd $other_dir/luna ||
12795 error "luna different after migration"
12797 diff /etc/passwd $migrate_dir/sofia ||
12798 error "sofia different after migration"
12800 diff /etc/passwd $migrate_dir/david ||
12801 error "david different after migration"
12803 diff /etc/passwd $other_dir/zachary ||
12804 error "zachary different after migration"
12806 diff /etc/passwd $migrate_dir/${tfile}_ln ||
12807 error "${tfile}_ln different after migration"
12809 diff /etc/passwd $migrate_dir/${tfile}_ln_other ||
12810 error "${tfile}_ln_other different after migration"
12812 stripe_count=$($LFS getstripe -c $migrate_dir/dir_default_stripe2)
12813 [ $stripe_count = 2 ] ||
12814 error "dir strpe_count $d != 2 after migration."
12816 stripe_count=$($LFS getstripe -c $migrate_dir/${tfile}_stripe2)
12817 [ $stripe_count = 2 ] ||
12818 error "file strpe_count $d != 2 after migration."
12820 #migrate back to MDT0
12823 $LFS migrate -m $MDTIDX $migrate_dir ||
12824 error "fails on migrating remote dir to MDT0"
12826 echo "migrate back to MDT0, checking.."
12827 for file in $(find $migrate_dir); do
12828 mdt_index=$($LFS getstripe -M $file)
12829 [ $mdt_index == $MDTIDX ] ||
12830 error "$file is not on MDT${MDTIDX}"
12833 local new_dir_flag=$(lsattr -a $migrate_dir | awk '/\/\.$/ {print $1}')
12834 [ "$old_dir_flag" = "$new_dir_flag" ] ||
12835 error " expect $old_dir_flag get $new_dir_flag"
12837 local new_file_flag=$(lsattr $migrate_dir/$tfile | awk '{print $1}')
12838 [ "$old_file_flag" = "$new_file_flag" ] ||
12839 error " expect $old_file_flag get $new_file_flag"
12841 local new_dir_mode=$(stat -c%f $migrate_dir)
12842 [ "$old_dir_mode" = "$new_dir_mode" ] ||
12843 error "expect mode $old_dir_mode get $new_dir_mode"
12845 local new_file_mode=$(stat -c%f $migrate_dir/$tfile)
12846 [ "$old_file_mode" = "$new_file_mode" ] ||
12847 error "expect mode $old_file_mode get $new_file_mode"
12849 diff /etc/passwd ${migrate_dir}/$tfile ||
12850 error "$tfile different after migration"
12852 diff /etc/passwd ${other_dir}/luna ||
12853 error "luna different after migration"
12855 diff /etc/passwd ${migrate_dir}/sofia ||
12856 error "sofia different after migration"
12858 diff /etc/passwd ${other_dir}/zachary ||
12859 error "zachary different after migration"
12861 diff /etc/passwd $migrate_dir/${tfile}_ln ||
12862 error "${tfile}_ln different after migration"
12864 diff /etc/passwd $migrate_dir/${tfile}_ln_other ||
12865 error "${tfile}_ln_other different after migration"
12867 stripe_count=$($LFS getstripe -c ${migrate_dir}/dir_default_stripe2)
12868 [ $stripe_count = 2 ] ||
12869 error "dir strpe_count $d != 2 after migration."
12871 stripe_count=$($LFS getstripe -c ${migrate_dir}/${tfile}_stripe2)
12872 [ $stripe_count = 2 ] ||
12873 error "file strpe_count $d != 2 after migration."
12875 rm -rf $DIR/$tdir || error "rm dir failed after migration"
12877 run_test 230b "migrate directory"
12880 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12881 remote_mds_nodsh && skip "remote MDS with nodsh" && return
12882 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
12886 local migrate_dir=$DIR/$tdir/migrate_dir
12888 #If migrating directory fails in the middle, all entries of
12889 #the directory is still accessiable.
12890 test_mkdir $DIR/$tdir
12891 test_mkdir -i0 -c1 $migrate_dir
12893 createmany -o $migrate_dir/f 10 ||
12894 error "create files under ${migrate_dir} failed"
12896 #failed after migrating 5 entries
12897 #OBD_FAIL_MIGRATE_ENTRIES 0x1801
12898 do_facet mds1 lctl set_param fail_loc=0x20001801
12899 do_facet mds1 lctl set_param fail_val=5
12900 local t=$(ls $migrate_dir | wc -l)
12901 $LFS migrate --mdt-index $MDTIDX $migrate_dir &&
12902 error "migrate should fail after 5 entries"
12904 mkdir $migrate_dir/dir &&
12905 error "mkdir succeeds under migrating directory"
12906 touch $migrate_dir/file &&
12907 error "touch file succeeds under migrating directory"
12909 local u=$(ls $migrate_dir | wc -l)
12910 [ "$u" == "$t" ] || error "$u != $t during migration"
12912 for file in $(find $migrate_dir); do
12913 stat $file || error "stat $file failed"
12916 do_facet mds1 lctl set_param fail_loc=0
12917 do_facet mds1 lctl set_param fail_val=0
12919 $LFS migrate -m $MDTIDX $migrate_dir ||
12920 error "migrate open files should failed with open files"
12922 echo "Finish migration, then checking.."
12923 for file in $(find $migrate_dir); do
12924 mdt_index=$($LFS getstripe -M $file)
12925 [ $mdt_index == $MDTIDX ] ||
12926 error "$file is not on MDT${MDTIDX}"
12929 rm -rf $DIR/$tdir || error "rm dir failed after migration"
12931 run_test 230c "check directory accessiblity if migration is failed"
12934 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12935 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
12938 local migrate_dir=$DIR/$tdir/migrate_dir
12942 test_mkdir $DIR/$tdir
12943 test_mkdir -i0 -c1 $migrate_dir
12945 for ((i=0; i<100; i++)); do
12946 test_mkdir -i0 -c1 $migrate_dir/dir_${i}
12947 createmany -o $migrate_dir/dir_${i}/f 100 ||
12948 error "create files under remote dir failed $i"
12951 $LFS migrate -m $MDTIDX $migrate_dir ||
12952 error "migrate remote dir error"
12954 echo "Finish migration, then checking.."
12955 for file in $(find $migrate_dir); do
12956 mdt_index=$($LFS getstripe -M $file)
12957 [ $mdt_index == $MDTIDX ] ||
12958 error "$file is not on MDT${MDTIDX}"
12961 rm -rf $DIR/$tdir || error "rm dir failed after migration"
12963 run_test 230d "check migrate big directory"
12966 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12967 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
12973 mkdir -p $DIR/$tdir
12974 mkdir $DIR/$tdir/migrate_dir
12975 mkdir $DIR/$tdir/other_dir
12976 touch $DIR/$tdir/migrate_dir/a
12977 ln $DIR/$tdir/migrate_dir/a $DIR/$tdir/other_dir/b
12979 $LFS migrate -m 1 $DIR/$tdir/migrate_dir ||
12980 error "migrate dir fails"
12982 mdt_index=$($LFS getstripe -M $DIR/$tdir/migrate_dir)
12983 [ $mdt_index == 1 ] || error "migrate_dir is not on MDT1"
12985 mdt_index=$($LFS getstripe -M $DIR/$tdir/migrate_dir/a)
12986 [ $mdt_index == 0 ] || error "a is not on MDT0"
12988 $LFS migrate -m 1 $DIR/$tdir/other_dir ||
12989 error "migrate dir fails"
12991 mdt_index=$($LFS getstripe -M $DIR/$tdir/other_dir)
12992 [ $mdt_index == 1 ] || error "other_dir is not on MDT1"
12994 mdt_index=$($LFS getstripe -M $DIR/$tdir/migrate_dir/a)
12995 [ $mdt_index == 1 ] || error "a is not on MDT1"
12997 mdt_index=$($LFS getstripe -M $DIR/$tdir/other_dir/b)
12998 [ $mdt_index == 1 ] || error "b is not on MDT1"
13000 a_fid=$($LFS path2fid $DIR/$tdir/migrate_dir/a)
13001 b_fid=$($LFS path2fid $DIR/$tdir/other_dir/b)
13003 [ "$a_fid" = "$b_fid" ] || error "different fid after migration"
13005 rm -rf $DIR/$tdir || error "rm dir failed after migration"
13007 run_test 230e "migrate mulitple local link files"
13010 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13011 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
13015 mkdir -p $DIR/$tdir
13016 mkdir $DIR/$tdir/migrate_dir
13017 $LFS mkdir -i1 $DIR/$tdir/other_dir
13018 touch $DIR/$tdir/migrate_dir/a
13019 ln $DIR/$tdir/migrate_dir/a $DIR/$tdir/other_dir/ln1
13020 ln $DIR/$tdir/migrate_dir/a $DIR/$tdir/other_dir/ln2
13022 # a should be migrated to MDT1, since no other links on MDT0
13023 $LFS migrate -m 1 $DIR/$tdir/migrate_dir ||
13024 error "migrate dir fails"
13025 mdt_index=$($LFS getstripe -M $DIR/$tdir/migrate_dir)
13026 [ $mdt_index == 1 ] || error "migrate_dir is not on MDT1"
13027 mdt_index=$($LFS getstripe -M $DIR/$tdir/migrate_dir/a)
13028 [ $mdt_index == 1 ] || error "a is not on MDT1"
13030 # a should stay on MDT1, because it is a mulitple link file
13031 $LFS migrate -m 0 $DIR/$tdir/migrate_dir ||
13032 error "migrate dir fails"
13033 mdt_index=$($LFS getstripe -M $DIR/$tdir/migrate_dir/a)
13034 [ $mdt_index == 1 ] || error "a is not on MDT1"
13036 $LFS migrate -m 1 $DIR/$tdir/migrate_dir ||
13037 error "migrate dir fails"
13039 a_fid=$($LFS path2fid $DIR/$tdir/migrate_dir/a)
13040 ln_fid=$($LFS path2fid $DIR/$tdir/other_dir/ln1)
13041 [ "$a_fid" = "$ln_fid" ] || error "different fid after migrate to MDT1"
13043 rm -rf $DIR/$tdir/other_dir/ln1 || error "unlink ln1 fails"
13044 rm -rf $DIR/$tdir/other_dir/ln2 || error "unlink ln2 fails"
13046 # a should be migrated to MDT0, since no other links on MDT1
13047 $LFS migrate -m 0 $DIR/$tdir/migrate_dir ||
13048 error "migrate dir fails"
13049 mdt_index=$($LFS getstripe -M $DIR/$tdir/migrate_dir/a)
13050 [ $mdt_index == 0 ] || error "a is not on MDT0"
13052 rm -rf $DIR/$tdir || error "rm dir failed after migration"
13054 run_test 230f "migrate mulitple remote link files"
13057 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13058 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
13060 mkdir -p $DIR/$tdir/migrate_dir
13062 $LFS migrate -m 1000 $DIR/$tdir/migrate_dir &&
13063 error "migrating dir to non-exist MDT succeeds"
13066 run_test 230g "migrate dir to non-exist MDT"
13070 # For simplicity this test assumes that max_pages_per_rpc
13071 # is the same across all OSCs
13072 local max_pages=$($LCTL get_param -n osc.*.max_pages_per_rpc | head -n1)
13073 local bulk_size=$((max_pages * 4096))
13075 mkdir -p $DIR/$tdir
13077 # clear the OSC stats
13078 $LCTL set_param osc.*.stats=0 &>/dev/null
13080 # Client writes $bulk_size - there must be 1 rpc for $max_pages.
13081 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=$bulk_size count=1 \
13082 oflag=direct &>/dev/null || error "dd failed"
13084 local nrpcs=$($LCTL get_param osc.*.stats |awk '/ost_write/ {print $2}')
13085 if [ x$nrpcs != "x1" ]; then
13086 error "found $nrpc ost_write RPCs, not 1 as expected"
13089 # Drop the OSC cache, otherwise we will read from it
13090 cancel_lru_locks osc
13092 # clear the OSC stats
13093 $LCTL set_param osc.*.stats=0 &>/dev/null
13095 # Client reads $bulk_size.
13096 dd if=$DIR/$tdir/$tfile of=/dev/null bs=$bulk_size count=1 \
13097 iflag=direct &>/dev/null || error "dd failed"
13099 nrpcs=$($LCTL get_param osc.*.stats | awk '/ost_read/ { print $2 }')
13100 if [ x$nrpcs != "x1" ]; then
13101 error "found $nrpc ost_read RPCs, not 1 as expected"
13104 run_test 231a "checking that reading/writing of BRW RPC size results in one RPC"
13107 mkdir -p $DIR/$tdir
13109 for i in {0..1023}; do
13110 dd if=/dev/zero of=$DIR/$tdir/$tfile conv=notrunc \
13111 seek=$((2 * i)) bs=4096 count=1 &>/dev/null ||
13112 error "dd of=$DIR/$tdir/$tfile seek=$((2 * i)) failed"
13116 run_test 231b "must not assert on fully utilized OST request buffer"
13119 mkdir -p $DIR/$tdir
13120 #define OBD_FAIL_LDLM_OST_LVB 0x31c
13121 $LCTL set_param fail_loc=0x31c
13123 # ignore dd failure
13124 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=1 || true
13126 $LCTL set_param fail_loc=0
13127 umount_client $MOUNT || error "umount failed"
13128 mount_client $MOUNT || error "mount failed"
13130 run_test 232 "failed lock should not block umount"
13133 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.3.64) ] ||
13134 { skip "Need MDS version at least 2.3.64"; return; }
13136 local fid=$($LFS path2fid $MOUNT)
13137 stat $MOUNT/.lustre/fid/$fid > /dev/null ||
13138 error "cannot access $MOUNT using its FID '$fid'"
13140 run_test 233a "checking that OBF of the FS root succeeds"
13143 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.5.90) ] ||
13144 { skip "Need MDS version at least 2.5.90"; return; }
13146 local fid=$($LFS path2fid $MOUNT/.lustre)
13147 stat $MOUNT/.lustre/fid/$fid > /dev/null ||
13148 error "cannot access $MOUNT/.lustre using its FID '$fid'"
13150 fid=$($LFS path2fid $MOUNT/.lustre/fid)
13151 stat $MOUNT/.lustre/fid/$fid > /dev/null ||
13152 error "cannot access $MOUNT/.lustre/fid using its FID '$fid'"
13154 run_test 233b "checking that OBF of the FS .lustre succeeds"
13157 local p="$TMP/sanityN-$TESTNAME.parameters"
13158 save_lustre_params client "llite.*.xattr_cache" > $p
13159 lctl set_param llite.*.xattr_cache 1 ||
13160 { skip "xattr cache is not supported"; return 0; }
13162 mkdir -p $DIR/$tdir || error "mkdir failed"
13163 touch $DIR/$tdir/$tfile || error "touch failed"
13164 # OBD_FAIL_LLITE_XATTR_ENOMEM
13165 $LCTL set_param fail_loc=0x1405
13166 # output of the form: attr 2 4 44 3 fc13 x86_64
13167 V=($(IFS=".-" rpm -q attr))
13168 if [[ ${V[1]} > 2 || ${V[2]} > 4 || ${V[3]} > 44 ||
13169 ${V[1]} = 2 && ${V[2]} = 4 && ${V[3]} = 44 && ${V[4]} > 6 ]]; then
13170 # attr pre-2.4.44-7 had a bug with rc
13171 # LU-3703 - SLES 11 and FC13 clients have older attr
13172 getfattr -n user.attr $DIR/$tdir/$tfile &&
13173 error "getfattr should have failed with ENOMEM"
13175 skip "LU-3703: attr version $(getfattr --version) too old"
13177 $LCTL set_param fail_loc=0x0
13180 restore_lustre_params < $p
13183 run_test 234 "xattr cache should not crash on ENOMEM"
13186 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.52) ] &&
13187 skip "Need MDS version at least 2.4.52" && return
13188 flock_deadlock $DIR/$tfile
13193 124) error "process hangs on a deadlock"
13195 *) error "error executing flock_deadlock $DIR/$tfile"
13199 run_test 235 "LU-1715: flock deadlock detection does not work properly"
13203 check_swap_layouts_support && return 0
13204 test_mkdir -p -c1 $DIR/$tdir || error "mkdir $tdir failed"
13206 local ref1=/etc/passwd
13207 local ref2=/etc/group
13208 local file1=$DIR/$tdir/f1
13209 local file2=$DIR/$tdir/f2
13211 $SETSTRIPE -c 1 $file1 || error "cannot setstripe on '$file1': rc = $?"
13212 cp $ref1 $file1 || error "cp $ref1 $file1 failed: rc = $?"
13213 $SETSTRIPE -c 2 $file2 || error "cannot setstripe on '$file2': rc = $?"
13214 cp $ref2 $file2 || error "cp $ref2 $file2 failed: rc = $?"
13215 local fd=$(free_fd)
13216 local cmd="exec $fd<>$file2"
13219 $LFS swap_layouts $file1 /proc/self/fd/${fd} ||
13220 error "cannot swap layouts of '$file1' and /proc/self/fd/${fd}"
13223 cmp $ref2 $file1 || error "content compare failed ($ref2 != $file1)"
13228 run_test 236 "Layout swap on open unlinked file"
13230 # test to verify file handle related system calls
13231 # (name_to_handle_at/open_by_handle_at)
13232 # The new system calls are supported in glibc >= 2.14.
13235 echo "Test file_handle syscalls" > $DIR/$tfile ||
13236 error "write failed"
13237 check_fhandle_syscalls $DIR/$tfile ||
13238 error "check_fhandle_syscalls failed"
13240 run_test 237 "Verify name_to_handle_at/open_by_handle_at syscalls"
13242 # LU-4659 linkea consistency
13244 local server_version=$(lustre_version_code $SINGLEMDS)
13246 [[ $server_version -gt $(version_code 2.5.57) ]] ||
13247 [[ $server_version -gt $(version_code 2.5.1) &&
13248 $server_version -lt $(version_code 2.5.50) ]] ||
13249 { skip "Need MDS version at least 2.5.58 or 2.5.2+"; return; }
13252 ln $DIR/$tfile $DIR/$tfile.lnk
13253 touch $DIR/$tfile.new
13254 mv $DIR/$tfile.new $DIR/$tfile
13255 local fid1=$($LFS path2fid $DIR/$tfile)
13256 local fid2=$($LFS path2fid $DIR/$tfile.lnk)
13257 local path1=$($LFS fid2path $FSNAME "$fid1")
13258 [ $tfile == $path1 ] || error "linkea inconsistent: $tfile $fid1 $path1"
13259 local path2=$($LFS fid2path $FSNAME "$fid2")
13260 [ $tfile.lnk == $path2 ] ||
13261 error "linkea inconsistent: $tfile.lnk $fid2 $path2!"
13264 run_test 238 "Verify linkea consistency"
13267 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.5.60) ] &&
13268 skip "Need MDS version at least 2.5.60" && return
13269 local list=$(comma_list $(mdts_nodes))
13271 mkdir -p $DIR/$tdir
13272 createmany -o $DIR/$tdir/f- 5000
13273 unlinkmany $DIR/$tdir/f- 5000
13274 do_nodes $list "lctl set_param -n osp*.*.sync_changes 1"
13275 changes=$(do_nodes $list "lctl get_param -n osc.*MDT*.sync_changes \
13276 osc.*MDT*.sync_in_flight" | calc_sum)
13277 [ "$changes" -eq 0 ] || error "$changes not synced"
13279 run_test 239 "osp_sync test"
13281 test_239a() { #LU-5297
13283 #define OBD_FAIL_OSP_CHECK_INVALID_REC 0x2100
13284 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x2100
13285 chgrp $RUNAS_GID $DIR/$tfile
13286 wait_delete_completed
13288 run_test 239a "process invalid osp sync record correctly"
13290 test_239b() { #LU-5297
13292 #define OBD_FAIL_OSP_CHECK_ENOMEM 0x2101
13293 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x2101
13294 chgrp $RUNAS_GID $DIR/$tfile1
13295 wait_delete_completed
13296 do_facet $SINGLEMDS $LCTL set_param fail_loc=0
13298 chgrp $RUNAS_GID $DIR/$tfile2
13299 wait_delete_completed
13301 run_test 239b "process osp sync record with ENOMEM error correctly"
13304 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
13306 mkdir -p $DIR/$tdir
13308 $LFS mkdir -i 0 $DIR/$tdir/d0 ||
13309 error "failed to mkdir $DIR/$tdir/d0 on MDT0"
13310 $LFS mkdir -i 1 $DIR/$tdir/d0/d1 ||
13311 error "failed to mkdir $DIR/$tdir/d0/d1 on MDT1"
13313 umount_client $MOUNT || error "umount failed"
13314 #define OBD_FAIL_TGT_DELAY_CONDITIONAL 0x713
13315 do_facet mds2 lctl set_param fail_loc=0x713 fail_val=1
13316 mount_client $MOUNT || error "failed to mount client"
13318 echo "stat $DIR/$tdir/d0/d1, should not fail/ASSERT"
13319 stat $DIR/$tdir/d0/d1 || error "fail to stat $DIR/$tdir/d0/d1"
13321 run_test 240 "race between ldlm enqueue and the connection RPC (no ASSERT)"
13324 for LOOP in $(seq $1); do
13325 dd if=$DIR/$tfile of=/dev/null bs=40960 count=1 2>/dev/null
13326 cancel_lru_locks osc
13331 for LOOP in $(seq $1); do
13332 dd if=$DIR/$tfile of=/dev/null bs=40960 count=1 \
13333 iflag=direct 2>/dev/null
13338 dd if=/dev/zero of=$DIR/$tfile count=1 bs=40960
13340 cancel_lru_locks osc
13341 test_241_bio 1000 &
13346 run_test 241 "bio vs dio"
13349 dd if=/dev/zero of=$DIR/$tfile count=1 bs=40960
13351 test_241_dio 1000 &
13356 run_test 241b "dio vs dio"
13359 mkdir -p $DIR/$tdir
13360 touch $DIR/$tdir/$tfile
13362 #define OBD_FAIL_MDS_READPAGE_PACK 0x105
13363 do_facet mds1 lctl set_param fail_loc=0x105
13364 /bin/ls $DIR/$tdir && error "ls $DIR/$tdir should fail"
13366 do_facet mds1 lctl set_param fail_loc=0
13367 /bin/ls $DIR/$tdir || error "ls $DIR/$tdir failed"
13369 run_test 242 "mdt_readpage failure should not cause directory unreadable"
13373 test_mkdir -p $DIR/$tdir
13374 group_lock_test -d $DIR/$tdir || error "A group lock test failed"
13376 run_test 243 "various group lock tests"
13380 test_mkdir -p $DIR/$tdir
13381 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=35
13382 sendfile_grouplock $DIR/$tdir/$tfile || \
13383 error "sendfile+grouplock failed"
13386 run_test 244 "sendfile with group lock tests"
13389 local flagname="multi_mod_rpcs"
13390 local connect_data_name="max_mod_rpcs"
13393 # check if multiple modify RPCs flag is set
13394 out=$($LCTL get_param mdc.$FSNAME-MDT0000-*.import |
13395 grep "connect_flags:")
13398 echo "$out" | grep -qw $flagname
13399 if [ $? -ne 0 ]; then
13400 echo "connect flag $flagname is not set"
13404 # check if multiple modify RPCs data is set
13405 out=$($LCTL get_param mdc.$FSNAME-MDT0000-*.import)
13408 echo "$out" | grep -qw $connect_data_name ||
13409 error "import should have connect data $connect_data_name"
13411 run_test 245 "check mdc connection flag/data: multiple modify RPCs"
13413 test_246() { # LU-7371
13414 [ $(lustre_version_code ost1) -lt $(version_code 2.7.62) ] &&
13415 skip "Need OST version >= 2.7.62" && return 0
13416 do_facet ost1 $LCTL set_param fail_val=4095
13417 #define OBD_FAIL_OST_READ_SIZE 0x234
13418 do_facet ost1 $LCTL set_param fail_loc=0x234
13419 $LFS setstripe $DIR/$tfile -i 0 -c 1
13420 dd if=/dev/zero of=$DIR/$tfile bs=4095 count=1 > /dev/null 2>&1
13421 cancel_lru_locks $FSNAME-OST0000
13422 dd if=$DIR/$tfile of=/dev/null bs=1048576 || error "Read failed"
13424 run_test 246 "Read file of size 4095 should return right length"
13427 [ "$(facet_fstype ost$(($($GETSTRIPE -i $DIR/$tfile) + 1)))" = "zfs" ] \
13428 && skip "no 16TB file size limit on ZFS" && return
13430 $SETSTRIPE -c 1 $DIR/$tfile
13431 # ldiskfs extent file size limit is (16TB - 4KB - 1) bytes
13432 local size=$((16 * 1024 * 1024 * 1024 * 1024 - 4096 - 1))
13433 $TRUNCATE $DIR/$tfile $size || error "truncate $tfile to $size failed"
13434 dd if=/dev/zero of=$DIR/$tfile bs=10 count=1 oflag=append \
13435 conv=notrunc,fsync && error "append succeeded"
13438 run_test 250 "Write above 16T limit"
13441 $SETSTRIPE -c -1 -S 1048576 $DIR/$tfile
13443 #define OBD_FAIL_LLITE_LOST_LAYOUT 0x1407
13444 #Skip once - writing the first stripe will succeed
13445 $LCTL set_param fail_loc=0xa0001407 fail_val=1
13446 $MULTIOP $DIR/$tfile o:O_RDWR:w2097152c 2>&1 | grep -q "short write" &&
13447 error "short write happened"
13449 $LCTL set_param fail_loc=0xa0001407 fail_val=1
13450 $MULTIOP $DIR/$tfile or2097152c 2>&1 | grep -q "short read" &&
13451 error "short read happened"
13455 run_test 251 "Handling short read and write correctly"
13465 if [ "$(facet_fstype ost1)" != "ldiskfs" -o \
13466 "$(facet_fstype mds1)" != "ldiskfs" ]; then
13467 skip "can only run lr_reader on ldiskfs target"
13471 # check lr_reader on OST0000
13473 dev=$(facet_device $tgt)
13474 out=$(do_facet $tgt $LR_READER $dev)
13475 [ $? -eq 0 ] || error "$LR_READER failed on target $tgt device $dev"
13477 uuid=$(echo "$out" | grep -i uuid | awk '{ print $2 }')
13478 [ "$uuid" == "$(ostuuid_from_index 0)" ] ||
13479 error "Invalid uuid returned by $LR_READER on target $tgt"
13480 echo -e "uuid returned by $LR_READER is '$uuid'\n"
13482 # check lr_reader -c on MDT0000
13484 dev=$(facet_device $tgt)
13485 if ! do_facet $tgt $LR_READER -h | grep -q OPTIONS; then
13486 echo "$LR_READER does not support additional options"
13489 out=$(do_facet $tgt $LR_READER -c $dev)
13490 [ $? -eq 0 ] || error "$LR_READER failed on target $tgt device $dev"
13492 num=$(echo "$out" | grep -c "mdtlov")
13493 [ "$num" -eq $((MDSCOUNT - 1)) ] ||
13494 error "Invalid number of mdtlov clients returned by $LR_READER"
13495 echo -e "Number of mdtlov clients returned by $LR_READER is '$num'\n"
13497 # check lr_reader -cr on MDT0000
13498 out=$(do_facet $tgt $LR_READER -cr $dev)
13499 [ $? -eq 0 ] || error "$LR_READER failed on target $tgt device $dev"
13501 echo "$out" | grep -q "^reply_data:$" ||
13502 error "$LR_READER should have returned 'reply_data' section"
13503 num=$(echo "$out" | grep -c "client_generation")
13504 echo -e "Number of reply data returned by $LR_READER is '$num'\n"
13506 run_test 252 "check lr_reader tool"
13509 cleanup_test_300() {
13513 test_striped_dir() {
13518 mkdir -p $DIR/$tdir
13520 SAVE_UMASK=$(umask)
13521 trap cleanup_test_300 RETURN EXIT
13523 $LFS setdirstripe -i $mdt_index -c 2 -t all_char -m 755 \
13524 $DIR/$tdir/striped_dir ||
13525 error "set striped dir error"
13527 local mode=$(stat -c%a $DIR/$tdir/striped_dir)
13528 [ "$mode" = "755" ] || error "expect 755 got $mode"
13530 $LFS getdirstripe $DIR/$tdir/striped_dir > /dev/null 2>&1 ||
13531 error "getdirstripe failed"
13532 stripe_count=$($LFS getdirstripe -c $DIR/$tdir/striped_dir)
13533 if [ "$stripe_count" != "2" ]; then
13534 error "stripe_count is $stripe_count, expect 2"
13537 stripe_index=$($LFS getdirstripe -i $DIR/$tdir/striped_dir)
13538 if [ "$stripe_index" != "$mdt_index" ]; then
13539 error "stripe_index is $stripe_index, expect $mdt_index"
13542 [ $(stat -c%h $DIR/$tdir/striped_dir) == '2' ] ||
13543 error "nlink error after create striped dir"
13545 mkdir $DIR/$tdir/striped_dir/a
13546 mkdir $DIR/$tdir/striped_dir/b
13548 stat $DIR/$tdir/striped_dir/a ||
13549 error "create dir under striped dir failed"
13550 stat $DIR/$tdir/striped_dir/b ||
13551 error "create dir under striped dir failed"
13553 [ $(stat -c%h $DIR/$tdir/striped_dir) == '4' ] ||
13554 error "nlink error after mkdir"
13556 rmdir $DIR/$tdir/striped_dir/a
13557 [ $(stat -c%h $DIR/$tdir/striped_dir) == '3' ] ||
13558 error "nlink error after rmdir"
13560 rmdir $DIR/$tdir/striped_dir/b
13561 [ $(stat -c%h $DIR/$tdir/striped_dir) == '2' ] ||
13562 error "nlink error after rmdir"
13564 chattr +i $DIR/$tdir/striped_dir
13565 createmany -o $DIR/$tdir/striped_dir/f 10 &&
13566 error "immutable flags not working under striped dir!"
13567 chattr -i $DIR/$tdir/striped_dir
13569 rmdir $DIR/$tdir/striped_dir ||
13570 error "rmdir striped dir error"
13578 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13579 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
13581 test_striped_dir 0 || error "failed on striped dir on MDT0"
13582 test_striped_dir 1 || error "failed on striped dir on MDT0"
13584 run_test 300a "basic striped dir sanity test"
13587 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13588 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
13594 test_mkdir $DIR/$tdir || error "mkdir fail"
13595 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir ||
13596 error "set striped dir error"
13597 for ((i=0; i<10; i++)); do
13598 mtime1=$(stat -c %Y $DIR/$tdir/striped_dir)
13600 touch $DIR/$tdir/striped_dir/file_$i ||
13601 error "touch error $i"
13602 mtime2=$(stat -c %Y $DIR/$tdir/striped_dir)
13603 [ $mtime1 -eq $mtime2 ] &&
13604 error "mtime not change after create"
13606 rm -f $DIR/$tdir/striped_dir/file_$i ||
13607 error "unlink error $i"
13608 mtime3=$(stat -c %Y $DIR/$tdir/striped_dir)
13609 [ $mtime2 -eq $mtime3 ] &&
13610 error "mtime did not change after unlink"
13614 run_test 300b "check ctime/mtime for striped dir"
13617 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13618 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
13621 mkdir -p $DIR/$tdir
13622 $LFS setdirstripe -i 0 -c 2 $DIR/$tdir/striped_dir ||
13623 error "set striped dir error"
13625 chown $RUNAS_ID:$RUNAS_GID $DIR/$tdir/striped_dir ||
13626 error "chown striped dir failed"
13628 $RUNAS createmany -o $DIR/$tdir/striped_dir/f 5000 ||
13629 error "create 5k files failed"
13631 file_count=$(ls $DIR/$tdir/striped_dir | wc -l)
13633 [ "$file_count" = 5000 ] || error "file count $file_count != 5000"
13637 run_test 300c "chown && check ls under striped directory"
13640 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13641 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
13645 mkdir -p $DIR/$tdir
13646 $SETSTRIPE -c 2 $DIR/$tdir
13648 #local striped directory
13649 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir ||
13650 error "set striped dir error"
13651 createmany -o $DIR/$tdir/striped_dir/f 10 ||
13652 error "create 10 files failed"
13654 #remote striped directory
13655 $LFS setdirstripe -i 1 -c 2 $DIR/$tdir/remote_striped_dir ||
13656 error "set striped dir error"
13657 createmany -o $DIR/$tdir/remote_striped_dir/f 10 ||
13658 error "create 10 files failed"
13660 for file in $(find $DIR/$tdir); do
13661 stripe_count=$($GETSTRIPE -c $file)
13662 [ $stripe_count -eq 2 ] ||
13663 error "wrong stripe $stripe_count for $file"
13668 run_test 300d "check default stripe under striped directory"
13671 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
13672 skip "Need MDS version at least 2.7.55" && return
13673 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13674 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
13678 mkdir -p $DIR/$tdir
13680 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir ||
13681 error "set striped dir error"
13683 touch $DIR/$tdir/striped_dir/a
13684 touch $DIR/$tdir/striped_dir/b
13685 touch $DIR/$tdir/striped_dir/c
13687 mkdir $DIR/$tdir/striped_dir/dir_a
13688 mkdir $DIR/$tdir/striped_dir/dir_b
13689 mkdir $DIR/$tdir/striped_dir/dir_c
13691 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir/stp_a ||
13692 error "set striped dir under striped dir error"
13694 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir/stp_b ||
13695 error "set striped dir under striped dir error"
13697 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir/stp_c ||
13698 error "set striped dir under striped dir error"
13700 mrename $DIR/$tdir/striped_dir/dir_a $DIR/$tdir/striped_dir/dir_b ||
13701 error "rename dir under striped dir fails"
13703 mrename $DIR/$tdir/striped_dir/stp_a $DIR/$tdir/striped_dir/stp_b ||
13704 error "rename dir under different stripes fails"
13706 mrename $DIR/$tdir/striped_dir/a $DIR/$tdir/striped_dir/c ||
13707 error "rename file under striped dir should succeed"
13709 mrename $DIR/$tdir/striped_dir/dir_b $DIR/$tdir/striped_dir/dir_c ||
13710 error "rename dir under striped dir should succeed"
13714 run_test 300e "check rename under striped directory"
13717 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
13718 skip "Need MDS version at least 2.7.55" && return
13719 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13720 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
13725 mkdir -p $DIR/$tdir
13727 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir ||
13728 error "set striped dir error"
13730 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir1 ||
13731 error "set striped dir error"
13733 touch $DIR/$tdir/striped_dir/a
13734 mkdir $DIR/$tdir/striped_dir/dir_a
13735 $LFS setdirstripe -i 0 -c 2 $DIR/$tdir/striped_dir/stp_a ||
13736 error "create striped dir under striped dir fails"
13738 touch $DIR/$tdir/striped_dir1/b
13739 mkdir $DIR/$tdir/striped_dir1/dir_b
13740 $LFS setdirstripe -i 0 -c 2 $DIR/$tdir/striped_dir/stp_b ||
13741 error "create striped dir under striped dir fails"
13743 mrename $DIR/$tdir/striped_dir/dir_a $DIR/$tdir/striped_dir1/dir_b ||
13744 error "rename dir under different striped dir should fail"
13746 mrename $DIR/$tdir/striped_dir/stp_a $DIR/$tdir/striped_dir1/stp_b ||
13747 error "rename striped dir under diff striped dir should fail"
13749 mrename $DIR/$tdir/striped_dir/a $DIR/$tdir/striped_dir1/a ||
13750 error "rename file under diff striped dirs fails"
13754 run_test 300f "check rename cross striped directory"
13756 test_300_check_default_striped_dir()
13759 local default_count=$2
13760 local default_index=$3
13763 local dir_stripe_index
13766 echo "checking $dirname $default_count $default_index"
13767 $LFS setdirstripe -D -c $default_count -i $default_index \
13768 -t all_char $DIR/$tdir/$dirname ||
13769 error "set default stripe on striped dir error"
13770 stripe_count=$($LFS getdirstripe -D -c $DIR/$tdir/$dirname)
13771 [ $stripe_count -eq $default_count ] ||
13772 error "expect $default_count get $stripe_count for $dirname"
13774 stripe_index=$($LFS getdirstripe -D -i $DIR/$tdir/$dirname)
13775 [ $stripe_index -eq $default_index ] ||
13776 error "expect $default_index get $stripe_index for $dirname"
13778 mkdir $DIR/$tdir/$dirname/{test1,test2,test3,test4} ||
13779 error "create dirs failed"
13781 createmany -o $DIR/$tdir/$dirname/f- 10 || error "create files failed"
13782 unlinkmany $DIR/$tdir/$dirname/f- 10 || error "unlink files failed"
13783 for dir in $(find $DIR/$tdir/$dirname/*); do
13784 stripe_count=$($LFS getdirstripe -c $dir)
13785 [ $stripe_count -eq $default_count ] ||
13786 [ $stripe_count -eq 0 -o $default_count -eq 1 ] ||
13787 error "stripe count $default_count != $stripe_count for $dir"
13789 stripe_index=$($LFS getdirstripe -i $dir)
13790 [ $default_index -eq -1 -o $stripe_index -eq $default_index ] ||
13791 error "$stripe_index != $default_index for $dir"
13793 #check default stripe
13794 stripe_count=$($LFS getdirstripe -D -c $dir)
13795 [ $stripe_count -eq $default_count ] ||
13796 error "default count $default_count != $stripe_count for $dir"
13798 stripe_index=$($LFS getdirstripe -D -i $dir)
13799 [ $stripe_index -eq $default_index ] ||
13800 error "default index $default_index != $stripe_index for $dir"
13802 rmdir $DIR/$tdir/$dirname/* || error "rmdir failed"
13806 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
13807 skip "Need MDS version at least 2.7.55" && return
13808 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
13814 mkdir $DIR/$tdir/normal_dir
13816 test_300_check_default_striped_dir normal_dir $MDSCOUNT 1
13817 test_300_check_default_striped_dir normal_dir 1 0
13818 test_300_check_default_striped_dir normal_dir 2 1
13819 test_300_check_default_striped_dir normal_dir 2 -1
13821 #delete default stripe information
13822 echo "delete default stripeEA"
13823 $LFS setdirstripe -d $DIR/$tdir/normal_dir ||
13824 error "set default stripe on striped dir error"
13826 mkdir -p $DIR/$tdir/normal_dir/{test1,test2,test3,test4}
13827 for dir in $(find $DIR/$tdir/normal_dir/*); do
13828 stripe_count=$($LFS getdirstripe -c $dir)
13829 [ $stripe_count -eq 0 ] ||
13830 error "expect 1 get $stripe_count for $dir"
13831 stripe_index=$($LFS getdirstripe -i $dir)
13832 [ $stripe_index -eq 0 ] ||
13833 error "expect 0 get $stripe_index for $dir"
13836 run_test 300g "check default striped directory for normal directory"
13839 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
13840 skip "Need MDS version at least 2.7.55" && return
13841 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
13846 $LFS setdirstripe -i 0 -c $MDSCOUNT -t all_char \
13847 $DIR/$tdir/striped_dir ||
13848 error "set striped dir error"
13850 test_300_check_default_striped_dir striped_dir $MDSCOUNT 1
13851 test_300_check_default_striped_dir striped_dir 1 0
13852 test_300_check_default_striped_dir striped_dir 2 1
13853 test_300_check_default_striped_dir striped_dir 2 -1
13855 #delete default stripe information
13856 $LFS setdirstripe -d $DIR/$tdir/striped_dir ||
13857 error "set default stripe on striped dir error"
13859 mkdir -p $DIR/$tdir/striped_dir/{test1,test2,test3,test4}
13860 for dir in $(find $DIR/$tdir/striped_dir/*); do
13861 stripe_count=$($LFS getdirstripe -c $dir)
13862 [ $stripe_count -eq 0 ] ||
13863 error "expect 1 get $stripe_count for $dir"
13866 run_test 300h "check default striped directory for striped directory"
13869 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
13870 skip "Need MDS version at least 2.7.55" && return
13871 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13872 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
13878 $LFS setdirstripe -i 0 -c$MDSCOUNT -t all_char $DIR/$tdir/striped_dir ||
13879 error "set striped dir error"
13881 createmany -o $DIR/$tdir/striped_dir/f- 10 ||
13882 error "create files under striped dir failed"
13884 # unfortunately, we need to umount to clear dir layout cache for now
13885 # once we fully implement dir layout, we can drop this
13886 umount_client $MOUNT || error "umount failed"
13887 mount_client $MOUNT || error "mount failed"
13889 #set the stripe to be unknown hash type
13890 #define OBD_FAIL_UNKNOWN_LMV_STRIPE 0x1901
13891 $LCTL set_param fail_loc=0x1901
13892 for ((i = 0; i < 10; i++)); do
13893 $CHECKSTAT -t file $DIR/$tdir/striped_dir/f-$i ||
13894 error "stat f-$i failed"
13895 rm $DIR/$tdir/striped_dir/f-$i || error "unlink f-$i failed"
13898 touch $DIR/$tdir/striped_dir/f0 &&
13899 error "create under striped dir with unknown hash should fail"
13901 $LCTL set_param fail_loc=0
13903 umount_client $MOUNT || error "umount failed"
13904 mount_client $MOUNT || error "mount failed"
13908 run_test 300i "client handle unknown hash type striped directory"
13911 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13912 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
13913 skip "Need MDS version at least 2.7.55" && return
13914 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
13920 #define OBD_FAIL_SPLIT_UPDATE_REC 0x1702
13921 $LCTL set_param fail_loc=0x1702
13922 $LFS setdirstripe -i 0 -c$MDSCOUNT -t all_char $DIR/$tdir/striped_dir ||
13923 error "set striped dir error"
13925 createmany -o $DIR/$tdir/striped_dir/f- 10 ||
13926 error "create files under striped dir failed"
13928 $LCTL set_param fail_loc=0
13930 rm -rf $DIR/$tdir || error "unlink striped dir fails"
13934 run_test 300j "test large update record"
13937 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
13938 skip "Need MDS version at least 2.7.55" && return
13939 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13940 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
13946 #define OBD_FAIL_LARGE_STRIPE 0x1703
13947 $LCTL set_param fail_loc=0x1703
13948 $LFS setdirstripe -i 0 -c512 $DIR/$tdir/striped_dir ||
13949 error "set striped dir error"
13950 $LCTL set_param fail_loc=0
13952 $LFS getdirstripe $DIR/$tdir/striped_dir ||
13953 error "getstripeddir fails"
13954 rm -rf $DIR/$tdir/striped_dir ||
13955 error "unlink striped dir fails"
13959 run_test 300k "test large striped directory"
13962 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
13963 skip "Need MDS version at least 2.7.55" && return
13964 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13965 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
13968 test_mkdir -p $DIR/$tdir/striped_dir
13969 chown $RUNAS_ID $DIR/$tdir/striped_dir ||
13970 error "chown $RUNAS_ID failed"
13971 $LFS setdirstripe -i 1 -D $DIR/$tdir/striped_dir ||
13972 error "set default striped dir failed"
13974 #define OBD_FAIL_MDS_STALE_DIR_LAYOUT 0x158
13975 $LCTL set_param fail_loc=0x80000158
13976 $RUNAS mkdir $DIR/$tdir/striped_dir/test_dir || error "create dir fails"
13978 stripe_index=$($LFS getdirstripe -i $DIR/$tdir/striped_dir/test_dir)
13979 [ $stripe_index -eq 1 ] ||
13980 error "expect 1 get $stripe_index for $dir"
13982 run_test 300l "non-root user to create dir under striped dir with stale layout"
13985 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
13986 skip "Need MDS version at least 2.7.55" && return
13987 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13988 [ $MDSCOUNT -ge 2 ] && skip "Only for single MDT" && return
13990 mkdir -p $DIR/$tdir/striped_dir
13991 $LFS setdirstripe -D -c 1 $DIR/$tdir/striped_dir ||
13992 error "set default stripes dir error"
13994 mkdir $DIR/$tdir/striped_dir/a || error "mkdir a fails"
13996 stripe_count=$($LFS getdirstripe -c $DIR/$tdir/striped_dir/a)
13997 [ $stripe_count -eq 0 ] ||
13998 error "expect 0 get $stripe_count for a"
14000 $LFS setdirstripe -D -c 2 $DIR/$tdir/striped_dir ||
14001 error "set default stripes dir error"
14003 mkdir $DIR/$tdir/striped_dir/b || error "mkdir b fails"
14005 stripe_count=$($LFS getdirstripe -c $DIR/$tdir/striped_dir/b)
14006 [ $stripe_count -eq 0 ] ||
14007 error "expect 0 get $stripe_count for b"
14009 $LFS setdirstripe -D -c1 -i2 $DIR/$tdir/striped_dir ||
14010 error "set default stripes dir error"
14012 mkdir $DIR/$tdir/striped_dir/c &&
14013 error "default stripe_index is invalid, mkdir c should fails"
14015 rm -rf $DIR/$tdir || error "rmdir fails"
14017 run_test 300m "setstriped directory on single MDT FS"
14020 local list=$(comma_list $(mdts_nodes))
14023 do_nodes $list $LCTL set_param -n mdt.*.enable_remote_dir_gid=0
14027 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
14028 skip "Need MDS version at least 2.7.55" && return
14029 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
14030 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
14032 local list=$(comma_list $(mdts_nodes))
14034 trap cleanup_300n RETURN EXIT
14035 mkdir -p $DIR/$tdir
14036 chmod 777 $DIR/$tdir
14037 $RUNAS $LFS setdirstripe -i0 -c$MDSCOUNT \
14038 $DIR/$tdir/striped_dir > /dev/null 2>&1 &&
14039 error "create striped dir succeeds with gid=0"
14041 do_nodes $list $LCTL set_param -n mdt.*.enable_remote_dir_gid=-1
14042 $RUNAS $LFS setdirstripe -i0 -c$MDSCOUNT $DIR/$tdir/striped_dir ||
14043 error "create striped dir fails with gid=-1"
14045 do_nodes $list $LCTL set_param -n mdt.*.enable_remote_dir_gid=0
14046 $RUNAS $LFS setdirstripe -i 1 -c$MDSCOUNT -D \
14047 $DIR/$tdir/striped_dir > /dev/null 2>&1 &&
14048 error "set default striped dir succeeds with gid=0"
14051 do_nodes $list $LCTL set_param -n mdt.*.enable_remote_dir_gid=-1
14052 $RUNAS $LFS setdirstripe -i 1 -c$MDSCOUNT -D $DIR/$tdir/striped_dir ||
14053 error "set default striped dir fails with gid=-1"
14056 do_nodes $list $LCTL set_param -n mdt.*.enable_remote_dir_gid=0
14057 $RUNAS mkdir $DIR/$tdir/striped_dir/test_dir ||
14058 error "create test_dir fails"
14059 $RUNAS mkdir $DIR/$tdir/striped_dir/test_dir1 ||
14060 error "create test_dir1 fails"
14061 $RUNAS mkdir $DIR/$tdir/striped_dir/test_dir2 ||
14062 error "create test_dir2 fails"
14065 run_test 300n "non-root user to create dir under striped dir with default EA"
14068 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
14069 skip "Need MDS version at least 2.7.55" && return
14070 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
14071 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
14075 mkdir -p $DIR/$tdir
14077 numfree1=$(lctl get_param -n mdc.*MDT0000*.filesfree)
14078 numfree2=$(lctl get_param -n mdc.*MDT0001*.filesfree)
14079 if [ $numfree1 -lt 66000 -o $numfree2 -lt 66000 ]; then
14080 skip "not enough free inodes $numfree1 $numfree2"
14084 numfree1=$(lctl get_param -n mdc.*MDT0000-mdc-*.kbytesfree)
14085 numfree2=$(lctl get_param -n mdc.*MDT0001-mdc-*.kbytesfree)
14086 if [ $numfree1 -lt 300000 -o $numfree2 -lt 300000 ]; then
14087 skip "not enough free space $numfree1 $numfree2"
14091 $LFS setdirstripe -c2 $DIR/$tdir/striped_dir ||
14092 error "setdirstripe fails"
14094 createmany -d $DIR/$tdir/striped_dir/d 131000 ||
14095 error "create dirs fails"
14097 $LCTL set_param ldlm.namespaces.*mdc-*.lru_size=0
14098 ls $DIR/$tdir/striped_dir > /dev/null ||
14099 error "ls striped dir fails"
14100 unlinkmany -d $DIR/$tdir/striped_dir/d 131000 ||
14101 error "unlink big striped dir fails"
14103 run_test 300o "unlink big sub stripe(> 65000 subdirs)"
14106 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
14107 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
14109 mkdir -p $DIR/$tdir
14111 #define OBD_FAIL_OUT_ENOSPC 0x1704
14112 do_facet mds2 lctl set_param fail_loc=0x80001704
14113 $LFS setdirstripe -c2 $DIR/$tdir/bad_striped_dir > /dev/null 2>&1 &&
14114 error "create striped directory should fail"
14116 [ -e $DIR/$tdir/bad_striped_dir ] && error "striped dir exists"
14119 run_test 300p "create striped directory without space"
14121 prepare_remote_file() {
14122 mkdir $DIR/$tdir/src_dir ||
14123 error "create remote source failed"
14125 cp /etc/hosts $DIR/$tdir/src_dir/a || error
14126 touch $DIR/$tdir/src_dir/a
14128 $LFS mkdir -i 1 $DIR/$tdir/tgt_dir ||
14129 error "create remote target dir failed"
14131 touch $DIR/$tdir/tgt_dir/b
14133 mrename $DIR/$tdir/src_dir/a $DIR/$tdir/tgt_dir/b ||
14134 error "rename dir cross MDT failed!"
14136 $CHECKSTAT -t file $DIR/$tdir/src_dir/a &&
14137 error "src_child still exists after rename"
14139 $CHECKSTAT -t file $DIR/$tdir/tgt_dir/b ||
14140 error "missing file(a) after rename"
14142 diff /etc/hosts $DIR/$tdir/tgt_dir/b ||
14143 error "diff after rename"
14147 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 4 MDTs" && return
14148 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
14149 local remote_file=$DIR/$tdir/tgt_dir/b
14151 mkdir -p $DIR/$tdir
14153 prepare_remote_file || error "prepare remote file failed"
14156 $OPENUNLINK $remote_file $remote_file || error
14157 $CHECKSTAT -a $remote_file || error
14159 run_test 310a "open unlink remote file"
14162 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 4 MDTs" && return
14163 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
14164 local remote_file=$DIR/$tdir/tgt_dir/b
14166 mkdir -p $DIR/$tdir
14168 prepare_remote_file || error "prepare remote file failed"
14170 ln $remote_file $DIR/$tfile || error "link failed for remote file"
14171 $MULTIOP $DIR/$tfile Ouc || error "mulitop failed"
14172 $CHECKSTAT -t file $remote_file || error "check file failed"
14174 run_test 310b "unlink remote file with multiple links while open"
14177 [[ $MDSCOUNT -lt 4 ]] && skip "needs >= 4 MDTs" && return
14178 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
14179 local remote_file=$DIR/$tdir/tgt_dir/b
14181 mkdir -p $DIR/$tdir
14183 prepare_remote_file || error "prepare remote file failed"
14185 ln $remote_file $DIR/$tfile || error "link failed for remote file"
14186 multiop_bg_pause $remote_file O_uc ||
14187 error "mulitop failed for remote file"
14189 $MULTIOP $DIR/$tfile Ouc
14190 kill -USR1 $MULTIPID
14193 run_test 310c "open-unlink remote file with multiple links"
14195 test_400a() { # LU-1606, was conf-sanity test_74
14196 local extra_flags=''
14197 local out=$TMP/$tfile
14198 local prefix=/usr/include/lustre
14201 if ! which $CC > /dev/null 2>&1; then
14202 skip_env "$CC is not installed"
14206 if ! [[ -d $prefix ]]; then
14207 # Assume we're running in tree and fixup the include path.
14208 extra_flags+=" -I$LUSTRE/../libcfs/include"
14209 extra_flags+=" -I$LUSTRE/include"
14210 extra_flags+=" -L$LUSTRE/utils"
14213 for prog in $LUSTRE_TESTS_API_DIR/*.c; do
14214 $CC -Wall -Werror $extra_flags -llustreapi -o $out $prog ||
14215 error "client api broken"
14218 run_test 400a "Lustre client api program can compile and link"
14220 test_400b() { # LU-1606, LU-5011
14222 local out=$TMP/$tfile
14223 local prefix=/usr/include/lustre
14225 # We use a hard coded prefix so that this test will not fail
14226 # when run in tree. There are headers in lustre/include/lustre/
14227 # that are not packaged (like lustre_idl.h) and have more
14228 # complicated include dependencies (like config.h and lnet/types.h).
14229 # Since this test about correct packaging we just skip them when
14230 # they don't exist (see below) rather than try to fixup cppflags.
14232 if ! which $CC > /dev/null 2>&1; then
14233 skip_env "$CC is not installed"
14237 for header in $prefix/*.h; do
14238 if ! [[ -f "$header" ]]; then
14242 if [[ "$(basename $header)" == liblustreapi.h ]]; then
14243 continue # liblustreapi.h is deprecated.
14246 $CC -Wall -Werror -include $header -c -x c /dev/null -o $out ||
14247 error "cannot compile '$header'"
14250 run_test 400b "packaged headers can be compiled"
14253 # tests that do cleanup/setup should be run at the end
14257 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
14259 #define OBD_FAIL_MGC_PAUSE_PROCESS_LOG 0x903
14260 $LCTL set_param fail_loc=0x903
14262 cancel_lru_locks MGC
14264 FAIL_ON_ERROR=true cleanup
14265 FAIL_ON_ERROR=true setup
14267 run_test 900 "umount should not race with any mgc requeue thread"
14270 [ -f $EXT2_DEV ] && rm $EXT2_DEV || true
14271 check_and_cleanup_lustre
14272 if [ "$I_MOUNTED" != "yes" ]; then
14273 lctl set_param debug="$OLDDEBUG" 2> /dev/null || true