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: LU-9693 LU-6493 LU-9693 LU-11058
12 ALWAYS_EXCEPT="$SANITY_EXCEPT 42a 42b 42c 77k"
13 # UPDATE THE COMMENT ABOVE WITH BUG NUMBERS WHEN CHANGING ALWAYS_EXCEPT!
15 # skipped tests: LU-8411 LU-9096 LU-9054 ..
16 ALWAYS_EXCEPT=" 407 253 312 $ALWAYS_EXCEPT"
19 # bug number for skipped tests: LU-9795 (all below)
20 ALWAYS_EXCEPT="$ALWAYS_EXCEPT 17n 60a 133g 300f"
23 # Check Grants after these tests
24 GRANT_CHECK_LIST="$GRANT_CHECK_LIST 42a 42b 42c 42d 42e 63a 63b 64a 64b 64c"
25 SRCDIR=$(cd $(dirname $0); echo $PWD)
26 export PATH=$PATH:/sbin
32 CHECKSTAT=${CHECKSTAT:-"checkstat -v"}
33 CREATETEST=${CREATETEST:-createtest}
35 LVERIFY=${LVERIFY:-ll_dirstripe_verify}
37 OPENFILE=${OPENFILE:-openfile}
38 OPENUNLINK=${OPENUNLINK:-openunlink}
39 export MULTIOP=${MULTIOP:-multiop}
40 READS=${READS:-"reads"}
41 MUNLINK=${MUNLINK:-munlink}
42 SOCKETSERVER=${SOCKETSERVER:-socketserver}
43 SOCKETCLIENT=${SOCKETCLIENT:-socketclient}
44 MEMHOG=${MEMHOG:-memhog}
45 DIRECTIO=${DIRECTIO:-directio}
46 ACCEPTOR_PORT=${ACCEPTOR_PORT:-988}
48 CHECK_GRANT=${CHECK_GRANT:-"yes"}
49 GRANT_CHECK_LIST=${GRANT_CHECK_LIST:-""}
50 export PARALLEL=${PARALLEL:-"no"}
52 export NAME=${NAME:-local}
59 LUSTRE=${LUSTRE:-$(cd $(dirname $0)/..; echo $PWD)}
60 LUSTRE_TESTS_API_DIR=${LUSTRE_TESTS_API_DIR:-${LUSTRE}/tests/clientapi}
61 . $LUSTRE/tests/test-framework.sh
63 . ${CONFIG:=$LUSTRE/tests/cfg/${NAME}.sh}
66 if [[ $MDSCOUNT -gt 1 ]]; then
67 # bug number: LU-11161
68 ALWAYS_EXCEPT+=" 160g"
72 [ "$SLOW" = "no" ] && EXCEPT_SLOW="27m 64b 68 71 115 300o"
74 if [ $(facet_fstype $SINGLEMDS) = "zfs" ]; then
75 # bug number for skipped test: LU-1957
76 ALWAYS_EXCEPT="$ALWAYS_EXCEPT 180"
78 [ "$SLOW" = "no" ] && EXCEPT_SLOW="$EXCEPT_SLOW 51b"
81 # Get the SLES distro version
83 # Returns a version string that should only be used in comparing
84 # strings returned by version_code()
87 local version=$(grep VERSION_ID /etc/os-release | cut -d'"' -f2)
89 # All SuSE Linux versions have one decimal. version_code expects two
90 local sles_version=$version.0
91 version_code $sles_version
94 # Check if we are running on Ubuntu or SLES so we can make decisions on
96 if [ -r /etc/SuSE-release ]; then
97 sles_version=$(sles_version_code)
98 [ $sles_version -lt $(version_code 11.4.0) ] &&
99 # bug number for skipped test: LU-4341
100 ALWAYS_EXCEPT="$ALWAYS_EXCEPT 170"
101 [ $sles_version -lt $(version_code 12.0.0) ] &&
102 # bug number for skipped test: LU-3703
103 ALWAYS_EXCEPT="$ALWAYS_EXCEPT 234"
104 elif [ -r /etc/os-release ]; then
105 if grep -qi ubuntu /etc/os-release; then
106 ubuntu_version=$(version_code $(sed -n -e 's/"//g' \
107 -e 's/^VERSION=//p' \
111 if [[ $ubuntu_version -gt $(version_code 16.0.0) ]]; then
112 # bug number for skipped test:
113 # LU-10334 LU-10335 LU-10335 LU-10335
114 ALWAYS_EXCEPT+=" 103a 130a 130b 130c"
115 # LU-10335 LU-10335 LU-10366
116 ALWAYS_EXCEPT+=" 130d 130e 410"
125 pgrep ll_sa > /dev/null && { echo "There are ll_sa thread not exit!"; exit 20; }
126 cleanupall ${FORCE} $* || { echo "FAILed to clean up"; exit 20; }
135 check_swap_layouts_support()
137 $LCTL get_param -n llite.*.sbi_flags | grep -q layout ||
138 skip "Does not support layout lock."
141 check_and_setup_lustre
145 MAXFREE=${MAXFREE:-$((200000 * $OSTCOUNT))}
147 [ -f $DIR/d52a/foo ] && chattr -a $DIR/d52a/foo
148 [ -f $DIR/d52b/foo ] && chattr -i $DIR/d52b/foo
149 rm -rf $DIR/[Rdfs][0-9]*
151 # $RUNAS_ID may get set incorrectly somewhere else
152 [ $UID -eq 0 -a $RUNAS_ID -eq 0 ] && error "\$RUNAS_ID set to 0, but \$UID is also 0!"
154 check_runas_id $RUNAS_ID $RUNAS_GID $RUNAS
158 if [ "${ONLY}" = "MOUNT" ] ; then
159 echo "Lustre is up, please go on"
163 echo "preparing for tests involving mounts"
164 EXT2_DEV=${EXT2_DEV:-$TMP/SANITY.LOOP}
166 mke2fs -j -F $EXT2_DEV 8000 > /dev/null
167 echo # add a newline after mke2fs.
171 OLDDEBUG=$(lctl get_param -n debug 2> /dev/null)
172 lctl set_param debug=-1 2> /dev/null || true
175 $CHECKSTAT -t file $DIR/$tfile || error "$tfile is not a file"
177 $CHECKSTAT -a $DIR/$tfile || error "$tfile was not removed"
179 run_test 0a "touch; rm ====================="
182 chmod 0755 $DIR || error "chmod 0755 $DIR failed"
183 $CHECKSTAT -p 0755 $DIR || error "$DIR permission is not 0755"
185 run_test 0b "chmod 0755 $DIR ============================="
188 $LCTL get_param mdc.*.import | grep "state: FULL" ||
189 error "import not FULL"
190 $LCTL get_param mdc.*.import | grep "target: $FSNAME-MDT" ||
193 run_test 0c "check import proc"
195 test_0d() { # LU-3397
196 [ $(lustre_version_code mgs) -lt $(version_code 2.10.57) ] &&
197 skip "proc exports not supported before 2.10.57"
199 local mgs_exp="mgs.MGS.exports"
200 local client_uuid=$($LCTL get_param -n mgc.*.uuid)
202 local exp_client_version
205 local temp_imp=$DIR/$tfile.import
206 local temp_exp=$DIR/$tfile.export
208 # save mgc import file to $temp_imp
209 $LCTL get_param mgc.*.import | tee $temp_imp
210 # Check if client uuid is found in MGS export
211 for exp_client_nid in $(do_facet mgs $LCTL get_param -N $mgs_exp.*); do
212 [ $(do_facet mgs $LCTL get_param -n $exp_client_nid.uuid) == \
216 # save mgs export file to $temp_exp
217 do_facet mgs $LCTL get_param $exp_client_nid.export | tee $temp_exp
219 # Compare the value of field "connect_flags"
220 imp_val=$(grep "connect_flags" $temp_imp)
221 exp_val=$(grep "connect_flags" $temp_exp)
222 [ "$exp_val" == "$imp_val" ] ||
223 error "export flags '$exp_val' != import flags '$imp_val'"
225 # Compare the value of client version
226 exp_client_version=$(awk '/target_version:/ { print $2 }' $temp_exp)
227 exp_val=$(version_code $exp_client_version)
228 imp_val=$(lustre_version_code client)
229 [ "$exp_val" == "$imp_val" ] ||
230 error "export client version '$exp_val' != '$imp_val'"
232 run_test 0d "check export proc ============================="
235 test_mkdir $DIR/$tdir
236 test_mkdir $DIR/$tdir/d2
237 mkdir $DIR/$tdir/d2 && error "we expect EEXIST, but not returned"
238 $CHECKSTAT -t dir $DIR/$tdir/d2 || error "$tdir/d2 is not a dir"
241 $CHECKSTAT -a $DIR/$tdir || error "$tdir was not removed"
243 run_test 1 "mkdir; remkdir; rmdir"
246 test_mkdir $DIR/$tdir
247 touch $DIR/$tdir/$tfile || error "touch $tdir/$tfile failed"
248 $CHECKSTAT -t file $DIR/$tdir/$tfile || error "$tdir/$tfile not a file"
250 $CHECKSTAT -a $DIR/$tdir/$tfile || error "$tdir/$file is not removed"
252 run_test 2 "mkdir; touch; rmdir; check file"
255 test_mkdir $DIR/$tdir
256 $CHECKSTAT -t dir $DIR/$tdir || error "$tdir is not a directory"
257 touch $DIR/$tdir/$tfile
258 $CHECKSTAT -t file $DIR/$tdir/$tfile || error "$tdir/$tfile not a file"
260 $CHECKSTAT -a $DIR/$tdir || error "$tdir is not removed"
262 run_test 3 "mkdir; touch; rmdir; check dir"
264 # LU-4471 - failed rmdir on remote directories still removes directory on MDT0
266 test_mkdir -i 1 $DIR/$tdir
268 touch $DIR/$tdir/$tfile ||
269 error "Create file under remote directory failed"
272 error "Expect error removing in-use dir $DIR/$tdir"
274 test -d $DIR/$tdir || error "Remote directory disappeared"
276 rm -rf $DIR/$tdir || error "remove remote dir error"
278 run_test 4 "mkdir; touch dir/file; rmdir; checkdir (expect error)"
281 test_mkdir $DIR/$tdir
282 test_mkdir $DIR/$tdir/d2
283 chmod 0707 $DIR/$tdir/d2 || error "chmod 0707 $tdir/d2 failed"
284 $CHECKSTAT -t dir -p 0707 $DIR/$tdir/d2 || error "$tdir/d2 not mode 707"
285 $CHECKSTAT -t dir $DIR/$tdir/d2 || error "$tdir/d2 is not a directory"
287 run_test 5 "mkdir .../d5 .../d5/d2; chmod .../d5/d2"
290 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
291 chmod 0666 $DIR/$tfile || error "chmod 0666 $tfile failed"
292 $CHECKSTAT -t file -p 0666 -u \#$UID $DIR/$tfile ||
293 error "$tfile does not have perm 0666 or UID $UID"
294 $RUNAS chmod 0444 $DIR/$tfile && error "chmod $tfile worked on UID $UID"
295 $CHECKSTAT -t file -p 0666 -u \#$UID $DIR/$tfile ||
296 error "$tfile should be 0666 and owned by UID $UID"
298 run_test 6a "touch f6a; chmod f6a; $RUNAS chmod f6a (should return error) =="
301 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID"
304 chown $RUNAS_ID $DIR/$tfile || error "chown $RUNAS_ID $file failed"
305 $CHECKSTAT -t file -u \#$RUNAS_ID $DIR/$tfile ||
306 error "$tfile should be owned by UID $RUNAS_ID"
307 $RUNAS chown $UID $DIR/$tfile && error "chown $UID $file succeeded"
308 $CHECKSTAT -t file -u \#$RUNAS_ID $DIR/$tfile ||
309 error "$tfile should be owned by UID $RUNAS_ID"
311 run_test 6c "touch f6c; chown f6c; $RUNAS chown f6c (should return error) =="
314 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID"
317 chgrp $RUNAS_ID $DIR/$tfile || error "chgrp $RUNAS_ID $file failed"
318 $CHECKSTAT -t file -u \#$UID -g \#$RUNAS_ID $DIR/$tfile ||
319 error "$tfile should be owned by GID $UID"
320 $RUNAS chgrp $UID $DIR/$tfile && error "chgrp $UID $file succeeded"
321 $CHECKSTAT -t file -u \#$UID -g \#$RUNAS_ID $DIR/$tfile ||
322 error "$tfile should be owned by UID $UID and GID $RUNAS_ID"
324 run_test 6e "touch+chgrp $tfile; $RUNAS chgrp $tfile (should return error)"
327 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID"
329 test_mkdir $DIR/$tdir
330 chmod 777 $DIR/$tdir || error "chmod 0777 $tdir failed"
331 $RUNAS mkdir $DIR/$tdir/d || error "mkdir $tdir/d failed"
332 chmod g+s $DIR/$tdir/d || error "chmod g+s $tdir/d failed"
333 test_mkdir $DIR/$tdir/d/subdir
334 $CHECKSTAT -g \#$RUNAS_GID $DIR/$tdir/d/subdir ||
335 error "$tdir/d/subdir should be GID $RUNAS_GID"
336 if [[ $MDSCOUNT -gt 1 ]]; then
337 # check remote dir sgid inherite
338 $LFS mkdir -i 0 $DIR/$tdir.local ||
339 error "mkdir $tdir.local failed"
340 chmod g+s $DIR/$tdir.local ||
341 error "chmod $tdir.local failed"
342 chgrp $RUNAS_GID $DIR/$tdir.local ||
343 error "chgrp $tdir.local failed"
344 $LFS mkdir -i 1 $DIR/$tdir.local/$tdir.remote ||
345 error "mkdir $tdir.remote failed"
346 $CHECKSTAT -g \#$RUNAS_GID $DIR/$tdir.local/$tdir.remote ||
347 error "$tdir.remote should be owned by $UID.$RUNAS_ID"
348 $CHECKSTAT -p 02755 $DIR/$tdir.local/$tdir.remote ||
349 error "$tdir.remote should be mode 02755"
352 run_test 6g "verify new dir in sgid dir inherits group"
354 test_6h() { # bug 7331
355 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID"
357 touch $DIR/$tfile || error "touch failed"
358 chown $RUNAS_ID:$RUNAS_GID $DIR/$tfile || error "initial chown failed"
359 $RUNAS -G$RUNAS_GID chown $RUNAS_ID:0 $DIR/$tfile &&
360 error "chown $RUNAS_ID:0 $tfile worked as GID $RUNAS_GID"
361 $CHECKSTAT -t file -u \#$RUNAS_ID -g \#$RUNAS_GID $DIR/$tfile ||
362 error "$tdir/$tfile should be UID $RUNAS_UID GID $RUNAS_GID"
364 run_test 6h "$RUNAS chown RUNAS_ID.0 .../$tfile (should return error)"
367 test_mkdir $DIR/$tdir
368 $MCREATE $DIR/$tdir/$tfile
369 chmod 0666 $DIR/$tdir/$tfile
370 $CHECKSTAT -t file -p 0666 $DIR/$tdir/$tfile ||
371 error "$tdir/$tfile should be mode 0666"
373 run_test 7a "mkdir .../d7; mcreate .../d7/f; chmod .../d7/f ===="
376 if [ ! -d $DIR/$tdir ]; then
377 test_mkdir $DIR/$tdir
379 $MCREATE $DIR/$tdir/$tfile
380 echo -n foo > $DIR/$tdir/$tfile
381 [ "$(cat $DIR/$tdir/$tfile)" = "foo" ] || error "$tdir/$tfile not 'foo'"
382 $CHECKSTAT -t file -s 3 $DIR/$tdir/$tfile || error "$tfile size not 3"
384 run_test 7b "mkdir .../d7; mcreate d7/f2; echo foo > d7/f2 ====="
387 test_mkdir $DIR/$tdir
388 touch $DIR/$tdir/$tfile
389 chmod 0666 $DIR/$tdir/$tfile
390 $CHECKSTAT -t file -p 0666 $DIR/$tdir/$tfile ||
391 error "$tfile mode not 0666"
393 run_test 8 "mkdir .../d8; touch .../d8/f; chmod .../d8/f ======="
396 test_mkdir $DIR/$tdir
397 test_mkdir $DIR/$tdir/d2
398 test_mkdir $DIR/$tdir/d2/d3
399 $CHECKSTAT -t dir $DIR/$tdir/d2/d3 || error "$tdir/d2/d3 not a dir"
401 run_test 9 "mkdir .../d9 .../d9/d2 .../d9/d2/d3 ================"
404 test_mkdir $DIR/$tdir
405 test_mkdir $DIR/$tdir/d2
406 touch $DIR/$tdir/d2/$tfile
407 $CHECKSTAT -t file $DIR/$tdir/d2/$tfile ||
408 error "$tdir/d2/$tfile not a file"
410 run_test 10 "mkdir .../d10 .../d10/d2; touch .../d10/d2/f ======"
413 test_mkdir $DIR/$tdir
414 test_mkdir $DIR/$tdir/d2
415 chmod 0666 $DIR/$tdir/d2
416 chmod 0705 $DIR/$tdir/d2
417 $CHECKSTAT -t dir -p 0705 $DIR/$tdir/d2 ||
418 error "$tdir/d2 mode not 0705"
420 run_test 11 "mkdir .../d11 d11/d2; chmod .../d11/d2 ============"
423 test_mkdir $DIR/$tdir
424 touch $DIR/$tdir/$tfile
425 chmod 0666 $DIR/$tdir/$tfile
426 chmod 0654 $DIR/$tdir/$tfile
427 $CHECKSTAT -t file -p 0654 $DIR/$tdir/$tfile ||
428 error "$tdir/d2 mode not 0654"
430 run_test 12 "touch .../d12/f; chmod .../d12/f .../d12/f ========"
433 test_mkdir $DIR/$tdir
434 dd if=/dev/zero of=$DIR/$tdir/$tfile count=10
436 $CHECKSTAT -t file -s 0 $DIR/$tdir/$tfile ||
437 error "$tdir/$tfile size not 0 after truncate"
439 run_test 13 "creat .../d13/f; dd .../d13/f; > .../d13/f ========"
442 test_mkdir $DIR/$tdir
443 touch $DIR/$tdir/$tfile
445 $CHECKSTAT -a $DIR/$tdir/$tfile || error "$tdir/$tfile not removed"
447 run_test 14 "touch .../d14/f; rm .../d14/f; rm .../d14/f ======="
450 test_mkdir $DIR/$tdir
451 touch $DIR/$tdir/$tfile
452 mv $DIR/$tdir/$tfile $DIR/$tdir/${tfile}_2
453 $CHECKSTAT -t file $DIR/$tdir/${tfile}_2 ||
454 error "$tdir/${tfile_2} not a file after rename"
455 rm $DIR/$tdir/${tfile}_2 || error "unlink failed after rename"
457 run_test 15 "touch .../d15/f; mv .../d15/f .../d15/f2 =========="
460 test_mkdir $DIR/$tdir
461 touch $DIR/$tdir/$tfile
462 rm -rf $DIR/$tdir/$tfile
463 $CHECKSTAT -a $DIR/$tdir/$tfile || error "$tdir/$tfile not removed"
465 run_test 16 "touch .../d16/f; rm -rf .../d16/f"
468 test_mkdir $DIR/$tdir
469 touch $DIR/$tdir/$tfile
470 ln -s $DIR/$tdir/$tfile $DIR/$tdir/l-exist
472 $CHECKSTAT -l $DIR/$tdir/$tfile $DIR/$tdir/l-exist ||
473 error "$tdir/l-exist not a symlink"
474 $CHECKSTAT -f -t f $DIR/$tdir/l-exist ||
475 error "$tdir/l-exist not referencing a file"
476 rm -f $DIR/$tdir/l-exist
477 $CHECKSTAT -a $DIR/$tdir/l-exist || error "$tdir/l-exist not removed"
479 run_test 17a "symlinks: create, remove (real)"
482 test_mkdir $DIR/$tdir
483 ln -s no-such-file $DIR/$tdir/l-dangle
485 $CHECKSTAT -l no-such-file $DIR/$tdir/l-dangle ||
486 error "$tdir/l-dangle not referencing no-such-file"
487 $CHECKSTAT -fa $DIR/$tdir/l-dangle ||
488 error "$tdir/l-dangle not referencing non-existent file"
489 rm -f $DIR/$tdir/l-dangle
490 $CHECKSTAT -a $DIR/$tdir/l-dangle || error "$tdir/l-dangle not removed"
492 run_test 17b "symlinks: create, remove (dangling)"
494 test_17c() { # bug 3440 - don't save failed open RPC for replay
495 test_mkdir $DIR/$tdir
496 ln -s foo $DIR/$tdir/$tfile
497 cat $DIR/$tdir/$tfile && error "opened non-existent symlink" || true
499 run_test 17c "symlinks: open dangling (should return error)"
502 test_mkdir $DIR/$tdir
503 ln -s foo $DIR/$tdir/$tfile
504 touch $DIR/$tdir/$tfile || error "creating to new symlink"
506 run_test 17d "symlinks: create dangling"
509 test_mkdir $DIR/$tdir
510 local foo=$DIR/$tdir/$tfile
511 ln -s $foo $foo || error "create symlink failed"
512 ls -l $foo || error "ls -l failed"
513 ls $foo && error "ls not failed" || true
515 run_test 17e "symlinks: create recursive symlink (should return error)"
518 test_mkdir $DIR/$tdir
519 ln -s 1234567890/2234567890/3234567890/4234567890 $DIR/$tdir/111
520 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890 $DIR/$tdir/222
521 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890 $DIR/$tdir/333
522 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890/9234567890/a234567890/b234567890 $DIR/$tdir/444
523 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890/9234567890/a234567890/b234567890/c234567890/d234567890/f234567890 $DIR/$tdir/555
524 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
527 run_test 17f "symlinks: long and very long symlink name"
529 # str_repeat(S, N) generate a string that is string S repeated N times
534 while [ $((n -= 1)) -ge 0 ]; do
540 # Long symlinks and LU-2241
542 test_mkdir $DIR/$tdir
543 local TESTS="59 60 61 4094 4095"
545 # Fix for inode size boundary in 2.1.4
546 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.1.4) ] &&
549 # Patch not applied to 2.2 or 2.3 branches
550 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] &&
551 [ $(lustre_version_code $SINGLEMDS) -le $(version_code 2.3.55) ] &&
554 # skip long symlink name for rhel6.5.
555 # rhel6.5 has a limit (PATH_MAX - sizeof(struct filename))
556 grep -q '6.5' /etc/redhat-release &>/dev/null &&
557 TESTS="59 60 61 4062 4063"
560 local SYMNAME=$(str_repeat 'x' $i)
561 ln -s $SYMNAME $DIR/$tdir/f$i || error "failed $i-char symlink"
562 readlink $DIR/$tdir/f$i || error "failed $i-char readlink"
565 run_test 17g "symlinks: really long symlink name and inode boundaries"
567 test_17h() { #bug 17378
568 [ $PARALLEL == "yes" ] && skip "skip parallel run"
569 remote_mds_nodsh && skip "remote MDS with nodsh"
573 test_mkdir $DIR/$tdir
574 mdt_idx=$($LFS getdirstripe -i $DIR/$tdir)
575 $LFS setstripe -c -1 $DIR/$tdir
576 #define OBD_FAIL_MDS_LOV_PREP_CREATE 0x141
577 do_facet mds$((mdt_idx + 1)) lctl set_param fail_loc=0x80000141
578 touch $DIR/$tdir/$tfile || true
580 run_test 17h "create objects: lov_free_memmd() doesn't lbug"
582 test_17i() { #bug 20018
583 [ $PARALLEL == "yes" ] && skip "skip parallel run"
584 remote_mds_nodsh && skip "remote MDS with nodsh"
586 local foo=$DIR/$tdir/$tfile
589 test_mkdir -c1 $DIR/$tdir
590 mdt_idx=$($LFS getdirstripe -i $DIR/$tdir)
591 ln -s $foo $foo || error "create symlink failed"
592 #define OBD_FAIL_MDS_READLINK_EPROTO 0x143
593 do_facet mds$((mdt_idx + 1)) lctl set_param fail_loc=0x80000143
594 ls -l $foo && error "error not detected"
597 run_test 17i "don't panic on short symlink (should return error)"
599 test_17k() { #bug 22301
600 [ $PARALLEL == "yes" ] && skip "skip parallel run"
601 [[ -z "$(which rsync 2>/dev/null)" ]] &&
602 skip "no rsync command"
603 rsync --help | grep -q xattr ||
604 skip_env "$(rsync --version | head -n1) does not support xattrs"
605 test_mkdir $DIR/$tdir
606 test_mkdir $DIR/$tdir.new
607 touch $DIR/$tdir/$tfile
608 ln -s $DIR/$tdir/$tfile $DIR/$tdir/$tfile.lnk
609 rsync -av -X $DIR/$tdir/ $DIR/$tdir.new ||
610 error "rsync failed with xattrs enabled"
612 run_test 17k "symlinks: rsync with xattrs enabled"
614 test_17l() { # LU-279
615 [[ -z "$(which getfattr 2>/dev/null)" ]] &&
616 skip "no getfattr command"
618 test_mkdir $DIR/$tdir
619 touch $DIR/$tdir/$tfile
620 ln -s $DIR/$tdir/$tfile $DIR/$tdir/$tfile.lnk
621 for path in "$DIR/$tdir" "$DIR/$tdir/$tfile" "$DIR/$tdir/$tfile.lnk"; do
622 # -h to not follow symlinks. -m '' to list all the xattrs.
623 # grep to remove first line: '# file: $path'.
624 for xattr in `getfattr -hm '' $path 2>/dev/null | grep -v '^#'`;
626 lgetxattr_size_check $path $xattr ||
627 error "lgetxattr_size_check $path $xattr failed"
631 run_test 17l "Ensure lgetxattr's returned xattr size is consistent"
635 [ $PARALLEL == "yes" ] && skip "skip parallel run"
636 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
637 skip_env "ldiskfs only test"
638 remote_mds_nodsh && skip "remote MDS with nodsh"
639 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] &&
640 [ $(lustre_version_code $SINGLEMDS) -le $(version_code 2.2.93) ] &&
641 skip "MDS 2.2.0-2.2.93 do not NUL-terminate symlinks"
643 local short_sym="0123456789"
644 local wdir=$DIR/$tdir
649 # create a long symlink file
650 for ((i = 0; i < 4; ++i)); do
651 long_sym=${long_sym}${long_sym}
654 echo "create 512 short and long symlink files under $wdir"
655 for ((i = 0; i < 256; ++i)); do
656 ln -sf ${long_sym}"a5a5" $wdir/long-$i
657 ln -sf ${short_sym}"a5a5" $wdir/short-$i
663 wait_delete_completed
665 echo "recreate the 512 symlink files with a shorter string"
666 for ((i = 0; i < 512; ++i)); do
667 # rewrite the symlink file with a shorter string
668 ln -sf ${long_sym} $wdir/long-$i || error "long_sym failed"
669 ln -sf ${short_sym} $wdir/short-$i || error "short_sym failed"
672 local mds_index=$(($($LFS getstripe -m $wdir) + 1))
673 local devname=$(mdsdevname $mds_index)
675 echo "stop and checking mds${mds_index}:"
676 # e2fsck should not return error
678 run_e2fsck $(facet_active_host mds${mds_index}) $devname -n
681 start mds${mds_index} $devname $MDS_MOUNT_OPTS ||
682 error "start mds${mds_index} failed"
683 df $MOUNT > /dev/null 2>&1
685 error "e2fsck detected error for short/long symlink: rc=$rc"
688 run_test 17m "run e2fsck against MDT which contains short/long symlink"
690 check_fs_consistency_17n() {
694 # create/unlink in 17n only change 2 MDTs(MDT1/MDT2),
695 # so it only check MDT1/MDT2 instead of all of MDTs.
696 for mdt_index in 1 2; do
697 local devname=$(mdsdevname $mdt_index)
698 # e2fsck should not return error
700 run_e2fsck $(facet_active_host mds$mdt_index) $devname -n ||
703 start mds${mdt_index} $devname $MDS_MOUNT_OPTS ||
704 error "mount mds$mdt_index failed"
705 df $MOUNT > /dev/null 2>&1
711 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
712 [ $PARALLEL == "yes" ] && skip "skip parallel run"
713 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
714 skip_env "ldiskfs only test"
715 remote_mds_nodsh && skip "remote MDS with nodsh"
716 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] &&
717 [ $(lustre_version_code $SINGLEMDS) -le $(version_code 2.2.93) ] &&
718 skip "MDS 2.2.0-2.2.93 do not NUL-terminate symlinks"
722 test_mkdir $DIR/$tdir
723 for ((i=0; i<10; i++)); do
724 $LFS mkdir -i1 -c2 $DIR/$tdir/remote_dir_${i} ||
725 error "create remote dir error $i"
726 createmany -o $DIR/$tdir/remote_dir_${i}/f 10 ||
727 error "create files under remote dir failed $i"
730 check_fs_consistency_17n ||
731 error "e2fsck report error after create files under remote dir"
733 for ((i = 0; i < 10; i++)); do
734 rm -rf $DIR/$tdir/remote_dir_${i} ||
735 error "destroy remote dir error $i"
738 check_fs_consistency_17n ||
739 error "e2fsck report error after unlink files under remote dir"
741 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.50) ] &&
742 skip "lustre < 2.4.50 does not support migrate mv"
744 for ((i = 0; i < 10; i++)); do
745 mkdir -p $DIR/$tdir/remote_dir_${i}
746 createmany -o $DIR/$tdir/remote_dir_${i}/f 10 ||
747 error "create files under remote dir failed $i"
748 $LFS migrate --mdt-index 1 $DIR/$tdir/remote_dir_${i} ||
749 error "migrate remote dir error $i"
751 check_fs_consistency_17n || error "e2fsck report error after migration"
753 for ((i = 0; i < 10; i++)); do
754 rm -rf $DIR/$tdir/remote_dir_${i} ||
755 error "destroy remote dir error $i"
758 check_fs_consistency_17n || error "e2fsck report error after unlink"
760 run_test 17n "run e2fsck against master/slave MDT which contains remote dir"
763 remote_mds_nodsh && skip "remote MDS with nodsh"
764 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.3.64) ] &&
765 skip "Need MDS version at least 2.3.64"
767 local wdir=$DIR/${tdir}o
773 mdt_index=$($LFS getstripe -m $wdir/$tfile)
774 mdt_index=$((mdt_index + 1))
777 #fail mds will wait the failover finish then set
778 #following fail_loc to avoid interfer the recovery process.
781 #define OBD_FAIL_OSD_LMA_INCOMPAT 0x194
782 do_facet mds${mdt_index} lctl set_param fail_loc=0x194
783 ls -l $wdir/$tfile && rc=1
784 do_facet mds${mdt_index} lctl set_param fail_loc=0
785 [[ $rc -eq 0 ]] || error "stat file should fail"
787 run_test 17o "stat file with incompat LMA feature"
790 touch $DIR/$tfile || error "Failed to touch $DIR/$tfile: $?"
791 ls $DIR || error "Failed to ls $DIR: $?"
793 run_test 18 "touch .../f ; ls ... =============================="
799 $CHECKSTAT -a $DIR/$tfile || error "$tfile was not removed"
801 run_test 19a "touch .../f19 ; ls -l ... ; rm .../f19 ==========="
804 ls -l $DIR/$tfile && error "ls -l $tfile failed"|| true
806 run_test 19b "ls -l .../f19 (should return error) =============="
809 [ $RUNAS_ID -eq $UID ] &&
810 skip_env "RUNAS_ID = UID = $UID -- skipping"
812 $RUNAS touch $DIR/$tfile && error "create non-root file failed" || true
814 run_test 19c "$RUNAS touch .../f19 (should return error) =="
817 cat $DIR/f19 && error || true
819 run_test 19d "cat .../f19 (should return error) =============="
828 $CHECKSTAT -a $DIR/$tfile || error "$tfile was not removed"
830 run_test 20 "touch .../f ; ls -l ..."
833 test_mkdir $DIR/$tdir
834 [ -f $DIR/$tdir/dangle ] && rm -f $DIR/$tdir/dangle
835 ln -s dangle $DIR/$tdir/link
836 echo foo >> $DIR/$tdir/link
837 cat $DIR/$tdir/dangle
838 $CHECKSTAT -t link $DIR/$tdir/link || error "$tdir/link not a link"
839 $CHECKSTAT -f -t file $DIR/$tdir/link ||
840 error "$tdir/link not linked to a file"
842 run_test 21 "write to dangling link"
845 local wdir=$DIR/$tdir
847 chown $RUNAS_ID:$RUNAS_GID $wdir
848 (cd $wdir || error "cd $wdir failed";
849 $RUNAS tar cf - /etc/hosts /etc/sysconfig/network |
851 ls -lR $wdir/etc || error "ls -lR $wdir/etc failed"
852 $CHECKSTAT -t dir $wdir/etc || error "checkstat -t dir failed"
853 $CHECKSTAT -u \#$RUNAS_ID -g \#$RUNAS_GID $wdir/etc ||
854 error "checkstat -u failed"
856 run_test 22 "unpack tar archive as non-root user"
860 test_mkdir $DIR/$tdir
861 local file=$DIR/$tdir/$tfile
863 openfile -f O_CREAT:O_EXCL $file || error "$file create failed"
864 openfile -f O_CREAT:O_EXCL $file &&
865 error "$file recreate succeeded" || true
867 run_test 23a "O_CREAT|O_EXCL in subdir"
869 test_23b() { # bug 18988
870 test_mkdir $DIR/$tdir
871 local file=$DIR/$tdir/$tfile
874 echo foo > $file || error "write filed"
875 echo bar >> $file || error "append filed"
876 $CHECKSTAT -s 8 $file || error "wrong size"
879 run_test 23b "O_APPEND check"
881 # LU-9409, size with O_APPEND and tiny writes
883 local file=$DIR/$tfile
886 dd conv=notrunc oflag=append if=/dev/zero of=$file bs=8 count=800
887 $CHECKSTAT -s 6400 $file || error "wrong size, expected 6400"
891 dd conv=notrunc oflag=append if=/dev/zero of=$file bs=8 count=800 &
892 dd conv=notrunc oflag=append if=/dev/zero of=$file bs=8 count=800 &
894 $CHECKSTAT -s 12800 $file || error "wrong size, expected 12800"
897 #racing tiny & normal writes
898 dd conv=notrunc oflag=append if=/dev/zero of=$file bs=4096 count=4 &
899 dd conv=notrunc oflag=append if=/dev/zero of=$file bs=8 count=100 &
901 $CHECKSTAT -s 17184 $file || error "wrong size, expected 17184"
904 #racing tiny & normal writes 2, ugly numbers
905 dd conv=notrunc oflag=append if=/dev/zero of=$file bs=4099 count=11 &
906 dd conv=notrunc oflag=append if=/dev/zero of=$file bs=17 count=173 &
908 $CHECKSTAT -s 48030 $file || error "wrong size, expected 48030"
911 run_test 23c "O_APPEND size checks for tiny writes"
913 # LU-11069 file offset is correct after appending writes
915 local file=$DIR/$tfile
918 echo CentaurHauls > $file
919 offset=$($MULTIOP $file oO_WRONLY:O_APPEND:w13Zp)
920 if ((offset != 26)); then
921 error "wrong offset, expected 26, got '$offset'"
924 run_test 23d "file offset is correct after appending writes"
928 echo '-- same directory rename'
929 test_mkdir $DIR/$tdir
930 touch $DIR/$tdir/$tfile.1
931 mv $DIR/$tdir/$tfile.1 $DIR/$tdir/$tfile.2
932 $CHECKSTAT -t file $DIR/$tdir/$tfile.2 || error "$tfile.2 not a file"
934 run_test 24a "rename file to non-existent target"
937 test_mkdir $DIR/$tdir
938 touch $DIR/$tdir/$tfile.{1,2}
939 mv $DIR/$tdir/$tfile.1 $DIR/$tdir/$tfile.2
940 $CHECKSTAT -a $DIR/$tdir/$tfile.1 || error "$tfile.1 exists"
941 $CHECKSTAT -t file $DIR/$tdir/$tfile.2 || error "$tfile.2 not a file"
943 run_test 24b "rename file to existing target"
946 test_mkdir $DIR/$tdir
947 test_mkdir $DIR/$tdir/d$testnum.1
948 mv $DIR/$tdir/d$testnum.1 $DIR/$tdir/d$testnum.2
949 $CHECKSTAT -a $DIR/$tdir/d$testnum.1 || error "d$testnum.1 exists"
950 $CHECKSTAT -t dir $DIR/$tdir/d$testnum.2 || error "d$testnum.2 not dir"
952 run_test 24c "rename directory to non-existent target"
955 test_mkdir -c1 $DIR/$tdir
956 test_mkdir -c1 $DIR/$tdir/d$testnum.1
957 test_mkdir -c1 $DIR/$tdir/d$testnum.2
958 mrename $DIR/$tdir/d$testnum.1 $DIR/$tdir/d$testnum.2
959 $CHECKSTAT -a $DIR/$tdir/d$testnum.1 || error "d$testnum.1 exists"
960 $CHECKSTAT -t dir $DIR/$tdir/d$testnum.2 || error "d$testnum.2 not dir"
962 run_test 24d "rename directory to existing target"
965 echo '-- cross directory renames --'
969 mv $DIR/R5a/f $DIR/R5b/g
970 $CHECKSTAT -a $DIR/R5a/f || error "$DIR/R5a/f exists"
971 $CHECKSTAT -t file $DIR/R5b/g || error "$DIR/R5b/g not file type"
973 run_test 24e "touch .../R5a/f; rename .../R5a/f .../R5b/g ======"
978 touch $DIR/R6a/f $DIR/R6b/g
979 mv $DIR/R6a/f $DIR/R6b/g
980 $CHECKSTAT -a $DIR/R6a/f || error "$DIR/R6a/f exists"
981 $CHECKSTAT -t file $DIR/R6b/g || error "$DIR/R6b/g not file type"
983 run_test 24f "touch .../R6a/f R6b/g; mv .../R6a/f .../R6b/g ===="
988 test_mkdir $DIR/R7a/d
989 mv $DIR/R7a/d $DIR/R7b/e
990 $CHECKSTAT -a $DIR/R7a/d || error "$DIR/R7a/d exists"
991 $CHECKSTAT -t dir $DIR/R7b/e || error "$DIR/R7b/e not dir type"
993 run_test 24g "mkdir .../R7{a,b}/d; mv .../R7a/d .../R7b/e ======"
996 test_mkdir -c1 $DIR/R8a
997 test_mkdir -c1 $DIR/R8b
998 test_mkdir -c1 $DIR/R8a/d
999 test_mkdir -c1 $DIR/R8b/e
1000 mrename $DIR/R8a/d $DIR/R8b/e
1001 $CHECKSTAT -a $DIR/R8a/d || error "$DIR/R8a/d exists"
1002 $CHECKSTAT -t dir $DIR/R8b/e || error "$DIR/R8b/e not dir type"
1004 run_test 24h "mkdir .../R8{a,b}/{d,e}; rename .../R8a/d .../R8b/e"
1007 echo "-- rename error cases"
1009 test_mkdir $DIR/R9/a
1011 mrename $DIR/R9/f $DIR/R9/a
1012 $CHECKSTAT -t file $DIR/R9/f || error "$DIR/R9/f not file type"
1013 $CHECKSTAT -t dir $DIR/R9/a || error "$DIR/R9/a not dir type"
1014 $CHECKSTAT -a $DIR/R9/a/f || error "$DIR/R9/a/f exists"
1016 run_test 24i "rename file to dir error: touch f ; mkdir a ; rename f a"
1020 mrename $DIR/R10/f $DIR/R10/g
1021 $CHECKSTAT -t dir $DIR/R10 || error "$DIR/R10 not dir type"
1022 $CHECKSTAT -a $DIR/R10/f || error "$DIR/R10/f exists"
1023 $CHECKSTAT -a $DIR/R10/g || error "$DIR/R10/g exists"
1025 run_test 24j "source does not exist ============================"
1028 test_mkdir $DIR/R11a
1029 test_mkdir $DIR/R11a/d
1031 mv $DIR/R11a/f $DIR/R11a/d
1032 $CHECKSTAT -a $DIR/R11a/f || error "$DIR/R11a/f exists"
1033 $CHECKSTAT -t file $DIR/R11a/d/f || error "$DIR/R11a/d/f not file type"
1035 run_test 24k "touch .../R11a/f; mv .../R11a/f .../R11a/d ======="
1037 # bug 2429 - rename foo foo foo creates invalid file
1040 $MULTIOP $f OcNs || error "rename of ${f} to itself failed"
1042 run_test 24l "Renaming a file to itself ========================"
1046 $MULTIOP $f OcLN ${f}2 ${f}2 || error "link ${f}2 ${f}2 failed"
1047 # on ext3 this does not remove either the source or target files
1048 # though the "expected" operation would be to remove the source
1049 $CHECKSTAT -t file ${f} || error "${f} missing"
1050 $CHECKSTAT -t file ${f}2 || error "${f}2 missing"
1052 run_test 24m "Renaming a file to a hard link to itself ========="
1056 # this stats the old file after it was renamed, so it should fail
1058 $CHECKSTAT ${f} || error "${f} missing"
1060 $CHECKSTAT ${f}.rename || error "${f}.rename missing"
1061 $CHECKSTAT -a ${f} || error "${f} exists"
1063 run_test 24n "Statting the old file after renaming (Posix rename 2)"
1066 test_mkdir $DIR/$tdir
1067 rename_many -s random -v -n 10 $DIR/$tdir
1069 run_test 24o "rename of files during htree split"
1072 test_mkdir $DIR/R12a
1073 test_mkdir $DIR/R12b
1074 DIRINO=`ls -lid $DIR/R12a | awk '{ print $1 }'`
1075 mrename $DIR/R12a $DIR/R12b
1076 $CHECKSTAT -a $DIR/R12a || error "$DIR/R12a exists"
1077 $CHECKSTAT -t dir $DIR/R12b || error "$DIR/R12b not dir type"
1078 DIRINO2=`ls -lid $DIR/R12b | awk '{ print $1 }'`
1079 [ "$DIRINO" = "$DIRINO2" ] || error "R12a $DIRINO != R12b $DIRINO2"
1081 run_test 24p "mkdir .../R12{a,b}; rename .../R12a .../R12b"
1083 cleanup_multiop_pause() {
1085 kill -USR1 $MULTIPID
1089 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1091 test_mkdir $DIR/R13a
1092 test_mkdir $DIR/R13b
1093 local DIRINO=$(ls -lid $DIR/R13a | awk '{ print $1 }')
1094 multiop_bg_pause $DIR/R13b D_c || error "multiop failed to start"
1097 trap cleanup_multiop_pause EXIT
1098 mrename $DIR/R13a $DIR/R13b
1099 $CHECKSTAT -a $DIR/R13a || error "R13a still exists"
1100 $CHECKSTAT -t dir $DIR/R13b || error "R13b does not exist"
1101 local DIRINO2=$(ls -lid $DIR/R13b | awk '{ print $1 }')
1102 [ "$DIRINO" = "$DIRINO2" ] || error "R13a $DIRINO != R13b $DIRINO2"
1103 cleanup_multiop_pause
1104 wait $MULTIPID || error "multiop close failed"
1106 run_test 24q "mkdir .../R13{a,b}; open R13b rename R13a R13b ==="
1108 test_24r() { #bug 3789
1109 test_mkdir $DIR/R14a
1110 test_mkdir $DIR/R14a/b
1111 mrename $DIR/R14a $DIR/R14a/b && error "rename to subdir worked!"
1112 $CHECKSTAT -t dir $DIR/R14a || error "$DIR/R14a missing"
1113 $CHECKSTAT -t dir $DIR/R14a/b || error "$DIR/R14a/b missing"
1115 run_test 24r "mkdir .../R14a/b; rename .../R14a .../R14a/b ====="
1118 test_mkdir $DIR/R15a
1119 test_mkdir $DIR/R15a/b
1120 test_mkdir $DIR/R15a/b/c
1121 mrename $DIR/R15a $DIR/R15a/b/c && error "rename to sub-subdir worked!"
1122 $CHECKSTAT -t dir $DIR/R15a || error "$DIR/R15a missing"
1123 $CHECKSTAT -t dir $DIR/R15a/b/c || error "$DIR/R15a/b/c missing"
1125 run_test 24s "mkdir .../R15a/b/c; rename .../R15a .../R15a/b/c ="
1127 test_mkdir $DIR/R16a
1128 test_mkdir $DIR/R16a/b
1129 test_mkdir $DIR/R16a/b/c
1130 mrename $DIR/R16a/b/c $DIR/R16a && error "rename to sub-subdir worked!"
1131 $CHECKSTAT -t dir $DIR/R16a || error "$DIR/R16a missing"
1132 $CHECKSTAT -t dir $DIR/R16a/b/c || error "$DIR/R16a/b/c missing"
1134 run_test 24t "mkdir .../R16a/b/c; rename .../R16a/b/c .../R16a ="
1136 test_24u() { # bug12192
1137 $MULTIOP $DIR/$tfile C2w$((2048 * 1024))c || error "multiop failed"
1138 $CHECKSTAT -s $((2048 * 1024)) $DIR/$tfile || error "wrong file size"
1140 run_test 24u "create stripe file"
1142 simple_cleanup_common() {
1145 [ -z "$DIR" -o -z "$tdir" ] && return 0
1147 local start=$SECONDS
1150 wait_delete_completed
1151 echo "cleanup time $((SECONDS - start))"
1155 max_pages_per_rpc() {
1156 local mdtname="$(printf "MDT%04x" ${1:-0})"
1157 $LCTL get_param -n mdc.*$mdtname*.max_pages_per_rpc
1161 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1163 local nrfiles=${COUNT:-100000}
1164 local fname="$DIR/$tdir/$tfile"
1166 # Performance issue on ZFS see LU-4072 (c.f. LU-2887)
1167 [ $(facet_fstype $SINGLEMDS) = "zfs" ] && nrfiles=${COUNT:-10000}
1169 test_mkdir "$(dirname $fname)"
1170 # assume MDT0000 has the fewest inodes
1171 local stripes=$($LFS getdirstripe -c $(dirname $fname))
1172 local free_inodes=$(($(mdt_free_inodes 0) * stripes))
1173 [[ $free_inodes -lt $nrfiles ]] && nrfiles=$free_inodes
1175 trap simple_cleanup_common EXIT
1177 createmany -m "$fname" $nrfiles
1179 cancel_lru_locks mdc
1180 lctl set_param mdc.*.stats clear
1182 # was previously test_24D: LU-6101
1183 # readdir() returns correct number of entries after cursor reload
1184 local num_ls=$(ls $DIR/$tdir | wc -l)
1185 local num_uniq=$(ls $DIR/$tdir | sort -u | wc -l)
1186 local num_all=$(ls -a $DIR/$tdir | wc -l)
1187 if [ $num_ls -ne $nrfiles -o $num_uniq -ne $nrfiles -o \
1188 $num_all -ne $((nrfiles + 2)) ]; then
1189 error "Expected $nrfiles files, got $num_ls " \
1190 "($num_uniq unique $num_all .&..)"
1192 # LU-5 large readdir
1193 # dirent_size = 32 bytes for sizeof(struct lu_dirent) +
1194 # N bytes for name (len($nrfiles) rounded to 8 bytes) +
1195 # 8 bytes for luda_type (4 bytes rounded to 8 bytes)
1196 # take into account of overhead in lu_dirpage header and end mark in
1197 # each page, plus one in rpc_num calculation.
1198 local dirent_size=$((32 + (${#tfile} | 7) + 1 + 8))
1199 local page_entries=$(((PAGE_SIZE - 24) / dirent_size))
1200 local mdt_idx=$($LFS getdirstripe -i $(dirname $fname))
1201 local rpc_pages=$(max_pages_per_rpc $mdt_idx)
1202 local rpc_max=$((nrfiles / (page_entries * rpc_pages) + stripes))
1203 local mds_readpage=$(calc_stats mdc.*.stats mds_readpage)
1204 echo "readpages: $mds_readpage rpc_max: $rpc_max"
1205 (( $mds_readpage < $rpc_max - 2 || $mds_readpage > $rpc_max + 1)) &&
1206 error "large readdir doesn't take effect: " \
1207 "$mds_readpage should be about $rpc_max"
1209 simple_cleanup_common
1211 run_test 24v "list large directory (test hash collision, b=17560)"
1213 test_24w() { # bug21506
1215 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=4096 || return 1
1216 dd if=/dev/zero bs=$SZ1 count=1 >> $DIR/$tfile || return 2
1217 dd if=$DIR/$tfile of=$DIR/${tfile}_left bs=1M skip=4097 || return 3
1218 SZ2=`ls -l $DIR/${tfile}_left | awk '{print $5}'`
1219 [[ "$SZ1" -eq "$SZ2" ]] ||
1220 error "Error reading at the end of the file $tfile"
1222 run_test 24w "Reading a file larger than 4Gb"
1225 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
1226 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1227 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.56) ]] &&
1228 skip "Need MDS version at least 2.7.56"
1231 local remote_dir=$DIR/$tdir/remote_dir
1233 test_mkdir $DIR/$tdir
1234 $LFS mkdir -i $MDTIDX $remote_dir ||
1235 error "create remote directory failed"
1237 test_mkdir $DIR/$tdir/src_dir
1238 touch $DIR/$tdir/src_file
1239 test_mkdir $remote_dir/tgt_dir
1240 touch $remote_dir/tgt_file
1242 mrename $DIR/$tdir/src_dir $remote_dir/tgt_dir ||
1243 error "rename dir cross MDT failed!"
1245 mrename $DIR/$tdir/src_file $remote_dir/tgt_file ||
1246 error "rename file cross MDT failed!"
1248 touch $DIR/$tdir/ln_file
1249 ln $DIR/$tdir/ln_file $remote_dir/ln_name ||
1250 error "ln file cross MDT failed"
1252 rm -rf $DIR/$tdir || error "Can not delete directories"
1254 run_test 24x "cross MDT rename/link"
1257 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
1258 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1260 local remote_dir=$DIR/$tdir/remote_dir
1263 test_mkdir $DIR/$tdir
1264 $LFS mkdir -i $mdtidx $remote_dir ||
1265 error "create remote directory failed"
1267 test_mkdir $remote_dir/src_dir
1268 touch $remote_dir/src_file
1269 test_mkdir $remote_dir/tgt_dir
1270 touch $remote_dir/tgt_file
1272 mrename $remote_dir/src_dir $remote_dir/tgt_dir ||
1273 error "rename subdir in the same remote dir failed!"
1275 mrename $remote_dir/src_file $remote_dir/tgt_file ||
1276 error "rename files in the same remote dir failed!"
1278 ln $remote_dir/tgt_file $remote_dir/tgt_file1 ||
1279 error "link files in the same remote dir failed!"
1281 rm -rf $DIR/$tdir || error "Can not delete directories"
1283 run_test 24y "rename/link on the same dir should succeed"
1285 test_24A() { # LU-3182
1289 test_mkdir $DIR/$tdir
1290 trap simple_cleanup_common EXIT
1291 createmany -m $DIR/$tdir/$tfile $NFILES
1292 local t=$(ls $DIR/$tdir | wc -l)
1293 local u=$(ls $DIR/$tdir | sort -u | wc -l)
1294 local v=$(ls -ai $DIR/$tdir | sort -u | wc -l)
1295 if [ $t -ne $NFILES -o $u -ne $NFILES -o $v -ne $((NFILES + 2)) ] ; then
1296 error "Expected $NFILES files, got $t ($u unique $v .&..)"
1299 simple_cleanup_common || error "Can not delete directories"
1301 run_test 24A "readdir() returns correct number of entries."
1303 test_24B() { # LU-4805
1304 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
1308 test_mkdir $DIR/$tdir
1309 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR/$tdir/striped_dir ||
1310 error "create striped dir failed"
1312 count=$(ls -ai $DIR/$tdir/striped_dir | wc -l)
1313 [ $count -eq 2 ] || error "Expected 2, got $count"
1315 touch $DIR/$tdir/striped_dir/a
1317 count=$(ls -ai $DIR/$tdir/striped_dir | wc -l)
1318 [ $count -eq 3 ] || error "Expected 3, got $count"
1320 touch $DIR/$tdir/striped_dir/.f
1322 count=$(ls -ai $DIR/$tdir/striped_dir | wc -l)
1323 [ $count -eq 4 ] || error "Expected 4, got $count"
1325 rm -rf $DIR/$tdir || error "Can not delete directories"
1327 run_test 24B "readdir for striped dir return correct number of entries"
1330 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
1336 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR/$tdir/d0/striped_dir ||
1337 error "create striped dir failed"
1339 cd $DIR/$tdir/d0/striped_dir
1341 local d0_ino=$(ls -i -l -a $DIR/$tdir | grep "d0" | awk '{print $1}')
1342 local d1_ino=$(ls -i -l -a $DIR/$tdir | grep "d1" | awk '{print $1}')
1343 local parent_ino=$(ls -i -l -a | grep "\.\." | awk '{print $1}')
1345 [ "$d0_ino" = "$parent_ino" ] ||
1346 error ".. wrong, expect $d0_ino, get $parent_ino"
1348 mv $DIR/$tdir/d0/striped_dir $DIR/$tdir/d1/ ||
1349 error "mv striped dir failed"
1351 parent_ino=$(ls -i -l -a | grep "\.\." | awk '{print $1}')
1353 [ "$d1_ino" = "$parent_ino" ] ||
1354 error ".. wrong after mv, expect $d1_ino, get $parent_ino"
1356 run_test 24C "check .. in striped dir"
1359 [[ $MDSCOUNT -lt 4 ]] && skip_env "needs >= 4 MDTs"
1360 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1363 mkdir $DIR/$tdir/src_dir
1364 $LFS mkdir -i 1 $DIR/$tdir/src_dir/src_child ||
1365 error "create remote source failed"
1367 touch $DIR/$tdir/src_dir/src_child/a
1369 $LFS mkdir -i 2 $DIR/$tdir/tgt_dir ||
1370 error "create remote target dir failed"
1372 $LFS mkdir -i 3 $DIR/$tdir/tgt_dir/tgt_child ||
1373 error "create remote target child failed"
1375 mrename $DIR/$tdir/src_dir/src_child $DIR/$tdir/tgt_dir/tgt_child ||
1376 error "rename dir cross MDT failed!"
1380 $CHECKSTAT -t dir $DIR/$tdir/src_dir/src_child &&
1381 error "src_child still exists after rename"
1383 $CHECKSTAT -t file $DIR/$tdir/tgt_dir/tgt_child/a ||
1384 error "missing file(a) after rename"
1386 rm -rf $DIR/$tdir || error "Can not delete directories"
1388 run_test 24E "cross MDT rename/link"
1391 echo '== symlink sanity ============================================='
1395 touch $DIR/s25/foo ||
1396 error "File creation in symlinked directory failed"
1398 run_test 25a "create file in symlinked directory ==============="
1401 [ ! -d $DIR/d25 ] && test_25a
1402 $CHECKSTAT -t file $DIR/s25/foo || error "$DIR/s25/foo not file type"
1404 run_test 25b "lookup file in symlinked directory ==============="
1408 test_mkdir $DIR/d26/d26-2
1409 ln -s d26/d26-2 $DIR/s26
1410 touch $DIR/s26/foo || error "File creation failed"
1412 run_test 26a "multiple component symlink ======================="
1415 test_mkdir -p $DIR/$tdir/d26-2
1416 ln -s $tdir/d26-2/foo $DIR/s26-2
1417 touch $DIR/s26-2 || error "File creation failed"
1419 run_test 26b "multiple component symlink at end of lookup ======"
1422 test_mkdir $DIR/d26.2
1423 touch $DIR/d26.2/foo
1424 ln -s d26.2 $DIR/s26.2-1
1425 ln -s s26.2-1 $DIR/s26.2-2
1426 ln -s s26.2-2 $DIR/s26.2-3
1427 chmod 0666 $DIR/s26.2-3/foo
1429 run_test 26c "chain of symlinks"
1431 # recursive symlinks (bug 439)
1433 ln -s d26-3/foo $DIR/d26-3
1435 run_test 26d "create multiple component recursive symlink"
1438 [ ! -h $DIR/d26-3 ] && test_26d
1441 run_test 26e "unlink multiple component recursive symlink"
1443 # recursive symlinks (bug 7022)
1445 test_mkdir $DIR/$tdir
1446 test_mkdir $DIR/$tdir/$tfile
1447 cd $DIR/$tdir/$tfile || error "cd $DIR/$tdir/$tfile failed"
1448 test_mkdir -p lndir/bar1
1449 test_mkdir $DIR/$tdir/$tfile/$tfile
1450 cd $tfile || error "cd $tfile failed"
1451 ln -s .. dotdot || error "ln dotdot failed"
1452 ln -s dotdot/lndir lndir || error "ln lndir failed"
1453 cd $DIR/$tdir || error "cd $DIR/$tdir failed"
1454 output=`ls $tfile/$tfile/lndir/bar1`
1455 [ "$output" = bar1 ] && error "unexpected output"
1456 rm -r $tfile || error "rm $tfile failed"
1457 $CHECKSTAT -a $DIR/$tfile || error "$tfile not gone"
1459 run_test 26f "rm -r of a directory which has recursive symlink"
1462 test_mkdir $DIR/$tdir
1463 $LFS getstripe $DIR/$tdir
1464 $LFS setstripe -c 1 $DIR/$tdir/$tfile || error "setstripe failed"
1465 $CHECKSTAT -t file $DIR/$tdir/$tfile || error "checkstat failed"
1466 cp /etc/hosts $DIR/$tdir/$tfile || error "Can't copy to one stripe file"
1468 run_test 27a "one stripe file"
1471 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
1473 test_mkdir $DIR/$tdir
1474 $LFS setstripe -c 2 $DIR/$tdir/$tfile || error "setstripe failed"
1475 $LFS getstripe -c $DIR/$tdir/$tfile
1476 [ $($LFS getstripe -c $DIR/$tdir/$tfile) -eq 2 ] ||
1477 error "two-stripe file doesn't have two stripes"
1479 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=4k count=4 || error "dd failed"
1481 run_test 27b "create and write to two stripe file"
1484 test_mkdir $DIR/$tdir
1485 $LFS setstripe -c 0 -i -1 -S 0 $DIR/$tdir/$tfile ||
1486 error "setstripe failed"
1487 $CHECKSTAT -t file $DIR/$tdir/$tfile || error "checkstat failed"
1488 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=4k count=4 || error "dd failed"
1490 run_test 27d "create file with default settings"
1493 # LU-5839 adds check for existed layout before setting it
1494 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.56) ]] &&
1495 skip "Need MDS version at least 2.7.56"
1497 test_mkdir $DIR/$tdir
1498 $LFS setstripe -c 2 $DIR/$tdir/$tfile || error "setstripe failed"
1499 $LFS setstripe -c 2 $DIR/$tdir/$tfile && error "setstripe worked twice"
1500 $CHECKSTAT -t file $DIR/$tdir/$tfile || error "checkstat failed"
1502 run_test 27e "setstripe existing file (should return error)"
1505 test_mkdir $DIR/$tdir
1506 $LFS setstripe -S 100 -i 0 -c 1 $DIR/$tdir/$tfile &&
1507 error "$SETSTRIPE $DIR/$tdir/$tfile failed"
1508 $CHECKSTAT -t file $DIR/$tdir/$tfile &&
1509 error "$CHECKSTAT -t file $DIR/$tdir/$tfile should fail"
1510 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=4k count=4 || error "dd failed"
1511 $LFS getstripe $DIR/$tdir/$tfile || error "$LFS getstripe failed"
1513 run_test 27f "setstripe with bad stripe size (should return error)"
1516 test_mkdir $DIR/$tdir
1517 $MCREATE $DIR/$tdir/$tfile || error "mcreate failed"
1518 $LFS getstripe $DIR/$tdir/$tfile 2>&1 | grep "no stripe info" ||
1519 error "$DIR/$tdir/$tfile has object"
1521 run_test 27g "$LFS getstripe with no objects"
1524 test_mkdir $DIR/$tdir
1525 touch $DIR/$tdir/$tfile || error "touch failed"
1526 [[ $($LFS getstripe -c $DIR/$tdir/$tfile) -gt 0 ]] ||
1527 error "missing objects"
1529 run_test 27i "$LFS getstripe with some objects"
1532 test_mkdir $DIR/$tdir
1533 $LFS setstripe -i $OSTCOUNT $DIR/$tdir/$tfile &&
1534 error "setstripe failed" || true
1536 run_test 27j "setstripe with bad stripe offset (should return error)"
1538 test_27k() { # bug 2844
1539 test_mkdir $DIR/$tdir
1540 local file=$DIR/$tdir/$tfile
1541 local ll_max_blksize=$((4 * 1024 * 1024))
1542 $LFS setstripe -S 67108864 $file || error "setstripe failed"
1543 local blksize=$(stat $file | awk '/IO Block:/ { print $7 }')
1544 [ $blksize -le $ll_max_blksize ] || error "1:$blksize > $ll_max_blksize"
1545 dd if=/dev/zero of=$file bs=4k count=1
1546 blksize=$(stat $file | awk '/IO Block:/ { print $7 }')
1547 [ $blksize -le $ll_max_blksize ] || error "2:$blksize > $ll_max_blksize"
1549 run_test 27k "limit i_blksize for broken user apps"
1552 mcreate $DIR/$tfile || error "creating file"
1553 $RUNAS $LFS setstripe -c 1 $DIR/$tfile &&
1554 error "setstripe should have failed" || true
1556 run_test 27l "check setstripe permissions (should return error)"
1559 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
1561 ORIGFREE=$($LCTL get_param -n lov.$FSNAME-clilov-*.kbytesavail |
1563 if [[ $ORIGFREE -gt $MAXFREE ]]; then
1564 skip "$ORIGFREE > $MAXFREE skipping out-of-space test on OST0"
1566 trap simple_cleanup_common EXIT
1567 test_mkdir $DIR/$tdir
1568 $LFS setstripe -i 0 -c 1 $DIR/$tdir/$tfile.1
1569 dd if=/dev/zero of=$DIR/$tdir/$tfile.1 bs=1024 count=$MAXFREE &&
1570 error "dd should fill OST0"
1572 while $LFS setstripe -i 0 -c 1 $DIR/$tdir/$tfile.$i; do
1574 [ $i -gt 256 ] && break
1577 touch $DIR/$tdir/$tfile.$i
1578 [ $($LFS getstripe $DIR/$tdir/$tfile.$i | grep -A 10 obdidx |
1579 awk '{print $1}'| grep -w "0") ] &&
1580 error "OST0 was full but new created file still use it"
1582 touch $DIR/$tdir/$tfile.$i
1583 [ $($LFS getstripe $DIR/$tdir/$tfile.$i | grep -A 10 obdidx |
1584 awk '{print $1}'| grep -w "0") ] &&
1585 error "OST0 was full but new created file still use it"
1586 simple_cleanup_common
1588 run_test 27m "create file while OST0 was full"
1591 local delay=$(do_facet $SINGLEMDS lctl get_param -n lov.*.qos_maxage |
1592 awk '{ print $1 * 2; exit; }')
1596 # OSCs keep a NOSPC flag that will be reset after ~5s (qos_maxage)
1597 # if the OST isn't full anymore.
1599 local OSTIDX=${1:-""}
1601 local list=$(comma_list $(osts_nodes))
1602 [ "$OSTIDX" ] && list=$(facet_host ost$((OSTIDX + 1)))
1604 do_nodes $list lctl set_param fail_loc=0
1605 sync # initiate all OST_DESTROYs from MDS to OST
1609 exhaust_precreations() {
1612 local FAILIDX=${3:-$OSTIDX}
1613 local ofacet=ost$((OSTIDX + 1))
1615 test_mkdir -p -c1 $DIR/$tdir
1616 local mdtidx=$($LFS getstripe -m $DIR/$tdir)
1617 local mfacet=mds$((mdtidx + 1))
1618 echo OSTIDX=$OSTIDX MDTIDX=$mdtidx
1620 local OST=$(ostname_from_index $OSTIDX)
1623 local mdtosc_proc1=$(get_mdtosc_proc_path $mfacet $OST)
1624 local last_id=$(do_facet $mfacet lctl get_param -n \
1625 osc.$mdtosc_proc1.prealloc_last_id)
1626 local next_id=$(do_facet $mfacet lctl get_param -n \
1627 osc.$mdtosc_proc1.prealloc_next_id)
1629 local mdtosc_proc2=$(get_mdtosc_proc_path $mfacet)
1630 do_facet $mfacet lctl get_param osc.$mdtosc_proc2.prealloc*
1632 test_mkdir -p $DIR/$tdir/${OST}
1633 $SETSTRIPE -i $OSTIDX -c 1 $DIR/$tdir/${OST}
1634 #define OBD_FAIL_OST_ENOSPC 0x215
1635 do_facet $ofacet lctl set_param fail_val=$FAILIDX fail_loc=0x215
1636 echo "Creating to objid $last_id on ost $OST..."
1637 createmany -o $DIR/$tdir/${OST}/f $next_id $((last_id - next_id + 2))
1638 do_facet $mfacet lctl get_param osc.$mdtosc_proc2.prealloc*
1639 do_facet $ofacet lctl set_param fail_loc=$FAILLOC
1643 exhaust_all_precreations() {
1645 for (( i=0; i < OSTCOUNT; i++ )) ; do
1646 exhaust_precreations $i $1 -1
1651 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
1652 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1653 remote_mds_nodsh && skip "remote MDS with nodsh"
1654 remote_ost_nodsh && skip "remote OST with nodsh"
1657 rm -f $DIR/$tdir/$tfile
1658 exhaust_precreations 0 0x80000215
1659 $LFS setstripe -c -1 $DIR/$tdir || error "setstripe failed"
1660 touch $DIR/$tdir/$tfile || error "touch failed"
1661 $LFS getstripe $DIR/$tdir/$tfile
1664 run_test 27n "create file with some full OSTs"
1667 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
1668 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1669 remote_mds_nodsh && skip "remote MDS with nodsh"
1670 remote_ost_nodsh && skip "remote OST with nodsh"
1673 rm -f $DIR/$tdir/$tfile
1674 exhaust_all_precreations 0x215
1676 touch $DIR/$tdir/$tfile && error "able to create $DIR/$tdir/$tfile"
1681 run_test 27o "create file with all full OSTs (should error)"
1684 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
1685 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1686 remote_mds_nodsh && skip "remote MDS with nodsh"
1687 remote_ost_nodsh && skip "remote OST with nodsh"
1690 rm -f $DIR/$tdir/$tfile
1691 test_mkdir $DIR/$tdir
1693 $MCREATE $DIR/$tdir/$tfile || error "mcreate failed"
1694 $TRUNCATE $DIR/$tdir/$tfile 80000000 || error "truncate failed"
1695 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat failed"
1697 exhaust_precreations 0 0x80000215
1698 echo foo >> $DIR/$tdir/$tfile || error "append failed"
1699 $CHECKSTAT -s 80000004 $DIR/$tdir/$tfile || error "checkstat failed"
1700 $LFS getstripe $DIR/$tdir/$tfile
1704 run_test 27p "append to a truncated file with some full OSTs"
1707 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
1708 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1709 remote_mds_nodsh && skip "remote MDS with nodsh"
1710 remote_ost_nodsh && skip "remote OST with nodsh"
1713 rm -f $DIR/$tdir/$tfile
1715 test_mkdir $DIR/$tdir
1716 $MCREATE $DIR/$tdir/$tfile || error "mcreate $DIR/$tdir/$tfile failed"
1717 $TRUNCATE $DIR/$tdir/$tfile 80000000 ||
1718 error "truncate $DIR/$tdir/$tfile failed"
1719 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat failed"
1721 exhaust_all_precreations 0x215
1723 echo foo >> $DIR/$tdir/$tfile && error "append succeeded"
1724 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat 2 failed"
1728 run_test 27q "append to truncated file with all OSTs full (should error)"
1731 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
1732 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1733 remote_mds_nodsh && skip "remote MDS with nodsh"
1734 remote_ost_nodsh && skip "remote OST with nodsh"
1737 rm -f $DIR/$tdir/$tfile
1738 exhaust_precreations 0 0x80000215
1740 $LFS setstripe -i 0 -c 2 $DIR/$tdir/$tfile || error "setstripe failed"
1744 run_test 27r "stripe file with some full OSTs (shouldn't LBUG) ="
1746 test_27s() { # bug 10725
1747 test_mkdir $DIR/$tdir
1748 local stripe_size=$((4096 * 1024 * 1024)) # 2^32
1749 local stripe_count=0
1750 [ $OSTCOUNT -eq 1 ] || stripe_count=2
1751 $LFS setstripe -S $stripe_size -c $stripe_count $DIR/$tdir &&
1752 error "stripe width >= 2^32 succeeded" || true
1755 run_test 27s "lsm_xfersize overflow (should error) (bug 10725)"
1757 test_27t() { # bug 10864
1762 $WLFS getstripe $tfile
1765 run_test 27t "check that utils parse path correctly"
1767 test_27u() { # bug 4900
1768 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
1769 remote_mds_nodsh && skip "remote MDS with nodsh"
1772 local list=$(comma_list $(mdts_nodes))
1774 #define OBD_FAIL_MDS_OSC_PRECREATE 0x139
1775 do_nodes $list $LCTL set_param fail_loc=0x139
1776 test_mkdir -p $DIR/$tdir
1777 trap simple_cleanup_common EXIT
1778 createmany -o $DIR/$tdir/t- 1000
1779 do_nodes $list $LCTL set_param fail_loc=0
1781 TLOG=$TMP/$tfile.getstripe
1782 $LFS getstripe $DIR/$tdir > $TLOG
1783 OBJS=$(awk -vobj=0 '($1 == 0) { obj += 1 } END { print obj; }' $TLOG)
1784 unlinkmany $DIR/$tdir/t- 1000
1786 [[ $OBJS -gt 0 ]] &&
1787 error "$OBJS objects created on OST-0. See $TLOG" ||
1790 run_test 27u "skip object creation on OSC w/o objects"
1792 test_27v() { # bug 4900
1793 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
1794 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1795 remote_mds_nodsh && skip "remote MDS with nodsh"
1796 remote_ost_nodsh && skip "remote OST with nodsh"
1798 exhaust_all_precreations 0x215
1801 $LFS setstripe -c 1 $DIR/$tdir # 1 stripe / file
1803 touch $DIR/$tdir/$tfile
1804 #define OBD_FAIL_TGT_DELAY_PRECREATE 0x705
1806 for (( i=1; i < OSTCOUNT; i++ )); do
1807 do_facet ost$i lctl set_param fail_loc=0x705
1809 local START=`date +%s`
1810 createmany -o $DIR/$tdir/$tfile 32
1812 local FINISH=`date +%s`
1813 local TIMEOUT=`lctl get_param -n timeout`
1814 local PROCESS=$((FINISH - START))
1815 [ $PROCESS -ge $((TIMEOUT / 2)) ] && \
1816 error "$FINISH - $START >= $TIMEOUT / 2"
1817 sleep $((TIMEOUT / 2 - PROCESS))
1820 run_test 27v "skip object creation on slow OST"
1822 test_27w() { # bug 10997
1823 test_mkdir $DIR/$tdir
1824 $LFS setstripe -S 65536 $DIR/$tdir/f0 || error "setstripe failed"
1825 [ $($LFS getstripe -S $DIR/$tdir/f0) -ne 65536 ] &&
1826 error "stripe size $size != 65536" || true
1827 [ $($LFS getstripe -d $DIR/$tdir | grep -c "stripe_count") -eq 0 ] &&
1828 error "$LFS getstripe -d $DIR/$tdir no 'stripe_count'" || true
1830 run_test 27w "check $LFS setstripe -S and getstrip -d options"
1833 [[ $OSTCOUNT -lt 2 ]] &&
1834 skip_env "skipping multiple stripe count/offset test"
1836 test_mkdir $DIR/$tdir
1837 for i in $(seq 1 $OSTCOUNT); do
1839 $LFS setstripe -c $i -i $offset $DIR/$tdir/f$i ||
1840 error "setstripe -c $i -i $offset failed"
1841 count=$($LFS getstripe -c $DIR/$tdir/f$i)
1842 index=$($LFS getstripe -i $DIR/$tdir/f$i)
1843 [ $count -ne $i ] && error "stripe count $count != $i" || true
1844 [ $index -ne $offset ] &&
1845 error "stripe offset $index != $offset" || true
1848 run_test 27wa "check $LFS setstripe -c -i options"
1851 remote_ost_nodsh && skip "remote OST with nodsh"
1852 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
1853 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1855 OFFSET=$(($OSTCOUNT - 1))
1857 local OST=$(ostname_from_index $OSTIDX)
1859 test_mkdir $DIR/$tdir
1860 $LFS setstripe -c 1 $DIR/$tdir # 1 stripe per file
1861 do_facet ost$((OSTIDX + 1)) lctl set_param -n obdfilter.$OST.degraded 1
1863 createmany -o $DIR/$tdir/$tfile $OSTCOUNT
1864 for i in $(seq 0 $OFFSET); do
1865 [ $($LFS getstripe $DIR/$tdir/$tfile$i | grep -A 10 obdidx |
1866 awk '{print $1}' | grep -w "$OSTIDX") ] &&
1867 error "OST0 was degraded but new created file still use it"
1869 do_facet ost$((OSTIDX + 1)) lctl set_param -n obdfilter.$OST.degraded 0
1871 run_test 27x "create files while OST0 is degraded"
1874 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
1875 remote_mds_nodsh && skip "remote MDS with nodsh"
1876 remote_ost_nodsh && skip "remote OST with nodsh"
1877 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1879 local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS $FSNAME-OST0000)
1880 local last_id=$(do_facet $SINGLEMDS lctl get_param -n \
1881 osc.$mdtosc.prealloc_last_id)
1882 local next_id=$(do_facet $SINGLEMDS lctl get_param -n \
1883 osc.$mdtosc.prealloc_next_id)
1884 local fcount=$((last_id - next_id))
1885 [[ $fcount -eq 0 ]] && skip "not enough space on OST0"
1886 [[ $fcount -gt $OSTCOUNT ]] && fcount=$OSTCOUNT
1888 local MDS_OSCS=$(do_facet $SINGLEMDS lctl dl |
1889 awk '/[oO][sS][cC].*md[ts]/ { print $4 }')
1890 local OST_DEACTIVE_IDX=-1
1895 for OSC in $MDS_OSCS; do
1896 OST=$(osc_to_ost $OSC)
1897 OSTIDX=$(index_from_ostuuid $OST)
1898 if [ $OST_DEACTIVE_IDX == -1 ]; then
1899 OST_DEACTIVE_IDX=$OSTIDX
1901 if [ $OSTIDX != $OST_DEACTIVE_IDX ]; then
1902 echo $OSC "is Deactivated:"
1903 do_facet $SINGLEMDS lctl --device %$OSC deactivate
1907 OSTIDX=$(index_from_ostuuid $OST)
1908 test_mkdir $DIR/$tdir
1909 $LFS setstripe -c 1 $DIR/$tdir # 1 stripe / file
1911 for OSC in $MDS_OSCS; do
1912 OST=$(osc_to_ost $OSC)
1913 OSTIDX=$(index_from_ostuuid $OST)
1914 if [ $OSTIDX == $OST_DEACTIVE_IDX ]; then
1915 echo $OST "is degraded:"
1916 do_facet ost$((OSTIDX+1)) lctl set_param -n \
1917 obdfilter.$OST.degraded=1
1922 createmany -o $DIR/$tdir/$tfile $fcount
1924 for OSC in $MDS_OSCS; do
1925 OST=$(osc_to_ost $OSC)
1926 OSTIDX=$(index_from_ostuuid $OST)
1927 if [ $OSTIDX == $OST_DEACTIVE_IDX ]; then
1928 echo $OST "is recovered from degraded:"
1929 do_facet ost$((OSTIDX+1)) lctl set_param -n \
1930 obdfilter.$OST.degraded=0
1932 do_facet $SINGLEMDS lctl --device %$OSC activate
1936 # all osp devices get activated, hence -1 stripe count restored
1937 local stripe_count=0
1939 # sleep 2*lod_qos_maxage seconds waiting for lod qos to notice osp
1940 # devices get activated.
1942 $LFS setstripe -c -1 $DIR/$tfile
1943 stripe_count=$($LFS getstripe -c $DIR/$tfile)
1945 [ $stripe_count -ne $OSTCOUNT ] &&
1946 error "Of $OSTCOUNT OSTs, only $stripe_count is available"
1949 run_test 27y "create files while OST0 is degraded and the rest inactive"
1955 lmm_count=$($GETSTRIPE -c $1)
1956 lmm_seq=$($GETSTRIPE -v $1 | awk '/lmm_seq/ { print $2 }')
1957 lmm_oid=$($GETSTRIPE -v $1 | awk '/lmm_object_id/ { print $2 }')
1959 local old_ifs="$IFS"
1961 fid=($($LFS path2fid $1))
1964 log "FID seq ${fid[1]}, oid ${fid[2]} ver ${fid[3]}"
1965 log "LOV seq $lmm_seq, oid $lmm_oid, count: $lmm_count"
1967 # compare lmm_seq and lu_fid->f_seq
1968 [ $lmm_seq = ${fid[1]} ] || { error "SEQ mismatch"; return 1; }
1969 # compare lmm_object_id and lu_fid->oid
1970 [ $lmm_oid = ${fid[2]} ] || { error "OID mismatch"; return 2; }
1972 # check the trusted.fid attribute of the OST objects of the file
1973 local have_obdidx=false
1975 $GETSTRIPE $1 | while read obdidx oid hex seq; do
1976 # skip lines up to and including "obdidx"
1977 [ -z "$obdidx" ] && break
1978 [ "$obdidx" = "obdidx" ] && have_obdidx=true && continue
1979 $have_obdidx || continue
1981 local ost=$((obdidx + 1))
1982 local dev=$(ostdevname $ost)
1985 log "want: stripe:$stripe_nr ost:$obdidx oid:$oid/$hex seq:$seq"
1987 seq=$(echo $seq | sed -e "s/^0x//g")
1988 if [ $seq == 0 ] || [ $(facet_fstype ost$ost) == zfs ]; then
1989 oid_hex=$(echo $oid)
1991 oid_hex=$(echo $hex | sed -e "s/^0x//g")
1993 local obj_file="O/$seq/d$((oid %32))/$oid_hex"
1997 # Don't unmount/remount the OSTs if we don't need to do that.
1998 # LU-2577 changes filter_fid to be smaller, so debugfs needs
1999 # update too, until that use mount/ll_decode_filter_fid/mount.
2000 # Re-enable when debugfs will understand new filter_fid.
2002 if [ $(facet_fstype ost$ost) == ldiskfs ]; then
2003 ff=$(do_facet ost$ost "$DEBUGFS -c -R 'stat $obj_file' \
2004 $dev 2>/dev/null" | grep "parent=")
2006 if [ -z "$ff" ]; then
2008 mount_fstype ost$ost
2009 ff=$(do_facet ost$ost $LL_DECODE_FILTER_FID \
2010 $(facet_mntpt ost$ost)/$obj_file)
2011 unmount_fstype ost$ost
2012 start ost$ost $dev $OST_MOUNT_OPTS
2016 [ -z "$ff" ] && error "$obj_file: no filter_fid info"
2018 echo "$ff" | sed -e 's#.*objid=#got: objid=#'
2020 # /mnt/O/0/d23/23: objid=23 seq=0 parent=[0x200000400:0x1e:0x1]
2021 # fid: objid=23 seq=0 parent=[0x200000400:0x1e:0x0] stripe=1
2023 # fid: parent=[0x200000400:0x1e:0x0] stripe=1 stripe_count=2 \
2024 # stripe_size=1048576 component_id=1 component_start=0 \
2025 # component_end=33554432
2026 local ff_parent=$(sed -e 's/.*parent=.//' <<<$ff)
2027 local ff_pseq=$(cut -d: -f1 <<<$ff_parent)
2028 local ff_poid=$(cut -d: -f2 <<<$ff_parent)
2030 if grep -q 'stripe=' <<<$ff; then
2031 ff_pstripe=$(sed -e 's/.*stripe=//' -e 's/ .*//' <<<$ff)
2033 # $LL_DECODE_FILTER_FID does not print "stripe="; look
2034 # into f_ver in this case. See comment on ff_parent.
2035 ff_pstripe=$(cut -d: -f3 <<<$ff_parent | sed -e 's/]//')
2038 # compare lmm_seq and filter_fid->ff_parent.f_seq
2039 [ $ff_pseq = $lmm_seq ] ||
2040 error "FF parent SEQ $ff_pseq != $lmm_seq"
2041 # compare lmm_object_id and filter_fid->ff_parent.f_oid
2042 [ $ff_poid = $lmm_oid ] ||
2043 error "FF parent OID $ff_poid != $lmm_oid"
2044 (($ff_pstripe == $stripe_nr)) ||
2045 error "FF stripe $ff_pstripe != $stripe_nr"
2047 stripe_nr=$((stripe_nr + 1))
2048 [ $(lustre_version_code client) -lt $(version_code 2.9.55) ] &&
2050 if grep -q 'stripe_count=' <<<$ff; then
2051 local ff_scnt=$(sed -e 's/.*stripe_count=//' \
2052 -e 's/ .*//' <<<$ff)
2053 [ $lmm_count = $ff_scnt ] ||
2054 error "FF stripe count $lmm_count != $ff_scnt"
2060 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2061 remote_ost_nodsh && skip "remote OST with nodsh"
2063 test_mkdir $DIR/$tdir
2064 $LFS setstripe -c 1 -i 0 -S 64k $DIR/$tdir/$tfile-1 ||
2065 { error "setstripe -c -1 failed"; return 1; }
2066 # We need to send a write to every object to get parent FID info set.
2067 # This _should_ also work for setattr, but does not currently.
2068 # touch $DIR/$tdir/$tfile-1 ||
2069 dd if=/dev/zero of=$DIR/$tdir/$tfile-1 bs=1M count=1 ||
2070 { error "dd $tfile-1 failed"; return 2; }
2071 $LFS setstripe -c -1 -i $((OSTCOUNT - 1)) -S 1M $DIR/$tdir/$tfile-2 ||
2072 { error "setstripe -c -1 failed"; return 3; }
2073 dd if=/dev/zero of=$DIR/$tdir/$tfile-2 bs=1M count=$OSTCOUNT ||
2074 { error "dd $tfile-2 failed"; return 4; }
2076 # make sure write RPCs have been sent to OSTs
2079 check_seq_oid $DIR/$tdir/$tfile-1 || return 5
2080 check_seq_oid $DIR/$tdir/$tfile-2 || return 6
2082 run_test 27z "check SEQ/OID on the MDT and OST filesystems"
2084 test_27A() { # b=19102
2085 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2087 save_layout_restore_at_exit $MOUNT
2088 $LFS setstripe -c 0 -i -1 -S 0 $MOUNT
2089 wait_update $HOSTNAME "$GETSTRIPE -c $MOUNT | sed 's/ *//g'" "1" 20 ||
2090 error "stripe count $($GETSTRIPE -c $MOUNT) != 1"
2091 local default_size=$($GETSTRIPE -S $MOUNT)
2092 local default_offset=$($GETSTRIPE -i $MOUNT)
2093 local dsize=$(do_facet $SINGLEMDS \
2094 "$LCTL get_param -n lod.$(facet_svc $SINGLEMDS)*.stripesize")
2095 [ $default_size -eq $dsize ] ||
2096 error "stripe size $default_size != $dsize"
2097 [ $default_offset -eq -1 ] ||
2098 error "stripe offset $default_offset != -1"
2100 run_test 27A "check filesystem-wide default LOV EA values"
2102 test_27B() { # LU-2523
2103 test_mkdir $DIR/$tdir
2104 rm -f $DIR/$tdir/f0 $DIR/$tdir/f1
2106 # open f1 with O_LOV_DELAY_CREATE
2108 # call setstripe ioctl on open file descriptor for f1
2110 multiop $DIR/$tdir/f1 oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:nB1c \
2114 # open f1 with O_LOV_DELAY_CREATE
2116 # call setstripe ioctl on open file descriptor for f1
2118 multiop $DIR/$tdir/f1 oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:uB1c
2120 # Allow multiop to fail in imitation of NFS's busted semantics.
2123 run_test 27B "call setstripe on open unlinked file/rename victim"
2125 test_27C() { #LU-2871
2126 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
2134 test_mkdir $DIR/$tdir
2136 for i in $(seq 0 $((OSTCOUNT - 1))); do
2137 # set stripe across all OSTs starting from OST$i
2138 $SETSTRIPE -i $i -c -1 $tfile$i
2139 # get striping information
2140 ost_idx=($($GETSTRIPE $tfile$i |
2141 tail -n $((OSTCOUNT + 1)) | awk '{print $1}'))
2145 [ ${#ost_idx[@]} -eq $OSTCOUNT ] ||
2146 error "${#ost_idx[@]} != $OSTCOUNT"
2148 for index in $(seq 0 $((OSTCOUNT - 1))); do
2150 for j in $(echo ${ost_idx[@]}); do
2151 if [ $index -eq $j ]; then
2157 error "Can not find $index in ${ost_idx[@]}"
2161 run_test 27C "check full striping across all OSTs"
2164 [ $OSTCOUNT -lt 2 ] && skip_env "needs >= 2 OSTs"
2165 [ -n "$FILESET" ] && skip "SKIP due to FILESET set"
2166 remote_mds_nodsh && skip "remote MDS with nodsh"
2168 local POOL=${POOL:-testpool}
2170 local last_ost=$(($OSTCOUNT - 1))
2172 local ost_list=$(seq $first_ost $ost_step $last_ost)
2173 local ost_range="$first_ost $last_ost $ost_step"
2175 if ! combined_mgs_mds ; then
2179 test_mkdir $DIR/$tdir
2180 pool_add $POOL || error "pool_add failed"
2181 pool_add_targets $POOL $ost_range || error "pool_add_targets failed"
2184 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.8.55) ] &&
2186 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.9.55) -o \
2187 $(lustre_version_code client) -lt $(version_code 2.9.55) ] &&
2188 skip27D+=" -s 30,31"
2189 llapi_layout_test -d$DIR/$tdir -p$POOL -o$OSTCOUNT $skip27D ||
2190 error "llapi_layout_test failed"
2192 destroy_test_pools || error "destroy test pools failed"
2194 if ! combined_mgs_mds ; then
2198 run_test 27D "validate llapi_layout API"
2200 # Verify that default_easize is increased from its initial value after
2201 # accessing a widely striped file.
2203 [ $OSTCOUNT -lt 2 ] && skip_env "needs >= 2 OSTs"
2204 [ $(lustre_version_code client) -lt $(version_code 2.5.57) ] &&
2205 skip "client does not have LU-3338 fix"
2207 # 72 bytes is the minimum space required to store striping
2208 # information for a file striped across one OST:
2209 # (sizeof(struct lov_user_md_v3) +
2210 # sizeof(struct lov_user_ost_data_v1))
2212 $LCTL set_param -n llite.*.default_easize $min_easize ||
2213 error "lctl set_param failed"
2214 local easize=$($LCTL get_param -n llite.*.default_easize)
2216 [ $easize -eq $min_easize ] ||
2217 error "failed to set default_easize"
2219 $LFS setstripe -c $OSTCOUNT $DIR/$tfile ||
2220 error "setstripe failed"
2224 easize=$($LCTL get_param -n llite.*.default_easize)
2226 [ $easize -gt $min_easize ] ||
2227 error "default_easize not updated"
2229 run_test 27E "check that default extended attribute size properly increases"
2231 test_27F() { # LU-5346/LU-7975
2232 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2233 [[ $OSTCOUNT -lt 2 ]] && skip "needs >= 2 OSTs"
2234 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.8.51) ]] &&
2235 skip "Need MDS version at least 2.8.51"
2236 remote_ost_nodsh && skip "remote OST with nodsh"
2238 test_mkdir $DIR/$tdir
2240 $SETSTRIPE -c 2 $DIR/$tdir
2242 # stop all OSTs to reproduce situation for LU-7975 ticket
2243 for num in $(seq $OSTCOUNT); do
2247 # open/create f0 with O_LOV_DELAY_CREATE
2248 # truncate f0 to a non-0 size
2250 multiop $DIR/$tdir/f0 oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:T1050000c
2252 $CHECKSTAT -s 1050000 $DIR/$tdir/f0 || error "checkstat failed"
2253 # open/write it again to force delayed layout creation
2254 cat /etc/hosts > $DIR/$tdir/f0 &
2258 for num in $(seq $OSTCOUNT); do
2259 start ost$num $(ostdevname $num) $OST_MOUNT_OPTS ||
2260 error "ost$num failed to start"
2263 wait $catpid || error "cat failed"
2265 cmp /etc/hosts $DIR/$tdir/f0 || error "cmp failed"
2266 [[ $($GETSTRIPE -c $DIR/$tdir/f0) == 2 ]] || error "wrong stripecount"
2269 run_test 27F "Client resend delayed layout creation with non-zero size"
2271 test_27G() { #LU-10629
2272 [ -n "$FILESET" ] && skip "SKIP due to FILESET set" && return
2273 remote_mds_nodsh && skip "remote MDS with nodsh" && return
2274 local POOL=${POOL:-testpool}
2275 local ostrange="0 0 1"
2277 test_mkdir $DIR/$tdir
2278 pool_add $POOL || error "pool_add failed"
2279 pool_add_targets $POOL $ostrange || error "pool_add_targets failed"
2280 $LFS setstripe -p $POOL $DIR/$tdir
2282 local pool=$($LFS getstripe -p $DIR/$tdir)
2284 [ "$pool" = "$POOL" ] || error "Striping failed got '$pool' not '$POOL'"
2286 $LFS setstripe -d $DIR/$tdir
2288 pool=$($LFS getstripe -p $DIR/$tdir)
2292 [ -z "$pool" ] || error "'$pool' is not empty"
2294 run_test 27G "Clear OST pool from stripe"
2297 [[ $(lustre_version_code $SINGLEMDS) -le $(version_code 2.11.54) ]] &&
2298 skip "Need MDS version newer than 2.11.54"
2299 [[ $OSTCOUNT -lt 3 ]] && skip_env "needs >= 3 OSTs"
2300 test_mkdir $DIR/$tdir
2301 $LFS setstripe -o 0 -o 2 $DIR/$tdir || error "setstripe failed"
2302 touch $DIR/$tdir/$tfile
2303 $LFS getstripe -c $DIR/$tdir/$tfile
2304 [ $($LFS getstripe -c $DIR/$tdir/$tfile) -eq 2 ] ||
2305 error "two-stripe file doesn't have two stripes"
2307 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=4k count=4 || error "dd failed"
2308 $LFS getstripe -y $DIR/$tdir/$tfile
2309 (( $($LFS getstripe -y $DIR/$tdir/$tfile |
2310 egrep -c "l_ost_idx: [02]$") == "2" )) ||
2311 error "expected l_ost_idx: [02]$ not matched"
2313 # make sure ost list have been cleared
2314 local stripesize=$($GETSTRIPE -S $DIR/$tdir)
2315 $LFS setstripe -S $((stripesize * 4)) -i 1 \
2316 -c $((OSTCOUNT - 1)) $DIR/$tdir || error "setstripe"
2318 $LVERIFY $DIR/$tdir $DIR/$tdir/f3 || error "lverify failed"
2320 run_test 27H "Set specific OSTs stripe"
2322 # createtest also checks that device nodes are created and
2323 # then visible correctly (#2091)
2324 test_28() { # bug 2091
2326 $CREATETEST $DIR/d28/ct || error "createtest failed"
2328 run_test 28 "create/mknod/mkdir with bad file types ============"
2331 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2333 sync; sleep 1; sync # flush out any dirty pages from previous tests
2340 declare -i LOCKCOUNTORIG=0
2341 for lock_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_count); do
2342 let LOCKCOUNTORIG=$LOCKCOUNTORIG+$lock_count
2344 [ $LOCKCOUNTORIG -eq 0 ] && error "No mdc lock count" && return 1
2346 declare -i LOCKUNUSEDCOUNTORIG=0
2347 for unused_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_unused_count); do
2348 let LOCKUNUSEDCOUNTORIG=$LOCKUNUSEDCOUNTORIG+$unused_count
2355 declare -i LOCKCOUNTCURRENT=0
2356 for lock_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_count); do
2357 let LOCKCOUNTCURRENT=$LOCKCOUNTCURRENT+$lock_count
2360 declare -i LOCKUNUSEDCOUNTCURRENT=0
2361 for unused_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_unused_count); do
2362 let LOCKUNUSEDCOUNTCURRENT=$LOCKUNUSEDCOUNTCURRENT+$unused_count
2365 if [[ $LOCKCOUNTCURRENT -gt $LOCKCOUNTORIG ]]; then
2366 $LCTL set_param -n ldlm.dump_namespaces ""
2367 error "CURRENT: $LOCKCOUNTCURRENT > $LOCKCOUNTORIG"
2368 $LCTL dk | sort -k4 -t: > $TMP/test_29.dk
2369 log "dumped log to $TMP/test_29.dk (bug 5793)"
2372 if [[ $LOCKUNUSEDCOUNTCURRENT -gt $LOCKUNUSEDCOUNTORIG ]]; then
2373 error "UNUSED: $LOCKUNUSEDCOUNTCURRENT > $LOCKUNUSEDCOUNTORIG"
2374 $LCTL dk | sort -k4 -t: > $TMP/test_29.dk
2375 log "dumped log to $TMP/test_29.dk (bug 5793)"
2379 run_test 29 "IT_GETATTR regression ============================"
2381 test_30a() { # was test_30
2382 cp $(which ls) $DIR || cp /bin/ls $DIR
2383 $DIR/ls / || error "Can't execute binary from lustre"
2386 run_test 30a "execute binary from Lustre (execve) =============="
2389 cp `which ls` $DIR || cp /bin/ls $DIR
2391 $RUNAS $DIR/ls / || error "Can't execute binary from lustre as non-root"
2394 run_test 30b "execute binary from Lustre as non-root ==========="
2396 test_30c() { # b=22376
2397 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2399 cp `which ls` $DIR || cp /bin/ls $DIR
2401 cancel_lru_locks mdc
2402 cancel_lru_locks osc
2403 $RUNAS $DIR/ls / || error "Can't execute binary from lustre"
2406 run_test 30c "execute binary from Lustre without read perms ===="
2409 $OPENUNLINK $DIR/f31 $DIR/f31 || error "openunlink failed"
2410 $CHECKSTAT -a $DIR/f31 || error "$DIR/f31 exists"
2412 run_test 31a "open-unlink file =================================="
2415 touch $DIR/f31 || error "touch $DIR/f31 failed"
2416 ln $DIR/f31 $DIR/f31b || error "ln failed"
2417 $MULTIOP $DIR/f31b Ouc || error "multiop failed"
2418 $CHECKSTAT -t file $DIR/f31 || error "$DIR/f31 not file type"
2420 run_test 31b "unlink file with multiple links while open ======="
2423 touch $DIR/f31 || error "touch $DIR/f31 failed"
2424 ln $DIR/f31 $DIR/f31c || error "ln failed"
2425 multiop_bg_pause $DIR/f31 O_uc ||
2426 error "multiop_bg_pause for $DIR/f31 failed"
2428 $MULTIOP $DIR/f31c Ouc
2429 kill -USR1 $MULTIPID
2432 run_test 31c "open-unlink file with multiple links ============="
2435 opendirunlink $DIR/d31d $DIR/d31d || error "opendirunlink failed"
2436 $CHECKSTAT -a $DIR/d31d || error "$DIR/d31d exists"
2438 run_test 31d "remove of open directory ========================="
2440 test_31e() { # bug 2904
2441 openfilleddirunlink $DIR/d31e || error "openfilleddirunlink failed"
2443 run_test 31e "remove of open non-empty directory ==============="
2445 test_31f() { # bug 4554
2446 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2449 test_mkdir $DIR/d31f
2450 $SETSTRIPE -S 1048576 -c 1 $DIR/d31f
2451 cp /etc/hosts $DIR/d31f
2453 $GETSTRIPE $DIR/d31f/hosts
2454 multiop_bg_pause $DIR/d31f D_c || return 1
2457 rm -rv $DIR/d31f || error "first of $DIR/d31f"
2458 test_mkdir $DIR/d31f
2459 $SETSTRIPE -S 1048576 -c 1 $DIR/d31f
2460 cp /etc/hosts $DIR/d31f
2462 $GETSTRIPE $DIR/d31f/hosts
2463 multiop_bg_pause $DIR/d31f D_c || return 1
2466 kill -USR1 $MULTIPID || error "first opendir $MULTIPID not running"
2467 wait $MULTIPID || error "first opendir $MULTIPID failed"
2471 kill -USR1 $MULTIPID2 || error "second opendir $MULTIPID not running"
2472 wait $MULTIPID2 || error "second opendir $MULTIPID2 failed"
2475 run_test 31f "remove of open directory with open-unlink file ==="
2478 echo "-- cross directory link --"
2479 test_mkdir -c1 $DIR/${tdir}ga
2480 test_mkdir -c1 $DIR/${tdir}gb
2481 touch $DIR/${tdir}ga/f
2482 ln $DIR/${tdir}ga/f $DIR/${tdir}gb/g
2483 $CHECKSTAT -t file $DIR/${tdir}ga/f || error "source"
2484 [ `stat -c%h $DIR/${tdir}ga/f` == '2' ] || error "source nlink"
2485 $CHECKSTAT -t file $DIR/${tdir}gb/g || error "target"
2486 [ `stat -c%h $DIR/${tdir}gb/g` == '2' ] || error "target nlink"
2488 run_test 31g "cross directory link==============="
2491 echo "-- cross directory link --"
2492 test_mkdir -c1 $DIR/${tdir}
2493 test_mkdir -c1 $DIR/${tdir}/dir
2494 touch $DIR/${tdir}/f
2495 ln $DIR/${tdir}/f $DIR/${tdir}/dir/g
2496 $CHECKSTAT -t file $DIR/${tdir}/f || error "source"
2497 [ `stat -c%h $DIR/${tdir}/f` == '2' ] || error "source nlink"
2498 $CHECKSTAT -t file $DIR/${tdir}/dir/g || error "target"
2499 [ `stat -c%h $DIR/${tdir}/dir/g` == '2' ] || error "target nlink"
2501 run_test 31h "cross directory link under child==============="
2504 echo "-- cross directory link --"
2505 test_mkdir -c1 $DIR/$tdir
2506 test_mkdir -c1 $DIR/$tdir/dir
2507 touch $DIR/$tdir/dir/f
2508 ln $DIR/$tdir/dir/f $DIR/$tdir/g
2509 $CHECKSTAT -t file $DIR/$tdir/dir/f || error "source"
2510 [ `stat -c%h $DIR/$tdir/dir/f` == '2' ] || error "source nlink"
2511 $CHECKSTAT -t file $DIR/$tdir/g || error "target"
2512 [ `stat -c%h $DIR/$tdir/g` == '2' ] || error "target nlink"
2514 run_test 31i "cross directory link under parent==============="
2517 test_mkdir -c1 -p $DIR/$tdir
2518 test_mkdir -c1 -p $DIR/$tdir/dir1
2519 ln $DIR/$tdir/dir1 $DIR/$tdir/dir2 && error "ln for dir"
2520 link $DIR/$tdir/dir1 $DIR/$tdir/dir3 && error "link for dir"
2521 mlink $DIR/$tdir/dir1 $DIR/$tdir/dir4 && error "mlink for dir"
2522 mlink $DIR/$tdir/dir1 $DIR/$tdir/dir1 && error "mlink to the same dir"
2525 run_test 31j "link for directory==============="
2528 test_mkdir -c1 -p $DIR/$tdir
2530 touch $DIR/$tdir/exist
2531 mlink $DIR/$tdir/s $DIR/$tdir/t || error "mlink"
2532 mlink $DIR/$tdir/s $DIR/$tdir/exist && error "mlink to exist file"
2533 mlink $DIR/$tdir/s $DIR/$tdir/s && error "mlink to the same file"
2534 mlink $DIR/$tdir/s $DIR/$tdir && error "mlink to parent dir"
2535 mlink $DIR/$tdir $DIR/$tdir/s && error "mlink parent dir to target"
2536 mlink $DIR/$tdir/not-exist $DIR/$tdir/foo && error "mlink non-existing to new"
2537 mlink $DIR/$tdir/not-exist $DIR/$tdir/s && error "mlink non-existing to exist"
2540 run_test 31k "link to file: the same, non-existing, dir==============="
2546 touch $DIR/d31m2/exist
2547 mlink $DIR/d31m/s $DIR/d31m2/t || error "mlink"
2548 mlink $DIR/d31m/s $DIR/d31m2/exist && error "mlink to exist file"
2549 mlink $DIR/d31m/s $DIR/d31m2 && error "mlink to parent dir"
2550 mlink $DIR/d31m2 $DIR/d31m/s && error "mlink parent dir to target"
2551 mlink $DIR/d31m/not-exist $DIR/d31m2/foo && error "mlink non-existing to new"
2552 mlink $DIR/d31m/not-exist $DIR/d31m2/s && error "mlink non-existing to exist"
2555 run_test 31m "link to file: the same, non-existing, dir==============="
2558 touch $DIR/$tfile || error "cannot create '$DIR/$tfile'"
2559 nlink=$(stat --format=%h $DIR/$tfile)
2560 [ ${nlink:--1} -eq 1 ] || error "nlink is $nlink, expected 1"
2562 local cmd="exec $fd<$DIR/$tfile"
2565 trap "eval $cmd" EXIT
2566 nlink=$(stat --dereference --format=%h /proc/self/fd/$fd)
2567 [ ${nlink:--1} -eq 1 ] || error "nlink is $nlink, expected 1"
2568 rm $DIR/$tfile || error "cannot remove '$DIR/$tfile'"
2569 nlink=$(stat --dereference --format=%h /proc/self/fd/$fd)
2570 [ ${nlink:--1} -eq 0 ] || error "nlink is $nlink, expected 0"
2573 run_test 31n "check link count of unlinked file"
2576 local TEMPNAME=$(mktemp $1_XXXXXX)
2577 mlink $TEMPNAME $1 2> /dev/null &&
2578 echo "$BASHPID: link $TEMPNAME to $1 succeeded"
2582 test_31o() { # LU-2901
2583 test_mkdir $DIR/$tdir
2584 for LOOP in $(seq 100); do
2585 rm -f $DIR/$tdir/$tfile*
2586 for THREAD in $(seq 8); do
2587 link_one $DIR/$tdir/$tfile.$LOOP &
2590 local LINKS=$(ls -1 $DIR/$tdir | grep -c $tfile.$LOOP)
2591 [[ $LINKS -gt 1 ]] && ls $DIR/$tdir &&
2592 error "$LINKS duplicate links to $tfile.$LOOP" &&
2596 run_test 31o "duplicate hard links with same filename"
2599 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
2601 test_mkdir $DIR/$tdir
2602 $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
2603 $LFS setdirstripe -D -c2 -H all_char $DIR/$tdir/striped_dir
2605 opendirunlink $DIR/$tdir/striped_dir/test1 ||
2606 error "open unlink test1 failed"
2607 opendirunlink $DIR/$tdir/striped_dir/test2 ||
2608 error "open unlink test2 failed"
2610 $CHECKSTAT -a $DIR/$tdir/striped_dir/test1 ||
2611 error "test1 still exists"
2612 $CHECKSTAT -a $DIR/$tdir/striped_dir/test2 ||
2613 error "test2 still exists"
2615 run_test 31p "remove of open striped directory"
2617 cleanup_test32_mount() {
2620 local loopdev=$(losetup -a | grep $EXT2_DEV | sed -ne 's/:.*$//p')
2621 $UMOUNT $DIR/$tdir/ext2-mountpoint || rc=$?
2622 losetup -d $loopdev || true
2628 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2630 echo "== more mountpoints and symlinks ================="
2631 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2632 trap cleanup_test32_mount EXIT
2633 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2634 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
2635 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
2636 $CHECKSTAT -t dir $DIR/$tdir/ext2-mountpoint/.. ||
2637 error "$DIR/$tdir/ext2-mountpoint/.. not dir type"
2638 cleanup_test32_mount
2640 run_test 32a "stat d32a/ext2-mountpoint/.. ====================="
2643 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2645 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2646 trap cleanup_test32_mount EXIT
2647 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2648 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
2649 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
2650 ls -al $DIR/$tdir/ext2-mountpoint/.. ||
2651 error "Can't list $DIR/$tdir/ext2-mountpoint/.."
2652 cleanup_test32_mount
2654 run_test 32b "open d32b/ext2-mountpoint/.. ====================="
2657 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2659 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2660 trap cleanup_test32_mount EXIT
2661 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2662 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
2663 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
2664 test_mkdir -p $DIR/$tdir/d2/test_dir
2665 $CHECKSTAT -t dir $DIR/$tdir/ext2-mountpoint/../d2/test_dir ||
2666 error "$DIR/$tdir/ext2-mountpoint/../d2/test_dir not dir type"
2667 cleanup_test32_mount
2669 run_test 32c "stat d32c/ext2-mountpoint/../d2/test_dir ========="
2672 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2674 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2675 trap cleanup_test32_mount EXIT
2676 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2677 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
2678 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
2679 test_mkdir -p $DIR/$tdir/d2/test_dir
2680 ls -al $DIR/$tdir/ext2-mountpoint/../d2/test_dir ||
2681 error "Can't list $DIR/$tdir/ext2-mountpoint/../d2/test_dir"
2682 cleanup_test32_mount
2684 run_test 32d "open d32d/ext2-mountpoint/../d2/test_dir"
2688 test_mkdir -p $DIR/$tdir/tmp
2689 local tmp_dir=$DIR/$tdir/tmp
2690 ln -s $DIR/$tdir $tmp_dir/symlink11
2691 ln -s $tmp_dir/symlink11 $tmp_dir/../symlink01
2692 $CHECKSTAT -t link $DIR/$tdir/tmp/symlink11 || error "symlink11 bad"
2693 $CHECKSTAT -t link $DIR/$tdir/symlink01 || error "symlink01 bad"
2695 run_test 32e "stat d32e/symlink->tmp/symlink->lustre-subdir"
2699 test_mkdir -p $DIR/$tdir/tmp
2700 local tmp_dir=$DIR/$tdir/tmp
2701 ln -s $DIR/$tdir $tmp_dir/symlink11
2702 ln -s $tmp_dir/symlink11 $tmp_dir/../symlink01
2703 ls $DIR/$tdir/tmp/symlink11 || error "symlink11 bad"
2704 ls $DIR/$tdir/symlink01 || error "symlink01 bad"
2706 run_test 32f "open d32f/symlink->tmp/symlink->lustre-subdir"
2709 local tmp_dir=$DIR/$tdir/tmp
2710 test_mkdir -p $tmp_dir
2711 test_mkdir $DIR/${tdir}2
2712 ln -s $DIR/${tdir}2 $tmp_dir/symlink12
2713 ln -s $tmp_dir/symlink12 $tmp_dir/../symlink02
2714 $CHECKSTAT -t link $tmp_dir/symlink12 || error "symlink12 not a link"
2715 $CHECKSTAT -t link $DIR/$tdir/symlink02 || error "symlink02 not a link"
2716 $CHECKSTAT -t dir -f $tmp_dir/symlink12 || error "symlink12 not a dir"
2717 $CHECKSTAT -t dir -f $DIR/$tdir/symlink02 || error "symlink12 not a dir"
2719 run_test 32g "stat d32g/symlink->tmp/symlink->lustre-subdir/${tdir}2"
2722 rm -fr $DIR/$tdir $DIR/${tdir}2
2723 tmp_dir=$DIR/$tdir/tmp
2724 test_mkdir -p $tmp_dir
2725 test_mkdir $DIR/${tdir}2
2726 ln -s $DIR/${tdir}2 $tmp_dir/symlink12
2727 ln -s $tmp_dir/symlink12 $tmp_dir/../symlink02
2728 ls $tmp_dir/symlink12 || error "listing symlink12"
2729 ls $DIR/$tdir/symlink02 || error "listing symlink02"
2731 run_test 32h "open d32h/symlink->tmp/symlink->lustre-subdir/${tdir}2"
2734 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2736 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2737 trap cleanup_test32_mount EXIT
2738 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2739 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
2740 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
2741 touch $DIR/$tdir/test_file
2742 $CHECKSTAT -t file $DIR/$tdir/ext2-mountpoint/../test_file ||
2743 error "$DIR/$tdir/ext2-mountpoint/../test_file not file type"
2744 cleanup_test32_mount
2746 run_test 32i "stat d32i/ext2-mountpoint/../test_file ==========="
2749 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2751 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2752 trap cleanup_test32_mount EXIT
2753 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2754 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
2755 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
2756 touch $DIR/$tdir/test_file
2757 cat $DIR/$tdir/ext2-mountpoint/../test_file ||
2758 error "Can't open $DIR/$tdir/ext2-mountpoint/../test_file"
2759 cleanup_test32_mount
2761 run_test 32j "open d32j/ext2-mountpoint/../test_file ==========="
2764 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2767 trap cleanup_test32_mount EXIT
2768 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2769 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
2770 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
2771 test_mkdir -p $DIR/$tdir/d2
2772 touch $DIR/$tdir/d2/test_file || error "touch failed"
2773 $CHECKSTAT -t file $DIR/$tdir/ext2-mountpoint/../d2/test_file ||
2774 error "$DIR/$tdir/ext2-mountpoint/../d2/test_file not file type"
2775 cleanup_test32_mount
2777 run_test 32k "stat d32k/ext2-mountpoint/../d2/test_file ========"
2780 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2783 trap cleanup_test32_mount EXIT
2784 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2785 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
2786 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
2787 test_mkdir -p $DIR/$tdir/d2
2788 touch $DIR/$tdir/d2/test_file || error "touch failed"
2789 cat $DIR/$tdir/ext2-mountpoint/../d2/test_file ||
2790 error "Can't open $DIR/$tdir/ext2-mountpoint/../d2/test_file"
2791 cleanup_test32_mount
2793 run_test 32l "open d32l/ext2-mountpoint/../d2/test_file ========"
2797 test_mkdir -p $DIR/d32m/tmp
2798 TMP_DIR=$DIR/d32m/tmp
2799 ln -s $DIR $TMP_DIR/symlink11
2800 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
2801 $CHECKSTAT -t link $DIR/d32m/tmp/symlink11 ||
2802 error "symlink11 not a link"
2803 $CHECKSTAT -t link $DIR/d32m/symlink01 ||
2804 error "symlink01 not a link"
2806 run_test 32m "stat d32m/symlink->tmp/symlink->lustre-root ======"
2810 test_mkdir -p $DIR/d32n/tmp
2811 TMP_DIR=$DIR/d32n/tmp
2812 ln -s $DIR $TMP_DIR/symlink11
2813 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
2814 ls -l $DIR/d32n/tmp/symlink11 || error "listing symlink11"
2815 ls -l $DIR/d32n/symlink01 || error "listing symlink01"
2817 run_test 32n "open d32n/symlink->tmp/symlink->lustre-root ======"
2821 test_mkdir -p $DIR/d32o/tmp
2822 TMP_DIR=$DIR/d32o/tmp
2823 ln -s $DIR/$tfile $TMP_DIR/symlink12
2824 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
2825 $CHECKSTAT -t link $DIR/d32o/tmp/symlink12 ||
2826 error "symlink12 not a link"
2827 $CHECKSTAT -t link $DIR/d32o/symlink02 || error "symlink02 not a link"
2828 $CHECKSTAT -t file -f $DIR/d32o/tmp/symlink12 ||
2829 error "$DIR/d32o/tmp/symlink12 not file type"
2830 $CHECKSTAT -t file -f $DIR/d32o/symlink02 ||
2831 error "$DIR/d32o/symlink02 not file type"
2833 run_test 32o "stat d32o/symlink->tmp/symlink->lustre-root/$tfile"
2843 test_mkdir -p $DIR/d32p/tmp
2845 TMP_DIR=$DIR/d32p/tmp
2847 ln -s $DIR/$tfile $TMP_DIR/symlink12
2849 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
2851 cat $DIR/d32p/tmp/symlink12 ||
2852 error "Can't open $DIR/d32p/tmp/symlink12"
2854 cat $DIR/d32p/symlink02 || error "Can't open $DIR/d32p/symlink02"
2857 run_test 32p "open d32p/symlink->tmp/symlink->lustre-root/$tfile"
2860 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2862 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2863 trap cleanup_test32_mount EXIT
2864 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2865 touch $DIR/$tdir/ext2-mountpoint/under_the_mount || error "touch failed"
2866 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
2867 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
2868 ls $DIR/$tdir/ext2-mountpoint | grep "\<under_the_mount\>" && error
2869 cleanup_test32_mount
2871 run_test 32q "stat follows mountpoints in Lustre (should return error)"
2874 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2876 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2877 trap cleanup_test32_mount EXIT
2878 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2879 touch $DIR/$tdir/ext2-mountpoint/under_the_mount || error "touch failed"
2880 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
2881 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
2882 ls $DIR/$tdir/ext2-mountpoint | grep -q under_the_mount && error || true
2883 cleanup_test32_mount
2885 run_test 32r "opendir follows mountpoints in Lustre (should return error)"
2890 chmod 444 $DIR/$tfile
2891 chown $RUNAS_ID $DIR/$tfile
2893 $RUNAS $OPENFILE -f O_RDWR $DIR/$tfile && error || true
2896 run_test 33aa "write file with mode 444 (should return error)"
2900 test_mkdir $DIR/$tdir
2901 chown $RUNAS_ID $DIR/$tdir
2902 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $DIR/$tdir/$tfile ||
2903 error "$RUNAS create $tdir/$tfile failed"
2904 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $DIR/$tdir/$tfile &&
2905 error "open RDWR" || true
2907 run_test 33a "test open file(mode=0444) with O_RDWR (should return error)"
2911 test_mkdir $DIR/$tdir
2912 chown $RUNAS_ID $DIR/$tdir
2913 $RUNAS $OPENFILE -f 1286739555 $DIR/$tdir/$tfile || true
2915 run_test 33b "test open file with malformed flags (No panic)"
2918 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2919 remote_ost_nodsh && skip "remote OST with nodsh"
2928 test_mkdir $DIR/$tdir
2929 # Read: 0, Write: 4, create/destroy: 2/0, stat: 1, punch: 0
2932 for ostnum in $(seq $OSTCOUNT); do
2933 # test-framework's OST numbering is one-based, while Lustre's
2935 ostname=$(printf "$FSNAME-OST%.4x" $((ostnum - 1)))
2936 # Parsing llobdstat's output sucks; we could grep the /proc
2937 # path, but that's likely to not be as portable as using the
2938 # llobdstat utility. So we parse lctl output instead.
2939 write_bytes=$(do_facet ost$ostnum lctl get_param -n \
2940 obdfilter/$ostname/stats |
2941 awk '/^write_bytes/ {print $7}' )
2942 echo "baseline_write_bytes@$OSTnum/$ostname=$write_bytes"
2943 if (( ${write_bytes:-0} > 0 ))
2950 $all_zeros || return 0
2953 echo foo > $DIR/$tdir/bar
2957 # Total up write_bytes after writing. We'd better find non-zeros.
2958 for ostnum in $(seq $OSTCOUNT); do
2959 ostname=$(printf "$FSNAME-OST%.4x" $((ostnum - 1)))
2960 write_bytes=$(do_facet ost$ostnum lctl get_param -n \
2961 obdfilter/$ostname/stats |
2962 awk '/^write_bytes/ {print $7}' )
2963 echo "write_bytes@$OSTnum/$ostname=$write_bytes"
2964 if (( ${write_bytes:-0} > 0 ))
2973 for ostnum in $(seq $OSTCOUNT); do
2974 ostname=$(printf "$FSNAME-OST%.4x" $((ostnum - 1)))
2975 echo "Check that write_bytes is present in obdfilter/*/stats:"
2976 do_facet ost$ostnum lctl get_param -n \
2977 obdfilter/$ostname/stats
2979 error "OST not keeping write_bytes stats (b22312)"
2982 run_test 33c "test llobdstat and write_bytes"
2985 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
2986 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2989 local remote_dir=$DIR/$tdir/remote_dir
2991 test_mkdir $DIR/$tdir
2992 $LFS mkdir -i $MDTIDX $remote_dir ||
2993 error "create remote directory failed"
2995 touch $remote_dir/$tfile
2996 chmod 444 $remote_dir/$tfile
2997 chown $RUNAS_ID $remote_dir/$tfile
2999 $RUNAS $OPENFILE -f O_RDWR $DIR/$tfile && error || true
3001 chown $RUNAS_ID $remote_dir
3002 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $remote_dir/f33 ||
3003 error "create" || true
3004 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $remote_dir/f33 &&
3005 error "open RDWR" || true
3006 $RUNAS $OPENFILE -f 1286739555 $remote_dir/f33 || true
3008 run_test 33d "openfile with 444 modes and malformed flags under remote dir"
3011 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
3015 $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
3016 $LFS setdirstripe -i1 -c2 $DIR/$tdir/striped_dir1
3017 mkdir $DIR/$tdir/local_dir
3019 local s0_mode=$(stat -c%f $DIR/$tdir/striped_dir)
3020 local s1_mode=$(stat -c%f $DIR/$tdir/striped_dir1)
3021 local l_mode=$(stat -c%f $DIR/$tdir/local_dir)
3023 [ "$l_mode" = "$s0_mode" -a "$l_mode" = "$s1_mode" ] ||
3024 error "mkdir $l_mode striped0 $s0_mode striped1 $s1_mode"
3026 rmdir $DIR/$tdir/* || error "rmdir failed"
3029 $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
3030 $LFS setdirstripe -i1 -c2 $DIR/$tdir/striped_dir1
3031 mkdir $DIR/$tdir/local_dir
3033 s0_mode=$(stat -c%f $DIR/$tdir/striped_dir)
3034 s1_mode=$(stat -c%f $DIR/$tdir/striped_dir1)
3035 l_mode=$(stat -c%f $DIR/$tdir/local_dir)
3037 [ "$l_mode" = "$s0_mode" -a "$l_mode" = "$s1_mode" ] ||
3038 error "mkdir $l_mode striped0 $s0_mode striped1 $s1_mode 777"
3040 rmdir $DIR/$tdir/* || error "rmdir(umask 777) failed"
3043 $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
3044 $LFS setdirstripe -i1 -c2 $DIR/$tdir/striped_dir1
3045 mkdir $DIR/$tdir/local_dir
3047 s0_mode=$(stat -c%f $DIR/$tdir/striped_dir)
3048 s1_mode=$(stat -c%f $DIR/$tdir/striped_dir1)
3049 l_mode=$(stat -c%f $DIR/$tdir/local_dir)
3051 [ "$l_mode" = "$s0_mode" -a "$l_mode" = "$s1_mode" ] ||
3052 error "mkdir $l_mode striped0 $s0_mode striped1 $s1_mode 0"
3054 run_test 33e "mkdir and striped directory should have same mode"
3058 do_facet $SINGLEMDS $LCTL set_param mdt.*.enable_remote_dir_gid=0
3062 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
3063 remote_mds_nodsh && skip "remote MDS with nodsh"
3066 chmod go+rwx $DIR/$tdir
3067 do_facet $SINGLEMDS $LCTL set_param mdt.*.enable_remote_dir_gid=-1
3068 trap cleanup_33f EXIT
3070 $RUNAS lfs mkdir -i 0 -c$MDSCOUNT $DIR/$tdir/striped_dir ||
3071 error "cannot create striped directory"
3073 $RUNAS touch $DIR/$tdir/striped_dir/{0..16} ||
3074 error "cannot create files in striped directory"
3076 $RUNAS rm $DIR/$tdir/striped_dir/{0..16} ||
3077 error "cannot remove files in striped directory"
3079 $RUNAS rmdir $DIR/$tdir/striped_dir ||
3080 error "cannot remove striped directory"
3084 run_test 33f "nonroot user can create, access, and remove a striped directory"
3087 mkdir -p $DIR/$tdir/dir2
3089 local err=$($RUNAS mkdir $DIR/$tdir/dir2 2>&1)
3091 [[ $err =~ "exists" ]] || error "Not exists error"
3093 run_test 33g "nonroot user create already existing root created file"
3095 TEST_34_SIZE=${TEST_34_SIZE:-2000000000000}
3098 $MCREATE $DIR/f34 || error "mcreate failed"
3099 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" ||
3100 error "getstripe failed"
3101 $TRUNCATE $DIR/f34 $TEST_34_SIZE || error "truncate failed"
3102 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" ||
3103 error "getstripe failed"
3104 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 ||
3105 error "Size of $DIR/f34 not equal to $TEST_34_SIZE bytes"
3107 run_test 34a "truncate file that has not been opened ==========="
3110 [ ! -f $DIR/f34 ] && test_34a
3111 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 ||
3112 error "Size of $DIR/f34 not equal to $TEST_34_SIZE bytes"
3113 $OPENFILE -f O_RDONLY $DIR/f34
3114 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" ||
3115 error "getstripe failed"
3116 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 ||
3117 error "Size of $DIR/f34 not equal to $TEST_34_SIZE bytes"
3119 run_test 34b "O_RDONLY opening file doesn't create objects ====="
3122 [ ! -f $DIR/f34 ] && test_34a
3123 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 ||
3124 error "Size of $DIR/f34 not equal to $TEST_34_SIZE bytes"
3125 $OPENFILE -f O_RDWR $DIR/f34
3126 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" && error
3127 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 ||
3128 error "Size of $DIR/f34 not equal to $TEST_34_SIZE bytes"
3130 run_test 34c "O_RDWR opening file-with-size works =============="
3133 [ ! -f $DIR/f34 ] && test_34a
3134 dd if=/dev/zero of=$DIR/f34 conv=notrunc bs=4k count=1 ||
3136 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 ||
3137 error "Size of $DIR/f34 not equal to $TEST_34_SIZE bytes"
3140 run_test 34d "write to sparse file ============================="
3144 $MCREATE $DIR/f34e || error "mcreate failed"
3145 $TRUNCATE $DIR/f34e 1000 || error "truncate failed"
3146 $CHECKSTAT -s 1000 $DIR/f34e ||
3147 error "Size of $DIR/f34e not equal to 1000 bytes"
3148 $OPENFILE -f O_RDWR $DIR/f34e
3149 $CHECKSTAT -s 1000 $DIR/f34e ||
3150 error "Size of $DIR/f34e not equal to 1000 bytes"
3152 run_test 34e "create objects, some with size and some without =="
3154 test_34f() { # bug 6242, 6243
3155 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3159 $MCREATE $DIR/f34f || error "mcreate failed"
3160 $TRUNCATE $DIR/f34f $SIZE34F || error "truncating $DIR/f3f to $SIZE34F"
3161 dd if=$DIR/f34f of=$TMP/f34f
3162 $CHECKSTAT -s $SIZE34F $TMP/f34f || error "$TMP/f34f not $SIZE34F bytes"
3163 dd if=/dev/zero of=$TMP/f34fzero bs=$SIZE34F count=1
3164 cmp $DIR/f34f $TMP/f34fzero || error "$DIR/f34f not all zero"
3165 cmp $TMP/f34f $TMP/f34fzero || error "$TMP/f34f not all zero"
3166 rm $TMP/f34f $TMP/f34fzero $DIR/f34f
3168 run_test 34f "read from a file with no objects until EOF ======="
3171 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3173 dd if=/dev/zero of=$DIR/$tfile bs=1 count=100 seek=$TEST_34_SIZE ||
3175 $TRUNCATE $DIR/$tfile $((TEST_34_SIZE / 2))|| error "truncate failed"
3176 $CHECKSTAT -s $((TEST_34_SIZE / 2)) $DIR/$tfile ||
3177 error "Size of $DIR/$tfile not equal to $((TEST_34_SIZE / 2))"
3178 cancel_lru_locks osc
3179 $CHECKSTAT -s $((TEST_34_SIZE / 2)) $DIR/$tfile ||
3180 error "wrong size after lock cancel"
3182 $TRUNCATE $DIR/$tfile $TEST_34_SIZE || error "truncate failed"
3183 $CHECKSTAT -s $TEST_34_SIZE $DIR/$tfile ||
3184 error "expanding truncate failed"
3185 cancel_lru_locks osc
3186 $CHECKSTAT -s $TEST_34_SIZE $DIR/$tfile ||
3187 error "wrong expanded size after lock cancel"
3189 run_test 34g "truncate long file ==============================="
3192 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3197 dd if=/dev/zero of=$DIR/$tfile bs=1M count=10 || error "dd failed"
3198 sync # Flush the cache so that multiop below does not block on cache
3199 # flush when getting the group lock
3200 $MULTIOP $DIR/$tfile OG${gid}T${sz}g${gid}c &
3203 # Since just timed wait is not good enough, let's do a sync write
3204 # that way we are sure enough time for a roundtrip + processing
3205 # passed + 2 seconds of extra margin.
3206 dd if=/dev/zero of=$DIR/${tfile}-1 bs=$PAGE_SIZE oflag=direct count=1
3210 if [[ `ps h -o comm -p $MULTIPID` == "multiop" ]]; then
3211 error "Multiop blocked on ftruncate, pid=$MULTIPID"
3215 local nsz=`stat -c %s $DIR/$tfile`
3216 [[ $nsz == $sz ]] || error "New size wrong $nsz != $sz"
3218 run_test 34h "ftruncate file under grouplock should not block"
3221 cp /bin/sh $DIR/f35a
3223 chown $RUNAS_ID $DIR/f35a
3224 $RUNAS $DIR/f35a && error || true
3227 run_test 35a "exec file with mode 444 (should return and not leak)"
3231 utime $DIR/f36 || error "utime failed for MDS"
3233 run_test 36a "MDS utime check (mknod, utime)"
3237 utime $DIR/f36 || error "utime failed for OST"
3239 run_test 36b "OST utime check (open, utime)"
3244 chown $RUNAS_ID $DIR/d36
3245 $RUNAS utime $DIR/d36/f36 || error "utime failed for MDS as non-root"
3247 run_test 36c "non-root MDS utime check (mknod, utime)"
3250 [ ! -d $DIR/d36 ] && test_36c
3251 echo "" > $DIR/d36/f36
3252 $RUNAS utime $DIR/d36/f36 || error "utime failed for OST as non-root"
3254 run_test 36d "non-root OST utime check (open, utime)"
3257 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID -- skipping"
3259 test_mkdir $DIR/$tdir
3260 touch $DIR/$tdir/$tfile
3261 $RUNAS utime $DIR/$tdir/$tfile &&
3262 error "utime worked, expected failure" || true
3264 run_test 36e "utime on non-owned file (should return error)"
3268 local LANG_SAVE=$LANG
3269 local LC_LANG_SAVE=$LC_LANG
3270 export LANG=C LC_LANG=C # for date language
3272 DATESTR="Dec 20 2000"
3273 test_mkdir $DIR/$tdir
3274 lctl set_param fail_loc=$fl
3276 cp /etc/hosts $DIR/$tdir/$tfile
3277 sync & # write RPC generated with "current" inode timestamp, but delayed
3279 touch --date="$DATESTR" $DIR/$tdir/$tfile # setattr timestamp in past
3280 LS_BEFORE="`ls -l $DIR/$tdir/$tfile`" # old timestamp from client cache
3281 cancel_lru_locks osc
3282 LS_AFTER="`ls -l $DIR/$tdir/$tfile`" # timestamp from OST object
3284 [ "$LS_BEFORE" != "$LS_AFTER" ] && \
3285 echo "BEFORE: $LS_BEFORE" && \
3286 echo "AFTER : $LS_AFTER" && \
3287 echo "WANT : $DATESTR" && \
3288 error "$DIR/$tdir/$tfile timestamps changed" || true
3290 export LANG=$LANG_SAVE LC_LANG=$LC_LANG_SAVE
3294 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3296 #define OBD_FAIL_OST_BRW_PAUSE_BULK 0x214
3297 subr_36fh "0x80000214"
3299 run_test 36f "utime on file racing with OST BRW write =========="
3302 remote_ost_nodsh && skip "remote OST with nodsh"
3303 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3309 test_mkdir $DIR/$tdir
3310 fmd_max_age=$(do_facet ost1 \
3311 "lctl get_param -n obdfilter.*.client_cache_seconds 2> /dev/null | \
3314 fmd_before=$(do_facet ost1 \
3315 "awk '/ll_fmd_cache/ {print \\\$2}' /proc/slabinfo")
3316 touch $DIR/$tdir/$tfile
3317 sleep $((fmd_max_age + 12))
3318 fmd_after=$(do_facet ost1 \
3319 "awk '/ll_fmd_cache/ {print \\\$2}' /proc/slabinfo")
3321 echo "fmd_before: $fmd_before"
3322 echo "fmd_after: $fmd_after"
3323 [[ $fmd_after -gt $fmd_before ]] &&
3324 echo "AFTER: $fmd_after > BEFORE: $fmd_before" &&
3325 error "fmd didn't expire after ping" || true
3327 run_test 36g "filter mod data cache expiry ====================="
3330 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3332 #define OBD_FAIL_OST_BRW_PAUSE_BULK2 0x227
3333 subr_36fh "0x80000227"
3335 run_test 36h "utime on file racing with OST BRW write =========="
3338 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
3340 test_mkdir $DIR/$tdir
3341 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR/$tdir/striped_dir
3343 local mtime=$(stat -c%Y $DIR/$tdir/striped_dir)
3344 local new_mtime=$((mtime + 200))
3346 #change Modify time of striped dir
3347 touch -m -d @$new_mtime $DIR/$tdir/striped_dir ||
3348 error "change mtime failed"
3350 local got=$(stat -c%Y $DIR/$tdir/striped_dir)
3352 [ "$new_mtime" = "$got" ] || error "expect $new_mtime got $got"
3354 run_test 36i "change mtime on striped directory"
3356 # test_37 - duplicate with tests 32q 32r
3359 local file=$DIR/$tfile
3361 openfile -f O_DIRECTORY $file
3364 [ $RC -eq 0 ] && error "opened file $file with O_DIRECTORY" || true
3365 [ $RC -eq $ENOTDIR ] || error "error $RC should be ENOTDIR ($ENOTDIR)"
3367 run_test 38 "open a regular file with O_DIRECTORY should return -ENOTDIR ==="
3369 test_39a() { # was test_39
3371 touch $DIR/${tfile}2
3372 # ls -l $DIR/$tfile $DIR/${tfile}2
3373 # ls -lu $DIR/$tfile $DIR/${tfile}2
3374 # ls -lc $DIR/$tfile $DIR/${tfile}2
3376 $OPENFILE -f O_CREAT:O_TRUNC:O_WRONLY $DIR/${tfile}2
3377 if [ ! $DIR/${tfile}2 -nt $DIR/$tfile ]; then
3379 ls -l --full-time $DIR/$tfile $DIR/${tfile}2
3381 ls -lu --full-time $DIR/$tfile $DIR/${tfile}2
3383 ls -lc --full-time $DIR/$tfile $DIR/${tfile}2
3384 error "O_TRUNC didn't change timestamps"
3387 run_test 39a "mtime changed on create"
3390 test_mkdir -c1 $DIR/$tdir
3391 cp -p /etc/passwd $DIR/$tdir/fopen
3392 cp -p /etc/passwd $DIR/$tdir/flink
3393 cp -p /etc/passwd $DIR/$tdir/funlink
3394 cp -p /etc/passwd $DIR/$tdir/frename
3395 ln $DIR/$tdir/funlink $DIR/$tdir/funlink2
3398 echo "aaaaaa" >> $DIR/$tdir/fopen
3399 echo "aaaaaa" >> $DIR/$tdir/flink
3400 echo "aaaaaa" >> $DIR/$tdir/funlink
3401 echo "aaaaaa" >> $DIR/$tdir/frename
3403 local open_new=`stat -c %Y $DIR/$tdir/fopen`
3404 local link_new=`stat -c %Y $DIR/$tdir/flink`
3405 local unlink_new=`stat -c %Y $DIR/$tdir/funlink`
3406 local rename_new=`stat -c %Y $DIR/$tdir/frename`
3408 cat $DIR/$tdir/fopen > /dev/null
3409 ln $DIR/$tdir/flink $DIR/$tdir/flink2
3410 rm -f $DIR/$tdir/funlink2
3411 mv -f $DIR/$tdir/frename $DIR/$tdir/frename2
3413 for (( i=0; i < 2; i++ )) ; do
3414 local open_new2=`stat -c %Y $DIR/$tdir/fopen`
3415 local link_new2=`stat -c %Y $DIR/$tdir/flink`
3416 local unlink_new2=`stat -c %Y $DIR/$tdir/funlink`
3417 local rename_new2=`stat -c %Y $DIR/$tdir/frename2`
3419 [ $open_new2 -eq $open_new ] || error "open file reverses mtime"
3420 [ $link_new2 -eq $link_new ] || error "link file reverses mtime"
3421 [ $unlink_new2 -eq $unlink_new ] || error "unlink file reverses mtime"
3422 [ $rename_new2 -eq $rename_new ] || error "rename file reverses mtime"
3424 cancel_lru_locks osc
3425 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3428 run_test 39b "mtime change on open, link, unlink, rename ======"
3430 # this should be set to past
3431 TEST_39_MTIME=`date -d "1 year ago" +%s`
3437 local mtime0=`stat -c %Y $DIR1/$tfile`
3439 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3440 local mtime1=`stat -c %Y $DIR1/$tfile`
3441 [ "$mtime1" = $TEST_39_MTIME ] || \
3442 error "mtime is not set to past: $mtime1, should be $TEST_39_MTIME"
3445 echo hello >> $DIR1/$tfile
3447 local mtime2=`stat -c %Y $DIR1/$tfile`
3448 [ "$mtime2" -ge "$d1" ] && [ "$mtime2" -le "$d2" ] || \
3449 error "mtime is not updated on write: $d1 <= $mtime2 <= $d2"
3451 mv $DIR1/$tfile $DIR1/$tfile-1
3453 for (( i=0; i < 2; i++ )) ; do
3454 local mtime3=`stat -c %Y $DIR1/$tfile-1`
3455 [ "$mtime2" = "$mtime3" ] || \
3456 error "mtime ($mtime2) changed (to $mtime3) on rename"
3458 cancel_lru_locks osc
3459 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3462 run_test 39c "mtime change on rename ==========================="
3466 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3469 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3471 for (( i=0; i < 2; i++ )) ; do
3472 local mtime=`stat -c %Y $DIR1/$tfile`
3473 [ $mtime = $TEST_39_MTIME ] || \
3474 error "mtime($mtime) is not set to $TEST_39_MTIME"
3476 cancel_lru_locks osc
3477 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3480 run_test 39d "create, utime, stat =============================="
3484 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3487 local mtime1=`stat -c %Y $DIR1/$tfile`
3489 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3491 for (( i=0; i < 2; i++ )) ; do
3492 local mtime2=`stat -c %Y $DIR1/$tfile`
3493 [ $mtime2 = $TEST_39_MTIME ] || \
3494 error "mtime($mtime2) is not set to $TEST_39_MTIME"
3496 cancel_lru_locks osc
3497 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3500 run_test 39e "create, stat, utime, stat ========================"
3504 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3507 mtime1=`stat -c %Y $DIR1/$tfile`
3510 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3512 for (( i=0; i < 2; i++ )) ; do
3513 local mtime2=`stat -c %Y $DIR1/$tfile`
3514 [ $mtime2 = $TEST_39_MTIME ] || \
3515 error "mtime($mtime2) is not set to $TEST_39_MTIME"
3517 cancel_lru_locks osc
3518 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3521 run_test 39f "create, stat, sleep, utime, stat ================="
3525 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3527 echo hello >> $DIR1/$tfile
3528 local mtime1=`stat -c %Y $DIR1/$tfile`
3531 chmod o+r $DIR1/$tfile
3533 for (( i=0; i < 2; i++ )) ; do
3534 local mtime2=`stat -c %Y $DIR1/$tfile`
3535 [ "$mtime1" = "$mtime2" ] || \
3536 error "lost mtime: $mtime2, should be $mtime1"
3538 cancel_lru_locks osc
3539 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3542 run_test 39g "write, chmod, stat ==============================="
3546 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3552 echo hello >> $DIR1/$tfile
3553 local mtime1=`stat -c %Y $DIR1/$tfile`
3555 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3557 if [ "$d1" != "$d2" ]; then
3558 echo "write and touch not within one second"
3560 for (( i=0; i < 2; i++ )) ; do
3561 local mtime2=`stat -c %Y $DIR1/$tfile`
3562 [ "$mtime2" = $TEST_39_MTIME ] || \
3563 error "lost mtime: $mtime2, should be $TEST_39_MTIME"
3565 cancel_lru_locks osc
3566 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3570 run_test 39h "write, utime within one second, stat ============="
3573 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3578 echo hello >> $DIR1/$tfile
3579 local mtime1=`stat -c %Y $DIR1/$tfile`
3581 mv $DIR1/$tfile $DIR1/$tfile-1
3583 for (( i=0; i < 2; i++ )) ; do
3584 local mtime2=`stat -c %Y $DIR1/$tfile-1`
3586 [ "$mtime1" = "$mtime2" ] || \
3587 error "lost mtime: $mtime2, should be $mtime1"
3589 cancel_lru_locks osc
3590 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3593 run_test 39i "write, rename, stat =============================="
3596 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3598 start_full_debug_logging
3602 #define OBD_FAIL_OSC_DELAY_SETTIME 0x412
3603 lctl set_param fail_loc=0x80000412
3604 multiop_bg_pause $DIR1/$tfile oO_RDWR:w2097152_c ||
3605 error "multiop failed"
3607 local mtime1=`stat -c %Y $DIR1/$tfile`
3609 mv $DIR1/$tfile $DIR1/$tfile-1
3611 kill -USR1 $multipid
3612 wait $multipid || error "multiop close failed"
3614 for (( i=0; i < 2; i++ )) ; do
3615 local mtime2=`stat -c %Y $DIR1/$tfile-1`
3616 [ "$mtime1" = "$mtime2" ] ||
3617 error "mtime is lost on close: $mtime2, " \
3620 cancel_lru_locks osc
3621 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3623 lctl set_param fail_loc=0
3624 stop_full_debug_logging
3626 run_test 39j "write, rename, close, stat ======================="
3629 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3634 multiop_bg_pause $DIR1/$tfile oO_RDWR:w2097152_c || error "multiop failed"
3636 local mtime1=`stat -c %Y $DIR1/$tfile`
3638 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3640 kill -USR1 $multipid
3641 wait $multipid || error "multiop close failed"
3643 for (( i=0; i < 2; i++ )) ; do
3644 local mtime2=`stat -c %Y $DIR1/$tfile`
3646 [ "$mtime2" = $TEST_39_MTIME ] || \
3647 error "mtime is lost on close: $mtime2, should be $TEST_39_MTIME"
3649 cancel_lru_locks osc
3650 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3653 run_test 39k "write, utime, close, stat ========================"
3655 # this should be set to future
3656 TEST_39_ATIME=`date -d "1 year" +%s`
3659 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3660 remote_mds_nodsh && skip "remote MDS with nodsh"
3662 local atime_diff=$(do_facet $SINGLEMDS \
3663 lctl get_param -n mdd.*MDT0000*.atime_diff)
3667 # test setting directory atime to future
3668 touch -a -d @$TEST_39_ATIME $DIR/$tdir
3669 local atime=$(stat -c %X $DIR/$tdir)
3670 [ "$atime" = $TEST_39_ATIME ] ||
3671 error "atime is not set to future: $atime, $TEST_39_ATIME"
3673 # test setting directory atime from future to now
3674 local now=$(date +%s)
3675 touch -a -d @$now $DIR/$tdir
3677 atime=$(stat -c %X $DIR/$tdir)
3678 [ "$atime" -eq "$now" ] ||
3679 error "atime is not updated from future: $atime, $now"
3681 do_facet $SINGLEMDS lctl set_param -n mdd.*MDT0000*.atime_diff=2
3684 # test setting directory atime when now > dir atime + atime_diff
3685 local d1=$(date +%s)
3687 local d2=$(date +%s)
3688 cancel_lru_locks mdc
3689 atime=$(stat -c %X $DIR/$tdir)
3690 [ "$atime" -ge "$d1" -a "$atime" -le "$d2" ] ||
3691 error "atime is not updated : $atime, should be $d2"
3693 do_facet $SINGLEMDS lctl set_param -n mdd.*MDT0000*.atime_diff=60
3696 # test not setting directory atime when now < dir atime + atime_diff
3698 cancel_lru_locks mdc
3699 atime=$(stat -c %X $DIR/$tdir)
3700 [ "$atime" -ge "$d1" -a "$atime" -le "$d2" ] ||
3701 error "atime is updated to $atime, should remain $d1<atime<$d2"
3703 do_facet $SINGLEMDS \
3704 lctl set_param -n mdd.*MDT0000*.atime_diff=$atime_diff
3706 run_test 39l "directory atime update ==========================="
3709 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3713 local far_past_mtime=$(date -d "May 29 1953" +%s)
3714 local far_past_atime=$(date -d "Dec 17 1903" +%s)
3716 touch -m -d @$far_past_mtime $DIR1/$tfile
3717 touch -a -d @$far_past_atime $DIR1/$tfile
3719 for (( i=0; i < 2; i++ )) ; do
3720 local timestamps=$(stat -c "%X %Y" $DIR1/$tfile)
3721 [ "$timestamps" = "$far_past_atime $far_past_mtime" ] || \
3722 error "atime or mtime set incorrectly"
3724 cancel_lru_locks osc
3725 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3728 run_test 39m "test atime and mtime before 1970"
3730 test_39n() { # LU-3832
3731 remote_mds_nodsh && skip "remote MDS with nodsh"
3733 local atime_diff=$(do_facet $SINGLEMDS \
3734 lctl get_param -n mdd.*MDT0000*.atime_diff)
3739 do_facet $SINGLEMDS lctl set_param -n mdd.*MDT0000*.atime_diff=1
3742 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 status=noxfer
3743 atime0=$(stat -c %X $DIR/$tfile)
3746 $MULTIOP $DIR/$tfile oO_RDONLY:O_NOATIME:r4096c
3747 atime1=$(stat -c %X $DIR/$tfile)
3750 cancel_lru_locks mdc
3751 cancel_lru_locks osc
3752 $MULTIOP $DIR/$tfile oO_RDONLY:O_NOATIME:r4096c
3753 atime2=$(stat -c %X $DIR/$tfile)
3755 do_facet $SINGLEMDS \
3756 lctl set_param -n mdd.*MDT0000*.atime_diff=$atime_diff
3758 [ "$atime0" -eq "$atime1" ] || error "atime0 $atime0 != atime1 $atime1"
3759 [ "$atime1" -eq "$atime2" ] || error "atime0 $atime0 != atime1 $atime1"
3761 run_test 39n "check that O_NOATIME is honored"
3764 TESTDIR=$DIR/$tdir/$tfile
3765 [ -e $TESTDIR ] && rm -rf $TESTDIR
3772 links2=$(stat -c %h .)
3773 [ $(($links1 + 2)) != $links2 ] &&
3774 error "wrong links count $(($links1 + 2)) != $links2"
3776 links3=$(stat -c %h .)
3777 [ $(($links1 + 1)) != $links3 ] &&
3778 error "wrong links count $links1 != $links3"
3781 run_test 39o "directory cached attributes updated after create"
3784 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
3787 TESTDIR=$DIR/$tdir/$tdir
3788 [ -e $TESTDIR ] && rm -rf $TESTDIR
3789 test_mkdir -p $TESTDIR
3793 test_mkdir -i $MDTIDX $TESTDIR/remote_dir1
3794 test_mkdir -i $MDTIDX $TESTDIR/remote_dir2
3796 links2=$(stat -c %h .)
3797 [ $(($links1 + 2)) != $links2 ] &&
3798 error "wrong links count $(($links1 + 2)) != $links2"
3800 links3=$(stat -c %h .)
3801 [ $(($links1 + 1)) != $links3 ] &&
3802 error "wrong links count $links1 != $links3"
3805 run_test 39p "remote directory cached attributes updated after create ========"
3808 test_39q() { # LU-8041
3809 local testdir=$DIR/$tdir
3811 multiop_bg_pause $testdir D_c || error "multiop failed"
3813 cancel_lru_locks mdc
3814 kill -USR1 $multipid
3815 local atime=$(stat -c %X $testdir)
3816 [ "$atime" -ne 0 ] || error "atime is zero"
3818 run_test 39q "close won't zero out atime"
3821 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1
3822 $RUNAS $OPENFILE -f O_WRONLY:O_TRUNC $DIR/$tfile &&
3823 error "openfile O_WRONLY:O_TRUNC $tfile failed"
3824 $CHECKSTAT -t file -s 4096 $DIR/$tfile ||
3825 error "$tfile is not 4096 bytes in size"
3827 run_test 40 "failed open(O_TRUNC) doesn't truncate ============="
3831 small_write $DIR/f41 18
3833 run_test 41 "test small file write + fstat ====================="
3835 count_ost_writes() {
3836 lctl get_param -n ${OSC}.*.stats |
3837 awk -vwrites=0 '/ost_write/ { writes += $2 } \
3838 END { printf("%0.0f", writes) }'
3845 BG_DIRTY_RATIO_SAVE=10
3846 MAX_BG_DIRTY_RATIO=25
3850 # in 2.6, restore /proc/sys/vm/dirty_writeback_centisecs,
3851 # dirty_ratio, dirty_background_ratio
3852 if [ -f /proc/sys/vm/dirty_writeback_centisecs ]; then
3853 sysctl -w vm.dirty_writeback_centisecs=$WRITEBACK_SAVE
3854 sysctl -w vm.dirty_background_ratio=$BG_DIRTY_RATIO_SAVE
3855 sysctl -w vm.dirty_ratio=$DIRTY_RATIO_SAVE
3857 # if file not here, we are a 2.4 kernel
3858 kill -CONT `pidof kupdated`
3863 # setup the trap first, so someone cannot exit the test at the
3864 # exact wrong time and mess up a machine
3865 trap start_writeback EXIT
3866 # in 2.6, save and 0 /proc/sys/vm/dirty_writeback_centisecs
3867 if [ -f /proc/sys/vm/dirty_writeback_centisecs ]; then
3868 WRITEBACK_SAVE=`sysctl -n vm.dirty_writeback_centisecs`
3869 sysctl -w vm.dirty_writeback_centisecs=0
3870 sysctl -w vm.dirty_writeback_centisecs=0
3871 # save and increase /proc/sys/vm/dirty_ratio
3872 DIRTY_RATIO_SAVE=`sysctl -n vm.dirty_ratio`
3873 sysctl -w vm.dirty_ratio=$MAX_DIRTY_RATIO
3874 # save and increase /proc/sys/vm/dirty_background_ratio
3875 BG_DIRTY_RATIO_SAVE=`sysctl -n vm.dirty_background_ratio`
3876 sysctl -w vm.dirty_background_ratio=$MAX_BG_DIRTY_RATIO
3878 # if file not here, we are a 2.4 kernel
3879 kill -STOP `pidof kupdated`
3883 # ensure that all stripes have some grant before we test client-side cache
3885 for i in `seq -f $DIR/f42-%g 1 $OSTCOUNT`; do
3886 dd if=/dev/zero of=$i bs=4k count=1
3891 # Tests 42* verify that our behaviour is correct WRT caching, file closure,
3892 # file truncation, and file removal.
3894 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3897 cancel_lru_locks $OSC
3899 sync; sleep 1; sync # just to be safe
3900 BEFOREWRITES=`count_ost_writes`
3901 lctl get_param -n osc.*[oO][sS][cC][_-]*.cur_grant_bytes | grep "[0-9]"
3902 dd if=/dev/zero of=$DIR/f42a bs=1024 count=100
3903 AFTERWRITES=`count_ost_writes`
3904 [ $BEFOREWRITES -eq $AFTERWRITES ] || \
3905 error "$BEFOREWRITES < $AFTERWRITES"
3908 run_test 42a "ensure that we don't flush on close"
3911 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3914 cancel_lru_locks $OSC
3917 dd if=/dev/zero of=$DIR/f42b bs=1024 count=100
3918 BEFOREWRITES=$(count_ost_writes)
3919 $MUNLINK $DIR/f42b || error "$MUNLINK $DIR/f42b: $?"
3920 AFTERWRITES=$(count_ost_writes)
3921 if [[ $BEFOREWRITES -lt $AFTERWRITES ]]; then
3922 error "$BEFOREWRITES < $AFTERWRITES on unlink"
3924 BEFOREWRITES=$(count_ost_writes)
3925 sync || error "sync: $?"
3926 AFTERWRITES=$(count_ost_writes)
3927 if [[ $BEFOREWRITES -lt $AFTERWRITES ]]; then
3928 error "$BEFOREWRITES < $AFTERWRITES on sync"
3930 dmesg | grep 'error from obd_brw_async' && error 'error writing back'
3934 run_test 42b "test destroy of file with cached dirty data ======"
3936 # if these tests just want to test the effect of truncation,
3937 # they have to be very careful. consider:
3938 # - the first open gets a {0,EOF}PR lock
3939 # - the first write conflicts and gets a {0, count-1}PW
3940 # - the rest of the writes are under {count,EOF}PW
3941 # - the open for truncate tries to match a {0,EOF}PR
3942 # for the filesize and cancels the PWs.
3943 # any number of fixes (don't get {0,EOF} on open, match
3944 # composite locks, do smarter file size management) fix
3945 # this, but for now we want these tests to verify that
3946 # the cancellation with truncate intent works, so we
3947 # start the file with a full-file pw lock to match against
3948 # until the truncate.
3953 cancel_lru_locks $OSC