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 230d"
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
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"
358 run_test 15 "touch .../d15/f; mv .../d15/f .../d15/f2 =========="
361 test_mkdir $DIR/$tdir
362 touch $DIR/$tdir/$tfile
363 rm -rf $DIR/$tdir/$tfile
364 $CHECKSTAT -a $DIR/$tdir/$tfile || error "$tdir/$tfile not removed"
366 run_test 16 "touch .../d16/f; rm -rf .../d16/f ================="
369 test_mkdir -p $DIR/$tdir
370 touch $DIR/$tdir/$tfile
371 ln -s $DIR/$tdir/$tfile $DIR/$tdir/l-exist
373 $CHECKSTAT -l $DIR/$tdir/$tfile $DIR/$tdir/l-exist ||
374 error "$tdir/l-exist not a symlink"
375 $CHECKSTAT -f -t f $DIR/$tdir/l-exist ||
376 error "$tdir/l-exist not referencing a file"
377 rm -f $DIR/$tdir/l-exist
378 $CHECKSTAT -a $DIR/$tdir/l-exist || error "$tdir/l-exist not removed"
380 run_test 17a "symlinks: create, remove (real) =================="
383 test_mkdir -p $DIR/$tdir
384 ln -s no-such-file $DIR/$tdir/l-dangle
386 $CHECKSTAT -l no-such-file $DIR/$tdir/l-dangle ||
387 error "$tdir/l-dangle not referencing no-such-file"
388 $CHECKSTAT -fa $DIR/$tdir/l-dangle ||
389 error "$tdir/l-dangle not referencing non-existent file"
390 rm -f $DIR/$tdir/l-dangle
391 $CHECKSTAT -a $DIR/$tdir/l-dangle || error "$tdir/l-dangle not removed"
393 run_test 17b "symlinks: create, remove (dangling) =============="
395 test_17c() { # bug 3440 - don't save failed open RPC for replay
396 test_mkdir -p $DIR/$tdir
397 ln -s foo $DIR/$tdir/$tfile
398 cat $DIR/$tdir/$tfile && error "opened non-existent symlink" || true
400 run_test 17c "symlinks: open dangling (should return error) ===="
403 test_mkdir -p $DIR/$tdir
404 ln -s foo $DIR/$tdir/$tfile
405 touch $DIR/$tdir/$tfile || error "creating to new symlink"
407 run_test 17d "symlinks: create dangling ========================"
410 test_mkdir -p $DIR/$tdir
411 local foo=$DIR/$tdir/$tfile
412 ln -s $foo $foo || error "create symlink failed"
413 ls -l $foo || error "ls -l failed"
414 ls $foo && error "ls not failed" || true
416 run_test 17e "symlinks: create recursive symlink (should return error) ===="
419 test_mkdir -p $DIR/$tdir
420 ln -s 1234567890/2234567890/3234567890/4234567890 $DIR/$tdir/111
421 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890 $DIR/$tdir/222
422 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890 $DIR/$tdir/333
423 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890/9234567890/a234567890/b234567890 $DIR/$tdir/444
424 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890/9234567890/a234567890/b234567890/c234567890/d234567890/f234567890 $DIR/$tdir/555
425 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
428 run_test 17f "symlinks: long and very long symlink name ========================"
430 # str_repeat(S, N) generate a string that is string S repeated N times
435 while [ $((n -= 1)) -ge 0 ]; do
441 # Long symlinks and LU-2241
443 test_mkdir -p $DIR/$tdir
444 local TESTS="59 60 61 4094 4095"
446 # Fix for inode size boundary in 2.1.4
447 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.1.4) ] &&
450 # Patch not applied to 2.2 or 2.3 branches
451 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] &&
452 [ $(lustre_version_code $SINGLEMDS) -le $(version_code 2.3.55) ] &&
455 # skip long symlink name for rhel6.5.
456 # rhel6.5 has a limit (PATH_MAX - sizeof(struct filename))
457 grep -q '6.5' /etc/redhat-release &>/dev/null &&
458 TESTS="59 60 61 4062 4063"
461 local SYMNAME=$(str_repeat 'x' $i)
462 ln -s $SYMNAME $DIR/$tdir/f$i || error "failed $i-char symlink"
463 readlink $DIR/$tdir/f$i || error "failed $i-char readlink"
466 run_test 17g "symlinks: really long symlink name and inode boundaries"
468 test_17h() { #bug 17378
469 remote_mds_nodsh && skip "remote MDS with nodsh" && return
470 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
472 test_mkdir -p $DIR/$tdir
473 if [[ $MDSCOUNT -gt 1 ]]; then
474 mdt_idx=$($LFS getdirstripe -i $DIR/$tdir)
478 $SETSTRIPE -c -1 $DIR/$tdir
479 #define OBD_FAIL_MDS_LOV_PREP_CREATE 0x141
480 do_facet mds$((mdt_idx + 1)) lctl set_param fail_loc=0x80000141
481 touch $DIR/$tdir/$tfile || true
483 run_test 17h "create objects: lov_free_memmd() doesn't lbug"
485 test_17i() { #bug 20018
486 remote_mds_nodsh && skip "remote MDS with nodsh" && return
487 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
488 test_mkdir -c1 $DIR/$tdir
489 local foo=$DIR/$tdir/$tfile
491 if [[ $MDSCOUNT -gt 1 ]]; then
492 mdt_idx=$($LFS getdirstripe -i $DIR/$tdir)
496 ln -s $foo $foo || error "create symlink failed"
497 #define OBD_FAIL_MDS_READLINK_EPROTO 0x143
498 do_facet mds$((mdt_idx + 1)) lctl set_param fail_loc=0x80000143
499 ls -l $foo && error "error not detected"
502 run_test 17i "don't panic on short symlink"
504 test_17k() { #bug 22301
505 [[ -z "$(which rsync 2>/dev/null)" ]] &&
506 skip "no rsync command" && return 0
507 rsync --help | grep -q xattr ||
508 skip_env "$(rsync --version | head -n1) does not support xattrs"
509 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return 0
510 test_mkdir -p $DIR/$tdir
511 test_mkdir -p $DIR/$tdir.new
512 touch $DIR/$tdir/$tfile
513 ln -s $DIR/$tdir/$tfile $DIR/$tdir/$tfile.lnk
514 rsync -av -X $DIR/$tdir/ $DIR/$tdir.new ||
515 error "rsync failed with xattrs enabled"
517 run_test 17k "symlinks: rsync with xattrs enabled ========================="
519 test_17l() { # LU-279
520 [[ -z "$(which getfattr 2>/dev/null)" ]] &&
521 skip "no getfattr command" && return 0
523 touch $DIR/$tdir/$tfile
524 ln -s $DIR/$tdir/$tfile $DIR/$tdir/$tfile.lnk
525 for path in "$DIR/$tdir" "$DIR/$tdir/$tfile" "$DIR/$tdir/$tfile.lnk"; do
526 # -h to not follow symlinks. -m '' to list all the xattrs.
527 # grep to remove first line: '# file: $path'.
528 for xattr in `getfattr -hm '' $path 2>/dev/null | grep -v '^#'`;
530 lgetxattr_size_check $path $xattr ||
531 error "lgetxattr_size_check $path $xattr failed"
535 run_test 17l "Ensure lgetxattr's returned xattr size is consistent ========"
539 local short_sym="0123456789"
540 local WDIR=$DIR/${tdir}m
547 remote_mds_nodsh && skip "remote MDS with nodsh" && return
548 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] &&
549 [ $(lustre_version_code $SINGLEMDS) -le $(version_code 2.2.93) ] &&
550 skip "MDS 2.2.0-2.2.93 do not NUL-terminate symlinks" && return
552 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
553 skip "only for ldiskfs MDT" && return 0
555 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
559 # create a long symlink file
560 for ((i = 0; i < 4; ++i)); do
561 long_sym=${long_sym}${long_sym}
564 echo "create 512 short and long symlink files under $WDIR"
565 for ((i = 0; i < 256; ++i)); do
566 ln -sf ${long_sym}"a5a5" $WDIR/long-$i
567 ln -sf ${short_sym}"a5a5" $WDIR/short-$i
573 wait_delete_completed
575 echo "recreate the 512 symlink files with a shorter string"
576 for ((i = 0; i < 512; ++i)); do
577 # rewrite the symlink file with a shorter string
578 ln -sf ${long_sym} $WDIR/long-$i
579 ln -sf ${short_sym} $WDIR/short-$i
582 mds_index=$($LFS getstripe -M $WDIR)
583 mds_index=$((mds_index+1))
584 devname=$(mdsdevname $mds_index)
585 cmd="$E2FSCK -fnvd $devname"
587 echo "stop and checking mds${mds_index}: $cmd"
588 # e2fsck should not return error
590 do_facet mds${mds_index} $cmd || rc=$?
592 start mds${mds_index} $devname $MDS_MOUNT_OPTS || error "start failed"
593 df $MOUNT > /dev/null 2>&1
594 [ $rc -ne 0 ] && error "e2fsck should not report error upon "\
595 "short/long symlink MDT: rc=$rc"
598 run_test 17m "run e2fsck against MDT which contains short/long symlink"
600 check_fs_consistency_17n() {
606 # create/unlink in 17n only change 2 MDTs(MDT1/MDT2),
607 # so it only check MDT1/MDT2 instead of all of MDTs.
608 for mdt_index in $(seq 1 2); do
609 devname=$(mdsdevname $mdt_index)
610 cmd="$E2FSCK -fnvd $devname"
612 echo "stop and checking mds${mdt_index}: $cmd"
613 # e2fsck should not return error
615 do_facet mds${mdt_index} $cmd || rc=$?
617 start mds${mdt_index} $devname $MDS_MOUNT_OPTS ||
618 error "mount mds${mdt_index} failed"
619 df $MOUNT > /dev/null 2>&1
620 [ $rc -ne 0 ] && break
628 remote_mds_nodsh && skip "remote MDS with nodsh" && return
629 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] &&
630 [ $(lustre_version_code $SINGLEMDS) -le $(version_code 2.2.93) ] &&
631 skip "MDS 2.2.0-2.2.93 do not NUL-terminate symlinks" && return
633 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
634 skip "only for ldiskfs MDT" && return 0
636 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 2 MDTs" && return
638 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
641 for ((i=0; i<10; i++)); do
642 $LFS mkdir -i1 -c2 $DIR/$tdir/remote_dir_${i} ||
643 error "create remote dir error $i"
644 createmany -o $DIR/$tdir/remote_dir_${i}/f 10 ||
645 error "create files under remote dir failed $i"
648 check_fs_consistency_17n ||
649 error "e2fsck report error after create files under remote dir"
651 for ((i = 0; i < 10; i++)); do
652 rm -rf $DIR/$tdir/remote_dir_${i} ||
653 error "destroy remote dir error $i"
656 check_fs_consistency_17n ||
657 error "e2fsck report error after unlink files under remote dir"
659 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.50) ] &&
660 skip "lustre < 2.4.50 does not support migrate mv " && return
662 for ((i = 0; i < 10; i++)); do
663 mkdir -p $DIR/$tdir/remote_dir_${i}
664 createmany -o $DIR/$tdir/remote_dir_${i}/f 10 ||
665 error "create files under remote dir failed $i"
666 $LFS mv --mdt-index 1 $DIR/$tdir/remote_dir_${i} ||
667 error "migrate remote dir error $i"
669 check_fs_consistency_17n || error "e2fsck report error after migration"
671 for ((i = 0; i < 10; i++)); do
672 rm -rf $DIR/$tdir/remote_dir_${i} ||
673 error "destroy remote dir error $i"
676 check_fs_consistency_17n || error "e2fsck report error after unlink"
678 run_test 17n "run e2fsck against master/slave MDT which contains remote dir"
681 remote_mds_nodsh && skip "remote MDS with nodsh" && return
682 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.3.64) ] &&
683 skip "Need MDS version at least 2.3.64" && return
685 local WDIR=$DIR/${tdir}o
691 mdt_index=$($LFS getstripe -M $WDIR)
692 mdt_index=$((mdt_index+1))
693 mdtdevname=$(mdsdevname $mdt_index)
697 start mds${mdt_index} $mdtdevname $MDS_MOUNT_OPTS ||
698 error "mount mds${mdt_index} failed"
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
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
1088 $LFS mkdir -i $MDTIDX $remote_dir ||
1089 error "create remote directory failed"
1091 mkdir -p $DIR/$tdir/src_dir
1092 touch $DIR/$tdir/src_file
1093 mkdir -p $remote_dir/tgt_dir
1094 touch $remote_dir/tgt_file
1096 mrename $remote_dir $DIR/ &&
1097 error "rename dir cross MDT works!"
1099 mrename $DIR/$tdir/src_dir $remote_dir/tgt_dir &&
1100 error "rename dir cross MDT works!"
1102 mrename $DIR/$tdir/src_file $remote_dir/tgt_file &&
1103 error "rename file cross MDT works!"
1105 ln $DIR/$tdir/src_file $remote_dir/tgt_file1 &&
1106 error "ln file cross MDT should not work!"
1108 rm -rf $DIR/$tdir || error "Can not delete directories"
1110 run_test 24x "cross rename/link should be failed"
1113 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 2 MDTs" && return
1114 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1116 local remote_dir=$DIR/$tdir/remote_dir
1119 $LFS mkdir -i $MDTIDX $remote_dir ||
1120 error "create remote directory failed"
1122 mkdir -p $remote_dir/src_dir
1123 touch $remote_dir/src_file
1124 mkdir -p $remote_dir/tgt_dir
1125 touch $remote_dir/tgt_file
1127 mrename $remote_dir/src_dir $remote_dir/tgt_dir ||
1128 error "rename subdir in the same remote dir failed!"
1130 mrename $remote_dir/src_file $remote_dir/tgt_file ||
1131 error "rename files in the same remote dir failed!"
1133 ln $remote_dir/tgt_file $remote_dir/tgt_file1 ||
1134 error "link files in the same remote dir failed!"
1136 rm -rf $DIR/$tdir || error "Can not delete directories"
1138 run_test 24y "rename/link on the same dir should succeed"
1141 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 2 MDTs" && return
1142 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1144 local remote_src=$DIR/$tdir/remote_dir
1145 local remote_tgt=$DIR/$tdir/remote_tgt
1148 $LFS mkdir -i $MDTIDX $remote_src ||
1149 error "create remote directory failed"
1151 $LFS mkdir -i $MDTIDX $remote_tgt ||
1152 error "create remote directory failed"
1154 mrename $remote_src $remote_tgt &&
1155 error "rename remote dirs should not work!"
1157 # If target dir does not exists, it should succeed
1159 mrename $remote_src $remote_tgt ||
1160 error "rename remote dirs(tgt dir does not exists) failed!"
1162 rm -rf $DIR/$tdir || error "Can not delete directories"
1164 run_test 24z "rename one remote dir to another remote dir should fail"
1166 test_24A() { # LU-3182
1171 createmany -m $DIR/$tdir/$tfile $NFILES
1172 local t=$(ls $DIR/$tdir | wc -l)
1173 local u=$(ls $DIR/$tdir | sort -u | wc -l)
1174 local v=$(ls -ai $DIR/$tdir | sort -u | wc -l)
1175 if [ $t -ne $NFILES -o $u -ne $NFILES -o $v -ne $((NFILES + 2)) ] ; then
1176 error "Expected $NFILES files, got $t ($u unique $v .&..)"
1179 rm -rf $DIR/$tdir || error "Can not delete directories"
1181 run_test 24A "readdir() returns correct number of entries."
1183 test_24B() { # LU-4805
1184 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
1188 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR/$tdir/striped_dir ||
1189 error "create striped dir failed"
1191 count=$(ls -ai $DIR/$tdir/striped_dir | wc -l)
1192 [ $count -eq 2 ] || error "Expected 2, got $count"
1194 touch $DIR/$tdir/striped_dir/a
1196 count=$(ls -ai $DIR/$tdir/striped_dir | wc -l)
1197 [ $count -eq 3 ] || error "Expected 3, got $count"
1199 touch $DIR/$tdir/striped_dir/.f
1201 count=$(ls -ai $DIR/$tdir/striped_dir | wc -l)
1202 [ $count -eq 4 ] || error "Expected 4, got $count"
1204 rm -rf $DIR/$tdir || error "Can not delete directories"
1206 run_test 24B "readdir for striped dir return correct number of entries"
1209 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
1215 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR/$tdir/d0/striped_dir ||
1216 error "create striped dir failed"
1218 cd $DIR/$tdir/d0/striped_dir
1220 local d0_ino=$(ls -i -l -a $DIR/$tdir | grep "d0" | awk '{print $1}')
1221 local d1_ino=$(ls -i -l -a $DIR/$tdir | grep "d1" | awk '{print $1}')
1222 local parent_ino=$(ls -i -l -a | grep "\.\." | awk '{print $1}')
1224 [ "$d0_ino" = "$parent_ino" ] ||
1225 error ".. wrong, expect $d0_ino, get $parent_ino"
1227 mv $DIR/$tdir/d0/striped_dir $DIR/$tdir/d1/ ||
1228 error "mv striped dir failed"
1230 parent_ino=$(ls -i -l -a | grep "\.\." | awk '{print $1}')
1232 [ "$d1_ino" = "$parent_ino" ] ||
1233 error ".. wrong after mv, expect $d1_ino, get $parent_ino"
1235 run_test 24C "check .. in striped dir"
1237 test_24D() { # LU-6101
1242 createmany -m $DIR/$tdir/$tfile $NFILES
1243 local t=$(ls $DIR/$tdir | wc -l)
1244 local u=$(ls $DIR/$tdir | sort -u | wc -l)
1245 local v=$(ls -ai $DIR/$tdir | sort -u | wc -l)
1246 if [ $t -ne $NFILES -o $u -ne $NFILES -o $v -ne $((NFILES + 2)) ] ; then
1247 error "Expected $NFILES files, got $t ($u unique $v .&..)"
1250 rm -rf $DIR/$tdir || error "Can not delete directories"
1252 run_test 24D "readdir() returns correct number of entries after cursor reload"
1255 echo '== symlink sanity ============================================='
1259 touch $DIR/s25/foo || error
1261 run_test 25a "create file in symlinked directory ==============="
1264 [ ! -d $DIR/d25 ] && test_25a
1265 $CHECKSTAT -t file $DIR/s25/foo || error
1267 run_test 25b "lookup file in symlinked directory ==============="
1271 test_mkdir $DIR/d26/d26-2
1272 ln -s d26/d26-2 $DIR/s26
1273 touch $DIR/s26/foo || error
1275 run_test 26a "multiple component symlink ======================="
1278 test_mkdir -p $DIR/d26b/d26-2
1279 ln -s d26b/d26-2/foo $DIR/s26-2
1280 touch $DIR/s26-2 || error
1282 run_test 26b "multiple component symlink at end of lookup ======"
1285 test_mkdir $DIR/d26.2
1286 touch $DIR/d26.2/foo
1287 ln -s d26.2 $DIR/s26.2-1
1288 ln -s s26.2-1 $DIR/s26.2-2
1289 ln -s s26.2-2 $DIR/s26.2-3
1290 chmod 0666 $DIR/s26.2-3/foo
1292 run_test 26c "chain of symlinks ================================"
1294 # recursive symlinks (bug 439)
1296 ln -s d26-3/foo $DIR/d26-3
1298 run_test 26d "create multiple component recursive symlink ======"
1301 [ ! -h $DIR/d26-3 ] && test_26d
1304 run_test 26e "unlink multiple component recursive symlink ======"
1306 # recursive symlinks (bug 7022)
1308 test_mkdir -p $DIR/$tdir
1309 test_mkdir $DIR/$tdir/$tfile || error "mkdir $DIR/$tdir/$tfile failed"
1310 cd $DIR/$tdir/$tfile || error "cd $DIR/$tdir/$tfile failed"
1311 test_mkdir -p lndir/bar1 || error "mkdir lndir/bar1 failed"
1312 test_mkdir $DIR/$tdir/$tfile/$tfile || error "mkdir $tfile failed"
1313 cd $tfile || error "cd $tfile failed"
1314 ln -s .. dotdot || error "ln dotdot failed"
1315 ln -s dotdot/lndir lndir || error "ln lndir failed"
1316 cd $DIR/$tdir || error "cd $DIR/$tdir failed"
1317 output=`ls $tfile/$tfile/lndir/bar1`
1318 [ "$output" = bar1 ] && error "unexpected output"
1319 rm -r $tfile || error "rm $tfile failed"
1320 $CHECKSTAT -a $DIR/$tfile || error "$tfile not gone"
1322 run_test 26f "rm -r of a directory which has recursive symlink ="
1325 echo '== stripe sanity =============================================='
1326 test_mkdir -p $DIR/d27 || error "mkdir failed"
1328 $SETSTRIPE -c 1 $DIR/d27/f0 || error "setstripe failed"
1329 $CHECKSTAT -t file $DIR/d27/f0 || error "checkstat failed"
1330 log "== test_27a: write to one stripe file ========================="
1331 cp /etc/hosts $DIR/d27/f0 || error
1333 run_test 27a "one stripe file =================================="
1336 [[ $OSTCOUNT -lt 2 ]] && skip_env "skipping 2-stripe test" && return
1337 test_mkdir -p $DIR/d27
1338 $SETSTRIPE -c 2 $DIR/d27/f01 || error "setstripe failed"
1339 $GETSTRIPE -c $DIR/d27/f01
1340 [ $($GETSTRIPE -c $DIR/d27/f01) -eq 2 ] ||
1341 error "two-stripe file doesn't have two stripes"
1343 dd if=/dev/zero of=$DIR/d27/f01 bs=4k count=4 || error "dd failed"
1345 run_test 27b "create and write to two stripe file"
1348 test_mkdir -p $DIR/d27
1349 $SETSTRIPE -c 0 -i -1 -S 0 $DIR/d27/fdef || error "setstripe failed"
1350 $CHECKSTAT -t file $DIR/d27/fdef || error "checkstat failed"
1351 dd if=/dev/zero of=$DIR/d27/fdef bs=4k count=4 || error
1353 run_test 27d "create file with default settings ================"
1356 test_mkdir -p $DIR/d27
1357 $SETSTRIPE -c 2 $DIR/d27/f12 || error "setstripe failed"
1358 $SETSTRIPE -c 2 $DIR/d27/f12 && error "setstripe succeeded twice"
1359 $CHECKSTAT -t file $DIR/d27/f12 || error "checkstat failed"
1361 run_test 27e "setstripe existing file (should return error) ======"
1364 test_mkdir $DIR/$tdir
1365 $SETSTRIPE -S 100 -i 0 -c 1 $DIR/$tdir/$tfile &&
1366 error "$SETSTRIPE $DIR/$tdir/$tfile failed"
1367 $CHECKSTAT -t file $DIR/$tdir/$tfile &&
1368 error "$CHECKSTAT -t file $DIR/$tdir/$tfile should fail"
1369 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=4k count=4 || error "dd failed"
1370 $GETSTRIPE $DIR/$tdir/$tfile || error "$GETSTRIPE failed"
1372 run_test 27f "setstripe with bad stripe size (should return error)"
1375 test_mkdir -p $DIR/d27
1376 $MCREATE $DIR/d27/fnone || error "mcreate failed"
1377 $GETSTRIPE $DIR/d27/fnone 2>&1 | grep "no stripe info" ||
1378 error "$DIR/d27/fnone has object"
1380 run_test 27g "$GETSTRIPE with no objects"
1383 test_mkdir $DIR/$tdir
1384 touch $DIR/$tdir/$tfile || error "touch failed"
1385 [[ $($GETSTRIPE -c $DIR/$tdir/$tfile) -gt 0 ]] ||
1386 error "missing objects"
1388 run_test 27i "$GETSTRIPE with some objects"
1391 test_mkdir -p $DIR/d27
1392 $SETSTRIPE -i $OSTCOUNT $DIR/d27/f27j && error "setstripe failed"||true
1394 run_test 27j "setstripe with bad stripe offset (should return error)"
1396 test_27k() { # bug 2844
1397 test_mkdir -p $DIR/d27
1399 LL_MAX_BLKSIZE=$((4 * 1024 * 1024))
1400 [ ! -d $DIR/d27 ] && test_mkdir -p $DIR d27
1401 $SETSTRIPE -S 67108864 $FILE || error "setstripe failed"
1402 BLKSIZE=`stat $FILE | awk '/IO Block:/ { print $7 }'`
1403 [ $BLKSIZE -le $LL_MAX_BLKSIZE ] || error "1:$BLKSIZE > $LL_MAX_BLKSIZE"
1404 dd if=/dev/zero of=$FILE bs=4k count=1
1405 BLKSIZE=`stat $FILE | awk '/IO Block:/ { print $7 }'`
1406 [ $BLKSIZE -le $LL_MAX_BLKSIZE ] || error "2:$BLKSIZE > $LL_MAX_BLKSIZE"
1408 run_test 27k "limit i_blksize for broken user apps ============="
1411 test_mkdir -p $DIR/d27
1412 mcreate $DIR/f27l || error "creating file"
1413 $RUNAS $SETSTRIPE -c 1 $DIR/f27l && \
1414 error "setstripe should have failed" || true
1416 run_test 27l "check setstripe permissions (should return error)"
1419 [[ $OSTCOUNT -lt 2 ]] && skip_env "$OSTCOUNT < 2 OSTs -- skipping" &&
1421 if [[ $ORIGFREE -gt $MAXFREE ]]; then
1422 skip "$ORIGFREE > $MAXFREE skipping out-of-space test on OST0"
1425 trap simple_cleanup_common EXIT
1426 test_mkdir -p $DIR/$tdir
1427 $SETSTRIPE -i 0 -c 1 $DIR/$tdir/f27m_1
1428 dd if=/dev/zero of=$DIR/$tdir/f27m_1 bs=1024 count=$MAXFREE &&
1429 error "dd should fill OST0"
1431 while $SETSTRIPE -i 0 -c 1 $DIR/$tdir/f27m_$i; do
1433 [ $i -gt 256 ] && break
1436 touch $DIR/$tdir/f27m_$i
1437 [ `$GETSTRIPE $DIR/$tdir/f27m_$i | grep -A 10 obdidx | awk '{print $1}'| grep -w "0"` ] &&
1438 error "OST0 was full but new created file still use it"
1440 touch $DIR/$tdir/f27m_$i
1441 [ `$GETSTRIPE $DIR/$tdir/f27m_$i | grep -A 10 obdidx | awk '{print $1}'| grep -w "0"` ] &&
1442 error "OST0 was full but new created file still use it"
1443 simple_cleanup_common
1445 run_test 27m "create file while OST0 was full =================="
1448 local DELAY=$(do_facet $SINGLEMDS lctl get_param -n lov.*.qos_maxage | head -n 1 | awk '{print $1 * 2}')
1452 # OSCs keep a NOSPC flag that will be reset after ~5s (qos_maxage)
1453 # if the OST isn't full anymore.
1455 local OSTIDX=${1:-""}
1457 local list=$(comma_list $(osts_nodes))
1458 [ "$OSTIDX" ] && list=$(facet_host ost$((OSTIDX + 1)))
1460 do_nodes $list lctl set_param fail_loc=0
1461 sync # initiate all OST_DESTROYs from MDS to OST
1465 exhaust_precreations() {
1468 local FAILIDX=${3:-$OSTIDX}
1469 local ofacet=ost$((OSTIDX + 1))
1471 test_mkdir -p -c1 $DIR/$tdir
1472 local mdtidx=$($LFS getstripe -M $DIR/$tdir)
1473 local mfacet=mds$((mdtidx + 1))
1474 echo OSTIDX=$OSTIDX MDTIDX=$mdtidx
1476 local OST=$(ostname_from_index $OSTIDX)
1479 local mdtosc_proc1=$(get_mdtosc_proc_path $mfacet $OST)
1480 local last_id=$(do_facet $mfacet lctl get_param -n \
1481 osc.$mdtosc_proc1.prealloc_last_id)
1482 local next_id=$(do_facet $mfacet lctl get_param -n \
1483 osc.$mdtosc_proc1.prealloc_next_id)
1485 local mdtosc_proc2=$(get_mdtosc_proc_path $mfacet)
1486 do_facet $mfacet lctl get_param osc.$mdtosc_proc2.prealloc*
1488 test_mkdir -p $DIR/$tdir/${OST}
1489 $SETSTRIPE -i $OSTIDX -c 1 $DIR/$tdir/${OST}
1490 #define OBD_FAIL_OST_ENOSPC 0x215
1491 do_facet $ofacet lctl set_param fail_val=$FAILIDX fail_loc=0x215
1492 echo "Creating to objid $last_id on ost $OST..."
1493 createmany -o $DIR/$tdir/${OST}/f $next_id $((last_id - next_id + 2))
1494 do_facet $mfacet lctl get_param osc.$mdtosc_proc2.prealloc*
1495 do_facet $ofacet lctl set_param fail_loc=$FAILLOC
1499 exhaust_all_precreations() {
1501 for (( i=0; i < OSTCOUNT; i++ )) ; do
1502 exhaust_precreations $i $1 -1
1507 [[ $OSTCOUNT -lt 2 ]] && skip_env "too few OSTs" && return
1508 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1509 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1510 remote_ost_nodsh && skip "remote OST with nodsh" && return
1513 rm -f $DIR/$tdir/$tfile
1514 exhaust_precreations 0 0x80000215
1515 $SETSTRIPE -c -1 $DIR/$tdir
1516 touch $DIR/$tdir/$tfile || error
1517 $GETSTRIPE $DIR/$tdir/$tfile
1520 run_test 27n "create file with some full OSTs =================="
1523 [[ $OSTCOUNT -lt 2 ]] && skip_env "too few OSTs" && return
1524 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1525 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1526 remote_ost_nodsh && skip "remote OST with nodsh" && return
1529 rm -f $DIR/$tdir/$tfile
1530 exhaust_all_precreations 0x215
1532 touch $DIR/$tdir/$tfile && error "able to create $DIR/$tdir/$tfile"
1537 run_test 27o "create file with all full OSTs (should error) ===="
1540 [[ $OSTCOUNT -lt 2 ]] && skip_env "too few OSTs" && return
1541 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1542 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1543 remote_ost_nodsh && skip "remote OST with nodsh" && return
1546 rm -f $DIR/$tdir/$tfile
1547 test_mkdir -p $DIR/$tdir
1549 $MCREATE $DIR/$tdir/$tfile || error "mcreate failed"
1550 $TRUNCATE $DIR/$tdir/$tfile 80000000 || error "truncate failed"
1551 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat failed"
1553 exhaust_precreations 0 0x80000215
1554 echo foo >> $DIR/$tdir/$tfile || error "append failed"
1555 $CHECKSTAT -s 80000004 $DIR/$tdir/$tfile || error "checkstat failed"
1556 $GETSTRIPE $DIR/$tdir/$tfile
1560 run_test 27p "append to a truncated file with some full OSTs ==="
1563 [[ $OSTCOUNT -lt 2 ]] && skip_env "too few OSTs" && return
1564 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1565 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1566 remote_ost_nodsh && skip "remote OST with nodsh" && return
1569 rm -f $DIR/$tdir/$tfile
1571 test_mkdir -p $DIR/$tdir
1572 $MCREATE $DIR/$tdir/$tfile || error "mcreate $DIR/$tdir/$tfile failed"
1573 $TRUNCATE $DIR/$tdir/$tfile 80000000 ||error "truncate $DIR/$tdir/$tfile failed"
1574 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat failed"
1576 exhaust_all_precreations 0x215
1578 echo foo >> $DIR/$tdir/$tfile && error "append succeeded"
1579 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat 2 failed"
1583 run_test 27q "append to truncated file with all OSTs full (should error) ==="
1586 [[ $OSTCOUNT -lt 2 ]] && skip_env "too few OSTs" && return
1587 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1588 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1589 remote_ost_nodsh && skip "remote OST with nodsh" && return
1592 rm -f $DIR/$tdir/$tfile
1593 exhaust_precreations 0 0x80000215
1595 $SETSTRIPE -i 0 -c 2 $DIR/$tdir/$tfile # && error
1599 run_test 27r "stripe file with some full OSTs (shouldn't LBUG) ="
1601 test_27s() { # bug 10725
1602 test_mkdir -p $DIR/$tdir
1603 local stripe_size=$((4096 * 1024 * 1024)) # 2^32
1604 local stripe_count=0
1605 [ $OSTCOUNT -eq 1 ] || stripe_count=2
1606 $SETSTRIPE -S $stripe_size -c $stripe_count $DIR/$tdir &&
1607 error "stripe width >= 2^32 succeeded" || true
1610 run_test 27s "lsm_xfersize overflow (should error) (bug 10725)"
1612 test_27t() { # bug 10864
1617 $WLFS getstripe $tfile
1620 run_test 27t "check that utils parse path correctly"
1622 test_27u() { # bug 4900
1623 [[ $OSTCOUNT -lt 2 ]] && skip_env "too few OSTs" && return
1624 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1626 local list=$(comma_list $(mdts_nodes))
1628 #define OBD_FAIL_MDS_OSC_PRECREATE 0x139
1629 do_nodes $list $LCTL set_param fail_loc=0x139
1630 test_mkdir -p $DIR/$tdir
1632 createmany -o $DIR/$tdir/t- 1000
1633 do_nodes $list $LCTL set_param fail_loc=0
1635 TLOG=$DIR/$tfile.getstripe
1636 $GETSTRIPE $DIR/$tdir > $TLOG
1637 OBJS=$(awk -vobj=0 '($1 == 0) { obj += 1 } END { print obj; }' $TLOG)
1638 unlinkmany $DIR/$tdir/t- 1000
1639 [[ $OBJS -gt 0 ]] &&
1640 error "$OBJS objects created on OST-0. See $TLOG" || pass
1642 run_test 27u "skip object creation on OSC w/o objects =========="
1644 test_27v() { # bug 4900
1645 [[ $OSTCOUNT -lt 2 ]] && skip_env "too few OSTs" && return
1646 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1647 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1648 remote_ost_nodsh && skip "remote OST with nodsh" && return
1650 exhaust_all_precreations 0x215
1653 test_mkdir -p $DIR/$tdir
1654 $SETSTRIPE -c 1 $DIR/$tdir # 1 stripe / file
1656 touch $DIR/$tdir/$tfile
1657 #define OBD_FAIL_TGT_DELAY_PRECREATE 0x705
1659 for (( i=1; i < OSTCOUNT; i++ )); do
1660 do_facet ost$i lctl set_param fail_loc=0x705
1662 local START=`date +%s`
1663 createmany -o $DIR/$tdir/$tfile 32
1665 local FINISH=`date +%s`
1666 local TIMEOUT=`lctl get_param -n timeout`
1667 local PROCESS=$((FINISH - START))
1668 [ $PROCESS -ge $((TIMEOUT / 2)) ] && \
1669 error "$FINISH - $START >= $TIMEOUT / 2"
1670 sleep $((TIMEOUT / 2 - PROCESS))
1673 run_test 27v "skip object creation on slow OST ================="
1675 test_27w() { # bug 10997
1676 test_mkdir -p $DIR/$tdir || error "mkdir failed"
1677 $SETSTRIPE -S 65536 $DIR/$tdir/f0 || error "setstripe failed"
1678 [ $($GETSTRIPE -S $DIR/$tdir/f0) -ne 65536 ] &&
1679 error "stripe size $size != 65536" || true
1680 [ $($GETSTRIPE -d $DIR/$tdir | grep -c "stripe_count") -ne 1 ] &&
1681 error "$GETSTRIPE -d $DIR/$tdir failed" || true
1683 run_test 27w "check $SETSTRIPE -S option"
1686 [[ $OSTCOUNT -lt 2 ]] &&
1687 skip_env "skipping multiple stripe count/offset test" && return
1689 test_mkdir -p $DIR/$tdir || error "mkdir failed"
1690 for i in $(seq 1 $OSTCOUNT); do
1692 $SETSTRIPE -c $i -i $offset $DIR/$tdir/f$i ||
1693 error "setstripe -c $i -i $offset failed"
1694 count=$($GETSTRIPE -c $DIR/$tdir/f$i)
1695 index=$($GETSTRIPE -i $DIR/$tdir/f$i)
1696 [ $count -ne $i ] && error "stripe count $count != $i" || true
1697 [ $index -ne $offset ] &&
1698 error "stripe offset $index != $offset" || true
1701 run_test 27wa "check $SETSTRIPE -c -i options"
1704 remote_ost_nodsh && skip "remote OST with nodsh" && return
1705 [[ $OSTCOUNT -lt 2 ]] && skip_env "$OSTCOUNT < 2 OSTs" && return
1706 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1707 OFFSET=$(($OSTCOUNT - 1))
1709 local OST=$(ostname_from_index $OSTIDX)
1711 test_mkdir -p $DIR/$tdir
1712 $SETSTRIPE -c 1 $DIR/$tdir # 1 stripe per file
1713 do_facet ost$((OSTIDX + 1)) lctl set_param -n obdfilter.$OST.degraded 1
1715 createmany -o $DIR/$tdir/$tfile $OSTCOUNT
1716 for i in `seq 0 $OFFSET`; do
1717 [ `$GETSTRIPE $DIR/$tdir/$tfile$i | grep -A 10 obdidx | awk '{print $1}' | grep -w "$OSTIDX"` ] &&
1718 error "OST0 was degraded but new created file still use it"
1720 do_facet ost$((OSTIDX + 1)) lctl set_param -n obdfilter.$OST.degraded 0
1722 run_test 27x "create files while OST0 is degraded"
1725 [[ $OSTCOUNT -lt 2 ]] &&
1726 skip_env "$OSTCOUNT < 2 OSTs -- skipping" && return
1727 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1728 remote_ost_nodsh && skip "remote OST with nodsh" && return
1729 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1731 local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS $FSNAME-OST0000)
1732 local last_id=$(do_facet $SINGLEMDS lctl get_param -n \
1733 osc.$mdtosc.prealloc_last_id)
1734 local next_id=$(do_facet $SINGLEMDS lctl get_param -n \
1735 osc.$mdtosc.prealloc_next_id)
1736 local fcount=$((last_id - next_id))
1737 [[ $fcount -eq 0 ]] && skip "not enough space on OST0" && return
1738 [[ $fcount -gt $OSTCOUNT ]] && fcount=$OSTCOUNT
1740 local MDS_OSCS=$(do_facet $SINGLEMDS lctl dl |
1741 awk '/[oO][sS][cC].*md[ts]/ { print $4 }')
1742 local OST_DEACTIVE_IDX=-1
1747 for OSC in $MDS_OSCS; do
1748 OST=$(osc_to_ost $OSC)
1749 OSTIDX=$(index_from_ostuuid $OST)
1750 if [ $OST_DEACTIVE_IDX == -1 ]; then
1751 OST_DEACTIVE_IDX=$OSTIDX
1753 if [ $OSTIDX != $OST_DEACTIVE_IDX ]; then
1754 echo $OSC "is Deactivated:"
1755 do_facet $SINGLEMDS lctl --device %$OSC deactivate
1759 OSTIDX=$(index_from_ostuuid $OST)
1761 $SETSTRIPE -c 1 $DIR/$tdir # 1 stripe / file
1763 for OSC in $MDS_OSCS; do
1764 OST=$(osc_to_ost $OSC)
1765 OSTIDX=$(index_from_ostuuid $OST)
1766 if [ $OSTIDX == $OST_DEACTIVE_IDX ]; then
1767 echo $OST "is degraded:"
1768 do_facet ost$((OSTIDX+1)) lctl set_param -n \
1769 obdfilter.$OST.degraded=1
1774 createmany -o $DIR/$tdir/$tfile $fcount
1776 for OSC in $MDS_OSCS; do
1777 OST=$(osc_to_ost $OSC)
1778 OSTIDX=$(index_from_ostuuid $OST)
1779 if [ $OSTIDX == $OST_DEACTIVE_IDX ]; then
1780 echo $OST "is recovered from degraded:"
1781 do_facet ost$((OSTIDX+1)) lctl set_param -n \
1782 obdfilter.$OST.degraded=0
1784 do_facet $SINGLEMDS lctl --device %$OSC activate
1788 # all osp devices get activated, hence -1 stripe count restored
1791 # sleep 2*lod_qos_maxage seconds waiting for lod qos to notice osp
1792 # devices get activated.
1794 $SETSTRIPE -c -1 $DIR/$tfile
1795 stripecnt=$($GETSTRIPE -c $DIR/$tfile)
1797 [ $stripecnt -ne $OSTCOUNT ] &&
1798 error "Of $OSTCOUNT OSTs, only $stripecnt is available"
1801 run_test 27y "create files while OST0 is degraded and the rest inactive"
1807 lmm_count=$($GETSTRIPE -c $1)
1808 lmm_seq=$($GETSTRIPE -v $1 | awk '/lmm_seq/ { print $2 }')
1809 lmm_oid=$($GETSTRIPE -v $1 | awk '/lmm_object_id/ { print $2 }')
1811 local old_ifs="$IFS"
1813 fid=($($LFS path2fid $1))
1816 log "FID seq ${fid[1]}, oid ${fid[2]} ver ${fid[3]}"
1817 log "LOV seq $lmm_seq, oid $lmm_oid, count: $lmm_count"
1819 # compare lmm_seq and lu_fid->f_seq
1820 [ $lmm_seq = ${fid[1]} ] || { error "SEQ mismatch"; return 1; }
1821 # compare lmm_object_id and lu_fid->oid
1822 [ $lmm_oid = ${fid[2]} ] || { error "OID mismatch"; return 2; }
1824 # check the trusted.fid attribute of the OST objects of the file
1825 local have_obdidx=false
1827 $GETSTRIPE $1 | while read obdidx oid hex seq; do
1828 # skip lines up to and including "obdidx"
1829 [ -z "$obdidx" ] && break
1830 [ "$obdidx" = "obdidx" ] && have_obdidx=true && continue
1831 $have_obdidx || continue
1833 local ost=$((obdidx + 1))
1834 local dev=$(ostdevname $ost)
1837 log "want: stripe:$stripe_nr ost:$obdidx oid:$oid/$hex seq:$seq"
1839 seq=$(echo $seq | sed -e "s/^0x//g")
1840 if [ $seq == 0 ]; then
1841 oid_hex=$(echo $oid)
1843 oid_hex=$(echo $hex | sed -e "s/^0x//g")
1845 local obj_file="O/$seq/d$((oid %32))/$oid_hex"
1849 # Don't unmount/remount the OSTs if we don't need to do that.
1850 # LU-2577 changes filter_fid to be smaller, so debugfs needs
1851 # update too, until that use mount/ll_decode_filter_fid/mount.
1852 # Re-enable when debugfs will understand new filter_fid.
1854 if false && [ $(facet_fstype ost$ost) == ldiskfs ]; then
1855 ff=$(do_facet ost$ost "$DEBUGFS -c -R 'stat $obj_file' \
1856 $dev 2>/dev/null" | grep "parent=")
1859 mount_fstype ost$ost
1860 ff=$(do_facet ost$ost $LL_DECODE_FILTER_FID \
1861 $(facet_mntpt ost$ost)/$obj_file)
1862 unmount_fstype ost$ost
1863 start ost$ost $dev $OST_MOUNT_OPTS
1866 [ -z "$ff" ] && error "$obj_file: no filter_fid info"
1868 echo "$ff" | sed -e 's#.*objid=#got: objid=#'
1870 # /mnt/O/0/d23/23: objid=23 seq=0 parent=[0x200000400:0x1e:0x1]
1871 # fid: objid=23 seq=0 parent=[0x200000400:0x1e:0x0] stripe=1
1872 local ff_parent=$(echo $ff|sed -e 's/.*parent=.//')
1873 local ff_pseq=$(echo $ff_parent | cut -d: -f1)
1874 local ff_poid=$(echo $ff_parent | cut -d: -f2)
1876 if echo $ff_parent | grep -q 'stripe='; then
1877 ff_pstripe=$(echo $ff_parent | sed -e 's/.*stripe=//')
1880 # $LL_DECODE_FILTER_FID does not print "stripe="; look
1881 # into f_ver in this case. See the comment on
1884 ff_pstripe=$(echo $ff_parent | cut -d: -f3 |
1888 # compare lmm_seq and filter_fid->ff_parent.f_seq
1889 [ $ff_pseq = $lmm_seq ] ||
1890 error "FF parent SEQ $ff_pseq != $lmm_seq"
1891 # compare lmm_object_id and filter_fid->ff_parent.f_oid
1892 [ $ff_poid = $lmm_oid ] ||
1893 error "FF parent OID $ff_poid != $lmm_oid"
1894 (($ff_pstripe == $stripe_nr)) ||
1895 error "FF stripe $ff_pstripe != $stripe_nr"
1897 stripe_nr=$((stripe_nr + 1))
1902 remote_ost_nodsh && skip "remote OST with nodsh" && return
1903 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1904 test_mkdir -p $DIR/$tdir
1906 $SETSTRIPE -c 1 -i 0 -S 64k $DIR/$tdir/$tfile-1 ||
1907 { error "setstripe -c -1 failed"; return 1; }
1908 # We need to send a write to every object to get parent FID info set.
1909 # This _should_ also work for setattr, but does not currently.
1910 # touch $DIR/$tdir/$tfile-1 ||
1911 dd if=/dev/zero of=$DIR/$tdir/$tfile-1 bs=1M count=1 ||
1912 { error "dd $tfile-1 failed"; return 2; }
1913 $SETSTRIPE -c -1 -i $((OSTCOUNT - 1)) -S 1M $DIR/$tdir/$tfile-2 ||
1914 { error "setstripe -c -1 failed"; return 3; }
1915 dd if=/dev/zero of=$DIR/$tdir/$tfile-2 bs=1M count=$OSTCOUNT ||
1916 { error "dd $tfile-2 failed"; return 4; }
1918 # make sure write RPCs have been sent to OSTs
1921 check_seq_oid $DIR/$tdir/$tfile-1 || return 5
1922 check_seq_oid $DIR/$tdir/$tfile-2 || return 6
1924 run_test 27z "check SEQ/OID on the MDT and OST filesystems"
1926 test_27A() { # b=19102
1927 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1928 local restore_size=$($GETSTRIPE -S $MOUNT)
1929 local restore_count=$($GETSTRIPE -c $MOUNT)
1930 local restore_offset=$($GETSTRIPE -i $MOUNT)
1931 $SETSTRIPE -c 0 -i -1 -S 0 $MOUNT
1932 wait_update $HOSTNAME "$GETSTRIPE -c $MOUNT | sed 's/ *//g'" "1" 20 ||
1933 error "stripe count $($GETSTRIPE -c $MOUNT) != 1"
1934 local default_size=$($GETSTRIPE -S $MOUNT)
1935 local default_offset=$($GETSTRIPE -i $MOUNT)
1936 local dsize=$((1024 * 1024))
1937 [ $default_size -eq $dsize ] ||
1938 error "stripe size $default_size != $dsize"
1939 [ $default_offset -eq -1 ] ||error "stripe offset $default_offset != -1"
1940 $SETSTRIPE -c $restore_count -i $restore_offset -S $restore_size $MOUNT
1942 run_test 27A "check filesystem-wide default LOV EA values"
1944 test_27B() { # LU-2523
1945 test_mkdir -p $DIR/$tdir
1946 rm -f $DIR/$tdir/f0 $DIR/$tdir/f1
1948 # open f1 with O_LOV_DELAY_CREATE
1950 # call setstripe ioctl on open file descriptor for f1
1952 multiop $DIR/$tdir/f1 oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:nB1c \
1956 # open f1 with O_LOV_DELAY_CREATE
1958 # call setstripe ioctl on open file descriptor for f1
1960 multiop $DIR/$tdir/f1 oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:uB1c
1962 # Allow multiop to fail in imitation of NFS's busted semantics.
1965 run_test 27B "call setstripe on open unlinked file/rename victim"
1967 test_27C() { #LU-2871
1968 [[ $OSTCOUNT -lt 2 ]] && skip "needs >= 2 OSTs" && return
1976 test_mkdir -p $DIR/$tdir
1978 for i in $(seq 0 $((OSTCOUNT - 1))); do
1979 # set stripe across all OSTs starting from OST$i
1980 $SETSTRIPE -i $i -c -1 $tfile$i
1981 # get striping information
1982 ost_idx=($($GETSTRIPE $tfile$i |
1983 tail -n $((OSTCOUNT + 1)) | awk '{print $1}'))
1987 [ ${#ost_idx[@]} -eq $OSTCOUNT ] ||
1988 error "${#ost_idx[@]} != $OSTCOUNT"
1990 for index in $(seq 0 $((OSTCOUNT - 1))); do
1992 for j in $(echo ${ost_idx[@]}); do
1993 if [ $index -eq $j ]; then
1999 error "Can not find $index in ${ost_idx[@]}"
2003 run_test 27C "check full striping across all OSTs"
2006 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs" && return
2007 local POOL=${POOL:-testpool}
2009 local last_ost=$(($OSTCOUNT - 1))
2011 local ost_list=$(seq $first_ost $ost_step $last_ost)
2012 local ost_range="$first_ost $last_ost $ost_step"
2015 pool_add $POOL || error "pool_add failed"
2016 pool_add_targets $POOL $ost_range || error "pool_add_targets failed"
2017 llapi_layout_test -d$DIR/$tdir -p$POOL -o$OSTCOUNT ||
2018 error "llapi_layout_test failed"
2019 cleanup_pools || error "cleanup_pools failed"
2021 run_test 27D "validate llapi_layout API"
2023 # Verify that default_easize is increased from its initial value after
2024 # accessing a widely striped file.
2026 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs" && return
2028 # 72 bytes is the minimum space required to store striping
2029 # information for a file striped across one OST:
2030 # (sizeof(struct lov_user_md_v3) +
2031 # sizeof(struct lov_user_ost_data_v1))
2033 $LCTL set_param -n llite.*.default_easize $min_easize ||
2034 error "lctl set_param failed"
2035 local easize=$($LCTL get_param -n llite.*.default_easize)
2037 [ $easize -eq $min_easize ] ||
2038 error "failed to set default_easize"
2040 $LFS setstripe -c $OSTCOUNT $DIR/$tfile ||
2041 error "setstripe failed"
2045 easize=$($LCTL get_param -n llite.*.default_easize)
2047 [ $easize -gt $min_easize ] ||
2048 error "default_easize not updated"
2050 run_test 27E "check that default extended attribute size properly increases"
2052 # createtest also checks that device nodes are created and
2053 # then visible correctly (#2091)
2054 test_28() { # bug 2091
2056 $CREATETEST $DIR/d28/ct || error
2058 run_test 28 "create/mknod/mkdir with bad file types ============"
2061 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2062 cancel_lru_locks mdc
2068 declare -i LOCKCOUNTORIG=0
2069 for lock_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_count); do
2070 let LOCKCOUNTORIG=$LOCKCOUNTORIG+$lock_count
2072 [ $LOCKCOUNTORIG -eq 0 ] && echo "No mdc lock count" && return 1
2074 declare -i LOCKUNUSEDCOUNTORIG=0
2075 for unused_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_unused_count); do
2076 let LOCKUNUSEDCOUNTORIG=$LOCKUNUSEDCOUNTORIG+$unused_count
2083 declare -i LOCKCOUNTCURRENT=0
2084 for lock_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_count); do
2085 let LOCKCOUNTCURRENT=$LOCKCOUNTCURRENT+$lock_count
2088 declare -i LOCKUNUSEDCOUNTCURRENT=0
2089 for unused_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_unused_count); do
2090 let LOCKUNUSEDCOUNTCURRENT=$LOCKUNUSEDCOUNTCURRENT+$unused_count
2093 if [[ $LOCKCOUNTCURRENT -gt $LOCKCOUNTORIG ]]; then
2094 $LCTL set_param -n ldlm.dump_namespaces ""
2095 error "CURRENT: $LOCKCOUNTCURRENT > $LOCKCOUNTORIG"
2096 $LCTL dk | sort -k4 -t: > $TMP/test_29.dk
2097 log "dumped log to $TMP/test_29.dk (bug 5793)"
2100 if [[ $LOCKUNUSEDCOUNTCURRENT -gt $LOCKUNUSEDCOUNTORIG ]]; then
2101 error "UNUSED: $LOCKUNUSEDCOUNTCURRENT > $LOCKUNUSEDCOUNTORIG"
2102 $LCTL dk | sort -k4 -t: > $TMP/test_29.dk
2103 log "dumped log to $TMP/test_29.dk (bug 5793)"
2107 run_test 29 "IT_GETATTR regression ============================"
2109 test_30a() { # was test_30
2110 cp $(which ls) $DIR || cp /bin/ls $DIR
2114 run_test 30a "execute binary from Lustre (execve) =============="
2117 cp `which ls` $DIR || cp /bin/ls $DIR
2119 $RUNAS $DIR/ls / || error
2122 run_test 30b "execute binary from Lustre as non-root ==========="
2124 test_30c() { # b=22376
2125 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2126 cp `which ls` $DIR || cp /bin/ls $DIR
2128 cancel_lru_locks mdc
2129 cancel_lru_locks osc
2130 $RUNAS $DIR/ls / || error
2133 run_test 30c "execute binary from Lustre without read perms ===="
2136 $OPENUNLINK $DIR/f31 $DIR/f31 || error
2137 $CHECKSTAT -a $DIR/f31 || error
2139 run_test 31a "open-unlink file =================================="
2142 touch $DIR/f31 || error
2143 ln $DIR/f31 $DIR/f31b || error
2144 $MULTIOP $DIR/f31b Ouc || error
2145 $CHECKSTAT -t file $DIR/f31 || error
2147 run_test 31b "unlink file with multiple links while open ======="
2150 touch $DIR/f31 || error
2151 ln $DIR/f31 $DIR/f31c || error
2152 multiop_bg_pause $DIR/f31 O_uc || return 1
2154 $MULTIOP $DIR/f31c Ouc
2155 kill -USR1 $MULTIPID
2158 run_test 31c "open-unlink file with multiple links ============="
2161 opendirunlink $DIR/d31d $DIR/d31d || error
2162 $CHECKSTAT -a $DIR/d31d || error
2164 run_test 31d "remove of open directory ========================="
2166 test_31e() { # bug 2904
2167 openfilleddirunlink $DIR/d31e || error
2169 run_test 31e "remove of open non-empty directory ==============="
2171 test_31f() { # bug 4554
2172 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2174 test_mkdir $DIR/d31f
2175 $SETSTRIPE -S 1048576 -c 1 $DIR/d31f
2176 cp /etc/hosts $DIR/d31f
2178 $GETSTRIPE $DIR/d31f/hosts
2179 multiop_bg_pause $DIR/d31f D_c || return 1
2182 rm -rv $DIR/d31f || error "first of $DIR/d31f"
2183 test_mkdir $DIR/d31f
2184 $SETSTRIPE -S 1048576 -c 1 $DIR/d31f
2185 cp /etc/hosts $DIR/d31f
2187 $GETSTRIPE $DIR/d31f/hosts
2188 multiop_bg_pause $DIR/d31f D_c || return 1
2191 kill -USR1 $MULTIPID || error "first opendir $MULTIPID not running"
2192 wait $MULTIPID || error "first opendir $MULTIPID failed"
2196 kill -USR1 $MULTIPID2 || error "second opendir $MULTIPID not running"
2197 wait $MULTIPID2 || error "second opendir $MULTIPID2 failed"
2200 run_test 31f "remove of open directory with open-unlink file ==="
2203 echo "-- cross directory link --"
2204 test_mkdir -c1 $DIR/${tdir}ga
2205 test_mkdir -c1 $DIR/${tdir}gb
2206 touch $DIR/${tdir}ga/f
2207 ln $DIR/${tdir}ga/f $DIR/${tdir}gb/g
2208 $CHECKSTAT -t file $DIR/${tdir}ga/f || error "source"
2209 [ `stat -c%h $DIR/${tdir}ga/f` == '2' ] || error "source nlink"
2210 $CHECKSTAT -t file $DIR/${tdir}gb/g || error "target"
2211 [ `stat -c%h $DIR/${tdir}gb/g` == '2' ] || error "target nlink"
2213 run_test 31g "cross directory link==============="
2216 echo "-- cross directory link --"
2217 test_mkdir -c1 $DIR/${tdir}
2218 test_mkdir -c1 $DIR/${tdir}/dir
2219 touch $DIR/${tdir}/f
2220 ln $DIR/${tdir}/f $DIR/${tdir}/dir/g
2221 $CHECKSTAT -t file $DIR/${tdir}/f || error "source"
2222 [ `stat -c%h $DIR/${tdir}/f` == '2' ] || error "source nlink"
2223 $CHECKSTAT -t file $DIR/${tdir}/dir/g || error "target"
2224 [ `stat -c%h $DIR/${tdir}/dir/g` == '2' ] || error "target nlink"
2226 run_test 31h "cross directory link under child==============="
2229 echo "-- cross directory link --"
2230 test_mkdir -c1 $DIR/$tdir
2231 test_mkdir -c1 $DIR/$tdir/dir
2232 touch $DIR/$tdir/dir/f
2233 ln $DIR/$tdir/dir/f $DIR/$tdir/g
2234 $CHECKSTAT -t file $DIR/$tdir/dir/f || error "source"
2235 [ `stat -c%h $DIR/$tdir/dir/f` == '2' ] || error "source nlink"
2236 $CHECKSTAT -t file $DIR/$tdir/g || error "target"
2237 [ `stat -c%h $DIR/$tdir/g` == '2' ] || error "target nlink"
2239 run_test 31i "cross directory link under parent==============="
2242 test_mkdir -c1 -p $DIR/$tdir
2243 test_mkdir -c1 -p $DIR/$tdir/dir1
2244 ln $DIR/$tdir/dir1 $DIR/$tdir/dir2 && error "ln for dir"
2245 link $DIR/$tdir/dir1 $DIR/$tdir/dir3 && error "link for dir"
2246 mlink $DIR/$tdir/dir1 $DIR/$tdir/dir4 && error "mlink for dir"
2247 mlink $DIR/$tdir/dir1 $DIR/$tdir/dir1 && error "mlink to the same dir"
2250 run_test 31j "link for directory==============="
2253 test_mkdir -c1 -p $DIR/$tdir
2255 touch $DIR/$tdir/exist
2256 mlink $DIR/$tdir/s $DIR/$tdir/t || error "mlink"
2257 mlink $DIR/$tdir/s $DIR/$tdir/exist && error "mlink to exist file"
2258 mlink $DIR/$tdir/s $DIR/$tdir/s && error "mlink to the same file"
2259 mlink $DIR/$tdir/s $DIR/$tdir && error "mlink to parent dir"
2260 mlink $DIR/$tdir $DIR/$tdir/s && error "mlink parent dir to target"
2261 mlink $DIR/$tdir/not-exist $DIR/$tdir/foo && error "mlink non-existing to new"
2262 mlink $DIR/$tdir/not-exist $DIR/$tdir/s && error "mlink non-existing to exist"
2265 run_test 31k "link to file: the same, non-existing, dir==============="
2271 touch $DIR/d31m2/exist
2272 mlink $DIR/d31m/s $DIR/d31m2/t || error "mlink"
2273 mlink $DIR/d31m/s $DIR/d31m2/exist && error "mlink to exist file"
2274 mlink $DIR/d31m/s $DIR/d31m2 && error "mlink to parent dir"
2275 mlink $DIR/d31m2 $DIR/d31m/s && error "mlink parent dir to target"
2276 mlink $DIR/d31m/not-exist $DIR/d31m2/foo && error "mlink non-existing to new"
2277 mlink $DIR/d31m/not-exist $DIR/d31m2/s && error "mlink non-existing to exist"
2280 run_test 31m "link to file: the same, non-existing, dir==============="
2283 touch $DIR/$tfile || error "cannot create '$DIR/$tfile'"
2284 nlink=$(stat --format=%h $DIR/$tfile)
2285 [ ${nlink:--1} -eq 1 ] || error "nlink is $nlink, expected 1"
2287 local cmd="exec $fd<$DIR/$tfile"
2290 trap "eval $cmd" EXIT
2291 nlink=$(stat --dereference --format=%h /proc/self/fd/$fd)
2292 [ ${nlink:--1} -eq 1 ] || error "nlink is $nlink, expected 1"
2293 rm $DIR/$tfile || error "cannot remove '$DIR/$tfile'"
2294 nlink=$(stat --dereference --format=%h /proc/self/fd/$fd)
2295 [ ${nlink:--1} -eq 0 ] || error "nlink is $nlink, expected 0"
2298 run_test 31n "check link count of unlinked file"
2301 local TEMPNAME=$(mktemp $1_XXXXXX)
2302 mlink $TEMPNAME $1 2> /dev/null &&
2303 echo "$BASHPID: link $TEMPNAME to $1 succeeded"
2307 test_31o() { # LU-2901
2309 for LOOP in $(seq 100); do
2310 rm -f $DIR/$tdir/$tfile*
2311 for THREAD in $(seq 8); do
2312 link_one $DIR/$tdir/$tfile.$LOOP &
2315 local LINKS=$(ls -1 $DIR/$tdir | grep -c $tfile.$LOOP)
2316 [[ $LINKS -gt 1 ]] && ls $DIR/$tdir &&
2317 error "$LINKS duplicate links to $tfile.$LOOP" &&
2321 run_test 31o "duplicate hard links with same filename"
2324 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2327 $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
2328 $LFS setdirstripe -D -c2 -t all_char $DIR/$tdir/striped_dir
2330 opendirunlink $DIR/$tdir/striped_dir/test1 ||
2331 error "open unlink test1 failed"
2332 opendirunlink $DIR/$tdir/striped_dir/test2 ||
2333 error "open unlink test2 failed"
2335 $CHECKSTAT -a $DIR/$tdir/striped_dir/test1 ||
2336 error "test1 still exists"
2337 $CHECKSTAT -a $DIR/$tdir/striped_dir/test2 ||
2338 error "test2 still exists"
2340 run_test 31p "remove of open striped directory"
2342 cleanup_test32_mount() {
2344 $UMOUNT -d $DIR/$tdir/ext2-mountpoint
2348 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2349 echo "== more mountpoints and symlinks ================="
2350 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2351 trap cleanup_test32_mount EXIT
2352 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2353 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2354 $CHECKSTAT -t dir $DIR/$tdir/ext2-mountpoint/.. || error
2355 cleanup_test32_mount
2357 run_test 32a "stat d32a/ext2-mountpoint/.. ====================="
2360 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2361 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2362 trap cleanup_test32_mount EXIT
2363 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2364 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2365 ls -al $DIR/$tdir/ext2-mountpoint/.. || error
2366 cleanup_test32_mount
2368 run_test 32b "open d32b/ext2-mountpoint/.. ====================="
2371 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2372 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2373 trap cleanup_test32_mount EXIT
2374 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2375 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2376 test_mkdir -p $DIR/$tdir/d2/test_dir
2377 $CHECKSTAT -t dir $DIR/$tdir/ext2-mountpoint/../d2/test_dir || error
2378 cleanup_test32_mount
2380 run_test 32c "stat d32c/ext2-mountpoint/../d2/test_dir ========="
2383 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2384 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2385 trap cleanup_test32_mount EXIT
2386 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2387 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2388 test_mkdir -p $DIR/$tdir/d2/test_dir
2389 ls -al $DIR/$tdir/ext2-mountpoint/../d2/test_dir || error
2390 cleanup_test32_mount
2392 run_test 32d "open d32d/ext2-mountpoint/../d2/test_dir ========="
2395 [ -e $DIR/d32e ] && rm -fr $DIR/d32e
2396 test_mkdir -p $DIR/d32e/tmp
2397 TMP_DIR=$DIR/d32e/tmp
2398 ln -s $DIR/d32e $TMP_DIR/symlink11
2399 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
2400 $CHECKSTAT -t link $DIR/d32e/tmp/symlink11 || error
2401 $CHECKSTAT -t link $DIR/d32e/symlink01 || error
2403 run_test 32e "stat d32e/symlink->tmp/symlink->lustre-subdir ===="
2406 [ -e $DIR/d32f ] && rm -fr $DIR/d32f
2407 test_mkdir -p $DIR/d32f/tmp
2408 TMP_DIR=$DIR/d32f/tmp
2409 ln -s $DIR/d32f $TMP_DIR/symlink11
2410 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
2411 ls $DIR/d32f/tmp/symlink11 || error
2412 ls $DIR/d32f/symlink01 || error
2414 run_test 32f "open d32f/symlink->tmp/symlink->lustre-subdir ===="
2417 TMP_DIR=$DIR/$tdir/tmp
2418 test_mkdir -p $DIR/$tdir/tmp
2419 test_mkdir $DIR/${tdir}2
2420 ln -s $DIR/${tdir}2 $TMP_DIR/symlink12
2421 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
2422 $CHECKSTAT -t link $TMP_DIR/symlink12 || error
2423 $CHECKSTAT -t link $DIR/$tdir/symlink02 || error
2424 $CHECKSTAT -t dir -f $TMP_DIR/symlink12 || error
2425 $CHECKSTAT -t dir -f $DIR/$tdir/symlink02 || error
2427 run_test 32g "stat d32g/symlink->tmp/symlink->lustre-subdir/${tdir}2"
2430 rm -fr $DIR/$tdir $DIR/${tdir}2
2431 TMP_DIR=$DIR/$tdir/tmp
2432 test_mkdir -p $DIR/$tdir/tmp
2433 test_mkdir $DIR/${tdir}2
2434 ln -s $DIR/${tdir}2 $TMP_DIR/symlink12
2435 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
2436 ls $TMP_DIR/symlink12 || error
2437 ls $DIR/$tdir/symlink02 || error
2439 run_test 32h "open d32h/symlink->tmp/symlink->lustre-subdir/${tdir}2"
2442 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2443 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2444 trap cleanup_test32_mount EXIT
2445 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2446 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2447 touch $DIR/$tdir/test_file
2448 $CHECKSTAT -t file $DIR/$tdir/ext2-mountpoint/../test_file || error
2449 cleanup_test32_mount
2451 run_test 32i "stat d32i/ext2-mountpoint/../test_file ==========="
2454 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2455 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2456 trap cleanup_test32_mount EXIT
2457 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2458 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2459 touch $DIR/$tdir/test_file
2460 cat $DIR/$tdir/ext2-mountpoint/../test_file || error
2461 cleanup_test32_mount
2463 run_test 32j "open d32j/ext2-mountpoint/../test_file ==========="
2466 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2468 trap cleanup_test32_mount EXIT
2469 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2470 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint
2471 test_mkdir -p $DIR/$tdir/d2
2472 touch $DIR/$tdir/d2/test_file || error
2473 $CHECKSTAT -t file $DIR/$tdir/ext2-mountpoint/../d2/test_file || error
2474 cleanup_test32_mount
2476 run_test 32k "stat d32k/ext2-mountpoint/../d2/test_file ========"
2479 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2481 trap cleanup_test32_mount EXIT
2482 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2483 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2484 test_mkdir -p $DIR/$tdir/d2
2485 touch $DIR/$tdir/d2/test_file
2486 cat $DIR/$tdir/ext2-mountpoint/../d2/test_file || error
2487 cleanup_test32_mount
2489 run_test 32l "open d32l/ext2-mountpoint/../d2/test_file ========"
2493 test_mkdir -p $DIR/d32m/tmp
2494 TMP_DIR=$DIR/d32m/tmp
2495 ln -s $DIR $TMP_DIR/symlink11
2496 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
2497 $CHECKSTAT -t link $DIR/d32m/tmp/symlink11 || error
2498 $CHECKSTAT -t link $DIR/d32m/symlink01 || error
2500 run_test 32m "stat d32m/symlink->tmp/symlink->lustre-root ======"
2504 test_mkdir -p $DIR/d32n/tmp
2505 TMP_DIR=$DIR/d32n/tmp
2506 ln -s $DIR $TMP_DIR/symlink11
2507 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
2508 ls -l $DIR/d32n/tmp/symlink11 || error
2509 ls -l $DIR/d32n/symlink01 || error
2511 run_test 32n "open d32n/symlink->tmp/symlink->lustre-root ======"
2515 test_mkdir -p $DIR/d32o/tmp
2516 TMP_DIR=$DIR/d32o/tmp
2517 ln -s $DIR/$tfile $TMP_DIR/symlink12
2518 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
2519 $CHECKSTAT -t link $DIR/d32o/tmp/symlink12 || error
2520 $CHECKSTAT -t link $DIR/d32o/symlink02 || error
2521 $CHECKSTAT -t file -f $DIR/d32o/tmp/symlink12 || error
2522 $CHECKSTAT -t file -f $DIR/d32o/symlink02 || error
2524 run_test 32o "stat d32o/symlink->tmp/symlink->lustre-root/$tfile"
2534 test_mkdir -p $DIR/d32p/tmp
2536 TMP_DIR=$DIR/d32p/tmp
2538 ln -s $DIR/$tfile $TMP_DIR/symlink12
2540 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
2542 cat $DIR/d32p/tmp/symlink12 || error
2544 cat $DIR/d32p/symlink02 || error
2547 run_test 32p "open d32p/symlink->tmp/symlink->lustre-root/$tfile"
2549 cleanup_testdir_mount() {
2551 $UMOUNT -d $DIR/$tdir
2555 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2556 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2557 trap cleanup_testdir_mount EXIT
2558 test_mkdir -p $DIR/$tdir
2559 touch $DIR/$tdir/under_the_mount
2560 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir
2561 ls $DIR/$tdir | grep "\<under_the_mount\>" && error
2562 cleanup_testdir_mount
2564 run_test 32q "stat follows mountpoints in Lustre (should return error)"
2567 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2568 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2569 trap cleanup_testdir_mount EXIT
2570 test_mkdir -p $DIR/$tdir
2571 touch $DIR/$tdir/under_the_mount
2572 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir
2573 ls $DIR/$tdir | grep -q under_the_mount && error || true
2574 cleanup_testdir_mount
2576 run_test 32r "opendir follows mountpoints in Lustre (should return error)"
2581 chmod 444 $DIR/$tfile
2582 chown $RUNAS_ID $DIR/$tfile
2584 $RUNAS $OPENFILE -f O_RDWR $DIR/$tfile && error || true
2587 run_test 33aa "write file with mode 444 (should return error) ===="
2591 test_mkdir -p $DIR/d33
2592 chown $RUNAS_ID $DIR/d33
2593 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $DIR/d33/f33|| error "create"
2594 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $DIR/d33/f33 && \
2595 error "open RDWR" || true
2597 run_test 33a "test open file(mode=0444) with O_RDWR (should return error)"
2601 test_mkdir -p $DIR/d33
2602 chown $RUNAS_ID $DIR/d33
2603 $RUNAS $OPENFILE -f 1286739555 $DIR/d33/f33 || true
2605 run_test 33b "test open file with malformed flags (No panic)"
2608 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2614 remote_ost_nodsh && skip "remote OST with nodsh" && return
2617 test_mkdir -p $DIR/d33
2618 # Read: 0, Write: 4, create/destroy: 2/0, stat: 1, punch: 0
2621 for ostnum in $(seq $OSTCOUNT); do
2622 # test-framework's OST numbering is one-based, while Lustre's
2624 ostname=$(printf "$FSNAME-OST%.4x" $((ostnum - 1)))
2625 # Parsing llobdstat's output sucks; we could grep the /proc
2626 # path, but that's likely to not be as portable as using the
2627 # llobdstat utility. So we parse lctl output instead.
2628 write_bytes=$(do_facet ost$ostnum lctl get_param -n \
2629 obdfilter/$ostname/stats |
2630 awk '/^write_bytes/ {print $7}' )
2631 echo "baseline_write_bytes@$OSTnum/$ostname=$write_bytes"
2632 if (( ${write_bytes:-0} > 0 ))
2639 $all_zeros || return 0
2642 echo foo > $DIR/d33/bar
2646 # Total up write_bytes after writing. We'd better find non-zeros.
2647 for ostnum in $(seq $OSTCOUNT); do
2648 ostname=$(printf "$FSNAME-OST%.4x" $((ostnum - 1)))
2649 write_bytes=$(do_facet ost$ostnum lctl get_param -n \
2650 obdfilter/$ostname/stats |
2651 awk '/^write_bytes/ {print $7}' )
2652 echo "write_bytes@$OSTnum/$ostname=$write_bytes"
2653 if (( ${write_bytes:-0} > 0 ))
2662 for ostnum in $(seq $OSTCOUNT); do
2663 ostname=$(printf "$FSNAME-OST%.4x" $((ostnum - 1)))
2664 echo "Check that write_bytes is present in obdfilter/*/stats:"
2665 do_facet ost$ostnum lctl get_param -n \
2666 obdfilter/$ostname/stats
2668 error "OST not keeping write_bytes stats (b22312)"
2671 run_test 33c "test llobdstat and write_bytes"
2674 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 2 MDTs" && return
2675 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2677 local remote_dir=$DIR/$tdir/remote_dir
2680 $LFS mkdir -i $MDTIDX $remote_dir ||
2681 error "create remote directory failed"
2683 touch $remote_dir/$tfile
2684 chmod 444 $remote_dir/$tfile
2685 chown $RUNAS_ID $remote_dir/$tfile
2687 $RUNAS $OPENFILE -f O_RDWR $DIR/$tfile && error || true
2689 chown $RUNAS_ID $remote_dir
2690 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $remote_dir/f33 ||
2691 error "create" || true
2692 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $remote_dir/f33 &&
2693 error "open RDWR" || true
2694 $RUNAS $OPENFILE -f 1286739555 $remote_dir/f33 &&
2695 error "create" || true
2697 run_test 33d "openfile with 444 modes and malformed flags under remote dir"
2700 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2704 $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
2705 $LFS setdirstripe -i1 -c2 $DIR/$tdir/striped_dir1
2706 mkdir $DIR/$tdir/local_dir
2708 local s0_mode=$(stat -c%f $DIR/$tdir/striped_dir)
2709 local s1_mode=$(stat -c%f $DIR/$tdir/striped_dir1)
2710 local l_mode=$(stat -c%f $DIR/$tdir/local_dir)
2712 [ "$l_mode" = "$s0_mode" -a "$l_mode" = "$s1_mode" ] ||
2713 error "mkdir $l_mode striped0 $s0_mode striped1 $s1_mode"
2715 rmdir $DIR/$tdir/* || error "rmdir failed"
2718 $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
2719 $LFS setdirstripe -i1 -c2 $DIR/$tdir/striped_dir1
2720 mkdir $DIR/$tdir/local_dir
2722 s0_mode=$(stat -c%f $DIR/$tdir/striped_dir)
2723 s1_mode=$(stat -c%f $DIR/$tdir/striped_dir1)
2724 l_mode=$(stat -c%f $DIR/$tdir/local_dir)
2726 [ "$l_mode" = "$s0_mode" -a "$l_mode" = "$s1_mode" ] ||
2727 error "mkdir $l_mode striped0 $s0_mode striped1 $s1_mode 777"
2729 rmdir $DIR/$tdir/* || error "rmdir(umask 777) failed"
2732 $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
2733 $LFS setdirstripe -i1 -c2 $DIR/$tdir/striped_dir1
2734 mkdir $DIR/$tdir/local_dir
2736 s0_mode=$(stat -c%f $DIR/$tdir/striped_dir)
2737 s1_mode=$(stat -c%f $DIR/$tdir/striped_dir1)
2738 l_mode=$(stat -c%f $DIR/$tdir/local_dir)
2740 [ "$l_mode" = "$s0_mode" -a "$l_mode" = "$s1_mode" ] ||
2741 error "mkdir $l_mode striped0 $s0_mode striped1 $s1_mode 0"
2743 run_test 33e "mkdir and striped directory should have same mode"
2747 do_facet $SINGLEMDS $LCTL set_param mdt.*.enable_remote_dir_gid=0
2751 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2754 chmod go+rwx $DIR/$tdir
2755 do_facet $SINGLEMDS $LCTL set_param mdt.*.enable_remote_dir_gid=-1
2756 trap cleanup_33f EXIT
2758 $RUNAS lfs mkdir -c$MDSCOUNT $DIR/$tdir/striped_dir ||
2759 error "cannot create striped directory"
2761 $RUNAS touch $DIR/$tdir/striped_dir/{0..16} ||
2762 error "cannot create files in striped directory"
2764 $RUNAS rm $DIR/$tdir/striped_dir/{0..16} ||
2765 error "cannot remove files in striped directory"
2767 $RUNAS rmdir $DIR/$tdir/striped_dir ||
2768 error "cannot remove striped directory"
2772 run_test 33f "nonroot user can create, access, and remove a striped directory"
2774 TEST_34_SIZE=${TEST_34_SIZE:-2000000000000}
2777 $MCREATE $DIR/f34 || error
2778 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" || error
2779 $TRUNCATE $DIR/f34 $TEST_34_SIZE || error
2780 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" || error
2781 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2783 run_test 34a "truncate file that has not been opened ==========="
2786 [ ! -f $DIR/f34 ] && test_34a
2787 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2788 $OPENFILE -f O_RDONLY $DIR/f34
2789 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" || error
2790 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2792 run_test 34b "O_RDONLY opening file doesn't create objects ====="
2795 [ ! -f $DIR/f34 ] && test_34a
2796 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2797 $OPENFILE -f O_RDWR $DIR/f34
2798 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" && error
2799 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2801 run_test 34c "O_RDWR opening file-with-size works =============="
2804 [ ! -f $DIR/f34 ] && test_34a
2805 dd if=/dev/zero of=$DIR/f34 conv=notrunc bs=4k count=1 || error
2806 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2809 run_test 34d "write to sparse file ============================="
2813 $MCREATE $DIR/f34e || error
2814 $TRUNCATE $DIR/f34e 1000 || error
2815 $CHECKSTAT -s 1000 $DIR/f34e || error
2816 $OPENFILE -f O_RDWR $DIR/f34e
2817 $CHECKSTAT -s 1000 $DIR/f34e || error
2819 run_test 34e "create objects, some with size and some without =="
2821 test_34f() { # bug 6242, 6243
2822 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2825 $MCREATE $DIR/f34f || error
2826 $TRUNCATE $DIR/f34f $SIZE34F || error "truncating $DIR/f3f to $SIZE34F"
2827 dd if=$DIR/f34f of=$TMP/f34f
2828 $CHECKSTAT -s $SIZE34F $TMP/f34f || error "$TMP/f34f not $SIZE34F bytes"
2829 dd if=/dev/zero of=$TMP/f34fzero bs=$SIZE34F count=1
2830 cmp $DIR/f34f $TMP/f34fzero || error "$DIR/f34f not all zero"
2831 cmp $TMP/f34f $TMP/f34fzero || error "$TMP/f34f not all zero"
2832 rm $TMP/f34f $TMP/f34fzero $DIR/f34f
2834 run_test 34f "read from a file with no objects until EOF ======="
2837 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2838 dd if=/dev/zero of=$DIR/$tfile bs=1 count=100 seek=$TEST_34_SIZE || error
2839 $TRUNCATE $DIR/$tfile $((TEST_34_SIZE / 2))|| error
2840 $CHECKSTAT -s $((TEST_34_SIZE / 2)) $DIR/$tfile || error "truncate failed"
2841 cancel_lru_locks osc
2842 $CHECKSTAT -s $((TEST_34_SIZE / 2)) $DIR/$tfile || \
2843 error "wrong size after lock cancel"
2845 $TRUNCATE $DIR/$tfile $TEST_34_SIZE || error
2846 $CHECKSTAT -s $TEST_34_SIZE $DIR/$tfile || \
2847 error "expanding truncate failed"
2848 cancel_lru_locks osc
2849 $CHECKSTAT -s $TEST_34_SIZE $DIR/$tfile || \
2850 error "wrong expanded size after lock cancel"
2852 run_test 34g "truncate long file ==============================="
2855 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2859 dd if=/dev/zero of=$DIR/$tfile bs=1M count=10 || error
2860 sync # Flush the cache so that multiop below does not block on cache
2861 # flush when getting the group lock
2862 $MULTIOP $DIR/$tfile OG${gid}T${sz}g${gid}c &
2865 # Since just timed wait is not good enough, let's do a sync write
2866 # that way we are sure enough time for a roundtrip + processing
2867 # passed + 2 seconds of extra margin.
2868 dd if=/dev/zero of=$DIR/${tfile}-1 bs=4096 oflag=direct count=1
2872 if [[ `ps h -o comm -p $MULTIPID` == "multiop" ]]; then
2873 error "Multiop blocked on ftruncate, pid=$MULTIPID"
2877 local nsz=`stat -c %s $DIR/$tfile`
2878 [[ $nsz == $sz ]] || error "New size wrong $nsz != $sz"
2880 run_test 34h "ftruncate file under grouplock should not block"
2883 cp /bin/sh $DIR/f35a
2885 chown $RUNAS_ID $DIR/f35a
2886 $RUNAS $DIR/f35a && error || true
2889 run_test 35a "exec file with mode 444 (should return and not leak) ====="
2893 utime $DIR/f36 || error
2895 run_test 36a "MDS utime check (mknod, utime) ==================="
2899 utime $DIR/f36 || error
2901 run_test 36b "OST utime check (open, utime) ===================="
2906 chown $RUNAS_ID $DIR/d36
2907 $RUNAS utime $DIR/d36/f36 || error
2909 run_test 36c "non-root MDS utime check (mknod, utime) =========="
2912 [ ! -d $DIR/d36 ] && test_36c
2913 echo "" > $DIR/d36/f36
2914 $RUNAS utime $DIR/d36/f36 || error
2916 run_test 36d "non-root OST utime check (open, utime) ==========="
2919 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID -- skipping" && return
2920 test_mkdir -p $DIR/$tdir
2921 touch $DIR/$tdir/$tfile
2922 $RUNAS utime $DIR/$tdir/$tfile && \
2923 error "utime worked, expected failure" || true
2925 run_test 36e "utime on non-owned file (should return error) ===="
2929 local LANG_SAVE=$LANG
2930 local LC_LANG_SAVE=$LC_LANG
2931 export LANG=C LC_LANG=C # for date language
2933 DATESTR="Dec 20 2000"
2934 test_mkdir -p $DIR/$tdir
2935 lctl set_param fail_loc=$fl
2937 cp /etc/hosts $DIR/$tdir/$tfile
2938 sync & # write RPC generated with "current" inode timestamp, but delayed
2940 touch --date="$DATESTR" $DIR/$tdir/$tfile # setattr timestamp in past
2941 LS_BEFORE="`ls -l $DIR/$tdir/$tfile`" # old timestamp from client cache
2942 cancel_lru_locks osc
2943 LS_AFTER="`ls -l $DIR/$tdir/$tfile`" # timestamp from OST object
2945 [ "$LS_BEFORE" != "$LS_AFTER" ] && \
2946 echo "BEFORE: $LS_BEFORE" && \
2947 echo "AFTER : $LS_AFTER" && \
2948 echo "WANT : $DATESTR" && \
2949 error "$DIR/$tdir/$tfile timestamps changed" || true
2951 export LANG=$LANG_SAVE LC_LANG=$LC_LANG_SAVE
2955 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2956 #define OBD_FAIL_OST_BRW_PAUSE_BULK 0x214
2957 subr_36fh "0x80000214"
2959 run_test 36f "utime on file racing with OST BRW write =========="
2962 remote_ost_nodsh && skip "remote OST with nodsh" && return
2963 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2968 test_mkdir -p $DIR/$tdir
2969 fmd_max_age=$(do_facet ost1 \
2970 "lctl get_param -n obdfilter.*.client_cache_seconds 2> /dev/null | \
2973 fmd_before=$(do_facet ost1 \
2974 "awk '/ll_fmd_cache/ {print \\\$2}' /proc/slabinfo")
2975 touch $DIR/$tdir/$tfile
2976 sleep $((fmd_max_age + 12))
2977 fmd_after=$(do_facet ost1 \
2978 "awk '/ll_fmd_cache/ {print \\\$2}' /proc/slabinfo")
2980 echo "fmd_before: $fmd_before"
2981 echo "fmd_after: $fmd_after"
2982 [[ $fmd_after -gt $fmd_before ]] &&
2983 echo "AFTER: $fmd_after > BEFORE: $fmd_before" &&
2984 error "fmd didn't expire after ping" || true
2986 run_test 36g "filter mod data cache expiry ====================="
2989 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2990 #define OBD_FAIL_OST_BRW_PAUSE_BULK2 0x227
2991 subr_36fh "0x80000227"
2993 run_test 36h "utime on file racing with OST BRW write =========="
2996 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2999 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR/$tdir/striped_dir
3001 local mtime=$(stat -c%Y $DIR/$tdir/striped_dir)
3002 local new_mtime=$((mtime + 200))
3004 #change Modify time of striped dir
3005 touch -m -d @$new_mtime $DIR/$tdir/striped_dir ||
3006 error "change mtime failed"
3008 local got=$(stat -c%Y $DIR/$tdir/striped_dir)
3010 [ "$new_mtime" = "$got" ] || error "expect $new_mtime got $got"
3012 run_test 36i "change mtime on striped directory"
3014 # test_37 - duplicate with tests 32q 32r
3017 local file=$DIR/$tfile
3019 openfile -f O_DIRECTORY $file
3022 [ $RC -eq 0 ] && error "opened file $file with O_DIRECTORY" || true
3023 [ $RC -eq $ENOTDIR ] || error "error $RC should be ENOTDIR ($ENOTDIR)"
3025 run_test 38 "open a regular file with O_DIRECTORY should return -ENOTDIR ==="
3029 touch $DIR/${tfile}2
3030 # ls -l $DIR/$tfile $DIR/${tfile}2
3031 # ls -lu $DIR/$tfile $DIR/${tfile}2
3032 # ls -lc $DIR/$tfile $DIR/${tfile}2
3034 $OPENFILE -f O_CREAT:O_TRUNC:O_WRONLY $DIR/${tfile}2
3035 if [ ! $DIR/${tfile}2 -nt $DIR/$tfile ]; then
3037 ls -l --full-time $DIR/$tfile $DIR/${tfile}2
3039 ls -lu --full-time $DIR/$tfile $DIR/${tfile}2
3041 ls -lc --full-time $DIR/$tfile $DIR/${tfile}2
3042 error "O_TRUNC didn't change timestamps"
3045 run_test 39 "mtime changed on create ==========================="
3048 test_mkdir -p -c1 $DIR/$tdir
3049 cp -p /etc/passwd $DIR/$tdir/fopen
3050 cp -p /etc/passwd $DIR/$tdir/flink
3051 cp -p /etc/passwd $DIR/$tdir/funlink
3052 cp -p /etc/passwd $DIR/$tdir/frename
3053 ln $DIR/$tdir/funlink $DIR/$tdir/funlink2
3056 echo "aaaaaa" >> $DIR/$tdir/fopen
3057 echo "aaaaaa" >> $DIR/$tdir/flink
3058 echo "aaaaaa" >> $DIR/$tdir/funlink
3059 echo "aaaaaa" >> $DIR/$tdir/frename
3061 local open_new=`stat -c %Y $DIR/$tdir/fopen`
3062 local link_new=`stat -c %Y $DIR/$tdir/flink`
3063 local unlink_new=`stat -c %Y $DIR/$tdir/funlink`
3064 local rename_new=`stat -c %Y $DIR/$tdir/frename`
3066 cat $DIR/$tdir/fopen > /dev/null
3067 ln $DIR/$tdir/flink $DIR/$tdir/flink2
3068 rm -f $DIR/$tdir/funlink2
3069 mv -f $DIR/$tdir/frename $DIR/$tdir/frename2
3071 for (( i=0; i < 2; i++ )) ; do
3072 local open_new2=`stat -c %Y $DIR/$tdir/fopen`
3073 local link_new2=`stat -c %Y $DIR/$tdir/flink`
3074 local unlink_new2=`stat -c %Y $DIR/$tdir/funlink`
3075 local rename_new2=`stat -c %Y $DIR/$tdir/frename2`
3077 [ $open_new2 -eq $open_new ] || error "open file reverses mtime"
3078 [ $link_new2 -eq $link_new ] || error "link file reverses mtime"
3079 [ $unlink_new2 -eq $unlink_new ] || error "unlink file reverses mtime"
3080 [ $rename_new2 -eq $rename_new ] || error "rename file reverses mtime"
3082 cancel_lru_locks osc
3083 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3086 run_test 39b "mtime change on open, link, unlink, rename ======"
3088 # this should be set to past
3089 TEST_39_MTIME=`date -d "1 year ago" +%s`
3095 local mtime0=`stat -c %Y $DIR1/$tfile`
3097 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3098 local mtime1=`stat -c %Y $DIR1/$tfile`
3099 [ "$mtime1" = $TEST_39_MTIME ] || \
3100 error "mtime is not set to past: $mtime1, should be $TEST_39_MTIME"
3103 echo hello >> $DIR1/$tfile
3105 local mtime2=`stat -c %Y $DIR1/$tfile`
3106 [ "$mtime2" -ge "$d1" ] && [ "$mtime2" -le "$d2" ] || \
3107 error "mtime is not updated on write: $d1 <= $mtime2 <= $d2"
3109 mv $DIR1/$tfile $DIR1/$tfile-1
3111 for (( i=0; i < 2; i++ )) ; do
3112 local mtime3=`stat -c %Y $DIR1/$tfile-1`
3113 [ "$mtime2" = "$mtime3" ] || \
3114 error "mtime ($mtime2) changed (to $mtime3) on rename"
3116 cancel_lru_locks osc
3117 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3120 run_test 39c "mtime change on rename ==========================="
3124 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3127 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3129 for (( i=0; i < 2; i++ )) ; do
3130 local mtime=`stat -c %Y $DIR1/$tfile`
3131 [ $mtime = $TEST_39_MTIME ] || \
3132 error "mtime($mtime) is not set to $TEST_39_MTIME"
3134 cancel_lru_locks osc
3135 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3138 run_test 39d "create, utime, stat =============================="
3142 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3144 local mtime1=`stat -c %Y $DIR1/$tfile`
3146 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3148 for (( i=0; i < 2; i++ )) ; do
3149 local mtime2=`stat -c %Y $DIR1/$tfile`
3150 [ $mtime2 = $TEST_39_MTIME ] || \
3151 error "mtime($mtime2) is not set to $TEST_39_MTIME"
3153 cancel_lru_locks osc
3154 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3157 run_test 39e "create, stat, utime, stat ========================"
3161 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3163 mtime1=`stat -c %Y $DIR1/$tfile`
3166 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3168 for (( i=0; i < 2; i++ )) ; do
3169 local mtime2=`stat -c %Y $DIR1/$tfile`
3170 [ $mtime2 = $TEST_39_MTIME ] || \
3171 error "mtime($mtime2) is not set to $TEST_39_MTIME"
3173 cancel_lru_locks osc
3174 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3177 run_test 39f "create, stat, sleep, utime, stat ================="
3181 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3182 echo hello >> $DIR1/$tfile
3183 local mtime1=`stat -c %Y $DIR1/$tfile`
3186 chmod o+r $DIR1/$tfile
3188 for (( i=0; i < 2; i++ )) ; do
3189 local mtime2=`stat -c %Y $DIR1/$tfile`
3190 [ "$mtime1" = "$mtime2" ] || \
3191 error "lost mtime: $mtime2, should be $mtime1"
3193 cancel_lru_locks osc
3194 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3197 run_test 39g "write, chmod, stat ==============================="
3201 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3206 echo hello >> $DIR1/$tfile
3207 local mtime1=`stat -c %Y $DIR1/$tfile`
3209 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3211 if [ "$d1" != "$d2" ]; then
3212 echo "write and touch not within one second"
3214 for (( i=0; i < 2; i++ )) ; do
3215 local mtime2=`stat -c %Y $DIR1/$tfile`
3216 [ "$mtime2" = $TEST_39_MTIME ] || \
3217 error "lost mtime: $mtime2, should be $TEST_39_MTIME"
3219 cancel_lru_locks osc
3220 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3224 run_test 39h "write, utime within one second, stat ============="
3227 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3231 echo hello >> $DIR1/$tfile
3232 local mtime1=`stat -c %Y $DIR1/$tfile`
3234 mv $DIR1/$tfile $DIR1/$tfile-1
3236 for (( i=0; i < 2; i++ )) ; do
3237 local mtime2=`stat -c %Y $DIR1/$tfile-1`
3239 [ "$mtime1" = "$mtime2" ] || \
3240 error "lost mtime: $mtime2, should be $mtime1"
3242 cancel_lru_locks osc
3243 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3246 run_test 39i "write, rename, stat =============================="
3249 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3250 start_full_debug_logging
3254 #define OBD_FAIL_OSC_DELAY_SETTIME 0x412
3255 lctl set_param fail_loc=0x80000412
3256 multiop_bg_pause $DIR1/$tfile oO_RDWR:w2097152_c ||
3257 error "multiop failed"
3259 local mtime1=`stat -c %Y $DIR1/$tfile`
3261 mv $DIR1/$tfile $DIR1/$tfile-1
3263 kill -USR1 $multipid
3264 wait $multipid || error "multiop close failed"
3266 for (( i=0; i < 2; i++ )) ; do
3267 local mtime2=`stat -c %Y $DIR1/$tfile-1`
3268 [ "$mtime1" = "$mtime2" ] ||
3269 error "mtime is lost on close: $mtime2, " \
3272 cancel_lru_locks osc
3273 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3275 lctl set_param fail_loc=0
3276 stop_full_debug_logging
3278 run_test 39j "write, rename, close, stat ======================="
3281 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3285 multiop_bg_pause $DIR1/$tfile oO_RDWR:w2097152_c || error "multiop failed"
3287 local mtime1=`stat -c %Y $DIR1/$tfile`
3289 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3291 kill -USR1 $multipid
3292 wait $multipid || error "multiop close failed"
3294 for (( i=0; i < 2; i++ )) ; do
3295 local mtime2=`stat -c %Y $DIR1/$tfile`
3297 [ "$mtime2" = $TEST_39_MTIME ] || \
3298 error "mtime is lost on close: $mtime2, should be $TEST_39_MTIME"
3300 cancel_lru_locks osc
3301 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3304 run_test 39k "write, utime, close, stat ========================"
3306 # this should be set to future
3307 TEST_39_ATIME=`date -d "1 year" +%s`
3310 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3311 remote_mds_nodsh && skip "remote MDS with nodsh" && return
3312 local atime_diff=$(do_facet $SINGLEMDS \
3313 lctl get_param -n mdd.*MDT0000*.atime_diff)
3317 # test setting directory atime to future
3318 touch -a -d @$TEST_39_ATIME $DIR/$tdir
3319 local atime=$(stat -c %X $DIR/$tdir)
3320 [ "$atime" = $TEST_39_ATIME ] || \
3321 error "atime is not set to future: $atime, $TEST_39_ATIME"
3323 # test setting directory atime from future to now
3324 local d1=$(date +%s)
3326 local d2=$(date +%s)
3328 cancel_lru_locks mdc
3329 atime=$(stat -c %X $DIR/$tdir)
3330 [ "$atime" -ge "$d1" -a "$atime" -le "$d2" ] || \
3331 error "atime is not updated from future: $atime, $d1<atime<$d2"
3333 do_facet $SINGLEMDS lctl set_param -n mdd.*MDT0000*.atime_diff=2
3336 # test setting directory atime when now > dir atime + atime_diff
3340 cancel_lru_locks mdc
3341 atime=$(stat -c %X $DIR/$tdir)
3342 [ "$atime" -ge "$d1" -a "$atime" -le "$d2" ] || \
3343 error "atime is not updated : $atime, should be $d2"
3345 do_facet $SINGLEMDS lctl set_param -n mdd.*MDT0000*.atime_diff=60
3348 # test not setting directory atime when now < dir atime + atime_diff
3350 cancel_lru_locks mdc
3351 atime=$(stat -c %X $DIR/$tdir)
3352 [ "$atime" -ge "$d1" -a "$atime" -le "$d2" ] || \
3353 error "atime is updated to $atime, should remain $d1<atime<$d2"
3355 do_facet $SINGLEMDS \
3356 lctl set_param -n mdd.*MDT0000*.atime_diff=$atime_diff
3358 run_test 39l "directory atime update ==========================="
3361 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3364 local far_past_mtime=$(date -d "May 29 1953" +%s)
3365 local far_past_atime=$(date -d "Dec 17 1903" +%s)
3367 touch -m -d @$far_past_mtime $DIR1/$tfile
3368 touch -a -d @$far_past_atime $DIR1/$tfile
3370 for (( i=0; i < 2; i++ )) ; do
3371 local timestamps=$(stat -c "%X %Y" $DIR1/$tfile)
3372 [ "$timestamps" = "$far_past_atime $far_past_mtime" ] || \
3373 error "atime or mtime set incorrectly"
3375 cancel_lru_locks osc
3376 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3379 run_test 39m "test atime and mtime before 1970"
3381 test_39n() { # LU-3832
3382 local atime_diff=$(do_facet $SINGLEMDS \
3383 lctl get_param -n mdd.*MDT0000*.atime_diff)
3388 do_facet $SINGLEMDS lctl set_param -n mdd.*MDT0000*.atime_diff=1
3391 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 status=noxfer
3392 atime0=$(stat -c %X $DIR/$tfile)
3395 $MULTIOP $DIR/$tfile oO_RDONLY:O_NOATIME:r4096c