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 5188
12 ALWAYS_EXCEPT=" 42a 42b 42c 42d 45 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 LU-8139
17 ALWAYS_EXCEPT=" 76 101g $ALWAYS_EXCEPT"
21 if [ -r /etc/SuSE-release ]
23 local vers=$(grep VERSION /etc/SuSE-release | awk '{print $3}')
24 local patchlev=$(grep PATCHLEVEL /etc/SuSE-release |
26 if [ $vers -eq 11 ] && [ $patchlev -ge 3 ]; then
33 if is_sles11; then # LU-4341
34 ALWAYS_EXCEPT="$ALWAYS_EXCEPT 170"
37 SRCDIR=$(cd $(dirname $0); echo $PWD)
38 export PATH=$PATH:/sbin
43 CHECKSTAT=${CHECKSTAT:-"checkstat -v"}
44 CREATETEST=${CREATETEST:-createtest}
46 LFIND=${LFIND:-"$LFS find"}
47 LVERIFY=${LVERIFY:-ll_dirstripe_verify}
49 OPENFILE=${OPENFILE:-openfile}
50 OPENUNLINK=${OPENUNLINK:-openunlink}
51 export MULTIOP=${MULTIOP:-multiop}
52 READS=${READS:-"reads"}
53 MUNLINK=${MUNLINK:-munlink}
54 SOCKETSERVER=${SOCKETSERVER:-socketserver}
55 SOCKETCLIENT=${SOCKETCLIENT:-socketclient}
56 MEMHOG=${MEMHOG:-memhog}
57 DIRECTIO=${DIRECTIO:-directio}
58 ACCEPTOR_PORT=${ACCEPTOR_PORT:-988}
60 CHECK_GRANT=${CHECK_GRANT:-"yes"}
61 GRANT_CHECK_LIST=${GRANT_CHECK_LIST:-""}
62 export PARALLEL=${PARALLEL:-"no"}
64 export NAME=${NAME:-local}
71 LUSTRE=${LUSTRE:-$(cd $(dirname $0)/..; echo $PWD)}
72 LUSTRE_TESTS_API_DIR=${LUSTRE_TESTS_API_DIR:-${LUSTRE}/tests/clientapi}
73 . $LUSTRE/tests/test-framework.sh
75 . ${CONFIG:=$LUSTRE/tests/cfg/${NAME}.sh}
79 [ "$SLOW" = "no" ] && EXCEPT_SLOW="24D 27m 64b 68 71 115 300o"
81 if [ $(facet_fstype $SINGLEMDS) = "zfs" ]; then
82 # bug number for skipped test: LU-4536 LU-1957 LU-2805
83 ALWAYS_EXCEPT="$ALWAYS_EXCEPT 65ic 180 184c"
85 [ "$SLOW" = "no" ] && EXCEPT_SLOW="$EXCEPT_SLOW 51b 51ba"
92 pgrep ll_sa > /dev/null && { echo "There are ll_sa thread not exit!"; exit 20; }
93 cleanupall ${FORCE} $* || { echo "FAILed to clean up"; exit 20; }
102 check_swap_layouts_support()
104 $LCTL get_param -n llite.*.sbi_flags | grep -q layout ||
105 { skip "Does not support layout lock."; return 0; }
109 check_and_setup_lustre
113 MDT0=$($LCTL get_param -n mdc.*.mds_server_uuid |
114 awk '{ gsub(/_UUID/,""); print $1 }' | head -n1)
115 MAXFREE=${MAXFREE:-$((200000 * $OSTCOUNT))}
117 [ -f $DIR/d52a/foo ] && chattr -a $DIR/d52a/foo
118 [ -f $DIR/d52b/foo ] && chattr -i $DIR/d52b/foo
119 rm -rf $DIR/[Rdfs][0-9]*
121 # $RUNAS_ID may get set incorrectly somewhere else
122 [ $UID -eq 0 -a $RUNAS_ID -eq 0 ] && error "\$RUNAS_ID set to 0, but \$UID is also 0!"
124 check_runas_id $RUNAS_ID $RUNAS_GID $RUNAS
128 if [ "${ONLY}" = "MOUNT" ] ; then
129 echo "Lustre is up, please go on"
133 echo "preparing for tests involving mounts"
134 EXT2_DEV=${EXT2_DEV:-$TMP/SANITY.LOOP}
136 mke2fs -j -F $EXT2_DEV 8000 > /dev/null
137 echo # add a newline after mke2fs.
141 OLDDEBUG=$(lctl get_param -n debug 2> /dev/null)
142 lctl set_param debug=-1 2> /dev/null || true
145 $CHECKSTAT -t file $DIR/$tfile || error "$tfile is not a file"
147 $CHECKSTAT -a $DIR/$tfile || error "$tfile was not removed"
149 run_test 0a "touch; rm ====================="
152 chmod 0755 $DIR || error "chmod 0755 $DIR failed"
153 $CHECKSTAT -p 0755 $DIR || error "$DIR permission is not 0755"
155 run_test 0b "chmod 0755 $DIR ============================="
158 $LCTL get_param mdc.*.import | grep "state: FULL" ||
159 error "import not FULL"
160 $LCTL get_param mdc.*.import | grep "target: $FSNAME-MDT" ||
163 run_test 0c "check import proc ============================="
166 test_mkdir -p $DIR/$tdir || error "mkdir $tdir failed"
167 test_mkdir -p $DIR/$tdir/d2 || error "mkdir $tdir/d2 failed"
168 test_mkdir $DIR/$tdir/d2 && error "we expect EEXIST, but not returned"
169 $CHECKSTAT -t dir $DIR/$tdir/d2 || error "$tdir/d2 is not a dir"
172 $CHECKSTAT -a $DIR/$tdir || error "$tdir was not removed"
174 run_test 1 "mkdir; remkdir; rmdir =============================="
177 test_mkdir -p $DIR/$tdir || error "mkdir $tdir failed"
178 touch $DIR/$tdir/$tfile || error "touch $tdir/$tfile failed"
179 $CHECKSTAT -t file $DIR/$tdir/$tfile || error "$tdir/$tfile not a file"
181 $CHECKSTAT -a $DIR/$tdir/$tfile || error "$tdir/$file is not removed"
183 run_test 2 "mkdir; touch; rmdir; check file ===================="
186 test_mkdir -p $DIR/$tdir || error "mkdir $tdir failed"
187 $CHECKSTAT -t dir $DIR/$tdir || error "$tdir is not a directory"
188 touch $DIR/$tdir/$tfile
189 $CHECKSTAT -t file $DIR/$tdir/$tfile || error "$tdir/$tfile not a file"
191 $CHECKSTAT -a $DIR/$tdir || error "$tdir is not removed"
193 run_test 3 "mkdir; touch; rmdir; check dir ====================="
195 # LU-4471 - failed rmdir on remote directories still removes directory on MDT0
199 test_mkdir $DIR/$tdir ||
200 error "Create remote directory failed"
202 touch $DIR/$tdir/$tfile ||
203 error "Create file under remote directory failed"
206 error "Expect error removing in-use dir $DIR/$tdir"
208 test -d $DIR/$tdir || error "Remote directory disappeared"
210 rm -rf $DIR/$tdir || error "remove remote dir error"
212 run_test 4 "mkdir; touch dir/file; rmdir; checkdir (expect error)"
215 test_mkdir -p $DIR/$tdir || error "mkdir $tdir failed"
216 test_mkdir $DIR/$tdir/d2 || error "mkdir $tdir/d2 failed"
217 chmod 0707 $DIR/$tdir/d2 || error "chmod 0707 $tdir/d2 failed"
218 $CHECKSTAT -t dir -p 0707 $DIR/$tdir/d2 || error "$tdir/d2 not mode 707"
219 $CHECKSTAT -t dir $DIR/$tdir/d2 || error "$tdir/d2 is not a directory"
221 run_test 5 "mkdir .../d5 .../d5/d2; chmod .../d5/d2 ============"
224 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
225 chmod 0666 $DIR/$tfile || error "chmod 0666 $tfile failed"
226 $CHECKSTAT -t file -p 0666 -u \#$UID $DIR/$tfile ||
227 error "$tfile does not have perm 0666 or UID $UID"
228 $RUNAS chmod 0444 $DIR/$tfile && error "chmod $tfile worked on UID $UID"
229 $CHECKSTAT -t file -p 0666 -u \#$UID $DIR/$tfile ||
230 error "$tfile should be 0666 and owned by UID $UID"
232 run_test 6a "touch f6a; chmod f6a; $RUNAS chmod f6a (should return error) =="
235 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID" && return
237 chown $RUNAS_ID $DIR/$tfile || error "chown $RUNAS_ID $file failed"
238 $CHECKSTAT -t file -u \#$RUNAS_ID $DIR/$tfile ||
239 error "$tfile should be owned by UID $RUNAS_ID"
240 $RUNAS chown $UID $DIR/$tfile && error "chown $UID $file succeeded"
241 $CHECKSTAT -t file -u \#$RUNAS_ID $DIR/$tfile ||
242 error "$tfile should be owned by UID $RUNAS_ID"
244 run_test 6c "touch f6c; chown f6c; $RUNAS chown f6c (should return error) =="
247 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID" && return
249 chgrp $RUNAS_ID $DIR/$tfile || error "chgrp $RUNAS_ID $file failed"
250 $CHECKSTAT -t file -u \#$UID -g \#$RUNAS_ID $DIR/$tfile ||
251 error "$tfile should be owned by GID $UID"
252 $RUNAS chgrp $UID $DIR/$tfile && error "chgrp $UID $file succeeded"
253 $CHECKSTAT -t file -u \#$UID -g \#$RUNAS_ID $DIR/$tfile ||
254 error "$tfile should be owned by UID $UID and GID $RUNAS_ID"
256 run_test 6e "touch f6e; chgrp f6e; $RUNAS chgrp f6e (should return error) =="
259 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID" && return
260 test_mkdir $DIR/$tdir || error "mkdir $tfile failed"
261 chmod 777 $DIR/$tdir || error "chmod 0777 $tdir failed"
262 $RUNAS mkdir $DIR/$tdir/d || error "mkdir $tdir/d failed"
263 chmod g+s $DIR/$tdir/d || error "chmod g+s $tdir/d failed"
264 test_mkdir $DIR/$tdir/d/subdir || error "mkdir $tdir/d/subdir failed"
265 $CHECKSTAT -g \#$RUNAS_GID $DIR/$tdir/d/subdir ||
266 error "$tdir/d/subdir should be GID $RUNAS_GID"
268 run_test 6g "Is new dir in sgid dir inheriting group?"
270 test_6h() { # bug 7331
271 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID" && return
272 touch $DIR/$tfile || error "touch failed"
273 chown $RUNAS_ID:$RUNAS_GID $DIR/$tfile || error "initial chown failed"
274 $RUNAS -G$RUNAS_GID chown $RUNAS_ID:0 $DIR/$tfile &&
275 error "chown $RUNAS_ID:0 $tfile worked as GID $RUNAS_GID"
276 $CHECKSTAT -t file -u \#$RUNAS_ID -g \#$RUNAS_GID $DIR/$tfile ||
277 error "$tdir/$tfile should be UID $RUNAS_UID GID $RUNAS_GID"
279 run_test 6h "$RUNAS chown RUNAS_ID.0 .../f6h (should return error)"
282 test_mkdir $DIR/$tdir
283 $MCREATE $DIR/$tdir/$tfile
284 chmod 0666 $DIR/$tdir/$tfile
285 $CHECKSTAT -t file -p 0666 $DIR/$tdir/$tfile ||
286 error "$tdir/$tfile should be mode 0666"
288 run_test 7a "mkdir .../d7; mcreate .../d7/f; chmod .../d7/f ===="
291 if [ ! -d $DIR/$tdir ]; then
292 test_mkdir $DIR/$tdir
294 $MCREATE $DIR/$tdir/$tfile
295 echo -n foo > $DIR/$tdir/$tfile
296 [ "$(cat $DIR/$tdir/$tfile)" = "foo" ] || error "$tdir/$tfile not 'foo'"
297 $CHECKSTAT -t file -s 3 $DIR/$tdir/$tfile || error "$tfile size not 3"
299 run_test 7b "mkdir .../d7; mcreate d7/f2; echo foo > d7/f2 ====="
302 test_mkdir $DIR/$tdir
303 touch $DIR/$tdir/$tfile
304 chmod 0666 $DIR/$tdir/$tfile
305 $CHECKSTAT -t file -p 0666 $DIR/$tdir/$tfile ||
306 error "$tfile mode not 0666"
308 run_test 8 "mkdir .../d8; touch .../d8/f; chmod .../d8/f ======="
311 test_mkdir $DIR/$tdir
312 test_mkdir $DIR/$tdir/d2
313 test_mkdir $DIR/$tdir/d2/d3
314 $CHECKSTAT -t dir $DIR/$tdir/d2/d3 || error "$tdir/d2/d3 not a dir"
316 run_test 9 "mkdir .../d9 .../d9/d2 .../d9/d2/d3 ================"
319 test_mkdir $DIR/$tdir
320 test_mkdir $DIR/$tdir/d2
321 touch $DIR/$tdir/d2/$tfile
322 $CHECKSTAT -t file $DIR/$tdir/d2/$tfile ||
323 error "$tdir/d2/$tfile not a file"
325 run_test 10 "mkdir .../d10 .../d10/d2; touch .../d10/d2/f ======"
328 test_mkdir $DIR/$tdir
329 test_mkdir $DIR/$tdir/d2
330 chmod 0666 $DIR/$tdir/d2
331 chmod 0705 $DIR/$tdir/d2
332 $CHECKSTAT -t dir -p 0705 $DIR/$tdir/d2 ||
333 error "$tdir/d2 mode not 0705"
335 run_test 11 "mkdir .../d11 d11/d2; chmod .../d11/d2 ============"
338 test_mkdir $DIR/$tdir
339 touch $DIR/$tdir/$tfile
340 chmod 0666 $DIR/$tdir/$tfile
341 chmod 0654 $DIR/$tdir/$tfile
342 $CHECKSTAT -t file -p 0654 $DIR/$tdir/$tfile ||
343 error "$tdir/d2 mode not 0654"
345 run_test 12 "touch .../d12/f; chmod .../d12/f .../d12/f ========"
348 test_mkdir $DIR/$tdir
349 dd if=/dev/zero of=$DIR/$tdir/$tfile count=10
351 $CHECKSTAT -t file -s 0 $DIR/$tdir/$tfile ||
352 error "$tdir/$tfile size not 0 after truncate"
354 run_test 13 "creat .../d13/f; dd .../d13/f; > .../d13/f ========"
357 test_mkdir $DIR/$tdir
358 touch $DIR/$tdir/$tfile
360 $CHECKSTAT -a $DIR/$tdir/$tfile || error "$tdir/$tfile not removed"
362 run_test 14 "touch .../d14/f; rm .../d14/f; rm .../d14/f ======="
365 test_mkdir $DIR/$tdir
366 touch $DIR/$tdir/$tfile
367 mv $DIR/$tdir/$tfile $DIR/$tdir/${tfile}_2
368 $CHECKSTAT -t file $DIR/$tdir/${tfile}_2 ||
369 error "$tdir/${tfile_2} not a file after rename"
370 rm $DIR/$tdir/${tfile}_2 || error "unlink failed after rename"
372 run_test 15 "touch .../d15/f; mv .../d15/f .../d15/f2 =========="
375 test_mkdir $DIR/$tdir
376 touch $DIR/$tdir/$tfile
377 rm -rf $DIR/$tdir/$tfile
378 $CHECKSTAT -a $DIR/$tdir/$tfile || error "$tdir/$tfile not removed"
380 run_test 16 "touch .../d16/f; rm -rf .../d16/f ================="
383 test_mkdir -p $DIR/$tdir
384 touch $DIR/$tdir/$tfile
385 ln -s $DIR/$tdir/$tfile $DIR/$tdir/l-exist
387 $CHECKSTAT -l $DIR/$tdir/$tfile $DIR/$tdir/l-exist ||
388 error "$tdir/l-exist not a symlink"
389 $CHECKSTAT -f -t f $DIR/$tdir/l-exist ||
390 error "$tdir/l-exist not referencing a file"
391 rm -f $DIR/$tdir/l-exist
392 $CHECKSTAT -a $DIR/$tdir/l-exist || error "$tdir/l-exist not removed"
394 run_test 17a "symlinks: create, remove (real) =================="
397 test_mkdir -p $DIR/$tdir
398 ln -s no-such-file $DIR/$tdir/l-dangle
400 $CHECKSTAT -l no-such-file $DIR/$tdir/l-dangle ||
401 error "$tdir/l-dangle not referencing no-such-file"
402 $CHECKSTAT -fa $DIR/$tdir/l-dangle ||
403 error "$tdir/l-dangle not referencing non-existent file"
404 rm -f $DIR/$tdir/l-dangle
405 $CHECKSTAT -a $DIR/$tdir/l-dangle || error "$tdir/l-dangle not removed"
407 run_test 17b "symlinks: create, remove (dangling) =============="
409 test_17c() { # bug 3440 - don't save failed open RPC for replay
410 test_mkdir -p $DIR/$tdir
411 ln -s foo $DIR/$tdir/$tfile
412 cat $DIR/$tdir/$tfile && error "opened non-existent symlink" || true
414 run_test 17c "symlinks: open dangling (should return error) ===="
417 test_mkdir -p $DIR/$tdir
418 ln -s foo $DIR/$tdir/$tfile
419 touch $DIR/$tdir/$tfile || error "creating to new symlink"
421 run_test 17d "symlinks: create dangling ========================"
424 test_mkdir -p $DIR/$tdir
425 local foo=$DIR/$tdir/$tfile
426 ln -s $foo $foo || error "create symlink failed"
427 ls -l $foo || error "ls -l failed"
428 ls $foo && error "ls not failed" || true
430 run_test 17e "symlinks: create recursive symlink (should return error) ===="
433 test_mkdir -p $DIR/$tdir
434 ln -s 1234567890/2234567890/3234567890/4234567890 $DIR/$tdir/111
435 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890 $DIR/$tdir/222
436 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890 $DIR/$tdir/333
437 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890/9234567890/a234567890/b234567890 $DIR/$tdir/444
438 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890/9234567890/a234567890/b234567890/c234567890/d234567890/f234567890 $DIR/$tdir/555
439 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
442 run_test 17f "symlinks: long and very long symlink name ========================"
444 # str_repeat(S, N) generate a string that is string S repeated N times
449 while [ $((n -= 1)) -ge 0 ]; do
455 # Long symlinks and LU-2241
457 test_mkdir -p $DIR/$tdir
458 local TESTS="59 60 61 4094 4095"
460 # Fix for inode size boundary in 2.1.4
461 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.1.4) ] &&
464 # Patch not applied to 2.2 or 2.3 branches
465 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] &&
466 [ $(lustre_version_code $SINGLEMDS) -le $(version_code 2.3.55) ] &&
469 # skip long symlink name for rhel6.5.
470 # rhel6.5 has a limit (PATH_MAX - sizeof(struct filename))
471 grep -q '6.5' /etc/redhat-release &>/dev/null &&
472 TESTS="59 60 61 4062 4063"
475 local SYMNAME=$(str_repeat 'x' $i)
476 ln -s $SYMNAME $DIR/$tdir/f$i || error "failed $i-char symlink"
477 readlink $DIR/$tdir/f$i || error "failed $i-char readlink"
480 run_test 17g "symlinks: really long symlink name and inode boundaries"
482 test_17h() { #bug 17378
483 remote_mds_nodsh && skip "remote MDS with nodsh" && return
484 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
486 test_mkdir -p $DIR/$tdir
487 if [[ $MDSCOUNT -gt 1 ]]; then
488 mdt_idx=$($LFS getdirstripe -i $DIR/$tdir)
492 $SETSTRIPE -c -1 $DIR/$tdir
493 #define OBD_FAIL_MDS_LOV_PREP_CREATE 0x141
494 do_facet mds$((mdt_idx + 1)) lctl set_param fail_loc=0x80000141
495 touch $DIR/$tdir/$tfile || true
497 run_test 17h "create objects: lov_free_memmd() doesn't lbug"
499 test_17i() { #bug 20018
500 remote_mds_nodsh && skip "remote MDS with nodsh" && return
501 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
502 test_mkdir -c1 $DIR/$tdir
503 local foo=$DIR/$tdir/$tfile
505 if [[ $MDSCOUNT -gt 1 ]]; then
506 mdt_idx=$($LFS getdirstripe -i $DIR/$tdir)
510 ln -s $foo $foo || error "create symlink failed"
511 #define OBD_FAIL_MDS_READLINK_EPROTO 0x143
512 do_facet mds$((mdt_idx + 1)) lctl set_param fail_loc=0x80000143
513 ls -l $foo && error "error not detected"
516 run_test 17i "don't panic on short symlink"
518 test_17k() { #bug 22301
519 [[ -z "$(which rsync 2>/dev/null)" ]] &&
520 skip "no rsync command" && return 0
521 rsync --help | grep -q xattr ||
522 skip_env "$(rsync --version | head -n1) does not support xattrs"
523 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return 0
524 test_mkdir -p $DIR/$tdir
525 test_mkdir -p $DIR/$tdir.new
526 touch $DIR/$tdir/$tfile
527 ln -s $DIR/$tdir/$tfile $DIR/$tdir/$tfile.lnk
528 rsync -av -X $DIR/$tdir/ $DIR/$tdir.new ||
529 error "rsync failed with xattrs enabled"
531 run_test 17k "symlinks: rsync with xattrs enabled ========================="
533 test_17l() { # LU-279
534 [[ -z "$(which getfattr 2>/dev/null)" ]] &&
535 skip "no getfattr command" && return 0
536 test_mkdir -p $DIR/$tdir
537 touch $DIR/$tdir/$tfile
538 ln -s $DIR/$tdir/$tfile $DIR/$tdir/$tfile.lnk
539 for path in "$DIR/$tdir" "$DIR/$tdir/$tfile" "$DIR/$tdir/$tfile.lnk"; do
540 # -h to not follow symlinks. -m '' to list all the xattrs.
541 # grep to remove first line: '# file: $path'.
542 for xattr in `getfattr -hm '' $path 2>/dev/null | grep -v '^#'`;
544 lgetxattr_size_check $path $xattr ||
545 error "lgetxattr_size_check $path $xattr failed"
549 run_test 17l "Ensure lgetxattr's returned xattr size is consistent ========"
553 local short_sym="0123456789"
554 local WDIR=$DIR/${tdir}m
557 remote_mds_nodsh && skip "remote MDS with nodsh" && return
558 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] &&
559 [ $(lustre_version_code $SINGLEMDS) -le $(version_code 2.2.93) ] &&
560 skip "MDS 2.2.0-2.2.93 do not NUL-terminate symlinks" && return
562 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
563 skip "only for ldiskfs MDT" && return 0
565 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
569 # create a long symlink file
570 for ((i = 0; i < 4; ++i)); do
571 long_sym=${long_sym}${long_sym}
574 echo "create 512 short and long symlink files under $WDIR"
575 for ((i = 0; i < 256; ++i)); do
576 ln -sf ${long_sym}"a5a5" $WDIR/long-$i
577 ln -sf ${short_sym}"a5a5" $WDIR/short-$i
583 wait_delete_completed
585 echo "recreate the 512 symlink files with a shorter string"
586 for ((i = 0; i < 512; ++i)); do
587 # rewrite the symlink file with a shorter string
588 ln -sf ${long_sym} $WDIR/long-$i || error "long_sym failed"
589 ln -sf ${short_sym} $WDIR/short-$i || error "short_sym failed"
592 local mds_index=$(($($LFS getstripe -M $WDIR) + 1))
593 local devname=$(mdsdevname $mds_index)
595 echo "stop and checking mds${mds_index}:"
596 # e2fsck should not return error
598 run_e2fsck $(facet_active_host mds${mds_index}) $devname -n
601 start mds${mds_index} $devname $MDS_MOUNT_OPTS || error "start failed"
602 df $MOUNT > /dev/null 2>&1
604 error "e2fsck detected error for short/long symlink: rc=$rc"
606 run_test 17m "run e2fsck against MDT which contains short/long symlink"
608 check_fs_consistency_17n() {
612 # create/unlink in 17n only change 2 MDTs(MDT1/MDT2),
613 # so it only check MDT1/MDT2 instead of all of MDTs.
614 for mdt_index in 1 2; do
615 local devname=$(mdsdevname $mdt_index)
616 # e2fsck should not return error
618 run_e2fsck $(facet_active_host mds$mdt_index) $devname -n ||
621 start mds${mdt_index} $devname $MDS_MOUNT_OPTS ||
622 error "mount mds$mdt_index failed"
623 df $MOUNT > /dev/null 2>&1
631 remote_mds_nodsh && skip "remote MDS with nodsh" && return
632 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] &&
633 [ $(lustre_version_code $SINGLEMDS) -le $(version_code 2.2.93) ] &&
634 skip "MDS 2.2.0-2.2.93 do not NUL-terminate symlinks" && return
636 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
637 skip "only for ldiskfs MDT" && return 0
639 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 2 MDTs" && return
641 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
643 test_mkdir $DIR/$tdir
644 for ((i=0; i<10; i++)); do
645 $LFS mkdir -i1 -c2 $DIR/$tdir/remote_dir_${i} ||
646 error "create remote dir error $i"
647 createmany -o $DIR/$tdir/remote_dir_${i}/f 10 ||
648 error "create files under remote dir failed $i"
651 check_fs_consistency_17n ||
652 error "e2fsck report error after create files under remote dir"
654 for ((i = 0; i < 10; i++)); do
655 rm -rf $DIR/$tdir/remote_dir_${i} ||
656 error "destroy remote dir error $i"
659 check_fs_consistency_17n ||
660 error "e2fsck report error after unlink files under remote dir"
662 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.50) ] &&
663 skip "lustre < 2.4.50 does not support migrate mv " && return
665 for ((i = 0; i < 10; i++)); do
666 mkdir -p $DIR/$tdir/remote_dir_${i}
667 createmany -o $DIR/$tdir/remote_dir_${i}/f 10 ||
668 error "create files under remote dir failed $i"
669 $LFS migrate --mdt-index 1 $DIR/$tdir/remote_dir_${i} ||
670 error "migrate remote dir error $i"
672 check_fs_consistency_17n || error "e2fsck report error after migration"
674 for ((i = 0; i < 10; i++)); do
675 rm -rf $DIR/$tdir/remote_dir_${i} ||
676 error "destroy remote dir error $i"
679 check_fs_consistency_17n || error "e2fsck report error after unlink"
681 run_test 17n "run e2fsck against master/slave MDT which contains remote dir"
684 remote_mds_nodsh && skip "remote MDS with nodsh" && return
685 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.3.64) ] &&
686 skip "Need MDS version at least 2.3.64" && return
688 local WDIR=$DIR/${tdir}o
693 mdt_index=$($LFS getstripe -M $WDIR)
694 mdt_index=$((mdt_index+1))
698 #fail mds will wait the failover finish then set
699 #following fail_loc to avoid interfer the recovery process.
702 #define OBD_FAIL_OSD_LMA_INCOMPAT 0x194
703 do_facet mds${mdt_index} lctl set_param fail_loc=0x194
704 ls -l $WDIR/$tfile && rc=1
705 do_facet mds${mdt_index} lctl set_param fail_loc=0
706 [[ $rc -ne 0 ]] && error "stat file should fail"
709 run_test 17o "stat file with incompat LMA feature"
712 touch $DIR/$tfile || error "Failed to touch $DIR/$tfile: $?"
713 ls $DIR || error "Failed to ls $DIR: $?"
715 run_test 18 "touch .../f ; ls ... =============================="
721 $CHECKSTAT -a $DIR/$tfile || error "$tfile was not removed"
723 run_test 19a "touch .../f19 ; ls -l ... ; rm .../f19 ==========="
726 ls -l $DIR/$tfile && error "ls -l $tfile failed"|| true
728 run_test 19b "ls -l .../f19 (should return error) =============="
731 [ $RUNAS_ID -eq $UID ] &&
732 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
733 $RUNAS touch $DIR/$tfile && error "create non-root file failed" || true
735 run_test 19c "$RUNAS touch .../f19 (should return error) =="
738 cat $DIR/f19 && error || true
740 run_test 19d "cat .../f19 (should return error) =============="
752 $CHECKSTAT -a $DIR/$tfile || error "$tfile was not removed"
754 run_test 20 "touch .../f ; ls -l ... ==========================="
757 test_mkdir -p $DIR/$tdir
758 [ -f $DIR/$tdir/dangle ] && rm -f $DIR/$tdir/dangle
759 ln -s dangle $DIR/$tdir/link
760 echo foo >> $DIR/$tdir/link
761 cat $DIR/$tdir/dangle
762 $CHECKSTAT -t link $DIR/$tdir/link || error "$tdir/link not a link"
763 $CHECKSTAT -f -t file $DIR/$tdir/link ||
764 error "$tdir/link not linked to a file"
766 run_test 21 "write to dangling link ============================"
770 test_mkdir -p $DIR/$tdir
771 chown $RUNAS_ID:$RUNAS_GID $WDIR
772 (cd $WDIR || error "cd $WDIR failed";
773 $RUNAS tar cf - /etc/hosts /etc/sysconfig/network | \
775 ls -lR $WDIR/etc || error "ls -lR $WDIR/etc failed"
776 $CHECKSTAT -t dir $WDIR/etc || error "checkstat -t dir failed"
777 $CHECKSTAT -u \#$RUNAS_ID -g \#$RUNAS_GID $WDIR/etc || error "checkstat -u failed"
779 run_test 22 "unpack tar archive as non-root user ==============="
783 test_mkdir -p $DIR/$tdir
784 local file=$DIR/$tdir/$tfile
786 openfile -f O_CREAT:O_EXCL $file || error "$file create failed"
787 openfile -f O_CREAT:O_EXCL $file &&
788 error "$file recreate succeeded" || true
790 run_test 23a "O_CREAT|O_EXCL in subdir =========================="
792 test_23b() { # bug 18988
793 test_mkdir -p $DIR/$tdir
794 local file=$DIR/$tdir/$tfile
797 echo foo > $file || error "write filed"
798 echo bar >> $file || error "append filed"
799 $CHECKSTAT -s 8 $file || error "wrong size"
802 run_test 23b "O_APPEND check =========================="
806 echo '-- same directory rename'
807 test_mkdir $DIR/$tdir
808 touch $DIR/$tdir/$tfile.1
809 mv $DIR/$tdir/$tfile.1 $DIR/$tdir/$tfile.2
810 $CHECKSTAT -t file $DIR/$tdir/$tfile.2 || error "$tfile.2 not a file"
812 run_test 24a "rename file to non-existent target"
815 test_mkdir $DIR/$tdir
816 touch $DIR/$tdir/$tfile.{1,2}
817 mv $DIR/$tdir/$tfile.1 $DIR/$tdir/$tfile.2
818 $CHECKSTAT -a $DIR/$tdir/$tfile.1 || error "$tfile.1 exists"
819 $CHECKSTAT -t file $DIR/$tdir/$tfile.2 || error "$tfile.2 not a file"
821 run_test 24b "rename file to existing target"
824 test_mkdir $DIR/$tdir
825 test_mkdir $DIR/$tdir/d$testnum.1
826 mv $DIR/$tdir/d$testnum.1 $DIR/$tdir/d$testnum.2
827 $CHECKSTAT -a $DIR/$tdir/d$testnum.1 || error "d$testnum.1 exists"
828 $CHECKSTAT -t dir $DIR/$tdir/d$testnum.2 || error "d$testnum.2 not dir"
830 run_test 24c "rename directory to non-existent target"
833 test_mkdir -c1 $DIR/$tdir
834 test_mkdir -c1 $DIR/$tdir/d$testnum.1
835 test_mkdir -c1 $DIR/$tdir/d$testnum.2
836 mrename $DIR/$tdir/d$testnum.1 $DIR/$tdir/d$testnum.2
837 $CHECKSTAT -a $DIR/$tdir/d$testnum.1 || error "d$testnum.1 exists"
838 $CHECKSTAT -t dir $DIR/$tdir/d$testnum.2 || error "d$testnum.2 not dir"
840 run_test 24d "rename directory to existing target"
843 echo '-- cross directory renames --'
847 mv $DIR/R5a/f $DIR/R5b/g
848 $CHECKSTAT -a $DIR/R5a/f || error
849 $CHECKSTAT -t file $DIR/R5b/g || error
851 run_test 24e "touch .../R5a/f; rename .../R5a/f .../R5b/g ======"
856 touch $DIR/R6a/f $DIR/R6b/g
857 mv $DIR/R6a/f $DIR/R6b/g
858 $CHECKSTAT -a $DIR/R6a/f || error
859 $CHECKSTAT -t file $DIR/R6b/g || error
861 run_test 24f "touch .../R6a/f R6b/g; mv .../R6a/f .../R6b/g ===="
866 test_mkdir $DIR/R7a/d
867 mv $DIR/R7a/d $DIR/R7b/e
868 $CHECKSTAT -a $DIR/R7a/d || error
869 $CHECKSTAT -t dir $DIR/R7b/e || error
871 run_test 24g "mkdir .../R7{a,b}/d; mv .../R7a/d .../R7b/e ======"
874 test_mkdir -c1 $DIR/R8a
875 test_mkdir -c1 $DIR/R8b
876 test_mkdir -c1 $DIR/R8a/d
877 test_mkdir -c1 $DIR/R8b/e
878 mrename $DIR/R8a/d $DIR/R8b/e
879 $CHECKSTAT -a $DIR/R8a/d || error
880 $CHECKSTAT -t dir $DIR/R8b/e || error
882 run_test 24h "mkdir .../R8{a,b}/{d,e}; rename .../R8a/d .../R8b/e"
885 echo "-- rename error cases"
889 mrename $DIR/R9/f $DIR/R9/a
890 $CHECKSTAT -t file $DIR/R9/f || error
891 $CHECKSTAT -t dir $DIR/R9/a || error
892 $CHECKSTAT -a $DIR/R9/a/f || error
894 run_test 24i "rename file to dir error: touch f ; mkdir a ; rename f a"
898 mrename $DIR/R10/f $DIR/R10/g
899 $CHECKSTAT -t dir $DIR/R10 || error
900 $CHECKSTAT -a $DIR/R10/f || error
901 $CHECKSTAT -a $DIR/R10/g || error
903 run_test 24j "source does not exist ============================"
907 test_mkdir $DIR/R11a/d
909 mv $DIR/R11a/f $DIR/R11a/d
910 $CHECKSTAT -a $DIR/R11a/f || error
911 $CHECKSTAT -t file $DIR/R11a/d/f || error
913 run_test 24k "touch .../R11a/f; mv .../R11a/f .../R11a/d ======="
915 # bug 2429 - rename foo foo foo creates invalid file
918 $MULTIOP $f OcNs || error
920 run_test 24l "Renaming a file to itself ========================"
924 $MULTIOP $f OcLN ${f}2 ${f}2 || error "link ${f}2 ${f}2 failed"
925 # on ext3 this does not remove either the source or target files
926 # though the "expected" operation would be to remove the source
927 $CHECKSTAT -t file ${f} || error "${f} missing"
928 $CHECKSTAT -t file ${f}2 || error "${f}2 missing"
930 run_test 24m "Renaming a file to a hard link to itself ========="
934 # this stats the old file after it was renamed, so it should fail
938 $CHECKSTAT ${f}.rename
941 run_test 24n "Statting the old file after renaming (Posix rename 2)"
944 test_mkdir -p $DIR/d24o
945 rename_many -s random -v -n 10 $DIR/d24o
947 run_test 24o "rename of files during htree split ==============="
952 DIRINO=`ls -lid $DIR/R12a | awk '{ print $1 }'`
953 mrename $DIR/R12a $DIR/R12b
954 $CHECKSTAT -a $DIR/R12a || error
955 $CHECKSTAT -t dir $DIR/R12b || error
956 DIRINO2=`ls -lid $DIR/R12b | awk '{ print $1 }'`
957 [ "$DIRINO" = "$DIRINO2" ] || error "R12a $DIRINO != R12b $DIRINO2"
959 run_test 24p "mkdir .../R12{a,b}; rename .../R12a .../R12b"
961 cleanup_multiop_pause() {
967 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
970 local DIRINO=$(ls -lid $DIR/R13a | awk '{ print $1 }')
971 multiop_bg_pause $DIR/R13b D_c || error "multiop failed to start"
974 trap cleanup_multiop_pause EXIT
975 mrename $DIR/R13a $DIR/R13b
976 $CHECKSTAT -a $DIR/R13a || error "R13a still exists"
977 $CHECKSTAT -t dir $DIR/R13b || error "R13b does not exist"
978 local DIRINO2=$(ls -lid $DIR/R13b | awk '{ print $1 }')
979 [ "$DIRINO" = "$DIRINO2" ] || error "R13a $DIRINO != R13b $DIRINO2"
980 cleanup_multiop_pause
981 wait $MULTIPID || error "multiop close failed"
983 run_test 24q "mkdir .../R13{a,b}; open R13b rename R13a R13b ==="
985 test_24r() { #bug 3789
987 test_mkdir $DIR/R14a/b
988 mrename $DIR/R14a $DIR/R14a/b && error "rename to subdir worked!"
989 $CHECKSTAT -t dir $DIR/R14a || error "$DIR/R14a missing"
990 $CHECKSTAT -t dir $DIR/R14a/b || error "$DIR/R14a/b missing"
992 run_test 24r "mkdir .../R14a/b; rename .../R14a .../R14a/b ====="
996 test_mkdir $DIR/R15a/b
997 test_mkdir $DIR/R15a/b/c
998 mrename $DIR/R15a $DIR/R15a/b/c && error "rename to sub-subdir worked!"
999 $CHECKSTAT -t dir $DIR/R15a || error "$DIR/R15a missing"
1000 $CHECKSTAT -t dir $DIR/R15a/b/c || error "$DIR/R15a/b/c missing"
1002 run_test 24s "mkdir .../R15a/b/c; rename .../R15a .../R15a/b/c ="
1004 test_mkdir $DIR/R16a
1005 test_mkdir $DIR/R16a/b
1006 test_mkdir $DIR/R16a/b/c
1007 mrename $DIR/R16a/b/c $DIR/R16a && error "rename to sub-subdir worked!"
1008 $CHECKSTAT -t dir $DIR/R16a || error "$DIR/R16a missing"
1009 $CHECKSTAT -t dir $DIR/R16a/b/c || error "$DIR/R16a/b/c missing"
1011 run_test 24t "mkdir .../R16a/b/c; rename .../R16a/b/c .../R16a ="
1013 test_24u() { # bug12192
1014 $MULTIOP $DIR/$tfile C2w$((2048 * 1024))c || error
1015 $CHECKSTAT -s $((2048 * 1024)) $DIR/$tfile || error "wrong file size"
1017 run_test 24u "create stripe file"
1023 simple_cleanup_common() {
1026 wait_delete_completed
1029 max_pages_per_rpc() {
1030 $LCTL get_param -n mdc.*.max_pages_per_rpc | head -n1
1034 local NRFILES=100000
1035 local FREE_INODES=$(mdt_free_inodes 0)
1036 [[ $FREE_INODES -lt $NRFILES ]] &&
1037 skip "not enough free inodes $FREE_INODES required $NRFILES" &&
1040 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1041 trap simple_cleanup_common EXIT
1043 # Performance issue on ZFS see LU-4072 (c.f. LU-2887)
1044 [ $(facet_fstype $SINGLEMDS) = "zfs" ] && NRFILES=10000
1046 test_mkdir -p $DIR/$tdir
1047 createmany -m $DIR/$tdir/$tfile $NRFILES
1049 cancel_lru_locks mdc
1050 lctl set_param mdc.*.stats clear
1052 ls $DIR/$tdir >/dev/null || error "error in listing large dir"
1054 # LU-5 large readdir
1055 # DIRENT_SIZE = 32 bytes for sizeof(struct lu_dirent) +
1056 # 8 bytes for name(filename is mostly 5 in this test) +
1057 # 8 bytes for luda_type
1058 # take into account of overhead in lu_dirpage header and end mark in
1059 # each page, plus one in RPC_NUM calculation.
1061 RPC_SIZE=$(($(max_pages_per_rpc) * $(page_size)))
1062 RPC_NUM=$(((NRFILES * DIRENT_SIZE + RPC_SIZE - 1) / RPC_SIZE + 1))
1063 mds_readpage=$(lctl get_param mdc.*MDT0000*.stats |
1064 awk '/^mds_readpage/ {print $2}')
1065 [[ $mds_readpage -gt $RPC_NUM ]] &&
1066 error "large readdir doesn't take effect"
1068 simple_cleanup_common
1070 run_test 24v "list directory with large files (handle hash collision, bug: 17560)"
1072 test_24w() { # bug21506
1074 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=4096 || return 1
1075 dd if=/dev/zero bs=$SZ1 count=1 >> $DIR/$tfile || return 2
1076 dd if=$DIR/$tfile of=$DIR/${tfile}_left bs=1M skip=4097 || return 3
1077 SZ2=`ls -l $DIR/${tfile}_left | awk '{print $5}'`
1078 [[ "$SZ1" -eq "$SZ2" ]] ||
1079 error "Error reading at the end of the file $tfile"
1081 run_test 24w "Reading a file larger than 4Gb"
1084 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 2 MDTs" && return
1086 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.56) ]] &&
1087 skip "Need MDS version at least 2.7.56" && return
1089 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1091 local remote_dir=$DIR/$tdir/remote_dir
1093 test_mkdir -p $DIR/$tdir
1094 $LFS mkdir -i $MDTIDX $remote_dir ||
1095 error "create remote directory failed"
1097 test_mkdir -p $DIR/$tdir/src_dir
1098 touch $DIR/$tdir/src_file
1099 test_mkdir -p $remote_dir/tgt_dir
1100 touch $remote_dir/tgt_file
1102 mrename $DIR/$tdir/src_dir $remote_dir/tgt_dir ||
1103 error "rename dir cross MDT failed!"
1105 mrename $DIR/$tdir/src_file $remote_dir/tgt_file ||
1106 error "rename file cross MDT failed!"
1108 touch $DIR/$tdir/ln_file
1109 ln $DIR/$tdir/ln_file $remote_dir/ln_name ||
1110 error "ln file cross MDT failed"
1112 rm -rf $DIR/$tdir || error "Can not delete directories"
1114 run_test 24x "cross MDT rename/link"
1117 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 2 MDTs" && return
1118 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1120 local remote_dir=$DIR/$tdir/remote_dir
1122 test_mkdir -p $DIR/$tdir
1123 $LFS mkdir -i $MDTIDX $remote_dir ||
1124 error "create remote directory failed"
1126 test_mkdir -p $remote_dir/src_dir
1127 touch $remote_dir/src_file
1128 test_mkdir -p $remote_dir/tgt_dir
1129 touch $remote_dir/tgt_file
1131 mrename $remote_dir/src_dir $remote_dir/tgt_dir ||
1132 error "rename subdir in the same remote dir failed!"
1134 mrename $remote_dir/src_file $remote_dir/tgt_file ||
1135 error "rename files in the same remote dir failed!"
1137 ln $remote_dir/tgt_file $remote_dir/tgt_file1 ||
1138 error "link files in the same remote dir failed!"
1140 rm -rf $DIR/$tdir || error "Can not delete directories"
1142 run_test 24y "rename/link on the same dir should succeed"
1144 test_24A() { # LU-3182
1148 test_mkdir -p $DIR/$tdir
1149 createmany -m $DIR/$tdir/$tfile $NFILES
1150 local t=$(ls $DIR/$tdir | wc -l)
1151 local u=$(ls $DIR/$tdir | sort -u | wc -l)
1152 local v=$(ls -ai $DIR/$tdir | sort -u | wc -l)
1153 if [ $t -ne $NFILES -o $u -ne $NFILES -o $v -ne $((NFILES + 2)) ] ; then
1154 error "Expected $NFILES files, got $t ($u unique $v .&..)"
1157 rm -rf $DIR/$tdir || error "Can not delete directories"
1159 run_test 24A "readdir() returns correct number of entries."
1161 test_24B() { # LU-4805
1162 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
1165 test_mkdir $DIR/$tdir
1166 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR/$tdir/striped_dir ||
1167 error "create striped dir failed"
1169 count=$(ls -ai $DIR/$tdir/striped_dir | wc -l)
1170 [ $count -eq 2 ] || error "Expected 2, got $count"
1172 touch $DIR/$tdir/striped_dir/a
1174 count=$(ls -ai $DIR/$tdir/striped_dir | wc -l)
1175 [ $count -eq 3 ] || error "Expected 3, got $count"
1177 touch $DIR/$tdir/striped_dir/.f
1179 count=$(ls -ai $DIR/$tdir/striped_dir | wc -l)
1180 [ $count -eq 4 ] || error "Expected 4, got $count"
1182 rm -rf $DIR/$tdir || error "Can not delete directories"
1184 run_test 24B "readdir for striped dir return correct number of entries"
1187 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
1193 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR/$tdir/d0/striped_dir ||
1194 error "create striped dir failed"
1196 cd $DIR/$tdir/d0/striped_dir
1198 local d0_ino=$(ls -i -l -a $DIR/$tdir | grep "d0" | awk '{print $1}')
1199 local d1_ino=$(ls -i -l -a $DIR/$tdir | grep "d1" | awk '{print $1}')
1200 local parent_ino=$(ls -i -l -a | grep "\.\." | awk '{print $1}')
1202 [ "$d0_ino" = "$parent_ino" ] ||
1203 error ".. wrong, expect $d0_ino, get $parent_ino"
1205 mv $DIR/$tdir/d0/striped_dir $DIR/$tdir/d1/ ||
1206 error "mv striped dir failed"
1208 parent_ino=$(ls -i -l -a | grep "\.\." | awk '{print $1}')
1210 [ "$d1_ino" = "$parent_ino" ] ||
1211 error ".. wrong after mv, expect $d1_ino, get $parent_ino"
1213 run_test 24C "check .. in striped dir"
1215 test_24D() { # LU-6101
1220 createmany -m $DIR/$tdir/$tfile $NFILES
1221 local t=$(ls $DIR/$tdir | wc -l)
1222 local u=$(ls $DIR/$tdir | sort -u | wc -l)
1223 local v=$(ls -ai $DIR/$tdir | sort -u | wc -l)
1224 if [ $t -ne $NFILES -o $u -ne $NFILES -o $v -ne $((NFILES + 2)) ] ; then
1225 error "Expected $NFILES files, got $t ($u unique $v .&..)"
1228 rm -rf $DIR/$tdir || error "Can not delete directories"
1230 run_test 24D "readdir() returns correct number of entries after cursor reload"
1233 [[ $MDSCOUNT -lt 4 ]] && skip "needs >= 4 MDTs" && return
1234 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1237 mkdir $DIR/$tdir/src_dir
1238 $LFS mkdir -i 1 $DIR/$tdir/src_dir/src_child ||
1239 error "create remote source failed"
1241 touch $DIR/$tdir/src_dir/src_child/a
1243 $LFS mkdir -i 2 $DIR/$tdir/tgt_dir ||
1244 error "create remote target dir failed"
1246 $LFS mkdir -i 3 $DIR/$tdir/tgt_dir/tgt_child ||
1247 error "create remote target child failed"
1249 mrename $DIR/$tdir/src_dir/src_child $DIR/$tdir/tgt_dir/tgt_child ||
1250 error "rename dir cross MDT failed!"
1254 $CHECKSTAT -t dir $DIR/$tdir/src_dir/src_child &&
1255 error "src_child still exists after rename"
1257 $CHECKSTAT -t file $DIR/$tdir/tgt_dir/tgt_child/a ||
1258 error "missing file(a) after rename"
1260 rm -rf $DIR/$tdir || error "Can not delete directories"
1262 run_test 24E "cross MDT rename/link"
1265 echo '== symlink sanity ============================================='
1269 touch $DIR/s25/foo || error
1271 run_test 25a "create file in symlinked directory ==============="
1274 [ ! -d $DIR/d25 ] && test_25a
1275 $CHECKSTAT -t file $DIR/s25/foo || error
1277 run_test 25b "lookup file in symlinked directory ==============="
1281 test_mkdir $DIR/d26/d26-2
1282 ln -s d26/d26-2 $DIR/s26
1283 touch $DIR/s26/foo || error
1285 run_test 26a "multiple component symlink ======================="
1288 test_mkdir -p $DIR/d26b/d26-2
1289 ln -s d26b/d26-2/foo $DIR/s26-2
1290 touch $DIR/s26-2 || error
1292 run_test 26b "multiple component symlink at end of lookup ======"
1295 test_mkdir $DIR/d26.2
1296 touch $DIR/d26.2/foo
1297 ln -s d26.2 $DIR/s26.2-1
1298 ln -s s26.2-1 $DIR/s26.2-2
1299 ln -s s26.2-2 $DIR/s26.2-3
1300 chmod 0666 $DIR/s26.2-3/foo
1302 run_test 26c "chain of symlinks ================================"
1304 # recursive symlinks (bug 439)
1306 ln -s d26-3/foo $DIR/d26-3
1308 run_test 26d "create multiple component recursive symlink ======"
1311 [ ! -h $DIR/d26-3 ] && test_26d
1314 run_test 26e "unlink multiple component recursive symlink ======"
1316 # recursive symlinks (bug 7022)
1318 test_mkdir -p $DIR/$tdir
1319 test_mkdir $DIR/$tdir/$tfile || error "mkdir $DIR/$tdir/$tfile failed"
1320 cd $DIR/$tdir/$tfile || error "cd $DIR/$tdir/$tfile failed"
1321 test_mkdir -p lndir/bar1 || error "mkdir lndir/bar1 failed"
1322 test_mkdir $DIR/$tdir/$tfile/$tfile || error "mkdir $tfile failed"
1323 cd $tfile || error "cd $tfile failed"
1324 ln -s .. dotdot || error "ln dotdot failed"
1325 ln -s dotdot/lndir lndir || error "ln lndir failed"
1326 cd $DIR/$tdir || error "cd $DIR/$tdir failed"
1327 output=`ls $tfile/$tfile/lndir/bar1`
1328 [ "$output" = bar1 ] && error "unexpected output"
1329 rm -r $tfile || error "rm $tfile failed"
1330 $CHECKSTAT -a $DIR/$tfile || error "$tfile not gone"
1332 run_test 26f "rm -r of a directory which has recursive symlink ="
1335 echo '== stripe sanity =============================================='
1336 test_mkdir -p $DIR/d27 || error "mkdir failed"
1338 $SETSTRIPE -c 1 $DIR/d27/f0 || error "setstripe failed"
1339 $CHECKSTAT -t file $DIR/d27/f0 || error "checkstat failed"
1340 log "== test_27a: write to one stripe file ========================="
1341 cp /etc/hosts $DIR/d27/f0 || error
1343 run_test 27a "one stripe file =================================="
1346 [[ $OSTCOUNT -lt 2 ]] && skip_env "skipping 2-stripe test" && return
1347 test_mkdir -p $DIR/d27
1348 $SETSTRIPE -c 2 $DIR/d27/f01 || error "setstripe failed"
1349 $GETSTRIPE -c $DIR/d27/f01
1350 [ $($GETSTRIPE -c $DIR/d27/f01) -eq 2 ] ||
1351 error "two-stripe file doesn't have two stripes"
1353 dd if=/dev/zero of=$DIR/d27/f01 bs=4k count=4 || error "dd failed"
1355 run_test 27b "create and write to two stripe file"
1358 test_mkdir -p $DIR/d27
1359 $SETSTRIPE -c 0 -i -1 -S 0 $DIR/d27/fdef || error "setstripe failed"
1360 $CHECKSTAT -t file $DIR/d27/fdef || error "checkstat failed"
1361 dd if=/dev/zero of=$DIR/d27/fdef bs=4k count=4 || error
1363 run_test 27d "create file with default settings ================"
1366 # LU-5839 adds check for existed layout before setting it
1367 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.56) ]] &&
1368 skip "Need MDS version at least 2.7.56" && return
1369 test_mkdir -p $DIR/d27
1370 $SETSTRIPE -c 2 $DIR/d27/f12 || error "setstripe failed"
1371 $SETSTRIPE -c 2 $DIR/d27/f12 && error "setstripe succeeded twice"
1372 $CHECKSTAT -t file $DIR/d27/f12 || error "checkstat failed"
1374 run_test 27e "setstripe existing file (should return error) ======"
1377 test_mkdir $DIR/$tdir
1378 $SETSTRIPE -S 100 -i 0 -c 1 $DIR/$tdir/$tfile &&
1379 error "$SETSTRIPE $DIR/$tdir/$tfile failed"
1380 $CHECKSTAT -t file $DIR/$tdir/$tfile &&
1381 error "$CHECKSTAT -t file $DIR/$tdir/$tfile should fail"
1382 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=4k count=4 || error "dd failed"
1383 $GETSTRIPE $DIR/$tdir/$tfile || error "$GETSTRIPE failed"
1385 run_test 27f "setstripe with bad stripe size (should return error)"
1388 test_mkdir -p $DIR/d27
1389 $MCREATE $DIR/d27/fnone || error "mcreate failed"
1390 $GETSTRIPE $DIR/d27/fnone 2>&1 | grep "no stripe info" ||
1391 error "$DIR/d27/fnone has object"
1393 run_test 27g "$GETSTRIPE with no objects"
1396 test_mkdir $DIR/$tdir
1397 touch $DIR/$tdir/$tfile || error "touch failed"
1398 [[ $($GETSTRIPE -c $DIR/$tdir/$tfile) -gt 0 ]] ||
1399 error "missing objects"
1401 run_test 27i "$GETSTRIPE with some objects"
1404 test_mkdir -p $DIR/d27
1405 $SETSTRIPE -i $OSTCOUNT $DIR/d27/f27j && error "setstripe failed"||true
1407 run_test 27j "setstripe with bad stripe offset (should return error)"
1409 test_27k() { # bug 2844
1410 test_mkdir -p $DIR/d27
1412 LL_MAX_BLKSIZE=$((4 * 1024 * 1024))
1413 [ ! -d $DIR/d27 ] && test_mkdir -p $DIR d27
1414 $SETSTRIPE -S 67108864 $FILE || error "setstripe failed"
1415 BLKSIZE=`stat $FILE | awk '/IO Block:/ { print $7 }'`
1416 [ $BLKSIZE -le $LL_MAX_BLKSIZE ] || error "1:$BLKSIZE > $LL_MAX_BLKSIZE"
1417 dd if=/dev/zero of=$FILE bs=4k count=1
1418 BLKSIZE=`stat $FILE | awk '/IO Block:/ { print $7 }'`
1419 [ $BLKSIZE -le $LL_MAX_BLKSIZE ] || error "2:$BLKSIZE > $LL_MAX_BLKSIZE"
1421 run_test 27k "limit i_blksize for broken user apps ============="
1424 test_mkdir -p $DIR/d27
1425 mcreate $DIR/f27l || error "creating file"
1426 $RUNAS $SETSTRIPE -c 1 $DIR/f27l && \
1427 error "setstripe should have failed" || true
1429 run_test 27l "check setstripe permissions (should return error)"
1432 [[ $OSTCOUNT -lt 2 ]] && skip_env "$OSTCOUNT < 2 OSTs -- skipping" &&
1435 ORIGFREE=$($LCTL get_param -n lov.$FSNAME-clilov-*.kbytesavail |
1437 if [[ $ORIGFREE -gt $MAXFREE ]]; then
1438 skip "$ORIGFREE > $MAXFREE skipping out-of-space test on OST0"
1441 trap simple_cleanup_common EXIT
1442 test_mkdir -p $DIR/$tdir
1443 $SETSTRIPE -i 0 -c 1 $DIR/$tdir/f27m_1
1444 dd if=/dev/zero of=$DIR/$tdir/f27m_1 bs=1024 count=$MAXFREE &&
1445 error "dd should fill OST0"
1447 while $SETSTRIPE -i 0 -c 1 $DIR/$tdir/f27m_$i; do
1449 [ $i -gt 256 ] && break
1452 touch $DIR/$tdir/f27m_$i
1453 [ `$GETSTRIPE $DIR/$tdir/f27m_$i | grep -A 10 obdidx | awk '{print $1}'| grep -w "0"` ] &&
1454 error "OST0 was full but new created file still use it"
1456 touch $DIR/$tdir/f27m_$i
1457 [ `$GETSTRIPE $DIR/$tdir/f27m_$i | grep -A 10 obdidx | awk '{print $1}'| grep -w "0"` ] &&
1458 error "OST0 was full but new created file still use it"
1459 simple_cleanup_common
1461 run_test 27m "create file while OST0 was full =================="
1464 local DELAY=$(do_facet $SINGLEMDS lctl get_param -n lov.*.qos_maxage | head -n 1 | awk '{print $1 * 2}')
1468 # OSCs keep a NOSPC flag that will be reset after ~5s (qos_maxage)
1469 # if the OST isn't full anymore.
1471 local OSTIDX=${1:-""}
1473 local list=$(comma_list $(osts_nodes))
1474 [ "$OSTIDX" ] && list=$(facet_host ost$((OSTIDX + 1)))
1476 do_nodes $list lctl set_param fail_loc=0
1477 sync # initiate all OST_DESTROYs from MDS to OST
1481 exhaust_precreations() {
1484 local FAILIDX=${3:-$OSTIDX}
1485 local ofacet=ost$((OSTIDX + 1))
1487 test_mkdir -p -c1 $DIR/$tdir
1488 local mdtidx=$($LFS getstripe -M $DIR/$tdir)
1489 local mfacet=mds$((mdtidx + 1))
1490 echo OSTIDX=$OSTIDX MDTIDX=$mdtidx
1492 local OST=$(ostname_from_index $OSTIDX)
1495 local mdtosc_proc1=$(get_mdtosc_proc_path $mfacet $OST)
1496 local last_id=$(do_facet $mfacet lctl get_param -n \
1497 osc.$mdtosc_proc1.prealloc_last_id)
1498 local next_id=$(do_facet $mfacet lctl get_param -n \
1499 osc.$mdtosc_proc1.prealloc_next_id)
1501 local mdtosc_proc2=$(get_mdtosc_proc_path $mfacet)
1502 do_facet $mfacet lctl get_param osc.$mdtosc_proc2.prealloc*
1504 test_mkdir -p $DIR/$tdir/${OST}
1505 $SETSTRIPE -i $OSTIDX -c 1 $DIR/$tdir/${OST}
1506 #define OBD_FAIL_OST_ENOSPC 0x215
1507 do_facet $ofacet lctl set_param fail_val=$FAILIDX fail_loc=0x215
1508 echo "Creating to objid $last_id on ost $OST..."
1509 createmany -o $DIR/$tdir/${OST}/f $next_id $((last_id - next_id + 2))
1510 do_facet $mfacet lctl get_param osc.$mdtosc_proc2.prealloc*
1511 do_facet $ofacet lctl set_param fail_loc=$FAILLOC
1515 exhaust_all_precreations() {
1517 for (( i=0; i < OSTCOUNT; i++ )) ; do
1518 exhaust_precreations $i $1 -1
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_precreations 0 0x80000215
1531 $SETSTRIPE -c -1 $DIR/$tdir
1532 touch $DIR/$tdir/$tfile || error
1533 $GETSTRIPE $DIR/$tdir/$tfile
1536 run_test 27n "create file with some full OSTs =================="
1539 [[ $OSTCOUNT -lt 2 ]] && skip_env "too few OSTs" && return
1540 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1541 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1542 remote_ost_nodsh && skip "remote OST with nodsh" && return
1545 rm -f $DIR/$tdir/$tfile
1546 exhaust_all_precreations 0x215
1548 touch $DIR/$tdir/$tfile && error "able to create $DIR/$tdir/$tfile"
1553 run_test 27o "create file with all full OSTs (should error) ===="
1556 [[ $OSTCOUNT -lt 2 ]] && skip_env "too few OSTs" && return
1557 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1558 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1559 remote_ost_nodsh && skip "remote OST with nodsh" && return
1562 rm -f $DIR/$tdir/$tfile
1563 test_mkdir -p $DIR/$tdir
1565 $MCREATE $DIR/$tdir/$tfile || error "mcreate failed"
1566 $TRUNCATE $DIR/$tdir/$tfile 80000000 || error "truncate failed"
1567 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat failed"
1569 exhaust_precreations 0 0x80000215
1570 echo foo >> $DIR/$tdir/$tfile || error "append failed"
1571 $CHECKSTAT -s 80000004 $DIR/$tdir/$tfile || error "checkstat failed"
1572 $GETSTRIPE $DIR/$tdir/$tfile
1576 run_test 27p "append to a truncated file with some full OSTs ==="
1579 [[ $OSTCOUNT -lt 2 ]] && skip_env "too few OSTs" && return
1580 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1581 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1582 remote_ost_nodsh && skip "remote OST with nodsh" && return
1585 rm -f $DIR/$tdir/$tfile
1587 test_mkdir -p $DIR/$tdir
1588 $MCREATE $DIR/$tdir/$tfile || error "mcreate $DIR/$tdir/$tfile failed"
1589 $TRUNCATE $DIR/$tdir/$tfile 80000000 ||error "truncate $DIR/$tdir/$tfile failed"
1590 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat failed"
1592 exhaust_all_precreations 0x215
1594 echo foo >> $DIR/$tdir/$tfile && error "append succeeded"
1595 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat 2 failed"
1599 run_test 27q "append to truncated file with all OSTs full (should error) ==="
1602 [[ $OSTCOUNT -lt 2 ]] && skip_env "too few OSTs" && return
1603 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1604 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1605 remote_ost_nodsh && skip "remote OST with nodsh" && return
1608 rm -f $DIR/$tdir/$tfile
1609 exhaust_precreations 0 0x80000215
1611 $SETSTRIPE -i 0 -c 2 $DIR/$tdir/$tfile # && error
1615 run_test 27r "stripe file with some full OSTs (shouldn't LBUG) ="
1617 test_27s() { # bug 10725
1618 test_mkdir -p $DIR/$tdir
1619 local stripe_size=$((4096 * 1024 * 1024)) # 2^32
1620 local stripe_count=0
1621 [ $OSTCOUNT -eq 1 ] || stripe_count=2
1622 $SETSTRIPE -S $stripe_size -c $stripe_count $DIR/$tdir &&
1623 error "stripe width >= 2^32 succeeded" || true
1626 run_test 27s "lsm_xfersize overflow (should error) (bug 10725)"
1628 test_27t() { # bug 10864
1633 $WLFS getstripe $tfile
1636 run_test 27t "check that utils parse path correctly"
1638 test_27u() { # bug 4900
1639 [[ $OSTCOUNT -lt 2 ]] && skip_env "too few OSTs" && return
1640 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1642 local list=$(comma_list $(mdts_nodes))
1644 #define OBD_FAIL_MDS_OSC_PRECREATE 0x139
1645 do_nodes $list $LCTL set_param fail_loc=0x139
1646 test_mkdir -p $DIR/$tdir
1648 createmany -o $DIR/$tdir/t- 1000
1649 do_nodes $list $LCTL set_param fail_loc=0
1651 TLOG=$DIR/$tfile.getstripe
1652 $GETSTRIPE $DIR/$tdir > $TLOG
1653 OBJS=$(awk -vobj=0 '($1 == 0) { obj += 1 } END { print obj; }' $TLOG)
1654 unlinkmany $DIR/$tdir/t- 1000
1655 [[ $OBJS -gt 0 ]] &&
1656 error "$OBJS objects created on OST-0. See $TLOG" || pass
1658 run_test 27u "skip object creation on OSC w/o objects =========="
1660 test_27v() { # bug 4900
1661 [[ $OSTCOUNT -lt 2 ]] && skip_env "too few OSTs" && return
1662 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1663 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1664 remote_ost_nodsh && skip "remote OST with nodsh" && return
1666 exhaust_all_precreations 0x215
1669 test_mkdir -p $DIR/$tdir
1670 $SETSTRIPE -c 1 $DIR/$tdir # 1 stripe / file
1672 touch $DIR/$tdir/$tfile
1673 #define OBD_FAIL_TGT_DELAY_PRECREATE 0x705
1675 for (( i=1; i < OSTCOUNT; i++ )); do
1676 do_facet ost$i lctl set_param fail_loc=0x705
1678 local START=`date +%s`
1679 createmany -o $DIR/$tdir/$tfile 32
1681 local FINISH=`date +%s`
1682 local TIMEOUT=`lctl get_param -n timeout`
1683 local PROCESS=$((FINISH - START))
1684 [ $PROCESS -ge $((TIMEOUT / 2)) ] && \
1685 error "$FINISH - $START >= $TIMEOUT / 2"
1686 sleep $((TIMEOUT / 2 - PROCESS))
1689 run_test 27v "skip object creation on slow OST ================="
1691 test_27w() { # bug 10997
1692 test_mkdir -p $DIR/$tdir || error "mkdir failed"
1693 $SETSTRIPE -S 65536 $DIR/$tdir/f0 || error "setstripe failed"
1694 [ $($GETSTRIPE -S $DIR/$tdir/f0) -ne 65536 ] &&
1695 error "stripe size $size != 65536" || true
1696 [ $($GETSTRIPE -d $DIR/$tdir | grep -c "stripe_count") -ne 1 ] &&
1697 error "$GETSTRIPE -d $DIR/$tdir failed" || true
1699 run_test 27w "check $SETSTRIPE -S option"
1702 [[ $OSTCOUNT -lt 2 ]] &&
1703 skip_env "skipping multiple stripe count/offset test" && return
1705 test_mkdir -p $DIR/$tdir || error "mkdir failed"
1706 for i in $(seq 1 $OSTCOUNT); do
1708 $SETSTRIPE -c $i -i $offset $DIR/$tdir/f$i ||
1709 error "setstripe -c $i -i $offset failed"
1710 count=$($GETSTRIPE -c $DIR/$tdir/f$i)
1711 index=$($GETSTRIPE -i $DIR/$tdir/f$i)
1712 [ $count -ne $i ] && error "stripe count $count != $i" || true
1713 [ $index -ne $offset ] &&
1714 error "stripe offset $index != $offset" || true
1717 run_test 27wa "check $SETSTRIPE -c -i options"
1720 remote_ost_nodsh && skip "remote OST with nodsh" && return
1721 [[ $OSTCOUNT -lt 2 ]] && skip_env "$OSTCOUNT < 2 OSTs" && return
1722 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1723 OFFSET=$(($OSTCOUNT - 1))
1725 local OST=$(ostname_from_index $OSTIDX)
1727 test_mkdir -p $DIR/$tdir
1728 $SETSTRIPE -c 1 $DIR/$tdir # 1 stripe per file
1729 do_facet ost$((OSTIDX + 1)) lctl set_param -n obdfilter.$OST.degraded 1
1731 createmany -o $DIR/$tdir/$tfile $OSTCOUNT
1732 for i in `seq 0 $OFFSET`; do
1733 [ `$GETSTRIPE $DIR/$tdir/$tfile$i | grep -A 10 obdidx | awk '{print $1}' | grep -w "$OSTIDX"` ] &&
1734 error "OST0 was degraded but new created file still use it"
1736 do_facet ost$((OSTIDX + 1)) lctl set_param -n obdfilter.$OST.degraded 0
1738 run_test 27x "create files while OST0 is degraded"
1741 [[ $OSTCOUNT -lt 2 ]] &&
1742 skip_env "$OSTCOUNT < 2 OSTs -- skipping" && return
1743 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1744 remote_ost_nodsh && skip "remote OST with nodsh" && return
1745 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1747 local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS $FSNAME-OST0000)
1748 local last_id=$(do_facet $SINGLEMDS lctl get_param -n \
1749 osc.$mdtosc.prealloc_last_id)
1750 local next_id=$(do_facet $SINGLEMDS lctl get_param -n \
1751 osc.$mdtosc.prealloc_next_id)
1752 local fcount=$((last_id - next_id))
1753 [[ $fcount -eq 0 ]] && skip "not enough space on OST0" && return
1754 [[ $fcount -gt $OSTCOUNT ]] && fcount=$OSTCOUNT
1756 local MDS_OSCS=$(do_facet $SINGLEMDS lctl dl |
1757 awk '/[oO][sS][cC].*md[ts]/ { print $4 }')
1758 local OST_DEACTIVE_IDX=-1
1763 for OSC in $MDS_OSCS; do
1764 OST=$(osc_to_ost $OSC)
1765 OSTIDX=$(index_from_ostuuid $OST)
1766 if [ $OST_DEACTIVE_IDX == -1 ]; then
1767 OST_DEACTIVE_IDX=$OSTIDX
1769 if [ $OSTIDX != $OST_DEACTIVE_IDX ]; then
1770 echo $OSC "is Deactivated:"
1771 do_facet $SINGLEMDS lctl --device %$OSC deactivate
1775 OSTIDX=$(index_from_ostuuid $OST)
1776 test_mkdir -p $DIR/$tdir
1777 $SETSTRIPE -c 1 $DIR/$tdir # 1 stripe / file
1779 for OSC in $MDS_OSCS; do
1780 OST=$(osc_to_ost $OSC)
1781 OSTIDX=$(index_from_ostuuid $OST)
1782 if [ $OSTIDX == $OST_DEACTIVE_IDX ]; then
1783 echo $OST "is degraded:"
1784 do_facet ost$((OSTIDX+1)) lctl set_param -n \
1785 obdfilter.$OST.degraded=1
1790 createmany -o $DIR/$tdir/$tfile $fcount
1792 for OSC in $MDS_OSCS; do
1793 OST=$(osc_to_ost $OSC)
1794 OSTIDX=$(index_from_ostuuid $OST)
1795 if [ $OSTIDX == $OST_DEACTIVE_IDX ]; then
1796 echo $OST "is recovered from degraded:"
1797 do_facet ost$((OSTIDX+1)) lctl set_param -n \
1798 obdfilter.$OST.degraded=0
1800 do_facet $SINGLEMDS lctl --device %$OSC activate
1804 # all osp devices get activated, hence -1 stripe count restored
1807 # sleep 2*lod_qos_maxage seconds waiting for lod qos to notice osp
1808 # devices get activated.
1810 $SETSTRIPE -c -1 $DIR/$tfile
1811 stripecnt=$($GETSTRIPE -c $DIR/$tfile)
1813 [ $stripecnt -ne $OSTCOUNT ] &&
1814 error "Of $OSTCOUNT OSTs, only $stripecnt is available"
1817 run_test 27y "create files while OST0 is degraded and the rest inactive"
1823 lmm_count=$($GETSTRIPE -c $1)
1824 lmm_seq=$($GETSTRIPE -v $1 | awk '/lmm_seq/ { print $2 }')
1825 lmm_oid=$($GETSTRIPE -v $1 | awk '/lmm_object_id/ { print $2 }')
1827 local old_ifs="$IFS"
1829 fid=($($LFS path2fid $1))
1832 log "FID seq ${fid[1]}, oid ${fid[2]} ver ${fid[3]}"
1833 log "LOV seq $lmm_seq, oid $lmm_oid, count: $lmm_count"
1835 # compare lmm_seq and lu_fid->f_seq
1836 [ $lmm_seq = ${fid[1]} ] || { error "SEQ mismatch"; return 1; }
1837 # compare lmm_object_id and lu_fid->oid
1838 [ $lmm_oid = ${fid[2]} ] || { error "OID mismatch"; return 2; }
1840 # check the trusted.fid attribute of the OST objects of the file
1841 local have_obdidx=false
1843 $GETSTRIPE $1 | while read obdidx oid hex seq; do
1844 # skip lines up to and including "obdidx"
1845 [ -z "$obdidx" ] && break
1846 [ "$obdidx" = "obdidx" ] && have_obdidx=true && continue
1847 $have_obdidx || continue
1849 local ost=$((obdidx + 1))
1850 local dev=$(ostdevname $ost)
1853 log "want: stripe:$stripe_nr ost:$obdidx oid:$oid/$hex seq:$seq"
1855 seq=$(echo $seq | sed -e "s/^0x//g")
1856 if [ $seq == 0 ] || [ $(facet_fstype ost$ost) == zfs ]; then
1857 oid_hex=$(echo $oid)
1859 oid_hex=$(echo $hex | sed -e "s/^0x//g")
1861 local obj_file="O/$seq/d$((oid %32))/$oid_hex"
1865 # Don't unmount/remount the OSTs if we don't need to do that.
1866 # LU-2577 changes filter_fid to be smaller, so debugfs needs
1867 # update too, until that use mount/ll_decode_filter_fid/mount.
1868 # Re-enable when debugfs will understand new filter_fid.
1870 if false && [ $(facet_fstype ost$ost) == ldiskfs ]; then
1871 ff=$(do_facet ost$ost "$DEBUGFS -c -R 'stat $obj_file' \
1872 $dev 2>/dev/null" | grep "parent=")
1875 mount_fstype ost$ost
1876 ff=$(do_facet ost$ost $LL_DECODE_FILTER_FID \
1877 $(facet_mntpt ost$ost)/$obj_file)
1878 unmount_fstype ost$ost
1879 start ost$ost $dev $OST_MOUNT_OPTS
1883 [ -z "$ff" ] && error "$obj_file: no filter_fid info"
1885 echo "$ff" | sed -e 's#.*objid=#got: objid=#'
1887 # /mnt/O/0/d23/23: objid=23 seq=0 parent=[0x200000400:0x1e:0x1]
1888 # fid: objid=23 seq=0 parent=[0x200000400:0x1e:0x0] stripe=1
1889 local ff_parent=$(echo $ff|sed -e 's/.*parent=.//')
1890 local ff_pseq=$(echo $ff_parent | cut -d: -f1)
1891 local ff_poid=$(echo $ff_parent | cut -d: -f2)
1893 if echo $ff_parent | grep -q 'stripe='; then
1894 ff_pstripe=$(echo $ff_parent | sed -e 's/.*stripe=//')
1897 # $LL_DECODE_FILTER_FID does not print "stripe="; look
1898 # into f_ver in this case. See the comment on
1901 ff_pstripe=$(echo $ff_parent | cut -d: -f3 |
1905 # compare lmm_seq and filter_fid->ff_parent.f_seq
1906 [ $ff_pseq = $lmm_seq ] ||
1907 error "FF parent SEQ $ff_pseq != $lmm_seq"
1908 # compare lmm_object_id and filter_fid->ff_parent.f_oid
1909 [ $ff_poid = $lmm_oid ] ||
1910 error "FF parent OID $ff_poid != $lmm_oid"
1911 (($ff_pstripe == $stripe_nr)) ||
1912 error "FF stripe $ff_pstripe != $stripe_nr"
1914 stripe_nr=$((stripe_nr + 1))
1919 remote_ost_nodsh && skip "remote OST with nodsh" && return
1920 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1921 test_mkdir -p $DIR/$tdir
1923 $SETSTRIPE -c 1 -i 0 -S 64k $DIR/$tdir/$tfile-1 ||
1924 { error "setstripe -c -1 failed"; return 1; }
1925 # We need to send a write to every object to get parent FID info set.
1926 # This _should_ also work for setattr, but does not currently.
1927 # touch $DIR/$tdir/$tfile-1 ||
1928 dd if=/dev/zero of=$DIR/$tdir/$tfile-1 bs=1M count=1 ||
1929 { error "dd $tfile-1 failed"; return 2; }
1930 $SETSTRIPE -c -1 -i $((OSTCOUNT - 1)) -S 1M $DIR/$tdir/$tfile-2 ||
1931 { error "setstripe -c -1 failed"; return 3; }
1932 dd if=/dev/zero of=$DIR/$tdir/$tfile-2 bs=1M count=$OSTCOUNT ||
1933 { error "dd $tfile-2 failed"; return 4; }
1935 # make sure write RPCs have been sent to OSTs
1938 check_seq_oid $DIR/$tdir/$tfile-1 || return 5
1939 check_seq_oid $DIR/$tdir/$tfile-2 || return 6
1941 run_test 27z "check SEQ/OID on the MDT and OST filesystems"
1943 test_27A() { # b=19102
1944 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1945 local restore_size=$($GETSTRIPE -S $MOUNT)
1946 local restore_count=$($GETSTRIPE -c $MOUNT)
1947 local restore_offset=$($GETSTRIPE -i $MOUNT)
1948 $SETSTRIPE -c 0 -i -1 -S 0 $MOUNT
1949 wait_update $HOSTNAME "$GETSTRIPE -c $MOUNT | sed 's/ *//g'" "1" 20 ||
1950 error "stripe count $($GETSTRIPE -c $MOUNT) != 1"
1951 local default_size=$($GETSTRIPE -S $MOUNT)
1952 local default_offset=$($GETSTRIPE -i $MOUNT)
1953 local dsize=$((1024 * 1024))
1954 [ $default_size -eq $dsize ] ||
1955 error "stripe size $default_size != $dsize"
1956 [ $default_offset -eq -1 ] ||error "stripe offset $default_offset != -1"
1957 $SETSTRIPE -c $restore_count -i $restore_offset -S $restore_size $MOUNT
1959 run_test 27A "check filesystem-wide default LOV EA values"
1961 test_27B() { # LU-2523
1962 test_mkdir -p $DIR/$tdir
1963 rm -f $DIR/$tdir/f0 $DIR/$tdir/f1
1965 # open f1 with O_LOV_DELAY_CREATE
1967 # call setstripe ioctl on open file descriptor for f1
1969 multiop $DIR/$tdir/f1 oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:nB1c \
1973 # open f1 with O_LOV_DELAY_CREATE
1975 # call setstripe ioctl on open file descriptor for f1
1977 multiop $DIR/$tdir/f1 oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:uB1c
1979 # Allow multiop to fail in imitation of NFS's busted semantics.
1982 run_test 27B "call setstripe on open unlinked file/rename victim"
1984 test_27C() { #LU-2871
1985 [[ $OSTCOUNT -lt 2 ]] && skip "needs >= 2 OSTs" && return
1993 test_mkdir -p $DIR/$tdir
1995 for i in $(seq 0 $((OSTCOUNT - 1))); do
1996 # set stripe across all OSTs starting from OST$i
1997 $SETSTRIPE -i $i -c -1 $tfile$i
1998 # get striping information
1999 ost_idx=($($GETSTRIPE $tfile$i |
2000 tail -n $((OSTCOUNT + 1)) | awk '{print $1}'))
2004 [ ${#ost_idx[@]} -eq $OSTCOUNT ] ||
2005 error "${#ost_idx[@]} != $OSTCOUNT"
2007 for index in $(seq 0 $((OSTCOUNT - 1))); do
2009 for j in $(echo ${ost_idx[@]}); do
2010 if [ $index -eq $j ]; then
2016 error "Can not find $index in ${ost_idx[@]}"
2020 run_test 27C "check full striping across all OSTs"
2023 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs" && return
2024 [ -n "$FILESET" ] && skip "SKIP due to FILESET set" && return
2025 local POOL=${POOL:-testpool}
2027 local last_ost=$(($OSTCOUNT - 1))
2029 local ost_list=$(seq $first_ost $ost_step $last_ost)
2030 local ost_range="$first_ost $last_ost $ost_step"
2032 test_mkdir -p $DIR/$tdir
2033 pool_add $POOL || error "pool_add failed"
2034 pool_add_targets $POOL $ost_range || error "pool_add_targets failed"
2035 llapi_layout_test -d$DIR/$tdir -p$POOL -o$OSTCOUNT ||
2036 error "llapi_layout_test failed"
2037 cleanup_pools || error "cleanup_pools failed"
2039 run_test 27D "validate llapi_layout API"
2041 # Verify that default_easize is increased from its initial value after
2042 # accessing a widely striped file.
2044 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs" && return
2045 [ $(lustre_version_code client) -lt $(version_code 2.5.57) ] &&
2046 skip "client does not have LU-3338 fix" && return
2048 # 72 bytes is the minimum space required to store striping
2049 # information for a file striped across one OST:
2050 # (sizeof(struct lov_user_md_v3) +
2051 # sizeof(struct lov_user_ost_data_v1))
2053 $LCTL set_param -n llite.*.default_easize $min_easize ||
2054 error "lctl set_param failed"
2055 local easize=$($LCTL get_param -n llite.*.default_easize)
2057 [ $easize -eq $min_easize ] ||
2058 error "failed to set default_easize"
2060 $LFS setstripe -c $OSTCOUNT $DIR/$tfile ||
2061 error "setstripe failed"
2065 easize=$($LCTL get_param -n llite.*.default_easize)
2067 [ $easize -gt $min_easize ] ||
2068 error "default_easize not updated"
2070 run_test 27E "check that default extended attribute size properly increases"
2072 test_27F() { # LU-5346/LU-7975
2074 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2076 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.8.51) ]] &&
2077 skip "Need MDS version at least 2.8.51" && return
2079 test_mkdir -p $DIR/$tdir
2081 $SETSTRIPE -c 2 $DIR/$tdir
2083 # stop all OSTs to reproduce situation for LU-7975 ticket
2084 for num in $(seq $OSTCOUNT); do
2088 # open/create f0 with O_LOV_DELAY_CREATE
2089 # truncate f0 to a non-0 size
2091 multiop $DIR/$tdir/f0 oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:T1050000c
2093 $CHECKSTAT -s 1050000 $DIR/$tdir/f0 || error "checkstat failed"
2094 # open/write it again to force delayed layout creation
2095 cat /etc/hosts > $DIR/$tdir/f0 &
2099 for num in $(seq $OSTCOUNT); do
2100 start ost$num $(ostdevname $num) $OST_MOUNT_OPTS ||
2101 error "ost$num failed to start"
2104 wait $catpid || error "cat failed"
2106 cmp /etc/hosts $DIR/$tdir/f0 || error "cmp failed"
2107 [[ $($GETSTRIPE -c $DIR/$tdir/f0) == 2 ]] || error "wrong stripecount"
2110 run_test 27F "Client resend delayed layout creation with non-zero size"
2112 # createtest also checks that device nodes are created and
2113 # then visible correctly (#2091)
2114 test_28() { # bug 2091
2116 $CREATETEST $DIR/d28/ct || error
2118 run_test 28 "create/mknod/mkdir with bad file types ============"
2121 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return 0
2122 cancel_lru_locks mdc
2128 declare -i LOCKCOUNTORIG=0
2129 for lock_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_count); do
2130 let LOCKCOUNTORIG=$LOCKCOUNTORIG+$lock_count
2132 [ $LOCKCOUNTORIG -eq 0 ] && error "No mdc lock count" && return 1
2134 declare -i LOCKUNUSEDCOUNTORIG=0
2135 for unused_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_unused_count); do
2136 let LOCKUNUSEDCOUNTORIG=$LOCKUNUSEDCOUNTORIG+$unused_count
2143 declare -i LOCKCOUNTCURRENT=0
2144 for lock_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_count); do
2145 let LOCKCOUNTCURRENT=$LOCKCOUNTCURRENT+$lock_count
2148 declare -i LOCKUNUSEDCOUNTCURRENT=0
2149 for unused_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_unused_count); do
2150 let LOCKUNUSEDCOUNTCURRENT=$LOCKUNUSEDCOUNTCURRENT+$unused_count
2153 if [[ $LOCKCOUNTCURRENT -gt $LOCKCOUNTORIG ]]; then
2154 $LCTL set_param -n ldlm.dump_namespaces ""
2155 error "CURRENT: $LOCKCOUNTCURRENT > $LOCKCOUNTORIG"
2156 $LCTL dk | sort -k4 -t: > $TMP/test_29.dk
2157 log "dumped log to $TMP/test_29.dk (bug 5793)"
2160 if [[ $LOCKUNUSEDCOUNTCURRENT -gt $LOCKUNUSEDCOUNTORIG ]]; then
2161 error "UNUSED: $LOCKUNUSEDCOUNTCURRENT > $LOCKUNUSEDCOUNTORIG"
2162 $LCTL dk | sort -k4 -t: > $TMP/test_29.dk
2163 log "dumped log to $TMP/test_29.dk (bug 5793)"
2167 run_test 29 "IT_GETATTR regression ============================"
2169 test_30a() { # was test_30
2170 cp $(which ls) $DIR || cp /bin/ls $DIR
2174 run_test 30a "execute binary from Lustre (execve) =============="
2177 cp `which ls` $DIR || cp /bin/ls $DIR
2179 $RUNAS $DIR/ls / || error
2182 run_test 30b "execute binary from Lustre as non-root ==========="
2184 test_30c() { # b=22376
2185 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2186 cp `which ls` $DIR || cp /bin/ls $DIR
2188 cancel_lru_locks mdc
2189 cancel_lru_locks osc
2190 $RUNAS $DIR/ls / || error
2193 run_test 30c "execute binary from Lustre without read perms ===="
2196 $OPENUNLINK $DIR/f31 $DIR/f31 || error
2197 $CHECKSTAT -a $DIR/f31 || error
2199 run_test 31a "open-unlink file =================================="
2202 touch $DIR/f31 || error
2203 ln $DIR/f31 $DIR/f31b || error
2204 $MULTIOP $DIR/f31b Ouc || error
2205 $CHECKSTAT -t file $DIR/f31 || error
2207 run_test 31b "unlink file with multiple links while open ======="
2210 touch $DIR/f31 || error
2211 ln $DIR/f31 $DIR/f31c || error
2212 multiop_bg_pause $DIR/f31 O_uc || return 1
2214 $MULTIOP $DIR/f31c Ouc
2215 kill -USR1 $MULTIPID
2218 run_test 31c "open-unlink file with multiple links ============="
2221 opendirunlink $DIR/d31d $DIR/d31d || error
2222 $CHECKSTAT -a $DIR/d31d || error
2224 run_test 31d "remove of open directory ========================="
2226 test_31e() { # bug 2904
2227 openfilleddirunlink $DIR/d31e || error
2229 run_test 31e "remove of open non-empty directory ==============="
2231 test_31f() { # bug 4554
2232 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2234 test_mkdir $DIR/d31f
2235 $SETSTRIPE -S 1048576 -c 1 $DIR/d31f
2236 cp /etc/hosts $DIR/d31f
2238 $GETSTRIPE $DIR/d31f/hosts
2239 multiop_bg_pause $DIR/d31f D_c || return 1
2242 rm -rv $DIR/d31f || error "first of $DIR/d31f"
2243 test_mkdir $DIR/d31f
2244 $SETSTRIPE -S 1048576 -c 1 $DIR/d31f
2245 cp /etc/hosts $DIR/d31f
2247 $GETSTRIPE $DIR/d31f/hosts
2248 multiop_bg_pause $DIR/d31f D_c || return 1
2251 kill -USR1 $MULTIPID || error "first opendir $MULTIPID not running"
2252 wait $MULTIPID || error "first opendir $MULTIPID failed"
2256 kill -USR1 $MULTIPID2 || error "second opendir $MULTIPID not running"
2257 wait $MULTIPID2 || error "second opendir $MULTIPID2 failed"
2260 run_test 31f "remove of open directory with open-unlink file ==="
2263 echo "-- cross directory link --"
2264 test_mkdir -c1 $DIR/${tdir}ga
2265 test_mkdir -c1 $DIR/${tdir}gb
2266 touch $DIR/${tdir}ga/f
2267 ln $DIR/${tdir}ga/f $DIR/${tdir}gb/g
2268 $CHECKSTAT -t file $DIR/${tdir}ga/f || error "source"
2269 [ `stat -c%h $DIR/${tdir}ga/f` == '2' ] || error "source nlink"
2270 $CHECKSTAT -t file $DIR/${tdir}gb/g || error "target"
2271 [ `stat -c%h $DIR/${tdir}gb/g` == '2' ] || error "target nlink"
2273 run_test 31g "cross directory link==============="
2276 echo "-- cross directory link --"
2277 test_mkdir -c1 $DIR/${tdir}
2278 test_mkdir -c1 $DIR/${tdir}/dir
2279 touch $DIR/${tdir}/f
2280 ln $DIR/${tdir}/f $DIR/${tdir}/dir/g
2281 $CHECKSTAT -t file $DIR/${tdir}/f || error "source"
2282 [ `stat -c%h $DIR/${tdir}/f` == '2' ] || error "source nlink"
2283 $CHECKSTAT -t file $DIR/${tdir}/dir/g || error "target"
2284 [ `stat -c%h $DIR/${tdir}/dir/g` == '2' ] || error "target nlink"
2286 run_test 31h "cross directory link under child==============="
2289 echo "-- cross directory link --"
2290 test_mkdir -c1 $DIR/$tdir
2291 test_mkdir -c1 $DIR/$tdir/dir
2292 touch $DIR/$tdir/dir/f
2293 ln $DIR/$tdir/dir/f $DIR/$tdir/g
2294 $CHECKSTAT -t file $DIR/$tdir/dir/f || error "source"
2295 [ `stat -c%h $DIR/$tdir/dir/f` == '2' ] || error "source nlink"
2296 $CHECKSTAT -t file $DIR/$tdir/g || error "target"
2297 [ `stat -c%h $DIR/$tdir/g` == '2' ] || error "target nlink"
2299 run_test 31i "cross directory link under parent==============="
2302 test_mkdir -c1 -p $DIR/$tdir
2303 test_mkdir -c1 -p $DIR/$tdir/dir1
2304 ln $DIR/$tdir/dir1 $DIR/$tdir/dir2 && error "ln for dir"
2305 link $DIR/$tdir/dir1 $DIR/$tdir/dir3 && error "link for dir"
2306 mlink $DIR/$tdir/dir1 $DIR/$tdir/dir4 && error "mlink for dir"
2307 mlink $DIR/$tdir/dir1 $DIR/$tdir/dir1 && error "mlink to the same dir"
2310 run_test 31j "link for directory==============="
2313 test_mkdir -c1 -p $DIR/$tdir
2315 touch $DIR/$tdir/exist
2316 mlink $DIR/$tdir/s $DIR/$tdir/t || error "mlink"
2317 mlink $DIR/$tdir/s $DIR/$tdir/exist && error "mlink to exist file"
2318 mlink $DIR/$tdir/s $DIR/$tdir/s && error "mlink to the same file"
2319 mlink $DIR/$tdir/s $DIR/$tdir && error "mlink to parent dir"
2320 mlink $DIR/$tdir $DIR/$tdir/s && error "mlink parent dir to target"
2321 mlink $DIR/$tdir/not-exist $DIR/$tdir/foo && error "mlink non-existing to new"
2322 mlink $DIR/$tdir/not-exist $DIR/$tdir/s && error "mlink non-existing to exist"
2325 run_test 31k "link to file: the same, non-existing, dir==============="
2331 touch $DIR/d31m2/exist
2332 mlink $DIR/d31m/s $DIR/d31m2/t || error "mlink"
2333 mlink $DIR/d31m/s $DIR/d31m2/exist && error "mlink to exist file"
2334 mlink $DIR/d31m/s $DIR/d31m2 && error "mlink to parent dir"
2335 mlink $DIR/d31m2 $DIR/d31m/s && error "mlink parent dir to target"
2336 mlink $DIR/d31m/not-exist $DIR/d31m2/foo && error "mlink non-existing to new"
2337 mlink $DIR/d31m/not-exist $DIR/d31m2/s && error "mlink non-existing to exist"
2340 run_test 31m "link to file: the same, non-existing, dir==============="
2343 touch $DIR/$tfile || error "cannot create '$DIR/$tfile'"
2344 nlink=$(stat --format=%h $DIR/$tfile)
2345 [ ${nlink:--1} -eq 1 ] || error "nlink is $nlink, expected 1"
2347 local cmd="exec $fd<$DIR/$tfile"
2350 trap "eval $cmd" EXIT
2351 nlink=$(stat --dereference --format=%h /proc/self/fd/$fd)
2352 [ ${nlink:--1} -eq 1 ] || error "nlink is $nlink, expected 1"
2353 rm $DIR/$tfile || error "cannot remove '$DIR/$tfile'"
2354 nlink=$(stat --dereference --format=%h /proc/self/fd/$fd)
2355 [ ${nlink:--1} -eq 0 ] || error "nlink is $nlink, expected 0"
2358 run_test 31n "check link count of unlinked file"
2361 local TEMPNAME=$(mktemp $1_XXXXXX)
2362 mlink $TEMPNAME $1 2> /dev/null &&
2363 echo "$BASHPID: link $TEMPNAME to $1 succeeded"
2367 test_31o() { # LU-2901
2368 test_mkdir -p $DIR/$tdir
2369 for LOOP in $(seq 100); do
2370 rm -f $DIR/$tdir/$tfile*
2371 for THREAD in $(seq 8); do
2372 link_one $DIR/$tdir/$tfile.$LOOP &
2375 local LINKS=$(ls -1 $DIR/$tdir | grep -c $tfile.$LOOP)
2376 [[ $LINKS -gt 1 ]] && ls $DIR/$tdir &&
2377 error "$LINKS duplicate links to $tfile.$LOOP" &&
2381 run_test 31o "duplicate hard links with same filename"
2384 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2386 test_mkdir $DIR/$tdir
2387 $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
2388 $LFS setdirstripe -D -c2 -t all_char $DIR/$tdir/striped_dir
2390 opendirunlink $DIR/$tdir/striped_dir/test1 ||
2391 error "open unlink test1 failed"
2392 opendirunlink $DIR/$tdir/striped_dir/test2 ||
2393 error "open unlink test2 failed"
2395 $CHECKSTAT -a $DIR/$tdir/striped_dir/test1 ||
2396 error "test1 still exists"
2397 $CHECKSTAT -a $DIR/$tdir/striped_dir/test2 ||
2398 error "test2 still exists"
2400 run_test 31p "remove of open striped directory"
2402 cleanup_test32_mount() {
2404 $UMOUNT $DIR/$tdir/ext2-mountpoint
2408 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2409 echo "== more mountpoints and symlinks ================="
2410 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2411 trap cleanup_test32_mount EXIT
2412 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2413 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2414 $CHECKSTAT -t dir $DIR/$tdir/ext2-mountpoint/.. || error
2415 cleanup_test32_mount
2417 run_test 32a "stat d32a/ext2-mountpoint/.. ====================="
2420 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2421 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2422 trap cleanup_test32_mount EXIT
2423 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2424 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2425 ls -al $DIR/$tdir/ext2-mountpoint/.. || error
2426 cleanup_test32_mount
2428 run_test 32b "open d32b/ext2-mountpoint/.. ====================="
2431 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2432 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2433 trap cleanup_test32_mount EXIT
2434 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2435 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2436 test_mkdir -p $DIR/$tdir/d2/test_dir
2437 $CHECKSTAT -t dir $DIR/$tdir/ext2-mountpoint/../d2/test_dir || error
2438 cleanup_test32_mount
2440 run_test 32c "stat d32c/ext2-mountpoint/../d2/test_dir ========="
2443 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2444 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2445 trap cleanup_test32_mount EXIT
2446 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2447 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2448 test_mkdir -p $DIR/$tdir/d2/test_dir
2449 ls -al $DIR/$tdir/ext2-mountpoint/../d2/test_dir || error
2450 cleanup_test32_mount
2452 run_test 32d "open d32d/ext2-mountpoint/../d2/test_dir ========="
2455 [ -e $DIR/d32e ] && rm -fr $DIR/d32e
2456 test_mkdir -p $DIR/d32e/tmp
2457 TMP_DIR=$DIR/d32e/tmp
2458 ln -s $DIR/d32e $TMP_DIR/symlink11
2459 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
2460 $CHECKSTAT -t link $DIR/d32e/tmp/symlink11 || error
2461 $CHECKSTAT -t link $DIR/d32e/symlink01 || error
2463 run_test 32e "stat d32e/symlink->tmp/symlink->lustre-subdir ===="
2466 [ -e $DIR/d32f ] && rm -fr $DIR/d32f
2467 test_mkdir -p $DIR/d32f/tmp
2468 TMP_DIR=$DIR/d32f/tmp
2469 ln -s $DIR/d32f $TMP_DIR/symlink11
2470 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
2471 ls $DIR/d32f/tmp/symlink11 || error
2472 ls $DIR/d32f/symlink01 || error
2474 run_test 32f "open d32f/symlink->tmp/symlink->lustre-subdir ===="
2477 TMP_DIR=$DIR/$tdir/tmp
2478 test_mkdir -p $DIR/$tdir/tmp
2479 test_mkdir $DIR/${tdir}2
2480 ln -s $DIR/${tdir}2 $TMP_DIR/symlink12
2481 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
2482 $CHECKSTAT -t link $TMP_DIR/symlink12 || error
2483 $CHECKSTAT -t link $DIR/$tdir/symlink02 || error
2484 $CHECKSTAT -t dir -f $TMP_DIR/symlink12 || error
2485 $CHECKSTAT -t dir -f $DIR/$tdir/symlink02 || error
2487 run_test 32g "stat d32g/symlink->tmp/symlink->lustre-subdir/${tdir}2"
2490 rm -fr $DIR/$tdir $DIR/${tdir}2
2491 TMP_DIR=$DIR/$tdir/tmp
2492 test_mkdir -p $DIR/$tdir/tmp
2493 test_mkdir $DIR/${tdir}2
2494 ln -s $DIR/${tdir}2 $TMP_DIR/symlink12
2495 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
2496 ls $TMP_DIR/symlink12 || error
2497 ls $DIR/$tdir/symlink02 || error
2499 run_test 32h "open d32h/symlink->tmp/symlink->lustre-subdir/${tdir}2"
2502 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2503 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2504 trap cleanup_test32_mount EXIT
2505 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2506 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2507 touch $DIR/$tdir/test_file
2508 $CHECKSTAT -t file $DIR/$tdir/ext2-mountpoint/../test_file || error
2509 cleanup_test32_mount
2511 run_test 32i "stat d32i/ext2-mountpoint/../test_file ==========="
2514 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2515 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2516 trap cleanup_test32_mount EXIT
2517 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2518 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2519 touch $DIR/$tdir/test_file
2520 cat $DIR/$tdir/ext2-mountpoint/../test_file || error
2521 cleanup_test32_mount
2523 run_test 32j "open d32j/ext2-mountpoint/../test_file ==========="
2526 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2528 trap cleanup_test32_mount EXIT
2529 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2530 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint
2531 test_mkdir -p $DIR/$tdir/d2
2532 touch $DIR/$tdir/d2/test_file || error
2533 $CHECKSTAT -t file $DIR/$tdir/ext2-mountpoint/../d2/test_file || error
2534 cleanup_test32_mount
2536 run_test 32k "stat d32k/ext2-mountpoint/../d2/test_file ========"
2539 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2541 trap cleanup_test32_mount EXIT
2542 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2543 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2544 test_mkdir -p $DIR/$tdir/d2
2545 touch $DIR/$tdir/d2/test_file
2546 cat $DIR/$tdir/ext2-mountpoint/../d2/test_file || error
2547 cleanup_test32_mount
2549 run_test 32l "open d32l/ext2-mountpoint/../d2/test_file ========"
2553 test_mkdir -p $DIR/d32m/tmp
2554 TMP_DIR=$DIR/d32m/tmp
2555 ln -s $DIR $TMP_DIR/symlink11
2556 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
2557 $CHECKSTAT -t link $DIR/d32m/tmp/symlink11 || error
2558 $CHECKSTAT -t link $DIR/d32m/symlink01 || error
2560 run_test 32m "stat d32m/symlink->tmp/symlink->lustre-root ======"
2564 test_mkdir -p $DIR/d32n/tmp
2565 TMP_DIR=$DIR/d32n/tmp
2566 ln -s $DIR $TMP_DIR/symlink11
2567 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
2568 ls -l $DIR/d32n/tmp/symlink11 || error
2569 ls -l $DIR/d32n/symlink01 || error
2571 run_test 32n "open d32n/symlink->tmp/symlink->lustre-root ======"
2575 test_mkdir -p $DIR/d32o/tmp
2576 TMP_DIR=$DIR/d32o/tmp
2577 ln -s $DIR/$tfile $TMP_DIR/symlink12
2578 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
2579 $CHECKSTAT -t link $DIR/d32o/tmp/symlink12 || error
2580 $CHECKSTAT -t link $DIR/d32o/symlink02 || error
2581 $CHECKSTAT -t file -f $DIR/d32o/tmp/symlink12 || error
2582 $CHECKSTAT -t file -f $DIR/d32o/symlink02 || error
2584 run_test 32o "stat d32o/symlink->tmp/symlink->lustre-root/$tfile"
2594 test_mkdir -p $DIR/d32p/tmp
2596 TMP_DIR=$DIR/d32p/tmp
2598 ln -s $DIR/$tfile $TMP_DIR/symlink12
2600 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
2602 cat $DIR/d32p/tmp/symlink12 || error
2604 cat $DIR/d32p/symlink02 || error
2607 run_test 32p "open d32p/symlink->tmp/symlink->lustre-root/$tfile"
2609 cleanup_testdir_mount() {
2615 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2616 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2617 trap cleanup_testdir_mount EXIT
2618 test_mkdir -p $DIR/$tdir
2619 touch $DIR/$tdir/under_the_mount
2620 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir
2621 ls $DIR/$tdir | grep "\<under_the_mount\>" && error
2622 cleanup_testdir_mount
2624 run_test 32q "stat follows mountpoints in Lustre (should return error)"
2627 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2628 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2629 trap cleanup_testdir_mount EXIT
2630 test_mkdir -p $DIR/$tdir
2631 touch $DIR/$tdir/under_the_mount
2632 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir
2633 ls $DIR/$tdir | grep -q under_the_mount && error || true
2634 cleanup_testdir_mount
2636 run_test 32r "opendir follows mountpoints in Lustre (should return error)"
2641 chmod 444 $DIR/$tfile
2642 chown $RUNAS_ID $DIR/$tfile
2644 $RUNAS $OPENFILE -f O_RDWR $DIR/$tfile && error || true
2647 run_test 33aa "write file with mode 444 (should return error) ===="
2651 test_mkdir -p $DIR/d33
2652 chown $RUNAS_ID $DIR/d33
2653 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $DIR/d33/f33|| error "create"
2654 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $DIR/d33/f33 && \
2655 error "open RDWR" || true
2657 run_test 33a "test open file(mode=0444) with O_RDWR (should return error)"
2661 test_mkdir -p $DIR/d33
2662 chown $RUNAS_ID $DIR/d33
2663 $RUNAS $OPENFILE -f 1286739555 $DIR/d33/f33 || true
2665 run_test 33b "test open file with malformed flags (No panic)"
2668 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2674 remote_ost_nodsh && skip "remote OST with nodsh" && return
2677 test_mkdir -p $DIR/d33
2678 # Read: 0, Write: 4, create/destroy: 2/0, stat: 1, punch: 0
2681 for ostnum in $(seq $OSTCOUNT); do
2682 # test-framework's OST numbering is one-based, while Lustre's
2684 ostname=$(printf "$FSNAME-OST%.4x" $((ostnum - 1)))
2685 # Parsing llobdstat's output sucks; we could grep the /proc
2686 # path, but that's likely to not be as portable as using the
2687 # llobdstat utility. So we parse lctl output instead.
2688 write_bytes=$(do_facet ost$ostnum lctl get_param -n \
2689 obdfilter/$ostname/stats |
2690 awk '/^write_bytes/ {print $7}' )
2691 echo "baseline_write_bytes@$OSTnum/$ostname=$write_bytes"
2692 if (( ${write_bytes:-0} > 0 ))
2699 $all_zeros || return 0
2702 echo foo > $DIR/d33/bar
2706 # Total up write_bytes after writing. We'd better find non-zeros.
2707 for ostnum in $(seq $OSTCOUNT); do
2708 ostname=$(printf "$FSNAME-OST%.4x" $((ostnum - 1)))
2709 write_bytes=$(do_facet ost$ostnum lctl get_param -n \
2710 obdfilter/$ostname/stats |
2711 awk '/^write_bytes/ {print $7}' )
2712 echo "write_bytes@$OSTnum/$ostname=$write_bytes"
2713 if (( ${write_bytes:-0} > 0 ))
2722 for ostnum in $(seq $OSTCOUNT); do
2723 ostname=$(printf "$FSNAME-OST%.4x" $((ostnum - 1)))
2724 echo "Check that write_bytes is present in obdfilter/*/stats:"
2725 do_facet ost$ostnum lctl get_param -n \
2726 obdfilter/$ostname/stats
2728 error "OST not keeping write_bytes stats (b22312)"
2731 run_test 33c "test llobdstat and write_bytes"
2734 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 2 MDTs" && return
2735 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2737 local remote_dir=$DIR/$tdir/remote_dir
2739 test_mkdir -p $DIR/$tdir
2740 $LFS mkdir -i $MDTIDX $remote_dir ||
2741 error "create remote directory failed"
2743 touch $remote_dir/$tfile
2744 chmod 444 $remote_dir/$tfile
2745 chown $RUNAS_ID $remote_dir/$tfile
2747 $RUNAS $OPENFILE -f O_RDWR $DIR/$tfile && error || true
2749 chown $RUNAS_ID $remote_dir
2750 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $remote_dir/f33 ||
2751 error "create" || true
2752 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $remote_dir/f33 &&
2753 error "open RDWR" || true
2754 $RUNAS $OPENFILE -f 1286739555 $remote_dir/f33 || true
2756 run_test 33d "openfile with 444 modes and malformed flags under remote dir"
2759 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2763 $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
2764 $LFS setdirstripe -i1 -c2 $DIR/$tdir/striped_dir1
2765 mkdir $DIR/$tdir/local_dir
2767 local s0_mode=$(stat -c%f $DIR/$tdir/striped_dir)
2768 local s1_mode=$(stat -c%f $DIR/$tdir/striped_dir1)
2769 local l_mode=$(stat -c%f $DIR/$tdir/local_dir)
2771 [ "$l_mode" = "$s0_mode" -a "$l_mode" = "$s1_mode" ] ||
2772 error "mkdir $l_mode striped0 $s0_mode striped1 $s1_mode"
2774 rmdir $DIR/$tdir/* || error "rmdir failed"
2777 $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
2778 $LFS setdirstripe -i1 -c2 $DIR/$tdir/striped_dir1
2779 mkdir $DIR/$tdir/local_dir
2781 s0_mode=$(stat -c%f $DIR/$tdir/striped_dir)
2782 s1_mode=$(stat -c%f $DIR/$tdir/striped_dir1)
2783 l_mode=$(stat -c%f $DIR/$tdir/local_dir)
2785 [ "$l_mode" = "$s0_mode" -a "$l_mode" = "$s1_mode" ] ||
2786 error "mkdir $l_mode striped0 $s0_mode striped1 $s1_mode 777"
2788 rmdir $DIR/$tdir/* || error "rmdir(umask 777) failed"
2791 $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
2792 $LFS setdirstripe -i1 -c2 $DIR/$tdir/striped_dir1
2793 mkdir $DIR/$tdir/local_dir
2795 s0_mode=$(stat -c%f $DIR/$tdir/striped_dir)
2796 s1_mode=$(stat -c%f $DIR/$tdir/striped_dir1)
2797 l_mode=$(stat -c%f $DIR/$tdir/local_dir)
2799 [ "$l_mode" = "$s0_mode" -a "$l_mode" = "$s1_mode" ] ||
2800 error "mkdir $l_mode striped0 $s0_mode striped1 $s1_mode 0"
2802 run_test 33e "mkdir and striped directory should have same mode"
2806 do_facet $SINGLEMDS $LCTL set_param mdt.*.enable_remote_dir_gid=0
2810 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2813 chmod go+rwx $DIR/$tdir
2814 do_facet $SINGLEMDS $LCTL set_param mdt.*.enable_remote_dir_gid=-1
2815 trap cleanup_33f EXIT
2817 $RUNAS lfs mkdir -c$MDSCOUNT $DIR/$tdir/striped_dir ||
2818 error "cannot create striped directory"
2820 $RUNAS touch $DIR/$tdir/striped_dir/{0..16} ||
2821 error "cannot create files in striped directory"
2823 $RUNAS rm $DIR/$tdir/striped_dir/{0..16} ||
2824 error "cannot remove files in striped directory"
2826 $RUNAS rmdir $DIR/$tdir/striped_dir ||
2827 error "cannot remove striped directory"
2831 run_test 33f "nonroot user can create, access, and remove a striped directory"
2833 TEST_34_SIZE=${TEST_34_SIZE:-2000000000000}
2836 $MCREATE $DIR/f34 || error
2837 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" || error
2838 $TRUNCATE $DIR/f34 $TEST_34_SIZE || error
2839 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" || error
2840 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2842 run_test 34a "truncate file that has not been opened ==========="
2845 [ ! -f $DIR/f34 ] && test_34a
2846 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2847 $OPENFILE -f O_RDONLY $DIR/f34
2848 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" || error
2849 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2851 run_test 34b "O_RDONLY opening file doesn't create objects ====="
2854 [ ! -f $DIR/f34 ] && test_34a
2855 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2856 $OPENFILE -f O_RDWR $DIR/f34
2857 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" && error
2858 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2860 run_test 34c "O_RDWR opening file-with-size works =============="
2863 [ ! -f $DIR/f34 ] && test_34a
2864 dd if=/dev/zero of=$DIR/f34 conv=notrunc bs=4k count=1 || error
2865 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2868 run_test 34d "write to sparse file ============================="
2872 $MCREATE $DIR/f34e || error
2873 $TRUNCATE $DIR/f34e 1000 || error
2874 $CHECKSTAT -s 1000 $DIR/f34e || error
2875 $OPENFILE -f O_RDWR $DIR/f34e
2876 $CHECKSTAT -s 1000 $DIR/f34e || error
2878 run_test 34e "create objects, some with size and some without =="
2880 test_34f() { # bug 6242, 6243
2881 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2884 $MCREATE $DIR/f34f || error
2885 $TRUNCATE $DIR/f34f $SIZE34F || error "truncating $DIR/f3f to $SIZE34F"
2886 dd if=$DIR/f34f of=$TMP/f34f
2887 $CHECKSTAT -s $SIZE34F $TMP/f34f || error "$TMP/f34f not $SIZE34F bytes"
2888 dd if=/dev/zero of=$TMP/f34fzero bs=$SIZE34F count=1
2889 cmp $DIR/f34f $TMP/f34fzero || error "$DIR/f34f not all zero"
2890 cmp $TMP/f34f $TMP/f34fzero || error "$TMP/f34f not all zero"
2891 rm $TMP/f34f $TMP/f34fzero $DIR/f34f
2893 run_test 34f "read from a file with no objects until EOF ======="
2896 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2897 dd if=/dev/zero of=$DIR/$tfile bs=1 count=100 seek=$TEST_34_SIZE || error
2898 $TRUNCATE $DIR/$tfile $((TEST_34_SIZE / 2))|| error
2899 $CHECKSTAT -s $((TEST_34_SIZE / 2)) $DIR/$tfile || error "truncate failed"
2900 cancel_lru_locks osc
2901 $CHECKSTAT -s $((TEST_34_SIZE / 2)) $DIR/$tfile || \
2902 error "wrong size after lock cancel"
2904 $TRUNCATE $DIR/$tfile $TEST_34_SIZE || error
2905 $CHECKSTAT -s $TEST_34_SIZE $DIR/$tfile || \
2906 error "expanding truncate failed"
2907 cancel_lru_locks osc
2908 $CHECKSTAT -s $TEST_34_SIZE $DIR/$tfile || \
2909 error "wrong expanded size after lock cancel"
2911 run_test 34g "truncate long file ==============================="
2914 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2918 dd if=/dev/zero of=$DIR/$tfile bs=1M count=10 || error
2919 sync # Flush the cache so that multiop below does not block on cache
2920 # flush when getting the group lock
2921 $MULTIOP $DIR/$tfile OG${gid}T${sz}g${gid}c &
2924 # Since just timed wait is not good enough, let's do a sync write
2925 # that way we are sure enough time for a roundtrip + processing
2926 # passed + 2 seconds of extra margin.
2927 dd if=/dev/zero of=$DIR/${tfile}-1 bs=4096 oflag=direct count=1
2931 if [[ `ps h -o comm -p $MULTIPID` == "multiop" ]]; then
2932 error "Multiop blocked on ftruncate, pid=$MULTIPID"
2936 local nsz=`stat -c %s $DIR/$tfile`
2937 [[ $nsz == $sz ]] || error "New size wrong $nsz != $sz"
2939 run_test 34h "ftruncate file under grouplock should not block"
2942 cp /bin/sh $DIR/f35a
2944 chown $RUNAS_ID $DIR/f35a
2945 $RUNAS $DIR/f35a && error || true
2948 run_test 35a "exec file with mode 444 (should return and not leak) ====="
2952 utime $DIR/f36 || error
2954 run_test 36a "MDS utime check (mknod, utime) ==================="
2958 utime $DIR/f36 || error
2960 run_test 36b "OST utime check (open, utime) ===================="
2965 chown $RUNAS_ID $DIR/d36
2966 $RUNAS utime $DIR/d36/f36 || error
2968 run_test 36c "non-root MDS utime check (mknod, utime) =========="
2971 [ ! -d $DIR/d36 ] && test_36c
2972 echo "" > $DIR/d36/f36
2973 $RUNAS utime $DIR/d36/f36 || error
2975 run_test 36d "non-root OST utime check (open, utime) ==========="
2978 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID -- skipping" && return
2979 test_mkdir -p $DIR/$tdir
2980 touch $DIR/$tdir/$tfile
2981 $RUNAS utime $DIR/$tdir/$tfile && \
2982 error "utime worked, expected failure" || true
2984 run_test 36e "utime on non-owned file (should return error) ===="
2988 local LANG_SAVE=$LANG
2989 local LC_LANG_SAVE=$LC_LANG
2990 export LANG=C LC_LANG=C # for date language
2992 DATESTR="Dec 20 2000"
2993 test_mkdir -p $DIR/$tdir
2994 lctl set_param fail_loc=$fl
2996 cp /etc/hosts $DIR/$tdir/$tfile
2997 sync & # write RPC generated with "current" inode timestamp, but delayed
2999 touch --date="$DATESTR" $DIR/$tdir/$tfile # setattr timestamp in past
3000 LS_BEFORE="`ls -l $DIR/$tdir/$tfile`" # old timestamp from client cache
3001 cancel_lru_locks osc
3002 LS_AFTER="`ls -l $DIR/$tdir/$tfile`" # timestamp from OST object
3004 [ "$LS_BEFORE" != "$LS_AFTER" ] && \
3005 echo "BEFORE: $LS_BEFORE" && \
3006 echo "AFTER : $LS_AFTER" && \
3007 echo "WANT : $DATESTR" && \
3008 error "$DIR/$tdir/$tfile timestamps changed" || true
3010 export LANG=$LANG_SAVE LC_LANG=$LC_LANG_SAVE
3014 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3015 #define OBD_FAIL_OST_BRW_PAUSE_BULK 0x214
3016 subr_36fh "0x80000214"
3018 run_test 36f "utime on file racing with OST BRW write =========="
3021 remote_ost_nodsh && skip "remote OST with nodsh" && return
3022 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3027 test_mkdir -p $DIR/$tdir
3028 fmd_max_age=$(do_facet ost1 \
3029 "lctl get_param -n obdfilter.*.client_cache_seconds 2> /dev/null | \
3032 fmd_before=$(do_facet ost1 \
3033 "awk '/ll_fmd_cache/ {print \\\$2}' /proc/slabinfo")
3034 touch $DIR/$tdir/$tfile
3035 sleep $((fmd_max_age + 12))
3036 fmd_after=$(do_facet ost1 \
3037 "awk '/ll_fmd_cache/ {print \\\$2}' /proc/slabinfo")
3039 echo "fmd_before: $fmd_before"
3040 echo "fmd_after: $fmd_after"
3041 [[ $fmd_after -gt $fmd_before ]] &&
3042 echo "AFTER: $fmd_after > BEFORE: $fmd_before" &&
3043 error "fmd didn't expire after ping" || true
3045 run_test 36g "filter mod data cache expiry ====================="
3048 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3049 #define OBD_FAIL_OST_BRW_PAUSE_BULK2 0x227
3050 subr_36fh "0x80000227"
3052 run_test 36h "utime on file racing with OST BRW write =========="
3055 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
3057 test_mkdir $DIR/$tdir
3058 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR/$tdir/striped_dir
3060 local mtime=$(stat -c%Y $DIR/$tdir/striped_dir)
3061 local new_mtime=$((mtime + 200))
3063 #change Modify time of striped dir
3064 touch -m -d @$new_mtime $DIR/$tdir/striped_dir ||
3065 error "change mtime failed"
3067 local got=$(stat -c%Y $DIR/$tdir/striped_dir)
3069 [ "$new_mtime" = "$got" ] || error "expect $new_mtime got $got"
3071 run_test 36i "change mtime on striped directory"
3073 # test_37 - duplicate with tests 32q 32r
3076 local file=$DIR/$tfile
3078 openfile -f O_DIRECTORY $file
3081 [ $RC -eq 0 ] && error "opened file $file with O_DIRECTORY" || true
3082 [ $RC -eq $ENOTDIR ] || error "error $RC should be ENOTDIR ($ENOTDIR)"
3084 run_test 38 "open a regular file with O_DIRECTORY should return -ENOTDIR ==="
3088 touch $DIR/${tfile}2
3089 # ls -l $DIR/$tfile $DIR/${tfile}2
3090 # ls -lu $DIR/$tfile $DIR/${tfile}2
3091 # ls -lc $DIR/$tfile $DIR/${tfile}2
3093 $OPENFILE -f O_CREAT:O_TRUNC:O_WRONLY $DIR/${tfile}2
3094 if [ ! $DIR/${tfile}2 -nt $DIR/$tfile ]; then
3096 ls -l --full-time $DIR/$tfile $DIR/${tfile}2
3098 ls -lu --full-time $DIR/$tfile $DIR/${tfile}2
3100 ls -lc --full-time $DIR/$tfile $DIR/${tfile}2
3101 error "O_TRUNC didn't change timestamps"
3104 run_test 39 "mtime changed on create ==========================="
3107 test_mkdir -p -c1 $DIR/$tdir
3108 cp -p /etc/passwd $DIR/$tdir/fopen
3109 cp -p /etc/passwd $DIR/$tdir/flink
3110 cp -p /etc/passwd $DIR/$tdir/funlink
3111 cp -p /etc/passwd $DIR/$tdir/frename
3112 ln $DIR/$tdir/funlink $DIR/$tdir/funlink2
3115 echo "aaaaaa" >> $DIR/$tdir/fopen
3116 echo "aaaaaa" >> $DIR/$tdir/flink
3117 echo "aaaaaa" >> $DIR/$tdir/funlink
3118 echo "aaaaaa" >> $DIR/$tdir/frename
3120 local open_new=`stat -c %Y $DIR/$tdir/fopen`
3121 local link_new=`stat -c %Y $DIR/$tdir/flink`
3122 local unlink_new=`stat -c %Y $DIR/$tdir/funlink`
3123 local rename_new=`stat -c %Y $DIR/$tdir/frename`
3125 cat $DIR/$tdir/fopen > /dev/null
3126 ln $DIR/$tdir/flink $DIR/$tdir/flink2
3127 rm -f $DIR/$tdir/funlink2
3128 mv -f $DIR/$tdir/frename $DIR/$tdir/frename2
3130 for (( i=0; i < 2; i++ )) ; do
3131 local open_new2=`stat -c %Y $DIR/$tdir/fopen`
3132 local link_new2=`stat -c %Y $DIR/$tdir/flink`
3133 local unlink_new2=`stat -c %Y $DIR/$tdir/funlink`
3134 local rename_new2=`stat -c %Y $DIR/$tdir/frename2`
3136 [ $open_new2 -eq $open_new ] || error "open file reverses mtime"
3137 [ $link_new2 -eq $link_new ] || error "link file reverses mtime"
3138 [ $unlink_new2 -eq $unlink_new ] || error "unlink file reverses mtime"
3139 [ $rename_new2 -eq $rename_new ] || error "rename file reverses mtime"
3141 cancel_lru_locks osc
3142 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3145 run_test 39b "mtime change on open, link, unlink, rename ======"
3147 # this should be set to past
3148 TEST_39_MTIME=`date -d "1 year ago" +%s`
3154 local mtime0=`stat -c %Y $DIR1/$tfile`
3156 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3157 local mtime1=`stat -c %Y $DIR1/$tfile`
3158 [ "$mtime1" = $TEST_39_MTIME ] || \
3159 error "mtime is not set to past: $mtime1, should be $TEST_39_MTIME"
3162 echo hello >> $DIR1/$tfile
3164 local mtime2=`stat -c %Y $DIR1/$tfile`
3165 [ "$mtime2" -ge "$d1" ] && [ "$mtime2" -le "$d2" ] || \
3166 error "mtime is not updated on write: $d1 <= $mtime2 <= $d2"
3168 mv $DIR1/$tfile $DIR1/$tfile-1
3170 for (( i=0; i < 2; i++ )) ; do
3171 local mtime3=`stat -c %Y $DIR1/$tfile-1`
3172 [ "$mtime2" = "$mtime3" ] || \
3173 error "mtime ($mtime2) changed (to $mtime3) on rename"
3175 cancel_lru_locks osc
3176 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3179 run_test 39c "mtime change on rename ==========================="
3183 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3186 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3188 for (( i=0; i < 2; i++ )) ; do
3189 local mtime=`stat -c %Y $DIR1/$tfile`
3190 [ $mtime = $TEST_39_MTIME ] || \
3191 error "mtime($mtime) is not set to $TEST_39_MTIME"
3193 cancel_lru_locks osc
3194 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3197 run_test 39d "create, utime, stat =============================="
3201 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3203 local mtime1=`stat -c %Y $DIR1/$tfile`
3205 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3207 for (( i=0; i < 2; i++ )) ; do
3208 local mtime2=`stat -c %Y $DIR1/$tfile`
3209 [ $mtime2 = $TEST_39_MTIME ] || \
3210 error "mtime($mtime2) is not set to $TEST_39_MTIME"
3212 cancel_lru_locks osc
3213 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3216 run_test 39e "create, stat, utime, stat ========================"
3220 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3222 mtime1=`stat -c %Y $DIR1/$tfile`
3225 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3227 for (( i=0; i < 2; i++ )) ; do
3228 local mtime2=`stat -c %Y $DIR1/$tfile`
3229 [ $mtime2 = $TEST_39_MTIME ] || \
3230 error "mtime($mtime2) is not set to $TEST_39_MTIME"
3232 cancel_lru_locks osc
3233 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3236 run_test 39f "create, stat, sleep, utime, stat ================="
3240 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3241 echo hello >> $DIR1/$tfile
3242 local mtime1=`stat -c %Y $DIR1/$tfile`
3245 chmod o+r $DIR1/$tfile
3247 for (( i=0; i < 2; i++ )) ; do
3248 local mtime2=`stat -c %Y $DIR1/$tfile`
3249 [ "$mtime1" = "$mtime2" ] || \
3250 error "lost mtime: $mtime2, should be $mtime1"
3252 cancel_lru_locks osc
3253 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3256 run_test 39g "write, chmod, stat ==============================="
3260 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3265 echo hello >> $DIR1/$tfile
3266 local mtime1=`stat -c %Y $DIR1/$tfile`
3268 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3270 if [ "$d1" != "$d2" ]; then
3271 echo "write and touch not within one second"
3273 for (( i=0; i < 2; i++ )) ; do
3274 local mtime2=`stat -c %Y $DIR1/$tfile`
3275 [ "$mtime2" = $TEST_39_MTIME ] || \
3276 error "lost mtime: $mtime2, should be $TEST_39_MTIME"
3278 cancel_lru_locks osc
3279 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3283 run_test 39h "write, utime within one second, stat ============="
3286 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3290 echo hello >> $DIR1/$tfile
3291 local mtime1=`stat -c %Y $DIR1/$tfile`
3293 mv $DIR1/$tfile $DIR1/$tfile-1
3295 for (( i=0; i < 2; i++ )) ; do
3296 local mtime2=`stat -c %Y $DIR1/$tfile-1`
3298 [ "$mtime1" = "$mtime2" ] || \
3299 error "lost mtime: $mtime2, should be $mtime1"
3301 cancel_lru_locks osc
3302 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3305 run_test 39i "write, rename, stat =============================="
3308 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3309 start_full_debug_logging
3313 #define OBD_FAIL_OSC_DELAY_SETTIME 0x412
3314 lctl set_param fail_loc=0x80000412
3315 multiop_bg_pause $DIR1/$tfile oO_RDWR:w2097152_c ||
3316 error "multiop failed"
3318 local mtime1=`stat -c %Y $DIR1/$tfile`
3320 mv $DIR1/$tfile $DIR1/$tfile-1
3322 kill -USR1 $multipid
3323 wait $multipid || error "multiop close failed"
3325 for (( i=0; i < 2; i++ )) ; do
3326 local mtime2=`stat -c %Y $DIR1/$tfile-1`
3327 [ "$mtime1" = "$mtime2" ] ||
3328 error "mtime is lost on close: $mtime2, " \
3331 cancel_lru_locks osc
3332 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3334 lctl set_param fail_loc=0
3335 stop_full_debug_logging
3337 run_test 39j "write, rename, close, stat ======================="
3340 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3344 multiop_bg_pause $DIR1/$tfile oO_RDWR:w2097152_c || error "multiop failed"
3346 local mtime1=`stat -c %Y $DIR1/$tfile`
3348 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3350 kill -USR1 $multipid
3351 wait $multipid || error "multiop close failed"
3353 for (( i=0; i < 2; i++ )) ; do
3354 local mtime2=`stat -c %Y $DIR1/$tfile`
3356 [ "$mtime2" = $TEST_39_MTIME ] || \
3357 error "mtime is lost on close: $mtime2, should be $TEST_39_MTIME"
3359 cancel_lru_locks osc
3360 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3363 run_test 39k "write, utime, close, stat ========================"
3365 # this should be set to future
3366 TEST_39_ATIME=`date -d "1 year" +%s`
3369 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3370 remote_mds_nodsh && skip "remote MDS with nodsh" && return
3371 local atime_diff=$(do_facet $SINGLEMDS \
3372 lctl get_param -n mdd.*MDT0000*.atime_diff)
3376 # test setting directory atime to future
3377 touch -a -d @$TEST_39_ATIME $DIR/$tdir
3378 local atime=$(stat -c %X $DIR/$tdir)
3379 [ "$atime" = $TEST_39_ATIME ] ||
3380 error "atime is not set to future: $atime, $TEST_39_ATIME"
3382 # test setting directory atime from future to now
3383 local now=$(date +%s)
3384 touch -a -d @$now $DIR/$tdir
3386 atime=$(stat -c %X $DIR/$tdir)
3387 [ "$atime" -eq "$now" ] ||
3388 error "atime is not updated from future: $atime, $now"
3390 do_facet $SINGLEMDS lctl set_param -n mdd.*MDT0000*.atime_diff=2