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"
19 SRCDIR=$(cd $(dirname $0); echo $PWD)
20 export PATH=$PATH:/sbin
25 CHECKSTAT=${CHECKSTAT:-"checkstat -v"}
26 CREATETEST=${CREATETEST:-createtest}
28 LFIND=${LFIND:-"$LFS find"}
29 LVERIFY=${LVERIFY:-ll_dirstripe_verify}
31 OPENFILE=${OPENFILE:-openfile}
32 OPENUNLINK=${OPENUNLINK:-openunlink}
33 export MULTIOP=${MULTIOP:-multiop}
34 READS=${READS:-"reads"}
35 MUNLINK=${MUNLINK:-munlink}
36 SOCKETSERVER=${SOCKETSERVER:-socketserver}
37 SOCKETCLIENT=${SOCKETCLIENT:-socketclient}
38 MEMHOG=${MEMHOG:-memhog}
39 DIRECTIO=${DIRECTIO:-directio}
40 ACCEPTOR_PORT=${ACCEPTOR_PORT:-988}
41 UMOUNT=${UMOUNT:-"umount -d"}
43 CHECK_GRANT=${CHECK_GRANT:-"yes"}
44 GRANT_CHECK_LIST=${GRANT_CHECK_LIST:-""}
45 export PARALLEL=${PARALLEL:-"no"}
47 export NAME=${NAME:-local}
54 LUSTRE=${LUSTRE:-$(cd $(dirname $0)/..; echo $PWD)}
55 LUSTRE_TESTS_API_DIR=${LUSTRE_TESTS_API_DIR:-${LUSTRE}/tests/clientapi}
56 . $LUSTRE/tests/test-framework.sh
58 . ${CONFIG:=$LUSTRE/tests/cfg/${NAME}.sh}
61 [ "$SLOW" = "no" ] && EXCEPT_SLOW="24o 24D 27m 64b 68 71 77f 78 115 124b"
63 if [ $(facet_fstype $SINGLEMDS) = "zfs" ]; then
64 # bug number for skipped test: LU-4536 LU-1957 LU-2805
65 ALWAYS_EXCEPT="$ALWAYS_EXCEPT 65ic 180 184c"
66 [ "$SLOW" = "no" ] && EXCEPT_SLOW="$EXCEPT_SLOW 51b 51ba"
73 pgrep ll_sa > /dev/null && { echo "There are ll_sa thread not exit!"; exit 20; }
74 cleanupall ${FORCE} $* || { echo "FAILed to clean up"; exit 20; }
83 check_swap_layouts_support()
85 $LCTL get_param -n llite.*.sbi_flags | grep -q layout ||
86 { skip "Does not support layout lock."; return 0; }
90 check_and_setup_lustre
95 MDT0=$($LCTL get_param -n mdc.*.mds_server_uuid |
96 awk '{ gsub(/_UUID/,""); print $1 }' | head -n1)
97 LOVNAME=$($LCTL get_param -n llite.*.lov.common_name | tail -n 1)
98 OSTCOUNT=$($LCTL get_param -n lov.$LOVNAME.numobd)
99 STRIPECOUNT=$($LCTL get_param -n lov.$LOVNAME.stripecount)
100 STRIPESIZE=$($LCTL get_param -n lov.$LOVNAME.stripesize)
101 ORIGFREE=$($LCTL get_param -n lov.$LOVNAME.kbytesavail)
102 MAXFREE=${MAXFREE:-$((200000 * $OSTCOUNT))}
104 [ -f $DIR/d52a/foo ] && chattr -a $DIR/d52a/foo
105 [ -f $DIR/d52b/foo ] && chattr -i $DIR/d52b/foo
106 rm -rf $DIR/[Rdfs][0-9]*
108 # $RUNAS_ID may get set incorrectly somewhere else
109 [ $UID -eq 0 -a $RUNAS_ID -eq 0 ] && error "\$RUNAS_ID set to 0, but \$UID is also 0!"
111 check_runas_id $RUNAS_ID $RUNAS_GID $RUNAS
115 if [ "${ONLY}" = "MOUNT" ] ; then
116 echo "Lustre is up, please go on"
120 echo "preparing for tests involving mounts"
121 EXT2_DEV=${EXT2_DEV:-$TMP/SANITY.LOOP}
123 mke2fs -j -F $EXT2_DEV 8000 > /dev/null
124 echo # add a newline after mke2fs.
128 OLDDEBUG=$(lctl get_param -n debug 2> /dev/null)
129 lctl set_param debug=-1 2> /dev/null || true
132 $CHECKSTAT -t file $DIR/$tfile || error "$tfile is not a file"
134 $CHECKSTAT -a $DIR/$tfile || error "$tfile was not removed"
136 run_test 0a "touch; rm ====================="
139 chmod 0755 $DIR || error "chmod 0755 $DIR failed"
140 $CHECKSTAT -p 0755 $DIR || error "$DIR permission is not 0755"
142 run_test 0b "chmod 0755 $DIR ============================="
145 $LCTL get_param mdc.*.import | grep "state: FULL" ||
146 error "import not FULL"
147 $LCTL get_param mdc.*.import | grep "target: $FSNAME-MDT" ||
150 run_test 0c "check import proc ============================="
153 test_mkdir -p $DIR/$tdir || error "mkdir $tdir failed"
154 test_mkdir -p $DIR/$tdir/d2 || error "mkdir $tdir/d2 failed"
155 test_mkdir $DIR/$tdir/d2 && error "we expect EEXIST, but not returned"
156 $CHECKSTAT -t dir $DIR/$tdir/d2 || error "$tdir/d2 is not a dir"
159 $CHECKSTAT -a $DIR/$tdir || error "$tdir was not removed"
161 run_test 1 "mkdir; remkdir; rmdir =============================="
164 test_mkdir -p $DIR/$tdir || error "mkdir $tdir failed"
165 touch $DIR/$tdir/$tfile || error "touch $tdir/$tfile failed"
166 $CHECKSTAT -t file $DIR/$tdir/$tfile || error "$tdir/$tfile not a file"
168 $CHECKSTAT -a $DIR/$tdir/$tfile || error "$tdir/$file is not removed"
170 run_test 2 "mkdir; touch; rmdir; check file ===================="
173 test_mkdir -p $DIR/$tdir || error "mkdir $tdir failed"
174 $CHECKSTAT -t dir $DIR/$tdir || error "$tdir is not a directory"
175 touch $DIR/$tdir/$tfile
176 $CHECKSTAT -t file $DIR/$tdir/$tfile || error "$tdir/$tfile not a file"
178 $CHECKSTAT -a $DIR/$tdir || error "$tdir is not removed"
180 run_test 3 "mkdir; touch; rmdir; check dir ====================="
182 # LU-4471 - failed rmdir on remote directories still removes directory on MDT0
186 test_mkdir $DIR/$tdir ||
187 error "Create remote directory failed"
189 touch $DIR/$tdir/$tfile ||
190 error "Create file under remote directory failed"
193 error "Expect error removing in-use dir $DIR/$tdir"
195 test -d $DIR/$tdir || error "Remote directory disappeared"
197 rm -rf $DIR/$tdir || error "remove remote dir error"
199 run_test 4 "mkdir; touch dir/file; rmdir; checkdir (expect error)"
202 test_mkdir -p $DIR/$tdir || error "mkdir $tdir failed"
203 test_mkdir $DIR/$tdir/d2 || error "mkdir $tdir/d2 failed"
204 chmod 0707 $DIR/$tdir/d2 || error "chmod 0707 $tdir/d2 failed"
205 $CHECKSTAT -t dir -p 0707 $DIR/$tdir/d2 || error "$tdir/d2 not mode 707"
206 $CHECKSTAT -t dir $DIR/$tdir/d2 || error "$tdir/d2 is not a directory"
208 run_test 5 "mkdir .../d5 .../d5/d2; chmod .../d5/d2 ============"
211 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
212 chmod 0666 $DIR/$tfile || error "chmod 0666 $tfile failed"
213 $CHECKSTAT -t file -p 0666 -u \#$UID $DIR/$tfile ||
214 error "$tfile does not have perm 0666 or UID $UID"
215 $RUNAS chmod 0444 $DIR/$tfile && error "chmod $tfile worked on UID $UID"
216 $CHECKSTAT -t file -p 0666 -u \#$UID $DIR/$tfile ||
217 error "$tfile should be 0666 and owned by UID $UID"
219 run_test 6a "touch f6a; chmod f6a; $RUNAS chmod f6a (should return error) =="
222 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID" && return
224 chown $RUNAS_ID $DIR/$tfile || error "chown $RUNAS_ID $file failed"
225 $CHECKSTAT -t file -u \#$RUNAS_ID $DIR/$tfile ||
226 error "$tfile should be owned by UID $RUNAS_ID"
227 $RUNAS chown $UID $DIR/$tfile && error "chown $UID $file succeeded"
228 $CHECKSTAT -t file -u \#$RUNAS_ID $DIR/$tfile ||
229 error "$tfile should be owned by UID $RUNAS_ID"
231 run_test 6c "touch f6c; chown f6c; $RUNAS chown f6c (should return error) =="
234 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID" && return
236 chgrp $RUNAS_ID $DIR/$tfile || error "chgrp $RUNAS_ID $file failed"
237 $CHECKSTAT -t file -u \#$UID -g \#$RUNAS_ID $DIR/$tfile ||
238 error "$tfile should be owned by GID $UID"
239 $RUNAS chgrp $UID $DIR/$tfile && error "chgrp $UID $file succeeded"
240 $CHECKSTAT -t file -u \#$UID -g \#$RUNAS_ID $DIR/$tfile ||
241 error "$tfile should be owned by UID $UID and GID $RUNAS_ID"
243 run_test 6e "touch f6e; chgrp f6e; $RUNAS chgrp f6e (should return error) =="
246 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID" && return
247 test_mkdir $DIR/$tdir || error "mkdir $tfile failed"
248 chmod 777 $DIR/$tdir || error "chmod 0777 $tdir failed"
249 $RUNAS mkdir $DIR/$tdir/d || error "mkdir $tdir/d failed"
250 chmod g+s $DIR/$tdir/d || error "chmod g+s $tdir/d failed"
251 test_mkdir $DIR/$tdir/d/subdir || error "mkdir $tdir/d/subdir failed"
252 $CHECKSTAT -g \#$RUNAS_GID $DIR/$tdir/d/subdir ||
253 error "$tdir/d/subdir should be GID $RUNAS_GID"
255 run_test 6g "Is new dir in sgid dir inheriting group?"
257 test_6h() { # bug 7331
258 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID" && return
259 touch $DIR/$tfile || error "touch failed"
260 chown $RUNAS_ID:$RUNAS_GID $DIR/$tfile || error "initial chown failed"
261 $RUNAS -G$RUNAS_GID chown $RUNAS_ID:0 $DIR/$tfile &&
262 error "chown $RUNAS_ID:0 $tfile worked as GID $RUNAS_GID"
263 $CHECKSTAT -t file -u \#$RUNAS_ID -g \#$RUNAS_GID $DIR/$tfile ||
264 error "$tdir/$tfile should be UID $RUNAS_UID GID $RUNAS_GID"
266 run_test 6h "$RUNAS chown RUNAS_ID.0 .../f6h (should return error)"
269 test_mkdir $DIR/$tdir
270 $MCREATE $DIR/$tdir/$tfile
271 chmod 0666 $DIR/$tdir/$tfile
272 $CHECKSTAT -t file -p 0666 $DIR/$tdir/$tfile ||
273 error "$tdir/$tfile should be mode 0666"
275 run_test 7a "mkdir .../d7; mcreate .../d7/f; chmod .../d7/f ===="
278 if [ ! -d $DIR/$tdir ]; then
279 test_mkdir $DIR/$tdir
281 $MCREATE $DIR/$tdir/$tfile
282 echo -n foo > $DIR/$tdir/$tfile
283 [ "$(cat $DIR/$tdir/$tfile)" = "foo" ] || error "$tdir/$tfile not 'foo'"
284 $CHECKSTAT -t file -s 3 $DIR/$tdir/$tfile || error "$tfile size not 3"
286 run_test 7b "mkdir .../d7; mcreate d7/f2; echo foo > d7/f2 ====="
289 test_mkdir $DIR/$tdir
290 touch $DIR/$tdir/$tfile
291 chmod 0666 $DIR/$tdir/$tfile
292 $CHECKSTAT -t file -p 0666 $DIR/$tdir/$tfile ||
293 error "$tfile mode not 0666"
295 run_test 8 "mkdir .../d8; touch .../d8/f; chmod .../d8/f ======="
298 test_mkdir $DIR/$tdir
299 test_mkdir $DIR/$tdir/d2
300 test_mkdir $DIR/$tdir/d2/d3
301 $CHECKSTAT -t dir $DIR/$tdir/d2/d3 || error "$tdir/d2/d3 not a dir"
303 run_test 9 "mkdir .../d9 .../d9/d2 .../d9/d2/d3 ================"
306 test_mkdir $DIR/$tdir
307 test_mkdir $DIR/$tdir/d2
308 touch $DIR/$tdir/d2/$tfile
309 $CHECKSTAT -t file $DIR/$tdir/d2/$tfile ||
310 error "$tdir/d2/$tfile not a file"
312 run_test 10 "mkdir .../d10 .../d10/d2; touch .../d10/d2/f ======"
315 test_mkdir $DIR/$tdir
316 test_mkdir $DIR/$tdir/d2
317 chmod 0666 $DIR/$tdir/d2
318 chmod 0705 $DIR/$tdir/d2
319 $CHECKSTAT -t dir -p 0705 $DIR/$tdir/d2 ||
320 error "$tdir/d2 mode not 0705"
322 run_test 11 "mkdir .../d11 d11/d2; chmod .../d11/d2 ============"
325 test_mkdir $DIR/$tdir
326 touch $DIR/$tdir/$tfile
327 chmod 0666 $DIR/$tdir/$tfile
328 chmod 0654 $DIR/$tdir/$tfile
329 $CHECKSTAT -t file -p 0654 $DIR/$tdir/$tfile ||
330 error "$tdir/d2 mode not 0654"
332 run_test 12 "touch .../d12/f; chmod .../d12/f .../d12/f ========"
335 test_mkdir $DIR/$tdir
336 dd if=/dev/zero of=$DIR/$tdir/$tfile count=10
338 $CHECKSTAT -t file -s 0 $DIR/$tdir/$tfile ||
339 error "$tdir/$tfile size not 0 after truncate"
341 run_test 13 "creat .../d13/f; dd .../d13/f; > .../d13/f ========"
344 test_mkdir $DIR/$tdir
345 touch $DIR/$tdir/$tfile
347 $CHECKSTAT -a $DIR/$tdir/$tfile || error "$tdir/$tfile not removed"
349 run_test 14 "touch .../d14/f; rm .../d14/f; rm .../d14/f ======="
352 test_mkdir $DIR/$tdir
353 touch $DIR/$tdir/$tfile
354 mv $DIR/$tdir/$tfile $DIR/$tdir/${tfile}_2
355 $CHECKSTAT -t file $DIR/$tdir/${tfile}_2 ||
356 error "$tdir/${tfile_2} not a file after rename"
357 rm $DIR/$tdir/${tfile}_2 || error "unlink failed after rename"
359 run_test 15 "touch .../d15/f; mv .../d15/f .../d15/f2 =========="
362 test_mkdir $DIR/$tdir
363 touch $DIR/$tdir/$tfile
364 rm -rf $DIR/$tdir/$tfile
365 $CHECKSTAT -a $DIR/$tdir/$tfile || error "$tdir/$tfile not removed"
367 run_test 16 "touch .../d16/f; rm -rf .../d16/f ================="
370 test_mkdir -p $DIR/$tdir
371 touch $DIR/$tdir/$tfile
372 ln -s $DIR/$tdir/$tfile $DIR/$tdir/l-exist
374 $CHECKSTAT -l $DIR/$tdir/$tfile $DIR/$tdir/l-exist ||
375 error "$tdir/l-exist not a symlink"
376 $CHECKSTAT -f -t f $DIR/$tdir/l-exist ||
377 error "$tdir/l-exist not referencing a file"
378 rm -f $DIR/$tdir/l-exist
379 $CHECKSTAT -a $DIR/$tdir/l-exist || error "$tdir/l-exist not removed"
381 run_test 17a "symlinks: create, remove (real) =================="
384 test_mkdir -p $DIR/$tdir
385 ln -s no-such-file $DIR/$tdir/l-dangle
387 $CHECKSTAT -l no-such-file $DIR/$tdir/l-dangle ||
388 error "$tdir/l-dangle not referencing no-such-file"
389 $CHECKSTAT -fa $DIR/$tdir/l-dangle ||
390 error "$tdir/l-dangle not referencing non-existent file"
391 rm -f $DIR/$tdir/l-dangle
392 $CHECKSTAT -a $DIR/$tdir/l-dangle || error "$tdir/l-dangle not removed"
394 run_test 17b "symlinks: create, remove (dangling) =============="
396 test_17c() { # bug 3440 - don't save failed open RPC for replay
397 test_mkdir -p $DIR/$tdir
398 ln -s foo $DIR/$tdir/$tfile
399 cat $DIR/$tdir/$tfile && error "opened non-existent symlink" || true
401 run_test 17c "symlinks: open dangling (should return error) ===="
404 test_mkdir -p $DIR/$tdir
405 ln -s foo $DIR/$tdir/$tfile
406 touch $DIR/$tdir/$tfile || error "creating to new symlink"
408 run_test 17d "symlinks: create dangling ========================"
411 test_mkdir -p $DIR/$tdir
412 local foo=$DIR/$tdir/$tfile
413 ln -s $foo $foo || error "create symlink failed"
414 ls -l $foo || error "ls -l failed"
415 ls $foo && error "ls not failed" || true
417 run_test 17e "symlinks: create recursive symlink (should return error) ===="
420 test_mkdir -p $DIR/$tdir
421 ln -s 1234567890/2234567890/3234567890/4234567890 $DIR/$tdir/111
422 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890 $DIR/$tdir/222
423 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890 $DIR/$tdir/333
424 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890/9234567890/a234567890/b234567890 $DIR/$tdir/444
425 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890/9234567890/a234567890/b234567890/c234567890/d234567890/f234567890 $DIR/$tdir/555
426 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
429 run_test 17f "symlinks: long and very long symlink name ========================"
431 # str_repeat(S, N) generate a string that is string S repeated N times
436 while [ $((n -= 1)) -ge 0 ]; do
442 # Long symlinks and LU-2241
444 test_mkdir -p $DIR/$tdir
445 local TESTS="59 60 61 4094 4095"
447 # Fix for inode size boundary in 2.1.4
448 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.1.4) ] &&
451 # Patch not applied to 2.2 or 2.3 branches
452 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] &&
453 [ $(lustre_version_code $SINGLEMDS) -le $(version_code 2.3.55) ] &&
456 # skip long symlink name for rhel6.5.
457 # rhel6.5 has a limit (PATH_MAX - sizeof(struct filename))
458 grep -q '6.5' /etc/redhat-release &>/dev/null &&
459 TESTS="59 60 61 4062 4063"
462 local SYMNAME=$(str_repeat 'x' $i)
463 ln -s $SYMNAME $DIR/$tdir/f$i || error "failed $i-char symlink"
464 readlink $DIR/$tdir/f$i || error "failed $i-char readlink"
467 run_test 17g "symlinks: really long symlink name and inode boundaries"
469 test_17h() { #bug 17378
470 remote_mds_nodsh && skip "remote MDS with nodsh" && return
471 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
473 test_mkdir -p $DIR/$tdir
474 if [[ $MDSCOUNT -gt 1 ]]; then
475 mdt_idx=$($LFS getdirstripe -i $DIR/$tdir)
479 $SETSTRIPE -c -1 $DIR/$tdir
480 #define OBD_FAIL_MDS_LOV_PREP_CREATE 0x141
481 do_facet mds$((mdt_idx + 1)) lctl set_param fail_loc=0x80000141
482 touch $DIR/$tdir/$tfile || true
484 run_test 17h "create objects: lov_free_memmd() doesn't lbug"
486 test_17i() { #bug 20018
487 remote_mds_nodsh && skip "remote MDS with nodsh" && return
488 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
489 test_mkdir -c1 $DIR/$tdir
490 local foo=$DIR/$tdir/$tfile
492 if [[ $MDSCOUNT -gt 1 ]]; then
493 mdt_idx=$($LFS getdirstripe -i $DIR/$tdir)
497 ln -s $foo $foo || error "create symlink failed"
498 #define OBD_FAIL_MDS_READLINK_EPROTO 0x143
499 do_facet mds$((mdt_idx + 1)) lctl set_param fail_loc=0x80000143
500 ls -l $foo && error "error not detected"
503 run_test 17i "don't panic on short symlink"
505 test_17k() { #bug 22301
506 [[ -z "$(which rsync 2>/dev/null)" ]] &&
507 skip "no rsync command" && return 0
508 rsync --help | grep -q xattr ||
509 skip_env "$(rsync --version | head -n1) does not support xattrs"
510 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return 0
511 test_mkdir -p $DIR/$tdir
512 test_mkdir -p $DIR/$tdir.new
513 touch $DIR/$tdir/$tfile
514 ln -s $DIR/$tdir/$tfile $DIR/$tdir/$tfile.lnk
515 rsync -av -X $DIR/$tdir/ $DIR/$tdir.new ||
516 error "rsync failed with xattrs enabled"
518 run_test 17k "symlinks: rsync with xattrs enabled ========================="
520 test_17l() { # LU-279
521 [[ -z "$(which getfattr 2>/dev/null)" ]] &&
522 skip "no getfattr command" && return 0
523 test_mkdir -p $DIR/$tdir
524 touch $DIR/$tdir/$tfile
525 ln -s $DIR/$tdir/$tfile $DIR/$tdir/$tfile.lnk
526 for path in "$DIR/$tdir" "$DIR/$tdir/$tfile" "$DIR/$tdir/$tfile.lnk"; do
527 # -h to not follow symlinks. -m '' to list all the xattrs.
528 # grep to remove first line: '# file: $path'.
529 for xattr in `getfattr -hm '' $path 2>/dev/null | grep -v '^#'`;
531 lgetxattr_size_check $path $xattr ||
532 error "lgetxattr_size_check $path $xattr failed"
536 run_test 17l "Ensure lgetxattr's returned xattr size is consistent ========"
540 local short_sym="0123456789"
541 local WDIR=$DIR/${tdir}m
548 remote_mds_nodsh && skip "remote MDS with nodsh" && return
549 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] &&
550 [ $(lustre_version_code $SINGLEMDS) -le $(version_code 2.2.93) ] &&
551 skip "MDS 2.2.0-2.2.93 do not NUL-terminate symlinks" && return
553 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
554 skip "only for ldiskfs MDT" && return 0
556 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
560 # create a long symlink file
561 for ((i = 0; i < 4; ++i)); do
562 long_sym=${long_sym}${long_sym}
565 echo "create 512 short and long symlink files under $WDIR"
566 for ((i = 0; i < 256; ++i)); do
567 ln -sf ${long_sym}"a5a5" $WDIR/long-$i
568 ln -sf ${short_sym}"a5a5" $WDIR/short-$i
574 wait_delete_completed
576 echo "recreate the 512 symlink files with a shorter string"
577 for ((i = 0; i < 512; ++i)); do
578 # rewrite the symlink file with a shorter string
579 ln -sf ${long_sym} $WDIR/long-$i
580 ln -sf ${short_sym} $WDIR/short-$i
583 mds_index=$($LFS getstripe -M $WDIR)
584 mds_index=$((mds_index+1))
585 devname=$(mdsdevname $mds_index)
586 cmd="$E2FSCK -fnvd $devname"
588 echo "stop and checking mds${mds_index}: $cmd"
589 # e2fsck should not return error
591 do_facet mds${mds_index} $cmd || rc=$?
593 start mds${mds_index} $devname $MDS_MOUNT_OPTS || error "start failed"
594 df $MOUNT > /dev/null 2>&1
595 [ $rc -ne 0 ] && error "e2fsck should not report error upon "\
596 "short/long symlink MDT: rc=$rc"
599 run_test 17m "run e2fsck against MDT which contains short/long symlink"
601 check_fs_consistency_17n() {
607 # create/unlink in 17n only change 2 MDTs(MDT1/MDT2),
608 # so it only check MDT1/MDT2 instead of all of MDTs.
609 for mdt_index in $(seq 1 2); do
610 devname=$(mdsdevname $mdt_index)
611 cmd="$E2FSCK -fnvd $devname"
613 echo "stop and checking mds${mdt_index}: $cmd"
614 # e2fsck should not return error
616 do_facet mds${mdt_index} $cmd || rc=$?
618 start mds${mdt_index} $devname $MDS_MOUNT_OPTS ||
619 error "mount mds${mdt_index} failed"
620 df $MOUNT > /dev/null 2>&1
621 [ $rc -ne 0 ] && break
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
1083 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1085 local remote_dir=$DIR/$tdir/remote_dir
1087 test_mkdir -p $DIR/$tdir
1088 $LFS mkdir -i $MDTIDX $remote_dir ||
1089 error "create remote directory failed"
1091 test_mkdir -p $DIR/$tdir/src_dir
1092 touch $DIR/$tdir/src_file
1093 test_mkdir -p $remote_dir/tgt_dir
1094 touch $remote_dir/tgt_file
1096 mrename $DIR/$tdir/src_dir $remote_dir/tgt_dir ||
1097 error "rename dir cross MDT failed!"
1099 mrename $DIR/$tdir/src_file $remote_dir/tgt_file ||
1100 error "rename file cross MDT failed!"
1102 touch $DIR/$tdir/ln_file
1103 ln $DIR/$tdir/ln_file $remote_dir/ln_name ||
1104 error "ln file cross MDT failed"
1106 rm -rf $DIR/$tdir || error "Can not delete directories"
1108 run_test 24x "cross MDT rename/link"
1111 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 2 MDTs" && return
1112 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1114 local remote_dir=$DIR/$tdir/remote_dir
1116 test_mkdir -p $DIR/$tdir
1117 $LFS mkdir -i $MDTIDX $remote_dir ||
1118 error "create remote directory failed"
1120 test_mkdir -p $remote_dir/src_dir
1121 touch $remote_dir/src_file
1122 test_mkdir -p $remote_dir/tgt_dir
1123 touch $remote_dir/tgt_file
1125 mrename $remote_dir/src_dir $remote_dir/tgt_dir ||
1126 error "rename subdir in the same remote dir failed!"
1128 mrename $remote_dir/src_file $remote_dir/tgt_file ||
1129 error "rename files in the same remote dir failed!"
1131 ln $remote_dir/tgt_file $remote_dir/tgt_file1 ||
1132 error "link files in the same remote dir failed!"
1134 rm -rf $DIR/$tdir || error "Can not delete directories"
1136 run_test 24y "rename/link on the same dir should succeed"
1138 test_24A() { # LU-3182
1142 test_mkdir -p $DIR/$tdir
1143 createmany -m $DIR/$tdir/$tfile $NFILES
1144 local t=$(ls $DIR/$tdir | wc -l)
1145 local u=$(ls $DIR/$tdir | sort -u | wc -l)
1146 local v=$(ls -ai $DIR/$tdir | sort -u | wc -l)
1147 if [ $t -ne $NFILES -o $u -ne $NFILES -o $v -ne $((NFILES + 2)) ] ; then
1148 error "Expected $NFILES files, got $t ($u unique $v .&..)"
1151 rm -rf $DIR/$tdir || error "Can not delete directories"
1153 run_test 24A "readdir() returns correct number of entries."
1155 test_24B() { # LU-4805
1156 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
1159 test_mkdir $DIR/$tdir
1160 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR/$tdir/striped_dir ||
1161 error "create striped dir failed"
1163 count=$(ls -ai $DIR/$tdir/striped_dir | wc -l)
1164 [ $count -eq 2 ] || error "Expected 2, got $count"
1166 touch $DIR/$tdir/striped_dir/a
1168 count=$(ls -ai $DIR/$tdir/striped_dir | wc -l)
1169 [ $count -eq 3 ] || error "Expected 3, got $count"
1171 touch $DIR/$tdir/striped_dir/.f
1173 count=$(ls -ai $DIR/$tdir/striped_dir | wc -l)
1174 [ $count -eq 4 ] || error "Expected 4, got $count"
1176 rm -rf $DIR/$tdir || error "Can not delete directories"
1178 run_test 24B "readdir for striped dir return correct number of entries"
1181 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
1187 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR/$tdir/d0/striped_dir ||
1188 error "create striped dir failed"
1190 cd $DIR/$tdir/d0/striped_dir
1192 local d0_ino=$(ls -i -l -a $DIR/$tdir | grep "d0" | awk '{print $1}')
1193 local d1_ino=$(ls -i -l -a $DIR/$tdir | grep "d1" | awk '{print $1}')
1194 local parent_ino=$(ls -i -l -a | grep "\.\." | awk '{print $1}')
1196 [ "$d0_ino" = "$parent_ino" ] ||
1197 error ".. wrong, expect $d0_ino, get $parent_ino"
1199 mv $DIR/$tdir/d0/striped_dir $DIR/$tdir/d1/ ||
1200 error "mv striped dir failed"
1202 parent_ino=$(ls -i -l -a | grep "\.\." | awk '{print $1}')
1204 [ "$d1_ino" = "$parent_ino" ] ||
1205 error ".. wrong after mv, expect $d1_ino, get $parent_ino"
1207 run_test 24C "check .. in striped dir"
1209 test_24D() { # LU-6101
1214 createmany -m $DIR/$tdir/$tfile $NFILES
1215 local t=$(ls $DIR/$tdir | wc -l)
1216 local u=$(ls $DIR/$tdir | sort -u | wc -l)
1217 local v=$(ls -ai $DIR/$tdir | sort -u | wc -l)
1218 if [ $t -ne $NFILES -o $u -ne $NFILES -o $v -ne $((NFILES + 2)) ] ; then
1219 error "Expected $NFILES files, got $t ($u unique $v .&..)"
1222 rm -rf $DIR/$tdir || error "Can not delete directories"
1224 run_test 24D "readdir() returns correct number of entries after cursor reload"
1227 [[ $MDSCOUNT -lt 4 ]] && skip "needs >= 4 MDTs" && return
1228 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1231 mkdir $DIR/$tdir/src_dir
1232 $LFS mkdir -i 1 $DIR/$tdir/src_dir/src_child ||
1233 error "create remote source failed"
1235 touch $DIR/$tdir/src_dir/src_child/a
1237 $LFS mkdir -i 2 $DIR/$tdir/tgt_dir ||
1238 error "create remote target dir failed"
1240 $LFS mkdir -i 3 $DIR/$tdir/tgt_dir/tgt_child ||
1241 error "create remote target child failed"
1243 mrename $DIR/$tdir/src_dir/src_child $DIR/$tdir/tgt_dir/tgt_child ||
1244 error "rename dir cross MDT failed!"
1248 $CHECKSTAT -t dir $DIR/$tdir/src_dir/src_child &&
1249 error "src_child still exists after rename"
1251 $CHECKSTAT -t file $DIR/$tdir/tgt_dir/tgt_child/a ||
1252 error "missing file(a) after rename"
1254 rm -rf $DIR/$tdir || error "Can not delete directories"
1256 run_test 24E "cross MDT rename/link"
1259 echo '== symlink sanity ============================================='
1263 touch $DIR/s25/foo || error
1265 run_test 25a "create file in symlinked directory ==============="
1268 [ ! -d $DIR/d25 ] && test_25a
1269 $CHECKSTAT -t file $DIR/s25/foo || error
1271 run_test 25b "lookup file in symlinked directory ==============="
1275 test_mkdir $DIR/d26/d26-2
1276 ln -s d26/d26-2 $DIR/s26
1277 touch $DIR/s26/foo || error
1279 run_test 26a "multiple component symlink ======================="
1282 test_mkdir -p $DIR/d26b/d26-2
1283 ln -s d26b/d26-2/foo $DIR/s26-2
1284 touch $DIR/s26-2 || error
1286 run_test 26b "multiple component symlink at end of lookup ======"
1289 test_mkdir $DIR/d26.2
1290 touch $DIR/d26.2/foo
1291 ln -s d26.2 $DIR/s26.2-1
1292 ln -s s26.2-1 $DIR/s26.2-2
1293 ln -s s26.2-2 $DIR/s26.2-3
1294 chmod 0666 $DIR/s26.2-3/foo
1296 run_test 26c "chain of symlinks ================================"
1298 # recursive symlinks (bug 439)
1300 ln -s d26-3/foo $DIR/d26-3
1302 run_test 26d "create multiple component recursive symlink ======"
1305 [ ! -h $DIR/d26-3 ] && test_26d
1308 run_test 26e "unlink multiple component recursive symlink ======"
1310 # recursive symlinks (bug 7022)
1312 test_mkdir -p $DIR/$tdir
1313 test_mkdir $DIR/$tdir/$tfile || error "mkdir $DIR/$tdir/$tfile failed"
1314 cd $DIR/$tdir/$tfile || error "cd $DIR/$tdir/$tfile failed"
1315 test_mkdir -p lndir/bar1 || error "mkdir lndir/bar1 failed"
1316 test_mkdir $DIR/$tdir/$tfile/$tfile || error "mkdir $tfile failed"
1317 cd $tfile || error "cd $tfile failed"
1318 ln -s .. dotdot || error "ln dotdot failed"
1319 ln -s dotdot/lndir lndir || error "ln lndir failed"
1320 cd $DIR/$tdir || error "cd $DIR/$tdir failed"
1321 output=`ls $tfile/$tfile/lndir/bar1`
1322 [ "$output" = bar1 ] && error "unexpected output"
1323 rm -r $tfile || error "rm $tfile failed"
1324 $CHECKSTAT -a $DIR/$tfile || error "$tfile not gone"
1326 run_test 26f "rm -r of a directory which has recursive symlink ="
1329 echo '== stripe sanity =============================================='
1330 test_mkdir -p $DIR/d27 || error "mkdir failed"
1332 $SETSTRIPE -c 1 $DIR/d27/f0 || error "setstripe failed"
1333 $CHECKSTAT -t file $DIR/d27/f0 || error "checkstat failed"
1334 log "== test_27a: write to one stripe file ========================="
1335 cp /etc/hosts $DIR/d27/f0 || error
1337 run_test 27a "one stripe file =================================="
1340 [[ $OSTCOUNT -lt 2 ]] && skip_env "skipping 2-stripe test" && return
1341 test_mkdir -p $DIR/d27
1342 $SETSTRIPE -c 2 $DIR/d27/f01 || error "setstripe failed"
1343 $GETSTRIPE -c $DIR/d27/f01
1344 [ $($GETSTRIPE -c $DIR/d27/f01) -eq 2 ] ||
1345 error "two-stripe file doesn't have two stripes"
1347 dd if=/dev/zero of=$DIR/d27/f01 bs=4k count=4 || error "dd failed"
1349 run_test 27b "create and write to two stripe file"
1352 test_mkdir -p $DIR/d27
1353 $SETSTRIPE -c 0 -i -1 -S 0 $DIR/d27/fdef || error "setstripe failed"
1354 $CHECKSTAT -t file $DIR/d27/fdef || error "checkstat failed"
1355 dd if=/dev/zero of=$DIR/d27/fdef bs=4k count=4 || error
1357 run_test 27d "create file with default settings ================"
1360 # LU-5839 adds check for existed layout before setting it
1361 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.56) ]] &&
1362 skip "Need MDS version at least 2.7.56" && return
1363 test_mkdir -p $DIR/d27
1364 $SETSTRIPE -c 2 $DIR/d27/f12 || error "setstripe failed"
1365 $SETSTRIPE -c 2 $DIR/d27/f12 && error "setstripe succeeded twice"
1366 $CHECKSTAT -t file $DIR/d27/f12 || error "checkstat failed"
1368 run_test 27e "setstripe existing file (should return error) ======"
1371 test_mkdir $DIR/$tdir
1372 $SETSTRIPE -S 100 -i 0 -c 1 $DIR/$tdir/$tfile &&
1373 error "$SETSTRIPE $DIR/$tdir/$tfile failed"
1374 $CHECKSTAT -t file $DIR/$tdir/$tfile &&
1375 error "$CHECKSTAT -t file $DIR/$tdir/$tfile should fail"
1376 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=4k count=4 || error "dd failed"
1377 $GETSTRIPE $DIR/$tdir/$tfile || error "$GETSTRIPE failed"
1379 run_test 27f "setstripe with bad stripe size (should return error)"
1382 test_mkdir -p $DIR/d27
1383 $MCREATE $DIR/d27/fnone || error "mcreate failed"
1384 $GETSTRIPE $DIR/d27/fnone 2>&1 | grep "no stripe info" ||
1385 error "$DIR/d27/fnone has object"
1387 run_test 27g "$GETSTRIPE with no objects"
1390 test_mkdir $DIR/$tdir
1391 touch $DIR/$tdir/$tfile || error "touch failed"
1392 [[ $($GETSTRIPE -c $DIR/$tdir/$tfile) -gt 0 ]] ||
1393 error "missing objects"
1395 run_test 27i "$GETSTRIPE with some objects"
1398 test_mkdir -p $DIR/d27
1399 $SETSTRIPE -i $OSTCOUNT $DIR/d27/f27j && error "setstripe failed"||true
1401 run_test 27j "setstripe with bad stripe offset (should return error)"
1403 test_27k() { # bug 2844
1404 test_mkdir -p $DIR/d27
1406 LL_MAX_BLKSIZE=$((4 * 1024 * 1024))
1407 [ ! -d $DIR/d27 ] && test_mkdir -p $DIR d27
1408 $SETSTRIPE -S 67108864 $FILE || error "setstripe failed"
1409 BLKSIZE=`stat $FILE | awk '/IO Block:/ { print $7 }'`
1410 [ $BLKSIZE -le $LL_MAX_BLKSIZE ] || error "1:$BLKSIZE > $LL_MAX_BLKSIZE"
1411 dd if=/dev/zero of=$FILE bs=4k count=1
1412 BLKSIZE=`stat $FILE | awk '/IO Block:/ { print $7 }'`
1413 [ $BLKSIZE -le $LL_MAX_BLKSIZE ] || error "2:$BLKSIZE > $LL_MAX_BLKSIZE"
1415 run_test 27k "limit i_blksize for broken user apps ============="
1418 test_mkdir -p $DIR/d27
1419 mcreate $DIR/f27l || error "creating file"
1420 $RUNAS $SETSTRIPE -c 1 $DIR/f27l && \
1421 error "setstripe should have failed" || true
1423 run_test 27l "check setstripe permissions (should return error)"
1426 [[ $OSTCOUNT -lt 2 ]] && skip_env "$OSTCOUNT < 2 OSTs -- skipping" &&
1428 if [[ $ORIGFREE -gt $MAXFREE ]]; then
1429 skip "$ORIGFREE > $MAXFREE skipping out-of-space test on OST0"
1432 trap simple_cleanup_common EXIT
1433 test_mkdir -p $DIR/$tdir
1434 $SETSTRIPE -i 0 -c 1 $DIR/$tdir/f27m_1
1435 dd if=/dev/zero of=$DIR/$tdir/f27m_1 bs=1024 count=$MAXFREE &&
1436 error "dd should fill OST0"
1438 while $SETSTRIPE -i 0 -c 1 $DIR/$tdir/f27m_$i; do
1440 [ $i -gt 256 ] && break
1443 touch $DIR/$tdir/f27m_$i
1444 [ `$GETSTRIPE $DIR/$tdir/f27m_$i | grep -A 10 obdidx | awk '{print $1}'| grep -w "0"` ] &&
1445 error "OST0 was full but new created file still use it"
1447 touch $DIR/$tdir/f27m_$i
1448 [ `$GETSTRIPE $DIR/$tdir/f27m_$i | grep -A 10 obdidx | awk '{print $1}'| grep -w "0"` ] &&
1449 error "OST0 was full but new created file still use it"
1450 simple_cleanup_common
1452 run_test 27m "create file while OST0 was full =================="
1455 local DELAY=$(do_facet $SINGLEMDS lctl get_param -n lov.*.qos_maxage | head -n 1 | awk '{print $1 * 2}')
1459 # OSCs keep a NOSPC flag that will be reset after ~5s (qos_maxage)
1460 # if the OST isn't full anymore.
1462 local OSTIDX=${1:-""}
1464 local list=$(comma_list $(osts_nodes))
1465 [ "$OSTIDX" ] && list=$(facet_host ost$((OSTIDX + 1)))
1467 do_nodes $list lctl set_param fail_loc=0
1468 sync # initiate all OST_DESTROYs from MDS to OST
1472 exhaust_precreations() {
1475 local FAILIDX=${3:-$OSTIDX}
1476 local ofacet=ost$((OSTIDX + 1))
1478 test_mkdir -p -c1 $DIR/$tdir
1479 local mdtidx=$($LFS getstripe -M $DIR/$tdir)
1480 local mfacet=mds$((mdtidx + 1))
1481 echo OSTIDX=$OSTIDX MDTIDX=$mdtidx
1483 local OST=$(ostname_from_index $OSTIDX)
1486 local mdtosc_proc1=$(get_mdtosc_proc_path $mfacet $OST)
1487 local last_id=$(do_facet $mfacet lctl get_param -n \
1488 osc.$mdtosc_proc1.prealloc_last_id)
1489 local next_id=$(do_facet $mfacet lctl get_param -n \
1490 osc.$mdtosc_proc1.prealloc_next_id)
1492 local mdtosc_proc2=$(get_mdtosc_proc_path $mfacet)
1493 do_facet $mfacet lctl get_param osc.$mdtosc_proc2.prealloc*
1495 test_mkdir -p $DIR/$tdir/${OST}
1496 $SETSTRIPE -i $OSTIDX -c 1 $DIR/$tdir/${OST}
1497 #define OBD_FAIL_OST_ENOSPC 0x215
1498 do_facet $ofacet lctl set_param fail_val=$FAILIDX fail_loc=0x215
1499 echo "Creating to objid $last_id on ost $OST..."
1500 createmany -o $DIR/$tdir/${OST}/f $next_id $((last_id - next_id + 2))
1501 do_facet $mfacet lctl get_param osc.$mdtosc_proc2.prealloc*
1502 do_facet $ofacet lctl set_param fail_loc=$FAILLOC
1506 exhaust_all_precreations() {
1508 for (( i=0; i < OSTCOUNT; i++ )) ; do
1509 exhaust_precreations $i $1 -1
1514 [[ $OSTCOUNT -lt 2 ]] && skip_env "too few OSTs" && return
1515 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1516 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1517 remote_ost_nodsh && skip "remote OST with nodsh" && return
1520 rm -f $DIR/$tdir/$tfile
1521 exhaust_precreations 0 0x80000215
1522 $SETSTRIPE -c -1 $DIR/$tdir
1523 touch $DIR/$tdir/$tfile || error
1524 $GETSTRIPE $DIR/$tdir/$tfile
1527 run_test 27n "create file with some full OSTs =================="
1530 [[ $OSTCOUNT -lt 2 ]] && skip_env "too few OSTs" && return
1531 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1532 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1533 remote_ost_nodsh && skip "remote OST with nodsh" && return
1536 rm -f $DIR/$tdir/$tfile
1537 exhaust_all_precreations 0x215
1539 touch $DIR/$tdir/$tfile && error "able to create $DIR/$tdir/$tfile"
1544 run_test 27o "create file with all full OSTs (should error) ===="
1547 [[ $OSTCOUNT -lt 2 ]] && skip_env "too few OSTs" && return
1548 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1549 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1550 remote_ost_nodsh && skip "remote OST with nodsh" && return
1553 rm -f $DIR/$tdir/$tfile
1554 test_mkdir -p $DIR/$tdir
1556 $MCREATE $DIR/$tdir/$tfile || error "mcreate failed"
1557 $TRUNCATE $DIR/$tdir/$tfile 80000000 || error "truncate failed"
1558 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat failed"
1560 exhaust_precreations 0 0x80000215
1561 echo foo >> $DIR/$tdir/$tfile || error "append failed"
1562 $CHECKSTAT -s 80000004 $DIR/$tdir/$tfile || error "checkstat failed"
1563 $GETSTRIPE $DIR/$tdir/$tfile
1567 run_test 27p "append to a truncated file with some full OSTs ==="
1570 [[ $OSTCOUNT -lt 2 ]] && skip_env "too few OSTs" && return
1571 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1572 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1573 remote_ost_nodsh && skip "remote OST with nodsh" && return
1576 rm -f $DIR/$tdir/$tfile
1578 test_mkdir -p $DIR/$tdir
1579 $MCREATE $DIR/$tdir/$tfile || error "mcreate $DIR/$tdir/$tfile failed"
1580 $TRUNCATE $DIR/$tdir/$tfile 80000000 ||error "truncate $DIR/$tdir/$tfile failed"
1581 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat failed"
1583 exhaust_all_precreations 0x215
1585 echo foo >> $DIR/$tdir/$tfile && error "append succeeded"
1586 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat 2 failed"
1590 run_test 27q "append to truncated file with all OSTs full (should error) ==="
1593 [[ $OSTCOUNT -lt 2 ]] && skip_env "too few OSTs" && return
1594 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1595 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1596 remote_ost_nodsh && skip "remote OST with nodsh" && return
1599 rm -f $DIR/$tdir/$tfile
1600 exhaust_precreations 0 0x80000215
1602 $SETSTRIPE -i 0 -c 2 $DIR/$tdir/$tfile # && error
1606 run_test 27r "stripe file with some full OSTs (shouldn't LBUG) ="
1608 test_27s() { # bug 10725
1609 test_mkdir -p $DIR/$tdir
1610 local stripe_size=$((4096 * 1024 * 1024)) # 2^32
1611 local stripe_count=0
1612 [ $OSTCOUNT -eq 1 ] || stripe_count=2
1613 $SETSTRIPE -S $stripe_size -c $stripe_count $DIR/$tdir &&
1614 error "stripe width >= 2^32 succeeded" || true
1617 run_test 27s "lsm_xfersize overflow (should error) (bug 10725)"
1619 test_27t() { # bug 10864
1624 $WLFS getstripe $tfile
1627 run_test 27t "check that utils parse path correctly"
1629 test_27u() { # bug 4900
1630 [[ $OSTCOUNT -lt 2 ]] && skip_env "too few OSTs" && return
1631 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1633 local list=$(comma_list $(mdts_nodes))
1635 #define OBD_FAIL_MDS_OSC_PRECREATE 0x139
1636 do_nodes $list $LCTL set_param fail_loc=0x139
1637 test_mkdir -p $DIR/$tdir
1639 createmany -o $DIR/$tdir/t- 1000
1640 do_nodes $list $LCTL set_param fail_loc=0
1642 TLOG=$DIR/$tfile.getstripe
1643 $GETSTRIPE $DIR/$tdir > $TLOG
1644 OBJS=$(awk -vobj=0 '($1 == 0) { obj += 1 } END { print obj; }' $TLOG)
1645 unlinkmany $DIR/$tdir/t- 1000
1646 [[ $OBJS -gt 0 ]] &&
1647 error "$OBJS objects created on OST-0. See $TLOG" || pass
1649 run_test 27u "skip object creation on OSC w/o objects =========="
1651 test_27v() { # bug 4900
1652 [[ $OSTCOUNT -lt 2 ]] && skip_env "too few OSTs" && return
1653 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1654 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1655 remote_ost_nodsh && skip "remote OST with nodsh" && return
1657 exhaust_all_precreations 0x215
1660 test_mkdir -p $DIR/$tdir
1661 $SETSTRIPE -c 1 $DIR/$tdir # 1 stripe / file
1663 touch $DIR/$tdir/$tfile
1664 #define OBD_FAIL_TGT_DELAY_PRECREATE 0x705
1666 for (( i=1; i < OSTCOUNT; i++ )); do
1667 do_facet ost$i lctl set_param fail_loc=0x705
1669 local START=`date +%s`
1670 createmany -o $DIR/$tdir/$tfile 32
1672 local FINISH=`date +%s`
1673 local TIMEOUT=`lctl get_param -n timeout`
1674 local PROCESS=$((FINISH - START))
1675 [ $PROCESS -ge $((TIMEOUT / 2)) ] && \
1676 error "$FINISH - $START >= $TIMEOUT / 2"
1677 sleep $((TIMEOUT / 2 - PROCESS))
1680 run_test 27v "skip object creation on slow OST ================="
1682 test_27w() { # bug 10997
1683 test_mkdir -p $DIR/$tdir || error "mkdir failed"
1684 $SETSTRIPE -S 65536 $DIR/$tdir/f0 || error "setstripe failed"
1685 [ $($GETSTRIPE -S $DIR/$tdir/f0) -ne 65536 ] &&
1686 error "stripe size $size != 65536" || true
1687 [ $($GETSTRIPE -d $DIR/$tdir | grep -c "stripe_count") -ne 1 ] &&
1688 error "$GETSTRIPE -d $DIR/$tdir failed" || true
1690 run_test 27w "check $SETSTRIPE -S option"
1693 [[ $OSTCOUNT -lt 2 ]] &&
1694 skip_env "skipping multiple stripe count/offset test" && return
1696 test_mkdir -p $DIR/$tdir || error "mkdir failed"
1697 for i in $(seq 1 $OSTCOUNT); do
1699 $SETSTRIPE -c $i -i $offset $DIR/$tdir/f$i ||
1700 error "setstripe -c $i -i $offset failed"
1701 count=$($GETSTRIPE -c $DIR/$tdir/f$i)
1702 index=$($GETSTRIPE -i $DIR/$tdir/f$i)
1703 [ $count -ne $i ] && error "stripe count $count != $i" || true
1704 [ $index -ne $offset ] &&
1705 error "stripe offset $index != $offset" || true
1708 run_test 27wa "check $SETSTRIPE -c -i options"
1711 remote_ost_nodsh && skip "remote OST with nodsh" && return
1712 [[ $OSTCOUNT -lt 2 ]] && skip_env "$OSTCOUNT < 2 OSTs" && return
1713 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1714 OFFSET=$(($OSTCOUNT - 1))
1716 local OST=$(ostname_from_index $OSTIDX)
1718 test_mkdir -p $DIR/$tdir
1719 $SETSTRIPE -c 1 $DIR/$tdir # 1 stripe per file
1720 do_facet ost$((OSTIDX + 1)) lctl set_param -n obdfilter.$OST.degraded 1
1722 createmany -o $DIR/$tdir/$tfile $OSTCOUNT
1723 for i in `seq 0 $OFFSET`; do
1724 [ `$GETSTRIPE $DIR/$tdir/$tfile$i | grep -A 10 obdidx | awk '{print $1}' | grep -w "$OSTIDX"` ] &&
1725 error "OST0 was degraded but new created file still use it"
1727 do_facet ost$((OSTIDX + 1)) lctl set_param -n obdfilter.$OST.degraded 0
1729 run_test 27x "create files while OST0 is degraded"
1732 [[ $OSTCOUNT -lt 2 ]] &&
1733 skip_env "$OSTCOUNT < 2 OSTs -- skipping" && return
1734 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1735 remote_ost_nodsh && skip "remote OST with nodsh" && return
1736 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1738 local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS $FSNAME-OST0000)
1739 local last_id=$(do_facet $SINGLEMDS lctl get_param -n \
1740 osc.$mdtosc.prealloc_last_id)
1741 local next_id=$(do_facet $SINGLEMDS lctl get_param -n \
1742 osc.$mdtosc.prealloc_next_id)
1743 local fcount=$((last_id - next_id))
1744 [[ $fcount -eq 0 ]] && skip "not enough space on OST0" && return
1745 [[ $fcount -gt $OSTCOUNT ]] && fcount=$OSTCOUNT
1747 local MDS_OSCS=$(do_facet $SINGLEMDS lctl dl |
1748 awk '/[oO][sS][cC].*md[ts]/ { print $4 }')
1749 local OST_DEACTIVE_IDX=-1
1754 for OSC in $MDS_OSCS; do
1755 OST=$(osc_to_ost $OSC)
1756 OSTIDX=$(index_from_ostuuid $OST)
1757 if [ $OST_DEACTIVE_IDX == -1 ]; then
1758 OST_DEACTIVE_IDX=$OSTIDX
1760 if [ $OSTIDX != $OST_DEACTIVE_IDX ]; then
1761 echo $OSC "is Deactivated:"
1762 do_facet $SINGLEMDS lctl --device %$OSC deactivate
1766 OSTIDX=$(index_from_ostuuid $OST)
1767 test_mkdir -p $DIR/$tdir
1768 $SETSTRIPE -c 1 $DIR/$tdir # 1 stripe / file
1770 for OSC in $MDS_OSCS; do
1771 OST=$(osc_to_ost $OSC)
1772 OSTIDX=$(index_from_ostuuid $OST)
1773 if [ $OSTIDX == $OST_DEACTIVE_IDX ]; then
1774 echo $OST "is degraded:"
1775 do_facet ost$((OSTIDX+1)) lctl set_param -n \
1776 obdfilter.$OST.degraded=1
1781 createmany -o $DIR/$tdir/$tfile $fcount
1783 for OSC in $MDS_OSCS; do
1784 OST=$(osc_to_ost $OSC)
1785 OSTIDX=$(index_from_ostuuid $OST)
1786 if [ $OSTIDX == $OST_DEACTIVE_IDX ]; then
1787 echo $OST "is recovered from degraded:"
1788 do_facet ost$((OSTIDX+1)) lctl set_param -n \
1789 obdfilter.$OST.degraded=0
1791 do_facet $SINGLEMDS lctl --device %$OSC activate
1795 # all osp devices get activated, hence -1 stripe count restored
1798 # sleep 2*lod_qos_maxage seconds waiting for lod qos to notice osp
1799 # devices get activated.
1801 $SETSTRIPE -c -1 $DIR/$tfile
1802 stripecnt=$($GETSTRIPE -c $DIR/$tfile)
1804 [ $stripecnt -ne $OSTCOUNT ] &&
1805 error "Of $OSTCOUNT OSTs, only $stripecnt is available"
1808 run_test 27y "create files while OST0 is degraded and the rest inactive"
1814 lmm_count=$($GETSTRIPE -c $1)
1815 lmm_seq=$($GETSTRIPE -v $1 | awk '/lmm_seq/ { print $2 }')
1816 lmm_oid=$($GETSTRIPE -v $1 | awk '/lmm_object_id/ { print $2 }')
1818 local old_ifs="$IFS"
1820 fid=($($LFS path2fid $1))
1823 log "FID seq ${fid[1]}, oid ${fid[2]} ver ${fid[3]}"
1824 log "LOV seq $lmm_seq, oid $lmm_oid, count: $lmm_count"
1826 # compare lmm_seq and lu_fid->f_seq
1827 [ $lmm_seq = ${fid[1]} ] || { error "SEQ mismatch"; return 1; }
1828 # compare lmm_object_id and lu_fid->oid
1829 [ $lmm_oid = ${fid[2]} ] || { error "OID mismatch"; return 2; }
1831 # check the trusted.fid attribute of the OST objects of the file
1832 local have_obdidx=false
1834 $GETSTRIPE $1 | while read obdidx oid hex seq; do
1835 # skip lines up to and including "obdidx"
1836 [ -z "$obdidx" ] && break
1837 [ "$obdidx" = "obdidx" ] && have_obdidx=true && continue
1838 $have_obdidx || continue
1840 local ost=$((obdidx + 1))
1841 local dev=$(ostdevname $ost)
1844 log "want: stripe:$stripe_nr ost:$obdidx oid:$oid/$hex seq:$seq"
1846 seq=$(echo $seq | sed -e "s/^0x//g")
1847 if [ $seq == 0 ]; then
1848 oid_hex=$(echo $oid)
1850 oid_hex=$(echo $hex | sed -e "s/^0x//g")
1852 local obj_file="O/$seq/d$((oid %32))/$oid_hex"
1856 # Don't unmount/remount the OSTs if we don't need to do that.
1857 # LU-2577 changes filter_fid to be smaller, so debugfs needs
1858 # update too, until that use mount/ll_decode_filter_fid/mount.
1859 # Re-enable when debugfs will understand new filter_fid.
1861 if false && [ $(facet_fstype ost$ost) == ldiskfs ]; then
1862 ff=$(do_facet ost$ost "$DEBUGFS -c -R 'stat $obj_file' \
1863 $dev 2>/dev/null" | grep "parent=")
1866 mount_fstype ost$ost
1867 ff=$(do_facet ost$ost $LL_DECODE_FILTER_FID \
1868 $(facet_mntpt ost$ost)/$obj_file)
1869 unmount_fstype ost$ost
1870 start ost$ost $dev $OST_MOUNT_OPTS
1873 [ -z "$ff" ] && error "$obj_file: no filter_fid info"
1875 echo "$ff" | sed -e 's#.*objid=#got: objid=#'
1877 # /mnt/O/0/d23/23: objid=23 seq=0 parent=[0x200000400:0x1e:0x1]
1878 # fid: objid=23 seq=0 parent=[0x200000400:0x1e:0x0] stripe=1
1879 local ff_parent=$(echo $ff|sed -e 's/.*parent=.//')
1880 local ff_pseq=$(echo $ff_parent | cut -d: -f1)
1881 local ff_poid=$(echo $ff_parent | cut -d: -f2)
1883 if echo $ff_parent | grep -q 'stripe='; then
1884 ff_pstripe=$(echo $ff_parent | sed -e 's/.*stripe=//')
1887 # $LL_DECODE_FILTER_FID does not print "stripe="; look
1888 # into f_ver in this case. See the comment on
1891 ff_pstripe=$(echo $ff_parent | cut -d: -f3 |
1895 # compare lmm_seq and filter_fid->ff_parent.f_seq
1896 [ $ff_pseq = $lmm_seq ] ||
1897 error "FF parent SEQ $ff_pseq != $lmm_seq"
1898 # compare lmm_object_id and filter_fid->ff_parent.f_oid
1899 [ $ff_poid = $lmm_oid ] ||
1900 error "FF parent OID $ff_poid != $lmm_oid"
1901 (($ff_pstripe == $stripe_nr)) ||
1902 error "FF stripe $ff_pstripe != $stripe_nr"
1904 stripe_nr=$((stripe_nr + 1))
1909 remote_ost_nodsh && skip "remote OST with nodsh" && return
1910 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1911 test_mkdir -p $DIR/$tdir
1913 $SETSTRIPE -c 1 -i 0 -S 64k $DIR/$tdir/$tfile-1 ||
1914 { error "setstripe -c -1 failed"; return 1; }
1915 # We need to send a write to every object to get parent FID info set.
1916 # This _should_ also work for setattr, but does not currently.
1917 # touch $DIR/$tdir/$tfile-1 ||
1918 dd if=/dev/zero of=$DIR/$tdir/$tfile-1 bs=1M count=1 ||
1919 { error "dd $tfile-1 failed"; return 2; }
1920 $SETSTRIPE -c -1 -i $((OSTCOUNT - 1)) -S 1M $DIR/$tdir/$tfile-2 ||
1921 { error "setstripe -c -1 failed"; return 3; }
1922 dd if=/dev/zero of=$DIR/$tdir/$tfile-2 bs=1M count=$OSTCOUNT ||
1923 { error "dd $tfile-2 failed"; return 4; }
1925 # make sure write RPCs have been sent to OSTs
1928 check_seq_oid $DIR/$tdir/$tfile-1 || return 5
1929 check_seq_oid $DIR/$tdir/$tfile-2 || return 6
1931 run_test 27z "check SEQ/OID on the MDT and OST filesystems"
1933 test_27A() { # b=19102
1934 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1935 local restore_size=$($GETSTRIPE -S $MOUNT)
1936 local restore_count=$($GETSTRIPE -c $MOUNT)
1937 local restore_offset=$($GETSTRIPE -i $MOUNT)
1938 $SETSTRIPE -c 0 -i -1 -S 0 $MOUNT
1939 wait_update $HOSTNAME "$GETSTRIPE -c $MOUNT | sed 's/ *//g'" "1" 20 ||
1940 error "stripe count $($GETSTRIPE -c $MOUNT) != 1"
1941 local default_size=$($GETSTRIPE -S $MOUNT)
1942 local default_offset=$($GETSTRIPE -i $MOUNT)
1943 local dsize=$((1024 * 1024))
1944 [ $default_size -eq $dsize ] ||
1945 error "stripe size $default_size != $dsize"
1946 [ $default_offset -eq -1 ] ||error "stripe offset $default_offset != -1"
1947 $SETSTRIPE -c $restore_count -i $restore_offset -S $restore_size $MOUNT
1949 run_test 27A "check filesystem-wide default LOV EA values"
1951 test_27B() { # LU-2523
1952 test_mkdir -p $DIR/$tdir
1953 rm -f $DIR/$tdir/f0 $DIR/$tdir/f1
1955 # open f1 with O_LOV_DELAY_CREATE
1957 # call setstripe ioctl on open file descriptor for f1
1959 multiop $DIR/$tdir/f1 oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:nB1c \
1963 # open f1 with O_LOV_DELAY_CREATE
1965 # call setstripe ioctl on open file descriptor for f1
1967 multiop $DIR/$tdir/f1 oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:uB1c
1969 # Allow multiop to fail in imitation of NFS's busted semantics.
1972 run_test 27B "call setstripe on open unlinked file/rename victim"
1974 test_27C() { #LU-2871
1975 [[ $OSTCOUNT -lt 2 ]] && skip "needs >= 2 OSTs" && return
1983 test_mkdir -p $DIR/$tdir
1985 for i in $(seq 0 $((OSTCOUNT - 1))); do
1986 # set stripe across all OSTs starting from OST$i
1987 $SETSTRIPE -i $i -c -1 $tfile$i
1988 # get striping information
1989 ost_idx=($($GETSTRIPE $tfile$i |
1990 tail -n $((OSTCOUNT + 1)) | awk '{print $1}'))
1994 [ ${#ost_idx[@]} -eq $OSTCOUNT ] ||
1995 error "${#ost_idx[@]} != $OSTCOUNT"
1997 for index in $(seq 0 $((OSTCOUNT - 1))); do
1999 for j in $(echo ${ost_idx[@]}); do
2000 if [ $index -eq $j ]; then
2006 error "Can not find $index in ${ost_idx[@]}"
2010 run_test 27C "check full striping across all OSTs"
2013 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs" && return
2014 local POOL=${POOL:-testpool}
2016 local last_ost=$(($OSTCOUNT - 1))
2018 local ost_list=$(seq $first_ost $ost_step $last_ost)
2019 local ost_range="$first_ost $last_ost $ost_step"
2021 test_mkdir -p $DIR/$tdir
2022 pool_add $POOL || error "pool_add failed"
2023 pool_add_targets $POOL $ost_range || error "pool_add_targets failed"
2024 llapi_layout_test -d$DIR/$tdir -p$POOL -o$OSTCOUNT ||
2025 error "llapi_layout_test failed"
2026 cleanup_pools || error "cleanup_pools failed"
2028 run_test 27D "validate llapi_layout API"
2030 # Verify that default_easize is increased from its initial value after
2031 # accessing a widely striped file.
2033 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs" && return
2035 # 72 bytes is the minimum space required to store striping
2036 # information for a file striped across one OST:
2037 # (sizeof(struct lov_user_md_v3) +
2038 # sizeof(struct lov_user_ost_data_v1))
2040 $LCTL set_param -n llite.*.default_easize $min_easize ||
2041 error "lctl set_param failed"
2042 local easize=$($LCTL get_param -n llite.*.default_easize)
2044 [ $easize -eq $min_easize ] ||
2045 error "failed to set default_easize"
2047 $LFS setstripe -c $OSTCOUNT $DIR/$tfile ||
2048 error "setstripe failed"
2052 easize=$($LCTL get_param -n llite.*.default_easize)
2054 [ $easize -gt $min_easize ] ||
2055 error "default_easize not updated"
2057 run_test 27E "check that default extended attribute size properly increases"
2059 # createtest also checks that device nodes are created and
2060 # then visible correctly (#2091)
2061 test_28() { # bug 2091
2063 $CREATETEST $DIR/d28/ct || error
2065 run_test 28 "create/mknod/mkdir with bad file types ============"
2068 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2069 cancel_lru_locks mdc
2075 declare -i LOCKCOUNTORIG=0
2076 for lock_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_count); do
2077 let LOCKCOUNTORIG=$LOCKCOUNTORIG+$lock_count
2079 [ $LOCKCOUNTORIG -eq 0 ] && echo "No mdc lock count" && return 1
2081 declare -i LOCKUNUSEDCOUNTORIG=0
2082 for unused_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_unused_count); do
2083 let LOCKUNUSEDCOUNTORIG=$LOCKUNUSEDCOUNTORIG+$unused_count
2090 declare -i LOCKCOUNTCURRENT=0
2091 for lock_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_count); do
2092 let LOCKCOUNTCURRENT=$LOCKCOUNTCURRENT+$lock_count
2095 declare -i LOCKUNUSEDCOUNTCURRENT=0
2096 for unused_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_unused_count); do
2097 let LOCKUNUSEDCOUNTCURRENT=$LOCKUNUSEDCOUNTCURRENT+$unused_count
2100 if [[ $LOCKCOUNTCURRENT -gt $LOCKCOUNTORIG ]]; then
2101 $LCTL set_param -n ldlm.dump_namespaces ""
2102 error "CURRENT: $LOCKCOUNTCURRENT > $LOCKCOUNTORIG"
2103 $LCTL dk | sort -k4 -t: > $TMP/test_29.dk
2104 log "dumped log to $TMP/test_29.dk (bug 5793)"
2107 if [[ $LOCKUNUSEDCOUNTCURRENT -gt $LOCKUNUSEDCOUNTORIG ]]; then
2108 error "UNUSED: $LOCKUNUSEDCOUNTCURRENT > $LOCKUNUSEDCOUNTORIG"
2109 $LCTL dk | sort -k4 -t: > $TMP/test_29.dk
2110 log "dumped log to $TMP/test_29.dk (bug 5793)"
2114 run_test 29 "IT_GETATTR regression ============================"
2116 test_30a() { # was test_30
2117 cp $(which ls) $DIR || cp /bin/ls $DIR
2121 run_test 30a "execute binary from Lustre (execve) =============="
2124 cp `which ls` $DIR || cp /bin/ls $DIR
2126 $RUNAS $DIR/ls / || error
2129 run_test 30b "execute binary from Lustre as non-root ==========="
2131 test_30c() { # b=22376
2132 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2133 cp `which ls` $DIR || cp /bin/ls $DIR
2135 cancel_lru_locks mdc
2136 cancel_lru_locks osc
2137 $RUNAS $DIR/ls / || error
2140 run_test 30c "execute binary from Lustre without read perms ===="
2143 $OPENUNLINK $DIR/f31 $DIR/f31 || error
2144 $CHECKSTAT -a $DIR/f31 || error
2146 run_test 31a "open-unlink file =================================="
2149 touch $DIR/f31 || error
2150 ln $DIR/f31 $DIR/f31b || error
2151 $MULTIOP $DIR/f31b Ouc || error
2152 $CHECKSTAT -t file $DIR/f31 || error
2154 run_test 31b "unlink file with multiple links while open ======="
2157 touch $DIR/f31 || error
2158 ln $DIR/f31 $DIR/f31c || error
2159 multiop_bg_pause $DIR/f31 O_uc || return 1
2161 $MULTIOP $DIR/f31c Ouc
2162 kill -USR1 $MULTIPID
2165 run_test 31c "open-unlink file with multiple links ============="
2168 opendirunlink $DIR/d31d $DIR/d31d || error
2169 $CHECKSTAT -a $DIR/d31d || error
2171 run_test 31d "remove of open directory ========================="
2173 test_31e() { # bug 2904
2174 openfilleddirunlink $DIR/d31e || error
2176 run_test 31e "remove of open non-empty directory ==============="
2178 test_31f() { # bug 4554
2179 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2181 test_mkdir $DIR/d31f
2182 $SETSTRIPE -S 1048576 -c 1 $DIR/d31f
2183 cp /etc/hosts $DIR/d31f
2185 $GETSTRIPE $DIR/d31f/hosts
2186 multiop_bg_pause $DIR/d31f D_c || return 1
2189 rm -rv $DIR/d31f || error "first of $DIR/d31f"
2190 test_mkdir $DIR/d31f
2191 $SETSTRIPE -S 1048576 -c 1 $DIR/d31f
2192 cp /etc/hosts $DIR/d31f
2194 $GETSTRIPE $DIR/d31f/hosts
2195 multiop_bg_pause $DIR/d31f D_c || return 1
2198 kill -USR1 $MULTIPID || error "first opendir $MULTIPID not running"
2199 wait $MULTIPID || error "first opendir $MULTIPID failed"
2203 kill -USR1 $MULTIPID2 || error "second opendir $MULTIPID not running"
2204 wait $MULTIPID2 || error "second opendir $MULTIPID2 failed"
2207 run_test 31f "remove of open directory with open-unlink file ==="
2210 echo "-- cross directory link --"
2211 test_mkdir -c1 $DIR/${tdir}ga
2212 test_mkdir -c1 $DIR/${tdir}gb
2213 touch $DIR/${tdir}ga/f
2214 ln $DIR/${tdir}ga/f $DIR/${tdir}gb/g
2215 $CHECKSTAT -t file $DIR/${tdir}ga/f || error "source"
2216 [ `stat -c%h $DIR/${tdir}ga/f` == '2' ] || error "source nlink"
2217 $CHECKSTAT -t file $DIR/${tdir}gb/g || error "target"
2218 [ `stat -c%h $DIR/${tdir}gb/g` == '2' ] || error "target nlink"
2220 run_test 31g "cross directory link==============="
2223 echo "-- cross directory link --"
2224 test_mkdir -c1 $DIR/${tdir}
2225 test_mkdir -c1 $DIR/${tdir}/dir
2226 touch $DIR/${tdir}/f
2227 ln $DIR/${tdir}/f $DIR/${tdir}/dir/g
2228 $CHECKSTAT -t file $DIR/${tdir}/f || error "source"
2229 [ `stat -c%h $DIR/${tdir}/f` == '2' ] || error "source nlink"
2230 $CHECKSTAT -t file $DIR/${tdir}/dir/g || error "target"
2231 [ `stat -c%h $DIR/${tdir}/dir/g` == '2' ] || error "target nlink"
2233 run_test 31h "cross directory link under child==============="
2236 echo "-- cross directory link --"
2237 test_mkdir -c1 $DIR/$tdir
2238 test_mkdir -c1 $DIR/$tdir/dir
2239 touch $DIR/$tdir/dir/f
2240 ln $DIR/$tdir/dir/f $DIR/$tdir/g
2241 $CHECKSTAT -t file $DIR/$tdir/dir/f || error "source"
2242 [ `stat -c%h $DIR/$tdir/dir/f` == '2' ] || error "source nlink"
2243 $CHECKSTAT -t file $DIR/$tdir/g || error "target"
2244 [ `stat -c%h $DIR/$tdir/g` == '2' ] || error "target nlink"
2246 run_test 31i "cross directory link under parent==============="
2249 test_mkdir -c1 -p $DIR/$tdir
2250 test_mkdir -c1 -p $DIR/$tdir/dir1
2251 ln $DIR/$tdir/dir1 $DIR/$tdir/dir2 && error "ln for dir"
2252 link $DIR/$tdir/dir1 $DIR/$tdir/dir3 && error "link for dir"
2253 mlink $DIR/$tdir/dir1 $DIR/$tdir/dir4 && error "mlink for dir"
2254 mlink $DIR/$tdir/dir1 $DIR/$tdir/dir1 && error "mlink to the same dir"
2257 run_test 31j "link for directory==============="
2260 test_mkdir -c1 -p $DIR/$tdir
2262 touch $DIR/$tdir/exist
2263 mlink $DIR/$tdir/s $DIR/$tdir/t || error "mlink"
2264 mlink $DIR/$tdir/s $DIR/$tdir/exist && error "mlink to exist file"
2265 mlink $DIR/$tdir/s $DIR/$tdir/s && error "mlink to the same file"
2266 mlink $DIR/$tdir/s $DIR/$tdir && error "mlink to parent dir"
2267 mlink $DIR/$tdir $DIR/$tdir/s && error "mlink parent dir to target"
2268 mlink $DIR/$tdir/not-exist $DIR/$tdir/foo && error "mlink non-existing to new"
2269 mlink $DIR/$tdir/not-exist $DIR/$tdir/s && error "mlink non-existing to exist"
2272 run_test 31k "link to file: the same, non-existing, dir==============="
2278 touch $DIR/d31m2/exist
2279 mlink $DIR/d31m/s $DIR/d31m2/t || error "mlink"
2280 mlink $DIR/d31m/s $DIR/d31m2/exist && error "mlink to exist file"
2281 mlink $DIR/d31m/s $DIR/d31m2 && error "mlink to parent dir"
2282 mlink $DIR/d31m2 $DIR/d31m/s && error "mlink parent dir to target"
2283 mlink $DIR/d31m/not-exist $DIR/d31m2/foo && error "mlink non-existing to new"
2284 mlink $DIR/d31m/not-exist $DIR/d31m2/s && error "mlink non-existing to exist"
2287 run_test 31m "link to file: the same, non-existing, dir==============="
2290 touch $DIR/$tfile || error "cannot create '$DIR/$tfile'"
2291 nlink=$(stat --format=%h $DIR/$tfile)
2292 [ ${nlink:--1} -eq 1 ] || error "nlink is $nlink, expected 1"
2294 local cmd="exec $fd<$DIR/$tfile"
2297 trap "eval $cmd" EXIT
2298 nlink=$(stat --dereference --format=%h /proc/self/fd/$fd)
2299 [ ${nlink:--1} -eq 1 ] || error "nlink is $nlink, expected 1"
2300 rm $DIR/$tfile || error "cannot remove '$DIR/$tfile'"
2301 nlink=$(stat --dereference --format=%h /proc/self/fd/$fd)
2302 [ ${nlink:--1} -eq 0 ] || error "nlink is $nlink, expected 0"
2305 run_test 31n "check link count of unlinked file"
2308 local TEMPNAME=$(mktemp $1_XXXXXX)
2309 mlink $TEMPNAME $1 2> /dev/null &&
2310 echo "$BASHPID: link $TEMPNAME to $1 succeeded"
2314 test_31o() { # LU-2901
2315 test_mkdir -p $DIR/$tdir
2316 for LOOP in $(seq 100); do
2317 rm -f $DIR/$tdir/$tfile*
2318 for THREAD in $(seq 8); do
2319 link_one $DIR/$tdir/$tfile.$LOOP &
2322 local LINKS=$(ls -1 $DIR/$tdir | grep -c $tfile.$LOOP)
2323 [[ $LINKS -gt 1 ]] && ls $DIR/$tdir &&
2324 error "$LINKS duplicate links to $tfile.$LOOP" &&
2328 run_test 31o "duplicate hard links with same filename"
2331 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2333 test_mkdir $DIR/$tdir
2334 $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
2335 $LFS setdirstripe -D -c2 -t all_char $DIR/$tdir/striped_dir
2337 opendirunlink $DIR/$tdir/striped_dir/test1 ||
2338 error "open unlink test1 failed"
2339 opendirunlink $DIR/$tdir/striped_dir/test2 ||
2340 error "open unlink test2 failed"
2342 $CHECKSTAT -a $DIR/$tdir/striped_dir/test1 ||
2343 error "test1 still exists"
2344 $CHECKSTAT -a $DIR/$tdir/striped_dir/test2 ||
2345 error "test2 still exists"
2347 run_test 31p "remove of open striped directory"
2349 cleanup_test32_mount() {
2351 $UMOUNT -d $DIR/$tdir/ext2-mountpoint
2355 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2356 echo "== more mountpoints and symlinks ================="
2357 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2358 trap cleanup_test32_mount EXIT
2359 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2360 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2361 $CHECKSTAT -t dir $DIR/$tdir/ext2-mountpoint/.. || error
2362 cleanup_test32_mount
2364 run_test 32a "stat d32a/ext2-mountpoint/.. ====================="
2367 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
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 ls -al $DIR/$tdir/ext2-mountpoint/.. || error
2373 cleanup_test32_mount
2375 run_test 32b "open d32b/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 test_mkdir -p $DIR/$tdir/d2/test_dir
2384 $CHECKSTAT -t dir $DIR/$tdir/ext2-mountpoint/../d2/test_dir || error
2385 cleanup_test32_mount
2387 run_test 32c "stat d32c/ext2-mountpoint/../d2/test_dir ========="
2390 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2391 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2392 trap cleanup_test32_mount EXIT
2393 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2394 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2395 test_mkdir -p $DIR/$tdir/d2/test_dir
2396 ls -al $DIR/$tdir/ext2-mountpoint/../d2/test_dir || error
2397 cleanup_test32_mount
2399 run_test 32d "open d32d/ext2-mountpoint/../d2/test_dir ========="
2402 [ -e $DIR/d32e ] && rm -fr $DIR/d32e
2403 test_mkdir -p $DIR/d32e/tmp
2404 TMP_DIR=$DIR/d32e/tmp
2405 ln -s $DIR/d32e $TMP_DIR/symlink11
2406 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
2407 $CHECKSTAT -t link $DIR/d32e/tmp/symlink11 || error
2408 $CHECKSTAT -t link $DIR/d32e/symlink01 || error
2410 run_test 32e "stat d32e/symlink->tmp/symlink->lustre-subdir ===="
2413 [ -e $DIR/d32f ] && rm -fr $DIR/d32f
2414 test_mkdir -p $DIR/d32f/tmp
2415 TMP_DIR=$DIR/d32f/tmp
2416 ln -s $DIR/d32f $TMP_DIR/symlink11
2417 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
2418 ls $DIR/d32f/tmp/symlink11 || error
2419 ls $DIR/d32f/symlink01 || error
2421 run_test 32f "open d32f/symlink->tmp/symlink->lustre-subdir ===="
2424 TMP_DIR=$DIR/$tdir/tmp
2425 test_mkdir -p $DIR/$tdir/tmp
2426 test_mkdir $DIR/${tdir}2
2427 ln -s $DIR/${tdir}2 $TMP_DIR/symlink12
2428 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
2429 $CHECKSTAT -t link $TMP_DIR/symlink12 || error
2430 $CHECKSTAT -t link $DIR/$tdir/symlink02 || error
2431 $CHECKSTAT -t dir -f $TMP_DIR/symlink12 || error
2432 $CHECKSTAT -t dir -f $DIR/$tdir/symlink02 || error
2434 run_test 32g "stat d32g/symlink->tmp/symlink->lustre-subdir/${tdir}2"
2437 rm -fr $DIR/$tdir $DIR/${tdir}2
2438 TMP_DIR=$DIR/$tdir/tmp
2439 test_mkdir -p $DIR/$tdir/tmp
2440 test_mkdir $DIR/${tdir}2
2441 ln -s $DIR/${tdir}2 $TMP_DIR/symlink12
2442 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
2443 ls $TMP_DIR/symlink12 || error
2444 ls $DIR/$tdir/symlink02 || error
2446 run_test 32h "open d32h/symlink->tmp/symlink->lustre-subdir/${tdir}2"
2449 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2450 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2451 trap cleanup_test32_mount EXIT
2452 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2453 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2454 touch $DIR/$tdir/test_file
2455 $CHECKSTAT -t file $DIR/$tdir/ext2-mountpoint/../test_file || error
2456 cleanup_test32_mount
2458 run_test 32i "stat d32i/ext2-mountpoint/../test_file ==========="
2461 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2462 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2463 trap cleanup_test32_mount EXIT
2464 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2465 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2466 touch $DIR/$tdir/test_file
2467 cat $DIR/$tdir/ext2-mountpoint/../test_file || error
2468 cleanup_test32_mount
2470 run_test 32j "open d32j/ext2-mountpoint/../test_file ==========="
2473 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2475 trap cleanup_test32_mount EXIT
2476 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2477 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint
2478 test_mkdir -p $DIR/$tdir/d2
2479 touch $DIR/$tdir/d2/test_file || error
2480 $CHECKSTAT -t file $DIR/$tdir/ext2-mountpoint/../d2/test_file || error
2481 cleanup_test32_mount
2483 run_test 32k "stat d32k/ext2-mountpoint/../d2/test_file ========"
2486 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2488 trap cleanup_test32_mount EXIT
2489 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2490 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2491 test_mkdir -p $DIR/$tdir/d2
2492 touch $DIR/$tdir/d2/test_file
2493 cat $DIR/$tdir/ext2-mountpoint/../d2/test_file || error
2494 cleanup_test32_mount
2496 run_test 32l "open d32l/ext2-mountpoint/../d2/test_file ========"
2500 test_mkdir -p $DIR/d32m/tmp
2501 TMP_DIR=$DIR/d32m/tmp
2502 ln -s $DIR $TMP_DIR/symlink11
2503 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
2504 $CHECKSTAT -t link $DIR/d32m/tmp/symlink11 || error
2505 $CHECKSTAT -t link $DIR/d32m/symlink01 || error
2507 run_test 32m "stat d32m/symlink->tmp/symlink->lustre-root ======"
2511 test_mkdir -p $DIR/d32n/tmp
2512 TMP_DIR=$DIR/d32n/tmp
2513 ln -s $DIR $TMP_DIR/symlink11
2514 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
2515 ls -l $DIR/d32n/tmp/symlink11 || error
2516 ls -l $DIR/d32n/symlink01 || error
2518 run_test 32n "open d32n/symlink->tmp/symlink->lustre-root ======"
2522 test_mkdir -p $DIR/d32o/tmp
2523 TMP_DIR=$DIR/d32o/tmp
2524 ln -s $DIR/$tfile $TMP_DIR/symlink12
2525 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
2526 $CHECKSTAT -t link $DIR/d32o/tmp/symlink12 || error
2527 $CHECKSTAT -t link $DIR/d32o/symlink02 || error
2528 $CHECKSTAT -t file -f $DIR/d32o/tmp/symlink12 || error
2529 $CHECKSTAT -t file -f $DIR/d32o/symlink02 || error
2531 run_test 32o "stat d32o/symlink->tmp/symlink->lustre-root/$tfile"
2541 test_mkdir -p $DIR/d32p/tmp
2543 TMP_DIR=$DIR/d32p/tmp
2545 ln -s $DIR/$tfile $TMP_DIR/symlink12
2547 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
2549 cat $DIR/d32p/tmp/symlink12 || error
2551 cat $DIR/d32p/symlink02 || error
2554 run_test 32p "open d32p/symlink->tmp/symlink->lustre-root/$tfile"
2556 cleanup_testdir_mount() {
2558 $UMOUNT -d $DIR/$tdir
2562 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2563 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2564 trap cleanup_testdir_mount EXIT
2565 test_mkdir -p $DIR/$tdir
2566 touch $DIR/$tdir/under_the_mount
2567 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir
2568 ls $DIR/$tdir | grep "\<under_the_mount\>" && error
2569 cleanup_testdir_mount
2571 run_test 32q "stat follows mountpoints in Lustre (should return error)"
2574 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2575 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2576 trap cleanup_testdir_mount EXIT
2577 test_mkdir -p $DIR/$tdir
2578 touch $DIR/$tdir/under_the_mount
2579 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir
2580 ls $DIR/$tdir | grep -q under_the_mount && error || true
2581 cleanup_testdir_mount
2583 run_test 32r "opendir follows mountpoints in Lustre (should return error)"
2588 chmod 444 $DIR/$tfile
2589 chown $RUNAS_ID $DIR/$tfile
2591 $RUNAS $OPENFILE -f O_RDWR $DIR/$tfile && error || true
2594 run_test 33aa "write file with mode 444 (should return error) ===="
2598 test_mkdir -p $DIR/d33
2599 chown $RUNAS_ID $DIR/d33
2600 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $DIR/d33/f33|| error "create"
2601 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $DIR/d33/f33 && \
2602 error "open RDWR" || true
2604 run_test 33a "test open file(mode=0444) with O_RDWR (should return error)"
2608 test_mkdir -p $DIR/d33
2609 chown $RUNAS_ID $DIR/d33
2610 $RUNAS $OPENFILE -f 1286739555 $DIR/d33/f33 || true
2612 run_test 33b "test open file with malformed flags (No panic)"
2615 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2621 remote_ost_nodsh && skip "remote OST with nodsh" && return
2624 test_mkdir -p $DIR/d33
2625 # Read: 0, Write: 4, create/destroy: 2/0, stat: 1, punch: 0
2628 for ostnum in $(seq $OSTCOUNT); do
2629 # test-framework's OST numbering is one-based, while Lustre's
2631 ostname=$(printf "$FSNAME-OST%.4x" $((ostnum - 1)))
2632 # Parsing llobdstat's output sucks; we could grep the /proc
2633 # path, but that's likely to not be as portable as using the
2634 # llobdstat utility. So we parse lctl output instead.
2635 write_bytes=$(do_facet ost$ostnum lctl get_param -n \
2636 obdfilter/$ostname/stats |
2637 awk '/^write_bytes/ {print $7}' )
2638 echo "baseline_write_bytes@$OSTnum/$ostname=$write_bytes"
2639 if (( ${write_bytes:-0} > 0 ))
2646 $all_zeros || return 0
2649 echo foo > $DIR/d33/bar
2653 # Total up write_bytes after writing. We'd better find non-zeros.
2654 for ostnum in $(seq $OSTCOUNT); do
2655 ostname=$(printf "$FSNAME-OST%.4x" $((ostnum - 1)))
2656 write_bytes=$(do_facet ost$ostnum lctl get_param -n \
2657 obdfilter/$ostname/stats |
2658 awk '/^write_bytes/ {print $7}' )
2659 echo "write_bytes@$OSTnum/$ostname=$write_bytes"
2660 if (( ${write_bytes:-0} > 0 ))
2669 for ostnum in $(seq $OSTCOUNT); do
2670 ostname=$(printf "$FSNAME-OST%.4x" $((ostnum - 1)))
2671 echo "Check that write_bytes is present in obdfilter/*/stats:"
2672 do_facet ost$ostnum lctl get_param -n \
2673 obdfilter/$ostname/stats
2675 error "OST not keeping write_bytes stats (b22312)"
2678 run_test 33c "test llobdstat and write_bytes"
2681 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 2 MDTs" && return
2682 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2684 local remote_dir=$DIR/$tdir/remote_dir
2686 test_mkdir -p $DIR/$tdir
2687 $LFS mkdir -i $MDTIDX $remote_dir ||
2688 error "create remote directory failed"
2690 touch $remote_dir/$tfile
2691 chmod 444 $remote_dir/$tfile
2692 chown $RUNAS_ID $remote_dir/$tfile
2694 $RUNAS $OPENFILE -f O_RDWR $DIR/$tfile && error || true
2696 chown $RUNAS_ID $remote_dir
2697 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $remote_dir/f33 ||
2698 error "create" || true
2699 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $remote_dir/f33 &&
2700 error "open RDWR" || true
2701 $RUNAS $OPENFILE -f 1286739555 $remote_dir/f33 &&
2702 error "create" || true
2704 run_test 33d "openfile with 444 modes and malformed flags under remote dir"
2707 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2711 $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
2712 $LFS setdirstripe -i1 -c2 $DIR/$tdir/striped_dir1
2713 mkdir $DIR/$tdir/local_dir
2715 local s0_mode=$(stat -c%f $DIR/$tdir/striped_dir)
2716 local s1_mode=$(stat -c%f $DIR/$tdir/striped_dir1)
2717 local l_mode=$(stat -c%f $DIR/$tdir/local_dir)
2719 [ "$l_mode" = "$s0_mode" -a "$l_mode" = "$s1_mode" ] ||
2720 error "mkdir $l_mode striped0 $s0_mode striped1 $s1_mode"
2722 rmdir $DIR/$tdir/* || error "rmdir failed"
2725 $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
2726 $LFS setdirstripe -i1 -c2 $DIR/$tdir/striped_dir1
2727 mkdir $DIR/$tdir/local_dir
2729 s0_mode=$(stat -c%f $DIR/$tdir/striped_dir)
2730 s1_mode=$(stat -c%f $DIR/$tdir/striped_dir1)
2731 l_mode=$(stat -c%f $DIR/$tdir/local_dir)
2733 [ "$l_mode" = "$s0_mode" -a "$l_mode" = "$s1_mode" ] ||
2734 error "mkdir $l_mode striped0 $s0_mode striped1 $s1_mode 777"
2736 rmdir $DIR/$tdir/* || error "rmdir(umask 777) failed"
2739 $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
2740 $LFS setdirstripe -i1 -c2 $DIR/$tdir/striped_dir1
2741 mkdir $DIR/$tdir/local_dir
2743 s0_mode=$(stat -c%f $DIR/$tdir/striped_dir)
2744 s1_mode=$(stat -c%f $DIR/$tdir/striped_dir1)
2745 l_mode=$(stat -c%f $DIR/$tdir/local_dir)
2747 [ "$l_mode" = "$s0_mode" -a "$l_mode" = "$s1_mode" ] ||
2748 error "mkdir $l_mode striped0 $s0_mode striped1 $s1_mode 0"
2750 run_test 33e "mkdir and striped directory should have same mode"
2754 do_facet $SINGLEMDS $LCTL set_param mdt.*.enable_remote_dir_gid=0
2758 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2761 chmod go+rwx $DIR/$tdir
2762 do_facet $SINGLEMDS $LCTL set_param mdt.*.enable_remote_dir_gid=-1
2763 trap cleanup_33f EXIT
2765 $RUNAS lfs mkdir -c$MDSCOUNT $DIR/$tdir/striped_dir ||
2766 error "cannot create striped directory"
2768 $RUNAS touch $DIR/$tdir/striped_dir/{0..16} ||
2769 error "cannot create files in striped directory"
2771 $RUNAS rm $DIR/$tdir/striped_dir/{0..16} ||
2772 error "cannot remove files in striped directory"
2774 $RUNAS rmdir $DIR/$tdir/striped_dir ||
2775 error "cannot remove striped directory"
2779 run_test 33f "nonroot user can create, access, and remove a striped directory"
2781 TEST_34_SIZE=${TEST_34_SIZE:-2000000000000}
2784 $MCREATE $DIR/f34 || error
2785 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" || error
2786 $TRUNCATE $DIR/f34 $TEST_34_SIZE || error
2787 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" || error
2788 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2790 run_test 34a "truncate file that has not been opened ==========="
2793 [ ! -f $DIR/f34 ] && test_34a
2794 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2795 $OPENFILE -f O_RDONLY $DIR/f34
2796 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" || error
2797 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2799 run_test 34b "O_RDONLY opening file doesn't create objects ====="
2802 [ ! -f $DIR/f34 ] && test_34a
2803 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2804 $OPENFILE -f O_RDWR $DIR/f34
2805 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" && error
2806 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2808 run_test 34c "O_RDWR opening file-with-size works =============="
2811 [ ! -f $DIR/f34 ] && test_34a
2812 dd if=/dev/zero of=$DIR/f34 conv=notrunc bs=4k count=1 || error
2813 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2816 run_test 34d "write to sparse file ============================="
2820 $MCREATE $DIR/f34e || error
2821 $TRUNCATE $DIR/f34e 1000 || error
2822 $CHECKSTAT -s 1000 $DIR/f34e || error
2823 $OPENFILE -f O_RDWR $DIR/f34e
2824 $CHECKSTAT -s 1000 $DIR/f34e || error
2826 run_test 34e "create objects, some with size and some without =="
2828 test_34f() { # bug 6242, 6243
2829 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2832 $MCREATE $DIR/f34f || error
2833 $TRUNCATE $DIR/f34f $SIZE34F || error "truncating $DIR/f3f to $SIZE34F"
2834 dd if=$DIR/f34f of=$TMP/f34f
2835 $CHECKSTAT -s $SIZE34F $TMP/f34f || error "$TMP/f34f not $SIZE34F bytes"
2836 dd if=/dev/zero of=$TMP/f34fzero bs=$SIZE34F count=1
2837 cmp $DIR/f34f $TMP/f34fzero || error "$DIR/f34f not all zero"
2838 cmp $TMP/f34f $TMP/f34fzero || error "$TMP/f34f not all zero"
2839 rm $TMP/f34f $TMP/f34fzero $DIR/f34f
2841 run_test 34f "read from a file with no objects until EOF ======="
2844 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2845 dd if=/dev/zero of=$DIR/$tfile bs=1 count=100 seek=$TEST_34_SIZE || error
2846 $TRUNCATE $DIR/$tfile $((TEST_34_SIZE / 2))|| error
2847 $CHECKSTAT -s $((TEST_34_SIZE / 2)) $DIR/$tfile || error "truncate failed"
2848 cancel_lru_locks osc
2849 $CHECKSTAT -s $((TEST_34_SIZE / 2)) $DIR/$tfile || \
2850 error "wrong size after lock cancel"
2852 $TRUNCATE $DIR/$tfile $TEST_34_SIZE || error
2853 $CHECKSTAT -s $TEST_34_SIZE $DIR/$tfile || \
2854 error "expanding truncate failed"
2855 cancel_lru_locks osc
2856 $CHECKSTAT -s $TEST_34_SIZE $DIR/$tfile || \
2857 error "wrong expanded size after lock cancel"
2859 run_test 34g "truncate long file ==============================="
2862 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2866 dd if=/dev/zero of=$DIR/$tfile bs=1M count=10 || error
2867 sync # Flush the cache so that multiop below does not block on cache
2868 # flush when getting the group lock
2869 $MULTIOP $DIR/$tfile OG${gid}T${sz}g${gid}c &
2872 # Since just timed wait is not good enough, let's do a sync write
2873 # that way we are sure enough time for a roundtrip + processing
2874 # passed + 2 seconds of extra margin.
2875 dd if=/dev/zero of=$DIR/${tfile}-1 bs=4096 oflag=direct count=1
2879 if [[ `ps h -o comm -p $MULTIPID` == "multiop" ]]; then
2880 error "Multiop blocked on ftruncate, pid=$MULTIPID"
2884 local nsz=`stat -c %s $DIR/$tfile`
2885 [[ $nsz == $sz ]] || error "New size wrong $nsz != $sz"
2887 run_test 34h "ftruncate file under grouplock should not block"
2890 cp /bin/sh $DIR/f35a
2892 chown $RUNAS_ID $DIR/f35a
2893 $RUNAS $DIR/f35a && error || true
2896 run_test 35a "exec file with mode 444 (should return and not leak) ====="
2900 utime $DIR/f36 || error
2902 run_test 36a "MDS utime check (mknod, utime) ==================="
2906 utime $DIR/f36 || error
2908 run_test 36b "OST utime check (open, utime) ===================="
2913 chown $RUNAS_ID $DIR/d36
2914 $RUNAS utime $DIR/d36/f36 || error
2916 run_test 36c "non-root MDS utime check (mknod, utime) =========="
2919 [ ! -d $DIR/d36 ] && test_36c
2920 echo "" > $DIR/d36/f36
2921 $RUNAS utime $DIR/d36/f36 || error
2923 run_test 36d "non-root OST utime check (open, utime) ==========="
2926 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID -- skipping" && return
2927 test_mkdir -p $DIR/$tdir
2928 touch $DIR/$tdir/$tfile
2929 $RUNAS utime $DIR/$tdir/$tfile && \
2930 error "utime worked, expected failure" || true
2932 run_test 36e "utime on non-owned file (should return error) ===="
2936 local LANG_SAVE=$LANG
2937 local LC_LANG_SAVE=$LC_LANG
2938 export LANG=C LC_LANG=C # for date language
2940 DATESTR="Dec 20 2000"
2941 test_mkdir -p $DIR/$tdir
2942 lctl set_param fail_loc=$fl
2944 cp /etc/hosts $DIR/$tdir/$tfile
2945 sync & # write RPC generated with "current" inode timestamp, but delayed
2947 touch --date="$DATESTR" $DIR/$tdir/$tfile # setattr timestamp in past
2948 LS_BEFORE="`ls -l $DIR/$tdir/$tfile`" # old timestamp from client cache
2949 cancel_lru_locks osc
2950 LS_AFTER="`ls -l $DIR/$tdir/$tfile`" # timestamp from OST object
2952 [ "$LS_BEFORE" != "$LS_AFTER" ] && \
2953 echo "BEFORE: $LS_BEFORE" && \
2954 echo "AFTER : $LS_AFTER" && \
2955 echo "WANT : $DATESTR" && \
2956 error "$DIR/$tdir/$tfile timestamps changed" || true
2958 export LANG=$LANG_SAVE LC_LANG=$LC_LANG_SAVE
2962 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2963 #define OBD_FAIL_OST_BRW_PAUSE_BULK 0x214
2964 subr_36fh "0x80000214"
2966 run_test 36f "utime on file racing with OST BRW write =========="
2969 remote_ost_nodsh && skip "remote OST with nodsh" && return
2970 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2975 test_mkdir -p $DIR/$tdir
2976 fmd_max_age=$(do_facet ost1 \
2977 "lctl get_param -n obdfilter.*.client_cache_seconds 2> /dev/null | \
2980 fmd_before=$(do_facet ost1 \
2981 "awk '/ll_fmd_cache/ {print \\\$2}' /proc/slabinfo")
2982 touch $DIR/$tdir/$tfile
2983 sleep $((fmd_max_age + 12))
2984 fmd_after=$(do_facet ost1 \
2985 "awk '/ll_fmd_cache/ {print \\\$2}' /proc/slabinfo")
2987 echo "fmd_before: $fmd_before"
2988 echo "fmd_after: $fmd_after"
2989 [[ $fmd_after -gt $fmd_before ]] &&
2990 echo "AFTER: $fmd_after > BEFORE: $fmd_before" &&
2991 error "fmd didn't expire after ping" || true
2993 run_test 36g "filter mod data cache expiry ====================="
2996 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2997 #define OBD_FAIL_OST_BRW_PAUSE_BULK2 0x227
2998 subr_36fh "0x80000227"
3000 run_test 36h "utime on file racing with OST BRW write =========="
3003 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
3005 test_mkdir $DIR/$tdir
3006 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR/$tdir/striped_dir
3008 local mtime=$(stat -c%Y $DIR/$tdir/striped_dir)
3009 local new_mtime=$((mtime + 200))
3011 #change Modify time of striped dir
3012 touch -m -d @$new_mtime $DIR/$tdir/striped_dir ||
3013 error "change mtime failed"
3015 local got=$(stat -c%Y $DIR/$tdir/striped_dir)
3017 [ "$new_mtime" = "$got" ] || error "expect $new_mtime got $got"
3019 run_test 36i "change mtime on striped directory"
3021 # test_37 - duplicate with tests 32q 32r
3024 local file=$DIR/$tfile
3026 openfile -f O_DIRECTORY $file
3029 [ $RC -eq 0 ] && error "opened file $file with O_DIRECTORY" || true
3030 [ $RC -eq $ENOTDIR ] || error "error $RC should be ENOTDIR ($ENOTDIR)"
3032 run_test 38 "open a regular file with O_DIRECTORY should return -ENOTDIR ==="
3036 touch $DIR/${tfile}2
3037 # ls -l $DIR/$tfile $DIR/${tfile}2
3038 # ls -lu $DIR/$tfile $DIR/${tfile}2
3039 # ls -lc $DIR/$tfile $DIR/${tfile}2
3041 $OPENFILE -f O_CREAT:O_TRUNC:O_WRONLY $DIR/${tfile}2
3042 if [ ! $DIR/${tfile}2 -nt $DIR/$tfile ]; then
3044 ls -l --full-time $DIR/$tfile $DIR/${tfile}2
3046 ls -lu --full-time $DIR/$tfile $DIR/${tfile}2
3048 ls -lc --full-time $DIR/$tfile $DIR/${tfile}2
3049 error "O_TRUNC didn't change timestamps"
3052 run_test 39 "mtime changed on create ==========================="
3055 test_mkdir -p -c1 $DIR/$tdir
3056 cp -p /etc/passwd $DIR/$tdir/fopen
3057 cp -p /etc/passwd $DIR/$tdir/flink
3058 cp -p /etc/passwd $DIR/$tdir/funlink
3059 cp -p /etc/passwd $DIR/$tdir/frename
3060 ln $DIR/$tdir/funlink $DIR/$tdir/funlink2
3063 echo "aaaaaa" >> $DIR/$tdir/fopen
3064 echo "aaaaaa" >> $DIR/$tdir/flink
3065 echo "aaaaaa" >> $DIR/$tdir/funlink
3066 echo "aaaaaa" >> $DIR/$tdir/frename
3068 local open_new=`stat -c %Y $DIR/$tdir/fopen`
3069 local link_new=`stat -c %Y $DIR/$tdir/flink`
3070 local unlink_new=`stat -c %Y $DIR/$tdir/funlink`
3071 local rename_new=`stat -c %Y $DIR/$tdir/frename`
3073 cat $DIR/$tdir/fopen > /dev/null
3074 ln $DIR/$tdir/flink $DIR/$tdir/flink2
3075 rm -f $DIR/$tdir/funlink2
3076 mv -f $DIR/$tdir/frename $DIR/$tdir/frename2
3078 for (( i=0; i < 2; i++ )) ; do
3079 local open_new2=`stat -c %Y $DIR/$tdir/fopen`
3080 local link_new2=`stat -c %Y $DIR/$tdir/flink`
3081 local unlink_new2=`stat -c %Y $DIR/$tdir/funlink`
3082 local rename_new2=`stat -c %Y $DIR/$tdir/frename2`
3084 [ $open_new2 -eq $open_new ] || error "open file reverses mtime"
3085 [ $link_new2 -eq $link_new ] || error "link file reverses mtime"
3086 [ $unlink_new2 -eq $unlink_new ] || error "unlink file reverses mtime"
3087 [ $rename_new2 -eq $rename_new ] || error "rename file reverses mtime"
3089 cancel_lru_locks osc
3090 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3093 run_test 39b "mtime change on open, link, unlink, rename ======"
3095 # this should be set to past
3096 TEST_39_MTIME=`date -d "1 year ago" +%s`
3102 local mtime0=`stat -c %Y $DIR1/$tfile`
3104 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3105 local mtime1=`stat -c %Y $DIR1/$tfile`
3106 [ "$mtime1" = $TEST_39_MTIME ] || \
3107 error "mtime is not set to past: $mtime1, should be $TEST_39_MTIME"
3110 echo hello >> $DIR1/$tfile
3112 local mtime2=`stat -c %Y $DIR1/$tfile`
3113 [ "$mtime2" -ge "$d1" ] && [ "$mtime2" -le "$d2" ] || \
3114 error "mtime is not updated on write: $d1 <= $mtime2 <= $d2"
3116 mv $DIR1/$tfile $DIR1/$tfile-1
3118 for (( i=0; i < 2; i++ )) ; do
3119 local mtime3=`stat -c %Y $DIR1/$tfile-1`
3120 [ "$mtime2" = "$mtime3" ] || \
3121 error "mtime ($mtime2) changed (to $mtime3) on rename"
3123 cancel_lru_locks osc
3124 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3127 run_test 39c "mtime change on rename ==========================="
3131 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3134 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3136 for (( i=0; i < 2; i++ )) ; do
3137 local mtime=`stat -c %Y $DIR1/$tfile`
3138 [ $mtime = $TEST_39_MTIME ] || \
3139 error "mtime($mtime) is not set to $TEST_39_MTIME"
3141 cancel_lru_locks osc
3142 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3145 run_test 39d "create, utime, stat =============================="
3149 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3151 local mtime1=`stat -c %Y $DIR1/$tfile`
3153 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3155 for (( i=0; i < 2; i++ )) ; do
3156 local mtime2=`stat -c %Y $DIR1/$tfile`
3157 [ $mtime2 = $TEST_39_MTIME ] || \
3158 error "mtime($mtime2) is not set to $TEST_39_MTIME"
3160 cancel_lru_locks osc
3161 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3164 run_test 39e "create, stat, utime, stat ========================"
3168 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3170 mtime1=`stat -c %Y $DIR1/$tfile`
3173 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3175 for (( i=0; i < 2; i++ )) ; do
3176 local mtime2=`stat -c %Y $DIR1/$tfile`
3177 [ $mtime2 = $TEST_39_MTIME ] || \
3178 error "mtime($mtime2) is not set to $TEST_39_MTIME"
3180 cancel_lru_locks osc
3181 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3184 run_test 39f "create, stat, sleep, utime, stat ================="
3188 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3189 echo hello >> $DIR1/$tfile
3190 local mtime1=`stat -c %Y $DIR1/$tfile`
3193 chmod o+r $DIR1/$tfile
3195 for (( i=0; i < 2; i++ )) ; do
3196 local mtime2=`stat -c %Y $DIR1/$tfile`
3197 [ "$mtime1" = "$mtime2" ] || \
3198 error "lost mtime: $mtime2, should be $mtime1"
3200 cancel_lru_locks osc
3201 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3204 run_test 39g "write, chmod, stat ==============================="
3208 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3213 echo hello >> $DIR1/$tfile
3214 local mtime1=`stat -c %Y $DIR1/$tfile`
3216 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3218 if [ "$d1" != "$d2" ]; then
3219 echo "write and touch not within one second"
3221 for (( i=0; i < 2; i++ )) ; do
3222 local mtime2=`stat -c %Y $DIR1/$tfile`
3223 [ "$mtime2" = $TEST_39_MTIME ] || \
3224 error "lost mtime: $mtime2, should be $TEST_39_MTIME"
3226 cancel_lru_locks osc
3227 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3231 run_test 39h "write, utime within one second, stat ============="
3234 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3238 echo hello >> $DIR1/$tfile
3239 local mtime1=`stat -c %Y $DIR1/$tfile`
3241 mv $DIR1/$tfile $DIR1/$tfile-1
3243 for (( i=0; i < 2; i++ )) ; do
3244 local mtime2=`stat -c %Y $DIR1/$tfile-1`
3246 [ "$mtime1" = "$mtime2" ] || \
3247 error "lost mtime: $mtime2, should be $mtime1"
3249 cancel_lru_locks osc
3250 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3253 run_test 39i "write, rename, stat =============================="
3256 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3257 start_full_debug_logging
3261 #define OBD_FAIL_OSC_DELAY_SETTIME 0x412
3262 lctl set_param fail_loc=0x80000412
3263 multiop_bg_pause $DIR1/$tfile oO_RDWR:w2097152_c ||
3264 error "multiop failed"
3266 local mtime1=`stat -c %Y $DIR1/$tfile`
3268 mv $DIR1/$tfile $DIR1/$tfile-1
3270 kill -USR1 $multipid
3271 wait $multipid || error "multiop close failed"
3273 for (( i=0; i < 2; i++ )) ; do
3274 local mtime2=`stat -c %Y $DIR1/$tfile-1`
3275 [ "$mtime1" = "$mtime2" ] ||
3276 error "mtime is lost on close: $mtime2, " \
3279 cancel_lru_locks osc
3280 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3282 lctl set_param fail_loc=0
3283 stop_full_debug_logging
3285 run_test 39j "write, rename, close, stat ======================="
3288 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3292 multiop_bg_pause $DIR1/$tfile oO_RDWR:w2097152_c || error "multiop failed"
3294 local mtime1=`stat -c %Y $DIR1/$tfile`
3296 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3298 kill -USR1 $multipid
3299 wait $multipid || error "multiop close failed"
3301 for (( i=0; i < 2; i++ )) ; do
3302 local mtime2=`stat -c %Y $DIR1/$tfile`
3304 [ "$mtime2" = $TEST_39_MTIME ] || \
3305 error "mtime is lost on close: $mtime2, should be $TEST_39_MTIME"
3307 cancel_lru_locks osc
3308 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3311 run_test 39k "write, utime, close, stat ========================"
3313 # this should be set to future
3314 TEST_39_ATIME=`date -d "1 year" +%s`
3317 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3318 remote_mds_nodsh && skip "remote MDS with nodsh" && return
3319 local atime_diff=$(do_facet $SINGLEMDS \
3320 lctl get_param -n mdd.*MDT0000*.atime_diff)
3324 # test setting directory atime to future
3325 touch -a -d @$TEST_39_ATIME $DIR/$tdir
3326 local atime=$(stat -c %X $DIR/$tdir)
3327 [ "$atime" = $TEST_39_ATIME ] || \
3328 error "atime is not set to future: $atime, $TEST_39_ATIME"
3330 # test setting directory atime from future to now
3331 local d1=$(date +%s)
3333 local d2=$(date +%s)
3335 cancel_lru_locks mdc
3336 atime=$(stat -c %X $DIR/$tdir)
3337 [ "$atime" -ge "$d1" -a "$atime" -le "$d2" ] || \
3338 error "atime is not updated from future: $atime, $d1<atime<$d2"
3340 do_facet $SINGLEMDS lctl set_param -n mdd.*MDT0000*.atime_diff=2
3343 # test setting directory atime when now > dir atime + atime_diff
3347 cancel_lru_locks mdc
3348 atime=$(stat -c %X $DIR/$tdir)
3349 [ "$atime" -ge "$d1" -a "$atime" -le "$d2" ] || \
3350 error "atime is not updated : $atime, should be $d2"
3352 do_facet $SINGLEMDS lctl set_param -n mdd.*MDT0000*.atime_diff=60
3355 # test not 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 updated to $atime, should remain $d1<atime<$d2"
3362 do_facet $SINGLEMDS \
3363 lctl set_param -n mdd.*MDT0000*.atime_diff=$atime_diff
3365 run_test 39l "directory atime update ==========================="
3368 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3371 local far_past_mtime=$(date -d "May 29 1953" +%s)
3372 local far_past_atime=$(date -d "Dec 17 1903" +%s)
3374 touch -m -d @$far_past_mtime $DIR1/$tfile
3375 touch -a -d @$far_past_atime $DIR1/$tfile
3377 for (( i=0; i < 2; i++ )) ; do
3378 local timestamps=$(stat -c "%X %Y" $DIR1/$tfile)
3379 [ "$timestamps" = "$far_past_atime $far_past_mtime" ] || \
3380 error "atime or mtime set incorrectly"
3382 cancel_lru_locks osc
3383 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3386 run_test 39m "test atime and mtime before 1970"
3388 test_39n() { # LU-3832
3389 local atime_diff=$(do_facet $SINGLEMDS \
3390 lctl get_param -n mdd.*MDT0000*.atime_diff)
3395 do_facet $SINGLEMDS lctl set_param -n mdd.*MDT0000*.atime_diff=1
3398 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 status=noxfer
3399 atime0=$(stat -c %X $DIR/$tfile)
3402 $MULTIOP $DIR/$tfile oO_RDONLY:O_NOATIME:r4096c
3403 atime1=$(stat -c %X $DIR/$tfile)
3406 cancel_lru_locks mdc
3407 cancel_lru_locks osc
3408 $MULTIOP $DIR/$tfile oO_RDONLY:O_NOATIME:r4096c
3409 atime2=$(stat -c %X $DIR/$tfile)
3411 do_facet $SINGLEMDS \
3412 lctl set_param -n mdd.*MDT0000*.atime_diff=$atime_diff
3414 [ "$atime0" -eq "$atime1" ] || error "atime0 $atime0 != atime1 $atime1"
3415 [ "$atime1" -eq "$atime2" ] || error "atime0 $atime0 != atime1 $atime1"
3417 run_test 39n "check that O_NOATIME is honored"
3420 TESTDIR=$DIR/$tdir/$tfile
3421 [ -e $TESTDIR ] && rm -rf $TESTDIR
3428 links2=$(stat -c %h .)
3429 [ $(($links1 + 2)) != $links2 ] &&
3430 error "wrong links count $(($links1 + 2)) != $links2"
3432 links3=$(stat -c %h .)
3433 [ $(($links1 + 1)) != $links3 ] &&
3434 error "wrong links count $links1 != $links3"
3437 run_test 39o "directory cached attributes updated after create ========"
3440 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 2 MDTs" && return
3442 TESTDIR=$DIR/$tdir/$tfile
3443 [ -e $TESTDIR ] && rm -rf $TESTDIR
3444 test_mkdir -p $TESTDIR
3448 $LFS mkdir -i $MDTIDX $TESTDIR/remote_dir1
3449 $LFS mkdir -i $MDTIDX $TESTDIR/remote_dir2
3451 links2=$(stat -c %h .)
3452 [ $(($links1 + 2)) != $links2 ] &&
3453 error "wrong links count $(($links1 + 2)) != $links2"
3455 links3=$(stat -c %h .)
3456 [ $(($links1 + 1)) != $links3 ] &&
3457 error "wrong links count $links1 != $links3"
3460 run_test 39p "remote directory cached attributes updated after create ========"
3464 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1
3465 $RUNAS $OPENFILE -f O_WRONLY:O_TRUNC $DIR/$tfile &&
3466 error "openfile O_WRONLY:O_TRUNC $tfile failed"
3467 $CHECKSTAT -t file -s 4096 $DIR/$tfile ||
3468 error "$tfile is not 4096 bytes in size"
3470 run_test 40 "failed open(O_TRUNC) doesn't truncate ============="
3474 small_write $DIR/f41 18
3476 run_test 41 "test small file write + fstat ====================="
3478 count_ost_writes() {
3479 lctl get_param -n osc.*.stats |
3480 awk -vwrites=0 '/ost_write/ { writes += $2 } \
3481 END { printf("%0.0f", writes) }'
3488 BG_DIRTY_RATIO_SAVE=10
3489 MAX_BG_DIRTY_RATIO=25
3493 # in 2.6, restore /proc/sys/vm/dirty_writeback_centisecs,
3494 # dirty_ratio, dirty_background_ratio
3495 if [ -f /proc/sys/vm/dirty_writeback_centisecs ]; then
3496 sysctl -w vm.dirty_writeback_centisecs=$WRITEBACK_SAVE
3497 sysctl -w vm.dirty_background_ratio=$BG_DIRTY_RATIO_SAVE
3498 sysctl -w vm.dirty_ratio=$DIRTY_RATIO_SAVE
3500 # if file not here, we are a 2.4 kernel
3501 kill -CONT `pidof kupdated`
3506 # setup the trap first, so someone cannot exit the test at the
3507 # exact wrong time and mess up a machine
3508 trap start_writeback EXIT
3509 # in 2.6, save and 0 /proc/sys/vm/dirty_writeback_centisecs
3510 if [ -f /proc/sys/vm/dirty_writeback_centisecs ]; then
3511 WRITEBACK_SAVE=`sysctl -n vm.dirty_writeback_centisecs`
3512 sysctl -w vm.dirty_writeback_centisecs=0
3513 sysctl -w vm.dirty_writeback_centisecs=0
3514 # save and increase /proc/sys/vm/dirty_ratio
3515 DIRTY_RATIO_SAVE=`sysctl -n vm.dirty_ratio`
3516 sysctl -w vm.dirty_ratio=$MAX_DIRTY_RATIO
3517 # save and increase /proc/sys/vm/dirty_background_ratio
3518 BG_DIRTY_RATIO_SAVE=`sysctl -n vm.dirty_background_ratio`
3519 sysctl -w vm.dirty_background_ratio=$MAX_BG_DIRTY_RATIO
3521 # if file not here, we are a 2.4 kernel
3522 kill -STOP `pidof kupdated`
3526 # ensure that all stripes have some grant before we test client-side cache
3528 for i in `seq -f $DIR/f42-%g 1 $OSTCOUNT`; do
3529 dd if=/dev/zero of=$i bs=4k count=1
3534 # Tests 42* verify that our behaviour is correct WRT caching, file closure,
3535 # file truncation, and file removal.
3537 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3539 cancel_lru_locks osc
3541 sync; sleep 1; sync # just to be safe
3542 BEFOREWRITES=`count_ost_writes`
3543 lctl get_param -n osc.*[oO][sS][cC][_-]*.cur_grant_bytes | grep "[0-9]"
3544 dd if=/dev/zero of=$DIR/f42a bs=1024 count=100
3545 AFTERWRITES=`count_ost_writes`
3546 [ $BEFOREWRITES -eq $AFTERWRITES ] || \
3547 error "$BEFOREWRITES < $AFTERWRITES"
3550 run_test 42a "ensure that we don't flush on close =============="
3553 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3555 cancel_lru_locks osc
3558 dd if=/dev/zero of=$DIR/f42b bs=1024 count=100
3559 BEFOREWRITES=$(count_ost_writes)
3560 $MUNLINK $DIR/f42b || error "$MUNLINK $DIR/f42b: $?"
3561 AFTERWRITES=$(count_ost_writes)
3562 if [[ $BEFOREWRITES -lt $AFTERWRITES ]]; then
3563 error "$BEFOREWRITES < $AFTERWRITES on unlink"
3565 BEFOREWRITES=$(count_ost_writes)
3566 sync || error "sync: $?"
3567 AFTERWRITES=$(count_ost_writes)
3568 if [[ $BEFOREWRITES -lt $AFTERWRITES ]]; then
3569 error "$BEFOREWRITES < $AFTERWRITES on sync"
3571 dmesg | grep 'error from obd_brw_async' && error 'error writing back'
3575 run_test 42b "test destroy of file with cached dirty data ======"
3577 # if these tests just want to test the effect of truncation,
3578 # they have to be very careful. consider:
3579 # - the first open gets a {0,EOF}PR lock
3580 # - the first write conflicts and gets a {0, count-1}PW
3581 # - the rest of the writes are under {count,EOF}PW
3582 # - the open for truncate tries to match a {0,EOF}PR
3583 # for the filesize and cancels the PWs.
3584 # any number of fixes (don't get {0,EOF} on open, match
3585 # composite locks, do smarter file size management) fix
3586 # this, but for now we want these tests to verify that
3587 # the cancellation with truncate intent works, so we
3588 # start the file with a full-file pw lock to match against
3589 # until the truncate.
3594 cancel_lru_locks osc
3596 # prime the file with 0,EOF PW to match
3600 # now the real test..
3601 dd if=/dev/zero of=$file bs=1024 count=100
3602 BEFOREWRITES=`count_ost_writes`
3603 $TRUNCATE $file $offset
3604 cancel_lru_locks osc
3605 AFTERWRITES=`count_ost_writes`
3610 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3612 [ $BEFOREWRITES -eq $AFTERWRITES ] && \
3613 error "beforewrites $BEFOREWRITES == afterwrites $AFTERWRITES on truncate"
3616 run_test 42c "test partial truncate of file with cached dirty data"
3619 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3621 [ $BEFOREWRITES -eq $AFTERWRITES ] || \
3622 error "beforewrites $BEFOREWRITES != afterwrites $AFTERWRITES on truncate"
3625 run_test 42d "test complete truncate of file with cached dirty data"
3627 test_42e() { # bug22074
3628 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3629 local TDIR=$DIR/${tdir}e
3630 local pagesz=$(page_size)
3631 local pages=16 # hardcoded 16 pages, don't change it.
3632 local files=$((OSTCOUNT * 500)) # hopefully 500 files on each OST
3633 local proc_osc0="osc.${FSNAME}-OST0000-osc-[^MDT]*"
3637 test_mkdir -p $DIR/${tdir}e
3638 $SETSTRIPE -c 1 $TDIR
3639 createmany -o $TDIR/f $files
3641 max_dirty_mb=$($LCTL get_param -n $proc_osc0/max_dirty_mb)
3643 # we assume that with $OSTCOUNT files, at least one of them will
3644 # be allocated on OST0.
3645 warmup_files=$((OSTCOUNT * max_dirty_mb))
3646 createmany -o $TDIR/w $warmup_files
3648 # write a large amount of data into one file and sync, to get good
3649 # avail_grant number from OST.
3650 for ((i=0; i<$warmup_files; i++)); do
3651 idx=$($GETSTRIPE -i $TDIR/w$i)
3652 [ $idx -ne 0 ] && continue
3653 dd if=/dev/zero of=$TDIR/w$i bs="$max_dirty_mb"M count=1
3656 [[ $i -gt $warmup_files ]] && error "OST0 is still cold"
3658 $LCTL get_param $proc_osc0/cur_dirty_bytes
3659 $LCTL get_param $proc_osc0/cur_grant_bytes
3661 # create as much dirty pages as we can while not to trigger the actual
3662 # RPCs directly. but depends on the env, VFS may trigger flush during this
3663 # period, hopefully we are good.
3664 for ((i=0; i<$warmup_files; i++)); do
3665 idx=$($GETSTRIPE -i $TDIR/w$i)
3666 [ $idx -ne 0 ] && continue
3667 dd if=/dev/zero of=$TDIR/w$i bs=1M count=1 2>/dev/null
3669 $LCTL get_param $proc_osc0/cur_dirty_bytes
3670 $LCTL get_param $proc_osc0/cur_grant_bytes
3672 # perform the real test
3673 $LCTL set_param $proc_osc0/rpc_stats 0
3674 for ((;i<$files; i++)); do
3675 [ $($GETSTRIPE -i $TDIR/f$i) -eq 0 ] || continue
3676 dd if=/dev/zero of=$TDIR/f$i bs=$pagesz count=$pages 2>/dev/null
3679 $LCTL get_param $proc_osc0/rpc_stats
3682 local have_ppr=false
3683 $LCTL get_param $proc_osc0/rpc_stats |
3684 while read PPR RRPC RPCT RCUM BAR WRPC WPCT WCUM; do
3685 # skip lines until we are at the RPC histogram data
3686 [ "$PPR" == "pages" ] && have_ppr=true && continue
3687 $have_ppr || continue
3689 # we only want the percent stat for < 16 pages
3690 [[ $(echo $PPR | tr -d ':') -ge $pages ]] && break
3692 percent=$((percent + WPCT))
3693 if [[ $percent -gt 15 ]]; then
3694 error "less than 16-pages write RPCs" \
3701 run_test 42e "verify sub-RPC writes are not done synchronously"
3704 test_mkdir -p $DIR/$tdir
3705 cp -p /bin/ls $DIR/$tdir/$tfile
3706 $MULTIOP $DIR/$tdir/$tfile Ow_c &
3708 # give multiop a chance to open
3711 $DIR/$tdir/$tfile && error || true
3714 run_test 43 "execution of file opened for write should return -ETXTBSY"
3717 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3718 test_mkdir -p $DIR/$tdir
3719 cp -p `which $MULTIOP` $DIR/$tdir/multiop ||
3720 cp -p multiop $DIR/$tdir/multiop
3721 MULTIOP_PROG=$DIR/$tdir/multiop multiop_bg_pause $TMP/$tfile.junk O_c ||
3724 $MULTIOP $DIR/$tdir/multiop Oc && error "expected error, got success"
3725 kill -USR1 $MULTIOP_PID || return 2
3726 wait $MULTIOP_PID || return 3
3727 rm $TMP/$tfile.junk $DIR/$tdir/multiop
3729 run_test 43a "open(RDWR) of file being executed should return -ETXTBSY"
3732 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3733 test_mkdir -p $DIR/$tdir
3734 cp -p `which $MULTIOP` $DIR/$tdir/multiop ||
3735 cp -p multiop $DIR/$tdir/multiop
3736 MULTIOP_PROG=$DIR/$tdir/multiop multiop_bg_pause $TMP/$tfile.junk O_c ||
3739 $TRUNCATE $DIR/$tdir/multiop 0 && error "expected error, got success"
3740 kill -USR1 $MULTIOP_PID || return 2
3741 wait $MULTIOP_PID || return 3
3742 rm $TMP/$tfile.junk $DIR/$tdir/multiop
3744 run_test 43b "truncate of file being executed should return -ETXTBSY"
3747 local testdir="$DIR/$tdir"
3748 test_mkdir -p $DIR/$tdir
3750 ( cd $(dirname $SHELL) && md5sum $(basename $SHELL) ) | \
3751 ( cd $testdir && md5sum -c)
3753 run_test 43c "md5sum of copy into lustre========================"
3756 [[ $OSTCOUNT -lt 2 ]] && skip_env "skipping 2-stripe test" && return
3757 dd if=/dev/zero of=$DIR/f1 bs=4k count=1 seek=1023
3758 dd if=$DIR/f1 bs=4k count=1 > /dev/null
3760 run_test 44 "zero length read from a sparse stripe ============="
3763 local nstripe=$($LCTL lov_getconfig $DIR | grep default_stripe_count: |
3765 [ -z "$nstripe" ] && skip "can't get stripe info" && return
3766 [[ $nstripe -gt $OSTCOUNT ]] &&
3767 skip "Wrong default_stripe_count: $nstripe (OSTCOUNT: $OSTCOUNT)" &&
3769 local stride=$($LCTL lov_getconfig $DIR | grep default_stripe_size: |
3771 if [[ $nstripe -eq 0 || $nstripe -eq -1 ]]; then
3772 nstripe=$($LCTL lov_getconfig $DIR | grep obd_count: |
3776 OFFSETS="0 $((stride/2)) $((stride-1))"
3777 for offset in $OFFSETS; do
3778 for i in $(seq 0 $((nstripe-1))); do
3779 local GLOBALOFFSETS=""
3781 local size=$((((i + 2 * $nstripe )*$stride + $offset)))
3782 local myfn=$DIR/d44a-$size
3783 echo "--------writing $myfn at $size"
3784 ll_sparseness_write $myfn $size ||
3785 error "ll_sparseness_write"
3786 GLOBALOFFSETS="$GLOBALOFFSETS $size"
3787 ll_sparseness_verify $myfn $GLOBALOFFSETS ||
3788 error "ll_sparseness_verify $GLOBALOFFSETS"
3790 for j in $(seq 0 $((nstripe-1))); do
3792 size=$((((j + $nstripe )*$stride + $offset)))
3793 ll_sparseness_write $myfn $size ||
3794 error "ll_sparseness_write"
3795 GLOBALOFFSETS="$GLOBALOFFSETS $size"
3797 ll_sparseness_verify $myfn $GLOBALOFFSETS ||
3798 error "ll_sparseness_verify $GLOBALOFFSETS"
3803 run_test 44a "test sparse pwrite ==============================="
3807 for d in `lctl get_param -n osc.*.cur_dirty_bytes`; do
3813 before=`dirty_osc_total`
3814 echo executing "\"$*\""
3816 after=`dirty_osc_total`
3817 echo before $before, after $after
3820 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3822 # Obtain grants from OST if it supports it
3823 echo blah > ${f}_grant
3826 do_dirty_record "echo blah > $f"
3827 [[ $before -eq $after ]] && error "write wasn't cached"
3828 do_dirty_record "> $f"
3829 [[ $before -gt $after ]] || error "truncate didn't lower dirty count"
3830 do_dirty_record "echo blah > $f"
3831 [[ $before -eq $after ]] && error "write wasn't cached"
3832 do_dirty_record "sync"
3833 [[ $before -gt $after ]] || error "writeback didn't lower dirty count"
3834 do_dirty_record "echo blah > $f"
3835 [[ $before -eq $after ]] && error "write wasn't cached"
3836 do_dirty_record "cancel_lru_locks osc"
3837 [[ $before -gt $after ]] ||
3838 error "lock cancellation didn't lower dirty count"
3841 run_test 45 "osc io page accounting ============================"
3843 # in a 2 stripe file (lov.sh), page 1023 maps to page 511 in its object. this
3844 # test tickles a bug where re-dirtying a page was failing to be mapped to the
3845 # objects offset and an assert hit when an rpc was built with 1023's mapped
3846 # offset 511 and 511's raw 511 offset. it also found general redirtying bugs.
3848 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3852 dd if=/dev/zero of=$f bs=`page_size` seek=511 count=1
3854 dd conv=notrunc if=/dev/zero of=$f bs=`page_size` seek=1023 count=1
3855 dd conv=notrunc if=/dev/zero of=$f bs=`page_size` seek=511 count=1
3859 run_test 46 "dirtying a previously written page ================"
3861 # test_47 is removed "Device nodes check" is moved to test_28
3863 test_48a() { # bug 2399
3864 [ $(facet_fstype $SINGLEMDS) = "zfs" ] &&
3865 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.3.63) ] &&
3866 skip "MDS prior to 2.3.63 handle ZFS dir .. incorrectly" &&
3868 test_mkdir $DIR/$tdir
3870 mv $DIR/$tdir $DIR/$tdir.new || error "move directory failed"
3871 test_mkdir $DIR/$tdir || error "recreate directory failed"
3872 touch foo || error "'touch foo' failed after recreating cwd"
3873 test_mkdir bar || error "'mkdir foo' failed after recreating cwd"
3874 touch .foo || error "'touch .foo' failed after recreating cwd"
3875 test_mkdir .bar || error "'mkdir .foo' failed after recreating cwd"
3876 ls . > /dev/null || error "'ls .' failed after recreating cwd"
3877 ls .. > /dev/null || error "'ls ..' failed after removing cwd"
3878 cd . || error "'cd .' failed after recreating cwd"
3879 test_mkdir . && error "'mkdir .' worked after recreating cwd"
3880 rmdir . && error "'rmdir .' worked after recreating cwd"
3881 ln -s . baz || error "'ln -s .' failed after recreating cwd"
3882 cd .. || error "'cd ..' failed after recreating cwd"
3884 run_test 48a "Access renamed working dir (should return errors)="
3886 test_48b() { # bug 2399
3888 test_mkdir $DIR/$tdir
3890 rmdir $DIR/$tdir || error "remove cwd $DIR/$tdir failed"
3891 touch foo && error "'touch foo' worked after removing cwd"
3892 test_mkdir foo && error "'mkdir foo' worked after removing cwd"
3893 touch .foo && error "'touch .foo' worked after removing cwd"
3894 test_mkdir .foo && error "'mkdir .foo' worked after removing cwd"
3895 ls . > /dev/null && error "'ls .' worked after removing cwd"
3896 ls .. > /dev/null || error "'ls ..' failed after removing cwd"
3897 is_patchless || ( cd . && error "'cd .' worked after removing cwd" )
3898 test_mkdir . && error "'mkdir .' worked after removing cwd"
3899 rmdir . && error "'rmdir .' worked after removing cwd"
3900 ln -s . foo && error "'ln -s .' worked after removing cwd"
3901 cd .. || echo "'cd ..' failed after removing cwd `pwd`" #bug 3517
3903 run_test 48b "Access removed working dir (should return errors)="
3905 test_48c() { # bug 2350
3906 #lctl set_param debug=-1
3909 test_mkdir -p $DIR/$tdir/dir
3911 $TRACE rmdir $DIR/$tdir/dir || error "remove cwd $DIR/$tdir/dir failed"
3912 $TRACE touch foo && error "touch foo worked after removing cwd"
3913 $TRACE test_mkdir foo && error "'mkdir foo' worked after removing cwd"
3914 touch .foo && error "touch .foo worked after removing cwd"
3915 test_mkdir .foo && error "mkdir .foo worked after removing cwd"
3916 $TRACE ls . && error "'ls .' worked after removing cwd"
3917 $TRACE ls .. || error "'ls ..' failed after removing cwd"
3918 is_patchless || ( $TRACE cd . &&
3919 error "'cd .' worked after removing cwd" )
3920 $TRACE test_mkdir . && error "'mkdir .' worked after removing cwd"
3921 $TRACE rmdir . && error "'rmdir .' worked after removing cwd"
3922 $TRACE ln -s . foo && error "'ln -s .' worked after removing cwd"
3923 $TRACE cd .. || echo "'cd ..' failed after removing cwd `pwd`" #bug 3415
3925 run_test 48c "Access removed working subdir (should return errors)"
3927 test_48d() { # bug 2350
3928 #lctl set_param debug=-1
3931 test_mkdir -p $DIR/$tdir/dir
3933 $TRACE rmdir $DIR/$tdir/dir || error "remove cwd $DIR/$tdir/dir failed"
3934 $TRACE rmdir $DIR/$tdir || error "remove parent $DIR/$tdir failed"
3935 $TRACE touch foo && error "'touch foo' worked after removing parent"
3936 $TRACE test_mkdir foo && error "mkdir foo worked after removing parent"
3937 touch .foo && error "'touch .foo' worked after removing parent"