2 # -*- tab-width: 4; 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}'`
32 if is_sles11; then # LU-4351
33 ALWAYS_EXCEPT="$ALWAYS_EXCEPT 54c"
36 SRCDIR=$(cd $(dirname $0); echo $PWD)
37 export PATH=$PATH:/sbin
41 CHECKSTAT=${CHECKSTAT:-"checkstat -v"}
42 CREATETEST=${CREATETEST:-createtest}
44 LFIND=${LFIND:-"$LFS find"}
45 LVERIFY=${LVERIFY:-ll_dirstripe_verify}
47 MCREATE=${MCREATE:-mcreate}
48 OPENFILE=${OPENFILE:-openfile}
49 OPENUNLINK=${OPENUNLINK:-openunlink}
50 export MULTIOP=${MULTIOP:-multiop}
51 READS=${READS:-"reads"}
52 MUNLINK=${MUNLINK:-munlink}
53 SOCKETSERVER=${SOCKETSERVER:-socketserver}
54 SOCKETCLIENT=${SOCKETCLIENT:-socketclient}
55 MEMHOG=${MEMHOG:-memhog}
56 DIRECTIO=${DIRECTIO:-directio}
57 ACCEPTOR_PORT=${ACCEPTOR_PORT:-988}
58 UMOUNT=${UMOUNT:-"umount -d"}
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/test-framework.sh
74 . ${CONFIG:=$LUSTRE/tests/cfg/${NAME}.sh}
77 [ "$SLOW" = "no" ] && EXCEPT_SLOW="24o 27m 64b 68 71 77f 78 115 124b"
79 [ $(facet_fstype $SINGLEMDS) = "zfs" ] &&
80 # bug number for skipped test: LU-1593 LU-2610 LU-2833 LU-1957 LU-2805
81 ALWAYS_EXCEPT="$ALWAYS_EXCEPT 34h 40 48a 180 184c"
87 pgrep ll_sa > /dev/null && { echo "There are ll_sa thread not exit!"; exit 20; }
88 cleanupall ${FORCE} $* || { echo "FAILed to clean up"; exit 20; }
97 check_kernel_version() {
99 GOT_VER=$(lctl get_param -n version | awk '/kernel:/ {print $2}')
101 patchless|patchless_client) return 0;;
102 *) [ $GOT_VER -ge $WANT_VER ] && return 0 ;;
104 log "test needs at least kernel version $WANT_VER, running $GOT_VER"
108 check_swap_layouts_support()
110 $LCTL get_param -n llite.*.sbi_flags | grep -q layout ||
111 { skip "Does not support layout lock."; return 0; }
115 if [ "$ONLY" == "cleanup" ]; then
120 check_and_setup_lustre
125 MDT0=$($LCTL get_param -n mdc.*.mds_server_uuid |
126 awk '{ gsub(/_UUID/,""); print $1 }' | head -n1)
127 LOVNAME=$($LCTL get_param -n llite.*.lov.common_name | tail -n 1)
128 OSTCOUNT=$($LCTL get_param -n lov.$LOVNAME.numobd)
129 STRIPECOUNT=$($LCTL get_param -n lov.$LOVNAME.stripecount)
130 STRIPESIZE=$($LCTL get_param -n lov.$LOVNAME.stripesize)
131 ORIGFREE=$($LCTL get_param -n lov.$LOVNAME.kbytesavail)
132 MAXFREE=${MAXFREE:-$((200000 * $OSTCOUNT))}
134 [ -f $DIR/d52a/foo ] && chattr -a $DIR/d52a/foo
135 [ -f $DIR/d52b/foo ] && chattr -i $DIR/d52b/foo
136 rm -rf $DIR/[Rdfs][0-9]*
138 # $RUNAS_ID may get set incorrectly somewhere else
139 [ $UID -eq 0 -a $RUNAS_ID -eq 0 ] && error "\$RUNAS_ID set to 0, but \$UID is also 0!"
141 check_runas_id $RUNAS_ID $RUNAS_GID $RUNAS
145 if [ "${ONLY}" = "MOUNT" ] ; then
146 echo "Lustre is up, please go on"
150 echo "preparing for tests involving mounts"
151 EXT2_DEV=${EXT2_DEV:-$TMP/SANITY.LOOP}
153 mke2fs -j -F $EXT2_DEV 8000 > /dev/null
154 echo # add a newline after mke2fs.
158 OLDDEBUG=$(lctl get_param -n debug 2> /dev/null)
159 lctl set_param debug=-1 2> /dev/null || true
162 $CHECKSTAT -t file $DIR/$tfile || error "$tfile is not a file"
164 $CHECKSTAT -a $DIR/$tfile || error "$tfile was not removed"
166 run_test 0a "touch; rm ====================="
169 chmod 0755 $DIR || error "chmod 0755 $DIR failed"
170 $CHECKSTAT -p 0755 $DIR || error "$DIR permission is not 0755"
172 run_test 0b "chmod 0755 $DIR ============================="
175 $LCTL get_param mdc.*.import | grep "state: FULL" ||
176 error "import not FULL"
177 $LCTL get_param mdc.*.import | grep "target: $FSNAME-MDT" ||
180 run_test 0c "check import proc ============================="
183 test_mkdir -p $DIR/$tdir || error "mkdir $tdir failed"
184 test_mkdir -p $DIR/$tdir/d2 || error "mkdir $tdir/d2 failed"
185 test_mkdir $DIR/$tdir/d2 && error "we expect EEXIST, but not returned"
186 $CHECKSTAT -t dir $DIR/$tdir/d2 || error "$tdir/d2 is not a dir"
189 $CHECKSTAT -a $DIR/$tdir || error "$tdir was not removed"
191 run_test 1 "mkdir; remkdir; rmdir =============================="
194 test_mkdir -p $DIR/$tdir || error "mkdir $tdir failed"
195 touch $DIR/$tdir/$tfile || error "touch $tdir/$tfile failed"
196 $CHECKSTAT -t file $DIR/$tdir/$tfile || error "$tdir/$tfile not a file"
198 $CHECKSTAT -a $DIR/$tdir/$tfile || error "$tdir/$file is not removed"
200 run_test 2 "mkdir; touch; rmdir; check file ===================="
203 test_mkdir -p $DIR/$tdir || error "mkdir $tdir failed"
204 $CHECKSTAT -t dir $DIR/$tdir || error "$tdir is not a directory"
205 touch $DIR/$tdir/$tfile
206 $CHECKSTAT -t file $DIR/$tdir/$tfile || error "$tdir/$tfile not a file"
208 $CHECKSTAT -a $DIR/$tdir || error "$tdir is not removed"
210 run_test 3 "mkdir; touch; rmdir; check dir ====================="
212 # LU-4471 - failed rmdir on remote directories still removes directory on MDT0
215 local remote_dir=remote_dir
217 [ $MDSCOUNT -ge 2 ] && skip "skip now for LU-4690" && return #LU-4690
218 test_mkdir $DIR/$remote_dir ||
219 error "Create remote directory failed"
221 touch $DIR/$remote_dir/$tfile ||
222 error "Create file under remote directory failed"
224 rmdir $DIR/$remote_dir &&
225 error "Expect error removing in-use dir $DIR/$remote_dir"
227 test -d $DIR/$remote_dir || error "Remote directory disappeared"
229 run_test 4 "mkdir; touch dir/file; rmdir; checkdir (expect error)"
232 test_mkdir -p $DIR/$tdir || error "mkdir $tdir failed"
233 test_mkdir $DIR/$tdir/d2 || error "mkdir $tdir/d2 failed"
234 chmod 0707 $DIR/$tdir/d2 || error "chmod 0707 $tdir/d2 failed"
235 $CHECKSTAT -t dir -p 0707 $DIR/$tdir/d2 || error "$tdir/d2 not mode 707"
236 $CHECKSTAT -t dir $DIR/$tdir/d2 || error "$tdir/d2 is not a directory"
238 run_test 5 "mkdir .../d5 .../d5/d2; chmod .../d5/d2 ============"
241 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
242 chmod 0666 $DIR/$tfile || error "chmod 0666 $tfile failed"
243 $CHECKSTAT -t file -p 0666 -u \#$UID $DIR/$tfile ||
244 error "$tfile does not have perm 0666 or UID $UID"
245 $RUNAS chmod 0444 $DIR/$tfile && error "chmod $tfile worked on UID $UID"
246 $CHECKSTAT -t file -p 0666 -u \#$UID $DIR/$tfile ||
247 error "$tfile should be 0666 and owned by UID $UID"
249 run_test 6a "touch f6a; chmod f6a; $RUNAS chmod f6a (should return error) =="
252 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID" && return
254 chown $RUNAS_ID $DIR/$tfile || error "chown $RUNAS_ID $file failed"
255 $CHECKSTAT -t file -u \#$RUNAS_ID $DIR/$tfile ||
256 error "$tfile should be owned by UID $RUNAS_ID"
257 $RUNAS chown $UID $DIR/$tfile && error "chown $UID $file succeeded"
258 $CHECKSTAT -t file -u \#$RUNAS_ID $DIR/$tfile ||
259 error "$tfile should be owned by UID $RUNAS_ID"
261 run_test 6c "touch f6c; chown f6c; $RUNAS chown f6c (should return error) =="
264 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID" && return
266 chgrp $RUNAS_ID $DIR/$tfile || error "chgrp $RUNAS_ID $file failed"
267 $CHECKSTAT -t file -u \#$UID -g \#$RUNAS_ID $DIR/$tfile ||
268 error "$tfile should be owned by GID $UID"
269 $RUNAS chgrp $UID $DIR/$tfile && error "chgrp $UID $file succeeded"
270 $CHECKSTAT -t file -u \#$UID -g \#$RUNAS_ID $DIR/$tfile ||
271 error "$tfile should be owned by UID $UID and GID $RUNAS_ID"
273 run_test 6e "touch f6e; chgrp f6e; $RUNAS chgrp f6e (should return error) =="
276 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID" && return
277 test_mkdir $DIR/$tdir || error "mkdir $tfile failed"
278 chmod 777 $DIR/$tdir || error "chmod 0777 $tdir failed"
279 $RUNAS mkdir $DIR/$tdir/d || error "mkdir $tdir/d failed"
280 chmod g+s $DIR/$tdir/d || error "chmod g+s $tdir/d failed"
281 test_mkdir $DIR/$tdir/d/subdir || error "mkdir $tdir/d/subdir failed"
282 $CHECKSTAT -g \#$RUNAS_GID $DIR/$tdir/d/subdir ||
283 error "$tdir/d/subdir should be GID $RUNAS_GID"
285 run_test 6g "Is new dir in sgid dir inheriting group?"
287 test_6h() { # bug 7331
288 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID" && return
289 touch $DIR/$tfile || error "touch failed"
290 chown $RUNAS_ID:$RUNAS_GID $DIR/$tfile || error "initial chown failed"
291 $RUNAS -G$RUNAS_GID chown $RUNAS_ID:0 $DIR/$tfile &&
292 error "chown $RUNAS_ID:0 $tfile worked as GID $RUNAS_GID"
293 $CHECKSTAT -t file -u \#$RUNAS_ID -g \#$RUNAS_GID $DIR/$tfile ||
294 error "$tdir/$tfile should be UID $RUNAS_UID GID $RUNAS_GID"
296 run_test 6h "$RUNAS chown RUNAS_ID.0 .../f6h (should return error)"
299 test_mkdir $DIR/$tdir
300 $MCREATE $DIR/$tdir/$tfile
301 chmod 0666 $DIR/$tdir/$tfile
302 $CHECKSTAT -t file -p 0666 $DIR/$tdir/$tfile ||
303 error "$tdir/$tfile should be mode 0666"
305 run_test 7a "mkdir .../d7; mcreate .../d7/f; chmod .../d7/f ===="
308 if [ ! -d $DIR/$tdir ]; then
311 $MCREATE $DIR/$tdir/$tfile
312 echo -n foo > $DIR/$tdir/$tfile
313 [ "$(cat $DIR/$tdir/$tfile)" = "foo" ] || error "$tdir/$tfile not 'foo'"
314 $CHECKSTAT -t file -s 3 $DIR/$tdir/$tfile || error "$tfile size not 3"
316 run_test 7b "mkdir .../d7; mcreate d7/f2; echo foo > d7/f2 ====="
319 test_mkdir $DIR/$tdir
320 touch $DIR/$tdir/$tfile
321 chmod 0666 $DIR/$tdir/$tfile
322 $CHECKSTAT -t file -p 0666 $DIR/$tdir/$tfile ||
323 error "$tfile mode not 0666"
325 run_test 8 "mkdir .../d8; touch .../d8/f; chmod .../d8/f ======="
328 test_mkdir $DIR/$tdir
329 test_mkdir $DIR/$tdir/d2
330 test_mkdir $DIR/$tdir/d2/d3
331 $CHECKSTAT -t dir $DIR/$tdir/d2/d3 || error "$tdir/d2/d3 not a dir"
333 run_test 9 "mkdir .../d9 .../d9/d2 .../d9/d2/d3 ================"
336 test_mkdir $DIR/$tdir
337 test_mkdir $DIR/$tdir/d2
338 touch $DIR/$tdir/d2/$tfile
339 $CHECKSTAT -t file $DIR/$tdir/d2/$tfile ||
340 error "$tdir/d2/$tfile not a file"
342 run_test 10 "mkdir .../d10 .../d10/d2; touch .../d10/d2/f ======"
345 test_mkdir $DIR/$tdir
346 test_mkdir $DIR/$tdir/d2
347 chmod 0666 $DIR/$tdir/d2
348 chmod 0705 $DIR/$tdir/d2
349 $CHECKSTAT -t dir -p 0705 $DIR/$tdir/d2 ||
350 error "$tdir/d2 mode not 0705"
352 run_test 11 "mkdir .../d11 d11/d2; chmod .../d11/d2 ============"
355 test_mkdir $DIR/$tdir
356 touch $DIR/$tdir/$tfile
357 chmod 0666 $DIR/$tdir/$tfile
358 chmod 0654 $DIR/$tdir/$tfile
359 $CHECKSTAT -t file -p 0654 $DIR/$tdir/$tfile ||
360 error "$tdir/d2 mode not 0654"
362 run_test 12 "touch .../d12/f; chmod .../d12/f .../d12/f ========"
365 test_mkdir $DIR/$tdir
366 dd if=/dev/zero of=$DIR/$tdir/$tfile count=10
368 $CHECKSTAT -t file -s 0 $DIR/$tdir/$tfile ||
369 error "$tdir/$tfile size not 0 after truncate"
371 run_test 13 "creat .../d13/f; dd .../d13/f; > .../d13/f ========"
374 test_mkdir $DIR/$tdir
375 touch $DIR/$tdir/$tfile
377 $CHECKSTAT -a $DIR/$tdir/$tfile || error "$tdir/$tfile not removed"
379 run_test 14 "touch .../d14/f; rm .../d14/f; rm .../d14/f ======="
382 test_mkdir $DIR/$tdir
383 touch $DIR/$tdir/$tfile
384 mv $DIR/$tdir/$tfile $DIR/$tdir/${tfile}_2
385 $CHECKSTAT -t file $DIR/$tdir/${tfile}_2 ||
386 error "$tdir/${tfile_2} not a file after rename"
388 run_test 15 "touch .../d15/f; mv .../d15/f .../d15/f2 =========="
391 test_mkdir $DIR/$tdir
392 touch $DIR/$tdir/$tfile
393 rm -rf $DIR/$tdir/$tfile
394 $CHECKSTAT -a $DIR/$tdir/$tfile || error "$tdir/$tfile not removed"
396 run_test 16 "touch .../d16/f; rm -rf .../d16/f ================="
399 test_mkdir -p $DIR/$tdir
400 touch $DIR/$tdir/$tfile
401 ln -s $DIR/$tdir/$tfile $DIR/$tdir/l-exist
403 $CHECKSTAT -l $DIR/$tdir/$tfile $DIR/$tdir/l-exist ||
404 error "$tdir/l-exist not a symlink"
405 $CHECKSTAT -f -t f $DIR/$tdir/l-exist ||
406 error "$tdir/l-exist not referencing a file"
407 rm -f $DIR/$tdir/l-exist
408 $CHECKSTAT -a $DIR/$tdir/l-exist || error "$tdir/l-exist not removed"
410 run_test 17a "symlinks: create, remove (real) =================="
413 test_mkdir -p $DIR/$tdir
414 ln -s no-such-file $DIR/$tdir/l-dangle
416 $CHECKSTAT -l no-such-file $DIR/$tdir/l-dangle ||
417 error "$tdir/l-dangle not referencing no-such-file"
418 $CHECKSTAT -fa $DIR/$tdir/l-dangle ||
419 error "$tdir/l-dangle not referencing non-existent file"
420 rm -f $DIR/$tdir/l-dangle
421 $CHECKSTAT -a $DIR/$tdir/l-dangle || error "$tdir/l-dangle not removed"
423 run_test 17b "symlinks: create, remove (dangling) =============="
425 test_17c() { # bug 3440 - don't save failed open RPC for replay
426 test_mkdir -p $DIR/$tdir
427 ln -s foo $DIR/$tdir/$tfile
428 cat $DIR/$tdir/$tfile && error "opened non-existent symlink" || true
430 run_test 17c "symlinks: open dangling (should return error) ===="
433 test_mkdir -p $DIR/$tdir
434 ln -s foo $DIR/$tdir/$tfile
435 touch $DIR/$tdir/$tfile || error "creating to new symlink"
437 run_test 17d "symlinks: create dangling ========================"
440 test_mkdir -p $DIR/$tdir
441 local foo=$DIR/$tdir/$tfile
442 ln -s $foo $foo || error "create symlink failed"
443 ls -l $foo || error "ls -l failed"
444 ls $foo && error "ls not failed" || true
446 run_test 17e "symlinks: create recursive symlink (should return error) ===="
449 test_mkdir -p $DIR/d17f
450 ln -s 1234567890/2234567890/3234567890/4234567890 $DIR/d17f/111
451 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890 $DIR/d17f/222
452 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890 $DIR/d17f/333
453 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890/9234567890/a234567890/b234567890 $DIR/d17f/444
454 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890/9234567890/a234567890/b234567890/c234567890/d234567890/f234567890 $DIR/d17f/555
455 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890/9234567890/a234567890/b234567890/c234567890/d234567890/f234567890/aaaaaaaaaa/bbbbbbbbbb/cccccccccc/dddddddddd/eeeeeeeeee/ffffffffff/ $DIR/d17f/666
458 run_test 17f "symlinks: long and very long symlink name ========================"
460 # str_repeat(S, N) generate a string that is string S repeated N times
465 while [ $((n -= 1)) -ge 0 ]; do
471 # Long symlinks and LU-2241
473 test_mkdir -p $DIR/$tdir
474 local TESTS="59 60 61 4094 4095"
476 # Fix for inode size boundary in 2.1.4
477 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.1.4) ] &&
480 # Patch not applied to 2.2 or 2.3 branches
481 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] &&
482 [ $(lustre_version_code $SINGLEMDS) -le $(version_code 2.3.55) ] &&
485 # skip long symlink name for rhel6.5.
486 # rhel6.5 has a limit (PATH_MAX - sizeof(struct filename))
487 grep -q '6.5' /etc/redhat-release &>/dev/null &&
488 TESTS="59 60 61 4062 4063"
491 local SYMNAME=$(str_repeat 'x' $i)
492 ln -s $SYMNAME $DIR/$tdir/f$i || error "failed $i-char symlink"
493 readlink $DIR/$tdir/f$i || error "failed $i-char readlink"
496 run_test 17g "symlinks: really long symlink name and inode boundaries"
498 test_17h() { #bug 17378
499 remote_mds_nodsh && skip "remote MDS with nodsh" && return
500 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
502 test_mkdir -p $DIR/$tdir
503 if [[ $MDSCOUNT -gt 1 ]]; then
504 mdt_idx=$($LFS getdirstripe -i $DIR/$tdir)
508 $SETSTRIPE -c -1 $DIR/$tdir
509 #define OBD_FAIL_MDS_LOV_PREP_CREATE 0x141
510 do_facet mds$((mdt_idx + 1)) lctl set_param fail_loc=0x80000141
511 touch $DIR/$tdir/$tfile || true
513 run_test 17h "create objects: lov_free_memmd() doesn't lbug"
515 test_17i() { #bug 20018
516 remote_mds_nodsh && skip "remote MDS with nodsh" && return
517 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
518 test_mkdir -p $DIR/$tdir
519 local foo=$DIR/$tdir/$tfile
521 if [[ $MDSCOUNT -gt 1 ]]; then
522 mdt_idx=$($LFS getdirstripe -i $DIR/$tdir)
526 ln -s $foo $foo || error "create symlink failed"
527 #define OBD_FAIL_MDS_READLINK_EPROTO 0x143
528 do_facet mds$((mdt_idx + 1)) lctl set_param fail_loc=0x80000143
529 ls -l $foo && error "error not detected"
532 run_test 17i "don't panic on short symlink"
534 test_17k() { #bug 22301
535 [[ -z "$(which rsync 2>/dev/null)" ]] &&
536 skip "no rsync command" && return 0
537 rsync --help | grep -q xattr ||
538 skip_env "$(rsync --version | head -n1) does not support xattrs"
539 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return 0
540 test_mkdir -p $DIR/$tdir
541 test_mkdir -p $DIR/$tdir.new
542 touch $DIR/$tdir/$tfile
543 ln -s $DIR/$tdir/$tfile $DIR/$tdir/$tfile.lnk
544 rsync -av -X $DIR/$tdir/ $DIR/$tdir.new ||
545 error "rsync failed with xattrs enabled"
547 run_test 17k "symlinks: rsync with xattrs enabled ========================="
549 test_17l() { # LU-279
550 [[ -z "$(which getfattr 2>/dev/null)" ]] &&
551 skip "no getfattr command" && return 0
553 touch $DIR/$tdir/$tfile
554 ln -s $DIR/$tdir/$tfile $DIR/$tdir/$tfile.lnk
555 for path in "$DIR/$tdir" "$DIR/$tdir/$tfile" "$DIR/$tdir/$tfile.lnk"; do
556 # -h to not follow symlinks. -m '' to list all the xattrs.
557 # grep to remove first line: '# file: $path'.
558 for xattr in `getfattr -hm '' $path 2>/dev/null | grep -v '^#'`;
560 lgetxattr_size_check $path $xattr ||
561 error "lgetxattr_size_check $path $xattr failed"
565 run_test 17l "Ensure lgetxattr's returned xattr size is consistent ========"
569 local short_sym="0123456789"
570 local WDIR=$DIR/${tdir}m
577 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] &&
578 [ $(lustre_version_code $SINGLEMDS) -le $(version_code 2.2.93) ] &&
579 skip "MDS 2.2.0-2.2.93 do not NUL-terminate symlinks" && return
581 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
582 skip "only for ldiskfs MDT" && return 0
584 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
588 # create a long symlink file
589 for ((i = 0; i < 4; ++i)); do
590 long_sym=${long_sym}${long_sym}
593 echo "create 512 short and long symlink files under $WDIR"
594 for ((i = 0; i < 256; ++i)); do
595 ln -sf ${long_sym}"a5a5" $WDIR/long-$i
596 ln -sf ${short_sym}"a5a5" $WDIR/short-$i
602 wait_delete_completed
604 echo "recreate the 512 symlink files with a shorter string"
605 for ((i = 0; i < 512; ++i)); do
606 # rewrite the symlink file with a shorter string
607 ln -sf ${long_sym} $WDIR/long-$i
608 ln -sf ${short_sym} $WDIR/short-$i
611 mds_index=$($LFS getstripe -M $WDIR)
612 mds_index=$((mds_index+1))
613 devname=$(mdsdevname $mds_index)
614 cmd="$E2FSCK -fnvd $devname"
616 echo "stop and checking mds${mds_index}: $cmd"
617 # e2fsck should not return error
618 stop mds${mds_index} -f
619 do_facet mds${mds_index} $cmd || rc=$?
621 start mds${mds_index} $devname $MDS_MOUNT_OPTS
622 df $MOUNT > /dev/null 2>&1
623 [ $rc -ne 0 ] && error "e2fsck should not report error upon "\
624 "short/long symlink MDT: rc=$rc"
627 run_test 17m "run e2fsck against MDT which contains short/long symlink"
629 check_fs_consistency_17n() {
635 for mdt_index in $(seq 1 $MDSCOUNT); do
636 devname=$(mdsdevname $mdt_index)
637 cmd="$E2FSCK -fnvd $devname"
639 echo "stop and checking mds${mdt_index}: $cmd"
640 # e2fsck should not return error
642 do_facet mds${mdt_index} $cmd || rc=$?
644 start mds${mdt_index} $devname $MDS_MOUNT_OPTS
645 df $MOUNT > /dev/null 2>&1
646 [ $rc -ne 0 ] && break
654 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] &&
655 [ $(lustre_version_code $SINGLEMDS) -le $(version_code 2.2.93) ] &&
656 skip "MDS 2.2.0-2.2.93 do not NUL-terminate symlinks" && return
658 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
659 skip "only for ldiskfs MDT" && return 0
661 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 2 MDTs" && return
663 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
666 for ((i=0; i<10; i++)); do
667 $LFS mkdir -i 1 $DIR/$tdir/remote_dir_${i} ||
668 error "create remote dir error $i"
669 createmany -o $DIR/$tdir/remote_dir_${i}/f 10 ||
670 error "create files under remote dir failed $i"
673 check_fs_consistency_17n || error "e2fsck report error"
675 for ((i=0;i<10;i++)); do
676 rm -rf $DIR/$tdir/remote_dir_${i} ||
677 error "destroy remote dir error $i"
680 check_fs_consistency_17n || error "e2fsck report error"
682 run_test 17n "run e2fsck against master/slave MDT which contains remote dir"
685 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.3.64) ] &&
686 skip "Need MDS version at least 2.3.64" && return
688 local WDIR=$DIR/${tdir}o
694 mdt_index=$($LFS getstripe -M $WDIR)
695 mdt_index=$((mdt_index+1))
696 mdtdevname=$(mdsdevname $mdt_index)
700 start mds${mdt_index} $mdtdevname $MDS_MOUNT_OPTS
702 #define OBD_FAIL_OSD_LMA_INCOMPAT 0x194
703 do_facet mds${mdt_index} lctl set_param fail_loc=0x194
704 ls -l $WDIR/$tfile && rc=1
705 do_facet mds${mdt_index} lctl set_param fail_loc=0
706 [[ $rc -ne 0 ]] && error "stat file should fail"
709 run_test 17o "stat file with incompat LMA feature"
712 touch $DIR/f || error "Failed to touch $DIR/f: $?"
713 ls $DIR || error "Failed to ls $DIR: $?"
715 run_test 18 "touch .../f ; ls ... =============================="
721 $CHECKSTAT -a $DIR/$tfile || error "$tfile was not removed"
723 run_test 19a "touch .../f19 ; ls -l ... ; rm .../f19 ==========="
726 ls -l $DIR/$tfile && error "ls -l $tfile failed"|| true
728 run_test 19b "ls -l .../f19 (should return error) =============="
731 [ $RUNAS_ID -eq $UID ] &&
732 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
733 $RUNAS touch $DIR/$tfile && error "create non-root file failed" || true
735 run_test 19c "$RUNAS touch .../f19 (should return error) =="
738 cat $DIR/f19 && error || true
740 run_test 19d "cat .../f19 (should return error) =============="
752 $CHECKSTAT -a $DIR/$tfile || error "$tfile was not removed"
754 run_test 20 "touch .../f ; ls -l ... ==========================="
757 test_mkdir -p $DIR/$tdir
758 [ -f $DIR/$tdir/dangle ] && rm -f $DIR/$tdir/dangle
759 ln -s dangle $DIR/$tdir/link
760 echo foo >> $DIR/$tdir/link
761 cat $DIR/$tdir/dangle
762 $CHECKSTAT -t link $DIR/$tdir/link || error "$tdir/link not a link"
763 $CHECKSTAT -f -t file $DIR/$tdir/link ||
764 error "$tdir/link not linked to a file"
766 run_test 21 "write to dangling link ============================"
770 test_mkdir -p $DIR/$tdir
771 chown $RUNAS_ID:$RUNAS_GID $WDIR
772 (cd $WDIR || error "cd $WDIR failed";
773 $RUNAS tar cf - /etc/hosts /etc/sysconfig/network | \
775 ls -lR $WDIR/etc || error "ls -lR $WDIR/etc failed"
776 $CHECKSTAT -t dir $WDIR/etc || error "checkstat -t dir failed"
777 $CHECKSTAT -u \#$RUNAS_ID -g \#$RUNAS_GID $WDIR/etc || error "checkstat -u failed"
779 run_test 22 "unpack tar archive as non-root user ==============="
783 test_mkdir -p $DIR/$tdir
784 local file=$DIR/$tdir/$tfile
786 openfile -f O_CREAT:O_EXCL $file || error "$file create failed"
787 openfile -f O_CREAT:O_EXCL $file &&
788 error "$file recreate succeeded" || true
790 run_test 23a "O_CREAT|O_EXCL in subdir =========================="
792 test_23b() { # bug 18988
793 test_mkdir -p $DIR/$tdir
794 local file=$DIR/$tdir/$tfile
797 echo foo > $file || error "write filed"
798 echo bar >> $file || error "append filed"
799 $CHECKSTAT -s 8 $file || error "wrong size"
802 run_test 23b "O_APPEND check =========================="
806 echo '-- same directory rename'
807 test_mkdir $DIR/$tdir
808 touch $DIR/$tdir/$tfile.1
809 mv $DIR/$tdir/$tfile.1 $DIR/$tdir/$tfile.2
810 $CHECKSTAT -t file $DIR/$tdir/$tfile.2 || error "$tfile.2 not a file"
812 run_test 24a "rename file to non-existent target"
815 test_mkdir $DIR/$tdir
816 touch $DIR/$tdir/$tfile.{1,2}
817 mv $DIR/$tdir/$tfile.1 $DIR/$tdir/$tfile.2
818 $CHECKSTAT -a $DIR/$tdir/$tfile.1 || error "$tfile.1 exists"
819 $CHECKSTAT -t file $DIR/$tdir/$tfile.2 || error "$tfile.2 not a file"
821 run_test 24b "rename file to existing target"
824 test_mkdir $DIR/$tdir
825 test_mkdir $DIR/$tdir/d$testnum.1
826 mv $DIR/$tdir/d$testnum.1 $DIR/$tdir/d$testnum.2
827 $CHECKSTAT -a $DIR/$tdir/d$testnum.1 || error "d$testnum.1 exists"
828 $CHECKSTAT -t dir $DIR/$tdir/d$testnum.2 || error "d$testnum.2 not dir"
830 run_test 24c "rename directory to non-existent target"
833 test_mkdir $DIR/$tdir
834 test_mkdir $DIR/$tdir/d$testnum.1
835 test_mkdir $DIR/$tdir/d$ttestnum.2
836 mrename $DIR/$tdir/d$testnum.1 $DIR/$tdir/d$testnum.2
837 $CHECKSTAT -a $DIR/$tdir/d$testnum.1 || error "d$testnum.1 exists"
838 $CHECKSTAT -t dir $DIR/$tdir/d$testnum.2 || error "d$testnum.2 not dir"
840 run_test 24d "rename directory to existing target"
843 echo '-- cross directory renames --'
847 mv $DIR/R5a/f $DIR/R5b/g
848 $CHECKSTAT -a $DIR/R5a/f || error
849 $CHECKSTAT -t file $DIR/R5b/g || error
851 run_test 24e "touch .../R5a/f; rename .../R5a/f .../R5b/g ======"
856 touch $DIR/R6a/f $DIR/R6b/g
857 mv $DIR/R6a/f $DIR/R6b/g
858 $CHECKSTAT -a $DIR/R6a/f || error
859 $CHECKSTAT -t file $DIR/R6b/g || error
861 run_test 24f "touch .../R6a/f R6b/g; mv .../R6a/f .../R6b/g ===="
866 test_mkdir $DIR/R7a/d
867 mv $DIR/R7a/d $DIR/R7b/e
868 $CHECKSTAT -a $DIR/R7a/d || error
869 $CHECKSTAT -t dir $DIR/R7b/e || error
871 run_test 24g "mkdir .../R7{a,b}/d; mv .../R7a/d .../R7b/e ======"
876 test_mkdir $DIR/R8a/d
877 test_mkdir $DIR/R8b/e
878 mrename $DIR/R8a/d $DIR/R8b/e
879 $CHECKSTAT -a $DIR/R8a/d || error
880 $CHECKSTAT -t dir $DIR/R8b/e || error
882 run_test 24h "mkdir .../R8{a,b}/{d,e}; rename .../R8a/d .../R8b/e"
885 echo "-- rename error cases"
889 mrename $DIR/R9/f $DIR/R9/a
890 $CHECKSTAT -t file $DIR/R9/f || error
891 $CHECKSTAT -t dir $DIR/R9/a || error
892 $CHECKSTAT -a $DIR/R9/a/f || error
894 run_test 24i "rename file to dir error: touch f ; mkdir a ; rename f a"
898 mrename $DIR/R10/f $DIR/R10/g
899 $CHECKSTAT -t dir $DIR/R10 || error
900 $CHECKSTAT -a $DIR/R10/f || error
901 $CHECKSTAT -a $DIR/R10/g || error
903 run_test 24j "source does not exist ============================"
907 test_mkdir $DIR/R11a/d
909 mv $DIR/R11a/f $DIR/R11a/d
910 $CHECKSTAT -a $DIR/R11a/f || error
911 $CHECKSTAT -t file $DIR/R11a/d/f || error
913 run_test 24k "touch .../R11a/f; mv .../R11a/f .../R11a/d ======="
915 # bug 2429 - rename foo foo foo creates invalid file
918 $MULTIOP $f OcNs || error
920 run_test 24l "Renaming a file to itself ========================"
924 $MULTIOP $f OcLN ${f}2 ${f}2 || error "link ${f}2 ${f}2 failed"
925 # on ext3 this does not remove either the source or target files
926 # though the "expected" operation would be to remove the source
927 $CHECKSTAT -t file ${f} || error "${f} missing"
928 $CHECKSTAT -t file ${f}2 || error "${f}2 missing"
930 run_test 24m "Renaming a file to a hard link to itself ========="
934 # this stats the old file after it was renamed, so it should fail
938 $CHECKSTAT ${f}.rename
941 run_test 24n "Statting the old file after renaming (Posix rename 2)"
944 check_kernel_version 37 || return 0
945 test_mkdir -p $DIR/d24o
946 rename_many -s random -v -n 10 $DIR/d24o
948 run_test 24o "rename of files during htree split ==============="
953 DIRINO=`ls -lid $DIR/R12a | awk '{ print $1 }'`
954 mrename $DIR/R12a $DIR/R12b
955 $CHECKSTAT -a $DIR/R12a || error
956 $CHECKSTAT -t dir $DIR/R12b || error
957 DIRINO2=`ls -lid $DIR/R12b | awk '{ print $1 }'`
958 [ "$DIRINO" = "$DIRINO2" ] || error "R12a $DIRINO != R12b $DIRINO2"
960 run_test 24p "mkdir .../R12{a,b}; rename .../R12a .../R12b"
962 cleanup_multiop_pause() {
968 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
971 local DIRINO=$(ls -lid $DIR/R13a | awk '{ print $1 }')
972 multiop_bg_pause $DIR/R13b D_c || error "multiop failed to start"
975 trap cleanup_multiop_pause EXIT
976 mrename $DIR/R13a $DIR/R13b
977 $CHECKSTAT -a $DIR/R13a || error "R13a still exists"
978 $CHECKSTAT -t dir $DIR/R13b || error "R13b does not exist"
979 local DIRINO2=$(ls -lid $DIR/R13b | awk '{ print $1 }')
980 [ "$DIRINO" = "$DIRINO2" ] || error "R13a $DIRINO != R13b $DIRINO2"
981 cleanup_multiop_pause
982 wait $MULTIPID || error "multiop close failed"
984 run_test 24q "mkdir .../R13{a,b}; open R13b rename R13a R13b ==="
986 test_24r() { #bug 3789
988 test_mkdir $DIR/R14a/b
989 mrename $DIR/R14a $DIR/R14a/b && error "rename to subdir worked!"
990 $CHECKSTAT -t dir $DIR/R14a || error "$DIR/R14a missing"
991 $CHECKSTAT -t dir $DIR/R14a/b || error "$DIR/R14a/b missing"
993 run_test 24r "mkdir .../R14a/b; rename .../R14a .../R14a/b ====="
997 test_mkdir $DIR/R15a/b
998 test_mkdir $DIR/R15a/b/c
999 mrename $DIR/R15a $DIR/R15a/b/c && error "rename to sub-subdir worked!"
1000 $CHECKSTAT -t dir $DIR/R15a || error "$DIR/R15a missing"
1001 $CHECKSTAT -t dir $DIR/R15a/b/c || error "$DIR/R15a/b/c missing"
1003 run_test 24s "mkdir .../R15a/b/c; rename .../R15a .../R15a/b/c ="
1005 test_mkdir $DIR/R16a
1006 test_mkdir $DIR/R16a/b
1007 test_mkdir $DIR/R16a/b/c
1008 mrename $DIR/R16a/b/c $DIR/R16a && error "rename to sub-subdir worked!"
1009 $CHECKSTAT -t dir $DIR/R16a || error "$DIR/R16a missing"
1010 $CHECKSTAT -t dir $DIR/R16a/b/c || error "$DIR/R16a/b/c missing"
1012 run_test 24t "mkdir .../R16a/b/c; rename .../R16a/b/c .../R16a ="
1014 test_24u() { # bug12192
1016 $MULTIOP $DIR/$tfile C2w$((2048 * 1024))c || error
1017 $CHECKSTAT -s $((2048 * 1024)) $DIR/$tfile || error "wrong file size"
1019 run_test 24u "create stripe file"
1025 simple_cleanup_common() {
1028 wait_delete_completed
1031 max_pages_per_rpc() {
1032 $LCTL get_param -n mdc.*.max_pages_per_rpc | head -n1
1036 local NRFILES=100000
1037 local FREE_INODES=$(mdt_free_inodes 0)
1038 [[ $FREE_INODES -lt $NRFILES ]] &&
1039 skip "not enough free inodes $FREE_INODES required $NRFILES" &&
1042 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1043 trap simple_cleanup_common EXIT
1045 # Performance issue on ZFS see LU-4072 (c.f. LU-2887)
1046 [ $(facet_fstype $SINGLEMDS) = "zfs" ] && NRFILES=10000
1049 createmany -m $DIR/$tdir/$tfile $NRFILES
1051 cancel_lru_locks mdc
1052 lctl set_param mdc.*.stats clear
1054 ls $DIR/$tdir >/dev/null || error "error in listing large dir"
1056 # LU-5 large readdir
1057 # DIRENT_SIZE = 32 bytes for sizeof(struct lu_dirent) +
1058 # 8 bytes for name(filename is mostly 5 in this test) +
1059 # 8 bytes for luda_type
1060 # take into account of overhead in lu_dirpage header and end mark in
1061 # each page, plus one in RPC_NUM calculation.
1063 RPC_SIZE=$(($(max_pages_per_rpc) * $(page_size)))
1064 RPC_NUM=$(((NRFILES * DIRENT_SIZE + RPC_SIZE - 1) / RPC_SIZE + 1))
1065 mds_readpage=$(lctl get_param mdc.*MDT0000*.stats |
1066 awk '/^mds_readpage/ {print $2}')
1067 [[ $mds_readpage -gt $RPC_NUM ]] &&
1068 error "large readdir doesn't take effect"
1070 simple_cleanup_common
1072 run_test 24v "list directory with large files (handle hash collision, bug: 17560)"
1074 test_24w() { # bug21506
1076 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=4096 || return 1
1077 dd if=/dev/zero bs=$SZ1 count=1 >> $DIR/$tfile || return 2
1078 dd if=$DIR/$tfile of=$DIR/${tfile}_left bs=1M skip=4097 || return 3
1079 SZ2=`ls -l $DIR/${tfile}_left | awk '{print $5}'`
1080 [ "$SZ1" = "$SZ2" ] || \
1081 error "Error reading at the end of the file $tfile"
1083 run_test 24w "Reading a file larger than 4Gb"
1086 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 2 MDTs" && return
1087 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1089 local remote_dir=$DIR/$tdir/remote_dir
1092 $LFS mkdir -i $MDTIDX $remote_dir ||
1093 error "create remote directory failed"
1095 mkdir -p $DIR/$tdir/src_dir
1096 touch $DIR/$tdir/src_file
1097 mkdir -p $remote_dir/tgt_dir
1098 touch $remote_dir/tgt_file
1100 mrename $remote_dir $DIR/ &&
1101 error "rename dir cross MDT works!"
1103 mrename $DIR/$tdir/src_dir $remote_dir/tgt_dir &&
1104 error "rename dir cross MDT works!"
1106 mrename $DIR/$tdir/src_file $remote_dir/tgt_file &&
1107 error "rename file cross MDT works!"
1109 ln $DIR/$tdir/src_file $remote_dir/tgt_file1 &&
1110 error "ln file cross MDT should not work!"
1112 rm -rf $DIR/$tdir || error "Can not delete directories"
1114 run_test 24x "cross rename/link should be failed"
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
1123 $LFS mkdir -i $MDTIDX $remote_dir ||
1124 error "create remote directory failed"
1126 mkdir -p $remote_dir/src_dir
1127 touch $remote_dir/src_file
1128 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"
1145 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 2 MDTs" && return
1146 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1148 local remote_src=$DIR/$tdir/remote_dir
1149 local remote_tgt=$DIR/$tdir/remote_tgt
1152 $LFS mkdir -i $MDTIDX $remote_src ||
1153 error "create remote directory failed"
1155 $LFS mkdir -i $MDTIDX $remote_tgt ||
1156 error "create remote directory failed"
1158 mrename $remote_src $remote_tgt &&
1159 error "rename remote dirs should not work!"
1161 # If target dir does not exists, it should succeed
1163 mrename $remote_src $remote_tgt ||
1164 error "rename remote dirs(tgt dir does not exists) failed!"
1166 rm -rf $DIR/$tdir || error "Can not delete directories"
1168 run_test 24z "rename one remote dir to another remote dir should fail"
1170 test_24A() { # LU-3182
1174 createmany -m $DIR/$tdir/$tfile $NFILES
1175 local t=`ls $DIR/$tdir | wc -l`
1176 local u=`ls $DIR/$tdir | sort -u | wc -l`
1177 if [ $t -ne $NFILES -o $u -ne $NFILES ] ; then
1178 error "Expected $NFILES files, got $t ($u unique)"
1181 rm -rf $DIR/$tdir || error "Can not delete directories"
1183 run_test 24A "readdir() returns correct number of entries."
1186 echo '== symlink sanity ============================================='
1190 touch $DIR/s25/foo || error
1192 run_test 25a "create file in symlinked directory ==============="
1195 [ ! -d $DIR/d25 ] && test_25a
1196 $CHECKSTAT -t file $DIR/s25/foo || error
1198 run_test 25b "lookup file in symlinked directory ==============="
1202 test_mkdir $DIR/d26/d26-2
1203 ln -s d26/d26-2 $DIR/s26
1204 touch $DIR/s26/foo || error
1206 run_test 26a "multiple component symlink ======================="
1209 test_mkdir -p $DIR/d26b/d26-2
1210 ln -s d26b/d26-2/foo $DIR/s26-2
1211 touch $DIR/s26-2 || error
1213 run_test 26b "multiple component symlink at end of lookup ======"
1216 test_mkdir $DIR/d26.2
1217 touch $DIR/d26.2/foo
1218 ln -s d26.2 $DIR/s26.2-1
1219 ln -s s26.2-1 $DIR/s26.2-2
1220 ln -s s26.2-2 $DIR/s26.2-3
1221 chmod 0666 $DIR/s26.2-3/foo
1223 run_test 26c "chain of symlinks ================================"
1225 # recursive symlinks (bug 439)
1227 ln -s d26-3/foo $DIR/d26-3
1229 run_test 26d "create multiple component recursive symlink ======"
1232 [ ! -h $DIR/d26-3 ] && test_26d
1235 run_test 26e "unlink multiple component recursive symlink ======"
1237 # recursive symlinks (bug 7022)
1239 test_mkdir -p $DIR/$tdir
1240 test_mkdir $DIR/$tdir/$tfile || error "mkdir $DIR/$tdir/$tfile failed"
1241 cd $DIR/$tdir/$tfile || error "cd $DIR/$tdir/$tfile failed"
1242 test_mkdir -p lndir/bar1 || error "mkdir lndir/bar1 failed"
1243 test_mkdir $DIR/$tdir/$tfile/$tfile || error "mkdir $tfile failed"
1244 cd $tfile || error "cd $tfile failed"
1245 ln -s .. dotdot || error "ln dotdot failed"
1246 ln -s dotdot/lndir lndir || error "ln lndir failed"
1247 cd $DIR/$tdir || error "cd $DIR/$tdir failed"
1248 output=`ls $tfile/$tfile/lndir/bar1`
1249 [ "$output" = bar1 ] && error "unexpected output"
1250 rm -r $tfile || error "rm $tfile failed"
1251 $CHECKSTAT -a $DIR/$tfile || error "$tfile not gone"
1253 run_test 26f "rm -r of a directory which has recursive symlink ="
1256 echo '== stripe sanity =============================================='
1257 test_mkdir -p $DIR/d27 || error "mkdir failed"
1259 $SETSTRIPE -c 1 $DIR/d27/f0 || error "setstripe failed"
1260 $CHECKSTAT -t file $DIR/d27/f0 || error "checkstat failed"
1261 log "== test_27a: write to one stripe file ========================="
1262 cp /etc/hosts $DIR/d27/f0 || error
1264 run_test 27a "one stripe file =================================="
1267 [[ $OSTCOUNT -lt 2 ]] && skip_env "skipping 2-stripe test" && return
1268 test_mkdir -p $DIR/d27
1269 $SETSTRIPE -c 2 $DIR/d27/f01 || error "setstripe failed"
1270 $GETSTRIPE -c $DIR/d27/f01
1271 [ $($GETSTRIPE -c $DIR/d27/f01) -eq 2 ] ||
1272 error "two-stripe file doesn't have two stripes"
1274 dd if=/dev/zero of=$DIR/d27/f01 bs=4k count=4 || error "dd failed"
1276 run_test 27b "create and write to two stripe file"
1279 test_mkdir -p $DIR/d27
1280 $SETSTRIPE -c 0 -i -1 -S 0 $DIR/d27/fdef || error "setstripe failed"
1281 $CHECKSTAT -t file $DIR/d27/fdef || error "checkstat failed"
1282 dd if=/dev/zero of=$DIR/d27/fdef bs=4k count=4 || error
1284 run_test 27d "create file with default settings ================"
1287 test_mkdir -p $DIR/d27
1288 $SETSTRIPE -c 2 $DIR/d27/f12 || error "setstripe failed"
1289 $SETSTRIPE -c 2 $DIR/d27/f12 && error "setstripe succeeded twice"
1290 $CHECKSTAT -t file $DIR/d27/f12 || error "checkstat failed"
1292 run_test 27e "setstripe existing file (should return error) ======"
1295 test_mkdir -p $DIR/d27
1296 $SETSTRIPE -S 100 -i 0 -c 1 $DIR/d27/fbad && error "setstripe failed"
1297 dd if=/dev/zero of=$DIR/d27/fbad bs=4k count=4 || error "dd failed"
1298 $GETSTRIPE $DIR/d27/fbad || error "$GETSTRIPE failed"
1300 run_test 27f "setstripe with bad stripe size (should return error)"
1303 test_mkdir -p $DIR/d27
1304 $MCREATE $DIR/d27/fnone || error "mcreate failed"
1305 $GETSTRIPE $DIR/d27/fnone 2>&1 | grep "no stripe info" ||
1306 error "$DIR/d27/fnone has object"
1308 run_test 27g "$GETSTRIPE with no objects"
1311 touch $DIR/d27/fsome || error "touch failed"
1312 [[ $($GETSTRIPE -c $DIR/d27/fsome) -gt 0 ]] || error "missing objects"
1314 run_test 27i "$GETSTRIPE with some objects"
1317 test_mkdir -p $DIR/d27
1318 $SETSTRIPE -i $OSTCOUNT $DIR/d27/f27j && error "setstripe failed"||true
1320 run_test 27j "setstripe with bad stripe offset (should return error)"
1322 test_27k() { # bug 2844
1323 test_mkdir -p $DIR/d27
1325 LL_MAX_BLKSIZE=$((4 * 1024 * 1024))
1326 [ ! -d $DIR/d27 ] && test_mkdir -p $DIR d27
1327 $SETSTRIPE -S 67108864 $FILE || error "setstripe failed"
1328 BLKSIZE=`stat $FILE | awk '/IO Block:/ { print $7 }'`
1329 [ $BLKSIZE -le $LL_MAX_BLKSIZE ] || error "$BLKSIZE > $LL_MAX_BLKSIZE"
1330 dd if=/dev/zero of=$FILE bs=4k count=1
1331 BLKSIZE=`stat $FILE | awk '/IO Block:/ { print $7 }'`
1332 [ $BLKSIZE -le $LL_MAX_BLKSIZE ] || error "$BLKSIZE > $LL_MAX_BLKSIZE"
1334 run_test 27k "limit i_blksize for broken user apps ============="
1337 test_mkdir -p $DIR/d27
1338 mcreate $DIR/f27l || error "creating file"
1339 $RUNAS $SETSTRIPE -c 1 $DIR/f27l && \
1340 error "setstripe should have failed" || true
1342 run_test 27l "check setstripe permissions (should return error)"
1345 [[ $OSTCOUNT -lt 2 ]] && skip_env "$OSTCOUNT < 2 OSTs -- skipping" &&
1347 if [[ $ORIGFREE -gt $MAXFREE ]]; then
1348 skip "$ORIGFREE > $MAXFREE skipping out-of-space test on OST0"
1351 trap simple_cleanup_common EXIT
1352 test_mkdir -p $DIR/$tdir
1353 $SETSTRIPE -i 0 -c 1 $DIR/$tdir/f27m_1
1354 dd if=/dev/zero of=$DIR/$tdir/f27m_1 bs=1024 count=$MAXFREE &&
1355 error "dd should fill OST0"
1357 while $SETSTRIPE -i 0 -c 1 $DIR/$tdir/f27m_$i; do
1359 [ $i -gt 256 ] && break
1362 touch $DIR/$tdir/f27m_$i
1363 [ `$GETSTRIPE $DIR/$tdir/f27m_$i | grep -A 10 obdidx | awk '{print $1}'| grep -w "0"` ] &&
1364 error "OST0 was full but new created file still use it"
1366 touch $DIR/$tdir/f27m_$i
1367 [ `$GETSTRIPE $DIR/$tdir/f27m_$i | grep -A 10 obdidx | awk '{print $1}'| grep -w "0"` ] &&
1368 error "OST0 was full but new created file still use it"
1369 simple_cleanup_common
1371 run_test 27m "create file while OST0 was full =================="
1374 local DELAY=$(do_facet $SINGLEMDS lctl get_param -n lov.*.qos_maxage | head -n 1 | awk '{print $1 * 2}')
1378 # OSCs keep a NOSPC flag that will be reset after ~5s (qos_maxage)
1379 # if the OST isn't full anymore.
1381 local OSTIDX=${1:-""}
1383 local list=$(comma_list $(osts_nodes))
1384 [ "$OSTIDX" ] && list=$(facet_host ost$((OSTIDX + 1)))
1386 do_nodes $list lctl set_param fail_loc=0
1387 sync # initiate all OST_DESTROYs from MDS to OST
1391 exhaust_precreations() {
1394 local FAILIDX=${3:-$OSTIDX}
1396 test_mkdir -p $DIR/$tdir
1397 local MDSIDX=$(get_mds_dir "$DIR/$tdir")
1398 echo OSTIDX=$OSTIDX MDSIDX=$MDSIDX
1400 local OST=$(ostname_from_index $OSTIDX)
1401 local MDT_INDEX=$(lfs df | grep "\[MDT:$((MDSIDX - 1))\]" | awk '{print $1}' | \
1402 sed -e 's/_UUID$//;s/^.*-//')
1405 local mdtosc_proc1=$(get_mdtosc_proc_path mds${MDSIDX} $OST)
1406 local last_id=$(do_facet mds${MDSIDX} lctl get_param -n \
1407 osc.$mdtosc_proc1.prealloc_last_id)
1408 local next_id=$(do_facet mds${MDSIDX} lctl get_param -n \
1409 osc.$mdtosc_proc1.prealloc_next_id)
1411 local mdtosc_proc2=$(get_mdtosc_proc_path mds${MDSIDX})
1412 do_facet mds${MDSIDX} lctl get_param osc.$mdtosc_proc2.prealloc*
1414 test_mkdir -p $DIR/$tdir/${OST}
1415 $SETSTRIPE -i $OSTIDX -c 1 $DIR/$tdir/${OST}
1416 #define OBD_FAIL_OST_ENOSPC 0x215
1417 do_facet ost$((OSTIDX + 1)) lctl set_param fail_val=$FAILIDX
1418 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=0x215
1419 echo "Creating to objid $last_id on ost $OST..."
1420 createmany -o $DIR/$tdir/${OST}/f $next_id $((last_id - next_id + 2))
1421 do_facet mds${MDSIDX} lctl get_param osc.$mdtosc_proc2.prealloc*
1422 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=$FAILLOC
1426 exhaust_all_precreations() {
1428 for (( i=0; i < OSTCOUNT; i++ )) ; do
1429 exhaust_precreations $i $1 -1
1434 [[ $OSTCOUNT -lt 2 ]] && skip_env "too few OSTs" && return
1435 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1436 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1437 remote_ost_nodsh && skip "remote OST with nodsh" && return
1440 rm -f $DIR/$tdir/$tfile
1441 exhaust_precreations 0 0x80000215
1442 $SETSTRIPE -c -1 $DIR/$tdir
1443 touch $DIR/$tdir/$tfile || error
1444 $GETSTRIPE $DIR/$tdir/$tfile
1447 run_test 27n "create file with some full OSTs =================="
1450 [[ $OSTCOUNT -lt 2 ]] && skip_env "too few OSTs" && return
1451 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1452 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1453 remote_ost_nodsh && skip "remote OST with nodsh" && return
1456 rm -f $DIR/$tdir/$tfile
1457 exhaust_all_precreations 0x215
1459 touch $DIR/$tdir/$tfile && error "able to create $DIR/$tdir/$tfile"
1464 run_test 27o "create file with all full OSTs (should error) ===="
1467 [[ $OSTCOUNT -lt 2 ]] && skip_env "too few OSTs" && return
1468 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1469 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1470 remote_ost_nodsh && skip "remote OST with nodsh" && return
1473 rm -f $DIR/$tdir/$tfile
1474 test_mkdir -p $DIR/$tdir
1476 $MCREATE $DIR/$tdir/$tfile || error "mcreate failed"
1477 $TRUNCATE $DIR/$tdir/$tfile 80000000 || error "truncate failed"
1478 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat failed"
1480 exhaust_precreations 0 0x80000215
1481 echo foo >> $DIR/$tdir/$tfile || error "append failed"
1482 $CHECKSTAT -s 80000004 $DIR/$tdir/$tfile || error "checkstat failed"
1483 $GETSTRIPE $DIR/$tdir/$tfile
1487 run_test 27p "append to a truncated file with some full OSTs ==="
1490 [[ $OSTCOUNT -lt 2 ]] && skip_env "too few OSTs" && return
1491 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1492 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1493 remote_ost_nodsh && skip "remote OST with nodsh" && return
1496 rm -f $DIR/$tdir/$tfile
1498 test_mkdir -p $DIR/$tdir
1499 $MCREATE $DIR/$tdir/$tfile || error "mcreate $DIR/$tdir/$tfile failed"
1500 $TRUNCATE $DIR/$tdir/$tfile 80000000 ||error "truncate $DIR/$tdir/$tfile failed"
1501 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat failed"
1503 exhaust_all_precreations 0x215
1505 echo foo >> $DIR/$tdir/$tfile && error "append succeeded"
1506 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat 2 failed"
1510 run_test 27q "append to truncated file with all OSTs full (should error) ==="
1513 [[ $OSTCOUNT -lt 2 ]] && skip_env "too few OSTs" && return
1514 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1515 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1516 remote_ost_nodsh && skip "remote OST with nodsh" && return
1519 rm -f $DIR/$tdir/$tfile
1520 exhaust_precreations 0 0x80000215
1522 $SETSTRIPE -i 0 -c 2 $DIR/$tdir/$tfile # && error
1526 run_test 27r "stripe file with some full OSTs (shouldn't LBUG) ="
1528 test_27s() { # bug 10725
1529 test_mkdir -p $DIR/$tdir
1530 local stripe_size=$((4096 * 1024 * 1024)) # 2^32
1531 local stripe_count=0
1532 [ $OSTCOUNT -eq 1 ] || stripe_count=2
1533 $SETSTRIPE -S $stripe_size -c $stripe_count $DIR/$tdir &&
1534 error "stripe width >= 2^32 succeeded" || true
1537 run_test 27s "lsm_xfersize overflow (should error) (bug 10725)"
1539 test_27t() { # bug 10864
1544 $WLFS getstripe $tfile
1547 run_test 27t "check that utils parse path correctly"
1549 test_27u() { # bug 4900
1550 [[ $OSTCOUNT -lt 2 ]] && skip_env "too few OSTs" && return
1551 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1553 local list=$(comma_list $(mdts_nodes))
1555 #define OBD_FAIL_MDS_OSC_PRECREATE 0x139
1556 do_nodes $list $LCTL set_param fail_loc=0x139
1557 test_mkdir -p $DIR/$tdir
1559 createmany -o $DIR/$tdir/t- 1000
1560 do_nodes $list $LCTL set_param fail_loc=0
1562 TLOG=$DIR/$tfile.getstripe
1563 $GETSTRIPE $DIR/$tdir > $TLOG
1564 OBJS=$(awk -vobj=0 '($1 == 0) { obj += 1 } END { print obj; }' $TLOG)
1565 unlinkmany $DIR/$tdir/t- 1000
1566 [[ $OBJS -gt 0 ]] &&
1567 error "$OBJS objects created on OST-0. See $TLOG" || pass
1569 run_test 27u "skip object creation on OSC w/o objects =========="
1571 test_27v() { # bug 4900
1572 [[ $OSTCOUNT -lt 2 ]] && skip_env "too few OSTs" && return
1573 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1574 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1575 remote_ost_nodsh && skip "remote OST with nodsh" && return
1577 exhaust_all_precreations 0x215
1580 test_mkdir -p $DIR/$tdir
1581 $SETSTRIPE -c 1 $DIR/$tdir # 1 stripe / file
1583 touch $DIR/$tdir/$tfile
1584 #define OBD_FAIL_TGT_DELAY_PRECREATE 0x705
1586 for (( i=1; i < OSTCOUNT; i++ )); do
1587 do_facet ost$i lctl set_param fail_loc=0x705
1589 local START=`date +%s`
1590 createmany -o $DIR/$tdir/$tfile 32
1592 local FINISH=`date +%s`
1593 local TIMEOUT=`lctl get_param -n timeout`
1594 local PROCESS=$((FINISH - START))
1595 [ $PROCESS -ge $((TIMEOUT / 2)) ] && \
1596 error "$FINISH - $START >= $TIMEOUT / 2"
1597 sleep $((TIMEOUT / 2 - PROCESS))
1600 run_test 27v "skip object creation on slow OST ================="
1602 test_27w() { # bug 10997
1603 test_mkdir -p $DIR/$tdir || error "mkdir failed"
1604 $SETSTRIPE -S 65536 $DIR/$tdir/f0 || error "setstripe failed"
1605 [ $($GETSTRIPE -S $DIR/$tdir/f0) -ne 65536 ] &&
1606 error "stripe size $size != 65536" || true
1607 [ $($GETSTRIPE -d $DIR/$tdir | grep -c "stripe_count") -ne 1 ] &&
1608 error "$GETSTRIPE -d $DIR/$tdir failed" || true
1610 run_test 27w "check $SETSTRIPE -S option"
1613 [[ $OSTCOUNT -lt 2 ]] &&
1614 skip_env "skipping multiple stripe count/offset test" && return
1616 test_mkdir -p $DIR/$tdir || error "mkdir failed"
1617 for i in $(seq 1 $OSTCOUNT); do
1619 $SETSTRIPE -c $i -i $offset $DIR/$tdir/f$i ||
1620 error "setstripe -c $i -i $offset failed"
1621 count=$($GETSTRIPE -c $DIR/$tdir/f$i)
1622 index=$($GETSTRIPE -i $DIR/$tdir/f$i)
1623 [ $count -ne $i ] && error "stripe count $count != $i" || true
1624 [ $index -ne $offset ] &&
1625 error "stripe offset $index != $offset" || true
1628 run_test 27wa "check $SETSTRIPE -c -i options"
1631 remote_ost_nodsh && skip "remote OST with nodsh" && return
1632 [[ $OSTCOUNT -lt 2 ]] && skip_env "$OSTCOUNT < 2 OSTs" && return
1633 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1634 OFFSET=$(($OSTCOUNT - 1))
1636 local OST=$(ostname_from_index $OSTIDX)
1638 test_mkdir -p $DIR/$tdir
1639 $SETSTRIPE -c 1 $DIR/$tdir # 1 stripe per file
1640 do_facet ost$((OSTIDX + 1)) lctl set_param -n obdfilter.$OST.degraded 1
1642 createmany -o $DIR/$tdir/$tfile $OSTCOUNT
1643 for i in `seq 0 $OFFSET`; do
1644 [ `$GETSTRIPE $DIR/$tdir/$tfile$i | grep -A 10 obdidx | awk '{print $1}' | grep -w "$OSTIDX"` ] &&
1645 error "OST0 was degraded but new created file still use it"
1647 do_facet ost$((OSTIDX + 1)) lctl set_param -n obdfilter.$OST.degraded 0
1649 run_test 27x "create files while OST0 is degraded"
1652 [[ $OSTCOUNT -lt 2 ]] &&
1653 skip_env "$OSTCOUNT < 2 OSTs -- skipping" && return
1654 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1655 remote_ost_nodsh && skip "remote OST with nodsh" && return
1656 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1658 local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS $FSNAME-OST0000)
1659 local last_id=$(do_facet $SINGLEMDS lctl get_param -n \
1660 osc.$mdtosc.prealloc_last_id)
1661 local next_id=$(do_facet $SINGLEMDS lctl get_param -n \
1662 osc.$mdtosc.prealloc_next_id)
1663 local fcount=$((last_id - next_id))
1664 [[ $fcount -eq 0 ]] && skip "not enough space on OST0" && return
1665 [[ $fcount -gt $OSTCOUNT ]] && fcount=$OSTCOUNT
1667 local MDS_OSCS=$(do_facet $SINGLEMDS lctl dl |
1668 awk '/[oO][sS][cC].*md[ts]/ { print $4 }')
1669 local OST_DEACTIVE_IDX=-1
1674 for OSC in $MDS_OSCS; do
1675 OST=$(osc_to_ost $OSC)
1676 OSTIDX=$(index_from_ostuuid $OST)
1677 if [ $OST_DEACTIVE_IDX == -1 ]; then
1678 OST_DEACTIVE_IDX=$OSTIDX
1680 if [ $OSTIDX != $OST_DEACTIVE_IDX ]; then
1681 echo $OSC "is Deactivated:"
1682 do_facet $SINGLEMDS lctl --device %$OSC deactivate
1686 OSTIDX=$(index_from_ostuuid $OST)
1688 $SETSTRIPE -c 1 $DIR/$tdir # 1 stripe / file
1690 for OSC in $MDS_OSCS; do
1691 OST=$(osc_to_ost $OSC)
1692 OSTIDX=$(index_from_ostuuid $OST)
1693 if [ $OSTIDX == $OST_DEACTIVE_IDX ]; then
1694 echo $OST "is degraded:"
1695 do_facet ost$((OSTIDX+1)) lctl set_param -n \
1696 obdfilter.$OST.degraded=1
1701 createmany -o $DIR/$tdir/$tfile $fcount
1703 for OSC in $MDS_OSCS; do
1704 OST=$(osc_to_ost $OSC)
1705 OSTIDX=$(index_from_ostuuid $OST)
1706 if [ $OSTIDX == $OST_DEACTIVE_IDX ]; then
1707 echo $OST "is recovered from degraded:"
1708 do_facet ost$((OSTIDX+1)) lctl set_param -n \
1709 obdfilter.$OST.degraded=0
1711 do_facet $SINGLEMDS lctl --device %$OSC activate
1715 # all osp devices get activated, hence -1 stripe count restored
1718 # sleep 2*lod_qos_maxage seconds waiting for lod qos to notice osp
1719 # devices get activated.
1721 $SETSTRIPE -c -1 $DIR/$tfile
1722 stripecnt=$($GETSTRIPE -c $DIR/$tfile)
1724 [ $stripecnt -ne $OSTCOUNT ] &&
1725 error "Of $OSTCOUNT OSTs, only $stripecnt is available"
1728 run_test 27y "create files while OST0 is degraded and the rest inactive"
1734 lmm_count=$($GETSTRIPE -c $1)
1735 lmm_seq=$($GETSTRIPE -v $1 | awk '/lmm_seq/ { print $2 }')
1736 lmm_oid=$($GETSTRIPE -v $1 | awk '/lmm_object_id/ { print $2 }')
1738 local old_ifs="$IFS"
1740 fid=($($LFS path2fid $1))
1743 log "FID seq ${fid[1]}, oid ${fid[2]} ver ${fid[3]}"
1744 log "LOV seq $lmm_seq, oid $lmm_oid, count: $lmm_count"
1746 # compare lmm_seq and lu_fid->f_seq
1747 [ $lmm_seq = ${fid[1]} ] || { error "SEQ mismatch"; return 1; }
1748 # compare lmm_object_id and lu_fid->oid
1749 [ $lmm_oid = ${fid[2]} ] || { error "OID mismatch"; return 2; }
1751 # check the trusted.fid attribute of the OST objects of the file
1752 local have_obdidx=false
1754 $GETSTRIPE $1 | while read obdidx oid hex seq; do
1755 # skip lines up to and including "obdidx"
1756 [ -z "$obdidx" ] && break
1757 [ "$obdidx" = "obdidx" ] && have_obdidx=true && continue
1758 $have_obdidx || continue
1760 local ost=$((obdidx + 1))
1761 local dev=$(ostdevname $ost)
1764 if [ $(facet_fstype ost$ost) != ldiskfs ]; then
1765 echo "Currently only works with ldiskfs-based OSTs"
1769 log "want: stripe:$stripe_nr ost:$obdidx oid:$oid/$hex seq:$seq"
1771 #don't unmount/remount the OSTs if we don't need to do that
1772 # LU-2577 changes filter_fid to be smaller, so debugfs needs
1773 # update too, until that use mount/ll_decode_filter_fid/mount
1774 local dir=$(facet_mntpt ost$ost)
1775 local opts=${OST_MOUNT_OPTS}
1777 if ! do_facet ost$ost test -b ${dev}; then
1778 opts=$(csa_add "$opts" -o loop)
1782 do_facet ost$ost mount -t $(facet_fstype ost$ost) $opts $dev $dir ||
1783 { error "mounting $dev as $FSTYPE failed"; return 3; }
1785 seq=$(echo $seq | sed -e "s/^0x//g")
1786 if [ $seq == 0 ]; then
1787 oid_hex=$(echo $oid)
1789 oid_hex=$(echo $hex | sed -e "s/^0x//g")
1791 local obj_file=$(do_facet ost$ost find $dir/O/$seq -name $oid_hex)
1792 local ff=$(do_facet ost$ost $LL_DECODE_FILTER_FID $obj_file)
1793 do_facet ost$ost umount -d $dir
1794 start ost$ost $dev $OST_MOUNT_OPTS
1796 # re-enable when debugfs will understand new filter_fid
1797 #local ff=$(do_facet ost$ost "$DEBUGFS -c -R 'stat $obj_file' \
1798 # $dev 2>/dev/null" | grep "parent=")
1800 [ -z "$ff" ] && error "$obj_file: no filter_fid info"
1802 echo "$ff" | sed -e 's#.*objid=#got: objid=#'
1804 # /mnt/O/0/d23/23: objid=23 seq=0 parent=[0x200000400:0x1e:0x1]
1805 # fid: objid=23 seq=0 parent=[0x200000400:0x1e:0x0] stripe=1
1806 local ff_parent=$(echo $ff|sed -e 's/.*parent=.//')
1807 local ff_pseq=$(echo $ff_parent | cut -d: -f1)
1808 local ff_poid=$(echo $ff_parent | cut -d: -f2)
1809 local ff_pstripe=$(echo $ff_parent | sed -e 's/.*stripe=//')
1811 # compare lmm_seq and filter_fid->ff_parent.f_seq
1812 [ $ff_pseq = $lmm_seq ] ||
1813 error "FF parent SEQ $ff_pseq != $lmm_seq"
1814 # compare lmm_object_id and filter_fid->ff_parent.f_oid
1815 [ $ff_poid = $lmm_oid ] ||
1816 error "FF parent OID $ff_poid != $lmm_oid"
1817 [ $ff_pstripe = $stripe_nr ] ||
1818 error "FF stripe $ff_pstripe != $stripe_nr"
1820 stripe_nr=$((stripe_nr + 1))
1825 remote_ost_nodsh && skip "remote OST with nodsh" && return
1826 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1827 test_mkdir -p $DIR/$tdir
1829 $SETSTRIPE -c 1 -i 0 -S 64k $DIR/$tdir/$tfile-1 ||
1830 { error "setstripe -c -1 failed"; return 1; }
1831 # We need to send a write to every object to get parent FID info set.
1832 # This _should_ also work for setattr, but does not currently.
1833 # touch $DIR/$tdir/$tfile-1 ||
1834 dd if=/dev/zero of=$DIR/$tdir/$tfile-1 bs=1M count=1 ||
1835 { error "dd $tfile-1 failed"; return 2; }
1836 $SETSTRIPE -c -1 -i $((OSTCOUNT - 1)) -S 1M $DIR/$tdir/$tfile-2 ||
1837 { error "setstripe -c -1 failed"; return 3; }
1838 dd if=/dev/zero of=$DIR/$tdir/$tfile-2 bs=1M count=$OSTCOUNT ||
1839 { error "dd $tfile-2 failed"; return 4; }
1841 # make sure write RPCs have been sent to OSTs
1844 check_seq_oid $DIR/$tdir/$tfile-1 || return 5
1845 check_seq_oid $DIR/$tdir/$tfile-2 || return 6
1847 run_test 27z "check SEQ/OID on the MDT and OST filesystems"
1849 test_27A() { # b=19102
1850 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1851 local restore_size=$($GETSTRIPE -S $MOUNT)
1852 local restore_count=$($GETSTRIPE -c $MOUNT)
1853 local restore_offset=$($GETSTRIPE -i $MOUNT)
1854 $SETSTRIPE -c 0 -i -1 -S 0 $MOUNT
1855 wait_update $HOSTNAME "$GETSTRIPE -c $MOUNT | sed 's/ *//g'" "1" 20 ||
1856 error "stripe count $($GETSTRIPE -c $MOUNT) != 1"
1857 local default_size=$($GETSTRIPE -S $MOUNT)
1858 local default_offset=$($GETSTRIPE -i $MOUNT)
1859 local dsize=$((1024 * 1024))
1860 [ $default_size -eq $dsize ] ||
1861 error "stripe size $default_size != $dsize"
1862 [ $default_offset -eq -1 ] ||error "stripe offset $default_offset != -1"
1863 $SETSTRIPE -c $restore_count -i $restore_offset -S $restore_size $MOUNT
1865 run_test 27A "check filesystem-wide default LOV EA values"
1867 test_27B() { # LU-2523
1868 test_mkdir -p $DIR/$tdir
1869 rm -f $DIR/$tdir/f0 $DIR/$tdir/f1
1871 # open f1 with O_LOV_DELAY_CREATE
1873 # call setstripe ioctl on open file descriptor for f1
1875 multiop $DIR/$tdir/f1 oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:nB1c \
1879 # open f1 with O_LOV_DELAY_CREATE
1881 # call setstripe ioctl on open file descriptor for f1
1883 multiop $DIR/$tdir/f1 oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:uB1c
1885 # Allow multiop to fail in imitation of NFS's busted semantics.
1888 run_test 27B "call setstripe on open unlinked file/rename victim"
1890 test_27C() { #LU-2871
1891 [[ $OSTCOUNT -lt 2 ]] && skip "needs >= 2 OSTs" && return
1899 test_mkdir -p $DIR/$tdir
1901 for i in $(seq 0 $((OSTCOUNT - 1))); do
1902 # set stripe across all OSTs starting from OST$i
1903 $SETSTRIPE -i $i -c -1 $tfile$i
1904 # get striping information
1905 ost_idx=($($GETSTRIPE $tfile$i |
1906 tail -n $((OSTCOUNT + 1)) | awk '{print $1}'))
1910 [ ${#ost_idx[@]} -eq $OSTCOUNT ] ||
1911 error "${#ost_idx[@]} != $OSTCOUNT"
1913 for index in $(seq 0 $((OSTCOUNT - 1))); do
1915 for j in $(echo ${ost_idx[@]}); do
1916 if [ $index -eq $j ]; then
1922 error "Can not find $index in ${ost_idx[@]}"
1926 run_test 27C "check full striping across all OSTs"
1928 # createtest also checks that device nodes are created and
1929 # then visible correctly (#2091)
1930 test_28() { # bug 2091
1932 $CREATETEST $DIR/d28/ct || error
1934 run_test 28 "create/mknod/mkdir with bad file types ============"
1937 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1938 cancel_lru_locks mdc
1944 declare -i LOCKCOUNTORIG=0
1945 for lock_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_count); do
1946 let LOCKCOUNTORIG=$LOCKCOUNTORIG+$lock_count
1948 [ $LOCKCOUNTORIG -eq 0 ] && echo "No mdc lock count" && return 1
1950 declare -i LOCKUNUSEDCOUNTORIG=0
1951 for unused_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_unused_count); do
1952 let LOCKUNUSEDCOUNTORIG=$LOCKUNUSEDCOUNTORIG+$unused_count
1959 declare -i LOCKCOUNTCURRENT=0
1960 for lock_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_count); do
1961 let LOCKCOUNTCURRENT=$LOCKCOUNTCURRENT+$lock_count
1964 declare -i LOCKUNUSEDCOUNTCURRENT=0
1965 for unused_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_unused_count); do
1966 let LOCKUNUSEDCOUNTCURRENT=$LOCKUNUSEDCOUNTCURRENT+$unused_count
1969 if [[ $LOCKCOUNTCURRENT -gt $LOCKCOUNTORIG ]]; then
1970 $LCTL set_param -n ldlm.dump_namespaces ""
1971 error "CURRENT: $LOCKCOUNTCURRENT > $LOCKCOUNTORIG"
1972 $LCTL dk | sort -k4 -t: > $TMP/test_29.dk
1973 log "dumped log to $TMP/test_29.dk (bug 5793)"
1976 if [[ $LOCKUNUSEDCOUNTCURRENT -gt $LOCKUNUSEDCOUNTORIG ]]; then
1977 error "UNUSED: $LOCKUNUSEDCOUNTCURRENT > $LOCKUNUSEDCOUNTORIG"
1978 $LCTL dk | sort -k4 -t: > $TMP/test_29.dk
1979 log "dumped log to $TMP/test_29.dk (bug 5793)"
1983 run_test 29 "IT_GETATTR regression ============================"
1985 test_30a() { # was test_30
1986 cp $(which ls) $DIR || cp /bin/ls $DIR
1990 run_test 30a "execute binary from Lustre (execve) =============="
1993 cp `which ls` $DIR || cp /bin/ls $DIR
1995 $RUNAS $DIR/ls / || error
1998 run_test 30b "execute binary from Lustre as non-root ==========="
2000 test_30c() { # b=22376
2001 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2002 cp `which ls` $DIR || cp /bin/ls $DIR
2004 cancel_lru_locks mdc
2005 cancel_lru_locks osc
2006 $RUNAS $DIR/ls / || error
2009 run_test 30c "execute binary from Lustre without read perms ===="
2012 $OPENUNLINK $DIR/f31 $DIR/f31 || error
2013 $CHECKSTAT -a $DIR/f31 || error
2015 run_test 31a "open-unlink file =================================="
2018 touch $DIR/f31 || error
2019 ln $DIR/f31 $DIR/f31b || error
2020 $MULTIOP $DIR/f31b Ouc || error
2021 $CHECKSTAT -t file $DIR/f31 || error
2023 run_test 31b "unlink file with multiple links while open ======="
2026 touch $DIR/f31 || error
2027 ln $DIR/f31 $DIR/f31c || error
2028 multiop_bg_pause $DIR/f31 O_uc || return 1
2030 $MULTIOP $DIR/f31c Ouc
2031 kill -USR1 $MULTIPID
2034 run_test 31c "open-unlink file with multiple links ============="
2037 opendirunlink $DIR/d31d $DIR/d31d || error
2038 $CHECKSTAT -a $DIR/d31d || error
2040 run_test 31d "remove of open directory ========================="
2042 test_31e() { # bug 2904
2043 check_kernel_version 34 || return 0
2044 openfilleddirunlink $DIR/d31e || error
2046 run_test 31e "remove of open non-empty directory ==============="
2048 test_31f() { # bug 4554
2049 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2051 test_mkdir $DIR/d31f
2052 $SETSTRIPE -S 1048576 -c 1 $DIR/d31f
2053 cp /etc/hosts $DIR/d31f
2055 $GETSTRIPE $DIR/d31f/hosts
2056 multiop_bg_pause $DIR/d31f D_c || return 1
2059 rm -rv $DIR/d31f || error "first of $DIR/d31f"
2060 test_mkdir $DIR/d31f
2061 $SETSTRIPE -S 1048576 -c 1 $DIR/d31f
2062 cp /etc/hosts $DIR/d31f
2064 $GETSTRIPE $DIR/d31f/hosts
2065 multiop_bg_pause $DIR/d31f D_c || return 1
2068 kill -USR1 $MULTIPID || error "first opendir $MULTIPID not running"
2069 wait $MULTIPID || error "first opendir $MULTIPID failed"
2073 kill -USR1 $MULTIPID2 || error "second opendir $MULTIPID not running"
2074 wait $MULTIPID2 || error "second opendir $MULTIPID2 failed"
2077 run_test 31f "remove of open directory with open-unlink file ==="
2080 echo "-- cross directory link --"
2081 test_mkdir $DIR/d31ga
2082 test_mkdir $DIR/d31gb
2084 ln $DIR/d31ga/f $DIR/d31gb/g
2085 $CHECKSTAT -t file $DIR/d31ga/f || error "source"
2086 [ `stat -c%h $DIR/d31ga/f` == '2' ] || error "source nlink"
2087 $CHECKSTAT -t file $DIR/d31gb/g || error "target"
2088 [ `stat -c%h $DIR/d31gb/g` == '2' ] || error "target nlink"
2090 run_test 31g "cross directory link==============="
2093 echo "-- cross directory link --"
2094 test_mkdir $DIR/d31h
2095 test_mkdir $DIR/d31h/dir
2097 ln $DIR/d31h/f $DIR/d31h/dir/g
2098 $CHECKSTAT -t file $DIR/d31h/f || error "source"
2099 [ `stat -c%h $DIR/d31h/f` == '2' ] || error "source nlink"
2100 $CHECKSTAT -t file $DIR/d31h/dir/g || error "target"
2101 [ `stat -c%h $DIR/d31h/dir/g` == '2' ] || error "target nlink"
2103 run_test 31h "cross directory link under child==============="
2106 echo "-- cross directory link --"
2107 test_mkdir $DIR/d31i
2108 test_mkdir $DIR/d31i/dir
2109 touch $DIR/d31i/dir/f
2110 ln $DIR/d31i/dir/f $DIR/d31i/g
2111 $CHECKSTAT -t file $DIR/d31i/dir/f || error "source"
2112 [ `stat -c%h $DIR/d31i/dir/f` == '2' ] || error "source nlink"
2113 $CHECKSTAT -t file $DIR/d31i/g || error "target"
2114 [ `stat -c%h $DIR/d31i/g` == '2' ] || error "target nlink"
2116 run_test 31i "cross directory link under parent==============="
2120 test_mkdir $DIR/d31j
2121 test_mkdir $DIR/d31j/dir1
2122 ln $DIR/d31j/dir1 $DIR/d31j/dir2 && error "ln for dir"
2123 link $DIR/d31j/dir1 $DIR/d31j/dir3 && error "link for dir"
2124 mlink $DIR/d31j/dir1 $DIR/d31j/dir4 && error "mlink for dir"
2125 mlink $DIR/d31j/dir1 $DIR/d31j/dir1 && error "mlink to the same dir"
2128 run_test 31j "link for directory==============="
2132 test_mkdir $DIR/d31k
2134 touch $DIR/d31k/exist
2135 mlink $DIR/d31k/s $DIR/d31k/t || error "mlink"
2136 mlink $DIR/d31k/s $DIR/d31k/exist && error "mlink to exist file"
2137 mlink $DIR/d31k/s $DIR/d31k/s && error "mlink to the same file"
2138 mlink $DIR/d31k/s $DIR/d31k && error "mlink to parent dir"
2139 mlink $DIR/d31k $DIR/d31k/s && error "mlink parent dir to target"
2140 mlink $DIR/d31k/not-exist $DIR/d31k/foo && error "mlink non-existing to new"
2141 mlink $DIR/d31k/not-exist $DIR/d31k/s && error "mlink non-existing to exist"
2144 run_test 31k "link to file: the same, non-existing, dir==============="
2147 test_mkdir $DIR/d31m
2149 test_mkdir $DIR/d31m2
2150 touch $DIR/d31m2/exist
2151 mlink $DIR/d31m/s $DIR/d31m2/t || error "mlink"
2152 mlink $DIR/d31m/s $DIR/d31m2/exist && error "mlink to exist file"
2153 mlink $DIR/d31m/s $DIR/d31m2 && error "mlink to parent dir"
2154 mlink $DIR/d31m2 $DIR/d31m/s && error "mlink parent dir to target"
2155 mlink $DIR/d31m/not-exist $DIR/d31m2/foo && error "mlink non-existing to new"
2156 mlink $DIR/d31m/not-exist $DIR/d31m2/s && error "mlink non-existing to exist"
2159 run_test 31m "link to file: the same, non-existing, dir==============="
2162 touch $DIR/$tfile || error "cannot create '$DIR/$tfile'"
2163 nlink=$(stat --format=%h $DIR/$tfile)
2164 [ ${nlink:--1} -eq 1 ] || error "nlink is $nlink, expected 1"
2166 local cmd="exec $fd<$DIR/$tfile"
2169 trap "eval $cmd" EXIT
2170 nlink=$(stat --dereference --format=%h /proc/self/fd/$fd)
2171 [ ${nlink:--1} -eq 1 ] || error "nlink is $nlink, expected 1"
2172 rm $DIR/$tfile || error "cannot remove '$DIR/$tfile'"
2173 nlink=$(stat --dereference --format=%h /proc/self/fd/$fd)
2174 [ ${nlink:--1} -eq 0 ] || error "nlink is $nlink, expected 0"
2177 run_test 31n "check link count of unlinked file"
2180 local TEMPNAME=$(mktemp $1_XXXXXX)
2181 mlink $TEMPNAME $1 2> /dev/null &&
2182 echo "$BASHPID: link $TEMPNAME to $1 succeeded"
2186 test_31o() { # LU-2901
2188 for LOOP in $(seq 100); do
2189 rm -f $DIR/$tdir/$tfile*
2190 for THREAD in $(seq 8); do
2191 link_one $DIR/$tdir/$tfile.$LOOP &
2194 local LINKS=$(ls -1 $DIR/$tdir | grep -c $tfile.$LOOP)
2195 [[ $LINKS -gt 1 ]] && ls $DIR/$tdir &&
2196 error "$LINKS duplicate links to $tfile.$LOOP" &&
2200 run_test 31o "duplicate hard links with same filename"
2202 cleanup_test32_mount() {
2204 $UMOUNT -d $DIR/$tdir/ext2-mountpoint
2208 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2209 echo "== more mountpoints and symlinks ================="
2210 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2211 trap cleanup_test32_mount EXIT
2212 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2213 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2214 $CHECKSTAT -t dir $DIR/$tdir/ext2-mountpoint/.. || error
2215 cleanup_test32_mount
2217 run_test 32a "stat d32a/ext2-mountpoint/.. ====================="
2220 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2221 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2222 trap cleanup_test32_mount EXIT
2223 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2224 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2225 ls -al $DIR/$tdir/ext2-mountpoint/.. || error
2226 cleanup_test32_mount
2228 run_test 32b "open d32b/ext2-mountpoint/.. ====================="
2231 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2232 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2233 trap cleanup_test32_mount EXIT
2234 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2235 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2236 test_mkdir -p $DIR/$tdir/d2/test_dir
2237 $CHECKSTAT -t dir $DIR/$tdir/ext2-mountpoint/../d2/test_dir || error
2238 cleanup_test32_mount
2240 run_test 32c "stat d32c/ext2-mountpoint/../d2/test_dir ========="
2243 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2244 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2245 trap cleanup_test32_mount EXIT
2246 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2247 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2248 test_mkdir -p $DIR/$tdir/d2/test_dir
2249 ls -al $DIR/$tdir/ext2-mountpoint/../d2/test_dir || error
2250 cleanup_test32_mount
2252 run_test 32d "open d32d/ext2-mountpoint/../d2/test_dir ========="
2255 [ -e $DIR/d32e ] && rm -fr $DIR/d32e
2256 test_mkdir -p $DIR/d32e/tmp
2257 TMP_DIR=$DIR/d32e/tmp
2258 ln -s $DIR/d32e $TMP_DIR/symlink11
2259 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
2260 $CHECKSTAT -t link $DIR/d32e/tmp/symlink11 || error
2261 $CHECKSTAT -t link $DIR/d32e/symlink01 || error
2263 run_test 32e "stat d32e/symlink->tmp/symlink->lustre-subdir ===="
2266 [ -e $DIR/d32f ] && rm -fr $DIR/d32f
2267 test_mkdir -p $DIR/d32f/tmp
2268 TMP_DIR=$DIR/d32f/tmp
2269 ln -s $DIR/d32f $TMP_DIR/symlink11
2270 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
2271 ls $DIR/d32f/tmp/symlink11 || error
2272 ls $DIR/d32f/symlink01 || error
2274 run_test 32f "open d32f/symlink->tmp/symlink->lustre-subdir ===="
2277 TMP_DIR=$DIR/$tdir/tmp
2278 test_mkdir -p $DIR/$tdir/tmp
2279 test_mkdir $DIR/${tdir}2
2280 ln -s $DIR/${tdir}2 $TMP_DIR/symlink12
2281 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
2282 $CHECKSTAT -t link $TMP_DIR/symlink12 || error
2283 $CHECKSTAT -t link $DIR/$tdir/symlink02 || error
2284 $CHECKSTAT -t dir -f $TMP_DIR/symlink12 || error
2285 $CHECKSTAT -t dir -f $DIR/$tdir/symlink02 || error
2287 run_test 32g "stat d32g/symlink->tmp/symlink->lustre-subdir/${tdir}2"
2290 rm -fr $DIR/$tdir $DIR/${tdir}2
2291 TMP_DIR=$DIR/$tdir/tmp
2292 test_mkdir -p $DIR/$tdir/tmp
2293 test_mkdir $DIR/${tdir}2
2294 ln -s $DIR/${tdir}2 $TMP_DIR/symlink12
2295 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
2296 ls $TMP_DIR/symlink12 || error
2297 ls $DIR/$tdir/symlink02 || error
2299 run_test 32h "open d32h/symlink->tmp/symlink->lustre-subdir/${tdir}2"
2302 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2303 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2304 trap cleanup_test32_mount EXIT
2305 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2306 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2307 touch $DIR/$tdir/test_file
2308 $CHECKSTAT -t file $DIR/$tdir/ext2-mountpoint/../test_file || error
2309 cleanup_test32_mount
2311 run_test 32i "stat d32i/ext2-mountpoint/../test_file ==========="
2314 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2315 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2316 trap cleanup_test32_mount EXIT
2317 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2318 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2319 touch $DIR/$tdir/test_file
2320 cat $DIR/$tdir/ext2-mountpoint/../test_file || error
2321 cleanup_test32_mount
2323 run_test 32j "open d32j/ext2-mountpoint/../test_file ==========="
2326 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2328 trap cleanup_test32_mount EXIT
2329 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2330 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint
2331 test_mkdir -p $DIR/$tdir/d2
2332 touch $DIR/$tdir/d2/test_file || error
2333 $CHECKSTAT -t file $DIR/$tdir/ext2-mountpoint/../d2/test_file || error
2334 cleanup_test32_mount
2336 run_test 32k "stat d32k/ext2-mountpoint/../d2/test_file ========"
2339 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2341 trap cleanup_test32_mount EXIT
2342 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2343 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2344 test_mkdir -p $DIR/$tdir/d2
2345 touch $DIR/$tdir/d2/test_file
2346 cat $DIR/$tdir/ext2-mountpoint/../d2/test_file || error
2347 cleanup_test32_mount
2349 run_test 32l "open d32l/ext2-mountpoint/../d2/test_file ========"
2353 test_mkdir -p $DIR/d32m/tmp
2354 TMP_DIR=$DIR/d32m/tmp
2355 ln -s $DIR $TMP_DIR/symlink11
2356 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
2357 $CHECKSTAT -t link $DIR/d32m/tmp/symlink11 || error
2358 $CHECKSTAT -t link $DIR/d32m/symlink01 || error
2360 run_test 32m "stat d32m/symlink->tmp/symlink->lustre-root ======"
2364 test_mkdir -p $DIR/d32n/tmp
2365 TMP_DIR=$DIR/d32n/tmp
2366 ln -s $DIR $TMP_DIR/symlink11
2367 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
2368 ls -l $DIR/d32n/tmp/symlink11 || error
2369 ls -l $DIR/d32n/symlink01 || error
2371 run_test 32n "open d32n/symlink->tmp/symlink->lustre-root ======"
2374 rm -fr $DIR/d32o $DIR/$tfile
2376 test_mkdir -p $DIR/d32o/tmp
2377 TMP_DIR=$DIR/d32o/tmp
2378 ln -s $DIR/$tfile $TMP_DIR/symlink12
2379 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
2380 $CHECKSTAT -t link $DIR/d32o/tmp/symlink12 || error
2381 $CHECKSTAT -t link $DIR/d32o/symlink02 || error
2382 $CHECKSTAT -t file -f $DIR/d32o/tmp/symlink12 || error
2383 $CHECKSTAT -t file -f $DIR/d32o/symlink02 || error
2385 run_test 32o "stat d32o/symlink->tmp/symlink->lustre-root/$tfile"
2395 test_mkdir -p $DIR/d32p/tmp
2397 TMP_DIR=$DIR/d32p/tmp
2399 ln -s $DIR/$tfile $TMP_DIR/symlink12
2401 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
2403 cat $DIR/d32p/tmp/symlink12 || error
2405 cat $DIR/d32p/symlink02 || error
2408 run_test 32p "open d32p/symlink->tmp/symlink->lustre-root/$tfile"
2410 cleanup_testdir_mount() {
2412 $UMOUNT -d $DIR/$tdir
2416 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2417 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2418 trap cleanup_testdir_mount EXIT
2419 test_mkdir -p $DIR/$tdir
2420 touch $DIR/$tdir/under_the_mount
2421 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir
2422 ls $DIR/$tdir | grep "\<under_the_mount\>" && error
2423 cleanup_testdir_mount
2425 run_test 32q "stat follows mountpoints in Lustre (should return error)"
2428 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2429 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2430 trap cleanup_testdir_mount EXIT
2431 test_mkdir -p $DIR/$tdir
2432 touch $DIR/$tdir/under_the_mount
2433 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir
2434 ls $DIR/$tdir | grep -q under_the_mount && error || true
2435 cleanup_testdir_mount
2437 run_test 32r "opendir follows mountpoints in Lustre (should return error)"
2442 chmod 444 $DIR/$tfile
2443 chown $RUNAS_ID $DIR/$tfile
2445 $RUNAS $OPENFILE -f O_RDWR $DIR/$tfile && error || true
2448 run_test 33aa "write file with mode 444 (should return error) ===="
2452 test_mkdir -p $DIR/d33
2453 chown $RUNAS_ID $DIR/d33
2454 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $DIR/d33/f33|| error "create"
2455 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $DIR/d33/f33 && \
2456 error "open RDWR" || true
2458 run_test 33a "test open file(mode=0444) with O_RDWR (should return error)"
2462 test_mkdir -p $DIR/d33
2463 chown $RUNAS_ID $DIR/d33
2464 $RUNAS $OPENFILE -f 1286739555 $DIR/d33/f33 && error "create" || true
2466 run_test 33b "test open file with malformed flags (No panic and return error)"
2469 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2475 remote_ost_nodsh && skip "remote OST with nodsh" && return
2478 test_mkdir -p $DIR/d33
2479 # Read: 0, Write: 4, create/destroy: 2/0, stat: 1, punch: 0
2482 for ostnum in $(seq $OSTCOUNT); do
2483 # test-framework's OST numbering is one-based, while Lustre's
2485 ostname=$(printf "$FSNAME-OST%.4x" $((ostnum - 1)))
2486 # Parsing llobdstat's output sucks; we could grep the /proc
2487 # path, but that's likely to not be as portable as using the
2488 # llobdstat utility. So we parse lctl output instead.
2489 write_bytes=$(do_facet ost$ostnum lctl get_param -n \
2490 obdfilter/$ostname/stats |
2491 awk '/^write_bytes/ {print $7}' )
2492 echo "baseline_write_bytes@$OSTnum/$ostname=$write_bytes"
2493 if (( ${write_bytes:-0} > 0 ))
2500 $all_zeros || return 0
2503 echo foo > $DIR/d33/bar
2507 # Total up write_bytes after writing. We'd better find non-zeros.
2508 for ostnum in $(seq $OSTCOUNT); do
2509 ostname=$(printf "$FSNAME-OST%.4x" $((ostnum - 1)))
2510 write_bytes=$(do_facet ost$ostnum lctl get_param -n \
2511 obdfilter/$ostname/stats |
2512 awk '/^write_bytes/ {print $7}' )
2513 echo "write_bytes@$OSTnum/$ostname=$write_bytes"
2514 if (( ${write_bytes:-0} > 0 ))
2523 for ostnum in $(seq $OSTCOUNT); do
2524 ostname=$(printf "$FSNAME-OST%.4x" $((ostnum - 1)))
2525 echo "Check that write_bytes is present in obdfilter/*/stats:"
2526 do_facet ost$ostnum lctl get_param -n \
2527 obdfilter/$ostname/stats
2529 error "OST not keeping write_bytes stats (b22312)"
2532 run_test 33c "test llobdstat and write_bytes"
2535 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 2 MDTs" && return
2536 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2538 local remote_dir=$DIR/$tdir/remote_dir
2541 $LFS mkdir -i $MDTIDX $remote_dir ||
2542 error "create remote directory failed"
2544 touch $remote_dir/$tfile
2545 chmod 444 $remote_dir/$tfile
2546 chown $RUNAS_ID $remote_dir/$tfile
2548 $RUNAS $OPENFILE -f O_RDWR $DIR/$tfile && error || true
2550 chown $RUNAS_ID $remote_dir
2551 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $remote_dir/f33 ||
2552 error "create" || true
2553 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $remote_dir/f33 &&
2554 error "open RDWR" || true
2555 $RUNAS $OPENFILE -f 1286739555 $remote_dir/f33 &&
2556 error "create" || true
2558 run_test 33d "openfile with 444 modes and malformed flags under remote dir"
2560 TEST_34_SIZE=${TEST_34_SIZE:-2000000000000}
2563 $MCREATE $DIR/f34 || error
2564 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" || error
2565 $TRUNCATE $DIR/f34 $TEST_34_SIZE || error
2566 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" || error
2567 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2569 run_test 34a "truncate file that has not been opened ==========="
2572 [ ! -f $DIR/f34 ] && test_34a
2573 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2574 $OPENFILE -f O_RDONLY $DIR/f34
2575 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" || error
2576 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2578 run_test 34b "O_RDONLY opening file doesn't create objects ====="
2581 [ ! -f $DIR/f34 ] && test_34a
2582 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2583 $OPENFILE -f O_RDWR $DIR/f34
2584 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" && error
2585 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2587 run_test 34c "O_RDWR opening file-with-size works =============="
2590 [ ! -f $DIR/f34 ] && test_34a
2591 dd if=/dev/zero of=$DIR/f34 conv=notrunc bs=4k count=1 || error
2592 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2595 run_test 34d "write to sparse file ============================="
2599 $MCREATE $DIR/f34e || error
2600 $TRUNCATE $DIR/f34e 1000 || error
2601 $CHECKSTAT -s 1000 $DIR/f34e || error
2602 $OPENFILE -f O_RDWR $DIR/f34e
2603 $CHECKSTAT -s 1000 $DIR/f34e || error
2605 run_test 34e "create objects, some with size and some without =="
2607 test_34f() { # bug 6242, 6243
2608 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2611 $MCREATE $DIR/f34f || error
2612 $TRUNCATE $DIR/f34f $SIZE34F || error "truncating $DIR/f3f to $SIZE34F"
2613 dd if=$DIR/f34f of=$TMP/f34f
2614 $CHECKSTAT -s $SIZE34F $TMP/f34f || error "$TMP/f34f not $SIZE34F bytes"
2615 dd if=/dev/zero of=$TMP/f34fzero bs=$SIZE34F count=1
2616 cmp $DIR/f34f $TMP/f34fzero || error "$DIR/f34f not all zero"
2617 cmp $TMP/f34f $TMP/f34fzero || error "$TMP/f34f not all zero"
2618 rm $TMP/f34f $TMP/f34fzero $DIR/f34f
2620 run_test 34f "read from a file with no objects until EOF ======="
2623 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2624 dd if=/dev/zero of=$DIR/$tfile bs=1 count=100 seek=$TEST_34_SIZE || error
2625 $TRUNCATE $DIR/$tfile $((TEST_34_SIZE / 2))|| error
2626 $CHECKSTAT -s $((TEST_34_SIZE / 2)) $DIR/$tfile || error "truncate failed"
2627 cancel_lru_locks osc
2628 $CHECKSTAT -s $((TEST_34_SIZE / 2)) $DIR/$tfile || \
2629 error "wrong size after lock cancel"
2631 $TRUNCATE $DIR/$tfile $TEST_34_SIZE || error
2632 $CHECKSTAT -s $TEST_34_SIZE $DIR/$tfile || \
2633 error "expanding truncate failed"
2634 cancel_lru_locks osc
2635 $CHECKSTAT -s $TEST_34_SIZE $DIR/$tfile || \
2636 error "wrong expanded size after lock cancel"
2638 run_test 34g "truncate long file ==============================="
2641 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2645 dd if=/dev/zero of=$DIR/$tfile bs=1M count=10 || error
2646 sync # Flush the cache so that multiop below does not block on cache
2647 # flush when getting the group lock
2648 $MULTIOP $DIR/$tfile OG${gid}T${sz}g${gid}c &
2651 # Since just timed wait is not good enough, let's do a sync write
2652 # that way we are sure enough time for a roundtrip + processing
2653 # passed + 2 seconds of extra margin.
2654 dd if=/dev/zero of=$DIR/${tfile}-1 bs=4096 oflag=direct count=1
2658 if [[ `ps h -o comm -p $MULTIPID` == "multiop" ]]; then
2659 error "Multiop blocked on ftruncate, pid=$MULTIPID"
2663 local nsz=`stat -c %s $DIR/$tfile`
2664 [[ $nsz == $sz ]] || error "New size wrong $nsz != $sz"
2666 run_test 34h "ftruncate file under grouplock should not block"
2669 cp /bin/sh $DIR/f35a
2671 chown $RUNAS_ID $DIR/f35a
2672 $RUNAS $DIR/f35a && error || true
2675 run_test 35a "exec file with mode 444 (should return and not leak) ====="
2679 utime $DIR/f36 || error
2681 run_test 36a "MDS utime check (mknod, utime) ==================="
2685 utime $DIR/f36 || error
2687 run_test 36b "OST utime check (open, utime) ===================="
2692 chown $RUNAS_ID $DIR/d36
2693 $RUNAS utime $DIR/d36/f36 || error
2695 run_test 36c "non-root MDS utime check (mknod, utime) =========="
2698 [ ! -d $DIR/d36 ] && test_36c
2699 echo "" > $DIR/d36/f36
2700 $RUNAS utime $DIR/d36/f36 || error
2702 run_test 36d "non-root OST utime check (open, utime) ==========="
2705 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID -- skipping" && return
2706 test_mkdir -p $DIR/$tdir
2707 touch $DIR/$tdir/$tfile
2708 $RUNAS utime $DIR/$tdir/$tfile && \
2709 error "utime worked, expected failure" || true
2711 run_test 36e "utime on non-owned file (should return error) ===="
2715 local LANG_SAVE=$LANG
2716 local LC_LANG_SAVE=$LC_LANG
2717 export LANG=C LC_LANG=C # for date language
2719 DATESTR="Dec 20 2000"
2720 test_mkdir -p $DIR/$tdir
2721 lctl set_param fail_loc=$fl
2723 cp /etc/hosts $DIR/$tdir/$tfile
2724 sync & # write RPC generated with "current" inode timestamp, but delayed
2726 touch --date="$DATESTR" $DIR/$tdir/$tfile # setattr timestamp in past
2727 LS_BEFORE="`ls -l $DIR/$tdir/$tfile`" # old timestamp from client cache
2728 cancel_lru_locks osc
2729 LS_AFTER="`ls -l $DIR/$tdir/$tfile`" # timestamp from OST object
2731 [ "$LS_BEFORE" != "$LS_AFTER" ] && \
2732 echo "BEFORE: $LS_BEFORE" && \
2733 echo "AFTER : $LS_AFTER" && \
2734 echo "WANT : $DATESTR" && \
2735 error "$DIR/$tdir/$tfile timestamps changed" || true
2737 export LANG=$LANG_SAVE LC_LANG=$LC_LANG_SAVE
2741 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2742 #define OBD_FAIL_OST_BRW_PAUSE_BULK 0x214
2743 subr_36fh "0x80000214"
2745 run_test 36f "utime on file racing with OST BRW write =========="
2748 remote_ost_nodsh && skip "remote OST with nodsh" && return
2749 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2754 test_mkdir -p $DIR/$tdir
2755 fmd_max_age=$(do_facet ost1 \
2756 "lctl get_param -n obdfilter.*.client_cache_seconds 2> /dev/null | \
2759 fmd_before=$(do_facet ost1 \
2760 "awk '/ll_fmd_cache/ {print \\\$2}' /proc/slabinfo")
2761 touch $DIR/$tdir/$tfile
2762 sleep $((fmd_max_age + 12))
2763 fmd_after=$(do_facet ost1 \
2764 "awk '/ll_fmd_cache/ {print \\\$2}' /proc/slabinfo")
2766 echo "fmd_before: $fmd_before"
2767 echo "fmd_after: $fmd_after"
2768 [[ $fmd_after -gt $fmd_before ]] &&
2769 echo "AFTER: $fmd_after > BEFORE: $fmd_before" &&
2770 error "fmd didn't expire after ping" || true
2772 run_test 36g "filter mod data cache expiry ====================="
2775 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2776 #define OBD_FAIL_OST_BRW_PAUSE_BULK2 0x227
2777 subr_36fh "0x80000227"
2779 run_test 36h "utime on file racing with OST BRW write =========="
2781 # test_37 - duplicate with tests 32q 32r
2784 local file=$DIR/$tfile
2786 openfile -f O_DIRECTORY $file
2789 [ $RC -eq 0 ] && error "opened file $file with O_DIRECTORY" || true
2790 [ $RC -eq $ENOTDIR ] || error "error $RC should be ENOTDIR ($ENOTDIR)"
2792 run_test 38 "open a regular file with O_DIRECTORY should return -ENOTDIR ==="
2796 touch $DIR/${tfile}2
2797 # ls -l $DIR/$tfile $DIR/${tfile}2
2798 # ls -lu $DIR/$tfile $DIR/${tfile}2
2799 # ls -lc $DIR/$tfile $DIR/${tfile}2
2801 $OPENFILE -f O_CREAT:O_TRUNC:O_WRONLY $DIR/${tfile}2
2802 if [ ! $DIR/${tfile}2 -nt $DIR/$tfile ]; then
2804 ls -l --full-time $DIR/$tfile $DIR/${tfile}2
2806 ls -lu --full-time $DIR/$tfile $DIR/${tfile}2
2808 ls -lc --full-time $DIR/$tfile $DIR/${tfile}2
2809 error "O_TRUNC didn't change timestamps"
2812 run_test 39 "mtime changed on create ==========================="
2815 test_mkdir -p $DIR/$tdir
2816 cp -p /etc/passwd $DIR/$tdir/fopen
2817 cp -p /etc/passwd $DIR/$tdir/flink
2818 cp -p /etc/passwd $DIR/$tdir/funlink
2819 cp -p /etc/passwd $DIR/$tdir/frename
2820 ln $DIR/$tdir/funlink $DIR/$tdir/funlink2
2823 echo "aaaaaa" >> $DIR/$tdir/fopen
2824 echo "aaaaaa" >> $DIR/$tdir/flink
2825 echo "aaaaaa" >> $DIR/$tdir/funlink
2826 echo "aaaaaa" >> $DIR/$tdir/frename
2828 local open_new=`stat -c %Y $DIR/$tdir/fopen`
2829 local link_new=`stat -c %Y $DIR/$tdir/flink`
2830 local unlink_new=`stat -c %Y $DIR/$tdir/funlink`
2831 local rename_new=`stat -c %Y $DIR/$tdir/frename`
2833 cat $DIR/$tdir/fopen > /dev/null
2834 ln $DIR/$tdir/flink $DIR/$tdir/flink2
2835 rm -f $DIR/$tdir/funlink2
2836 mv -f $DIR/$tdir/frename $DIR/$tdir/frename2
2838 for (( i=0; i < 2; i++ )) ; do
2839 local open_new2=`stat -c %Y $DIR/$tdir/fopen`
2840 local link_new2=`stat -c %Y $DIR/$tdir/flink`
2841 local unlink_new2=`stat -c %Y $DIR/$tdir/funlink`
2842 local rename_new2=`stat -c %Y $DIR/$tdir/frename2`
2844 [ $open_new2 -eq $open_new ] || error "open file reverses mtime"
2845 [ $link_new2 -eq $link_new ] || error "link file reverses mtime"
2846 [ $unlink_new2 -eq $unlink_new ] || error "unlink file reverses mtime"
2847 [ $rename_new2 -eq $rename_new ] || error "rename file reverses mtime"
2849 cancel_lru_locks osc
2850 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2853 run_test 39b "mtime change on open, link, unlink, rename ======"
2855 # this should be set to past
2856 TEST_39_MTIME=`date -d "1 year ago" +%s`
2862 local mtime0=`stat -c %Y $DIR1/$tfile`
2864 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
2865 local mtime1=`stat -c %Y $DIR1/$tfile`
2866 [ "$mtime1" = $TEST_39_MTIME ] || \
2867 error "mtime is not set to past: $mtime1, should be $TEST_39_MTIME"
2870 echo hello >> $DIR1/$tfile
2872 local mtime2=`stat -c %Y $DIR1/$tfile`
2873 [ "$mtime2" -ge "$d1" ] && [ "$mtime2" -le "$d2" ] || \
2874 error "mtime is not updated on write: $d1 <= $mtime2 <= $d2"
2876 mv $DIR1/$tfile $DIR1/$tfile-1
2878 for (( i=0; i < 2; i++ )) ; do
2879 local mtime3=`stat -c %Y $DIR1/$tfile-1`
2880 [ "$mtime2" = "$mtime3" ] || \
2881 error "mtime ($mtime2) changed (to $mtime3) on rename"
2883 cancel_lru_locks osc
2884 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2887 run_test 39c "mtime change on rename ==========================="
2891 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2894 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
2896 for (( i=0; i < 2; i++ )) ; do
2897 local mtime=`stat -c %Y $DIR1/$tfile`
2898 [ $mtime = $TEST_39_MTIME ] || \
2899 error "mtime($mtime) is not set to $TEST_39_MTIME"
2901 cancel_lru_locks osc
2902 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2905 run_test 39d "create, utime, stat =============================="
2909 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2911 local mtime1=`stat -c %Y $DIR1/$tfile`
2913 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
2915 for (( i=0; i < 2; i++ )) ; do
2916 local mtime2=`stat -c %Y $DIR1/$tfile`
2917 [ $mtime2 = $TEST_39_MTIME ] || \
2918 error "mtime($mtime2) is not set to $TEST_39_MTIME"
2920 cancel_lru_locks osc
2921 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2924 run_test 39e "create, stat, utime, stat ========================"
2928 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2930 mtime1=`stat -c %Y $DIR1/$tfile`
2933 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
2935 for (( i=0; i < 2; i++ )) ; do
2936 local mtime2=`stat -c %Y $DIR1/$tfile`
2937 [ $mtime2 = $TEST_39_MTIME ] || \
2938 error "mtime($mtime2) is not set to $TEST_39_MTIME"
2940 cancel_lru_locks osc
2941 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2944 run_test 39f "create, stat, sleep, utime, stat ================="
2948 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2949 echo hello >> $DIR1/$tfile
2950 local mtime1=`stat -c %Y $DIR1/$tfile`
2953 chmod o+r $DIR1/$tfile
2955 for (( i=0; i < 2; i++ )) ; do
2956 local mtime2=`stat -c %Y $DIR1/$tfile`
2957 [ "$mtime1" = "$mtime2" ] || \
2958 error "lost mtime: $mtime2, should be $mtime1"
2960 cancel_lru_locks osc
2961 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2964 run_test 39g "write, chmod, stat ==============================="
2968 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2973 echo hello >> $DIR1/$tfile
2974 local mtime1=`stat -c %Y $DIR1/$tfile`
2976 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
2978 if [ "$d1" != "$d2" ]; then
2979 echo "write and touch not within one second"
2981 for (( i=0; i < 2; i++ )) ; do
2982 local mtime2=`stat -c %Y $DIR1/$tfile`
2983 [ "$mtime2" = $TEST_39_MTIME ] || \
2984 error "lost mtime: $mtime2, should be $TEST_39_MTIME"
2986 cancel_lru_locks osc
2987 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2991 run_test 39h "write, utime within one second, stat ============="
2994 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2998 echo hello >> $DIR1/$tfile
2999 local mtime1=`stat -c %Y $DIR1/$tfile`
3001 mv $DIR1/$tfile $DIR1/$tfile-1
3003 for (( i=0; i < 2; i++ )) ; do
3004 local mtime2=`stat -c %Y $DIR1/$tfile-1`
3006 [ "$mtime1" = "$mtime2" ] || \
3007 error "lost mtime: $mtime2, should be $mtime1"
3009 cancel_lru_locks osc
3010 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3013 run_test 39i "write, rename, stat =============================="
3016 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3017 start_full_debug_logging
3021 #define OBD_FAIL_OSC_DELAY_SETTIME 0x412
3022 lctl set_param fail_loc=0x80000412
3023 multiop_bg_pause $DIR1/$tfile oO_RDWR:w2097152_c ||
3024 error "multiop failed"
3026 local mtime1=`stat -c %Y $DIR1/$tfile`
3028 mv $DIR1/$tfile $DIR1/$tfile-1
3030 kill -USR1 $multipid
3031 wait $multipid || error "multiop close failed"
3033 for (( i=0; i < 2; i++ )) ; do
3034 local mtime2=`stat -c %Y $DIR1/$tfile-1`
3035 [ "$mtime1" = "$mtime2" ] ||
3036 error "mtime is lost on close: $mtime2, " \
3039 cancel_lru_locks osc
3040 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3042 lctl set_param fail_loc=0
3043 stop_full_debug_logging
3045 run_test 39j "write, rename, close, stat ======================="
3048 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3052 multiop_bg_pause $DIR1/$tfile oO_RDWR:w2097152_c || error "multiop failed"
3054 local mtime1=`stat -c %Y $DIR1/$tfile`
3056 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3058 kill -USR1 $multipid
3059 wait $multipid || error "multiop close failed"
3061 for (( i=0; i < 2; i++ )) ; do
3062 local mtime2=`stat -c %Y $DIR1/$tfile`
3064 [ "$mtime2" = $TEST_39_MTIME ] || \
3065 error "mtime is lost on close: $mtime2, should be $TEST_39_MTIME"
3067 cancel_lru_locks osc
3068 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3071 run_test 39k "write, utime, close, stat ========================"
3073 # this should be set to future
3074 TEST_39_ATIME=`date -d "1 year" +%s`
3077 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3078 remote_mds_nodsh && skip "remote MDS with nodsh" && return
3079 local atime_diff=$(do_facet $SINGLEMDS \
3080 lctl get_param -n mdd.*MDT0000*.atime_diff)
3084 # test setting directory atime to future
3085 touch -a -d @$TEST_39_ATIME $DIR/$tdir
3086 local atime=$(stat -c %X $DIR/$tdir)
3087 [ "$atime" = $TEST_39_ATIME ] || \
3088 error "atime is not set to future: $atime, $TEST_39_ATIME"
3090 # test setting directory atime from future to now
3091 local d1=$(date +%s)
3093 local d2=$(date +%s)
3095 cancel_lru_locks mdc
3096 atime=$(stat -c %X $DIR/$tdir)
3097 [ "$atime" -ge "$d1" -a "$atime" -le "$d2" ] || \
3098 error "atime is not updated from future: $atime, $d1<atime<$d2"
3100 do_facet $SINGLEMDS lctl set_param -n mdd.*MDT0000*.atime_diff=2
3103 # test setting directory atime when now > dir atime + atime_diff
3107 cancel_lru_locks mdc
3108 atime=$(stat -c %X $DIR/$tdir)
3109 [ "$atime" -ge "$d1" -a "$atime" -le "$d2" ] || \
3110 error "atime is not updated : $atime, should be $d2"
3112 do_facet $SINGLEMDS lctl set_param -n mdd.*MDT0000*.atime_diff=60
3115 # test not setting directory atime when now < dir atime + atime_diff
3117 cancel_lru_locks mdc
3118 atime=$(stat -c %X $DIR/$tdir)
3119 [ "$atime" -ge "$d1" -a "$atime" -le "$d2" ] || \
3120 error "atime is updated to $atime, should remain $d1<atime<$d2"
3122 do_facet $SINGLEMDS \
3123 lctl set_param -n mdd.*MDT0000*.atime_diff=$atime_diff
3125 run_test 39l "directory atime update ==========================="
3128 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3131 local far_past_mtime=$(date -d "May 29 1953" +%s)
3132 local far_past_atime=$(date -d "Dec 17 1903" +%s)
3134 touch -m -d @$far_past_mtime $DIR1/$tfile
3135 touch -a -d @$far_past_atime $DIR1/$tfile
3137 for (( i=0; i < 2; i++ )) ; do
3138 local timestamps=$(stat -c "%X %Y" $DIR1/$tfile)
3139 [ "$timestamps" = "$far_past_atime $far_past_mtime" ] || \
3140 error "atime or mtime set incorrectly"
3142 cancel_lru_locks osc
3143 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3146 run_test 39m "test atime and mtime before 1970"
3148 test_39n() { # LU-3832
3149 local atime_diff=$(do_facet $SINGLEMDS \
3150 lctl get_param -n mdd.*MDT0000*.atime_diff)
3155 do_facet $SINGLEMDS lctl set_param -n mdd.*MDT0000*.atime_diff=1
3158 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 status=noxfer
3159 atime0=$(stat -c %X $DIR/$tfile)
3162 $MULTIOP $DIR/$tfile oO_RDONLY:O_NOATIME:r4096c
3163 atime1=$(stat -c %X $DIR/$tfile)
3166 cancel_lru_locks mdc
3167 cancel_lru_locks osc
3168 $MULTIOP $DIR/$tfile oO_RDONLY:O_NOATIME:r4096c
3169 atime2=$(stat -c %X $DIR/$tfile)
3171 do_facet $SINGLEMDS \
3172 lctl set_param -n mdd.*MDT0000*.atime_diff=$atime_diff
3174 [ "$atime0" -eq "$atime1" ] || error "atime0 $atime0 != atime1 $atime1"
3175 [ "$atime1" -eq "$atime2" ] || error "atime0 $atime0 != atime1 $atime1"
3177 run_test 39n "check that O_NOATIME is honored"
3180 TESTDIR=$DIR/$tdir/$tfile
3181 [ -e $TESTDIR ] && rm -rf $TESTDIR
3188 links2=$(stat -c %h .)
3189 [ $(($links1 + 2)) != $links2 ] &&
3190 error "wrong links count $(($links1 + 2)) != $links2"
3192 links3=$(stat -c %h .)
3193 [ $(($links1 + 1)) != $links3 ] &&
3194 error "wrong links count $links1 != $links3"
3197 run_test 39o "directory cached attributes updated after create ========"
3200 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1
3201 $RUNAS $OPENFILE -f O_WRONLY:O_TRUNC $DIR/$tfile &&
3202 error "openfile O_WRONLY:O_TRUNC $tfile failed"
3203 $CHECKSTAT -t file -s 4096 $DIR/$tfile ||
3204 error "$tfile is not 4096 bytes in size"
3206 run_test 40 "failed open(O_TRUNC) doesn't truncate ============="
3210 small_write $DIR/f41 18
3212 run_test 41 "test small file write + fstat ====================="
3214 count_ost_writes() {
3215 lctl get_param -n osc.*.stats |
3216 awk -vwrites=0 '/ost_write/ { writes += $2 } \
3217 END { printf("%0.0f", writes) }'
3224 BG_DIRTY_RATIO_SAVE=10
3225 MAX_BG_DIRTY_RATIO=25
3229 # in 2.6, restore /proc/sys/vm/dirty_writeback_centisecs,
3230 # dirty_ratio, dirty_background_ratio
3231 if [ -f /proc/sys/vm/dirty_writeback_centisecs ]; then
3232 sysctl -w vm.dirty_writeback_centisecs=$WRITEBACK_SAVE
3233 sysctl -w vm.dirty_background_ratio=$BG_DIRTY_RATIO_SAVE
3234 sysctl -w vm.dirty_ratio=$DIRTY_RATIO_SAVE
3236 # if file not here, we are a 2.4 kernel
3237 kill -CONT `pidof kupdated`
3242 # setup the trap first, so someone cannot exit the test at the
3243 # exact wrong time and mess up a machine
3244 trap start_writeback EXIT
3245 # in 2.6, save and 0 /proc/sys/vm/dirty_writeback_centisecs
3246 if [ -f /proc/sys/vm/dirty_writeback_centisecs ]; then
3247 WRITEBACK_SAVE=`sysctl -n vm.dirty_writeback_centisecs`
3248 sysctl -w vm.dirty_writeback_centisecs=0
3249 sysctl -w vm.dirty_writeback_centisecs=0
3250 # save and increase /proc/sys/vm/dirty_ratio
3251 DIRTY_RATIO_SAVE=`sysctl -n vm.dirty_ratio`
3252 sysctl -w vm.dirty_ratio=$MAX_DIRTY_RATIO
3253 # save and increase /proc/sys/vm/dirty_background_ratio
3254 BG_DIRTY_RATIO_SAVE=`sysctl -n vm.dirty_background_ratio`
3255 sysctl -w vm.dirty_background_ratio=$MAX_BG_DIRTY_RATIO
3257 # if file not here, we are a 2.4 kernel
3258 kill -STOP `pidof kupdated`
3262 # ensure that all stripes have some grant before we test client-side cache
3264 for i in `seq -f $DIR/f42-%g 1 $OSTCOUNT`; do
3265 dd if=/dev/zero of=$i bs=4k count=1
3270 # Tests 42* verify that our behaviour is correct WRT caching, file closure,
3271 # file truncation, and file removal.
3273 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3275 cancel_lru_locks osc
3277 sync; sleep 1; sync # just to be safe
3278 BEFOREWRITES=`count_ost_writes`
3279 lctl get_param -n osc.*[oO][sS][cC][_-]*.cur_grant_bytes | grep "[0-9]"
3280 dd if=/dev/zero of=$DIR/f42a bs=1024 count=100
3281 AFTERWRITES=`count_ost_writes`
3282 [ $BEFOREWRITES -eq $AFTERWRITES ] || \
3283 error "$BEFOREWRITES < $AFTERWRITES"
3286 run_test 42a "ensure that we don't flush on close =============="
3289 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3291 cancel_lru_locks osc
3294 dd if=/dev/zero of=$DIR/f42b bs=1024 count=100
3295 BEFOREWRITES=$(count_ost_writes)
3296 $MUNLINK $DIR/f42b || error "$MUNLINK $DIR/f42b: $?"
3297 AFTERWRITES=$(count_ost_writes)
3298 if [[ $BEFOREWRITES -lt $AFTERWRITES ]]; then
3299 error "$BEFOREWRITES < $AFTERWRITES on unlink"
3301 BEFOREWRITES=$(count_ost_writes)
3302 sync || error "sync: $?"
3303 AFTERWRITES=$(count_ost_writes)
3304 if [[ $BEFOREWRITES -lt $AFTERWRITES ]]; then
3305 error "$BEFOREWRITES < $AFTERWRITES on sync"
3307 dmesg | grep 'error from obd_brw_async' && error 'error writing back'
3311 run_test 42b "test destroy of file with cached dirty data ======"
3313 # if these tests just want to test the effect of truncation,
3314 # they have to be very careful. consider:
3315 # - the first open gets a {0,EOF}PR lock
3316 # - the first write conflicts and gets a {0, count-1}PW
3317 # - the rest of the writes are under {count,EOF}PW
3318 # - the open for truncate tries to match a {0,EOF}PR
3319 # for the filesize and cancels the PWs.
3320 # any number of fixes (don't get {0,EOF} on open, match
3321 # composite locks, do smarter file size management) fix
3322 # this, but for now we want these tests to verify that
3323 # the cancellation with truncate intent works, so we
3324 # start the file with a full-file pw lock to match against
3325 # until the truncate.
3330 cancel_lru_locks osc
3332 # prime the file with 0,EOF PW to match
3336 # now the real test..
3337 dd if=/dev/zero of=$file bs=1024 count=100
3338 BEFOREWRITES=`count_ost_writes`
3339 $TRUNCATE $file $offset
3340 cancel_lru_locks osc
3341 AFTERWRITES=`count_ost_writes`
3346 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3348 [ $BEFOREWRITES -eq $AFTERWRITES ] && \
3349 error "beforewrites $BEFOREWRITES == afterwrites $AFTERWRITES on truncate"
3352 run_test 42c "test partial truncate of file with cached dirty data"
3355 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3357 [ $BEFOREWRITES -eq $AFTERWRITES ] || \
3358 error "beforewrites $BEFOREWRITES != afterwrites $AFTERWRITES on truncate"
3361 run_test 42d "test complete truncate of file with cached dirty data"
3363 test_42e() { # bug22074
3364 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3365 local TDIR=$DIR/${tdir}e
3366 local pagesz=$(page_size)
3367 local pages=16 # hardcoded 16 pages, don't change it.
3368 local files=$((OSTCOUNT * 500)) # hopefully 500 files on each OST
3369 local proc_osc0="osc.${FSNAME}-OST0000-osc-[^MDT]*"
3373 test_mkdir -p $DIR/${tdir}e
3374 $SETSTRIPE -c 1 $TDIR
3375 createmany -o $TDIR/f $files
3377 max_dirty_mb=$($LCTL get_param -n $proc_osc0/max_dirty_mb)
3379 # we assume that with $OSTCOUNT files, at least one of them will
3380 # be allocated on OST0.
3381 warmup_files=$((OSTCOUNT * max_dirty_mb))
3382 createmany -o $TDIR/w $warmup_files
3384 # write a large amount of data into one file and sync, to get good
3385 # avail_grant number from OST.
3386 for ((i=0; i<$warmup_files; i++)); do
3387 idx=$($GETSTRIPE -i $TDIR/w$i)
3388 [ $idx -ne 0 ] && continue
3389 dd if=/dev/zero of=$TDIR/w$i bs="$max_dirty_mb"M count=1
3392 [[ $i -gt $warmup_files ]] && error "OST0 is still cold"
3394 $LCTL get_param $proc_osc0/cur_dirty_bytes
3395 $LCTL get_param $proc_osc0/cur_grant_bytes
3397 # create as much dirty pages as we can while not to trigger the actual
3398 # RPCs directly. but depends on the env, VFS may trigger flush during this
3399 # period, hopefully we are good.
3400 for ((i=0; i<$warmup_files; i++)); do
3401 idx=$($GETSTRIPE -i $TDIR/w$i)
3402 [ $idx -ne 0 ] && continue
3403 dd if=/dev/zero of=$TDIR/w$i bs=1M count=1 2>/dev/null
3405 $LCTL get_param $proc_osc0/cur_dirty_bytes
3406 $LCTL get_param $proc_osc0/cur_grant_bytes
3408 # perform the real test
3409 $LCTL set_param $proc_osc0/rpc_stats 0
3410 for ((;i<$files; i++)); do
3411 [ $($GETSTRIPE -i $TDIR/f$i) -eq 0 ] || continue
3412 dd if=/dev/zero of=$TDIR/f$i bs=$pagesz count=$pages 2>/dev/null
3415 $LCTL get_param $proc_osc0/rpc_stats
3418 local have_ppr=false
3419 $LCTL get_param $proc_osc0/rpc_stats |
3420 while read PPR RRPC RPCT RCUM BAR WRPC WPCT WCUM; do
3421 # skip lines until we are at the RPC histogram data
3422 [ "$PPR" == "pages" ] && have_ppr=true && continue
3423 $have_ppr || continue
3425 # we only want the percent stat for < 16 pages
3426 [[ $(echo $PPR | tr -d ':') -ge $pages ]] && break
3428 percent=$((percent + WPCT))
3429 if [[ $percent -gt 15 ]]; then
3430 error "less than 16-pages write RPCs" \
3437 run_test 42e "verify sub-RPC writes are not done synchronously"
3440 test_mkdir -p $DIR/$tdir
3441 cp -p /bin/ls $DIR/$tdir/$tfile
3442 $MULTIOP $DIR/$tdir/$tfile Ow_c &
3444 # give multiop a chance to open
3447 $DIR/$tdir/$tfile && error || true
3450 run_test 43 "execution of file opened for write should return -ETXTBSY"
3453 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3454 test_mkdir -p $DIR/$tdir
3455 cp -p `which $MULTIOP` $DIR/$tdir/multiop ||
3456 cp -p multiop $DIR/$tdir/multiop
3457 MULTIOP_PROG=$DIR/$tdir/multiop multiop_bg_pause $TMP/$tfile.junk O_c ||
3460 $MULTIOP $DIR/$tdir/multiop Oc && error "expected error, got success"
3461 kill -USR1 $MULTIOP_PID || return 2
3462 wait $MULTIOP_PID || return 3
3463 rm $TMP/$tfile.junk $DIR/$tdir/multiop
3465 run_test 43a "open(RDWR) of file being executed should return -ETXTBSY"
3468 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3469 test_mkdir -p $DIR/$tdir
3470 cp -p `which $MULTIOP` $DIR/$tdir/multiop ||
3471 cp -p multiop $DIR/$tdir/multiop
3472 MULTIOP_PROG=$DIR/$tdir/multiop multiop_bg_pause $TMP/$tfile.junk O_c ||
3475 $TRUNCATE $DIR/$tdir/multiop 0 && error "expected error, got success"
3476 kill -USR1 $MULTIOP_PID || return 2
3477 wait $MULTIOP_PID || return 3
3478 rm $TMP/$tfile.junk $DIR/$tdir/multiop
3480 run_test 43b "truncate of file being executed should return -ETXTBSY"
3483 local testdir="$DIR/$tdir"
3484 test_mkdir -p $DIR/$tdir
3486 ( cd $(dirname $SHELL) && md5sum $(basename $SHELL) ) | \
3487 ( cd $testdir && md5sum -c)
3489 run_test 43c "md5sum of copy into lustre========================"
3492 [[ $OSTCOUNT -lt 2 ]] && skip_env "skipping 2-stripe test" && return
3493 dd if=/dev/zero of=$DIR/f1 bs=4k count=1 seek=1023
3494 dd if=$DIR/f1 bs=4k count=1 > /dev/null
3496 run_test 44 "zero length read from a sparse stripe ============="
3499 local nstripe=$($LCTL lov_getconfig $DIR | grep default_stripe_count: |
3501 [ -z "$nstripe" ] && skip "can't get stripe info" && return
3502 [[ $nstripe -gt $OSTCOUNT ]] &&
3503 skip "Wrong default_stripe_count: $nstripe (OSTCOUNT: $OSTCOUNT)" &&
3505 local stride=$($LCTL lov_getconfig $DIR | grep default_stripe_size: |
3507 if [[ $nstripe -eq 0 || $nstripe -eq -1 ]]; then
3508 nstripe=$($LCTL lov_getconfig $DIR | grep obd_count: |
3512 OFFSETS="0 $((stride/2)) $((stride-1))"
3513 for offset in $OFFSETS; do
3514 for i in $(seq 0 $((nstripe-1))); do
3515 local GLOBALOFFSETS=""
3517 local size=$((((i + 2 * $nstripe )*$stride + $offset)))
3518 local myfn=$DIR/d44a-$size
3519 echo "--------writing $myfn at $size"
3520 ll_sparseness_write $myfn $size ||
3521 error "ll_sparseness_write"
3522 GLOBALOFFSETS="$GLOBALOFFSETS $size"
3523 ll_sparseness_verify $myfn $GLOBALOFFSETS ||
3524 error "ll_sparseness_verify $GLOBALOFFSETS"
3526 for j in $(seq 0 $((nstripe-1))); do
3528 size=$((((j + $nstripe )*$stride + $offset)))
3529 ll_sparseness_write $myfn $size ||
3530 error "ll_sparseness_write"
3531 GLOBALOFFSETS="$GLOBALOFFSETS $size"
3533 ll_sparseness_verify $myfn $GLOBALOFFSETS ||
3534 error "ll_sparseness_verify $GLOBALOFFSETS"
3539 run_test 44a "test sparse pwrite ==============================="
3543 for d in `lctl get_param -n osc.*.cur_dirty_bytes`; do
3549 before=`dirty_osc_total`
3550 echo executing "\"$*\""
3552 after=`dirty_osc_total`
3553 echo before $before, after $after
3556 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3558 # Obtain grants from OST if it supports it
3559 echo blah > ${f}_grant
3562 do_dirty_record "echo blah > $f"
3563 [[ $before -eq $after ]] && error "write wasn't cached"
3564 do_dirty_record "> $f"
3565 [[ $before -gt $after ]] || error "truncate didn't lower dirty count"
3566 do_dirty_record "echo blah > $f"
3567 [[ $before -eq $after ]] && error "write wasn't cached"
3568 do_dirty_record "sync"
3569 [[ $before -gt $after ]] || error "writeback didn't lower dirty count"
3570 do_dirty_record "echo blah > $f"
3571 [[ $before -eq $after ]] && error "write wasn't cached"
3572 do_dirty_record "cancel_lru_locks osc"
3573 [[ $before -gt $after ]] ||
3574 error "lock cancellation didn't lower dirty count"
3577 run_test 45 "osc io page accounting ============================"
3579 # in a 2 stripe file (lov.sh), page 1023 maps to page 511 in its object. this
3580 # test tickles a bug where re-dirtying a page was failing to be mapped to the
3581 # objects offset and an assert hit when an rpc was built with 1023's mapped
3582 # offset 511 and 511's raw 511 offset. it also found general redirtying bugs.
3584 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3588 dd if=/dev/zero of=$f bs=`page_size` seek=511 count=1
3590 dd conv=notrunc if=/dev/zero of=$f bs=`page_size` seek=1023 count=1
3591 dd conv=notrunc if=/dev/zero of=$f bs=`page_size` seek=511 count=1
3595 run_test 46 "dirtying a previously written page ================"
3597 # test_47 is removed "Device nodes check" is moved to test_28
3599 test_48a() { # bug 2399
3600 check_kernel_version 34 || return 0
3601 test_mkdir -p $DIR/$tdir
3603 mv $DIR/$tdir $DIR/d48.new || error "move directory failed"
3604 test_mkdir $DIR/$tdir || error "recreate directory failed"
3605 touch foo || error "'touch foo' failed after recreating cwd"
3606 test_mkdir $DIR/$tdir/bar ||
3607 error "'mkdir foo' failed after recreating cwd"
3608 if check_kernel_version 44; then
3609 touch .foo || error "'touch .foo' failed after recreating cwd"
3610 test_mkdir $DIR/$tdir/.bar ||
3611 error "'mkdir .foo' failed after recreating cwd"
3613 ls . > /dev/null || error "'ls .' failed after recreating cwd"
3614 ls .. > /dev/null || error "'ls ..' failed after removing cwd"
3615 cd . || error "'cd .' failed after recreating cwd"
3616 test_mkdir . && error "'mkdir .' worked after recreating cwd"
3617 rmdir . && error "'rmdir .' worked after recreating cwd"
3618 ln -s . baz || error "'ln -s .' failed after recreating cwd"
3619 cd .. || error "'cd ..' failed after recreating cwd"
3621 run_test 48a "Access renamed working dir (should return errors)="
3623 test_48b() { # bug 2399
3624 check_kernel_version 34 || return 0
3626 test_mkdir -p $DIR/$tdir
3628 rmdir $DIR/$tdir || error "remove cwd $DIR/$tdir failed"
3629 touch foo && error "'touch foo' worked after removing cwd"
3630 test_mkdir $DIR/$tdir/foo &&
3631 error "'mkdir foo' worked after removing cwd"
3632 if check_kernel_version 44; then
3633 touch .foo && error "'touch .foo' worked after removing cwd"
3634 test_mkdir $DIR/$tdir/.foo &&
3635 error "'mkdir .foo' worked after removing cwd"
3637 ls . > /dev/null && error "'ls .' worked after removing cwd"
3638 ls .. > /dev/null || error "'ls ..' failed after removing cwd"
3639 is_patchless || ( cd . && error "'cd .' worked after removing cwd" )
3640 test_mkdir $DIR/$tdir/. && error "'mkdir .' worked after removing cwd"
3641 rmdir . && error "'rmdir .' worked after removing cwd"
3642 ln -s . foo && error "'ln -s .' worked after removing cwd"
3643 cd .. || echo "'cd ..' failed after removing cwd `pwd`" #bug 3517
3645 run_test 48b "Access removed working dir (should return errors)="
3647 test_48c() { # bug 2350
3648 check_kernel_version 36 || return 0
3649 #lctl set_param debug=-1
3652 test_mkdir -p $DIR/$tdir/dir
3654 $TRACE rmdir $DIR/$tdir/dir || error "remove cwd $DIR/$tdir/dir failed"
3655 $TRACE touch foo && error "touch foo worked after removing cwd"
3656 $TRACE test_mkdir foo && error "'mkdir foo' worked after removing cwd"
3657 if check_kernel_version 44; then
3658 touch .foo && error "touch .foo worked after removing cwd"
3659 test_mkdir .foo && error "mkdir .foo worked after removing cwd"
3661 $TRACE ls . && error "'ls .' worked after removing cwd"
3662 $TRACE ls .. || error "'ls ..' failed after removing cwd"
3663 is_patchless || ( $TRACE cd . &&
3664 error "'cd .' worked after removing cwd" )
3665 $TRACE test_mkdir . && error "'mkdir .' worked after removing cwd"
3666 $TRACE rmdir . && error "'rmdir .' worked after removing cwd"
3667 $TRACE ln -s . foo && error "'ln -s .' worked after removing cwd"
3668 $TRACE cd .. || echo "'cd ..' failed after removing cwd `pwd`" #bug 3415
3670 run_test 48c "Access removed working subdir (should return errors)"
3672 test_48d() { # bug 2350
3673 check_kernel_version 36 || return 0
3674 #lctl set_param debug=-1
3677 test_mkdir -p $DIR/$tdir/dir
3679 $TRACE rmdir $DIR/$tdir/dir || error "remove cwd $DIR/$tdir/dir failed"
3680 $TRACE rmdir $DIR/$tdir || error "remove parent $DIR/$tdir failed"
3681 $TRACE touch foo && error "'touch foo' worked after removing parent"
3682 $TRACE test_mkdir foo && error "mkdir foo worked after removing parent"
3683 if check_kernel_version 44; then
3684 touch .foo && error "'touch .foo' worked after removing parent"
3686 error "mkdir .foo worked after removing parent"
3688 $TRACE ls . && error "'ls .' worked after removing parent"
3689 $TRACE ls .. && error "'ls ..' worked after removing parent"
3690 is_patchless || ( $TRACE cd . &&
3691 error "'cd .' worked after recreate parent" )
3692 $TRACE test_mkdir . && error "'mkdir .' worked after removing parent"
3693 $TRACE rmdir . && error "'rmdir .' worked after removing parent"
3694 $TRACE ln -s . foo && error "'ln -s .' worked after removing parent"
3695 is_patchless || ( $TRACE cd .. &&
3696 error "'cd ..' worked after removing parent" || true )
3698 run_test 48d "Access removed parent subdir (should return errors)"
3700 test_48e() { # bug 4134
3701 check_kernel_version 41 || return 0
3702 #lctl set_param debug=-1
3705 test_mkdir -p $DIR/$tdir/dir
3707 $TRACE rmdir $DIR/$tdir/dir || error "remove cwd $DIR/$tdir/dir failed"
3708 $TRACE rmdir $DIR/$tdir || error "remove parent $DIR/$tdir failed"
3709 $TRACE touch $DIR/$tdir || error "'touch $DIR/$tdir' failed"
3710 $TRACE chmod +x $DIR/$tdir || error "'chmod +x $DIR/$tdir' failed"
3711 # On a buggy kernel addition of "touch foo" after cd .. will
3712 # produce kernel oops in lookup_hash_it
3713 touch ../foo && error "'cd ..' worked after recreate parent"
3715 $TRACE rm $DIR/$tdir || error "rm '$DIR/$tdir' failed"
3717 run_test 48e "Access to recreated parent subdir (should return errors)"
3719 test_49() { # LU-1030
3720 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3721 # get ost1 size - lustre-OST0000
3722 ost1_size=$(do_facet ost1 $LFS df | grep ${ost1_svc} |
3724 # write 800M at maximum
3725 [[ $ost1_size -lt 2 ]] && ost1_size=2
3726 [[ $ost1_size -gt 819200 ]] && ost1_size=819200
3728 $SETSTRIPE -c 1 -i 0 $DIR/$tfile
3729 dd if=/dev/zero of=$DIR/$tfile bs=4k count=$((ost1_size >> 2)) &
3732 # change max_pages_per_rpc while writing the file
3733 local osc1_mppc=osc.$(get_osc_import_name client ost1).max_pages_per_rpc
3734 local orig_mppc=$($LCTL get_param -n $osc1_mppc)
3735 # loop until dd process exits
3736 while ps ax -opid | grep -wq $dd_pid; do
3737 $LCTL set_param $osc1_mppc=$((RANDOM % 256 + 1))
3738 sleep $((RANDOM % 5 + 1))
3740 # restore original max_pages_per_rpc
3741 $LCTL set_param $osc1_mppc=$orig_mppc
3742 rm $DIR/$tfile || error "rm $DIR/$tfile failed"
3744 run_test 49 "Change max_pages_per_rpc won't break osc extent"
3748 test_mkdir $DIR/$tdir
3750 ls /proc/$$/cwd || error "ls /proc/$$/cwd failed"
3752 run_test 50 "special situations: /proc symlinks ==============="
3754 test_51a() { # was test_51
3755 # bug 1516 - create an empty entry right after ".." then split dir
3756 test_mkdir -p $DIR/$tdir
3757 touch $DIR/$tdir/foo
3758 $MCREATE $DIR/$tdir/bar
3760 createmany -m $DIR/$tdir/longfile 201
3762 while [[ $(ls -sd $DIR/$tdir | awk '{ print $1 }') -eq 4 ]]; do
3763 $MCREATE $DIR/$tdir/longfile$FNUM
3768 ls -l $DIR/$tdir > /dev/null || error "ls -l $DIR/$tdir failed"
3770 run_test 51a "special situations: split htree with empty entry =="
3772 export NUMTEST=70000
3774 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3775 local BASE=$DIR/d${base}.${TESTSUITE}
3777 # cleanup the directory
3782 local mdtidx=$(printf "%04x" $($LFS getstripe -M $BASE))
3783 local numfree=$(lctl get_param -n mdc.$FSNAME-MDT$mdtidx*.filesfree)
3784 [[ $numfree -lt 21000 ]] && skip "not enough free inodes ($numfree)" &&
3787 [[ $numfree -lt $NUMTEST ]] && NUMTEST=$(($numfree - 50)) &&
3788 echo "reduced count to $NUMTEST due to inodes"
3790 # need to check free space for the directories as well
3791 local blkfree=$(lctl get_param -n mdc.$FSNAME-MDT$mdtidx*.kbytesavail)
3792 numfree=$((blkfree / 4))
3793 [[ $numfree -lt $NUMTEST ]] && NUMTEST=$(($numfree - 50)) &&
3794 echo "reduced count to $NUMTEST due to blocks"
3796 createmany -d $BASE/d $NUMTEST && echo $NUMTEST > $BASE/fnum ||
3797 echo "failed" > $BASE/fnum
3799 run_test 51b "exceed 64k subdirectory nlink limit"
3801 test_51ba() { # LU-993
3802 local BASE=$DIR/d${base}.${TESTSUITE}
3803 # unlink all but 100 subdirectories, then check it still works
3805 [ -f $BASE/fnum ] && local NUMPREV=$(cat $BASE/fnum) && rm $BASE/fnum
3807 [ "$NUMPREV" != "failed" ] && NUMTEST=$NUMPREV
3808 local DELETE=$((NUMTEST - LEFT))
3810 # continue on to run this test even if 51b didn't finish,
3811 # just to delete the many subdirectories created.
3812 [ ! -d "${BASE}/d1" ] && skip "test_51b() not run" && return 0
3814 # for ldiskfs the nlink count should be 1, but this is OSD specific
3815 # and so this is listed for informational purposes only
3816 echo "nlink before: $(stat -c %h $BASE), created before: $NUMTEST"
3817 unlinkmany -d $BASE/d $DELETE
3820 if [ $RC -ne 0 ]; then
3821 if [ "$NUMPREV" == "failed" ]; then
3822 skip "previous setup failed"
3825 error "unlink of first $DELETE subdirs failed"
3830 echo "nlink between: $(stat -c %h $BASE)"
3831 # trim the first line of ls output
3832 local FOUND=$(($(ls -l ${BASE} | wc -l) - 1))
3833 [ $FOUND -ne $LEFT ] &&
3834 error "can't find subdirs: found only $FOUND/$LEFT"
3836 unlinkmany -d $BASE/d $DELETE $LEFT ||
3837 error "unlink of second $LEFT subdirs failed"
3838 # regardless of whether the backing filesystem tracks nlink accurately
3839 # or not, the nlink count shouldn't be more than "." and ".." here
3840 local AFTER=$(stat -c %h $BASE)
3841 [[ $AFTER -gt 2 ]] && error "nlink after: $AFTER > 2" ||
3842 echo "nlink after: $AFTER"
3844 run_test 51ba "verify nlink for many subdirectory cleanup"
3847 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3848 [[ $OSTCOUNT -lt 3 ]] &&
3849 skip_env "skipping test with few OSTs" && return
3850 test_mkdir -p $DIR/$tdir
3851 createmany -o $DIR/$tdir/t- 1000
3852 $GETSTRIPE $DIR/$tdir > $TMP/files
3853 for N in $(seq 0 $((OSTCOUNT - 1))); do
3854 OBJS[$N]=$(awk -vobjs=0 '($1 == '$N') { objs += 1 } \
3855 END { printf("%0.0f", objs) }' $TMP/files)
3856 OBJS0[$N]=$(grep -A 1 idx $TMP/files | awk -vobjs=0 \
3857 '($1 == '$N') { objs += 1 } \
3858 END { printf("%0.0f", objs) }')
3859 log "OST$N has ${OBJS[$N]} objects, ${OBJS0[$N]} are index 0"
3861 unlinkmany $DIR/$tdir/t- 1000
3864 for N in $(seq 1 $((OSTCOUNT - 1))); do
3865 [[ ${OBJS[$N]} -lt $((${OBJS[$NLAST]} - 20)) ]] &&
3866 error "OST $N has less objects vs OST $NLAST" \
3867 " (${OBJS[$N]} < ${OBJS[$NLAST]}"
3868 [[ ${OBJS[$N]} -gt $((${OBJS[$NLAST]} + 20)) ]] &&
3869 error "OST $N has less objects vs OST $NLAST" \
3870 " (${OBJS[$N]} < ${OBJS[$NLAST]}"
3872 [[ ${OBJS0[$N]} -lt $((${OBJS0[$NLAST]} - 20)) ]] &&
3873 error "OST $N has less #0 objects vs OST $NLAST" \
3874 " (${OBJS0[$N]} < ${OBJS0[$NLAST]}"
3875 [[ ${OBJS0[$N]} -gt $((${OBJS0[$NLAST]} + 20)) ]] &&
3876 error "OST $N has less #0 objects vs OST $NLAST" \
3877 " (${OBJS0[$N]} < ${OBJS0[$NLAST]}"
3881 run_test 51d "check object distribution ===================="
3884 [ -f $DIR/$tdir/foo ] && chattr -a $DIR/$tdir/foo
3885 test_mkdir -p $DIR/$tdir
3886 touch $DIR/$tdir/foo
3887 chattr +a $DIR/$tdir/foo || error "chattr +a failed"
3888 echo bar >> $DIR/$tdir/foo || error "append bar failed"
3889 cp /etc/hosts $DIR/$tdir/foo && error "cp worked"
3890 rm -f $DIR/$tdir/foo 2>/dev/null && error "rm worked"
3891 link $DIR/$tdir/foo $DIR/$tdir/foo_link 2>/dev/null &&
3893 echo foo >> $DIR/$tdir/foo || error "append foo failed"
3894 mrename $DIR/$tdir/foo $DIR/$tdir/foo_ren && error "rename worked"
3895 lsattr $DIR/$tdir/foo | egrep -q "^-+a[-e]+ $DIR/$tdir/foo" ||
3897 chattr -a $DIR/$tdir/foo || error "chattr -a failed"
3898 cp -r $DIR/$tdir /tmp/
3899 rm -fr $DIR/$tdir || error "cleanup rm failed"
3901 run_test 52a "append-only flag test (should return errors) ====="
3904 [ -f $DIR/$tdir/foo ] && chattr -i $DIR/$tdir/foo
3905 test_mkdir -p $DIR/$tdir
3906 touch $DIR/$tdir/foo
3907 chattr +i $DIR/$tdir/foo || error "chattr +i failed"
3908 cat test > $DIR/$tdir/foo && error "cat test worked"
3909 cp /etc/hosts $DIR/$tdir/foo && error "cp worked"
3910 rm -f $DIR/$tdir/foo 2>/dev/null && error "rm worked"
3911 link $DIR/$tdir/foo $DIR/$tdir/foo_link 2>/dev/null &&
3913 echo foo >> $DIR/$tdir/foo && error "echo worked"
3914 mrename $DIR/$tdir/foo $DIR/$tdir/foo_ren && error "rename worked"
3915 [ -f $DIR/$tdir/foo ] || error "$tdir/foo is not a file"
3916 [ -f $DIR/$tdir/foo_ren ] && error "$tdir/foo_ren is not a file"
3917 lsattr $DIR/$tdir/foo | egrep -q "^-+i[-e]+ $DIR/$tdir/foo" ||
3919 chattr -i $DIR/$tdir/foo || error "chattr failed"
3921 rm -fr $DIR/$tdir || error "unable to remove $DIR/$tdir"
3923 run_test 52b "immutable flag test (should return errors) ======="
3926 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3927 remote_mds_nodsh && skip "remote MDS with nodsh" && return
3928 remote_ost_nodsh && skip "remote OST with nodsh" && return
3941 local support_last_seq=true
3943 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.3.60) ]] ||
3944 support_last_seq=false
3947 local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS)
3949 for value in $(do_facet $SINGLEMDS \
3950 $LCTL get_param osc.$mdtosc.prealloc_last_id) ; do
3951 param=$(echo ${value[0]} | cut -d "=" -f1)
3952 ostname=$(echo $param | cut -d "." -f2 | cut -d - -f 1-2)
3954 if $support_last_seq; then
3955 param_seq=$(echo $param |
3956 sed -e s/prealloc_last_id/prealloc_last_seq/g)
3957 mds_last_seq=$(do_facet $SINGLEMDS \
3958 $LCTL get_param -n $param_seq)
3960 mds_last=$(do_facet $SINGLEMDS $LCTL get_param -n $param)
3962 ostnum=$(index_from_ostuuid ${ostname}_UUID)
3963 node=$(facet_active_host ost$((ostnum+1)))
3964 param="obdfilter.$ostname.last_id"
3965 for ost_last in $(do_node $node $LCTL get_param -n $param) ; do
3966 echo "$ostname.last_id=$ost_last; MDS.last_id=$mds_last"
3967 ost_last_id=$ost_last
3969 if $support_last_seq; then
3970 ost_last_id=$(echo $ost_last |
3971 awk -F':' '{print $2}' |
3973 ost_last_seq=$(echo $ost_last |
3974 awk -F':' '{print $1}')
3975 [[ $ost_last_seq = $mds_last_seq ]] || continue
3978 if [[ $ost_last_id != $mds_last ]]; then
3979 error "$ost_last_id != $mds_last"
3986 $found || error "can not match last_seq/last_id for $mdtosc"
3989 run_test 53 "verify that MDS and OSTs agree on pre-creation ===="
3992 $SOCKETSERVER $DIR/socket ||
3993 error "$SOCKETSERVER $DIR/socket failed: $?"
3994 $SOCKETCLIENT $DIR/socket ||
3995 error "$SOCKETCLIENT $DIR/socket failed: $?"
3996 $MUNLINK $DIR/socket || error "$MUNLINK $DIR/socket failed: $?"
3998 run_test 54a "unix domain socket test =========================="
4004 dd if=/dev/zero of=$f bs=$(page_size) count=1
4006 run_test 54b "char device works in lustre ======================"
4009 [ -b /dev/loop/0 ] && LOOPBASE=/dev/loop/
4010 [ -b /dev/loop0 ] && LOOPBASE=/dev/loop
4011 [ -z "$LOOPBASE" ] && echo "/dev/loop/0 and /dev/loop0 gone?" && return
4013 for i in $(seq 3 7); do
4014 losetup $LOOPBASE$i > /dev/null 2>&1 && continue
4022 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4025 loopdev="$DIR/loop54c"
4028 [ -z "$LOOPNUM" ] && echo "couldn't find empty loop device" && return
4029 mknod $loopdev b 7 $LOOPNUM
4030 echo "make a loop file system with $tfile on $loopdev ($LOOPNUM)..."
4031 dd if=/dev/zero of=$tfile bs=`page_size` seek=1024 count=1 > /dev/null
4032 losetup $loopdev $tfile || error "can't set up $loopdev for $tfile"
4033 mkfs.ext2 $loopdev || error "mke2fs on $loopdev"
4035 mount -t ext2 $loopdev $tdir || error "error mounting $loopdev on $tdir"
4036 dd if=/dev/zero of=$tdir/tmp bs=`page_size` count=30 || error "dd write"
4038 dd if=$tdir/tmp of=/dev/zero bs=`page_size` count=30 || error "dd read"
4043 run_test 54c "block device works in lustre ====================="
4049 [ "$string" = $(echo $string > $f | cat $f) ] || error "$f != $string"
4051 run_test 54d "fifo device works in lustre ======================"
4054 check_kernel_version 46 || return 0
4057 cp -aL /dev/console $f
4058 echo $string > $f || error "echo $string to $f failed"
4060 run_test 54e "console/tty device works in lustre ======================"
4062 #The test_55 used to be iopen test and it was removed by bz#24037.
4063 #run_test 55 "check iopen_connect_dentry() ======================"
4065 test_56a() { # was test_56
4068 test_mkdir -p $DIR/$tdir/dir
4070 NUMFILESx2=$(($NUMFILES * 2))
4071 for i in $(seq 1 $NUMFILES); do
4072 touch $DIR/$tdir/file$i
4073 touch $DIR/$tdir/dir/file$i
4076 # test lfs getstripe with --recursive
4077 FILENUM=$($GETSTRIPE --recursive $DIR/$tdir | grep -c obdidx)
4078 [[ $FILENUM -eq $NUMFILESx2 ]] ||
4079 error "$GETSTRIPE --recursive: found $FILENUM, not $NUMFILESx2"
4080 FILENUM=$($GETSTRIPE $DIR/$tdir | grep -c obdidx)
4081 [[ $FILENUM -eq $NUMFILES ]] ||
4082 error "$GETSTRIPE $DIR/$tdir: found $FILENUM, not $NUMFILES"
4083 echo "$GETSTRIPE --recursive passed."
4085 # test lfs getstripe with file instead of dir
4086 FILENUM=$($GETSTRIPE $DIR/$tdir/file1 | grep -c obdidx)
4087 [[ $FILENUM -eq 1 ]] ||
4088 error "$GETSTRIPE $DIR/$tdir/file1: found $FILENUM, not 1"
4089 echo "$GETSTRIPE file1 passed."
4091 #test lfs getstripe with --verbose
4092 [[ $($GETSTRIPE --verbose $DIR/$tdir |
4093 grep -c lmm_magic) -eq $NUMFILES ]] ||
4094 error "$GETSTRIPE --verbose $DIR/$tdir: want $NUMFILES"
4095 [[ $($GETSTRIPE $DIR/$tdir | grep -c lmm_magic) -eq 0 ]] ||
4096 rror "$GETSTRIPE $DIR/$tdir: showed lmm_magic"
4097 echo "$GETSTRIPE --verbose passed."
4099 #test lfs getstripe with --obd
4100 $GETSTRIPE --obd wrong_uuid $DIR/$tdir 2>&1 |
4101 grep -q "unknown obduuid" ||
4102 error "$GETSTRIPE --obd wrong_uuid should return error message"
4104 [[ $OSTCOUNT -lt 2 ]] &&
4105 skip_env "skipping other $GETSTRIPE --obd test" && return
4108 OBDUUID=$(ostuuid_from_index $OSTIDX)
4109 FILENUM=$($GETSTRIPE -ir $DIR/$tdir | grep "^$OSTIDX\$" | wc -l)
4110 FOUND=$($GETSTRIPE -r --obd $OBDUUID $DIR/$tdir | grep obdidx | wc -l)
4111 [[ $FOUND -eq $FILENUM ]] ||
4112 error "$GETSTRIPE --obd wrong: found $FOUND, expected $FILENUM"
4113 [[ $($GETSTRIPE -r -v --obd $OBDUUID $DIR/$tdir |
4114 sed '/^[ ]*'${OSTIDX}'[ ]/d' |
4115 sed -n '/^[ ]*[0-9][0-9]*[ ]/p' | wc -l) -eq 0 ]] ||
4116 error "$GETSTRIPE --obd: should not show file on other obd"
4117 echo "$GETSTRIPE --obd passed"
4119 run_test 56a "check $GETSTRIPE"
4124 local LOCAL_NUMFILES="$1"
4125 local LOCAL_NUMDIRS="$2"
4126 local MKDIR_PARAMS="$3"
4128 if [ ! -d "$TDIR" ] ; then
4130 [ "$MKDIR_PARAMS" ] && $SETSTRIPE $MKDIR_PARAMS $TDIR
4131 for i in `seq 1 $LOCAL_NUMFILES` ; do
4134 for i in `seq 1 $LOCAL_NUMDIRS` ; do
4135 test_mkdir $TDIR/dir$i
4136 for j in `seq 1 $LOCAL_NUMFILES` ; do
4137 touch $TDIR/dir$i/file$j
4143 setup_56_special() {
4147 if [ ! -e "$TDIR/loop1b" ] ; then
4148 for i in `seq 1 $LOCAL_NUMFILES` ; do
4149 mknod $TDIR/loop${i}b b 7 $i
4150 mknod $TDIR/null${i}c c 1 3
4151 ln -s $TDIR/file1 $TDIR/link${i}l
4153 for i in `seq 1 $LOCAL_NUMDIRS` ; do
4154 mknod $TDIR/dir$i/loop${i}b b 7 $i
4155 mknod $TDIR/dir$i/null${i}c c 1 3
4156 ln -s $TDIR/dir$i/file1 $TDIR/dir$i/link${i}l
4165 setup_56 $NUMFILES $NUMDIRS
4167 EXPECTED=$(($NUMDIRS + 2))
4168 # test lfs find with -name
4169 for i in $(seq 1 $NUMFILES) ; do
4170 NUMS=$($LFIND -name "*$i" $TDIR | wc -l)
4171 [ $NUMS -eq $EXPECTED ] ||
4172 error "lfs find -name \"*$i\" $TDIR wrong: "\
4173 "found $NUMS, expected $EXPECTED"
4176 run_test 56g "check lfs find -name ============================="
4182 setup_56 $NUMFILES $NUMDIRS
4184 EXPECTED=$(((NUMDIRS + 1) * (NUMFILES - 1) + NUMFILES))
4185 # test lfs find with ! -name
4186 for i in $(seq 1 $NUMFILES) ; do
4187 NUMS=$($LFIND ! -name "*$i" $TDIR | wc -l)
4188 [ $NUMS -eq $EXPECTED ] ||
4189 error "lfs find ! -name \"*$i\" $TDIR wrong: "\
4190 "found $NUMS, expected $EXPECTED"
4193 run_test 56h "check lfs find ! -name ============================="
4197 test_mkdir -p $DIR/$tdir
4198 UUID=$(ostuuid_from_index 0 $DIR/$tdir)
4199 CMD="$LFIND -ost $UUID $DIR/$tdir"
4201 [ -z "$OUT" ] || error "\"$CMD\" returned directory '$OUT'"
4203 run_test 56i "check 'lfs find -ost UUID' skips directories ======="
4207 setup_56_special $NUMFILES $NUMDIRS
4209 EXPECTED=$((NUMDIRS + 1))
4210 CMD="$LFIND -type d $TDIR"
4211 NUMS=$($CMD | wc -l)
4212 [ $NUMS -eq $EXPECTED ] ||
4213 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4215 run_test 56j "check lfs find -type d ============================="
4219 setup_56_special $NUMFILES $NUMDIRS
4221 EXPECTED=$(((NUMDIRS + 1) * NUMFILES))
4222 CMD="$LFIND -type f $TDIR"
4223 NUMS=$($CMD | wc -l)
4224 [ $NUMS -eq $EXPECTED ] ||
4225 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4227 run_test 56k "check lfs find -type f ============================="
4231 setup_56_special $NUMFILES $NUMDIRS
4233 EXPECTED=$((NUMDIRS + NUMFILES))
4234 CMD="$LFIND -type b $TDIR"
4235 NUMS=$($CMD | wc -l)
4236 [ $NUMS -eq $EXPECTED ] ||
4237 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4239 run_test 56l "check lfs find -type b ============================="
4243 setup_56_special $NUMFILES $NUMDIRS
4245 EXPECTED=$((NUMDIRS + NUMFILES))
4246 CMD="$LFIND -type c $TDIR"
4247 NUMS=$($CMD | wc -l)
4248 [ $NUMS -eq $EXPECTED ] ||
4249 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4251 run_test 56m "check lfs find -type c ============================="
4255 setup_56_special $NUMFILES $NUMDIRS
4257 EXPECTED=$((NUMDIRS + NUMFILES))
4258 CMD="$LFIND -type l $TDIR"
4259 NUMS=$($CMD | wc -l)
4260 [ $NUMS -eq $EXPECTED ] ||
4261 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4263 run_test 56n "check lfs find -type l ============================="
4267 setup_56 $NUMFILES $NUMDIRS
4269 utime $TDIR/file1 > /dev/null || error "utime (1)"
4270 utime $TDIR/file2 > /dev/null || error "utime (2)"
4271 utime $TDIR/dir1 > /dev/null || error "utime (3)"
4272 utime $TDIR/dir2 > /dev/null || error "utime (4)"
4273 utime $TDIR/dir1/file1 > /dev/null || error "utime (5)"
4274 dd if=/dev/zero count=1 >> $TDIR/dir1/file1 && sync
4277 NUMS=`$LFIND -mtime +0 $TDIR | wc -l`
4278 [ $NUMS -eq $EXPECTED ] || \
4279 error "lfs find -mtime +0 $TDIR wrong: found $NUMS, expected $EXPECTED"
4282 CMD="$LFIND -mtime 0 $TDIR"
4283 NUMS=$($CMD | wc -l)
4284 [ $NUMS -eq $EXPECTED ] ||
4285 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4287 run_test 56o "check lfs find -mtime for old files =========================="
4290 [ $RUNAS_ID -eq $UID ] &&
4291 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
4294 setup_56 $NUMFILES $NUMDIRS
4296 chown $RUNAS_ID $TDIR/file* || error "chown $DIR/${tdir}g/file$i failed"
4298 CMD="$LFIND -uid $RUNAS_ID $TDIR"
4299 NUMS=$($CMD | wc -l)
4300 [ $NUMS -eq $EXPECTED ] || \
4301 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4303 EXPECTED=$(((NUMFILES + 1) * NUMDIRS + 1))
4304 CMD="$LFIND ! -uid $RUNAS_ID $TDIR"
4305 NUMS=$($CMD | wc -l)
4306 [ $NUMS -eq $EXPECTED ] || \
4307 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4309 run_test 56p "check lfs find -uid and ! -uid ==============================="
4312 [ $RUNAS_ID -eq $UID ] &&
4313 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
4316 setup_56 $NUMFILES $NUMDIRS
4318 chgrp $RUNAS_GID $TDIR/file* || error "chown $TDIR/file$i failed"
4321 CMD="$LFIND -gid $RUNAS_GID $TDIR"
4322 NUMS=$($CMD | wc -l)
4323 [ $NUMS -eq $EXPECTED ] ||
4324 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4326 EXPECTED=$(( ($NUMFILES+1) * $NUMDIRS + 1))
4327 CMD="$LFIND ! -gid $RUNAS_GID $TDIR"
4328 NUMS=$($CMD | wc -l)
4329 [ $NUMS -eq $EXPECTED ] ||
4330 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4332 run_test 56q "check lfs find -gid and ! -gid ==============================="
4336 setup_56 $NUMFILES $NUMDIRS
4339 CMD="$LFIND -size 0 -type f $TDIR"
4340 NUMS=$($CMD | wc -l)
4341 [ $NUMS -eq $EXPECTED ] ||
4342 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4344 CMD="$LFIND ! -size 0 -type f $TDIR"
4345 NUMS=$($CMD | wc -l)
4346 [ $NUMS -eq $EXPECTED ] ||
4347 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4348 echo "test" > $TDIR/$tfile
4349 echo "test2" > $TDIR/$tfile.2 && sync
4351 CMD="$LFIND -size 5 -type f $TDIR"
4352 NUMS=$($CMD | wc -l)
4353 [ $NUMS -eq $EXPECTED ] ||
4354 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4356 CMD="$LFIND -size +5 -type f $TDIR"
4357 NUMS=$($CMD | wc -l)
4358 [ $NUMS -eq $EXPECTED ] ||
4359 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4361 CMD="$LFIND -size +0 -type f $TDIR"
4362 NUMS=$($CMD | wc -l)
4363 [ $NUMS -eq $EXPECTED ] ||
4364 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4366 CMD="$LFIND ! -size -5 -type f $TDIR"
4367 NUMS=$($CMD | wc -l)
4368 [ $NUMS -eq $EXPECTED ] ||
4369 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4371 CMD="$LFIND -size -5 -type f $TDIR"
4372 NUMS=$($CMD | wc -l)
4373 [ $NUMS -eq $EXPECTED ] ||
4374 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4376 run_test 56r "check lfs find -size works =========================="
4378 test_56s() { # LU-611
4380 setup_56 $NUMFILES $NUMDIRS "-c $OSTCOUNT"
4382 if [[ $OSTCOUNT -gt 1 ]]; then
4383 $SETSTRIPE -c 1 $TDIR/$tfile.{0,1,2,3}
4387 ONESTRIPE=$(((NUMDIRS + 1) * NUMFILES))
4391 EXPECTED=$(((NUMDIRS + 1) * NUMFILES))
4392 CMD="$LFIND -stripe-count $OSTCOUNT -type f $TDIR"
4393 NUMS=$($CMD | wc -l)
4394 [ $NUMS -eq $EXPECTED ] ||
4395 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4397 EXPECTED=$(((NUMDIRS + 1) * NUMFILES + EXTRA))
4398 CMD="$LFIND -stripe-count +0 -type f $TDIR"
4399 NUMS=$($CMD | wc -l)
4400 [ $NUMS -eq $EXPECTED ] ||
4401 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4404 CMD="$LFIND -stripe-count 1 -type f $TDIR"
4405 NUMS=$($CMD | wc -l)
4406 [ $NUMS -eq $EXPECTED ] ||
4407 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4409 CMD="$LFIND -stripe-count -2 -type f $TDIR"
4410 NUMS=$($CMD | wc -l)
4411 [ $NUMS -eq $EXPECTED ] ||
4412 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4415 CMD="$LFIND -stripe-count $((OSTCOUNT + 1)) -type f $TDIR"
4416 NUMS=$($CMD | wc -l)
4417 [ $NUMS -eq $EXPECTED ] ||
4418 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4420 run_test 56s "check lfs find -stripe-count works"
4422 test_56t() { # LU-611
4424 setup_56 $NUMFILES $NUMDIRS "-s 512k"
4426 $SETSTRIPE -S 256k $TDIR/$tfile.{0,1,2,3}
4428 EXPECTED=$(((NUMDIRS + 1) * NUMFILES))
4429 CMD="$LFIND -stripe-size 512k -type f $TDIR"
4430 NUMS=$($CMD | wc -l)
4431 [ $NUMS -eq $EXPECTED ] ||
4432 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4434 CMD="$LFIND -stripe-size +320k -type f $TDIR"
4435 NUMS=$($CMD | wc -l)
4436 [ $NUMS -eq $EXPECTED ] ||
4437 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4439 EXPECTED=$(((NUMDIRS + 1) * NUMFILES + 4))
4440 CMD="$LFIND -stripe-size +200k -type f $TDIR"
4441 NUMS=$($CMD | wc -l)
4442 [ $NUMS -eq $EXPECTED ] ||
4443 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4445 CMD="$LFIND -stripe-size -640k -type f $TDIR"
4446 NUMS=$($CMD | wc -l)
4447 [ $NUMS -eq $EXPECTED ] ||
4448 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4451 CMD="$LFIND -stripe-size 256k -type f $TDIR"
4452 NUMS=$($CMD | wc -l)
4453 [ $NUMS -eq $EXPECTED ] ||
4454 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4456 CMD="$LFIND -stripe-size -320k -type f $TDIR"
4457 NUMS=$($CMD | wc -l)
4458 [ $NUMS -eq $EXPECTED ] ||
4459 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4462 CMD="$LFIND -stripe-size 1024k -type f $TDIR"
4463 NUMS=$($CMD | wc -l)
4464 [ $NUMS -eq $EXPECTED ] ||
4465 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4467 run_test 56t "check lfs find -stripe-size works"
4469 test_56u() { # LU-611
4471 setup_56 $NUMFILES $NUMDIRS "-i 0"
4473 if [[ $OSTCOUNT -gt 1 ]]; then
4474 $SETSTRIPE -i 1 $TDIR/$tfile.{0,1,2,3}
4480 EXPECTED=$(((NUMDIRS + 1) * NUMFILES))
4481 CMD="$LFIND -stripe-index 0 -type f $TDIR"
4482 NUMS=$($CMD | wc -l)
4483 [ $NUMS -eq $EXPECTED ] ||
4484 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4487 CMD="$LFIND -stripe-index 1 -type f $TDIR"
4488 NUMS=$($CMD | wc -l)
4489 [ $NUMS -eq $EXPECTED ] ||
4490 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4492 CMD="$LFIND ! -stripe-index 0 -type f $TDIR"
4493 NUMS=$($CMD | wc -l)
4494 [ $NUMS -eq $EXPECTED ] ||
4495 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4498 # This should produce an error and not return any files
4499 CMD="$LFIND -stripe-index $OSTCOUNT -type f $TDIR"
4500 NUMS=$($CMD 2>/dev/null | wc -l)
4501 [ $NUMS -eq $EXPECTED ] ||
4502 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4504 if [[ $OSTCOUNT -gt 1 ]]; then
4505 EXPECTED=$(((NUMDIRS + 1) * NUMFILES + ONESTRIPE))
4506 CMD="$LFIND -stripe-index 0,1 -type f $TDIR"
4507 NUMS=$($CMD | wc -l)
4508 [ $NUMS -eq $EXPECTED ] ||
4509 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4512 run_test 56u "check lfs find -stripe-index works"
4519 setup_56 $NUMFILES $NUMDIRS
4521 UUID=$(mdtuuid_from_index $MDT_IDX $TDIR)
4522 [ -z "$UUID" ] && error "mdtuuid_from_index cannot find MDT index $MDT_IDX"
4524 for file in $($LFIND -mdt $UUID $TDIR); do
4525 file_mdt_idx=$($GETSTRIPE -M $file)
4526 [ $file_mdt_idx -eq $MDT_IDX ] ||
4527 error "'lfind -mdt $UUID' != 'getstripe -M' ($file_mdt_idx)"
4530 run_test 56v "check 'lfs find -mdt match with lfs getstripe -M' ======="
4532 # Get and check the actual stripe count of one file.
4533 # Usage: check_stripe_count <file> <expected_stripe_count>
4534 check_stripe_count() {
4539 [[ -z "$file" || -z "$expected" ]] &&
4540 error "check_stripe_count: invalid argument!"
4542 local cmd="$GETSTRIPE -c $file"
4543 actual=$($cmd) || error "$cmd failed"
4544 actual=${actual%% *}
4546 if [[ $actual -ne $expected ]]; then
4547 [[ $expected -eq -1 ]] ||
4548 error "$cmd wrong: found $actual, expected $expected"
4549 [[ $actual -eq $OSTCOUNT ]] ||
4550 error "$cmd wrong: found $actual, expected $OSTCOUNT"
4555 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4558 rm -rf $TDIR || error "remove $TDIR failed"
4559 setup_56 $NUMFILES $NUMDIRS "-c $OSTCOUNT"
4562 stripe_size=$($GETSTRIPE -S -d $TDIR) ||
4563 error "$GETSTRIPE -S -d $TDIR failed"
4564 stripe_size=${stripe_size%% *}
4566 local file_size=$((stripe_size * OSTCOUNT))
4567 local file_num=$((NUMDIRS * NUMFILES + NUMFILES))
4568 local required_space=$((file_num * file_size))
4569 local free_space=$($LCTL get_param -n lov.$LOVNAME.kbytesavail)
4570 [[ $free_space -le $((required_space / 1024)) ]] &&
4571 skip_env "need at least $required_space bytes free space," \
4572 "have $free_space kbytes" && return
4575 local dd_count=$((file_size / dd_bs))
4577 # write data into the files
4581 for i in $(seq 1 $NUMFILES); do
4583 yes | dd bs=$dd_bs count=$dd_count of=$file >/dev/null 2>&1 ||
4584 error "write data into $file failed"
4586 for i in $(seq 1 $NUMDIRS); do
4587 for j in $(seq 1 $NUMFILES); do
4588 file=$TDIR/dir$i/file$j
4589 yes | dd bs=$dd_bs count=$dd_count of=$file \
4591 error "write data into $file failed"
4596 [[ $OSTCOUNT -gt 1 ]] && expected=$((OSTCOUNT - 1))
4599 local cmd="$LFS_MIGRATE -y -c $expected $TDIR/file1"
4601 eval $cmd || error "$cmd failed"
4603 check_stripe_count $TDIR/file1 $expected
4606 cmd="$LFS_MIGRATE -y -c $expected $TDIR/dir1"
4608 eval $cmd || error "$cmd failed"
4610 for j in $(seq 1 $NUMFILES); do
4611 check_stripe_count $TDIR/dir1/file$j $expected
4614 # lfs_migrate works with lfs find
4615 cmd="$LFIND -stripe_count $OSTCOUNT -type f $TDIR |
4616 $LFS_MIGRATE -y -c $expected"
4618 eval $cmd || error "$cmd failed"
4620 for i in $(seq 2 $NUMFILES); do
4621 check_stripe_count $TDIR/file$i $expected
4623 for i in $(seq 2 $NUMDIRS); do
4624 for j in $(seq 1 $NUMFILES); do
4625 check_stripe_count $TDIR/dir$i/file$j $expected
4629 run_test 56w "check lfs_migrate -c stripe_count works"
4632 check_swap_layouts_support && return 0
4633 [[ $OSTCOUNT -lt 2 ]] &&
4634 skip_env "need 2 OST, skipping test" && return
4636 local dir0=$DIR/$tdir/$testnum
4637 mkdir -p $dir0 || error "creating dir $dir0"
4639 local ref1=/etc/passwd
4640 local file1=$dir0/file1
4642 $SETSTRIPE -c 2 $file1
4644 $LFS migrate -c 1 $file1 || error "migrate failed rc = $?"
4645 stripe=$($GETSTRIPE -c $file1)
4646 [[ $stripe == 1 ]] || error "stripe of $file1 is $stripe != 1"
4647 cmp $file1 $ref1 || error "content mismatch $file1 differs from $ref1"
4652 run_test 56x "lfs migration support"
4655 local server_version=$(get_lustre_version $SINGLEMDS)
4656 [[ $(version_code $server_version) -lt $(version_code 2.4.53) ]] &&
4657 skip "No HSM support on $server_version MDS," \
4658 "need 2.4.53 at least" && return
4662 local dir0=$DIR/$tdir/$testnum
4663 mkdir -p $dir0 || error "creating dir $dir0"
4664 local f1=$dir0/file1
4665 local f2=$dir0/file2
4667 touch $f1 || error "creating std file $f1"
4668 $MULTIOP $f2 H2c || error "creating released file $f2"
4670 # a directory can be raid0, so ask only for files
4671 res=$($LFIND $dir0 -L raid0 -type f | wc -l)
4672 [[ $res == 2 ]] || error "search raid0: found $res files != 2"
4674 res=$($LFIND $dir0 \! -L raid0 -type f | wc -l)
4675 [[ $res == 0 ]] || error "search !raid0: found $res files != 0"
4677 # only files can be released, so no need to force file search
4678 res=$($LFIND $dir0 -L released)
4679 [[ $res == $f2 ]] || error "search released: found $res != $f2"
4681 res=$($LFIND $dir0 \! -L released)
4682 [[ $res == $f1 ]] || error "search !released: found $res != $f1"
4685 run_test 56y "lfs find -L raid0|released"
4688 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4689 # note test will not do anything if MDS is not local
4690 if [ "$(facet_fstype $SINGLEMDS)" != ldiskfs ]; then
4691 skip "Only applicable to ldiskfs-based MDTs"
4695 remote_mds_nodsh && skip "remote MDS with nodsh" && return
4696 local MNTDEV="osd*.*MDT*.mntdev"
4697 DEV=$(do_facet $SINGLEMDS lctl get_param -n $MNTDEV)
4698 [ -z "$DEV" ] && error "can't access $MNTDEV"
4699 for DEV in $(do_facet $SINGLEMDS lctl get_param -n $MNTDEV); do
4700 do_facet $SINGLEMDS $DUMPE2FS -h $DEV > $TMP/t57a.dump ||
4701 error "can't access $DEV"
4702 DEVISIZE=$(awk '/Inode size:/ { print $3 }' $TMP/t57a.dump)
4703 [[ $DEVISIZE -gt 128 ]] || error "inode size $DEVISIZE"
4707 run_test 57a "verify MDS filesystem created with large inodes =="
4710 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4711 if [ "$(facet_fstype $SINGLEMDS)" != ldiskfs ]; then
4712 skip "Only applicable to ldiskfs-based MDTs"
4716 remote_mds_nodsh && skip "remote MDS with nodsh" && return
4721 local FILEN=$dir/f$FILECOUNT
4723 rm -rf $dir || error "removing $dir"
4724 test_mkdir -p $dir || error "creating $dir"
4725 local num=$(get_mds_dir $dir)
4728 echo "mcreating $FILECOUNT files"
4729 createmany -m $dir/f 1 $FILECOUNT || \
4730 error "creating files in $dir"
4732 # verify that files do not have EAs yet
4733 $GETSTRIPE $FILE1 2>&1 | grep -q "no stripe" || error "$FILE1 has an EA"
4734 $GETSTRIPE $FILEN 2>&1 | grep -q "no stripe" || error "$FILEN has an EA"
4738 df $dir #make sure we get new statfs data
4739 local MDSFREE=$(do_facet $mymds \
4740 lctl get_param -n osd*.*MDT000$((num -1)).kbytesfree)
4741 local MDCFREE=$(lctl get_param -n mdc.*MDT000$((num -1))-mdc-*.kbytesfree)
4742 echo "opening files to create objects/EAs"
4744 for FILE in `seq -f $dir/f%g 1 $FILECOUNT`; do
4745 $OPENFILE -f O_RDWR $FILE > /dev/null 2>&1 || error "opening $FILE"
4748 # verify that files have EAs now
4749 $GETSTRIPE $FILE1 | grep -q "obdidx" || error "$FILE1 missing EA"
4750 $GETSTRIPE $FILEN | grep -q "obdidx" || error "$FILEN missing EA"
4752 sleep 1 #make sure we get new statfs data
4754 local MDSFREE2=$(do_facet $mymds \
4755 lctl get_param -n osd*.*MDT000$((num -1)).kbytesfree)
4756 local MDCFREE2=$(lctl get_param -n mdc.*MDT000$((num -1))-mdc-*.kbytesfree)
4757 if [[ $MDCFREE2 -lt $((MDCFREE - 16)) ]]; then
4758 if [ "$MDSFREE" != "$MDSFREE2" ]; then
4759 error "MDC before $MDCFREE != after $MDCFREE2"
4761 echo "MDC before $MDCFREE != after $MDCFREE2"
4762 echo "unable to confirm if MDS has large inodes"
4767 run_test 57b "default LOV EAs are stored inside large inodes ==="
4770 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4771 [ -z "$(which wiretest 2>/dev/null)" ] &&
4772 skip_env "could not find wiretest" && return
4775 run_test 58 "verify cross-platform wire constants =============="
4778 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4779 echo "touch 130 files"
4780 createmany -o $DIR/f59- 130
4782 unlinkmany $DIR/f59- 130
4784 # wait for commitment of removal
4785 wait_delete_completed
4787 run_test 59 "verify cancellation of llog records async ========="
4789 TEST60_HEAD="test_60 run $RANDOM"
4791 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4792 remote_mgs_nodsh && skip "remote MGS with nodsh" && return
4793 do_facet mgs "! which run-llog.sh &> /dev/null" &&
4794 skip_env "missing subtest run-llog.sh" && return
4795 log "$TEST60_HEAD - from kernel mode"
4796 do_facet mgs sh run-llog.sh
4798 run_test 60a "llog sanity tests run from kernel module =========="
4800 test_60b() { # bug 6411
4801 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4803 LLOG_COUNT=`dmesg | awk "/$TEST60_HEAD/{marker = 1; from_marker = 0;}
4815 [[ $LLOG_COUNT -gt 50 ]] &&
4816 error "CDEBUG_LIMIT not limiting messages ($LLOG_COUNT)" || true
4818 run_test 60b "limit repeated messages from CERROR/CWARN ========"
4821 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4822 echo "create 5000 files"
4823 createmany -o $DIR/f60c- 5000
4824 #define OBD_FAIL_MDS_LLOG_CREATE_FAILED 0x137
4825 lctl set_param fail_loc=0x80000137
4826 unlinkmany $DIR/f60c- 5000
4827 lctl set_param fail_loc=0
4829 run_test 60c "unlink file when mds full"
4832 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4833 SAVEPRINTK=$(lctl get_param -n printk)
4835 # verify "lctl mark" is even working"
4836 MESSAGE="test message ID $RANDOM $$"
4837 $LCTL mark "$MESSAGE" || error "$LCTL mark failed"
4838 dmesg | grep -q "$MESSAGE" || error "didn't find debug marker in log"
4840 lctl set_param printk=0 || error "set lnet.printk failed"
4841 lctl get_param -n printk | grep emerg || error "lnet.printk dropped emerg"
4842 MESSAGE="new test message ID $RANDOM $$"
4843 # Assume here that libcfs_debug_mark_buffer() uses D_WARNING
4844 $LCTL mark "$MESSAGE" || error "$LCTL mark failed"
4845 dmesg | grep -q "$MESSAGE" && error "D_WARNING wasn't masked" || true
4847 lctl set_param -n printk="$SAVEPRINTK"
4849 run_test 60d "test printk console message masking"
4852 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4854 dd if=/dev/zero of=$f bs=$(page_size) count=1 || error "dd $f failed"
4855 cancel_lru_locks osc
4856 $MULTIOP $f OSMWUc || error "$MULTIOP $f failed"
4859 run_test 61 "mmap() writes don't make sync hang ================"
4861 # bug 2330 - insufficient obd_match error checking causes LBUG
4863 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4866 cancel_lru_locks osc
4867 lctl set_param fail_loc=0x405
4868 cat $f && error "cat succeeded, expect -EIO"
4869 lctl set_param fail_loc=0
4871 # This test is now irrelevant (as of bug 10718 inclusion), we no longer
4872 # match every page all of the time.
4873 #run_test 62 "verify obd_match failure doesn't LBUG (should -EIO)"
4875 # bug 2319 - oig_wait() interrupted causes crash because of invalid waitq.
4876 test_63a() { # was test_63
4877 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4878 MAX_DIRTY_MB=`lctl get_param -n osc.*.max_dirty_mb | head -n 1`
4879 lctl set_param -n osc.*.max_dirty_mb 0
4880 for i in `seq 10` ; do
4881 dd if=/dev/zero of=$DIR/f63 bs=8k &
4887 lctl set_param -n osc.*.max_dirty_mb $MAX_DIRTY_MB
4888 rm -f $DIR/f63 || true
4890 run_test 63a "Verify oig_wait interruption does not crash ======="
4892 # bug 2248 - async write errors didn't return to application on sync
4893 # bug 3677 - async write errors left page locked
4895 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4897 lctl set_param debug=-1
4899 # ensure we have a grant to do async writes
4900 dd if=/dev/zero of=$DIR/$tfile bs=4k count=1
4903 #define OBD_FAIL_OSC_BRW_PREP_REQ 0x406
4904 lctl set_param fail_loc=0x80000406
4905 $MULTIOP $DIR/$tfile Owy && \
4906 error "sync didn't return ENOMEM"
4907 sync; sleep 2; sync # do a real sync this time to flush page
4908 lctl get_param -n llite.*.dump_page_cache | grep locked && \
4909 error "locked page left in cache after async error" || true
4912 run_test 63b "async write errors should be returned to fsync ==="
4915 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4917 lctl get_param -n osc.*[oO][sS][cC][_-]*.cur* | grep "[0-9]"
4919 run_test 64a "verify filter grant calculations (in kernel) ====="
4922 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4923 sh oos.sh $MOUNT || error "oos.sh failed: $?"
4925 run_test 64b "check out-of-space detection on client ==========="
4928 $LCTL set_param osc.*OST0000-osc-[^mM]*.cur_grant_bytes=0
4930 run_test 64c "verify grant shrink ========================------"
4932 # bug 1414 - set/get directories' stripe info
4934 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4935 test_mkdir -p $DIR/$tdir
4937 $LVERIFY $DIR/$tdir $DIR/$tdir/f1 || error "lverify failed"
4939 run_test 65a "directory with no stripe info ===================="
4942 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4943 test_mkdir -p $DIR/$tdir
4944 $SETSTRIPE -S $((STRIPESIZE * 2)) -i 0 -c 1 $DIR/$tdir ||
4947 $LVERIFY $DIR/$tdir $DIR/$tdir/f2 || error "lverify failed"
4949 run_test 65b "directory setstripe -S $((STRIPESIZE * 2)) -i 0 -c 1"
4952 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4953 if [[ $OSTCOUNT -gt 1 ]]; then
4954 test_mkdir -p $DIR/$tdir
4955 $SETSTRIPE -S $(($STRIPESIZE * 4)) -i 1 \
4956 -c $(($OSTCOUNT - 1)) $DIR/$tdir || error "setstripe"
4958 $LVERIFY $DIR/$tdir $DIR/$tdir/f3 || error "lverify failed"
4961 run_test 65c "directory setstripe -S $((STRIPESIZE*4)) -i 1 -c $((OSTCOUNT-1))"
4964 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4965 test_mkdir -p $DIR/$tdir
4966 if [[ $STRIPECOUNT -le 0 ]]; then
4968 elif [[ $STRIPECOUNT -gt 2000 ]]; then
4969 #LOV_MAX_STRIPE_COUNT is 2000
4970 [[ $OSTCOUNT -gt 2000 ]] && sc=2000 || sc=$(($OSTCOUNT - 1))
4972 sc=$(($STRIPECOUNT - 1))
4974 $SETSTRIPE -S $STRIPESIZE -c $sc $DIR/$tdir || error "setstripe"
4975 touch $DIR/$tdir/f4 $DIR/$tdir/f5
4976 $LVERIFY $DIR/$tdir $DIR/$tdir/f4 $DIR/$tdir/f5 ||
4977 error "lverify failed"
4979 run_test 65d "directory setstripe -S $STRIPESIZE -c stripe_count"
4982 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4983 test_mkdir -p $DIR/$tdir
4985 $SETSTRIPE $DIR/$tdir || error "setstripe"
4986 $GETSTRIPE -v $DIR/$tdir | grep "Default" ||
4987 error "no stripe info failed"
4989 $LVERIFY $DIR/$tdir $DIR/$tdir/f6 || error "lverify failed"
4991 run_test 65e "directory setstripe defaults ======================="
4994 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4995 test_mkdir -p $DIR/${tdir}f
4996 $RUNAS $SETSTRIPE $DIR/${tdir}f && error "setstripe succeeded" || true
4998 run_test 65f "dir setstripe permission (should return error) ==="
5001 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5002 test_mkdir -p $DIR/$tdir
5003 $SETSTRIPE -S $((STRIPESIZE * 2)) -i 0 -c 1 $DIR/$tdir ||
5005 $SETSTRIPE -d $DIR/$tdir || error "setstripe"
5006 $GETSTRIPE -v $DIR/$tdir | grep "Default" ||
5007 error "delete default stripe failed"
5009 run_test 65g "directory setstripe -d ==========================="
5012 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5013 test_mkdir -p $DIR/$tdir
5014 $SETSTRIPE -S $((STRIPESIZE * 2)) -i 0 -c 1 $DIR/$tdir ||
5016 test_mkdir -p $DIR/$tdir/dd1
5017 [ $($GETSTRIPE -c $DIR/$tdir) == $($GETSTRIPE -c $DIR/$tdir/dd1) ] ||
5018 error "stripe info inherit failed"
5020 run_test 65h "directory stripe info inherit ===================="
5022 test_65i() { # bug6367
5023 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5024 $SETSTRIPE -S 65536 -c -1 $MOUNT
5026 run_test 65i "set non-default striping on root directory (bug 6367)="
5028 test_65ia() { # bug12836
5029 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5030 $GETSTRIPE $MOUNT || error "getstripe $MOUNT failed"
5032 run_test 65ia "getstripe on -1 default directory striping"
5034 test_65ib() { # bug12836
5035 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5036 $GETSTRIPE -v $MOUNT || error "getstripe -v $MOUNT failed"
5038 run_test 65ib "getstripe -v on -1 default directory striping"
5040 test_65ic() { # bug12836
5041 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5042 $LFS find -mtime -1 $MOUNT > /dev/null || error "find $MOUNT failed"
5044 run_test 65ic "new find on -1 default directory striping"
5046 test_65j() { # bug6367
5047 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5049 # if we aren't already remounting for each test, do so for this test
5050 if [ "$CLEANUP" = ":" -a "$I_MOUNTED" = "yes" ]; then
5051 cleanup || error "failed to unmount"
5054 $SETSTRIPE -d $MOUNT || error "setstripe failed"
5056 run_test 65j "set default striping on root directory (bug 6367)="
5058 test_65k() { # bug11679
5059 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5060 [[ $OSTCOUNT -lt 2 ]] && skip_env "too few OSTs" && return
5061 remote_mds_nodsh && skip "remote MDS with nodsh" && return
5063 echo "Check OST status: "
5064 local MDS_OSCS=`do_facet $SINGLEMDS lctl dl |
5065 awk '/[oO][sS][cC].*md[ts]/ { print $4 }'`
5067 for OSC in $MDS_OSCS; do
5068 echo $OSC "is activate"
5069 do_facet $SINGLEMDS lctl --device %$OSC activate
5073 for INACTIVE_OSC in $MDS_OSCS; do
5074 echo "Deactivate: " $INACTIVE_OSC
5075 do_facet $SINGLEMDS lctl --device %$INACTIVE_OSC deactivate
5076 for STRIPE_OSC in $MDS_OSCS; do
5077 OST=`osc_to_ost $STRIPE_OSC`
5078 IDX=`do_facet $SINGLEMDS lctl get_param -n lov.*md*.target_obd |
5079 awk -F: /$OST/'{ print $1 }' | head -n 1`
5081 [ -f $DIR/$tdir/$IDX ] && continue
5082 echo "$SETSTRIPE -i $IDX -c 1 $DIR/$tdir/$IDX"
5083 $SETSTRIPE -i $IDX -c 1 $DIR/$tdir/$IDX
5085 [ $RC -ne 0 ] && error "setstripe should have succeeded"
5088 echo $INACTIVE_OSC "is Activate."
5089 do_facet $SINGLEMDS lctl --device %$INACTIVE_OSC activate
5092 run_test 65k "validate manual striping works properly with deactivated OSCs"
5094 test_65l() { # bug 12836
5095 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5096 test_mkdir -p $DIR/$tdir/test_dir
5097 $SETSTRIPE -c -1 $DIR/$tdir/test_dir
5098 $LFS find -mtime -1 $DIR/$tdir >/dev/null
5100 run_test 65l "lfs find on -1 stripe dir ========================"
5102 # bug 2543 - update blocks count on client
5104 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5106 dd if=/dev/zero of=$DIR/f66 bs=1k count=$COUNT
5107 sync; sync_all_data; sync; sync_all_data
5108 cancel_lru_locks osc
5109 BLOCKS=`ls -s $DIR/f66 | awk '{ print $1 }'`
5110 [ $BLOCKS -ge $COUNT ] || error "$DIR/f66 blocks $BLOCKS < $COUNT"
5112 run_test 66 "update inode blocks count on client ==============="
5117 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5119 if [ ! -z "$LLOOP" ]; then
5120 if swapon -s | grep -q $LLOOP; then
5121 swapoff $LLOOP || error "swapoff failed"
5124 $LCTL blockdev_detach $LLOOP || error "detach failed"
5128 if [ ! -z "$LLITELOOPLOAD" ]; then
5136 awk '($1 == "'$1':") { print $2 }' /proc/meminfo
5140 swapon -s | awk '($1 == "'$1'") { print $4 }'
5143 # test case for lloop driver, basic function
5145 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5146 [ "$UID" != 0 ] && skip_env "must run as root" && return
5147 llite_lloop_enabled || \
5148 { skip_env "llite_lloop module disabled" && return; }
5150 trap cleanup_68 EXIT
5152 if ! module_loaded llite_lloop; then
5153 if load_module llite/llite_lloop; then
5156 skip_env "can't find module llite_lloop"
5161 LLOOP=$TMP/lloop.`date +%s`.`date +%N`
5162 dd if=/dev/zero of=$DIR/f68a bs=4k count=1024
5163 $LCTL blockdev_attach $DIR/f68a $LLOOP || error "attach failed"
5165 directio rdwr $LLOOP 0 1024 4096 || error "direct write failed"
5166 directio rdwr $LLOOP 0 1025 4096 && error "direct write should fail"
5170 run_test 68a "lloop driver - basic test ========================"
5172 # excercise swapping to lustre by adding a high priority swapfile entry
5173 # and then consuming memory until it is used.
5174 test_68b() { # was test_68
5175 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5176 [ "$UID" != 0 ] && skip_env "must run as root" && return
5177 lctl get_param -n devices | grep -q obdfilter && \
5178 skip "local OST" && return
5180 grep -q llite_lloop /proc/modules
5181 [ $? -ne 0 ] && skip "can't find module llite_lloop" && return
5183 [ -z "`$LCTL list_nids | grep -v tcp`" ] && \
5184 skip "can't reliably test swap with TCP" && return
5186 MEMTOTAL=`meminfo MemTotal`
5187 NR_BLOCKS=$((MEMTOTAL>>8))
5188 [[ $NR_BLOCKS -le 2048 ]] && NR_BLOCKS=2048
5190 LLOOP=$TMP/lloop.`date +%s`.`date +%N`
5191 dd if=/dev/zero of=$DIR/f68b bs=64k seek=$NR_BLOCKS count=1
5194 $LCTL blockdev_attach $DIR/f68b $LLOOP || error "attach failed"
5196 trap cleanup_68 EXIT
5198 swapon -p 32767 $LLOOP || error "swapon $LLOOP failed"
5200 echo "before: `swapon -s | grep $LLOOP`"
5201 $MEMHOG $MEMTOTAL || error "error allocating $MEMTOTAL kB"
5202 echo "after: `swapon -s | grep $LLOOP`"
5203 SWAPUSED=`swap_used $LLOOP`
5207 [ $SWAPUSED -eq 0 ] && echo "no swap used???" || true
5209 run_test 68b "support swapping to Lustre ========================"
5211 # bug5265, obdfilter oa2dentry return -ENOENT
5212 # #define OBD_FAIL_OST_ENOENT 0x217
5214 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5215 remote_ost_nodsh && skip "remote OST with nodsh" && return
5218 $SETSTRIPE -c 1 -i 0 $f
5220 $DIRECTIO write ${f}.2 0 1 || error "directio write error"
5222 do_facet ost1 lctl set_param fail_loc=0x217
5223 $TRUNCATE $f 1 # vmtruncate() will ignore truncate() error.
5224 $DIRECTIO write $f 0 2 && error "write succeeded, expect -ENOENT"
5226 do_facet ost1 lctl set_param fail_loc=0
5227 $DIRECTIO write $f 0 2 || error "write error"
5229 cancel_lru_locks osc
5230 $DIRECTIO read $f 0 1 || error "read error"
5232 do_facet ost1 lctl set_param fail_loc=0x217
5233 $DIRECTIO read $f 1 1 && error "read succeeded, expect -ENOENT"
5235 do_facet ost1 lctl set_param fail_loc=0
5238 run_test 69 "verify oa2dentry return -ENOENT doesn't LBUG ======"
5241 test_mkdir -p $DIR/$tdir
5242 sh rundbench -C -D $DIR/$tdir 2 || error "dbench failed!"
5244 run_test 71 "Running dbench on lustre (don't segment fault) ===="
5246 test_72a() { # bug 5695 - Test that on 2.6 remove_suid works properly
5247 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5248 [ "$RUNAS_ID" = "$UID" ] &&
5249 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
5251 # Check that testing environment is properly set up. Skip if not
5252 FAIL_ON_ERROR=false check_runas_id_ret $RUNAS_ID $RUNAS_GID $RUNAS || {
5253 skip_env "User $RUNAS_ID does not exist - skipping"
5256 # We had better clear the $DIR to get enough space for dd
5259 chmod 777 $DIR/$tfile
5260 chmod ug+s $DIR/$tfile
5261 $RUNAS dd if=/dev/zero of=$DIR/$tfile bs=512 count=1 ||
5262 error "$RUNAS dd $DIR/$tfile failed"
5263 # See if we are still setuid/sgid
5264 test -u $DIR/$tfile -o -g $DIR/$tfile &&
5265 error "S/gid is not dropped on write"
5266 # Now test that MDS is updated too
5267 cancel_lru_locks mdc
5268 test -u $DIR/$tfile -o -g $DIR/$tfile &&
5269 error "S/gid is not dropped on MDS"
5272 run_test 72a "Test that remove suid works properly (bug5695) ===="
5274 test_72b() { # bug 24226 -- keep mode setting when size is not changing
5277 [ "$RUNAS_ID" = "$UID" ] && \
5278 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
5279 [ "$RUNAS_ID" -eq 0 ] && \
5280 skip_env "RUNAS_ID = 0 -- skipping" && return
5282 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5283 # Check that testing environment is properly set up. Skip if not
5284 FAIL_ON_ERROR=false check_runas_id_ret $RUNAS_ID $RUNAS_ID $RUNAS || {
5285 skip_env "User $RUNAS_ID does not exist - skipping"
5288 touch $DIR/${tfile}-f{g,u}
5289 test_mkdir $DIR/${tfile}-dg
5290 test_mkdir $DIR/${tfile}-du
5291 chmod 770 $DIR/${tfile}-{f,d}{g,u}
5292 chmod g+s $DIR/${tfile}-{f,d}g
5293 chmod u+s $DIR/${tfile}-{f,d}u
5294 for perm in 777 2777 4777; do
5295 $RUNAS chmod $perm $DIR/${tfile}-fg && error "S/gid file allowed improper chmod to $perm"
5296 $RUNAS chmod $perm $DIR/${tfile}-fu && error "S/uid file allowed improper chmod to $perm"
5297 $RUNAS chmod $perm $DIR/${tfile}-dg && error "S/gid dir allowed improper chmod to $perm"
5298 $RUNAS chmod $perm $DIR/${tfile}-du && error "S/uid dir allowed improper chmod to $perm"
5302 run_test 72b "Test that we keep mode setting if without file data changed (bug 24226)"
5304 # bug 3462 - multiple simultaneous MDC requests
5306 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5307 test_mkdir $DIR/d73-1
5308 test_mkdir $DIR/d73-2
5309 multiop_bg_pause $DIR/d73-1/f73-1 O_c || return 1
5312 lctl set_param fail_loc=0x80000129
5313 $MULTIOP $DIR/d73-1/f73-2 Oc &
5315 lctl set_param fail_loc=0
5317 $MULTIOP $DIR/d73-2/f73-3 Oc &
5321 wait $pid1 || return 1
5325 $CHECKSTAT -t file $DIR/d73-1/f73-1 || return 4
5326 $CHECKSTAT -t file $DIR/d73-1/f73-2 || return 5
5327 $CHECKSTAT -t file $DIR/d73-2/f73-3 || return 6
5331 run_test 73 "multiple MDC requests (should not deadlock)"
5333 test_74a() { # bug 6149, 6184
5334 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5335 #define OBD_FAIL_LDLM_ENQUEUE_OLD_EXPORT 0x30e
5337 # very important to OR with OBD_FAIL_ONCE (0x80000000) -- otherwise it
5338 # will spin in a tight reconnection loop
5340 $LCTL set_param fail_loc=0x8000030e
5341 # get any lock that won't be difficult - lookup works.
5343 $LCTL set_param fail_loc=0
5347 run_test 74a "ldlm_enqueue freed-export error path, ls (shouldn't LBUG)"
5349 test_74b() { # bug 13310
5350 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5351 #define OBD_FAIL_LDLM_ENQUEUE_OLD_EXPORT 0x30e
5353 # very important to OR with OBD_FAIL_ONCE (0x80000000) -- otherwise it
5354 # will spin in a tight reconnection loop
5355 $LCTL set_param fail_loc=0x8000030e
5356 # get a "difficult" lock
5358 $LCTL set_param fail_loc=0
5362 run_test 74b "ldlm_enqueue freed-export error path, touch (shouldn't LBUG)"
5365 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5366 #define OBD_FAIL_LDLM_NEW_LOCK
5367 $LCTL set_param fail_loc=0x319
5368 touch $DIR/$tfile && error "touch successful"
5369 $LCTL set_param fail_loc=0
5372 run_test 74c "ldlm_lock_create error path, (shouldn't LBUG)"
5375 awk '/lustre_inode_cache/ {print $2; exit}' /proc/slabinfo
5378 get_inode_slab_tunables() {
5379 awk '/lustre_inode_cache/ {print $9," ",$10," ",$11; exit}' /proc/slabinfo
5382 set_inode_slab_tunables() {
5383 echo "lustre_inode_cache $1" > /proc/slabinfo
5386 test_76() { # Now for bug 20433, added originally in bug 1443
5387 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5388 local SLAB_SETTINGS=`get_inode_slab_tunables`
5389 local CPUS=`getconf _NPROCESSORS_ONLN`
5390 # we cannot set limit below 1 which means 1 inode in each
5391 # per-cpu cache is still allowed
5392 set_inode_slab_tunables "1 1 0"
5393 cancel_lru_locks osc
5394 BEFORE_INODES=$(num_inodes)
5395 echo "before inodes: $BEFORE_INODES"
5397 [ "$SLOW" = "no" ] && COUNT=100
5398 for i in $(seq $COUNT); do
5402 cancel_lru_locks osc
5403 AFTER_INODES=$(num_inodes)
5404 echo "after inodes: $AFTER_INODES"
5406 while [[ $((AFTER_INODES-1*CPUS)) -gt $BEFORE_INODES ]]; do
5408 AFTER_INODES=$(num_inodes)
5410 echo "wait $wait seconds inodes: $AFTER_INODES"
5411 if [ $wait -gt 30 ]; then
5412 error "inode slab grew from $BEFORE_INODES to $AFTER_INODES"
5415 set_inode_slab_tunables "$SLAB_SETTINGS"
5417 run_test 76 "confirm clients recycle inodes properly ===="
5423 # Note: in sptlrpc modes which enable its own bulk checksum, the
5424 # original crc32_le bulk checksum will be automatically disabled,
5425 # and the OBD_FAIL_OSC_CHECKSUM_SEND/OBD_FAIL_OSC_CHECKSUM_RECEIVE
5426 # will be checked by sptlrpc code against sptlrpc bulk checksum.
5427 # In this case set_checksums() will not be no-op, because sptlrpc
5428 # bulk checksum will be enabled all through the test.
5430 [ "$ORIG_CSUM" ] || ORIG_CSUM=`lctl get_param -n osc.*.checksums | head -n1`
5431 lctl set_param -n osc.*.checksums $1
5435 export ORIG_CSUM_TYPE="`lctl get_param -n osc.*osc-[^mM]*.checksum_type |
5436 sed 's/.*\[\(.*\)\].*/\1/g' | head -n1`"
5437 CKSUM_TYPES=${CKSUM_TYPES:-"crc32 adler"}
5438 [ "$ORIG_CSUM_TYPE" = "crc32c" ] && CKSUM_TYPES="$CKSUM_TYPES crc32c"
5441 lctl set_param -n osc.*osc-[^mM]*.checksum_type $1
5442 log "set checksum type to $1"
5445 F77_TMP=$TMP/f77-temp
5448 dd if=/dev/urandom of=$F77_TMP bs=1M count=$F77SZ || \
5449 error "error writing to $F77_TMP"
5452 test_77a() { # bug 10889
5453 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5454 $GSS && skip "could not run with gss" && return
5455 [ ! -f $F77_TMP ] && setup_f77
5457 dd if=$F77_TMP of=$DIR/$tfile bs=1M count=$F77SZ || error "dd error"
5461 run_test 77a "normal checksum read/write operation"
5463 test_77b() { # bug 10889
5464 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5465 $GSS && skip "could not run with gss" && return
5466 [ ! -f $F77_TMP ] && setup_f77
5467 #define OBD_FAIL_OSC_CHECKSUM_SEND 0x409
5468 $LCTL set_param fail_loc=0x80000409
5471 dd if=$F77_TMP of=$DIR/$tfile bs=1M count=$F77SZ conv=sync ||
5472 error "dd error: $?"
5473 $LCTL set_param fail_loc=0
5475 for algo in $CKSUM_TYPES; do
5476 cancel_lru_locks osc
5477 set_checksum_type $algo
5478 #define OBD_FAIL_OSC_CHECKSUM_RECEIVE 0x408
5479 $LCTL set_param fail_loc=0x80000408
5480 cmp $F77_TMP $DIR/$tfile || error "file compare failed"
5481 $LCTL set_param fail_loc=0
5484 set_checksum_type $ORIG_CSUM_TYPE
5487 run_test 77b "checksum error on client write, read"
5489 test_77d() { # bug 10889
5490 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5491 $GSS && skip "could not run with gss" && return
5492 #define OBD_FAIL_OSC_CHECKSUM_SEND 0x409
5493 $LCTL set_param fail_loc=0x80000409
5495 $DIRECTIO write $DIR/$tfile 0 $F77SZ $((1024 * 1024)) ||
5496 error "direct write: rc=$?"
5497 $LCTL set_param fail_loc=0
5500 #define OBD_FAIL_OSC_CHECKSUM_RECEIVE 0x408
5501 $LCTL set_param fail_loc=0x80000408
5503 cancel_lru_locks osc
5504 $DIRECTIO read $DIR/$tfile 0 $F77SZ $((1024 * 1024)) ||
5505 error "direct read: rc=$?"
5506 $LCTL set_param fail_loc=0
5509 run_test 77d "checksum error on OST direct write, read"
5511 test_77f() { # bug 10889
5512 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5513 $GSS && skip "could not run with gss" && return
5515 for algo in $CKSUM_TYPES; do
5516 cancel_lru_locks osc
5517 set_checksum_type $algo
5518 #define OBD_FAIL_OSC_CHECKSUM_SEND 0x409
5519 $LCTL set_param fail_loc=0x409
5520 $DIRECTIO write $DIR/$tfile 0 $F77SZ $((1024 * 1024)) &&
5521 error "direct write succeeded"
5522 $LCTL set_param fail_loc=0
5524 set_checksum_type $ORIG_CSUM_TYPE
5527 run_test 77f "repeat checksum error on write (expect error)"
5529 test_77g() { # bug 10889
5530 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5531 $GSS && skip "could not run with gss" && return
5532 remote_ost_nodsh && skip "remote OST with nodsh" && return
5534 [ ! -f $F77_TMP ] && setup_f77
5536 $SETSTRIPE -c 1 -i 0 $DIR/$tfile
5537 #define OBD_FAIL_OST_CHECKSUM_RECEIVE 0x21a
5538 do_facet ost1 lctl set_param fail_loc=0x8000021a
5540 dd if=$F77_TMP of=$DIR/$tfile bs=1M count=$F77SZ ||
5541 error "write error: rc=$?"
5542 do_facet ost1 lctl set_param fail_loc=0
5545 cancel_lru_locks osc
5546 #define OBD_FAIL_OST_CHECKSUM_SEND 0x21b
5547 do_facet ost1 lctl set_param fail_loc=0x8000021b
5549 cmp $F77_TMP $DIR/$tfile || error "file compare failed"
5550 do_facet ost1 lctl set_param fail_loc=0
5553 run_test 77g "checksum error on OST write, read"
5555 test_77i() { # bug 13805
5556 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5557 $GSS && skip "could not run with gss" && return
5558 #define OBD_FAIL_OSC_CONNECT_CKSUM 0x40b
5559 lctl set_param fail_loc=0x40b
5560 remount_client $MOUNT
5561 lctl set_param fail_loc=0
5562 for VALUE in `lctl get_param osc.*osc-[^mM]*.checksum_type`; do
5563 PARAM=`echo ${VALUE[0]} | cut -d "=" -f1`
5564 algo=`lctl get_param -n $PARAM | sed 's/.*\[\(.*\)\].*/\1/g'`
5565 [ "$algo" = "adler" ] || error "algo set to $algo instead of adler"
5567 remount_client $MOUNT
5569 run_test 77i "client not supporting OSD_CONNECT_CKSUM"
5571 test_77j() { # bug 13805
5572 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5573 $GSS && skip "could not run with gss" && return
5574 #define OBD_FAIL_OSC_CKSUM_ADLER_ONLY 0x40c
5575 lctl set_param fail_loc=0x40c
5576 remount_client $MOUNT
5577 lctl set_param fail_loc=0
5578 sleep 2 # wait async osc connect to finish
5579 for VALUE in `lctl get_param osc.*osc-[^mM]*.checksum_type`; do
5580 PARAM=`echo ${VALUE[0]} | cut -d "=" -f1`
5581 algo=`lctl get_param -n $PARAM | sed 's/.*\[\(.*\)\].*/\1/g'`
5582 [ "$algo" = "adler" ] || error "algo set to $algo instead of adler"
5584 remount_client $MOUNT
5586 run_test 77j "client only supporting ADLER32"
5588 [ "$ORIG_CSUM" ] && set_checksums $ORIG_CSUM || true
5592 test_78() { # bug 10901
5593 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5594 remote_ost || { skip_env "local OST" && return; }
5597 F78SIZE=$(($(awk '/MemFree:/ { print $2 }' /proc/meminfo) / 1024))
5598 echo "MemFree: $F78SIZE, Max file size: $MAXFREE"
5599 MEMTOTAL=$(($(awk '/MemTotal:/ { print $2 }' /proc/meminfo) / 1024))
5600 echo "MemTotal: $MEMTOTAL"
5602 # reserve 256MB of memory for the kernel and other running processes,
5603 # and then take 1/2 of the remaining memory for the read/write buffers.
5604 if [ $MEMTOTAL -gt 512 ] ;then
5605 MEMTOTAL=$(((MEMTOTAL - 256 ) / 2))
5607 # for those poor memory-starved high-end clusters...
5608 MEMTOTAL=$((MEMTOTAL / 2))
5610 echo "Mem to use for directio: $MEMTOTAL"
5612 [[ $F78SIZE -gt $MEMTOTAL ]] && F78SIZE=$MEMTOTAL
5613 [[ $F78SIZE -gt 512 ]] && F78SIZE=512
5614 [[ $F78SIZE -gt $((MAXFREE / 1024)) ]] && F78SIZE=$((MAXFREE / 1024))
5615 SMALLESTOST=$(lfs df $DIR | grep OST | awk '{ print $4 }' | sort -n |
5617 echo "Smallest OST: $SMALLESTOST"
5618 [[ $SMALLESTOST -lt 10240 ]] &&
5619 skip "too small OSTSIZE, useless to run large O_DIRECT test" && return 0
5621 [[ $F78SIZE -gt $((SMALLESTOST * $OSTCOUNT / 1024 - 80)) ]] &&
5622 F78SIZE=$((SMALLESTOST * $OSTCOUNT / 1024 - 80))
5624 [ "$SLOW" = "no" ] && NSEQ=1 && [ $F78SIZE -gt 32 ] && F78SIZE=32
5625 echo "File size: $F78SIZE"
5626 $SETSTRIPE -c $OSTCOUNT $DIR/$tfile || error "setstripe failed"
5627 for i in $(seq 1 $NSEQ); do
5628 FSIZE=$(($F78SIZE / ($NSEQ - $i + 1)))
5629 echo directIO rdwr round $i of $NSEQ
5630 $DIRECTIO rdwr $DIR/$tfile 0 $FSIZE 1048576||error "rdwr failed"
5635 run_test 78 "handle large O_DIRECT writes correctly ============"
5637 test_79() { # bug 12743
5638 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5639 wait_delete_completed
5641 BKTOTAL=$(calc_osc_kbytes kbytestotal)
5642 BKFREE=$(calc_osc_kbytes kbytesfree)
5643 BKAVAIL=$(calc_osc_kbytes kbytesavail)
5645 STRING=`df -P $MOUNT | tail -n 1 | awk '{print $2","$3","$4}'`
5646 DFTOTAL=`echo $STRING | cut -d, -f1`
5647 DFUSED=`echo $STRING | cut -d, -f2`
5648 DFAVAIL=`echo $STRING | cut -d, -f3`
5649 DFFREE=$(($DFTOTAL - $DFUSED))
5651 ALLOWANCE=$((64 * $OSTCOUNT))
5653 if [ $DFTOTAL -lt $(($BKTOTAL - $ALLOWANCE)) ] ||
5654 [ $DFTOTAL -gt $(($BKTOTAL + $ALLOWANCE)) ] ; then
5655 error "df total($DFTOTAL) mismatch OST total($BKTOTAL)"
5657 if [ $DFFREE -lt $(($BKFREE - $ALLOWANCE)) ] ||
5658 [ $DFFREE -gt $(($BKFREE + $ALLOWANCE)) ] ; then
5659 error "df free($DFFREE) mismatch OST free($BKFREE)"
5661 if [ $DFAVAIL -lt $(($BKAVAIL - $ALLOWANCE)) ] ||
5662 [ $DFAVAIL -gt $(($BKAVAIL + $ALLOWANCE)) ] ; then
5663 error "df avail($DFAVAIL) mismatch OST avail($BKAVAIL)"
5666 run_test 79 "df report consistency check ======================="
5668 test_80() { # bug 10718
5669 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5670 # relax strong synchronous semantics for slow backends like ZFS
5671 local soc="obdfilter.*.sync_on_lock_cancel"
5672 local soc_old=$(do_facet ost1 lctl get_param -n $soc | head -n1)
5674 if [ "$soc_old" != "never" -a "$(facet_fstype ost1)" != "ldiskfs" ]; then
5675 hosts=$(for host in $(seq -f "ost%g" 1 $OSTCOUNT); do
5676 facet_active_host $host; done | sort -u)
5677 do_nodes $hosts lctl set_param $soc=never
5680 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=1M
5682 local BEFORE=`date +%s`
5683 cancel_lru_locks osc
5684 local AFTER=`date +%s`
5685 local DIFF=$((AFTER-BEFORE))
5686 if [ $DIFF -gt 1 ] ; then
5687 error "elapsed for 1M@1T = $DIFF"
5690 [ -n "$hosts" ] && do_nodes $hosts lctl set_param $soc=$soc_old
5694 run_test 80 "Page eviction is equally fast at high offsets too ===="
5696 test_81a() { # LU-456
5697 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5698 remote_ost_nodsh && skip "remote OST with nodsh" && return
5699 # define OBD_FAIL_OST_MAPBLK_ENOSPC 0x228
5700 # MUST OR with the OBD_FAIL_ONCE (0x80000000)
5701 do_facet ost1 lctl set_param fail_loc=0x80000228
5703 # write should trigger a retry and success
5704 $SETSTRIPE -i 0 -c 1 $DIR/$tfile
5705 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
5707 if [ $RC -ne 0 ] ; then
5708 error "write should success, but failed for $RC"
5711 run_test 81a "OST should retry write when get -ENOSPC ==============="
5713 test_81b() { # LU-456
5714 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5715 remote_ost_nodsh && skip "remote OST with nodsh" && return
5716 # define OBD_FAIL_OST_MAPBLK_ENOSPC 0x228
5717 # Don't OR with the OBD_FAIL_ONCE (0x80000000)
5718 do_facet ost1 lctl set_param fail_loc=0x228
5720 # write should retry several times and return -ENOSPC finally
5721 $SETSTRIPE -i 0 -c 1 $DIR/$tfile
5722 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
5725 if [ $RC -ne $ENOSPC ] ; then
5726 error "dd should fail for -ENOSPC, but succeed."
5729 run_test 81b "OST should return -ENOSPC when retry still fails ======="
5731 test_82() { # LU-1031
5732 dd if=/dev/zero of=$DIR/$tfile bs=1M count=10
5736 multiop_bg_pause $DIR/$tfile OG${gid1}_g${gid1}c || return 1
5738 multiop_bg_pause $DIR/$tfile O_G${gid2}r10g${gid2}c || return 2
5740 kill -USR1 $MULTIPID2
5742 if [[ `ps h -o comm -p $MULTIPID2` == "" ]]; then
5743 error "First grouplock does not block second one"
5745 echo "Second grouplock blocks first one"
5747 kill -USR1 $MULTIPID1
5751 run_test 82 "Basic grouplock test ==============================="
5754 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" &&
5756 test_mkdir -p $DIR/d99cvsroot
5757 chown $RUNAS_ID $DIR/d99cvsroot
5758 local oldPWD=$PWD # bug 13584, use $TMP as working dir
5761 $RUNAS cvs -d $DIR/d99cvsroot init || error "cvs init failed"
5764 run_test 99a "cvs init ========================================="
5767 [ -z "$(which cvs 2>/dev/null)" ] &&
5768 skip_env "could not find cvs" && return
5769 [ ! -d $DIR/d99cvsroot ] && test_99a
5771 # some versions of cvs import exit(1) when asked to import links or
5772 # files they can't read. ignore those files.
5773 TOIGNORE=$(find . -type l -printf '-I %f\n' -o \
5774 ! -perm +4 -printf '-I %f\n')
5775 $RUNAS cvs -d $DIR/d99cvsroot import -m "nomesg" $TOIGNORE \
5776 d99reposname vtag rtag
5778 run_test 99b "cvs import ======================================="
5781 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" && return
5782 [ ! -d $DIR/d99cvsroot ] && test_99b
5784 test_mkdir -p $DIR/d99reposname
5785 chown $RUNAS_ID $DIR/d99reposname
5786 $RUNAS cvs -d $DIR/d99cvsroot co d99reposname
5788 run_test 99c "cvs checkout ====================================="
5791 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" && return
5792 [ ! -d $DIR/d99cvsroot ] && test_99c
5793 cd $DIR/d99reposname
5795 $RUNAS cvs add -m 'addmsg' foo99
5797 run_test 99d "cvs add =========================================="
5800 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" && return
5801 [ ! -d $DIR/d99cvsroot ] && test_99c
5802 cd $DIR/d99reposname
5805 run_test 99e "cvs update ======================================="
5808 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" && return
5809 [ ! -d $DIR/d99cvsroot ] && test_99d
5810 cd $DIR/d99reposname
5811 $RUNAS cvs commit -m 'nomsg' foo99
5812 rm -fr $DIR/d99cvsroot
5814 run_test 99f "cvs commit ======================================="
5817 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5818 [ "$NETTYPE" = tcp ] || \
5819 { skip "TCP secure port test, not useful for NETTYPE=$NETTYPE" && \
5822 remote_ost_nodsh && skip "remote OST with nodsh" && return
5823 remote_mds_nodsh && skip "remote MDS with nodsh" && return
5825 { skip "useless for local single node setup" && return; }
5827 netstat -tna | ( rc=1; while read PROT SND RCV LOCAL REMOTE STAT; do
5828 [ "$PROT" != "tcp" ] && continue
5829 RPORT=$(echo $REMOTE | cut -d: -f2)
5830 [ "$RPORT" != "$ACCEPTOR_PORT" ] && continue
5833 LPORT=`echo $LOCAL | cut -d: -f2`
5834 if [ $LPORT -ge 1024 ]; then
5835 echo "bad: $PROT $SND $RCV $LOCAL $REMOTE $STAT"
5837 error_exit "local: $LPORT > 1024, remote: $RPORT"
5840 [ "$rc" = 0 ] || error_exit "privileged port not found" )
5842 run_test 100 "check local port using privileged port ==========="
5844 function get_named_value()
5853 echo $line | sed "s/^$tag[ ]*//"
5860 export CACHE_MAX=$($LCTL get_param -n llite.*.max_cached_mb |
5861 awk '/^max_cached_mb/ { print $2 }')
5864 $LCTL set_param -n llite.*.max_cached_mb $CACHE_MAX
5869 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5873 local cache_limit=32
5875 $LCTL set_param -n osc.*-osc*.rpc_stats 0
5876 trap cleanup_101a EXIT
5877 $LCTL set_param -n llite.*.read_ahead_stats 0
5878 $LCTL set_param -n llite.*.max_cached_mb $cache_limit
5881 # randomly read 10000 of 64K chunks from file 3x 32MB in size
5883 echo "nreads: $nreads file size: $((cache_limit * 3))MB"
5884 $READS -f $DIR/$tfile -s$((cache_limit * 3192 * 1024)) -b65536 -C -n$nreads -t 180
5887 for s in $($LCTL get_param -n llite.*.read_ahead_stats |
5888 get_named_value 'read but discarded' | cut -d" " -f1); do
5889 discard=$(($discard + $s))
5893 if [[ $(($discard * 10)) -gt $nreads ]]; then
5894 $LCTL get_param osc.*-osc*.rpc_stats
5895 $LCTL get_param llite.*.read_ahead_stats
5896 error "too many ($discard) discarded pages"
5898 rm -f $DIR/$tfile || true
5900 run_test 101a "check read-ahead for random reads ================"
5903 test_mkdir -p $DIR/$tdir
5905 STRIPE_COUNT=$OSTCOUNT
5908 local list=$(comma_list $(osts_nodes))
5909 set_osd_param $list '' read_cache_enable 0
5910 set_osd_param $list '' writethrough_cache_enable 0
5912 trap cleanup_test101bc EXIT
5913 # prepare the read-ahead file
5914 $SETSTRIPE -S $STRIPE_SIZE -i $STRIPE_OFFSET -c $OSTCOUNT $DIR/$tfile
5916 dd if=/dev/zero of=$DIR/$tfile bs=1024k count=100 2> /dev/null
5919 cleanup_test101bc() {
5924 local list=$(comma_list $(osts_nodes))
5925 set_osd_param $list '' read_cache_enable 1
5926 set_osd_param $list '' writethrough_cache_enable 1
5930 awk 'BEGIN{total=0}; {total+=$1}; END{print total}'
5935 local STRIPE_SIZE=1048576
5936 local RA_INC=1048576
5937 local STRIDE_LENGTH=$((STRIPE_SIZE/READ_SIZE))
5938 local FILE_LENGTH=$((64*100))
5939 local discard_limit=$((((STRIDE_LENGTH - 1)*3/(STRIDE_LENGTH*OSTCOUNT))* \
5940 (STRIDE_LENGTH*OSTCOUNT - STRIDE_LENGTH)))
5941 DISCARD=$($LCTL get_param -n llite.*.read_ahead_stats |
5942 get_named_value 'read but discarded' |
5943 cut -d" " -f1 | calc_total)
5944 if [[ $DISCARD -gt $discard_limit ]]; then
5945 $LCTL get_param llite.*.read_ahead_stats
5946 error "Too many ($DISCARD) discarded pages with size (${READ_SIZE})"
5948 echo "Read-ahead success for size ${READ_SIZE}"
5953 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5954 [[ $OSTCOUNT -lt 2 ]] &&
5955 skip_env "skipping stride IO stride-ahead test" && return
5956 local STRIPE_SIZE=1048576
5957 local STRIDE_SIZE=$((STRIPE_SIZE*OSTCOUNT))
5958 local FILE_LENGTH=$((STRIPE_SIZE*100))
5959 local ITERATION=$((FILE_LENGTH/STRIDE_SIZE))
5960 # prepare the read-ahead file
5962 cancel_lru_locks osc
5963 for BIDX in 2 4 8 16 32 64 128 256
5965 local BSIZE=$((BIDX*4096))
5966 local READ_COUNT=$((STRIPE_SIZE/BSIZE))
5967 local STRIDE_LENGTH=$((STRIDE_SIZE/BSIZE))
5968 local OFFSET=$((STRIPE_SIZE/BSIZE*(OSTCOUNT - 1)))
5969 $LCTL set_param -n llite.*.read_ahead_stats 0
5970 $READS -f $DIR/$tfile -l $STRIDE_LENGTH -o $OFFSET \
5971 -s $FILE_LENGTH -b $STRIPE_SIZE -a $READ_COUNT -n $ITERATION
5972 cancel_lru_locks osc
5978 run_test 101b "check stride-io mode read-ahead ================="
5981 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5982 local STRIPE_SIZE=1048576
5983 local FILE_LENGTH=$((STRIPE_SIZE*100))
5989 cancel_lru_locks osc
5990 $LCTL set_param osc.*.rpc_stats 0
5991 $READS -f $DIR/$tfile -s$FILE_LENGTH -b65536 -n$nreads -t 180
5992 for osc_rpc_stats in $($LCTL get_param -N osc.*.rpc_stats); do
5993 local stats=$($LCTL get_param -n $osc_rpc_stats)
5994 local lines=$(echo "$stats" | awk 'END {print NR;}')
5997 if [ $lines -le 20 ]; then
6000 for size in 1 2 4 8; do
6001 local rpc=$(echo "$stats" |
6002 awk '($1 == "'$size':") {print $2; exit; }')
6004 error "Small $((size*4))k read IO $rpc !"
6006 echo "$osc_rpc_stats check passed!"
6011 run_test 101c "check stripe_size aligned read-ahead ================="
6014 $LCTL get_param -n llite.*.max_read_ahead_mb | head -n 1
6015 $LCTL set_param -n llite.*.max_read_ahead_mb $1 > /dev/null 2>&1
6019 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6020 local file=$DIR/$tfile
6021 local size=${FILESIZE_101c:-500}
6022 local ra_MB=${READAHEAD_MB:-40}
6024 local space=$(df -P $DIR | tail -n 1 | awk '{ print $4 }')
6025 [ $space -gt $((size * 1024)) ] ||
6026 { skip "Need free space ${size}M, have ${space}K" && return; }
6028 echo "Creating test file $file of size ${size}M with ${space}K free space"
6029 $SETSTRIPE -c -1 $file || error "setstripe failed"
6030 dd if=/dev/zero of=$file bs=1M count=$size || error "dd failed"
6031 echo Cancel LRU locks on lustre client to flush the client cache
6032 cancel_lru_locks osc
6034 echo Disable read-ahead
6035 local old_READAHEAD=$(set_read_ahead 0)
6037 echo Reading the test file $file with read-ahead disabled
6038 time_ra_OFF=$(do_and_time "dd if=$file of=/dev/null bs=1M count=$size")
6040 echo Cancel LRU locks on lustre client to flush the client cache
6041 cancel_lru_locks osc
6042 echo Enable read-ahead with ${ra_MB}MB
6043 set_read_ahead $ra_MB
6045 echo Reading the test file $file with read-ahead enabled
6046 time_ra_ON=$(do_and_time "dd if=$file of=/dev/null bs=1M count=$size")
6048 echo read-ahead disabled time read $time_ra_OFF
6049 echo read-ahead enabled time read $time_ra_ON
6051 set_read_ahead $old_READAHEAD
6053 wait_delete_completed
6055 [ $time_ra_ON -lt $time_ra_OFF ] ||
6056 error "read-ahead enabled time read (${time_ra_ON}s) is more than
6057 read-ahead disabled time read (${time_ra_OFF}s) filesize ${size}M"
6059 run_test 101d "file read with and without read-ahead enabled ================="
6062 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6063 local file=$DIR/$tfile
6064 local size_KB=500 #KB
6068 local free_KB=$(df -P $DIR | tail -n 1 | awk '{ print $4 }')
6069 local need_KB=$((count * size_KB))
6070 [[ $free_KB -le $need_KB ]] &&
6071 skip_env "Need free space $need_KB, have $free_KB" && return
6073 echo "Creating $count ${size_KB}K test files"
6074 for ((i = 0; i < $count; i++)); do
6075 dd if=/dev/zero of=$file.$i bs=$bsize count=$size_KB 2>/dev/null
6078 echo Cancel LRU locks on lustre client to flush the client cache
6079 cancel_lru_locks osc
6081 echo Reset readahead stats
6082 $LCTL set_param -n llite.*.read_ahead_stats 0
6084 for ((i = 0; i < $count; i++)); do
6085 dd if=$file.$i of=/dev/null bs=$bsize count=$size_KB 2>/dev/null
6088 local miss=$($LCTL get_param -n llite.*.read_ahead_stats | \
6089 get_named_value 'misses' | cut -d" " -f1 | calc_total)
6091 for ((i = 0; i < $count; i++)); do
6092 rm -rf $file.$i 2>/dev/null
6095 #10000 means 20% reads are missing in readahead
6096 [[ $miss -lt 10000 ]] || error "misses too much for small reads"
6098 run_test 101e "check read-ahead for small read(1k) for small files(500k)"
6100 cleanup_test101f() {
6102 $LCTL set_param -n llite.*.max_read_ahead_whole_mb $MAX_WHOLE_MB
6103 rm -rf $DIR/$tfile 2>/dev/null
6107 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6108 local file=$DIR/$tfile
6111 MAX_WHOLE_MB=$($LCTL get_param -n llite.*.max_read_ahead_whole_mb)
6112 $LCTL set_param -n llite.*.max_read_ahead_whole_mb 2
6113 dd if=/dev/zero of=${file} bs=2097152 count=1 2>/dev/null
6114 trap cleanup_test101f EXIT
6116 echo Cancel LRU locks on lustre client to flush the client cache
6117 cancel_lru_locks osc
6119 echo Reset readahead stats
6120 $LCTL set_param -n llite.*.read_ahead_stats 0
6121 # Random read in a 2M file, because max_read_ahead_whole_mb = 2M,
6122 # readahead should read in 2M file on second read, so only miss
6124 echo Random 4K reads on 2M file for 1000 times
6125 $READS -f $file -s 2097152 -b 4096 -n $nreads
6127 echo checking missing pages
6128 local miss=$($LCTL get_param -n llite.*.read_ahead_stats |
6129 get_named_value 'misses' | cut -d" " -f1 | calc_total)
6131 [ $miss -lt 3 ] || error "misses too much pages!"
6134 run_test 101f "check read-ahead for max_read_ahead_whole_mb"
6137 test_mkdir -p $DIR/$tdir
6138 chown $RUNAS_ID $DIR/$tdir
6141 STRIPE_COUNT=$OSTCOUNT
6142 [[ $OSTCOUNT -gt 4 ]] && STRIPE_COUNT=4
6144 trap cleanup_test102 EXIT
6146 $1 $SETSTRIPE -S $STRIPE_SIZE -i $STRIPE_OFFSET -c $STRIPE_COUNT $tdir
6148 for num in 1 2 3 4; do
6149 for count in $(seq 1 $STRIPE_COUNT); do
6150 for idx in $(seq 0 $[$STRIPE_COUNT - 1]); do
6151 local size=`expr $STRIPE_SIZE \* $num`
6152 local file=file"$num-$idx-$count"
6153 $1 $SETSTRIPE -S $size -i $idx -c $count $file
6159 $1 $TAR cf $TMP/f102.tar $tdir --xattrs
6165 rm -rf $DIR/d0.sanity/d102
6169 local testfile=$DIR/xattr_testfile
6173 [ "$UID" != 0 ] && skip_env "must run as root" && return
6174 [ -z "$(lctl get_param -n mdc.*-mdc-*.connect_flags | grep xattr)" ] &&
6175 skip_env "must have user_xattr" && return
6177 [ -z "$(which setfattr 2>/dev/null)" ] &&
6178 skip_env "could not find setfattr" && return
6180 echo "set/get xattr..."
6181 setfattr -n trusted.name1 -v value1 $testfile ||
6182 error "setfattr -n trusted.name1=value1 $testfile failed"
6183 getfattr -n trusted.name1 $testfile 2> /dev/null |
6184 grep "trusted.name1=.value1" ||
6185 error "$testfile missing trusted.name1=value1"
6187 setfattr -n user.author1 -v author1 $testfile ||
6188 error "setfattr -n user.author1=author1 $testfile failed"
6189 getfattr -n user.author1 $testfile 2> /dev/null |
6190 grep "user.author1=.author1" ||
6191 error "$testfile missing trusted.author1=author1"
6194 setfattr -n trusted.name2 -v value2 $testfile ||
6195 error "$testfile unable to set trusted.name2"
6196 setfattr -n trusted.name3 -v value3 $testfile ||
6197 error "$testfile unable to set trusted.name3"
6198 [ $(getfattr -d -m "^trusted" $testfile 2> /dev/null |
6199 grep "trusted.name" | wc -l) -eq 3 ] ||
6200 error "$testfile missing 3 trusted.name xattrs"
6202 setfattr -n user.author2 -v author2 $testfile ||
6203 error "$testfile unable to set user.author2"
6204 setfattr -n user.author3 -v author3 $testfile ||
6205 error "$testfile unable to set user.author3"
6206 [ $(getfattr -d -m "^user" $testfile 2> /dev/null |
6207 grep "user.author" | wc -l) -eq 3 ] ||
6208 error "$testfile missing 3 user.author xattrs"
6210 echo "remove xattr..."
6211 setfattr -x trusted.name1 $testfile ||
6212 error "$testfile error deleting trusted.name1"
6213 getfattr -d -m trusted $testfile 2> /dev/null | grep "trusted.name1" &&
6214 error "$testfile did not delete trusted.name1 xattr"
6216 setfattr -x user.author1 $testfile ||
6217 error "$testfile error deleting user.author1"
6218 getfattr -d -m user $testfile 2> /dev/null | grep "user.author1" &&
6219 error "$testfile did not delete trusted.name1 xattr"
6221 # b10667: setting lustre special xattr be silently discarded
6222 echo "set lustre special xattr ..."
6223 setfattr -n "trusted.lov" -v "invalid value" $testfile ||
6224 error "$testfile allowed setting trusted.lov"
6226 run_test 102a "user xattr test =================================="
6229 [ -z "$(which setfattr 2>/dev/null)" ] &&
6230 skip_env "could not find setfattr" && return
6232 # b10930: get/set/list trusted.lov xattr
6233 echo "get/set/list trusted.lov xattr ..."
6234 [[ $OSTCOUNT -lt 2 ]] && skip_env "skipping 2-stripe test" && return
6235 local testfile=$DIR/$tfile
6236 $SETSTRIPE -S 65536 -i 1 -c $OSTCOUNT $testfile ||
6237 error "setstripe failed"
6238 local STRIPECOUNT=$($GETSTRIPE -c $testfile) ||
6239 error "getstripe failed"
6240 getfattr -d -m "^trusted" $testfile 2>/dev/null | grep "trusted.lov" ||
6241 error "can't get trusted.lov from $testfile"
6243 local testfile2=${testfile}2
6244 local value=$(getfattr -n trusted.lov $testfile 2>/dev/null |
6245 grep "trusted.lov" | sed -e 's/[^=]\+=//')
6248 setfattr -n trusted.lov -v $value $testfile2
6249 local stripe_size=$($GETSTRIPE -S $testfile2)
6250 local stripe_count=$($GETSTRIPE -c $testfile2)
6251 [[ $stripe_size -eq 65536 ]] ||
6252 error "stripe size $stripe_size != 65536"
6253 [[ $stripe_count -eq $STRIPECOUNT ]] ||
6254 error "stripe count $stripe_count != $STRIPECOUNT"
6257 run_test 102b "getfattr/setfattr for trusted.lov EAs ============"
6260 [ -z "$(which setfattr 2>/dev/null)" ] &&
6261 skip_env "could not find setfattr" && return
6263 # b10930: get/set/list lustre.lov xattr
6264 echo "get/set/list lustre.lov xattr ..."
6265 [[ $OSTCOUNT -lt 2 ]] && skip_env "skipping 2-stripe test" && return
6266 test_mkdir -p $DIR/$tdir
6267 chown $RUNAS_ID $DIR/$tdir
6268 local testfile=$DIR/$tdir/$tfile
6269 $RUNAS $SETSTRIPE -S 65536 -i 1 -c $OSTCOUNT $testfile ||
6270 error "setstripe failed"
6271 local STRIPECOUNT=$($RUNAS $GETSTRIPE -c $testfile) ||
6272 error "getstripe failed"
6273 $RUNAS getfattr -d -m "^lustre" $testfile 2> /dev/null | \
6274 grep "lustre.lov" || error "can't get lustre.lov from $testfile"
6276 local testfile2=${testfile}2
6277 local value=`getfattr -n lustre.lov $testfile 2> /dev/null | \
6278 grep "lustre.lov" |sed -e 's/[^=]\+=//' `
6280 $RUNAS $MCREATE $testfile2
6281 $RUNAS setfattr -n lustre.lov -v $value $testfile2
6282 local stripe_size=$($RUNAS $GETSTRIPE -S $testfile2)
6283 local stripe_count=$($RUNAS $GETSTRIPE -c $testfile2)
6284 [ $stripe_size -eq 65536 ] || error "stripe size $stripe_size != 65536"
6285 [ $stripe_count -eq $STRIPECOUNT ] ||
6286 error "stripe count $stripe_count != $STRIPECOUNT"
6288 run_test 102c "non-root getfattr/setfattr for lustre.lov EAs ==========="
6290 compare_stripe_info1() {
6291 local stripe_index_all_zero=true
6293 for num in 1 2 3 4; do
6294 for count in $(seq 1 $STRIPE_COUNT); do
6295 for offset in $(seq 0 $[$STRIPE_COUNT - 1]); do
6296 local size=$((STRIPE_SIZE * num))
6297 local file=file"$num-$offset-$count"
6298 stripe_size=$(lfs getstripe -S $PWD/$file)
6299 [[ $stripe_size -ne $size ]] &&
6300 error "$file: size $stripe_size != $size"
6301 stripe_count=$(lfs getstripe -c $PWD/$file)
6302 # allow fewer stripes to be created, ORI-601
6303 [[ $stripe_count -lt $(((3 * count + 3) / 4)) ]] &&
6304 error "$file: count $stripe_count != $count"
6305 stripe_index=$(lfs getstripe -i $PWD/$file)
6306 [[ $stripe_index -ne 0 ]] &&
6307 stripe_index_all_zero=false
6311 $stripe_index_all_zero &&
6312 error "all files are being extracted starting from OST index 0"
6317 [ -n "$(which tar 2>/dev/null)" ] &&
6318 strings $(which tar) | grep -q "lustre" && echo tar
6322 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6323 # b10930: tar test for trusted.lov xattr
6324 TAR=$(find_lustre_tar)
6325 [ -z "$TAR" ] && skip_env "lustre-aware tar is not installed" && return
6326 [[ $OSTCOUNT -lt 2 ]] && skip_env "skipping N-stripe test" && return
6328 test_mkdir -p $DIR/d102d
6329 $TAR xf $TMP/f102.tar -C $DIR/d102d --xattrs
6331 compare_stripe_info1
6333 run_test 102d "tar restore stripe info from tarfile,not keep osts ==========="
6336 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6337 # b10930: tar test for trusted.lov xattr
6338 TAR=$(find_lustre_tar)
6339 [ -z "$TAR" ] && skip_env "lustre-aware tar is not installed" && return
6340 [[ $OSTCOUNT -lt 2 ]] && skip_env "skipping N-stripe test" && return
6342 test_mkdir -p $DIR/d102f
6344 $TAR cf - --xattrs $tdir | $TAR xf - --xattrs -C $DIR/d102f
6346 compare_stripe_info1
6348 run_test 102f "tar copy files, not keep osts ==========="
6351 local xsize=${1:-1024} # in bytes
6352 local file=$DIR/$tfile
6354 [ -z $(lctl get_param -n mdc.*.connect_flags | grep xattr) ] &&
6355 skip "must have user_xattr" && return 0
6356 [ -z "$(which setfattr 2>/dev/null)" ] &&
6357 skip_env "could not find setfattr" && return 0
6358 [ -z "$(which getfattr 2>/dev/null)" ] &&
6359 skip_env "could not find getfattr" && return 0
6363 local value="$(generate_string $xsize)"
6365 local xbig=trusted.big
6366 log "save $xbig on $file"
6367 setfattr -n $xbig -v $value $file ||
6368 error "saving $xbig on $file failed"
6370 local orig=$(get_xattr_value $xbig $file)
6371 [[ "$orig" != "$value" ]] && error "$xbig different after saving $xbig"
6373 local xsml=trusted.sml
6374 log "save $xsml on $file"
6375 setfattr -n $xsml -v val $file || error "saving $xsml on $file failed"
6377 local new=$(get_xattr_value $xbig $file)
6378 [[ "$new" != "$orig" ]] && error "$xbig different after saving $xsml"
6380 log "grow $xsml on $file"
6381 setfattr -n $xsml -v "$value" $file ||
6382 error "growing $xsml on $file failed"
6384 new=$(get_xattr_value $xbig $file)
6385 [[ "$new" != "$orig" ]] && error "$xbig different after growing $xsml"
6386 log "$xbig still valid after growing $xsml"
6391 test_102h() { # bug 15777
6394 run_test 102h "grow xattr from inside inode to external block"
6397 large_xattr_enabled || { skip "large_xattr disabled" && return; }
6398 grow_xattr $(max_xattr_size)
6400 run_test 102ha "grow xattr from inside inode to external inode"
6402 test_102i() { # bug 17038
6403 [ -z "$(which getfattr 2>/dev/null)" ] &&
6404 skip "could not find getfattr" && return
6406 ln -s $DIR/$tfile $DIR/${tfile}link
6407 getfattr -n trusted.lov $DIR/$tfile ||
6408 error "lgetxattr on $DIR/$tfile failed"
6409 getfattr -h -n trusted.lov $DIR/${tfile}link 2>&1 |
6410 grep -i "no such attr" ||
6411 error "error for lgetxattr on $DIR/${tfile}link is not ENODATA"
6412 rm -f $DIR/$tfile $DIR/${tfile}link
6414 run_test 102i "lgetxattr test on symbolic link ============"
6417 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6418 TAR=$(find_lustre_tar)
6419 [ -z "$TAR" ] && skip_env "lustre-aware tar is not installed" && return
6420 [[ $OSTCOUNT -lt 2 ]] && skip_env "skipping N-stripe test" && return
6421 setup_test102 "$RUNAS"
6422 test_mkdir -p $DIR/d102j
6423 chown $RUNAS_ID $DIR/d102j
6424 $RUNAS $TAR xf $TMP/f102.tar -C $DIR/d102j --xattrs
6426 compare_stripe_info1 "$RUNAS"
6428 run_test 102j "non-root tar restore stripe info from tarfile, not keep osts ==="
6431 [ -z "$(which setfattr 2>/dev/null)" ] &&
6432 skip "could not find setfattr" && return
6434 # b22187 just check that does not crash for regular file.
6435 setfattr -n trusted.lov $DIR/$tfile
6436 # b22187 'setfattr -n trusted.lov' should work as remove LOV EA for directories
6437 local test_kdir=$DIR/d102k
6438 test_mkdir $test_kdir
6439 local default_size=`$GETSTRIPE -S $test_kdir`
6440 local default_count=`$GETSTRIPE -c $test_kdir`
6441 local default_offset=`$GETSTRIPE -i $test_kdir`
6442 $SETSTRIPE -S 65536 -i 0 -c $OSTCOUNT $test_kdir ||
6443 error 'dir setstripe failed'
6444 setfattr -n trusted.lov $test_kdir
6445 local stripe_size=`$GETSTRIPE -S $test_kdir`
6446 local stripe_count=`$GETSTRIPE -c $test_kdir`
6447 local stripe_offset=`$GETSTRIPE -i $test_kdir`
6448 [ $stripe_size -eq $default_size ] ||
6449 error "stripe size $stripe_size != $default_size"
6450 [ $stripe_count -eq $default_count ] ||
6451 error "stripe count $stripe_count != $default_count"
6452 [ $stripe_offset -eq $default_offset ] ||
6453 error "stripe offset $stripe_offset != $default_offset"
6454 rm -rf $DIR/$tfile $test_kdir
6456 run_test 102k "setfattr without parameter of value shouldn't cause a crash"
6459 [ -z "$(which getfattr 2>/dev/null)" ] &&
6460 skip "could not find getfattr" && return
6462 # LU-532 trusted. xattr is invisible to non-root
6463 local testfile=$DIR/$tfile
6467 echo "listxattr as user..."
6468 chown $RUNAS_ID $testfile
6469 $RUNAS getfattr -d -m '.*' $testfile 2>&1 |
6470 grep -q "trusted" &&
6471 error "$testfile trusted xattrs are user visible"
6475 run_test 102l "listxattr size test =================================="
6477 test_102m() { # LU-3403 llite: error of listxattr when buffer is small
6478 local path=$DIR/$tfile
6481 listxattr_size_check $path || error "listattr_size_check $path failed"
6483 run_test 102m "Ensure listxattr fails on small bufffer ========"
6487 getxattr() { # getxattr path name
6488 # Return the base64 encoding of the value of xattr name on path.
6492 # # getfattr --absolute-names --encoding=base64 --name=trusted.lov $path
6494 # trusted.lov=0s0AvRCwEAAAAGAAAAAAAAAAAEAAACAAAAAAAQAAEAA...AAAAAAAAA=
6496 # We print just 0s0AvRCwEAAAAGAAAAAAAAAAAEAAACAAAAAAAQAAEAA...AAAAAAAAA=
6498 getfattr --absolute-names --encoding=base64 --name=$name $path |
6499 awk -F= -v name=$name '$1 == name {
6500 print substr($0, index($0, "=") + 1);
6504 test_102n() { # LU-4101 mdt: protect internal xattrs
6505 local file0=$DIR/$tfile.0
6506 local file1=$DIR/$tfile.1
6507 local xattr0=$TMP/$tfile.0
6508 local xattr1=$TMP/$tfile.1
6512 [ -z "$(which setfattr 2>/dev/null)" ] &&
6513 skip "could not find setfattr" && return
6515 if [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.5.50) ]
6517 skip "MDT < 2.5.50 allows setxattr on internal trusted xattrs"
6521 rm -rf $file0 $file1 $xattr0 $xattr1
6524 # Get 'before' xattrs of $file1.
6525 getfattr --absolute-names --dump --match=- $file1 > $xattr0
6527 for name in lov lma lmv link fid version som hsm lfsck_namespace; do
6528 # Try to copy xattr from $file0 to $file1.
6529 value=$(getxattr $file0 trusted.$name 2> /dev/null)
6531 setfattr --name=trusted.$name --value="$value" $file1 ||
6532 error "setxattr 'trusted.$name' failed"
6534 # Try to set a garbage xattr.
6535 value=0sVGhlIHF1aWNrIGJyb3duIGZveCBqdW1wcyBvdmVyIGl0c2VsZi4=
6537 setfattr --name=trusted.$name --value="$value" $file1 ||
6538 error "setxattr 'trusted.$name' failed"
6540 # Try to remove the xattr from $file1. We don't care if this
6541 # appears to succeed or fail, we just don't want there to be
6542 # any changes or crashes.
6543 setfattr --remove=$trusted.$name $file1 2> /dev/null
6546 # Get 'after' xattrs of file1.
6547 getfattr --absolute-names --dump --match=- $file1 > $xattr1
6549 if ! diff $xattr0 $xattr1; then
6550 error "before and after xattrs of '$file1' differ"
6553 rm -rf $file0 $file1 $xattr0 $xattr1
6557 run_test 102n "silently ignore setxattr on internal trusted xattrs"
6561 $LUSTRE/tests/acl/run $LUSTRE/tests/acl/$1.test
6566 [ "$UID" != 0 ] && skip_env "must run as root" && return
6567 [ -z "$(lctl get_param -n mdc.*-mdc-*.connect_flags | grep acl)" ] &&
6568 skip "must have acl enabled" && return
6569 [ -z "$(which setfacl 2>/dev/null)" ] &&
6570 skip_env "could not find setfacl" && return
6571 $GSS && skip "could not run under gss" && return
6573 declare -a identity_old
6575 for num in $(seq $MDSCOUNT); do
6576 switch_identity $num true || identity_old[$num]=$?
6583 echo "performing cp ..."
6584 run_acl_subtest cp || error "run_acl_subtest cp failed"
6585 echo "performing getfacl-noacl..."
6586 run_acl_subtest getfacl-noacl || error "getfacl-noacl test failed"
6587 echo "performing misc..."
6588 run_acl_subtest misc || error "misc test failed"
6589 echo "performing permissions..."
6590 run_acl_subtest permissions || error "permissions failed"
6591 echo "performing setfacl..."
6592 run_acl_subtest setfacl || error "setfacl test failed"
6594 # inheritance test got from HP
6595 echo "performing inheritance..."
6596 cp $LUSTRE/tests/acl/make-tree . || error "cannot copy make-tree"
6597 chmod +x make-tree || error "chmod +x failed"
6598 run_acl_subtest inheritance || error "inheritance test failed"
6601 echo "LU-974 ignore umask when acl is enabled..."
6602 run_acl_subtest 974 || error "LU-974 umask test failed"
6603 if [ $MDSCOUNT -ge 2 ]; then
6604 run_acl_subtest 974_remote ||
6605 error "LU-974 umask test failed under remote dir"
6608 echo "LU-2561 newly created file is same size as directory..."
6609 if [ $(facet_fstype $SINGLEMDS) != "zfs" ]; then
6610 run_acl_subtest 2561 || error "LU-2561 test failed"
6612 run_acl_subtest 2561_zfs || error "LU-2561 zfs test failed"
6615 run_acl_subtest 4924 || error "LU-4924 test failed"
6620 for num in $(seq $MDSCOUNT); do
6621 if [ "${identity_old[$num]}" = 1 ]; then
6622 switch_identity $num false || identity_old[$num]=$?
6626 run_test 103 "acl test ========================================="
6629 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6631 lfs df || error "lfs df failed"
6632 lfs df -ih || error "lfs df -ih failed"
6633 lfs df -h $DIR || error "lfs df -h $DIR failed"
6634 lfs df -i $DIR || error "lfs df -i $DIR failed"
6635 lfs df $DIR/$tfile || error "lfs df $DIR/$tfile failed"
6636 lfs df -ih $DIR/$tfile || error "lfs df -ih $DIR/$tfile failed"
6638 local OSC=$(lctl dl | grep OST0000-osc-[^M] | awk '{ print $4 }')
6639 lctl --device %$OSC deactivate
6640 lfs df || error "lfs df with deactivated OSC failed"
6641 lctl --device %$OSC activate
6642 # wait the osc back to normal
6643 wait_osc_import_state client ost FULL
6645 lfs df || error "lfs df with reactivated OSC failed"
6648 run_test 104a "lfs df [-ih] [path] test ========================="
6651 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6652 [ $RUNAS_ID -eq $UID ] &&
6653 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
6655 denied_cnt=$(($($RUNAS $LFS check servers 2>&1 |
6656 grep "Permission denied" | wc -l)))
6657 if [ $denied_cnt -ne 0 ]; then
6658 error "lfs check servers test failed"
6661 run_test 104b "$RUNAS lfs check servers test ===================="
6664 # doesn't work on 2.4 kernels
6666 if [ -n "$(mount | grep "$MOUNT.*flock" | grep -v noflock)" ]; then
6667 flocks_test 1 on -f $DIR/$tfile || error "fail flock on"
6669 flocks_test 1 off -f $DIR/$tfile || error "fail flock off"
6673 run_test 105a "flock when mounted without -o flock test ========"
6677 if [ -n "$(mount | grep "$MOUNT.*flock" | grep -v noflock)" ]; then
6678 flocks_test 1 on -c $DIR/$tfile || error "fail flock on"
6680 flocks_test 1 off -c $DIR/$tfile || error "fail flock off"
6684 run_test 105b "fcntl when mounted without -o flock test ========"
6688 if [ -n "$(mount | grep "$MOUNT.*flock" | grep -v noflock)" ]; then
6689 flocks_test 1 on -l $DIR/$tfile || error "fail flock on"
6691 flocks_test 1 off -l $DIR/$tfile || error "fail flock off"
6695 run_test 105c "lockf when mounted without -o flock test ========"
6697 test_105d() { # bug 15924
6698 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6699 test_mkdir -p $DIR/$tdir
6700 [ -z "$(mount | grep "$MOUNT.*flock" | grep -v noflock)" ] &&
6701 skip "mount w/o flock enabled" && return
6702 #define OBD_FAIL_LDLM_CP_CB_WAIT 0x315
6703 $LCTL set_param fail_loc=0x80000315
6704 flocks_test 2 $DIR/$tdir
6706 run_test 105d "flock race (should not freeze) ========"
6708 test_105e() { # bug 22660 && 22040
6709 [ -z "$(mount | grep "$MOUNT.*flock" | grep -v noflock)" ] &&
6710 skip "mount w/o flock enabled" && return
6712 flocks_test 3 $DIR/$tfile
6714 run_test 105e "Two conflicting flocks from same process ======="
6716 test_106() { #bug 10921
6717 test_mkdir -p $DIR/$tdir
6718 $DIR/$tdir && error "exec $DIR/$tdir succeeded"
6719 chmod 777 $DIR/$tdir || error "chmod $DIR/$tdir failed"
6721 run_test 106 "attempt exec of dir followed by chown of that dir"
6724 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6731 local save_pattern=$(sysctl -n kernel.core_pattern)
6732 local save_uses_pid=$(sysctl -n kernel.core_uses_pid)
6733 sysctl -w kernel.core_pattern=$file
6734 sysctl -w kernel.core_uses_pid=0
6742 kill -s 11 $SLEEPPID
6744 if [ -e $file ]; then
6745 size=`stat -c%s $file`
6746 [ $size -eq 0 ] && error "Fail to create core file $file"
6748 error "Fail to create core file $file"
6751 sysctl -w kernel.core_pattern=$save_pattern
6752 sysctl -w kernel.core_uses_pid=$save_uses_pid
6755 run_test 107 "Coredump on SIG"
6758 test_mkdir -p $DIR/$tdir
6759 test_mkdir $DIR/$tdir/$(str_repeat 'a' 255) ||
6760 error "mkdir with 255 char failed"
6761 test_mkdir $DIR/$tdir/$(str_repeat 'b' 256) &&
6762 error "mkdir with 256 char should fail, but did not"
6763 touch $DIR/$tdir/$(str_repeat 'x' 255) ||
6764 error "create with 255 char failed"
6765 touch $DIR/$tdir/$(str_repeat 'y' 256) &&
6766 error "create with 256 char should fail, but did not"
6771 run_test 110 "filename length checking"
6774 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6775 OSTIO_pre=$(ps -e | grep ll_ost_io | awk '{ print $4 }'| sort -n |
6776 tail -1 | cut -c11-20)
6777 [ -z "$OSTIO_pre" ] && skip "no OSS threads" && return
6778 echo "Starting with $OSTIO_pre threads"
6781 NUMFREE=$(df -i -P $DIR | tail -n 1 | awk '{ print $4 }')
6782 [[ $NUMFREE -lt $NUMTEST ]] && NUMTEST=$(($NUMFREE - 1000))
6783 echo "$NUMTEST creates/unlinks"
6784 test_mkdir -p $DIR/$tdir
6785 createmany -o $DIR/$tdir/$tfile $NUMTEST
6786 unlinkmany $DIR/$tdir/$tfile $NUMTEST
6788 OSTIO_post=$(ps -e | grep ll_ost_io | awk '{ print $4 }' | sort -n |
6789 tail -1 | cut -c11-20)
6791 # don't return an error
6792 [ $OSTIO_post == $OSTIO_pre ] && echo \
6793 "WARNING: No new ll_ost_io threads were created ($OSTIO_pre)" &&
6794 echo "This may be fine, depending on what ran before this test" &&
6795 echo "and how fast this system is." && return
6797 echo "Started with $OSTIO_pre threads, ended with $OSTIO_post"
6799 run_test 115 "verify dynamic thread creation===================="
6802 wait_delete_completed
6803 AVAIL=($(lctl get_param -n osc.*[oO][sS][cC]-[^M]*.kbytesavail))
6804 echo OST kbytes available: ${AVAIL[@]}
6805 MAXI=0; MAXV=${AVAIL[0]}
6806 MINI=0; MINV=${AVAIL[0]}
6807 for ((i = 0; i < ${#AVAIL[@]}; i++)); do
6808 #echo OST $i: ${AVAIL[i]}kb
6809 if [[ ${AVAIL[i]} -gt $MAXV ]]; then
6810 MAXV=${AVAIL[i]}; MAXI=$i
6812 if [[ ${AVAIL[i]} -lt $MINV ]]; then
6813 MINV=${AVAIL[i]}; MINI=$i
6816 echo Min free space: OST $MINI: $MINV
6817 echo Max free space: OST $MAXI: $MAXV
6820 test_116a() { # was previously test_116()
6821 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6822 [[ $OSTCOUNT -lt 2 ]] && skip_env "$OSTCOUNT < 2 OSTs" && return
6824 echo -n "Free space priority "
6825 do_facet $SINGLEMDS lctl get_param -n lo*.*-mdtlov.qos_prio_free |
6830 [ $MINV -eq 0 ] && skip "no free space in OST$MINI, skip" && return
6831 trap simple_cleanup_common EXIT
6833 # Check if we need to generate uneven OSTs
6834 test_mkdir -p $DIR/$tdir/OST${MINI}
6835 local FILL=$(($MINV / 4))
6836 local DIFF=$(($MAXV - $MINV))
6837 local DIFF2=$(($DIFF * 100 / $MINV))
6839 local threshold=$(do_facet $SINGLEMDS \
6840 lctl get_param -n *.*MDT0000-mdtlov.qos_threshold_rr | head -n1)
6841 threshold=${threshold%%%}
6842 echo -n "Check for uneven OSTs: "
6843 echo -n "diff=${DIFF}KB (${DIFF2}%) must be > ${threshold}% ..."
6845 if [[ $DIFF2 -gt $threshold ]]; then
6847 echo "Don't need to fill OST$MINI"
6849 # generate uneven OSTs. Write 2% over the QOS threshold value
6851 DIFF=$(($threshold - $DIFF2 + 2))
6852 DIFF2=$(( ($MINV * $DIFF)/100 ))
6853 echo "Fill ${DIFF}% remaining space in OST${MINI} with ${DIFF2}KB"
6854 $SETSTRIPE -i $MINI -c 1 $DIR/$tdir/OST${MINI} ||
6855 error "setstripe failed"
6856 DIFF=$(($DIFF2 / 2048))
6858 while [ $i -lt $DIFF ]; do
6860 dd if=/dev/zero of=$DIR/$tdir/OST${MINI}/$tfile-$i \
6861 bs=2M count=1 2>/dev/null
6870 DIFF=$(($MAXV - $MINV))
6871 DIFF2=$(($DIFF * 100 / $MINV))
6872 echo -n "diff=${DIFF}=${DIFF2}% must be > ${threshold}% for QOS mode..."
6873 if [[ $DIFF2 -gt $threshold ]]; then
6876 echo "failed - QOS mode won't be used"
6877 error_ignore 0000 "QOS imbalance criteria not met"
6878 simple_cleanup_common
6882 MINI1=$MINI; MINV1=$MINV
6883 MAXI1=$MAXI; MAXV1=$MAXV
6885 # now fill using QOS
6886 $SETSTRIPE -c 1 $DIR/$tdir
6887 FILL=$(($FILL / 200))
6888 if [ $FILL -gt 600 ]; then
6891 echo "writing $FILL files to QOS-assigned OSTs"
6893 while [ $i -lt $FILL ]; do
6895 dd if=/dev/zero of=$DIR/$tdir/$tfile-$i bs=200k \
6899 echo "wrote $i 200k files"
6903 echo "Note: free space may not be updated, so measurements might be off"
6905 DIFF2=$(($MAXV - $MINV))
6906 echo "free space delta: orig $DIFF final $DIFF2"
6907 [ $DIFF2 -gt $DIFF ] && echo "delta got worse!"
6908 DIFF=$(($MINV1 - ${AVAIL[$MINI1]}))
6909 echo "Wrote ${DIFF}KB to smaller OST $MINI1"
6910 DIFF2=$(($MAXV1 - ${AVAIL[$MAXI1]}))
6911 echo "Wrote ${DIFF2}KB to larger OST $MAXI1"
6912 FILL=$(($DIFF2 * 100 / $DIFF - 100))
6914 echo "Wrote ${FILL}% more data to larger OST $MAXI1"
6916 # Figure out which files were written where
6917 UUID=$(lctl get_param -n lov.${FSNAME}-clilov-*.target_obd |
6918 awk '/'$MINI1': / {print $2; exit}')
6920 MINC=$($GETSTRIPE --ost $UUID $DIR/$tdir | grep $DIR | wc -l)
6921 echo "$MINC files created on smaller OST $MINI1"
6922 UUID=$(lctl get_param -n lov.${FSNAME}-clilov-*.target_obd |
6923 awk '/'$MAXI1': / {print $2; exit}')
6925 MAXC=$($GETSTRIPE --ost $UUID $DIR/$tdir | grep $DIR | wc -l)
6926 echo "$MAXC files created on larger OST $MAXI1"
6927 FILL=$(($MAXC * 100 / $MINC - 100))
6928 [[ $MINC -gt 0 ]] &&
6929 echo "Wrote ${FILL}% more files to larger OST $MAXI1"
6930 [[ $MAXC -gt $MINC ]] ||
6931 error_ignore LU-9 "stripe QOS didn't balance free space"
6932 simple_cleanup_common
6934 run_test 116a "stripe QOS: free space balance ==================="
6936 test_116b() { # LU-2093
6937 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6938 [ -z "$($LCTL get_param -n lo*.$FSNAME-MDT0000-mdtlov.qos_threshold_rr |
6939 head -1 2>/dev/null)" ] && skip "no QOS" && return
6940 #define OBD_FAIL_MDS_OSC_CREATE_FAIL 0x147
6942 old_rr=$(do_facet $SINGLEMDS lctl get_param -n \
6943 lo*.$FSNAME-MDT0000-mdtlov.qos_threshold_rr | head -1)
6944 do_facet $SINGLEMDS lctl set_param \
6945 lo*.$FSNAME-MDT0000-mdtlov.qos_threshold_rr=0
6947 do_facet $SINGLEMDS lctl set_param fail_loc=0x147
6948 createmany -o $DIR/$tdir/f- 20 || error "can't create"
6949 do_facet $SINGLEMDS lctl set_param fail_loc=0
6951 do_facet $SINGLEMDS lctl set_param \
6952 lo*.$FSNAME-MDT0000-mdtlov.qos_threshold_rr=$old_rr
6954 run_test 116b "QoS shouldn't LBUG if not enough OSTs found on the 2nd pass"
6956 test_117() # bug 10891
6958 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6959 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1
6960 #define OBD_FAIL_OST_SETATTR_CREDITS 0x21e
6961 lctl set_param fail_loc=0x21e
6962 > $DIR/$tfile || error "truncate failed"
6963 lctl set_param fail_loc=0
6964 echo "Truncate succeeded."
6967 run_test 117 "verify fsfilt_extend =========="
6969 NO_SLOW_RESENDCOUNT=4
6970 export OLD_RESENDCOUNT=""
6971 set_resend_count () {
6972 local PROC_RESENDCOUNT="osc.${FSNAME}-OST*-osc-*.resend_count"
6973 OLD_RESENDCOUNT=$(lctl get_param -n $PROC_RESENDCOUNT | head -n1)
6974 lctl set_param -n $PROC_RESENDCOUNT $1
6975 echo resend_count is set to $(lctl get_param -n $PROC_RESENDCOUNT)
6978 # for reduce test_118* time (b=14842)
6979 [ "$SLOW" = "no" ] && set_resend_count $NO_SLOW_RESENDCOUNT
6981 # Reset async IO behavior after error case
6983 FILE=$DIR/reset_async
6985 # Ensure all OSCs are cleared
6986 $SETSTRIPE -c -1 $FILE
6987 dd if=/dev/zero of=$FILE bs=64k count=$OSTCOUNT
6992 test_118a() #bug 11710
6994 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6997 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
6998 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
6999 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
7001 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
7002 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
7007 run_test 118a "verify O_SYNC works =========="
7011 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7012 remote_ost_nodsh && skip "remote OST with nodsh" && return
7016 #define OBD_FAIL_OST_ENOENT 0x217
7017 set_nodes_failloc "$(osts_nodes)" 0x217
7018 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
7020 set_nodes_failloc "$(osts_nodes)" 0
7021 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
7022 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
7025 if [[ $RC -eq 0 ]]; then
7026 error "Must return error due to dropped pages, rc=$RC"
7030 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
7031 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
7035 echo "Dirty pages not leaked on ENOENT"
7037 # Due to the above error the OSC will issue all RPCs syncronously
7038 # until a subsequent RPC completes successfully without error.
7039 $MULTIOP $DIR/$tfile Ow4096yc
7044 run_test 118b "Reclaim dirty pages on fatal error =========="
7048 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7050 # for 118c, restore the original resend count, LU-1940
7051 [ "$SLOW" = "no" ] && [ -n "$OLD_RESENDCOUNT" ] &&
7052 set_resend_count $OLD_RESENDCOUNT
7053 remote_ost_nodsh && skip "remote OST with nodsh" && return
7057 #define OBD_FAIL_OST_EROFS 0x216
7058 set_nodes_failloc "$(osts_nodes)" 0x216
7060 # multiop should block due to fsync until pages are written
7061 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
7065 if [[ `ps h -o comm -p $MULTIPID` != "multiop" ]]; then
7066 error "Multiop failed to block on fsync, pid=$MULTIPID"
7069 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
7071 if [[ $WRITEBACK -eq 0 ]]; then
7072 error "No page in writeback, writeback=$WRITEBACK"
7075 set_nodes_failloc "$(osts_nodes)" 0
7078 if [[ $RC -ne 0 ]]; then
7079 error "Multiop fsync failed, rc=$RC"
7082 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
7083 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
7085 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
7086 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
7090 echo "Dirty pages flushed via fsync on EROFS"
7093 run_test 118c "Fsync blocks on EROFS until dirty pages are flushed =========="
7095 # continue to use small resend count to reduce test_118* time (b=14842)
7096 [ "$SLOW" = "no" ] && set_resend_count $NO_SLOW_RESENDCOUNT
7100 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7101 remote_ost_nodsh && skip "remote OST with nodsh" && return
7105 #define OBD_FAIL_OST_BRW_PAUSE_BULK
7106 set_nodes_failloc "$(osts_nodes)" 0x214
7107 # multiop should block due to fsync until pages are written
7108 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
7112 if [[ `ps h -o comm -p $MULTIPID` != "multiop" ]]; then
7113 error "Multiop failed to block on fsync, pid=$MULTIPID"
7116 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
7118 if [[ $WRITEBACK -eq 0 ]]; then
7119 error "No page in writeback, writeback=$WRITEBACK"
7122 wait $MULTIPID || error "Multiop fsync failed, rc=$?"
7123 set_nodes_failloc "$(osts_nodes)" 0
7125 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
7126 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
7128 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
7129 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
7133 echo "Dirty pages gaurenteed flushed via fsync"
7136 run_test 118d "Fsync validation inject a delay of the bulk =========="
7139 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7142 #define OBD_FAIL_OSC_BRW_PREP_REQ2 0x40a
7143 lctl set_param fail_loc=0x8000040a
7145 # Should simulate EINVAL error which is fatal
7146 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
7148 if [[ $RC -eq 0 ]]; then
7149 error "Must return error due to dropped pages, rc=$RC"
7152 lctl set_param fail_loc=0x0
7154 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
7155 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
7156 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
7158 if [[ $LOCKED -ne 0 ]]; then
7159 error "Locked pages remain in cache, locked=$LOCKED"
7162 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
7163 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
7167 echo "No pages locked after fsync"
7172 run_test 118f "Simulate unrecoverable OSC side error =========="
7175 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7178 #define OBD_FAIL_OSC_BRW_PREP_REQ 0x406
7179 lctl set_param fail_loc=0x406
7181 # simulate local -ENOMEM
7182 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
7185 lctl set_param fail_loc=0
7186 if [[ $RC -eq 0 ]]; then
7187 error "Must return error due to dropped pages, rc=$RC"
7190 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
7191 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
7192 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
7194 if [[ $LOCKED -ne 0 ]]; then
7195 error "Locked pages remain in cache, locked=$LOCKED"
7198 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
7199 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
7203 echo "No pages locked after fsync"
7208 run_test 118g "Don't stay in wait if we got local -ENOMEM =========="
7211 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7212 remote_ost_nodsh && skip "remote OST with nodsh" && return
7216 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
7217 set_nodes_failloc "$(osts_nodes)" 0x20e
7218 # Should simulate ENOMEM error which is recoverable and should be handled by timeout
7219 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
7222 set_nodes_failloc "$(osts_nodes)" 0
7223 if [[ $RC -eq 0 ]]; then
7224 error "Must return error due to dropped pages, rc=$RC"
7227 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
7228 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
7229 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
7231 if [[ $LOCKED -ne 0 ]]; then
7232 error "Locked pages remain in cache, locked=$LOCKED"
7235 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
7236 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
7240 echo "No pages locked after fsync"
7244 run_test 118h "Verify timeout in handling recoverables errors =========="
7246 [ "$SLOW" = "no" ] && [ -n "$OLD_RESENDCOUNT" ] && set_resend_count $OLD_RESENDCOUNT
7249 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7250 remote_ost_nodsh && skip "remote OST with nodsh" && return
7254 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
7255 set_nodes_failloc "$(osts_nodes)" 0x20e
7257 # Should simulate ENOMEM error which is recoverable and should be handled by timeout
7258 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
7261 set_nodes_failloc "$(osts_nodes)" 0
7265 if [[ $RC -ne 0 ]]; then
7266 error "got error, but should be not, rc=$RC"
7269 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
7270 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
7271 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
7272 if [[ $LOCKED -ne 0 ]]; then
7273 error "Locked pages remain in cache, locked=$LOCKED"
7276 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
7277 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
7281 echo "No pages locked after fsync"
7285 run_test 118i "Fix error before timeout in recoverable error =========="
7287 [ "$SLOW" = "no" ] && set_resend_count 4
7290 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7291 remote_ost_nodsh && skip "remote OST with nodsh" && return
7295 #define OBD_FAIL_OST_BRW_WRITE_BULK2 0x220
7296 set_nodes_failloc "$(osts_nodes)" 0x220
7298 # return -EIO from OST
7299 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
7301 set_nodes_failloc "$(osts_nodes)" 0x0
7302 if [[ $RC -eq 0 ]]; then
7303 error "Must return error due to dropped pages, rc=$RC"
7306 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
7307 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
7308 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
7309 if [[ $LOCKED -ne 0 ]]; then
7310 error "Locked pages remain in cache, locked=$LOCKED"
7313 # in recoverable error on OST we want resend and stay until it finished
7314 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
7315 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
7319 echo "No pages locked after fsync"
7323 run_test 118j "Simulate unrecoverable OST side error =========="
7327 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7328 remote_ost_nodsh && skip "remote OSTs with nodsh" && return
7330 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
7331 set_nodes_failloc "$(osts_nodes)" 0x20e
7332 test_mkdir -p $DIR/$tdir
7334 for ((i=0;i<10;i++)); do
7335 (dd if=/dev/zero of=$DIR/$tdir/$tfile-$i bs=1M count=10 || \
7336 error "dd to $DIR/$tdir/$tfile-$i failed" )&
7343 set_nodes_failloc "$(osts_nodes)" 0
7346 run_test 118k "bio alloc -ENOMEM and IO TERM handling ========="
7350 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7352 test_mkdir -p $DIR/$tdir
7353 $MULTIOP $DIR/$tdir Dy || error "fsync dir failed"
7356 run_test 118l "fsync dir ========="
7358 test_118m() # LU-3066
7360 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7361 test_mkdir -p $DIR/$tdir
7362 $MULTIOP $DIR/$tdir DY || error "fdatasync dir failed"
7365 run_test 118m "fdatasync dir ========="
7367 [ "$SLOW" = "no" ] && [ -n "$OLD_RESENDCOUNT" ] && set_resend_count $OLD_RESENDCOUNT
7369 test_119a() # bug 11737
7371 BSIZE=$((512 * 1024))
7372 directio write $DIR/$tfile 0 1 $BSIZE
7373 # We ask to read two blocks, which is more than a file size.
7374 # directio will indicate an error when requested and actual
7375 # sizes aren't equeal (a normal situation in this case) and
7376 # print actual read amount.
7377 NOB=`directio read $DIR/$tfile 0 2 $BSIZE | awk '/error/ {print $6}'`
7378 if [ "$NOB" != "$BSIZE" ]; then
7379 error "read $NOB bytes instead of $BSIZE"
7383 run_test 119a "Short directIO read must return actual read amount"
7385 test_119b() # bug 11737
7387 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping 2-stripe test" && return
7389 $SETSTRIPE -c 2 $DIR/$tfile || error "setstripe failed"
7390 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=1 || error "dd failed"
7392 $MULTIOP $DIR/$tfile oO_RDONLY:O_DIRECT:r$((2048 * 1024)) || \
7393 error "direct read failed"
7396 run_test 119b "Sparse directIO read must return actual read amount"
7398 test_119c() # bug 13099
7401 directio write $DIR/$tfile 3 1 $BSIZE || error "direct write failed"
7402 directio readhole $DIR/$tfile 0 2 $BSIZE || error "reading hole failed"
7405 run_test 119c "Testing for direct read hitting hole"
7407 test_119d() # bug 15950
7409 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7410 MAX_RPCS_IN_FLIGHT=`$LCTL get_param -n osc.*OST0000-osc-[^mM]*.max_rpcs_in_flight`
7411 $LCTL set_param -n osc.*OST0000-osc-[^mM]*.max_rpcs_in_flight 1
7413 $SETSTRIPE $DIR/$tfile -i 0 -c 1 || error "setstripe failed"
7414 $DIRECTIO write $DIR/$tfile 0 1 $BSIZE || error "first directio failed"
7415 #define OBD_FAIL_OSC_DIO_PAUSE 0x40d
7416 lctl set_param fail_loc=0x40d
7417 $DIRECTIO write $DIR/$tfile 1 4 $BSIZE &
7420 cat $DIR/$tfile > /dev/null &
7421 lctl set_param fail_loc=0
7424 log "the DIO writes have completed, now wait for the reads (should not block very long)"
7426 [ -n "`ps h -p $pid_reads -o comm`" ] && \
7427 error "the read rpcs have not completed in 2s"
7429 $LCTL set_param -n osc.*OST0000-osc-[^mM]*.max_rpcs_in_flight $MAX_RPCS_IN_FLIGHT
7431 run_test 119d "The DIO path should try to send a new rpc once one is completed"
7434 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7435 test_mkdir -p $DIR/$tdir
7436 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
7437 skip "no early lock cancel on server" && return 0
7439 lru_resize_disable mdc
7440 lru_resize_disable osc
7441 cancel_lru_locks mdc
7442 # asynchronous object destroy at MDT could cause bl ast to client
7443 cancel_lru_locks osc
7445 stat $DIR/$tdir > /dev/null
7446 can1=`lctl get_param -n ldlm.services.ldlm_canceld.stats | awk '/ldlm_cancel/ {print $2}'`
7447 blk1=`lctl get_param -n ldlm.services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
7448 test_mkdir $DIR/$tdir/d1
7449 can2=`lctl get_param -n ldlm.services.ldlm_canceld.stats | awk '/ldlm_cancel/ {print $2}'`
7450 blk2=`lctl get_param -n ldlm.services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
7451 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
7452 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
7453 lru_resize_enable mdc
7454 lru_resize_enable osc
7456 run_test 120a "Early Lock Cancel: mkdir test"
7459 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7460 test_mkdir -p $DIR/$tdir
7461 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
7462 skip "no early lock cancel on server" && return 0
7463 lru_resize_disable mdc
7464 lru_resize_disable osc
7465 cancel_lru_locks mdc
7466 stat $DIR/$tdir > /dev/null
7467 can1=`lctl get_param -n ldlm.services.ldlm_canceld.stats | awk '/ldlm_cancel/ {print $2}'`
7468 blk1=`lctl get_param -n ldlm.services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
7470 can2=`lctl get_param -n ldlm.services.ldlm_canceld.stats | awk '/ldlm_cancel/ {print $2}'`
7471 blk2=`lctl get_param -n ldlm.services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
7472 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
7473 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
7474 lru_resize_enable mdc
7475 lru_resize_enable osc
7477 run_test 120b "Early Lock Cancel: create test"
7480 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7481 test_mkdir -p $DIR/$tdir
7482 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
7483 skip "no early lock cancel on server" && return 0
7484 lru_resize_disable mdc
7485 lru_resize_disable osc
7486 test_mkdir -p $DIR/$tdir/d1
7487 test_mkdir -p $DIR/$tdir/d2
7488 touch $DIR/$tdir/d1/f1
7489 cancel_lru_locks mdc
7490 stat $DIR/$tdir/d1 $DIR/$tdir/d2 $DIR/$tdir/d1/f1 > /dev/null
7491 can1=`lctl get_param -n ldlm.services.ldlm_canceld.stats | awk '/ldlm_cancel/ {print $2}'`
7492 blk1=`lctl get_param -n ldlm.services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
7493 ln $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2
7494 can2=`lctl get_param -n ldlm.services.ldlm_canceld.stats | awk '/ldlm_cancel/ {print $2}'`
7495 blk2=`lctl get_param -n ldlm.services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
7496 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
7497 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
7498 lru_resize_enable mdc
7499 lru_resize_enable osc
7501 run_test 120c "Early Lock Cancel: link test"
7504 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7505 test_mkdir -p $DIR/$tdir
7506 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
7507 skip "no early lock cancel on server" && return 0
7508 lru_resize_disable mdc
7509 lru_resize_disable osc
7511 cancel_lru_locks mdc
7512 stat $DIR/$tdir > /dev/null
7513 can1=`lctl get_param -n ldlm.services.ldlm_canceld.stats | awk '/ldlm_cancel/ {print $2}'`
7514 blk1=`lctl get_param -n ldlm.services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
7515 chmod a+x $DIR/$tdir
7516 can2=`lctl get_param -n ldlm.services.ldlm_canceld.stats | awk '/ldlm_cancel/ {print $2}'`
7517 blk2=`lctl get_param -n ldlm.services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
7518 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
7519 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
7520 lru_resize_enable mdc
7521 lru_resize_enable osc
7523 run_test 120d "Early Lock Cancel: setattr test"
7526 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7527 test_mkdir -p $DIR/$tdir
7528 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
7529 skip "no early lock cancel on server" && return 0
7530 lru_resize_disable mdc
7531 lru_resize_disable osc
7532 dd if=/dev/zero of=$DIR/$tdir/f1 count=1
7533 cancel_lru_locks mdc
7534 cancel_lru_locks osc
7535 dd if=$DIR/$tdir/f1 of=/dev/null
7536 stat $DIR/$tdir $DIR/$tdir/f1 > /dev/null
7537 can1=`lctl get_param -n ldlm.services.ldlm_canceld.stats |
7538 awk '/ldlm_cancel/ {print $2}'`
7539 blk1=`lctl get_param -n ldlm.services.ldlm_cbd.stats |
7540 awk '/ldlm_bl_callback/ {print $2}'`
7541 unlink $DIR/$tdir/f1
7542 can2=`lctl get_param -n ldlm.services.ldlm_canceld.stats |
7543 awk '/ldlm_cancel/ {print $2}'`
7544 blk2=`lctl get_param -n ldlm.services.ldlm_cbd.stats |
7545 awk '/ldlm_bl_callback/ {print $2}'`
7546 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
7547 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
7548 lru_resize_enable mdc
7549 lru_resize_enable osc
7551 run_test 120e "Early Lock Cancel: unlink test"
7554 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7555 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
7556 skip "no early lock cancel on server" && return 0
7557 test_mkdir -p $DIR/$tdir
7558 lru_resize_disable mdc
7559 lru_resize_disable osc
7560 test_mkdir -p $DIR/$tdir/d1
7561 test_mkdir -p $DIR/$tdir/d2
7562 dd if=/dev/zero of=$DIR/$tdir/d1/f1 count=1
7563 dd if=/dev/zero of=$DIR/$tdir/d2/f2 count=1
7564 cancel_lru_locks mdc
7565 cancel_lru_locks osc
7566 dd if=$DIR/$tdir/d1/f1 of=/dev/null
7567 dd if=$DIR/$tdir/d2/f2 of=/dev/null
7568 stat $DIR/$tdir/d1 $DIR/$tdir/d2 $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2 > /dev/null
7569 can1=`lctl get_param -n ldlm.services.ldlm_canceld.stats |
7570 awk '/ldlm_cancel/ {print $2}'`
7571 blk1=`lctl get_param -n ldlm.services.ldlm_cbd.stats |
7572 awk '/ldlm_bl_callback/ {print $2}'`
7573 mv $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2
7574 can2=`lctl get_param -n ldlm.services.ldlm_canceld.stats |
7575 awk '/ldlm_cancel/ {print $2}'`
7576 blk2=`lctl get_param -n ldlm.services.ldlm_cbd.stats |
7577 awk '/ldlm_bl_callback/ {print $2}'`
7578 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
7579 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
7580 lru_resize_enable mdc
7581 lru_resize_enable osc
7583 run_test 120f "Early Lock Cancel: rename test"
7586 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7587 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
7588 skip "no early lock cancel on server" && return 0
7589 lru_resize_disable mdc
7590 lru_resize_disable osc
7592 echo create $count files
7593 test_mkdir -p $DIR/$tdir
7594 cancel_lru_locks mdc
7595 cancel_lru_locks osc
7598 can0=`lctl get_param -n ldlm.services.ldlm_canceld.stats |
7599 awk '/ldlm_cancel/ {print $2}'`
7600 blk0=`lctl get_param -n ldlm.services.ldlm_cbd.stats |
7601 awk '/ldlm_bl_callback/ {print $2}'`
7602 createmany -o $DIR/$tdir/f $count
7604 can1=`lctl get_param -n ldlm.services.ldlm_canceld.stats |
7605 awk '/ldlm_cancel/ {print $2}'`
7606 blk1=`lctl get_param -n ldlm.services.ldlm_cbd.stats |
7607 awk '/ldlm_bl_callback/ {print $2}'`
7609 echo total: $((can1-can0)) cancels, $((blk1-blk0)) blockings
7610 echo rm $count files
7613 can2=`lctl get_param -n ldlm.services.ldlm_canceld.stats |
7614 awk '/ldlm_cancel/ {print $2}'`
7615 blk2=`lctl get_param -n ldlm.services.ldlm_cbd.stats |
7616 awk '/ldlm_bl_callback/ {print $2}'`
7618 echo total: $count removes in $((t2-t1))
7619 echo total: $((can2-can1)) cancels, $((blk2-blk1)) blockings
7621 # wait for commitment of removal
7622 lru_resize_enable mdc
7623 lru_resize_enable osc
7625 run_test 120g "Early Lock Cancel: performance test"
7627 test_121() { #bug #10589
7628 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7630 writes=$(LANG=C dd if=/dev/zero of=$DIR/$tfile count=1 2>&1 | awk -F '+' '/out$/ {print $1}')
7631 #define OBD_FAIL_LDLM_CANCEL_RACE 0x310
7632 lctl set_param fail_loc=0x310
7633 cancel_lru_locks osc > /dev/null
7634 reads=$(LANG=C dd if=$DIR/$tfile of=/dev/null 2>&1 | awk -F '+' '/in$/ {print $1}')
7635 lctl set_param fail_loc=0
7636 [[ $reads -eq $writes ]] ||
7637 error "read $reads blocks, must be $writes blocks"
7639 run_test 121 "read cancel race ========="
7641 test_123a() { # was test 123, statahead(bug 11401)
7642 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7644 if [ -z "$(grep "processor.*: 1" /proc/cpuinfo)" ]; then
7645 log "testing on UP system. Performance may be not as good as expected."
7650 test_mkdir -p $DIR/$tdir
7651 NUMFREE=$(df -i -P $DIR | tail -n 1 | awk '{ print $4 }')
7652 [[ $NUMFREE -gt 100000 ]] && NUMFREE=100000 || NUMFREE=$((NUMFREE-1000))
7654 for ((i=100, j=0; i<=$NUMFREE; j=$i, i=$((i * MULT)) )); do
7655 createmany -o $DIR/$tdir/$tfile $j $((i - j))
7657 max=`lctl get_param -n llite.*.statahead_max | head -n 1`
7658 lctl set_param -n llite.*.statahead_max 0
7659 lctl get_param llite.*.statahead_max
7660 cancel_lru_locks mdc
7661 cancel_lru_locks osc
7663 time ls -l $DIR/$tdir | wc -l
7665 delta=$((etime - stime))
7666 log "ls $i files without statahead: $delta sec"
7667 lctl set_param llite.*.statahead_max=$max
7669 swrong=`lctl get_param -n llite.*.statahead_stats | grep "statahead wrong:" | awk '{print $3}'`
7670 lctl get_param -n llite.*.statahead_max | grep '[0-9]'
7671 cancel_lru_locks mdc
7672 cancel_lru_locks osc
7674 time ls -l $DIR/$tdir | wc -l
7676 delta_sa=$((etime - stime))
7677 log "ls $i files with statahead: $delta_sa sec"
7678 lctl get_param -n llite.*.statahead_stats
7679 ewrong=`lctl get_param -n llite.*.statahead_stats | grep "statahead wrong:" | awk '{print $3}'`
7681 [[ $swrong -lt $ewrong ]] &&
7682 log "statahead was stopped, maybe too many locks held!"
7683 [[ $delta -eq 0 || $delta_sa -eq 0 ]] && continue
7685 if [ $((delta_sa * 100)) -gt $((delta * 105)) -a $delta_sa -gt $((delta + 2)) ]; then
7686 max=`lctl get_param -n llite.*.statahead_max | head -n 1`
7687 lctl set_param -n llite.*.statahead_max 0
7688 lctl get_param llite.*.statahead_max
7689 cancel_lru_locks mdc
7690 cancel_lru_locks osc
7692 time ls -l $DIR/$tdir | wc -l
7694 delta=$((etime - stime))
7695 log "ls $i files again without statahead: $delta sec"
7696 lctl set_param llite.*.statahead_max=$max
7697 if [ $((delta_sa * 100)) -gt $((delta * 105)) -a $delta_sa -gt $((delta + 2)) ]; then
7698 if [ $SLOWOK -eq 0 ]; then
7699 error "ls $i files is slower with statahead!"
7701 log "ls $i files is slower with statahead!"
7707 [ $delta -gt 20 ] && break
7708 [ $delta -gt 8 ] && MULT=$((50 / delta))
7709 [ "$SLOW" = "no" -a $delta -gt 5 ] && break
7717 delta=$((etime - stime))
7718 log "rm -r $DIR/$tdir/: $delta seconds"
7720 lctl get_param -n llite.*.statahead_stats
7722 run_test 123a "verify statahead work"
7724 test_123b () { # statahead(bug 15027)
7725 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7726 test_mkdir -p $DIR/$tdir
7727 createmany -o $DIR/$tdir/$tfile-%d 1000
7729 cancel_lru_locks mdc
7730 cancel_lru_locks osc
7732 #define OBD_FAIL_MDC_GETATTR_ENQUEUE 0x803
7733 lctl set_param fail_loc=0x80000803
7734 ls -lR $DIR/$tdir > /dev/null
7736 lctl set_param fail_loc=0x0
7737 lctl get_param -n llite.*.statahead_stats
7742 run_test 123b "not panic with network error in statahead enqueue (bug 15027)"
7745 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7746 [ -z "$($LCTL get_param -n mdc.*.connect_flags | grep lru_resize)" ] &&
7747 skip "no lru resize on server" && return 0
7749 test_mkdir -p $DIR/$tdir || error "failed to create $DIR/$tdir"
7751 log "create $NR files at $DIR/$tdir"
7752 createmany -o $DIR/$tdir/f $NR ||
7753 error "failed to create $NR files in $DIR/$tdir"
7755 cancel_lru_locks mdc
7756 ls -l $DIR/$tdir > /dev/null
7760 for VALUE in $($LCTL get_param ldlm.namespaces.*mdc-*.lru_size); do
7761 local PARAM=$(echo ${VALUE[0]} | cut -d "=" -f1)
7762 LRU_SIZE=$($LCTL get_param -n $PARAM)
7763 if [[ $LRU_SIZE -gt $(default_lru_size) ]]; then
7764 NSDIR=$(echo $PARAM | cut -d "." -f1-3)
7766 log "NS=$(basename $NSDIR)"
7771 if [[ -z "$NSDIR" || $LRU_SIZE -lt $(default_lru_size) ]]; then
7772 skip "Not enough cached locks created!"
7779 # We know that lru resize allows one client to hold $LIMIT locks
7780 # for 10h. After that locks begin to be killed by client.
7782 local LIMIT=$($LCTL get_param -n $NSDIR.pool.limit)
7785 # Make LVF so higher that sleeping for $SLEEP is enough to _start_
7786 # killing locks. Some time was spent for creating locks. This means
7787 # that up to the moment of sleep finish we must have killed some of
7788 # them (10-100 locks). This depends on how fast ther were created.
7789 # Many of them were touched in almost the same moment and thus will
7790 # be killed in groups.
7791 local LVF=$(($MAX_HRS * 60 * 60 / $SLEEP * $LIMIT / $LRU_SIZE))
7793 # Use $LRU_SIZE_B here to take into account real number of locks
7794 # created in the case of CMD, LRU_SIZE_B != $NR in most of cases
7795 local LRU_SIZE_B=$LRU_SIZE
7797 local OLD_LVF=$($LCTL get_param -n $NSDIR.pool.lock_volume_factor)
7798 log "OLD_LVF=$OLD_LVF"
7799 $LCTL set_param -n $NSDIR.pool.lock_volume_factor $LVF
7801 # Let's make sure that we really have some margin. Client checks
7802 # cached locks every 10 sec.
7804 log "Sleep ${SLEEP} sec"
7806 while ((SEC<$SLEEP)); do
7810 LRU_SIZE=$($LCTL get_param -n $NSDIR/lru_size)
7814 $LCTL set_param -n $NSDIR.pool.lock_volume_factor $OLD_LVF
7815 local LRU_SIZE_A=$($LCTL get_param -n $NSDIR.lru_size)
7817 [[ $LRU_SIZE_B -gt $LRU_SIZE_A ]] || {
7818 error "No locks dropped in ${SLEEP}s. LRU size: $LRU_SIZE_A"
7819 unlinkmany $DIR/$tdir/f $NR
7823 log "Dropped "$((LRU_SIZE_B-LRU_SIZE_A))" locks in ${SLEEP}s"
7824 log "unlink $NR files at $DIR/$tdir"
7825 unlinkmany $DIR/$tdir/f $NR
7827 run_test 124a "lru resize ======================================="
7829 get_max_pool_limit()
7831 local limit=$($LCTL get_param \
7832 -n ldlm.namespaces.*-MDT0000-mdc-*.pool.limit)
7835 if [[ $l -gt $max ]]; then
7843 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7844 [ -z "$($LCTL get_param -n mdc.*.connect_flags | grep lru_resize)" ] &&
7845 skip "no lru resize on server" && return 0
7847 LIMIT=$(get_max_pool_limit)
7849 NR=$(($(default_lru_size)*20))
7850 if [[ $NR -gt $LIMIT ]]; then
7851 log "Limit lock number by $LIMIT locks"
7854 lru_resize_disable mdc
7855 test_mkdir -p $DIR/$tdir/disable_lru_resize ||
7856 error "failed to create $DIR/$tdir/disable_lru_resize"
7858 createmany -o $DIR/$tdir/disable_lru_resize/f $NR
7859 log "doing ls -la $DIR/$tdir/disable_lru_resize 3 times"
7860 cancel_lru_locks mdc
7863 ls -la $DIR/$tdir/disable_lru_resize > /dev/null &
7866 ls -la $DIR/$tdir/disable_lru_resize > /dev/null &
7869 ls -la $DIR/$tdir/disable_lru_resize > /dev/null &
7873 nolruresize_delta=$((etime-stime))
7874 log "ls -la time: $nolruresize_delta seconds"
7875 log "lru_size = $(lctl get_param -n ldlm.namespaces.*mdc*.lru_size)"
7876 unlinkmany $DIR/$tdir/disable_lru_resize/f $NR
7878 lru_resize_enable mdc
7879 test_mkdir -p $DIR/$tdir/enable_lru_resize ||
7880 error "failed to create $DIR/$tdir/enable_lru_resize"
7882 createmany -o $DIR/$tdir/enable_lru_resize/f $NR
7883 log "doing ls -la $DIR/$tdir/enable_lru_resize 3 times"
7884 cancel_lru_locks mdc
7887 ls -la $DIR/$tdir/enable_lru_resize > /dev/null &
7890 ls -la $DIR/$tdir/enable_lru_resize > /dev/null &
7893 ls -la $DIR/$tdir/enable_lru_resize > /dev/null &
7897 lruresize_delta=$((etime-stime))
7898 log "ls -la time: $lruresize_delta seconds"
7899 log "lru_size = $(lctl get_param -n ldlm.namespaces.*mdc*.lru_size)"
7901 if [ $lruresize_delta -gt $nolruresize_delta ]; then
7902 log "ls -la is $(((lruresize_delta - $nolruresize_delta) * 100 / $nolruresize_delta))% slower with lru resize enabled"
7903 elif [ $nolruresize_delta -gt $lruresize_delta ]; then
7904 log "ls -la is $(((nolruresize_delta - $lruresize_delta) * 100 / $nolruresize_delta))% faster with lru resize enabled"
7906 log "lru resize performs the same with no lru resize"
7908 unlinkmany $DIR/$tdir/enable_lru_resize/f $NR
7910 run_test 124b "lru resize (performance test) ======================="
7912 test_125() { # 13358
7913 [ -z "$(lctl get_param -n llite.*.client_type | grep local)" ] && skip "must run as local client" && return
7914 [ -z "$(lctl get_param -n mdc.*-mdc-*.connect_flags | grep acl)" ] && skip "must have acl enabled" && return
7915 [ -z "$(which setfacl)" ] && skip "must have setfacl tool" && return
7916 test_mkdir -p $DIR/d125 || error "mkdir failed"
7917 $SETSTRIPE -S 65536 -c -1 $DIR/d125 || error "setstripe failed"
7918 setfacl -R -m u:bin:rwx $DIR/d125 || error "setfacl $DIR/d125 failed"
7919 ls -ld $DIR/d125 || error "cannot access $DIR/d125"
7921 run_test 125 "don't return EPROTO when a dir has a non-default striping and ACLs"
7923 test_126() { # bug 12829/13455
7924 [ -z "$(lctl get_param -n llite.*.client_type | grep local)" ] && skip "must run as local client" && return
7925 [ "$UID" != 0 ] && skip_env "skipping $TESTNAME (must run as root)" && return
7926 $GSS && skip "must run as gss disabled" && return
7928 $RUNAS -u 0 -g 1 touch $DIR/$tfile || error "touch failed"
7929 gid=`ls -n $DIR/$tfile | awk '{print $4}'`
7931 [ $gid -eq "1" ] || error "gid is set to" $gid "instead of 1"
7933 run_test 126 "check that the fsgid provided by the client is taken into account"
7935 test_127a() { # bug 15521
7936 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7937 $SETSTRIPE -i 0 -c 1 $DIR/$tfile || error "setstripe failed"
7938 $LCTL set_param osc.*.stats=0
7939 FSIZE=$((2048 * 1024))
7940 dd if=/dev/zero of=$DIR/$tfile bs=$FSIZE count=1
7941 cancel_lru_locks osc
7942 dd if=$DIR/$tfile of=/dev/null bs=$FSIZE
7944 $LCTL get_param osc.*0000-osc-*.stats | grep samples > $DIR/${tfile}.tmp
7945 while read NAME COUNT SAMP UNIT MIN MAX SUM SUMSQ; do
7946 echo "got $COUNT $NAME"
7947 [ ! $MIN ] && error "Missing min value for $NAME proc entry"
7948 eval $NAME=$COUNT || error "Wrong proc format"
7951 read_bytes|write_bytes)
7952 [ $MIN -lt 4096 ] && error "min is too small: $MIN"
7953 [ $MIN -gt $FSIZE ] && error "min is too big: $MIN"
7954 [ $MAX -lt 4096 ] && error "max is too small: $MAX"
7955 [ $MAX -gt $FSIZE ] && error "max is too big: $MAX"
7956 [ $SUM -ne $FSIZE ] && error "sum is wrong: $SUM"
7957 [ $SUMSQ -lt $(((FSIZE /4096) * (4096 * 4096))) ] &&
7958 error "sumsquare is too small: $SUMSQ"
7959 [ $SUMSQ -gt $((FSIZE * FSIZE)) ] &&
7960 error "sumsquare is too big: $SUMSQ"
7964 done < $DIR/${tfile}.tmp
7966 #check that we actually got some stats
7967 [ "$read_bytes" ] || error "Missing read_bytes stats"
7968 [ "$write_bytes" ] || error "Missing write_bytes stats"
7969 [ "$read_bytes" != 0 ] || error "no read done"
7970 [ "$write_bytes" != 0 ] || error "no write done"
7972 run_test 127a "verify the client stats are sane"
7974 test_127b() { # bug LU-333
7975 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7976 $LCTL set_param llite.*.stats=0
7977 FSIZE=65536 # sized fixed to match PAGE_SIZE for most clients
7978 # perform 2 reads and writes so MAX is different from SUM.
7979 dd if=/dev/zero of=$DIR/$tfile bs=$FSIZE count=1
7980 dd if=/dev/zero of=$DIR/$tfile bs=$FSIZE count=1
7981 cancel_lru_locks osc
7982 dd if=$DIR/$tfile of=/dev/null bs=$FSIZE count=1
7983 dd if=$DIR/$tfile of=/dev/null bs=$FSIZE count=1
7985 $LCTL get_param llite.*.stats | grep samples > $TMP/${tfile}.tmp
7986 while read NAME COUNT SAMP UNIT MIN MAX SUM SUMSQ; do
7987 echo "got $COUNT $NAME"
7988 eval $NAME=$COUNT || error "Wrong proc format"
7992 [ $COUNT -ne 2 ] && error "count is not 2: $COUNT"
7993 [ $MIN -ne $FSIZE ] && error "min is not $FSIZE: $MIN"
7994 [ $MAX -ne $FSIZE ] && error "max is incorrect: $MAX"
7995 [ $SUM -ne $((FSIZE * 2)) ] && error "sum is wrong: $SUM"
7998 [ $COUNT -ne 2 ] && error "count is not 2: $COUNT"
7999 [ $MIN -ne $FSIZE ] && error "min is not $FSIZE: $MIN"
8000 [ $MAX -ne $FSIZE ] && error "max is incorrect: $MAX"
8001 [ $SUM -ne $((FSIZE * 2)) ] && error "sum is wrong: $SUM"
8005 done < $TMP/${tfile}.tmp
8007 #check that we actually got some stats
8008 [ "$read_bytes" ] || error "Missing read_bytes stats"
8009 [ "$write_bytes" ] || error "Missing write_bytes stats"
8010 [ "$read_bytes" != 0 ] || error "no read done"
8011 [ "$write_bytes" != 0 ] || error "no write done"
8013 run_test 127b "verify the llite client stats are sane"
8015 test_128() { # bug 15212
8017 $LFS 2>&1 <<-EOF | tee $TMP/$tfile.log
8022 result=$(grep error $TMP/$tfile.log)
8024 [ -z "$result" ] || error "consecutive find's under interactive lfs failed"
8026 run_test 128 "interactive lfs for 2 consecutive find's"
8033 local LDPROC=/proc/fs/ldiskfs
8034 local facets=$(get_facets MDS)
8036 for facet in ${facets//,/ }; do
8037 canondev=$(ldiskfs_canon \
8038 *.$(convert_facet2label $facet).mntdev $facet)
8039 do_facet $facet "test -e $LDPROC/$canondev/max_dir_size" ||
8040 LDPROC=/sys/fs/ldiskfs
8041 do_facet $facet "echo $1 >$LDPROC/$canondev/max_dir_size"
8046 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8047 if [ "$(facet_fstype $SINGLEMDS)" != ldiskfs ]; then
8048 skip "Only applicable to ldiskfs-based MDTs"
8051 remote_mds_nodsh && skip "remote MDS with nodsh" && return
8057 test_mkdir -p $DIR/$tdir
8059 # block size of mds1
8060 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
8061 local MDSBLOCKSIZE=$($LCTL get_param -n mdc.*MDT0000*.blocksize)
8062 local MAX=$((MDSBLOCKSIZE * 3))
8064 local I=$(stat -c%s "$DIR/$tdir")
8066 local STRIPE_COUNT=1
8067 [[ $MDSCOUNT -ge 2 ]] && STRIPE_COUNT=$($LFS getdirstripe -c $DIR/$tdir)
8068 MAX=$((MAX*STRIPE_COUNT))
8069 while [[ $I -le $MAX ]]; do
8070 $MULTIOP $DIR/$tdir/$J Oc
8072 #check two errors ENOSPC for new version of ext4 max_dir_size patch
8073 #mainline kernel commit df981d03eeff7971ac7e6ff37000bfa702327ef1
8074 #and EFBIG for previous versions
8075 if [ $rc -eq $EFBIG -o $rc -eq $ENOSPC ]; then
8077 echo "return code $rc received as expected"
8078 multiop $DIR/$tdir/$J Oc ||
8079 error_exit "multiop failed w/o dir size limit"
8081 I=$(stat -c%s "$DIR/$tdir")
8083 if [ $(lustre_version_code $SINGLEMDS) -lt \
8084 $(version_code 2.4.51) ]
8086 [[ $I -eq $MAX ]] && return 0
8088 [[ $I -gt $MAX ]] && return 0
8090 error_exit "current dir size $I, previous limit $MAX"
8091 elif [ $rc -ne 0 ]; then
8093 error_exit "return code $rc received instead of expected " \
8094 "$EFBIG or $ENOSPC, files in dir $I"
8097 I=$(stat -c%s "$DIR/$tdir")
8101 error "exceeded dir size limit $MAX x $MDSCOUNT $MAX : $I bytes"
8103 run_test 129 "test directory size limit ========================"
8112 local filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
8113 [ -n "$filefrag_op" ] && skip_env "filefrag does not support FIEMAP" &&
8116 trap cleanup_130 EXIT RETURN
8118 local fm_file=$DIR/$tfile
8119 $SETSTRIPE -S 65536 -c 1 $fm_file || error "setstripe on $fm_file"
8120 dd if=/dev/zero of=$fm_file bs=65536 count=1 ||
8121 error "dd failed for $fm_file"
8123 # LU-1795: test filefrag/FIEMAP once, even if unsupported
8124 filefrag -ves $fm_file
8126 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
8127 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
8128 [ $RC != 0 ] && error "filefrag $fm_file failed"
8130 filefrag_op=$(filefrag -ve $fm_file | grep -A 100 "ext:" |
8131 grep -v "ext:" | grep -v "found")
8132 lun=$($GETSTRIPE -i $fm_file)
8134 start_blk=`echo $filefrag_op | cut -d: -f2 | cut -d. -f1`
8137 for line in $filefrag_op
8139 frag_lun=`echo $line | cut -d: -f5`
8140 ext_len=`echo $line | cut -d: -f4`
8141 if (( $frag_lun != $lun )); then
8143 error "FIEMAP on 1-stripe file($fm_file) failed"
8146 (( tot_len += ext_len ))
8149 if (( lun != frag_lun || start_blk != 0 || tot_len != 64 )); then
8151 error "FIEMAP on 1-stripe file($fm_file) failed;"
8157 echo "FIEMAP on single striped file succeeded"
8159 run_test 130a "FIEMAP (1-stripe file)"
8162 [ "$OSTCOUNT" -lt "2" ] &&
8163 skip_env "skipping FIEMAP on 2-stripe file test" && return
8165 [ "$OSTCOUNT" -ge "10" ] &&
8166 skip_env "skipping FIEMAP with >= 10 OSTs" && return
8168 local filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
8169 [ -n "$filefrag_op" ] && skip_env "filefrag does not support FIEMAP" &&
8172 trap cleanup_130 EXIT RETURN
8174 local fm_file=$DIR/$tfile
8175 $SETSTRIPE -S 65536 -c 2 $fm_file || error "setstripe on $fm_file"
8176 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
8177 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
8179 dd if=/dev/zero of=$fm_file bs=1M count=2 ||
8180 error "dd failed on $fm_file"
8182 filefrag -ves $fm_file || error "filefrag $fm_file failed"
8183 filefrag_op=$(filefrag -ve $fm_file | grep -A 100 "ext:" |
8184 grep -v "ext:" | grep -v "found")
8186 last_lun=$(echo $filefrag_op | cut -d: -f5)
8191 for line in $filefrag_op
8193 frag_lun=`echo $line | cut -d: -f5`
8194 ext_len=`echo $line | cut -d: -f4`
8195 if (( $frag_lun != $last_lun )); then
8196 if (( tot_len != 1024 )); then
8198 error "FIEMAP on $fm_file failed; returned len $tot_len for OST $last_lun instead of 256"
8205 (( tot_len += ext_len ))
8208 if (( num_luns != 2 || tot_len != 1024 )); then
8210 error "FIEMAP on $fm_file failed; returned wrong number of luns or wrong len for OST $last_lun"
8216 echo "FIEMAP on 2-stripe file succeeded"
8218 run_test 130b "FIEMAP (2-stripe file)"
8221 [ "$OSTCOUNT" -lt "2" ] &&
8222 skip_env "skipping FIEMAP on 2-stripe file" && return
8224 [ "$OSTCOUNT" -ge "10" ] &&
8225 skip_env "skipping FIEMAP with >= 10 OSTs" && return
8227 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
8228 [ -n "$filefrag_op" ] && skip "filefrag does not support FIEMAP" &&
8231 trap cleanup_130 EXIT RETURN
8233 local fm_file=$DIR/$tfile
8234 $SETSTRIPE -S 65536 -c 2 $fm_file || error "setstripe on $fm_file"
8235 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
8236 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
8238 dd if=/dev/zero of=$fm_file seek=1 bs=1M count=1 || error "dd failed on $fm_file"
8240 filefrag -ves $fm_file || error "filefrag $fm_file failed"
8241 filefrag_op=`filefrag -ve $fm_file | grep -A 100 "ext:" | grep -v "ext:" | grep -v "found"`
8243 last_lun=`echo $filefrag_op | cut -d: -f5`
8248 for line in $filefrag_op
8250 frag_lun=`echo $line | cut -d: -f5`
8251 ext_len=`echo $line | cut -d: -f4`
8252 if (( $frag_lun != $last_lun )); then
8253 logical=`echo $line | cut -d: -f2 | cut -d. -f1`
8254 if (( logical != 512 )); then
8256 error "FIEMAP on $fm_file failed; returned logical start for lun $logical instead of 512"
8259 if (( tot_len != 512 )); then
8261 error "FIEMAP on $fm_file failed; returned len $tot_len for OST $last_lun instead of 1024"
8268 (( tot_len += ext_len ))
8271 if (( num_luns != 2 || tot_len != 512 )); then
8273 error "FIEMAP on $fm_file failed; returned wrong number of luns or wrong len for OST $last_lun"
8279 echo "FIEMAP on 2-stripe file with hole succeeded"
8281 run_test 130c "FIEMAP (2-stripe file with hole)"
8284 [ "$OSTCOUNT" -lt "3" ] && skip_env "skipping FIEMAP on N-stripe file test" && return
8286 [ "$OSTCOUNT" -ge "10" ] &&
8287 skip_env "skipping FIEMAP with >= 10 OSTs" && return
8289 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
8290 [ -n "$filefrag_op" ] && skip "filefrag does not support FIEMAP" && return
8292 trap cleanup_130 EXIT RETURN
8294 local fm_file=$DIR/$tfile
8295 $SETSTRIPE -S 65536 -c $OSTCOUNT $fm_file||error "setstripe on $fm_file"
8296 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
8297 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
8299 local actual_stripecnt=$($GETSTRIPE -c $fm_file)
8300 dd if=/dev/zero of=$fm_file bs=1M count=$actual_stripecnt ||
8301 error "dd failed on $fm_file"
8303 filefrag -ves $fm_file || error "filefrag $fm_file failed"
8304 filefrag_op=`filefrag -ve $fm_file | grep -A 100 "ext:" |
8305 grep -v "ext:" | grep -v "found"`
8307 last_lun=`echo $filefrag_op | cut -d: -f5`
8312 for line in $filefrag_op
8314 frag_lun=`echo $line | cut -d: -f5`
8315 ext_len=`echo $line | cut -d: -f4`
8316 if (( $frag_lun != $last_lun )); then
8317 if (( tot_len != 1024 )); then
8319 error "FIEMAP on $fm_file failed; returned len $tot_len for OST $last_lun instead of 1024"
8326 (( tot_len += ext_len ))
8329 if (( num_luns != actual_stripecnt || tot_len != 1024 )); then
8331 error "FIEMAP on $fm_file failed; returned wrong number of luns or wrong len for OST $last_lun"
8337 echo "FIEMAP on N-stripe file succeeded"
8339 run_test 130d "FIEMAP (N-stripe file)"
8342 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping continuation FIEMAP test" && return
8344 [ "$OSTCOUNT" -ge "10" ] &&
8345 skip_env "skipping FIEMAP with >= 10 OSTs" && return
8347 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
8348 [ -n "$filefrag_op" ] && skip "filefrag does not support FIEMAP" && return
8350 trap cleanup_130 EXIT RETURN
8352 local fm_file=$DIR/$tfile
8353 $SETSTRIPE -S 131072 -c 2 $fm_file || error "setstripe on $fm_file"
8354 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
8355 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
8358 EXPECTED_LEN=$(( (NUM_BLKS / 2) * 64 ))
8359 for ((i = 0; i < $NUM_BLKS; i++))
8361 dd if=/dev/zero of=$fm_file count=1 bs=64k seek=$((2*$i)) conv=notrunc > /dev/null 2>&1
8364 filefrag -ves $fm_file || error "filefrag $fm_file failed"
8365 filefrag_op=`filefrag -ve $fm_file | grep -A 12000 "ext:" | grep -v "ext:" | grep -v "found"`
8367 last_lun=`echo $filefrag_op | cut -d: -f5`
8372 for line in $filefrag_op
8374 frag_lun=`echo $line | cut -d: -f5`
8375 ext_len=`echo $line | cut -d: -f4`
8376 if (( $frag_lun != $last_lun )); then
8377 if (( tot_len != $EXPECTED_LEN )); then
8379 error "FIEMAP on $fm_file failed; returned len $tot_len for OST $last_lun instead of $EXPECTED_LEN"
8386 (( tot_len += ext_len ))
8389 if (( num_luns != 2 || tot_len != $EXPECTED_LEN )); then
8391 error "FIEMAP on $fm_file failed; returned wrong number of luns or wrong len for OST $last_lun"
8397 echo "FIEMAP with continuation calls succeeded"
8399 run_test 130e "FIEMAP (test continuation FIEMAP calls)"
8401 # Test for writev/readv
8403 rwv -f $DIR/$tfile -w -n 3 524288 1048576 1572864 || \
8404 error "writev test failed"
8405 rwv -f $DIR/$tfile -r -v -n 2 1572864 1048576 || \
8406 error "readv failed"
8409 run_test 131a "test iov's crossing stripe boundary for writev/readv"
8412 rwv -f $DIR/$tfile -w -a -n 3 524288 1048576 1572864 || \
8413 error "append writev test failed"
8414 rwv -f $DIR/$tfile -w -a -n 2 1572864 1048576 || \
8415 error "append writev test failed"
8418 run_test 131b "test append writev"
8421 rwv -f $DIR/$tfile -w -d -n 1 1048576 || return 0
8424 run_test 131c "test read/write on file w/o objects"
8427 rwv -f $DIR/$tfile -w -n 1 1572864
8428 NOB=`rwv -f $DIR/$tfile -r -n 3 524288 524288 1048576 | awk '/error/ {print $6}'`
8429 if [ "$NOB" != 1572864 ]; then
8430 error "Short read filed: read $NOB bytes instead of 1572864"
8434 run_test 131d "test short read"
8437 rwv -f $DIR/$tfile -w -s 1048576 -n 1 1048576
8438 rwv -f $DIR/$tfile -r -z -s 0 -n 1 524288 || \
8439 error "read hitting hole failed"
8442 run_test 131e "test read hitting hole"
8447 for node in $(osts_nodes); do
8448 gl=$(do_node $node "$LCTL get_param -n ost.OSS.ost.stats" | awk '/'$token'/ {print $2}' | head -n 1)
8449 [ x$gl = x"" ] && gl=0
8450 gl_sum=$((gl_sum + gl))
8460 if [ x$som = x"enabled" ]; then
8461 [ $((gl2 - gl1)) -gt 0 ] && error "no glimpse RPC is expected"
8462 MOUNTOPT=`echo $MOUNTOPT | sed 's/som_preview//g'`
8463 do_facet mgs "$LCTL conf_param $FSNAME.mdt.som=disabled"
8465 [ $((gl2 - gl1)) -gt 0 ] || error "some glimpse RPC is expected"
8466 MOUNTOPT="$MOUNTOPT,som_preview"
8467 do_facet mgs "$LCTL conf_param $FSNAME.mdt.som=enabled"
8470 # do remount to make new mount-conf parameters actual
8477 test_132() { #1028, SOM
8478 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8479 remote_mds_nodsh && skip "remote MDS with nodsh" && return
8480 local num=$(get_mds_dir $DIR)
8481 local mymds=mds${num}
8482 local MOUNTOPT_SAVE=$MOUNTOPT
8484 dd if=/dev/zero of=$DIR/$tfile count=1 2>/dev/null
8485 cancel_lru_locks osc
8487 som1=$(do_facet $mymds "$LCTL get_param mdt.*.som" | awk -F= ' {print $2}' | head -n 1)
8489 gl1=$(get_ost_param "ldlm_glimpse_enqueue")
8490 stat $DIR/$tfile >/dev/null
8491 gl2=$(get_ost_param "ldlm_glimpse_enqueue")
8492 echo "====> SOM is "$som1", "$((gl2 - gl1))" glimpse RPC occured"
8494 som_mode_switch $som1 $gl1 $gl2
8496 dd if=/dev/zero of=$DIR/$tfile count=1 2>/dev/null
8497 cancel_lru_locks osc
8499 som2=$(do_facet $mymds "$LCTL get_param mdt.*.som" | awk -F= ' {print $2}' | head -n 1)
8500 if [ $som1 == $som2 ]; then
8501 error "som is still "$som2
8502 if [ x$som2 = x"enabled" ]; then
8509 gl1=$(get_ost_param "ldlm_glimpse_enqueue")
8510 stat $DIR/$tfile >/dev/null
8511 gl2=$(get_ost_param "ldlm_glimpse_enqueue")
8512 echo "====> SOM is "$som2", "$((gl2 - gl1))" glimpse RPC occured"
8513 som_mode_switch $som2 $gl1 $gl2
8514 MOUNTOPT=$MOUNTOPT_SAVE
8516 run_test 132 "som avoids glimpse rpc"
8522 $SINGLEMDS) res=`do_facet $SINGLEMDS $LCTL get_param mdt.$FSNAME-MDT0000.md_stats | grep "$2"`
8524 ost) res=`do_facet ost1 $LCTL get_param obdfilter.$FSNAME-OST0000.stats | grep "$2"`
8526 *) error "Wrong argument $1" ;;
8529 [ -z "$res" ] && error "The counter for $2 on $1 was not incremented"
8530 # if the argument $3 is zero, it means any stat increment is ok.
8531 if [[ $3 -gt 0 ]]; then
8532 count=$(echo $res | awk '{ print $2 }')
8533 [[ $count -ne $3 ]] &&
8534 error "The $2 counter on $1 is wrong - expected $3"
8539 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8540 remote_ost_nodsh && skip "remote OST with nodsh" && return
8541 remote_mds_nodsh && skip "remote MDS with nodsh" && return
8543 do_facet $SINGLEMDS $LCTL list_param mdt.*.rename_stats ||
8544 { skip "MDS doesn't support rename stats"; return; }
8545 local testdir=$DIR/${tdir}/stats_testdir
8546 mkdir -p $DIR/${tdir}
8549 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
8550 do_facet ost1 $LCTL set_param obdfilter.*.stats=clear
8552 # verify mdt stats first.
8553 mkdir ${testdir} || error "mkdir failed"
8554 check_stats $SINGLEMDS "mkdir" 1
8555 touch ${testdir}/${tfile} || "touch failed"
8556 check_stats $SINGLEMDS "open" 1
8557 check_stats $SINGLEMDS "close" 1
8558 mknod ${testdir}/${tfile}-pipe p || "mknod failed"
8559 check_stats $SINGLEMDS "mknod" 1
8560 rm -f ${testdir}/${tfile}-pipe || "pipe remove failed"
8561 check_stats $SINGLEMDS "unlink" 1
8562 rm -f ${testdir}/${tfile} || error "file remove failed"
8563 check_stats $SINGLEMDS "unlink" 2
8565 # remove working dir and check mdt stats again.
8566 rmdir ${testdir} || error "rmdir failed"
8567 check_stats $SINGLEMDS "rmdir" 1
8569 local testdir1=$DIR/${tdir}/stats_testdir1
8571 mkdir -p ${testdir1}
8572 touch ${testdir1}/test1
8573 mv ${testdir1}/test1 ${testdir} || error "file crossdir rename"
8574 check_stats $SINGLEMDS "crossdir_rename" 1
8576 mv ${testdir}/test1 ${testdir}/test0 || error "file samedir rename"
8577 check_stats $SINGLEMDS "samedir_rename" 1
8581 run_test 133a "Verifying MDT stats ========================================"
8584 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8585 remote_ost_nodsh && skip "remote OST with nodsh" && return
8586 remote_mds_nodsh && skip "remote MDS with nodsh" && return
8587 local testdir=$DIR/${tdir}/stats_testdir
8588 mkdir -p ${testdir} || error "mkdir failed"
8589 touch ${testdir}/${tfile} || "touch failed"
8590 cancel_lru_locks mdc
8593 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
8594 do_facet ost1 $LCTL set_param obdfilter.*.stats=clear
8596 # extra mdt stats verification.
8597 chmod 444 ${testdir}/${tfile} || error "chmod failed"
8598 check_stats $SINGLEMDS "setattr" 1
8599 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
8600 if [ $(lustre_version_code $SINGLEMDS) -ne $(version_code 2.2.0) ]
8602 ls -l ${testdir}/${tfile} > /dev/null|| error "ls failed"
8603 check_stats $SINGLEMDS "getattr" 1
8605 $LFS df || error "lfs failed"
8606 check_stats $SINGLEMDS "statfs" 1
8610 run_test 133b "Verifying extra MDT stats =================================="
8613 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8614 remote_ost_nodsh && skip "remote OST with nodsh" && return
8615 remote_mds_nodsh && skip "remote MDS with nodsh" && return
8616 local testdir=$DIR/${tdir}/stats_testdir
8617 test_mkdir -p ${testdir} || error "mkdir failed"
8619 # verify obdfilter stats.
8620 $SETSTRIPE -c 1 -i 0 ${testdir}/${tfile}
8622 cancel_lru_locks osc
8623 wait_delete_completed
8626 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
8627 do_facet ost1 $LCTL set_param obdfilter.*.stats=clear
8629 dd if=/dev/zero of=${testdir}/${tfile} conv=notrunc bs=512k count=1 || error "dd failed"
8631 cancel_lru_locks osc
8632 check_stats ost "write" 1
8634 dd if=${testdir}/${tfile} of=/dev/null bs=1k count=1 || error "dd failed"
8635 check_stats ost "read" 1
8637 > ${testdir}/${tfile} || error "truncate failed"
8638 check_stats ost "punch" 1
8640 rm -f ${testdir}/${tfile} || error "file remove failed"
8641 wait_delete_completed
8642 check_stats ost "destroy" 1
8646 run_test 133c "Verifying OST stats ========================================"
8653 while [ $value -ge 2 ]; do
8658 if [ $orig -gt $order ]; then
8666 local size=('K' 'M' 'G' 'T');
8668 local size_string=$value
8670 while [ $value -ge 1024 ]; do
8671 if [ $i -gt 3 ]; then
8672 #T is the biggest unit we get here, if that is bigger,
8674 size_string=${value}T
8677 value=$((value >> 10))
8678 if [ $value -lt 1024 ]; then
8679 size_string=${value}${size[$i]}
8690 local context=${2:-.}
8691 local sample=$(do_facet $SINGLEMDS $LCTL get_param mdt.*.rename_stats |
8693 awk '/ '${size}'/ {print $4}' | sed -e "s/,//g")
8698 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8699 remote_ost_nodsh && skip "remote OST with nodsh" && return
8700 remote_mds_nodsh && skip "remote MDS with nodsh" && return
8701 do_facet $SINGLEMDS $LCTL list_param mdt.*.rename_stats ||
8702 { skip "MDS doesn't support rename stats"; return; }
8704 local testdir1=$DIR/${tdir}/stats_testdir1
8705 local testdir2=$DIR/${tdir}/stats_testdir2
8707 do_facet $SINGLEMDS $LCTL set_param mdt.*.rename_stats=clear
8709 mkdir -p ${testdir1} || error "mkdir failed"
8710 mkdir -p ${testdir2} || error "mkdir failed"
8712 createmany -o $testdir1/test 512 || error "createmany failed"
8714 # check samedir rename size
8715 mv ${testdir1}/test0 ${testdir1}/test_0
8717 local testdir1_size=$(ls -l $DIR/${tdir} |
8718 awk '/stats_testdir1/ {print $5}')
8719 local testdir2_size=$(ls -l $DIR/${tdir} |
8720 awk '/stats_testdir2/ {print $5}')
8722 testdir1_size=$(order_2 $testdir1_size)
8723 testdir2_size=$(order_2 $testdir2_size)
8725 testdir1_size=$(size_in_KMGT $testdir1_size)
8726 testdir2_size=$(size_in_KMGT $testdir2_size)
8728 echo "source rename dir size: ${testdir1_size}"
8729 echo "target rename dir size: ${testdir2_size}"
8731 local cmd="do_facet $SINGLEMDS $LCTL get_param mdt.*.rename_stats"
8732 eval $cmd || error "$cmd failed"
8733 local samedir=$($cmd | grep 'same_dir')
8734 local same_sample=$(get_rename_size $testdir1_size)
8735 [ -z "$samedir" ] && error "samedir_rename_size count error"
8736 [[ $same_sample -eq 1 ]] ||
8737 error "samedir_rename_size error $same_sample"
8738 echo "Check same dir rename stats success"
8740 do_facet $SINGLEMDS $LCTL set_param mdt.*.rename_stats=clear
8742 # check crossdir rename size
8743 mv ${testdir1}/test_0 ${testdir2}/test_0
8745 testdir1_size=$(ls -l $DIR/${tdir} |
8746 awk '/stats_testdir1/ {print $5}')
8747 testdir2_size=$(ls -l $DIR/${tdir} |
8748 awk '/stats_testdir2/ {print $5}')
8750 testdir1_size=$(order_2 $testdir1_size)
8751 testdir2_size=$(order_2 $testdir2_size)
8753 testdir1_size=$(size_in_KMGT $testdir1_size)
8754 testdir2_size=$(size_in_KMGT $testdir2_size)
8756 echo "source rename dir size: ${testdir1_size}"
8757 echo "target rename dir size: ${testdir2_size}"
8759 eval $cmd || error "$cmd failed"
8760 local crossdir=$($cmd | grep 'crossdir')
8761 local src_sample=$(get_rename_size $testdir1_size crossdir_src)
8762 local tgt_sample=$(get_rename_size $testdir2_size crossdir_tgt)
8763 [ -z "$crossdir" ] && error "crossdir_rename_size count error"
8764 [[ $src_sample -eq 1 ]] ||
8765 error "crossdir_rename_size error $src_sample"
8766 [[ $tgt_sample -eq 1 ]] ||
8767 error "crossdir_rename_size error $tgt_sample"
8768 echo "Check cross dir rename stats success"
8771 run_test 133d "Verifying rename_stats ========================================"
8774 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8775 local testdir=$DIR/${tdir}/stats_testdir
8776 local ctr f0 f1 bs=32768 count=42 sum
8778 remote_ost_nodsh && skip "remote OST with nodsh" && return
8779 mkdir -p ${testdir} || error "mkdir failed"
8781 $SETSTRIPE -c 1 -i 0 ${testdir}/${tfile}
8783 for ctr in {write,read}_bytes; do
8785 cancel_lru_locks osc
8787 do_facet ost1 $LCTL set_param -n \
8788 "obdfilter.*.exports.clear=clear"
8790 if [ $ctr = write_bytes ]; then
8792 f1=${testdir}/${tfile}
8794 f0=${testdir}/${tfile}
8798 dd if=$f0 of=$f1 conv=notrunc bs=$bs count=$count || \
8801 cancel_lru_locks osc
8803 sum=$(do_facet ost1 $LCTL get_param \
8804 "obdfilter.*.exports.*.stats" |
8805 awk -v ctr=$ctr 'BEGIN { sum = 0 }
8806 $1 == ctr { sum += $7 }
8807 END { printf("%0.0f", sum) }')
8809 if ((sum != bs * count)); then
8810 error "Bad $ctr sum, expected $((bs * count)), got $sum"
8816 run_test 133e "Verifying OST {read,write}_bytes nid stats ================="
8819 local proc_dirs="/proc/fs/lustre/ /proc/sys/lnet/ /proc/sys/lustre/"
8822 # First without trusting modes.
8823 find $proc_dirs -exec cat '{}' \; &> /dev/null
8825 # Second verifying readability.
8828 -exec cat '{}' \; &> /dev/null ||
8829 error "proc file read failed"
8831 for facet in $SINGLEMDS ost1; do
8832 do_facet $facet find $proc_dirs \
8833 ! -name req_history \
8834 -exec cat '{}' \\\; &> /dev/null
8836 do_facet $facet find $proc_dirs \
8837 ! -name req_history \
8839 -exec cat '{}' \\\; &> /dev/null ||
8840 error "proc file read failed"
8843 run_test 133f "Check for LBUGs/Oopses/unreadable files in /proc"
8845 test_140() { #bug-17379
8846 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8847 test_mkdir -p $DIR/$tdir || error "Creating dir $DIR/$tdir"
8848 cd $DIR/$tdir || error "Changing to $DIR/$tdir"
8849 cp /usr/bin/stat . || error "Copying stat to $DIR/$tdir"
8851 # VFS limits max symlink depth to 5(4KSTACK) or 7(8KSTACK) or 8
8852 # For kernel > 3.5, bellow only tests consecutive symlink (MAX 40)
8854 while i=`expr $i + 1`; do
8855 test_mkdir -p $i || error "Creating dir $i"
8856 cd $i || error "Changing to $i"
8857 ln -s ../stat stat || error "Creating stat symlink"
8858 # Read the symlink until ELOOP present,
8859 # not LBUGing the system is considered success,
8860 # we didn't overrun the stack.
8861 $OPENFILE -f O_RDONLY stat >/dev/null 2>&1; ret=$?
8863 if [ $ret -eq 40 ]; then
8866 error "Open stat symlink"
8872 echo "The symlink depth = $i"
8873 [ $i -eq 5 -o $i -eq 7 -o $i -eq 8 -o $i -eq 40 ] ||
8874 error "Invalid symlink depth"
8876 # Test recursive symlink
8877 ln -s symlink_self symlink_self
8878 $OPENFILE -f O_RDONLY symlink_self >/dev/null 2>&1; ret=$?
8879 echo "open symlink_self returns $ret"
8880 [ $ret -eq 40 ] || error "recursive symlink doesn't return -ELOOP"
8882 run_test 140 "Check reasonable stack depth (shouldn't LBUG) ===="
8885 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8886 local TF="$TMP/$tfile"
8888 dd if=/dev/urandom of=$TF bs=6096 count=1 || error "dd failed"
8890 cancel_lru_locks osc
8891 cmp $TF $DIR/$tfile || error "$TMP/$tfile $DIR/$tfile differ"
8892 remount_client $MOUNT
8894 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (remount)"
8897 $TRUNCATE $DIR/$tfile 6000
8898 cancel_lru_locks osc
8899 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (truncate1)"
8902 echo "12345" >>$DIR/$tfile
8903 cancel_lru_locks osc
8904 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (append1)"
8907 echo "12345" >>$DIR/$tfile
8908 cancel_lru_locks osc
8909 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (append2)"
8914 run_test 150 "truncate/append tests"
8916 #LU-2902 roc_hit was not able to read all values from lproc
8917 function roc_hit_init() {
8918 local list=$(comma_list $(osts_nodes))
8919 local dir=$DIR/$tdir-check
8920 local file=$dir/file
8926 #use setstripe to do a write to every ost
8927 for i in $(seq 0 $((OSTCOUNT-1))); do
8928 $SETSTRIPE -c 1 -i $i $dir || error "$SETSTRIPE $file failed"
8929 dd if=/dev/urandom of=$file bs=4k count=4 2>&1 > /dev/null
8930 idx=$(printf %04x $i)
8931 BEFORE=$(get_osd_param $list *OST*$idx stats |
8932 awk '$1 == "cache_access" {sum += $2}
8933 END { printf("%0.0f", sum) }')
8935 cancel_lru_locks osc
8936 cat $file >/dev/null
8938 AFTER=$(get_osd_param $list *OST*$idx stats |
8939 awk '$1 == "cache_access" {sum += $2}
8940 END { printf("%0.0f", sum) }')
8942 echo BEFORE:$BEFORE AFTER:$AFTER
8943 if ! let "AFTER - BEFORE == 4"; then
8945 error "roc_hit is not safe to use"
8953 function roc_hit() {
8954 local list=$(comma_list $(osts_nodes))
8955 echo $(get_osd_param $list '' stats |
8956 awk '$1 == "cache_hit" {sum += $2}
8957 END { printf("%0.0f", sum) }')
8960 function set_cache() {
8963 if [ "$2" == "off" ]; then
8966 local list=$(comma_list $(osts_nodes))
8967 set_osd_param $list '' $1_cache_enable $on
8969 cancel_lru_locks osc
8973 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8974 remote_ost_nodsh && skip "remote OST with nodsh" && return
8977 local list=$(comma_list $(osts_nodes))
8979 # check whether obdfilter is cache capable at all
8980 if ! get_osd_param $list '' read_cache_enable >/dev/null; then
8981 echo "not cache-capable obdfilter"
8985 # check cache is enabled on all obdfilters
8986 if get_osd_param $list '' read_cache_enable | grep 0; then
8987 echo "oss cache is disabled"
8991 set_osd_param $list '' writethrough_cache_enable 1
8993 # check write cache is enabled on all obdfilters
8994 if get_osd_param $list '' writethrough_cache_enable | grep 0; then
8995 echo "oss write cache is NOT enabled"
9001 #define OBD_FAIL_OBD_NO_LRU 0x609
9002 do_nodes $list $LCTL set_param fail_loc=0x609
9004 # pages should be in the case right after write
9005 dd if=/dev/urandom of=$DIR/$tfile bs=4k count=$CPAGES ||
9008 local BEFORE=$(roc_hit)
9009 cancel_lru_locks osc
9010 cat $DIR/$tfile >/dev/null
9011 local AFTER=$(roc_hit)
9013 do_nodes $list $LCTL set_param fail_loc=0
9015 if ! let "AFTER - BEFORE == CPAGES"; then
9016 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
9019 # the following read invalidates the cache
9020 cancel_lru_locks osc
9021 set_osd_param $list '' read_cache_enable 0
9022 cat $DIR/$tfile >/dev/null
9024 # now data shouldn't be found in the cache
9026 cancel_lru_locks osc
9027 cat $DIR/$tfile >/dev/null
9029 if let "AFTER - BEFORE != 0"; then
9030 error "IN CACHE: before: $BEFORE, after: $AFTER"
9033 set_osd_param $list '' read_cache_enable 1
9036 run_test 151 "test cache on oss and controls ==============================="
9039 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9040 local TF="$TMP/$tfile"
9042 # simulate ENOMEM during write
9043 #define OBD_FAIL_OST_NOMEM 0x226
9044 lctl set_param fail_loc=0x80000226
9045 dd if=/dev/urandom of=$TF bs=6096 count=1 || error "dd failed"
9047 sync || error "sync failed"
9048 lctl set_param fail_loc=0
9050 # discard client's cache
9051 cancel_lru_locks osc
9053 # simulate ENOMEM during read
9054 lctl set_param fail_loc=0x80000226
9055 cmp $TF $DIR/$tfile || error "cmp failed"
9056 lctl set_param fail_loc=0
9060 run_test 152 "test read/write with enomem ============================"
9063 $MULTIOP $DIR/$tfile Ow4096Ycu || error "multiop failed"
9065 run_test 153 "test if fdatasync does not crash ======================="
9067 dot_lustre_fid_permission_check() {
9069 local ffid=$MOUNT/.lustre/fid/$fid
9072 echo "stat fid $fid"
9073 stat $ffid > /dev/null || error "stat $ffid failed."
9074 echo "touch fid $fid"
9075 touch $ffid || error "touch $ffid failed."
9076 echo "write to fid $fid"
9077 cat /etc/hosts > $ffid || error "write $ffid failed."
9078 echo "read fid $fid"
9079 diff /etc/hosts $ffid || error "read $ffid failed."
9080 echo "append write to fid $fid"
9081 cat /etc/hosts >> $ffid || error "append write $ffid failed."
9082 echo "rename fid $fid"
9083 mv $ffid $test_dir/$tfile.1 &&
9084 error "rename $ffid to $tfile.1 should fail."
9085 touch $test_dir/$tfile.1
9086 mv $test_dir/$tfile.1 $ffid &&
9087 error "rename $tfile.1 to $ffid should fail."
9088 rm -f $test_dir/$tfile.1
9089 echo "truncate fid $fid"
9090 $TRUNCATE $ffid 777 || error "truncate $ffid failed."
9091 echo "link fid $fid"
9092 ln -f $ffid $test_dir/tfile.lnk || error "link $ffid failed."
9093 if [ -n $(lctl get_param -n mdc.*-mdc-*.connect_flags | grep acl) ]; then
9094 echo "setfacl fid $fid"
9095 setfacl -R -m u:bin:rwx $ffid || error "setfacl $ffid failed."
9096 echo "getfacl fid $fid"
9097 getfacl $ffid >/dev/null || error "getfacl $ffid failed."
9099 echo "unlink fid $fid"
9100 unlink $MOUNT/.lustre/fid/$fid && error "unlink $ffid should fail."
9101 echo "mknod fid $fid"
9102 mknod $ffid c 1 3 && error "mknod $ffid should fail."
9104 fid=[0xf00000400:0x1:0x0]
9105 ffid=$MOUNT/.lustre/fid/$fid
9107 echo "stat non-exist fid $fid"
9108 stat $ffid > /dev/null && error "stat non-exist $ffid should fail."
9109 echo "write to non-exist fid $fid"
9110 cat /etc/hosts > $ffid && error "write non-exist $ffid should fail."
9111 echo "link new fid $fid"
9112 ln $test_dir/$tfile $ffid && error "link $ffid should fail."
9114 mkdir -p $test_dir/$tdir
9115 touch $test_dir/$tdir/$tfile
9116 fid=$($LFS path2fid $test_dir/$tdir)
9119 error "error: could not get fid for $test_dir/$dir/$tfile."
9121 ffid=$MOUNT/.lustre/fid/$fid
9124 ls $ffid > /dev/null || error "ls $ffid failed."
9125 echo "touch $fid/$tfile.1"
9126 touch $ffid/$tfile.1 || error "touch $ffid/$tfile.1 failed."
9128 echo "touch $MOUNT/.lustre/fid/$tfile"
9129 touch $MOUNT/.lustre/fid/$tfile && \
9130 error "touch $MOUNT/.lustre/fid/$tfile should fail."
9132 echo "setxattr to $MOUNT/.lustre/fid"
9133 setfattr -n trusted.name1 -v value1 $MOUNT/.lustre/fid
9135 echo "listxattr for $MOUNT/.lustre/fid"
9136 getfattr -d -m "^trusted" $MOUNT/.lustre/fid
9138 echo "delxattr from $MOUNT/.lustre/fid"
9139 setfattr -x trusted.name1 $MOUNT/.lustre/fid
9141 echo "touch invalid fid: $MOUNT/.lustre/fid/[0x200000400:0x2:0x3]"
9142 touch $MOUNT/.lustre/fid/[0x200000400:0x2:0x3] &&
9143 error "touch invalid fid should fail."
9145 echo "touch non-normal fid: $MOUNT/.lustre/fid/[0x1:0x2:0x0]"
9146 touch $MOUNT/.lustre/fid/[0x1:0x2:0x0] &&
9147 error "touch non-normal fid should fail."
9149 echo "rename $tdir to $MOUNT/.lustre/fid"
9150 mrename $test_dir/$tdir $MOUNT/.lustre/fid &&
9151 error "rename to $MOUNT/.lustre/fid should fail."
9153 if [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.3.51) ]
9155 local old_obf_mode=$(stat --format="%a" $DIR/.lustre/fid)
9156 local new_obf_mode=777
9158 echo "change mode of $DIR/.lustre/fid to $new_obf_mode"
9159 chmod $new_obf_mode $DIR/.lustre/fid ||
9160 error "chmod $new_obf_mode $DIR/.lustre/fid failed"
9162 local obf_mode=$(stat --format=%a $DIR/.lustre/fid)
9163 [ $obf_mode -eq $new_obf_mode ] ||
9164 error "stat $DIR/.lustre/fid returned wrong mode $obf_mode"
9166 echo "restore mode of $DIR/.lustre/fid to $old_obf_mode"
9167 chmod $old_obf_mode $DIR/.lustre/fid ||
9168 error "chmod $old_obf_mode $DIR/.lustre/fid failed"
9171 $OPENFILE -f O_LOV_DELAY_CREATE:O_CREAT $test_dir/$tfile-2
9172 fid=$($LFS path2fid $test_dir/$tfile-2)
9173 echo "cp /etc/passwd $MOUNT/.lustre/fid/$fid"
9174 cp /etc/passwd $MOUNT/.lustre/fid/$fid &&
9175 error "create lov data thru .lustre should fail."
9176 echo "cp /etc/passwd $test_dir/$tfile-2"
9177 cp /etc/passwd $test_dir/$tfile-2 ||
9178 error "copy to $test_dir/$tfile-2 failed."
9179 echo "diff /etc/passwd $MOUNT/.lustre/fid/$fid"
9180 diff /etc/passwd $MOUNT/.lustre/fid/$fid ||
9181 error "diff /etc/passwd $MOUNT/.lustre/fid/$fid failed."
9183 rm -rf $test_dir/tfile.lnk
9184 rm -rf $test_dir/$tfile-2
9188 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.1) ]] &&
9189 skip "Need MDS version at least 2.4.1" && return
9192 local FID=$($LFS path2fid $DIR/$tfile)
9193 [ -z "$FID" ] && error "path2fid unable to get $DIR/$tfile FID"
9195 # check that we get the same pathname back
9196 local FOUND=$($LFS fid2path $MOUNT $FID)
9197 [ -z "$FOUND" ] && error "fid2path unable to get $FID path"
9198 [ "$FOUND" != "$DIR/$tfile" ] &&
9199 error "fid2path(path2fid($DIR/$tfile)) = $FOUND != $DIR/$tfile"
9203 run_test 154A "lfs path2fid and fid2path basic checks"
9206 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9207 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.51) ]] ||
9208 { skip "Need MDS version at least 2.2.51"; return 0; }
9209 [ -z "$(which setfacl)" ] && skip "must have setfacl tool" && return
9211 cp /etc/hosts $DIR/$tfile
9213 fid=$($LFS path2fid $DIR/$tfile)
9215 [ $rc -ne 0 ] && error "error: could not get fid for $DIR/$tfile."
9217 dot_lustre_fid_permission_check "$fid" $DIR ||
9218 error "dot lustre permission check $fid failed"
9220 rm -rf $MOUNT/.lustre && error ".lustre is not allowed to be unlinked"
9222 touch $MOUNT/.lustre/file &&
9223 error "creation is not allowed under .lustre"
9225 mkdir $MOUNT/.lustre/dir &&
9226 error "mkdir is not allowed under .lustre"
9230 run_test 154a "Open-by-FID"
9233 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9234 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.51) ]] ||
9235 { skip "Need MDS version at least 2.2.51"; return 0; }
9237 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
9239 local remote_dir=$DIR/$tdir/remote_dir
9244 $LFS mkdir -i $MDTIDX $remote_dir ||
9245 error "create remote directory failed"
9247 cp /etc/hosts $remote_dir/$tfile
9249 fid=$($LFS path2fid $remote_dir/$tfile)
9251 [ $rc -ne 0 ] && error "error: could not get fid for $remote_dir/$tfile"
9253 dot_lustre_fid_permission_check "$fid" $remote_dir ||
9254 error "dot lustre permission check $fid failed"
9257 run_test 154b "Open-by-FID for remote directory"
9260 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.1) ]] &&
9261 skip "Need MDS version at least 2.4.1" && return
9263 touch $DIR/$tfile.1 $DIR/$tfile.2 $DIR/$tfile.3
9264 local FID1=$($LFS path2fid $DIR/$tfile.1)
9265 local FID2=$($LFS path2fid $DIR/$tfile.2)
9266 local FID3=$($LFS path2fid $DIR/$tfile.3)
9269 $LFS path2fid $DIR/$tfile.[123] | while read PATHNAME FID; do
9270 [ "$PATHNAME" = "$DIR/$tfile.$N:" ] ||
9271 error "path2fid pathname $PATHNAME != $DIR/$tfile.$N:"
9273 [ "$FID" = "${!want}" ] ||
9274 error "path2fid $PATHNAME FID $FID != FID$N ${!want}"
9278 $LFS fid2path $MOUNT $FID1 $FID2 $FID3 | while read PATHNAME; do
9279 [ "$PATHNAME" = "$DIR/$tfile.$N" ] ||
9280 error "fid2path pathname $PATHNAME != $DIR/$tfile.$N:"
9284 run_test 154c "lfs path2fid and fid2path multiple arguments"
9287 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.5.53) ]] &&
9288 skip "Need MDS version at least 2.5.53" && return
9291 nid=$($LCTL list_nids | sed "s/\./\\\./g")
9295 local proc_ofile="mdt.*.exports.'$nid'.open_files"
9302 fid=$($LFS path2fid $DIR/$tfile)
9305 cmd="exec $fd<$DIR/$tfile"
9307 fid_list=$(do_facet $SINGLEMDS $LCTL get_param $proc_ofile)
9308 echo $fid_list | grep $fid
9311 cmd="exec $fd>/dev/null"
9313 if [ $rc -ne 0 ]; then
9314 error "FID $fid not found in open files list $fid_list"
9317 run_test 154d "Verify open file fid"
9319 test_155_small_load() {
9320 local temp=$TMP/$tfile
9321 local file=$DIR/$tfile
9323 dd if=/dev/urandom of=$temp bs=6096 count=1 || \
9324 error "dd of=$temp bs=6096 count=1 failed"
9326 cancel_lru_locks osc
9327 cmp $temp $file || error "$temp $file differ"
9329 $TRUNCATE $temp 6000
9330 $TRUNCATE $file 6000
9331 cmp $temp $file || error "$temp $file differ (truncate1)"
9333 echo "12345" >>$temp
9334 echo "12345" >>$file
9335 cmp $temp $file || error "$temp $file differ (append1)"
9337 echo "12345" >>$temp
9338 echo "12345" >>$file
9339 cmp $temp $file || error "$temp $file differ (append2)"
9345 test_155_big_load() {
9346 remote_ost_nodsh && skip "remote OST with nodsh" && return
9347 local temp=$TMP/$tfile
9348 local file=$DIR/$tfile
9351 local cache_size=$(do_facet ost$((MAXI+1)) \
9352 "awk '/cache/ {sum+=\\\$4} END {print sum}' /proc/cpuinfo")
9353 local large_file_size=$((cache_size * 2))
9355 echo "OSS cache size: $cache_size KB"
9356 echo "Large file size: $large_file_size KB"
9358 [ $MAXV -le $large_file_size ] && \
9359 skip_env "max available OST size needs > $large_file_size KB" && \
9362 $SETSTRIPE $file -c 1 -i $MAXI || error "$SETSTRIPE $file failed"
9364 dd if=/dev/urandom of=$temp bs=$large_file_size count=1k || \
9365 error "dd of=$temp bs=$large_file_size count=1k failed"
9368 cancel_lru_locks osc
9369 cmp $temp $file || error "$temp $file differ"
9376 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9378 set_cache writethrough on
9381 run_test 155a "Verify small file correctness: read cache:on write_cache:on"
9384 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9386 set_cache writethrough off
9389 run_test 155b "Verify small file correctness: read cache:on write_cache:off"
9392 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9394 set_cache writethrough on
9397 run_test 155c "Verify small file correctness: read cache:off write_cache:on"
9400 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9402 set_cache writethrough off
9405 run_test 155d "Verify small file correctness: read cache:off write_cache:off"
9408 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9410 set_cache writethrough on
9413 run_test 155e "Verify big file correctness: read cache:on write_cache:on"
9416 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9418 set_cache writethrough off
9421 run_test 155f "Verify big file correctness: read cache:on write_cache:off"
9424 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9426 set_cache writethrough on
9429 run_test 155g "Verify big file correctness: read cache:off write_cache:on"
9432 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9434 set_cache writethrough off
9437 run_test 155h "Verify big file correctness: read cache:off write_cache:off"
9440 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9444 local file="$DIR/$tfile"
9446 [ "$(facet_fstype ost1)" = "zfs" ] &&
9447 skip "LU-1956/LU-2261: stats unimplemented on OSD ZFS" &&
9452 log "Turn on read and write cache"
9454 set_cache writethrough on
9456 log "Write data and read it back."
9457 log "Read should be satisfied from the cache."
9458 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
9460 cancel_lru_locks osc
9461 cat $file >/dev/null
9463 if ! let "AFTER - BEFORE == CPAGES"; then
9464 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
9466 log "cache hits:: before: $BEFORE, after: $AFTER"
9469 log "Read again; it should be satisfied from the cache."
9471 cancel_lru_locks osc
9472 cat $file >/dev/null
9474 if ! let "AFTER - BEFORE == CPAGES"; then
9475 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
9477 log "cache hits:: before: $BEFORE, after: $AFTER"
9481 log "Turn off the read cache and turn on the write cache"
9483 set_cache writethrough on
9485 log "Read again; it should be satisfied from the cache."
9487 cancel_lru_locks osc
9488 cat $file >/dev/null
9490 if ! let "AFTER - BEFORE == CPAGES"; then
9491 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
9493 log "cache hits:: before: $BEFORE, after: $AFTER"
9496 log "Read again; it should not be satisfied from the cache."
9498 cancel_lru_locks osc
9499 cat $file >/dev/null
9501 if ! let "AFTER - BEFORE == 0"; then
9502 error "IN CACHE: before: $BEFORE, after: $AFTER"
9504 log "cache hits:: before: $BEFORE, after: $AFTER"
9507 log "Write data and read it back."
9508 log "Read should be satisfied from the cache."
9509 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
9511 cancel_lru_locks osc
9512 cat $file >/dev/null
9514 if ! let "AFTER - BEFORE == CPAGES"; then
9515 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
9517 log "cache hits:: before: $BEFORE, after: $AFTER"
9520 log "Read again; it should not be satisfied from the cache."
9522 cancel_lru_locks osc
9523 cat $file >/dev/null
9525 if ! let "AFTER - BEFORE == 0"; then
9526 error "IN CACHE: before: $BEFORE, after: $AFTER"
9528 log "cache hits:: before: $BEFORE, after: $AFTER"
9532 log "Turn off read and write cache"
9534 set_cache writethrough off
9536 log "Write data and read it back"
9537 log "It should not be satisfied from the cache."
9539 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
9540 cancel_lru_locks osc
9542 cat $file >/dev/null
9544 if ! let "AFTER - BEFORE == 0"; then
9545 error_ignore 20762 "IN CACHE: before: $BEFORE, after: $AFTER"
9547 log "cache hits:: before: $BEFORE, after: $AFTER"
9551 log "Turn on the read cache and turn off the write cache"
9553 set_cache writethrough off
9555 log "Write data and read it back"
9556 log "It should not be satisfied from the cache."
9558 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
9560 cancel_lru_locks osc
9561 cat $file >/dev/null
9563 if ! let "AFTER - BEFORE == 0"; then
9564 error_ignore 20762 "IN CACHE: before: $BEFORE, after: $AFTER"
9566 log "cache hits:: before: $BEFORE, after: $AFTER"
9569 log "Read again; it should be satisfied from the cache."
9571 cancel_lru_locks osc
9572 cat $file >/dev/null
9574 if ! let "AFTER - BEFORE == CPAGES"; then
9575 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
9577 log "cache hits:: before: $BEFORE, after: $AFTER"
9582 run_test 156 "Verification of tunables ============================"
9586 if [[ $MDSCOUNT -gt 1 ]]; then
9587 error_ignore bz17935 $*
9595 local CL_MASK_PARAM="mdd.$MDT0.changelog_mask"
9597 MASK=$(do_facet $SINGLEMDS $LCTL get_param $CL_MASK_PARAM| grep -c "$1")
9599 if [ $MASK -eq 1 ]; then
9600 do_facet $SINGLEMDS $LCTL set_param $CL_MASK_PARAM="-$1"
9602 do_facet $SINGLEMDS $LCTL set_param $CL_MASK_PARAM="+$1"
9606 changelog_extract_field() {
9612 $LFS changelog $mdt | gawk "/$cltype.*$file$/ {
9613 print gensub(/^.* "$identifier'(\[[^\]]*\]).*$/,"\\1",1)}' |
9618 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9619 remote_mds_nodsh && skip "remote MDS with nodsh" && return
9620 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] ||
9621 { skip "Need MDS version at least 2.2.0"; return; }
9623 local CL_USERS="mdd.$MDT0.changelog_users"
9624 local GET_CL_USERS="do_facet $SINGLEMDS $LCTL get_param -n $CL_USERS"
9625 USER=$(do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_register -n)
9626 echo "Registered as changelog user $USER"
9627 $GET_CL_USERS | grep -q $USER ||
9628 error "User $USER not found in changelog_users"
9631 test_mkdir -p $DIR/$tdir/pics/2008/zachy
9632 touch $DIR/$tdir/pics/2008/zachy/timestamp
9633 cp /etc/hosts $DIR/$tdir/pics/2008/zachy/pic1.jpg
9634 mv $DIR/$tdir/pics/2008/zachy $DIR/$tdir/pics/zach
9635 ln $DIR/$tdir/pics/zach/pic1.jpg $DIR/$tdir/pics/2008/portland.jpg
9636 ln -s $DIR/$tdir/pics/2008/portland.jpg $DIR/$tdir/pics/desktop.jpg
9637 rm $DIR/$tdir/pics/desktop.jpg
9639 $LFS changelog $MDT0 | tail -5
9641 echo "verifying changelog mask"
9642 changelog_chmask "MKDIR"
9643 changelog_chmask "CLOSE"
9645 test_mkdir -p $DIR/$tdir/pics/zach/sofia
9646 echo "zzzzzz" > $DIR/$tdir/pics/zach/file
9648 changelog_chmask "MKDIR"
9649 changelog_chmask "CLOSE"
9651 test_mkdir -p $DIR/$tdir/pics/2008/sofia
9652 echo "zzzzzz" > $DIR/$tdir/pics/zach/file
9654 $LFS changelog $MDT0
9655 MKDIRS=$($LFS changelog $MDT0 | tail -5 | grep -c "MKDIR")
9656 CLOSES=$($LFS changelog $MDT0 | tail -5 | grep -c "CLOSE")
9657 [ $MKDIRS -eq 1 ] || err17935 "MKDIR changelog mask count $DIRS != 1"
9658 [ $CLOSES -eq 1 ] || err17935 "CLOSE changelog mask count $DIRS != 1"
9661 echo "verifying target fid"
9662 fidc=$(changelog_extract_field $MDT0 "CREAT" "timestamp" "t=")
9663 fidf=$($LFS path2fid $DIR/$tdir/pics/zach/timestamp)
9664 [ "$fidc" == "$fidf" ] ||
9665 err17935 "fid in changelog $fidc != file fid $fidf"
9666 echo "verifying parent fid"
9667 fidc=$(changelog_extract_field $MDT0 "CREAT" "timestamp" "p=")
9668 fidf=$($LFS path2fid $DIR/$tdir/pics/zach)
9669 [ "$fidc" == "$fidf" ] ||
9670 err17935 "pfid in changelog $fidc != dir fid $fidf"
9672 USER_REC1=$($GET_CL_USERS | awk "\$1 == \"$USER\" {print \$2}")
9673 $LFS changelog_clear $MDT0 $USER $(($USER_REC1 + 5))
9674 USER_REC2=$($GET_CL_USERS | awk "\$1 == \"$USER\" {print \$2}")
9675 echo "verifying user clear: $(( $USER_REC1 + 5 )) == $USER_REC2"
9676 [ $USER_REC2 == $(($USER_REC1 + 5)) ] ||
9677 err17935 "user index expected $(($USER_REC1 + 5)) is $USER_REC2"
9679 MIN_REC=$($GET_CL_USERS |
9680 awk 'min == "" || $2 < min {min = $2}; END {print min}')
9681 FIRST_REC=$($LFS changelog $MDT0 | head -n1 | awk '{print $1}')
9682 echo "verifying min purge: $(( $MIN_REC + 1 )) == $FIRST_REC"
9683 [ $FIRST_REC == $(($MIN_REC + 1)) ] ||
9684 err17935 "first index should be $(($MIN_REC + 1)) is $FIRST_REC"
9686 # LU-3446 changelog index reset on MDT restart
9687 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
9688 CUR_REC1=$($GET_CL_USERS | head -n1 | cut -f3 -d' ')
9689 $LFS changelog_clear $MDT0 $USER 0
9690 stop $SINGLEMDS || error "Fail to stop MDT."
9691 start $SINGLEMDS $MDT_DEV $MDS_MOUNT_OPTS || error "Fail to start MDT."
9692 CUR_REC2=$($GET_CL_USERS | head -n1 | cut -f3 -d' ')
9693 echo "verifying index survives MDT restart: $CUR_REC1 == $CUR_REC2"
9694 [ $CUR_REC1 == $CUR_REC2 ] ||
9695 err17935 "current index should be $CUR_REC1 is $CUR_REC2"
9697 echo "verifying user deregister"
9698 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister $USER
9699 $GET_CL_USERS | grep -q $USER &&
9700 error "User $USER still in changelog_users"
9702 USERS=$(( $($GET_CL_USERS | wc -l) - 2 ))
9703 if [ $USERS -eq 0 ]; then
9704 LAST_REC1=$($GET_CL_USERS | head -n1 | cut -f3 -d' ')
9705 touch $DIR/$tdir/chloe
9706 LAST_REC2=$($GET_CL_USERS | head -n1 | cut -f3 -d' ')
9707 echo "verify changelogs are off: $LAST_REC1 == $LAST_REC2"
9708 [ $LAST_REC1 == $LAST_REC2 ] || error "changelogs not off"
9710 echo "$USERS other changelog users; can't verify off"
9713 run_test 160a "changelog sanity"
9715 test_160b() { # LU-3587
9716 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9717 remote_mds_nodsh && skip "remote MDS with nodsh" && return
9718 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] ||
9719 { skip "Need MDS version at least 2.2.0"; return; }
9721 local CL_USERS="mdd.$MDT0.changelog_users"
9722 local GET_CL_USERS="do_facet $SINGLEMDS $LCTL get_param -n $CL_USERS"
9723 USER=$(do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_register -n)
9724 echo "Registered as changelog user $USER"
9725 $GET_CL_USERS | grep -q $USER ||
9726 error "User $USER not found in changelog_users"
9728 local LONGNAME1=$(str_repeat a 255)
9729 local LONGNAME2=$(str_repeat b 255)
9732 echo "creating very long named file"
9733 touch $LONGNAME1 || error "create of $LONGNAME1 failed"
9734 echo "moving very long named file"
9735 mv $LONGNAME1 $LONGNAME2
9737 $LFS changelog $MDT0 | grep RENME
9739 echo "deregistering $USER"
9740 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister $USER
9744 run_test 160b "Verify that very long rename doesn't crash in changelog"
9748 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9751 local USER=$(do_facet $SINGLEMDS $LCTL --device $MDT0 \
9752 changelog_register -n)
9756 $MCREATE $DIR/$tdir/foo_160c
9757 changelog_chmask "TRUNC"
9758 $TRUNCATE $DIR/$tdir/foo_160c 200
9759 changelog_chmask "TRUNC"
9760 $TRUNCATE $DIR/$tdir/foo_160c 199
9761 $LFS changelog $MDT0
9762 TRUNCS=$($LFS changelog $MDT0 | tail -5 | grep -c "TRUNC")
9763 [ $TRUNCS -eq 1 ] || err17935 "TRUNC changelog mask count $TRUNCS != 1"
9764 $LFS changelog_clear $MDT0 $USER 0
9766 # Deregistration step
9767 echo "deregistering $USER"
9768 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister $USER
9770 run_test 160c "verify that changelog log catch the truncate event"
9773 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9774 test_mkdir -p $DIR/$tdir
9775 cp /etc/hosts $DIR/$tdir/$tfile
9776 test_mkdir $DIR/$tdir/foo1
9777 test_mkdir $DIR/$tdir/foo2
9778 ln $DIR/$tdir/$tfile $DIR/$tdir/foo1/sofia
9779 ln $DIR/$tdir/$tfile $DIR/$tdir/foo2/zachary
9780 ln $DIR/$tdir/$tfile $DIR/$tdir/foo1/luna
9781 ln $DIR/$tdir/$tfile $DIR/$tdir/foo2/thor
9782 local FID=$($LFS path2fid $DIR/$tdir/$tfile | tr -d '[]')
9783 if [ "$($LFS fid2path $DIR $FID | wc -l)" != "5" ]; then
9784 $LFS fid2path $DIR $FID
9785 err17935 "bad link ea"
9788 rm $DIR/$tdir/foo2/zachary
9790 rm $DIR/$tdir/foo2/thor
9792 rm $DIR/$tdir/$tfile
9794 mv $DIR/$tdir/foo1/sofia $DIR/$tdir/foo2/maggie
9795 if [ "$($LFS fid2path $FSNAME --link 1 $FID)" != "$tdir/foo2/maggie" ]
9797 $LFS fid2path $DIR $FID
9798 err17935 "bad link rename"
9800 rm $DIR/$tdir/foo2/maggie
9803 local longname=filename_avg_len_is_thirty_two_
9804 createmany -l$DIR/$tdir/foo1/luna $DIR/$tdir/foo2/$longname 1000 ||
9805 error "failed to hardlink many files"
9806 links=$($LFS fid2path $DIR $FID | wc -l)
9807 echo -n "${links}/1000 links in link EA"
9808 [[ $links -gt 60 ]] ||
9809 err17935 "expected at least 60 links in link EA"
9810 unlinkmany $DIR/$tdir/foo2/$longname 1000 ||
9811 error "failed to unlink many hardlinks"
9813 run_test 161a "link ea sanity"
9816 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9817 [ $MDSCOUNT -lt 2 ] &&
9818 skip "skipping remote directory test" && return
9820 local remote_dir=$DIR/$tdir/remote_dir
9823 $LFS mkdir -i $MDTIDX $remote_dir ||
9824 error "create remote directory failed"
9826 cp /etc/hosts $remote_dir/$tfile
9827 mkdir -p $remote_dir/foo1
9828 mkdir -p $remote_dir/foo2
9829 ln $remote_dir/$tfile $remote_dir/foo1/sofia
9830 ln $remote_dir/$tfile $remote_dir/foo2/zachary
9831 ln $remote_dir/$tfile $remote_dir/foo1/luna
9832 ln $remote_dir/$tfile $remote_dir/foo2/thor
9834 local FID=$($LFS path2fid $remote_dir/$tfile | tr -d '[' |
9836 if [ "$($LFS fid2path $DIR $FID | wc -l)" != "5" ]; then
9837 $LFS fid2path $DIR $FID
9838 err17935 "bad link ea"
9841 rm $remote_dir/foo2/zachary
9843 rm $remote_dir/foo2/thor
9845 rm $remote_dir/$tfile
9847 mv $remote_dir/foo1/sofia $remote_dir/foo2/maggie
9848 local link_path=$($LFS fid2path $FSNAME --link 1 $FID)
9849 if [ "$DIR/$link_path" != "$remote_dir/foo2/maggie" ]; then
9850 $LFS fid2path $DIR $FID
9851 err17935 "bad link rename"
9853 rm $remote_dir/foo2/maggie
9856 local longname=filename_avg_len_is_thirty_two_
9857 createmany -l$remote_dir/foo1/luna $remote_dir/foo2/$longname 1000 ||
9858 error "failed to hardlink many files"
9859 links=$($LFS fid2path $DIR $FID | wc -l)
9860 echo -n "${links}/1000 links in link EA"
9861 [[ ${links} -gt 60 ]] ||
9862 err17935 "expected at least 60 links in link EA"
9863 unlinkmany $remote_dir/foo2/$longname 1000 ||
9864 error "failed to unlink many hardlinks"
9866 run_test 161b "link ea sanity under remote directory"
9869 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9870 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.1.5) ]] &&
9871 skip "Need MDS version at least 2.1.5" && return
9873 # define CLF_RENAME_LAST 0x0001
9874 # rename overwrite a target having nlink = 1 (changelog flag 0x1)
9875 local USER=$(do_facet $SINGLEMDS $LCTL --device $MDT0 \
9876 changelog_register -n)
9879 touch $DIR/$tdir/foo_161c
9880 touch $DIR/$tdir/bar_161c
9881 mv -f $DIR/$tdir/foo_161c $DIR/$tdir/bar_161c
9882 $LFS changelog $MDT0 | grep RENME
9883 local flags=$($LFS changelog $MDT0 | grep RENME | tail -1 | \
9885 $LFS changelog_clear $MDT0 $USER 0
9886 if [ x$flags != "x0x1" ]; then
9887 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister \
9889 error "flag $flags is not 0x1"
9891 echo "rename overwrite a target having nlink = 1," \
9892 "changelog record has flags of $flags"
9894 # rename overwrite a target having nlink > 1 (changelog flag 0x0)
9895 touch $DIR/$tdir/foo_161c
9896 touch $DIR/$tdir/bar_161c
9897 ln $DIR/$tdir/bar_161c $DIR/$tdir/foobar_161c
9898 mv -f $DIR/$tdir/foo_161c $DIR/$tdir/bar_161c
9899 $LFS changelog $MDT0 | grep RENME
9900 flags=$($LFS changelog $MDT0 | grep RENME | tail -1 | cut -f5 -d' ')
9901 $LFS changelog_clear $MDT0 $USER 0
9902 if [ x$flags != "x0x0" ]; then
9903 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister \
9905 error "flag $flags is not 0x0"
9907 echo "rename overwrite a target having nlink > 1," \
9908 "changelog record has flags of $flags"
9910 # rename doesn't overwrite a target (changelog flag 0x0)
9911 touch $DIR/$tdir/foo_161c
9912 mv -f $DIR/$tdir/foo_161c $DIR/$tdir/foo2_161c
9913 $LFS changelog $MDT0 | grep RENME
9914 flags=$($LFS changelog $MDT0 | grep RENME | tail -1 | cut -f5 -d' ')
9915 $LFS changelog_clear $MDT0 $USER 0
9916 if [ x$flags != "x0x0" ]; then
9917 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister \
9919 error "flag $flags is not 0x0"
9921 echo "rename doesn't overwrite a target," \
9922 "changelog record has flags of $flags"
9924 # define CLF_UNLINK_LAST 0x0001
9925 # unlink a file having nlink = 1 (changelog flag 0x1)
9926 rm -f $DIR/$tdir/foo2_161c
9927 $LFS changelog $MDT0 | grep UNLNK
9928 flags=$($LFS changelog $MDT0 | grep UNLNK | tail -1 | cut -f5 -d' ')
9929 $LFS changelog_clear $MDT0 $USER 0
9930 if [ x$flags != "x0x1" ]; then
9931 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister \
9933 error "flag $flags is not 0x1"
9935 echo "unlink a file having nlink = 1," \
9936 "changelog record has flags of $flags"
9938 # unlink a file having nlink > 1 (changelog flag 0x0)
9939 ln -f $DIR/$tdir/bar_161c $DIR/$tdir/foobar_161c
9940 rm -f $DIR/$tdir/foobar_161c
9941 $LFS changelog $MDT0 | grep UNLNK
9942 flags=$($LFS changelog $MDT0 | grep UNLNK | tail -1 | cut -f5 -d' ')
9943 $LFS changelog_clear $MDT0 $USER 0
9944 if [ x$flags != "x0x0" ]; then
9945 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister \
9947 error "flag $flags is not 0x0"
9949 echo "unlink a file having nlink > 1," \
9950 "changelog record has flags of $flags"
9951 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister $USER
9953 run_test 161c "check CL_RENME[UNLINK] changelog record flags"
9960 local path=$(${LFS} fid2path $*)
9963 if [ $RC -ne 0 ]; then
9964 err17935 "path looked up of $expected failed. Error $RC"
9966 elif [ "${path}" != "${expected}" ]; then
9967 err17935 "path looked up \"${path}\" instead of \"${expected}\""
9970 echo "fid $fid resolves to path $path (expected $expected)"
9974 # Make changes to filesystem
9975 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9976 test_mkdir -p $DIR/$tdir/d2
9977 touch $DIR/$tdir/d2/$tfile
9978 touch $DIR/$tdir/d2/x1
9979 touch $DIR/$tdir/d2/x2
9980 test_mkdir -p $DIR/$tdir/d2/a/b/c
9981 test_mkdir -p $DIR/$tdir/d2/p/q/r
9983 FID=$($LFS path2fid $DIR/$tdir/d2/$tfile | tr -d '[]')
9984 check_path "$tdir/d2/$tfile" $FSNAME $FID --link 0
9987 ln -s $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/p/q/r/slink
9988 FID=$($LFS path2fid $DIR/$tdir/d2/p/q/r/slink | tr -d '[]')
9989 check_path "$tdir/d2/p/q/r/slink" $FSNAME $FID --link 0
9991 # softlink to wrong file
9992 ln -s /this/is/garbage $DIR/$tdir/d2/p/q/r/slink.wrong
9993 FID=$($LFS path2fid $DIR/$tdir/d2/p/q/r/slink.wrong | tr -d '[]')
9994 check_path "$tdir/d2/p/q/r/slink.wrong" $FSNAME $FID --link 0
9997 ln $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/p/q/r/hlink
9998 mv $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/a/b/c/new_file
9999 FID=$($LFS path2fid $DIR/$tdir/d2/a/b/c/new_file | tr -d '[]')
10000 # fid2path dir/fsname should both work
10001 check_path "$tdir/d2/a/b/c/new_file" $FSNAME $FID --link 1
10002 check_path "$DIR/$tdir/d2/p/q/r/hlink" $DIR $FID --link 0
10004 # hardlink count: check that there are 2 links
10005 # Doesnt work with CMD yet: 17935
10006 ${LFS} fid2path $DIR $FID | wc -l | grep -q 2 || \
10007 err17935 "expected 2 links"
10009 # hardlink indexing: remove the first link
10010 rm $DIR/$tdir/d2/p/q/r/hlink
10011 check_path "$tdir/d2/a/b/c/new_file" $FSNAME $FID --link 0
10015 run_test 162 "path lookup sanity"
10018 # do directio so as not to populate the page cache
10019 log "creating a 10 Mb file"
10020 $MULTIOP $DIR/$tfile oO_CREAT:O_DIRECT:O_RDWR:w$((10*1048576))c || error "multiop failed while creating a file"
10021 log "starting reads"
10022 dd if=$DIR/$tfile of=/dev/null bs=4096 &
10023 log "truncating the file"
10024 $MULTIOP $DIR/$tfile oO_TRUNC:c || error "multiop failed while truncating the file"
10026 kill %+ || true # reads might have finished
10027 echo "wait until dd is finished"
10029 log "removing the temporary file"
10030 rm -rf $DIR/$tfile || error "tmp file removal failed"
10032 run_test 169 "parallel read and truncate should not deadlock"
10035 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10036 $LCTL clear # bug 18514
10037 $LCTL debug_daemon start $TMP/${tfile}_log_good
10039 $LCTL debug_daemon stop
10040 sed -e "s/^...../a/g" $TMP/${tfile}_log_good > $TMP/${tfile}_log_bad ||
10041 error "sed failed to read log_good"
10043 $LCTL debug_daemon start $TMP/${tfile}_log_good
10045 $LCTL debug_daemon stop
10047 $LCTL df $TMP/${tfile}_log_bad > $TMP/${tfile}_log_bad.out 2>&1 ||
10048 error "lctl df log_bad failed"
10050 local bad_line=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $9}')
10051 local good_line1=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $5}')
10053 $LCTL df $TMP/${tfile}_log_good > $TMP/${tfile}_log_good.out 2>&1
10054 local good_line2=$(tail -n 1 $TMP/${tfile}_log_good.out | awk '{print $5}')
10056 [ "$bad_line" ] && [ "$good_line1" ] && [ "$good_line2" ] ||
10057 error "bad_line good_line1 good_line2 are empty"
10059 cat $TMP/${tfile}_log_good >> $TMP/${tfile}_logs_corrupt
10060 cat $TMP/${tfile}_log_bad >> $TMP/${tfile}_logs_corrupt
10061 cat $TMP/${tfile}_log_good >> $TMP/${tfile}_logs_corrupt
10063 $LCTL df $TMP/${tfile}_logs_corrupt > $TMP/${tfile}_log_bad.out 2>&1
10064 local bad_line_new=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $9}')
10065 local good_line_new=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $5}')
10067 [ "$bad_line_new" ] && [ "$good_line_new" ] ||
10068 error "bad_line_new good_line_new are empty"
10070 local expected_good=$((good_line1 + good_line2*2))
10072 rm -f $TMP/${tfile}*
10073 # LU-231, short malformed line may not be counted into bad lines
10074 if [ $bad_line -ne $bad_line_new ] &&
10075 [ $bad_line -ne $((bad_line_new - 1)) ]; then
10076 error "expected $bad_line bad lines, but got $bad_line_new"
10080 if [ $expected_good -ne $good_line_new ]; then
10081 error "expected $expected_good good lines, but got $good_line_new"
10086 run_test 170 "test lctl df to handle corrupted log ====================="
10088 test_171() { # bug20592
10089 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10090 #define OBD_FAIL_PTLRPC_DUMP_LOG 0x50e
10091 $LCTL set_param fail_loc=0x50e
10092 $LCTL set_param fail_val=3000
10093 multiop_bg_pause $DIR/$tfile O_s || true
10095 kill -USR1 $MULTIPID
10099 if dmesg | grep "recursive fault"; then
10100 error "caught a recursive fault"
10102 $LCTL set_param fail_loc=0
10105 run_test 171 "test libcfs_debug_dumplog_thread stuck in do_exit() ======"
10107 # it would be good to share it with obdfilter-survey/libecho code
10108 setup_obdecho_osc () {
10111 local obdfilter_name=$2
10112 echo "Creating new osc for $obdfilter_name on $ost_nid"
10113 # make sure we can find loopback nid
10114 $LCTL add_uuid $ost_nid $ost_nid >/dev/null 2>&1
10116 [ $rc -eq 0 ] && { $LCTL attach osc ${obdfilter_name}_osc \
10117 ${obdfilter_name}_osc_UUID || rc=2; }
10118 [ $rc -eq 0 ] && { $LCTL --device ${obdfilter_name}_osc setup \
10119 ${obdfilter_name}_UUID $ost_nid || rc=3; }
10123 cleanup_obdecho_osc () {
10124 local obdfilter_name=$1
10125 $LCTL --device ${obdfilter_name}_osc cleanup >/dev/null
10126 $LCTL --device ${obdfilter_name}_osc detach >/dev/null
10133 local pages=${3:-64}
10138 local obd_size=$(get_obd_size $node $OBD)
10139 local page_size=$(get_page_size $node)
10140 if [[ -n "$obd_size" ]]; then
10141 local new_count=$((obd_size / (pages * page_size / 1024)))
10142 [[ $new_count -ge $count ]] || count=$new_count
10145 do_facet $node "$LCTL attach echo_client ec ec_uuid" || rc=1
10146 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec setup $OBD" ||
10148 if [ $rc -eq 0 ]; then
10149 id=$(do_facet $node "$LCTL --device ec create 1" | awk '/object id/ {print $6}')
10150 [ ${PIPESTATUS[0]} -eq 0 -a -n "$id" ] || rc=3
10152 echo "New object id is $id"
10153 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec getattr $id" ||
10155 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec " \
10156 "test_brw $count w v $pages $id" || rc=4; }
10157 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec destroy $id 1" ||
10159 [ $rc -eq 0 -o $rc -gt 2 ] && { do_facet $node "$LCTL --device ec " \
10160 "cleanup" || rc=5; }
10161 [ $rc -eq 0 -o $rc -gt 1 ] && { do_facet $node "$LCTL --device ec " \
10162 "detach" || rc=6; }
10163 [ $rc -ne 0 ] && echo "obecho_create_test failed: $rc"
10168 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10169 remote_ost_nodsh && skip "remote OST with nodsh" && return
10171 local rmmod_local=0
10173 if ! module_loaded obdecho; then
10174 load_module obdecho/obdecho
10178 local osc=$($LCTL dl | grep -v mdt | awk '$3 == "osc" {print $4; exit}')
10179 local host=$(lctl get_param -n osc.$osc.import |
10180 awk '/current_connection:/ {print $2}' )
10181 local target=$(lctl get_param -n osc.$osc.import |
10182 awk '/target:/ {print $2}' )
10183 target=${target%_UUID}
10185 [[ -n $target ]] && { setup_obdecho_osc $host $target || rc=1; } || rc=1
10186 [ $rc -eq 0 ] && { obdecho_test ${target}_osc client || rc=2; }
10187 [[ -n $target ]] && cleanup_obdecho_osc $target
10188 [ $rmmod_local -eq 1 ] && rmmod obdecho
10191 run_test 180a "test obdecho on osc"
10194 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10195 remote_ost_nodsh && skip "remote OST with nodsh" && return
10197 local rmmod_remote=0
10199 do_facet ost1 "lsmod | grep -q obdecho || " \
10200 "{ insmod ${LUSTRE}/obdecho/obdecho.ko || " \
10201 "modprobe obdecho; }" && rmmod_remote=1
10202 target=$(do_facet ost1 $LCTL dl | awk '/obdfilter/ {print $4;exit}')
10203 [[ -n $target ]] && { obdecho_test $target ost1 || rc=1; }
10204 [ $rmmod_remote -eq 1 ] && do_facet ost1 "rmmod obdecho"
10207 run_test 180b "test obdecho directly on obdfilter"
10209 test_180c() { # LU-2598
10210 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10211 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.0) ]] &&
10212 skip "Need MDS version at least 2.4.0" && return
10215 local rmmod_remote=false
10216 local pages=16384 # 64MB bulk I/O RPC size
10219 do_rpc_nodes $(facet_active_host ost1) load_module obdecho/obdecho &&
10220 rmmod_remote=true || error "failed to load module obdecho"
10222 target=$(do_facet ost1 $LCTL dl | awk '/obdfilter/ { print $4 }' |
10224 if [ -n "$target" ]; then
10225 obdecho_test "$target" ost1 "$pages" || rc=${PIPESTATUS[0]}
10227 echo "there is no obdfilter target on ost1"
10230 $rmmod_remote && do_facet ost1 "rmmod obdecho" || true
10233 run_test 180c "test huge bulk I/O size on obdfilter, don't LASSERT"
10235 test_181() { # bug 22177
10236 test_mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
10237 # create enough files to index the directory
10238 createmany -o $DIR/$tdir/foobar 4000
10239 # print attributes for debug purpose
10242 multiop_bg_pause $DIR/$tdir D_Sc || return 1
10244 # remove the files & current working dir
10245 unlinkmany $DIR/$tdir/foobar 4000
10247 kill -USR1 $MULTIPID
10249 stat $DIR/$tdir && error "open-unlinked dir was not removed!"
10252 run_test 181 "Test open-unlinked dir ========================"
10255 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10256 # disable MDC RPC lock wouldn't crash client
10260 mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
10261 #define OBD_FAIL_MDC_RPCS_SEM 0x804
10262 $LCTL set_param fail_loc=0x804
10264 for (( i=0; i < $tcount; i++ )) ; do
10265 mkdir $DIR/$tdir/$i
10266 createmany -o $DIR/$tdir/$i/f- $fcount &
10270 for (( i=0; i < $tcount; i++ )) ; do
10271 unlinkmany $DIR/$tdir/$i/f- $fcount &
10277 $LCTL set_param fail_loc=0
10279 run_test 182 "Disable MDC RPCs semaphore wouldn't crash client ================"
10281 test_183() { # LU-2275
10282 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.3.56) ]] &&
10283 skip "Need MDS version at least 2.3.56" && return
10285 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10286 mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
10287 echo aaa > $DIR/$tdir/$tfile
10289 #define OBD_FAIL_MDS_NEGATIVE_POSITIVE 0x148
10290 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x148
10292 ls -l $DIR/$tdir && error "ls succeeded, should have failed"
10293 cat $DIR/$tdir/$tfile && error "cat succeeded, should have failed"
10295 do_facet $SINGLEMDS $LCTL set_param fail_loc=0
10297 # Flush negative dentry cache
10298 touch $DIR/$tdir/$tfile
10300 # We are not checking for any leaked references here, they'll
10301 # become evident next time we do cleanup with module unload.
10304 run_test 183 "No crash or request leak in case of strange dispositions ========"
10306 # test suite 184 is for LU-2016, LU-2017
10308 check_swap_layouts_support && return 0
10310 dir0=$DIR/$tdir/$testnum
10311 test_mkdir -p $dir0 || error "creating dir $dir0"
10316 $SETSTRIPE -c1 $file1
10318 $SETSTRIPE -c2 $file2
10320 gen1=$($GETSTRIPE -g $file1)
10321 gen2=$($GETSTRIPE -g $file2)
10323 $LFS swap_layouts $file1 $file2 || error "swap of file layout failed"
10324 gen=$($GETSTRIPE -g $file1)
10325 [[ $gen1 != $gen ]] ||
10326 "Layout generation on $file1 does not change"
10327 gen=$($GETSTRIPE -g $file2)
10328 [[ $gen2 != $gen ]] ||
10329 "Layout generation on $file2 does not change"
10331 cmp $ref1 $file2 || error "content compare failed ($ref1 != $file2)"
10332 cmp $ref2 $file1 || error "content compare failed ($ref2 != $file1)"
10334 run_test 184a "Basic layout swap"
10337 check_swap_layouts_support && return 0
10339 dir0=$DIR/$tdir/$testnum
10340 mkdir -p $dir0 || error "creating dir $dir0"
10347 $SETSTRIPE -c1 $file1
10348 $SETSTRIPE -c2 $file2
10349 $SETSTRIPE -c1 $file3
10350 chown $RUNAS_ID $file3
10351 gen1=$($GETSTRIPE -g $file1)
10352 gen2=$($GETSTRIPE -g $file2)
10354 $LFS swap_layouts $dir1 $dir2 &&
10355 error "swap of directories layouts should fail"
10356 $LFS swap_layouts $dir1 $file1 &&
10357 error "swap of directory and file layouts should fail"
10358 $RUNAS $LFS swap_layouts $file1 $file2 &&
10359 error "swap of file we cannot write should fail"
10360 $LFS swap_layouts $file1 $file3 &&
10361 error "swap of file with different owner should fail"
10362 /bin/true # to clear error code
10364 run_test 184b "Forbidden layout swap (will generate errors)"
10367 check_swap_layouts_support && return 0
10369 local dir0=$DIR/$tdir/$testnum
10370 mkdir -p $dir0 || error "creating dir $dir0"
10372 local ref1=$dir0/ref1
10373 local ref2=$dir0/ref2
10374 local file1=$dir0/file1
10375 local file2=$dir0/file2
10376 # create a file large enough for the concurent test
10377 dd if=/dev/urandom of=$ref1 bs=1M count=$((RANDOM % 50 + 20))
10378 dd if=/dev/urandom of=$ref2 bs=1M count=$((RANDOM % 50 + 20))
10379 echo "ref file size: ref1($(stat -c %s $ref1))," \
10380 "ref2($(stat -c %s $ref2))"
10383 dd if=$ref1 of=$file1 bs=16k &
10386 # Make sure dd starts to copy file
10387 while [ ! -f $file1 ]; do sleep 0.1; done
10389 $LFS swap_layouts $file1 $file2
10392 [[ $? == 0 ]] || error "concurrent write on $file1 failed"
10393 [[ $rc == 0 ]] || error "swap of $file1 and $file2 failed"
10395 # how many bytes copied before swapping layout
10396 local copied=$(stat -c %s $file2)
10397 local remaining=$(stat -c %s $ref1)
10398 remaining=$((remaining - copied))
10399 echo "Copied $copied bytes before swapping layout..."
10401 cmp -n $copied $file1 $ref2 | grep differ &&
10402 error "Content mismatch [0, $copied) of ref2 and file1"
10403 cmp -n $copied $file2 $ref1 ||
10404 error "Content mismatch [0, $copied) of ref1 and file2"
10405 cmp -i $copied:$copied -n $remaining $file1 $ref1 ||
10406 error "Content mismatch [$copied, EOF) of ref1 and file1"
10409 rm -f $ref1 $ref2 $file1 $file2
10411 run_test 184c "Concurrent write and layout swap"
10414 check_swap_layouts_support && return 0
10415 [ -z "$(which getfattr 2>/dev/null)" ] &&
10416 skip "no getfattr command" && return 0
10418 local file1=$DIR/$tdir/$tfile-1
10419 local file2=$DIR/$tdir/$tfile-2
10420 local file3=$DIR/$tdir/$tfile-3
10424 mkdir -p $DIR/$tdir
10425 touch $file1 || error "create $file1 failed"
10426 $OPENFILE -f O_CREAT:O_LOV_DELAY_CREATE $file2 ||
10427 error "create $file2 failed"
10428 $OPENFILE -f O_CREAT:O_LOV_DELAY_CREATE $file3 ||
10429 error "create $file3 failed"
10430 lovea1=$($LFS getstripe $file1 | sed 1d)
10432 $LFS swap_layouts $file2 $file3 ||
10433 error "swap $file2 $file3 layouts failed"
10434 $LFS swap_layouts $file1 $file2 ||
10435 error "swap $file1 $file2 layouts failed"
10437 lovea2=$($LFS getstripe $file2 | sed 1d)
10438 [ "$lovea1" == "$lovea2" ] || error "lovea $lovea1 != $lovea2"
10440 lovea1=$(getfattr -n trusted.lov $file1 | grep ^trusted)
10441 [[ -z "$lovea1" ]] || error "$file1 shouldn't have lovea"
10443 run_test 184d "allow stripeless layouts swap"
10446 test_185() { # LU-2441
10447 # LU-3553 - no volatile file support in old servers
10448 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.3.60) ]] ||
10449 { skip "Need MDS version at least 2.3.60"; return 0; }
10451 mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
10452 touch $DIR/$tdir/spoo
10453 local mtime1=$(stat -c "%Y" $DIR/$tdir)
10454 local fid=$($MULTIOP $DIR/$tdir VFw4096c) ||
10455 error "cannot create/write a volatile file"
10456 $CHECKSTAT -t file $MOUNT/.lustre/fid/$fid 2>/dev/null &&
10457 error "FID is still valid after close"
10459 multiop_bg_pause $DIR/$tdir vVw4096_c
10466 # assume that the next FID for this client is sequential, since stdout
10467 # is unfortunately eaten by multiop_bg_pause
10468 local n=$((${fidv[1]} + 1))
10469 local next_fid="${fidv[0]}:$(printf "0x%x" $n):${fidv[2]}"
10470 $CHECKSTAT -t file $MOUNT/.lustre/fid/$next_fid ||
10471 error "FID is missing before close"
10472 kill -USR1 $multi_pid
10473 # 1 second delay, so if mtime change we will see it
10475 local mtime2=$(stat -c "%Y" $DIR/$tdir)
10476 [[ $mtime1 == $mtime2 ]] || error "mtime has changed"
10478 run_test 185 "Volatile file support"
10481 local dir0=$DIR/$tdir/$testnum
10482 mkdir -p $dir0 || error "creating dir $dir0"
10484 local file=$dir0/file1
10485 dd if=/dev/urandom of=$file count=10 bs=1M conv=fsync
10486 local dv1=$($LFS data_version $file)
10487 dd if=/dev/urandom of=$file seek=10 count=1 bs=1M conv=fsync
10488 local dv2=$($LFS data_version $file)
10489 [[ $dv1 != $dv2 ]] ||
10490 error "data version did not change on write $dv1 == $dv2"
10495 run_test 187a "Test data version change"
10498 local dir0=$DIR/$tdir/$testnum
10499 mkdir -p $dir0 || error "creating dir $dir0"
10501 declare -a DV=$($MULTIOP $dir0 Vw1000xYw1000xY | cut -f3 -d" ")
10502 [[ ${DV[0]} != ${DV[1]} ]] ||
10503 error "data version did not change on write"\
10504 " ${DV[0]} == ${DV[1]}"
10509 run_test 187b "Test data version change on volatile file"
10512 check_file_in_pool()
10517 local res=$($GETSTRIPE $file | grep 0x | cut -f2)
10520 for t in $tlist ; do
10521 [ "$i" -eq "$t" ] && continue 2
10524 echo "pool list: $tlist"
10525 echo "striping: $res"
10526 error_noexit "$file not allocated in $pool"
10533 echo "Creating new pool"
10536 create_pool $FSNAME.$pool ||
10537 { error_noexit "No pool created, result code $?"; return 1; }
10538 [ $($LFS pool_list $FSNAME | grep -c $pool) -eq 1 ] ||
10539 { error_noexit "$pool not in lfs pool_list"; return 2; }
10542 pool_add_targets() {
10543 echo "Adding targets to pool"
10549 local list=$(seq $first $step $last)
10551 local t=$(for i in $list; do printf "$FSNAME-OST%04x_UUID " $i; done)
10552 do_facet mgs $LCTL pool_add \
10553 $FSNAME.$pool $FSNAME-OST[$first-$last/$step]
10554 wait_update $HOSTNAME "lctl get_param -n lov.$FSNAME-*.pools.$pool \
10555 | sort -u | tr '\n' ' ' " "$t" || {
10556 error_noexit "Add to pool failed"
10559 local lfscount=$($LFS pool_list $FSNAME.$pool | grep -c "\-OST")
10560 local addcount=$(((last - first) / step + 1))
10561 [ $lfscount -eq $addcount ] || {
10562 error_noexit "lfs pool_list bad ost count" \
10563 "$lfscount != $addcount"
10571 echo "Setting pool on directory $tdir"
10573 $SETSTRIPE -c 2 -p $pool $tdir && return 0
10575 error_noexit "Cannot set pool $pool to $tdir"
10582 echo "Checking pool on directory $tdir"
10584 local res=$($GETSTRIPE --pool $tdir | sed "s/\s*$//")
10585 [ "$res" = "$pool" ] && return 0
10587 error_noexit "Pool on '$tdir' is '$res', not '$pool'"
10591 pool_dir_rel_path() {
10592 echo "Testing relative path works well"
10597 mkdir -p $root/$tdir/$tdir
10599 pool_set_dir $pool $tdir || return 1
10600 pool_set_dir $pool ./$tdir || return 2
10601 pool_set_dir $pool ../$tdir || return 3
10602 pool_set_dir $pool ../$tdir/$tdir || return 4
10603 rm -rf $tdir; cd - > /dev/null
10606 pool_alloc_files() {
10607 echo "Checking files allocation from directory pool"
10614 for i in $(seq -w 1 $count)
10616 local file=$tdir/file-$i
10618 check_file_in_pool $file $pool "$tlist" || \
10619 failed=$((failed + 1))
10621 [ "$failed" = 0 ] && return 0
10623 error_noexit "$failed files not allocated in $pool"
10627 pool_create_files() {
10628 echo "Creating files in pool"
10636 for i in $(seq -w 1 $count)
10638 local file=$tdir/spoo-$i
10639 $SETSTRIPE -p $pool $file
10640 check_file_in_pool $file $pool "$tlist" || \
10641 failed=$((failed + 1))
10643 [ "$failed" = 0 ] && return 0
10645 error_noexit "$failed files not allocated in $pool"
10650 echo "Checking 'lfs df' output"
10653 local t=$($LCTL get_param -n lov.$FSNAME-clilov-*.pools.$pool |
10655 local res=$($LFS df --pool $FSNAME.$pool |
10657 grep "$FSNAME-OST" |
10659 [ "$res" = "$t" ] && return 0
10661 error_noexit "Pools OSTs '$t' is not '$res' that lfs df reports"
10665 pool_file_rel_path() {
10666 echo "Creating files in a pool with relative pathname"
10671 { error_noexit "unable to create $tdir"; return 1 ; }
10672 local file="/..$tdir/$tfile-1"
10673 $SETSTRIPE -p $pool $file ||
10674 { error_noexit "unable to create $file" ; return 2 ; }
10677 $SETSTRIPE -p $pool $tfile-2 || {
10678 error_noexit "unable to create $tfile-2 in $tdir"
10683 pool_remove_first_target() {
10684 echo "Removing first target from a pool"
10687 local pname="lov.$FSNAME-*.pools.$pool"
10688 local t=$($LCTL get_param -n $pname | head -n1)
10689 do_facet mgs $LCTL pool_remove $FSNAME.$pool $t
10690 wait_update $HOSTNAME "lctl get_param -n $pname | grep $t" "" || {
10691 error_noexit "$t not removed from $FSNAME.$pool"
10696 pool_remove_all_targets() {
10697 echo "Removing all targets from pool"
10700 local pname="lov.$FSNAME-*.pools.$pool"
10701 for t in $($LCTL get_param -n $pname | sort -u)
10703 do_facet mgs $LCTL pool_remove $FSNAME.$pool $t
10705 wait_update $HOSTNAME "lctl get_param -n $pname" "" || {
10706 error_noexit "Pool $FSNAME.$pool cannot be drained"
10709 # striping on an empty/nonexistant pool should fall back
10710 # to "pool of everything"
10712 error_noexit "failed to use fallback striping for empty pool"
10715 # setstripe on an empty pool should fail
10716 $SETSTRIPE -p $pool $file 2>/dev/null && {
10717 error_noexit "expected failure when creating file" \
10725 echo "Destroying pool"
10729 do_facet mgs $LCTL pool_destroy $FSNAME.$pool
10732 # striping on an empty/nonexistant pool should fall back
10733 # to "pool of everything"
10735 error_noexit "failed to use fallback striping for missing pool"
10738 # setstripe on an empty pool should fail
10739 $SETSTRIPE -p $pool $file 2>/dev/null && {
10740 error_noexit "expected failure when creating file" \
10741 "with missing pool"
10745 # get param should return err once pool is gone
10746 if wait_update $HOSTNAME "lctl get_param -n \
10747 lov.$FSNAME-*.pools.$pool 2>/dev/null || echo foo" "foo"
10749 remove_pool_from_list $FSNAME.$pool
10752 error_noexit "Pool $FSNAME.$pool is not destroyed"
10757 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10758 remote_mgs_nodsh && skip "remote MGS with nodsh" && return
10760 local POOL=${POOL:-cea1}
10761 local POOL_ROOT=${POOL_ROOT:-$DIR/d200.pools}
10762 local POOL_DIR_NAME=${POOL_DIR_NAME:-dir_tst}
10765 local last_ost=$(($OSTCOUNT - 1))
10767 local ost_list=$(seq $first_ost $ost_step $last_ost)
10768 local ost_range="$first_ost $last_ost $ost_step"
10769 local test_path=$POOL_ROOT/$POOL_DIR_NAME
10770 local file_dir=$POOL_ROOT/file_tst
10774 # former test_200a test_200b
10775 pool_add $POOL || { rc=$? ; break; }
10776 pool_add_targets $POOL $ost_range || { rc=$? ; break; }
10777 # former test_200c test_200d
10778 mkdir -p $test_path
10779 pool_set_dir $POOL $test_path || { rc=$? ; break; }
10780 pool_check_dir $POOL $test_path || { rc=$? ; break; }
10781 pool_dir_rel_path $POOL $POOL_DIR_NAME $POOL_ROOT \
10782 || { rc=$? ; break; }
10783 # former test_200e test_200f
10784 local files=$((OSTCOUNT*3))
10785 pool_alloc_files $POOL $test_path $files "$ost_list" \
10786 || { rc=$? ; break; }
10787 pool_create_files $POOL $file_dir $files "$ost_list" \
10788 || { rc=$? ; break; }
10789 # former test_200g test_200h
10790 pool_lfs_df $POOL || { rc=$? ; break; }
10791 pool_file_rel_path $POOL $test_path || { rc=$? ; break; }
10793 # former test_201a test_201b test_201c
10794 pool_remove_first_target $POOL || { rc=$? ; break; }
10796 local f=$test_path/$tfile
10797 pool_remove_all_targets $POOL $f || { rc=$? ; break; }
10798 pool_remove $POOL $f || { rc=$? ; break; }
10805 run_test 200 "OST pools"
10807 # usage: default_attr <count | size | offset>
10809 $LCTL get_param -n lov.$FSNAME-clilov-\*.stripe${1}
10812 # usage: check_default_stripe_attr
10813 check_default_stripe_attr() {
10814 ACTUAL=$($GETSTRIPE $* $DIR/$tdir)
10816 --stripe-count|--count)
10817 [ -n "$2" ] && EXPECTED=0 || EXPECTED=$(default_attr count);;
10818 --stripe-size|--size)
10819 [ -n "$2" ] && EXPECTED=0 || EXPECTED=$(default_attr size);;
10820 --stripe-index|--index)
10823 error "unknown getstripe attr '$1'"
10826 [ $ACTUAL != $EXPECTED ] &&
10827 error "$DIR/$tdir has $1 '$ACTUAL', not '$EXPECTED'"
10831 test_mkdir -p $DIR/$tdir
10832 $SETSTRIPE --stripe-count 0 --stripe-size 0 --stripe-index -1 $DIR/$tdir
10834 check_default_stripe_attr --stripe-count
10835 check_default_stripe_attr --stripe-size
10836 check_default_stripe_attr --stripe-index
10840 run_test 204a "Print default stripe attributes ================="
10843 test_mkdir -p $DIR/$tdir
10844 $SETSTRIPE --stripe-count 1 $DIR/$tdir
10846 check_default_stripe_attr --stripe-size
10847 check_default_stripe_attr --stripe-index
10851 run_test 204b "Print default stripe size and offset ==========="
10854 test_mkdir -p $DIR/$tdir
10855 $SETSTRIPE --stripe-size 65536 $DIR/$tdir
10857 check_default_stripe_attr --stripe-count
10858 check_default_stripe_attr --stripe-index
10862 run_test 204c "Print default stripe count and offset ==========="
10865 test_mkdir -p $DIR/$tdir
10866 $SETSTRIPE --stripe-index 0 $DIR/$tdir
10868 check_default_stripe_attr --stripe-count
10869 check_default_stripe_attr --stripe-size
10873 run_test 204d "Print default stripe count and size ============="
10876 test_mkdir -p $DIR/$tdir
10877 $SETSTRIPE -d $DIR/$tdir
10879 check_default_stripe_attr --stripe-count --raw
10880 check_default_stripe_attr --stripe-size --raw
10881 check_default_stripe_attr --stripe-index --raw
10885 run_test 204e "Print raw stripe attributes ================="
10888 test_mkdir -p $DIR/$tdir
10889 $SETSTRIPE --stripe-count 1 $DIR/$tdir
10891 check_default_stripe_attr --stripe-size --raw
10892 check_default_stripe_attr --stripe-index --raw
10896 run_test 204f "Print raw stripe size and offset ==========="
10899 test_mkdir -p $DIR/$tdir
10900 $SETSTRIPE --stripe-size 65536 $DIR/$tdir
10902 check_default_stripe_attr --stripe-count --raw
10903 check_default_stripe_attr --stripe-index --raw
10907 run_test 204g "Print raw stripe count and offset ==========="
10910 test_mkdir -p $DIR/$tdir
10911 $SETSTRIPE --stripe-index 0 $DIR/$tdir
10913 check_default_stripe_attr --stripe-count --raw
10914 check_default_stripe_attr --stripe-size --raw
10918 run_test 204h "Print raw stripe count and size ============="
10920 # Figure out which job scheduler is being used, if any,
10921 # or use a fake one
10922 if [ -n "$SLURM_JOB_ID" ]; then # SLURM
10923 JOBENV=SLURM_JOB_ID
10924 elif [ -n "$LSB_JOBID" ]; then # Load Sharing Facility
10926 elif [ -n "$PBS_JOBID" ]; then # PBS/Maui/Moab
10928 elif [ -n "$LOADL_STEPID" ]; then # LoadLeveller
10929 JOBENV=LOADL_STEP_ID
10930 elif [ -n "$JOB_ID" ]; then # Sun Grid Engine
10936 verify_jobstats() {
10940 # clear old jobstats
10941 do_facet $SINGLEMDS lctl set_param mdt.*.job_stats="clear"
10942 do_facet ost1 lctl set_param obdfilter.*.job_stats="clear"
10944 # use a new JobID for this test, or we might see an old one
10945 [ "$JOBENV" = "FAKE_JOBID" ] && FAKE_JOBID=test_id.$testnum.$RANDOM
10949 log "Using JobID environment variable $JOBENV=$JOBVAL"
10951 if [ $JOBENV = "FAKE_JOBID" ]; then
10952 FAKE_JOBID=$JOBVAL $cmd
10957 if [ "$target" = "mdt" -o "$target" = "both" ]; then
10958 FACET="$SINGLEMDS" # will need to get MDS number for DNE
10959 do_facet $FACET lctl get_param mdt.*.job_stats |
10960 grep $JOBVAL || error "No job stats found on MDT $FACET"
10962 if [ "$target" = "ost" -o "$target" = "both" ]; then
10964 do_facet $FACET lctl get_param obdfilter.*.job_stats |
10965 grep $JOBVAL || error "No job stats found on OST $FACET"
10971 NEW_JOBENV=${1:-$OLD_JOBENV}
10972 do_facet mgs $LCTL conf_param $FSNAME.sys.jobid_var=$NEW_JOBENV
10973 wait_update $HOSTNAME "$LCTL get_param -n jobid_var" $NEW_JOBENV
10976 test_205() { # Job stats
10977 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10978 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep jobstats)" ] &&
10979 skip "Server doesn't support jobstats" && return 0
10980 [[ $JOBID_VAR = disable ]] && skip "jobstats is disabled" && return
10983 OLD_JOBENV=$($LCTL get_param -n jobid_var)
10984 if [ $OLD_JOBENV != $JOBENV ]; then
10985 jobstats_set $JOBENV
10986 trap jobstats_set EXIT
10990 cmd="mkdir $DIR/$tfile"
10991 verify_jobstats "$cmd" "mdt"
10993 cmd="rm -fr $DIR/$tfile"
10994 verify_jobstats "$cmd" "mdt"
10996 cmd="mknod $DIR/$tfile c 1 3"
10997 verify_jobstats "$cmd" "mdt"
10999 cmd="rm -f $DIR/$tfile"
11000 verify_jobstats "$cmd" "mdt"
11002 cmd="$SETSTRIPE -i 0 -c 1 $DIR/$tfile"
11003 verify_jobstats "$cmd" "mdt"
11005 cmd="touch $DIR/$tfile"
11006 verify_jobstats "$cmd" "both"
11008 cmd="dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 oflag=sync"
11009 verify_jobstats "$cmd" "ost"
11011 cmd="dd if=$DIR/$tfile of=/dev/null bs=1M count=1 iflag=direct"
11012 verify_jobstats "$cmd" "ost"
11014 cmd="$TRUNCATE $DIR/$tfile 0"
11015 verify_jobstats "$cmd" "both"
11017 cmd="mv -f $DIR/$tfile $DIR/jobstats_test_rename"
11018 verify_jobstats "$cmd" "mdt"
11021 rm -f $DIR/jobstats_test_rename
11023 [ $OLD_JOBENV != $JOBENV ] && jobstats_set $OLD_JOBENV
11025 run_test 205 "Verify job stats"
11027 # LU-1480, LU-1773 and LU-1657
11029 mkdir -p $DIR/$tdir
11030 $SETSTRIPE -c -1 $DIR/$tdir
11031 #define OBD_FAIL_LOV_INIT 0x1403
11032 $LCTL set_param fail_loc=0xa0001403
11033 $LCTL set_param fail_val=1
11034 touch $DIR/$tdir/$tfile || true
11036 run_test 206 "fail lov_init_raid0() doesn't lbug"
11039 dd if=/dev/zero of=$DIR/$tfile bs=4k count=$((RANDOM%10+1))
11040 local fsz=`stat -c %s $DIR/$tfile`
11041 cancel_lru_locks mdc
11043 # do not return layout in getattr intent
11044 #define OBD_FAIL_MDS_NO_LL_GETATTR 0x170
11045 $LCTL set_param fail_loc=0x170
11046 local sz=`stat -c %s $DIR/$tfile`
11048 [ $fsz -eq $sz ] || error "file size expected $fsz, actual $sz"
11052 run_test 207a "can refresh layout at glimpse"
11055 dd if=/dev/zero of=$DIR/$tfile bs=4k count=$((RANDOM%10+1))
11056 local cksum=`md5sum $DIR/$tfile`
11057 local fsz=`stat -c %s $DIR/$tfile`
11058 cancel_lru_locks mdc
11059 cancel_lru_locks osc
11061 # do not return layout in getattr intent
11062 #define OBD_FAIL_MDS_NO_LL_OPEN 0x171
11063 $LCTL set_param fail_loc=0x171
11065 # it will refresh layout after the file is opened but before read issues
11066 echo checksum is "$cksum"
11067 echo "$cksum" |md5sum -c --quiet || error "file differs"
11071 run_test 207b "can refresh layout at open"
11074 # FIXME: in this test suite, only RD lease is used. This is okay
11075 # for now as only exclusive open is supported. After generic lease
11076 # is done, this test suite should be revised. - Jinshan
11078 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.4.52) ]] ||
11079 { skip "Need MDS version at least 2.4.52"; return 0; }
11081 echo "==== test 1: verify get lease work"
11082 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:eRE+eU || error "get lease error"
11084 echo "==== test 2: verify lease can be broken by upcoming open"
11085 $MULTIOP $DIR/$tfile oO_RDONLY:eR_E-eUc &
11089 $MULTIOP $DIR/$tfile oO_RDONLY:c
11090 kill -USR1 $PID && wait $PID || error "break lease error"
11092 echo "==== test 3: verify lease can't be granted if an open already exists"
11093 $MULTIOP $DIR/$tfile oO_RDONLY:_c &
11097 $MULTIOP $DIR/$tfile oO_RDONLY:eReUc && error "apply lease should fail"
11098 kill -USR1 $PID && wait $PID || error "open file error"
11100 echo "==== test 4: lease can sustain over recovery"
11101 $MULTIOP $DIR/$tfile oO_RDONLY:eR_E+eUc &
11107 kill -USR1 $PID && wait $PID || error "lease broken over recovery"
11109 echo "==== test 5: lease broken can't be regained by replay"
11110 $MULTIOP $DIR/$tfile oO_RDONLY:eR_E-eUc &
11114 # open file to break lease and then recovery
11115 $MULTIOP $DIR/$tfile oO_RDWR:c || error "open file error"
11118 kill -USR1 $PID && wait $PID || error "lease not broken over recovery"
11122 run_test 208 "Exclusive open"
11125 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep disp_stripe)" ] &&
11126 skip_env "must have disp_stripe" && return
11129 sync; sleep 5; sync;
11131 echo 3 > /proc/sys/vm/drop_caches
11132 req_before=$(awk '/ptlrpc_cache / { print $2 }' /proc/slabinfo)
11134 # open/close 500 times
11135 for i in $(seq 500); do
11139 echo 3 > /proc/sys/vm/drop_caches
11140 req_after=$(awk '/ptlrpc_cache / { print $2 }' /proc/slabinfo)
11142 echo "before: $req_before, after: $req_after"
11143 [ $((req_after - req_before)) -ge 300 ] &&
11144 error "open/close requests are not freed"
11147 run_test 209 "read-only open/close requests should be freed promptly"
11151 size=$((size % 8192 + 1))
11152 dd if=/dev/urandom of=$DIR/f212 bs=1k count=$size
11153 sendfile $DIR/f212 $DIR/f212.xyz || error "sendfile wrong"
11154 rm -f $DIR/f212 $DIR/f212.xyz
11156 run_test 212 "Sendfile test ============================================"
11159 dd if=/dev/zero of=$DIR/$tfile bs=4k count=4
11160 cancel_lru_locks osc
11161 lctl set_param fail_loc=0x8000040f
11162 # generate a read lock
11163 cat $DIR/$tfile > /dev/null
11164 # write to the file, it will try to cancel the above read lock.
11165 cat /etc/hosts >> $DIR/$tfile
11167 run_test 213 "OSC lock completion and cancel race don't crash - bug 18829"
11169 test_214() { # for bug 20133
11170 mkdir -p $DIR/$tdir/d214c || error "mkdir $DIR/$tdir/d214c failed"
11171 for (( i=0; i < 340; i++ )) ; do
11172 touch $DIR/$tdir/d214c/a$i
11175 ls -l $DIR/$tdir || error "ls -l $DIR/d214p failed"
11176 mv $DIR/$tdir/d214c $DIR/ || error "mv $DIR/d214p/d214c $DIR/ failed"
11177 ls $DIR/d214c || error "ls $DIR/d214c failed"
11178 rm -rf $DIR/$tdir || error "rm -rf $DIR/d214* failed"
11179 rm -rf $DIR/d214* || error "rm -rf $DIR/d214* failed"
11181 run_test 214 "hash-indexed directory test - bug 20133"
11183 # having "abc" as 1st arg, creates $TMP/lnet_abc.out and $TMP/lnet_abc.sys
11184 create_lnet_proc_files() {
11185 cat /proc/sys/lnet/$1 >$TMP/lnet_$1.out || error "cannot read /proc/sys/lnet/$1"
11186 sysctl lnet.$1 >$TMP/lnet_$1.sys_tmp || error "cannot read lnet.$1"
11188 sed "s/^lnet.$1\ =\ //g" "$TMP/lnet_$1.sys_tmp" >$TMP/lnet_$1.sys
11189 rm -f "$TMP/lnet_$1.sys_tmp"
11192 # counterpart of create_lnet_proc_files
11193 remove_lnet_proc_files() {
11194 rm -f $TMP/lnet_$1.out $TMP/lnet_$1.sys
11197 # uses 1st arg as trailing part of filename, 2nd arg as description for reports,
11198 # 3rd arg as regexp for body
11199 check_lnet_proc_stats() {
11200 local l=$(cat "$TMP/lnet_$1" |wc -l)
11201 [ $l = 1 ] || (cat "$TMP/lnet_$1" && error "$2 is not of 1 line: $l")
11203 grep -E "$3" "$TMP/lnet_$1" || (cat "$TMP/lnet_$1" && error "$2 misformatted")
11206 # uses 1st arg as trailing part of filename, 2nd arg as description for reports,
11207 # 3rd arg as regexp for body, 4th arg as regexp for 1st line, 5th arg is
11208 # optional and can be regexp for 2nd line (lnet.routes case)
11209 check_lnet_proc_entry() {
11210 local blp=2 # blp stands for 'position of 1st line of body'
11211 [ -z "$5" ] || blp=3 # lnet.routes case
11213 local l=$(cat "$TMP/lnet_$1" |wc -l)
11214 # subtracting one from $blp because the body can be empty
11215 [ "$l" -ge "$(($blp - 1))" ] || (cat "$TMP/lnet_$1" && error "$2 is too short: $l")
11217 sed -n '1 p' "$TMP/lnet_$1" |grep -E "$4" >/dev/null ||
11218 (cat "$TMP/lnet_$1" && error "1st line of $2 misformatted")
11220 [ "$5" = "" ] || sed -n '2 p' "$TMP/lnet_$1" |grep -E "$5" >/dev/null ||
11221 (cat "$TMP/lnet_$1" && error "2nd line of $2 misformatted")
11223 # bail out if any unexpected line happened
11224 sed -n "$blp p" "$TMP/lnet_$1" | grep -Ev "$3"
11225 [ "$?" != 0 ] || error "$2 misformatted"
11228 test_215() { # for bugs 18102, 21079, 21517
11229 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11230 local N='(0|[1-9][0-9]*)' # non-negative numeric
11231 local P='[1-9][0-9]*' # positive numeric
11232 local I='(0|-?[1-9][0-9]*|NA)' # any numeric (0 | >0 | <0) or NA if no value
11233 local NET='[a-z][a-z0-9]*' # LNET net like o2ib2
11234 local ADDR='[0-9.]+' # LNET addr like 10.0.0.1
11235 local NID="$ADDR@$NET" # LNET nid like 10.0.0.1@o2ib2
11237 local L1 # regexp for 1st line
11238 local L2 # regexp for 2nd line (optional)
11239 local BR # regexp for the rest (body)
11241 # /proc/sys/lnet/stats should look as 11 space-separated non-negative numerics
11242 BR="^$N $N $N $N $N $N $N $N $N $N $N$"
11243 create_lnet_proc_files "stats"
11244 check_lnet_proc_stats "stats.out" "/proc/sys/lnet/stats" "$BR"
11245 check_lnet_proc_stats "stats.sys" "lnet.stats" "$BR"
11246 remove_lnet_proc_files "stats"
11248 # /proc/sys/lnet/routes should look like this:
11249 # Routing disabled/enabled
11250 # net hops priority state router
11251 # where net is a string like tcp0, hops > 0, priority >= 0,
11252 # state is up/down,
11253 # router is a string like 192.168.1.1@tcp2
11254 L1="^Routing (disabled|enabled)$"
11255 L2="^net +hops +priority +state +router$"
11256 BR="^$NET +$N +(0|1) +(up|down) +$NID$"
11257 create_lnet_proc_files "routes"
11258 check_lnet_proc_entry "routes.out" "/proc/sys/lnet/routes" "$BR" "$L1" "$L2"
11259 check_lnet_proc_entry "routes.sys" "lnet.routes" "$BR" "$L1" "$L2"
11260 remove_lnet_proc_files "routes"
11262 # /proc/sys/lnet/routers should look like this:
11263 # ref rtr_ref alive_cnt state last_ping ping_sent deadline down_ni router
11264 # where ref > 0, rtr_ref > 0, alive_cnt >= 0, state is up/down,
11265 # last_ping >= 0, ping_sent is boolean (0/1), deadline and down_ni are
11266 # numeric (0 or >0 or <0), router is a string like 192.168.1.1@tcp2
11267 L1="^ref +rtr_ref +alive_cnt +state +last_ping +ping_sent +deadline +down_ni +router$"
11268 BR="^$P +$P +$N +(up|down) +$N +(0|1) +$I +$I +$NID$"
11269 create_lnet_proc_files "routers"
11270 check_lnet_proc_entry "routers.out" "/proc/sys/lnet/routers" "$BR" "$L1"
11271 check_lnet_proc_entry "routers.sys" "lnet.routers" "$BR" "$L1"
11272 remove_lnet_proc_files "routers"
11274 # /proc/sys/lnet/peers should look like this:
11275 # nid refs state last max rtr min tx min queue
11276 # where nid is a string like 192.168.1.1@tcp2, refs > 0,
11277 # state is up/down/NA, max >= 0. last, rtr, min, tx, min are
11278 # numeric (0 or >0 or <0), queue >= 0.
11279 L1="^nid +refs +state +last +max +rtr +min +tx +min +queue$"
11280 BR="^$NID +$P +(up|down|NA) +$I +$N +$I +$I +$I +$I +$N$"
11281 create_lnet_proc_files "peers"
11282 check_lnet_proc_entry "peers.out" "/proc/sys/lnet/peers" "$BR" "$L1"
11283 check_lnet_proc_entry "peers.sys" "lnet.peers" "$BR" "$L1"
11284 remove_lnet_proc_files "peers"
11286 # /proc/sys/lnet/buffers should look like this:
11287 # pages count credits min
11288 # where pages >=0, count >=0, credits and min are numeric (0 or >0 or <0)
11289 L1="^pages +count +credits +min$"
11290 BR="^ +$N +$N +$I +$I$"
11291 create_lnet_proc_files "buffers"
11292 check_lnet_proc_entry "buffers.out" "/proc/sys/lnet/buffers" "$BR" "$L1"
11293 check_lnet_proc_entry "buffers.sys" "lnet.buffers" "$BR" "$L1"
11294 remove_lnet_proc_files "buffers"
11296 # /proc/sys/lnet/nis should look like this:
11297 # nid status alive refs peer rtr max tx min
11298 # where nid is a string like 192.168.1.1@tcp2, status is up/down,
11299 # alive is numeric (0 or >0 or <0), refs >= 0, peer >= 0,
11300 # rtr >= 0, max >=0, tx and min are numeric (0 or >0 or <0).
11301 L1="^nid +status +alive +refs +peer +rtr +max +tx +min$"
11302 BR="^$NID +(up|down) +$I +$N +$N +$N +$N +$I +$I$"
11303 create_lnet_proc_files "nis"
11304 check_lnet_proc_entry "nis.out" "/proc/sys/lnet/nis" "$BR" "$L1"
11305 check_lnet_proc_entry "nis.sys" "lnet.nis" "$BR" "$L1"
11306 remove_lnet_proc_files "nis"
11308 # can we successfully write to /proc/sys/lnet/stats?
11309 echo "0" >/proc/sys/lnet/stats || error "cannot write to /proc/sys/lnet/stats"
11310 sysctl -w lnet.stats=0 || error "cannot write to lnet.stats"
11312 run_test 215 "/proc/sys/lnet exists and has proper content - bugs 18102, 21079, 21517"
11314 test_216() { # bug 20317
11315 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11316 remote_ost_nodsh && skip "remote OST with nodsh" && return
11319 local facets=$(get_facets OST)
11320 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
11322 save_lustre_params client "osc.*.contention_seconds" > $p
11323 save_lustre_params $facets \
11324 "ldlm.namespaces.filter-*.max_nolock_bytes" >> $p
11325 save_lustre_params $facets \
11326 "ldlm.namespaces.filter-*.contended_locks" >> $p
11327 save_lustre_params $facets \
11328 "ldlm.namespaces.filter-*.contention_seconds" >> $p
11331 # agressive lockless i/o settings
11332 for node in $(osts_nodes); do
11333 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'
11335 lctl set_param -n osc.*.contention_seconds 60
11337 $DIRECTIO write $DIR/$tfile 0 10 4096
11338 $CHECKSTAT -s 40960 $DIR/$tfile
11340 # disable lockless i/o
11341 for node in $(osts_nodes); do
11342 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'
11344 lctl set_param -n osc.*.contention_seconds 0
11347 dd if=/dev/zero of=$DIR/$tfile count=0
11348 $CHECKSTAT -s 0 $DIR/$tfile
11350 restore_lustre_params <$p
11354 run_test 216 "check lockless direct write works and updates file size and kms correctly"
11356 test_217() { # bug 22430
11357 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11361 for node in $(nodes_list); do
11362 nid=$(host_nids_address $node $NETTYPE)
11363 if [[ $nid = *-* ]] ; then
11364 echo "lctl ping $nid@$NETTYPE"
11365 lctl ping $nid@$NETTYPE
11367 echo "skipping $node (no hyphen detected)"
11371 run_test 217 "check lctl ping for hostnames with hiphen ('-')"
11374 # do directio so as not to populate the page cache
11375 log "creating a 10 Mb file"
11376 $MULTIOP $DIR/$tfile oO_CREAT:O_DIRECT:O_RDWR:w$((10*1048576))c || error "multiop failed while creating a file"
11377 log "starting reads"
11378 dd if=$DIR/$tfile of=/dev/null bs=4096 &
11379 log "truncating the file"
11380 $MULTIOP $DIR/$tfile oO_TRUNC:c || error "multiop failed while truncating the file"
11382 kill %+ || true # reads might have finished
11383 echo "wait until dd is finished"
11385 log "removing the temporary file"
11386 rm -rf $DIR/$tfile || error "tmp file removal failed"
11388 run_test 218 "parallel read and truncate should not deadlock ======================="
11391 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11392 # write one partial page
11393 dd if=/dev/zero of=$DIR/$tfile bs=1024 count=1
11394 # set no grant so vvp_io_commit_write will do sync write
11395 $LCTL set_param fail_loc=0x411
11396 # write a full page at the end of file
11397 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 seek=1 conv=notrunc
11399 $LCTL set_param fail_loc=0
11400 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 seek=3
11401 $LCTL set_param fail_loc=0x411
11402 dd if=/dev/zero of=$DIR/$tfile bs=1024 count=1 seek=2 conv=notrunc
11404 run_test 219 "LU-394: Write partial won't cause uncontiguous pages vec at LND"
11406 test_220() { #LU-325
11407 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11408 remote_ost_nodsh && skip "remote OST with nodsh" && return
11411 test_mkdir -p $DIR/$tdir
11412 local OST=$(lfs osts | grep ${OSTIDX}": " | \
11413 awk '{print $2}' | sed -e 's/_UUID$//')
11416 local mdtosc_proc1=$(get_mdtosc_proc_path $SINGLEMDS $OST)
11417 local last_id=$(do_facet $SINGLEMDS lctl get_param -n \
11418 osc.$mdtosc_proc1.prealloc_last_id)
11419 local next_id=$(do_facet $SINGLEMDS lctl get_param -n \
11420 osc.$mdtosc_proc1.prealloc_next_id)
11424 do_facet ost$((OSTIDX + 1)) lctl set_param fail_val=-1
11425 #define OBD_FAIL_OST_ENOINO 0x229
11426 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=0x229
11427 do_facet mgs $LCTL pool_new $FSNAME.$TESTNAME || return 1
11428 do_facet mgs $LCTL pool_add $FSNAME.$TESTNAME $OST || return 2
11430 $SETSTRIPE $DIR/$tdir -i $OSTIDX -c 1 -p $FSNAME.$TESTNAME
11432 MDSOBJS=$((last_id - next_id))
11433 echo "preallocated objects on MDS is $MDSOBJS" "($last_id - $next_id)"
11435 blocks=$($LFS df $MOUNT | awk '($1 == '$OSTIDX') { print $4 }')
11436 echo "OST still has $count kbytes free"
11438 echo "create $MDSOBJS files @next_id..."
11439 createmany -o $DIR/$tdir/f $MDSOBJS || return 3
11441 local last_id2=$(do_facet mds${MDSIDX} lctl get_param -n \
11442 osc.$mdtosc_proc1.prealloc_last_id)
11443 local next_id2=$(do_facet mds${MDSIDX} lctl get_param -n \
11444 osc.$mdtosc_proc1.prealloc_next_id)
11446 echo "after creation, last_id=$last_id2, next_id=$next_id2"
11451 do_facet ost$((OSTIDX + 1)) lctl set_param fail_val=0
11452 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=0
11454 do_facet mgs $LCTL pool_remove $FSNAME.$TESTNAME $OST || return 4
11455 do_facet mgs $LCTL pool_destroy $FSNAME.$TESTNAME || return 5
11456 echo "unlink $MDSOBJS files @$next_id..."
11457 unlinkmany $DIR/$tdir/f $MDSOBJS || return 6
11459 run_test 220 "preallocated MDS objects still used if ENOSPC from OST"
11462 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11463 dd if=`which date` of=$MOUNT/date oflag=sync
11464 chmod +x $MOUNT/date
11466 #define OBD_FAIL_LLITE_FAULT_TRUNC_RACE 0x1401
11467 $LCTL set_param fail_loc=0x80001401
11469 $MOUNT/date > /dev/null
11472 run_test 221 "make sure fault and truncate race to not cause OOM"
11475 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11477 test_mkdir -p $DIR/$tdir
11478 $SETSTRIPE -c 1 -i 0 $DIR/$tdir
11479 createmany -o $DIR/$tdir/$tfile 10
11480 cancel_lru_locks mdc
11481 cancel_lru_locks osc
11482 #define OBD_FAIL_LDLM_AGL_DELAY 0x31a
11483 $LCTL set_param fail_loc=0x31a
11484 ls -l $DIR/$tdir > /dev/null || error "AGL for ls failed"
11485 $LCTL set_param fail_loc=0
11488 run_test 222a "AGL for ls should not trigger CLIO lock failure ================"
11491 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11493 test_mkdir -p $DIR/$tdir
11494 $SETSTRIPE -c 1 -i 0 $DIR/$tdir
11495 createmany -o $DIR/$tdir/$tfile 10
11496 cancel_lru_locks mdc
11497 cancel_lru_locks osc
11498 #define OBD_FAIL_LDLM_AGL_DELAY 0x31a
11499 $LCTL set_param fail_loc=0x31a
11500 rm -r $DIR/$tdir || "AGL for rmdir failed"
11501 $LCTL set_param fail_loc=0
11503 run_test 222b "AGL for rmdir should not trigger CLIO lock failure ============="
11506 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11508 test_mkdir -p $DIR/$tdir
11509 $SETSTRIPE -c 1 -i 0 $DIR/$tdir
11510 createmany -o $DIR/$tdir/$tfile 10
11511 cancel_lru_locks mdc
11512 cancel_lru_locks osc
11513 #define OBD_FAIL_LDLM_AGL_NOLOCK 0x31b
11514 $LCTL set_param fail_loc=0x31b
11515 ls -l $DIR/$tdir > /dev/null || error "reenqueue failed"
11516 $LCTL set_param fail_loc=0
11519 run_test 223 "osc reenqueue if without AGL lock granted ======================="
11521 test_224a() { # LU-1039, MRP-303
11522 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11523 #define OBD_FAIL_PTLRPC_CLIENT_BULK_CB 0x508
11524 $LCTL set_param fail_loc=0x508
11525 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 conv=fsync
11526 $LCTL set_param fail_loc=0
11529 run_test 224a "Don't panic on bulk IO failure"
11531 test_224b() { # LU-1039, MRP-303
11532 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11533 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1
11534 cancel_lru_locks osc
11535 #define OBD_FAIL_PTLRPC_CLIENT_BULK_CB2 0x515
11536 $LCTL set_param fail_loc=0x515
11537 dd of=/dev/null if=$DIR/$tfile bs=4096 count=1
11538 $LCTL set_param fail_loc=0
11541 run_test 224b "Don't panic on bulk IO failure"
11543 MDSSURVEY=${MDSSURVEY:-$(which mds-survey 2>/dev/null || true)}
11545 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11546 if [ -z ${MDSSURVEY} ]; then
11547 skip_env "mds-survey not found" && return
11550 [ $MDSCOUNT -ge 2 ] &&
11551 skip "skipping now for more than one MDT" && return
11553 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.51) ] ||
11554 { skip "Need MDS version at least 2.2.51"; return; }
11556 local mds=$(facet_host $SINGLEMDS)
11557 local target=$(do_nodes $mds 'lctl dl' | \
11558 awk "{if (\$2 == \"UP\" && \$3 == \"mdt\") {print \$4}}")
11560 local cmd1="file_count=1000 thrhi=4"
11561 local cmd2="dir_count=2 layer=mdd stripe_count=0"
11562 local cmd3="rslt_loc=${TMP} targets=\"$mds:$target\" $MDSSURVEY"
11563 local cmd="$cmd1 $cmd2 $cmd3"
11565 rm -f ${TMP}/mds_survey*
11567 eval $cmd || error "mds-survey with zero-stripe failed"
11568 cat ${TMP}/mds_survey*
11569 rm -f ${TMP}/mds_survey*
11571 run_test 225a "Metadata survey sanity with zero-stripe"
11574 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11576 if [ -z ${MDSSURVEY} ]; then
11577 skip_env "mds-survey not found" && return
11579 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.51) ] ||
11580 { skip "Need MDS version at least 2.2.51"; return; }
11582 if [ $($LCTL dl | grep -c osc) -eq 0 ]; then
11583 skip_env "Need to mount OST to test" && return
11586 [ $MDSCOUNT -ge 2 ] &&
11587 skip "skipping now for more than one MDT" && return
11588 local mds=$(facet_host $SINGLEMDS)
11589 local target=$(do_nodes $mds 'lctl dl' | \
11590 awk "{if (\$2 == \"UP\" && \$3 == \"mdt\") {print \$4}}")
11592 local cmd1="file_count=1000 thrhi=4"
11593 local cmd2="dir_count=2 layer=mdd stripe_count=1"
11594 local cmd3="rslt_loc=${TMP} targets=\"$mds:$target\" $MDSSURVEY"
11595 local cmd="$cmd1 $cmd2 $cmd3"
11597 rm -f ${TMP}/mds_survey*
11599 eval $cmd || error "mds-survey with stripe_count failed"
11600 cat ${TMP}/mds_survey*
11601 rm -f ${TMP}/mds_survey*
11603 run_test 225b "Metadata survey sanity with stripe_count = 1"
11605 mcreate_path2fid () {
11611 local path=$DIR/$tdir/$name
11616 $MCREATE --mode=$1 --major=$2 --minor=$3 $path ||
11617 error "cannot create $desc"
11619 fid=$($LFS path2fid $path | tr -d '[' | tr -d ']')
11621 [ $rc -ne 0 ] && error "cannot get fid of a $desc"
11623 fid_path=$($LFS fid2path $MOUNT $fid)
11625 [ $rc -ne 0 ] && error "cannot get path of $desc by $DIR $path $fid"
11627 [ "$path" == "$fid_path" ] ||
11628 error "fid2path returned $fid_path, expected $path"
11630 echo "pass with $path and $fid"
11635 mkdir -p $DIR/$tdir
11637 mcreate_path2fid 0010666 0 0 fifo "FIFO"
11638 mcreate_path2fid 0020666 1 3 null "character special file (null)"
11639 mcreate_path2fid 0020666 1 255 none "character special file (no device)"
11640 mcreate_path2fid 0040666 0 0 dir "directory"
11641 mcreate_path2fid 0060666 7 0 loop0 "block special file (loop)"
11642 mcreate_path2fid 0100666 0 0 file "regular file"
11643 mcreate_path2fid 0120666 0 0 link "symbolic link"
11644 mcreate_path2fid 0140666 0 0 sock "socket"
11646 run_test 226a "call path2fid and fid2path on files of all type"
11649 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
11653 mkdir -p $DIR/$tdir
11654 $LFS setdirstripe -i $MDTIDX $DIR/$tdir/remote_dir ||
11655 error "create remote directory failed"
11656 mcreate_path2fid 0010666 0 0 "remote_dir/fifo" "FIFO"
11657 mcreate_path2fid 0020666 1 3 "remote_dir/null" \
11658 "character special file (null)"
11659 mcreate_path2fid 0020666 1 255 "remote_dir/none" \
11660 "character special file (no device)"
11661 mcreate_path2fid 0040666 0 0 "remote_dir/dir" "directory"
11662 mcreate_path2fid 0060666 7 0 "remote_dir/loop0" \
11663 "block special file (loop)"
11664 mcreate_path2fid 0100666 0 0 "remote_dir/file" "regular file"
11665 mcreate_path2fid 0120666 0 0 "remote_dir/link" "symbolic link"
11666 mcreate_path2fid 0140666 0 0 "remote_dir/sock" "socket"
11668 run_test 226b "call path2fid and fid2path on files of all type under remote dir"
11670 # LU-1299 Executing or running ldd on a truncated executable does not
11671 # cause an out-of-memory condition.
11673 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11674 [ -z "$(which ldd)" ] && skip "should have ldd tool" && return
11675 dd if=$(which date) of=$MOUNT/date bs=1k count=1
11676 chmod +x $MOUNT/date
11678 $MOUNT/date > /dev/null
11679 ldd $MOUNT/date > /dev/null
11682 run_test 227 "running truncated executable does not cause OOM"
11684 # LU-1512 try to reuse idle OI blocks
11686 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11687 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
11688 skip "non-ldiskfs backend" && return
11690 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
11691 local myDIR=$DIR/$tdir
11694 #define OBD_FAIL_SEQ_EXHAUST 0x1002
11695 $LCTL set_param fail_loc=0x80001002
11696 createmany -o $myDIR/t- 10000
11697 $LCTL set_param fail_loc=0
11698 # The guard is current the largest FID holder
11700 local SEQ=$($LFS path2fid $myDIR/guard | awk -F ':' '{print $1}' |
11702 local IDX=$(($SEQ % 64))
11704 do_facet $SINGLEMDS sync
11705 # Make sure journal flushed.
11707 local blk1=$(do_facet $SINGLEMDS \
11708 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
11709 grep Blockcount | awk '{print $4}')
11711 # Remove old files, some OI blocks will become idle.
11712 unlinkmany $myDIR/t- 10000
11713 # Create new files, idle OI blocks should be reused.
11714 createmany -o $myDIR/t- 2000
11715 do_facet $SINGLEMDS sync
11716 # Make sure journal flushed.
11718 local blk2=$(do_facet $SINGLEMDS \
11719 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
11720 grep Blockcount | awk '{print $4}')
11722 [ $blk1 == $blk2 ] || error "old blk1=$blk1, new blk2=$blk2, unmatched!"
11724 run_test 228a "try to reuse idle OI blocks"
11727 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11728 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
11729 skip "non-ldiskfs backend" && return
11731 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
11732 local myDIR=$DIR/$tdir
11735 #define OBD_FAIL_SEQ_EXHAUST 0x1002
11736 $LCTL set_param fail_loc=0x80001002
11737 createmany -o $myDIR/t- 10000
11738 $LCTL set_param fail_loc=0
11739 # The guard is current the largest FID holder
11741 local SEQ=$($LFS path2fid $myDIR/guard | awk -F ':' '{print $1}' |
11743 local IDX=$(($SEQ % 64))
11745 do_facet $SINGLEMDS sync
11746 # Make sure journal flushed.
11748 local blk1=$(do_facet $SINGLEMDS \
11749 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
11750 grep Blockcount | awk '{print $4}')
11752 # Remove old files, some OI blocks will become idle.
11753 unlinkmany $myDIR/t- 10000
11756 stop $SINGLEMDS || error "Fail to stop MDT."
11758 start $SINGLEMDS $MDT_DEV $MDS_MOUNT_OPTS || error "Fail to start MDT."
11760 df $MOUNT || error "Fail to df."
11761 # Create new files, idle OI blocks should be reused.
11762 createmany -o $myDIR/t- 2000
11763 do_facet $SINGLEMDS sync
11764 # Make sure journal flushed.
11766 local blk2=$(do_facet $SINGLEMDS \
11767 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
11768 grep Blockcount | awk '{print $4}')
11770 [ $blk1 == $blk2 ] || error "old blk1=$blk1, new blk2=$blk2, unmatched!"
11772 run_test 228b "idle OI blocks can be reused after MDT restart"
11776 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11777 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
11778 skip "non-ldiskfs backend" && return
11780 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
11781 local myDIR=$DIR/$tdir
11784 #define OBD_FAIL_SEQ_EXHAUST 0x1002
11785 $LCTL set_param fail_loc=0x80001002
11786 # 20000 files can guarantee there are index nodes in the OI file
11787 createmany -o $myDIR/t- 20000
11788 $LCTL set_param fail_loc=0
11789 # The guard is current the largest FID holder
11791 local SEQ=$($LFS path2fid $myDIR/guard | awk -F ':' '{print $1}' |
11793 local IDX=$(($SEQ % 64))
11795 do_facet $SINGLEMDS sync
11796 # Make sure journal flushed.
11798 local blk1=$(do_facet $SINGLEMDS \
11799 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
11800 grep Blockcount | awk '{print $4}')
11802 # Remove old files, some OI blocks will become idle.
11803 unlinkmany $myDIR/t- 20000
11805 # The OI file should become empty now
11807 # Create new files, idle OI blocks should be reused.
11808 createmany -o $myDIR/t- 2000
11809 do_facet $SINGLEMDS sync
11810 # Make sure journal flushed.
11812 local blk2=$(do_facet $SINGLEMDS \
11813 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
11814 grep Blockcount | awk '{print $4}')
11816 [ $blk1 == $blk2 ] || error "old blk1=$blk1, new blk2=$blk2, unmatched!"
11818 run_test 228c "NOT shrink the last entry in OI index node to recycle idle leaf"
11820 test_229() { # LU-2482, LU-3448
11821 local server_version=$(get_lustre_version $SINGLEMDS)
11822 [[ $(version_code $server_version) -lt $(version_code 2.4.53) ]] &&
11823 skip "No HSM support on $server_version MDS," \
11824 "need 2.4.53 at least" && return
11825 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11826 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs" && return
11830 # Create a file with a released layout and stripe count 2.
11831 $MULTIOP $DIR/$tfile H2c ||
11832 error "failed to create file with released layout"
11834 $GETSTRIPE -v $DIR/$tfile
11836 local pattern=$($GETSTRIPE -L $DIR/$tfile)
11837 [ X"$pattern" = X"80000001" ] || error "pattern error ($pattern)"
11839 local stripe_count=$($GETSTRIPE -c $DIR/$tfile) || error "getstripe"
11840 [ $stripe_count -eq 2 ] || error "stripe count not 2 ($stripe_count)"
11841 stat $DIR/$tfile || error "failed to stat released file"
11843 chown $RUNAS_ID $DIR/$tfile ||
11844 error "chown $RUNAS_ID $DIR/$tfile failed"
11846 chgrp $RUNAS_ID $DIR/$tfile ||
11847 error "chgrp $RUNAS_ID $DIR/$tfile failed"
11849 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
11850 rm $DIR/$tfile || error "failed to remove released file"
11852 run_test 229 "getstripe/stat/rm/attr changes work on released files"
11855 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11856 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
11859 mkdir -p $DIR/$tdir/test_230_local
11860 local mdt_idx=$($GETSTRIPE -M $DIR/$tdir/test_230_local)
11861 [ $mdt_idx -ne 0 ] &&
11862 error "create local directory on wrong MDT $mdt_idx"
11864 $LFS mkdir -i $MDTIDX $DIR/$tdir/test_230 ||
11865 error "create remote directory failed"
11866 local mdt_idx=$($GETSTRIPE -M $DIR/$tdir/test_230)
11867 [ $mdt_idx -ne $MDTIDX ] &&
11868 error "create remote directory on wrong MDT $mdt_idx"
11870 createmany -o $DIR/$tdir/test_230/t- 10 ||
11871 error "create files on remote directory failed"
11872 mdt_idx=$($GETSTRIPE -M $DIR/$tdir/test_230/t-0)
11873 [ $mdt_idx -ne $MDTIDX ] && error "create files on wrong MDT $mdt_idx"
11874 rm -r $DIR/$tdir || error "unlink remote directory failed"
11876 run_test 230a "Create remote directory and files under the remote directory"
11879 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11880 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
11882 local remote_dir=$DIR/$tdir/remote_dir
11885 mkdir -p $DIR/$tdir
11886 $LFS mkdir -i $MDTIDX $remote_dir ||
11887 error "create remote directory failed"
11889 $LFS mkdir -i 0 $remote_dir/new_dir &&
11890 error "nested remote directory create succeed!"
11892 do_facet mds$((MDTIDX + 1)) lctl set_param mdt.*.enable_remote_dir=1
11893 $LFS mkdir -i 0 $remote_dir/new_dir || rc=$?
11894 do_facet mds$((MDTIDX + 1)) lctl set_param mdt.*.enable_remote_dir=0
11897 error "create remote directory failed after set enable_remote_dir"
11899 rm -rf $remote_dir || error "first unlink remote directory failed"
11901 $RUNAS -G$RUNAS_GID $LFS mkdir -i $MDTIDX $DIR/$tfile &&
11902 error "chown worked"
11904 do_facet mds$MDTIDX lctl set_param \
11905 mdt.*.enable_remote_dir_gid=$RUNAS_GID
11906 $LFS mkdir -i $MDTIDX $remote_dir || rc=$?
11907 do_facet mds$MDTIDX lctl set_param mdt.*.enable_remote_dir_gid=0
11910 error "create remote dir failed after set enable_remote_dir_gid"
11912 rm -r $DIR/$tdir || error "second unlink remote directory failed"
11914 run_test 230b "nested remote directory should be failed"
11918 # For simplicity this test assumes that max_pages_per_rpc
11919 # is the same across all OSCs
11920 local max_pages=$($LCTL get_param -n osc.*.max_pages_per_rpc | head -n1)
11921 local bulk_size=$((max_pages * 4096))
11923 mkdir -p $DIR/$tdir
11925 # clear the OSC stats
11926 $LCTL set_param osc.*.stats=0 &>/dev/null
11928 # Client writes $bulk_size - there must be 1 rpc for $max_pages.
11929 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=$bulk_size count=1 \
11930 oflag=direct &>/dev/null || error "dd failed"
11932 local nrpcs=$($LCTL get_param osc.*.stats |awk '/ost_write/ {print $2}')
11933 if [ x$nrpcs != "x1" ]; then
11934 error "found $nrpc ost_write RPCs, not 1 as expected"
11937 # Drop the OSC cache, otherwise we will read from it
11938 cancel_lru_locks osc
11940 # clear the OSC stats
11941 $LCTL set_param osc.*.stats=0 &>/dev/null
11943 # Client reads $bulk_size.
11944 dd if=$DIR/$tdir/$tfile of=/dev/null bs=$bulk_size count=1 \
11945 iflag=direct &>/dev/null || error "dd failed"
11947 nrpcs=$($LCTL get_param osc.*.stats | awk '/ost_read/ { print $2 }')
11948 if [ x$nrpcs != "x1" ]; then
11949 error "found $nrpc ost_read RPCs, not 1 as expected"
11952 run_test 231a "checking that reading/writing of BRW RPC size results in one RPC"
11955 mkdir -p $DIR/$tdir
11957 for i in {0..1023}; do
11958 dd if=/dev/zero of=$DIR/$tdir/$tfile conv=notrunc \
11959 seek=$((2 * i)) bs=4096 count=1 &>/dev/null ||
11960 error "dd of=$DIR/$tdir/$tfile seek=$((2 * i)) failed"
11964 run_test 231b "must not assert on fully utilized OST request buffer"
11967 mkdir -p $DIR/$tdir
11968 #define OBD_FAIL_LDLM_OST_LVB 0x31c
11969 $LCTL set_param fail_loc=0x31c
11971 # ignore dd failure
11972 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=1 || true
11974 $LCTL set_param fail_loc=0
11975 umount_client $MOUNT || error "umount failed"
11976 mount_client $MOUNT || error "mount failed"
11978 run_test 232 "failed lock should not block umount"
11981 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.3.64) ] ||
11982 { skip "Need MDS version at least 2.3.64"; return; }
11984 local fid=$($LFS path2fid $MOUNT)
11985 stat $MOUNT/.lustre/fid/$fid > /dev/null ||
11986 error "cannot access $MOUNT using its FID '$fid'"
11988 run_test 233a "checking that OBF of the FS root succeeds"
11991 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.5.90) ] ||
11992 { skip "Need MDS version at least 2.5.90"; return; }
11994 local fid=$($LFS path2fid $MOUNT/.lustre)
11995 stat $MOUNT/.lustre/fid/$fid > /dev/null ||
11996 error "cannot access $MOUNT/.lustre using its FID '$fid'"
11998 fid=$($LFS path2fid $MOUNT/.lustre/fid)
11999 stat $MOUNT/.lustre/fid/$fid > /dev/null ||
12000 error "cannot access $MOUNT/.lustre/fid using its FID '$fid'"
12002 run_test 233b "checking that OBF of the FS .lustre succeeds"
12005 local p="$TMP/sanityN-$TESTNAME.parameters"
12006 save_lustre_params client "llite.*.xattr_cache" > $p
12007 lctl set_param llite.*.xattr_cache 1 ||
12008 { skip "xattr cache is not supported"; return 0; }
12010 mkdir -p $DIR/$tdir || error "mkdir failed"
12011 touch $DIR/$tdir/$tfile || error "touch failed"
12012 # OBD_FAIL_LLITE_XATTR_ENOMEM
12013 $LCTL set_param fail_loc=0x1405
12014 if [ ! -f /etc/SuSE-release ]; then
12015 # attr pre-2.4.44-7 had a bug with rc
12016 # LU-3703 - SLES clients have older attr
12017 getfattr -n user.attr $DIR/$tdir/$tfile &&
12018 error "getfattr should have failed with ENOMEM"
12020 $LCTL set_param fail_loc=0x0
12023 restore_lustre_params < $p
12026 run_test 234 "xattr cache should not crash on ENOMEM"
12029 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.52) ] &&
12030 skip "Need MDS version at least 2.4.52" && return
12031 flock_deadlock $DIR/$tfile
12036 124) error "process hangs on a deadlock"
12038 *) error "error executing flock_deadlock $DIR/$tfile"
12042 run_test 235 "LU-1715: flock deadlock detection does not work properly"
12046 check_swap_layouts_support && return 0
12047 test_mkdir -p $DIR/$tdir || error "mkdir $tdir failed"
12049 local ref1=/etc/passwd
12050 local ref2=/etc/group
12051 local file1=$DIR/$tdir/f1
12052 local file2=$DIR/$tdir/f2
12054 $SETSTRIPE -c 1 $file1 || error "cannot setstripe on '$file1': rc = $?"
12055 cp $ref1 $file1 || error "cp $ref1 $file1 failed: rc = $?"
12056 $SETSTRIPE -c 2 $file2 || error "cannot setstripe on '$file2': rc = $?"
12057 cp $ref2 $file2 || error "cp $ref2 $file2 failed: rc = $?"
12058 local fd=$(free_fd)
12059 local cmd="exec $fd<>$file2"
12062 $LFS swap_layouts $file1 /proc/self/fd/${fd} ||
12063 error "cannot swap layouts of '$file1' and /proc/self/fd/${fd}"
12066 cmp $ref2 $file1 || error "content compare failed ($ref2 != $file1)"
12071 run_test 236 "Layout swap on open unlinked file"
12073 # LU-4659 linkea consistency
12076 ln $DIR/$tfile $DIR/$tfile.lnk
12077 touch $DIR/$tfile.new
12078 mv $DIR/$tfile.new $DIR/$tfile
12079 local fid1=$(lfs path2fid $DIR/$tfile)
12080 local fid2=$(lfs path2fid $DIR/$tfile.lnk)
12081 local path1=$(lfs fid2path $FSNAME $fid1)
12082 [ $tfile == $path1 ] || error "linkea inconsistent: $tfile $fid1 $path1"
12083 local path2=$(lfs fid2path $FSNAME $fid2)
12084 [ $tfile.lnk == $path2 ] ||
12085 error "linkea inconsistent: $tfile.lnk $fid2 $path2!"
12088 run_test 238 "Verify linkea consistency"
12090 # tests that do cleanup/setup should be run at the end
12094 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12096 #define OBD_FAIL_MGC_PAUSE_PROCESS_LOG 0x903
12097 $LCTL set_param fail_loc=0x903
12098 # cancel_lru_locks mgc - does not work due to lctl set_param syntax
12099 for ls in /proc/fs/lustre/ldlm/namespaces/MGC*/lru_size; do
12102 FAIL_ON_ERROR=true cleanup
12103 FAIL_ON_ERROR=true setup
12105 run_test 900 "umount should not race with any mgc requeue thread"
12108 check_and_cleanup_lustre
12109 if [ "$I_MOUNTED" != "yes" ]; then
12110 lctl set_param debug="$OLDDEBUG" 2> /dev/null || true