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 &>/dev/null &&
488 TESTS="59 60 61 4062 4063"
491 local SYMNAME=$(str_repeat 'x' $i)
492 ln -s $SYMNAME $DIR/$tdir/f$i || error "failed $i-char symlink"
493 readlink $DIR/$tdir/f$i || error "failed $i-char readlink"
496 run_test 17g "symlinks: really long symlink name and inode boundaries"
498 test_17h() { #bug 17378
499 remote_mds_nodsh && skip "remote MDS with nodsh" && return
500 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
502 test_mkdir -p $DIR/$tdir
503 if [[ $MDSCOUNT -gt 1 ]]; then
504 mdt_idx=$($LFS getdirstripe -i $DIR/$tdir)
508 $SETSTRIPE -c -1 $DIR/$tdir
509 #define OBD_FAIL_MDS_LOV_PREP_CREATE 0x141
510 do_facet mds$((mdt_idx + 1)) lctl set_param fail_loc=0x80000141
511 touch $DIR/$tdir/$tfile || true
513 run_test 17h "create objects: lov_free_memmd() doesn't lbug"
515 test_17i() { #bug 20018
516 remote_mds_nodsh && skip "remote MDS with nodsh" && return
517 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
518 test_mkdir -p $DIR/$tdir
519 local foo=$DIR/$tdir/$tfile
521 if [[ $MDSCOUNT -gt 1 ]]; then
522 mdt_idx=$($LFS getdirstripe -i $DIR/$tdir)
526 ln -s $foo $foo || error "create symlink failed"
527 #define OBD_FAIL_MDS_READLINK_EPROTO 0x143
528 do_facet mds$((mdt_idx + 1)) lctl set_param fail_loc=0x80000143
529 ls -l $foo && error "error not detected"
532 run_test 17i "don't panic on short symlink"
534 test_17k() { #bug 22301
535 [[ -z "$(which rsync 2>/dev/null)" ]] &&
536 skip "no rsync command" && return 0
537 rsync --help | grep -q xattr ||
538 skip_env "$(rsync --version | head -n1) does not support xattrs"
539 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return 0
540 test_mkdir -p $DIR/$tdir
541 test_mkdir -p $DIR/$tdir.new
542 touch $DIR/$tdir/$tfile
543 ln -s $DIR/$tdir/$tfile $DIR/$tdir/$tfile.lnk
544 rsync -av -X $DIR/$tdir/ $DIR/$tdir.new ||
545 error "rsync failed with xattrs enabled"
547 run_test 17k "symlinks: rsync with xattrs enabled ========================="
549 test_17l() { # LU-279
550 [[ -z "$(which getfattr 2>/dev/null)" ]] &&
551 skip "no getfattr command" && return 0
553 touch $DIR/$tdir/$tfile
554 ln -s $DIR/$tdir/$tfile $DIR/$tdir/$tfile.lnk
555 for path in "$DIR/$tdir" "$DIR/$tdir/$tfile" "$DIR/$tdir/$tfile.lnk"; do
556 # -h to not follow symlinks. -m '' to list all the xattrs.
557 # grep to remove first line: '# file: $path'.
558 for xattr in `getfattr -hm '' $path 2>/dev/null | grep -v '^#'`;
560 lgetxattr_size_check $path $xattr ||
561 error "lgetxattr_size_check $path $xattr failed"
565 run_test 17l "Ensure lgetxattr's returned xattr size is consistent ========"
569 local short_sym="0123456789"
570 local WDIR=$DIR/${tdir}m
577 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] &&
578 [ $(lustre_version_code $SINGLEMDS) -le $(version_code 2.2.93) ] &&
579 skip "MDS 2.2.0-2.2.93 do not NUL-terminate symlinks" && return
581 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
582 skip "only for ldiskfs MDT" && return 0
584 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
588 # create a long symlink file
589 for ((i = 0; i < 4; ++i)); do
590 long_sym=${long_sym}${long_sym}
593 echo "create 512 short and long symlink files under $WDIR"
594 for ((i = 0; i < 256; ++i)); do
595 ln -sf ${long_sym}"a5a5" $WDIR/long-$i
596 ln -sf ${short_sym}"a5a5" $WDIR/short-$i
602 wait_delete_completed
604 echo "recreate the 512 symlink files with a shorter string"
605 for ((i = 0; i < 512; ++i)); do
606 # rewrite the symlink file with a shorter string
607 ln -sf ${long_sym} $WDIR/long-$i
608 ln -sf ${short_sym} $WDIR/short-$i
611 mds_index=$($LFS getstripe -M $WDIR)
612 mds_index=$((mds_index+1))
613 devname=$(mdsdevname $mds_index)
614 cmd="$E2FSCK -fnvd $devname"
616 echo "stop and checking mds${mds_index}: $cmd"
617 # e2fsck should not return error
619 do_facet mds${mds_index} $cmd || rc=$?
621 start mds${mds_index} $devname $MDS_MOUNT_OPTS
622 df $MOUNT > /dev/null 2>&1
623 [ $rc -ne 0 ] && error "e2fsck should not report error upon "\
624 "short/long symlink MDT: rc=$rc"
627 run_test 17m "run e2fsck against MDT which contains short/long symlink"
629 check_fs_consistency_17n() {
635 # create/unlink in 17n only change 2 MDTs(MDT1/MDT2),
636 # so it only check MDT1/MDT2 instead of all of MDTs.
637 for mdt_index in $(seq 1 2); do
638 devname=$(mdsdevname $mdt_index)
639 cmd="$E2FSCK -fnvd $devname"
641 echo "stop and checking mds${mdt_index}: $cmd"
642 # e2fsck should not return error
644 do_facet mds${mdt_index} $cmd || rc=$?
646 start mds${mdt_index} $devname $MDS_MOUNT_OPTS
647 df $MOUNT > /dev/null 2>&1
648 [ $rc -ne 0 ] && break
656 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] &&
657 [ $(lustre_version_code $SINGLEMDS) -le $(version_code 2.2.93) ] &&
658 skip "MDS 2.2.0-2.2.93 do not NUL-terminate symlinks" && return
660 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
661 skip "only for ldiskfs MDT" && return 0
663 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 2 MDTs" && return
665 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
668 for ((i=0; i<10; i++)); do
669 $LFS mkdir -i 1 $DIR/$tdir/remote_dir_${i} ||
670 error "create remote dir error $i"
671 createmany -o $DIR/$tdir/remote_dir_${i}/f 10 ||
672 error "create files under remote dir failed $i"
675 check_fs_consistency_17n ||
676 error "e2fsck report error after create files under remote dir"
678 for ((i=0;i<10;i++)); do
679 rm -rf $DIR/$tdir/remote_dir_${i} ||
680 error "destroy remote dir error $i"
683 check_fs_consistency_17n ||
684 error "e2fsck report error after unlink files under remote dir"
686 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.50) ] &&
687 skip "lustre < 2.4.50 does not support migrate mv " && return
689 for ((i=0; i<10; i++)); do
690 mkdir -p $DIR/$tdir/remote_dir_${i}
691 createmany -o $DIR/$tdir/remote_dir_${i}/f 10 ||
692 error "create files under remote dir failed $i"
693 $LFS mv -M 1 $DIR/$tdir/remote_dir_${i} ||
694 error "migrate remote dir error $i"
696 check_fs_consistency_17n || error "e2fsck report error after migration"
698 for ((i=0;i<10;i++)); do
699 rm -rf $DIR/$tdir/remote_dir_${i} ||
700 error "destroy remote dir error $i"
703 check_fs_consistency_17n || error "e2fsck report error after unlink"
705 run_test 17n "run e2fsck against master/slave MDT which contains remote dir"
708 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.3.64) ] &&
709 skip "Need MDS version at least 2.3.64" && return
711 local WDIR=$DIR/${tdir}o
717 mdt_index=$($LFS getstripe -M $WDIR)
718 mdt_index=$((mdt_index+1))
719 mdtdevname=$(mdsdevname $mdt_index)
723 start mds${mdt_index} $mdtdevname $MDS_MOUNT_OPTS
725 #define OBD_FAIL_OSD_LMA_INCOMPAT 0x194
726 do_facet mds${mdt_index} lctl set_param fail_loc=0x194
727 ls -l $WDIR/$tfile && rc=1
728 do_facet mds${mdt_index} lctl set_param fail_loc=0
729 [[ $rc -ne 0 ]] && error "stat file should fail"
732 run_test 17o "stat file with incompat LMA feature"
735 touch $DIR/f || error "Failed to touch $DIR/f: $?"
736 ls $DIR || error "Failed to ls $DIR: $?"
738 run_test 18 "touch .../f ; ls ... =============================="
744 $CHECKSTAT -a $DIR/$tfile || error "$tfile was not removed"
746 run_test 19a "touch .../f19 ; ls -l ... ; rm .../f19 ==========="
749 ls -l $DIR/$tfile && error "ls -l $tfile failed"|| true
751 run_test 19b "ls -l .../f19 (should return error) =============="
754 [ $RUNAS_ID -eq $UID ] &&
755 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
756 $RUNAS touch $DIR/$tfile && error "create non-root file failed" || true
758 run_test 19c "$RUNAS touch .../f19 (should return error) =="
761 cat $DIR/f19 && error || true
763 run_test 19d "cat .../f19 (should return error) =============="
775 $CHECKSTAT -a $DIR/$tfile || error "$tfile was not removed"
777 run_test 20 "touch .../f ; ls -l ... ==========================="
780 test_mkdir -p $DIR/$tdir
781 [ -f $DIR/$tdir/dangle ] && rm -f $DIR/$tdir/dangle
782 ln -s dangle $DIR/$tdir/link
783 echo foo >> $DIR/$tdir/link
784 cat $DIR/$tdir/dangle
785 $CHECKSTAT -t link $DIR/$tdir/link || error "$tdir/link not a link"
786 $CHECKSTAT -f -t file $DIR/$tdir/link ||
787 error "$tdir/link not linked to a file"
789 run_test 21 "write to dangling link ============================"
793 test_mkdir -p $DIR/$tdir
794 chown $RUNAS_ID:$RUNAS_GID $WDIR
795 (cd $WDIR || error "cd $WDIR failed";
796 $RUNAS tar cf - /etc/hosts /etc/sysconfig/network | \
798 ls -lR $WDIR/etc || error "ls -lR $WDIR/etc failed"
799 $CHECKSTAT -t dir $WDIR/etc || error "checkstat -t dir failed"
800 $CHECKSTAT -u \#$RUNAS_ID -g \#$RUNAS_GID $WDIR/etc || error "checkstat -u failed"
802 run_test 22 "unpack tar archive as non-root user ==============="
806 test_mkdir -p $DIR/$tdir
807 local file=$DIR/$tdir/$tfile
809 openfile -f O_CREAT:O_EXCL $file || error "$file create failed"
810 openfile -f O_CREAT:O_EXCL $file &&
811 error "$file recreate succeeded" || true
813 run_test 23a "O_CREAT|O_EXCL in subdir =========================="
815 test_23b() { # bug 18988
816 test_mkdir -p $DIR/$tdir
817 local file=$DIR/$tdir/$tfile
820 echo foo > $file || error "write filed"
821 echo bar >> $file || error "append filed"
822 $CHECKSTAT -s 8 $file || error "wrong size"
825 run_test 23b "O_APPEND check =========================="
829 echo '-- same directory rename'
830 test_mkdir $DIR/$tdir
831 touch $DIR/$tdir/$tfile.1
832 mv $DIR/$tdir/$tfile.1 $DIR/$tdir/$tfile.2
833 $CHECKSTAT -t file $DIR/$tdir/$tfile.2 || error "$tfile.2 not a file"
835 run_test 24a "rename file to non-existent target"
838 test_mkdir $DIR/$tdir
839 touch $DIR/$tdir/$tfile.{1,2}
840 mv $DIR/$tdir/$tfile.1 $DIR/$tdir/$tfile.2
841 $CHECKSTAT -a $DIR/$tdir/$tfile.1 || error "$tfile.1 exists"
842 $CHECKSTAT -t file $DIR/$tdir/$tfile.2 || error "$tfile.2 not a file"
844 run_test 24b "rename file to existing target"
847 test_mkdir $DIR/$tdir
848 test_mkdir $DIR/$tdir/d$testnum.1
849 mv $DIR/$tdir/d$testnum.1 $DIR/$tdir/d$testnum.2
850 $CHECKSTAT -a $DIR/$tdir/d$testnum.1 || error "d$testnum.1 exists"
851 $CHECKSTAT -t dir $DIR/$tdir/d$testnum.2 || error "d$testnum.2 not dir"
853 run_test 24c "rename directory to non-existent target"
856 test_mkdir -c1 $DIR/$tdir
857 test_mkdir -c1 $DIR/$tdir/d$testnum.1
858 test_mkdir -c1 $DIR/$tdir/d$testnum.2
859 mrename $DIR/$tdir/d$testnum.1 $DIR/$tdir/d$testnum.2
860 $CHECKSTAT -a $DIR/$tdir/d$testnum.1 || error "d$testnum.1 exists"
861 $CHECKSTAT -t dir $DIR/$tdir/d$testnum.2 || error "d$testnum.2 not dir"
863 run_test 24d "rename directory to existing target"
866 echo '-- cross directory renames --'
870 mv $DIR/R5a/f $DIR/R5b/g
871 $CHECKSTAT -a $DIR/R5a/f || error
872 $CHECKSTAT -t file $DIR/R5b/g || error
874 run_test 24e "touch .../R5a/f; rename .../R5a/f .../R5b/g ======"
879 touch $DIR/R6a/f $DIR/R6b/g
880 mv $DIR/R6a/f $DIR/R6b/g
881 $CHECKSTAT -a $DIR/R6a/f || error
882 $CHECKSTAT -t file $DIR/R6b/g || error
884 run_test 24f "touch .../R6a/f R6b/g; mv .../R6a/f .../R6b/g ===="
889 test_mkdir $DIR/R7a/d
890 mv $DIR/R7a/d $DIR/R7b/e
891 $CHECKSTAT -a $DIR/R7a/d || error
892 $CHECKSTAT -t dir $DIR/R7b/e || error
894 run_test 24g "mkdir .../R7{a,b}/d; mv .../R7a/d .../R7b/e ======"
897 test_mkdir -c1 $DIR/R8a
898 test_mkdir -c1 $DIR/R8b
899 test_mkdir -c1 $DIR/R8a/d
900 test_mkdir -c1 $DIR/R8b/e
901 mrename $DIR/R8a/d $DIR/R8b/e
902 $CHECKSTAT -a $DIR/R8a/d || error
903 $CHECKSTAT -t dir $DIR/R8b/e || error
905 run_test 24h "mkdir .../R8{a,b}/{d,e}; rename .../R8a/d .../R8b/e"
908 echo "-- rename error cases"
912 mrename $DIR/R9/f $DIR/R9/a
913 $CHECKSTAT -t file $DIR/R9/f || error
914 $CHECKSTAT -t dir $DIR/R9/a || error
915 $CHECKSTAT -a $DIR/R9/a/f || error
917 run_test 24i "rename file to dir error: touch f ; mkdir a ; rename f a"
921 mrename $DIR/R10/f $DIR/R10/g
922 $CHECKSTAT -t dir $DIR/R10 || error
923 $CHECKSTAT -a $DIR/R10/f || error
924 $CHECKSTAT -a $DIR/R10/g || error
926 run_test 24j "source does not exist ============================"
930 test_mkdir $DIR/R11a/d
932 mv $DIR/R11a/f $DIR/R11a/d
933 $CHECKSTAT -a $DIR/R11a/f || error
934 $CHECKSTAT -t file $DIR/R11a/d/f || error
936 run_test 24k "touch .../R11a/f; mv .../R11a/f .../R11a/d ======="
938 # bug 2429 - rename foo foo foo creates invalid file
941 $MULTIOP $f OcNs || error
943 run_test 24l "Renaming a file to itself ========================"
947 $MULTIOP $f OcLN ${f}2 ${f}2 || error "link ${f}2 ${f}2 failed"
948 # on ext3 this does not remove either the source or target files
949 # though the "expected" operation would be to remove the source
950 $CHECKSTAT -t file ${f} || error "${f} missing"
951 $CHECKSTAT -t file ${f}2 || error "${f}2 missing"
953 run_test 24m "Renaming a file to a hard link to itself ========="
957 # this stats the old file after it was renamed, so it should fail
961 $CHECKSTAT ${f}.rename
964 run_test 24n "Statting the old file after renaming (Posix rename 2)"
967 check_kernel_version 37 || return 0
968 test_mkdir -p $DIR/d24o
969 rename_many -s random -v -n 10 $DIR/d24o
971 run_test 24o "rename of files during htree split ==============="
976 DIRINO=`ls -lid $DIR/R12a | awk '{ print $1 }'`
977 mrename $DIR/R12a $DIR/R12b
978 $CHECKSTAT -a $DIR/R12a || error
979 $CHECKSTAT -t dir $DIR/R12b || error
980 DIRINO2=`ls -lid $DIR/R12b | awk '{ print $1 }'`
981 [ "$DIRINO" = "$DIRINO2" ] || error "R12a $DIRINO != R12b $DIRINO2"
983 run_test 24p "mkdir .../R12{a,b}; rename .../R12a .../R12b"
985 cleanup_multiop_pause() {
991 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
994 local DIRINO=$(ls -lid $DIR/R13a | awk '{ print $1 }')
995 multiop_bg_pause $DIR/R13b D_c || error "multiop failed to start"
998 trap cleanup_multiop_pause EXIT
999 mrename $DIR/R13a $DIR/R13b
1000 $CHECKSTAT -a $DIR/R13a || error "R13a still exists"
1001 $CHECKSTAT -t dir $DIR/R13b || error "R13b does not exist"
1002 local DIRINO2=$(ls -lid $DIR/R13b | awk '{ print $1 }')
1003 [ "$DIRINO" = "$DIRINO2" ] || error "R13a $DIRINO != R13b $DIRINO2"
1004 cleanup_multiop_pause
1005 wait $MULTIPID || error "multiop close failed"
1007 run_test 24q "mkdir .../R13{a,b}; open R13b rename R13a R13b ==="
1009 test_24r() { #bug 3789
1010 test_mkdir $DIR/R14a
1011 test_mkdir $DIR/R14a/b
1012 mrename $DIR/R14a $DIR/R14a/b && error "rename to subdir worked!"
1013 $CHECKSTAT -t dir $DIR/R14a || error "$DIR/R14a missing"
1014 $CHECKSTAT -t dir $DIR/R14a/b || error "$DIR/R14a/b missing"
1016 run_test 24r "mkdir .../R14a/b; rename .../R14a .../R14a/b ====="
1019 test_mkdir $DIR/R15a
1020 test_mkdir $DIR/R15a/b
1021 test_mkdir $DIR/R15a/b/c
1022 mrename $DIR/R15a $DIR/R15a/b/c && error "rename to sub-subdir worked!"
1023 $CHECKSTAT -t dir $DIR/R15a || error "$DIR/R15a missing"
1024 $CHECKSTAT -t dir $DIR/R15a/b/c || error "$DIR/R15a/b/c missing"
1026 run_test 24s "mkdir .../R15a/b/c; rename .../R15a .../R15a/b/c ="
1028 test_mkdir $DIR/R16a
1029 test_mkdir $DIR/R16a/b
1030 test_mkdir $DIR/R16a/b/c
1031 mrename $DIR/R16a/b/c $DIR/R16a && error "rename to sub-subdir worked!"
1032 $CHECKSTAT -t dir $DIR/R16a || error "$DIR/R16a missing"
1033 $CHECKSTAT -t dir $DIR/R16a/b/c || error "$DIR/R16a/b/c missing"
1035 run_test 24t "mkdir .../R16a/b/c; rename .../R16a/b/c .../R16a ="
1037 test_24u() { # bug12192
1039 $MULTIOP $DIR/$tfile C2w$((2048 * 1024))c || error
1040 $CHECKSTAT -s $((2048 * 1024)) $DIR/$tfile || error "wrong file size"
1042 run_test 24u "create stripe file"
1048 simple_cleanup_common() {
1051 wait_delete_completed
1054 max_pages_per_rpc() {
1055 $LCTL get_param -n mdc.*.max_pages_per_rpc | head -n1
1059 local NRFILES=100000
1060 local FREE_INODES=$(mdt_free_inodes 0)
1061 [[ $FREE_INODES -lt $NRFILES ]] &&
1062 skip "not enough free inodes $FREE_INODES required $NRFILES" &&
1065 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1066 trap simple_cleanup_common EXIT
1068 # Performance issue on ZFS see LU-4072 (c.f. LU-2887)
1069 [ $(facet_fstype $SINGLEMDS) = "zfs" ] && NRFILES=10000
1072 createmany -m $DIR/$tdir/$tfile $NRFILES
1074 cancel_lru_locks mdc
1075 lctl set_param mdc.*.stats clear
1077 ls $DIR/$tdir >/dev/null || error "error in listing large dir"
1079 # LU-5 large readdir
1080 # DIRENT_SIZE = 32 bytes for sizeof(struct lu_dirent) +
1081 # 8 bytes for name(filename is mostly 5 in this test) +
1082 # 8 bytes for luda_type
1083 # take into account of overhead in lu_dirpage header and end mark in
1084 # each page, plus one in RPC_NUM calculation.
1086 RPC_SIZE=$(($(max_pages_per_rpc) * $(page_size)))
1087 RPC_NUM=$(((NRFILES * DIRENT_SIZE + RPC_SIZE - 1) / RPC_SIZE + 1))
1088 mds_readpage=$(lctl get_param mdc.*MDT0000*.stats |
1089 awk '/^mds_readpage/ {print $2}')
1090 [[ $mds_readpage -gt $RPC_NUM ]] &&
1091 error "large readdir doesn't take effect"
1093 simple_cleanup_common
1095 run_test 24v "list directory with large files (handle hash collision, bug: 17560)"
1097 test_24w() { # bug21506
1099 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=4096 || return 1
1100 dd if=/dev/zero bs=$SZ1 count=1 >> $DIR/$tfile || return 2
1101 dd if=$DIR/$tfile of=$DIR/${tfile}_left bs=1M skip=4097 || return 3
1102 SZ2=`ls -l $DIR/${tfile}_left | awk '{print $5}'`
1103 [ "$SZ1" = "$SZ2" ] || \
1104 error "Error reading at the end of the file $tfile"
1106 run_test 24w "Reading a file larger than 4Gb"
1109 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 2 MDTs" && return
1110 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1112 local remote_dir=$DIR/$tdir/remote_dir
1115 $LFS mkdir -i $MDTIDX $remote_dir ||
1116 error "create remote directory failed"
1118 mkdir -p $DIR/$tdir/src_dir
1119 touch $DIR/$tdir/src_file
1120 mkdir -p $remote_dir/tgt_dir
1121 touch $remote_dir/tgt_file
1123 mrename $remote_dir $DIR/ &&
1124 error "rename dir cross MDT works!"
1126 mrename $DIR/$tdir/src_dir $remote_dir/tgt_dir &&
1127 error "rename dir cross MDT works!"
1129 mrename $DIR/$tdir/src_file $remote_dir/tgt_file &&
1130 error "rename file cross MDT works!"
1132 ln $DIR/$tdir/src_file $remote_dir/tgt_file1 &&
1133 error "ln file cross MDT should not work!"
1135 rm -rf $DIR/$tdir || error "Can not delete directories"
1137 run_test 24x "cross rename/link should be failed"
1140 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 2 MDTs" && return
1141 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1143 local remote_dir=$DIR/$tdir/remote_dir
1146 $LFS mkdir -i $MDTIDX $remote_dir ||
1147 error "create remote directory failed"
1149 mkdir -p $remote_dir/src_dir
1150 touch $remote_dir/src_file
1151 mkdir -p $remote_dir/tgt_dir
1152 touch $remote_dir/tgt_file
1154 mrename $remote_dir/src_dir $remote_dir/tgt_dir ||
1155 error "rename subdir in the same remote dir failed!"
1157 mrename $remote_dir/src_file $remote_dir/tgt_file ||
1158 error "rename files in the same remote dir failed!"
1160 ln $remote_dir/tgt_file $remote_dir/tgt_file1 ||
1161 error "link files in the same remote dir failed!"
1163 rm -rf $DIR/$tdir || error "Can not delete directories"
1165 run_test 24y "rename/link on the same dir should succeed"
1168 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 2 MDTs" && return
1169 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1171 local remote_src=$DIR/$tdir/remote_dir
1172 local remote_tgt=$DIR/$tdir/remote_tgt
1175 $LFS mkdir -i $MDTIDX $remote_src ||
1176 error "create remote directory failed"
1178 $LFS mkdir -i $MDTIDX $remote_tgt ||
1179 error "create remote directory failed"
1181 mrename $remote_src $remote_tgt &&
1182 error "rename remote dirs should not work!"
1184 # If target dir does not exists, it should succeed
1186 mrename $remote_src $remote_tgt ||
1187 error "rename remote dirs(tgt dir does not exists) failed!"
1189 rm -rf $DIR/$tdir || error "Can not delete directories"
1191 run_test 24z "rename one remote dir to another remote dir should fail"
1193 test_24A() { # LU-3182
1198 createmany -m $DIR/$tdir/$tfile $NFILES
1199 local t=`ls $DIR/$tdir | wc -l`
1200 local u=`ls $DIR/$tdir | sort -u | wc -l`
1201 if [ $t -ne $NFILES -o $u -ne $NFILES ] ; then
1202 error "Expected $NFILES files, got $t ($u unique)"
1205 rm -rf $DIR/$tdir || error "Can not delete directories"
1207 run_test 24A "readdir() returns correct number of entries."
1210 echo '== symlink sanity ============================================='
1214 touch $DIR/s25/foo || error
1216 run_test 25a "create file in symlinked directory ==============="
1219 [ ! -d $DIR/d25 ] && test_25a
1220 $CHECKSTAT -t file $DIR/s25/foo || error
1222 run_test 25b "lookup file in symlinked directory ==============="
1226 test_mkdir $DIR/d26/d26-2
1227 ln -s d26/d26-2 $DIR/s26
1228 touch $DIR/s26/foo || error
1230 run_test 26a "multiple component symlink ======================="
1233 test_mkdir -p $DIR/d26b/d26-2
1234 ln -s d26b/d26-2/foo $DIR/s26-2
1235 touch $DIR/s26-2 || error
1237 run_test 26b "multiple component symlink at end of lookup ======"
1240 test_mkdir $DIR/d26.2
1241 touch $DIR/d26.2/foo
1242 ln -s d26.2 $DIR/s26.2-1
1243 ln -s s26.2-1 $DIR/s26.2-2
1244 ln -s s26.2-2 $DIR/s26.2-3
1245 chmod 0666 $DIR/s26.2-3/foo
1247 run_test 26c "chain of symlinks ================================"
1249 # recursive symlinks (bug 439)
1251 ln -s d26-3/foo $DIR/d26-3
1253 run_test 26d "create multiple component recursive symlink ======"
1256 [ ! -h $DIR/d26-3 ] && test_26d
1259 run_test 26e "unlink multiple component recursive symlink ======"
1261 # recursive symlinks (bug 7022)
1263 test_mkdir -p $DIR/$tdir
1264 test_mkdir $DIR/$tdir/$tfile || error "mkdir $DIR/$tdir/$tfile failed"
1265 cd $DIR/$tdir/$tfile || error "cd $DIR/$tdir/$tfile failed"
1266 test_mkdir -p lndir/bar1 || error "mkdir lndir/bar1 failed"
1267 test_mkdir $DIR/$tdir/$tfile/$tfile || error "mkdir $tfile failed"
1268 cd $tfile || error "cd $tfile failed"
1269 ln -s .. dotdot || error "ln dotdot failed"
1270 ln -s dotdot/lndir lndir || error "ln lndir failed"
1271 cd $DIR/$tdir || error "cd $DIR/$tdir failed"
1272 output=`ls $tfile/$tfile/lndir/bar1`
1273 [ "$output" = bar1 ] && error "unexpected output"
1274 rm -r $tfile || error "rm $tfile failed"
1275 $CHECKSTAT -a $DIR/$tfile || error "$tfile not gone"
1277 run_test 26f "rm -r of a directory which has recursive symlink ="
1280 echo '== stripe sanity =============================================='
1281 test_mkdir -p $DIR/d27 || error "mkdir failed"
1283 $SETSTRIPE -c 1 $DIR/d27/f0 || error "setstripe failed"
1284 $CHECKSTAT -t file $DIR/d27/f0 || error "checkstat failed"
1285 log "== test_27a: write to one stripe file ========================="
1286 cp /etc/hosts $DIR/d27/f0 || error
1288 run_test 27a "one stripe file =================================="
1291 [[ $OSTCOUNT -lt 2 ]] && skip_env "skipping 2-stripe test" && return
1292 test_mkdir -p $DIR/d27
1293 $SETSTRIPE -c 2 $DIR/d27/f01 || error "setstripe failed"
1294 $GETSTRIPE -c $DIR/d27/f01
1295 [ $($GETSTRIPE -c $DIR/d27/f01) -eq 2 ] ||
1296 error "two-stripe file doesn't have two stripes"
1298 dd if=/dev/zero of=$DIR/d27/f01 bs=4k count=4 || error "dd failed"
1300 run_test 27b "create and write to two stripe file"
1303 test_mkdir -p $DIR/d27
1304 $SETSTRIPE -c 0 -i -1 -S 0 $DIR/d27/fdef || error "setstripe failed"
1305 $CHECKSTAT -t file $DIR/d27/fdef || error "checkstat failed"
1306 dd if=/dev/zero of=$DIR/d27/fdef bs=4k count=4 || error
1308 run_test 27d "create file with default settings ================"
1311 test_mkdir -p $DIR/d27
1312 $SETSTRIPE -c 2 $DIR/d27/f12 || error "setstripe failed"
1313 $SETSTRIPE -c 2 $DIR/d27/f12 && error "setstripe succeeded twice"
1314 $CHECKSTAT -t file $DIR/d27/f12 || error "checkstat failed"
1316 run_test 27e "setstripe existing file (should return error) ======"
1319 test_mkdir -p $DIR/d27
1320 $SETSTRIPE -S 100 -i 0 -c 1 $DIR/d27/fbad && error "setstripe failed"
1321 dd if=/dev/zero of=$DIR/d27/fbad bs=4k count=4 || error "dd failed"
1322 $GETSTRIPE $DIR/d27/fbad || error "$GETSTRIPE failed"
1324 run_test 27f "setstripe with bad stripe size (should return error)"
1327 test_mkdir -p $DIR/d27
1328 $MCREATE $DIR/d27/fnone || error "mcreate failed"
1329 $GETSTRIPE $DIR/d27/fnone 2>&1 | grep "no stripe info" ||
1330 error "$DIR/d27/fnone has object"
1332 run_test 27g "$GETSTRIPE with no objects"
1335 touch $DIR/d27/fsome || error "touch failed"
1336 [[ $($GETSTRIPE -c $DIR/d27/fsome) -gt 0 ]] || error "missing objects"
1338 run_test 27i "$GETSTRIPE with some objects"
1341 test_mkdir -p $DIR/d27
1342 $SETSTRIPE -i $OSTCOUNT $DIR/d27/f27j && error "setstripe failed"||true
1344 run_test 27j "setstripe with bad stripe offset (should return error)"
1346 test_27k() { # bug 2844
1347 test_mkdir -p $DIR/d27
1349 LL_MAX_BLKSIZE=$((4 * 1024 * 1024))
1350 [ ! -d $DIR/d27 ] && test_mkdir -p $DIR d27
1351 $SETSTRIPE -S 67108864 $FILE || error "setstripe failed"
1352 BLKSIZE=`stat $FILE | awk '/IO Block:/ { print $7 }'`
1353 [ $BLKSIZE -le $LL_MAX_BLKSIZE ] || error "1:$BLKSIZE > $LL_MAX_BLKSIZE"
1354 dd if=/dev/zero of=$FILE bs=4k count=1
1355 BLKSIZE=`stat $FILE | awk '/IO Block:/ { print $7 }'`
1356 [ $BLKSIZE -le $LL_MAX_BLKSIZE ] || error "2:$BLKSIZE > $LL_MAX_BLKSIZE"
1358 run_test 27k "limit i_blksize for broken user apps ============="
1361 test_mkdir -p $DIR/d27
1362 mcreate $DIR/f27l || error "creating file"
1363 $RUNAS $SETSTRIPE -c 1 $DIR/f27l && \
1364 error "setstripe should have failed" || true
1366 run_test 27l "check setstripe permissions (should return error)"
1369 [[ $OSTCOUNT -lt 2 ]] && skip_env "$OSTCOUNT < 2 OSTs -- skipping" &&
1371 if [[ $ORIGFREE -gt $MAXFREE ]]; then
1372 skip "$ORIGFREE > $MAXFREE skipping out-of-space test on OST0"
1375 trap simple_cleanup_common EXIT
1376 test_mkdir -p $DIR/$tdir
1377 $SETSTRIPE -i 0 -c 1 $DIR/$tdir/f27m_1
1378 dd if=/dev/zero of=$DIR/$tdir/f27m_1 bs=1024 count=$MAXFREE &&
1379 error "dd should fill OST0"
1381 while $SETSTRIPE -i 0 -c 1 $DIR/$tdir/f27m_$i; do
1383 [ $i -gt 256 ] && break
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"
1390 touch $DIR/$tdir/f27m_$i
1391 [ `$GETSTRIPE $DIR/$tdir/f27m_$i | grep -A 10 obdidx | awk '{print $1}'| grep -w "0"` ] &&
1392 error "OST0 was full but new created file still use it"
1393 simple_cleanup_common
1395 run_test 27m "create file while OST0 was full =================="
1398 local DELAY=$(do_facet $SINGLEMDS lctl get_param -n lov.*.qos_maxage | head -n 1 | awk '{print $1 * 2}')
1402 # OSCs keep a NOSPC flag that will be reset after ~5s (qos_maxage)
1403 # if the OST isn't full anymore.
1405 local OSTIDX=${1:-""}
1407 local list=$(comma_list $(osts_nodes))
1408 [ "$OSTIDX" ] && list=$(facet_host ost$((OSTIDX + 1)))
1410 do_nodes $list lctl set_param fail_loc=0
1411 sync # initiate all OST_DESTROYs from MDS to OST
1415 exhaust_precreations() {
1418 local FAILIDX=${3:-$OSTIDX}
1420 test_mkdir -p $DIR/$tdir
1421 local MDSIDX=$(get_mds_dir "$DIR/$tdir")
1422 echo OSTIDX=$OSTIDX MDSIDX=$MDSIDX
1424 local OST=$(ostname_from_index $OSTIDX)
1425 local MDT_INDEX=$(lfs df | grep "\[MDT:$((MDSIDX - 1))\]" | awk '{print $1}' | \
1426 sed -e 's/_UUID$//;s/^.*-//')
1429 local mdtosc_proc1=$(get_mdtosc_proc_path mds${MDSIDX} $OST)
1430 local last_id=$(do_facet mds${MDSIDX} lctl get_param -n \
1431 osc.$mdtosc_proc1.prealloc_last_id)
1432 local next_id=$(do_facet mds${MDSIDX} lctl get_param -n \
1433 osc.$mdtosc_proc1.prealloc_next_id)
1435 local mdtosc_proc2=$(get_mdtosc_proc_path mds${MDSIDX})
1436 do_facet mds${MDSIDX} lctl get_param osc.$mdtosc_proc2.prealloc*
1438 test_mkdir -p $DIR/$tdir/${OST}
1439 $SETSTRIPE -i $OSTIDX -c 1 $DIR/$tdir/${OST}
1440 #define OBD_FAIL_OST_ENOSPC 0x215
1441 do_facet ost$((OSTIDX + 1)) lctl set_param fail_val=$FAILIDX
1442 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=0x215
1443 echo "Creating to objid $last_id on ost $OST..."
1444 createmany -o $DIR/$tdir/${OST}/f $next_id $((last_id - next_id + 2))
1445 do_facet mds${MDSIDX} lctl get_param osc.$mdtosc_proc2.prealloc*
1446 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=$FAILLOC
1450 exhaust_all_precreations() {
1452 for (( i=0; i < OSTCOUNT; i++ )) ; do
1453 exhaust_precreations $i $1 -1
1458 [[ $OSTCOUNT -lt 2 ]] && skip_env "too few OSTs" && return
1459 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1460 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1461 remote_ost_nodsh && skip "remote OST with nodsh" && return
1464 rm -f $DIR/$tdir/$tfile
1465 exhaust_precreations 0 0x80000215
1466 $SETSTRIPE -c -1 $DIR/$tdir
1467 touch $DIR/$tdir/$tfile || error
1468 $GETSTRIPE $DIR/$tdir/$tfile
1471 run_test 27n "create file with some full OSTs =================="
1474 [[ $OSTCOUNT -lt 2 ]] && skip_env "too few OSTs" && return
1475 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1476 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1477 remote_ost_nodsh && skip "remote OST with nodsh" && return
1480 rm -f $DIR/$tdir/$tfile
1481 exhaust_all_precreations 0x215
1483 touch $DIR/$tdir/$tfile && error "able to create $DIR/$tdir/$tfile"
1488 run_test 27o "create file with all full OSTs (should error) ===="
1491 [[ $OSTCOUNT -lt 2 ]] && skip_env "too few OSTs" && return
1492 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1493 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1494 remote_ost_nodsh && skip "remote OST with nodsh" && return
1497 rm -f $DIR/$tdir/$tfile
1498 test_mkdir -p $DIR/$tdir
1500 $MCREATE $DIR/$tdir/$tfile || error "mcreate failed"
1501 $TRUNCATE $DIR/$tdir/$tfile 80000000 || error "truncate failed"
1502 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat failed"
1504 exhaust_precreations 0 0x80000215
1505 echo foo >> $DIR/$tdir/$tfile || error "append failed"
1506 $CHECKSTAT -s 80000004 $DIR/$tdir/$tfile || error "checkstat failed"
1507 $GETSTRIPE $DIR/$tdir/$tfile
1511 run_test 27p "append to a truncated file with some full OSTs ==="
1514 [[ $OSTCOUNT -lt 2 ]] && skip_env "too few OSTs" && return
1515 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1516 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1517 remote_ost_nodsh && skip "remote OST with nodsh" && return
1520 rm -f $DIR/$tdir/$tfile
1522 test_mkdir -p $DIR/$tdir
1523 $MCREATE $DIR/$tdir/$tfile || error "mcreate $DIR/$tdir/$tfile failed"
1524 $TRUNCATE $DIR/$tdir/$tfile 80000000 ||error "truncate $DIR/$tdir/$tfile failed"
1525 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat failed"
1527 exhaust_all_precreations 0x215
1529 echo foo >> $DIR/$tdir/$tfile && error "append succeeded"
1530 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat 2 failed"
1534 run_test 27q "append to truncated file with all OSTs full (should error) ==="
1537 [[ $OSTCOUNT -lt 2 ]] && skip_env "too few OSTs" && return
1538 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1539 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1540 remote_ost_nodsh && skip "remote OST with nodsh" && return
1543 rm -f $DIR/$tdir/$tfile
1544 exhaust_precreations 0 0x80000215
1546 $SETSTRIPE -i 0 -c 2 $DIR/$tdir/$tfile # && error
1550 run_test 27r "stripe file with some full OSTs (shouldn't LBUG) ="
1552 test_27s() { # bug 10725
1553 test_mkdir -p $DIR/$tdir
1554 local stripe_size=$((4096 * 1024 * 1024)) # 2^32
1555 local stripe_count=0
1556 [ $OSTCOUNT -eq 1 ] || stripe_count=2
1557 $SETSTRIPE -S $stripe_size -c $stripe_count $DIR/$tdir &&
1558 error "stripe width >= 2^32 succeeded" || true
1561 run_test 27s "lsm_xfersize overflow (should error) (bug 10725)"
1563 test_27t() { # bug 10864
1568 $WLFS getstripe $tfile
1571 run_test 27t "check that utils parse path correctly"
1573 test_27u() { # bug 4900
1574 [[ $OSTCOUNT -lt 2 ]] && skip_env "too few OSTs" && return
1575 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1577 local list=$(comma_list $(mdts_nodes))
1579 #define OBD_FAIL_MDS_OSC_PRECREATE 0x139
1580 do_nodes $list $LCTL set_param fail_loc=0x139
1581 test_mkdir -p $DIR/$tdir
1583 createmany -o $DIR/$tdir/t- 1000
1584 do_nodes $list $LCTL set_param fail_loc=0
1586 TLOG=$DIR/$tfile.getstripe
1587 $GETSTRIPE $DIR/$tdir > $TLOG
1588 OBJS=$(awk -vobj=0 '($1 == 0) { obj += 1 } END { print obj; }' $TLOG)
1589 unlinkmany $DIR/$tdir/t- 1000
1590 [[ $OBJS -gt 0 ]] &&
1591 error "$OBJS objects created on OST-0. See $TLOG" || pass
1593 run_test 27u "skip object creation on OSC w/o objects =========="
1595 test_27v() { # bug 4900
1596 [[ $OSTCOUNT -lt 2 ]] && skip_env "too few OSTs" && return
1597 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1598 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1599 remote_ost_nodsh && skip "remote OST with nodsh" && return
1601 exhaust_all_precreations 0x215
1604 test_mkdir -p $DIR/$tdir
1605 $SETSTRIPE -c 1 $DIR/$tdir # 1 stripe / file
1607 touch $DIR/$tdir/$tfile
1608 #define OBD_FAIL_TGT_DELAY_PRECREATE 0x705
1610 for (( i=1; i < OSTCOUNT; i++ )); do
1611 do_facet ost$i lctl set_param fail_loc=0x705
1613 local START=`date +%s`
1614 createmany -o $DIR/$tdir/$tfile 32
1616 local FINISH=`date +%s`
1617 local TIMEOUT=`lctl get_param -n timeout`
1618 local PROCESS=$((FINISH - START))
1619 [ $PROCESS -ge $((TIMEOUT / 2)) ] && \
1620 error "$FINISH - $START >= $TIMEOUT / 2"
1621 sleep $((TIMEOUT / 2 - PROCESS))
1624 run_test 27v "skip object creation on slow OST ================="
1626 test_27w() { # bug 10997
1627 test_mkdir -p $DIR/$tdir || error "mkdir failed"
1628 $SETSTRIPE -S 65536 $DIR/$tdir/f0 || error "setstripe failed"
1629 [ $($GETSTRIPE -S $DIR/$tdir/f0) -ne 65536 ] &&
1630 error "stripe size $size != 65536" || true
1631 [ $($GETSTRIPE -d $DIR/$tdir | grep -c "stripe_count") -ne 1 ] &&
1632 error "$GETSTRIPE -d $DIR/$tdir failed" || true
1634 run_test 27w "check $SETSTRIPE -S option"
1637 [[ $OSTCOUNT -lt 2 ]] &&
1638 skip_env "skipping multiple stripe count/offset test" && return
1640 test_mkdir -p $DIR/$tdir || error "mkdir failed"
1641 for i in $(seq 1 $OSTCOUNT); do
1643 $SETSTRIPE -c $i -i $offset $DIR/$tdir/f$i ||
1644 error "setstripe -c $i -i $offset failed"
1645 count=$($GETSTRIPE -c $DIR/$tdir/f$i)
1646 index=$($GETSTRIPE -i $DIR/$tdir/f$i)
1647 [ $count -ne $i ] && error "stripe count $count != $i" || true
1648 [ $index -ne $offset ] &&
1649 error "stripe offset $index != $offset" || true
1652 run_test 27wa "check $SETSTRIPE -c -i options"
1655 remote_ost_nodsh && skip "remote OST with nodsh" && return
1656 [[ $OSTCOUNT -lt 2 ]] && skip_env "$OSTCOUNT < 2 OSTs" && return
1657 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1658 OFFSET=$(($OSTCOUNT - 1))
1660 local OST=$(ostname_from_index $OSTIDX)
1662 test_mkdir -p $DIR/$tdir
1663 $SETSTRIPE -c 1 $DIR/$tdir # 1 stripe per file
1664 do_facet ost$((OSTIDX + 1)) lctl set_param -n obdfilter.$OST.degraded 1
1666 createmany -o $DIR/$tdir/$tfile $OSTCOUNT
1667 for i in `seq 0 $OFFSET`; do
1668 [ `$GETSTRIPE $DIR/$tdir/$tfile$i | grep -A 10 obdidx | awk '{print $1}' | grep -w "$OSTIDX"` ] &&
1669 error "OST0 was degraded but new created file still use it"
1671 do_facet ost$((OSTIDX + 1)) lctl set_param -n obdfilter.$OST.degraded 0
1673 run_test 27x "create files while OST0 is degraded"
1676 [[ $OSTCOUNT -lt 2 ]] &&
1677 skip_env "$OSTCOUNT < 2 OSTs -- skipping" && return
1678 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1679 remote_ost_nodsh && skip "remote OST with nodsh" && return
1680 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1682 local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS $FSNAME-OST0000)
1683 local last_id=$(do_facet $SINGLEMDS lctl get_param -n \
1684 osc.$mdtosc.prealloc_last_id)
1685 local next_id=$(do_facet $SINGLEMDS lctl get_param -n \
1686 osc.$mdtosc.prealloc_next_id)
1687 local fcount=$((last_id - next_id))
1688 [[ $fcount -eq 0 ]] && skip "not enough space on OST0" && return
1689 [[ $fcount -gt $OSTCOUNT ]] && fcount=$OSTCOUNT
1691 local MDS_OSCS=$(do_facet $SINGLEMDS lctl dl |
1692 awk '/[oO][sS][cC].*md[ts]/ { print $4 }')
1693 local OST_DEACTIVE_IDX=-1
1698 for OSC in $MDS_OSCS; do
1699 OST=$(osc_to_ost $OSC)
1700 OSTIDX=$(index_from_ostuuid $OST)
1701 if [ $OST_DEACTIVE_IDX == -1 ]; then
1702 OST_DEACTIVE_IDX=$OSTIDX
1704 if [ $OSTIDX != $OST_DEACTIVE_IDX ]; then
1705 echo $OSC "is Deactivated:"
1706 do_facet $SINGLEMDS lctl --device %$OSC deactivate
1710 OSTIDX=$(index_from_ostuuid $OST)
1712 $SETSTRIPE -c 1 $DIR/$tdir # 1 stripe / file
1714 for OSC in $MDS_OSCS; do
1715 OST=$(osc_to_ost $OSC)
1716 OSTIDX=$(index_from_ostuuid $OST)
1717 if [ $OSTIDX == $OST_DEACTIVE_IDX ]; then
1718 echo $OST "is degraded:"
1719 do_facet ost$((OSTIDX+1)) lctl set_param -n \
1720 obdfilter.$OST.degraded=1
1725 createmany -o $DIR/$tdir/$tfile $fcount
1727 for OSC in $MDS_OSCS; do
1728 OST=$(osc_to_ost $OSC)
1729 OSTIDX=$(index_from_ostuuid $OST)
1730 if [ $OSTIDX == $OST_DEACTIVE_IDX ]; then
1731 echo $OST "is recovered from degraded:"
1732 do_facet ost$((OSTIDX+1)) lctl set_param -n \
1733 obdfilter.$OST.degraded=0
1735 do_facet $SINGLEMDS lctl --device %$OSC activate
1739 # all osp devices get activated, hence -1 stripe count restored
1742 # sleep 2*lod_qos_maxage seconds waiting for lod qos to notice osp
1743 # devices get activated.
1745 $SETSTRIPE -c -1 $DIR/$tfile
1746 stripecnt=$($GETSTRIPE -c $DIR/$tfile)
1748 [ $stripecnt -ne $OSTCOUNT ] &&
1749 error "Of $OSTCOUNT OSTs, only $stripecnt is available"
1752 run_test 27y "create files while OST0 is degraded and the rest inactive"
1758 lmm_count=$($GETSTRIPE -c $1)
1759 lmm_seq=$($GETSTRIPE -v $1 | awk '/lmm_seq/ { print $2 }')
1760 lmm_oid=$($GETSTRIPE -v $1 | awk '/lmm_object_id/ { print $2 }')
1762 local old_ifs="$IFS"
1764 fid=($($LFS path2fid $1))
1767 log "FID seq ${fid[1]}, oid ${fid[2]} ver ${fid[3]}"
1768 log "LOV seq $lmm_seq, oid $lmm_oid, count: $lmm_count"
1770 # compare lmm_seq and lu_fid->f_seq
1771 [ $lmm_seq = ${fid[1]} ] || { error "SEQ mismatch"; return 1; }
1772 # compare lmm_object_id and lu_fid->oid
1773 [ $lmm_oid = ${fid[2]} ] || { error "OID mismatch"; return 2; }
1775 # check the trusted.fid attribute of the OST objects of the file
1776 local have_obdidx=false
1778 $GETSTRIPE $1 | while read obdidx oid hex seq; do
1779 # skip lines up to and including "obdidx"
1780 [ -z "$obdidx" ] && break
1781 [ "$obdidx" = "obdidx" ] && have_obdidx=true && continue
1782 $have_obdidx || continue
1784 local ost=$((obdidx + 1))
1785 local dev=$(ostdevname $ost)
1788 log "want: stripe:$stripe_nr ost:$obdidx oid:$oid/$hex seq:$seq"
1790 seq=$(echo $seq | sed -e "s/^0x//g")
1791 if [ $seq == 0 ]; then
1792 oid_hex=$(echo $oid)
1794 oid_hex=$(echo $hex | sed -e "s/^0x//g")
1796 local obj_file="O/$seq/d$((oid %32))/$oid_hex"
1800 # Don't unmount/remount the OSTs if we don't need to do that.
1801 # LU-2577 changes filter_fid to be smaller, so debugfs needs
1802 # update too, until that use mount/ll_decode_filter_fid/mount.
1803 # Re-enable when debugfs will understand new filter_fid.
1805 if false && [ $(facet_fstype ost$ost) == ldiskfs ]; then
1806 ff=$(do_facet ost$ost "$DEBUGFS -c -R 'stat $obj_file' \
1807 $dev 2>/dev/null" | grep "parent=")
1810 mount_fstype ost$ost
1811 ff=$(do_facet ost$ost $LL_DECODE_FILTER_FID \
1812 $(facet_mntpt ost$ost)/$obj_file)
1813 unmount_fstype ost$ost
1814 start ost$ost $dev $OST_MOUNT_OPTS
1817 [ -z "$ff" ] && error "$obj_file: no filter_fid info"
1819 echo "$ff" | sed -e 's#.*objid=#got: objid=#'
1821 # /mnt/O/0/d23/23: objid=23 seq=0 parent=[0x200000400:0x1e:0x1]
1822 # fid: objid=23 seq=0 parent=[0x200000400:0x1e:0x0] stripe=1
1823 local ff_parent=$(echo $ff|sed -e 's/.*parent=.//')
1824 local ff_pseq=$(echo $ff_parent | cut -d: -f1)
1825 local ff_poid=$(echo $ff_parent | cut -d: -f2)
1827 if echo $ff_parent | grep -q 'stripe='; then
1828 ff_pstripe=$(echo $ff_parent | sed -e 's/.*stripe=//')
1831 # $LL_DECODE_FILTER_FID does not print "stripe="; look
1832 # into f_ver in this case. See the comment on
1835 ff_pstripe=$(echo $ff_parent | cut -d: -f3 |
1839 # compare lmm_seq and filter_fid->ff_parent.f_seq
1840 [ $ff_pseq = $lmm_seq ] ||
1841 error "FF parent SEQ $ff_pseq != $lmm_seq"
1842 # compare lmm_object_id and filter_fid->ff_parent.f_oid
1843 [ $ff_poid = $lmm_oid ] ||
1844 error "FF parent OID $ff_poid != $lmm_oid"
1845 (($ff_pstripe == $stripe_nr)) ||
1846 error "FF stripe $ff_pstripe != $stripe_nr"
1848 stripe_nr=$((stripe_nr + 1))
1853 remote_ost_nodsh && skip "remote OST with nodsh" && return
1854 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1855 test_mkdir -p $DIR/$tdir
1857 $SETSTRIPE -c 1 -i 0 -S 64k $DIR/$tdir/$tfile-1 ||
1858 { error "setstripe -c -1 failed"; return 1; }
1859 # We need to send a write to every object to get parent FID info set.
1860 # This _should_ also work for setattr, but does not currently.
1861 # touch $DIR/$tdir/$tfile-1 ||
1862 dd if=/dev/zero of=$DIR/$tdir/$tfile-1 bs=1M count=1 ||
1863 { error "dd $tfile-1 failed"; return 2; }
1864 $SETSTRIPE -c -1 -i $((OSTCOUNT - 1)) -S 1M $DIR/$tdir/$tfile-2 ||
1865 { error "setstripe -c -1 failed"; return 3; }
1866 dd if=/dev/zero of=$DIR/$tdir/$tfile-2 bs=1M count=$OSTCOUNT ||
1867 { error "dd $tfile-2 failed"; return 4; }
1869 # make sure write RPCs have been sent to OSTs
1872 check_seq_oid $DIR/$tdir/$tfile-1 || return 5
1873 check_seq_oid $DIR/$tdir/$tfile-2 || return 6
1875 run_test 27z "check SEQ/OID on the MDT and OST filesystems"
1877 test_27A() { # b=19102
1878 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1879 local restore_size=$($GETSTRIPE -S $MOUNT)
1880 local restore_count=$($GETSTRIPE -c $MOUNT)
1881 local restore_offset=$($GETSTRIPE -i $MOUNT)
1882 $SETSTRIPE -c 0 -i -1 -S 0 $MOUNT
1883 wait_update $HOSTNAME "$GETSTRIPE -c $MOUNT | sed 's/ *//g'" "1" 20 ||
1884 error "stripe count $($GETSTRIPE -c $MOUNT) != 1"
1885 local default_size=$($GETSTRIPE -S $MOUNT)
1886 local default_offset=$($GETSTRIPE -i $MOUNT)
1887 local dsize=$((1024 * 1024))
1888 [ $default_size -eq $dsize ] ||
1889 error "stripe size $default_size != $dsize"
1890 [ $default_offset -eq -1 ] ||error "stripe offset $default_offset != -1"
1891 $SETSTRIPE -c $restore_count -i $restore_offset -S $restore_size $MOUNT
1893 run_test 27A "check filesystem-wide default LOV EA values"
1895 test_27B() { # LU-2523
1896 test_mkdir -p $DIR/$tdir
1897 rm -f $DIR/$tdir/f0 $DIR/$tdir/f1
1899 # open f1 with O_LOV_DELAY_CREATE
1901 # call setstripe ioctl on open file descriptor for f1
1903 multiop $DIR/$tdir/f1 oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:nB1c \
1907 # open f1 with O_LOV_DELAY_CREATE
1909 # call setstripe ioctl on open file descriptor for f1
1911 multiop $DIR/$tdir/f1 oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:uB1c
1913 # Allow multiop to fail in imitation of NFS's busted semantics.
1916 run_test 27B "call setstripe on open unlinked file/rename victim"
1918 test_27C() { #LU-2871
1919 [[ $OSTCOUNT -lt 2 ]] && skip "needs >= 2 OSTs" && return
1927 test_mkdir -p $DIR/$tdir
1929 for i in $(seq 0 $((OSTCOUNT - 1))); do
1930 # set stripe across all OSTs starting from OST$i
1931 $SETSTRIPE -i $i -c -1 $tfile$i
1932 # get striping information
1933 ost_idx=($($GETSTRIPE $tfile$i |
1934 tail -n $((OSTCOUNT + 1)) | awk '{print $1}'))
1938 [ ${#ost_idx[@]} -eq $OSTCOUNT ] ||
1939 error "${#ost_idx[@]} != $OSTCOUNT"
1941 for index in $(seq 0 $((OSTCOUNT - 1))); do
1943 for j in $(echo ${ost_idx[@]}); do
1944 if [ $index -eq $j ]; then
1950 error "Can not find $index in ${ost_idx[@]}"
1954 run_test 27C "check full striping across all OSTs"
1956 # createtest also checks that device nodes are created and
1957 # then visible correctly (#2091)
1958 test_28() { # bug 2091
1960 $CREATETEST $DIR/d28/ct || error
1962 run_test 28 "create/mknod/mkdir with bad file types ============"
1965 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1966 cancel_lru_locks mdc
1972 declare -i LOCKCOUNTORIG=0
1973 for lock_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_count); do
1974 let LOCKCOUNTORIG=$LOCKCOUNTORIG+$lock_count
1976 [ $LOCKCOUNTORIG -eq 0 ] && echo "No mdc lock count" && return 1
1978 declare -i LOCKUNUSEDCOUNTORIG=0
1979 for unused_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_unused_count); do
1980 let LOCKUNUSEDCOUNTORIG=$LOCKUNUSEDCOUNTORIG+$unused_count
1987 declare -i LOCKCOUNTCURRENT=0
1988 for lock_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_count); do
1989 let LOCKCOUNTCURRENT=$LOCKCOUNTCURRENT+$lock_count
1992 declare -i LOCKUNUSEDCOUNTCURRENT=0
1993 for unused_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_unused_count); do
1994 let LOCKUNUSEDCOUNTCURRENT=$LOCKUNUSEDCOUNTCURRENT+$unused_count
1997 if [[ $LOCKCOUNTCURRENT -gt $LOCKCOUNTORIG ]]; then
1998 $LCTL set_param -n ldlm.dump_namespaces ""
1999 error "CURRENT: $LOCKCOUNTCURRENT > $LOCKCOUNTORIG"
2000 $LCTL dk | sort -k4 -t: > $TMP/test_29.dk
2001 log "dumped log to $TMP/test_29.dk (bug 5793)"
2004 if [[ $LOCKUNUSEDCOUNTCURRENT -gt $LOCKUNUSEDCOUNTORIG ]]; then
2005 error "UNUSED: $LOCKUNUSEDCOUNTCURRENT > $LOCKUNUSEDCOUNTORIG"
2006 $LCTL dk | sort -k4 -t: > $TMP/test_29.dk
2007 log "dumped log to $TMP/test_29.dk (bug 5793)"
2011 run_test 29 "IT_GETATTR regression ============================"
2013 test_30a() { # was test_30
2014 cp $(which ls) $DIR || cp /bin/ls $DIR
2018 run_test 30a "execute binary from Lustre (execve) =============="
2021 cp `which ls` $DIR || cp /bin/ls $DIR
2023 $RUNAS $DIR/ls / || error
2026 run_test 30b "execute binary from Lustre as non-root ==========="
2028 test_30c() { # b=22376
2029 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2030 cp `which ls` $DIR || cp /bin/ls $DIR
2032 cancel_lru_locks mdc
2033 cancel_lru_locks osc
2034 $RUNAS $DIR/ls / || error
2037 run_test 30c "execute binary from Lustre without read perms ===="
2040 $OPENUNLINK $DIR/f31 $DIR/f31 || error
2041 $CHECKSTAT -a $DIR/f31 || error
2043 run_test 31a "open-unlink file =================================="
2046 touch $DIR/f31 || error
2047 ln $DIR/f31 $DIR/f31b || error
2048 $MULTIOP $DIR/f31b Ouc || error
2049 $CHECKSTAT -t file $DIR/f31 || error
2051 run_test 31b "unlink file with multiple links while open ======="
2054 touch $DIR/f31 || error
2055 ln $DIR/f31 $DIR/f31c || error
2056 multiop_bg_pause $DIR/f31 O_uc || return 1
2058 $MULTIOP $DIR/f31c Ouc
2059 kill -USR1 $MULTIPID
2062 run_test 31c "open-unlink file with multiple links ============="
2065 opendirunlink $DIR/d31d $DIR/d31d || error
2066 $CHECKSTAT -a $DIR/d31d || error
2068 run_test 31d "remove of open directory ========================="
2070 test_31e() { # bug 2904
2071 check_kernel_version 34 || return 0
2072 openfilleddirunlink $DIR/d31e || error
2074 run_test 31e "remove of open non-empty directory ==============="
2076 test_31f() { # bug 4554
2077 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2079 test_mkdir $DIR/d31f
2080 $SETSTRIPE -S 1048576 -c 1 $DIR/d31f
2081 cp /etc/hosts $DIR/d31f
2083 $GETSTRIPE $DIR/d31f/hosts
2084 multiop_bg_pause $DIR/d31f D_c || return 1
2087 rm -rv $DIR/d31f || error "first of $DIR/d31f"
2088 test_mkdir $DIR/d31f
2089 $SETSTRIPE -S 1048576 -c 1 $DIR/d31f
2090 cp /etc/hosts $DIR/d31f
2092 $GETSTRIPE $DIR/d31f/hosts
2093 multiop_bg_pause $DIR/d31f D_c || return 1
2096 kill -USR1 $MULTIPID || error "first opendir $MULTIPID not running"
2097 wait $MULTIPID || error "first opendir $MULTIPID failed"
2101 kill -USR1 $MULTIPID2 || error "second opendir $MULTIPID not running"
2102 wait $MULTIPID2 || error "second opendir $MULTIPID2 failed"
2105 run_test 31f "remove of open directory with open-unlink file ==="
2108 echo "-- cross directory link --"
2109 test_mkdir -c1 $DIR/${tdir}ga
2110 test_mkdir -c1 $DIR/${tdir}gb
2111 touch $DIR/${tdir}ga/f
2112 ln $DIR/${tdir}ga/f $DIR/${tdir}gb/g
2113 $CHECKSTAT -t file $DIR/${tdir}ga/f || error "source"
2114 [ `stat -c%h $DIR/${tdir}ga/f` == '2' ] || error "source nlink"
2115 $CHECKSTAT -t file $DIR/${tdir}gb/g || error "target"
2116 [ `stat -c%h $DIR/${tdir}gb/g` == '2' ] || error "target nlink"
2118 run_test 31g "cross directory link==============="
2121 echo "-- cross directory link --"
2122 test_mkdir -c1 $DIR/${tdir}
2123 test_mkdir -c1 $DIR/${tdir}/dir
2124 touch $DIR/${tdir}/f
2125 ln $DIR/${tdir}/f $DIR/${tdir}/dir/g
2126 $CHECKSTAT -t file $DIR/${tdir}/f || error "source"
2127 [ `stat -c%h $DIR/${tdir}/f` == '2' ] || error "source nlink"
2128 $CHECKSTAT -t file $DIR/${tdir}/dir/g || error "target"
2129 [ `stat -c%h $DIR/${tdir}/dir/g` == '2' ] || error "target nlink"
2131 run_test 31h "cross directory link under child==============="
2134 echo "-- cross directory link --"
2135 test_mkdir -c1 $DIR/$tdir
2136 test_mkdir -c1 $DIR/$tdir/dir
2137 touch $DIR/$tdir/dir/f
2138 ln $DIR/$tdir/dir/f $DIR/$tdir/g
2139 $CHECKSTAT -t file $DIR/$tdir/dir/f || error "source"
2140 [ `stat -c%h $DIR/$tdir/dir/f` == '2' ] || error "source nlink"
2141 $CHECKSTAT -t file $DIR/$tdir/g || error "target"
2142 [ `stat -c%h $DIR/$tdir/g` == '2' ] || error "target nlink"
2144 run_test 31i "cross directory link under parent==============="
2147 test_mkdir -c1 -p $DIR/$tdir
2148 test_mkdir -c1 -p $DIR/$tdir/dir1
2149 ln $DIR/$tdir/dir1 $DIR/$tdir/dir2 && error "ln for dir"
2150 link $DIR/$tdir/dir1 $DIR/$tdir/dir3 && error "link for dir"
2151 mlink $DIR/$tdir/dir1 $DIR/$tdir/dir4 && error "mlink for dir"
2152 mlink $DIR/$tdir/dir1 $DIR/$tdir/dir1 && error "mlink to the same dir"
2155 run_test 31j "link for directory==============="
2158 test_mkdir -c1 -p $DIR/$tdir
2160 touch $DIR/$tdir/exist
2161 mlink $DIR/$tdir/s $DIR/$tdir/t || error "mlink"
2162 mlink $DIR/$tdir/s $DIR/$tdir/exist && error "mlink to exist file"
2163 mlink $DIR/$tdir/s $DIR/$tdir/s && error "mlink to the same file"
2164 mlink $DIR/$tdir/s $DIR/$tdir && error "mlink to parent dir"
2165 mlink $DIR/$tdir $DIR/$tdir/s && error "mlink parent dir to target"
2166 mlink $DIR/$tdir/not-exist $DIR/$tdir/foo && error "mlink non-existing to new"
2167 mlink $DIR/$tdir/not-exist $DIR/$tdir/s && error "mlink non-existing to exist"
2170 run_test 31k "link to file: the same, non-existing, dir==============="
2176 touch $DIR/d31m2/exist
2177 mlink $DIR/d31m/s $DIR/d31m2/t || error "mlink"
2178 mlink $DIR/d31m/s $DIR/d31m2/exist && error "mlink to exist file"
2179 mlink $DIR/d31m/s $DIR/d31m2 && error "mlink to parent dir"
2180 mlink $DIR/d31m2 $DIR/d31m/s && error "mlink parent dir to target"
2181 mlink $DIR/d31m/not-exist $DIR/d31m2/foo && error "mlink non-existing to new"
2182 mlink $DIR/d31m/not-exist $DIR/d31m2/s && error "mlink non-existing to exist"
2185 run_test 31m "link to file: the same, non-existing, dir==============="
2188 touch $DIR/$tfile || error "cannot create '$DIR/$tfile'"
2189 nlink=$(stat --format=%h $DIR/$tfile)
2190 [ ${nlink:--1} -eq 1 ] || error "nlink is $nlink, expected 1"
2192 local cmd="exec $fd<$DIR/$tfile"
2195 trap "eval $cmd" EXIT
2196 nlink=$(stat --dereference --format=%h /proc/self/fd/$fd)
2197 [ ${nlink:--1} -eq 1 ] || error "nlink is $nlink, expected 1"
2198 rm $DIR/$tfile || error "cannot remove '$DIR/$tfile'"
2199 nlink=$(stat --dereference --format=%h /proc/self/fd/$fd)
2200 [ ${nlink:--1} -eq 0 ] || error "nlink is $nlink, expected 0"
2203 run_test 31n "check link count of unlinked file"
2206 local TEMPNAME=$(mktemp $1_XXXXXX)
2207 mlink $TEMPNAME $1 2> /dev/null &&
2208 echo "$BASHPID: link $TEMPNAME to $1 succeeded"
2212 test_31o() { # LU-2901
2214 for LOOP in $(seq 100); do
2215 rm -f $DIR/$tdir/$tfile*
2216 for THREAD in $(seq 8); do
2217 link_one $DIR/$tdir/$tfile.$LOOP &
2220 local LINKS=$(ls -1 $DIR/$tdir | grep -c $tfile.$LOOP)
2221 [[ $LINKS -gt 1 ]] && ls $DIR/$tdir &&
2222 error "$LINKS duplicate links to $tfile.$LOOP" &&
2226 run_test 31o "duplicate hard links with same filename"
2228 cleanup_test32_mount() {
2230 $UMOUNT -d $DIR/$tdir/ext2-mountpoint
2234 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2235 echo "== more mountpoints and symlinks ================="
2236 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2237 trap cleanup_test32_mount EXIT
2238 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2239 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2240 $CHECKSTAT -t dir $DIR/$tdir/ext2-mountpoint/.. || error
2241 cleanup_test32_mount
2243 run_test 32a "stat d32a/ext2-mountpoint/.. ====================="
2246 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2247 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2248 trap cleanup_test32_mount EXIT
2249 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2250 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2251 ls -al $DIR/$tdir/ext2-mountpoint/.. || error
2252 cleanup_test32_mount
2254 run_test 32b "open d32b/ext2-mountpoint/.. ====================="
2257 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2258 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2259 trap cleanup_test32_mount EXIT
2260 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2261 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2262 test_mkdir -p $DIR/$tdir/d2/test_dir
2263 $CHECKSTAT -t dir $DIR/$tdir/ext2-mountpoint/../d2/test_dir || error
2264 cleanup_test32_mount
2266 run_test 32c "stat d32c/ext2-mountpoint/../d2/test_dir ========="
2269 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2270 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2271 trap cleanup_test32_mount EXIT
2272 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2273 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2274 test_mkdir -p $DIR/$tdir/d2/test_dir
2275 ls -al $DIR/$tdir/ext2-mountpoint/../d2/test_dir || error
2276 cleanup_test32_mount
2278 run_test 32d "open d32d/ext2-mountpoint/../d2/test_dir ========="
2281 [ -e $DIR/d32e ] && rm -fr $DIR/d32e
2282 test_mkdir -p $DIR/d32e/tmp
2283 TMP_DIR=$DIR/d32e/tmp
2284 ln -s $DIR/d32e $TMP_DIR/symlink11
2285 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
2286 $CHECKSTAT -t link $DIR/d32e/tmp/symlink11 || error
2287 $CHECKSTAT -t link $DIR/d32e/symlink01 || error
2289 run_test 32e "stat d32e/symlink->tmp/symlink->lustre-subdir ===="
2292 [ -e $DIR/d32f ] && rm -fr $DIR/d32f
2293 test_mkdir -p $DIR/d32f/tmp
2294 TMP_DIR=$DIR/d32f/tmp
2295 ln -s $DIR/d32f $TMP_DIR/symlink11
2296 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
2297 ls $DIR/d32f/tmp/symlink11 || error
2298 ls $DIR/d32f/symlink01 || error
2300 run_test 32f "open d32f/symlink->tmp/symlink->lustre-subdir ===="
2303 TMP_DIR=$DIR/$tdir/tmp
2304 test_mkdir -p $DIR/$tdir/tmp
2305 test_mkdir $DIR/${tdir}2
2306 ln -s $DIR/${tdir}2 $TMP_DIR/symlink12
2307 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
2308 $CHECKSTAT -t link $TMP_DIR/symlink12 || error
2309 $CHECKSTAT -t link $DIR/$tdir/symlink02 || error
2310 $CHECKSTAT -t dir -f $TMP_DIR/symlink12 || error
2311 $CHECKSTAT -t dir -f $DIR/$tdir/symlink02 || error
2313 run_test 32g "stat d32g/symlink->tmp/symlink->lustre-subdir/${tdir}2"
2316 rm -fr $DIR/$tdir $DIR/${tdir}2
2317 TMP_DIR=$DIR/$tdir/tmp
2318 test_mkdir -p $DIR/$tdir/tmp
2319 test_mkdir $DIR/${tdir}2
2320 ln -s $DIR/${tdir}2 $TMP_DIR/symlink12
2321 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
2322 ls $TMP_DIR/symlink12 || error
2323 ls $DIR/$tdir/symlink02 || error
2325 run_test 32h "open d32h/symlink->tmp/symlink->lustre-subdir/${tdir}2"
2328 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2329 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2330 trap cleanup_test32_mount EXIT
2331 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2332 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2333 touch $DIR/$tdir/test_file
2334 $CHECKSTAT -t file $DIR/$tdir/ext2-mountpoint/../test_file || error
2335 cleanup_test32_mount
2337 run_test 32i "stat d32i/ext2-mountpoint/../test_file ==========="
2340 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2341 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2342 trap cleanup_test32_mount EXIT
2343 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2344 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2345 touch $DIR/$tdir/test_file
2346 cat $DIR/$tdir/ext2-mountpoint/../test_file || error
2347 cleanup_test32_mount
2349 run_test 32j "open d32j/ext2-mountpoint/../test_file ==========="
2352 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2354 trap cleanup_test32_mount EXIT
2355 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2356 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint
2357 test_mkdir -p $DIR/$tdir/d2
2358 touch $DIR/$tdir/d2/test_file || error
2359 $CHECKSTAT -t file $DIR/$tdir/ext2-mountpoint/../d2/test_file || error
2360 cleanup_test32_mount
2362 run_test 32k "stat d32k/ext2-mountpoint/../d2/test_file ========"
2365 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2367 trap cleanup_test32_mount EXIT
2368 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2369 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2370 test_mkdir -p $DIR/$tdir/d2
2371 touch $DIR/$tdir/d2/test_file
2372 cat $DIR/$tdir/ext2-mountpoint/../d2/test_file || error
2373 cleanup_test32_mount
2375 run_test 32l "open d32l/ext2-mountpoint/../d2/test_file ========"
2379 test_mkdir -p $DIR/d32m/tmp
2380 TMP_DIR=$DIR/d32m/tmp
2381 ln -s $DIR $TMP_DIR/symlink11
2382 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
2383 $CHECKSTAT -t link $DIR/d32m/tmp/symlink11 || error
2384 $CHECKSTAT -t link $DIR/d32m/symlink01 || error
2386 run_test 32m "stat d32m/symlink->tmp/symlink->lustre-root ======"
2390 test_mkdir -p $DIR/d32n/tmp
2391 TMP_DIR=$DIR/d32n/tmp
2392 ln -s $DIR $TMP_DIR/symlink11
2393 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
2394 ls -l $DIR/d32n/tmp/symlink11 || error
2395 ls -l $DIR/d32n/symlink01 || error
2397 run_test 32n "open d32n/symlink->tmp/symlink->lustre-root ======"
2400 rm -fr $DIR/d32o $DIR/$tfile
2402 test_mkdir -p $DIR/d32o/tmp
2403 TMP_DIR=$DIR/d32o/tmp
2404 ln -s $DIR/$tfile $TMP_DIR/symlink12
2405 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
2406 $CHECKSTAT -t link $DIR/d32o/tmp/symlink12 || error
2407 $CHECKSTAT -t link $DIR/d32o/symlink02 || error
2408 $CHECKSTAT -t file -f $DIR/d32o/tmp/symlink12 || error
2409 $CHECKSTAT -t file -f $DIR/d32o/symlink02 || error
2411 run_test 32o "stat d32o/symlink->tmp/symlink->lustre-root/$tfile"
2421 test_mkdir -p $DIR/d32p/tmp
2423 TMP_DIR=$DIR/d32p/tmp
2425 ln -s $DIR/$tfile $TMP_DIR/symlink12
2427 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
2429 cat $DIR/d32p/tmp/symlink12 || error
2431 cat $DIR/d32p/symlink02 || error
2434 run_test 32p "open d32p/symlink->tmp/symlink->lustre-root/$tfile"
2436 cleanup_testdir_mount() {
2438 $UMOUNT -d $DIR/$tdir
2442 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2443 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2444 trap cleanup_testdir_mount EXIT
2445 test_mkdir -p $DIR/$tdir
2446 touch $DIR/$tdir/under_the_mount
2447 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir
2448 ls $DIR/$tdir | grep "\<under_the_mount\>" && error
2449 cleanup_testdir_mount
2451 run_test 32q "stat follows mountpoints in Lustre (should return error)"
2454 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2455 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2456 trap cleanup_testdir_mount EXIT
2457 test_mkdir -p $DIR/$tdir
2458 touch $DIR/$tdir/under_the_mount
2459 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir
2460 ls $DIR/$tdir | grep -q under_the_mount && error || true
2461 cleanup_testdir_mount
2463 run_test 32r "opendir follows mountpoints in Lustre (should return error)"
2468 chmod 444 $DIR/$tfile
2469 chown $RUNAS_ID $DIR/$tfile
2471 $RUNAS $OPENFILE -f O_RDWR $DIR/$tfile && error || true
2474 run_test 33aa "write file with mode 444 (should return error) ===="
2478 test_mkdir -p $DIR/d33
2479 chown $RUNAS_ID $DIR/d33
2480 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $DIR/d33/f33|| error "create"
2481 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $DIR/d33/f33 && \
2482 error "open RDWR" || true
2484 run_test 33a "test open file(mode=0444) with O_RDWR (should return error)"
2488 test_mkdir -p $DIR/d33
2489 chown $RUNAS_ID $DIR/d33
2490 $RUNAS $OPENFILE -f 1286739555 $DIR/d33/f33 && error "create" || true
2492 run_test 33b "test open file with malformed flags (No panic and return error)"
2495 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2501 remote_ost_nodsh && skip "remote OST with nodsh" && return
2504 test_mkdir -p $DIR/d33
2505 # Read: 0, Write: 4, create/destroy: 2/0, stat: 1, punch: 0
2508 for ostnum in $(seq $OSTCOUNT); do
2509 # test-framework's OST numbering is one-based, while Lustre's
2511 ostname=$(printf "$FSNAME-OST%.4x" $((ostnum - 1)))
2512 # Parsing llobdstat's output sucks; we could grep the /proc
2513 # path, but that's likely to not be as portable as using the
2514 # llobdstat utility. So we parse lctl output instead.
2515 write_bytes=$(do_facet ost$ostnum lctl get_param -n \
2516 obdfilter/$ostname/stats |
2517 awk '/^write_bytes/ {print $7}' )
2518 echo "baseline_write_bytes@$OSTnum/$ostname=$write_bytes"
2519 if (( ${write_bytes:-0} > 0 ))
2526 $all_zeros || return 0
2529 echo foo > $DIR/d33/bar
2533 # Total up write_bytes after writing. We'd better find non-zeros.
2534 for ostnum in $(seq $OSTCOUNT); do
2535 ostname=$(printf "$FSNAME-OST%.4x" $((ostnum - 1)))
2536 write_bytes=$(do_facet ost$ostnum lctl get_param -n \
2537 obdfilter/$ostname/stats |
2538 awk '/^write_bytes/ {print $7}' )
2539 echo "write_bytes@$OSTnum/$ostname=$write_bytes"
2540 if (( ${write_bytes:-0} > 0 ))
2549 for ostnum in $(seq $OSTCOUNT); do
2550 ostname=$(printf "$FSNAME-OST%.4x" $((ostnum - 1)))
2551 echo "Check that write_bytes is present in obdfilter/*/stats:"
2552 do_facet ost$ostnum lctl get_param -n \
2553 obdfilter/$ostname/stats
2555 error "OST not keeping write_bytes stats (b22312)"
2558 run_test 33c "test llobdstat and write_bytes"
2561 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 2 MDTs" && return
2562 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2564 local remote_dir=$DIR/$tdir/remote_dir
2567 $LFS mkdir -i $MDTIDX $remote_dir ||
2568 error "create remote directory failed"
2570 touch $remote_dir/$tfile
2571 chmod 444 $remote_dir/$tfile
2572 chown $RUNAS_ID $remote_dir/$tfile
2574 $RUNAS $OPENFILE -f O_RDWR $DIR/$tfile && error || true
2576 chown $RUNAS_ID $remote_dir
2577 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $remote_dir/f33 ||
2578 error "create" || true
2579 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $remote_dir/f33 &&
2580 error "open RDWR" || true
2581 $RUNAS $OPENFILE -f 1286739555 $remote_dir/f33 &&
2582 error "create" || true
2584 run_test 33d "openfile with 444 modes and malformed flags under remote dir"
2586 TEST_34_SIZE=${TEST_34_SIZE:-2000000000000}
2589 $MCREATE $DIR/f34 || error
2590 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" || error
2591 $TRUNCATE $DIR/f34 $TEST_34_SIZE || error
2592 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" || error
2593 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2595 run_test 34a "truncate file that has not been opened ==========="
2598 [ ! -f $DIR/f34 ] && test_34a
2599 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2600 $OPENFILE -f O_RDONLY $DIR/f34
2601 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" || error
2602 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2604 run_test 34b "O_RDONLY opening file doesn't create objects ====="
2607 [ ! -f $DIR/f34 ] && test_34a
2608 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2609 $OPENFILE -f O_RDWR $DIR/f34
2610 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" && error
2611 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2613 run_test 34c "O_RDWR opening file-with-size works =============="
2616 [ ! -f $DIR/f34 ] && test_34a
2617 dd if=/dev/zero of=$DIR/f34 conv=notrunc bs=4k count=1 || error
2618 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2621 run_test 34d "write to sparse file ============================="
2625 $MCREATE $DIR/f34e || error
2626 $TRUNCATE $DIR/f34e 1000 || error
2627 $CHECKSTAT -s 1000 $DIR/f34e || error
2628 $OPENFILE -f O_RDWR $DIR/f34e
2629 $CHECKSTAT -s 1000 $DIR/f34e || error
2631 run_test 34e "create objects, some with size and some without =="
2633 test_34f() { # bug 6242, 6243
2634 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2637 $MCREATE $DIR/f34f || error
2638 $TRUNCATE $DIR/f34f $SIZE34F || error "truncating $DIR/f3f to $SIZE34F"
2639 dd if=$DIR/f34f of=$TMP/f34f
2640 $CHECKSTAT -s $SIZE34F $TMP/f34f || error "$TMP/f34f not $SIZE34F bytes"
2641 dd if=/dev/zero of=$TMP/f34fzero bs=$SIZE34F count=1
2642 cmp $DIR/f34f $TMP/f34fzero || error "$DIR/f34f not all zero"
2643 cmp $TMP/f34f $TMP/f34fzero || error "$TMP/f34f not all zero"
2644 rm $TMP/f34f $TMP/f34fzero $DIR/f34f
2646 run_test 34f "read from a file with no objects until EOF ======="
2649 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2650 dd if=/dev/zero of=$DIR/$tfile bs=1 count=100 seek=$TEST_34_SIZE || error
2651 $TRUNCATE $DIR/$tfile $((TEST_34_SIZE / 2))|| error
2652 $CHECKSTAT -s $((TEST_34_SIZE / 2)) $DIR/$tfile || error "truncate failed"
2653 cancel_lru_locks osc
2654 $CHECKSTAT -s $((TEST_34_SIZE / 2)) $DIR/$tfile || \
2655 error "wrong size after lock cancel"
2657 $TRUNCATE $DIR/$tfile $TEST_34_SIZE || error
2658 $CHECKSTAT -s $TEST_34_SIZE $DIR/$tfile || \
2659 error "expanding truncate failed"
2660 cancel_lru_locks osc
2661 $CHECKSTAT -s $TEST_34_SIZE $DIR/$tfile || \
2662 error "wrong expanded size after lock cancel"
2664 run_test 34g "truncate long file ==============================="
2667 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2671 dd if=/dev/zero of=$DIR/$tfile bs=1M count=10 || error
2672 sync # Flush the cache so that multiop below does not block on cache
2673 # flush when getting the group lock
2674 $MULTIOP $DIR/$tfile OG${gid}T${sz}g${gid}c &
2677 # Since just timed wait is not good enough, let's do a sync write
2678 # that way we are sure enough time for a roundtrip + processing
2679 # passed + 2 seconds of extra margin.
2680 dd if=/dev/zero of=$DIR/${tfile}-1 bs=4096 oflag=direct count=1
2684 if [[ `ps h -o comm -p $MULTIPID` == "multiop" ]]; then
2685 error "Multiop blocked on ftruncate, pid=$MULTIPID"
2689 local nsz=`stat -c %s $DIR/$tfile`
2690 [[ $nsz == $sz ]] || error "New size wrong $nsz != $sz"
2692 run_test 34h "ftruncate file under grouplock should not block"
2695 cp /bin/sh $DIR/f35a
2697 chown $RUNAS_ID $DIR/f35a
2698 $RUNAS $DIR/f35a && error || true
2701 run_test 35a "exec file with mode 444 (should return and not leak) ====="
2705 utime $DIR/f36 || error
2707 run_test 36a "MDS utime check (mknod, utime) ==================="
2711 utime $DIR/f36 || error
2713 run_test 36b "OST utime check (open, utime) ===================="
2718 chown $RUNAS_ID $DIR/d36
2719 $RUNAS utime $DIR/d36/f36 || error
2721 run_test 36c "non-root MDS utime check (mknod, utime) =========="
2724 [ ! -d $DIR/d36 ] && test_36c
2725 echo "" > $DIR/d36/f36
2726 $RUNAS utime $DIR/d36/f36 || error
2728 run_test 36d "non-root OST utime check (open, utime) ==========="
2731 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID -- skipping" && return
2732 test_mkdir -p $DIR/$tdir
2733 touch $DIR/$tdir/$tfile
2734 $RUNAS utime $DIR/$tdir/$tfile && \
2735 error "utime worked, expected failure" || true
2737 run_test 36e "utime on non-owned file (should return error) ===="
2741 local LANG_SAVE=$LANG
2742 local LC_LANG_SAVE=$LC_LANG
2743 export LANG=C LC_LANG=C # for date language
2745 DATESTR="Dec 20 2000"
2746 test_mkdir -p $DIR/$tdir
2747 lctl set_param fail_loc=$fl
2749 cp /etc/hosts $DIR/$tdir/$tfile
2750 sync & # write RPC generated with "current" inode timestamp, but delayed
2752 touch --date="$DATESTR" $DIR/$tdir/$tfile # setattr timestamp in past
2753 LS_BEFORE="`ls -l $DIR/$tdir/$tfile`" # old timestamp from client cache
2754 cancel_lru_locks osc
2755 LS_AFTER="`ls -l $DIR/$tdir/$tfile`" # timestamp from OST object
2757 [ "$LS_BEFORE" != "$LS_AFTER" ] && \
2758 echo "BEFORE: $LS_BEFORE" && \
2759 echo "AFTER : $LS_AFTER" && \
2760 echo "WANT : $DATESTR" && \
2761 error "$DIR/$tdir/$tfile timestamps changed" || true
2763 export LANG=$LANG_SAVE LC_LANG=$LC_LANG_SAVE
2767 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2768 #define OBD_FAIL_OST_BRW_PAUSE_BULK 0x214
2769 subr_36fh "0x80000214"
2771 run_test 36f "utime on file racing with OST BRW write =========="
2774 remote_ost_nodsh && skip "remote OST with nodsh" && return
2775 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2780 test_mkdir -p $DIR/$tdir
2781 fmd_max_age=$(do_facet ost1 \
2782 "lctl get_param -n obdfilter.*.client_cache_seconds 2> /dev/null | \
2785 fmd_before=$(do_facet ost1 \
2786 "awk '/ll_fmd_cache/ {print \\\$2}' /proc/slabinfo")
2787 touch $DIR/$tdir/$tfile
2788 sleep $((fmd_max_age + 12))
2789 fmd_after=$(do_facet ost1 \
2790 "awk '/ll_fmd_cache/ {print \\\$2}' /proc/slabinfo")
2792 echo "fmd_before: $fmd_before"
2793 echo "fmd_after: $fmd_after"
2794 [[ $fmd_after -gt $fmd_before ]] &&
2795 echo "AFTER: $fmd_after > BEFORE: $fmd_before" &&
2796 error "fmd didn't expire after ping" || true
2798 run_test 36g "filter mod data cache expiry ====================="
2801 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2802 #define OBD_FAIL_OST_BRW_PAUSE_BULK2 0x227
2803 subr_36fh "0x80000227"
2805 run_test 36h "utime on file racing with OST BRW write =========="
2807 # test_37 - duplicate with tests 32q 32r
2810 local file=$DIR/$tfile
2812 openfile -f O_DIRECTORY $file
2815 [ $RC -eq 0 ] && error "opened file $file with O_DIRECTORY" || true
2816 [ $RC -eq $ENOTDIR ] || error "error $RC should be ENOTDIR ($ENOTDIR)"
2818 run_test 38 "open a regular file with O_DIRECTORY should return -ENOTDIR ==="
2822 touch $DIR/${tfile}2
2823 # ls -l $DIR/$tfile $DIR/${tfile}2
2824 # ls -lu $DIR/$tfile $DIR/${tfile}2
2825 # ls -lc $DIR/$tfile $DIR/${tfile}2
2827 $OPENFILE -f O_CREAT:O_TRUNC:O_WRONLY $DIR/${tfile}2
2828 if [ ! $DIR/${tfile}2 -nt $DIR/$tfile ]; then
2830 ls -l --full-time $DIR/$tfile $DIR/${tfile}2
2832 ls -lu --full-time $DIR/$tfile $DIR/${tfile}2
2834 ls -lc --full-time $DIR/$tfile $DIR/${tfile}2
2835 error "O_TRUNC didn't change timestamps"
2838 run_test 39 "mtime changed on create ==========================="
2841 test_mkdir -p $DIR/$tdir
2842 cp -p /etc/passwd $DIR/$tdir/fopen
2843 cp -p /etc/passwd $DIR/$tdir/flink
2844 cp -p /etc/passwd $DIR/$tdir/funlink
2845 cp -p /etc/passwd $DIR/$tdir/frename
2846 ln $DIR/$tdir/funlink $DIR/$tdir/funlink2
2849 echo "aaaaaa" >> $DIR/$tdir/fopen
2850 echo "aaaaaa" >> $DIR/$tdir/flink
2851 echo "aaaaaa" >> $DIR/$tdir/funlink
2852 echo "aaaaaa" >> $DIR/$tdir/frename
2854 local open_new=`stat -c %Y $DIR/$tdir/fopen`
2855 local link_new=`stat -c %Y $DIR/$tdir/flink`
2856 local unlink_new=`stat -c %Y $DIR/$tdir/funlink`
2857 local rename_new=`stat -c %Y $DIR/$tdir/frename`
2859 cat $DIR/$tdir/fopen > /dev/null
2860 ln $DIR/$tdir/flink $DIR/$tdir/flink2
2861 rm -f $DIR/$tdir/funlink2
2862 mv -f $DIR/$tdir/frename $DIR/$tdir/frename2
2864 for (( i=0; i < 2; i++ )) ; do
2865 local open_new2=`stat -c %Y $DIR/$tdir/fopen`
2866 local link_new2=`stat -c %Y $DIR/$tdir/flink`
2867 local unlink_new2=`stat -c %Y $DIR/$tdir/funlink`
2868 local rename_new2=`stat -c %Y $DIR/$tdir/frename2`
2870 [ $open_new2 -eq $open_new ] || error "open file reverses mtime"
2871 [ $link_new2 -eq $link_new ] || error "link file reverses mtime"
2872 [ $unlink_new2 -eq $unlink_new ] || error "unlink file reverses mtime"
2873 [ $rename_new2 -eq $rename_new ] || error "rename file reverses mtime"
2875 cancel_lru_locks osc
2876 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2879 run_test 39b "mtime change on open, link, unlink, rename ======"
2881 # this should be set to past
2882 TEST_39_MTIME=`date -d "1 year ago" +%s`
2888 local mtime0=`stat -c %Y $DIR1/$tfile`
2890 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
2891 local mtime1=`stat -c %Y $DIR1/$tfile`
2892 [ "$mtime1" = $TEST_39_MTIME ] || \
2893 error "mtime is not set to past: $mtime1, should be $TEST_39_MTIME"
2896 echo hello >> $DIR1/$tfile
2898 local mtime2=`stat -c %Y $DIR1/$tfile`
2899 [ "$mtime2" -ge "$d1" ] && [ "$mtime2" -le "$d2" ] || \
2900 error "mtime is not updated on write: $d1 <= $mtime2 <= $d2"
2902 mv $DIR1/$tfile $DIR1/$tfile-1
2904 for (( i=0; i < 2; i++ )) ; do
2905 local mtime3=`stat -c %Y $DIR1/$tfile-1`
2906 [ "$mtime2" = "$mtime3" ] || \
2907 error "mtime ($mtime2) changed (to $mtime3) on rename"
2909 cancel_lru_locks osc
2910 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2913 run_test 39c "mtime change on rename ==========================="
2917 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2920 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
2922 for (( i=0; i < 2; i++ )) ; do
2923 local mtime=`stat -c %Y $DIR1/$tfile`
2924 [ $mtime = $TEST_39_MTIME ] || \
2925 error "mtime($mtime) is not set to $TEST_39_MTIME"
2927 cancel_lru_locks osc
2928 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2931 run_test 39d "create, utime, stat =============================="
2935 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2937 local mtime1=`stat -c %Y $DIR1/$tfile`
2939 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
2941 for (( i=0; i < 2; i++ )) ; do
2942 local mtime2=`stat -c %Y $DIR1/$tfile`
2943 [ $mtime2 = $TEST_39_MTIME ] || \
2944 error "mtime($mtime2) is not set to $TEST_39_MTIME"
2946 cancel_lru_locks osc
2947 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2950 run_test 39e "create, stat, utime, stat ========================"
2954 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2956 mtime1=`stat -c %Y $DIR1/$tfile`
2959 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
2961 for (( i=0; i < 2; i++ )) ; do
2962 local mtime2=`stat -c %Y $DIR1/$tfile`
2963 [ $mtime2 = $TEST_39_MTIME ] || \
2964 error "mtime($mtime2) is not set to $TEST_39_MTIME"
2966 cancel_lru_locks osc
2967 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2970 run_test 39f "create, stat, sleep, utime, stat ================="
2974 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2975 echo hello >> $DIR1/$tfile
2976 local mtime1=`stat -c %Y $DIR1/$tfile`
2979 chmod o+r $DIR1/$tfile
2981 for (( i=0; i < 2; i++ )) ; do
2982 local mtime2=`stat -c %Y $DIR1/$tfile`
2983 [ "$mtime1" = "$mtime2" ] || \
2984 error "lost mtime: $mtime2, should be $mtime1"
2986 cancel_lru_locks osc
2987 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2990 run_test 39g "write, chmod, stat ==============================="
2994 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2999 echo hello >> $DIR1/$tfile
3000 local mtime1=`stat -c %Y $DIR1/$tfile`
3002 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3004 if [ "$d1" != "$d2" ]; then
3005 echo "write and touch not within one second"
3007 for (( i=0; i < 2; i++ )) ; do
3008 local mtime2=`stat -c %Y $DIR1/$tfile`
3009 [ "$mtime2" = $TEST_39_MTIME ] || \
3010 error "lost mtime: $mtime2, should be $TEST_39_MTIME"
3012 cancel_lru_locks osc
3013 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3017 run_test 39h "write, utime within one second, stat ============="
3020 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3024 echo hello >> $DIR1/$tfile
3025 local mtime1=`stat -c %Y $DIR1/$tfile`
3027 mv $DIR1/$tfile $DIR1/$tfile-1
3029 for (( i=0; i < 2; i++ )) ; do
3030 local mtime2=`stat -c %Y $DIR1/$tfile-1`
3032 [ "$mtime1" = "$mtime2" ] || \
3033 error "lost mtime: $mtime2, should be $mtime1"
3035 cancel_lru_locks osc
3036 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3039 run_test 39i "write, rename, stat =============================="
3042 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3043 start_full_debug_logging
3047 #define OBD_FAIL_OSC_DELAY_SETTIME 0x412
3048 lctl set_param fail_loc=0x80000412
3049 multiop_bg_pause $DIR1/$tfile oO_RDWR:w2097152_c ||
3050 error "multiop failed"
3052 local mtime1=`stat -c %Y $DIR1/$tfile`
3054 mv $DIR1/$tfile $DIR1/$tfile-1
3056 kill -USR1 $multipid
3057 wait $multipid || error "multiop close failed"
3059 for (( i=0; i < 2; i++ )) ; do
3060 local mtime2=`stat -c %Y $DIR1/$tfile-1`
3061 [ "$mtime1" = "$mtime2" ] ||
3062 error "mtime is lost on close: $mtime2, " \
3065 cancel_lru_locks osc
3066 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3068 lctl set_param fail_loc=0
3069 stop_full_debug_logging
3071 run_test 39j "write, rename, close, stat ======================="
3074 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3078 multiop_bg_pause $DIR1/$tfile oO_RDWR:w2097152_c || error "multiop failed"
3080 local mtime1=`stat -c %Y $DIR1/$tfile`
3082 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3084 kill -USR1 $multipid
3085 wait $multipid || error "multiop close failed"
3087 for (( i=0; i < 2; i++ )) ; do
3088 local mtime2=`stat -c %Y $DIR1/$tfile`
3090 [ "$mtime2" = $TEST_39_MTIME ] || \
3091 error "mtime is lost on close: $mtime2, should be $TEST_39_MTIME"
3093 cancel_lru_locks osc
3094 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3097 run_test 39k "write, utime, close, stat ========================"
3099 # this should be set to future
3100 TEST_39_ATIME=`date -d "1 year" +%s`
3103 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3104 remote_mds_nodsh && skip "remote MDS with nodsh" && return
3105 local atime_diff=$(do_facet $SINGLEMDS \
3106 lctl get_param -n mdd.*MDT0000*.atime_diff)
3110 # test setting directory atime to future
3111 touch -a -d @$TEST_39_ATIME $DIR/$tdir
3112 local atime=$(stat -c %X $DIR/$tdir)
3113 [ "$atime" = $TEST_39_ATIME ] || \
3114 error "atime is not set to future: $atime, $TEST_39_ATIME"
3116 # test setting directory atime from future to now
3117 local d1=$(date +%s)
3119 local d2=$(date +%s)
3121 cancel_lru_locks mdc
3122 atime=$(stat -c %X $DIR/$tdir)
3123 [ "$atime" -ge "$d1" -a "$atime" -le "$d2" ] || \
3124 error "atime is not updated from future: $atime, $d1<atime<$d2"
3126 do_facet $SINGLEMDS lctl set_param -n mdd.*MDT0000*.atime_diff=2
3129 # test setting directory atime when now > dir atime + atime_diff
3133 cancel_lru_locks mdc
3134 atime=$(stat -c %X $DIR/$tdir)
3135 [ "$atime" -ge "$d1" -a "$atime" -le "$d2" ] || \
3136 error "atime is not updated : $atime, should be $d2"
3138 do_facet $SINGLEMDS lctl set_param -n mdd.*MDT0000*.atime_diff=60
3141 # test not setting directory atime when now < dir atime + atime_diff
3143 cancel_lru_locks mdc
3144 atime=$(stat -c %X $DIR/$tdir)
3145 [ "$atime" -ge "$d1" -a "$atime" -le "$d2" ] || \
3146 error "atime is updated to $atime, should remain $d1<atime<$d2"
3148 do_facet $SINGLEMDS \
3149 lctl set_param -n mdd.*MDT0000*.atime_diff=$atime_diff
3151 run_test 39l "directory atime update ==========================="
3154 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3157 local far_past_mtime=$(date -d "May 29 1953" +%s)
3158 local far_past_atime=$(date -d "Dec 17 1903" +%s)
3160 touch -m -d @$far_past_mtime $DIR1/$tfile
3161 touch -a -d @$far_past_atime $DIR1/$tfile
3163 for (( i=0; i < 2; i++ )) ; do
3164 local timestamps=$(stat -c "%X %Y" $DIR1/$tfile)
3165 [ "$timestamps" = "$far_past_atime $far_past_mtime" ] || \
3166 error "atime or mtime set incorrectly"
3168 cancel_lru_locks osc
3169 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3172 run_test 39m "test atime and mtime before 1970"
3174 test_39n() { # LU-3832
3175 local atime_diff=$(do_facet $SINGLEMDS \
3176 lctl get_param -n mdd.*MDT0000*.atime_diff)
3181 do_facet $SINGLEMDS lctl set_param -n mdd.*MDT0000*.atime_diff=1
3184 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 status=noxfer
3185 atime0=$(stat -c %X $DIR/$tfile)
3188 $MULTIOP $DIR/$tfile oO_RDONLY:O_NOATIME:r4096c
3189 atime1=$(stat -c %X $DIR/$tfile)
3192 cancel_lru_locks mdc
3193 cancel_lru_locks osc
3194 $MULTIOP $DIR/$tfile oO_RDONLY:O_NOATIME:r4096c
3195 atime2=$(stat -c %X $DIR/$tfile)
3197 do_facet $SINGLEMDS \
3198 lctl set_param -n mdd.*MDT0000*.atime_diff=$atime_diff
3200 [ "$atime0" -eq "$atime1" ] || error "atime0 $atime0 != atime1 $atime1"
3201 [ "$atime1" -eq "$atime2" ] || error "atime0 $atime0 != atime1 $atime1"
3203 run_test 39n "check that O_NOATIME is honored"
3206 TESTDIR=$DIR/$tdir/$tfile
3207 [ -e $TESTDIR ] && rm -rf $TESTDIR
3208 test_mkdir -p $TESTDIR
3214 links2=$(stat -c %h .)
3215 [ $(($links1 + 2)) != $links2 ] &&
3216 error "wrong links count $(($links1 + 2)) != $links2"
3218 links3=$(stat -c %h .)
3219 [ $(($links1 + 1)) != $links3 ] &&
3220 error "wrong links count $links1 != $links3"
3223 run_test 39o "directory cached attributes updated after create ========"
3226 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 2 MDTs" && return
3228 TESTDIR=$DIR/$tdir/$tfile
3229 [ -e $TESTDIR ] && rm -rf $TESTDIR
3234 $LFS mkdir -i $MDTIDX $TESTDIR/remote_dir1
3235 $LFS mkdir -i $MDTIDX $TESTDIR/remote_dir2
3237 links2=$(stat -c %h .)
3238 [ $(($links1 + 2)) != $links2 ] &&
3239 error "wrong links count $(($links1 + 2)) != $links2"
3241 links3=$(stat -c %h .)
3242 [ $(($links1 + 1)) != $links3 ] &&
3243 error "wrong links count $links1 != $links3"
3246 run_test 39p "remote directory cached attributes updated after create ========"
3250 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1
3251 $RUNAS $OPENFILE -f O_WRONLY:O_TRUNC $DIR/$tfile &&
3252 error "openfile O_WRONLY:O_TRUNC $tfile failed"
3253 $CHECKSTAT -t file -s 4096 $DIR/$tfile ||
3254 error "$tfile is not 4096 bytes in size"
3256 run_test 40 "failed open(O_TRUNC) doesn't truncate ============="
3260 small_write $DIR/f41 18
3262 run_test 41 "test small file write + fstat ====================="
3264 count_ost_writes() {
3265 lctl get_param -n osc.*.stats |
3266 awk -vwrites=0 '/ost_write/ { writes += $2 } \
3267 END { printf("%0.0f", writes) }'
3274 BG_DIRTY_RATIO_SAVE=10
3275 MAX_BG_DIRTY_RATIO=25
3279 # in 2.6, restore /proc/sys/vm/dirty_writeback_centisecs,
3280 # dirty_ratio, dirty_background_ratio
3281 if [ -f /proc/sys/vm/dirty_writeback_centisecs ]; then
3282 sysctl -w vm.dirty_writeback_centisecs=$WRITEBACK_SAVE
3283 sysctl -w vm.dirty_background_ratio=$BG_DIRTY_RATIO_SAVE
3284 sysctl -w vm.dirty_ratio=$DIRTY_RATIO_SAVE
3286 # if file not here, we are a 2.4 kernel
3287 kill -CONT `pidof kupdated`
3292 # setup the trap first, so someone cannot exit the test at the
3293 # exact wrong time and mess up a machine
3294 trap start_writeback EXIT
3295 # in 2.6, save and 0 /proc/sys/vm/dirty_writeback_centisecs
3296 if [ -f /proc/sys/vm/dirty_writeback_centisecs ]; then
3297 WRITEBACK_SAVE=`sysctl -n vm.dirty_writeback_centisecs`
3298 sysctl -w vm.dirty_writeback_centisecs=0
3299 sysctl -w vm.dirty_writeback_centisecs=0
3300 # save and increase /proc/sys/vm/dirty_ratio
3301 DIRTY_RATIO_SAVE=`sysctl -n vm.dirty_ratio`
3302 sysctl -w vm.dirty_ratio=$MAX_DIRTY_RATIO
3303 # save and increase /proc/sys/vm/dirty_background_ratio
3304 BG_DIRTY_RATIO_SAVE=`sysctl -n vm.dirty_background_ratio`
3305 sysctl -w vm.dirty_background_ratio=$MAX_BG_DIRTY_RATIO
3307 # if file not here, we are a 2.4 kernel
3308 kill -STOP `pidof kupdated`
3312 # ensure that all stripes have some grant before we test client-side cache
3314 for i in `seq -f $DIR/f42-%g 1 $OSTCOUNT`; do
3315 dd if=/dev/zero of=$i bs=4k count=1
3320 # Tests 42* verify that our behaviour is correct WRT caching, file closure,
3321 # file truncation, and file removal.
3323 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3325 cancel_lru_locks osc
3327 sync; sleep 1; sync # just to be safe
3328 BEFOREWRITES=`count_ost_writes`
3329 lctl get_param -n osc.*[oO][sS][cC][_-]*.cur_grant_bytes | grep "[0-9]"
3330 dd if=/dev/zero of=$DIR/f42a bs=1024 count=100
3331 AFTERWRITES=`count_ost_writes`
3332 [ $BEFOREWRITES -eq $AFTERWRITES ] || \
3333 error "$BEFOREWRITES < $AFTERWRITES"
3336 run_test 42a "ensure that we don't flush on close =============="
3339 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3341 cancel_lru_locks osc
3344 dd if=/dev/zero of=$DIR/f42b bs=1024 count=100
3345 BEFOREWRITES=$(count_ost_writes)
3346 $MUNLINK $DIR/f42b || error "$MUNLINK $DIR/f42b: $?"
3347 AFTERWRITES=$(count_ost_writes)
3348 if [[ $BEFOREWRITES -lt $AFTERWRITES ]]; then
3349 error "$BEFOREWRITES < $AFTERWRITES on unlink"
3351 BEFOREWRITES=$(count_ost_writes)
3352 sync || error "sync: $?"
3353 AFTERWRITES=$(count_ost_writes)
3354 if [[ $BEFOREWRITES -lt $AFTERWRITES ]]; then
3355 error "$BEFOREWRITES < $AFTERWRITES on sync"
3357 dmesg | grep 'error from obd_brw_async' && error 'error writing back'
3361 run_test 42b "test destroy of file with cached dirty data ======"
3363 # if these tests just want to test the effect of truncation,
3364 # they have to be very careful. consider:
3365 # - the first open gets a {0,EOF}PR lock
3366 # - the first write conflicts and gets a {0, count-1}PW
3367 # - the rest of the writes are under {count,EOF}PW
3368 # - the open for truncate tries to match a {0,EOF}PR
3369 # for the filesize and cancels the PWs.
3370 # any number of fixes (don't get {0,EOF} on open, match
3371 # composite locks, do smarter file size management) fix
3372 # this, but for now we want these tests to verify that
3373 # the cancellation with truncate intent works, so we
3374 # start the file with a full-file pw lock to match against
3375 # until the truncate.
3380 cancel_lru_locks osc
3382 # prime the file with 0,EOF PW to match
3386 # now the real test..
3387 dd if=/dev/zero of=$file bs=1024 count=100
3388 BEFOREWRITES=`count_ost_writes`
3389 $TRUNCATE $file $offset
3390 cancel_lru_locks osc
3391 AFTERWRITES=`count_ost_writes`
3396 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3398 [ $BEFOREWRITES -eq $AFTERWRITES ] && \
3399 error "beforewrites $BEFOREWRITES == afterwrites $AFTERWRITES on truncate"
3402 run_test 42c "test partial truncate of file with cached dirty data"
3405 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3407 [ $BEFOREWRITES -eq $AFTERWRITES ] || \
3408 error "beforewrites $BEFOREWRITES != afterwrites $AFTERWRITES on truncate"
3411 run_test 42d "test complete truncate of file with cached dirty data"
3413 test_42e() { # bug22074
3414 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3415 local TDIR=$DIR/${tdir}e
3416 local pagesz=$(page_size)
3417 local pages=16 # hardcoded 16 pages, don't change it.
3418 local files=$((OSTCOUNT * 500)) # hopefully 500 files on each OST
3419 local proc_osc0="osc.${FSNAME}-OST0000-osc-[^MDT]*"
3423 test_mkdir -p $DIR/${tdir}e
3424 $SETSTRIPE -c 1 $TDIR
3425 createmany -o $TDIR/f $files
3427 max_dirty_mb=$($LCTL get_param -n $proc_osc0/max_dirty_mb)
3429 # we assume that with $OSTCOUNT files, at least one of them will
3430 # be allocated on OST0.
3431 warmup_files=$((OSTCOUNT * max_dirty_mb))
3432 createmany -o $TDIR/w $warmup_files
3434 # write a large amount of data into one file and sync, to get good
3435 # avail_grant number from OST.
3436 for ((i=0; i<$warmup_files; i++)); do
3437 idx=$($GETSTRIPE -i $TDIR/w$i)
3438 [ $idx -ne 0 ] && continue
3439 dd if=/dev/zero of=$TDIR/w$i bs="$max_dirty_mb"M count=1
3442 [[ $i -gt $warmup_files ]] && error "OST0 is still cold"
3444 $LCTL get_param $proc_osc0/cur_dirty_bytes
3445 $LCTL get_param $proc_osc0/cur_grant_bytes
3447 # create as much dirty pages as we can while not to trigger the actual
3448 # RPCs directly. but depends on the env, VFS may trigger flush during this
3449 # period, hopefully we are good.
3450 for ((i=0; i<$warmup_files; i++)); do
3451 idx=$($GETSTRIPE -i $TDIR/w$i)
3452 [ $idx -ne 0 ] && continue
3453 dd if=/dev/zero of=$TDIR/w$i bs=1M count=1 2>/dev/null
3455 $LCTL get_param $proc_osc0/cur_dirty_bytes
3456 $LCTL get_param $proc_osc0/cur_grant_bytes
3458 # perform the real test
3459 $LCTL set_param $proc_osc0/rpc_stats 0
3460 for ((;i<$files; i++)); do
3461 [ $($GETSTRIPE -i $TDIR/f$i) -eq 0 ] || continue
3462 dd if=/dev/zero of=$TDIR/f$i bs=$pagesz count=$pages 2>/dev/null
3465 $LCTL get_param $proc_osc0/rpc_stats
3468 local have_ppr=false
3469 $LCTL get_param $proc_osc0/rpc_stats |
3470 while read PPR RRPC RPCT RCUM BAR WRPC WPCT WCUM; do
3471 # skip lines until we are at the RPC histogram data
3472 [ "$PPR" == "pages" ] && have_ppr=true && continue
3473 $have_ppr || continue
3475 # we only want the percent stat for < 16 pages
3476 [[ $(echo $PPR | tr -d ':') -ge $pages ]] && break
3478 percent=$((percent + WPCT))
3479 if [[ $percent -gt 15 ]]; then
3480 error "less than 16-pages write RPCs" \
3487 run_test 42e "verify sub-RPC writes are not done synchronously"
3490 test_mkdir -p $DIR/$tdir
3491 cp -p /bin/ls $DIR/$tdir/$tfile
3492 $MULTIOP $DIR/$tdir/$tfile Ow_c &
3494 # give multiop a chance to open
3497 $DIR/$tdir/$tfile && error || true
3500 run_test 43 "execution of file opened for write should return -ETXTBSY"
3503 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3504 test_mkdir -p $DIR/$tdir
3505 cp -p `which $MULTIOP` $DIR/$tdir/multiop ||
3506 cp -p multiop $DIR/$tdir/multiop
3507 MULTIOP_PROG=$DIR/$tdir/multiop multiop_bg_pause $TMP/$tfile.junk O_c ||
3510 $MULTIOP $DIR/$tdir/multiop Oc && error "expected error, got success"
3511 kill -USR1 $MULTIOP_PID || return 2
3512 wait $MULTIOP_PID || return 3
3513 rm $TMP/$tfile.junk $DIR/$tdir/multiop
3515 run_test 43a "open(RDWR) of file being executed should return -ETXTBSY"
3518 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3519 test_mkdir -p $DIR/$tdir
3520 cp -p `which $MULTIOP` $DIR/$tdir/multiop ||
3521 cp -p multiop $DIR/$tdir/multiop
3522 MULTIOP_PROG=$DIR/$tdir/multiop multiop_bg_pause $TMP/$tfile.junk O_c ||
3525 $TRUNCATE $DIR/$tdir/multiop 0 && error "expected error, got success"
3526 kill -USR1 $MULTIOP_PID || return 2
3527 wait $MULTIOP_PID || return 3
3528 rm $TMP/$tfile.junk $DIR/$tdir/multiop
3530 run_test 43b "truncate of file being executed should return -ETXTBSY"
3533 local testdir="$DIR/$tdir"
3534 test_mkdir -p $DIR/$tdir
3536 ( cd $(dirname $SHELL) && md5sum $(basename $SHELL) ) | \
3537 ( cd $testdir && md5sum -c)
3539 run_test 43c "md5sum of copy into lustre========================"
3542 [[ $OSTCOUNT -lt 2 ]] && skip_env "skipping 2-stripe test" && return
3543 dd if=/dev/zero of=$DIR/f1 bs=4k count=1 seek=1023
3544 dd if=$DIR/f1 bs=4k count=1 > /dev/null
3546 run_test 44 "zero length read from a sparse stripe ============="
3549 local nstripe=$($LCTL lov_getconfig $DIR | grep default_stripe_count: |
3551 [ -z "$nstripe" ] && skip "can't get stripe info" && return
3552 [[ $nstripe -gt $OSTCOUNT ]] &&
3553 skip "Wrong default_stripe_count: $nstripe (OSTCOUNT: $OSTCOUNT)" &&
3555 local stride=$($LCTL lov_getconfig $DIR | grep default_stripe_size: |
3557 if [[ $nstripe -eq 0 || $nstripe -eq -1 ]]; then
3558 nstripe=$($LCTL lov_getconfig $DIR | grep obd_count: |
3562 OFFSETS="0 $((stride/2)) $((stride-1))"
3563 for offset in $OFFSETS; do
3564 for i in $(seq 0 $((nstripe-1))); do
3565 local GLOBALOFFSETS=""
3567 local size=$((((i + 2 * $nstripe )*$stride + $offset)))
3568 local myfn=$DIR/d44a-$size
3569 echo "--------writing $myfn at $size"
3570 ll_sparseness_write $myfn $size ||
3571 error "ll_sparseness_write"
3572 GLOBALOFFSETS="$GLOBALOFFSETS $size"
3573 ll_sparseness_verify $myfn $GLOBALOFFSETS ||
3574 error "ll_sparseness_verify $GLOBALOFFSETS"
3576 for j in $(seq 0 $((nstripe-1))); do
3578 size=$((((j + $nstripe )*$stride + $offset)))
3579 ll_sparseness_write $myfn $size ||
3580 error "ll_sparseness_write"
3581 GLOBALOFFSETS="$GLOBALOFFSETS $size"
3583 ll_sparseness_verify $myfn $GLOBALOFFSETS ||
3584 error "ll_sparseness_verify $GLOBALOFFSETS"
3589 run_test 44a "test sparse pwrite ==============================="
3593 for d in `lctl get_param -n osc.*.cur_dirty_bytes`; do
3599 before=`dirty_osc_total`
3600 echo executing "\"$*\""
3602 after=`dirty_osc_total`
3603 echo before $before, after $after
3606 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3608 # Obtain grants from OST if it supports it
3609 echo blah > ${f}_grant
3612 do_dirty_record "echo blah > $f"
3613 [[ $before -eq $after ]] && error "write wasn't cached"
3614 do_dirty_record "> $f"
3615 [[ $before -gt $after ]] || error "truncate didn't lower dirty count"
3616 do_dirty_record "echo blah > $f"
3617 [[ $before -eq $after ]] && error "write wasn't cached"
3618 do_dirty_record "sync"
3619 [[ $before -gt $after ]] || error "writeback didn't lower dirty count"
3620 do_dirty_record "echo blah > $f"
3621 [[ $before -eq $after ]] && error "write wasn't cached"
3622 do_dirty_record "cancel_lru_locks osc"
3623 [[ $before -gt $after ]] ||
3624 error "lock cancellation didn't lower dirty count"
3627 run_test 45 "osc io page accounting ============================"
3629 # in a 2 stripe file (lov.sh), page 1023 maps to page 511 in its object. this
3630 # test tickles a bug where re-dirtying a page was failing to be mapped to the
3631 # objects offset and an assert hit when an rpc was built with 1023's mapped
3632 # offset 511 and 511's raw 511 offset. it also found general redirtying bugs.
3634 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3638 dd if=/dev/zero of=$f bs=`page_size` seek=511 count=1
3640 dd conv=notrunc if=/dev/zero of=$f bs=`page_size` seek=1023 count=1
3641 dd conv=notrunc if=/dev/zero of=$f bs=`page_size` seek=511 count=1
3645 run_test 46 "dirtying a previously written page ================"
3647 # test_47 is removed "Device nodes check" is moved to test_28
3649 test_48a() { # bug 2399
3650 check_kernel_version 34 || return 0
3651 test_mkdir -p $DIR/$tdir
3653 mv $DIR/$tdir $DIR/d48.new || error "move directory failed"
3654 test_mkdir $DIR/$tdir || error "recreate directory failed"
3655 touch foo || error "'touch foo' failed after recreating cwd"
3656 test_mkdir $DIR/$tdir/bar ||
3657 error "'mkdir foo' failed after recreating cwd"
3658 if check_kernel_version 44; then
3659 touch .foo || error "'touch .foo' failed after recreating cwd"
3660 test_mkdir $DIR/$tdir/.bar ||
3661 error "'mkdir .foo' failed after recreating cwd"
3663 ls . > /dev/null || error "'ls .' failed after recreating cwd"
3664 ls .. > /dev/null || error "'ls ..' failed after removing cwd"
3665 cd . || error "'cd .' failed after recreating cwd"
3666 test_mkdir . && error "'mkdir .' worked after recreating cwd"
3667 rmdir . && error "'rmdir .' worked after recreating cwd"
3668 ln -s . baz || error "'ln -s .' failed after recreating cwd"
3669 cd .. || error "'cd ..' failed after recreating cwd"
3671 run_test 48a "Access renamed working dir (should return errors)="
3673 test_48b() { # bug 2399
3674 check_kernel_version 34 || return 0
3676 test_mkdir -p $DIR/$tdir
3678 rmdir $DIR/$tdir || error "remove cwd $DIR/$tdir failed"
3679 touch foo && error "'touch foo' worked after removing cwd"
3680 test_mkdir $DIR/$tdir/foo &&
3681 error "'mkdir foo' worked after removing cwd"
3682 if check_kernel_version 44; then
3683 touch .foo && error "'touch .foo' worked after removing cwd"
3684 test_mkdir $DIR/$tdir/.foo &&
3685 error "'mkdir .foo' worked after removing cwd"
3687 ls . > /dev/null && error "'ls .' worked after removing cwd"
3688 ls .. > /dev/null || error "'ls ..' failed after removing cwd"
3689 is_patchless || ( cd . && error "'cd .' worked after removing cwd" )
3690 test_mkdir $DIR/$tdir/. && error "'mkdir .' worked after removing cwd"
3691 rmdir . && error "'rmdir .' worked after removing cwd"
3692 ln -s . foo && error "'ln -s .' worked after removing cwd"
3693 cd .. || echo "'cd ..' failed after removing cwd `pwd`" #bug 3517
3695 run_test 48b "Access removed working dir (should return errors)="
3697 test_48c() { # bug 2350
3698 check_kernel_version 36 || return 0
3699 #lctl set_param debug=-1
3702 test_mkdir -p $DIR/$tdir/dir
3704 $TRACE rmdir $DIR/$tdir/dir || error "remove cwd $DIR/$tdir/dir failed"
3705 $TRACE touch foo && error "touch foo worked after removing cwd"
3706 $TRACE test_mkdir foo && error "'mkdir foo' worked after removing cwd"
3707 if check_kernel_version 44; then
3708 touch .foo && error "touch .foo worked after removing cwd"
3709 test_mkdir .foo && error "mkdir .foo worked after removing cwd"
3711 $TRACE ls . && error "'ls .' worked after removing cwd"
3712 $TRACE ls .. || error "'ls ..' failed after removing cwd"
3713 is_patchless || ( $TRACE cd . &&
3714 error "'cd .' worked after removing cwd" )
3715 $TRACE test_mkdir . && error "'mkdir .' worked after removing cwd"
3716 $TRACE rmdir . && error "'rmdir .' worked after removing cwd"
3717 $TRACE ln -s . foo && error "'ln -s .' worked after removing cwd"
3718 $TRACE cd .. || echo "'cd ..' failed after removing cwd `pwd`" #bug 3415
3720 run_test 48c "Access removed working subdir (should return errors)"
3722 test_48d() { # bug 2350
3723 check_kernel_version 36 || return 0
3724 #lctl set_param debug=-1
3727 test_mkdir -p $DIR/$tdir/dir
3729 $TRACE rmdir $DIR/$tdir/dir || error "remove cwd $DIR/$tdir/dir failed"
3730 $TRACE rmdir $DIR/$tdir || error "remove parent $DIR/$tdir failed"
3731 $TRACE touch foo && error "'touch foo' worked after removing parent"
3732 $TRACE test_mkdir foo && error "mkdir foo worked after removing parent"
3733 if check_kernel_version 44; then
3734 touch .foo && error "'touch .foo' worked after removing parent"
3736 error "mkdir .foo worked after removing parent"
3738 $TRACE ls . && error "'ls .' worked after removing parent"
3739 $TRACE ls .. && error "'ls ..' worked after removing parent"
3740 is_patchless || ( $TRACE cd . &&
3741 error "'cd .' worked after recreate parent" )
3742 $TRACE test_mkdir . && error "'mkdir .' worked after removing parent"
3743 $TRACE rmdir . && error "'rmdir .' worked after removing parent"
3744 $TRACE ln -s . foo && error "'ln -s .' worked after removing parent"
3745 is_patchless || ( $TRACE cd .. &&
3746 error "'cd ..' worked after removing parent" || true )
3748 run_test 48d "Access removed parent subdir (should return errors)"
3750 test_48e() { # bug 4134
3751 check_kernel_version 41 || return 0
3752 #lctl set_param debug=-1
3755 test_mkdir -p $DIR/$tdir/dir
3757 $TRACE rmdir $DIR/$tdir/dir || error "remove cwd $DIR/$tdir/dir failed"
3758 $TRACE rmdir $DIR/$tdir || error "remove parent $DIR/$tdir failed"
3759 $TRACE touch $DIR/$tdir || error "'touch $DIR/$tdir' failed"
3760 $TRACE chmod +x $DIR/$tdir || error "'chmod +x $DIR/$tdir' failed"
3761 # On a buggy kernel addition of "touch foo" after cd .. will
3762 # produce kernel oops in lookup_hash_it
3763 touch ../foo && error "'cd ..' worked after recreate parent"
3765 $TRACE rm $DIR/$tdir || error "rm '$DIR/$tdir' failed"
3767 run_test 48e "Access to recreated parent subdir (should return errors)"
3769 test_49() { # LU-1030
3770 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3771 # get ost1 size - lustre-OST0000
3772 ost1_size=$(do_facet ost1 $LFS df | grep ${ost1_svc} |
3774 # write 800M at maximum
3775 [[ $ost1_size -lt 2 ]] && ost1_size=2
3776 [[ $ost1_size -gt 819200 ]] && ost1_size=819200
3778 $SETSTRIPE -c 1 -i 0 $DIR/$tfile
3779 dd if=/dev/zero of=$DIR/$tfile bs=4k count=$((ost1_size >> 2)) &
3782 # change max_pages_per_rpc while writing the file
3783 local osc1_mppc=osc.$(get_osc_import_name client ost1).max_pages_per_rpc
3784 local orig_mppc=$($LCTL get_param -n $osc1_mppc)
3785 # loop until dd process exits
3786 while ps ax -opid | grep -wq $dd_pid; do
3787 $LCTL set_param $osc1_mppc=$((RANDOM % 256 + 1))
3788 sleep $((RANDOM % 5 + 1))
3790 # restore original max_pages_per_rpc
3791 $LCTL set_param $osc1_mppc=$orig_mppc
3792 rm $DIR/$tfile || error "rm $DIR/$tfile failed"
3794 run_test 49 "Change max_pages_per_rpc won't break osc extent"
3798 test_mkdir $DIR/$tdir
3800 ls /proc/$$/cwd || error "ls /proc/$$/cwd failed"
3802 run_test 50 "special situations: /proc symlinks ==============="
3804 test_51a() { # was test_51
3805 # bug 1516 - create an empty entry right after ".." then split dir
3806 test_mkdir -p $DIR/$tdir
3807 touch $DIR/$tdir/foo
3808 $MCREATE $DIR/$tdir/bar
3810 createmany -m $DIR/$tdir/longfile 201
3812 while [[ $(ls -sd $DIR/$tdir | awk '{ print $1 }') -eq 4 ]]; do
3813 $MCREATE $DIR/$tdir/longfile$FNUM
3818 ls -l $DIR/$tdir > /dev/null || error "ls -l $DIR/$tdir failed"
3820 run_test 51a "special situations: split htree with empty entry =="
3822 export NUMTEST=70000
3824 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3825 local BASE=$DIR/d${base}.${TESTSUITE}
3827 # cleanup the directory
3832 local mdtidx=$(printf "%04x" $($LFS getstripe -M $BASE))
3833 local numfree=$(lctl get_param -n mdc.$FSNAME-MDT$mdtidx*.filesfree)
3834 [[ $numfree -lt 21000 ]] && skip "not enough free inodes ($numfree)" &&
3837 [[ $numfree -lt $NUMTEST ]] && NUMTEST=$(($numfree - 50)) &&
3838 echo "reduced count to $NUMTEST due to inodes"
3840 # need to check free space for the directories as well
3841 local blkfree=$(lctl get_param -n mdc.$FSNAME-MDT$mdtidx*.kbytesavail)
3842 numfree=$((blkfree / 4))
3843 [[ $numfree -lt $NUMTEST ]] && NUMTEST=$(($numfree - 50)) &&
3844 echo "reduced count to $NUMTEST due to blocks"
3846 createmany -d $BASE/d $NUMTEST && echo $NUMTEST > $BASE/fnum ||
3847 echo "failed" > $BASE/fnum
3849 run_test 51b "exceed 64k subdirectory nlink limit"
3851 test_51ba() { # LU-993
3852 local BASE=$DIR/d${base}.${TESTSUITE}
3853 # unlink all but 100 subdirectories, then check it still works
3855 [ -f $BASE/fnum ] && local NUMPREV=$(cat $BASE/fnum) && rm $BASE/fnum
3857 [ "$NUMPREV" != "failed" ] && NUMTEST=$NUMPREV
3858 local DELETE=$((NUMTEST - LEFT))
3860 # continue on to run this test even if 51b didn't finish,
3861 # just to delete the many subdirectories created.
3862 [ ! -d "${BASE}/d1" ] && skip "test_51b() not run" && return 0
3864 # for ldiskfs the nlink count should be 1, but this is OSD specific
3865 # and so this is listed for informational purposes only
3866 echo "nlink before: $(stat -c %h $BASE), created before: $NUMTEST"
3867 unlinkmany -d $BASE/d $DELETE
3870 if [ $RC -ne 0 ]; then
3871 if [ "$NUMPREV" == "failed" ]; then
3872 skip "previous setup failed"
3875 error "unlink of first $DELETE subdirs failed"
3880 echo "nlink between: $(stat -c %h $BASE)"
3881 # trim the first line of ls output
3882 local FOUND=$(($(ls -l ${BASE} | wc -l) - 1))
3883 [ $FOUND -ne $LEFT ] &&
3884 error "can't find subdirs: found only $FOUND/$LEFT"
3886 unlinkmany -d $BASE/d $DELETE $LEFT ||
3887 error "unlink of second $LEFT subdirs failed"
3888 # regardless of whether the backing filesystem tracks nlink accurately
3889 # or not, the nlink count shouldn't be more than "." and ".." here
3890 local AFTER=$(stat -c %h $BASE)
3891 [[ $AFTER -gt 2 ]] && error "nlink after: $AFTER > 2" ||
3892 echo "nlink after: $AFTER"
3894 run_test 51ba "verify nlink for many subdirectory cleanup"
3897 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3898 [[ $OSTCOUNT -lt 3 ]] &&
3899 skip_env "skipping test with few OSTs" && return
3900 test_mkdir -p $DIR/$tdir
3901 createmany -o $DIR/$tdir/t- 1000
3902 $GETSTRIPE $DIR/$tdir > $TMP/files
3903 for N in $(seq 0 $((OSTCOUNT - 1))); do