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}')
24 local patchlev=$(grep PATCHLEVEL /etc/SuSE-release |
26 if [ $vers -eq 11 ] && [ $patchlev -ge 3 ]; then
33 if is_sles11; then # LU-4341
34 ALWAYS_EXCEPT="$ALWAYS_EXCEPT 170"
37 SRCDIR=$(cd $(dirname $0); echo $PWD)
38 export PATH=$PATH:/sbin
43 CHECKSTAT=${CHECKSTAT:-"checkstat -v"}
44 CREATETEST=${CREATETEST:-createtest}
46 LFIND=${LFIND:-"$LFS find"}
47 LVERIFY=${LVERIFY:-ll_dirstripe_verify}
49 OPENFILE=${OPENFILE:-openfile}
50 OPENUNLINK=${OPENUNLINK:-openunlink}
51 export MULTIOP=${MULTIOP:-multiop}
52 READS=${READS:-"reads"}
53 MUNLINK=${MUNLINK:-munlink}
54 SOCKETSERVER=${SOCKETSERVER:-socketserver}
55 SOCKETCLIENT=${SOCKETCLIENT:-socketclient}
56 MEMHOG=${MEMHOG:-memhog}
57 DIRECTIO=${DIRECTIO:-directio}
58 ACCEPTOR_PORT=${ACCEPTOR_PORT:-988}
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_API_DIR=${LUSTRE_TESTS_API_DIR:-${LUSTRE}/tests/clientapi}
73 . $LUSTRE/tests/test-framework.sh
75 . ${CONFIG:=$LUSTRE/tests/cfg/${NAME}.sh}
78 [ "$SLOW" = "no" ] && EXCEPT_SLOW="24o 24D 27m 64b 68 71 77f 78 115 124b 300o"
80 if [ $(facet_fstype $SINGLEMDS) = "zfs" ]; then
81 # bug number for skipped test: LU-4536 LU-1957 LU-2805
82 ALWAYS_EXCEPT="$ALWAYS_EXCEPT 65ic 180 184c"
83 [ "$SLOW" = "no" ] && EXCEPT_SLOW="$EXCEPT_SLOW 51b 51ba"
90 pgrep ll_sa > /dev/null && { echo "There are ll_sa thread not exit!"; exit 20; }
91 cleanupall ${FORCE} $* || { echo "FAILed to clean up"; exit 20; }
100 check_swap_layouts_support()
102 $LCTL get_param -n llite.*.sbi_flags | grep -q layout ||
103 { skip "Does not support layout lock."; return 0; }
107 check_and_setup_lustre
111 MDT0=$($LCTL get_param -n mdc.*.mds_server_uuid |
112 awk '{ gsub(/_UUID/,""); print $1 }' | head -n1)
113 MAXFREE=${MAXFREE:-$((200000 * $OSTCOUNT))}
115 [ -f $DIR/d52a/foo ] && chattr -a $DIR/d52a/foo
116 [ -f $DIR/d52b/foo ] && chattr -i $DIR/d52b/foo
117 rm -rf $DIR/[Rdfs][0-9]*
119 # $RUNAS_ID may get set incorrectly somewhere else
120 [ $UID -eq 0 -a $RUNAS_ID -eq 0 ] && error "\$RUNAS_ID set to 0, but \$UID is also 0!"
122 check_runas_id $RUNAS_ID $RUNAS_GID $RUNAS
126 if [ "${ONLY}" = "MOUNT" ] ; then
127 echo "Lustre is up, please go on"
131 echo "preparing for tests involving mounts"
132 EXT2_DEV=${EXT2_DEV:-$TMP/SANITY.LOOP}
134 mke2fs -j -F $EXT2_DEV 8000 > /dev/null
135 echo # add a newline after mke2fs.
139 OLDDEBUG=$(lctl get_param -n debug 2> /dev/null)
140 lctl set_param debug=-1 2> /dev/null || true
143 $CHECKSTAT -t file $DIR/$tfile || error "$tfile is not a file"
145 $CHECKSTAT -a $DIR/$tfile || error "$tfile was not removed"
147 run_test 0a "touch; rm ====================="
150 chmod 0755 $DIR || error "chmod 0755 $DIR failed"
151 $CHECKSTAT -p 0755 $DIR || error "$DIR permission is not 0755"
153 run_test 0b "chmod 0755 $DIR ============================="
156 $LCTL get_param mdc.*.import | grep "state: FULL" ||
157 error "import not FULL"
158 $LCTL get_param mdc.*.import | grep "target: $FSNAME-MDT" ||
161 run_test 0c "check import proc ============================="
164 test_mkdir -p $DIR/$tdir || error "mkdir $tdir failed"
165 test_mkdir -p $DIR/$tdir/d2 || error "mkdir $tdir/d2 failed"
166 test_mkdir $DIR/$tdir/d2 && error "we expect EEXIST, but not returned"
167 $CHECKSTAT -t dir $DIR/$tdir/d2 || error "$tdir/d2 is not a dir"
170 $CHECKSTAT -a $DIR/$tdir || error "$tdir was not removed"
172 run_test 1 "mkdir; remkdir; rmdir =============================="
175 test_mkdir -p $DIR/$tdir || error "mkdir $tdir failed"
176 touch $DIR/$tdir/$tfile || error "touch $tdir/$tfile failed"
177 $CHECKSTAT -t file $DIR/$tdir/$tfile || error "$tdir/$tfile not a file"
179 $CHECKSTAT -a $DIR/$tdir/$tfile || error "$tdir/$file is not removed"
181 run_test 2 "mkdir; touch; rmdir; check file ===================="
184 test_mkdir -p $DIR/$tdir || error "mkdir $tdir failed"
185 $CHECKSTAT -t dir $DIR/$tdir || error "$tdir is not a directory"
186 touch $DIR/$tdir/$tfile
187 $CHECKSTAT -t file $DIR/$tdir/$tfile || error "$tdir/$tfile not a file"
189 $CHECKSTAT -a $DIR/$tdir || error "$tdir is not removed"
191 run_test 3 "mkdir; touch; rmdir; check dir ====================="
193 # LU-4471 - failed rmdir on remote directories still removes directory on MDT0
197 test_mkdir $DIR/$tdir ||
198 error "Create remote directory failed"
200 touch $DIR/$tdir/$tfile ||
201 error "Create file under remote directory failed"
204 error "Expect error removing in-use dir $DIR/$tdir"
206 test -d $DIR/$tdir || error "Remote directory disappeared"
208 rm -rf $DIR/$tdir || error "remove remote dir error"
210 run_test 4 "mkdir; touch dir/file; rmdir; checkdir (expect error)"
213 test_mkdir -p $DIR/$tdir || error "mkdir $tdir failed"
214 test_mkdir $DIR/$tdir/d2 || error "mkdir $tdir/d2 failed"
215 chmod 0707 $DIR/$tdir/d2 || error "chmod 0707 $tdir/d2 failed"
216 $CHECKSTAT -t dir -p 0707 $DIR/$tdir/d2 || error "$tdir/d2 not mode 707"
217 $CHECKSTAT -t dir $DIR/$tdir/d2 || error "$tdir/d2 is not a directory"
219 run_test 5 "mkdir .../d5 .../d5/d2; chmod .../d5/d2 ============"
222 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
223 chmod 0666 $DIR/$tfile || error "chmod 0666 $tfile failed"
224 $CHECKSTAT -t file -p 0666 -u \#$UID $DIR/$tfile ||
225 error "$tfile does not have perm 0666 or UID $UID"
226 $RUNAS chmod 0444 $DIR/$tfile && error "chmod $tfile worked on UID $UID"
227 $CHECKSTAT -t file -p 0666 -u \#$UID $DIR/$tfile ||
228 error "$tfile should be 0666 and owned by UID $UID"
230 run_test 6a "touch f6a; chmod f6a; $RUNAS chmod f6a (should return error) =="
233 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID" && return
235 chown $RUNAS_ID $DIR/$tfile || error "chown $RUNAS_ID $file failed"
236 $CHECKSTAT -t file -u \#$RUNAS_ID $DIR/$tfile ||
237 error "$tfile should be owned by UID $RUNAS_ID"
238 $RUNAS chown $UID $DIR/$tfile && error "chown $UID $file succeeded"
239 $CHECKSTAT -t file -u \#$RUNAS_ID $DIR/$tfile ||
240 error "$tfile should be owned by UID $RUNAS_ID"
242 run_test 6c "touch f6c; chown f6c; $RUNAS chown f6c (should return error) =="
245 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID" && return
247 chgrp $RUNAS_ID $DIR/$tfile || error "chgrp $RUNAS_ID $file failed"
248 $CHECKSTAT -t file -u \#$UID -g \#$RUNAS_ID $DIR/$tfile ||
249 error "$tfile should be owned by GID $UID"
250 $RUNAS chgrp $UID $DIR/$tfile && error "chgrp $UID $file succeeded"
251 $CHECKSTAT -t file -u \#$UID -g \#$RUNAS_ID $DIR/$tfile ||
252 error "$tfile should be owned by UID $UID and GID $RUNAS_ID"
254 run_test 6e "touch f6e; chgrp f6e; $RUNAS chgrp f6e (should return error) =="
257 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID" && return
258 test_mkdir $DIR/$tdir || error "mkdir $tfile failed"
259 chmod 777 $DIR/$tdir || error "chmod 0777 $tdir failed"
260 $RUNAS mkdir $DIR/$tdir/d || error "mkdir $tdir/d failed"
261 chmod g+s $DIR/$tdir/d || error "chmod g+s $tdir/d failed"
262 test_mkdir $DIR/$tdir/d/subdir || error "mkdir $tdir/d/subdir failed"
263 $CHECKSTAT -g \#$RUNAS_GID $DIR/$tdir/d/subdir ||
264 error "$tdir/d/subdir should be GID $RUNAS_GID"
266 run_test 6g "Is new dir in sgid dir inheriting group?"
268 test_6h() { # bug 7331
269 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID" && return
270 touch $DIR/$tfile || error "touch failed"
271 chown $RUNAS_ID:$RUNAS_GID $DIR/$tfile || error "initial chown failed"
272 $RUNAS -G$RUNAS_GID chown $RUNAS_ID:0 $DIR/$tfile &&
273 error "chown $RUNAS_ID:0 $tfile worked as GID $RUNAS_GID"
274 $CHECKSTAT -t file -u \#$RUNAS_ID -g \#$RUNAS_GID $DIR/$tfile ||
275 error "$tdir/$tfile should be UID $RUNAS_UID GID $RUNAS_GID"
277 run_test 6h "$RUNAS chown RUNAS_ID.0 .../f6h (should return error)"
280 test_mkdir $DIR/$tdir
281 $MCREATE $DIR/$tdir/$tfile
282 chmod 0666 $DIR/$tdir/$tfile
283 $CHECKSTAT -t file -p 0666 $DIR/$tdir/$tfile ||
284 error "$tdir/$tfile should be mode 0666"
286 run_test 7a "mkdir .../d7; mcreate .../d7/f; chmod .../d7/f ===="
289 if [ ! -d $DIR/$tdir ]; then
290 test_mkdir $DIR/$tdir
292 $MCREATE $DIR/$tdir/$tfile
293 echo -n foo > $DIR/$tdir/$tfile
294 [ "$(cat $DIR/$tdir/$tfile)" = "foo" ] || error "$tdir/$tfile not 'foo'"
295 $CHECKSTAT -t file -s 3 $DIR/$tdir/$tfile || error "$tfile size not 3"
297 run_test 7b "mkdir .../d7; mcreate d7/f2; echo foo > d7/f2 ====="
300 test_mkdir $DIR/$tdir
301 touch $DIR/$tdir/$tfile
302 chmod 0666 $DIR/$tdir/$tfile
303 $CHECKSTAT -t file -p 0666 $DIR/$tdir/$tfile ||
304 error "$tfile mode not 0666"
306 run_test 8 "mkdir .../d8; touch .../d8/f; chmod .../d8/f ======="
309 test_mkdir $DIR/$tdir
310 test_mkdir $DIR/$tdir/d2
311 test_mkdir $DIR/$tdir/d2/d3
312 $CHECKSTAT -t dir $DIR/$tdir/d2/d3 || error "$tdir/d2/d3 not a dir"
314 run_test 9 "mkdir .../d9 .../d9/d2 .../d9/d2/d3 ================"
317 test_mkdir $DIR/$tdir
318 test_mkdir $DIR/$tdir/d2
319 touch $DIR/$tdir/d2/$tfile
320 $CHECKSTAT -t file $DIR/$tdir/d2/$tfile ||
321 error "$tdir/d2/$tfile not a file"
323 run_test 10 "mkdir .../d10 .../d10/d2; touch .../d10/d2/f ======"
326 test_mkdir $DIR/$tdir
327 test_mkdir $DIR/$tdir/d2
328 chmod 0666 $DIR/$tdir/d2
329 chmod 0705 $DIR/$tdir/d2
330 $CHECKSTAT -t dir -p 0705 $DIR/$tdir/d2 ||
331 error "$tdir/d2 mode not 0705"
333 run_test 11 "mkdir .../d11 d11/d2; chmod .../d11/d2 ============"
336 test_mkdir $DIR/$tdir
337 touch $DIR/$tdir/$tfile
338 chmod 0666 $DIR/$tdir/$tfile
339 chmod 0654 $DIR/$tdir/$tfile
340 $CHECKSTAT -t file -p 0654 $DIR/$tdir/$tfile ||
341 error "$tdir/d2 mode not 0654"
343 run_test 12 "touch .../d12/f; chmod .../d12/f .../d12/f ========"
346 test_mkdir $DIR/$tdir
347 dd if=/dev/zero of=$DIR/$tdir/$tfile count=10
349 $CHECKSTAT -t file -s 0 $DIR/$tdir/$tfile ||
350 error "$tdir/$tfile size not 0 after truncate"
352 run_test 13 "creat .../d13/f; dd .../d13/f; > .../d13/f ========"
355 test_mkdir $DIR/$tdir
356 touch $DIR/$tdir/$tfile
358 $CHECKSTAT -a $DIR/$tdir/$tfile || error "$tdir/$tfile not removed"
360 run_test 14 "touch .../d14/f; rm .../d14/f; rm .../d14/f ======="
363 test_mkdir $DIR/$tdir
364 touch $DIR/$tdir/$tfile
365 mv $DIR/$tdir/$tfile $DIR/$tdir/${tfile}_2
366 $CHECKSTAT -t file $DIR/$tdir/${tfile}_2 ||
367 error "$tdir/${tfile_2} not a file after rename"
368 rm $DIR/$tdir/${tfile}_2 || error "unlink failed after rename"
370 run_test 15 "touch .../d15/f; mv .../d15/f .../d15/f2 =========="
373 test_mkdir $DIR/$tdir
374 touch $DIR/$tdir/$tfile
375 rm -rf $DIR/$tdir/$tfile
376 $CHECKSTAT -a $DIR/$tdir/$tfile || error "$tdir/$tfile not removed"
378 run_test 16 "touch .../d16/f; rm -rf .../d16/f ================="
381 test_mkdir -p $DIR/$tdir
382 touch $DIR/$tdir/$tfile
383 ln -s $DIR/$tdir/$tfile $DIR/$tdir/l-exist
385 $CHECKSTAT -l $DIR/$tdir/$tfile $DIR/$tdir/l-exist ||
386 error "$tdir/l-exist not a symlink"
387 $CHECKSTAT -f -t f $DIR/$tdir/l-exist ||
388 error "$tdir/l-exist not referencing a file"
389 rm -f $DIR/$tdir/l-exist
390 $CHECKSTAT -a $DIR/$tdir/l-exist || error "$tdir/l-exist not removed"
392 run_test 17a "symlinks: create, remove (real) =================="
395 test_mkdir -p $DIR/$tdir
396 ln -s no-such-file $DIR/$tdir/l-dangle
398 $CHECKSTAT -l no-such-file $DIR/$tdir/l-dangle ||
399 error "$tdir/l-dangle not referencing no-such-file"
400 $CHECKSTAT -fa $DIR/$tdir/l-dangle ||
401 error "$tdir/l-dangle not referencing non-existent file"
402 rm -f $DIR/$tdir/l-dangle
403 $CHECKSTAT -a $DIR/$tdir/l-dangle || error "$tdir/l-dangle not removed"
405 run_test 17b "symlinks: create, remove (dangling) =============="
407 test_17c() { # bug 3440 - don't save failed open RPC for replay
408 test_mkdir -p $DIR/$tdir
409 ln -s foo $DIR/$tdir/$tfile
410 cat $DIR/$tdir/$tfile && error "opened non-existent symlink" || true
412 run_test 17c "symlinks: open dangling (should return error) ===="
415 test_mkdir -p $DIR/$tdir
416 ln -s foo $DIR/$tdir/$tfile
417 touch $DIR/$tdir/$tfile || error "creating to new symlink"
419 run_test 17d "symlinks: create dangling ========================"
422 test_mkdir -p $DIR/$tdir
423 local foo=$DIR/$tdir/$tfile
424 ln -s $foo $foo || error "create symlink failed"
425 ls -l $foo || error "ls -l failed"
426 ls $foo && error "ls not failed" || true
428 run_test 17e "symlinks: create recursive symlink (should return error) ===="
431 test_mkdir -p $DIR/$tdir
432 ln -s 1234567890/2234567890/3234567890/4234567890 $DIR/$tdir/111
433 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890 $DIR/$tdir/222
434 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890 $DIR/$tdir/333
435 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890/9234567890/a234567890/b234567890 $DIR/$tdir/444
436 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890/9234567890/a234567890/b234567890/c234567890/d234567890/f234567890 $DIR/$tdir/555
437 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890/9234567890/a234567890/b234567890/c234567890/d234567890/f234567890/aaaaaaaaaa/bbbbbbbbbb/cccccccccc/dddddddddd/eeeeeeeeee/ffffffffff/ $DIR/$tdir/666
440 run_test 17f "symlinks: long and very long symlink name ========================"
442 # str_repeat(S, N) generate a string that is string S repeated N times
447 while [ $((n -= 1)) -ge 0 ]; do
453 # Long symlinks and LU-2241
455 test_mkdir -p $DIR/$tdir
456 local TESTS="59 60 61 4094 4095"
458 # Fix for inode size boundary in 2.1.4
459 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.1.4) ] &&
462 # Patch not applied to 2.2 or 2.3 branches
463 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] &&
464 [ $(lustre_version_code $SINGLEMDS) -le $(version_code 2.3.55) ] &&
467 # skip long symlink name for rhel6.5.
468 # rhel6.5 has a limit (PATH_MAX - sizeof(struct filename))
469 grep -q '6.5' /etc/redhat-release &>/dev/null &&
470 TESTS="59 60 61 4062 4063"
473 local SYMNAME=$(str_repeat 'x' $i)
474 ln -s $SYMNAME $DIR/$tdir/f$i || error "failed $i-char symlink"
475 readlink $DIR/$tdir/f$i || error "failed $i-char readlink"
478 run_test 17g "symlinks: really long symlink name and inode boundaries"
480 test_17h() { #bug 17378
481 remote_mds_nodsh && skip "remote MDS with nodsh" && return
482 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
484 test_mkdir -p $DIR/$tdir
485 if [[ $MDSCOUNT -gt 1 ]]; then
486 mdt_idx=$($LFS getdirstripe -i $DIR/$tdir)
490 $SETSTRIPE -c -1 $DIR/$tdir
491 #define OBD_FAIL_MDS_LOV_PREP_CREATE 0x141
492 do_facet mds$((mdt_idx + 1)) lctl set_param fail_loc=0x80000141
493 touch $DIR/$tdir/$tfile || true
495 run_test 17h "create objects: lov_free_memmd() doesn't lbug"
497 test_17i() { #bug 20018
498 remote_mds_nodsh && skip "remote MDS with nodsh" && return
499 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
500 test_mkdir -c1 $DIR/$tdir
501 local foo=$DIR/$tdir/$tfile
503 if [[ $MDSCOUNT -gt 1 ]]; then
504 mdt_idx=$($LFS getdirstripe -i $DIR/$tdir)
508 ln -s $foo $foo || error "create symlink failed"
509 #define OBD_FAIL_MDS_READLINK_EPROTO 0x143
510 do_facet mds$((mdt_idx + 1)) lctl set_param fail_loc=0x80000143
511 ls -l $foo && error "error not detected"
514 run_test 17i "don't panic on short symlink"
516 test_17k() { #bug 22301
517 [[ -z "$(which rsync 2>/dev/null)" ]] &&
518 skip "no rsync command" && return 0
519 rsync --help | grep -q xattr ||
520 skip_env "$(rsync --version | head -n1) does not support xattrs"
521 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return 0
522 test_mkdir -p $DIR/$tdir
523 test_mkdir -p $DIR/$tdir.new
524 touch $DIR/$tdir/$tfile
525 ln -s $DIR/$tdir/$tfile $DIR/$tdir/$tfile.lnk
526 rsync -av -X $DIR/$tdir/ $DIR/$tdir.new ||
527 error "rsync failed with xattrs enabled"
529 run_test 17k "symlinks: rsync with xattrs enabled ========================="
531 test_17l() { # LU-279
532 [[ -z "$(which getfattr 2>/dev/null)" ]] &&
533 skip "no getfattr command" && return 0
534 test_mkdir -p $DIR/$tdir
535 touch $DIR/$tdir/$tfile
536 ln -s $DIR/$tdir/$tfile $DIR/$tdir/$tfile.lnk
537 for path in "$DIR/$tdir" "$DIR/$tdir/$tfile" "$DIR/$tdir/$tfile.lnk"; do
538 # -h to not follow symlinks. -m '' to list all the xattrs.
539 # grep to remove first line: '# file: $path'.
540 for xattr in `getfattr -hm '' $path 2>/dev/null | grep -v '^#'`;
542 lgetxattr_size_check $path $xattr ||
543 error "lgetxattr_size_check $path $xattr failed"
547 run_test 17l "Ensure lgetxattr's returned xattr size is consistent ========"
551 local short_sym="0123456789"
552 local WDIR=$DIR/${tdir}m
555 remote_mds_nodsh && skip "remote MDS with nodsh" && return
556 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] &&
557 [ $(lustre_version_code $SINGLEMDS) -le $(version_code 2.2.93) ] &&
558 skip "MDS 2.2.0-2.2.93 do not NUL-terminate symlinks" && return
560 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
561 skip "only for ldiskfs MDT" && return 0
563 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
567 # create a long symlink file
568 for ((i = 0; i < 4; ++i)); do
569 long_sym=${long_sym}${long_sym}
572 echo "create 512 short and long symlink files under $WDIR"
573 for ((i = 0; i < 256; ++i)); do
574 ln -sf ${long_sym}"a5a5" $WDIR/long-$i
575 ln -sf ${short_sym}"a5a5" $WDIR/short-$i
581 wait_delete_completed
583 echo "recreate the 512 symlink files with a shorter string"
584 for ((i = 0; i < 512; ++i)); do
585 # rewrite the symlink file with a shorter string
586 ln -sf ${long_sym} $WDIR/long-$i || error "long_sym failed"
587 ln -sf ${short_sym} $WDIR/short-$i || error "short_sym failed"
590 local mds_index=$(($($LFS getstripe -M $WDIR) + 1))
591 local devname=$(mdsdevname $mds_index)
593 echo "stop and checking mds${mds_index}:"
594 # e2fsck should not return error
596 run_e2fsck $(facet_active_host mds${mds_index}) $devname -n
599 start mds${mds_index} $devname $MDS_MOUNT_OPTS || error "start failed"
600 df $MOUNT > /dev/null 2>&1
602 error "e2fsck detected error for short/long symlink: rc=$rc"
604 run_test 17m "run e2fsck against MDT which contains short/long symlink"
606 check_fs_consistency_17n() {
610 # create/unlink in 17n only change 2 MDTs(MDT1/MDT2),
611 # so it only check MDT1/MDT2 instead of all of MDTs.
612 for mdt_index in 1 2; do
613 local devname=$(mdsdevname $mdt_index)
614 # e2fsck should not return error
616 run_e2fsck $(facet_active_host mds$mdt_index) $devname -n ||
619 start mds${mdt_index} $devname $MDS_MOUNT_OPTS ||
620 error "mount mds$mdt_index failed"
621 df $MOUNT > /dev/null 2>&1
629 remote_mds_nodsh && skip "remote MDS with nodsh" && return
630 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] &&
631 [ $(lustre_version_code $SINGLEMDS) -le $(version_code 2.2.93) ] &&
632 skip "MDS 2.2.0-2.2.93 do not NUL-terminate symlinks" && return
634 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
635 skip "only for ldiskfs MDT" && return 0
637 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 2 MDTs" && return
639 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
641 test_mkdir $DIR/$tdir
642 for ((i=0; i<10; i++)); do
643 $LFS mkdir -i1 -c2 $DIR/$tdir/remote_dir_${i} ||
644 error "create remote dir error $i"
645 createmany -o $DIR/$tdir/remote_dir_${i}/f 10 ||
646 error "create files under remote dir failed $i"
649 check_fs_consistency_17n ||
650 error "e2fsck report error after create files under remote dir"
652 for ((i = 0; i < 10; i++)); do
653 rm -rf $DIR/$tdir/remote_dir_${i} ||
654 error "destroy remote dir error $i"
657 check_fs_consistency_17n ||
658 error "e2fsck report error after unlink files under remote dir"
660 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.50) ] &&
661 skip "lustre < 2.4.50 does not support migrate mv " && return
663 for ((i = 0; i < 10; i++)); do
664 mkdir -p $DIR/$tdir/remote_dir_${i}
665 createmany -o $DIR/$tdir/remote_dir_${i}/f 10 ||
666 error "create files under remote dir failed $i"
667 $LFS migrate --mdt-index 1 $DIR/$tdir/remote_dir_${i} ||
668 error "migrate remote dir error $i"
670 check_fs_consistency_17n || error "e2fsck report error after migration"
672 for ((i = 0; i < 10; i++)); do
673 rm -rf $DIR/$tdir/remote_dir_${i} ||
674 error "destroy remote dir error $i"
677 check_fs_consistency_17n || error "e2fsck report error after unlink"
679 run_test 17n "run e2fsck against master/slave MDT which contains remote dir"
682 remote_mds_nodsh && skip "remote MDS with nodsh" && return
683 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.3.64) ] &&
684 skip "Need MDS version at least 2.3.64" && return
686 local WDIR=$DIR/${tdir}o
691 mdt_index=$($LFS getstripe -M $WDIR)
692 mdt_index=$((mdt_index+1))
696 #fail mds will wait the failover finish then set
697 #following fail_loc to avoid interfer the recovery process.
700 #define OBD_FAIL_OSD_LMA_INCOMPAT 0x194
701 do_facet mds${mdt_index} lctl set_param fail_loc=0x194
702 ls -l $WDIR/$tfile && rc=1
703 do_facet mds${mdt_index} lctl set_param fail_loc=0
704 [[ $rc -ne 0 ]] && error "stat file should fail"
707 run_test 17o "stat file with incompat LMA feature"
710 touch $DIR/$tfile || error "Failed to touch $DIR/$tfile: $?"
711 ls $DIR || error "Failed to ls $DIR: $?"
713 run_test 18 "touch .../f ; ls ... =============================="
719 $CHECKSTAT -a $DIR/$tfile || error "$tfile was not removed"
721 run_test 19a "touch .../f19 ; ls -l ... ; rm .../f19 ==========="
724 ls -l $DIR/$tfile && error "ls -l $tfile failed"|| true
726 run_test 19b "ls -l .../f19 (should return error) =============="
729 [ $RUNAS_ID -eq $UID ] &&
730 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
731 $RUNAS touch $DIR/$tfile && error "create non-root file failed" || true
733 run_test 19c "$RUNAS touch .../f19 (should return error) =="
736 cat $DIR/f19 && error || true
738 run_test 19d "cat .../f19 (should return error) =============="
750 $CHECKSTAT -a $DIR/$tfile || error "$tfile was not removed"
752 run_test 20 "touch .../f ; ls -l ... ==========================="
755 test_mkdir -p $DIR/$tdir
756 [ -f $DIR/$tdir/dangle ] && rm -f $DIR/$tdir/dangle
757 ln -s dangle $DIR/$tdir/link
758 echo foo >> $DIR/$tdir/link
759 cat $DIR/$tdir/dangle
760 $CHECKSTAT -t link $DIR/$tdir/link || error "$tdir/link not a link"
761 $CHECKSTAT -f -t file $DIR/$tdir/link ||
762 error "$tdir/link not linked to a file"
764 run_test 21 "write to dangling link ============================"
768 test_mkdir -p $DIR/$tdir
769 chown $RUNAS_ID:$RUNAS_GID $WDIR
770 (cd $WDIR || error "cd $WDIR failed";
771 $RUNAS tar cf - /etc/hosts /etc/sysconfig/network | \
773 ls -lR $WDIR/etc || error "ls -lR $WDIR/etc failed"
774 $CHECKSTAT -t dir $WDIR/etc || error "checkstat -t dir failed"
775 $CHECKSTAT -u \#$RUNAS_ID -g \#$RUNAS_GID $WDIR/etc || error "checkstat -u failed"
777 run_test 22 "unpack tar archive as non-root user ==============="
781 test_mkdir -p $DIR/$tdir
782 local file=$DIR/$tdir/$tfile
784 openfile -f O_CREAT:O_EXCL $file || error "$file create failed"
785 openfile -f O_CREAT:O_EXCL $file &&
786 error "$file recreate succeeded" || true
788 run_test 23a "O_CREAT|O_EXCL in subdir =========================="
790 test_23b() { # bug 18988
791 test_mkdir -p $DIR/$tdir
792 local file=$DIR/$tdir/$tfile
795 echo foo > $file || error "write filed"
796 echo bar >> $file || error "append filed"
797 $CHECKSTAT -s 8 $file || error "wrong size"
800 run_test 23b "O_APPEND check =========================="
804 echo '-- same directory rename'
805 test_mkdir $DIR/$tdir
806 touch $DIR/$tdir/$tfile.1
807 mv $DIR/$tdir/$tfile.1 $DIR/$tdir/$tfile.2
808 $CHECKSTAT -t file $DIR/$tdir/$tfile.2 || error "$tfile.2 not a file"
810 run_test 24a "rename file to non-existent target"
813 test_mkdir $DIR/$tdir
814 touch $DIR/$tdir/$tfile.{1,2}
815 mv $DIR/$tdir/$tfile.1 $DIR/$tdir/$tfile.2
816 $CHECKSTAT -a $DIR/$tdir/$tfile.1 || error "$tfile.1 exists"
817 $CHECKSTAT -t file $DIR/$tdir/$tfile.2 || error "$tfile.2 not a file"
819 run_test 24b "rename file to existing target"
822 test_mkdir $DIR/$tdir
823 test_mkdir $DIR/$tdir/d$testnum.1
824 mv $DIR/$tdir/d$testnum.1 $DIR/$tdir/d$testnum.2
825 $CHECKSTAT -a $DIR/$tdir/d$testnum.1 || error "d$testnum.1 exists"
826 $CHECKSTAT -t dir $DIR/$tdir/d$testnum.2 || error "d$testnum.2 not dir"
828 run_test 24c "rename directory to non-existent target"
831 test_mkdir -c1 $DIR/$tdir
832 test_mkdir -c1 $DIR/$tdir/d$testnum.1
833 test_mkdir -c1 $DIR/$tdir/d$testnum.2
834 mrename $DIR/$tdir/d$testnum.1 $DIR/$tdir/d$testnum.2
835 $CHECKSTAT -a $DIR/$tdir/d$testnum.1 || error "d$testnum.1 exists"
836 $CHECKSTAT -t dir $DIR/$tdir/d$testnum.2 || error "d$testnum.2 not dir"
838 run_test 24d "rename directory to existing target"
841 echo '-- cross directory renames --'
845 mv $DIR/R5a/f $DIR/R5b/g
846 $CHECKSTAT -a $DIR/R5a/f || error
847 $CHECKSTAT -t file $DIR/R5b/g || error
849 run_test 24e "touch .../R5a/f; rename .../R5a/f .../R5b/g ======"
854 touch $DIR/R6a/f $DIR/R6b/g
855 mv $DIR/R6a/f $DIR/R6b/g
856 $CHECKSTAT -a $DIR/R6a/f || error
857 $CHECKSTAT -t file $DIR/R6b/g || error
859 run_test 24f "touch .../R6a/f R6b/g; mv .../R6a/f .../R6b/g ===="
864 test_mkdir $DIR/R7a/d
865 mv $DIR/R7a/d $DIR/R7b/e
866 $CHECKSTAT -a $DIR/R7a/d || error
867 $CHECKSTAT -t dir $DIR/R7b/e || error
869 run_test 24g "mkdir .../R7{a,b}/d; mv .../R7a/d .../R7b/e ======"
872 test_mkdir -c1 $DIR/R8a
873 test_mkdir -c1 $DIR/R8b
874 test_mkdir -c1 $DIR/R8a/d
875 test_mkdir -c1 $DIR/R8b/e
876 mrename $DIR/R8a/d $DIR/R8b/e
877 $CHECKSTAT -a $DIR/R8a/d || error
878 $CHECKSTAT -t dir $DIR/R8b/e || error
880 run_test 24h "mkdir .../R8{a,b}/{d,e}; rename .../R8a/d .../R8b/e"
883 echo "-- rename error cases"
887 mrename $DIR/R9/f $DIR/R9/a
888 $CHECKSTAT -t file $DIR/R9/f || error
889 $CHECKSTAT -t dir $DIR/R9/a || error
890 $CHECKSTAT -a $DIR/R9/a/f || error
892 run_test 24i "rename file to dir error: touch f ; mkdir a ; rename f a"
896 mrename $DIR/R10/f $DIR/R10/g
897 $CHECKSTAT -t dir $DIR/R10 || error
898 $CHECKSTAT -a $DIR/R10/f || error
899 $CHECKSTAT -a $DIR/R10/g || error
901 run_test 24j "source does not exist ============================"
905 test_mkdir $DIR/R11a/d
907 mv $DIR/R11a/f $DIR/R11a/d
908 $CHECKSTAT -a $DIR/R11a/f || error
909 $CHECKSTAT -t file $DIR/R11a/d/f || error
911 run_test 24k "touch .../R11a/f; mv .../R11a/f .../R11a/d ======="
913 # bug 2429 - rename foo foo foo creates invalid file
916 $MULTIOP $f OcNs || error
918 run_test 24l "Renaming a file to itself ========================"
922 $MULTIOP $f OcLN ${f}2 ${f}2 || error "link ${f}2 ${f}2 failed"
923 # on ext3 this does not remove either the source or target files
924 # though the "expected" operation would be to remove the source
925 $CHECKSTAT -t file ${f} || error "${f} missing"
926 $CHECKSTAT -t file ${f}2 || error "${f}2 missing"
928 run_test 24m "Renaming a file to a hard link to itself ========="
932 # this stats the old file after it was renamed, so it should fail
936 $CHECKSTAT ${f}.rename
939 run_test 24n "Statting the old file after renaming (Posix rename 2)"
942 test_mkdir -p $DIR/d24o
943 rename_many -s random -v -n 10 $DIR/d24o
945 run_test 24o "rename of files during htree split ==============="
950 DIRINO=`ls -lid $DIR/R12a | awk '{ print $1 }'`
951 mrename $DIR/R12a $DIR/R12b
952 $CHECKSTAT -a $DIR/R12a || error
953 $CHECKSTAT -t dir $DIR/R12b || error
954 DIRINO2=`ls -lid $DIR/R12b | awk '{ print $1 }'`
955 [ "$DIRINO" = "$DIRINO2" ] || error "R12a $DIRINO != R12b $DIRINO2"
957 run_test 24p "mkdir .../R12{a,b}; rename .../R12a .../R12b"
959 cleanup_multiop_pause() {
965 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
968 local DIRINO=$(ls -lid $DIR/R13a | awk '{ print $1 }')
969 multiop_bg_pause $DIR/R13b D_c || error "multiop failed to start"
972 trap cleanup_multiop_pause EXIT
973 mrename $DIR/R13a $DIR/R13b
974 $CHECKSTAT -a $DIR/R13a || error "R13a still exists"
975 $CHECKSTAT -t dir $DIR/R13b || error "R13b does not exist"
976 local DIRINO2=$(ls -lid $DIR/R13b | awk '{ print $1 }')
977 [ "$DIRINO" = "$DIRINO2" ] || error "R13a $DIRINO != R13b $DIRINO2"
978 cleanup_multiop_pause
979 wait $MULTIPID || error "multiop close failed"
981 run_test 24q "mkdir .../R13{a,b}; open R13b rename R13a R13b ==="
983 test_24r() { #bug 3789
985 test_mkdir $DIR/R14a/b
986 mrename $DIR/R14a $DIR/R14a/b && error "rename to subdir worked!"
987 $CHECKSTAT -t dir $DIR/R14a || error "$DIR/R14a missing"
988 $CHECKSTAT -t dir $DIR/R14a/b || error "$DIR/R14a/b missing"
990 run_test 24r "mkdir .../R14a/b; rename .../R14a .../R14a/b ====="
994 test_mkdir $DIR/R15a/b
995 test_mkdir $DIR/R15a/b/c
996 mrename $DIR/R15a $DIR/R15a/b/c && error "rename to sub-subdir worked!"
997 $CHECKSTAT -t dir $DIR/R15a || error "$DIR/R15a missing"
998 $CHECKSTAT -t dir $DIR/R15a/b/c || error "$DIR/R15a/b/c missing"
1000 run_test 24s "mkdir .../R15a/b/c; rename .../R15a .../R15a/b/c ="
1002 test_mkdir $DIR/R16a
1003 test_mkdir $DIR/R16a/b
1004 test_mkdir $DIR/R16a/b/c
1005 mrename $DIR/R16a/b/c $DIR/R16a && error "rename to sub-subdir worked!"
1006 $CHECKSTAT -t dir $DIR/R16a || error "$DIR/R16a missing"
1007 $CHECKSTAT -t dir $DIR/R16a/b/c || error "$DIR/R16a/b/c missing"
1009 run_test 24t "mkdir .../R16a/b/c; rename .../R16a/b/c .../R16a ="
1011 test_24u() { # bug12192
1012 $MULTIOP $DIR/$tfile C2w$((2048 * 1024))c || error
1013 $CHECKSTAT -s $((2048 * 1024)) $DIR/$tfile || error "wrong file size"
1015 run_test 24u "create stripe file"
1021 simple_cleanup_common() {
1024 wait_delete_completed
1027 max_pages_per_rpc() {
1028 $LCTL get_param -n mdc.*.max_pages_per_rpc | head -n1
1032 local NRFILES=100000
1033 local FREE_INODES=$(mdt_free_inodes 0)
1034 [[ $FREE_INODES -lt $NRFILES ]] &&
1035 skip "not enough free inodes $FREE_INODES required $NRFILES" &&
1038 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1039 trap simple_cleanup_common EXIT
1041 # Performance issue on ZFS see LU-4072 (c.f. LU-2887)
1042 [ $(facet_fstype $SINGLEMDS) = "zfs" ] && NRFILES=10000
1044 test_mkdir -p $DIR/$tdir
1045 createmany -m $DIR/$tdir/$tfile $NRFILES
1047 cancel_lru_locks mdc
1048 lctl set_param mdc.*.stats clear
1050 ls $DIR/$tdir >/dev/null || error "error in listing large dir"
1052 # LU-5 large readdir
1053 # DIRENT_SIZE = 32 bytes for sizeof(struct lu_dirent) +
1054 # 8 bytes for name(filename is mostly 5 in this test) +
1055 # 8 bytes for luda_type
1056 # take into account of overhead in lu_dirpage header and end mark in
1057 # each page, plus one in RPC_NUM calculation.
1059 RPC_SIZE=$(($(max_pages_per_rpc) * $(page_size)))
1060 RPC_NUM=$(((NRFILES * DIRENT_SIZE + RPC_SIZE - 1) / RPC_SIZE + 1))
1061 mds_readpage=$(lctl get_param mdc.*MDT0000*.stats |
1062 awk '/^mds_readpage/ {print $2}')
1063 [[ $mds_readpage -gt $RPC_NUM ]] &&
1064 error "large readdir doesn't take effect"
1066 simple_cleanup_common
1068 run_test 24v "list directory with large files (handle hash collision, bug: 17560)"
1070 test_24w() { # bug21506
1072 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=4096 || return 1
1073 dd if=/dev/zero bs=$SZ1 count=1 >> $DIR/$tfile || return 2
1074 dd if=$DIR/$tfile of=$DIR/${tfile}_left bs=1M skip=4097 || return 3
1075 SZ2=`ls -l $DIR/${tfile}_left | awk '{print $5}'`
1076 [[ "$SZ1" -eq "$SZ2" ]] ||
1077 error "Error reading at the end of the file $tfile"
1079 run_test 24w "Reading a file larger than 4Gb"
1082 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 2 MDTs" && return
1084 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.56) ]] &&
1085 skip "Need MDS version at least 2.7.56" && return
1087 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1089 local remote_dir=$DIR/$tdir/remote_dir
1091 test_mkdir -p $DIR/$tdir
1092 $LFS mkdir -i $MDTIDX $remote_dir ||
1093 error "create remote directory failed"
1095 test_mkdir -p $DIR/$tdir/src_dir
1096 touch $DIR/$tdir/src_file
1097 test_mkdir -p $remote_dir/tgt_dir
1098 touch $remote_dir/tgt_file
1100 mrename $DIR/$tdir/src_dir $remote_dir/tgt_dir ||
1101 error "rename dir cross MDT failed!"
1103 mrename $DIR/$tdir/src_file $remote_dir/tgt_file ||
1104 error "rename file cross MDT failed!"
1106 touch $DIR/$tdir/ln_file
1107 ln $DIR/$tdir/ln_file $remote_dir/ln_name ||
1108 error "ln file cross MDT failed"
1110 rm -rf $DIR/$tdir || error "Can not delete directories"
1112 run_test 24x "cross MDT rename/link"
1115 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 2 MDTs" && return
1116 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1118 local remote_dir=$DIR/$tdir/remote_dir
1120 test_mkdir -p $DIR/$tdir
1121 $LFS mkdir -i $MDTIDX $remote_dir ||
1122 error "create remote directory failed"
1124 test_mkdir -p $remote_dir/src_dir
1125 touch $remote_dir/src_file
1126 test_mkdir -p $remote_dir/tgt_dir
1127 touch $remote_dir/tgt_file
1129 mrename $remote_dir/src_dir $remote_dir/tgt_dir ||
1130 error "rename subdir in the same remote dir failed!"
1132 mrename $remote_dir/src_file $remote_dir/tgt_file ||
1133 error "rename files in the same remote dir failed!"
1135 ln $remote_dir/tgt_file $remote_dir/tgt_file1 ||
1136 error "link files in the same remote dir failed!"
1138 rm -rf $DIR/$tdir || error "Can not delete directories"
1140 run_test 24y "rename/link on the same dir should succeed"
1142 test_24A() { # LU-3182
1146 test_mkdir -p $DIR/$tdir
1147 createmany -m $DIR/$tdir/$tfile $NFILES
1148 local t=$(ls $DIR/$tdir | wc -l)
1149 local u=$(ls $DIR/$tdir | sort -u | wc -l)
1150 local v=$(ls -ai $DIR/$tdir | sort -u | wc -l)
1151 if [ $t -ne $NFILES -o $u -ne $NFILES -o $v -ne $((NFILES + 2)) ] ; then
1152 error "Expected $NFILES files, got $t ($u unique $v .&..)"
1155 rm -rf $DIR/$tdir || error "Can not delete directories"
1157 run_test 24A "readdir() returns correct number of entries."
1159 test_24B() { # LU-4805
1160 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
1163 test_mkdir $DIR/$tdir
1164 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR/$tdir/striped_dir ||
1165 error "create striped dir failed"
1167 count=$(ls -ai $DIR/$tdir/striped_dir | wc -l)
1168 [ $count -eq 2 ] || error "Expected 2, got $count"
1170 touch $DIR/$tdir/striped_dir/a
1172 count=$(ls -ai $DIR/$tdir/striped_dir | wc -l)
1173 [ $count -eq 3 ] || error "Expected 3, got $count"
1175 touch $DIR/$tdir/striped_dir/.f
1177 count=$(ls -ai $DIR/$tdir/striped_dir | wc -l)
1178 [ $count -eq 4 ] || error "Expected 4, got $count"
1180 rm -rf $DIR/$tdir || error "Can not delete directories"
1182 run_test 24B "readdir for striped dir return correct number of entries"
1185 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
1191 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR/$tdir/d0/striped_dir ||
1192 error "create striped dir failed"
1194 cd $DIR/$tdir/d0/striped_dir
1196 local d0_ino=$(ls -i -l -a $DIR/$tdir | grep "d0" | awk '{print $1}')
1197 local d1_ino=$(ls -i -l -a $DIR/$tdir | grep "d1" | awk '{print $1}')
1198 local parent_ino=$(ls -i -l -a | grep "\.\." | awk '{print $1}')
1200 [ "$d0_ino" = "$parent_ino" ] ||
1201 error ".. wrong, expect $d0_ino, get $parent_ino"
1203 mv $DIR/$tdir/d0/striped_dir $DIR/$tdir/d1/ ||
1204 error "mv striped dir failed"
1206 parent_ino=$(ls -i -l -a | grep "\.\." | awk '{print $1}')
1208 [ "$d1_ino" = "$parent_ino" ] ||
1209 error ".. wrong after mv, expect $d1_ino, get $parent_ino"
1211 run_test 24C "check .. in striped dir"
1213 test_24D() { # LU-6101
1218 createmany -m $DIR/$tdir/$tfile $NFILES
1219 local t=$(ls $DIR/$tdir | wc -l)
1220 local u=$(ls $DIR/$tdir | sort -u | wc -l)
1221 local v=$(ls -ai $DIR/$tdir | sort -u | wc -l)
1222 if [ $t -ne $NFILES -o $u -ne $NFILES -o $v -ne $((NFILES + 2)) ] ; then
1223 error "Expected $NFILES files, got $t ($u unique $v .&..)"
1226 rm -rf $DIR/$tdir || error "Can not delete directories"
1228 run_test 24D "readdir() returns correct number of entries after cursor reload"
1231 [[ $MDSCOUNT -lt 4 ]] && skip "needs >= 4 MDTs" && return
1232 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1235 mkdir $DIR/$tdir/src_dir
1236 $LFS mkdir -i 1 $DIR/$tdir/src_dir/src_child ||
1237 error "create remote source failed"
1239 touch $DIR/$tdir/src_dir/src_child/a
1241 $LFS mkdir -i 2 $DIR/$tdir/tgt_dir ||
1242 error "create remote target dir failed"
1244 $LFS mkdir -i 3 $DIR/$tdir/tgt_dir/tgt_child ||
1245 error "create remote target child failed"
1247 mrename $DIR/$tdir/src_dir/src_child $DIR/$tdir/tgt_dir/tgt_child ||
1248 error "rename dir cross MDT failed!"
1252 $CHECKSTAT -t dir $DIR/$tdir/src_dir/src_child &&
1253 error "src_child still exists after rename"
1255 $CHECKSTAT -t file $DIR/$tdir/tgt_dir/tgt_child/a ||
1256 error "missing file(a) after rename"
1258 rm -rf $DIR/$tdir || error "Can not delete directories"
1260 run_test 24E "cross MDT rename/link"
1263 echo '== symlink sanity ============================================='
1267 touch $DIR/s25/foo || error
1269 run_test 25a "create file in symlinked directory ==============="
1272 [ ! -d $DIR/d25 ] && test_25a
1273 $CHECKSTAT -t file $DIR/s25/foo || error
1275 run_test 25b "lookup file in symlinked directory ==============="
1279 test_mkdir $DIR/d26/d26-2
1280 ln -s d26/d26-2 $DIR/s26
1281 touch $DIR/s26/foo || error
1283 run_test 26a "multiple component symlink ======================="
1286 test_mkdir -p $DIR/d26b/d26-2
1287 ln -s d26b/d26-2/foo $DIR/s26-2
1288 touch $DIR/s26-2 || error
1290 run_test 26b "multiple component symlink at end of lookup ======"
1293 test_mkdir $DIR/d26.2
1294 touch $DIR/d26.2/foo
1295 ln -s d26.2 $DIR/s26.2-1
1296 ln -s s26.2-1 $DIR/s26.2-2
1297 ln -s s26.2-2 $DIR/s26.2-3
1298 chmod 0666 $DIR/s26.2-3/foo
1300 run_test 26c "chain of symlinks ================================"
1302 # recursive symlinks (bug 439)
1304 ln -s d26-3/foo $DIR/d26-3
1306 run_test 26d "create multiple component recursive symlink ======"
1309 [ ! -h $DIR/d26-3 ] && test_26d
1312 run_test 26e "unlink multiple component recursive symlink ======"
1314 # recursive symlinks (bug 7022)
1316 test_mkdir -p $DIR/$tdir
1317 test_mkdir $DIR/$tdir/$tfile || error "mkdir $DIR/$tdir/$tfile failed"
1318 cd $DIR/$tdir/$tfile || error "cd $DIR/$tdir/$tfile failed"
1319 test_mkdir -p lndir/bar1 || error "mkdir lndir/bar1 failed"
1320 test_mkdir $DIR/$tdir/$tfile/$tfile || error "mkdir $tfile failed"
1321 cd $tfile || error "cd $tfile failed"
1322 ln -s .. dotdot || error "ln dotdot failed"
1323 ln -s dotdot/lndir lndir || error "ln lndir failed"
1324 cd $DIR/$tdir || error "cd $DIR/$tdir failed"
1325 output=`ls $tfile/$tfile/lndir/bar1`
1326 [ "$output" = bar1 ] && error "unexpected output"
1327 rm -r $tfile || error "rm $tfile failed"
1328 $CHECKSTAT -a $DIR/$tfile || error "$tfile not gone"
1330 run_test 26f "rm -r of a directory which has recursive symlink ="
1333 echo '== stripe sanity =============================================='
1334 test_mkdir -p $DIR/d27 || error "mkdir failed"
1336 $SETSTRIPE -c 1 $DIR/d27/f0 || error "setstripe failed"
1337 $CHECKSTAT -t file $DIR/d27/f0 || error "checkstat failed"
1338 log "== test_27a: write to one stripe file ========================="
1339 cp /etc/hosts $DIR/d27/f0 || error
1341 run_test 27a "one stripe file =================================="
1344 [[ $OSTCOUNT -lt 2 ]] && skip_env "skipping 2-stripe test" && return
1345 test_mkdir -p $DIR/d27
1346 $SETSTRIPE -c 2 $DIR/d27/f01 || error "setstripe failed"
1347 $GETSTRIPE -c $DIR/d27/f01
1348 [ $($GETSTRIPE -c $DIR/d27/f01) -eq 2 ] ||
1349 error "two-stripe file doesn't have two stripes"
1351 dd if=/dev/zero of=$DIR/d27/f01 bs=4k count=4 || error "dd failed"
1353 run_test 27b "create and write to two stripe file"
1356 test_mkdir -p $DIR/d27
1357 $SETSTRIPE -c 0 -i -1 -S 0 $DIR/d27/fdef || error "setstripe failed"
1358 $CHECKSTAT -t file $DIR/d27/fdef || error "checkstat failed"
1359 dd if=/dev/zero of=$DIR/d27/fdef bs=4k count=4 || error
1361 run_test 27d "create file with default settings ================"
1364 # LU-5839 adds check for existed layout before setting it
1365 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.56) ]] &&
1366 skip "Need MDS version at least 2.7.56" && return
1367 test_mkdir -p $DIR/d27
1368 $SETSTRIPE -c 2 $DIR/d27/f12 || error "setstripe failed"
1369 $SETSTRIPE -c 2 $DIR/d27/f12 && error "setstripe succeeded twice"
1370 $CHECKSTAT -t file $DIR/d27/f12 || error "checkstat failed"
1372 run_test 27e "setstripe existing file (should return error) ======"
1375 test_mkdir $DIR/$tdir
1376 $SETSTRIPE -S 100 -i 0 -c 1 $DIR/$tdir/$tfile &&
1377 error "$SETSTRIPE $DIR/$tdir/$tfile failed"
1378 $CHECKSTAT -t file $DIR/$tdir/$tfile &&
1379 error "$CHECKSTAT -t file $DIR/$tdir/$tfile should fail"
1380 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=4k count=4 || error "dd failed"
1381 $GETSTRIPE $DIR/$tdir/$tfile || error "$GETSTRIPE failed"
1383 run_test 27f "setstripe with bad stripe size (should return error)"
1386 test_mkdir -p $DIR/d27
1387 $MCREATE $DIR/d27/fnone || error "mcreate failed"
1388 $GETSTRIPE $DIR/d27/fnone 2>&1 | grep "no stripe info" ||
1389 error "$DIR/d27/fnone has object"
1391 run_test 27g "$GETSTRIPE with no objects"
1394 test_mkdir $DIR/$tdir
1395 touch $DIR/$tdir/$tfile || error "touch failed"
1396 [[ $($GETSTRIPE -c $DIR/$tdir/$tfile) -gt 0 ]] ||
1397 error "missing objects"
1399 run_test 27i "$GETSTRIPE with some objects"
1402 test_mkdir -p $DIR/d27
1403 $SETSTRIPE -i $OSTCOUNT $DIR/d27/f27j && error "setstripe failed"||true
1405 run_test 27j "setstripe with bad stripe offset (should return error)"
1407 test_27k() { # bug 2844
1408 test_mkdir -p $DIR/d27
1410 LL_MAX_BLKSIZE=$((4 * 1024 * 1024))
1411 [ ! -d $DIR/d27 ] && test_mkdir -p $DIR d27
1412 $SETSTRIPE -S 67108864 $FILE || error "setstripe failed"
1413 BLKSIZE=`stat $FILE | awk '/IO Block:/ { print $7 }'`
1414 [ $BLKSIZE -le $LL_MAX_BLKSIZE ] || error "1:$BLKSIZE > $LL_MAX_BLKSIZE"
1415 dd if=/dev/zero of=$FILE bs=4k count=1
1416 BLKSIZE=`stat $FILE | awk '/IO Block:/ { print $7 }'`
1417 [ $BLKSIZE -le $LL_MAX_BLKSIZE ] || error "2:$BLKSIZE > $LL_MAX_BLKSIZE"
1419 run_test 27k "limit i_blksize for broken user apps ============="
1422 test_mkdir -p $DIR/d27
1423 mcreate $DIR/f27l || error "creating file"
1424 $RUNAS $SETSTRIPE -c 1 $DIR/f27l && \
1425 error "setstripe should have failed" || true
1427 run_test 27l "check setstripe permissions (should return error)"
1430 [[ $OSTCOUNT -lt 2 ]] && skip_env "$OSTCOUNT < 2 OSTs -- skipping" &&
1433 ORIGFREE=$($LCTL get_param -n lov.$FSNAME-clilov-*.kbytesavail |
1435 if [[ $ORIGFREE -gt $MAXFREE ]]; then
1436 skip "$ORIGFREE > $MAXFREE skipping out-of-space test on OST0"
1439 trap simple_cleanup_common EXIT
1440 test_mkdir -p $DIR/$tdir
1441 $SETSTRIPE -i 0 -c 1 $DIR/$tdir/f27m_1
1442 dd if=/dev/zero of=$DIR/$tdir/f27m_1 bs=1024 count=$MAXFREE &&
1443 error "dd should fill OST0"
1445 while $SETSTRIPE -i 0 -c 1 $DIR/$tdir/f27m_$i; do
1447 [ $i -gt 256 ] && break
1450 touch $DIR/$tdir/f27m_$i
1451 [ `$GETSTRIPE $DIR/$tdir/f27m_$i | grep -A 10 obdidx | awk '{print $1}'| grep -w "0"` ] &&
1452 error "OST0 was full but new created file still use it"
1454 touch $DIR/$tdir/f27m_$i
1455 [ `$GETSTRIPE $DIR/$tdir/f27m_$i | grep -A 10 obdidx | awk '{print $1}'| grep -w "0"` ] &&
1456 error "OST0 was full but new created file still use it"
1457 simple_cleanup_common
1459 run_test 27m "create file while OST0 was full =================="
1462 local DELAY=$(do_facet $SINGLEMDS lctl get_param -n lov.*.qos_maxage | head -n 1 | awk '{print $1 * 2}')
1466 # OSCs keep a NOSPC flag that will be reset after ~5s (qos_maxage)
1467 # if the OST isn't full anymore.
1469 local OSTIDX=${1:-""}
1471 local list=$(comma_list $(osts_nodes))
1472 [ "$OSTIDX" ] && list=$(facet_host ost$((OSTIDX + 1)))
1474 do_nodes $list lctl set_param fail_loc=0
1475 sync # initiate all OST_DESTROYs from MDS to OST
1479 exhaust_precreations() {
1482 local FAILIDX=${3:-$OSTIDX}
1483 local ofacet=ost$((OSTIDX + 1))
1485 test_mkdir -p -c1 $DIR/$tdir
1486 local mdtidx=$($LFS getstripe -M $DIR/$tdir)
1487 local mfacet=mds$((mdtidx + 1))
1488 echo OSTIDX=$OSTIDX MDTIDX=$mdtidx
1490 local OST=$(ostname_from_index $OSTIDX)
1493 local mdtosc_proc1=$(get_mdtosc_proc_path $mfacet $OST)
1494 local last_id=$(do_facet $mfacet lctl get_param -n \
1495 osc.$mdtosc_proc1.prealloc_last_id)
1496 local next_id=$(do_facet $mfacet lctl get_param -n \
1497 osc.$mdtosc_proc1.prealloc_next_id)
1499 local mdtosc_proc2=$(get_mdtosc_proc_path $mfacet)
1500 do_facet $mfacet lctl get_param osc.$mdtosc_proc2.prealloc*
1502 test_mkdir -p $DIR/$tdir/${OST}
1503 $SETSTRIPE -i $OSTIDX -c 1 $DIR/$tdir/${OST}
1504 #define OBD_FAIL_OST_ENOSPC 0x215
1505 do_facet $ofacet lctl set_param fail_val=$FAILIDX fail_loc=0x215
1506 echo "Creating to objid $last_id on ost $OST..."
1507 createmany -o $DIR/$tdir/${OST}/f $next_id $((last_id - next_id + 2))
1508 do_facet $mfacet lctl get_param osc.$mdtosc_proc2.prealloc*
1509 do_facet $ofacet lctl set_param fail_loc=$FAILLOC
1513 exhaust_all_precreations() {
1515 for (( i=0; i < OSTCOUNT; i++ )) ; do
1516 exhaust_precreations $i $1 -1
1521 [[ $OSTCOUNT -lt 2 ]] && skip_env "too few OSTs" && return
1522 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1523 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1524 remote_ost_nodsh && skip "remote OST with nodsh" && return
1527 rm -f $DIR/$tdir/$tfile
1528 exhaust_precreations 0 0x80000215
1529 $SETSTRIPE -c -1 $DIR/$tdir
1530 touch $DIR/$tdir/$tfile || error
1531 $GETSTRIPE $DIR/$tdir/$tfile
1534 run_test 27n "create file with some full OSTs =================="
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_all_precreations 0x215
1546 touch $DIR/$tdir/$tfile && error "able to create $DIR/$tdir/$tfile"
1551 run_test 27o "create file with all full OSTs (should error) ===="
1554 [[ $OSTCOUNT -lt 2 ]] && skip_env "too few OSTs" && return
1555 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1556 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1557 remote_ost_nodsh && skip "remote OST with nodsh" && return
1560 rm -f $DIR/$tdir/$tfile
1561 test_mkdir -p $DIR/$tdir
1563 $MCREATE $DIR/$tdir/$tfile || error "mcreate failed"
1564 $TRUNCATE $DIR/$tdir/$tfile 80000000 || error "truncate failed"
1565 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat failed"
1567 exhaust_precreations 0 0x80000215
1568 echo foo >> $DIR/$tdir/$tfile || error "append failed"
1569 $CHECKSTAT -s 80000004 $DIR/$tdir/$tfile || error "checkstat failed"
1570 $GETSTRIPE $DIR/$tdir/$tfile
1574 run_test 27p "append to a truncated file with some full OSTs ==="
1577 [[ $OSTCOUNT -lt 2 ]] && skip_env "too few OSTs" && return
1578 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1579 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1580 remote_ost_nodsh && skip "remote OST with nodsh" && return
1583 rm -f $DIR/$tdir/$tfile
1585 test_mkdir -p $DIR/$tdir
1586 $MCREATE $DIR/$tdir/$tfile || error "mcreate $DIR/$tdir/$tfile failed"
1587 $TRUNCATE $DIR/$tdir/$tfile 80000000 ||error "truncate $DIR/$tdir/$tfile failed"
1588 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat failed"
1590 exhaust_all_precreations 0x215
1592 echo foo >> $DIR/$tdir/$tfile && error "append succeeded"
1593 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat 2 failed"
1597 run_test 27q "append to truncated file with all OSTs full (should error) ==="
1600 [[ $OSTCOUNT -lt 2 ]] && skip_env "too few OSTs" && return
1601 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1602 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1603 remote_ost_nodsh && skip "remote OST with nodsh" && return
1606 rm -f $DIR/$tdir/$tfile
1607 exhaust_precreations 0 0x80000215
1609 $SETSTRIPE -i 0 -c 2 $DIR/$tdir/$tfile # && error
1613 run_test 27r "stripe file with some full OSTs (shouldn't LBUG) ="
1615 test_27s() { # bug 10725
1616 test_mkdir -p $DIR/$tdir
1617 local stripe_size=$((4096 * 1024 * 1024)) # 2^32
1618 local stripe_count=0
1619 [ $OSTCOUNT -eq 1 ] || stripe_count=2
1620 $SETSTRIPE -S $stripe_size -c $stripe_count $DIR/$tdir &&
1621 error "stripe width >= 2^32 succeeded" || true
1624 run_test 27s "lsm_xfersize overflow (should error) (bug 10725)"
1626 test_27t() { # bug 10864
1631 $WLFS getstripe $tfile
1634 run_test 27t "check that utils parse path correctly"
1636 test_27u() { # bug 4900
1637 [[ $OSTCOUNT -lt 2 ]] && skip_env "too few OSTs" && return
1638 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1640 local list=$(comma_list $(mdts_nodes))
1642 #define OBD_FAIL_MDS_OSC_PRECREATE 0x139
1643 do_nodes $list $LCTL set_param fail_loc=0x139
1644 test_mkdir -p $DIR/$tdir
1646 createmany -o $DIR/$tdir/t- 1000
1647 do_nodes $list $LCTL set_param fail_loc=0
1649 TLOG=$DIR/$tfile.getstripe
1650 $GETSTRIPE $DIR/$tdir > $TLOG
1651 OBJS=$(awk -vobj=0 '($1 == 0) { obj += 1 } END { print obj; }' $TLOG)
1652 unlinkmany $DIR/$tdir/t- 1000
1653 [[ $OBJS -gt 0 ]] &&
1654 error "$OBJS objects created on OST-0. See $TLOG" || pass
1656 run_test 27u "skip object creation on OSC w/o objects =========="
1658 test_27v() { # bug 4900
1659 [[ $OSTCOUNT -lt 2 ]] && skip_env "too few OSTs" && return
1660 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1661 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1662 remote_ost_nodsh && skip "remote OST with nodsh" && return
1664 exhaust_all_precreations 0x215
1667 test_mkdir -p $DIR/$tdir
1668 $SETSTRIPE -c 1 $DIR/$tdir # 1 stripe / file
1670 touch $DIR/$tdir/$tfile
1671 #define OBD_FAIL_TGT_DELAY_PRECREATE 0x705
1673 for (( i=1; i < OSTCOUNT; i++ )); do
1674 do_facet ost$i lctl set_param fail_loc=0x705
1676 local START=`date +%s`
1677 createmany -o $DIR/$tdir/$tfile 32
1679 local FINISH=`date +%s`
1680 local TIMEOUT=`lctl get_param -n timeout`
1681 local PROCESS=$((FINISH - START))
1682 [ $PROCESS -ge $((TIMEOUT / 2)) ] && \
1683 error "$FINISH - $START >= $TIMEOUT / 2"
1684 sleep $((TIMEOUT / 2 - PROCESS))
1687 run_test 27v "skip object creation on slow OST ================="
1689 test_27w() { # bug 10997
1690 test_mkdir -p $DIR/$tdir || error "mkdir failed"
1691 $SETSTRIPE -S 65536 $DIR/$tdir/f0 || error "setstripe failed"
1692 [ $($GETSTRIPE -S $DIR/$tdir/f0) -ne 65536 ] &&
1693 error "stripe size $size != 65536" || true
1694 [ $($GETSTRIPE -d $DIR/$tdir | grep -c "stripe_count") -ne 1 ] &&
1695 error "$GETSTRIPE -d $DIR/$tdir failed" || true
1697 run_test 27w "check $SETSTRIPE -S option"
1700 [[ $OSTCOUNT -lt 2 ]] &&
1701 skip_env "skipping multiple stripe count/offset test" && return
1703 test_mkdir -p $DIR/$tdir || error "mkdir failed"
1704 for i in $(seq 1 $OSTCOUNT); do
1706 $SETSTRIPE -c $i -i $offset $DIR/$tdir/f$i ||
1707 error "setstripe -c $i -i $offset failed"
1708 count=$($GETSTRIPE -c $DIR/$tdir/f$i)
1709 index=$($GETSTRIPE -i $DIR/$tdir/f$i)
1710 [ $count -ne $i ] && error "stripe count $count != $i" || true
1711 [ $index -ne $offset ] &&
1712 error "stripe offset $index != $offset" || true
1715 run_test 27wa "check $SETSTRIPE -c -i options"
1718 remote_ost_nodsh && skip "remote OST with nodsh" && return
1719 [[ $OSTCOUNT -lt 2 ]] && skip_env "$OSTCOUNT < 2 OSTs" && return
1720 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1721 OFFSET=$(($OSTCOUNT - 1))
1723 local OST=$(ostname_from_index $OSTIDX)
1725 test_mkdir -p $DIR/$tdir
1726 $SETSTRIPE -c 1 $DIR/$tdir # 1 stripe per file
1727 do_facet ost$((OSTIDX + 1)) lctl set_param -n obdfilter.$OST.degraded 1
1729 createmany -o $DIR/$tdir/$tfile $OSTCOUNT
1730 for i in `seq 0 $OFFSET`; do
1731 [ `$GETSTRIPE $DIR/$tdir/$tfile$i | grep -A 10 obdidx | awk '{print $1}' | grep -w "$OSTIDX"` ] &&
1732 error "OST0 was degraded but new created file still use it"
1734 do_facet ost$((OSTIDX + 1)) lctl set_param -n obdfilter.$OST.degraded 0
1736 run_test 27x "create files while OST0 is degraded"
1739 [[ $OSTCOUNT -lt 2 ]] &&
1740 skip_env "$OSTCOUNT < 2 OSTs -- skipping" && return
1741 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1742 remote_ost_nodsh && skip "remote OST with nodsh" && return
1743 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1745 local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS $FSNAME-OST0000)
1746 local last_id=$(do_facet $SINGLEMDS lctl get_param -n \
1747 osc.$mdtosc.prealloc_last_id)
1748 local next_id=$(do_facet $SINGLEMDS lctl get_param -n \
1749 osc.$mdtosc.prealloc_next_id)
1750 local fcount=$((last_id - next_id))
1751 [[ $fcount -eq 0 ]] && skip "not enough space on OST0" && return
1752 [[ $fcount -gt $OSTCOUNT ]] && fcount=$OSTCOUNT
1754 local MDS_OSCS=$(do_facet $SINGLEMDS lctl dl |
1755 awk '/[oO][sS][cC].*md[ts]/ { print $4 }')
1756 local OST_DEACTIVE_IDX=-1
1761 for OSC in $MDS_OSCS; do
1762 OST=$(osc_to_ost $OSC)
1763 OSTIDX=$(index_from_ostuuid $OST)
1764 if [ $OST_DEACTIVE_IDX == -1 ]; then
1765 OST_DEACTIVE_IDX=$OSTIDX
1767 if [ $OSTIDX != $OST_DEACTIVE_IDX ]; then
1768 echo $OSC "is Deactivated:"
1769 do_facet $SINGLEMDS lctl --device %$OSC deactivate
1773 OSTIDX=$(index_from_ostuuid $OST)
1774 test_mkdir -p $DIR/$tdir
1775 $SETSTRIPE -c 1 $DIR/$tdir # 1 stripe / file
1777 for OSC in $MDS_OSCS; do
1778 OST=$(osc_to_ost $OSC)
1779 OSTIDX=$(index_from_ostuuid $OST)
1780 if [ $OSTIDX == $OST_DEACTIVE_IDX ]; then
1781 echo $OST "is degraded:"
1782 do_facet ost$((OSTIDX+1)) lctl set_param -n \
1783 obdfilter.$OST.degraded=1
1788 createmany -o $DIR/$tdir/$tfile $fcount
1790 for OSC in $MDS_OSCS; do
1791 OST=$(osc_to_ost $OSC)
1792 OSTIDX=$(index_from_ostuuid $OST)
1793 if [ $OSTIDX == $OST_DEACTIVE_IDX ]; then
1794 echo $OST "is recovered from degraded:"
1795 do_facet ost$((OSTIDX+1)) lctl set_param -n \
1796 obdfilter.$OST.degraded=0
1798 do_facet $SINGLEMDS lctl --device %$OSC activate
1802 # all osp devices get activated, hence -1 stripe count restored
1805 # sleep 2*lod_qos_maxage seconds waiting for lod qos to notice osp
1806 # devices get activated.
1808 $SETSTRIPE -c -1 $DIR/$tfile
1809 stripecnt=$($GETSTRIPE -c $DIR/$tfile)
1811 [ $stripecnt -ne $OSTCOUNT ] &&
1812 error "Of $OSTCOUNT OSTs, only $stripecnt is available"
1815 run_test 27y "create files while OST0 is degraded and the rest inactive"
1821 lmm_count=$($GETSTRIPE -c $1)
1822 lmm_seq=$($GETSTRIPE -v $1 | awk '/lmm_seq/ { print $2 }')
1823 lmm_oid=$($GETSTRIPE -v $1 | awk '/lmm_object_id/ { print $2 }')
1825 local old_ifs="$IFS"
1827 fid=($($LFS path2fid $1))
1830 log "FID seq ${fid[1]}, oid ${fid[2]} ver ${fid[3]}"
1831 log "LOV seq $lmm_seq, oid $lmm_oid, count: $lmm_count"
1833 # compare lmm_seq and lu_fid->f_seq
1834 [ $lmm_seq = ${fid[1]} ] || { error "SEQ mismatch"; return 1; }
1835 # compare lmm_object_id and lu_fid->oid
1836 [ $lmm_oid = ${fid[2]} ] || { error "OID mismatch"; return 2; }
1838 # check the trusted.fid attribute of the OST objects of the file
1839 local have_obdidx=false
1841 $GETSTRIPE $1 | while read obdidx oid hex seq; do
1842 # skip lines up to and including "obdidx"
1843 [ -z "$obdidx" ] && break
1844 [ "$obdidx" = "obdidx" ] && have_obdidx=true && continue
1845 $have_obdidx || continue
1847 local ost=$((obdidx + 1))
1848 local dev=$(ostdevname $ost)
1851 log "want: stripe:$stripe_nr ost:$obdidx oid:$oid/$hex seq:$seq"
1853 seq=$(echo $seq | sed -e "s/^0x//g")
1854 if [ $seq == 0 ] || [ $(facet_fstype ost$ost) == zfs ]; then
1855 oid_hex=$(echo $oid)
1857 oid_hex=$(echo $hex | sed -e "s/^0x//g")
1859 local obj_file="O/$seq/d$((oid %32))/$oid_hex"
1863 # Don't unmount/remount the OSTs if we don't need to do that.
1864 # LU-2577 changes filter_fid to be smaller, so debugfs needs
1865 # update too, until that use mount/ll_decode_filter_fid/mount.
1866 # Re-enable when debugfs will understand new filter_fid.
1868 if false && [ $(facet_fstype ost$ost) == ldiskfs ]; then
1869 ff=$(do_facet ost$ost "$DEBUGFS -c -R 'stat $obj_file' \
1870 $dev 2>/dev/null" | grep "parent=")
1873 mount_fstype ost$ost
1874 ff=$(do_facet ost$ost $LL_DECODE_FILTER_FID \
1875 $(facet_mntpt ost$ost)/$obj_file)
1876 unmount_fstype ost$ost
1877 start ost$ost $dev $OST_MOUNT_OPTS
1881 [ -z "$ff" ] && error "$obj_file: no filter_fid info"
1883 echo "$ff" | sed -e 's#.*objid=#got: objid=#'
1885 # /mnt/O/0/d23/23: objid=23 seq=0 parent=[0x200000400:0x1e:0x1]
1886 # fid: objid=23 seq=0 parent=[0x200000400:0x1e:0x0] stripe=1
1887 local ff_parent=$(echo $ff|sed -e 's/.*parent=.//')
1888 local ff_pseq=$(echo $ff_parent | cut -d: -f1)
1889 local ff_poid=$(echo $ff_parent | cut -d: -f2)
1891 if echo $ff_parent | grep -q 'stripe='; then
1892 ff_pstripe=$(echo $ff_parent | sed -e 's/.*stripe=//')
1895 # $LL_DECODE_FILTER_FID does not print "stripe="; look
1896 # into f_ver in this case. See the comment on
1899 ff_pstripe=$(echo $ff_parent | cut -d: -f3 |
1903 # compare lmm_seq and filter_fid->ff_parent.f_seq
1904 [ $ff_pseq = $lmm_seq ] ||
1905 error "FF parent SEQ $ff_pseq != $lmm_seq"
1906 # compare lmm_object_id and filter_fid->ff_parent.f_oid
1907 [ $ff_poid = $lmm_oid ] ||
1908 error "FF parent OID $ff_poid != $lmm_oid"
1909 (($ff_pstripe == $stripe_nr)) ||
1910 error "FF stripe $ff_pstripe != $stripe_nr"
1912 stripe_nr=$((stripe_nr + 1))
1917 remote_ost_nodsh && skip "remote OST with nodsh" && return
1918 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1919 test_mkdir -p $DIR/$tdir
1921 $SETSTRIPE -c 1 -i 0 -S 64k $DIR/$tdir/$tfile-1 ||
1922 { error "setstripe -c -1 failed"; return 1; }
1923 # We need to send a write to every object to get parent FID info set.
1924 # This _should_ also work for setattr, but does not currently.
1925 # touch $DIR/$tdir/$tfile-1 ||
1926 dd if=/dev/zero of=$DIR/$tdir/$tfile-1 bs=1M count=1 ||
1927 { error "dd $tfile-1 failed"; return 2; }
1928 $SETSTRIPE -c -1 -i $((OSTCOUNT - 1)) -S 1M $DIR/$tdir/$tfile-2 ||
1929 { error "setstripe -c -1 failed"; return 3; }
1930 dd if=/dev/zero of=$DIR/$tdir/$tfile-2 bs=1M count=$OSTCOUNT ||
1931 { error "dd $tfile-2 failed"; return 4; }
1933 # make sure write RPCs have been sent to OSTs
1936 check_seq_oid $DIR/$tdir/$tfile-1 || return 5
1937 check_seq_oid $DIR/$tdir/$tfile-2 || return 6
1939 run_test 27z "check SEQ/OID on the MDT and OST filesystems"
1941 test_27A() { # b=19102
1942 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1943 local restore_size=$($GETSTRIPE -S $MOUNT)
1944 local restore_count=$($GETSTRIPE -c $MOUNT)
1945 local restore_offset=$($GETSTRIPE -i $MOUNT)
1946 $SETSTRIPE -c 0 -i -1 -S 0 $MOUNT
1947 wait_update $HOSTNAME "$GETSTRIPE -c $MOUNT | sed 's/ *//g'" "1" 20 ||
1948 error "stripe count $($GETSTRIPE -c $MOUNT) != 1"
1949 local default_size=$($GETSTRIPE -S $MOUNT)
1950 local default_offset=$($GETSTRIPE -i $MOUNT)
1951 local dsize=$((1024 * 1024))
1952 [ $default_size -eq $dsize ] ||
1953 error "stripe size $default_size != $dsize"
1954 [ $default_offset -eq -1 ] ||error "stripe offset $default_offset != -1"
1955 $SETSTRIPE -c $restore_count -i $restore_offset -S $restore_size $MOUNT
1957 run_test 27A "check filesystem-wide default LOV EA values"
1959 test_27B() { # LU-2523
1960 test_mkdir -p $DIR/$tdir
1961 rm -f $DIR/$tdir/f0 $DIR/$tdir/f1
1963 # open f1 with O_LOV_DELAY_CREATE
1965 # call setstripe ioctl on open file descriptor for f1
1967 multiop $DIR/$tdir/f1 oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:nB1c \
1971 # open f1 with O_LOV_DELAY_CREATE
1973 # call setstripe ioctl on open file descriptor for f1
1975 multiop $DIR/$tdir/f1 oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:uB1c
1977 # Allow multiop to fail in imitation of NFS's busted semantics.
1980 run_test 27B "call setstripe on open unlinked file/rename victim"
1982 test_27C() { #LU-2871
1983 [[ $OSTCOUNT -lt 2 ]] && skip "needs >= 2 OSTs" && return
1991 test_mkdir -p $DIR/$tdir
1993 for i in $(seq 0 $((OSTCOUNT - 1))); do
1994 # set stripe across all OSTs starting from OST$i
1995 $SETSTRIPE -i $i -c -1 $tfile$i
1996 # get striping information
1997 ost_idx=($($GETSTRIPE $tfile$i |
1998 tail -n $((OSTCOUNT + 1)) | awk '{print $1}'))
2002 [ ${#ost_idx[@]} -eq $OSTCOUNT ] ||
2003 error "${#ost_idx[@]} != $OSTCOUNT"
2005 for index in $(seq 0 $((OSTCOUNT - 1))); do
2007 for j in $(echo ${ost_idx[@]}); do
2008 if [ $index -eq $j ]; then
2014 error "Can not find $index in ${ost_idx[@]}"
2018 run_test 27C "check full striping across all OSTs"
2021 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs" && return
2022 [ -n "$FILESET" ] && skip "SKIP due to FILESET set" && return
2023 local POOL=${POOL:-testpool}
2025 local last_ost=$(($OSTCOUNT - 1))
2027 local ost_list=$(seq $first_ost $ost_step $last_ost)
2028 local ost_range="$first_ost $last_ost $ost_step"
2030 test_mkdir -p $DIR/$tdir
2031 pool_add $POOL || error "pool_add failed"
2032 pool_add_targets $POOL $ost_range || error "pool_add_targets failed"
2033 llapi_layout_test -d$DIR/$tdir -p$POOL -o$OSTCOUNT ||
2034 error "llapi_layout_test failed"
2035 cleanup_pools || error "cleanup_pools failed"
2037 run_test 27D "validate llapi_layout API"
2039 # Verify that default_easize is increased from its initial value after
2040 # accessing a widely striped file.
2042 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs" && return
2043 [ $(lustre_version_code client) -lt $(version_code 2.5.57) ] &&
2044 skip "client does not have LU-3338 fix" && return
2046 # 72 bytes is the minimum space required to store striping
2047 # information for a file striped across one OST:
2048 # (sizeof(struct lov_user_md_v3) +
2049 # sizeof(struct lov_user_ost_data_v1))
2051 $LCTL set_param -n llite.*.default_easize $min_easize ||
2052 error "lctl set_param failed"
2053 local easize=$($LCTL get_param -n llite.*.default_easize)
2055 [ $easize -eq $min_easize ] ||
2056 error "failed to set default_easize"
2058 $LFS setstripe -c $OSTCOUNT $DIR/$tfile ||
2059 error "setstripe failed"
2063 easize=$($LCTL get_param -n llite.*.default_easize)
2065 [ $easize -gt $min_easize ] ||
2066 error "default_easize not updated"
2068 run_test 27E "check that default extended attribute size properly increases"
2070 # createtest also checks that device nodes are created and
2071 # then visible correctly (#2091)
2072 test_28() { # bug 2091
2074 $CREATETEST $DIR/d28/ct || error
2076 run_test 28 "create/mknod/mkdir with bad file types ============"
2079 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return 0
2080 cancel_lru_locks mdc
2086 declare -i LOCKCOUNTORIG=0
2087 for lock_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_count); do
2088 let LOCKCOUNTORIG=$LOCKCOUNTORIG+$lock_count
2090 [ $LOCKCOUNTORIG -eq 0 ] && error "No mdc lock count" && return 1
2092 declare -i LOCKUNUSEDCOUNTORIG=0
2093 for unused_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_unused_count); do
2094 let LOCKUNUSEDCOUNTORIG=$LOCKUNUSEDCOUNTORIG+$unused_count
2101 declare -i LOCKCOUNTCURRENT=0
2102 for lock_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_count); do
2103 let LOCKCOUNTCURRENT=$LOCKCOUNTCURRENT+$lock_count
2106 declare -i LOCKUNUSEDCOUNTCURRENT=0
2107 for unused_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_unused_count); do
2108 let LOCKUNUSEDCOUNTCURRENT=$LOCKUNUSEDCOUNTCURRENT+$unused_count
2111 if [[ $LOCKCOUNTCURRENT -gt $LOCKCOUNTORIG ]]; then
2112 $LCTL set_param -n ldlm.dump_namespaces ""
2113 error "CURRENT: $LOCKCOUNTCURRENT > $LOCKCOUNTORIG"
2114 $LCTL dk | sort -k4 -t: > $TMP/test_29.dk
2115 log "dumped log to $TMP/test_29.dk (bug 5793)"
2118 if [[ $LOCKUNUSEDCOUNTCURRENT -gt $LOCKUNUSEDCOUNTORIG ]]; then
2119 error "UNUSED: $LOCKUNUSEDCOUNTCURRENT > $LOCKUNUSEDCOUNTORIG"
2120 $LCTL dk | sort -k4 -t: > $TMP/test_29.dk
2121 log "dumped log to $TMP/test_29.dk (bug 5793)"
2125 run_test 29 "IT_GETATTR regression ============================"
2127 test_30a() { # was test_30
2128 cp $(which ls) $DIR || cp /bin/ls $DIR
2132 run_test 30a "execute binary from Lustre (execve) =============="
2135 cp `which ls` $DIR || cp /bin/ls $DIR
2137 $RUNAS $DIR/ls / || error
2140 run_test 30b "execute binary from Lustre as non-root ==========="
2142 test_30c() { # b=22376
2143 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2144 cp `which ls` $DIR || cp /bin/ls $DIR
2146 cancel_lru_locks mdc
2147 cancel_lru_locks osc
2148 $RUNAS $DIR/ls / || error
2151 run_test 30c "execute binary from Lustre without read perms ===="
2154 $OPENUNLINK $DIR/f31 $DIR/f31 || error
2155 $CHECKSTAT -a $DIR/f31 || error
2157 run_test 31a "open-unlink file =================================="
2160 touch $DIR/f31 || error
2161 ln $DIR/f31 $DIR/f31b || error
2162 $MULTIOP $DIR/f31b Ouc || error
2163 $CHECKSTAT -t file $DIR/f31 || error
2165 run_test 31b "unlink file with multiple links while open ======="
2168 touch $DIR/f31 || error
2169 ln $DIR/f31 $DIR/f31c || error
2170 multiop_bg_pause $DIR/f31 O_uc || return 1
2172 $MULTIOP $DIR/f31c Ouc
2173 kill -USR1 $MULTIPID
2176 run_test 31c "open-unlink file with multiple links ============="
2179 opendirunlink $DIR/d31d $DIR/d31d || error
2180 $CHECKSTAT -a $DIR/d31d || error
2182 run_test 31d "remove of open directory ========================="
2184 test_31e() { # bug 2904
2185 openfilleddirunlink $DIR/d31e || error
2187 run_test 31e "remove of open non-empty directory ==============="
2189 test_31f() { # bug 4554
2190 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2192 test_mkdir $DIR/d31f
2193 $SETSTRIPE -S 1048576 -c 1 $DIR/d31f
2194 cp /etc/hosts $DIR/d31f
2196 $GETSTRIPE $DIR/d31f/hosts
2197 multiop_bg_pause $DIR/d31f D_c || return 1
2200 rm -rv $DIR/d31f || error "first of $DIR/d31f"
2201 test_mkdir $DIR/d31f
2202 $SETSTRIPE -S 1048576 -c 1 $DIR/d31f
2203 cp /etc/hosts $DIR/d31f
2205 $GETSTRIPE $DIR/d31f/hosts
2206 multiop_bg_pause $DIR/d31f D_c || return 1
2209 kill -USR1 $MULTIPID || error "first opendir $MULTIPID not running"
2210 wait $MULTIPID || error "first opendir $MULTIPID failed"
2214 kill -USR1 $MULTIPID2 || error "second opendir $MULTIPID not running"
2215 wait $MULTIPID2 || error "second opendir $MULTIPID2 failed"
2218 run_test 31f "remove of open directory with open-unlink file ==="
2221 echo "-- cross directory link --"
2222 test_mkdir -c1 $DIR/${tdir}ga
2223 test_mkdir -c1 $DIR/${tdir}gb
2224 touch $DIR/${tdir}ga/f
2225 ln $DIR/${tdir}ga/f $DIR/${tdir}gb/g
2226 $CHECKSTAT -t file $DIR/${tdir}ga/f || error "source"
2227 [ `stat -c%h $DIR/${tdir}ga/f` == '2' ] || error "source nlink"
2228 $CHECKSTAT -t file $DIR/${tdir}gb/g || error "target"
2229 [ `stat -c%h $DIR/${tdir}gb/g` == '2' ] || error "target nlink"
2231 run_test 31g "cross directory link==============="
2234 echo "-- cross directory link --"
2235 test_mkdir -c1 $DIR/${tdir}
2236 test_mkdir -c1 $DIR/${tdir}/dir
2237 touch $DIR/${tdir}/f
2238 ln $DIR/${tdir}/f $DIR/${tdir}/dir/g
2239 $CHECKSTAT -t file $DIR/${tdir}/f || error "source"
2240 [ `stat -c%h $DIR/${tdir}/f` == '2' ] || error "source nlink"
2241 $CHECKSTAT -t file $DIR/${tdir}/dir/g || error "target"
2242 [ `stat -c%h $DIR/${tdir}/dir/g` == '2' ] || error "target nlink"
2244 run_test 31h "cross directory link under child==============="
2247 echo "-- cross directory link --"
2248 test_mkdir -c1 $DIR/$tdir
2249 test_mkdir -c1 $DIR/$tdir/dir
2250 touch $DIR/$tdir/dir/f
2251 ln $DIR/$tdir/dir/f $DIR/$tdir/g
2252 $CHECKSTAT -t file $DIR/$tdir/dir/f || error "source"
2253 [ `stat -c%h $DIR/$tdir/dir/f` == '2' ] || error "source nlink"
2254 $CHECKSTAT -t file $DIR/$tdir/g || error "target"
2255 [ `stat -c%h $DIR/$tdir/g` == '2' ] || error "target nlink"
2257 run_test 31i "cross directory link under parent==============="
2260 test_mkdir -c1 -p $DIR/$tdir
2261 test_mkdir -c1 -p $DIR/$tdir/dir1
2262 ln $DIR/$tdir/dir1 $DIR/$tdir/dir2 && error "ln for dir"
2263 link $DIR/$tdir/dir1 $DIR/$tdir/dir3 && error "link for dir"
2264 mlink $DIR/$tdir/dir1 $DIR/$tdir/dir4 && error "mlink for dir"
2265 mlink $DIR/$tdir/dir1 $DIR/$tdir/dir1 && error "mlink to the same dir"
2268 run_test 31j "link for directory==============="
2271 test_mkdir -c1 -p $DIR/$tdir
2273 touch $DIR/$tdir/exist
2274 mlink $DIR/$tdir/s $DIR/$tdir/t || error "mlink"
2275 mlink $DIR/$tdir/s $DIR/$tdir/exist && error "mlink to exist file"
2276 mlink $DIR/$tdir/s $DIR/$tdir/s && error "mlink to the same file"
2277 mlink $DIR/$tdir/s $DIR/$tdir && error "mlink to parent dir"
2278 mlink $DIR/$tdir $DIR/$tdir/s && error "mlink parent dir to target"
2279 mlink $DIR/$tdir/not-exist $DIR/$tdir/foo && error "mlink non-existing to new"
2280 mlink $DIR/$tdir/not-exist $DIR/$tdir/s && error "mlink non-existing to exist"
2283 run_test 31k "link to file: the same, non-existing, dir==============="
2289 touch $DIR/d31m2/exist
2290 mlink $DIR/d31m/s $DIR/d31m2/t || error "mlink"
2291 mlink $DIR/d31m/s $DIR/d31m2/exist && error "mlink to exist file"
2292 mlink $DIR/d31m/s $DIR/d31m2 && error "mlink to parent dir"
2293 mlink $DIR/d31m2 $DIR/d31m/s && error "mlink parent dir to target"
2294 mlink $DIR/d31m/not-exist $DIR/d31m2/foo && error "mlink non-existing to new"
2295 mlink $DIR/d31m/not-exist $DIR/d31m2/s && error "mlink non-existing to exist"
2298 run_test 31m "link to file: the same, non-existing, dir==============="
2301 touch $DIR/$tfile || error "cannot create '$DIR/$tfile'"
2302 nlink=$(stat --format=%h $DIR/$tfile)
2303 [ ${nlink:--1} -eq 1 ] || error "nlink is $nlink, expected 1"
2305 local cmd="exec $fd<$DIR/$tfile"
2308 trap "eval $cmd" EXIT
2309 nlink=$(stat --dereference --format=%h /proc/self/fd/$fd)
2310 [ ${nlink:--1} -eq 1 ] || error "nlink is $nlink, expected 1"
2311 rm $DIR/$tfile || error "cannot remove '$DIR/$tfile'"
2312 nlink=$(stat --dereference --format=%h /proc/self/fd/$fd)
2313 [ ${nlink:--1} -eq 0 ] || error "nlink is $nlink, expected 0"
2316 run_test 31n "check link count of unlinked file"
2319 local TEMPNAME=$(mktemp $1_XXXXXX)
2320 mlink $TEMPNAME $1 2> /dev/null &&
2321 echo "$BASHPID: link $TEMPNAME to $1 succeeded"
2325 test_31o() { # LU-2901
2326 test_mkdir -p $DIR/$tdir
2327 for LOOP in $(seq 100); do
2328 rm -f $DIR/$tdir/$tfile*
2329 for THREAD in $(seq 8); do
2330 link_one $DIR/$tdir/$tfile.$LOOP &
2333 local LINKS=$(ls -1 $DIR/$tdir | grep -c $tfile.$LOOP)
2334 [[ $LINKS -gt 1 ]] && ls $DIR/$tdir &&
2335 error "$LINKS duplicate links to $tfile.$LOOP" &&
2339 run_test 31o "duplicate hard links with same filename"
2342 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2344 test_mkdir $DIR/$tdir
2345 $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
2346 $LFS setdirstripe -D -c2 -t all_char $DIR/$tdir/striped_dir
2348 opendirunlink $DIR/$tdir/striped_dir/test1 ||
2349 error "open unlink test1 failed"
2350 opendirunlink $DIR/$tdir/striped_dir/test2 ||
2351 error "open unlink test2 failed"
2353 $CHECKSTAT -a $DIR/$tdir/striped_dir/test1 ||
2354 error "test1 still exists"
2355 $CHECKSTAT -a $DIR/$tdir/striped_dir/test2 ||
2356 error "test2 still exists"
2358 run_test 31p "remove of open striped directory"
2360 cleanup_test32_mount() {
2362 $UMOUNT $DIR/$tdir/ext2-mountpoint
2366 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2367 echo "== more mountpoints and symlinks ================="
2368 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2369 trap cleanup_test32_mount EXIT
2370 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2371 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2372 $CHECKSTAT -t dir $DIR/$tdir/ext2-mountpoint/.. || error
2373 cleanup_test32_mount
2375 run_test 32a "stat d32a/ext2-mountpoint/.. ====================="
2378 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2379 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2380 trap cleanup_test32_mount EXIT
2381 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2382 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2383 ls -al $DIR/$tdir/ext2-mountpoint/.. || error
2384 cleanup_test32_mount
2386 run_test 32b "open d32b/ext2-mountpoint/.. ====================="
2389 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2390 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2391 trap cleanup_test32_mount EXIT
2392 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2393 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2394 test_mkdir -p $DIR/$tdir/d2/test_dir
2395 $CHECKSTAT -t dir $DIR/$tdir/ext2-mountpoint/../d2/test_dir || error
2396 cleanup_test32_mount
2398 run_test 32c "stat d32c/ext2-mountpoint/../d2/test_dir ========="
2401 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2402 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2403 trap cleanup_test32_mount EXIT
2404 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2405 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2406 test_mkdir -p $DIR/$tdir/d2/test_dir
2407 ls -al $DIR/$tdir/ext2-mountpoint/../d2/test_dir || error
2408 cleanup_test32_mount
2410 run_test 32d "open d32d/ext2-mountpoint/../d2/test_dir ========="
2413 [ -e $DIR/d32e ] && rm -fr $DIR/d32e
2414 test_mkdir -p $DIR/d32e/tmp
2415 TMP_DIR=$DIR/d32e/tmp
2416 ln -s $DIR/d32e $TMP_DIR/symlink11
2417 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
2418 $CHECKSTAT -t link $DIR/d32e/tmp/symlink11 || error
2419 $CHECKSTAT -t link $DIR/d32e/symlink01 || error
2421 run_test 32e "stat d32e/symlink->tmp/symlink->lustre-subdir ===="
2424 [ -e $DIR/d32f ] && rm -fr $DIR/d32f
2425 test_mkdir -p $DIR/d32f/tmp
2426 TMP_DIR=$DIR/d32f/tmp
2427 ln -s $DIR/d32f $TMP_DIR/symlink11
2428 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
2429 ls $DIR/d32f/tmp/symlink11 || error
2430 ls $DIR/d32f/symlink01 || error
2432 run_test 32f "open d32f/symlink->tmp/symlink->lustre-subdir ===="
2435 TMP_DIR=$DIR/$tdir/tmp
2436 test_mkdir -p $DIR/$tdir/tmp
2437 test_mkdir $DIR/${tdir}2
2438 ln -s $DIR/${tdir}2 $TMP_DIR/symlink12
2439 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
2440 $CHECKSTAT -t link $TMP_DIR/symlink12 || error
2441 $CHECKSTAT -t link $DIR/$tdir/symlink02 || error
2442 $CHECKSTAT -t dir -f $TMP_DIR/symlink12 || error
2443 $CHECKSTAT -t dir -f $DIR/$tdir/symlink02 || error
2445 run_test 32g "stat d32g/symlink->tmp/symlink->lustre-subdir/${tdir}2"
2448 rm -fr $DIR/$tdir $DIR/${tdir}2
2449 TMP_DIR=$DIR/$tdir/tmp
2450 test_mkdir -p $DIR/$tdir/tmp
2451 test_mkdir $DIR/${tdir}2
2452 ln -s $DIR/${tdir}2 $TMP_DIR/symlink12
2453 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
2454 ls $TMP_DIR/symlink12 || error
2455 ls $DIR/$tdir/symlink02 || error
2457 run_test 32h "open d32h/symlink->tmp/symlink->lustre-subdir/${tdir}2"
2460 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2461 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2462 trap cleanup_test32_mount EXIT
2463 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2464 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2465 touch $DIR/$tdir/test_file
2466 $CHECKSTAT -t file $DIR/$tdir/ext2-mountpoint/../test_file || error
2467 cleanup_test32_mount
2469 run_test 32i "stat d32i/ext2-mountpoint/../test_file ==========="
2472 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2473 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2474 trap cleanup_test32_mount EXIT
2475 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2476 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2477 touch $DIR/$tdir/test_file
2478 cat $DIR/$tdir/ext2-mountpoint/../test_file || error
2479 cleanup_test32_mount
2481 run_test 32j "open d32j/ext2-mountpoint/../test_file ==========="
2484 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2486 trap cleanup_test32_mount EXIT
2487 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2488 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint
2489 test_mkdir -p $DIR/$tdir/d2
2490 touch $DIR/$tdir/d2/test_file || error
2491 $CHECKSTAT -t file $DIR/$tdir/ext2-mountpoint/../d2/test_file || error
2492 cleanup_test32_mount
2494 run_test 32k "stat d32k/ext2-mountpoint/../d2/test_file ========"
2497 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2499 trap cleanup_test32_mount EXIT
2500 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2501 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2502 test_mkdir -p $DIR/$tdir/d2
2503 touch $DIR/$tdir/d2/test_file
2504 cat $DIR/$tdir/ext2-mountpoint/../d2/test_file || error
2505 cleanup_test32_mount
2507 run_test 32l "open d32l/ext2-mountpoint/../d2/test_file ========"
2511 test_mkdir -p $DIR/d32m/tmp
2512 TMP_DIR=$DIR/d32m/tmp
2513 ln -s $DIR $TMP_DIR/symlink11
2514 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
2515 $CHECKSTAT -t link $DIR/d32m/tmp/symlink11 || error
2516 $CHECKSTAT -t link $DIR/d32m/symlink01 || error
2518 run_test 32m "stat d32m/symlink->tmp/symlink->lustre-root ======"
2522 test_mkdir -p $DIR/d32n/tmp
2523 TMP_DIR=$DIR/d32n/tmp
2524 ln -s $DIR $TMP_DIR/symlink11
2525 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
2526 ls -l $DIR/d32n/tmp/symlink11 || error
2527 ls -l $DIR/d32n/symlink01 || error
2529 run_test 32n "open d32n/symlink->tmp/symlink->lustre-root ======"
2533 test_mkdir -p $DIR/d32o/tmp
2534 TMP_DIR=$DIR/d32o/tmp
2535 ln -s $DIR/$tfile $TMP_DIR/symlink12
2536 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
2537 $CHECKSTAT -t link $DIR/d32o/tmp/symlink12 || error
2538 $CHECKSTAT -t link $DIR/d32o/symlink02 || error
2539 $CHECKSTAT -t file -f $DIR/d32o/tmp/symlink12 || error
2540 $CHECKSTAT -t file -f $DIR/d32o/symlink02 || error
2542 run_test 32o "stat d32o/symlink->tmp/symlink->lustre-root/$tfile"
2552 test_mkdir -p $DIR/d32p/tmp
2554 TMP_DIR=$DIR/d32p/tmp
2556 ln -s $DIR/$tfile $TMP_DIR/symlink12
2558 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
2560 cat $DIR/d32p/tmp/symlink12 || error
2562 cat $DIR/d32p/symlink02 || error
2565 run_test 32p "open d32p/symlink->tmp/symlink->lustre-root/$tfile"
2567 cleanup_testdir_mount() {
2573 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2574 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2575 trap cleanup_testdir_mount EXIT
2576 test_mkdir -p $DIR/$tdir
2577 touch $DIR/$tdir/under_the_mount
2578 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir
2579 ls $DIR/$tdir | grep "\<under_the_mount\>" && error
2580 cleanup_testdir_mount
2582 run_test 32q "stat follows mountpoints in Lustre (should return error)"
2585 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2586 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2587 trap cleanup_testdir_mount EXIT
2588 test_mkdir -p $DIR/$tdir
2589 touch $DIR/$tdir/under_the_mount
2590 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir
2591 ls $DIR/$tdir | grep -q under_the_mount && error || true
2592 cleanup_testdir_mount
2594 run_test 32r "opendir follows mountpoints in Lustre (should return error)"
2599 chmod 444 $DIR/$tfile
2600 chown $RUNAS_ID $DIR/$tfile
2602 $RUNAS $OPENFILE -f O_RDWR $DIR/$tfile && error || true
2605 run_test 33aa "write file with mode 444 (should return error) ===="
2609 test_mkdir -p $DIR/d33
2610 chown $RUNAS_ID $DIR/d33
2611 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $DIR/d33/f33|| error "create"
2612 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $DIR/d33/f33 && \
2613 error "open RDWR" || true
2615 run_test 33a "test open file(mode=0444) with O_RDWR (should return error)"
2619 test_mkdir -p $DIR/d33
2620 chown $RUNAS_ID $DIR/d33
2621 $RUNAS $OPENFILE -f 1286739555 $DIR/d33/f33 || true
2623 run_test 33b "test open file with malformed flags (No panic)"
2626 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2632 remote_ost_nodsh && skip "remote OST with nodsh" && return
2635 test_mkdir -p $DIR/d33
2636 # Read: 0, Write: 4, create/destroy: 2/0, stat: 1, punch: 0
2639 for ostnum in $(seq $OSTCOUNT); do
2640 # test-framework's OST numbering is one-based, while Lustre's
2642 ostname=$(printf "$FSNAME-OST%.4x" $((ostnum - 1)))
2643 # Parsing llobdstat's output sucks; we could grep the /proc
2644 # path, but that's likely to not be as portable as using the
2645 # llobdstat utility. So we parse lctl output instead.
2646 write_bytes=$(do_facet ost$ostnum lctl get_param -n \
2647 obdfilter/$ostname/stats |
2648 awk '/^write_bytes/ {print $7}' )
2649 echo "baseline_write_bytes@$OSTnum/$ostname=$write_bytes"
2650 if (( ${write_bytes:-0} > 0 ))
2657 $all_zeros || return 0
2660 echo foo > $DIR/d33/bar
2664 # Total up write_bytes after writing. We'd better find non-zeros.
2665 for ostnum in $(seq $OSTCOUNT); do
2666 ostname=$(printf "$FSNAME-OST%.4x" $((ostnum - 1)))
2667 write_bytes=$(do_facet ost$ostnum lctl get_param -n \
2668 obdfilter/$ostname/stats |
2669 awk '/^write_bytes/ {print $7}' )
2670 echo "write_bytes@$OSTnum/$ostname=$write_bytes"
2671 if (( ${write_bytes:-0} > 0 ))
2680 for ostnum in $(seq $OSTCOUNT); do
2681 ostname=$(printf "$FSNAME-OST%.4x" $((ostnum - 1)))
2682 echo "Check that write_bytes is present in obdfilter/*/stats:"
2683 do_facet ost$ostnum lctl get_param -n \
2684 obdfilter/$ostname/stats
2686 error "OST not keeping write_bytes stats (b22312)"
2689 run_test 33c "test llobdstat and write_bytes"
2692 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 2 MDTs" && return
2693 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2695 local remote_dir=$DIR/$tdir/remote_dir
2697 test_mkdir -p $DIR/$tdir
2698 $LFS mkdir -i $MDTIDX $remote_dir ||
2699 error "create remote directory failed"
2701 touch $remote_dir/$tfile
2702 chmod 444 $remote_dir/$tfile
2703 chown $RUNAS_ID $remote_dir/$tfile
2705 $RUNAS $OPENFILE -f O_RDWR $DIR/$tfile && error || true
2707 chown $RUNAS_ID $remote_dir
2708 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $remote_dir/f33 ||
2709 error "create" || true
2710 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $remote_dir/f33 &&
2711 error "open RDWR" || true
2712 $RUNAS $OPENFILE -f 1286739555 $remote_dir/f33 || true
2714 run_test 33d "openfile with 444 modes and malformed flags under remote dir"
2717 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2721 $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
2722 $LFS setdirstripe -i1 -c2 $DIR/$tdir/striped_dir1
2723 mkdir $DIR/$tdir/local_dir
2725 local s0_mode=$(stat -c%f $DIR/$tdir/striped_dir)
2726 local s1_mode=$(stat -c%f $DIR/$tdir/striped_dir1)
2727 local l_mode=$(stat -c%f $DIR/$tdir/local_dir)
2729 [ "$l_mode" = "$s0_mode" -a "$l_mode" = "$s1_mode" ] ||
2730 error "mkdir $l_mode striped0 $s0_mode striped1 $s1_mode"
2732 rmdir $DIR/$tdir/* || error "rmdir failed"
2735 $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
2736 $LFS setdirstripe -i1 -c2 $DIR/$tdir/striped_dir1
2737 mkdir $DIR/$tdir/local_dir
2739 s0_mode=$(stat -c%f $DIR/$tdir/striped_dir)
2740 s1_mode=$(stat -c%f $DIR/$tdir/striped_dir1)
2741 l_mode=$(stat -c%f $DIR/$tdir/local_dir)
2743 [ "$l_mode" = "$s0_mode" -a "$l_mode" = "$s1_mode" ] ||
2744 error "mkdir $l_mode striped0 $s0_mode striped1 $s1_mode 777"
2746 rmdir $DIR/$tdir/* || error "rmdir(umask 777) failed"
2749 $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
2750 $LFS setdirstripe -i1 -c2 $DIR/$tdir/striped_dir1
2751 mkdir $DIR/$tdir/local_dir
2753 s0_mode=$(stat -c%f $DIR/$tdir/striped_dir)
2754 s1_mode=$(stat -c%f $DIR/$tdir/striped_dir1)
2755 l_mode=$(stat -c%f $DIR/$tdir/local_dir)
2757 [ "$l_mode" = "$s0_mode" -a "$l_mode" = "$s1_mode" ] ||
2758 error "mkdir $l_mode striped0 $s0_mode striped1 $s1_mode 0"
2760 run_test 33e "mkdir and striped directory should have same mode"
2764 do_facet $SINGLEMDS $LCTL set_param mdt.*.enable_remote_dir_gid=0
2768 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2771 chmod go+rwx $DIR/$tdir
2772 do_facet $SINGLEMDS $LCTL set_param mdt.*.enable_remote_dir_gid=-1
2773 trap cleanup_33f EXIT
2775 $RUNAS lfs mkdir -c$MDSCOUNT $DIR/$tdir/striped_dir ||
2776 error "cannot create striped directory"
2778 $RUNAS touch $DIR/$tdir/striped_dir/{0..16} ||
2779 error "cannot create files in striped directory"
2781 $RUNAS rm $DIR/$tdir/striped_dir/{0..16} ||
2782 error "cannot remove files in striped directory"
2784 $RUNAS rmdir $DIR/$tdir/striped_dir ||
2785 error "cannot remove striped directory"
2789 run_test 33f "nonroot user can create, access, and remove a striped directory"
2791 TEST_34_SIZE=${TEST_34_SIZE:-2000000000000}
2794 $MCREATE $DIR/f34 || error
2795 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" || error
2796 $TRUNCATE $DIR/f34 $TEST_34_SIZE || error
2797 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" || error
2798 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2800 run_test 34a "truncate file that has not been opened ==========="
2803 [ ! -f $DIR/f34 ] && test_34a
2804 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2805 $OPENFILE -f O_RDONLY $DIR/f34
2806 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" || error
2807 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2809 run_test 34b "O_RDONLY opening file doesn't create objects ====="
2812 [ ! -f $DIR/f34 ] && test_34a
2813 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2814 $OPENFILE -f O_RDWR $DIR/f34
2815 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" && error
2816 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2818 run_test 34c "O_RDWR opening file-with-size works =============="
2821 [ ! -f $DIR/f34 ] && test_34a
2822 dd if=/dev/zero of=$DIR/f34 conv=notrunc bs=4k count=1 || error
2823 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2826 run_test 34d "write to sparse file ============================="
2830 $MCREATE $DIR/f34e || error
2831 $TRUNCATE $DIR/f34e 1000 || error
2832 $CHECKSTAT -s 1000 $DIR/f34e || error
2833 $OPENFILE -f O_RDWR $DIR/f34e
2834 $CHECKSTAT -s 1000 $DIR/f34e || error
2836 run_test 34e "create objects, some with size and some without =="
2838 test_34f() { # bug 6242, 6243
2839 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2842 $MCREATE $DIR/f34f || error
2843 $TRUNCATE $DIR/f34f $SIZE34F || error "truncating $DIR/f3f to $SIZE34F"
2844 dd if=$DIR/f34f of=$TMP/f34f
2845 $CHECKSTAT -s $SIZE34F $TMP/f34f || error "$TMP/f34f not $SIZE34F bytes"
2846 dd if=/dev/zero of=$TMP/f34fzero bs=$SIZE34F count=1
2847 cmp $DIR/f34f $TMP/f34fzero || error "$DIR/f34f not all zero"
2848 cmp $TMP/f34f $TMP/f34fzero || error "$TMP/f34f not all zero"
2849 rm $TMP/f34f $TMP/f34fzero $DIR/f34f
2851 run_test 34f "read from a file with no objects until EOF ======="
2854 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2855 dd if=/dev/zero of=$DIR/$tfile bs=1 count=100 seek=$TEST_34_SIZE || error
2856 $TRUNCATE $DIR/$tfile $((TEST_34_SIZE / 2))|| error
2857 $CHECKSTAT -s $((TEST_34_SIZE / 2)) $DIR/$tfile || error "truncate failed"
2858 cancel_lru_locks osc
2859 $CHECKSTAT -s $((TEST_34_SIZE / 2)) $DIR/$tfile || \
2860 error "wrong size after lock cancel"
2862 $TRUNCATE $DIR/$tfile $TEST_34_SIZE || error
2863 $CHECKSTAT -s $TEST_34_SIZE $DIR/$tfile || \
2864 error "expanding truncate failed"
2865 cancel_lru_locks osc
2866 $CHECKSTAT -s $TEST_34_SIZE $DIR/$tfile || \
2867 error "wrong expanded size after lock cancel"
2869 run_test 34g "truncate long file ==============================="
2872 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2876 dd if=/dev/zero of=$DIR/$tfile bs=1M count=10 || error
2877 sync # Flush the cache so that multiop below does not block on cache
2878 # flush when getting the group lock
2879 $MULTIOP $DIR/$tfile OG${gid}T${sz}g${gid}c &
2882 # Since just timed wait is not good enough, let's do a sync write
2883 # that way we are sure enough time for a roundtrip + processing
2884 # passed + 2 seconds of extra margin.
2885 dd if=/dev/zero of=$DIR/${tfile}-1 bs=4096 oflag=direct count=1
2889 if [[ `ps h -o comm -p $MULTIPID` == "multiop" ]]; then
2890 error "Multiop blocked on ftruncate, pid=$MULTIPID"
2894 local nsz=`stat -c %s $DIR/$tfile`
2895 [[ $nsz == $sz ]] || error "New size wrong $nsz != $sz"
2897 run_test 34h "ftruncate file under grouplock should not block"
2900 cp /bin/sh $DIR/f35a
2902 chown $RUNAS_ID $DIR/f35a
2903 $RUNAS $DIR/f35a && error || true
2906 run_test 35a "exec file with mode 444 (should return and not leak) ====="
2910 utime $DIR/f36 || error
2912 run_test 36a "MDS utime check (mknod, utime) ==================="
2916 utime $DIR/f36 || error
2918 run_test 36b "OST utime check (open, utime) ===================="
2923 chown $RUNAS_ID $DIR/d36
2924 $RUNAS utime $DIR/d36/f36 || error
2926 run_test 36c "non-root MDS utime check (mknod, utime) =========="
2929 [ ! -d $DIR/d36 ] && test_36c
2930 echo "" > $DIR/d36/f36
2931 $RUNAS utime $DIR/d36/f36 || error
2933 run_test 36d "non-root OST utime check (open, utime) ==========="
2936 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID -- skipping" && return
2937 test_mkdir -p $DIR/$tdir
2938 touch $DIR/$tdir/$tfile
2939 $RUNAS utime $DIR/$tdir/$tfile && \
2940 error "utime worked, expected failure" || true
2942 run_test 36e "utime on non-owned file (should return error) ===="
2946 local LANG_SAVE=$LANG
2947 local LC_LANG_SAVE=$LC_LANG
2948 export LANG=C LC_LANG=C # for date language
2950 DATESTR="Dec 20 2000"
2951 test_mkdir -p $DIR/$tdir
2952 lctl set_param fail_loc=$fl
2954 cp /etc/hosts $DIR/$tdir/$tfile
2955 sync & # write RPC generated with "current" inode timestamp, but delayed
2957 touch --date="$DATESTR" $DIR/$tdir/$tfile # setattr timestamp in past
2958 LS_BEFORE="`ls -l $DIR/$tdir/$tfile`" # old timestamp from client cache
2959 cancel_lru_locks osc
2960 LS_AFTER="`ls -l $DIR/$tdir/$tfile`" # timestamp from OST object
2962 [ "$LS_BEFORE" != "$LS_AFTER" ] && \
2963 echo "BEFORE: $LS_BEFORE" && \
2964 echo "AFTER : $LS_AFTER" && \
2965 echo "WANT : $DATESTR" && \
2966 error "$DIR/$tdir/$tfile timestamps changed" || true
2968 export LANG=$LANG_SAVE LC_LANG=$LC_LANG_SAVE
2972 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2973 #define OBD_FAIL_OST_BRW_PAUSE_BULK 0x214
2974 subr_36fh "0x80000214"
2976 run_test 36f "utime on file racing with OST BRW write =========="
2979 remote_ost_nodsh && skip "remote OST with nodsh" && return
2980 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2985 test_mkdir -p $DIR/$tdir
2986 fmd_max_age=$(do_facet ost1 \
2987 "lctl get_param -n obdfilter.*.client_cache_seconds 2> /dev/null | \
2990 fmd_before=$(do_facet ost1 \
2991 "awk '/ll_fmd_cache/ {print \\\$2}' /proc/slabinfo")
2992 touch $DIR/$tdir/$tfile
2993 sleep $((fmd_max_age + 12))
2994 fmd_after=$(do_facet ost1 \
2995 "awk '/ll_fmd_cache/ {print \\\$2}' /proc/slabinfo")
2997 echo "fmd_before: $fmd_before"
2998 echo "fmd_after: $fmd_after"
2999 [[ $fmd_after -gt $fmd_before ]] &&
3000 echo "AFTER: $fmd_after > BEFORE: $fmd_before" &&
3001 error "fmd didn't expire after ping" || true
3003 run_test 36g "filter mod data cache expiry ====================="
3006 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3007 #define OBD_FAIL_OST_BRW_PAUSE_BULK2 0x227
3008 subr_36fh "0x80000227"
3010 run_test 36h "utime on file racing with OST BRW write =========="
3013 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
3015 test_mkdir $DIR/$tdir
3016 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR/$tdir/striped_dir
3018 local mtime=$(stat -c%Y $DIR/$tdir/striped_dir)
3019 local new_mtime=$((mtime + 200))
3021 #change Modify time of striped dir
3022 touch -m -d @$new_mtime $DIR/$tdir/striped_dir ||
3023 error "change mtime failed"
3025 local got=$(stat -c%Y $DIR/$tdir/striped_dir)
3027 [ "$new_mtime" = "$got" ] || error "expect $new_mtime got $got"
3029 run_test 36i "change mtime on striped directory"
3031 # test_37 - duplicate with tests 32q 32r
3034 local file=$DIR/$tfile
3036 openfile -f O_DIRECTORY $file
3039 [ $RC -eq 0 ] && error "opened file $file with O_DIRECTORY" || true
3040 [ $RC -eq $ENOTDIR ] || error "error $RC should be ENOTDIR ($ENOTDIR)"
3042 run_test 38 "open a regular file with O_DIRECTORY should return -ENOTDIR ==="
3046 touch $DIR/${tfile}2
3047 # ls -l $DIR/$tfile $DIR/${tfile}2
3048 # ls -lu $DIR/$tfile $DIR/${tfile}2
3049 # ls -lc $DIR/$tfile $DIR/${tfile}2
3051 $OPENFILE -f O_CREAT:O_TRUNC:O_WRONLY $DIR/${tfile}2
3052 if [ ! $DIR/${tfile}2 -nt $DIR/$tfile ]; then
3054 ls -l --full-time $DIR/$tfile $DIR/${tfile}2
3056 ls -lu --full-time $DIR/$tfile $DIR/${tfile}2
3058 ls -lc --full-time $DIR/$tfile $DIR/${tfile}2
3059 error "O_TRUNC didn't change timestamps"
3062 run_test 39 "mtime changed on create ==========================="
3065 test_mkdir -p -c1 $DIR/$tdir
3066 cp -p /etc/passwd $DIR/$tdir/fopen
3067 cp -p /etc/passwd $DIR/$tdir/flink
3068 cp -p /etc/passwd $DIR/$tdir/funlink
3069 cp -p /etc/passwd $DIR/$tdir/frename
3070 ln $DIR/$tdir/funlink $DIR/$tdir/funlink2
3073 echo "aaaaaa" >> $DIR/$tdir/fopen
3074 echo "aaaaaa" >> $DIR/$tdir/flink
3075 echo "aaaaaa" >> $DIR/$tdir/funlink
3076 echo "aaaaaa" >> $DIR/$tdir/frename
3078 local open_new=`stat -c %Y $DIR/$tdir/fopen`
3079 local link_new=`stat -c %Y $DIR/$tdir/flink`
3080 local unlink_new=`stat -c %Y $DIR/$tdir/funlink`
3081 local rename_new=`stat -c %Y $DIR/$tdir/frename`
3083 cat $DIR/$tdir/fopen > /dev/null
3084 ln $DIR/$tdir/flink $DIR/$tdir/flink2
3085 rm -f $DIR/$tdir/funlink2
3086 mv -f $DIR/$tdir/frename $DIR/$tdir/frename2
3088 for (( i=0; i < 2; i++ )) ; do
3089 local open_new2=`stat -c %Y $DIR/$tdir/fopen`
3090 local link_new2=`stat -c %Y $DIR/$tdir/flink`
3091 local unlink_new2=`stat -c %Y $DIR/$tdir/funlink`
3092 local rename_new2=`stat -c %Y $DIR/$tdir/frename2`
3094 [ $open_new2 -eq $open_new ] || error "open file reverses mtime"
3095 [ $link_new2 -eq $link_new ] || error "link file reverses mtime"
3096 [ $unlink_new2 -eq $unlink_new ] || error "unlink file reverses mtime"
3097 [ $rename_new2 -eq $rename_new ] || error "rename file reverses mtime"
3099 cancel_lru_locks osc
3100 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3103 run_test 39b "mtime change on open, link, unlink, rename ======"
3105 # this should be set to past
3106 TEST_39_MTIME=`date -d "1 year ago" +%s`
3112 local mtime0=`stat -c %Y $DIR1/$tfile`
3114 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3115 local mtime1=`stat -c %Y $DIR1/$tfile`
3116 [ "$mtime1" = $TEST_39_MTIME ] || \
3117 error "mtime is not set to past: $mtime1, should be $TEST_39_MTIME"
3120 echo hello >> $DIR1/$tfile
3122 local mtime2=`stat -c %Y $DIR1/$tfile`
3123 [ "$mtime2" -ge "$d1" ] && [ "$mtime2" -le "$d2" ] || \
3124 error "mtime is not updated on write: $d1 <= $mtime2 <= $d2"
3126 mv $DIR1/$tfile $DIR1/$tfile-1
3128 for (( i=0; i < 2; i++ )) ; do
3129 local mtime3=`stat -c %Y $DIR1/$tfile-1`
3130 [ "$mtime2" = "$mtime3" ] || \
3131 error "mtime ($mtime2) changed (to $mtime3) on rename"
3133 cancel_lru_locks osc
3134 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3137 run_test 39c "mtime change on rename ==========================="
3141 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3144 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3146 for (( i=0; i < 2; i++ )) ; do
3147 local mtime=`stat -c %Y $DIR1/$tfile`
3148 [ $mtime = $TEST_39_MTIME ] || \
3149 error "mtime($mtime) is not set to $TEST_39_MTIME"
3151 cancel_lru_locks osc
3152 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3155 run_test 39d "create, utime, stat =============================="
3159 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3161 local mtime1=`stat -c %Y $DIR1/$tfile`
3163 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3165 for (( i=0; i < 2; i++ )) ; do
3166 local mtime2=`stat -c %Y $DIR1/$tfile`
3167 [ $mtime2 = $TEST_39_MTIME ] || \
3168 error "mtime($mtime2) is not set to $TEST_39_MTIME"
3170 cancel_lru_locks osc
3171 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3174 run_test 39e "create, stat, utime, stat ========================"
3178 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3180 mtime1=`stat -c %Y $DIR1/$tfile`
3183 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3185 for (( i=0; i < 2; i++ )) ; do
3186 local mtime2=`stat -c %Y $DIR1/$tfile`
3187 [ $mtime2 = $TEST_39_MTIME ] || \
3188 error "mtime($mtime2) is not set to $TEST_39_MTIME"
3190 cancel_lru_locks osc
3191 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3194 run_test 39f "create, stat, sleep, utime, stat ================="
3198 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3199 echo hello >> $DIR1/$tfile
3200 local mtime1=`stat -c %Y $DIR1/$tfile`
3203 chmod o+r $DIR1/$tfile
3205 for (( i=0; i < 2; i++ )) ; do
3206 local mtime2=`stat -c %Y $DIR1/$tfile`
3207 [ "$mtime1" = "$mtime2" ] || \
3208 error "lost mtime: $mtime2, should be $mtime1"
3210 cancel_lru_locks osc
3211 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3214 run_test 39g "write, chmod, stat ==============================="
3218 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3223 echo hello >> $DIR1/$tfile
3224 local mtime1=`stat -c %Y $DIR1/$tfile`
3226 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3228 if [ "$d1" != "$d2" ]; then
3229 echo "write and touch not within one second"
3231 for (( i=0; i < 2; i++ )) ; do
3232 local mtime2=`stat -c %Y $DIR1/$tfile`
3233 [ "$mtime2" = $TEST_39_MTIME ] || \
3234 error "lost mtime: $mtime2, should be $TEST_39_MTIME"
3236 cancel_lru_locks osc
3237 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3241 run_test 39h "write, utime within one second, stat ============="
3244 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3248 echo hello >> $DIR1/$tfile
3249 local mtime1=`stat -c %Y $DIR1/$tfile`
3251 mv $DIR1/$tfile $DIR1/$tfile-1
3253 for (( i=0; i < 2; i++ )) ; do
3254 local mtime2=`stat -c %Y $DIR1/$tfile-1`
3256 [ "$mtime1" = "$mtime2" ] || \
3257 error "lost mtime: $mtime2, should be $mtime1"
3259 cancel_lru_locks osc
3260 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3263 run_test 39i "write, rename, stat =============================="
3266 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3267 start_full_debug_logging
3271 #define OBD_FAIL_OSC_DELAY_SETTIME 0x412
3272 lctl set_param fail_loc=0x80000412
3273 multiop_bg_pause $DIR1/$tfile oO_RDWR:w2097152_c ||
3274 error "multiop failed"
3276 local mtime1=`stat -c %Y $DIR1/$tfile`
3278 mv $DIR1/$tfile $DIR1/$tfile-1
3280 kill -USR1 $multipid
3281 wait $multipid || error "multiop close failed"
3283 for (( i=0; i < 2; i++ )) ; do
3284 local mtime2=`stat -c %Y $DIR1/$tfile-1`
3285 [ "$mtime1" = "$mtime2" ] ||
3286 error "mtime is lost on close: $mtime2, " \
3289 cancel_lru_locks osc
3290 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3292 lctl set_param fail_loc=0
3293 stop_full_debug_logging
3295 run_test 39j "write, rename, close, stat ======================="
3298 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3302 multiop_bg_pause $DIR1/$tfile oO_RDWR:w2097152_c || error "multiop failed"
3304 local mtime1=`stat -c %Y $DIR1/$tfile`
3306 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3308 kill -USR1 $multipid
3309 wait $multipid || error "multiop close failed"
3311 for (( i=0; i < 2; i++ )) ; do
3312 local mtime2=`stat -c %Y $DIR1/$tfile`
3314 [ "$mtime2" = $TEST_39_MTIME ] || \
3315 error "mtime is lost on close: $mtime2, should be $TEST_39_MTIME"
3317 cancel_lru_locks osc
3318 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3321 run_test 39k "write, utime, close, stat ========================"
3323 # this should be set to future
3324 TEST_39_ATIME=`date -d "1 year" +%s`
3327 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3328 remote_mds_nodsh && skip "remote MDS with nodsh" && return
3329 local atime_diff=$(do_facet $SINGLEMDS \
3330 lctl get_param -n mdd.*MDT0000*.atime_diff)
3334 # test setting directory atime to future
3335 touch -a -d @$TEST_39_ATIME $DIR/$tdir
3336 local atime=$(stat -c %X $DIR/$tdir)
3337 [ "$atime" = $TEST_39_ATIME ] || \
3338 error "atime is not set to future: $atime, $TEST_39_ATIME"
3340 # test setting directory atime from future to now
3341 local d1=$(date +%s)
3343 local d2=$(date +%s)
3345 cancel_lru_locks mdc
3346 atime=$(stat -c %X $DIR/$tdir)
3347 [ "$atime" -ge "$d1" -a "$atime" -le "$d2" ] || \
3348 error "atime is not updated from future: $atime, $d1<atime<$d2"
3350 do_facet $SINGLEMDS lctl set_param -n mdd.*MDT0000*.atime_diff=2
3353 # test setting directory atime when now > dir atime + atime_diff
3357 cancel_lru_locks mdc
3358 atime=$(stat -c %X $DIR/$tdir)
3359 [ "$atime" -ge "$d1" -a "$atime" -le "$d2" ] || \
3360 error "atime is not updated : $atime, should be $d2"
3362 do_facet $SINGLEMDS lctl set_param -n mdd.*MDT0000*.atime_diff=60
3365 # test not setting directory atime when now < dir atime + atime_diff
3367 cancel_lru_locks mdc
3368 atime=$(stat -c %X $DIR/$tdir)
3369 [ "$atime" -ge "$d1" -a "$atime" -le "$d2" ] || \
3370 error "atime is updated to $atime, should remain $d1<atime<$d2"
3372 do_facet $SINGLEMDS \
3373 lctl set_param -n mdd.*MDT0000*.atime_diff=$atime_diff
3375 run_test 39l "directory atime update ==========================="
3378 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3381 local far_past_mtime=$(date -d "May 29 1953" +%s)
3382 local far_past_atime=$(date -d "Dec 17 1903" +%s)
3384 touch -m -d @$far_past_mtime $DIR1/$tfile
3385 touch -a -d @$far_past_atime $DIR1/$tfile
3387 for (( i=0; i < 2; i++ )) ; do
3388 local timestamps=$(stat -c "%X %Y" $DIR1/$tfile)
3389 [ "$timestamps" = "$far_past_atime $far_past_mtime" ] || \
3390 error "atime or mtime set incorrectly"
3392 cancel_lru_locks osc
3393 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3396 run_test 39m "test atime and mtime before 1970"
3398 test_39n() { # LU-3832
3399 local atime_diff=$(do_facet $SINGLEMDS \
3400 lctl get_param -n mdd.*MDT0000*.atime_diff)
3405 do_facet $SINGLEMDS lctl set_param -n mdd.*MDT0000*.atime_diff=1
3408 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 status=noxfer
3409 atime0=$(stat -c %X $DIR/$tfile)
3412 $MULTIOP $DIR/$tfile oO_RDONLY:O_NOATIME:r4096c
3413 atime1=$(stat -c %X $DIR/$tfile)
3416 cancel_lru_locks mdc
3417 cancel_lru_locks osc
3418 $MULTIOP $DIR/$tfile oO_RDONLY:O_NOATIME:r4096c
3419 atime2=$(stat -c %X $DIR/$tfile)
3421 do_facet $SINGLEMDS \
3422 lctl set_param -n mdd.*MDT0000*.atime_diff=$atime_diff
3424 [ "$atime0" -eq "$atime1" ] || error "atime0 $atime0 != atime1 $atime1"
3425 [ "$atime1" -eq "$atime2" ] || error "atime0 $atime0 != atime1 $atime1"
3427 run_test 39n "check that O_NOATIME is honored"
3430 TESTDIR=$DIR/$tdir/$tfile
3431 [ -e $TESTDIR ] && rm -rf $TESTDIR
3438 links2=$(stat -c %h .)
3439 [ $(($links1 + 2)) != $links2 ] &&
3440 error "wrong links count $(($links1 + 2)) != $links2"
3442 links3=$(stat -c %h .)
3443 [ $(($links1 + 1)) != $links3 ] &&
3444 error "wrong links count $links1 != $links3"
3447 run_test 39o "directory cached attributes updated after create ========"
3450 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 2 MDTs" && return
3452 TESTDIR=$DIR/$tdir/$tfile
3453 [ -e $TESTDIR ] && rm -rf $TESTDIR
3454 test_mkdir -p $TESTDIR
3458 $LFS mkdir -i $MDTIDX $TESTDIR/remote_dir1
3459 $LFS mkdir -i $MDTIDX $TESTDIR/remote_dir2
3461 links2=$(stat -c %h .)
3462 [ $(($links1 + 2)) != $links2 ] &&
3463 error "wrong links count $(($links1 + 2)) != $links2"
3465 links3=$(stat -c %h .)
3466 [ $(($links1 + 1)) != $links3 ] &&
3467 error "wrong links count $links1 != $links3"
3470 run_test 39p "remote directory cached attributes updated after create ========"
3474 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1
3475 $RUNAS $OPENFILE -f O_WRONLY:O_TRUNC $DIR/$tfile &&
3476 error "openfile O_WRONLY:O_TRUNC $tfile failed"
3477 $CHECKSTAT -t file -s 4096 $DIR/$tfile ||
3478 error "$tfile is not 4096 bytes in size"
3480 run_test 40 "failed open(O_TRUNC) doesn't truncate ============="
3484 small_write $DIR/f41 18
3486 run_test 41 "test small file write + fstat ====================="
3488 count_ost_writes() {
3489 lctl get_param -n osc.*.stats |
3490 awk -vwrites=0 '/ost_write/ { writes += $2 } \
3491 END { printf("%0.0f", writes) }'
3498 BG_DIRTY_RATIO_SAVE=10
3499 MAX_BG_DIRTY_RATIO=25
3503 # in 2.6, restore /proc/sys/vm/dirty_writeback_centisecs,
3504 # dirty_ratio, dirty_background_ratio
3505 if [ -f /proc/sys/vm/dirty_writeback_centisecs ]; then
3506 sysctl -w vm.dirty_writeback_centisecs=$WRITEBACK_SAVE
3507 sysctl -w vm.dirty_background_ratio=$BG_DIRTY_RATIO_SAVE
3508 sysctl -w vm.dirty_ratio=$DIRTY_RATIO_SAVE
3510 # if file not here, we are a 2.4 kernel
3511 kill -CONT `pidof kupdated`
3516 # setup the trap first, so someone cannot exit the test at the
3517 # exact wrong time and mess up a machine
3518 trap start_writeback EXIT
3519 # in 2.6, save and 0 /proc/sys/vm/dirty_writeback_centisecs
3520 if [ -f /proc/sys/vm/dirty_writeback_centisecs ]; then
3521 WRITEBACK_SAVE=`sysctl -n vm.dirty_writeback_centisecs`
3522 sysctl -w vm.dirty_writeback_centisecs=0
3523 sysctl -w vm.dirty_writeback_centisecs=0
3524 # save and increase /proc/sys/vm/dirty_ratio
3525 DIRTY_RATIO_SAVE=`sysctl -n vm.dirty_ratio`
3526 sysctl -w vm.dirty_ratio=$MAX_DIRTY_RATIO
3527 # save and increase /proc/sys/vm/dirty_background_ratio
3528 BG_DIRTY_RATIO_SAVE=`sysctl -n vm.dirty_background_ratio`
3529 sysctl -w vm.dirty_background_ratio=$MAX_BG_DIRTY_RATIO
3531 # if file not here, we are a 2.4 kernel
3532 kill -STOP `pidof kupdated`
3536 # ensure that all stripes have some grant before we test client-side cache
3538 for i in `seq -f $DIR/f42-%g 1 $OSTCOUNT`; do
3539 dd if=/dev/zero of=$i bs=4k count=1
3544 # Tests 42* verify that our behaviour is correct WRT caching, file closure,
3545 # file truncation, and file removal.
3547 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3549 cancel_lru_locks osc
3551 sync; sleep 1; sync # just to be safe
3552 BEFOREWRITES=`count_ost_writes`
3553 lctl get_param -n osc.*[oO][sS][cC][_-]*.cur_grant_bytes | grep "[0-9]"
3554 dd if=/dev/zero of=$DIR/f42a bs=1024 count=100
3555 AFTERWRITES=`count_ost_writes`
3556 [ $BEFOREWRITES -eq $AFTERWRITES ] || \
3557 error "$BEFOREWRITES < $AFTERWRITES"
3560 run_test 42a "ensure that we don't flush on close =============="
3563 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3565 cancel_lru_locks osc
3568 dd if=/dev/zero of=$DIR/f42b bs=1024 count=100
3569 BEFOREWRITES=$(count_ost_writes)
3570 $MUNLINK $DIR/f42b || error "$MUNLINK $DIR/f42b: $?"
3571 AFTERWRITES=$(count_ost_writes)
3572 if [[ $BEFOREWRITES -lt $AFTERWRITES ]]; then
3573 error "$BEFOREWRITES < $AFTERWRITES on unlink"
3575 BEFOREWRITES=$(count_ost_writes)
3576 sync || error "sync: $?"
3577 AFTERWRITES=$(count_ost_writes)
3578 if [[ $BEFOREWRITES -lt $AFTERWRITES ]]; then
3579 error "$BEFOREWRITES < $AFTERWRITES on sync"
3581 dmesg | grep 'error from obd_brw_async' && error 'error writing back'
3585 run_test 42b "test destroy of file with cached dirty data ======"
3587 # if these tests just want to test the effect of truncation,
3588 # they have to be very careful. consider:
3589 # - the first open gets a {0,EOF}PR lock
3590 # - the first write conflicts and gets a {0, count-1}PW
3591 # - the rest of the writes are under {count,EOF}PW
3592 # - the open for truncate tries to match a {0,EOF}PR
3593 # for the filesize and cancels the PWs.
3594 # any number of fixes (don't get {0,EOF} on open, match
3595 # composite locks, do smarter file size management) fix
3596 # this, but for now we want these tests to verify that
3597 # the cancellation with truncate intent works, so we
3598 # start the file with a full-file pw lock to match against
3599 # until the truncate.
3604 cancel_lru_locks osc
3606 # prime the file with 0,EOF PW to match
3610 # now the real test..
3611 dd if=/dev/zero of=$file bs=1024 count=100
3612 BEFOREWRITES=`count_ost_writes`
3613 $TRUNCATE $file $offset
3614 cancel_lru_locks osc
3615 AFTERWRITES=`count_ost_writes`
3620 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3622 [ $BEFOREWRITES -eq $AFTERWRITES ] && \
3623 error "beforewrites $BEFOREWRITES == afterwrites $AFTERWRITES on truncate"
3626 run_test 42c "test partial truncate of file with cached dirty data"
3629 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3631 [ $BEFOREWRITES -eq $AFTERWRITES ] || \
3632 error "beforewrites $BEFOREWRITES != afterwrites $AFTERWRITES on truncate"
3635 run_test 42d "test complete truncate of file with cached dirty data"
3637 test_42e() { # bug22074
3638 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3639 local TDIR=$DIR/${tdir}e
3640 local pagesz=$(page_size)
3641 local pages=16 # hardcoded 16 pages, don't change it.
3642 local files=$((OSTCOUNT * 500)) # hopefully 500 files on each OST
3643 local proc_osc0="osc.${FSNAME}-OST0000-osc-[^MDT]*"
3647 test_mkdir -p $DIR/${tdir}e
3648 $SETSTRIPE -c 1 $TDIR
3649 createmany -o $TDIR/f $files
3651 max_dirty_mb=$($LCTL get_param -n $proc_osc0/max_dirty_mb)
3653 # we assume that with $OSTCOUNT files, at least one of them will
3654 # be allocated on OST0.
3655 warmup_files=$((OSTCOUNT * max_dirty_mb))
3656 createmany -o $TDIR/w $warmup_files
3658 # write a large amount of data into one file and sync, to get good
3659 # avail_grant number from OST.
3660 for ((i=0; i<$warmup_files; i++)); do
3661 idx=$($GETSTRIPE -i $TDIR/w$i)
3662 [ $idx -ne 0 ] && continue
3663 dd if=/dev/zero of=$TDIR/w$i bs="$max_dirty_mb"M count=1
3666 [[ $i -gt $warmup_files ]] && error "OST0 is still cold"
3668 $LCTL get_param $proc_osc0/cur_dirty_bytes
3669 $LCTL get_param $proc_osc0/cur_grant_bytes
3671 # create as much dirty pages as we can while not to trigger the actual
3672 # RPCs directly. but depends on the env, VFS may trigger flush during this
3673 # period, hopefully we are good.
3674 for ((i=0; i<$warmup_files; i++)); do
3675 idx=$($GETSTRIPE -i $TDIR/w$i)
3676 [ $idx -ne 0 ] && continue
3677 dd if=/dev/zero of=$TDIR/w$i bs=1M count=1 2>/dev/null
3679 $LCTL get_param $proc_osc0/cur_dirty_bytes
3680 $LCTL get_param $proc_osc0/cur_grant_bytes
3682 # perform the real test
3683 $LCTL set_param $proc_osc0/rpc_stats 0
3684 for ((;i<$files; i++)); do
3685 [ $($GETSTRIPE -i $TDIR/f$i) -eq 0 ] || continue
3686 dd if=/dev/zero of=$TDIR/f$i bs=$pagesz count=$pages 2>/dev/null
3689 $LCTL get_param $proc_osc0/rpc_stats
3692 local have_ppr=false
3693 $LCTL get_param $proc_osc0/rpc_stats |
3694 while read PPR RRPC RPCT RCUM BAR WRPC WPCT WCUM; do
3695 # skip lines until we are at the RPC histogram data
3696 [ "$PPR" == "pages" ] && have_ppr=true && continue
3697 $have_ppr || continue
3699 # we only want the percent stat for < 16 pages
3700 [[ $(echo $PPR | tr -d ':') -ge $pages ]] && break
3702 percent=$((percent + WPCT))
3703 if [[ $percent -gt 15 ]]; then
3704 error "less than 16-pages write RPCs" \
3711 run_test 42e "verify sub-RPC writes are not done synchronously"
3714 test_mkdir -p $DIR/$tdir
3715 cp -p /bin/ls $DIR/$tdir/$tfile
3716 $MULTIOP $DIR/$tdir/$tfile Ow_c &
3718 # give multiop a chance to open
3721 $DIR/$tdir/$tfile && error || true
3724 run_test 43 "execution of file opened for write should return -ETXTBSY"
3727 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3728 test_mkdir -p $DIR/$tdir
3729 cp -p `which $MULTIOP` $DIR/$tdir/multiop ||
3730 cp -p multiop $DIR/$tdir/multiop
3731 MULTIOP_PROG=$DIR/$tdir/multiop multiop_bg_pause $TMP/$tfile.junk O_c ||
3734 $MULTIOP $DIR/$tdir/multiop Oc && error "expected error, got success"
3735 kill -USR1 $MULTIOP_PID || return 2
3736 wait $MULTIOP_PID || return 3
3737 rm $TMP/$tfile.junk $DIR/$tdir/multiop
3739 run_test 43a "open(RDWR) of file being executed should return -ETXTBSY"
3742 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3743 test_mkdir -p $DIR/$tdir
3744 cp -p `which $MULTIOP` $DIR/$tdir/multiop ||
3745 cp -p multiop $DIR/$tdir/multiop
3746 MULTIOP_PROG=$DIR/$tdir/multiop multiop_bg_pause $TMP/$tfile.junk O_c ||
3749 $TRUNCATE $DIR/$tdir/multiop 0 && error "expected error, got success"
3750 kill -USR1 $MULTIOP_PID || return 2
3751 wait $MULTIOP_PID || return 3
3752 rm $TMP/$tfile.junk $DIR/$tdir/multiop
3754 run_test 43b "truncate of file being executed should return -ETXTBSY"
3757 local testdir="$DIR/$tdir"
3758 test_mkdir -p $DIR/$tdir
3760 ( cd $(dirname $SHELL) && md5sum $(basename $SHELL) ) | \
3761 ( cd $testdir && md5sum -c)
3763 run_test 43c "md5sum of copy into lustre========================"
3766 [[ $OSTCOUNT -lt 2 ]] && skip_env "skipping 2-stripe test" && return
3767 dd if=/dev/zero of=$DIR/f1 bs=4k count=1 seek=1023
3768 dd if=$DIR/f1 bs=4k count=1 > /dev/null
3770 run_test 44 "zero length read from a sparse stripe ============="
3773 local nstripe=$($LCTL lov_getconfig $DIR | grep default_stripe_count: |
3775 [ -z "$nstripe" ] && skip "can't get stripe info" && return
3776 [[ $nstripe -gt $OSTCOUNT ]] &&
3777 skip "Wrong default_stripe_count: $nstripe (OSTCOUNT: $OSTCOUNT)" &&
3779 local stride=$($LCTL lov_getconfig $DIR | grep default_stripe_size: |
3781 if [[ $nstripe -eq 0 || $nstripe -eq -1 ]]; then
3782 nstripe=$($LCTL lov_getconfig $DIR | grep obd_count: |
3786 OFFSETS="0 $((stride/2)) $((stride-1))"
3787 for offset in $OFFSETS; do
3788 for i in $(seq 0 $((nstripe-1))); do
3789 local GLOBALOFFSETS=""
3791 local size=$((((i + 2 * $nstripe )*$stride + $offset)))
3792 local myfn=$DIR/d44a-$size
3793 echo "--------writing $myfn at $size"
3794 ll_sparseness_write $myfn $size ||
3795 error "ll_sparseness_write"
3796 GLOBALOFFSETS="$GLOBALOFFSETS $size"
3797 ll_sparseness_verify $myfn $GLOBALOFFSETS ||
3798 error "ll_sparseness_verify $GLOBALOFFSETS"
3800 for j in $(seq 0 $((nstripe-1))); do
3802 size=$((((j + $nstripe )*$stride + $offset)))
3803 ll_sparseness_write $myfn $size ||
3804 error "ll_sparseness_write"
3805 GLOBALOFFSETS="$GLOBALOFFSETS $size"
3807 ll_sparseness_verify $myfn $GLOBALOFFSETS ||
3808 error "ll_sparseness_verify $GLOBALOFFSETS"
3813 run_test 44a "test sparse pwrite ==============================="
3817 for d in `lctl get_param -n osc.*.cur_dirty_bytes`; do
3823 before=`dirty_osc_total`
3824 echo executing "\"$*\""
3826 after=`dirty_osc_total`
3827 echo before $before, after $after
3830 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3832 # Obtain grants from OST if it supports it
3833 echo blah > ${f}_grant
3836 do_dirty_record "echo blah > $f"
3837 [[ $before -eq $after ]] && error "write wasn't cached"
3838 do_dirty_record "> $f"
3839 [[ $before -gt $after ]] || error "truncate didn't lower dirty count"
3840 do_dirty_record "echo blah > $f"
3841 [[ $before -eq $after ]] && error "write wasn't cached"
3842 do_dirty_record "sync"
3843 [[ $before -gt $after ]] || error "writeback didn't lower dirty count"
3844 do_dirty_record "echo blah > $f"
3845 [[ $before -eq $after ]] && error "write wasn't cached"
3846 do_dirty_record "cancel_lru_locks osc"
3847 [[ $before -gt $after ]] ||
3848 error "lock cancellation didn't lower dirty count"
3851 run_test 45 "osc io page accounting ============================"
3853 # in a 2 stripe file (lov.sh), page 1023 maps to page 511 in its object. this
3854 # test tickles a bug where re-dirtying a page was failing to be mapped to the
3855 # objects offset and an assert hit when an rpc was built with 1023's mapped
3856 # offset 511 and 511's raw 511 offset. it also found general redirtying bugs.
3858 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3862 dd if=/dev/zero of=$f bs=`page_size` seek=511 count=1
3864 dd conv=notrunc if=/dev/zero of=$f bs=`page_size` seek=1023 count=1
3865 dd conv=notrunc if=/dev/zero of=$f bs=`page_size` seek=511 count=1
3869 run_test 46 "dirtying a previously written page ================"
3871 # test_47 is removed "Device nodes check" is moved to test_28
3873 test_48a() { # bug 2399
3874 [ $(facet_fstype $SINGLEMDS) = "zfs" ] &&
3875 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.3.63) ] &&
3876 skip "MDS prior to 2.3.63 handle ZFS dir .. incorrectly" &&
3878 test_mkdir $DIR/$tdir
3880 mv $DIR/$tdir $DIR/$tdir.new || error "move directory failed"
3881 test_mkdir $DIR/$tdir || error "recreate directory failed"
3882 touch foo || error "'touch foo' failed after recreating cwd"
3883 test_mkdir bar || error "'mkdir foo' failed after recreating cwd"
3884 touch .foo || error "'touch .foo' failed after recreating cwd"
3885 test_mkdir .bar || error "'mkdir .foo' failed after recreating cwd"
3886 ls . > /dev/null || error "'ls .' failed after recreating cwd"
3887 ls .. > /dev/null || error "'ls ..' failed after removing cwd"
3888 cd . || error "'cd .' failed after recreating cwd"
3889 test_mkdir . && error "'mkdir .' worked after recreating cwd"
3890 rmdir . && error "'rmdir .' worked after recreating cwd"
3891 ln -s . baz || error "'ln -s .' failed after recreating cwd"
3892 cd .. || error "'cd ..' failed after recreating cwd"
3894 run_test 48a "Access renamed working dir (should return errors)="
3896 test_48b() { # bug 2399
3898 test_mkdir $DIR/$tdir
3900 rmdir $DIR/$tdir || error "remove cwd $DIR/$tdir failed"
3901 touch foo && error "'touch foo' worked after removing cwd"
3902 test_mkdir foo && error "'mkdir foo' worked after removing cwd"
3903 touch .foo && error "'touch .foo' worked after removing cwd"
3904 test_mkdir .foo && error "'mkdir .foo' worked after removing cwd"
3905 ls . > /dev/null && error "'ls .' worked after removing cwd"
3906 ls .. > /dev/null || error "'ls ..' failed after removing cwd"
3907 test_mkdir . && error "'mkdir .' worked after removing cwd"
3908 rmdir . && error "'rmdir .' worked after removing cwd"
3909 ln -s . foo && error "'ln -s .' worked after removing cwd"
3910 cd .. || echo "'cd ..' failed after removing cwd `pwd`" #bug 3517
3912 run_test 48b "Access removed working dir (should return errors)="
3914 test_48c() { # bug 2350
3915 #lctl set_param debug=-1
3918 test_mkdir -p $DIR/$tdir/dir
3920 $TRACE rmdir $DIR/$tdir/dir || error "remove cwd $DIR/$tdir/dir failed"
3921 $TRACE touch foo && error "touch foo worked after removing cwd"
3922 $TRACE test_mkdir foo && error "'mkdir foo' worked after removing cwd"
3923 touch .foo && error "touch .foo worked after removing cwd"
3924 test_mkdir .foo && error "mkdir .foo worked after removing cwd"
3925 $TRACE ls . && error "'ls .' worked after removing cwd"
3926 $TRACE ls .. || error "'ls ..' failed after removing cwd"
3927 $TRACE test_mkdir . && error "'mkdir .' worked after removing cwd"
3928 $TRACE rmdir . && error "'rmdir .' worked after removing cwd"
3929 $TRACE ln -s . foo && error "'ln -s .' worked after removing cwd"
3930 $TRACE cd .. || echo "'cd ..' failed after removing cwd `pwd`" #bug 3415
3932 run_test 48c "Access removed working subdir (should return errors)"
3934 test_48d() { # bug 2350
3935 #lctl set_param debug=-1