2 # -*- tab-width: 8; indent-tabs-mode: t; -*-
4 # Run select tests by setting ONLY, or as arguments to the script.
5 # Skip specific tests by setting EXCEPT.
7 # e.g. ONLY="22 23" or ONLY="`seq 32 39`" or EXCEPT="31"
11 # bug number for skipped test: 13297 2108 9789 3637 9789 3561 12622 5188
12 ALWAYS_EXCEPT=" 42a 42b 42c 42d 45 51d 68b $SANITY_EXCEPT"
13 # UPDATE THE COMMENT ABOVE WITH BUG NUMBERS WHEN CHANGING ALWAYS_EXCEPT!
15 # with LOD/OSP landing
16 # bug number for skipped tests: LU-2036
17 ALWAYS_EXCEPT=" 76 $ALWAYS_EXCEPT"
21 if [ -r /etc/SuSE-release ]
23 local vers=`grep VERSION /etc/SuSE-release | awk '{print $3}'`
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 230d"
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 && TESTS="59 60 61 4062 4063"
490 local SYMNAME=$(str_repeat 'x' $i)
491 ln -s $SYMNAME $DIR/$tdir/f$i || error "failed $i-char symlink"
492 readlink $DIR/$tdir/f$i || error "failed $i-char readlink"
495 run_test 17g "symlinks: really long symlink name and inode boundaries"
497 test_17h() { #bug 17378
498 remote_mds_nodsh && skip "remote MDS with nodsh" && return
499 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
501 test_mkdir -p $DIR/$tdir
502 if [ $MDSCOUNT -gt 1 ]; then
503 mdt_idx=$($LFS getdirstripe -i $DIR/$tdir)
507 $SETSTRIPE -c -1 $DIR/$tdir
508 #define OBD_FAIL_MDS_LOV_PREP_CREATE 0x141
509 do_facet mds$((mdt_idx + 1)) lctl set_param fail_loc=0x80000141
510 touch $DIR/$tdir/$tfile || true
512 run_test 17h "create objects: lov_free_memmd() doesn't lbug"
514 test_17i() { #bug 20018
515 remote_mds_nodsh && skip "remote MDS with nodsh" && return
516 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
517 test_mkdir -p $DIR/$tdir
518 local foo=$DIR/$tdir/$tfile
520 if [ $MDSCOUNT -gt 1 ]; then
521 mdt_idx=$($LFS getdirstripe -i $DIR/$tdir)
525 ln -s $foo $foo || error "create symlink failed"
526 #define OBD_FAIL_MDS_READLINK_EPROTO 0x143
527 do_facet mds$((mdt_idx + 1)) lctl set_param fail_loc=0x80000143
528 ls -l $foo && error "error not detected"
531 run_test 17i "don't panic on short symlink"
533 test_17k() { #bug 22301
534 rsync --help | grep -q xattr ||
535 skip_env "$(rsync --version | head -n1) does not support xattrs"
536 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return 0
537 test_mkdir -p $DIR/$tdir
538 test_mkdir -p $DIR/$tdir.new
539 touch $DIR/$tdir/$tfile
540 ln -s $DIR/$tdir/$tfile $DIR/$tdir/$tfile.lnk
541 rsync -av -X $DIR/$tdir/ $DIR/$tdir.new ||
542 error "rsync failed with xattrs enabled"
544 run_test 17k "symlinks: rsync with xattrs enabled ========================="
546 test_17l() { # LU-279
548 touch $DIR/$tdir/$tfile
549 ln -s $DIR/$tdir/$tfile $DIR/$tdir/$tfile.lnk
550 for path in "$DIR/$tdir" "$DIR/$tdir/$tfile" "$DIR/$tdir/$tfile.lnk"; do
551 # -h to not follow symlinks. -m '' to list all the xattrs.
552 # grep to remove first line: '# file: $path'.
553 for xattr in `getfattr -hm '' $path 2>/dev/null | grep -v '^#'`;
555 lgetxattr_size_check $path $xattr ||
556 error "lgetxattr_size_check $path $xattr failed"
560 run_test 17l "Ensure lgetxattr's returned xattr size is consistent ========"
564 local short_sym="0123456789"
565 local WDIR=$DIR/${tdir}m
572 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] &&
573 [ $(lustre_version_code $SINGLEMDS) -le $(version_code 2.2.93) ] &&
574 skip "MDS 2.2.0-2.2.93 do not NUL-terminate symlinks" && return
576 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
577 skip "only for ldiskfs MDT" && return 0
579 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
583 # create a long symlink file
584 for ((i = 0; i < 4; ++i)); do
585 long_sym=${long_sym}${long_sym}
588 echo "create 512 short and long symlink files under $WDIR"
589 for ((i = 0; i < 256; ++i)); do
590 ln -sf ${long_sym}"a5a5" $WDIR/long-$i
591 ln -sf ${short_sym}"a5a5" $WDIR/short-$i
597 wait_delete_completed
599 echo "recreate the 512 symlink files with a shorter string"
600 for ((i = 0; i < 512; ++i)); do
601 # rewrite the symlink file with a shorter string
602 ln -sf ${long_sym} $WDIR/long-$i
603 ln -sf ${short_sym} $WDIR/short-$i
606 mds_index=$($LFS getstripe -M $WDIR)
607 mds_index=$((mds_index+1))
608 devname=$(mdsdevname $mds_index)
609 cmd="$E2FSCK -fnvd $devname"
611 echo "stop and checking mds${mds_index}: $cmd"
612 # e2fsck should not return error
614 do_facet mds${mds_index} $cmd || rc=$?
616 start mds${mds_index} $devname $MDS_MOUNT_OPTS
617 df $MOUNT > /dev/null 2>&1
618 [ $rc -ne 0 ] && error "e2fsck should not report error upon "\
619 "short/long symlink MDT: rc=$rc"
622 run_test 17m "run e2fsck against MDT which contains short/long symlink"
624 check_fs_consistency_17n() {
630 # create/unlink in 17n only change 2 MDTs(MDT1/MDT2),
631 # so it only check MDT1/MDT2 instead of all of MDTs.
632 for mdt_index in $(seq 1 2); do
633 devname=$(mdsdevname $mdt_index)
634 cmd="$E2FSCK -fnvd $devname"
636 echo "stop and checking mds${mdt_index}: $cmd"
637 # e2fsck should not return error
639 do_facet mds${mdt_index} $cmd || rc=$?
641 start mds${mdt_index} $devname $MDS_MOUNT_OPTS
642 df $MOUNT > /dev/null 2>&1
643 [ $rc -ne 0 ] && break
651 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] &&
652 [ $(lustre_version_code $SINGLEMDS) -le $(version_code 2.2.93) ] &&
653 skip "MDS 2.2.0-2.2.93 do not NUL-terminate symlinks" && return
655 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
656 skip "only for ldiskfs MDT" && return 0
658 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
660 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
663 for ((i=0; i<10; i++)); do
664 $LFS mkdir -i 1 $DIR/$tdir/remote_dir_${i} ||
665 error "create remote dir error $i"
666 createmany -o $DIR/$tdir/remote_dir_${i}/f 10 ||
667 error "create files under remote dir failed $i"
670 check_fs_consistency_17n ||
671 error "e2fsck report error after create files under remote dir"
673 for ((i=0;i<10;i++)); do
674 rm -rf $DIR/$tdir/remote_dir_${i} ||
675 error "destroy remote dir error $i"
678 check_fs_consistency_17n ||
679 error "e2fsck report error after unlink files under remote dir"
681 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.50) ] &&
682 skip "lustre < 2.4.50 does not support migrate mv " && return
684 for ((i=0; i<10; i++)); do
685 mkdir -p $DIR/$tdir/remote_dir_${i}
686 createmany -o $DIR/$tdir/remote_dir_${i}/f 10 ||
687 error "create files under remote dir failed $i"
688 $LFS mv -M 1 $DIR/$tdir/remote_dir_${i} ||
689 error "migrate remote dir error $i"
691 check_fs_consistency_17n || error "e2fsck report error after migration"
693 for ((i=0;i<10;i++)); do
694 rm -rf $DIR/$tdir/remote_dir_${i} ||
695 error "destroy remote dir error $i"
698 check_fs_consistency_17n || error "e2fsck report error after unlink"
700 run_test 17n "run e2fsck against master/slave MDT which contains remote dir"
703 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.3.64) ]] &&
704 skip "Need MDS version at least 2.3.64" && return
706 local WDIR=$DIR/${tdir}o
712 mdt_index=$($LFS getstripe -M $WDIR)
713 mdt_index=$((mdt_index+1))
714 mdtdevname=$(mdsdevname $mdt_index)
718 start mds${mdt_index} $mdtdevname $MDS_MOUNT_OPTS
720 #define OBD_FAIL_OSD_LMA_INCOMPAT 0x194
721 do_facet mds${mdt_index} lctl set_param fail_loc=0x194
722 ls -l $WDIR/$tfile && rc=1
723 do_facet mds${mdt_index} lctl set_param fail_loc=0
724 [[ $rc -ne 0 ]] && error "stat file should fail"
727 run_test 17o "stat file with incompat LMA feature"
730 touch $DIR/f || error "Failed to touch $DIR/f: $?"
731 ls $DIR || error "Failed to ls $DIR: $?"
733 run_test 18 "touch .../f ; ls ... =============================="
739 $CHECKSTAT -a $DIR/$tfile || error "$tfile was not removed"
741 run_test 19a "touch .../f19 ; ls -l ... ; rm .../f19 ==========="
744 ls -l $DIR/$tfile && error "ls -l $tfile failed"|| true
746 run_test 19b "ls -l .../f19 (should return error) =============="
749 [ $RUNAS_ID -eq $UID ] &&
750 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
751 $RUNAS touch $DIR/$tfile && error "create non-root file failed" || true
753 run_test 19c "$RUNAS touch .../f19 (should return error) =="
756 cat $DIR/f19 && error || true
758 run_test 19d "cat .../f19 (should return error) =============="
770 $CHECKSTAT -a $DIR/$tfile || error "$tfile was not removed"
772 run_test 20 "touch .../f ; ls -l ... ==========================="
775 test_mkdir -p $DIR/$tdir
776 [ -f $DIR/$tdir/dangle ] && rm -f $DIR/$tdir/dangle
777 ln -s dangle $DIR/$tdir/link
778 echo foo >> $DIR/$tdir/link
779 cat $DIR/$tdir/dangle
780 $CHECKSTAT -t link $DIR/$tdir/link || error "$tdir/link not a link"
781 $CHECKSTAT -f -t file $DIR/$tdir/link ||
782 error "$tdir/link not linked to a file"
784 run_test 21 "write to dangling link ============================"
788 test_mkdir -p $DIR/$tdir
789 chown $RUNAS_ID:$RUNAS_GID $WDIR
790 (cd $WDIR || error "cd $WDIR failed";
791 $RUNAS tar cf - /etc/hosts /etc/sysconfig/network | \
793 ls -lR $WDIR/etc || error "ls -lR $WDIR/etc failed"
794 $CHECKSTAT -t dir $WDIR/etc || error "checkstat -t dir failed"
795 $CHECKSTAT -u \#$RUNAS_ID -g \#$RUNAS_GID $WDIR/etc || error "checkstat -u failed"
797 run_test 22 "unpack tar archive as non-root user ==============="
801 test_mkdir -p $DIR/$tdir
802 local file=$DIR/$tdir/$tfile
804 openfile -f O_CREAT:O_EXCL $file || error "$file create failed"
805 openfile -f O_CREAT:O_EXCL $file &&
806 error "$file recreate succeeded" || true
808 run_test 23a "O_CREAT|O_EXCL in subdir =========================="
810 test_23b() { # bug 18988
811 test_mkdir -p $DIR/$tdir
812 local file=$DIR/$tdir/$tfile
815 echo foo > $file || error "write filed"
816 echo bar >> $file || error "append filed"
817 $CHECKSTAT -s 8 $file || error "wrong size"
820 run_test 23b "O_APPEND check =========================="
824 echo '-- same directory rename'
825 test_mkdir $DIR/$tdir
826 touch $DIR/$tdir/$tfile.1
827 mv $DIR/$tdir/$tfile.1 $DIR/$tdir/$tfile.2
828 $CHECKSTAT -t file $DIR/$tdir/$tfile.2 || error "$tfile.2 not a file"
830 run_test 24a "rename file to non-existent target"
833 test_mkdir $DIR/$tdir
834 touch $DIR/$tdir/$tfile.{1,2}
835 mv $DIR/$tdir/$tfile.1 $DIR/$tdir/$tfile.2
836 $CHECKSTAT -a $DIR/$tdir/$tfile.1 || error "$tfile.1 exists"
837 $CHECKSTAT -t file $DIR/$tdir/$tfile.2 || error "$tfile.2 not a file"
839 run_test 24b "rename file to existing target"
842 test_mkdir $DIR/$tdir
843 test_mkdir $DIR/$tdir/d$testnum.1
844 mv $DIR/$tdir/d$testnum.1 $DIR/$tdir/d$testnum.2
845 $CHECKSTAT -a $DIR/$tdir/d$testnum.1 || error "d$testnum.1 exists"
846 $CHECKSTAT -t dir $DIR/$tdir/d$testnum.2 || error "d$testnum.2 not dir"
848 run_test 24c "rename directory to non-existent target"
851 test_mkdir -c1 $DIR/$tdir
852 test_mkdir -c1 $DIR/$tdir/d$testnum.1
853 test_mkdir -c1 $DIR/$tdir/d$testnum.2
854 mrename $DIR/$tdir/d$testnum.1 $DIR/$tdir/d$testnum.2
855 $CHECKSTAT -a $DIR/$tdir/d$testnum.1 || error "d$testnum.1 exists"
856 $CHECKSTAT -t dir $DIR/$tdir/d$testnum.2 || error "d$testnum.2 not dir"
858 run_test 24d "rename directory to existing target"
861 echo '-- cross directory renames --'
865 mv $DIR/R5a/f $DIR/R5b/g
866 $CHECKSTAT -a $DIR/R5a/f || error
867 $CHECKSTAT -t file $DIR/R5b/g || error
869 run_test 24e "touch .../R5a/f; rename .../R5a/f .../R5b/g ======"
874 touch $DIR/R6a/f $DIR/R6b/g
875 mv $DIR/R6a/f $DIR/R6b/g
876 $CHECKSTAT -a $DIR/R6a/f || error
877 $CHECKSTAT -t file $DIR/R6b/g || error
879 run_test 24f "touch .../R6a/f R6b/g; mv .../R6a/f .../R6b/g ===="
884 test_mkdir $DIR/R7a/d
885 mv $DIR/R7a/d $DIR/R7b/e
886 $CHECKSTAT -a $DIR/R7a/d || error
887 $CHECKSTAT -t dir $DIR/R7b/e || error
889 run_test 24g "mkdir .../R7{a,b}/d; mv .../R7a/d .../R7b/e ======"
892 test_mkdir -c1 $DIR/R8a
893 test_mkdir -c1 $DIR/R8b
894 test_mkdir -c1 $DIR/R8a/d
895 test_mkdir -c1 $DIR/R8b/e
896 mrename $DIR/R8a/d $DIR/R8b/e
897 $CHECKSTAT -a $DIR/R8a/d || error
898 $CHECKSTAT -t dir $DIR/R8b/e || error
900 run_test 24h "mkdir .../R8{a,b}/{d,e}; rename .../R8a/d .../R8b/e"
903 echo "-- rename error cases"
907 mrename $DIR/R9/f $DIR/R9/a
908 $CHECKSTAT -t file $DIR/R9/f || error
909 $CHECKSTAT -t dir $DIR/R9/a || error
910 $CHECKSTAT -a $DIR/R9/a/f || error
912 run_test 24i "rename file to dir error: touch f ; mkdir a ; rename f a"
916 mrename $DIR/R10/f $DIR/R10/g
917 $CHECKSTAT -t dir $DIR/R10 || error
918 $CHECKSTAT -a $DIR/R10/f || error
919 $CHECKSTAT -a $DIR/R10/g || error
921 run_test 24j "source does not exist ============================"
925 test_mkdir $DIR/R11a/d
927 mv $DIR/R11a/f $DIR/R11a/d
928 $CHECKSTAT -a $DIR/R11a/f || error
929 $CHECKSTAT -t file $DIR/R11a/d/f || error
931 run_test 24k "touch .../R11a/f; mv .../R11a/f .../R11a/d ======="
933 # bug 2429 - rename foo foo foo creates invalid file
936 $MULTIOP $f OcNs || error
938 run_test 24l "Renaming a file to itself ========================"
942 $MULTIOP $f OcLN ${f}2 ${f}2 || error "link ${f}2 ${f}2 failed"
943 # on ext3 this does not remove either the source or target files
944 # though the "expected" operation would be to remove the source
945 $CHECKSTAT -t file ${f} || error "${f} missing"
946 $CHECKSTAT -t file ${f}2 || error "${f}2 missing"
948 run_test 24m "Renaming a file to a hard link to itself ========="
952 # this stats the old file after it was renamed, so it should fail
956 $CHECKSTAT ${f}.rename
959 run_test 24n "Statting the old file after renaming (Posix rename 2)"
962 check_kernel_version 37 || return 0
963 test_mkdir -p $DIR/d24o
964 rename_many -s random -v -n 10 $DIR/d24o
966 run_test 24o "rename of files during htree split ==============="
971 DIRINO=`ls -lid $DIR/R12a | awk '{ print $1 }'`
972 mrename $DIR/R12a $DIR/R12b
973 $CHECKSTAT -a $DIR/R12a || error
974 $CHECKSTAT -t dir $DIR/R12b || error
975 DIRINO2=`ls -lid $DIR/R12b | awk '{ print $1 }'`
976 [ "$DIRINO" = "$DIRINO2" ] || error "R12a $DIRINO != R12b $DIRINO2"
978 run_test 24p "mkdir .../R12{a,b}; rename .../R12a .../R12b"
980 cleanup_multiop_pause() {
986 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
989 local DIRINO=$(ls -lid $DIR/R13a | awk '{ print $1 }')
990 multiop_bg_pause $DIR/R13b D_c || error "multiop failed to start"
993 trap cleanup_multiop_pause EXIT
994 mrename $DIR/R13a $DIR/R13b
995 $CHECKSTAT -a $DIR/R13a || error "R13a still exists"
996 $CHECKSTAT -t dir $DIR/R13b || error "R13b does not exist"
997 local DIRINO2=$(ls -lid $DIR/R13b | awk '{ print $1 }')
998 [ "$DIRINO" = "$DIRINO2" ] || error "R13a $DIRINO != R13b $DIRINO2"
999 cleanup_multiop_pause
1000 wait $MULTIPID || error "multiop close failed"
1002 run_test 24q "mkdir .../R13{a,b}; open R13b rename R13a R13b ==="
1004 test_24r() { #bug 3789
1005 test_mkdir $DIR/R14a
1006 test_mkdir $DIR/R14a/b
1007 mrename $DIR/R14a $DIR/R14a/b && error "rename to subdir worked!"
1008 $CHECKSTAT -t dir $DIR/R14a || error "$DIR/R14a missing"
1009 $CHECKSTAT -t dir $DIR/R14a/b || error "$DIR/R14a/b missing"
1011 run_test 24r "mkdir .../R14a/b; rename .../R14a .../R14a/b ====="
1014 test_mkdir $DIR/R15a
1015 test_mkdir $DIR/R15a/b
1016 test_mkdir $DIR/R15a/b/c
1017 mrename $DIR/R15a $DIR/R15a/b/c && error "rename to sub-subdir worked!"
1018 $CHECKSTAT -t dir $DIR/R15a || error "$DIR/R15a missing"
1019 $CHECKSTAT -t dir $DIR/R15a/b/c || error "$DIR/R15a/b/c missing"
1021 run_test 24s "mkdir .../R15a/b/c; rename .../R15a .../R15a/b/c ="
1023 test_mkdir $DIR/R16a
1024 test_mkdir $DIR/R16a/b
1025 test_mkdir $DIR/R16a/b/c
1026 mrename $DIR/R16a/b/c $DIR/R16a && error "rename to sub-subdir worked!"
1027 $CHECKSTAT -t dir $DIR/R16a || error "$DIR/R16a missing"
1028 $CHECKSTAT -t dir $DIR/R16a/b/c || error "$DIR/R16a/b/c missing"
1030 run_test 24t "mkdir .../R16a/b/c; rename .../R16a/b/c .../R16a ="
1032 test_24u() { # bug12192
1034 $MULTIOP $DIR/$tfile C2w$((2048 * 1024))c || error
1035 $CHECKSTAT -s $((2048 * 1024)) $DIR/$tfile || error "wrong file size"
1037 run_test 24u "create stripe file"
1043 simple_cleanup_common() {
1046 wait_delete_completed
1049 max_pages_per_rpc() {
1050 $LCTL get_param -n mdc.*.max_pages_per_rpc | head -n1
1054 local NRFILES=100000
1055 local FREE_INODES=$(mdt_free_inodes 0)
1056 [ $FREE_INODES -lt $NRFILES ] && \
1057 skip "not enough free inodes $FREE_INODES required $NRFILES" &&
1060 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1061 trap simple_cleanup_common EXIT
1063 # Performance issue on ZFS see LU-4072 (c.f. LU-2887)
1064 [ $(facet_fstype $SINGLEMDS) = "zfs" ] && NRFILES=10000
1067 createmany -m $DIR/$tdir/$tfile $NRFILES
1069 cancel_lru_locks mdc
1070 lctl set_param mdc.*.stats clear
1072 ls $DIR/$tdir >/dev/null || error "error in listing large dir"
1074 # LU-5 large readdir
1075 # DIRENT_SIZE = 32 bytes for sizeof(struct lu_dirent) +
1076 # 8 bytes for name(filename is mostly 5 in this test) +
1077 # 8 bytes for luda_type
1078 # take into account of overhead in lu_dirpage header and end mark in
1079 # each page, plus one in RPC_NUM calculation.
1081 RPC_SIZE=$(($(max_pages_per_rpc) * $(page_size)))
1082 RPC_NUM=$(((NRFILES * DIRENT_SIZE + RPC_SIZE - 1) / RPC_SIZE + 1))
1083 mds_readpage=$(lctl get_param mdc.*MDT0000*.stats | \
1084 awk '/^mds_readpage/ {print $2}')
1085 [ $mds_readpage -gt $RPC_NUM ] && \
1086 error "large readdir doesn't take effect"
1088 simple_cleanup_common
1090 run_test 24v "list directory with large files (handle hash collision, bug: 17560)"
1092 test_24w() { # bug21506
1094 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=4096 || return 1
1095 dd if=/dev/zero bs=$SZ1 count=1 >> $DIR/$tfile || return 2
1096 dd if=$DIR/$tfile of=$DIR/${tfile}_left bs=1M skip=4097 || return 3
1097 SZ2=`ls -l $DIR/${tfile}_left | awk '{print $5}'`
1098 [ "$SZ1" = "$SZ2" ] || \
1099 error "Error reading at the end of the file $tfile"
1101 run_test 24w "Reading a file larger than 4Gb"
1104 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
1105 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1107 local remote_dir=$DIR/$tdir/remote_dir
1110 $LFS mkdir -i $MDTIDX $remote_dir ||
1111 error "create remote directory failed"
1113 mkdir -p $DIR/$tdir/src_dir
1114 touch $DIR/$tdir/src_file
1115 mkdir -p $remote_dir/tgt_dir
1116 touch $remote_dir/tgt_file
1118 mrename $remote_dir $DIR/ &&
1119 error "rename dir cross MDT works!"
1121 mrename $DIR/$tdir/src_dir $remote_dir/tgt_dir &&
1122 error "rename dir cross MDT works!"
1124 mrename $DIR/$tdir/src_file $remote_dir/tgt_file &&
1125 error "rename file cross MDT works!"
1127 ln $DIR/$tdir/src_file $remote_dir/tgt_file1 &&
1128 error "ln file cross MDT should not work!"
1130 rm -rf $DIR/$tdir || error "Can not delete directories"
1132 run_test 24x "cross rename/link should be failed"
1135 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
1136 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1138 local remote_dir=$DIR/$tdir/remote_dir
1141 $LFS mkdir -i $MDTIDX $remote_dir ||
1142 error "create remote directory failed"
1144 mkdir -p $remote_dir/src_dir
1145 touch $remote_dir/src_file
1146 mkdir -p $remote_dir/tgt_dir
1147 touch $remote_dir/tgt_file
1149 mrename $remote_dir/src_dir $remote_dir/tgt_dir ||
1150 error "rename subdir in the same remote dir failed!"
1152 mrename $remote_dir/src_file $remote_dir/tgt_file ||
1153 error "rename files in the same remote dir failed!"
1155 ln $remote_dir/tgt_file $remote_dir/tgt_file1 ||
1156 error "link files in the same remote dir failed!"
1158 rm -rf $DIR/$tdir || error "Can not delete directories"
1160 run_test 24y "rename/link on the same dir should succeed"
1163 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
1164 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1166 local remote_src=$DIR/$tdir/remote_dir
1167 local remote_tgt=$DIR/$tdir/remote_tgt
1170 $LFS mkdir -i $MDTIDX $remote_src ||
1171 error "create remote directory failed"
1173 $LFS mkdir -i $MDTIDX $remote_tgt ||
1174 error "create remote directory failed"
1176 mrename $remote_src $remote_tgt &&
1177 error "rename remote dirs should not work!"
1179 # If target dir does not exists, it should succeed
1181 mrename $remote_src $remote_tgt ||
1182 error "rename remote dirs(tgt dir does not exists) failed!"
1184 rm -rf $DIR/$tdir || error "Can not delete directories"
1186 run_test 24z "rename one remote dir to another remote dir should fail"
1188 test_24A() { # LU-3182
1193 createmany -m $DIR/$tdir/$tfile $NFILES
1194 local t=`ls $DIR/$tdir | wc -l`
1195 local u=`ls $DIR/$tdir | sort -u | wc -l`
1196 if [ $t -ne $NFILES -o $u -ne $NFILES ] ; then
1197 error "Expected $NFILES files, got $t ($u unique)"
1200 rm -rf $DIR/$tdir || error "Can not delete directories"
1202 run_test 24A "readdir() returns correct number of entries."
1205 echo '== symlink sanity ============================================='
1209 touch $DIR/s25/foo || error
1211 run_test 25a "create file in symlinked directory ==============="
1214 [ ! -d $DIR/d25 ] && test_25a
1215 $CHECKSTAT -t file $DIR/s25/foo || error
1217 run_test 25b "lookup file in symlinked directory ==============="
1221 test_mkdir $DIR/d26/d26-2
1222 ln -s d26/d26-2 $DIR/s26
1223 touch $DIR/s26/foo || error
1225 run_test 26a "multiple component symlink ======================="
1228 test_mkdir -p $DIR/d26b/d26-2
1229 ln -s d26b/d26-2/foo $DIR/s26-2
1230 touch $DIR/s26-2 || error
1232 run_test 26b "multiple component symlink at end of lookup ======"
1235 test_mkdir $DIR/d26.2
1236 touch $DIR/d26.2/foo
1237 ln -s d26.2 $DIR/s26.2-1
1238 ln -s s26.2-1 $DIR/s26.2-2
1239 ln -s s26.2-2 $DIR/s26.2-3
1240 chmod 0666 $DIR/s26.2-3/foo
1242 run_test 26c "chain of symlinks ================================"
1244 # recursive symlinks (bug 439)
1246 ln -s d26-3/foo $DIR/d26-3
1248 run_test 26d "create multiple component recursive symlink ======"
1251 [ ! -h $DIR/d26-3 ] && test_26d
1254 run_test 26e "unlink multiple component recursive symlink ======"
1256 # recursive symlinks (bug 7022)
1258 test_mkdir -p $DIR/$tdir
1259 test_mkdir $DIR/$tdir/$tfile || error "mkdir $DIR/$tdir/$tfile failed"
1260 cd $DIR/$tdir/$tfile || error "cd $DIR/$tdir/$tfile failed"
1261 test_mkdir -p lndir/bar1 || error "mkdir lndir/bar1 failed"
1262 test_mkdir $DIR/$tdir/$tfile/$tfile || error "mkdir $tfile failed"
1263 cd $tfile || error "cd $tfile failed"
1264 ln -s .. dotdot || error "ln dotdot failed"
1265 ln -s dotdot/lndir lndir || error "ln lndir failed"
1266 cd $DIR/$tdir || error "cd $DIR/$tdir failed"
1267 output=`ls $tfile/$tfile/lndir/bar1`
1268 [ "$output" = bar1 ] && error "unexpected output"
1269 rm -r $tfile || error "rm $tfile failed"
1270 $CHECKSTAT -a $DIR/$tfile || error "$tfile not gone"
1272 run_test 26f "rm -r of a directory which has recursive symlink ="
1275 echo '== stripe sanity =============================================='
1276 test_mkdir -p $DIR/d27 || error "mkdir failed"
1278 $SETSTRIPE -c 1 $DIR/d27/f0 || error "setstripe failed"
1279 $CHECKSTAT -t file $DIR/d27/f0 || error "checkstat failed"
1281 log "== test_27a: write to one stripe file ========================="
1282 cp /etc/hosts $DIR/d27/f0 || error
1284 run_test 27a "one stripe file =================================="
1287 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping 2-stripe test" && return
1288 test_mkdir -p $DIR/d27
1289 $SETSTRIPE -c 2 $DIR/d27/f01 || error "setstripe failed"
1290 $GETSTRIPE -c $DIR/d27/f01
1291 [ $($GETSTRIPE -c $DIR/d27/f01) -eq 2 ] ||
1292 error "two-stripe file doesn't have two stripes"
1294 dd if=/dev/zero of=$DIR/d27/f01 bs=4k count=4 || error "dd failed"
1296 run_test 27b "create and write to two stripe file"
1299 test_mkdir -p $DIR/d27
1300 $SETSTRIPE -c 0 -i -1 -S 0 $DIR/d27/fdef || error "setstripe failed"
1301 $CHECKSTAT -t file $DIR/d27/fdef || error "checkstat failed"
1302 dd if=/dev/zero of=$DIR/d27/fdef bs=4k count=4 || error
1304 run_test 27d "create file with default settings ================"
1307 test_mkdir -p $DIR/d27
1308 $SETSTRIPE -c 2 $DIR/d27/f12 || error "setstripe failed"
1309 $SETSTRIPE -c 2 $DIR/d27/f12 && error "setstripe succeeded twice"
1310 $CHECKSTAT -t file $DIR/d27/f12 || error "checkstat failed"
1312 run_test 27e "setstripe existing file (should return error) ======"
1315 test_mkdir -p $DIR/d27
1316 $SETSTRIPE -S 100 -i 0 -c 1 $DIR/d27/fbad && error "setstripe failed"
1317 dd if=/dev/zero of=$DIR/d27/fbad bs=4k count=4 || error "dd failed"
1318 $GETSTRIPE $DIR/d27/fbad || error "$GETSTRIPE failed"
1320 run_test 27f "setstripe with bad stripe size (should return error)"
1323 test_mkdir -p $DIR/d27
1324 $MCREATE $DIR/d27/fnone || error "mcreate failed"
1325 $GETSTRIPE $DIR/d27/fnone 2>&1 | grep "no stripe info" ||
1326 error "$DIR/d27/fnone has object"
1328 run_test 27g "$GETSTRIPE with no objects"
1331 touch $DIR/d27/fsome || error "touch failed"
1332 [ $($GETSTRIPE -c $DIR/d27/fsome) -gt 0 ] || error "missing objects"
1334 run_test 27i "$GETSTRIPE with some objects"
1337 test_mkdir -p $DIR/d27
1338 $SETSTRIPE -i $OSTCOUNT $DIR/d27/f27j && error "setstripe failed"||true
1340 run_test 27j "setstripe with bad stripe offset (should return error)"
1342 test_27k() { # bug 2844
1343 test_mkdir -p $DIR/d27
1345 LL_MAX_BLKSIZE=$((4 * 1024 * 1024))
1346 [ ! -d $DIR/d27 ] && test_mkdir -p $DIR d27
1347 $SETSTRIPE -S 67108864 $FILE || error "setstripe failed"
1348 BLKSIZE=`stat $FILE | awk '/IO Block:/ { print $7 }'`
1349 [ $BLKSIZE -le $LL_MAX_BLKSIZE ] || error "1:$BLKSIZE > $LL_MAX_BLKSIZE"
1350 dd if=/dev/zero of=$FILE bs=4k count=1
1351 BLKSIZE=`stat $FILE | awk '/IO Block:/ { print $7 }'`
1352 [ $BLKSIZE -le $LL_MAX_BLKSIZE ] || error "2:$BLKSIZE > $LL_MAX_BLKSIZE"
1354 run_test 27k "limit i_blksize for broken user apps ============="
1357 test_mkdir -p $DIR/d27
1358 mcreate $DIR/f27l || error "creating file"
1359 $RUNAS $SETSTRIPE -c 1 $DIR/f27l && \
1360 error "setstripe should have failed" || true
1362 run_test 27l "check setstripe permissions (should return error)"
1365 [ "$OSTCOUNT" -lt "2" ] && skip_env "$OSTCOUNT < 2 OSTs -- skipping" &&
1367 if [ $ORIGFREE -gt $MAXFREE ]; then
1368 skip "$ORIGFREE > $MAXFREE skipping out-of-space test on OST0"
1371 trap simple_cleanup_common EXIT
1372 test_mkdir -p $DIR/$tdir
1373 $SETSTRIPE -i 0 -c 1 $DIR/$tdir/f27m_1
1374 dd if=/dev/zero of=$DIR/$tdir/f27m_1 bs=1024 count=$MAXFREE &&
1375 error "dd should fill OST0"
1377 while $SETSTRIPE -i 0 -c 1 $DIR/$tdir/f27m_$i; do
1379 [ $i -gt 256 ] && break
1382 touch $DIR/$tdir/f27m_$i
1383 [ `$GETSTRIPE $DIR/$tdir/f27m_$i | grep -A 10 obdidx | awk '{print $1}'| grep -w "0"` ] &&
1384 error "OST0 was full but new created file still use it"
1386 touch $DIR/$tdir/f27m_$i
1387 [ `$GETSTRIPE $DIR/$tdir/f27m_$i | grep -A 10 obdidx | awk '{print $1}'| grep -w "0"` ] &&
1388 error "OST0 was full but new created file still use it"
1389 simple_cleanup_common
1391 run_test 27m "create file while OST0 was full =================="
1394 local DELAY=$(do_facet $SINGLEMDS lctl get_param -n lov.*.qos_maxage | head -n 1 | awk '{print $1 * 2}')
1398 # OSCs keep a NOSPC flag that will be reset after ~5s (qos_maxage)
1399 # if the OST isn't full anymore.
1401 local OSTIDX=${1:-""}
1403 local list=$(comma_list $(osts_nodes))
1404 [ "$OSTIDX" ] && list=$(facet_host ost$((OSTIDX + 1)))
1406 do_nodes $list lctl set_param fail_loc=0
1407 sync # initiate all OST_DESTROYs from MDS to OST
1411 exhaust_precreations() {
1414 local FAILIDX=${3:-$OSTIDX}
1416 test_mkdir -p $DIR/$tdir
1417 local MDSIDX=$(get_mds_dir "$DIR/$tdir")
1418 echo OSTIDX=$OSTIDX MDSIDX=$MDSIDX
1420 local OST=$(ostname_from_index $OSTIDX)
1421 local MDT_INDEX=$(lfs df | grep "\[MDT:$((MDSIDX - 1))\]" | awk '{print $1}' | \
1422 sed -e 's/_UUID$//;s/^.*-//')
1425 local mdtosc_proc1=$(get_mdtosc_proc_path mds${MDSIDX} $OST)
1426 local last_id=$(do_facet mds${MDSIDX} lctl get_param -n \
1427 osc.$mdtosc_proc1.prealloc_last_id)
1428 local next_id=$(do_facet mds${MDSIDX} lctl get_param -n \
1429 osc.$mdtosc_proc1.prealloc_next_id)
1431 local mdtosc_proc2=$(get_mdtosc_proc_path mds${MDSIDX})
1432 do_facet mds${MDSIDX} lctl get_param osc.$mdtosc_proc2.prealloc*
1434 test_mkdir -p $DIR/$tdir/${OST}
1435 $SETSTRIPE -i $OSTIDX -c 1 $DIR/$tdir/${OST}
1436 #define OBD_FAIL_OST_ENOSPC 0x215
1437 do_facet ost$((OSTIDX + 1)) lctl set_param fail_val=$FAILIDX
1438 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=0x215
1439 echo "Creating to objid $last_id on ost $OST..."
1440 createmany -o $DIR/$tdir/${OST}/f $next_id $((last_id - next_id + 2))
1441 do_facet mds${MDSIDX} lctl get_param osc.$mdtosc_proc2.prealloc*
1442 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=$FAILLOC
1446 exhaust_all_precreations() {
1448 for (( i=0; i < OSTCOUNT; i++ )) ; do
1449 exhaust_precreations $i $1 -1
1454 [ "$OSTCOUNT" -lt "2" ] && skip_env "too few OSTs" && return
1455 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1456 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1457 remote_ost_nodsh && skip "remote OST with nodsh" && return
1460 rm -f $DIR/$tdir/$tfile
1461 exhaust_precreations 0 0x80000215
1462 $SETSTRIPE -c -1 $DIR/$tdir
1463 touch $DIR/$tdir/$tfile || error
1464 $GETSTRIPE $DIR/$tdir/$tfile
1467 run_test 27n "create file with some full OSTs =================="
1470 [ "$OSTCOUNT" -lt "2" ] && skip_env "too few OSTs" && return
1471 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1472 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1473 remote_ost_nodsh && skip "remote OST with nodsh" && return
1476 rm -f $DIR/$tdir/$tfile
1477 exhaust_all_precreations 0x215
1479 touch $DIR/$tdir/$tfile && error "able to create $DIR/$tdir/$tfile"
1484 run_test 27o "create file with all full OSTs (should error) ===="
1487 [ "$OSTCOUNT" -lt "2" ] && skip_env "too few OSTs" && return
1488 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1489 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1490 remote_ost_nodsh && skip "remote OST with nodsh" && return
1493 rm -f $DIR/$tdir/$tfile
1494 test_mkdir -p $DIR/$tdir
1496 $MCREATE $DIR/$tdir/$tfile || error "mcreate failed"
1497 $TRUNCATE $DIR/$tdir/$tfile 80000000 || error "truncate failed"
1498 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat failed"
1500 exhaust_precreations 0 0x80000215
1501 echo foo >> $DIR/$tdir/$tfile || error "append failed"
1502 $CHECKSTAT -s 80000004 $DIR/$tdir/$tfile || error "checkstat failed"
1503 $GETSTRIPE $DIR/$tdir/$tfile
1507 run_test 27p "append to a truncated file with some full OSTs ==="
1510 [ "$OSTCOUNT" -lt "2" ] && skip_env "too few OSTs" && return
1511 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1512 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1513 remote_ost_nodsh && skip "remote OST with nodsh" && return
1516 rm -f $DIR/$tdir/$tfile
1518 test_mkdir -p $DIR/$tdir
1519 $MCREATE $DIR/$tdir/$tfile || error "mcreate $DIR/$tdir/$tfile failed"
1520 $TRUNCATE $DIR/$tdir/$tfile 80000000 ||error "truncate $DIR/$tdir/$tfile failed"
1521 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat failed"
1523 exhaust_all_precreations 0x215
1525 echo foo >> $DIR/$tdir/$tfile && error "append succeeded"
1526 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat 2 failed"
1530 run_test 27q "append to truncated file with all OSTs full (should error) ==="
1533 [ "$OSTCOUNT" -lt "2" ] && skip_env "too few OSTs" && return
1534 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1535 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1536 remote_ost_nodsh && skip "remote OST with nodsh" && return
1539 rm -f $DIR/$tdir/$tfile
1540 exhaust_precreations 0 0x80000215
1542 $SETSTRIPE -i 0 -c 2 $DIR/$tdir/$tfile # && error
1546 run_test 27r "stripe file with some full OSTs (shouldn't LBUG) ="
1548 test_27s() { # bug 10725
1549 test_mkdir -p $DIR/$tdir
1550 local stripe_size=$((4096 * 1024 * 1024)) # 2^32
1551 local stripe_count=0
1552 [ $OSTCOUNT -eq 1 ] || stripe_count=2
1553 $SETSTRIPE -S $stripe_size -c $stripe_count $DIR/$tdir &&
1554 error "stripe width >= 2^32 succeeded" || true
1557 run_test 27s "lsm_xfersize overflow (should error) (bug 10725)"
1559 test_27t() { # bug 10864
1564 $WLFS getstripe $tfile
1567 run_test 27t "check that utils parse path correctly"
1569 test_27u() { # bug 4900
1570 [ "$OSTCOUNT" -lt "2" ] && skip_env "too few OSTs" && return
1571 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1573 local list=$(comma_list $(mdts_nodes))
1575 #define OBD_FAIL_MDS_OSC_PRECREATE 0x139
1576 do_nodes $list $LCTL set_param fail_loc=0x139
1577 test_mkdir -p $DIR/$tdir
1579 createmany -o $DIR/$tdir/t- 1000
1580 do_nodes $list $LCTL set_param fail_loc=0
1582 TLOG=$DIR/$tfile.getstripe
1583 $GETSTRIPE $DIR/$tdir > $TLOG
1584 OBJS=`awk -vobj=0 '($1 == 0) { obj += 1 } END { print obj;}' $TLOG`
1585 unlinkmany $DIR/$tdir/t- 1000
1586 [ $OBJS -gt 0 ] && \
1587 error "$OBJS objects created on OST-0. See $TLOG" || pass
1589 run_test 27u "skip object creation on OSC w/o objects =========="
1591 test_27v() { # bug 4900
1592 [ "$OSTCOUNT" -lt "2" ] && skip_env "too few OSTs" && return
1593 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1594 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1595 remote_ost_nodsh && skip "remote OST with nodsh" && return
1597 exhaust_all_precreations 0x215
1600 test_mkdir -p $DIR/$tdir
1601 $SETSTRIPE -c 1 $DIR/$tdir # 1 stripe / file
1603 touch $DIR/$tdir/$tfile
1604 #define OBD_FAIL_TGT_DELAY_PRECREATE 0x705
1606 for (( i=1; i < OSTCOUNT; i++ )); do
1607 do_facet ost$i lctl set_param fail_loc=0x705
1609 local START=`date +%s`
1610 createmany -o $DIR/$tdir/$tfile 32
1612 local FINISH=`date +%s`
1613 local TIMEOUT=`lctl get_param -n timeout`
1614 local PROCESS=$((FINISH - START))
1615 [ $PROCESS -ge $((TIMEOUT / 2)) ] && \
1616 error "$FINISH - $START >= $TIMEOUT / 2"
1617 sleep $((TIMEOUT / 2 - PROCESS))
1620 run_test 27v "skip object creation on slow OST ================="
1622 test_27w() { # bug 10997
1623 test_mkdir -p $DIR/$tdir || error "mkdir failed"
1624 $SETSTRIPE -S 65536 $DIR/$tdir/f0 || error "setstripe failed"
1625 [ $($GETSTRIPE -S $DIR/$tdir/f0) -ne 65536 ] &&
1626 error "stripe size $size != 65536" || true
1627 [ $($GETSTRIPE -d $DIR/$tdir | grep -c "stripe_count") -ne 1 ] &&
1628 error "$GETSTRIPE -d $DIR/$tdir failed" || true
1630 run_test 27w "check $SETSTRIPE -S option"
1633 [ "$OSTCOUNT" -lt "2" ] &&
1634 skip_env "skipping multiple stripe count/offset test" && return
1636 test_mkdir -p $DIR/$tdir || error "mkdir failed"
1637 for i in $(seq 1 $OSTCOUNT); do
1639 $SETSTRIPE -c $i -i $offset $DIR/$tdir/f$i ||
1640 error "setstripe -c $i -i $offset failed"
1641 count=$($GETSTRIPE -c $DIR/$tdir/f$i)
1642 index=$($GETSTRIPE -i $DIR/$tdir/f$i)
1643 [ $count -ne $i ] && error "stripe count $count != $i" || true
1644 [ $index -ne $offset ] &&
1645 error "stripe offset $index != $offset" || true
1648 run_test 27wa "check $SETSTRIPE -c -i options"
1651 remote_ost_nodsh && skip "remote OST with nodsh" && return
1652 [ "$OSTCOUNT" -lt "2" ] && skip_env "$OSTCOUNT < 2 OSTs" && return
1653 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1654 OFFSET=$(($OSTCOUNT - 1))
1656 local OST=$(ostname_from_index $OSTIDX)
1658 test_mkdir -p $DIR/$tdir
1659 $SETSTRIPE -c 1 $DIR/$tdir # 1 stripe per file
1660 do_facet ost$((OSTIDX + 1)) lctl set_param -n obdfilter.$OST.degraded 1
1662 createmany -o $DIR/$tdir/$tfile $OSTCOUNT
1663 for i in `seq 0 $OFFSET`; do
1664 [ `$GETSTRIPE $DIR/$tdir/$tfile$i | grep -A 10 obdidx | awk '{print $1}' | grep -w "$OSTIDX"` ] &&
1665 error "OST0 was degraded but new created file still use it"
1667 do_facet ost$((OSTIDX + 1)) lctl set_param -n obdfilter.$OST.degraded 0
1669 run_test 27x "create files while OST0 is degraded"
1672 [ "$OSTCOUNT" -lt "2" ] && skip_env "$OSTCOUNT < 2 OSTs -- skipping" && return
1673 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1674 remote_ost_nodsh && skip "remote OST with nodsh" && return
1675 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1677 local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS $FSNAME-OST0000)
1678 local last_id=$(do_facet $SINGLEMDS lctl get_param -n \
1679 osc.$mdtosc.prealloc_last_id)
1680 local next_id=$(do_facet $SINGLEMDS lctl get_param -n \
1681 osc.$mdtosc.prealloc_next_id)
1682 local fcount=$((last_id - next_id))
1683 [ $fcount -eq 0 ] && skip "not enough space on OST0" && return
1684 [ $fcount -gt $OSTCOUNT ] && fcount=$OSTCOUNT
1686 local MDS_OSCS=$(do_facet $SINGLEMDS lctl dl |
1687 awk '/[oO][sS][cC].*md[ts]/ { print $4 }')
1688 local OST_DEACTIVE_IDX=-1
1693 for OSC in $MDS_OSCS; do
1694 OST=$(osc_to_ost $OSC)
1695 OSTIDX=$(index_from_ostuuid $OST)
1696 if [ $OST_DEACTIVE_IDX == -1 ]; then
1697 OST_DEACTIVE_IDX=$OSTIDX
1699 if [ $OSTIDX != $OST_DEACTIVE_IDX ]; then
1700 echo $OSC "is Deactivated:"
1701 do_facet $SINGLEMDS lctl --device %$OSC deactivate
1705 OSTIDX=$(index_from_ostuuid $OST)
1707 $SETSTRIPE -c 1 $DIR/$tdir # 1 stripe / file
1709 for OSC in $MDS_OSCS; do
1710 OST=$(osc_to_ost $OSC)
1711 OSTIDX=$(index_from_ostuuid $OST)
1712 if [ $OSTIDX == $OST_DEACTIVE_IDX ]; then
1713 echo $OST "is degraded:"
1714 do_facet ost$((OSTIDX+1)) lctl set_param -n \
1715 obdfilter.$OST.degraded=1
1720 createmany -o $DIR/$tdir/$tfile $fcount
1722 for OSC in $MDS_OSCS; do
1723 OST=$(osc_to_ost $OSC)
1724 OSTIDX=$(index_from_ostuuid $OST)
1725 if [ $OSTIDX == $OST_DEACTIVE_IDX ]; then
1726 echo $OST "is recovered from degraded:"
1727 do_facet ost$((OSTIDX+1)) lctl set_param -n \
1728 obdfilter.$OST.degraded=0
1730 do_facet $SINGLEMDS lctl --device %$OSC activate
1734 # all osp devices get activated, hence -1 stripe count restored
1737 # sleep 2*lod_qos_maxage seconds waiting for lod qos to notice osp
1738 # devices get activated.
1740 $SETSTRIPE -c -1 $DIR/$tfile
1741 stripecnt=$($GETSTRIPE -c $DIR/$tfile)
1743 [ $stripecnt -ne $OSTCOUNT ] &&
1744 error "Of $OSTCOUNT OSTs, only $stripecnt is available"
1747 run_test 27y "create files while OST0 is degraded and the rest inactive"
1753 lmm_count=$($GETSTRIPE -c $1)
1754 lmm_seq=$($GETSTRIPE -v $1 | awk '/lmm_seq/ { print $2 }')
1755 lmm_oid=$($GETSTRIPE -v $1 | awk '/lmm_object_id/ { print $2 }')
1757 local old_ifs="$IFS"
1759 fid=($($LFS path2fid $1))
1762 log "FID seq ${fid[1]}, oid ${fid[2]} ver ${fid[3]}"
1763 log "LOV seq $lmm_seq, oid $lmm_oid, count: $lmm_count"
1765 # compare lmm_seq and lu_fid->f_seq
1766 [ $lmm_seq = ${fid[1]} ] || { error "SEQ mismatch"; return 1; }
1767 # compare lmm_object_id and lu_fid->oid
1768 [ $lmm_oid = ${fid[2]} ] || { error "OID mismatch"; return 2; }
1770 # check the trusted.fid attribute of the OST objects of the file
1771 local have_obdidx=false
1773 $GETSTRIPE $1 | while read obdidx oid hex seq; do
1774 # skip lines up to and including "obdidx"
1775 [ -z "$obdidx" ] && break
1776 [ "$obdidx" = "obdidx" ] && have_obdidx=true && continue
1777 $have_obdidx || continue
1779 local ost=$((obdidx + 1))
1780 local dev=$(ostdevname $ost)
1783 log "want: stripe:$stripe_nr ost:$obdidx oid:$oid/$hex seq:$seq"
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="O/$seq/d$((oid %32))/$oid_hex"
1795 # Don't unmount/remount the OSTs if we don't need to do that.
1796 # LU-2577 changes filter_fid to be smaller, so debugfs needs
1797 # update too, until that use mount/ll_decode_filter_fid/mount.
1798 # Re-enable when debugfs will understand new filter_fid.
1800 if false && [ $(facet_fstype ost$ost) == ldiskfs ]; then
1801 ff=$(do_facet ost$ost "$DEBUGFS -c -R 'stat $obj_file' \
1802 $dev 2>/dev/null" | grep "parent=")
1805 mount_fstype ost$ost
1806 ff=$(do_facet ost$ost $LL_DECODE_FILTER_FID \
1807 $(facet_mntpt ost$ost)/$obj_file)
1808 unmount_fstype ost$ost
1809 start ost$ost $dev $OST_MOUNT_OPTS
1812 [ -z "$ff" ] && error "$obj_file: no filter_fid info"
1814 echo "$ff" | sed -e 's#.*objid=#got: objid=#'
1816 # /mnt/O/0/d23/23: objid=23 seq=0 parent=[0x200000400:0x1e:0x1]
1817 # fid: objid=23 seq=0 parent=[0x200000400:0x1e:0x0] stripe=1
1818 local ff_parent=$(echo $ff|sed -e 's/.*parent=.//')
1819 local ff_pseq=$(echo $ff_parent | cut -d: -f1)
1820 local ff_poid=$(echo $ff_parent | cut -d: -f2)
1822 if echo $ff_parent | grep -q 'stripe='; then
1823 ff_pstripe=$(echo $ff_parent | sed -e 's/.*stripe=//')
1826 # $LL_DECODE_FILTER_FID does not print "stripe="; look
1827 # into f_ver in this case. See the comment on
1830 ff_pstripe=$(echo $ff_parent | cut -d: -f3 |
1834 # compare lmm_seq and filter_fid->ff_parent.f_seq
1835 [ $ff_pseq = $lmm_seq ] ||
1836 error "FF parent SEQ $ff_pseq != $lmm_seq"
1837 # compare lmm_object_id and filter_fid->ff_parent.f_oid
1838 [ $ff_poid = $lmm_oid ] ||
1839 error "FF parent OID $ff_poid != $lmm_oid"
1840 (($ff_pstripe == $stripe_nr)) ||
1841 error "FF stripe $ff_pstripe != $stripe_nr"
1843 stripe_nr=$((stripe_nr + 1))
1848 remote_ost_nodsh && skip "remote OST with nodsh" && return
1849 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1850 test_mkdir -p $DIR/$tdir
1852 $SETSTRIPE -c 1 -i 0 -S 64k $DIR/$tdir/$tfile-1 ||
1853 { error "setstripe -c -1 failed"; return 1; }
1854 # We need to send a write to every object to get parent FID info set.
1855 # This _should_ also work for setattr, but does not currently.
1856 # touch $DIR/$tdir/$tfile-1 ||
1857 dd if=/dev/zero of=$DIR/$tdir/$tfile-1 bs=1M count=1 ||
1858 { error "dd $tfile-1 failed"; return 2; }
1859 $SETSTRIPE -c -1 -i $((OSTCOUNT - 1)) -S 1M $DIR/$tdir/$tfile-2 ||
1860 { error "setstripe -c -1 failed"; return 3; }
1861 dd if=/dev/zero of=$DIR/$tdir/$tfile-2 bs=1M count=$OSTCOUNT ||
1862 { error "dd $tfile-2 failed"; return 4; }
1864 # make sure write RPCs have been sent to OSTs
1867 check_seq_oid $DIR/$tdir/$tfile-1 || return 5
1868 check_seq_oid $DIR/$tdir/$tfile-2 || return 6
1870 run_test 27z "check SEQ/OID on the MDT and OST filesystems"
1872 test_27A() { # b=19102
1873 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1874 local restore_size=$($GETSTRIPE -S $MOUNT)
1875 local restore_count=$($GETSTRIPE -c $MOUNT)
1876 local restore_offset=$($GETSTRIPE -i $MOUNT)
1877 $SETSTRIPE -c 0 -i -1 -S 0 $MOUNT
1878 wait_update $HOSTNAME "$GETSTRIPE -c $MOUNT | sed 's/ *//g'" "1" 20 ||
1879 error "stripe count $($GETSTRIPE -c $MOUNT) != 1"
1880 local default_size=$($GETSTRIPE -S $MOUNT)
1881 local default_offset=$($GETSTRIPE -i $MOUNT)
1882 local dsize=$((1024 * 1024))
1883 [ $default_size -eq $dsize ] ||
1884 error "stripe size $default_size != $dsize"
1885 [ $default_offset -eq -1 ] ||error "stripe offset $default_offset != -1"
1886 $SETSTRIPE -c $restore_count -i $restore_offset -S $restore_size $MOUNT
1888 run_test 27A "check filesystem-wide default LOV EA values"
1890 test_27B() { # LU-2523
1891 test_mkdir -p $DIR/$tdir
1892 rm -f $DIR/$tdir/f0 $DIR/$tdir/f1
1894 # open f1 with O_LOV_DELAY_CREATE
1896 # call setstripe ioctl on open file descriptor for f1
1898 multiop $DIR/$tdir/f1 oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:nB1c \
1902 # open f1 with O_LOV_DELAY_CREATE
1904 # call setstripe ioctl on open file descriptor for f1
1906 multiop $DIR/$tdir/f1 oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:uB1c
1908 # Allow multiop to fail in imitation of NFS's busted semantics.
1911 run_test 27B "call setstripe on open unlinked file/rename victim"
1913 test_27C() { #LU-2871
1914 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs" && return
1922 test_mkdir -p $DIR/$tdir
1924 for i in $(seq 0 $((OSTCOUNT - 1))); do
1925 # set stripe across all OSTs starting from OST$i
1926 $SETSTRIPE -i $i -c -1 $tfile$i
1927 # get striping information
1928 ost_idx=($($GETSTRIPE $tfile$i |
1929 tail -n $((OSTCOUNT + 1)) | awk '{print $1}'))
1933 [ ${#ost_idx[@]} -eq $OSTCOUNT ] ||
1934 error "${#ost_idx[@]} != $OSTCOUNT"
1936 for index in $(seq 0 $((OSTCOUNT - 1))); do
1938 for j in $(echo ${ost_idx[@]}); do
1939 if [ $index -eq $j ]; then
1945 error "Can not find $index in ${ost_idx[@]}"
1949 run_test 27C "check full striping across all OSTs"
1951 # createtest also checks that device nodes are created and
1952 # then visible correctly (#2091)
1953 test_28() { # bug 2091
1955 $CREATETEST $DIR/d28/ct || error
1957 run_test 28 "create/mknod/mkdir with bad file types ============"
1960 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1961 cancel_lru_locks mdc
1967 declare -i LOCKCOUNTORIG=0
1968 for lock_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_count); do
1969 let LOCKCOUNTORIG=$LOCKCOUNTORIG+$lock_count
1971 [ $LOCKCOUNTORIG -eq 0 ] && echo "No mdc lock count" && return 1
1973 declare -i LOCKUNUSEDCOUNTORIG=0
1974 for unused_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_unused_count); do
1975 let LOCKUNUSEDCOUNTORIG=$LOCKUNUSEDCOUNTORIG+$unused_count
1982 declare -i LOCKCOUNTCURRENT=0
1983 for lock_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_count); do
1984 let LOCKCOUNTCURRENT=$LOCKCOUNTCURRENT+$lock_count
1987 declare -i LOCKUNUSEDCOUNTCURRENT=0
1988 for unused_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_unused_count); do
1989 let LOCKUNUSEDCOUNTCURRENT=$LOCKUNUSEDCOUNTCURRENT+$unused_count
1992 if [ "$LOCKCOUNTCURRENT" -gt "$LOCKCOUNTORIG" ]; then
1993 lctl set_param -n ldlm.dump_namespaces ""
1994 error "CURRENT: $LOCKCOUNTCURRENT > $LOCKCOUNTORIG"
1995 $LCTL dk | sort -k4 -t: > $TMP/test_29.dk
1996 log "dumped log to $TMP/test_29.dk (bug 5793)"
1999 if [ "$LOCKUNUSEDCOUNTCURRENT" -gt "$LOCKUNUSEDCOUNTORIG" ]; then
2000 error "UNUSED: $LOCKUNUSEDCOUNTCURRENT > $LOCKUNUSEDCOUNTORIG"
2001 $LCTL dk | sort -k4 -t: > $TMP/test_29.dk
2002 log "dumped log to $TMP/test_29.dk (bug 5793)"
2006 run_test 29 "IT_GETATTR regression ============================"
2008 test_30a() { # was test_30
2009 cp `which ls` $DIR || cp /bin/ls $DIR
2013 run_test 30a "execute binary from Lustre (execve) =============="
2016 cp `which ls` $DIR || cp /bin/ls $DIR
2018 $RUNAS $DIR/ls / || error
2021 run_test 30b "execute binary from Lustre as non-root ==========="
2023 test_30c() { # b=22376
2024 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2025 cp `which ls` $DIR || cp /bin/ls $DIR
2027 cancel_lru_locks mdc
2028 cancel_lru_locks osc
2029 $RUNAS $DIR/ls / || error
2032 run_test 30c "execute binary from Lustre without read perms ===="
2035 $OPENUNLINK $DIR/f31 $DIR/f31 || error
2036 $CHECKSTAT -a $DIR/f31 || error
2038 run_test 31a "open-unlink file =================================="
2041 touch $DIR/f31 || error
2042 ln $DIR/f31 $DIR/f31b || error
2043 $MULTIOP $DIR/f31b Ouc || error
2044 $CHECKSTAT -t file $DIR/f31 || error
2046 run_test 31b "unlink file with multiple links while open ======="
2049 touch $DIR/f31 || error
2050 ln $DIR/f31 $DIR/f31c || error
2051 multiop_bg_pause $DIR/f31 O_uc || return 1
2053 $MULTIOP $DIR/f31c Ouc
2054 kill -USR1 $MULTIPID
2057 run_test 31c "open-unlink file with multiple links ============="
2060 opendirunlink $DIR/d31d $DIR/d31d || error
2061 $CHECKSTAT -a $DIR/d31d || error
2063 run_test 31d "remove of open directory ========================="
2065 test_31e() { # bug 2904
2066 check_kernel_version 34 || return 0
2067 openfilleddirunlink $DIR/d31e || error
2069 run_test 31e "remove of open non-empty directory ==============="
2071 test_31f() { # bug 4554
2072 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2074 test_mkdir $DIR/d31f
2075 $SETSTRIPE -S 1048576 -c 1 $DIR/d31f
2076 cp /etc/hosts $DIR/d31f
2078 $GETSTRIPE $DIR/d31f/hosts
2079 multiop_bg_pause $DIR/d31f D_c || return 1
2082 rm -rv $DIR/d31f || error "first of $DIR/d31f"
2083 test_mkdir $DIR/d31f
2084 $SETSTRIPE -S 1048576 -c 1 $DIR/d31f
2085 cp /etc/hosts $DIR/d31f
2087 $GETSTRIPE $DIR/d31f/hosts
2088 multiop_bg_pause $DIR/d31f D_c || return 1
2091 kill -USR1 $MULTIPID || error "first opendir $MULTIPID not running"
2092 wait $MULTIPID || error "first opendir $MULTIPID failed"
2096 kill -USR1 $MULTIPID2 || error "second opendir $MULTIPID not running"
2097 wait $MULTIPID2 || error "second opendir $MULTIPID2 failed"
2100 run_test 31f "remove of open directory with open-unlink file ==="
2103 echo "-- cross directory link --"
2104 test_mkdir -c1 $DIR/${tdir}ga
2105 test_mkdir -c1 $DIR/${tdir}gb
2106 touch $DIR/${tdir}ga/f
2107 ln $DIR/${tdir}ga/f $DIR/${tdir}gb/g
2108 $CHECKSTAT -t file $DIR/${tdir}ga/f || error "source"
2109 [ `stat -c%h $DIR/${tdir}ga/f` == '2' ] || error "source nlink"
2110 $CHECKSTAT -t file $DIR/${tdir}gb/g || error "target"
2111 [ `stat -c%h $DIR/${tdir}gb/g` == '2' ] || error "target nlink"
2113 run_test 31g "cross directory link==============="
2116 echo "-- cross directory link --"
2117 test_mkdir -c1 $DIR/${tdir}
2118 test_mkdir -c1 $DIR/${tdir}/dir
2119 touch $DIR/${tdir}/f
2120 ln $DIR/${tdir}/f $DIR/${tdir}/dir/g
2121 $CHECKSTAT -t file $DIR/${tdir}/f || error "source"
2122 [ `stat -c%h $DIR/${tdir}/f` == '2' ] || error "source nlink"
2123 $CHECKSTAT -t file $DIR/${tdir}/dir/g || error "target"
2124 [ `stat -c%h $DIR/${tdir}/dir/g` == '2' ] || error "target nlink"
2126 run_test 31h "cross directory link under child==============="
2129 echo "-- cross directory link --"
2130 test_mkdir -c1 $DIR/$tdir
2131 test_mkdir -c1 $DIR/$tdir/dir
2132 touch $DIR/$tdir/dir/f
2133 ln $DIR/$tdir/dir/f $DIR/$tdir/g
2134 $CHECKSTAT -t file $DIR/$tdir/dir/f || error "source"
2135 [ `stat -c%h $DIR/$tdir/dir/f` == '2' ] || error "source nlink"
2136 $CHECKSTAT -t file $DIR/$tdir/g || error "target"
2137 [ `stat -c%h $DIR/$tdir/g` == '2' ] || error "target nlink"
2139 run_test 31i "cross directory link under parent==============="
2142 test_mkdir -c1 -p $DIR/$tdir
2143 test_mkdir -c1 -p $DIR/$tdir/dir1
2144 ln $DIR/$tdir/dir1 $DIR/$tdir/dir2 && error "ln for dir"
2145 link $DIR/$tdir/dir1 $DIR/$tdir/dir3 && error "link for dir"
2146 mlink $DIR/$tdir/dir1 $DIR/$tdir/dir4 && error "mlink for dir"
2147 mlink $DIR/$tdir/dir1 $DIR/$tdir/dir1 && error "mlink to the same dir"
2150 run_test 31j "link for directory==============="
2153 test_mkdir -c1 -p $DIR/$tdir
2155 touch $DIR/$tdir/exist
2156 mlink $DIR/$tdir/s $DIR/$tdir/t || error "mlink"
2157 mlink $DIR/$tdir/s $DIR/$tdir/exist && error "mlink to exist file"
2158 mlink $DIR/$tdir/s $DIR/$tdir/s && error "mlink to the same file"
2159 mlink $DIR/$tdir/s $DIR/$tdir && error "mlink to parent dir"
2160 mlink $DIR/$tdir $DIR/$tdir/s && error "mlink parent dir to target"
2161 mlink $DIR/$tdir/not-exist $DIR/$tdir/foo && error "mlink non-existing to new"
2162 mlink $DIR/$tdir/not-exist $DIR/$tdir/s && error "mlink non-existing to exist"
2165 run_test 31k "link to file: the same, non-existing, dir==============="
2171 touch $DIR/d31m2/exist
2172 mlink $DIR/d31m/s $DIR/d31m2/t || error "mlink"
2173 mlink $DIR/d31m/s $DIR/d31m2/exist && error "mlink to exist file"
2174 mlink $DIR/d31m/s $DIR/d31m2 && error "mlink to parent dir"
2175 mlink $DIR/d31m2 $DIR/d31m/s && error "mlink parent dir to target"
2176 mlink $DIR/d31m/not-exist $DIR/d31m2/foo && error "mlink non-existing to new"
2177 mlink $DIR/d31m/not-exist $DIR/d31m2/s && error "mlink non-existing to exist"
2180 run_test 31m "link to file: the same, non-existing, dir==============="
2183 touch $DIR/$tfile || error "cannot create '$DIR/$tfile'"
2184 nlink=$(stat --format=%h $DIR/$tfile)
2185 [ ${nlink:--1} -eq 1 ] || error "nlink is $nlink, expected 1"
2187 local cmd="exec $fd<$DIR/$tfile"
2190 trap "eval $cmd" EXIT
2191 nlink=$(stat --dereference --format=%h /proc/self/fd/$fd)
2192 [ ${nlink:--1} -eq 1 ] || error "nlink is $nlink, expected 1"
2193 rm $DIR/$tfile || error "cannot remove '$DIR/$tfile'"
2194 nlink=$(stat --dereference --format=%h /proc/self/fd/$fd)
2195 [ ${nlink:--1} -eq 0 ] || error "nlink is $nlink, expected 0"
2198 run_test 31n "check link count of unlinked file"
2201 local TEMPNAME=$(mktemp $1_XXXXXX)
2202 mlink $TEMPNAME $1 2> /dev/null &&
2203 echo "$BASHPID: link $TEMPNAME to $1 succeeded"
2207 test_31o() { # LU-2901
2209 for LOOP in $(seq 100); do
2210 rm -f $DIR/$tdir/$tfile*
2211 for THREAD in $(seq 8); do
2212 link_one $DIR/$tdir/$tfile.$LOOP &
2215 local LINKS=$(ls -1 $DIR/$tdir | grep -c $tfile.$LOOP)
2216 [ $LINKS -gt 1 ] && ls $DIR/$tdir &&
2217 error "$LINKS duplicate links to $tfile.$LOOP" &&
2221 run_test 31o "duplicate hard links with same filename"
2223 cleanup_test32_mount() {
2225 $UMOUNT -d $DIR/$tdir/ext2-mountpoint
2229 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2230 echo "== more mountpoints and symlinks ================="
2231 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2232 trap cleanup_test32_mount EXIT
2233 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2234 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2235 $CHECKSTAT -t dir $DIR/$tdir/ext2-mountpoint/.. || error
2236 cleanup_test32_mount
2238 run_test 32a "stat d32a/ext2-mountpoint/.. ====================="
2241 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2242 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2243 trap cleanup_test32_mount EXIT
2244 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2245 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2246 ls -al $DIR/$tdir/ext2-mountpoint/.. || error
2247 cleanup_test32_mount
2249 run_test 32b "open d32b/ext2-mountpoint/.. ====================="
2252 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2253 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2254 trap cleanup_test32_mount EXIT
2255 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2256 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2257 test_mkdir -p $DIR/$tdir/d2/test_dir
2258 $CHECKSTAT -t dir $DIR/$tdir/ext2-mountpoint/../d2/test_dir || error
2259 cleanup_test32_mount
2261 run_test 32c "stat d32c/ext2-mountpoint/../d2/test_dir ========="
2264 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2265 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2266 trap cleanup_test32_mount EXIT
2267 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2268 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2269 test_mkdir -p $DIR/$tdir/d2/test_dir
2270 ls -al $DIR/$tdir/ext2-mountpoint/../d2/test_dir || error
2271 cleanup_test32_mount
2273 run_test 32d "open d32d/ext2-mountpoint/../d2/test_dir ========="
2276 [ -e $DIR/d32e ] && rm -fr $DIR/d32e
2277 test_mkdir -p $DIR/d32e/tmp
2278 TMP_DIR=$DIR/d32e/tmp
2279 ln -s $DIR/d32e $TMP_DIR/symlink11
2280 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
2281 $CHECKSTAT -t link $DIR/d32e/tmp/symlink11 || error
2282 $CHECKSTAT -t link $DIR/d32e/symlink01 || error
2284 run_test 32e "stat d32e/symlink->tmp/symlink->lustre-subdir ===="
2287 [ -e $DIR/d32f ] && rm -fr $DIR/d32f
2288 test_mkdir -p $DIR/d32f/tmp
2289 TMP_DIR=$DIR/d32f/tmp
2290 ln -s $DIR/d32f $TMP_DIR/symlink11
2291 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
2292 ls $DIR/d32f/tmp/symlink11 || error
2293 ls $DIR/d32f/symlink01 || error
2295 run_test 32f "open d32f/symlink->tmp/symlink->lustre-subdir ===="
2298 TMP_DIR=$DIR/$tdir/tmp
2299 test_mkdir -p $DIR/$tdir/tmp
2300 test_mkdir $DIR/${tdir}2
2301 ln -s $DIR/${tdir}2 $TMP_DIR/symlink12
2302 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
2303 $CHECKSTAT -t link $TMP_DIR/symlink12 || error
2304 $CHECKSTAT -t link $DIR/$tdir/symlink02 || error
2305 $CHECKSTAT -t dir -f $TMP_DIR/symlink12 || error
2306 $CHECKSTAT -t dir -f $DIR/$tdir/symlink02 || error
2308 run_test 32g "stat d32g/symlink->tmp/symlink->lustre-subdir/${tdir}2"
2311 rm -fr $DIR/$tdir $DIR/${tdir}2
2312 TMP_DIR=$DIR/$tdir/tmp
2313 test_mkdir -p $DIR/$tdir/tmp
2314 test_mkdir $DIR/${tdir}2
2315 ln -s $DIR/${tdir}2 $TMP_DIR/symlink12
2316 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
2317 ls $TMP_DIR/symlink12 || error
2318 ls $DIR/$tdir/symlink02 || error
2320 run_test 32h "open d32h/symlink->tmp/symlink->lustre-subdir/${tdir}2"
2323 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2324 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2325 trap cleanup_test32_mount EXIT
2326 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2327 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2328 touch $DIR/$tdir/test_file
2329 $CHECKSTAT -t file $DIR/$tdir/ext2-mountpoint/../test_file || error
2330 cleanup_test32_mount
2332 run_test 32i "stat d32i/ext2-mountpoint/../test_file ==========="
2335 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2336 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2337 trap cleanup_test32_mount EXIT
2338 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2339 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2340 touch $DIR/$tdir/test_file
2341 cat $DIR/$tdir/ext2-mountpoint/../test_file || error
2342 cleanup_test32_mount
2344 run_test 32j "open d32j/ext2-mountpoint/../test_file ==========="
2347 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2349 trap cleanup_test32_mount EXIT
2350 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2351 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint
2352 test_mkdir -p $DIR/$tdir/d2
2353 touch $DIR/$tdir/d2/test_file || error
2354 $CHECKSTAT -t file $DIR/$tdir/ext2-mountpoint/../d2/test_file || error
2355 cleanup_test32_mount
2357 run_test 32k "stat d32k/ext2-mountpoint/../d2/test_file ========"
2360 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2362 trap cleanup_test32_mount EXIT
2363 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2364 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2365 test_mkdir -p $DIR/$tdir/d2
2366 touch $DIR/$tdir/d2/test_file
2367 cat $DIR/$tdir/ext2-mountpoint/../d2/test_file || error
2368 cleanup_test32_mount
2370 run_test 32l "open d32l/ext2-mountpoint/../d2/test_file ========"
2374 test_mkdir -p $DIR/d32m/tmp
2375 TMP_DIR=$DIR/d32m/tmp
2376 ln -s $DIR $TMP_DIR/symlink11
2377 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
2378 $CHECKSTAT -t link $DIR/d32m/tmp/symlink11 || error
2379 $CHECKSTAT -t link $DIR/d32m/symlink01 || error
2381 run_test 32m "stat d32m/symlink->tmp/symlink->lustre-root ======"
2385 test_mkdir -p $DIR/d32n/tmp
2386 TMP_DIR=$DIR/d32n/tmp
2387 ln -s $DIR $TMP_DIR/symlink11
2388 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
2389 ls -l $DIR/d32n/tmp/symlink11 || error
2390 ls -l $DIR/d32n/symlink01 || error
2392 run_test 32n "open d32n/symlink->tmp/symlink->lustre-root ======"
2395 rm -fr $DIR/d32o $DIR/$tfile
2397 test_mkdir -p $DIR/d32o/tmp
2398 TMP_DIR=$DIR/d32o/tmp
2399 ln -s $DIR/$tfile $TMP_DIR/symlink12
2400 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
2401 $CHECKSTAT -t link $DIR/d32o/tmp/symlink12 || error
2402 $CHECKSTAT -t link $DIR/d32o/symlink02 || error
2403 $CHECKSTAT -t file -f $DIR/d32o/tmp/symlink12 || error
2404 $CHECKSTAT -t file -f $DIR/d32o/symlink02 || error
2406 run_test 32o "stat d32o/symlink->tmp/symlink->lustre-root/$tfile"
2416 test_mkdir -p $DIR/d32p/tmp
2418 TMP_DIR=$DIR/d32p/tmp
2420 ln -s $DIR/$tfile $TMP_DIR/symlink12
2422 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
2424 cat $DIR/d32p/tmp/symlink12 || error
2426 cat $DIR/d32p/symlink02 || error
2429 run_test 32p "open d32p/symlink->tmp/symlink->lustre-root/$tfile"
2431 cleanup_testdir_mount() {
2433 $UMOUNT -d $DIR/$tdir
2437 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2438 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2439 trap cleanup_testdir_mount EXIT
2440 test_mkdir -p $DIR/$tdir
2441 touch $DIR/$tdir/under_the_mount
2442 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir
2443 ls $DIR/$tdir | grep "\<under_the_mount\>" && error
2444 cleanup_testdir_mount
2446 run_test 32q "stat follows mountpoints in Lustre (should return error)"
2449 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2450 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2451 trap cleanup_testdir_mount EXIT
2452 test_mkdir -p $DIR/$tdir
2453 touch $DIR/$tdir/under_the_mount
2454 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir
2455 ls $DIR/$tdir | grep -q under_the_mount && error || true
2456 cleanup_testdir_mount
2458 run_test 32r "opendir follows mountpoints in Lustre (should return error)"
2463 chmod 444 $DIR/$tfile
2464 chown $RUNAS_ID $DIR/$tfile
2466 $RUNAS $OPENFILE -f O_RDWR $DIR/$tfile && error || true
2469 run_test 33aa "write file with mode 444 (should return error) ===="
2473 test_mkdir -p $DIR/d33
2474 chown $RUNAS_ID $DIR/d33
2475 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $DIR/d33/f33|| error "create"
2476 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $DIR/d33/f33 && \
2477 error "open RDWR" || true
2479 run_test 33a "test open file(mode=0444) with O_RDWR (should return error)"
2483 test_mkdir -p $DIR/d33
2484 chown $RUNAS_ID $DIR/d33
2485 $RUNAS $OPENFILE -f 1286739555 $DIR/d33/f33 && error "create" || true
2487 run_test 33b "test open file with malformed flags (No panic and return error)"
2490 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2496 remote_ost_nodsh && skip "remote OST with nodsh" && return
2499 test_mkdir -p $DIR/d33
2500 # Read: 0, Write: 4, create/destroy: 2/0, stat: 1, punch: 0
2503 for ostnum in $(seq $OSTCOUNT); do
2504 # test-framework's OST numbering is one-based, while Lustre's
2506 ostname=$(printf "$FSNAME-OST%.4x" $((ostnum - 1)))
2507 # Parsing llobdstat's output sucks; we could grep the /proc
2508 # path, but that's likely to not be as portable as using the
2509 # llobdstat utility. So we parse lctl output instead.
2510 write_bytes=$(do_facet ost$ostnum lctl get_param -n \
2511 obdfilter/$ostname/stats |
2512 awk '/^write_bytes/ {print $7}' )
2513 echo "baseline_write_bytes@$OSTnum/$ostname=$write_bytes"
2514 if (( ${write_bytes:-0} > 0 ))
2521 $all_zeros || return 0
2524 echo foo > $DIR/d33/bar
2528 # Total up write_bytes after writing. We'd better find non-zeros.
2529 for ostnum in $(seq $OSTCOUNT); do
2530 ostname=$(printf "$FSNAME-OST%.4x" $((ostnum - 1)))
2531 write_bytes=$(do_facet ost$ostnum lctl get_param -n \
2532 obdfilter/$ostname/stats |
2533 awk '/^write_bytes/ {print $7}' )
2534 echo "write_bytes@$OSTnum/$ostname=$write_bytes"
2535 if (( ${write_bytes:-0} > 0 ))
2544 for ostnum in $(seq $OSTCOUNT); do
2545 ostname=$(printf "$FSNAME-OST%.4x" $((ostnum - 1)))
2546 echo "Check that write_bytes is present in obdfilter/*/stats:"
2547 do_facet ost$ostnum lctl get_param -n \
2548 obdfilter/$ostname/stats
2550 error "OST not keeping write_bytes stats (b22312)"
2553 run_test 33c "test llobdstat and write_bytes"
2556 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2557 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2559 local remote_dir=$DIR/$tdir/remote_dir
2562 $LFS mkdir -i $MDTIDX $remote_dir ||
2563 error "create remote directory failed"
2565 touch $remote_dir/$tfile
2566 chmod 444 $remote_dir/$tfile
2567 chown $RUNAS_ID $remote_dir/$tfile
2569 $RUNAS $OPENFILE -f O_RDWR $DIR/$tfile && error || true
2571 chown $RUNAS_ID $remote_dir
2572 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $remote_dir/f33 ||
2573 error "create" || true
2574 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $remote_dir/f33 &&
2575 error "open RDWR" || true
2576 $RUNAS $OPENFILE -f 1286739555 $remote_dir/f33 &&
2577 error "create" || true
2579 run_test 33d "openfile with 444 modes and malformed flags under remote dir"
2581 TEST_34_SIZE=${TEST_34_SIZE:-2000000000000}
2584 $MCREATE $DIR/f34 || error
2585 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" || error
2586 $TRUNCATE $DIR/f34 $TEST_34_SIZE || error
2587 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" || error
2588 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2590 run_test 34a "truncate file that has not been opened ==========="
2593 [ ! -f $DIR/f34 ] && test_34a
2594 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2595 $OPENFILE -f O_RDONLY $DIR/f34
2596 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" || error
2597 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2599 run_test 34b "O_RDONLY opening file doesn't create objects ====="
2602 [ ! -f $DIR/f34 ] && test_34a
2603 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2604 $OPENFILE -f O_RDWR $DIR/f34
2605 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" && error
2606 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2608 run_test 34c "O_RDWR opening file-with-size works =============="
2611 [ ! -f $DIR/f34 ] && test_34a
2612 dd if=/dev/zero of=$DIR/f34 conv=notrunc bs=4k count=1 || error
2613 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2616 run_test 34d "write to sparse file ============================="
2620 $MCREATE $DIR/f34e || error
2621 $TRUNCATE $DIR/f34e 1000 || error
2622 $CHECKSTAT -s 1000 $DIR/f34e || error
2623 $OPENFILE -f O_RDWR $DIR/f34e
2624 $CHECKSTAT -s 1000 $DIR/f34e || error
2626 run_test 34e "create objects, some with size and some without =="
2628 test_34f() { # bug 6242, 6243
2629 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2632 $MCREATE $DIR/f34f || error
2633 $TRUNCATE $DIR/f34f $SIZE34F || error "truncating $DIR/f3f to $SIZE34F"
2634 dd if=$DIR/f34f of=$TMP/f34f
2635 $CHECKSTAT -s $SIZE34F $TMP/f34f || error "$TMP/f34f not $SIZE34F bytes"
2636 dd if=/dev/zero of=$TMP/f34fzero bs=$SIZE34F count=1
2637 cmp $DIR/f34f $TMP/f34fzero || error "$DIR/f34f not all zero"
2638 cmp $TMP/f34f $TMP/f34fzero || error "$TMP/f34f not all zero"
2639 rm $TMP/f34f $TMP/f34fzero $DIR/f34f
2641 run_test 34f "read from a file with no objects until EOF ======="
2644 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2645 dd if=/dev/zero of=$DIR/$tfile bs=1 count=100 seek=$TEST_34_SIZE || error
2646 $TRUNCATE $DIR/$tfile $((TEST_34_SIZE / 2))|| error
2647 $CHECKSTAT -s $((TEST_34_SIZE / 2)) $DIR/$tfile || error "truncate failed"
2648 cancel_lru_locks osc
2649 $CHECKSTAT -s $((TEST_34_SIZE / 2)) $DIR/$tfile || \
2650 error "wrong size after lock cancel"
2652 $TRUNCATE $DIR/$tfile $TEST_34_SIZE || error
2653 $CHECKSTAT -s $TEST_34_SIZE $DIR/$tfile || \
2654 error "expanding truncate failed"
2655 cancel_lru_locks osc
2656 $CHECKSTAT -s $TEST_34_SIZE $DIR/$tfile || \
2657 error "wrong expanded size after lock cancel"
2659 run_test 34g "truncate long file ==============================="
2662 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2666 dd if=/dev/zero of=$DIR/$tfile bs=1M count=10 || error
2667 sync # Flush the cache so that multiop below does not block on cache
2668 # flush when getting the group lock
2669 $MULTIOP $DIR/$tfile OG${gid}T${sz}g${gid}c &
2672 # Since just timed wait is not good enough, let's do a sync write
2673 # that way we are sure enough time for a roundtrip + processing
2674 # passed + 2 seconds of extra margin.
2675 dd if=/dev/zero of=$DIR/${tfile}-1 bs=4096 oflag=direct count=1
2679 if [[ `ps h -o comm -p $MULTIPID` == "multiop" ]]; then
2680 error "Multiop blocked on ftruncate, pid=$MULTIPID"
2684 local nsz=`stat -c %s $DIR/$tfile`
2685 [[ $nsz == $sz ]] || error "New size wrong $nsz != $sz"
2687 run_test 34h "ftruncate file under grouplock should not block"
2690 cp /bin/sh $DIR/f35a
2692 chown $RUNAS_ID $DIR/f35a
2693 $RUNAS $DIR/f35a && error || true
2696 run_test 35a "exec file with mode 444 (should return and not leak) ====="
2700 utime $DIR/f36 || error
2702 run_test 36a "MDS utime check (mknod, utime) ==================="
2706 utime $DIR/f36 || error
2708 run_test 36b "OST utime check (open, utime) ===================="
2713 chown $RUNAS_ID $DIR/d36
2714 $RUNAS utime $DIR/d36/f36 || error
2716 run_test 36c "non-root MDS utime check (mknod, utime) =========="
2719 [ ! -d $DIR/d36 ] && test_36c
2720 echo "" > $DIR/d36/f36
2721 $RUNAS utime $DIR/d36/f36 || error
2723 run_test 36d "non-root OST utime check (open, utime) ==========="
2726 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID -- skipping" && return
2727 test_mkdir -p $DIR/$tdir
2728 touch $DIR/$tdir/$tfile
2729 $RUNAS utime $DIR/$tdir/$tfile && \
2730 error "utime worked, expected failure" || true
2732 run_test 36e "utime on non-owned file (should return error) ===="
2736 local LANG_SAVE=$LANG
2737 local LC_LANG_SAVE=$LC_LANG
2738 export LANG=C LC_LANG=C # for date language
2740 DATESTR="Dec 20 2000"
2741 test_mkdir -p $DIR/$tdir
2742 lctl set_param fail_loc=$fl
2744 cp /etc/hosts $DIR/$tdir/$tfile
2745 sync & # write RPC generated with "current" inode timestamp, but delayed
2747 touch --date="$DATESTR" $DIR/$tdir/$tfile # setattr timestamp in past
2748 LS_BEFORE="`ls -l $DIR/$tdir/$tfile`" # old timestamp from client cache
2749 cancel_lru_locks osc
2750 LS_AFTER="`ls -l $DIR/$tdir/$tfile`" # timestamp from OST object
2752 [ "$LS_BEFORE" != "$LS_AFTER" ] && \
2753 echo "BEFORE: $LS_BEFORE" && \
2754 echo "AFTER : $LS_AFTER" && \
2755 echo "WANT : $DATESTR" && \
2756 error "$DIR/$tdir/$tfile timestamps changed" || true
2758 export LANG=$LANG_SAVE LC_LANG=$LC_LANG_SAVE
2762 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2763 #define OBD_FAIL_OST_BRW_PAUSE_BULK 0x214
2764 subr_36fh "0x80000214"
2766 run_test 36f "utime on file racing with OST BRW write =========="
2769 remote_ost_nodsh && skip "remote OST with nodsh" && return
2770 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2775 test_mkdir -p $DIR/$tdir
2776 fmd_max_age=$(do_facet ost1 \
2777 "lctl get_param -n obdfilter.*.client_cache_seconds 2> /dev/null | \
2780 fmd_before=$(do_facet ost1 \
2781 "awk '/ll_fmd_cache/ {print \\\$2}' /proc/slabinfo")
2782 touch $DIR/$tdir/$tfile
2783 sleep $((fmd_max_age + 12))
2784 fmd_after=$(do_facet ost1 \
2785 "awk '/ll_fmd_cache/ {print \\\$2}' /proc/slabinfo")
2787 echo "fmd_before: $fmd_before"
2788 echo "fmd_after: $fmd_after"
2789 [ "$fmd_after" -gt "$fmd_before" ] && \
2790 echo "AFTER: $fmd_after > BEFORE: $fmd_before" && \
2791 error "fmd didn't expire after ping" || true
2793 run_test 36g "filter mod data cache expiry ====================="
2796 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2797 #define OBD_FAIL_OST_BRW_PAUSE_BULK2 0x227
2798 subr_36fh "0x80000227"
2800 run_test 36h "utime on file racing with OST BRW write =========="
2802 # test_37 - duplicate with tests 32q 32r
2805 local file=$DIR/$tfile
2807 openfile -f O_DIRECTORY $file
2810 [ $RC -eq 0 ] && error "opened file $file with O_DIRECTORY" || true
2811 [ $RC -eq $ENOTDIR ] || error "error $RC should be ENOTDIR ($ENOTDIR)"
2813 run_test 38 "open a regular file with O_DIRECTORY should return -ENOTDIR ==="
2817 touch $DIR/${tfile}2
2818 # ls -l $DIR/$tfile $DIR/${tfile}2
2819 # ls -lu $DIR/$tfile $DIR/${tfile}2
2820 # ls -lc $DIR/$tfile $DIR/${tfile}2
2822 $OPENFILE -f O_CREAT:O_TRUNC:O_WRONLY $DIR/${tfile}2
2823 if [ ! $DIR/${tfile}2 -nt $DIR/$tfile ]; then
2825 ls -l --full-time $DIR/$tfile $DIR/${tfile}2
2827 ls -lu --full-time $DIR/$tfile $DIR/${tfile}2
2829 ls -lc --full-time $DIR/$tfile $DIR/${tfile}2
2830 error "O_TRUNC didn't change timestamps"
2833 run_test 39 "mtime changed on create ==========================="
2836 test_mkdir -p $DIR/$tdir
2837 cp -p /etc/passwd $DIR/$tdir/fopen
2838 cp -p /etc/passwd $DIR/$tdir/flink
2839 cp -p /etc/passwd $DIR/$tdir/funlink
2840 cp -p /etc/passwd $DIR/$tdir/frename
2841 ln $DIR/$tdir/funlink $DIR/$tdir/funlink2
2844 echo "aaaaaa" >> $DIR/$tdir/fopen
2845 echo "aaaaaa" >> $DIR/$tdir/flink
2846 echo "aaaaaa" >> $DIR/$tdir/funlink
2847 echo "aaaaaa" >> $DIR/$tdir/frename
2849 local open_new=`stat -c %Y $DIR/$tdir/fopen`
2850 local link_new=`stat -c %Y $DIR/$tdir/flink`
2851 local unlink_new=`stat -c %Y $DIR/$tdir/funlink`
2852 local rename_new=`stat -c %Y $DIR/$tdir/frename`
2854 cat $DIR/$tdir/fopen > /dev/null
2855 ln $DIR/$tdir/flink $DIR/$tdir/flink2
2856 rm -f $DIR/$tdir/funlink2
2857 mv -f $DIR/$tdir/frename $DIR/$tdir/frename2
2859 for (( i=0; i < 2; i++ )) ; do
2860 local open_new2=`stat -c %Y $DIR/$tdir/fopen`
2861 local link_new2=`stat -c %Y $DIR/$tdir/flink`
2862 local unlink_new2=`stat -c %Y $DIR/$tdir/funlink`
2863 local rename_new2=`stat -c %Y $DIR/$tdir/frename2`
2865 [ $open_new2 -eq $open_new ] || error "open file reverses mtime"
2866 [ $link_new2 -eq $link_new ] || error "link file reverses mtime"
2867 [ $unlink_new2 -eq $unlink_new ] || error "unlink file reverses mtime"
2868 [ $rename_new2 -eq $rename_new ] || error "rename file reverses mtime"
2870 cancel_lru_locks osc
2871 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2874 run_test 39b "mtime change on open, link, unlink, rename ======"
2876 # this should be set to past
2877 TEST_39_MTIME=`date -d "1 year ago" +%s`
2883 local mtime0=`stat -c %Y $DIR1/$tfile`
2885 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
2886 local mtime1=`stat -c %Y $DIR1/$tfile`
2887 [ "$mtime1" = $TEST_39_MTIME ] || \
2888 error "mtime is not set to past: $mtime1, should be $TEST_39_MTIME"
2891 echo hello >> $DIR1/$tfile
2893 local mtime2=`stat -c %Y $DIR1/$tfile`
2894 [ "$mtime2" -ge "$d1" ] && [ "$mtime2" -le "$d2" ] || \
2895 error "mtime is not updated on write: $d1 <= $mtime2 <= $d2"
2897 mv $DIR1/$tfile $DIR1/$tfile-1
2899 for (( i=0; i < 2; i++ )) ; do
2900 local mtime3=`stat -c %Y $DIR1/$tfile-1`
2901 [ "$mtime2" = "$mtime3" ] || \
2902 error "mtime ($mtime2) changed (to $mtime3) on rename"
2904 cancel_lru_locks osc
2905 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2908 run_test 39c "mtime change on rename ==========================="
2912 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2915 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
2917 for (( i=0; i < 2; i++ )) ; do
2918 local mtime=`stat -c %Y $DIR1/$tfile`
2919 [ $mtime = $TEST_39_MTIME ] || \
2920 error "mtime($mtime) is not set to $TEST_39_MTIME"
2922 cancel_lru_locks osc
2923 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2926 run_test 39d "create, utime, stat =============================="
2930 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2932 local mtime1=`stat -c %Y $DIR1/$tfile`
2934 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
2936 for (( i=0; i < 2; i++ )) ; do
2937 local mtime2=`stat -c %Y $DIR1/$tfile`
2938 [ $mtime2 = $TEST_39_MTIME ] || \
2939 error "mtime($mtime2) is not set to $TEST_39_MTIME"
2941 cancel_lru_locks osc
2942 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2945 run_test 39e "create, stat, utime, stat ========================"
2949 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2951 mtime1=`stat -c %Y $DIR1/$tfile`
2954 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
2956 for (( i=0; i < 2; i++ )) ; do
2957 local mtime2=`stat -c %Y $DIR1/$tfile`
2958 [ $mtime2 = $TEST_39_MTIME ] || \
2959 error "mtime($mtime2) is not set to $TEST_39_MTIME"
2961 cancel_lru_locks osc
2962 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2965 run_test 39f "create, stat, sleep, utime, stat ================="
2969 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2970 echo hello >> $DIR1/$tfile
2971 local mtime1=`stat -c %Y $DIR1/$tfile`
2974 chmod o+r $DIR1/$tfile
2976 for (( i=0; i < 2; i++ )) ; do
2977 local mtime2=`stat -c %Y $DIR1/$tfile`
2978 [ "$mtime1" = "$mtime2" ] || \
2979 error "lost mtime: $mtime2, should be $mtime1"
2981 cancel_lru_locks osc
2982 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2985 run_test 39g "write, chmod, stat ==============================="
2989 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2994 echo hello >> $DIR1/$tfile
2995 local mtime1=`stat -c %Y $DIR1/$tfile`
2997 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
2999 if [ "$d1" != "$d2" ]; then
3000 echo "write and touch not within one second"
3002 for (( i=0; i < 2; i++ )) ; do
3003 local mtime2=`stat -c %Y $DIR1/$tfile`
3004 [ "$mtime2" = $TEST_39_MTIME ] || \
3005 error "lost mtime: $mtime2, should be $TEST_39_MTIME"
3007 cancel_lru_locks osc
3008 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3012 run_test 39h "write, utime within one second, stat ============="
3015 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3019 echo hello >> $DIR1/$tfile
3020 local mtime1=`stat -c %Y $DIR1/$tfile`
3022 mv $DIR1/$tfile $DIR1/$tfile-1
3024 for (( i=0; i < 2; i++ )) ; do
3025 local mtime2=`stat -c %Y $DIR1/$tfile-1`
3027 [ "$mtime1" = "$mtime2" ] || \
3028 error "lost mtime: $mtime2, should be $mtime1"
3030 cancel_lru_locks osc
3031 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3034 run_test 39i "write, rename, stat =============================="
3037 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3038 start_full_debug_logging
3042 #define OBD_FAIL_OSC_DELAY_SETTIME 0x412
3043 lctl set_param fail_loc=0x80000412
3044 multiop_bg_pause $DIR1/$tfile oO_RDWR:w2097152_c ||
3045 error "multiop failed"
3047 local mtime1=`stat -c %Y $DIR1/$tfile`
3049 mv $DIR1/$tfile $DIR1/$tfile-1
3051 kill -USR1 $multipid
3052 wait $multipid || error "multiop close failed"
3054 for (( i=0; i < 2; i++ )) ; do
3055 local mtime2=`stat -c %Y $DIR1/$tfile-1`
3056 [ "$mtime1" = "$mtime2" ] ||
3057 error "mtime is lost on close: $mtime2, " \
3060 cancel_lru_locks osc
3061 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3063 lctl set_param fail_loc=0
3064 stop_full_debug_logging
3066 run_test 39j "write, rename, close, stat ======================="
3069 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3073 multiop_bg_pause $DIR1/$tfile oO_RDWR:w2097152_c || error "multiop failed"
3075 local mtime1=`stat -c %Y $DIR1/$tfile`
3077 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3079 kill -USR1 $multipid
3080 wait $multipid || error "multiop close failed"
3082 for (( i=0; i < 2; i++ )) ; do
3083 local mtime2=`stat -c %Y $DIR1/$tfile`
3085 [ "$mtime2" = $TEST_39_MTIME ] || \
3086 error "mtime is lost on close: $mtime2, should be $TEST_39_MTIME"
3088 cancel_lru_locks osc
3089 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3092 run_test 39k "write, utime, close, stat ========================"
3094 # this should be set to future
3095 TEST_39_ATIME=`date -d "1 year" +%s`
3098 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3099 remote_mds_nodsh && skip "remote MDS with nodsh" && return
3100 local atime_diff=$(do_facet $SINGLEMDS \
3101 lctl get_param -n mdd.*MDT0000*.atime_diff)
3105 # test setting directory atime to future
3106 touch -a -d @$TEST_39_ATIME $DIR/$tdir
3107 local atime=$(stat -c %X $DIR/$tdir)
3108 [ "$atime" = $TEST_39_ATIME ] || \
3109 error "atime is not set to future: $atime, $TEST_39_ATIME"
3111 # test setting directory atime from future to now
3112 local d1=$(date +%s)
3114 local d2=$(date +%s)
3116 cancel_lru_locks mdc
3117 atime=$(stat -c %X $DIR/$tdir)
3118 [ "$atime" -ge "$d1" -a "$atime" -le "$d2" ] || \
3119 error "atime is not updated from future: $atime, $d1<atime<$d2"
3121 do_facet $SINGLEMDS lctl set_param -n mdd.*MDT0000*.atime_diff=2
3124 # test setting directory atime when now > dir atime + atime_diff
3128 cancel_lru_locks mdc
3129 atime=$(stat -c %X $DIR/$tdir)
3130 [ "$atime" -ge "$d1" -a "$atime" -le "$d2" ] || \
3131 error "atime is not updated : $atime, should be $d2"
3133 do_facet $SINGLEMDS lctl set_param -n mdd.*MDT0000*.atime_diff=60
3136 # test not setting directory atime when now < dir atime + atime_diff
3138 cancel_lru_locks mdc
3139 atime=$(stat -c %X $DIR/$tdir)
3140 [ "$atime" -ge "$d1" -a "$atime" -le "$d2" ] || \
3141 error "atime is updated to $atime, should remain $d1<atime<$d2"
3143 do_facet $SINGLEMDS \
3144 lctl set_param -n mdd.*MDT0000*.atime_diff=$atime_diff
3146 run_test 39l "directory atime update ==========================="
3149 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3152 local far_past_mtime=$(date -d "May 29 1953" +%s)
3153 local far_past_atime=$(date -d "Dec 17 1903" +%s)
3155 touch -m -d @$far_past_mtime $DIR1/$tfile
3156 touch -a -d @$far_past_atime $DIR1/$tfile
3158 for (( i=0; i < 2; i++ )) ; do
3159 local timestamps=$(stat -c "%X %Y" $DIR1/$tfile)
3160 [ "$timestamps" = "$far_past_atime $far_past_mtime" ] || \
3161 error "atime or mtime set incorrectly"
3163 cancel_lru_locks osc
3164 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3167 run_test 39m "test atime and mtime before 1970"
3169 test_39n() { # LU-3832
3170 local atime_diff=$(do_facet $SINGLEMDS \
3171 lctl get_param -n mdd.*MDT0000*.atime_diff)
3176 do_facet $SINGLEMDS lctl set_param -n mdd.*MDT0000*.atime_diff=1
3179 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 status=noxfer
3180 atime0=$(stat -c %X $DIR/$tfile)
3183 $MULTIOP $DIR/$tfile oO_RDONLY:O_NOATIME:r4096c
3184 atime1=$(stat -c %X $DIR/$tfile)
3187 cancel_lru_locks mdc
3188 cancel_lru_locks osc
3189 $MULTIOP $DIR/$tfile oO_RDONLY:O_NOATIME:r4096c
3190 atime2=$(stat -c %X $DIR/$tfile)
3192 do_facet $SINGLEMDS \
3193 lctl set_param -n mdd.*MDT0000*.atime_diff=$atime_diff
3195 [ "$atime0" -eq "$atime1" ] || error "atime0 $atime0 != atime1 $atime1"
3196 [ "$atime1" -eq "$atime2" ] || error "atime0 $atime0 != atime1 $atime1"
3198 run_test 39n "check that O_NOATIME is honored"
3201 TESTDIR=$DIR/$tdir/$tfile
3202 [ -e $TESTDIR ] && rm -rf $TESTDIR
3203 test_mkdir -p $TESTDIR
3209 links2=$(stat -c %h .)
3210 [ $(($links1 + 2)) != $links2 ] &&
3211 error "wrong links count $(($links1 + 2)) != $links2"
3213 links3=$(stat -c %h .)
3214 [ $(($links1 + 1)) != $links3 ] &&
3215 error "wrong links count $links1 != $links3"
3218 run_test 39o "directory cached attributes updated after create ========"
3221 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
3223 TESTDIR=$DIR/$tdir/$tfile
3224 [ -e $TESTDIR ] && rm -rf $TESTDIR
3229 $LFS mkdir -i $MDTIDX $TESTDIR/remote_dir1
3230 $LFS mkdir -i $MDTIDX $TESTDIR/remote_dir2
3232 links2=$(stat -c %h .)
3233 [ $(($links1 + 2)) != $links2 ] &&
3234 error "wrong links count $(($links1 + 2)) != $links2"
3236 links3=$(stat -c %h .)
3237 [ $(($links1 + 1)) != $links3 ] &&
3238 error "wrong links count $links1 != $links3"
3241 run_test 39p "remote directory cached attributes updated after create ========"
3245 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1
3246 $RUNAS $OPENFILE -f O_WRONLY:O_TRUNC $DIR/$tfile &&
3247 error "openfile O_WRONLY:O_TRUNC $tfile failed"
3248 $CHECKSTAT -t file -s 4096 $DIR/$tfile ||
3249 error "$tfile is not 4096 bytes in size"
3251 run_test 40 "failed open(O_TRUNC) doesn't truncate ============="
3255 small_write $DIR/f41 18
3257 run_test 41 "test small file write + fstat ====================="
3259 count_ost_writes() {
3260 lctl get_param -n osc.*.stats |
3261 awk -vwrites=0 '/ost_write/ { writes += $2 } END { print writes; }'
3268 BG_DIRTY_RATIO_SAVE=10
3269 MAX_BG_DIRTY_RATIO=25
3273 # in 2.6, restore /proc/sys/vm/dirty_writeback_centisecs,
3274 # dirty_ratio, dirty_background_ratio
3275 if [ -f /proc/sys/vm/dirty_writeback_centisecs ]; then
3276 sysctl -w vm.dirty_writeback_centisecs=$WRITEBACK_SAVE
3277 sysctl -w vm.dirty_background_ratio=$BG_DIRTY_RATIO_SAVE
3278 sysctl -w vm.dirty_ratio=$DIRTY_RATIO_SAVE
3280 # if file not here, we are a 2.4 kernel
3281 kill -CONT `pidof kupdated`
3286 # setup the trap first, so someone cannot exit the test at the
3287 # exact wrong time and mess up a machine
3288 trap start_writeback EXIT
3289 # in 2.6, save and 0 /proc/sys/vm/dirty_writeback_centisecs
3290 if [ -f /proc/sys/vm/dirty_writeback_centisecs ]; then
3291 WRITEBACK_SAVE=`sysctl -n vm.dirty_writeback_centisecs`
3292 sysctl -w vm.dirty_writeback_centisecs=0
3293 sysctl -w vm.dirty_writeback_centisecs=0
3294 # save and increase /proc/sys/vm/dirty_ratio
3295 DIRTY_RATIO_SAVE=`sysctl -n vm.dirty_ratio`
3296 sysctl -w vm.dirty_ratio=$MAX_DIRTY_RATIO
3297 # save and increase /proc/sys/vm/dirty_background_ratio
3298 BG_DIRTY_RATIO_SAVE=`sysctl -n vm.dirty_background_ratio`
3299 sysctl -w vm.dirty_background_ratio=$MAX_BG_DIRTY_RATIO
3301 # if file not here, we are a 2.4 kernel
3302 kill -STOP `pidof kupdated`
3306 # ensure that all stripes have some grant before we test client-side cache
3308 for i in `seq -f $DIR/f42-%g 1 $OSTCOUNT`; do
3309 dd if=/dev/zero of=$i bs=4k count=1
3314 # Tests 42* verify that our behaviour is correct WRT caching, file closure,
3315 # file truncation, and file removal.
3317 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3319 cancel_lru_locks osc
3321 sync; sleep 1; sync # just to be safe
3322 BEFOREWRITES=`count_ost_writes`
3323 lctl get_param -n osc.*[oO][sS][cC][_-]*.cur_grant_bytes | grep "[0-9]"
3324 dd if=/dev/zero of=$DIR/f42a bs=1024 count=100
3325 AFTERWRITES=`count_ost_writes`
3326 [ $BEFOREWRITES -eq $AFTERWRITES ] || \
3327 error "$BEFOREWRITES < $AFTERWRITES"
3330 run_test 42a "ensure that we don't flush on close =============="
3333 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3335 cancel_lru_locks osc
3338 dd if=/dev/zero of=$DIR/f42b bs=1024 count=100
3339 BEFOREWRITES=`count_ost_writes`
3340 $MUNLINK $DIR/f42b || error "$MUNLINK $DIR/f42b: $?"
3341 AFTERWRITES=`count_ost_writes`
3342 if [ $BEFOREWRITES -lt $AFTERWRITES ]; then
3343 error "$BEFOREWRITES < $AFTERWRITES on unlink"
3345 BEFOREWRITES=`count_ost_writes`
3346 sync || error "sync: $?"
3347 AFTERWRITES=`count_ost_writes`
3348 if [ $BEFOREWRITES -lt $AFTERWRITES ]; then
3349 error "$BEFOREWRITES < $AFTERWRITES on sync"
3351 dmesg | grep 'error from obd_brw_async' && error 'error writing back'
3355 run_test 42b "test destroy of file with cached dirty data ======"
3357 # if these tests just want to test the effect of truncation,
3358 # they have to be very careful. consider:
3359 # - the first open gets a {0,EOF}PR lock
3360 # - the first write conflicts and gets a {0, count-1}PW
3361 # - the rest of the writes are under {count,EOF}PW
3362 # - the open for truncate tries to match a {0,EOF}PR
3363 # for the filesize and cancels the PWs.
3364 # any number of fixes (don't get {0,EOF} on open, match
3365 # composite locks, do smarter file size management) fix
3366 # this, but for now we want these tests to verify that
3367 # the cancellation with truncate intent works, so we
3368 # start the file with a full-file pw lock to match against
3369 # until the truncate.
3374 cancel_lru_locks osc
3376 # prime the file with 0,EOF PW to match
3380 # now the real test..
3381 dd if=/dev/zero of=$file bs=1024 count=100
3382 BEFOREWRITES=`count_ost_writes`
3383 $TRUNCATE $file $offset
3384 cancel_lru_locks osc
3385 AFTERWRITES=`count_ost_writes`
3390 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3392 [ $BEFOREWRITES -eq $AFTERWRITES ] && \
3393 error "beforewrites $BEFOREWRITES == afterwrites $AFTERWRITES on truncate"
3396 run_test 42c "test partial truncate of file with cached dirty data"
3399 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3401 [ $BEFOREWRITES -eq $AFTERWRITES ] || \
3402 error "beforewrites $BEFOREWRITES != afterwrites $AFTERWRITES on truncate"
3405 run_test 42d "test complete truncate of file with cached dirty data"
3407 test_42e() { # bug22074
3408 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3409 local TDIR=$DIR/${tdir}e
3410 local pagesz=$(page_size)
3411 local pages=16 # hardcoded 16 pages, don't change it.
3412 local files=$((OSTCOUNT * 500)) # hopefully 500 files on each OST
3413 local proc_osc0="osc.${FSNAME}-OST0000-osc-[^MDT]*"
3417 test_mkdir -p $DIR/${tdir}e
3418 $SETSTRIPE -c 1 $TDIR
3419 createmany -o $TDIR/f $files
3421 max_dirty_mb=$($LCTL get_param -n $proc_osc0/max_dirty_mb)
3423 # we assume that with $OSTCOUNT files, at least one of them will
3424 # be allocated on OST0.
3425 warmup_files=$((OSTCOUNT * max_dirty_mb))
3426 createmany -o $TDIR/w $warmup_files
3428 # write a large amount of data into one file and sync, to get good
3429 # avail_grant number from OST.
3430 for ((i=0; i<$warmup_files; i++)); do
3431 idx=$($GETSTRIPE -i $TDIR/w$i)
3432 [ $idx -ne 0 ] && continue
3433 dd if=/dev/zero of=$TDIR/w$i bs="$max_dirty_mb"M count=1
3436 [ $i -gt $warmup_files ] && error "OST0 is still cold"
3438 $LCTL get_param $proc_osc0/cur_dirty_bytes
3439 $LCTL get_param $proc_osc0/cur_grant_bytes
3441 # create as much dirty pages as we can while not to trigger the actual
3442 # RPCs directly. but depends on the env, VFS may trigger flush during this
3443 # period, hopefully we are good.
3444 for ((i=0; i<$warmup_files; i++)); do
3445 idx=$($GETSTRIPE -i $TDIR/w$i)
3446 [ $idx -ne 0 ] && continue
3447 dd if=/dev/zero of=$TDIR/w$i bs=1M count=1 2>/dev/null
3449 $LCTL get_param $proc_osc0/cur_dirty_bytes
3450 $LCTL get_param $proc_osc0/cur_grant_bytes
3452 # perform the real test
3453 $LCTL set_param $proc_osc0/rpc_stats 0
3454 for ((;i<$files; i++)); do
3455 [ $($GETSTRIPE -i $TDIR/f$i) -eq 0 ] || continue
3456 dd if=/dev/zero of=$TDIR/f$i bs=$pagesz count=$pages 2>/dev/null
3459 $LCTL get_param $proc_osc0/rpc_stats
3462 local have_ppr=false
3463 $LCTL get_param $proc_osc0/rpc_stats |
3464 while read PPR RRPC RPCT RCUM BAR WRPC WPCT WCUM; do
3465 # skip lines until we are at the RPC histogram data
3466 [ "$PPR" == "pages" ] && have_ppr=true && continue
3467 $have_ppr || continue
3469 # we only want the percent stat for < 16 pages
3470 [ $(echo $PPR | tr -d ':') -ge $pages ] && break
3472 percent=$((percent + WPCT))
3473 if [ $percent -gt 15 ]; then
3474 error "less than 16-pages write RPCs" \
3481 run_test 42e "verify sub-RPC writes are not done synchronously"
3484 test_mkdir -p $DIR/$tdir
3485 cp -p /bin/ls $DIR/$tdir/$tfile
3486 $MULTIOP $DIR/$tdir/$tfile Ow_c &
3488 # give multiop a chance to open
3491 $DIR/$tdir/$tfile && error || true
3494 run_test 43 "execution of file opened for write should return -ETXTBSY"
3497 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3498 test_mkdir -p $DIR/$tdir
3499 cp -p `which $MULTIOP` $DIR/$tdir/multiop ||
3500 cp -p multiop $DIR/$tdir/multiop
3501 MULTIOP_PROG=$DIR/$tdir/multiop multiop_bg_pause $TMP/$tfile.junk O_c ||
3504 $MULTIOP $DIR/$tdir/multiop Oc && error "expected error, got success"
3505 kill -USR1 $MULTIOP_PID || return 2
3506 wait $MULTIOP_PID || return 3
3507 rm $TMP/$tfile.junk $DIR/$tdir/multiop
3509 run_test 43a "open(RDWR) of file being executed should return -ETXTBSY"
3512 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3513 test_mkdir -p $DIR/$tdir
3514 cp -p `which $MULTIOP` $DIR/$tdir/multiop ||
3515 cp -p multiop $DIR/$tdir/multiop
3516 MULTIOP_PROG=$DIR/$tdir/multiop multiop_bg_pause $TMP/$tfile.junk O_c ||
3519 $TRUNCATE $DIR/$tdir/multiop 0 && error "expected error, got success"
3520 kill -USR1 $MULTIOP_PID || return 2
3521 wait $MULTIOP_PID || return 3
3522 rm $TMP/$tfile.junk $DIR/$tdir/multiop
3524 run_test 43b "truncate of file being executed should return -ETXTBSY"
3527 local testdir="$DIR/$tdir"
3528 test_mkdir -p $DIR/$tdir
3530 ( cd $(dirname $SHELL) && md5sum $(basename $SHELL) ) | \
3531 ( cd $testdir && md5sum -c)
3533 run_test 43c "md5sum of copy into lustre========================"
3536 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping 2-stripe test" && return
3537 dd if=/dev/zero of=$DIR/f1 bs=4k count=1 seek=1023
3538 dd if=$DIR/f1 bs=4k count=1 > /dev/null
3540 run_test 44 "zero length read from a sparse stripe ============="
3543 local nstripe=`$LCTL lov_getconfig $DIR | grep default_stripe_count: | \
3545 [ -z "$nstripe" ] && skip "can't get stripe info" && return
3546 [ "$nstripe" -gt "$OSTCOUNT" ] && skip "Wrong default_stripe_count: $nstripe (OSTCOUNT: $OSTCOUNT)" && return
3547 local stride=`$LCTL lov_getconfig $DIR | grep default_stripe_size: | \
3549 if [ $nstripe -eq 0 -o $nstripe -eq -1 ] ; then
3550 nstripe=`$LCTL lov_getconfig $DIR | grep obd_count: | awk '{print $2}'`
3553 OFFSETS="0 $((stride/2)) $((stride-1))"
3554 for offset in $OFFSETS ; do
3555 for i in `seq 0 $((nstripe-1))`; do
3556 local GLOBALOFFSETS=""
3557 local size=$((((i + 2 * $nstripe )*$stride + $offset))) # Bytes
3558 local myfn=$DIR/d44a-$size
3559 echo "--------writing $myfn at $size"
3560 ll_sparseness_write $myfn $size || error "ll_sparseness_write"
3561 GLOBALOFFSETS="$GLOBALOFFSETS $size"
3562 ll_sparseness_verify $myfn $GLOBALOFFSETS \
3563 || error "ll_sparseness_verify $GLOBALOFFSETS"
3565 for j in `seq 0 $((nstripe-1))`; do
3566 size=$((((j + $nstripe )*$stride + $offset))) # Bytes
3567 ll_sparseness_write $myfn $size || error "ll_sparseness_write"
3568 GLOBALOFFSETS="$GLOBALOFFSETS $size"
3570 ll_sparseness_verify $myfn $GLOBALOFFSETS \
3571 || error "ll_sparseness_verify $GLOBALOFFSETS"
3576 run_test 44a "test sparse pwrite ==============================="
3580 for d in `lctl get_param -n osc.*.cur_dirty_bytes`; do
3586 before=`dirty_osc_total`
3587 echo executing "\"$*\""
3589 after=`dirty_osc_total`
3590 echo before $before, after $after
3593 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3595 # Obtain grants from OST if it supports it
3596 echo blah > ${f}_grant
3599 do_dirty_record "echo blah > $f"
3600 [ $before -eq $after ] && error "write wasn't cached"
3601 do_dirty_record "> $f"
3602 [ $before -gt $after ] || error "truncate didn't lower dirty count"
3603 do_dirty_record "echo blah > $f"
3604 [ $before -eq $after ] && error "write wasn't cached"
3605 do_dirty_record "sync"
3606 [ $before -gt $after ] || error "writeback didn't lower dirty count"
3607 do_dirty_record "echo blah > $f"
3608 [ $before -eq $after ] && error "write wasn't cached"
3609 do_dirty_record "cancel_lru_locks osc"
3610 [ $before -gt $after ] || error "lock cancellation didn't lower dirty count"
3613 run_test 45 "osc io page accounting ============================"
3615 # in a 2 stripe file (lov.sh), page 1023 maps to page 511 in its object. this
3616 # test tickles a bug where re-dirtying a page was failing to be mapped to the
3617 # objects offset and an assert hit when an rpc was built with 1023's mapped
3618 # offset 511 and 511's raw 511 offset. it also found general redirtying bugs.
3620 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3624 dd if=/dev/zero of=$f bs=`page_size` seek=511 count=1
3626 dd conv=notrunc if=/dev/zero of=$f bs=`page_size` seek=1023 count=1
3627 dd conv=notrunc if=/dev/zero of=$f bs=`page_size` seek=511 count=1
3631 run_test 46 "dirtying a previously written page ================"
3633 # test_47 is removed "Device nodes check" is moved to test_28
3635 test_48a() { # bug 2399
3636 check_kernel_version 34 || return 0
3637 test_mkdir -p $DIR/$tdir
3639 mv $DIR/$tdir $DIR/d48.new || error "move directory failed"
3640 test_mkdir $DIR/$tdir || error "recreate directory failed"
3641 touch foo || error "'touch foo' failed after recreating cwd"
3642 test_mkdir $DIR/$tdir/bar ||
3643 error "'mkdir foo' failed after recreating cwd"
3644 if check_kernel_version 44; then
3645 touch .foo || error "'touch .foo' failed after recreating cwd"
3646 test_mkdir $DIR/$tdir/.bar ||
3647 error "'mkdir .foo' failed after recreating cwd"
3649 ls . > /dev/null || error "'ls .' failed after recreating cwd"
3650 ls .. > /dev/null || error "'ls ..' failed after removing cwd"
3651 cd . || error "'cd .' failed after recreating cwd"
3652 test_mkdir . && error "'mkdir .' worked after recreating cwd"
3653 rmdir . && error "'rmdir .' worked after recreating cwd"
3654 ln -s . baz || error "'ln -s .' failed after recreating cwd"
3655 cd .. || error "'cd ..' failed after recreating cwd"
3657 run_test 48a "Access renamed working dir (should return errors)="
3659 test_48b() { # bug 2399
3660 check_kernel_version 34 || return 0
3662 test_mkdir -p $DIR/$tdir
3664 rmdir $DIR/$tdir || error "remove cwd $DIR/$tdir failed"
3665 touch foo && error "'touch foo' worked after removing cwd"
3666 test_mkdir $DIR/$tdir/foo &&
3667 error "'mkdir foo' worked after removing cwd"
3668 if check_kernel_version 44; then
3669 touch .foo && error "'touch .foo' worked after removing cwd"
3670 test_mkdir $DIR/$tdir/.foo &&
3671 error "'mkdir .foo' worked after removing cwd"
3673 ls . > /dev/null && error "'ls .' worked after removing cwd"
3674 ls .. > /dev/null || error "'ls ..' failed after removing cwd"
3675 is_patchless || ( cd . && error "'cd .' worked after removing cwd" )
3676 test_mkdir $DIR/$tdir/. && error "'mkdir .' worked after removing cwd"
3677 rmdir . && error "'rmdir .' worked after removing cwd"
3678 ln -s . foo && error "'ln -s .' worked after removing cwd"
3679 cd .. || echo "'cd ..' failed after removing cwd `pwd`" #bug 3517
3681 run_test 48b "Access removed working dir (should return errors)="
3683 test_48c() { # bug 2350
3684 check_kernel_version 36 || return 0
3685 #lctl set_param debug=-1
3688 test_mkdir -p $DIR/$tdir/dir
3690 $TRACE rmdir $DIR/$tdir/dir || error "remove cwd $DIR/$tdir/dir failed"
3691 $TRACE touch foo && error "touch foo worked after removing cwd"
3692 $TRACE test_mkdir foo && error "'mkdir foo' worked after removing cwd"
3693 if check_kernel_version 44; then
3694 touch .foo && error "touch .foo worked after removing cwd"
3695 test_mkdir .foo && error "mkdir .foo worked after removing cwd"
3697 $TRACE ls . && error "'ls .' worked after removing cwd"
3698 $TRACE ls .. || error "'ls ..' failed after removing cwd"
3699 is_patchless || ( $TRACE cd . &&
3700 error "'cd .' worked after removing cwd" )
3701 $TRACE test_mkdir . && error "'mkdir .' worked after removing cwd"
3702 $TRACE rmdir . && error "'rmdir .' worked after removing cwd"
3703 $TRACE ln -s . foo && error "'ln -s .' worked after removing cwd"
3704 $TRACE cd .. || echo "'cd ..' failed after removing cwd `pwd`" #bug 3415
3706 run_test 48c "Access removed working subdir (should return errors)"
3708 test_48d() { # bug 2350
3709 check_kernel_version 36 || return 0
3710 #lctl set_param debug=-1
3713 test_mkdir -p $DIR/$tdir/dir
3715 $TRACE rmdir $DIR/$tdir/dir || error "remove cwd $DIR/$tdir/dir failed"
3716 $TRACE rmdir $DIR/$tdir || error "remove parent $DIR/$tdir failed"
3717 $TRACE touch foo && error "'touch foo' worked after removing parent"
3718 $TRACE test_mkdir foo && error "mkdir foo worked after removing parent"
3719 if check_kernel_version 44; then
3720 touch .foo && error "'touch .foo' worked after removing parent"
3722 error "mkdir .foo worked after removing parent"
3724 $TRACE ls . && error "'ls .' worked after removing parent"
3725 $TRACE ls .. && error "'ls ..' worked after removing parent"
3726 is_patchless || ( $TRACE cd . &&
3727 error "'cd .' worked after recreate parent" )
3728 $TRACE test_mkdir . && error "'mkdir .' worked after removing parent"
3729 $TRACE rmdir . && error "'rmdir .' worked after removing parent"
3730 $TRACE ln -s . foo && error "'ln -s .' worked after removing parent"
3731 is_patchless || ( $TRACE cd .. &&
3732 error "'cd ..' worked after removing parent" || true )
3734 run_test 48d "Access removed parent subdir (should return errors)"
3736 test_48e() { # bug 4134
3737 check_kernel_version 41 || return 0
3738 #lctl set_param debug=-1
3741 test_mkdir -p $DIR/$tdir/dir
3743 $TRACE rmdir $DIR/$tdir/dir || error "remove cwd $DIR/$tdir/dir failed"
3744 $TRACE rmdir $DIR/$tdir || error "remove parent $DIR/$tdir failed"
3745 $TRACE touch $DIR/$tdir || error "'touch $DIR/$tdir' failed"
3746 $TRACE chmod +x $DIR/$tdir || error "'chmod +x $DIR/$tdir' failed"
3747 # On a buggy kernel addition of "touch foo" after cd .. will
3748 # produce kernel oops in lookup_hash_it
3749 touch ../foo && error "'cd ..' worked after recreate parent"
3751 $TRACE rm $DIR/$tdir || error "rm '$DIR/$tdir' failed"
3753 run_test 48e "Access to recreated parent subdir (should return errors)"
3755 test_49() { # LU-1030
3756 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3757 # get ost1 size - lustre-OST0000
3758 ost1_size=$(do_facet ost1 lfs df |grep ${ost1_svc} |awk '{print $4}')
3759 # write 800M at maximum
3760 [ $ost1_size -gt 819200 ] && ost1_size=819200
3762 lfs setstripe -c 1 -i 0 $DIR/$tfile
3763 dd if=/dev/zero of=$DIR/$tfile bs=4k count=$((ost1_size >> 2)) &
3766 # change max_pages_per_rpc while writing the file
3767 local osc1_mppc=osc.$(get_osc_import_name client ost1).max_pages_per_rpc
3768 local orig_mppc=`$LCTL get_param -n $osc1_mppc`
3769 # loop until dd process exits
3770 while ps ax -opid | grep -wq $dd_pid; do
3771 $LCTL set_param $osc1_mppc=$((RANDOM % 256 + 1))
3772 sleep $((RANDOM % 5 + 1))
3774 # restore original max_pages_per_rpc
3775 $LCTL set_param $osc1_mppc=$orig_mppc
3776 rm $DIR/$tfile || error "rm $DIR/$tfile failed"
3778 run_test 49 "Change max_pages_per_rpc won't break osc extent"
3782 test_mkdir $DIR/$tdir
3784 ls /proc/$$/cwd || error "ls /proc/$$/cwd failed"
3786 run_test 50 "special situations: /proc symlinks ==============="
3788 test_51a() { # was test_51
3789 # bug 1516 - create an empty entry right after ".." then split dir
3790 test_mkdir -p $DIR/$tdir
3791 touch $DIR/$tdir/foo
3792 $MCREATE $DIR/$tdir/bar
3794 createmany -m $DIR/$tdir/longfile 201
3796 while [ $(ls -sd $DIR/$tdir | awk '{ print $1 }') -eq 4 ]; do
3797 $MCREATE $DIR/$tdir/longfile$FNUM
3802 ls -l $DIR/$tdir > /dev/null || error "ls -l $DIR/$tdir failed"
3804 run_test 51a "special situations: split htree with empty entry =="
3806 export NUMTEST=70000
3808 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3809 local BASE=$DIR/d${base}.${TESTSUITE}
3811 # cleanup the directory
3816 local mdtidx=$(printf "%04x" $($LFS getstripe -M $BASE))
3817 local numfree=$(lctl get_param -n mdc.$FSNAME-MDT$mdtidx*.filesfree)
3818 [ $numfree -lt 21000 ] && skip "not enough free inodes ($numfree)" &&
3821 [ $numfree -lt $NUMTEST ] && NUMTEST=$(($numfree - 50)) &&
3822 echo "reduced count to $NUMTEST due to inodes"
3824 # need to check free space for the directories as well
3825 local blkfree=$(lctl get_param -n mdc.$FSNAME-MDT$mdtidx*.kbytesavail)
3826 numfree=$((blkfree / 4))
3827 [ $numfree -lt $NUMTEST ] && NUMTEST=$(($numfree - 50)) &&
3828 echo "reduced count to $NUMTEST due to blocks"
3830 createmany -d $BASE/d $NUMTEST && echo $NUMTEST > $BASE/fnum ||
3831 echo "failed" > $BASE/fnum
3833 run_test 51b "exceed 64k subdirectory nlink limit"
3835 test_51ba() { # LU-993
3836 local BASE=$DIR/d${base}.${TESTSUITE}
3837 # unlink all but 100 subdirectories, then check it still works
3839 [ -f $BASE/fnum ] && local NUMPREV=$(cat $BASE/fnum) && rm $BASE/fnum
3841 [ "$NUMPREV" != "failed" ] && NUMTEST=$NUMPREV
3842 local DELETE=$((NUMTEST - LEFT))
3844 # continue on to run this test even if 51b didn't finish,
3845 # just to delete the many subdirectories created.
3846 [ ! -d "${BASE}/d1" ] && skip "test_51b() not run" && return 0
3848 # for ldiskfs the nlink count should be 1, but this is OSD specific
3849 # and so this is listed for informational purposes only
3850 echo "nlink before: $(stat -c %h $BASE), created before: $NUMTEST"
3851 unlinkmany -d $BASE/d $DELETE
3854 if [ $RC -ne 0 ]; then
3855 if [ "$NUMPREV" == "failed" ]; then
3856 skip "previous setup failed"
3859 error "unlink of first $DELETE subdirs failed"
3864 echo "nlink between: $(stat -c %h $BASE)"
3865 # trim the first line of ls output
3866 local FOUND=$(($(ls -l ${BASE} | wc -l) - 1))
3867 [ $FOUND -ne $LEFT ] &&
3868 error "can't find subdirs: found only $FOUND/$LEFT"
3870 unlinkmany -d $BASE/d $DELETE $LEFT ||
3871 error "unlink of second $LEFT subdirs failed"
3872 # regardless of whether the backing filesystem tracks nlink accurately
3873 # or not, the nlink count shouldn't be more than "." and ".." here
3874 local AFTER=$(stat -c %h $BASE)
3875 [ $AFTER -gt 2 ] && error "nlink after: $AFTER > 2" ||
3876 echo "nlink after: $AFTER"
3878 run_test 51ba "verify nlink for many subdirectory cleanup"
3881 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3882 [ "$OSTCOUNT" -lt "3" ] && skip_env "skipping test with few OSTs" && return
3883 test_mkdir -p $DIR/$tdir
3884 createmany -o $DIR/$tdir/t- 1000
3885 $GETSTRIPE $DIR/$tdir > $TMP/files
3886 for N in `seq 0 $((OSTCOUNT - 1))`; do
3887 OBJS[$N]=`awk -vobjs=0 '($1 == '$N') { objs += 1 } END { print objs;}' $TMP/files`
3888 OBJS0[$N]=`grep -A 1 idx $TMP/files | awk -vobjs=0 '($1 == '$N') { objs += 1 } END { print objs;}'`
3889 log "OST$N has ${OBJS[$N]} objects, ${OBJS0[$N]} are index 0"
3891 unlinkmany $DIR/$tdir/t- 1000
3894 for N in `seq 1 $((OSTCOUNT - 1))`; do
3895 [ ${OBJS[$N]} -lt $((${OBJS[$NLAST]} - 20)) ] && \
3896 error "OST $N has less objects vs OST $NLAST (${OBJS[$N]} < ${OBJS[$NLAST]}"
3897 [ ${OBJS[$N]} -gt $((${OBJS[$NLAST]} + 20)) ] && \
3898 error "OST $N has less objects vs OST $NLAST (${OBJS[$N]} < ${OBJS[$NLAST]}"
3900 [ ${OBJS0[$N]} -lt $((${OBJS0[$NLAST]} - 20)) ] && \
3901 error "OST $N has less #0 objects vs OST $NLAST (${OBJS0[$N]} < ${OBJS0[$NLAST]}"
3902 [ ${OBJS0[$N]} -gt $((${OBJS0[$NLAST]} + 20)) ] && \
3903 error "OST $N has less #0 objects vs OST $NLAST (${OBJS0[$N]} < ${OBJS0[$NLAST]}"
3907 run_test 51d "check object distribution ===================="
3910 [ -f $DIR/$tdir/foo ] && chattr -a $DIR/$tdir/foo
3911 test_mkdir -p $DIR/$tdir
3912 touch $DIR/$tdir/foo
3913 chattr +a $DIR/$tdir/foo || error "chattr +a failed"
3914 echo bar >> $DIR/$tdir/foo || error "append bar failed"
3915 cp /etc/hosts $DIR/$tdir/foo && error "cp worked"
3916 rm -f $DIR/$tdir/foo 2>/dev/null && error "rm worked"
3917 link $DIR/$tdir/foo $DIR/$tdir/foo_link 2>/dev/null &&
3919 echo foo >> $DIR/$tdir/foo || error "append foo failed"
3920 mrename $DIR/$tdir/foo $DIR/$tdir/foo_ren && error "rename worked"
3921 lsattr $DIR/$tdir/foo | egrep -q "^-+a[-e]+ $DIR/$tdir/foo" ||
3923 chattr -a $DIR/$tdir/foo || error "chattr -a failed"
3924 cp -r $DIR/$tdir /tmp/
3925 rm -fr $DIR/$tdir || error "cleanup rm failed"
3927 run_test 52a "append-only flag test (should return errors) ====="
3930 [ -f $DIR/$tdir/foo ] && chattr -i $DIR/$tdir/foo
3931 test_mkdir -p $DIR/$tdir
3932 touch $DIR/$tdir/foo
3933 chattr +i $DIR/$tdir/foo || error "chattr +i failed"
3934 cat test > $DIR/$tdir/foo && error "cat test worked"
3935 cp /etc/hosts $DIR/$tdir/foo && error "cp worked"
3936 rm -f $DIR/$tdir/foo 2>/dev/null && error "rm worked"
3937 link $DIR/$tdir/foo $DIR/$tdir/foo_link 2>/dev/null &&
3939 echo foo >> $DIR/$tdir/foo && error "echo worked"
3940 mrename $DIR/$tdir/foo $DIR/$tdir/foo_ren && error "rename worked"
3941 [ -f $DIR/$tdir/foo ] || error "$tdir/foo is not a file"
3942 [ -f $DIR/$tdir/foo_ren ] && error "$tdir/foo_ren is not a file"
3943 lsattr $DIR/$tdir/foo | egrep -q "^-+i[-e]+ $DIR/$tdir/foo" ||
3945 chattr -i $DIR/$tdir/foo || error "chattr failed"
3947 rm -fr $DIR/$tdir || error "unable to remove $DIR/$tdir"
3949 run_test 52b "immutable flag test (should return errors) ======="
3952 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3953 remote_mds_nodsh && skip "remote MDS with nodsh" && return
3954 remote_ost_nodsh && skip "remote OST with nodsh" && return
3967 local support_last_seq=true
3969 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.3.60) ]] ||
3970 support_last_seq=false
3973 local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS)
3975 for value in $(do_facet $SINGLEMDS \
3976 $LCTL get_param osc.$mdtosc.prealloc_last_id) ; do
3977 param=$(echo ${value[0]} | cut -d "=" -f1)
3978 ostname=$(echo $param | cut -d "." -f2 | cut -d - -f 1-2)
3980 if $support_last_seq; then
3981 param_seq=$(echo $param |
3982 sed -e s/prealloc_last_id/prealloc_last_seq/g)
3983 mds_last_seq=$(do_facet $SINGLEMDS \
3984 $LCTL get_param -n $param_seq)
3986 mds_last=$(do_facet $SINGLEMDS $LCTL get_param -n $param)
3988 ostnum=$(index_from_ostuuid ${ostname}_UUID)
3989 node=$(facet_active_host ost$((ostnum+1)))
3990 param="obdfilter.$ostname.last_id"
3991 for ost_last in $(do_node $node $LCTL get_param -n $param) ; do
3992 echo "$ostname.last_id=$ost_last; MDS.last_id=$mds_last"
3993 ost_last_id=$ost_last
3995 if $support_last_seq; then
3996 ost_last_id=$(echo $ost_last |
3997 awk -F':' '{print $2}' |
3999 ost_last_seq=$(echo $ost_last |
4000 awk -F':' '{print $1}')
4001 [[ $ost_last_seq = $mds_last_seq ]] || continue
4004 if [[ $ost_last_id != $mds_last ]]; then
4005 error "$ost_last_id != $mds_last"
4012 $found || error "can not match last_seq/last_id for $mdtosc"
4015 run_test 53 "verify that MDS and OSTs agree on pre-creation ===="
4018 $SOCKETSERVER $DIR/socket ||
4019 error "$SOCKETSERVER $DIR/socket failed: $?"
4020 $SOCKETCLIENT $DIR/socket ||
4021 error "$SOCKETCLIENT $DIR/socket failed: $?"
4022 $MUNLINK $DIR/socket || error "$MUNLINK $DIR/socket failed: $?"
4024 run_test 54a "unix domain socket test =========================="
4030 dd if=/dev/zero of=$f bs=$(page_size) count=1
4032 run_test 54b "char device works in lustre ======================"
4035 [ -b /dev/loop/0 ] && LOOPBASE=/dev/loop/
4036 [ -b /dev/loop0 ] && LOOPBASE=/dev/loop
4037 [ -z "$LOOPBASE" ] && echo "/dev/loop/0 and /dev/loop0 gone?" && return
4039 for i in $(seq 3 7); do
4040 losetup $LOOPBASE$i > /dev/null 2>&1 && continue
4048 loopdev="$DIR/loop54c"
4051 $UMOUNT -d $tdir || rc=$?
4052 losetup -d $loopdev || true
4058 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4061 loopdev="$DIR/loop54c"
4064 [ -z "$LOOPNUM" ] && echo "couldn't find empty loop device" && return
4065 mknod $loopdev b 7 $LOOPNUM
4066 echo "make a loop file system with $tfile on $loopdev ($LOOPNUM)..."
4067 dd if=/dev/zero of=$tfile bs=$(get_page_size client) seek=1024 count=1 > /dev/null
4068 losetup $loopdev $tfile || error "can't set up $loopdev for $tfile"
4069 trap cleanup_54c EXIT
4070 mkfs.ext2 $loopdev || error "mke2fs on $loopdev"
4072 mount -t ext2 $loopdev $tdir || error "error mounting $loopdev on $tdir"
4073 dd if=/dev/zero of=$tdir/tmp bs=`page_size` count=30 || error "dd write"
4075 dd if=$tdir/tmp of=/dev/zero bs=`page_size` count=30 || error "dd read"
4078 run_test 54c "block device works in lustre ====================="
4084 [ "$string" = $(echo $string > $f | cat $f) ] || error "$f != $string"
4086 run_test 54d "fifo device works in lustre ======================"
4089 check_kernel_version 46 || return 0
4092 cp -aL /dev/console $f
4093 echo $string > $f || error "echo $string to $f failed"
4095 run_test 54e "console/tty device works in lustre ======================"
4097 #The test_55 used to be iopen test and it was removed by bz#24037.
4098 #run_test 55 "check iopen_connect_dentry() ======================"
4100 test_56a() { # was test_56
4103 test_mkdir -p $DIR/$tdir/dir
4105 NUMFILESx2=$(($NUMFILES * 2))
4106 for i in `seq 1 $NUMFILES` ; do
4107 touch $DIR/$tdir/file$i
4108 touch $DIR/$tdir/dir/file$i
4111 # test lfs getstripe with --recursive
4112 FILENUM=`$GETSTRIPE --recursive $DIR/$tdir | grep -c obdidx`
4113 [ $FILENUM -eq $NUMFILESx2 ] ||
4114 error "$GETSTRIPE --recursive: found $FILENUM, not $NUMFILESx2"
4115 FILENUM=`$GETSTRIPE $DIR/$tdir | grep -c obdidx`
4116 [ $FILENUM -eq $NUMFILES ] ||
4117 error "$GETSTRIPE $DIR/$tdir: found $FILENUM, not $NUMFILES"
4118 echo "$GETSTRIPE --recursive passed."
4120 # test lfs getstripe with file instead of dir
4121 FILENUM=`$GETSTRIPE $DIR/$tdir/file1 | grep -c obdidx`
4122 [ $FILENUM -eq 1 ] || error \
4123 "$GETSTRIPE $DIR/$tdir/file1: found $FILENUM, not 1"
4124 echo "$GETSTRIPE file1 passed."
4126 #test lfs getstripe with --verbose
4127 [ `$GETSTRIPE --verbose $DIR/$tdir |
4128 grep -c lmm_magic` -eq $NUMFILES ] ||
4129 error "$GETSTRIPE --verbose $DIR/$tdir: want $NUMFILES"
4130 [ `$GETSTRIPE $DIR/$tdir | grep -c lmm_magic` -eq 0 ] ||
4131 error "$GETSTRIPE $DIR/$tdir: showed lmm_magic"
4132 echo "$GETSTRIPE --verbose passed."
4134 #test lfs getstripe with --obd
4135 $GETSTRIPE --obd wrong_uuid $DIR/$tdir 2>&1 |
4136 grep -q "unknown obduuid" ||
4137 error "$GETSTRIPE --obd wrong_uuid should return error message"
4139 [ "$OSTCOUNT" -lt 2 ] &&
4140 skip_env "skipping other $GETSTRIPE --obd test" && return
4143 OBDUUID=$(ostuuid_from_index $OSTIDX)
4144 FILENUM=`$GETSTRIPE -ir $DIR/$tdir | grep -x $OSTIDX | wc -l`
4145 FOUND=`$GETSTRIPE -r --obd $OBDUUID $DIR/$tdir | grep obdidx | wc -l`
4146 [ $FOUND -eq $FILENUM ] ||
4147 error "$GETSTRIPE --obd wrong: found $FOUND, expected $FILENUM"
4148 [ `$GETSTRIPE -r -v --obd $OBDUUID $DIR/$tdir |
4149 sed '/^[ ]*'${OSTIDX}'[ ]/d' |
4150 sed -n '/^[ ]*[0-9][0-9]*[ ]/p' | wc -l` -eq 0 ] ||
4151 error "$GETSTRIPE --obd: should not show file on other obd"
4152 echo "$GETSTRIPE --obd passed"
4154 run_test 56a "check $GETSTRIPE"
4159 local LOCAL_NUMFILES="$1"
4160 local LOCAL_NUMDIRS="$2"
4161 local MKDIR_PARAMS="$3"
4162 local DIR_STRIPE_PARAMS="$4"
4164 if [ ! -d "$TDIR" ] ; then
4165 test_mkdir -p $DIR_STRIPE_PARAMS $TDIR
4166 [ "$MKDIR_PARAMS" ] && $SETSTRIPE $MKDIR_PARAMS $TDIR
4167 for i in `seq 1 $LOCAL_NUMFILES` ; do
4170 for i in `seq 1 $LOCAL_NUMDIRS` ; do
4171 test_mkdir $DIR_STRIPE_PARAMS $TDIR/dir$i
4172 for j in `seq 1 $LOCAL_NUMFILES` ; do
4173 touch $TDIR/dir$i/file$j
4179 setup_56_special() {
4183 if [ ! -e "$TDIR/loop1b" ] ; then
4184 for i in `seq 1 $LOCAL_NUMFILES` ; do
4185 mknod $TDIR/loop${i}b b 7 $i
4186 mknod $TDIR/null${i}c c 1 3
4187 ln -s $TDIR/file1 $TDIR/link${i}l
4189 for i in `seq 1 $LOCAL_NUMDIRS` ; do
4190 mknod $TDIR/dir$i/loop${i}b b 7 $i
4191 mknod $TDIR/dir$i/null${i}c c 1 3
4192 ln -s $TDIR/dir$i/file1 $TDIR/dir$i/link${i}l
4201 setup_56 $NUMFILES $NUMDIRS
4203 EXPECTED=$(($NUMDIRS + 2))
4204 # test lfs find with -name
4205 for i in $(seq 1 $NUMFILES) ; do
4206 NUMS=$($LFIND -name "*$i" $TDIR | wc -l)
4207 [ $NUMS -eq $EXPECTED ] ||
4208 error "lfs find -name \"*$i\" $TDIR wrong: "\
4209 "found $NUMS, expected $EXPECTED"
4212 run_test 56g "check lfs find -name ============================="
4218 setup_56 $NUMFILES $NUMDIRS
4220 EXPECTED=$(((NUMDIRS + 1) * (NUMFILES - 1) + NUMFILES))
4221 # test lfs find with ! -name
4222 for i in $(seq 1 $NUMFILES) ; do
4223 NUMS=$($LFIND ! -name "*$i" $TDIR | wc -l)
4224 [ $NUMS -eq $EXPECTED ] ||
4225 error "lfs find ! -name \"*$i\" $TDIR wrong: "\
4226 "found $NUMS, expected $EXPECTED"
4229 run_test 56h "check lfs find ! -name ============================="
4233 test_mkdir -p $DIR/$tdir
4234 UUID=$(ostuuid_from_index 0 $DIR/$tdir)
4235 CMD="$LFIND -ost $UUID $DIR/$tdir"
4237 [ -z "$OUT" ] || error "\"$CMD\" returned directory '$OUT'"
4239 run_test 56i "check 'lfs find -ost UUID' skips directories ======="
4243 setup_56_special $NUMFILES $NUMDIRS
4245 EXPECTED=$((NUMDIRS + 1))
4246 CMD="$LFIND -type d $TDIR"
4247 NUMS=$($CMD | wc -l)
4248 [ $NUMS -eq $EXPECTED ] ||
4249 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4251 run_test 56j "check lfs find -type d ============================="
4255 setup_56_special $NUMFILES $NUMDIRS
4257 EXPECTED=$(((NUMDIRS + 1) * NUMFILES))
4258 CMD="$LFIND -type f $TDIR"
4259 NUMS=$($CMD | wc -l)
4260 [ $NUMS -eq $EXPECTED ] ||
4261 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4263 run_test 56k "check lfs find -type f ============================="
4267 setup_56_special $NUMFILES $NUMDIRS
4269 EXPECTED=$((NUMDIRS + NUMFILES))
4270 CMD="$LFIND -type b $TDIR"
4271 NUMS=$($CMD | wc -l)
4272 [ $NUMS -eq $EXPECTED ] ||
4273 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4275 run_test 56l "check lfs find -type b ============================="
4279 setup_56_special $NUMFILES $NUMDIRS
4281 EXPECTED=$((NUMDIRS + NUMFILES))
4282 CMD="$LFIND -type c $TDIR"
4283 NUMS=$($CMD | wc -l)
4284 [ $NUMS -eq $EXPECTED ] ||
4285 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4287 run_test 56m "check lfs find -type c ============================="
4291 setup_56_special $NUMFILES $NUMDIRS
4293 EXPECTED=$((NUMDIRS + NUMFILES))
4294 CMD="$LFIND -type l $TDIR"
4295 NUMS=$($CMD | wc -l)
4296 [ $NUMS -eq $EXPECTED ] ||
4297 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4299 run_test 56n "check lfs find -type l ============================="
4303 setup_56 $NUMFILES $NUMDIRS
4304 utime $TDIR/file1 > /dev/null || error "utime (1)"
4305 utime $TDIR/file2 > /dev/null || error "utime (2)"
4306 utime $TDIR/dir1 > /dev/null || error "utime (3)"
4307 utime $TDIR/dir2 > /dev/null || error "utime (4)"
4308 utime $TDIR/dir1/file1 > /dev/null || error "utime (5)"
4309 dd if=/dev/zero count=1 >> $TDIR/dir1/file1 && sync
4312 NUMS=`$LFIND -mtime +0 $TDIR | wc -l`
4313 [ $NUMS -eq $EXPECTED ] || \
4314 error "lfs find -mtime +0 $TDIR wrong: found $NUMS, expected $EXPECTED"
4317 CMD="$LFIND -mtime 0 $TDIR"
4318 NUMS=$($CMD | wc -l)
4319 [ $NUMS -eq $EXPECTED ] ||
4320 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4322 run_test 56o "check lfs find -mtime for old files =========================="
4325 [ $RUNAS_ID -eq $UID ] &&
4326 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
4329 setup_56 $NUMFILES $NUMDIRS
4331 chown $RUNAS_ID $TDIR/file* || error "chown $DIR/${tdir}g/file$i failed"
4333 CMD="$LFIND -uid $RUNAS_ID $TDIR"
4334 NUMS=$($CMD | wc -l)
4335 [ $NUMS -eq $EXPECTED ] || \
4336 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4338 EXPECTED=$(((NUMFILES + 1) * NUMDIRS + 1))
4339 CMD="$LFIND ! -uid $RUNAS_ID $TDIR"
4340 NUMS=$($CMD | wc -l)
4341 [ $NUMS -eq $EXPECTED ] || \
4342 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4344 run_test 56p "check lfs find -uid and ! -uid ==============================="
4347 [ $RUNAS_ID -eq $UID ] &&
4348 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
4351 setup_56 $NUMFILES $NUMDIRS
4353 chgrp $RUNAS_GID $TDIR/file* || error "chown $TDIR/file$i failed"
4356 CMD="$LFIND -gid $RUNAS_GID $TDIR"
4357 NUMS=$($CMD | wc -l)
4358 [ $NUMS -eq $EXPECTED ] ||
4359 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4361 EXPECTED=$(( ($NUMFILES+1) * $NUMDIRS + 1))
4362 CMD="$LFIND ! -gid $RUNAS_GID $TDIR"
4363 NUMS=$($CMD | wc -l)
4364 [ $NUMS -eq $EXPECTED ] ||
4365 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4367 run_test 56q "check lfs find -gid and ! -gid ==============================="
4371 setup_56 $NUMFILES $NUMDIRS
4374 CMD="$LFIND -size 0 -type f $TDIR"
4375 NUMS=$($CMD | wc -l)
4376 [ $NUMS -eq $EXPECTED ] ||
4377 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4379 CMD="$LFIND ! -size 0 -type f $TDIR"
4380 NUMS=$($CMD | wc -l)
4381 [ $NUMS -eq $EXPECTED ] ||
4382 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4383 echo "test" > $TDIR/$tfile
4384 echo "test2" > $TDIR/$tfile.2 && sync
4386 CMD="$LFIND -size 5 -type f $TDIR"
4387 NUMS=$($CMD | wc -l)
4388 [ $NUMS -eq $EXPECTED ] ||
4389 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4391 CMD="$LFIND -size +5 -type f $TDIR"
4392 NUMS=$($CMD | wc -l)
4393 [ $NUMS -eq $EXPECTED ] ||
4394 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4396 CMD="$LFIND -size +0 -type f $TDIR"
4397 NUMS=$($CMD | wc -l)
4398 [ $NUMS -eq $EXPECTED ] ||
4399 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4401 CMD="$LFIND ! -size -5 -type f $TDIR"
4402 NUMS=$($CMD | wc -l)
4403 [ $NUMS -eq $EXPECTED ] ||
4404 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4406 CMD="$LFIND -size -5 -type f $TDIR"
4407 NUMS=$($CMD | wc -l)
4408 [ $NUMS -eq $EXPECTED ] ||
4409 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4411 run_test 56r "check lfs find -size works =========================="
4413 test_56s() { # LU-611
4415 setup_56 $NUMFILES $NUMDIRS "-c $OSTCOUNT"
4417 if [ $OSTCOUNT -gt 1 ]; then
4418 $SETSTRIPE -c 1 $TDIR/$tfile.{0,1,2,3}
4422 ONESTRIPE=$(((NUMDIRS + 1) * NUMFILES))
4426 EXPECTED=$(((NUMDIRS + 1) * NUMFILES))
4427 CMD="$LFIND -stripe-count $OSTCOUNT -type f $TDIR"
4428 NUMS=$($CMD | wc -l)
4429 [ $NUMS -eq $EXPECTED ] ||
4430 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4432 EXPECTED=$(((NUMDIRS + 1) * NUMFILES + EXTRA))
4433 CMD="$LFIND -stripe-count +0 -type f $TDIR"
4434 NUMS=$($CMD | wc -l)
4435 [ $NUMS -eq $EXPECTED ] ||
4436 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4439 CMD="$LFIND -stripe-count 1 -type f $TDIR"
4440 NUMS=$($CMD | wc -l)
4441 [ $NUMS -eq $EXPECTED ] ||
4442 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4444 CMD="$LFIND -stripe-count -2 -type f $TDIR"
4445 NUMS=$($CMD | wc -l)
4446 [ $NUMS -eq $EXPECTED ] ||
4447 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4450 CMD="$LFIND -stripe-count $((OSTCOUNT + 1)) -type f $TDIR"
4451 NUMS=$($CMD | wc -l)
4452 [ $NUMS -eq $EXPECTED ] ||
4453 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4455 run_test 56s "check lfs find -stripe-count works"
4457 test_56t() { # LU-611
4459 setup_56 $NUMFILES $NUMDIRS "-s 512k"
4461 $SETSTRIPE -S 256k $TDIR/$tfile.{0,1,2,3}
4463 EXPECTED=$(((NUMDIRS + 1) * NUMFILES))
4464 CMD="$LFIND -stripe-size 512k -type f $TDIR"
4465 NUMS=$($CMD | wc -l)
4466 [ $NUMS -eq $EXPECTED ] ||
4467 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4469 CMD="$LFIND -stripe-size +320k -type f $TDIR"
4470 NUMS=$($CMD | wc -l)
4471 [ $NUMS -eq $EXPECTED ] ||
4472 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4474 EXPECTED=$(((NUMDIRS + 1) * NUMFILES + 4))
4475 CMD="$LFIND -stripe-size +200k -type f $TDIR"
4476 NUMS=$($CMD | wc -l)
4477 [ $NUMS -eq $EXPECTED ] ||
4478 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4480 CMD="$LFIND -stripe-size -640k -type f $TDIR"
4481 NUMS=$($CMD | wc -l)
4482 [ $NUMS -eq $EXPECTED ] ||
4483 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4486 CMD="$LFIND -stripe-size 256k -type f $TDIR"
4487 NUMS=$($CMD | wc -l)
4488 [ $NUMS -eq $EXPECTED ] ||
4489 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4491 CMD="$LFIND -stripe-size -320k -type f $TDIR"
4492 NUMS=$($CMD | wc -l)
4493 [ $NUMS -eq $EXPECTED ] ||
4494 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4497 CMD="$LFIND -stripe-size 1024k -type f $TDIR"
4498 NUMS=$($CMD | wc -l)
4499 [ $NUMS -eq $EXPECTED ] ||
4500 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4502 run_test 56t "check lfs find -stripe-size works"
4504 test_56u() { # LU-611
4506 setup_56 $NUMFILES $NUMDIRS "-i 0"
4508 if [ $OSTCOUNT -gt 1 ]; then
4509 $SETSTRIPE -i 1 $TDIR/$tfile.{0,1,2,3}
4515 EXPECTED=$(((NUMDIRS + 1) * NUMFILES))
4516 CMD="$LFIND -stripe-index 0 -type f $TDIR"
4517 NUMS=$($CMD | wc -l)
4518 [ $NUMS -eq $EXPECTED ] ||
4519 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4522 CMD="$LFIND -stripe-index 1 -type f $TDIR"
4523 NUMS=$($CMD | wc -l)
4524 [ $NUMS -eq $EXPECTED ] ||
4525 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4527 CMD="$LFIND ! -stripe-index 0 -type f $TDIR"
4528 NUMS=$($CMD | wc -l)
4529 [ $NUMS -eq $EXPECTED ] ||
4530 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4533 # This should produce an error and not return any files
4534 CMD="$LFIND -stripe-index $OSTCOUNT -type f $TDIR"
4535 NUMS=$($CMD 2>/dev/null | wc -l)
4536 [ $NUMS -eq $EXPECTED ] ||
4537 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4539 if [ $OSTCOUNT -gt 1 ]; then
4540 EXPECTED=$(((NUMDIRS + 1) * NUMFILES + ONESTRIPE))
4541 CMD="$LFIND -stripe-index 0,1 -type f $TDIR"
4542 NUMS=$($CMD | wc -l)
4543 [ $NUMS -eq $EXPECTED ] ||
4544 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4547 run_test 56u "check lfs find -stripe-index works"
4554 setup_56 $NUMFILES $NUMDIRS
4556 UUID=$(mdtuuid_from_index $MDT_IDX $TDIR)
4557 [ -z "$UUID" ] && error "mdtuuid_from_index cannot find MDT index $MDT_IDX"
4559 for file in $($LFIND -mdt $UUID $TDIR); do
4560 file_mdt_idx=$($GETSTRIPE -M $file)
4561 [ $file_mdt_idx -eq $MDT_IDX ] ||
4562 error "'lfind -mdt $UUID' != 'getstripe -M' ($file_mdt_idx)"
4565 run_test 56v "check 'lfs find -mdt match with lfs getstripe -M' ======="
4567 # Get and check the actual stripe count of one file.
4568 # Usage: check_stripe_count <file> <expected_stripe_count>
4569 check_stripe_count() {
4574 [[ -z "$file" || -z "$expected" ]] &&
4575 error "check_stripe_count: invalid argument!"
4577 local cmd="$GETSTRIPE -c $file"
4578 actual=$($cmd) || error "$cmd failed"
4579 actual=${actual%% *}
4581 if [[ $actual -ne $expected ]]; then
4582 [[ $expected -eq -1 ]] ||
4583 error "$cmd wrong: found $actual, expected $expected"
4584 [[ $actual -eq $OSTCOUNT ]] ||
4585 error "$cmd wrong: found $actual, expected $OSTCOUNT"
4590 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4593 rm -rf $TDIR || error "remove $TDIR failed"
4594 setup_56 $NUMFILES $NUMDIRS "-c $OSTCOUNT" "-c1"
4597 stripe_size=$($GETSTRIPE -S -d $TDIR) ||
4598 error "$GETSTRIPE -S -d $TDIR failed"
4599 stripe_size=${stripe_size%% *}
4601 local file_size=$((stripe_size * OSTCOUNT))
4602 local file_num=$((NUMDIRS * NUMFILES + NUMFILES))
4603 local required_space=$((file_num * file_size))
4604 local free_space=$($LCTL get_param -n lov.$LOVNAME.kbytesavail)
4605 [[ $free_space -le $((required_space / 1024)) ]] &&
4606 skip_env "need at least $required_space bytes free space," \
4607 "have $free_space kbytes" && return
4610 local dd_count=$((file_size / dd_bs))
4612 # write data into the files
4616 for i in $(seq 1 $NUMFILES); do
4618 yes | dd bs=$dd_bs count=$dd_count of=$file >/dev/null 2>&1 ||
4619 error "write data into $file failed"
4621 for i in $(seq 1 $NUMDIRS); do
4622 for j in $(seq 1 $NUMFILES); do
4623 file=$TDIR/dir$i/file$j
4624 yes | dd bs=$dd_bs count=$dd_count of=$file \
4626 error "write data into $file failed"
4631 [[ $OSTCOUNT -gt 1 ]] && expected=$((OSTCOUNT - 1))
4634 local cmd="$LFS_MIGRATE -y -c $expected $TDIR/file1"
4636 eval $cmd || error "$cmd failed"
4638 check_stripe_count $TDIR/file1 $expected
4641 cmd="$LFS_MIGRATE -y -c $expected $TDIR/dir1"
4643 eval $cmd || error "$cmd failed"
4645 for j in $(seq 1 $NUMFILES); do
4646 check_stripe_count $TDIR/dir1/file$j $expected
4649 # lfs_migrate works with lfs find
4650 cmd="$LFIND -stripe_count $OSTCOUNT -type f $TDIR |
4651 $LFS_MIGRATE -y -c $expected"
4653 eval $cmd || error "$cmd failed"
4655 for i in $(seq 2 $NUMFILES); do
4656 check_stripe_count $TDIR/file$i $expected
4658 for i in $(seq 2 $NUMDIRS); do
4659 for j in $(seq 1 $NUMFILES); do
4660 check_stripe_count $TDIR/dir$i/file$j $expected
4664 run_test 56w "check lfs_migrate -c stripe_count works"
4667 check_swap_layouts_support && return 0
4668 [ "$OSTCOUNT" -lt "2" ] &&
4669 skip_env "need 2 OST, skipping test" && return
4671 local dir0=$DIR/$tdir/$testnum
4672 mkdir -p $dir0 || error "creating dir $dir0"
4674 local ref1=/etc/passwd
4675 local file1=$dir0/file1
4677 $SETSTRIPE -c 2 $file1
4679 $LFS migrate -c 1 $file1 || error "migrate failed rc = $?"
4680 stripe=$($GETSTRIPE -c $file1)
4681 [[ $stripe == 1 ]] || error "stripe of $file1 is $stripe != 1"
4682 cmp $file1 $ref1 || error "content mismatch $file1 differs from $ref1"
4687 run_test 56x "lfs migration support"
4690 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.53) ] &&
4691 skip "No HSM support on MDS of $(get_lustre_version)," \
4692 "need 2.4.53 at least" && return
4695 local dir0=$DIR/$tdir/$testnum
4696 mkdir -p $dir0 || error "creating dir $dir0"
4697 local f1=$dir0/file1
4698 local f2=$dir0/file2
4700 touch $f1 || error "creating std file $f1"
4701 $MULTIOP $f2 H2c || error "creating released file $f2"
4703 # a directory can be raid0, so ask only for files
4704 res=$($LFIND $dir0 -L raid0 -type f | wc -l)
4705 [[ $res == 2 ]] || error "search raid0: found $res files != 2"
4707 res=$($LFIND $dir0 \! -L raid0 -type f | wc -l)
4708 [[ $res == 0 ]] || error "search !raid0: found $res files != 0"
4710 # only files can be released, so no need to force file search
4711 res=$($LFIND $dir0 -L released)
4712 [[ $res == $f2 ]] || error "search released: found $res != $f2"
4714 res=$($LFIND $dir0 \! -L released)
4715 [[ $res == $f1 ]] || error "search !released: found $res != $f1"
4718 run_test 56y "lfs find -L raid0|released"
4721 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4722 # note test will not do anything if MDS is not local
4723 if [ "$(facet_fstype $SINGLEMDS)" != ldiskfs ]; then
4724 skip "Only applicable to ldiskfs-based MDTs"
4728 remote_mds_nodsh && skip "remote MDS with nodsh" && return
4729 local MNTDEV="osd*.*MDT*.mntdev"
4730 DEV=$(do_facet $SINGLEMDS lctl get_param -n $MNTDEV)
4731 [ -z "$DEV" ] && error "can't access $MNTDEV"
4732 for DEV in $(do_facet $SINGLEMDS lctl get_param -n $MNTDEV); do
4733 do_facet $SINGLEMDS $DUMPE2FS -h $DEV > $TMP/t57a.dump ||
4734 error "can't access $DEV"
4735 DEVISIZE=`awk '/Inode size:/ { print $3 }' $TMP/t57a.dump`
4736 [ "$DEVISIZE" -gt 128 ] || error "inode size $DEVISIZE"
4740 run_test 57a "verify MDS filesystem created with large inodes =="
4743 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4744 if [ "$(facet_fstype $SINGLEMDS)" != ldiskfs ]; then
4745 skip "Only applicable to ldiskfs-based MDTs"
4749 remote_mds_nodsh && skip "remote MDS with nodsh" && return
4754 local FILEN=$dir/f$FILECOUNT
4756 rm -rf $dir || error "removing $dir"
4757 test_mkdir -p $dir || error "creating $dir"
4758 local num=$(get_mds_dir $dir)
4761 echo "mcreating $FILECOUNT files"
4762 createmany -m $dir/f 1 $FILECOUNT || \
4763 error "creating files in $dir"
4765 # verify that files do not have EAs yet
4766 $GETSTRIPE $FILE1 2>&1 | grep -q "no stripe" || error "$FILE1 has an EA"
4767 $GETSTRIPE $FILEN 2>&1 | grep -q "no stripe" || error "$FILEN has an EA"
4771 df $dir #make sure we get new statfs data
4772 local MDSFREE=$(do_facet $mymds \
4773 lctl get_param -n osd*.*MDT000$((num -1)).kbytesfree)
4774 local MDCFREE=$(lctl get_param -n mdc.*MDT000$((num -1))-mdc-*.kbytesfree)
4775 echo "opening files to create objects/EAs"
4777 for FILE in `seq -f $dir/f%g 1 $FILECOUNT`; do
4778 $OPENFILE -f O_RDWR $FILE > /dev/null 2>&1 || error "opening $FILE"
4781 # verify that files have EAs now
4782 $GETSTRIPE $FILE1 | grep -q "obdidx" || error "$FILE1 missing EA"
4783 $GETSTRIPE $FILEN | grep -q "obdidx" || error "$FILEN missing EA"
4785 sleep 1 #make sure we get new statfs data
4787 local MDSFREE2=$(do_facet $mymds \
4788 lctl get_param -n osd*.*MDT000$((num -1)).kbytesfree)
4789 local MDCFREE2=$(lctl get_param -n mdc.*MDT000$((num -1))-mdc-*.kbytesfree)
4790 if [ "$MDCFREE2" -lt "$((MDCFREE - 16))" ]; then
4791 if [ "$MDSFREE" != "$MDSFREE2" ]; then
4792 error "MDC before $MDCFREE != after $MDCFREE2"
4794 echo "MDC before $MDCFREE != after $MDCFREE2"
4795 echo "unable to confirm if MDS has large inodes"
4800 run_test 57b "default LOV EAs are stored inside large inodes ==="
4803 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4804 [ -z "$(which wiretest 2>/dev/null)" ] &&
4805 skip_env "could not find wiretest" && return
4808 run_test 58 "verify cross-platform wire constants =============="
4811 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4812 echo "touch 130 files"
4813 createmany -o $DIR/f59- 130
4815 unlinkmany $DIR/f59- 130
4817 # wait for commitment of removal
4818 wait_delete_completed
4820 run_test 59 "verify cancellation of llog records async ========="
4822 TEST60_HEAD="test_60 run $RANDOM"
4824 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4825 remote_mgs_nodsh && skip "remote MGS with nodsh" && return
4826 do_facet mgs "! which run-llog.sh &> /dev/null" &&
4827 skip_env "missing subtest run-llog.sh" && return
4828 log "$TEST60_HEAD - from kernel mode"
4829 do_facet mgs sh run-llog.sh
4831 run_test 60a "llog sanity tests run from kernel module =========="
4833 test_60b() { # bug 6411
4834 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4836 LLOG_COUNT=`dmesg | awk "/$TEST60_HEAD/{marker = 1; from_marker = 0;}
4848 [ $LLOG_COUNT -gt 50 ] && error "CDEBUG_LIMIT not limiting messages ($LLOG_COUNT)"|| true
4850 run_test 60b "limit repeated messages from CERROR/CWARN ========"
4853 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4854 echo "create 5000 files"
4855 createmany -o $DIR/f60c- 5000
4856 #define OBD_FAIL_MDS_LLOG_CREATE_FAILED 0x137
4857 lctl set_param fail_loc=0x80000137
4858 unlinkmany $DIR/f60c- 5000
4859 lctl set_param fail_loc=0
4861 run_test 60c "unlink file when mds full"
4864 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4865 SAVEPRINTK=$(lctl get_param -n printk)
4867 # verify "lctl mark" is even working"
4868 MESSAGE="test message ID $RANDOM $$"
4869 $LCTL mark "$MESSAGE" || error "$LCTL mark failed"
4870 dmesg | grep -q "$MESSAGE" || error "didn't find debug marker in log"
4872 lctl set_param printk=0 || error "set lnet.printk failed"
4873 lctl get_param -n printk | grep emerg || error "lnet.printk dropped emerg"
4874 MESSAGE="new test message ID $RANDOM $$"
4875 # Assume here that libcfs_debug_mark_buffer() uses D_WARNING
4876 $LCTL mark "$MESSAGE" || error "$LCTL mark failed"
4877 dmesg | grep -q "$MESSAGE" && error "D_WARNING wasn't masked" || true
4879 lctl set_param -n printk="$SAVEPRINTK"
4881 run_test 60d "test printk console message masking"
4884 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4886 dd if=/dev/zero of=$f bs=$(page_size) count=1 || error "dd $f failed"
4887 cancel_lru_locks osc
4888 $MULTIOP $f OSMWUc || error "$MULTIOP $f failed"
4891 run_test 61 "mmap() writes don't make sync hang ================"
4893 # bug 2330 - insufficient obd_match error checking causes LBUG
4895 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4898 cancel_lru_locks osc
4899 lctl set_param fail_loc=0x405
4900 cat $f && error "cat succeeded, expect -EIO"
4901 lctl set_param fail_loc=0
4903 # This test is now irrelevant (as of bug 10718 inclusion), we no longer
4904 # match every page all of the time.
4905 #run_test 62 "verify obd_match failure doesn't LBUG (should -EIO)"
4907 # bug 2319 - oig_wait() interrupted causes crash because of invalid waitq.
4908 # Though this test is irrelevant anymore, it helped to reveal some
4909 # other grant bugs (LU-4482), let's keep it.
4910 test_63a() { # was test_63
4911 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4912 MAX_DIRTY_MB=`lctl get_param -n osc.*.max_dirty_mb | head -n 1`
4913 for i in `seq 10` ; do
4914 dd if=/dev/zero of=$DIR/f63 bs=8k &
4920 rm -f $DIR/f63 || true
4922 run_test 63a "Verify oig_wait interruption does not crash ======="
4924 # bug 2248 - async write errors didn't return to application on sync
4925 # bug 3677 - async write errors left page locked
4927 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4929 lctl set_param debug=-1
4931 # ensure we have a grant to do async writes
4932 dd if=/dev/zero of=$DIR/$tfile bs=4k count=1
4935 #define OBD_FAIL_OSC_BRW_PREP_REQ 0x406
4936 lctl set_param fail_loc=0x80000406
4937 $MULTIOP $DIR/$tfile Owy && \
4938 error "sync didn't return ENOMEM"
4939 sync; sleep 2; sync # do a real sync this time to flush page
4940 lctl get_param -n llite.*.dump_page_cache | grep locked && \
4941 error "locked page left in cache after async error" || true
4944 run_test 63b "async write errors should be returned to fsync ==="
4947 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4949 lctl get_param -n osc.*[oO][sS][cC][_-]*.cur* | grep "[0-9]"
4951 run_test 64a "verify filter grant calculations (in kernel) ====="
4954 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4955 sh oos.sh $MOUNT || error "oos.sh failed: $?"
4957 run_test 64b "check out-of-space detection on client ==========="
4960 $LCTL set_param osc.*OST0000-osc-[^mM]*.cur_grant_bytes=0
4962 run_test 64c "verify grant shrink ========================------"
4964 # bug 1414 - set/get directories' stripe info
4966 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4967 test_mkdir -p $DIR/$tdir
4969 $LVERIFY $DIR/$tdir $DIR/$tdir/f1 || error "lverify failed"
4971 run_test 65a "directory with no stripe info ===================="
4974 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4975 test_mkdir -p $DIR/$tdir
4976 $SETSTRIPE -S $((STRIPESIZE * 2)) -i 0 -c 1 $DIR/$tdir ||
4979 $LVERIFY $DIR/$tdir $DIR/$tdir/f2 || error "lverify failed"
4981 run_test 65b "directory setstripe -S $((STRIPESIZE * 2)) -i 0 -c 1"
4984 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4985 if [ $OSTCOUNT -gt 1 ]; then
4986 test_mkdir -p $DIR/$tdir
4987 $SETSTRIPE -S $(($STRIPESIZE * 4)) -i 1 \
4988 -c $(($OSTCOUNT - 1)) $DIR/$tdir || error "setstripe"
4990 $LVERIFY $DIR/$tdir $DIR/$tdir/f3 || error "lverify failed"
4993 run_test 65c "directory setstripe -S $((STRIPESIZE*4)) -i 1 -c $((OSTCOUNT-1))"
4996 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4997 test_mkdir -p $DIR/$tdir
4998 if [ $STRIPECOUNT -le 0 ]; then
5000 elif [ $STRIPECOUNT -gt 2000 ]; then
5001 #LOV_MAX_STRIPE_COUNT is 2000
5002 [ $OSTCOUNT -gt 2000 ] && sc=2000 || sc=$(($OSTCOUNT - 1))
5004 sc=$(($STRIPECOUNT - 1))
5006 $SETSTRIPE -S $STRIPESIZE -c $sc $DIR/$tdir || error "setstripe"
5007 touch $DIR/$tdir/f4 $DIR/$tdir/f5
5008 $LVERIFY $DIR/$tdir $DIR/$tdir/f4 $DIR/$tdir/f5 ||
5009 error "lverify failed"
5011 run_test 65d "directory setstripe -S $STRIPESIZE -c stripe_count"
5014 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5015 test_mkdir -p $DIR/$tdir
5017 $SETSTRIPE $DIR/$tdir || error "setstripe"
5018 $GETSTRIPE -v $DIR/$tdir | grep "Default" ||
5019 error "no stripe info failed"
5021 $LVERIFY $DIR/$tdir $DIR/$tdir/f6 || error "lverify failed"
5023 run_test 65e "directory setstripe defaults ======================="
5026 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5027 test_mkdir -p $DIR/${tdir}f
5028 $RUNAS $SETSTRIPE $DIR/${tdir}f && error "setstripe succeeded" || true
5030 run_test 65f "dir setstripe permission (should return error) ==="
5033 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5034 test_mkdir -p $DIR/$tdir
5035 $SETSTRIPE -S $((STRIPESIZE * 2)) -i 0 -c 1 $DIR/$tdir ||
5037 $SETSTRIPE -d $DIR/$tdir || error "setstripe"
5038 $GETSTRIPE -v $DIR/$tdir | grep "Default" ||
5039 error "delete default stripe failed"
5041 run_test 65g "directory setstripe -d ==========================="
5044 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5045 test_mkdir -p $DIR/$tdir
5046 $SETSTRIPE -S $((STRIPESIZE * 2)) -i 0 -c 1 $DIR/$tdir ||
5048 test_mkdir -p $DIR/$tdir/dd1
5049 [ $($GETSTRIPE -c $DIR/$tdir) == $($GETSTRIPE -c $DIR/$tdir/dd1) ] ||
5050 error "stripe info inherit failed"
5052 run_test 65h "directory stripe info inherit ===================="
5054 test_65i() { # bug6367
5055 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5056 $SETSTRIPE -S 65536 -c -1 $MOUNT
5058 run_test 65i "set non-default striping on root directory (bug 6367)="
5060 test_65ia() { # bug12836
5061 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5062 $GETSTRIPE $MOUNT || error "getstripe $MOUNT failed"
5064 run_test 65ia "getstripe on -1 default directory striping"
5066 test_65ib() { # bug12836
5067 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5068 $GETSTRIPE -v $MOUNT || error "getstripe -v $MOUNT failed"
5070 run_test 65ib "getstripe -v on -1 default directory striping"
5072 test_65ic() { # bug12836
5073 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5074 $LFS find -mtime -1 $MOUNT > /dev/null || error "find $MOUNT failed"
5076 run_test 65ic "new find on -1 default directory striping"
5078 test_65j() { # bug6367
5079 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5081 # if we aren't already remounting for each test, do so for this test
5082 if [ "$CLEANUP" = ":" -a "$I_MOUNTED" = "yes" ]; then
5083 cleanup || error "failed to unmount"
5086 $SETSTRIPE -d $MOUNT || error "setstripe failed"
5088 run_test 65j "set default striping on root directory (bug 6367)="
5090 test_65k() { # bug11679
5091 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5092 [ "$OSTCOUNT" -lt 2 ] && skip_env "too few OSTs" && return
5093 remote_mds_nodsh && skip "remote MDS with nodsh" && return
5095 echo "Check OST status: "
5096 local MDS_OSCS=`do_facet $SINGLEMDS lctl dl |
5097 awk '/[oO][sS][cC].*md[ts]/ { print $4 }'`
5099 for OSC in $MDS_OSCS; do
5100 echo $OSC "is activate"
5101 do_facet $SINGLEMDS lctl --device %$OSC activate
5105 for INACTIVE_OSC in $MDS_OSCS; do
5106 echo "Deactivate: " $INACTIVE_OSC
5107 do_facet $SINGLEMDS lctl --device %$INACTIVE_OSC deactivate
5108 for STRIPE_OSC in $MDS_OSCS; do
5109 OST=`osc_to_ost $STRIPE_OSC`
5110 IDX=`do_facet $SINGLEMDS lctl get_param -n lov.*md*.target_obd |
5111 awk -F: /$OST/'{ print $1 }' | head -n 1`
5113 [ -f $DIR/$tdir/$IDX ] && continue
5114 echo "$SETSTRIPE -i $IDX -c 1 $DIR/$tdir/$IDX"
5115 $SETSTRIPE -i $IDX -c 1 $DIR/$tdir/$IDX
5117 [ $RC -ne 0 ] && error "setstripe should have succeeded"
5120 echo $INACTIVE_OSC "is Activate."
5121 do_facet $SINGLEMDS lctl --device %$INACTIVE_OSC activate
5124 run_test 65k "validate manual striping works properly with deactivated OSCs"
5126 test_65l() { # bug 12836
5127 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5128 test_mkdir -p $DIR/$tdir/test_dir
5129 $SETSTRIPE -c -1 $DIR/$tdir/test_dir
5130 $LFS find -mtime -1 $DIR/$tdir >/dev/null
5132 run_test 65l "lfs find on -1 stripe dir ========================"
5134 # bug 2543 - update blocks count on client
5136 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5138 dd if=/dev/zero of=$DIR/f66 bs=1k count=$COUNT
5139 sync; sync_all_data; sync; sync_all_data
5140 cancel_lru_locks osc
5141 BLOCKS=`ls -s $DIR/f66 | awk '{ print $1 }'`
5142 [ $BLOCKS -ge $COUNT ] || error "$DIR/f66 blocks $BLOCKS < $COUNT"
5144 run_test 66 "update inode blocks count on client ==============="
5149 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5151 if [ ! -z "$LLOOP" ]; then
5152 if swapon -s | grep -q $LLOOP; then
5153 swapoff $LLOOP || error "swapoff failed"
5156 $LCTL blockdev_detach $LLOOP || error "detach failed"
5160 if [ ! -z "$LLITELOOPLOAD" ]; then
5168 awk '($1 == "'$1':") { print $2 }' /proc/meminfo
5172 swapon -s | awk '($1 == "'$1'") { print $4 }'
5175 # test case for lloop driver, basic function
5177 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5178 [ "$UID" != 0 ] && skip_env "must run as root" && return
5179 llite_lloop_enabled || \
5180 { skip_env "llite_lloop module disabled" && return; }
5182 trap cleanup_68 EXIT
5184 if ! module_loaded llite_lloop; then
5185 if load_module llite/llite_lloop; then
5188 skip_env "can't find module llite_lloop"
5193 LLOOP=$TMP/lloop.`date +%s`.`date +%N`
5194 dd if=/dev/zero of=$DIR/f68a bs=4k count=1024
5195 $LCTL blockdev_attach $DIR/f68a $LLOOP || error "attach failed"
5197 directio rdwr $LLOOP 0 1024 4096 || error "direct write failed"
5198 directio rdwr $LLOOP 0 1025 4096 && error "direct write should fail"
5202 run_test 68a "lloop driver - basic test ========================"
5204 # excercise swapping to lustre by adding a high priority swapfile entry
5205 # and then consuming memory until it is used.
5206 test_68b() { # was test_68
5207 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5208 [ "$UID" != 0 ] && skip_env "must run as root" && return
5209 lctl get_param -n devices | grep -q obdfilter && \
5210 skip "local OST" && return
5212 grep -q llite_lloop /proc/modules
5213 [ $? -ne 0 ] && skip "can't find module llite_lloop" && return
5215 [ -z "`$LCTL list_nids | grep -v tcp`" ] && \
5216 skip "can't reliably test swap with TCP" && return
5218 MEMTOTAL=`meminfo MemTotal`
5219 NR_BLOCKS=$((MEMTOTAL>>8))
5220 [[ $NR_BLOCKS -le 2048 ]] && NR_BLOCKS=2048
5222 LLOOP=$TMP/lloop.`date +%s`.`date +%N`
5223 dd if=/dev/zero of=$DIR/f68b bs=64k seek=$NR_BLOCKS count=1
5226 $LCTL blockdev_attach $DIR/f68b $LLOOP || error "attach failed"
5228 trap cleanup_68 EXIT
5230 swapon -p 32767 $LLOOP || error "swapon $LLOOP failed"
5232 echo "before: `swapon -s | grep $LLOOP`"
5233 $MEMHOG $MEMTOTAL || error "error allocating $MEMTOTAL kB"
5234 echo "after: `swapon -s | grep $LLOOP`"
5235 SWAPUSED=`swap_used $LLOOP`
5239 [ $SWAPUSED -eq 0 ] && echo "no swap used???" || true
5241 run_test 68b "support swapping to Lustre ========================"
5243 # bug5265, obdfilter oa2dentry return -ENOENT
5244 # #define OBD_FAIL_OST_ENOENT 0x217
5246 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5247 remote_ost_nodsh && skip "remote OST with nodsh" && return
5250 $SETSTRIPE -c 1 -i 0 $f
5252 $DIRECTIO write ${f}.2 0 1 || error "directio write error"
5254 do_facet ost1 lctl set_param fail_loc=0x217
5255 $TRUNCATE $f 1 # vmtruncate() will ignore truncate() error.
5256 $DIRECTIO write $f 0 2 && error "write succeeded, expect -ENOENT"
5258 do_facet ost1 lctl set_param fail_loc=0
5259 $DIRECTIO write $f 0 2 || error "write error"
5261 cancel_lru_locks osc
5262 $DIRECTIO read $f 0 1 || error "read error"
5264 do_facet ost1 lctl set_param fail_loc=0x217
5265 $DIRECTIO read $f 1 1 && error "read succeeded, expect -ENOENT"
5267 do_facet ost1 lctl set_param fail_loc=0
5270 run_test 69 "verify oa2dentry return -ENOENT doesn't LBUG ======"
5273 test_mkdir -p $DIR/$tdir
5274 sh rundbench -C -D $DIR/$tdir 2 || error "dbench failed!"
5276 run_test 71 "Running dbench on lustre (don't segment fault) ===="
5278 test_72a() { # bug 5695 - Test that on 2.6 remove_suid works properly
5279 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5280 [ "$RUNAS_ID" = "$UID" ] &&
5281 skip_env "RUNAS_ID = UID = $UID -- skipping" && 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_GID $RUNAS || {
5285 skip_env "User $RUNAS_ID does not exist - skipping"
5288 # We had better clear the $DIR to get enough space for dd
5291 chmod 777 $DIR/$tfile
5292 chmod ug+s $DIR/$tfile
5293 $RUNAS dd if=/dev/zero of=$DIR/$tfile bs=512 count=1 ||
5294 error "$RUNAS dd $DIR/$tfile failed"
5295 # See if we are still setuid/sgid
5296 test -u $DIR/$tfile -o -g $DIR/$tfile &&
5297 error "S/gid is not dropped on write"
5298 # Now test that MDS is updated too
5299 cancel_lru_locks mdc
5300 test -u $DIR/$tfile -o -g $DIR/$tfile &&
5301 error "S/gid is not dropped on MDS"
5304 run_test 72a "Test that remove suid works properly (bug5695) ===="
5306 test_72b() { # bug 24226 -- keep mode setting when size is not changing
5309 [ "$RUNAS_ID" = "$UID" ] && \
5310 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
5311 [ "$RUNAS_ID" -eq 0 ] && \
5312 skip_env "RUNAS_ID = 0 -- skipping" && return
5314 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5315 # Check that testing environment is properly set up. Skip if not
5316 FAIL_ON_ERROR=false check_runas_id_ret $RUNAS_ID $RUNAS_ID $RUNAS || {
5317 skip_env "User $RUNAS_ID does not exist - skipping"
5320 touch $DIR/${tfile}-f{g,u}
5321 test_mkdir $DIR/${tfile}-dg
5322 test_mkdir $DIR/${tfile}-du
5323 chmod 770 $DIR/${tfile}-{f,d}{g,u}
5324 chmod g+s $DIR/${tfile}-{f,d}g
5325 chmod u+s $DIR/${tfile}-{f,d}u
5326 for perm in 777 2777 4777; do
5327 $RUNAS chmod $perm $DIR/${tfile}-fg && error "S/gid file allowed improper chmod to $perm"
5328 $RUNAS chmod $perm $DIR/${tfile}-fu && error "S/uid file allowed improper chmod to $perm"
5329 $RUNAS chmod $perm $DIR/${tfile}-dg && error "S/gid dir allowed improper chmod to $perm"
5330 $RUNAS chmod $perm $DIR/${tfile}-du && error "S/uid dir allowed improper chmod to $perm"
5334 run_test 72b "Test that we keep mode setting if without file data changed (bug 24226)"
5336 # bug 3462 - multiple simultaneous MDC requests
5338 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5339 test_mkdir $DIR/d73-1
5340 test_mkdir $DIR/d73-2
5341 multiop_bg_pause $DIR/d73-1/f73-1 O_c || return 1
5344 lctl set_param fail_loc=0x80000129
5345 $MULTIOP $DIR/d73-1/f73-2 Oc &
5347 lctl set_param fail_loc=0
5349 $MULTIOP $DIR/d73-2/f73-3 Oc &
5353 wait $pid1 || return 1
5357 $CHECKSTAT -t file $DIR/d73-1/f73-1 || return 4
5358 $CHECKSTAT -t file $DIR/d73-1/f73-2 || return 5
5359 $CHECKSTAT -t file $DIR/d73-2/f73-3 || return 6
5363 run_test 73 "multiple MDC requests (should not deadlock)"
5365 test_74a() { # bug 6149, 6184
5366 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5367 #define OBD_FAIL_LDLM_ENQUEUE_OLD_EXPORT 0x30e
5369 # very important to OR with OBD_FAIL_ONCE (0x80000000) -- otherwise it
5370 # will spin in a tight reconnection loop
5372 lctl set_param fail_loc=0x8000030e
5373 # get any lock that won't be difficult - lookup works.
5375 lctl set_param fail_loc=0
5379 run_test 74a "ldlm_enqueue freed-export error path, ls (shouldn't LBUG)"
5381 test_74b() { # bug 13310
5382 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5383 #define OBD_FAIL_LDLM_ENQUEUE_OLD_EXPORT 0x30e
5385 # very important to OR with OBD_FAIL_ONCE (0x80000000) -- otherwise it
5386 # will spin in a tight reconnection loop
5387 lctl set_param fail_loc=0x8000030e
5388 # get a "difficult" lock
5390 lctl set_param fail_loc=0
5394 run_test 74b "ldlm_enqueue freed-export error path, touch (shouldn't LBUG)"
5397 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5398 #define OBD_FAIL_LDLM_NEW_LOCK
5399 lctl set_param fail_loc=0x80000319
5400 touch $DIR/$tfile && error "Touch successful"
5403 run_test 74c "ldlm_lock_create error path, (shouldn't LBUG)"
5406 awk '/lustre_inode_cache/ {print $2; exit}' /proc/slabinfo
5409 get_inode_slab_tunables() {
5410 awk '/lustre_inode_cache/ {print $9," ",$10," ",$11; exit}' /proc/slabinfo
5413 set_inode_slab_tunables() {
5414 echo "lustre_inode_cache $1" > /proc/slabinfo
5417 test_76() { # Now for bug 20433, added originally in bug 1443
5418 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5419 local SLAB_SETTINGS=`get_inode_slab_tunables`
5420 local CPUS=`getconf _NPROCESSORS_ONLN`
5421 # we cannot set limit below 1 which means 1 inode in each
5422 # per-cpu cache is still allowed
5423 set_inode_slab_tunables "1 1 0"
5424 cancel_lru_locks osc
5425 BEFORE_INODES=`num_inodes`
5426 echo "before inodes: $BEFORE_INODES"
5428 [ "$SLOW" = "no" ] && COUNT=100
5429 for i in `seq $COUNT`; do
5433 cancel_lru_locks osc
5434 AFTER_INODES=`num_inodes`
5435 echo "after inodes: $AFTER_INODES"
5437 while [ $((AFTER_INODES-1*CPUS)) -gt $BEFORE_INODES ]; do
5439 AFTER_INODES=`num_inodes`
5441 echo "wait $wait seconds inodes: $AFTER_INODES"
5442 if [ $wait -gt 30 ]; then
5443 error "inode slab grew from $BEFORE_INODES to $AFTER_INODES"
5446 set_inode_slab_tunables "$SLAB_SETTINGS"
5448 run_test 76 "confirm clients recycle inodes properly ===="
5454 # Note: in sptlrpc modes which enable its own bulk checksum, the
5455 # original crc32_le bulk checksum will be automatically disabled,
5456 # and the OBD_FAIL_OSC_CHECKSUM_SEND/OBD_FAIL_OSC_CHECKSUM_RECEIVE
5457 # will be checked by sptlrpc code against sptlrpc bulk checksum.
5458 # In this case set_checksums() will not be no-op, because sptlrpc
5459 # bulk checksum will be enabled all through the test.
5461 [ "$ORIG_CSUM" ] || ORIG_CSUM=`lctl get_param -n osc.*.checksums | head -n1`
5462 lctl set_param -n osc.*.checksums $1
5466 export ORIG_CSUM_TYPE="`lctl get_param -n osc.*osc-[^mM]*.checksum_type |
5467 sed 's/.*\[\(.*\)\].*/\1/g' | head -n1`"
5468 CKSUM_TYPES=${CKSUM_TYPES:-"crc32 adler"}
5469 [ "$ORIG_CSUM_TYPE" = "crc32c" ] && CKSUM_TYPES="$CKSUM_TYPES crc32c"
5472 lctl set_param -n osc.*osc-[^mM]*.checksum_type $1
5473 log "set checksum type to $1"
5476 F77_TMP=$TMP/f77-temp
5479 dd if=/dev/urandom of=$F77_TMP bs=1M count=$F77SZ || \
5480 error "error writing to $F77_TMP"
5483 test_77a() { # bug 10889
5484 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5485 $GSS && skip "could not run with gss" && return
5486 [ ! -f $F77_TMP ] && setup_f77
5488 dd if=$F77_TMP of=$DIR/$tfile bs=1M count=$F77SZ || error "dd error"
5492 run_test 77a "normal checksum read/write operation"
5494 test_77b() { # bug 10889
5495 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5496 $GSS && skip "could not run with gss" && return
5497 [ ! -f $F77_TMP ] && setup_f77
5498 #define OBD_FAIL_OSC_CHECKSUM_SEND 0x409
5499 $LCTL set_param fail_loc=0x80000409
5502 dd if=$F77_TMP of=$DIR/$tfile bs=1M count=$F77SZ conv=sync ||
5503 error "dd error: $?"
5504 $LCTL set_param fail_loc=0
5506 for algo in $CKSUM_TYPES; do
5507 cancel_lru_locks osc
5508 set_checksum_type $algo
5509 #define OBD_FAIL_OSC_CHECKSUM_RECEIVE 0x408
5510 $LCTL set_param fail_loc=0x80000408
5511 cmp $F77_TMP $DIR/$tfile || error "file compare failed"
5512 $LCTL set_param fail_loc=0
5515 set_checksum_type $ORIG_CSUM_TYPE
5518 run_test 77b "checksum error on client write, read"
5520 test_77d() { # bug 10889
5521 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5522 $GSS && skip "could not run with gss" && return
5523 #define OBD_FAIL_OSC_CHECKSUM_SEND 0x409
5524 $LCTL set_param fail_loc=0x80000409
5526 $DIRECTIO write $DIR/$tfile 0 $F77SZ $((1024 * 1024)) ||
5527 error "direct write: rc=$?"
5528 $LCTL set_param fail_loc=0
5531 #define OBD_FAIL_OSC_CHECKSUM_RECEIVE 0x408
5532 $LCTL set_param fail_loc=0x80000408
5534 cancel_lru_locks osc
5535 $DIRECTIO read $DIR/$tfile 0 $F77SZ $((1024 * 1024)) ||
5536 error "direct read: rc=$?"
5537 $LCTL set_param fail_loc=0
5540 run_test 77d "checksum error on OST direct write, read"
5542 test_77f() { # bug 10889
5543 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5544 $GSS && skip "could not run with gss" && return
5546 for algo in $CKSUM_TYPES; do
5547 cancel_lru_locks osc
5548 set_checksum_type $algo
5549 #define OBD_FAIL_OSC_CHECKSUM_SEND 0x409
5550 $LCTL set_param fail_loc=0x409
5551 $DIRECTIO write $DIR/$tfile 0 $F77SZ $((1024 * 1024)) &&
5552 error "direct write succeeded"
5553 $LCTL set_param fail_loc=0
5555 set_checksum_type $ORIG_CSUM_TYPE
5558 run_test 77f "repeat checksum error on write (expect error)"
5560 test_77g() { # bug 10889
5561 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5562 $GSS && skip "could not run with gss" && return
5563 remote_ost_nodsh && skip "remote OST with nodsh" && return
5565 [ ! -f $F77_TMP ] && setup_f77
5567 $SETSTRIPE -c 1 -i 0 $DIR/$tfile
5568 #define OBD_FAIL_OST_CHECKSUM_RECEIVE 0x21a
5569 do_facet ost1 lctl set_param fail_loc=0x8000021a
5571 dd if=$F77_TMP of=$DIR/$tfile bs=1M count=$F77SZ ||
5572 error "write error: rc=$?"
5573 do_facet ost1 lctl set_param fail_loc=0
5576 cancel_lru_locks osc
5577 #define OBD_FAIL_OST_CHECKSUM_SEND 0x21b
5578 do_facet ost1 lctl set_param fail_loc=0x8000021b
5580 cmp $F77_TMP $DIR/$tfile || error "file compare failed"
5581 do_facet ost1 lctl set_param fail_loc=0
5584 run_test 77g "checksum error on OST write, read"
5586 test_77i() { # bug 13805
5587 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5588 $GSS && skip "could not run with gss" && return
5589 #define OBD_FAIL_OSC_CONNECT_CKSUM 0x40b
5590 lctl set_param fail_loc=0x40b
5591 remount_client $MOUNT
5592 lctl set_param fail_loc=0
5593 for VALUE in `lctl get_param osc.*osc-[^mM]*.checksum_type`; do
5594 PARAM=`echo ${VALUE[0]} | cut -d "=" -f1`
5595 algo=`lctl get_param -n $PARAM | sed 's/.*\[\(.*\)\].*/\1/g'`
5596 [ "$algo" = "adler" ] || error "algo set to $algo instead of adler"
5598 remount_client $MOUNT
5600 run_test 77i "client not supporting OSD_CONNECT_CKSUM"
5602 test_77j() { # bug 13805
5603 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5604 $GSS && skip "could not run with gss" && return
5605 #define OBD_FAIL_OSC_CKSUM_ADLER_ONLY 0x40c
5606 lctl set_param fail_loc=0x40c
5607 remount_client $MOUNT
5608 lctl set_param fail_loc=0
5609 sleep 2 # wait async osc connect to finish
5610 for VALUE in `lctl get_param osc.*osc-[^mM]*.checksum_type`; do
5611 PARAM=`echo ${VALUE[0]} | cut -d "=" -f1`
5612 algo=`lctl get_param -n $PARAM | sed 's/.*\[\(.*\)\].*/\1/g'`
5613 [ "$algo" = "adler" ] || error "algo set to $algo instead of adler"
5615 remount_client $MOUNT
5617 run_test 77j "client only supporting ADLER32"
5619 [ "$ORIG_CSUM" ] && set_checksums $ORIG_CSUM || true
5623 test_78() { # bug 10901
5624 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5625 remote_ost || { skip_env "local OST" && return; }
5628 F78SIZE=$(($(awk '/MemFree:/ { print $2 }' /proc/meminfo) / 1024))
5629 echo "MemFree: $F78SIZE, Max file size: $MAXFREE"
5630 MEMTOTAL=$(($(awk '/MemTotal:/ { print $2 }' /proc/meminfo) / 1024))
5631 echo "MemTotal: $MEMTOTAL"
5632 # reserve 256MB of memory for the kernel and other running processes,
5633 # and then take 1/2 of the remaining memory for the read/write buffers.
5634 if [ $MEMTOTAL -gt 512 ] ;then
5635 MEMTOTAL=$(((MEMTOTAL - 256 ) / 2))
5637 # for those poor memory-starved high-end clusters...
5638 MEMTOTAL=$((MEMTOTAL / 2))
5640 echo "Mem to use for directio: $MEMTOTAL"
5641 [ $F78SIZE -gt $MEMTOTAL ] && F78SIZE=$MEMTOTAL
5642 [ $F78SIZE -gt 512 ] && F78SIZE=512
5643 [ $F78SIZE -gt $((MAXFREE / 1024)) ] && F78SIZE=$((MAXFREE / 1024))
5644 SMALLESTOST=$(lfs df $DIR | grep OST | awk '{ print $4 }' | sort -n |
5646 echo "Smallest OST: $SMALLESTOST"
5647 [ $SMALLESTOST -lt 10240 ] && \
5648 skip "too small OSTSIZE, useless to run large O_DIRECT test" && return 0
5650 [ $F78SIZE -gt $((SMALLESTOST * $OSTCOUNT / 1024 - 80)) ] && \
5651 F78SIZE=$((SMALLESTOST * $OSTCOUNT / 1024 - 80))
5653 [ "$SLOW" = "no" ] && NSEQ=1 && [ $F78SIZE -gt 32 ] && F78SIZE=32
5654 echo "File size: $F78SIZE"
5655 $SETSTRIPE -c $OSTCOUNT $DIR/$tfile || error "setstripe failed"
5656 for i in `seq 1 $NSEQ`
5658 FSIZE=$(($F78SIZE / ($NSEQ - $i + 1)))
5659 echo directIO rdwr round $i of $NSEQ
5660 $DIRECTIO rdwr $DIR/$tfile 0 $FSIZE 1048576||error "rdwr failed"
5665 run_test 78 "handle large O_DIRECT writes correctly ============"
5667 test_79() { # bug 12743
5668 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5669 wait_delete_completed
5671 BKTOTAL=$(calc_osc_kbytes kbytestotal)
5672 BKFREE=$(calc_osc_kbytes kbytesfree)
5673 BKAVAIL=$(calc_osc_kbytes kbytesavail)
5675 STRING=`df -P $MOUNT | tail -n 1 | awk '{print $2","$3","$4}'`
5676 DFTOTAL=`echo $STRING | cut -d, -f1`
5677 DFUSED=`echo $STRING | cut -d, -f2`
5678 DFAVAIL=`echo $STRING | cut -d, -f3`
5679 DFFREE=$(($DFTOTAL - $DFUSED))
5681 ALLOWANCE=$((64 * $OSTCOUNT))
5683 if [ $DFTOTAL -lt $(($BKTOTAL - $ALLOWANCE)) ] ||
5684 [ $DFTOTAL -gt $(($BKTOTAL + $ALLOWANCE)) ] ; then
5685 error "df total($DFTOTAL) mismatch OST total($BKTOTAL)"
5687 if [ $DFFREE -lt $(($BKFREE - $ALLOWANCE)) ] ||
5688 [ $DFFREE -gt $(($BKFREE + $ALLOWANCE)) ] ; then
5689 error "df free($DFFREE) mismatch OST free($BKFREE)"
5691 if [ $DFAVAIL -lt $(($BKAVAIL - $ALLOWANCE)) ] ||
5692 [ $DFAVAIL -gt $(($BKAVAIL + $ALLOWANCE)) ] ; then
5693 error "df avail($DFAVAIL) mismatch OST avail($BKAVAIL)"
5696 run_test 79 "df report consistency check ======================="
5698 test_80() { # bug 10718
5699 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5700 # relax strong synchronous semantics for slow backends like ZFS
5701 local soc="obdfilter.*.sync_on_lock_cancel"
5702 local soc_old=$(do_facet ost1 lctl get_param -n $soc | head -n1)
5704 if [ "$soc_old" != "never" -a "$(facet_fstype ost1)" != "ldiskfs" ]; then
5705 hosts=$(for host in $(seq -f "ost%g" 1 $OSTCOUNT); do
5706 facet_active_host $host; done | sort -u)
5707 do_nodes $hosts lctl set_param $soc=never
5710 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=1M
5712 local BEFORE=`date +%s`
5713 cancel_lru_locks osc
5714 local AFTER=`date +%s`
5715 local DIFF=$((AFTER-BEFORE))
5716 if [ $DIFF -gt 1 ] ; then
5717 error "elapsed for 1M@1T = $DIFF"
5720 [ -n "$hosts" ] && do_nodes $hosts lctl set_param $soc=$soc_old
5724 run_test 80 "Page eviction is equally fast at high offsets too ===="
5726 test_81a() { # LU-456
5727 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5728 remote_ost_nodsh && skip "remote OST with nodsh" && return
5729 # define OBD_FAIL_OST_MAPBLK_ENOSPC 0x228
5730 # MUST OR with the OBD_FAIL_ONCE (0x80000000)
5731 do_facet ost1 lctl set_param fail_loc=0x80000228
5733 # write should trigger a retry and success
5734 $SETSTRIPE -i 0 -c 1 $DIR/$tfile
5735 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
5737 if [ $RC -ne 0 ] ; then
5738 error "write should success, but failed for $RC"
5741 run_test 81a "OST should retry write when get -ENOSPC ==============="
5743 test_81b() { # LU-456
5744 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5745 remote_ost_nodsh && skip "remote OST with nodsh" && return
5746 # define OBD_FAIL_OST_MAPBLK_ENOSPC 0x228
5747 # Don't OR with the OBD_FAIL_ONCE (0x80000000)
5748 do_facet ost1 lctl set_param fail_loc=0x228
5750 # write should retry several times and return -ENOSPC finally
5751 $SETSTRIPE -i 0 -c 1 $DIR/$tfile
5752 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
5755 if [ $RC -ne $ENOSPC ] ; then
5756 error "dd should fail for -ENOSPC, but succeed."
5759 run_test 81b "OST should return -ENOSPC when retry still fails ======="
5761 test_82() { # LU-1031
5762 dd if=/dev/zero of=$DIR/$tfile bs=1M count=10
5766 multiop_bg_pause $DIR/$tfile OG${gid1}_g${gid1}c || return 1
5768 multiop_bg_pause $DIR/$tfile O_G${gid2}r10g${gid2}c || return 2
5770 kill -USR1 $MULTIPID2
5772 if [[ `ps h -o comm -p $MULTIPID2` == "" ]]; then
5773 error "First grouplock does not block second one"
5775 echo "Second grouplock blocks first one"
5777 kill -USR1 $MULTIPID1
5781 run_test 82 "Basic grouplock test ==============================="
5784 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" &&
5786 test_mkdir -p $DIR/d99cvsroot
5787 chown $RUNAS_ID $DIR/d99cvsroot
5788 local oldPWD=$PWD # bug 13584, use $TMP as working dir
5791 $RUNAS cvs -d $DIR/d99cvsroot init || error "cvs init failed"
5794 run_test 99a "cvs init ========================================="
5797 [ -z "$(which cvs 2>/dev/null)" ] &&
5798 skip_env "could not find cvs" && return
5799 [ ! -d $DIR/d99cvsroot ] && test_99a
5801 # some versions of cvs import exit(1) when asked to import links or
5802 # files they can't read. ignore those files.
5803 TOIGNORE=$(find . -type l -printf '-I %f\n' -o \
5804 ! -perm +4 -printf '-I %f\n')
5805 $RUNAS cvs -d $DIR/d99cvsroot import -m "nomesg" $TOIGNORE \
5806 d99reposname vtag rtag
5808 run_test 99b "cvs import ======================================="
5811 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" && return
5812 [ ! -d $DIR/d99cvsroot ] && test_99b
5814 test_mkdir -p $DIR/d99reposname
5815 chown $RUNAS_ID $DIR/d99reposname
5816 $RUNAS cvs -d $DIR/d99cvsroot co d99reposname
5818 run_test 99c "cvs checkout ====================================="
5821 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" && return
5822 [ ! -d $DIR/d99cvsroot ] && test_99c
5823 cd $DIR/d99reposname
5825 $RUNAS cvs add -m 'addmsg' foo99
5827 run_test 99d "cvs add =========================================="
5830 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" && return
5831 [ ! -d $DIR/d99cvsroot ] && test_99c
5832 cd $DIR/d99reposname
5835 run_test 99e "cvs update ======================================="
5838 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" && return
5839 [ ! -d $DIR/d99cvsroot ] && test_99d
5840 cd $DIR/d99reposname
5841 $RUNAS cvs commit -m 'nomsg' foo99
5842 rm -fr $DIR/d99cvsroot
5844 run_test 99f "cvs commit ======================================="
5847 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5848 [ "$NETTYPE" = tcp ] || \
5849 { skip "TCP secure port test, not useful for NETTYPE=$NETTYPE" && \
5852 remote_ost_nodsh && skip "remote OST with nodsh" && return
5853 remote_mds_nodsh && skip "remote MDS with nodsh" && return
5855 { skip "useless for local single node setup" && return; }
5857 netstat -tna | ( rc=1; while read PROT SND RCV LOCAL REMOTE STAT; do
5858 [ "$PROT" != "tcp" ] && continue
5859 RPORT=$(echo $REMOTE | cut -d: -f2)
5860 [ "$RPORT" != "$ACCEPTOR_PORT" ] && continue
5863 LPORT=`echo $LOCAL | cut -d: -f2`
5864 if [ $LPORT -ge 1024 ]; then
5865 echo "bad: $PROT $SND $RCV $LOCAL $REMOTE $STAT"
5867 error_exit "local: $LPORT > 1024, remote: $RPORT"
5870 [ "$rc" = 0 ] || error_exit "privileged port not found" )
5872 run_test 100 "check local port using privileged port ==========="
5874 function get_named_value()
5883 echo $line | sed "s/^$tag[ ]*//"
5890 export CACHE_MAX=$($LCTL get_param -n llite.*.max_cached_mb |
5891 awk '/^max_cached_mb/ { print $2 }')
5894 $LCTL set_param -n llite.*.max_cached_mb $CACHE_MAX
5899 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5900 [ $MDSCOUNT -ge 2 ] && skip "skip now for >= 2 MDTs" && return #LU-4322
5904 local cache_limit=32
5906 $LCTL set_param -n osc.*-osc*.rpc_stats 0
5907 trap cleanup_101a EXIT
5908 $LCTL set_param -n llite.*.read_ahead_stats 0
5909 $LCTL set_param -n llite.*.max_cached_mb $cache_limit
5912 # randomly read 10000 of 64K chunks from file 3x 32MB in size
5914 echo "nreads: $nreads file size: $((cache_limit * 3))MB"
5915 $READS -f $DIR/$tfile -s$((cache_limit * 3192 * 1024)) -b65536 -C -n$nreads -t 180
5918 for s in `$LCTL get_param -n llite.*.read_ahead_stats | \
5919 get_named_value 'read but discarded' | cut -d" " -f1`; do
5920 discard=$(($discard + $s))
5924 if [ $(($discard * 10)) -gt $nreads ] ;then
5925 $LCTL get_param osc.*-osc*.rpc_stats
5926 $LCTL get_param llite.*.read_ahead_stats
5927 error "too many ($discard) discarded pages"
5929 rm -f $DIR/$tfile || true
5931 run_test 101a "check read-ahead for random reads ================"
5934 test_mkdir -p $DIR/$tdir
5935 local STRIPE_SIZE=$1
5936 local FILE_LENGTH=$2
5939 local FILE_SIZE_MB=$((FILE_LENGTH / STRIPE_SIZE))
5941 local list=$(comma_list $(osts_nodes))
5942 set_osd_param $list '' read_cache_enable 0
5943 set_osd_param $list '' writethrough_cache_enable 0
5945 trap cleanup_test101bc EXIT
5946 # prepare the read-ahead file
5947 $SETSTRIPE -S $STRIPE_SIZE -i $STRIPE_OFFSET -c $OSTCOUNT $DIR/$tfile
5949 dd if=/dev/zero of=$DIR/$tfile bs=$STRIPE_SIZE \
5950 count=$FILE_SIZE_MB 2> /dev/null
5954 cleanup_test101bc() {
5959 local list=$(comma_list $(osts_nodes))
5960 set_osd_param $list '' read_cache_enable 1
5961 set_osd_param $list '' writethrough_cache_enable 1
5965 awk 'BEGIN{total=0}; {total+=$1}; END{print total}'
5970 local STRIPE_SIZE=$2
5971 local FILE_LENGTH=$3
5972 local RA_INC=1048576
5973 local STRIDE_LENGTH=$((STRIPE_SIZE/READ_SIZE))
5974 local discard_limit=$((((STRIDE_LENGTH - 1)*3/(STRIDE_LENGTH*OSTCOUNT))* \
5975 (STRIDE_LENGTH*OSTCOUNT - STRIDE_LENGTH)))
5976 DISCARD=`$LCTL get_param -n llite.*.read_ahead_stats | \
5977 get_named_value 'read but discarded' | \
5978 cut -d" " -f1 | calc_total`
5979 if [ $DISCARD -gt $discard_limit ]; then
5980 $LCTL get_param llite.*.read_ahead_stats
5981 error "Too many ($DISCARD) discarded pages with size (${READ_SIZE})"
5983 echo "Read-ahead success for size ${READ_SIZE}"
5988 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5989 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping stride IO stride-ahead test" && return
5990 local STRIPE_SIZE=1048576
5991 local STRIDE_SIZE=$((STRIPE_SIZE*OSTCOUNT))
5992 if [ $SLOW == "yes" ]; then
5993 local FILE_LENGTH=$((STRIDE_SIZE * 64))
5995 local FILE_LENGTH=$((STRIDE_SIZE * 8))
5998 local ITERATION=$((FILE_LENGTH / STRIDE_SIZE))
6000 # prepare the read-ahead file
6001 setup_test101bc $STRIPE_SIZE $FILE_LENGTH
6002 cancel_lru_locks osc
6003 for BIDX in 2 4 8 16 32 64 128 256
6005 local BSIZE=$((BIDX*4096))
6006 local READ_COUNT=$((STRIPE_SIZE/BSIZE))
6007 local STRIDE_LENGTH=$((STRIDE_SIZE/BSIZE))
6008 local OFFSET=$((STRIPE_SIZE/BSIZE*(OSTCOUNT - 1)))
6009 $LCTL set_param -n llite.*.read_ahead_stats 0
6010 $READS -f $DIR/$tfile -l $STRIDE_LENGTH -o $OFFSET \
6011 -s $FILE_LENGTH -b $STRIPE_SIZE -a $READ_COUNT -n $ITERATION
6012 cancel_lru_locks osc
6013 ra_check_101 $BSIZE $STRIPE_SIZE $FILE_LENGTH
6018 run_test 101b "check stride-io mode read-ahead ================="
6021 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6022 local STRIPE_SIZE=1048576
6023 local FILE_LENGTH=$((STRIPE_SIZE*100))
6027 setup_test101bc $STRIPE_SIZE $FILE_LENGTH
6029 cancel_lru_locks osc
6030 $LCTL set_param osc.*.rpc_stats 0
6031 $READS -f $DIR/$tfile -s$FILE_LENGTH -b65536 -n$nreads -t 180
6032 for osc_rpc_stats in $($LCTL get_param -N osc.*.rpc_stats); do
6033 local stats=$($LCTL get_param -n $osc_rpc_stats)
6034 local lines=$(echo "$stats" | awk 'END {print NR;}')
6037 if [ $lines -le 20 ]; then
6040 for size in 1 2 4 8; do
6041 local rpc=$(echo "$stats" |
6042 awk '($1 == "'$size':") {print $2; exit; }')
6044 error "Small $((size*4))k read IO $rpc !"
6046 echo "$osc_rpc_stats check passed!"
6051 run_test 101c "check stripe_size aligned read-ahead ================="
6054 $LCTL get_param -n llite.*.max_read_ahead_mb | head -n 1
6055 $LCTL set_param -n llite.*.max_read_ahead_mb $1 > /dev/null 2>&1
6059 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6060 local file=$DIR/$tfile
6061 local sz_MB=${FILESIZE_101d:-500}
6062 local ra_MB=${READAHEAD_MB:-40}
6064 local free_MB=$(($(df -P $DIR | tail -n 1 | awk '{ print $4 }') / 1024))
6065 [ $free_MB -lt $sz_MB ] &&
6066 skip "Need free space ${sz_MB}M, have ${free_MB}M" && return
6068 echo "Create test file $file size ${sz_MB}M, ${free_MB}M free"
6069 $SETSTRIPE -c -1 $file || error "setstripe failed"
6071 dd if=/dev/zero of=$file bs=1M count=$sz_MB || error "dd failed"
6072 echo Cancel LRU locks on lustre client to flush the client cache
6073 cancel_lru_locks osc
6075 echo Disable read-ahead
6076 local old_READAHEAD=$(set_read_ahead 0)
6078 echo Reading the test file $file with read-ahead disabled
6079 local raOFF=$(do_and_time "dd if=$file of=/dev/null bs=1M count=$sz_MB")
6081 echo Cancel LRU locks on lustre client to flush the client cache
6082 cancel_lru_locks osc
6083 echo Enable read-ahead with ${ra_MB}MB
6084 set_read_ahead $ra_MB
6086 echo Reading the test file $file with read-ahead enabled
6087 local raON=$(do_and_time "dd if=$file of=/dev/null bs=1M count=$sz_MB")
6089 echo "read-ahead disabled time read $raOFF"
6090 echo "read-ahead enabled time read $raON"
6092 set_read_ahead $old_READAHEAD
6094 wait_delete_completed
6096 [ $raOFF -le 1 -o $raON -lt $raOFF ] ||
6097 error "readahead ${raON}s > no-readahead ${raOFF}s ${sz_MB}M"
6099 run_test 101d "file read with and without read-ahead enabled"
6102 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6103 local file=$DIR/$tfile
6104 local size_KB=500 #KB
6108 local free_KB=$(df -P $DIR | tail -n 1 | awk '{ print $4 }')
6109 local need_KB=$((count * size_KB))
6110 [ $free_KB -le $need_KB ] &&
6111 skip_env "Need free space $need_KB, have $free_KB" && return
6113 echo "Creating $count ${size_KB}K test files"
6114 for ((i = 0; i < $count; i++)); do
6115 dd if=/dev/zero of=$file.$i bs=$bsize count=$size_KB 2>/dev/null
6118 echo "Cancel LRU locks on lustre client to flush the client cache"
6119 cancel_lru_locks osc
6121 echo "Reset readahead stats"
6122 $LCTL set_param -n llite.*.read_ahead_stats 0
6124 for ((i = 0; i < $count; i++)); do
6125 dd if=$file.$i of=/dev/null bs=$bsize count=$size_KB 2>/dev/null
6128 local miss=$($LCTL get_param -n llite.*.read_ahead_stats |
6129 get_named_value 'misses' | cut -d" " -f1 | calc_total)
6131 for ((i = 0; i < $count; i++)); do
6132 rm -rf $file.$i 2>/dev/null
6135 #10000 means 20% reads are missing in readahead
6136 [ $miss -lt 10000 ] || error "misses too much for small reads"
6138 run_test 101e "check read-ahead for small read(1k) for small files(500k)"
6140 cleanup_test101f() {
6142 $LCTL set_param -n llite.*.max_read_ahead_whole_mb $MAX_WHOLE_MB
6143 rm -rf $DIR/$tfile 2>/dev/null
6147 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6148 local file=$DIR/$tfile
6151 MAX_WHOLE_MB=$($LCTL get_param -n llite.*.max_read_ahead_whole_mb)
6152 $LCTL set_param -n llite.*.max_read_ahead_whole_mb 2
6153 dd if=/dev/zero of=${file} bs=2097152 count=1 2>/dev/null
6154 trap cleanup_test101f EXIT
6156 echo Cancel LRU locks on lustre client to flush the client cache
6157 cancel_lru_locks osc
6159 echo Reset readahead stats
6160 $LCTL set_param -n llite.*.read_ahead_stats 0
6161 # Random read in a 2M file, because max_read_ahead_whole_mb = 2M,
6162 # readahead should read in 2M file on second read, so only miss
6164 echo Random 4K reads on 2M file for 1000 times
6165 $READS -f $file -s 2097152 -b 4096 -n $nreads
6167 echo checking missing pages
6168 local miss=$($LCTL get_param -n llite.*.read_ahead_stats |
6169 get_named_value 'misses' | cut -d" " -f1 | calc_total)
6171 [ $miss -lt 3 ] || error "misses too much pages!"
6174 run_test 101f "check read-ahead for max_read_ahead_whole_mb"
6177 test_mkdir -p $DIR/$tdir
6178 chown $RUNAS_ID $DIR/$tdir
6181 STRIPE_COUNT=$OSTCOUNT
6182 [ $OSTCOUNT -gt 4 ] && STRIPE_COUNT=4
6184 trap cleanup_test102 EXIT
6186 $1 $SETSTRIPE -S $STRIPE_SIZE -i $STRIPE_OFFSET -c $STRIPE_COUNT $tdir
6188 for num in 1 2 3 4; do
6189 for count in $(seq 1 $STRIPE_COUNT); do
6190 for idx in $(seq 0 $[$STRIPE_COUNT - 1]); do
6191 local size=`expr $STRIPE_SIZE \* $num`
6192 local file=file"$num-$idx-$count"
6193 $1 $SETSTRIPE -S $size -i $idx -c $count $file
6199 $1 $TAR cf $TMP/f102.tar $tdir --xattrs
6205 rm -rf $DIR/d0.sanity/d102
6209 local testfile=$DIR/xattr_testfile
6213 [ "$UID" != 0 ] && skip_env "must run as root" && return
6214 [ -z "$(lctl get_param -n mdc.*-mdc-*.connect_flags | grep xattr)" ] &&
6215 skip_env "must have user_xattr" && return
6217 [ -z "$(which setfattr 2>/dev/null)" ] &&
6218 skip_env "could not find setfattr" && return
6220 echo "set/get xattr..."
6221 setfattr -n trusted.name1 -v value1 $testfile ||
6222 error "setfattr -n trusted.name1=value1 $testfile failed"
6223 getfattr -n trusted.name1 $testfile 2> /dev/null |
6224 grep "trusted.name1=.value1" ||
6225 error "$testfile missing trusted.name1=value1"
6227 setfattr -n user.author1 -v author1 $testfile ||
6228 error "setfattr -n user.author1=author1 $testfile failed"
6229 getfattr -n user.author1 $testfile 2> /dev/null |
6230 grep "user.author1=.author1" ||
6231 error "$testfile missing trusted.author1=author1"
6234 setfattr -n trusted.name2 -v value2 $testfile ||
6235 error "$testfile unable to set trusted.name2"
6236 setfattr -n trusted.name3 -v value3 $testfile ||
6237 error "$testfile unable to set trusted.name3"
6238 [ $(getfattr -d -m "^trusted" $testfile 2> /dev/null |
6239 grep "trusted.name" | wc -l) -eq 3 ] ||
6240 error "$testfile missing 3 trusted.name xattrs"
6242 setfattr -n user.author2 -v author2 $testfile ||
6243 error "$testfile unable to set user.author2"
6244 setfattr -n user.author3 -v author3 $testfile ||
6245 error "$testfile unable to set user.author3"
6246 [ $(getfattr -d -m "^user" $testfile 2> /dev/null |
6247 grep "user.author" | wc -l) -eq 3 ] ||
6248 error "$testfile missing 3 user.author xattrs"
6250 echo "remove xattr..."
6251 setfattr -x trusted.name1 $testfile ||
6252 error "$testfile error deleting trusted.name1"
6253 getfattr -d -m trusted $testfile 2> /dev/null | grep "trusted.name1" &&
6254 error "$testfile did not delete trusted.name1 xattr"
6256 setfattr -x user.author1 $testfile ||
6257 error "$testfile error deleting user.author1"
6258 getfattr -d -m user $testfile 2> /dev/null | grep "user.author1" &&
6259 error "$testfile did not delete trusted.name1 xattr"
6261 # b10667: setting lustre special xattr be silently discarded
6262 echo "set lustre special xattr ..."
6263 setfattr -n "trusted.lov" -v "invalid value" $testfile ||
6264 error "$testfile allowed setting trusted.lov"
6266 run_test 102a "user xattr test =================================="
6269 # b10930: get/set/list trusted.lov xattr
6270 echo "get/set/list trusted.lov xattr ..."
6271 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping 2-stripe test" && return
6272 local testfile=$DIR/$tfile
6273 $SETSTRIPE -S 65536 -i 1 -c $OSTCOUNT $testfile ||
6274 error "setstripe failed"
6275 local STRIPECOUNT=$($GETSTRIPE -c $testfile) ||
6276 error "getstripe failed"
6277 getfattr -d -m "^trusted" $testfile 2> /dev/null | \
6278 grep "trusted.lov" || error "can't get trusted.lov from $testfile"
6280 local testfile2=${testfile}2
6281 local value=`getfattr -n trusted.lov $testfile 2> /dev/null | \
6282 grep "trusted.lov" |sed -e 's/[^=]\+=//'`
6285 setfattr -n trusted.lov -v $value $testfile2
6286 local stripe_size=$($GETSTRIPE -S $testfile2)
6287 local stripe_count=$($GETSTRIPE -c $testfile2)
6288 [ $stripe_size -eq 65536 ] || error "stripe size $stripe_size != 65536"
6289 [ $stripe_count -eq $STRIPECOUNT ] ||
6290 error "stripe count $stripe_count != $STRIPECOUNT"
6293 run_test 102b "getfattr/setfattr for trusted.lov EAs ============"
6296 # b10930: get/set/list lustre.lov xattr
6297 echo "get/set/list lustre.lov xattr ..."
6298 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping 2-stripe test" && return
6299 test_mkdir -p $DIR/$tdir
6300 chown $RUNAS_ID $DIR/$tdir
6301 local testfile=$DIR/$tdir/$tfile
6302 $RUNAS $SETSTRIPE -S 65536 -i 1 -c $OSTCOUNT $testfile ||
6303 error "setstripe failed"
6304 local STRIPECOUNT=$($RUNAS $GETSTRIPE -c $testfile) ||
6305 error "getstripe failed"
6306 $RUNAS getfattr -d -m "^lustre" $testfile 2> /dev/null | \
6307 grep "lustre.lov" || error "can't get lustre.lov from $testfile"
6309 local testfile2=${testfile}2
6310 local value=`getfattr -n lustre.lov $testfile 2> /dev/null | \
6311 grep "lustre.lov" |sed -e 's/[^=]\+=//' `
6313 $RUNAS $MCREATE $testfile2
6314 $RUNAS setfattr -n lustre.lov -v $value $testfile2
6315 local stripe_size=$($RUNAS $GETSTRIPE -S $testfile2)
6316 local stripe_count=$($RUNAS $GETSTRIPE -c $testfile2)
6317 [ $stripe_size -eq 65536 ] || error "stripe size $stripe_size != 65536"
6318 [ $stripe_count -eq $STRIPECOUNT ] ||
6319 error "stripe count $stripe_count != $STRIPECOUNT"
6321 run_test 102c "non-root getfattr/setfattr for lustre.lov EAs ==========="
6323 compare_stripe_info1() {
6324 local stripe_index_all_zero=true
6326 for num in 1 2 3 4; do
6327 for count in $(seq 1 $STRIPE_COUNT); do
6328 for offset in $(seq 0 $[$STRIPE_COUNT - 1]); do
6329 local size=$((STRIPE_SIZE * num))
6330 local file=file"$num-$offset-$count"
6331 stripe_size=$(lfs getstripe -S $PWD/$file)
6332 [ $stripe_size -ne $size ] &&
6333 error "$file: size $stripe_size != $size"
6334 stripe_count=$(lfs getstripe -c $PWD/$file)
6335 # allow fewer stripes to be created, ORI-601
6336 [ $stripe_count -lt $(((3 * count + 3) / 4)) ]&&
6337 error "$file: count $stripe_count != $count"
6338 stripe_index=$(lfs getstripe -i $PWD/$file)
6339 [ $stripe_index -ne 0 ] &&
6340 stripe_index_all_zero=false
6344 $stripe_index_all_zero &&
6345 error "all files are being extracted starting from OST index 0"
6350 [ -n "$(which tar 2>/dev/null)" ] &&
6351 strings $(which tar) | grep -q "lustre" && echo tar
6355 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6356 # b10930: tar test for trusted.lov xattr
6357 TAR=$(find_lustre_tar)
6358 [ -z "$TAR" ] && skip_env "lustre-aware tar is not installed" && return
6359 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping N-stripe test" && return
6361 test_mkdir -p $DIR/d102d
6362 $TAR xf $TMP/f102.tar -C $DIR/d102d --xattrs
6364 compare_stripe_info1
6366 run_test 102d "tar restore stripe info from tarfile,not keep osts ==========="
6369 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6370 # b10930: tar test for trusted.lov xattr
6371 TAR=$(find_lustre_tar)
6372 [ -z "$TAR" ] && skip_env "lustre-aware tar is not installed" && return
6373 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping N-stripe test" && return
6375 test_mkdir -p $DIR/d102f
6377 $TAR cf - --xattrs $tdir | $TAR xf - --xattrs -C $DIR/d102f
6379 compare_stripe_info1
6381 run_test 102f "tar copy files, not keep osts ==========="
6384 local xsize=${1:-1024} # in bytes
6385 local file=$DIR/$tfile
6387 [ -z $(lctl get_param -n mdc.*.connect_flags | grep xattr) ] &&
6388 skip "must have user_xattr" && return 0
6389 [ -z "$(which setfattr 2>/dev/null)" ] &&
6390 skip_env "could not find setfattr" && return 0
6391 [ -z "$(which getfattr 2>/dev/null)" ] &&
6392 skip_env "could not find getfattr" && return 0
6396 local value="$(generate_string $xsize)"
6398 local xbig=trusted.big
6399 log "save $xbig on $file"
6400 setfattr -n $xbig -v $value $file ||
6401 error "saving $xbig on $file failed"
6403 local orig=$(get_xattr_value $xbig $file)
6404 [[ "$orig" != "$value" ]] && error "$xbig different after saving $xbig"
6406 local xsml=trusted.sml
6407 log "save $xsml on $file"
6408 setfattr -n $xsml -v val $file || error "saving $xsml on $file failed"
6410 local new=$(get_xattr_value $xbig $file)
6411 [[ "$new" != "$orig" ]] && error "$xbig different after saving $xsml"
6413 log "grow $xsml on $file"
6414 setfattr -n $xsml -v "$value" $file ||
6415 error "growing $xsml on $file failed"
6417 new=$(get_xattr_value $xbig $file)
6418 [[ "$new" != "$orig" ]] && error "$xbig different after growing $xsml"
6419 log "$xbig still valid after growing $xsml"
6424 test_102h() { # bug 15777
6427 run_test 102h "grow xattr from inside inode to external block"
6430 large_xattr_enabled || { skip "large_xattr disabled" && return; }
6431 grow_xattr $(max_xattr_size)
6433 run_test 102ha "grow xattr from inside inode to external inode"
6435 test_102i() { # bug 17038
6437 ln -s $DIR/$tfile $DIR/${tfile}link
6438 getfattr -n trusted.lov $DIR/$tfile || error "lgetxattr on $DIR/$tfile failed"
6439 getfattr -h -n trusted.lov $DIR/${tfile}link 2>&1 | grep -i "no such attr" || error "error for lgetxattr on $DIR/${tfile}link is not ENODATA"
6440 rm -f $DIR/$tfile $DIR/${tfile}link
6442 run_test 102i "lgetxattr test on symbolic link ============"
6445 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6446 TAR=$(find_lustre_tar)
6447 [ -z "$TAR" ] && skip_env "lustre-aware tar is not installed" && return
6448 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping N-stripe test" && return
6449 setup_test102 "$RUNAS"
6450 test_mkdir -p $DIR/d102j
6451 chown $RUNAS_ID $DIR/d102j
6452 $RUNAS $TAR xf $TMP/f102.tar -C $DIR/d102j --xattrs
6454 compare_stripe_info1 "$RUNAS"
6456 run_test 102j "non-root tar restore stripe info from tarfile, not keep osts ==="
6460 # b22187 just check that does not crash for regular file.
6461 setfattr -n trusted.lov $DIR/$tfile
6462 # b22187 'setfattr -n trusted.lov' should work as remove LOV EA for directories
6463 local test_kdir=$DIR/d102k
6464 test_mkdir $test_kdir
6465 local default_size=`$GETSTRIPE -S $test_kdir`
6466 local default_count=`$GETSTRIPE -c $test_kdir`
6467 local default_offset=`$GETSTRIPE -i $test_kdir`
6468 $SETSTRIPE -S 65536 -i 0 -c $OSTCOUNT $test_kdir ||
6469 error 'dir setstripe failed'
6470 setfattr -n trusted.lov $test_kdir
6471 local stripe_size=`$GETSTRIPE -S $test_kdir`
6472 local stripe_count=`$GETSTRIPE -c $test_kdir`
6473 local stripe_offset=`$GETSTRIPE -i $test_kdir`
6474 [ $stripe_size -eq $default_size ] ||
6475 error "stripe size $stripe_size != $default_size"
6476 [ $stripe_count -eq $default_count ] ||
6477 error "stripe count $stripe_count != $default_count"
6478 [ $stripe_offset -eq $default_offset ] ||
6479 error "stripe offset $stripe_offset != $default_offset"
6480 rm -rf $DIR/$tfile $test_kdir
6482 run_test 102k "setfattr without parameter of value shouldn't cause a crash"
6485 # LU-532 trusted. xattr is invisible to non-root
6486 local testfile=$DIR/$tfile
6490 echo "listxattr as user..."
6491 chown $RUNAS_ID $testfile
6492 $RUNAS getfattr -d -m '.*' $testfile 2>&1 |
6493 grep -q "trusted" &&
6494 error "$testfile trusted xattrs are user visible"
6498 run_test 102l "listxattr size test =================================="
6500 test_102m() { # LU-3403 llite: error of listxattr when buffer is small
6501 local path=$DIR/$tfile
6504 listxattr_size_check $path || error "listattr_size_check $path failed"
6506 run_test 102m "Ensure listxattr fails on small bufffer ========"
6510 getxattr() { # getxattr path name
6511 # Return the base64 encoding of the value of xattr name on path.
6515 # # getfattr --absolute-names --encoding=base64 --name=trusted.lov $path
6517 # trusted.lov=0s0AvRCwEAAAAGAAAAAAAAAAAEAAACAAAAAAAQAAEAA...AAAAAAAAA=
6519 # We print just 0s0AvRCwEAAAAGAAAAAAAAAAAEAAACAAAAAAAQAAEAA...AAAAAAAAA=
6521 getfattr --absolute-names --encoding=base64 --name=$name $path |
6522 awk -F= -v name=$name '$1 == name {
6523 print substr($0, index($0, "=") + 1);
6527 test_102n() { # LU-4101 mdt: protect internal xattrs
6528 local file0=$DIR/$tfile.0
6529 local file1=$DIR/$tfile.1
6530 local xattr0=$TMP/$tfile.0
6531 local xattr1=$TMP/$tfile.1
6535 if [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.5.50) ]
6537 skip "MDT < 2.5.50 allows setxattr on internal trusted xattrs"
6541 rm -rf $file0 $file1 $xattr0 $xattr1
6544 # Get 'before' xattrs of $file1.
6545 getfattr --absolute-names --dump --match=- $file1 > $xattr0
6547 for name in lov lma lmv link fid version som hsm lfsck_namespace; do
6548 # Try to copy xattr from $file0 to $file1.
6549 value=$(getxattr $file0 trusted.$name 2> /dev/null)
6551 setfattr --name=trusted.$name --value="$value" $file1 ||
6552 error "setxattr 'trusted.$name' failed"
6554 # Try to set a garbage xattr.
6555 value=0sVGhlIHF1aWNrIGJyb3duIGZveCBqdW1wcyBvdmVyIGl0c2VsZi4=
6557 setfattr --name=trusted.$name --value="$value" $file1 ||
6558 error "setxattr 'trusted.$name' failed"
6560 # Try to remove the xattr from $file1. We don't care if this
6561 # appears to succeed or fail, we just don't want there to be
6562 # any changes or crashes.
6563 setfattr --remove=$trusted.$name $file1 2> /dev/null
6566 # Get 'after' xattrs of file1.
6567 getfattr --absolute-names --dump --match=- $file1 > $xattr1
6569 if ! diff $xattr0 $xattr1; then
6570 error "before and after xattrs of '$file1' differ"
6573 rm -rf $file0 $file1 $xattr0 $xattr1
6577 run_test 102n "silently ignore setxattr on internal trusted xattrs"
6579 test_102p() { # LU-4703 setxattr did not check ownership
6580 local testfile=$DIR/$tfile
6582 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.5.56) ] &&
6583 skip "MDS needs to be at least 2.5.56" && return
6587 echo "setfacl as user..."
6588 $RUNAS setfacl -m "u:$RUNAS_ID:rwx" $testfile
6589 [ $? -ne 0 ] || error "setfacl by $RUNAS_ID was allowed on $testfile"
6591 echo "setfattr as user..."
6592 setfacl -m "u:$RUNAS_ID:---" $testfile
6593 $RUNAS setfattr -x system.posix_acl_access $testfile
6594 [ $? -ne 0 ] || error "setfattr by $RUNAS_ID was allowed on $testfile"
6596 run_test 102p "check setxattr(2) correctly fails without permission"
6600 $LUSTRE/tests/acl/run $LUSTRE/tests/acl/$1.test
6605 [ "$UID" != 0 ] && skip_env "must run as root" && return
6606 [ -z "$(lctl get_param -n mdc.*-mdc-*.connect_flags | grep acl)" ] &&
6607 skip "must have acl enabled" && return
6608 [ -z "$(which setfacl 2>/dev/null)" ] &&
6609 skip_env "could not find setfacl" && return
6610 $GSS && skip "could not run under gss" && return
6612 declare -a identity_old
6614 for num in $(seq $MDSCOUNT); do
6615 switch_identity $num true || identity_old[$num]=$?
6622 echo "performing cp ..."
6623 run_acl_subtest cp || error "run_acl_subtest cp failed"
6624 echo "performing getfacl-noacl..."
6625 run_acl_subtest getfacl-noacl || error "getfacl-noacl test failed"
6626 echo "performing misc..."
6627 run_acl_subtest misc || error "misc test failed"
6628 echo "performing permissions..."
6629 run_acl_subtest permissions || error "permissions failed"
6630 echo "performing setfacl..."
6631 run_acl_subtest setfacl || error "setfacl test failed"
6633 # inheritance test got from HP
6634 echo "performing inheritance..."
6635 cp $LUSTRE/tests/acl/make-tree . || error "cannot copy make-tree"
6636 chmod +x make-tree || error "chmod +x failed"
6637 run_acl_subtest inheritance || error "inheritance test failed"
6640 echo "LU-974 ignore umask when acl is enabled..."
6641 run_acl_subtest 974 || error "LU-974 umask test failed"
6642 if [ $MDSCOUNT -ge 2 ]; then
6643 run_acl_subtest 974_remote ||
6644 error "LU-974 umask test failed under remote dir"
6647 echo "LU-2561 newly created file is same size as directory..."
6648 if [ $(facet_fstype $SINGLEMDS) != "zfs" ]; then
6649 run_acl_subtest 2561 || error "LU-2561 test failed"
6651 run_acl_subtest 2561_zfs || error "LU-2561 zfs test failed"
6657 for num in $(seq $MDSCOUNT); do
6658 if [ "${identity_old[$num]}" = 1 ]; then
6659 switch_identity $num false || identity_old[$num]=$?
6663 run_test 103 "acl test ========================================="
6666 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6668 lfs df || error "lfs df failed"
6669 lfs df -ih || error "lfs df -ih failed"
6670 lfs df -h $DIR || error "lfs df -h $DIR failed"
6671 lfs df -i $DIR || error "lfs df -i $DIR failed"
6672 lfs df $DIR/$tfile || error "lfs df $DIR/$tfile failed"
6673 lfs df -ih $DIR/$tfile || error "lfs df -ih $DIR/$tfile failed"
6675 local OSC=$(lctl dl | grep OST0000-osc-[^M] | awk '{ print $4 }')
6676 lctl --device %$OSC deactivate
6677 lfs df || error "lfs df with deactivated OSC failed"
6678 lctl --device %$OSC activate
6679 # wait the osc back to normal
6680 wait_osc_import_state client ost FULL
6682 lfs df || error "lfs df with reactivated OSC failed"
6685 run_test 104a "lfs df [-ih] [path] test ========================="
6688 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6689 [ $RUNAS_ID -eq $UID ] &&
6690 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
6692 denied_cnt=$(($($RUNAS $LFS check servers 2>&1 |
6693 grep "Permission denied" | wc -l)))
6694 if [ $denied_cnt -ne 0 ]; then
6695 error "lfs check servers test failed"
6698 run_test 104b "$RUNAS lfs check servers test ===================="
6701 # doesn't work on 2.4 kernels
6703 if [ -n "$(mount | grep "$MOUNT.*flock" | grep -v noflock)" ]; then
6704 flocks_test 1 on -f $DIR/$tfile || error "fail flock on"
6706 flocks_test 1 off -f $DIR/$tfile || error "fail flock off"
6710 run_test 105a "flock when mounted without -o flock test ========"
6714 if [ -n "$(mount | grep "$MOUNT.*flock" | grep -v noflock)" ]; then
6715 flocks_test 1 on -c $DIR/$tfile || error "fail flock on"
6717 flocks_test 1 off -c $DIR/$tfile || error "fail flock off"
6721 run_test 105b "fcntl when mounted without -o flock test ========"
6725 if [ -n "$(mount | grep "$MOUNT.*flock" | grep -v noflock)" ]; then
6726 flocks_test 1 on -l $DIR/$tfile || error "fail flock on"
6728 flocks_test 1 off -l $DIR/$tfile || error "fail flock off"
6732 run_test 105c "lockf when mounted without -o flock test ========"
6734 test_105d() { # bug 15924
6735 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6736 test_mkdir -p $DIR/$tdir
6737 [ -z "$(mount | grep "$MOUNT.*flock" | grep -v noflock)" ] &&
6738 skip "mount w/o flock enabled" && return
6739 #define OBD_FAIL_LDLM_CP_CB_WAIT 0x315
6740 $LCTL set_param fail_loc=0x80000315
6741 flocks_test 2 $DIR/$tdir
6743 run_test 105d "flock race (should not freeze) ========"
6745 test_105e() { # bug 22660 && 22040
6746 [ -z "$(mount | grep "$MOUNT.*flock" | grep -v noflock)" ] &&
6747 skip "mount w/o flock enabled" && return
6749 flocks_test 3 $DIR/$tfile
6751 run_test 105e "Two conflicting flocks from same process ======="
6753 test_106() { #bug 10921
6754 test_mkdir -p $DIR/$tdir
6755 $DIR/$tdir && error "exec $DIR/$tdir succeeded"
6756 chmod 777 $DIR/$tdir || error "chmod $DIR/$tdir failed"
6758 run_test 106 "attempt exec of dir followed by chown of that dir"
6761 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6768 local save_pattern=$(sysctl -n kernel.core_pattern)
6769 local save_uses_pid=$(sysctl -n kernel.core_uses_pid)
6770 sysctl -w kernel.core_pattern=$file
6771 sysctl -w kernel.core_uses_pid=0
6779 kill -s 11 $SLEEPPID
6781 if [ -e $file ]; then
6782 size=`stat -c%s $file`
6783 [ $size -eq 0 ] && error "Fail to create core file $file"
6785 error "Fail to create core file $file"
6788 sysctl -w kernel.core_pattern=$save_pattern
6789 sysctl -w kernel.core_uses_pid=$save_uses_pid
6792 run_test 107 "Coredump on SIG"
6795 test_mkdir -p $DIR/$tdir
6796 test_mkdir $DIR/$tdir/$(str_repeat 'a' 255) ||
6797 error "mkdir with 255 char failed"
6798 test_mkdir $DIR/$tdir/$(str_repeat 'b' 256) &&
6799 error "mkdir with 256 char should fail, but did not"
6800 touch $DIR/$tdir/$(str_repeat 'x' 255) ||
6801 error "create with 255 char failed"
6802 touch $DIR/$tdir/$(str_repeat 'y' 256) &&
6803 error "create with 256 char should fail, but did not"
6808 run_test 110 "filename length checking"
6811 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6812 OSTIO_pre=$(ps -e|grep ll_ost_io|awk '{print $4}'|sort -n|tail -1|\
6814 [ -z "$OSTIO_pre" ] && skip "no OSS threads" && \
6816 echo "Starting with $OSTIO_pre threads"
6819 NUMFREE=`df -i -P $DIR | tail -n 1 | awk '{ print $4 }'`
6820 [ $NUMFREE -lt $NUMTEST ] && NUMTEST=$(($NUMFREE - 1000))
6821 echo "$NUMTEST creates/unlinks"
6822 test_mkdir -p $DIR/$tdir
6823 createmany -o $DIR/$tdir/$tfile $NUMTEST
6824 unlinkmany $DIR/$tdir/$tfile $NUMTEST
6826 OSTIO_post=$(ps -e|grep ll_ost_io|awk '{print $4}'|sort -n|tail -1|\
6829 # don't return an error
6830 [ $OSTIO_post == $OSTIO_pre ] && echo \
6831 "WARNING: No new ll_ost_io threads were created ($OSTIO_pre)" &&
6832 echo "This may be fine, depending on what ran before this test" &&
6833 echo "and how fast this system is." && return
6835 echo "Started with $OSTIO_pre threads, ended with $OSTIO_post"
6837 run_test 115 "verify dynamic thread creation===================="
6840 wait_delete_completed
6841 AVAIL=($(lctl get_param -n osc.*[oO][sS][cC]-[^M]*.kbytesavail))
6842 echo OST kbytes available: ${AVAIL[@]}
6843 MAXI=0; MAXV=${AVAIL[0]}
6844 MINI=0; MINV=${AVAIL[0]}
6845 for ((i = 0; i < ${#AVAIL[@]}; i++)); do
6846 #echo OST $i: ${AVAIL[i]}kb
6847 if [ ${AVAIL[i]} -gt $MAXV ]; then
6848 MAXV=${AVAIL[i]}; MAXI=$i
6850 if [ ${AVAIL[i]} -lt $MINV ]; then
6851 MINV=${AVAIL[i]}; MINI=$i
6854 echo Min free space: OST $MINI: $MINV
6855 echo Max free space: OST $MAXI: $MAXV
6858 test_116a() { # was previously test_116()
6859 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6860 [ "$OSTCOUNT" -lt "2" ] && skip_env "$OSTCOUNT < 2 OSTs" && return
6862 echo -n "Free space priority "
6863 do_facet $SINGLEMDS lctl get_param -n lo*.*-mdtlov.qos_prio_free |
6868 [ $MINV -eq 0 ] && skip "no free space in OST$MINI, skip" && return
6869 [ $MINV -gt 10000000 ] && skip "too much free space in OST$MINI, skip" \
6871 trap simple_cleanup_common EXIT
6874 # Check if we need to generate uneven OSTs
6875 test_mkdir -p $DIR/$tdir/OST${MINI}
6876 local FILL=$(($MINV / 4))
6877 local DIFF=$(($MAXV - $MINV))
6878 local DIFF2=$(($DIFF * 100 / $MINV))
6880 local threshold=$(do_facet $SINGLEMDS \
6881 lctl get_param -n *.*MDT0000-mdtlov.qos_threshold_rr | head -n1)
6882 threshold=${threshold%%%}
6883 echo -n "Check for uneven OSTs: "
6884 echo -n "diff=${DIFF}KB (${DIFF2}%) must be > ${threshold}% ..."
6886 if [ $DIFF2 -gt $threshold ]; then
6888 echo "Don't need to fill OST$MINI"
6890 # generate uneven OSTs. Write 2% over the QOS threshold value
6892 DIFF=$(($threshold - $DIFF2 + 2))
6893 DIFF2=$(( ($MINV * $DIFF)/100 ))
6894 echo "Fill ${DIFF}% remaining space in OST${MINI} with ${DIFF2}KB"
6895 $SETSTRIPE -i $MINI -c 1 $DIR/$tdir/OST${MINI} ||
6896 error "setstripe failed"
6897 DIFF=$(($DIFF2 / 2048))
6899 while [ $i -lt $DIFF ]; do
6901 dd if=/dev/zero of=$DIR/$tdir/OST${MINI}/$tfile-$i \
6902 bs=2M count=1 2>/dev/null
6911 DIFF=$(($MAXV - $MINV))
6912 DIFF2=$(($DIFF * 100 / $MINV))
6913 echo -n "diff=${DIFF}=${DIFF2}% must be > ${threshold}% for QOS mode..."
6914 if [ $DIFF2 -gt $threshold ]; then
6917 echo "failed - QOS mode won't be used"
6918 skip "QOS imbalance criteria not met"
6919 simple_cleanup_common
6923 MINI1=$MINI; MINV1=$MINV
6924 MAXI1=$MAXI; MAXV1=$MAXV
6926 # now fill using QOS
6927 $SETSTRIPE -c 1 $DIR/$tdir
6928 FILL=$(($FILL / 200))
6929 if [ $FILL -gt 600 ]; then
6932 echo "writing $FILL files to QOS-assigned OSTs"
6934 while [ $i -lt $FILL ]; do
6936 dd if=/dev/zero of=$DIR/$tdir/$tfile-$i bs=200k \
6940 echo "wrote $i 200k files"
6944 echo "Note: free space may not be updated, so measurements might be off"
6946 DIFF2=$(($MAXV - $MINV))
6947 echo "free space delta: orig $DIFF final $DIFF2"
6948 [ $DIFF2 -gt $DIFF ] && echo "delta got worse!"
6949 DIFF=$(($MINV1 - ${AVAIL[$MINI1]}))
6950 echo "Wrote ${DIFF}KB to smaller OST $MINI1"
6951 DIFF2=$(($MAXV1 - ${AVAIL[$MAXI1]}))
6952 echo "Wrote ${DIFF2}KB to larger OST $MAXI1"
6953 FILL=$(($DIFF2 * 100 / $DIFF - 100))
6955 echo "Wrote ${FILL}% more data to larger OST $MAXI1"
6957 # Figure out which files were written where
6958 UUID=$(lctl get_param -n lov.${FSNAME}-clilov-*.target_obd |
6959 awk '/'$MINI1': / {print $2; exit}')
6961 MINC=$($GETSTRIPE --ost $UUID $DIR/$tdir | grep $DIR | wc -l)
6962 echo "$MINC files created on smaller OST $MINI1"
6963 UUID=$(lctl get_param -n lov.${FSNAME}-clilov-*.target_obd |
6964 awk '/'$MAXI1': / {print $2; exit}')
6966 MAXC=$($GETSTRIPE --ost $UUID $DIR/$tdir | grep $DIR | wc -l)
6967 echo "$MAXC files created on larger OST $MAXI1"
6968 FILL=$(($MAXC * 100 / $MINC - 100))
6970 echo "Wrote ${FILL}% more files to larger OST $MAXI1"
6971 [ $MAXC -gt $MINC ] ||
6972 error_ignore LU-9 "stripe QOS didn't balance free space"
6973 simple_cleanup_common
6975 run_test 116a "stripe QOS: free space balance ==================="
6977 test_116b() { # LU-2093
6978 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6979 #define OBD_FAIL_MDS_OSC_CREATE_FAIL 0x147
6981 old_rr=$(do_facet $SINGLEMDS lctl get_param -n \
6982 lo*.$FSNAME-MDT0000-mdtlov.qos_threshold_rr | head -1)
6983 do_facet $SINGLEMDS lctl set_param \
6984 lo*.$FSNAME-MDT0000-mdtlov.qos_threshold_rr=0
6986 do_facet $SINGLEMDS lctl set_param fail_loc=0x147
6987 createmany -o $DIR/$tdir/f- 20 || error "can't create"
6988 do_facet $SINGLEMDS lctl set_param fail_loc=0
6990 do_facet $SINGLEMDS lctl set_param \
6991 lo*.$FSNAME-MDT0000-mdtlov.qos_threshold_rr=$old_rr
6993 run_test 116b "QoS shouldn't LBUG if not enough OSTs found on the 2nd pass"
6995 test_117() # bug 10891
6997 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6998 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1
6999 #define OBD_FAIL_OST_SETATTR_CREDITS 0x21e
7000 lctl set_param fail_loc=0x21e
7001 > $DIR/$tfile || error "truncate failed"
7002 lctl set_param fail_loc=0
7003 echo "Truncate succeeded."
7006 run_test 117 "verify osd extend =========="
7008 NO_SLOW_RESENDCOUNT=4
7009 export OLD_RESENDCOUNT=""
7010 set_resend_count () {
7011 local PROC_RESENDCOUNT="osc.${FSNAME}-OST*-osc-*.resend_count"
7012 OLD_RESENDCOUNT=$(lctl get_param -n $PROC_RESENDCOUNT | head -n1)
7013 lctl set_param -n $PROC_RESENDCOUNT $1
7014 echo resend_count is set to $(lctl get_param -n $PROC_RESENDCOUNT)
7017 # for reduce test_118* time (b=14842)
7018 [ "$SLOW" = "no" ] && set_resend_count $NO_SLOW_RESENDCOUNT
7020 # Reset async IO behavior after error case
7022 FILE=$DIR/reset_async
7024 # Ensure all OSCs are cleared
7025 $SETSTRIPE -c -1 $FILE
7026 dd if=/dev/zero of=$FILE bs=64k count=$OSTCOUNT
7031 test_118a() #bug 11710
7033 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7036 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
7037 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
7038 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
7040 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
7041 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
7046 run_test 118a "verify O_SYNC works =========="
7050 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7051 remote_ost_nodsh && skip "remote OST with nodsh" && return
7055 #define OBD_FAIL_OST_ENOENT 0x217
7056 set_nodes_failloc "$(osts_nodes)" 0x217
7057 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
7059 set_nodes_failloc "$(osts_nodes)" 0
7060 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
7061 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
7064 if [[ $RC -eq 0 ]]; then
7065 error "Must return error due to dropped pages, rc=$RC"
7069 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
7070 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
7074 echo "Dirty pages not leaked on ENOENT"
7076 # Due to the above error the OSC will issue all RPCs syncronously
7077 # until a subsequent RPC completes successfully without error.
7078 $MULTIOP $DIR/$tfile Ow4096yc
7083 run_test 118b "Reclaim dirty pages on fatal error =========="
7087 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7089 # for 118c, restore the original resend count, LU-1940
7090 [ "$SLOW" = "no" ] && [ -n "$OLD_RESENDCOUNT" ] &&
7091 set_resend_count $OLD_RESENDCOUNT
7092 remote_ost_nodsh && skip "remote OST with nodsh" && return
7096 #define OBD_FAIL_OST_EROFS 0x216
7097 set_nodes_failloc "$(osts_nodes)" 0x216
7099 # multiop should block due to fsync until pages are written
7100 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
7104 if [[ `ps h -o comm -p $MULTIPID` != "multiop" ]]; then
7105 error "Multiop failed to block on fsync, pid=$MULTIPID"
7108 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
7110 if [[ $WRITEBACK -eq 0 ]]; then
7111 error "No page in writeback, writeback=$WRITEBACK"
7114 set_nodes_failloc "$(osts_nodes)" 0
7117 if [[ $RC -ne 0 ]]; then
7118 error "Multiop fsync failed, rc=$RC"
7121 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
7122 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
7124 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
7125 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
7129 echo "Dirty pages flushed via fsync on EROFS"
7132 run_test 118c "Fsync blocks on EROFS until dirty pages are flushed =========="
7134 # continue to use small resend count to reduce test_118* time (b=14842)
7135 [ "$SLOW" = "no" ] && set_resend_count $NO_SLOW_RESENDCOUNT
7139 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7140 remote_ost_nodsh && skip "remote OST with nodsh" && return
7144 #define OBD_FAIL_OST_BRW_PAUSE_BULK
7145 set_nodes_failloc "$(osts_nodes)" 0x214
7146 # multiop should block due to fsync until pages are written
7147 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
7151 if [[ `ps h -o comm -p $MULTIPID` != "multiop" ]]; then
7152 error "Multiop failed to block on fsync, pid=$MULTIPID"
7155 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
7157 if [[ $WRITEBACK -eq 0 ]]; then
7158 error "No page in writeback, writeback=$WRITEBACK"
7161 wait $MULTIPID || error "Multiop fsync failed, rc=$?"
7162 set_nodes_failloc "$(osts_nodes)" 0
7164 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
7165 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
7167 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
7168 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
7172 echo "Dirty pages gaurenteed flushed via fsync"
7175 run_test 118d "Fsync validation inject a delay of the bulk =========="
7178 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7181 #define OBD_FAIL_OSC_BRW_PREP_REQ2 0x40a
7182 lctl set_param fail_loc=0x8000040a
7184 # Should simulate EINVAL error which is fatal
7185 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
7187 if [[ $RC -eq 0 ]]; then
7188 error "Must return error due to dropped pages, rc=$RC"
7191 lctl set_param fail_loc=0x0
7193 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
7194 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
7195 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
7197 if [[ $LOCKED -ne 0 ]]; then
7198 error "Locked pages remain in cache, locked=$LOCKED"
7201 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
7202 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
7206 echo "No pages locked after fsync"
7211 run_test 118f "Simulate unrecoverable OSC side error =========="
7214 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7217 #define OBD_FAIL_OSC_BRW_PREP_REQ 0x406
7218 lctl set_param fail_loc=0x406
7220 # simulate local -ENOMEM
7221 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
7224 lctl set_param fail_loc=0
7225 if [[ $RC -eq 0 ]]; then
7226 error "Must return error due to dropped pages, rc=$RC"
7229 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
7230 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
7231 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
7233 if [[ $LOCKED -ne 0 ]]; then
7234 error "Locked pages remain in cache, locked=$LOCKED"
7237 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
7238 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
7242 echo "No pages locked after fsync"
7247 run_test 118g "Don't stay in wait if we got local -ENOMEM =========="
7250 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7251 remote_ost_nodsh && skip "remote OST with nodsh" && return
7255 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
7256 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
7262 if [[ $RC -eq 0 ]]; then
7263 error "Must return error due to dropped pages, rc=$RC"
7266 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
7267 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
7268 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
7270 if [[ $LOCKED -ne 0 ]]; then
7271 error "Locked pages remain in cache, locked=$LOCKED"
7274 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
7275 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
7279 echo "No pages locked after fsync"
7283 run_test 118h "Verify timeout in handling recoverables errors =========="
7285 [ "$SLOW" = "no" ] && [ -n "$OLD_RESENDCOUNT" ] && set_resend_count $OLD_RESENDCOUNT
7288 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7289 remote_ost_nodsh && skip "remote OST with nodsh" && return
7293 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
7294 set_nodes_failloc "$(osts_nodes)" 0x20e
7296 # Should simulate ENOMEM error which is recoverable and should be handled by timeout
7297 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
7300 set_nodes_failloc "$(osts_nodes)" 0
7304 if [[ $RC -ne 0 ]]; then
7305 error "got error, but should be not, rc=$RC"
7308 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
7309 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
7310 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
7311 if [[ $LOCKED -ne 0 ]]; then
7312 error "Locked pages remain in cache, locked=$LOCKED"
7315 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
7316 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
7320 echo "No pages locked after fsync"
7324 run_test 118i "Fix error before timeout in recoverable error =========="
7326 [ "$SLOW" = "no" ] && set_resend_count 4
7329 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7330 remote_ost_nodsh && skip "remote OST with nodsh" && return
7334 #define OBD_FAIL_OST_BRW_WRITE_BULK2 0x220
7335 set_nodes_failloc "$(osts_nodes)" 0x220
7337 # return -EIO from OST
7338 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
7340 set_nodes_failloc "$(osts_nodes)" 0x0
7341 if [[ $RC -eq 0 ]]; then
7342 error "Must return error due to dropped pages, rc=$RC"
7345 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
7346 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
7347 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
7348 if [[ $LOCKED -ne 0 ]]; then
7349 error "Locked pages remain in cache, locked=$LOCKED"
7352 # in recoverable error on OST we want resend and stay until it finished
7353 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
7354 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
7358 echo "No pages locked after fsync"
7362 run_test 118j "Simulate unrecoverable OST side error =========="
7366 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7367 remote_ost_nodsh && skip "remote OSTs with nodsh" && return
7369 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
7370 set_nodes_failloc "$(osts_nodes)" 0x20e
7371 test_mkdir -p $DIR/$tdir
7373 for ((i=0;i<10;i++)); do
7374 (dd if=/dev/zero of=$DIR/$tdir/$tfile-$i bs=1M count=10 || \
7375 error "dd to $DIR/$tdir/$tfile-$i failed" )&
7382 set_nodes_failloc "$(osts_nodes)" 0
7385 run_test 118k "bio alloc -ENOMEM and IO TERM handling ========="
7389 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7391 test_mkdir -p $DIR/$tdir
7392 $MULTIOP $DIR/$tdir Dy || error "fsync dir failed"
7395 run_test 118l "fsync dir ========="
7397 test_118m() # LU-3066
7399 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7400 test_mkdir -p $DIR/$tdir
7401 $MULTIOP $DIR/$tdir DY || error "fdatasync dir failed"
7404 run_test 118m "fdatasync dir ========="
7406 [ "$SLOW" = "no" ] && [ -n "$OLD_RESENDCOUNT" ] && set_resend_count $OLD_RESENDCOUNT
7408 test_119a() # bug 11737
7410 BSIZE=$((512 * 1024))
7411 directio write $DIR/$tfile 0 1 $BSIZE
7412 # We ask to read two blocks, which is more than a file size.
7413 # directio will indicate an error when requested and actual
7414 # sizes aren't equeal (a normal situation in this case) and
7415 # print actual read amount.
7416 NOB=`directio read $DIR/$tfile 0 2 $BSIZE | awk '/error/ {print $6}'`
7417 if [ "$NOB" != "$BSIZE" ]; then
7418 error "read $NOB bytes instead of $BSIZE"
7422 run_test 119a "Short directIO read must return actual read amount"
7424 test_119b() # bug 11737
7426 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping 2-stripe test" && return
7428 $SETSTRIPE -c 2 $DIR/$tfile || error "setstripe failed"
7429 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=1 || error "dd failed"
7431 $MULTIOP $DIR/$tfile oO_RDONLY:O_DIRECT:r$((2048 * 1024)) || \
7432 error "direct read failed"
7435 run_test 119b "Sparse directIO read must return actual read amount"
7437 test_119c() # bug 13099
7440 directio write $DIR/$tfile 3 1 $BSIZE || error "direct write failed"
7441 directio readhole $DIR/$tfile 0 2 $BSIZE || error "reading hole failed"
7444 run_test 119c "Testing for direct read hitting hole"
7446 test_119d() # bug 15950
7448 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7449 MAX_RPCS_IN_FLIGHT=`$LCTL get_param -n osc.*OST0000-osc-[^mM]*.max_rpcs_in_flight`
7450 $LCTL set_param -n osc.*OST0000-osc-[^mM]*.max_rpcs_in_flight 1
7452 $SETSTRIPE $DIR/$tfile -i 0 -c 1 || error "setstripe failed"
7453 $DIRECTIO write $DIR/$tfile 0 1 $BSIZE || error "first directio failed"
7454 #define OBD_FAIL_OSC_DIO_PAUSE 0x40d
7455 lctl set_param fail_loc=0x40d
7456 $DIRECTIO write $DIR/$tfile 1 4 $BSIZE &
7459 cat $DIR/$tfile > /dev/null &
7460 lctl set_param fail_loc=0
7463 log "the DIO writes have completed, now wait for the reads (should not block very long)"
7465 [ -n "`ps h -p $pid_reads -o comm`" ] && \
7466 error "the read rpcs have not completed in 2s"
7468 $LCTL set_param -n osc.*OST0000-osc-[^mM]*.max_rpcs_in_flight $MAX_RPCS_IN_FLIGHT
7470 run_test 119d "The DIO path should try to send a new rpc once one is completed"
7473 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7474 test_mkdir -p $DIR/$tdir
7475 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
7476 skip "no early lock cancel on server" && return 0
7478 lru_resize_disable mdc
7479 lru_resize_disable osc
7480 cancel_lru_locks mdc
7481 # asynchronous object destroy at MDT could cause bl ast to client
7482 cancel_lru_locks osc
7484 stat $DIR/$tdir > /dev/null
7485 can1=$(do_facet $SINGLEMDS \
7486 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
7487 awk '/ldlm_cancel/ {print $2}')
7488 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
7489 awk '/ldlm_bl_callback/ {print $2}')
7490 test_mkdir -c1 $DIR/$tdir/d1
7491 can2=$(do_facet $SINGLEMDS \
7492 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
7493 awk '/ldlm_cancel/ {print $2}')
7494 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
7495 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 120a "Early Lock Cancel: mkdir test"
7504 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7505 test_mkdir $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
7510 cancel_lru_locks mdc
7511 stat $DIR/$tdir > /dev/null
7512 can1=$(do_facet $SINGLEMDS \
7513 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
7514 awk '/ldlm_cancel/ {print $2}')
7515 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
7516 awk '/ldlm_bl_callback/ {print $2}')
7518 can2=$(do_facet $SINGLEMDS \
7519 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
7520 awk '/ldlm_cancel/ {print $2}')
7521 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
7522 awk '/ldlm_bl_callback/ {print $2}')
7523 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
7524 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
7525 lru_resize_enable mdc
7526 lru_resize_enable osc
7528 run_test 120b "Early Lock Cancel: create test"
7531 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7532 test_mkdir -c1 $DIR/$tdir
7533 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel)" ] && \
7534 skip "no early lock cancel on server" && return 0
7535 lru_resize_disable mdc
7536 lru_resize_disable osc
7537 test_mkdir -p -c1 $DIR/$tdir/d1
7538 test_mkdir -p -c1 $DIR/$tdir/d2
7539 touch $DIR/$tdir/d1/f1
7540 cancel_lru_locks mdc
7541 stat $DIR/$tdir/d1 $DIR/$tdir/d2 $DIR/$tdir/d1/f1 > /dev/null
7542 can1=$(do_facet $SINGLEMDS \
7543 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
7544 awk '/ldlm_cancel/ {print $2}')
7545 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
7546 awk '/ldlm_bl_callback/ {print $2}')
7547 ln $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2
7548 can2=$(do_facet $SINGLEMDS \
7549 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
7550 awk '/ldlm_cancel/ {print $2}')
7551 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
7552 awk '/ldlm_bl_callback/ {print $2}')
7553 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
7554 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
7555 lru_resize_enable mdc
7556 lru_resize_enable osc
7558 run_test 120c "Early Lock Cancel: link test"
7561 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7562 test_mkdir -p -c1 $DIR/$tdir
7563 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel)" ] && \
7564 skip "no early lock cancel on server" && return 0
7565 lru_resize_disable mdc
7566 lru_resize_disable osc
7568 cancel_lru_locks mdc
7569 stat $DIR/$tdir > /dev/null
7570 can1=$(do_facet $SINGLEMDS \
7571 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
7572 awk '/ldlm_cancel/ {print $2}')
7573 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
7574 awk '/ldlm_bl_callback/ {print $2}')
7575 chmod a+x $DIR/$tdir
7576 can2=$(do_facet $SINGLEMDS \
7577 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
7578 awk '/ldlm_cancel/ {print $2}')
7579 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
7580 awk '/ldlm_bl_callback/ {print $2}')
7581 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
7582 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
7583 lru_resize_enable mdc
7584 lru_resize_enable osc
7586 run_test 120d "Early Lock Cancel: setattr test"
7589 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7590 test_mkdir -p -c1 $DIR/$tdir
7591 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
7592 skip "no early lock cancel on server" && return 0
7593 lru_resize_disable mdc
7594 lru_resize_disable osc
7595 dd if=/dev/zero of=$DIR/$tdir/f1 count=1
7596 cancel_lru_locks mdc
7597 cancel_lru_locks osc
7598 dd if=$DIR/$tdir/f1 of=/dev/null
7599 stat $DIR/$tdir $DIR/$tdir/f1 > /dev/null
7600 can1=$(do_facet $SINGLEMDS \
7601 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
7602 awk '/ldlm_cancel/ {print $2}')
7603 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
7604 awk '/ldlm_bl_callback/ {print $2}')
7605 unlink $DIR/$tdir/f1
7606 can2=$(do_facet $SINGLEMDS \
7607 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
7608 awk '/ldlm_cancel/ {print $2}')
7609 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
7610 awk '/ldlm_bl_callback/ {print $2}')
7611 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
7612 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
7613 lru_resize_enable mdc
7614 lru_resize_enable osc
7616 run_test 120e "Early Lock Cancel: unlink test"
7619 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7620 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
7621 skip "no early lock cancel on server" && return 0
7622 test_mkdir -p -c1 $DIR/$tdir
7623 lru_resize_disable mdc
7624 lru_resize_disable osc
7625 test_mkdir -p -c1 $DIR/$tdir/d1
7626 test_mkdir -p -c1 $DIR/$tdir/d2
7627 dd if=/dev/zero of=$DIR/$tdir/d1/f1 count=1
7628 dd if=/dev/zero of=$DIR/$tdir/d2/f2 count=1
7629 cancel_lru_locks mdc
7630 cancel_lru_locks osc
7631 dd if=$DIR/$tdir/d1/f1 of=/dev/null
7632 dd if=$DIR/$tdir/d2/f2 of=/dev/null
7633 stat $DIR/$tdir/d1 $DIR/$tdir/d2 $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2 > /dev/null
7634 can1=$(do_facet $SINGLEMDS \
7635 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
7636 awk '/ldlm_cancel/ {print $2}')
7637 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
7638 awk '/ldlm_bl_callback/ {print $2}')
7639 mv $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2
7640 can2=$(do_facet $SINGLEMDS \
7641 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
7642 awk '/ldlm_cancel/ {print $2}')
7643 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
7644 awk '/ldlm_bl_callback/ {print $2}')
7645 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
7646 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
7647 lru_resize_enable mdc
7648 lru_resize_enable osc
7650 run_test 120f "Early Lock Cancel: rename test"
7653 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7654 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
7655 skip "no early lock cancel on server" && return 0
7656 lru_resize_disable mdc
7657 lru_resize_disable osc
7659 echo create $count files
7660 test_mkdir -p $DIR/$tdir
7661 cancel_lru_locks mdc
7662 cancel_lru_locks osc
7665 can0=$(do_facet $SINGLEMDS \
7666 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
7667 awk '/ldlm_cancel/ {print $2}')
7668 blk0=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
7669 awk '/ldlm_bl_callback/ {print $2}')
7670 createmany -o $DIR/$tdir/f $count
7672 can1=$(do_facet $SINGLEMDS \
7673 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
7674 awk '/ldlm_cancel/ {print $2}')
7675 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
7676 awk '/ldlm_bl_callback/ {print $2}')
7678 echo total: $((can1-can0)) cancels, $((blk1-blk0)) blockings
7679 echo rm $count files
7682 can2=$(do_facet $SINGLEMDS \
7683 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
7684 awk '/ldlm_cancel/ {print $2}')
7685 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
7686 awk '/ldlm_bl_callback/ {print $2}')
7688 echo total: $count removes in $((t2-t1))
7689 echo total: $((can2-can1)) cancels, $((blk2-blk1)) blockings
7691 # wait for commitment of removal
7692 lru_resize_enable mdc
7693 lru_resize_enable osc
7695 run_test 120g "Early Lock Cancel: performance test"
7697 test_121() { #bug #10589
7698 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7700 writes=$(LANG=C dd if=/dev/zero of=$DIR/$tfile count=1 2>&1 | awk -F '+' '/out$/ {print $1}')
7701 #define OBD_FAIL_LDLM_CANCEL_RACE 0x310
7702 lctl set_param fail_loc=0x310
7703 cancel_lru_locks osc > /dev/null
7704 reads=$(LANG=C dd if=$DIR/$tfile of=/dev/null 2>&1 | awk -F '+' '/in$/ {print $1}')
7705 lctl set_param fail_loc=0
7706 [ "$reads" -eq "$writes" ] || error "read" $reads "blocks, must be" $writes
7708 run_test 121 "read cancel race ========="
7710 test_123a() { # was test 123, statahead(bug 11401)
7711 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7713 if [ -z "$(grep "processor.*: 1" /proc/cpuinfo)" ]; then
7714 log "testing on UP system. Performance may be not as good as expected."
7719 test_mkdir -p $DIR/$tdir
7720 NUMFREE=`df -i -P $DIR | tail -n 1 | awk '{ print $4 }'`
7721 [ $NUMFREE -gt 100000 ] && NUMFREE=100000 || NUMFREE=$((NUMFREE-1000))
7723 for ((i=100, j=0; i<=$NUMFREE; j=$i, i=$((i * MULT)) )); do
7724 createmany -o $DIR/$tdir/$tfile $j $((i - j))
7726 max=`lctl get_param -n llite.*.statahead_max | head -n 1`
7727 lctl set_param -n llite.*.statahead_max 0
7728 lctl get_param llite.*.statahead_max
7729 cancel_lru_locks mdc
7730 cancel_lru_locks osc
7732 time ls -l $DIR/$tdir | wc -l
7734 delta=$((etime - stime))
7735 log "ls $i files without statahead: $delta sec"
7736 lctl set_param llite.*.statahead_max=$max
7738 swrong=`lctl get_param -n llite.*.statahead_stats | grep "statahead wrong:" | awk '{print $3}'`
7739 lctl get_param -n llite.*.statahead_max | grep '[0-9]'
7740 cancel_lru_locks mdc
7741 cancel_lru_locks osc
7743 time ls -l $DIR/$tdir | wc -l
7745 delta_sa=$((etime - stime))
7746 log "ls $i files with statahead: $delta_sa sec"
7747 lctl get_param -n llite.*.statahead_stats
7748 ewrong=`lctl get_param -n llite.*.statahead_stats | grep "statahead wrong:" | awk '{print $3}'`
7750 [ $swrong -lt $ewrong ] && log "statahead was stopped, maybe too many locks held!"
7751 [ $delta -eq 0 -o $delta_sa -eq 0 ] && continue
7753 if [ $((delta_sa * 100)) -gt $((delta * 105)) -a $delta_sa -gt $((delta + 2)) ]; then
7754 max=`lctl get_param -n llite.*.statahead_max | head -n 1`
7755 lctl set_param -n llite.*.statahead_max 0
7756 lctl get_param llite.*.statahead_max
7757 cancel_lru_locks mdc
7758 cancel_lru_locks osc
7760 time ls -l $DIR/$tdir | wc -l
7762 delta=$((etime - stime))
7763 log "ls $i files again without statahead: $delta sec"
7764 lctl set_param llite.*.statahead_max=$max
7765 if [ $((delta_sa * 100)) -gt $((delta * 105)) -a $delta_sa -gt $((delta + 2)) ]; then
7766 if [ $SLOWOK -eq 0 ]; then
7767 error "ls $i files is slower with statahead!"
7769 log "ls $i files is slower with statahead!"
7775 [ $delta -gt 20 ] && break
7776 [ $delta -gt 8 ] && MULT=$((50 / delta))
7777 [ "$SLOW" = "no" -a $delta -gt 5 ] && break
7785 delta=$((etime - stime))
7786 log "rm -r $DIR/$tdir/: $delta seconds"
7788 lctl get_param -n llite.*.statahead_stats
7790 run_test 123a "verify statahead work"
7792 test_123b () { # statahead(bug 15027)
7793 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7794 test_mkdir -p $DIR/$tdir
7795 createmany -o $DIR/$tdir/$tfile-%d 1000
7797 cancel_lru_locks mdc
7798 cancel_lru_locks osc
7800 #define OBD_FAIL_MDC_GETATTR_ENQUEUE 0x803
7801 lctl set_param fail_loc=0x80000803
7802 ls -lR $DIR/$tdir > /dev/null
7804 lctl set_param fail_loc=0x0
7805 lctl get_param -n llite.*.statahead_stats
7810 run_test 123b "not panic with network error in statahead enqueue (bug 15027)"
7813 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7814 [ -z "`lctl get_param -n mdc.*.connect_flags | grep lru_resize`" ] && \
7815 skip "no lru resize on server" && return 0
7817 test_mkdir -p $DIR/$tdir || error "failed to create $DIR/$tdir"
7819 log "create $NR files at $DIR/$tdir"
7820 createmany -o $DIR/$tdir/f $NR ||
7821 error "failed to create $NR files in $DIR/$tdir"
7823 cancel_lru_locks mdc
7824 ls -l $DIR/$tdir > /dev/null
7828 for VALUE in `lctl get_param ldlm.namespaces.*mdc-*.lru_size`; do
7829 local PARAM=`echo ${VALUE[0]} | cut -d "=" -f1`
7830 LRU_SIZE=$(lctl get_param -n $PARAM)
7831 if [ $LRU_SIZE -gt $(default_lru_size) ]; then
7832 NSDIR=$(echo $PARAM | cut -d "." -f1-3)
7834 log "NS=$(basename $NSDIR)"
7839 if [ -z "$NSDIR" -o $LRU_SIZE -lt $(default_lru_size) ]; then
7840 skip "Not enough cached locks created!"
7847 # We know that lru resize allows one client to hold $LIMIT locks
7848 # for 10h. After that locks begin to be killed by client.
7850 local LIMIT=`lctl get_param -n $NSDIR.pool.limit`
7853 # Make LVF so higher that sleeping for $SLEEP is enough to _start_
7854 # killing locks. Some time was spent for creating locks. This means
7855 # that up to the moment of sleep finish we must have killed some of
7856 # them (10-100 locks). This depends on how fast ther were created.
7857 # Many of them were touched in almost the same moment and thus will
7858 # be killed in groups.
7859 local LVF=$(($MAX_HRS * 60 * 60 / $SLEEP * $LIMIT / $LRU_SIZE))
7861 # Use $LRU_SIZE_B here to take into account real number of locks
7862 # created in the case of CMD, LRU_SIZE_B != $NR in most of cases
7863 local LRU_SIZE_B=$LRU_SIZE
7865 local OLD_LVF=`lctl get_param -n $NSDIR.pool.lock_volume_factor`
7866 log "OLD_LVF=$OLD_LVF"
7867 lctl set_param -n $NSDIR.pool.lock_volume_factor $LVF
7869 # Let's make sure that we really have some margin. Client checks
7870 # cached locks every 10 sec.
7872 log "Sleep ${SLEEP} sec"
7874 while ((SEC<$SLEEP)); do
7878 LRU_SIZE=`lctl get_param -n $NSDIR/lru_size`
7882 lctl set_param -n $NSDIR.pool.lock_volume_factor $OLD_LVF
7883 local LRU_SIZE_A=`lctl get_param -n $NSDIR.lru_size`
7885 [ $LRU_SIZE_B -gt $LRU_SIZE_A ] || {
7886 error "No locks dropped in ${SLEEP}s. LRU size: $LRU_SIZE_A"
7887 unlinkmany $DIR/$tdir/f $NR
7891 log "Dropped "$((LRU_SIZE_B-LRU_SIZE_A))" locks in ${SLEEP}s"
7892 log "unlink $NR files at $DIR/$tdir"
7893 unlinkmany $DIR/$tdir/f $NR
7895 run_test 124a "lru resize ======================================="
7897 get_max_pool_limit()
7899 local limit=`lctl get_param -n ldlm.namespaces.*-MDT0000-mdc-*.pool.limit`
7902 if test $l -gt $max; then
7910 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7911 [ -z "`lctl get_param -n mdc.*.connect_flags | grep lru_resize`" ] && \
7912 skip "no lru resize on server" && return 0
7914 LIMIT=`get_max_pool_limit`
7916 NR=$(($(default_lru_size)*20))
7917 if [ $NR -gt $LIMIT ]; then
7918 log "Limit lock number by $LIMIT locks"
7921 lru_resize_disable mdc
7922 test_mkdir -p $DIR/$tdir/disable_lru_resize ||
7923 error "failed to create $DIR/$tdir/disable_lru_resize"
7925 createmany -o $DIR/$tdir/disable_lru_resize/f $NR
7926 log "doing ls -la $DIR/$tdir/disable_lru_resize 3 times"
7927 cancel_lru_locks mdc
7930 ls -la $DIR/$tdir/disable_lru_resize > /dev/null &
7933 ls -la $DIR/$tdir/disable_lru_resize > /dev/null &
7936 ls -la $DIR/$tdir/disable_lru_resize > /dev/null &
7940 nolruresize_delta=$((etime-stime))
7941 log "ls -la time: $nolruresize_delta seconds"
7942 log "lru_size = $(lctl get_param -n ldlm.namespaces.*mdc*.lru_size)"
7943 unlinkmany $DIR/$tdir/disable_lru_resize/f $NR
7945 lru_resize_enable mdc
7946 test_mkdir -p $DIR/$tdir/enable_lru_resize ||
7947 error "failed to create $DIR/$tdir/enable_lru_resize"
7949 createmany -o $DIR/$tdir/enable_lru_resize/f $NR
7950 log "doing ls -la $DIR/$tdir/enable_lru_resize 3 times"
7951 cancel_lru_locks mdc
7954 ls -la $DIR/$tdir/enable_lru_resize > /dev/null &
7957 ls -la $DIR/$tdir/enable_lru_resize > /dev/null &
7960 ls -la $DIR/$tdir/enable_lru_resize > /dev/null &
7964 lruresize_delta=$((etime-stime))
7965 log "ls -la time: $lruresize_delta seconds"
7966 log "lru_size = $(lctl get_param -n ldlm.namespaces.*mdc*.lru_size)"
7968 if [ $lruresize_delta -gt $nolruresize_delta ]; then
7969 log "ls -la is $(((lruresize_delta - $nolruresize_delta) * 100 / $nolruresize_delta))% slower with lru resize enabled"
7970 elif [ $nolruresize_delta -gt $lruresize_delta ]; then
7971 log "ls -la is $(((nolruresize_delta - $lruresize_delta) * 100 / $nolruresize_delta))% faster with lru resize enabled"
7973 log "lru resize performs the same with no lru resize"
7975 unlinkmany $DIR/$tdir/enable_lru_resize/f $NR
7977 run_test 124b "lru resize (performance test) ======================="
7979 test_125() { # 13358
7980 [ -z "$(lctl get_param -n llite.*.client_type | grep local)" ] && skip "must run as local client" && return
7981 [ -z "$(lctl get_param -n mdc.*-mdc-*.connect_flags | grep acl)" ] && skip "must have acl enabled" && return
7982 test_mkdir -p $DIR/d125 || error "mkdir failed"
7983 $SETSTRIPE -S 65536 -c -1 $DIR/d125 || error "setstripe failed"
7984 setfacl -R -m u:bin:rwx $DIR/d125 || error "setfacl $DIR/d125 failed"
7985 ls -ld $DIR/d125 || error "cannot access $DIR/d125"
7987 run_test 125 "don't return EPROTO when a dir has a non-default striping and ACLs"
7989 test_126() { # bug 12829/13455
7990 [ -z "$(lctl get_param -n llite.*.client_type | grep local)" ] && skip "must run as local client" && return
7991 [ "$UID" != 0 ] && skip_env "skipping $TESTNAME (must run as root)" && return
7992 $GSS && skip "must run as gss disabled" && return
7994 $RUNAS -u 0 -g 1 touch $DIR/$tfile || error "touch failed"
7995 gid=`ls -n $DIR/$tfile | awk '{print $4}'`
7997 [ $gid -eq "1" ] || error "gid is set to" $gid "instead of 1"
7999 run_test 126 "check that the fsgid provided by the client is taken into account"
8001 test_127a() { # bug 15521
8002 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8003 $SETSTRIPE -i 0 -c 1 $DIR/$tfile || error "setstripe failed"
8004 $LCTL set_param osc.*.stats=0
8005 FSIZE=$((2048 * 1024))
8006 dd if=/dev/zero of=$DIR/$tfile bs=$FSIZE count=1
8007 cancel_lru_locks osc
8008 dd if=$DIR/$tfile of=/dev/null bs=$FSIZE
8010 $LCTL get_param osc.*0000-osc-*.stats | grep samples > $DIR/${tfile}.tmp
8011 while read NAME COUNT SAMP UNIT MIN MAX SUM SUMSQ; do
8012 echo "got $COUNT $NAME"
8013 [ ! $MIN ] && error "Missing min value for $NAME proc entry"
8014 eval $NAME=$COUNT || error "Wrong proc format"
8017 read_bytes|write_bytes)
8018 [ $MIN -lt 4096 ] && error "min is too small: $MIN"
8019 [ $MIN -gt $FSIZE ] && error "min is too big: $MIN"
8020 [ $MAX -lt 4096 ] && error "max is too small: $MAX"
8021 [ $MAX -gt $FSIZE ] && error "max is too big: $MAX"
8022 [ $SUM -ne $FSIZE ] && error "sum is wrong: $SUM"
8023 [ $SUMSQ -lt $(((FSIZE /4096) * (4096 * 4096))) ] &&
8024 error "sumsquare is too small: $SUMSQ"
8025 [ $SUMSQ -gt $((FSIZE * FSIZE)) ] &&
8026 error "sumsquare is too big: $SUMSQ"
8030 done < $DIR/${tfile}.tmp
8032 #check that we actually got some stats
8033 [ "$read_bytes" ] || error "Missing read_bytes stats"
8034 [ "$write_bytes" ] || error "Missing write_bytes stats"
8035 [ "$read_bytes" != 0 ] || error "no read done"
8036 [ "$write_bytes" != 0 ] || error "no write done"
8038 run_test 127a "verify the client stats are sane"
8040 test_127b() { # bug LU-333
8041 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8042 $LCTL set_param llite.*.stats=0
8043 FSIZE=65536 # sized fixed to match PAGE_SIZE for most clients
8044 # perform 2 reads and writes so MAX is different from SUM.
8045 dd if=/dev/zero of=$DIR/$tfile bs=$FSIZE count=1
8046 dd if=/dev/zero of=$DIR/$tfile bs=$FSIZE count=1
8047 cancel_lru_locks osc
8048 dd if=$DIR/$tfile of=/dev/null bs=$FSIZE count=1
8049 dd if=$DIR/$tfile of=/dev/null bs=$FSIZE count=1
8051 $LCTL get_param llite.*.stats | grep samples > $TMP/${tfile}.tmp
8052 while read NAME COUNT SAMP UNIT MIN MAX SUM SUMSQ; do
8053 echo "got $COUNT $NAME"
8054 eval $NAME=$COUNT || error "Wrong proc format"
8058 [ $COUNT -ne 2 ] && error "count is not 2: $COUNT"
8059 [ $MIN -ne $FSIZE ] && error "min is not $FSIZE: $MIN"
8060 [ $MAX -ne $FSIZE ] && error "max is incorrect: $MAX"
8061 [ $SUM -ne $((FSIZE * 2)) ] && error "sum is wrong: $SUM"
8064 [ $COUNT -ne 2 ] && error "count is not 2: $COUNT"
8065 [ $MIN -ne $FSIZE ] && error "min is not $FSIZE: $MIN"
8066 [ $MAX -ne $FSIZE ] && error "max is incorrect: $MAX"
8067 [ $SUM -ne $((FSIZE * 2)) ] && error "sum is wrong: $SUM"
8071 done < $TMP/${tfile}.tmp
8073 #check that we actually got some stats
8074 [ "$read_bytes" ] || error "Missing read_bytes stats"
8075 [ "$write_bytes" ] || error "Missing write_bytes stats"
8076 [ "$read_bytes" != 0 ] || error "no read done"
8077 [ "$write_bytes" != 0 ] || error "no write done"
8079 run_test 127b "verify the llite client stats are sane"
8081 test_128() { # bug 15212
8083 $LFS 2>&1 <<-EOF | tee $TMP/$tfile.log
8088 result=$(grep error $TMP/$tfile.log)
8090 [ -z "$result" ] || error "consecutive find's under interactive lfs failed"
8092 run_test 128 "interactive lfs for 2 consecutive find's"
8099 local LDPROC=/proc/fs/ldiskfs
8100 local facets=$(get_facets MDS)
8102 for facet in ${facets//,/ }; do
8103 canondev=$(ldiskfs_canon \
8104 *.$(convert_facet2label $facet).mntdev $facet)
8105 do_facet $facet "test -e $LDPROC/$canondev/max_dir_size" ||
8106 LDPROC=/sys/fs/ldiskfs
8107 do_facet $facet "echo $1 >$LDPROC/$canondev/max_dir_size"
8112 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8113 if [ "$(facet_fstype $SINGLEMDS)" != ldiskfs ]; then
8114 skip "Only applicable to ldiskfs-based MDTs"
8117 remote_mds_nodsh && skip "remote MDS with nodsh" && return
8122 test_mkdir -p $DIR/$tdir
8124 # block size of mds1
8125 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
8126 local MDSBLOCKSIZE=$($LCTL get_param -n mdc.*MDT0000*.blocksize)
8127 local MAX=$((MDSBLOCKSIZE * 3))
8129 local I=$(stat -c%s "$DIR/$tdir")
8131 local STRIPE_COUNT=1
8132 [ $MDSCOUNT -ge 2 ] && STRIPE_COUNT=$($LFS getdirstripe -c $DIR/$tdir)
8133 MAX=$((MAX*STRIPE_COUNT))
8134 while [ ! $I -gt $MAX ]; do
8135 $MULTIOP $DIR/$tdir/$J Oc
8137 #check two errors ENOSPC for new version of ext4 max_dir_size patch
8138 #mainline kernel commit df981d03eeff7971ac7e6ff37000bfa702327ef1
8139 #and EFBIG for previous versions
8140 if [ $rc -eq $EFBIG -o $rc -eq $ENOSPC ]; then
8142 echo "return code $rc received as expected"
8143 multiop $DIR/$tdir/$J Oc ||
8144 error_exit "multiop failed w/o dir size limit"
8146 I=$(stat -c%s "$DIR/$tdir")
8148 if [ $(lustre_version_code $SINGLEMDS) -lt \
8149 $(version_code 2.4.51) ]
8151 [ $I -eq $MAX ] && return 0
8153 [ $I -gt $MAX ] && return 0
8155 error_exit "current dir size $I, previous limit $MAX"
8156 elif [ $rc -ne 0 ]; then
8158 error_exit "return code $rc received instead of expected " \
8159 "$EFBIG or $ENOSPC, files in dir $I"
8162 I=$(stat -c%s "$DIR/$tdir")
8166 error "exceeded dir size limit $MAX($MDSCOUNT) : $I bytes"
8168 run_test 129 "test directory size limit ========================"
8177 local filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
8178 [ -n "$filefrag_op" ] && skip_env "filefrag does not support FIEMAP" &&
8181 trap cleanup_130 EXIT RETURN
8183 local fm_file=$DIR/$tfile
8184 $SETSTRIPE -S 65536 -c 1 $fm_file || error "setstripe on $fm_file"
8185 dd if=/dev/zero of=$fm_file bs=65536 count=1 ||
8186 error "dd failed for $fm_file"
8188 # LU-1795: test filefrag/FIEMAP once, even if unsupported
8189 filefrag -ves $fm_file
8191 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
8192 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
8193 [ $RC != 0 ] && error "filefrag $fm_file failed"
8195 filefrag_op=$(filefrag -ve $fm_file | grep -A 100 "ext:" |
8196 grep -v "ext:" | grep -v "found")
8197 lun=$($GETSTRIPE -i $fm_file)
8199 start_blk=`echo $filefrag_op | cut -d: -f2 | cut -d. -f1`
8202 for line in $filefrag_op
8204 frag_lun=`echo $line | cut -d: -f5`
8205 ext_len=`echo $line | cut -d: -f4`
8206 if (( $frag_lun != $lun )); then
8208 error "FIEMAP on 1-stripe file($fm_file) failed"
8211 (( tot_len += ext_len ))
8214 if (( lun != frag_lun || start_blk != 0 || tot_len != 64 )); then
8216 error "FIEMAP on 1-stripe file($fm_file) failed;"
8222 echo "FIEMAP on single striped file succeeded"
8224 run_test 130a "FIEMAP (1-stripe file)"
8227 [ "$OSTCOUNT" -lt "2" ] &&
8228 skip_env "skipping FIEMAP on 2-stripe file test" && return
8230 [ "$OSTCOUNT" -ge "10" ] &&
8231 skip_env "skipping FIEMAP with >= 10 OSTs" && return
8233 local filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
8234 [ -n "$filefrag_op" ] && skip_env "filefrag does not support FIEMAP" &&
8237 trap cleanup_130 EXIT RETURN
8239 local fm_file=$DIR/$tfile
8240 $SETSTRIPE -S 65536 -c 2 $fm_file || error "setstripe on $fm_file"
8241 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
8242 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
8244 dd if=/dev/zero of=$fm_file bs=1M count=2 ||
8245 error "dd failed on $fm_file"
8247 filefrag -ves $fm_file || error "filefrag $fm_file failed"
8248 filefrag_op=$(filefrag -ve $fm_file | grep -A 100 "ext:" |
8249 grep -v "ext:" | grep -v "found")
8251 last_lun=$(echo $filefrag_op | cut -d: -f5)
8256 for line in $filefrag_op
8258 frag_lun=`echo $line | cut -d: -f5`
8259 ext_len=`echo $line | cut -d: -f4`
8260 if (( $frag_lun != $last_lun )); then
8261 if (( tot_len != 1024 )); then
8263 error "FIEMAP on $fm_file failed; returned len $tot_len for OST $last_lun instead of 256"
8270 (( tot_len += ext_len ))
8273 if (( num_luns != 2 || tot_len != 1024 )); then
8275 error "FIEMAP on $fm_file failed; returned wrong number of luns or wrong len for OST $last_lun"
8281 echo "FIEMAP on 2-stripe file succeeded"
8283 run_test 130b "FIEMAP (2-stripe file)"
8286 [ "$OSTCOUNT" -lt "2" ] &&
8287 skip_env "skipping FIEMAP on 2-stripe file" && return
8289 [ "$OSTCOUNT" -ge "10" ] &&
8290 skip_env "skipping FIEMAP with >= 10 OSTs" && return
8292 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
8293 [ -n "$filefrag_op" ] && skip "filefrag does not support FIEMAP" &&
8296 trap cleanup_130 EXIT RETURN
8298 local fm_file=$DIR/$tfile
8299 $SETSTRIPE -S 65536 -c 2 $fm_file || error "setstripe on $fm_file"
8300 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
8301 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
8303 dd if=/dev/zero of=$fm_file seek=1 bs=1M count=1 || error "dd failed on $fm_file"
8305 filefrag -ves $fm_file || error "filefrag $fm_file failed"
8306 filefrag_op=`filefrag -ve $fm_file | grep -A 100 "ext:" | grep -v "ext:" | grep -v "found"`
8308 last_lun=`echo $filefrag_op | cut -d: -f5`
8313 for line in $filefrag_op
8315 frag_lun=`echo $line | cut -d: -f5`
8316 ext_len=`echo $line | cut -d: -f4`
8317 if (( $frag_lun != $last_lun )); then
8318 logical=`echo $line | cut -d: -f2 | cut -d. -f1`
8319 if (( logical != 512 )); then
8321 error "FIEMAP on $fm_file failed; returned logical start for lun $logical instead of 512"
8324 if (( tot_len != 512 )); then
8326 error "FIEMAP on $fm_file failed; returned len $tot_len for OST $last_lun instead of 1024"
8333 (( tot_len += ext_len ))
8336 if (( num_luns != 2 || tot_len != 512 )); then
8338 error "FIEMAP on $fm_file failed; returned wrong number of luns or wrong len for OST $last_lun"
8344 echo "FIEMAP on 2-stripe file with hole succeeded"
8346 run_test 130c "FIEMAP (2-stripe file with hole)"
8349 [ "$OSTCOUNT" -lt "3" ] && skip_env "skipping FIEMAP on N-stripe file test" && return
8351 [ "$OSTCOUNT" -ge "10" ] &&
8352 skip_env "skipping FIEMAP with >= 10 OSTs" && return
8354 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
8355 [ -n "$filefrag_op" ] && skip "filefrag does not support FIEMAP" && return
8357 trap cleanup_130 EXIT RETURN
8359 local fm_file=$DIR/$tfile
8360 $SETSTRIPE -S 65536 -c $OSTCOUNT $fm_file||error "setstripe on $fm_file"
8361 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
8362 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
8364 local actual_stripecnt=$($GETSTRIPE -c $fm_file)
8365 dd if=/dev/zero of=$fm_file bs=1M count=$actual_stripecnt ||
8366 error "dd failed on $fm_file"
8368 filefrag -ves $fm_file || error "filefrag $fm_file failed"
8369 filefrag_op=`filefrag -ve $fm_file | grep -A 100 "ext:" |
8370 grep -v "ext:" | grep -v "found"`
8372 last_lun=`echo $filefrag_op | cut -d: -f5`
8377 for line in $filefrag_op
8379 frag_lun=`echo $line | cut -d: -f5`
8380 ext_len=`echo $line | cut -d: -f4`
8381 if (( $frag_lun != $last_lun )); then
8382 if (( tot_len != 1024 )); then
8384 error "FIEMAP on $fm_file failed; returned len $tot_len for OST $last_lun instead of 1024"
8391 (( tot_len += ext_len ))
8394 if (( num_luns != actual_stripecnt || tot_len != 1024 )); then
8396 error "FIEMAP on $fm_file failed; returned wrong number of luns or wrong len for OST $last_lun"
8402 echo "FIEMAP on N-stripe file succeeded"
8404 run_test 130d "FIEMAP (N-stripe file)"
8407 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping continuation FIEMAP test" && return
8409 [ "$OSTCOUNT" -ge "10" ] &&
8410 skip_env "skipping FIEMAP with >= 10 OSTs" && return
8412 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
8413 [ -n "$filefrag_op" ] && skip "filefrag does not support FIEMAP" && return
8415 trap cleanup_130 EXIT RETURN
8417 local fm_file=$DIR/$tfile
8418 $SETSTRIPE -S 131072 -c 2 $fm_file || error "setstripe on $fm_file"
8419 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
8420 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
8423 EXPECTED_LEN=$(( (NUM_BLKS / 2) * 64 ))
8424 for ((i = 0; i < $NUM_BLKS; i++))
8426 dd if=/dev/zero of=$fm_file count=1 bs=64k seek=$((2*$i)) conv=notrunc > /dev/null 2>&1
8429 filefrag -ves $fm_file || error "filefrag $fm_file failed"
8430 filefrag_op=`filefrag -ve $fm_file | grep -A 12000 "ext:" | grep -v "ext:" | grep -v "found"`
8432 last_lun=`echo $filefrag_op | cut -d: -f5`
8437 for line in $filefrag_op
8439 frag_lun=`echo $line | cut -d: -f5`
8440 ext_len=`echo $line | cut -d: -f4`
8441 if (( $frag_lun != $last_lun )); then
8442 if (( tot_len != $EXPECTED_LEN )); then
8444 error "FIEMAP on $fm_file failed; returned len $tot_len for OST $last_lun instead of $EXPECTED_LEN"
8451 (( tot_len += ext_len ))
8454 if (( num_luns != 2 || tot_len != $EXPECTED_LEN )); then
8456 error "FIEMAP on $fm_file failed; returned wrong number of luns or wrong len for OST $last_lun"
8462 echo "FIEMAP with continuation calls succeeded"
8464 run_test 130e "FIEMAP (test continuation FIEMAP calls)"
8466 # Test for writev/readv
8468 rwv -f $DIR/$tfile -w -n 3 524288 1048576 1572864 || \
8469 error "writev test failed"
8470 rwv -f $DIR/$tfile -r -v -n 2 1572864 1048576 || \
8471 error "readv failed"
8474 run_test 131a "test iov's crossing stripe boundary for writev/readv"
8477 rwv -f $DIR/$tfile -w -a -n 3 524288 1048576 1572864 || \
8478 error "append writev test failed"
8479 rwv -f $DIR/$tfile -w -a -n 2 1572864 1048576 || \
8480 error "append writev test failed"
8483 run_test 131b "test append writev"
8486 rwv -f $DIR/$tfile -w -d -n 1 1048576 || return 0
8489 run_test 131c "test read/write on file w/o objects"
8492 rwv -f $DIR/$tfile -w -n 1 1572864
8493 NOB=`rwv -f $DIR/$tfile -r -n 3 524288 524288 1048576 | awk '/error/ {print $6}'`
8494 if [ "$NOB" != 1572864 ]; then
8495 error "Short read filed: read $NOB bytes instead of 1572864"
8499 run_test 131d "test short read"
8502 rwv -f $DIR/$tfile -w -s 1048576 -n 1 1048576
8503 rwv -f $DIR/$tfile -r -z -s 0 -n 1 524288 || \
8504 error "read hitting hole failed"
8507 run_test 131e "test read hitting hole"
8512 for node in $(osts_nodes); do
8513 gl=$(do_node $node "$LCTL get_param -n ost.OSS.ost.stats" | awk '/'$token'/ {print $2}' | head -n 1)
8514 [ x$gl = x"" ] && gl=0
8515 gl_sum=$((gl_sum + gl))
8525 if [ x$som = x"enabled" ]; then
8526 [ $((gl2 - gl1)) -gt 0 ] && error "no glimpse RPC is expected"
8527 MOUNTOPT=`echo $MOUNTOPT | sed 's/som_preview//g'`
8528 do_facet mgs "$LCTL conf_param $FSNAME.mdt.som=disabled"
8530 [ $((gl2 - gl1)) -gt 0 ] || error "some glimpse RPC is expected"
8531 MOUNTOPT="$MOUNTOPT,som_preview"
8532 do_facet mgs "$LCTL conf_param $FSNAME.mdt.som=enabled"
8535 # do remount to make new mount-conf parameters actual
8542 test_132() { #1028, SOM
8543 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8544 remote_mds_nodsh && skip "remote MDS with nodsh" && return
8545 local num=$(get_mds_dir $DIR)
8546 local mymds=mds${num}
8547 local MOUNTOPT_SAVE=$MOUNTOPT
8549 dd if=/dev/zero of=$DIR/$tfile count=1 2>/dev/null
8550 cancel_lru_locks osc
8552 som1=$(do_facet $mymds "$LCTL get_param mdt.*.som" | awk -F= ' {print $2}' | head -n 1)
8554 gl1=$(get_ost_param "ldlm_glimpse_enqueue")
8555 stat $DIR/$tfile >/dev/null
8556 gl2=$(get_ost_param "ldlm_glimpse_enqueue")
8557 echo "====> SOM is "$som1", "$((gl2 - gl1))" glimpse RPC occured"
8559 som_mode_switch $som1 $gl1 $gl2
8561 dd if=/dev/zero of=$DIR/$tfile count=1 2>/dev/null
8562 cancel_lru_locks osc
8564 som2=$(do_facet $mymds "$LCTL get_param mdt.*.som" | awk -F= ' {print $2}' | head -n 1)
8565 if [ $som1 == $som2 ]; then
8566 error "som is still "$som2
8567 if [ x$som2 = x"enabled" ]; then
8574 gl1=$(get_ost_param "ldlm_glimpse_enqueue")
8575 stat $DIR/$tfile >/dev/null
8576 gl2=$(get_ost_param "ldlm_glimpse_enqueue")
8577 echo "====> SOM is "$som2", "$((gl2 - gl1))" glimpse RPC occured"
8578 som_mode_switch $som2 $gl1 $gl2
8579 MOUNTOPT=$MOUNTOPT_SAVE
8581 run_test 132 "som avoids glimpse rpc"
8587 $SINGLEMDS) res=`do_facet $SINGLEMDS $LCTL get_param mdt.$FSNAME-MDT0000.md_stats | grep "$2"`
8589 ost) res=`do_facet ost1 $LCTL get_param obdfilter.$FSNAME-OST0000.stats | grep "$2"`
8591 *) error "Wrong argument $1" ;;
8594 count=`echo $res | awk '{print $2}'`
8595 [ -z "$res" ] && error "The counter for $2 on $1 was not incremented"
8596 # if the argument $3 is zero, it means any stat increment is ok.
8597 if [ $3 -gt 0 ] ; then
8598 [ $count -ne $3 ] && error "The $2 counter on $1 is wrong - expected $3"
8603 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8604 remote_ost_nodsh && skip "remote OST with nodsh" && return
8605 remote_mds_nodsh && skip "remote MDS with nodsh" && return
8607 do_facet $SINGLEMDS $LCTL list_param mdt.*.rename_stats ||
8608 { skip "MDS doesn't support rename stats"; return; }
8609 local testdir=$DIR/${tdir}/stats_testdir
8610 mkdir -p $DIR/${tdir}
8613 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
8614 do_facet ost1 $LCTL set_param obdfilter.*.stats=clear
8616 # verify mdt stats first.
8617 mkdir ${testdir} || error "mkdir failed"
8618 check_stats $SINGLEMDS "mkdir" 1
8619 touch ${testdir}/${tfile} || "touch failed"
8620 check_stats $SINGLEMDS "open" 1
8621 check_stats $SINGLEMDS "close" 1
8622 mknod ${testdir}/${tfile}-pipe p || "mknod failed"
8623 check_stats $SINGLEMDS "mknod" 1
8624 rm -f ${testdir}/${tfile}-pipe || "pipe remove failed"
8625 check_stats $SINGLEMDS "unlink" 1
8626 rm -f ${testdir}/${tfile} || error "file remove failed"
8627 check_stats $SINGLEMDS "unlink" 2
8629 # remove working dir and check mdt stats again.
8630 rmdir ${testdir} || error "rmdir failed"
8631 check_stats $SINGLEMDS "rmdir" 1
8633 local testdir1=$DIR/${tdir}/stats_testdir1
8635 mkdir -p ${testdir1}
8636 touch ${testdir1}/test1
8637 mv ${testdir1}/test1 ${testdir} || error "file crossdir rename"
8638 check_stats $SINGLEMDS "crossdir_rename" 1
8640 mv ${testdir}/test1 ${testdir}/test0 || error "file samedir rename"
8641 check_stats $SINGLEMDS "samedir_rename" 1
8645 run_test 133a "Verifying MDT stats ========================================"
8648 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8649 remote_ost_nodsh && skip "remote OST with nodsh" && return
8650 remote_mds_nodsh && skip "remote MDS with nodsh" && return
8651 local testdir=$DIR/${tdir}/stats_testdir
8652 mkdir -p ${testdir} || error "mkdir failed"
8653 touch ${testdir}/${tfile} || "touch failed"
8654 cancel_lru_locks mdc
8657 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
8658 do_facet ost1 $LCTL set_param obdfilter.*.stats=clear
8660 # extra mdt stats verification.
8661 chmod 444 ${testdir}/${tfile} || error "chmod failed"
8662 check_stats $SINGLEMDS "setattr" 1
8663 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
8664 if [ $(lustre_version_code $SINGLEMDS) -ne $(version_code 2.2.0) ]
8666 ls -l ${testdir}/${tfile} > /dev/null|| error "ls failed"
8667 check_stats $SINGLEMDS "getattr" 1
8669 $LFS df || error "lfs failed"
8670 check_stats $SINGLEMDS "statfs" 1
8674 run_test 133b "Verifying extra MDT stats =================================="
8677 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8678 remote_ost_nodsh && skip "remote OST with nodsh" && return
8679 remote_mds_nodsh && skip "remote MDS with nodsh" && return
8680 local testdir=$DIR/${tdir}/stats_testdir
8681 test_mkdir -p ${testdir} || error "mkdir failed"
8683 # verify obdfilter stats.
8684 $SETSTRIPE -c 1 -i 0 ${testdir}/${tfile}
8686 cancel_lru_locks osc
8687 wait_delete_completed
8690 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
8691 do_facet ost1 $LCTL set_param obdfilter.*.stats=clear
8693 dd if=/dev/zero of=${testdir}/${tfile} conv=notrunc bs=512k count=1 || error "dd failed"
8695 cancel_lru_locks osc
8696 check_stats ost "write" 1
8698 dd if=${testdir}/${tfile} of=/dev/null bs=1k count=1 || error "dd failed"
8699 check_stats ost "read" 1
8701 > ${testdir}/${tfile} || error "truncate failed"
8702 check_stats ost "punch" 1
8704 rm -f ${testdir}/${tfile} || error "file remove failed"
8705 wait_delete_completed
8706 check_stats ost "destroy" 1
8710 run_test 133c "Verifying OST stats ========================================"
8717 while [ $value -ge 2 ]; do
8722 if [ $orig -gt $order ]; then
8730 local size=('K' 'M' 'G' 'T');
8732 local size_string=$value
8734 while [ $value -ge 1024 ]; do
8735 if [ $i -gt 3 ]; then
8736 #T is the biggest unit we get here, if that is bigger,
8738 size_string=${value}T
8741 value=$((value >> 10))
8742 if [ $value -lt 1024 ]; then
8743 size_string=${value}${size[$i]}
8754 local context=${2:-.}
8755 local sample=$(do_facet $SINGLEMDS $LCTL get_param mdt.*.rename_stats |
8757 awk '/ '${size}'/ {print $4}' | sed -e "s/,//g")
8762 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8763 remote_ost_nodsh && skip "remote OST with nodsh" && return
8764 remote_mds_nodsh && skip "remote MDS with nodsh" && return
8765 do_facet $SINGLEMDS $LCTL list_param mdt.*.rename_stats ||
8766 { skip "MDS doesn't support rename stats"; return; }
8768 local testdir1=$DIR/${tdir}/stats_testdir1
8769 local testdir2=$DIR/${tdir}/stats_testdir2
8771 do_facet $SINGLEMDS $LCTL set_param mdt.*.rename_stats=clear
8773 mkdir -p ${testdir1} || error "mkdir failed"
8774 mkdir -p ${testdir2} || error "mkdir failed"
8776 createmany -o $testdir1/test 512 || error "createmany failed"
8778 # check samedir rename size
8779 mv ${testdir1}/test0 ${testdir1}/test_0
8781 local testdir1_size=$(ls -l $DIR/${tdir} |
8782 awk '/stats_testdir1/ {print $5}')
8783 local testdir2_size=$(ls -l $DIR/${tdir} |
8784 awk '/stats_testdir2/ {print $5}')
8786 testdir1_size=$(order_2 $testdir1_size)
8787 testdir2_size=$(order_2 $testdir2_size)
8789 testdir1_size=$(size_in_KMGT $testdir1_size)
8790 testdir2_size=$(size_in_KMGT $testdir2_size)
8792 echo "source rename dir size: ${testdir1_size}"
8793 echo "target rename dir size: ${testdir2_size}"
8795 local cmd="do_facet $SINGLEMDS $LCTL get_param mdt.*.rename_stats"
8796 eval $cmd || error "$cmd failed"
8797 local samedir=$($cmd | grep 'same_dir')
8798 local same_sample=$(get_rename_size $testdir1_size)
8799 [ -z "$samedir" ] && error "samedir_rename_size count error"
8800 [ "$same_sample" -eq 1 ] || error "samedir_rename_size error $same_sample"
8801 echo "Check same dir rename stats success"
8803 do_facet $SINGLEMDS $LCTL set_param mdt.*.rename_stats=clear
8805 # check crossdir rename size
8806 mv ${testdir1}/test_0 ${testdir2}/test_0
8808 testdir1_size=$(ls -l $DIR/${tdir} |
8809 awk '/stats_testdir1/ {print $5}')
8810 testdir2_size=$(ls -l $DIR/${tdir} |
8811 awk '/stats_testdir2/ {print $5}')
8813 testdir1_size=$(order_2 $testdir1_size)
8814 testdir2_size=$(order_2 $testdir2_size)
8816 testdir1_size=$(size_in_KMGT $testdir1_size)
8817 testdir2_size=$(size_in_KMGT $testdir2_size)
8819 echo "source rename dir size: ${testdir1_size}"
8820 echo "target rename dir size: ${testdir2_size}"
8822 eval $cmd || error "$cmd failed"
8823 local crossdir=$($cmd | grep 'crossdir')
8824 local src_sample=$(get_rename_size $testdir1_size crossdir_src)
8825 local tgt_sample=$(get_rename_size $testdir2_size crossdir_tgt)
8826 [ -z "$crossdir" ] && error "crossdir_rename_size count error"
8827 [ "$src_sample" -eq 1 ] || error "crossdir_rename_size error $src_sample"
8828 [ "$tgt_sample" -eq 1 ] || error "crossdir_rename_size error $tgt_sample"
8829 echo "Check cross dir rename stats success"
8832 run_test 133d "Verifying rename_stats ========================================"
8835 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8836 local testdir=$DIR/${tdir}/stats_testdir
8837 local ctr f0 f1 bs=32768 count=42 sum
8839 remote_ost_nodsh && skip "remote OST with nodsh" && return
8840 mkdir -p ${testdir} || error "mkdir failed"
8842 $SETSTRIPE -c 1 -i 0 ${testdir}/${tfile}
8844 for ctr in {write,read}_bytes; do
8846 cancel_lru_locks osc
8848 do_facet ost1 $LCTL set_param -n \
8849 "obdfilter.*.exports.clear=clear"
8851 if [ $ctr = write_bytes ]; then
8853 f1=${testdir}/${tfile}
8855 f0=${testdir}/${tfile}
8859 dd if=$f0 of=$f1 conv=notrunc bs=$bs count=$count || \
8862 cancel_lru_locks osc
8864 sum=$(do_facet ost1 $LCTL get_param \
8865 "obdfilter.*.exports.*.stats" | \
8868 $1 == ctr { sum += $7 }
8871 if ((sum != bs * count)); then
8872 error "Bad $ctr sum, expected $((bs * count)), got $sum"
8878 run_test 133e "Verifying OST {read,write}_bytes nid stats ================="
8881 local proc_dirs="/proc/fs/lustre/ /proc/sys/lnet/ /proc/sys/lustre/"
8884 # First without trusting modes.
8886 -exec cat '{}' \; &> /dev/null
8888 # Second verifying readability.
8892 -exec cat '{}' \; > /dev/null ||
8893 error "proc file read failed"
8895 for facet in $SINGLEMDS ost1; do
8896 do_facet $facet find $proc_dirs \
8897 -not -name req_history \
8898 -exec cat '{}' \\\; &> /dev/null
8900 do_facet $facet find $proc_dirs \
8901 -not -name req_history \
8904 -exec cat '{}' \\\; > /dev/null ||
8905 error "proc file read failed"
8908 run_test 133f "Check for LBUGs/Oopses/unreadable files in /proc"
8910 test_140() { #bug-17379
8911 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8912 test_mkdir -p $DIR/$tdir || error "Creating dir $DIR/$tdir"
8913 cd $DIR/$tdir || error "Changing to $DIR/$tdir"
8914 cp /usr/bin/stat . || error "Copying stat to $DIR/$tdir"
8916 # VFS limits max symlink depth to 5(4KSTACK) or 7(8KSTACK) or 8
8917 # For kernel > 3.5, bellow only tests consecutive symlink (MAX 40)
8919 while i=`expr $i + 1`; do
8920 test_mkdir -p $i || error "Creating dir $i"
8921 cd $i || error "Changing to $i"
8922 ln -s ../stat stat || error "Creating stat symlink"
8923 # Read the symlink until ELOOP present,
8924 # not LBUGing the system is considered success,
8925 # we didn't overrun the stack.
8926 $OPENFILE -f O_RDONLY stat >/dev/null 2>&1; ret=$?
8928 if [ $ret -eq 40 ]; then
8931 error "Open stat symlink"
8937 echo "The symlink depth = $i"
8938 [ $i -eq 5 -o $i -eq 7 -o $i -eq 8 -o $i -eq 40 ] ||
8939 error "Invalid symlink depth"
8941 # Test recursive symlink
8942 ln -s symlink_self symlink_self
8943 $OPENFILE -f O_RDONLY symlink_self >/dev/null 2>&1; ret=$?
8944 echo "open symlink_self returns $ret"
8945 [ $ret -eq 40 ] || error "recursive symlink doesn't return -ELOOP"
8947 run_test 140 "Check reasonable stack depth (shouldn't LBUG) ===="
8950 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8951 local TF="$TMP/$tfile"
8953 dd if=/dev/urandom of=$TF bs=6096 count=1 || error "dd failed"
8955 cancel_lru_locks osc
8956 cmp $TF $DIR/$tfile || error "$TMP/$tfile $DIR/$tfile differ"
8957 remount_client $MOUNT
8959 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (remount)"
8962 $TRUNCATE $DIR/$tfile 6000
8963 cancel_lru_locks osc
8964 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (truncate1)"
8967 echo "12345" >>$DIR/$tfile
8968 cancel_lru_locks osc
8969 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (append1)"
8972 echo "12345" >>$DIR/$tfile
8973 cancel_lru_locks osc
8974 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (append2)"
8979 run_test 150 "truncate/append tests"
8981 #LU-2902 roc_hit was not able to read all values from lproc
8982 function roc_hit_init() {
8983 local list=$(comma_list $(osts_nodes))
8984 local dir=$DIR/$tdir-check
8985 local file=$dir/file
8991 #use setstripe to do a write to every ost
8992 for i in $(seq 0 $((OSTCOUNT-1))); do
8993 $SETSTRIPE -c 1 -i $i $dir || error "$SETSTRIPE $file failed"
8994 dd if=/dev/urandom of=$file bs=4k count=4 2>&1 > /dev/null
8995 idx=$(printf %04x $i)
8996 BEFORE=$(get_osd_param $list *OST*$idx stats |
8997 awk '$1 == "cache_access" {sum += $2} END { print sum }')
8998 if [ -z "$BEFORE" ]; then
9002 cancel_lru_locks osc
9003 cat $file >/dev/null
9005 AFTER=$(get_osd_param $list *OST*$idx stats |
9006 awk '$1 == "cache_access" {sum += $2} END { print sum }')
9008 echo BEFORE:$BEFORE AFTER:$AFTER
9009 if ! let "AFTER - BEFORE == 4"; then
9011 error "roc_hit is not safe to use"
9019 function roc_hit() {
9020 local list=$(comma_list $(osts_nodes))
9021 echo $(get_osd_param $list '' stats |
9022 awk '$1 == "cache_hit" {sum += $2} END { print sum }')
9025 function set_cache() {
9028 if [ "$2" == "off" ]; then
9031 local list=$(comma_list $(osts_nodes))
9032 set_osd_param $list '' $1_cache_enable $on
9034 cancel_lru_locks osc
9038 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9039 remote_ost_nodsh && skip "remote OST with nodsh" && return
9042 local list=$(comma_list $(osts_nodes))
9044 # check whether obdfilter is cache capable at all
9045 if ! get_osd_param $list '' read_cache_enable >/dev/null; then
9046 echo "not cache-capable obdfilter"
9050 # check cache is enabled on all obdfilters
9051 if get_osd_param $list '' read_cache_enable | grep 0; then
9052 echo "oss cache is disabled"
9056 set_osd_param $list '' writethrough_cache_enable 1
9058 # check write cache is enabled on all obdfilters
9059 if get_osd_param $list '' writethrough_cache_enable | grep 0; then
9060 echo "oss write cache is NOT enabled"
9066 #define OBD_FAIL_OBD_NO_LRU 0x609
9067 do_nodes $list $LCTL set_param fail_loc=0x609
9069 # pages should be in the case right after write
9070 dd if=/dev/urandom of=$DIR/$tfile bs=4k count=$CPAGES ||
9073 local BEFORE=$(roc_hit)
9074 cancel_lru_locks osc
9075 cat $DIR/$tfile >/dev/null
9076 local AFTER=$(roc_hit)
9078 do_nodes $list $LCTL set_param fail_loc=0
9080 if ! let "AFTER - BEFORE == CPAGES"; then
9081 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
9084 # the following read invalidates the cache
9085 cancel_lru_locks osc
9086 set_osd_param $list '' read_cache_enable 0
9087 cat $DIR/$tfile >/dev/null
9089 # now data shouldn't be found in the cache
9091 cancel_lru_locks osc
9092 cat $DIR/$tfile >/dev/null
9094 if let "AFTER - BEFORE != 0"; then
9095 error "IN CACHE: before: $BEFORE, after: $AFTER"
9098 set_osd_param $list '' read_cache_enable 1
9101 run_test 151 "test cache on oss and controls ==============================="
9104 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9105 local TF="$TMP/$tfile"
9107 # simulate ENOMEM during write
9108 #define OBD_FAIL_OST_NOMEM 0x226
9109 lctl set_param fail_loc=0x80000226
9110 dd if=/dev/urandom of=$TF bs=6096 count=1 || error "dd failed"
9112 sync || error "sync failed"
9113 lctl set_param fail_loc=0
9115 # discard client's cache
9116 cancel_lru_locks osc
9118 # simulate ENOMEM during read
9119 lctl set_param fail_loc=0x80000226
9120 cmp $TF $DIR/$tfile || error "cmp failed"
9121 lctl set_param fail_loc=0
9125 run_test 152 "test read/write with enomem ============================"
9128 $MULTIOP $DIR/$tfile Ow4096Ycu || error "multiop failed"
9130 run_test 153 "test if fdatasync does not crash ======================="
9132 dot_lustre_fid_permission_check() {
9134 local ffid=$MOUNT/.lustre/fid/$fid
9137 echo "stat fid $fid"
9138 stat $ffid > /dev/null || error "stat $ffid failed."
9139 echo "touch fid $fid"
9140 touch $ffid || error "touch $ffid failed."
9141 echo "write to fid $fid"
9142 cat /etc/hosts > $ffid || error "write $ffid failed."
9143 echo "read fid $fid"
9144 diff /etc/hosts $ffid || error "read $ffid failed."
9145 echo "append write to fid $fid"
9146 cat /etc/hosts >> $ffid || error "append write $ffid failed."
9147 echo "rename fid $fid"
9148 mv $ffid $test_dir/$tfile.1 &&
9149 error "rename $ffid to $tfile.1 should fail."
9150 touch $test_dir/$tfile.1
9151 mv $test_dir/$tfile.1 $ffid &&
9152 error "rename $tfile.1 to $ffid should fail."
9153 rm -f $test_dir/$tfile.1
9154 echo "truncate fid $fid"
9155 $TRUNCATE $ffid 777 || error "truncate $ffid failed."
9156 if [ $MDSCOUNT -lt 2 ]; then #FIXME when cross-MDT hard link is working
9157 echo "link fid $fid"
9158 ln -f $ffid $test_dir/tfile.lnk || error "link $ffid failed."
9160 if [ -n $(lctl get_param -n mdc.*-mdc-*.connect_flags | grep acl) ]; then
9161 echo "setfacl fid $fid"
9162 setfacl -R -m u:bin:rwx $ffid || error "setfacl $ffid failed."
9163 echo "getfacl fid $fid"
9164 getfacl $ffid >/dev/null || error "getfacl $ffid failed."
9166 echo "unlink fid $fid"
9167 unlink $MOUNT/.lustre/fid/$fid && error "unlink $ffid should fail."
9168 echo "mknod fid $fid"
9169 mknod $ffid c 1 3 && error "mknod $ffid should fail."
9171 fid=[0xf00000400:0x1:0x0]
9172 ffid=$MOUNT/.lustre/fid/$fid
9174 echo "stat non-exist fid $fid"
9175 stat $ffid > /dev/null && error "stat non-exist $ffid should fail."
9176 echo "write to non-exist fid $fid"
9177 cat /etc/hosts > $ffid && error "write non-exist $ffid should fail."
9178 echo "link new fid $fid"
9179 ln $test_dir/$tfile $ffid && error "link $ffid should fail."
9181 mkdir -p $test_dir/$tdir
9182 touch $test_dir/$tdir/$tfile
9183 fid=$($LFS path2fid $test_dir/$tdir)
9186 error "error: could not get fid for $test_dir/$dir/$tfile."
9188 ffid=$MOUNT/.lustre/fid/$fid
9191 ls $ffid > /dev/null || error "ls $ffid failed."
9192 echo "touch $fid/$tfile.1"
9193 touch $ffid/$tfile.1 || error "touch $ffid/$tfile.1 failed."
9195 echo "touch $MOUNT/.lustre/fid/$tfile"
9196 touch $MOUNT/.lustre/fid/$tfile && \
9197 error "touch $MOUNT/.lustre/fid/$tfile should fail."
9199 echo "setxattr to $MOUNT/.lustre/fid"
9200 setfattr -n trusted.name1 -v value1 $MOUNT/.lustre/fid
9202 echo "listxattr for $MOUNT/.lustre/fid"
9203 getfattr -d -m "^trusted" $MOUNT/.lustre/fid
9205 echo "delxattr from $MOUNT/.lustre/fid"
9206 setfattr -x trusted.name1 $MOUNT/.lustre/fid
9208 echo "touch invalid fid: $MOUNT/.lustre/fid/[0x200000400:0x2:0x3]"
9209 touch $MOUNT/.lustre/fid/[0x200000400:0x2:0x3] &&
9210 error "touch invalid fid should fail."
9212 echo "touch non-normal fid: $MOUNT/.lustre/fid/[0x1:0x2:0x0]"
9213 touch $MOUNT/.lustre/fid/[0x1:0x2:0x0] &&
9214 error "touch non-normal fid should fail."
9216 echo "rename $tdir to $MOUNT/.lustre/fid"
9217 mrename $test_dir/$tdir $MOUNT/.lustre/fid &&
9218 error "rename to $MOUNT/.lustre/fid should fail."
9220 if [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.3.51) ]
9222 local old_obf_mode=$(stat --format="%a" $DIR/.lustre/fid)
9223 local new_obf_mode=777
9225 echo "change mode of $DIR/.lustre/fid to $new_obf_mode"
9226 chmod $new_obf_mode $DIR/.lustre/fid ||
9227 error "chmod $new_obf_mode $DIR/.lustre/fid failed"
9229 local obf_mode=$(stat --format=%a $DIR/.lustre/fid)
9230 [ $obf_mode -eq $new_obf_mode ] ||
9231 error "stat $DIR/.lustre/fid returned wrong mode $obf_mode"
9233 echo "restore mode of $DIR/.lustre/fid to $old_obf_mode"
9234 chmod $old_obf_mode $DIR/.lustre/fid ||
9235 error "chmod $old_obf_mode $DIR/.lustre/fid failed"
9238 $OPENFILE -f O_LOV_DELAY_CREATE:O_CREAT $test_dir/$tfile-2
9239 fid=$($LFS path2fid $test_dir/$tfile-2)
9240 echo "cp /etc/passwd $MOUNT/.lustre/fid/$fid"
9241 cp /etc/passwd $MOUNT/.lustre/fid/$fid &&
9242 error "create lov data thru .lustre should fail."
9243 echo "cp /etc/passwd $test_dir/$tfile-2"
9244 cp /etc/passwd $test_dir/$tfile-2 ||
9245 error "copy to $test_dir/$tfile-2 failed."
9246 echo "diff /etc/passwd $MOUNT/.lustre/fid/$fid"
9247 diff /etc/passwd $MOUNT/.lustre/fid/$fid ||
9248 error "diff /etc/passwd $MOUNT/.lustre/fid/$fid failed."
9250 rm -rf $test_dir/tfile.lnk
9251 rm -rf $test_dir/$tfile-2
9255 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.1) ]] &&
9256 skip "Need MDS version at least 2.4.1" && return
9259 local FID=$($LFS path2fid $DIR/$tfile)
9260 [ -z "$FID" ] && error "path2fid unable to get $DIR/$tfile FID"
9262 # check that we get the same pathname back
9263 local FOUND=$($LFS fid2path $MOUNT $FID)
9264 [ -z "$FOUND" ] && error "fid2path unable to get $FID path"
9265 [ "$FOUND" != "$DIR/$tfile" ] &&
9266 error "fid2path(path2fid($DIR/$tfile)) = $FOUND != $DIR/$tfile"
9270 run_test 154A "lfs path2fid and fid2path basic checks"
9273 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9274 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.51) ]] ||
9275 { skip "Need MDS version at least 2.2.51"; return 0; }
9277 cp /etc/hosts $DIR/$tfile
9279 fid=$($LFS path2fid $DIR/$tfile)
9281 [ $rc -ne 0 ] && error "error: could not get fid for $DIR/$tfile."
9283 dot_lustre_fid_permission_check "$fid" $DIR ||
9284 error "dot lustre permission check $fid failed"
9286 rm -rf $MOUNT/.lustre && error ".lustre is not allowed to be unlinked"
9288 touch $MOUNT/.lustre/file &&
9289 error "creation is not allowed under .lustre"
9291 mkdir $MOUNT/.lustre/dir &&
9292 error "mkdir is not allowed under .lustre"
9296 run_test 154a "Open-by-FID"
9299 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9300 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.51) ]] ||
9301 { skip "Need MDS version at least 2.2.51"; return 0; }
9303 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
9305 local remote_dir=$DIR/$tdir/remote_dir
9310 $LFS mkdir -i $MDTIDX -c $MDSCOUNT $remote_dir ||
9311 error "create remote directory failed"
9313 cp /etc/hosts $remote_dir/$tfile
9315 fid=$($LFS path2fid $remote_dir/$tfile)
9317 [ $rc -ne 0 ] && error "error: could not get fid for $remote_dir/$tfile"
9319 dot_lustre_fid_permission_check "$fid" $remote_dir ||
9320 error "dot lustre permission check $fid failed"
9323 run_test 154b "Open-by-FID for remote directory"
9326 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.1) ]] &&
9327 skip "Need MDS version at least 2.4.1" && return
9329 touch $DIR/$tfile.1 $DIR/$tfile.2 $DIR/$tfile.3
9330 local FID1=$($LFS path2fid $DIR/$tfile.1)
9331 local FID2=$($LFS path2fid $DIR/$tfile.2)
9332 local FID3=$($LFS path2fid $DIR/$tfile.3)
9335 $LFS path2fid $DIR/$tfile.[123] | while read PATHNAME FID; do
9336 [ "$PATHNAME" = "$DIR/$tfile.$N:" ] ||
9337 error "path2fid pathname $PATHNAME != $DIR/$tfile.$N:"
9339 [ "$FID" = "${!want}" ] ||
9340 error "path2fid $PATHNAME FID $FID != FID$N ${!want}"
9344 $LFS fid2path $MOUNT $FID1 $FID2 $FID3 | while read PATHNAME; do
9345 [ "$PATHNAME" = "$DIR/$tfile.$N" ] ||
9346 error "fid2path pathname $PATHNAME != $DIR/$tfile.$N:"
9350 run_test 154c "lfs path2fid and fid2path multiple arguments"
9353 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.5.53) ]] &&
9354 skip "Need MDS version at least 2.5.53" && return
9357 nid=$($LCTL list_nids | sed "s/\./\\\./g")
9361 local proc_ofile="mdt.*.exports.'$nid'.open_files"
9368 fid=$($LFS path2fid $DIR/$tfile)
9371 cmd="exec $fd<$DIR/$tfile"
9373 fid_list=$(do_facet $SINGLEMDS $LCTL get_param $proc_ofile)
9374 echo $fid_list | grep $fid
9377 cmd="exec $fd>/dev/null"
9379 if [ $rc -ne 0 ]; then
9380 error "FID $fid not found in open files list $fid_list"
9383 run_test 154d "Verify open file fid"
9385 test_155_small_load() {
9386 local temp=$TMP/$tfile
9387 local file=$DIR/$tfile
9389 dd if=/dev/urandom of=$temp bs=6096 count=1 || \
9390 error "dd of=$temp bs=6096 count=1 failed"
9392 cancel_lru_locks osc
9393 cmp $temp $file || error "$temp $file differ"
9395 $TRUNCATE $temp 6000
9396 $TRUNCATE $file 6000
9397 cmp $temp $file || error "$temp $file differ (truncate1)"
9399 echo "12345" >>$temp
9400 echo "12345" >>$file
9401 cmp $temp $file || error "$temp $file differ (append1)"
9403 echo "12345" >>$temp
9404 echo "12345" >>$file
9405 cmp $temp $file || error "$temp $file differ (append2)"
9411 test_155_big_load() {
9412 remote_ost_nodsh && skip "remote OST with nodsh" && return
9413 local temp=$TMP/$tfile
9414 local file=$DIR/$tfile
9417 local cache_size=$(do_facet ost$((MAXI+1)) \
9418 "awk '/cache/ {sum+=\\\$4} END {print sum}' /proc/cpuinfo")
9419 local large_file_size=$((cache_size * 2))
9421 echo "OSS cache size: $cache_size KB"
9422 echo "Large file size: $large_file_size KB"
9424 [ $MAXV -le $large_file_size ] && \
9425 skip_env "max available OST size needs > $large_file_size KB" && \
9428 $SETSTRIPE $file -c 1 -i $MAXI || error "$SETSTRIPE $file failed"
9430 dd if=/dev/urandom of=$temp bs=$large_file_size count=1k || \
9431 error "dd of=$temp bs=$large_file_size count=1k failed"
9434 cancel_lru_locks osc
9435 cmp $temp $file || error "$temp $file differ"
9442 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9444 set_cache writethrough on
9447 run_test 155a "Verify small file correctness: read cache:on write_cache:on"
9450 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9452 set_cache writethrough off
9455 run_test 155b "Verify small file correctness: read cache:on write_cache:off"
9458 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9460 set_cache writethrough on
9463 run_test 155c "Verify small file correctness: read cache:off write_cache:on"
9466 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9468 set_cache writethrough off
9471 run_test 155d "Verify small file correctness: read cache:off write_cache:off"
9474 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9476 set_cache writethrough on
9479 run_test 155e "Verify big file correctness: read cache:on write_cache:on"
9482 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9484 set_cache writethrough off
9487 run_test 155f "Verify big file correctness: read cache:on write_cache:off"
9490 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9492 set_cache writethrough on
9495 run_test 155g "Verify big file correctness: read cache:off write_cache:on"
9498 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9500 set_cache writethrough off
9503 run_test 155h "Verify big file correctness: read cache:off write_cache:off"
9506 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9510 local file="$DIR/$tfile"
9512 [ "$(facet_fstype ost1)" = "zfs" ] &&
9513 skip "LU-1956/LU-2261: stats unimplemented on OSD ZFS" &&
9518 log "Turn on read and write cache"
9520 set_cache writethrough on
9522 log "Write data and read it back."
9523 log "Read should be satisfied from the cache."
9524 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
9526 cancel_lru_locks osc
9527 cat $file >/dev/null
9529 if ! let "AFTER - BEFORE == CPAGES"; then
9530 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
9532 log "cache hits:: before: $BEFORE, after: $AFTER"
9535 log "Read again; it should be satisfied from the cache."
9537 cancel_lru_locks osc
9538 cat $file >/dev/null
9540 if ! let "AFTER - BEFORE == CPAGES"; then
9541 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
9543 log "cache hits:: before: $BEFORE, after: $AFTER"
9547 log "Turn off the read cache and turn on the write cache"
9549 set_cache writethrough on
9551 log "Read again; it should be satisfied from the cache."
9553 cancel_lru_locks osc
9554 cat $file >/dev/null
9556 if ! let "AFTER - BEFORE == CPAGES"; then
9557 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
9559 log "cache hits:: before: $BEFORE, after: $AFTER"
9562 log "Read again; it should not be satisfied from the cache."
9564 cancel_lru_locks osc
9565 cat $file >/dev/null
9567 if ! let "AFTER - BEFORE == 0"; then
9568 error "IN CACHE: before: $BEFORE, after: $AFTER"
9570 log "cache hits:: before: $BEFORE, after: $AFTER"
9573 log "Write data and read it back."
9574 log "Read should be satisfied from the cache."
9575 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
9577 cancel_lru_locks osc
9578 cat $file >/dev/null
9580 if ! let "AFTER - BEFORE == CPAGES"; then
9581 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
9583 log "cache hits:: before: $BEFORE, after: $AFTER"
9586 log "Read again; it should not be satisfied from the cache."
9588 cancel_lru_locks osc
9589 cat $file >/dev/null
9591 if ! let "AFTER - BEFORE == 0"; then
9592 error "IN CACHE: before: $BEFORE, after: $AFTER"
9594 log "cache hits:: before: $BEFORE, after: $AFTER"
9598 log "Turn off read and write cache"
9600 set_cache writethrough off
9602 log "Write data and read it back"
9603 log "It should not be satisfied from the cache."
9605 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
9606 cancel_lru_locks osc
9608 cat $file >/dev/null
9610 if ! let "AFTER - BEFORE == 0"; then
9611 error_ignore bz20762 "IN CACHE: before: $BEFORE, after: $AFTER"
9613 log "cache hits:: before: $BEFORE, after: $AFTER"
9616 log "Turn on the read cache and turn off the write cache"
9618 set_cache writethrough off
9620 log "Write data and read it back"
9621 log "It should not be satisfied from the cache."
9623 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
9625 cancel_lru_locks osc
9626 cat $file >/dev/null
9628 if ! let "AFTER - BEFORE == 0"; then
9629 error_ignore bz20762 "IN CACHE: before: $BEFORE, after: $AFTER"
9631 log "cache hits:: before: $BEFORE, after: $AFTER"
9634 log "Read again; it should be satisfied from the cache."
9636 cancel_lru_locks osc
9637 cat $file >/dev/null
9639 if ! let "AFTER - BEFORE == CPAGES"; then
9640 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
9642 log "cache hits:: before: $BEFORE, after: $AFTER"
9647 run_test 156 "Verification of tunables ============================"
9651 if [ $MDSCOUNT -gt 1 ]; then
9652 error_ignore bz17935 $*
9660 local CL_MASK_PARAM="mdd.$MDT0.changelog_mask"
9662 MASK=$(do_facet $SINGLEMDS $LCTL get_param $CL_MASK_PARAM| grep -c "$1")
9664 if [ $MASK -eq 1 ]; then
9665 do_facet $SINGLEMDS $LCTL set_param $CL_MASK_PARAM="-$1"
9667 do_facet $SINGLEMDS $LCTL set_param $CL_MASK_PARAM="+$1"
9671 changelog_extract_field() {
9677 $LFS changelog $mdt | gawk "/$cltype.*$file$/ {
9678 print gensub(/^.* "$identifier'(\[[^\]]*\]).*$/,"\\1",1)}' |
9683 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9684 remote_mds_nodsh && skip "remote MDS with nodsh" && return
9685 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] ||
9686 { skip "Need MDS version at least 2.2.0"; return; }
9688 local CL_USERS="mdd.$MDT0.changelog_users"
9689 local GET_CL_USERS="do_facet $SINGLEMDS $LCTL get_param -n $CL_USERS"
9690 USER=$(do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_register -n)
9691 echo "Registered as changelog user $USER"
9692 $GET_CL_USERS | grep -q $USER ||
9693 error "User $USER not found in changelog_users"
9696 test_mkdir -p $DIR/$tdir/pics/2008/zachy
9697 touch $DIR/$tdir/pics/2008/zachy/timestamp
9698 cp /etc/hosts $DIR/$tdir/pics/2008/zachy/pic1.jpg
9699 mv $DIR/$tdir/pics/2008/zachy $DIR/$tdir/pics/zach
9700 ln $DIR/$tdir/pics/zach/pic1.jpg $DIR/$tdir/pics/2008/portland.jpg
9701 ln -s $DIR/$tdir/pics/2008/portland.jpg $DIR/$tdir/pics/desktop.jpg
9702 rm $DIR/$tdir/pics/desktop.jpg
9704 $LFS changelog $MDT0 | tail -5
9706 echo "verifying changelog mask"
9707 changelog_chmask "MKDIR"
9708 changelog_chmask "CLOSE"
9710 test_mkdir -p $DIR/$tdir/pics/zach/sofia
9711 echo "zzzzzz" > $DIR/$tdir/pics/zach/file
9713 changelog_chmask "MKDIR"
9714 changelog_chmask "CLOSE"
9716 test_mkdir -p $DIR/$tdir/pics/2008/sofia
9717 echo "zzzzzz" > $DIR/$tdir/pics/zach/file
9719 $LFS changelog $MDT0
9720 MKDIRS=$($LFS changelog $MDT0 | tail -5 | grep -c "MKDIR")
9721 CLOSES=$($LFS changelog $MDT0 | tail -5 | grep -c "CLOSE")
9722 [ $MKDIRS -eq 1 ] || err17935 "MKDIR changelog mask count $DIRS != 1"
9723 [ $CLOSES -eq 1 ] || err17935 "CLOSE changelog mask count $DIRS != 1"
9726 echo "verifying target fid"
9727 fidc=$(changelog_extract_field $MDT0 "CREAT" "timestamp" "t=")
9728 fidf=$($LFS path2fid $DIR/$tdir/pics/zach/timestamp)
9729 [ "$fidc" == "$fidf" ] ||
9730 err17935 "fid in changelog $fidc != file fid $fidf"
9731 echo "verifying parent fid"
9732 fidc=$(changelog_extract_field $MDT0 "CREAT" "timestamp" "p=")
9733 fidf=$($LFS path2fid $DIR/$tdir/pics/zach)
9734 [ "$fidc" == "$fidf" ] ||
9735 err17935 "pfid in changelog $fidc != dir fid $fidf"
9737 USER_REC1=$($GET_CL_USERS | awk "\$1 == \"$USER\" {print \$2}")
9738 $LFS changelog_clear $MDT0 $USER $(($USER_REC1 + 5))
9739 USER_REC2=$($GET_CL_USERS | awk "\$1 == \"$USER\" {print \$2}")
9740 echo "verifying user clear: $(( $USER_REC1 + 5 )) == $USER_REC2"
9741 [ $USER_REC2 == $(($USER_REC1 + 5)) ] ||
9742 err17935 "user index expected $(($USER_REC1 + 5)) is $USER_REC2"
9744 MIN_REC=$($GET_CL_USERS |
9745 awk 'min == "" || $2 < min {min = $2}; END {print min}')
9746 FIRST_REC=$($LFS changelog $MDT0 | head -n1 | awk '{print $1}')
9747 echo "verifying min purge: $(( $MIN_REC + 1 )) == $FIRST_REC"
9748 [ $FIRST_REC == $(($MIN_REC + 1)) ] ||
9749 err17935 "first index should be $(($MIN_REC + 1)) is $FIRST_REC"
9751 # LU-3446 changelog index reset on MDT restart
9752 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
9753 CUR_REC1=$($GET_CL_USERS | head -n1 | cut -f3 -d' ')
9754 $LFS changelog_clear $MDT0 $USER 0
9755 stop $SINGLEMDS || error "Fail to stop MDT."
9756 start $SINGLEMDS $MDT_DEV $MDS_MOUNT_OPTS || error "Fail to start MDT."
9757 CUR_REC2=$($GET_CL_USERS | head -n1 | cut -f3 -d' ')
9758 echo "verifying index survives MDT restart: $CUR_REC1 == $CUR_REC2"
9759 [ $CUR_REC1 == $CUR_REC2 ] ||
9760 err17935 "current index should be $CUR_REC1 is $CUR_REC2"
9762 echo "verifying user deregister"
9763 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister $USER
9764 $GET_CL_USERS | grep -q $USER &&
9765 error "User $USER still in changelog_users"
9767 USERS=$(( $($GET_CL_USERS | wc -l) - 2 ))
9768 if [ $USERS -eq 0 ]; then
9769 LAST_REC1=$($GET_CL_USERS | head -n1 | cut -f3 -d' ')
9770 touch $DIR/$tdir/chloe
9771 LAST_REC2=$($GET_CL_USERS | head -n1 | cut -f3 -d' ')
9772 echo "verify changelogs are off: $LAST_REC1 == $LAST_REC2"
9773 [ $LAST_REC1 == $LAST_REC2 ] || error "changelogs not off"
9775 echo "$USERS other changelog users; can't verify off"
9778 run_test 160a "changelog sanity"
9780 test_160b() { # LU-3587
9781 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9782 remote_mds_nodsh && skip "remote MDS with nodsh" && return
9783 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] ||
9784 { skip "Need MDS version at least 2.2.0"; return; }
9786 local CL_USERS="mdd.$MDT0.changelog_users"
9787 local GET_CL_USERS="do_facet $SINGLEMDS $LCTL get_param -n $CL_USERS"
9788 USER=$(do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_register -n)
9789 echo "Registered as changelog user $USER"
9790 $GET_CL_USERS | grep -q $USER ||
9791 error "User $USER not found in changelog_users"
9793 local LONGNAME1=$(str_repeat a 255)
9794 local LONGNAME2=$(str_repeat b 255)
9797 echo "creating very long named file"
9798 touch $LONGNAME1 || error "create of $LONGNAME1 failed"
9799 echo "moving very long named file"
9800 mv $LONGNAME1 $LONGNAME2
9802 $LFS changelog $MDT0 | grep RENME
9804 echo "deregistering $USER"
9805 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister $USER
9809 run_test 160b "Verify that very long rename doesn't crash in changelog"
9813 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9816 local USER=$(do_facet $SINGLEMDS $LCTL --device $MDT0 \
9817 changelog_register -n)
9821 $MCREATE $DIR/$tdir/foo_160c
9822 changelog_chmask "TRUNC"
9823 $TRUNCATE $DIR/$tdir/foo_160c 200
9824 changelog_chmask "TRUNC"
9825 $TRUNCATE $DIR/$tdir/foo_160c 199
9826 $LFS changelog $MDT0
9827 TRUNCS=$($LFS changelog $MDT0 | tail -5 | grep -c "TRUNC")
9828 [ $TRUNCS -eq 1 ] || err17935 "TRUNC changelog mask count $TRUNCS != 1"
9829 $LFS changelog_clear $MDT0 $USER 0
9831 # Deregistration step
9832 echo "deregistering $USER"
9833 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister $USER
9835 run_test 160c "verify that changelog log catch the truncate event"
9838 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9839 test_mkdir -p -c1 $DIR/$tdir
9840 cp /etc/hosts $DIR/$tdir/$tfile
9841 test_mkdir -c1 $DIR/$tdir/foo1
9842 test_mkdir -c1 $DIR/$tdir/foo2
9843 ln $DIR/$tdir/$tfile $DIR/$tdir/foo1/sofia
9844 ln $DIR/$tdir/$tfile $DIR/$tdir/foo2/zachary
9845 ln $DIR/$tdir/$tfile $DIR/$tdir/foo1/luna
9846 ln $DIR/$tdir/$tfile $DIR/$tdir/foo2/thor
9847 local FID=$($LFS path2fid $DIR/$tdir/$tfile | tr -d '[]')
9848 if [ "$($LFS fid2path $DIR $FID | wc -l)" != "5" ]; then
9849 $LFS fid2path $DIR $FID
9850 err17935 "bad link ea"
9853 rm $DIR/$tdir/foo2/zachary
9855 rm $DIR/$tdir/foo2/thor
9857 rm $DIR/$tdir/$tfile
9859 mv $DIR/$tdir/foo1/sofia $DIR/$tdir/foo2/maggie
9860 if [ "$($LFS fid2path $FSNAME --link 1 $FID)" != "$tdir/foo2/maggie" ]
9862 $LFS fid2path $DIR $FID
9863 err17935 "bad link rename"
9865 rm $DIR/$tdir/foo2/maggie
9868 local longname=filename_avg_len_is_thirty_two_
9869 createmany -l$DIR/$tdir/foo1/luna $DIR/$tdir/foo2/$longname 1000 || \
9870 error "failed to hardlink many files"
9871 links=$($LFS fid2path $DIR $FID | wc -l)
9872 echo -n "${links}/1000 links in link EA"
9873 [ ${links} -gt 60 ] || err17935 "expected at least 60 links in link EA"
9874 unlinkmany $DIR/$tdir/foo2/$longname 1000 || \
9875 error "failed to unlink many hardlinks"
9877 run_test 161a "link ea sanity"
9880 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9881 [ $MDSCOUNT -lt 2 ] &&
9882 skip "skipping remote directory test" && return
9884 local remote_dir=$DIR/$tdir/remote_dir
9887 $LFS mkdir -i $MDTIDX $remote_dir ||
9888 error "create remote directory failed"
9890 cp /etc/hosts $remote_dir/$tfile
9891 mkdir -p $remote_dir/foo1
9892 mkdir -p $remote_dir/foo2
9893 ln $remote_dir/$tfile $remote_dir/foo1/sofia
9894 ln $remote_dir/$tfile $remote_dir/foo2/zachary
9895 ln $remote_dir/$tfile $remote_dir/foo1/luna
9896 ln $remote_dir/$tfile $remote_dir/foo2/thor
9898 local FID=$($LFS path2fid $remote_dir/$tfile | tr -d '[' |
9900 if [ "$($LFS fid2path $DIR $FID | wc -l)" != "5" ]; then
9901 $LFS fid2path $DIR $FID
9902 err17935 "bad link ea"
9905 rm $remote_dir/foo2/zachary
9907 rm $remote_dir/foo2/thor
9909 rm $remote_dir/$tfile
9911 mv $remote_dir/foo1/sofia $remote_dir/foo2/maggie
9912 local link_path=$($LFS fid2path $FSNAME --link 1 $FID)
9913 if [ "$DIR/$link_path" != "$remote_dir/foo2/maggie" ]; then
9914 $LFS fid2path $DIR $FID
9915 err17935 "bad link rename"
9917 rm $remote_dir/foo2/maggie
9920 local longname=filename_avg_len_is_thirty_two_
9921 createmany -l$remote_dir/foo1/luna $remote_dir/foo2/$longname 1000 ||
9922 error "failed to hardlink many files"
9923 links=$($LFS fid2path $DIR $FID | wc -l)
9924 echo -n "${links}/1000 links in link EA"
9925 [ ${links} -gt 60 ] || err17935 "expected at least 60 links in link EA"
9926 unlinkmany $remote_dir/foo2/$longname 1000 ||
9927 error "failed to unlink many hardlinks"
9929 run_test 161b "link ea sanity under remote directory"
9932 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9933 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.1.5) ]] &&
9934 skip "Need MDS version at least 2.1.5" && return
9936 # define CLF_RENAME_LAST 0x0001
9937 # rename overwrite a target having nlink = 1 (changelog flag 0x1)
9938 local USER=$(do_facet $SINGLEMDS $LCTL --device $MDT0 \
9939 changelog_register -n)
9942 touch $DIR/$tdir/foo_161c
9943 touch $DIR/$tdir/bar_161c
9944 mv -f $DIR/$tdir/foo_161c $DIR/$tdir/bar_161c
9945 $LFS changelog $MDT0 | grep RENME
9946 local flags=$($LFS changelog $MDT0 | grep RENME | tail -1 | \
9948 $LFS changelog_clear $MDT0 $USER 0
9949 if [ x$flags != "x0x1" ]; then
9950 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister \
9952 error "flag $flags is not 0x1"
9954 echo "rename overwrite a target having nlink = 1," \
9955 "changelog record has flags of $flags"
9957 # rename overwrite a target having nlink > 1 (changelog flag 0x0)
9958 touch $DIR/$tdir/foo_161c
9959 touch $DIR/$tdir/bar_161c
9960 ln $DIR/$tdir/bar_161c $DIR/$tdir/foobar_161c
9961 mv -f $DIR/$tdir/foo_161c $DIR/$tdir/bar_161c
9962 $LFS changelog $MDT0 | grep RENME
9963 flags=$($LFS changelog $MDT0 | grep RENME | tail -1 | cut -f5 -d' ')
9964 $LFS changelog_clear $MDT0 $USER 0
9965 if [ x$flags != "x0x0" ]; then
9966 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister \
9968 error "flag $flags is not 0x0"
9970 echo "rename overwrite a target having nlink > 1," \
9971 "changelog record has flags of $flags"
9973 # rename doesn't overwrite a target (changelog flag 0x0)
9974 touch $DIR/$tdir/foo_161c
9975 mv -f $DIR/$tdir/foo_161c $DIR/$tdir/foo2_161c
9976 $LFS changelog $MDT0 | grep RENME
9977 flags=$($LFS changelog $MDT0 | grep RENME | tail -1 | cut -f5 -d' ')
9978 $LFS changelog_clear $MDT0 $USER 0
9979 if [ x$flags != "x0x0" ]; then
9980 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister \
9982 error "flag $flags is not 0x0"
9984 echo "rename doesn't overwrite a target," \
9985 "changelog record has flags of $flags"
9987 # define CLF_UNLINK_LAST 0x0001
9988 # unlink a file having nlink = 1 (changelog flag 0x1)
9989 rm -f $DIR/$tdir/foo2_161c
9990 $LFS changelog $MDT0 | grep UNLNK
9991 flags=$($LFS changelog $MDT0 | grep UNLNK | tail -1 | cut -f5 -d' ')
9992 $LFS changelog_clear $MDT0 $USER 0
9993 if [ x$flags != "x0x1" ]; then
9994 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister \
9996 error "flag $flags is not 0x1"
9998 echo "unlink a file having nlink = 1," \
9999 "changelog record has flags of $flags"
10001 # unlink a file having nlink > 1 (changelog flag 0x0)
10002 ln -f $DIR/$tdir/bar_161c $DIR/$tdir/foobar_161c
10003 rm -f $DIR/$tdir/foobar_161c
10004 $LFS changelog $MDT0 | grep UNLNK
10005 flags=$($LFS changelog $MDT0 | grep UNLNK | tail -1 | cut -f5 -d' ')
10006 $LFS changelog_clear $MDT0 $USER 0
10007 if [ x$flags != "x0x0" ]; then
10008 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister \
10010 error "flag $flags is not 0x0"
10012 echo "unlink a file having nlink > 1," \
10013 "changelog record has flags of $flags"
10014 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister $USER
10016 run_test 161c "check CL_RENME[UNLINK] changelog record flags"
10023 local path=$(${LFS} fid2path $*)
10026 if [ $RC -ne 0 ]; then
10027 err17935 "path looked up of $expected failed. Error $RC"
10029 elif [ "${path}" != "${expected}" ]; then
10030 err17935 "path looked up \"${path}\" instead of \"${expected}\""
10033 echo "fid $fid resolves to path $path (expected $expected)"
10037 # Make changes to filesystem
10038 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10039 test_mkdir -p $DIR/$tdir/d2
10040 touch $DIR/$tdir/d2/$tfile
10041 touch $DIR/$tdir/d2/x1
10042 touch $DIR/$tdir/d2/x2
10043 test_mkdir -p $DIR/$tdir/d2/a/b/c
10044 test_mkdir -p $DIR/$tdir/d2/p/q/r
10046 FID=$($LFS path2fid $DIR/$tdir/d2/$tfile | tr -d '[]')
10047 check_path "$tdir/d2/$tfile" $FSNAME $FID --link 0
10050 ln -s $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/p/q/r/slink
10051 FID=$($LFS path2fid $DIR/$tdir/d2/p/q/r/slink | tr -d '[]')
10052 check_path "$tdir/d2/p/q/r/slink" $FSNAME $FID --link 0
10054 # softlink to wrong file
10055 ln -s /this/is/garbage $DIR/$tdir/d2/p/q/r/slink.wrong
10056 FID=$($LFS path2fid $DIR/$tdir/d2/p/q/r/slink.wrong | tr -d '[]')
10057 check_path "$tdir/d2/p/q/r/slink.wrong" $FSNAME $FID --link 0
10060 ln $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/p/q/r/hlink
10061 mv $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/a/b/c/new_file
10062 FID=$($LFS path2fid $DIR/$tdir/d2/a/b/c/new_file | tr -d '[]')
10063 # fid2path dir/fsname should both work
10064 check_path "$tdir/d2/a/b/c/new_file" $FSNAME $FID --link 1
10065 check_path "$DIR/$tdir/d2/p/q/r/hlink" $DIR $FID --link 0
10067 # hardlink count: check that there are 2 links
10068 # Doesnt work with CMD yet: 17935
10069 ${LFS} fid2path $DIR $FID | wc -l | grep -q 2 || \
10070 err17935 "expected 2 links"
10072 # hardlink indexing: remove the first link
10073 rm $DIR/$tdir/d2/p/q/r/hlink
10074 check_path "$tdir/d2/a/b/c/new_file" $FSNAME $FID --link 0
10078 run_test 162 "path lookup sanity"
10081 # do directio so as not to populate the page cache
10082 log "creating a 10 Mb file"
10083 $MULTIOP $DIR/$tfile oO_CREAT:O_DIRECT:O_RDWR:w$((10*1048576))c || error "multiop failed while creating a file"
10084 log "starting reads"
10085 dd if=$DIR/$tfile of=/dev/null bs=4096 &
10086 log "truncating the file"
10087 $MULTIOP $DIR/$tfile oO_TRUNC:c || error "multiop failed while truncating the file"
10089 kill %+ || true # reads might have finished
10090 echo "wait until dd is finished"
10092 log "removing the temporary file"
10093 rm -rf $DIR/$tfile || error "tmp file removal failed"
10095 run_test 169 "parallel read and truncate should not deadlock"
10098 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10099 $LCTL clear # bug 18514
10100 $LCTL debug_daemon start $TMP/${tfile}_log_good
10102 $LCTL debug_daemon stop
10103 sed -e "s/^...../a/g" $TMP/${tfile}_log_good > $TMP/${tfile}_log_bad ||
10104 error "sed failed to read log_good"
10106 $LCTL debug_daemon start $TMP/${tfile}_log_good
10108 $LCTL debug_daemon stop
10110 $LCTL df $TMP/${tfile}_log_bad > $TMP/${tfile}_log_bad.out 2>&1 ||
10111 error "lctl df log_bad failed"
10113 local bad_line=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $9}')
10114 local good_line1=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $5}')
10116 $LCTL df $TMP/${tfile}_log_good > $TMP/${tfile}_log_good.out 2>&1
10117 local good_line2=$(tail -n 1 $TMP/${tfile}_log_good.out | awk '{print $5}')
10119 [ "$bad_line" ] && [ "$good_line1" ] && [ "$good_line2" ] ||
10120 error "bad_line good_line1 good_line2 are empty"
10122 cat $TMP/${tfile}_log_good >> $TMP/${tfile}_logs_corrupt
10123 cat $TMP/${tfile}_log_bad >> $TMP/${tfile}_logs_corrupt
10124 cat $TMP/${tfile}_log_good >> $TMP/${tfile}_logs_corrupt
10126 $LCTL df $TMP/${tfile}_logs_corrupt > $TMP/${tfile}_log_bad.out 2>&1
10127 local bad_line_new=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $9}')
10128 local good_line_new=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $5}')
10130 [ "$bad_line_new" ] && [ "$good_line_new" ] ||
10131 error "bad_line_new good_line_new are empty"
10133 local expected_good=$((good_line1 + good_line2*2))
10135 rm -f $TMP/${tfile}*
10136 # LU-231, short malformed line may not be counted into bad lines
10137 if [ $bad_line -ne $bad_line_new ] &&
10138 [ $bad_line -ne $((bad_line_new - 1)) ]; then
10139 error "expected $bad_line bad lines, but got $bad_line_new"
10143 if [ $expected_good -ne $good_line_new ]; then
10144 error "expected $expected_good good lines, but got $good_line_new"
10149 run_test 170 "test lctl df to handle corrupted log ====================="
10151 test_171() { # bug20592
10152 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10153 #define OBD_FAIL_PTLRPC_DUMP_LOG 0x50e
10154 $LCTL set_param fail_loc=0x50e
10155 $LCTL set_param fail_val=3000
10156 multiop_bg_pause $DIR/$tfile O_s || true
10158 kill -USR1 $MULTIPID
10162 if dmesg | grep "recursive fault"; then
10163 error "caught a recursive fault"
10165 $LCTL set_param fail_loc=0
10168 run_test 171 "test libcfs_debug_dumplog_thread stuck in do_exit() ======"
10170 # it would be good to share it with obdfilter-survey/libecho code
10171 setup_obdecho_osc () {
10174 local obdfilter_name=$2
10175 echo "Creating new osc for $obdfilter_name on $ost_nid"
10176 # make sure we can find loopback nid
10177 $LCTL add_uuid $ost_nid $ost_nid >/dev/null 2>&1
10179 [ $rc -eq 0 ] && { $LCTL attach osc ${obdfilter_name}_osc \
10180 ${obdfilter_name}_osc_UUID || rc=2; }
10181 [ $rc -eq 0 ] && { $LCTL --device ${obdfilter_name}_osc setup \
10182 ${obdfilter_name}_UUID $ost_nid || rc=3; }
10186 cleanup_obdecho_osc () {
10187 local obdfilter_name=$1
10188 $LCTL --device ${obdfilter_name}_osc cleanup >/dev/null
10189 $LCTL --device ${obdfilter_name}_osc detach >/dev/null
10196 local pages=${3:-64}
10201 local obd_size=$(get_obd_size $node $OBD)
10202 local page_size=$(get_page_size $node)
10203 if [[ -n "$obd_size" ]]; then
10204 local new_count=$((obd_size / (pages * page_size / 1024)))
10205 [[ $new_count -ge $count ]] || count=$new_count
10208 do_facet $node "$LCTL attach echo_client ec ec_uuid" || rc=1
10209 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec setup $OBD" ||
10211 if [ $rc -eq 0 ]; then
10212 id=$(do_facet $node "$LCTL --device ec create 1" | awk '/object id/ {print $6}')
10213 [ ${PIPESTATUS[0]} -eq 0 -a -n "$id" ] || rc=3
10215 echo "New object id is $id"
10216 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec getattr $id" ||
10218 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec " \
10219 "test_brw $count w v $pages $id" || rc=4; }
10220 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec destroy $id 1" ||
10222 [ $rc -eq 0 -o $rc -gt 2 ] && { do_facet $node "$LCTL --device ec " \
10223 "cleanup" || rc=5; }
10224 [ $rc -eq 0 -o $rc -gt 1 ] && { do_facet $node "$LCTL --device ec " \
10225 "detach" || rc=6; }
10226 [ $rc -ne 0 ] && echo "obecho_create_test failed: $rc"
10231 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10232 remote_ost_nodsh && skip "remote OST with nodsh" && return
10234 local rmmod_local=0
10236 if ! module_loaded obdecho; then
10237 load_module obdecho/obdecho
10241 local osc=$($LCTL dl | grep -v mdt | awk '$3 == "osc" {print $4; exit}')
10242 local host=$(lctl get_param -n osc.$osc.import |
10243 awk '/current_connection:/ {print $2}' )
10244 local target=$(lctl get_param -n osc.$osc.import |
10245 awk '/target:/ {print $2}' )
10246 target=${target%_UUID}
10248 [[ -n $target ]] && { setup_obdecho_osc $host $target || rc=1; } || rc=1
10249 [ $rc -eq 0 ] && { obdecho_test ${target}_osc client || rc=2; }
10250 [[ -n $target ]] && cleanup_obdecho_osc $target
10251 [ $rmmod_local -eq 1 ] && rmmod obdecho
10254 run_test 180a "test obdecho on osc"
10257 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10258 remote_ost_nodsh && skip "remote OST with nodsh" && return
10260 local rmmod_remote=0
10262 do_facet ost1 "lsmod | grep -q obdecho || " \
10263 "{ insmod ${LUSTRE}/obdecho/obdecho.ko || " \
10264 "modprobe obdecho; }" && rmmod_remote=1
10265 target=$(do_facet ost1 $LCTL dl | awk '/obdfilter/ {print $4;exit}')
10266 [[ -n $target ]] && { obdecho_test $target ost1 || rc=1; }
10267 [ $rmmod_remote -eq 1 ] && do_facet ost1 "rmmod obdecho"
10270 run_test 180b "test obdecho directly on obdfilter"
10272 test_180c() { # LU-2598
10273 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10274 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.0) ]] &&
10275 skip "Need MDS version at least 2.4.0" && return
10278 local rmmod_remote=false
10279 local pages=16384 # 64MB bulk I/O RPC size
10282 do_rpc_nodes $(facet_active_host ost1) load_module obdecho/obdecho &&
10283 rmmod_remote=true || error "failed to load module obdecho"
10285 target=$(do_facet ost1 $LCTL dl | awk '/obdfilter/ { print $4 }' |
10287 if [[ -n $target ]]; then
10288 obdecho_test "$target" ost1 "$pages" ||
10289 rc=${PIPESTATUS[0]}
10291 echo "there is no obdfilter target on ost1"
10294 $rmmod_remote && do_facet ost1 "rmmod obdecho" || true
10297 run_test 180c "test huge bulk I/O size on obdfilter, don't LASSERT"
10299 test_181() { # bug 22177
10300 test_mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
10301 # create enough files to index the directory
10302 createmany -o $DIR/$tdir/foobar 4000
10303 # print attributes for debug purpose
10306 multiop_bg_pause $DIR/$tdir D_Sc || return 1
10308 # remove the files & current working dir
10309 unlinkmany $DIR/$tdir/foobar 4000
10311 kill -USR1 $MULTIPID
10313 stat $DIR/$tdir && error "open-unlinked dir was not removed!"
10316 run_test 181 "Test open-unlinked dir ========================"
10319 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10320 # disable MDC RPC lock wouldn't crash client
10324 mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
10325 #define OBD_FAIL_MDC_RPCS_SEM 0x804
10326 $LCTL set_param fail_loc=0x804
10328 for (( i=0; i < $tcount; i++ )) ; do
10329 mkdir $DIR/$tdir/$i
10330 createmany -o $DIR/$tdir/$i/f- $fcount &
10334 for (( i=0; i < $tcount; i++ )) ; do
10335 unlinkmany $DIR/$tdir/$i/f- $fcount &
10341 $LCTL set_param fail_loc=0
10343 run_test 182 "Disable MDC RPCs semaphore wouldn't crash client ================"
10345 test_183() { # LU-2275
10346 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.3.56) ]] &&
10347 skip "Need MDS version at least 2.3.56" && return
10349 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10350 mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
10351 echo aaa > $DIR/$tdir/$tfile
10353 #define OBD_FAIL_MDS_NEGATIVE_POSITIVE 0x148
10354 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x148
10356 ls -l $DIR/$tdir && error "ls succeeded, should have failed"
10357 cat $DIR/$tdir/$tfile && error "cat succeeded, should have failed"
10359 do_facet $SINGLEMDS $LCTL set_param fail_loc=0
10361 # Flush negative dentry cache
10362 touch $DIR/$tdir/$tfile
10364 # We are not checking for any leaked references here, they'll
10365 # become evident next time we do cleanup with module unload.
10368 run_test 183 "No crash or request leak in case of strange dispositions ========"
10370 # test suite 184 is for LU-2016, LU-2017
10372 check_swap_layouts_support && return 0
10374 dir0=$DIR/$tdir/$testnum
10375 test_mkdir -p -c1 $dir0 || error "creating dir $dir0"
10380 $SETSTRIPE -c1 $file1
10382 $SETSTRIPE -c2 $file2
10384 gen1=$($GETSTRIPE -g $file1)
10385 gen2=$($GETSTRIPE -g $file2)
10387 $LFS swap_layouts $file1 $file2 || error "swap of file layout failed"
10388 gen=$($GETSTRIPE -g $file1)
10389 [[ $gen1 != $gen ]] ||
10390 "Layout generation on $file1 does not change"
10391 gen=$($GETSTRIPE -g $file2)
10392 [[ $gen2 != $gen ]] ||
10393 "Layout generation on $file2 does not change"
10395 cmp $ref1 $file2 || error "content compare failed ($ref1 != $file2)"
10396 cmp $ref2 $file1 || error "content compare failed ($ref2 != $file1)"
10398 run_test 184a "Basic layout swap"
10401 check_swap_layouts_support && return 0
10403 dir0=$DIR/$tdir/$testnum
10404 mkdir -p $dir0 || error "creating dir $dir0"
10411 $SETSTRIPE -c1 $file1
10412 $SETSTRIPE -c2 $file2
10413 $SETSTRIPE -c1 $file3
10414 chown $RUNAS_ID $file3
10415 gen1=$($GETSTRIPE -g $file1)
10416 gen2=$($GETSTRIPE -g $file2)
10418 $LFS swap_layouts $dir1 $dir2 &&
10419 error "swap of directories layouts should fail"
10420 $LFS swap_layouts $dir1 $file1 &&
10421 error "swap of directory and file layouts should fail"
10422 $RUNAS $LFS swap_layouts $file1 $file2 &&
10423 error "swap of file we cannot write should fail"
10424 $LFS swap_layouts $file1 $file3 &&
10425 error "swap of file with different owner should fail"
10426 /bin/true # to clear error code
10428 run_test 184b "Forbidden layout swap (will generate errors)"
10431 check_swap_layouts_support && return 0
10433 local dir0=$DIR/$tdir/$testnum
10434 mkdir -p $dir0 || error "creating dir $dir0"
10436 local ref1=$dir0/ref1
10437 local ref2=$dir0/ref2
10438 local file1=$dir0/file1
10439 local file2=$dir0/file2
10440 # create a file large enough for the concurent test
10441 dd if=/dev/urandom of=$ref1 bs=1M count=$((RANDOM % 50 + 20))
10442 dd if=/dev/urandom of=$ref2 bs=1M count=$((RANDOM % 50 + 20))
10443 echo "ref file size: ref1(`stat -c %s $ref1`), ref2(`stat -c %s $ref2`)"
10446 dd if=$ref1 of=$file1 bs=16k &
10449 # Make sure dd starts to copy file
10450 while [ ! -f $file1 ]; do sleep 0.1; done
10452 $LFS swap_layouts $file1 $file2
10455 [[ $? == 0 ]] || error "concurrent write on $file1 failed"
10456 [[ $rc == 0 ]] || error "swap of $file1 and $file2 failed"
10458 # how many bytes copied before swapping layout
10459 local copied=`stat -c %s $file2`
10460 local remaining=`stat -c %s $ref1`
10461 remaining=$((remaining - copied))
10462 echo "Copied $copied bytes before swapping layout..."
10464 cmp -n $copied $file1 $ref2 | grep differ &&
10465 error "Content mismatch [0, $copied) of ref2 and file1"
10466 cmp -n $copied $file2 $ref1 ||
10467 error "Content mismatch [0, $copied) of ref1 and file2"
10468 cmp -i $copied:$copied -n $remaining $file1 $ref1 ||
10469 error "Content mismatch [$copied, EOF) of ref1 and file1"
10472 rm -f $ref1 $ref2 $file1 $file2
10474 run_test 184c "Concurrent write and layout swap"
10477 check_swap_layouts_support && return 0
10479 local file1=$DIR/$tdir/$tfile-1
10480 local file2=$DIR/$tdir/$tfile-2
10481 local file3=$DIR/$tdir/$tfile-3
10485 mkdir -p $DIR/$tdir
10486 touch $file1 || error "create $file1 failed"
10487 $OPENFILE -f O_CREAT:O_LOV_DELAY_CREATE $file2 ||
10488 error "create $file2 failed"
10489 $OPENFILE -f O_CREAT:O_LOV_DELAY_CREATE $file3 ||
10490 error "create $file3 failed"
10491 lovea1=$($LFS getstripe $file1 | sed 1d)
10493 $LFS swap_layouts $file2 $file3 ||
10494 error "swap $file2 $file3 layouts failed"
10495 $LFS swap_layouts $file1 $file2 ||
10496 error "swap $file1 $file2 layouts failed"
10498 lovea2=$($LFS getstripe $file2 | sed 1d)
10499 [ "$lovea1" == "$lovea2" ] || error "lovea $lovea1 != $lovea2"
10501 lovea1=$(getfattr -n trusted.lov $file1 | grep ^trusted)
10502 [ -z $lovea1 ] || error "$file1 shouldn't have lovea"
10504 run_test 184d "allow stripeless layouts swap"
10507 test_185() { # LU-2441
10508 # LU-3553 - no volatile file support in old servers
10509 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.3.60) ]] ||
10510 { skip "Need MDS version at least 2.3.60"; return 0; }
10512 mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
10513 touch $DIR/$tdir/spoo
10514 local mtime1=$(stat -c "%Y" $DIR/$tdir)
10515 local fid=$($MULTIOP $DIR/$tdir VFw4096c) ||
10516 error "cannot create/write a volatile file"
10517 $CHECKSTAT -t file $MOUNT/.lustre/fid/$fid 2>/dev/null &&
10518 error "FID is still valid after close"
10520 multiop_bg_pause $DIR/$tdir vVw4096_c
10527 # assume that the next FID for this client is sequential, since stdout
10528 # is unfortunately eaten by multiop_bg_pause
10529 local n=$((${fidv[1]} + 1))
10530 local next_fid="${fidv[0]}:$(printf "0x%x" $n):${fidv[2]}"
10531 $CHECKSTAT -t file $MOUNT/.lustre/fid/$next_fid ||
10532 error "FID is missing before close"
10533 kill -USR1 $multi_pid
10534 # 1 second delay, so if mtime change we will see it
10536 local mtime2=$(stat -c "%Y" $DIR/$tdir)
10537 [[ $mtime1 == $mtime2 ]] || error "mtime has changed"
10539 run_test 185 "Volatile file support"
10542 local dir0=$DIR/$tdir/$testnum
10543 mkdir -p $dir0 || error "creating dir $dir0"
10545 local file=$dir0/file1
10546 dd if=/dev/urandom of=$file count=10 bs=1M conv=fsync
10547 local dv1=$($LFS data_version $file)
10548 dd if=/dev/urandom of=$file seek=10 count=1 bs=1M conv=fsync
10549 local dv2=$($LFS data_version $file)
10550 [[ $dv1 != $dv2 ]] ||
10551 error "data version did not change on write $dv1 == $dv2"
10556 run_test 187a "Test data version change"
10559 local dir0=$DIR/$tdir/$testnum
10560 mkdir -p $dir0 || error "creating dir $dir0"
10562 declare -a DV=$($MULTIOP $dir0 Vw1000xYw1000xY | cut -f3 -d" ")
10563 [[ ${DV[0]} != ${DV[1]} ]] ||
10564 error "data version did not change on write"\
10565 " ${DV[0]} == ${DV[1]}"
10570 run_test 187b "Test data version change on volatile file"
10573 check_file_in_pool()
10578 local res=$($GETSTRIPE $file | grep 0x | cut -f2)
10581 for t in $tlist ; do
10582 [ "$i" -eq "$t" ] && continue 2
10585 echo "pool list: $tlist"
10586 echo "striping: $res"
10587 error_noexit "$file not allocated in $pool"
10594 echo "Creating new pool"
10597 create_pool $FSNAME.$pool ||
10598 { error_noexit "No pool created, result code $?"; return 1; }
10599 [ $($LFS pool_list $FSNAME | grep -c $pool) -eq 1 ] ||
10600 { error_noexit "$pool not in lfs pool_list"; return 2; }
10603 pool_add_targets() {
10604 echo "Adding targets to pool"
10610 local list=$(seq $first $step $last)
10612 local t=$(for i in $list; do printf "$FSNAME-OST%04x_UUID " $i; done)
10613 do_facet mgs $LCTL pool_add \
10614 $FSNAME.$pool $FSNAME-OST[$first-$last/$step]
10615 wait_update $HOSTNAME "lctl get_param -n lov.$FSNAME-*.pools.$pool \
10616 | sort -u | tr '\n' ' ' " "$t" || {
10617 error_noexit "Add to pool failed"
10620 local lfscount=$($LFS pool_list $FSNAME.$pool | grep -c "\-OST")
10621 local addcount=$(((last - first) / step + 1))
10622 [ $lfscount -eq $addcount ] || {
10623 error_noexit "lfs pool_list bad ost count" \
10624 "$lfscount != $addcount"
10632 echo "Setting pool on directory $tdir"
10634 $SETSTRIPE -c 2 -p $pool $tdir && return 0
10636 error_noexit "Cannot set pool $pool to $tdir"
10643 echo "Checking pool on directory $tdir"
10645 local res=$($GETSTRIPE --pool $tdir | sed "s/\s*$//")
10646 [ "$res" = "$pool" ] && return 0
10648 error_noexit "Pool on '$tdir' is '$res', not '$pool'"
10652 pool_dir_rel_path() {
10653 echo "Testing relative path works well"
10658 mkdir -p $root/$tdir/$tdir
10660 pool_set_dir $pool $tdir || return 1
10661 pool_set_dir $pool ./$tdir || return 2
10662 pool_set_dir $pool ../$tdir || return 3
10663 pool_set_dir $pool ../$tdir/$tdir || return 4
10664 rm -rf $tdir; cd - > /dev/null
10667 pool_alloc_files() {
10668 echo "Checking files allocation from directory pool"
10675 for i in $(seq -w 1 $count)
10677 local file=$tdir/file-$i
10679 check_file_in_pool $file $pool "$tlist" || \
10680 failed=$((failed + 1))
10682 [ "$failed" = 0 ] && return 0
10684 error_noexit "$failed files not allocated in $pool"
10688 pool_create_files() {
10689 echo "Creating files in pool"
10697 for i in $(seq -w 1 $count)
10699 local file=$tdir/spoo-$i
10700 $SETSTRIPE -p $pool $file
10701 check_file_in_pool $file $pool "$tlist" || \
10702 failed=$((failed + 1))
10704 [ "$failed" = 0 ] && return 0
10706 error_noexit "$failed files not allocated in $pool"
10711 echo "Checking 'lfs df' output"
10714 local t=$($LCTL get_param -n lov.$FSNAME-clilov-*.pools.$pool |
10716 local res=$($LFS df --pool $FSNAME.$pool |
10718 grep "$FSNAME-OST" |
10720 [ "$res" = "$t" ] && return 0
10722 error_noexit "Pools OSTs '$t' is not '$res' that lfs df reports"
10726 pool_file_rel_path() {
10727 echo "Creating files in a pool with relative pathname"
10732 { error_noexit "unable to create $tdir"; return 1 ; }
10733 local file="/..$tdir/$tfile-1"
10734 $SETSTRIPE -p $pool $file ||
10735 { error_noexit "unable to create $file" ; return 2 ; }
10738 $SETSTRIPE -p $pool $tfile-2 || {
10739 error_noexit "unable to create $tfile-2 in $tdir"
10744 pool_remove_first_target() {
10745 echo "Removing first target from a pool"
10748 local pname="lov.$FSNAME-*.pools.$pool"
10749 local t=$($LCTL get_param -n $pname | head -n1)
10750 do_facet mgs $LCTL pool_remove $FSNAME.$pool $t
10751 wait_update $HOSTNAME "lctl get_param -n $pname | grep $t" "" || {
10752 error_noexit "$t not removed from $FSNAME.$pool"
10757 pool_remove_all_targets() {
10758 echo "Removing all targets from pool"
10761 local pname="lov.$FSNAME-*.pools.$pool"
10762 for t in $($LCTL get_param -n $pname | sort -u)
10764 do_facet mgs $LCTL pool_remove $FSNAME.$pool $t
10766 wait_update $HOSTNAME "lctl get_param -n $pname" "" || {
10767 error_noexit "Pool $FSNAME.$pool cannot be drained"
10770 # striping on an empty/nonexistant pool should fall back
10771 # to "pool of everything"
10773 error_noexit "failed to use fallback striping for empty pool"
10776 # setstripe on an empty pool should fail
10777 $SETSTRIPE -p $pool $file 2>/dev/null && {
10778 error_noexit "expected failure when creating file" \
10786 echo "Destroying pool"
10790 do_facet mgs $LCTL pool_destroy $FSNAME.$pool
10793 # striping on an empty/nonexistant pool should fall back
10794 # to "pool of everything"
10796 error_noexit "failed to use fallback striping for missing pool"
10799 # setstripe on an empty pool should fail
10800 $SETSTRIPE -p $pool $file 2>/dev/null && {
10801 error_noexit "expected failure when creating file" \
10802 "with missing pool"
10806 # get param should return err once pool is gone
10807 if wait_update $HOSTNAME "lctl get_param -n \
10808 lov.$FSNAME-*.pools.$pool 2>/dev/null || echo foo" "foo"
10810 remove_pool_from_list $FSNAME.$pool
10813 error_noexit "Pool $FSNAME.$pool is not destroyed"
10818 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10819 remote_mgs_nodsh && skip "remote MGS with nodsh" && return
10821 local POOL=${POOL:-cea1}
10822 local POOL_ROOT=${POOL_ROOT:-$DIR/d200.pools}
10823 local POOL_DIR_NAME=${POOL_DIR_NAME:-dir_tst}
10826 local last_ost=$(($OSTCOUNT - 1))
10828 local ost_list=$(seq $first_ost $ost_step $last_ost)
10829 local ost_range="$first_ost $last_ost $ost_step"
10830 local test_path=$POOL_ROOT/$POOL_DIR_NAME
10831 local file_dir=$POOL_ROOT/file_tst
10835 # former test_200a test_200b
10836 pool_add $POOL || { rc=$? ; break; }
10837 pool_add_targets $POOL $ost_range || { rc=$? ; break; }
10838 # former test_200c test_200d
10839 mkdir -p $test_path
10840 pool_set_dir $POOL $test_path || { rc=$? ; break; }
10841 pool_check_dir $POOL $test_path || { rc=$? ; break; }
10842 pool_dir_rel_path $POOL $POOL_DIR_NAME $POOL_ROOT \
10843 || { rc=$? ; break; }
10844 # former test_200e test_200f
10845 local files=$((OSTCOUNT*3))
10846 pool_alloc_files $POOL $test_path $files "$ost_list" \
10847 || { rc=$? ; break; }
10848 pool_create_files $POOL $file_dir $files "$ost_list" \
10849 || { rc=$? ; break; }
10850 # former test_200g test_200h
10851 pool_lfs_df $POOL || { rc=$? ; break; }
10852 pool_file_rel_path $POOL $test_path || { rc=$? ; break; }
10854 # former test_201a test_201b test_201c
10855 pool_remove_first_target $POOL || { rc=$? ; break; }
10857 local f=$test_path/$tfile
10858 pool_remove_all_targets $POOL $f || { rc=$? ; break; }
10859 pool_remove $POOL $f || { rc=$? ; break; }
10866 run_test 200 "OST pools"
10868 # usage: default_attr <count | size | offset>
10870 $LCTL get_param -n lov.$FSNAME-clilov-\*.stripe${1}
10873 # usage: check_default_stripe_attr
10874 check_default_stripe_attr() {
10875 ACTUAL=$($GETSTRIPE $* $DIR/$tdir)
10877 --stripe-count|--count)
10878 [ -n "$2" ] && EXPECTED=0 || EXPECTED=$(default_attr count);;
10879 --stripe-size|--size)
10880 [ -n "$2" ] && EXPECTED=0 || EXPECTED=$(default_attr size);;
10881 --stripe-index|--index)
10884 error "unknown getstripe attr '$1'"
10887 [ $ACTUAL != $EXPECTED ] &&
10888 error "$DIR/$tdir has $1 '$ACTUAL', not '$EXPECTED'"
10892 test_mkdir -p $DIR/$tdir
10893 $SETSTRIPE --stripe-count 0 --stripe-size 0 --stripe-index -1 $DIR/$tdir
10895 check_default_stripe_attr --stripe-count
10896 check_default_stripe_attr --stripe-size
10897 check_default_stripe_attr --stripe-index
10901 run_test 204a "Print default stripe attributes ================="
10904 test_mkdir -p $DIR/$tdir
10905 $SETSTRIPE --stripe-count 1 $DIR/$tdir
10907 check_default_stripe_attr --stripe-size
10908 check_default_stripe_attr --stripe-index
10912 run_test 204b "Print default stripe size and offset ==========="
10915 test_mkdir -p $DIR/$tdir
10916 $SETSTRIPE --stripe-size 65536 $DIR/$tdir
10918 check_default_stripe_attr --stripe-count
10919 check_default_stripe_attr --stripe-index
10923 run_test 204c "Print default stripe count and offset ==========="
10926 test_mkdir -p $DIR/$tdir
10927 $SETSTRIPE --stripe-index 0 $DIR/$tdir
10929 check_default_stripe_attr --stripe-count
10930 check_default_stripe_attr --stripe-size
10934 run_test 204d "Print default stripe count and size ============="
10937 test_mkdir -p $DIR/$tdir
10938 $SETSTRIPE -d $DIR/$tdir
10940 check_default_stripe_attr --stripe-count --raw
10941 check_default_stripe_attr --stripe-size --raw
10942 check_default_stripe_attr --stripe-index --raw
10946 run_test 204e "Print raw stripe attributes ================="
10949 test_mkdir -p $DIR/$tdir
10950 $SETSTRIPE --stripe-count 1 $DIR/$tdir
10952 check_default_stripe_attr --stripe-size --raw
10953 check_default_stripe_attr --stripe-index --raw
10957 run_test 204f "Print raw stripe size and offset ==========="
10960 test_mkdir -p $DIR/$tdir
10961 $SETSTRIPE --stripe-size 65536 $DIR/$tdir
10963 check_default_stripe_attr --stripe-count --raw
10964 check_default_stripe_attr --stripe-index --raw
10968 run_test 204g "Print raw stripe count and offset ==========="
10971 test_mkdir -p $DIR/$tdir
10972 $SETSTRIPE --stripe-index 0 $DIR/$tdir
10974 check_default_stripe_attr --stripe-count --raw
10975 check_default_stripe_attr --stripe-size --raw
10979 run_test 204h "Print raw stripe count and size ============="
10981 # Figure out which job scheduler is being used, if any,
10982 # or use a fake one
10983 if [ -n "$SLURM_JOB_ID" ]; then # SLURM
10984 JOBENV=SLURM_JOB_ID
10985 elif [ -n "$LSB_JOBID" ]; then # Load Sharing Facility
10987 elif [ -n "$PBS_JOBID" ]; then # PBS/Maui/Moab
10989 elif [ -n "$LOADL_STEPID" ]; then # LoadLeveller
10990 JOBENV=LOADL_STEP_ID
10991 elif [ -n "$JOB_ID" ]; then # Sun Grid Engine
10997 verify_jobstats() {
11001 # clear old jobstats
11002 do_facet $SINGLEMDS lctl set_param mdt.*.job_stats="clear"
11003 do_facet ost1 lctl set_param obdfilter.*.job_stats="clear"
11005 # use a new JobID for this test, or we might see an old one
11006 [ "$JOBENV" = "FAKE_JOBID" ] && FAKE_JOBID=test_id.$testnum.$RANDOM
11010 log "Using JobID environment variable $JOBENV=$JOBVAL"
11012 if [ $JOBENV = "FAKE_JOBID" ]; then
11013 FAKE_JOBID=$JOBVAL $cmd
11018 if [ "$target" = "mdt" -o "$target" = "both" ]; then
11019 FACET="$SINGLEMDS" # will need to get MDS number for DNE
11020 do_facet $FACET lctl get_param mdt.*.job_stats |
11021 grep $JOBVAL || error "No job stats found on MDT $FACET"
11023 if [ "$target" = "ost" -o "$target" = "both" ]; then
11025 do_facet $FACET lctl get_param obdfilter.*.job_stats |
11026 grep $JOBVAL || error "No job stats found on OST $FACET"
11032 NEW_JOBENV=${1:-$OLD_JOBENV}
11033 do_facet mgs $LCTL conf_param $FSNAME.sys.jobid_var=$NEW_JOBENV
11034 wait_update $HOSTNAME "$LCTL get_param -n jobid_var" $NEW_JOBENV
11037 test_205() { # Job stats
11038 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11039 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep jobstats)" ] &&
11040 skip "Server doesn't support jobstats" && return 0
11043 OLD_JOBENV=`$LCTL get_param -n jobid_var`
11044 if [ $OLD_JOBENV != $JOBENV ]; then
11045 jobstats_set $JOBENV
11046 trap jobstats_set EXIT
11050 cmd="mkdir $DIR/$tfile"
11051 verify_jobstats "$cmd" "mdt"
11053 cmd="rm -fr $DIR/$tfile"
11054 verify_jobstats "$cmd" "mdt"
11056 cmd="mknod $DIR/$tfile c 1 3"
11057 verify_jobstats "$cmd" "mdt"
11059 cmd="rm -f $DIR/$tfile"
11060 verify_jobstats "$cmd" "mdt"
11062 cmd="$SETSTRIPE -i 0 -c 1 $DIR/$tfile"
11063 verify_jobstats "$cmd" "mdt"
11065 cmd="touch $DIR/$tfile"
11066 verify_jobstats "$cmd" "both"
11068 cmd="dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 oflag=sync"
11069 verify_jobstats "$cmd" "ost"
11071 cmd="dd if=$DIR/$tfile of=/dev/null bs=1M count=1 iflag=direct"
11072 verify_jobstats "$cmd" "ost"
11074 cmd="$TRUNCATE $DIR/$tfile 0"
11075 verify_jobstats "$cmd" "both"
11077 cmd="mv -f $DIR/$tfile $DIR/jobstats_test_rename"
11078 verify_jobstats "$cmd" "mdt"
11081 rm -f $DIR/jobstats_test_rename
11083 [ $OLD_JOBENV != $JOBENV ] && jobstats_set $OLD_JOBENV
11085 run_test 205 "Verify job stats"
11087 # LU-1480, LU-1773 and LU-1657
11089 mkdir -p $DIR/$tdir
11090 lfs setstripe -c -1 $DIR/$tdir
11091 #define OBD_FAIL_LOV_INIT 0x1403
11092 $LCTL set_param fail_loc=0xa0001403
11093 $LCTL set_param fail_val=1
11094 touch $DIR/$tdir/$tfile || true
11096 run_test 206 "fail lov_init_raid0() doesn't lbug"
11099 dd if=/dev/zero of=$DIR/$tfile bs=4k count=$((RANDOM%10+1))
11100 local fsz=`stat -c %s $DIR/$tfile`
11101 cancel_lru_locks mdc
11103 # do not return layout in getattr intent
11104 #define OBD_FAIL_MDS_NO_LL_GETATTR 0x170
11105 $LCTL set_param fail_loc=0x170
11106 local sz=`stat -c %s $DIR/$tfile`
11108 [ $fsz -eq $sz ] || error "file size expected $fsz, actual $sz"
11112 run_test 207a "can refresh layout at glimpse"
11115 dd if=/dev/zero of=$DIR/$tfile bs=4k count=$((RANDOM%10+1))
11116 local cksum=`md5sum $DIR/$tfile`
11117 local fsz=`stat -c %s $DIR/$tfile`
11118 cancel_lru_locks mdc
11119 cancel_lru_locks osc
11121 # do not return layout in getattr intent
11122 #define OBD_FAIL_MDS_NO_LL_OPEN 0x171
11123 $LCTL set_param fail_loc=0x171
11125 # it will refresh layout after the file is opened but before read issues
11126 echo checksum is "$cksum"
11127 echo "$cksum" |md5sum -c --quiet || error "file differs"
11131 run_test 207b "can refresh layout at open"
11134 # FIXME: in this test suite, only RD lease is used. This is okay
11135 # for now as only exclusive open is supported. After generic lease
11136 # is done, this test suite should be revised. - Jinshan
11138 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.4.52) ]] ||
11139 { skip "Need MDS version at least 2.4.52"; return 0; }
11141 echo "==== test 1: verify get lease work"
11142 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:eRE+eU || error "get lease error"
11144 echo "==== test 2: verify lease can be broken by upcoming open"
11145 $MULTIOP $DIR/$tfile oO_RDONLY:eR_E-eUc &
11149 $MULTIOP $DIR/$tfile oO_RDONLY:c
11150 kill -USR1 $PID && wait $PID || error "break lease error"
11152 echo "==== test 3: verify lease can't be granted if an open already exists"
11153 $MULTIOP $DIR/$tfile oO_RDONLY:_c &
11157 $MULTIOP $DIR/$tfile oO_RDONLY:eReUc && error "apply lease should fail"
11158 kill -USR1 $PID && wait $PID || error "open file error"
11160 echo "==== test 4: lease can sustain over recovery"
11161 $MULTIOP $DIR/$tfile oO_RDONLY:eR_E+eUc &
11167 kill -USR1 $PID && wait $PID || error "lease broken over recovery"
11169 echo "==== test 5: lease broken can't be regained by replay"
11170 $MULTIOP $DIR/$tfile oO_RDONLY:eR_E-eUc &
11174 # open file to break lease and then recovery
11175 $MULTIOP $DIR/$tfile oO_RDWR:c || error "open file error"
11178 kill -USR1 $PID && wait $PID || error "lease not broken over recovery"
11182 run_test 208 "Exclusive open"
11185 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep disp_stripe)" ] &&
11186 skip_env "must have disp_stripe" && return
11189 sync; sleep 5; sync;
11191 echo 3 > /proc/sys/vm/drop_caches
11192 req_before=$(awk '/ptlrpc_cache / { print $2 }' /proc/slabinfo)
11194 # open/close 500 times
11195 for i in $(seq 500); do
11199 echo 3 > /proc/sys/vm/drop_caches
11200 req_after=$(awk '/ptlrpc_cache / { print $2 }' /proc/slabinfo)
11202 echo "before: $req_before, after: $req_after"
11203 [ $((req_after - req_before)) -ge 300 ] &&
11204 error "open/close requests are not freed"
11207 run_test 209 "read-only open/close requests should be freed promptly"
11211 size=$((size % 8192 + 1))
11212 dd if=/dev/urandom of=$DIR/f212 bs=1k count=$size
11213 sendfile $DIR/f212 $DIR/f212.xyz || error "sendfile wrong"
11214 rm -f $DIR/f212 $DIR/f212.xyz
11216 run_test 212 "Sendfile test ============================================"
11219 dd if=/dev/zero of=$DIR/$tfile bs=4k count=4
11220 cancel_lru_locks osc
11221 lctl set_param fail_loc=0x8000040f
11222 # generate a read lock
11223 cat $DIR/$tfile > /dev/null
11224 # write to the file, it will try to cancel the above read lock.
11225 cat /etc/hosts >> $DIR/$tfile
11227 run_test 213 "OSC lock completion and cancel race don't crash - bug 18829"
11229 test_214() { # for bug 20133
11230 mkdir -p $DIR/$tdir/d214c || error "mkdir $DIR/$tdir/d214c failed"
11231 for (( i=0; i < 340; i++ )) ; do
11232 touch $DIR/$tdir/d214c/a$i
11235 ls -l $DIR/$tdir || error "ls -l $DIR/d214p failed"
11236 mv $DIR/$tdir/d214c $DIR/ || error "mv $DIR/d214p/d214c $DIR/ failed"
11237 ls $DIR/d214c || error "ls $DIR/d214c failed"
11238 rm -rf $DIR/$tdir || error "rm -rf $DIR/d214* failed"
11239 rm -rf $DIR/d214* || error "rm -rf $DIR/d214* failed"
11241 run_test 214 "hash-indexed directory test - bug 20133"
11243 # having "abc" as 1st arg, creates $TMP/lnet_abc.out and $TMP/lnet_abc.sys
11244 create_lnet_proc_files() {
11245 cat /proc/sys/lnet/$1 >$TMP/lnet_$1.out || error "cannot read /proc/sys/lnet/$1"
11246 sysctl lnet.$1 >$TMP/lnet_$1.sys_tmp || error "cannot read lnet.$1"
11248 sed "s/^lnet.$1\ =\ //g" "$TMP/lnet_$1.sys_tmp" >$TMP/lnet_$1.sys
11249 rm -f "$TMP/lnet_$1.sys_tmp"
11252 # counterpart of create_lnet_proc_files
11253 remove_lnet_proc_files() {
11254 rm -f $TMP/lnet_$1.out $TMP/lnet_$1.sys
11257 # uses 1st arg as trailing part of filename, 2nd arg as description for reports,
11258 # 3rd arg as regexp for body
11259 check_lnet_proc_stats() {
11260 local l=$(cat "$TMP/lnet_$1" |wc -l)
11261 [ $l = 1 ] || (cat "$TMP/lnet_$1" && error "$2 is not of 1 line: $l")
11263 grep -E "$3" "$TMP/lnet_$1" || (cat "$TMP/lnet_$1" && error "$2 misformatted")
11266 # uses 1st arg as trailing part of filename, 2nd arg as description for reports,
11267 # 3rd arg as regexp for body, 4th arg as regexp for 1st line, 5th arg is
11268 # optional and can be regexp for 2nd line (lnet.routes case)
11269 check_lnet_proc_entry() {
11270 local blp=2 # blp stands for 'position of 1st line of body'
11271 [ "$5" = "" ] || blp=3 # lnet.routes case
11273 local l=$(cat "$TMP/lnet_$1" |wc -l)
11274 # subtracting one from $blp because the body can be empty
11275 [ "$l" -ge "$(($blp - 1))" ] || (cat "$TMP/lnet_$1" && error "$2 is too short: $l")
11277 sed -n '1 p' "$TMP/lnet_$1" |grep -E "$4" >/dev/null ||
11278 (cat "$TMP/lnet_$1" && error "1st line of $2 misformatted")
11280 [ "$5" = "" ] || sed -n '2 p' "$TMP/lnet_$1" |grep -E "$5" >/dev/null ||
11281 (cat "$TMP/lnet_$1" && error "2nd line of $2 misformatted")
11283 # bail out if any unexpected line happened
11284 sed -n "$blp~1 p" "$TMP/lnet_$1" |grep -Ev "$3"
11285 [ "$?" != 0 ] || error "$2 misformatted"
11288 test_215() { # for bugs 18102, 21079, 21517
11289 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11290 local N='(0|[1-9][0-9]*)' # non-negative numeric
11291 local P='[1-9][0-9]*' # positive numeric
11292 local I='(0|-?[1-9][0-9]*|NA)' # any numeric (0 | >0 | <0) or NA if no value
11293 local NET='[a-z][a-z0-9]*' # LNET net like o2ib2
11294 local ADDR='[0-9.]+' # LNET addr like 10.0.0.1
11295 local NID="$ADDR@$NET" # LNET nid like 10.0.0.1@o2ib2
11297 local L1 # regexp for 1st line
11298 local L2 # regexp for 2nd line (optional)
11299 local BR # regexp for the rest (body)
11301 # /proc/sys/lnet/stats should look as 11 space-separated non-negative numerics
11302 BR="^$N $N $N $N $N $N $N $N $N $N $N$"
11303 create_lnet_proc_files "stats"
11304 check_lnet_proc_stats "stats.out" "/proc/sys/lnet/stats" "$BR"
11305 check_lnet_proc_stats "stats.sys" "lnet.stats" "$BR"
11306 remove_lnet_proc_files "stats"
11308 # /proc/sys/lnet/routes should look like this:
11309 # Routing disabled/enabled
11310 # net hops priority state router
11311 # where net is a string like tcp0, hops > 0, priority >= 0,
11312 # state is up/down,
11313 # router is a string like 192.168.1.1@tcp2
11314 L1="^Routing (disabled|enabled)$"
11315 L2="^net +hops +priority +state +router$"
11316 BR="^$NET +$N +(0|1) +(up|down) +$NID$"
11317 create_lnet_proc_files "routes"
11318 check_lnet_proc_entry "routes.out" "/proc/sys/lnet/routes" "$BR" "$L1" "$L2"
11319 check_lnet_proc_entry "routes.sys" "lnet.routes" "$BR" "$L1" "$L2"
11320 remove_lnet_proc_files "routes"
11322 # /proc/sys/lnet/routers should look like this:
11323 # ref rtr_ref alive_cnt state last_ping ping_sent deadline down_ni router
11324 # where ref > 0, rtr_ref > 0, alive_cnt >= 0, state is up/down,
11325 # last_ping >= 0, ping_sent is boolean (0/1), deadline and down_ni are
11326 # numeric (0 or >0 or <0), router is a string like 192.168.1.1@tcp2
11327 L1="^ref +rtr_ref +alive_cnt +state +last_ping +ping_sent +deadline +down_ni +router$"
11328 BR="^$P +$P +$N +(up|down) +$N +(0|1) +$I +$I +$NID$"
11329 create_lnet_proc_files "routers"
11330 check_lnet_proc_entry "routers.out" "/proc/sys/lnet/routers" "$BR" "$L1"
11331 check_lnet_proc_entry "routers.sys" "lnet.routers" "$BR" "$L1"
11332 remove_lnet_proc_files "routers"
11334 # /proc/sys/lnet/peers should look like this:
11335 # nid refs state last max rtr min tx min queue
11336 # where nid is a string like 192.168.1.1@tcp2, refs > 0,
11337 # state is up/down/NA, max >= 0. last, rtr, min, tx, min are
11338 # numeric (0 or >0 or <0), queue >= 0.
11339 L1="^nid +refs +state +last +max +rtr +min +tx +min +queue$"
11340 BR="^$NID +$P +(up|down|NA) +$I +$N +$I +$I +$I +$I +$N$"
11341 create_lnet_proc_files "peers"
11342 check_lnet_proc_entry "peers.out" "/proc/sys/lnet/peers" "$BR" "$L1"
11343 check_lnet_proc_entry "peers.sys" "lnet.peers" "$BR" "$L1"
11344 remove_lnet_proc_files "peers"
11346 # /proc/sys/lnet/buffers should look like this:
11347 # pages count credits min
11348 # where pages >=0, count >=0, credits and min are numeric (0 or >0 or <0)
11349 L1="^pages +count +credits +min$"
11350 BR="^ +$N +$N +$I +$I$"
11351 create_lnet_proc_files "buffers"
11352 check_lnet_proc_entry "buffers.out" "/proc/sys/lnet/buffers" "$BR" "$L1"
11353 check_lnet_proc_entry "buffers.sys" "lnet.buffers" "$BR" "$L1"
11354 remove_lnet_proc_files "buffers"
11356 # /proc/sys/lnet/nis should look like this:
11357 # nid status alive refs peer rtr max tx min
11358 # where nid is a string like 192.168.1.1@tcp2, status is up/down,
11359 # alive is numeric (0 or >0 or <0), refs >= 0, peer >= 0,
11360 # rtr >= 0, max >=0, tx and min are numeric (0 or >0 or <0).
11361 L1="^nid +status +alive +refs +peer +rtr +max +tx +min$"
11362 BR="^$NID +(up|down) +$I +$N +$N +$N +$N +$I +$I$"
11363 create_lnet_proc_files "nis"
11364 check_lnet_proc_entry "nis.out" "/proc/sys/lnet/nis" "$BR" "$L1"
11365 check_lnet_proc_entry "nis.sys" "lnet.nis" "$BR" "$L1"
11366 remove_lnet_proc_files "nis"
11368 # can we successfully write to /proc/sys/lnet/stats?
11369 echo "0" >/proc/sys/lnet/stats || error "cannot write to /proc/sys/lnet/stats"
11370 sysctl -w lnet.stats=0 || error "cannot write to lnet.stats"
11372 run_test 215 "/proc/sys/lnet exists and has proper content - bugs 18102, 21079, 21517"
11374 test_216() { # bug 20317
11375 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11376 remote_ost_nodsh && skip "remote OST with nodsh" && return
11379 local facets=$(get_facets OST)
11380 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
11382 save_lustre_params client "osc.*.contention_seconds" > $p
11383 save_lustre_params $facets \
11384 "ldlm.namespaces.filter-*.max_nolock_bytes" >> $p
11385 save_lustre_params $facets \
11386 "ldlm.namespaces.filter-*.contended_locks" >> $p
11387 save_lustre_params $facets \
11388 "ldlm.namespaces.filter-*.contention_seconds" >> $p
11391 # agressive lockless i/o settings
11392 for node in $(osts_nodes); do
11393 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'
11395 lctl set_param -n osc.*.contention_seconds 60
11397 $DIRECTIO write $DIR/$tfile 0 10 4096
11398 $CHECKSTAT -s 40960 $DIR/$tfile
11400 # disable lockless i/o
11401 for node in $(osts_nodes); do
11402 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'
11404 lctl set_param -n osc.*.contention_seconds 0
11407 dd if=/dev/zero of=$DIR/$tfile count=0
11408 $CHECKSTAT -s 0 $DIR/$tfile
11410 restore_lustre_params <$p
11414 run_test 216 "check lockless direct write works and updates file size and kms correctly"
11416 test_217() { # bug 22430
11417 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11421 for node in $(nodes_list); do
11422 nid=$(host_nids_address $node $NETTYPE)
11423 if [[ $nid = *-* ]] ; then
11424 echo "lctl ping $nid@$NETTYPE"
11425 lctl ping $nid@$NETTYPE
11427 echo "skipping $node (no hyphen detected)"
11431 run_test 217 "check lctl ping for hostnames with hiphen ('-')"
11434 # do directio so as not to populate the page cache
11435 log "creating a 10 Mb file"
11436 $MULTIOP $DIR/$tfile oO_CREAT:O_DIRECT:O_RDWR:w$((10*1048576))c || error "multiop failed while creating a file"
11437 log "starting reads"
11438 dd if=$DIR/$tfile of=/dev/null bs=4096 &
11439 log "truncating the file"
11440 $MULTIOP $DIR/$tfile oO_TRUNC:c || error "multiop failed while truncating the file"
11442 kill %+ || true # reads might have finished
11443 echo "wait until dd is finished"
11445 log "removing the temporary file"
11446 rm -rf $DIR/$tfile || error "tmp file removal failed"
11448 run_test 218 "parallel read and truncate should not deadlock ======================="
11451 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11452 # write one partial page
11453 dd if=/dev/zero of=$DIR/$tfile bs=1024 count=1
11454 # set no grant so vvp_io_commit_write will do sync write
11455 $LCTL set_param fail_loc=0x411
11456 # write a full page at the end of file
11457 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 seek=1 conv=notrunc
11459 $LCTL set_param fail_loc=0
11460 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 seek=3
11461 $LCTL set_param fail_loc=0x411
11462 dd if=/dev/zero of=$DIR/$tfile bs=1024 count=1 seek=2 conv=notrunc
11465 dd if=/dev/zero of=$DIR/$tfile-2 bs=1024 count=1
11466 $CHECKSTAT -s 1024 $DIR/$tfile-2 || error "checkstat wrong size"
11468 run_test 219 "LU-394: Write partial won't cause uncontiguous pages vec at LND"
11470 test_220() { #LU-325
11471 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11472 remote_ost_nodsh && skip "remote OST with nodsh" && return
11475 test_mkdir -p $DIR/$tdir
11476 local OST=$(lfs osts | grep ${OSTIDX}": " | \
11477 awk '{print $2}' | sed -e 's/_UUID$//')
11480 local mdtosc_proc1=$(get_mdtosc_proc_path $SINGLEMDS $OST)
11481 local last_id=$(do_facet $SINGLEMDS lctl get_param -n \
11482 osc.$mdtosc_proc1.prealloc_last_id)
11483 local next_id=$(do_facet $SINGLEMDS lctl get_param -n \
11484 osc.$mdtosc_proc1.prealloc_next_id)
11488 do_facet ost$((OSTIDX + 1)) lctl set_param fail_val=-1
11489 #define OBD_FAIL_OST_ENOINO 0x229
11490 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=0x229
11491 do_facet mgs $LCTL pool_new $FSNAME.$TESTNAME || return 1
11492 do_facet mgs $LCTL pool_add $FSNAME.$TESTNAME $OST || return 2
11494 $SETSTRIPE $DIR/$tdir -i $OSTIDX -c 1 -p $FSNAME.$TESTNAME
11496 MDSOBJS=$((last_id - next_id))
11497 echo "preallocated objects on MDS is $MDSOBJS" "($last_id - $next_id)"
11499 blocks=$($LFS df $MOUNT | awk '($1 == '$OSTIDX') { print $4 }')
11500 echo "OST still has $count kbytes free"
11502 echo "create $MDSOBJS files @next_id..."
11503 createmany -o $DIR/$tdir/f $MDSOBJS || return 3
11505 local last_id2=$(do_facet mds${MDSIDX} lctl get_param -n \
11506 osc.$mdtosc_proc1.prealloc_last_id)
11507 local next_id2=$(do_facet mds${MDSIDX} lctl get_param -n \
11508 osc.$mdtosc_proc1.prealloc_next_id)
11510 echo "after creation, last_id=$last_id2, next_id=$next_id2"
11515 do_facet ost$((OSTIDX + 1)) lctl set_param fail_val=0
11516 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=0
11518 do_facet mgs $LCTL pool_remove $FSNAME.$TESTNAME $OST || return 4
11519 do_facet mgs $LCTL pool_destroy $FSNAME.$TESTNAME || return 5
11520 echo "unlink $MDSOBJS files @$next_id..."
11521 unlinkmany $DIR/$tdir/f $MDSOBJS || return 6
11523 run_test 220 "preallocated MDS objects still used if ENOSPC from OST"
11526 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11527 dd if=`which date` of=$MOUNT/date oflag=sync
11528 chmod +x $MOUNT/date
11530 #define OBD_FAIL_LLITE_FAULT_TRUNC_RACE 0x1401
11531 $LCTL set_param fail_loc=0x80001401
11533 $MOUNT/date > /dev/null
11536 run_test 221 "make sure fault and truncate race to not cause OOM"
11539 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11541 test_mkdir -p $DIR/$tdir
11542 $SETSTRIPE -c 1 -i 0 $DIR/$tdir
11543 createmany -o $DIR/$tdir/$tfile 10
11544 cancel_lru_locks mdc
11545 cancel_lru_locks osc
11546 #define OBD_FAIL_LDLM_AGL_DELAY 0x31a
11547 $LCTL set_param fail_loc=0x31a
11548 ls -l $DIR/$tdir > /dev/null || error "AGL for ls failed"
11549 $LCTL set_param fail_loc=0
11552 run_test 222a "AGL for ls should not trigger CLIO lock failure ================"
11555 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11557 test_mkdir -p $DIR/$tdir
11558 $SETSTRIPE -c 1 -i 0 $DIR/$tdir
11559 createmany -o $DIR/$tdir/$tfile 10
11560 cancel_lru_locks mdc
11561 cancel_lru_locks osc
11562 #define OBD_FAIL_LDLM_AGL_DELAY 0x31a
11563 $LCTL set_param fail_loc=0x31a
11564 rm -r $DIR/$tdir || "AGL for rmdir failed"
11565 $LCTL set_param fail_loc=0
11567 run_test 222b "AGL for rmdir should not trigger CLIO lock failure ============="
11570 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11572 test_mkdir -p $DIR/$tdir
11573 $SETSTRIPE -c 1 -i 0 $DIR/$tdir
11574 createmany -o $DIR/$tdir/$tfile 10
11575 cancel_lru_locks mdc
11576 cancel_lru_locks osc
11577 #define OBD_FAIL_LDLM_AGL_NOLOCK 0x31b
11578 $LCTL set_param fail_loc=0x31b
11579 ls -l $DIR/$tdir > /dev/null || error "reenqueue failed"
11580 $LCTL set_param fail_loc=0
11583 run_test 223 "osc reenqueue if without AGL lock granted ======================="
11585 test_224a() { # LU-1039, MRP-303
11586 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11587 #define OBD_FAIL_PTLRPC_CLIENT_BULK_CB 0x508
11588 $LCTL set_param fail_loc=0x508
11589 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 conv=fsync
11590 $LCTL set_param fail_loc=0
11593 run_test 224a "Don't panic on bulk IO failure"
11595 test_224b() { # LU-1039, MRP-303
11596 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11597 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1
11598 cancel_lru_locks osc
11599 #define OBD_FAIL_PTLRPC_CLIENT_BULK_CB2 0x515
11600 $LCTL set_param fail_loc=0x515
11601 dd of=/dev/null if=$DIR/$tfile bs=4096 count=1
11602 $LCTL set_param fail_loc=0
11605 run_test 224b "Don't panic on bulk IO failure"
11607 MDSSURVEY=${MDSSURVEY:-$(which mds-survey 2>/dev/null || true)}
11609 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11610 if [ -z ${MDSSURVEY} ]; then
11611 skip_env "mds-survey not found" && return
11614 [ $MDSCOUNT -ge 2 ] &&
11615 skip "skipping now for more than one MDT" && return
11617 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.51) ] ||
11618 { skip "Need MDS version at least 2.2.51"; return; }
11620 local mds=$(facet_host $SINGLEMDS)
11621 local target=$(do_nodes $mds 'lctl dl' | \
11622 awk "{if (\$2 == \"UP\" && \$3 == \"mdt\") {print \$4}}")
11624 local cmd1="file_count=1000 thrhi=4"
11625 local cmd2="dir_count=2 layer=mdd stripe_count=0"
11626 local cmd3="rslt_loc=${TMP} targets=\"$mds:$target\" $MDSSURVEY"
11627 local cmd="$cmd1 $cmd2 $cmd3"
11629 rm -f ${TMP}/mds_survey*
11631 eval $cmd || error "mds-survey with zero-stripe failed"
11632 cat ${TMP}/mds_survey*
11633 rm -f ${TMP}/mds_survey*
11635 run_test 225a "Metadata survey sanity with zero-stripe"
11638 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11640 if [ -z ${MDSSURVEY} ]; then
11641 skip_env "mds-survey not found" && return
11643 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.51) ] ||
11644 { skip "Need MDS version at least 2.2.51"; return; }
11646 if [ $($LCTL dl | grep -c osc) -eq 0 ]; then
11647 skip_env "Need to mount OST to test" && return
11650 [ $MDSCOUNT -ge 2 ] &&
11651 skip "skipping now for more than one MDT" && return
11652 local mds=$(facet_host $SINGLEMDS)
11653 local target=$(do_nodes $mds 'lctl dl' | \
11654 awk "{if (\$2 == \"UP\" && \$3 == \"mdt\") {print \$4}}")
11656 local cmd1="file_count=1000 thrhi=4"
11657 local cmd2="dir_count=2 layer=mdd stripe_count=1"
11658 local cmd3="rslt_loc=${TMP} targets=\"$mds:$target\" $MDSSURVEY"
11659 local cmd="$cmd1 $cmd2 $cmd3"
11661 rm -f ${TMP}/mds_survey*
11663 eval $cmd || error "mds-survey with stripe_count failed"
11664 cat ${TMP}/mds_survey*
11665 rm -f ${TMP}/mds_survey*
11667 run_test 225b "Metadata survey sanity with stripe_count = 1"
11669 mcreate_path2fid () {
11675 local path=$DIR/$tdir/$name
11680 $MCREATE --mode=$1 --major=$2 --minor=$3 $path ||
11681 error "cannot create $desc"
11683 fid=$($LFS path2fid $path | tr -d '[' | tr -d ']')
11685 [ $rc -ne 0 ] && error "cannot get fid of a $desc"
11687 fid_path=$($LFS fid2path $MOUNT $fid)
11689 [ $rc -ne 0 ] && error "cannot get path of $desc by $DIR $path $fid"
11691 [ "$path" == "$fid_path" ] ||
11692 error "fid2path returned $fid_path, expected $path"
11694 echo "pass with $path and $fid"
11699 mkdir -p $DIR/$tdir
11701 mcreate_path2fid 0010666 0 0 fifo "FIFO"
11702 mcreate_path2fid 0020666 1 3 null "character special file (null)"
11703 mcreate_path2fid 0020666 1 255 none "character special file (no device)"
11704 mcreate_path2fid 0040666 0 0 dir "directory"
11705 mcreate_path2fid 0060666 7 0 loop0 "block special file (loop)"
11706 mcreate_path2fid 0100666 0 0 file "regular file"
11707 mcreate_path2fid 0120666 0 0 link "symbolic link"
11708 mcreate_path2fid 0140666 0 0 sock "socket"
11710 run_test 226a "call path2fid and fid2path on files of all type"
11713 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
11717 mkdir -p $DIR/$tdir
11718 $LFS setdirstripe -i $MDTIDX $DIR/$tdir/remote_dir ||
11719 error "create remote directory failed"
11720 mcreate_path2fid 0010666 0 0 "remote_dir/fifo" "FIFO"
11721 mcreate_path2fid 0020666 1 3 "remote_dir/null" \
11722 "character special file (null)"
11723 mcreate_path2fid 0020666 1 255 "remote_dir/none" \
11724 "character special file (no device)"
11725 mcreate_path2fid 0040666 0 0 "remote_dir/dir" "directory"
11726 mcreate_path2fid 0060666 7 0 "remote_dir/loop0" \
11727 "block special file (loop)"
11728 mcreate_path2fid 0100666 0 0 "remote_dir/file" "regular file"
11729 mcreate_path2fid 0120666 0 0 "remote_dir/link" "symbolic link"
11730 mcreate_path2fid 0140666 0 0 "remote_dir/sock" "socket"
11732 run_test 226b "call path2fid and fid2path on files of all type under remote dir"
11734 # LU-1299 Executing or running ldd on a truncated executable does not
11735 # cause an out-of-memory condition.
11737 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11738 dd if=`which date` of=$MOUNT/date bs=1k count=1
11739 chmod +x $MOUNT/date
11741 $MOUNT/date > /dev/null
11742 ldd $MOUNT/date > /dev/null
11745 run_test 227 "running truncated executable does not cause OOM"
11747 # LU-1512 try to reuse idle OI blocks
11749 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11750 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
11751 skip "non-ldiskfs backend" && return
11753 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
11754 local myDIR=$DIR/$tdir
11757 #define OBD_FAIL_SEQ_EXHAUST 0x1002
11758 $LCTL set_param fail_loc=0x80001002
11759 createmany -o $myDIR/t- 10000
11760 $LCTL set_param fail_loc=0
11761 # The guard is current the largest FID holder
11763 local SEQ=$($LFS path2fid $myDIR/guard | awk -F ':' '{print $1}' |
11765 local IDX=$(($SEQ % 64))
11767 do_facet $SINGLEMDS sync
11768 # Make sure journal flushed.
11770 local blk1=$(do_facet $SINGLEMDS \
11771 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
11772 grep Blockcount | awk '{print $4}')
11774 # Remove old files, some OI blocks will become idle.
11775 unlinkmany $myDIR/t- 10000
11776 # Create new files, idle OI blocks should be reused.
11777 createmany -o $myDIR/t- 2000
11778 do_facet $SINGLEMDS sync
11779 # Make sure journal flushed.
11781 local blk2=$(do_facet $SINGLEMDS \
11782 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
11783 grep Blockcount | awk '{print $4}')
11785 [ $blk1 == $blk2 ] || error "old blk1=$blk1, new blk2=$blk2, unmatched!"
11787 run_test 228a "try to reuse idle OI blocks"
11790 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11791 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
11792 skip "non-ldiskfs backend" && return
11794 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
11795 local myDIR=$DIR/$tdir
11798 #define OBD_FAIL_SEQ_EXHAUST 0x1002
11799 $LCTL set_param fail_loc=0x80001002
11800 createmany -o $myDIR/t- 10000
11801 $LCTL set_param fail_loc=0
11802 # The guard is current the largest FID holder
11804 local SEQ=$($LFS path2fid $myDIR/guard | awk -F ':' '{print $1}' |
11806 local IDX=$(($SEQ % 64))
11808 do_facet $SINGLEMDS sync
11809 # Make sure journal flushed.
11811 local blk1=$(do_facet $SINGLEMDS \
11812 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
11813 grep Blockcount | awk '{print $4}')
11815 # Remove old files, some OI blocks will become idle.
11816 unlinkmany $myDIR/t- 10000
11819 stop $SINGLEMDS || error "Fail to stop MDT."
11821 start $SINGLEMDS $MDT_DEV $MDS_MOUNT_OPTS || error "Fail to start MDT."
11823 df $MOUNT || error "Fail to df."
11824 # Create new files, idle OI blocks should be reused.
11825 createmany -o $myDIR/t- 2000
11826 do_facet $SINGLEMDS sync
11827 # Make sure journal flushed.
11829 local blk2=$(do_facet $SINGLEMDS \
11830 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
11831 grep Blockcount | awk '{print $4}')
11833 [ $blk1 == $blk2 ] || error "old blk1=$blk1, new blk2=$blk2, unmatched!"
11835 run_test 228b "idle OI blocks can be reused after MDT restart"
11839 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11840 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
11841 skip "non-ldiskfs backend" && return
11843 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
11844 local myDIR=$DIR/$tdir
11847 #define OBD_FAIL_SEQ_EXHAUST 0x1002
11848 $LCTL set_param fail_loc=0x80001002
11849 # 20000 files can guarantee there are index nodes in the OI file
11850 createmany -o $myDIR/t- 20000
11851 $LCTL set_param fail_loc=0
11852 # The guard is current the largest FID holder
11854 local SEQ=$($LFS path2fid $myDIR/guard | awk -F ':' '{print $1}' |
11856 local IDX=$(($SEQ % 64))
11858 do_facet $SINGLEMDS sync
11859 # Make sure journal flushed.
11861 local blk1=$(do_facet $SINGLEMDS \
11862 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
11863 grep Blockcount | awk '{print $4}')
11865 # Remove old files, some OI blocks will become idle.
11866 unlinkmany $myDIR/t- 20000
11868 # The OI file should become empty now
11870 # Create new files, idle OI blocks should be reused.
11871 createmany -o $myDIR/t- 2000
11872 do_facet $SINGLEMDS sync
11873 # Make sure journal flushed.
11875 local blk2=$(do_facet $SINGLEMDS \
11876 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
11877 grep Blockcount | awk '{print $4}')
11879 [ $blk1 == $blk2 ] || error "old blk1=$blk1, new blk2=$blk2, unmatched!"
11881 run_test 228c "NOT shrink the last entry in OI index node to recycle idle leaf"
11883 test_229() { # LU-2482, LU-3448
11884 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.53) ] &&
11885 skip "No HSM support on MDS of $(get_lustre_version)," \
11886 "need 2.4.53 at least" && return
11887 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11888 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs" && return
11892 # Create a file with a released layout and stripe count 2.
11893 $MULTIOP $DIR/$tfile H2c ||
11894 error "failed to create file with released layout"
11896 $GETSTRIPE -v $DIR/$tfile
11898 local pattern=$($GETSTRIPE -L $DIR/$tfile)
11899 [ X"$pattern" = X"80000001" ] || error "pattern error ($pattern)"
11901 local stripe_count=$($GETSTRIPE -c $DIR/$tfile) || error "getstripe"
11902 [ $stripe_count -eq 2 ] || error "stripe count not 2 ($stripe_count)"
11903 stat $DIR/$tfile || error "failed to stat released file"
11905 chown $RUNAS_ID $DIR/$tfile ||
11906 error "chown $RUNAS_ID $DIR/$tfile failed"
11908 chgrp $RUNAS_ID $DIR/$tfile ||
11909 error "chgrp $RUNAS_ID $DIR/$tfile failed"
11911 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
11912 rm $DIR/$tfile || error "failed to remove released file"
11914 run_test 229 "getstripe/stat/rm/attr changes work on released files"
11917 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11918 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
11921 mkdir -p $DIR/$tdir/test_230_local
11922 local mdt_idx=$($GETSTRIPE -M $DIR/$tdir/test_230_local)
11923 [ $mdt_idx -ne 0 ] &&
11924 error "create local directory on wrong MDT $mdt_idx"
11926 $LFS mkdir -i $MDTIDX $DIR/$tdir/test_230 ||
11927 error "create remote directory failed"
11928 local mdt_idx=$($GETSTRIPE -M $DIR/$tdir/test_230)
11929 [ $mdt_idx -ne $MDTIDX ] &&
11930 error "create remote directory on wrong MDT $mdt_idx"
11932 createmany -o $DIR/$tdir/test_230/t- 10 ||
11933 error "create files on remote directory failed"
11934 mdt_idx=$($GETSTRIPE -M $DIR/$tdir/test_230/t-0)
11935 [ $mdt_idx -ne $MDTIDX ] && error "create files on wrong MDT $mdt_idx"
11936 rm -r $DIR/$tdir || error "unlink remote directory failed"
11938 run_test 230a "Create remote directory and files under the remote directory"
11941 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11942 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
11949 local migrate_dir=$DIR/$tdir/migrate_dir
11950 local other_dir=$DIR/$tdir/other_dir
11952 mkdir -p $migrate_dir
11953 mkdir -p $other_dir
11954 for ((i=0; i<10; i++)); do
11955 mkdir -p $migrate_dir/dir_${i}
11956 createmany -o $migrate_dir/dir_${i}/f 10 ||
11957 error "create files under remote dir failed $i"
11960 cp /etc/passwd $migrate_dir/$tfile
11961 cp /etc/passwd $other_dir/$tfile
11962 mkdir -p $migrate_dir/dir_default_stripe2
11963 $LFS setstripe -c 2 $migrate_dir/dir_default_stripe2
11964 $LFS setstripe -c 2 $migrate_dir/${tfile}_stripe2
11966 mkdir -p $other_dir
11967 ln $migrate_dir/$tfile $other_dir/luna
11968 ln $migrate_dir/$tfile $migrate_dir/sofia
11969 ln $other_dir/$tfile $migrate_dir/david
11970 ln -s $migrate_dir/$tfile $other_dir/zachary
11971 ln -s $migrate_dir/$tfile $migrate_dir/${tfile}_ln
11972 ln -s $other_dir/$tfile $migrate_dir/${tfile}_ln_other
11974 $LFS mv -v -M $MDTIDX $migrate_dir ||
11975 error "migrate remote dir error"
11977 echo "migratate to MDT1, then checking.."
11978 for ((i=0; i<10; i++)); do
11979 for file in $(find $migrate_dir/dir_${i}); do
11980 mdt_index=$($LFS getstripe -M $file)
11981 [ $mdt_index == $MDTIDX ] ||
11982 error "$file is not on MDT${MDTIDX}"
11986 # the multiple link file should still in MDT0
11987 mdt_index=$($LFS getstripe -M $migrate_dir/$tfile)
11988 [ $mdt_index == 0 ] ||
11989 error "$file is not on MDT${MDTIDX}"
11991 diff /etc/passwd $migrate_dir/$tfile ||
11992 error "$tfile different after migration"
11994 diff /etc/passwd $other_dir/luna ||
11995 error "luna different after migration"
11997 diff /etc/passwd $migrate_dir/sofia ||
11998 error "sofia different after migration"
12000 diff /etc/passwd $migrate_dir/david ||
12001 error "david different after migration"
12003 diff /etc/passwd $other_dir/zachary ||
12004 error "zachary different after migration"
12006 diff /etc/passwd $migrate_dir/${tfile}_ln ||
12007 error "${tfile}_ln different after migration"
12009 diff /etc/passwd $migrate_dir/${tfile}_ln_other ||
12010 error "${tfile}_ln_other different after migration"
12012 stripe_count=$($LFS getstripe -c $migrate_dir/dir_default_stripe2)
12013 [ $stripe_count = 2 ] ||
12014 error "dir strpe_count $d != 2 after migration."
12016 stripe_count=$($LFS getstripe -c $migrate_dir/${tfile}_stripe2)
12017 [ $stripe_count = 2 ] ||
12018 error "file strpe_count $d != 2 after migration."
12020 #migrate back to MDT0
12022 $LFS mv -v -M $MDTIDX $migrate_dir ||
12023 error "migrate remote dir error"
12025 echo "migrate back to MDT0, checking.."
12026 for file in $(find $migrate_dir); do
12027 mdt_index=$($LFS getstripe -M $file)
12028 [ $mdt_index == $MDTIDX ] ||
12029 error "$file is not on MDT${MDTIDX}"
12032 diff /etc/passwd ${migrate_dir}/$tfile ||
12033 error "$tfile different after migration"
12035 diff /etc/passwd ${other_dir}/luna ||
12036 error "luna different after migration"
12038 diff /etc/passwd ${migrate_dir}/sofia ||
12039 error "sofia different after migration"
12041 diff /etc/passwd ${other_dir}/zachary ||
12042 error "zachary different after migration"
12044 diff /etc/passwd $migrate_dir/${tfile}_ln ||
12045 error "${tfile}_ln different after migration"
12047 diff /etc/passwd $migrate_dir/${tfile}_ln_other ||
12048 error "${tfile}_ln_other different after migration"
12050 stripe_count=$($LFS getstripe -c ${migrate_dir}/dir_default_stripe2)
12051 [ $stripe_count = 2 ] ||
12052 error "dir strpe_count $d != 2 after migration."
12054 stripe_count=$($LFS getstripe -c ${migrate_dir}/${tfile}_stripe2)
12055 [ $stripe_count = 2 ] ||
12056 error "file strpe_count $d != 2 after migration."
12058 rm -rf $DIR/$tdir || error "rm dir failed after migration"
12060 run_test 230b "migrate directory"
12063 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12064 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
12069 #If migrating directory fails in the middle, all entries of
12070 #the directory is still accessiable.
12071 mkdir -p $DIR/$tdir
12073 createmany -o $DIR/$tdir/f 10 ||
12074 error "create files under ${tdir} failed"
12076 #failed after migrating 5 entries
12077 #OBD_FAIL_MIGRATE_ENTRIES 0x1801
12078 do_facet mds1 lctl set_param fail_loc=0x20001801
12079 do_facet mds1 lctl set_param fail_val=5
12080 local t=`ls $DIR/$tdir | wc -l`
12081 $LFS mv -M $MDTIDX $DIR/$tdir &&
12082 error "migrate should failed after 5 entries"
12083 local u=`ls $DIR/$tdir | wc -l`
12084 [ "$u" == "$t" ] || error "$u != $t during migration"
12086 for file in $(find $DIR/$tdir); do
12087 stat $file || error "stat $file failed"
12090 do_facet mds1 lctl set_param fail_loc=0
12091 do_facet mds1 lctl set_param fail_val=0
12093 $LFS mv -M $MDTIDX $DIR/$tdir ||
12094 error "migrate open files should failed with open files"
12096 echo "Finish migration, then checking.."
12097 for file in $(find $DIR/$tdir); do
12098 mdt_index=$($LFS getstripe -M $file)
12099 [ $mdt_index == $MDTIDX ] ||
12100 error "$file is not on MDT${MDTIDX}"
12103 rm -rf $DIR/$tdir || error "rm dir failed after migration"
12105 run_test 230c "check directory accessiblity if migration is failed"
12108 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12109 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
12115 mkdir -p $DIR/$tdir
12117 for ((i=0; i<100; i++)); do
12118 mkdir -p $DIR/$tdir/dir_${i}
12119 createmany -o $DIR/$tdir/dir_${i}/f 100 ||
12120 error "create files under remote dir failed $i"
12123 $LFS mv -M $MDTIDX -v $DIR/$tdir || error "migrate remote dir error"
12125 echo "Finish migration, then checking.."
12126 for file in $(find $DIR/$tdir); do
12127 mdt_index=$($LFS getstripe -M $file)
12128 [ $mdt_index == $MDTIDX ] ||
12129 error "$file is not on MDT${MDTIDX}"
12132 rm -rf $DIR/$tdir || error "rm dir failed after migration"
12134 run_test 230d "check migrate big directory"
12138 # For simplicity this test assumes that max_pages_per_rpc
12139 # is the same across all OSCs
12140 local max_pages=$($LCTL get_param -n osc.*.max_pages_per_rpc | head -n1)
12141 local bulk_size=$((max_pages * 4096))
12143 mkdir -p $DIR/$tdir
12145 # clear the OSC stats
12146 $LCTL set_param osc.*.stats=0 &>/dev/null
12148 # Client writes $bulk_size - there must be 1 rpc for $max_pages.
12149 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=$bulk_size count=1 \
12150 oflag=direct &>/dev/null || error "dd failed"
12152 local nrpcs=$($LCTL get_param osc.*.stats |awk '/ost_write/ {print $2}')
12153 if [ x$nrpcs != "x1" ]; then
12154 error "found $nrpc ost_write RPCs, not 1 as expected"
12157 # Drop the OSC cache, otherwise we will read from it
12158 cancel_lru_locks osc
12160 # clear the OSC stats
12161 $LCTL set_param osc.*.stats=0 &>/dev/null
12163 # Client reads $bulk_size.
12164 dd if=$DIR/$tdir/$tfile of=/dev/null bs=$bulk_size count=1 \
12165 iflag=direct &>/dev/null || error "dd failed"
12167 nrpcs=$($LCTL get_param osc.*.stats | awk '/ost_read/ { print $2 }')
12168 if [ x$nrpcs != "x1" ]; then
12169 error "found $nrpc ost_read RPCs, not 1 as expected"
12172 run_test 231a "checking that reading/writing of BRW RPC size results in one RPC"
12175 mkdir -p $DIR/$tdir
12177 for i in {0..1023}; do
12178 dd if=/dev/zero of=$DIR/$tdir/$tfile conv=notrunc \
12179 seek=$((2 * i)) bs=4096 count=1 &>/dev/null ||
12180 error "dd of=$DIR/$tdir/$tfile seek=$((2 * i)) failed"
12184 run_test 231b "must not assert on fully utilized OST request buffer"
12187 mkdir -p $DIR/$tdir
12188 #define OBD_FAIL_LDLM_OST_LVB 0x31c
12189 $LCTL set_param fail_loc=0x31c
12191 # ignore dd failure
12192 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=1 || true
12194 $LCTL set_param fail_loc=0
12195 umount_client $MOUNT || error "umount failed"
12196 mount_client $MOUNT || error "mount failed"
12198 run_test 232 "failed lock should not block umount"
12201 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.3.64) ] ||
12202 { skip "Need MDS version at least 2.3.64"; return; }
12204 local fid=$($LFS path2fid $MOUNT)
12205 stat $MOUNT/.lustre/fid/$fid > /dev/null ||
12206 error "cannot access $MOUNT using its FID '$fid'"
12208 run_test 233a "checking that OBF of the FS root succeeds"
12211 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.5.90) ] ||
12212 { skip "Need MDS version at least 2.5.90"; return; }
12214 local fid=$($LFS path2fid $MOUNT/.lustre)
12215 stat $MOUNT/.lustre/fid/$fid > /dev/null ||
12216 error "cannot access $MOUNT/.lustre using its FID '$fid'"
12218 fid=$($LFS path2fid $MOUNT/.lustre/fid)
12219 stat $MOUNT/.lustre/fid/$fid > /dev/null ||
12220 error "cannot access $MOUNT/.lustre/fid using its FID '$fid'"
12222 run_test 233b "checking that OBF of the FS .lustre succeeds"
12225 local p="$TMP/sanityN-$TESTNAME.parameters"
12226 save_lustre_params client "llite.*.xattr_cache" > $p
12227 lctl set_param llite.*.xattr_cache 1 ||
12228 { skip "xattr cache is not supported"; return 0; }
12230 mkdir -p $DIR/$tdir || error "mkdir failed"
12231 touch $DIR/$tdir/$tfile || error "touch failed"
12232 # OBD_FAIL_LLITE_XATTR_ENOMEM
12233 $LCTL set_param fail_loc=0x1405
12234 if [ ! -f /etc/SuSE-release ]; then
12235 # attr pre-2.4.44-7 had a bug with rc
12236 # LU-3703 - SLES clients have older attr
12237 getfattr -n user.attr $DIR/$tdir/$tfile &&
12238 error "getfattr should have failed with ENOMEM"
12240 $LCTL set_param fail_loc=0x0
12243 restore_lustre_params < $p
12246 run_test 234 "xattr cache should not crash on ENOMEM"
12249 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.52) ] &&
12250 skip "Need MDS version at least 2.4.52" && return
12251 flock_deadlock $DIR/$tfile
12256 124) error "process hangs on a deadlock"
12258 *) error "error executing flock_deadlock $DIR/$tfile"
12262 run_test 235 "LU-1715: flock deadlock detection does not work properly"
12266 check_swap_layouts_support && return 0
12267 test_mkdir -p -c1 $DIR/$tdir || error "mkdir $tdir failed"
12269 local ref1=/etc/passwd
12270 local ref2=/etc/group
12271 local file1=$DIR/$tdir/f1
12272 local file2=$DIR/$tdir/f2
12274 $SETSTRIPE -c 1 $file1 || error "cannot setstripe on '$file1': rc = $?"
12275 cp $ref1 $file1 || error "cp $ref1 $file1 failed: rc = $?"
12276 $SETSTRIPE -c 2 $file2 || error "cannot setstripe on '$file2': rc = $?"
12277 cp $ref2 $file2 || error "cp $ref2 $file2 failed: rc = $?"
12278 local fd=$(free_fd)
12279 local cmd="exec $fd<>$file2"
12282 $LFS swap_layouts $file1 /proc/self/fd/${fd} ||
12283 error "cannot swap layouts of '$file1' and /proc/self/fd/${fd}"
12286 cmp $ref2 $file1 || error "content compare failed ($ref2 != $file1)"
12291 run_test 236 "Layout swap on open unlinked file"
12293 # test to verify file handle related system calls
12294 # (name_to_handle_at/open_by_handle_at)
12295 # The new system calls are supported in glibc >= 2.14.
12298 echo "Test file_handle syscalls" > $DIR/$tfile
12299 check_fhandle_syscalls $DIR/$tfile ||
12300 error "check_fhandle_syscalls failed"
12302 run_test 237 "Verify name_to_handle_at/open_by_handle_at syscalls"
12304 # LU-4659 linkea consistency
12307 ln $DIR/$tfile $DIR/$tfile.lnk
12308 touch $DIR/$tfile.new
12309 mv $DIR/$tfile.new $DIR/$tfile
12310 local fid1=$(lfs path2fid $DIR/$tfile)
12311 local fid2=$(lfs path2fid $DIR/$tfile.lnk)
12312 local path1=$(lfs fid2path $FSNAME $fid1)
12313 [ $tfile == $path1 ] || error "linkea inconsistent: $tfile $fid1 $path1"
12314 local path2=$(lfs fid2path $FSNAME $fid2)
12315 [ $tfile.lnk == $path2 ] ||
12316 error "linkea inconsistent: $tfile.lnk $fid2 $path2!"
12319 run_test 238 "Verify linkea consistency"
12321 test_striped_dir() {
12326 mkdir -p $DIR/$tdir
12327 $LFS setdirstripe -i $mdt_index -c 2 -t all_char $DIR/$tdir/striped_dir ||
12328 error "set striped dir error"
12330 stripe_count=$($LFS getdirstripe -c $DIR/$tdir/striped_dir)
12331 if [ "$stripe_count" != "2" ]; then
12332 error "stripe_count is $stripe_count, expect 2"
12335 stripe_index=$($LFS getdirstripe -i $DIR/$tdir/striped_dir)
12336 if [ "$stripe_index" != "$mdt_index" ]; then
12337 error "stripe_index is $stripe_index, expect $mdt_index"
12340 [ $(stat -c%h $DIR/$tdir/striped_dir) == '2' ] ||
12341 error "nlink error after create striped dir"
12343 mkdir $DIR/$tdir/striped_dir/a
12344 mkdir $DIR/$tdir/striped_dir/b
12346 stat $DIR/$tdir/striped_dir/a ||
12347 error "create dir under striped dir failed"
12348 stat $DIR/$tdir/striped_dir/b ||
12349 error "create dir under striped dir failed"
12351 [ $(stat -c%h $DIR/$tdir/striped_dir) == '4' ] ||
12352 error "nlink error after mkdir"
12354 rmdir $DIR/$tdir/striped_dir/a
12355 [ $(stat -c%h $DIR/$tdir/striped_dir) == '3' ] ||
12356 error "nlink error after rmdir"
12358 rmdir $DIR/$tdir/striped_dir/b
12359 [ $(stat -c%h $DIR/$tdir/striped_dir) == '2' ] ||
12360 error "nlink error after rmdir"
12362 rmdir $DIR/$tdir/striped_dir ||
12363 error "rmdir striped dir error"
12368 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12369 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
12371 test_striped_dir 0 || error "failed on striped dir on MDT0"
12372 test_striped_dir 1 || error "failed on striped dir on MDT0"
12374 run_test 300a "basic striped dir sanity test"
12377 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12378 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
12384 test_mkdir $DIR/$tdir || error "mkdir fail"
12385 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir ||
12386 error "set striped dir error"
12387 for ((i=0; i<10; i++)); do
12388 mtime1=$(stat -c %Y $DIR/$tdir/striped_dir)
12390 touch $DIR/$tdir/striped_dir/file_$i ||
12391 error "touch error $i"
12392 mtime2=$(stat -c %Y $DIR/$tdir/striped_dir)
12393 [ $mtime1 -eq $mtime2 ] &&
12394 error "mtime not change after create"
12396 rm -f $DIR/$tdir/striped_dir/file_$i ||
12397 error "unlink error $i"
12398 mtime3=$(stat -c %Y $DIR/$tdir/striped_dir)
12399 [ $mtime2 -eq $mtime3 ] &&
12400 error "mtime did not change after unlink"
12404 run_test 300b "check ctime/mtime for striped dir"
12407 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12408 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
12411 mkdir -p $DIR/$tdir
12412 $LFS setdirstripe -i 0 -c 2 $DIR/$tdir/striped_dir ||
12413 error "set striped dir error"
12415 chown $RUNAS_ID:$RUNAS_GID $DIR/$tdir/striped_dir ||
12416 error "chown striped dir failed"
12418 $RUNAS createmany -o $DIR/$tdir/striped_dir/f 5000 ||
12419 error "create 5k files failed"
12421 file_count=$(ls $DIR/$tdir/striped_dir | wc -l)
12423 [ "$file_count" = 5000 ] || error "file count $file_count != 5000"
12427 run_test 300c "chown && check ls under striped directory"
12430 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12431 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
12435 mkdir -p $DIR/$tdir
12436 $SETSTRIPE -c 2 $DIR/$tdir
12438 #local striped directory
12439 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir ||
12440 error "set striped dir error"
12441 createmany -o $DIR/$tdir/striped_dir/f 10 ||
12442 error "create 10 files failed"
12444 #remote striped directory
12445 $LFS setdirstripe -i 1 -c 2 $DIR/$tdir/remote_striped_dir ||
12446 error "set striped dir error"
12447 createmany -o $DIR/$tdir/remote_striped_dir/f 10 ||
12448 error "create 10 files failed"
12450 for file in $(find $DIR/$tdir); do
12451 stripe_count=$($GETSTRIPE -c $file)
12452 [ $stripe_count -eq 2 ] ||
12453 error "wrong stripe $stripe_count for $file"
12458 run_test 300d "check default stripe under striped directory"
12461 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12462 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
12466 mkdir -p $DIR/$tdir
12468 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir ||
12469 error "set striped dir error"
12471 touch $DIR/$tdir/striped_dir/a
12472 touch $DIR/$tdir/striped_dir/b
12473 touch $DIR/$tdir/striped_dir/c
12475 mkdir $DIR/$tdir/striped_dir/dir_a
12476 mkdir $DIR/$tdir/striped_dir/dir_b
12477 mkdir $DIR/$tdir/striped_dir/dir_c
12479 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir/stp_a ||
12480 error "set striped dir under striped dir error"
12482 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir/stp_b ||
12483 error "set striped dir under striped dir error"
12485 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir/stp_c ||
12486 error "set striped dir under striped dir error"
12488 mrename $DIR/$tdir/striped_dir/a $DIR/$tdir/striped_dir/b &&
12489 error "rename file under striped dir should fail"
12491 mrename $DIR/$tdir/striped_dir/dir_a $DIR/$tdir/striped_dir/dir_b &&
12492 error "rename dir under striped dir should fail"
12494 mrename $DIR/$tdir/striped_dir/stp_a $DIR/$tdir/striped_dir/stp_b &&
12495 error "rename dir under different stripes should fail"
12497 mrename $DIR/$tdir/striped_dir/a $DIR/$tdir/striped_dir/c ||
12498 error "rename file under striped dir should succeed"
12500 mrename $DIR/$tdir/striped_dir/dir_a $DIR/$tdir/striped_dir/dir_c ||
12501 error "rename dir under striped dir should succeed"
12505 run_test 300e "check rename under striped directory"
12508 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12509 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
12514 mkdir -p $DIR/$tdir
12516 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir ||
12517 error "set striped dir error"
12519 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir1 ||
12520 error "set striped dir error"
12522 touch $DIR/$tdir/striped_dir/a
12523 mkdir $DIR/$tdir/striped_dir/dir_a
12524 $LFS setdirstripe -i 0 -c 2 $DIR/$tdir/striped_dir/stp_a ||
12525 error "create striped dir under striped dir fails"
12527 touch $DIR/$tdir/striped_dir1/b
12528 mkdir $DIR/$tdir/striped_dir1/dir_b
12529 $LFS setdirstripe -i 0 -c 2 $DIR/$tdir/striped_dir/stp_b ||
12530 error "create striped dir under striped dir fails"
12532 mrename $DIR/$tdir/striped_dir/a $DIR/$tdir/striped_dir1/b &&
12533 error "rename file under different striped dir should fail"
12535 mrename $DIR/$tdir/striped_dir/dir_a $DIR/$tdir/striped_dir1/dir_b &&
12536 error "rename dir under different striped dir should fail"
12538 mrename $DIR/$tdir/striped_dir/stp_a $DIR/$tdir/striped_dir1/stp_b &&
12539 error "rename striped dir under diff striped dir should fail"
12541 mrename $DIR/$tdir/striped_dir/a $DIR/$tdir/striped_dir1/a ||
12542 error "rename file under diff striped dirs fails"
12544 mrename $DIR/$tdir/striped_dir/dir_a $DIR/$tdir/striped_dir1/dir_a ||
12545 error "rename dir under diff striped dirs fails"
12549 run_test 300f "check rename cross striped directory"
12552 # tests that do cleanup/setup should be run at the end
12556 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12558 #define OBD_FAIL_MGC_PAUSE_PROCESS_LOG 0x903
12559 $LCTL set_param fail_loc=0x903
12560 # cancel_lru_locks mgc - does not work due to lctl set_param syntax
12561 for ls in /proc/fs/lustre/ldlm/namespaces/MGC*/lru_size; do
12564 FAIL_ON_ERROR=true cleanup
12565 FAIL_ON_ERROR=true setup
12567 run_test 900 "umount should not race with any mgc requeue thread"
12570 [ -f $EXT2_DEV ] && rm $EXT2_DEV || true
12571 check_and_cleanup_lustre
12572 if [ "$I_MOUNTED" != "yes" ]; then
12573 lctl set_param debug="$OLDDEBUG" 2> /dev/null || true