2 # -*- tab-width: 8; indent-tabs-mode: t; -*-
4 # Run select tests by setting ONLY, or as arguments to the script.
5 # Skip specific tests by setting EXCEPT.
7 # e.g. ONLY="22 23" or ONLY="`seq 32 39`" or EXCEPT="31"
11 # bug number for skipped test: 13297 2108 9789 3637 9789 3561 12622 5188
12 ALWAYS_EXCEPT=" 42a 42b 42c 42d 45 51d 68b $SANITY_EXCEPT"
13 # UPDATE THE COMMENT ABOVE WITH BUG NUMBERS WHEN CHANGING ALWAYS_EXCEPT!
15 # with LOD/OSP landing
16 # bug number for skipped tests: LU-2036
17 ALWAYS_EXCEPT=" 76 $ALWAYS_EXCEPT"
21 if [ -r /etc/SuSE-release ]
23 local vers=$(grep VERSION /etc/SuSE-release | awk '{print $3}')
24 local patchlev=$(grep PATCHLEVEL /etc/SuSE-release |
26 if [ $vers -eq 11 ] && [ $patchlev -ge 3 ]; then
33 if is_sles11; then # LU-4341
34 ALWAYS_EXCEPT="$ALWAYS_EXCEPT 170"
37 SRCDIR=$(cd $(dirname $0); echo $PWD)
38 export PATH=$PATH:/sbin
43 CHECKSTAT=${CHECKSTAT:-"checkstat -v"}
44 CREATETEST=${CREATETEST:-createtest}
46 LFIND=${LFIND:-"$LFS find"}
47 LVERIFY=${LVERIFY:-ll_dirstripe_verify}
49 OPENFILE=${OPENFILE:-openfile}
50 OPENUNLINK=${OPENUNLINK:-openunlink}
51 export MULTIOP=${MULTIOP:-multiop}
52 READS=${READS:-"reads"}
53 MUNLINK=${MUNLINK:-munlink}
54 SOCKETSERVER=${SOCKETSERVER:-socketserver}
55 SOCKETCLIENT=${SOCKETCLIENT:-socketclient}
56 MEMHOG=${MEMHOG:-memhog}
57 DIRECTIO=${DIRECTIO:-directio}
58 ACCEPTOR_PORT=${ACCEPTOR_PORT:-988}
60 CHECK_GRANT=${CHECK_GRANT:-"yes"}
61 GRANT_CHECK_LIST=${GRANT_CHECK_LIST:-""}
62 export PARALLEL=${PARALLEL:-"no"}
64 export NAME=${NAME:-local}
71 LUSTRE=${LUSTRE:-$(cd $(dirname $0)/..; echo $PWD)}
72 LUSTRE_TESTS_API_DIR=${LUSTRE_TESTS_API_DIR:-${LUSTRE}/tests/clientapi}
73 . $LUSTRE/tests/test-framework.sh
75 . ${CONFIG:=$LUSTRE/tests/cfg/${NAME}.sh}
78 [ "$SLOW" = "no" ] && EXCEPT_SLOW="24o 24D 27m 64b 68 71 77f 78 115 124b 300o"
80 if [ $(facet_fstype $SINGLEMDS) = "zfs" ]; then
81 # bug number for skipped test: LU-4536 LU-1957 LU-2805
82 ALWAYS_EXCEPT="$ALWAYS_EXCEPT 65ic 180 184c"
83 [ "$SLOW" = "no" ] && EXCEPT_SLOW="$EXCEPT_SLOW 51b 51ba"
90 pgrep ll_sa > /dev/null && { echo "There are ll_sa thread not exit!"; exit 20; }
91 cleanupall ${FORCE} $* || { echo "FAILed to clean up"; exit 20; }
100 check_swap_layouts_support()
102 $LCTL get_param -n llite.*.sbi_flags | grep -q layout ||
103 { skip "Does not support layout lock."; return 0; }
107 check_and_setup_lustre
112 MDT0=$($LCTL get_param -n mdc.*.mds_server_uuid |
113 awk '{ gsub(/_UUID/,""); print $1 }' | head -n1)
114 LOVNAME=$($LCTL get_param -n llite.*.lov.common_name | tail -n 1)
115 OSTCOUNT=$($LCTL get_param -n lov.$LOVNAME.numobd)
116 STRIPECOUNT=$($LCTL get_param -n lov.$LOVNAME.stripecount)
117 STRIPESIZE=$($LCTL get_param -n lov.$LOVNAME.stripesize)
118 ORIGFREE=$($LCTL get_param -n lov.$LOVNAME.kbytesavail)
119 MAXFREE=${MAXFREE:-$((200000 * $OSTCOUNT))}
121 [ -f $DIR/d52a/foo ] && chattr -a $DIR/d52a/foo
122 [ -f $DIR/d52b/foo ] && chattr -i $DIR/d52b/foo
123 rm -rf $DIR/[Rdfs][0-9]*
125 # $RUNAS_ID may get set incorrectly somewhere else
126 [ $UID -eq 0 -a $RUNAS_ID -eq 0 ] && error "\$RUNAS_ID set to 0, but \$UID is also 0!"
128 check_runas_id $RUNAS_ID $RUNAS_GID $RUNAS
132 if [ "${ONLY}" = "MOUNT" ] ; then
133 echo "Lustre is up, please go on"
137 echo "preparing for tests involving mounts"
138 EXT2_DEV=${EXT2_DEV:-$TMP/SANITY.LOOP}
140 mke2fs -j -F $EXT2_DEV 8000 > /dev/null
141 echo # add a newline after mke2fs.
145 OLDDEBUG=$(lctl get_param -n debug 2> /dev/null)
146 lctl set_param debug=-1 2> /dev/null || true
149 $CHECKSTAT -t file $DIR/$tfile || error "$tfile is not a file"
151 $CHECKSTAT -a $DIR/$tfile || error "$tfile was not removed"
153 run_test 0a "touch; rm ====================="
156 chmod 0755 $DIR || error "chmod 0755 $DIR failed"
157 $CHECKSTAT -p 0755 $DIR || error "$DIR permission is not 0755"
159 run_test 0b "chmod 0755 $DIR ============================="
162 $LCTL get_param mdc.*.import | grep "state: FULL" ||
163 error "import not FULL"
164 $LCTL get_param mdc.*.import | grep "target: $FSNAME-MDT" ||
167 run_test 0c "check import proc ============================="
170 test_mkdir -p $DIR/$tdir || error "mkdir $tdir failed"
171 test_mkdir -p $DIR/$tdir/d2 || error "mkdir $tdir/d2 failed"
172 test_mkdir $DIR/$tdir/d2 && error "we expect EEXIST, but not returned"
173 $CHECKSTAT -t dir $DIR/$tdir/d2 || error "$tdir/d2 is not a dir"
176 $CHECKSTAT -a $DIR/$tdir || error "$tdir was not removed"
178 run_test 1 "mkdir; remkdir; rmdir =============================="
181 test_mkdir -p $DIR/$tdir || error "mkdir $tdir failed"
182 touch $DIR/$tdir/$tfile || error "touch $tdir/$tfile failed"
183 $CHECKSTAT -t file $DIR/$tdir/$tfile || error "$tdir/$tfile not a file"
185 $CHECKSTAT -a $DIR/$tdir/$tfile || error "$tdir/$file is not removed"
187 run_test 2 "mkdir; touch; rmdir; check file ===================="
190 test_mkdir -p $DIR/$tdir || error "mkdir $tdir failed"
191 $CHECKSTAT -t dir $DIR/$tdir || error "$tdir is not a directory"
192 touch $DIR/$tdir/$tfile
193 $CHECKSTAT -t file $DIR/$tdir/$tfile || error "$tdir/$tfile not a file"
195 $CHECKSTAT -a $DIR/$tdir || error "$tdir is not removed"
197 run_test 3 "mkdir; touch; rmdir; check dir ====================="
199 # LU-4471 - failed rmdir on remote directories still removes directory on MDT0
203 test_mkdir $DIR/$tdir ||
204 error "Create remote directory failed"
206 touch $DIR/$tdir/$tfile ||
207 error "Create file under remote directory failed"
210 error "Expect error removing in-use dir $DIR/$tdir"
212 test -d $DIR/$tdir || error "Remote directory disappeared"
214 rm -rf $DIR/$tdir || error "remove remote dir error"
216 run_test 4 "mkdir; touch dir/file; rmdir; checkdir (expect error)"
219 test_mkdir -p $DIR/$tdir || error "mkdir $tdir failed"
220 test_mkdir $DIR/$tdir/d2 || error "mkdir $tdir/d2 failed"
221 chmod 0707 $DIR/$tdir/d2 || error "chmod 0707 $tdir/d2 failed"
222 $CHECKSTAT -t dir -p 0707 $DIR/$tdir/d2 || error "$tdir/d2 not mode 707"
223 $CHECKSTAT -t dir $DIR/$tdir/d2 || error "$tdir/d2 is not a directory"
225 run_test 5 "mkdir .../d5 .../d5/d2; chmod .../d5/d2 ============"
228 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
229 chmod 0666 $DIR/$tfile || error "chmod 0666 $tfile failed"
230 $CHECKSTAT -t file -p 0666 -u \#$UID $DIR/$tfile ||
231 error "$tfile does not have perm 0666 or UID $UID"
232 $RUNAS chmod 0444 $DIR/$tfile && error "chmod $tfile worked on UID $UID"
233 $CHECKSTAT -t file -p 0666 -u \#$UID $DIR/$tfile ||
234 error "$tfile should be 0666 and owned by UID $UID"
236 run_test 6a "touch f6a; chmod f6a; $RUNAS chmod f6a (should return error) =="
239 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID" && return
241 chown $RUNAS_ID $DIR/$tfile || error "chown $RUNAS_ID $file failed"
242 $CHECKSTAT -t file -u \#$RUNAS_ID $DIR/$tfile ||
243 error "$tfile should be owned by UID $RUNAS_ID"
244 $RUNAS chown $UID $DIR/$tfile && error "chown $UID $file succeeded"
245 $CHECKSTAT -t file -u \#$RUNAS_ID $DIR/$tfile ||
246 error "$tfile should be owned by UID $RUNAS_ID"
248 run_test 6c "touch f6c; chown f6c; $RUNAS chown f6c (should return error) =="
251 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID" && return
253 chgrp $RUNAS_ID $DIR/$tfile || error "chgrp $RUNAS_ID $file failed"
254 $CHECKSTAT -t file -u \#$UID -g \#$RUNAS_ID $DIR/$tfile ||
255 error "$tfile should be owned by GID $UID"
256 $RUNAS chgrp $UID $DIR/$tfile && error "chgrp $UID $file succeeded"
257 $CHECKSTAT -t file -u \#$UID -g \#$RUNAS_ID $DIR/$tfile ||
258 error "$tfile should be owned by UID $UID and GID $RUNAS_ID"
260 run_test 6e "touch f6e; chgrp f6e; $RUNAS chgrp f6e (should return error) =="
263 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID" && return
264 test_mkdir $DIR/$tdir || error "mkdir $tfile failed"
265 chmod 777 $DIR/$tdir || error "chmod 0777 $tdir failed"
266 $RUNAS mkdir $DIR/$tdir/d || error "mkdir $tdir/d failed"
267 chmod g+s $DIR/$tdir/d || error "chmod g+s $tdir/d failed"
268 test_mkdir $DIR/$tdir/d/subdir || error "mkdir $tdir/d/subdir failed"
269 $CHECKSTAT -g \#$RUNAS_GID $DIR/$tdir/d/subdir ||
270 error "$tdir/d/subdir should be GID $RUNAS_GID"
272 run_test 6g "Is new dir in sgid dir inheriting group?"
274 test_6h() { # bug 7331
275 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID" && return
276 touch $DIR/$tfile || error "touch failed"
277 chown $RUNAS_ID:$RUNAS_GID $DIR/$tfile || error "initial chown failed"
278 $RUNAS -G$RUNAS_GID chown $RUNAS_ID:0 $DIR/$tfile &&
279 error "chown $RUNAS_ID:0 $tfile worked as GID $RUNAS_GID"
280 $CHECKSTAT -t file -u \#$RUNAS_ID -g \#$RUNAS_GID $DIR/$tfile ||
281 error "$tdir/$tfile should be UID $RUNAS_UID GID $RUNAS_GID"
283 run_test 6h "$RUNAS chown RUNAS_ID.0 .../f6h (should return error)"
286 test_mkdir $DIR/$tdir
287 $MCREATE $DIR/$tdir/$tfile
288 chmod 0666 $DIR/$tdir/$tfile
289 $CHECKSTAT -t file -p 0666 $DIR/$tdir/$tfile ||
290 error "$tdir/$tfile should be mode 0666"
292 run_test 7a "mkdir .../d7; mcreate .../d7/f; chmod .../d7/f ===="
295 if [ ! -d $DIR/$tdir ]; then
296 test_mkdir $DIR/$tdir
298 $MCREATE $DIR/$tdir/$tfile
299 echo -n foo > $DIR/$tdir/$tfile
300 [ "$(cat $DIR/$tdir/$tfile)" = "foo" ] || error "$tdir/$tfile not 'foo'"
301 $CHECKSTAT -t file -s 3 $DIR/$tdir/$tfile || error "$tfile size not 3"
303 run_test 7b "mkdir .../d7; mcreate d7/f2; echo foo > d7/f2 ====="
306 test_mkdir $DIR/$tdir
307 touch $DIR/$tdir/$tfile
308 chmod 0666 $DIR/$tdir/$tfile
309 $CHECKSTAT -t file -p 0666 $DIR/$tdir/$tfile ||
310 error "$tfile mode not 0666"
312 run_test 8 "mkdir .../d8; touch .../d8/f; chmod .../d8/f ======="
315 test_mkdir $DIR/$tdir
316 test_mkdir $DIR/$tdir/d2
317 test_mkdir $DIR/$tdir/d2/d3
318 $CHECKSTAT -t dir $DIR/$tdir/d2/d3 || error "$tdir/d2/d3 not a dir"
320 run_test 9 "mkdir .../d9 .../d9/d2 .../d9/d2/d3 ================"
323 test_mkdir $DIR/$tdir
324 test_mkdir $DIR/$tdir/d2
325 touch $DIR/$tdir/d2/$tfile
326 $CHECKSTAT -t file $DIR/$tdir/d2/$tfile ||
327 error "$tdir/d2/$tfile not a file"
329 run_test 10 "mkdir .../d10 .../d10/d2; touch .../d10/d2/f ======"
332 test_mkdir $DIR/$tdir
333 test_mkdir $DIR/$tdir/d2
334 chmod 0666 $DIR/$tdir/d2
335 chmod 0705 $DIR/$tdir/d2
336 $CHECKSTAT -t dir -p 0705 $DIR/$tdir/d2 ||
337 error "$tdir/d2 mode not 0705"
339 run_test 11 "mkdir .../d11 d11/d2; chmod .../d11/d2 ============"
342 test_mkdir $DIR/$tdir
343 touch $DIR/$tdir/$tfile
344 chmod 0666 $DIR/$tdir/$tfile
345 chmod 0654 $DIR/$tdir/$tfile
346 $CHECKSTAT -t file -p 0654 $DIR/$tdir/$tfile ||
347 error "$tdir/d2 mode not 0654"
349 run_test 12 "touch .../d12/f; chmod .../d12/f .../d12/f ========"
352 test_mkdir $DIR/$tdir
353 dd if=/dev/zero of=$DIR/$tdir/$tfile count=10
355 $CHECKSTAT -t file -s 0 $DIR/$tdir/$tfile ||
356 error "$tdir/$tfile size not 0 after truncate"
358 run_test 13 "creat .../d13/f; dd .../d13/f; > .../d13/f ========"
361 test_mkdir $DIR/$tdir
362 touch $DIR/$tdir/$tfile
364 $CHECKSTAT -a $DIR/$tdir/$tfile || error "$tdir/$tfile not removed"
366 run_test 14 "touch .../d14/f; rm .../d14/f; rm .../d14/f ======="
369 test_mkdir $DIR/$tdir
370 touch $DIR/$tdir/$tfile
371 mv $DIR/$tdir/$tfile $DIR/$tdir/${tfile}_2
372 $CHECKSTAT -t file $DIR/$tdir/${tfile}_2 ||
373 error "$tdir/${tfile_2} not a file after rename"
374 rm $DIR/$tdir/${tfile}_2 || error "unlink failed after rename"
376 run_test 15 "touch .../d15/f; mv .../d15/f .../d15/f2 =========="
379 test_mkdir $DIR/$tdir
380 touch $DIR/$tdir/$tfile
381 rm -rf $DIR/$tdir/$tfile
382 $CHECKSTAT -a $DIR/$tdir/$tfile || error "$tdir/$tfile not removed"
384 run_test 16 "touch .../d16/f; rm -rf .../d16/f ================="
387 test_mkdir -p $DIR/$tdir
388 touch $DIR/$tdir/$tfile
389 ln -s $DIR/$tdir/$tfile $DIR/$tdir/l-exist
391 $CHECKSTAT -l $DIR/$tdir/$tfile $DIR/$tdir/l-exist ||
392 error "$tdir/l-exist not a symlink"
393 $CHECKSTAT -f -t f $DIR/$tdir/l-exist ||
394 error "$tdir/l-exist not referencing a file"
395 rm -f $DIR/$tdir/l-exist
396 $CHECKSTAT -a $DIR/$tdir/l-exist || error "$tdir/l-exist not removed"
398 run_test 17a "symlinks: create, remove (real) =================="
401 test_mkdir -p $DIR/$tdir
402 ln -s no-such-file $DIR/$tdir/l-dangle
404 $CHECKSTAT -l no-such-file $DIR/$tdir/l-dangle ||
405 error "$tdir/l-dangle not referencing no-such-file"
406 $CHECKSTAT -fa $DIR/$tdir/l-dangle ||
407 error "$tdir/l-dangle not referencing non-existent file"
408 rm -f $DIR/$tdir/l-dangle
409 $CHECKSTAT -a $DIR/$tdir/l-dangle || error "$tdir/l-dangle not removed"
411 run_test 17b "symlinks: create, remove (dangling) =============="
413 test_17c() { # bug 3440 - don't save failed open RPC for replay
414 test_mkdir -p $DIR/$tdir
415 ln -s foo $DIR/$tdir/$tfile
416 cat $DIR/$tdir/$tfile && error "opened non-existent symlink" || true
418 run_test 17c "symlinks: open dangling (should return error) ===="
421 test_mkdir -p $DIR/$tdir
422 ln -s foo $DIR/$tdir/$tfile
423 touch $DIR/$tdir/$tfile || error "creating to new symlink"
425 run_test 17d "symlinks: create dangling ========================"
428 test_mkdir -p $DIR/$tdir
429 local foo=$DIR/$tdir/$tfile
430 ln -s $foo $foo || error "create symlink failed"
431 ls -l $foo || error "ls -l failed"
432 ls $foo && error "ls not failed" || true
434 run_test 17e "symlinks: create recursive symlink (should return error) ===="
437 test_mkdir -p $DIR/$tdir
438 ln -s 1234567890/2234567890/3234567890/4234567890 $DIR/$tdir/111
439 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890 $DIR/$tdir/222
440 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890 $DIR/$tdir/333
441 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890/9234567890/a234567890/b234567890 $DIR/$tdir/444
442 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890/9234567890/a234567890/b234567890/c234567890/d234567890/f234567890 $DIR/$tdir/555
443 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890/9234567890/a234567890/b234567890/c234567890/d234567890/f234567890/aaaaaaaaaa/bbbbbbbbbb/cccccccccc/dddddddddd/eeeeeeeeee/ffffffffff/ $DIR/$tdir/666
446 run_test 17f "symlinks: long and very long symlink name ========================"
448 # str_repeat(S, N) generate a string that is string S repeated N times
453 while [ $((n -= 1)) -ge 0 ]; do
459 # Long symlinks and LU-2241
461 test_mkdir -p $DIR/$tdir
462 local TESTS="59 60 61 4094 4095"
464 # Fix for inode size boundary in 2.1.4
465 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.1.4) ] &&
468 # Patch not applied to 2.2 or 2.3 branches
469 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] &&
470 [ $(lustre_version_code $SINGLEMDS) -le $(version_code 2.3.55) ] &&
473 # skip long symlink name for rhel6.5.
474 # rhel6.5 has a limit (PATH_MAX - sizeof(struct filename))
475 grep -q '6.5' /etc/redhat-release &>/dev/null &&
476 TESTS="59 60 61 4062 4063"
479 local SYMNAME=$(str_repeat 'x' $i)
480 ln -s $SYMNAME $DIR/$tdir/f$i || error "failed $i-char symlink"
481 readlink $DIR/$tdir/f$i || error "failed $i-char readlink"
484 run_test 17g "symlinks: really long symlink name and inode boundaries"
486 test_17h() { #bug 17378
487 remote_mds_nodsh && skip "remote MDS with nodsh" && return
488 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
490 test_mkdir -p $DIR/$tdir
491 if [[ $MDSCOUNT -gt 1 ]]; then
492 mdt_idx=$($LFS getdirstripe -i $DIR/$tdir)
496 $SETSTRIPE -c -1 $DIR/$tdir
497 #define OBD_FAIL_MDS_LOV_PREP_CREATE 0x141
498 do_facet mds$((mdt_idx + 1)) lctl set_param fail_loc=0x80000141
499 touch $DIR/$tdir/$tfile || true
501 run_test 17h "create objects: lov_free_memmd() doesn't lbug"
503 test_17i() { #bug 20018
504 remote_mds_nodsh && skip "remote MDS with nodsh" && return
505 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
506 test_mkdir -c1 $DIR/$tdir
507 local foo=$DIR/$tdir/$tfile
509 if [[ $MDSCOUNT -gt 1 ]]; then
510 mdt_idx=$($LFS getdirstripe -i $DIR/$tdir)
514 ln -s $foo $foo || error "create symlink failed"
515 #define OBD_FAIL_MDS_READLINK_EPROTO 0x143
516 do_facet mds$((mdt_idx + 1)) lctl set_param fail_loc=0x80000143
517 ls -l $foo && error "error not detected"
520 run_test 17i "don't panic on short symlink"
522 test_17k() { #bug 22301
523 [[ -z "$(which rsync 2>/dev/null)" ]] &&
524 skip "no rsync command" && return 0
525 rsync --help | grep -q xattr ||
526 skip_env "$(rsync --version | head -n1) does not support xattrs"
527 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return 0
528 test_mkdir -p $DIR/$tdir
529 test_mkdir -p $DIR/$tdir.new
530 touch $DIR/$tdir/$tfile
531 ln -s $DIR/$tdir/$tfile $DIR/$tdir/$tfile.lnk
532 rsync -av -X $DIR/$tdir/ $DIR/$tdir.new ||
533 error "rsync failed with xattrs enabled"
535 run_test 17k "symlinks: rsync with xattrs enabled ========================="
537 test_17l() { # LU-279
538 [[ -z "$(which getfattr 2>/dev/null)" ]] &&
539 skip "no getfattr command" && return 0
540 test_mkdir -p $DIR/$tdir
541 touch $DIR/$tdir/$tfile
542 ln -s $DIR/$tdir/$tfile $DIR/$tdir/$tfile.lnk
543 for path in "$DIR/$tdir" "$DIR/$tdir/$tfile" "$DIR/$tdir/$tfile.lnk"; do
544 # -h to not follow symlinks. -m '' to list all the xattrs.
545 # grep to remove first line: '# file: $path'.
546 for xattr in `getfattr -hm '' $path 2>/dev/null | grep -v '^#'`;
548 lgetxattr_size_check $path $xattr ||
549 error "lgetxattr_size_check $path $xattr failed"
553 run_test 17l "Ensure lgetxattr's returned xattr size is consistent ========"
557 local short_sym="0123456789"
558 local WDIR=$DIR/${tdir}m
561 remote_mds_nodsh && skip "remote MDS with nodsh" && return
562 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] &&
563 [ $(lustre_version_code $SINGLEMDS) -le $(version_code 2.2.93) ] &&
564 skip "MDS 2.2.0-2.2.93 do not NUL-terminate symlinks" && return
566 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
567 skip "only for ldiskfs MDT" && return 0
569 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
573 # create a long symlink file
574 for ((i = 0; i < 4; ++i)); do
575 long_sym=${long_sym}${long_sym}
578 echo "create 512 short and long symlink files under $WDIR"
579 for ((i = 0; i < 256; ++i)); do
580 ln -sf ${long_sym}"a5a5" $WDIR/long-$i
581 ln -sf ${short_sym}"a5a5" $WDIR/short-$i
587 wait_delete_completed
589 echo "recreate the 512 symlink files with a shorter string"
590 for ((i = 0; i < 512; ++i)); do
591 # rewrite the symlink file with a shorter string
592 ln -sf ${long_sym} $WDIR/long-$i || error "long_sym failed"
593 ln -sf ${short_sym} $WDIR/short-$i || error "short_sym failed"
596 local mds_index=$(($($LFS getstripe -M $WDIR) + 1))
597 local devname=$(mdsdevname $mds_index)
599 echo "stop and checking mds${mds_index}:"
600 # e2fsck should not return error
602 run_e2fsck $(facet_active_host mds${mds_index}) $devname -n
605 start mds${mds_index} $devname $MDS_MOUNT_OPTS || error "start failed"
606 df $MOUNT > /dev/null 2>&1
608 error "e2fsck detected error for short/long symlink: rc=$rc"
610 run_test 17m "run e2fsck against MDT which contains short/long symlink"
612 check_fs_consistency_17n() {
616 # create/unlink in 17n only change 2 MDTs(MDT1/MDT2),
617 # so it only check MDT1/MDT2 instead of all of MDTs.
618 for mdt_index in 1 2; do
619 local devname=$(mdsdevname $mdt_index)
620 # e2fsck should not return error
622 run_e2fsck $(facet_active_host mds$mdt_index) $devname -n ||
625 start mds${mdt_index} $devname $MDS_MOUNT_OPTS ||
626 error "mount mds$mdt_index failed"
627 df $MOUNT > /dev/null 2>&1
635 remote_mds_nodsh && skip "remote MDS with nodsh" && return
636 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] &&
637 [ $(lustre_version_code $SINGLEMDS) -le $(version_code 2.2.93) ] &&
638 skip "MDS 2.2.0-2.2.93 do not NUL-terminate symlinks" && return
640 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
641 skip "only for ldiskfs MDT" && return 0
643 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 2 MDTs" && return
645 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
647 test_mkdir $DIR/$tdir
648 for ((i=0; i<10; i++)); do
649 $LFS mkdir -i1 -c2 $DIR/$tdir/remote_dir_${i} ||
650 error "create remote dir error $i"
651 createmany -o $DIR/$tdir/remote_dir_${i}/f 10 ||
652 error "create files under remote dir failed $i"
655 check_fs_consistency_17n ||
656 error "e2fsck report error after create files under remote dir"
658 for ((i = 0; i < 10; i++)); do
659 rm -rf $DIR/$tdir/remote_dir_${i} ||
660 error "destroy remote dir error $i"
663 check_fs_consistency_17n ||
664 error "e2fsck report error after unlink files under remote dir"
666 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.50) ] &&
667 skip "lustre < 2.4.50 does not support migrate mv " && return
669 for ((i = 0; i < 10; i++)); do
670 mkdir -p $DIR/$tdir/remote_dir_${i}
671 createmany -o $DIR/$tdir/remote_dir_${i}/f 10 ||
672 error "create files under remote dir failed $i"
673 $LFS migrate --mdt-index 1 $DIR/$tdir/remote_dir_${i} ||
674 error "migrate remote dir error $i"
676 check_fs_consistency_17n || error "e2fsck report error after migration"
678 for ((i = 0; i < 10; i++)); do
679 rm -rf $DIR/$tdir/remote_dir_${i} ||
680 error "destroy remote dir error $i"
683 check_fs_consistency_17n || error "e2fsck report error after unlink"
685 run_test 17n "run e2fsck against master/slave MDT which contains remote dir"
688 remote_mds_nodsh && skip "remote MDS with nodsh" && return
689 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.3.64) ] &&
690 skip "Need MDS version at least 2.3.64" && return
692 local WDIR=$DIR/${tdir}o
697 mdt_index=$($LFS getstripe -M $WDIR)
698 mdt_index=$((mdt_index+1))
702 #fail mds will wait the failover finish then set
703 #following fail_loc to avoid interfer the recovery process.
706 #define OBD_FAIL_OSD_LMA_INCOMPAT 0x194
707 do_facet mds${mdt_index} lctl set_param fail_loc=0x194
708 ls -l $WDIR/$tfile && rc=1
709 do_facet mds${mdt_index} lctl set_param fail_loc=0
710 [[ $rc -ne 0 ]] && error "stat file should fail"
713 run_test 17o "stat file with incompat LMA feature"
716 touch $DIR/$tfile || error "Failed to touch $DIR/$tfile: $?"
717 ls $DIR || error "Failed to ls $DIR: $?"
719 run_test 18 "touch .../f ; ls ... =============================="
725 $CHECKSTAT -a $DIR/$tfile || error "$tfile was not removed"
727 run_test 19a "touch .../f19 ; ls -l ... ; rm .../f19 ==========="
730 ls -l $DIR/$tfile && error "ls -l $tfile failed"|| true
732 run_test 19b "ls -l .../f19 (should return error) =============="
735 [ $RUNAS_ID -eq $UID ] &&
736 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
737 $RUNAS touch $DIR/$tfile && error "create non-root file failed" || true
739 run_test 19c "$RUNAS touch .../f19 (should return error) =="
742 cat $DIR/f19 && error || true
744 run_test 19d "cat .../f19 (should return error) =============="
756 $CHECKSTAT -a $DIR/$tfile || error "$tfile was not removed"
758 run_test 20 "touch .../f ; ls -l ... ==========================="
761 test_mkdir -p $DIR/$tdir
762 [ -f $DIR/$tdir/dangle ] && rm -f $DIR/$tdir/dangle
763 ln -s dangle $DIR/$tdir/link
764 echo foo >> $DIR/$tdir/link
765 cat $DIR/$tdir/dangle
766 $CHECKSTAT -t link $DIR/$tdir/link || error "$tdir/link not a link"
767 $CHECKSTAT -f -t file $DIR/$tdir/link ||
768 error "$tdir/link not linked to a file"
770 run_test 21 "write to dangling link ============================"
774 test_mkdir -p $DIR/$tdir
775 chown $RUNAS_ID:$RUNAS_GID $WDIR
776 (cd $WDIR || error "cd $WDIR failed";
777 $RUNAS tar cf - /etc/hosts /etc/sysconfig/network | \
779 ls -lR $WDIR/etc || error "ls -lR $WDIR/etc failed"
780 $CHECKSTAT -t dir $WDIR/etc || error "checkstat -t dir failed"
781 $CHECKSTAT -u \#$RUNAS_ID -g \#$RUNAS_GID $WDIR/etc || error "checkstat -u failed"
783 run_test 22 "unpack tar archive as non-root user ==============="
787 test_mkdir -p $DIR/$tdir
788 local file=$DIR/$tdir/$tfile
790 openfile -f O_CREAT:O_EXCL $file || error "$file create failed"
791 openfile -f O_CREAT:O_EXCL $file &&
792 error "$file recreate succeeded" || true
794 run_test 23a "O_CREAT|O_EXCL in subdir =========================="
796 test_23b() { # bug 18988
797 test_mkdir -p $DIR/$tdir
798 local file=$DIR/$tdir/$tfile
801 echo foo > $file || error "write filed"
802 echo bar >> $file || error "append filed"
803 $CHECKSTAT -s 8 $file || error "wrong size"
806 run_test 23b "O_APPEND check =========================="
810 echo '-- same directory rename'
811 test_mkdir $DIR/$tdir
812 touch $DIR/$tdir/$tfile.1
813 mv $DIR/$tdir/$tfile.1 $DIR/$tdir/$tfile.2
814 $CHECKSTAT -t file $DIR/$tdir/$tfile.2 || error "$tfile.2 not a file"
816 run_test 24a "rename file to non-existent target"
819 test_mkdir $DIR/$tdir
820 touch $DIR/$tdir/$tfile.{1,2}
821 mv $DIR/$tdir/$tfile.1 $DIR/$tdir/$tfile.2
822 $CHECKSTAT -a $DIR/$tdir/$tfile.1 || error "$tfile.1 exists"
823 $CHECKSTAT -t file $DIR/$tdir/$tfile.2 || error "$tfile.2 not a file"
825 run_test 24b "rename file to existing target"
828 test_mkdir $DIR/$tdir
829 test_mkdir $DIR/$tdir/d$testnum.1
830 mv $DIR/$tdir/d$testnum.1 $DIR/$tdir/d$testnum.2
831 $CHECKSTAT -a $DIR/$tdir/d$testnum.1 || error "d$testnum.1 exists"
832 $CHECKSTAT -t dir $DIR/$tdir/d$testnum.2 || error "d$testnum.2 not dir"
834 run_test 24c "rename directory to non-existent target"
837 test_mkdir -c1 $DIR/$tdir
838 test_mkdir -c1 $DIR/$tdir/d$testnum.1
839 test_mkdir -c1 $DIR/$tdir/d$testnum.2
840 mrename $DIR/$tdir/d$testnum.1 $DIR/$tdir/d$testnum.2
841 $CHECKSTAT -a $DIR/$tdir/d$testnum.1 || error "d$testnum.1 exists"
842 $CHECKSTAT -t dir $DIR/$tdir/d$testnum.2 || error "d$testnum.2 not dir"
844 run_test 24d "rename directory to existing target"
847 echo '-- cross directory renames --'
851 mv $DIR/R5a/f $DIR/R5b/g
852 $CHECKSTAT -a $DIR/R5a/f || error
853 $CHECKSTAT -t file $DIR/R5b/g || error
855 run_test 24e "touch .../R5a/f; rename .../R5a/f .../R5b/g ======"
860 touch $DIR/R6a/f $DIR/R6b/g
861 mv $DIR/R6a/f $DIR/R6b/g
862 $CHECKSTAT -a $DIR/R6a/f || error
863 $CHECKSTAT -t file $DIR/R6b/g || error
865 run_test 24f "touch .../R6a/f R6b/g; mv .../R6a/f .../R6b/g ===="
870 test_mkdir $DIR/R7a/d
871 mv $DIR/R7a/d $DIR/R7b/e
872 $CHECKSTAT -a $DIR/R7a/d || error
873 $CHECKSTAT -t dir $DIR/R7b/e || error
875 run_test 24g "mkdir .../R7{a,b}/d; mv .../R7a/d .../R7b/e ======"
878 test_mkdir -c1 $DIR/R8a
879 test_mkdir -c1 $DIR/R8b
880 test_mkdir -c1 $DIR/R8a/d
881 test_mkdir -c1 $DIR/R8b/e
882 mrename $DIR/R8a/d $DIR/R8b/e
883 $CHECKSTAT -a $DIR/R8a/d || error
884 $CHECKSTAT -t dir $DIR/R8b/e || error
886 run_test 24h "mkdir .../R8{a,b}/{d,e}; rename .../R8a/d .../R8b/e"
889 echo "-- rename error cases"
893 mrename $DIR/R9/f $DIR/R9/a
894 $CHECKSTAT -t file $DIR/R9/f || error
895 $CHECKSTAT -t dir $DIR/R9/a || error
896 $CHECKSTAT -a $DIR/R9/a/f || error
898 run_test 24i "rename file to dir error: touch f ; mkdir a ; rename f a"
902 mrename $DIR/R10/f $DIR/R10/g
903 $CHECKSTAT -t dir $DIR/R10 || error
904 $CHECKSTAT -a $DIR/R10/f || error
905 $CHECKSTAT -a $DIR/R10/g || error
907 run_test 24j "source does not exist ============================"
911 test_mkdir $DIR/R11a/d
913 mv $DIR/R11a/f $DIR/R11a/d
914 $CHECKSTAT -a $DIR/R11a/f || error
915 $CHECKSTAT -t file $DIR/R11a/d/f || error
917 run_test 24k "touch .../R11a/f; mv .../R11a/f .../R11a/d ======="
919 # bug 2429 - rename foo foo foo creates invalid file
922 $MULTIOP $f OcNs || error
924 run_test 24l "Renaming a file to itself ========================"
928 $MULTIOP $f OcLN ${f}2 ${f}2 || error "link ${f}2 ${f}2 failed"
929 # on ext3 this does not remove either the source or target files
930 # though the "expected" operation would be to remove the source
931 $CHECKSTAT -t file ${f} || error "${f} missing"
932 $CHECKSTAT -t file ${f}2 || error "${f}2 missing"
934 run_test 24m "Renaming a file to a hard link to itself ========="
938 # this stats the old file after it was renamed, so it should fail
942 $CHECKSTAT ${f}.rename
945 run_test 24n "Statting the old file after renaming (Posix rename 2)"
948 test_mkdir -p $DIR/d24o
949 rename_many -s random -v -n 10 $DIR/d24o
951 run_test 24o "rename of files during htree split ==============="
956 DIRINO=`ls -lid $DIR/R12a | awk '{ print $1 }'`
957 mrename $DIR/R12a $DIR/R12b
958 $CHECKSTAT -a $DIR/R12a || error
959 $CHECKSTAT -t dir $DIR/R12b || error
960 DIRINO2=`ls -lid $DIR/R12b | awk '{ print $1 }'`
961 [ "$DIRINO" = "$DIRINO2" ] || error "R12a $DIRINO != R12b $DIRINO2"
963 run_test 24p "mkdir .../R12{a,b}; rename .../R12a .../R12b"
965 cleanup_multiop_pause() {
971 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
974 local DIRINO=$(ls -lid $DIR/R13a | awk '{ print $1 }')
975 multiop_bg_pause $DIR/R13b D_c || error "multiop failed to start"
978 trap cleanup_multiop_pause EXIT
979 mrename $DIR/R13a $DIR/R13b
980 $CHECKSTAT -a $DIR/R13a || error "R13a still exists"
981 $CHECKSTAT -t dir $DIR/R13b || error "R13b does not exist"
982 local DIRINO2=$(ls -lid $DIR/R13b | awk '{ print $1 }')
983 [ "$DIRINO" = "$DIRINO2" ] || error "R13a $DIRINO != R13b $DIRINO2"
984 cleanup_multiop_pause
985 wait $MULTIPID || error "multiop close failed"
987 run_test 24q "mkdir .../R13{a,b}; open R13b rename R13a R13b ==="
989 test_24r() { #bug 3789
991 test_mkdir $DIR/R14a/b
992 mrename $DIR/R14a $DIR/R14a/b && error "rename to subdir worked!"
993 $CHECKSTAT -t dir $DIR/R14a || error "$DIR/R14a missing"
994 $CHECKSTAT -t dir $DIR/R14a/b || error "$DIR/R14a/b missing"
996 run_test 24r "mkdir .../R14a/b; rename .../R14a .../R14a/b ====="
1000 test_mkdir $DIR/R15a/b
1001 test_mkdir $DIR/R15a/b/c
1002 mrename $DIR/R15a $DIR/R15a/b/c && error "rename to sub-subdir worked!"
1003 $CHECKSTAT -t dir $DIR/R15a || error "$DIR/R15a missing"
1004 $CHECKSTAT -t dir $DIR/R15a/b/c || error "$DIR/R15a/b/c missing"
1006 run_test 24s "mkdir .../R15a/b/c; rename .../R15a .../R15a/b/c ="
1008 test_mkdir $DIR/R16a
1009 test_mkdir $DIR/R16a/b
1010 test_mkdir $DIR/R16a/b/c
1011 mrename $DIR/R16a/b/c $DIR/R16a && error "rename to sub-subdir worked!"
1012 $CHECKSTAT -t dir $DIR/R16a || error "$DIR/R16a missing"
1013 $CHECKSTAT -t dir $DIR/R16a/b/c || error "$DIR/R16a/b/c missing"
1015 run_test 24t "mkdir .../R16a/b/c; rename .../R16a/b/c .../R16a ="
1017 test_24u() { # bug12192
1018 $MULTIOP $DIR/$tfile C2w$((2048 * 1024))c || error
1019 $CHECKSTAT -s $((2048 * 1024)) $DIR/$tfile || error "wrong file size"
1021 run_test 24u "create stripe file"
1027 simple_cleanup_common() {
1030 wait_delete_completed
1033 max_pages_per_rpc() {
1034 $LCTL get_param -n mdc.*.max_pages_per_rpc | head -n1
1038 local NRFILES=100000
1039 local FREE_INODES=$(mdt_free_inodes 0)
1040 [[ $FREE_INODES -lt $NRFILES ]] &&
1041 skip "not enough free inodes $FREE_INODES required $NRFILES" &&
1044 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1045 trap simple_cleanup_common EXIT
1047 # Performance issue on ZFS see LU-4072 (c.f. LU-2887)
1048 [ $(facet_fstype $SINGLEMDS) = "zfs" ] && NRFILES=10000
1050 test_mkdir -p $DIR/$tdir
1051 createmany -m $DIR/$tdir/$tfile $NRFILES
1053 cancel_lru_locks mdc
1054 lctl set_param mdc.*.stats clear
1056 ls $DIR/$tdir >/dev/null || error "error in listing large dir"
1058 # LU-5 large readdir
1059 # DIRENT_SIZE = 32 bytes for sizeof(struct lu_dirent) +
1060 # 8 bytes for name(filename is mostly 5 in this test) +
1061 # 8 bytes for luda_type
1062 # take into account of overhead in lu_dirpage header and end mark in
1063 # each page, plus one in RPC_NUM calculation.
1065 RPC_SIZE=$(($(max_pages_per_rpc) * $(page_size)))
1066 RPC_NUM=$(((NRFILES * DIRENT_SIZE + RPC_SIZE - 1) / RPC_SIZE + 1))
1067 mds_readpage=$(lctl get_param mdc.*MDT0000*.stats |
1068 awk '/^mds_readpage/ {print $2}')
1069 [[ $mds_readpage -gt $RPC_NUM ]] &&
1070 error "large readdir doesn't take effect"
1072 simple_cleanup_common
1074 run_test 24v "list directory with large files (handle hash collision, bug: 17560)"
1076 test_24w() { # bug21506
1078 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=4096 || return 1
1079 dd if=/dev/zero bs=$SZ1 count=1 >> $DIR/$tfile || return 2
1080 dd if=$DIR/$tfile of=$DIR/${tfile}_left bs=1M skip=4097 || return 3
1081 SZ2=`ls -l $DIR/${tfile}_left | awk '{print $5}'`
1082 [[ "$SZ1" -eq "$SZ2" ]] ||
1083 error "Error reading at the end of the file $tfile"
1085 run_test 24w "Reading a file larger than 4Gb"
1088 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 2 MDTs" && return
1089 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1091 local remote_dir=$DIR/$tdir/remote_dir
1093 test_mkdir -p $DIR/$tdir
1094 $LFS mkdir -i $MDTIDX $remote_dir ||
1095 error "create remote directory failed"
1097 test_mkdir -p $DIR/$tdir/src_dir
1098 touch $DIR/$tdir/src_file
1099 test_mkdir -p $remote_dir/tgt_dir
1100 touch $remote_dir/tgt_file
1102 mrename $DIR/$tdir/src_dir $remote_dir/tgt_dir ||
1103 error "rename dir cross MDT failed!"
1105 mrename $DIR/$tdir/src_file $remote_dir/tgt_file ||
1106 error "rename file cross MDT failed!"
1108 touch $DIR/$tdir/ln_file
1109 ln $DIR/$tdir/ln_file $remote_dir/ln_name ||
1110 error "ln file cross MDT failed"
1112 rm -rf $DIR/$tdir || error "Can not delete directories"
1114 run_test 24x "cross MDT rename/link"
1117 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 2 MDTs" && return
1118 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1120 local remote_dir=$DIR/$tdir/remote_dir
1122 test_mkdir -p $DIR/$tdir
1123 $LFS mkdir -i $MDTIDX $remote_dir ||
1124 error "create remote directory failed"
1126 test_mkdir -p $remote_dir/src_dir
1127 touch $remote_dir/src_file
1128 test_mkdir -p $remote_dir/tgt_dir
1129 touch $remote_dir/tgt_file
1131 mrename $remote_dir/src_dir $remote_dir/tgt_dir ||
1132 error "rename subdir in the same remote dir failed!"
1134 mrename $remote_dir/src_file $remote_dir/tgt_file ||
1135 error "rename files in the same remote dir failed!"
1137 ln $remote_dir/tgt_file $remote_dir/tgt_file1 ||
1138 error "link files in the same remote dir failed!"
1140 rm -rf $DIR/$tdir || error "Can not delete directories"
1142 run_test 24y "rename/link on the same dir should succeed"
1144 test_24A() { # LU-3182
1148 test_mkdir -p $DIR/$tdir
1149 createmany -m $DIR/$tdir/$tfile $NFILES
1150 local t=$(ls $DIR/$tdir | wc -l)
1151 local u=$(ls $DIR/$tdir | sort -u | wc -l)
1152 local v=$(ls -ai $DIR/$tdir | sort -u | wc -l)
1153 if [ $t -ne $NFILES -o $u -ne $NFILES -o $v -ne $((NFILES + 2)) ] ; then
1154 error "Expected $NFILES files, got $t ($u unique $v .&..)"
1157 rm -rf $DIR/$tdir || error "Can not delete directories"
1159 run_test 24A "readdir() returns correct number of entries."
1161 test_24B() { # LU-4805
1162 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
1165 test_mkdir $DIR/$tdir
1166 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR/$tdir/striped_dir ||
1167 error "create striped dir failed"
1169 count=$(ls -ai $DIR/$tdir/striped_dir | wc -l)
1170 [ $count -eq 2 ] || error "Expected 2, got $count"
1172 touch $DIR/$tdir/striped_dir/a
1174 count=$(ls -ai $DIR/$tdir/striped_dir | wc -l)
1175 [ $count -eq 3 ] || error "Expected 3, got $count"
1177 touch $DIR/$tdir/striped_dir/.f
1179 count=$(ls -ai $DIR/$tdir/striped_dir | wc -l)
1180 [ $count -eq 4 ] || error "Expected 4, got $count"
1182 rm -rf $DIR/$tdir || error "Can not delete directories"
1184 run_test 24B "readdir for striped dir return correct number of entries"
1187 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
1193 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR/$tdir/d0/striped_dir ||
1194 error "create striped dir failed"
1196 cd $DIR/$tdir/d0/striped_dir
1198 local d0_ino=$(ls -i -l -a $DIR/$tdir | grep "d0" | awk '{print $1}')
1199 local d1_ino=$(ls -i -l -a $DIR/$tdir | grep "d1" | awk '{print $1}')
1200 local parent_ino=$(ls -i -l -a | grep "\.\." | awk '{print $1}')
1202 [ "$d0_ino" = "$parent_ino" ] ||
1203 error ".. wrong, expect $d0_ino, get $parent_ino"
1205 mv $DIR/$tdir/d0/striped_dir $DIR/$tdir/d1/ ||
1206 error "mv striped dir failed"
1208 parent_ino=$(ls -i -l -a | grep "\.\." | awk '{print $1}')
1210 [ "$d1_ino" = "$parent_ino" ] ||
1211 error ".. wrong after mv, expect $d1_ino, get $parent_ino"
1213 run_test 24C "check .. in striped dir"
1215 test_24D() { # LU-6101
1220 createmany -m $DIR/$tdir/$tfile $NFILES
1221 local t=$(ls $DIR/$tdir | wc -l)
1222 local u=$(ls $DIR/$tdir | sort -u | wc -l)
1223 local v=$(ls -ai $DIR/$tdir | sort -u | wc -l)
1224 if [ $t -ne $NFILES -o $u -ne $NFILES -o $v -ne $((NFILES + 2)) ] ; then
1225 error "Expected $NFILES files, got $t ($u unique $v .&..)"
1228 rm -rf $DIR/$tdir || error "Can not delete directories"
1230 run_test 24D "readdir() returns correct number of entries after cursor reload"
1233 [[ $MDSCOUNT -lt 4 ]] && skip "needs >= 4 MDTs" && return
1234 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1237 mkdir $DIR/$tdir/src_dir
1238 $LFS mkdir -i 1 $DIR/$tdir/src_dir/src_child ||
1239 error "create remote source failed"
1241 touch $DIR/$tdir/src_dir/src_child/a
1243 $LFS mkdir -i 2 $DIR/$tdir/tgt_dir ||
1244 error "create remote target dir failed"
1246 $LFS mkdir -i 3 $DIR/$tdir/tgt_dir/tgt_child ||
1247 error "create remote target child failed"
1249 mrename $DIR/$tdir/src_dir/src_child $DIR/$tdir/tgt_dir/tgt_child ||
1250 error "rename dir cross MDT failed!"
1254 $CHECKSTAT -t dir $DIR/$tdir/src_dir/src_child &&
1255 error "src_child still exists after rename"
1257 $CHECKSTAT -t file $DIR/$tdir/tgt_dir/tgt_child/a ||
1258 error "missing file(a) after rename"
1260 rm -rf $DIR/$tdir || error "Can not delete directories"
1262 run_test 24E "cross MDT rename/link"
1265 echo '== symlink sanity ============================================='
1269 touch $DIR/s25/foo || error
1271 run_test 25a "create file in symlinked directory ==============="
1274 [ ! -d $DIR/d25 ] && test_25a
1275 $CHECKSTAT -t file $DIR/s25/foo || error
1277 run_test 25b "lookup file in symlinked directory ==============="
1281 test_mkdir $DIR/d26/d26-2
1282 ln -s d26/d26-2 $DIR/s26
1283 touch $DIR/s26/foo || error
1285 run_test 26a "multiple component symlink ======================="
1288 test_mkdir -p $DIR/d26b/d26-2
1289 ln -s d26b/d26-2/foo $DIR/s26-2
1290 touch $DIR/s26-2 || error
1292 run_test 26b "multiple component symlink at end of lookup ======"
1295 test_mkdir $DIR/d26.2
1296 touch $DIR/d26.2/foo
1297 ln -s d26.2 $DIR/s26.2-1
1298 ln -s s26.2-1 $DIR/s26.2-2
1299 ln -s s26.2-2 $DIR/s26.2-3
1300 chmod 0666 $DIR/s26.2-3/foo
1302 run_test 26c "chain of symlinks ================================"
1304 # recursive symlinks (bug 439)
1306 ln -s d26-3/foo $DIR/d26-3
1308 run_test 26d "create multiple component recursive symlink ======"
1311 [ ! -h $DIR/d26-3 ] && test_26d
1314 run_test 26e "unlink multiple component recursive symlink ======"
1316 # recursive symlinks (bug 7022)
1318 test_mkdir -p $DIR/$tdir
1319 test_mkdir $DIR/$tdir/$tfile || error "mkdir $DIR/$tdir/$tfile failed"
1320 cd $DIR/$tdir/$tfile || error "cd $DIR/$tdir/$tfile failed"
1321 test_mkdir -p lndir/bar1 || error "mkdir lndir/bar1 failed"
1322 test_mkdir $DIR/$tdir/$tfile/$tfile || error "mkdir $tfile failed"
1323 cd $tfile || error "cd $tfile failed"
1324 ln -s .. dotdot || error "ln dotdot failed"
1325 ln -s dotdot/lndir lndir || error "ln lndir failed"
1326 cd $DIR/$tdir || error "cd $DIR/$tdir failed"
1327 output=`ls $tfile/$tfile/lndir/bar1`
1328 [ "$output" = bar1 ] && error "unexpected output"
1329 rm -r $tfile || error "rm $tfile failed"
1330 $CHECKSTAT -a $DIR/$tfile || error "$tfile not gone"
1332 run_test 26f "rm -r of a directory which has recursive symlink ="
1335 echo '== stripe sanity =============================================='
1336 test_mkdir -p $DIR/d27 || error "mkdir failed"
1338 $SETSTRIPE -c 1 $DIR/d27/f0 || error "setstripe failed"
1339 $CHECKSTAT -t file $DIR/d27/f0 || error "checkstat failed"
1340 log "== test_27a: write to one stripe file ========================="
1341 cp /etc/hosts $DIR/d27/f0 || error
1343 run_test 27a "one stripe file =================================="
1346 [[ $OSTCOUNT -lt 2 ]] && skip_env "skipping 2-stripe test" && return
1347 test_mkdir -p $DIR/d27
1348 $SETSTRIPE -c 2 $DIR/d27/f01 || error "setstripe failed"
1349 $GETSTRIPE -c $DIR/d27/f01
1350 [ $($GETSTRIPE -c $DIR/d27/f01) -eq 2 ] ||
1351 error "two-stripe file doesn't have two stripes"
1353 dd if=/dev/zero of=$DIR/d27/f01 bs=4k count=4 || error "dd failed"
1355 run_test 27b "create and write to two stripe file"
1358 test_mkdir -p $DIR/d27
1359 $SETSTRIPE -c 0 -i -1 -S 0 $DIR/d27/fdef || error "setstripe failed"
1360 $CHECKSTAT -t file $DIR/d27/fdef || error "checkstat failed"
1361 dd if=/dev/zero of=$DIR/d27/fdef bs=4k count=4 || error
1363 run_test 27d "create file with default settings ================"
1366 # LU-5839 adds check for existed layout before setting it
1367 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.56) ]] &&
1368 skip "Need MDS version at least 2.7.56" && return
1369 test_mkdir -p $DIR/d27
1370 $SETSTRIPE -c 2 $DIR/d27/f12 || error "setstripe failed"
1371 $SETSTRIPE -c 2 $DIR/d27/f12 && error "setstripe succeeded twice"
1372 $CHECKSTAT -t file $DIR/d27/f12 || error "checkstat failed"
1374 run_test 27e "setstripe existing file (should return error) ======"
1377 test_mkdir $DIR/$tdir
1378 $SETSTRIPE -S 100 -i 0 -c 1 $DIR/$tdir/$tfile &&
1379 error "$SETSTRIPE $DIR/$tdir/$tfile failed"
1380 $CHECKSTAT -t file $DIR/$tdir/$tfile &&
1381 error "$CHECKSTAT -t file $DIR/$tdir/$tfile should fail"
1382 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=4k count=4 || error "dd failed"
1383 $GETSTRIPE $DIR/$tdir/$tfile || error "$GETSTRIPE failed"
1385 run_test 27f "setstripe with bad stripe size (should return error)"
1388 test_mkdir -p $DIR/d27
1389 $MCREATE $DIR/d27/fnone || error "mcreate failed"
1390 $GETSTRIPE $DIR/d27/fnone 2>&1 | grep "no stripe info" ||
1391 error "$DIR/d27/fnone has object"
1393 run_test 27g "$GETSTRIPE with no objects"
1396 test_mkdir $DIR/$tdir
1397 touch $DIR/$tdir/$tfile || error "touch failed"
1398 [[ $($GETSTRIPE -c $DIR/$tdir/$tfile) -gt 0 ]] ||
1399 error "missing objects"
1401 run_test 27i "$GETSTRIPE with some objects"
1404 test_mkdir -p $DIR/d27
1405 $SETSTRIPE -i $OSTCOUNT $DIR/d27/f27j && error "setstripe failed"||true
1407 run_test 27j "setstripe with bad stripe offset (should return error)"
1409 test_27k() { # bug 2844
1410 test_mkdir -p $DIR/d27
1412 LL_MAX_BLKSIZE=$((4 * 1024 * 1024))
1413 [ ! -d $DIR/d27 ] && test_mkdir -p $DIR d27
1414 $SETSTRIPE -S 67108864 $FILE || error "setstripe failed"
1415 BLKSIZE=`stat $FILE | awk '/IO Block:/ { print $7 }'`
1416 [ $BLKSIZE -le $LL_MAX_BLKSIZE ] || error "1:$BLKSIZE > $LL_MAX_BLKSIZE"
1417 dd if=/dev/zero of=$FILE bs=4k count=1
1418 BLKSIZE=`stat $FILE | awk '/IO Block:/ { print $7 }'`
1419 [ $BLKSIZE -le $LL_MAX_BLKSIZE ] || error "2:$BLKSIZE > $LL_MAX_BLKSIZE"
1421 run_test 27k "limit i_blksize for broken user apps ============="
1424 test_mkdir -p $DIR/d27
1425 mcreate $DIR/f27l || error "creating file"
1426 $RUNAS $SETSTRIPE -c 1 $DIR/f27l && \
1427 error "setstripe should have failed" || true
1429 run_test 27l "check setstripe permissions (should return error)"
1432 [[ $OSTCOUNT -lt 2 ]] && skip_env "$OSTCOUNT < 2 OSTs -- skipping" &&
1434 if [[ $ORIGFREE -gt $MAXFREE ]]; then
1435 skip "$ORIGFREE > $MAXFREE skipping out-of-space test on OST0"
1438 trap simple_cleanup_common EXIT
1439 test_mkdir -p $DIR/$tdir
1440 $SETSTRIPE -i 0 -c 1 $DIR/$tdir/f27m_1
1441 dd if=/dev/zero of=$DIR/$tdir/f27m_1 bs=1024 count=$MAXFREE &&
1442 error "dd should fill OST0"
1444 while $SETSTRIPE -i 0 -c 1 $DIR/$tdir/f27m_$i; do
1446 [ $i -gt 256 ] && break
1449 touch $DIR/$tdir/f27m_$i
1450 [ `$GETSTRIPE $DIR/$tdir/f27m_$i | grep -A 10 obdidx | awk '{print $1}'| grep -w "0"` ] &&
1451 error "OST0 was full but new created file still use it"
1453 touch $DIR/$tdir/f27m_$i
1454 [ `$GETSTRIPE $DIR/$tdir/f27m_$i | grep -A 10 obdidx | awk '{print $1}'| grep -w "0"` ] &&
1455 error "OST0 was full but new created file still use it"
1456 simple_cleanup_common
1458 run_test 27m "create file while OST0 was full =================="
1461 local DELAY=$(do_facet $SINGLEMDS lctl get_param -n lov.*.qos_maxage | head -n 1 | awk '{print $1 * 2}')
1465 # OSCs keep a NOSPC flag that will be reset after ~5s (qos_maxage)
1466 # if the OST isn't full anymore.
1468 local OSTIDX=${1:-""}
1470 local list=$(comma_list $(osts_nodes))
1471 [ "$OSTIDX" ] && list=$(facet_host ost$((OSTIDX + 1)))
1473 do_nodes $list lctl set_param fail_loc=0
1474 sync # initiate all OST_DESTROYs from MDS to OST
1478 exhaust_precreations() {
1481 local FAILIDX=${3:-$OSTIDX}
1482 local ofacet=ost$((OSTIDX + 1))
1484 test_mkdir -p -c1 $DIR/$tdir
1485 local mdtidx=$($LFS getstripe -M $DIR/$tdir)
1486 local mfacet=mds$((mdtidx + 1))
1487 echo OSTIDX=$OSTIDX MDTIDX=$mdtidx
1489 local OST=$(ostname_from_index $OSTIDX)
1492 local mdtosc_proc1=$(get_mdtosc_proc_path $mfacet $OST)
1493 local last_id=$(do_facet $mfacet lctl get_param -n \
1494 osc.$mdtosc_proc1.prealloc_last_id)
1495 local next_id=$(do_facet $mfacet lctl get_param -n \
1496 osc.$mdtosc_proc1.prealloc_next_id)
1498 local mdtosc_proc2=$(get_mdtosc_proc_path $mfacet)
1499 do_facet $mfacet lctl get_param osc.$mdtosc_proc2.prealloc*
1501 test_mkdir -p $DIR/$tdir/${OST}
1502 $SETSTRIPE -i $OSTIDX -c 1 $DIR/$tdir/${OST}
1503 #define OBD_FAIL_OST_ENOSPC 0x215
1504 do_facet $ofacet lctl set_param fail_val=$FAILIDX fail_loc=0x215
1505 echo "Creating to objid $last_id on ost $OST..."
1506 createmany -o $DIR/$tdir/${OST}/f $next_id $((last_id - next_id + 2))
1507 do_facet $mfacet lctl get_param osc.$mdtosc_proc2.prealloc*
1508 do_facet $ofacet lctl set_param fail_loc=$FAILLOC
1512 exhaust_all_precreations() {
1514 for (( i=0; i < OSTCOUNT; i++ )) ; do
1515 exhaust_precreations $i $1 -1
1520 [[ $OSTCOUNT -lt 2 ]] && skip_env "too few OSTs" && return
1521 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1522 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1523 remote_ost_nodsh && skip "remote OST with nodsh" && return
1526 rm -f $DIR/$tdir/$tfile
1527 exhaust_precreations 0 0x80000215
1528 $SETSTRIPE -c -1 $DIR/$tdir
1529 touch $DIR/$tdir/$tfile || error
1530 $GETSTRIPE $DIR/$tdir/$tfile
1533 run_test 27n "create file with some full OSTs =================="
1536 [[ $OSTCOUNT -lt 2 ]] && skip_env "too few OSTs" && return
1537 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1538 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1539 remote_ost_nodsh && skip "remote OST with nodsh" && return
1542 rm -f $DIR/$tdir/$tfile
1543 exhaust_all_precreations 0x215
1545 touch $DIR/$tdir/$tfile && error "able to create $DIR/$tdir/$tfile"
1550 run_test 27o "create file with all full OSTs (should error) ===="
1553 [[ $OSTCOUNT -lt 2 ]] && skip_env "too few OSTs" && return
1554 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1555 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1556 remote_ost_nodsh && skip "remote OST with nodsh" && return
1559 rm -f $DIR/$tdir/$tfile
1560 test_mkdir -p $DIR/$tdir
1562 $MCREATE $DIR/$tdir/$tfile || error "mcreate failed"
1563 $TRUNCATE $DIR/$tdir/$tfile 80000000 || error "truncate failed"
1564 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat failed"
1566 exhaust_precreations 0 0x80000215
1567 echo foo >> $DIR/$tdir/$tfile || error "append failed"
1568 $CHECKSTAT -s 80000004 $DIR/$tdir/$tfile || error "checkstat failed"
1569 $GETSTRIPE $DIR/$tdir/$tfile
1573 run_test 27p "append to a truncated file with some full OSTs ==="
1576 [[ $OSTCOUNT -lt 2 ]] && skip_env "too few OSTs" && return
1577 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1578 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1579 remote_ost_nodsh && skip "remote OST with nodsh" && return
1582 rm -f $DIR/$tdir/$tfile
1584 test_mkdir -p $DIR/$tdir
1585 $MCREATE $DIR/$tdir/$tfile || error "mcreate $DIR/$tdir/$tfile failed"
1586 $TRUNCATE $DIR/$tdir/$tfile 80000000 ||error "truncate $DIR/$tdir/$tfile failed"
1587 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat failed"
1589 exhaust_all_precreations 0x215
1591 echo foo >> $DIR/$tdir/$tfile && error "append succeeded"
1592 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat 2 failed"
1596 run_test 27q "append to truncated file with all OSTs full (should error) ==="
1599 [[ $OSTCOUNT -lt 2 ]] && skip_env "too few OSTs" && return
1600 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1601 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1602 remote_ost_nodsh && skip "remote OST with nodsh" && return
1605 rm -f $DIR/$tdir/$tfile
1606 exhaust_precreations 0 0x80000215
1608 $SETSTRIPE -i 0 -c 2 $DIR/$tdir/$tfile # && error
1612 run_test 27r "stripe file with some full OSTs (shouldn't LBUG) ="
1614 test_27s() { # bug 10725
1615 test_mkdir -p $DIR/$tdir
1616 local stripe_size=$((4096 * 1024 * 1024)) # 2^32
1617 local stripe_count=0
1618 [ $OSTCOUNT -eq 1 ] || stripe_count=2
1619 $SETSTRIPE -S $stripe_size -c $stripe_count $DIR/$tdir &&
1620 error "stripe width >= 2^32 succeeded" || true
1623 run_test 27s "lsm_xfersize overflow (should error) (bug 10725)"
1625 test_27t() { # bug 10864
1630 $WLFS getstripe $tfile
1633 run_test 27t "check that utils parse path correctly"
1635 test_27u() { # bug 4900
1636 [[ $OSTCOUNT -lt 2 ]] && skip_env "too few OSTs" && return
1637 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1639 local list=$(comma_list $(mdts_nodes))
1641 #define OBD_FAIL_MDS_OSC_PRECREATE 0x139
1642 do_nodes $list $LCTL set_param fail_loc=0x139
1643 test_mkdir -p $DIR/$tdir
1645 createmany -o $DIR/$tdir/t- 1000
1646 do_nodes $list $LCTL set_param fail_loc=0
1648 TLOG=$DIR/$tfile.getstripe
1649 $GETSTRIPE $DIR/$tdir > $TLOG
1650 OBJS=$(awk -vobj=0 '($1 == 0) { obj += 1 } END { print obj; }' $TLOG)
1651 unlinkmany $DIR/$tdir/t- 1000
1652 [[ $OBJS -gt 0 ]] &&
1653 error "$OBJS objects created on OST-0. See $TLOG" || pass
1655 run_test 27u "skip object creation on OSC w/o objects =========="
1657 test_27v() { # bug 4900
1658 [[ $OSTCOUNT -lt 2 ]] && skip_env "too few OSTs" && return
1659 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1660 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1661 remote_ost_nodsh && skip "remote OST with nodsh" && return
1663 exhaust_all_precreations 0x215
1666 test_mkdir -p $DIR/$tdir
1667 $SETSTRIPE -c 1 $DIR/$tdir # 1 stripe / file
1669 touch $DIR/$tdir/$tfile
1670 #define OBD_FAIL_TGT_DELAY_PRECREATE 0x705
1672 for (( i=1; i < OSTCOUNT; i++ )); do
1673 do_facet ost$i lctl set_param fail_loc=0x705
1675 local START=`date +%s`
1676 createmany -o $DIR/$tdir/$tfile 32
1678 local FINISH=`date +%s`
1679 local TIMEOUT=`lctl get_param -n timeout`
1680 local PROCESS=$((FINISH - START))
1681 [ $PROCESS -ge $((TIMEOUT / 2)) ] && \
1682 error "$FINISH - $START >= $TIMEOUT / 2"
1683 sleep $((TIMEOUT / 2 - PROCESS))
1686 run_test 27v "skip object creation on slow OST ================="
1688 test_27w() { # bug 10997
1689 test_mkdir -p $DIR/$tdir || error "mkdir failed"
1690 $SETSTRIPE -S 65536 $DIR/$tdir/f0 || error "setstripe failed"
1691 [ $($GETSTRIPE -S $DIR/$tdir/f0) -ne 65536 ] &&
1692 error "stripe size $size != 65536" || true
1693 [ $($GETSTRIPE -d $DIR/$tdir | grep -c "stripe_count") -ne 1 ] &&
1694 error "$GETSTRIPE -d $DIR/$tdir failed" || true
1696 run_test 27w "check $SETSTRIPE -S option"
1699 [[ $OSTCOUNT -lt 2 ]] &&
1700 skip_env "skipping multiple stripe count/offset test" && return
1702 test_mkdir -p $DIR/$tdir || error "mkdir failed"
1703 for i in $(seq 1 $OSTCOUNT); do
1705 $SETSTRIPE -c $i -i $offset $DIR/$tdir/f$i ||
1706 error "setstripe -c $i -i $offset failed"
1707 count=$($GETSTRIPE -c $DIR/$tdir/f$i)
1708 index=$($GETSTRIPE -i $DIR/$tdir/f$i)
1709 [ $count -ne $i ] && error "stripe count $count != $i" || true
1710 [ $index -ne $offset ] &&
1711 error "stripe offset $index != $offset" || true
1714 run_test 27wa "check $SETSTRIPE -c -i options"
1717 remote_ost_nodsh && skip "remote OST with nodsh" && return
1718 [[ $OSTCOUNT -lt 2 ]] && skip_env "$OSTCOUNT < 2 OSTs" && return
1719 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1720 OFFSET=$(($OSTCOUNT - 1))
1722 local OST=$(ostname_from_index $OSTIDX)
1724 test_mkdir -p $DIR/$tdir
1725 $SETSTRIPE -c 1 $DIR/$tdir # 1 stripe per file
1726 do_facet ost$((OSTIDX + 1)) lctl set_param -n obdfilter.$OST.degraded 1
1728 createmany -o $DIR/$tdir/$tfile $OSTCOUNT
1729 for i in `seq 0 $OFFSET`; do
1730 [ `$GETSTRIPE $DIR/$tdir/$tfile$i | grep -A 10 obdidx | awk '{print $1}' | grep -w "$OSTIDX"` ] &&
1731 error "OST0 was degraded but new created file still use it"
1733 do_facet ost$((OSTIDX + 1)) lctl set_param -n obdfilter.$OST.degraded 0
1735 run_test 27x "create files while OST0 is degraded"
1738 [[ $OSTCOUNT -lt 2 ]] &&
1739 skip_env "$OSTCOUNT < 2 OSTs -- skipping" && return
1740 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1741 remote_ost_nodsh && skip "remote OST with nodsh" && return
1742 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1744 local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS $FSNAME-OST0000)
1745 local last_id=$(do_facet $SINGLEMDS lctl get_param -n \
1746 osc.$mdtosc.prealloc_last_id)
1747 local next_id=$(do_facet $SINGLEMDS lctl get_param -n \
1748 osc.$mdtosc.prealloc_next_id)
1749 local fcount=$((last_id - next_id))
1750 [[ $fcount -eq 0 ]] && skip "not enough space on OST0" && return
1751 [[ $fcount -gt $OSTCOUNT ]] && fcount=$OSTCOUNT
1753 local MDS_OSCS=$(do_facet $SINGLEMDS lctl dl |
1754 awk '/[oO][sS][cC].*md[ts]/ { print $4 }')
1755 local OST_DEACTIVE_IDX=-1
1760 for OSC in $MDS_OSCS; do
1761 OST=$(osc_to_ost $OSC)
1762 OSTIDX=$(index_from_ostuuid $OST)
1763 if [ $OST_DEACTIVE_IDX == -1 ]; then
1764 OST_DEACTIVE_IDX=$OSTIDX
1766 if [ $OSTIDX != $OST_DEACTIVE_IDX ]; then
1767 echo $OSC "is Deactivated:"
1768 do_facet $SINGLEMDS lctl --device %$OSC deactivate
1772 OSTIDX=$(index_from_ostuuid $OST)
1773 test_mkdir -p $DIR/$tdir
1774 $SETSTRIPE -c 1 $DIR/$tdir # 1 stripe / file
1776 for OSC in $MDS_OSCS; do
1777 OST=$(osc_to_ost $OSC)
1778 OSTIDX=$(index_from_ostuuid $OST)
1779 if [ $OSTIDX == $OST_DEACTIVE_IDX ]; then
1780 echo $OST "is degraded:"
1781 do_facet ost$((OSTIDX+1)) lctl set_param -n \
1782 obdfilter.$OST.degraded=1
1787 createmany -o $DIR/$tdir/$tfile $fcount
1789 for OSC in $MDS_OSCS; do
1790 OST=$(osc_to_ost $OSC)
1791 OSTIDX=$(index_from_ostuuid $OST)
1792 if [ $OSTIDX == $OST_DEACTIVE_IDX ]; then
1793 echo $OST "is recovered from degraded:"
1794 do_facet ost$((OSTIDX+1)) lctl set_param -n \
1795 obdfilter.$OST.degraded=0
1797 do_facet $SINGLEMDS lctl --device %$OSC activate
1801 # all osp devices get activated, hence -1 stripe count restored
1804 # sleep 2*lod_qos_maxage seconds waiting for lod qos to notice osp
1805 # devices get activated.
1807 $SETSTRIPE -c -1 $DIR/$tfile
1808 stripecnt=$($GETSTRIPE -c $DIR/$tfile)
1810 [ $stripecnt -ne $OSTCOUNT ] &&
1811 error "Of $OSTCOUNT OSTs, only $stripecnt is available"
1814 run_test 27y "create files while OST0 is degraded and the rest inactive"
1820 lmm_count=$($GETSTRIPE -c $1)
1821 lmm_seq=$($GETSTRIPE -v $1 | awk '/lmm_seq/ { print $2 }')
1822 lmm_oid=$($GETSTRIPE -v $1 | awk '/lmm_object_id/ { print $2 }')
1824 local old_ifs="$IFS"
1826 fid=($($LFS path2fid $1))
1829 log "FID seq ${fid[1]}, oid ${fid[2]} ver ${fid[3]}"
1830 log "LOV seq $lmm_seq, oid $lmm_oid, count: $lmm_count"
1832 # compare lmm_seq and lu_fid->f_seq
1833 [ $lmm_seq = ${fid[1]} ] || { error "SEQ mismatch"; return 1; }
1834 # compare lmm_object_id and lu_fid->oid
1835 [ $lmm_oid = ${fid[2]} ] || { error "OID mismatch"; return 2; }
1837 # check the trusted.fid attribute of the OST objects of the file
1838 local have_obdidx=false
1840 $GETSTRIPE $1 | while read obdidx oid hex seq; do
1841 # skip lines up to and including "obdidx"
1842 [ -z "$obdidx" ] && break
1843 [ "$obdidx" = "obdidx" ] && have_obdidx=true && continue
1844 $have_obdidx || continue
1846 local ost=$((obdidx + 1))
1847 local dev=$(ostdevname $ost)
1850 log "want: stripe:$stripe_nr ost:$obdidx oid:$oid/$hex seq:$seq"
1852 seq=$(echo $seq | sed -e "s/^0x//g")
1853 if [ $seq == 0 ] || [ $(facet_fstype ost$ost) == zfs ]; then
1854 oid_hex=$(echo $oid)
1856 oid_hex=$(echo $hex | sed -e "s/^0x//g")
1858 local obj_file="O/$seq/d$((oid %32))/$oid_hex"
1862 # Don't unmount/remount the OSTs if we don't need to do that.
1863 # LU-2577 changes filter_fid to be smaller, so debugfs needs
1864 # update too, until that use mount/ll_decode_filter_fid/mount.
1865 # Re-enable when debugfs will understand new filter_fid.
1867 if false && [ $(facet_fstype ost$ost) == ldiskfs ]; then
1868 ff=$(do_facet ost$ost "$DEBUGFS -c -R 'stat $obj_file' \
1869 $dev 2>/dev/null" | grep "parent=")
1872 mount_fstype ost$ost
1873 ff=$(do_facet ost$ost $LL_DECODE_FILTER_FID \
1874 $(facet_mntpt ost$ost)/$obj_file)
1875 unmount_fstype ost$ost
1876 start ost$ost $dev $OST_MOUNT_OPTS
1880 [ -z "$ff" ] && error "$obj_file: no filter_fid info"
1882 echo "$ff" | sed -e 's#.*objid=#got: objid=#'
1884 # /mnt/O/0/d23/23: objid=23 seq=0 parent=[0x200000400:0x1e:0x1]
1885 # fid: objid=23 seq=0 parent=[0x200000400:0x1e:0x0] stripe=1
1886 local ff_parent=$(echo $ff|sed -e 's/.*parent=.//')
1887 local ff_pseq=$(echo $ff_parent | cut -d: -f1)
1888 local ff_poid=$(echo $ff_parent | cut -d: -f2)
1890 if echo $ff_parent | grep -q 'stripe='; then
1891 ff_pstripe=$(echo $ff_parent | sed -e 's/.*stripe=//')
1894 # $LL_DECODE_FILTER_FID does not print "stripe="; look
1895 # into f_ver in this case. See the comment on
1898 ff_pstripe=$(echo $ff_parent | cut -d: -f3 |
1902 # compare lmm_seq and filter_fid->ff_parent.f_seq
1903 [ $ff_pseq = $lmm_seq ] ||
1904 error "FF parent SEQ $ff_pseq != $lmm_seq"
1905 # compare lmm_object_id and filter_fid->ff_parent.f_oid
1906 [ $ff_poid = $lmm_oid ] ||
1907 error "FF parent OID $ff_poid != $lmm_oid"
1908 (($ff_pstripe == $stripe_nr)) ||
1909 error "FF stripe $ff_pstripe != $stripe_nr"
1911 stripe_nr=$((stripe_nr + 1))
1916 remote_ost_nodsh && skip "remote OST with nodsh" && return
1917 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1918 test_mkdir -p $DIR/$tdir
1920 $SETSTRIPE -c 1 -i 0 -S 64k $DIR/$tdir/$tfile-1 ||
1921 { error "setstripe -c -1 failed"; return 1; }
1922 # We need to send a write to every object to get parent FID info set.
1923 # This _should_ also work for setattr, but does not currently.
1924 # touch $DIR/$tdir/$tfile-1 ||
1925 dd if=/dev/zero of=$DIR/$tdir/$tfile-1 bs=1M count=1 ||
1926 { error "dd $tfile-1 failed"; return 2; }
1927 $SETSTRIPE -c -1 -i $((OSTCOUNT - 1)) -S 1M $DIR/$tdir/$tfile-2 ||
1928 { error "setstripe -c -1 failed"; return 3; }
1929 dd if=/dev/zero of=$DIR/$tdir/$tfile-2 bs=1M count=$OSTCOUNT ||
1930 { error "dd $tfile-2 failed"; return 4; }
1932 # make sure write RPCs have been sent to OSTs
1935 check_seq_oid $DIR/$tdir/$tfile-1 || return 5
1936 check_seq_oid $DIR/$tdir/$tfile-2 || return 6
1938 run_test 27z "check SEQ/OID on the MDT and OST filesystems"
1940 test_27A() { # b=19102
1941 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1942 local restore_size=$($GETSTRIPE -S $MOUNT)
1943 local restore_count=$($GETSTRIPE -c $MOUNT)
1944 local restore_offset=$($GETSTRIPE -i $MOUNT)
1945 $SETSTRIPE -c 0 -i -1 -S 0 $MOUNT
1946 wait_update $HOSTNAME "$GETSTRIPE -c $MOUNT | sed 's/ *//g'" "1" 20 ||
1947 error "stripe count $($GETSTRIPE -c $MOUNT) != 1"
1948 local default_size=$($GETSTRIPE -S $MOUNT)
1949 local default_offset=$($GETSTRIPE -i $MOUNT)
1950 local dsize=$((1024 * 1024))
1951 [ $default_size -eq $dsize ] ||
1952 error "stripe size $default_size != $dsize"
1953 [ $default_offset -eq -1 ] ||error "stripe offset $default_offset != -1"
1954 $SETSTRIPE -c $restore_count -i $restore_offset -S $restore_size $MOUNT
1956 run_test 27A "check filesystem-wide default LOV EA values"
1958 test_27B() { # LU-2523
1959 test_mkdir -p $DIR/$tdir
1960 rm -f $DIR/$tdir/f0 $DIR/$tdir/f1
1962 # open f1 with O_LOV_DELAY_CREATE
1964 # call setstripe ioctl on open file descriptor for f1
1966 multiop $DIR/$tdir/f1 oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:nB1c \
1970 # open f1 with O_LOV_DELAY_CREATE
1972 # call setstripe ioctl on open file descriptor for f1
1974 multiop $DIR/$tdir/f1 oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:uB1c
1976 # Allow multiop to fail in imitation of NFS's busted semantics.
1979 run_test 27B "call setstripe on open unlinked file/rename victim"
1981 test_27C() { #LU-2871
1982 [[ $OSTCOUNT -lt 2 ]] && skip "needs >= 2 OSTs" && return
1990 test_mkdir -p $DIR/$tdir
1992 for i in $(seq 0 $((OSTCOUNT - 1))); do
1993 # set stripe across all OSTs starting from OST$i
1994 $SETSTRIPE -i $i -c -1 $tfile$i
1995 # get striping information
1996 ost_idx=($($GETSTRIPE $tfile$i |
1997 tail -n $((OSTCOUNT + 1)) | awk '{print $1}'))
2001 [ ${#ost_idx[@]} -eq $OSTCOUNT ] ||
2002 error "${#ost_idx[@]} != $OSTCOUNT"
2004 for index in $(seq 0 $((OSTCOUNT - 1))); do
2006 for j in $(echo ${ost_idx[@]}); do
2007 if [ $index -eq $j ]; then
2013 error "Can not find $index in ${ost_idx[@]}"
2017 run_test 27C "check full striping across all OSTs"
2020 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs" && return
2021 local POOL=${POOL:-testpool}
2023 local last_ost=$(($OSTCOUNT - 1))
2025 local ost_list=$(seq $first_ost $ost_step $last_ost)
2026 local ost_range="$first_ost $last_ost $ost_step"
2028 test_mkdir -p $DIR/$tdir
2029 pool_add $POOL || error "pool_add failed"
2030 pool_add_targets $POOL $ost_range || error "pool_add_targets failed"
2031 llapi_layout_test -d$DIR/$tdir -p$POOL -o$OSTCOUNT ||
2032 error "llapi_layout_test failed"
2033 cleanup_pools || error "cleanup_pools failed"
2035 run_test 27D "validate llapi_layout API"
2037 # Verify that default_easize is increased from its initial value after
2038 # accessing a widely striped file.
2040 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs" && return
2042 # 72 bytes is the minimum space required to store striping
2043 # information for a file striped across one OST:
2044 # (sizeof(struct lov_user_md_v3) +
2045 # sizeof(struct lov_user_ost_data_v1))
2047 $LCTL set_param -n llite.*.default_easize $min_easize ||
2048 error "lctl set_param failed"
2049 local easize=$($LCTL get_param -n llite.*.default_easize)
2051 [ $easize -eq $min_easize ] ||
2052 error "failed to set default_easize"
2054 $LFS setstripe -c $OSTCOUNT $DIR/$tfile ||
2055 error "setstripe failed"
2059 easize=$($LCTL get_param -n llite.*.default_easize)
2061 [ $easize -gt $min_easize ] ||
2062 error "default_easize not updated"
2064 run_test 27E "check that default extended attribute size properly increases"
2066 # createtest also checks that device nodes are created and
2067 # then visible correctly (#2091)
2068 test_28() { # bug 2091
2070 $CREATETEST $DIR/d28/ct || error
2072 run_test 28 "create/mknod/mkdir with bad file types ============"
2075 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2076 cancel_lru_locks mdc
2082 declare -i LOCKCOUNTORIG=0
2083 for lock_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_count); do
2084 let LOCKCOUNTORIG=$LOCKCOUNTORIG+$lock_count
2086 [ $LOCKCOUNTORIG -eq 0 ] && echo "No mdc lock count" && return 1
2088 declare -i LOCKUNUSEDCOUNTORIG=0
2089 for unused_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_unused_count); do
2090 let LOCKUNUSEDCOUNTORIG=$LOCKUNUSEDCOUNTORIG+$unused_count
2097 declare -i LOCKCOUNTCURRENT=0
2098 for lock_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_count); do
2099 let LOCKCOUNTCURRENT=$LOCKCOUNTCURRENT+$lock_count
2102 declare -i LOCKUNUSEDCOUNTCURRENT=0
2103 for unused_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_unused_count); do
2104 let LOCKUNUSEDCOUNTCURRENT=$LOCKUNUSEDCOUNTCURRENT+$unused_count
2107 if [[ $LOCKCOUNTCURRENT -gt $LOCKCOUNTORIG ]]; then
2108 $LCTL set_param -n ldlm.dump_namespaces ""
2109 error "CURRENT: $LOCKCOUNTCURRENT > $LOCKCOUNTORIG"
2110 $LCTL dk | sort -k4 -t: > $TMP/test_29.dk
2111 log "dumped log to $TMP/test_29.dk (bug 5793)"
2114 if [[ $LOCKUNUSEDCOUNTCURRENT -gt $LOCKUNUSEDCOUNTORIG ]]; then
2115 error "UNUSED: $LOCKUNUSEDCOUNTCURRENT > $LOCKUNUSEDCOUNTORIG"
2116 $LCTL dk | sort -k4 -t: > $TMP/test_29.dk
2117 log "dumped log to $TMP/test_29.dk (bug 5793)"
2121 run_test 29 "IT_GETATTR regression ============================"
2123 test_30a() { # was test_30
2124 cp $(which ls) $DIR || cp /bin/ls $DIR
2128 run_test 30a "execute binary from Lustre (execve) =============="
2131 cp `which ls` $DIR || cp /bin/ls $DIR
2133 $RUNAS $DIR/ls / || error
2136 run_test 30b "execute binary from Lustre as non-root ==========="
2138 test_30c() { # b=22376
2139 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2140 cp `which ls` $DIR || cp /bin/ls $DIR
2142 cancel_lru_locks mdc
2143 cancel_lru_locks osc
2144 $RUNAS $DIR/ls / || error
2147 run_test 30c "execute binary from Lustre without read perms ===="
2150 $OPENUNLINK $DIR/f31 $DIR/f31 || error
2151 $CHECKSTAT -a $DIR/f31 || error
2153 run_test 31a "open-unlink file =================================="
2156 touch $DIR/f31 || error
2157 ln $DIR/f31 $DIR/f31b || error
2158 $MULTIOP $DIR/f31b Ouc || error
2159 $CHECKSTAT -t file $DIR/f31 || error
2161 run_test 31b "unlink file with multiple links while open ======="
2164 touch $DIR/f31 || error
2165 ln $DIR/f31 $DIR/f31c || error
2166 multiop_bg_pause $DIR/f31 O_uc || return 1
2168 $MULTIOP $DIR/f31c Ouc
2169 kill -USR1 $MULTIPID
2172 run_test 31c "open-unlink file with multiple links ============="
2175 opendirunlink $DIR/d31d $DIR/d31d || error
2176 $CHECKSTAT -a $DIR/d31d || error
2178 run_test 31d "remove of open directory ========================="
2180 test_31e() { # bug 2904
2181 openfilleddirunlink $DIR/d31e || error
2183 run_test 31e "remove of open non-empty directory ==============="
2185 test_31f() { # bug 4554
2186 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2188 test_mkdir $DIR/d31f
2189 $SETSTRIPE -S 1048576 -c 1 $DIR/d31f
2190 cp /etc/hosts $DIR/d31f
2192 $GETSTRIPE $DIR/d31f/hosts
2193 multiop_bg_pause $DIR/d31f D_c || return 1
2196 rm -rv $DIR/d31f || error "first of $DIR/d31f"
2197 test_mkdir $DIR/d31f
2198 $SETSTRIPE -S 1048576 -c 1 $DIR/d31f
2199 cp /etc/hosts $DIR/d31f
2201 $GETSTRIPE $DIR/d31f/hosts
2202 multiop_bg_pause $DIR/d31f D_c || return 1
2205 kill -USR1 $MULTIPID || error "first opendir $MULTIPID not running"
2206 wait $MULTIPID || error "first opendir $MULTIPID failed"
2210 kill -USR1 $MULTIPID2 || error "second opendir $MULTIPID not running"
2211 wait $MULTIPID2 || error "second opendir $MULTIPID2 failed"
2214 run_test 31f "remove of open directory with open-unlink file ==="
2217 echo "-- cross directory link --"
2218 test_mkdir -c1 $DIR/${tdir}ga
2219 test_mkdir -c1 $DIR/${tdir}gb
2220 touch $DIR/${tdir}ga/f
2221 ln $DIR/${tdir}ga/f $DIR/${tdir}gb/g
2222 $CHECKSTAT -t file $DIR/${tdir}ga/f || error "source"
2223 [ `stat -c%h $DIR/${tdir}ga/f` == '2' ] || error "source nlink"
2224 $CHECKSTAT -t file $DIR/${tdir}gb/g || error "target"
2225 [ `stat -c%h $DIR/${tdir}gb/g` == '2' ] || error "target nlink"
2227 run_test 31g "cross directory link==============="
2230 echo "-- cross directory link --"
2231 test_mkdir -c1 $DIR/${tdir}
2232 test_mkdir -c1 $DIR/${tdir}/dir
2233 touch $DIR/${tdir}/f
2234 ln $DIR/${tdir}/f $DIR/${tdir}/dir/g
2235 $CHECKSTAT -t file $DIR/${tdir}/f || error "source"
2236 [ `stat -c%h $DIR/${tdir}/f` == '2' ] || error "source nlink"
2237 $CHECKSTAT -t file $DIR/${tdir}/dir/g || error "target"
2238 [ `stat -c%h $DIR/${tdir}/dir/g` == '2' ] || error "target nlink"
2240 run_test 31h "cross directory link under child==============="
2243 echo "-- cross directory link --"
2244 test_mkdir -c1 $DIR/$tdir
2245 test_mkdir -c1 $DIR/$tdir/dir
2246 touch $DIR/$tdir/dir/f
2247 ln $DIR/$tdir/dir/f $DIR/$tdir/g
2248 $CHECKSTAT -t file $DIR/$tdir/dir/f || error "source"
2249 [ `stat -c%h $DIR/$tdir/dir/f` == '2' ] || error "source nlink"
2250 $CHECKSTAT -t file $DIR/$tdir/g || error "target"
2251 [ `stat -c%h $DIR/$tdir/g` == '2' ] || error "target nlink"
2253 run_test 31i "cross directory link under parent==============="
2256 test_mkdir -c1 -p $DIR/$tdir
2257 test_mkdir -c1 -p $DIR/$tdir/dir1
2258 ln $DIR/$tdir/dir1 $DIR/$tdir/dir2 && error "ln for dir"
2259 link $DIR/$tdir/dir1 $DIR/$tdir/dir3 && error "link for dir"
2260 mlink $DIR/$tdir/dir1 $DIR/$tdir/dir4 && error "mlink for dir"
2261 mlink $DIR/$tdir/dir1 $DIR/$tdir/dir1 && error "mlink to the same dir"
2264 run_test 31j "link for directory==============="
2267 test_mkdir -c1 -p $DIR/$tdir
2269 touch $DIR/$tdir/exist
2270 mlink $DIR/$tdir/s $DIR/$tdir/t || error "mlink"
2271 mlink $DIR/$tdir/s $DIR/$tdir/exist && error "mlink to exist file"
2272 mlink $DIR/$tdir/s $DIR/$tdir/s && error "mlink to the same file"
2273 mlink $DIR/$tdir/s $DIR/$tdir && error "mlink to parent dir"
2274 mlink $DIR/$tdir $DIR/$tdir/s && error "mlink parent dir to target"
2275 mlink $DIR/$tdir/not-exist $DIR/$tdir/foo && error "mlink non-existing to new"
2276 mlink $DIR/$tdir/not-exist $DIR/$tdir/s && error "mlink non-existing to exist"
2279 run_test 31k "link to file: the same, non-existing, dir==============="
2285 touch $DIR/d31m2/exist
2286 mlink $DIR/d31m/s $DIR/d31m2/t || error "mlink"
2287 mlink $DIR/d31m/s $DIR/d31m2/exist && error "mlink to exist file"
2288 mlink $DIR/d31m/s $DIR/d31m2 && error "mlink to parent dir"
2289 mlink $DIR/d31m2 $DIR/d31m/s && error "mlink parent dir to target"
2290 mlink $DIR/d31m/not-exist $DIR/d31m2/foo && error "mlink non-existing to new"
2291 mlink $DIR/d31m/not-exist $DIR/d31m2/s && error "mlink non-existing to exist"
2294 run_test 31m "link to file: the same, non-existing, dir==============="
2297 touch $DIR/$tfile || error "cannot create '$DIR/$tfile'"
2298 nlink=$(stat --format=%h $DIR/$tfile)
2299 [ ${nlink:--1} -eq 1 ] || error "nlink is $nlink, expected 1"
2301 local cmd="exec $fd<$DIR/$tfile"
2304 trap "eval $cmd" EXIT
2305 nlink=$(stat --dereference --format=%h /proc/self/fd/$fd)
2306 [ ${nlink:--1} -eq 1 ] || error "nlink is $nlink, expected 1"
2307 rm $DIR/$tfile || error "cannot remove '$DIR/$tfile'"
2308 nlink=$(stat --dereference --format=%h /proc/self/fd/$fd)
2309 [ ${nlink:--1} -eq 0 ] || error "nlink is $nlink, expected 0"
2312 run_test 31n "check link count of unlinked file"
2315 local TEMPNAME=$(mktemp $1_XXXXXX)
2316 mlink $TEMPNAME $1 2> /dev/null &&
2317 echo "$BASHPID: link $TEMPNAME to $1 succeeded"
2321 test_31o() { # LU-2901
2322 test_mkdir -p $DIR/$tdir
2323 for LOOP in $(seq 100); do
2324 rm -f $DIR/$tdir/$tfile*
2325 for THREAD in $(seq 8); do
2326 link_one $DIR/$tdir/$tfile.$LOOP &
2329 local LINKS=$(ls -1 $DIR/$tdir | grep -c $tfile.$LOOP)
2330 [[ $LINKS -gt 1 ]] && ls $DIR/$tdir &&
2331 error "$LINKS duplicate links to $tfile.$LOOP" &&
2335 run_test 31o "duplicate hard links with same filename"
2338 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2340 test_mkdir $DIR/$tdir
2341 $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
2342 $LFS setdirstripe -D -c2 -t all_char $DIR/$tdir/striped_dir
2344 opendirunlink $DIR/$tdir/striped_dir/test1 ||
2345 error "open unlink test1 failed"
2346 opendirunlink $DIR/$tdir/striped_dir/test2 ||
2347 error "open unlink test2 failed"
2349 $CHECKSTAT -a $DIR/$tdir/striped_dir/test1 ||
2350 error "test1 still exists"
2351 $CHECKSTAT -a $DIR/$tdir/striped_dir/test2 ||
2352 error "test2 still exists"
2354 run_test 31p "remove of open striped directory"
2356 cleanup_test32_mount() {
2358 $UMOUNT $DIR/$tdir/ext2-mountpoint
2362 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2363 echo "== more mountpoints and symlinks ================="
2364 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2365 trap cleanup_test32_mount EXIT
2366 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2367 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2368 $CHECKSTAT -t dir $DIR/$tdir/ext2-mountpoint/.. || error
2369 cleanup_test32_mount
2371 run_test 32a "stat d32a/ext2-mountpoint/.. ====================="
2374 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2375 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2376 trap cleanup_test32_mount EXIT
2377 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2378 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2379 ls -al $DIR/$tdir/ext2-mountpoint/.. || error
2380 cleanup_test32_mount
2382 run_test 32b "open d32b/ext2-mountpoint/.. ====================="
2385 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2386 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2387 trap cleanup_test32_mount EXIT
2388 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2389 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2390 test_mkdir -p $DIR/$tdir/d2/test_dir
2391 $CHECKSTAT -t dir $DIR/$tdir/ext2-mountpoint/../d2/test_dir || error
2392 cleanup_test32_mount
2394 run_test 32c "stat d32c/ext2-mountpoint/../d2/test_dir ========="
2397 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2398 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2399 trap cleanup_test32_mount EXIT
2400 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2401 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2402 test_mkdir -p $DIR/$tdir/d2/test_dir
2403 ls -al $DIR/$tdir/ext2-mountpoint/../d2/test_dir || error
2404 cleanup_test32_mount
2406 run_test 32d "open d32d/ext2-mountpoint/../d2/test_dir ========="
2409 [ -e $DIR/d32e ] && rm -fr $DIR/d32e
2410 test_mkdir -p $DIR/d32e/tmp
2411 TMP_DIR=$DIR/d32e/tmp
2412 ln -s $DIR/d32e $TMP_DIR/symlink11
2413 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
2414 $CHECKSTAT -t link $DIR/d32e/tmp/symlink11 || error
2415 $CHECKSTAT -t link $DIR/d32e/symlink01 || error
2417 run_test 32e "stat d32e/symlink->tmp/symlink->lustre-subdir ===="
2420 [ -e $DIR/d32f ] && rm -fr $DIR/d32f
2421 test_mkdir -p $DIR/d32f/tmp
2422 TMP_DIR=$DIR/d32f/tmp
2423 ln -s $DIR/d32f $TMP_DIR/symlink11
2424 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
2425 ls $DIR/d32f/tmp/symlink11 || error
2426 ls $DIR/d32f/symlink01 || error
2428 run_test 32f "open d32f/symlink->tmp/symlink->lustre-subdir ===="
2431 TMP_DIR=$DIR/$tdir/tmp
2432 test_mkdir -p $DIR/$tdir/tmp
2433 test_mkdir $DIR/${tdir}2
2434 ln -s $DIR/${tdir}2 $TMP_DIR/symlink12
2435 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
2436 $CHECKSTAT -t link $TMP_DIR/symlink12 || error
2437 $CHECKSTAT -t link $DIR/$tdir/symlink02 || error
2438 $CHECKSTAT -t dir -f $TMP_DIR/symlink12 || error
2439 $CHECKSTAT -t dir -f $DIR/$tdir/symlink02 || error
2441 run_test 32g "stat d32g/symlink->tmp/symlink->lustre-subdir/${tdir}2"
2444 rm -fr $DIR/$tdir $DIR/${tdir}2
2445 TMP_DIR=$DIR/$tdir/tmp
2446 test_mkdir -p $DIR/$tdir/tmp
2447 test_mkdir $DIR/${tdir}2
2448 ln -s $DIR/${tdir}2 $TMP_DIR/symlink12
2449 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
2450 ls $TMP_DIR/symlink12 || error
2451 ls $DIR/$tdir/symlink02 || error
2453 run_test 32h "open d32h/symlink->tmp/symlink->lustre-subdir/${tdir}2"
2456 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2457 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2458 trap cleanup_test32_mount EXIT
2459 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2460 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2461 touch $DIR/$tdir/test_file
2462 $CHECKSTAT -t file $DIR/$tdir/ext2-mountpoint/../test_file || error
2463 cleanup_test32_mount
2465 run_test 32i "stat d32i/ext2-mountpoint/../test_file ==========="
2468 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2469 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2470 trap cleanup_test32_mount EXIT
2471 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2472 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2473 touch $DIR/$tdir/test_file
2474 cat $DIR/$tdir/ext2-mountpoint/../test_file || error
2475 cleanup_test32_mount
2477 run_test 32j "open d32j/ext2-mountpoint/../test_file ==========="
2480 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2482 trap cleanup_test32_mount EXIT
2483 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2484 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint
2485 test_mkdir -p $DIR/$tdir/d2
2486 touch $DIR/$tdir/d2/test_file || error
2487 $CHECKSTAT -t file $DIR/$tdir/ext2-mountpoint/../d2/test_file || error
2488 cleanup_test32_mount
2490 run_test 32k "stat d32k/ext2-mountpoint/../d2/test_file ========"
2493 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2495 trap cleanup_test32_mount EXIT
2496 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2497 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2498 test_mkdir -p $DIR/$tdir/d2
2499 touch $DIR/$tdir/d2/test_file
2500 cat $DIR/$tdir/ext2-mountpoint/../d2/test_file || error
2501 cleanup_test32_mount
2503 run_test 32l "open d32l/ext2-mountpoint/../d2/test_file ========"
2507 test_mkdir -p $DIR/d32m/tmp
2508 TMP_DIR=$DIR/d32m/tmp
2509 ln -s $DIR $TMP_DIR/symlink11
2510 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
2511 $CHECKSTAT -t link $DIR/d32m/tmp/symlink11 || error
2512 $CHECKSTAT -t link $DIR/d32m/symlink01 || error
2514 run_test 32m "stat d32m/symlink->tmp/symlink->lustre-root ======"
2518 test_mkdir -p $DIR/d32n/tmp
2519 TMP_DIR=$DIR/d32n/tmp
2520 ln -s $DIR $TMP_DIR/symlink11
2521 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
2522 ls -l $DIR/d32n/tmp/symlink11 || error
2523 ls -l $DIR/d32n/symlink01 || error
2525 run_test 32n "open d32n/symlink->tmp/symlink->lustre-root ======"
2529 test_mkdir -p $DIR/d32o/tmp
2530 TMP_DIR=$DIR/d32o/tmp
2531 ln -s $DIR/$tfile $TMP_DIR/symlink12
2532 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
2533 $CHECKSTAT -t link $DIR/d32o/tmp/symlink12 || error
2534 $CHECKSTAT -t link $DIR/d32o/symlink02 || error
2535 $CHECKSTAT -t file -f $DIR/d32o/tmp/symlink12 || error
2536 $CHECKSTAT -t file -f $DIR/d32o/symlink02 || error
2538 run_test 32o "stat d32o/symlink->tmp/symlink->lustre-root/$tfile"
2548 test_mkdir -p $DIR/d32p/tmp
2550 TMP_DIR=$DIR/d32p/tmp
2552 ln -s $DIR/$tfile $TMP_DIR/symlink12
2554 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
2556 cat $DIR/d32p/tmp/symlink12 || error
2558 cat $DIR/d32p/symlink02 || error
2561 run_test 32p "open d32p/symlink->tmp/symlink->lustre-root/$tfile"
2563 cleanup_testdir_mount() {
2569 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2570 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2571 trap cleanup_testdir_mount EXIT
2572 test_mkdir -p $DIR/$tdir
2573 touch $DIR/$tdir/under_the_mount
2574 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir
2575 ls $DIR/$tdir | grep "\<under_the_mount\>" && error
2576 cleanup_testdir_mount
2578 run_test 32q "stat follows mountpoints in Lustre (should return error)"
2581 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2582 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2583 trap cleanup_testdir_mount EXIT
2584 test_mkdir -p $DIR/$tdir
2585 touch $DIR/$tdir/under_the_mount
2586 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir
2587 ls $DIR/$tdir | grep -q under_the_mount && error || true
2588 cleanup_testdir_mount
2590 run_test 32r "opendir follows mountpoints in Lustre (should return error)"
2595 chmod 444 $DIR/$tfile
2596 chown $RUNAS_ID $DIR/$tfile
2598 $RUNAS $OPENFILE -f O_RDWR $DIR/$tfile && error || true
2601 run_test 33aa "write file with mode 444 (should return error) ===="
2605 test_mkdir -p $DIR/d33
2606 chown $RUNAS_ID $DIR/d33
2607 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $DIR/d33/f33|| error "create"
2608 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $DIR/d33/f33 && \
2609 error "open RDWR" || true
2611 run_test 33a "test open file(mode=0444) with O_RDWR (should return error)"
2615 test_mkdir -p $DIR/d33
2616 chown $RUNAS_ID $DIR/d33
2617 $RUNAS $OPENFILE -f 1286739555 $DIR/d33/f33 || true
2619 run_test 33b "test open file with malformed flags (No panic)"
2622 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2628 remote_ost_nodsh && skip "remote OST with nodsh" && return
2631 test_mkdir -p $DIR/d33
2632 # Read: 0, Write: 4, create/destroy: 2/0, stat: 1, punch: 0
2635 for ostnum in $(seq $OSTCOUNT); do
2636 # test-framework's OST numbering is one-based, while Lustre's
2638 ostname=$(printf "$FSNAME-OST%.4x" $((ostnum - 1)))
2639 # Parsing llobdstat's output sucks; we could grep the /proc
2640 # path, but that's likely to not be as portable as using the
2641 # llobdstat utility. So we parse lctl output instead.
2642 write_bytes=$(do_facet ost$ostnum lctl get_param -n \
2643 obdfilter/$ostname/stats |
2644 awk '/^write_bytes/ {print $7}' )
2645 echo "baseline_write_bytes@$OSTnum/$ostname=$write_bytes"
2646 if (( ${write_bytes:-0} > 0 ))
2653 $all_zeros || return 0
2656 echo foo > $DIR/d33/bar
2660 # Total up write_bytes after writing. We'd better find non-zeros.
2661 for ostnum in $(seq $OSTCOUNT); do
2662 ostname=$(printf "$FSNAME-OST%.4x" $((ostnum - 1)))
2663 write_bytes=$(do_facet ost$ostnum lctl get_param -n \
2664 obdfilter/$ostname/stats |
2665 awk '/^write_bytes/ {print $7}' )
2666 echo "write_bytes@$OSTnum/$ostname=$write_bytes"
2667 if (( ${write_bytes:-0} > 0 ))
2676 for ostnum in $(seq $OSTCOUNT); do
2677 ostname=$(printf "$FSNAME-OST%.4x" $((ostnum - 1)))
2678 echo "Check that write_bytes is present in obdfilter/*/stats:"
2679 do_facet ost$ostnum lctl get_param -n \
2680 obdfilter/$ostname/stats
2682 error "OST not keeping write_bytes stats (b22312)"
2685 run_test 33c "test llobdstat and write_bytes"
2688 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 2 MDTs" && return
2689 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2691 local remote_dir=$DIR/$tdir/remote_dir
2693 test_mkdir -p $DIR/$tdir
2694 $LFS mkdir -i $MDTIDX $remote_dir ||
2695 error "create remote directory failed"
2697 touch $remote_dir/$tfile
2698 chmod 444 $remote_dir/$tfile
2699 chown $RUNAS_ID $remote_dir/$tfile
2701 $RUNAS $OPENFILE -f O_RDWR $DIR/$tfile && error || true
2703 chown $RUNAS_ID $remote_dir
2704 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $remote_dir/f33 ||
2705 error "create" || true
2706 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $remote_dir/f33 &&
2707 error "open RDWR" || true
2708 $RUNAS $OPENFILE -f 1286739555 $remote_dir/f33 || true
2710 run_test 33d "openfile with 444 modes and malformed flags under remote dir"
2713 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2717 $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
2718 $LFS setdirstripe -i1 -c2 $DIR/$tdir/striped_dir1
2719 mkdir $DIR/$tdir/local_dir
2721 local s0_mode=$(stat -c%f $DIR/$tdir/striped_dir)
2722 local s1_mode=$(stat -c%f $DIR/$tdir/striped_dir1)
2723 local l_mode=$(stat -c%f $DIR/$tdir/local_dir)
2725 [ "$l_mode" = "$s0_mode" -a "$l_mode" = "$s1_mode" ] ||
2726 error "mkdir $l_mode striped0 $s0_mode striped1 $s1_mode"
2728 rmdir $DIR/$tdir/* || error "rmdir failed"
2731 $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
2732 $LFS setdirstripe -i1 -c2 $DIR/$tdir/striped_dir1
2733 mkdir $DIR/$tdir/local_dir
2735 s0_mode=$(stat -c%f $DIR/$tdir/striped_dir)
2736 s1_mode=$(stat -c%f $DIR/$tdir/striped_dir1)
2737 l_mode=$(stat -c%f $DIR/$tdir/local_dir)
2739 [ "$l_mode" = "$s0_mode" -a "$l_mode" = "$s1_mode" ] ||
2740 error "mkdir $l_mode striped0 $s0_mode striped1 $s1_mode 777"
2742 rmdir $DIR/$tdir/* || error "rmdir(umask 777) failed"
2745 $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
2746 $LFS setdirstripe -i1 -c2 $DIR/$tdir/striped_dir1
2747 mkdir $DIR/$tdir/local_dir
2749 s0_mode=$(stat -c%f $DIR/$tdir/striped_dir)
2750 s1_mode=$(stat -c%f $DIR/$tdir/striped_dir1)
2751 l_mode=$(stat -c%f $DIR/$tdir/local_dir)
2753 [ "$l_mode" = "$s0_mode" -a "$l_mode" = "$s1_mode" ] ||
2754 error "mkdir $l_mode striped0 $s0_mode striped1 $s1_mode 0"
2756 run_test 33e "mkdir and striped directory should have same mode"
2760 do_facet $SINGLEMDS $LCTL set_param mdt.*.enable_remote_dir_gid=0
2764 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2767 chmod go+rwx $DIR/$tdir
2768 do_facet $SINGLEMDS $LCTL set_param mdt.*.enable_remote_dir_gid=-1
2769 trap cleanup_33f EXIT
2771 $RUNAS lfs mkdir -c$MDSCOUNT $DIR/$tdir/striped_dir ||
2772 error "cannot create striped directory"
2774 $RUNAS touch $DIR/$tdir/striped_dir/{0..16} ||
2775 error "cannot create files in striped directory"
2777 $RUNAS rm $DIR/$tdir/striped_dir/{0..16} ||
2778 error "cannot remove files in striped directory"
2780 $RUNAS rmdir $DIR/$tdir/striped_dir ||
2781 error "cannot remove striped directory"
2785 run_test 33f "nonroot user can create, access, and remove a striped directory"
2787 TEST_34_SIZE=${TEST_34_SIZE:-2000000000000}
2790 $MCREATE $DIR/f34 || error
2791 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" || error
2792 $TRUNCATE $DIR/f34 $TEST_34_SIZE || error
2793 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" || error
2794 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2796 run_test 34a "truncate file that has not been opened ==========="
2799 [ ! -f $DIR/f34 ] && test_34a
2800 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2801 $OPENFILE -f O_RDONLY $DIR/f34
2802 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" || error
2803 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2805 run_test 34b "O_RDONLY opening file doesn't create objects ====="
2808 [ ! -f $DIR/f34 ] && test_34a
2809 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2810 $OPENFILE -f O_RDWR $DIR/f34
2811 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" && error
2812 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2814 run_test 34c "O_RDWR opening file-with-size works =============="
2817 [ ! -f $DIR/f34 ] && test_34a
2818 dd if=/dev/zero of=$DIR/f34 conv=notrunc bs=4k count=1 || error
2819 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2822 run_test 34d "write to sparse file ============================="
2826 $MCREATE $DIR/f34e || error
2827 $TRUNCATE $DIR/f34e 1000 || error
2828 $CHECKSTAT -s 1000 $DIR/f34e || error
2829 $OPENFILE -f O_RDWR $DIR/f34e
2830 $CHECKSTAT -s 1000 $DIR/f34e || error
2832 run_test 34e "create objects, some with size and some without =="
2834 test_34f() { # bug 6242, 6243
2835 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2838 $MCREATE $DIR/f34f || error
2839 $TRUNCATE $DIR/f34f $SIZE34F || error "truncating $DIR/f3f to $SIZE34F"
2840 dd if=$DIR/f34f of=$TMP/f34f
2841 $CHECKSTAT -s $SIZE34F $TMP/f34f || error "$TMP/f34f not $SIZE34F bytes"
2842 dd if=/dev/zero of=$TMP/f34fzero bs=$SIZE34F count=1
2843 cmp $DIR/f34f $TMP/f34fzero || error "$DIR/f34f not all zero"
2844 cmp $TMP/f34f $TMP/f34fzero || error "$TMP/f34f not all zero"
2845 rm $TMP/f34f $TMP/f34fzero $DIR/f34f
2847 run_test 34f "read from a file with no objects until EOF ======="
2850 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2851 dd if=/dev/zero of=$DIR/$tfile bs=1 count=100 seek=$TEST_34_SIZE || error
2852 $TRUNCATE $DIR/$tfile $((TEST_34_SIZE / 2))|| error
2853 $CHECKSTAT -s $((TEST_34_SIZE / 2)) $DIR/$tfile || error "truncate failed"
2854 cancel_lru_locks osc
2855 $CHECKSTAT -s $((TEST_34_SIZE / 2)) $DIR/$tfile || \
2856 error "wrong size after lock cancel"
2858 $TRUNCATE $DIR/$tfile $TEST_34_SIZE || error
2859 $CHECKSTAT -s $TEST_34_SIZE $DIR/$tfile || \
2860 error "expanding truncate failed"
2861 cancel_lru_locks osc
2862 $CHECKSTAT -s $TEST_34_SIZE $DIR/$tfile || \
2863 error "wrong expanded size after lock cancel"
2865 run_test 34g "truncate long file ==============================="
2868 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2872 dd if=/dev/zero of=$DIR/$tfile bs=1M count=10 || error
2873 sync # Flush the cache so that multiop below does not block on cache
2874 # flush when getting the group lock
2875 $MULTIOP $DIR/$tfile OG${gid}T${sz}g${gid}c &
2878 # Since just timed wait is not good enough, let's do a sync write
2879 # that way we are sure enough time for a roundtrip + processing
2880 # passed + 2 seconds of extra margin.
2881 dd if=/dev/zero of=$DIR/${tfile}-1 bs=4096 oflag=direct count=1
2885 if [[ `ps h -o comm -p $MULTIPID` == "multiop" ]]; then
2886 error "Multiop blocked on ftruncate, pid=$MULTIPID"
2890 local nsz=`stat -c %s $DIR/$tfile`
2891 [[ $nsz == $sz ]] || error "New size wrong $nsz != $sz"
2893 run_test 34h "ftruncate file under grouplock should not block"
2896 cp /bin/sh $DIR/f35a
2898 chown $RUNAS_ID $DIR/f35a
2899 $RUNAS $DIR/f35a && error || true
2902 run_test 35a "exec file with mode 444 (should return and not leak) ====="
2906 utime $DIR/f36 || error
2908 run_test 36a "MDS utime check (mknod, utime) ==================="
2912 utime $DIR/f36 || error
2914 run_test 36b "OST utime check (open, utime) ===================="
2919 chown $RUNAS_ID $DIR/d36
2920 $RUNAS utime $DIR/d36/f36 || error
2922 run_test 36c "non-root MDS utime check (mknod, utime) =========="
2925 [ ! -d $DIR/d36 ] && test_36c
2926 echo "" > $DIR/d36/f36
2927 $RUNAS utime $DIR/d36/f36 || error
2929 run_test 36d "non-root OST utime check (open, utime) ==========="
2932 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID -- skipping" && return
2933 test_mkdir -p $DIR/$tdir
2934 touch $DIR/$tdir/$tfile
2935 $RUNAS utime $DIR/$tdir/$tfile && \
2936 error "utime worked, expected failure" || true
2938 run_test 36e "utime on non-owned file (should return error) ===="
2942 local LANG_SAVE=$LANG
2943 local LC_LANG_SAVE=$LC_LANG
2944 export LANG=C LC_LANG=C # for date language
2946 DATESTR="Dec 20 2000"
2947 test_mkdir -p $DIR/$tdir
2948 lctl set_param fail_loc=$fl
2950 cp /etc/hosts $DIR/$tdir/$tfile
2951 sync & # write RPC generated with "current" inode timestamp, but delayed
2953 touch --date="$DATESTR" $DIR/$tdir/$tfile # setattr timestamp in past
2954 LS_BEFORE="`ls -l $DIR/$tdir/$tfile`" # old timestamp from client cache
2955 cancel_lru_locks osc
2956 LS_AFTER="`ls -l $DIR/$tdir/$tfile`" # timestamp from OST object
2958 [ "$LS_BEFORE" != "$LS_AFTER" ] && \
2959 echo "BEFORE: $LS_BEFORE" && \
2960 echo "AFTER : $LS_AFTER" && \
2961 echo "WANT : $DATESTR" && \
2962 error "$DIR/$tdir/$tfile timestamps changed" || true
2964 export LANG=$LANG_SAVE LC_LANG=$LC_LANG_SAVE
2968 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2969 #define OBD_FAIL_OST_BRW_PAUSE_BULK 0x214
2970 subr_36fh "0x80000214"
2972 run_test 36f "utime on file racing with OST BRW write =========="
2975 remote_ost_nodsh && skip "remote OST with nodsh" && return
2976 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2981 test_mkdir -p $DIR/$tdir
2982 fmd_max_age=$(do_facet ost1 \
2983 "lctl get_param -n obdfilter.*.client_cache_seconds 2> /dev/null | \
2986 fmd_before=$(do_facet ost1 \
2987 "awk '/ll_fmd_cache/ {print \\\$2}' /proc/slabinfo")
2988 touch $DIR/$tdir/$tfile
2989 sleep $((fmd_max_age + 12))
2990 fmd_after=$(do_facet ost1 \
2991 "awk '/ll_fmd_cache/ {print \\\$2}' /proc/slabinfo")
2993 echo "fmd_before: $fmd_before"
2994 echo "fmd_after: $fmd_after"
2995 [[ $fmd_after -gt $fmd_before ]] &&
2996 echo "AFTER: $fmd_after > BEFORE: $fmd_before" &&
2997 error "fmd didn't expire after ping" || true
2999 run_test 36g "filter mod data cache expiry ====================="
3002 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3003 #define OBD_FAIL_OST_BRW_PAUSE_BULK2 0x227
3004 subr_36fh "0x80000227"
3006 run_test 36h "utime on file racing with OST BRW write =========="
3009 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
3011 test_mkdir $DIR/$tdir
3012 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR/$tdir/striped_dir
3014 local mtime=$(stat -c%Y $DIR/$tdir/striped_dir)
3015 local new_mtime=$((mtime + 200))
3017 #change Modify time of striped dir
3018 touch -m -d @$new_mtime $DIR/$tdir/striped_dir ||
3019 error "change mtime failed"
3021 local got=$(stat -c%Y $DIR/$tdir/striped_dir)
3023 [ "$new_mtime" = "$got" ] || error "expect $new_mtime got $got"
3025 run_test 36i "change mtime on striped directory"
3027 # test_37 - duplicate with tests 32q 32r
3030 local file=$DIR/$tfile
3032 openfile -f O_DIRECTORY $file
3035 [ $RC -eq 0 ] && error "opened file $file with O_DIRECTORY" || true
3036 [ $RC -eq $ENOTDIR ] || error "error $RC should be ENOTDIR ($ENOTDIR)"
3038 run_test 38 "open a regular file with O_DIRECTORY should return -ENOTDIR ==="
3042 touch $DIR/${tfile}2
3043 # ls -l $DIR/$tfile $DIR/${tfile}2
3044 # ls -lu $DIR/$tfile $DIR/${tfile}2
3045 # ls -lc $DIR/$tfile $DIR/${tfile}2
3047 $OPENFILE -f O_CREAT:O_TRUNC:O_WRONLY $DIR/${tfile}2
3048 if [ ! $DIR/${tfile}2 -nt $DIR/$tfile ]; then
3050 ls -l --full-time $DIR/$tfile $DIR/${tfile}2
3052 ls -lu --full-time $DIR/$tfile $DIR/${tfile}2
3054 ls -lc --full-time $DIR/$tfile $DIR/${tfile}2
3055 error "O_TRUNC didn't change timestamps"
3058 run_test 39 "mtime changed on create ==========================="
3061 test_mkdir -p -c1 $DIR/$tdir
3062 cp -p /etc/passwd $DIR/$tdir/fopen
3063 cp -p /etc/passwd $DIR/$tdir/flink
3064 cp -p /etc/passwd $DIR/$tdir/funlink
3065 cp -p /etc/passwd $DIR/$tdir/frename
3066 ln $DIR/$tdir/funlink $DIR/$tdir/funlink2
3069 echo "aaaaaa" >> $DIR/$tdir/fopen
3070 echo "aaaaaa" >> $DIR/$tdir/flink
3071 echo "aaaaaa" >> $DIR/$tdir/funlink
3072 echo "aaaaaa" >> $DIR/$tdir/frename
3074 local open_new=`stat -c %Y $DIR/$tdir/fopen`
3075 local link_new=`stat -c %Y $DIR/$tdir/flink`
3076 local unlink_new=`stat -c %Y $DIR/$tdir/funlink`
3077 local rename_new=`stat -c %Y $DIR/$tdir/frename`
3079 cat $DIR/$tdir/fopen > /dev/null
3080 ln $DIR/$tdir/flink $DIR/$tdir/flink2
3081 rm -f $DIR/$tdir/funlink2
3082 mv -f $DIR/$tdir/frename $DIR/$tdir/frename2
3084 for (( i=0; i < 2; i++ )) ; do
3085 local open_new2=`stat -c %Y $DIR/$tdir/fopen`
3086 local link_new2=`stat -c %Y $DIR/$tdir/flink`
3087 local unlink_new2=`stat -c %Y $DIR/$tdir/funlink`
3088 local rename_new2=`stat -c %Y $DIR/$tdir/frename2`
3090 [ $open_new2 -eq $open_new ] || error "open file reverses mtime"
3091 [ $link_new2 -eq $link_new ] || error "link file reverses mtime"
3092 [ $unlink_new2 -eq $unlink_new ] || error "unlink file reverses mtime"
3093 [ $rename_new2 -eq $rename_new ] || error "rename file reverses mtime"
3095 cancel_lru_locks osc
3096 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3099 run_test 39b "mtime change on open, link, unlink, rename ======"
3101 # this should be set to past
3102 TEST_39_MTIME=`date -d "1 year ago" +%s`
3108 local mtime0=`stat -c %Y $DIR1/$tfile`
3110 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3111 local mtime1=`stat -c %Y $DIR1/$tfile`
3112 [ "$mtime1" = $TEST_39_MTIME ] || \
3113 error "mtime is not set to past: $mtime1, should be $TEST_39_MTIME"
3116 echo hello >> $DIR1/$tfile
3118 local mtime2=`stat -c %Y $DIR1/$tfile`
3119 [ "$mtime2" -ge "$d1" ] && [ "$mtime2" -le "$d2" ] || \
3120 error "mtime is not updated on write: $d1 <= $mtime2 <= $d2"
3122 mv $DIR1/$tfile $DIR1/$tfile-1
3124 for (( i=0; i < 2; i++ )) ; do
3125 local mtime3=`stat -c %Y $DIR1/$tfile-1`
3126 [ "$mtime2" = "$mtime3" ] || \
3127 error "mtime ($mtime2) changed (to $mtime3) on rename"
3129 cancel_lru_locks osc
3130 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3133 run_test 39c "mtime change on rename ==========================="
3137 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3140 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3142 for (( i=0; i < 2; i++ )) ; do
3143 local mtime=`stat -c %Y $DIR1/$tfile`
3144 [ $mtime = $TEST_39_MTIME ] || \
3145 error "mtime($mtime) is not set to $TEST_39_MTIME"
3147 cancel_lru_locks osc
3148 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3151 run_test 39d "create, utime, stat =============================="
3155 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3157 local mtime1=`stat -c %Y $DIR1/$tfile`
3159 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3161 for (( i=0; i < 2; i++ )) ; do
3162 local mtime2=`stat -c %Y $DIR1/$tfile`
3163 [ $mtime2 = $TEST_39_MTIME ] || \
3164 error "mtime($mtime2) is not set to $TEST_39_MTIME"
3166 cancel_lru_locks osc
3167 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3170 run_test 39e "create, stat, utime, stat ========================"
3174 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3176 mtime1=`stat -c %Y $DIR1/$tfile`
3179 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3181 for (( i=0; i < 2; i++ )) ; do
3182 local mtime2=`stat -c %Y $DIR1/$tfile`
3183 [ $mtime2 = $TEST_39_MTIME ] || \
3184 error "mtime($mtime2) is not set to $TEST_39_MTIME"
3186 cancel_lru_locks osc
3187 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3190 run_test 39f "create, stat, sleep, utime, stat ================="
3194 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3195 echo hello >> $DIR1/$tfile
3196 local mtime1=`stat -c %Y $DIR1/$tfile`
3199 chmod o+r $DIR1/$tfile
3201 for (( i=0; i < 2; i++ )) ; do
3202 local mtime2=`stat -c %Y $DIR1/$tfile`
3203 [ "$mtime1" = "$mtime2" ] || \
3204 error "lost mtime: $mtime2, should be $mtime1"
3206 cancel_lru_locks osc
3207 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3210 run_test 39g "write, chmod, stat ==============================="
3214 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3219 echo hello >> $DIR1/$tfile
3220 local mtime1=`stat -c %Y $DIR1/$tfile`
3222 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3224 if [ "$d1" != "$d2" ]; then
3225 echo "write and touch not within one second"
3227 for (( i=0; i < 2; i++ )) ; do
3228 local mtime2=`stat -c %Y $DIR1/$tfile`
3229 [ "$mtime2" = $TEST_39_MTIME ] || \
3230 error "lost mtime: $mtime2, should be $TEST_39_MTIME"
3232 cancel_lru_locks osc
3233 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3237 run_test 39h "write, utime within one second, stat ============="
3240 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3244 echo hello >> $DIR1/$tfile
3245 local mtime1=`stat -c %Y $DIR1/$tfile`
3247 mv $DIR1/$tfile $DIR1/$tfile-1
3249 for (( i=0; i < 2; i++ )) ; do
3250 local mtime2=`stat -c %Y $DIR1/$tfile-1`
3252 [ "$mtime1" = "$mtime2" ] || \
3253 error "lost mtime: $mtime2, should be $mtime1"
3255 cancel_lru_locks osc
3256 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3259 run_test 39i "write, rename, stat =============================="
3262 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3263 start_full_debug_logging
3267 #define OBD_FAIL_OSC_DELAY_SETTIME 0x412
3268 lctl set_param fail_loc=0x80000412
3269 multiop_bg_pause $DIR1/$tfile oO_RDWR:w2097152_c ||
3270 error "multiop failed"
3272 local mtime1=`stat -c %Y $DIR1/$tfile`
3274 mv $DIR1/$tfile $DIR1/$tfile-1
3276 kill -USR1 $multipid
3277 wait $multipid || error "multiop close failed"
3279 for (( i=0; i < 2; i++ )) ; do
3280 local mtime2=`stat -c %Y $DIR1/$tfile-1`
3281 [ "$mtime1" = "$mtime2" ] ||
3282 error "mtime is lost on close: $mtime2, " \
3285 cancel_lru_locks osc
3286 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3288 lctl set_param fail_loc=0
3289 stop_full_debug_logging
3291 run_test 39j "write, rename, close, stat ======================="
3294 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3298 multiop_bg_pause $DIR1/$tfile oO_RDWR:w2097152_c || error "multiop failed"
3300 local mtime1=`stat -c %Y $DIR1/$tfile`
3302 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3304 kill -USR1 $multipid
3305 wait $multipid || error "multiop close failed"
3307 for (( i=0; i < 2; i++ )) ; do
3308 local mtime2=`stat -c %Y $DIR1/$tfile`
3310 [ "$mtime2" = $TEST_39_MTIME ] || \
3311 error "mtime is lost on close: $mtime2, should be $TEST_39_MTIME"
3313 cancel_lru_locks osc
3314 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3317 run_test 39k "write, utime, close, stat ========================"
3319 # this should be set to future
3320 TEST_39_ATIME=`date -d "1 year" +%s`
3323 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3324 remote_mds_nodsh && skip "remote MDS with nodsh" && return
3325 local atime_diff=$(do_facet $SINGLEMDS \
3326 lctl get_param -n mdd.*MDT0000*.atime_diff)
3330 # test setting directory atime to future
3331 touch -a -d @$TEST_39_ATIME $DIR/$tdir
3332 local atime=$(stat -c %X $DIR/$tdir)
3333 [ "$atime" = $TEST_39_ATIME ] || \
3334 error "atime is not set to future: $atime, $TEST_39_ATIME"
3336 # test setting directory atime from future to now
3337 local d1=$(date +%s)
3339 local d2=$(date +%s)
3341 cancel_lru_locks mdc
3342 atime=$(stat -c %X $DIR/$tdir)
3343 [ "$atime" -ge "$d1" -a "$atime" -le "$d2" ] || \
3344 error "atime is not updated from future: $atime, $d1<atime<$d2"
3346 do_facet $SINGLEMDS lctl set_param -n mdd.*MDT0000*.atime_diff=2
3349 # test setting directory atime when now > dir atime + atime_diff
3353 cancel_lru_locks mdc
3354 atime=$(stat -c %X $DIR/$tdir)
3355 [ "$atime" -ge "$d1" -a "$atime" -le "$d2" ] || \
3356 error "atime is not updated : $atime, should be $d2"
3358 do_facet $SINGLEMDS lctl set_param -n mdd.*MDT0000*.atime_diff=60
3361 # test not 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 updated to $atime, should remain $d1<atime<$d2"
3368 do_facet $SINGLEMDS \
3369 lctl set_param -n mdd.*MDT0000*.atime_diff=$atime_diff
3371 run_test 39l "directory atime update ==========================="
3374 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3377 local far_past_mtime=$(date -d "May 29 1953" +%s)
3378 local far_past_atime=$(date -d "Dec 17 1903" +%s)
3380 touch -m -d @$far_past_mtime $DIR1/$tfile
3381 touch -a -d @$far_past_atime $DIR1/$tfile
3383 for (( i=0; i < 2; i++ )) ; do
3384 local timestamps=$(stat -c "%X %Y" $DIR1/$tfile)
3385 [ "$timestamps" = "$far_past_atime $far_past_mtime" ] || \
3386 error "atime or mtime set incorrectly"
3388 cancel_lru_locks osc
3389 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3392 run_test 39m "test atime and mtime before 1970"
3394 test_39n() { # LU-3832
3395 local atime_diff=$(do_facet $SINGLEMDS \
3396 lctl get_param -n mdd.*MDT0000*.atime_diff)
3401 do_facet $SINGLEMDS lctl set_param -n mdd.*MDT0000*.atime_diff=1
3404 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 status=noxfer
3405 atime0=$(stat -c %X $DIR/$tfile)
3408 $MULTIOP $DIR/$tfile oO_RDONLY:O_NOATIME:r4096c
3409 atime1=$(stat -c %X $DIR/$tfile)
3412 cancel_lru_locks mdc
3413 cancel_lru_locks osc
3414 $MULTIOP $DIR/$tfile oO_RDONLY:O_NOATIME:r4096c
3415 atime2=$(stat -c %X $DIR/$tfile)
3417 do_facet $SINGLEMDS \
3418 lctl set_param -n mdd.*MDT0000*.atime_diff=$atime_diff
3420 [ "$atime0" -eq "$atime1" ] || error "atime0 $atime0 != atime1 $atime1"
3421 [ "$atime1" -eq "$atime2" ] || error "atime0 $atime0 != atime1 $atime1"
3423 run_test 39n "check that O_NOATIME is honored"
3426 TESTDIR=$DIR/$tdir/$tfile
3427 [ -e $TESTDIR ] && rm -rf $TESTDIR
3434 links2=$(stat -c %h .)
3435 [ $(($links1 + 2)) != $links2 ] &&
3436 error "wrong links count $(($links1 + 2)) != $links2"
3438 links3=$(stat -c %h .)
3439 [ $(($links1 + 1)) != $links3 ] &&
3440 error "wrong links count $links1 != $links3"
3443 run_test 39o "directory cached attributes updated after create ========"
3446 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 2 MDTs" && return
3448 TESTDIR=$DIR/$tdir/$tfile
3449 [ -e $TESTDIR ] && rm -rf $TESTDIR
3450 test_mkdir -p $TESTDIR
3454 $LFS mkdir -i $MDTIDX $TESTDIR/remote_dir1
3455 $LFS mkdir -i $MDTIDX $TESTDIR/remote_dir2
3457 links2=$(stat -c %h .)
3458 [ $(($links1 + 2)) != $links2 ] &&
3459 error "wrong links count $(($links1 + 2)) != $links2"
3461 links3=$(stat -c %h .)
3462 [ $(($links1 + 1)) != $links3 ] &&
3463 error "wrong links count $links1 != $links3"
3466 run_test 39p "remote directory cached attributes updated after create ========"
3470 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1
3471 $RUNAS $OPENFILE -f O_WRONLY:O_TRUNC $DIR/$tfile &&
3472 error "openfile O_WRONLY:O_TRUNC $tfile failed"
3473 $CHECKSTAT -t file -s 4096 $DIR/$tfile ||
3474 error "$tfile is not 4096 bytes in size"
3476 run_test 40 "failed open(O_TRUNC) doesn't truncate ============="
3480 small_write $DIR/f41 18
3482 run_test 41 "test small file write + fstat ====================="
3484 count_ost_writes() {
3485 lctl get_param -n osc.*.stats |
3486 awk -vwrites=0 '/ost_write/ { writes += $2 } \
3487 END { printf("%0.0f", writes) }'
3494 BG_DIRTY_RATIO_SAVE=10
3495 MAX_BG_DIRTY_RATIO=25
3499 # in 2.6, restore /proc/sys/vm/dirty_writeback_centisecs,
3500 # dirty_ratio, dirty_background_ratio
3501 if [ -f /proc/sys/vm/dirty_writeback_centisecs ]; then
3502 sysctl -w vm.dirty_writeback_centisecs=$WRITEBACK_SAVE
3503 sysctl -w vm.dirty_background_ratio=$BG_DIRTY_RATIO_SAVE
3504 sysctl -w vm.dirty_ratio=$DIRTY_RATIO_SAVE
3506 # if file not here, we are a 2.4 kernel
3507 kill -CONT `pidof kupdated`
3512 # setup the trap first, so someone cannot exit the test at the
3513 # exact wrong time and mess up a machine
3514 trap start_writeback EXIT
3515 # in 2.6, save and 0 /proc/sys/vm/dirty_writeback_centisecs
3516 if [ -f /proc/sys/vm/dirty_writeback_centisecs ]; then
3517 WRITEBACK_SAVE=`sysctl -n vm.dirty_writeback_centisecs`
3518 sysctl -w vm.dirty_writeback_centisecs=0
3519 sysctl -w vm.dirty_writeback_centisecs=0
3520 # save and increase /proc/sys/vm/dirty_ratio
3521 DIRTY_RATIO_SAVE=`sysctl -n vm.dirty_ratio`
3522 sysctl -w vm.dirty_ratio=$MAX_DIRTY_RATIO
3523 # save and increase /proc/sys/vm/dirty_background_ratio
3524 BG_DIRTY_RATIO_SAVE=`sysctl -n vm.dirty_background_ratio`
3525 sysctl -w vm.dirty_background_ratio=$MAX_BG_DIRTY_RATIO
3527 # if file not here, we are a 2.4 kernel
3528 kill -STOP `pidof kupdated`
3532 # ensure that all stripes have some grant before we test client-side cache
3534 for i in `seq -f $DIR/f42-%g 1 $OSTCOUNT`; do
3535 dd if=/dev/zero of=$i bs=4k count=1
3540 # Tests 42* verify that our behaviour is correct WRT caching, file closure,
3541 # file truncation, and file removal.
3543 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3545 cancel_lru_locks osc
3547 sync; sleep 1; sync # just to be safe
3548 BEFOREWRITES=`count_ost_writes`
3549 lctl get_param -n osc.*[oO][sS][cC][_-]*.cur_grant_bytes | grep "[0-9]"
3550 dd if=/dev/zero of=$DIR/f42a bs=1024 count=100
3551 AFTERWRITES=`count_ost_writes`
3552 [ $BEFOREWRITES -eq $AFTERWRITES ] || \
3553 error "$BEFOREWRITES < $AFTERWRITES"
3556 run_test 42a "ensure that we don't flush on close =============="
3559 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3561 cancel_lru_locks osc
3564 dd if=/dev/zero of=$DIR/f42b bs=1024 count=100
3565 BEFOREWRITES=$(count_ost_writes)
3566 $MUNLINK $DIR/f42b || error "$MUNLINK $DIR/f42b: $?"
3567 AFTERWRITES=$(count_ost_writes)
3568 if [[ $BEFOREWRITES -lt $AFTERWRITES ]]; then
3569 error "$BEFOREWRITES < $AFTERWRITES on unlink"
3571 BEFOREWRITES=$(count_ost_writes)
3572 sync || error "sync: $?"
3573 AFTERWRITES=$(count_ost_writes)
3574 if [[ $BEFOREWRITES -lt $AFTERWRITES ]]; then
3575 error "$BEFOREWRITES < $AFTERWRITES on sync"
3577 dmesg | grep 'error from obd_brw_async' && error 'error writing back'
3581 run_test 42b "test destroy of file with cached dirty data ======"
3583 # if these tests just want to test the effect of truncation,
3584 # they have to be very careful. consider:
3585 # - the first open gets a {0,EOF}PR lock
3586 # - the first write conflicts and gets a {0, count-1}PW
3587 # - the rest of the writes are under {count,EOF}PW
3588 # - the open for truncate tries to match a {0,EOF}PR
3589 # for the filesize and cancels the PWs.
3590 # any number of fixes (don't get {0,EOF} on open, match
3591 # composite locks, do smarter file size management) fix
3592 # this, but for now we want these tests to verify that
3593 # the cancellation with truncate intent works, so we
3594 # start the file with a full-file pw lock to match against
3595 # until the truncate.
3600 cancel_lru_locks osc
3602 # prime the file with 0,EOF PW to match
3606 # now the real test..
3607 dd if=/dev/zero of=$file bs=1024 count=100
3608 BEFOREWRITES=`count_ost_writes`
3609 $TRUNCATE $file $offset
3610 cancel_lru_locks osc
3611 AFTERWRITES=`count_ost_writes`
3616 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3618 [ $BEFOREWRITES -eq $AFTERWRITES ] && \
3619 error "beforewrites $BEFOREWRITES == afterwrites $AFTERWRITES on truncate"
3622 run_test 42c "test partial truncate of file with cached dirty data"
3625 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3627 [ $BEFOREWRITES -eq $AFTERWRITES ] || \
3628 error "beforewrites $BEFOREWRITES != afterwrites $AFTERWRITES on truncate"
3631 run_test 42d "test complete truncate of file with cached dirty data"
3633 test_42e() { # bug22074
3634 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3635 local TDIR=$DIR/${tdir}e
3636 local pagesz=$(page_size)
3637 local pages=16 # hardcoded 16 pages, don't change it.
3638 local files=$((OSTCOUNT * 500)) # hopefully 500 files on each OST
3639 local proc_osc0="osc.${FSNAME}-OST0000-osc-[^MDT]*"
3643 test_mkdir -p $DIR/${tdir}e
3644 $SETSTRIPE -c 1 $TDIR
3645 createmany -o $TDIR/f $files
3647 max_dirty_mb=$($LCTL get_param -n $proc_osc0/max_dirty_mb)
3649 # we assume that with $OSTCOUNT files, at least one of them will
3650 # be allocated on OST0.
3651 warmup_files=$((OSTCOUNT * max_dirty_mb))
3652 createmany -o $TDIR/w $warmup_files
3654 # write a large amount of data into one file and sync, to get good
3655 # avail_grant number from OST.
3656 for ((i=0; i<$warmup_files; i++)); do
3657 idx=$($GETSTRIPE -i $TDIR/w$i)
3658 [ $idx -ne 0 ] && continue
3659 dd if=/dev/zero of=$TDIR/w$i bs="$max_dirty_mb"M count=1
3662 [[ $i -gt $warmup_files ]] && error "OST0 is still cold"
3664 $LCTL get_param $proc_osc0/cur_dirty_bytes
3665 $LCTL get_param $proc_osc0/cur_grant_bytes
3667 # create as much dirty pages as we can while not to trigger the actual
3668 # RPCs directly. but depends on the env, VFS may trigger flush during this
3669 # period, hopefully we are good.
3670 for ((i=0; i<$warmup_files; i++)); do
3671 idx=$($GETSTRIPE -i $TDIR/w$i)
3672 [ $idx -ne 0 ] && continue
3673 dd if=/dev/zero of=$TDIR/w$i bs=1M count=1 2>/dev/null
3675 $LCTL get_param $proc_osc0/cur_dirty_bytes
3676 $LCTL get_param $proc_osc0/cur_grant_bytes
3678 # perform the real test
3679 $LCTL set_param $proc_osc0/rpc_stats 0
3680 for ((;i<$files; i++)); do
3681 [ $($GETSTRIPE -i $TDIR/f$i) -eq 0 ] || continue
3682 dd if=/dev/zero of=$TDIR/f$i bs=$pagesz count=$pages 2>/dev/null
3685 $LCTL get_param $proc_osc0/rpc_stats
3688 local have_ppr=false
3689 $LCTL get_param $proc_osc0/rpc_stats |
3690 while read PPR RRPC RPCT RCUM BAR WRPC WPCT WCUM; do
3691 # skip lines until we are at the RPC histogram data
3692 [ "$PPR" == "pages" ] && have_ppr=true && continue
3693 $have_ppr || continue
3695 # we only want the percent stat for < 16 pages
3696 [[ $(echo $PPR | tr -d ':') -ge $pages ]] && break
3698 percent=$((percent + WPCT))
3699 if [[ $percent -gt 15 ]]; then
3700 error "less than 16-pages write RPCs" \
3707 run_test 42e "verify sub-RPC writes are not done synchronously"
3710 test_mkdir -p $DIR/$tdir
3711 cp -p /bin/ls $DIR/$tdir/$tfile
3712 $MULTIOP $DIR/$tdir/$tfile Ow_c &
3714 # give multiop a chance to open
3717 $DIR/$tdir/$tfile && error || true
3720 run_test 43 "execution of file opened for write should return -ETXTBSY"
3723 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3724 test_mkdir -p $DIR/$tdir
3725 cp -p `which $MULTIOP` $DIR/$tdir/multiop ||
3726 cp -p multiop $DIR/$tdir/multiop
3727 MULTIOP_PROG=$DIR/$tdir/multiop multiop_bg_pause $TMP/$tfile.junk O_c ||
3730 $MULTIOP $DIR/$tdir/multiop Oc && error "expected error, got success"
3731 kill -USR1 $MULTIOP_PID || return 2
3732 wait $MULTIOP_PID || return 3
3733 rm $TMP/$tfile.junk $DIR/$tdir/multiop
3735 run_test 43a "open(RDWR) of file being executed should return -ETXTBSY"
3738 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3739 test_mkdir -p $DIR/$tdir
3740 cp -p `which $MULTIOP` $DIR/$tdir/multiop ||
3741 cp -p multiop $DIR/$tdir/multiop
3742 MULTIOP_PROG=$DIR/$tdir/multiop multiop_bg_pause $TMP/$tfile.junk O_c ||
3745 $TRUNCATE $DIR/$tdir/multiop 0 && error "expected error, got success"
3746 kill -USR1 $MULTIOP_PID || return 2
3747 wait $MULTIOP_PID || return 3
3748 rm $TMP/$tfile.junk $DIR/$tdir/multiop
3750 run_test 43b "truncate of file being executed should return -ETXTBSY"
3753 local testdir="$DIR/$tdir"
3754 test_mkdir -p $DIR/$tdir
3756 ( cd $(dirname $SHELL) && md5sum $(basename $SHELL) ) | \
3757 ( cd $testdir && md5sum -c)
3759 run_test 43c "md5sum of copy into lustre========================"
3762 [[ $OSTCOUNT -lt 2 ]] && skip_env "skipping 2-stripe test" && return
3763 dd if=/dev/zero of=$DIR/f1 bs=4k count=1 seek=1023
3764 dd if=$DIR/f1 bs=4k count=1 > /dev/null
3766 run_test 44 "zero length read from a sparse stripe ============="
3769 local nstripe=$($LCTL lov_getconfig $DIR | grep default_stripe_count: |
3771 [ -z "$nstripe" ] && skip "can't get stripe info" && return
3772 [[ $nstripe -gt $OSTCOUNT ]] &&
3773 skip "Wrong default_stripe_count: $nstripe (OSTCOUNT: $OSTCOUNT)" &&
3775 local stride=$($LCTL lov_getconfig $DIR | grep default_stripe_size: |
3777 if [[ $nstripe -eq 0 || $nstripe -eq -1 ]]; then
3778 nstripe=$($LCTL lov_getconfig $DIR | grep obd_count: |
3782 OFFSETS="0 $((stride/2)) $((stride-1))"
3783 for offset in $OFFSETS; do
3784 for i in $(seq 0 $((nstripe-1))); do
3785 local GLOBALOFFSETS=""
3787 local size=$((((i + 2 * $nstripe )*$stride + $offset)))
3788 local myfn=$DIR/d44a-$size
3789 echo "--------writing $myfn at $size"
3790 ll_sparseness_write $myfn $size ||
3791 error "ll_sparseness_write"
3792 GLOBALOFFSETS="$GLOBALOFFSETS $size"
3793 ll_sparseness_verify $myfn $GLOBALOFFSETS ||
3794 error "ll_sparseness_verify $GLOBALOFFSETS"
3796 for j in $(seq 0 $((nstripe-1))); do
3798 size=$((((j + $nstripe )*$stride + $offset)))
3799 ll_sparseness_write $myfn $size ||
3800 error "ll_sparseness_write"
3801 GLOBALOFFSETS="$GLOBALOFFSETS $size"
3803 ll_sparseness_verify $myfn $GLOBALOFFSETS ||
3804 error "ll_sparseness_verify $GLOBALOFFSETS"
3809 run_test 44a "test sparse pwrite ==============================="
3813 for d in `lctl get_param -n osc.*.cur_dirty_bytes`; do
3819 before=`dirty_osc_total`
3820 echo executing "\"$*\""
3822 after=`dirty_osc_total`
3823 echo before $before, after $after
3826 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3828 # Obtain grants from OST if it supports it
3829 echo blah > ${f}_grant
3832 do_dirty_record "echo blah > $f"
3833 [[ $before -eq $after ]] && error "write wasn't cached"
3834 do_dirty_record "> $f"
3835 [[ $before -gt $after ]] || error "truncate didn't lower dirty count"
3836 do_dirty_record "echo blah > $f"
3837 [[ $before -eq $after ]] && error "write wasn't cached"
3838 do_dirty_record "sync"
3839 [[ $before -gt $after ]] || error "writeback didn't lower dirty count"
3840 do_dirty_record "echo blah > $f"
3841 [[ $before -eq $after ]] && error "write wasn't cached"
3842 do_dirty_record "cancel_lru_locks osc"
3843 [[ $before -gt $after ]] ||
3844 error "lock cancellation didn't lower dirty count"
3847 run_test 45 "osc io page accounting ============================"
3849 # in a 2 stripe file (lov.sh), page 1023 maps to page 511 in its object. this
3850 # test tickles a bug where re-dirtying a page was failing to be mapped to the
3851 # objects offset and an assert hit when an rpc was built with 1023's mapped
3852 # offset 511 and 511's raw 511 offset. it also found general redirtying bugs.
3854 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3858 dd if=/dev/zero of=$f bs=`page_size` seek=511 count=1
3860 dd conv=notrunc if=/dev/zero of=$f bs=`page_size` seek=1023 count=1
3861 dd conv=notrunc if=/dev/zero of=$f bs=`page_size` seek=511 count=1
3865 run_test 46 "dirtying a previously written page ================"
3867 # test_47 is removed "Device nodes check" is moved to test_28
3869 test_48a() { # bug 2399
3870 [ $(facet_fstype $SINGLEMDS) = "zfs" ] &&
3871 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.3.63) ] &&
3872 skip "MDS prior to 2.3.63 handle ZFS dir .. incorrectly" &&
3874 test_mkdir $DIR/$tdir
3876 mv $DIR/$tdir $DIR/$tdir.new || error "move directory failed"
3877 test_mkdir $DIR/$tdir || error "recreate directory failed"
3878 touch foo || error "'touch foo' failed after recreating cwd"
3879 test_mkdir bar || error "'mkdir foo' failed after recreating cwd"
3880 touch .foo || error "'touch .foo' failed after recreating cwd"
3881 test_mkdir .bar || error "'mkdir .foo' failed after recreating cwd"
3882 ls . > /dev/null || error "'ls .' failed after recreating cwd"
3883 ls .. > /dev/null || error "'ls ..' failed after removing cwd"
3884 cd . || error "'cd .' failed after recreating cwd"
3885 test_mkdir . && error "'mkdir .' worked after recreating cwd"
3886 rmdir . && error "'rmdir .' worked after recreating cwd"
3887 ln -s . baz || error "'ln -s .' failed after recreating cwd"
3888 cd .. || error "'cd ..' failed after recreating cwd"
3890 run_test 48a "Access renamed working dir (should return errors)="
3892 test_48b() { # bug 2399
3894 test_mkdir $DIR/$tdir
3896 rmdir $DIR/$tdir || error "remove cwd $DIR/$tdir failed"
3897 touch foo && error "'touch foo' worked after removing cwd"
3898 test_mkdir foo && error "'mkdir foo' worked after removing cwd"
3899 touch .foo && error "'touch .foo' worked after removing cwd"
3900 test_mkdir .foo && error "'mkdir .foo' worked after removing cwd"
3901 ls . > /dev/null && error "'ls .' worked after removing cwd"
3902 ls .. > /dev/null || error "'ls ..' failed after removing cwd"
3903 is_patchless || ( cd . && error "'cd .' worked after removing cwd" )
3904 test_mkdir . && error "'mkdir .' worked after removing cwd"
3905 rmdir . && error "'rmdir .' worked after removing cwd"
3906 ln -s . foo && error "'ln -s .' worked after removing cwd"
3907 cd .. || echo "'cd ..' failed after removing cwd `pwd`" #bug 3517
3909 run_test 48b "Access removed working dir (should return errors)="
3911 test_48c() { # bug 2350
3912 #lctl set_param debug=-1
3915 test_mkdir -p $DIR/$tdir/dir
3917 $TRACE rmdir $DIR/$tdir/dir || error "remove cwd $DIR/$tdir/dir failed"
3918 $TRACE touch foo && error "touch foo worked after removing cwd"
3919 $TRACE test_mkdir foo && error "'mkdir foo' worked after removing cwd"
3920 touch .foo && error "touch .foo worked after removing cwd"
3921 test_mkdir .foo && error "mkdir .foo worked after removing cwd"
3922 $TRACE ls . && error "'ls .' worked after removing cwd"
3923 $TRACE ls .. || error "'ls ..' failed after removing cwd"
3924 is_patchless || ( $TRACE cd . &&
3925 error "'cd .' worked after removing cwd" )
3926 $TRACE test_mkdir . && error "'mkdir .' worked after removing cwd"
3927 $TRACE rmdir . && error "'rmdir .' worked after removing cwd"
3928 $TRACE ln -s . foo && error "'ln -s .' worked after removing cwd"
3929 $TRACE cd .. || echo "'cd ..' failed after removing cwd `pwd`" #bug 3415
3931 run_test 48c "Access removed working subdir (should return errors)"
3933 test_48d() { # bug 2350
3934 #lctl set_param debug=-1
3937 test_mkdir -p $DIR/$tdir/dir
3939 $TRACE rmdir $DIR/$tdir/dir || error "remove cwd $DIR/$tdir/dir failed"
3940 $TRACE rmdir $DIR/$tdir || error "remove parent $DIR/$tdir failed"
3941 $TRACE touch foo && error "'touch foo' worked after removing parent"
3942 $TRACE test_mkdir foo && error "mkdir foo worked after removing parent"
3943 touch .foo && error "'touch .foo' worked after removing parent"
3944 test_mkdir .foo && error "mkdir .foo worked after removing parent"
3945 $TRACE ls . && error "'ls .' worked after removing parent"
3946 $TRACE ls .. && error "'ls ..' worked after removing parent"
3947 is_patchless || ( $TRACE cd . &&
3948 error "'cd .' worked after recreate parent" )
3949 $TRACE test_mkdir . && error "'mkdir .' worked after removing parent"
3950 $TRACE rmdir . && error "'rmdir .' worked after removing parent"
3951 $TRACE ln -s . foo && error "'ln -s .' worked after removing parent"
3952 is_patchless || ( $TRACE cd .. &&
3953 error "'cd ..' worked after removing parent" || true )
3955 run_test 48d "Access removed parent subdir (should return errors)"
3957 test_48e() { # bug 4134
3958 #lctl set_param debug=-1
3961 test_mkdir -p $DIR/$tdir/dir
3963 $TRACE rmdir $DIR/$tdir/dir || error "remove cwd $DIR/$tdir/dir failed"
3964 $TRACE rmdir $DIR/$tdir || error "remove parent $DIR/$tdir failed"
3965 $TRACE touch $DIR/$tdir || error "'touch $DIR/$tdir' failed"
3966 $TRACE chmod +x $DIR/$tdir || error "'chmod +x $DIR/$tdir' failed"
3967 # On a buggy kernel addition of "touch foo" after cd .. will
3968 # produce kernel oops in lookup_hash_it
3969 touch ../foo && error "'cd ..' worked after recreate parent"
3971 $TRACE rm $DIR/$tdir || error "rm '$DIR/$tdir' failed"
3973 run_test 48e "Access to recreated parent subdir (should return errors)"
3975 test_49() { # LU-1030
3976 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3977 # get ost1 size - lustre-OST0000
3978 ost1_size=$(do_facet ost1 $LFS df | grep ${ost1_svc} |
3980 # write 800M at maximum
3981 [[ $ost1_size -lt 2 ]] && ost1_size=2
3982 [[ $ost1_size -gt 819200 ]] && ost1_size=819200
3984 $SETSTRIPE -c 1 -i 0 $DIR/$tfile
3985 dd if=/dev/zero of=$DIR/$tfile bs=4k count=$((ost1_size >> 2)) &
3988 # change max_pages_per_rpc while writing the file
3989 local osc1_mppc=osc.$(get_osc_import_name client ost1).max_pages_per_rpc
3990 local orig_mppc=$($LCTL get_param -n $osc1_mppc)
3991 # loop until dd process exits
3992 while ps ax -opid | grep -wq $dd_pid; do
3993 $LCTL set_param $osc1_mppc=$((RANDOM % 256 + 1))
3994 sleep $((RANDOM % 5 + 1))
3996 # restore original max_pages_per_rpc
3997 $LCTL set_param $osc1_mppc=$orig_mppc
3998 rm $DIR/$tfile || error "rm $DIR/$tfile failed"
4000 run_test 49 "Change max_pages_per_rpc won't break osc extent"
4004 test_mkdir $DIR/$tdir
4006 ls /proc/$$/cwd || error "ls /proc/$$/cwd failed"
4008 run_test 50 "special situations: /proc symlinks ==============="
4010 test_51a() { # was test_51
4011 # bug 1516 - create an empty entry right after ".." then split dir
4012 test_mkdir -c1 $DIR/$tdir
4013 touch $DIR/$tdir/foo
4014 $MCREATE $DIR/$tdir/bar
4016 createmany -m $DIR/$tdir/longfile 201
4018 while [[ $(ls -sd $DIR/$tdir | awk '{ print $1 }') -eq 4 ]]; do
4019 $MCREATE $DIR/$tdir/longfile$FNUM
4024 ls -l $DIR/$tdir > /dev/null || error "ls -l $DIR/$tdir failed"
4026 run_test 51a "special situations: split htree with empty entry =="
4028 export NUMTEST=70000
4030 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4031 local BASE=$DIR/d${base}.${TESTSUITE}
4033 # cleanup the directory
4036 test_mkdir -p -c1 $BASE
4040 local mdtidx=$(printf "%04x" $($LFS getstripe -M $BASE))
4041 local numfree=$(lctl get_param -n mdc.$FSNAME-MDT$mdtidx*.filesfree)
4042 [[ $numfree -lt 21000 ]] &&
4043 skip "not enough free inodes ($numfree) on MDT$mdtidx" &&
4046 [[ $numfree -lt $NUMTEST ]] && NUMTEST=$(($numfree - 50)) &&
4047 echo "reduced count to $NUMTEST due to inodes on MDT$mdtidx"
4049 # need to check free space for the directories as well
4050 local blkfree=$(lctl get_param -n mdc.$FSNAME-MDT$mdtidx*.kbytesavail)
4051 numfree=$((blkfree / 4))
4052 [[ $numfree -lt $NUMTEST ]] && NUMTEST=$((numfree - 50)) &&
4053 echo "reduced count to $NUMTEST due to blocks on MDT$mdtidx"
4055 createmany -d $BASE/d $NUMTEST && echo $NUMTEST > $BASE/fnum ||
4059 echo "failed" > $BASE/fnum
4060 error "failed to create $NUMTEST subdirs in MDT$mdtidx:$BASE"
4063 run_test 51b "exceed 64k subdirectory nlink limit"
4065 test_51ba() { # LU-993
4066 local BASE=$DIR/d${base}.${TESTSUITE}
4067 # unlink all but 100 subdirectories, then check it still works
4069 [ -f $BASE/fnum ] && local NUMPREV=$(cat $BASE/fnum) && rm $BASE/fnum
4071 [ "$NUMPREV" != "failed" ] && NUMTEST=$NUMPREV
4072 local DELETE=$((NUMTEST - LEFT))
4074 # continue on to run this test even if 51b didn't finish,
4075 # just to delete the many subdirectories created.
4076 [ ! -d "${BASE}/d1" ] && skip "test_51b() not run" && return 0
4078 # for ldiskfs the nlink count should be 1, but this is OSD specific
4079 # and so this is listed for informational purposes only
4080 echo "nlink before: $(stat -c %h $BASE), created before: $NUMTEST"
4081 unlinkmany -d $BASE/d $DELETE
4084 if [ $RC -ne 0 ]; then
4085 if [ "$NUMPREV" == "failed" ]; then
4086 skip "previous setup failed"
4089 error "unlink of first $DELETE subdirs failed"
4094 echo "nlink between: $(stat -c %h $BASE)"
4095 # trim the first line of ls output
4096 local FOUND=$(($(ls -l ${BASE} | wc -l) - 1))
4097 [ $FOUND -ne $LEFT ] &&
4098 error "can't find subdirs: found only $FOUND/$LEFT"
4100 unlinkmany -d $BASE/d $DELETE $LEFT ||
4101 error "unlink of second $LEFT subdirs failed"
4102 # regardless of whether the backing filesystem tracks nlink accurately
4103 # or not, the nlink count shouldn't be more than "." and ".." here
4104 local AFTER=$(stat -c %h $BASE)
4105 [[ $AFTER -gt 2 ]] && error "nlink after: $AFTER > 2" ||
4106 echo "nlink after: $AFTER"
4108 run_test 51ba "verify nlink for many subdirectory cleanup"
4111 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4112 [[ $OSTCOUNT -lt 3 ]] &&
4113 skip_env "skipping test with few OSTs" && return
4114 test_mkdir -p $DIR/$tdir
4115 createmany -o $DIR/$tdir/t- 1000
4116 $GETSTRIPE $DIR/$tdir > $TMP/files
4117 for N in $(seq 0 $((OSTCOUNT - 1))); do
4118 OBJS[$N]=$(awk -vobjs=0 '($1 == '$N') { objs += 1 } \
4119 END { printf("%0.0f", objs) }' $TMP/files)
4120 OBJS0[$N]=$(grep -A 1 idx $TMP/files | awk -vobjs=0 \
4121 '($1 == '$N') { objs += 1 } \
4122 END { printf("%0.0f", objs) }')
4123 log "OST$N has ${OBJS[$N]} objects, ${OBJS0[$N]} are index 0"
4125 unlinkmany $DIR/$tdir/t- 1000
4128 for N in $(seq 1 $((OSTCOUNT - 1))); do
4129 [[ ${OBJS[$N]} -lt $((${OBJS[$NLAST]} - 20)) ]] &&
4130 error "OST $N has less objects vs OST $NLAST" \
4131 " (${OBJS[$N]} < ${OBJS[$NLAST]}"
4132 [[ ${OBJS[$N]} -gt $((${OBJS[$NLAST]} + 20)) ]] &&
4133 error "OST $N has less objects vs OST $NLAST" \
4134 " (${OBJS[$N]} < ${OBJS[$NLAST]}"
4136 [[ ${OBJS0[$N]} -lt $((${OBJS0[$NLAST]} - 20)) ]] &&
4137 error "OST $N has less #0 objects vs OST $NLAST" \
4138 " (${OBJS0[$N]} < ${OBJS0[$NLAST]}"
4139 [[ ${OBJS0[$N]} -gt $((${OBJS0[$NLAST]} + 20)) ]] &&
4140 error "OST $N has less #0 objects vs OST $NLAST" \
4141 " (${OBJS0[$N]} < ${OBJS0[$NLAST]}"
4145 run_test 51d "check object distribution ===================="
4148 if [ "$(facet_fstype $SINGLEMDS)" != ldiskfs ]; then
4149 skip "Only applicable to ldiskfs-based MDTs"
4153 test_mkdir -c1 $DIR/$tdir || error "create $tdir failed"
4154 test_mkdir -c1 $DIR/$tdir/d0 || error "create d0 failed"
4156 touch $DIR/$tdir/d0/foo
4157 createmany -l $DIR/$tdir/d0/foo $DIR/$tdir/d0/f- 65001 &&
4158 error "file exceed 65000 nlink limit!"
4159 unlinkmany $DIR/$tdir/d0/f- 65001
4162 run_test 51e "check file nlink limit"
4165 [ -f $DIR/$tdir/foo ] && chattr -a $DIR/$tdir/foo
4166 test_mkdir -p $DIR/$tdir
4167 touch $DIR/$tdir/foo
4168 chattr +a $DIR/$tdir/foo || error "chattr +a failed"
4169 echo bar >> $DIR/$tdir/foo || error "append bar failed"
4170 cp /etc/hosts $DIR/$tdir/foo && error "cp worked"
4171 rm -f $DIR/$tdir/foo 2>/dev/null && error "rm worked"
4172 link $DIR/$tdir/foo $DIR/$tdir/foo_link 2>/dev/null &&
4174 echo foo >> $DIR/$tdir/foo || error "append foo failed"
4175 mrename $DIR/$tdir/foo $DIR/$tdir/foo_ren && error "rename worked"
4176 lsattr $DIR/$tdir/foo | egrep -q "^-+a[-e]+ $DIR/$tdir/foo" ||
4178 chattr -a $DIR/$tdir/foo || error "chattr -a failed"
4179 cp -r $DIR/$tdir /tmp/
4180 rm -fr $DIR/$tdir || error "cleanup rm failed"
4182 run_test 52a "append-only flag test (should return errors) ====="
4185 [ -f $DIR/$tdir/foo ] && chattr -i $DIR/$tdir/foo
4186 test_mkdir -p $DIR/$tdir
4187 touch $DIR/$tdir/foo
4188 chattr +i $DIR/$tdir/foo || error "chattr +i failed"
4189 cat test > $DIR/$tdir/foo && error "cat test worked"
4190 cp /etc/hosts $DIR/$tdir/foo && error "cp worked"
4191 rm -f $DIR/$tdir/foo 2>/dev/null && error "rm worked"
4192 link $DIR/$tdir/foo $DIR/$tdir/foo_link 2>/dev/null &&
4194 echo foo >> $DIR/$tdir/foo && error "echo worked"
4195 mrename $DIR/$tdir/foo $DIR/$tdir/foo_ren && error "rename worked"
4196 [ -f $DIR/$tdir/foo ] || error "$tdir/foo is not a file"
4197 [ -f $DIR/$tdir/foo_ren ] && error "$tdir/foo_ren is not a file"
4198 lsattr $DIR/$tdir/foo | egrep -q "^-+i[-e]+ $DIR/$tdir/foo" ||
4200 chattr -i $DIR/$tdir/foo || error "chattr failed"
4202 rm -fr $DIR/$tdir || error "unable to remove $DIR/$tdir"
4204 run_test 52b "immutable flag test (should return errors) ======="
4207 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4208 remote_mds_nodsh && skip "remote MDS with nodsh" && return
4209 remote_ost_nodsh && skip "remote OST with nodsh" && return
4222 local support_last_seq=true
4224 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.3.60) ]] ||
4225 support_last_seq=false
4228 local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS)
4230 for value in $(do_facet $SINGLEMDS \
4231 $LCTL get_param osc.$mdtosc.prealloc_last_id) ; do
4232 param=$(echo ${value[0]} | cut -d "=" -f1)
4233 ostname=$(echo $param | cut -d "." -f2 | cut -d - -f 1-2)
4235 if $support_last_seq; then
4236 param_seq=$(echo $param |
4237 sed -e s/prealloc_last_id/prealloc_last_seq/g)
4238 mds_last_seq=$(do_facet $SINGLEMDS \
4239 $LCTL get_param -n $param_seq)
4241 mds_last=$(do_facet $SINGLEMDS $LCTL get_param -n $param)
4243 ostnum=$(index_from_ostuuid ${ostname}_UUID)
4244 node=$(facet_active_host ost$((ostnum+1)))
4245 param="obdfilter.$ostname.last_id"
4246 for ost_last in $(do_node $node $LCTL get_param -n $param) ; do
4247 echo "$ostname.last_id=$ost_last; MDS.last_id=$mds_last"
4248 ost_last_id=$ost_last
4250 if $support_last_seq; then
4251 ost_last_id=$(echo $ost_last |
4252 awk -F':' '{print $2}' |
4254 ost_last_seq=$(echo $ost_last |
4255 awk -F':' '{print $1}')
4256 [[ $ost_last_seq = $mds_last_seq ]] || continue
4259 if [[ $ost_last_id != $mds_last ]]; then
4260 error "$ost_last_id != $mds_last"
4267 $found || error "can not match last_seq/last_id for $mdtosc"
4270 run_test 53 "verify that MDS and OSTs agree on pre-creation ===="
4273 $SOCKETSERVER $DIR/socket ||
4274 error "$SOCKETSERVER $DIR/socket failed: $?"
4275 $SOCKETCLIENT $DIR/socket ||
4276 error "$SOCKETCLIENT $DIR/socket failed: $?"
4277 $MUNLINK $DIR/socket || error "$MUNLINK $DIR/socket failed: $?"
4279 run_test 54a "unix domain socket test =========================="
4285 dd if=/dev/zero of=$f bs=$(page_size) count=1
4287 run_test 54b "char device works in lustre ======================"
4290 [ -b /dev/loop/0 ] && LOOPBASE=/dev/loop/
4291 [ -b /dev/loop0 ] && LOOPBASE=/dev/loop
4292 [ -z "$LOOPBASE" ] && echo "/dev/loop/0 and /dev/loop0 gone?" && return
4294 for i in $(seq 3 7); do
4295 losetup $LOOPBASE$i > /dev/null 2>&1 && continue
4303 loopdev="$DIR/loop54c"
4306 $UMOUNT $DIR/$tdir || rc=$?
4307 losetup -d $loopdev || true
4308 losetup -d $LOOPDEV || true
4309 rm -rf $loopdev $DIR/$tfile $DIR/$tdir
4314 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4315 loopdev="$DIR/loop54c"
4318 [ -z "$LOOPNUM" ] && echo "couldn't find empty loop device" && return
4319 trap cleanup_54c EXIT
4320 mknod $loopdev b 7 $LOOPNUM
4321 echo "make a loop file system with $DIR/$tfile on $loopdev ($LOOPNUM)."
4322 dd if=/dev/zero of=$DIR/$tfile bs=$(get_page_size client) seek=1024 count=1 > /dev/null
4323 losetup $loopdev $DIR/$tfile ||
4324 error "can't set up $loopdev for $DIR/$tfile"
4325 mkfs.ext2 $loopdev || error "mke2fs on $loopdev"
4326 test_mkdir -p $DIR/$tdir
4327 mount -t ext2 $loopdev $DIR/$tdir ||
4328 error "error mounting $loopdev on $DIR/$tdir"
4329 dd if=/dev/zero of=$DIR/$tdir/tmp bs=$(get_page_size client) count=30 ||
4332 dd if=$DIR/$tdir/tmp of=/dev/zero bs=$(get_page_size client) count=30 ||
4336 run_test 54c "block device works in lustre ====================="
4342 [ "$string" = $(echo $string > $f | cat $f) ] || error "$f != $string"
4344 run_test 54d "fifo device works in lustre ======================"
4349 cp -aL /dev/console $f
4350 echo $string > $f || error "echo $string to $f failed"
4352 run_test 54e "console/tty device works in lustre ======================"
4354 #The test_55 used to be iopen test and it was removed by bz#24037.
4355 #run_test 55 "check iopen_connect_dentry() ======================"
4357 test_56a() { # was test_56
4360 test_mkdir -p $DIR/$tdir/dir
4362 NUMFILESx2=$(($NUMFILES * 2))
4363 for i in $(seq 1 $NUMFILES); do
4364 touch $DIR/$tdir/file$i
4365 touch $DIR/$tdir/dir/file$i
4368 # test lfs getstripe with --recursive
4369 FILENUM=$($GETSTRIPE --recursive $DIR/$tdir | grep -c obdidx)
4370 [[ $FILENUM -eq $NUMFILESx2 ]] ||
4371 error "$GETSTRIPE --recursive: found $FILENUM, not $NUMFILESx2"
4372 FILENUM=$($GETSTRIPE $DIR/$tdir | grep -c obdidx)
4373 [[ $FILENUM -eq $NUMFILES ]] ||
4374 error "$GETSTRIPE $DIR/$tdir: found $FILENUM, not $NUMFILES"
4375 echo "$GETSTRIPE --recursive passed."
4377 # test lfs getstripe with file instead of dir
4378 FILENUM=$($GETSTRIPE $DIR/$tdir/file1 | grep -c obdidx)
4379 [[ $FILENUM -eq 1 ]] ||
4380 error "$GETSTRIPE $DIR/$tdir/file1: found $FILENUM, not 1"
4381 echo "$GETSTRIPE file1 passed."
4383 #test lfs getstripe with --verbose
4384 [[ $($GETSTRIPE --verbose $DIR/$tdir |
4385 grep -c lmm_magic) -eq $NUMFILES ]] ||
4386 error "$GETSTRIPE --verbose $DIR/$tdir: want $NUMFILES"
4387 [[ $($GETSTRIPE $DIR/$tdir | grep -c lmm_magic) -eq 0 ]] ||
4388 rror "$GETSTRIPE $DIR/$tdir: showed lmm_magic"
4389 echo "$GETSTRIPE --verbose passed."
4391 #test lfs getstripe with --obd
4392 $GETSTRIPE --obd wrong_uuid $DIR/$tdir 2>&1 |
4393 grep -q "unknown obduuid" ||
4394 error "$GETSTRIPE --obd wrong_uuid should return error message"
4396 [[ $OSTCOUNT -lt 2 ]] &&
4397 skip_env "skipping other $GETSTRIPE --obd test" && return
4400 OBDUUID=$(ostuuid_from_index $OSTIDX)
4401 FILENUM=$($GETSTRIPE -ir $DIR/$tdir | grep "^$OSTIDX\$" | wc -l)
4402 FOUND=$($GETSTRIPE -r --obd $OBDUUID $DIR/$tdir | grep obdidx | wc -l)
4403 [[ $FOUND -eq $FILENUM ]] ||
4404 error "$GETSTRIPE --obd wrong: found $FOUND, expected $FILENUM"
4405 [[ $($GETSTRIPE -r -v --obd $OBDUUID $DIR/$tdir |
4406 sed '/^[ ]*'${OSTIDX}'[ ]/d' |
4407 sed -n '/^[ ]*[0-9][0-9]*[ ]/p' | wc -l) -eq 0 ]] ||
4408 error "$GETSTRIPE --obd: should not show file on other obd"
4409 echo "$GETSTRIPE --obd passed"
4411 run_test 56a "check $GETSTRIPE"
4416 local LOCAL_NUMFILES="$1"
4417 local LOCAL_NUMDIRS="$2"
4418 local MKDIR_PARAMS="$3"
4419 local DIR_STRIPE_PARAMS="$4"
4421 if [ ! -d "$TDIR" ] ; then
4422 test_mkdir -p $DIR_STRIPE_PARAMS $TDIR
4423 [ "$MKDIR_PARAMS" ] && $SETSTRIPE $MKDIR_PARAMS $TDIR
4424 for i in `seq 1 $LOCAL_NUMFILES` ; do
4427 for i in `seq 1 $LOCAL_NUMDIRS` ; do
4428 test_mkdir $DIR_STRIPE_PARAMS $TDIR/dir$i
4429 for j in `seq 1 $LOCAL_NUMFILES` ; do
4430 touch $TDIR/dir$i/file$j
4436 setup_56_special() {
4440 if [ ! -e "$TDIR/loop1b" ] ; then
4441 for i in `seq 1 $LOCAL_NUMFILES` ; do
4442 mknod $TDIR/loop${i}b b 7 $i
4443 mknod $TDIR/null${i}c c 1 3
4444 ln -s $TDIR/file1 $TDIR/link${i}l
4446 for i in `seq 1 $LOCAL_NUMDIRS` ; do
4447 mknod $TDIR/dir$i/loop${i}b b 7 $i
4448 mknod $TDIR/dir$i/null${i}c c 1 3
4449 ln -s $TDIR/dir$i/file1 $TDIR/dir$i/link${i}l
4458 setup_56 $NUMFILES $NUMDIRS
4460 EXPECTED=$(($NUMDIRS + 2))
4461 # test lfs find with -name
4462 for i in $(seq 1 $NUMFILES) ; do
4463 NUMS=$($LFIND -name "*$i" $TDIR | wc -l)
4464 [ $NUMS -eq $EXPECTED ] ||
4465 error "lfs find -name \"*$i\" $TDIR wrong: "\
4466 "found $NUMS, expected $EXPECTED"
4469 run_test 56g "check lfs find -name ============================="
4475 setup_56 $NUMFILES $NUMDIRS
4477 EXPECTED=$(((NUMDIRS + 1) * (NUMFILES - 1) + NUMFILES))
4478 # test lfs find with ! -name
4479 for i in $(seq 1 $NUMFILES) ; do
4480 NUMS=$($LFIND ! -name "*$i" $TDIR | wc -l)
4481 [ $NUMS -eq $EXPECTED ] ||
4482 error "lfs find ! -name \"*$i\" $TDIR wrong: "\
4483 "found $NUMS, expected $EXPECTED"
4486 run_test 56h "check lfs find ! -name ============================="
4490 test_mkdir -p $DIR/$tdir
4491 UUID=$(ostuuid_from_index 0 $DIR/$tdir)
4492 CMD="$LFIND -ost $UUID $DIR/$tdir"
4494 [ -z "$OUT" ] || error "\"$CMD\" returned directory '$OUT'"
4496 run_test 56i "check 'lfs find -ost UUID' skips directories ======="
4500 setup_56_special $NUMFILES $NUMDIRS
4502 EXPECTED=$((NUMDIRS + 1))
4503 CMD="$LFIND -type d $TDIR"
4504 NUMS=$($CMD | wc -l)
4505 [ $NUMS -eq $EXPECTED ] ||
4506 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4508 run_test 56j "check lfs find -type d ============================="
4512 setup_56_special $NUMFILES $NUMDIRS
4514 EXPECTED=$(((NUMDIRS + 1) * NUMFILES))
4515 CMD="$LFIND -type f $TDIR"
4516 NUMS=$($CMD | wc -l)
4517 [ $NUMS -eq $EXPECTED ] ||
4518 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4520 run_test 56k "check lfs find -type f ============================="
4524 setup_56_special $NUMFILES $NUMDIRS
4526 EXPECTED=$((NUMDIRS + NUMFILES))
4527 CMD="$LFIND -type b $TDIR"
4528 NUMS=$($CMD | wc -l)
4529 [ $NUMS -eq $EXPECTED ] ||
4530 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4532 run_test 56l "check lfs find -type b ============================="
4536 setup_56_special $NUMFILES $NUMDIRS
4538 EXPECTED=$((NUMDIRS + NUMFILES))
4539 CMD="$LFIND -type c $TDIR"
4540 NUMS=$($CMD | wc -l)
4541 [ $NUMS -eq $EXPECTED ] ||
4542 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4544 run_test 56m "check lfs find -type c ============================="
4548 setup_56_special $NUMFILES $NUMDIRS
4550 EXPECTED=$((NUMDIRS + NUMFILES))
4551 CMD="$LFIND -type l $TDIR"
4552 NUMS=$($CMD | wc -l)
4553 [ $NUMS -eq $EXPECTED ] ||
4554 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4556 run_test 56n "check lfs find -type l ============================="
4560 setup_56 $NUMFILES $NUMDIRS
4561 utime $TDIR/file1 > /dev/null || error "utime (1)"
4562 utime $TDIR/file2 > /dev/null || error "utime (2)"
4563 utime $TDIR/dir1 > /dev/null || error "utime (3)"
4564 utime $TDIR/dir2 > /dev/null || error "utime (4)"
4565 utime $TDIR/dir1/file1 > /dev/null || error "utime (5)"
4566 dd if=/dev/zero count=1 >> $TDIR/dir1/file1 && sync
4569 NUMS=`$LFIND -mtime +0 $TDIR | wc -l`
4570 [ $NUMS -eq $EXPECTED ] || \
4571 error "lfs find -mtime +0 $TDIR wrong: found $NUMS, expected $EXPECTED"
4574 CMD="$LFIND -mtime 0 $TDIR"
4575 NUMS=$($CMD | wc -l)
4576 [ $NUMS -eq $EXPECTED ] ||
4577 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4579 run_test 56o "check lfs find -mtime for old files =========================="
4582 [ $RUNAS_ID -eq $UID ] &&
4583 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
4586 setup_56 $NUMFILES $NUMDIRS
4588 chown $RUNAS_ID $TDIR/file* || error "chown $DIR/${tdir}g/file$i failed"
4590 CMD="$LFIND -uid $RUNAS_ID $TDIR"
4591 NUMS=$($CMD | wc -l)
4592 [ $NUMS -eq $EXPECTED ] || \
4593 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4595 EXPECTED=$(((NUMFILES + 1) * NUMDIRS + 1))
4596 CMD="$LFIND ! -uid $RUNAS_ID $TDIR"
4597 NUMS=$($CMD | wc -l)
4598 [ $NUMS -eq $EXPECTED ] || \
4599 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4601 run_test 56p "check lfs find -uid and ! -uid ==============================="
4604 [ $RUNAS_ID -eq $UID ] &&
4605 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
4608 setup_56 $NUMFILES $NUMDIRS
4610 chgrp $RUNAS_GID $TDIR/file* || error "chown $TDIR/file$i failed"
4613 CMD="$LFIND -gid $RUNAS_GID $TDIR"
4614 NUMS=$($CMD | wc -l)
4615 [ $NUMS -eq $EXPECTED ] ||
4616 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4618 EXPECTED=$(( ($NUMFILES+1) * $NUMDIRS + 1))
4619 CMD="$LFIND ! -gid $RUNAS_GID $TDIR"
4620 NUMS=$($CMD | wc -l)
4621 [ $NUMS -eq $EXPECTED ] ||
4622 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4624 run_test 56q "check lfs find -gid and ! -gid ==============================="
4628 setup_56 $NUMFILES $NUMDIRS
4631 CMD="$LFIND -size 0 -type f $TDIR"
4632 NUMS=$($CMD | wc -l)
4633 [ $NUMS -eq $EXPECTED ] ||
4634 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4636 CMD="$LFIND ! -size 0 -type f $TDIR"
4637 NUMS=$($CMD | wc -l)
4638 [ $NUMS -eq $EXPECTED ] ||
4639 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4640 echo "test" > $TDIR/$tfile
4641 echo "test2" > $TDIR/$tfile.2 && sync
4643 CMD="$LFIND -size 5 -type f $TDIR"
4644 NUMS=$($CMD | wc -l)
4645 [ $NUMS -eq $EXPECTED ] ||
4646 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4648 CMD="$LFIND -size +5 -type f $TDIR"
4649 NUMS=$($CMD | wc -l)
4650 [ $NUMS -eq $EXPECTED ] ||
4651 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4653 CMD="$LFIND -size +0 -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 -5 -type f $TDIR"
4664 NUMS=$($CMD | wc -l)
4665 [ $NUMS -eq $EXPECTED ] ||
4666 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4668 run_test 56r "check lfs find -size works =========================="
4670 test_56s() { # LU-611
4672 setup_56 $NUMFILES $NUMDIRS "-c $OSTCOUNT"
4674 if [[ $OSTCOUNT -gt 1 ]]; then
4675 $SETSTRIPE -c 1 $TDIR/$tfile.{0,1,2,3}
4679 ONESTRIPE=$(((NUMDIRS + 1) * NUMFILES))
4683 EXPECTED=$(((NUMDIRS + 1) * NUMFILES))
4684 CMD="$LFIND -stripe-count $OSTCOUNT -type f $TDIR"
4685 NUMS=$($CMD | wc -l)
4686 [ $NUMS -eq $EXPECTED ] || {
4688 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4691 EXPECTED=$(((NUMDIRS + 1) * NUMFILES + EXTRA))
4692 CMD="$LFIND -stripe-count +0 -type f $TDIR"
4693 NUMS=$($CMD | wc -l)
4694 [ $NUMS -eq $EXPECTED ] || {
4696 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4700 CMD="$LFIND -stripe-count 1 -type f $TDIR"
4701 NUMS=$($CMD | wc -l)
4702 [ $NUMS -eq $EXPECTED ] || {
4704 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4707 CMD="$LFIND -stripe-count -2 -type f $TDIR"
4708 NUMS=$($CMD | wc -l)
4709 [ $NUMS -eq $EXPECTED ] || {
4711 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4715 CMD="$LFIND -stripe-count $((OSTCOUNT + 1)) -type f $TDIR"
4716 NUMS=$($CMD | wc -l)
4717 [ $NUMS -eq $EXPECTED ] || {
4719 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4722 run_test 56s "check lfs find -stripe-count works"
4724 test_56t() { # LU-611
4726 setup_56 $NUMFILES $NUMDIRS "-s 512k"
4728 $SETSTRIPE -S 256k $TDIR/$tfile.{0,1,2,3}
4730 EXPECTED=$(((NUMDIRS + 1) * NUMFILES))
4731 CMD="$LFIND -stripe-size 512k -type f $TDIR"
4732 NUMS=$($CMD | wc -l)
4733 [ $NUMS -eq $EXPECTED ] ||
4734 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4736 CMD="$LFIND -stripe-size +320k -type f $TDIR"
4737 NUMS=$($CMD | wc -l)
4738 [ $NUMS -eq $EXPECTED ] ||
4739 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4741 EXPECTED=$(((NUMDIRS + 1) * NUMFILES + 4))
4742 CMD="$LFIND -stripe-size +200k -type f $TDIR"
4743 NUMS=$($CMD | wc -l)
4744 [ $NUMS -eq $EXPECTED ] ||
4745 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4747 CMD="$LFIND -stripe-size -640k -type f $TDIR"
4748 NUMS=$($CMD | wc -l)
4749 [ $NUMS -eq $EXPECTED ] ||
4750 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4753 CMD="$LFIND -stripe-size 256k -type f $TDIR"
4754 NUMS=$($CMD | wc -l)
4755 [ $NUMS -eq $EXPECTED ] ||
4756 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4758 CMD="$LFIND -stripe-size -320k -type f $TDIR"
4759 NUMS=$($CMD | wc -l)
4760 [ $NUMS -eq $EXPECTED ] ||
4761 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4764 CMD="$LFIND -stripe-size 1024k -type f $TDIR"
4765 NUMS=$($CMD | wc -l)
4766 [ $NUMS -eq $EXPECTED ] ||
4767 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4769 run_test 56t "check lfs find -stripe-size works"
4771 test_56u() { # LU-611
4773 setup_56 $NUMFILES $NUMDIRS "-i 0"
4775 if [[ $OSTCOUNT -gt 1 ]]; then
4776 $SETSTRIPE -i 1 $TDIR/$tfile.{0,1,2,3}
4782 EXPECTED=$(((NUMDIRS + 1) * NUMFILES))
4783 CMD="$LFIND -stripe-index 0 -type f $TDIR"
4784 NUMS=$($CMD | wc -l)
4785 [ $NUMS -eq $EXPECTED ] ||
4786 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4789 CMD="$LFIND -stripe-index 1 -type f $TDIR"
4790 NUMS=$($CMD | wc -l)
4791 [ $NUMS -eq $EXPECTED ] ||
4792 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4794 CMD="$LFIND ! -stripe-index 0 -type f $TDIR"
4795 NUMS=$($CMD | wc -l)
4796 [ $NUMS -eq $EXPECTED ] ||
4797 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4800 # This should produce an error and not return any files
4801 CMD="$LFIND -stripe-index $OSTCOUNT -type f $TDIR"
4802 NUMS=$($CMD 2>/dev/null | wc -l)
4803 [ $NUMS -eq $EXPECTED ] ||
4804 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4806 if [[ $OSTCOUNT -gt 1 ]]; then
4807 EXPECTED=$(((NUMDIRS + 1) * NUMFILES + ONESTRIPE))
4808 CMD="$LFIND -stripe-index 0,1 -type f $TDIR"
4809 NUMS=$($CMD | wc -l)
4810 [ $NUMS -eq $EXPECTED ] ||
4811 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4814 run_test 56u "check lfs find -stripe-index works"
4821 setup_56 $NUMFILES $NUMDIRS
4823 UUID=$(mdtuuid_from_index $MDT_IDX $TDIR)
4824 [ -z "$UUID" ] && error "mdtuuid_from_index cannot find MDT index $MDT_IDX"
4826 for file in $($LFIND -mdt $UUID $TDIR); do
4827 file_mdt_idx=$($GETSTRIPE -M $file)
4828 [ $file_mdt_idx -eq $MDT_IDX ] ||
4829 error "'lfind -mdt $UUID' != 'getstripe -M' ($file_mdt_idx)"
4832 run_test 56v "check 'lfs find -mdt match with lfs getstripe -M' ======="
4835 [[ $OSTCOUNT -lt 2 ]] && skip_env "$OSTCOUNT < 2 OSTs -- skipping" &&
4837 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4840 rm -rf $TDIR || error "remove $TDIR failed"
4841 setup_56 $NUMFILES $NUMDIRS "-c $OSTCOUNT" "-c1"
4844 stripe_size=$($GETSTRIPE -S -d $TDIR) ||
4845 error "$GETSTRIPE -S -d $TDIR failed"
4846 stripe_size=${stripe_size%% *}
4848 local file_size=$((stripe_size * OSTCOUNT))
4849 local file_num=$((NUMDIRS * NUMFILES + NUMFILES))
4850 local required_space=$((file_num * file_size))
4851 local free_space=$($LCTL get_param -n lov.$LOVNAME.kbytesavail)
4852 [[ $free_space -le $((required_space / 1024)) ]] &&
4853 skip_env "need at least $required_space bytes free space," \
4854 "have $free_space kbytes" && return
4857 local dd_count=$((file_size / dd_bs))
4859 # write data into the files
4863 for i in $(seq 1 $NUMFILES); do
4865 yes | dd bs=$dd_bs count=$dd_count of=$file >/dev/null 2>&1 ||
4866 error "write data into $file failed"
4868 for i in $(seq 1 $NUMDIRS); do
4869 for j in $(seq 1 $NUMFILES); do
4870 file=$TDIR/dir$i/file$j
4871 yes | dd bs=$dd_bs count=$dd_count of=$file \
4873 error "write data into $file failed"
4878 [[ $OSTCOUNT -gt 1 ]] && expected=$((OSTCOUNT - 1))
4881 local cmd="$LFS_MIGRATE -y -c $expected $TDIR/file1"
4883 eval $cmd || error "$cmd failed"
4885 check_stripe_count $TDIR/file1 $expected
4887 if [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.6.90) ];
4889 # lfs_migrate file onto OST 0 if it is on OST 1, or onto
4890 # OST 1 if it is on OST 0. This file is small enough to
4891 # be on only one stripe.
4892 file=$TDIR/migr_1_ost
4893 dd bs=$dd_bs count=1 if=/dev/urandom of=$file >/dev/null 2>&1 ||
4894 error "write data into $file failed"
4895 local obdidx=$($LFS getstripe -i $file)
4896 local oldmd5=$(md5sum $file)
4898 [[ $obdidx -eq 0 ]] && newobdidx=1
4899 cmd="$LFS migrate -i $newobdidx $file"
4901 eval $cmd || error "$cmd failed"
4902 local realobdix=$($LFS getstripe -i $file)
4903 local newmd5=$(md5sum $file)
4904 [[ $newobdidx -ne $realobdix ]] &&
4905 error "new OST is different (was=$obdidx, wanted=$newobdidx, got=$realobdix)"
4906 [[ "$oldmd5" != "$newmd5" ]] &&
4907 error "md5sum differ: $oldmd5, $newmd5"
4911 cmd="$LFS_MIGRATE -y -c $expected $TDIR/dir1"
4913 eval $cmd || error "$cmd failed"
4915 for j in $(seq 1 $NUMFILES); do
4916 check_stripe_count $TDIR/dir1/file$j $expected
4919 # lfs_migrate works with lfs find
4920 cmd="$LFIND -stripe_count $OSTCOUNT -type f $TDIR |
4921 $LFS_MIGRATE -y -c $expected"
4923 eval $cmd || error "$cmd failed"
4925 for i in $(seq 2 $NUMFILES); do
4926 check_stripe_count $TDIR/file$i $expected
4928 for i in $(seq 2 $NUMDIRS); do
4929 for j in $(seq 1 $NUMFILES); do
4930 check_stripe_count $TDIR/dir$i/file$j $expected
4934 run_test 56w "check lfs_migrate -c stripe_count works"
4937 check_swap_layouts_support && return 0
4938 [[ $OSTCOUNT -lt 2 ]] &&
4939 skip_env "need 2 OST, skipping test" && return
4941 local dir0=$DIR/$tdir/$testnum
4942 test_mkdir -p $dir0 || error "creating dir $dir0"
4944 local ref1=/etc/passwd
4945 local file1=$dir0/file1
4947 $SETSTRIPE -c 2 $file1
4949 $LFS migrate -c 1 $file1 || error "migrate failed rc = $?"
4950 stripe=$($GETSTRIPE -c $file1)
4951 [[ $stripe == 1 ]] || error "stripe of $file1 is $stripe != 1"
4952 cmp $file1 $ref1 || error "content mismatch $file1 differs from $ref1"
4957 run_test 56x "lfs migration support"
4960 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.53) ] &&
4961 skip "No HSM $(lustre_build_version $SINGLEMDS) MDS < 2.4.53" &&
4965 local dir0=$DIR/$tdir/$testnum
4966 test_mkdir -p $dir0 || error "creating dir $dir0"
4967 local f1=$dir0/file1
4968 local f2=$dir0/file2
4970 touch $f1 || error "creating std file $f1"
4971 $MULTIOP $f2 H2c || error "creating released file $f2"
4973 # a directory can be raid0, so ask only for files
4974 res=$($LFIND $dir0 -L raid0 -type f | wc -l)
4975 [[ $res == 2 ]] || error "search raid0: found $res files != 2"
4977 res=$($LFIND $dir0 \! -L raid0 -type f | wc -l)
4978 [[ $res == 0 ]] || error "search !raid0: found $res files != 0"
4980 # only files can be released, so no need to force file search
4981 res=$($LFIND $dir0 -L released)
4982 [[ $res == $f2 ]] || error "search released: found $res != $f2"
4984 res=$($LFIND $dir0 \! -L released)
4985 [[ $res == $f1 ]] || error "search !released: found $res != $f1"
4988 run_test 56y "lfs find -L raid0|released"
4990 test_56z() { # LU-4824
4991 # This checks to make sure 'lfs find' continues after errors
4992 # There are two classes of errors that should be caught:
4993 # - If multiple paths are provided, all should be searched even if one
4995 # - If errors are encountered during the search, it should not terminate
4998 test_mkdir $DIR/$tdir
4999 for i in d{0..9}; do
5000 test_mkdir $DIR/$tdir/$i
5002 touch $DIR/$tdir/d{0..9}/$tfile
5003 $LFS find $DIR/non_existent_dir $DIR/$tdir &&
5004 error "$LFS find did not return an error"
5005 # Make a directory unsearchable. This should NOT be the last entry in
5006 # directory order. Arbitrarily pick the 6th entry
5007 chmod 700 $($LFS find $DIR/$tdir -type d | sed '6!d')
5008 local count=$($RUNAS $LFS find $DIR/non_existent $DIR/$tdir | wc -l)
5009 # The user should be able to see 10 directories and 9 files
5010 [ $count == 19 ] || error "$LFS find did not continue after error"
5012 run_test 56z "lfs find should continue after an error"
5014 test_56aa() { # LU-5937
5015 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
5018 $LFS setdirstripe -c$MDSCOUNT $DIR/$tdir/striped_dir
5020 createmany -o $DIR/$tdir/striped_dir/${tfile}- 1024
5021 local dirs=$(lfs find --size +8k $DIR/$tdir/)
5023 [ -n "$dirs" ] || error "lfs find --size wrong under striped dir"
5025 run_test 56aa "lfs find --size under striped dir"
5028 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5029 # note test will not do anything if MDS is not local
5030 if [ "$(facet_fstype $SINGLEMDS)" != ldiskfs ]; then
5031 skip "Only applicable to ldiskfs-based MDTs"
5035 remote_mds_nodsh && skip "remote MDS with nodsh" && return
5036 local MNTDEV="osd*.*MDT*.mntdev"
5037 DEV=$(do_facet $SINGLEMDS lctl get_param -n $MNTDEV)
5038 [ -z "$DEV" ] && error "can't access $MNTDEV"
5039 for DEV in $(do_facet $SINGLEMDS lctl get_param -n $MNTDEV); do
5040 do_facet $SINGLEMDS $DUMPE2FS -h $DEV > $TMP/t57a.dump ||
5041 error "can't access $DEV"
5042 DEVISIZE=$(awk '/Inode size:/ { print $3 }' $TMP/t57a.dump)
5043 [[ $DEVISIZE -gt 128 ]] || error "inode size $DEVISIZE"
5047 run_test 57a "verify MDS filesystem created with large inodes =="
5050 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5051 if [ "$(facet_fstype $SINGLEMDS)" != ldiskfs ]; then
5052 skip "Only applicable to ldiskfs-based MDTs"
5056 remote_mds_nodsh && skip "remote MDS with nodsh" && return
5057 local dir=$DIR/$tdir
5061 local FILEN=$dir/f$FILECOUNT
5063 rm -rf $dir || error "removing $dir"
5064 test_mkdir -p -c1 $dir || error "creating $dir"
5065 local mdtidx=$($LFS getstripe -M $dir)
5066 local mdtname=MDT$(printf %04x $mdtidx)
5067 local facet=mds$((mdtidx + 1))
5069 echo "mcreating $FILECOUNT files"
5070 createmany -m $dir/f 1 $FILECOUNT || \
5071 error "creating files in $dir"
5073 # verify that files do not have EAs yet
5074 $GETSTRIPE $FILE1 2>&1 | grep -q "no stripe" || error "$FILE1 has an EA"
5075 $GETSTRIPE $FILEN 2>&1 | grep -q "no stripe" || error "$FILEN has an EA"
5079 df $dir #make sure we get new statfs data
5080 local MDSFREE=$(do_facet $facet \
5081 lctl get_param -n osd*.*$mdtname.kbytesfree)
5082 local MDCFREE=$(lctl get_param -n mdc.*$mdtname-mdc-*.kbytesfree)
5083 echo "opening files to create objects/EAs"
5085 for FILE in `seq -f $dir/f%g 1 $FILECOUNT`; do
5086 $OPENFILE -f O_RDWR $FILE > /dev/null 2>&1 || error "opening $FILE"
5089 # verify that files have EAs now
5090 $GETSTRIPE $FILE1 | grep -q "obdidx" || error "$FILE1 missing EA"
5091 $GETSTRIPE $FILEN | grep -q "obdidx" || error "$FILEN missing EA"
5093 sleep 1 #make sure we get new statfs data
5095 local MDSFREE2=$(do_facet $facet \
5096 lctl get_param -n osd*.*$mdtname.kbytesfree)
5097 local MDCFREE2=$(lctl get_param -n mdc.*$mdtname-mdc-*.kbytesfree)
5098 if [[ $MDCFREE2 -lt $((MDCFREE - 16)) ]]; then
5099 if [ "$MDSFREE" != "$MDSFREE2" ]; then
5100 error "MDC before $MDCFREE != after $MDCFREE2"
5102 echo "MDC before $MDCFREE != after $MDCFREE2"
5103 echo "unable to confirm if MDS has large inodes"
5108 run_test 57b "default LOV EAs are stored inside large inodes ==="
5111 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5112 [ -z "$(which wiretest 2>/dev/null)" ] &&
5113 skip_env "could not find wiretest" && return
5116 run_test 58 "verify cross-platform wire constants =============="
5119 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5120 echo "touch 130 files"
5121 createmany -o $DIR/f59- 130
5123 unlinkmany $DIR/f59- 130
5125 # wait for commitment of removal
5126 wait_delete_completed
5128 run_test 59 "verify cancellation of llog records async ========="
5130 TEST60_HEAD="test_60 run $RANDOM"
5132 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5133 remote_mgs_nodsh && skip "remote MGS with nodsh" && return
5134 do_facet mgs "! which run-llog.sh &> /dev/null" &&
5135 do_facet mgs "! ls run-llog.sh &> /dev/null" &&
5136 skip_env "missing subtest run-llog.sh" && return
5138 log "$TEST60_HEAD - from kernel mode"
5139 do_facet mgs "$LCTL set_param debug=warning; $LCTL dk > /dev/null"
5140 do_facet mgs sh run-llog.sh
5141 do_facet mgs $LCTL dk > $TMP/$tfile
5143 # LU-6388: test llog_reader
5144 local llog_reader=$(do_facet mgs "which llog_reader 2> /dev/null")
5145 llog_reader=${llog_reader:-$LUSTRE/utils/llog_reader}
5146 [ -z $(do_facet mgs ls -d $llog_reader 2> /dev/null) ] &&
5147 skip_env "missing llog_reader" && return
5148 local fstype=$(facet_fstype mgs)
5149 [ $fstype != ldiskfs -a $fstype != zfs ] &&
5150 skip_env "Only for ldiskfs or zfs type mgs" && return
5152 local mntpt=$(facet_mntpt mgs)
5153 local mgsdev=$(mgsdevname 1)
5165 #get fid and record list
5166 fid_list=($(awk '/9_sub.*record/ { print $NF }' /$TMP/$tfile |
5168 rec_list=($(awk '/9_sub.*record/ { print $((NF-3)) }' /$TMP/$tfile |
5170 #remount mgs as ldiskfs or zfs type
5171 stop mgs || error "stop mgs failed"
5172 mount_fstype mgs || error "remount mgs failed"
5173 for ((i = 0; i < ${#fid_list[@]}; i++)); do
5176 seq=$(echo $fid | awk -F ':' '{ print $1 }' | sed -e "s/^0x//g")
5177 oid=$(echo $fid | awk -F ':' '{ print $2 }' | sed -e "s/^0x//g")
5182 obj_file=$mntpt/O/$seq/d$((oid%32))/$oid ;;
5184 obj_file=$mntpt/oi.$(($((16#$seq))&127))/$fid ;;
5186 echo "obj_file is $obj_file"
5187 do_facet mgs $llog_reader $obj_file
5189 rec_type=$(do_facet mgs $llog_reader $obj_file | grep "type=" |
5190 awk '{ print $3 }' | sed -e "s/^type=//g")
5191 if [ $rec_type != $rec ]; then
5192 echo "FAILED test_60a wrong record type $rec_type," \
5198 #check obj path if record type is LLOG_LOGID_MAGIC
5199 if [ "$rec" == "1064553b" ]; then
5200 path=$(do_facet mgs $llog_reader $obj_file |
5201 grep "path=" | awk '{ print $NF }' |
5202 sed -e "s/^path=//g")
5203 if [ $obj_file != $mntpt/$path ]; then
5204 echo "FAILED test_60a wrong obj path" \
5205 "$montpt/$path, should be $obj_file"
5212 #restart mgs before "error", otherwise it will block the next test
5213 stop mgs || error "stop mgs failed"
5214 start mgs $(mgsdevname) $MGS_MOUNT_OPTS || error "start mgs failed"
5215 $pass || error "test failed, see FAILED test_60a messages for specifics"
5217 run_test 60a "llog_test run from kernel module and test llog_reader =========="
5219 test_60b() { # bug 6411
5220 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5222 LLOG_COUNT=`dmesg | awk "/$TEST60_HEAD/{marker = 1; from_marker = 0;}
5234 [[ $LLOG_COUNT -gt 50 ]] &&
5235 error "CDEBUG_LIMIT not limiting messages ($LLOG_COUNT)" || true
5237 run_test 60b "limit repeated messages from CERROR/CWARN ========"
5240 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5241 echo "create 5000 files"
5242 createmany -o $DIR/f60c- 5000
5243 #define OBD_FAIL_MDS_LLOG_CREATE_FAILED 0x137
5244 lctl set_param fail_loc=0x80000137
5245 unlinkmany $DIR/f60c- 5000
5246 lctl set_param fail_loc=0
5248 run_test 60c "unlink file when mds full"
5251 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5252 SAVEPRINTK=$(lctl get_param -n printk)
5254 # verify "lctl mark" is even working"
5255 MESSAGE="test message ID $RANDOM $$"
5256 $LCTL mark "$MESSAGE" || error "$LCTL mark failed"
5257 dmesg | grep -q "$MESSAGE" || error "didn't find debug marker in log"
5259 lctl set_param printk=0 || error "set lnet.printk failed"
5260 lctl get_param -n printk | grep emerg || error "lnet.printk dropped emerg"
5261 MESSAGE="new test message ID $RANDOM $$"
5262 # Assume here that libcfs_debug_mark_buffer() uses D_WARNING
5263 $LCTL mark "$MESSAGE" || error "$LCTL mark failed"
5264 dmesg | grep -q "$MESSAGE" && error "D_WARNING wasn't masked" || true
5266 lctl set_param -n printk="$SAVEPRINTK"
5268 run_test 60d "test printk console message masking"
5271 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5273 #define OBD_FAIL_MDS_LLOG_CREATE_FAILED2 0x15b
5274 do_facet mds1 lctl set_param fail_loc=0x15b
5277 run_test 60e "no space while new llog is being created"
5280 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5282 dd if=/dev/zero of=$f bs=$(page_size) count=1 || error "dd $f failed"
5283 cancel_lru_locks osc
5284 $MULTIOP $f OSMWUc || error "$MULTIOP $f failed"
5287 run_test 61 "mmap() writes don't make sync hang ================"
5289 # bug 2330 - insufficient obd_match error checking causes LBUG
5291 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5294 cancel_lru_locks osc
5295 lctl set_param fail_loc=0x405
5296 cat $f && error "cat succeeded, expect -EIO"
5297 lctl set_param fail_loc=0
5299 # This test is now irrelevant (as of bug 10718 inclusion), we no longer
5300 # match every page all of the time.
5301 #run_test 62 "verify obd_match failure doesn't LBUG (should -EIO)"
5303 # bug 2319 - oig_wait() interrupted causes crash because of invalid waitq.
5304 # Though this test is irrelevant anymore, it helped to reveal some
5305 # other grant bugs (LU-4482), let's keep it.
5306 test_63a() { # was test_63
5307 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5308 MAX_DIRTY_MB=`lctl get_param -n osc.*.max_dirty_mb | head -n 1`
5309 for i in `seq 10` ; do
5310 dd if=/dev/zero of=$DIR/f63 bs=8k &
5316 rm -f $DIR/f63 || true
5318 run_test 63a "Verify oig_wait interruption does not crash ======="
5320 # bug 2248 - async write errors didn't return to application on sync
5321 # bug 3677 - async write errors left page locked
5323 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5325 lctl set_param debug=-1
5327 # ensure we have a grant to do async writes
5328 dd if=/dev/zero of=$DIR/$tfile bs=4k count=1
5331 sync # sync lest earlier test intercept the fail_loc
5333 #define OBD_FAIL_OSC_BRW_PREP_REQ 0x406
5334 lctl set_param fail_loc=0x80000406
5335 $MULTIOP $DIR/$tfile Owy && \
5336 error "sync didn't return ENOMEM"
5337 sync; sleep 2; sync # do a real sync this time to flush page
5338 lctl get_param -n llite.*.dump_page_cache | grep locked && \
5339 error "locked page left in cache after async error" || true
5342 run_test 63b "async write errors should be returned to fsync ==="
5345 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5347 lctl get_param -n osc.*[oO][sS][cC][_-]*.cur* | grep "[0-9]"
5349 run_test 64a "verify filter grant calculations (in kernel) ====="
5352 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5353 sh oos.sh $MOUNT || error "oos.sh failed: $?"
5355 run_test 64b "check out-of-space detection on client ==========="
5358 $LCTL set_param osc.*OST0000-osc-[^mM]*.cur_grant_bytes=0
5360 run_test 64c "verify grant shrink ========================------"
5362 # bug 1414 - set/get directories' stripe info
5364 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5365 test_mkdir -p $DIR/$tdir
5367 $LVERIFY $DIR/$tdir $DIR/$tdir/f1 || error "lverify failed"
5369 run_test 65a "directory with no stripe info ===================="
5372 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5373 test_mkdir -p $DIR/$tdir
5374 $SETSTRIPE -S $((STRIPESIZE * 2)) -i 0 -c 1 $DIR/$tdir ||
5377 $LVERIFY $DIR/$tdir $DIR/$tdir/f2 || error "lverify failed"
5379 run_test 65b "directory setstripe -S $((STRIPESIZE * 2)) -i 0 -c 1"
5382 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5383 if [[ $OSTCOUNT -gt 1 ]]; then
5384 test_mkdir -p $DIR/$tdir
5385 $SETSTRIPE -S $(($STRIPESIZE * 4)) -i 1 \
5386 -c $(($OSTCOUNT - 1)) $DIR/$tdir || error "setstripe"
5388 $LVERIFY $DIR/$tdir $DIR/$tdir/f3 || error "lverify failed"
5391 run_test 65c "directory setstripe -S $((STRIPESIZE*4)) -i 1 -c $((OSTCOUNT-1))"
5394 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5395 test_mkdir -p $DIR/$tdir
5396 if [[ $STRIPECOUNT -le 0 ]]; then
5398 elif [[ $STRIPECOUNT -gt 2000 ]]; then
5399 #LOV_MAX_STRIPE_COUNT is 2000
5400 [[ $OSTCOUNT -gt 2000 ]] && sc=2000 || sc=$(($OSTCOUNT - 1))
5402 sc=$(($STRIPECOUNT - 1))
5404 $SETSTRIPE -S $STRIPESIZE -c $sc $DIR/$tdir || error "setstripe"
5405 touch $DIR/$tdir/f4 $DIR/$tdir/f5
5406 $LVERIFY $DIR/$tdir $DIR/$tdir/f4 $DIR/$tdir/f5 ||
5407 error "lverify failed"
5409 run_test 65d "directory setstripe -S $STRIPESIZE -c stripe_count"
5412 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5413 test_mkdir -p $DIR/$tdir
5415 $SETSTRIPE $DIR/$tdir || error "setstripe"
5416 $GETSTRIPE -v $DIR/$tdir | grep "Default" ||
5417 error "no stripe info failed"
5419 $LVERIFY $DIR/$tdir $DIR/$tdir/f6 || error "lverify failed"
5421 run_test 65e "directory setstripe defaults ======================="
5424 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5425 test_mkdir -p $DIR/${tdir}f
5426 $RUNAS $SETSTRIPE $DIR/${tdir}f && error "setstripe succeeded" || true
5428 run_test 65f "dir setstripe permission (should return error) ==="
5431 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5432 test_mkdir -p $DIR/$tdir
5433 $SETSTRIPE -S $((STRIPESIZE * 2)) -i 0 -c 1 $DIR/$tdir ||
5435 $SETSTRIPE -d $DIR/$tdir || error "setstripe"
5436 $GETSTRIPE -v $DIR/$tdir | grep "Default" ||
5437 error "delete default stripe failed"
5439 run_test 65g "directory setstripe -d ==========================="
5442 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5443 test_mkdir -p $DIR/$tdir
5444 $SETSTRIPE -S $((STRIPESIZE * 2)) -i 0 -c 1 $DIR/$tdir ||
5446 test_mkdir -p $DIR/$tdir/dd1
5447 [ $($GETSTRIPE -c $DIR/$tdir) == $($GETSTRIPE -c $DIR/$tdir/dd1) ] ||
5448 error "stripe info inherit failed"
5450 run_test 65h "directory stripe info inherit ===================="
5452 test_65i() { # bug6367
5453 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5454 $SETSTRIPE -S 65536 -c -1 $MOUNT
5456 run_test 65i "set non-default striping on root directory (bug 6367)="
5458 test_65ia() { # bug12836
5459 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5460 $GETSTRIPE $MOUNT || error "getstripe $MOUNT failed"
5462 run_test 65ia "getstripe on -1 default directory striping"
5464 test_65ib() { # bug12836
5465 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5466 $GETSTRIPE -v $MOUNT || error "getstripe -v $MOUNT failed"
5468 run_test 65ib "getstripe -v on -1 default directory striping"
5470 test_65ic() { # bug12836
5471 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5472 $LFS find -mtime -1 $MOUNT > /dev/null || error "find $MOUNT failed"
5474 run_test 65ic "new find on -1 default directory striping"
5476 test_65j() { # bug6367
5477 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5479 # if we aren't already remounting for each test, do so for this test
5480 if [ "$CLEANUP" = ":" -a "$I_MOUNTED" = "yes" ]; then
5481 cleanup || error "failed to unmount"
5484 $SETSTRIPE -d $MOUNT || error "setstripe failed"
5486 run_test 65j "set default striping on root directory (bug 6367)="
5488 test_65k() { # bug11679
5489 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5490 [[ $OSTCOUNT -lt 2 ]] && skip_env "too few OSTs" && return
5491 remote_mds_nodsh && skip "remote MDS with nodsh" && return
5493 echo "Check OST status: "
5494 local MDS_OSCS=`do_facet $SINGLEMDS lctl dl |
5495 awk '/[oO][sS][cC].*md[ts]/ { print $4 }'`
5497 for OSC in $MDS_OSCS; do
5498 echo $OSC "is activate"
5499 do_facet $SINGLEMDS lctl --device %$OSC activate
5503 for INACTIVE_OSC in $MDS_OSCS; do
5504 echo "Deactivate: " $INACTIVE_OSC
5505 do_facet $SINGLEMDS lctl --device %$INACTIVE_OSC deactivate
5506 for STRIPE_OSC in $MDS_OSCS; do
5507 OST=`osc_to_ost $STRIPE_OSC`
5508 IDX=`do_facet $SINGLEMDS lctl get_param -n lov.*md*.target_obd |
5509 awk -F: /$OST/'{ print $1 }' | head -n 1`
5511 [ -f $DIR/$tdir/$IDX ] && continue
5512 echo "$SETSTRIPE -i $IDX -c 1 $DIR/$tdir/$IDX"
5513 $SETSTRIPE -i $IDX -c 1 $DIR/$tdir/$IDX
5515 [ $RC -ne 0 ] && error "setstripe should have succeeded"
5518 echo $INACTIVE_OSC "is Activate."
5519 do_facet $SINGLEMDS lctl --device %$INACTIVE_OSC activate
5522 run_test 65k "validate manual striping works properly with deactivated OSCs"
5524 test_65l() { # bug 12836
5525 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5526 test_mkdir -p $DIR/$tdir/test_dir
5527 $SETSTRIPE -c -1 $DIR/$tdir/test_dir
5528 $LFS find -mtime -1 $DIR/$tdir >/dev/null
5530 run_test 65l "lfs find on -1 stripe dir ========================"
5532 # bug 2543 - update blocks count on client
5534 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5536 dd if=/dev/zero of=$DIR/f66 bs=1k count=$COUNT
5537 sync; sync_all_data; sync; sync_all_data
5538 cancel_lru_locks osc
5539 BLOCKS=`ls -s $DIR/f66 | awk '{ print $1 }'`
5540 [ $BLOCKS -ge $COUNT ] || error "$DIR/f66 blocks $BLOCKS < $COUNT"
5542 run_test 66 "update inode blocks count on client ==============="
5547 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5549 if [ ! -z "$LLOOP" ]; then
5550 if swapon -s | grep -q $LLOOP; then
5551 swapoff $LLOOP || error "swapoff failed"
5554 $LCTL blockdev_detach $LLOOP || error "detach failed"
5558 if [ ! -z "$LLITELOOPLOAD" ]; then
5566 awk '($1 == "'$1':") { print $2 }' /proc/meminfo
5570 swapon -s | awk '($1 == "'$1'") { print $4 }'
5573 # test case for lloop driver, basic function
5575 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5576 [ "$UID" != 0 ] && skip_env "must run as root" && return
5577 llite_lloop_enabled || \
5578 { skip_env "llite_lloop module disabled" && return; }
5580 trap cleanup_68 EXIT
5582 if ! module_loaded llite_lloop; then
5583 if load_module llite/llite_lloop; then
5586 skip_env "can't find module llite_lloop"
5591 LLOOP=$TMP/lloop.`date +%s`.`date +%N`
5592 dd if=/dev/zero of=$DIR/f68a bs=4k count=1024
5593 $LCTL blockdev_attach $DIR/f68a $LLOOP || error "attach failed"
5595 directio rdwr $LLOOP 0 1024 4096 || error "direct write failed"
5596 directio rdwr $LLOOP 0 1025 4096 && error "direct write should fail"
5600 run_test 68a "lloop driver - basic test ========================"
5602 # excercise swapping to lustre by adding a high priority swapfile entry
5603 # and then consuming memory until it is used.
5604 test_68b() { # was test_68
5605 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5606 [ "$UID" != 0 ] && skip_env "must run as root" && return
5607 lctl get_param -n devices | grep -q obdfilter && \
5608 skip "local OST" && return
5610 grep -q llite_lloop /proc/modules
5611 [ $? -ne 0 ] && skip "can't find module llite_lloop" && return
5613 [ -z "`$LCTL list_nids | grep -v tcp`" ] && \
5614 skip "can't reliably test swap with TCP" && return
5616 MEMTOTAL=`meminfo MemTotal`
5617 NR_BLOCKS=$((MEMTOTAL>>8))
5618 [[ $NR_BLOCKS -le 2048 ]] && NR_BLOCKS=2048
5620 LLOOP=$TMP/lloop.`date +%s`.`date +%N`
5621 dd if=/dev/zero of=$DIR/f68b bs=64k seek=$NR_BLOCKS count=1
5624 $LCTL blockdev_attach $DIR/f68b $LLOOP || error "attach failed"
5626 trap cleanup_68 EXIT
5628 swapon -p 32767 $LLOOP || error "swapon $LLOOP failed"
5630 echo "before: `swapon -s | grep $LLOOP`"
5631 $MEMHOG $MEMTOTAL || error "error allocating $MEMTOTAL kB"
5632 echo "after: `swapon -s | grep $LLOOP`"
5633 SWAPUSED=`swap_used $LLOOP`
5637 [ $SWAPUSED -eq 0 ] && echo "no swap used???" || true
5639 run_test 68b "support swapping to Lustre ========================"
5641 # bug5265, obdfilter oa2dentry return -ENOENT
5642 # #define OBD_FAIL_SRV_ENOENT 0x217
5644 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5645 remote_ost_nodsh && skip "remote OST with nodsh" && return
5648 $SETSTRIPE -c 1 -i 0 $f
5650 $DIRECTIO write ${f}.2 0 1 || error "directio write error"
5652 do_facet ost1 lctl set_param fail_loc=0x217
5653 $TRUNCATE $f 1 # vmtruncate() will ignore truncate() error.
5654 $DIRECTIO write $f 0 2 && error "write succeeded, expect -ENOENT"
5656 do_facet ost1 lctl set_param fail_loc=0
5657 $DIRECTIO write $f 0 2 || error "write error"
5659 cancel_lru_locks osc
5660 $DIRECTIO read $f 0 1 || error "read error"
5662 do_facet ost1 lctl set_param fail_loc=0x217
5663 $DIRECTIO read $f 1 1 && error "read succeeded, expect -ENOENT"
5665 do_facet ost1 lctl set_param fail_loc=0
5668 run_test 69 "verify oa2dentry return -ENOENT doesn't LBUG ======"
5671 test_mkdir -p $DIR/$tdir
5672 $LFS setdirstripe -D -c$MDSCOUNT $DIR/$tdir
5673 sh rundbench -C -D $DIR/$tdir 2 || error "dbench failed!"
5675 run_test 71 "Running dbench on lustre (don't segment fault) ===="
5677 test_72a() { # bug 5695 - Test that on 2.6 remove_suid works properly
5678 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5679 [ "$RUNAS_ID" = "$UID" ] &&
5680 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
5682 # Check that testing environment is properly set up. Skip if not
5683 FAIL_ON_ERROR=false check_runas_id_ret $RUNAS_ID $RUNAS_GID $RUNAS || {
5684 skip_env "User $RUNAS_ID does not exist - skipping"
5688 chmod 777 $DIR/$tfile
5689 chmod ug+s $DIR/$tfile
5690 $RUNAS dd if=/dev/zero of=$DIR/$tfile bs=512 count=1 ||
5691 error "$RUNAS dd $DIR/$tfile failed"
5692 # See if we are still setuid/sgid
5693 test -u $DIR/$tfile -o -g $DIR/$tfile &&
5694 error "S/gid is not dropped on write"
5695 # Now test that MDS is updated too
5696 cancel_lru_locks mdc
5697 test -u $DIR/$tfile -o -g $DIR/$tfile &&
5698 error "S/gid is not dropped on MDS"
5701 run_test 72a "Test that remove suid works properly (bug5695) ===="
5703 test_72b() { # bug 24226 -- keep mode setting when size is not changing
5706 [ "$RUNAS_ID" = "$UID" ] && \
5707 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
5708 [ "$RUNAS_ID" -eq 0 ] && \
5709 skip_env "RUNAS_ID = 0 -- skipping" && return
5711 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5712 # Check that testing environment is properly set up. Skip if not
5713 FAIL_ON_ERROR=false check_runas_id_ret $RUNAS_ID $RUNAS_ID $RUNAS || {
5714 skip_env "User $RUNAS_ID does not exist - skipping"
5717 touch $DIR/${tfile}-f{g,u}
5718 test_mkdir $DIR/${tfile}-dg
5719 test_mkdir $DIR/${tfile}-du
5720 chmod 770 $DIR/${tfile}-{f,d}{g,u}
5721 chmod g+s $DIR/${tfile}-{f,d}g
5722 chmod u+s $DIR/${tfile}-{f,d}u
5723 for perm in 777 2777 4777; do
5724 $RUNAS chmod $perm $DIR/${tfile}-fg && error "S/gid file allowed improper chmod to $perm"
5725 $RUNAS chmod $perm $DIR/${tfile}-fu && error "S/uid file allowed improper chmod to $perm"
5726 $RUNAS chmod $perm $DIR/${tfile}-dg && error "S/gid dir allowed improper chmod to $perm"
5727 $RUNAS chmod $perm $DIR/${tfile}-du && error "S/uid dir allowed improper chmod to $perm"
5731 run_test 72b "Test that we keep mode setting if without file data changed (bug 24226)"
5733 # bug 3462 - multiple simultaneous MDC requests
5735 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5736 test_mkdir $DIR/d73-1
5737 test_mkdir $DIR/d73-2
5738 multiop_bg_pause $DIR/d73-1/f73-1 O_c || return 1
5741 lctl set_param fail_loc=0x80000129
5742 $MULTIOP $DIR/d73-1/f73-2 Oc &
5744 lctl set_param fail_loc=0
5746 $MULTIOP $DIR/d73-2/f73-3 Oc &
5750 wait $pid1 || return 1
5754 $CHECKSTAT -t file $DIR/d73-1/f73-1 || return 4
5755 $CHECKSTAT -t file $DIR/d73-1/f73-2 || return 5
5756 $CHECKSTAT -t file $DIR/d73-2/f73-3 || return 6
5760 run_test 73 "multiple MDC requests (should not deadlock)"
5762 test_74a() { # bug 6149, 6184
5763 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5764 #define OBD_FAIL_LDLM_ENQUEUE_OLD_EXPORT 0x30e
5766 # very important to OR with OBD_FAIL_ONCE (0x80000000) -- otherwise it
5767 # will spin in a tight reconnection loop
5769 $LCTL set_param fail_loc=0x8000030e
5770 # get any lock that won't be difficult - lookup works.
5772 $LCTL set_param fail_loc=0
5776 run_test 74a "ldlm_enqueue freed-export error path, ls (shouldn't LBUG)"
5778 test_74b() { # bug 13310
5779 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5780 #define OBD_FAIL_LDLM_ENQUEUE_OLD_EXPORT 0x30e
5782 # very important to OR with OBD_FAIL_ONCE (0x80000000) -- otherwise it
5783 # will spin in a tight reconnection loop
5784 $LCTL set_param fail_loc=0x8000030e
5785 # get a "difficult" lock
5787 $LCTL set_param fail_loc=0
5791 run_test 74b "ldlm_enqueue freed-export error path, touch (shouldn't LBUG)"
5794 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5795 #define OBD_FAIL_LDLM_NEW_LOCK
5796 $LCTL set_param fail_loc=0x319
5797 touch $DIR/$tfile && error "touch successful"
5798 $LCTL set_param fail_loc=0
5801 run_test 74c "ldlm_lock_create error path, (shouldn't LBUG)"
5804 awk '/lustre_inode_cache/ {print $2; exit}' /proc/slabinfo
5807 get_inode_slab_tunables() {
5808 awk '/lustre_inode_cache/ {print $9," ",$10," ",$11; exit}' /proc/slabinfo
5811 set_inode_slab_tunables() {
5812 echo "lustre_inode_cache $1" > /proc/slabinfo
5815 test_76() { # Now for bug 20433, added originally in bug 1443
5816 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5817 local SLAB_SETTINGS=`get_inode_slab_tunables`
5818 local CPUS=`getconf _NPROCESSORS_ONLN`
5819 # we cannot set limit below 1 which means 1 inode in each
5820 # per-cpu cache is still allowed
5821 set_inode_slab_tunables "1 1 0"
5822 cancel_lru_locks osc
5823 BEFORE_INODES=$(num_inodes)
5824 echo "before inodes: $BEFORE_INODES"
5826 [ "$SLOW" = "no" ] && COUNT=100
5827 for i in $(seq $COUNT); do
5831 cancel_lru_locks osc
5832 AFTER_INODES=$(num_inodes)
5833 echo "after inodes: $AFTER_INODES"
5835 while [[ $((AFTER_INODES-1*CPUS)) -gt $BEFORE_INODES ]]; do
5837 AFTER_INODES=$(num_inodes)
5839 echo "wait $wait seconds inodes: $AFTER_INODES"
5840 if [ $wait -gt 30 ]; then
5841 error "inode slab grew from $BEFORE_INODES to $AFTER_INODES"
5844 set_inode_slab_tunables "$SLAB_SETTINGS"
5846 run_test 76 "confirm clients recycle inodes properly ===="
5852 # Note: in sptlrpc modes which enable its own bulk checksum, the
5853 # original crc32_le bulk checksum will be automatically disabled,
5854 # and the OBD_FAIL_OSC_CHECKSUM_SEND/OBD_FAIL_OSC_CHECKSUM_RECEIVE
5855 # will be checked by sptlrpc code against sptlrpc bulk checksum.
5856 # In this case set_checksums() will not be no-op, because sptlrpc
5857 # bulk checksum will be enabled all through the test.
5859 [ "$ORIG_CSUM" ] || ORIG_CSUM=`lctl get_param -n osc.*.checksums | head -n1`
5860 lctl set_param -n osc.*.checksums $1
5864 export ORIG_CSUM_TYPE="`lctl get_param -n osc.*osc-[^mM]*.checksum_type |
5865 sed 's/.*\[\(.*\)\].*/\1/g' | head -n1`"
5866 CKSUM_TYPES=${CKSUM_TYPES:-"crc32 adler"}
5867 [ "$ORIG_CSUM_TYPE" = "crc32c" ] && CKSUM_TYPES="$CKSUM_TYPES crc32c"
5870 lctl set_param -n osc.*osc-[^mM]*.checksum_type $1
5871 log "set checksum type to $1"
5874 F77_TMP=$TMP/f77-temp
5877 dd if=/dev/urandom of=$F77_TMP bs=1M count=$F77SZ || \
5878 error "error writing to $F77_TMP"
5881 test_77a() { # bug 10889
5882 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5883 $GSS && skip "could not run with gss" && return
5884 [ ! -f $F77_TMP ] && setup_f77
5886 dd if=$F77_TMP of=$DIR/$tfile bs=1M count=$F77SZ || error "dd error"
5890 run_test 77a "normal checksum read/write operation"
5892 test_77b() { # bug 10889
5893 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5894 $GSS && skip "could not run with gss" && return
5895 [ ! -f $F77_TMP ] && setup_f77
5896 #define OBD_FAIL_OSC_CHECKSUM_SEND 0x409
5897 $LCTL set_param fail_loc=0x80000409
5900 dd if=$F77_TMP of=$DIR/$tfile bs=1M count=$F77SZ conv=sync ||
5901 error "dd error: $?"
5902 $LCTL set_param fail_loc=0
5904 for algo in $CKSUM_TYPES; do
5905 cancel_lru_locks osc
5906 set_checksum_type $algo
5907 #define OBD_FAIL_OSC_CHECKSUM_RECEIVE 0x408
5908 $LCTL set_param fail_loc=0x80000408
5909 cmp $F77_TMP $DIR/$tfile || error "file compare failed"
5910 $LCTL set_param fail_loc=0
5913 set_checksum_type $ORIG_CSUM_TYPE
5916 run_test 77b "checksum error on client write, read"
5918 test_77d() { # bug 10889
5919 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5920 $GSS && skip "could not run with gss" && return
5921 #define OBD_FAIL_OSC_CHECKSUM_SEND 0x409
5922 $LCTL set_param fail_loc=0x80000409
5924 $DIRECTIO write $DIR/$tfile 0 $F77SZ $((1024 * 1024)) ||
5925 error "direct write: rc=$?"
5926 $LCTL set_param fail_loc=0
5929 #define OBD_FAIL_OSC_CHECKSUM_RECEIVE 0x408
5930 $LCTL set_param fail_loc=0x80000408
5932 cancel_lru_locks osc
5933 $DIRECTIO read $DIR/$tfile 0 $F77SZ $((1024 * 1024)) ||
5934 error "direct read: rc=$?"
5935 $LCTL set_param fail_loc=0
5938 run_test 77d "checksum error on OST direct write, read"
5940 test_77f() { # bug 10889
5941 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5942 $GSS && skip "could not run with gss" && return
5944 for algo in $CKSUM_TYPES; do
5945 cancel_lru_locks osc
5946 set_checksum_type $algo
5947 #define OBD_FAIL_OSC_CHECKSUM_SEND 0x409
5948 $LCTL set_param fail_loc=0x409
5949 $DIRECTIO write $DIR/$tfile 0 $F77SZ $((1024 * 1024)) &&
5950 error "direct write succeeded"
5951 $LCTL set_param fail_loc=0
5953 set_checksum_type $ORIG_CSUM_TYPE
5956 run_test 77f "repeat checksum error on write (expect error)"
5958 test_77g() { # bug 10889
5959 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5960 $GSS && skip "could not run with gss" && return
5961 remote_ost_nodsh && skip "remote OST with nodsh" && return
5963 [ ! -f $F77_TMP ] && setup_f77
5965 $SETSTRIPE -c 1 -i 0 $DIR/$tfile
5966 #define OBD_FAIL_OST_CHECKSUM_RECEIVE 0x21a
5967 do_facet ost1 lctl set_param fail_loc=0x8000021a
5969 dd if=$F77_TMP of=$DIR/$tfile bs=1M count=$F77SZ ||
5970 error "write error: rc=$?"
5971 do_facet ost1 lctl set_param fail_loc=0
5974 cancel_lru_locks osc
5975 #define OBD_FAIL_OST_CHECKSUM_SEND 0x21b
5976 do_facet ost1 lctl set_param fail_loc=0x8000021b
5978 cmp $F77_TMP $DIR/$tfile || error "file compare failed"
5979 do_facet ost1 lctl set_param fail_loc=0
5982 run_test 77g "checksum error on OST write, read"
5984 test_77i() { # bug 13805
5985 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5986 $GSS && skip "could not run with gss" && return
5987 #define OBD_FAIL_OSC_CONNECT_CKSUM 0x40b
5988 lctl set_param fail_loc=0x40b
5989 remount_client $MOUNT
5990 lctl set_param fail_loc=0
5991 for VALUE in `lctl get_param osc.*osc-[^mM]*.checksum_type`; do
5992 PARAM=`echo ${VALUE[0]} | cut -d "=" -f1`
5993 algo=`lctl get_param -n $PARAM | sed 's/.*\[\(.*\)\].*/\1/g'`
5994 [ "$algo" = "adler" ] || error "algo set to $algo instead of adler"
5996 remount_client $MOUNT
5998 run_test 77i "client not supporting OSD_CONNECT_CKSUM"
6000 test_77j() { # bug 13805
6001 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6002 $GSS && skip "could not run with gss" && return
6003 #define OBD_FAIL_OSC_CKSUM_ADLER_ONLY 0x40c
6004 lctl set_param fail_loc=0x40c
6005 remount_client $MOUNT
6006 lctl set_param fail_loc=0
6007 sleep 2 # wait async osc connect to finish
6008 for VALUE in `lctl get_param osc.*osc-[^mM]*.checksum_type`; do
6009 PARAM=`echo ${VALUE[0]} | cut -d "=" -f1`
6010 algo=`lctl get_param -n $PARAM | sed 's/.*\[\(.*\)\].*/\1/g'`
6011 [ "$algo" = "adler" ] || error "algo set to $algo instead of adler"
6013 remount_client $MOUNT
6015 run_test 77j "client only supporting ADLER32"
6017 [ "$ORIG_CSUM" ] && set_checksums $ORIG_CSUM || true
6021 test_78() { # bug 10901
6022 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6023 remote_ost || { skip_env "local OST" && return; }
6026 F78SIZE=$(($(awk '/MemFree:/ { print $2 }' /proc/meminfo) / 1024))
6027 echo "MemFree: $F78SIZE, Max file size: $MAXFREE"
6028 MEMTOTAL=$(($(awk '/MemTotal:/ { print $2 }' /proc/meminfo) / 1024))
6029 echo "MemTotal: $MEMTOTAL"
6031 # reserve 256MB of memory for the kernel and other running processes,
6032 # and then take 1/2 of the remaining memory for the read/write buffers.
6033 if [ $MEMTOTAL -gt 512 ] ;then
6034 MEMTOTAL=$(((MEMTOTAL - 256 ) / 2))
6036 # for those poor memory-starved high-end clusters...
6037 MEMTOTAL=$((MEMTOTAL / 2))
6039 echo "Mem to use for directio: $MEMTOTAL"
6041 [[ $F78SIZE -gt $MEMTOTAL ]] && F78SIZE=$MEMTOTAL
6042 [[ $F78SIZE -gt 512 ]] && F78SIZE=512
6043 [[ $F78SIZE -gt $((MAXFREE / 1024)) ]] && F78SIZE=$((MAXFREE / 1024))
6044 SMALLESTOST=$($LFS df $DIR | grep OST | awk '{ print $4 }' | sort -n |
6046 echo "Smallest OST: $SMALLESTOST"
6047 [[ $SMALLESTOST -lt 10240 ]] &&
6048 skip "too small OSTSIZE, useless to run large O_DIRECT test" && return 0
6050 [[ $F78SIZE -gt $((SMALLESTOST * $OSTCOUNT / 1024 - 80)) ]] &&
6051 F78SIZE=$((SMALLESTOST * $OSTCOUNT / 1024 - 80))
6053 [ "$SLOW" = "no" ] && NSEQ=1 && [ $F78SIZE -gt 32 ] && F78SIZE=32
6054 echo "File size: $F78SIZE"
6055 $SETSTRIPE -c $OSTCOUNT $DIR/$tfile || error "setstripe failed"
6056 for i in $(seq 1 $NSEQ); do
6057 FSIZE=$(($F78SIZE / ($NSEQ - $i + 1)))
6058 echo directIO rdwr round $i of $NSEQ
6059 $DIRECTIO rdwr $DIR/$tfile 0 $FSIZE 1048576||error "rdwr failed"
6064 run_test 78 "handle large O_DIRECT writes correctly ============"
6066 test_79() { # bug 12743
6067 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6068 wait_delete_completed
6070 BKTOTAL=$(calc_osc_kbytes kbytestotal)
6071 BKFREE=$(calc_osc_kbytes kbytesfree)
6072 BKAVAIL=$(calc_osc_kbytes kbytesavail)
6074 STRING=`df -P $MOUNT | tail -n 1 | awk '{print $2","$3","$4}'`
6075 DFTOTAL=`echo $STRING | cut -d, -f1`
6076 DFUSED=`echo $STRING | cut -d, -f2`
6077 DFAVAIL=`echo $STRING | cut -d, -f3`
6078 DFFREE=$(($DFTOTAL - $DFUSED))
6080 ALLOWANCE=$((64 * $OSTCOUNT))
6082 if [ $DFTOTAL -lt $(($BKTOTAL - $ALLOWANCE)) ] ||
6083 [ $DFTOTAL -gt $(($BKTOTAL + $ALLOWANCE)) ] ; then
6084 error "df total($DFTOTAL) mismatch OST total($BKTOTAL)"
6086 if [ $DFFREE -lt $(($BKFREE - $ALLOWANCE)) ] ||
6087 [ $DFFREE -gt $(($BKFREE + $ALLOWANCE)) ] ; then
6088 error "df free($DFFREE) mismatch OST free($BKFREE)"
6090 if [ $DFAVAIL -lt $(($BKAVAIL - $ALLOWANCE)) ] ||
6091 [ $DFAVAIL -gt $(($BKAVAIL + $ALLOWANCE)) ] ; then
6092 error "df avail($DFAVAIL) mismatch OST avail($BKAVAIL)"
6095 run_test 79 "df report consistency check ======================="
6097 test_80() { # bug 10718
6098 remote_ost_nodsh && skip "remote OST with nodsh" && return
6099 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6100 # relax strong synchronous semantics for slow backends like ZFS
6101 local soc="obdfilter.*.sync_on_lock_cancel"
6102 local soc_old=$(do_facet ost1 lctl get_param -n $soc | head -n1)
6104 if [ "$soc_old" != "never" -a "$(facet_fstype ost1)" != "ldiskfs" ]; then
6105 hosts=$(for host in $(seq -f "ost%g" 1 $OSTCOUNT); do
6106 facet_active_host $host; done | sort -u)
6107 do_nodes $hosts lctl set_param $soc=never
6110 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=1M
6112 local BEFORE=`date +%s`
6113 cancel_lru_locks osc
6114 local AFTER=`date +%s`
6115 local DIFF=$((AFTER-BEFORE))
6116 if [ $DIFF -gt 1 ] ; then
6117 error "elapsed for 1M@1T = $DIFF"
6120 [ -n "$hosts" ] && do_nodes $hosts lctl set_param $soc=$soc_old
6124 run_test 80 "Page eviction is equally fast at high offsets too ===="
6126 test_81a() { # LU-456
6127 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6128 remote_ost_nodsh && skip "remote OST with nodsh" && return
6129 # define OBD_FAIL_OST_MAPBLK_ENOSPC 0x228
6130 # MUST OR with the OBD_FAIL_ONCE (0x80000000)
6131 do_facet ost1 lctl set_param fail_loc=0x80000228
6133 # write should trigger a retry and success
6134 $SETSTRIPE -i 0 -c 1 $DIR/$tfile
6135 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
6137 if [ $RC -ne 0 ] ; then
6138 error "write should success, but failed for $RC"
6141 run_test 81a "OST should retry write when get -ENOSPC ==============="
6143 test_81b() { # LU-456
6144 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6145 remote_ost_nodsh && skip "remote OST with nodsh" && return
6146 # define OBD_FAIL_OST_MAPBLK_ENOSPC 0x228
6147 # Don't OR with the OBD_FAIL_ONCE (0x80000000)
6148 do_facet ost1 lctl set_param fail_loc=0x228
6150 # write should retry several times and return -ENOSPC finally
6151 $SETSTRIPE -i 0 -c 1 $DIR/$tfile
6152 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
6155 if [ $RC -ne $ENOSPC ] ; then
6156 error "dd should fail for -ENOSPC, but succeed."
6159 run_test 81b "OST should return -ENOSPC when retry still fails ======="
6161 test_82() { # LU-1031
6162 dd if=/dev/zero of=$DIR/$tfile bs=1M count=10
6166 multiop_bg_pause $DIR/$tfile OG${gid1}_g${gid1}c || return 1
6168 multiop_bg_pause $DIR/$tfile O_G${gid2}r10g${gid2}c || return 2
6170 kill -USR1 $MULTIPID2
6172 if [[ `ps h -o comm -p $MULTIPID2` == "" ]]; then
6173 error "First grouplock does not block second one"
6175 echo "Second grouplock blocks first one"
6177 kill -USR1 $MULTIPID1
6181 run_test 82 "Basic grouplock test ==============================="
6184 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" &&
6186 test_mkdir -p $DIR/d99cvsroot
6187 chown $RUNAS_ID $DIR/d99cvsroot
6188 local oldPWD=$PWD # bug 13584, use $TMP as working dir
6191 $RUNAS cvs -d $DIR/d99cvsroot init || error "cvs init failed"
6194 run_test 99a "cvs init ========================================="
6197 [ -z "$(which cvs 2>/dev/null)" ] &&
6198 skip_env "could not find cvs" && return
6199 [ ! -d $DIR/d99cvsroot ] && test_99a
6201 # some versions of cvs import exit(1) when asked to import links or
6202 # files they can't read. ignore those files.
6203 TOIGNORE=$(find . -type l -printf '-I %f\n' -o \
6204 ! -perm +4 -printf '-I %f\n')
6205 $RUNAS cvs -d $DIR/d99cvsroot import -m "nomesg" $TOIGNORE \
6206 d99reposname vtag rtag
6208 run_test 99b "cvs import ======================================="
6211 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" && return
6212 [ ! -d $DIR/d99cvsroot ] && test_99b
6214 test_mkdir -p $DIR/d99reposname
6215 chown $RUNAS_ID $DIR/d99reposname
6216 $RUNAS cvs -d $DIR/d99cvsroot co d99reposname
6218 run_test 99c "cvs checkout ====================================="
6221 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" && return
6222 [ ! -d $DIR/d99cvsroot ] && test_99c
6223 cd $DIR/d99reposname
6225 $RUNAS cvs add -m 'addmsg' foo99
6227 run_test 99d "cvs add =========================================="
6230 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" && return
6231 [ ! -d $DIR/d99cvsroot ] && test_99c
6232 cd $DIR/d99reposname
6235 run_test 99e "cvs update ======================================="
6238 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" && return
6239 [ ! -d $DIR/d99cvsroot ] && test_99d
6240 cd $DIR/d99reposname
6241 $RUNAS cvs commit -m 'nomsg' foo99
6242 rm -fr $DIR/d99cvsroot
6244 run_test 99f "cvs commit ======================================="
6247 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6248 [ "$NETTYPE" = tcp ] || \
6249 { skip "TCP secure port test, not useful for NETTYPE=$NETTYPE" && \
6252 remote_ost_nodsh && skip "remote OST with nodsh" && return
6253 remote_mds_nodsh && skip "remote MDS with nodsh" && return
6255 { skip "useless for local single node setup" && return; }
6257 netstat -tna | ( rc=1; while read PROT SND RCV LOCAL REMOTE STAT; do
6258 [ "$PROT" != "tcp" ] && continue
6259 RPORT=$(echo $REMOTE | cut -d: -f2)
6260 [ "$RPORT" != "$ACCEPTOR_PORT" ] && continue
6263 LPORT=`echo $LOCAL | cut -d: -f2`
6264 if [ $LPORT -ge 1024 ]; then
6265 echo "bad: $PROT $SND $RCV $LOCAL $REMOTE $STAT"
6267 error_exit "local: $LPORT > 1024, remote: $RPORT"
6270 [ "$rc" = 0 ] || error_exit "privileged port not found" )
6272 run_test 100 "check local port using privileged port ==========="
6274 function get_named_value()
6283 echo $line | sed "s/^$tag[ ]*//"
6290 export CACHE_MAX=$($LCTL get_param -n llite.*.max_cached_mb |
6291 awk '/^max_cached_mb/ { print $2 }')
6294 $LCTL set_param -n llite.*.max_cached_mb $CACHE_MAX
6299 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6300 [ $MDSCOUNT -ge 2 ] && skip "skip now for >= 2 MDTs" && return #LU-4322
6304 local cache_limit=32
6306 $LCTL set_param -n osc.*-osc*.rpc_stats 0
6307 trap cleanup_101a EXIT
6308 $LCTL set_param -n llite.*.read_ahead_stats 0
6309 $LCTL set_param -n llite.*.max_cached_mb $cache_limit
6312 # randomly read 10000 of 64K chunks from file 3x 32MB in size
6314 echo "nreads: $nreads file size: $((cache_limit * 3))MB"
6315 $READS -f $DIR/$tfile -s$((cache_limit * 3192 * 1024)) -b65536 -C -n$nreads -t 180
6318 for s in $($LCTL get_param -n llite.*.read_ahead_stats |
6319 get_named_value 'read but discarded' | cut -d" " -f1); do
6320 discard=$(($discard + $s))
6324 if [[ $(($discard * 10)) -gt $nreads ]]; then
6325 $LCTL get_param osc.*-osc*.rpc_stats
6326 $LCTL get_param llite.*.read_ahead_stats
6327 error "too many ($discard) discarded pages"
6329 rm -f $DIR/$tfile || true
6331 run_test 101a "check read-ahead for random reads ================"
6334 test_mkdir -p $DIR/$tdir
6335 local STRIPE_SIZE=$1
6336 local FILE_LENGTH=$2
6339 local FILE_SIZE_MB=$((FILE_LENGTH / STRIPE_SIZE))
6341 local list=$(comma_list $(osts_nodes))
6342 set_osd_param $list '' read_cache_enable 0
6343 set_osd_param $list '' writethrough_cache_enable 0
6345 trap cleanup_test101bc EXIT
6346 # prepare the read-ahead file
6347 $SETSTRIPE -S $STRIPE_SIZE -i $STRIPE_OFFSET -c $OSTCOUNT $DIR/$tfile
6349 dd if=/dev/zero of=$DIR/$tfile bs=$STRIPE_SIZE \
6350 count=$FILE_SIZE_MB 2> /dev/null
6354 cleanup_test101bc() {
6359 local list=$(comma_list $(osts_nodes))
6360 set_osd_param $list '' read_cache_enable 1
6361 set_osd_param $list '' writethrough_cache_enable 1
6365 awk 'BEGIN{total=0}; {total+=$1}; END{print total}'
6370 local STRIPE_SIZE=$2
6371 local FILE_LENGTH=$3
6372 local RA_INC=1048576
6373 local STRIDE_LENGTH=$((STRIPE_SIZE/READ_SIZE))
6374 local discard_limit=$((((STRIDE_LENGTH - 1)*3/(STRIDE_LENGTH*OSTCOUNT))* \
6375 (STRIDE_LENGTH*OSTCOUNT - STRIDE_LENGTH)))
6376 DISCARD=$($LCTL get_param -n llite.*.read_ahead_stats |
6377 get_named_value 'read but discarded' |
6378 cut -d" " -f1 | calc_total)
6379 if [[ $DISCARD -gt $discard_limit ]]; then
6380 $LCTL get_param llite.*.read_ahead_stats
6381 error "Too many ($DISCARD) discarded pages with size (${READ_SIZE})"
6383 echo "Read-ahead success for size ${READ_SIZE}"
6388 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6389 [[ $OSTCOUNT -lt 2 ]] &&
6390 skip_env "skipping stride IO stride-ahead test" && return
6391 local STRIPE_SIZE=1048576
6392 local STRIDE_SIZE=$((STRIPE_SIZE*OSTCOUNT))
6393 if [ $SLOW == "yes" ]; then
6394 local FILE_LENGTH=$((STRIDE_SIZE * 64))
6396 local FILE_LENGTH=$((STRIDE_SIZE * 8))
6399 local ITERATION=$((FILE_LENGTH / STRIDE_SIZE))
6401 # prepare the read-ahead file
6402 setup_test101bc $STRIPE_SIZE $FILE_LENGTH
6403 cancel_lru_locks osc
6404 for BIDX in 2 4 8 16 32 64 128 256
6406 local BSIZE=$((BIDX*4096))
6407 local READ_COUNT=$((STRIPE_SIZE/BSIZE))
6408 local STRIDE_LENGTH=$((STRIDE_SIZE/BSIZE))
6409 local OFFSET=$((STRIPE_SIZE/BSIZE*(OSTCOUNT - 1)))
6410 $LCTL set_param -n llite.*.read_ahead_stats 0
6411 $READS -f $DIR/$tfile -l $STRIDE_LENGTH -o $OFFSET \
6412 -s $FILE_LENGTH -b $STRIPE_SIZE -a $READ_COUNT -n $ITERATION
6413 cancel_lru_locks osc
6414 ra_check_101 $BSIZE $STRIPE_SIZE $FILE_LENGTH
6419 run_test 101b "check stride-io mode read-ahead ================="
6422 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6423 local STRIPE_SIZE=1048576
6424 local FILE_LENGTH=$((STRIPE_SIZE*100))
6428 setup_test101bc $STRIPE_SIZE $FILE_LENGTH
6430 cancel_lru_locks osc
6431 $LCTL set_param osc.*.rpc_stats 0
6432 $READS -f $DIR/$tfile -s$FILE_LENGTH -b65536 -n$nreads -t 180
6433 for osc_rpc_stats in $($LCTL get_param -N osc.*.rpc_stats); do
6434 local stats=$($LCTL get_param -n $osc_rpc_stats)
6435 local lines=$(echo "$stats" | awk 'END {print NR;}')
6438 if [ $lines -le 20 ]; then
6441 for size in 1 2 4 8; do
6442 local rpc=$(echo "$stats" |
6443 awk '($1 == "'$size':") {print $2; exit; }')
6445 error "Small $((size*4))k read IO $rpc !"
6447 echo "$osc_rpc_stats check passed!"
6452 run_test 101c "check stripe_size aligned read-ahead ================="
6455 $LCTL get_param -n llite.*.max_read_ahead_mb | head -n 1
6456 $LCTL set_param -n llite.*.max_read_ahead_mb $1 > /dev/null 2>&1
6460 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6461 local file=$DIR/$tfile
6462 local sz_MB=${FILESIZE_101d:-500}
6463 local ra_MB=${READAHEAD_MB:-40}
6465 local free_MB=$(($(df -P $DIR | tail -n 1 | awk '{ print $4 }') / 1024))
6466 [ $free_MB -lt $sz_MB ] &&
6467 skip "Need free space ${sz_MB}M, have ${free_MB}M" && return
6469 echo "Create test file $file size ${sz_MB}M, ${free_MB}M free"
6470 $SETSTRIPE -c -1 $file || error "setstripe failed"
6472 dd if=/dev/zero of=$file bs=1M count=$sz_MB || error "dd failed"
6473 echo Cancel LRU locks on lustre client to flush the client cache
6474 cancel_lru_locks osc
6476 echo Disable read-ahead
6477 local old_READAHEAD=$(set_read_ahead 0)
6479 echo Reading the test file $file with read-ahead disabled
6480 local raOFF=$(do_and_time "dd if=$file of=/dev/null bs=1M count=$sz_MB")
6482 echo Cancel LRU locks on lustre client to flush the client cache
6483 cancel_lru_locks osc
6484 echo Enable read-ahead with ${ra_MB}MB
6485 set_read_ahead $ra_MB
6487 echo Reading the test file $file with read-ahead enabled
6488 local raON=$(do_and_time "dd if=$file of=/dev/null bs=1M count=$sz_MB")
6490 echo "read-ahead disabled time read $raOFF"
6491 echo "read-ahead enabled time read $raON"
6493 set_read_ahead $old_READAHEAD
6495 wait_delete_completed
6497 [ $raOFF -le 1 -o $raON -lt $raOFF ] ||
6498 error "readahead ${raON}s > no-readahead ${raOFF}s ${sz_MB}M"
6500 run_test 101d "file read with and without read-ahead enabled"
6503 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6504 local file=$DIR/$tfile
6505 local size_KB=500 #KB
6509 local free_KB=$(df -P $DIR | tail -n 1 | awk '{ print $4 }')
6510 local need_KB=$((count * size_KB))
6511 [[ $free_KB -le $need_KB ]] &&
6512 skip_env "Need free space $need_KB, have $free_KB" && return
6514 echo "Creating $count ${size_KB}K test files"
6515 for ((i = 0; i < $count; i++)); do
6516 dd if=/dev/zero of=$file.$i bs=$bsize count=$size_KB 2>/dev/null
6519 echo "Cancel LRU locks on lustre client to flush the client cache"
6520 cancel_lru_locks osc
6522 echo "Reset readahead stats"
6523 $LCTL set_param -n llite.*.read_ahead_stats 0
6525 for ((i = 0; i < $count; i++)); do
6526 dd if=$file.$i of=/dev/null bs=$bsize count=$size_KB 2>/dev/null
6529 local miss=$($LCTL get_param -n llite.*.read_ahead_stats |
6530 get_named_value 'misses' | cut -d" " -f1 | calc_total)
6532 for ((i = 0; i < $count; i++)); do
6533 rm -rf $file.$i 2>/dev/null
6536 #10000 means 20% reads are missing in readahead
6537 [[ $miss -lt 10000 ]] || error "misses too much for small reads"
6539 run_test 101e "check read-ahead for small read(1k) for small files(500k)"
6541 cleanup_test101f() {
6543 $LCTL set_param -n llite.*.max_read_ahead_whole_mb $MAX_WHOLE_MB
6544 rm -rf $DIR/$tfile 2>/dev/null
6548 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6549 local file=$DIR/$tfile
6552 MAX_WHOLE_MB=$($LCTL get_param -n llite.*.max_read_ahead_whole_mb)
6553 $LCTL set_param -n llite.*.max_read_ahead_whole_mb 2
6554 dd if=/dev/zero of=${file} bs=2097152 count=1 2>/dev/null
6555 trap cleanup_test101f EXIT
6557 echo Cancel LRU locks on lustre client to flush the client cache
6558 cancel_lru_locks osc
6560 echo Reset readahead stats
6561 $LCTL set_param -n llite.*.read_ahead_stats 0
6562 # Random read in a 2M file, because max_read_ahead_whole_mb = 2M,
6563 # readahead should read in 2M file on second read, so only miss
6565 echo Random 4K reads on 2M file for 1000 times
6566 $READS -f $file -s 2097152 -b 4096 -n $nreads
6568 echo checking missing pages
6569 local miss=$($LCTL get_param -n llite.*.read_ahead_stats |
6570 get_named_value 'misses' | cut -d" " -f1 | calc_total)
6572 [ $miss -lt 3 ] || error "misses too much pages!"
6575 run_test 101f "check read-ahead for max_read_ahead_whole_mb"
6578 test_mkdir -p $DIR/$tdir
6579 chown $RUNAS_ID $DIR/$tdir
6582 STRIPE_COUNT=$OSTCOUNT
6583 [[ $OSTCOUNT -gt 4 ]] && STRIPE_COUNT=4
6585 trap cleanup_test102 EXIT
6587 $1 $SETSTRIPE -S $STRIPE_SIZE -i $STRIPE_OFFSET -c $STRIPE_COUNT $tdir
6589 for num in 1 2 3 4; do
6590 for count in $(seq 1 $STRIPE_COUNT); do
6591 for idx in $(seq 0 $[$STRIPE_COUNT - 1]); do
6592 local size=`expr $STRIPE_SIZE \* $num`
6593 local file=file"$num-$idx-$count"
6594 $1 $SETSTRIPE -S $size -i $idx -c $count $file
6600 $1 $TAR cf $TMP/f102.tar $tdir --xattrs
6606 rm -rf $DIR/d0.sanity/d102
6610 local testfile=$DIR/$tfile
6614 [ "$UID" != 0 ] && skip_env "must run as root" && return
6615 [ -z "$(lctl get_param -n mdc.*-mdc-*.connect_flags | grep xattr)" ] &&
6616 skip_env "must have user_xattr" && return
6618 [ -z "$(which setfattr 2>/dev/null)" ] &&
6619 skip_env "could not find setfattr" && return
6621 echo "set/get xattr..."
6622 setfattr -n trusted.name1 -v value1 $testfile ||
6623 error "setfattr -n trusted.name1=value1 $testfile failed"
6624 getfattr -n trusted.name1 $testfile 2> /dev/null |
6625 grep "trusted.name1=.value1" ||
6626 error "$testfile missing trusted.name1=value1"
6628 setfattr -n user.author1 -v author1 $testfile ||
6629 error "setfattr -n user.author1=author1 $testfile failed"
6630 getfattr -n user.author1 $testfile 2> /dev/null |
6631 grep "user.author1=.author1" ||
6632 error "$testfile missing trusted.author1=author1"
6635 setfattr -n trusted.name2 -v value2 $testfile ||
6636 error "$testfile unable to set trusted.name2"
6637 setfattr -n trusted.name3 -v value3 $testfile ||
6638 error "$testfile unable to set trusted.name3"
6639 [ $(getfattr -d -m "^trusted" $testfile 2> /dev/null |
6640 grep "trusted.name" | wc -l) -eq 3 ] ||
6641 error "$testfile missing 3 trusted.name xattrs"
6643 setfattr -n user.author2 -v author2 $testfile ||
6644 error "$testfile unable to set user.author2"
6645 setfattr -n user.author3 -v author3 $testfile ||
6646 error "$testfile unable to set user.author3"
6647 [ $(getfattr -d -m "^user" $testfile 2> /dev/null |
6648 grep "user.author" | wc -l) -eq 3 ] ||
6649 error "$testfile missing 3 user.author xattrs"
6651 echo "remove xattr..."
6652 setfattr -x trusted.name1 $testfile ||
6653 error "$testfile error deleting trusted.name1"
6654 getfattr -d -m trusted $testfile 2> /dev/null | grep "trusted.name1" &&
6655 error "$testfile did not delete trusted.name1 xattr"
6657 setfattr -x user.author1 $testfile ||
6658 error "$testfile error deleting user.author1"
6659 getfattr -d -m user $testfile 2> /dev/null | grep "user.author1" &&
6660 error "$testfile did not delete trusted.name1 xattr"
6662 # b10667: setting lustre special xattr be silently discarded
6663 echo "set lustre special xattr ..."
6664 setfattr -n "trusted.lov" -v "invalid value" $testfile ||
6665 error "$testfile allowed setting trusted.lov"
6667 run_test 102a "user xattr test =================================="
6670 [ -z "$(which setfattr 2>/dev/null)" ] &&
6671 skip_env "could not find setfattr" && return
6673 # b10930: get/set/list trusted.lov xattr
6674 echo "get/set/list trusted.lov xattr ..."
6675 [[ $OSTCOUNT -lt 2 ]] && skip_env "skipping 2-stripe test" && return
6676 local testfile=$DIR/$tfile
6677 $SETSTRIPE -S 65536 -i 1 -c $OSTCOUNT $testfile ||
6678 error "setstripe failed"
6679 local STRIPECOUNT=$($GETSTRIPE -c $testfile) ||
6680 error "getstripe failed"
6681 getfattr -d -m "^trusted" $testfile 2>/dev/null | grep "trusted.lov" ||
6682 error "can't get trusted.lov from $testfile"
6684 local testfile2=${testfile}2
6685 local value=$(getfattr -n trusted.lov $testfile 2>/dev/null |
6686 grep "trusted.lov" | sed -e 's/[^=]\+=//')
6689 setfattr -n trusted.lov -v $value $testfile2
6690 local stripe_size=$($GETSTRIPE -S $testfile2)
6691 local stripe_count=$($GETSTRIPE -c $testfile2)
6692 [[ $stripe_size -eq 65536 ]] ||
6693 error "stripe size $stripe_size != 65536"
6694 [[ $stripe_count -eq $STRIPECOUNT ]] ||
6695 error "stripe count $stripe_count != $STRIPECOUNT"
6698 run_test 102b "getfattr/setfattr for trusted.lov EAs ============"
6701 [ -z "$(which setfattr 2>/dev/null)" ] &&
6702 skip_env "could not find setfattr" && return
6704 # b10930: get/set/list lustre.lov xattr
6705 echo "get/set/list lustre.lov xattr ..."
6706 [[ $OSTCOUNT -lt 2 ]] && skip_env "skipping 2-stripe test" && return
6707 test_mkdir -p $DIR/$tdir
6708 chown $RUNAS_ID $DIR/$tdir
6709 local testfile=$DIR/$tdir/$tfile
6710 $RUNAS $SETSTRIPE -S 65536 -i 1 -c $OSTCOUNT $testfile ||
6711 error "setstripe failed"
6712 local STRIPECOUNT=$($RUNAS $GETSTRIPE -c $testfile) ||
6713 error "getstripe failed"
6714 $RUNAS getfattr -d -m "^lustre" $testfile 2> /dev/null | \
6715 grep "lustre.lov" || error "can't get lustre.lov from $testfile"
6717 local testfile2=${testfile}2
6718 local value=`getfattr -n lustre.lov $testfile 2> /dev/null | \
6719 grep "lustre.lov" |sed -e 's/[^=]\+=//' `
6721 $RUNAS $MCREATE $testfile2
6722 $RUNAS setfattr -n lustre.lov -v $value $testfile2
6723 local stripe_size=$($RUNAS $GETSTRIPE -S $testfile2)
6724 local stripe_count=$($RUNAS $GETSTRIPE -c $testfile2)
6725 [ $stripe_size -eq 65536 ] || error "stripe size $stripe_size != 65536"
6726 [ $stripe_count -eq $STRIPECOUNT ] ||
6727 error "stripe count $stripe_count != $STRIPECOUNT"
6729 run_test 102c "non-root getfattr/setfattr for lustre.lov EAs ==========="
6731 compare_stripe_info1() {
6732 local stripe_index_all_zero=true
6734 for num in 1 2 3 4; do
6735 for count in $(seq 1 $STRIPE_COUNT); do
6736 for offset in $(seq 0 $[$STRIPE_COUNT - 1]); do
6737 local size=$((STRIPE_SIZE * num))
6738 local file=file"$num-$offset-$count"
6739 stripe_size=$($LFS getstripe -S $PWD/$file)
6740 [[ $stripe_size -ne $size ]] &&
6741 error "$file: size $stripe_size != $size"
6742 stripe_count=$($LFS getstripe -c $PWD/$file)
6743 # allow fewer stripes to be created, ORI-601
6744 [[ $stripe_count -lt $(((3 * count + 3) / 4)) ]] &&
6745 error "$file: count $stripe_count != $count"
6746 stripe_index=$($LFS getstripe -i $PWD/$file)
6747 [[ $stripe_index -ne 0 ]] &&
6748 stripe_index_all_zero=false
6752 $stripe_index_all_zero &&
6753 error "all files are being extracted starting from OST index 0"
6758 [ -n "$(which tar 2>/dev/null)" ] &&
6759 strings $(which tar) | grep -q "lustre" && echo tar
6763 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6764 # b10930: tar test for trusted.lov xattr
6765 TAR=$(find_lustre_tar)
6766 [ -z "$TAR" ] && skip_env "lustre-aware tar is not installed" && return
6767 [[ $OSTCOUNT -lt 2 ]] && skip_env "skipping N-stripe test" && return
6769 test_mkdir -p $DIR/d102d
6770 $TAR xf $TMP/f102.tar -C $DIR/d102d --xattrs
6772 compare_stripe_info1
6774 run_test 102d "tar restore stripe info from tarfile,not keep osts ==========="
6777 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6778 # b10930: tar test for trusted.lov xattr
6779 TAR=$(find_lustre_tar)
6780 [ -z "$TAR" ] && skip_env "lustre-aware tar is not installed" && return
6781 [[ $OSTCOUNT -lt 2 ]] && skip_env "skipping N-stripe test" && return
6783 test_mkdir -p $DIR/d102f
6785 $TAR cf - --xattrs $tdir | $TAR xf - --xattrs -C $DIR/d102f
6787 compare_stripe_info1
6789 run_test 102f "tar copy files, not keep osts ==========="
6792 local xsize=${1:-1024} # in bytes
6793 local file=$DIR/$tfile
6795 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep xattr)" ] &&
6796 skip "must have user_xattr" && return 0
6797 [ -z "$(which setfattr 2>/dev/null)" ] &&
6798 skip_env "could not find setfattr" && return 0
6799 [ -z "$(which getfattr 2>/dev/null)" ] &&
6800 skip_env "could not find getfattr" && return 0
6804 local value="$(generate_string $xsize)"
6806 local xbig=trusted.big
6807 log "save $xbig on $file"
6808 setfattr -n $xbig -v $value $file ||
6809 error "saving $xbig on $file failed"
6811 local orig=$(get_xattr_value $xbig $file)
6812 [[ "$orig" != "$value" ]] && error "$xbig different after saving $xbig"
6814 local xsml=trusted.sml
6815 log "save $xsml on $file"
6816 setfattr -n $xsml -v val $file || error "saving $xsml on $file failed"
6818 local new=$(get_xattr_value $xbig $file)
6819 [[ "$new" != "$orig" ]] && error "$xbig different after saving $xsml"
6821 log "grow $xsml on $file"
6822 setfattr -n $xsml -v "$value" $file ||
6823 error "growing $xsml on $file failed"
6825 new=$(get_xattr_value $xbig $file)
6826 [[ "$new" != "$orig" ]] && error "$xbig different after growing $xsml"
6827 log "$xbig still valid after growing $xsml"
6832 test_102h() { # bug 15777
6835 run_test 102h "grow xattr from inside inode to external block"
6838 large_xattr_enabled || { skip "large_xattr disabled" && return; }
6839 grow_xattr $(max_xattr_size)
6841 run_test 102ha "grow xattr from inside inode to external inode"
6843 test_102i() { # bug 17038
6844 [ -z "$(which getfattr 2>/dev/null)" ] &&
6845 skip "could not find getfattr" && return
6847 ln -s $DIR/$tfile $DIR/${tfile}link
6848 getfattr -n trusted.lov $DIR/$tfile ||
6849 error "lgetxattr on $DIR/$tfile failed"
6850 getfattr -h -n trusted.lov $DIR/${tfile}link 2>&1 |
6851 grep -i "no such attr" ||
6852 error "error for lgetxattr on $DIR/${tfile}link is not ENODATA"
6853 rm -f $DIR/$tfile $DIR/${tfile}link
6855 run_test 102i "lgetxattr test on symbolic link ============"
6858 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6859 TAR=$(find_lustre_tar)
6860 [ -z "$TAR" ] && skip_env "lustre-aware tar is not installed" && return
6861 [[ $OSTCOUNT -lt 2 ]] && skip_env "skipping N-stripe test" && return
6862 setup_test102 "$RUNAS"
6863 test_mkdir -p $DIR/d102j
6864 chown $RUNAS_ID $DIR/d102j
6865 $RUNAS $TAR xf $TMP/f102.tar -C $DIR/d102j --xattrs
6867 compare_stripe_info1 "$RUNAS"
6869 run_test 102j "non-root tar restore stripe info from tarfile, not keep osts ==="
6872 [ -z "$(which setfattr 2>/dev/null)" ] &&
6873 skip "could not find setfattr" && return
6875 # b22187 just check that does not crash for regular file.
6876 setfattr -n trusted.lov $DIR/$tfile
6877 # b22187 'setfattr -n trusted.lov' should work as remove LOV EA for directories
6878 local test_kdir=$DIR/d102k
6879 test_mkdir $test_kdir
6880 local default_size=`$GETSTRIPE -S $test_kdir`
6881 local default_count=`$GETSTRIPE -c $test_kdir`
6882 local default_offset=`$GETSTRIPE -i $test_kdir`
6883 $SETSTRIPE -S 65536 -i 0 -c $OSTCOUNT $test_kdir ||
6884 error 'dir setstripe failed'
6885 setfattr -n trusted.lov $test_kdir
6886 local stripe_size=`$GETSTRIPE -S $test_kdir`
6887 local stripe_count=`$GETSTRIPE -c $test_kdir`
6888 local stripe_offset=`$GETSTRIPE -i $test_kdir`
6889 [ $stripe_size -eq $default_size ] ||
6890 error "stripe size $stripe_size != $default_size"
6891 [ $stripe_count -eq $default_count ] ||
6892 error "stripe count $stripe_count != $default_count"
6893 [ $stripe_offset -eq $default_offset ] ||
6894 error "stripe offset $stripe_offset != $default_offset"
6895 rm -rf $DIR/$tfile $test_kdir
6897 run_test 102k "setfattr without parameter of value shouldn't cause a crash"
6900 [ -z "$(which getfattr 2>/dev/null)" ] &&
6901 skip "could not find getfattr" && return
6903 # LU-532 trusted. xattr is invisible to non-root
6904 local testfile=$DIR/$tfile
6908 echo "listxattr as user..."
6909 chown $RUNAS_ID $testfile
6910 $RUNAS getfattr -d -m '.*' $testfile 2>&1 |
6911 grep -q "trusted" &&
6912 error "$testfile trusted xattrs are user visible"
6916 run_test 102l "listxattr size test =================================="
6918 test_102m() { # LU-3403 llite: error of listxattr when buffer is small
6919 local path=$DIR/$tfile
6922 listxattr_size_check $path || error "listattr_size_check $path failed"
6924 run_test 102m "Ensure listxattr fails on small bufffer ========"
6928 getxattr() { # getxattr path name
6929 # Return the base64 encoding of the value of xattr name on path.
6933 # # getfattr --absolute-names --encoding=base64 --name=trusted.lov $path
6935 # trusted.lov=0s0AvRCwEAAAAGAAAAAAAAAAAEAAACAAAAAAAQAAEAA...AAAAAAAAA=
6937 # We print just 0s0AvRCwEAAAAGAAAAAAAAAAAEAAACAAAAAAAQAAEAA...AAAAAAAAA=
6939 getfattr --absolute-names --encoding=base64 --name=$name $path |
6940 awk -F= -v name=$name '$1 == name {
6941 print substr($0, index($0, "=") + 1);
6945 test_102n() { # LU-4101 mdt: protect internal xattrs
6946 local file0=$DIR/$tfile.0
6947 local file1=$DIR/$tfile.1
6948 local xattr0=$TMP/$tfile.0
6949 local xattr1=$TMP/$tfile.1
6953 [ -z "$(which setfattr 2>/dev/null)" ] &&
6954 skip "could not find setfattr" && return
6956 if [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.5.50) ]
6958 skip "MDT < 2.5.50 allows setxattr on internal trusted xattrs"
6962 rm -rf $file0 $file1 $xattr0 $xattr1
6965 # Get 'before' xattrs of $file1.
6966 getfattr --absolute-names --dump --match=- $file1 > $xattr0
6968 for name in lov lma lmv link fid version som hsm lfsck_namespace; do
6969 # Try to copy xattr from $file0 to $file1.
6970 value=$(getxattr $file0 trusted.$name 2> /dev/null)
6972 setfattr --name=trusted.$name --value="$value" $file1 ||
6973 error "setxattr 'trusted.$name' failed"
6975 # Try to set a garbage xattr.
6976 value=0sVGhlIHF1aWNrIGJyb3duIGZveCBqdW1wcyBvdmVyIGl0c2VsZi4=
6978 setfattr --name=trusted.$name --value="$value" $file1 ||
6979 error "setxattr 'trusted.$name' failed"
6981 # Try to remove the xattr from $file1. We don't care if this
6982 # appears to succeed or fail, we just don't want there to be
6983 # any changes or crashes.
6984 setfattr --remove=$trusted.$name $file1 2> /dev/null
6987 if [ $(lustre_version_code $SINGLEMDS) -gt $(version_code 2.6.50) ]
6990 # Try to copy xattr from $file0 to $file1.
6991 value=$(getxattr $file0 trusted.$name 2> /dev/null)
6993 setfattr --name=trusted.$name --value="$value" $file1 ||
6994 error "setxattr 'trusted.$name' failed"
6996 # Try to set a garbage xattr.
6997 value=0sVGhlIHF1aWNrIGJyb3duIGZveCBqdW1wcyBvdmVyIGl0c2VsZi4=
6999 setfattr --name=trusted.$name --value="$value" $file1 ||
7000 error "setxattr 'trusted.$name' failed"
7002 # Try to remove the xattr from $file1. We don't care if this
7003 # appears to succeed or fail, we just don't want there to be
7004 # any changes or crashes.
7005 setfattr --remove=$trusted.$name $file1 2> /dev/null
7008 # Get 'after' xattrs of file1.
7009 getfattr --absolute-names --dump --match=- $file1 > $xattr1
7011 if ! diff $xattr0 $xattr1; then
7012 error "before and after xattrs of '$file1' differ"
7015 rm -rf $file0 $file1 $xattr0 $xattr1
7019 run_test 102n "silently ignore setxattr on internal trusted xattrs"
7021 test_102p() { # LU-4703 setxattr did not check ownership
7022 local testfile=$DIR/$tfile
7024 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.5.56) ] &&
7025 skip "MDS needs to be at least 2.5.56" && return
7029 echo "setfacl as user..."
7030 $RUNAS setfacl -m "u:$RUNAS_ID:rwx" $testfile
7031 [ $? -ne 0 ] || error "setfacl by $RUNAS_ID was allowed on $testfile"
7033 echo "setfattr as user..."
7034 setfacl -m "u:$RUNAS_ID:---" $testfile
7035 $RUNAS setfattr -x system.posix_acl_access $testfile
7036 [ $? -ne 0 ] || error "setfattr by $RUNAS_ID was allowed on $testfile"
7038 run_test 102p "check setxattr(2) correctly fails without permission"
7041 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.6.92) ] &&
7042 skip "MDS needs to be at least 2.6.92" && return
7043 orphan_linkea_check $DIR/$tfile || error "orphan_linkea_check"
7045 run_test 102q "flistxattr should not return trusted.link EAs for orphans"
7048 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.6.93) ] &&
7049 skip "MDS needs to be at least 2.6.93" && return
7050 touch $DIR/$tfile || error "touch"
7051 setfattr -n user.$(basename $tfile) $DIR/$tfile || error "setfattr"
7052 getfattr -n user.$(basename $tfile) $DIR/$tfile || error "getfattr"
7053 rm $DIR/$tfile || error "rm"
7056 mkdir -p $DIR/$tdir || error "mkdir"
7057 setfattr -n user.$(basename $tdir) $DIR/$tdir || error "setfattr dir"
7058 getfattr -n user.$(basename $tdir) $DIR/$tdir || error "getfattr dir"
7059 setfattr -x user.$(basename $tdir) $DIR/$tdir ||
7060 error "$testfile error deleting user.author1"
7061 getfattr -d -m user.$(basename $tdir) 2> /dev/null |
7062 grep "user.$(basename $tdir)" &&
7063 error "$tdir did not delete user.$(basename $tdir)"
7064 rmdir $DIR/$tdir || error "rmdir"
7067 test_mkdir -p $DIR/$tdir || error "make striped dir"
7068 setfattr -n user.$(basename $tdir) $DIR/$tdir || error "setfattr dir"
7069 getfattr -n user.$(basename $tdir) $DIR/$tdir || error "getfattr dir"
7070 setfattr -x user.$(basename $tdir) $DIR/$tdir ||
7071 error "$testfile error deleting user.author1"
7072 getfattr -d -m user.$(basename $tdir) 2> /dev/null |
7073 grep "user.$(basename $tdir)" &&
7074 error "$tdir did not delete user.$(basename $tdir)"
7075 rmdir $DIR/$tdir || error "rm striped dir"
7077 run_test 102r "set EAs with empty values"
7081 $LUSTRE/tests/acl/run $LUSTRE/tests/acl/$1.test
7086 [ "$UID" != 0 ] && skip_env "must run as root" && return
7087 [ -z "$(lctl get_param -n mdc.*-mdc-*.connect_flags | grep acl)" ] &&
7088 skip "must have acl enabled" && return
7089 [ -z "$(which setfacl 2>/dev/null)" ] &&
7090 skip_env "could not find setfacl" && return
7091 $GSS && skip "could not run under gss" && return
7093 gpasswd -a daemon bin # LU-5641
7094 do_facet $SINGLEMDS gpasswd -a daemon bin # LU-5641
7096 declare -a identity_old
7098 for num in $(seq $MDSCOUNT); do
7099 switch_identity $num true || identity_old[$num]=$?
7106 echo "performing cp ..."
7107 run_acl_subtest cp || error "run_acl_subtest cp failed"
7108 echo "performing getfacl-noacl..."
7109 run_acl_subtest getfacl-noacl || error "getfacl-noacl test failed"
7110 echo "performing misc..."
7111 run_acl_subtest misc || error "misc test failed"
7112 echo "performing permissions..."
7113 run_acl_subtest permissions || error "permissions failed"
7114 echo "performing setfacl..."
7115 run_acl_subtest setfacl || error "setfacl test failed"
7117 # inheritance test got from HP
7118 echo "performing inheritance..."
7119 cp $LUSTRE/tests/acl/make-tree . || error "cannot copy make-tree"
7120 chmod +x make-tree || error "chmod +x failed"
7121 run_acl_subtest inheritance || error "inheritance test failed"
7124 echo "LU-974 ignore umask when acl is enabled..."
7125 run_acl_subtest 974 || error "LU-974 umask test failed"
7126 if [ $MDSCOUNT -ge 2 ]; then
7127 run_acl_subtest 974_remote ||
7128 error "LU-974 umask test failed under remote dir"
7131 echo "LU-2561 newly created file is same size as directory..."
7132 if [ $(facet_fstype $SINGLEMDS) != "zfs" ]; then
7133 run_acl_subtest 2561 || error "LU-2561 test failed"
7135 run_acl_subtest 2561_zfs || error "LU-2561 zfs test failed"
7138 run_acl_subtest 4924 || error "LU-4924 test failed"
7143 for num in $(seq $MDSCOUNT); do
7144 if [ "${identity_old[$num]}" = 1 ]; then
7145 switch_identity $num false || identity_old[$num]=$?
7149 run_test 103a "acl test ========================================="
7153 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
7154 local mountopts=$MDS_MOUNT_OPTS
7156 if [[ "$MDS_MOUNT_OPTS" =~ "noacl" ]]; then
7160 stop $SINGLEMDS || error "failed to stop MDT."
7162 if [ -z "$MDS_MOUNT_OPTS" ]; then
7163 MDS_MOUNT_OPTS="-o noacl"
7165 MDS_MOUNT_OPTS="${MDS_MOUNT_OPTS},noacl"
7167 start $SINGLEMDS $MDT_DEV $MDS_MOUNT_OPTS ||
7168 error "failed to start MDT."
7169 MDS_MOUNT_OPTS=$mountopts
7173 setfacl -m u:bin:rw $DIR/$tfile && error "setfacl should fail"
7177 stop $SINGLEMDS || error "failed to stop MDT."
7179 start $SINGLEMDS $MDT_DEV $MDS_MOUNT_OPTS ||
7180 error "failed to start MDT."
7185 run_test 103b "MDS mount option 'noacl'"
7189 cp -rp $DIR/$tdir $DIR/$tdir.bak
7191 [ -n "$(getfattr -d -m. $DIR/$tdir | grep posix_acl_default)" ] &&
7192 error "$DIR/$tdir shouldn't contain default ACL"
7193 [ -n "$(getfattr -d -m. $DIR/$tdir.bak | grep posix_acl_default)" ] &&
7194 error "$DIR/$tdir.bak shouldn't contain default ACL"
7197 run_test 103c "'cp -rp' won't set empty acl"
7200 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7202 lfs df || error "lfs df failed"
7203 lfs df -ih || error "lfs df -ih failed"
7204 lfs df -h $DIR || error "lfs df -h $DIR failed"
7205 lfs df -i $DIR || error "lfs df -i $DIR failed"
7206 lfs df $DIR/$tfile || error "lfs df $DIR/$tfile failed"
7207 lfs df -ih $DIR/$tfile || error "lfs df -ih $DIR/$tfile failed"
7209 local OSC=$(lctl dl | grep OST0000-osc-[^M] | awk '{ print $4 }')
7210 lctl --device %$OSC deactivate
7211 lfs df || error "lfs df with deactivated OSC failed"
7212 lctl --device %$OSC activate
7213 # wait the osc back to normal
7214 wait_osc_import_state client ost FULL
7216 lfs df || error "lfs df with reactivated OSC failed"
7219 run_test 104a "lfs df [-ih] [path] test ========================="
7222 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7223 [ $RUNAS_ID -eq $UID ] &&
7224 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
7226 denied_cnt=$(($($RUNAS $LFS check servers 2>&1 |
7227 grep "Permission denied" | wc -l)))
7228 if [ $denied_cnt -ne 0 ]; then
7229 error "lfs check servers test failed"
7232 run_test 104b "$RUNAS lfs check servers test ===================="
7235 # doesn't work on 2.4 kernels
7237 if $(flock_is_enabled); then
7238 flocks_test 1 on -f $DIR/$tfile || error "fail flock on"
7240 flocks_test 1 off -f $DIR/$tfile || error "fail flock off"
7244 run_test 105a "flock when mounted without -o flock test ========"
7248 if $(flock_is_enabled); then
7249 flocks_test 1 on -c $DIR/$tfile || error "fail flock on"
7251 flocks_test 1 off -c $DIR/$tfile || error "fail flock off"
7255 run_test 105b "fcntl when mounted without -o flock test ========"
7259 if $(flock_is_enabled); then
7260 flocks_test 1 on -l $DIR/$tfile || error "fail flock on"
7262 flocks_test 1 off -l $DIR/$tfile || error "fail flock off"
7266 run_test 105c "lockf when mounted without -o flock test ========"
7268 test_105d() { # bug 15924
7269 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7270 test_mkdir -p $DIR/$tdir
7271 flock_is_enabled || { skip "mount w/o flock enabled" && return; }
7272 #define OBD_FAIL_LDLM_CP_CB_WAIT 0x315
7273 $LCTL set_param fail_loc=0x80000315
7274 flocks_test 2 $DIR/$tdir
7276 run_test 105d "flock race (should not freeze) ========"
7278 test_105e() { # bug 22660 && 22040
7279 flock_is_enabled || { skip "mount w/o flock enabled" && return; }
7281 flocks_test 3 $DIR/$tfile
7283 run_test 105e "Two conflicting flocks from same process ======="
7285 test_106() { #bug 10921
7286 test_mkdir -p $DIR/$tdir
7287 $DIR/$tdir && error "exec $DIR/$tdir succeeded"
7288 chmod 777 $DIR/$tdir || error "chmod $DIR/$tdir failed"
7290 run_test 106 "attempt exec of dir followed by chown of that dir"
7293 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7300 local save_pattern=$(sysctl -n kernel.core_pattern)
7301 local save_uses_pid=$(sysctl -n kernel.core_uses_pid)
7302 sysctl -w kernel.core_pattern=$file
7303 sysctl -w kernel.core_uses_pid=0
7311 kill -s 11 $SLEEPPID
7313 if [ -e $file ]; then
7314 size=`stat -c%s $file`
7315 [ $size -eq 0 ] && error "Fail to create core file $file"
7317 error "Fail to create core file $file"
7320 sysctl -w kernel.core_pattern=$save_pattern
7321 sysctl -w kernel.core_uses_pid=$save_uses_pid
7324 run_test 107 "Coredump on SIG"
7327 test_mkdir -p $DIR/$tdir
7328 test_mkdir $DIR/$tdir/$(str_repeat 'a' 255) ||
7329 error "mkdir with 255 char failed"
7330 test_mkdir $DIR/$tdir/$(str_repeat 'b' 256) &&
7331 error "mkdir with 256 char should fail, but did not"
7332 touch $DIR/$tdir/$(str_repeat 'x' 255) ||
7333 error "create with 255 char failed"
7334 touch $DIR/$tdir/$(str_repeat 'y' 256) &&
7335 error "create with 256 char should fail, but did not"
7340 run_test 110 "filename length checking"
7343 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7344 OSTIO_pre=$(ps -e | grep ll_ost_io | awk '{ print $4 }'| sort -n |
7345 tail -1 | cut -c11-20)
7346 [ -z "$OSTIO_pre" ] && skip "no OSS threads" && return
7347 echo "Starting with $OSTIO_pre threads"
7350 NUMFREE=$(df -i -P $DIR | tail -n 1 | awk '{ print $4 }')
7351 [[ $NUMFREE -lt $NUMTEST ]] && NUMTEST=$(($NUMFREE - 1000))
7352 echo "$NUMTEST creates/unlinks"
7353 test_mkdir -p $DIR/$tdir
7354 createmany -o $DIR/$tdir/$tfile $NUMTEST
7355 unlinkmany $DIR/$tdir/$tfile $NUMTEST
7357 OSTIO_post=$(ps -e | grep ll_ost_io | awk '{ print $4 }' | sort -n |
7358 tail -1 | cut -c11-20)
7360 # don't return an error
7361 [ $OSTIO_post == $OSTIO_pre ] && echo \
7362 "WARNING: No new ll_ost_io threads were created ($OSTIO_pre)" &&
7363 echo "This may be fine, depending on what ran before this test" &&
7364 echo "and how fast this system is." && return
7366 echo "Started with $OSTIO_pre threads, ended with $OSTIO_post"
7368 run_test 115 "verify dynamic thread creation===================="
7371 wait_delete_completed
7372 AVAIL=($(lctl get_param -n osc.*[oO][sS][cC]-[^M]*.kbytesavail))
7373 echo OST kbytes available: ${AVAIL[@]}
7374 MAXI=0; MAXV=${AVAIL[0]}
7375 MINI=0; MINV=${AVAIL[0]}
7376 for ((i = 0; i < ${#AVAIL[@]}; i++)); do
7377 #echo OST $i: ${AVAIL[i]}kb
7378 if [[ ${AVAIL[i]} -gt $MAXV ]]; then
7379 MAXV=${AVAIL[i]}; MAXI=$i
7381 if [[ ${AVAIL[i]} -lt $MINV ]]; then
7382 MINV=${AVAIL[i]}; MINI=$i
7385 echo Min free space: OST $MINI: $MINV
7386 echo Max free space: OST $MAXI: $MAXV
7389 test_116a() { # was previously test_116()
7390 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7391 remote_mds_nodsh && skip "remote MDS with nodsh" && return
7393 [[ $OSTCOUNT -lt 2 ]] && skip_env "$OSTCOUNT < 2 OSTs" && return
7395 echo -n "Free space priority "
7396 do_facet $SINGLEMDS lctl get_param -n lo*.*-mdtlov.qos_prio_free |
7401 [ $MINV -eq 0 ] && skip "no free space in OST$MINI, skip" && return
7402 [ $MINV -gt 10000000 ] && skip "too much free space in OST$MINI, skip" \
7404 trap simple_cleanup_common EXIT
7407 # Check if we need to generate uneven OSTs
7408 test_mkdir -p $DIR/$tdir/OST${MINI}
7409 local FILL=$(($MINV / 4))
7410 local DIFF=$(($MAXV - $MINV))
7411 local DIFF2=$(($DIFF * 100 / $MINV))
7413 local threshold=$(do_facet $SINGLEMDS \
7414 lctl get_param -n *.*MDT0000-mdtlov.qos_threshold_rr | head -n1)
7415 threshold=${threshold%%%}
7416 echo -n "Check for uneven OSTs: "
7417 echo -n "diff=${DIFF}KB (${DIFF2}%) must be > ${threshold}% ..."
7419 if [[ $DIFF2 -gt $threshold ]]; then
7421 echo "Don't need to fill OST$MINI"
7423 # generate uneven OSTs. Write 2% over the QOS threshold value
7425 DIFF=$(($threshold - $DIFF2 + 2))
7426 DIFF2=$(( ($MINV * $DIFF)/100 ))
7427 echo "Fill ${DIFF}% remaining space in OST${MINI} with ${DIFF2}KB"
7428 $SETSTRIPE -i $MINI -c 1 $DIR/$tdir/OST${MINI} ||
7429 error "setstripe failed"
7430 DIFF=$(($DIFF2 / 2048))
7432 while [ $i -lt $DIFF ]; do
7434 dd if=/dev/zero of=$DIR/$tdir/OST${MINI}/$tfile-$i \
7435 bs=2M count=1 2>/dev/null
7444 DIFF=$(($MAXV - $MINV))
7445 DIFF2=$(($DIFF * 100 / $MINV))
7446 echo -n "diff=${DIFF}=${DIFF2}% must be > ${threshold}% for QOS mode..."
7447 if [[ $DIFF2 -gt $threshold ]]; then
7450 echo "failed - QOS mode won't be used"
7451 skip "QOS imbalance criteria not met"
7452 simple_cleanup_common
7456 MINI1=$MINI; MINV1=$MINV
7457 MAXI1=$MAXI; MAXV1=$MAXV
7459 # now fill using QOS
7460 $SETSTRIPE -c 1 $DIR/$tdir
7461 FILL=$(($FILL / 200))
7462 if [ $FILL -gt 600 ]; then
7465 echo "writing $FILL files to QOS-assigned OSTs"
7467 while [ $i -lt $FILL ]; do
7469 dd if=/dev/zero of=$DIR/$tdir/$tfile-$i bs=200k \
7473 echo "wrote $i 200k files"
7477 echo "Note: free space may not be updated, so measurements might be off"
7479 DIFF2=$(($MAXV - $MINV))
7480 echo "free space delta: orig $DIFF final $DIFF2"
7481 [ $DIFF2 -gt $DIFF ] && echo "delta got worse!"
7482 DIFF=$(($MINV1 - ${AVAIL[$MINI1]}))
7483 echo "Wrote ${DIFF}KB to smaller OST $MINI1"
7484 DIFF2=$(($MAXV1 - ${AVAIL[$MAXI1]}))
7485 echo "Wrote ${DIFF2}KB to larger OST $MAXI1"
7486 FILL=$(($DIFF2 * 100 / $DIFF - 100))
7488 echo "Wrote ${FILL}% more data to larger OST $MAXI1"
7490 # Figure out which files were written where
7491 UUID=$(lctl get_param -n lov.${FSNAME}-clilov-*.target_obd |
7492 awk '/'$MINI1': / {print $2; exit}')
7494 MINC=$($GETSTRIPE --ost $UUID $DIR/$tdir | grep $DIR | wc -l)
7495 echo "$MINC files created on smaller OST $MINI1"
7496 UUID=$(lctl get_param -n lov.${FSNAME}-clilov-*.target_obd |
7497 awk '/'$MAXI1': / {print $2; exit}')
7499 MAXC=$($GETSTRIPE --ost $UUID $DIR/$tdir | grep $DIR | wc -l)
7500 echo "$MAXC files created on larger OST $MAXI1"
7501 FILL=$(($MAXC * 100 / $MINC - 100))
7502 [[ $MINC -gt 0 ]] &&
7503 echo "Wrote ${FILL}% more files to larger OST $MAXI1"
7504 [[ $MAXC -gt $MINC ]] ||
7505 error_ignore LU-9 "stripe QOS didn't balance free space"
7506 simple_cleanup_common
7508 run_test 116a "stripe QOS: free space balance ==================="
7510 test_116b() { # LU-2093
7511 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7512 remote_mds_nodsh && skip "remote MDS with nodsh" && return
7514 #define OBD_FAIL_MDS_OSC_CREATE_FAIL 0x147
7515 local old_rr=$(do_facet $SINGLEMDS lctl get_param -n \
7516 lo*.$FSNAME-MDT0000-mdtlov.qos_threshold_rr | head -1)
7517 [ -z "$old_rr" ] && skip "no QOS" && return 0
7518 do_facet $SINGLEMDS lctl set_param \
7519 lo*.$FSNAME-MDT0000-mdtlov.qos_threshold_rr=0
7521 do_facet $SINGLEMDS lctl set_param fail_loc=0x147
7522 createmany -o $DIR/$tdir/f- 20 || error "can't create"
7523 do_facet $SINGLEMDS lctl set_param fail_loc=0
7525 do_facet $SINGLEMDS lctl set_param \
7526 lo*.$FSNAME-MDT0000-mdtlov.qos_threshold_rr=$old_rr
7528 run_test 116b "QoS shouldn't LBUG if not enough OSTs found on the 2nd pass"
7530 test_117() # bug 10891
7532 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7533 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1
7534 #define OBD_FAIL_OST_SETATTR_CREDITS 0x21e
7535 lctl set_param fail_loc=0x21e
7536 > $DIR/$tfile || error "truncate failed"
7537 lctl set_param fail_loc=0
7538 echo "Truncate succeeded."
7541 run_test 117 "verify osd extend =========="
7543 NO_SLOW_RESENDCOUNT=4
7544 export OLD_RESENDCOUNT=""
7545 set_resend_count () {
7546 local PROC_RESENDCOUNT="osc.${FSNAME}-OST*-osc-*.resend_count"
7547 OLD_RESENDCOUNT=$(lctl get_param -n $PROC_RESENDCOUNT | head -n1)
7548 lctl set_param -n $PROC_RESENDCOUNT $1
7549 echo resend_count is set to $(lctl get_param -n $PROC_RESENDCOUNT)
7552 # for reduce test_118* time (b=14842)
7553 [ "$SLOW" = "no" ] && set_resend_count $NO_SLOW_RESENDCOUNT
7555 # Reset async IO behavior after error case
7557 FILE=$DIR/reset_async
7559 # Ensure all OSCs are cleared
7560 $SETSTRIPE -c -1 $FILE
7561 dd if=/dev/zero of=$FILE bs=64k count=$OSTCOUNT
7566 test_118a() #bug 11710
7568 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7571 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
7572 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
7573 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
7575 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
7576 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
7581 run_test 118a "verify O_SYNC works =========="
7585 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7586 remote_ost_nodsh && skip "remote OST with nodsh" && return
7590 #define OBD_FAIL_SRV_ENOENT 0x217
7591 set_nodes_failloc "$(osts_nodes)" 0x217
7592 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
7594 set_nodes_failloc "$(osts_nodes)" 0
7595 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
7596 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
7599 if [[ $RC -eq 0 ]]; then
7600 error "Must return error due to dropped pages, rc=$RC"
7604 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
7605 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
7609 echo "Dirty pages not leaked on ENOENT"
7611 # Due to the above error the OSC will issue all RPCs syncronously
7612 # until a subsequent RPC completes successfully without error.
7613 $MULTIOP $DIR/$tfile Ow4096yc
7618 run_test 118b "Reclaim dirty pages on fatal error =========="
7622 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7624 # for 118c, restore the original resend count, LU-1940
7625 [ "$SLOW" = "no" ] && [ -n "$OLD_RESENDCOUNT" ] &&
7626 set_resend_count $OLD_RESENDCOUNT
7627 remote_ost_nodsh && skip "remote OST with nodsh" && return
7631 #define OBD_FAIL_OST_EROFS 0x216
7632 set_nodes_failloc "$(osts_nodes)" 0x216
7634 # multiop should block due to fsync until pages are written
7635 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
7639 if [[ `ps h -o comm -p $MULTIPID` != "multiop" ]]; then
7640 error "Multiop failed to block on fsync, pid=$MULTIPID"
7643 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
7645 if [[ $WRITEBACK -eq 0 ]]; then
7646 error "No page in writeback, writeback=$WRITEBACK"
7649 set_nodes_failloc "$(osts_nodes)" 0
7652 if [[ $RC -ne 0 ]]; then
7653 error "Multiop fsync failed, rc=$RC"
7656 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
7657 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
7659 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
7660 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
7664 echo "Dirty pages flushed via fsync on EROFS"
7667 run_test 118c "Fsync blocks on EROFS until dirty pages are flushed =========="
7669 # continue to use small resend count to reduce test_118* time (b=14842)
7670 [ "$SLOW" = "no" ] && set_resend_count $NO_SLOW_RESENDCOUNT
7674 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7675 remote_ost_nodsh && skip "remote OST with nodsh" && return
7679 #define OBD_FAIL_OST_BRW_PAUSE_BULK
7680 set_nodes_failloc "$(osts_nodes)" 0x214
7681 # multiop should block due to fsync until pages are written
7682 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
7686 if [[ `ps h -o comm -p $MULTIPID` != "multiop" ]]; then
7687 error "Multiop failed to block on fsync, pid=$MULTIPID"
7690 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
7692 if [[ $WRITEBACK -eq 0 ]]; then
7693 error "No page in writeback, writeback=$WRITEBACK"
7696 wait $MULTIPID || error "Multiop fsync failed, rc=$?"
7697 set_nodes_failloc "$(osts_nodes)" 0
7699 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
7700 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
7702 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
7703 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
7707 echo "Dirty pages gaurenteed flushed via fsync"
7710 run_test 118d "Fsync validation inject a delay of the bulk =========="
7713 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7716 #define OBD_FAIL_OSC_BRW_PREP_REQ2 0x40a
7717 lctl set_param fail_loc=0x8000040a
7719 # Should simulate EINVAL error which is fatal
7720 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
7722 if [[ $RC -eq 0 ]]; then
7723 error "Must return error due to dropped pages, rc=$RC"
7726 lctl set_param fail_loc=0x0
7728 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
7729 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
7730 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
7732 if [[ $LOCKED -ne 0 ]]; then
7733 error "Locked pages remain in cache, locked=$LOCKED"
7736 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
7737 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
7741 echo "No pages locked after fsync"
7746 run_test 118f "Simulate unrecoverable OSC side error =========="
7749 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7752 #define OBD_FAIL_OSC_BRW_PREP_REQ 0x406
7753 lctl set_param fail_loc=0x406
7755 # simulate local -ENOMEM
7756 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
7759 lctl set_param fail_loc=0
7760 if [[ $RC -eq 0 ]]; then
7761 error "Must return error due to dropped pages, rc=$RC"
7764 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
7765 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
7766 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
7768 if [[ $LOCKED -ne 0 ]]; then
7769 error "Locked pages remain in cache, locked=$LOCKED"
7772 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
7773 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
7777 echo "No pages locked after fsync"
7782 run_test 118g "Don't stay in wait if we got local -ENOMEM =========="
7785 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7786 remote_ost_nodsh && skip "remote OST with nodsh" && return
7790 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
7791 set_nodes_failloc "$(osts_nodes)" 0x20e
7792 # Should simulate ENOMEM error which is recoverable and should be handled by timeout
7793 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
7796 set_nodes_failloc "$(osts_nodes)" 0
7797 if [[ $RC -eq 0 ]]; then
7798 error "Must return error due to dropped pages, rc=$RC"
7801 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
7802 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
7803 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
7805 if [[ $LOCKED -ne 0 ]]; then
7806 error "Locked pages remain in cache, locked=$LOCKED"
7809 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
7810 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
7814 echo "No pages locked after fsync"
7818 run_test 118h "Verify timeout in handling recoverables errors =========="
7820 [ "$SLOW" = "no" ] && [ -n "$OLD_RESENDCOUNT" ] && set_resend_count $OLD_RESENDCOUNT
7823 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7824 remote_ost_nodsh && skip "remote OST with nodsh" && return
7828 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
7829 set_nodes_failloc "$(osts_nodes)" 0x20e
7831 # Should simulate ENOMEM error which is recoverable and should be handled by timeout
7832 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
7835 set_nodes_failloc "$(osts_nodes)" 0
7839 if [[ $RC -ne 0 ]]; then
7840 error "got error, but should be not, rc=$RC"
7843 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
7844 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
7845 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
7846 if [[ $LOCKED -ne 0 ]]; then
7847 error "Locked pages remain in cache, locked=$LOCKED"
7850 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
7851 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
7855 echo "No pages locked after fsync"
7859 run_test 118i "Fix error before timeout in recoverable error =========="
7861 [ "$SLOW" = "no" ] && set_resend_count 4
7864 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7865 remote_ost_nodsh && skip "remote OST with nodsh" && return
7869 #define OBD_FAIL_OST_BRW_WRITE_BULK2 0x220
7870 set_nodes_failloc "$(osts_nodes)" 0x220
7872 # return -EIO from OST
7873 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
7875 set_nodes_failloc "$(osts_nodes)" 0x0
7876 if [[ $RC -eq 0 ]]; then
7877 error "Must return error due to dropped pages, rc=$RC"
7880 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
7881 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
7882 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
7883 if [[ $LOCKED -ne 0 ]]; then
7884 error "Locked pages remain in cache, locked=$LOCKED"
7887 # in recoverable error on OST we want resend and stay until it finished
7888 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
7889 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
7893 echo "No pages locked after fsync"
7897 run_test 118j "Simulate unrecoverable OST side error =========="
7901 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7902 remote_ost_nodsh && skip "remote OSTs with nodsh" && return
7904 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
7905 set_nodes_failloc "$(osts_nodes)" 0x20e
7906 test_mkdir -p $DIR/$tdir
7908 for ((i=0;i<10;i++)); do
7909 (dd if=/dev/zero of=$DIR/$tdir/$tfile-$i bs=1M count=10 || \
7910 error "dd to $DIR/$tdir/$tfile-$i failed" )&
7917 set_nodes_failloc "$(osts_nodes)" 0
7920 run_test 118k "bio alloc -ENOMEM and IO TERM handling ========="
7924 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7926 test_mkdir -p $DIR/$tdir
7927 $MULTIOP $DIR/$tdir Dy || error "fsync dir failed"
7930 run_test 118l "fsync dir ========="
7932 test_118m() # LU-3066
7934 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7935 test_mkdir -p $DIR/$tdir
7936 $MULTIOP $DIR/$tdir DY || error "fdatasync dir failed"
7939 run_test 118m "fdatasync dir ========="
7941 [ "$SLOW" = "no" ] && [ -n "$OLD_RESENDCOUNT" ] && set_resend_count $OLD_RESENDCOUNT
7943 test_119a() # bug 11737
7945 BSIZE=$((512 * 1024))
7946 directio write $DIR/$tfile 0 1 $BSIZE
7947 # We ask to read two blocks, which is more than a file size.
7948 # directio will indicate an error when requested and actual
7949 # sizes aren't equeal (a normal situation in this case) and
7950 # print actual read amount.
7951 NOB=`directio read $DIR/$tfile 0 2 $BSIZE | awk '/error/ {print $6}'`
7952 if [ "$NOB" != "$BSIZE" ]; then
7953 error "read $NOB bytes instead of $BSIZE"
7957 run_test 119a "Short directIO read must return actual read amount"
7959 test_119b() # bug 11737
7961 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping 2-stripe test" && return
7963 $SETSTRIPE -c 2 $DIR/$tfile || error "setstripe failed"
7964 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=1 || error "dd failed"
7966 $MULTIOP $DIR/$tfile oO_RDONLY:O_DIRECT:r$((2048 * 1024)) || \
7967 error "direct read failed"
7970 run_test 119b "Sparse directIO read must return actual read amount"
7972 test_119c() # bug 13099
7975 directio write $DIR/$tfile 3 1 $BSIZE || error "direct write failed"
7976 directio readhole $DIR/$tfile 0 2 $BSIZE || error "reading hole failed"
7979 run_test 119c "Testing for direct read hitting hole"
7981 test_119d() # bug 15950
7983 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7984 MAX_RPCS_IN_FLIGHT=`$LCTL get_param -n osc.*OST0000-osc-[^mM]*.max_rpcs_in_flight`
7985 $LCTL set_param -n osc.*OST0000-osc-[^mM]*.max_rpcs_in_flight 1
7987 $SETSTRIPE $DIR/$tfile -i 0 -c 1 || error "setstripe failed"
7988 $DIRECTIO write $DIR/$tfile 0 1 $BSIZE || error "first directio failed"
7989 #define OBD_FAIL_OSC_DIO_PAUSE 0x40d
7990 lctl set_param fail_loc=0x40d
7991 $DIRECTIO write $DIR/$tfile 1 4 $BSIZE &
7994 cat $DIR/$tfile > /dev/null &
7995 lctl set_param fail_loc=0
7998 log "the DIO writes have completed, now wait for the reads (should not block very long)"
8000 [ -n "`ps h -p $pid_reads -o comm`" ] && \
8001 error "the read rpcs have not completed in 2s"
8003 $LCTL set_param -n osc.*OST0000-osc-[^mM]*.max_rpcs_in_flight $MAX_RPCS_IN_FLIGHT
8005 run_test 119d "The DIO path should try to send a new rpc once one is completed"
8008 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8009 test_mkdir -p $DIR/$tdir
8010 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
8011 skip "no early lock cancel on server" && return 0
8013 lru_resize_disable mdc
8014 lru_resize_disable osc
8015 cancel_lru_locks mdc
8016 # asynchronous object destroy at MDT could cause bl ast to client
8017 cancel_lru_locks osc
8019 stat $DIR/$tdir > /dev/null
8020 can1=$(do_facet $SINGLEMDS \
8021 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8022 awk '/ldlm_cancel/ {print $2}')
8023 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8024 awk '/ldlm_bl_callback/ {print $2}')
8025 test_mkdir -c1 $DIR/$tdir/d1
8026 can2=$(do_facet $SINGLEMDS \
8027 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8028 awk '/ldlm_cancel/ {print $2}')
8029 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8030 awk '/ldlm_bl_callback/ {print $2}')
8031 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
8032 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
8033 lru_resize_enable mdc
8034 lru_resize_enable osc
8036 run_test 120a "Early Lock Cancel: mkdir test"
8039 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8040 test_mkdir $DIR/$tdir
8041 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel)" ] && \
8042 skip "no early lock cancel on server" && return 0
8043 lru_resize_disable mdc
8044 lru_resize_disable osc
8045 cancel_lru_locks mdc
8046 stat $DIR/$tdir > /dev/null
8047 can1=$(do_facet $SINGLEMDS \
8048 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8049 awk '/ldlm_cancel/ {print $2}')
8050 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8051 awk '/ldlm_bl_callback/ {print $2}')
8053 can2=$(do_facet $SINGLEMDS \
8054 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8055 awk '/ldlm_cancel/ {print $2}')
8056 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8057 awk '/ldlm_bl_callback/ {print $2}')
8058 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
8059 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
8060 lru_resize_enable mdc
8061 lru_resize_enable osc
8063 run_test 120b "Early Lock Cancel: create test"
8066 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8067 test_mkdir -c1 $DIR/$tdir
8068 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel)" ] && \
8069 skip "no early lock cancel on server" && return 0
8070 lru_resize_disable mdc
8071 lru_resize_disable osc
8072 test_mkdir -p -c1 $DIR/$tdir/d1
8073 test_mkdir -p -c1 $DIR/$tdir/d2
8074 touch $DIR/$tdir/d1/f1
8075 cancel_lru_locks mdc
8076 stat $DIR/$tdir/d1 $DIR/$tdir/d2 $DIR/$tdir/d1/f1 > /dev/null
8077 can1=$(do_facet $SINGLEMDS \
8078 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8079 awk '/ldlm_cancel/ {print $2}')
8080 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8081 awk '/ldlm_bl_callback/ {print $2}')
8082 ln $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2
8083 can2=$(do_facet $SINGLEMDS \
8084 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8085 awk '/ldlm_cancel/ {print $2}')
8086 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8087 awk '/ldlm_bl_callback/ {print $2}')
8088 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
8089 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
8090 lru_resize_enable mdc
8091 lru_resize_enable osc
8093 run_test 120c "Early Lock Cancel: link test"
8096 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8097 test_mkdir -p -c1 $DIR/$tdir
8098 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel)" ] && \
8099 skip "no early lock cancel on server" && return 0
8100 lru_resize_disable mdc
8101 lru_resize_disable osc
8103 cancel_lru_locks mdc
8104 stat $DIR/$tdir > /dev/null
8105 can1=$(do_facet $SINGLEMDS \
8106 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8107 awk '/ldlm_cancel/ {print $2}')
8108 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8109 awk '/ldlm_bl_callback/ {print $2}')
8110 chmod a+x $DIR/$tdir
8111 can2=$(do_facet $SINGLEMDS \
8112 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8113 awk '/ldlm_cancel/ {print $2}')
8114 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8115 awk '/ldlm_bl_callback/ {print $2}')
8116 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
8117 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
8118 lru_resize_enable mdc
8119 lru_resize_enable osc
8121 run_test 120d "Early Lock Cancel: setattr test"
8124 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8125 test_mkdir -p -c1 $DIR/$tdir
8126 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
8127 skip "no early lock cancel on server" && return 0
8128 lru_resize_disable mdc
8129 lru_resize_disable osc
8130 dd if=/dev/zero of=$DIR/$tdir/f1 count=1
8131 cancel_lru_locks mdc
8132 cancel_lru_locks osc
8133 dd if=$DIR/$tdir/f1 of=/dev/null
8134 stat $DIR/$tdir $DIR/$tdir/f1 > /dev/null
8135 # XXX client can not do early lock cancel of OST lock
8136 # during unlink (LU-4206), so cancel osc lock now.
8137 cancel_lru_locks osc
8138 can1=$(do_facet $SINGLEMDS \
8139 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8140 awk '/ldlm_cancel/ {print $2}')
8141 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8142 awk '/ldlm_bl_callback/ {print $2}')
8143 unlink $DIR/$tdir/f1
8145 can2=$(do_facet $SINGLEMDS \
8146 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8147 awk '/ldlm_cancel/ {print $2}')
8148 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8149 awk '/ldlm_bl_callback/ {print $2}')
8150 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
8151 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
8152 lru_resize_enable mdc
8153 lru_resize_enable osc
8155 run_test 120e "Early Lock Cancel: unlink test"
8158 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8159 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
8160 skip "no early lock cancel on server" && return 0
8161 test_mkdir -p -c1 $DIR/$tdir
8162 lru_resize_disable mdc
8163 lru_resize_disable osc
8164 test_mkdir -p -c1 $DIR/$tdir/d1
8165 test_mkdir -p -c1 $DIR/$tdir/d2
8166 dd if=/dev/zero of=$DIR/$tdir/d1/f1 count=1
8167 dd if=/dev/zero of=$DIR/$tdir/d2/f2 count=1
8168 cancel_lru_locks mdc
8169 cancel_lru_locks osc
8170 dd if=$DIR/$tdir/d1/f1 of=/dev/null
8171 dd if=$DIR/$tdir/d2/f2 of=/dev/null
8172 stat $DIR/$tdir/d1 $DIR/$tdir/d2 $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2 > /dev/null
8173 # XXX client can not do early lock cancel of OST lock
8174 # during rename (LU-4206), so cancel osc lock now.
8175 cancel_lru_locks osc
8176 can1=$(do_facet $SINGLEMDS \
8177 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8178 awk '/ldlm_cancel/ {print $2}')
8179 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8180 awk '/ldlm_bl_callback/ {print $2}')
8181 mrename $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2
8183 can2=$(do_facet $SINGLEMDS \
8184 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8185 awk '/ldlm_cancel/ {print $2}')
8186 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8187 awk '/ldlm_bl_callback/ {print $2}')
8188 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
8189 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
8190 lru_resize_enable mdc
8191 lru_resize_enable osc
8193 run_test 120f "Early Lock Cancel: rename test"
8196 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8197 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
8198 skip "no early lock cancel on server" && return 0
8199 lru_resize_disable mdc
8200 lru_resize_disable osc
8202 echo create $count files
8203 test_mkdir -p $DIR/$tdir
8204 cancel_lru_locks mdc
8205 cancel_lru_locks osc
8208 can0=$(do_facet $SINGLEMDS \
8209 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8210 awk '/ldlm_cancel/ {print $2}')
8211 blk0=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8212 awk '/ldlm_bl_callback/ {print $2}')
8213 createmany -o $DIR/$tdir/f $count
8215 can1=$(do_facet $SINGLEMDS \
8216 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8217 awk '/ldlm_cancel/ {print $2}')
8218 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8219 awk '/ldlm_bl_callback/ {print $2}')
8221 echo total: $((can1-can0)) cancels, $((blk1-blk0)) blockings
8222 echo rm $count files
8225 can2=$(do_facet $SINGLEMDS \
8226 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8227 awk '/ldlm_cancel/ {print $2}')
8228 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8229 awk '/ldlm_bl_callback/ {print $2}')
8231 echo total: $count removes in $((t2-t1))
8232 echo total: $((can2-can1)) cancels, $((blk2-blk1)) blockings
8234 # wait for commitment of removal
8235 lru_resize_enable mdc
8236 lru_resize_enable osc
8238 run_test 120g "Early Lock Cancel: performance test"
8240 test_121() { #bug #10589
8241 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8243 writes=$(LANG=C dd if=/dev/zero of=$DIR/$tfile count=1 2>&1 | awk -F '+' '/out$/ {print $1}')
8244 #define OBD_FAIL_LDLM_CANCEL_RACE 0x310
8245 lctl set_param fail_loc=0x310
8246 cancel_lru_locks osc > /dev/null
8247 reads=$(LANG=C dd if=$DIR/$tfile of=/dev/null 2>&1 | awk -F '+' '/in$/ {print $1}')
8248 lctl set_param fail_loc=0
8249 [[ $reads -eq $writes ]] ||
8250 error "read $reads blocks, must be $writes blocks"
8252 run_test 121 "read cancel race ========="
8254 test_123a() { # was test 123, statahead(bug 11401)
8255 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8257 if [ -z "$(grep "processor.*: 1" /proc/cpuinfo)" ]; then
8258 log "testing on UP system. Performance may be not as good as expected."
8263 test_mkdir -p $DIR/$tdir
8264 NUMFREE=$(df -i -P $DIR | tail -n 1 | awk '{ print $4 }')
8265 [[ $NUMFREE -gt 100000 ]] && NUMFREE=100000 || NUMFREE=$((NUMFREE-1000))
8267 for ((i=100, j=0; i<=$NUMFREE; j=$i, i=$((i * MULT)) )); do
8268 createmany -o $DIR/$tdir/$tfile $j $((i - j))
8270 max=`lctl get_param -n llite.*.statahead_max | head -n 1`
8271 lctl set_param -n llite.*.statahead_max 0
8272 lctl get_param llite.*.statahead_max
8273 cancel_lru_locks mdc
8274 cancel_lru_locks osc
8276 time ls -l $DIR/$tdir | wc -l
8278 delta=$((etime - stime))
8279 log "ls $i files without statahead: $delta sec"
8280 lctl set_param llite.*.statahead_max=$max
8282 swrong=`lctl get_param -n llite.*.statahead_stats | grep "statahead wrong:" | awk '{print $3}'`
8283 lctl get_param -n llite.*.statahead_max | grep '[0-9]'
8284 cancel_lru_locks mdc
8285 cancel_lru_locks osc
8287 time ls -l $DIR/$tdir | wc -l
8289 delta_sa=$((etime - stime))
8290 log "ls $i files with statahead: $delta_sa sec"
8291 lctl get_param -n llite.*.statahead_stats
8292 ewrong=`lctl get_param -n llite.*.statahead_stats | grep "statahead wrong:" | awk '{print $3}'`
8294 [[ $swrong -lt $ewrong ]] &&
8295 log "statahead was stopped, maybe too many locks held!"
8296 [[ $delta -eq 0 || $delta_sa -eq 0 ]] && continue
8298 if [ $((delta_sa * 100)) -gt $((delta * 105)) -a $delta_sa -gt $((delta + 2)) ]; then
8299 max=`lctl get_param -n llite.*.statahead_max | head -n 1`
8300 lctl set_param -n llite.*.statahead_max 0
8301 lctl get_param llite.*.statahead_max
8302 cancel_lru_locks mdc
8303 cancel_lru_locks osc
8305 time ls -l $DIR/$tdir | wc -l
8307 delta=$((etime - stime))
8308 log "ls $i files again without statahead: $delta sec"
8309 lctl set_param llite.*.statahead_max=$max
8310 if [ $((delta_sa * 100)) -gt $((delta * 105)) -a $delta_sa -gt $((delta + 2)) ]; then
8311 if [ $SLOWOK -eq 0 ]; then
8312 error "ls $i files is slower with statahead!"
8314 log "ls $i files is slower with statahead!"
8320 [ $delta -gt 20 ] && break
8321 [ $delta -gt 8 ] && MULT=$((50 / delta))
8322 [ "$SLOW" = "no" -a $delta -gt 5 ] && break
8330 delta=$((etime - stime))
8331 log "rm -r $DIR/$tdir/: $delta seconds"
8333 lctl get_param -n llite.*.statahead_stats
8335 run_test 123a "verify statahead work"
8337 test_123b () { # statahead(bug 15027)
8338 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8339 test_mkdir -p $DIR/$tdir
8340 createmany -o $DIR/$tdir/$tfile-%d 1000
8342 cancel_lru_locks mdc
8343 cancel_lru_locks osc
8345 #define OBD_FAIL_MDC_GETATTR_ENQUEUE 0x803
8346 lctl set_param fail_loc=0x80000803
8347 ls -lR $DIR/$tdir > /dev/null
8349 lctl set_param fail_loc=0x0
8350 lctl get_param -n llite.*.statahead_stats
8355 run_test 123b "not panic with network error in statahead enqueue (bug 15027)"
8358 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8359 [ -z "$($LCTL get_param -n mdc.*.connect_flags | grep lru_resize)" ] &&
8360 skip "no lru resize on server" && return 0
8362 test_mkdir -p $DIR/$tdir || error "failed to create $DIR/$tdir"
8364 log "create $NR files at $DIR/$tdir"
8365 createmany -o $DIR/$tdir/f $NR ||
8366 error "failed to create $NR files in $DIR/$tdir"
8368 cancel_lru_locks mdc
8369 ls -l $DIR/$tdir > /dev/null
8373 for VALUE in $($LCTL get_param ldlm.namespaces.*mdc-*.lru_size); do
8374 local PARAM=$(echo ${VALUE[0]} | cut -d "=" -f1)
8375 LRU_SIZE=$($LCTL get_param -n $PARAM)
8376 if [[ $LRU_SIZE -gt $(default_lru_size) ]]; then
8377 NSDIR=$(echo $PARAM | cut -d "." -f1-3)
8379 log "NS=$(basename $NSDIR)"
8384 if [[ -z "$NSDIR" || $LRU_SIZE -lt $(default_lru_size) ]]; then
8385 skip "Not enough cached locks created!"
8392 # We know that lru resize allows one client to hold $LIMIT locks
8393 # for 10h. After that locks begin to be killed by client.
8395 local LIMIT=$($LCTL get_param -n $NSDIR.pool.limit)
8397 if [ $LIMIT -lt $LRU_SIZE ]; then
8398 skip "Limit is too small $LIMIT"
8402 # Make LVF so higher that sleeping for $SLEEP is enough to _start_
8403 # killing locks. Some time was spent for creating locks. This means
8404 # that up to the moment of sleep finish we must have killed some of
8405 # them (10-100 locks). This depends on how fast ther were created.
8406 # Many of them were touched in almost the same moment and thus will
8407 # be killed in groups.
8408 local LVF=$(($MAX_HRS * 60 * 60 / $SLEEP * $LIMIT / $LRU_SIZE))
8410 # Use $LRU_SIZE_B here to take into account real number of locks
8411 # created in the case of CMD, LRU_SIZE_B != $NR in most of cases
8412 local LRU_SIZE_B=$LRU_SIZE
8414 local OLD_LVF=$($LCTL get_param -n $NSDIR.pool.lock_volume_factor)
8415 log "OLD_LVF=$OLD_LVF"
8416 $LCTL set_param -n $NSDIR.pool.lock_volume_factor $LVF
8418 # Let's make sure that we really have some margin. Client checks
8419 # cached locks every 10 sec.
8421 log "Sleep ${SLEEP} sec"
8423 while ((SEC<$SLEEP)); do
8427 LRU_SIZE=$($LCTL get_param -n $NSDIR/lru_size)
8431 $LCTL set_param -n $NSDIR.pool.lock_volume_factor $OLD_LVF
8432 local LRU_SIZE_A=$($LCTL get_param -n $NSDIR.lru_size)
8434 [[ $LRU_SIZE_B -gt $LRU_SIZE_A ]] || {
8435 error "No locks dropped in ${SLEEP}s. LRU size: $LRU_SIZE_A"
8436 unlinkmany $DIR/$tdir/f $NR
8440 log "Dropped "$((LRU_SIZE_B-LRU_SIZE_A))" locks in ${SLEEP}s"
8441 log "unlink $NR files at $DIR/$tdir"
8442 unlinkmany $DIR/$tdir/f $NR
8444 run_test 124a "lru resize ======================================="
8446 get_max_pool_limit()
8448 local limit=$($LCTL get_param \
8449 -n ldlm.namespaces.*-MDT0000-mdc-*.pool.limit)
8452 if [[ $l -gt $max ]]; then
8460 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8461 [ -z "$($LCTL get_param -n mdc.*.connect_flags | grep lru_resize)" ] &&
8462 skip "no lru resize on server" && return 0
8464 LIMIT=$(get_max_pool_limit)
8466 NR=$(($(default_lru_size)*20))
8467 if [[ $NR -gt $LIMIT ]]; then
8468 log "Limit lock number by $LIMIT locks"
8471 lru_resize_disable mdc
8472 test_mkdir -p $DIR/$tdir/disable_lru_resize ||
8473 error "failed to create $DIR/$tdir/disable_lru_resize"
8475 createmany -o $DIR/$tdir/disable_lru_resize/f $NR
8476 log "doing ls -la $DIR/$tdir/disable_lru_resize 3 times"
8477 cancel_lru_locks mdc
8480 ls -la $DIR/$tdir/disable_lru_resize > /dev/null &
8483 ls -la $DIR/$tdir/disable_lru_resize > /dev/null &
8486 ls -la $DIR/$tdir/disable_lru_resize > /dev/null &
8490 nolruresize_delta=$((etime-stime))
8491 log "ls -la time: $nolruresize_delta seconds"
8492 log "lru_size = $(lctl get_param -n ldlm.namespaces.*mdc*.lru_size)"
8493 unlinkmany $DIR/$tdir/disable_lru_resize/f $NR
8495 lru_resize_enable mdc
8496 test_mkdir -p $DIR/$tdir/enable_lru_resize ||
8497 error "failed to create $DIR/$tdir/enable_lru_resize"
8499 createmany -o $DIR/$tdir/enable_lru_resize/f $NR
8500 log "doing ls -la $DIR/$tdir/enable_lru_resize 3 times"
8501 cancel_lru_locks mdc
8504 ls -la $DIR/$tdir/enable_lru_resize > /dev/null &
8507 ls -la $DIR/$tdir/enable_lru_resize > /dev/null &
8510 ls -la $DIR/$tdir/enable_lru_resize > /dev/null &
8514 lruresize_delta=$((etime-stime))
8515 log "ls -la time: $lruresize_delta seconds"
8516 log "lru_size = $(lctl get_param -n ldlm.namespaces.*mdc*.lru_size)"
8518 if [ $lruresize_delta -gt $nolruresize_delta ]; then
8519 log "ls -la is $(((lruresize_delta - $nolruresize_delta) * 100 / $nolruresize_delta))% slower with lru resize enabled"
8520 elif [ $nolruresize_delta -gt $lruresize_delta ]; then
8521 log "ls -la is $(((nolruresize_delta - $lruresize_delta) * 100 / $nolruresize_delta))% faster with lru resize enabled"
8523 log "lru resize performs the same with no lru resize"
8525 unlinkmany $DIR/$tdir/enable_lru_resize/f $NR
8527 run_test 124b "lru resize (performance test) ======================="
8530 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8531 [ -z "$($LCTL get_param -n mdc.*.connect_flags | grep lru_resize)" ] &&
8532 skip "no lru resize on server" && return 0
8534 # cache ununsed locks on client
8536 cancel_lru_locks mdc
8537 test_mkdir -p $DIR/$tdir || error "failed to create $DIR/$tdir"
8538 createmany -o $DIR/$tdir/f $nr ||
8539 error "failed to create $nr files in $DIR/$tdir"
8540 ls -l $DIR/$tdir > /dev/null
8542 local nsdir="ldlm.namespaces.*-MDT0000-mdc-*"
8543 local unused=$($LCTL get_param -n $nsdir.lock_unused_count)
8544 local max_age=$($LCTL get_param -n $nsdir.lru_max_age)
8545 local recalc_p=$($LCTL get_param -n $nsdir.pool.recalc_period)
8546 echo "unused=$unused, max_age=$max_age, recalc_p=$recalc_p"
8548 # set lru_max_age to 1 sec
8549 $LCTL set_param $nsdir.lru_max_age=1000 # jiffies
8550 echo "sleep $((recalc_p * 2)) seconds..."
8551 sleep $((recalc_p * 2))
8553 local remaining=$($LCTL get_param -n $nsdir.lock_unused_count)
8554 # restore lru_max_age
8555 $LCTL set_param -n $nsdir.lru_max_age $max_age
8556 [ $remaining -eq 0 ] || error "$remaining locks are not canceled"
8557 unlinkmany $DIR/$tdir/f $nr
8559 run_test 124c "LRUR cancel very aged locks"
8561 test_125() { # 13358
8562 [ -z "$(lctl get_param -n llite.*.client_type | grep local)" ] && skip "must run as local client" && return
8563 [ -z "$(lctl get_param -n mdc.*-mdc-*.connect_flags | grep acl)" ] && skip "must have acl enabled" && return
8564 [ -z "$(which setfacl)" ] && skip "must have setfacl tool" && return
8565 test_mkdir -p $DIR/d125 || error "mkdir failed"
8566 $SETSTRIPE -S 65536 -c -1 $DIR/d125 || error "setstripe failed"
8567 setfacl -R -m u:bin:rwx $DIR/d125 || error "setfacl $DIR/d125 failed"
8568 ls -ld $DIR/d125 || error "cannot access $DIR/d125"
8570 run_test 125 "don't return EPROTO when a dir has a non-default striping and ACLs"
8572 test_126() { # bug 12829/13455
8573 [ -z "$(lctl get_param -n llite.*.client_type | grep local)" ] && skip "must run as local client" && return
8574 [ "$UID" != 0 ] && skip_env "skipping $TESTNAME (must run as root)" && return
8575 $GSS && skip "must run as gss disabled" && return
8577 $RUNAS -u 0 -g 1 touch $DIR/$tfile || error "touch failed"
8578 gid=`ls -n $DIR/$tfile | awk '{print $4}'`
8580 [ $gid -eq "1" ] || error "gid is set to" $gid "instead of 1"
8582 run_test 126 "check that the fsgid provided by the client is taken into account"
8584 test_127a() { # bug 15521
8585 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8586 $SETSTRIPE -i 0 -c 1 $DIR/$tfile || error "setstripe failed"
8587 $LCTL set_param osc.*.stats=0
8588 FSIZE=$((2048 * 1024))
8589 dd if=/dev/zero of=$DIR/$tfile bs=$FSIZE count=1
8590 cancel_lru_locks osc
8591 dd if=$DIR/$tfile of=/dev/null bs=$FSIZE
8593 $LCTL get_param osc.*0000-osc-*.stats | grep samples > $DIR/${tfile}.tmp
8594 while read NAME COUNT SAMP UNIT MIN MAX SUM SUMSQ; do
8595 echo "got $COUNT $NAME"
8596 [ ! $MIN ] && error "Missing min value for $NAME proc entry"
8597 eval $NAME=$COUNT || error "Wrong proc format"
8600 read_bytes|write_bytes)
8601 [ $MIN -lt 4096 ] && error "min is too small: $MIN"
8602 [ $MIN -gt $FSIZE ] && error "min is too big: $MIN"
8603 [ $MAX -lt 4096 ] && error "max is too small: $MAX"
8604 [ $MAX -gt $FSIZE ] && error "max is too big: $MAX"
8605 [ $SUM -ne $FSIZE ] && error "sum is wrong: $SUM"
8606 [ $SUMSQ -lt $(((FSIZE /4096) * (4096 * 4096))) ] &&
8607 error "sumsquare is too small: $SUMSQ"
8608 [ $SUMSQ -gt $((FSIZE * FSIZE)) ] &&
8609 error "sumsquare is too big: $SUMSQ"
8613 done < $DIR/${tfile}.tmp
8615 #check that we actually got some stats
8616 [ "$read_bytes" ] || error "Missing read_bytes stats"
8617 [ "$write_bytes" ] || error "Missing write_bytes stats"
8618 [ "$read_bytes" != 0 ] || error "no read done"
8619 [ "$write_bytes" != 0 ] || error "no write done"
8621 run_test 127a "verify the client stats are sane"
8623 test_127b() { # bug LU-333
8624 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8625 $LCTL set_param llite.*.stats=0
8626 FSIZE=65536 # sized fixed to match PAGE_SIZE for most clients
8627 # perform 2 reads and writes so MAX is different from SUM.
8628 dd if=/dev/zero of=$DIR/$tfile bs=$FSIZE count=1
8629 dd if=/dev/zero of=$DIR/$tfile bs=$FSIZE count=1
8630 cancel_lru_locks osc
8631 dd if=$DIR/$tfile of=/dev/null bs=$FSIZE count=1
8632 dd if=$DIR/$tfile of=/dev/null bs=$FSIZE count=1
8634 $LCTL get_param llite.*.stats | grep samples > $TMP/${tfile}.tmp
8635 while read NAME COUNT SAMP UNIT MIN MAX SUM SUMSQ; do
8636 echo "got $COUNT $NAME"
8637 eval $NAME=$COUNT || error "Wrong proc format"
8641 [ $COUNT -ne 2 ] && error "count is not 2: $COUNT"
8642 [ $MIN -ne $FSIZE ] && error "min is not $FSIZE: $MIN"
8643 [ $MAX -ne $FSIZE ] && error "max is incorrect: $MAX"
8644 [ $SUM -ne $((FSIZE * 2)) ] && error "sum is wrong: $SUM"
8647 [ $COUNT -ne 2 ] && error "count is not 2: $COUNT"
8648 [ $MIN -ne $FSIZE ] && error "min is not $FSIZE: $MIN"
8649 [ $MAX -ne $FSIZE ] && error "max is incorrect: $MAX"
8650 [ $SUM -ne $((FSIZE * 2)) ] && error "sum is wrong: $SUM"
8654 done < $TMP/${tfile}.tmp
8656 #check that we actually got some stats
8657 [ "$read_bytes" ] || error "Missing read_bytes stats"
8658 [ "$write_bytes" ] || error "Missing write_bytes stats"
8659 [ "$read_bytes" != 0 ] || error "no read done"
8660 [ "$write_bytes" != 0 ] || error "no write done"
8662 run_test 127b "verify the llite client stats are sane"
8664 test_128() { # bug 15212
8666 $LFS 2>&1 <<-EOF | tee $TMP/$tfile.log
8671 result=$(grep error $TMP/$tfile.log)
8673 [ -z "$result" ] || error "consecutive find's under interactive lfs failed"
8675 run_test 128 "interactive lfs for 2 consecutive find's"
8682 local LDPROC=/proc/fs/ldiskfs
8683 local facets=$(get_facets MDS)
8685 for facet in ${facets//,/ }; do
8686 canondev=$(ldiskfs_canon \
8687 *.$(convert_facet2label $facet).mntdev $facet)
8688 do_facet $facet "test -e $LDPROC/$canondev/max_dir_size" ||
8689 LDPROC=/sys/fs/ldiskfs
8690 do_facet $facet "echo $1 >$LDPROC/$canondev/max_dir_size"
8691 do_facet $facet "test -e $LDPROC/$canondev/warning_dir_size" ||
8692 LDPROC=/sys/fs/ldiskfs
8693 do_facet $facet "echo $2 >$LDPROC/$canondev/warning_dir_size"
8698 local facets=$(get_facets MDS)
8699 for facet in ${facets//,/ }; do
8700 do_facet $facet "dmesg | tail -3 | grep -q $1" && return 0
8706 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8707 if [ "$(facet_fstype $SINGLEMDS)" != ldiskfs ]; then
8708 skip "Only applicable to ldiskfs-based MDTs"
8711 remote_mds_nodsh && skip "remote MDS with nodsh" && return
8717 test_mkdir -p $DIR/$tdir
8719 # block size of mds1
8720 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
8721 local MDSBLOCKSIZE=$($LCTL get_param -n mdc.*MDT0000*.blocksize)
8722 local MAX=$((MDSBLOCKSIZE * 5))
8723 set_dir_limits $MAX $MAX
8724 local I=$(stat -c%s "$DIR/$tdir")
8726 local STRIPE_COUNT=1
8727 [[ $MDSCOUNT -ge 2 ]] && STRIPE_COUNT=$($LFS getdirstripe -c $DIR/$tdir)
8728 MAX=$((MAX*STRIPE_COUNT))
8729 while [[ $I -le $MAX ]]; do
8730 $MULTIOP $DIR/$tdir/$J Oc
8732 if [ $has_warning -eq 0 ]; then
8733 check_mds_dmesg '"is approaching"' &&
8736 #check two errors ENOSPC for new version of ext4 max_dir_size patch
8737 #mainline kernel commit df981d03eeff7971ac7e6ff37000bfa702327ef1
8738 #and EFBIG for previous versions
8739 if [ $rc -eq $EFBIG -o $rc -eq $ENOSPC ]; then
8741 echo "return code $rc received as expected"
8742 multiop $DIR/$tdir/$J Oc ||
8743 error_exit "multiop failed w/o dir size limit"
8745 check_mds_dmesg '"has reached"' ||
8746 error_exit "has reached message should be output"
8749 error_exit "warning message should be output"
8751 I=$(stat -c%s "$DIR/$tdir")
8753 if [ $(lustre_version_code $SINGLEMDS) -lt \
8754 $(version_code 2.4.51) ]
8756 [[ $I -eq $MAX ]] && return 0
8758 [[ $I -gt $MAX ]] && return 0
8760 error_exit "current dir size $I, previous limit $MAX"
8761 elif [ $rc -ne 0 ]; then
8763 error_exit "return code $rc received instead of expected " \
8764 "$EFBIG or $ENOSPC, files in dir $I"
8767 I=$(stat -c%s "$DIR/$tdir")
8771 error "exceeded dir size limit $MAX($MDSCOUNT) : $I bytes"
8773 run_test 129 "test directory size limit ========================"
8782 local filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
8783 [ -n "$filefrag_op" ] && skip_env "filefrag does not support FIEMAP" &&
8786 trap cleanup_130 EXIT RETURN
8788 local fm_file=$DIR/$tfile
8789 $SETSTRIPE -S 65536 -c 1 $fm_file || error "setstripe on $fm_file"
8790 dd if=/dev/zero of=$fm_file bs=65536 count=1 ||
8791 error "dd failed for $fm_file"
8793 # LU-1795: test filefrag/FIEMAP once, even if unsupported
8794 filefrag -ves $fm_file
8796 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
8797 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
8798 [ $RC != 0 ] && error "filefrag $fm_file failed"
8800 filefrag_op=$(filefrag -ve $fm_file | grep -A 100 "ext:" |
8801 grep -v "ext:" | grep -v "found")
8802 lun=$($GETSTRIPE -i $fm_file)
8804 start_blk=`echo $filefrag_op | cut -d: -f2 | cut -d. -f1`
8807 for line in $filefrag_op
8809 frag_lun=`echo $line | cut -d: -f5`
8810 ext_len=`echo $line | cut -d: -f4`
8811 if (( $frag_lun != $lun )); then
8813 error "FIEMAP on 1-stripe file($fm_file) failed"
8816 (( tot_len += ext_len ))
8819 if (( lun != frag_lun || start_blk != 0 || tot_len != 64 )); then
8821 error "FIEMAP on 1-stripe file($fm_file) failed;"
8827 echo "FIEMAP on single striped file succeeded"
8829 run_test 130a "FIEMAP (1-stripe file)"
8832 [ "$OSTCOUNT" -lt "2" ] &&
8833 skip_env "skipping FIEMAP on 2-stripe file test" && return
8835 [ "$OSTCOUNT" -ge "10" ] &&
8836 skip_env "skipping FIEMAP with >= 10 OSTs" && return
8838 local filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
8839 [ -n "$filefrag_op" ] && skip_env "filefrag does not support FIEMAP" &&
8842 trap cleanup_130 EXIT RETURN
8844 local fm_file=$DIR/$tfile
8845 $SETSTRIPE -S 65536 -c 2 $fm_file || error "setstripe on $fm_file"
8846 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
8847 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
8849 dd if=/dev/zero of=$fm_file bs=1M count=2 ||
8850 error "dd failed on $fm_file"
8852 filefrag -ves $fm_file || error "filefrag $fm_file failed"
8853 filefrag_op=$(filefrag -ve $fm_file | grep -A 100 "ext:" |
8854 grep -v "ext:" | grep -v "found")
8856 last_lun=$(echo $filefrag_op | cut -d: -f5)
8861 for line in $filefrag_op
8863 frag_lun=`echo $line | cut -d: -f5`
8864 ext_len=`echo $line | cut -d: -f4`
8865 if (( $frag_lun != $last_lun )); then
8866 if (( tot_len != 1024 )); then
8868 error "FIEMAP on $fm_file failed; returned len $tot_len for OST $last_lun instead of 256"
8875 (( tot_len += ext_len ))
8878 if (( num_luns != 2 || tot_len != 1024 )); then
8880 error "FIEMAP on $fm_file failed; returned wrong number of luns or wrong len for OST $last_lun"
8886 echo "FIEMAP on 2-stripe file succeeded"
8888 run_test 130b "FIEMAP (2-stripe file)"
8891 [ "$OSTCOUNT" -lt "2" ] &&
8892 skip_env "skipping FIEMAP on 2-stripe file" && return
8894 [ "$OSTCOUNT" -ge "10" ] &&
8895 skip_env "skipping FIEMAP with >= 10 OSTs" && return
8897 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
8898 [ -n "$filefrag_op" ] && skip "filefrag does not support FIEMAP" &&
8901 trap cleanup_130 EXIT RETURN
8903 local fm_file=$DIR/$tfile
8904 $SETSTRIPE -S 65536 -c 2 $fm_file || error "setstripe on $fm_file"
8905 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
8906 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
8908 dd if=/dev/zero of=$fm_file seek=1 bs=1M count=1 || error "dd failed on $fm_file"
8910 filefrag -ves $fm_file || error "filefrag $fm_file failed"
8911 filefrag_op=`filefrag -ve $fm_file | grep -A 100 "ext:" | grep -v "ext:" | grep -v "found"`
8913 last_lun=`echo $filefrag_op | cut -d: -f5`
8918 for line in $filefrag_op
8920 frag_lun=`echo $line | cut -d: -f5`
8921 ext_len=`echo $line | cut -d: -f4`
8922 if (( $frag_lun != $last_lun )); then
8923 logical=`echo $line | cut -d: -f2 | cut -d. -f1`
8924 if (( logical != 512 )); then
8926 error "FIEMAP on $fm_file failed; returned logical start for lun $logical instead of 512"
8929 if (( tot_len != 512 )); then
8931 error "FIEMAP on $fm_file failed; returned len $tot_len for OST $last_lun instead of 1024"
8938 (( tot_len += ext_len ))
8941 if (( num_luns != 2 || tot_len != 512 )); then
8943 error "FIEMAP on $fm_file failed; returned wrong number of luns or wrong len for OST $last_lun"
8949 echo "FIEMAP on 2-stripe file with hole succeeded"
8951 run_test 130c "FIEMAP (2-stripe file with hole)"
8954 [ "$OSTCOUNT" -lt "3" ] && skip_env "skipping FIEMAP on N-stripe file test" && return
8956 [ "$OSTCOUNT" -ge "10" ] &&
8957 skip_env "skipping FIEMAP with >= 10 OSTs" && return
8959 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
8960 [ -n "$filefrag_op" ] && skip "filefrag does not support FIEMAP" && return
8962 trap cleanup_130 EXIT RETURN
8964 local fm_file=$DIR/$tfile
8965 $SETSTRIPE -S 65536 -c $OSTCOUNT $fm_file||error "setstripe on $fm_file"
8966 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
8967 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
8969 local actual_stripecnt=$($GETSTRIPE -c $fm_file)
8970 dd if=/dev/zero of=$fm_file bs=1M count=$actual_stripecnt ||
8971 error "dd failed on $fm_file"
8973 filefrag -ves $fm_file || error "filefrag $fm_file failed"
8974 filefrag_op=`filefrag -ve $fm_file | grep -A 100 "ext:" |
8975 grep -v "ext:" | grep -v "found"`
8977 last_lun=`echo $filefrag_op | cut -d: -f5`
8982 for line in $filefrag_op
8984 frag_lun=`echo $line | cut -d: -f5`
8985 ext_len=`echo $line | cut -d: -f4`
8986 if (( $frag_lun != $last_lun )); then
8987 if (( tot_len != 1024 )); then
8989 error "FIEMAP on $fm_file failed; returned len $tot_len for OST $last_lun instead of 1024"
8996 (( tot_len += ext_len ))
8999 if (( num_luns != actual_stripecnt || tot_len != 1024 )); then
9001 error "FIEMAP on $fm_file failed; returned wrong number of luns or wrong len for OST $last_lun"
9007 echo "FIEMAP on N-stripe file succeeded"
9009 run_test 130d "FIEMAP (N-stripe file)"
9012 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping continuation FIEMAP test" && return
9014 [ "$OSTCOUNT" -ge "10" ] &&
9015 skip_env "skipping FIEMAP with >= 10 OSTs" && return
9017 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
9018 [ -n "$filefrag_op" ] && skip "filefrag does not support FIEMAP" && return
9020 trap cleanup_130 EXIT RETURN
9022 local fm_file=$DIR/$tfile
9023 $SETSTRIPE -S 131072 -c 2 $fm_file || error "setstripe on $fm_file"
9024 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
9025 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
9028 EXPECTED_LEN=$(( (NUM_BLKS / 2) * 64 ))
9029 for ((i = 0; i < $NUM_BLKS; i++))
9031 dd if=/dev/zero of=$fm_file count=1 bs=64k seek=$((2*$i)) conv=notrunc > /dev/null 2>&1
9034 filefrag -ves $fm_file || error "filefrag $fm_file failed"
9035 filefrag_op=`filefrag -ve $fm_file | grep -A 12000 "ext:" | grep -v "ext:" | grep -v "found"`
9037 last_lun=`echo $filefrag_op | cut -d: -f5`
9042 for line in $filefrag_op
9044 frag_lun=`echo $line | cut -d: -f5`
9045 ext_len=`echo $line | cut -d: -f4`
9046 if (( $frag_lun != $last_lun )); then
9047 if (( tot_len != $EXPECTED_LEN )); then
9049 error "FIEMAP on $fm_file failed; returned len $tot_len for OST $last_lun instead of $EXPECTED_LEN"
9056 (( tot_len += ext_len ))
9059 if (( num_luns != 2 || tot_len != $EXPECTED_LEN )); then
9061 error "FIEMAP on $fm_file failed; returned wrong number of luns or wrong len for OST $last_lun"
9067 echo "FIEMAP with continuation calls succeeded"
9069 run_test 130e "FIEMAP (test continuation FIEMAP calls)"
9071 # Test for writev/readv
9073 rwv -f $DIR/$tfile -w -n 3 524288 1048576 1572864 || \
9074 error "writev test failed"
9075 rwv -f $DIR/$tfile -r -v -n 2 1572864 1048576 || \
9076 error "readv failed"
9079 run_test 131a "test iov's crossing stripe boundary for writev/readv"
9082 rwv -f $DIR/$tfile -w -a -n 3 524288 1048576 1572864 || \
9083 error "append writev test failed"
9084 rwv -f $DIR/$tfile -w -a -n 2 1572864 1048576 || \
9085 error "append writev test failed"
9088 run_test 131b "test append writev"
9091 rwv -f $DIR/$tfile -w -d -n 1 1048576 || return 0
9094 run_test 131c "test read/write on file w/o objects"
9097 rwv -f $DIR/$tfile -w -n 1 1572864
9098 NOB=`rwv -f $DIR/$tfile -r -n 3 524288 524288 1048576 | awk '/error/ {print $6}'`
9099 if [ "$NOB" != 1572864 ]; then
9100 error "Short read filed: read $NOB bytes instead of 1572864"
9104 run_test 131d "test short read"
9107 rwv -f $DIR/$tfile -w -s 1048576 -n 1 1048576
9108 rwv -f $DIR/$tfile -r -z -s 0 -n 1 524288 || \
9109 error "read hitting hole failed"
9112 run_test 131e "test read hitting hole"
9118 $SINGLEMDS) res=`do_facet $SINGLEMDS $LCTL get_param mdt.$FSNAME-MDT0000.md_stats | grep "$2"`
9120 ost) res=`do_facet ost1 $LCTL get_param obdfilter.$FSNAME-OST0000.stats | grep "$2"`
9122 *) error "Wrong argument $1" ;;
9125 [ -z "$res" ] && error "The counter for $2 on $1 was not incremented"
9126 # if the argument $3 is zero, it means any stat increment is ok.
9127 if [[ $3 -gt 0 ]]; then
9128 count=$(echo $res | awk '{ print $2 }')
9129 [[ $count -ne $3 ]] &&
9130 error "The $2 counter on $1 is wrong - expected $3"
9135 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9136 remote_ost_nodsh && skip "remote OST with nodsh" && return
9137 remote_mds_nodsh && skip "remote MDS with nodsh" && return
9139 do_facet $SINGLEMDS $LCTL list_param mdt.*.rename_stats ||
9140 { skip "MDS doesn't support rename stats"; return; }
9141 local testdir=$DIR/${tdir}/stats_testdir
9142 mkdir -p $DIR/${tdir}
9145 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
9146 do_facet ost1 $LCTL set_param obdfilter.*.stats=clear
9148 # verify mdt stats first.
9149 mkdir ${testdir} || error "mkdir failed"
9150 check_stats $SINGLEMDS "mkdir" 1
9151 touch ${testdir}/${tfile} || "touch failed"
9152 check_stats $SINGLEMDS "open" 1
9153 check_stats $SINGLEMDS "close" 1
9154 mknod ${testdir}/${tfile}-pipe p || "mknod failed"
9155 check_stats $SINGLEMDS "mknod" 1
9156 rm -f ${testdir}/${tfile}-pipe || "pipe remove failed"
9157 check_stats $SINGLEMDS "unlink" 1
9158 rm -f ${testdir}/${tfile} || error "file remove failed"
9159 check_stats $SINGLEMDS "unlink" 2
9161 # remove working dir and check mdt stats again.
9162 rmdir ${testdir} || error "rmdir failed"
9163 check_stats $SINGLEMDS "rmdir" 1
9165 local testdir1=$DIR/${tdir}/stats_testdir1
9167 mkdir -p ${testdir1}
9168 touch ${testdir1}/test1
9169 mv ${testdir1}/test1 ${testdir} || error "file crossdir rename"
9170 check_stats $SINGLEMDS "crossdir_rename" 1
9172 mv ${testdir}/test1 ${testdir}/test0 || error "file samedir rename"
9173 check_stats $SINGLEMDS "samedir_rename" 1
9177 run_test 133a "Verifying MDT stats ========================================"
9180 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9181 remote_ost_nodsh && skip "remote OST with nodsh" && return
9182 remote_mds_nodsh && skip "remote MDS with nodsh" && return
9183 local testdir=$DIR/${tdir}/stats_testdir
9184 mkdir -p ${testdir} || error "mkdir failed"
9185 touch ${testdir}/${tfile} || "touch failed"
9186 cancel_lru_locks mdc
9189 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
9190 do_facet ost1 $LCTL set_param obdfilter.*.stats=clear
9192 # extra mdt stats verification.
9193 chmod 444 ${testdir}/${tfile} || error "chmod failed"
9194 check_stats $SINGLEMDS "setattr" 1
9195 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
9196 if [ $(lustre_version_code $SINGLEMDS) -ne $(version_code 2.2.0) ]
9198 ls -l ${testdir}/${tfile} > /dev/null|| error "ls failed"
9199 check_stats $SINGLEMDS "getattr" 1
9201 $LFS df || error "lfs failed"
9202 check_stats $SINGLEMDS "statfs" 1
9206 run_test 133b "Verifying extra MDT stats =================================="
9209 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9210 remote_ost_nodsh && skip "remote OST with nodsh" && return
9211 remote_mds_nodsh && skip "remote MDS with nodsh" && return
9212 local testdir=$DIR/${tdir}/stats_testdir
9213 test_mkdir -p ${testdir} || error "mkdir failed"
9215 # verify obdfilter stats.
9216 $SETSTRIPE -c 1 -i 0 ${testdir}/${tfile}
9218 cancel_lru_locks osc
9219 wait_delete_completed
9222 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
9223 do_facet ost1 $LCTL set_param obdfilter.*.stats=clear
9225 dd if=/dev/zero of=${testdir}/${tfile} conv=notrunc bs=512k count=1 || error "dd failed"
9227 cancel_lru_locks osc
9228 check_stats ost "write" 1
9230 dd if=${testdir}/${tfile} of=/dev/null bs=1k count=1 || error "dd failed"
9231 check_stats ost "read" 1
9233 > ${testdir}/${tfile} || error "truncate failed"
9234 check_stats ost "punch" 1
9236 rm -f ${testdir}/${tfile} || error "file remove failed"
9237 wait_delete_completed
9238 check_stats ost "destroy" 1
9242 run_test 133c "Verifying OST stats ========================================"
9249 while [ $value -ge 2 ]; do
9254 if [ $orig -gt $order ]; then
9262 local size=('K' 'M' 'G' 'T');
9264 local size_string=$value
9266 while [ $value -ge 1024 ]; do
9267 if [ $i -gt 3 ]; then
9268 #T is the biggest unit we get here, if that is bigger,
9270 size_string=${value}T
9273 value=$((value >> 10))
9274 if [ $value -lt 1024 ]; then
9275 size_string=${value}${size[$i]}
9286 local context=${2:-.}
9287 local sample=$(do_facet $SINGLEMDS $LCTL get_param mdt.*.rename_stats |
9289 awk '/ '${size}'/ {print $4}' | sed -e "s/,//g")
9294 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9295 remote_ost_nodsh && skip "remote OST with nodsh" && return
9296 remote_mds_nodsh && skip "remote MDS with nodsh" && return
9297 do_facet $SINGLEMDS $LCTL list_param mdt.*.rename_stats ||
9298 { skip "MDS doesn't support rename stats"; return; }
9300 local testdir1=$DIR/${tdir}/stats_testdir1
9301 local testdir2=$DIR/${tdir}/stats_testdir2
9303 do_facet $SINGLEMDS $LCTL set_param mdt.*.rename_stats=clear
9305 mkdir -p ${testdir1} || error "mkdir failed"
9306 mkdir -p ${testdir2} || error "mkdir failed"
9308 createmany -o $testdir1/test 512 || error "createmany failed"
9310 # check samedir rename size
9311 mv ${testdir1}/test0 ${testdir1}/test_0
9313 local testdir1_size=$(ls -l $DIR/${tdir} |
9314 awk '/stats_testdir1/ {print $5}')
9315 local testdir2_size=$(ls -l $DIR/${tdir} |
9316 awk '/stats_testdir2/ {print $5}')
9318 testdir1_size=$(order_2 $testdir1_size)
9319 testdir2_size=$(order_2 $testdir2_size)
9321 testdir1_size=$(size_in_KMGT $testdir1_size)
9322 testdir2_size=$(size_in_KMGT $testdir2_size)
9324 echo "source rename dir size: ${testdir1_size}"
9325 echo "target rename dir size: ${testdir2_size}"
9327 local cmd="do_facet $SINGLEMDS $LCTL get_param mdt.*.rename_stats"
9328 eval $cmd || error "$cmd failed"
9329 local samedir=$($cmd | grep 'same_dir')
9330 local same_sample=$(get_rename_size $testdir1_size)
9331 [ -z "$samedir" ] && error "samedir_rename_size count error"
9332 [[ $same_sample -eq 1 ]] ||
9333 error "samedir_rename_size error $same_sample"
9334 echo "Check same dir rename stats success"
9336 do_facet $SINGLEMDS $LCTL set_param mdt.*.rename_stats=clear
9338 # check crossdir rename size
9339 mv ${testdir1}/test_0 ${testdir2}/test_0
9341 testdir1_size=$(ls -l $DIR/${tdir} |
9342 awk '/stats_testdir1/ {print $5}')
9343 testdir2_size=$(ls -l $DIR/${tdir} |
9344 awk '/stats_testdir2/ {print $5}')
9346 testdir1_size=$(order_2 $testdir1_size)
9347 testdir2_size=$(order_2 $testdir2_size)
9349 testdir1_size=$(size_in_KMGT $testdir1_size)
9350 testdir2_size=$(size_in_KMGT $testdir2_size)
9352 echo "source rename dir size: ${testdir1_size}"
9353 echo "target rename dir size: ${testdir2_size}"
9355 eval $cmd || error "$cmd failed"
9356 local crossdir=$($cmd | grep 'crossdir')
9357 local src_sample=$(get_rename_size $testdir1_size crossdir_src)
9358 local tgt_sample=$(get_rename_size $testdir2_size crossdir_tgt)
9359 [ -z "$crossdir" ] && error "crossdir_rename_size count error"
9360 [[ $src_sample -eq 1 ]] ||
9361 error "crossdir_rename_size error $src_sample"
9362 [[ $tgt_sample -eq 1 ]] ||
9363 error "crossdir_rename_size error $tgt_sample"
9364 echo "Check cross dir rename stats success"
9367 run_test 133d "Verifying rename_stats ========================================"
9370 remote_mds_nodsh && skip "remote MDS with nodsh" && return
9371 remote_ost_nodsh && skip "remote OST with nodsh" && return
9372 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9373 local testdir=$DIR/${tdir}/stats_testdir
9374 local ctr f0 f1 bs=32768 count=42 sum
9376 mkdir -p ${testdir} || error "mkdir failed"
9378 $SETSTRIPE -c 1 -i 0 ${testdir}/${tfile}
9380 for ctr in {write,read}_bytes; do
9382 cancel_lru_locks osc
9384 do_facet ost1 $LCTL set_param -n \
9385 "obdfilter.*.exports.clear=clear"
9387 if [ $ctr = write_bytes ]; then
9389 f1=${testdir}/${tfile}
9391 f0=${testdir}/${tfile}
9395 dd if=$f0 of=$f1 conv=notrunc bs=$bs count=$count || \
9398 cancel_lru_locks osc
9400 sum=$(do_facet ost1 $LCTL get_param \
9401 "obdfilter.*.exports.*.stats" |
9402 awk -v ctr=$ctr 'BEGIN { sum = 0 }
9403 $1 == ctr { sum += $7 }
9404 END { printf("%0.0f", sum) }')
9406 if ((sum != bs * count)); then
9407 error "Bad $ctr sum, expected $((bs * count)), got $sum"
9413 run_test 133e "Verifying OST {read,write}_bytes nid stats ================="
9418 local dirs="/proc/fs/lustre/ /proc/sys/lnet/ /proc/sys/lustre/ \
9419 /sys/fs/lustre/ /sys/fs/lnet/"
9421 for dir in $dirs; do
9422 if [ -d $dir ]; then
9423 proc_dirs="$proc_dirs $dir"
9429 remote_mds_nodsh && skip "remote MDS with nodsh" && return
9430 remote_ost_nodsh && skip "remote OST with nodsh" && return
9431 # First without trusting modes.
9432 find $proc_dirs -exec cat '{}' \; &> /dev/null
9434 # Second verifying readability.
9437 -exec cat '{}' \; &> /dev/null ||
9438 error "proc file read failed"
9440 for facet in $SINGLEMDS ost1; do
9441 do_facet $facet find $proc_dirs \
9442 ! -name req_history \
9443 -exec cat '{}' \\\; &> /dev/null
9445 do_facet $facet find $proc_dirs \
9446 ! -name req_history \
9448 -exec cat '{}' \\\; &> /dev/null ||
9449 error "proc file read failed"
9452 run_test 133f "Check for LBUGs/Oopses/unreadable files in /proc"
9457 local dirs="/proc/fs/lustre/ /proc/sys/lnet/ /proc/sys/lustre/ \
9458 /sys/fs/lustre/ /sys/fs/lnet/"
9460 for dir in $dirs; do
9461 if [ -d $dir ]; then
9462 proc_dirs="$proc_dirs $dir"
9468 # Second verifying readability.
9471 -not -name force_lbug \
9472 -not -name changelog_mask \
9473 -exec badarea_io '{}' \; &> /dev/null ||
9474 error "find $proc_dirs failed"
9476 [ $(lustre_version_code $SINGLEMDS) -le $(version_code 2.5.54) ] &&
9477 skip "Too old lustre on MDS" && return
9479 [ $(lustre_version_code ost1) -le $(version_code 2.5.54) ] &&
9480 skip "Too old lustre on ost1" && return
9482 for facet in $SINGLEMDS ost1; do
9483 do_facet $facet find $proc_dirs \
9485 -not -name force_lbug \
9486 -not -name changelog_mask \
9487 -exec badarea_io '{}' \\\; &> /dev/null ||
9488 error "$facet find $proc_dirs failed"
9492 # remount the FS in case writes/reads /proc break the FS
9493 cleanup || error "failed to unmount"
9494 setup || error "failed to setup"
9497 run_test 133g "Check for Oopses on bad io area writes/reads in /proc"
9500 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.54) ]] &&
9501 skip "Need MDS version at least 2.7.54" && return
9503 mkdir -p $DIR/$tdir || error "failed to create $DIR/$tdir"
9504 cancel_lru_locks mdc
9506 local nsdir="ldlm.namespaces.*-MDT0000-mdc-*"
9507 local unused=$($LCTL get_param -n $nsdir.lock_unused_count)
9508 [ $unused -eq 0 ] || "$unused locks are not cleared"
9511 createmany -o $DIR/$tdir/f $nr ||
9512 error "failed to create $nr files in $DIR/$tdir"
9513 unused=$($LCTL get_param -n $nsdir.lock_unused_count)
9515 #define OBD_FAIL_LDLM_WATERMARK_LOW 0x327
9516 do_facet mds1 $LCTL set_param fail_loc=0x327
9517 do_facet mds1 $LCTL set_param fail_val=500
9520 echo "sleep 10 seconds ..."
9522 local lck_cnt=$($LCTL get_param -n $nsdir.lock_unused_count)
9524 do_facet mds1 $LCTL set_param fail_loc=0
9525 do_facet mds1 $LCTL set_param fail_val=0
9526 [ $lck_cnt -lt $unused ] ||
9527 error "No locks reclaimed, before:$unused, after:$lck_cnt"
9530 unlinkmany $DIR/$tdir/f $nr
9532 run_test 134a "Server reclaims locks when reaching lock_reclaim_threshold"
9535 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.54) ]] &&
9536 skip "Need MDS version at least 2.7.54" && return
9538 mkdir -p $DIR/$tdir || error "failed to create $DIR/$tdir"
9539 cancel_lru_locks mdc
9541 local low_wm=$(do_facet mds1 $LCTL get_param -n \
9542 ldlm.lock_reclaim_threshold_mb)
9543 # disable reclaim temporarily
9544 do_facet mds1 $LCTL set_param ldlm.lock_reclaim_threshold_mb=0
9546 #define OBD_FAIL_LDLM_WATERMARK_HIGH 0x328
9547 do_facet mds1 $LCTL set_param fail_loc=0x328
9548 do_facet mds1 $LCTL set_param fail_val=500
9550 $LCTL set_param debug=+trace
9553 createmany -o $DIR/$tdir/f $nr &
9556 echo "Sleep $TIMEOUT seconds ..."
9558 if ! ps -p $create_pid > /dev/null 2>&1; then
9559 do_facet mds1 $LCTL set_param fail_loc=0
9560 do_facet mds1 $LCTL set_param fail_val=0
9561 do_facet mds1 $LCTL set_param \
9562 ldlm.lock_reclaim_threshold_mb=${low_wm}m
9563 error "createmany finished incorrectly!"
9565 do_facet mds1 $LCTL set_param fail_loc=0
9566 do_facet mds1 $LCTL set_param fail_val=0
9567 do_facet mds1 $LCTL set_param ldlm.lock_reclaim_threshold_mb=${low_wm}m
9568 wait $create_pid || return 1
9570 unlinkmany $DIR/$tdir/f $nr
9572 run_test 134b "Server rejects lock request when reaching lock_limit_mb"
9574 test_140() { #bug-17379
9575 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9576 test_mkdir -p $DIR/$tdir || error "Creating dir $DIR/$tdir"
9577 cd $DIR/$tdir || error "Changing to $DIR/$tdir"
9578 cp /usr/bin/stat . || error "Copying stat to $DIR/$tdir"
9580 # VFS limits max symlink depth to 5(4KSTACK) or 7(8KSTACK) or 8
9581 # For kernel > 3.5, bellow only tests consecutive symlink (MAX 40)
9583 while i=`expr $i + 1`; do
9584 test_mkdir -p $i || error "Creating dir $i"
9585 cd $i || error "Changing to $i"
9586 ln -s ../stat stat || error "Creating stat symlink"
9587 # Read the symlink until ELOOP present,
9588 # not LBUGing the system is considered success,
9589 # we didn't overrun the stack.
9590 $OPENFILE -f O_RDONLY stat >/dev/null 2>&1; ret=$?
9592 if [ $ret -eq 40 ]; then
9595 error "Open stat symlink"
9601 echo "The symlink depth = $i"
9602 [ $i -eq 5 -o $i -eq 7 -o $i -eq 8 -o $i -eq 40 ] ||
9603 error "Invalid symlink depth"
9605 # Test recursive symlink
9606 ln -s symlink_self symlink_self
9607 $OPENFILE -f O_RDONLY symlink_self >/dev/null 2>&1; ret=$?
9608 echo "open symlink_self returns $ret"
9609 [ $ret -eq 40 ] || error "recursive symlink doesn't return -ELOOP"
9611 run_test 140 "Check reasonable stack depth (shouldn't LBUG) ===="
9614 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9615 local TF="$TMP/$tfile"
9617 dd if=/dev/urandom of=$TF bs=6096 count=1 || error "dd failed"
9619 cancel_lru_locks osc
9620 cmp $TF $DIR/$tfile || error "$TMP/$tfile $DIR/$tfile differ"
9621 remount_client $MOUNT
9623 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (remount)"
9626 $TRUNCATE $DIR/$tfile 6000
9627 cancel_lru_locks osc
9628 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (truncate1)"
9631 echo "12345" >>$DIR/$tfile
9632 cancel_lru_locks osc
9633 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (append1)"
9636 echo "12345" >>$DIR/$tfile
9637 cancel_lru_locks osc
9638 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (append2)"
9643 run_test 150 "truncate/append tests"
9645 #LU-2902 roc_hit was not able to read all values from lproc
9646 function roc_hit_init() {
9647 local list=$(comma_list $(osts_nodes))
9648 local dir=$DIR/$tdir-check
9649 local file=$dir/file
9655 #use setstripe to do a write to every ost
9656 for i in $(seq 0 $((OSTCOUNT-1))); do
9657 $SETSTRIPE -c 1 -i $i $dir || error "$SETSTRIPE $file failed"
9658 dd if=/dev/urandom of=$file bs=4k count=4 2>&1 > /dev/null
9659 idx=$(printf %04x $i)
9660 BEFORE=$(get_osd_param $list *OST*$idx stats |
9661 awk '$1 == "cache_access" {sum += $7}
9662 END { printf("%0.0f", sum) }')
9664 cancel_lru_locks osc
9665 cat $file >/dev/null
9667 AFTER=$(get_osd_param $list *OST*$idx stats |
9668 awk '$1 == "cache_access" {sum += $7}
9669 END { printf("%0.0f", sum) }')
9671 echo BEFORE:$BEFORE AFTER:$AFTER
9672 if ! let "AFTER - BEFORE == 4"; then
9674 error "roc_hit is not safe to use"
9682 function roc_hit() {
9683 local list=$(comma_list $(osts_nodes))
9684 echo $(get_osd_param $list '' stats |
9685 awk '$1 == "cache_hit" {sum += $7}
9686 END { printf("%0.0f", sum) }')
9689 function set_cache() {
9692 if [ "$2" == "off" ]; then
9695 local list=$(comma_list $(osts_nodes))
9696 set_osd_param $list '' $1_cache_enable $on
9698 cancel_lru_locks osc
9702 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9703 remote_ost_nodsh && skip "remote OST with nodsh" && return
9706 local list=$(comma_list $(osts_nodes))
9708 # check whether obdfilter is cache capable at all
9709 if ! get_osd_param $list '' read_cache_enable >/dev/null; then
9710 echo "not cache-capable obdfilter"
9714 # check cache is enabled on all obdfilters
9715 if get_osd_param $list '' read_cache_enable | grep 0; then
9716 echo "oss cache is disabled"
9720 set_osd_param $list '' writethrough_cache_enable 1
9722 # check write cache is enabled on all obdfilters
9723 if get_osd_param $list '' writethrough_cache_enable | grep 0; then
9724 echo "oss write cache is NOT enabled"
9730 #define OBD_FAIL_OBD_NO_LRU 0x609
9731 do_nodes $list $LCTL set_param fail_loc=0x609
9733 # pages should be in the case right after write
9734 dd if=/dev/urandom of=$DIR/$tfile bs=4k count=$CPAGES ||
9737 local BEFORE=$(roc_hit)
9738 cancel_lru_locks osc
9739 cat $DIR/$tfile >/dev/null
9740 local AFTER=$(roc_hit)
9742 do_nodes $list $LCTL set_param fail_loc=0
9744 if ! let "AFTER - BEFORE == CPAGES"; then
9745 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
9748 # the following read invalidates the cache
9749 cancel_lru_locks osc
9750 set_osd_param $list '' read_cache_enable 0
9751 cat $DIR/$tfile >/dev/null
9753 # now data shouldn't be found in the cache
9755 cancel_lru_locks osc
9756 cat $DIR/$tfile >/dev/null
9758 if let "AFTER - BEFORE != 0"; then
9759 error "IN CACHE: before: $BEFORE, after: $AFTER"
9762 set_osd_param $list '' read_cache_enable 1
9765 run_test 151 "test cache on oss and controls ==============================="
9768 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9769 local TF="$TMP/$tfile"
9771 # simulate ENOMEM during write
9772 #define OBD_FAIL_OST_NOMEM 0x226
9773 lctl set_param fail_loc=0x80000226
9774 dd if=/dev/urandom of=$TF bs=6096 count=1 || error "dd failed"
9776 sync || error "sync failed"
9777 lctl set_param fail_loc=0
9779 # discard client's cache
9780 cancel_lru_locks osc
9782 # simulate ENOMEM during read
9783 lctl set_param fail_loc=0x80000226
9784 cmp $TF $DIR/$tfile || error "cmp failed"
9785 lctl set_param fail_loc=0
9789 run_test 152 "test read/write with enomem ============================"
9792 $MULTIOP $DIR/$tfile Ow4096Ycu || error "multiop failed"
9794 run_test 153 "test if fdatasync does not crash ======================="
9796 dot_lustre_fid_permission_check() {
9798 local ffid=$MOUNT/.lustre/fid/$fid
9801 echo "stat fid $fid"
9802 stat $ffid > /dev/null || error "stat $ffid failed."
9803 echo "touch fid $fid"
9804 touch $ffid || error "touch $ffid failed."
9805 echo "write to fid $fid"
9806 cat /etc/hosts > $ffid || error "write $ffid failed."
9807 echo "read fid $fid"
9808 diff /etc/hosts $ffid || error "read $ffid failed."
9809 echo "append write to fid $fid"
9810 cat /etc/hosts >> $ffid || error "append write $ffid failed."
9811 echo "rename fid $fid"
9812 mv $ffid $test_dir/$tfile.1 &&
9813 error "rename $ffid to $tfile.1 should fail."
9814 touch $test_dir/$tfile.1
9815 mv $test_dir/$tfile.1 $ffid &&
9816 error "rename $tfile.1 to $ffid should fail."
9817 rm -f $test_dir/$tfile.1
9818 echo "truncate fid $fid"
9819 $TRUNCATE $ffid 777 || error "truncate $ffid failed."
9820 if [ $MDSCOUNT -lt 2 ]; then #FIXME when cross-MDT hard link is working
9821 echo "link fid $fid"
9822 ln -f $ffid $test_dir/tfile.lnk || error "link $ffid failed."
9824 if [ -n $(lctl get_param -n mdc.*-mdc-*.connect_flags | grep acl) ]; then
9825 echo "setfacl fid $fid"
9826 setfacl -R -m u:bin:rwx $ffid || error "setfacl $ffid failed."
9827 echo "getfacl fid $fid"
9828 getfacl $ffid >/dev/null || error "getfacl $ffid failed."
9830 echo "unlink fid $fid"
9831 unlink $MOUNT/.lustre/fid/$fid && error "unlink $ffid should fail."
9832 echo "mknod fid $fid"
9833 mknod $ffid c 1 3 && error "mknod $ffid should fail."
9835 fid=[0xf00000400:0x1:0x0]
9836 ffid=$MOUNT/.lustre/fid/$fid
9838 echo "stat non-exist fid $fid"
9839 stat $ffid > /dev/null && error "stat non-exist $ffid should fail."
9840 echo "write to non-exist fid $fid"
9841 cat /etc/hosts > $ffid && error "write non-exist $ffid should fail."
9842 echo "link new fid $fid"
9843 ln $test_dir/$tfile $ffid && error "link $ffid should fail."
9845 mkdir -p $test_dir/$tdir
9846 touch $test_dir/$tdir/$tfile
9847 fid=$($LFS path2fid $test_dir/$tdir)
9850 error "error: could not get fid for $test_dir/$dir/$tfile."
9852 ffid=$MOUNT/.lustre/fid/$fid
9855 ls $ffid > /dev/null || error "ls $ffid failed."
9856 echo "touch $fid/$tfile.1"
9857 touch $ffid/$tfile.1 || error "touch $ffid/$tfile.1 failed."
9859 echo "touch $MOUNT/.lustre/fid/$tfile"
9860 touch $MOUNT/.lustre/fid/$tfile && \
9861 error "touch $MOUNT/.lustre/fid/$tfile should fail."
9863 echo "setxattr to $MOUNT/.lustre/fid"
9864 setfattr -n trusted.name1 -v value1 $MOUNT/.lustre/fid
9866 echo "listxattr for $MOUNT/.lustre/fid"
9867 getfattr -d -m "^trusted" $MOUNT/.lustre/fid
9869 echo "delxattr from $MOUNT/.lustre/fid"
9870 setfattr -x trusted.name1 $MOUNT/.lustre/fid
9872 echo "touch invalid fid: $MOUNT/.lustre/fid/[0x200000400:0x2:0x3]"
9873 touch $MOUNT/.lustre/fid/[0x200000400:0x2:0x3] &&
9874 error "touch invalid fid should fail."
9876 echo "touch non-normal fid: $MOUNT/.lustre/fid/[0x1:0x2:0x0]"
9877 touch $MOUNT/.lustre/fid/[0x1:0x2:0x0] &&
9878 error "touch non-normal fid should fail."
9880 echo "rename $tdir to $MOUNT/.lustre/fid"
9881 mrename $test_dir/$tdir $MOUNT/.lustre/fid &&
9882 error "rename to $MOUNT/.lustre/fid should fail."
9884 if [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.3.51) ]
9886 local old_obf_mode=$(stat --format="%a" $DIR/.lustre/fid)
9887 local new_obf_mode=777
9889 echo "change mode of $DIR/.lustre/fid to $new_obf_mode"
9890 chmod $new_obf_mode $DIR/.lustre/fid ||
9891 error "chmod $new_obf_mode $DIR/.lustre/fid failed"
9893 local obf_mode=$(stat --format=%a $DIR/.lustre/fid)
9894 [ $obf_mode -eq $new_obf_mode ] ||
9895 error "stat $DIR/.lustre/fid returned wrong mode $obf_mode"
9897 echo "restore mode of $DIR/.lustre/fid to $old_obf_mode"
9898 chmod $old_obf_mode $DIR/.lustre/fid ||
9899 error "chmod $old_obf_mode $DIR/.lustre/fid failed"
9902 $OPENFILE -f O_LOV_DELAY_CREATE:O_CREAT $test_dir/$tfile-2
9903 fid=$($LFS path2fid $test_dir/$tfile-2)
9905 if [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.6.50) ]
9907 echo "cp /etc/passwd $MOUNT/.lustre/fid/$fid"
9908 cp /etc/passwd $MOUNT/.lustre/fid/$fid ||
9909 error "create lov data thru .lustre failed"
9911 echo "cp /etc/passwd $test_dir/$tfile-2"
9912 cp /etc/passwd $test_dir/$tfile-2 ||
9913 error "copy to $test_dir/$tfile-2 failed."
9914 echo "diff /etc/passwd $MOUNT/.lustre/fid/$fid"
9915 diff /etc/passwd $MOUNT/.lustre/fid/$fid ||
9916 error "diff /etc/passwd $MOUNT/.lustre/fid/$fid failed."
9918 rm -rf $test_dir/tfile.lnk
9919 rm -rf $test_dir/$tfile-2
9923 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.1) ]] &&
9924 skip "Need MDS version at least 2.4.1" && return
9927 local FID=$($LFS path2fid $DIR/$tfile)
9928 [ -z "$FID" ] && error "path2fid unable to get $DIR/$tfile FID"
9930 # check that we get the same pathname back
9931 local FOUND=$($LFS fid2path $MOUNT "$FID")
9932 [ -z "$FOUND" ] && error "fid2path unable to get $FID path"
9933 [ "$FOUND" != "$DIR/$tfile" ] &&
9934 error "fid2path(path2fid($DIR/$tfile)) = $FOUND != $DIR/$tfile"
9938 run_test 154A "lfs path2fid and fid2path basic checks"
9941 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9942 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.51) ]] ||
9943 { skip "Need MDS version at least 2.2.51"; return 0; }
9944 [ -z "$(which setfacl)" ] && skip "must have setfacl tool" && return
9946 cp /etc/hosts $DIR/$tfile
9948 fid=$($LFS path2fid $DIR/$tfile)
9950 [ $rc -ne 0 ] && error "error: could not get fid for $DIR/$tfile."
9952 dot_lustre_fid_permission_check "$fid" $DIR ||
9953 error "dot lustre permission check $fid failed"
9955 rm -rf $MOUNT/.lustre && error ".lustre is not allowed to be unlinked"
9957 touch $MOUNT/.lustre/file &&
9958 error "creation is not allowed under .lustre"
9960 mkdir $MOUNT/.lustre/dir &&
9961 error "mkdir is not allowed under .lustre"
9965 run_test 154a "Open-by-FID"
9968 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9969 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.51) ]] ||
9970 { skip "Need MDS version at least 2.2.51"; return 0; }
9972 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
9974 local remote_dir=$DIR/$tdir/remote_dir
9979 $LFS mkdir -i $MDTIDX $remote_dir ||
9980 error "create remote directory failed"
9982 cp /etc/hosts $remote_dir/$tfile
9984 fid=$($LFS path2fid $remote_dir/$tfile)
9986 [ $rc -ne 0 ] && error "error: could not get fid for $remote_dir/$tfile"
9988 dot_lustre_fid_permission_check "$fid" $remote_dir ||
9989 error "dot lustre permission check $fid failed"
9992 run_test 154b "Open-by-FID for remote directory"
9995 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.1) ]] &&
9996 skip "Need MDS version at least 2.4.1" && return
9998 touch $DIR/$tfile.1 $DIR/$tfile.2 $DIR/$tfile.3
9999 local FID1=$($LFS path2fid $DIR/$tfile.1)
10000 local FID2=$($LFS path2fid $DIR/$tfile.2)
10001 local FID3=$($LFS path2fid $DIR/$tfile.3)
10004 $LFS path2fid $DIR/$tfile.[123] | while read PATHNAME FID; do
10005 [ "$PATHNAME" = "$DIR/$tfile.$N:" ] ||
10006 error "path2fid pathname $PATHNAME != $DIR/$tfile.$N:"
10008 [ "$FID" = "${!want}" ] ||
10009 error "path2fid $PATHNAME FID $FID != FID$N ${!want}"
10013 $LFS fid2path $MOUNT "$FID1" "$FID2" "$FID3" | while read PATHNAME;
10015 [ "$PATHNAME" = "$DIR/$tfile.$N" ] ||
10016 error "fid2path pathname $PATHNAME != $DIR/$tfile.$N:"
10020 run_test 154c "lfs path2fid and fid2path multiple arguments"
10023 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.5.53) ]] &&
10024 skip "Need MDS version at least 2.5.53" && return
10026 if remote_mds; then
10027 nid=$($LCTL list_nids | sed "s/\./\\\./g")
10031 local proc_ofile="mdt.*.exports.'$nid'.open_files"
10038 local fid=$($LFS path2fid $DIR/$tfile)
10041 cmd="exec $fd<$DIR/$tfile"
10043 local fid_list=$(do_facet $SINGLEMDS $LCTL get_param $proc_ofile)
10044 echo "$fid_list" | grep "$fid"
10047 cmd="exec $fd>/dev/null"
10049 if [ $rc -ne 0 ]; then
10050 error "FID $fid not found in open files list $fid_list"
10053 run_test 154d "Verify open file fid"
10057 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.6.50) ]] &&
10058 skip "Need MDS version at least 2.6.50" && return
10060 if ls -a $MOUNT | grep -q '^\.lustre$'; then
10061 error ".lustre returned by readdir"
10064 run_test 154e ".lustre is not returned by readdir"
10067 # create parent directory on a single MDT to avoid cross-MDT hardlinks
10068 test_mkdir -p -c1 $DIR/$tdir/d
10069 # test dirs inherit from its stripe
10070 mkdir -p $DIR/$tdir/d/foo1 || error "mkdir error"
10071 mkdir -p $DIR/$tdir/d/foo2 || error "mkdir error"
10072 cp /etc/hosts $DIR/$tdir/d/foo1/$tfile
10073 ln $DIR/$tdir/d/foo1/$tfile $DIR/$tdir/d/foo2/link
10076 # get fid of parents
10077 local FID0=$($LFS path2fid $DIR/$tdir/d)
10078 local FID1=$($LFS path2fid $DIR/$tdir/d/foo1)
10079 local FID2=$($LFS path2fid $DIR/$tdir/d/foo2)
10080 local FID3=$($LFS path2fid $DIR)
10082 # check that path2fid --parents returns expected <parent_fid>/name
10083 # 1) test for a directory (single parent)
10084 local parent=$($LFS path2fid --parents $DIR/$tdir/d/foo1)
10085 [ "$parent" == "$FID0/foo1" ] ||
10086 error "expected parent: $FID0/foo1, got: $parent"
10088 # 2) test for a file with nlink > 1 (multiple parents)
10089 parent=$($LFS path2fid --parents $DIR/$tdir/d/foo1/$tfile)
10090 echo "$parent" | grep -F "$FID1/$tfile" ||
10091 error "$FID1/$tfile not returned in parent list"
10092 echo "$parent" | grep -F "$FID2/link" ||
10093 error "$FID2/link not returned in parent list"
10095 # 3) get parent by fid
10096 local file_fid=$($LFS path2fid $DIR/$tdir/d/foo1/$tfile)
10097 parent=$($LFS path2fid --parents $MOUNT/.lustre/fid/$file_fid)
10098 echo "$parent" | grep -F "$FID1/$tfile" ||
10099 error "$FID1/$tfile not returned in parent list (by fid)"
10100 echo "$parent" | grep -F "$FID2/link" ||
10101 error "$FID2/link not returned in parent list (by fid)"
10103 # 4) test for entry in root directory
10104 parent=$($LFS path2fid --parents $DIR/f)
10105 echo "$parent" | grep -F "$FID3/f" ||
10106 error "$FID3/f not returned in parent list"
10108 # 5) test it on root directory
10109 [ -z "$($LFS path2fid --parents $MOUNT 2>/dev/null)" ] ||
10110 error "$MOUNT should not have parents"
10112 # enable xattr caching and check that linkea is correctly updated
10113 local save="$TMP/$TESTSUITE-$TESTNAME.parameters"
10114 save_lustre_params client "llite.*.xattr_cache" > $save
10115 lctl set_param llite.*.xattr_cache 1
10117 # 6.1) linkea update on rename
10118 mv $DIR/$tdir/d/foo1/$tfile $DIR/$tdir/d/foo2/$tfile.moved
10120 # get parents by fid
10121 parent=$($LFS path2fid --parents $MOUNT/.lustre/fid/$file_fid)
10122 # foo1 should no longer be returned in parent list
10123 echo "$parent" | grep -F "$FID1" &&
10124 error "$FID1 should no longer be in parent list"
10125 # the new path should appear
10126 echo "$parent" | grep -F "$FID2/$tfile.moved" ||
10127 error "$FID2/$tfile.moved is not in parent list"
10129 # 6.2) linkea update on unlink
10130 rm -f $DIR/$tdir/d/foo2/link
10131 parent=$($LFS path2fid --parents $MOUNT/.lustre/fid/$file_fid)
10132 # foo2/link should no longer be returned in parent list
10133 echo "$parent" | grep -F "$FID2/link" &&
10134 error "$FID2/link should no longer be in parent list"
10138 restore_lustre_params < $save
10140 run_test 154f "get parent fids by reading link ea"
10144 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.6.92) ]] ||
10145 { skip "Need MDS version at least 2.6.92"; return 0; }
10147 mkdir -p $DIR/$tdir
10148 llapi_fid_test -d $DIR/$tdir
10150 run_test 154g "various llapi FID tests"
10152 test_155_small_load() {
10153 local temp=$TMP/$tfile
10154 local file=$DIR/$tfile
10156 dd if=/dev/urandom of=$temp bs=6096 count=1 || \
10157 error "dd of=$temp bs=6096 count=1 failed"
10159 cancel_lru_locks osc
10160 cmp $temp $file || error "$temp $file differ"
10162 $TRUNCATE $temp 6000
10163 $TRUNCATE $file 6000
10164 cmp $temp $file || error "$temp $file differ (truncate1)"
10166 echo "12345" >>$temp
10167 echo "12345" >>$file
10168 cmp $temp $file || error "$temp $file differ (append1)"
10170 echo "12345" >>$temp
10171 echo "12345" >>$file
10172 cmp $temp $file || error "$temp $file differ (append2)"
10178 test_155_big_load() {
10179 remote_ost_nodsh && skip "remote OST with nodsh" && return
10180 local temp=$TMP/$tfile
10181 local file=$DIR/$tfile
10184 local cache_size=$(do_facet ost$((MAXI+1)) \
10185 "awk '/cache/ {sum+=\\\$4} END {print sum}' /proc/cpuinfo")
10186 local large_file_size=$((cache_size * 2))
10188 echo "OSS cache size: $cache_size KB"
10189 echo "Large file size: $large_file_size KB"
10191 [ $MAXV -le $large_file_size ] && \
10192 skip_env "max available OST size needs > $large_file_size KB" && \
10195 $SETSTRIPE $file -c 1 -i $MAXI || error "$SETSTRIPE $file failed"
10197 dd if=/dev/urandom of=$temp bs=$large_file_size count=1k || \
10198 error "dd of=$temp bs=$large_file_size count=1k failed"
10201 cancel_lru_locks osc
10202 cmp $temp $file || error "$temp $file differ"
10209 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10211 set_cache writethrough on
10212 test_155_small_load
10214 run_test 155a "Verify small file correctness: read cache:on write_cache:on"
10217 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10219 set_cache writethrough off
10220 test_155_small_load
10222 run_test 155b "Verify small file correctness: read cache:on write_cache:off"
10225 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10227 set_cache writethrough on
10228 test_155_small_load
10230 run_test 155c "Verify small file correctness: read cache:off write_cache:on"
10233 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10235 set_cache writethrough off
10236 test_155_small_load
10238 run_test 155d "Verify small file correctness: read cache:off write_cache:off"
10241 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10243 set_cache writethrough on
10246 run_test 155e "Verify big file correctness: read cache:on write_cache:on"
10249 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10251 set_cache writethrough off
10254 run_test 155f "Verify big file correctness: read cache:on write_cache:off"
10257 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10259 set_cache writethrough on
10262 run_test 155g "Verify big file correctness: read cache:off write_cache:on"
10265 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10267 set_cache writethrough off
10270 run_test 155h "Verify big file correctness: read cache:off write_cache:off"
10273 remote_ost_nodsh && skip "remote OST with nodsh" && return
10274 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10278 local file="$DIR/$tfile"
10280 [ "$(facet_fstype ost1)" = "zfs" -a \
10281 $(lustre_version_code ost1 -lt $(version_code 2.6.93)) ] &&
10282 skip "LU-1956/LU-2261: stats not implemented on OSD ZFS" &&
10287 log "Turn on read and write cache"
10289 set_cache writethrough on
10291 log "Write data and read it back."
10292 log "Read should be satisfied from the cache."
10293 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
10295 cancel_lru_locks osc
10296 cat $file >/dev/null
10298 if ! let "AFTER - BEFORE == CPAGES"; then
10299 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
10301 log "cache hits:: before: $BEFORE, after: $AFTER"
10304 log "Read again; it should be satisfied from the cache."
10306 cancel_lru_locks osc
10307 cat $file >/dev/null
10309 if ! let "AFTER - BEFORE == CPAGES"; then
10310 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
10312 log "cache hits:: before: $BEFORE, after: $AFTER"
10315 log "Turn off the read cache and turn on the write cache"
10317 set_cache writethrough on
10319 log "Read again; it should be satisfied from the cache."
10321 cancel_lru_locks osc
10322 cat $file >/dev/null
10324 if ! let "AFTER - BEFORE == CPAGES"; then
10325 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
10327 log "cache hits:: before: $BEFORE, after: $AFTER"
10330 log "Read again; it should not be satisfied from the cache."
10332 cancel_lru_locks osc
10333 cat $file >/dev/null
10335 if ! let "AFTER - BEFORE == 0"; then
10336 error "IN CACHE: before: $BEFORE, after: $AFTER"
10338 log "cache hits:: before: $BEFORE, after: $AFTER"
10341 log "Write data and read it back."
10342 log "Read should be satisfied from the cache."
10343 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
10345 cancel_lru_locks osc
10346 cat $file >/dev/null
10348 if ! let "AFTER - BEFORE == CPAGES"; then
10349 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
10351 log "cache hits:: before: $BEFORE, after: $AFTER"
10354 log "Read again; it should not be satisfied from the cache."
10356 cancel_lru_locks osc
10357 cat $file >/dev/null
10359 if ! let "AFTER - BEFORE == 0"; then
10360 error "IN CACHE: before: $BEFORE, after: $AFTER"
10362 log "cache hits:: before: $BEFORE, after: $AFTER"
10365 log "Turn off read and write cache"
10367 set_cache writethrough off
10369 log "Write data and read it back"
10370 log "It should not be satisfied from the cache."
10372 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
10373 cancel_lru_locks osc
10375 cat $file >/dev/null
10377 if ! let "AFTER - BEFORE == 0"; then
10378 error_ignore bz20762 "IN CACHE: before: $BEFORE, after: $AFTER"
10380 log "cache hits:: before: $BEFORE, after: $AFTER"
10383 log "Turn on the read cache and turn off the write cache"
10385 set_cache writethrough off
10387 log "Write data and read it back"
10388 log "It should not be satisfied from the cache."
10390 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
10392 cancel_lru_locks osc
10393 cat $file >/dev/null
10395 if ! let "AFTER - BEFORE == 0"; then
10396 error_ignore bz20762 "IN CACHE: before: $BEFORE, after: $AFTER"
10398 log "cache hits:: before: $BEFORE, after: $AFTER"
10401 log "Read again; it should be satisfied from the cache."
10403 cancel_lru_locks osc
10404 cat $file >/dev/null
10406 if ! let "AFTER - BEFORE == CPAGES"; then
10407 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
10409 log "cache hits:: before: $BEFORE, after: $AFTER"
10414 run_test 156 "Verification of tunables"
10418 if [[ $MDSCOUNT -gt 1 ]]; then
10419 error_ignore bz17935 $*
10427 local CL_MASK_PARAM="mdd.$MDT0.changelog_mask"
10429 MASK=$(do_facet $SINGLEMDS $LCTL get_param $CL_MASK_PARAM| grep -c "$1")
10431 if [ $MASK -eq 1 ]; then
10432 do_facet $SINGLEMDS $LCTL set_param $CL_MASK_PARAM="-$1"
10434 do_facet $SINGLEMDS $LCTL set_param $CL_MASK_PARAM="+$1"
10438 changelog_extract_field() {
10442 local identifier=$4
10444 $LFS changelog $mdt | gawk "/$cltype.*$file$/ {
10445 print gensub(/^.* "$identifier'(\[[^\]]*\]).*$/,"\\1",1)}' |
10450 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10451 remote_mds_nodsh && skip "remote MDS with nodsh" && return
10452 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] ||
10453 { skip "Need MDS version at least 2.2.0"; return; }
10455 local CL_USERS="mdd.$MDT0.changelog_users"
10456 local GET_CL_USERS="do_facet $SINGLEMDS $LCTL get_param -n $CL_USERS"
10457 USER=$(do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_register -n)
10458 echo "Registered as changelog user $USER"
10459 $GET_CL_USERS | grep -q $USER ||
10460 error "User $USER not found in changelog_users"
10463 test_mkdir -p $DIR/$tdir/pics/2008/zachy
10464 touch $DIR/$tdir/pics/2008/zachy/timestamp
10465 cp /etc/hosts $DIR/$tdir/pics/2008/zachy/pic1.jpg
10466 mv $DIR/$tdir/pics/2008/zachy $DIR/$tdir/pics/zach
10467 ln $DIR/$tdir/pics/zach/pic1.jpg $DIR/$tdir/pics/2008/portland.jpg
10468 ln -s $DIR/$tdir/pics/2008/portland.jpg $DIR/$tdir/pics/desktop.jpg
10469 rm $DIR/$tdir/pics/desktop.jpg
10471 $LFS changelog $MDT0 | tail -5
10473 echo "verifying changelog mask"
10474 changelog_chmask "MKDIR"
10475 changelog_chmask "CLOSE"
10477 test_mkdir -p $DIR/$tdir/pics/zach/sofia
10478 echo "zzzzzz" > $DIR/$tdir/pics/zach/file
10480 changelog_chmask "MKDIR"
10481 changelog_chmask "CLOSE"
10483 test_mkdir -p $DIR/$tdir/pics/2008/sofia
10484 echo "zzzzzz" > $DIR/$tdir/pics/zach/file
10486 $LFS changelog $MDT0
10487 MKDIRS=$($LFS changelog $MDT0 | tail -5 | grep -c "MKDIR")
10488 CLOSES=$($LFS changelog $MDT0 | tail -5 | grep -c "CLOSE")
10489 [ $MKDIRS -eq 1 ] || err17935 "MKDIR changelog mask count $DIRS != 1"
10490 [ $CLOSES -eq 1 ] || err17935 "CLOSE changelog mask count $DIRS != 1"
10493 echo "verifying target fid"
10494 fidc=$(changelog_extract_field $MDT0 "CREAT" "timestamp" "t=")
10495 fidf=$($LFS path2fid $DIR/$tdir/pics/zach/timestamp)
10496 [ "$fidc" == "$fidf" ] ||
10497 err17935 "fid in changelog $fidc != file fid $fidf"
10498 echo "verifying parent fid"
10499 fidc=$(changelog_extract_field $MDT0 "CREAT" "timestamp" "p=")
10500 fidf=$($LFS path2fid $DIR/$tdir/pics/zach)
10501 [ "$fidc" == "$fidf" ] ||
10502 err17935 "pfid in changelog $fidc != dir fid $fidf"
10504 USER_REC1=$($GET_CL_USERS | awk "\$1 == \"$USER\" {print \$2}")
10505 $LFS changelog_clear $MDT0 $USER $(($USER_REC1 + 5))
10506 USER_REC2=$($GET_CL_USERS | awk "\$1 == \"$USER\" {print \$2}")
10507 echo "verifying user clear: $(( $USER_REC1 + 5 )) == $USER_REC2"
10508 [ $USER_REC2 == $(($USER_REC1 + 5)) ] ||
10509 err17935 "user index expected $(($USER_REC1 + 5)) is $USER_REC2"
10511 MIN_REC=$($GET_CL_USERS |
10512 awk 'min == "" || $2 < min {min = $2}; END {print min}')
10513 FIRST_REC=$($LFS changelog $MDT0 | head -n1 | awk '{print $1}')
10514 echo "verifying min purge: $(( $MIN_REC + 1 )) == $FIRST_REC"
10515 [ $FIRST_REC == $(($MIN_REC + 1)) ] ||
10516 err17935 "first index should be $(($MIN_REC + 1)) is $FIRST_REC"
10518 # LU-3446 changelog index reset on MDT restart
10519 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
10520 CUR_REC1=$($GET_CL_USERS | head -n1 | cut -f3 -d' ')
10521 $LFS changelog_clear $MDT0 $USER 0
10522 stop $SINGLEMDS || error "Fail to stop MDT."
10523 start $SINGLEMDS $MDT_DEV $MDS_MOUNT_OPTS || error "Fail to start MDT."
10524 CUR_REC2=$($GET_CL_USERS | head -n1 | cut -f3 -d' ')
10525 echo "verifying index survives MDT restart: $CUR_REC1 == $CUR_REC2"
10526 [ $CUR_REC1 == $CUR_REC2 ] ||
10527 err17935 "current index should be $CUR_REC1 is $CUR_REC2"
10529 echo "verifying user deregister"
10530 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister $USER
10531 $GET_CL_USERS | grep -q $USER &&
10532 error "User $USER still in changelog_users"
10534 USERS=$(( $($GET_CL_USERS | wc -l) - 2 ))
10535 if [ $USERS -eq 0 ]; then
10536 LAST_REC1=$($GET_CL_USERS | head -n1 | cut -f3 -d' ')
10537 touch $DIR/$tdir/chloe
10538 LAST_REC2=$($GET_CL_USERS | head -n1 | cut -f3 -d' ')
10539 echo "verify changelogs are off: $LAST_REC1 == $LAST_REC2"
10540 [ $LAST_REC1 == $LAST_REC2 ] || error "changelogs not off"
10542 echo "$USERS other changelog users; can't verify off"
10545 run_test 160a "changelog sanity"
10547 test_160b() { # LU-3587
10548 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10549 remote_mds_nodsh && skip "remote MDS with nodsh" && return
10550 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] ||
10551 { skip "Need MDS version at least 2.2.0"; return; }
10553 local CL_USERS="mdd.$MDT0.changelog_users"
10554 local GET_CL_USERS="do_facet $SINGLEMDS $LCTL get_param -n $CL_USERS"
10555 USER=$(do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_register -n)
10556 echo "Registered as changelog user $USER"
10557 $GET_CL_USERS | grep -q $USER ||
10558 error "User $USER not found in changelog_users"
10560 local LONGNAME1=$(str_repeat a 255)
10561 local LONGNAME2=$(str_repeat b 255)
10564 echo "creating very long named file"
10565 touch $LONGNAME1 || error "create of $LONGNAME1 failed"
10566 echo "moving very long named file"
10567 mv $LONGNAME1 $LONGNAME2
10569 $LFS changelog $MDT0 | grep RENME
10571 echo "deregistering $USER"
10572 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister $USER
10576 run_test 160b "Verify that very long rename doesn't crash in changelog"
10579 remote_mds_nodsh && skip "remote MDS with nodsh" && return
10582 local server_version=$(lustre_version_code $SINGLEMDS)
10584 [[ $server_version -gt $(version_code 2.5.57) ]] ||
10585 [[ $server_version -gt $(version_code 2.5.1) &&
10586 $server_version -lt $(version_code 2.5.50) ]] ||
10587 { skip "Need MDS version at least 2.5.58 or 2.5.2+"; return; }
10588 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10590 # Registration step
10591 local USER=$(do_facet $SINGLEMDS $LCTL --device $MDT0 \
10592 changelog_register -n)
10595 mkdir -p $DIR/$tdir
10596 $MCREATE $DIR/$tdir/foo_160c
10597 changelog_chmask "TRUNC"
10598 $TRUNCATE $DIR/$tdir/foo_160c 200
10599 changelog_chmask "TRUNC"
10600 $TRUNCATE $DIR/$tdir/foo_160c 199
10601 $LFS changelog $MDT0
10602 TRUNCS=$($LFS changelog $MDT0 | tail -5 | grep -c "TRUNC")
10603 [ $TRUNCS -eq 1 ] || err17935 "TRUNC changelog mask count $TRUNCS != 1"
10604 $LFS changelog_clear $MDT0 $USER 0
10606 # Deregistration step
10607 echo "deregistering $USER"
10608 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister $USER
10610 run_test 160c "verify that changelog log catch the truncate event"
10613 remote_mds_nodsh && skip "remote MDS with nodsh" && return
10614 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
10616 local server_version=$(lustre_version_code mds1)
10617 local CL_MASK_PARAM="mdd.$MDT0.changelog_mask"
10619 [[ $server_version -ge $(version_code 2.7.60) ]] ||
10620 { skip "Need MDS version at least 2.7.60+"; return; }
10621 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10623 # Registration step
10624 local USER=$(do_facet mds1 $LCTL --device $MDT0 \
10625 changelog_register -n)
10627 mkdir -p $DIR/$tdir/migrate_dir
10628 $LFS changelog_clear $MDT0 $USER 0
10630 $LFS migrate -m 1 $DIR/$tdir/migrate_dir || error "migrate fails"
10631 $LFS changelog $MDT0
10632 MIGRATES=$($LFS changelog $MDT0 | tail -5 | grep -c "MIGRT")
10633 $LFS changelog_clear $MDT0 $USER 0
10634 [ $MIGRATES -eq 1 ] ||
10635 error "MIGRATE changelog mask count $MIGRATES != 1"
10637 # Deregistration step
10638 do_facet mds1 $LCTL --device $MDT0 changelog_deregister $USER
10640 run_test 160d "verify that changelog log catch the migrate event"
10643 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10644 test_mkdir -p -c1 $DIR/$tdir
10645 cp /etc/hosts $DIR/$tdir/$tfile
10646 test_mkdir -c1 $DIR/$tdir/foo1
10647 test_mkdir -c1 $DIR/$tdir/foo2
10648 ln $DIR/$tdir/$tfile $DIR/$tdir/foo1/sofia
10649 ln $DIR/$tdir/$tfile $DIR/$tdir/foo2/zachary
10650 ln $DIR/$tdir/$tfile $DIR/$tdir/foo1/luna
10651 ln $DIR/$tdir/$tfile $DIR/$tdir/foo2/thor
10652 local FID=$($LFS path2fid $DIR/$tdir/$tfile | tr -d '[]')
10653 if [ "$($LFS fid2path $DIR $FID | wc -l)" != "5" ]; then
10654 $LFS fid2path $DIR $FID
10655 err17935 "bad link ea"
10658 rm $DIR/$tdir/foo2/zachary
10660 rm $DIR/$tdir/foo2/thor
10662 rm $DIR/$tdir/$tfile
10664 mv $DIR/$tdir/foo1/sofia $DIR/$tdir/foo2/maggie
10665 if [ "$($LFS fid2path $FSNAME --link 1 $FID)" != "$tdir/foo2/maggie" ]
10667 $LFS fid2path $DIR $FID
10668 err17935 "bad link rename"
10670 rm $DIR/$tdir/foo2/maggie
10673 local longname=filename_avg_len_is_thirty_two_
10674 createmany -l$DIR/$tdir/foo1/luna $DIR/$tdir/foo2/$longname 1000 ||
10675 error "failed to hardlink many files"
10676 links=$($LFS fid2path $DIR $FID | wc -l)
10677 echo -n "${links}/1000 links in link EA"
10678 [[ $links -gt 60 ]] ||
10679 err17935 "expected at least 60 links in link EA"
10680 unlinkmany $DIR/$tdir/foo2/$longname 1000 ||
10681 error "failed to unlink many hardlinks"
10683 run_test 161a "link ea sanity"
10686 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10687 [ $MDSCOUNT -lt 2 ] &&
10688 skip "skipping remote directory test" && return
10690 local remote_dir=$DIR/$tdir/remote_dir
10692 mkdir -p $DIR/$tdir
10693 $LFS mkdir -i $MDTIDX $remote_dir ||
10694 error "create remote directory failed"
10696 cp /etc/hosts $remote_dir/$tfile
10697 mkdir -p $remote_dir/foo1
10698 mkdir -p $remote_dir/foo2
10699 ln $remote_dir/$tfile $remote_dir/foo1/sofia
10700 ln $remote_dir/$tfile $remote_dir/foo2/zachary
10701 ln $remote_dir/$tfile $remote_dir/foo1/luna
10702 ln $remote_dir/$tfile $remote_dir/foo2/thor
10704 local FID=$($LFS path2fid $remote_dir/$tfile | tr -d '[' |
10706 if [ "$($LFS fid2path $DIR $FID | wc -l)" != "5" ]; then
10707 $LFS fid2path $DIR $FID
10708 err17935 "bad link ea"
10711 rm $remote_dir/foo2/zachary
10713 rm $remote_dir/foo2/thor
10715 rm $remote_dir/$tfile
10717 mv $remote_dir/foo1/sofia $remote_dir/foo2/maggie
10718 local link_path=$($LFS fid2path $FSNAME --link 1 $FID)
10719 if [ "$DIR/$link_path" != "$remote_dir/foo2/maggie" ]; then
10720 $LFS fid2path $DIR $FID
10721 err17935 "bad link rename"
10723 rm $remote_dir/foo2/maggie
10726 local longname=filename_avg_len_is_thirty_two_
10727 createmany -l$remote_dir/foo1/luna $remote_dir/foo2/$longname 1000 ||
10728 error "failed to hardlink many files"
10729 links=$($LFS fid2path $DIR $FID | wc -l)
10730 echo -n "${links}/1000 links in link EA"
10731 [[ ${links} -gt 60 ]] ||
10732 err17935 "expected at least 60 links in link EA"
10733 unlinkmany $remote_dir/foo2/$longname 1000 ||
10734 error "failed to unlink many hardlinks"
10736 run_test 161b "link ea sanity under remote directory"
10739 remote_mds_nodsh && skip "remote MDS with nodsh" && return
10740 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10741 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.1.5) ]] &&
10742 skip "Need MDS version at least 2.1.5" && return
10744 # define CLF_RENAME_LAST 0x0001
10745 # rename overwrite a target having nlink = 1 (changelog flag 0x1)
10746 local USER=$(do_facet $SINGLEMDS $LCTL --device $MDT0 \
10747 changelog_register -n)
10749 mkdir -p $DIR/$tdir
10750 touch $DIR/$tdir/foo_161c
10751 touch $DIR/$tdir/bar_161c
10752 mv -f $DIR/$tdir/foo_161c $DIR/$tdir/bar_161c
10753 $LFS changelog $MDT0 | grep RENME
10754 local flags=$($LFS changelog $MDT0 | grep RENME | tail -1 | \
10756 $LFS changelog_clear $MDT0 $USER 0
10757 if [ x$flags != "x0x1" ]; then
10758 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister \
10760 error "flag $flags is not 0x1"
10762 echo "rename overwrite a target having nlink = 1," \
10763 "changelog record has flags of $flags"
10765 # rename overwrite a target having nlink > 1 (changelog flag 0x0)
10766 touch $DIR/$tdir/foo_161c
10767 touch $DIR/$tdir/bar_161c
10768 ln $DIR/$tdir/bar_161c $DIR/$tdir/foobar_161c
10769 mv -f $DIR/$tdir/foo_161c $DIR/$tdir/bar_161c
10770 $LFS changelog $MDT0 | grep RENME
10771 flags=$($LFS changelog $MDT0 | grep RENME | tail -1 | cut -f5 -d' ')
10772 $LFS changelog_clear $MDT0 $USER 0
10773 if [ x$flags != "x0x0" ]; then
10774 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister \
10776 error "flag $flags is not 0x0"
10778 echo "rename overwrite a target having nlink > 1," \
10779 "changelog record has flags of $flags"
10781 # rename doesn't overwrite a target (changelog flag 0x0)
10782 touch $DIR/$tdir/foo_161c
10783 mv -f $DIR/$tdir/foo_161c $DIR/$tdir/foo2_161c
10784 $LFS changelog $MDT0 | grep RENME
10785 flags=$($LFS changelog $MDT0 | grep RENME | tail -1 | cut -f5 -d' ')
10786 $LFS changelog_clear $MDT0 $USER 0
10787 if [ x$flags != "x0x0" ]; then
10788 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister \
10790 error "flag $flags is not 0x0"
10792 echo "rename doesn't overwrite a target," \
10793 "changelog record has flags of $flags"
10795 # define CLF_UNLINK_LAST 0x0001
10796 # unlink a file having nlink = 1 (changelog flag 0x1)
10797 rm -f $DIR/$tdir/foo2_161c
10798 $LFS changelog $MDT0 | grep UNLNK
10799 flags=$($LFS changelog $MDT0 | grep UNLNK | tail -1 | cut -f5 -d' ')
10800 $LFS changelog_clear $MDT0 $USER 0
10801 if [ x$flags != "x0x1" ]; then
10802 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister \
10804 error "flag $flags is not 0x1"
10806 echo "unlink a file having nlink = 1," \
10807 "changelog record has flags of $flags"
10809 # unlink a file having nlink > 1 (changelog flag 0x0)
10810 ln -f $DIR/$tdir/bar_161c $DIR/$tdir/foobar_161c
10811 rm -f $DIR/$tdir/foobar_161c
10812 $LFS changelog $MDT0 | grep UNLNK
10813 flags=$($LFS changelog $MDT0 | grep UNLNK | tail -1 | cut -f5 -d' ')
10814 $LFS changelog_clear $MDT0 $USER 0
10815 if [ x$flags != "x0x0" ]; then
10816 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister \
10818 error "flag $flags is not 0x0"
10820 echo "unlink a file having nlink > 1," \
10821 "changelog record has flags of $flags"
10822 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister $USER
10824 run_test 161c "check CL_RENME[UNLINK] changelog record flags"
10831 local path=$(${LFS} fid2path $*)
10832 # Remove the '//' indicating a remote directory
10833 path=$(echo $path | sed 's#//#/#g')
10836 if [ $RC -ne 0 ]; then
10837 err17935 "path looked up of $expected failed. Error $RC"
10839 elif [ "${path}" != "${expected}" ]; then
10840 err17935 "path looked up \"${path}\" instead of \"${expected}\""
10843 echo "fid $fid resolves to path $path (expected $expected)"
10846 test_162a() { # was test_162
10847 # Make changes to filesystem
10848 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10849 test_mkdir -p -c1 $DIR/$tdir/d2
10850 touch $DIR/$tdir/d2/$tfile
10851 touch $DIR/$tdir/d2/x1
10852 touch $DIR/$tdir/d2/x2
10853 test_mkdir -p -c1 $DIR/$tdir/d2/a/b/c
10854 test_mkdir -p -c1 $DIR/$tdir/d2/p/q/r
10856 FID=$($LFS path2fid $DIR/$tdir/d2/$tfile | tr -d '[]')
10857 check_path "$tdir/d2/$tfile" $FSNAME $FID --link 0 ||
10858 error "check path $tdir/d2/$tfile failed"
10861 ln -s $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/p/q/r/slink
10862 FID=$($LFS path2fid $DIR/$tdir/d2/p/q/r/slink | tr -d '[]')
10863 check_path "$tdir/d2/p/q/r/slink" $FSNAME $FID --link 0 ||
10864 error "check path $tdir/d2/p/q/r/slink failed"
10866 # softlink to wrong file
10867 ln -s /this/is/garbage $DIR/$tdir/d2/p/q/r/slink.wrong
10868 FID=$($LFS path2fid $DIR/$tdir/d2/p/q/r/slink.wrong | tr -d '[]')
10869 check_path "$tdir/d2/p/q/r/slink.wrong" $FSNAME $FID --link 0 ||
10870 error "check path $tdir/d2/p/q/r/slink.wrong failed"
10873 ln $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/p/q/r/hlink
10874 mv $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/a/b/c/new_file
10875 FID=$($LFS path2fid $DIR/$tdir/d2/a/b/c/new_file | tr -d '[]')
10876 # fid2path dir/fsname should both work
10877 check_path "$tdir/d2/a/b/c/new_file" $FSNAME $FID --link 1 ||
10878 error "check path $tdir/d2/a/b/c/new_file failed"
10879 check_path "$DIR/$tdir/d2/p/q/r/hlink" $DIR $FID --link 0 ||
10880 error "check path $DIR/$tdir/d2/p/q/r/hlink failed"
10882 # hardlink count: check that there are 2 links
10883 # Doesnt work with CMD yet: 17935
10884 ${LFS} fid2path $DIR $FID | wc -l | grep -q 2 || \
10885 err17935 "expected 2 links"
10887 # hardlink indexing: remove the first link
10888 rm $DIR/$tdir/d2/p/q/r/hlink
10889 check_path "$tdir/d2/a/b/c/new_file" $FSNAME $FID --link 0 ||
10890 error "check path $DIR/$tdir/d2/a/b/c/new_file failed"
10894 run_test 162a "path lookup sanity"
10897 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10898 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
10901 $LFS setdirstripe -i0 -c$MDSCOUNT -t all_char $DIR/$tdir/striped_dir ||
10902 error "create striped dir failed"
10904 local FID=$($LFS getdirstripe $DIR/$tdir/striped_dir |
10905 tail -n 1 | awk '{print $2}')
10906 stat $MOUNT/.lustre/fid/$FID && error "sub_stripe can be accessed"
10908 touch $DIR/$tdir/striped_dir/f{0..4} || error "touch f0..4 failed"
10909 mkdir $DIR/$tdir/striped_dir/d{0..4} || error "mkdir d0..4 failed"
10912 for ((i=0;i<5;i++)); do
10913 FID=$($LFS path2fid $DIR/$tdir/striped_dir/f$i | tr -d '[]') ||
10914 error "get fid for f$i failed"
10915 check_path "$tdir/striped_dir/f$i" $FSNAME $FID --link 0 ||
10916 error "check path $tdir/striped_dir/f$i failed"
10918 FID=$($LFS path2fid $DIR/$tdir/striped_dir/d$i | tr -d '[]') ||
10919 error "get fid for d$i failed"
10920 check_path "$tdir/striped_dir/d$i" $FSNAME $FID --link 0 ||
10921 error "check path $tdir/striped_dir/d$i failed"
10926 run_test 162b "striped directory path lookup sanity"
10928 # LU-4239: Verify fid2path works with paths 100 or more directories deep
10930 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.51) ]] &&
10931 skip "Need MDS version at least 2.7.51" && return
10932 test_mkdir $DIR/$tdir.local
10933 test_mkdir $DIR/$tdir.remote
10934 local lpath=$tdir.local
10935 local rpath=$tdir.remote
10937 for ((i = 0; i <= 101; i++)); do
10940 FID=$($LFS path2fid $DIR/$lpath | tr -d '[]') ||
10941 error "get fid for local directory $DIR/$lpath failed"
10942 check_path "$DIR/$lpath" $MOUNT $FID --link 0 ||
10943 error "check path for local directory $DIR/$lpath failed"
10946 test_mkdir $DIR/$rpath
10947 FID=$($LFS path2fid $DIR/$rpath | tr -d '[]') ||
10948 error "get fid for remote directory $DIR/$rpath failed"
10949 check_path "$DIR/$rpath" $MOUNT $FID --link 0 ||
10950 error "check path for remote directory $DIR/$rpath failed"
10955 run_test 162c "fid2path works with paths 100 or more directories deep"
10958 # do directio so as not to populate the page cache
10959 log "creating a 10 Mb file"
10960 $MULTIOP $DIR/$tfile oO_CREAT:O_DIRECT:O_RDWR:w$((10*1048576))c || error "multiop failed while creating a file"
10961 log "starting reads"
10962 dd if=$DIR/$tfile of=/dev/null bs=4096 &
10963 log "truncating the file"
10964 $MULTIOP $DIR/$tfile oO_TRUNC:c || error "multiop failed while truncating the file"
10966 kill %+ || true # reads might have finished
10967 echo "wait until dd is finished"
10969 log "removing the temporary file"
10970 rm -rf $DIR/$tfile || error "tmp file removal failed"
10972 run_test 169 "parallel read and truncate should not deadlock"
10975 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10976 $LCTL clear # bug 18514
10977 $LCTL debug_daemon start $TMP/${tfile}_log_good
10979 $LCTL debug_daemon stop
10980 sed -e "s/^...../a/g" $TMP/${tfile}_log_good > $TMP/${tfile}_log_bad ||
10981 error "sed failed to read log_good"
10983 $LCTL debug_daemon start $TMP/${tfile}_log_good
10985 $LCTL debug_daemon stop
10987 $LCTL df $TMP/${tfile}_log_bad > $TMP/${tfile}_log_bad.out 2>&1 ||
10988 error "lctl df log_bad failed"
10990 local bad_line=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $9}')
10991 local good_line1=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $5}')
10993 $LCTL df $TMP/${tfile}_log_good > $TMP/${tfile}_log_good.out 2>&1
10994 local good_line2=$(tail -n 1 $TMP/${tfile}_log_good.out | awk '{print $5}')
10996 [ "$bad_line" ] && [ "$good_line1" ] && [ "$good_line2" ] ||
10997 error "bad_line good_line1 good_line2 are empty"
10999 cat $TMP/${tfile}_log_good >> $TMP/${tfile}_logs_corrupt
11000 cat $TMP/${tfile}_log_bad >> $TMP/${tfile}_logs_corrupt
11001 cat $TMP/${tfile}_log_good >> $TMP/${tfile}_logs_corrupt
11003 $LCTL df $TMP/${tfile}_logs_corrupt > $TMP/${tfile}_log_bad.out 2>&1
11004 local bad_line_new=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $9}')
11005 local good_line_new=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $5}')
11007 [ "$bad_line_new" ] && [ "$good_line_new" ] ||
11008 error "bad_line_new good_line_new are empty"
11010 local expected_good=$((good_line1 + good_line2*2))
11012 rm -f $TMP/${tfile}*
11013 # LU-231, short malformed line may not be counted into bad lines
11014 if [ $bad_line -ne $bad_line_new ] &&
11015 [ $bad_line -ne $((bad_line_new - 1)) ]; then
11016 error "expected $bad_line bad lines, but got $bad_line_new"
11020 if [ $expected_good -ne $good_line_new ]; then
11021 error "expected $expected_good good lines, but got $good_line_new"
11026 run_test 170 "test lctl df to handle corrupted log ====================="
11028 test_171() { # bug20592
11029 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11030 #define OBD_FAIL_PTLRPC_DUMP_LOG 0x50e
11031 $LCTL set_param fail_loc=0x50e
11032 $LCTL set_param fail_val=3000
11033 multiop_bg_pause $DIR/$tfile O_s || true
11035 kill -USR1 $MULTIPID
11039 if dmesg | grep "recursive fault"; then
11040 error "caught a recursive fault"
11042 $LCTL set_param fail_loc=0
11045 run_test 171 "test libcfs_debug_dumplog_thread stuck in do_exit() ======"
11047 # it would be good to share it with obdfilter-survey/iokit-libecho code
11048 setup_obdecho_osc () {
11051 local obdfilter_name=$2
11052 echo "Creating new osc for $obdfilter_name on $ost_nid"
11053 # make sure we can find loopback nid
11054 $LCTL add_uuid $ost_nid $ost_nid >/dev/null 2>&1
11056 [ $rc -eq 0 ] && { $LCTL attach osc ${obdfilter_name}_osc \
11057 ${obdfilter_name}_osc_UUID || rc=2; }
11058 [ $rc -eq 0 ] && { $LCTL --device ${obdfilter_name}_osc setup \
11059 ${obdfilter_name}_UUID $ost_nid || rc=3; }
11063 cleanup_obdecho_osc () {
11064 local obdfilter_name=$1
11065 $LCTL --device ${obdfilter_name}_osc cleanup >/dev/null
11066 $LCTL --device ${obdfilter_name}_osc detach >/dev/null
11073 local pages=${3:-64}
11078 local obd_size=$(get_obd_size $node $OBD)
11079 local page_size=$(get_page_size $node)
11080 if [[ -n "$obd_size" ]]; then
11081 local new_count=$((obd_size / (pages * page_size / 1024)))
11082 [[ $new_count -ge $count ]] || count=$new_count
11085 do_facet $node "$LCTL attach echo_client ec ec_uuid" || rc=1
11086 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec setup $OBD" ||
11088 if [ $rc -eq 0 ]; then
11089 id=$(do_facet $node "$LCTL --device ec create 1" | awk '/object id/ {print $6}')
11090 [ ${PIPESTATUS[0]} -eq 0 -a -n "$id" ] || rc=3
11092 echo "New object id is $id"
11093 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec getattr $id" ||
11095 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec " \
11096 "test_brw $count w v $pages $id" || rc=4; }
11097 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec destroy $id 1" ||
11099 [ $rc -eq 0 -o $rc -gt 2 ] && { do_facet $node "$LCTL --device ec " \
11100 "cleanup" || rc=5; }
11101 [ $rc -eq 0 -o $rc -gt 1 ] && { do_facet $node "$LCTL --device ec " \
11102 "detach" || rc=6; }
11103 [ $rc -ne 0 ] && echo "obecho_create_test failed: $rc"
11108 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11109 remote_ost_nodsh && skip "remote OST with nodsh" && return
11111 local rmmod_local=0
11113 if ! module_loaded obdecho; then
11114 load_module obdecho/obdecho
11118 local osc=$($LCTL dl | grep -v mdt | awk '$3 == "osc" {print $4; exit}')
11119 local host=$(lctl get_param -n osc.$osc.import |
11120 awk '/current_connection:/ {print $2}' )
11121 local target=$(lctl get_param -n osc.$osc.import |
11122 awk '/target:/ {print $2}' )
11123 target=${target%_UUID}
11125 [[ -n $target ]] && { setup_obdecho_osc $host $target || rc=1; } || rc=1
11126 [ $rc -eq 0 ] && { obdecho_test ${target}_osc client || rc=2; }
11127 [[ -n $target ]] && cleanup_obdecho_osc $target
11128 [ $rmmod_local -eq 1 ] && rmmod obdecho
11131 run_test 180a "test obdecho on osc"
11134 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11135 remote_ost_nodsh && skip "remote OST with nodsh" && return
11137 local rmmod_remote=0
11139 do_facet ost1 "lsmod | grep -q obdecho || " \
11140 "{ insmod ${LUSTRE}/obdecho/obdecho.ko || " \
11141 "modprobe obdecho; }" && rmmod_remote=1
11142 target=$(do_facet ost1 $LCTL dl | awk '/obdfilter/ {print $4;exit}')
11143 [[ -n $target ]] && { obdecho_test $target ost1 || rc=1; }
11144 [ $rmmod_remote -eq 1 ] && do_facet ost1 "rmmod obdecho"
11147 run_test 180b "test obdecho directly on obdfilter"
11149 test_180c() { # LU-2598
11150 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11151 remote_ost_nodsh && skip "remote OST with nodsh" && return
11152 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.0) ]] &&
11153 skip "Need MDS version at least 2.4.0" && return
11156 local rmmod_remote=false
11157 local pages=16384 # 64MB bulk I/O RPC size
11160 do_rpc_nodes $(facet_active_host ost1) load_module obdecho/obdecho &&
11161 rmmod_remote=true || error "failed to load module obdecho"
11163 target=$(do_facet ost1 $LCTL dl | awk '/obdfilter/ { print $4 }' |
11165 if [ -n "$target" ]; then
11166 obdecho_test "$target" ost1 "$pages" || rc=${PIPESTATUS[0]}
11168 echo "there is no obdfilter target on ost1"
11171 $rmmod_remote && do_facet ost1 "rmmod obdecho" || true
11174 run_test 180c "test huge bulk I/O size on obdfilter, don't LASSERT"
11176 test_181() { # bug 22177
11177 test_mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
11178 # create enough files to index the directory
11179 createmany -o $DIR/$tdir/foobar 4000
11180 # print attributes for debug purpose
11183 multiop_bg_pause $DIR/$tdir D_Sc || return 1
11185 # remove the files & current working dir
11186 unlinkmany $DIR/$tdir/foobar 4000
11188 kill -USR1 $MULTIPID
11190 stat $DIR/$tdir && error "open-unlinked dir was not removed!"
11193 run_test 181 "Test open-unlinked dir ========================"
11199 mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
11201 $LCTL set_param mdc.*.rpc_stats=clear
11203 for (( i = 0; i < $tcount; i++ )) ; do
11204 mkdir $DIR/$tdir/$i
11207 for (( i = 0; i < $tcount; i++ )) ; do
11208 createmany -o $DIR/$tdir/$i/f- $fcount &
11212 for (( i = 0; i < $tcount; i++ )) ; do
11213 unlinkmany $DIR/$tdir/$i/f- $fcount &
11217 $LCTL get_param mdc.*.rpc_stats
11221 run_test 182 "Test parallel modify metadata operations ================"
11223 test_183() { # LU-2275
11224 remote_mds_nodsh && skip "remote MDS with nodsh" && return
11225 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.3.56) ]] &&
11226 skip "Need MDS version at least 2.3.56" && return
11228 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11229 mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
11230 echo aaa > $DIR/$tdir/$tfile
11232 #define OBD_FAIL_MDS_NEGATIVE_POSITIVE 0x148
11233 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x148
11235 ls -l $DIR/$tdir && error "ls succeeded, should have failed"
11236 cat $DIR/$tdir/$tfile && error "cat succeeded, should have failed"
11238 do_facet $SINGLEMDS $LCTL set_param fail_loc=0
11240 # Flush negative dentry cache
11241 touch $DIR/$tdir/$tfile
11243 # We are not checking for any leaked references here, they'll
11244 # become evident next time we do cleanup with module unload.
11247 run_test 183 "No crash or request leak in case of strange dispositions ========"
11249 # test suite 184 is for LU-2016, LU-2017
11251 check_swap_layouts_support && return 0
11253 dir0=$DIR/$tdir/$testnum
11254 test_mkdir -p -c1 $dir0 || error "creating dir $dir0"
11259 $SETSTRIPE -c1 $file1
11261 $SETSTRIPE -c2 $file2
11263 gen1=$($GETSTRIPE -g $file1)
11264 gen2=$($GETSTRIPE -g $file2)
11266 $LFS swap_layouts $file1 $file2 || error "swap of file layout failed"
11267 gen=$($GETSTRIPE -g $file1)
11268 [[ $gen1 != $gen ]] ||
11269 "Layout generation on $file1 does not change"
11270 gen=$($GETSTRIPE -g $file2)
11271 [[ $gen2 != $gen ]] ||
11272 "Layout generation on $file2 does not change"
11274 cmp $ref1 $file2 || error "content compare failed ($ref1 != $file2)"
11275 cmp $ref2 $file1 || error "content compare failed ($ref2 != $file1)"
11277 run_test 184a "Basic layout swap"
11280 check_swap_layouts_support && return 0
11282 dir0=$DIR/$tdir/$testnum
11283 mkdir -p $dir0 || error "creating dir $dir0"
11290 $SETSTRIPE -c1 $file1
11291 $SETSTRIPE -c2 $file2
11292 $SETSTRIPE -c1 $file3
11293 chown $RUNAS_ID $file3
11294 gen1=$($GETSTRIPE -g $file1)
11295 gen2=$($GETSTRIPE -g $file2)
11297 $LFS swap_layouts $dir1 $dir2 &&
11298 error "swap of directories layouts should fail"
11299 $LFS swap_layouts $dir1 $file1 &&
11300 error "swap of directory and file layouts should fail"
11301 $RUNAS $LFS swap_layouts $file1 $file2 &&
11302 error "swap of file we cannot write should fail"
11303 $LFS swap_layouts $file1 $file3 &&
11304 error "swap of file with different owner should fail"
11305 /bin/true # to clear error code
11307 run_test 184b "Forbidden layout swap (will generate errors)"
11310 check_swap_layouts_support && return 0
11312 local dir0=$DIR/$tdir/$testnum
11313 mkdir -p $dir0 || error "creating dir $dir0"
11315 local ref1=$dir0/ref1
11316 local ref2=$dir0/ref2
11317 local file1=$dir0/file1
11318 local file2=$dir0/file2
11319 # create a file large enough for the concurrent test
11320 dd if=/dev/urandom of=$ref1 bs=1M count=$((RANDOM % 50 + 20))
11321 dd if=/dev/urandom of=$ref2 bs=1M count=$((RANDOM % 50 + 20))
11322 echo "ref file size: ref1($(stat -c %s $ref1))," \
11323 "ref2($(stat -c %s $ref2))"
11326 dd if=$ref1 of=$file1 bs=16k &
11329 # Make sure dd starts to copy file
11330 while [ ! -f $file1 ]; do sleep 0.1; done
11332 $LFS swap_layouts $file1 $file2
11335 [[ $? == 0 ]] || error "concurrent write on $file1 failed"
11336 [[ $rc == 0 ]] || error "swap of $file1 and $file2 failed"
11338 # how many bytes copied before swapping layout
11339 local copied=$(stat -c %s $file2)
11340 local remaining=$(stat -c %s $ref1)
11341 remaining=$((remaining - copied))
11342 echo "Copied $copied bytes before swapping layout..."
11344 cmp -n $copied $file1 $ref2 | grep differ &&
11345 error "Content mismatch [0, $copied) of ref2 and file1"
11346 cmp -n $copied $file2 $ref1 ||
11347 error "Content mismatch [0, $copied) of ref1 and file2"
11348 cmp -i $copied:$copied -n $remaining $file1 $ref1 ||
11349 error "Content mismatch [$copied, EOF) of ref1 and file1"
11352 rm -f $ref1 $ref2 $file1 $file2
11354 run_test 184c "Concurrent write and layout swap"
11357 check_swap_layouts_support && return 0
11358 [ -z "$(which getfattr 2>/dev/null)" ] &&
11359 skip "no getfattr command" && return 0
11361 local file1=$DIR/$tdir/$tfile-1
11362 local file2=$DIR/$tdir/$tfile-2
11363 local file3=$DIR/$tdir/$tfile-3
11367 mkdir -p $DIR/$tdir
11368 touch $file1 || error "create $file1 failed"
11369 $OPENFILE -f O_CREAT:O_LOV_DELAY_CREATE $file2 ||
11370 error "create $file2 failed"
11371 $OPENFILE -f O_CREAT:O_LOV_DELAY_CREATE $file3 ||
11372 error "create $file3 failed"
11373 lovea1=$($LFS getstripe $file1 | sed 1d)
11375 $LFS swap_layouts $file2 $file3 ||
11376 error "swap $file2 $file3 layouts failed"
11377 $LFS swap_layouts $file1 $file2 ||
11378 error "swap $file1 $file2 layouts failed"
11380 lovea2=$($LFS getstripe $file2 | sed 1d)
11381 [ "$lovea1" == "$lovea2" ] || error "lovea $lovea1 != $lovea2"
11383 lovea1=$(getfattr -n trusted.lov $file1 | grep ^trusted)
11384 [[ -z "$lovea1" ]] || error "$file1 shouldn't have lovea"
11386 run_test 184d "allow stripeless layouts swap"
11389 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.6.94) ]] ||
11390 { skip "Need MDS version at least 2.6.94"; return 0; }
11391 check_swap_layouts_support && return 0
11392 [ -z "$(which getfattr 2>/dev/null)" ] &&
11393 skip "no getfattr command" && return 0
11395 local file1=$DIR/$tdir/$tfile-1
11396 local file2=$DIR/$tdir/$tfile-2
11397 local file3=$DIR/$tdir/$tfile-3
11400 mkdir -p $DIR/$tdir
11401 touch $file1 || error "create $file1 failed"
11402 $OPENFILE -f O_CREAT:O_LOV_DELAY_CREATE $file2 ||
11403 error "create $file2 failed"
11404 $OPENFILE -f O_CREAT:O_LOV_DELAY_CREATE $file3 ||
11405 error "create $file3 failed"
11407 $LFS swap_layouts $file1 $file2 ||
11408 error "swap $file1 $file2 layouts failed"
11410 lovea=$(getfattr -n trusted.lov $file1 | grep ^trusted)
11411 [[ -z "$lovea" ]] || error "$file1 shouldn't have lovea"
11413 echo 123 > $file1 || error "Should be able to write into $file1"
11415 $LFS swap_layouts $file1 $file3 ||
11416 error "swap $file1 $file3 layouts failed"
11418 echo 123 > $file1 || error "Should be able to write into $file1"
11420 rm -rf $file1 $file2 $file3
11422 run_test 184e "Recreate layout after stripeless layout swaps"
11424 test_185() { # LU-2441
11425 # LU-3553 - no volatile file support in old servers
11426 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.3.60) ]] ||
11427 { skip "Need MDS version at least 2.3.60"; return 0; }
11429 mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
11430 touch $DIR/$tdir/spoo
11431 local mtime1=$(stat -c "%Y" $DIR/$tdir)
11432 local fid=$($MULTIOP $DIR/$tdir VFw4096c) ||
11433 error "cannot create/write a volatile file"
11434 $CHECKSTAT -t file $MOUNT/.lustre/fid/$fid 2>/dev/null &&
11435 error "FID is still valid after close"
11437 multiop_bg_pause $DIR/$tdir vVw4096_c
11444 # assume that the next FID for this client is sequential, since stdout
11445 # is unfortunately eaten by multiop_bg_pause
11446 local n=$((${fidv[1]} + 1))
11447 local next_fid="${fidv[0]}:$(printf "0x%x" $n):${fidv[2]}"
11448 $CHECKSTAT -t file $MOUNT/.lustre/fid/$next_fid ||
11449 error "FID is missing before close"
11450 kill -USR1 $multi_pid
11451 # 1 second delay, so if mtime change we will see it
11453 local mtime2=$(stat -c "%Y" $DIR/$tdir)
11454 [[ $mtime1 == $mtime2 ]] || error "mtime has changed"
11456 run_test 185 "Volatile file support"
11459 remote_mds_nodsh && skip "remote MDS with nodsh" && return
11460 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.3.0) ] &&
11461 skip "Need MDS version at least 2.3.0" && return
11463 local dir0=$DIR/$tdir/$testnum
11464 mkdir -p $dir0 || error "creating dir $dir0"
11466 local file=$dir0/file1
11467 dd if=/dev/urandom of=$file count=10 bs=1M conv=fsync
11468 local dv1=$($LFS data_version $file)
11469 dd if=/dev/urandom of=$file seek=10 count=1 bs=1M conv=fsync
11470 local dv2=$($LFS data_version $file)
11471 [[ $dv1 != $dv2 ]] ||
11472 error "data version did not change on write $dv1 == $dv2"
11477 run_test 187a "Test data version change"
11480 remote_mds_nodsh && skip "remote MDS with nodsh" && return
11481 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.3.0) ] &&
11482 skip "Need MDS version at least 2.3.0" && return
11484 local dir0=$DIR/$tdir/$testnum
11485 mkdir -p $dir0 || error "creating dir $dir0"
11487 declare -a DV=$($MULTIOP $dir0 Vw1000xYw1000xY | cut -f3 -d" ")
11488 [[ ${DV[0]} != ${DV[1]} ]] ||
11489 error "data version did not change on write"\
11490 " ${DV[0]} == ${DV[1]}"
11495 run_test 187b "Test data version change on volatile file"
11498 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11499 remote_mgs_nodsh && skip "remote MGS with nodsh" && return
11501 local POOL=${POOL:-cea1}
11502 local POOL_ROOT=${POOL_ROOT:-$DIR/d200.pools}
11503 local POOL_DIR_NAME=${POOL_DIR_NAME:-dir_tst}
11506 local last_ost=$(($OSTCOUNT - 1))
11508 local ost_list=$(seq $first_ost $ost_step $last_ost)
11509 local ost_range="$first_ost $last_ost $ost_step"
11510 local test_path=$POOL_ROOT/$POOL_DIR_NAME
11511 local file_dir=$POOL_ROOT/file_tst
11512 local subdir=$test_path/subdir
11516 # former test_200a test_200b
11517 pool_add $POOL || { rc=$? ; break; }
11518 pool_add_targets $POOL $ost_range || { rc=$? ; break; }
11519 # former test_200c test_200d
11520 mkdir -p $test_path
11521 pool_set_dir $POOL $test_path || { rc=$? ; break; }
11522 pool_check_dir $POOL $test_path || { rc=$? ; break; }
11524 pool_check_dir $POOL $subdir || { rc=$? ; break; }
11525 pool_dir_rel_path $POOL $POOL_DIR_NAME $POOL_ROOT \
11526 || { rc=$? ; break; }
11527 # former test_200e test_200f
11528 local files=$((OSTCOUNT*3))
11529 pool_alloc_files $POOL $test_path $files "$ost_list" \
11530 || { rc=$? ; break; }
11531 pool_create_files $POOL $file_dir $files "$ost_list" \
11532 || { rc=$? ; break; }
11533 # former test_200g test_200h
11534 pool_lfs_df $POOL || { rc=$? ; break; }
11535 pool_file_rel_path $POOL $test_path || { rc=$? ; break; }
11537 # former test_201a test_201b test_201c
11538 pool_remove_first_target $POOL || { rc=$? ; break; }
11540 local f=$test_path/$tfile
11541 pool_remove_all_targets $POOL $f || { rc=$? ; break; }
11542 pool_remove $POOL $f || { rc=$? ; break; }
11549 run_test 200 "OST pools"
11551 # usage: default_attr <count | size | offset>
11553 $LCTL get_param -n lov.$FSNAME-clilov-\*.stripe${1}
11556 # usage: check_default_stripe_attr
11557 check_default_stripe_attr() {
11558 ACTUAL=$($GETSTRIPE $* $DIR/$tdir)
11560 --stripe-count|--count)
11561 [ -n "$2" ] && EXPECTED=0 || EXPECTED=$(default_attr count);;
11562 --stripe-size|--size)
11563 [ -n "$2" ] && EXPECTED=0 || EXPECTED=$(default_attr size);;
11564 --stripe-index|--index)
11567 error "unknown getstripe attr '$1'"
11570 [ $ACTUAL != $EXPECTED ] &&
11571 error "$DIR/$tdir has $1 '$ACTUAL', not '$EXPECTED'"
11575 test_mkdir -p $DIR/$tdir
11576 $SETSTRIPE --stripe-count 0 --stripe-size 0 --stripe-index -1 $DIR/$tdir
11578 check_default_stripe_attr --stripe-count
11579 check_default_stripe_attr --stripe-size
11580 check_default_stripe_attr --stripe-index
11584 run_test 204a "Print default stripe attributes ================="
11587 test_mkdir -p $DIR/$tdir
11588 $SETSTRIPE --stripe-count 1 $DIR/$tdir
11590 check_default_stripe_attr --stripe-size
11591 check_default_stripe_attr --stripe-index
11595 run_test 204b "Print default stripe size and offset ==========="
11598 test_mkdir -p $DIR/$tdir
11599 $SETSTRIPE --stripe-size 65536 $DIR/$tdir
11601 check_default_stripe_attr --stripe-count
11602 check_default_stripe_attr --stripe-index
11606 run_test 204c "Print default stripe count and offset ==========="
11609 test_mkdir -p $DIR/$tdir
11610 $SETSTRIPE --stripe-index 0 $DIR/$tdir
11612 check_default_stripe_attr --stripe-count
11613 check_default_stripe_attr --stripe-size
11617 run_test 204d "Print default stripe count and size ============="
11620 test_mkdir -p $DIR/$tdir
11621 $SETSTRIPE -d $DIR/$tdir
11623 check_default_stripe_attr --stripe-count --raw
11624 check_default_stripe_attr --stripe-size --raw
11625 check_default_stripe_attr --stripe-index --raw
11629 run_test 204e "Print raw stripe attributes ================="
11632 test_mkdir -p $DIR/$tdir
11633 $SETSTRIPE --stripe-count 1 $DIR/$tdir
11635 check_default_stripe_attr --stripe-size --raw
11636 check_default_stripe_attr --stripe-index --raw
11640 run_test 204f "Print raw stripe size and offset ==========="
11643 test_mkdir -p $DIR/$tdir
11644 $SETSTRIPE --stripe-size 65536 $DIR/$tdir
11646 check_default_stripe_attr --stripe-count --raw
11647 check_default_stripe_attr --stripe-index --raw
11651 run_test 204g "Print raw stripe count and offset ==========="
11654 test_mkdir -p $DIR/$tdir
11655 $SETSTRIPE --stripe-index 0 $DIR/$tdir
11657 check_default_stripe_attr --stripe-count --raw
11658 check_default_stripe_attr --stripe-size --raw
11662 run_test 204h "Print raw stripe count and size ============="
11664 # Figure out which job scheduler is being used, if any,
11665 # or use a fake one
11666 if [ -n "$SLURM_JOB_ID" ]; then # SLURM
11667 JOBENV=SLURM_JOB_ID
11668 elif [ -n "$LSB_JOBID" ]; then # Load Sharing Facility
11670 elif [ -n "$PBS_JOBID" ]; then # PBS/Maui/Moab
11672 elif [ -n "$LOADL_STEPID" ]; then # LoadLeveller
11673 JOBENV=LOADL_STEP_ID
11674 elif [ -n "$JOB_ID" ]; then # Sun Grid Engine
11677 $LCTL list_param jobid_name > /dev/null 2>&1
11678 if [ $? -eq 0 ]; then
11685 verify_jobstats() {
11690 # we don't really need to clear the stats for this test to work, since each
11691 # command has a unique jobid, but it makes debugging easier if needed.
11692 # for facet in $facets; do
11693 # local dev=$(convert_facet2label $facet)
11694 # # clear old jobstats
11695 # do_facet $facet lctl set_param *.$dev.job_stats="clear"
11698 # use a new JobID for each test, or we might see an old one
11699 [ "$JOBENV" = "FAKE_JOBID" ] &&
11700 FAKE_JOBID=id.$testnum.$(basename ${cmd[0]}).$RANDOM
11704 [ "$JOBENV" = "nodelocal" ] && {
11705 FAKE_JOBID=id.$testnum.$(basename ${cmd[0]}).$RANDOM
11706 $LCTL set_param jobid_name=$FAKE_JOBID
11710 log "Test: ${cmd[*]}"
11711 log "Using JobID environment variable $JOBENV=$JOBVAL"
11713 if [ $JOBENV = "FAKE_JOBID" ]; then
11714 FAKE_JOBID=$JOBVAL ${cmd[*]}
11719 # all files are created on OST0000
11720 for facet in $facets; do
11721 local stats="*.$(convert_facet2label $facet).job_stats"
11722 if [ $(do_facet $facet lctl get_param $stats |
11723 grep -c $JOBVAL) -ne 1 ]; then
11724 do_facet $facet lctl get_param $stats
11725 error "No jobstats for $JOBVAL found on $facet::$stats"
11732 NEW_JOBENV=${1:-$OLD_JOBENV}
11733 do_facet mgs $LCTL conf_param $FSNAME.sys.jobid_var=$NEW_JOBENV
11734 wait_update $HOSTNAME "$LCTL get_param -n jobid_var" $NEW_JOBENV
11738 do_facet $SINGLEMDS \
11739 $LCTL set_param mdt.*.job_cleanup_interval=$OLD_INTERVAL
11740 [ $OLD_JOBENV != $JOBENV ] && jobstats_set $OLD_JOBENV
11741 do_facet $SINGLEMDS lctl --device $MDT0 changelog_deregister $CL_USER
11744 test_205() { # Job stats
11745 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11746 remote_mgs_nodsh && skip "remote MGS with nodsh" && return
11747 remote_mds_nodsh && skip "remote MDS with nodsh" && return
11748 remote_ost_nodsh && skip "remote OST with nodsh" && return
11750 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep jobstats)" ] &&
11751 skip "Server doesn't support jobstats" && return 0
11752 [[ $JOBID_VAR = disable ]] && skip "jobstats is disabled" && return
11754 OLD_JOBENV=$($LCTL get_param -n jobid_var)
11755 if [ $OLD_JOBENV != $JOBENV ]; then
11756 jobstats_set $JOBENV
11757 trap cleanup_205 EXIT
11760 CL_USER=$(do_facet $SINGLEMDS lctl --device $MDT0 changelog_register -n)
11761 echo "Registered as changelog user $CL_USER"
11763 OLD_INTERVAL=$(do_facet $SINGLEMDS \
11764 lctl get_param -n mdt.*.job_cleanup_interval)
11765 local interval_new=5
11766 do_facet $SINGLEMDS \
11767 $LCTL set_param mdt.*.job_cleanup_interval=$interval_new
11768 local start=$SECONDS
11772 cmd="mkdir $DIR/$tdir"
11773 verify_jobstats "$cmd" "$SINGLEMDS"
11775 cmd="rmdir $DIR/$tdir"
11776 verify_jobstats "$cmd" "$SINGLEMDS"
11777 # mkdir on secondary MDT
11778 if [ $MDSCOUNT -gt 1 ]; then
11779 cmd="lfs mkdir -i 1 $DIR/$tdir.remote"
11780 verify_jobstats "$cmd" "mds2"
11783 cmd="mknod $DIR/$tfile c 1 3"
11784 verify_jobstats "$cmd" "$SINGLEMDS"
11786 cmd="rm -f $DIR/$tfile"
11787 verify_jobstats "$cmd" "$SINGLEMDS"
11788 # create all files on OST0000 so verify_jobstats can find OST stats
11790 cmd="$SETSTRIPE -i 0 -c 1 $DIR/$tfile"
11791 verify_jobstats "$cmd" "$SINGLEMDS"
11793 cmd="touch $DIR/$tfile"
11794 verify_jobstats "$cmd" "$SINGLEMDS ost1"
11796 cmd="dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 oflag=sync"
11797 verify_jobstats "$cmd" "ost1"
11799 cmd="dd if=$DIR/$tfile of=/dev/null bs=1M count=1 iflag=direct"
11800 verify_jobstats "$cmd" "ost1"
11802 cmd="$TRUNCATE $DIR/$tfile 0"
11803 verify_jobstats "$cmd" "$SINGLEMDS ost1"
11805 cmd="mv -f $DIR/$tfile $DIR/$tdir.rename"
11806 verify_jobstats "$cmd" "$SINGLEMDS"
11807 # jobstats expiry - sleep until old stats should be expired
11808 local left=$((interval_new + 2 - (SECONDS - start)))
11809 [ $left -ge 0 ] && echo "sleep $left for expiry" && sleep $((left + 1))
11810 cmd="mkdir $DIR/$tdir.expire"
11811 verify_jobstats "$cmd" "$SINGLEMDS"
11812 [ $(do_facet $SINGLEMDS lctl get_param *.*.job_stats |
11813 grep -c "job_id.*mkdir") -gt 1 ] && error "old jobstats not expired"
11815 # Ensure that jobid are present in changelog (if supported by MDS)
11816 if [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.6.52) ]
11818 $LFS changelog $MDT0 | tail -9
11819 jobids=$($LFS changelog $MDT0 | tail -9 | grep -c "j=")
11820 [ $jobids -eq 9 ] ||
11821 error "Wrong changelog jobid count $jobids != 9"
11825 jobstats_set $JOBENV
11827 $LFS changelog $MDT0 | tail -1
11828 jobids=$($LFS changelog $MDT0 | tail -1 | grep -c "j=")
11829 [ $jobids -eq 0 ] ||
11830 error "Unexpected jobids when jobid_var=$JOBENV"
11835 run_test 205 "Verify job stats"
11837 # LU-1480, LU-1773 and LU-1657
11839 mkdir -p $DIR/$tdir
11840 $SETSTRIPE -c -1 $DIR/$tdir
11841 #define OBD_FAIL_LOV_INIT 0x1403
11842 $LCTL set_param fail_loc=0xa0001403
11843 $LCTL set_param fail_val=1
11844 touch $DIR/$tdir/$tfile || true
11846 run_test 206 "fail lov_init_raid0() doesn't lbug"
11849 dd if=/dev/zero of=$DIR/$tfile bs=4k count=$((RANDOM%10+1))
11850 local fsz=`stat -c %s $DIR/$tfile`
11851 cancel_lru_locks mdc
11853 # do not return layout in getattr intent
11854 #define OBD_FAIL_MDS_NO_LL_GETATTR 0x170
11855 $LCTL set_param fail_loc=0x170
11856 local sz=`stat -c %s $DIR/$tfile`
11858 [ $fsz -eq $sz ] || error "file size expected $fsz, actual $sz"
11862 run_test 207a "can refresh layout at glimpse"
11865 dd if=/dev/zero of=$DIR/$tfile bs=4k count=$((RANDOM%10+1))
11866 local cksum=`md5sum $DIR/$tfile`
11867 local fsz=`stat -c %s $DIR/$tfile`
11868 cancel_lru_locks mdc
11869 cancel_lru_locks osc
11871 # do not return layout in getattr intent
11872 #define OBD_FAIL_MDS_NO_LL_OPEN 0x171
11873 $LCTL set_param fail_loc=0x171
11875 # it will refresh layout after the file is opened but before read issues
11876 echo checksum is "$cksum"
11877 echo "$cksum" |md5sum -c --quiet || error "file differs"
11881 run_test 207b "can refresh layout at open"
11884 # FIXME: in this test suite, only RD lease is used. This is okay
11885 # for now as only exclusive open is supported. After generic lease
11886 # is done, this test suite should be revised. - Jinshan
11888 remote_mds_nodsh && skip "remote MDS with nodsh" && return
11889 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.4.52) ]] ||
11890 { skip "Need MDS version at least 2.4.52"; return 0; }
11892 echo "==== test 1: verify get lease work"
11893 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:eRE+eU || error "get lease error"
11895 echo "==== test 2: verify lease can be broken by upcoming open"
11896 $MULTIOP $DIR/$tfile oO_RDONLY:eR_E-eUc &
11900 $MULTIOP $DIR/$tfile oO_RDONLY:c
11901 kill -USR1 $PID && wait $PID || error "break lease error"
11903 echo "==== test 3: verify lease can't be granted if an open already exists"
11904 $MULTIOP $DIR/$tfile oO_RDONLY:_c &
11908 $MULTIOP $DIR/$tfile oO_RDONLY:eReUc && error "apply lease should fail"
11909 kill -USR1 $PID && wait $PID || error "open file error"
11911 echo "==== test 4: lease can sustain over recovery"
11912 $MULTIOP $DIR/$tfile oO_RDONLY:eR_E+eUc &
11918 kill -USR1 $PID && wait $PID || error "lease broken over recovery"
11920 echo "==== test 5: lease broken can't be regained by replay"
11921 $MULTIOP $DIR/$tfile oO_RDONLY:eR_E-eUc &
11925 # open file to break lease and then recovery
11926 $MULTIOP $DIR/$tfile oO_RDWR:c || error "open file error"
11929 kill -USR1 $PID && wait $PID || error "lease not broken over recovery"
11933 run_test 208 "Exclusive open"
11936 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep disp_stripe)" ] &&
11937 skip_env "must have disp_stripe" && return
11940 sync; sleep 5; sync;
11942 echo 3 > /proc/sys/vm/drop_caches
11943 req_before=$(awk '/ptlrpc_cache / { print $2 }' /proc/slabinfo)
11945 # open/close 500 times
11946 for i in $(seq 500); do
11950 echo 3 > /proc/sys/vm/drop_caches
11951 req_after=$(awk '/ptlrpc_cache / { print $2 }' /proc/slabinfo)
11953 echo "before: $req_before, after: $req_after"
11954 [ $((req_after - req_before)) -ge 300 ] &&
11955 error "open/close requests are not freed"
11958 run_test 209 "read-only open/close requests should be freed promptly"
11962 size=$((size % 8192 + 1))
11963 dd if=/dev/urandom of=$DIR/f212 bs=1k count=$size
11964 sendfile $DIR/f212 $DIR/f212.xyz || error "sendfile wrong"
11965 rm -f $DIR/f212 $DIR/f212.xyz
11967 run_test 212 "Sendfile test ============================================"
11970 dd if=/dev/zero of=$DIR/$tfile bs=4k count=4
11971 cancel_lru_locks osc
11972 lctl set_param fail_loc=0x8000040f
11973 # generate a read lock
11974 cat $DIR/$tfile > /dev/null
11975 # write to the file, it will try to cancel the above read lock.
11976 cat /etc/hosts >> $DIR/$tfile
11978 run_test 213 "OSC lock completion and cancel race don't crash - bug 18829"
11980 test_214() { # for bug 20133
11981 mkdir -p $DIR/$tdir/d214c || error "mkdir $DIR/$tdir/d214c failed"
11982 for (( i=0; i < 340; i++ )) ; do
11983 touch $DIR/$tdir/d214c/a$i
11986 ls -l $DIR/$tdir || error "ls -l $DIR/d214p failed"
11987 mv $DIR/$tdir/d214c $DIR/ || error "mv $DIR/d214p/d214c $DIR/ failed"
11988 ls $DIR/d214c || error "ls $DIR/d214c failed"
11989 rm -rf $DIR/$tdir || error "rm -rf $DIR/d214* failed"
11990 rm -rf $DIR/d214* || error "rm -rf $DIR/d214* failed"
11992 run_test 214 "hash-indexed directory test - bug 20133"
11994 # having "abc" as 1st arg, creates $TMP/lnet_abc.out and $TMP/lnet_abc.sys
11995 create_lnet_proc_files() {
11996 lctl get_param -n $1 >$TMP/lnet_$1.out || error "cannot read lnet.$1"
11997 sysctl lnet.$1 >$TMP/lnet_$1.sys_tmp || error "cannot read lnet.$1"
11999 sed "s/^lnet.$1\ =\ //g" "$TMP/lnet_$1.sys_tmp" >$TMP/lnet_$1.sys
12000 rm -f "$TMP/lnet_$1.sys_tmp"
12003 # counterpart of create_lnet_proc_files
12004 remove_lnet_proc_files() {
12005 rm -f $TMP/lnet_$1.out $TMP/lnet_$1.sys
12008 # uses 1st arg as trailing part of filename, 2nd arg as description for reports,
12009 # 3rd arg as regexp for body
12010 check_lnet_proc_stats() {
12011 local l=$(cat "$TMP/lnet_$1" |wc -l)
12012 [ $l = 1 ] || (cat "$TMP/lnet_$1" && error "$2 is not of 1 line: $l")
12014 grep -E "$3" "$TMP/lnet_$1" || (cat "$TMP/lnet_$1" && error "$2 misformatted")
12017 # uses 1st arg as trailing part of filename, 2nd arg as description for reports,
12018 # 3rd arg as regexp for body, 4th arg as regexp for 1st line, 5th arg is
12019 # optional and can be regexp for 2nd line (lnet.routes case)
12020 check_lnet_proc_entry() {
12021 local blp=2 # blp stands for 'position of 1st line of body'
12022 [ -z "$5" ] || blp=3 # lnet.routes case
12024 local l=$(cat "$TMP/lnet_$1" |wc -l)
12025 # subtracting one from $blp because the body can be empty
12026 [ "$l" -ge "$(($blp - 1))" ] || (cat "$TMP/lnet_$1" && error "$2 is too short: $l")
12028 sed -n '1 p' "$TMP/lnet_$1" |grep -E "$4" >/dev/null ||
12029 (cat "$TMP/lnet_$1" && error "1st line of $2 misformatted")
12031 [ "$5" = "" ] || sed -n '2 p' "$TMP/lnet_$1" |grep -E "$5" >/dev/null ||
12032 (cat "$TMP/lnet_$1" && error "2nd line of $2 misformatted")
12034 # bail out if any unexpected line happened
12035 sed -n "$blp p" "$TMP/lnet_$1" | grep -Ev "$3"
12036 [ "$?" != 0 ] || error "$2 misformatted"
12039 test_215() { # for bugs 18102, 21079, 21517
12040 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12041 local N='(0|[1-9][0-9]*)' # non-negative numeric
12042 local P='[1-9][0-9]*' # positive numeric
12043 local I='(0|-?[1-9][0-9]*|NA)' # any numeric (0 | >0 | <0) or NA if no value
12044 local NET='[a-z][a-z0-9]*' # LNET net like o2ib2
12045 local ADDR='[0-9.]+' # LNET addr like 10.0.0.1
12046 local NID="$ADDR@$NET" # LNET nid like 10.0.0.1@o2ib2
12048 local L1 # regexp for 1st line
12049 local L2 # regexp for 2nd line (optional)
12050 local BR # regexp for the rest (body)
12052 # lnet.stats should look as 11 space-separated non-negative numerics
12053 BR="^$N $N $N $N $N $N $N $N $N $N $N$"
12054 create_lnet_proc_files "stats"
12055 check_lnet_proc_stats "stats.sys" "lnet.stats" "$BR"
12056 remove_lnet_proc_files "stats"
12058 # lnet.routes should look like this:
12059 # Routing disabled/enabled
12060 # net hops priority state router
12061 # where net is a string like tcp0, hops > 0, priority >= 0,
12062 # state is up/down,
12063 # router is a string like 192.168.1.1@tcp2
12064 L1="^Routing (disabled|enabled)$"
12065 L2="^net +hops +priority +state +router$"
12066 BR="^$NET +$N +(0|1) +(up|down) +$NID$"
12067 create_lnet_proc_files "routes"
12068 check_lnet_proc_entry "routes.sys" "lnet.routes" "$BR" "$L1" "$L2"
12069 remove_lnet_proc_files "routes"
12071 # lnet.routers should look like this:
12072 # ref rtr_ref alive_cnt state last_ping ping_sent deadline down_ni router
12073 # where ref > 0, rtr_ref > 0, alive_cnt >= 0, state is up/down,
12074 # last_ping >= 0, ping_sent is boolean (0/1), deadline and down_ni are
12075 # numeric (0 or >0 or <0), router is a string like 192.168.1.1@tcp2
12076 L1="^ref +rtr_ref +alive_cnt +state +last_ping +ping_sent +deadline +down_ni +router$"
12077 BR="^$P +$P +$N +(up|down) +$N +(0|1) +$I +$I +$NID$"
12078 create_lnet_proc_files "routers"
12079 check_lnet_proc_entry "routers.sys" "lnet.routers" "$BR" "$L1"
12080 remove_lnet_proc_files "routers"
12082 # lnet.peers should look like this:
12083 # nid refs state last max rtr min tx min queue
12084 # where nid is a string like 192.168.1.1@tcp2, refs > 0,
12085 # state is up/down/NA, max >= 0. last, rtr, min, tx, min are
12086 # numeric (0 or >0 or <0), queue >= 0.
12087 L1="^nid +refs +state +last +max +rtr +min +tx +min +queue$"
12088 BR="^$NID +$P +(up|down|NA) +$I +$N +$I +$I +$I +$I +$N$"
12089 create_lnet_proc_files "peers"
12090 check_lnet_proc_entry "peers.sys" "lnet.peers" "$BR" "$L1"
12091 remove_lnet_proc_files "peers"
12093 # lnet.buffers should look like this:
12094 # pages count credits min
12095 # where pages >=0, count >=0, credits and min are numeric (0 or >0 or <0)
12096 L1="^pages +count +credits +min$"
12097 BR="^ +$N +$N +$I +$I$"
12098 create_lnet_proc_files "buffers"
12099 check_lnet_proc_entry "buffers.sys" "lnet.buffers" "$BR" "$L1"
12100 remove_lnet_proc_files "buffers"
12102 # lnet.nis should look like this:
12103 # nid status alive refs peer rtr max tx min
12104 # where nid is a string like 192.168.1.1@tcp2, status is up/down,
12105 # alive is numeric (0 or >0 or <0), refs >= 0, peer >= 0,
12106 # rtr >= 0, max >=0, tx and min are numeric (0 or >0 or <0).
12107 L1="^nid +status +alive +refs +peer +rtr +max +tx +min$"
12108 BR="^$NID +(up|down) +$I +$N +$N +$N +$N +$I +$I$"
12109 create_lnet_proc_files "nis"
12110 check_lnet_proc_entry "nis.sys" "lnet.nis" "$BR" "$L1"
12111 remove_lnet_proc_files "nis"
12113 # can we successfully write to lnet.stats?
12114 lctl set_param -n stats=0 || error "cannot write to lnet.stats"
12115 sysctl -w lnet.stats=0 || error "cannot write to lnet.stats"
12117 run_test 215 "lnet exists and has proper content - bugs 18102, 21079, 21517"
12119 test_216() { # bug 20317
12120 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12121 remote_ost_nodsh && skip "remote OST with nodsh" && return
12124 local facets=$(get_facets OST)
12125 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
12127 save_lustre_params client "osc.*.contention_seconds" > $p
12128 save_lustre_params $facets \
12129 "ldlm.namespaces.filter-*.max_nolock_bytes" >> $p
12130 save_lustre_params $facets \
12131 "ldlm.namespaces.filter-*.contended_locks" >> $p
12132 save_lustre_params $facets \
12133 "ldlm.namespaces.filter-*.contention_seconds" >> $p
12136 # agressive lockless i/o settings
12137 for node in $(osts_nodes); do
12138 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'
12140 lctl set_param -n osc.*.contention_seconds 60
12142 $DIRECTIO write $DIR/$tfile 0 10 4096
12143 $CHECKSTAT -s 40960 $DIR/$tfile
12145 # disable lockless i/o
12146 for node in $(osts_nodes); do
12147 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'
12149 lctl set_param -n osc.*.contention_seconds 0
12152 dd if=/dev/zero of=$DIR/$tfile count=0
12153 $CHECKSTAT -s 0 $DIR/$tfile
12155 restore_lustre_params <$p
12159 run_test 216 "check lockless direct write works and updates file size and kms correctly"
12161 test_217() { # bug 22430
12162 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12166 for node in $(nodes_list); do
12167 nid=$(host_nids_address $node $NETTYPE)
12168 if [[ $nid = *-* ]] ; then
12169 echo "lctl ping $nid@$NETTYPE"
12170 lctl ping $nid@$NETTYPE
12172 echo "skipping $node (no hyphen detected)"
12176 run_test 217 "check lctl ping for hostnames with hiphen ('-')"
12179 # do directio so as not to populate the page cache
12180 log "creating a 10 Mb file"
12181 $MULTIOP $DIR/$tfile oO_CREAT:O_DIRECT:O_RDWR:w$((10*1048576))c || error "multiop failed while creating a file"
12182 log "starting reads"
12183 dd if=$DIR/$tfile of=/dev/null bs=4096 &
12184 log "truncating the file"
12185 $MULTIOP $DIR/$tfile oO_TRUNC:c || error "multiop failed while truncating the file"
12187 kill %+ || true # reads might have finished
12188 echo "wait until dd is finished"
12190 log "removing the temporary file"
12191 rm -rf $DIR/$tfile || error "tmp file removal failed"
12193 run_test 218 "parallel read and truncate should not deadlock ======================="
12196 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12197 # write one partial page
12198 dd if=/dev/zero of=$DIR/$tfile bs=1024 count=1
12199 # set no grant so vvp_io_commit_write will do sync write
12200 $LCTL set_param fail_loc=0x411
12201 # write a full page at the end of file
12202 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 seek=1 conv=notrunc
12204 $LCTL set_param fail_loc=0
12205 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 seek=3
12206 $LCTL set_param fail_loc=0x411
12207 dd if=/dev/zero of=$DIR/$tfile bs=1024 count=1 seek=2 conv=notrunc
12210 dd if=/dev/zero of=$DIR/$tfile-2 bs=1024 count=1
12211 $CHECKSTAT -s 1024 $DIR/$tfile-2 || error "checkstat wrong size"
12213 run_test 219 "LU-394: Write partial won't cause uncontiguous pages vec at LND"
12215 test_220() { #LU-325
12216 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12217 remote_ost_nodsh && skip "remote OST with nodsh" && return
12218 remote_mds_nodsh && skip "remote MDS with nodsh" && return
12219 remote_mgs_nodsh && skip "remote MGS with nodsh" && return
12222 # create on MDT0000 so the last_id and next_id are correct
12224 local OST=$($LFS df $DIR | awk '/OST:'$OSTIDX'/ { print $1 }')
12228 local mdtosc_proc1=$(get_mdtosc_proc_path $SINGLEMDS $OST)
12229 local last_id=$(do_facet $SINGLEMDS lctl get_param -n \
12230 osc.$mdtosc_proc1.prealloc_last_id)
12231 local next_id=$(do_facet $SINGLEMDS lctl get_param -n \
12232 osc.$mdtosc_proc1.prealloc_next_id)
12236 do_facet ost$((OSTIDX + 1)) lctl set_param fail_val=-1
12237 #define OBD_FAIL_OST_ENOINO 0x229
12238 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=0x229
12239 do_facet mgs $LCTL pool_new $FSNAME.$TESTNAME || return 1
12240 do_facet mgs $LCTL pool_add $FSNAME.$TESTNAME $OST || return 2
12242 $SETSTRIPE $DIR/$tdir -i $OSTIDX -c 1 -p $FSNAME.$TESTNAME
12244 MDSOBJS=$((last_id - next_id))
12245 echo "preallocated objects on MDS is $MDSOBJS" "($last_id - $next_id)"
12247 blocks=$($LFS df $MOUNT | awk '($1 == '$OSTIDX') { print $4 }')
12248 echo "OST still has $count kbytes free"
12250 echo "create $MDSOBJS files @next_id..."
12251 createmany -o $DIR/$tdir/f $MDSOBJS || return 3
12253 local last_id2=$(do_facet mds${MDSIDX} lctl get_param -n \
12254 osc.$mdtosc_proc1.prealloc_last_id)
12255 local next_id2=$(do_facet mds${MDSIDX} lctl get_param -n \
12256 osc.$mdtosc_proc1.prealloc_next_id)
12258 echo "after creation, last_id=$last_id2, next_id=$next_id2"
12263 do_facet ost$((OSTIDX + 1)) lctl set_param fail_val=0
12264 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=0
12266 do_facet mgs $LCTL pool_remove $FSNAME.$TESTNAME $OST || return 4
12267 do_facet mgs $LCTL pool_destroy $FSNAME.$TESTNAME || return 5
12268 echo "unlink $MDSOBJS files @$next_id..."
12269 unlinkmany $DIR/$tdir/f $MDSOBJS || return 6
12271 run_test 220 "preallocated MDS objects still used if ENOSPC from OST"
12274 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12275 dd if=`which date` of=$MOUNT/date oflag=sync
12276 chmod +x $MOUNT/date
12278 #define OBD_FAIL_LLITE_FAULT_TRUNC_RACE 0x1401
12279 $LCTL set_param fail_loc=0x80001401
12281 $MOUNT/date > /dev/null
12284 run_test 221 "make sure fault and truncate race to not cause OOM"
12287 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12289 test_mkdir -p $DIR/$tdir
12290 $SETSTRIPE -c 1 -i 0 $DIR/$tdir
12291 createmany -o $DIR/$tdir/$tfile 10
12292 cancel_lru_locks mdc
12293 cancel_lru_locks osc
12294 #define OBD_FAIL_LDLM_AGL_DELAY 0x31a
12295 $LCTL set_param fail_loc=0x31a
12296 ls -l $DIR/$tdir > /dev/null || error "AGL for ls failed"
12297 $LCTL set_param fail_loc=0
12300 run_test 222a "AGL for ls should not trigger CLIO lock failure ================"
12303 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12305 test_mkdir -p $DIR/$tdir
12306 $SETSTRIPE -c 1 -i 0 $DIR/$tdir
12307 createmany -o $DIR/$tdir/$tfile 10
12308 cancel_lru_locks mdc
12309 cancel_lru_locks osc
12310 #define OBD_FAIL_LDLM_AGL_DELAY 0x31a
12311 $LCTL set_param fail_loc=0x31a
12312 rm -r $DIR/$tdir || "AGL for rmdir failed"
12313 $LCTL set_param fail_loc=0
12315 run_test 222b "AGL for rmdir should not trigger CLIO lock failure ============="
12318 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12320 test_mkdir -p $DIR/$tdir
12321 $SETSTRIPE -c 1 -i 0 $DIR/$tdir
12322 createmany -o $DIR/$tdir/$tfile 10
12323 cancel_lru_locks mdc
12324 cancel_lru_locks osc
12325 #define OBD_FAIL_LDLM_AGL_NOLOCK 0x31b
12326 $LCTL set_param fail_loc=0x31b
12327 ls -l $DIR/$tdir > /dev/null || error "reenqueue failed"
12328 $LCTL set_param fail_loc=0
12331 run_test 223 "osc reenqueue if without AGL lock granted ======================="
12333 test_224a() { # LU-1039, MRP-303
12334 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12335 #define OBD_FAIL_PTLRPC_CLIENT_BULK_CB 0x508
12336 $LCTL set_param fail_loc=0x508
12337 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 conv=fsync
12338 $LCTL set_param fail_loc=0
12341 run_test 224a "Don't panic on bulk IO failure"
12343 test_224b() { # LU-1039, MRP-303
12344 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12345 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1
12346 cancel_lru_locks osc
12347 #define OBD_FAIL_PTLRPC_CLIENT_BULK_CB2 0x515
12348 $LCTL set_param fail_loc=0x515
12349 dd of=/dev/null if=$DIR/$tfile bs=4096 count=1
12350 $LCTL set_param fail_loc=0
12353 run_test 224b "Don't panic on bulk IO failure"
12355 test_224c() { # LU-6441
12356 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12357 local pages_per_rpc=$($LCTL get_param \
12358 osc.*.max_pages_per_rpc)
12359 local at_max=$($LCTL get_param -n at_max)
12360 local timeout=$($LCTL get_param -n timeout)
12361 local test_at="$LCTL get_param -n at_max"
12362 local param_at="$FSNAME.sys.at_max"
12363 local test_timeout="$LCTL get_param -n timeout"
12364 local param_timeout="$FSNAME.sys.timeout"
12366 $LCTL set_param -n osc.*.max_pages_per_rpc=1024
12368 set_conf_param_and_check client "$test_at" "$param_at" 0 ||
12369 error "conf_param at_max=0 failed"
12370 set_conf_param_and_check client "$test_timeout" "$param_timeout" 5 ||
12371 error "conf_param timeout=5 failed"
12373 #define OBD_FAIL_PTLRPC_CLIENT_BULK_CB3 0x520
12374 $LCTL set_param fail_loc=0x520
12375 dd if=/dev/zero of=$DIR/$tfile bs=8MB count=1
12377 $LCTL set_param fail_loc=0
12379 set_conf_param_and_check client "$test_at" "$param_at" $at_max ||
12380 error "conf_param at_max=$at_max failed"
12381 set_conf_param_and_check client "$test_timeout" "$param_timeout" \
12382 $timeout || error "conf_param timeout=$timeout failed"
12384 $LCTL set_param -n $pages_per_rpc
12386 run_test 224c "Don't hang if one of md lost during large bulk RPC"
12388 MDSSURVEY=${MDSSURVEY:-$(which mds-survey 2>/dev/null || true)}
12390 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12391 remote_mds_nodsh && skip "remote MDS with nodsh" && return
12392 if [ -z ${MDSSURVEY} ]; then
12393 skip_env "mds-survey not found" && return
12396 [ $MDSCOUNT -ge 2 ] &&
12397 skip "skipping now for more than one MDT" && return
12399 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.51) ] ||
12400 { skip "Need MDS version at least 2.2.51"; return; }
12402 local mds=$(facet_host $SINGLEMDS)
12403 local target=$(do_nodes $mds 'lctl dl' | \
12404 awk "{if (\$2 == \"UP\" && \$3 == \"mdt\") {print \$4}}")
12406 local cmd1="file_count=1000 thrhi=4"
12407 local cmd2="dir_count=2 layer=mdd stripe_count=0"
12408 local cmd3="rslt_loc=${TMP} targets=\"$mds:$target\" $MDSSURVEY"
12409 local cmd="$cmd1 $cmd2 $cmd3"
12411 rm -f ${TMP}/mds_survey*
12413 eval $cmd || error "mds-survey with zero-stripe failed"
12414 cat ${TMP}/mds_survey*
12415 rm -f ${TMP}/mds_survey*
12417 run_test 225a "Metadata survey sanity with zero-stripe"
12420 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12421 remote_mds_nodsh && skip "remote MDS with nodsh" && return
12422 if [ -z ${MDSSURVEY} ]; then
12423 skip_env "mds-survey not found" && return
12425 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.51) ] ||
12426 { skip "Need MDS version at least 2.2.51"; return; }
12428 if [ $($LCTL dl | grep -c osc) -eq 0 ]; then
12429 skip_env "Need to mount OST to test" && return
12432 [ $MDSCOUNT -ge 2 ] &&
12433 skip "skipping now for more than one MDT" && return
12434 local mds=$(facet_host $SINGLEMDS)
12435 local target=$(do_nodes $mds 'lctl dl' | \
12436 awk "{if (\$2 == \"UP\" && \$3 == \"mdt\") {print \$4}}")
12438 local cmd1="file_count=1000 thrhi=4"
12439 local cmd2="dir_count=2 layer=mdd stripe_count=1"
12440 local cmd3="rslt_loc=${TMP} targets=\"$mds:$target\" $MDSSURVEY"
12441 local cmd="$cmd1 $cmd2 $cmd3"
12443 rm -f ${TMP}/mds_survey*
12445 eval $cmd || error "mds-survey with stripe_count failed"
12446 cat ${TMP}/mds_survey*
12447 rm -f ${TMP}/mds_survey*
12449 run_test 225b "Metadata survey sanity with stripe_count = 1"
12451 mcreate_path2fid () {
12457 local path=$DIR/$tdir/$name
12462 $MCREATE --mode=$1 --major=$2 --minor=$3 $path ||
12463 error "cannot create $desc"
12465 fid=$($LFS path2fid $path | tr -d '[' | tr -d ']')
12467 [ $rc -ne 0 ] && error "cannot get fid of a $desc"
12469 fid_path=$($LFS fid2path $MOUNT $fid)
12471 [ $rc -ne 0 ] && error "cannot get path of $desc by $DIR $path $fid"
12473 [ "$path" == "$fid_path" ] ||
12474 error "fid2path returned $fid_path, expected $path"
12476 echo "pass with $path and $fid"
12481 mkdir -p $DIR/$tdir
12483 mcreate_path2fid 0010666 0 0 fifo "FIFO"
12484 mcreate_path2fid 0020666 1 3 null "character special file (null)"
12485 mcreate_path2fid 0020666 1 255 none "character special file (no device)"
12486 mcreate_path2fid 0040666 0 0 dir "directory"
12487 mcreate_path2fid 0060666 7 0 loop0 "block special file (loop)"
12488 mcreate_path2fid 0100666 0 0 file "regular file"
12489 mcreate_path2fid 0120666 0 0 link "symbolic link"
12490 mcreate_path2fid 0140666 0 0 sock "socket"
12492 run_test 226a "call path2fid and fid2path on files of all type"
12495 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
12499 mkdir -p $DIR/$tdir
12500 $LFS setdirstripe -i $MDTIDX $DIR/$tdir/remote_dir ||
12501 error "create remote directory failed"
12502 mcreate_path2fid 0010666 0 0 "remote_dir/fifo" "FIFO"
12503 mcreate_path2fid 0020666 1 3 "remote_dir/null" \
12504 "character special file (null)"
12505 mcreate_path2fid 0020666 1 255 "remote_dir/none" \
12506 "character special file (no device)"
12507 mcreate_path2fid 0040666 0 0 "remote_dir/dir" "directory"
12508 mcreate_path2fid 0060666 7 0 "remote_dir/loop0" \
12509 "block special file (loop)"
12510 mcreate_path2fid 0100666 0 0 "remote_dir/file" "regular file"
12511 mcreate_path2fid 0120666 0 0 "remote_dir/link" "symbolic link"
12512 mcreate_path2fid 0140666 0 0 "remote_dir/sock" "socket"
12514 run_test 226b "call path2fid and fid2path on files of all type under remote dir"
12516 # LU-1299 Executing or running ldd on a truncated executable does not
12517 # cause an out-of-memory condition.
12519 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12520 [ -z "$(which ldd)" ] && skip "should have ldd tool" && return
12521 dd if=$(which date) of=$MOUNT/date bs=1k count=1
12522 chmod +x $MOUNT/date
12524 $MOUNT/date > /dev/null
12525 ldd $MOUNT/date > /dev/null
12528 run_test 227 "running truncated executable does not cause OOM"
12530 # LU-1512 try to reuse idle OI blocks
12532 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12533 remote_mds_nodsh && skip "remote MDS with nodsh" && return
12534 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
12535 skip "non-ldiskfs backend" && return
12537 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
12538 local myDIR=$DIR/$tdir
12541 #define OBD_FAIL_SEQ_EXHAUST 0x1002
12542 $LCTL set_param fail_loc=0x80001002
12543 createmany -o $myDIR/t- 10000
12544 $LCTL set_param fail_loc=0
12545 # The guard is current the largest FID holder
12547 local SEQ=$($LFS path2fid $myDIR/guard | awk -F ':' '{print $1}' |
12549 local IDX=$(($SEQ % 64))
12551 do_facet $SINGLEMDS sync
12552 # Make sure journal flushed.
12554 local blk1=$(do_facet $SINGLEMDS \
12555 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
12556 grep Blockcount | awk '{print $4}')
12558 # Remove old files, some OI blocks will become idle.
12559 unlinkmany $myDIR/t- 10000
12560 # Create new files, idle OI blocks should be reused.
12561 createmany -o $myDIR/t- 2000
12562 do_facet $SINGLEMDS sync
12563 # Make sure journal flushed.
12565 local blk2=$(do_facet $SINGLEMDS \
12566 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
12567 grep Blockcount | awk '{print $4}')
12569 [ $blk1 == $blk2 ] || error "old blk1=$blk1, new blk2=$blk2, unmatched!"
12571 run_test 228a "try to reuse idle OI blocks"
12574 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12575 remote_mds_nodsh && skip "remote MDS with nodsh" && return
12576 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
12577 skip "non-ldiskfs backend" && return
12579 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
12580 local myDIR=$DIR/$tdir
12583 #define OBD_FAIL_SEQ_EXHAUST 0x1002
12584 $LCTL set_param fail_loc=0x80001002
12585 createmany -o $myDIR/t- 10000
12586 $LCTL set_param fail_loc=0
12587 # The guard is current the largest FID holder
12589 local SEQ=$($LFS path2fid $myDIR/guard | awk -F ':' '{print $1}' |
12591 local IDX=$(($SEQ % 64))
12593 do_facet $SINGLEMDS sync
12594 # Make sure journal flushed.
12596 local blk1=$(do_facet $SINGLEMDS \
12597 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
12598 grep Blockcount | awk '{print $4}')
12600 # Remove old files, some OI blocks will become idle.
12601 unlinkmany $myDIR/t- 10000
12604 stop $SINGLEMDS || error "Fail to stop MDT."
12606 start $SINGLEMDS $MDT_DEV $MDS_MOUNT_OPTS || error "Fail to start MDT."
12608 df $MOUNT || error "Fail to df."
12609 # Create new files, idle OI blocks should be reused.
12610 createmany -o $myDIR/t- 2000
12611 do_facet $SINGLEMDS sync
12612 # Make sure journal flushed.
12614 local blk2=$(do_facet $SINGLEMDS \
12615 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
12616 grep Blockcount | awk '{print $4}')
12618 [ $blk1 == $blk2 ] || error "old blk1=$blk1, new blk2=$blk2, unmatched!"
12620 run_test 228b "idle OI blocks can be reused after MDT restart"
12624 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12625 remote_mds_nodsh && skip "remote MDS with nodsh" && return
12626 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
12627 skip "non-ldiskfs backend" && return
12629 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
12630 local myDIR=$DIR/$tdir
12633 #define OBD_FAIL_SEQ_EXHAUST 0x1002
12634 $LCTL set_param fail_loc=0x80001002
12635 # 20000 files can guarantee there are index nodes in the OI file
12636 createmany -o $myDIR/t- 20000
12637 $LCTL set_param fail_loc=0
12638 # The guard is current the largest FID holder
12640 local SEQ=$($LFS path2fid $myDIR/guard | awk -F ':' '{print $1}' |
12642 local IDX=$(($SEQ % 64))
12644 do_facet $SINGLEMDS sync
12645 # Make sure journal flushed.
12647 local blk1=$(do_facet $SINGLEMDS \
12648 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
12649 grep Blockcount | awk '{print $4}')
12651 # Remove old files, some OI blocks will become idle.
12652 unlinkmany $myDIR/t- 20000
12654 # The OI file should become empty now
12656 # Create new files, idle OI blocks should be reused.
12657 createmany -o $myDIR/t- 2000
12658 do_facet $SINGLEMDS sync
12659 # Make sure journal flushed.
12661 local blk2=$(do_facet $SINGLEMDS \
12662 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
12663 grep Blockcount | awk '{print $4}')
12665 [ $blk1 == $blk2 ] || error "old blk1=$blk1, new blk2=$blk2, unmatched!"
12667 run_test 228c "NOT shrink the last entry in OI index node to recycle idle leaf"
12669 test_229() { # LU-2482, LU-3448
12670 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.53) ] &&
12671 skip "No HSM $(lustre_build_version $SINGLEMDS) MDS < 2.4.53" &&
12673 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12674 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs" && return
12678 # Create a file with a released layout and stripe count 2.
12679 $MULTIOP $DIR/$tfile H2c ||
12680 error "failed to create file with released layout"
12682 $GETSTRIPE -v $DIR/$tfile
12684 local pattern=$($GETSTRIPE -L $DIR/$tfile)
12685 [ X"$pattern" = X"80000001" ] || error "pattern error ($pattern)"
12687 local stripe_count=$($GETSTRIPE -c $DIR/$tfile) || error "getstripe"
12688 [ $stripe_count -eq 2 ] || error "stripe count not 2 ($stripe_count)"
12689 stat $DIR/$tfile || error "failed to stat released file"
12691 chown $RUNAS_ID $DIR/$tfile ||
12692 error "chown $RUNAS_ID $DIR/$tfile failed"
12694 chgrp $RUNAS_ID $DIR/$tfile ||
12695 error "chgrp $RUNAS_ID $DIR/$tfile failed"
12697 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
12698 rm $DIR/$tfile || error "failed to remove released file"
12700 run_test 229 "getstripe/stat/rm/attr changes work on released files"
12703 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12704 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
12707 test_mkdir $DIR/$tdir
12708 test_mkdir -i0 -c1 $DIR/$tdir/test_230_local
12709 local mdt_idx=$($GETSTRIPE -M $DIR/$tdir/test_230_local)
12710 [ $mdt_idx -ne 0 ] &&
12711 error "create local directory on wrong MDT $mdt_idx"
12713 $LFS mkdir -i $MDTIDX $DIR/$tdir/test_230 ||
12714 error "create remote directory failed"
12715 local mdt_idx=$($GETSTRIPE -M $DIR/$tdir/test_230)
12716 [ $mdt_idx -ne $MDTIDX ] &&
12717 error "create remote directory on wrong MDT $mdt_idx"
12719 createmany -o $DIR/$tdir/test_230/t- 10 ||
12720 error "create files on remote directory failed"
12721 mdt_idx=$($GETSTRIPE -M $DIR/$tdir/test_230/t-0)
12722 [ $mdt_idx -ne $MDTIDX ] && error "create files on wrong MDT $mdt_idx"
12723 rm -r $DIR/$tdir || error "unlink remote directory failed"
12725 run_test 230a "Create remote directory and files under the remote directory"
12728 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12729 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
12736 local migrate_dir=$DIR/$tdir/migrate_dir
12737 local other_dir=$DIR/$tdir/other_dir
12739 test_mkdir $DIR/$tdir
12740 test_mkdir -i0 -c1 $migrate_dir
12741 test_mkdir -i0 -c1 $other_dir
12742 for ((i=0; i<10; i++)); do
12743 mkdir -p $migrate_dir/dir_${i}
12744 createmany -o $migrate_dir/dir_${i}/f 10 ||
12745 error "create files under remote dir failed $i"
12748 cp /etc/passwd $migrate_dir/$tfile
12749 cp /etc/passwd $other_dir/$tfile
12750 chattr +SAD $migrate_dir
12751 chattr +SAD $migrate_dir/$tfile
12753 local old_dir_flag=$(lsattr -a $migrate_dir | awk '/\/\.$/ {print $1}')
12754 local old_file_flag=$(lsattr $migrate_dir/$tfile | awk '{print $1}')
12755 local old_dir_mode=$(stat -c%f $migrate_dir)
12756 local old_file_mode=$(stat -c%f $migrate_dir/$tfile)
12758 mkdir -p $migrate_dir/dir_default_stripe2
12759 $SETSTRIPE -c 2 $migrate_dir/dir_default_stripe2
12760 $SETSTRIPE -c 2 $migrate_dir/${tfile}_stripe2
12762 mkdir -p $other_dir
12763 ln $migrate_dir/$tfile $other_dir/luna
12764 ln $migrate_dir/$tfile $migrate_dir/sofia
12765 ln $other_dir/$tfile $migrate_dir/david
12766 ln -s $migrate_dir/$tfile $other_dir/zachary
12767 ln -s $migrate_dir/$tfile $migrate_dir/${tfile}_ln
12768 ln -s $other_dir/$tfile $migrate_dir/${tfile}_ln_other
12770 $LFS migrate -m $MDTIDX $migrate_dir ||
12771 error "fails on migrating remote dir to MDT1"
12773 echo "migratate to MDT1, then checking.."
12774 for ((i = 0; i < 10; i++)); do
12775 for file in $(find $migrate_dir/dir_${i}); do
12776 mdt_index=$($LFS getstripe -M $file)
12777 [ $mdt_index == $MDTIDX ] ||
12778 error "$file is not on MDT${MDTIDX}"
12782 # the multiple link file should still in MDT0
12783 mdt_index=$($LFS getstripe -M $migrate_dir/$tfile)
12784 [ $mdt_index == 0 ] ||
12785 error "$file is not on MDT${MDTIDX}"
12787 local new_dir_flag=$(lsattr -a $migrate_dir | awk '/\/\.$/ {print $1}')
12788 [ "$old_dir_flag" = "$new_dir_flag" ] ||
12789 error " expect $old_dir_flag get $new_dir_flag"
12791 local new_file_flag=$(lsattr $migrate_dir/$tfile | awk '{print $1}')
12792 [ "$old_file_flag" = "$new_file_flag" ] ||
12793 error " expect $old_file_flag get $new_file_flag"
12795 local new_dir_mode=$(stat -c%f $migrate_dir)
12796 [ "$old_dir_mode" = "$new_dir_mode" ] ||
12797 error "expect mode $old_dir_mode get $new_dir_mode"
12799 local new_file_mode=$(stat -c%f $migrate_dir/$tfile)
12800 [ "$old_file_mode" = "$new_file_mode" ] ||
12801 error "expect mode $old_file_mode get $new_file_mode"
12803 diff /etc/passwd $migrate_dir/$tfile ||
12804 error "$tfile different after migration"
12806 diff /etc/passwd $other_dir/luna ||
12807 error "luna different after migration"
12809 diff /etc/passwd $migrate_dir/sofia ||
12810 error "sofia different after migration"
12812 diff /etc/passwd $migrate_dir/david ||
12813 error "david different after migration"
12815 diff /etc/passwd $other_dir/zachary ||
12816 error "zachary different after migration"
12818 diff /etc/passwd $migrate_dir/${tfile}_ln ||
12819 error "${tfile}_ln different after migration"
12821 diff /etc/passwd $migrate_dir/${tfile}_ln_other ||
12822 error "${tfile}_ln_other different after migration"
12824 stripe_count=$($LFS getstripe -c $migrate_dir/dir_default_stripe2)
12825 [ $stripe_count = 2 ] ||
12826 error "dir strpe_count $d != 2 after migration."
12828 stripe_count=$($LFS getstripe -c $migrate_dir/${tfile}_stripe2)
12829 [ $stripe_count = 2 ] ||
12830 error "file strpe_count $d != 2 after migration."
12832 #migrate back to MDT0
12835 $LFS migrate -m $MDTIDX $migrate_dir ||
12836 error "fails on migrating remote dir to MDT0"
12838 echo "migrate back to MDT0, checking.."
12839 for file in $(find $migrate_dir); do
12840 mdt_index=$($LFS getstripe -M $file)
12841 [ $mdt_index == $MDTIDX ] ||
12842 error "$file is not on MDT${MDTIDX}"
12845 local new_dir_flag=$(lsattr -a $migrate_dir | awk '/\/\.$/ {print $1}')
12846 [ "$old_dir_flag" = "$new_dir_flag" ] ||
12847 error " expect $old_dir_flag get $new_dir_flag"
12849 local new_file_flag=$(lsattr $migrate_dir/$tfile | awk '{print $1}')
12850 [ "$old_file_flag" = "$new_file_flag" ] ||
12851 error " expect $old_file_flag get $new_file_flag"
12853 local new_dir_mode=$(stat -c%f $migrate_dir)
12854 [ "$old_dir_mode" = "$new_dir_mode" ] ||
12855 error "expect mode $old_dir_mode get $new_dir_mode"
12857 local new_file_mode=$(stat -c%f $migrate_dir/$tfile)
12858 [ "$old_file_mode" = "$new_file_mode" ] ||
12859 error "expect mode $old_file_mode get $new_file_mode"
12861 diff /etc/passwd ${migrate_dir}/$tfile ||
12862 error "$tfile different after migration"
12864 diff /etc/passwd ${other_dir}/luna ||
12865 error "luna different after migration"
12867 diff /etc/passwd ${migrate_dir}/sofia ||
12868 error "sofia different after migration"
12870 diff /etc/passwd ${other_dir}/zachary ||
12871 error "zachary different after migration"
12873 diff /etc/passwd $migrate_dir/${tfile}_ln ||
12874 error "${tfile}_ln different after migration"
12876 diff /etc/passwd $migrate_dir/${tfile}_ln_other ||
12877 error "${tfile}_ln_other different after migration"
12879 stripe_count=$($LFS getstripe -c ${migrate_dir}/dir_default_stripe2)
12880 [ $stripe_count = 2 ] ||
12881 error "dir strpe_count $d != 2 after migration."
12883 stripe_count=$($LFS getstripe -c ${migrate_dir}/${tfile}_stripe2)
12884 [ $stripe_count = 2 ] ||
12885 error "file strpe_count $d != 2 after migration."
12887 rm -rf $DIR/$tdir || error "rm dir failed after migration"
12889 run_test 230b "migrate directory"
12892 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12893 remote_mds_nodsh && skip "remote MDS with nodsh" && return
12894 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
12898 local migrate_dir=$DIR/$tdir/migrate_dir
12900 #If migrating directory fails in the middle, all entries of
12901 #the directory is still accessiable.
12902 test_mkdir $DIR/$tdir
12903 test_mkdir -i0 -c1 $migrate_dir
12905 createmany -o $migrate_dir/f 10 ||
12906 error "create files under ${migrate_dir} failed"
12908 #failed after migrating 5 entries
12909 #OBD_FAIL_MIGRATE_ENTRIES 0x1801
12910 do_facet mds1 lctl set_param fail_loc=0x20001801
12911 do_facet mds1 lctl set_param fail_val=5
12912 local t=$(ls $migrate_dir | wc -l)
12913 $LFS migrate --mdt-index $MDTIDX $migrate_dir &&
12914 error "migrate should fail after 5 entries"
12916 mkdir $migrate_dir/dir &&
12917 error "mkdir succeeds under migrating directory"
12918 touch $migrate_dir/file &&
12919 error "touch file succeeds under migrating directory"
12921 local u=$(ls $migrate_dir | wc -l)
12922 [ "$u" == "$t" ] || error "$u != $t during migration"
12924 for file in $(find $migrate_dir); do
12925 stat $file || error "stat $file failed"
12928 do_facet mds1 lctl set_param fail_loc=0
12929 do_facet mds1 lctl set_param fail_val=0
12931 $LFS migrate -m $MDTIDX $migrate_dir ||
12932 error "migrate open files should failed with open files"
12934 echo "Finish migration, then checking.."
12935 for file in $(find $migrate_dir); do
12936 mdt_index=$($LFS getstripe -M $file)
12937 [ $mdt_index == $MDTIDX ] ||
12938 error "$file is not on MDT${MDTIDX}"
12941 rm -rf $DIR/$tdir || error "rm dir failed after migration"
12943 run_test 230c "check directory accessiblity if migration is failed"
12946 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12947 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
12950 local migrate_dir=$DIR/$tdir/migrate_dir
12954 test_mkdir $DIR/$tdir
12955 test_mkdir -i0 -c1 $migrate_dir
12957 for ((i=0; i<100; i++)); do
12958 test_mkdir -i0 -c1 $migrate_dir/dir_${i}
12959 createmany -o $migrate_dir/dir_${i}/f 100 ||
12960 error "create files under remote dir failed $i"
12963 $LFS migrate -m $MDTIDX $migrate_dir ||
12964 error "migrate remote dir error"
12966 echo "Finish migration, then checking.."
12967 for file in $(find $migrate_dir); do
12968 mdt_index=$($LFS getstripe -M $file)
12969 [ $mdt_index == $MDTIDX ] ||
12970 error "$file is not on MDT${MDTIDX}"
12973 rm -rf $DIR/$tdir || error "rm dir failed after migration"
12975 run_test 230d "check migrate big directory"
12978 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12979 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
12985 mkdir -p $DIR/$tdir
12986 mkdir $DIR/$tdir/migrate_dir
12987 mkdir $DIR/$tdir/other_dir
12988 touch $DIR/$tdir/migrate_dir/a
12989 ln $DIR/$tdir/migrate_dir/a $DIR/$tdir/other_dir/b
12990 ls $DIR/$tdir/other_dir
12992 $LFS migrate -m 1 $DIR/$tdir/migrate_dir ||
12993 error "migrate dir fails"
12995 mdt_index=$($LFS getstripe -M $DIR/$tdir/migrate_dir)
12996 [ $mdt_index == 1 ] || error "migrate_dir is not on MDT1"
12998 mdt_index=$($LFS getstripe -M $DIR/$tdir/migrate_dir/a)
12999 [ $mdt_index == 0 ] || error "a is not on MDT0"
13001 $LFS migrate -m 1 $DIR/$tdir/other_dir ||
13002 error "migrate dir fails"
13004 mdt_index=$($LFS getstripe -M $DIR/$tdir/other_dir)
13005 [ $mdt_index == 1 ] || error "other_dir is not on MDT1"
13007 mdt_index=$($LFS getstripe -M $DIR/$tdir/migrate_dir/a)
13008 [ $mdt_index == 1 ] || error "a is not on MDT1"
13010 mdt_index=$($LFS getstripe -M $DIR/$tdir/other_dir/b)
13011 [ $mdt_index == 1 ] || error "b is not on MDT1"
13013 a_fid=$($LFS path2fid $DIR/$tdir/migrate_dir/a)
13014 b_fid=$($LFS path2fid $DIR/$tdir/other_dir/b)
13016 [ "$a_fid" = "$b_fid" ] || error "different fid after migration"
13018 rm -rf $DIR/$tdir || error "rm dir failed after migration"
13020 run_test 230e "migrate mulitple local link files"
13023 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13024 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
13028 mkdir -p $DIR/$tdir
13029 mkdir $DIR/$tdir/migrate_dir
13030 $LFS mkdir -i1 $DIR/$tdir/other_dir
13031 touch $DIR/$tdir/migrate_dir/a
13032 ln $DIR/$tdir/migrate_dir/a $DIR/$tdir/other_dir/ln1
13033 ln $DIR/$tdir/migrate_dir/a $DIR/$tdir/other_dir/ln2
13034 ls $DIR/$tdir/other_dir
13036 # a should be migrated to MDT1, since no other links on MDT0
13037 $LFS migrate -m 1 $DIR/$tdir/migrate_dir ||
13038 error "migrate dir fails"
13039 mdt_index=$($LFS getstripe -M $DIR/$tdir/migrate_dir)
13040 [ $mdt_index == 1 ] || error "migrate_dir is not on MDT1"
13041 mdt_index=$($LFS getstripe -M $DIR/$tdir/migrate_dir/a)
13042 [ $mdt_index == 1 ] || error "a is not on MDT1"
13044 # a should stay on MDT1, because it is a mulitple link file
13045 $LFS migrate -m 0 $DIR/$tdir/migrate_dir ||
13046 error "migrate dir fails"
13047 mdt_index=$($LFS getstripe -M $DIR/$tdir/migrate_dir/a)
13048 [ $mdt_index == 1 ] || error "a is not on MDT1"
13050 $LFS migrate -m 1 $DIR/$tdir/migrate_dir ||
13051 error "migrate dir fails"
13053 a_fid=$($LFS path2fid $DIR/$tdir/migrate_dir/a)
13054 ln_fid=$($LFS path2fid $DIR/$tdir/other_dir/ln1)
13055 [ "$a_fid" = "$ln_fid" ] || error "different fid after migrate to MDT1"
13057 rm -rf $DIR/$tdir/other_dir/ln1 || error "unlink ln1 fails"
13058 rm -rf $DIR/$tdir/other_dir/ln2 || error "unlink ln2 fails"
13060 # a should be migrated to MDT0, since no other links on MDT1
13061 $LFS migrate -m 0 $DIR/$tdir/migrate_dir ||
13062 error "migrate dir fails"
13063 mdt_index=$($LFS getstripe -M $DIR/$tdir/migrate_dir/a)
13064 [ $mdt_index == 0 ] || error "a is not on MDT0"
13066 rm -rf $DIR/$tdir || error "rm dir failed after migration"
13068 run_test 230f "migrate mulitple remote link files"
13071 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13072 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
13074 mkdir -p $DIR/$tdir/migrate_dir
13076 $LFS migrate -m 1000 $DIR/$tdir/migrate_dir &&
13077 error "migrating dir to non-exist MDT succeeds"
13080 run_test 230g "migrate dir to non-exist MDT"
13083 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13084 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
13085 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.64) ] &&
13086 skip "Need MDS version at least 2.7.64" && return
13089 mkdir -p $DIR/$tdir/migrate_dir
13091 $LFS migrate -m1 $DIR &&
13092 error "migrating mountpoint1 should fail"
13094 $LFS migrate -m1 $DIR/$tdir/.. &&
13095 error "migrating mountpoint2 should fail"
13097 $LFS migrate -m1 $DIR/$tdir/migrate_dir/.. ||
13098 error "migrating $tdir fail"
13100 mdt_index=$($LFS getstripe -M $DIR/$tdir)
13101 [ $mdt_index == 1 ] || error "$mdt_index != 1 after migration"
13103 mdt_index=$($LFS getstripe -M $DIR/$tdir/migrate_dir)
13104 [ $mdt_index == 1 ] || error "$mdt_index != 1 after migration"
13107 run_test 230h "migrate .. and root"
13111 # For simplicity this test assumes that max_pages_per_rpc
13112 # is the same across all OSCs
13113 local max_pages=$($LCTL get_param -n osc.*.max_pages_per_rpc | head -n1)
13114 local bulk_size=$((max_pages * 4096))
13116 mkdir -p $DIR/$tdir
13118 # clear the OSC stats
13119 $LCTL set_param osc.*.stats=0 &>/dev/null
13121 # Client writes $bulk_size - there must be 1 rpc for $max_pages.
13122 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=$bulk_size count=1 \
13123 oflag=direct &>/dev/null || error "dd failed"
13125 local nrpcs=$($LCTL get_param osc.*.stats |awk '/ost_write/ {print $2}')
13126 if [ x$nrpcs != "x1" ]; then
13127 error "found $nrpc ost_write RPCs, not 1 as expected"
13130 # Drop the OSC cache, otherwise we will read from it
13131 cancel_lru_locks osc
13133 # clear the OSC stats
13134 $LCTL set_param osc.*.stats=0 &>/dev/null
13136 # Client reads $bulk_size.
13137 dd if=$DIR/$tdir/$tfile of=/dev/null bs=$bulk_size count=1 \
13138 iflag=direct &>/dev/null || error "dd failed"
13140 nrpcs=$($LCTL get_param osc.*.stats | awk '/ost_read/ { print $2 }')
13141 if [ x$nrpcs != "x1" ]; then
13142 error "found $nrpc ost_read RPCs, not 1 as expected"
13145 run_test 231a "checking that reading/writing of BRW RPC size results in one RPC"
13148 mkdir -p $DIR/$tdir
13150 for i in {0..1023}; do
13151 dd if=/dev/zero of=$DIR/$tdir/$tfile conv=notrunc \
13152 seek=$((2 * i)) bs=4096 count=1 &>/dev/null ||
13153 error "dd of=$DIR/$tdir/$tfile seek=$((2 * i)) failed"
13157 run_test 231b "must not assert on fully utilized OST request buffer"
13160 mkdir -p $DIR/$tdir
13161 #define OBD_FAIL_LDLM_OST_LVB 0x31c
13162 $LCTL set_param fail_loc=0x31c
13164 # ignore dd failure
13165 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=1 || true
13167 $LCTL set_param fail_loc=0
13168 umount_client $MOUNT || error "umount failed"
13169 mount_client $MOUNT || error "mount failed"
13171 run_test 232 "failed lock should not block umount"
13174 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.3.64) ] ||
13175 { skip "Need MDS version at least 2.3.64"; return; }
13177 local fid=$($LFS path2fid $MOUNT)
13178 stat $MOUNT/.lustre/fid/$fid > /dev/null ||
13179 error "cannot access $MOUNT using its FID '$fid'"
13181 run_test 233a "checking that OBF of the FS root succeeds"
13184 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.5.90) ] ||
13185 { skip "Need MDS version at least 2.5.90"; return; }
13187 local fid=$($LFS path2fid $MOUNT/.lustre)
13188 stat $MOUNT/.lustre/fid/$fid > /dev/null ||
13189 error "cannot access $MOUNT/.lustre using its FID '$fid'"
13191 fid=$($LFS path2fid $MOUNT/.lustre/fid)
13192 stat $MOUNT/.lustre/fid/$fid > /dev/null ||
13193 error "cannot access $MOUNT/.lustre/fid using its FID '$fid'"
13195 run_test 233b "checking that OBF of the FS .lustre succeeds"
13198 local p="$TMP/sanityN-$TESTNAME.parameters"
13199 save_lustre_params client "llite.*.xattr_cache" > $p
13200 lctl set_param llite.*.xattr_cache 1 ||
13201 { skip "xattr cache is not supported"; return 0; }
13203 mkdir -p $DIR/$tdir || error "mkdir failed"
13204 touch $DIR/$tdir/$tfile || error "touch failed"
13205 # OBD_FAIL_LLITE_XATTR_ENOMEM
13206 $LCTL set_param fail_loc=0x1405
13207 # output of the form: attr 2 4 44 3 fc13 x86_64
13208 V=($(IFS=".-" rpm -q attr))
13209 if [[ ${V[1]} > 2 || ${V[2]} > 4 || ${V[3]} > 44 ||
13210 ${V[1]} = 2 && ${V[2]} = 4 && ${V[3]} = 44 && ${V[4]} > 6 ]]; then
13211 # attr pre-2.4.44-7 had a bug with rc
13212 # LU-3703 - SLES 11 and FC13 clients have older attr
13213 getfattr -n user.attr $DIR/$tdir/$tfile &&
13214 error "getfattr should have failed with ENOMEM"
13216 skip "LU-3703: attr version $(getfattr --version) too old"
13218 $LCTL set_param fail_loc=0x0
13221 restore_lustre_params < $p
13224 run_test 234 "xattr cache should not crash on ENOMEM"
13227 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.52) ] &&
13228 skip "Need MDS version at least 2.4.52" && return
13229 flock_deadlock $DIR/$tfile
13234 124) error "process hangs on a deadlock"
13236 *) error "error executing flock_deadlock $DIR/$tfile"
13240 run_test 235 "LU-1715: flock deadlock detection does not work properly"
13244 check_swap_layouts_support && return 0
13245 test_mkdir -p -c1 $DIR/$tdir || error "mkdir $tdir failed"
13247 local ref1=/etc/passwd
13248 local ref2=/etc/group
13249 local file1=$DIR/$tdir/f1
13250 local file2=$DIR/$tdir/f2
13252 $SETSTRIPE -c 1 $file1 || error "cannot setstripe on '$file1': rc = $?"
13253 cp $ref1 $file1 || error "cp $ref1 $file1 failed: rc = $?"
13254 $SETSTRIPE -c 2 $file2 || error "cannot setstripe on '$file2': rc = $?"
13255 cp $ref2 $file2 || error "cp $ref2 $file2 failed: rc = $?"
13256 local fd=$(free_fd)
13257 local cmd="exec $fd<>$file2"
13260 $LFS swap_layouts $file1 /proc/self/fd/${fd} ||
13261 error "cannot swap layouts of '$file1' and /proc/self/fd/${fd}"
13264 cmp $ref2 $file1 || error "content compare failed ($ref2 != $file1)"
13269 run_test 236 "Layout swap on open unlinked file"
13271 # test to verify file handle related system calls
13272 # (name_to_handle_at/open_by_handle_at)
13273 # The new system calls are supported in glibc >= 2.14.
13276 echo "Test file_handle syscalls" > $DIR/$tfile ||
13277 error "write failed"
13278 check_fhandle_syscalls $DIR/$tfile ||
13279 error "check_fhandle_syscalls failed"
13281 run_test 237 "Verify name_to_handle_at/open_by_handle_at syscalls"
13283 # LU-4659 linkea consistency
13285 local server_version=$(lustre_version_code $SINGLEMDS)
13287 [[ $server_version -gt $(version_code 2.5.57) ]] ||
13288 [[ $server_version -gt $(version_code 2.5.1) &&
13289 $server_version -lt $(version_code 2.5.50) ]] ||
13290 { skip "Need MDS version at least 2.5.58 or 2.5.2+"; return; }
13293 ln $DIR/$tfile $DIR/$tfile.lnk
13294 touch $DIR/$tfile.new
13295 mv $DIR/$tfile.new $DIR/$tfile
13296 local fid1=$($LFS path2fid $DIR/$tfile)
13297 local fid2=$($LFS path2fid $DIR/$tfile.lnk)
13298 local path1=$($LFS fid2path $FSNAME "$fid1")
13299 [ $tfile == $path1 ] || error "linkea inconsistent: $tfile $fid1 $path1"
13300 local path2=$($LFS fid2path $FSNAME "$fid2")
13301 [ $tfile.lnk == $path2 ] ||
13302 error "linkea inconsistent: $tfile.lnk $fid2 $path2!"
13305 run_test 238 "Verify linkea consistency"
13308 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.5.60) ] &&
13309 skip "Need MDS version at least 2.5.60" && return
13310 local list=$(comma_list $(mdts_nodes))
13312 mkdir -p $DIR/$tdir
13313 createmany -o $DIR/$tdir/f- 5000
13314 unlinkmany $DIR/$tdir/f- 5000
13315 do_nodes $list "lctl set_param -n osp*.*.sync_changes 1"
13316 changes=$(do_nodes $list "lctl get_param -n osc.*MDT*.sync_changes \
13317 osc.*MDT*.sync_in_flight" | calc_sum)
13318 [ "$changes" -eq 0 ] || error "$changes not synced"
13320 run_test 239 "osp_sync test"
13322 test_239a() { #LU-5297
13324 #define OBD_FAIL_OSP_CHECK_INVALID_REC 0x2100
13325 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x2100
13326 chgrp $RUNAS_GID $DIR/$tfile
13327 wait_delete_completed
13329 run_test 239a "process invalid osp sync record correctly"
13331 test_239b() { #LU-5297
13333 #define OBD_FAIL_OSP_CHECK_ENOMEM 0x2101
13334 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x2101
13335 chgrp $RUNAS_GID $DIR/$tfile1
13336 wait_delete_completed
13337 do_facet $SINGLEMDS $LCTL set_param fail_loc=0
13339 chgrp $RUNAS_GID $DIR/$tfile2
13340 wait_delete_completed
13342 run_test 239b "process osp sync record with ENOMEM error correctly"
13345 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
13347 mkdir -p $DIR/$tdir
13349 $LFS mkdir -i 0 $DIR/$tdir/d0 ||
13350 error "failed to mkdir $DIR/$tdir/d0 on MDT0"
13351 $LFS mkdir -i 1 $DIR/$tdir/d0/d1 ||
13352 error "failed to mkdir $DIR/$tdir/d0/d1 on MDT1"
13354 umount_client $MOUNT || error "umount failed"
13355 #define OBD_FAIL_TGT_DELAY_CONDITIONAL 0x713
13356 do_facet mds2 lctl set_param fail_loc=0x713 fail_val=1
13357 mount_client $MOUNT || error "failed to mount client"
13359 echo "stat $DIR/$tdir/d0/d1, should not fail/ASSERT"
13360 stat $DIR/$tdir/d0/d1 || error "fail to stat $DIR/$tdir/d0/d1"
13362 run_test 240 "race between ldlm enqueue and the connection RPC (no ASSERT)"
13365 for LOOP in $(seq $1); do
13366 dd if=$DIR/$tfile of=/dev/null bs=40960 count=1 2>/dev/null
13367 cancel_lru_locks osc
13372 for LOOP in $(seq $1); do
13373 dd if=$DIR/$tfile of=/dev/null bs=40960 count=1 \
13374 iflag=direct 2>/dev/null
13379 dd if=/dev/zero of=$DIR/$tfile count=1 bs=40960
13381 cancel_lru_locks osc
13382 test_241_bio 1000 &
13387 run_test 241 "bio vs dio"
13390 dd if=/dev/zero of=$DIR/$tfile count=1 bs=40960
13392 test_241_dio 1000 &
13397 run_test 241b "dio vs dio"
13400 mkdir -p $DIR/$tdir
13401 touch $DIR/$tdir/$tfile
13403 #define OBD_FAIL_MDS_READPAGE_PACK 0x105
13404 do_facet mds1 lctl set_param fail_loc=0x105
13405 /bin/ls $DIR/$tdir && error "ls $DIR/$tdir should fail"
13407 do_facet mds1 lctl set_param fail_loc=0
13408 /bin/ls $DIR/$tdir || error "ls $DIR/$tdir failed"
13410 run_test 242 "mdt_readpage failure should not cause directory unreadable"
13414 test_mkdir -p $DIR/$tdir
13415 group_lock_test -d $DIR/$tdir || error "A group lock test failed"
13417 run_test 243 "various group lock tests"
13421 test_mkdir -p $DIR/$tdir
13422 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=35
13423 sendfile_grouplock $DIR/$tdir/$tfile || \
13424 error "sendfile+grouplock failed"
13427 run_test 244 "sendfile with group lock tests"
13430 local flagname="multi_mod_rpcs"
13431 local connect_data_name="max_mod_rpcs"
13434 # check if multiple modify RPCs flag is set
13435 out=$($LCTL get_param mdc.$FSNAME-MDT0000-*.import |
13436 grep "connect_flags:")
13439 echo "$out" | grep -qw $flagname
13440 if [ $? -ne 0 ]; then
13441 echo "connect flag $flagname is not set"
13445 # check if multiple modify RPCs data is set
13446 out=$($LCTL get_param mdc.$FSNAME-MDT0000-*.import)
13449 echo "$out" | grep -qw $connect_data_name ||
13450 error "import should have connect data $connect_data_name"
13452 run_test 245 "check mdc connection flag/data: multiple modify RPCs"
13454 test_246() { # LU-7371
13455 [ $(lustre_version_code ost1) -lt $(version_code 2.7.62) ] &&
13456 skip "Need OST version >= 2.7.62" && return 0
13457 do_facet ost1 $LCTL set_param fail_val=4095
13458 #define OBD_FAIL_OST_READ_SIZE 0x234
13459 do_facet ost1 $LCTL set_param fail_loc=0x234
13460 $LFS setstripe $DIR/$tfile -i 0 -c 1
13461 dd if=/dev/zero of=$DIR/$tfile bs=4095 count=1 > /dev/null 2>&1
13462 cancel_lru_locks $FSNAME-OST0000
13463 dd if=$DIR/$tfile of=/dev/null bs=1048576 || error "Read failed"
13465 run_test 246 "Read file of size 4095 should return right length"
13468 [ "$(facet_fstype ost$(($($GETSTRIPE -i $DIR/$tfile) + 1)))" = "zfs" ] \
13469 && skip "no 16TB file size limit on ZFS" && return
13471 $SETSTRIPE -c 1 $DIR/$tfile
13472 # ldiskfs extent file size limit is (16TB - 4KB - 1) bytes
13473 local size=$((16 * 1024 * 1024 * 1024 * 1024 - 4096 - 1))
13474 $TRUNCATE $DIR/$tfile $size || error "truncate $tfile to $size failed"
13475 dd if=/dev/zero of=$DIR/$tfile bs=10 count=1 oflag=append \
13476 conv=notrunc,fsync && error "append succeeded"
13479 run_test 250 "Write above 16T limit"
13482 $SETSTRIPE -c -1 -S 1048576 $DIR/$tfile
13484 #define OBD_FAIL_LLITE_LOST_LAYOUT 0x1407
13485 #Skip once - writing the first stripe will succeed
13486 $LCTL set_param fail_loc=0xa0001407 fail_val=1
13487 $MULTIOP $DIR/$tfile o:O_RDWR:w2097152c 2>&1 | grep -q "short write" &&
13488 error "short write happened"
13490 $LCTL set_param fail_loc=0xa0001407 fail_val=1
13491 $MULTIOP $DIR/$tfile or2097152c 2>&1 | grep -q "short read" &&
13492 error "short read happened"
13496 run_test 251 "Handling short read and write correctly"
13506 if [ "$(facet_fstype ost1)" != "ldiskfs" -o \
13507 "$(facet_fstype mds1)" != "ldiskfs" ]; then
13508 skip "can only run lr_reader on ldiskfs target"
13512 # check lr_reader on OST0000
13514 dev=$(facet_device $tgt)
13515 out=$(do_facet $tgt $LR_READER $dev)
13516 [ $? -eq 0 ] || error "$LR_READER failed on target $tgt device $dev"
13518 uuid=$(echo "$out" | grep -i uuid | awk '{ print $2 }')
13519 [ "$uuid" == "$(ostuuid_from_index 0)" ] ||
13520 error "Invalid uuid returned by $LR_READER on target $tgt"
13521 echo -e "uuid returned by $LR_READER is '$uuid'\n"
13523 # check lr_reader -c on MDT0000
13525 dev=$(facet_device $tgt)
13526 if ! do_facet $tgt $LR_READER -h | grep -q OPTIONS; then
13527 echo "$LR_READER does not support additional options"
13530 out=$(do_facet $tgt $LR_READER -c $dev)
13531 [ $? -eq 0 ] || error "$LR_READER failed on target $tgt device $dev"
13533 num=$(echo "$out" | grep -c "mdtlov")
13534 [ "$num" -eq $((MDSCOUNT - 1)) ] ||
13535 error "Invalid number of mdtlov clients returned by $LR_READER"
13536 echo -e "Number of mdtlov clients returned by $LR_READER is '$num'\n"
13538 # check lr_reader -cr on MDT0000
13539 out=$(do_facet $tgt $LR_READER -cr $dev)
13540 [ $? -eq 0 ] || error "$LR_READER failed on target $tgt device $dev"
13542 echo "$out" | grep -q "^reply_data:$" ||
13543 error "$LR_READER should have returned 'reply_data' section"
13544 num=$(echo "$out" | grep -c "client_generation")
13545 echo -e "Number of reply data returned by $LR_READER is '$num'\n"
13547 run_test 252 "check lr_reader tool"
13550 cleanup_test_300() {
13554 test_striped_dir() {
13559 mkdir -p $DIR/$tdir
13561 SAVE_UMASK=$(umask)
13562 trap cleanup_test_300 RETURN EXIT
13564 $LFS setdirstripe -i $mdt_index -c 2 -t all_char -m 755 \
13565 $DIR/$tdir/striped_dir ||
13566 error "set striped dir error"
13568 local mode=$(stat -c%a $DIR/$tdir/striped_dir)
13569 [ "$mode" = "755" ] || error "expect 755 got $mode"
13571 $LFS getdirstripe $DIR/$tdir/striped_dir > /dev/null 2>&1 ||
13572 error "getdirstripe failed"
13573 stripe_count=$($LFS getdirstripe -c $DIR/$tdir/striped_dir)
13574 if [ "$stripe_count" != "2" ]; then
13575 error "stripe_count is $stripe_count, expect 2"
13578 stripe_index=$($LFS getdirstripe -i $DIR/$tdir/striped_dir)
13579 if [ "$stripe_index" != "$mdt_index" ]; then
13580 error "stripe_index is $stripe_index, expect $mdt_index"
13583 [ $(stat -c%h $DIR/$tdir/striped_dir) == '2' ] ||
13584 error "nlink error after create striped dir"
13586 mkdir $DIR/$tdir/striped_dir/a
13587 mkdir $DIR/$tdir/striped_dir/b
13589 stat $DIR/$tdir/striped_dir/a ||
13590 error "create dir under striped dir failed"
13591 stat $DIR/$tdir/striped_dir/b ||
13592 error "create dir under striped dir failed"
13594 [ $(stat -c%h $DIR/$tdir/striped_dir) == '4' ] ||
13595 error "nlink error after mkdir"
13597 rmdir $DIR/$tdir/striped_dir/a
13598 [ $(stat -c%h $DIR/$tdir/striped_dir) == '3' ] ||
13599 error "nlink error after rmdir"
13601 rmdir $DIR/$tdir/striped_dir/b
13602 [ $(stat -c%h $DIR/$tdir/striped_dir) == '2' ] ||
13603 error "nlink error after rmdir"
13605 chattr +i $DIR/$tdir/striped_dir
13606 createmany -o $DIR/$tdir/striped_dir/f 10 &&
13607 error "immutable flags not working under striped dir!"
13608 chattr -i $DIR/$tdir/striped_dir
13610 rmdir $DIR/$tdir/striped_dir ||
13611 error "rmdir striped dir error"
13619 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13620 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
13622 test_striped_dir 0 || error "failed on striped dir on MDT0"
13623 test_striped_dir 1 || error "failed on striped dir on MDT0"
13625 run_test 300a "basic striped dir sanity test"
13628 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13629 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
13635 test_mkdir $DIR/$tdir || error "mkdir fail"
13636 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir ||
13637 error "set striped dir error"
13638 for ((i=0; i<10; i++)); do
13639 mtime1=$(stat -c %Y $DIR/$tdir/striped_dir)
13641 touch $DIR/$tdir/striped_dir/file_$i ||
13642 error "touch error $i"
13643 mtime2=$(stat -c %Y $DIR/$tdir/striped_dir)
13644 [ $mtime1 -eq $mtime2 ] &&
13645 error "mtime not change after create"
13647 rm -f $DIR/$tdir/striped_dir/file_$i ||
13648 error "unlink error $i"
13649 mtime3=$(stat -c %Y $DIR/$tdir/striped_dir)
13650 [ $mtime2 -eq $mtime3 ] &&
13651 error "mtime did not change after unlink"
13655 run_test 300b "check ctime/mtime for striped dir"
13658 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13659 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
13662 mkdir -p $DIR/$tdir
13663 $LFS setdirstripe -i 0 -c 2 $DIR/$tdir/striped_dir ||
13664 error "set striped dir error"
13666 chown $RUNAS_ID:$RUNAS_GID $DIR/$tdir/striped_dir ||
13667 error "chown striped dir failed"
13669 $RUNAS createmany -o $DIR/$tdir/striped_dir/f 5000 ||
13670 error "create 5k files failed"
13672 file_count=$(ls $DIR/$tdir/striped_dir | wc -l)
13674 [ "$file_count" = 5000 ] || error "file count $file_count != 5000"
13678 run_test 300c "chown && check ls under striped directory"
13681 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13682 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
13686 mkdir -p $DIR/$tdir
13687 $SETSTRIPE -c 2 $DIR/$tdir
13689 #local striped directory
13690 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir ||
13691 error "set striped dir error"
13692 createmany -o $DIR/$tdir/striped_dir/f 10 ||
13693 error "create 10 files failed"
13695 #remote striped directory
13696 $LFS setdirstripe -i 1 -c 2 $DIR/$tdir/remote_striped_dir ||
13697 error "set striped dir error"
13698 createmany -o $DIR/$tdir/remote_striped_dir/f 10 ||
13699 error "create 10 files failed"
13701 for file in $(find $DIR/$tdir); do
13702 stripe_count=$($GETSTRIPE -c $file)
13703 [ $stripe_count -eq 2 ] ||
13704 error "wrong stripe $stripe_count for $file"
13709 run_test 300d "check default stripe under striped directory"
13712 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
13713 skip "Need MDS version at least 2.7.55" && return
13714 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13715 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
13719 mkdir -p $DIR/$tdir
13721 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir ||
13722 error "set striped dir error"
13724 touch $DIR/$tdir/striped_dir/a
13725 touch $DIR/$tdir/striped_dir/b
13726 touch $DIR/$tdir/striped_dir/c
13728 mkdir $DIR/$tdir/striped_dir/dir_a
13729 mkdir $DIR/$tdir/striped_dir/dir_b
13730 mkdir $DIR/$tdir/striped_dir/dir_c
13732 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir/stp_a ||
13733 error "set striped dir under striped dir error"
13735 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir/stp_b ||
13736 error "set striped dir under striped dir error"
13738 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir/stp_c ||
13739 error "set striped dir under striped dir error"
13741 mrename $DIR/$tdir/striped_dir/dir_a $DIR/$tdir/striped_dir/dir_b ||
13742 error "rename dir under striped dir fails"
13744 mrename $DIR/$tdir/striped_dir/stp_a $DIR/$tdir/striped_dir/stp_b ||
13745 error "rename dir under different stripes fails"
13747 mrename $DIR/$tdir/striped_dir/a $DIR/$tdir/striped_dir/c ||
13748 error "rename file under striped dir should succeed"
13750 mrename $DIR/$tdir/striped_dir/dir_b $DIR/$tdir/striped_dir/dir_c ||
13751 error "rename dir under striped dir should succeed"
13755 run_test 300e "check rename under striped directory"
13758 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
13759 skip "Need MDS version at least 2.7.55" && return
13760 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13761 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
13766 mkdir -p $DIR/$tdir
13768 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir ||
13769 error "set striped dir error"
13771 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir1 ||
13772 error "set striped dir error"
13774 touch $DIR/$tdir/striped_dir/a
13775 mkdir $DIR/$tdir/striped_dir/dir_a
13776 $LFS setdirstripe -i 0 -c 2 $DIR/$tdir/striped_dir/stp_a ||
13777 error "create striped dir under striped dir fails"
13779 touch $DIR/$tdir/striped_dir1/b
13780 mkdir $DIR/$tdir/striped_dir1/dir_b
13781 $LFS setdirstripe -i 0 -c 2 $DIR/$tdir/striped_dir/stp_b ||
13782 error "create striped dir under striped dir fails"
13784 mrename $DIR/$tdir/striped_dir/dir_a $DIR/$tdir/striped_dir1/dir_b ||
13785 error "rename dir under different striped dir should fail"
13787 mrename $DIR/$tdir/striped_dir/stp_a $DIR/$tdir/striped_dir1/stp_b ||
13788 error "rename striped dir under diff striped dir should fail"
13790 mrename $DIR/$tdir/striped_dir/a $DIR/$tdir/striped_dir1/a ||
13791 error "rename file under diff striped dirs fails"
13795 run_test 300f "check rename cross striped directory"
13797 test_300_check_default_striped_dir()
13800 local default_count=$2
13801 local default_index=$3
13804 local dir_stripe_index
13807 echo "checking $dirname $default_count $default_index"
13808 $LFS setdirstripe -D -c $default_count -i $default_index \
13809 -t all_char $DIR/$tdir/$dirname ||
13810 error "set default stripe on striped dir error"
13811 stripe_count=$($LFS getdirstripe -D -c $DIR/$tdir/$dirname)
13812 [ $stripe_count -eq $default_count ] ||
13813 error "expect $default_count get $stripe_count for $dirname"
13815 stripe_index=$($LFS getdirstripe -D -i $DIR/$tdir/$dirname)
13816 [ $stripe_index -eq $default_index ] ||
13817 error "expect $default_index get $stripe_index for $dirname"
13819 mkdir $DIR/$tdir/$dirname/{test1,test2,test3,test4} ||
13820 error "create dirs failed"
13822 createmany -o $DIR/$tdir/$dirname/f- 10 || error "create files failed"
13823 unlinkmany $DIR/$tdir/$dirname/f- 10 || error "unlink files failed"
13824 for dir in $(find $DIR/$tdir/$dirname/*); do
13825 stripe_count=$($LFS getdirstripe -c $dir)
13826 [ $stripe_count -eq $default_count ] ||
13827 [ $stripe_count -eq 0 -o $default_count -eq 1 ] ||
13828 error "stripe count $default_count != $stripe_count for $dir"
13830 stripe_index=$($LFS getdirstripe -i $dir)
13831 [ $default_index -eq -1 -o $stripe_index -eq $default_index ] ||
13832 error "$stripe_index != $default_index for $dir"
13834 #check default stripe
13835 stripe_count=$($LFS getdirstripe -D -c $dir)
13836 [ $stripe_count -eq $default_count ] ||
13837 error "default count $default_count != $stripe_count for $dir"
13839 stripe_index=$($LFS getdirstripe -D -i $dir)
13840 [ $stripe_index -eq $default_index ] ||
13841 error "default index $default_index != $stripe_index for $dir"
13843 rmdir $DIR/$tdir/$dirname/* || error "rmdir failed"
13847 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
13848 skip "Need MDS version at least 2.7.55" && return
13849 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
13855 mkdir $DIR/$tdir/normal_dir
13857 test_300_check_default_striped_dir normal_dir $MDSCOUNT 1
13858 test_300_check_default_striped_dir normal_dir 1 0
13859 test_300_check_default_striped_dir normal_dir 2 1
13860 test_300_check_default_striped_dir normal_dir 2 -1
13862 #delete default stripe information
13863 echo "delete default stripeEA"
13864 $LFS setdirstripe -d $DIR/$tdir/normal_dir ||
13865 error "set default stripe on striped dir error"
13867 mkdir -p $DIR/$tdir/normal_dir/{test1,test2,test3,test4}
13868 for dir in $(find $DIR/$tdir/normal_dir/*); do
13869 stripe_count=$($LFS getdirstripe -c $dir)
13870 [ $stripe_count -eq 0 ] ||
13871 error "expect 1 get $stripe_count for $dir"
13872 stripe_index=$($LFS getdirstripe -i $dir)
13873 [ $stripe_index -eq 0 ] ||
13874 error "expect 0 get $stripe_index for $dir"
13877 run_test 300g "check default striped directory for normal directory"
13880 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
13881 skip "Need MDS version at least 2.7.55" && return
13882 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
13887 $LFS setdirstripe -i 0 -c $MDSCOUNT -t all_char \
13888 $DIR/$tdir/striped_dir ||
13889 error "set striped dir error"
13891 test_300_check_default_striped_dir striped_dir $MDSCOUNT 1
13892 test_300_check_default_striped_dir striped_dir 1 0
13893 test_300_check_default_striped_dir striped_dir 2 1
13894 test_300_check_default_striped_dir striped_dir 2 -1
13896 #delete default stripe information
13897 $LFS setdirstripe -d $DIR/$tdir/striped_dir ||
13898 error "set default stripe on striped dir error"
13900 mkdir -p $DIR/$tdir/striped_dir/{test1,test2,test3,test4}
13901 for dir in $(find $DIR/$tdir/striped_dir/*); do
13902 stripe_count=$($LFS getdirstripe -c $dir)
13903 [ $stripe_count -eq 0 ] ||
13904 error "expect 1 get $stripe_count for $dir"
13907 run_test 300h "check default striped directory for striped directory"
13910 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
13911 skip "Need MDS version at least 2.7.55" && return
13912 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13913 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
13919 $LFS setdirstripe -i 0 -c$MDSCOUNT -t all_char $DIR/$tdir/striped_dir ||
13920 error "set striped dir error"
13922 createmany -o $DIR/$tdir/striped_dir/f- 10 ||
13923 error "create files under striped dir failed"
13925 # unfortunately, we need to umount to clear dir layout cache for now
13926 # once we fully implement dir layout, we can drop this
13927 umount_client $MOUNT || error "umount failed"
13928 mount_client $MOUNT || error "mount failed"
13930 #set the stripe to be unknown hash type
13931 #define OBD_FAIL_UNKNOWN_LMV_STRIPE 0x1901
13932 $LCTL set_param fail_loc=0x1901
13933 for ((i = 0; i < 10; i++)); do
13934 $CHECKSTAT -t file $DIR/$tdir/striped_dir/f-$i ||
13935 error "stat f-$i failed"
13936 rm $DIR/$tdir/striped_dir/f-$i || error "unlink f-$i failed"
13939 touch $DIR/$tdir/striped_dir/f0 &&
13940 error "create under striped dir with unknown hash should fail"
13942 $LCTL set_param fail_loc=0
13944 umount_client $MOUNT || error "umount failed"
13945 mount_client $MOUNT || error "mount failed"
13949 run_test 300i "client handle unknown hash type striped directory"
13952 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13953 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
13954 skip "Need MDS version at least 2.7.55" && return
13955 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
13961 #define OBD_FAIL_SPLIT_UPDATE_REC 0x1702
13962 $LCTL set_param fail_loc=0x1702
13963 $LFS setdirstripe -i 0 -c$MDSCOUNT -t all_char $DIR/$tdir/striped_dir ||
13964 error "set striped dir error"
13966 createmany -o $DIR/$tdir/striped_dir/f- 10 ||
13967 error "create files under striped dir failed"
13969 $LCTL set_param fail_loc=0
13971 rm -rf $DIR/$tdir || error "unlink striped dir fails"
13975 run_test 300j "test large update record"
13978 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
13979 skip "Need MDS version at least 2.7.55" && return
13980 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13981 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
13987 #define OBD_FAIL_LARGE_STRIPE 0x1703
13988 $LCTL set_param fail_loc=0x1703
13989 $LFS setdirstripe -i 0 -c512 $DIR/$tdir/striped_dir ||
13990 error "set striped dir error"
13991 $LCTL set_param fail_loc=0
13993 $LFS getdirstripe $DIR/$tdir/striped_dir ||
13994 error "getstripeddir fails"
13995 rm -rf $DIR/$tdir/striped_dir ||
13996 error "unlink striped dir fails"
14000 run_test 300k "test large striped directory"
14003 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
14004 skip "Need MDS version at least 2.7.55" && return
14005 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
14006 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
14009 test_mkdir -p $DIR/$tdir/striped_dir
14010 chown $RUNAS_ID $DIR/$tdir/striped_dir ||
14011 error "chown $RUNAS_ID failed"
14012 $LFS setdirstripe -i 1 -D $DIR/$tdir/striped_dir ||
14013 error "set default striped dir failed"
14015 #define OBD_FAIL_MDS_STALE_DIR_LAYOUT 0x158
14016 $LCTL set_param fail_loc=0x80000158
14017 $RUNAS mkdir $DIR/$tdir/striped_dir/test_dir || error "create dir fails"
14019 stripe_index=$($LFS getdirstripe -i $DIR/$tdir/striped_dir/test_dir)
14020 [ $stripe_index -eq 1 ] ||
14021 error "expect 1 get $stripe_index for $dir"
14023 run_test 300l "non-root user to create dir under striped dir with stale layout"
14026 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
14027 skip "Need MDS version at least 2.7.55" && return
14028 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
14029 [ $MDSCOUNT -ge 2 ] && skip "Only for single MDT" && return
14031 mkdir -p $DIR/$tdir/striped_dir
14032 $LFS setdirstripe -D -c 1 $DIR/$tdir/striped_dir ||
14033 error "set default stripes dir error"
14035 mkdir $DIR/$tdir/striped_dir/a || error "mkdir a fails"
14037 stripe_count=$($LFS getdirstripe -c $DIR/$tdir/striped_dir/a)
14038 [ $stripe_count -eq 0 ] ||
14039 error "expect 0 get $stripe_count for a"
14041 $LFS setdirstripe -D -c 2 $DIR/$tdir/striped_dir ||
14042 error "set default stripes dir error"
14044 mkdir $DIR/$tdir/striped_dir/b || error "mkdir b fails"
14046 stripe_count=$($LFS getdirstripe -c $DIR/$tdir/striped_dir/b)
14047 [ $stripe_count -eq 0 ] ||
14048 error "expect 0 get $stripe_count for b"
14050 $LFS setdirstripe -D -c1 -i2 $DIR/$tdir/striped_dir ||
14051 error "set default stripes dir error"
14053 mkdir $DIR/$tdir/striped_dir/c &&
14054 error "default stripe_index is invalid, mkdir c should fails"
14056 rm -rf $DIR/$tdir || error "rmdir fails"
14058 run_test 300m "setstriped directory on single MDT FS"
14061 local list=$(comma_list $(mdts_nodes))
14064 do_nodes $list $LCTL set_param -n mdt.*.enable_remote_dir_gid=0
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
14073 local list=$(comma_list $(mdts_nodes))
14075 trap cleanup_300n RETURN EXIT
14076 mkdir -p $DIR/$tdir
14077 chmod 777 $DIR/$tdir
14078 $RUNAS $LFS setdirstripe -i0 -c$MDSCOUNT \
14079 $DIR/$tdir/striped_dir > /dev/null 2>&1 &&
14080 error "create striped dir succeeds with gid=0"
14082 do_nodes $list $LCTL set_param -n mdt.*.enable_remote_dir_gid=-1
14083 $RUNAS $LFS setdirstripe -i0 -c$MDSCOUNT $DIR/$tdir/striped_dir ||
14084 error "create striped dir fails with gid=-1"
14086 do_nodes $list $LCTL set_param -n mdt.*.enable_remote_dir_gid=0
14087 $RUNAS $LFS setdirstripe -i 1 -c$MDSCOUNT -D \
14088 $DIR/$tdir/striped_dir > /dev/null 2>&1 &&
14089 error "set default striped dir succeeds with gid=0"
14092 do_nodes $list $LCTL set_param -n mdt.*.enable_remote_dir_gid=-1
14093 $RUNAS $LFS setdirstripe -i 1 -c$MDSCOUNT -D $DIR/$tdir/striped_dir ||
14094 error "set default striped dir fails with gid=-1"
14097 do_nodes $list $LCTL set_param -n mdt.*.enable_remote_dir_gid=0
14098 $RUNAS mkdir $DIR/$tdir/striped_dir/test_dir ||
14099 error "create test_dir fails"
14100 $RUNAS mkdir $DIR/$tdir/striped_dir/test_dir1 ||
14101 error "create test_dir1 fails"
14102 $RUNAS mkdir $DIR/$tdir/striped_dir/test_dir2 ||
14103 error "create test_dir2 fails"
14106 run_test 300n "non-root user to create dir under striped dir with default EA"
14109 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
14110 skip "Need MDS version at least 2.7.55" && return
14111 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
14112 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
14116 mkdir -p $DIR/$tdir
14118 numfree1=$(lctl get_param -n mdc.*MDT0000*.filesfree)
14119 numfree2=$(lctl get_param -n mdc.*MDT0001*.filesfree)
14120 if [ $numfree1 -lt 66000 -o $numfree2 -lt 66000 ]; then
14121 skip "not enough free inodes $numfree1 $numfree2"
14125 numfree1=$(lctl get_param -n mdc.*MDT0000-mdc-*.kbytesfree)
14126 numfree2=$(lctl get_param -n mdc.*MDT0001-mdc-*.kbytesfree)
14127 if [ $numfree1 -lt 300000 -o $numfree2 -lt 300000 ]; then
14128 skip "not enough free space $numfree1 $numfree2"
14132 $LFS setdirstripe -c2 $DIR/$tdir/striped_dir ||
14133 error "setdirstripe fails"
14135 createmany -d $DIR/$tdir/striped_dir/d 131000 ||
14136 error "create dirs fails"
14138 $LCTL set_param ldlm.namespaces.*mdc-*.lru_size=0
14139 ls $DIR/$tdir/striped_dir > /dev/null ||
14140 error "ls striped dir fails"
14141 unlinkmany -d $DIR/$tdir/striped_dir/d 131000 ||
14142 error "unlink big striped dir fails"
14144 run_test 300o "unlink big sub stripe(> 65000 subdirs)"
14147 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
14148 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
14150 mkdir -p $DIR/$tdir
14152 #define OBD_FAIL_OUT_ENOSPC 0x1704
14153 do_facet mds2 lctl set_param fail_loc=0x80001704
14154 $LFS setdirstripe -c2 $DIR/$tdir/bad_striped_dir > /dev/null 2>&1 &&
14155 error "create striped directory should fail"
14157 [ -e $DIR/$tdir/bad_striped_dir ] && error "striped dir exists"
14160 run_test 300p "create striped directory without space"
14162 prepare_remote_file() {
14163 mkdir $DIR/$tdir/src_dir ||
14164 error "create remote source failed"
14166 cp /etc/hosts $DIR/$tdir/src_dir/a || error
14167 touch $DIR/$tdir/src_dir/a
14169 $LFS mkdir -i 1 $DIR/$tdir/tgt_dir ||
14170 error "create remote target dir failed"
14172 touch $DIR/$tdir/tgt_dir/b
14174 mrename $DIR/$tdir/src_dir/a $DIR/$tdir/tgt_dir/b ||
14175 error "rename dir cross MDT failed!"
14177 $CHECKSTAT -t file $DIR/$tdir/src_dir/a &&
14178 error "src_child still exists after rename"
14180 $CHECKSTAT -t file $DIR/$tdir/tgt_dir/b ||
14181 error "missing file(a) after rename"
14183 diff /etc/hosts $DIR/$tdir/tgt_dir/b ||
14184 error "diff after rename"
14188 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 4 MDTs" && return
14189 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
14190 local remote_file=$DIR/$tdir/tgt_dir/b
14192 mkdir -p $DIR/$tdir
14194 prepare_remote_file || error "prepare remote file failed"
14197 $OPENUNLINK $remote_file $remote_file || error
14198 $CHECKSTAT -a $remote_file || error
14200 run_test 310a "open unlink remote file"
14203 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 4 MDTs" && return
14204 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
14205 local remote_file=$DIR/$tdir/tgt_dir/b
14207 mkdir -p $DIR/$tdir
14209 prepare_remote_file || error "prepare remote file failed"
14211 ln $remote_file $DIR/$tfile || error "link failed for remote file"
14212 $MULTIOP $DIR/$tfile Ouc || error "mulitop failed"
14213 $CHECKSTAT -t file $remote_file || error "check file failed"
14215 run_test 310b "unlink remote file with multiple links while open"
14218 [[ $MDSCOUNT -lt 4 ]] && skip "needs >= 4 MDTs" && return
14219 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
14220 local remote_file=$DIR/$tdir/tgt_dir/b
14222 mkdir -p $DIR/$tdir
14224 prepare_remote_file || error "prepare remote file failed"
14226 ln $remote_file $DIR/$tfile || error "link failed for remote file"
14227 multiop_bg_pause $remote_file O_uc ||
14228 error "mulitop failed for remote file"
14230 $MULTIOP $DIR/$tfile Ouc
14231 kill -USR1 $MULTIPID
14234 run_test 310c "open-unlink remote file with multiple links"
14236 test_400a() { # LU-1606, was conf-sanity test_74
14237 local extra_flags=''
14238 local out=$TMP/$tfile
14239 local prefix=/usr/include/lustre
14242 if ! which $CC > /dev/null 2>&1; then
14243 skip_env "$CC is not installed"
14247 if ! [[ -d $prefix ]]; then
14248 # Assume we're running in tree and fixup the include path.
14249 extra_flags+=" -I$LUSTRE/../libcfs/include"
14250 extra_flags+=" -I$LUSTRE/include"
14251 extra_flags+=" -L$LUSTRE/utils"
14254 for prog in $LUSTRE_TESTS_API_DIR/*.c; do
14255 $CC -Wall -Werror $extra_flags -llustreapi -o $out $prog ||
14256 error "client api broken"
14259 run_test 400a "Lustre client api program can compile and link"
14261 test_400b() { # LU-1606, LU-5011
14263 local out=$TMP/$tfile
14264 local prefix=/usr/include/lustre
14266 # We use a hard coded prefix so that this test will not fail
14267 # when run in tree. There are headers in lustre/include/lustre/
14268 # that are not packaged (like lustre_idl.h) and have more
14269 # complicated include dependencies (like config.h and lnet/types.h).
14270 # Since this test about correct packaging we just skip them when
14271 # they don't exist (see below) rather than try to fixup cppflags.
14273 if ! which $CC > /dev/null 2>&1; then
14274 skip_env "$CC is not installed"
14278 for header in $prefix/*.h; do
14279 if ! [[ -f "$header" ]]; then
14283 if [[ "$(basename $header)" == liblustreapi.h ]]; then
14284 continue # liblustreapi.h is deprecated.
14287 $CC -Wall -Werror -include $header -c -x c /dev/null -o $out ||
14288 error "cannot compile '$header'"
14291 run_test 400b "packaged headers can be compiled"
14293 test_401() { #LU-7437
14297 #count the number of parameters by "list_param -R"
14298 params=$($LCTL list_param -R '*' 2>/dev/null | wc -l)
14299 #count the number of parameters by listing proc files
14300 ls -lRL /proc/{fs,sys}/{lnet,lustre} 2>/dev/null |
14301 grep -v "^t" | grep -v "^d" > $TMP/$tfile
14302 #Since there is no /proc/fs/lnet, we need to remove other
14303 #3 directories, /proc/{fs,sys}/lustre and /proc/sys/lnet.
14304 procs=$(($(sed /^$/d $TMP/$tfile | wc -l)-3))
14306 [ $params -eq $procs ] ||
14307 error "found $params parameters vs. $procs proc files"
14311 run_test 401 "Verify if 'lctl list_param -R' can list parameters recursively"
14314 # tests that do cleanup/setup should be run at the end
14318 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
14320 #define OBD_FAIL_MGC_PAUSE_PROCESS_LOG 0x903
14321 $LCTL set_param fail_loc=0x903
14323 cancel_lru_locks MGC
14325 FAIL_ON_ERROR=true cleanup
14326 FAIL_ON_ERROR=true setup
14328 run_test 900 "umount should not race with any mgc requeue thread"
14331 [ -f $EXT2_DEV ] && rm $EXT2_DEV || true
14332 check_and_cleanup_lustre
14333 if [ "$I_MOUNTED" != "yes" ]; then
14334 lctl set_param debug="$OLDDEBUG" 2> /dev/null || true