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
12 ALWAYS_EXCEPT="$SANITY_EXCEPT 42a 42b 42c"
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 64d"
26 # skip the grant tests for ARM until they are fixed
27 if [[ $(uname -m) = aarch64 ]]; then
28 # bug number: LU-11596 (all below)
29 ALWAYS_EXCEPT+=" $GRANT_CHECK_LIST"
30 # bug number: LU-11671 LU-11594 LU-11667 LU-11729
31 ALWAYS_EXCEPT+=" 45 103a 317 810"
34 SRCDIR=$(cd $(dirname $0); echo $PWD)
35 export PATH=$PATH:/sbin
41 CHECKSTAT=${CHECKSTAT:-"checkstat -v"}
42 CREATETEST=${CREATETEST:-createtest}
44 LVERIFY=${LVERIFY:-ll_dirstripe_verify}
46 OPENFILE=${OPENFILE:-openfile}
47 OPENUNLINK=${OPENUNLINK:-openunlink}
48 export MULTIOP=${MULTIOP:-multiop}
49 READS=${READS:-"reads"}
50 MUNLINK=${MUNLINK:-munlink}
51 SOCKETSERVER=${SOCKETSERVER:-socketserver}
52 SOCKETCLIENT=${SOCKETCLIENT:-socketclient}
53 MEMHOG=${MEMHOG:-memhog}
54 DIRECTIO=${DIRECTIO:-directio}
55 ACCEPTOR_PORT=${ACCEPTOR_PORT:-988}
57 CHECK_GRANT=${CHECK_GRANT:-"yes"}
58 GRANT_CHECK_LIST=${GRANT_CHECK_LIST:-""}
59 export PARALLEL=${PARALLEL:-"no"}
61 export NAME=${NAME:-local}
68 LUSTRE=${LUSTRE:-$(cd $(dirname $0)/..; echo $PWD)}
69 LUSTRE_TESTS_API_DIR=${LUSTRE_TESTS_API_DIR:-${LUSTRE}/tests/clientapi}
70 . $LUSTRE/tests/test-framework.sh
72 . ${CONFIG:=$LUSTRE/tests/cfg/${NAME}.sh}
77 [ "$SLOW" = "no" ] && EXCEPT_SLOW="27m 64b 68 71 115 300o"
79 if [ "$mds1_FSTYPE" = "zfs" ]; then
80 # bug number for skipped test: LU-1957
81 ALWAYS_EXCEPT="$ALWAYS_EXCEPT 180"
83 [ "$SLOW" = "no" ] && EXCEPT_SLOW="$EXCEPT_SLOW 51b"
86 # Get the SLES distro version
88 # Returns a version string that should only be used in comparing
89 # strings returned by version_code()
92 local version=$(grep VERSION_ID /etc/os-release | cut -d'"' -f2)
94 # All SuSE Linux versions have one decimal. version_code expects two
95 local sles_version=$version.0
96 version_code $sles_version
99 # Check if we are running on Ubuntu or SLES so we can make decisions on
101 if [ -r /etc/SuSE-release ]; then
102 sles_version=$(sles_version_code)
103 [ $sles_version -lt $(version_code 11.4.0) ] &&
104 # bug number for skipped test: LU-4341
105 ALWAYS_EXCEPT="$ALWAYS_EXCEPT 170"
106 [ $sles_version -lt $(version_code 12.0.0) ] &&
107 # bug number for skipped test: LU-3703
108 ALWAYS_EXCEPT="$ALWAYS_EXCEPT 234"
109 elif [ -r /etc/os-release ]; then
110 if grep -qi ubuntu /etc/os-release; then
111 ubuntu_version=$(version_code $(sed -n -e 's/"//g' \
112 -e 's/^VERSION=//p' \
116 if [[ $ubuntu_version -gt $(version_code 16.0.0) ]]; then
117 # bug number for skipped test:
119 ALWAYS_EXCEPT+=" 103a 410"
128 pgrep ll_sa > /dev/null && { echo "There are ll_sa thread not exit!"; exit 20; }
129 cleanupall ${FORCE} $* || { echo "FAILed to clean up"; exit 20; }
138 check_swap_layouts_support()
140 $LCTL get_param -n llite.*.sbi_flags | grep -q layout ||
141 skip "Does not support layout lock."
144 check_and_setup_lustre
148 MAXFREE=${MAXFREE:-$((200000 * $OSTCOUNT))}
150 [ -f $DIR/d52a/foo ] && chattr -a $DIR/d52a/foo
151 [ -f $DIR/d52b/foo ] && chattr -i $DIR/d52b/foo
152 rm -rf $DIR/[Rdfs][0-9]*
154 # $RUNAS_ID may get set incorrectly somewhere else
155 [ $UID -eq 0 -a $RUNAS_ID -eq 0 ] &&
156 error "\$RUNAS_ID set to 0, but \$UID is also 0!"
158 check_runas_id $RUNAS_ID $RUNAS_GID $RUNAS
162 if [ "${ONLY}" = "MOUNT" ] ; then
163 echo "Lustre is up, please go on"
167 echo "preparing for tests involving mounts"
168 EXT2_DEV=${EXT2_DEV:-$TMP/SANITY.LOOP}
170 mke2fs -j -F $EXT2_DEV 8000 > /dev/null
171 echo # add a newline after mke2fs.
175 OLDDEBUG=$(lctl get_param -n debug 2> /dev/null)
176 lctl set_param debug=-1 2> /dev/null || true
179 $CHECKSTAT -t file $DIR/$tfile || error "$tfile is not a file"
181 $CHECKSTAT -a $DIR/$tfile || error "$tfile was not removed"
183 run_test 0a "touch; rm ====================="
186 chmod 0755 $DIR || error "chmod 0755 $DIR failed"
187 $CHECKSTAT -p 0755 $DIR || error "$DIR permission is not 0755"
189 run_test 0b "chmod 0755 $DIR ============================="
192 $LCTL get_param mdc.*.import | grep "state: FULL" ||
193 error "import not FULL"
194 $LCTL get_param mdc.*.import | grep "target: $FSNAME-MDT" ||
197 run_test 0c "check import proc"
199 test_0d() { # LU-3397
200 [ $MGS_VERSION -lt $(version_code 2.10.57) ] &&
201 skip "proc exports not supported before 2.10.57"
203 local mgs_exp="mgs.MGS.exports"
204 local client_uuid=$($LCTL get_param -n mgc.*.uuid)
206 local exp_client_version
209 local temp_imp=$DIR/$tfile.import
210 local temp_exp=$DIR/$tfile.export
212 # save mgc import file to $temp_imp
213 $LCTL get_param mgc.*.import | tee $temp_imp
214 # Check if client uuid is found in MGS export
215 for exp_client_nid in $(do_facet mgs $LCTL get_param -N $mgs_exp.*); do
216 [ $(do_facet mgs $LCTL get_param -n $exp_client_nid.uuid) == \
220 # save mgs export file to $temp_exp
221 do_facet mgs $LCTL get_param $exp_client_nid.export | tee $temp_exp
223 # Compare the value of field "connect_flags"
224 imp_val=$(grep "connect_flags" $temp_imp)
225 exp_val=$(grep "connect_flags" $temp_exp)
226 [ "$exp_val" == "$imp_val" ] ||
227 error "export flags '$exp_val' != import flags '$imp_val'"
229 # Compare the value of client version
230 exp_client_version=$(awk '/target_version:/ { print $2 }' $temp_exp)
231 exp_val=$(version_code $exp_client_version)
232 imp_val=$CLIENT_VERSION
233 [ "$exp_val" == "$imp_val" ] ||
234 error "export client version '$exp_val' != '$imp_val'"
236 run_test 0d "check export proc ============================="
239 test_mkdir $DIR/$tdir
240 test_mkdir $DIR/$tdir/d2
241 mkdir $DIR/$tdir/d2 && error "we expect EEXIST, but not returned"
242 $CHECKSTAT -t dir $DIR/$tdir/d2 || error "$tdir/d2 is not a dir"
245 $CHECKSTAT -a $DIR/$tdir || error "$tdir was not removed"
247 run_test 1 "mkdir; remkdir; rmdir"
250 test_mkdir $DIR/$tdir
251 touch $DIR/$tdir/$tfile || error "touch $tdir/$tfile failed"
252 $CHECKSTAT -t file $DIR/$tdir/$tfile || error "$tdir/$tfile not a file"
254 $CHECKSTAT -a $DIR/$tdir/$tfile || error "$tdir/$file is not removed"
256 run_test 2 "mkdir; touch; rmdir; check file"
259 test_mkdir $DIR/$tdir
260 $CHECKSTAT -t dir $DIR/$tdir || error "$tdir is not a directory"
261 touch $DIR/$tdir/$tfile
262 $CHECKSTAT -t file $DIR/$tdir/$tfile || error "$tdir/$tfile not a file"
264 $CHECKSTAT -a $DIR/$tdir || error "$tdir is not removed"
266 run_test 3 "mkdir; touch; rmdir; check dir"
268 # LU-4471 - failed rmdir on remote directories still removes directory on MDT0
270 test_mkdir -i 1 $DIR/$tdir
272 touch $DIR/$tdir/$tfile ||
273 error "Create file under remote directory failed"
276 error "Expect error removing in-use dir $DIR/$tdir"
278 test -d $DIR/$tdir || error "Remote directory disappeared"
280 rm -rf $DIR/$tdir || error "remove remote dir error"
282 run_test 4 "mkdir; touch dir/file; rmdir; checkdir (expect error)"
285 test_mkdir $DIR/$tdir
286 test_mkdir $DIR/$tdir/d2
287 chmod 0707 $DIR/$tdir/d2 || error "chmod 0707 $tdir/d2 failed"
288 $CHECKSTAT -t dir -p 0707 $DIR/$tdir/d2 || error "$tdir/d2 not mode 707"
289 $CHECKSTAT -t dir $DIR/$tdir/d2 || error "$tdir/d2 is not a directory"
291 run_test 5 "mkdir .../d5 .../d5/d2; chmod .../d5/d2"
294 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
295 chmod 0666 $DIR/$tfile || error "chmod 0666 $tfile failed"
296 $CHECKSTAT -t file -p 0666 -u \#$UID $DIR/$tfile ||
297 error "$tfile does not have perm 0666 or UID $UID"
298 $RUNAS chmod 0444 $DIR/$tfile && error "chmod $tfile worked on UID $UID"
299 $CHECKSTAT -t file -p 0666 -u \#$UID $DIR/$tfile ||
300 error "$tfile should be 0666 and owned by UID $UID"
302 run_test 6a "touch f6a; chmod f6a; $RUNAS chmod f6a (should return error) =="
305 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID"
308 chown $RUNAS_ID $DIR/$tfile || error "chown $RUNAS_ID $file failed"
309 $CHECKSTAT -t file -u \#$RUNAS_ID $DIR/$tfile ||
310 error "$tfile should be owned by UID $RUNAS_ID"
311 $RUNAS chown $UID $DIR/$tfile && error "chown $UID $file succeeded"
312 $CHECKSTAT -t file -u \#$RUNAS_ID $DIR/$tfile ||
313 error "$tfile should be owned by UID $RUNAS_ID"
315 run_test 6c "touch f6c; chown f6c; $RUNAS chown f6c (should return error) =="
318 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID"
321 chgrp $RUNAS_ID $DIR/$tfile || error "chgrp $RUNAS_ID $file failed"
322 $CHECKSTAT -t file -u \#$UID -g \#$RUNAS_ID $DIR/$tfile ||
323 error "$tfile should be owned by GID $UID"
324 $RUNAS chgrp $UID $DIR/$tfile && error "chgrp $UID $file succeeded"
325 $CHECKSTAT -t file -u \#$UID -g \#$RUNAS_ID $DIR/$tfile ||
326 error "$tfile should be owned by UID $UID and GID $RUNAS_ID"
328 run_test 6e "touch+chgrp $tfile; $RUNAS chgrp $tfile (should return error)"
331 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID"
333 test_mkdir $DIR/$tdir
334 chmod 777 $DIR/$tdir || error "chmod 0777 $tdir failed"
335 $RUNAS mkdir $DIR/$tdir/d || error "mkdir $tdir/d failed"
336 chmod g+s $DIR/$tdir/d || error "chmod g+s $tdir/d failed"
337 test_mkdir $DIR/$tdir/d/subdir
338 $CHECKSTAT -g \#$RUNAS_GID $DIR/$tdir/d/subdir ||
339 error "$tdir/d/subdir should be GID $RUNAS_GID"
340 if [[ $MDSCOUNT -gt 1 ]]; then
341 # check remote dir sgid inherite
342 $LFS mkdir -i 0 $DIR/$tdir.local ||
343 error "mkdir $tdir.local failed"
344 chmod g+s $DIR/$tdir.local ||
345 error "chmod $tdir.local failed"
346 chgrp $RUNAS_GID $DIR/$tdir.local ||
347 error "chgrp $tdir.local failed"
348 $LFS mkdir -i 1 $DIR/$tdir.local/$tdir.remote ||
349 error "mkdir $tdir.remote failed"
350 $CHECKSTAT -g \#$RUNAS_GID $DIR/$tdir.local/$tdir.remote ||
351 error "$tdir.remote should be owned by $UID.$RUNAS_ID"
352 $CHECKSTAT -p 02755 $DIR/$tdir.local/$tdir.remote ||
353 error "$tdir.remote should be mode 02755"
356 run_test 6g "verify new dir in sgid dir inherits group"
358 test_6h() { # bug 7331
359 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID"
361 touch $DIR/$tfile || error "touch failed"
362 chown $RUNAS_ID:$RUNAS_GID $DIR/$tfile || error "initial chown failed"
363 $RUNAS -G$RUNAS_GID chown $RUNAS_ID:0 $DIR/$tfile &&
364 error "chown $RUNAS_ID:0 $tfile worked as GID $RUNAS_GID"
365 $CHECKSTAT -t file -u \#$RUNAS_ID -g \#$RUNAS_GID $DIR/$tfile ||
366 error "$tdir/$tfile should be UID $RUNAS_UID GID $RUNAS_GID"
368 run_test 6h "$RUNAS chown RUNAS_ID.0 .../$tfile (should return error)"
371 test_mkdir $DIR/$tdir
372 $MCREATE $DIR/$tdir/$tfile
373 chmod 0666 $DIR/$tdir/$tfile
374 $CHECKSTAT -t file -p 0666 $DIR/$tdir/$tfile ||
375 error "$tdir/$tfile should be mode 0666"
377 run_test 7a "mkdir .../d7; mcreate .../d7/f; chmod .../d7/f ===="
380 if [ ! -d $DIR/$tdir ]; then
381 test_mkdir $DIR/$tdir
383 $MCREATE $DIR/$tdir/$tfile
384 echo -n foo > $DIR/$tdir/$tfile
385 [ "$(cat $DIR/$tdir/$tfile)" = "foo" ] || error "$tdir/$tfile not 'foo'"
386 $CHECKSTAT -t file -s 3 $DIR/$tdir/$tfile || error "$tfile size not 3"
388 run_test 7b "mkdir .../d7; mcreate d7/f2; echo foo > d7/f2 ====="
391 test_mkdir $DIR/$tdir
392 touch $DIR/$tdir/$tfile
393 chmod 0666 $DIR/$tdir/$tfile
394 $CHECKSTAT -t file -p 0666 $DIR/$tdir/$tfile ||
395 error "$tfile mode not 0666"
397 run_test 8 "mkdir .../d8; touch .../d8/f; chmod .../d8/f ======="
400 test_mkdir $DIR/$tdir
401 test_mkdir $DIR/$tdir/d2
402 test_mkdir $DIR/$tdir/d2/d3
403 $CHECKSTAT -t dir $DIR/$tdir/d2/d3 || error "$tdir/d2/d3 not a dir"
405 run_test 9 "mkdir .../d9 .../d9/d2 .../d9/d2/d3 ================"
408 test_mkdir $DIR/$tdir
409 test_mkdir $DIR/$tdir/d2
410 touch $DIR/$tdir/d2/$tfile
411 $CHECKSTAT -t file $DIR/$tdir/d2/$tfile ||
412 error "$tdir/d2/$tfile not a file"
414 run_test 10 "mkdir .../d10 .../d10/d2; touch .../d10/d2/f ======"
417 test_mkdir $DIR/$tdir
418 test_mkdir $DIR/$tdir/d2
419 chmod 0666 $DIR/$tdir/d2
420 chmod 0705 $DIR/$tdir/d2
421 $CHECKSTAT -t dir -p 0705 $DIR/$tdir/d2 ||
422 error "$tdir/d2 mode not 0705"
424 run_test 11 "mkdir .../d11 d11/d2; chmod .../d11/d2 ============"
427 test_mkdir $DIR/$tdir
428 touch $DIR/$tdir/$tfile
429 chmod 0666 $DIR/$tdir/$tfile
430 chmod 0654 $DIR/$tdir/$tfile
431 $CHECKSTAT -t file -p 0654 $DIR/$tdir/$tfile ||
432 error "$tdir/d2 mode not 0654"
434 run_test 12 "touch .../d12/f; chmod .../d12/f .../d12/f ========"
437 test_mkdir $DIR/$tdir
438 dd if=/dev/zero of=$DIR/$tdir/$tfile count=10
440 $CHECKSTAT -t file -s 0 $DIR/$tdir/$tfile ||
441 error "$tdir/$tfile size not 0 after truncate"
443 run_test 13 "creat .../d13/f; dd .../d13/f; > .../d13/f ========"
446 test_mkdir $DIR/$tdir
447 touch $DIR/$tdir/$tfile
449 $CHECKSTAT -a $DIR/$tdir/$tfile || error "$tdir/$tfile not removed"
451 run_test 14 "touch .../d14/f; rm .../d14/f; rm .../d14/f ======="
454 test_mkdir $DIR/$tdir
455 touch $DIR/$tdir/$tfile
456 mv $DIR/$tdir/$tfile $DIR/$tdir/${tfile}_2
457 $CHECKSTAT -t file $DIR/$tdir/${tfile}_2 ||
458 error "$tdir/${tfile_2} not a file after rename"
459 rm $DIR/$tdir/${tfile}_2 || error "unlink failed after rename"
461 run_test 15 "touch .../d15/f; mv .../d15/f .../d15/f2 =========="
464 test_mkdir $DIR/$tdir
465 touch $DIR/$tdir/$tfile
466 rm -rf $DIR/$tdir/$tfile
467 $CHECKSTAT -a $DIR/$tdir/$tfile || error "$tdir/$tfile not removed"
469 run_test 16 "touch .../d16/f; rm -rf .../d16/f"
472 test_mkdir $DIR/$tdir
473 touch $DIR/$tdir/$tfile
474 ln -s $DIR/$tdir/$tfile $DIR/$tdir/l-exist
476 $CHECKSTAT -l $DIR/$tdir/$tfile $DIR/$tdir/l-exist ||
477 error "$tdir/l-exist not a symlink"
478 $CHECKSTAT -f -t f $DIR/$tdir/l-exist ||
479 error "$tdir/l-exist not referencing a file"
480 rm -f $DIR/$tdir/l-exist
481 $CHECKSTAT -a $DIR/$tdir/l-exist || error "$tdir/l-exist not removed"
483 run_test 17a "symlinks: create, remove (real)"
486 test_mkdir $DIR/$tdir
487 ln -s no-such-file $DIR/$tdir/l-dangle
489 $CHECKSTAT -l no-such-file $DIR/$tdir/l-dangle ||
490 error "$tdir/l-dangle not referencing no-such-file"
491 $CHECKSTAT -fa $DIR/$tdir/l-dangle ||
492 error "$tdir/l-dangle not referencing non-existent file"
493 rm -f $DIR/$tdir/l-dangle
494 $CHECKSTAT -a $DIR/$tdir/l-dangle || error "$tdir/l-dangle not removed"
496 run_test 17b "symlinks: create, remove (dangling)"
498 test_17c() { # bug 3440 - don't save failed open RPC for replay
499 test_mkdir $DIR/$tdir
500 ln -s foo $DIR/$tdir/$tfile
501 cat $DIR/$tdir/$tfile && error "opened non-existent symlink" || true
503 run_test 17c "symlinks: open dangling (should return error)"
506 test_mkdir $DIR/$tdir
507 ln -s foo $DIR/$tdir/$tfile
508 touch $DIR/$tdir/$tfile || error "creating to new symlink"
510 run_test 17d "symlinks: create dangling"
513 test_mkdir $DIR/$tdir
514 local foo=$DIR/$tdir/$tfile
515 ln -s $foo $foo || error "create symlink failed"
516 ls -l $foo || error "ls -l failed"
517 ls $foo && error "ls not failed" || true
519 run_test 17e "symlinks: create recursive symlink (should return error)"
522 test_mkdir $DIR/$tdir
523 ln -s 1234567890/2234567890/3234567890/4234567890 $DIR/$tdir/111
524 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890 $DIR/$tdir/222
525 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890 $DIR/$tdir/333
526 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890/9234567890/a234567890/b234567890 $DIR/$tdir/444
527 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890/9234567890/a234567890/b234567890/c234567890/d234567890/f234567890 $DIR/$tdir/555
528 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
531 run_test 17f "symlinks: long and very long symlink name"
533 # str_repeat(S, N) generate a string that is string S repeated N times
538 while [ $((n -= 1)) -ge 0 ]; do
544 # Long symlinks and LU-2241
546 test_mkdir $DIR/$tdir
547 local TESTS="59 60 61 4094 4095"
549 # Fix for inode size boundary in 2.1.4
550 [ $MDS1_VERSION -lt $(version_code 2.1.4) ] &&
553 # Patch not applied to 2.2 or 2.3 branches
554 [ $MDS1_VERSION -ge $(version_code 2.2.0) ] &&
555 [ $MDS1_VERSION -le $(version_code 2.3.55) ] &&
558 # skip long symlink name for rhel6.5.
559 # rhel6.5 has a limit (PATH_MAX - sizeof(struct filename))
560 grep -q '6.5' /etc/redhat-release &>/dev/null &&
561 TESTS="59 60 61 4062 4063"
564 local SYMNAME=$(str_repeat 'x' $i)
565 ln -s $SYMNAME $DIR/$tdir/f$i || error "failed $i-char symlink"
566 readlink $DIR/$tdir/f$i || error "failed $i-char readlink"
569 run_test 17g "symlinks: really long symlink name and inode boundaries"
571 test_17h() { #bug 17378
572 [ $PARALLEL == "yes" ] && skip "skip parallel run"
573 remote_mds_nodsh && skip "remote MDS with nodsh"
577 test_mkdir $DIR/$tdir
578 mdt_idx=$($LFS getdirstripe -i $DIR/$tdir)
579 $LFS setstripe -c -1 $DIR/$tdir
580 #define OBD_FAIL_MDS_LOV_PREP_CREATE 0x141
581 do_facet mds$((mdt_idx + 1)) lctl set_param fail_loc=0x80000141
582 touch $DIR/$tdir/$tfile || true
584 run_test 17h "create objects: lov_free_memmd() doesn't lbug"
586 test_17i() { #bug 20018
587 [ $PARALLEL == "yes" ] && skip "skip parallel run"
588 remote_mds_nodsh && skip "remote MDS with nodsh"
590 local foo=$DIR/$tdir/$tfile
593 test_mkdir -c1 $DIR/$tdir
594 mdt_idx=$($LFS getdirstripe -i $DIR/$tdir)
595 ln -s $foo $foo || error "create symlink failed"
596 #define OBD_FAIL_MDS_READLINK_EPROTO 0x143
597 do_facet mds$((mdt_idx + 1)) lctl set_param fail_loc=0x80000143
598 ls -l $foo && error "error not detected"
601 run_test 17i "don't panic on short symlink (should return error)"
603 test_17k() { #bug 22301
604 [ $PARALLEL == "yes" ] && skip "skip parallel run"
605 [[ -z "$(which rsync 2>/dev/null)" ]] &&
606 skip "no rsync command"
607 rsync --help | grep -q xattr ||
608 skip_env "$(rsync --version | head -n1) does not support xattrs"
609 test_mkdir $DIR/$tdir
610 test_mkdir $DIR/$tdir.new
611 touch $DIR/$tdir/$tfile
612 ln -s $DIR/$tdir/$tfile $DIR/$tdir/$tfile.lnk
613 rsync -av -X $DIR/$tdir/ $DIR/$tdir.new ||
614 error "rsync failed with xattrs enabled"
616 run_test 17k "symlinks: rsync with xattrs enabled"
618 test_17l() { # LU-279
619 [[ -z "$(which getfattr 2>/dev/null)" ]] &&
620 skip "no getfattr command"
622 test_mkdir $DIR/$tdir
623 touch $DIR/$tdir/$tfile
624 ln -s $DIR/$tdir/$tfile $DIR/$tdir/$tfile.lnk
625 for path in "$DIR/$tdir" "$DIR/$tdir/$tfile" "$DIR/$tdir/$tfile.lnk"; do
626 # -h to not follow symlinks. -m '' to list all the xattrs.
627 # grep to remove first line: '# file: $path'.
628 for xattr in `getfattr -hm '' $path 2>/dev/null | grep -v '^#'`;
630 lgetxattr_size_check $path $xattr ||
631 error "lgetxattr_size_check $path $xattr failed"
635 run_test 17l "Ensure lgetxattr's returned xattr size is consistent"
639 [ $PARALLEL == "yes" ] && skip "skip parallel run"
640 [ "$mds1_FSTYPE" != "ldiskfs" ] && skip_env "ldiskfs only test"
641 remote_mds_nodsh && skip "remote MDS with nodsh"
642 [ $MDS1_VERSION -ge $(version_code 2.2.0) ] &&
643 [ $MDS1_VERSION -le $(version_code 2.2.93) ] &&
644 skip "MDS 2.2.0-2.2.93 do not NUL-terminate symlinks"
646 local short_sym="0123456789"
647 local wdir=$DIR/$tdir
652 # create a long symlink file
653 for ((i = 0; i < 4; ++i)); do
654 long_sym=${long_sym}${long_sym}
657 echo "create 512 short and long symlink files under $wdir"
658 for ((i = 0; i < 256; ++i)); do
659 ln -sf ${long_sym}"a5a5" $wdir/long-$i
660 ln -sf ${short_sym}"a5a5" $wdir/short-$i
666 wait_delete_completed
668 echo "recreate the 512 symlink files with a shorter string"
669 for ((i = 0; i < 512; ++i)); do
670 # rewrite the symlink file with a shorter string
671 ln -sf ${long_sym} $wdir/long-$i || error "long_sym failed"
672 ln -sf ${short_sym} $wdir/short-$i || error "short_sym failed"
675 local mds_index=$(($($LFS getstripe -m $wdir) + 1))
676 local devname=$(mdsdevname $mds_index)
678 echo "stop and checking mds${mds_index}:"
679 # e2fsck should not return error
681 run_e2fsck $(facet_active_host mds${mds_index}) $devname -n
684 start mds${mds_index} $devname $MDS_MOUNT_OPTS ||
685 error "start mds${mds_index} failed"
686 df $MOUNT > /dev/null 2>&1
688 error "e2fsck detected error for short/long symlink: rc=$rc"
691 run_test 17m "run e2fsck against MDT which contains short/long symlink"
693 check_fs_consistency_17n() {
697 # create/unlink in 17n only change 2 MDTs(MDT1/MDT2),
698 # so it only check MDT1/MDT2 instead of all of MDTs.
699 for mdt_index in 1 2; do
700 local devname=$(mdsdevname $mdt_index)
701 # e2fsck should not return error
703 run_e2fsck $(facet_active_host mds$mdt_index) $devname -n ||
706 start mds${mdt_index} $devname $MDS_MOUNT_OPTS ||
707 error "mount mds$mdt_index failed"
708 df $MOUNT > /dev/null 2>&1
714 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
715 [ $PARALLEL == "yes" ] && skip "skip parallel run"
716 [ "$mds1_FSTYPE" != "ldiskfs" ] && skip_env "ldiskfs only test"
717 remote_mds_nodsh && skip "remote MDS with nodsh"
718 [ $MDS1_VERSION -ge $(version_code 2.2.0) ] &&
719 [ $MDS1_VERSION -le $(version_code 2.2.93) ] &&
720 skip "MDS 2.2.0-2.2.93 do not NUL-terminate symlinks"
724 test_mkdir $DIR/$tdir
725 for ((i=0; i<10; i++)); do
726 $LFS mkdir -i1 -c2 $DIR/$tdir/remote_dir_${i} ||
727 error "create remote dir error $i"
728 createmany -o $DIR/$tdir/remote_dir_${i}/f 10 ||
729 error "create files under remote dir failed $i"
732 check_fs_consistency_17n ||
733 error "e2fsck report error after create files under remote dir"
735 for ((i = 0; i < 10; i++)); do
736 rm -rf $DIR/$tdir/remote_dir_${i} ||
737 error "destroy remote dir error $i"
740 check_fs_consistency_17n ||
741 error "e2fsck report error after unlink files under remote dir"
743 [ $MDS1_VERSION -lt $(version_code 2.4.50) ] &&
744 skip "lustre < 2.4.50 does not support migrate mv"
746 for ((i = 0; i < 10; i++)); do
747 mkdir -p $DIR/$tdir/remote_dir_${i}
748 createmany -o $DIR/$tdir/remote_dir_${i}/f 10 ||
749 error "create files under remote dir failed $i"
750 $LFS migrate --mdt-index 1 $DIR/$tdir/remote_dir_${i} ||
751 error "migrate remote dir error $i"
753 check_fs_consistency_17n || error "e2fsck report error after migration"
755 for ((i = 0; i < 10; i++)); do
756 rm -rf $DIR/$tdir/remote_dir_${i} ||
757 error "destroy remote dir error $i"
760 check_fs_consistency_17n || error "e2fsck report error after unlink"
762 run_test 17n "run e2fsck against master/slave MDT which contains remote dir"
765 remote_mds_nodsh && skip "remote MDS with nodsh"
766 [ $MDS1_VERSION -lt $(version_code 2.3.64) ] &&
767 skip "Need MDS version at least 2.3.64"
769 local wdir=$DIR/${tdir}o
775 mdt_index=$($LFS getstripe -m $wdir/$tfile)
776 mdt_index=$((mdt_index + 1))
779 #fail mds will wait the failover finish then set
780 #following fail_loc to avoid interfer the recovery process.
783 #define OBD_FAIL_OSD_LMA_INCOMPAT 0x194
784 do_facet mds${mdt_index} lctl set_param fail_loc=0x194
785 ls -l $wdir/$tfile && rc=1
786 do_facet mds${mdt_index} lctl set_param fail_loc=0
787 [[ $rc -eq 0 ]] || error "stat file should fail"
789 run_test 17o "stat file with incompat LMA feature"
792 touch $DIR/$tfile || error "Failed to touch $DIR/$tfile: $?"
793 ls $DIR || error "Failed to ls $DIR: $?"
795 run_test 18 "touch .../f ; ls ... =============================="
801 $CHECKSTAT -a $DIR/$tfile || error "$tfile was not removed"
803 run_test 19a "touch .../f19 ; ls -l ... ; rm .../f19 ==========="
806 ls -l $DIR/$tfile && error "ls -l $tfile failed"|| true
808 run_test 19b "ls -l .../f19 (should return error) =============="
811 [ $RUNAS_ID -eq $UID ] &&
812 skip_env "RUNAS_ID = UID = $UID -- skipping"
814 $RUNAS touch $DIR/$tfile && error "create non-root file failed" || true
816 run_test 19c "$RUNAS touch .../f19 (should return error) =="
819 cat $DIR/f19 && error || true
821 run_test 19d "cat .../f19 (should return error) =============="
830 $CHECKSTAT -a $DIR/$tfile || error "$tfile was not removed"
832 run_test 20 "touch .../f ; ls -l ..."
835 test_mkdir $DIR/$tdir
836 [ -f $DIR/$tdir/dangle ] && rm -f $DIR/$tdir/dangle
837 ln -s dangle $DIR/$tdir/link
838 echo foo >> $DIR/$tdir/link
839 cat $DIR/$tdir/dangle
840 $CHECKSTAT -t link $DIR/$tdir/link || error "$tdir/link not a link"
841 $CHECKSTAT -f -t file $DIR/$tdir/link ||
842 error "$tdir/link not linked to a file"
844 run_test 21 "write to dangling link"
847 local wdir=$DIR/$tdir
849 chown $RUNAS_ID:$RUNAS_GID $wdir
850 (cd $wdir || error "cd $wdir failed";
851 $RUNAS tar cf - /etc/hosts /etc/sysconfig/network |
853 ls -lR $wdir/etc || error "ls -lR $wdir/etc failed"
854 $CHECKSTAT -t dir $wdir/etc || error "checkstat -t dir failed"
855 $CHECKSTAT -u \#$RUNAS_ID -g \#$RUNAS_GID $wdir/etc ||
856 error "checkstat -u failed"
858 run_test 22 "unpack tar archive as non-root user"
862 test_mkdir $DIR/$tdir
863 local file=$DIR/$tdir/$tfile
865 openfile -f O_CREAT:O_EXCL $file || error "$file create failed"
866 openfile -f O_CREAT:O_EXCL $file &&
867 error "$file recreate succeeded" || true
869 run_test 23a "O_CREAT|O_EXCL in subdir"
871 test_23b() { # bug 18988
872 test_mkdir $DIR/$tdir
873 local file=$DIR/$tdir/$tfile
876 echo foo > $file || error "write filed"
877 echo bar >> $file || error "append filed"
878 $CHECKSTAT -s 8 $file || error "wrong size"
881 run_test 23b "O_APPEND check"
883 # LU-9409, size with O_APPEND and tiny writes
885 local file=$DIR/$tfile
888 dd conv=notrunc oflag=append if=/dev/zero of=$file bs=8 count=800
889 $CHECKSTAT -s 6400 $file || error "wrong size, expected 6400"
893 dd conv=notrunc oflag=append if=/dev/zero of=$file bs=8 count=800 &
894 dd conv=notrunc oflag=append if=/dev/zero of=$file bs=8 count=800 &
896 $CHECKSTAT -s 12800 $file || error "wrong size, expected 12800"
899 #racing tiny & normal writes
900 dd conv=notrunc oflag=append if=/dev/zero of=$file bs=4096 count=4 &
901 dd conv=notrunc oflag=append if=/dev/zero of=$file bs=8 count=100 &
903 $CHECKSTAT -s 17184 $file || error "wrong size, expected 17184"
906 #racing tiny & normal writes 2, ugly numbers
907 dd conv=notrunc oflag=append if=/dev/zero of=$file bs=4099 count=11 &
908 dd conv=notrunc oflag=append if=/dev/zero of=$file bs=17 count=173 &
910 $CHECKSTAT -s 48030 $file || error "wrong size, expected 48030"
913 run_test 23c "O_APPEND size checks for tiny writes"
915 # LU-11069 file offset is correct after appending writes
917 local file=$DIR/$tfile
920 echo CentaurHauls > $file
921 offset=$($MULTIOP $file oO_WRONLY:O_APPEND:w13Zp)
922 if ((offset != 26)); then
923 error "wrong offset, expected 26, got '$offset'"
926 run_test 23d "file offset is correct after appending writes"
930 echo '-- same directory rename'
931 test_mkdir $DIR/$tdir
932 touch $DIR/$tdir/$tfile.1
933 mv $DIR/$tdir/$tfile.1 $DIR/$tdir/$tfile.2
934 $CHECKSTAT -t file $DIR/$tdir/$tfile.2 || error "$tfile.2 not a file"
936 run_test 24a "rename file to non-existent target"
939 test_mkdir $DIR/$tdir
940 touch $DIR/$tdir/$tfile.{1,2}
941 mv $DIR/$tdir/$tfile.1 $DIR/$tdir/$tfile.2
942 $CHECKSTAT -a $DIR/$tdir/$tfile.1 || error "$tfile.1 exists"
943 $CHECKSTAT -t file $DIR/$tdir/$tfile.2 || error "$tfile.2 not a file"
945 run_test 24b "rename file to existing target"
948 test_mkdir $DIR/$tdir
949 test_mkdir $DIR/$tdir/d$testnum.1
950 mv $DIR/$tdir/d$testnum.1 $DIR/$tdir/d$testnum.2
951 $CHECKSTAT -a $DIR/$tdir/d$testnum.1 || error "d$testnum.1 exists"
952 $CHECKSTAT -t dir $DIR/$tdir/d$testnum.2 || error "d$testnum.2 not dir"
954 run_test 24c "rename directory to non-existent target"
957 test_mkdir -c1 $DIR/$tdir
958 test_mkdir -c1 $DIR/$tdir/d$testnum.1
959 test_mkdir -c1 $DIR/$tdir/d$testnum.2
960 mrename $DIR/$tdir/d$testnum.1 $DIR/$tdir/d$testnum.2
961 $CHECKSTAT -a $DIR/$tdir/d$testnum.1 || error "d$testnum.1 exists"
962 $CHECKSTAT -t dir $DIR/$tdir/d$testnum.2 || error "d$testnum.2 not dir"
964 run_test 24d "rename directory to existing target"
967 echo '-- cross directory renames --'
971 mv $DIR/R5a/f $DIR/R5b/g
972 $CHECKSTAT -a $DIR/R5a/f || error "$DIR/R5a/f exists"
973 $CHECKSTAT -t file $DIR/R5b/g || error "$DIR/R5b/g not file type"
975 run_test 24e "touch .../R5a/f; rename .../R5a/f .../R5b/g ======"
980 touch $DIR/R6a/f $DIR/R6b/g
981 mv $DIR/R6a/f $DIR/R6b/g
982 $CHECKSTAT -a $DIR/R6a/f || error "$DIR/R6a/f exists"
983 $CHECKSTAT -t file $DIR/R6b/g || error "$DIR/R6b/g not file type"
985 run_test 24f "touch .../R6a/f R6b/g; mv .../R6a/f .../R6b/g ===="
990 test_mkdir $DIR/R7a/d
991 mv $DIR/R7a/d $DIR/R7b/e
992 $CHECKSTAT -a $DIR/R7a/d || error "$DIR/R7a/d exists"
993 $CHECKSTAT -t dir $DIR/R7b/e || error "$DIR/R7b/e not dir type"
995 run_test 24g "mkdir .../R7{a,b}/d; mv .../R7a/d .../R7b/e ======"
998 test_mkdir -c1 $DIR/R8a
999 test_mkdir -c1 $DIR/R8b
1000 test_mkdir -c1 $DIR/R8a/d
1001 test_mkdir -c1 $DIR/R8b/e
1002 mrename $DIR/R8a/d $DIR/R8b/e
1003 $CHECKSTAT -a $DIR/R8a/d || error "$DIR/R8a/d exists"
1004 $CHECKSTAT -t dir $DIR/R8b/e || error "$DIR/R8b/e not dir type"
1006 run_test 24h "mkdir .../R8{a,b}/{d,e}; rename .../R8a/d .../R8b/e"
1009 echo "-- rename error cases"
1011 test_mkdir $DIR/R9/a
1013 mrename $DIR/R9/f $DIR/R9/a
1014 $CHECKSTAT -t file $DIR/R9/f || error "$DIR/R9/f not file type"
1015 $CHECKSTAT -t dir $DIR/R9/a || error "$DIR/R9/a not dir type"
1016 $CHECKSTAT -a $DIR/R9/a/f || error "$DIR/R9/a/f exists"
1018 run_test 24i "rename file to dir error: touch f ; mkdir a ; rename f a"
1022 mrename $DIR/R10/f $DIR/R10/g
1023 $CHECKSTAT -t dir $DIR/R10 || error "$DIR/R10 not dir type"
1024 $CHECKSTAT -a $DIR/R10/f || error "$DIR/R10/f exists"
1025 $CHECKSTAT -a $DIR/R10/g || error "$DIR/R10/g exists"
1027 run_test 24j "source does not exist ============================"
1030 test_mkdir $DIR/R11a
1031 test_mkdir $DIR/R11a/d
1033 mv $DIR/R11a/f $DIR/R11a/d
1034 $CHECKSTAT -a $DIR/R11a/f || error "$DIR/R11a/f exists"
1035 $CHECKSTAT -t file $DIR/R11a/d/f || error "$DIR/R11a/d/f not file type"
1037 run_test 24k "touch .../R11a/f; mv .../R11a/f .../R11a/d ======="
1039 # bug 2429 - rename foo foo foo creates invalid file
1042 $MULTIOP $f OcNs || error "rename of ${f} to itself failed"
1044 run_test 24l "Renaming a file to itself ========================"
1048 $MULTIOP $f OcLN ${f}2 ${f}2 || error "link ${f}2 ${f}2 failed"
1049 # on ext3 this does not remove either the source or target files
1050 # though the "expected" operation would be to remove the source
1051 $CHECKSTAT -t file ${f} || error "${f} missing"
1052 $CHECKSTAT -t file ${f}2 || error "${f}2 missing"
1054 run_test 24m "Renaming a file to a hard link to itself ========="
1058 # this stats the old file after it was renamed, so it should fail
1060 $CHECKSTAT ${f} || error "${f} missing"
1062 $CHECKSTAT ${f}.rename || error "${f}.rename missing"
1063 $CHECKSTAT -a ${f} || error "${f} exists"
1065 run_test 24n "Statting the old file after renaming (Posix rename 2)"
1068 test_mkdir $DIR/$tdir
1069 rename_many -s random -v -n 10 $DIR/$tdir
1071 run_test 24o "rename of files during htree split"
1074 test_mkdir $DIR/R12a
1075 test_mkdir $DIR/R12b
1076 DIRINO=`ls -lid $DIR/R12a | awk '{ print $1 }'`
1077 mrename $DIR/R12a $DIR/R12b
1078 $CHECKSTAT -a $DIR/R12a || error "$DIR/R12a exists"
1079 $CHECKSTAT -t dir $DIR/R12b || error "$DIR/R12b not dir type"
1080 DIRINO2=`ls -lid $DIR/R12b | awk '{ print $1 }'`
1081 [ "$DIRINO" = "$DIRINO2" ] || error "R12a $DIRINO != R12b $DIRINO2"
1083 run_test 24p "mkdir .../R12{a,b}; rename .../R12a .../R12b"
1085 cleanup_multiop_pause() {
1087 kill -USR1 $MULTIPID
1091 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1093 test_mkdir $DIR/R13a
1094 test_mkdir $DIR/R13b
1095 local DIRINO=$(ls -lid $DIR/R13a | awk '{ print $1 }')
1096 multiop_bg_pause $DIR/R13b D_c || error "multiop failed to start"
1099 trap cleanup_multiop_pause EXIT
1100 mrename $DIR/R13a $DIR/R13b
1101 $CHECKSTAT -a $DIR/R13a || error "R13a still exists"
1102 $CHECKSTAT -t dir $DIR/R13b || error "R13b does not exist"
1103 local DIRINO2=$(ls -lid $DIR/R13b | awk '{ print $1 }')
1104 [ "$DIRINO" = "$DIRINO2" ] || error "R13a $DIRINO != R13b $DIRINO2"
1105 cleanup_multiop_pause
1106 wait $MULTIPID || error "multiop close failed"
1108 run_test 24q "mkdir .../R13{a,b}; open R13b rename R13a R13b ==="
1110 test_24r() { #bug 3789
1111 test_mkdir $DIR/R14a
1112 test_mkdir $DIR/R14a/b
1113 mrename $DIR/R14a $DIR/R14a/b && error "rename to subdir worked!"
1114 $CHECKSTAT -t dir $DIR/R14a || error "$DIR/R14a missing"
1115 $CHECKSTAT -t dir $DIR/R14a/b || error "$DIR/R14a/b missing"
1117 run_test 24r "mkdir .../R14a/b; rename .../R14a .../R14a/b ====="
1120 test_mkdir $DIR/R15a
1121 test_mkdir $DIR/R15a/b
1122 test_mkdir $DIR/R15a/b/c
1123 mrename $DIR/R15a $DIR/R15a/b/c && error "rename to sub-subdir worked!"
1124 $CHECKSTAT -t dir $DIR/R15a || error "$DIR/R15a missing"
1125 $CHECKSTAT -t dir $DIR/R15a/b/c || error "$DIR/R15a/b/c missing"
1127 run_test 24s "mkdir .../R15a/b/c; rename .../R15a .../R15a/b/c ="
1129 test_mkdir $DIR/R16a
1130 test_mkdir $DIR/R16a/b
1131 test_mkdir $DIR/R16a/b/c
1132 mrename $DIR/R16a/b/c $DIR/R16a && error "rename to sub-subdir worked!"
1133 $CHECKSTAT -t dir $DIR/R16a || error "$DIR/R16a missing"
1134 $CHECKSTAT -t dir $DIR/R16a/b/c || error "$DIR/R16a/b/c missing"
1136 run_test 24t "mkdir .../R16a/b/c; rename .../R16a/b/c .../R16a ="
1138 test_24u() { # bug12192
1139 $MULTIOP $DIR/$tfile C2w$((2048 * 1024))c || error "multiop failed"
1140 $CHECKSTAT -s $((2048 * 1024)) $DIR/$tfile || error "wrong file size"
1142 run_test 24u "create stripe file"
1144 simple_cleanup_common() {
1147 [ -z "$DIR" ] || [ -z "$tdir" ] && return 0
1149 local start=$SECONDS
1152 wait_delete_completed
1153 echo "cleanup time $((SECONDS - start))"
1157 max_pages_per_rpc() {
1158 local mdtname="$(printf "MDT%04x" ${1:-0})"
1159 $LCTL get_param -n mdc.*$mdtname*.max_pages_per_rpc
1163 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1165 local nrfiles=${COUNT:-100000}
1166 local fname="$DIR/$tdir/$tfile"
1168 # Performance issue on ZFS see LU-4072 (c.f. LU-2887)
1169 [ "$mds1_FSTYPE" = "zfs" ] && nrfiles=${COUNT:-10000}
1171 test_mkdir "$(dirname $fname)"
1172 # assume MDT0000 has the fewest inodes
1173 local stripes=$($LFS getdirstripe -c $(dirname $fname))
1174 local free_inodes=$(($(mdt_free_inodes 0) * stripes))
1175 [[ $free_inodes -lt $nrfiles ]] && nrfiles=$free_inodes
1177 trap simple_cleanup_common EXIT
1179 createmany -m "$fname" $nrfiles
1181 cancel_lru_locks mdc
1182 lctl set_param mdc.*.stats clear
1184 # was previously test_24D: LU-6101
1185 # readdir() returns correct number of entries after cursor reload
1186 local num_ls=$(ls $DIR/$tdir | wc -l)
1187 local num_uniq=$(ls $DIR/$tdir | sort -u | wc -l)
1188 local num_all=$(ls -a $DIR/$tdir | wc -l)
1189 if [ $num_ls -ne $nrfiles ] || [ $num_uniq -ne $nrfiles ] ||
1190 [ $num_all -ne $((nrfiles + 2)) ]; then
1191 error "Expected $nrfiles files, got $num_ls " \
1192 "($num_uniq unique $num_all .&..)"
1194 # LU-5 large readdir
1195 # dirent_size = 32 bytes for sizeof(struct lu_dirent) +
1196 # N bytes for name (len($nrfiles) rounded to 8 bytes) +
1197 # 8 bytes for luda_type (4 bytes rounded to 8 bytes)
1198 # take into account of overhead in lu_dirpage header and end mark in
1199 # each page, plus one in rpc_num calculation.
1200 local dirent_size=$((32 + (${#tfile} | 7) + 1 + 8))
1201 local page_entries=$(((PAGE_SIZE - 24) / dirent_size))
1202 local mdt_idx=$($LFS getdirstripe -i $(dirname $fname))
1203 local rpc_pages=$(max_pages_per_rpc $mdt_idx)
1204 local rpc_max=$((nrfiles / (page_entries * rpc_pages) + stripes))
1205 local mds_readpage=$(calc_stats mdc.*.stats mds_readpage)
1206 echo "readpages: $mds_readpage rpc_max: $rpc_max"
1207 (( $mds_readpage < $rpc_max - 2 || $mds_readpage > $rpc_max + 1)) &&
1208 error "large readdir doesn't take effect: " \
1209 "$mds_readpage should be about $rpc_max"
1211 simple_cleanup_common
1213 run_test 24v "list large directory (test hash collision, b=17560)"
1215 test_24w() { # bug21506
1217 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=4096 || return 1
1218 dd if=/dev/zero bs=$SZ1 count=1 >> $DIR/$tfile || return 2
1219 dd if=$DIR/$tfile of=$DIR/${tfile}_left bs=1M skip=4097 || return 3
1220 SZ2=`ls -l $DIR/${tfile}_left | awk '{print $5}'`
1221 [[ "$SZ1" -eq "$SZ2" ]] ||
1222 error "Error reading at the end of the file $tfile"
1224 run_test 24w "Reading a file larger than 4Gb"
1227 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
1228 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1229 [[ $MDS1_VERSION -lt $(version_code 2.7.56) ]] &&
1230 skip "Need MDS version at least 2.7.56"
1233 local remote_dir=$DIR/$tdir/remote_dir
1235 test_mkdir $DIR/$tdir
1236 $LFS mkdir -i $MDTIDX $remote_dir ||
1237 error "create remote directory failed"
1239 test_mkdir $DIR/$tdir/src_dir
1240 touch $DIR/$tdir/src_file
1241 test_mkdir $remote_dir/tgt_dir
1242 touch $remote_dir/tgt_file
1244 mrename $DIR/$tdir/src_dir $remote_dir/tgt_dir ||
1245 error "rename dir cross MDT failed!"
1247 mrename $DIR/$tdir/src_file $remote_dir/tgt_file ||
1248 error "rename file cross MDT failed!"
1250 touch $DIR/$tdir/ln_file
1251 ln $DIR/$tdir/ln_file $remote_dir/ln_name ||
1252 error "ln file cross MDT failed"
1254 rm -rf $DIR/$tdir || error "Can not delete directories"
1256 run_test 24x "cross MDT rename/link"
1259 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
1260 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1262 local remote_dir=$DIR/$tdir/remote_dir
1265 test_mkdir $DIR/$tdir
1266 $LFS mkdir -i $mdtidx $remote_dir ||
1267 error "create remote directory failed"
1269 test_mkdir $remote_dir/src_dir
1270 touch $remote_dir/src_file
1271 test_mkdir $remote_dir/tgt_dir
1272 touch $remote_dir/tgt_file
1274 mrename $remote_dir/src_dir $remote_dir/tgt_dir ||
1275 error "rename subdir in the same remote dir failed!"
1277 mrename $remote_dir/src_file $remote_dir/tgt_file ||
1278 error "rename files in the same remote dir failed!"
1280 ln $remote_dir/tgt_file $remote_dir/tgt_file1 ||
1281 error "link files in the same remote dir failed!"
1283 rm -rf $DIR/$tdir || error "Can not delete directories"
1285 run_test 24y "rename/link on the same dir should succeed"
1288 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
1289 [[ $MDS1_VERSION -lt $(version_code 2.12.51) ]] &&
1290 skip "Need MDS version at least 2.12.51"
1294 for index in 0 1; do
1295 $LFS mkdir -i $index $DIR/$tdir.$index || error "mkdir failed"
1296 touch $DIR/$tdir.0/$tfile.$index || error "touch failed"
1299 mv $DIR/$tdir.0/$tfile.0 $DIR/$tdir.1 || error "mv $tfile.0 failed"
1301 index=$($LFS getstripe -m $DIR/$tdir.1/$tfile.0)
1302 [ $index -eq 0 ] || error "$tfile.0 is on MDT$index"
1304 local mdts=$(comma_list $(mdts_nodes))
1306 do_nodes $mdts $LCTL set_param mdt.*.enable_remote_rename=0
1307 stack_trap "do_nodes $mdts $LCTL \
1308 set_param mdt.*.enable_remote_rename=1" EXIT
1310 mv $DIR/$tdir.0/$tfile.1 $DIR/$tdir.1 || error "mv $tfile.1 failed"
1312 index=$($LFS getstripe -m $DIR/$tdir.1/$tfile.1)
1313 [ $index -eq 1 ] || error "$tfile.1 is on MDT$index"
1315 run_test 24z "cross-MDT rename is done as cp"
1317 test_24A() { # LU-3182
1321 test_mkdir $DIR/$tdir
1322 trap simple_cleanup_common EXIT
1323 createmany -m $DIR/$tdir/$tfile $NFILES
1324 local t=$(ls $DIR/$tdir | wc -l)
1325 local u=$(ls $DIR/$tdir | sort -u | wc -l)
1326 local v=$(ls -ai $DIR/$tdir | sort -u | wc -l)
1327 if [ $t -ne $NFILES ] || [ $u -ne $NFILES ] ||
1328 [ $v -ne $((NFILES + 2)) ] ; then
1329 error "Expected $NFILES files, got $t ($u unique $v .&..)"
1332 simple_cleanup_common || error "Can not delete directories"
1334 run_test 24A "readdir() returns correct number of entries."
1336 test_24B() { # LU-4805
1337 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
1341 test_mkdir $DIR/$tdir
1342 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR/$tdir/striped_dir ||
1343 error "create striped dir failed"
1345 count=$(ls -ai $DIR/$tdir/striped_dir | wc -l)
1346 [ $count -eq 2 ] || error "Expected 2, got $count"
1348 touch $DIR/$tdir/striped_dir/a
1350 count=$(ls -ai $DIR/$tdir/striped_dir | wc -l)
1351 [ $count -eq 3 ] || error "Expected 3, got $count"
1353 touch $DIR/$tdir/striped_dir/.f
1355 count=$(ls -ai $DIR/$tdir/striped_dir | wc -l)
1356 [ $count -eq 4 ] || error "Expected 4, got $count"
1358 rm -rf $DIR/$tdir || error "Can not delete directories"
1360 run_test 24B "readdir for striped dir return correct number of entries"
1363 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
1369 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR/$tdir/d0/striped_dir ||
1370 error "create striped dir failed"
1372 cd $DIR/$tdir/d0/striped_dir
1374 local d0_ino=$(ls -i -l -a $DIR/$tdir | grep "d0" | awk '{print $1}')
1375 local d1_ino=$(ls -i -l -a $DIR/$tdir | grep "d1" | awk '{print $1}')
1376 local parent_ino=$(ls -i -l -a | grep "\.\." | awk '{print $1}')
1378 [ "$d0_ino" = "$parent_ino" ] ||
1379 error ".. wrong, expect $d0_ino, get $parent_ino"
1381 mv $DIR/$tdir/d0/striped_dir $DIR/$tdir/d1/ ||
1382 error "mv striped dir failed"
1384 parent_ino=$(ls -i -l -a | grep "\.\." | awk '{print $1}')
1386 [ "$d1_ino" = "$parent_ino" ] ||
1387 error ".. wrong after mv, expect $d1_ino, get $parent_ino"
1389 run_test 24C "check .. in striped dir"
1392 [[ $MDSCOUNT -lt 4 ]] && skip_env "needs >= 4 MDTs"
1393 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1396 mkdir $DIR/$tdir/src_dir
1397 $LFS mkdir -i 1 $DIR/$tdir/src_dir/src_child ||
1398 error "create remote source failed"
1400 touch $DIR/$tdir/src_dir/src_child/a
1402 $LFS mkdir -i 2 $DIR/$tdir/tgt_dir ||
1403 error "create remote target dir failed"
1405 $LFS mkdir -i 3 $DIR/$tdir/tgt_dir/tgt_child ||
1406 error "create remote target child failed"
1408 mrename $DIR/$tdir/src_dir/src_child $DIR/$tdir/tgt_dir/tgt_child ||
1409 error "rename dir cross MDT failed!"
1413 $CHECKSTAT -t dir $DIR/$tdir/src_dir/src_child &&
1414 error "src_child still exists after rename"
1416 $CHECKSTAT -t file $DIR/$tdir/tgt_dir/tgt_child/a ||
1417 error "missing file(a) after rename"
1419 rm -rf $DIR/$tdir || error "Can not delete directories"
1421 run_test 24E "cross MDT rename/link"
1424 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
1427 [ "$SLOW" = "no" ] && repeats=100
1431 echo "$repeats repeats"
1432 for ((i = 0; i < repeats; i++)); do
1433 $LFS mkdir -i0 -c2 $DIR/$tdir/test || error "mkdir fails"
1434 touch $DIR/$tdir/test/a || error "touch fails"
1435 mkdir $DIR/$tdir/test/b || error "mkdir fails"
1436 rm -rf $DIR/$tdir/test || error "rmdir fails"
1441 run_test 24F "hash order vs readdir (LU-11330)"
1444 echo '== symlink sanity ============================================='
1448 touch $DIR/s25/foo ||
1449 error "File creation in symlinked directory failed"
1451 run_test 25a "create file in symlinked directory ==============="
1454 [ ! -d $DIR/d25 ] && test_25a
1455 $CHECKSTAT -t file $DIR/s25/foo || error "$DIR/s25/foo not file type"
1457 run_test 25b "lookup file in symlinked directory ==============="
1461 test_mkdir $DIR/d26/d26-2
1462 ln -s d26/d26-2 $DIR/s26
1463 touch $DIR/s26/foo || error "File creation failed"
1465 run_test 26a "multiple component symlink ======================="
1468 test_mkdir -p $DIR/$tdir/d26-2
1469 ln -s $tdir/d26-2/foo $DIR/s26-2
1470 touch $DIR/s26-2 || error "File creation failed"
1472 run_test 26b "multiple component symlink at end of lookup ======"
1475 test_mkdir $DIR/d26.2
1476 touch $DIR/d26.2/foo
1477 ln -s d26.2 $DIR/s26.2-1
1478 ln -s s26.2-1 $DIR/s26.2-2
1479 ln -s s26.2-2 $DIR/s26.2-3
1480 chmod 0666 $DIR/s26.2-3/foo
1482 run_test 26c "chain of symlinks"
1484 # recursive symlinks (bug 439)
1486 ln -s d26-3/foo $DIR/d26-3
1488 run_test 26d "create multiple component recursive symlink"
1491 [ ! -h $DIR/d26-3 ] && test_26d
1494 run_test 26e "unlink multiple component recursive symlink"
1496 # recursive symlinks (bug 7022)
1498 test_mkdir $DIR/$tdir
1499 test_mkdir $DIR/$tdir/$tfile
1500 cd $DIR/$tdir/$tfile || error "cd $DIR/$tdir/$tfile failed"
1501 test_mkdir -p lndir/bar1
1502 test_mkdir $DIR/$tdir/$tfile/$tfile
1503 cd $tfile || error "cd $tfile failed"
1504 ln -s .. dotdot || error "ln dotdot failed"
1505 ln -s dotdot/lndir lndir || error "ln lndir failed"
1506 cd $DIR/$tdir || error "cd $DIR/$tdir failed"
1507 output=`ls $tfile/$tfile/lndir/bar1`
1508 [ "$output" = bar1 ] && error "unexpected output"
1509 rm -r $tfile || error "rm $tfile failed"
1510 $CHECKSTAT -a $DIR/$tfile || error "$tfile not gone"
1512 run_test 26f "rm -r of a directory which has recursive symlink"
1515 test_mkdir $DIR/$tdir
1516 $LFS getstripe $DIR/$tdir
1517 $LFS setstripe -c 1 $DIR/$tdir/$tfile || error "setstripe failed"
1518 $CHECKSTAT -t file $DIR/$tdir/$tfile || error "checkstat failed"
1519 cp /etc/hosts $DIR/$tdir/$tfile || error "Can't copy to one stripe file"
1521 run_test 27a "one stripe file"
1524 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
1526 test_mkdir $DIR/$tdir
1527 $LFS setstripe -c 2 $DIR/$tdir/$tfile || error "setstripe failed"
1528 $LFS getstripe -c $DIR/$tdir/$tfile
1529 [ $($LFS getstripe -c $DIR/$tdir/$tfile) -eq 2 ] ||
1530 error "two-stripe file doesn't have two stripes"
1532 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=4k count=4 || error "dd failed"
1534 run_test 27b "create and write to two stripe file"
1536 # 27c family tests specific striping, setstripe -o
1538 [[ $OSTCOUNT -lt 2 ]] && skip_env "skipping 2-stripe test"
1539 test_mkdir -p $DIR/$tdir
1542 $LFS setstripe -o $osts $DIR/$tdir/$tfile || error "setstripe failed"
1543 $LFS getstripe -i $DIR/$tdir/$tfile
1544 [ $($LFS getstripe -i $DIR/$tdir/$tfile ) -eq $osts ] ||
1545 error "stripe not on specified OST"
1547 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=4 || error "dd failed"
1549 run_test 27ca "one stripe on specified OST"
1552 [[ $OSTCOUNT -lt 2 ]] && skip_env "skipping 2-stripe test"
1553 test_mkdir -p $DIR/$tdir
1555 $LFS setstripe -o $osts $DIR/$tdir/$tfile || error "setstripe failed"
1556 local getstripe=$($LFS getstripe $DIR/$tdir/$tfile)
1559 # Strip getstripe output to a space separated list of OSTs
1560 local getstripe_osts=$(echo "$getstripe" | sed -e '1,/obdidx/d' |\
1561 awk '{print $1}' | tr '\n' '\ ' | sed -e 's/[[:space:]]*$//')
1562 [ "$getstripe_osts" = "${osts//,/ }" ] ||
1563 error "stripes not on specified OSTs"
1565 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=4 || error "dd failed"
1567 run_test 27cb "two stripes on specified OSTs"
1570 [[ $OSTCOUNT -lt 2 ]] && skip_env "skipping 2-stripe test"
1571 [[ $($LCTL get_param mdc.*.import) =~ connect_flags.*overstriping ]] ||
1572 skip "server does not support overstriping"
1574 test_mkdir -p $DIR/$tdir
1576 $LFS setstripe -o $osts $DIR/$tdir/$tfile || error "setstripe failed"
1577 local getstripe=$($LFS getstripe $DIR/$tdir/$tfile)
1580 # Strip getstripe output to a space separated list of OSTs
1581 local getstripe_osts=$(echo "$getstripe" | sed -e '1,/obdidx/d' |\
1582 awk '{print $1}' | tr '\n' '\ ' | sed -e 's/[[:space:]]*$//')
1583 [ "$getstripe_osts" = "${osts//,/ }" ] ||
1584 error "stripes not on specified OSTs"
1586 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=4 || error "dd failed"
1588 run_test 27cc "two stripes on the same OST"
1591 [[ $OSTCOUNT -lt 2 ]] && skip_env "skipping 2-stripe test"
1592 [[ $($LCTL get_param mdc.*.import) =~ connect_flags.*overstriping ]] ||
1593 skip "server does not support overstriping"
1594 test_mkdir -p $DIR/$tdir
1595 local osts="0,1,1,0"
1596 $LFS setstripe -o $osts $DIR/$tdir/$tfile || error "setstripe failed"
1597 local getstripe=$($LFS getstripe $DIR/$tdir/$tfile)
1600 # Strip getstripe output to a space separated list of OSTs
1601 local getstripe_osts=$(echo "$getstripe" | sed -e '1,/obdidx/d' |\
1602 awk '{print $1}' | tr '\n' '\ ' | sed -e 's/[[:space:]]*$//')
1603 [ "$getstripe_osts" = "${osts//,/ }" ] ||
1604 error "stripes not on specified OSTs"
1606 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=4 || error "dd failed"
1608 run_test 27cd "four stripes on two OSTs"
1611 [[ $OSTCOUNT -ge $(($LOV_MAX_STRIPE_COUNT / 2)) ]] &&
1612 skip_env "too many osts, skipping"
1613 [[ $($LCTL get_param mdc.*.import) =~ connect_flags.*overstriping ]] ||
1614 skip "server does not support overstriping"
1615 # We do one more stripe than we have OSTs
1616 [ $OSTCOUNT -ge 159 ] || large_xattr_enabled ||
1617 skip_env "ea_inode feature disabled"
1619 test_mkdir -p $DIR/$tdir
1621 for i in $(seq 0 $OSTCOUNT);
1624 if [ $i -ne $OSTCOUNT ]; then
1628 $LFS setstripe -o $osts $DIR/$tdir/$tfile || error "setstripe failed"
1629 local getstripe=$($LFS getstripe $DIR/$tdir/$tfile)
1632 # Strip getstripe output to a space separated list of OSTs
1633 local getstripe_osts=$(echo "$getstripe" | sed -e '1,/obdidx/d' |\
1634 awk '{print $1}' | tr '\n' '\ ' | sed -e 's/[[:space:]]*$//')
1635 [ "$getstripe_osts" = "${osts//,/ }" ] ||
1636 error "stripes not on specified OSTs"
1638 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=4 || error "dd failed"
1640 run_test 27ce "more stripes than OSTs with -o"
1643 test_mkdir $DIR/$tdir
1644 $LFS setstripe -c 0 -i -1 -S 0 $DIR/$tdir/$tfile ||
1645 error "setstripe failed"
1646 $CHECKSTAT -t file $DIR/$tdir/$tfile || error "checkstat failed"
1647 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=4k count=4 || error "dd failed"
1649 run_test 27d "create file with default settings"
1652 # LU-5839 adds check for existed layout before setting it
1653 [[ $MDS1_VERSION -lt $(version_code 2.7.56) ]] &&
1654 skip "Need MDS version at least 2.7.56"
1656 test_mkdir $DIR/$tdir
1657 $LFS setstripe -c 2 $DIR/$tdir/$tfile || error "setstripe failed"
1658 $LFS setstripe -c 2 $DIR/$tdir/$tfile && error "setstripe worked twice"
1659 $CHECKSTAT -t file $DIR/$tdir/$tfile || error "checkstat failed"
1661 run_test 27e "setstripe existing file (should return error)"
1664 test_mkdir $DIR/$tdir
1665 $LFS setstripe -S 100 -i 0 -c 1 $DIR/$tdir/$tfile &&
1666 error "$LFS setstripe $DIR/$tdir/$tfile failed"
1667 $CHECKSTAT -t file $DIR/$tdir/$tfile &&
1668 error "$CHECKSTAT -t file $DIR/$tdir/$tfile should fail"
1669 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=4k count=4 || error "dd failed"
1670 $LFS getstripe $DIR/$tdir/$tfile || error "$LFS getstripe failed"
1672 run_test 27f "setstripe with bad stripe size (should return error)"
1675 test_mkdir $DIR/$tdir
1676 $MCREATE $DIR/$tdir/$tfile || error "mcreate failed"
1677 $LFS getstripe $DIR/$tdir/$tfile 2>&1 | grep "no stripe info" ||
1678 error "$DIR/$tdir/$tfile has object"
1680 run_test 27g "$LFS getstripe with no objects"
1683 test_mkdir $DIR/$tdir
1684 touch $DIR/$tdir/$tfile || error "touch failed"
1685 ln -s bogus $DIR/$tdir/$tfile.2 || error "ln failed"
1686 $LFS getstripe -m $DIR/$tdir/$tfile $DIR/$tdir/$tfile.2
1688 (( rc == 2 )) || error "getstripe did not return ENOENT"
1690 run_test 27ga "$LFS getstripe with missing file (should return error)"
1693 test_mkdir $DIR/$tdir
1694 touch $DIR/$tdir/$tfile || error "touch failed"
1695 [[ $($LFS getstripe -c $DIR/$tdir/$tfile) -gt 0 ]] ||
1696 error "missing objects"
1698 run_test 27i "$LFS getstripe with some objects"
1701 test_mkdir $DIR/$tdir
1702 $LFS setstripe -i $OSTCOUNT $DIR/$tdir/$tfile &&
1703 error "setstripe failed" || true
1705 run_test 27j "setstripe with bad stripe offset (should return error)"
1707 test_27k() { # bug 2844
1708 test_mkdir $DIR/$tdir
1709 local file=$DIR/$tdir/$tfile
1710 local ll_max_blksize=$((4 * 1024 * 1024))
1711 $LFS setstripe -S 67108864 $file || error "setstripe failed"
1712 local blksize=$(stat $file | awk '/IO Block:/ { print $7 }')
1713 [ $blksize -le $ll_max_blksize ] || error "1:$blksize > $ll_max_blksize"
1714 dd if=/dev/zero of=$file bs=4k count=1
1715 blksize=$(stat $file | awk '/IO Block:/ { print $7 }')
1716 [ $blksize -le $ll_max_blksize ] || error "2:$blksize > $ll_max_blksize"
1718 run_test 27k "limit i_blksize for broken user apps"
1721 mcreate $DIR/$tfile || error "creating file"
1722 $RUNAS $LFS setstripe -c 1 $DIR/$tfile &&
1723 error "setstripe should have failed" || true
1725 run_test 27l "check setstripe permissions (should return error)"
1728 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
1730 [ -n "$RCLIENTS" -o -n "$MOUNT_2" ] &&
1731 skip_env "multiple clients -- skipping"
1733 ORIGFREE=$($LCTL get_param -n lov.$FSNAME-clilov-*.kbytesavail |
1735 if [[ $ORIGFREE -gt $MAXFREE ]]; then
1736 skip "$ORIGFREE > $MAXFREE skipping out-of-space test on OST0"
1738 trap simple_cleanup_common EXIT
1739 test_mkdir $DIR/$tdir
1740 $LFS setstripe -i 0 -c 1 $DIR/$tdir/$tfile.1
1741 dd if=/dev/zero of=$DIR/$tdir/$tfile.1 bs=1024 count=$MAXFREE &&
1742 error "dd should fill OST0"
1744 while $LFS setstripe -i 0 -c 1 $DIR/$tdir/$tfile.$i; do
1746 [ $i -gt 256 ] && break
1749 touch $DIR/$tdir/$tfile.$i
1750 [ $($LFS getstripe $DIR/$tdir/$tfile.$i | grep -A 10 obdidx |
1751 awk '{print $1}'| grep -w "0") ] &&
1752 error "OST0 was full but new created file still use it"
1754 touch $DIR/$tdir/$tfile.$i
1755 [ $($LFS getstripe $DIR/$tdir/$tfile.$i | grep -A 10 obdidx |
1756 awk '{print $1}'| grep -w "0") ] &&
1757 error "OST0 was full but new created file still use it"
1758 simple_cleanup_common
1760 run_test 27m "create file while OST0 was full"
1763 local delay=$(do_facet $SINGLEMDS lctl get_param -n lov.*.qos_maxage |
1764 awk '{ print $1 * 2; exit; }')
1768 # OSCs keep a NOSPC flag that will be reset after ~5s (qos_maxage)
1769 # if the OST isn't full anymore.
1771 local OSTIDX=${1:-""}
1773 local list=$(comma_list $(osts_nodes))
1774 [ "$OSTIDX" ] && list=$(facet_host ost$((OSTIDX + 1)))
1776 do_nodes $list lctl set_param fail_loc=0
1777 sync # initiate all OST_DESTROYs from MDS to OST
1781 exhaust_precreations() {
1784 local FAILIDX=${3:-$OSTIDX}
1785 local ofacet=ost$((OSTIDX + 1))
1787 test_mkdir -p -c1 $DIR/$tdir
1788 local mdtidx=$($LFS getstripe -m $DIR/$tdir)
1789 local mfacet=mds$((mdtidx + 1))
1790 echo OSTIDX=$OSTIDX MDTIDX=$mdtidx
1792 local OST=$(ostname_from_index $OSTIDX)
1795 local mdtosc_proc1=$(get_mdtosc_proc_path $mfacet $OST)
1796 local last_id=$(do_facet $mfacet lctl get_param -n \
1797 osc.$mdtosc_proc1.prealloc_last_id)
1798 local next_id=$(do_facet $mfacet lctl get_param -n \
1799 osc.$mdtosc_proc1.prealloc_next_id)
1801 local mdtosc_proc2=$(get_mdtosc_proc_path $mfacet)
1802 do_facet $mfacet lctl get_param osc.$mdtosc_proc2.prealloc*
1804 test_mkdir -p $DIR/$tdir/${OST}
1805 $LFS setstripe -i $OSTIDX -c 1 $DIR/$tdir/${OST}
1806 #define OBD_FAIL_OST_ENOSPC 0x215
1807 do_facet $ofacet lctl set_param fail_val=$FAILIDX fail_loc=0x215
1808 echo "Creating to objid $last_id on ost $OST..."
1809 createmany -o $DIR/$tdir/${OST}/f $next_id $((last_id - next_id + 2))
1810 do_facet $mfacet lctl get_param osc.$mdtosc_proc2.prealloc*
1811 do_facet $ofacet lctl set_param fail_loc=$FAILLOC
1815 exhaust_all_precreations() {
1817 for (( i=0; i < OSTCOUNT; i++ )) ; do
1818 exhaust_precreations $i $1 -1
1823 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
1824 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1825 remote_mds_nodsh && skip "remote MDS with nodsh"
1826 remote_ost_nodsh && skip "remote OST with nodsh"
1829 rm -f $DIR/$tdir/$tfile
1830 exhaust_precreations 0 0x80000215
1831 $LFS setstripe -c -1 $DIR/$tdir || error "setstripe failed"
1832 touch $DIR/$tdir/$tfile || error "touch failed"
1833 $LFS getstripe $DIR/$tdir/$tfile
1836 run_test 27n "create file with some full OSTs"
1839 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
1840 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1841 remote_mds_nodsh && skip "remote MDS with nodsh"
1842 remote_ost_nodsh && skip "remote OST with nodsh"
1845 rm -f $DIR/$tdir/$tfile
1846 exhaust_all_precreations 0x215
1848 touch $DIR/$tdir/$tfile && error "able to create $DIR/$tdir/$tfile"
1853 run_test 27o "create file with all full OSTs (should error)"
1856 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
1857 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1858 remote_mds_nodsh && skip "remote MDS with nodsh"
1859 remote_ost_nodsh && skip "remote OST with nodsh"
1862 rm -f $DIR/$tdir/$tfile
1863 test_mkdir $DIR/$tdir
1865 $MCREATE $DIR/$tdir/$tfile || error "mcreate failed"
1866 $TRUNCATE $DIR/$tdir/$tfile 80000000 || error "truncate failed"
1867 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat failed"
1869 exhaust_precreations 0 0x80000215
1870 echo foo >> $DIR/$tdir/$tfile || error "append failed"
1871 $CHECKSTAT -s 80000004 $DIR/$tdir/$tfile || error "checkstat failed"
1872 $LFS getstripe $DIR/$tdir/$tfile
1876 run_test 27p "append to a truncated file with some full OSTs"
1879 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
1880 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1881 remote_mds_nodsh && skip "remote MDS with nodsh"
1882 remote_ost_nodsh && skip "remote OST with nodsh"
1885 rm -f $DIR/$tdir/$tfile
1887 test_mkdir $DIR/$tdir
1888 $MCREATE $DIR/$tdir/$tfile || error "mcreate $DIR/$tdir/$tfile failed"
1889 $TRUNCATE $DIR/$tdir/$tfile 80000000 ||
1890 error "truncate $DIR/$tdir/$tfile failed"
1891 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat failed"
1893 exhaust_all_precreations 0x215
1895 echo foo >> $DIR/$tdir/$tfile && error "append succeeded"
1896 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat 2 failed"
1900 run_test 27q "append to truncated file with all OSTs full (should error)"
1903 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
1904 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1905 remote_mds_nodsh && skip "remote MDS with nodsh"
1906 remote_ost_nodsh && skip "remote OST with nodsh"
1909 rm -f $DIR/$tdir/$tfile
1910 exhaust_precreations 0 0x80000215
1912 $LFS setstripe -i 0 -c 2 $DIR/$tdir/$tfile || error "setstripe failed"
1916 run_test 27r "stripe file with some full OSTs (shouldn't LBUG) ="
1918 test_27s() { # bug 10725
1919 test_mkdir $DIR/$tdir
1920 local stripe_size=$((4096 * 1024 * 1024)) # 2^32
1921 local stripe_count=0
1922 [ $OSTCOUNT -eq 1 ] || stripe_count=2
1923 $LFS setstripe -S $stripe_size -c $stripe_count $DIR/$tdir &&
1924 error "stripe width >= 2^32 succeeded" || true
1927 run_test 27s "lsm_xfersize overflow (should error) (bug 10725)"
1929 test_27t() { # bug 10864
1934 $WLFS getstripe $tfile
1937 run_test 27t "check that utils parse path correctly"
1939 test_27u() { # bug 4900
1940 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
1941 remote_mds_nodsh && skip "remote MDS with nodsh"
1944 local list=$(comma_list $(mdts_nodes))
1946 #define OBD_FAIL_MDS_OSC_PRECREATE 0x139
1947 do_nodes $list $LCTL set_param fail_loc=0x139
1948 test_mkdir -p $DIR/$tdir
1949 trap simple_cleanup_common EXIT
1950 createmany -o $DIR/$tdir/t- 1000
1951 do_nodes $list $LCTL set_param fail_loc=0
1953 TLOG=$TMP/$tfile.getstripe
1954 $LFS getstripe $DIR/$tdir > $TLOG
1955 OBJS=$(awk -vobj=0 '($1 == 0) { obj += 1 } END { print obj; }' $TLOG)
1956 unlinkmany $DIR/$tdir/t- 1000
1958 [[ $OBJS -gt 0 ]] &&
1959 error "$OBJS objects created on OST-0. See $TLOG" ||
1962 run_test 27u "skip object creation on OSC w/o objects"
1964 test_27v() { # bug 4900
1965 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
1966 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1967 remote_mds_nodsh && skip "remote MDS with nodsh"
1968 remote_ost_nodsh && skip "remote OST with nodsh"
1970 exhaust_all_precreations 0x215
1973 $LFS setstripe -c 1 $DIR/$tdir # 1 stripe / file
1975 touch $DIR/$tdir/$tfile
1976 #define OBD_FAIL_TGT_DELAY_PRECREATE 0x705
1978 for (( i=1; i < OSTCOUNT; i++ )); do
1979 do_facet ost$i lctl set_param fail_loc=0x705
1981 local START=`date +%s`
1982 createmany -o $DIR/$tdir/$tfile 32
1984 local FINISH=`date +%s`
1985 local TIMEOUT=`lctl get_param -n timeout`
1986 local PROCESS=$((FINISH - START))
1987 [ $PROCESS -ge $((TIMEOUT / 2)) ] && \
1988 error "$FINISH - $START >= $TIMEOUT / 2"
1989 sleep $((TIMEOUT / 2 - PROCESS))
1992 run_test 27v "skip object creation on slow OST"
1994 test_27w() { # bug 10997
1995 test_mkdir $DIR/$tdir
1996 $LFS setstripe -S 65536 $DIR/$tdir/f0 || error "setstripe failed"
1997 [ $($LFS getstripe -S $DIR/$tdir/f0) -ne 65536 ] &&
1998 error "stripe size $size != 65536" || true
1999 [ $($LFS getstripe -d $DIR/$tdir | grep -c "stripe_count") -eq 0 ] &&
2000 error "$LFS getstripe -d $DIR/$tdir no 'stripe_count'" || true
2002 run_test 27w "check $LFS setstripe -S and getstrip -d options"
2005 [[ $OSTCOUNT -lt 2 ]] &&
2006 skip_env "skipping multiple stripe count/offset test"
2008 test_mkdir $DIR/$tdir
2009 for i in $(seq 1 $OSTCOUNT); do
2011 $LFS setstripe -c $i -i $offset $DIR/$tdir/f$i ||
2012 error "setstripe -c $i -i $offset failed"
2013 count=$($LFS getstripe -c $DIR/$tdir/f$i)
2014 index=$($LFS getstripe -i $DIR/$tdir/f$i)
2015 [ $count -ne $i ] && error "stripe count $count != $i" || true
2016 [ $index -ne $offset ] &&
2017 error "stripe offset $index != $offset" || true
2020 run_test 27wa "check $LFS setstripe -c -i options"
2023 remote_ost_nodsh && skip "remote OST with nodsh"
2024 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
2025 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2027 OFFSET=$(($OSTCOUNT - 1))
2029 local OST=$(ostname_from_index $OSTIDX)
2031 test_mkdir $DIR/$tdir
2032 $LFS setstripe -c 1 $DIR/$tdir # 1 stripe per file
2033 do_facet ost$((OSTIDX + 1)) lctl set_param -n obdfilter.$OST.degraded 1
2035 createmany -o $DIR/$tdir/$tfile $OSTCOUNT
2036 for i in $(seq 0 $OFFSET); do
2037 [ $($LFS getstripe $DIR/$tdir/$tfile$i | grep -A 10 obdidx |
2038 awk '{print $1}' | grep -w "$OSTIDX") ] &&
2039 error "OST0 was degraded but new created file still use it"
2041 do_facet ost$((OSTIDX + 1)) lctl set_param -n obdfilter.$OST.degraded 0
2043 run_test 27x "create files while OST0 is degraded"
2046 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
2047 remote_mds_nodsh && skip "remote MDS with nodsh"
2048 remote_ost_nodsh && skip "remote OST with nodsh"
2049 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2051 local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS $FSNAME-OST0000)
2052 local last_id=$(do_facet $SINGLEMDS lctl get_param -n \
2053 osc.$mdtosc.prealloc_last_id)
2054 local next_id=$(do_facet $SINGLEMDS lctl get_param -n \
2055 osc.$mdtosc.prealloc_next_id)
2056 local fcount=$((last_id - next_id))
2057 [[ $fcount -eq 0 ]] && skip "not enough space on OST0"
2058 [[ $fcount -gt $OSTCOUNT ]] && fcount=$OSTCOUNT
2060 local MDS_OSCS=$(do_facet $SINGLEMDS lctl dl |
2061 awk '/[oO][sS][cC].*md[ts]/ { print $4 }')
2062 local OST_DEACTIVE_IDX=-1
2067 for OSC in $MDS_OSCS; do
2068 OST=$(osc_to_ost $OSC)
2069 OSTIDX=$(index_from_ostuuid $OST)
2070 if [ $OST_DEACTIVE_IDX == -1 ]; then
2071 OST_DEACTIVE_IDX=$OSTIDX
2073 if [ $OSTIDX != $OST_DEACTIVE_IDX ]; then
2074 echo $OSC "is Deactivated:"
2075 do_facet $SINGLEMDS lctl --device %$OSC deactivate
2079 OSTIDX=$(index_from_ostuuid $OST)
2080 test_mkdir $DIR/$tdir
2081 $LFS setstripe -c 1 $DIR/$tdir # 1 stripe / file
2083 for OSC in $MDS_OSCS; do
2084 OST=$(osc_to_ost $OSC)
2085 OSTIDX=$(index_from_ostuuid $OST)
2086 if [ $OSTIDX == $OST_DEACTIVE_IDX ]; then
2087 echo $OST "is degraded:"
2088 do_facet ost$((OSTIDX+1)) lctl set_param -n \
2089 obdfilter.$OST.degraded=1
2094 createmany -o $DIR/$tdir/$tfile $fcount
2096 for OSC in $MDS_OSCS; do
2097 OST=$(osc_to_ost $OSC)
2098 OSTIDX=$(index_from_ostuuid $OST)
2099 if [ $OSTIDX == $OST_DEACTIVE_IDX ]; then
2100 echo $OST "is recovered from degraded:"
2101 do_facet ost$((OSTIDX+1)) lctl set_param -n \
2102 obdfilter.$OST.degraded=0
2104 do_facet $SINGLEMDS lctl --device %$OSC activate
2108 # all osp devices get activated, hence -1 stripe count restored
2109 local stripe_count=0
2111 # sleep 2*lod_qos_maxage seconds waiting for lod qos to notice osp
2112 # devices get activated.
2114 $LFS setstripe -c -1 $DIR/$tfile
2115 stripe_count=$($LFS getstripe -c $DIR/$tfile)
2117 [ $stripe_count -ne $OSTCOUNT ] &&
2118 error "Of $OSTCOUNT OSTs, only $stripe_count is available"
2121 run_test 27y "create files while OST0 is degraded and the rest inactive"
2127 lmm_count=$($LFS getstripe -c $1)
2128 lmm_seq=$($LFS getstripe -v $1 | awk '/lmm_seq/ { print $2 }')
2129 lmm_oid=$($LFS getstripe -v $1 | awk '/lmm_object_id/ { print $2 }')
2131 local old_ifs="$IFS"
2133 fid=($($LFS path2fid $1))
2136 log "FID seq ${fid[1]}, oid ${fid[2]} ver ${fid[3]}"
2137 log "LOV seq $lmm_seq, oid $lmm_oid, count: $lmm_count"
2139 # compare lmm_seq and lu_fid->f_seq
2140 [ $lmm_seq = ${fid[1]} ] || { error "SEQ mismatch"; return 1; }
2141 # compare lmm_object_id and lu_fid->oid
2142 [ $lmm_oid = ${fid[2]} ] || { error "OID mismatch"; return 2; }
2144 # check the trusted.fid attribute of the OST objects of the file
2145 local have_obdidx=false
2147 $LFS getstripe $1 | while read obdidx oid hex seq; do
2148 # skip lines up to and including "obdidx"
2149 [ -z "$obdidx" ] && break
2150 [ "$obdidx" = "obdidx" ] && have_obdidx=true && continue
2151 $have_obdidx || continue
2153 local ost=$((obdidx + 1))
2154 local dev=$(ostdevname $ost)
2157 log "want: stripe:$stripe_nr ost:$obdidx oid:$oid/$hex seq:$seq"
2159 seq=$(echo $seq | sed -e "s/^0x//g")
2160 if [ $seq == 0 ] || [ $(facet_fstype ost$ost) == zfs ]; then
2161 oid_hex=$(echo $oid)
2163 oid_hex=$(echo $hex | sed -e "s/^0x//g")
2165 local obj_file="O/$seq/d$((oid %32))/$oid_hex"
2169 # Don't unmount/remount the OSTs if we don't need to do that.
2170 # LU-2577 changes filter_fid to be smaller, so debugfs needs
2171 # update too, until that use mount/ll_decode_filter_fid/mount.
2172 # Re-enable when debugfs will understand new filter_fid.
2174 if [ $(facet_fstype ost$ost) == ldiskfs ]; then
2175 ff=$(do_facet ost$ost "$DEBUGFS -c -R 'stat $obj_file' \
2176 $dev 2>/dev/null" | grep "parent=")
2178 if [ -z "$ff" ]; then
2180 mount_fstype ost$ost
2181 ff=$(do_facet ost$ost $LL_DECODE_FILTER_FID \
2182 $(facet_mntpt ost$ost)/$obj_file)
2183 unmount_fstype ost$ost
2184 start ost$ost $dev $OST_MOUNT_OPTS
2188 [ -z "$ff" ] && error "$obj_file: no filter_fid info"
2190 echo "$ff" | sed -e 's#.*objid=#got: objid=#'
2192 # /mnt/O/0/d23/23: objid=23 seq=0 parent=[0x200000400:0x1e:0x1]
2193 # fid: objid=23 seq=0 parent=[0x200000400:0x1e:0x0] stripe=1
2195 # fid: parent=[0x200000400:0x1e:0x0] stripe=1 stripe_count=2 \
2196 # stripe_size=1048576 component_id=1 component_start=0 \
2197 # component_end=33554432
2198 local ff_parent=$(sed -e 's/.*parent=.//' <<<$ff)
2199 local ff_pseq=$(cut -d: -f1 <<<$ff_parent)
2200 local ff_poid=$(cut -d: -f2 <<<$ff_parent)
2202 if grep -q 'stripe=' <<<$ff; then
2203 ff_pstripe=$(sed -e 's/.*stripe=//' -e 's/ .*//' <<<$ff)
2205 # $LL_DECODE_FILTER_FID does not print "stripe="; look
2206 # into f_ver in this case. See comment on ff_parent.
2207 ff_pstripe=$(cut -d: -f3 <<<$ff_parent | sed -e 's/]//')
2210 # compare lmm_seq and filter_fid->ff_parent.f_seq
2211 [ $ff_pseq = $lmm_seq ] ||
2212 error "FF parent SEQ $ff_pseq != $lmm_seq"
2213 # compare lmm_object_id and filter_fid->ff_parent.f_oid
2214 [ $ff_poid = $lmm_oid ] ||
2215 error "FF parent OID $ff_poid != $lmm_oid"
2216 (($ff_pstripe == $stripe_nr)) ||
2217 error "FF stripe $ff_pstripe != $stripe_nr"
2219 stripe_nr=$((stripe_nr + 1))
2220 [ $CLIENT_VERSION -lt $(version_code 2.9.55) ] &&
2222 if grep -q 'stripe_count=' <<<$ff; then
2223 local ff_scnt=$(sed -e 's/.*stripe_count=//' \
2224 -e 's/ .*//' <<<$ff)
2225 [ $lmm_count = $ff_scnt ] ||
2226 error "FF stripe count $lmm_count != $ff_scnt"
2232 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2233 remote_ost_nodsh && skip "remote OST with nodsh"
2235 test_mkdir $DIR/$tdir
2236 $LFS setstripe -c 1 -i 0 -S 64k $DIR/$tdir/$tfile-1 ||
2237 { error "setstripe -c -1 failed"; return 1; }
2238 # We need to send a write to every object to get parent FID info set.
2239 # This _should_ also work for setattr, but does not currently.
2240 # touch $DIR/$tdir/$tfile-1 ||
2241 dd if=/dev/zero of=$DIR/$tdir/$tfile-1 bs=1M count=1 ||
2242 { error "dd $tfile-1 failed"; return 2; }
2243 $LFS setstripe -c -1 -i $((OSTCOUNT - 1)) -S 1M $DIR/$tdir/$tfile-2 ||
2244 { error "setstripe -c -1 failed"; return 3; }
2245 dd if=/dev/zero of=$DIR/$tdir/$tfile-2 bs=1M count=$OSTCOUNT ||
2246 { error "dd $tfile-2 failed"; return 4; }
2248 # make sure write RPCs have been sent to OSTs
2251 check_seq_oid $DIR/$tdir/$tfile-1 || return 5
2252 check_seq_oid $DIR/$tdir/$tfile-2 || return 6
2254 run_test 27z "check SEQ/OID on the MDT and OST filesystems"
2256 test_27A() { # b=19102
2257 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2259 save_layout_restore_at_exit $MOUNT
2260 $LFS setstripe -c 0 -i -1 -S 0 $MOUNT
2261 wait_update $HOSTNAME "$LFS getstripe -c $MOUNT | sed 's/ *//g'" "1" 20 ||
2262 error "stripe count $($LFS getstripe -c $MOUNT) != 1"
2263 local default_size=$($LFS getstripe -S $MOUNT)
2264 local default_offset=$($LFS getstripe -i $MOUNT)
2265 local dsize=$(do_facet $SINGLEMDS \
2266 "$LCTL get_param -n lod.$(facet_svc $SINGLEMDS)*.stripesize")
2267 [ $default_size -eq $dsize ] ||
2268 error "stripe size $default_size != $dsize"
2269 [ $default_offset -eq -1 ] ||
2270 error "stripe offset $default_offset != -1"
2272 run_test 27A "check filesystem-wide default LOV EA values"
2274 test_27B() { # LU-2523
2275 test_mkdir $DIR/$tdir
2276 rm -f $DIR/$tdir/f0 $DIR/$tdir/f1
2278 # open f1 with O_LOV_DELAY_CREATE
2280 # call setstripe ioctl on open file descriptor for f1
2282 multiop $DIR/$tdir/f1 oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:nB1c \
2286 # open f1 with O_LOV_DELAY_CREATE
2288 # call setstripe ioctl on open file descriptor for f1
2290 multiop $DIR/$tdir/f1 oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:uB1c
2292 # Allow multiop to fail in imitation of NFS's busted semantics.
2295 run_test 27B "call setstripe on open unlinked file/rename victim"
2297 # 27C family tests full striping and overstriping
2298 test_27Ca() { #LU-2871
2299 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
2307 test_mkdir $DIR/$tdir
2309 for i in $(seq 0 $((OSTCOUNT - 1))); do
2310 # set stripe across all OSTs starting from OST$i
2311 $LFS setstripe -i $i -c -1 $tfile$i
2312 # get striping information
2313 ost_idx=($($LFS getstripe $tfile$i |
2314 tail -n $((OSTCOUNT + 1)) | awk '{print $1}'))
2318 [ ${#ost_idx[@]} -eq $OSTCOUNT ] ||
2319 error "${#ost_idx[@]} != $OSTCOUNT"
2321 for index in $(seq 0 $((OSTCOUNT - 1))); do
2323 for j in $(echo ${ost_idx[@]}); do
2324 if [ $index -eq $j ]; then
2330 error "Can not find $index in ${ost_idx[@]}"
2334 run_test 27Ca "check full striping across all OSTs"
2337 [[ $($LCTL get_param mdc.*.import) =~ connect_flags.*overstriping ]] ||
2338 skip "server does not support overstriping"
2339 [[ $OSTCOUNT -ge $(($LOV_MAX_STRIPE_COUNT / 2)) ]] &&
2340 skip_env "too many osts, skipping"
2342 test_mkdir -p $DIR/$tdir
2343 local setcount=$(($OSTCOUNT * 2))
2344 [ $setcount -ge 160 ] || large_xattr_enabled ||
2345 skip_env "ea_inode feature disabled"
2347 $LFS setstripe -C $setcount $DIR/$tdir/$tfile ||
2348 error "setstripe failed"
2350 local count=$($LFS getstripe -c $DIR/$tdir/$tfile)
2351 [ $count -eq $setcount ] ||
2352 error "stripe count $count, should be $setcount"
2354 $LFS getstripe $DIR/$tdir/$tfile 2>&1 | grep "overstriped" ||
2355 error "overstriped should be set in pattern"
2357 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=4 conv=notrunc ||
2360 run_test 27Cb "more stripes than OSTs with -C"
2363 [[ $($LCTL get_param mdc.*.import) =~ connect_flags.*overstriping ]] ||
2364 skip "server does not support overstriping"
2365 [[ $OSTCOUNT -lt 2 ]] && skip_env "need > 1 OST"
2367 test_mkdir -p $DIR/$tdir
2368 local setcount=$(($OSTCOUNT - 1))
2370 [ $setcount -ge 160 ] || large_xattr_enabled ||
2371 skip_env "ea_inode feature disabled"
2373 $LFS setstripe -C $setcount $DIR/$tdir/$tfile ||
2374 error "setstripe failed"
2376 local count=$($LFS getstripe -c $DIR/$tdir/$tfile)
2377 [ $count -eq $setcount ] ||
2378 error "stripe count $count, should be $setcount"
2380 $LFS getstripe $DIR/$tdir/$tfile 2>&1 | grep "overstriped" &&
2381 error "overstriped should not be set in pattern"
2383 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=4 conv=notrunc ||
2386 run_test 27Cc "fewer stripes than OSTs does not set overstriping"
2389 [[ $($LCTL get_param mdc.*.import) =~ connect_flags.*overstriping ]] ||
2390 skip "server does not support overstriping"
2391 [[ $OSTCOUNT -lt 2 ]] && skip_env "need > 1 OST"
2392 large_xattr_enabled || skip_env "ea_inode feature disabled"
2394 test_mkdir -p $DIR/$tdir
2395 local setcount=$LOV_MAX_STRIPE_COUNT
2397 $LFS setstripe -C $setcount $DIR/$tdir/$tfile ||
2398 error "setstripe failed"
2400 local count=$($LFS getstripe -c $DIR/$tdir/$tfile)
2401 [ $count -eq $setcount ] ||
2402 error "stripe count $count, should be $setcount"
2404 $LFS getstripe $DIR/$tdir/$tfile 2>&1 | grep "overstriped" ||
2405 error "overstriped should be set in pattern"
2407 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=4 conv=notrunc ||
2410 rm -f $DIR/$tdir/$tfile || error "Delete $tfile failed"
2412 run_test 27Cd "test maximum stripe count"
2415 [[ $($LCTL get_param mdc.*.import) =~ connect_flags.*overstriping ]] ||
2416 skip "server does not support overstriping"
2417 test_mkdir -p $DIR/$tdir
2419 pool_add $TESTNAME || error "Pool creation failed"
2420 pool_add_targets $TESTNAME 0 || error "pool_add_targets failed"
2424 $LFS setstripe -C $setcount -p "$TESTNAME" $DIR/$tdir/$tfile ||
2425 error "setstripe failed"
2427 local count=$($LFS getstripe -c $DIR/$tdir/$tfile)
2428 [ $count -eq $setcount ] ||
2429 error "stripe count $count, should be $setcount"
2431 $LFS getstripe $DIR/$tdir/$tfile 2>&1 | grep "overstriped" ||
2432 error "overstriped should be set in pattern"
2434 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=4 conv=notrunc ||
2437 rm -f $DIR/$tdir/$tfile || error "Delete $tfile failed"
2439 run_test 27Ce "test pool with overstriping"
2442 [[ $($LCTL get_param mdc.*.import) =~ connect_flags.*overstriping ]] ||
2443 skip "server does not support overstriping"
2444 [[ $OSTCOUNT -ge $(($LOV_MAX_STRIPE_COUNT / 2)) ]] &&
2445 skip_env "too many osts, skipping"
2447 test_mkdir -p $DIR/$tdir
2449 local setcount=$(($OSTCOUNT * 2))
2450 [ $setcount -ge 160 ] || large_xattr_enabled ||
2451 skip_env "ea_inode feature disabled"
2453 $LFS setstripe -C $setcount $DIR/$tdir/ ||
2454 error "setstripe failed"
2456 echo 1 > $DIR/$tdir/$tfile
2458 local count=$($LFS getstripe -c $DIR/$tdir/$tfile)
2459 [ $count -eq $setcount ] ||
2460 error "stripe count $count, should be $setcount"
2462 $LFS getstripe $DIR/$tdir/$tfile 2>&1 | grep "overstriped" ||
2463 error "overstriped should be set in pattern"
2465 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=4 conv=notrunc ||
2468 rm -f $DIR/$tdir/$tfile || error "Delete $tfile failed"
2470 run_test 27Cf "test default inheritance with overstriping"
2473 [ $OSTCOUNT -lt 2 ] && skip_env "needs >= 2 OSTs"
2474 [ -n "$FILESET" ] && skip "SKIP due to FILESET set"
2475 remote_mds_nodsh && skip "remote MDS with nodsh"
2477 local POOL=${POOL:-testpool}
2479 local last_ost=$(($OSTCOUNT - 1))
2481 local ost_list=$(seq $first_ost $ost_step $last_ost)
2482 local ost_range="$first_ost $last_ost $ost_step"
2484 if ! combined_mgs_mds ; then
2488 test_mkdir $DIR/$tdir
2489 pool_add $POOL || error "pool_add failed"
2490 pool_add_targets $POOL $ost_range || error "pool_add_targets failed"
2493 [ $MDS1_VERSION -lt $(version_code 2.8.55) ] &&
2495 [ $MDS1_VERSION -lt $(version_code 2.9.55) ] ||
2496 [ $CLIENT_VERSION -lt $(version_code 2.9.55) ] &&
2497 skip27D+=" -s 30,31"
2498 [[ ! $($LCTL get_param mdc.*.import) =~ connect_flags.*overstriping ||
2499 $OSTCOUNT -ge $(($LOV_MAX_STRIPE_COUNT / 2)) ]] &&
2500 skip27D+=" -s 32,33"
2501 llapi_layout_test -d$DIR/$tdir -p$POOL -o$OSTCOUNT $skip27D ||
2502 error "llapi_layout_test failed"
2504 destroy_test_pools || error "destroy test pools failed"
2506 if ! combined_mgs_mds ; then
2510 run_test 27D "validate llapi_layout API"
2512 # Verify that default_easize is increased from its initial value after
2513 # accessing a widely striped file.
2515 [ $OSTCOUNT -lt 2 ] && skip_env "needs >= 2 OSTs"
2516 [ $CLIENT_VERSION -lt $(version_code 2.5.57) ] &&
2517 skip "client does not have LU-3338 fix"
2519 # 72 bytes is the minimum space required to store striping
2520 # information for a file striped across one OST:
2521 # (sizeof(struct lov_user_md_v3) +
2522 # sizeof(struct lov_user_ost_data_v1))
2524 $LCTL set_param -n llite.*.default_easize $min_easize ||
2525 error "lctl set_param failed"
2526 local easize=$($LCTL get_param -n llite.*.default_easize)
2528 [ $easize -eq $min_easize ] ||
2529 error "failed to set default_easize"
2531 $LFS setstripe -c $OSTCOUNT $DIR/$tfile ||
2532 error "setstripe failed"
2533 # In order to ensure stat() call actually talks to MDS we need to
2534 # do something drastic to this file to shake off all lock, e.g.
2535 # rename it (kills lookup lock forcing cache cleaning)
2536 mv $DIR/$tfile $DIR/${tfile}-1
2537 ls -l $DIR/${tfile}-1
2540 easize=$($LCTL get_param -n llite.*.default_easize)
2542 [ $easize -gt $min_easize ] ||
2543 error "default_easize not updated"
2545 run_test 27E "check that default extended attribute size properly increases"
2547 test_27F() { # LU-5346/LU-7975
2548 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2549 [[ $OSTCOUNT -lt 2 ]] && skip "needs >= 2 OSTs"
2550 [[ $MDS1_VERSION -lt $(version_code 2.8.51) ]] &&
2551 skip "Need MDS version at least 2.8.51"
2552 remote_ost_nodsh && skip "remote OST with nodsh"
2554 test_mkdir $DIR/$tdir
2556 $LFS setstripe -c 2 $DIR/$tdir
2558 # stop all OSTs to reproduce situation for LU-7975 ticket
2559 for num in $(seq $OSTCOUNT); do
2563 # open/create f0 with O_LOV_DELAY_CREATE
2564 # truncate f0 to a non-0 size
2566 multiop $DIR/$tdir/f0 oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:T1050000c
2568 $CHECKSTAT -s 1050000 $DIR/$tdir/f0 || error "checkstat failed"
2569 # open/write it again to force delayed layout creation
2570 cat /etc/hosts > $DIR/$tdir/f0 &
2574 for num in $(seq $OSTCOUNT); do
2575 start ost$num $(ostdevname $num) $OST_MOUNT_OPTS ||
2576 error "ost$num failed to start"
2579 wait $catpid || error "cat failed"
2581 cmp /etc/hosts $DIR/$tdir/f0 || error "cmp failed"
2582 [[ $($LFS getstripe -c $DIR/$tdir/f0) == 2 ]] ||
2583 error "wrong stripecount"
2586 run_test 27F "Client resend delayed layout creation with non-zero size"
2588 test_27G() { #LU-10629
2589 [ $MDS1_VERSION -lt $(version_code 2.11.51) ] &&
2590 skip "Need MDS version at least 2.11.51"
2591 [ -n "$FILESET" ] && skip "SKIP due to FILESET set"
2592 remote_mds_nodsh && skip "remote MDS with nodsh"
2593 local POOL=${POOL:-testpool}
2594 local ostrange="0 0 1"
2596 test_mkdir $DIR/$tdir
2597 pool_add $POOL || error "pool_add failed"
2598 pool_add_targets $POOL $ostrange || error "pool_add_targets failed"
2599 $LFS setstripe -p $POOL $DIR/$tdir
2601 local pool=$($LFS getstripe -p $DIR/$tdir)
2603 [ "$pool" = "$POOL" ] || error "Striping failed got '$pool' not '$POOL'"
2605 $LFS setstripe -d $DIR/$tdir
2607 pool=$($LFS getstripe -p $DIR/$tdir)
2611 [ -z "$pool" ] || error "'$pool' is not empty"
2613 run_test 27G "Clear OST pool from stripe"
2616 [[ $MDS1_VERSION -le $(version_code 2.11.54) ]] &&
2617 skip "Need MDS version newer than 2.11.54"
2618 [[ $OSTCOUNT -lt 3 ]] && skip_env "needs >= 3 OSTs"
2619 test_mkdir $DIR/$tdir
2620 $LFS setstripe -o 0 -o 2 $DIR/$tdir || error "setstripe failed"
2621 touch $DIR/$tdir/$tfile
2622 $LFS getstripe -c $DIR/$tdir/$tfile
2623 [ $($LFS getstripe -c $DIR/$tdir/$tfile) -eq 2 ] ||
2624 error "two-stripe file doesn't have two stripes"
2626 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=4k count=4 || error "dd failed"
2627 $LFS getstripe -y $DIR/$tdir/$tfile
2628 (( $($LFS getstripe -y $DIR/$tdir/$tfile |
2629 egrep -c "l_ost_idx: [02]$") == "2" )) ||
2630 error "expected l_ost_idx: [02]$ not matched"
2632 # make sure ost list has been cleared
2633 local stripesize=$($LFS getstripe -S $DIR/$tdir)
2634 $LFS setstripe -S $((stripesize * 4)) -i 1 \
2635 -c $((OSTCOUNT - 1)) $DIR/$tdir || error "setstripe"
2637 $LVERIFY $DIR/$tdir $DIR/$tdir/f3 || error "lverify failed"
2639 run_test 27H "Set specific OSTs stripe"
2642 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2643 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
2644 local pool=$TESTNAME
2645 local ostrange="1 1 1"
2647 save_layout_restore_at_exit $MOUNT
2648 $LFS setstripe -c 2 -i 0 $MOUNT
2649 pool_add $pool || error "pool_add failed"
2650 pool_add_targets $pool $ostrange || "pool_add_targets failed"
2651 test_mkdir $DIR/$tdir
2652 $LFS setstripe -p $pool $DIR/$tdir
2653 $MULTIOP $DIR/$tdir/$tfile Oc || error "multiop failed"
2654 $LFS getstripe $DIR/$tdir/$tfile
2656 run_test 27I "check that root dir striping does not break parent dir one"
2659 [[ $(lustre_version_code $SINGLEMDS) -le $(version_code 2.12.51) ]] &&
2660 skip "Need MDS version newer than 2.12.51"
2662 test_mkdir $DIR/$tdir
2663 local uuid1=$(cat /proc/sys/kernel/random/uuid)
2664 local uuid2=$(cat /proc/sys/kernel/random/uuid)
2666 # create foreign file (raw way)
2667 create_foreign_file -f $DIR/$tdir/$tfile -x "${uuid1}@${uuid2}" \
2668 -t 1 -F 0xda08 || error "create_foreign_file failed"
2670 # verify foreign file (raw way)
2671 parse_foreign_file -f $DIR/$tdir/$tfile |
2672 grep "lov_foreign_magic: 0x0BD70BD0" ||
2673 error "$DIR/$tdir/$tfile: invalid LOV EA foreign magic"
2674 parse_foreign_file -f $DIR/$tdir/$tfile | grep "lov_xattr_size: 89" ||
2675 error "$DIR/$tdir/$tfile: invalid LOV EA foreign size"
2676 parse_foreign_file -f $DIR/$tdir/$tfile |
2677 grep "lov_foreign_size: 73" ||
2678 error "$DIR/$tdir/$tfile: invalid LOV EA foreign size"
2679 parse_foreign_file -f $DIR/$tdir/$tfile |
2680 grep "lov_foreign_type: 1" ||
2681 error "$DIR/$tdir/$tfile: invalid LOV EA foreign type"
2682 parse_foreign_file -f $DIR/$tdir/$tfile |
2683 grep "lov_foreign_flags: 0x0000DA08" ||
2684 error "$DIR/$tdir/$tfile: invalid LOV EA foreign flags"
2685 local lov=$(parse_foreign_file -f $DIR/$tdir/$tfile |
2686 grep "lov_foreign_value: 0x" |
2687 sed -e 's/lov_foreign_value: 0x//')
2688 local lov2=$(echo -n "${uuid1}@${uuid2}" | od -A n -t x1 -w160)
2689 [[ $lov = ${lov2// /} ]] ||
2690 error "$DIR/$tdir/$tfile: invalid LOV EA foreign value"
2692 # create foreign file (lfs + API)
2693 $LFS setstripe --foreign=daos --flags 0xda08 \
2694 -x "${uuid1}@${uuid2}" $DIR/$tdir/${tfile}2 ||
2695 error "$DIR/$tdir/${tfile}2: create failed"
2697 $LFS getstripe -v $DIR/$tdir/${tfile}2 |
2698 grep "lfm_magic:.*0x0BD70BD0" ||
2699 error "$DIR/$tdir/${tfile}2: invalid LOV EA foreign magic"
2700 # lfm_length is LOV EA size - sizeof(lfm_magic) - sizeof(lfm_length)
2701 $LFS getstripe -v $DIR/$tdir/${tfile}2 | grep "lfm_length:.*73" ||
2702 error "$DIR/$tdir/${tfile}2: invalid LOV EA foreign size"
2703 $LFS getstripe -v $DIR/$tdir/${tfile}2 | grep "lfm_type:.*daos" ||
2704 error "$DIR/$tdir/${tfile}2: invalid LOV EA foreign type"
2705 $LFS getstripe -v $DIR/$tdir/${tfile}2 |
2706 grep "lfm_flags:.*0x0000DA08" ||
2707 error "$DIR/$tdir/${tfile}2: invalid LOV EA foreign flags"
2708 $LFS getstripe $DIR/$tdir/${tfile}2 |
2709 grep "lfm_value:.*${uuid1}@${uuid2}" ||
2710 error "$DIR/$tdir/${tfile}2: invalid LOV EA foreign value"
2712 # modify striping should fail
2713 $LFS setstripe -c 2 $DIR/$tdir/$tfile &&
2714 error "$DIR/$tdir/$tfile: setstripe should fail"
2715 $LFS setstripe -c 2 $DIR/$tdir/${tfile}2 &&
2716 error "$DIR/$tdir/${tfile}2: setstripe should fail"
2719 cat $DIR/$tdir/$tfile && error "$DIR/$tdir/$tfile: read should fail"
2720 cat $DIR/$tdir/${tfile}2 &&
2721 error "$DIR/$tdir/${tfile}2: read should fail"
2722 cat /etc/passwd > $DIR/$tdir/$tfile &&
2723 error "$DIR/$tdir/$tfile: write should fail"
2724 cat /etc/passwd > $DIR/$tdir/${tfile}2 &&
2725 error "$DIR/$tdir/${tfile}2: write should fail"
2728 chmod 222 $DIR/$tdir/$tfile ||
2729 error "$DIR/$tdir/$tfile: chmod failed"
2730 chmod 222 $DIR/$tdir/${tfile}2 ||
2731 error "$DIR/$tdir/${tfile}2: chmod failed"
2734 chown $RUNAS_ID:$RUNAS_GID $DIR/$tdir/$tfile ||
2735 error "$DIR/$tdir/$tfile: chown failed"
2736 chown $RUNAS_ID:$RUNAS_GID $DIR/$tdir/${tfile}2 ||
2737 error "$DIR/$tdir/${tfile}2: chown failed"
2739 # rename should work
2740 mv $DIR/$tdir/$tfile $DIR/$tdir/${tfile}.new ||
2741 error "$DIR/$tdir/$tfile: rename of foreign file has failed"
2742 mv $DIR/$tdir/${tfile}2 $DIR/$tdir/${tfile}2.new ||
2743 error "$DIR/$tdir/${tfile}2: rename of foreign file has failed"
2745 #remove foreign file
2746 rm $DIR/$tdir/${tfile}.new ||
2747 error "$DIR/$tdir/${tfile}.new: remove of foreign file has failed"
2748 rm $DIR/$tdir/${tfile}2.new ||
2749 error "$DIR/$tdir/${tfile}2.new: remove of foreign file has failed"
2751 run_test 27J "basic ops on file with foreign LOV"
2754 [[ $(lustre_version_code $SINGLEMDS) -le $(version_code 2.12.49) ]] &&
2755 skip "Need MDS version newer than 2.12.49"
2757 test_mkdir $DIR/$tdir
2758 local uuid1=$(cat /proc/sys/kernel/random/uuid)
2759 local uuid2=$(cat /proc/sys/kernel/random/uuid)
2761 # create foreign dir (raw way)
2762 create_foreign_dir -d $DIR/$tdir/$tdir -x "${uuid1}@${uuid2}" -t 1 ||
2763 error "create_foreign_dir FAILED"
2765 # verify foreign dir (raw way)
2766 parse_foreign_dir -d $DIR/$tdir/$tdir |
2767 grep "lmv_foreign_magic:.*0xcd50cd0" ||
2768 error "$DIR/$tdir/$tfile: invalid LMV EA magic"
2769 parse_foreign_dir -d $DIR/$tdir/$tdir | grep "lmv_xattr_size:.*89$" ||
2770 error "$DIR/$tdir/$tdir: invalid LMV EA size"
2771 parse_foreign_dir -d $DIR/$tdir/$tdir | grep "lmv_foreign_type: 1$" ||
2772 error "$DIR/$tdir/$tdir: invalid LMV EA type"
2773 parse_foreign_dir -d $DIR/$tdir/$tdir | grep "lmv_foreign_flags: 0$" ||
2774 error "$DIR/$tdir/$tdir: invalid LMV EA flags"
2775 local lmv=$(parse_foreign_dir -d $DIR/$tdir/$tdir |
2776 grep "lmv_foreign_value: 0x" |
2777 sed 's/lmv_foreign_value: 0x//')
2778 local lmv2=$(echo -n "${uuid1}@${uuid2}" | od -A n -t x1 -w160 |
2780 [[ $lmv == $lmv2 ]] || error "$DIR/$tdir/$tdir: invalid LMV EA value"
2782 # create foreign dir (lfs + API)
2783 $LFS mkdir --foreign=daos --xattr="${uuid1}@${uuid2}" --flags=0xda05 \
2784 $DIR/$tdir/${tdir}2 ||
2785 error "$DIR/$tdir/${tdir}2: create failed"
2787 $LFS getdirstripe -v $DIR/$tdir/${tdir}2 |
2788 grep "lfm_magic:.*0x0CD50CD0" ||
2789 error "$DIR/$tdir/${tdir}2: invalid LMV EA magic"
2790 # lfm_length is LMV EA size - sizeof(lfm_magic) - sizeof(lfm_length)
2791 # - sizeof(lfm_type) - sizeof(lfm_flags)
2792 $LFS getdirstripe -v $DIR/$tdir/${tdir}2 | grep "lfm_length:.*73" ||
2793 error "$DIR/$tdir/${tdir}2: invalid LMV EA size"
2794 $LFS getdirstripe -v $DIR/$tdir/${tdir}2 | grep "lfm_type:.*daos" ||
2795 error "$DIR/$tdir/${tdir}2: invalid LMV EA type"
2796 $LFS getdirstripe -v $DIR/$tdir/${tdir}2 |
2797 grep "lfm_flags:.*0x0000DA05" ||
2798 error "$DIR/$tdir/${tdir}2: invalid LMV EA flags"
2799 $LFS getdirstripe $DIR/$tdir/${tdir}2 |
2800 grep "lfm_value.*${uuid1}@${uuid2}" ||
2801 error "$DIR/$tdir/${tdir}2: invalid LMV EA value"
2803 # file create in dir should fail
2804 touch $DIR/$tdir/$tdir/$tfile && "$DIR/$tdir: file create should fail"
2805 touch $DIR/$tdir/${tdir}2/$tfile &&
2806 "$DIR/${tdir}2: file create should fail"
2809 chmod 777 $DIR/$tdir/$tdir ||
2810 error "$DIR/$tdir: chmod failed"
2811 chmod 777 $DIR/$tdir/${tdir}2 ||
2812 error "$DIR/${tdir}2: chmod failed"
2815 chown $RUNAS_ID:$RUNAS_GID $DIR/$tdir/$tdir ||
2816 error "$DIR/$tdir: chown failed"
2817 chown $RUNAS_ID:$RUNAS_GID $DIR/$tdir/${tdir}2 ||
2818 error "$DIR/${tdir}2: chown failed"
2820 # rename should work
2821 mv $DIR/$tdir/$tdir $DIR/$tdir/${tdir}.new ||
2822 error "$DIR/$tdir/$tdir: rename of foreign dir has failed"
2823 mv $DIR/$tdir/${tdir}2 $DIR/$tdir/${tdir}2.new ||
2824 error "$DIR/$tdir/${tdir}2: rename of foreign dir has failed"
2827 rmdir $DIR/$tdir/${tdir}.new ||
2828 error "$DIR/$tdir/${tdir}.new: remove of foreign dir has failed"
2829 rmdir $DIR/$tdir/${tdir}2.new ||
2830 error "$DIR/$tdir/${tdir}2.new: remove of foreign dir has failed"
2832 run_test 27K "basic ops on dir with foreign LMV"
2834 # createtest also checks that device nodes are created and
2835 # then visible correctly (#2091)
2836 test_28() { # bug 2091
2838 $CREATETEST $DIR/d28/ct || error "createtest failed"
2840 run_test 28 "create/mknod/mkdir with bad file types ============"
2843 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2845 sync; sleep 1; sync # flush out any dirty pages from previous tests
2852 declare -i LOCKCOUNTORIG=0
2853 for lock_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_count); do
2854 let LOCKCOUNTORIG=$LOCKCOUNTORIG+$lock_count
2856 [ $LOCKCOUNTORIG -eq 0 ] && error "No mdc lock count" && return 1
2858 declare -i LOCKUNUSEDCOUNTORIG=0
2859 for unused_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_unused_count); do
2860 let LOCKUNUSEDCOUNTORIG=$LOCKUNUSEDCOUNTORIG+$unused_count
2867 declare -i LOCKCOUNTCURRENT=0
2868 for lock_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_count); do
2869 let LOCKCOUNTCURRENT=$LOCKCOUNTCURRENT+$lock_count
2872 declare -i LOCKUNUSEDCOUNTCURRENT=0
2873 for unused_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_unused_count); do
2874 let LOCKUNUSEDCOUNTCURRENT=$LOCKUNUSEDCOUNTCURRENT+$unused_count
2877 if [[ $LOCKCOUNTCURRENT -gt $LOCKCOUNTORIG ]]; then
2878 $LCTL set_param -n ldlm.dump_namespaces ""
2879 error "CURRENT: $LOCKCOUNTCURRENT > $LOCKCOUNTORIG"
2880 $LCTL dk | sort -k4 -t: > $TMP/test_29.dk
2881 log "dumped log to $TMP/test_29.dk (bug 5793)"
2884 if [[ $LOCKUNUSEDCOUNTCURRENT -gt $LOCKUNUSEDCOUNTORIG ]]; then
2885 error "UNUSED: $LOCKUNUSEDCOUNTCURRENT > $LOCKUNUSEDCOUNTORIG"
2886 $LCTL dk | sort -k4 -t: > $TMP/test_29.dk
2887 log "dumped log to $TMP/test_29.dk (bug 5793)"
2891 run_test 29 "IT_GETATTR regression ============================"
2893 test_30a() { # was test_30
2894 cp $(which ls) $DIR || cp /bin/ls $DIR
2895 $DIR/ls / || error "Can't execute binary from lustre"
2898 run_test 30a "execute binary from Lustre (execve) =============="
2901 cp `which ls` $DIR || cp /bin/ls $DIR
2903 $RUNAS $DIR/ls / || error "Can't execute binary from lustre as non-root"
2906 run_test 30b "execute binary from Lustre as non-root ==========="
2908 test_30c() { # b=22376
2909 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2911 cp `which ls` $DIR || cp /bin/ls $DIR
2913 cancel_lru_locks mdc
2914 cancel_lru_locks osc
2915 $RUNAS $DIR/ls / || error "Can't execute binary from lustre"
2918 run_test 30c "execute binary from Lustre without read perms ===="
2921 $OPENUNLINK $DIR/f31 $DIR/f31 || error "openunlink failed"
2922 $CHECKSTAT -a $DIR/f31 || error "$DIR/f31 exists"
2924 run_test 31a "open-unlink file =================================="
2927 touch $DIR/f31 || error "touch $DIR/f31 failed"
2928 ln $DIR/f31 $DIR/f31b || error "ln failed"
2929 $MULTIOP $DIR/f31b Ouc || error "multiop failed"
2930 $CHECKSTAT -t file $DIR/f31 || error "$DIR/f31 not file type"
2932 run_test 31b "unlink file with multiple links while open ======="
2935 touch $DIR/f31 || error "touch $DIR/f31 failed"
2936 ln $DIR/f31 $DIR/f31c || error "ln failed"
2937 multiop_bg_pause $DIR/f31 O_uc ||
2938 error "multiop_bg_pause for $DIR/f31 failed"
2940 $MULTIOP $DIR/f31c Ouc
2941 kill -USR1 $MULTIPID
2944 run_test 31c "open-unlink file with multiple links ============="
2947 opendirunlink $DIR/d31d $DIR/d31d || error "opendirunlink failed"
2948 $CHECKSTAT -a $DIR/d31d || error "$DIR/d31d exists"
2950 run_test 31d "remove of open directory ========================="
2952 test_31e() { # bug 2904
2953 openfilleddirunlink $DIR/d31e || error "openfilleddirunlink failed"
2955 run_test 31e "remove of open non-empty directory ==============="
2957 test_31f() { # bug 4554
2958 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2961 test_mkdir $DIR/d31f
2962 $LFS setstripe -S 1048576 -c 1 $DIR/d31f
2963 cp /etc/hosts $DIR/d31f
2965 $LFS getstripe $DIR/d31f/hosts
2966 multiop_bg_pause $DIR/d31f D_c || return 1
2969 rm -rv $DIR/d31f || error "first of $DIR/d31f"
2970 test_mkdir $DIR/d31f
2971 $LFS setstripe -S 1048576 -c 1 $DIR/d31f
2972 cp /etc/hosts $DIR/d31f
2974 $LFS getstripe $DIR/d31f/hosts
2975 multiop_bg_pause $DIR/d31f D_c || return 1
2978 kill -USR1 $MULTIPID || error "first opendir $MULTIPID not running"
2979 wait $MULTIPID || error "first opendir $MULTIPID failed"
2983 kill -USR1 $MULTIPID2 || error "second opendir $MULTIPID not running"
2984 wait $MULTIPID2 || error "second opendir $MULTIPID2 failed"
2987 run_test 31f "remove of open directory with open-unlink file ==="
2990 echo "-- cross directory link --"
2991 test_mkdir -c1 $DIR/${tdir}ga
2992 test_mkdir -c1 $DIR/${tdir}gb
2993 touch $DIR/${tdir}ga/f
2994 ln $DIR/${tdir}ga/f $DIR/${tdir}gb/g
2995 $CHECKSTAT -t file $DIR/${tdir}ga/f || error "source"
2996 [ `stat -c%h $DIR/${tdir}ga/f` == '2' ] || error "source nlink"
2997 $CHECKSTAT -t file $DIR/${tdir}gb/g || error "target"
2998 [ `stat -c%h $DIR/${tdir}gb/g` == '2' ] || error "target nlink"
3000 run_test 31g "cross directory link==============="
3003 echo "-- cross directory link --"
3004 test_mkdir -c1 $DIR/${tdir}
3005 test_mkdir -c1 $DIR/${tdir}/dir
3006 touch $DIR/${tdir}/f
3007 ln $DIR/${tdir}/f $DIR/${tdir}/dir/g
3008 $CHECKSTAT -t file $DIR/${tdir}/f || error "source"
3009 [ `stat -c%h $DIR/${tdir}/f` == '2' ] || error "source nlink"
3010 $CHECKSTAT -t file $DIR/${tdir}/dir/g || error "target"
3011 [ `stat -c%h $DIR/${tdir}/dir/g` == '2' ] || error "target nlink"
3013 run_test 31h "cross directory link under child==============="
3016 echo "-- cross directory link --"
3017 test_mkdir -c1 $DIR/$tdir
3018 test_mkdir -c1 $DIR/$tdir/dir
3019 touch $DIR/$tdir/dir/f
3020 ln $DIR/$tdir/dir/f $DIR/$tdir/g
3021 $CHECKSTAT -t file $DIR/$tdir/dir/f || error "source"
3022 [ `stat -c%h $DIR/$tdir/dir/f` == '2' ] || error "source nlink"
3023 $CHECKSTAT -t file $DIR/$tdir/g || error "target"
3024 [ `stat -c%h $DIR/$tdir/g` == '2' ] || error "target nlink"
3026 run_test 31i "cross directory link under parent==============="
3029 test_mkdir -c1 -p $DIR/$tdir
3030 test_mkdir -c1 -p $DIR/$tdir/dir1
3031 ln $DIR/$tdir/dir1 $DIR/$tdir/dir2 && error "ln for dir"
3032 link $DIR/$tdir/dir1 $DIR/$tdir/dir3 && error "link for dir"
3033 mlink $DIR/$tdir/dir1 $DIR/$tdir/dir4 && error "mlink for dir"
3034 mlink $DIR/$tdir/dir1 $DIR/$tdir/dir1 && error "mlink to the same dir"
3037 run_test 31j "link for directory==============="
3040 test_mkdir -c1 -p $DIR/$tdir
3042 touch $DIR/$tdir/exist
3043 mlink $DIR/$tdir/s $DIR/$tdir/t || error "mlink"
3044 mlink $DIR/$tdir/s $DIR/$tdir/exist && error "mlink to exist file"
3045 mlink $DIR/$tdir/s $DIR/$tdir/s && error "mlink to the same file"
3046 mlink $DIR/$tdir/s $DIR/$tdir && error "mlink to parent dir"
3047 mlink $DIR/$tdir $DIR/$tdir/s && error "mlink parent dir to target"
3048 mlink $DIR/$tdir/not-exist $DIR/$tdir/foo && error "mlink non-existing to new"
3049 mlink $DIR/$tdir/not-exist $DIR/$tdir/s && error "mlink non-existing to exist"
3052 run_test 31k "link to file: the same, non-existing, dir==============="
3058 touch $DIR/d31m2/exist
3059 mlink $DIR/d31m/s $DIR/d31m2/t || error "mlink"
3060 mlink $DIR/d31m/s $DIR/d31m2/exist && error "mlink to exist file"
3061 mlink $DIR/d31m/s $DIR/d31m2 && error "mlink to parent dir"
3062 mlink $DIR/d31m2 $DIR/d31m/s && error "mlink parent dir to target"
3063 mlink $DIR/d31m/not-exist $DIR/d31m2/foo && error "mlink non-existing to new"
3064 mlink $DIR/d31m/not-exist $DIR/d31m2/s && error "mlink non-existing to exist"
3067 run_test 31m "link to file: the same, non-existing, dir==============="
3070 touch $DIR/$tfile || error "cannot create '$DIR/$tfile'"
3071 nlink=$(stat --format=%h $DIR/$tfile)
3072 [ ${nlink:--1} -eq 1 ] || error "nlink is $nlink, expected 1"
3074 local cmd="exec $fd<$DIR/$tfile"
3077 trap "eval $cmd" EXIT
3078 nlink=$(stat --dereference --format=%h /proc/self/fd/$fd)
3079 [ ${nlink:--1} -eq 1 ] || error "nlink is $nlink, expected 1"
3080 rm $DIR/$tfile || error "cannot remove '$DIR/$tfile'"
3081 nlink=$(stat --dereference --format=%h /proc/self/fd/$fd)
3082 [ ${nlink:--1} -eq 0 ] || error "nlink is $nlink, expected 0"
3085 run_test 31n "check link count of unlinked file"
3088 local TEMPNAME=$(mktemp $1_XXXXXX)
3089 mlink $TEMPNAME $1 2> /dev/null &&
3090 echo "$BASHPID: link $TEMPNAME to $1 succeeded"
3094 test_31o() { # LU-2901
3095 test_mkdir $DIR/$tdir
3096 for LOOP in $(seq 100); do
3097 rm -f $DIR/$tdir/$tfile*
3098 for THREAD in $(seq 8); do
3099 link_one $DIR/$tdir/$tfile.$LOOP &
3102 local LINKS=$(ls -1 $DIR/$tdir | grep -c $tfile.$LOOP)
3103 [[ $LINKS -gt 1 ]] && ls $DIR/$tdir &&
3104 error "$LINKS duplicate links to $tfile.$LOOP" &&
3108 run_test 31o "duplicate hard links with same filename"
3111 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
3113 test_mkdir $DIR/$tdir
3114 $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
3115 $LFS setdirstripe -D -c2 -H all_char $DIR/$tdir/striped_dir
3117 opendirunlink $DIR/$tdir/striped_dir/test1 ||
3118 error "open unlink test1 failed"
3119 opendirunlink $DIR/$tdir/striped_dir/test2 ||
3120 error "open unlink test2 failed"
3122 $CHECKSTAT -a $DIR/$tdir/striped_dir/test1 ||
3123 error "test1 still exists"
3124 $CHECKSTAT -a $DIR/$tdir/striped_dir/test2 ||
3125 error "test2 still exists"
3127 run_test 31p "remove of open striped directory"
3129 cleanup_test32_mount() {
3132 local loopdev=$(losetup -a | grep $EXT2_DEV | sed -ne 's/:.*$//p')
3133 $UMOUNT $DIR/$tdir/ext2-mountpoint || rc=$?
3134 losetup -d $loopdev || true
3140 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3142 echo "== more mountpoints and symlinks ================="
3143 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
3144 trap cleanup_test32_mount EXIT
3145 test_mkdir -p $DIR/$tdir/ext2-mountpoint
3146 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
3147 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
3148 $CHECKSTAT -t dir $DIR/$tdir/ext2-mountpoint/.. ||
3149 error "$DIR/$tdir/ext2-mountpoint/.. not dir type"
3150 cleanup_test32_mount
3152 run_test 32a "stat d32a/ext2-mountpoint/.. ====================="
3155 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3157 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
3158 trap cleanup_test32_mount EXIT
3159 test_mkdir -p $DIR/$tdir/ext2-mountpoint
3160 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
3161 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
3162 ls -al $DIR/$tdir/ext2-mountpoint/.. ||
3163 error "Can't list $DIR/$tdir/ext2-mountpoint/.."
3164 cleanup_test32_mount
3166 run_test 32b "open d32b/ext2-mountpoint/.. ====================="
3169 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3171 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
3172 trap cleanup_test32_mount EXIT
3173 test_mkdir -p $DIR/$tdir/ext2-mountpoint
3174 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
3175 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
3176 test_mkdir -p $DIR/$tdir/d2/test_dir
3177 $CHECKSTAT -t dir $DIR/$tdir/ext2-mountpoint/../d2/test_dir ||
3178 error "$DIR/$tdir/ext2-mountpoint/../d2/test_dir not dir type"
3179 cleanup_test32_mount
3181 run_test 32c "stat d32c/ext2-mountpoint/../d2/test_dir ========="
3184 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3186 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
3187 trap cleanup_test32_mount EXIT
3188 test_mkdir -p $DIR/$tdir/ext2-mountpoint
3189 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
3190 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
3191 test_mkdir -p $DIR/$tdir/d2/test_dir
3192 ls -al $DIR/$tdir/ext2-mountpoint/../d2/test_dir ||
3193 error "Can't list $DIR/$tdir/ext2-mountpoint/../d2/test_dir"
3194 cleanup_test32_mount
3196 run_test 32d "open d32d/ext2-mountpoint/../d2/test_dir"
3200 test_mkdir -p $DIR/$tdir/tmp
3201 local tmp_dir=$DIR/$tdir/tmp
3202 ln -s $DIR/$tdir $tmp_dir/symlink11
3203 ln -s $tmp_dir/symlink11 $tmp_dir/../symlink01
3204 $CHECKSTAT -t link $DIR/$tdir/tmp/symlink11 || error "symlink11 bad"
3205 $CHECKSTAT -t link $DIR/$tdir/symlink01 || error "symlink01 bad"
3207 run_test 32e "stat d32e/symlink->tmp/symlink->lustre-subdir"
3211 test_mkdir -p $DIR/$tdir/tmp
3212 local tmp_dir=$DIR/$tdir/tmp
3213 ln -s $DIR/$tdir $tmp_dir/symlink11
3214 ln -s $tmp_dir/symlink11 $tmp_dir/../symlink01
3215 ls $DIR/$tdir/tmp/symlink11 || error "symlink11 bad"
3216 ls $DIR/$tdir/symlink01 || error "symlink01 bad"
3218 run_test 32f "open d32f/symlink->tmp/symlink->lustre-subdir"
3221 local tmp_dir=$DIR/$tdir/tmp
3222 test_mkdir -p $tmp_dir
3223 test_mkdir $DIR/${tdir}2
3224 ln -s $DIR/${tdir}2 $tmp_dir/symlink12
3225 ln -s $tmp_dir/symlink12 $tmp_dir/../symlink02
3226 $CHECKSTAT -t link $tmp_dir/symlink12 || error "symlink12 not a link"
3227 $CHECKSTAT -t link $DIR/$tdir/symlink02 || error "symlink02 not a link"
3228 $CHECKSTAT -t dir -f $tmp_dir/symlink12 || error "symlink12 not a dir"
3229 $CHECKSTAT -t dir -f $DIR/$tdir/symlink02 || error "symlink12 not a dir"
3231 run_test 32g "stat d32g/symlink->tmp/symlink->lustre-subdir/${tdir}2"
3234 rm -fr $DIR/$tdir $DIR/${tdir}2
3235 tmp_dir=$DIR/$tdir/tmp
3236 test_mkdir -p $tmp_dir
3237 test_mkdir $DIR/${tdir}2
3238 ln -s $DIR/${tdir}2 $tmp_dir/symlink12
3239 ln -s $tmp_dir/symlink12 $tmp_dir/../symlink02
3240 ls $tmp_dir/symlink12 || error "listing symlink12"
3241 ls $DIR/$tdir/symlink02 || error "listing symlink02"
3243 run_test 32h "open d32h/symlink->tmp/symlink->lustre-subdir/${tdir}2"
3246 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3248 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
3249 trap cleanup_test32_mount EXIT
3250 test_mkdir -p $DIR/$tdir/ext2-mountpoint
3251 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
3252 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
3253 touch $DIR/$tdir/test_file
3254 $CHECKSTAT -t file $DIR/$tdir/ext2-mountpoint/../test_file ||
3255 error "$DIR/$tdir/ext2-mountpoint/../test_file not file type"
3256 cleanup_test32_mount
3258 run_test 32i "stat d32i/ext2-mountpoint/../test_file ==========="
3261 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3263 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
3264 trap cleanup_test32_mount EXIT
3265 test_mkdir -p $DIR/$tdir/ext2-mountpoint
3266 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
3267 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
3268 touch $DIR/$tdir/test_file
3269 cat $DIR/$tdir/ext2-mountpoint/../test_file ||
3270 error "Can't open $DIR/$tdir/ext2-mountpoint/../test_file"
3271 cleanup_test32_mount
3273 run_test 32j "open d32j/ext2-mountpoint/../test_file ==========="
3276 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3279 trap cleanup_test32_mount EXIT
3280 test_mkdir -p $DIR/$tdir/ext2-mountpoint
3281 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
3282 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
3283 test_mkdir -p $DIR/$tdir/d2
3284 touch $DIR/$tdir/d2/test_file || error "touch failed"
3285 $CHECKSTAT -t file $DIR/$tdir/ext2-mountpoint/../d2/test_file ||
3286 error "$DIR/$tdir/ext2-mountpoint/../d2/test_file not file type"
3287 cleanup_test32_mount
3289 run_test 32k "stat d32k/ext2-mountpoint/../d2/test_file ========"
3292 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3295 trap cleanup_test32_mount EXIT
3296 test_mkdir -p $DIR/$tdir/ext2-mountpoint
3297 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
3298 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
3299 test_mkdir -p $DIR/$tdir/d2
3300 touch $DIR/$tdir/d2/test_file || error "touch failed"
3301 cat $DIR/$tdir/ext2-mountpoint/../d2/test_file ||
3302 error "Can't open $DIR/$tdir/ext2-mountpoint/../d2/test_file"
3303 cleanup_test32_mount
3305 run_test 32l "open d32l/ext2-mountpoint/../d2/test_file ========"
3309 test_mkdir -p $DIR/d32m/tmp
3310 TMP_DIR=$DIR/d32m/tmp
3311 ln -s $DIR $TMP_DIR/symlink11
3312 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
3313 $CHECKSTAT -t link $DIR/d32m/tmp/symlink11 ||
3314 error "symlink11 not a link"
3315 $CHECKSTAT -t link $DIR/d32m/symlink01 ||
3316 error "symlink01 not a link"
3318 run_test 32m "stat d32m/symlink->tmp/symlink->lustre-root ======"
3322 test_mkdir -p $DIR/d32n/tmp
3323 TMP_DIR=$DIR/d32n/tmp
3324 ln -s $DIR $TMP_DIR/symlink11
3325 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
3326 ls -l $DIR/d32n/tmp/symlink11 || error "listing symlink11"
3327 ls -l $DIR/d32n/symlink01 || error "listing symlink01"
3329 run_test 32n "open d32n/symlink->tmp/symlink->lustre-root ======"
3333 test_mkdir -p $DIR/d32o/tmp
3334 TMP_DIR=$DIR/d32o/tmp
3335 ln -s $DIR/$tfile $TMP_DIR/symlink12
3336 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
3337 $CHECKSTAT -t link $DIR/d32o/tmp/symlink12 ||
3338 error "symlink12 not a link"
3339 $CHECKSTAT -t link $DIR/d32o/symlink02 || error "symlink02 not a link"
3340 $CHECKSTAT -t file -f $DIR/d32o/tmp/symlink12 ||
3341 error "$DIR/d32o/tmp/symlink12 not file type"
3342 $CHECKSTAT -t file -f $DIR/d32o/symlink02 ||
3343 error "$DIR/d32o/symlink02 not file type"
3345 run_test 32o "stat d32o/symlink->tmp/symlink->lustre-root/$tfile"
3355 test_mkdir -p $DIR/d32p/tmp
3357 TMP_DIR=$DIR/d32p/tmp
3359 ln -s $DIR/$tfile $TMP_DIR/symlink12
3361 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02