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
42 CHECKSTAT=${CHECKSTAT:-"checkstat -v"}
43 CREATETEST=${CREATETEST:-createtest}
45 LFIND=${LFIND:-"$LFS find"}
46 LVERIFY=${LVERIFY:-ll_dirstripe_verify}
48 MCREATE=${MCREATE:-mcreate}
49 OPENFILE=${OPENFILE:-openfile}
50 OPENUNLINK=${OPENUNLINK:-openunlink}
51 export MULTIOP=${MULTIOP:-multiop}
52 READS=${READS:-"reads"}
53 MUNLINK=${MUNLINK:-munlink}
54 SOCKETSERVER=${SOCKETSERVER:-socketserver}
55 SOCKETCLIENT=${SOCKETCLIENT:-socketclient}
56 MEMHOG=${MEMHOG:-memhog}
57 DIRECTIO=${DIRECTIO:-directio}
58 ACCEPTOR_PORT=${ACCEPTOR_PORT:-988}
59 UMOUNT=${UMOUNT:-"umount -d"}
61 CHECK_GRANT=${CHECK_GRANT:-"yes"}
62 GRANT_CHECK_LIST=${GRANT_CHECK_LIST:-""}
63 export PARALLEL=${PARALLEL:-"no"}
65 export NAME=${NAME:-local}
72 LUSTRE=${LUSTRE:-$(cd $(dirname $0)/..; echo $PWD)}
73 LUSTRE_TESTS_API_DIR=${LUSTRE_TESTS_API_DIR:-${LUSTRE}/tests/clientapi}
74 . $LUSTRE/tests/test-framework.sh
76 . ${CONFIG:=$LUSTRE/tests/cfg/${NAME}.sh}
79 [ "$SLOW" = "no" ] && EXCEPT_SLOW="24o 27m 64b 68 71 77f 78 115 124b 230d"
81 [ $(facet_fstype $SINGLEMDS) = "zfs" ] &&
82 # bug number for skipped test: LU-1593 LU-2610 LU-2833 LU-1957 LU-2805
83 ALWAYS_EXCEPT="$ALWAYS_EXCEPT 34h 40 48a 180 184c"
89 pgrep ll_sa > /dev/null && { echo "There are ll_sa thread not exit!"; exit 20; }
90 cleanupall ${FORCE} $* || { echo "FAILed to clean up"; exit 20; }
99 check_kernel_version() {
101 GOT_VER=$(lctl get_param -n version | awk '/kernel:/ {print $2}')
103 patchless|patchless_client) return 0;;
104 *) [ $GOT_VER -ge $WANT_VER ] && return 0 ;;
106 log "test needs at least kernel version $WANT_VER, running $GOT_VER"
110 check_swap_layouts_support()
112 $LCTL get_param -n llite.*.sbi_flags | grep -q layout ||
113 { skip "Does not support layout lock."; return 0; }
117 if [ "$ONLY" == "cleanup" ]; then
122 check_and_setup_lustre
127 MDT0=$($LCTL get_param -n mdc.*.mds_server_uuid |
128 awk '{ gsub(/_UUID/,""); print $1 }' | head -n1)
129 LOVNAME=$($LCTL get_param -n llite.*.lov.common_name | tail -n 1)
130 OSTCOUNT=$($LCTL get_param -n lov.$LOVNAME.numobd)
131 STRIPECOUNT=$($LCTL get_param -n lov.$LOVNAME.stripecount)
132 STRIPESIZE=$($LCTL get_param -n lov.$LOVNAME.stripesize)
133 ORIGFREE=$($LCTL get_param -n lov.$LOVNAME.kbytesavail)
134 MAXFREE=${MAXFREE:-$((200000 * $OSTCOUNT))}
136 [ -f $DIR/d52a/foo ] && chattr -a $DIR/d52a/foo
137 [ -f $DIR/d52b/foo ] && chattr -i $DIR/d52b/foo
138 rm -rf $DIR/[Rdfs][0-9]*
140 # $RUNAS_ID may get set incorrectly somewhere else
141 [ $UID -eq 0 -a $RUNAS_ID -eq 0 ] && error "\$RUNAS_ID set to 0, but \$UID is also 0!"
143 check_runas_id $RUNAS_ID $RUNAS_GID $RUNAS
147 if [ "${ONLY}" = "MOUNT" ] ; then
148 echo "Lustre is up, please go on"
152 echo "preparing for tests involving mounts"
153 EXT2_DEV=${EXT2_DEV:-$TMP/SANITY.LOOP}
155 mke2fs -j -F $EXT2_DEV 8000 > /dev/null
156 echo # add a newline after mke2fs.
160 OLDDEBUG=$(lctl get_param -n debug 2> /dev/null)
161 lctl set_param debug=-1 2> /dev/null || true
164 $CHECKSTAT -t file $DIR/$tfile || error "$tfile is not a file"
166 $CHECKSTAT -a $DIR/$tfile || error "$tfile was not removed"
168 run_test 0a "touch; rm ====================="
171 chmod 0755 $DIR || error "chmod 0755 $DIR failed"
172 $CHECKSTAT -p 0755 $DIR || error "$DIR permission is not 0755"
174 run_test 0b "chmod 0755 $DIR ============================="
177 $LCTL get_param mdc.*.import | grep "state: FULL" ||
178 error "import not FULL"
179 $LCTL get_param mdc.*.import | grep "target: $FSNAME-MDT" ||
182 run_test 0c "check import proc ============================="
185 test_mkdir -p $DIR/$tdir || error "mkdir $tdir failed"
186 test_mkdir -p $DIR/$tdir/d2 || error "mkdir $tdir/d2 failed"
187 test_mkdir $DIR/$tdir/d2 && error "we expect EEXIST, but not returned"
188 $CHECKSTAT -t dir $DIR/$tdir/d2 || error "$tdir/d2 is not a dir"
191 $CHECKSTAT -a $DIR/$tdir || error "$tdir was not removed"
193 run_test 1 "mkdir; remkdir; rmdir =============================="
196 test_mkdir -p $DIR/$tdir || error "mkdir $tdir failed"
197 touch $DIR/$tdir/$tfile || error "touch $tdir/$tfile failed"
198 $CHECKSTAT -t file $DIR/$tdir/$tfile || error "$tdir/$tfile not a file"
200 $CHECKSTAT -a $DIR/$tdir/$tfile || error "$tdir/$file is not removed"
202 run_test 2 "mkdir; touch; rmdir; check file ===================="
205 test_mkdir -p $DIR/$tdir || error "mkdir $tdir failed"
206 $CHECKSTAT -t dir $DIR/$tdir || error "$tdir is not a directory"
207 touch $DIR/$tdir/$tfile
208 $CHECKSTAT -t file $DIR/$tdir/$tfile || error "$tdir/$tfile not a file"
210 $CHECKSTAT -a $DIR/$tdir || error "$tdir is not removed"
212 run_test 3 "mkdir; touch; rmdir; check dir ====================="
214 # LU-4471 - failed rmdir on remote directories still removes directory on MDT0
218 test_mkdir $DIR/$tdir ||
219 error "Create remote directory failed"
221 touch $DIR/$tdir/$tfile ||
222 error "Create file under remote directory failed"
225 error "Expect error removing in-use dir $DIR/$tdir"
227 test -d $DIR/$tdir || error "Remote directory disappeared"
229 rm -rf $DIR/$tdir || error "remove remote dir error"
231 run_test 4 "mkdir; touch dir/file; rmdir; checkdir (expect error)"
234 test_mkdir -p $DIR/$tdir || error "mkdir $tdir failed"
235 test_mkdir $DIR/$tdir/d2 || error "mkdir $tdir/d2 failed"
236 chmod 0707 $DIR/$tdir/d2 || error "chmod 0707 $tdir/d2 failed"
237 $CHECKSTAT -t dir -p 0707 $DIR/$tdir/d2 || error "$tdir/d2 not mode 707"
238 $CHECKSTAT -t dir $DIR/$tdir/d2 || error "$tdir/d2 is not a directory"
240 run_test 5 "mkdir .../d5 .../d5/d2; chmod .../d5/d2 ============"
243 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
244 chmod 0666 $DIR/$tfile || error "chmod 0666 $tfile failed"
245 $CHECKSTAT -t file -p 0666 -u \#$UID $DIR/$tfile ||
246 error "$tfile does not have perm 0666 or UID $UID"
247 $RUNAS chmod 0444 $DIR/$tfile && error "chmod $tfile worked on UID $UID"
248 $CHECKSTAT -t file -p 0666 -u \#$UID $DIR/$tfile ||
249 error "$tfile should be 0666 and owned by UID $UID"
251 run_test 6a "touch f6a; chmod f6a; $RUNAS chmod f6a (should return error) =="
254 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID" && return
256 chown $RUNAS_ID $DIR/$tfile || error "chown $RUNAS_ID $file failed"
257 $CHECKSTAT -t file -u \#$RUNAS_ID $DIR/$tfile ||
258 error "$tfile should be owned by UID $RUNAS_ID"
259 $RUNAS chown $UID $DIR/$tfile && error "chown $UID $file succeeded"
260 $CHECKSTAT -t file -u \#$RUNAS_ID $DIR/$tfile ||
261 error "$tfile should be owned by UID $RUNAS_ID"
263 run_test 6c "touch f6c; chown f6c; $RUNAS chown f6c (should return error) =="
266 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID" && return
268 chgrp $RUNAS_ID $DIR/$tfile || error "chgrp $RUNAS_ID $file failed"
269 $CHECKSTAT -t file -u \#$UID -g \#$RUNAS_ID $DIR/$tfile ||
270 error "$tfile should be owned by GID $UID"
271 $RUNAS chgrp $UID $DIR/$tfile && error "chgrp $UID $file succeeded"
272 $CHECKSTAT -t file -u \#$UID -g \#$RUNAS_ID $DIR/$tfile ||
273 error "$tfile should be owned by UID $UID and GID $RUNAS_ID"
275 run_test 6e "touch f6e; chgrp f6e; $RUNAS chgrp f6e (should return error) =="
278 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID" && return
279 test_mkdir $DIR/$tdir || error "mkdir $tfile failed"
280 chmod 777 $DIR/$tdir || error "chmod 0777 $tdir failed"
281 $RUNAS mkdir $DIR/$tdir/d || error "mkdir $tdir/d failed"
282 chmod g+s $DIR/$tdir/d || error "chmod g+s $tdir/d failed"
283 test_mkdir $DIR/$tdir/d/subdir || error "mkdir $tdir/d/subdir failed"
284 $CHECKSTAT -g \#$RUNAS_GID $DIR/$tdir/d/subdir ||
285 error "$tdir/d/subdir should be GID $RUNAS_GID"
287 run_test 6g "Is new dir in sgid dir inheriting group?"
289 test_6h() { # bug 7331
290 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID" && return
291 touch $DIR/$tfile || error "touch failed"
292 chown $RUNAS_ID:$RUNAS_GID $DIR/$tfile || error "initial chown failed"
293 $RUNAS -G$RUNAS_GID chown $RUNAS_ID:0 $DIR/$tfile &&
294 error "chown $RUNAS_ID:0 $tfile worked as GID $RUNAS_GID"
295 $CHECKSTAT -t file -u \#$RUNAS_ID -g \#$RUNAS_GID $DIR/$tfile ||
296 error "$tdir/$tfile should be UID $RUNAS_UID GID $RUNAS_GID"
298 run_test 6h "$RUNAS chown RUNAS_ID.0 .../f6h (should return error)"
301 test_mkdir $DIR/$tdir
302 $MCREATE $DIR/$tdir/$tfile
303 chmod 0666 $DIR/$tdir/$tfile
304 $CHECKSTAT -t file -p 0666 $DIR/$tdir/$tfile ||
305 error "$tdir/$tfile should be mode 0666"
307 run_test 7a "mkdir .../d7; mcreate .../d7/f; chmod .../d7/f ===="
310 if [ ! -d $DIR/$tdir ]; then
313 $MCREATE $DIR/$tdir/$tfile
314 echo -n foo > $DIR/$tdir/$tfile
315 [ "$(cat $DIR/$tdir/$tfile)" = "foo" ] || error "$tdir/$tfile not 'foo'"
316 $CHECKSTAT -t file -s 3 $DIR/$tdir/$tfile || error "$tfile size not 3"
318 run_test 7b "mkdir .../d7; mcreate d7/f2; echo foo > d7/f2 ====="
321 test_mkdir $DIR/$tdir
322 touch $DIR/$tdir/$tfile
323 chmod 0666 $DIR/$tdir/$tfile
324 $CHECKSTAT -t file -p 0666 $DIR/$tdir/$tfile ||
325 error "$tfile mode not 0666"
327 run_test 8 "mkdir .../d8; touch .../d8/f; chmod .../d8/f ======="
330 test_mkdir $DIR/$tdir
331 test_mkdir $DIR/$tdir/d2
332 test_mkdir $DIR/$tdir/d2/d3
333 $CHECKSTAT -t dir $DIR/$tdir/d2/d3 || error "$tdir/d2/d3 not a dir"
335 run_test 9 "mkdir .../d9 .../d9/d2 .../d9/d2/d3 ================"
338 test_mkdir $DIR/$tdir
339 test_mkdir $DIR/$tdir/d2
340 touch $DIR/$tdir/d2/$tfile
341 $CHECKSTAT -t file $DIR/$tdir/d2/$tfile ||
342 error "$tdir/d2/$tfile not a file"
344 run_test 10 "mkdir .../d10 .../d10/d2; touch .../d10/d2/f ======"
347 test_mkdir $DIR/$tdir
348 test_mkdir $DIR/$tdir/d2
349 chmod 0666 $DIR/$tdir/d2
350 chmod 0705 $DIR/$tdir/d2
351 $CHECKSTAT -t dir -p 0705 $DIR/$tdir/d2 ||
352 error "$tdir/d2 mode not 0705"
354 run_test 11 "mkdir .../d11 d11/d2; chmod .../d11/d2 ============"
357 test_mkdir $DIR/$tdir
358 touch $DIR/$tdir/$tfile
359 chmod 0666 $DIR/$tdir/$tfile
360 chmod 0654 $DIR/$tdir/$tfile
361 $CHECKSTAT -t file -p 0654 $DIR/$tdir/$tfile ||
362 error "$tdir/d2 mode not 0654"
364 run_test 12 "touch .../d12/f; chmod .../d12/f .../d12/f ========"
367 test_mkdir $DIR/$tdir
368 dd if=/dev/zero of=$DIR/$tdir/$tfile count=10
370 $CHECKSTAT -t file -s 0 $DIR/$tdir/$tfile ||
371 error "$tdir/$tfile size not 0 after truncate"
373 run_test 13 "creat .../d13/f; dd .../d13/f; > .../d13/f ========"
376 test_mkdir $DIR/$tdir
377 touch $DIR/$tdir/$tfile
379 $CHECKSTAT -a $DIR/$tdir/$tfile || error "$tdir/$tfile not removed"
381 run_test 14 "touch .../d14/f; rm .../d14/f; rm .../d14/f ======="
384 test_mkdir $DIR/$tdir
385 touch $DIR/$tdir/$tfile
386 mv $DIR/$tdir/$tfile $DIR/$tdir/${tfile}_2
387 $CHECKSTAT -t file $DIR/$tdir/${tfile}_2 ||
388 error "$tdir/${tfile_2} not a file after rename"
390 run_test 15 "touch .../d15/f; mv .../d15/f .../d15/f2 =========="
393 test_mkdir $DIR/$tdir
394 touch $DIR/$tdir/$tfile
395 rm -rf $DIR/$tdir/$tfile
396 $CHECKSTAT -a $DIR/$tdir/$tfile || error "$tdir/$tfile not removed"
398 run_test 16 "touch .../d16/f; rm -rf .../d16/f ================="
401 test_mkdir -p $DIR/$tdir
402 touch $DIR/$tdir/$tfile
403 ln -s $DIR/$tdir/$tfile $DIR/$tdir/l-exist
405 $CHECKSTAT -l $DIR/$tdir/$tfile $DIR/$tdir/l-exist ||
406 error "$tdir/l-exist not a symlink"
407 $CHECKSTAT -f -t f $DIR/$tdir/l-exist ||
408 error "$tdir/l-exist not referencing a file"
409 rm -f $DIR/$tdir/l-exist
410 $CHECKSTAT -a $DIR/$tdir/l-exist || error "$tdir/l-exist not removed"
412 run_test 17a "symlinks: create, remove (real) =================="
415 test_mkdir -p $DIR/$tdir
416 ln -s no-such-file $DIR/$tdir/l-dangle
418 $CHECKSTAT -l no-such-file $DIR/$tdir/l-dangle ||
419 error "$tdir/l-dangle not referencing no-such-file"
420 $CHECKSTAT -fa $DIR/$tdir/l-dangle ||
421 error "$tdir/l-dangle not referencing non-existent file"
422 rm -f $DIR/$tdir/l-dangle
423 $CHECKSTAT -a $DIR/$tdir/l-dangle || error "$tdir/l-dangle not removed"
425 run_test 17b "symlinks: create, remove (dangling) =============="
427 test_17c() { # bug 3440 - don't save failed open RPC for replay
428 test_mkdir -p $DIR/$tdir
429 ln -s foo $DIR/$tdir/$tfile
430 cat $DIR/$tdir/$tfile && error "opened non-existent symlink" || true
432 run_test 17c "symlinks: open dangling (should return error) ===="
435 test_mkdir -p $DIR/$tdir
436 ln -s foo $DIR/$tdir/$tfile
437 touch $DIR/$tdir/$tfile || error "creating to new symlink"
439 run_test 17d "symlinks: create dangling ========================"
442 test_mkdir -p $DIR/$tdir
443 local foo=$DIR/$tdir/$tfile
444 ln -s $foo $foo || error "create symlink failed"
445 ls -l $foo || error "ls -l failed"
446 ls $foo && error "ls not failed" || true
448 run_test 17e "symlinks: create recursive symlink (should return error) ===="
451 test_mkdir -p $DIR/$tdir
452 ln -s 1234567890/2234567890/3234567890/4234567890 $DIR/$tdir/111
453 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890 $DIR/$tdir/222
454 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890 $DIR/$tdir/333
455 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890/9234567890/a234567890/b234567890 $DIR/$tdir/444
456 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890/9234567890/a234567890/b234567890/c234567890/d234567890/f234567890 $DIR/$tdir/555
457 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890/9234567890/a234567890/b234567890/c234567890/d234567890/f234567890/aaaaaaaaaa/bbbbbbbbbb/cccccccccc/dddddddddd/eeeeeeeeee/ffffffffff/ $DIR/$tdir/666
460 run_test 17f "symlinks: long and very long symlink name ========================"
462 # str_repeat(S, N) generate a string that is string S repeated N times
467 while [ $((n -= 1)) -ge 0 ]; do
473 # Long symlinks and LU-2241
475 test_mkdir -p $DIR/$tdir
476 local TESTS="59 60 61 4094 4095"
478 # Fix for inode size boundary in 2.1.4
479 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.1.4) ] &&
482 # Patch not applied to 2.2 or 2.3 branches
483 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] &&
484 [ $(lustre_version_code $SINGLEMDS) -le $(version_code 2.3.55) ] &&
487 # skip long symlink name for rhel6.5.
488 # rhel6.5 has a limit (PATH_MAX - sizeof(struct filename))
489 grep -q '6.5' /etc/redhat-release &>/dev/null &&
490 TESTS="59 60 61 4062 4063"
493 local SYMNAME=$(str_repeat 'x' $i)
494 ln -s $SYMNAME $DIR/$tdir/f$i || error "failed $i-char symlink"
495 readlink $DIR/$tdir/f$i || error "failed $i-char readlink"
498 run_test 17g "symlinks: really long symlink name and inode boundaries"
500 test_17h() { #bug 17378
501 remote_mds_nodsh && skip "remote MDS with nodsh" && return
502 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
504 test_mkdir -p $DIR/$tdir
505 if [[ $MDSCOUNT -gt 1 ]]; then
506 mdt_idx=$($LFS getdirstripe -i $DIR/$tdir)
510 $SETSTRIPE -c -1 $DIR/$tdir
511 #define OBD_FAIL_MDS_LOV_PREP_CREATE 0x141
512 do_facet mds$((mdt_idx + 1)) lctl set_param fail_loc=0x80000141
513 touch $DIR/$tdir/$tfile || true
515 run_test 17h "create objects: lov_free_memmd() doesn't lbug"
517 test_17i() { #bug 20018
518 remote_mds_nodsh && skip "remote MDS with nodsh" && return
519 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
520 test_mkdir -c1 $DIR/$tdir
521 local foo=$DIR/$tdir/$tfile
523 if [[ $MDSCOUNT -gt 1 ]]; then
524 mdt_idx=$($LFS getdirstripe -i $DIR/$tdir)
528 ln -s $foo $foo || error "create symlink failed"
529 #define OBD_FAIL_MDS_READLINK_EPROTO 0x143
530 do_facet mds$((mdt_idx + 1)) lctl set_param fail_loc=0x80000143
531 ls -l $foo && error "error not detected"
534 run_test 17i "don't panic on short symlink"
536 test_17k() { #bug 22301
537 [[ -z "$(which rsync 2>/dev/null)" ]] &&
538 skip "no rsync command" && return 0
539 rsync --help | grep -q xattr ||
540 skip_env "$(rsync --version | head -n1) does not support xattrs"
541 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return 0
542 test_mkdir -p $DIR/$tdir
543 test_mkdir -p $DIR/$tdir.new
544 touch $DIR/$tdir/$tfile
545 ln -s $DIR/$tdir/$tfile $DIR/$tdir/$tfile.lnk
546 rsync -av -X $DIR/$tdir/ $DIR/$tdir.new ||
547 error "rsync failed with xattrs enabled"
549 run_test 17k "symlinks: rsync with xattrs enabled ========================="
551 test_17l() { # LU-279
552 [[ -z "$(which getfattr 2>/dev/null)" ]] &&
553 skip "no getfattr command" && return 0
555 touch $DIR/$tdir/$tfile
556 ln -s $DIR/$tdir/$tfile $DIR/$tdir/$tfile.lnk
557 for path in "$DIR/$tdir" "$DIR/$tdir/$tfile" "$DIR/$tdir/$tfile.lnk"; do
558 # -h to not follow symlinks. -m '' to list all the xattrs.
559 # grep to remove first line: '# file: $path'.
560 for xattr in `getfattr -hm '' $path 2>/dev/null | grep -v '^#'`;
562 lgetxattr_size_check $path $xattr ||
563 error "lgetxattr_size_check $path $xattr failed"
567 run_test 17l "Ensure lgetxattr's returned xattr size is consistent ========"
571 local short_sym="0123456789"
572 local WDIR=$DIR/${tdir}m
579 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] &&
580 [ $(lustre_version_code $SINGLEMDS) -le $(version_code 2.2.93) ] &&
581 skip "MDS 2.2.0-2.2.93 do not NUL-terminate symlinks" && return
583 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
584 skip "only for ldiskfs MDT" && return 0
586 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
590 # create a long symlink file
591 for ((i = 0; i < 4; ++i)); do
592 long_sym=${long_sym}${long_sym}
595 echo "create 512 short and long symlink files under $WDIR"
596 for ((i = 0; i < 256; ++i)); do
597 ln -sf ${long_sym}"a5a5" $WDIR/long-$i
598 ln -sf ${short_sym}"a5a5" $WDIR/short-$i
604 wait_delete_completed
606 echo "recreate the 512 symlink files with a shorter string"
607 for ((i = 0; i < 512; ++i)); do
608 # rewrite the symlink file with a shorter string
609 ln -sf ${long_sym} $WDIR/long-$i
610 ln -sf ${short_sym} $WDIR/short-$i
613 mds_index=$($LFS getstripe -M $WDIR)
614 mds_index=$((mds_index+1))
615 devname=$(mdsdevname $mds_index)
616 cmd="$E2FSCK -fnvd $devname"
618 echo "stop and checking mds${mds_index}: $cmd"
619 # e2fsck should not return error
621 do_facet mds${mds_index} $cmd || rc=$?
623 start mds${mds_index} $devname $MDS_MOUNT_OPTS || error "start failed"
624 df $MOUNT > /dev/null 2>&1
625 [ $rc -ne 0 ] && error "e2fsck should not report error upon "\
626 "short/long symlink MDT: rc=$rc"
629 run_test 17m "run e2fsck against MDT which contains short/long symlink"
631 check_fs_consistency_17n() {
637 # create/unlink in 17n only change 2 MDTs(MDT1/MDT2),
638 # so it only check MDT1/MDT2 instead of all of MDTs.
639 for mdt_index in $(seq 1 2); do
640 devname=$(mdsdevname $mdt_index)
641 cmd="$E2FSCK -fnvd $devname"
643 echo "stop and checking mds${mdt_index}: $cmd"
644 # e2fsck should not return error
646 do_facet mds${mdt_index} $cmd || rc=$?
648 start mds${mdt_index} $devname $MDS_MOUNT_OPTS ||
649 error "mount mds${mdt_index} failed"
650 df $MOUNT > /dev/null 2>&1
651 [ $rc -ne 0 ] && break
659 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] &&
660 [ $(lustre_version_code $SINGLEMDS) -le $(version_code 2.2.93) ] &&
661 skip "MDS 2.2.0-2.2.93 do not NUL-terminate symlinks" && return
663 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
664 skip "only for ldiskfs MDT" && return 0
666 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 2 MDTs" && return
668 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
671 for ((i=0; i<10; i++)); do
672 $LFS mkdir -i1 -c2 $DIR/$tdir/remote_dir_${i} ||
673 error "create remote dir error $i"
674 createmany -o $DIR/$tdir/remote_dir_${i}/f 10 ||
675 error "create files under remote dir failed $i"
678 check_fs_consistency_17n ||
679 error "e2fsck report error after create files under remote dir"
681 for ((i=0;i<10;i++)); do
682 rm -rf $DIR/$tdir/remote_dir_${i} ||
683 error "destroy remote dir error $i"
686 check_fs_consistency_17n ||
687 error "e2fsck report error after unlink files under remote dir"
689 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.50) ] &&
690 skip "lustre < 2.4.50 does not support migrate mv " && return
692 for ((i=0; i<10; i++)); do
693 mkdir -p $DIR/$tdir/remote_dir_${i}
694 createmany -o $DIR/$tdir/remote_dir_${i}/f 10 ||
695 error "create files under remote dir failed $i"
696 $LFS mv -M 1 $DIR/$tdir/remote_dir_${i} ||
697 error "migrate remote dir error $i"
699 check_fs_consistency_17n || error "e2fsck report error after migration"
701 for ((i=0;i<10;i++)); do
702 rm -rf $DIR/$tdir/remote_dir_${i} ||
703 error "destroy remote dir error $i"
706 check_fs_consistency_17n || error "e2fsck report error after unlink"
708 run_test 17n "run e2fsck against master/slave MDT which contains remote dir"
711 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.3.64) ] &&
712 skip "Need MDS version at least 2.3.64" && return
714 local WDIR=$DIR/${tdir}o
720 mdt_index=$($LFS getstripe -M $WDIR)
721 mdt_index=$((mdt_index+1))
722 mdtdevname=$(mdsdevname $mdt_index)
726 start mds${mdt_index} $mdtdevname $MDS_MOUNT_OPTS ||
727 error "mount mds${mdt_index} failed"
729 #define OBD_FAIL_OSD_LMA_INCOMPAT 0x194
730 do_facet mds${mdt_index} lctl set_param fail_loc=0x194
731 ls -l $WDIR/$tfile && rc=1
732 do_facet mds${mdt_index} lctl set_param fail_loc=0
733 [[ $rc -ne 0 ]] && error "stat file should fail"
736 run_test 17o "stat file with incompat LMA feature"
739 touch $DIR/$tfile || error "Failed to touch $DIR/$tfile: $?"
740 ls $DIR || error "Failed to ls $DIR: $?"
742 run_test 18 "touch .../f ; ls ... =============================="
748 $CHECKSTAT -a $DIR/$tfile || error "$tfile was not removed"
750 run_test 19a "touch .../f19 ; ls -l ... ; rm .../f19 ==========="
753 ls -l $DIR/$tfile && error "ls -l $tfile failed"|| true
755 run_test 19b "ls -l .../f19 (should return error) =============="
758 [ $RUNAS_ID -eq $UID ] &&
759 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
760 $RUNAS touch $DIR/$tfile && error "create non-root file failed" || true
762 run_test 19c "$RUNAS touch .../f19 (should return error) =="
765 cat $DIR/f19 && error || true
767 run_test 19d "cat .../f19 (should return error) =============="
779 $CHECKSTAT -a $DIR/$tfile || error "$tfile was not removed"
781 run_test 20 "touch .../f ; ls -l ... ==========================="
784 test_mkdir -p $DIR/$tdir
785 [ -f $DIR/$tdir/dangle ] && rm -f $DIR/$tdir/dangle
786 ln -s dangle $DIR/$tdir/link
787 echo foo >> $DIR/$tdir/link
788 cat $DIR/$tdir/dangle
789 $CHECKSTAT -t link $DIR/$tdir/link || error "$tdir/link not a link"
790 $CHECKSTAT -f -t file $DIR/$tdir/link ||
791 error "$tdir/link not linked to a file"
793 run_test 21 "write to dangling link ============================"
797 test_mkdir -p $DIR/$tdir
798 chown $RUNAS_ID:$RUNAS_GID $WDIR
799 (cd $WDIR || error "cd $WDIR failed";
800 $RUNAS tar cf - /etc/hosts /etc/sysconfig/network | \
802 ls -lR $WDIR/etc || error "ls -lR $WDIR/etc failed"
803 $CHECKSTAT -t dir $WDIR/etc || error "checkstat -t dir failed"
804 $CHECKSTAT -u \#$RUNAS_ID -g \#$RUNAS_GID $WDIR/etc || error "checkstat -u failed"
806 run_test 22 "unpack tar archive as non-root user ==============="
810 test_mkdir -p $DIR/$tdir
811 local file=$DIR/$tdir/$tfile
813 openfile -f O_CREAT:O_EXCL $file || error "$file create failed"
814 openfile -f O_CREAT:O_EXCL $file &&
815 error "$file recreate succeeded" || true
817 run_test 23a "O_CREAT|O_EXCL in subdir =========================="
819 test_23b() { # bug 18988
820 test_mkdir -p $DIR/$tdir
821 local file=$DIR/$tdir/$tfile
824 echo foo > $file || error "write filed"
825 echo bar >> $file || error "append filed"
826 $CHECKSTAT -s 8 $file || error "wrong size"
829 run_test 23b "O_APPEND check =========================="
833 echo '-- same directory rename'
834 test_mkdir $DIR/$tdir
835 touch $DIR/$tdir/$tfile.1
836 mv $DIR/$tdir/$tfile.1 $DIR/$tdir/$tfile.2
837 $CHECKSTAT -t file $DIR/$tdir/$tfile.2 || error "$tfile.2 not a file"
839 run_test 24a "rename file to non-existent target"
842 test_mkdir $DIR/$tdir
843 touch $DIR/$tdir/$tfile.{1,2}
844 mv $DIR/$tdir/$tfile.1 $DIR/$tdir/$tfile.2
845 $CHECKSTAT -a $DIR/$tdir/$tfile.1 || error "$tfile.1 exists"
846 $CHECKSTAT -t file $DIR/$tdir/$tfile.2 || error "$tfile.2 not a file"
848 run_test 24b "rename file to existing target"
851 test_mkdir $DIR/$tdir
852 test_mkdir $DIR/$tdir/d$testnum.1
853 mv $DIR/$tdir/d$testnum.1 $DIR/$tdir/d$testnum.2
854 $CHECKSTAT -a $DIR/$tdir/d$testnum.1 || error "d$testnum.1 exists"
855 $CHECKSTAT -t dir $DIR/$tdir/d$testnum.2 || error "d$testnum.2 not dir"
857 run_test 24c "rename directory to non-existent target"
860 test_mkdir -c1 $DIR/$tdir
861 test_mkdir -c1 $DIR/$tdir/d$testnum.1
862 test_mkdir -c1 $DIR/$tdir/d$testnum.2
863 mrename $DIR/$tdir/d$testnum.1 $DIR/$tdir/d$testnum.2
864 $CHECKSTAT -a $DIR/$tdir/d$testnum.1 || error "d$testnum.1 exists"
865 $CHECKSTAT -t dir $DIR/$tdir/d$testnum.2 || error "d$testnum.2 not dir"
867 run_test 24d "rename directory to existing target"
870 echo '-- cross directory renames --'
874 mv $DIR/R5a/f $DIR/R5b/g
875 $CHECKSTAT -a $DIR/R5a/f || error
876 $CHECKSTAT -t file $DIR/R5b/g || error
878 run_test 24e "touch .../R5a/f; rename .../R5a/f .../R5b/g ======"
883 touch $DIR/R6a/f $DIR/R6b/g
884 mv $DIR/R6a/f $DIR/R6b/g
885 $CHECKSTAT -a $DIR/R6a/f || error
886 $CHECKSTAT -t file $DIR/R6b/g || error
888 run_test 24f "touch .../R6a/f R6b/g; mv .../R6a/f .../R6b/g ===="
893 test_mkdir $DIR/R7a/d
894 mv $DIR/R7a/d $DIR/R7b/e
895 $CHECKSTAT -a $DIR/R7a/d || error
896 $CHECKSTAT -t dir $DIR/R7b/e || error
898 run_test 24g "mkdir .../R7{a,b}/d; mv .../R7a/d .../R7b/e ======"
901 test_mkdir -c1 $DIR/R8a
902 test_mkdir -c1 $DIR/R8b
903 test_mkdir -c1 $DIR/R8a/d
904 test_mkdir -c1 $DIR/R8b/e
905 mrename $DIR/R8a/d $DIR/R8b/e
906 $CHECKSTAT -a $DIR/R8a/d || error
907 $CHECKSTAT -t dir $DIR/R8b/e || error
909 run_test 24h "mkdir .../R8{a,b}/{d,e}; rename .../R8a/d .../R8b/e"
912 echo "-- rename error cases"
916 mrename $DIR/R9/f $DIR/R9/a
917 $CHECKSTAT -t file $DIR/R9/f || error
918 $CHECKSTAT -t dir $DIR/R9/a || error
919 $CHECKSTAT -a $DIR/R9/a/f || error
921 run_test 24i "rename file to dir error: touch f ; mkdir a ; rename f a"
925 mrename $DIR/R10/f $DIR/R10/g
926 $CHECKSTAT -t dir $DIR/R10 || error
927 $CHECKSTAT -a $DIR/R10/f || error
928 $CHECKSTAT -a $DIR/R10/g || error
930 run_test 24j "source does not exist ============================"
934 test_mkdir $DIR/R11a/d
936 mv $DIR/R11a/f $DIR/R11a/d
937 $CHECKSTAT -a $DIR/R11a/f || error
938 $CHECKSTAT -t file $DIR/R11a/d/f || error
940 run_test 24k "touch .../R11a/f; mv .../R11a/f .../R11a/d ======="
942 # bug 2429 - rename foo foo foo creates invalid file
945 $MULTIOP $f OcNs || error
947 run_test 24l "Renaming a file to itself ========================"
951 $MULTIOP $f OcLN ${f}2 ${f}2 || error "link ${f}2 ${f}2 failed"
952 # on ext3 this does not remove either the source or target files
953 # though the "expected" operation would be to remove the source
954 $CHECKSTAT -t file ${f} || error "${f} missing"
955 $CHECKSTAT -t file ${f}2 || error "${f}2 missing"
957 run_test 24m "Renaming a file to a hard link to itself ========="
961 # this stats the old file after it was renamed, so it should fail
965 $CHECKSTAT ${f}.rename
968 run_test 24n "Statting the old file after renaming (Posix rename 2)"
971 check_kernel_version 37 || return 0
972 test_mkdir -p $DIR/d24o
973 rename_many -s random -v -n 10 $DIR/d24o
975 run_test 24o "rename of files during htree split ==============="
980 DIRINO=`ls -lid $DIR/R12a | awk '{ print $1 }'`
981 mrename $DIR/R12a $DIR/R12b
982 $CHECKSTAT -a $DIR/R12a || error
983 $CHECKSTAT -t dir $DIR/R12b || error
984 DIRINO2=`ls -lid $DIR/R12b | awk '{ print $1 }'`
985 [ "$DIRINO" = "$DIRINO2" ] || error "R12a $DIRINO != R12b $DIRINO2"
987 run_test 24p "mkdir .../R12{a,b}; rename .../R12a .../R12b"
989 cleanup_multiop_pause() {
995 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
998 local DIRINO=$(ls -lid $DIR/R13a | awk '{ print $1 }')
999 multiop_bg_pause $DIR/R13b D_c || error "multiop failed to start"
1002 trap cleanup_multiop_pause EXIT
1003 mrename $DIR/R13a $DIR/R13b
1004 $CHECKSTAT -a $DIR/R13a || error "R13a still exists"
1005 $CHECKSTAT -t dir $DIR/R13b || error "R13b does not exist"
1006 local DIRINO2=$(ls -lid $DIR/R13b | awk '{ print $1 }')
1007 [ "$DIRINO" = "$DIRINO2" ] || error "R13a $DIRINO != R13b $DIRINO2"
1008 cleanup_multiop_pause
1009 wait $MULTIPID || error "multiop close failed"
1011 run_test 24q "mkdir .../R13{a,b}; open R13b rename R13a R13b ==="
1013 test_24r() { #bug 3789
1014 test_mkdir $DIR/R14a
1015 test_mkdir $DIR/R14a/b
1016 mrename $DIR/R14a $DIR/R14a/b && error "rename to subdir worked!"
1017 $CHECKSTAT -t dir $DIR/R14a || error "$DIR/R14a missing"
1018 $CHECKSTAT -t dir $DIR/R14a/b || error "$DIR/R14a/b missing"
1020 run_test 24r "mkdir .../R14a/b; rename .../R14a .../R14a/b ====="
1023 test_mkdir $DIR/R15a
1024 test_mkdir $DIR/R15a/b
1025 test_mkdir $DIR/R15a/b/c
1026 mrename $DIR/R15a $DIR/R15a/b/c && error "rename to sub-subdir worked!"
1027 $CHECKSTAT -t dir $DIR/R15a || error "$DIR/R15a missing"
1028 $CHECKSTAT -t dir $DIR/R15a/b/c || error "$DIR/R15a/b/c missing"
1030 run_test 24s "mkdir .../R15a/b/c; rename .../R15a .../R15a/b/c ="
1032 test_mkdir $DIR/R16a
1033 test_mkdir $DIR/R16a/b
1034 test_mkdir $DIR/R16a/b/c
1035 mrename $DIR/R16a/b/c $DIR/R16a && error "rename to sub-subdir worked!"
1036 $CHECKSTAT -t dir $DIR/R16a || error "$DIR/R16a missing"
1037 $CHECKSTAT -t dir $DIR/R16a/b/c || error "$DIR/R16a/b/c missing"
1039 run_test 24t "mkdir .../R16a/b/c; rename .../R16a/b/c .../R16a ="
1041 test_24u() { # bug12192
1042 $MULTIOP $DIR/$tfile C2w$((2048 * 1024))c || error
1043 $CHECKSTAT -s $((2048 * 1024)) $DIR/$tfile || error "wrong file size"
1045 run_test 24u "create stripe file"
1051 simple_cleanup_common() {
1054 wait_delete_completed
1057 max_pages_per_rpc() {
1058 $LCTL get_param -n mdc.*.max_pages_per_rpc | head -n1
1062 local NRFILES=100000
1063 local FREE_INODES=$(mdt_free_inodes 0)
1064 [[ $FREE_INODES -lt $NRFILES ]] &&
1065 skip "not enough free inodes $FREE_INODES required $NRFILES" &&
1068 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1069 trap simple_cleanup_common EXIT
1071 # Performance issue on ZFS see LU-4072 (c.f. LU-2887)
1072 [ $(facet_fstype $SINGLEMDS) = "zfs" ] && NRFILES=10000
1075 createmany -m $DIR/$tdir/$tfile $NRFILES
1077 cancel_lru_locks mdc
1078 lctl set_param mdc.*.stats clear
1080 ls $DIR/$tdir >/dev/null || error "error in listing large dir"
1082 # LU-5 large readdir
1083 # DIRENT_SIZE = 32 bytes for sizeof(struct lu_dirent) +
1084 # 8 bytes for name(filename is mostly 5 in this test) +
1085 # 8 bytes for luda_type
1086 # take into account of overhead in lu_dirpage header and end mark in
1087 # each page, plus one in RPC_NUM calculation.
1089 RPC_SIZE=$(($(max_pages_per_rpc) * $(page_size)))
1090 RPC_NUM=$(((NRFILES * DIRENT_SIZE + RPC_SIZE - 1) / RPC_SIZE + 1))
1091 mds_readpage=$(lctl get_param mdc.*MDT0000*.stats |
1092 awk '/^mds_readpage/ {print $2}')
1093 [[ $mds_readpage -gt $RPC_NUM ]] &&
1094 error "large readdir doesn't take effect"
1096 simple_cleanup_common
1098 run_test 24v "list directory with large files (handle hash collision, bug: 17560)"
1100 test_24w() { # bug21506
1102 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=4096 || return 1
1103 dd if=/dev/zero bs=$SZ1 count=1 >> $DIR/$tfile || return 2
1104 dd if=$DIR/$tfile of=$DIR/${tfile}_left bs=1M skip=4097 || return 3
1105 SZ2=`ls -l $DIR/${tfile}_left | awk '{print $5}'`
1106 [[ "$SZ1" -eq "$SZ2" ]] ||
1107 error "Error reading at the end of the file $tfile"
1109 run_test 24w "Reading a file larger than 4Gb"
1112 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 2 MDTs" && return
1113 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1115 local remote_dir=$DIR/$tdir/remote_dir
1118 $LFS mkdir -i $MDTIDX $remote_dir ||
1119 error "create remote directory failed"
1121 mkdir -p $DIR/$tdir/src_dir
1122 touch $DIR/$tdir/src_file
1123 mkdir -p $remote_dir/tgt_dir
1124 touch $remote_dir/tgt_file
1126 mrename $remote_dir $DIR/ &&
1127 error "rename dir cross MDT works!"
1129 mrename $DIR/$tdir/src_dir $remote_dir/tgt_dir &&
1130 error "rename dir cross MDT works!"
1132 mrename $DIR/$tdir/src_file $remote_dir/tgt_file &&
1133 error "rename file cross MDT works!"
1135 ln $DIR/$tdir/src_file $remote_dir/tgt_file1 &&
1136 error "ln file cross MDT should not work!"
1138 rm -rf $DIR/$tdir || error "Can not delete directories"
1140 run_test 24x "cross rename/link should be failed"
1143 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 2 MDTs" && return
1144 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1146 local remote_dir=$DIR/$tdir/remote_dir
1149 $LFS mkdir -i $MDTIDX $remote_dir ||
1150 error "create remote directory failed"
1152 mkdir -p $remote_dir/src_dir
1153 touch $remote_dir/src_file
1154 mkdir -p $remote_dir/tgt_dir
1155 touch $remote_dir/tgt_file
1157 mrename $remote_dir/src_dir $remote_dir/tgt_dir ||
1158 error "rename subdir in the same remote dir failed!"
1160 mrename $remote_dir/src_file $remote_dir/tgt_file ||
1161 error "rename files in the same remote dir failed!"
1163 ln $remote_dir/tgt_file $remote_dir/tgt_file1 ||
1164 error "link files in the same remote dir failed!"
1166 rm -rf $DIR/$tdir || error "Can not delete directories"
1168 run_test 24y "rename/link on the same dir should succeed"
1171 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 2 MDTs" && return
1172 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1174 local remote_src=$DIR/$tdir/remote_dir
1175 local remote_tgt=$DIR/$tdir/remote_tgt
1178 $LFS mkdir -i $MDTIDX $remote_src ||
1179 error "create remote directory failed"
1181 $LFS mkdir -i $MDTIDX $remote_tgt ||
1182 error "create remote directory failed"
1184 mrename $remote_src $remote_tgt &&
1185 error "rename remote dirs should not work!"
1187 # If target dir does not exists, it should succeed
1189 mrename $remote_src $remote_tgt ||
1190 error "rename remote dirs(tgt dir does not exists) failed!"
1192 rm -rf $DIR/$tdir || error "Can not delete directories"
1194 run_test 24z "rename one remote dir to another remote dir should fail"
1196 test_24A() { # LU-3182
1201 createmany -m $DIR/$tdir/$tfile $NFILES
1202 local t=$(ls $DIR/$tdir | wc -l)
1203 local u=$(ls $DIR/$tdir | sort -u | wc -l)
1204 local v=$(ls -ai $DIR/$tdir | sort -u | wc -l)
1205 if [ $t -ne $NFILES -o $u -ne $NFILES -o $v -ne $((NFILES + 2)) ] ; then
1206 error "Expected $NFILES files, got $t ($u unique $v .&..)"
1209 rm -rf $DIR/$tdir || error "Can not delete directories"
1211 run_test 24A "readdir() returns correct number of entries."
1213 test_24B() { # LU-4805
1214 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
1218 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR/$tdir/striped_dir ||
1219 error "create striped dir failed"
1221 count=$(ls -ai $DIR/$tdir/striped_dir | wc -l)
1222 [ $count -eq 2 ] || error "Expected 2, got $count"
1224 touch $DIR/$tdir/striped_dir/a
1226 count=$(ls -ai $DIR/$tdir/striped_dir | wc -l)
1227 [ $count -eq 3 ] || error "Expected 3, got $count"
1229 touch $DIR/$tdir/striped_dir/.f
1231 count=$(ls -ai $DIR/$tdir/striped_dir | wc -l)
1232 [ $count -eq 4 ] || error "Expected 4, got $count"
1234 rm -rf $DIR/$tdir || error "Can not delete directories"
1236 run_test 24B "readdir for striped dir return correct number of entries"
1239 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
1245 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR/$tdir/d0/striped_dir ||
1246 error "create striped dir failed"
1248 cd $DIR/$tdir/d0/striped_dir
1250 local d0_ino=$(ls -i -l -a $DIR/$tdir | grep "d0" | awk '{print $1}')
1251 local d1_ino=$(ls -i -l -a $DIR/$tdir | grep "d1" | awk '{print $1}')
1252 local parent_ino=$(ls -i -l -a | grep "\.\." | awk '{print $1}')
1254 [ "$d0_ino" = "$parent_ino" ] ||
1255 error ".. wrong, expect $d0_ino, get $parent_ino"
1257 mv $DIR/$tdir/d0/striped_dir $DIR/$tdir/d1/ ||
1258 error "mv striped dir failed"
1260 parent_ino=$(ls -i -l -a | grep "\.\." | awk '{print $1}')
1262 [ "$d1_ino" = "$parent_ino" ] ||
1263 error ".. wrong after mv, expect $d1_ino, get $parent_ino"
1265 run_test 24C "check .. in striped dir"
1268 echo '== symlink sanity ============================================='
1272 touch $DIR/s25/foo || error
1274 run_test 25a "create file in symlinked directory ==============="
1277 [ ! -d $DIR/d25 ] && test_25a
1278 $CHECKSTAT -t file $DIR/s25/foo || error
1280 run_test 25b "lookup file in symlinked directory ==============="
1284 test_mkdir $DIR/d26/d26-2
1285 ln -s d26/d26-2 $DIR/s26
1286 touch $DIR/s26/foo || error
1288 run_test 26a "multiple component symlink ======================="
1291 test_mkdir -p $DIR/d26b/d26-2
1292 ln -s d26b/d26-2/foo $DIR/s26-2
1293 touch $DIR/s26-2 || error
1295 run_test 26b "multiple component symlink at end of lookup ======"
1298 test_mkdir $DIR/d26.2
1299 touch $DIR/d26.2/foo
1300 ln -s d26.2 $DIR/s26.2-1
1301 ln -s s26.2-1 $DIR/s26.2-2
1302 ln -s s26.2-2 $DIR/s26.2-3
1303 chmod 0666 $DIR/s26.2-3/foo
1305 run_test 26c "chain of symlinks ================================"
1307 # recursive symlinks (bug 439)
1309 ln -s d26-3/foo $DIR/d26-3
1311 run_test 26d "create multiple component recursive symlink ======"
1314 [ ! -h $DIR/d26-3 ] && test_26d
1317 run_test 26e "unlink multiple component recursive symlink ======"
1319 # recursive symlinks (bug 7022)
1321 test_mkdir -p $DIR/$tdir
1322 test_mkdir $DIR/$tdir/$tfile || error "mkdir $DIR/$tdir/$tfile failed"
1323 cd $DIR/$tdir/$tfile || error "cd $DIR/$tdir/$tfile failed"
1324 test_mkdir -p lndir/bar1 || error "mkdir lndir/bar1 failed"
1325 test_mkdir $DIR/$tdir/$tfile/$tfile || error "mkdir $tfile failed"
1326 cd $tfile || error "cd $tfile failed"
1327 ln -s .. dotdot || error "ln dotdot failed"
1328 ln -s dotdot/lndir lndir || error "ln lndir failed"
1329 cd $DIR/$tdir || error "cd $DIR/$tdir failed"
1330 output=`ls $tfile/$tfile/lndir/bar1`
1331 [ "$output" = bar1 ] && error "unexpected output"
1332 rm -r $tfile || error "rm $tfile failed"
1333 $CHECKSTAT -a $DIR/$tfile || error "$tfile not gone"
1335 run_test 26f "rm -r of a directory which has recursive symlink ="
1338 echo '== stripe sanity =============================================='
1339 test_mkdir -p $DIR/d27 || error "mkdir failed"
1341 $SETSTRIPE -c 1 $DIR/d27/f0 || error "setstripe failed"
1342 $CHECKSTAT -t file $DIR/d27/f0 || error "checkstat failed"
1343 log "== test_27a: write to one stripe file ========================="
1344 cp /etc/hosts $DIR/d27/f0 || error
1346 run_test 27a "one stripe file =================================="
1349 [[ $OSTCOUNT -lt 2 ]] && skip_env "skipping 2-stripe test" && return
1350 test_mkdir -p $DIR/d27
1351 $SETSTRIPE -c 2 $DIR/d27/f01 || error "setstripe failed"
1352 $GETSTRIPE -c $DIR/d27/f01
1353 [ $($GETSTRIPE -c $DIR/d27/f01) -eq 2 ] ||
1354 error "two-stripe file doesn't have two stripes"
1356 dd if=/dev/zero of=$DIR/d27/f01 bs=4k count=4 || error "dd failed"
1358 run_test 27b "create and write to two stripe file"
1361 test_mkdir -p $DIR/d27
1362 $SETSTRIPE -c 0 -i -1 -S 0 $DIR/d27/fdef || error "setstripe failed"
1363 $CHECKSTAT -t file $DIR/d27/fdef || error "checkstat failed"
1364 dd if=/dev/zero of=$DIR/d27/fdef bs=4k count=4 || error
1366 run_test 27d "create file with default settings ================"
1369 test_mkdir -p $DIR/d27
1370 $SETSTRIPE -c 2 $DIR/d27/f12 || error "setstripe failed"
1371 $SETSTRIPE -c 2 $DIR/d27/f12 && error "setstripe succeeded twice"
1372 $CHECKSTAT -t file $DIR/d27/f12 || error "checkstat failed"
1374 run_test 27e "setstripe existing file (should return error) ======"
1377 test_mkdir -p $DIR/d27
1378 $SETSTRIPE -S 100 -i 0 -c 1 $DIR/d27/fbad && error "setstripe failed"
1379 dd if=/dev/zero of=$DIR/d27/fbad bs=4k count=4 || error "dd failed"
1380 $GETSTRIPE $DIR/d27/fbad || error "$GETSTRIPE failed"
1382 run_test 27f "setstripe with bad stripe size (should return error)"
1385 test_mkdir -p $DIR/d27
1386 $MCREATE $DIR/d27/fnone || error "mcreate failed"
1387 $GETSTRIPE $DIR/d27/fnone 2>&1 | grep "no stripe info" ||
1388 error "$DIR/d27/fnone has object"
1390 run_test 27g "$GETSTRIPE with no objects"
1393 touch $DIR/d27/fsome || error "touch failed"
1394 [[ $($GETSTRIPE -c $DIR/d27/fsome) -gt 0 ]] || error "missing objects"
1396 run_test 27i "$GETSTRIPE with some objects"
1399 test_mkdir -p $DIR/d27
1400 $SETSTRIPE -i $OSTCOUNT $DIR/d27/f27j && error "setstripe failed"||true
1402 run_test 27j "setstripe with bad stripe offset (should return error)"
1404 test_27k() { # bug 2844
1405 test_mkdir -p $DIR/d27
1407 LL_MAX_BLKSIZE=$((4 * 1024 * 1024))
1408 [ ! -d $DIR/d27 ] && test_mkdir -p $DIR d27
1409 $SETSTRIPE -S 67108864 $FILE || error "setstripe failed"
1410 BLKSIZE=`stat $FILE | awk '/IO Block:/ { print $7 }'`
1411 [ $BLKSIZE -le $LL_MAX_BLKSIZE ] || error "1:$BLKSIZE > $LL_MAX_BLKSIZE"
1412 dd if=/dev/zero of=$FILE bs=4k count=1
1413 BLKSIZE=`stat $FILE | awk '/IO Block:/ { print $7 }'`
1414 [ $BLKSIZE -le $LL_MAX_BLKSIZE ] || error "2:$BLKSIZE > $LL_MAX_BLKSIZE"
1416 run_test 27k "limit i_blksize for broken user apps ============="
1419 test_mkdir -p $DIR/d27
1420 mcreate $DIR/f27l || error "creating file"
1421 $RUNAS $SETSTRIPE -c 1 $DIR/f27l && \
1422 error "setstripe should have failed" || true
1424 run_test 27l "check setstripe permissions (should return error)"
1427 [[ $OSTCOUNT -lt 2 ]] && skip_env "$OSTCOUNT < 2 OSTs -- skipping" &&
1429 if [[ $ORIGFREE -gt $MAXFREE ]]; then
1430 skip "$ORIGFREE > $MAXFREE skipping out-of-space test on OST0"
1433 trap simple_cleanup_common EXIT
1434 test_mkdir -p $DIR/$tdir
1435 $SETSTRIPE -i 0 -c 1 $DIR/$tdir/f27m_1
1436 dd if=/dev/zero of=$DIR/$tdir/f27m_1 bs=1024 count=$MAXFREE &&
1437 error "dd should fill OST0"
1439 while $SETSTRIPE -i 0 -c 1 $DIR/$tdir/f27m_$i; do
1441 [ $i -gt 256 ] && break
1444 touch $DIR/$tdir/f27m_$i
1445 [ `$GETSTRIPE $DIR/$tdir/f27m_$i | grep -A 10 obdidx | awk '{print $1}'| grep -w "0"` ] &&
1446 error "OST0 was full but new created file still use it"
1448 touch $DIR/$tdir/f27m_$i
1449 [ `$GETSTRIPE $DIR/$tdir/f27m_$i | grep -A 10 obdidx | awk '{print $1}'| grep -w "0"` ] &&
1450 error "OST0 was full but new created file still use it"
1451 simple_cleanup_common
1453 run_test 27m "create file while OST0 was full =================="
1456 local DELAY=$(do_facet $SINGLEMDS lctl get_param -n lov.*.qos_maxage | head -n 1 | awk '{print $1 * 2}')
1460 # OSCs keep a NOSPC flag that will be reset after ~5s (qos_maxage)
1461 # if the OST isn't full anymore.
1463 local OSTIDX=${1:-""}
1465 local list=$(comma_list $(osts_nodes))
1466 [ "$OSTIDX" ] && list=$(facet_host ost$((OSTIDX + 1)))
1468 do_nodes $list lctl set_param fail_loc=0
1469 sync # initiate all OST_DESTROYs from MDS to OST
1473 exhaust_precreations() {
1476 local FAILIDX=${3:-$OSTIDX}
1478 test_mkdir -p $DIR/$tdir
1479 local MDSIDX=$(get_mds_dir "$DIR/$tdir")
1480 echo OSTIDX=$OSTIDX MDSIDX=$MDSIDX
1482 local OST=$(ostname_from_index $OSTIDX)
1483 local MDT_INDEX=$(lfs df | grep "\[MDT:$((MDSIDX - 1))\]" | awk '{print $1}' | \
1484 sed -e 's/_UUID$//;s/^.*-//')
1487 local mdtosc_proc1=$(get_mdtosc_proc_path mds${MDSIDX} $OST)
1488 local last_id=$(do_facet mds${MDSIDX} lctl get_param -n \
1489 osc.$mdtosc_proc1.prealloc_last_id)
1490 local next_id=$(do_facet mds${MDSIDX} lctl get_param -n \
1491 osc.$mdtosc_proc1.prealloc_next_id)
1493 local mdtosc_proc2=$(get_mdtosc_proc_path mds${MDSIDX})
1494 do_facet mds${MDSIDX} lctl get_param osc.$mdtosc_proc2.prealloc*
1496 test_mkdir -p $DIR/$tdir/${OST}
1497 $SETSTRIPE -i $OSTIDX -c 1 $DIR/$tdir/${OST}
1498 #define OBD_FAIL_OST_ENOSPC 0x215
1499 do_facet ost$((OSTIDX + 1)) lctl set_param fail_val=$FAILIDX
1500 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=0x215
1501 echo "Creating to objid $last_id on ost $OST..."
1502 createmany -o $DIR/$tdir/${OST}/f $next_id $((last_id - next_id + 2))
1503 do_facet mds${MDSIDX} lctl get_param osc.$mdtosc_proc2.prealloc*
1504 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=$FAILLOC
1508 exhaust_all_precreations() {
1510 for (( i=0; i < OSTCOUNT; i++ )) ; do
1511 exhaust_precreations $i $1 -1
1516 [[ $OSTCOUNT -lt 2 ]] && skip_env "too few OSTs" && return
1517 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1518 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1519 remote_ost_nodsh && skip "remote OST with nodsh" && return
1522 rm -f $DIR/$tdir/$tfile
1523 exhaust_precreations 0 0x80000215
1524 $SETSTRIPE -c -1 $DIR/$tdir
1525 touch $DIR/$tdir/$tfile || error
1526 $GETSTRIPE $DIR/$tdir/$tfile
1529 run_test 27n "create file with some full OSTs =================="
1532 [[ $OSTCOUNT -lt 2 ]] && skip_env "too few OSTs" && return
1533 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1534 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1535 remote_ost_nodsh && skip "remote OST with nodsh" && return
1538 rm -f $DIR/$tdir/$tfile
1539 exhaust_all_precreations 0x215
1541 touch $DIR/$tdir/$tfile && error "able to create $DIR/$tdir/$tfile"
1546 run_test 27o "create file with all full OSTs (should error) ===="
1549 [[ $OSTCOUNT -lt 2 ]] && skip_env "too few OSTs" && return
1550 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1551 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1552 remote_ost_nodsh && skip "remote OST with nodsh" && return
1555 rm -f $DIR/$tdir/$tfile
1556 test_mkdir -p $DIR/$tdir
1558 $MCREATE $DIR/$tdir/$tfile || error "mcreate failed"
1559 $TRUNCATE $DIR/$tdir/$tfile 80000000 || error "truncate failed"
1560 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat failed"
1562 exhaust_precreations 0 0x80000215
1563 echo foo >> $DIR/$tdir/$tfile || error "append failed"
1564 $CHECKSTAT -s 80000004 $DIR/$tdir/$tfile || error "checkstat failed"
1565 $GETSTRIPE $DIR/$tdir/$tfile
1569 run_test 27p "append to a truncated file with some full OSTs ==="
1572 [[ $OSTCOUNT -lt 2 ]] && skip_env "too few OSTs" && return
1573 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1574 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1575 remote_ost_nodsh && skip "remote OST with nodsh" && return
1578 rm -f $DIR/$tdir/$tfile
1580 test_mkdir -p $DIR/$tdir
1581 $MCREATE $DIR/$tdir/$tfile || error "mcreate $DIR/$tdir/$tfile failed"
1582 $TRUNCATE $DIR/$tdir/$tfile 80000000 ||error "truncate $DIR/$tdir/$tfile failed"
1583 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat failed"
1585 exhaust_all_precreations 0x215
1587 echo foo >> $DIR/$tdir/$tfile && error "append succeeded"
1588 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat 2 failed"
1592 run_test 27q "append to truncated file with all OSTs full (should error) ==="
1595 [[ $OSTCOUNT -lt 2 ]] && skip_env "too few OSTs" && return
1596 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1597 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1598 remote_ost_nodsh && skip "remote OST with nodsh" && return
1601 rm -f $DIR/$tdir/$tfile
1602 exhaust_precreations 0 0x80000215
1604 $SETSTRIPE -i 0 -c 2 $DIR/$tdir/$tfile # && error
1608 run_test 27r "stripe file with some full OSTs (shouldn't LBUG) ="
1610 test_27s() { # bug 10725
1611 test_mkdir -p $DIR/$tdir
1612 local stripe_size=$((4096 * 1024 * 1024)) # 2^32
1613 local stripe_count=0
1614 [ $OSTCOUNT -eq 1 ] || stripe_count=2
1615 $SETSTRIPE -S $stripe_size -c $stripe_count $DIR/$tdir &&
1616 error "stripe width >= 2^32 succeeded" || true
1619 run_test 27s "lsm_xfersize overflow (should error) (bug 10725)"
1621 test_27t() { # bug 10864
1626 $WLFS getstripe $tfile
1629 run_test 27t "check that utils parse path correctly"
1631 test_27u() { # bug 4900
1632 [[ $OSTCOUNT -lt 2 ]] && skip_env "too few OSTs" && return
1633 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1635 local list=$(comma_list $(mdts_nodes))
1637 #define OBD_FAIL_MDS_OSC_PRECREATE 0x139
1638 do_nodes $list $LCTL set_param fail_loc=0x139
1639 test_mkdir -p $DIR/$tdir
1641 createmany -o $DIR/$tdir/t- 1000
1642 do_nodes $list $LCTL set_param fail_loc=0
1644 TLOG=$DIR/$tfile.getstripe
1645 $GETSTRIPE $DIR/$tdir > $TLOG
1646 OBJS=$(awk -vobj=0 '($1 == 0) { obj += 1 } END { print obj; }' $TLOG)
1647 unlinkmany $DIR/$tdir/t- 1000
1648 [[ $OBJS -gt 0 ]] &&
1649 error "$OBJS objects created on OST-0. See $TLOG" || pass
1651 run_test 27u "skip object creation on OSC w/o objects =========="
1653 test_27v() { # bug 4900
1654 [[ $OSTCOUNT -lt 2 ]] && skip_env "too few OSTs" && return
1655 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1656 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1657 remote_ost_nodsh && skip "remote OST with nodsh" && return
1659 exhaust_all_precreations 0x215
1662 test_mkdir -p $DIR/$tdir
1663 $SETSTRIPE -c 1 $DIR/$tdir # 1 stripe / file
1665 touch $DIR/$tdir/$tfile
1666 #define OBD_FAIL_TGT_DELAY_PRECREATE 0x705
1668 for (( i=1; i < OSTCOUNT; i++ )); do
1669 do_facet ost$i lctl set_param fail_loc=0x705
1671 local START=`date +%s`
1672 createmany -o $DIR/$tdir/$tfile 32
1674 local FINISH=`date +%s`
1675 local TIMEOUT=`lctl get_param -n timeout`
1676 local PROCESS=$((FINISH - START))
1677 [ $PROCESS -ge $((TIMEOUT / 2)) ] && \
1678 error "$FINISH - $START >= $TIMEOUT / 2"
1679 sleep $((TIMEOUT / 2 - PROCESS))
1682 run_test 27v "skip object creation on slow OST ================="
1684 test_27w() { # bug 10997
1685 test_mkdir -p $DIR/$tdir || error "mkdir failed"
1686 $SETSTRIPE -S 65536 $DIR/$tdir/f0 || error "setstripe failed"
1687 [ $($GETSTRIPE -S $DIR/$tdir/f0) -ne 65536 ] &&
1688 error "stripe size $size != 65536" || true
1689 [ $($GETSTRIPE -d $DIR/$tdir | grep -c "stripe_count") -ne 1 ] &&
1690 error "$GETSTRIPE -d $DIR/$tdir failed" || true
1692 run_test 27w "check $SETSTRIPE -S option"
1695 [[ $OSTCOUNT -lt 2 ]] &&
1696 skip_env "skipping multiple stripe count/offset test" && return
1698 test_mkdir -p $DIR/$tdir || error "mkdir failed"
1699 for i in $(seq 1 $OSTCOUNT); do
1701 $SETSTRIPE -c $i -i $offset $DIR/$tdir/f$i ||
1702 error "setstripe -c $i -i $offset failed"
1703 count=$($GETSTRIPE -c $DIR/$tdir/f$i)
1704 index=$($GETSTRIPE -i $DIR/$tdir/f$i)
1705 [ $count -ne $i ] && error "stripe count $count != $i" || true
1706 [ $index -ne $offset ] &&
1707 error "stripe offset $index != $offset" || true
1710 run_test 27wa "check $SETSTRIPE -c -i options"
1713 remote_ost_nodsh && skip "remote OST with nodsh" && return
1714 [[ $OSTCOUNT -lt 2 ]] && skip_env "$OSTCOUNT < 2 OSTs" && return
1715 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1716 OFFSET=$(($OSTCOUNT - 1))
1718 local OST=$(ostname_from_index $OSTIDX)
1720 test_mkdir -p $DIR/$tdir
1721 $SETSTRIPE -c 1 $DIR/$tdir # 1 stripe per file
1722 do_facet ost$((OSTIDX + 1)) lctl set_param -n obdfilter.$OST.degraded 1
1724 createmany -o $DIR/$tdir/$tfile $OSTCOUNT
1725 for i in `seq 0 $OFFSET`; do
1726 [ `$GETSTRIPE $DIR/$tdir/$tfile$i | grep -A 10 obdidx | awk '{print $1}' | grep -w "$OSTIDX"` ] &&
1727 error "OST0 was degraded but new created file still use it"
1729 do_facet ost$((OSTIDX + 1)) lctl set_param -n obdfilter.$OST.degraded 0
1731 run_test 27x "create files while OST0 is degraded"
1734 [[ $OSTCOUNT -lt 2 ]] &&
1735 skip_env "$OSTCOUNT < 2 OSTs -- skipping" && return
1736 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1737 remote_ost_nodsh && skip "remote OST with nodsh" && return
1738 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1740 local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS $FSNAME-OST0000)
1741 local last_id=$(do_facet $SINGLEMDS lctl get_param -n \
1742 osc.$mdtosc.prealloc_last_id)
1743 local next_id=$(do_facet $SINGLEMDS lctl get_param -n \
1744 osc.$mdtosc.prealloc_next_id)
1745 local fcount=$((last_id - next_id))
1746 [[ $fcount -eq 0 ]] && skip "not enough space on OST0" && return
1747 [[ $fcount -gt $OSTCOUNT ]] && fcount=$OSTCOUNT
1749 local MDS_OSCS=$(do_facet $SINGLEMDS lctl dl |
1750 awk '/[oO][sS][cC].*md[ts]/ { print $4 }')
1751 local OST_DEACTIVE_IDX=-1
1756 for OSC in $MDS_OSCS; do
1757 OST=$(osc_to_ost $OSC)
1758 OSTIDX=$(index_from_ostuuid $OST)
1759 if [ $OST_DEACTIVE_IDX == -1 ]; then
1760 OST_DEACTIVE_IDX=$OSTIDX
1762 if [ $OSTIDX != $OST_DEACTIVE_IDX ]; then
1763 echo $OSC "is Deactivated:"
1764 do_facet $SINGLEMDS lctl --device %$OSC deactivate
1768 OSTIDX=$(index_from_ostuuid $OST)
1770 $SETSTRIPE -c 1 $DIR/$tdir # 1 stripe / file
1772 for OSC in $MDS_OSCS; do
1773 OST=$(osc_to_ost $OSC)
1774 OSTIDX=$(index_from_ostuuid $OST)
1775 if [ $OSTIDX == $OST_DEACTIVE_IDX ]; then
1776 echo $OST "is degraded:"
1777 do_facet ost$((OSTIDX+1)) lctl set_param -n \
1778 obdfilter.$OST.degraded=1
1783 createmany -o $DIR/$tdir/$tfile $fcount
1785 for OSC in $MDS_OSCS; do
1786 OST=$(osc_to_ost $OSC)
1787 OSTIDX=$(index_from_ostuuid $OST)
1788 if [ $OSTIDX == $OST_DEACTIVE_IDX ]; then
1789 echo $OST "is recovered from degraded:"
1790 do_facet ost$((OSTIDX+1)) lctl set_param -n \
1791 obdfilter.$OST.degraded=0
1793 do_facet $SINGLEMDS lctl --device %$OSC activate
1797 # all osp devices get activated, hence -1 stripe count restored
1800 # sleep 2*lod_qos_maxage seconds waiting for lod qos to notice osp
1801 # devices get activated.
1803 $SETSTRIPE -c -1 $DIR/$tfile
1804 stripecnt=$($GETSTRIPE -c $DIR/$tfile)
1806 [ $stripecnt -ne $OSTCOUNT ] &&
1807 error "Of $OSTCOUNT OSTs, only $stripecnt is available"
1810 run_test 27y "create files while OST0 is degraded and the rest inactive"
1816 lmm_count=$($GETSTRIPE -c $1)
1817 lmm_seq=$($GETSTRIPE -v $1 | awk '/lmm_seq/ { print $2 }')
1818 lmm_oid=$($GETSTRIPE -v $1 | awk '/lmm_object_id/ { print $2 }')
1820 local old_ifs="$IFS"
1822 fid=($($LFS path2fid $1))
1825 log "FID seq ${fid[1]}, oid ${fid[2]} ver ${fid[3]}"
1826 log "LOV seq $lmm_seq, oid $lmm_oid, count: $lmm_count"
1828 # compare lmm_seq and lu_fid->f_seq
1829 [ $lmm_seq = ${fid[1]} ] || { error "SEQ mismatch"; return 1; }
1830 # compare lmm_object_id and lu_fid->oid
1831 [ $lmm_oid = ${fid[2]} ] || { error "OID mismatch"; return 2; }
1833 # check the trusted.fid attribute of the OST objects of the file
1834 local have_obdidx=false
1836 $GETSTRIPE $1 | while read obdidx oid hex seq; do
1837 # skip lines up to and including "obdidx"
1838 [ -z "$obdidx" ] && break
1839 [ "$obdidx" = "obdidx" ] && have_obdidx=true && continue
1840 $have_obdidx || continue
1842 local ost=$((obdidx + 1))
1843 local dev=$(ostdevname $ost)
1846 log "want: stripe:$stripe_nr ost:$obdidx oid:$oid/$hex seq:$seq"
1848 seq=$(echo $seq | sed -e "s/^0x//g")
1849 if [ $seq == 0 ]; then
1850 oid_hex=$(echo $oid)
1852 oid_hex=$(echo $hex | sed -e "s/^0x//g")
1854 local obj_file="O/$seq/d$((oid %32))/$oid_hex"
1858 # Don't unmount/remount the OSTs if we don't need to do that.
1859 # LU-2577 changes filter_fid to be smaller, so debugfs needs
1860 # update too, until that use mount/ll_decode_filter_fid/mount.
1861 # Re-enable when debugfs will understand new filter_fid.
1863 if false && [ $(facet_fstype ost$ost) == ldiskfs ]; then
1864 ff=$(do_facet ost$ost "$DEBUGFS -c -R 'stat $obj_file' \
1865 $dev 2>/dev/null" | grep "parent=")
1868 mount_fstype ost$ost
1869 ff=$(do_facet ost$ost $LL_DECODE_FILTER_FID \
1870 $(facet_mntpt ost$ost)/$obj_file)
1871 unmount_fstype ost$ost
1872 start ost$ost $dev $OST_MOUNT_OPTS
1875 [ -z "$ff" ] && error "$obj_file: no filter_fid info"
1877 echo "$ff" | sed -e 's#.*objid=#got: objid=#'
1879 # /mnt/O/0/d23/23: objid=23 seq=0 parent=[0x200000400:0x1e:0x1]
1880 # fid: objid=23 seq=0 parent=[0x200000400:0x1e:0x0] stripe=1
1881 local ff_parent=$(echo $ff|sed -e 's/.*parent=.//')
1882 local ff_pseq=$(echo $ff_parent | cut -d: -f1)
1883 local ff_poid=$(echo $ff_parent | cut -d: -f2)
1885 if echo $ff_parent | grep -q 'stripe='; then
1886 ff_pstripe=$(echo $ff_parent | sed -e 's/.*stripe=//')
1889 # $LL_DECODE_FILTER_FID does not print "stripe="; look
1890 # into f_ver in this case. See the comment on
1893 ff_pstripe=$(echo $ff_parent | cut -d: -f3 |
1897 # compare lmm_seq and filter_fid->ff_parent.f_seq
1898 [ $ff_pseq = $lmm_seq ] ||
1899 error "FF parent SEQ $ff_pseq != $lmm_seq"
1900 # compare lmm_object_id and filter_fid->ff_parent.f_oid
1901 [ $ff_poid = $lmm_oid ] ||
1902 error "FF parent OID $ff_poid != $lmm_oid"
1903 (($ff_pstripe == $stripe_nr)) ||
1904 error "FF stripe $ff_pstripe != $stripe_nr"
1906 stripe_nr=$((stripe_nr + 1))
1911 remote_ost_nodsh && skip "remote OST with nodsh" && return
1912 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1913 test_mkdir -p $DIR/$tdir
1915 $SETSTRIPE -c 1 -i 0 -S 64k $DIR/$tdir/$tfile-1 ||
1916 { error "setstripe -c -1 failed"; return 1; }
1917 # We need to send a write to every object to get parent FID info set.
1918 # This _should_ also work for setattr, but does not currently.
1919 # touch $DIR/$tdir/$tfile-1 ||
1920 dd if=/dev/zero of=$DIR/$tdir/$tfile-1 bs=1M count=1 ||
1921 { error "dd $tfile-1 failed"; return 2; }
1922 $SETSTRIPE -c -1 -i $((OSTCOUNT - 1)) -S 1M $DIR/$tdir/$tfile-2 ||
1923 { error "setstripe -c -1 failed"; return 3; }
1924 dd if=/dev/zero of=$DIR/$tdir/$tfile-2 bs=1M count=$OSTCOUNT ||
1925 { error "dd $tfile-2 failed"; return 4; }
1927 # make sure write RPCs have been sent to OSTs
1930 check_seq_oid $DIR/$tdir/$tfile-1 || return 5
1931 check_seq_oid $DIR/$tdir/$tfile-2 || return 6
1933 run_test 27z "check SEQ/OID on the MDT and OST filesystems"
1935 test_27A() { # b=19102
1936 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1937 local restore_size=$($GETSTRIPE -S $MOUNT)
1938 local restore_count=$($GETSTRIPE -c $MOUNT)
1939 local restore_offset=$($GETSTRIPE -i $MOUNT)
1940 $SETSTRIPE -c 0 -i -1 -S 0 $MOUNT
1941 wait_update $HOSTNAME "$GETSTRIPE -c $MOUNT | sed 's/ *//g'" "1" 20 ||
1942 error "stripe count $($GETSTRIPE -c $MOUNT) != 1"
1943 local default_size=$($GETSTRIPE -S $MOUNT)
1944 local default_offset=$($GETSTRIPE -i $MOUNT)
1945 local dsize=$((1024 * 1024))
1946 [ $default_size -eq $dsize ] ||
1947 error "stripe size $default_size != $dsize"
1948 [ $default_offset -eq -1 ] ||error "stripe offset $default_offset != -1"
1949 $SETSTRIPE -c $restore_count -i $restore_offset -S $restore_size $MOUNT
1951 run_test 27A "check filesystem-wide default LOV EA values"
1953 test_27B() { # LU-2523
1954 test_mkdir -p $DIR/$tdir
1955 rm -f $DIR/$tdir/f0 $DIR/$tdir/f1
1957 # open f1 with O_LOV_DELAY_CREATE
1959 # call setstripe ioctl on open file descriptor for f1
1961 multiop $DIR/$tdir/f1 oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:nB1c \
1965 # open f1 with O_LOV_DELAY_CREATE
1967 # call setstripe ioctl on open file descriptor for f1
1969 multiop $DIR/$tdir/f1 oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:uB1c
1971 # Allow multiop to fail in imitation of NFS's busted semantics.
1974 run_test 27B "call setstripe on open unlinked file/rename victim"
1976 test_27C() { #LU-2871
1977 [[ $OSTCOUNT -lt 2 ]] && skip "needs >= 2 OSTs" && return
1985 test_mkdir -p $DIR/$tdir
1987 for i in $(seq 0 $((OSTCOUNT - 1))); do
1988 # set stripe across all OSTs starting from OST$i
1989 $SETSTRIPE -i $i -c -1 $tfile$i
1990 # get striping information
1991 ost_idx=($($GETSTRIPE $tfile$i |
1992 tail -n $((OSTCOUNT + 1)) | awk '{print $1}'))
1996 [ ${#ost_idx[@]} -eq $OSTCOUNT ] ||
1997 error "${#ost_idx[@]} != $OSTCOUNT"
1999 for index in $(seq 0 $((OSTCOUNT - 1))); do
2001 for j in $(echo ${ost_idx[@]}); do
2002 if [ $index -eq $j ]; then
2008 error "Can not find $index in ${ost_idx[@]}"
2012 run_test 27C "check full striping across all OSTs"
2014 # createtest also checks that device nodes are created and
2015 # then visible correctly (#2091)
2016 test_28() { # bug 2091
2018 $CREATETEST $DIR/d28/ct || error
2020 run_test 28 "create/mknod/mkdir with bad file types ============"
2023 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2024 cancel_lru_locks mdc
2030 declare -i LOCKCOUNTORIG=0
2031 for lock_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_count); do
2032 let LOCKCOUNTORIG=$LOCKCOUNTORIG+$lock_count
2034 [ $LOCKCOUNTORIG -eq 0 ] && echo "No mdc lock count" && return 1
2036 declare -i LOCKUNUSEDCOUNTORIG=0
2037 for unused_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_unused_count); do
2038 let LOCKUNUSEDCOUNTORIG=$LOCKUNUSEDCOUNTORIG+$unused_count
2045 declare -i LOCKCOUNTCURRENT=0
2046 for lock_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_count); do
2047 let LOCKCOUNTCURRENT=$LOCKCOUNTCURRENT+$lock_count
2050 declare -i LOCKUNUSEDCOUNTCURRENT=0
2051 for unused_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_unused_count); do
2052 let LOCKUNUSEDCOUNTCURRENT=$LOCKUNUSEDCOUNTCURRENT+$unused_count
2055 if [[ $LOCKCOUNTCURRENT -gt $LOCKCOUNTORIG ]]; then
2056 $LCTL set_param -n ldlm.dump_namespaces ""
2057 error "CURRENT: $LOCKCOUNTCURRENT > $LOCKCOUNTORIG"
2058 $LCTL dk | sort -k4 -t: > $TMP/test_29.dk
2059 log "dumped log to $TMP/test_29.dk (bug 5793)"
2062 if [[ $LOCKUNUSEDCOUNTCURRENT -gt $LOCKUNUSEDCOUNTORIG ]]; then
2063 error "UNUSED: $LOCKUNUSEDCOUNTCURRENT > $LOCKUNUSEDCOUNTORIG"
2064 $LCTL dk | sort -k4 -t: > $TMP/test_29.dk
2065 log "dumped log to $TMP/test_29.dk (bug 5793)"
2069 run_test 29 "IT_GETATTR regression ============================"
2071 test_30a() { # was test_30
2072 cp $(which ls) $DIR || cp /bin/ls $DIR
2076 run_test 30a "execute binary from Lustre (execve) =============="
2079 cp `which ls` $DIR || cp /bin/ls $DIR
2081 $RUNAS $DIR/ls / || error
2084 run_test 30b "execute binary from Lustre as non-root ==========="
2086 test_30c() { # b=22376
2087 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2088 cp `which ls` $DIR || cp /bin/ls $DIR
2090 cancel_lru_locks mdc
2091 cancel_lru_locks osc
2092 $RUNAS $DIR/ls / || error
2095 run_test 30c "execute binary from Lustre without read perms ===="
2098 $OPENUNLINK $DIR/f31 $DIR/f31 || error
2099 $CHECKSTAT -a $DIR/f31 || error
2101 run_test 31a "open-unlink file =================================="
2104 touch $DIR/f31 || error
2105 ln $DIR/f31 $DIR/f31b || error
2106 $MULTIOP $DIR/f31b Ouc || error
2107 $CHECKSTAT -t file $DIR/f31 || error
2109 run_test 31b "unlink file with multiple links while open ======="
2112 touch $DIR/f31 || error
2113 ln $DIR/f31 $DIR/f31c || error
2114 multiop_bg_pause $DIR/f31 O_uc || return 1
2116 $MULTIOP $DIR/f31c Ouc
2117 kill -USR1 $MULTIPID
2120 run_test 31c "open-unlink file with multiple links ============="
2123 opendirunlink $DIR/d31d $DIR/d31d || error
2124 $CHECKSTAT -a $DIR/d31d || error
2126 run_test 31d "remove of open directory ========================="
2128 test_31e() { # bug 2904
2129 check_kernel_version 34 || return 0
2130 openfilleddirunlink $DIR/d31e || error
2132 run_test 31e "remove of open non-empty directory ==============="
2134 test_31f() { # bug 4554
2135 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2137 test_mkdir $DIR/d31f
2138 $SETSTRIPE -S 1048576 -c 1 $DIR/d31f
2139 cp /etc/hosts $DIR/d31f
2141 $GETSTRIPE $DIR/d31f/hosts
2142 multiop_bg_pause $DIR/d31f D_c || return 1
2145 rm -rv $DIR/d31f || error "first of $DIR/d31f"
2146 test_mkdir $DIR/d31f
2147 $SETSTRIPE -S 1048576 -c 1 $DIR/d31f
2148 cp /etc/hosts $DIR/d31f
2150 $GETSTRIPE $DIR/d31f/hosts
2151 multiop_bg_pause $DIR/d31f D_c || return 1
2154 kill -USR1 $MULTIPID || error "first opendir $MULTIPID not running"
2155 wait $MULTIPID || error "first opendir $MULTIPID failed"
2159 kill -USR1 $MULTIPID2 || error "second opendir $MULTIPID not running"
2160 wait $MULTIPID2 || error "second opendir $MULTIPID2 failed"
2163 run_test 31f "remove of open directory with open-unlink file ==="
2166 echo "-- cross directory link --"
2167 test_mkdir -c1 $DIR/${tdir}ga
2168 test_mkdir -c1 $DIR/${tdir}gb
2169 touch $DIR/${tdir}ga/f
2170 ln $DIR/${tdir}ga/f $DIR/${tdir}gb/g
2171 $CHECKSTAT -t file $DIR/${tdir}ga/f || error "source"
2172 [ `stat -c%h $DIR/${tdir}ga/f` == '2' ] || error "source nlink"
2173 $CHECKSTAT -t file $DIR/${tdir}gb/g || error "target"
2174 [ `stat -c%h $DIR/${tdir}gb/g` == '2' ] || error "target nlink"
2176 run_test 31g "cross directory link==============="
2179 echo "-- cross directory link --"
2180 test_mkdir -c1 $DIR/${tdir}
2181 test_mkdir -c1 $DIR/${tdir}/dir
2182 touch $DIR/${tdir}/f
2183 ln $DIR/${tdir}/f $DIR/${tdir}/dir/g
2184 $CHECKSTAT -t file $DIR/${tdir}/f || error "source"
2185 [ `stat -c%h $DIR/${tdir}/f` == '2' ] || error "source nlink"
2186 $CHECKSTAT -t file $DIR/${tdir}/dir/g || error "target"
2187 [ `stat -c%h $DIR/${tdir}/dir/g` == '2' ] || error "target nlink"
2189 run_test 31h "cross directory link under child==============="
2192 echo "-- cross directory link --"
2193 test_mkdir -c1 $DIR/$tdir
2194 test_mkdir -c1 $DIR/$tdir/dir
2195 touch $DIR/$tdir/dir/f
2196 ln $DIR/$tdir/dir/f $DIR/$tdir/g
2197 $CHECKSTAT -t file $DIR/$tdir/dir/f || error "source"
2198 [ `stat -c%h $DIR/$tdir/dir/f` == '2' ] || error "source nlink"
2199 $CHECKSTAT -t file $DIR/$tdir/g || error "target"
2200 [ `stat -c%h $DIR/$tdir/g` == '2' ] || error "target nlink"
2202 run_test 31i "cross directory link under parent==============="
2205 test_mkdir -c1 -p $DIR/$tdir
2206 test_mkdir -c1 -p $DIR/$tdir/dir1
2207 ln $DIR/$tdir/dir1 $DIR/$tdir/dir2 && error "ln for dir"
2208 link $DIR/$tdir/dir1 $DIR/$tdir/dir3 && error "link for dir"
2209 mlink $DIR/$tdir/dir1 $DIR/$tdir/dir4 && error "mlink for dir"
2210 mlink $DIR/$tdir/dir1 $DIR/$tdir/dir1 && error "mlink to the same dir"
2213 run_test 31j "link for directory==============="
2216 test_mkdir -c1 -p $DIR/$tdir
2218 touch $DIR/$tdir/exist
2219 mlink $DIR/$tdir/s $DIR/$tdir/t || error "mlink"
2220 mlink $DIR/$tdir/s $DIR/$tdir/exist && error "mlink to exist file"
2221 mlink $DIR/$tdir/s $DIR/$tdir/s && error "mlink to the same file"
2222 mlink $DIR/$tdir/s $DIR/$tdir && error "mlink to parent dir"
2223 mlink $DIR/$tdir $DIR/$tdir/s && error "mlink parent dir to target"
2224 mlink $DIR/$tdir/not-exist $DIR/$tdir/foo && error "mlink non-existing to new"
2225 mlink $DIR/$tdir/not-exist $DIR/$tdir/s && error "mlink non-existing to exist"
2228 run_test 31k "link to file: the same, non-existing, dir==============="
2234 touch $DIR/d31m2/exist
2235 mlink $DIR/d31m/s $DIR/d31m2/t || error "mlink"
2236 mlink $DIR/d31m/s $DIR/d31m2/exist && error "mlink to exist file"
2237 mlink $DIR/d31m/s $DIR/d31m2 && error "mlink to parent dir"
2238 mlink $DIR/d31m2 $DIR/d31m/s && error "mlink parent dir to target"
2239 mlink $DIR/d31m/not-exist $DIR/d31m2/foo && error "mlink non-existing to new"
2240 mlink $DIR/d31m/not-exist $DIR/d31m2/s && error "mlink non-existing to exist"
2243 run_test 31m "link to file: the same, non-existing, dir==============="
2246 touch $DIR/$tfile || error "cannot create '$DIR/$tfile'"
2247 nlink=$(stat --format=%h $DIR/$tfile)
2248 [ ${nlink:--1} -eq 1 ] || error "nlink is $nlink, expected 1"
2250 local cmd="exec $fd<$DIR/$tfile"
2253 trap "eval $cmd" EXIT
2254 nlink=$(stat --dereference --format=%h /proc/self/fd/$fd)
2255 [ ${nlink:--1} -eq 1 ] || error "nlink is $nlink, expected 1"
2256 rm $DIR/$tfile || error "cannot remove '$DIR/$tfile'"
2257 nlink=$(stat --dereference --format=%h /proc/self/fd/$fd)
2258 [ ${nlink:--1} -eq 0 ] || error "nlink is $nlink, expected 0"
2261 run_test 31n "check link count of unlinked file"
2264 local TEMPNAME=$(mktemp $1_XXXXXX)
2265 mlink $TEMPNAME $1 2> /dev/null &&
2266 echo "$BASHPID: link $TEMPNAME to $1 succeeded"
2270 test_31o() { # LU-2901
2272 for LOOP in $(seq 100); do
2273 rm -f $DIR/$tdir/$tfile*
2274 for THREAD in $(seq 8); do
2275 link_one $DIR/$tdir/$tfile.$LOOP &
2278 local LINKS=$(ls -1 $DIR/$tdir | grep -c $tfile.$LOOP)
2279 [[ $LINKS -gt 1 ]] && ls $DIR/$tdir &&
2280 error "$LINKS duplicate links to $tfile.$LOOP" &&
2284 run_test 31o "duplicate hard links with same filename"
2287 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2290 $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
2291 $LFS setdirstripe -D -c2 -t all_char $DIR/$tdir/striped_dir
2293 opendirunlink $DIR/$tdir/striped_dir/test1 ||
2294 error "open unlink test1 failed"
2295 opendirunlink $DIR/$tdir/striped_dir/test2 ||
2296 error "open unlink test2 failed"
2298 $CHECKSTAT -a $DIR/$tdir/striped_dir/test1 ||
2299 error "test1 still exists"
2300 $CHECKSTAT -a $DIR/$tdir/striped_dir/test2 ||
2301 error "test2 still exists"
2303 run_test 31p "remove of open striped directory"
2305 cleanup_test32_mount() {
2307 $UMOUNT -d $DIR/$tdir/ext2-mountpoint
2311 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2312 echo "== more mountpoints and symlinks ================="
2313 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2314 trap cleanup_test32_mount EXIT
2315 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2316 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2317 $CHECKSTAT -t dir $DIR/$tdir/ext2-mountpoint/.. || error
2318 cleanup_test32_mount
2320 run_test 32a "stat d32a/ext2-mountpoint/.. ====================="
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 ls -al $DIR/$tdir/ext2-mountpoint/.. || error
2329 cleanup_test32_mount
2331 run_test 32b "open d32b/ext2-mountpoint/.. ====================="
2334 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2335 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2336 trap cleanup_test32_mount EXIT
2337 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2338 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2339 test_mkdir -p $DIR/$tdir/d2/test_dir
2340 $CHECKSTAT -t dir $DIR/$tdir/ext2-mountpoint/../d2/test_dir || error
2341 cleanup_test32_mount
2343 run_test 32c "stat d32c/ext2-mountpoint/../d2/test_dir ========="
2346 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2347 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2348 trap cleanup_test32_mount EXIT
2349 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2350 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2351 test_mkdir -p $DIR/$tdir/d2/test_dir
2352 ls -al $DIR/$tdir/ext2-mountpoint/../d2/test_dir || error
2353 cleanup_test32_mount
2355 run_test 32d "open d32d/ext2-mountpoint/../d2/test_dir ========="
2358 [ -e $DIR/d32e ] && rm -fr $DIR/d32e
2359 test_mkdir -p $DIR/d32e/tmp
2360 TMP_DIR=$DIR/d32e/tmp
2361 ln -s $DIR/d32e $TMP_DIR/symlink11
2362 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
2363 $CHECKSTAT -t link $DIR/d32e/tmp/symlink11 || error
2364 $CHECKSTAT -t link $DIR/d32e/symlink01 || error
2366 run_test 32e "stat d32e/symlink->tmp/symlink->lustre-subdir ===="
2369 [ -e $DIR/d32f ] && rm -fr $DIR/d32f
2370 test_mkdir -p $DIR/d32f/tmp
2371 TMP_DIR=$DIR/d32f/tmp
2372 ln -s $DIR/d32f $TMP_DIR/symlink11
2373 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
2374 ls $DIR/d32f/tmp/symlink11 || error
2375 ls $DIR/d32f/symlink01 || error
2377 run_test 32f "open d32f/symlink->tmp/symlink->lustre-subdir ===="
2380 TMP_DIR=$DIR/$tdir/tmp
2381 test_mkdir -p $DIR/$tdir/tmp
2382 test_mkdir $DIR/${tdir}2
2383 ln -s $DIR/${tdir}2 $TMP_DIR/symlink12
2384 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
2385 $CHECKSTAT -t link $TMP_DIR/symlink12 || error
2386 $CHECKSTAT -t link $DIR/$tdir/symlink02 || error
2387 $CHECKSTAT -t dir -f $TMP_DIR/symlink12 || error
2388 $CHECKSTAT -t dir -f $DIR/$tdir/symlink02 || error
2390 run_test 32g "stat d32g/symlink->tmp/symlink->lustre-subdir/${tdir}2"
2393 rm -fr $DIR/$tdir $DIR/${tdir}2
2394 TMP_DIR=$DIR/$tdir/tmp
2395 test_mkdir -p $DIR/$tdir/tmp
2396 test_mkdir $DIR/${tdir}2
2397 ln -s $DIR/${tdir}2 $TMP_DIR/symlink12
2398 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
2399 ls $TMP_DIR/symlink12 || error
2400 ls $DIR/$tdir/symlink02 || error
2402 run_test 32h "open d32h/symlink->tmp/symlink->lustre-subdir/${tdir}2"
2405 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2406 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2407 trap cleanup_test32_mount EXIT
2408 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2409 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2410 touch $DIR/$tdir/test_file
2411 $CHECKSTAT -t file $DIR/$tdir/ext2-mountpoint/../test_file || error
2412 cleanup_test32_mount
2414 run_test 32i "stat d32i/ext2-mountpoint/../test_file ==========="
2417 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2418 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2419 trap cleanup_test32_mount EXIT
2420 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2421 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2422 touch $DIR/$tdir/test_file
2423 cat $DIR/$tdir/ext2-mountpoint/../test_file || error
2424 cleanup_test32_mount
2426 run_test 32j "open d32j/ext2-mountpoint/../test_file ==========="
2429 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2431 trap cleanup_test32_mount EXIT
2432 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2433 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint
2434 test_mkdir -p $DIR/$tdir/d2
2435 touch $DIR/$tdir/d2/test_file || error
2436 $CHECKSTAT -t file $DIR/$tdir/ext2-mountpoint/../d2/test_file || error
2437 cleanup_test32_mount
2439 run_test 32k "stat d32k/ext2-mountpoint/../d2/test_file ========"
2442 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2444 trap cleanup_test32_mount EXIT
2445 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2446 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2447 test_mkdir -p $DIR/$tdir/d2
2448 touch $DIR/$tdir/d2/test_file
2449 cat $DIR/$tdir/ext2-mountpoint/../d2/test_file || error
2450 cleanup_test32_mount
2452 run_test 32l "open d32l/ext2-mountpoint/../d2/test_file ========"
2456 test_mkdir -p $DIR/d32m/tmp
2457 TMP_DIR=$DIR/d32m/tmp
2458 ln -s $DIR $TMP_DIR/symlink11
2459 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
2460 $CHECKSTAT -t link $DIR/d32m/tmp/symlink11 || error
2461 $CHECKSTAT -t link $DIR/d32m/symlink01 || error
2463 run_test 32m "stat d32m/symlink->tmp/symlink->lustre-root ======"
2467 test_mkdir -p $DIR/d32n/tmp
2468 TMP_DIR=$DIR/d32n/tmp
2469 ln -s $DIR $TMP_DIR/symlink11
2470 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
2471 ls -l $DIR/d32n/tmp/symlink11 || error
2472 ls -l $DIR/d32n/symlink01 || error
2474 run_test 32n "open d32n/symlink->tmp/symlink->lustre-root ======"
2478 test_mkdir -p $DIR/d32o/tmp
2479 TMP_DIR=$DIR/d32o/tmp
2480 ln -s $DIR/$tfile $TMP_DIR/symlink12
2481 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
2482 $CHECKSTAT -t link $DIR/d32o/tmp/symlink12 || error
2483 $CHECKSTAT -t link $DIR/d32o/symlink02 || error
2484 $CHECKSTAT -t file -f $DIR/d32o/tmp/symlink12 || error
2485 $CHECKSTAT -t file -f $DIR/d32o/symlink02 || error
2487 run_test 32o "stat d32o/symlink->tmp/symlink->lustre-root/$tfile"
2497 test_mkdir -p $DIR/d32p/tmp
2499 TMP_DIR=$DIR/d32p/tmp
2501 ln -s $DIR/$tfile $TMP_DIR/symlink12
2503 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
2505 cat $DIR/d32p/tmp/symlink12 || error
2507 cat $DIR/d32p/symlink02 || error
2510 run_test 32p "open d32p/symlink->tmp/symlink->lustre-root/$tfile"
2512 cleanup_testdir_mount() {
2514 $UMOUNT -d $DIR/$tdir
2518 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2519 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2520 trap cleanup_testdir_mount EXIT
2521 test_mkdir -p $DIR/$tdir
2522 touch $DIR/$tdir/under_the_mount
2523 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir
2524 ls $DIR/$tdir | grep "\<under_the_mount\>" && error
2525 cleanup_testdir_mount
2527 run_test 32q "stat follows mountpoints in Lustre (should return error)"
2530 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2531 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2532 trap cleanup_testdir_mount EXIT
2533 test_mkdir -p $DIR/$tdir
2534 touch $DIR/$tdir/under_the_mount
2535 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir
2536 ls $DIR/$tdir | grep -q under_the_mount && error || true
2537 cleanup_testdir_mount
2539 run_test 32r "opendir follows mountpoints in Lustre (should return error)"
2544 chmod 444 $DIR/$tfile
2545 chown $RUNAS_ID $DIR/$tfile
2547 $RUNAS $OPENFILE -f O_RDWR $DIR/$tfile && error || true
2550 run_test 33aa "write file with mode 444 (should return error) ===="
2554 test_mkdir -p $DIR/d33
2555 chown $RUNAS_ID $DIR/d33
2556 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $DIR/d33/f33|| error "create"
2557 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $DIR/d33/f33 && \
2558 error "open RDWR" || true
2560 run_test 33a "test open file(mode=0444) with O_RDWR (should return error)"
2564 test_mkdir -p $DIR/d33
2565 chown $RUNAS_ID $DIR/d33
2566 $RUNAS $OPENFILE -f 1286739555 $DIR/d33/f33 && error "create" || true
2568 run_test 33b "test open file with malformed flags (No panic and return error)"
2571 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2577 remote_ost_nodsh && skip "remote OST with nodsh" && return
2580 test_mkdir -p $DIR/d33
2581 # Read: 0, Write: 4, create/destroy: 2/0, stat: 1, punch: 0
2584 for ostnum in $(seq $OSTCOUNT); do
2585 # test-framework's OST numbering is one-based, while Lustre's
2587 ostname=$(printf "$FSNAME-OST%.4x" $((ostnum - 1)))
2588 # Parsing llobdstat's output sucks; we could grep the /proc
2589 # path, but that's likely to not be as portable as using the
2590 # llobdstat utility. So we parse lctl output instead.
2591 write_bytes=$(do_facet ost$ostnum lctl get_param -n \
2592 obdfilter/$ostname/stats |
2593 awk '/^write_bytes/ {print $7}' )
2594 echo "baseline_write_bytes@$OSTnum/$ostname=$write_bytes"
2595 if (( ${write_bytes:-0} > 0 ))
2602 $all_zeros || return 0
2605 echo foo > $DIR/d33/bar
2609 # Total up write_bytes after writing. We'd better find non-zeros.
2610 for ostnum in $(seq $OSTCOUNT); do
2611 ostname=$(printf "$FSNAME-OST%.4x" $((ostnum - 1)))
2612 write_bytes=$(do_facet ost$ostnum lctl get_param -n \
2613 obdfilter/$ostname/stats |
2614 awk '/^write_bytes/ {print $7}' )
2615 echo "write_bytes@$OSTnum/$ostname=$write_bytes"
2616 if (( ${write_bytes:-0} > 0 ))
2625 for ostnum in $(seq $OSTCOUNT); do
2626 ostname=$(printf "$FSNAME-OST%.4x" $((ostnum - 1)))
2627 echo "Check that write_bytes is present in obdfilter/*/stats:"
2628 do_facet ost$ostnum lctl get_param -n \
2629 obdfilter/$ostname/stats
2631 error "OST not keeping write_bytes stats (b22312)"
2634 run_test 33c "test llobdstat and write_bytes"
2637 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 2 MDTs" && return
2638 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2640 local remote_dir=$DIR/$tdir/remote_dir
2643 $LFS mkdir -i $MDTIDX $remote_dir ||
2644 error "create remote directory failed"
2646 touch $remote_dir/$tfile
2647 chmod 444 $remote_dir/$tfile
2648 chown $RUNAS_ID $remote_dir/$tfile
2650 $RUNAS $OPENFILE -f O_RDWR $DIR/$tfile && error || true
2652 chown $RUNAS_ID $remote_dir
2653 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $remote_dir/f33 ||
2654 error "create" || true
2655 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $remote_dir/f33 &&
2656 error "open RDWR" || true
2657 $RUNAS $OPENFILE -f 1286739555 $remote_dir/f33 &&
2658 error "create" || true
2660 run_test 33d "openfile with 444 modes and malformed flags under remote dir"
2663 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2667 $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
2668 $LFS setdirstripe -i1 -c2 $DIR/$tdir/striped_dir1
2669 mkdir $DIR/$tdir/local_dir
2671 local s0_mode=$(stat -c%f $DIR/$tdir/striped_dir)
2672 local s1_mode=$(stat -c%f $DIR/$tdir/striped_dir1)
2673 local l_mode=$(stat -c%f $DIR/$tdir/local_dir)
2675 [ "$l_mode" = "$s0_mode" -a "$l_mode" = "$s1_mode" ] ||
2676 error "mkdir $l_mode striped0 $s0_mode striped1 $s1_mode"
2678 rmdir $DIR/$tdir/* || error "rmdir failed"
2681 $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
2682 $LFS setdirstripe -i1 -c2 $DIR/$tdir/striped_dir1
2683 mkdir $DIR/$tdir/local_dir
2685 s0_mode=$(stat -c%f $DIR/$tdir/striped_dir)
2686 s1_mode=$(stat -c%f $DIR/$tdir/striped_dir1)
2687 l_mode=$(stat -c%f $DIR/$tdir/local_dir)
2689 [ "$l_mode" = "$s0_mode" -a "$l_mode" = "$s1_mode" ] ||
2690 error "mkdir $l_mode striped0 $s0_mode striped1 $s1_mode 777"
2692 rmdir $DIR/$tdir/* || error "rmdir(umask 777) failed"
2695 $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
2696 $LFS setdirstripe -i1 -c2 $DIR/$tdir/striped_dir1
2697 mkdir $DIR/$tdir/local_dir
2699 s0_mode=$(stat -c%f $DIR/$tdir/striped_dir)
2700 s1_mode=$(stat -c%f $DIR/$tdir/striped_dir1)
2701 l_mode=$(stat -c%f $DIR/$tdir/local_dir)
2703 [ "$l_mode" = "$s0_mode" -a "$l_mode" = "$s1_mode" ] ||
2704 error "mkdir $l_mode striped0 $s0_mode striped1 $s1_mode 0"
2706 run_test 33e "mkdir and striped directory should have same mode"
2708 TEST_34_SIZE=${TEST_34_SIZE:-2000000000000}
2711 $MCREATE $DIR/f34 || error
2712 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" || error
2713 $TRUNCATE $DIR/f34 $TEST_34_SIZE || error
2714 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" || error
2715 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2717 run_test 34a "truncate file that has not been opened ==========="
2720 [ ! -f $DIR/f34 ] && test_34a
2721 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2722 $OPENFILE -f O_RDONLY $DIR/f34
2723 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" || error
2724 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2726 run_test 34b "O_RDONLY opening file doesn't create objects ====="
2729 [ ! -f $DIR/f34 ] && test_34a
2730 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2731 $OPENFILE -f O_RDWR $DIR/f34
2732 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" && error
2733 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2735 run_test 34c "O_RDWR opening file-with-size works =============="
2738 [ ! -f $DIR/f34 ] && test_34a
2739 dd if=/dev/zero of=$DIR/f34 conv=notrunc bs=4k count=1 || error
2740 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2743 run_test 34d "write to sparse file ============================="
2747 $MCREATE $DIR/f34e || error
2748 $TRUNCATE $DIR/f34e 1000 || error
2749 $CHECKSTAT -s 1000 $DIR/f34e || error
2750 $OPENFILE -f O_RDWR $DIR/f34e
2751 $CHECKSTAT -s 1000 $DIR/f34e || error
2753 run_test 34e "create objects, some with size and some without =="
2755 test_34f() { # bug 6242, 6243
2756 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2759 $MCREATE $DIR/f34f || error
2760 $TRUNCATE $DIR/f34f $SIZE34F || error "truncating $DIR/f3f to $SIZE34F"
2761 dd if=$DIR/f34f of=$TMP/f34f
2762 $CHECKSTAT -s $SIZE34F $TMP/f34f || error "$TMP/f34f not $SIZE34F bytes"
2763 dd if=/dev/zero of=$TMP/f34fzero bs=$SIZE34F count=1
2764 cmp $DIR/f34f $TMP/f34fzero || error "$DIR/f34f not all zero"
2765 cmp $TMP/f34f $TMP/f34fzero || error "$TMP/f34f not all zero"
2766 rm $TMP/f34f $TMP/f34fzero $DIR/f34f
2768 run_test 34f "read from a file with no objects until EOF ======="
2771 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2772 dd if=/dev/zero of=$DIR/$tfile bs=1 count=100 seek=$TEST_34_SIZE || error
2773 $TRUNCATE $DIR/$tfile $((TEST_34_SIZE / 2))|| error
2774 $CHECKSTAT -s $((TEST_34_SIZE / 2)) $DIR/$tfile || error "truncate failed"
2775 cancel_lru_locks osc
2776 $CHECKSTAT -s $((TEST_34_SIZE / 2)) $DIR/$tfile || \
2777 error "wrong size after lock cancel"
2779 $TRUNCATE $DIR/$tfile $TEST_34_SIZE || error
2780 $CHECKSTAT -s $TEST_34_SIZE $DIR/$tfile || \
2781 error "expanding truncate failed"
2782 cancel_lru_locks osc
2783 $CHECKSTAT -s $TEST_34_SIZE $DIR/$tfile || \
2784 error "wrong expanded size after lock cancel"
2786 run_test 34g "truncate long file ==============================="
2789 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2793 dd if=/dev/zero of=$DIR/$tfile bs=1M count=10 || error
2794 sync # Flush the cache so that multiop below does not block on cache
2795 # flush when getting the group lock
2796 $MULTIOP $DIR/$tfile OG${gid}T${sz}g${gid}c &
2799 # Since just timed wait is not good enough, let's do a sync write
2800 # that way we are sure enough time for a roundtrip + processing
2801 # passed + 2 seconds of extra margin.
2802 dd if=/dev/zero of=$DIR/${tfile}-1 bs=4096 oflag=direct count=1
2806 if [[ `ps h -o comm -p $MULTIPID` == "multiop" ]]; then
2807 error "Multiop blocked on ftruncate, pid=$MULTIPID"
2811 local nsz=`stat -c %s $DIR/$tfile`
2812 [[ $nsz == $sz ]] || error "New size wrong $nsz != $sz"
2814 run_test 34h "ftruncate file under grouplock should not block"
2817 cp /bin/sh $DIR/f35a
2819 chown $RUNAS_ID $DIR/f35a
2820 $RUNAS $DIR/f35a && error || true
2823 run_test 35a "exec file with mode 444 (should return and not leak) ====="
2827 utime $DIR/f36 || error
2829 run_test 36a "MDS utime check (mknod, utime) ==================="
2833 utime $DIR/f36 || error
2835 run_test 36b "OST utime check (open, utime) ===================="
2840 chown $RUNAS_ID $DIR/d36
2841 $RUNAS utime $DIR/d36/f36 || error
2843 run_test 36c "non-root MDS utime check (mknod, utime) =========="
2846 [ ! -d $DIR/d36 ] && test_36c
2847 echo "" > $DIR/d36/f36
2848 $RUNAS utime $DIR/d36/f36 || error
2850 run_test 36d "non-root OST utime check (open, utime) ==========="
2853 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID -- skipping" && return
2854 test_mkdir -p $DIR/$tdir
2855 touch $DIR/$tdir/$tfile
2856 $RUNAS utime $DIR/$tdir/$tfile && \
2857 error "utime worked, expected failure" || true
2859 run_test 36e "utime on non-owned file (should return error) ===="
2863 local LANG_SAVE=$LANG
2864 local LC_LANG_SAVE=$LC_LANG
2865 export LANG=C LC_LANG=C # for date language
2867 DATESTR="Dec 20 2000"
2868 test_mkdir -p $DIR/$tdir
2869 lctl set_param fail_loc=$fl
2871 cp /etc/hosts $DIR/$tdir/$tfile
2872 sync & # write RPC generated with "current" inode timestamp, but delayed
2874 touch --date="$DATESTR" $DIR/$tdir/$tfile # setattr timestamp in past
2875 LS_BEFORE="`ls -l $DIR/$tdir/$tfile`" # old timestamp from client cache
2876 cancel_lru_locks osc
2877 LS_AFTER="`ls -l $DIR/$tdir/$tfile`" # timestamp from OST object
2879 [ "$LS_BEFORE" != "$LS_AFTER" ] && \
2880 echo "BEFORE: $LS_BEFORE" && \
2881 echo "AFTER : $LS_AFTER" && \
2882 echo "WANT : $DATESTR" && \
2883 error "$DIR/$tdir/$tfile timestamps changed" || true
2885 export LANG=$LANG_SAVE LC_LANG=$LC_LANG_SAVE
2889 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2890 #define OBD_FAIL_OST_BRW_PAUSE_BULK 0x214
2891 subr_36fh "0x80000214"
2893 run_test 36f "utime on file racing with OST BRW write =========="
2896 remote_ost_nodsh && skip "remote OST with nodsh" && return
2897 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2902 test_mkdir -p $DIR/$tdir
2903 fmd_max_age=$(do_facet ost1 \
2904 "lctl get_param -n obdfilter.*.client_cache_seconds 2> /dev/null | \
2907 fmd_before=$(do_facet ost1 \
2908 "awk '/ll_fmd_cache/ {print \\\$2}' /proc/slabinfo")
2909 touch $DIR/$tdir/$tfile
2910 sleep $((fmd_max_age + 12))
2911 fmd_after=$(do_facet ost1 \
2912 "awk '/ll_fmd_cache/ {print \\\$2}' /proc/slabinfo")
2914 echo "fmd_before: $fmd_before"
2915 echo "fmd_after: $fmd_after"
2916 [[ $fmd_after -gt $fmd_before ]] &&
2917 echo "AFTER: $fmd_after > BEFORE: $fmd_before" &&
2918 error "fmd didn't expire after ping" || true
2920 run_test 36g "filter mod data cache expiry ====================="
2923 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2924 #define OBD_FAIL_OST_BRW_PAUSE_BULK2 0x227
2925 subr_36fh "0x80000227"
2927 run_test 36h "utime on file racing with OST BRW write =========="
2930 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2933 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR/$tdir/striped_dir
2935 local mtime=$(stat -c%Y $DIR/$tdir/striped_dir)
2936 local new_mtime=$((mtime + 200))
2938 #change Modify time of striped dir
2939 touch -m -d @$new_mtime $DIR/$tdir/striped_dir ||
2940 error "change mtime failed"
2942 local got=$(stat -c%Y $DIR/$tdir/striped_dir)
2944 [ "$new_mtime" = "$got" ] || error "expect $new_mtime got $got"
2946 run_test 36i "change mtime on striped directory"
2948 # test_37 - duplicate with tests 32q 32r
2951 local file=$DIR/$tfile
2953 openfile -f O_DIRECTORY $file
2956 [ $RC -eq 0 ] && error "opened file $file with O_DIRECTORY" || true
2957 [ $RC -eq $ENOTDIR ] || error "error $RC should be ENOTDIR ($ENOTDIR)"
2959 run_test 38 "open a regular file with O_DIRECTORY should return -ENOTDIR ==="
2963 touch $DIR/${tfile}2
2964 # ls -l $DIR/$tfile $DIR/${tfile}2
2965 # ls -lu $DIR/$tfile $DIR/${tfile}2
2966 # ls -lc $DIR/$tfile $DIR/${tfile}2
2968 $OPENFILE -f O_CREAT:O_TRUNC:O_WRONLY $DIR/${tfile}2
2969 if [ ! $DIR/${tfile}2 -nt $DIR/$tfile ]; then
2971 ls -l --full-time $DIR/$tfile $DIR/${tfile}2
2973 ls -lu --full-time $DIR/$tfile $DIR/${tfile}2
2975 ls -lc --full-time $DIR/$tfile $DIR/${tfile}2
2976 error "O_TRUNC didn't change timestamps"
2979 run_test 39 "mtime changed on create ==========================="
2982 test_mkdir -p -c1 $DIR/$tdir
2983 cp -p /etc/passwd $DIR/$tdir/fopen
2984 cp -p /etc/passwd $DIR/$tdir/flink
2985 cp -p /etc/passwd $DIR/$tdir/funlink
2986 cp -p /etc/passwd $DIR/$tdir/frename
2987 ln $DIR/$tdir/funlink $DIR/$tdir/funlink2
2990 echo "aaaaaa" >> $DIR/$tdir/fopen
2991 echo "aaaaaa" >> $DIR/$tdir/flink
2992 echo "aaaaaa" >> $DIR/$tdir/funlink
2993 echo "aaaaaa" >> $DIR/$tdir/frename
2995 local open_new=`stat -c %Y $DIR/$tdir/fopen`
2996 local link_new=`stat -c %Y $DIR/$tdir/flink`
2997 local unlink_new=`stat -c %Y $DIR/$tdir/funlink`
2998 local rename_new=`stat -c %Y $DIR/$tdir/frename`
3000 cat $DIR/$tdir/fopen > /dev/null
3001 ln $DIR/$tdir/flink $DIR/$tdir/flink2
3002 rm -f $DIR/$tdir/funlink2
3003 mv -f $DIR/$tdir/frename $DIR/$tdir/frename2
3005 for (( i=0; i < 2; i++ )) ; do
3006 local open_new2=`stat -c %Y $DIR/$tdir/fopen`
3007 local link_new2=`stat -c %Y $DIR/$tdir/flink`
3008 local unlink_new2=`stat -c %Y $DIR/$tdir/funlink`
3009 local rename_new2=`stat -c %Y $DIR/$tdir/frename2`
3011 [ $open_new2 -eq $open_new ] || error "open file reverses mtime"
3012 [ $link_new2 -eq $link_new ] || error "link file reverses mtime"
3013 [ $unlink_new2 -eq $unlink_new ] || error "unlink file reverses mtime"
3014 [ $rename_new2 -eq $rename_new ] || error "rename file reverses mtime"
3016 cancel_lru_locks osc
3017 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3020 run_test 39b "mtime change on open, link, unlink, rename ======"
3022 # this should be set to past
3023 TEST_39_MTIME=`date -d "1 year ago" +%s`
3029 local mtime0=`stat -c %Y $DIR1/$tfile`
3031 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3032 local mtime1=`stat -c %Y $DIR1/$tfile`
3033 [ "$mtime1" = $TEST_39_MTIME ] || \
3034 error "mtime is not set to past: $mtime1, should be $TEST_39_MTIME"
3037 echo hello >> $DIR1/$tfile
3039 local mtime2=`stat -c %Y $DIR1/$tfile`
3040 [ "$mtime2" -ge "$d1" ] && [ "$mtime2" -le "$d2" ] || \
3041 error "mtime is not updated on write: $d1 <= $mtime2 <= $d2"
3043 mv $DIR1/$tfile $DIR1/$tfile-1
3045 for (( i=0; i < 2; i++ )) ; do
3046 local mtime3=`stat -c %Y $DIR1/$tfile-1`
3047 [ "$mtime2" = "$mtime3" ] || \
3048 error "mtime ($mtime2) changed (to $mtime3) on rename"
3050 cancel_lru_locks osc
3051 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3054 run_test 39c "mtime change on rename ==========================="
3058 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3061 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3063 for (( i=0; i < 2; i++ )) ; do
3064 local mtime=`stat -c %Y $DIR1/$tfile`
3065 [ $mtime = $TEST_39_MTIME ] || \
3066 error "mtime($mtime) is not set to $TEST_39_MTIME"
3068 cancel_lru_locks osc
3069 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3072 run_test 39d "create, utime, stat =============================="
3076 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3078 local mtime1=`stat -c %Y $DIR1/$tfile`
3080 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3082 for (( i=0; i < 2; i++ )) ; do
3083 local mtime2=`stat -c %Y $DIR1/$tfile`
3084 [ $mtime2 = $TEST_39_MTIME ] || \
3085 error "mtime($mtime2) is not set to $TEST_39_MTIME"
3087 cancel_lru_locks osc
3088 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3091 run_test 39e "create, stat, utime, stat ========================"
3095 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3097 mtime1=`stat -c %Y $DIR1/$tfile`
3100 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3102 for (( i=0; i < 2; i++ )) ; do
3103 local mtime2=`stat -c %Y $DIR1/$tfile`
3104 [ $mtime2 = $TEST_39_MTIME ] || \
3105 error "mtime($mtime2) is not set to $TEST_39_MTIME"
3107 cancel_lru_locks osc
3108 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3111 run_test 39f "create, stat, sleep, utime, stat ================="
3115 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3116 echo hello >> $DIR1/$tfile
3117 local mtime1=`stat -c %Y $DIR1/$tfile`
3120 chmod o+r $DIR1/$tfile
3122 for (( i=0; i < 2; i++ )) ; do
3123 local mtime2=`stat -c %Y $DIR1/$tfile`
3124 [ "$mtime1" = "$mtime2" ] || \
3125 error "lost mtime: $mtime2, should be $mtime1"
3127 cancel_lru_locks osc
3128 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3131 run_test 39g "write, chmod, stat ==============================="
3135 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3140 echo hello >> $DIR1/$tfile
3141 local mtime1=`stat -c %Y $DIR1/$tfile`
3143 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3145 if [ "$d1" != "$d2" ]; then
3146 echo "write and touch not within one second"
3148 for (( i=0; i < 2; i++ )) ; do
3149 local mtime2=`stat -c %Y $DIR1/$tfile`
3150 [ "$mtime2" = $TEST_39_MTIME ] || \
3151 error "lost mtime: $mtime2, should be $TEST_39_MTIME"
3153 cancel_lru_locks osc
3154 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3158 run_test 39h "write, utime within one second, stat ============="
3161 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3165 echo hello >> $DIR1/$tfile
3166 local mtime1=`stat -c %Y $DIR1/$tfile`
3168 mv $DIR1/$tfile $DIR1/$tfile-1
3170 for (( i=0; i < 2; i++ )) ; do
3171 local mtime2=`stat -c %Y $DIR1/$tfile-1`
3173 [ "$mtime1" = "$mtime2" ] || \
3174 error "lost mtime: $mtime2, should be $mtime1"
3176 cancel_lru_locks osc
3177 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3180 run_test 39i "write, rename, stat =============================="
3183 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3184 start_full_debug_logging
3188 #define OBD_FAIL_OSC_DELAY_SETTIME 0x412
3189 lctl set_param fail_loc=0x80000412
3190 multiop_bg_pause $DIR1/$tfile oO_RDWR:w2097152_c ||
3191 error "multiop failed"
3193 local mtime1=`stat -c %Y $DIR1/$tfile`
3195 mv $DIR1/$tfile $DIR1/$tfile-1
3197 kill -USR1 $multipid
3198 wait $multipid || error "multiop close failed"
3200 for (( i=0; i < 2; i++ )) ; do
3201 local mtime2=`stat -c %Y $DIR1/$tfile-1`
3202 [ "$mtime1" = "$mtime2" ] ||
3203 error "mtime is lost on close: $mtime2, " \
3206 cancel_lru_locks osc
3207 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3209 lctl set_param fail_loc=0
3210 stop_full_debug_logging
3212 run_test 39j "write, rename, close, stat ======================="
3215 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3219 multiop_bg_pause $DIR1/$tfile oO_RDWR:w2097152_c || error "multiop failed"
3221 local mtime1=`stat -c %Y $DIR1/$tfile`
3223 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3225 kill -USR1 $multipid
3226 wait $multipid || error "multiop close failed"
3228 for (( i=0; i < 2; i++ )) ; do
3229 local mtime2=`stat -c %Y $DIR1/$tfile`
3231 [ "$mtime2" = $TEST_39_MTIME ] || \
3232 error "mtime is lost on close: $mtime2, should be $TEST_39_MTIME"
3234 cancel_lru_locks osc
3235 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3238 run_test 39k "write, utime, close, stat ========================"
3240 # this should be set to future
3241 TEST_39_ATIME=`date -d "1 year" +%s`
3244 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3245 remote_mds_nodsh && skip "remote MDS with nodsh" && return
3246 local atime_diff=$(do_facet $SINGLEMDS \
3247 lctl get_param -n mdd.*MDT0000*.atime_diff)
3251 # test setting directory atime to future
3252 touch -a -d @$TEST_39_ATIME $DIR/$tdir
3253 local atime=$(stat -c %X $DIR/$tdir)
3254 [ "$atime" = $TEST_39_ATIME ] || \
3255 error "atime is not set to future: $atime, $TEST_39_ATIME"
3257 # test setting directory atime from future to now
3258 local d1=$(date +%s)
3260 local d2=$(date +%s)
3262 cancel_lru_locks mdc
3263 atime=$(stat -c %X $DIR/$tdir)
3264 [ "$atime" -ge "$d1" -a "$atime" -le "$d2" ] || \
3265 error "atime is not updated from future: $atime, $d1<atime<$d2"
3267 do_facet $SINGLEMDS lctl set_param -n mdd.*MDT0000*.atime_diff=2
3270 # test setting directory atime when now > dir atime + atime_diff
3274 cancel_lru_locks mdc
3275 atime=$(stat -c %X $DIR/$tdir)
3276 [ "$atime" -ge "$d1" -a "$atime" -le "$d2" ] || \
3277 error "atime is not updated : $atime, should be $d2"
3279 do_facet $SINGLEMDS lctl set_param -n mdd.*MDT0000*.atime_diff=60
3282 # test not setting directory atime when now < dir atime + atime_diff
3284 cancel_lru_locks mdc
3285 atime=$(stat -c %X $DIR/$tdir)
3286 [ "$atime" -ge "$d1" -a "$atime" -le "$d2" ] || \
3287 error "atime is updated to $atime, should remain $d1<atime<$d2"
3289 do_facet $SINGLEMDS \
3290 lctl set_param -n mdd.*MDT0000*.atime_diff=$atime_diff
3292 run_test 39l "directory atime update ==========================="
3295 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3298 local far_past_mtime=$(date -d "May 29 1953" +%s)
3299 local far_past_atime=$(date -d "Dec 17 1903" +%s)
3301 touch -m -d @$far_past_mtime $DIR1/$tfile
3302 touch -a -d @$far_past_atime $DIR1/$tfile
3304 for (( i=0; i < 2; i++ )) ; do
3305 local timestamps=$(stat -c "%X %Y" $DIR1/$tfile)
3306 [ "$timestamps" = "$far_past_atime $far_past_mtime" ] || \
3307 error "atime or mtime set incorrectly"
3309 cancel_lru_locks osc
3310 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3313 run_test 39m "test atime and mtime before 1970"
3315 test_39n() { # LU-3832
3316 local atime_diff=$(do_facet $SINGLEMDS \
3317 lctl get_param -n mdd.*MDT0000*.atime_diff)
3322 do_facet $SINGLEMDS lctl set_param -n mdd.*MDT0000*.atime_diff=1
3325 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 status=noxfer
3326 atime0=$(stat -c %X $DIR/$tfile)
3329 $MULTIOP $DIR/$tfile oO_RDONLY:O_NOATIME:r4096c
3330 atime1=$(stat -c %X $DIR/$tfile)
3333 cancel_lru_locks mdc
3334 cancel_lru_locks osc
3335 $MULTIOP $DIR/$tfile oO_RDONLY:O_NOATIME:r4096c
3336 atime2=$(stat -c %X $DIR/$tfile)
3338 do_facet $SINGLEMDS \
3339 lctl set_param -n mdd.*MDT0000*.atime_diff=$atime_diff
3341 [ "$atime0" -eq "$atime1" ] || error "atime0 $atime0 != atime1 $atime1"
3342 [ "$atime1" -eq "$atime2" ] || error "atime0 $atime0 != atime1 $atime1"
3344 run_test 39n "check that O_NOATIME is honored"
3347 TESTDIR=$DIR/$tdir/$tfile
3348 [ -e $TESTDIR ] && rm -rf $TESTDIR
3349 test_mkdir -p $TESTDIR
3355 links2=$(stat -c %h .)
3356 [ $(($links1 + 2)) != $links2 ] &&
3357 error "wrong links count $(($links1 + 2)) != $links2"
3359 links3=$(stat -c %h .)
3360 [ $(($links1 + 1)) != $links3 ] &&
3361 error "wrong links count $links1 != $links3"
3364 run_test 39o "directory cached attributes updated after create ========"
3367 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 2 MDTs" && return
3369 TESTDIR=$DIR/$tdir/$tfile
3370 [ -e $TESTDIR ] && rm -rf $TESTDIR
3375 $LFS mkdir -i $MDTIDX $TESTDIR/remote_dir1
3376 $LFS mkdir -i $MDTIDX $TESTDIR/remote_dir2
3378 links2=$(stat -c %h .)
3379 [ $(($links1 + 2)) != $links2 ] &&
3380 error "wrong links count $(($links1 + 2)) != $links2"
3382 links3=$(stat -c %h .)
3383 [ $(($links1 + 1)) != $links3 ] &&
3384 error "wrong links count $links1 != $links3"
3387 run_test 39p "remote directory cached attributes updated after create ========"
3391 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1
3392 $RUNAS $OPENFILE -f O_WRONLY:O_TRUNC $DIR/$tfile &&
3393 error "openfile O_WRONLY:O_TRUNC $tfile failed"
3394 $CHECKSTAT -t file -s 4096 $DIR/$tfile ||
3395 error "$tfile is not 4096 bytes in size"
3397 run_test 40 "failed open(O_TRUNC) doesn't truncate ============="
3401 small_write $DIR/f41 18
3403 run_test 41 "test small file write + fstat ====================="
3405 count_ost_writes() {
3406 lctl get_param -n osc.*.stats |
3407 awk -vwrites=0 '/ost_write/ { writes += $2 } \
3408 END { printf("%0.0f", writes) }'
3415 BG_DIRTY_RATIO_SAVE=10
3416 MAX_BG_DIRTY_RATIO=25
3420 # in 2.6, restore /proc/sys/vm/dirty_writeback_centisecs,
3421 # dirty_ratio, dirty_background_ratio
3422 if [ -f /proc/sys/vm/dirty_writeback_centisecs ]; then
3423 sysctl -w vm.dirty_writeback_centisecs=$WRITEBACK_SAVE
3424 sysctl -w vm.dirty_background_ratio=$BG_DIRTY_RATIO_SAVE
3425 sysctl -w vm.dirty_ratio=$DIRTY_RATIO_SAVE
3427 # if file not here, we are a 2.4 kernel
3428 kill -CONT `pidof kupdated`
3433 # setup the trap first, so someone cannot exit the test at the
3434 # exact wrong time and mess up a machine
3435 trap start_writeback EXIT
3436 # in 2.6, save and 0 /proc/sys/vm/dirty_writeback_centisecs
3437 if [ -f /proc/sys/vm/dirty_writeback_centisecs ]; then
3438 WRITEBACK_SAVE=`sysctl -n vm.dirty_writeback_centisecs`
3439 sysctl -w vm.dirty_writeback_centisecs=0
3440 sysctl -w vm.dirty_writeback_centisecs=0
3441 # save and increase /proc/sys/vm/dirty_ratio
3442 DIRTY_RATIO_SAVE=`sysctl -n vm.dirty_ratio`
3443 sysctl -w vm.dirty_ratio=$MAX_DIRTY_RATIO
3444 # save and increase /proc/sys/vm/dirty_background_ratio
3445 BG_DIRTY_RATIO_SAVE=`sysctl -n vm.dirty_background_ratio`
3446 sysctl -w vm.dirty_background_ratio=$MAX_BG_DIRTY_RATIO
3448 # if file not here, we are a 2.4 kernel
3449 kill -STOP `pidof kupdated`
3453 # ensure that all stripes have some grant before we test client-side cache
3455 for i in `seq -f $DIR/f42-%g 1 $OSTCOUNT`; do
3456 dd if=/dev/zero of=$i bs=4k count=1
3461 # Tests 42* verify that our behaviour is correct WRT caching, file closure,
3462 # file truncation, and file removal.
3464 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3466 cancel_lru_locks osc
3468 sync; sleep 1; sync # just to be safe
3469 BEFOREWRITES=`count_ost_writes`
3470 lctl get_param -n osc.*[oO][sS][cC][_-]*.cur_grant_bytes | grep "[0-9]"
3471 dd if=/dev/zero of=$DIR/f42a bs=1024 count=100
3472 AFTERWRITES=`count_ost_writes`
3473 [ $BEFOREWRITES -eq $AFTERWRITES ] || \
3474 error "$BEFOREWRITES < $AFTERWRITES"
3477 run_test 42a "ensure that we don't flush on close =============="
3480 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3482 cancel_lru_locks osc
3485 dd if=/dev/zero of=$DIR/f42b bs=1024 count=100
3486 BEFOREWRITES=$(count_ost_writes)
3487 $MUNLINK $DIR/f42b || error "$MUNLINK $DIR/f42b: $?"
3488 AFTERWRITES=$(count_ost_writes)
3489 if [[ $BEFOREWRITES -lt $AFTERWRITES ]]; then
3490 error "$BEFOREWRITES < $AFTERWRITES on unlink"
3492 BEFOREWRITES=$(count_ost_writes)
3493 sync || error "sync: $?"
3494 AFTERWRITES=$(count_ost_writes)
3495 if [[ $BEFOREWRITES -lt $AFTERWRITES ]]; then
3496 error "$BEFOREWRITES < $AFTERWRITES on sync"
3498 dmesg | grep 'error from obd_brw_async' && error 'error writing back'
3502 run_test 42b "test destroy of file with cached dirty data ======"
3504 # if these tests just want to test the effect of truncation,
3505 # they have to be very careful. consider:
3506 # - the first open gets a {0,EOF}PR lock
3507 # - the first write conflicts and gets a {0, count-1}PW
3508 # - the rest of the writes are under {count,EOF}PW
3509 # - the open for truncate tries to match a {0,EOF}PR
3510 # for the filesize and cancels the PWs.
3511 # any number of fixes (don't get {0,EOF} on open, match
3512 # composite locks, do smarter file size management) fix
3513 # this, but for now we want these tests to verify that
3514 # the cancellation with truncate intent works, so we
3515 # start the file with a full-file pw lock to match against
3516 # until the truncate.
3521 cancel_lru_locks osc
3523 # prime the file with 0,EOF PW to match
3527 # now the real test..
3528 dd if=/dev/zero of=$file bs=1024 count=100
3529 BEFOREWRITES=`count_ost_writes`
3530 $TRUNCATE $file $offset
3531 cancel_lru_locks osc
3532 AFTERWRITES=`count_ost_writes`
3537 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3539 [ $BEFOREWRITES -eq $AFTERWRITES ] && \
3540 error "beforewrites $BEFOREWRITES == afterwrites $AFTERWRITES on truncate"
3543 run_test 42c "test partial truncate of file with cached dirty data"
3546 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3548 [ $BEFOREWRITES -eq $AFTERWRITES ] || \
3549 error "beforewrites $BEFOREWRITES != afterwrites $AFTERWRITES on truncate"
3552 run_test 42d "test complete truncate of file with cached dirty data"
3554 test_42e() { # bug22074
3555 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3556 local TDIR=$DIR/${tdir}e
3557 local pagesz=$(page_size)
3558 local pages=16 # hardcoded 16 pages, don't change it.
3559 local files=$((OSTCOUNT * 500)) # hopefully 500 files on each OST
3560 local proc_osc0="osc.${FSNAME}-OST0000-osc-[^MDT]*"
3564 test_mkdir -p $DIR/${tdir}e
3565 $SETSTRIPE -c 1 $TDIR
3566 createmany -o $TDIR/f $files
3568 max_dirty_mb=$($LCTL get_param -n $proc_osc0/max_dirty_mb)
3570 # we assume that with $OSTCOUNT files, at least one of them will
3571 # be allocated on OST0.
3572 warmup_files=$((OSTCOUNT * max_dirty_mb))
3573 createmany -o $TDIR/w $warmup_files
3575 # write a large amount of data into one file and sync, to get good
3576 # avail_grant number from OST.
3577 for ((i=0; i<$warmup_files; i++)); do
3578 idx=$($GETSTRIPE -i $TDIR/w$i)
3579 [ $idx -ne 0 ] && continue
3580 dd if=/dev/zero of=$TDIR/w$i bs="$max_dirty_mb"M count=1
3583 [[ $i -gt $warmup_files ]] && error "OST0 is still cold"
3585 $LCTL get_param $proc_osc0/cur_dirty_bytes
3586 $LCTL get_param $proc_osc0/cur_grant_bytes
3588 # create as much dirty pages as we can while not to trigger the actual
3589 # RPCs directly. but depends on the env, VFS may trigger flush during this
3590 # period, hopefully we are good.
3591 for ((i=0; i<$warmup_files; i++)); do
3592 idx=$($GETSTRIPE -i $TDIR/w$i)
3593 [ $idx -ne 0 ] && continue
3594 dd if=/dev/zero of=$TDIR/w$i bs=1M count=1 2>/dev/null
3596 $LCTL get_param $proc_osc0/cur_dirty_bytes
3597 $LCTL get_param $proc_osc0/cur_grant_bytes
3599 # perform the real test
3600 $LCTL set_param $proc_osc0/rpc_stats 0
3601 for ((;i<$files; i++)); do
3602 [ $($GETSTRIPE -i $TDIR/f$i) -eq 0 ] || continue
3603 dd if=/dev/zero of=$TDIR/f$i bs=$pagesz count=$pages 2>/dev/null
3606 $LCTL get_param $proc_osc0/rpc_stats
3609 local have_ppr=false
3610 $LCTL get_param $proc_osc0/rpc_stats |
3611 while read PPR RRPC RPCT RCUM BAR WRPC WPCT WCUM; do
3612 # skip lines until we are at the RPC histogram data
3613 [ "$PPR" == "pages" ] && have_ppr=true && continue
3614 $have_ppr || continue
3616 # we only want the percent stat for < 16 pages
3617 [[ $(echo $PPR | tr -d ':') -ge $pages ]] && break
3619 percent=$((percent + WPCT))
3620 if [[ $percent -gt 15 ]]; then
3621 error "less than 16-pages write RPCs" \
3628 run_test 42e "verify sub-RPC writes are not done synchronously"
3631 test_mkdir -p $DIR/$tdir
3632 cp -p /bin/ls $DIR/$tdir/$tfile
3633 $MULTIOP $DIR/$tdir/$tfile Ow_c &
3635 # give multiop a chance to open
3638 $DIR/$tdir/$tfile && error || true
3641 run_test 43 "execution of file opened for write should return -ETXTBSY"
3644 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3645 test_mkdir -p $DIR/$tdir
3646 cp -p `which $MULTIOP` $DIR/$tdir/multiop ||
3647 cp -p multiop $DIR/$tdir/multiop
3648 MULTIOP_PROG=$DIR/$tdir/multiop multiop_bg_pause $TMP/$tfile.junk O_c ||
3651 $MULTIOP $DIR/$tdir/multiop Oc && error "expected error, got success"
3652 kill -USR1 $MULTIOP_PID || return 2
3653 wait $MULTIOP_PID || return 3
3654 rm $TMP/$tfile.junk $DIR/$tdir/multiop
3656 run_test 43a "open(RDWR) of file being executed should return -ETXTBSY"
3659 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3660 test_mkdir -p $DIR/$tdir
3661 cp -p `which $MULTIOP` $DIR/$tdir/multiop ||
3662 cp -p multiop $DIR/$tdir/multiop
3663 MULTIOP_PROG=$DIR/$tdir/multiop multiop_bg_pause $TMP/$tfile.junk O_c ||
3666 $TRUNCATE $DIR/$tdir/multiop 0 && error "expected error, got success"
3667 kill -USR1 $MULTIOP_PID || return 2
3668 wait $MULTIOP_PID || return 3
3669 rm $TMP/$tfile.junk $DIR/$tdir/multiop
3671 run_test 43b "truncate of file being executed should return -ETXTBSY"
3674 local testdir="$DIR/$tdir"
3675 test_mkdir -p $DIR/$tdir
3677 ( cd $(dirname $SHELL) && md5sum $(basename $SHELL) ) | \
3678 ( cd $testdir && md5sum -c)
3680 run_test 43c "md5sum of copy into lustre========================"
3683 [[ $OSTCOUNT -lt 2 ]] && skip_env "skipping 2-stripe test" && return
3684 dd if=/dev/zero of=$DIR/f1 bs=4k count=1 seek=1023
3685 dd if=$DIR/f1 bs=4k count=1 > /dev/null
3687 run_test 44 "zero length read from a sparse stripe ============="
3690 local nstripe=$($LCTL lov_getconfig $DIR | grep default_stripe_count: |
3692 [ -z "$nstripe" ] && skip "can't get stripe info" && return
3693 [[ $nstripe -gt $OSTCOUNT ]] &&
3694 skip "Wrong default_stripe_count: $nstripe (OSTCOUNT: $OSTCOUNT)" &&
3696 local stride=$($LCTL lov_getconfig $DIR | grep default_stripe_size: |
3698 if [[ $nstripe -eq 0 || $nstripe -eq -1 ]]; then
3699 nstripe=$($LCTL lov_getconfig $DIR | grep obd_count: |
3703 OFFSETS="0 $((stride/2)) $((stride-1))"
3704 for offset in $OFFSETS; do
3705 for i in $(seq 0 $((nstripe-1))); do
3706 local GLOBALOFFSETS=""
3708 local size=$((((i + 2 * $nstripe )*$stride + $offset)))
3709 local myfn=$DIR/d44a-$size
3710 echo "--------writing $myfn at $size"
3711 ll_sparseness_write $myfn $size ||
3712 error "ll_sparseness_write"
3713 GLOBALOFFSETS="$GLOBALOFFSETS $size"
3714 ll_sparseness_verify $myfn $GLOBALOFFSETS ||
3715 error "ll_sparseness_verify $GLOBALOFFSETS"
3717 for j in $(seq 0 $((nstripe-1))); do
3719 size=$((((j + $nstripe )*$stride + $offset)))
3720 ll_sparseness_write $myfn $size ||
3721 error "ll_sparseness_write"
3722 GLOBALOFFSETS="$GLOBALOFFSETS $size"
3724 ll_sparseness_verify $myfn $GLOBALOFFSETS ||
3725 error "ll_sparseness_verify $GLOBALOFFSETS"
3730 run_test 44a "test sparse pwrite ==============================="
3734 for d in `lctl get_param -n osc.*.cur_dirty_bytes`; do
3740 before=`dirty_osc_total`
3741 echo executing "\"$*\""
3743 after=`dirty_osc_total`
3744 echo before $before, after $after
3747 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3749 # Obtain grants from OST if it supports it
3750 echo blah > ${f}_grant
3753 do_dirty_record "echo blah > $f"
3754 [[ $before -eq $after ]] && error "write wasn't cached"
3755 do_dirty_record "> $f"
3756 [[ $before -gt $after ]] || error "truncate didn't lower dirty count"
3757 do_dirty_record "echo blah > $f"
3758 [[ $before -eq $after ]] && error "write wasn't cached"
3759 do_dirty_record "sync"
3760 [[ $before -gt $after ]] || error "writeback didn't lower dirty count"
3761 do_dirty_record "echo blah > $f"
3762 [[ $before -eq $after ]] && error "write wasn't cached"
3763 do_dirty_record "cancel_lru_locks osc"
3764 [[ $before -gt $after ]] ||
3765 error "lock cancellation didn't lower dirty count"
3768 run_test 45 "osc io page accounting ============================"
3770 # in a 2 stripe file (lov.sh), page 1023 maps to page 511 in its object. this
3771 # test tickles a bug where re-dirtying a page was failing to be mapped to the
3772 # objects offset and an assert hit when an rpc was built with 1023's mapped
3773 # offset 511 and 511's raw 511 offset. it also found general redirtying bugs.
3775 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3779 dd if=/dev/zero of=$f bs=`page_size` seek=511 count=1
3781 dd conv=notrunc if=/dev/zero of=$f bs=`page_size` seek=1023 count=1
3782 dd conv=notrunc if=/dev/zero of=$f bs=`page_size` seek=511 count=1
3786 run_test 46 "dirtying a previously written page ================"
3788 # test_47 is removed "Device nodes check" is moved to test_28
3790 test_48a() { # bug 2399
3791 check_kernel_version 34 || return 0
3792 test_mkdir -p $DIR/$tdir
3794 mv $DIR/$tdir $DIR/d48.new || error "move directory failed"
3795 test_mkdir $DIR/$tdir || error "recreate directory failed"
3796 touch foo || error "'touch foo' failed after recreating cwd"
3797 test_mkdir $DIR/$tdir/bar ||
3798 error "'mkdir foo' failed after recreating cwd"
3799 if check_kernel_version 44; then
3800 touch .foo || error "'touch .foo' failed after recreating cwd"
3801 test_mkdir $DIR/$tdir/.bar ||
3802 error "'mkdir .foo' failed after recreating cwd"
3804 ls . > /dev/null || error "'ls .' failed after recreating cwd"
3805 ls .. > /dev/null || error "'ls ..' failed after removing cwd"
3806 cd . || error "'cd .' failed after recreating cwd"
3807 test_mkdir . && error "'mkdir .' worked after recreating cwd"
3808 rmdir . && error "'rmdir .' worked after recreating cwd"
3809 ln -s . baz || error "'ln -s .' failed after recreating cwd"
3810 cd .. || error "'cd ..' failed after recreating cwd"
3812 run_test 48a "Access renamed working dir (should return errors)="
3814 test_48b() { # bug 2399
3815 check_kernel_version 34 || return 0
3817 test_mkdir -p $DIR/$tdir
3819 rmdir $DIR/$tdir || error "remove cwd $DIR/$tdir failed"
3820 touch foo && error "'touch foo' worked after removing cwd"
3821 test_mkdir $DIR/$tdir/foo &&
3822 error "'mkdir foo' worked after removing cwd"
3823 if check_kernel_version 44; then
3824 touch .foo && error "'touch .foo' worked after removing cwd"
3825 test_mkdir $DIR/$tdir/.foo &&
3826 error "'mkdir .foo' worked after removing cwd"
3828 ls . > /dev/null && error "'ls .' worked after removing cwd"
3829 ls .. > /dev/null || error "'ls ..' failed after removing cwd"
3830 is_patchless || ( cd . && error "'cd .' worked after removing cwd" )
3831 test_mkdir $DIR/$tdir/. && error "'mkdir .' worked after removing cwd"
3832 rmdir . && error "'rmdir .' worked after removing cwd"
3833 ln -s . foo && error "'ln -s .' worked after removing cwd"
3834 cd .. || echo "'cd ..' failed after removing cwd `pwd`" #bug 3517
3836 run_test 48b "Access removed working dir (should return errors)="
3838 test_48c() { # bug 2350
3839 check_kernel_version 36 || return 0
3840 #lctl set_param debug=-1
3843 test_mkdir -p $DIR/$tdir/dir
3845 $TRACE rmdir $DIR/$tdir/dir || error "remove cwd $DIR/$tdir/dir failed"
3846 $TRACE touch foo && error "touch foo worked after removing cwd"
3847 $TRACE test_mkdir foo && error "'mkdir foo' worked after removing cwd"
3848 if check_kernel_version 44; then
3849 touch .foo && error "touch .foo worked after removing cwd"
3850 test_mkdir .foo && error "mkdir .foo worked after removing cwd"
3852 $TRACE ls . && error "'ls .' worked after removing cwd"
3853 $TRACE ls .. || error "'ls ..' failed after removing cwd"
3854 is_patchless || ( $TRACE cd . &&
3855 error "'cd .' worked after removing cwd" )
3856 $TRACE test_mkdir . && error "'mkdir .' worked after removing cwd"
3857 $TRACE rmdir . && error "'rmdir .' worked after removing cwd"
3858 $TRACE ln -s . foo && error "'ln -s .' worked after removing cwd"
3859 $TRACE cd .. || echo "'cd ..' failed after removing cwd `pwd`" #bug 3415
3861 run_test 48c "Access removed working subdir (should return errors)"
3863 test_48d() { # bug 2350
3864 check_kernel_version 36 || return 0
3865 #lctl set_param debug=-1
3868 test_mkdir -p $DIR/$tdir/dir
3870 $TRACE rmdir $DIR/$tdir/dir || error "remove cwd $DIR/$tdir/dir failed"
3871 $TRACE rmdir $DIR/$tdir || error "remove parent $DIR/$tdir failed"
3872 $TRACE touch foo && error "'touch foo' worked after removing parent"
3873 $TRACE test_mkdir foo && error "mkdir foo worked after removing parent"
3874 if check_kernel_version 44; then
3875 touch .foo && error "'touch .foo' worked after removing parent"
3877 error "mkdir .foo worked after removing parent"
3879 $TRACE ls . && error "'ls .' worked after removing parent"
3880 $TRACE ls .. && error "'ls ..' worked after removing parent"
3881 is_patchless || ( $TRACE cd . &&
3882 error "'cd .' worked after recreate parent" )
3883 $TRACE test_mkdir . && error "'mkdir .' worked after removing parent"
3884 $TRACE rmdir . && error "'rmdir .' worked after removing parent"
3885 $TRACE ln -s . foo && error "'ln -s .' worked after removing parent"
3886 is_patchless || ( $TRACE cd .. &&
3887 error "'cd ..' worked after removing parent" || true )
3889 run_test 48d "Access removed parent subdir (should return errors)"
3891 test_48e() { # bug 4134
3892 check_kernel_version 41 || return 0
3893 #lctl set_param debug=-1
3896 test_mkdir -p $DIR/$tdir/dir
3898 $TRACE rmdir $DIR/$tdir/dir || error "remove cwd $DIR/$tdir/dir failed"
3899 $TRACE rmdir $DIR/$tdir || error "remove parent $DIR/$tdir failed"
3900 $TRACE touch $DIR/$tdir || error "'touch $DIR/$tdir' failed"
3901 $TRACE chmod +x $DIR/$tdir || error "'chmod +x $DIR/$tdir' failed"
3902 # On a buggy kernel addition of "touch foo" after cd .. will
3903 # produce kernel oops in lookup_hash_it
3904 touch ../foo && error "'cd ..' worked after recreate parent"
3906 $TRACE rm $DIR/$tdir || error "rm '$DIR/$tdir' failed"
3908 run_test 48e "Access to recreated parent subdir (should return errors)"
3910 test_49() { # LU-1030
3911 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3912 # get ost1 size - lustre-OST0000