2 # -*- tab-width: 8; indent-tabs-mode: t; -*-
4 # Run select tests by setting ONLY, or as arguments to the script.
5 # Skip specific tests by setting EXCEPT.
7 # e.g. ONLY="22 23" or ONLY="`seq 32 39`" or EXCEPT="31"
11 # bug number for skipped test: 13297 2108 9789 3637 9789 3561 12622 5188
12 ALWAYS_EXCEPT=" 42a 42b 42c 42d 45 51d 68b $SANITY_EXCEPT"
13 # UPDATE THE COMMENT ABOVE WITH BUG NUMBERS WHEN CHANGING ALWAYS_EXCEPT!
15 # with LOD/OSP landing
16 # bug number for skipped tests: LU-2036
17 ALWAYS_EXCEPT=" 76 $ALWAYS_EXCEPT"
21 if [ -r /etc/SuSE-release ]
23 local vers=`grep VERSION /etc/SuSE-release | awk '{print $3}'`
32 if is_sles11; then # LU-4351
33 ALWAYS_EXCEPT="$ALWAYS_EXCEPT 54c"
36 SRCDIR=$(cd $(dirname $0); echo $PWD)
37 export PATH=$PATH:/sbin
41 CHECKSTAT=${CHECKSTAT:-"checkstat -v"}
42 CREATETEST=${CREATETEST:-createtest}
44 LFIND=${LFIND:-"$LFS find"}
45 LVERIFY=${LVERIFY:-ll_dirstripe_verify}
47 MCREATE=${MCREATE:-mcreate}
48 OPENFILE=${OPENFILE:-openfile}
49 OPENUNLINK=${OPENUNLINK:-openunlink}
50 export MULTIOP=${MULTIOP:-multiop}
51 READS=${READS:-"reads"}
52 MUNLINK=${MUNLINK:-munlink}
53 SOCKETSERVER=${SOCKETSERVER:-socketserver}
54 SOCKETCLIENT=${SOCKETCLIENT:-socketclient}
55 MEMHOG=${MEMHOG:-memhog}
56 DIRECTIO=${DIRECTIO:-directio}
57 ACCEPTOR_PORT=${ACCEPTOR_PORT:-988}
58 UMOUNT=${UMOUNT:-"umount -d"}
60 CHECK_GRANT=${CHECK_GRANT:-"yes"}
61 GRANT_CHECK_LIST=${GRANT_CHECK_LIST:-""}
62 export PARALLEL=${PARALLEL:-"no"}
64 export NAME=${NAME:-local}
71 LUSTRE=${LUSTRE:-$(cd $(dirname $0)/..; echo $PWD)}
72 . $LUSTRE/tests/test-framework.sh
74 . ${CONFIG:=$LUSTRE/tests/cfg/${NAME}.sh}
77 [ "$SLOW" = "no" ] && EXCEPT_SLOW="24o 27m 64b 68 71 77f 78 115 124b 230d"
79 [ $(facet_fstype $SINGLEMDS) = "zfs" ] &&
80 # bug number for skipped test: LU-1593 LU-2610 LU-2833 LU-1957 LU-2805
81 ALWAYS_EXCEPT="$ALWAYS_EXCEPT 34h 40 48a 180 184c"
87 pgrep ll_sa > /dev/null && { echo "There are ll_sa thread not exit!"; exit 20; }
88 cleanupall ${FORCE} $* || { echo "FAILed to clean up"; exit 20; }
97 check_kernel_version() {
99 GOT_VER=$(lctl get_param -n version | awk '/kernel:/ {print $2}')
101 patchless|patchless_client) return 0;;
102 *) [ $GOT_VER -ge $WANT_VER ] && return 0 ;;
104 log "test needs at least kernel version $WANT_VER, running $GOT_VER"
108 check_swap_layouts_support()
110 $LCTL get_param -n llite.*.sbi_flags | grep -q layout ||
111 { skip "Does not support layout lock."; return 0; }
115 if [ "$ONLY" == "cleanup" ]; then
120 check_and_setup_lustre
125 MDT0=$($LCTL get_param -n mdc.*.mds_server_uuid |
126 awk '{ gsub(/_UUID/,""); print $1 }' | head -n1)
127 LOVNAME=$($LCTL get_param -n llite.*.lov.common_name | tail -n 1)
128 OSTCOUNT=$($LCTL get_param -n lov.$LOVNAME.numobd)
129 STRIPECOUNT=$($LCTL get_param -n lov.$LOVNAME.stripecount)
130 STRIPESIZE=$($LCTL get_param -n lov.$LOVNAME.stripesize)
131 ORIGFREE=$($LCTL get_param -n lov.$LOVNAME.kbytesavail)
132 MAXFREE=${MAXFREE:-$((200000 * $OSTCOUNT))}
134 [ -f $DIR/d52a/foo ] && chattr -a $DIR/d52a/foo
135 [ -f $DIR/d52b/foo ] && chattr -i $DIR/d52b/foo
136 rm -rf $DIR/[Rdfs][0-9]*
138 # $RUNAS_ID may get set incorrectly somewhere else
139 [ $UID -eq 0 -a $RUNAS_ID -eq 0 ] && error "\$RUNAS_ID set to 0, but \$UID is also 0!"
141 check_runas_id $RUNAS_ID $RUNAS_GID $RUNAS
145 if [ "${ONLY}" = "MOUNT" ] ; then
146 echo "Lustre is up, please go on"
150 echo "preparing for tests involving mounts"
151 EXT2_DEV=${EXT2_DEV:-$TMP/SANITY.LOOP}
153 mke2fs -j -F $EXT2_DEV 8000 > /dev/null
154 echo # add a newline after mke2fs.
158 OLDDEBUG=$(lctl get_param -n debug 2> /dev/null)
159 lctl set_param debug=-1 2> /dev/null || true
162 $CHECKSTAT -t file $DIR/$tfile || error "$tfile is not a file"
164 $CHECKSTAT -a $DIR/$tfile || error "$tfile was not removed"
166 run_test 0a "touch; rm ====================="
169 chmod 0755 $DIR || error "chmod 0755 $DIR failed"
170 $CHECKSTAT -p 0755 $DIR || error "$DIR permission is not 0755"
172 run_test 0b "chmod 0755 $DIR ============================="
175 $LCTL get_param mdc.*.import | grep "state: FULL" ||
176 error "import not FULL"
177 $LCTL get_param mdc.*.import | grep "target: $FSNAME-MDT" ||
180 run_test 0c "check import proc ============================="
183 test_mkdir -p $DIR/$tdir || error "mkdir $tdir failed"
184 test_mkdir -p $DIR/$tdir/d2 || error "mkdir $tdir/d2 failed"
185 test_mkdir $DIR/$tdir/d2 && error "we expect EEXIST, but not returned"
186 $CHECKSTAT -t dir $DIR/$tdir/d2 || error "$tdir/d2 is not a dir"
189 $CHECKSTAT -a $DIR/$tdir || error "$tdir was not removed"
191 run_test 1 "mkdir; remkdir; rmdir =============================="
194 test_mkdir -p $DIR/$tdir || error "mkdir $tdir failed"
195 touch $DIR/$tdir/$tfile || error "touch $tdir/$tfile failed"
196 $CHECKSTAT -t file $DIR/$tdir/$tfile || error "$tdir/$tfile not a file"
198 $CHECKSTAT -a $DIR/$tdir/$tfile || error "$tdir/$file is not removed"
200 run_test 2 "mkdir; touch; rmdir; check file ===================="
203 test_mkdir -p $DIR/$tdir || error "mkdir $tdir failed"
204 $CHECKSTAT -t dir $DIR/$tdir || error "$tdir is not a directory"
205 touch $DIR/$tdir/$tfile
206 $CHECKSTAT -t file $DIR/$tdir/$tfile || error "$tdir/$tfile not a file"
208 $CHECKSTAT -a $DIR/$tdir || error "$tdir is not removed"
210 run_test 3 "mkdir; touch; rmdir; check dir ====================="
212 # LU-4471 - failed rmdir on remote directories still removes directory on MDT0
215 local remote_dir=remote_dir
217 [ $MDSCOUNT -ge 2 ] && skip "skip now for LU-4690" && return #LU-4690
218 test_mkdir $DIR/$remote_dir ||
219 error "Create remote directory failed"
221 touch $DIR/$remote_dir/$tfile ||
222 error "Create file under remote directory failed"
224 rmdir $DIR/$remote_dir &&
225 error "Expect error removing in-use dir $DIR/$remote_dir"
227 test -d $DIR/$remote_dir || error "Remote directory disappeared"
229 run_test 4 "mkdir; touch dir/file; rmdir; checkdir (expect error)"
232 test_mkdir -p $DIR/$tdir || error "mkdir $tdir failed"
233 test_mkdir $DIR/$tdir/d2 || error "mkdir $tdir/d2 failed"
234 chmod 0707 $DIR/$tdir/d2 || error "chmod 0707 $tdir/d2 failed"
235 $CHECKSTAT -t dir -p 0707 $DIR/$tdir/d2 || error "$tdir/d2 not mode 707"
236 $CHECKSTAT -t dir $DIR/$tdir/d2 || error "$tdir/d2 is not a directory"
238 run_test 5 "mkdir .../d5 .../d5/d2; chmod .../d5/d2 ============"
241 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
242 chmod 0666 $DIR/$tfile || error "chmod 0666 $tfile failed"
243 $CHECKSTAT -t file -p 0666 -u \#$UID $DIR/$tfile ||
244 error "$tfile does not have perm 0666 or UID $UID"
245 $RUNAS chmod 0444 $DIR/$tfile && error "chmod $tfile worked on UID $UID"
246 $CHECKSTAT -t file -p 0666 -u \#$UID $DIR/$tfile ||
247 error "$tfile should be 0666 and owned by UID $UID"
249 run_test 6a "touch f6a; chmod f6a; $RUNAS chmod f6a (should return error) =="
252 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID" && return
254 chown $RUNAS_ID $DIR/$tfile || error "chown $RUNAS_ID $file failed"
255 $CHECKSTAT -t file -u \#$RUNAS_ID $DIR/$tfile ||
256 error "$tfile should be owned by UID $RUNAS_ID"
257 $RUNAS chown $UID $DIR/$tfile && error "chown $UID $file succeeded"
258 $CHECKSTAT -t file -u \#$RUNAS_ID $DIR/$tfile ||
259 error "$tfile should be owned by UID $RUNAS_ID"
261 run_test 6c "touch f6c; chown f6c; $RUNAS chown f6c (should return error) =="
264 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID" && return
266 chgrp $RUNAS_ID $DIR/$tfile || error "chgrp $RUNAS_ID $file failed"
267 $CHECKSTAT -t file -u \#$UID -g \#$RUNAS_ID $DIR/$tfile ||
268 error "$tfile should be owned by GID $UID"
269 $RUNAS chgrp $UID $DIR/$tfile && error "chgrp $UID $file succeeded"
270 $CHECKSTAT -t file -u \#$UID -g \#$RUNAS_ID $DIR/$tfile ||
271 error "$tfile should be owned by UID $UID and GID $RUNAS_ID"
273 run_test 6e "touch f6e; chgrp f6e; $RUNAS chgrp f6e (should return error) =="
276 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID" && return
277 test_mkdir $DIR/$tdir || error "mkdir $tfile failed"
278 chmod 777 $DIR/$tdir || error "chmod 0777 $tdir failed"
279 $RUNAS mkdir $DIR/$tdir/d || error "mkdir $tdir/d failed"
280 chmod g+s $DIR/$tdir/d || error "chmod g+s $tdir/d failed"
281 test_mkdir $DIR/$tdir/d/subdir || error "mkdir $tdir/d/subdir failed"
282 $CHECKSTAT -g \#$RUNAS_GID $DIR/$tdir/d/subdir ||
283 error "$tdir/d/subdir should be GID $RUNAS_GID"
285 run_test 6g "Is new dir in sgid dir inheriting group?"
287 test_6h() { # bug 7331
288 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID" && return
289 touch $DIR/$tfile || error "touch failed"
290 chown $RUNAS_ID:$RUNAS_GID $DIR/$tfile || error "initial chown failed"
291 $RUNAS -G$RUNAS_GID chown $RUNAS_ID:0 $DIR/$tfile &&
292 error "chown $RUNAS_ID:0 $tfile worked as GID $RUNAS_GID"
293 $CHECKSTAT -t file -u \#$RUNAS_ID -g \#$RUNAS_GID $DIR/$tfile ||
294 error "$tdir/$tfile should be UID $RUNAS_UID GID $RUNAS_GID"
296 run_test 6h "$RUNAS chown RUNAS_ID.0 .../f6h (should return error)"
299 test_mkdir $DIR/$tdir
300 $MCREATE $DIR/$tdir/$tfile
301 chmod 0666 $DIR/$tdir/$tfile
302 $CHECKSTAT -t file -p 0666 $DIR/$tdir/$tfile ||
303 error "$tdir/$tfile should be mode 0666"
305 run_test 7a "mkdir .../d7; mcreate .../d7/f; chmod .../d7/f ===="
308 if [ ! -d $DIR/$tdir ]; then
311 $MCREATE $DIR/$tdir/$tfile
312 echo -n foo > $DIR/$tdir/$tfile
313 [ "$(cat $DIR/$tdir/$tfile)" = "foo" ] || error "$tdir/$tfile not 'foo'"
314 $CHECKSTAT -t file -s 3 $DIR/$tdir/$tfile || error "$tfile size not 3"
316 run_test 7b "mkdir .../d7; mcreate d7/f2; echo foo > d7/f2 ====="
319 test_mkdir $DIR/$tdir
320 touch $DIR/$tdir/$tfile
321 chmod 0666 $DIR/$tdir/$tfile
322 $CHECKSTAT -t file -p 0666 $DIR/$tdir/$tfile ||
323 error "$tfile mode not 0666"
325 run_test 8 "mkdir .../d8; touch .../d8/f; chmod .../d8/f ======="
328 test_mkdir $DIR/$tdir
329 test_mkdir $DIR/$tdir/d2
330 test_mkdir $DIR/$tdir/d2/d3
331 $CHECKSTAT -t dir $DIR/$tdir/d2/d3 || error "$tdir/d2/d3 not a dir"
333 run_test 9 "mkdir .../d9 .../d9/d2 .../d9/d2/d3 ================"
336 test_mkdir $DIR/$tdir
337 test_mkdir $DIR/$tdir/d2
338 touch $DIR/$tdir/d2/$tfile
339 $CHECKSTAT -t file $DIR/$tdir/d2/$tfile ||
340 error "$tdir/d2/$tfile not a file"
342 run_test 10 "mkdir .../d10 .../d10/d2; touch .../d10/d2/f ======"
345 test_mkdir $DIR/$tdir
346 test_mkdir $DIR/$tdir/d2
347 chmod 0666 $DIR/$tdir/d2
348 chmod 0705 $DIR/$tdir/d2
349 $CHECKSTAT -t dir -p 0705 $DIR/$tdir/d2 ||
350 error "$tdir/d2 mode not 0705"
352 run_test 11 "mkdir .../d11 d11/d2; chmod .../d11/d2 ============"
355 test_mkdir $DIR/$tdir
356 touch $DIR/$tdir/$tfile
357 chmod 0666 $DIR/$tdir/$tfile
358 chmod 0654 $DIR/$tdir/$tfile
359 $CHECKSTAT -t file -p 0654 $DIR/$tdir/$tfile ||
360 error "$tdir/d2 mode not 0654"
362 run_test 12 "touch .../d12/f; chmod .../d12/f .../d12/f ========"
365 test_mkdir $DIR/$tdir
366 dd if=/dev/zero of=$DIR/$tdir/$tfile count=10
368 $CHECKSTAT -t file -s 0 $DIR/$tdir/$tfile ||
369 error "$tdir/$tfile size not 0 after truncate"
371 run_test 13 "creat .../d13/f; dd .../d13/f; > .../d13/f ========"
374 test_mkdir $DIR/$tdir
375 touch $DIR/$tdir/$tfile
377 $CHECKSTAT -a $DIR/$tdir/$tfile || error "$tdir/$tfile not removed"
379 run_test 14 "touch .../d14/f; rm .../d14/f; rm .../d14/f ======="
382 test_mkdir $DIR/$tdir
383 touch $DIR/$tdir/$tfile
384 mv $DIR/$tdir/$tfile $DIR/$tdir/${tfile}_2
385 $CHECKSTAT -t file $DIR/$tdir/${tfile}_2 ||
386 error "$tdir/${tfile_2} not a file after rename"
388 run_test 15 "touch .../d15/f; mv .../d15/f .../d15/f2 =========="
391 test_mkdir $DIR/$tdir
392 touch $DIR/$tdir/$tfile
393 rm -rf $DIR/$tdir/$tfile
394 $CHECKSTAT -a $DIR/$tdir/$tfile || error "$tdir/$tfile not removed"
396 run_test 16 "touch .../d16/f; rm -rf .../d16/f ================="
399 test_mkdir -p $DIR/$tdir
400 touch $DIR/$tdir/$tfile
401 ln -s $DIR/$tdir/$tfile $DIR/$tdir/l-exist
403 $CHECKSTAT -l $DIR/$tdir/$tfile $DIR/$tdir/l-exist ||
404 error "$tdir/l-exist not a symlink"
405 $CHECKSTAT -f -t f $DIR/$tdir/l-exist ||
406 error "$tdir/l-exist not referencing a file"
407 rm -f $DIR/$tdir/l-exist
408 $CHECKSTAT -a $DIR/$tdir/l-exist || error "$tdir/l-exist not removed"
410 run_test 17a "symlinks: create, remove (real) =================="
413 test_mkdir -p $DIR/$tdir
414 ln -s no-such-file $DIR/$tdir/l-dangle
416 $CHECKSTAT -l no-such-file $DIR/$tdir/l-dangle ||
417 error "$tdir/l-dangle not referencing no-such-file"
418 $CHECKSTAT -fa $DIR/$tdir/l-dangle ||
419 error "$tdir/l-dangle not referencing non-existent file"
420 rm -f $DIR/$tdir/l-dangle
421 $CHECKSTAT -a $DIR/$tdir/l-dangle || error "$tdir/l-dangle not removed"
423 run_test 17b "symlinks: create, remove (dangling) =============="
425 test_17c() { # bug 3440 - don't save failed open RPC for replay
426 test_mkdir -p $DIR/$tdir
427 ln -s foo $DIR/$tdir/$tfile
428 cat $DIR/$tdir/$tfile && error "opened non-existent symlink" || true
430 run_test 17c "symlinks: open dangling (should return error) ===="
433 test_mkdir -p $DIR/$tdir
434 ln -s foo $DIR/$tdir/$tfile
435 touch $DIR/$tdir/$tfile || error "creating to new symlink"
437 run_test 17d "symlinks: create dangling ========================"
440 test_mkdir -p $DIR/$tdir
441 local foo=$DIR/$tdir/$tfile
442 ln -s $foo $foo || error "create symlink failed"
443 ls -l $foo || error "ls -l failed"
444 ls $foo && error "ls not failed" || true
446 run_test 17e "symlinks: create recursive symlink (should return error) ===="
449 test_mkdir -p $DIR/d17f
450 ln -s 1234567890/2234567890/3234567890/4234567890 $DIR/d17f/111
451 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890 $DIR/d17f/222
452 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890 $DIR/d17f/333
453 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890/9234567890/a234567890/b234567890 $DIR/d17f/444
454 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890/9234567890/a234567890/b234567890/c234567890/d234567890/f234567890 $DIR/d17f/555
455 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890/9234567890/a234567890/b234567890/c234567890/d234567890/f234567890/aaaaaaaaaa/bbbbbbbbbb/cccccccccc/dddddddddd/eeeeeeeeee/ffffffffff/ $DIR/d17f/666
458 run_test 17f "symlinks: long and very long symlink name ========================"
460 # str_repeat(S, N) generate a string that is string S repeated N times
465 while [ $((n -= 1)) -ge 0 ]; do
471 # Long symlinks and LU-2241
473 test_mkdir -p $DIR/$tdir
474 local TESTS="59 60 61 4094 4095"
476 # Fix for inode size boundary in 2.1.4
477 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.1.4) ] &&
480 # Patch not applied to 2.2 or 2.3 branches
481 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] &&
482 [ $(lustre_version_code $SINGLEMDS) -le $(version_code 2.3.55) ] &&
485 # skip long symlink name for rhel6.5.
486 # rhel6.5 has a limit (PATH_MAX - sizeof(struct filename))
487 grep -q '6.5' /etc/redhat-release && TESTS="59 60 61 4062 4063"
490 local SYMNAME=$(str_repeat 'x' $i)
491 ln -s $SYMNAME $DIR/$tdir/f$i || error "failed $i-char symlink"
492 readlink $DIR/$tdir/f$i || error "failed $i-char readlink"
495 run_test 17g "symlinks: really long symlink name and inode boundaries"
497 test_17h() { #bug 17378
498 remote_mds_nodsh && skip "remote MDS with nodsh" && return
499 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
501 test_mkdir -p $DIR/$tdir
502 if [ $MDSCOUNT -gt 1 ]; then
503 mdt_idx=$($LFS getdirstripe -i $DIR/$tdir)
507 $SETSTRIPE -c -1 $DIR/$tdir
508 #define OBD_FAIL_MDS_LOV_PREP_CREATE 0x141
509 do_facet mds$((mdt_idx + 1)) lctl set_param fail_loc=0x80000141
510 touch $DIR/$tdir/$tfile || true
512 run_test 17h "create objects: lov_free_memmd() doesn't lbug"
514 test_17i() { #bug 20018
515 remote_mds_nodsh && skip "remote MDS with nodsh" && return
516 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
517 test_mkdir -p $DIR/$tdir
518 local foo=$DIR/$tdir/$tfile
520 if [ $MDSCOUNT -gt 1 ]; then
521 mdt_idx=$($LFS getdirstripe -i $DIR/$tdir)
525 ln -s $foo $foo || error "create symlink failed"
526 #define OBD_FAIL_MDS_READLINK_EPROTO 0x143
527 do_facet mds$((mdt_idx + 1)) lctl set_param fail_loc=0x80000143
528 ls -l $foo && error "error not detected"
531 run_test 17i "don't panic on short symlink"
533 test_17k() { #bug 22301
534 rsync --help | grep -q xattr ||
535 skip_env "$(rsync --version | head -n1) does not support xattrs"
536 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return 0
537 test_mkdir -p $DIR/$tdir
538 test_mkdir -p $DIR/$tdir.new
539 touch $DIR/$tdir/$tfile
540 ln -s $DIR/$tdir/$tfile $DIR/$tdir/$tfile.lnk
541 rsync -av -X $DIR/$tdir/ $DIR/$tdir.new ||
542 error "rsync failed with xattrs enabled"
544 run_test 17k "symlinks: rsync with xattrs enabled ========================="
546 test_17l() { # LU-279
548 touch $DIR/$tdir/$tfile
549 ln -s $DIR/$tdir/$tfile $DIR/$tdir/$tfile.lnk
550 for path in "$DIR/$tdir" "$DIR/$tdir/$tfile" "$DIR/$tdir/$tfile.lnk"; do
551 # -h to not follow symlinks. -m '' to list all the xattrs.
552 # grep to remove first line: '# file: $path'.
553 for xattr in `getfattr -hm '' $path 2>/dev/null | grep -v '^#'`;
555 lgetxattr_size_check $path $xattr ||
556 error "lgetxattr_size_check $path $xattr failed"
560 run_test 17l "Ensure lgetxattr's returned xattr size is consistent ========"
564 local short_sym="0123456789"
565 local WDIR=$DIR/${tdir}m
572 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] &&
573 [ $(lustre_version_code $SINGLEMDS) -le $(version_code 2.2.93) ] &&
574 skip "MDS 2.2.0-2.2.93 do not NUL-terminate symlinks" && return
576 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
577 skip "only for ldiskfs MDT" && return 0
579 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
583 # create a long symlink file
584 for ((i = 0; i < 4; ++i)); do
585 long_sym=${long_sym}${long_sym}
588 echo "create 512 short and long symlink files under $WDIR"
589 for ((i = 0; i < 256; ++i)); do
590 ln -sf ${long_sym}"a5a5" $WDIR/long-$i
591 ln -sf ${short_sym}"a5a5" $WDIR/short-$i
597 wait_delete_completed
599 echo "recreate the 512 symlink files with a shorter string"
600 for ((i = 0; i < 512; ++i)); do
601 # rewrite the symlink file with a shorter string
602 ln -sf ${long_sym} $WDIR/long-$i
603 ln -sf ${short_sym} $WDIR/short-$i
606 mds_index=$($LFS getstripe -M $WDIR)
607 mds_index=$((mds_index+1))
608 devname=$(mdsdevname $mds_index)
609 cmd="$E2FSCK -fnvd $devname"
611 echo "stop and checking mds${mds_index}: $cmd"
612 # e2fsck should not return error
614 do_facet mds${mds_index} $cmd || rc=$?
616 start mds${mds_index} $devname $MDS_MOUNT_OPTS
617 df $MOUNT > /dev/null 2>&1
618 [ $rc -ne 0 ] && error "e2fsck should not report error upon "\
619 "short/long symlink MDT: rc=$rc"
622 run_test 17m "run e2fsck against MDT which contains short/long symlink"
624 check_fs_consistency_17n() {
630 # create/unlink in 17n only change 2 MDTs(MDT1/MDT2),
631 # so it only check MDT1/MDT2 instead of all of MDTs.
632 for mdt_index in $(seq 1 2); do
633 devname=$(mdsdevname $mdt_index)
634 cmd="$E2FSCK -fnvd $devname"
636 echo "stop and checking mds${mdt_index}: $cmd"
637 # e2fsck should not return error
639 do_facet mds${mdt_index} $cmd || rc=$?
641 start mds${mdt_index} $devname $MDS_MOUNT_OPTS
642 df $MOUNT > /dev/null 2>&1
643 [ $rc -ne 0 ] && break
651 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] &&
652 [ $(lustre_version_code $SINGLEMDS) -le $(version_code 2.2.93) ] &&
653 skip "MDS 2.2.0-2.2.93 do not NUL-terminate symlinks" && return
655 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
656 skip "only for ldiskfs MDT" && return 0
658 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
660 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
663 for ((i=0; i<10; i++)); do
664 $LFS mkdir -i 1 $DIR/$tdir/remote_dir_${i} ||
665 error "create remote dir error $i"
666 createmany -o $DIR/$tdir/remote_dir_${i}/f 10 ||
667 error "create files under remote dir failed $i"
670 check_fs_consistency_17n ||
671 error "e2fsck report error after create files under remote dir"
673 for ((i=0;i<10;i++)); do
674 rm -rf $DIR/$tdir/remote_dir_${i} ||
675 error "destroy remote dir error $i"
678 check_fs_consistency_17n ||
679 error "e2fsck report error after unlink files under remote dir"
681 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.50) ] &&
682 skip "lustre < 2.4.50 does not support migrate mv " && return
684 for ((i=0; i<10; i++)); do
685 mkdir -p $DIR/$tdir/remote_dir_${i}
686 createmany -o $DIR/$tdir/remote_dir_${i}/f 10 ||
687 error "create files under remote dir failed $i"
688 $LFS mv -M 1 $DIR/$tdir/remote_dir_${i} ||
689 error "migrate remote dir error $i"
691 check_fs_consistency_17n || error "e2fsck report error after migration"
693 for ((i=0;i<10;i++)); do
694 rm -rf $DIR/$tdir/remote_dir_${i} ||
695 error "destroy remote dir error $i"
698 check_fs_consistency_17n || error "e2fsck report error after unlink"
700 run_test 17n "run e2fsck against master/slave MDT which contains remote dir"
703 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.3.64) ]] &&
704 skip "Need MDS version at least 2.3.64" && return
706 local WDIR=$DIR/${tdir}o
712 mdt_index=$($LFS getstripe -M $WDIR)
713 mdt_index=$((mdt_index+1))
714 mdtdevname=$(mdsdevname $mdt_index)
718 start mds${mdt_index} $mdtdevname $MDS_MOUNT_OPTS
720 #define OBD_FAIL_OSD_LMA_INCOMPAT 0x194
721 do_facet mds${mdt_index} lctl set_param fail_loc=0x194
722 ls -l $WDIR/$tfile && rc=1
723 do_facet mds${mdt_index} lctl set_param fail_loc=0
724 [[ $rc -ne 0 ]] && error "stat file should fail"
727 run_test 17o "stat file with incompat LMA feature"
730 touch $DIR/f || error "Failed to touch $DIR/f: $?"
731 ls $DIR || error "Failed to ls $DIR: $?"
733 run_test 18 "touch .../f ; ls ... =============================="
739 $CHECKSTAT -a $DIR/$tfile || error "$tfile was not removed"
741 run_test 19a "touch .../f19 ; ls -l ... ; rm .../f19 ==========="
744 ls -l $DIR/$tfile && error "ls -l $tfile failed"|| true
746 run_test 19b "ls -l .../f19 (should return error) =============="
749 [ $RUNAS_ID -eq $UID ] &&
750 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
751 $RUNAS touch $DIR/$tfile && error "create non-root file failed" || true
753 run_test 19c "$RUNAS touch .../f19 (should return error) =="
756 cat $DIR/f19 && error || true
758 run_test 19d "cat .../f19 (should return error) =============="
770 $CHECKSTAT -a $DIR/$tfile || error "$tfile was not removed"
772 run_test 20 "touch .../f ; ls -l ... ==========================="
775 test_mkdir -p $DIR/$tdir
776 [ -f $DIR/$tdir/dangle ] && rm -f $DIR/$tdir/dangle
777 ln -s dangle $DIR/$tdir/link
778 echo foo >> $DIR/$tdir/link
779 cat $DIR/$tdir/dangle
780 $CHECKSTAT -t link $DIR/$tdir/link || error "$tdir/link not a link"
781 $CHECKSTAT -f -t file $DIR/$tdir/link ||
782 error "$tdir/link not linked to a file"
784 run_test 21 "write to dangling link ============================"
788 test_mkdir -p $DIR/$tdir
789 chown $RUNAS_ID:$RUNAS_GID $WDIR
790 (cd $WDIR || error "cd $WDIR failed";
791 $RUNAS tar cf - /etc/hosts /etc/sysconfig/network | \
793 ls -lR $WDIR/etc || error "ls -lR $WDIR/etc failed"
794 $CHECKSTAT -t dir $WDIR/etc || error "checkstat -t dir failed"
795 $CHECKSTAT -u \#$RUNAS_ID -g \#$RUNAS_GID $WDIR/etc || error "checkstat -u failed"
797 run_test 22 "unpack tar archive as non-root user ==============="
801 test_mkdir -p $DIR/$tdir
802 local file=$DIR/$tdir/$tfile
804 openfile -f O_CREAT:O_EXCL $file || error "$file create failed"
805 openfile -f O_CREAT:O_EXCL $file &&
806 error "$file recreate succeeded" || true
808 run_test 23a "O_CREAT|O_EXCL in subdir =========================="
810 test_23b() { # bug 18988
811 test_mkdir -p $DIR/$tdir
812 local file=$DIR/$tdir/$tfile
815 echo foo > $file || error "write filed"
816 echo bar >> $file || error "append filed"
817 $CHECKSTAT -s 8 $file || error "wrong size"
820 run_test 23b "O_APPEND check =========================="
824 echo '-- same directory rename'
825 test_mkdir $DIR/$tdir
826 touch $DIR/$tdir/$tfile.1
827 mv $DIR/$tdir/$tfile.1 $DIR/$tdir/$tfile.2
828 $CHECKSTAT -t file $DIR/$tdir/$tfile.2 || error "$tfile.2 not a file"
830 run_test 24a "rename file to non-existent target"
833 test_mkdir $DIR/$tdir
834 touch $DIR/$tdir/$tfile.{1,2}
835 mv $DIR/$tdir/$tfile.1 $DIR/$tdir/$tfile.2
836 $CHECKSTAT -a $DIR/$tdir/$tfile.1 || error "$tfile.1 exists"
837 $CHECKSTAT -t file $DIR/$tdir/$tfile.2 || error "$tfile.2 not a file"
839 run_test 24b "rename file to existing target"
842 test_mkdir $DIR/$tdir
843 test_mkdir $DIR/$tdir/d$testnum.1
844 mv $DIR/$tdir/d$testnum.1 $DIR/$tdir/d$testnum.2
845 $CHECKSTAT -a $DIR/$tdir/d$testnum.1 || error "d$testnum.1 exists"
846 $CHECKSTAT -t dir $DIR/$tdir/d$testnum.2 || error "d$testnum.2 not dir"
848 run_test 24c "rename directory to non-existent target"
851 test_mkdir -c1 $DIR/$tdir
852 test_mkdir -c1 $DIR/$tdir/d$testnum.1
853 test_mkdir -c1 $DIR/$tdir/d$testnum.2
854 mrename $DIR/$tdir/d$testnum.1 $DIR/$tdir/d$testnum.2
855 $CHECKSTAT -a $DIR/$tdir/d$testnum.1 || error "d$testnum.1 exists"
856 $CHECKSTAT -t dir $DIR/$tdir/d$testnum.2 || error "d$testnum.2 not dir"
858 run_test 24d "rename directory to existing target"
861 echo '-- cross directory renames --'
865 mv $DIR/R5a/f $DIR/R5b/g
866 $CHECKSTAT -a $DIR/R5a/f || error
867 $CHECKSTAT -t file $DIR/R5b/g || error
869 run_test 24e "touch .../R5a/f; rename .../R5a/f .../R5b/g ======"
874 touch $DIR/R6a/f $DIR/R6b/g
875 mv $DIR/R6a/f $DIR/R6b/g
876 $CHECKSTAT -a $DIR/R6a/f || error
877 $CHECKSTAT -t file $DIR/R6b/g || error
879 run_test 24f "touch .../R6a/f R6b/g; mv .../R6a/f .../R6b/g ===="
884 test_mkdir $DIR/R7a/d
885 mv $DIR/R7a/d $DIR/R7b/e
886 $CHECKSTAT -a $DIR/R7a/d || error
887 $CHECKSTAT -t dir $DIR/R7b/e || error
889 run_test 24g "mkdir .../R7{a,b}/d; mv .../R7a/d .../R7b/e ======"
892 test_mkdir -c1 $DIR/R8a
893 test_mkdir -c1 $DIR/R8b
894 test_mkdir -c1 $DIR/R8a/d
895 test_mkdir -c1 $DIR/R8b/e
896 mrename $DIR/R8a/d $DIR/R8b/e
897 $CHECKSTAT -a $DIR/R8a/d || error
898 $CHECKSTAT -t dir $DIR/R8b/e || error
900 run_test 24h "mkdir .../R8{a,b}/{d,e}; rename .../R8a/d .../R8b/e"
903 echo "-- rename error cases"
907 mrename $DIR/R9/f $DIR/R9/a
908 $CHECKSTAT -t file $DIR/R9/f || error
909 $CHECKSTAT -t dir $DIR/R9/a || error
910 $CHECKSTAT -a $DIR/R9/a/f || error
912 run_test 24i "rename file to dir error: touch f ; mkdir a ; rename f a"
916 mrename $DIR/R10/f $DIR/R10/g
917 $CHECKSTAT -t dir $DIR/R10 || error
918 $CHECKSTAT -a $DIR/R10/f || error
919 $CHECKSTAT -a $DIR/R10/g || error
921 run_test 24j "source does not exist ============================"
925 test_mkdir $DIR/R11a/d
927 mv $DIR/R11a/f $DIR/R11a/d
928 $CHECKSTAT -a $DIR/R11a/f || error
929 $CHECKSTAT -t file $DIR/R11a/d/f || error
931 run_test 24k "touch .../R11a/f; mv .../R11a/f .../R11a/d ======="
933 # bug 2429 - rename foo foo foo creates invalid file
936 $MULTIOP $f OcNs || error
938 run_test 24l "Renaming a file to itself ========================"
942 $MULTIOP $f OcLN ${f}2 ${f}2 || error "link ${f}2 ${f}2 failed"
943 # on ext3 this does not remove either the source or target files
944 # though the "expected" operation would be to remove the source
945 $CHECKSTAT -t file ${f} || error "${f} missing"
946 $CHECKSTAT -t file ${f}2 || error "${f}2 missing"
948 run_test 24m "Renaming a file to a hard link to itself ========="
952 # this stats the old file after it was renamed, so it should fail
956 $CHECKSTAT ${f}.rename
959 run_test 24n "Statting the old file after renaming (Posix rename 2)"
962 check_kernel_version 37 || return 0
963 test_mkdir -p $DIR/d24o
964 rename_many -s random -v -n 10 $DIR/d24o
966 run_test 24o "rename of files during htree split ==============="
971 DIRINO=`ls -lid $DIR/R12a | awk '{ print $1 }'`
972 mrename $DIR/R12a $DIR/R12b
973 $CHECKSTAT -a $DIR/R12a || error
974 $CHECKSTAT -t dir $DIR/R12b || error
975 DIRINO2=`ls -lid $DIR/R12b | awk '{ print $1 }'`
976 [ "$DIRINO" = "$DIRINO2" ] || error "R12a $DIRINO != R12b $DIRINO2"
978 run_test 24p "mkdir .../R12{a,b}; rename .../R12a .../R12b"
980 cleanup_multiop_pause() {
986 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
989 local DIRINO=$(ls -lid $DIR/R13a | awk '{ print $1 }')
990 multiop_bg_pause $DIR/R13b D_c || error "multiop failed to start"
993 trap cleanup_multiop_pause EXIT
994 mrename $DIR/R13a $DIR/R13b
995 $CHECKSTAT -a $DIR/R13a || error "R13a still exists"
996 $CHECKSTAT -t dir $DIR/R13b || error "R13b does not exist"
997 local DIRINO2=$(ls -lid $DIR/R13b | awk '{ print $1 }')
998 [ "$DIRINO" = "$DIRINO2" ] || error "R13a $DIRINO != R13b $DIRINO2"
999 cleanup_multiop_pause
1000 wait $MULTIPID || error "multiop close failed"
1002 run_test 24q "mkdir .../R13{a,b}; open R13b rename R13a R13b ==="
1004 test_24r() { #bug 3789
1005 test_mkdir $DIR/R14a
1006 test_mkdir $DIR/R14a/b
1007 mrename $DIR/R14a $DIR/R14a/b && error "rename to subdir worked!"
1008 $CHECKSTAT -t dir $DIR/R14a || error "$DIR/R14a missing"
1009 $CHECKSTAT -t dir $DIR/R14a/b || error "$DIR/R14a/b missing"
1011 run_test 24r "mkdir .../R14a/b; rename .../R14a .../R14a/b ====="
1014 test_mkdir $DIR/R15a
1015 test_mkdir $DIR/R15a/b
1016 test_mkdir $DIR/R15a/b/c
1017 mrename $DIR/R15a $DIR/R15a/b/c && error "rename to sub-subdir worked!"
1018 $CHECKSTAT -t dir $DIR/R15a || error "$DIR/R15a missing"
1019 $CHECKSTAT -t dir $DIR/R15a/b/c || error "$DIR/R15a/b/c missing"
1021 run_test 24s "mkdir .../R15a/b/c; rename .../R15a .../R15a/b/c ="
1023 test_mkdir $DIR/R16a
1024 test_mkdir $DIR/R16a/b
1025 test_mkdir $DIR/R16a/b/c
1026 mrename $DIR/R16a/b/c $DIR/R16a && error "rename to sub-subdir worked!"
1027 $CHECKSTAT -t dir $DIR/R16a || error "$DIR/R16a missing"
1028 $CHECKSTAT -t dir $DIR/R16a/b/c || error "$DIR/R16a/b/c missing"
1030 run_test 24t "mkdir .../R16a/b/c; rename .../R16a/b/c .../R16a ="
1032 test_24u() { # bug12192
1034 $MULTIOP $DIR/$tfile C2w$((2048 * 1024))c || error
1035 $CHECKSTAT -s $((2048 * 1024)) $DIR/$tfile || error "wrong file size"
1037 run_test 24u "create stripe file"
1043 simple_cleanup_common() {
1046 wait_delete_completed
1049 max_pages_per_rpc() {
1050 $LCTL get_param -n mdc.*.max_pages_per_rpc | head -n1
1054 local NRFILES=100000
1055 local FREE_INODES=$(mdt_free_inodes 0)
1056 [ $FREE_INODES -lt $NRFILES ] && \
1057 skip "not enough free inodes $FREE_INODES required $NRFILES" &&
1060 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1061 trap simple_cleanup_common EXIT
1063 # Performance issue on ZFS see LU-4072 (c.f. LU-2887)
1064 [ $(facet_fstype $SINGLEMDS) = "zfs" ] && NRFILES=10000
1067 createmany -m $DIR/$tdir/$tfile $NRFILES
1069 cancel_lru_locks mdc
1070 lctl set_param mdc.*.stats clear
1072 ls $DIR/$tdir >/dev/null || error "error in listing large dir"
1074 # LU-5 large readdir
1075 # DIRENT_SIZE = 32 bytes for sizeof(struct lu_dirent) +
1076 # 8 bytes for name(filename is mostly 5 in this test) +
1077 # 8 bytes for luda_type
1078 # take into account of overhead in lu_dirpage header and end mark in
1079 # each page, plus one in RPC_NUM calculation.
1081 RPC_SIZE=$(($(max_pages_per_rpc) * $(page_size)))
1082 RPC_NUM=$(((NRFILES * DIRENT_SIZE + RPC_SIZE - 1) / RPC_SIZE + 1))
1083 mds_readpage=$(lctl get_param mdc.*MDT0000*.stats | \
1084 awk '/^mds_readpage/ {print $2}')
1085 [ $mds_readpage -gt $RPC_NUM ] && \
1086 error "large readdir doesn't take effect"
1088 simple_cleanup_common
1090 run_test 24v "list directory with large files (handle hash collision, bug: 17560)"
1092 test_24w() { # bug21506
1094 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=4096 || return 1
1095 dd if=/dev/zero bs=$SZ1 count=1 >> $DIR/$tfile || return 2
1096 dd if=$DIR/$tfile of=$DIR/${tfile}_left bs=1M skip=4097 || return 3
1097 SZ2=`ls -l $DIR/${tfile}_left | awk '{print $5}'`
1098 [ "$SZ1" = "$SZ2" ] || \
1099 error "Error reading at the end of the file $tfile"
1101 run_test 24w "Reading a file larger than 4Gb"
1104 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
1105 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1107 local remote_dir=$DIR/$tdir/remote_dir
1110 $LFS mkdir -i $MDTIDX $remote_dir ||
1111 error "create remote directory failed"
1113 mkdir -p $DIR/$tdir/src_dir
1114 touch $DIR/$tdir/src_file
1115 mkdir -p $remote_dir/tgt_dir
1116 touch $remote_dir/tgt_file
1118 mrename $remote_dir $DIR/ &&
1119 error "rename dir cross MDT works!"
1121 mrename $DIR/$tdir/src_dir $remote_dir/tgt_dir &&
1122 error "rename dir cross MDT works!"
1124 mrename $DIR/$tdir/src_file $remote_dir/tgt_file &&
1125 error "rename file cross MDT works!"
1127 ln $DIR/$tdir/src_file $remote_dir/tgt_file1 &&
1128 error "ln file cross MDT should not work!"
1130 rm -rf $DIR/$tdir || error "Can not delete directories"
1132 run_test 24x "cross rename/link should be failed"
1135 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
1136 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1138 local remote_dir=$DIR/$tdir/remote_dir
1141 $LFS mkdir -i $MDTIDX $remote_dir ||
1142 error "create remote directory failed"
1144 mkdir -p $remote_dir/src_dir
1145 touch $remote_dir/src_file
1146 mkdir -p $remote_dir/tgt_dir
1147 touch $remote_dir/tgt_file
1149 mrename $remote_dir/src_dir $remote_dir/tgt_dir ||
1150 error "rename subdir in the same remote dir failed!"
1152 mrename $remote_dir/src_file $remote_dir/tgt_file ||
1153 error "rename files in the same remote dir failed!"
1155 ln $remote_dir/tgt_file $remote_dir/tgt_file1 ||
1156 error "link files in the same remote dir failed!"
1158 rm -rf $DIR/$tdir || error "Can not delete directories"
1160 run_test 24y "rename/link on the same dir should succeed"
1163 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
1164 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1166 local remote_src=$DIR/$tdir/remote_dir
1167 local remote_tgt=$DIR/$tdir/remote_tgt
1170 $LFS mkdir -i $MDTIDX $remote_src ||
1171 error "create remote directory failed"
1173 $LFS mkdir -i $MDTIDX $remote_tgt ||
1174 error "create remote directory failed"
1176 mrename $remote_src $remote_tgt &&
1177 error "rename remote dirs should not work!"
1179 # If target dir does not exists, it should succeed
1181 mrename $remote_src $remote_tgt ||
1182 error "rename remote dirs(tgt dir does not exists) failed!"
1184 rm -rf $DIR/$tdir || error "Can not delete directories"
1186 run_test 24z "rename one remote dir to another remote dir should fail"
1188 test_24A() { # LU-3182
1193 createmany -m $DIR/$tdir/$tfile $NFILES
1194 local t=`ls $DIR/$tdir | wc -l`
1195 local u=`ls $DIR/$tdir | sort -u | wc -l`
1196 if [ $t -ne $NFILES -o $u -ne $NFILES ] ; then
1197 error "Expected $NFILES files, got $t ($u unique)"
1200 rm -rf $DIR/$tdir || error "Can not delete directories"
1202 run_test 24A "readdir() returns correct number of entries."
1205 echo '== symlink sanity ============================================='
1209 touch $DIR/s25/foo || error
1211 run_test 25a "create file in symlinked directory ==============="
1214 [ ! -d $DIR/d25 ] && test_25a
1215 $CHECKSTAT -t file $DIR/s25/foo || error
1217 run_test 25b "lookup file in symlinked directory ==============="
1221 test_mkdir $DIR/d26/d26-2
1222 ln -s d26/d26-2 $DIR/s26
1223 touch $DIR/s26/foo || error
1225 run_test 26a "multiple component symlink ======================="
1228 test_mkdir -p $DIR/d26b/d26-2
1229 ln -s d26b/d26-2/foo $DIR/s26-2
1230 touch $DIR/s26-2 || error
1232 run_test 26b "multiple component symlink at end of lookup ======"
1235 test_mkdir $DIR/d26.2
1236 touch $DIR/d26.2/foo
1237 ln -s d26.2 $DIR/s26.2-1
1238 ln -s s26.2-1 $DIR/s26.2-2
1239 ln -s s26.2-2 $DIR/s26.2-3
1240 chmod 0666 $DIR/s26.2-3/foo
1242 run_test 26c "chain of symlinks ================================"
1244 # recursive symlinks (bug 439)
1246 ln -s d26-3/foo $DIR/d26-3
1248 run_test 26d "create multiple component recursive symlink ======"
1251 [ ! -h $DIR/d26-3 ] && test_26d
1254 run_test 26e "unlink multiple component recursive symlink ======"
1256 # recursive symlinks (bug 7022)
1258 test_mkdir -p $DIR/$tdir
1259 test_mkdir $DIR/$tdir/$tfile || error "mkdir $DIR/$tdir/$tfile failed"
1260 cd $DIR/$tdir/$tfile || error "cd $DIR/$tdir/$tfile failed"
1261 test_mkdir -p lndir/bar1 || error "mkdir lndir/bar1 failed"
1262 test_mkdir $DIR/$tdir/$tfile/$tfile || error "mkdir $tfile failed"
1263 cd $tfile || error "cd $tfile failed"
1264 ln -s .. dotdot || error "ln dotdot failed"
1265 ln -s dotdot/lndir lndir || error "ln lndir failed"
1266 cd $DIR/$tdir || error "cd $DIR/$tdir failed"
1267 output=`ls $tfile/$tfile/lndir/bar1`
1268 [ "$output" = bar1 ] && error "unexpected output"
1269 rm -r $tfile || error "rm $tfile failed"
1270 $CHECKSTAT -a $DIR/$tfile || error "$tfile not gone"
1272 run_test 26f "rm -r of a directory which has recursive symlink ="
1275 echo '== stripe sanity =============================================='
1276 test_mkdir -p $DIR/d27 || error "mkdir failed"
1278 $SETSTRIPE -c 1 $DIR/d27/f0 || error "setstripe failed"
1279 $CHECKSTAT -t file $DIR/d27/f0 || error "checkstat failed"
1281 log "== test_27a: write to one stripe file ========================="
1282 cp /etc/hosts $DIR/d27/f0 || error
1284 run_test 27a "one stripe file =================================="
1287 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping 2-stripe test" && return
1288 test_mkdir -p $DIR/d27
1289 $SETSTRIPE -c 2 $DIR/d27/f01 || error "setstripe failed"
1290 $GETSTRIPE -c $DIR/d27/f01
1291 [ $($GETSTRIPE -c $DIR/d27/f01) -eq 2 ] ||
1292 error "two-stripe file doesn't have two stripes"
1294 dd if=/dev/zero of=$DIR/d27/f01 bs=4k count=4 || error "dd failed"
1296 run_test 27b "create and write to two stripe file"
1299 test_mkdir -p $DIR/d27
1300 $SETSTRIPE -c 0 -i -1 -S 0 $DIR/d27/fdef || error "setstripe failed"
1301 $CHECKSTAT -t file $DIR/d27/fdef || error "checkstat failed"
1302 dd if=/dev/zero of=$DIR/d27/fdef bs=4k count=4 || error
1304 run_test 27d "create file with default settings ================"
1307 test_mkdir -p $DIR/d27
1308 $SETSTRIPE -c 2 $DIR/d27/f12 || error "setstripe failed"
1309 $SETSTRIPE -c 2 $DIR/d27/f12 && error "setstripe succeeded twice"
1310 $CHECKSTAT -t file $DIR/d27/f12 || error "checkstat failed"
1312 run_test 27e "setstripe existing file (should return error) ======"
1315 test_mkdir -p $DIR/d27
1316 $SETSTRIPE -S 100 -i 0 -c 1 $DIR/d27/fbad && error "setstripe failed"
1317 dd if=/dev/zero of=$DIR/d27/fbad bs=4k count=4 || error "dd failed"
1318 $GETSTRIPE $DIR/d27/fbad || error "$GETSTRIPE failed"
1320 run_test 27f "setstripe with bad stripe size (should return error)"
1323 test_mkdir -p $DIR/d27
1324 $MCREATE $DIR/d27/fnone || error "mcreate failed"
1325 $GETSTRIPE $DIR/d27/fnone 2>&1 | grep "no stripe info" ||
1326 error "$DIR/d27/fnone has object"
1328 run_test 27g "$GETSTRIPE with no objects"
1331 touch $DIR/d27/fsome || error "touch failed"
1332 [ $($GETSTRIPE -c $DIR/d27/fsome) -gt 0 ] || error "missing objects"
1334 run_test 27i "$GETSTRIPE with some objects"
1337 test_mkdir -p $DIR/d27
1338 $SETSTRIPE -i $OSTCOUNT $DIR/d27/f27j && error "setstripe failed"||true
1340 run_test 27j "setstripe with bad stripe offset (should return error)"
1342 test_27k() { # bug 2844
1343 test_mkdir -p $DIR/d27
1345 LL_MAX_BLKSIZE=$((4 * 1024 * 1024))
1346 [ ! -d $DIR/d27 ] && test_mkdir -p $DIR d27
1347 $SETSTRIPE -S 67108864 $FILE || error "setstripe failed"
1348 BLKSIZE=`stat $FILE | awk '/IO Block:/ { print $7 }'`
1349 [ $BLKSIZE -le $LL_MAX_BLKSIZE ] || error "1:$BLKSIZE > $LL_MAX_BLKSIZE"
1350 dd if=/dev/zero of=$FILE bs=4k count=1
1351 BLKSIZE=`stat $FILE | awk '/IO Block:/ { print $7 }'`
1352 [ $BLKSIZE -le $LL_MAX_BLKSIZE ] || error "2:$BLKSIZE > $LL_MAX_BLKSIZE"
1354 run_test 27k "limit i_blksize for broken user apps ============="
1357 test_mkdir -p $DIR/d27
1358 mcreate $DIR/f27l || error "creating file"
1359 $RUNAS $SETSTRIPE -c 1 $DIR/f27l && \
1360 error "setstripe should have failed" || true
1362 run_test 27l "check setstripe permissions (should return error)"
1365 [ "$OSTCOUNT" -lt "2" ] && skip_env "$OSTCOUNT < 2 OSTs -- skipping" &&
1367 if [ $ORIGFREE -gt $MAXFREE ]; then
1368 skip "$ORIGFREE > $MAXFREE skipping out-of-space test on OST0"
1371 trap simple_cleanup_common EXIT
1372 test_mkdir -p $DIR/$tdir
1373 $SETSTRIPE -i 0 -c 1 $DIR/$tdir/f27m_1
1374 dd if=/dev/zero of=$DIR/$tdir/f27m_1 bs=1024 count=$MAXFREE &&
1375 error "dd should fill OST0"
1377 while $SETSTRIPE -i 0 -c 1 $DIR/$tdir/f27m_$i; do
1379 [ $i -gt 256 ] && break
1382 touch $DIR/$tdir/f27m_$i
1383 [ `$GETSTRIPE $DIR/$tdir/f27m_$i | grep -A 10 obdidx | awk '{print $1}'| grep -w "0"` ] &&
1384 error "OST0 was full but new created file still use it"
1386 touch $DIR/$tdir/f27m_$i
1387 [ `$GETSTRIPE $DIR/$tdir/f27m_$i | grep -A 10 obdidx | awk '{print $1}'| grep -w "0"` ] &&
1388 error "OST0 was full but new created file still use it"
1389 simple_cleanup_common
1391 run_test 27m "create file while OST0 was full =================="
1394 local DELAY=$(do_facet $SINGLEMDS lctl get_param -n lov.*.qos_maxage | head -n 1 | awk '{print $1 * 2}')
1398 # OSCs keep a NOSPC flag that will be reset after ~5s (qos_maxage)
1399 # if the OST isn't full anymore.
1401 local OSTIDX=${1:-""}
1403 local list=$(comma_list $(osts_nodes))
1404 [ "$OSTIDX" ] && list=$(facet_host ost$((OSTIDX + 1)))
1406 do_nodes $list lctl set_param fail_loc=0
1407 sync # initiate all OST_DESTROYs from MDS to OST
1411 exhaust_precreations() {
1414 local FAILIDX=${3:-$OSTIDX}
1416 test_mkdir -p $DIR/$tdir
1417 local MDSIDX=$(get_mds_dir "$DIR/$tdir")
1418 echo OSTIDX=$OSTIDX MDSIDX=$MDSIDX
1420 local OST=$(ostname_from_index $OSTIDX)
1421 local MDT_INDEX=$(lfs df | grep "\[MDT:$((MDSIDX - 1))\]" | awk '{print $1}' | \
1422 sed -e 's/_UUID$//;s/^.*-//')
1425 local mdtosc_proc1=$(get_mdtosc_proc_path mds${MDSIDX} $OST)
1426 local last_id=$(do_facet mds${MDSIDX} lctl get_param -n \
1427 osc.$mdtosc_proc1.prealloc_last_id)
1428 local next_id=$(do_facet mds${MDSIDX} lctl get_param -n \
1429 osc.$mdtosc_proc1.prealloc_next_id)
1431 local mdtosc_proc2=$(get_mdtosc_proc_path mds${MDSIDX})
1432 do_facet mds${MDSIDX} lctl get_param osc.$mdtosc_proc2.prealloc*
1434 test_mkdir -p $DIR/$tdir/${OST}
1435 $SETSTRIPE -i $OSTIDX -c 1 $DIR/$tdir/${OST}
1436 #define OBD_FAIL_OST_ENOSPC 0x215
1437 do_facet ost$((OSTIDX + 1)) lctl set_param fail_val=$FAILIDX
1438 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=0x215
1439 echo "Creating to objid $last_id on ost $OST..."
1440 createmany -o $DIR/$tdir/${OST}/f $next_id $((last_id - next_id + 2))
1441 do_facet mds${MDSIDX} lctl get_param osc.$mdtosc_proc2.prealloc*
1442 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=$FAILLOC
1446 exhaust_all_precreations() {
1448 for (( i=0; i < OSTCOUNT; i++ )) ; do
1449 exhaust_precreations $i $1 -1
1454 [ "$OSTCOUNT" -lt "2" ] && skip_env "too few OSTs" && return
1455 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1456 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1457 remote_ost_nodsh && skip "remote OST with nodsh" && return
1460 rm -f $DIR/$tdir/$tfile
1461 exhaust_precreations 0 0x80000215
1462 $SETSTRIPE -c -1 $DIR/$tdir
1463 touch $DIR/$tdir/$tfile || error
1464 $GETSTRIPE $DIR/$tdir/$tfile
1467 run_test 27n "create file with some full OSTs =================="
1470 [ "$OSTCOUNT" -lt "2" ] && skip_env "too few OSTs" && return
1471 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1472 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1473 remote_ost_nodsh && skip "remote OST with nodsh" && return
1476 rm -f $DIR/$tdir/$tfile
1477 exhaust_all_precreations 0x215
1479 touch $DIR/$tdir/$tfile && error "able to create $DIR/$tdir/$tfile"
1484 run_test 27o "create file with all full OSTs (should error) ===="
1487 [ "$OSTCOUNT" -lt "2" ] && skip_env "too few OSTs" && return
1488 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1489 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1490 remote_ost_nodsh && skip "remote OST with nodsh" && return
1493 rm -f $DIR/$tdir/$tfile
1494 test_mkdir -p $DIR/$tdir
1496 $MCREATE $DIR/$tdir/$tfile || error "mcreate failed"
1497 $TRUNCATE $DIR/$tdir/$tfile 80000000 || error "truncate failed"
1498 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat failed"
1500 exhaust_precreations 0 0x80000215
1501 echo foo >> $DIR/$tdir/$tfile || error "append failed"
1502 $CHECKSTAT -s 80000004 $DIR/$tdir/$tfile || error "checkstat failed"
1503 $GETSTRIPE $DIR/$tdir/$tfile
1507 run_test 27p "append to a truncated file with some full OSTs ==="
1510 [ "$OSTCOUNT" -lt "2" ] && skip_env "too few OSTs" && return
1511 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1512 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1513 remote_ost_nodsh && skip "remote OST with nodsh" && return
1516 rm -f $DIR/$tdir/$tfile
1518 test_mkdir -p $DIR/$tdir
1519 $MCREATE $DIR/$tdir/$tfile || error "mcreate $DIR/$tdir/$tfile failed"
1520 $TRUNCATE $DIR/$tdir/$tfile 80000000 ||error "truncate $DIR/$tdir/$tfile failed"
1521 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat failed"
1523 exhaust_all_precreations 0x215
1525 echo foo >> $DIR/$tdir/$tfile && error "append succeeded"
1526 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat 2 failed"
1530 run_test 27q "append to truncated file with all OSTs full (should error) ==="
1533 [ "$OSTCOUNT" -lt "2" ] && skip_env "too few OSTs" && return
1534 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1535 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1536 remote_ost_nodsh && skip "remote OST with nodsh" && return
1539 rm -f $DIR/$tdir/$tfile
1540 exhaust_precreations 0 0x80000215
1542 $SETSTRIPE -i 0 -c 2 $DIR/$tdir/$tfile # && error
1546 run_test 27r "stripe file with some full OSTs (shouldn't LBUG) ="
1548 test_27s() { # bug 10725
1549 test_mkdir -p $DIR/$tdir
1550 local stripe_size=$((4096 * 1024 * 1024)) # 2^32
1551 local stripe_count=0
1552 [ $OSTCOUNT -eq 1 ] || stripe_count=2
1553 $SETSTRIPE -S $stripe_size -c $stripe_count $DIR/$tdir &&
1554 error "stripe width >= 2^32 succeeded" || true
1557 run_test 27s "lsm_xfersize overflow (should error) (bug 10725)"
1559 test_27t() { # bug 10864
1564 $WLFS getstripe $tfile
1567 run_test 27t "check that utils parse path correctly"
1569 test_27u() { # bug 4900
1570 [ "$OSTCOUNT" -lt "2" ] && skip_env "too few OSTs" && return
1571 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1573 local list=$(comma_list $(mdts_nodes))
1575 #define OBD_FAIL_MDS_OSC_PRECREATE 0x139
1576 do_nodes $list $LCTL set_param fail_loc=0x139
1577 test_mkdir -p $DIR/$tdir
1579 createmany -o $DIR/$tdir/t- 1000
1580 do_nodes $list $LCTL set_param fail_loc=0
1582 TLOG=$DIR/$tfile.getstripe
1583 $GETSTRIPE $DIR/$tdir > $TLOG
1584 OBJS=`awk -vobj=0 '($1 == 0) { obj += 1 } END { print obj;}' $TLOG`
1585 unlinkmany $DIR/$tdir/t- 1000
1586 [ $OBJS -gt 0 ] && \
1587 error "$OBJS objects created on OST-0. See $TLOG" || pass
1589 run_test 27u "skip object creation on OSC w/o objects =========="
1591 test_27v() { # bug 4900
1592 [ "$OSTCOUNT" -lt "2" ] && skip_env "too few OSTs" && return
1593 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1594 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1595 remote_ost_nodsh && skip "remote OST with nodsh" && return
1597 exhaust_all_precreations 0x215
1600 test_mkdir -p $DIR/$tdir
1601 $SETSTRIPE -c 1 $DIR/$tdir # 1 stripe / file
1603 touch $DIR/$tdir/$tfile
1604 #define OBD_FAIL_TGT_DELAY_PRECREATE 0x705
1606 for (( i=1; i < OSTCOUNT; i++ )); do
1607 do_facet ost$i lctl set_param fail_loc=0x705
1609 local START=`date +%s`
1610 createmany -o $DIR/$tdir/$tfile 32
1612 local FINISH=`date +%s`
1613 local TIMEOUT=`lctl get_param -n timeout`
1614 local PROCESS=$((FINISH - START))
1615 [ $PROCESS -ge $((TIMEOUT / 2)) ] && \
1616 error "$FINISH - $START >= $TIMEOUT / 2"
1617 sleep $((TIMEOUT / 2 - PROCESS))
1620 run_test 27v "skip object creation on slow OST ================="
1622 test_27w() { # bug 10997
1623 test_mkdir -p $DIR/$tdir || error "mkdir failed"
1624 $SETSTRIPE -S 65536 $DIR/$tdir/f0 || error "setstripe failed"
1625 [ $($GETSTRIPE -S $DIR/$tdir/f0) -ne 65536 ] &&
1626 error "stripe size $size != 65536" || true
1627 [ $($GETSTRIPE -d $DIR/$tdir | grep -c "stripe_count") -ne 1 ] &&
1628 error "$GETSTRIPE -d $DIR/$tdir failed" || true
1630 run_test 27w "check $SETSTRIPE -S option"
1633 [ "$OSTCOUNT" -lt "2" ] &&
1634 skip_env "skipping multiple stripe count/offset test" && return
1636 test_mkdir -p $DIR/$tdir || error "mkdir failed"
1637 for i in $(seq 1 $OSTCOUNT); do
1639 $SETSTRIPE -c $i -i $offset $DIR/$tdir/f$i ||
1640 error "setstripe -c $i -i $offset failed"
1641 count=$($GETSTRIPE -c $DIR/$tdir/f$i)
1642 index=$($GETSTRIPE -i $DIR/$tdir/f$i)
1643 [ $count -ne $i ] && error "stripe count $count != $i" || true
1644 [ $index -ne $offset ] &&
1645 error "stripe offset $index != $offset" || true
1648 run_test 27wa "check $SETSTRIPE -c -i options"
1651 remote_ost_nodsh && skip "remote OST with nodsh" && return
1652 [ "$OSTCOUNT" -lt "2" ] && skip_env "$OSTCOUNT < 2 OSTs" && return
1653 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1654 OFFSET=$(($OSTCOUNT - 1))
1656 local OST=$(ostname_from_index $OSTIDX)
1658 test_mkdir -p $DIR/$tdir
1659 $SETSTRIPE -c 1 $DIR/$tdir # 1 stripe per file
1660 do_facet ost$((OSTIDX + 1)) lctl set_param -n obdfilter.$OST.degraded 1
1662 createmany -o $DIR/$tdir/$tfile $OSTCOUNT
1663 for i in `seq 0 $OFFSET`; do
1664 [ `$GETSTRIPE $DIR/$tdir/$tfile$i | grep -A 10 obdidx | awk '{print $1}' | grep -w "$OSTIDX"` ] &&
1665 error "OST0 was degraded but new created file still use it"
1667 do_facet ost$((OSTIDX + 1)) lctl set_param -n obdfilter.$OST.degraded 0
1669 run_test 27x "create files while OST0 is degraded"
1672 [ "$OSTCOUNT" -lt "2" ] && skip_env "$OSTCOUNT < 2 OSTs -- skipping" && return
1673 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1674 remote_ost_nodsh && skip "remote OST with nodsh" && return
1675 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1677 local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS $FSNAME-OST0000)
1678 local last_id=$(do_facet $SINGLEMDS lctl get_param -n \
1679 osc.$mdtosc.prealloc_last_id)
1680 local next_id=$(do_facet $SINGLEMDS lctl get_param -n \
1681 osc.$mdtosc.prealloc_next_id)
1682 local fcount=$((last_id - next_id))
1683 [ $fcount -eq 0 ] && skip "not enough space on OST0" && return
1684 [ $fcount -gt $OSTCOUNT ] && fcount=$OSTCOUNT
1686 local MDS_OSCS=$(do_facet $SINGLEMDS lctl dl |
1687 awk '/[oO][sS][cC].*md[ts]/ { print $4 }')
1688 local OST_DEACTIVE_IDX=-1
1693 for OSC in $MDS_OSCS; do
1694 OST=$(osc_to_ost $OSC)
1695 OSTIDX=$(index_from_ostuuid $OST)
1696 if [ $OST_DEACTIVE_IDX == -1 ]; then
1697 OST_DEACTIVE_IDX=$OSTIDX
1699 if [ $OSTIDX != $OST_DEACTIVE_IDX ]; then
1700 echo $OSC "is Deactivated:"
1701 do_facet $SINGLEMDS lctl --device %$OSC deactivate
1705 OSTIDX=$(index_from_ostuuid $OST)
1707 $SETSTRIPE -c 1 $DIR/$tdir # 1 stripe / file
1709 for OSC in $MDS_OSCS; do
1710 OST=$(osc_to_ost $OSC)
1711 OSTIDX=$(index_from_ostuuid $OST)
1712 if [ $OSTIDX == $OST_DEACTIVE_IDX ]; then
1713 echo $OST "is degraded:"
1714 do_facet ost$((OSTIDX+1)) lctl set_param -n \
1715 obdfilter.$OST.degraded=1
1720 createmany -o $DIR/$tdir/$tfile $fcount
1722 for OSC in $MDS_OSCS; do
1723 OST=$(osc_to_ost $OSC)
1724 OSTIDX=$(index_from_ostuuid $OST)
1725 if [ $OSTIDX == $OST_DEACTIVE_IDX ]; then
1726 echo $OST "is recovered from degraded:"
1727 do_facet ost$((OSTIDX+1)) lctl set_param -n \
1728 obdfilter.$OST.degraded=0
1730 do_facet $SINGLEMDS lctl --device %$OSC activate
1734 # all osp devices get activated, hence -1 stripe count restored
1737 # sleep 2*lod_qos_maxage seconds waiting for lod qos to notice osp
1738 # devices get activated.
1740 $SETSTRIPE -c -1 $DIR/$tfile
1741 stripecnt=$($GETSTRIPE -c $DIR/$tfile)
1743 [ $stripecnt -ne $OSTCOUNT ] &&
1744 error "Of $OSTCOUNT OSTs, only $stripecnt is available"
1747 run_test 27y "create files while OST0 is degraded and the rest inactive"
1753 lmm_count=$($GETSTRIPE -c $1)
1754 lmm_seq=$($GETSTRIPE -v $1 | awk '/lmm_seq/ { print $2 }')
1755 lmm_oid=$($GETSTRIPE -v $1 | awk '/lmm_object_id/ { print $2 }')
1757 local old_ifs="$IFS"
1759 fid=($($LFS path2fid $1))
1762 log "FID seq ${fid[1]}, oid ${fid[2]} ver ${fid[3]}"
1763 log "LOV seq $lmm_seq, oid $lmm_oid, count: $lmm_count"
1765 # compare lmm_seq and lu_fid->f_seq
1766 [ $lmm_seq = ${fid[1]} ] || { error "SEQ mismatch"; return 1; }
1767 # compare lmm_object_id and lu_fid->oid
1768 [ $lmm_oid = ${fid[2]} ] || { error "OID mismatch"; return 2; }
1770 # check the trusted.fid attribute of the OST objects of the file
1771 local have_obdidx=false
1773 $GETSTRIPE $1 | while read obdidx oid hex seq; do
1774 # skip lines up to and including "obdidx"
1775 [ -z "$obdidx" ] && break
1776 [ "$obdidx" = "obdidx" ] && have_obdidx=true && continue
1777 $have_obdidx || continue
1779 local ost=$((obdidx + 1))
1780 local dev=$(ostdevname $ost)
1783 log "want: stripe:$stripe_nr ost:$obdidx oid:$oid/$hex seq:$seq"
1785 seq=$(echo $seq | sed -e "s/^0x//g")
1786 if [ $seq == 0 ]; then
1787 oid_hex=$(echo $oid)
1789 oid_hex=$(echo $hex | sed -e "s/^0x//g")
1791 local obj_file="O/$seq/d$((oid %32))/$oid_hex"
1795 # Don't unmount/remount the OSTs if we don't need to do that.
1796 # LU-2577 changes filter_fid to be smaller, so debugfs needs
1797 # update too, until that use mount/ll_decode_filter_fid/mount.
1798 # Re-enable when debugfs will understand new filter_fid.
1800 if false && [ $(facet_fstype ost$ost) == ldiskfs ]; then
1801 ff=$(do_facet ost$ost "$DEBUGFS -c -R 'stat $obj_file' \
1802 $dev 2>/dev/null" | grep "parent=")
1805 mount_fstype ost$ost
1806 ff=$(do_facet ost$ost $LL_DECODE_FILTER_FID \
1807 $(facet_mntpt ost$ost)/$obj_file)
1808 unmount_fstype ost$ost
1809 start ost$ost $dev $OST_MOUNT_OPTS
1812 [ -z "$ff" ] && error "$obj_file: no filter_fid info"
1814 echo "$ff" | sed -e 's#.*objid=#got: objid=#'
1816 # /mnt/O/0/d23/23: objid=23 seq=0 parent=[0x200000400:0x1e:0x1]
1817 # fid: objid=23 seq=0 parent=[0x200000400:0x1e:0x0] stripe=1
1818 local ff_parent=$(echo $ff|sed -e 's/.*parent=.//')
1819 local ff_pseq=$(echo $ff_parent | cut -d: -f1)
1820 local ff_poid=$(echo $ff_parent | cut -d: -f2)
1822 if echo $ff_parent | grep -q 'stripe='; then
1823 ff_pstripe=$(echo $ff_parent | sed -e 's/.*stripe=//')
1826 # $LL_DECODE_FILTER_FID does not print "stripe="; look
1827 # into f_ver in this case. See the comment on
1830 ff_pstripe=$(echo $ff_parent | cut -d: -f3 |
1834 # compare lmm_seq and filter_fid->ff_parent.f_seq
1835 [ $ff_pseq = $lmm_seq ] ||
1836 error "FF parent SEQ $ff_pseq != $lmm_seq"
1837 # compare lmm_object_id and filter_fid->ff_parent.f_oid
1838 [ $ff_poid = $lmm_oid ] ||
1839 error "FF parent OID $ff_poid != $lmm_oid"
1840 (($ff_pstripe == $stripe_nr)) ||
1841 error "FF stripe $ff_pstripe != $stripe_nr"
1843 stripe_nr=$((stripe_nr + 1))
1848 remote_ost_nodsh && skip "remote OST with nodsh" && return
1849 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1850 test_mkdir -p $DIR/$tdir
1852 $SETSTRIPE -c 1 -i 0 -S 64k $DIR/$tdir/$tfile-1 ||
1853 { error "setstripe -c -1 failed"; return 1; }
1854 # We need to send a write to every object to get parent FID info set.
1855 # This _should_ also work for setattr, but does not currently.
1856 # touch $DIR/$tdir/$tfile-1 ||
1857 dd if=/dev/zero of=$DIR/$tdir/$tfile-1 bs=1M count=1 ||
1858 { error "dd $tfile-1 failed"; return 2; }
1859 $SETSTRIPE -c -1 -i $((OSTCOUNT - 1)) -S 1M $DIR/$tdir/$tfile-2 ||
1860 { error "setstripe -c -1 failed"; return 3; }
1861 dd if=/dev/zero of=$DIR/$tdir/$tfile-2 bs=1M count=$OSTCOUNT ||
1862 { error "dd $tfile-2 failed"; return 4; }
1864 # make sure write RPCs have been sent to OSTs
1867 check_seq_oid $DIR/$tdir/$tfile-1 || return 5
1868 check_seq_oid $DIR/$tdir/$tfile-2 || return 6
1870 run_test 27z "check SEQ/OID on the MDT and OST filesystems"
1872 test_27A() { # b=19102
1873 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1874 local restore_size=$($GETSTRIPE -S $MOUNT)
1875 local restore_count=$($GETSTRIPE -c $MOUNT)
1876 local restore_offset=$($GETSTRIPE -i $MOUNT)
1877 $SETSTRIPE -c 0 -i -1 -S 0 $MOUNT
1878 wait_update $HOSTNAME "$GETSTRIPE -c $MOUNT | sed 's/ *//g'" "1" 20 ||
1879 error "stripe count $($GETSTRIPE -c $MOUNT) != 1"
1880 local default_size=$($GETSTRIPE -S $MOUNT)
1881 local default_offset=$($GETSTRIPE -i $MOUNT)
1882 local dsize=$((1024 * 1024))
1883 [ $default_size -eq $dsize ] ||
1884 error "stripe size $default_size != $dsize"
1885 [ $default_offset -eq -1 ] ||error "stripe offset $default_offset != -1"
1886 $SETSTRIPE -c $restore_count -i $restore_offset -S $restore_size $MOUNT
1888 run_test 27A "check filesystem-wide default LOV EA values"
1890 test_27B() { # LU-2523
1891 test_mkdir -p $DIR/$tdir
1892 rm -f $DIR/$tdir/f0 $DIR/$tdir/f1
1894 # open f1 with O_LOV_DELAY_CREATE
1896 # call setstripe ioctl on open file descriptor for f1
1898 multiop $DIR/$tdir/f1 oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:nB1c \
1902 # open f1 with O_LOV_DELAY_CREATE
1904 # call setstripe ioctl on open file descriptor for f1
1906 multiop $DIR/$tdir/f1 oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:uB1c
1908 # Allow multiop to fail in imitation of NFS's busted semantics.
1911 run_test 27B "call setstripe on open unlinked file/rename victim"
1913 test_27C() { #LU-2871
1914 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs" && return
1922 test_mkdir -p $DIR/$tdir
1924 for i in $(seq 0 $((OSTCOUNT - 1))); do
1925 # set stripe across all OSTs starting from OST$i
1926 $SETSTRIPE -i $i -c -1 $tfile$i
1927 # get striping information
1928 ost_idx=($($GETSTRIPE $tfile$i |
1929 tail -n $((OSTCOUNT + 1)) | awk '{print $1}'))
1933 [ ${#ost_idx[@]} -eq $OSTCOUNT ] ||
1934 error "${#ost_idx[@]} != $OSTCOUNT"
1936 for index in $(seq 0 $((OSTCOUNT - 1))); do
1938 for j in $(echo ${ost_idx[@]}); do
1939 if [ $index -eq $j ]; then
1945 error "Can not find $index in ${ost_idx[@]}"
1949 run_test 27C "check full striping across all OSTs"
1951 # createtest also checks that device nodes are created and
1952 # then visible correctly (#2091)
1953 test_28() { # bug 2091
1955 $CREATETEST $DIR/d28/ct || error
1957 run_test 28 "create/mknod/mkdir with bad file types ============"
1960 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1961 cancel_lru_locks mdc
1967 declare -i LOCKCOUNTORIG=0
1968 for lock_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_count); do
1969 let LOCKCOUNTORIG=$LOCKCOUNTORIG+$lock_count
1971 [ $LOCKCOUNTORIG -eq 0 ] && echo "No mdc lock count" && return 1
1973 declare -i LOCKUNUSEDCOUNTORIG=0
1974 for unused_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_unused_count); do
1975 let LOCKUNUSEDCOUNTORIG=$LOCKUNUSEDCOUNTORIG+$unused_count
1982 declare -i LOCKCOUNTCURRENT=0
1983 for lock_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_count); do
1984 let LOCKCOUNTCURRENT=$LOCKCOUNTCURRENT+$lock_count
1987 declare -i LOCKUNUSEDCOUNTCURRENT=0
1988 for unused_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_unused_count); do
1989 let LOCKUNUSEDCOUNTCURRENT=$LOCKUNUSEDCOUNTCURRENT+$unused_count
1992 if [ "$LOCKCOUNTCURRENT" -gt "$LOCKCOUNTORIG" ]; then
1993 lctl set_param -n ldlm.dump_namespaces ""
1994 error "CURRENT: $LOCKCOUNTCURRENT > $LOCKCOUNTORIG"
1995 $LCTL dk | sort -k4 -t: > $TMP/test_29.dk
1996 log "dumped log to $TMP/test_29.dk (bug 5793)"
1999 if [ "$LOCKUNUSEDCOUNTCURRENT" -gt "$LOCKUNUSEDCOUNTORIG" ]; then
2000 error "UNUSED: $LOCKUNUSEDCOUNTCURRENT > $LOCKUNUSEDCOUNTORIG"
2001 $LCTL dk | sort -k4 -t: > $TMP/test_29.dk
2002 log "dumped log to $TMP/test_29.dk (bug 5793)"
2006 run_test 29 "IT_GETATTR regression ============================"
2008 test_30a() { # was test_30
2009 cp `which ls` $DIR || cp /bin/ls $DIR
2013 run_test 30a "execute binary from Lustre (execve) =============="
2016 cp `which ls` $DIR || cp /bin/ls $DIR
2018 $RUNAS $DIR/ls / || error
2021 run_test 30b "execute binary from Lustre as non-root ==========="
2023 test_30c() { # b=22376
2024 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2025 cp `which ls` $DIR || cp /bin/ls $DIR
2027 cancel_lru_locks mdc
2028 cancel_lru_locks osc
2029 $RUNAS $DIR/ls / || error
2032 run_test 30c "execute binary from Lustre without read perms ===="
2035 $OPENUNLINK $DIR/f31 $DIR/f31 || error
2036 $CHECKSTAT -a $DIR/f31 || error
2038 run_test 31a "open-unlink file =================================="
2041 touch $DIR/f31 || error
2042 ln $DIR/f31 $DIR/f31b || error
2043 $MULTIOP $DIR/f31b Ouc || error
2044 $CHECKSTAT -t file $DIR/f31 || error
2046 run_test 31b "unlink file with multiple links while open ======="
2049 touch $DIR/f31 || error
2050 ln $DIR/f31 $DIR/f31c || error
2051 multiop_bg_pause $DIR/f31 O_uc || return 1
2053 $MULTIOP $DIR/f31c Ouc
2054 kill -USR1 $MULTIPID
2057 run_test 31c "open-unlink file with multiple links ============="
2060 opendirunlink $DIR/d31d $DIR/d31d || error
2061 $CHECKSTAT -a $DIR/d31d || error
2063 run_test 31d "remove of open directory ========================="
2065 test_31e() { # bug 2904
2066 check_kernel_version 34 || return 0
2067 openfilleddirunlink $DIR/d31e || error
2069 run_test 31e "remove of open non-empty directory ==============="
2071 test_31f() { # bug 4554
2072 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2074 test_mkdir $DIR/d31f
2075 $SETSTRIPE -S 1048576 -c 1 $DIR/d31f
2076 cp /etc/hosts $DIR/d31f
2078 $GETSTRIPE $DIR/d31f/hosts
2079 multiop_bg_pause $DIR/d31f D_c || return 1
2082 rm -rv $DIR/d31f || error "first of $DIR/d31f"
2083 test_mkdir $DIR/d31f
2084 $SETSTRIPE -S 1048576 -c 1 $DIR/d31f
2085 cp /etc/hosts $DIR/d31f
2087 $GETSTRIPE $DIR/d31f/hosts
2088 multiop_bg_pause $DIR/d31f D_c || return 1
2091 kill -USR1 $MULTIPID || error "first opendir $MULTIPID not running"
2092 wait $MULTIPID || error "first opendir $MULTIPID failed"
2096 kill -USR1 $MULTIPID2 || error "second opendir $MULTIPID not running"
2097 wait $MULTIPID2 || error "second opendir $MULTIPID2 failed"
2100 run_test 31f "remove of open directory with open-unlink file ==="
2103 echo "-- cross directory link --"
2104 test_mkdir -c1 $DIR/${tdir}ga
2105 test_mkdir -c1 $DIR/${tdir}gb
2106 touch $DIR/${tdir}ga/f
2107 ln $DIR/${tdir}ga/f $DIR/${tdir}gb/g
2108 $CHECKSTAT -t file $DIR/${tdir}ga/f || error "source"
2109 [ `stat -c%h $DIR/${tdir}ga/f` == '2' ] || error "source nlink"
2110 $CHECKSTAT -t file $DIR/${tdir}gb/g || error "target"
2111 [ `stat -c%h $DIR/${tdir}gb/g` == '2' ] || error "target nlink"
2113 run_test 31g "cross directory link==============="
2116 echo "-- cross directory link --"
2117 test_mkdir -c1 $DIR/${tdir}
2118 test_mkdir -c1 $DIR/${tdir}/dir
2119 touch $DIR/${tdir}/f
2120 ln $DIR/${tdir}/f $DIR/${tdir}/dir/g
2121 $CHECKSTAT -t file $DIR/${tdir}/f || error "source"
2122 [ `stat -c%h $DIR/${tdir}/f` == '2' ] || error "source nlink"
2123 $CHECKSTAT -t file $DIR/${tdir}/dir/g || error "target"
2124 [ `stat -c%h $DIR/${tdir}/dir/g` == '2' ] || error "target nlink"
2126 run_test 31h "cross directory link under child==============="
2129 echo "-- cross directory link --"
2130 test_mkdir -c1 $DIR/$tdir
2131 test_mkdir -c1 $DIR/$tdir/dir
2132 touch $DIR/$tdir/dir/f
2133 ln $DIR/$tdir/dir/f $DIR/$tdir/g
2134 $CHECKSTAT -t file $DIR/$tdir/dir/f || error "source"
2135 [ `stat -c%h $DIR/$tdir/dir/f` == '2' ] || error "source nlink"
2136 $CHECKSTAT -t file $DIR/$tdir/g || error "target"
2137 [ `stat -c%h $DIR/$tdir/g` == '2' ] || error "target nlink"
2139 run_test 31i "cross directory link under parent==============="
2142 test_mkdir -c1 -p $DIR/$tdir
2143 test_mkdir -c1 -p $DIR/$tdir/dir1
2144 ln $DIR/$tdir/dir1 $DIR/$tdir/dir2 && error "ln for dir"
2145 link $DIR/$tdir/dir1 $DIR/$tdir/dir3 && error "link for dir"
2146 mlink $DIR/$tdir/dir1 $DIR/$tdir/dir4 && error "mlink for dir"
2147 mlink $DIR/$tdir/dir1 $DIR/$tdir/dir1 && error "mlink to the same dir"
2150 run_test 31j "link for directory==============="
2153 test_mkdir -c1 -p $DIR/$tdir
2155 touch $DIR/$tdir/exist
2156 mlink $DIR/$tdir/s $DIR/$tdir/t || error "mlink"
2157 mlink $DIR/$tdir/s $DIR/$tdir/exist && error "mlink to exist file"
2158 mlink $DIR/$tdir/s $DIR/$tdir/s && error "mlink to the same file"
2159 mlink $DIR/$tdir/s $DIR/$tdir && error "mlink to parent dir"
2160 mlink $DIR/$tdir $DIR/$tdir/s && error "mlink parent dir to target"
2161 mlink $DIR/$tdir/not-exist $DIR/$tdir/foo && error "mlink non-existing to new"
2162 mlink $DIR/$tdir/not-exist $DIR/$tdir/s && error "mlink non-existing to exist"
2165 run_test 31k "link to file: the same, non-existing, dir==============="
2171 touch $DIR/d31m2/exist
2172 mlink $DIR/d31m/s $DIR/d31m2/t || error "mlink"
2173 mlink $DIR/d31m/s $DIR/d31m2/exist && error "mlink to exist file"
2174 mlink $DIR/d31m/s $DIR/d31m2 && error "mlink to parent dir"
2175 mlink $DIR/d31m2 $DIR/d31m/s && error "mlink parent dir to target"
2176 mlink $DIR/d31m/not-exist $DIR/d31m2/foo && error "mlink non-existing to new"
2177 mlink $DIR/d31m/not-exist $DIR/d31m2/s && error "mlink non-existing to exist"
2180 run_test 31m "link to file: the same, non-existing, dir==============="
2183 touch $DIR/$tfile || error "cannot create '$DIR/$tfile'"
2184 nlink=$(stat --format=%h $DIR/$tfile)
2185 [ ${nlink:--1} -eq 1 ] || error "nlink is $nlink, expected 1"
2187 local cmd="exec $fd<$DIR/$tfile"
2190 trap "eval $cmd" EXIT
2191 nlink=$(stat --dereference --format=%h /proc/self/fd/$fd)
2192 [ ${nlink:--1} -eq 1 ] || error "nlink is $nlink, expected 1"
2193 rm $DIR/$tfile || error "cannot remove '$DIR/$tfile'"
2194 nlink=$(stat --dereference --format=%h /proc/self/fd/$fd)
2195 [ ${nlink:--1} -eq 0 ] || error "nlink is $nlink, expected 0"
2198 run_test 31n "check link count of unlinked file"
2201 local TEMPNAME=$(mktemp $1_XXXXXX)
2202 mlink $TEMPNAME $1 2> /dev/null &&
2203 echo "$BASHPID: link $TEMPNAME to $1 succeeded"
2207 test_31o() { # LU-2901
2209 for LOOP in $(seq 100); do
2210 rm -f $DIR/$tdir/$tfile*
2211 for THREAD in $(seq 8); do
2212 link_one $DIR/$tdir/$tfile.$LOOP &
2215 local LINKS=$(ls -1 $DIR/$tdir | grep -c $tfile.$LOOP)
2216 [ $LINKS -gt 1 ] && ls $DIR/$tdir &&
2217 error "$LINKS duplicate links to $tfile.$LOOP" &&
2221 run_test 31o "duplicate hard links with same filename"
2223 cleanup_test32_mount() {
2225 $UMOUNT -d $DIR/$tdir/ext2-mountpoint
2229 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2230 echo "== more mountpoints and symlinks ================="
2231 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2232 trap cleanup_test32_mount EXIT
2233 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2234 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2235 $CHECKSTAT -t dir $DIR/$tdir/ext2-mountpoint/.. || error
2236 cleanup_test32_mount
2238 run_test 32a "stat d32a/ext2-mountpoint/.. ====================="
2241 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2242 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2243 trap cleanup_test32_mount EXIT
2244 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2245 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2246 ls -al $DIR/$tdir/ext2-mountpoint/.. || error
2247 cleanup_test32_mount
2249 run_test 32b "open d32b/ext2-mountpoint/.. ====================="
2252 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2253 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2254 trap cleanup_test32_mount EXIT
2255 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2256 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2257 test_mkdir -p $DIR/$tdir/d2/test_dir
2258 $CHECKSTAT -t dir $DIR/$tdir/ext2-mountpoint/../d2/test_dir || error
2259 cleanup_test32_mount
2261 run_test 32c "stat d32c/ext2-mountpoint/../d2/test_dir ========="
2264 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2265 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2266 trap cleanup_test32_mount EXIT
2267 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2268 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2269 test_mkdir -p $DIR/$tdir/d2/test_dir
2270 ls -al $DIR/$tdir/ext2-mountpoint/../d2/test_dir || error
2271 cleanup_test32_mount
2273 run_test 32d "open d32d/ext2-mountpoint/../d2/test_dir ========="
2276 [ -e $DIR/d32e ] && rm -fr $DIR/d32e
2277 test_mkdir -p $DIR/d32e/tmp
2278 TMP_DIR=$DIR/d32e/tmp
2279 ln -s $DIR/d32e $TMP_DIR/symlink11
2280 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
2281 $CHECKSTAT -t link $DIR/d32e/tmp/symlink11 || error
2282 $CHECKSTAT -t link $DIR/d32e/symlink01 || error
2284 run_test 32e "stat d32e/symlink->tmp/symlink->lustre-subdir ===="
2287 [ -e $DIR/d32f ] && rm -fr $DIR/d32f
2288 test_mkdir -p $DIR/d32f/tmp
2289 TMP_DIR=$DIR/d32f/tmp
2290 ln -s $DIR/d32f $TMP_DIR/symlink11
2291 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
2292 ls $DIR/d32f/tmp/symlink11 || error
2293 ls $DIR/d32f/symlink01 || error
2295 run_test 32f "open d32f/symlink->tmp/symlink->lustre-subdir ===="
2298 TMP_DIR=$DIR/$tdir/tmp
2299 test_mkdir -p $DIR/$tdir/tmp
2300 test_mkdir $DIR/${tdir}2
2301 ln -s $DIR/${tdir}2 $TMP_DIR/symlink12
2302 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
2303 $CHECKSTAT -t link $TMP_DIR/symlink12 || error
2304 $CHECKSTAT -t link $DIR/$tdir/symlink02 || error
2305 $CHECKSTAT -t dir -f $TMP_DIR/symlink12 || error
2306 $CHECKSTAT -t dir -f $DIR/$tdir/symlink02 || error
2308 run_test 32g "stat d32g/symlink->tmp/symlink->lustre-subdir/${tdir}2"
2311 rm -fr $DIR/$tdir $DIR/${tdir}2
2312 TMP_DIR=$DIR/$tdir/tmp
2313 test_mkdir -p $DIR/$tdir/tmp
2314 test_mkdir $DIR/${tdir}2
2315 ln -s $DIR/${tdir}2 $TMP_DIR/symlink12
2316 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
2317 ls $TMP_DIR/symlink12 || error
2318 ls $DIR/$tdir/symlink02 || error
2320 run_test 32h "open d32h/symlink->tmp/symlink->lustre-subdir/${tdir}2"
2323 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2324 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2325 trap cleanup_test32_mount EXIT
2326 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2327 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2328 touch $DIR/$tdir/test_file
2329 $CHECKSTAT -t file $DIR/$tdir/ext2-mountpoint/../test_file || error
2330 cleanup_test32_mount
2332 run_test 32i "stat d32i/ext2-mountpoint/../test_file ==========="
2335 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2336 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2337 trap cleanup_test32_mount EXIT
2338 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2339 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2340 touch $DIR/$tdir/test_file
2341 cat $DIR/$tdir/ext2-mountpoint/../test_file || error
2342 cleanup_test32_mount
2344 run_test 32j "open d32j/ext2-mountpoint/../test_file ==========="
2347 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2349 trap cleanup_test32_mount EXIT
2350 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2351 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint
2352 test_mkdir -p $DIR/$tdir/d2
2353 touch $DIR/$tdir/d2/test_file || error
2354 $CHECKSTAT -t file $DIR/$tdir/ext2-mountpoint/../d2/test_file || error
2355 cleanup_test32_mount
2357 run_test 32k "stat d32k/ext2-mountpoint/../d2/test_file ========"
2360 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2362 trap cleanup_test32_mount EXIT
2363 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2364 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2365 test_mkdir -p $DIR/$tdir/d2
2366 touch $DIR/$tdir/d2/test_file
2367 cat $DIR/$tdir/ext2-mountpoint/../d2/test_file || error
2368 cleanup_test32_mount
2370 run_test 32l "open d32l/ext2-mountpoint/../d2/test_file ========"
2374 test_mkdir -p $DIR/d32m/tmp
2375 TMP_DIR=$DIR/d32m/tmp
2376 ln -s $DIR $TMP_DIR/symlink11
2377 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
2378 $CHECKSTAT -t link $DIR/d32m/tmp/symlink11 || error
2379 $CHECKSTAT -t link $DIR/d32m/symlink01 || error
2381 run_test 32m "stat d32m/symlink->tmp/symlink->lustre-root ======"
2385 test_mkdir -p $DIR/d32n/tmp
2386 TMP_DIR=$DIR/d32n/tmp
2387 ln -s $DIR $TMP_DIR/symlink11
2388 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
2389 ls -l $DIR/d32n/tmp/symlink11 || error
2390 ls -l $DIR/d32n/symlink01 || error
2392 run_test 32n "open d32n/symlink->tmp/symlink->lustre-root ======"
2395 rm -fr $DIR/d32o $DIR/$tfile
2397 test_mkdir -p $DIR/d32o/tmp
2398 TMP_DIR=$DIR/d32o/tmp
2399 ln -s $DIR/$tfile $TMP_DIR/symlink12
2400 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
2401 $CHECKSTAT -t link $DIR/d32o/tmp/symlink12 || error
2402 $CHECKSTAT -t link $DIR/d32o/symlink02 || error
2403 $CHECKSTAT -t file -f $DIR/d32o/tmp/symlink12 || error
2404 $CHECKSTAT -t file -f $DIR/d32o/symlink02 || error
2406 run_test 32o "stat d32o/symlink->tmp/symlink->lustre-root/$tfile"
2416 test_mkdir -p $DIR/d32p/tmp
2418 TMP_DIR=$DIR/d32p/tmp
2420 ln -s $DIR/$tfile $TMP_DIR/symlink12
2422 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
2424 cat $DIR/d32p/tmp/symlink12 || error
2426 cat $DIR/d32p/symlink02 || error
2429 run_test 32p "open d32p/symlink->tmp/symlink->lustre-root/$tfile"
2431 cleanup_testdir_mount() {
2433 $UMOUNT -d $DIR/$tdir
2437 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2438 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2439 trap cleanup_testdir_mount EXIT
2440 test_mkdir -p $DIR/$tdir
2441 touch $DIR/$tdir/under_the_mount
2442 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir
2443 ls $DIR/$tdir | grep "\<under_the_mount\>" && error
2444 cleanup_testdir_mount
2446 run_test 32q "stat follows mountpoints in Lustre (should return error)"
2449 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2450 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2451 trap cleanup_testdir_mount EXIT
2452 test_mkdir -p $DIR/$tdir
2453 touch $DIR/$tdir/under_the_mount
2454 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir
2455 ls $DIR/$tdir | grep -q under_the_mount && error || true
2456 cleanup_testdir_mount
2458 run_test 32r "opendir follows mountpoints in Lustre (should return error)"
2463 chmod 444 $DIR/$tfile
2464 chown $RUNAS_ID $DIR/$tfile
2466 $RUNAS $OPENFILE -f O_RDWR $DIR/$tfile && error || true
2469 run_test 33aa "write file with mode 444 (should return error) ===="
2473 test_mkdir -p $DIR/d33
2474 chown $RUNAS_ID $DIR/d33
2475 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $DIR/d33/f33|| error "create"
2476 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $DIR/d33/f33 && \
2477 error "open RDWR" || true
2479 run_test 33a "test open file(mode=0444) with O_RDWR (should return error)"
2483 test_mkdir -p $DIR/d33
2484 chown $RUNAS_ID $DIR/d33
2485 $RUNAS $OPENFILE -f 1286739555 $DIR/d33/f33 && error "create" || true
2487 run_test 33b "test open file with malformed flags (No panic and return error)"
2490 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2496 remote_ost_nodsh && skip "remote OST with nodsh" && return
2499 test_mkdir -p $DIR/d33
2500 # Read: 0, Write: 4, create/destroy: 2/0, stat: 1, punch: 0
2503 for ostnum in $(seq $OSTCOUNT); do
2504 # test-framework's OST numbering is one-based, while Lustre's
2506 ostname=$(printf "$FSNAME-OST%.4x" $((ostnum - 1)))
2507 # Parsing llobdstat's output sucks; we could grep the /proc
2508 # path, but that's likely to not be as portable as using the
2509 # llobdstat utility. So we parse lctl output instead.
2510 write_bytes=$(do_facet ost$ostnum lctl get_param -n \
2511 obdfilter/$ostname/stats |
2512 awk '/^write_bytes/ {print $7}' )
2513 echo "baseline_write_bytes@$OSTnum/$ostname=$write_bytes"
2514 if (( ${write_bytes:-0} > 0 ))
2521 $all_zeros || return 0
2524 echo foo > $DIR/d33/bar
2528 # Total up write_bytes after writing. We'd better find non-zeros.
2529 for ostnum in $(seq $OSTCOUNT); do
2530 ostname=$(printf "$FSNAME-OST%.4x" $((ostnum - 1)))
2531 write_bytes=$(do_facet ost$ostnum lctl get_param -n \
2532 obdfilter/$ostname/stats |
2533 awk '/^write_bytes/ {print $7}' )
2534 echo "write_bytes@$OSTnum/$ostname=$write_bytes"
2535 if (( ${write_bytes:-0} > 0 ))
2544 for ostnum in $(seq $OSTCOUNT); do
2545 ostname=$(printf "$FSNAME-OST%.4x" $((ostnum - 1)))
2546 echo "Check that write_bytes is present in obdfilter/*/stats:"
2547 do_facet ost$ostnum lctl get_param -n \
2548 obdfilter/$ostname/stats
2550 error "OST not keeping write_bytes stats (b22312)"
2553 run_test 33c "test llobdstat and write_bytes"
2556 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2557 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2559 local remote_dir=$DIR/$tdir/remote_dir
2562 $LFS mkdir -i $MDTIDX $remote_dir ||
2563 error "create remote directory failed"
2565 touch $remote_dir/$tfile
2566 chmod 444 $remote_dir/$tfile
2567 chown $RUNAS_ID $remote_dir/$tfile
2569 $RUNAS $OPENFILE -f O_RDWR $DIR/$tfile && error || true
2571 chown $RUNAS_ID $remote_dir
2572 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $remote_dir/f33 ||
2573 error "create" || true
2574 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $remote_dir/f33 &&
2575 error "open RDWR" || true
2576 $RUNAS $OPENFILE -f 1286739555 $remote_dir/f33 &&
2577 error "create" || true
2579 run_test 33d "openfile with 444 modes and malformed flags under remote dir"
2581 TEST_34_SIZE=${TEST_34_SIZE:-2000000000000}
2584 $MCREATE $DIR/f34 || error
2585 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" || error
2586 $TRUNCATE $DIR/f34 $TEST_34_SIZE || error
2587 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" || error
2588 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2590 run_test 34a "truncate file that has not been opened ==========="
2593 [ ! -f $DIR/f34 ] && test_34a
2594 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2595 $OPENFILE -f O_RDONLY $DIR/f34
2596 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" || error
2597 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2599 run_test 34b "O_RDONLY opening file doesn't create objects ====="
2602 [ ! -f $DIR/f34 ] && test_34a
2603 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2604 $OPENFILE -f O_RDWR $DIR/f34
2605 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" && error
2606 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2608 run_test 34c "O_RDWR opening file-with-size works =============="
2611 [ ! -f $DIR/f34 ] && test_34a
2612 dd if=/dev/zero of=$DIR/f34 conv=notrunc bs=4k count=1 || error
2613 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2616 run_test 34d "write to sparse file ============================="
2620 $MCREATE $DIR/f34e || error
2621 $TRUNCATE $DIR/f34e 1000 || error
2622 $CHECKSTAT -s 1000 $DIR/f34e || error
2623 $OPENFILE -f O_RDWR $DIR/f34e
2624 $CHECKSTAT -s 1000 $DIR/f34e || error
2626 run_test 34e "create objects, some with size and some without =="
2628 test_34f() { # bug 6242, 6243
2629 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2632 $MCREATE $DIR/f34f || error
2633 $TRUNCATE $DIR/f34f $SIZE34F || error "truncating $DIR/f3f to $SIZE34F"
2634 dd if=$DIR/f34f of=$TMP/f34f
2635 $CHECKSTAT -s $SIZE34F $TMP/f34f || error "$TMP/f34f not $SIZE34F bytes"
2636 dd if=/dev/zero of=$TMP/f34fzero bs=$SIZE34F count=1
2637 cmp $DIR/f34f $TMP/f34fzero || error "$DIR/f34f not all zero"
2638 cmp $TMP/f34f $TMP/f34fzero || error "$TMP/f34f not all zero"
2639 rm $TMP/f34f $TMP/f34fzero $DIR/f34f
2641 run_test 34f "read from a file with no objects until EOF ======="
2644 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2645 dd if=/dev/zero of=$DIR/$tfile bs=1 count=100 seek=$TEST_34_SIZE || error
2646 $TRUNCATE $DIR/$tfile $((TEST_34_SIZE / 2))|| error
2647 $CHECKSTAT -s $((TEST_34_SIZE / 2)) $DIR/$tfile || error "truncate failed"
2648 cancel_lru_locks osc
2649 $CHECKSTAT -s $((TEST_34_SIZE / 2)) $DIR/$tfile || \
2650 error "wrong size after lock cancel"
2652 $TRUNCATE $DIR/$tfile $TEST_34_SIZE || error
2653 $CHECKSTAT -s $TEST_34_SIZE $DIR/$tfile || \
2654 error "expanding truncate failed"
2655 cancel_lru_locks osc
2656 $CHECKSTAT -s $TEST_34_SIZE $DIR/$tfile || \
2657 error "wrong expanded size after lock cancel"
2659 run_test 34g "truncate long file ==============================="
2662 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2666 dd if=/dev/zero of=$DIR/$tfile bs=1M count=10 || error
2667 sync # Flush the cache so that multiop below does not block on cache
2668 # flush when getting the group lock
2669 $MULTIOP $DIR/$tfile OG${gid}T${sz}g${gid}c &
2672 # Since just timed wait is not good enough, let's do a sync write
2673 # that way we are sure enough time for a roundtrip + processing
2674 # passed + 2 seconds of extra margin.
2675 dd if=/dev/zero of=$DIR/${tfile}-1 bs=4096 oflag=direct count=1
2679 if [[ `ps h -o comm -p $MULTIPID` == "multiop" ]]; then
2680 error "Multiop blocked on ftruncate, pid=$MULTIPID"
2684 local nsz=`stat -c %s $DIR/$tfile`
2685 [[ $nsz == $sz ]] || error "New size wrong $nsz != $sz"
2687 run_test 34h "ftruncate file under grouplock should not block"
2690 cp /bin/sh $DIR/f35a
2692 chown $RUNAS_ID $DIR/f35a
2693 $RUNAS $DIR/f35a && error || true
2696 run_test 35a "exec file with mode 444 (should return and not leak) ====="
2700 utime $DIR/f36 || error
2702 run_test 36a "MDS utime check (mknod, utime) ==================="
2706 utime $DIR/f36 || error
2708 run_test 36b "OST utime check (open, utime) ===================="
2713 chown $RUNAS_ID $DIR/d36
2714 $RUNAS utime $DIR/d36/f36 || error
2716 run_test 36c "non-root MDS utime check (mknod, utime) =========="
2719 [ ! -d $DIR/d36 ] && test_36c
2720 echo "" > $DIR/d36/f36
2721 $RUNAS utime $DIR/d36/f36 || error
2723 run_test 36d "non-root OST utime check (open, utime) ==========="
2726 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID -- skipping" && return
2727 test_mkdir -p $DIR/$tdir
2728 touch $DIR/$tdir/$tfile
2729 $RUNAS utime $DIR/$tdir/$tfile && \
2730 error "utime worked, expected failure" || true
2732 run_test 36e "utime on non-owned file (should return error) ===="
2736 local LANG_SAVE=$LANG
2737 local LC_LANG_SAVE=$LC_LANG
2738 export LANG=C LC_LANG=C # for date language
2740 DATESTR="Dec 20 2000"
2741 test_mkdir -p $DIR/$tdir
2742 lctl set_param fail_loc=$fl
2744 cp /etc/hosts $DIR/$tdir/$tfile
2745 sync & # write RPC generated with "current" inode timestamp, but delayed
2747 touch --date="$DATESTR" $DIR/$tdir/$tfile # setattr timestamp in past
2748 LS_BEFORE="`ls -l $DIR/$tdir/$tfile`" # old timestamp from client cache
2749 cancel_lru_locks osc
2750 LS_AFTER="`ls -l $DIR/$tdir/$tfile`" # timestamp from OST object
2752 [ "$LS_BEFORE" != "$LS_AFTER" ] && \
2753 echo "BEFORE: $LS_BEFORE" && \
2754 echo "AFTER : $LS_AFTER" && \
2755 echo "WANT : $DATESTR" && \
2756 error "$DIR/$tdir/$tfile timestamps changed" || true
2758 export LANG=$LANG_SAVE LC_LANG=$LC_LANG_SAVE
2762 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2763 #define OBD_FAIL_OST_BRW_PAUSE_BULK 0x214
2764 subr_36fh "0x80000214"
2766 run_test 36f "utime on file racing with OST BRW write =========="
2769 remote_ost_nodsh && skip "remote OST with nodsh" && return
2770 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2775 test_mkdir -p $DIR/$tdir
2776 fmd_max_age=$(do_facet ost1 \
2777 "lctl get_param -n obdfilter.*.client_cache_seconds 2> /dev/null | \
2780 fmd_before=$(do_facet ost1 \
2781 "awk '/ll_fmd_cache/ {print \\\$2}' /proc/slabinfo")
2782 touch $DIR/$tdir/$tfile
2783 sleep $((fmd_max_age + 12))
2784 fmd_after=$(do_facet ost1 \
2785 "awk '/ll_fmd_cache/ {print \\\$2}' /proc/slabinfo")
2787 echo "fmd_before: $fmd_before"
2788 echo "fmd_after: $fmd_after"
2789 [ "$fmd_after" -gt "$fmd_before" ] && \
2790 echo "AFTER: $fmd_after > BEFORE: $fmd_before" && \
2791 error "fmd didn't expire after ping" || true
2793 run_test 36g "filter mod data cache expiry ====================="
2796 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2797 #define OBD_FAIL_OST_BRW_PAUSE_BULK2 0x227
2798 subr_36fh "0x80000227"
2800 run_test 36h "utime on file racing with OST BRW write =========="
2802 # test_37 - duplicate with tests 32q 32r
2805 local file=$DIR/$tfile
2807 openfile -f O_DIRECTORY $file
2810 [ $RC -eq 0 ] && error "opened file $file with O_DIRECTORY" || true
2811 [ $RC -eq $ENOTDIR ] || error "error $RC should be ENOTDIR ($ENOTDIR)"
2813 run_test 38 "open a regular file with O_DIRECTORY should return -ENOTDIR ==="
2817 touch $DIR/${tfile}2
2818 # ls -l $DIR/$tfile $DIR/${tfile}2
2819 # ls -lu $DIR/$tfile $DIR/${tfile}2
2820 # ls -lc $DIR/$tfile $DIR/${tfile}2
2822 $OPENFILE -f O_CREAT:O_TRUNC:O_WRONLY $DIR/${tfile}2
2823 if [ ! $DIR/${tfile}2 -nt $DIR/$tfile ]; then
2825 ls -l --full-time $DIR/$tfile $DIR/${tfile}2
2827 ls -lu --full-time $DIR/$tfile $DIR/${tfile}2
2829 ls -lc --full-time $DIR/$tfile $DIR/${tfile}2
2830 error "O_TRUNC didn't change timestamps"
2833 run_test 39 "mtime changed on create ==========================="
2836 test_mkdir -p $DIR/$tdir
2837 cp -p /etc/passwd $DIR/$tdir/fopen
2838 cp -p /etc/passwd $DIR/$tdir/flink
2839 cp -p /etc/passwd $DIR/$tdir/funlink
2840 cp -p /etc/passwd $DIR/$tdir/frename
2841 ln $DIR/$tdir/funlink $DIR/$tdir/funlink2
2844 echo "aaaaaa" >> $DIR/$tdir/fopen
2845 echo "aaaaaa" >> $DIR/$tdir/flink
2846 echo "aaaaaa" >> $DIR/$tdir/funlink
2847 echo "aaaaaa" >> $DIR/$tdir/frename
2849 local open_new=`stat -c %Y $DIR/$tdir/fopen`
2850 local link_new=`stat -c %Y $DIR/$tdir/flink`
2851 local unlink_new=`stat -c %Y $DIR/$tdir/funlink`
2852 local rename_new=`stat -c %Y $DIR/$tdir/frename`
2854 cat $DIR/$tdir/fopen > /dev/null
2855 ln $DIR/$tdir/flink $DIR/$tdir/flink2
2856 rm -f $DIR/$tdir/funlink2
2857 mv -f $DIR/$tdir/frename $DIR/$tdir/frename2
2859 for (( i=0; i < 2; i++ )) ; do
2860 local open_new2=`stat -c %Y $DIR/$tdir/fopen`
2861 local link_new2=`stat -c %Y $DIR/$tdir/flink`
2862 local unlink_new2=`stat -c %Y $DIR/$tdir/funlink`
2863 local rename_new2=`stat -c %Y $DIR/$tdir/frename2`
2865 [ $open_new2 -eq $open_new ] || error "open file reverses mtime"
2866 [ $link_new2 -eq $link_new ] || error "link file reverses mtime"
2867 [ $unlink_new2 -eq $unlink_new ] || error "unlink file reverses mtime"
2868 [ $rename_new2 -eq $rename_new ] || error "rename file reverses mtime"
2870 cancel_lru_locks osc
2871 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2874 run_test 39b "mtime change on open, link, unlink, rename ======"
2876 # this should be set to past
2877 TEST_39_MTIME=`date -d "1 year ago" +%s`
2883 local mtime0=`stat -c %Y $DIR1/$tfile`
2885 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
2886 local mtime1=`stat -c %Y $DIR1/$tfile`
2887 [ "$mtime1" = $TEST_39_MTIME ] || \
2888 error "mtime is not set to past: $mtime1, should be $TEST_39_MTIME"
2891 echo hello >> $DIR1/$tfile
2893 local mtime2=`stat -c %Y $DIR1/$tfile`
2894 [ "$mtime2" -ge "$d1" ] && [ "$mtime2" -le "$d2" ] || \
2895 error "mtime is not updated on write: $d1 <= $mtime2 <= $d2"
2897 mv $DIR1/$tfile $DIR1/$tfile-1
2899 for (( i=0; i < 2; i++ )) ; do
2900 local mtime3=`stat -c %Y $DIR1/$tfile-1`
2901 [ "$mtime2" = "$mtime3" ] || \
2902 error "mtime ($mtime2) changed (to $mtime3) on rename"
2904 cancel_lru_locks osc
2905 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2908 run_test 39c "mtime change on rename ==========================="
2912 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2915 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
2917 for (( i=0; i < 2; i++ )) ; do
2918 local mtime=`stat -c %Y $DIR1/$tfile`
2919 [ $mtime = $TEST_39_MTIME ] || \
2920 error "mtime($mtime) is not set to $TEST_39_MTIME"
2922 cancel_lru_locks osc
2923 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2926 run_test 39d "create, utime, stat =============================="
2930 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2932 local mtime1=`stat -c %Y $DIR1/$tfile`
2934 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
2936 for (( i=0; i < 2; i++ )) ; do
2937 local mtime2=`stat -c %Y $DIR1/$tfile`
2938 [ $mtime2 = $TEST_39_MTIME ] || \
2939 error "mtime($mtime2) is not set to $TEST_39_MTIME"
2941 cancel_lru_locks osc
2942 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2945 run_test 39e "create, stat, utime, stat ========================"
2949 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2951 mtime1=`stat -c %Y $DIR1/$tfile`
2954 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
2956 for (( i=0; i < 2; i++ )) ; do
2957 local mtime2=`stat -c %Y $DIR1/$tfile`
2958 [ $mtime2 = $TEST_39_MTIME ] || \
2959 error "mtime($mtime2) is not set to $TEST_39_MTIME"
2961 cancel_lru_locks osc
2962 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2965 run_test 39f "create, stat, sleep, utime, stat ================="
2969 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2970 echo hello >> $DIR1/$tfile
2971 local mtime1=`stat -c %Y $DIR1/$tfile`
2974 chmod o+r $DIR1/$tfile
2976 for (( i=0; i < 2; i++ )) ; do
2977 local mtime2=`stat -c %Y $DIR1/$tfile`
2978 [ "$mtime1" = "$mtime2" ] || \
2979 error "lost mtime: $mtime2, should be $mtime1"
2981 cancel_lru_locks osc
2982 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2985 run_test 39g "write, chmod, stat ==============================="
2989 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2994 echo hello >> $DIR1/$tfile
2995 local mtime1=`stat -c %Y $DIR1/$tfile`
2997 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
2999 if [ "$d1" != "$d2" ]; then
3000 echo "write and touch not within one second"
3002 for (( i=0; i < 2; i++ )) ; do
3003 local mtime2=`stat -c %Y $DIR1/$tfile`
3004 [ "$mtime2" = $TEST_39_MTIME ] || \
3005 error "lost mtime: $mtime2, should be $TEST_39_MTIME"
3007 cancel_lru_locks osc
3008 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3012 run_test 39h "write, utime within one second, stat ============="
3015 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3019 echo hello >> $DIR1/$tfile
3020 local mtime1=`stat -c %Y $DIR1/$tfile`
3022 mv $DIR1/$tfile $DIR1/$tfile-1
3024 for (( i=0; i < 2; i++ )) ; do
3025 local mtime2=`stat -c %Y $DIR1/$tfile-1`
3027 [ "$mtime1" = "$mtime2" ] || \
3028 error "lost mtime: $mtime2, should be $mtime1"
3030 cancel_lru_locks osc
3031 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3034 run_test 39i "write, rename, stat =============================="
3037 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3038 start_full_debug_logging
3042 #define OBD_FAIL_OSC_DELAY_SETTIME 0x412
3043 lctl set_param fail_loc=0x80000412
3044 multiop_bg_pause $DIR1/$tfile oO_RDWR:w2097152_c ||
3045 error "multiop failed"
3047 local mtime1=`stat -c %Y $DIR1/$tfile`
3049 mv $DIR1/$tfile $DIR1/$tfile-1
3051 kill -USR1 $multipid
3052 wait $multipid || error "multiop close failed"
3054 for (( i=0; i < 2; i++ )) ; do
3055 local mtime2=`stat -c %Y $DIR1/$tfile-1`
3056 [ "$mtime1" = "$mtime2" ] ||
3057 error "mtime is lost on close: $mtime2, " \
3060 cancel_lru_locks osc
3061 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3063 lctl set_param fail_loc=0
3064 stop_full_debug_logging
3066 run_test 39j "write, rename, close, stat ======================="
3069 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3073 multiop_bg_pause $DIR1/$tfile oO_RDWR:w2097152_c || error "multiop failed"
3075 local mtime1=`stat -c %Y $DIR1/$tfile`
3077 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3079 kill -USR1 $multipid
3080 wait $multipid || error "multiop close failed"
3082 for (( i=0; i < 2; i++ )) ; do
3083 local mtime2=`stat -c %Y $DIR1/$tfile`
3085 [ "$mtime2" = $TEST_39_MTIME ] || \
3086 error "mtime is lost on close: $mtime2, should be $TEST_39_MTIME"
3088 cancel_lru_locks osc
3089 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3092 run_test 39k "write, utime, close, stat ========================"
3094 # this should be set to future
3095 TEST_39_ATIME=`date -d "1 year" +%s`
3098 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3099 remote_mds_nodsh && skip "remote MDS with nodsh" && return
3100 local atime_diff=$(do_facet $SINGLEMDS \
3101 lctl get_param -n mdd.*MDT0000*.atime_diff)
3105 # test setting directory atime to future
3106 touch -a -d @$TEST_39_ATIME $DIR/$tdir
3107 local atime=$(stat -c %X $DIR/$tdir)
3108 [ "$atime" = $TEST_39_ATIME ] || \
3109 error "atime is not set to future: $atime, $TEST_39_ATIME"
3111 # test setting directory atime from future to now
3112 local d1=$(date +%s)
3114 local d2=$(date +%s)
3116 cancel_lru_locks mdc
3117 atime=$(stat -c %X $DIR/$tdir)
3118 [ "$atime" -ge "$d1" -a "$atime" -le "$d2" ] || \
3119 error "atime is not updated from future: $atime, $d1<atime<$d2"
3121 do_facet $SINGLEMDS lctl set_param -n mdd.*MDT0000*.atime_diff=2
3124 # test setting directory atime when now > dir atime + atime_diff
3128 cancel_lru_locks mdc
3129 atime=$(stat -c %X $DIR/$tdir)
3130 [ "$atime" -ge "$d1" -a "$atime" -le "$d2" ] || \
3131 error "atime is not updated : $atime, should be $d2"
3133 do_facet $SINGLEMDS lctl set_param -n mdd.*MDT0000*.atime_diff=60
3136 # test not setting directory atime when now < dir atime + atime_diff
3138 cancel_lru_locks mdc
3139 atime=$(stat -c %X $DIR/$tdir)
3140 [ "$atime" -ge "$d1" -a "$atime" -le "$d2" ] || \
3141 error "atime is updated to $atime, should remain $d1<atime<$d2"
3143 do_facet $SINGLEMDS \
3144 lctl set_param -n mdd.*MDT0000*.atime_diff=$atime_diff
3146 run_test 39l "directory atime update ==========================="
3149 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3152 local far_past_mtime=$(date -d "May 29 1953" +%s)
3153 local far_past_atime=$(date -d "Dec 17 1903" +%s)
3155 touch -m -d @$far_past_mtime $DIR1/$tfile
3156 touch -a -d @$far_past_atime $DIR1/$tfile
3158 for (( i=0; i < 2; i++ )) ; do
3159 local timestamps=$(stat -c "%X %Y" $DIR1/$tfile)
3160 [ "$timestamps" = "$far_past_atime $far_past_mtime" ] || \
3161 error "atime or mtime set incorrectly"
3163 cancel_lru_locks osc
3164 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3167 run_test 39m "test atime and mtime before 1970"
3169 test_39n() { # LU-3832
3170 local atime_diff=$(do_facet $SINGLEMDS \
3171 lctl get_param -n mdd.*MDT0000*.atime_diff)
3176 do_facet $SINGLEMDS lctl set_param -n mdd.*MDT0000*.atime_diff=1
3179 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 status=noxfer
3180 atime0=$(stat -c %X $DIR/$tfile)
3183 $MULTIOP $DIR/$tfile oO_RDONLY:O_NOATIME:r4096c
3184 atime1=$(stat -c %X $DIR/$tfile)
3187 cancel_lru_locks mdc
3188 cancel_lru_locks osc
3189 $MULTIOP $DIR/$tfile oO_RDONLY:O_NOATIME:r4096c
3190 atime2=$(stat -c %X $DIR/$tfile)
3192 do_facet $SINGLEMDS \
3193 lctl set_param -n mdd.*MDT0000*.atime_diff=$atime_diff
3195 [ "$atime0" -eq "$atime1" ] || error "atime0 $atime0 != atime1 $atime1"
3196 [ "$atime1" -eq "$atime2" ] || error "atime0 $atime0 != atime1 $atime1"
3198 run_test 39n "check that O_NOATIME is honored"
3201 TESTDIR=$DIR/$tdir/$tfile
3202 [ -e $TESTDIR ] && rm -rf $TESTDIR
3203 test_mkdir -p $TESTDIR
3209 links2=$(stat -c %h .)
3210 [ $(($links1 + 2)) != $links2 ] &&
3211 error "wrong links count $(($links1 + 2)) != $links2"
3213 links3=$(stat -c %h .)
3214 [ $(($links1 + 1)) != $links3 ] &&
3215 error "wrong links count $links1 != $links3"
3218 run_test 39o "directory cached attributes updated after create ========"
3221 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
3223 TESTDIR=$DIR/$tdir/$tfile
3224 [ -e $TESTDIR ] && rm -rf $TESTDIR
3229 $LFS mkdir -i $MDTIDX $TESTDIR/remote_dir1
3230 $LFS mkdir -i $MDTIDX $TESTDIR/remote_dir2
3232 links2=$(stat -c %h .)
3233 [ $(($links1 + 2)) != $links2 ] &&
3234 error "wrong links count $(($links1 + 2)) != $links2"
3236 links3=$(stat -c %h .)
3237 [ $(($links1 + 1)) != $links3 ] &&
3238 error "wrong links count $links1 != $links3"
3241 run_test 39p "remote directory cached attributes updated after create ========"
3245 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1
3246 $RUNAS $OPENFILE -f O_WRONLY:O_TRUNC $DIR/$tfile &&
3247 error "openfile O_WRONLY:O_TRUNC $tfile failed"
3248 $CHECKSTAT -t file -s 4096 $DIR/$tfile ||
3249 error "$tfile is not 4096 bytes in size"
3251 run_test 40 "failed open(O_TRUNC) doesn't truncate ============="
3255 small_write $DIR/f41 18
3257 run_test 41 "test small file write + fstat ====================="
3259 count_ost_writes() {
3260 lctl get_param -n osc.*.stats |
3261 awk -vwrites=0 '/ost_write/ { writes += $2 } END { print writes; }'
3268 BG_DIRTY_RATIO_SAVE=10
3269 MAX_BG_DIRTY_RATIO=25
3273 # in 2.6, restore /proc/sys/vm/dirty_writeback_centisecs,
3274 # dirty_ratio, dirty_background_ratio
3275 if [ -f /proc/sys/vm/dirty_writeback_centisecs ]; then
3276 sysctl -w vm.dirty_writeback_centisecs=$WRITEBACK_SAVE
3277 sysctl -w vm.dirty_background_ratio=$BG_DIRTY_RATIO_SAVE
3278 sysctl -w vm.dirty_ratio=$DIRTY_RATIO_SAVE
3280 # if file not here, we are a 2.4 kernel
3281 kill -CONT `pidof kupdated`
3286 # setup the trap first, so someone cannot exit the test at the
3287 # exact wrong time and mess up a machine
3288 trap start_writeback EXIT
3289 # in 2.6, save and 0 /proc/sys/vm/dirty_writeback_centisecs
3290 if [ -f /proc/sys/vm/dirty_writeback_centisecs ]; then
3291 WRITEBACK_SAVE=`sysctl -n vm.dirty_writeback_centisecs`
3292 sysctl -w vm.dirty_writeback_centisecs=0
3293 sysctl -w vm.dirty_writeback_centisecs=0
3294 # save and increase /proc/sys/vm/dirty_ratio
3295 DIRTY_RATIO_SAVE=`sysctl -n vm.dirty_ratio`
3296 sysctl -w vm.dirty_ratio=$MAX_DIRTY_RATIO
3297 # save and increase /proc/sys/vm/dirty_background_ratio
3298 BG_DIRTY_RATIO_SAVE=`sysctl -n vm.dirty_background_ratio`
3299 sysctl -w vm.dirty_background_ratio=$MAX_BG_DIRTY_RATIO
3301 # if file not here, we are a 2.4 kernel
3302 kill -STOP `pidof kupdated`
3306 # ensure that all stripes have some grant before we test client-side cache
3308 for i in `seq -f $DIR/f42-%g 1 $OSTCOUNT`; do
3309 dd if=/dev/zero of=$i bs=4k count=1
3314 # Tests 42* verify that our behaviour is correct WRT caching, file closure,
3315 # file truncation, and file removal.
3317 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3319 cancel_lru_locks osc
3321 sync; sleep 1; sync # just to be safe
3322 BEFOREWRITES=`count_ost_writes`
3323 lctl get_param -n osc.*[oO][sS][cC][_-]*.cur_grant_bytes | grep "[0-9]"
3324 dd if=/dev/zero of=$DIR/f42a bs=1024 count=100
3325 AFTERWRITES=`count_ost_writes`
3326 [ $BEFOREWRITES -eq $AFTERWRITES ] || \
3327 error "$BEFOREWRITES < $AFTERWRITES"
3330 run_test 42a "ensure that we don't flush on close =============="
3333 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3335 cancel_lru_locks osc
3338 dd if=/dev/zero of=$DIR/f42b bs=1024 count=100
3339 BEFOREWRITES=`count_ost_writes`
3340 $MUNLINK $DIR/f42b || error "$MUNLINK $DIR/f42b: $?"
3341 AFTERWRITES=`count_ost_writes`
3342 if [ $BEFOREWRITES -lt $AFTERWRITES ]; then
3343 error "$BEFOREWRITES < $AFTERWRITES on unlink"
3345 BEFOREWRITES=`count_ost_writes`
3346 sync || error "sync: $?"
3347 AFTERWRITES=`count_ost_writes`
3348 if [ $BEFOREWRITES -lt $AFTERWRITES ]; then
3349 error "$BEFOREWRITES < $AFTERWRITES on sync"
3351 dmesg | grep 'error from obd_brw_async' && error 'error writing back'
3355 run_test 42b "test destroy of file with cached dirty data ======"
3357 # if these tests just want to test the effect of truncation,
3358 # they have to be very careful. consider:
3359 # - the first open gets a {0,EOF}PR lock
3360 # - the first write conflicts and gets a {0, count-1}PW
3361 # - the rest of the writes are under {count,EOF}PW
3362 # - the open for truncate tries to match a {0,EOF}PR
3363 # for the filesize and cancels the PWs.
3364 # any number of fixes (don't get {0,EOF} on open, match
3365 # composite locks, do smarter file size management) fix
3366 # this, but for now we want these tests to verify that
3367 # the cancellation with truncate intent works, so we
3368 # start the file with a full-file pw lock to match against
3369 # until the truncate.
3374 cancel_lru_locks osc
3376 # prime the file with 0,EOF PW to match
3380 # now the real test..
3381 dd if=/dev/zero of=$file bs=1024 count=100
3382 BEFOREWRITES=`count_ost_writes`
3383 $TRUNCATE $file $offset
3384 cancel_lru_locks osc
3385 AFTERWRITES=`count_ost_writes`
3390 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3392 [ $BEFOREWRITES -eq $AFTERWRITES ] && \
3393 error "beforewrites $BEFOREWRITES == afterwrites $AFTERWRITES on truncate"
3396 run_test 42c "test partial truncate of file with cached dirty data"
3399 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3401 [ $BEFOREWRITES -eq $AFTERWRITES ] || \
3402 error "beforewrites $BEFOREWRITES != afterwrites $AFTERWRITES on truncate"
3405 run_test 42d "test complete truncate of file with cached dirty data"
3407 test_42e() { # bug22074
3408 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3409 local TDIR=$DIR/${tdir}e
3410 local pagesz=$(page_size)
3411 local pages=16 # hardcoded 16 pages, don't change it.
3412 local files=$((OSTCOUNT * 500)) # hopefully 500 files on each OST
3413 local proc_osc0="osc.${FSNAME}-OST0000-osc-[^MDT]*"
3417 test_mkdir -p $DIR/${tdir}e
3418 $SETSTRIPE -c 1 $TDIR
3419 createmany -o $TDIR/f $files
3421 max_dirty_mb=$($LCTL get_param -n $proc_osc0/max_dirty_mb)
3423 # we assume that with $OSTCOUNT files, at least one of them will
3424 # be allocated on OST0.
3425 warmup_files=$((OSTCOUNT * max_dirty_mb))
3426 createmany -o $TDIR/w $warmup_files
3428 # write a large amount of data into one file and sync, to get good
3429 # avail_grant number from OST.
3430 for ((i=0; i<$warmup_files; i++)); do
3431 idx=$($GETSTRIPE -i $TDIR/w$i)
3432 [ $idx -ne 0 ] && continue
3433 dd if=/dev/zero of=$TDIR/w$i bs="$max_dirty_mb"M count=1
3436 [ $i -gt $warmup_files ] && error "OST0 is still cold"
3438 $LCTL get_param $proc_osc0/cur_dirty_bytes
3439 $LCTL get_param $proc_osc0/cur_grant_bytes
3441 # create as much dirty pages as we can while not to trigger the actual
3442 # RPCs directly. but depends on the env, VFS may trigger flush during this
3443 # period, hopefully we are good.
3444 for ((i=0; i<$warmup_files; i++)); do
3445 idx=$($GETSTRIPE -i $TDIR/w$i)
3446 [ $idx -ne 0 ] && continue
3447 dd if=/dev/zero of=$TDIR/w$i bs=1M count=1 2>/dev/null
3449 $LCTL get_param $proc_osc0/cur_dirty_bytes
3450 $LCTL get_param $proc_osc0/cur_grant_bytes
3452 # perform the real test
3453 $LCTL set_param $proc_osc0/rpc_stats 0
3454 for ((;i<$files; i++)); do
3455 [ $($GETSTRIPE -i $TDIR/f$i) -eq 0 ] || continue
3456 dd if=/dev/zero of=$TDIR/f$i bs=$pagesz count=$pages 2>/dev/null
3459 $LCTL get_param $proc_osc0/rpc_stats
3462 local have_ppr=false
3463 $LCTL get_param $proc_osc0/rpc_stats |
3464 while read PPR RRPC RPCT RCUM BAR WRPC WPCT WCUM; do
3465 # skip lines until we are at the RPC histogram data
3466 [ "$PPR" == "pages" ] && have_ppr=true && continue
3467 $have_ppr || continue
3469 # we only want the percent stat for < 16 pages
3470 [ $(echo $PPR | tr -d ':') -ge $pages ] && break
3472 percent=$((percent + WPCT))
3473 if [ $percent -gt 15 ]; then
3474 error "less than 16-pages write RPCs" \
3481 run_test 42e "verify sub-RPC writes are not done synchronously"
3484 test_mkdir -p $DIR/$tdir
3485 cp -p /bin/ls $DIR/$tdir/$tfile
3486 $MULTIOP $DIR/$tdir/$tfile Ow_c &
3488 # give multiop a chance to open
3491 $DIR/$tdir/$tfile && error || true
3494 run_test 43 "execution of file opened for write should return -ETXTBSY"
3497 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3498 test_mkdir -p $DIR/$tdir
3499 cp -p `which $MULTIOP` $DIR/$tdir/multiop ||
3500 cp -p multiop $DIR/$tdir/multiop
3501 MULTIOP_PROG=$DIR/$tdir/multiop multiop_bg_pause $TMP/$tfile.junk O_c ||
3504 $MULTIOP $DIR/$tdir/multiop Oc && error "expected error, got success"
3505 kill -USR1 $MULTIOP_PID || return 2
3506 wait $MULTIOP_PID || return 3
3507 rm $TMP/$tfile.junk $DIR/$tdir/multiop
3509 run_test 43a "open(RDWR) of file being executed should return -ETXTBSY"
3512 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3513 test_mkdir -p $DIR/$tdir
3514 cp -p `which $MULTIOP` $DIR/$tdir/multiop ||
3515 cp -p multiop $DIR/$tdir/multiop
3516 MULTIOP_PROG=$DIR/$tdir/multiop multiop_bg_pause $TMP/$tfile.junk O_c ||
3519 $TRUNCATE $DIR/$tdir/multiop 0 && error "expected error, got success"
3520 kill -USR1 $MULTIOP_PID || return 2
3521 wait $MULTIOP_PID || return 3
3522 rm $TMP/$tfile.junk $DIR/$tdir/multiop
3524 run_test 43b "truncate of file being executed should return -ETXTBSY"
3527 local testdir="$DIR/$tdir"
3528 test_mkdir -p $DIR/$tdir
3530 ( cd $(dirname $SHELL) && md5sum $(basename $SHELL) ) | \
3531 ( cd $testdir && md5sum -c)
3533 run_test 43c "md5sum of copy into lustre========================"
3536 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping 2-stripe test" && return
3537 dd if=/dev/zero of=$DIR/f1 bs=4k count=1 seek=1023
3538 dd if=$DIR/f1 bs=4k count=1 > /dev/null
3540 run_test 44 "zero length read from a sparse stripe ============="
3543 local nstripe=`$LCTL lov_getconfig $DIR | grep default_stripe_count: | \
3545 [ -z "$nstripe" ] && skip "can't get stripe info" && return
3546 [ "$nstripe" -gt "$OSTCOUNT" ] && skip "Wrong default_stripe_count: $nstripe (OSTCOUNT: $OSTCOUNT)" && return
3547 local stride=`$LCTL lov_getconfig $DIR | grep default_stripe_size: | \
3549 if [ $nstripe -eq 0 -o $nstripe -eq -1 ] ; then
3550 nstripe=`$LCTL lov_getconfig $DIR | grep obd_count: | awk '{print $2}'`
3553 OFFSETS="0 $((stride/2)) $((stride-1))"
3554 for offset in $OFFSETS ; do
3555 for i in `seq 0 $((nstripe-1))`; do
3556 local GLOBALOFFSETS=""
3557 local size=$((((i + 2 * $nstripe )*$stride + $offset))) # Bytes
3558 local myfn=$DIR/d44a-$size
3559 echo "--------writing $myfn at $size"
3560 ll_sparseness_write $myfn $size || error "ll_sparseness_write"
3561 GLOBALOFFSETS="$GLOBALOFFSETS $size"
3562 ll_sparseness_verify $myfn $GLOBALOFFSETS \
3563 || error "ll_sparseness_verify $GLOBALOFFSETS"
3565 for j in `seq 0 $((nstripe-1))`; do
3566 size=$((((j + $nstripe )*$stride + $offset))) # Bytes
3567 ll_sparseness_write $myfn $size || error "ll_sparseness_write"
3568 GLOBALOFFSETS="$GLOBALOFFSETS $size"
3570 ll_sparseness_verify $myfn $GLOBALOFFSETS \
3571 || error "ll_sparseness_verify $GLOBALOFFSETS"
3576 run_test 44a "test sparse pwrite ==============================="
3580 for d in `lctl get_param -n osc.*.cur_dirty_bytes`; do
3586 before=`dirty_osc_total`
3587 echo executing "\"$*\""
3589 after=`dirty_osc_total`
3590 echo before $before, after $after
3593 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3595 # Obtain grants from OST if it supports it
3596 echo blah > ${f}_grant
3599 do_dirty_record "echo blah > $f"
3600 [ $before -eq $after ] && error "write wasn't cached"
3601 do_dirty_record "> $f"
3602 [ $before -gt $after ] || error "truncate didn't lower dirty count"
3603 do_dirty_record "echo blah > $f"
3604 [ $before -eq $after ] && error "write wasn't cached"
3605 do_dirty_record "sync"
3606 [ $before -gt $after ] || error "writeback didn't lower dirty count"
3607 do_dirty_record "echo blah > $f"
3608 [ $before -eq $after ] && error "write wasn't cached"
3609 do_dirty_record "cancel_lru_locks osc"
3610 [ $before -gt $after ] || error "lock cancellation didn't lower dirty count"
3613 run_test 45 "osc io page accounting ============================"
3615 # in a 2 stripe file (lov.sh), page 1023 maps to page 511 in its object. this
3616 # test tickles a bug where re-dirtying a page was failing to be mapped to the
3617 # objects offset and an assert hit when an rpc was built with 1023's mapped
3618 # offset 511 and 511's raw 511 offset. it also found general redirtying bugs.
3620 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3624 dd if=/dev/zero of=$f bs=`page_size` seek=511 count=1
3626 dd conv=notrunc if=/dev/zero of=$f bs=`page_size` seek=1023 count=1
3627 dd conv=notrunc if=/dev/zero of=$f bs=`page_size` seek=511 count=1
3631 run_test 46 "dirtying a previously written page ================"
3633 # test_47 is removed "Device nodes check" is moved to test_28
3635 test_48a() { # bug 2399
3636 check_kernel_version 34 || return 0
3637 test_mkdir -p $DIR/$tdir
3639 mv $DIR/$tdir $DIR/d48.new || error "move directory failed"
3640 test_mkdir $DIR/$tdir || error "recreate directory failed"
3641 touch foo || error "'touch foo' failed after recreating cwd"
3642 test_mkdir $DIR/$tdir/bar ||
3643 error "'mkdir foo' failed after recreating cwd"
3644 if check_kernel_version 44; then
3645 touch .foo || error "'touch .foo' failed after recreating cwd"
3646 test_mkdir $DIR/$tdir/.bar ||
3647 error "'mkdir .foo' failed after recreating cwd"
3649 ls . > /dev/null || error "'ls .' failed after recreating cwd"
3650 ls .. > /dev/null || error "'ls ..' failed after removing cwd"
3651 cd . || error "'cd .' failed after recreating cwd"
3652 test_mkdir . && error "'mkdir .' worked after recreating cwd"
3653 rmdir . && error "'rmdir .' worked after recreating cwd"
3654 ln -s . baz || error "'ln -s .' failed after recreating cwd"
3655 cd .. || error "'cd ..' failed after recreating cwd"
3657 run_test 48a "Access renamed working dir (should return errors)="
3659 test_48b() { # bug 2399
3660 check_kernel_version 34 || return 0
3662 test_mkdir -p $DIR/$tdir
3664 rmdir $DIR/$tdir || error "remove cwd $DIR/$tdir failed"
3665 touch foo && error "'touch foo' worked after removing cwd"
3666 test_mkdir $DIR/$tdir/foo &&
3667 error "'mkdir foo' worked after removing cwd"
3668 if check_kernel_version 44; then
3669 touch .foo && error "'touch .foo' worked after removing cwd"
3670 test_mkdir $DIR/$tdir/.foo &&
3671 error "'mkdir .foo' worked after removing cwd"
3673 ls . > /dev/null && error "'ls .' worked after removing cwd"
3674 ls .. > /dev/null || error "'ls ..' failed after removing cwd"
3675 is_patchless || ( cd . && error "'cd .' worked after removing cwd" )
3676 test_mkdir $DIR/$tdir/. && error "'mkdir .' worked after removing cwd"
3677 rmdir . && error "'rmdir .' worked after removing cwd"
3678 ln -s . foo && error "'ln -s .' worked after removing cwd"
3679 cd .. || echo "'cd ..' failed after removing cwd `pwd`" #bug 3517
3681 run_test 48b "Access removed working dir (should return errors)="
3683 test_48c() { # bug 2350
3684 check_kernel_version 36 || return 0
3685 #lctl set_param debug=-1
3688 test_mkdir -p $DIR/$tdir/dir
3690 $TRACE rmdir $DIR/$tdir/dir || error "remove cwd $DIR/$tdir/dir failed"
3691 $TRACE touch foo && error "touch foo worked after removing cwd"
3692 $TRACE test_mkdir foo && error "'mkdir foo' worked after removing cwd"
3693 if check_kernel_version 44; then
3694 touch .foo && error "touch .foo worked after removing cwd"
3695 test_mkdir .foo && error "mkdir .foo worked after removing cwd"
3697 $TRACE ls . && error "'ls .' worked after removing cwd"
3698 $TRACE ls .. || error "'ls ..' failed after removing cwd"
3699 is_patchless || ( $TRACE cd . &&
3700 error "'cd .' worked after removing cwd" )
3701 $TRACE test_mkdir . && error "'mkdir .' worked after removing cwd"
3702 $TRACE rmdir . && error "'rmdir .' worked after removing cwd"
3703 $TRACE ln -s . foo && error "'ln -s .' worked after removing cwd"
3704 $TRACE cd .. || echo "'cd ..' failed after removing cwd `pwd`" #bug 3415
3706 run_test 48c "Access removed working subdir (should return errors)"
3708 test_48d() { # bug 2350
3709 check_kernel_version 36 || return 0
3710 #lctl set_param debug=-1
3713 test_mkdir -p $DIR/$tdir/dir
3715 $TRACE rmdir $DIR/$tdir/dir || error "remove cwd $DIR/$tdir/dir failed"
3716 $TRACE rmdir $DIR/$tdir || error "remove parent $DIR/$tdir failed"
3717 $TRACE touch foo && error "'touch foo' worked after removing parent"
3718 $TRACE test_mkdir foo && error "mkdir foo worked after removing parent"
3719 if check_kernel_version 44; then
3720 touch .foo && error "'touch .foo' worked after removing parent"
3722 error "mkdir .foo worked after removing parent"
3724 $TRACE ls . && error "'ls .' worked after removing parent"
3725 $TRACE ls .. && error "'ls ..' worked after removing parent"
3726 is_patchless || ( $TRACE cd . &&
3727 error "'cd .' worked after recreate parent" )
3728 $TRACE test_mkdir . && error "'mkdir .' worked after removing parent"
3729 $TRACE rmdir . && error "'rmdir .' worked after removing parent"
3730 $TRACE ln -s . foo && error "'ln -s .' worked after removing parent"
3731 is_patchless || ( $TRACE cd .. &&
3732 error "'cd ..' worked after removing parent" || true )
3734 run_test 48d "Access removed parent subdir (should return errors)"
3736 test_48e() { # bug 4134
3737 check_kernel_version 41 || return 0
3738 #lctl set_param debug=-1
3741 test_mkdir -p $DIR/$tdir/dir
3743 $TRACE rmdir $DIR/$tdir/dir || error "remove cwd $DIR/$tdir/dir failed"
3744 $TRACE rmdir $DIR/$tdir || error "remove parent $DIR/$tdir failed"
3745 $TRACE touch $DIR/$tdir || error "'touch $DIR/$tdir' failed"
3746 $TRACE chmod +x $DIR/$tdir || error "'chmod +x $DIR/$tdir' failed"
3747 # On a buggy kernel addition of "touch foo" after cd .. will
3748 # produce kernel oops in lookup_hash_it
3749 touch ../foo && error "'cd ..' worked after recreate parent"
3751 $TRACE rm $DIR/$tdir || error "rm '$DIR/$tdir' failed"
3753 run_test 48e "Access to recreated parent subdir (should return errors)"
3755 test_49() { # LU-1030
3756 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3757 # get ost1 size - lustre-OST0000
3758 ost1_size=$(do_facet ost1 lfs df |grep ${ost1_svc} |awk '{print $4}')
3759 # write 800M at maximum
3760 [ $ost1_size -gt 819200 ] && ost1_size=819200
3762 lfs setstripe -c 1 -i 0 $DIR/$tfile
3763 dd if=/dev/zero of=$DIR/$tfile bs=4k count=$((ost1_size >> 2)) &
3766 # change max_pages_per_rpc while writing the file
3767 local osc1_mppc=osc.$(get_osc_import_name client ost1).max_pages_per_rpc
3768 local orig_mppc=`$LCTL get_param -n $osc1_mppc`
3769 # loop until dd process exits
3770 while ps ax -opid | grep -wq $dd_pid; do
3771 $LCTL set_param $osc1_mppc=$((RANDOM % 256 + 1))
3772 sleep $((RANDOM % 5 + 1))
3774 # restore original max_pages_per_rpc
3775 $LCTL set_param $osc1_mppc=$orig_mppc
3776 rm $DIR/$tfile || error "rm $DIR/$tfile failed"
3778 run_test 49 "Change max_pages_per_rpc won't break osc extent"
3782 test_mkdir $DIR/$tdir
3784 ls /proc/$$/cwd || error "ls /proc/$$/cwd failed"
3786 run_test 50 "special situations: /proc symlinks ==============="
3788 test_51a() { # was test_51
3789 # bug 1516 - create an empty entry right after ".." then split dir
3790 test_mkdir -p $DIR/$tdir
3791 touch $DIR/$tdir/foo
3792 $MCREATE $DIR/$tdir/bar
3794 createmany -m $DIR/$tdir/longfile 201
3796 while [ $(ls -sd $DIR/$tdir | awk '{ print $1 }') -eq 4 ]; do
3797 $MCREATE $DIR/$tdir/longfile$FNUM
3802 ls -l $DIR/$tdir > /dev/null || error "ls -l $DIR/$tdir failed"
3804 run_test 51a "special situations: split htree with empty entry =="
3806 export NUMTEST=70000
3808 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3809 local BASE=$DIR/d${base}.${TESTSUITE}
3811 # cleanup the directory
3816 local mdtidx=$(printf "%04x" $($LFS getstripe -M $BASE))
3817 local numfree=$(lctl get_param -n mdc.$FSNAME-MDT$mdtidx*.filesfree)
3818 [ $numfree -lt 21000 ] && skip "not enough free inodes ($numfree)" &&
3821 [ $numfree -lt $NUMTEST ] && NUMTEST=$(($numfree - 50)) &&
3822 echo "reduced count to $NUMTEST due to inodes"
3824 # need to check free space for the directories as well
3825 local blkfree=$(lctl get_param -n mdc.$FSNAME-MDT$mdtidx*.kbytesavail)
3826 numfree=$((blkfree / 4))
3827 [ $numfree -lt $NUMTEST ] && NUMTEST=$(($numfree - 50)) &&
3828 echo "reduced count to $NUMTEST due to blocks"
3830 createmany -d $BASE/d $NUMTEST && echo $NUMTEST > $BASE/fnum ||
3831 echo "failed" > $BASE/fnum
3833 run_test 51b "exceed 64k subdirectory nlink limit"
3835 test_51ba() { # LU-993
3836 local BASE=$DIR/d${base}.${TESTSUITE}
3837 # unlink all but 100 subdirectories, then check it still works
3839 [ -f $BASE/fnum ] && local NUMPREV=$(cat $BASE/fnum) && rm $BASE/fnum
3841 [ "$NUMPREV" != "failed" ] && NUMTEST=$NUMPREV
3842 local DELETE=$((NUMTEST - LEFT))
3844 # continue on to run this test even if 51b didn't finish,
3845 # just to delete the many subdirectories created.
3846 [ ! -d "${BASE}/d1" ] && skip "test_51b() not run" && return 0
3848 # for ldiskfs the nlink count should be 1, but this is OSD specific
3849 # and so this is listed for informational purposes only
3850 echo "nlink before: $(stat -c %h $BASE), created before: $NUMTEST"
3851 unlinkmany -d $BASE/d $DELETE
3854 if [ $RC -ne 0 ]; then
3855 if [ "$NUMPREV" == "failed" ]; then
3856 skip "previous setup failed"
3859 error "unlink of first $DELETE subdirs failed"
3864 echo "nlink between: $(stat -c %h $BASE)"
3865 # trim the first line of ls output
3866 local FOUND=$(($(ls -l ${BASE} | wc -l) - 1))
3867 [ $FOUND -ne $LEFT ] &&
3868 error "can't find subdirs: found only $FOUND/$LEFT"
3870 unlinkmany -d $BASE/d $DELETE $LEFT ||
3871 error "unlink of second $LEFT subdirs failed"
3872 # regardless of whether the backing filesystem tracks nlink accurately
3873 # or not, the nlink count shouldn't be more than "." and ".." here
3874 local AFTER=$(stat -c %h $BASE)
3875 [ $AFTER -gt 2 ] && error "nlink after: $AFTER > 2" ||
3876 echo "nlink after: $AFTER"
3878 run_test 51ba "verify nlink for many subdirectory cleanup"
3881 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3882 [ "$OSTCOUNT" -lt "3" ] && skip_env "skipping test with few OSTs" && return
3883 test_mkdir -p $DIR/$tdir
3884 createmany -o $DIR/$tdir/t- 1000
3885 $GETSTRIPE $DIR/$tdir > $TMP/files
3886 for N in `seq 0 $((OSTCOUNT - 1))`; do
3887 OBJS[$N]=`awk -vobjs=0 '($1 == '$N') { objs += 1 } END { print objs;}' $TMP/files`
3888 OBJS0[$N]=`grep -A 1 idx $TMP/files | awk -vobjs=0 '($1 == '$N') { objs += 1 } END { print objs;}'`
3889 log "OST$N has ${OBJS[$N]} objects, ${OBJS0[$N]} are index 0"
3891 unlinkmany $DIR/$tdir/t- 1000
3894 for N in `seq 1 $((OSTCOUNT - 1))`; do
3895 [ ${OBJS[$N]} -lt $((${OBJS[$NLAST]} - 20)) ] && \
3896 error "OST $N has less objects vs OST $NLAST (${OBJS[$N]} < ${OBJS[$NLAST]}"
3897 [ ${OBJS[$N]} -gt $((${OBJS[$NLAST]} + 20)) ] && \
3898 error "OST $N has less objects vs OST $NLAST (${OBJS[$N]} < ${OBJS[$NLAST]}"
3900 [ ${OBJS0[$N]} -lt $((${OBJS0[$NLAST]} - 20)) ] && \
3901 error "OST $N has less #0 objects vs OST $NLAST (${OBJS0[$N]} < ${OBJS0[$NLAST]}"
3902 [ ${OBJS0[$N]} -gt $((${OBJS0[$NLAST]} + 20)) ] && \
3903 error "OST $N has less #0 objects vs OST $NLAST (${OBJS0[$N]} < ${OBJS0[$NLAST]}"
3907 run_test 51d "check object distribution ===================="