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
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 df $MOUNT > /dev/null 2>&1
650 [ $rc -ne 0 ] && break
658 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] &&
659 [ $(lustre_version_code $SINGLEMDS) -le $(version_code 2.2.93) ] &&
660 skip "MDS 2.2.0-2.2.93 do not NUL-terminate symlinks" && return
662 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
663 skip "only for ldiskfs MDT" && return 0
665 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 2 MDTs" && return
667 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
670 for ((i=0; i<10; i++)); do
671 $LFS mkdir -i1 -c2 $DIR/$tdir/remote_dir_${i} ||
672 error "create remote dir error $i"
673 createmany -o $DIR/$tdir/remote_dir_${i}/f 10 ||
674 error "create files under remote dir failed $i"
677 check_fs_consistency_17n ||
678 error "e2fsck report error after create files under remote dir"
680 for ((i=0;i<10;i++)); do
681 rm -rf $DIR/$tdir/remote_dir_${i} ||
682 error "destroy remote dir error $i"
685 check_fs_consistency_17n ||
686 error "e2fsck report error after unlink files under remote dir"
688 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.50) ] &&
689 skip "lustre < 2.4.50 does not support migrate mv " && return
691 for ((i=0; i<10; i++)); do
692 mkdir -p $DIR/$tdir/remote_dir_${i}
693 createmany -o $DIR/$tdir/remote_dir_${i}/f 10 ||
694 error "create files under remote dir failed $i"
695 $LFS mv -M 1 $DIR/$tdir/remote_dir_${i} ||
696 error "migrate remote dir error $i"
698 check_fs_consistency_17n || error "e2fsck report error after migration"
700 for ((i=0;i<10;i++)); do
701 rm -rf $DIR/$tdir/remote_dir_${i} ||
702 error "destroy remote dir error $i"
705 check_fs_consistency_17n || error "e2fsck report error after unlink"
707 run_test 17n "run e2fsck against master/slave MDT which contains remote dir"
710 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.3.64) ] &&
711 skip "Need MDS version at least 2.3.64" && return
713 local WDIR=$DIR/${tdir}o
719 mdt_index=$($LFS getstripe -M $WDIR)
720 mdt_index=$((mdt_index+1))
721 mdtdevname=$(mdsdevname $mdt_index)
725 start mds${mdt_index} $mdtdevname $MDS_MOUNT_OPTS
727 #define OBD_FAIL_OSD_LMA_INCOMPAT 0x194
728 do_facet mds${mdt_index} lctl set_param fail_loc=0x194
729 ls -l $WDIR/$tfile && rc=1
730 do_facet mds${mdt_index} lctl set_param fail_loc=0
731 [[ $rc -ne 0 ]] && error "stat file should fail"
734 run_test 17o "stat file with incompat LMA feature"
737 touch $DIR/$tfile || error "Failed to touch $DIR/$tfile: $?"
738 ls $DIR || error "Failed to ls $DIR: $?"
740 run_test 18 "touch .../f ; ls ... =============================="
746 $CHECKSTAT -a $DIR/$tfile || error "$tfile was not removed"
748 run_test 19a "touch .../f19 ; ls -l ... ; rm .../f19 ==========="
751 ls -l $DIR/$tfile && error "ls -l $tfile failed"|| true
753 run_test 19b "ls -l .../f19 (should return error) =============="
756 [ $RUNAS_ID -eq $UID ] &&
757 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
758 $RUNAS touch $DIR/$tfile && error "create non-root file failed" || true
760 run_test 19c "$RUNAS touch .../f19 (should return error) =="
763 cat $DIR/f19 && error || true
765 run_test 19d "cat .../f19 (should return error) =============="
777 $CHECKSTAT -a $DIR/$tfile || error "$tfile was not removed"
779 run_test 20 "touch .../f ; ls -l ... ==========================="
782 test_mkdir -p $DIR/$tdir
783 [ -f $DIR/$tdir/dangle ] && rm -f $DIR/$tdir/dangle
784 ln -s dangle $DIR/$tdir/link
785 echo foo >> $DIR/$tdir/link
786 cat $DIR/$tdir/dangle
787 $CHECKSTAT -t link $DIR/$tdir/link || error "$tdir/link not a link"
788 $CHECKSTAT -f -t file $DIR/$tdir/link ||
789 error "$tdir/link not linked to a file"
791 run_test 21 "write to dangling link ============================"
795 test_mkdir -p $DIR/$tdir
796 chown $RUNAS_ID:$RUNAS_GID $WDIR
797 (cd $WDIR || error "cd $WDIR failed";
798 $RUNAS tar cf - /etc/hosts /etc/sysconfig/network | \
800 ls -lR $WDIR/etc || error "ls -lR $WDIR/etc failed"
801 $CHECKSTAT -t dir $WDIR/etc || error "checkstat -t dir failed"
802 $CHECKSTAT -u \#$RUNAS_ID -g \#$RUNAS_GID $WDIR/etc || error "checkstat -u failed"
804 run_test 22 "unpack tar archive as non-root user ==============="
808 test_mkdir -p $DIR/$tdir
809 local file=$DIR/$tdir/$tfile
811 openfile -f O_CREAT:O_EXCL $file || error "$file create failed"
812 openfile -f O_CREAT:O_EXCL $file &&
813 error "$file recreate succeeded" || true
815 run_test 23a "O_CREAT|O_EXCL in subdir =========================="
817 test_23b() { # bug 18988
818 test_mkdir -p $DIR/$tdir
819 local file=$DIR/$tdir/$tfile
822 echo foo > $file || error "write filed"
823 echo bar >> $file || error "append filed"
824 $CHECKSTAT -s 8 $file || error "wrong size"
827 run_test 23b "O_APPEND check =========================="
831 echo '-- same directory rename'
832 test_mkdir $DIR/$tdir
833 touch $DIR/$tdir/$tfile.1
834 mv $DIR/$tdir/$tfile.1 $DIR/$tdir/$tfile.2
835 $CHECKSTAT -t file $DIR/$tdir/$tfile.2 || error "$tfile.2 not a file"
837 run_test 24a "rename file to non-existent target"
840 test_mkdir $DIR/$tdir
841 touch $DIR/$tdir/$tfile.{1,2}
842 mv $DIR/$tdir/$tfile.1 $DIR/$tdir/$tfile.2
843 $CHECKSTAT -a $DIR/$tdir/$tfile.1 || error "$tfile.1 exists"
844 $CHECKSTAT -t file $DIR/$tdir/$tfile.2 || error "$tfile.2 not a file"
846 run_test 24b "rename file to existing target"
849 test_mkdir $DIR/$tdir
850 test_mkdir $DIR/$tdir/d$testnum.1
851 mv $DIR/$tdir/d$testnum.1 $DIR/$tdir/d$testnum.2
852 $CHECKSTAT -a $DIR/$tdir/d$testnum.1 || error "d$testnum.1 exists"
853 $CHECKSTAT -t dir $DIR/$tdir/d$testnum.2 || error "d$testnum.2 not dir"
855 run_test 24c "rename directory to non-existent target"
858 test_mkdir -c1 $DIR/$tdir
859 test_mkdir -c1 $DIR/$tdir/d$testnum.1
860 test_mkdir -c1 $DIR/$tdir/d$testnum.2
861 mrename $DIR/$tdir/d$testnum.1 $DIR/$tdir/d$testnum.2
862 $CHECKSTAT -a $DIR/$tdir/d$testnum.1 || error "d$testnum.1 exists"
863 $CHECKSTAT -t dir $DIR/$tdir/d$testnum.2 || error "d$testnum.2 not dir"
865 run_test 24d "rename directory to existing target"
868 echo '-- cross directory renames --'
872 mv $DIR/R5a/f $DIR/R5b/g
873 $CHECKSTAT -a $DIR/R5a/f || error
874 $CHECKSTAT -t file $DIR/R5b/g || error
876 run_test 24e "touch .../R5a/f; rename .../R5a/f .../R5b/g ======"
881 touch $DIR/R6a/f $DIR/R6b/g
882 mv $DIR/R6a/f $DIR/R6b/g
883 $CHECKSTAT -a $DIR/R6a/f || error
884 $CHECKSTAT -t file $DIR/R6b/g || error
886 run_test 24f "touch .../R6a/f R6b/g; mv .../R6a/f .../R6b/g ===="
891 test_mkdir $DIR/R7a/d
892 mv $DIR/R7a/d $DIR/R7b/e
893 $CHECKSTAT -a $DIR/R7a/d || error
894 $CHECKSTAT -t dir $DIR/R7b/e || error
896 run_test 24g "mkdir .../R7{a,b}/d; mv .../R7a/d .../R7b/e ======"
899 test_mkdir -c1 $DIR/R8a
900 test_mkdir -c1 $DIR/R8b
901 test_mkdir -c1 $DIR/R8a/d
902 test_mkdir -c1 $DIR/R8b/e
903 mrename $DIR/R8a/d $DIR/R8b/e
904 $CHECKSTAT -a $DIR/R8a/d || error
905 $CHECKSTAT -t dir $DIR/R8b/e || error
907 run_test 24h "mkdir .../R8{a,b}/{d,e}; rename .../R8a/d .../R8b/e"
910 echo "-- rename error cases"
914 mrename $DIR/R9/f $DIR/R9/a
915 $CHECKSTAT -t file $DIR/R9/f || error
916 $CHECKSTAT -t dir $DIR/R9/a || error
917 $CHECKSTAT -a $DIR/R9/a/f || error
919 run_test 24i "rename file to dir error: touch f ; mkdir a ; rename f a"
923 mrename $DIR/R10/f $DIR/R10/g
924 $CHECKSTAT -t dir $DIR/R10 || error
925 $CHECKSTAT -a $DIR/R10/f || error
926 $CHECKSTAT -a $DIR/R10/g || error
928 run_test 24j "source does not exist ============================"
932 test_mkdir $DIR/R11a/d
934 mv $DIR/R11a/f $DIR/R11a/d
935 $CHECKSTAT -a $DIR/R11a/f || error
936 $CHECKSTAT -t file $DIR/R11a/d/f || error
938 run_test 24k "touch .../R11a/f; mv .../R11a/f .../R11a/d ======="
940 # bug 2429 - rename foo foo foo creates invalid file
943 $MULTIOP $f OcNs || error
945 run_test 24l "Renaming a file to itself ========================"
949 $MULTIOP $f OcLN ${f}2 ${f}2 || error "link ${f}2 ${f}2 failed"
950 # on ext3 this does not remove either the source or target files
951 # though the "expected" operation would be to remove the source
952 $CHECKSTAT -t file ${f} || error "${f} missing"
953 $CHECKSTAT -t file ${f}2 || error "${f}2 missing"
955 run_test 24m "Renaming a file to a hard link to itself ========="
959 # this stats the old file after it was renamed, so it should fail
963 $CHECKSTAT ${f}.rename
966 run_test 24n "Statting the old file after renaming (Posix rename 2)"
969 check_kernel_version 37 || return 0
970 test_mkdir -p $DIR/d24o
971 rename_many -s random -v -n 10 $DIR/d24o
973 run_test 24o "rename of files during htree split ==============="
978 DIRINO=`ls -lid $DIR/R12a | awk '{ print $1 }'`
979 mrename $DIR/R12a $DIR/R12b
980 $CHECKSTAT -a $DIR/R12a || error
981 $CHECKSTAT -t dir $DIR/R12b || error
982 DIRINO2=`ls -lid $DIR/R12b | awk '{ print $1 }'`
983 [ "$DIRINO" = "$DIRINO2" ] || error "R12a $DIRINO != R12b $DIRINO2"
985 run_test 24p "mkdir .../R12{a,b}; rename .../R12a .../R12b"
987 cleanup_multiop_pause() {
993 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
996 local DIRINO=$(ls -lid $DIR/R13a | awk '{ print $1 }')
997 multiop_bg_pause $DIR/R13b D_c || error "multiop failed to start"
1000 trap cleanup_multiop_pause EXIT
1001 mrename $DIR/R13a $DIR/R13b
1002 $CHECKSTAT -a $DIR/R13a || error "R13a still exists"
1003 $CHECKSTAT -t dir $DIR/R13b || error "R13b does not exist"
1004 local DIRINO2=$(ls -lid $DIR/R13b | awk '{ print $1 }')
1005 [ "$DIRINO" = "$DIRINO2" ] || error "R13a $DIRINO != R13b $DIRINO2"
1006 cleanup_multiop_pause
1007 wait $MULTIPID || error "multiop close failed"
1009 run_test 24q "mkdir .../R13{a,b}; open R13b rename R13a R13b ==="
1011 test_24r() { #bug 3789
1012 test_mkdir $DIR/R14a
1013 test_mkdir $DIR/R14a/b
1014 mrename $DIR/R14a $DIR/R14a/b && error "rename to subdir worked!"
1015 $CHECKSTAT -t dir $DIR/R14a || error "$DIR/R14a missing"
1016 $CHECKSTAT -t dir $DIR/R14a/b || error "$DIR/R14a/b missing"
1018 run_test 24r "mkdir .../R14a/b; rename .../R14a .../R14a/b ====="
1021 test_mkdir $DIR/R15a
1022 test_mkdir $DIR/R15a/b
1023 test_mkdir $DIR/R15a/b/c
1024 mrename $DIR/R15a $DIR/R15a/b/c && error "rename to sub-subdir worked!"
1025 $CHECKSTAT -t dir $DIR/R15a || error "$DIR/R15a missing"
1026 $CHECKSTAT -t dir $DIR/R15a/b/c || error "$DIR/R15a/b/c missing"
1028 run_test 24s "mkdir .../R15a/b/c; rename .../R15a .../R15a/b/c ="
1030 test_mkdir $DIR/R16a
1031 test_mkdir $DIR/R16a/b
1032 test_mkdir $DIR/R16a/b/c
1033 mrename $DIR/R16a/b/c $DIR/R16a && error "rename to sub-subdir worked!"
1034 $CHECKSTAT -t dir $DIR/R16a || error "$DIR/R16a missing"
1035 $CHECKSTAT -t dir $DIR/R16a/b/c || error "$DIR/R16a/b/c missing"
1037 run_test 24t "mkdir .../R16a/b/c; rename .../R16a/b/c .../R16a ="
1039 test_24u() { # bug12192
1040 $MULTIOP $DIR/$tfile C2w$((2048 * 1024))c || error
1041 $CHECKSTAT -s $((2048 * 1024)) $DIR/$tfile || error "wrong file size"
1043 run_test 24u "create stripe file"
1049 simple_cleanup_common() {
1052 wait_delete_completed
1055 max_pages_per_rpc() {
1056 $LCTL get_param -n mdc.*.max_pages_per_rpc | head -n1
1060 local NRFILES=100000
1061 local FREE_INODES=$(mdt_free_inodes 0)
1062 [[ $FREE_INODES -lt $NRFILES ]] &&
1063 skip "not enough free inodes $FREE_INODES required $NRFILES" &&
1066 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1067 trap simple_cleanup_common EXIT
1069 # Performance issue on ZFS see LU-4072 (c.f. LU-2887)
1070 [ $(facet_fstype $SINGLEMDS) = "zfs" ] && NRFILES=10000
1073 createmany -m $DIR/$tdir/$tfile $NRFILES
1075 cancel_lru_locks mdc
1076 lctl set_param mdc.*.stats clear
1078 ls $DIR/$tdir >/dev/null || error "error in listing large dir"
1080 # LU-5 large readdir
1081 # DIRENT_SIZE = 32 bytes for sizeof(struct lu_dirent) +
1082 # 8 bytes for name(filename is mostly 5 in this test) +
1083 # 8 bytes for luda_type
1084 # take into account of overhead in lu_dirpage header and end mark in
1085 # each page, plus one in RPC_NUM calculation.
1087 RPC_SIZE=$(($(max_pages_per_rpc) * $(page_size)))
1088 RPC_NUM=$(((NRFILES * DIRENT_SIZE + RPC_SIZE - 1) / RPC_SIZE + 1))
1089 mds_readpage=$(lctl get_param mdc.*MDT0000*.stats |
1090 awk '/^mds_readpage/ {print $2}')
1091 [[ $mds_readpage -gt $RPC_NUM ]] &&
1092 error "large readdir doesn't take effect"
1094 simple_cleanup_common
1096 run_test 24v "list directory with large files (handle hash collision, bug: 17560)"
1098 test_24w() { # bug21506
1100 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=4096 || return 1
1101 dd if=/dev/zero bs=$SZ1 count=1 >> $DIR/$tfile || return 2
1102 dd if=$DIR/$tfile of=$DIR/${tfile}_left bs=1M skip=4097 || return 3
1103 SZ2=`ls -l $DIR/${tfile}_left | awk '{print $5}'`
1104 [[ "$SZ1" -eq "$SZ2" ]] ||
1105 error "Error reading at the end of the file $tfile"
1107 run_test 24w "Reading a file larger than 4Gb"
1110 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 2 MDTs" && return
1111 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1113 local remote_dir=$DIR/$tdir/remote_dir
1116 $LFS mkdir -i $MDTIDX $remote_dir ||
1117 error "create remote directory failed"
1119 mkdir -p $DIR/$tdir/src_dir
1120 touch $DIR/$tdir/src_file
1121 mkdir -p $remote_dir/tgt_dir
1122 touch $remote_dir/tgt_file
1124 mrename $remote_dir $DIR/ &&
1125 error "rename dir cross MDT works!"
1127 mrename $DIR/$tdir/src_dir $remote_dir/tgt_dir &&
1128 error "rename dir cross MDT works!"
1130 mrename $DIR/$tdir/src_file $remote_dir/tgt_file &&
1131 error "rename file cross MDT works!"
1133 ln $DIR/$tdir/src_file $remote_dir/tgt_file1 &&
1134 error "ln file cross MDT should not work!"
1136 rm -rf $DIR/$tdir || error "Can not delete directories"
1138 run_test 24x "cross rename/link should be failed"
1141 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 2 MDTs" && return
1142 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1144 local remote_dir=$DIR/$tdir/remote_dir
1147 $LFS mkdir -i $MDTIDX $remote_dir ||
1148 error "create remote directory failed"
1150 mkdir -p $remote_dir/src_dir
1151 touch $remote_dir/src_file
1152 mkdir -p $remote_dir/tgt_dir
1153 touch $remote_dir/tgt_file
1155 mrename $remote_dir/src_dir $remote_dir/tgt_dir ||
1156 error "rename subdir in the same remote dir failed!"
1158 mrename $remote_dir/src_file $remote_dir/tgt_file ||
1159 error "rename files in the same remote dir failed!"
1161 ln $remote_dir/tgt_file $remote_dir/tgt_file1 ||
1162 error "link files in the same remote dir failed!"
1164 rm -rf $DIR/$tdir || error "Can not delete directories"
1166 run_test 24y "rename/link on the same dir should succeed"
1169 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 2 MDTs" && return
1170 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1172 local remote_src=$DIR/$tdir/remote_dir
1173 local remote_tgt=$DIR/$tdir/remote_tgt
1176 $LFS mkdir -i $MDTIDX $remote_src ||
1177 error "create remote directory failed"
1179 $LFS mkdir -i $MDTIDX $remote_tgt ||
1180 error "create remote directory failed"
1182 mrename $remote_src $remote_tgt &&
1183 error "rename remote dirs should not work!"
1185 # If target dir does not exists, it should succeed
1187 mrename $remote_src $remote_tgt ||
1188 error "rename remote dirs(tgt dir does not exists) failed!"
1190 rm -rf $DIR/$tdir || error "Can not delete directories"
1192 run_test 24z "rename one remote dir to another remote dir should fail"
1194 test_24A() { # LU-3182
1199 createmany -m $DIR/$tdir/$tfile $NFILES
1200 local t=$(ls $DIR/$tdir | wc -l)
1201 local u=$(ls $DIR/$tdir | sort -u | wc -l)
1202 local v=$(ls -ai $DIR/$tdir | sort -u | wc -l)
1203 if [ $t -ne $NFILES -o $u -ne $NFILES -o $v -ne $((NFILES + 2)) ] ; then
1204 error "Expected $NFILES files, got $t ($u unique $v .&..)"
1207 rm -rf $DIR/$tdir || error "Can not delete directories"
1209 run_test 24A "readdir() returns correct number of entries."
1211 test_24B() { # LU-4805
1212 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
1216 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR/$tdir/striped_dir ||
1217 error "create striped dir failed"
1219 count=$(ls -ai $DIR/$tdir/striped_dir | wc -l)
1220 [ $count -eq 2 ] || error "Expected 2, got $count"
1222 touch $DIR/$tdir/striped_dir/a
1224 count=$(ls -ai $DIR/$tdir/striped_dir | wc -l)
1225 [ $count -eq 3 ] || error "Expected 3, got $count"
1227 touch $DIR/$tdir/striped_dir/.f
1229 count=$(ls -ai $DIR/$tdir/striped_dir | wc -l)
1230 [ $count -eq 4 ] || error "Expected 4, got $count"
1232 rm -rf $DIR/$tdir || error "Can not delete directories"
1234 run_test 24B "readdir for striped dir return correct number of entries"
1237 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
1243 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR/$tdir/d0/striped_dir ||
1244 error "create striped dir failed"
1246 cd $DIR/$tdir/d0/striped_dir
1248 local d0_ino=$(ls -i -l -a $DIR/$tdir | grep "d0" | awk '{print $1}')
1249 local d1_ino=$(ls -i -l -a $DIR/$tdir | grep "d1" | awk '{print $1}')
1250 local parent_ino=$(ls -i -l -a | grep "\.\." | awk '{print $1}')
1252 [ "$d0_ino" = "$parent_ino" ] ||
1253 error ".. wrong, expect $d0_ino, get $parent_ino"
1255 mv $DIR/$tdir/d0/striped_dir $DIR/$tdir/d1/ ||
1256 error "mv striped dir failed"
1258 parent_ino=$(ls -i -l -a | grep "\.\." | awk '{print $1}')
1260 [ "$d1_ino" = "$parent_ino" ] ||
1261 error ".. wrong after mv, expect $d1_ino, get $parent_ino"
1263 run_test 24C "check .. in striped dir"
1266 echo '== symlink sanity ============================================='
1270 touch $DIR/s25/foo || error
1272 run_test 25a "create file in symlinked directory ==============="
1275 [ ! -d $DIR/d25 ] && test_25a
1276 $CHECKSTAT -t file $DIR/s25/foo || error
1278 run_test 25b "lookup file in symlinked directory ==============="
1282 test_mkdir $DIR/d26/d26-2
1283 ln -s d26/d26-2 $DIR/s26
1284 touch $DIR/s26/foo || error
1286 run_test 26a "multiple component symlink ======================="
1289 test_mkdir -p $DIR/d26b/d26-2
1290 ln -s d26b/d26-2/foo $DIR/s26-2
1291 touch $DIR/s26-2 || error
1293 run_test 26b "multiple component symlink at end of lookup ======"
1296 test_mkdir $DIR/d26.2
1297 touch $DIR/d26.2/foo
1298 ln -s d26.2 $DIR/s26.2-1
1299 ln -s s26.2-1 $DIR/s26.2-2
1300 ln -s s26.2-2 $DIR/s26.2-3
1301 chmod 0666 $DIR/s26.2-3/foo
1303 run_test 26c "chain of symlinks ================================"
1305 # recursive symlinks (bug 439)
1307 ln -s d26-3/foo $DIR/d26-3
1309 run_test 26d "create multiple component recursive symlink ======"
1312 [ ! -h $DIR/d26-3 ] && test_26d
1315 run_test 26e "unlink multiple component recursive symlink ======"
1317 # recursive symlinks (bug 7022)
1319 test_mkdir -p $DIR/$tdir
1320 test_mkdir $DIR/$tdir/$tfile || error "mkdir $DIR/$tdir/$tfile failed"
1321 cd $DIR/$tdir/$tfile || error "cd $DIR/$tdir/$tfile failed"
1322 test_mkdir -p lndir/bar1 || error "mkdir lndir/bar1 failed"
1323 test_mkdir $DIR/$tdir/$tfile/$tfile || error "mkdir $tfile failed"
1324 cd $tfile || error "cd $tfile failed"
1325 ln -s .. dotdot || error "ln dotdot failed"
1326 ln -s dotdot/lndir lndir || error "ln lndir failed"
1327 cd $DIR/$tdir || error "cd $DIR/$tdir failed"
1328 output=`ls $tfile/$tfile/lndir/bar1`
1329 [ "$output" = bar1 ] && error "unexpected output"
1330 rm -r $tfile || error "rm $tfile failed"
1331 $CHECKSTAT -a $DIR/$tfile || error "$tfile not gone"
1333 run_test 26f "rm -r of a directory which has recursive symlink ="
1336 echo '== stripe sanity =============================================='
1337 test_mkdir -p $DIR/d27 || error "mkdir failed"
1339 $SETSTRIPE -c 1 $DIR/d27/f0 || error "setstripe failed"
1340 $CHECKSTAT -t file $DIR/d27/f0 || error "checkstat failed"
1341 log "== test_27a: write to one stripe file ========================="
1342 cp /etc/hosts $DIR/d27/f0 || error
1344 run_test 27a "one stripe file =================================="
1347 [[ $OSTCOUNT -lt 2 ]] && skip_env "skipping 2-stripe test" && return
1348 test_mkdir -p $DIR/d27
1349 $SETSTRIPE -c 2 $DIR/d27/f01 || error "setstripe failed"
1350 $GETSTRIPE -c $DIR/d27/f01
1351 [ $($GETSTRIPE -c $DIR/d27/f01) -eq 2 ] ||
1352 error "two-stripe file doesn't have two stripes"
1354 dd if=/dev/zero of=$DIR/d27/f01 bs=4k count=4 || error "dd failed"
1356 run_test 27b "create and write to two stripe file"
1359 test_mkdir -p $DIR/d27
1360 $SETSTRIPE -c 0 -i -1 -S 0 $DIR/d27/fdef || error "setstripe failed"
1361 $CHECKSTAT -t file $DIR/d27/fdef || error "checkstat failed"
1362 dd if=/dev/zero of=$DIR/d27/fdef bs=4k count=4 || error
1364 run_test 27d "create file with default settings ================"
1367 test_mkdir -p $DIR/d27
1368 $SETSTRIPE -c 2 $DIR/d27/f12 || error "setstripe failed"
1369 $SETSTRIPE -c 2 $DIR/d27/f12 && error "setstripe succeeded twice"
1370 $CHECKSTAT -t file $DIR/d27/f12 || error "checkstat failed"
1372 run_test 27e "setstripe existing file (should return error) ======"
1375 test_mkdir -p $DIR/d27
1376 $SETSTRIPE -S 100 -i 0 -c 1 $DIR/d27/fbad && error "setstripe failed"
1377 dd if=/dev/zero of=$DIR/d27/fbad bs=4k count=4 || error "dd failed"
1378 $GETSTRIPE $DIR/d27/fbad || error "$GETSTRIPE failed"
1380 run_test 27f "setstripe with bad stripe size (should return error)"
1383 test_mkdir -p $DIR/d27
1384 $MCREATE $DIR/d27/fnone || error "mcreate failed"
1385 $GETSTRIPE $DIR/d27/fnone 2>&1 | grep "no stripe info" ||
1386 error "$DIR/d27/fnone has object"
1388 run_test 27g "$GETSTRIPE with no objects"
1391 touch $DIR/d27/fsome || error "touch failed"
1392 [[ $($GETSTRIPE -c $DIR/d27/fsome) -gt 0 ]] || error "missing objects"
1394 run_test 27i "$GETSTRIPE with some objects"
1397 test_mkdir -p $DIR/d27
1398 $SETSTRIPE -i $OSTCOUNT $DIR/d27/f27j && error "setstripe failed"||true
1400 run_test 27j "setstripe with bad stripe offset (should return error)"
1402 test_27k() { # bug 2844
1403 test_mkdir -p $DIR/d27
1405 LL_MAX_BLKSIZE=$((4 * 1024 * 1024))
1406 [ ! -d $DIR/d27 ] && test_mkdir -p $DIR d27
1407 $SETSTRIPE -S 67108864 $FILE || error "setstripe failed"
1408 BLKSIZE=`stat $FILE | awk '/IO Block:/ { print $7 }'`
1409 [ $BLKSIZE -le $LL_MAX_BLKSIZE ] || error "1:$BLKSIZE > $LL_MAX_BLKSIZE"
1410 dd if=/dev/zero of=$FILE bs=4k count=1
1411 BLKSIZE=`stat $FILE | awk '/IO Block:/ { print $7 }'`
1412 [ $BLKSIZE -le $LL_MAX_BLKSIZE ] || error "2:$BLKSIZE > $LL_MAX_BLKSIZE"
1414 run_test 27k "limit i_blksize for broken user apps ============="
1417 test_mkdir -p $DIR/d27
1418 mcreate $DIR/f27l || error "creating file"
1419 $RUNAS $SETSTRIPE -c 1 $DIR/f27l && \
1420 error "setstripe should have failed" || true
1422 run_test 27l "check setstripe permissions (should return error)"
1425 [[ $OSTCOUNT -lt 2 ]] && skip_env "$OSTCOUNT < 2 OSTs -- skipping" &&
1427 if [[ $ORIGFREE -gt $MAXFREE ]]; then
1428 skip "$ORIGFREE > $MAXFREE skipping out-of-space test on OST0"
1431 trap simple_cleanup_common EXIT
1432 test_mkdir -p $DIR/$tdir
1433 $SETSTRIPE -i 0 -c 1 $DIR/$tdir/f27m_1
1434 dd if=/dev/zero of=$DIR/$tdir/f27m_1 bs=1024 count=$MAXFREE &&
1435 error "dd should fill OST0"
1437 while $SETSTRIPE -i 0 -c 1 $DIR/$tdir/f27m_$i; do
1439 [ $i -gt 256 ] && break
1442 touch $DIR/$tdir/f27m_$i
1443 [ `$GETSTRIPE $DIR/$tdir/f27m_$i | grep -A 10 obdidx | awk '{print $1}'| grep -w "0"` ] &&
1444 error "OST0 was full but new created file still use it"
1446 touch $DIR/$tdir/f27m_$i
1447 [ `$GETSTRIPE $DIR/$tdir/f27m_$i | grep -A 10 obdidx | awk '{print $1}'| grep -w "0"` ] &&
1448 error "OST0 was full but new created file still use it"
1449 simple_cleanup_common
1451 run_test 27m "create file while OST0 was full =================="
1454 local DELAY=$(do_facet $SINGLEMDS lctl get_param -n lov.*.qos_maxage | head -n 1 | awk '{print $1 * 2}')
1458 # OSCs keep a NOSPC flag that will be reset after ~5s (qos_maxage)
1459 # if the OST isn't full anymore.
1461 local OSTIDX=${1:-""}
1463 local list=$(comma_list $(osts_nodes))
1464 [ "$OSTIDX" ] && list=$(facet_host ost$((OSTIDX + 1)))
1466 do_nodes $list lctl set_param fail_loc=0
1467 sync # initiate all OST_DESTROYs from MDS to OST
1471 exhaust_precreations() {
1474 local FAILIDX=${3:-$OSTIDX}
1476 test_mkdir -p $DIR/$tdir
1477 local MDSIDX=$(get_mds_dir "$DIR/$tdir")
1478 echo OSTIDX=$OSTIDX MDSIDX=$MDSIDX
1480 local OST=$(ostname_from_index $OSTIDX)
1481 local MDT_INDEX=$(lfs df | grep "\[MDT:$((MDSIDX - 1))\]" | awk '{print $1}' | \
1482 sed -e 's/_UUID$//;s/^.*-//')
1485 local mdtosc_proc1=$(get_mdtosc_proc_path mds${MDSIDX} $OST)
1486 local last_id=$(do_facet mds${MDSIDX} lctl get_param -n \
1487 osc.$mdtosc_proc1.prealloc_last_id)
1488 local next_id=$(do_facet mds${MDSIDX} lctl get_param -n \
1489 osc.$mdtosc_proc1.prealloc_next_id)
1491 local mdtosc_proc2=$(get_mdtosc_proc_path mds${MDSIDX})
1492 do_facet mds${MDSIDX} lctl get_param osc.$mdtosc_proc2.prealloc*
1494 test_mkdir -p $DIR/$tdir/${OST}
1495 $SETSTRIPE -i $OSTIDX -c 1 $DIR/$tdir/${OST}
1496 #define OBD_FAIL_OST_ENOSPC 0x215
1497 do_facet ost$((OSTIDX + 1)) lctl set_param fail_val=$FAILIDX
1498 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=0x215
1499 echo "Creating to objid $last_id on ost $OST..."
1500 createmany -o $DIR/$tdir/${OST}/f $next_id $((last_id - next_id + 2))
1501 do_facet mds${MDSIDX} lctl get_param osc.$mdtosc_proc2.prealloc*
1502 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=$FAILLOC
1506 exhaust_all_precreations() {
1508 for (( i=0; i < OSTCOUNT; i++ )) ; do
1509 exhaust_precreations $i $1 -1
1514 [[ $OSTCOUNT -lt 2 ]] && skip_env "too few OSTs" && return
1515 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1516 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1517 remote_ost_nodsh && skip "remote OST with nodsh" && return
1520 rm -f $DIR/$tdir/$tfile
1521 exhaust_precreations 0 0x80000215
1522 $SETSTRIPE -c -1 $DIR/$tdir
1523 touch $DIR/$tdir/$tfile || error
1524 $GETSTRIPE $DIR/$tdir/$tfile
1527 run_test 27n "create file with some full OSTs =================="
1530 [[ $OSTCOUNT -lt 2 ]] && skip_env "too few OSTs" && return
1531 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1532 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1533 remote_ost_nodsh && skip "remote OST with nodsh" && return
1536 rm -f $DIR/$tdir/$tfile
1537 exhaust_all_precreations 0x215
1539 touch $DIR/$tdir/$tfile && error "able to create $DIR/$tdir/$tfile"
1544 run_test 27o "create file with all full OSTs (should error) ===="
1547 [[ $OSTCOUNT -lt 2 ]] && skip_env "too few OSTs" && return
1548 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1549 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1550 remote_ost_nodsh && skip "remote OST with nodsh" && return
1553 rm -f $DIR/$tdir/$tfile
1554 test_mkdir -p $DIR/$tdir
1556 $MCREATE $DIR/$tdir/$tfile || error "mcreate failed"
1557 $TRUNCATE $DIR/$tdir/$tfile 80000000 || error "truncate failed"
1558 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat failed"
1560 exhaust_precreations 0 0x80000215
1561 echo foo >> $DIR/$tdir/$tfile || error "append failed"
1562 $CHECKSTAT -s 80000004 $DIR/$tdir/$tfile || error "checkstat failed"
1563 $GETSTRIPE $DIR/$tdir/$tfile
1567 run_test 27p "append to a truncated file with some full OSTs ==="
1570 [[ $OSTCOUNT -lt 2 ]] && skip_env "too few OSTs" && return
1571 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1572 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1573 remote_ost_nodsh && skip "remote OST with nodsh" && return
1576 rm -f $DIR/$tdir/$tfile
1578 test_mkdir -p $DIR/$tdir
1579 $MCREATE $DIR/$tdir/$tfile || error "mcreate $DIR/$tdir/$tfile failed"
1580 $TRUNCATE $DIR/$tdir/$tfile 80000000 ||error "truncate $DIR/$tdir/$tfile failed"
1581 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat failed"
1583 exhaust_all_precreations 0x215
1585 echo foo >> $DIR/$tdir/$tfile && error "append succeeded"
1586 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat 2 failed"
1590 run_test 27q "append to truncated file with all OSTs full (should error) ==="
1593 [[ $OSTCOUNT -lt 2 ]] && skip_env "too few OSTs" && return
1594 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1595 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1596 remote_ost_nodsh && skip "remote OST with nodsh" && return
1599 rm -f $DIR/$tdir/$tfile
1600 exhaust_precreations 0 0x80000215
1602 $SETSTRIPE -i 0 -c 2 $DIR/$tdir/$tfile # && error
1606 run_test 27r "stripe file with some full OSTs (shouldn't LBUG) ="
1608 test_27s() { # bug 10725
1609 test_mkdir -p $DIR/$tdir
1610 local stripe_size=$((4096 * 1024 * 1024)) # 2^32
1611 local stripe_count=0
1612 [ $OSTCOUNT -eq 1 ] || stripe_count=2
1613 $SETSTRIPE -S $stripe_size -c $stripe_count $DIR/$tdir &&
1614 error "stripe width >= 2^32 succeeded" || true
1617 run_test 27s "lsm_xfersize overflow (should error) (bug 10725)"
1619 test_27t() { # bug 10864
1624 $WLFS getstripe $tfile
1627 run_test 27t "check that utils parse path correctly"
1629 test_27u() { # bug 4900
1630 [[ $OSTCOUNT -lt 2 ]] && skip_env "too few OSTs" && return
1631 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1633 local list=$(comma_list $(mdts_nodes))
1635 #define OBD_FAIL_MDS_OSC_PRECREATE 0x139
1636 do_nodes $list $LCTL set_param fail_loc=0x139
1637 test_mkdir -p $DIR/$tdir
1639 createmany -o $DIR/$tdir/t- 1000
1640 do_nodes $list $LCTL set_param fail_loc=0
1642 TLOG=$DIR/$tfile.getstripe
1643 $GETSTRIPE $DIR/$tdir > $TLOG
1644 OBJS=$(awk -vobj=0 '($1 == 0) { obj += 1 } END { print obj; }' $TLOG)
1645 unlinkmany $DIR/$tdir/t- 1000
1646 [[ $OBJS -gt 0 ]] &&
1647 error "$OBJS objects created on OST-0. See $TLOG" || pass
1649 run_test 27u "skip object creation on OSC w/o objects =========="
1651 test_27v() { # bug 4900
1652 [[ $OSTCOUNT -lt 2 ]] && skip_env "too few OSTs" && return
1653 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1654 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1655 remote_ost_nodsh && skip "remote OST with nodsh" && return
1657 exhaust_all_precreations 0x215
1660 test_mkdir -p $DIR/$tdir
1661 $SETSTRIPE -c 1 $DIR/$tdir # 1 stripe / file
1663 touch $DIR/$tdir/$tfile
1664 #define OBD_FAIL_TGT_DELAY_PRECREATE 0x705
1666 for (( i=1; i < OSTCOUNT; i++ )); do
1667 do_facet ost$i lctl set_param fail_loc=0x705
1669 local START=`date +%s`
1670 createmany -o $DIR/$tdir/$tfile 32
1672 local FINISH=`date +%s`
1673 local TIMEOUT=`lctl get_param -n timeout`
1674 local PROCESS=$((FINISH - START))
1675 [ $PROCESS -ge $((TIMEOUT / 2)) ] && \
1676 error "$FINISH - $START >= $TIMEOUT / 2"
1677 sleep $((TIMEOUT / 2 - PROCESS))
1680 run_test 27v "skip object creation on slow OST ================="
1682 test_27w() { # bug 10997
1683 test_mkdir -p $DIR/$tdir || error "mkdir failed"
1684 $SETSTRIPE -S 65536 $DIR/$tdir/f0 || error "setstripe failed"
1685 [ $($GETSTRIPE -S $DIR/$tdir/f0) -ne 65536 ] &&
1686 error "stripe size $size != 65536" || true
1687 [ $($GETSTRIPE -d $DIR/$tdir | grep -c "stripe_count") -ne 1 ] &&
1688 error "$GETSTRIPE -d $DIR/$tdir failed" || true
1690 run_test 27w "check $SETSTRIPE -S option"
1693 [[ $OSTCOUNT -lt 2 ]] &&
1694 skip_env "skipping multiple stripe count/offset test" && return
1696 test_mkdir -p $DIR/$tdir || error "mkdir failed"
1697 for i in $(seq 1 $OSTCOUNT); do
1699 $SETSTRIPE -c $i -i $offset $DIR/$tdir/f$i ||
1700 error "setstripe -c $i -i $offset failed"
1701 count=$($GETSTRIPE -c $DIR/$tdir/f$i)
1702 index=$($GETSTRIPE -i $DIR/$tdir/f$i)
1703 [ $count -ne $i ] && error "stripe count $count != $i" || true
1704 [ $index -ne $offset ] &&
1705 error "stripe offset $index != $offset" || true
1708 run_test 27wa "check $SETSTRIPE -c -i options"
1711 remote_ost_nodsh && skip "remote OST with nodsh" && return
1712 [[ $OSTCOUNT -lt 2 ]] && skip_env "$OSTCOUNT < 2 OSTs" && return
1713 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1714 OFFSET=$(($OSTCOUNT - 1))
1716 local OST=$(ostname_from_index $OSTIDX)
1718 test_mkdir -p $DIR/$tdir
1719 $SETSTRIPE -c 1 $DIR/$tdir # 1 stripe per file
1720 do_facet ost$((OSTIDX + 1)) lctl set_param -n obdfilter.$OST.degraded 1
1722 createmany -o $DIR/$tdir/$tfile $OSTCOUNT
1723 for i in `seq 0 $OFFSET`; do
1724 [ `$GETSTRIPE $DIR/$tdir/$tfile$i | grep -A 10 obdidx | awk '{print $1}' | grep -w "$OSTIDX"` ] &&
1725 error "OST0 was degraded but new created file still use it"
1727 do_facet ost$((OSTIDX + 1)) lctl set_param -n obdfilter.$OST.degraded 0
1729 run_test 27x "create files while OST0 is degraded"
1732 [[ $OSTCOUNT -lt 2 ]] &&
1733 skip_env "$OSTCOUNT < 2 OSTs -- skipping" && return
1734 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1735 remote_ost_nodsh && skip "remote OST with nodsh" && return
1736 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1738 local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS $FSNAME-OST0000)
1739 local last_id=$(do_facet $SINGLEMDS lctl get_param -n \
1740 osc.$mdtosc.prealloc_last_id)
1741 local next_id=$(do_facet $SINGLEMDS lctl get_param -n \
1742 osc.$mdtosc.prealloc_next_id)
1743 local fcount=$((last_id - next_id))
1744 [[ $fcount -eq 0 ]] && skip "not enough space on OST0" && return
1745 [[ $fcount -gt $OSTCOUNT ]] && fcount=$OSTCOUNT
1747 local MDS_OSCS=$(do_facet $SINGLEMDS lctl dl |
1748 awk '/[oO][sS][cC].*md[ts]/ { print $4 }')
1749 local OST_DEACTIVE_IDX=-1
1754 for OSC in $MDS_OSCS; do
1755 OST=$(osc_to_ost $OSC)
1756 OSTIDX=$(index_from_ostuuid $OST)
1757 if [ $OST_DEACTIVE_IDX == -1 ]; then
1758 OST_DEACTIVE_IDX=$OSTIDX
1760 if [ $OSTIDX != $OST_DEACTIVE_IDX ]; then
1761 echo $OSC "is Deactivated:"
1762 do_facet $SINGLEMDS lctl --device %$OSC deactivate
1766 OSTIDX=$(index_from_ostuuid $OST)
1768 $SETSTRIPE -c 1 $DIR/$tdir # 1 stripe / file
1770 for OSC in $MDS_OSCS; do
1771 OST=$(osc_to_ost $OSC)
1772 OSTIDX=$(index_from_ostuuid $OST)
1773 if [ $OSTIDX == $OST_DEACTIVE_IDX ]; then
1774 echo $OST "is degraded:"
1775 do_facet ost$((OSTIDX+1)) lctl set_param -n \
1776 obdfilter.$OST.degraded=1
1781 createmany -o $DIR/$tdir/$tfile $fcount
1783 for OSC in $MDS_OSCS; do
1784 OST=$(osc_to_ost $OSC)
1785 OSTIDX=$(index_from_ostuuid $OST)
1786 if [ $OSTIDX == $OST_DEACTIVE_IDX ]; then
1787 echo $OST "is recovered from degraded:"
1788 do_facet ost$((OSTIDX+1)) lctl set_param -n \
1789 obdfilter.$OST.degraded=0
1791 do_facet $SINGLEMDS lctl --device %$OSC activate
1795 # all osp devices get activated, hence -1 stripe count restored
1798 # sleep 2*lod_qos_maxage seconds waiting for lod qos to notice osp
1799 # devices get activated.
1801 $SETSTRIPE -c -1 $DIR/$tfile
1802 stripecnt=$($GETSTRIPE -c $DIR/$tfile)
1804 [ $stripecnt -ne $OSTCOUNT ] &&
1805 error "Of $OSTCOUNT OSTs, only $stripecnt is available"
1808 run_test 27y "create files while OST0 is degraded and the rest inactive"
1814 lmm_count=$($GETSTRIPE -c $1)
1815 lmm_seq=$($GETSTRIPE -v $1 | awk '/lmm_seq/ { print $2 }')
1816 lmm_oid=$($GETSTRIPE -v $1 | awk '/lmm_object_id/ { print $2 }')
1818 local old_ifs="$IFS"
1820 fid=($($LFS path2fid $1))
1823 log "FID seq ${fid[1]}, oid ${fid[2]} ver ${fid[3]}"
1824 log "LOV seq $lmm_seq, oid $lmm_oid, count: $lmm_count"
1826 # compare lmm_seq and lu_fid->f_seq
1827 [ $lmm_seq = ${fid[1]} ] || { error "SEQ mismatch"; return 1; }
1828 # compare lmm_object_id and lu_fid->oid
1829 [ $lmm_oid = ${fid[2]} ] || { error "OID mismatch"; return 2; }
1831 # check the trusted.fid attribute of the OST objects of the file
1832 local have_obdidx=false
1834 $GETSTRIPE $1 | while read obdidx oid hex seq; do
1835 # skip lines up to and including "obdidx"
1836 [ -z "$obdidx" ] && break
1837 [ "$obdidx" = "obdidx" ] && have_obdidx=true && continue
1838 $have_obdidx || continue
1840 local ost=$((obdidx + 1))
1841 local dev=$(ostdevname $ost)
1844 log "want: stripe:$stripe_nr ost:$obdidx oid:$oid/$hex seq:$seq"
1846 seq=$(echo $seq | sed -e "s/^0x//g")
1847 if [ $seq == 0 ]; then
1848 oid_hex=$(echo $oid)
1850 oid_hex=$(echo $hex | sed -e "s/^0x//g")
1852 local obj_file="O/$seq/d$((oid %32))/$oid_hex"
1856 # Don't unmount/remount the OSTs if we don't need to do that.
1857 # LU-2577 changes filter_fid to be smaller, so debugfs needs
1858 # update too, until that use mount/ll_decode_filter_fid/mount.
1859 # Re-enable when debugfs will understand new filter_fid.
1861 if false && [ $(facet_fstype ost$ost) == ldiskfs ]; then
1862 ff=$(do_facet ost$ost "$DEBUGFS -c -R 'stat $obj_file' \
1863 $dev 2>/dev/null" | grep "parent=")
1866 mount_fstype ost$ost
1867 ff=$(do_facet ost$ost $LL_DECODE_FILTER_FID \
1868 $(facet_mntpt ost$ost)/$obj_file)
1869 unmount_fstype ost$ost
1870 start ost$ost $dev $OST_MOUNT_OPTS
1873 [ -z "$ff" ] && error "$obj_file: no filter_fid info"
1875 echo "$ff" | sed -e 's#.*objid=#got: objid=#'
1877 # /mnt/O/0/d23/23: objid=23 seq=0 parent=[0x200000400:0x1e:0x1]
1878 # fid: objid=23 seq=0 parent=[0x200000400:0x1e:0x0] stripe=1
1879 local ff_parent=$(echo $ff|sed -e 's/.*parent=.//')
1880 local ff_pseq=$(echo $ff_parent | cut -d: -f1)
1881 local ff_poid=$(echo $ff_parent | cut -d: -f2)
1883 if echo $ff_parent | grep -q 'stripe='; then
1884 ff_pstripe=$(echo $ff_parent | sed -e 's/.*stripe=//')
1887 # $LL_DECODE_FILTER_FID does not print "stripe="; look
1888 # into f_ver in this case. See the comment on
1891 ff_pstripe=$(echo $ff_parent | cut -d: -f3 |
1895 # compare lmm_seq and filter_fid->ff_parent.f_seq
1896 [ $ff_pseq = $lmm_seq ] ||
1897 error "FF parent SEQ $ff_pseq != $lmm_seq"
1898 # compare lmm_object_id and filter_fid->ff_parent.f_oid
1899 [ $ff_poid = $lmm_oid ] ||
1900 error "FF parent OID $ff_poid != $lmm_oid"
1901 (($ff_pstripe == $stripe_nr)) ||
1902 error "FF stripe $ff_pstripe != $stripe_nr"
1904 stripe_nr=$((stripe_nr + 1))
1909 remote_ost_nodsh && skip "remote OST with nodsh" && return
1910 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1911 test_mkdir -p $DIR/$tdir
1913 $SETSTRIPE -c 1 -i 0 -S 64k $DIR/$tdir/$tfile-1 ||
1914 { error "setstripe -c -1 failed"; return 1; }
1915 # We need to send a write to every object to get parent FID info set.
1916 # This _should_ also work for setattr, but does not currently.
1917 # touch $DIR/$tdir/$tfile-1 ||
1918 dd if=/dev/zero of=$DIR/$tdir/$tfile-1 bs=1M count=1 ||
1919 { error "dd $tfile-1 failed"; return 2; }
1920 $SETSTRIPE -c -1 -i $((OSTCOUNT - 1)) -S 1M $DIR/$tdir/$tfile-2 ||
1921 { error "setstripe -c -1 failed"; return 3; }
1922 dd if=/dev/zero of=$DIR/$tdir/$tfile-2 bs=1M count=$OSTCOUNT ||
1923 { error "dd $tfile-2 failed"; return 4; }
1925 # make sure write RPCs have been sent to OSTs
1928 check_seq_oid $DIR/$tdir/$tfile-1 || return 5
1929 check_seq_oid $DIR/$tdir/$tfile-2 || return 6
1931 run_test 27z "check SEQ/OID on the MDT and OST filesystems"
1933 test_27A() { # b=19102
1934 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1935 local restore_size=$($GETSTRIPE -S $MOUNT)
1936 local restore_count=$($GETSTRIPE -c $MOUNT)
1937 local restore_offset=$($GETSTRIPE -i $MOUNT)
1938 $SETSTRIPE -c 0 -i -1 -S 0 $MOUNT
1939 wait_update $HOSTNAME "$GETSTRIPE -c $MOUNT | sed 's/ *//g'" "1" 20 ||
1940 error "stripe count $($GETSTRIPE -c $MOUNT) != 1"
1941 local default_size=$($GETSTRIPE -S $MOUNT)
1942 local default_offset=$($GETSTRIPE -i $MOUNT)
1943 local dsize=$((1024 * 1024))
1944 [ $default_size -eq $dsize ] ||
1945 error "stripe size $default_size != $dsize"
1946 [ $default_offset -eq -1 ] ||error "stripe offset $default_offset != -1"
1947 $SETSTRIPE -c $restore_count -i $restore_offset -S $restore_size $MOUNT
1949 run_test 27A "check filesystem-wide default LOV EA values"
1951 test_27B() { # LU-2523
1952 test_mkdir -p $DIR/$tdir
1953 rm -f $DIR/$tdir/f0 $DIR/$tdir/f1
1955 # open f1 with O_LOV_DELAY_CREATE
1957 # call setstripe ioctl on open file descriptor for f1
1959 multiop $DIR/$tdir/f1 oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:nB1c \
1963 # open f1 with O_LOV_DELAY_CREATE
1965 # call setstripe ioctl on open file descriptor for f1
1967 multiop $DIR/$tdir/f1 oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:uB1c
1969 # Allow multiop to fail in imitation of NFS's busted semantics.
1972 run_test 27B "call setstripe on open unlinked file/rename victim"
1974 test_27C() { #LU-2871
1975 [[ $OSTCOUNT -lt 2 ]] && skip "needs >= 2 OSTs" && return
1983 test_mkdir -p $DIR/$tdir
1985 for i in $(seq 0 $((OSTCOUNT - 1))); do
1986 # set stripe across all OSTs starting from OST$i
1987 $SETSTRIPE -i $i -c -1 $tfile$i
1988 # get striping information
1989 ost_idx=($($GETSTRIPE $tfile$i |
1990 tail -n $((OSTCOUNT + 1)) | awk '{print $1}'))
1994 [ ${#ost_idx[@]} -eq $OSTCOUNT ] ||
1995 error "${#ost_idx[@]} != $OSTCOUNT"
1997 for index in $(seq 0 $((OSTCOUNT - 1))); do
1999 for j in $(echo ${ost_idx[@]}); do
2000 if [ $index -eq $j ]; then
2006 error "Can not find $index in ${ost_idx[@]}"
2010 run_test 27C "check full striping across all OSTs"
2012 # createtest also checks that device nodes are created and
2013 # then visible correctly (#2091)
2014 test_28() { # bug 2091
2016 $CREATETEST $DIR/d28/ct || error
2018 run_test 28 "create/mknod/mkdir with bad file types ============"
2021 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2022 cancel_lru_locks mdc
2028 declare -i LOCKCOUNTORIG=0
2029 for lock_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_count); do
2030 let LOCKCOUNTORIG=$LOCKCOUNTORIG+$lock_count
2032 [ $LOCKCOUNTORIG -eq 0 ] && echo "No mdc lock count" && return 1
2034 declare -i LOCKUNUSEDCOUNTORIG=0
2035 for unused_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_unused_count); do
2036 let LOCKUNUSEDCOUNTORIG=$LOCKUNUSEDCOUNTORIG+$unused_count
2043 declare -i LOCKCOUNTCURRENT=0
2044 for lock_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_count); do
2045 let LOCKCOUNTCURRENT=$LOCKCOUNTCURRENT+$lock_count
2048 declare -i LOCKUNUSEDCOUNTCURRENT=0
2049 for unused_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_unused_count); do
2050 let LOCKUNUSEDCOUNTCURRENT=$LOCKUNUSEDCOUNTCURRENT+$unused_count
2053 if [[ $LOCKCOUNTCURRENT -gt $LOCKCOUNTORIG ]]; then
2054 $LCTL set_param -n ldlm.dump_namespaces ""
2055 error "CURRENT: $LOCKCOUNTCURRENT > $LOCKCOUNTORIG"
2056 $LCTL dk | sort -k4 -t: > $TMP/test_29.dk
2057 log "dumped log to $TMP/test_29.dk (bug 5793)"
2060 if [[ $LOCKUNUSEDCOUNTCURRENT -gt $LOCKUNUSEDCOUNTORIG ]]; then
2061 error "UNUSED: $LOCKUNUSEDCOUNTCURRENT > $LOCKUNUSEDCOUNTORIG"
2062 $LCTL dk | sort -k4 -t: > $TMP/test_29.dk
2063 log "dumped log to $TMP/test_29.dk (bug 5793)"
2067 run_test 29 "IT_GETATTR regression ============================"
2069 test_30a() { # was test_30
2070 cp $(which ls) $DIR || cp /bin/ls $DIR
2074 run_test 30a "execute binary from Lustre (execve) =============="
2077 cp `which ls` $DIR || cp /bin/ls $DIR
2079 $RUNAS $DIR/ls / || error
2082 run_test 30b "execute binary from Lustre as non-root ==========="
2084 test_30c() { # b=22376
2085 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2086 cp `which ls` $DIR || cp /bin/ls $DIR
2088 cancel_lru_locks mdc
2089 cancel_lru_locks osc
2090 $RUNAS $DIR/ls / || error
2093 run_test 30c "execute binary from Lustre without read perms ===="
2096 $OPENUNLINK $DIR/f31 $DIR/f31 || error
2097 $CHECKSTAT -a $DIR/f31 || error
2099 run_test 31a "open-unlink file =================================="
2102 touch $DIR/f31 || error
2103 ln $DIR/f31 $DIR/f31b || error
2104 $MULTIOP $DIR/f31b Ouc || error
2105 $CHECKSTAT -t file $DIR/f31 || error
2107 run_test 31b "unlink file with multiple links while open ======="
2110 touch $DIR/f31 || error
2111 ln $DIR/f31 $DIR/f31c || error
2112 multiop_bg_pause $DIR/f31 O_uc || return 1
2114 $MULTIOP $DIR/f31c Ouc
2115 kill -USR1 $MULTIPID
2118 run_test 31c "open-unlink file with multiple links ============="
2121 opendirunlink $DIR/d31d $DIR/d31d || error
2122 $CHECKSTAT -a $DIR/d31d || error
2124 run_test 31d "remove of open directory ========================="
2126 test_31e() { # bug 2904
2127 check_kernel_version 34 || return 0
2128 openfilleddirunlink $DIR/d31e || error
2130 run_test 31e "remove of open non-empty directory ==============="
2132 test_31f() { # bug 4554
2133 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2135 test_mkdir $DIR/d31f
2136 $SETSTRIPE -S 1048576 -c 1 $DIR/d31f
2137 cp /etc/hosts $DIR/d31f
2139 $GETSTRIPE $DIR/d31f/hosts
2140 multiop_bg_pause $DIR/d31f D_c || return 1
2143 rm -rv $DIR/d31f || error "first of $DIR/d31f"
2144 test_mkdir $DIR/d31f
2145 $SETSTRIPE -S 1048576 -c 1 $DIR/d31f
2146 cp /etc/hosts $DIR/d31f
2148 $GETSTRIPE $DIR/d31f/hosts
2149 multiop_bg_pause $DIR/d31f D_c || return 1
2152 kill -USR1 $MULTIPID || error "first opendir $MULTIPID not running"
2153 wait $MULTIPID || error "first opendir $MULTIPID failed"
2157 kill -USR1 $MULTIPID2 || error "second opendir $MULTIPID not running"
2158 wait $MULTIPID2 || error "second opendir $MULTIPID2 failed"
2161 run_test 31f "remove of open directory with open-unlink file ==="
2164 echo "-- cross directory link --"
2165 test_mkdir -c1 $DIR/${tdir}ga
2166 test_mkdir -c1 $DIR/${tdir}gb
2167 touch $DIR/${tdir}ga/f
2168 ln $DIR/${tdir}ga/f $DIR/${tdir}gb/g
2169 $CHECKSTAT -t file $DIR/${tdir}ga/f || error "source"
2170 [ `stat -c%h $DIR/${tdir}ga/f` == '2' ] || error "source nlink"
2171 $CHECKSTAT -t file $DIR/${tdir}gb/g || error "target"
2172 [ `stat -c%h $DIR/${tdir}gb/g` == '2' ] || error "target nlink"
2174 run_test 31g "cross directory link==============="
2177 echo "-- cross directory link --"
2178 test_mkdir -c1 $DIR/${tdir}
2179 test_mkdir -c1 $DIR/${tdir}/dir
2180 touch $DIR/${tdir}/f
2181 ln $DIR/${tdir}/f $DIR/${tdir}/dir/g
2182 $CHECKSTAT -t file $DIR/${tdir}/f || error "source"
2183 [ `stat -c%h $DIR/${tdir}/f` == '2' ] || error "source nlink"
2184 $CHECKSTAT -t file $DIR/${tdir}/dir/g || error "target"
2185 [ `stat -c%h $DIR/${tdir}/dir/g` == '2' ] || error "target nlink"
2187 run_test 31h "cross directory link under child==============="
2190 echo "-- cross directory link --"
2191 test_mkdir -c1 $DIR/$tdir
2192 test_mkdir -c1 $DIR/$tdir/dir
2193 touch $DIR/$tdir/dir/f
2194 ln $DIR/$tdir/dir/f $DIR/$tdir/g
2195 $CHECKSTAT -t file $DIR/$tdir/dir/f || error "source"
2196 [ `stat -c%h $DIR/$tdir/dir/f` == '2' ] || error "source nlink"
2197 $CHECKSTAT -t file $DIR/$tdir/g || error "target"
2198 [ `stat -c%h $DIR/$tdir/g` == '2' ] || error "target nlink"
2200 run_test 31i "cross directory link under parent==============="
2203 test_mkdir -c1 -p $DIR/$tdir
2204 test_mkdir -c1 -p $DIR/$tdir/dir1
2205 ln $DIR/$tdir/dir1 $DIR/$tdir/dir2 && error "ln for dir"
2206 link $DIR/$tdir/dir1 $DIR/$tdir/dir3 && error "link for dir"
2207 mlink $DIR/$tdir/dir1 $DIR/$tdir/dir4 && error "mlink for dir"
2208 mlink $DIR/$tdir/dir1 $DIR/$tdir/dir1 && error "mlink to the same dir"
2211 run_test 31j "link for directory==============="
2214 test_mkdir -c1 -p $DIR/$tdir
2216 touch $DIR/$tdir/exist
2217 mlink $DIR/$tdir/s $DIR/$tdir/t || error "mlink"
2218 mlink $DIR/$tdir/s $DIR/$tdir/exist && error "mlink to exist file"
2219 mlink $DIR/$tdir/s $DIR/$tdir/s && error "mlink to the same file"
2220 mlink $DIR/$tdir/s $DIR/$tdir && error "mlink to parent dir"
2221 mlink $DIR/$tdir $DIR/$tdir/s && error "mlink parent dir to target"
2222 mlink $DIR/$tdir/not-exist $DIR/$tdir/foo && error "mlink non-existing to new"
2223 mlink $DIR/$tdir/not-exist $DIR/$tdir/s && error "mlink non-existing to exist"
2226 run_test 31k "link to file: the same, non-existing, dir==============="
2232 touch $DIR/d31m2/exist
2233 mlink $DIR/d31m/s $DIR/d31m2/t || error "mlink"
2234 mlink $DIR/d31m/s $DIR/d31m2/exist && error "mlink to exist file"
2235 mlink $DIR/d31m/s $DIR/d31m2 && error "mlink to parent dir"
2236 mlink $DIR/d31m2 $DIR/d31m/s && error "mlink parent dir to target"
2237 mlink $DIR/d31m/not-exist $DIR/d31m2/foo && error "mlink non-existing to new"
2238 mlink $DIR/d31m/not-exist $DIR/d31m2/s && error "mlink non-existing to exist"
2241 run_test 31m "link to file: the same, non-existing, dir==============="
2244 touch $DIR/$tfile || error "cannot create '$DIR/$tfile'"
2245 nlink=$(stat --format=%h $DIR/$tfile)
2246 [ ${nlink:--1} -eq 1 ] || error "nlink is $nlink, expected 1"
2248 local cmd="exec $fd<$DIR/$tfile"
2251 trap "eval $cmd" EXIT
2252 nlink=$(stat --dereference --format=%h /proc/self/fd/$fd)
2253 [ ${nlink:--1} -eq 1 ] || error "nlink is $nlink, expected 1"
2254 rm $DIR/$tfile || error "cannot remove '$DIR/$tfile'"
2255 nlink=$(stat --dereference --format=%h /proc/self/fd/$fd)
2256 [ ${nlink:--1} -eq 0 ] || error "nlink is $nlink, expected 0"
2259 run_test 31n "check link count of unlinked file"
2262 local TEMPNAME=$(mktemp $1_XXXXXX)
2263 mlink $TEMPNAME $1 2> /dev/null &&
2264 echo "$BASHPID: link $TEMPNAME to $1 succeeded"
2268 test_31o() { # LU-2901
2270 for LOOP in $(seq 100); do
2271 rm -f $DIR/$tdir/$tfile*
2272 for THREAD in $(seq 8); do
2273 link_one $DIR/$tdir/$tfile.$LOOP &
2276 local LINKS=$(ls -1 $DIR/$tdir | grep -c $tfile.$LOOP)
2277 [[ $LINKS -gt 1 ]] && ls $DIR/$tdir &&
2278 error "$LINKS duplicate links to $tfile.$LOOP" &&
2282 run_test 31o "duplicate hard links with same filename"
2285 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2288 $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
2289 $LFS setdirstripe -D -c2 -t all_char $DIR/$tdir/striped_dir
2291 opendirunlink $DIR/$tdir/striped_dir/test1 ||
2292 error "open unlink test1 failed"
2293 opendirunlink $DIR/$tdir/striped_dir/test2 ||
2294 error "open unlink test2 failed"
2296 $CHECKSTAT -a $DIR/$tdir/striped_dir/test1 ||
2297 error "test1 still exists"
2298 $CHECKSTAT -a $DIR/$tdir/striped_dir/test2 ||
2299 error "test2 still exists"
2301 run_test 31p "remove of open striped directory"
2303 cleanup_test32_mount() {
2305 $UMOUNT -d $DIR/$tdir/ext2-mountpoint
2309 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2310 echo "== more mountpoints and symlinks ================="
2311 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2312 trap cleanup_test32_mount EXIT
2313 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2314 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2315 $CHECKSTAT -t dir $DIR/$tdir/ext2-mountpoint/.. || error
2316 cleanup_test32_mount
2318 run_test 32a "stat d32a/ext2-mountpoint/.. ====================="
2321 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2322 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2323 trap cleanup_test32_mount EXIT
2324 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2325 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2326 ls -al $DIR/$tdir/ext2-mountpoint/.. || error
2327 cleanup_test32_mount
2329 run_test 32b "open d32b/ext2-mountpoint/.. ====================="
2332 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2333 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2334 trap cleanup_test32_mount EXIT
2335 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2336 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2337 test_mkdir -p $DIR/$tdir/d2/test_dir
2338 $CHECKSTAT -t dir $DIR/$tdir/ext2-mountpoint/../d2/test_dir || error
2339 cleanup_test32_mount
2341 run_test 32c "stat d32c/ext2-mountpoint/../d2/test_dir ========="
2344 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2345 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2346 trap cleanup_test32_mount EXIT
2347 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2348 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2349 test_mkdir -p $DIR/$tdir/d2/test_dir
2350 ls -al $DIR/$tdir/ext2-mountpoint/../d2/test_dir || error
2351 cleanup_test32_mount
2353 run_test 32d "open d32d/ext2-mountpoint/../d2/test_dir ========="
2356 [ -e $DIR/d32e ] && rm -fr $DIR/d32e
2357 test_mkdir -p $DIR/d32e/tmp
2358 TMP_DIR=$DIR/d32e/tmp
2359 ln -s $DIR/d32e $TMP_DIR/symlink11
2360 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
2361 $CHECKSTAT -t link $DIR/d32e/tmp/symlink11 || error
2362 $CHECKSTAT -t link $DIR/d32e/symlink01 || error
2364 run_test 32e "stat d32e/symlink->tmp/symlink->lustre-subdir ===="
2367 [ -e $DIR/d32f ] && rm -fr $DIR/d32f
2368 test_mkdir -p $DIR/d32f/tmp
2369 TMP_DIR=$DIR/d32f/tmp
2370 ln -s $DIR/d32f $TMP_DIR/symlink11
2371 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
2372 ls $DIR/d32f/tmp/symlink11 || error
2373 ls $DIR/d32f/symlink01 || error
2375 run_test 32f "open d32f/symlink->tmp/symlink->lustre-subdir ===="
2378 TMP_DIR=$DIR/$tdir/tmp
2379 test_mkdir -p $DIR/$tdir/tmp
2380 test_mkdir $DIR/${tdir}2
2381 ln -s $DIR/${tdir}2 $TMP_DIR/symlink12
2382 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
2383 $CHECKSTAT -t link $TMP_DIR/symlink12 || error
2384 $CHECKSTAT -t link $DIR/$tdir/symlink02 || error
2385 $CHECKSTAT -t dir -f $TMP_DIR/symlink12 || error
2386 $CHECKSTAT -t dir -f $DIR/$tdir/symlink02 || error
2388 run_test 32g "stat d32g/symlink->tmp/symlink->lustre-subdir/${tdir}2"
2391 rm -fr $DIR/$tdir $DIR/${tdir}2
2392 TMP_DIR=$DIR/$tdir/tmp
2393 test_mkdir -p $DIR/$tdir/tmp
2394 test_mkdir $DIR/${tdir}2
2395 ln -s $DIR/${tdir}2 $TMP_DIR/symlink12
2396 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
2397 ls $TMP_DIR/symlink12 || error
2398 ls $DIR/$tdir/symlink02 || error
2400 run_test 32h "open d32h/symlink->tmp/symlink->lustre-subdir/${tdir}2"
2403 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2404 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2405 trap cleanup_test32_mount EXIT
2406 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2407 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2408 touch $DIR/$tdir/test_file
2409 $CHECKSTAT -t file $DIR/$tdir/ext2-mountpoint/../test_file || error
2410 cleanup_test32_mount
2412 run_test 32i "stat d32i/ext2-mountpoint/../test_file ==========="
2415 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2416 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2417 trap cleanup_test32_mount EXIT
2418 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2419 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2420 touch $DIR/$tdir/test_file
2421 cat $DIR/$tdir/ext2-mountpoint/../test_file || error
2422 cleanup_test32_mount
2424 run_test 32j "open d32j/ext2-mountpoint/../test_file ==========="
2427 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2429 trap cleanup_test32_mount EXIT
2430 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2431 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint
2432 test_mkdir -p $DIR/$tdir/d2
2433 touch $DIR/$tdir/d2/test_file || error
2434 $CHECKSTAT -t file $DIR/$tdir/ext2-mountpoint/../d2/test_file || error
2435 cleanup_test32_mount
2437 run_test 32k "stat d32k/ext2-mountpoint/../d2/test_file ========"
2440 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2442 trap cleanup_test32_mount EXIT
2443 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2444 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2445 test_mkdir -p $DIR/$tdir/d2
2446 touch $DIR/$tdir/d2/test_file
2447 cat $DIR/$tdir/ext2-mountpoint/../d2/test_file || error
2448 cleanup_test32_mount
2450 run_test 32l "open d32l/ext2-mountpoint/../d2/test_file ========"
2454 test_mkdir -p $DIR/d32m/tmp
2455 TMP_DIR=$DIR/d32m/tmp
2456 ln -s $DIR $TMP_DIR/symlink11
2457 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
2458 $CHECKSTAT -t link $DIR/d32m/tmp/symlink11 || error
2459 $CHECKSTAT -t link $DIR/d32m/symlink01 || error
2461 run_test 32m "stat d32m/symlink->tmp/symlink->lustre-root ======"
2465 test_mkdir -p $DIR/d32n/tmp
2466 TMP_DIR=$DIR/d32n/tmp
2467 ln -s $DIR $TMP_DIR/symlink11
2468 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
2469 ls -l $DIR/d32n/tmp/symlink11 || error
2470 ls -l $DIR/d32n/symlink01 || error
2472 run_test 32n "open d32n/symlink->tmp/symlink->lustre-root ======"
2476 test_mkdir -p $DIR/d32o/tmp
2477 TMP_DIR=$DIR/d32o/tmp
2478 ln -s $DIR/$tfile $TMP_DIR/symlink12
2479 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
2480 $CHECKSTAT -t link $DIR/d32o/tmp/symlink12 || error
2481 $CHECKSTAT -t link $DIR/d32o/symlink02 || error
2482 $CHECKSTAT -t file -f $DIR/d32o/tmp/symlink12 || error
2483 $CHECKSTAT -t file -f $DIR/d32o/symlink02 || error
2485 run_test 32o "stat d32o/symlink->tmp/symlink->lustre-root/$tfile"
2495 test_mkdir -p $DIR/d32p/tmp
2497 TMP_DIR=$DIR/d32p/tmp
2499 ln -s $DIR/$tfile $TMP_DIR/symlink12
2501 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
2503 cat $DIR/d32p/tmp/symlink12 || error
2505 cat $DIR/d32p/symlink02 || error
2508 run_test 32p "open d32p/symlink->tmp/symlink->lustre-root/$tfile"
2510 cleanup_testdir_mount() {
2512 $UMOUNT -d $DIR/$tdir
2516 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2517 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2518 trap cleanup_testdir_mount EXIT
2519 test_mkdir -p $DIR/$tdir
2520 touch $DIR/$tdir/under_the_mount
2521 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir
2522 ls $DIR/$tdir | grep "\<under_the_mount\>" && error
2523 cleanup_testdir_mount
2525 run_test 32q "stat follows mountpoints in Lustre (should return error)"
2528 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2529 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2530 trap cleanup_testdir_mount EXIT
2531 test_mkdir -p $DIR/$tdir
2532 touch $DIR/$tdir/under_the_mount
2533 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir
2534 ls $DIR/$tdir | grep -q under_the_mount && error || true
2535 cleanup_testdir_mount
2537 run_test 32r "opendir follows mountpoints in Lustre (should return error)"
2542 chmod 444 $DIR/$tfile
2543 chown $RUNAS_ID $DIR/$tfile
2545 $RUNAS $OPENFILE -f O_RDWR $DIR/$tfile && error || true
2548 run_test 33aa "write file with mode 444 (should return error) ===="
2552 test_mkdir -p $DIR/d33
2553 chown $RUNAS_ID $DIR/d33
2554 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $DIR/d33/f33|| error "create"
2555 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $DIR/d33/f33 && \
2556 error "open RDWR" || true
2558 run_test 33a "test open file(mode=0444) with O_RDWR (should return error)"
2562 test_mkdir -p $DIR/d33
2563 chown $RUNAS_ID $DIR/d33
2564 $RUNAS $OPENFILE -f 1286739555 $DIR/d33/f33 && error "create" || true
2566 run_test 33b "test open file with malformed flags (No panic and return error)"
2569 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2575 remote_ost_nodsh && skip "remote OST with nodsh" && return
2578 test_mkdir -p $DIR/d33
2579 # Read: 0, Write: 4, create/destroy: 2/0, stat: 1, punch: 0
2582 for ostnum in $(seq $OSTCOUNT); do
2583 # test-framework's OST numbering is one-based, while Lustre's
2585 ostname=$(printf "$FSNAME-OST%.4x" $((ostnum - 1)))
2586 # Parsing llobdstat's output sucks; we could grep the /proc
2587 # path, but that's likely to not be as portable as using the
2588 # llobdstat utility. So we parse lctl output instead.
2589 write_bytes=$(do_facet ost$ostnum lctl get_param -n \
2590 obdfilter/$ostname/stats |
2591 awk '/^write_bytes/ {print $7}' )
2592 echo "baseline_write_bytes@$OSTnum/$ostname=$write_bytes"
2593 if (( ${write_bytes:-0} > 0 ))
2600 $all_zeros || return 0
2603 echo foo > $DIR/d33/bar
2607 # Total up write_bytes after writing. We'd better find non-zeros.
2608 for ostnum in $(seq $OSTCOUNT); do
2609 ostname=$(printf "$FSNAME-OST%.4x" $((ostnum - 1)))
2610 write_bytes=$(do_facet ost$ostnum lctl get_param -n \
2611 obdfilter/$ostname/stats |
2612 awk '/^write_bytes/ {print $7}' )
2613 echo "write_bytes@$OSTnum/$ostname=$write_bytes"
2614 if (( ${write_bytes:-0} > 0 ))
2623 for ostnum in $(seq $OSTCOUNT); do
2624 ostname=$(printf "$FSNAME-OST%.4x" $((ostnum - 1)))
2625 echo "Check that write_bytes is present in obdfilter/*/stats:"
2626 do_facet ost$ostnum lctl get_param -n \
2627 obdfilter/$ostname/stats
2629 error "OST not keeping write_bytes stats (b22312)"
2632 run_test 33c "test llobdstat and write_bytes"
2635 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 2 MDTs" && return
2636 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2638 local remote_dir=$DIR/$tdir/remote_dir
2641 $LFS mkdir -i $MDTIDX $remote_dir ||
2642 error "create remote directory failed"
2644 touch $remote_dir/$tfile
2645 chmod 444 $remote_dir/$tfile
2646 chown $RUNAS_ID $remote_dir/$tfile
2648 $RUNAS $OPENFILE -f O_RDWR $DIR/$tfile && error || true
2650 chown $RUNAS_ID $remote_dir
2651 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $remote_dir/f33 ||
2652 error "create" || true
2653 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $remote_dir/f33 &&
2654 error "open RDWR" || true
2655 $RUNAS $OPENFILE -f 1286739555 $remote_dir/f33 &&
2656 error "create" || true
2658 run_test 33d "openfile with 444 modes and malformed flags under remote dir"
2661 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2665 $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
2666 $LFS setdirstripe -i1 -c2 $DIR/$tdir/striped_dir1
2667 mkdir $DIR/$tdir/local_dir
2669 local s0_mode=$(stat -c%f $DIR/$tdir/striped_dir)
2670 local s1_mode=$(stat -c%f $DIR/$tdir/striped_dir1)
2671 local l_mode=$(stat -c%f $DIR/$tdir/local_dir)
2673 [ "$l_mode" = "$s0_mode" -a "$l_mode" = "$s1_mode" ] ||
2674 error "mkdir $l_mode striped0 $s0_mode striped1 $s1_mode"
2676 rmdir $DIR/$tdir/* || error "rmdir failed"
2679 $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
2680 $LFS setdirstripe -i1 -c2 $DIR/$tdir/striped_dir1
2681 mkdir $DIR/$tdir/local_dir
2683 s0_mode=$(stat -c%f $DIR/$tdir/striped_dir)
2684 s1_mode=$(stat -c%f $DIR/$tdir/striped_dir1)
2685 l_mode=$(stat -c%f $DIR/$tdir/local_dir)
2687 [ "$l_mode" = "$s0_mode" -a "$l_mode" = "$s1_mode" ] ||
2688 error "mkdir $l_mode striped0 $s0_mode striped1 $s1_mode 777"
2690 rmdir $DIR/$tdir/* || error "rmdir(umask 777) failed"
2693 $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
2694 $LFS setdirstripe -i1 -c2 $DIR/$tdir/striped_dir1
2695 mkdir $DIR/$tdir/local_dir
2697 s0_mode=$(stat -c%f $DIR/$tdir/striped_dir)
2698 s1_mode=$(stat -c%f $DIR/$tdir/striped_dir1)
2699 l_mode=$(stat -c%f $DIR/$tdir/local_dir)
2701 [ "$l_mode" = "$s0_mode" -a "$l_mode" = "$s1_mode" ] ||
2702 error "mkdir $l_mode striped0 $s0_mode striped1 $s1_mode 0"
2704 run_test 33e "mkdir and striped directory should have same mode"
2706 TEST_34_SIZE=${TEST_34_SIZE:-2000000000000}
2709 $MCREATE $DIR/f34 || error
2710 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" || error
2711 $TRUNCATE $DIR/f34 $TEST_34_SIZE || error
2712 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" || error
2713 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2715 run_test 34a "truncate file that has not been opened ==========="
2718 [ ! -f $DIR/f34 ] && test_34a
2719 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2720 $OPENFILE -f O_RDONLY $DIR/f34
2721 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" || error
2722 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2724 run_test 34b "O_RDONLY opening file doesn't create objects ====="
2727 [ ! -f $DIR/f34 ] && test_34a
2728 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2729 $OPENFILE -f O_RDWR $DIR/f34
2730 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" && error
2731 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2733 run_test 34c "O_RDWR opening file-with-size works =============="
2736 [ ! -f $DIR/f34 ] && test_34a
2737 dd if=/dev/zero of=$DIR/f34 conv=notrunc bs=4k count=1 || error
2738 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2741 run_test 34d "write to sparse file ============================="
2745 $MCREATE $DIR/f34e || error
2746 $TRUNCATE $DIR/f34e 1000 || error
2747 $CHECKSTAT -s 1000 $DIR/f34e || error
2748 $OPENFILE -f O_RDWR $DIR/f34e
2749 $CHECKSTAT -s 1000 $DIR/f34e || error
2751 run_test 34e "create objects, some with size and some without =="
2753 test_34f() { # bug 6242, 6243
2754 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2757 $MCREATE $DIR/f34f || error
2758 $TRUNCATE $DIR/f34f $SIZE34F || error "truncating $DIR/f3f to $SIZE34F"
2759 dd if=$DIR/f34f of=$TMP/f34f
2760 $CHECKSTAT -s $SIZE34F $TMP/f34f || error "$TMP/f34f not $SIZE34F bytes"
2761 dd if=/dev/zero of=$TMP/f34fzero bs=$SIZE34F count=1
2762 cmp $DIR/f34f $TMP/f34fzero || error "$DIR/f34f not all zero"
2763 cmp $TMP/f34f $TMP/f34fzero || error "$TMP/f34f not all zero"
2764 rm $TMP/f34f $TMP/f34fzero $DIR/f34f
2766 run_test 34f "read from a file with no objects until EOF ======="
2769 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2770 dd if=/dev/zero of=$DIR/$tfile bs=1 count=100 seek=$TEST_34_SIZE || error
2771 $TRUNCATE $DIR/$tfile $((TEST_34_SIZE / 2))|| error
2772 $CHECKSTAT -s $((TEST_34_SIZE / 2)) $DIR/$tfile || error "truncate failed"
2773 cancel_lru_locks osc
2774 $CHECKSTAT -s $((TEST_34_SIZE / 2)) $DIR/$tfile || \
2775 error "wrong size after lock cancel"
2777 $TRUNCATE $DIR/$tfile $TEST_34_SIZE || error
2778 $CHECKSTAT -s $TEST_34_SIZE $DIR/$tfile || \
2779 error "expanding truncate failed"
2780 cancel_lru_locks osc
2781 $CHECKSTAT -s $TEST_34_SIZE $DIR/$tfile || \
2782 error "wrong expanded size after lock cancel"
2784 run_test 34g "truncate long file ==============================="
2787 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2791 dd if=/dev/zero of=$DIR/$tfile bs=1M count=10 || error
2792 sync # Flush the cache so that multiop below does not block on cache
2793 # flush when getting the group lock
2794 $MULTIOP $DIR/$tfile OG${gid}T${sz}g${gid}c &
2797 # Since just timed wait is not good enough, let's do a sync write
2798 # that way we are sure enough time for a roundtrip + processing
2799 # passed + 2 seconds of extra margin.
2800 dd if=/dev/zero of=$DIR/${tfile}-1 bs=4096 oflag=direct count=1
2804 if [[ `ps h -o comm -p $MULTIPID` == "multiop" ]]; then
2805 error "Multiop blocked on ftruncate, pid=$MULTIPID"
2809 local nsz=`stat -c %s $DIR/$tfile`
2810 [[ $nsz == $sz ]] || error "New size wrong $nsz != $sz"
2812 run_test 34h "ftruncate file under grouplock should not block"
2815 cp /bin/sh $DIR/f35a
2817 chown $RUNAS_ID $DIR/f35a
2818 $RUNAS $DIR/f35a && error || true
2821 run_test 35a "exec file with mode 444 (should return and not leak) ====="
2825 utime $DIR/f36 || error
2827 run_test 36a "MDS utime check (mknod, utime) ==================="
2831 utime $DIR/f36 || error
2833 run_test 36b "OST utime check (open, utime) ===================="
2838 chown $RUNAS_ID $DIR/d36
2839 $RUNAS utime $DIR/d36/f36 || error
2841 run_test 36c "non-root MDS utime check (mknod, utime) =========="
2844 [ ! -d $DIR/d36 ] && test_36c
2845 echo "" > $DIR/d36/f36
2846 $RUNAS utime $DIR/d36/f36 || error
2848 run_test 36d "non-root OST utime check (open, utime) ==========="
2851 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID -- skipping" && return
2852 test_mkdir -p $DIR/$tdir
2853 touch $DIR/$tdir/$tfile
2854 $RUNAS utime $DIR/$tdir/$tfile && \
2855 error "utime worked, expected failure" || true
2857 run_test 36e "utime on non-owned file (should return error) ===="
2861 local LANG_SAVE=$LANG
2862 local LC_LANG_SAVE=$LC_LANG
2863 export LANG=C LC_LANG=C # for date language
2865 DATESTR="Dec 20 2000"
2866 test_mkdir -p $DIR/$tdir
2867 lctl set_param fail_loc=$fl
2869 cp /etc/hosts $DIR/$tdir/$tfile
2870 sync & # write RPC generated with "current" inode timestamp, but delayed
2872 touch --date="$DATESTR" $DIR/$tdir/$tfile # setattr timestamp in past
2873 LS_BEFORE="`ls -l $DIR/$tdir/$tfile`" # old timestamp from client cache
2874 cancel_lru_locks osc
2875 LS_AFTER="`ls -l $DIR/$tdir/$tfile`" # timestamp from OST object
2877 [ "$LS_BEFORE" != "$LS_AFTER" ] && \
2878 echo "BEFORE: $LS_BEFORE" && \
2879 echo "AFTER : $LS_AFTER" && \
2880 echo "WANT : $DATESTR" && \
2881 error "$DIR/$tdir/$tfile timestamps changed" || true
2883 export LANG=$LANG_SAVE LC_LANG=$LC_LANG_SAVE
2887 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2888 #define OBD_FAIL_OST_BRW_PAUSE_BULK 0x214
2889 subr_36fh "0x80000214"
2891 run_test 36f "utime on file racing with OST BRW write =========="
2894 remote_ost_nodsh && skip "remote OST with nodsh" && return
2895 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2900 test_mkdir -p $DIR/$tdir
2901 fmd_max_age=$(do_facet ost1 \
2902 "lctl get_param -n obdfilter.*.client_cache_seconds 2> /dev/null | \
2905 fmd_before=$(do_facet ost1 \
2906 "awk '/ll_fmd_cache/ {print \\\$2}' /proc/slabinfo")
2907 touch $DIR/$tdir/$tfile
2908 sleep $((fmd_max_age + 12))
2909 fmd_after=$(do_facet ost1 \
2910 "awk '/ll_fmd_cache/ {print \\\$2}' /proc/slabinfo")
2912 echo "fmd_before: $fmd_before"
2913 echo "fmd_after: $fmd_after"
2914 [[ $fmd_after -gt $fmd_before ]] &&
2915 echo "AFTER: $fmd_after > BEFORE: $fmd_before" &&
2916 error "fmd didn't expire after ping" || true
2918 run_test 36g "filter mod data cache expiry ====================="
2921 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2922 #define OBD_FAIL_OST_BRW_PAUSE_BULK2 0x227
2923 subr_36fh "0x80000227"
2925 run_test 36h "utime on file racing with OST BRW write =========="
2928 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2931 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR/$tdir/striped_dir
2933 local mtime=$(stat -c%Y $DIR/$tdir/striped_dir)
2934 local new_mtime=$((mtime + 200))
2936 #change Modify time of striped dir
2937 touch -m -d @$new_mtime $DIR/$tdir/striped_dir ||
2938 error "change mtime failed"
2940 local got=$(stat -c%Y $DIR/$tdir/striped_dir)
2942 [ "$new_mtime" = "$got" ] || error "expect $new_mtime got $got"
2944 run_test 36i "change mtime on striped directory"
2946 # test_37 - duplicate with tests 32q 32r
2949 local file=$DIR/$tfile
2951 openfile -f O_DIRECTORY $file
2954 [ $RC -eq 0 ] && error "opened file $file with O_DIRECTORY" || true
2955 [ $RC -eq $ENOTDIR ] || error "error $RC should be ENOTDIR ($ENOTDIR)"
2957 run_test 38 "open a regular file with O_DIRECTORY should return -ENOTDIR ==="
2961 touch $DIR/${tfile}2
2962 # ls -l $DIR/$tfile $DIR/${tfile}2
2963 # ls -lu $DIR/$tfile $DIR/${tfile}2
2964 # ls -lc $DIR/$tfile $DIR/${tfile}2
2966 $OPENFILE -f O_CREAT:O_TRUNC:O_WRONLY $DIR/${tfile}2
2967 if [ ! $DIR/${tfile}2 -nt $DIR/$tfile ]; then
2969 ls -l --full-time $DIR/$tfile $DIR/${tfile}2
2971 ls -lu --full-time $DIR/$tfile $DIR/${tfile}2
2973 ls -lc --full-time $DIR/$tfile $DIR/${tfile}2
2974 error "O_TRUNC didn't change timestamps"
2977 run_test 39 "mtime changed on create ==========================="
2980 test_mkdir -p -c1 $DIR/$tdir
2981 cp -p /etc/passwd $DIR/$tdir/fopen
2982 cp -p /etc/passwd $DIR/$tdir/flink
2983 cp -p /etc/passwd $DIR/$tdir/funlink
2984 cp -p /etc/passwd $DIR/$tdir/frename
2985 ln $DIR/$tdir/funlink $DIR/$tdir/funlink2
2988 echo "aaaaaa" >> $DIR/$tdir/fopen
2989 echo "aaaaaa" >> $DIR/$tdir/flink
2990 echo "aaaaaa" >> $DIR/$tdir/funlink
2991 echo "aaaaaa" >> $DIR/$tdir/frename
2993 local open_new=`stat -c %Y $DIR/$tdir/fopen`
2994 local link_new=`stat -c %Y $DIR/$tdir/flink`
2995 local unlink_new=`stat -c %Y $DIR/$tdir/funlink`
2996 local rename_new=`stat -c %Y $DIR/$tdir/frename`
2998 cat $DIR/$tdir/fopen > /dev/null
2999 ln $DIR/$tdir/flink $DIR/$tdir/flink2
3000 rm -f $DIR/$tdir/funlink2
3001 mv -f $DIR/$tdir/frename $DIR/$tdir/frename2
3003 for (( i=0; i < 2; i++ )) ; do
3004 local open_new2=`stat -c %Y $DIR/$tdir/fopen`
3005 local link_new2=`stat -c %Y $DIR/$tdir/flink`
3006 local unlink_new2=`stat -c %Y $DIR/$tdir/funlink`
3007 local rename_new2=`stat -c %Y $DIR/$tdir/frename2`
3009 [ $open_new2 -eq $open_new ] || error "open file reverses mtime"
3010 [ $link_new2 -eq $link_new ] || error "link file reverses mtime"
3011 [ $unlink_new2 -eq $unlink_new ] || error "unlink file reverses mtime"
3012 [ $rename_new2 -eq $rename_new ] || error "rename file reverses mtime"
3014 cancel_lru_locks osc
3015 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3018 run_test 39b "mtime change on open, link, unlink, rename ======"
3020 # this should be set to past
3021 TEST_39_MTIME=`date -d "1 year ago" +%s`
3027 local mtime0=`stat -c %Y $DIR1/$tfile`
3029 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3030 local mtime1=`stat -c %Y $DIR1/$tfile`
3031 [ "$mtime1" = $TEST_39_MTIME ] || \
3032 error "mtime is not set to past: $mtime1, should be $TEST_39_MTIME"
3035 echo hello >> $DIR1/$tfile
3037 local mtime2=`stat -c %Y $DIR1/$tfile`
3038 [ "$mtime2" -ge "$d1" ] && [ "$mtime2" -le "$d2" ] || \
3039 error "mtime is not updated on write: $d1 <= $mtime2 <= $d2"
3041 mv $DIR1/$tfile $DIR1/$tfile-1
3043 for (( i=0; i < 2; i++ )) ; do
3044 local mtime3=`stat -c %Y $DIR1/$tfile-1`
3045 [ "$mtime2" = "$mtime3" ] || \
3046 error "mtime ($mtime2) changed (to $mtime3) on rename"
3048 cancel_lru_locks osc
3049 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3052 run_test 39c "mtime change on rename ==========================="
3056 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3059 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3061 for (( i=0; i < 2; i++ )) ; do
3062 local mtime=`stat -c %Y $DIR1/$tfile`
3063 [ $mtime = $TEST_39_MTIME ] || \
3064 error "mtime($mtime) is not set to $TEST_39_MTIME"
3066 cancel_lru_locks osc
3067 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3070 run_test 39d "create, utime, stat =============================="
3074 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3076 local mtime1=`stat -c %Y $DIR1/$tfile`
3078 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3080 for (( i=0; i < 2; i++ )) ; do
3081 local mtime2=`stat -c %Y $DIR1/$tfile`
3082 [ $mtime2 = $TEST_39_MTIME ] || \
3083 error "mtime($mtime2) is not set to $TEST_39_MTIME"
3085 cancel_lru_locks osc
3086 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3089 run_test 39e "create, stat, utime, stat ========================"
3093 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3095 mtime1=`stat -c %Y $DIR1/$tfile`
3098 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3100 for (( i=0; i < 2; i++ )) ; do
3101 local mtime2=`stat -c %Y $DIR1/$tfile`
3102 [ $mtime2 = $TEST_39_MTIME ] || \
3103 error "mtime($mtime2) is not set to $TEST_39_MTIME"
3105 cancel_lru_locks osc
3106 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3109 run_test 39f "create, stat, sleep, utime, stat ================="
3113 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3114 echo hello >> $DIR1/$tfile
3115 local mtime1=`stat -c %Y $DIR1/$tfile`
3118 chmod o+r $DIR1/$tfile
3120 for (( i=0; i < 2; i++ )) ; do
3121 local mtime2=`stat -c %Y $DIR1/$tfile`
3122 [ "$mtime1" = "$mtime2" ] || \
3123 error "lost mtime: $mtime2, should be $mtime1"
3125 cancel_lru_locks osc
3126 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3129 run_test 39g "write, chmod, stat ==============================="
3133 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3138 echo hello >> $DIR1/$tfile
3139 local mtime1=`stat -c %Y $DIR1/$tfile`
3141 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3143 if [ "$d1" != "$d2" ]; then
3144 echo "write and touch not within one second"
3146 for (( i=0; i < 2; i++ )) ; do
3147 local mtime2=`stat -c %Y $DIR1/$tfile`
3148 [ "$mtime2" = $TEST_39_MTIME ] || \
3149 error "lost mtime: $mtime2, should be $TEST_39_MTIME"
3151 cancel_lru_locks osc
3152 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3156 run_test 39h "write, utime within one second, stat ============="
3159 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3163 echo hello >> $DIR1/$tfile
3164 local mtime1=`stat -c %Y $DIR1/$tfile`
3166 mv $DIR1/$tfile $DIR1/$tfile-1
3168 for (( i=0; i < 2; i++ )) ; do
3169 local mtime2=`stat -c %Y $DIR1/$tfile-1`
3171 [ "$mtime1" = "$mtime2" ] || \
3172 error "lost mtime: $mtime2, should be $mtime1"
3174 cancel_lru_locks osc
3175 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3178 run_test 39i "write, rename, stat =============================="
3181 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3182 start_full_debug_logging
3186 #define OBD_FAIL_OSC_DELAY_SETTIME 0x412
3187 lctl set_param fail_loc=0x80000412
3188 multiop_bg_pause $DIR1/$tfile oO_RDWR:w2097152_c ||
3189 error "multiop failed"
3191 local mtime1=`stat -c %Y $DIR1/$tfile`
3193 mv $DIR1/$tfile $DIR1/$tfile-1
3195 kill -USR1 $multipid
3196 wait $multipid || error "multiop close failed"
3198 for (( i=0; i < 2; i++ )) ; do
3199 local mtime2=`stat -c %Y $DIR1/$tfile-1`
3200 [ "$mtime1" = "$mtime2" ] ||
3201 error "mtime is lost on close: $mtime2, " \
3204 cancel_lru_locks osc
3205 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3207 lctl set_param fail_loc=0
3208 stop_full_debug_logging
3210 run_test 39j "write, rename, close, stat ======================="
3213 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3217 multiop_bg_pause $DIR1/$tfile oO_RDWR:w2097152_c || error "multiop failed"
3219 local mtime1=`stat -c %Y $DIR1/$tfile`
3221 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3223 kill -USR1 $multipid
3224 wait $multipid || error "multiop close failed"
3226 for (( i=0; i < 2; i++ )) ; do
3227 local mtime2=`stat -c %Y $DIR1/$tfile`
3229 [ "$mtime2" = $TEST_39_MTIME ] || \
3230 error "mtime is lost on close: $mtime2, should be $TEST_39_MTIME"
3232 cancel_lru_locks osc
3233 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3236 run_test 39k "write, utime, close, stat ========================"
3238 # this should be set to future
3239 TEST_39_ATIME=`date -d "1 year" +%s`
3242 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3243 remote_mds_nodsh && skip "remote MDS with nodsh" && return
3244 local atime_diff=$(do_facet $SINGLEMDS \
3245 lctl get_param -n mdd.*MDT0000*.atime_diff)
3249 # test setting directory atime to future
3250 touch -a -d @$TEST_39_ATIME $DIR/$tdir
3251 local atime=$(stat -c %X $DIR/$tdir)
3252 [ "$atime" = $TEST_39_ATIME ] || \
3253 error "atime is not set to future: $atime, $TEST_39_ATIME"
3255 # test setting directory atime from future to now
3256 local d1=$(date +%s)
3258 local d2=$(date +%s)
3260 cancel_lru_locks mdc
3261 atime=$(stat -c %X $DIR/$tdir)
3262 [ "$atime" -ge "$d1" -a "$atime" -le "$d2" ] || \
3263 error "atime is not updated from future: $atime, $d1<atime<$d2"
3265 do_facet $SINGLEMDS lctl set_param -n mdd.*MDT0000*.atime_diff=2
3268 # test setting directory atime when now > dir atime + atime_diff
3272 cancel_lru_locks mdc
3273 atime=$(stat -c %X $DIR/$tdir)
3274 [ "$atime" -ge "$d1" -a "$atime" -le "$d2" ] || \
3275 error "atime is not updated : $atime, should be $d2"
3277 do_facet $SINGLEMDS lctl set_param -n mdd.*MDT0000*.atime_diff=60
3280 # test not setting directory atime when now < dir atime + atime_diff
3282 cancel_lru_locks mdc
3283 atime=$(stat -c %X $DIR/$tdir)
3284 [ "$atime" -ge "$d1" -a "$atime" -le "$d2" ] || \
3285 error "atime is updated to $atime, should remain $d1<atime<$d2"
3287 do_facet $SINGLEMDS \
3288 lctl set_param -n mdd.*MDT0000*.atime_diff=$atime_diff
3290 run_test 39l "directory atime update ==========================="
3293 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3296 local far_past_mtime=$(date -d "May 29 1953" +%s)
3297 local far_past_atime=$(date -d "Dec 17 1903" +%s)
3299 touch -m -d @$far_past_mtime $DIR1/$tfile
3300 touch -a -d @$far_past_atime $DIR1/$tfile
3302 for (( i=0; i < 2; i++ )) ; do
3303 local timestamps=$(stat -c "%X %Y" $DIR1/$tfile)
3304 [ "$timestamps" = "$far_past_atime $far_past_mtime" ] || \
3305 error "atime or mtime set incorrectly"
3307 cancel_lru_locks osc
3308 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3311 run_test 39m "test atime and mtime before 1970"
3313 test_39n() { # LU-3832
3314 local atime_diff=$(do_facet $SINGLEMDS \
3315 lctl get_param -n mdd.*MDT0000*.atime_diff)
3320 do_facet $SINGLEMDS lctl set_param -n mdd.*MDT0000*.atime_diff=1
3323 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 status=noxfer
3324 atime0=$(stat -c %X $DIR/$tfile)
3327 $MULTIOP $DIR/$tfile oO_RDONLY:O_NOATIME:r4096c
3328 atime1=$(stat -c %X $DIR/$tfile)
3331 cancel_lru_locks mdc
3332 cancel_lru_locks osc
3333 $MULTIOP $DIR/$tfile oO_RDONLY:O_NOATIME:r4096c
3334 atime2=$(stat -c %X $DIR/$tfile)
3336 do_facet $SINGLEMDS \
3337 lctl set_param -n mdd.*MDT0000*.atime_diff=$atime_diff
3339 [ "$atime0" -eq "$atime1" ] || error "atime0 $atime0 != atime1 $atime1"
3340 [ "$atime1" -eq "$atime2" ] || error "atime0 $atime0 != atime1 $atime1"
3342 run_test 39n "check that O_NOATIME is honored"
3345 TESTDIR=$DIR/$tdir/$tfile
3346 [ -e $TESTDIR ] && rm -rf $TESTDIR
3347 test_mkdir -p $TESTDIR
3353 links2=$(stat -c %h .)
3354 [ $(($links1 + 2)) != $links2 ] &&
3355 error "wrong links count $(($links1 + 2)) != $links2"
3357 links3=$(stat -c %h .)
3358 [ $(($links1 + 1)) != $links3 ] &&
3359 error "wrong links count $links1 != $links3"
3362 run_test 39o "directory cached attributes updated after create ========"
3365 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 2 MDTs" && return
3367 TESTDIR=$DIR/$tdir/$tfile
3368 [ -e $TESTDIR ] && rm -rf $TESTDIR
3373 $LFS mkdir -i $MDTIDX $TESTDIR/remote_dir1
3374 $LFS mkdir -i $MDTIDX $TESTDIR/remote_dir2
3376 links2=$(stat -c %h .)
3377 [ $(($links1 + 2)) != $links2 ] &&
3378 error "wrong links count $(($links1 + 2)) != $links2"
3380 links3=$(stat -c %h .)
3381 [ $(($links1 + 1)) != $links3 ] &&
3382 error "wrong links count $links1 != $links3"
3385 run_test 39p "remote directory cached attributes updated after create ========"
3389 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1
3390 $RUNAS $OPENFILE -f O_WRONLY:O_TRUNC $DIR/$tfile &&
3391 error "openfile O_WRONLY:O_TRUNC $tfile failed"
3392 $CHECKSTAT -t file -s 4096 $DIR/$tfile ||
3393 error "$tfile is not 4096 bytes in size"
3395 run_test 40 "failed open(O_TRUNC) doesn't truncate ============="
3399 small_write $DIR/f41 18
3401 run_test 41 "test small file write + fstat ====================="
3403 count_ost_writes() {
3404 lctl get_param -n osc.*.stats |
3405 awk -vwrites=0 '/ost_write/ { writes += $2 } \
3406 END { printf("%0.0f", writes) }'
3413 BG_DIRTY_RATIO_SAVE=10
3414 MAX_BG_DIRTY_RATIO=25
3418 # in 2.6, restore /proc/sys/vm/dirty_writeback_centisecs,
3419 # dirty_ratio, dirty_background_ratio
3420 if [ -f /proc/sys/vm/dirty_writeback_centisecs ]; then
3421 sysctl -w vm.dirty_writeback_centisecs=$WRITEBACK_SAVE
3422 sysctl -w vm.dirty_background_ratio=$BG_DIRTY_RATIO_SAVE
3423 sysctl -w vm.dirty_ratio=$DIRTY_RATIO_SAVE
3425 # if file not here, we are a 2.4 kernel
3426 kill -CONT `pidof kupdated`
3431 # setup the trap first, so someone cannot exit the test at the
3432 # exact wrong time and mess up a machine
3433 trap start_writeback EXIT
3434 # in 2.6, save and 0 /proc/sys/vm/dirty_writeback_centisecs
3435 if [ -f /proc/sys/vm/dirty_writeback_centisecs ]; then
3436 WRITEBACK_SAVE=`sysctl -n vm.dirty_writeback_centisecs`
3437 sysctl -w vm.dirty_writeback_centisecs=0
3438 sysctl -w vm.dirty_writeback_centisecs=0
3439 # save and increase /proc/sys/vm/dirty_ratio
3440 DIRTY_RATIO_SAVE=`sysctl -n vm.dirty_ratio`
3441 sysctl -w vm.dirty_ratio=$MAX_DIRTY_RATIO
3442 # save and increase /proc/sys/vm/dirty_background_ratio
3443 BG_DIRTY_RATIO_SAVE=`sysctl -n vm.dirty_background_ratio`
3444 sysctl -w vm.dirty_background_ratio=$MAX_BG_DIRTY_RATIO
3446 # if file not here, we are a 2.4 kernel
3447 kill -STOP `pidof kupdated`
3451 # ensure that all stripes have some grant before we test client-side cache
3453 for i in `seq -f $DIR/f42-%g 1 $OSTCOUNT`; do
3454 dd if=/dev/zero of=$i bs=4k count=1
3459 # Tests 42* verify that our behaviour is correct WRT caching, file closure,
3460 # file truncation, and file removal.
3462 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3464 cancel_lru_locks osc
3466 sync; sleep 1; sync # just to be safe
3467 BEFOREWRITES=`count_ost_writes`
3468 lctl get_param -n osc.*[oO][sS][cC][_-]*.cur_grant_bytes | grep "[0-9]"
3469 dd if=/dev/zero of=$DIR/f42a bs=1024 count=100
3470 AFTERWRITES=`count_ost_writes`
3471 [ $BEFOREWRITES -eq $AFTERWRITES ] || \
3472 error "$BEFOREWRITES < $AFTERWRITES"
3475 run_test 42a "ensure that we don't flush on close =============="
3478 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3480 cancel_lru_locks osc
3483 dd if=/dev/zero of=$DIR/f42b bs=1024 count=100
3484 BEFOREWRITES=$(count_ost_writes)
3485 $MUNLINK $DIR/f42b || error "$MUNLINK $DIR/f42b: $?"
3486 AFTERWRITES=$(count_ost_writes)
3487 if [[ $BEFOREWRITES -lt $AFTERWRITES ]]; then
3488 error "$BEFOREWRITES < $AFTERWRITES on unlink"
3490 BEFOREWRITES=$(count_ost_writes)
3491 sync || error "sync: $?"
3492 AFTERWRITES=$(count_ost_writes)
3493 if [[ $BEFOREWRITES -lt $AFTERWRITES ]]; then
3494 error "$BEFOREWRITES < $AFTERWRITES on sync"
3496 dmesg | grep 'error from obd_brw_async' && error 'error writing back'
3500 run_test 42b "test destroy of file with cached dirty data ======"
3502 # if these tests just want to test the effect of truncation,
3503 # they have to be very careful. consider:
3504 # - the first open gets a {0,EOF}PR lock
3505 # - the first write conflicts and gets a {0, count-1}PW
3506 # - the rest of the writes are under {count,EOF}PW
3507 # - the open for truncate tries to match a {0,EOF}PR
3508 # for the filesize and cancels the PWs.
3509 # any number of fixes (don't get {0,EOF} on open, match
3510 # composite locks, do smarter file size management) fix
3511 # this, but for now we want these tests to verify that
3512 # the cancellation with truncate intent works, so we
3513 # start the file with a full-file pw lock to match against
3514 # until the truncate.
3519 cancel_lru_locks osc
3521 # prime the file with 0,EOF PW to match
3525 # now the real test..
3526 dd if=/dev/zero of=$file bs=1024 count=100
3527 BEFOREWRITES=`count_ost_writes`
3528 $TRUNCATE $file $offset
3529 cancel_lru_locks osc
3530 AFTERWRITES=`count_ost_writes`
3535 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3537 [ $BEFOREWRITES -eq $AFTERWRITES ] && \
3538 error "beforewrites $BEFOREWRITES == afterwrites $AFTERWRITES on truncate"
3541 run_test 42c "test partial truncate of file with cached dirty data"
3544 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3546 [ $BEFOREWRITES -eq $AFTERWRITES ] || \
3547 error "beforewrites $BEFOREWRITES != afterwrites $AFTERWRITES on truncate"
3550 run_test 42d "test complete truncate of file with cached dirty data"
3552 test_42e() { # bug22074
3553 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3554 local TDIR=$DIR/${tdir}e
3555 local pagesz=$(page_size)
3556 local pages=16 # hardcoded 16 pages, don't change it.
3557 local files=$((OSTCOUNT * 500)) # hopefully 500 files on each OST
3558 local proc_osc0="osc.${FSNAME}-OST0000-osc-[^MDT]*"
3562 test_mkdir -p $DIR/${tdir}e
3563 $SETSTRIPE -c 1 $TDIR
3564 createmany -o $TDIR/f $files
3566 max_dirty_mb=$($LCTL get_param -n $proc_osc0/max_dirty_mb)
3568 # we assume that with $OSTCOUNT files, at least one of them will
3569 # be allocated on OST0.
3570 warmup_files=$((OSTCOUNT * max_dirty_mb))
3571 createmany -o $TDIR/w $warmup_files
3573 # write a large amount of data into one file and sync, to get good
3574 # avail_grant number from OST.
3575 for ((i=0; i<$warmup_files; i++)); do
3576 idx=$($GETSTRIPE -i $TDIR/w$i)
3577 [ $idx -ne 0 ] && continue
3578 dd if=/dev/zero of=$TDIR/w$i bs="$max_dirty_mb"M count=1
3581 [[ $i -gt $warmup_files ]] && error "OST0 is still cold"
3583 $LCTL get_param $proc_osc0/cur_dirty_bytes
3584 $LCTL get_param $proc_osc0/cur_grant_bytes
3586 # create as much dirty pages as we can while not to trigger the actual
3587 # RPCs directly. but depends on the env, VFS may trigger flush during this
3588 # period, hopefully we are good.
3589 for ((i=0; i<$warmup_files; i++)); do
3590 idx=$($GETSTRIPE -i $TDIR/w$i)
3591 [ $idx -ne 0 ] && continue
3592 dd if=/dev/zero of=$TDIR/w$i bs=1M count=1 2>/dev/null
3594 $LCTL get_param $proc_osc0/cur_dirty_bytes
3595 $LCTL get_param $proc_osc0/cur_grant_bytes
3597 # perform the real test
3598 $LCTL set_param $proc_osc0/rpc_stats 0
3599 for ((;i<$files; i++)); do
3600 [ $($GETSTRIPE -i $TDIR/f$i) -eq 0 ] || continue
3601 dd if=/dev/zero of=$TDIR/f$i bs=$pagesz count=$pages 2>/dev/null
3604 $LCTL get_param $proc_osc0/rpc_stats
3607 local have_ppr=false
3608 $LCTL get_param $proc_osc0/rpc_stats |
3609 while read PPR RRPC RPCT RCUM BAR WRPC WPCT WCUM; do
3610 # skip lines until we are at the RPC histogram data
3611 [ "$PPR" == "pages" ] && have_ppr=true && continue
3612 $have_ppr || continue
3614 # we only want the percent stat for < 16 pages
3615 [[ $(echo $PPR | tr -d ':') -ge $pages ]] && break
3617 percent=$((percent + WPCT))
3618 if [[ $percent -gt 15 ]]; then
3619 error "less than 16-pages write RPCs" \
3626 run_test 42e "verify sub-RPC writes are not done synchronously"
3629 test_mkdir -p $DIR/$tdir
3630 cp -p /bin/ls $DIR/$tdir/$tfile
3631 $MULTIOP $DIR/$tdir/$tfile Ow_c &
3633 # give multiop a chance to open
3636 $DIR/$tdir/$tfile && error || true
3639 run_test 43 "execution of file opened for write should return -ETXTBSY"
3642 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3643 test_mkdir -p $DIR/$tdir
3644 cp -p `which $MULTIOP` $DIR/$tdir/multiop ||
3645 cp -p multiop $DIR/$tdir/multiop
3646 MULTIOP_PROG=$DIR/$tdir/multiop multiop_bg_pause $TMP/$tfile.junk O_c ||
3649 $MULTIOP $DIR/$tdir/multiop Oc && error "expected error, got success"
3650 kill -USR1 $MULTIOP_PID || return 2
3651 wait $MULTIOP_PID || return 3
3652 rm $TMP/$tfile.junk $DIR/$tdir/multiop
3654 run_test 43a "open(RDWR) of file being executed should return -ETXTBSY"
3657 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3658 test_mkdir -p $DIR/$tdir
3659 cp -p `which $MULTIOP` $DIR/$tdir/multiop ||
3660 cp -p multiop $DIR/$tdir/multiop
3661 MULTIOP_PROG=$DIR/$tdir/multiop multiop_bg_pause $TMP/$tfile.junk O_c ||
3664 $TRUNCATE $DIR/$tdir/multiop 0 && error "expected error, got success"
3665 kill -USR1 $MULTIOP_PID || return 2
3666 wait $MULTIOP_PID || return 3
3667 rm $TMP/$tfile.junk $DIR/$tdir/multiop
3669 run_test 43b "truncate of file being executed should return -ETXTBSY"
3672 local testdir="$DIR/$tdir"
3673 test_mkdir -p $DIR/$tdir
3675 ( cd $(dirname $SHELL) && md5sum $(basename $SHELL) ) | \
3676 ( cd $testdir && md5sum -c)
3678 run_test 43c "md5sum of copy into lustre========================"
3681 [[ $OSTCOUNT -lt 2 ]] && skip_env "skipping 2-stripe test" && return
3682 dd if=/dev/zero of=$DIR/f1 bs=4k count=1 seek=1023
3683 dd if=$DIR/f1 bs=4k count=1 > /dev/null
3685 run_test 44 "zero length read from a sparse stripe ============="
3688 local nstripe=$($LCTL lov_getconfig $DIR | grep default_stripe_count: |
3690 [ -z "$nstripe" ] && skip "can't get stripe info" && return
3691 [[ $nstripe -gt $OSTCOUNT ]] &&
3692 skip "Wrong default_stripe_count: $nstripe (OSTCOUNT: $OSTCOUNT)" &&
3694 local stride=$($LCTL lov_getconfig $DIR | grep default_stripe_size: |
3696 if [[ $nstripe -eq 0 || $nstripe -eq -1 ]]; then
3697 nstripe=$($LCTL lov_getconfig $DIR | grep obd_count: |
3701 OFFSETS="0 $((stride/2)) $((stride-1))"
3702 for offset in $OFFSETS; do
3703 for i in $(seq 0 $((nstripe-1))); do
3704 local GLOBALOFFSETS=""
3706 local size=$((((i + 2 * $nstripe )*$stride + $offset)))
3707 local myfn=$DIR/d44a-$size
3708 echo "--------writing $myfn at $size"
3709 ll_sparseness_write $myfn $size ||
3710 error "ll_sparseness_write"
3711 GLOBALOFFSETS="$GLOBALOFFSETS $size"
3712 ll_sparseness_verify $myfn $GLOBALOFFSETS ||
3713 error "ll_sparseness_verify $GLOBALOFFSETS"
3715 for j in $(seq 0 $((nstripe-1))); do
3717 size=$((((j + $nstripe )*$stride + $offset)))
3718 ll_sparseness_write $myfn $size ||
3719 error "ll_sparseness_write"
3720 GLOBALOFFSETS="$GLOBALOFFSETS $size"
3722 ll_sparseness_verify $myfn $GLOBALOFFSETS ||
3723 error "ll_sparseness_verify $GLOBALOFFSETS"
3728 run_test 44a "test sparse pwrite ==============================="
3732 for d in `lctl get_param -n osc.*.cur_dirty_bytes`; do
3738 before=`dirty_osc_total`
3739 echo executing "\"$*\""
3741 after=`dirty_osc_total`
3742 echo before $before, after $after
3745 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3747 # Obtain grants from OST if it supports it
3748 echo blah > ${f}_grant
3751 do_dirty_record "echo blah > $f"
3752 [[ $before -eq $after ]] && error "write wasn't cached"
3753 do_dirty_record "> $f"
3754 [[ $before -gt $after ]] || error "truncate didn't lower dirty count"
3755 do_dirty_record "echo blah > $f"
3756 [[ $before -eq $after ]] && error "write wasn't cached"
3757 do_dirty_record "sync"
3758 [[ $before -gt $after ]] || error "writeback didn't lower dirty count"
3759 do_dirty_record "echo blah > $f"
3760 [[ $before -eq $after ]] && error "write wasn't cached"
3761 do_dirty_record "cancel_lru_locks osc"
3762 [[ $before -gt $after ]] ||
3763 error "lock cancellation didn't lower dirty count"
3766 run_test 45 "osc io page accounting ============================"
3768 # in a 2 stripe file (lov.sh), page 1023 maps to page 511 in its object. this
3769 # test tickles a bug where re-dirtying a page was failing to be mapped to the
3770 # objects offset and an assert hit when an rpc was built with 1023's mapped
3771 # offset 511 and 511's raw 511 offset. it also found general redirtying bugs.
3773 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3777 dd if=/dev/zero of=$f bs=`page_size` seek=511 count=1
3779 dd conv=notrunc if=/dev/zero of=$f bs=`page_size` seek=1023 count=1
3780 dd conv=notrunc if=/dev/zero of=$f bs=`page_size` seek=511 count=1
3784 run_test 46 "dirtying a previously written page ================"
3786 # test_47 is removed "Device nodes check" is moved to test_28
3788 test_48a() { # bug 2399
3789 check_kernel_version 34 || return 0
3790 test_mkdir -p $DIR/$tdir
3792 mv $DIR/$tdir $DIR/d48.new || error "move directory failed"
3793 test_mkdir $DIR/$tdir || error "recreate directory failed"
3794 touch foo || error "'touch foo' failed after recreating cwd"
3795 test_mkdir $DIR/$tdir/bar ||
3796 error "'mkdir foo' failed after recreating cwd"
3797 if check_kernel_version 44; then
3798 touch .foo || error "'touch .foo' failed after recreating cwd"
3799 test_mkdir $DIR/$tdir/.bar ||
3800 error "'mkdir .foo' failed after recreating cwd"
3802 ls . > /dev/null || error "'ls .' failed after recreating cwd"
3803 ls .. > /dev/null || error "'ls ..' failed after removing cwd"
3804 cd . || error "'cd .' failed after recreating cwd"
3805 test_mkdir . && error "'mkdir .' worked after recreating cwd"
3806 rmdir . && error "'rmdir .' worked after recreating cwd"
3807 ln -s . baz || error "'ln -s .' failed after recreating cwd"
3808 cd .. || error "'cd ..' failed after recreating cwd"
3810 run_test 48a "Access renamed working dir (should return errors)="
3812 test_48b() { # bug 2399
3813 check_kernel_version 34 || return 0
3815 test_mkdir -p $DIR/$tdir
3817 rmdir $DIR/$tdir || error "remove cwd $DIR/$tdir failed"
3818 touch foo && error "'touch foo' worked after removing cwd"
3819 test_mkdir $DIR/$tdir/foo &&
3820 error "'mkdir foo' worked after removing cwd"
3821 if check_kernel_version 44; then
3822 touch .foo && error "'touch .foo' worked after removing cwd"
3823 test_mkdir $DIR/$tdir/.foo &&
3824 error "'mkdir .foo' worked after removing cwd"
3826 ls . > /dev/null && error "'ls .' worked after removing cwd"
3827 ls .. > /dev/null || error "'ls ..' failed after removing cwd"
3828 is_patchless || ( cd . && error "'cd .' worked after removing cwd" )
3829 test_mkdir $DIR/$tdir/. && error "'mkdir .' worked after removing cwd"
3830 rmdir . && error "'rmdir .' worked after removing cwd"
3831 ln -s . foo && error "'ln -s .' worked after removing cwd"
3832 cd .. || echo "'cd ..' failed after removing cwd `pwd`" #bug 3517
3834 run_test 48b "Access removed working dir (should return errors)="
3836 test_48c() { # bug 2350
3837 check_kernel_version 36 || return 0
3838 #lctl set_param debug=-1
3841 test_mkdir -p $DIR/$tdir/dir
3843 $TRACE rmdir $DIR/$tdir/dir || error "remove cwd $DIR/$tdir/dir failed"
3844 $TRACE touch foo && error "touch foo worked after removing cwd"
3845 $TRACE test_mkdir foo && error "'mkdir foo' worked after removing cwd"
3846 if check_kernel_version 44; then
3847 touch .foo && error "touch .foo worked after removing cwd"
3848 test_mkdir .foo && error "mkdir .foo worked after removing cwd"
3850 $TRACE ls . && error "'ls .' worked after removing cwd"
3851 $TRACE ls .. || error "'ls ..' failed after removing cwd"
3852 is_patchless || ( $TRACE cd . &&
3853 error "'cd .' worked after removing cwd" )
3854 $TRACE test_mkdir . && error "'mkdir .' worked after removing cwd"
3855 $TRACE rmdir . && error "'rmdir .' worked after removing cwd"
3856 $TRACE ln -s . foo && error "'ln -s .' worked after removing cwd"
3857 $TRACE cd .. || echo "'cd ..' failed after removing cwd `pwd`" #bug 3415
3859 run_test 48c "Access removed working subdir (should return errors)"
3861 test_48d() { # bug 2350
3862 check_kernel_version 36 || return 0
3863 #lctl set_param debug=-1
3866 test_mkdir -p $DIR/$tdir/dir
3868 $TRACE rmdir $DIR/$tdir/dir || error "remove cwd $DIR/$tdir/dir failed"
3869 $TRACE rmdir $DIR/$tdir || error "remove parent $DIR/$tdir failed"
3870 $TRACE touch foo && error "'touch foo' worked after removing parent"
3871 $TRACE test_mkdir foo && error "mkdir foo worked after removing parent"
3872 if check_kernel_version 44; then
3873 touch .foo && error "'touch .foo' worked after removing parent"
3875 error "mkdir .foo worked after removing parent"
3877 $TRACE ls . && error "'ls .' worked after removing parent"
3878 $TRACE ls .. && error "'ls ..' worked after removing parent"
3879 is_patchless || ( $TRACE cd . &&
3880 error "'cd .' worked after recreate parent" )
3881 $TRACE test_mkdir . && error "'mkdir .' worked after removing parent"
3882 $TRACE rmdir . && error "'rmdir .' worked after removing parent"
3883 $TRACE ln -s . foo && error "'ln -s .' worked after removing parent"
3884 is_patchless || ( $TRACE cd .. &&
3885 error "'cd ..' worked after removing parent" || true )
3887 run_test 48d "Access removed parent subdir (should return errors)"
3889 test_48e() { # bug 4134
3890 check_kernel_version 41 || return 0
3891 #lctl set_param debug=-1
3894 test_mkdir -p $DIR/$tdir/dir
3896 $TRACE rmdir $DIR/$tdir/dir || error "remove cwd $DIR/$tdir/dir failed"
3897 $TRACE rmdir $DIR/$tdir || error "remove parent $DIR/$tdir failed"
3898 $TRACE touch $DIR/$tdir || error "'touch $DIR/$tdir' failed"
3899 $TRACE chmod +x $DIR/$tdir || error "'chmod +x $DIR/$tdir' failed"
3900 # On a buggy kernel addition of "touch foo" after cd .. will
3901 # produce kernel oops in lookup_hash_it
3902 touch ../foo && error "'cd ..' worked after recreate parent"
3904 $TRACE rm $DIR/$tdir || error "rm '$DIR/$tdir' failed"
3906 run_test 48e "Access to recreated parent subdir (should return errors)"
3908 test_49() { # LU-1030
3909 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3910 # get ost1 size - lustre-OST0000
3911 ost1_size=$(do_facet ost1 $LFS df | grep ${ost1_svc} |