3 # Run select tests by setting ONLY, or as arguments to the script.
4 # Skip specific tests by setting EXCEPT.
6 # e.g. ONLY="22 23" or ONLY="`seq 32 39`" or EXCEPT="31"
11 # Check Grants after these tests
12 GRANT_CHECK_LIST="$GRANT_CHECK_LIST 42a 42b 42c 42d 42e 63a 63b 64a 64b 64c 64d"
17 CREATETEST=${CREATETEST:-createtest}
18 LVERIFY=${LVERIFY:-ll_dirstripe_verify}
19 OPENFILE=${OPENFILE:-openfile}
20 OPENUNLINK=${OPENUNLINK:-openunlink}
21 READS=${READS:-"reads"}
22 MUNLINK=${MUNLINK:-munlink}
23 SOCKETSERVER=${SOCKETSERVER:-socketserver}
24 SOCKETCLIENT=${SOCKETCLIENT:-socketclient}
25 MEMHOG=${MEMHOG:-memhog}
26 DIRECTIO=${DIRECTIO:-directio}
27 ACCEPTOR_PORT=${ACCEPTOR_PORT:-988}
29 CHECK_GRANT=${CHECK_GRANT:-"yes"}
30 GRANT_CHECK_LIST=${GRANT_CHECK_LIST:-""}
31 export PARALLEL=${PARALLEL:-"no"}
34 LUSTRE=${LUSTRE:-$(dirname $0)/..}
35 LUSTRE_TESTS_API_DIR=${LUSTRE_TESTS_API_DIR:-${LUSTRE}/tests/clientapi}
36 . $LUSTRE/tests/test-framework.sh
41 ALWAYS_EXCEPT="$SANITY_EXCEPT "
42 # bug number for skipped test: LU-9693 LU-6493 LU-9693
43 ALWAYS_EXCEPT+=" 42a 42b 42c "
44 # bug number: LU-8411 LU-9054 LU-13314
45 ALWAYS_EXCEPT+=" 407 312 56ob"
48 # bug number: LU-9795 LU-9795 LU-9795 LU-9795
49 ALWAYS_EXCEPT+=" 17n 60a 133g 300f"
52 selinux_status=$(getenforce)
53 if [ "$selinux_status" != "Disabled" ]; then
58 # skip the grant tests for ARM until they are fixed
59 if [[ $(uname -m) = aarch64 ]]; then
60 # bug number: LU-11596
61 ALWAYS_EXCEPT+=" $GRANT_CHECK_LIST"
62 # bug number: LU-11671 LU-11667
63 ALWAYS_EXCEPT+=" 45 317"
66 # skip nfs tests on kernels >= 4.14.0 until they are fixed
67 if [ $LINUX_VERSION_CODE -ge $(version_code 4.14.0) ]; then
68 # bug number: LU-12661
71 # skip cgroup tests on RHEL8.1 kernels until they are fixed
72 if (( $LINUX_VERSION_CODE >= $(version_code 4.18.0) &&
73 $LINUX_VERSION_CODE < $(version_code 5.4.0) )); then
74 # bug number: LU-13063
79 [ "$SLOW" = "no" ] && EXCEPT_SLOW="27m 64b 68 71 115 135 136 300o"
81 if [ "$mds1_FSTYPE" = "zfs" ]; then
82 # bug number for skipped test:
83 ALWAYS_EXCEPT="$ALWAYS_EXCEPT "
85 [ "$SLOW" = "no" ] && EXCEPT_SLOW="$EXCEPT_SLOW 51b"
88 # Get the SLES distro version
90 # Returns a version string that should only be used in comparing
91 # strings returned by version_code()
94 local version=$(grep VERSION_ID /etc/os-release | cut -d'"' -f2)
96 # All SuSE Linux versions have one decimal. version_code expects two
97 local sles_version=$version.0
98 version_code $sles_version
101 # Check if we are running on Ubuntu or SLES so we can make decisions on
103 if [ -r /etc/SuSE-release ]; then
104 sles_version=$(sles_version_code)
105 [ $sles_version -lt $(version_code 11.4.0) ] &&
106 # bug number for skipped test: LU-4341
107 ALWAYS_EXCEPT="$ALWAYS_EXCEPT 170"
108 [ $sles_version -lt $(version_code 12.0.0) ] &&
109 # bug number for skipped test: LU-3703
110 ALWAYS_EXCEPT="$ALWAYS_EXCEPT 234"
111 elif [ -r /etc/os-release ]; then
112 if grep -qi ubuntu /etc/os-release; then
113 ubuntu_version=$(version_code $(sed -n -e 's/"//g' \
114 -e 's/^VERSION=//p' \
118 if [[ $ubuntu_version -gt $(version_code 16.0.0) ]]; then
119 # bug number for skipped test:
121 ALWAYS_EXCEPT+=" 103a 410"
131 pgrep ll_sa > /dev/null && { echo "There are ll_sa thread not exit!"; exit 20; }
132 cleanupall ${FORCE} $* || { echo "FAILed to clean up"; exit 20; }
141 check_swap_layouts_support()
143 $LCTL get_param -n llite.*.sbi_flags | grep -q layout ||
144 skip "Does not support layout lock."
147 check_and_setup_lustre
151 MAXFREE=${MAXFREE:-$((200000 * $OSTCOUNT))}
153 [ -f $DIR/d52a/foo ] && chattr -a $DIR/d52a/foo
154 [ -f $DIR/d52b/foo ] && chattr -i $DIR/d52b/foo
155 rm -rf $DIR/[Rdfs][0-9]*
157 # $RUNAS_ID may get set incorrectly somewhere else
158 [ $UID -eq 0 -a $RUNAS_ID -eq 0 ] &&
159 error "\$RUNAS_ID set to 0, but \$UID is also 0!"
161 check_runas_id $RUNAS_ID $RUNAS_GID $RUNAS
163 if [ "${ONLY}" = "MOUNT" ] ; then
164 echo "Lustre is up, please go on"
168 echo "preparing for tests involving mounts"
169 EXT2_DEV=${EXT2_DEV:-$TMP/SANITY.LOOP}
171 mke2fs -j -F $EXT2_DEV 8000 > /dev/null
172 echo # add a newline after mke2fs.
176 OLDDEBUG=$(lctl get_param -n debug 2> /dev/null)
177 lctl set_param debug=-1 2> /dev/null || true
180 $CHECKSTAT -t file $DIR/$tfile || error "$tfile is not a file"
182 $CHECKSTAT -a $DIR/$tfile || error "$tfile was not removed"
184 run_test 0a "touch; rm ====================="
187 chmod 0755 $DIR || error "chmod 0755 $DIR failed"
188 $CHECKSTAT -p 0755 $DIR || error "$DIR permission is not 0755"
190 run_test 0b "chmod 0755 $DIR ============================="
193 $LCTL get_param mdc.*.import | grep "state: FULL" ||
194 error "import not FULL"
195 $LCTL get_param mdc.*.import | grep "target: $FSNAME-MDT" ||
198 run_test 0c "check import proc"
200 test_0d() { # LU-3397
201 [ $MGS_VERSION -lt $(version_code 2.10.57) ] &&
202 skip "proc exports not supported before 2.10.57"
204 local mgs_exp="mgs.MGS.exports"
205 local client_uuid=$($LCTL get_param -n mgc.*.uuid)
207 local exp_client_version
210 local temp_imp=$DIR/$tfile.import
211 local temp_exp=$DIR/$tfile.export
213 # save mgc import file to $temp_imp
214 $LCTL get_param mgc.*.import | tee $temp_imp
215 # Check if client uuid is found in MGS export
216 for exp_client_nid in $(do_facet mgs $LCTL get_param -N $mgs_exp.*); do
217 [ $(do_facet mgs $LCTL get_param -n $exp_client_nid.uuid) == \
221 # save mgs export file to $temp_exp
222 do_facet mgs $LCTL get_param $exp_client_nid.export | tee $temp_exp
224 # Compare the value of field "connect_flags"
225 imp_val=$(grep "connect_flags" $temp_imp)
226 exp_val=$(grep "connect_flags" $temp_exp)
227 [ "$exp_val" == "$imp_val" ] ||
228 error "export flags '$exp_val' != import flags '$imp_val'"
230 # Compare the value of client version
231 exp_client_version=$(awk '/target_version:/ { print $2 }' $temp_exp)
232 exp_val=$(version_code $exp_client_version)
233 imp_val=$CLIENT_VERSION
234 [ "$exp_val" == "$imp_val" ] ||
235 error "export client version '$exp_val' != '$imp_val'"
237 run_test 0d "check export proc ============================="
240 test_mkdir $DIR/$tdir
241 test_mkdir $DIR/$tdir/d2
242 mkdir $DIR/$tdir/d2 && error "we expect EEXIST, but not returned"
243 $CHECKSTAT -t dir $DIR/$tdir/d2 || error "$tdir/d2 is not a dir"
246 $CHECKSTAT -a $DIR/$tdir || error "$tdir was not removed"
248 run_test 1 "mkdir; remkdir; rmdir"
251 test_mkdir $DIR/$tdir
252 touch $DIR/$tdir/$tfile || error "touch $tdir/$tfile failed"
253 $CHECKSTAT -t file $DIR/$tdir/$tfile || error "$tdir/$tfile not a file"
255 $CHECKSTAT -a $DIR/$tdir/$tfile || error "$tdir/$file is not removed"
257 run_test 2 "mkdir; touch; rmdir; check file"
260 test_mkdir $DIR/$tdir
261 $CHECKSTAT -t dir $DIR/$tdir || error "$tdir is not a directory"
262 touch $DIR/$tdir/$tfile
263 $CHECKSTAT -t file $DIR/$tdir/$tfile || error "$tdir/$tfile not a file"
265 $CHECKSTAT -a $DIR/$tdir || error "$tdir is not removed"
267 run_test 3 "mkdir; touch; rmdir; check dir"
269 # LU-4471 - failed rmdir on remote directories still removes directory on MDT0
271 test_mkdir -i 1 $DIR/$tdir
273 touch $DIR/$tdir/$tfile ||
274 error "Create file under remote directory failed"
277 error "Expect error removing in-use dir $DIR/$tdir"
279 test -d $DIR/$tdir || error "Remote directory disappeared"
281 rm -rf $DIR/$tdir || error "remove remote dir error"
283 run_test 4 "mkdir; touch dir/file; rmdir; checkdir (expect error)"
286 test_mkdir $DIR/$tdir
287 test_mkdir $DIR/$tdir/d2
288 chmod 0707 $DIR/$tdir/d2 || error "chmod 0707 $tdir/d2 failed"
289 $CHECKSTAT -t dir -p 0707 $DIR/$tdir/d2 || error "$tdir/d2 not mode 707"
290 $CHECKSTAT -t dir $DIR/$tdir/d2 || error "$tdir/d2 is not a directory"
292 run_test 5 "mkdir .../d5 .../d5/d2; chmod .../d5/d2"
295 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
296 chmod 0666 $DIR/$tfile || error "chmod 0666 $tfile failed"
297 $CHECKSTAT -t file -p 0666 -u \#$UID $DIR/$tfile ||
298 error "$tfile does not have perm 0666 or UID $UID"
299 $RUNAS chmod 0444 $DIR/$tfile && error "chmod $tfile worked on UID $UID"
300 $CHECKSTAT -t file -p 0666 -u \#$UID $DIR/$tfile ||
301 error "$tfile should be 0666 and owned by UID $UID"
303 run_test 6a "touch f6a; chmod f6a; $RUNAS chmod f6a (should return error) =="
306 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID"
309 chown $RUNAS_ID $DIR/$tfile || error "chown $RUNAS_ID $file failed"
310 $CHECKSTAT -t file -u \#$RUNAS_ID $DIR/$tfile ||
311 error "$tfile should be owned by UID $RUNAS_ID"
312 $RUNAS chown $UID $DIR/$tfile && error "chown $UID $file succeeded"
313 $CHECKSTAT -t file -u \#$RUNAS_ID $DIR/$tfile ||
314 error "$tfile should be owned by UID $RUNAS_ID"
316 run_test 6c "touch f6c; chown f6c; $RUNAS chown f6c (should return error) =="
319 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID"
322 chgrp $RUNAS_ID $DIR/$tfile || error "chgrp $RUNAS_ID $file failed"
323 $CHECKSTAT -t file -u \#$UID -g \#$RUNAS_ID $DIR/$tfile ||
324 error "$tfile should be owned by GID $UID"
325 $RUNAS chgrp $UID $DIR/$tfile && error "chgrp $UID $file succeeded"
326 $CHECKSTAT -t file -u \#$UID -g \#$RUNAS_ID $DIR/$tfile ||
327 error "$tfile should be owned by UID $UID and GID $RUNAS_ID"
329 run_test 6e "touch+chgrp $tfile; $RUNAS chgrp $tfile (should return error)"
332 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID"
334 test_mkdir $DIR/$tdir
335 chmod 777 $DIR/$tdir || error "chmod 0777 $tdir failed"
336 $RUNAS mkdir $DIR/$tdir/d || error "mkdir $tdir/d failed"
337 chmod g+s $DIR/$tdir/d || error "chmod g+s $tdir/d failed"
338 test_mkdir $DIR/$tdir/d/subdir
339 $CHECKSTAT -g \#$RUNAS_GID $DIR/$tdir/d/subdir ||
340 error "$tdir/d/subdir should be GID $RUNAS_GID"
341 if [[ $MDSCOUNT -gt 1 ]]; then
342 # check remote dir sgid inherite
343 $LFS mkdir -i 0 $DIR/$tdir.local ||
344 error "mkdir $tdir.local failed"
345 chmod g+s $DIR/$tdir.local ||
346 error "chmod $tdir.local failed"
347 chgrp $RUNAS_GID $DIR/$tdir.local ||
348 error "chgrp $tdir.local failed"
349 $LFS mkdir -i 1 $DIR/$tdir.local/$tdir.remote ||
350 error "mkdir $tdir.remote failed"
351 $CHECKSTAT -g \#$RUNAS_GID $DIR/$tdir.local/$tdir.remote ||
352 error "$tdir.remote should be owned by $UID.$RUNAS_ID"
353 $CHECKSTAT -p 02755 $DIR/$tdir.local/$tdir.remote ||
354 error "$tdir.remote should be mode 02755"
357 run_test 6g "verify new dir in sgid dir inherits group"
359 test_6h() { # bug 7331
360 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID"
362 touch $DIR/$tfile || error "touch failed"
363 chown $RUNAS_ID:$RUNAS_GID $DIR/$tfile || error "initial chown failed"
364 $RUNAS -G$RUNAS_GID chown $RUNAS_ID:0 $DIR/$tfile &&
365 error "chown $RUNAS_ID:0 $tfile worked as GID $RUNAS_GID"
366 $CHECKSTAT -t file -u \#$RUNAS_ID -g \#$RUNAS_GID $DIR/$tfile ||
367 error "$tdir/$tfile should be UID $RUNAS_UID GID $RUNAS_GID"
369 run_test 6h "$RUNAS chown RUNAS_ID.0 .../$tfile (should return error)"
372 test_mkdir $DIR/$tdir
373 $MCREATE $DIR/$tdir/$tfile
374 chmod 0666 $DIR/$tdir/$tfile
375 $CHECKSTAT -t file -p 0666 $DIR/$tdir/$tfile ||
376 error "$tdir/$tfile should be mode 0666"
378 run_test 7a "mkdir .../d7; mcreate .../d7/f; chmod .../d7/f ===="
381 if [ ! -d $DIR/$tdir ]; then
382 test_mkdir $DIR/$tdir
384 $MCREATE $DIR/$tdir/$tfile
385 echo -n foo > $DIR/$tdir/$tfile
386 [ "$(cat $DIR/$tdir/$tfile)" = "foo" ] || error "$tdir/$tfile not 'foo'"
387 $CHECKSTAT -t file -s 3 $DIR/$tdir/$tfile || error "$tfile size not 3"
389 run_test 7b "mkdir .../d7; mcreate d7/f2; echo foo > d7/f2 ====="
392 test_mkdir $DIR/$tdir
393 touch $DIR/$tdir/$tfile
394 chmod 0666 $DIR/$tdir/$tfile
395 $CHECKSTAT -t file -p 0666 $DIR/$tdir/$tfile ||
396 error "$tfile mode not 0666"
398 run_test 8 "mkdir .../d8; touch .../d8/f; chmod .../d8/f ======="
401 test_mkdir $DIR/$tdir
402 test_mkdir $DIR/$tdir/d2
403 test_mkdir $DIR/$tdir/d2/d3
404 $CHECKSTAT -t dir $DIR/$tdir/d2/d3 || error "$tdir/d2/d3 not a dir"
406 run_test 9 "mkdir .../d9 .../d9/d2 .../d9/d2/d3 ================"
409 test_mkdir $DIR/$tdir
410 test_mkdir $DIR/$tdir/d2
411 touch $DIR/$tdir/d2/$tfile
412 $CHECKSTAT -t file $DIR/$tdir/d2/$tfile ||
413 error "$tdir/d2/$tfile not a file"
415 run_test 10 "mkdir .../d10 .../d10/d2; touch .../d10/d2/f ======"
418 test_mkdir $DIR/$tdir
419 test_mkdir $DIR/$tdir/d2
420 chmod 0666 $DIR/$tdir/d2
421 chmod 0705 $DIR/$tdir/d2
422 $CHECKSTAT -t dir -p 0705 $DIR/$tdir/d2 ||
423 error "$tdir/d2 mode not 0705"
425 run_test 11 "mkdir .../d11 d11/d2; chmod .../d11/d2 ============"
428 test_mkdir $DIR/$tdir
429 touch $DIR/$tdir/$tfile
430 chmod 0666 $DIR/$tdir/$tfile
431 chmod 0654 $DIR/$tdir/$tfile
432 $CHECKSTAT -t file -p 0654 $DIR/$tdir/$tfile ||
433 error "$tdir/d2 mode not 0654"
435 run_test 12 "touch .../d12/f; chmod .../d12/f .../d12/f ========"
438 test_mkdir $DIR/$tdir
439 dd if=/dev/zero of=$DIR/$tdir/$tfile count=10
441 $CHECKSTAT -t file -s 0 $DIR/$tdir/$tfile ||
442 error "$tdir/$tfile size not 0 after truncate"
444 run_test 13 "creat .../d13/f; dd .../d13/f; > .../d13/f ========"
447 test_mkdir $DIR/$tdir
448 touch $DIR/$tdir/$tfile
450 $CHECKSTAT -a $DIR/$tdir/$tfile || error "$tdir/$tfile not removed"
452 run_test 14 "touch .../d14/f; rm .../d14/f; rm .../d14/f ======="
455 test_mkdir $DIR/$tdir
456 touch $DIR/$tdir/$tfile
457 mv $DIR/$tdir/$tfile $DIR/$tdir/${tfile}_2
458 $CHECKSTAT -t file $DIR/$tdir/${tfile}_2 ||
459 error "$tdir/${tfile_2} not a file after rename"
460 rm $DIR/$tdir/${tfile}_2 || error "unlink failed after rename"
462 run_test 15 "touch .../d15/f; mv .../d15/f .../d15/f2 =========="
465 test_mkdir $DIR/$tdir
466 touch $DIR/$tdir/$tfile
467 rm -rf $DIR/$tdir/$tfile
468 $CHECKSTAT -a $DIR/$tdir/$tfile || error "$tdir/$tfile not removed"
470 run_test 16 "touch .../d16/f; rm -rf .../d16/f"
473 test_mkdir $DIR/$tdir
474 touch $DIR/$tdir/$tfile
475 ln -s $DIR/$tdir/$tfile $DIR/$tdir/l-exist
477 $CHECKSTAT -l $DIR/$tdir/$tfile $DIR/$tdir/l-exist ||
478 error "$tdir/l-exist not a symlink"
479 $CHECKSTAT -f -t f $DIR/$tdir/l-exist ||
480 error "$tdir/l-exist not referencing a file"
481 rm -f $DIR/$tdir/l-exist
482 $CHECKSTAT -a $DIR/$tdir/l-exist || error "$tdir/l-exist not removed"
484 run_test 17a "symlinks: create, remove (real)"
487 test_mkdir $DIR/$tdir
488 ln -s no-such-file $DIR/$tdir/l-dangle
490 $CHECKSTAT -l no-such-file $DIR/$tdir/l-dangle ||
491 error "$tdir/l-dangle not referencing no-such-file"
492 $CHECKSTAT -fa $DIR/$tdir/l-dangle ||
493 error "$tdir/l-dangle not referencing non-existent file"
494 rm -f $DIR/$tdir/l-dangle
495 $CHECKSTAT -a $DIR/$tdir/l-dangle || error "$tdir/l-dangle not removed"
497 run_test 17b "symlinks: create, remove (dangling)"
499 test_17c() { # bug 3440 - don't save failed open RPC for replay
500 test_mkdir $DIR/$tdir
501 ln -s foo $DIR/$tdir/$tfile
502 cat $DIR/$tdir/$tfile && error "opened non-existent symlink" || true
504 run_test 17c "symlinks: open dangling (should return error)"
507 test_mkdir $DIR/$tdir
508 ln -s foo $DIR/$tdir/$tfile
509 touch $DIR/$tdir/$tfile || error "creating to new symlink"
511 run_test 17d "symlinks: create dangling"
514 test_mkdir $DIR/$tdir
515 local foo=$DIR/$tdir/$tfile
516 ln -s $foo $foo || error "create symlink failed"
517 ls -l $foo || error "ls -l failed"
518 ls $foo && error "ls not failed" || true
520 run_test 17e "symlinks: create recursive symlink (should return error)"
523 test_mkdir $DIR/$tdir
524 ln -s 1234567890/2234567890/3234567890/4234567890 $DIR/$tdir/111
525 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890 $DIR/$tdir/222
526 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890 $DIR/$tdir/333
527 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890/9234567890/a234567890/b234567890 $DIR/$tdir/444
528 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890/9234567890/a234567890/b234567890/c234567890/d234567890/f234567890 $DIR/$tdir/555
529 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
532 run_test 17f "symlinks: long and very long symlink name"
534 # str_repeat(S, N) generate a string that is string S repeated N times
539 while [ $((n -= 1)) -ge 0 ]; do
545 # Long symlinks and LU-2241
547 test_mkdir $DIR/$tdir
548 local TESTS="59 60 61 4094 4095"
550 # Fix for inode size boundary in 2.1.4
551 [ $MDS1_VERSION -lt $(version_code 2.1.4) ] &&
554 # Patch not applied to 2.2 or 2.3 branches
555 [ $MDS1_VERSION -ge $(version_code 2.2.0) ] &&
556 [ $MDS1_VERSION -le $(version_code 2.3.55) ] &&
560 local SYMNAME=$(str_repeat 'x' $i)
561 ln -s $SYMNAME $DIR/$tdir/f$i || error "failed $i-char symlink"
562 readlink $DIR/$tdir/f$i || error "failed $i-char readlink"
565 run_test 17g "symlinks: really long symlink name and inode boundaries"
567 test_17h() { #bug 17378
568 [ $PARALLEL == "yes" ] && skip "skip parallel run"
569 remote_mds_nodsh && skip "remote MDS with nodsh"
573 test_mkdir $DIR/$tdir
574 mdt_idx=$($LFS getdirstripe -i $DIR/$tdir)
575 $LFS setstripe -c -1 $DIR/$tdir
576 #define OBD_FAIL_MDS_LOV_PREP_CREATE 0x141
577 do_facet mds$((mdt_idx + 1)) lctl set_param fail_loc=0x80000141
578 touch $DIR/$tdir/$tfile || true
580 run_test 17h "create objects: lov_free_memmd() doesn't lbug"
582 test_17i() { #bug 20018
583 [ $PARALLEL == "yes" ] && skip "skip parallel run"
584 remote_mds_nodsh && skip "remote MDS with nodsh"
586 local foo=$DIR/$tdir/$tfile
589 test_mkdir -c1 $DIR/$tdir
590 mdt_idx=$($LFS getdirstripe -i $DIR/$tdir)
591 ln -s $foo $foo || error "create symlink failed"
592 #define OBD_FAIL_MDS_READLINK_EPROTO 0x143
593 do_facet mds$((mdt_idx + 1)) lctl set_param fail_loc=0x80000143
594 ls -l $foo && error "error not detected"
597 run_test 17i "don't panic on short symlink (should return error)"
599 test_17k() { #bug 22301
600 [ $PARALLEL == "yes" ] && skip "skip parallel run"
601 [[ -z "$(which rsync 2>/dev/null)" ]] &&
602 skip "no rsync command"
603 rsync --help | grep -q xattr ||
604 skip_env "$(rsync --version | head -n1) does not support xattrs"
605 test_mkdir $DIR/$tdir
606 test_mkdir $DIR/$tdir.new
607 touch $DIR/$tdir/$tfile
608 ln -s $DIR/$tdir/$tfile $DIR/$tdir/$tfile.lnk
609 rsync -av -X $DIR/$tdir/ $DIR/$tdir.new ||
610 error "rsync failed with xattrs enabled"
612 run_test 17k "symlinks: rsync with xattrs enabled"
614 test_17l() { # LU-279
615 [[ -z "$(which getfattr 2>/dev/null)" ]] &&
616 skip "no getfattr command"
618 test_mkdir $DIR/$tdir
619 touch $DIR/$tdir/$tfile
620 ln -s $DIR/$tdir/$tfile $DIR/$tdir/$tfile.lnk
621 for path in "$DIR/$tdir" "$DIR/$tdir/$tfile" "$DIR/$tdir/$tfile.lnk"; do
622 # -h to not follow symlinks. -m '' to list all the xattrs.
623 # grep to remove first line: '# file: $path'.
624 for xattr in `getfattr -hm '' $path 2>/dev/null | grep -v '^#'`;
626 lgetxattr_size_check $path $xattr ||
627 error "lgetxattr_size_check $path $xattr failed"
631 run_test 17l "Ensure lgetxattr's returned xattr size is consistent"
635 [ $PARALLEL == "yes" ] && skip "skip parallel run"
636 [ "$mds1_FSTYPE" != "ldiskfs" ] && skip_env "ldiskfs only test"
637 remote_mds_nodsh && skip "remote MDS with nodsh"
638 [ $MDS1_VERSION -ge $(version_code 2.2.0) ] &&
639 [ $MDS1_VERSION -le $(version_code 2.2.93) ] &&
640 skip "MDS 2.2.0-2.2.93 do not NUL-terminate symlinks"
642 local short_sym="0123456789"
643 local wdir=$DIR/$tdir
648 # create a long symlink file
649 for ((i = 0; i < 4; ++i)); do
650 long_sym=${long_sym}${long_sym}
653 echo "create 512 short and long symlink files under $wdir"
654 for ((i = 0; i < 256; ++i)); do
655 ln -sf ${long_sym}"a5a5" $wdir/long-$i
656 ln -sf ${short_sym}"a5a5" $wdir/short-$i
662 wait_delete_completed
664 echo "recreate the 512 symlink files with a shorter string"
665 for ((i = 0; i < 512; ++i)); do
666 # rewrite the symlink file with a shorter string
667 ln -sf ${long_sym} $wdir/long-$i || error "long_sym failed"
668 ln -sf ${short_sym} $wdir/short-$i || error "short_sym failed"
671 local mds_index=$(($($LFS getstripe -m $wdir) + 1))
672 local devname=$(mdsdevname $mds_index)
674 echo "stop and checking mds${mds_index}:"
675 # e2fsck should not return error
677 run_e2fsck $(facet_active_host mds${mds_index}) $devname -n
680 start mds${mds_index} $devname $MDS_MOUNT_OPTS ||
681 error "start mds${mds_index} failed"
682 df $MOUNT > /dev/null 2>&1
684 error "e2fsck detected error for short/long symlink: rc=$rc"
687 run_test 17m "run e2fsck against MDT which contains short/long symlink"
689 check_fs_consistency_17n() {
693 # create/unlink in 17n only change 2 MDTs(MDT1/MDT2),
694 # so it only check MDT1/MDT2 instead of all of MDTs.
695 for mdt_index in 1 2; do
696 local devname=$(mdsdevname $mdt_index)
697 # e2fsck should not return error
699 run_e2fsck $(facet_active_host mds$mdt_index) $devname -n ||
702 start mds${mdt_index} $devname $MDS_MOUNT_OPTS ||
703 error "mount mds$mdt_index failed"
704 df $MOUNT > /dev/null 2>&1
710 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
711 [ $PARALLEL == "yes" ] && skip "skip parallel run"
712 [ "$mds1_FSTYPE" != "ldiskfs" ] && skip_env "ldiskfs only test"
713 remote_mds_nodsh && skip "remote MDS with nodsh"
714 [ $MDS1_VERSION -ge $(version_code 2.2.0) ] &&
715 [ $MDS1_VERSION -le $(version_code 2.2.93) ] &&
716 skip "MDS 2.2.0-2.2.93 do not NUL-terminate symlinks"
720 test_mkdir $DIR/$tdir
721 for ((i=0; i<10; i++)); do
722 $LFS mkdir -i1 -c2 $DIR/$tdir/remote_dir_${i} ||
723 error "create remote dir error $i"
724 createmany -o $DIR/$tdir/remote_dir_${i}/f 10 ||
725 error "create files under remote dir failed $i"
728 check_fs_consistency_17n ||
729 error "e2fsck report error after create files under remote dir"
731 for ((i = 0; i < 10; i++)); do
732 rm -rf $DIR/$tdir/remote_dir_${i} ||
733 error "destroy remote dir error $i"
736 check_fs_consistency_17n ||
737 error "e2fsck report error after unlink files under remote dir"
739 [ $MDS1_VERSION -lt $(version_code 2.4.50) ] &&
740 skip "lustre < 2.4.50 does not support migrate mv"
742 for ((i = 0; i < 10; i++)); do
743 mkdir -p $DIR/$tdir/remote_dir_${i}
744 createmany -o $DIR/$tdir/remote_dir_${i}/f 10 ||
745 error "create files under remote dir failed $i"
746 $LFS migrate --mdt-index 1 $DIR/$tdir/remote_dir_${i} ||
747 error "migrate remote dir error $i"
749 check_fs_consistency_17n || error "e2fsck report error after migration"
751 for ((i = 0; i < 10; i++)); do
752 rm -rf $DIR/$tdir/remote_dir_${i} ||
753 error "destroy remote dir error $i"
756 check_fs_consistency_17n || error "e2fsck report error after unlink"
758 run_test 17n "run e2fsck against master/slave MDT which contains remote dir"
761 remote_mds_nodsh && skip "remote MDS with nodsh"
762 [ $MDS1_VERSION -lt $(version_code 2.3.64) ] &&
763 skip "Need MDS version at least 2.3.64"
765 local wdir=$DIR/${tdir}o
771 mdt_index=$($LFS getstripe -m $wdir/$tfile)
772 mdt_index=$((mdt_index + 1))
775 #fail mds will wait the failover finish then set
776 #following fail_loc to avoid interfer the recovery process.
779 #define OBD_FAIL_OSD_LMA_INCOMPAT 0x194
780 do_facet mds${mdt_index} lctl set_param fail_loc=0x194
781 ls -l $wdir/$tfile && rc=1
782 do_facet mds${mdt_index} lctl set_param fail_loc=0
783 [[ $rc -eq 0 ]] || error "stat file should fail"
785 run_test 17o "stat file with incompat LMA feature"
788 touch $DIR/$tfile || error "Failed to touch $DIR/$tfile: $?"
789 ls $DIR || error "Failed to ls $DIR: $?"
791 run_test 18 "touch .../f ; ls ... =============================="
797 $CHECKSTAT -a $DIR/$tfile || error "$tfile was not removed"
799 run_test 19a "touch .../f19 ; ls -l ... ; rm .../f19 ==========="
802 ls -l $DIR/$tfile && error "ls -l $tfile failed"|| true
804 run_test 19b "ls -l .../f19 (should return error) =============="
807 [ $RUNAS_ID -eq $UID ] &&
808 skip_env "RUNAS_ID = UID = $UID -- skipping"
810 $RUNAS touch $DIR/$tfile && error "create non-root file failed" || true
812 run_test 19c "$RUNAS touch .../f19 (should return error) =="
815 cat $DIR/f19 && error || true
817 run_test 19d "cat .../f19 (should return error) =============="
826 $CHECKSTAT -a $DIR/$tfile || error "$tfile was not removed"
828 run_test 20 "touch .../f ; ls -l ..."
831 test_mkdir $DIR/$tdir
832 [ -f $DIR/$tdir/dangle ] && rm -f $DIR/$tdir/dangle
833 ln -s dangle $DIR/$tdir/link
834 echo foo >> $DIR/$tdir/link
835 cat $DIR/$tdir/dangle
836 $CHECKSTAT -t link $DIR/$tdir/link || error "$tdir/link not a link"
837 $CHECKSTAT -f -t file $DIR/$tdir/link ||
838 error "$tdir/link not linked to a file"
840 run_test 21 "write to dangling link"
843 local wdir=$DIR/$tdir
845 chown $RUNAS_ID:$RUNAS_GID $wdir
846 (cd $wdir || error "cd $wdir failed";
847 $RUNAS tar cf - /etc/hosts /etc/sysconfig/network |
849 ls -lR $wdir/etc || error "ls -lR $wdir/etc failed"
850 $CHECKSTAT -t dir $wdir/etc || error "checkstat -t dir failed"
851 $CHECKSTAT -u \#$RUNAS_ID -g \#$RUNAS_GID $wdir/etc ||
852 error "checkstat -u failed"
854 run_test 22 "unpack tar archive as non-root user"
858 test_mkdir $DIR/$tdir
859 local file=$DIR/$tdir/$tfile
861 openfile -f O_CREAT:O_EXCL $file || error "$file create failed"
862 openfile -f O_CREAT:O_EXCL $file &&
863 error "$file recreate succeeded" || true
865 run_test 23a "O_CREAT|O_EXCL in subdir"
867 test_23b() { # bug 18988
868 test_mkdir $DIR/$tdir
869 local file=$DIR/$tdir/$tfile
872 echo foo > $file || error "write filed"
873 echo bar >> $file || error "append filed"
874 $CHECKSTAT -s 8 $file || error "wrong size"
877 run_test 23b "O_APPEND check"
879 # LU-9409, size with O_APPEND and tiny writes
881 local file=$DIR/$tfile
884 dd conv=notrunc oflag=append if=/dev/zero of=$file bs=8 count=800
885 $CHECKSTAT -s 6400 $file || error "wrong size, expected 6400"
889 dd conv=notrunc oflag=append if=/dev/zero of=$file bs=8 count=800 &
890 dd conv=notrunc oflag=append if=/dev/zero of=$file bs=8 count=800 &
892 $CHECKSTAT -s 12800 $file || error "wrong size, expected 12800"
895 #racing tiny & normal writes
896 dd conv=notrunc oflag=append if=/dev/zero of=$file bs=4096 count=4 &
897 dd conv=notrunc oflag=append if=/dev/zero of=$file bs=8 count=100 &
899 $CHECKSTAT -s 17184 $file || error "wrong size, expected 17184"
902 #racing tiny & normal writes 2, ugly numbers
903 dd conv=notrunc oflag=append if=/dev/zero of=$file bs=4099 count=11 &
904 dd conv=notrunc oflag=append if=/dev/zero of=$file bs=17 count=173 &
906 $CHECKSTAT -s 48030 $file || error "wrong size, expected 48030"
909 run_test 23c "O_APPEND size checks for tiny writes"
911 # LU-11069 file offset is correct after appending writes
913 local file=$DIR/$tfile
916 echo CentaurHauls > $file
917 offset=$($MULTIOP $file oO_WRONLY:O_APPEND:w13Zp)
918 if ((offset != 26)); then
919 error "wrong offset, expected 26, got '$offset'"
922 run_test 23d "file offset is correct after appending writes"
926 echo '-- same directory rename'
927 test_mkdir $DIR/$tdir
928 touch $DIR/$tdir/$tfile.1
929 mv $DIR/$tdir/$tfile.1 $DIR/$tdir/$tfile.2
930 $CHECKSTAT -t file $DIR/$tdir/$tfile.2 || error "$tfile.2 not a file"
932 run_test 24a "rename file to non-existent target"
935 test_mkdir $DIR/$tdir
936 touch $DIR/$tdir/$tfile.{1,2}
937 mv $DIR/$tdir/$tfile.1 $DIR/$tdir/$tfile.2
938 $CHECKSTAT -a $DIR/$tdir/$tfile.1 || error "$tfile.1 exists"
939 $CHECKSTAT -t file $DIR/$tdir/$tfile.2 || error "$tfile.2 not a file"
941 run_test 24b "rename file to existing target"
944 test_mkdir $DIR/$tdir
945 test_mkdir $DIR/$tdir/d$testnum.1
946 mv $DIR/$tdir/d$testnum.1 $DIR/$tdir/d$testnum.2
947 $CHECKSTAT -a $DIR/$tdir/d$testnum.1 || error "d$testnum.1 exists"
948 $CHECKSTAT -t dir $DIR/$tdir/d$testnum.2 || error "d$testnum.2 not dir"
950 run_test 24c "rename directory to non-existent target"
953 test_mkdir -c1 $DIR/$tdir
954 test_mkdir -c1 $DIR/$tdir/d$testnum.1
955 test_mkdir -c1 $DIR/$tdir/d$testnum.2
956 mrename $DIR/$tdir/d$testnum.1 $DIR/$tdir/d$testnum.2
957 $CHECKSTAT -a $DIR/$tdir/d$testnum.1 || error "d$testnum.1 exists"
958 $CHECKSTAT -t dir $DIR/$tdir/d$testnum.2 || error "d$testnum.2 not dir"
960 run_test 24d "rename directory to existing target"
963 echo '-- cross directory renames --'
967 mv $DIR/R5a/f $DIR/R5b/g
968 $CHECKSTAT -a $DIR/R5a/f || error "$DIR/R5a/f exists"
969 $CHECKSTAT -t file $DIR/R5b/g || error "$DIR/R5b/g not file type"
971 run_test 24e "touch .../R5a/f; rename .../R5a/f .../R5b/g ======"
976 touch $DIR/R6a/f $DIR/R6b/g
977 mv $DIR/R6a/f $DIR/R6b/g
978 $CHECKSTAT -a $DIR/R6a/f || error "$DIR/R6a/f exists"
979 $CHECKSTAT -t file $DIR/R6b/g || error "$DIR/R6b/g not file type"
981 run_test 24f "touch .../R6a/f R6b/g; mv .../R6a/f .../R6b/g ===="
986 test_mkdir $DIR/R7a/d
987 mv $DIR/R7a/d $DIR/R7b/e
988 $CHECKSTAT -a $DIR/R7a/d || error "$DIR/R7a/d exists"
989 $CHECKSTAT -t dir $DIR/R7b/e || error "$DIR/R7b/e not dir type"
991 run_test 24g "mkdir .../R7{a,b}/d; mv .../R7a/d .../R7b/e ======"
994 test_mkdir -c1 $DIR/R8a
995 test_mkdir -c1 $DIR/R8b
996 test_mkdir -c1 $DIR/R8a/d
997 test_mkdir -c1 $DIR/R8b/e
998 mrename $DIR/R8a/d $DIR/R8b/e
999 $CHECKSTAT -a $DIR/R8a/d || error "$DIR/R8a/d exists"
1000 $CHECKSTAT -t dir $DIR/R8b/e || error "$DIR/R8b/e not dir type"
1002 run_test 24h "mkdir .../R8{a,b}/{d,e}; rename .../R8a/d .../R8b/e"
1005 echo "-- rename error cases"
1007 test_mkdir $DIR/R9/a
1009 mrename $DIR/R9/f $DIR/R9/a
1010 $CHECKSTAT -t file $DIR/R9/f || error "$DIR/R9/f not file type"
1011 $CHECKSTAT -t dir $DIR/R9/a || error "$DIR/R9/a not dir type"
1012 $CHECKSTAT -a $DIR/R9/a/f || error "$DIR/R9/a/f exists"
1014 run_test 24i "rename file to dir error: touch f ; mkdir a ; rename f a"
1018 mrename $DIR/R10/f $DIR/R10/g
1019 $CHECKSTAT -t dir $DIR/R10 || error "$DIR/R10 not dir type"
1020 $CHECKSTAT -a $DIR/R10/f || error "$DIR/R10/f exists"
1021 $CHECKSTAT -a $DIR/R10/g || error "$DIR/R10/g exists"
1023 run_test 24j "source does not exist ============================"
1026 test_mkdir $DIR/R11a
1027 test_mkdir $DIR/R11a/d
1029 mv $DIR/R11a/f $DIR/R11a/d
1030 $CHECKSTAT -a $DIR/R11a/f || error "$DIR/R11a/f exists"
1031 $CHECKSTAT -t file $DIR/R11a/d/f || error "$DIR/R11a/d/f not file type"
1033 run_test 24k "touch .../R11a/f; mv .../R11a/f .../R11a/d ======="
1035 # bug 2429 - rename foo foo foo creates invalid file
1038 $MULTIOP $f OcNs || error "rename of ${f} to itself failed"
1040 run_test 24l "Renaming a file to itself ========================"
1044 $MULTIOP $f OcLN ${f}2 ${f}2 || error "link ${f}2 ${f}2 failed"
1045 # on ext3 this does not remove either the source or target files
1046 # though the "expected" operation would be to remove the source
1047 $CHECKSTAT -t file ${f} || error "${f} missing"
1048 $CHECKSTAT -t file ${f}2 || error "${f}2 missing"
1050 run_test 24m "Renaming a file to a hard link to itself ========="
1054 # this stats the old file after it was renamed, so it should fail
1056 $CHECKSTAT ${f} || error "${f} missing"
1058 $CHECKSTAT ${f}.rename || error "${f}.rename missing"
1059 $CHECKSTAT -a ${f} || error "${f} exists"
1061 run_test 24n "Statting the old file after renaming (Posix rename 2)"
1064 test_mkdir $DIR/$tdir
1065 rename_many -s random -v -n 10 $DIR/$tdir
1067 run_test 24o "rename of files during htree split"
1070 test_mkdir $DIR/R12a
1071 test_mkdir $DIR/R12b
1072 DIRINO=`ls -lid $DIR/R12a | awk '{ print $1 }'`
1073 mrename $DIR/R12a $DIR/R12b
1074 $CHECKSTAT -a $DIR/R12a || error "$DIR/R12a exists"
1075 $CHECKSTAT -t dir $DIR/R12b || error "$DIR/R12b not dir type"
1076 DIRINO2=`ls -lid $DIR/R12b | awk '{ print $1 }'`
1077 [ "$DIRINO" = "$DIRINO2" ] || error "R12a $DIRINO != R12b $DIRINO2"
1079 run_test 24p "mkdir .../R12{a,b}; rename .../R12a .../R12b"
1081 cleanup_multiop_pause() {
1083 kill -USR1 $MULTIPID
1087 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1089 test_mkdir $DIR/R13a
1090 test_mkdir $DIR/R13b
1091 local DIRINO=$(ls -lid $DIR/R13a | awk '{ print $1 }')
1092 multiop_bg_pause $DIR/R13b D_c || error "multiop failed to start"
1095 trap cleanup_multiop_pause EXIT
1096 mrename $DIR/R13a $DIR/R13b
1097 $CHECKSTAT -a $DIR/R13a || error "R13a still exists"
1098 $CHECKSTAT -t dir $DIR/R13b || error "R13b does not exist"
1099 local DIRINO2=$(ls -lid $DIR/R13b | awk '{ print $1 }')
1100 [ "$DIRINO" = "$DIRINO2" ] || error "R13a $DIRINO != R13b $DIRINO2"
1101 cleanup_multiop_pause
1102 wait $MULTIPID || error "multiop close failed"
1104 run_test 24q "mkdir .../R13{a,b}; open R13b rename R13a R13b ==="
1106 test_24r() { #bug 3789
1107 test_mkdir $DIR/R14a
1108 test_mkdir $DIR/R14a/b
1109 mrename $DIR/R14a $DIR/R14a/b && error "rename to subdir worked!"
1110 $CHECKSTAT -t dir $DIR/R14a || error "$DIR/R14a missing"
1111 $CHECKSTAT -t dir $DIR/R14a/b || error "$DIR/R14a/b missing"
1113 run_test 24r "mkdir .../R14a/b; rename .../R14a .../R14a/b ====="
1116 test_mkdir $DIR/R15a
1117 test_mkdir $DIR/R15a/b
1118 test_mkdir $DIR/R15a/b/c
1119 mrename $DIR/R15a $DIR/R15a/b/c && error "rename to sub-subdir worked!"
1120 $CHECKSTAT -t dir $DIR/R15a || error "$DIR/R15a missing"
1121 $CHECKSTAT -t dir $DIR/R15a/b/c || error "$DIR/R15a/b/c missing"
1123 run_test 24s "mkdir .../R15a/b/c; rename .../R15a .../R15a/b/c ="
1125 test_mkdir $DIR/R16a
1126 test_mkdir $DIR/R16a/b
1127 test_mkdir $DIR/R16a/b/c
1128 mrename $DIR/R16a/b/c $DIR/R16a && error "rename to sub-subdir worked!"
1129 $CHECKSTAT -t dir $DIR/R16a || error "$DIR/R16a missing"
1130 $CHECKSTAT -t dir $DIR/R16a/b/c || error "$DIR/R16a/b/c missing"
1132 run_test 24t "mkdir .../R16a/b/c; rename .../R16a/b/c .../R16a ="
1134 test_24u() { # bug12192
1135 $MULTIOP $DIR/$tfile C2w$((2048 * 1024))c || error "multiop failed"
1136 $CHECKSTAT -s $((2048 * 1024)) $DIR/$tfile || error "wrong file size"
1138 run_test 24u "create stripe file"
1140 simple_cleanup_common() {
1143 [ -z "$DIR" ] || [ -z "$tdir" ] && return 0
1145 local start=$SECONDS
1148 wait_delete_completed
1149 echo "cleanup time $((SECONDS - start))"
1153 max_pages_per_rpc() {
1154 local mdtname="$(printf "MDT%04x" ${1:-0})"
1155 $LCTL get_param -n mdc.*$mdtname*.max_pages_per_rpc
1159 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1161 local nrfiles=${COUNT:-100000}
1162 local fname="$DIR/$tdir/$tfile"
1164 # Performance issue on ZFS see LU-4072 (c.f. LU-2887)
1165 [ "$mds1_FSTYPE" = "zfs" ] && nrfiles=${COUNT:-10000}
1167 test_mkdir "$(dirname $fname)"
1168 # assume MDT0000 has the fewest inodes
1169 local stripes=$($LFS getdirstripe -c $(dirname $fname))
1170 local free_inodes=$(($(mdt_free_inodes 0) * stripes))
1171 [[ $free_inodes -lt $nrfiles ]] && nrfiles=$free_inodes
1173 trap simple_cleanup_common EXIT
1175 createmany -m "$fname" $nrfiles
1177 cancel_lru_locks mdc
1178 lctl set_param mdc.*.stats clear
1180 # was previously test_24D: LU-6101
1181 # readdir() returns correct number of entries after cursor reload
1182 local num_ls=$(ls $DIR/$tdir | wc -l)
1183 local num_uniq=$(ls $DIR/$tdir | sort -u | wc -l)
1184 local num_all=$(ls -a $DIR/$tdir | wc -l)
1185 if [ $num_ls -ne $nrfiles ] || [ $num_uniq -ne $nrfiles ] ||
1186 [ $num_all -ne $((nrfiles + 2)) ]; then
1187 error "Expected $nrfiles files, got $num_ls " \
1188 "($num_uniq unique $num_all .&..)"
1190 # LU-5 large readdir
1191 # dirent_size = 32 bytes for sizeof(struct lu_dirent) +
1192 # N bytes for name (len($nrfiles) rounded to 8 bytes) +
1193 # 8 bytes for luda_type (4 bytes rounded to 8 bytes)
1194 # take into account of overhead in lu_dirpage header and end mark in
1195 # each page, plus one in rpc_num calculation.
1196 local dirent_size=$((32 + (${#tfile} | 7) + 1 + 8))
1197 local page_entries=$(((PAGE_SIZE - 24) / dirent_size))
1198 local mdt_idx=$($LFS getdirstripe -i $(dirname $fname))
1199 local rpc_pages=$(max_pages_per_rpc $mdt_idx)
1200 local rpc_max=$((nrfiles / (page_entries * rpc_pages) + stripes))
1201 local mds_readpage=$(calc_stats mdc.*.stats mds_readpage)
1202 echo "readpages: $mds_readpage rpc_max: $rpc_max"
1203 (( $mds_readpage < $rpc_max - 2 || $mds_readpage > $rpc_max + 1)) &&
1204 error "large readdir doesn't take effect: " \
1205 "$mds_readpage should be about $rpc_max"
1207 simple_cleanup_common
1209 run_test 24v "list large directory (test hash collision, b=17560)"
1211 test_24w() { # bug21506
1213 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=4096 || return 1
1214 dd if=/dev/zero bs=$SZ1 count=1 >> $DIR/$tfile || return 2
1215 dd if=$DIR/$tfile of=$DIR/${tfile}_left bs=1M skip=4097 || return 3
1216 SZ2=`ls -l $DIR/${tfile}_left | awk '{print $5}'`
1217 [[ "$SZ1" -eq "$SZ2" ]] ||
1218 error "Error reading at the end of the file $tfile"
1220 run_test 24w "Reading a file larger than 4Gb"
1223 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
1224 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1225 [[ $MDS1_VERSION -lt $(version_code 2.7.56) ]] &&
1226 skip "Need MDS version at least 2.7.56"
1229 local remote_dir=$DIR/$tdir/remote_dir
1231 test_mkdir $DIR/$tdir
1232 $LFS mkdir -i $MDTIDX $remote_dir ||
1233 error "create remote directory failed"
1235 test_mkdir $DIR/$tdir/src_dir
1236 touch $DIR/$tdir/src_file
1237 test_mkdir $remote_dir/tgt_dir
1238 touch $remote_dir/tgt_file
1240 mrename $DIR/$tdir/src_dir $remote_dir/tgt_dir ||
1241 error "rename dir cross MDT failed!"
1243 mrename $DIR/$tdir/src_file $remote_dir/tgt_file ||
1244 error "rename file cross MDT failed!"
1246 touch $DIR/$tdir/ln_file
1247 ln $DIR/$tdir/ln_file $remote_dir/ln_name ||
1248 error "ln file cross MDT failed"
1250 rm -rf $DIR/$tdir || error "Can not delete directories"
1252 run_test 24x "cross MDT rename/link"
1255 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
1256 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1258 local remote_dir=$DIR/$tdir/remote_dir
1261 test_mkdir $DIR/$tdir
1262 $LFS mkdir -i $mdtidx $remote_dir ||
1263 error "create remote directory failed"
1265 test_mkdir $remote_dir/src_dir
1266 touch $remote_dir/src_file
1267 test_mkdir $remote_dir/tgt_dir
1268 touch $remote_dir/tgt_file
1270 mrename $remote_dir/src_dir $remote_dir/tgt_dir ||
1271 error "rename subdir in the same remote dir failed!"
1273 mrename $remote_dir/src_file $remote_dir/tgt_file ||
1274 error "rename files in the same remote dir failed!"
1276 ln $remote_dir/tgt_file $remote_dir/tgt_file1 ||
1277 error "link files in the same remote dir failed!"
1279 rm -rf $DIR/$tdir || error "Can not delete directories"
1281 run_test 24y "rename/link on the same dir should succeed"
1284 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
1285 [[ $MDS1_VERSION -lt $(version_code 2.12.51) ]] &&
1286 skip "Need MDS version at least 2.12.51"
1290 for index in 0 1; do
1291 $LFS mkdir -i $index $DIR/$tdir.$index || error "mkdir failed"
1292 touch $DIR/$tdir.0/$tfile.$index || error "touch failed"
1295 mv $DIR/$tdir.0/$tfile.0 $DIR/$tdir.1 || error "mv $tfile.0 failed"
1297 index=$($LFS getstripe -m $DIR/$tdir.1/$tfile.0)
1298 [ $index -eq 0 ] || error "$tfile.0 is on MDT$index"
1300 local mdts=$(comma_list $(mdts_nodes))
1302 do_nodes $mdts $LCTL set_param mdt.*.enable_remote_rename=0
1303 stack_trap "do_nodes $mdts $LCTL \
1304 set_param mdt.*.enable_remote_rename=1" EXIT
1306 mv $DIR/$tdir.0/$tfile.1 $DIR/$tdir.1 || error "mv $tfile.1 failed"
1308 index=$($LFS getstripe -m $DIR/$tdir.1/$tfile.1)
1309 [ $index -eq 1 ] || error "$tfile.1 is on MDT$index"
1311 run_test 24z "cross-MDT rename is done as cp"
1313 test_24A() { # LU-3182
1317 test_mkdir $DIR/$tdir
1318 trap simple_cleanup_common EXIT
1319 createmany -m $DIR/$tdir/$tfile $NFILES
1320 local t=$(ls $DIR/$tdir | wc -l)
1321 local u=$(ls $DIR/$tdir | sort -u | wc -l)
1322 local v=$(ls -ai $DIR/$tdir | sort -u | wc -l)
1323 if [ $t -ne $NFILES ] || [ $u -ne $NFILES ] ||
1324 [ $v -ne $((NFILES + 2)) ] ; then
1325 error "Expected $NFILES files, got $t ($u unique $v .&..)"
1328 simple_cleanup_common || error "Can not delete directories"
1330 run_test 24A "readdir() returns correct number of entries."
1332 test_24B() { # LU-4805
1333 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
1337 test_mkdir $DIR/$tdir
1338 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR/$tdir/striped_dir ||
1339 error "create striped dir failed"
1341 count=$(ls -ai $DIR/$tdir/striped_dir | wc -l)
1342 [ $count -eq 2 ] || error "Expected 2, got $count"
1344 touch $DIR/$tdir/striped_dir/a
1346 count=$(ls -ai $DIR/$tdir/striped_dir | wc -l)
1347 [ $count -eq 3 ] || error "Expected 3, got $count"
1349 touch $DIR/$tdir/striped_dir/.f
1351 count=$(ls -ai $DIR/$tdir/striped_dir | wc -l)
1352 [ $count -eq 4 ] || error "Expected 4, got $count"
1354 rm -rf $DIR/$tdir || error "Can not delete directories"
1356 run_test 24B "readdir for striped dir return correct number of entries"
1359 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
1365 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR/$tdir/d0/striped_dir ||
1366 error "create striped dir failed"
1368 cd $DIR/$tdir/d0/striped_dir
1370 local d0_ino=$(ls -i -l -a $DIR/$tdir | grep "d0" | awk '{print $1}')
1371 local d1_ino=$(ls -i -l -a $DIR/$tdir | grep "d1" | awk '{print $1}')
1372 local parent_ino=$(ls -i -l -a | grep "\.\." | awk '{print $1}')
1374 [ "$d0_ino" = "$parent_ino" ] ||
1375 error ".. wrong, expect $d0_ino, get $parent_ino"
1377 mv $DIR/$tdir/d0/striped_dir $DIR/$tdir/d1/ ||
1378 error "mv striped dir failed"
1380 parent_ino=$(ls -i -l -a | grep "\.\." | awk '{print $1}')
1382 [ "$d1_ino" = "$parent_ino" ] ||
1383 error ".. wrong after mv, expect $d1_ino, get $parent_ino"
1385 run_test 24C "check .. in striped dir"
1388 [[ $MDSCOUNT -lt 4 ]] && skip_env "needs >= 4 MDTs"
1389 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1392 mkdir $DIR/$tdir/src_dir
1393 $LFS mkdir -i 1 $DIR/$tdir/src_dir/src_child ||
1394 error "create remote source failed"
1396 touch $DIR/$tdir/src_dir/src_child/a
1398 $LFS mkdir -i 2 $DIR/$tdir/tgt_dir ||
1399 error "create remote target dir failed"
1401 $LFS mkdir -i 3 $DIR/$tdir/tgt_dir/tgt_child ||
1402 error "create remote target child failed"
1404 mrename $DIR/$tdir/src_dir/src_child $DIR/$tdir/tgt_dir/tgt_child ||
1405 error "rename dir cross MDT failed!"
1409 $CHECKSTAT -t dir $DIR/$tdir/src_dir/src_child &&
1410 error "src_child still exists after rename"
1412 $CHECKSTAT -t file $DIR/$tdir/tgt_dir/tgt_child/a ||
1413 error "missing file(a) after rename"
1415 rm -rf $DIR/$tdir || error "Can not delete directories"
1417 run_test 24E "cross MDT rename/link"
1420 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
1423 [ "$SLOW" = "no" ] && repeats=100
1427 echo "$repeats repeats"
1428 for ((i = 0; i < repeats; i++)); do
1429 $LFS mkdir -i0 -c2 $DIR/$tdir/test || error "mkdir fails"
1430 touch $DIR/$tdir/test/a || error "touch fails"
1431 mkdir $DIR/$tdir/test/b || error "mkdir fails"
1432 rm -rf $DIR/$tdir/test || error "rmdir fails"
1437 run_test 24F "hash order vs readdir (LU-11330)"
1440 echo '== symlink sanity ============================================='
1444 touch $DIR/s25/foo ||
1445 error "File creation in symlinked directory failed"
1447 run_test 25a "create file in symlinked directory ==============="
1450 [ ! -d $DIR/d25 ] && test_25a
1451 $CHECKSTAT -t file $DIR/s25/foo || error "$DIR/s25/foo not file type"
1453 run_test 25b "lookup file in symlinked directory ==============="
1457 test_mkdir $DIR/d26/d26-2
1458 ln -s d26/d26-2 $DIR/s26
1459 touch $DIR/s26/foo || error "File creation failed"
1461 run_test 26a "multiple component symlink ======================="
1464 test_mkdir -p $DIR/$tdir/d26-2
1465 ln -s $tdir/d26-2/foo $DIR/s26-2
1466 touch $DIR/s26-2 || error "File creation failed"
1468 run_test 26b "multiple component symlink at end of lookup ======"
1471 test_mkdir $DIR/d26.2
1472 touch $DIR/d26.2/foo
1473 ln -s d26.2 $DIR/s26.2-1
1474 ln -s s26.2-1 $DIR/s26.2-2
1475 ln -s s26.2-2 $DIR/s26.2-3
1476 chmod 0666 $DIR/s26.2-3/foo
1478 run_test 26c "chain of symlinks"
1480 # recursive symlinks (bug 439)
1482 ln -s d26-3/foo $DIR/d26-3
1484 run_test 26d "create multiple component recursive symlink"
1487 [ ! -h $DIR/d26-3 ] && test_26d
1490 run_test 26e "unlink multiple component recursive symlink"
1492 # recursive symlinks (bug 7022)
1494 test_mkdir $DIR/$tdir
1495 test_mkdir $DIR/$tdir/$tfile
1496 cd $DIR/$tdir/$tfile || error "cd $DIR/$tdir/$tfile failed"
1497 test_mkdir -p lndir/bar1
1498 test_mkdir $DIR/$tdir/$tfile/$tfile
1499 cd $tfile || error "cd $tfile failed"
1500 ln -s .. dotdot || error "ln dotdot failed"
1501 ln -s dotdot/lndir lndir || error "ln lndir failed"
1502 cd $DIR/$tdir || error "cd $DIR/$tdir failed"
1503 output=`ls $tfile/$tfile/lndir/bar1`
1504 [ "$output" = bar1 ] && error "unexpected output"
1505 rm -r $tfile || error "rm $tfile failed"
1506 $CHECKSTAT -a $DIR/$tfile || error "$tfile not gone"
1508 run_test 26f "rm -r of a directory which has recursive symlink"
1511 test_mkdir $DIR/$tdir
1512 $LFS getstripe $DIR/$tdir
1513 $LFS setstripe -c 1 $DIR/$tdir/$tfile || error "setstripe failed"
1514 $CHECKSTAT -t file $DIR/$tdir/$tfile || error "checkstat failed"
1515 cp /etc/hosts $DIR/$tdir/$tfile || error "Can't copy to one stripe file"
1517 run_test 27a "one stripe file"
1520 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
1522 test_mkdir $DIR/$tdir
1523 $LFS setstripe -c 2 $DIR/$tdir/$tfile || error "setstripe failed"
1524 $LFS getstripe -c $DIR/$tdir/$tfile
1525 [ $($LFS getstripe -c $DIR/$tdir/$tfile) -eq 2 ] ||
1526 error "two-stripe file doesn't have two stripes"
1528 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=4k count=4 || error "dd failed"
1530 run_test 27b "create and write to two stripe file"
1532 # 27c family tests specific striping, setstripe -o
1534 [[ $OSTCOUNT -lt 2 ]] && skip_env "skipping 2-stripe test"
1535 test_mkdir -p $DIR/$tdir
1538 $LFS setstripe -o $osts $DIR/$tdir/$tfile || error "setstripe failed"
1539 $LFS getstripe -i $DIR/$tdir/$tfile
1540 [ $($LFS getstripe -i $DIR/$tdir/$tfile ) -eq $osts ] ||
1541 error "stripe not on specified OST"
1543 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=4 || error "dd failed"
1545 run_test 27ca "one stripe on specified OST"
1548 [[ $OSTCOUNT -lt 2 ]] && skip_env "skipping 2-stripe test"
1549 test_mkdir -p $DIR/$tdir
1551 $LFS setstripe -o $osts $DIR/$tdir/$tfile || error "setstripe failed"
1552 local getstripe=$($LFS getstripe $DIR/$tdir/$tfile)
1555 # Strip getstripe output to a space separated list of OSTs
1556 local getstripe_osts=$(echo "$getstripe" | sed -e '1,/obdidx/d' |\
1557 awk '{print $1}' | tr '\n' '\ ' | sed -e 's/[[:space:]]*$//')
1558 [ "$getstripe_osts" = "${osts//,/ }" ] ||
1559 error "stripes not on specified OSTs"
1561 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=4 || error "dd failed"
1563 run_test 27cb "two stripes on specified OSTs"
1566 [[ $OSTCOUNT -lt 2 ]] && skip_env "skipping 2-stripe test"
1567 [[ $($LCTL get_param mdc.*.import) =~ connect_flags.*overstriping ]] ||
1568 skip "server does not support overstriping"
1570 test_mkdir -p $DIR/$tdir
1572 $LFS setstripe -o $osts $DIR/$tdir/$tfile || error "setstripe failed"
1573 local getstripe=$($LFS getstripe $DIR/$tdir/$tfile)
1576 # Strip getstripe output to a space separated list of OSTs
1577 local getstripe_osts=$(echo "$getstripe" | sed -e '1,/obdidx/d' |\
1578 awk '{print $1}' | tr '\n' '\ ' | sed -e 's/[[:space:]]*$//')
1579 [ "$getstripe_osts" = "${osts//,/ }" ] ||
1580 error "stripes not on specified OSTs"
1582 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=4 || error "dd failed"
1584 run_test 27cc "two stripes on the same OST"
1587 [[ $OSTCOUNT -lt 2 ]] && skip_env "skipping 2-stripe test"
1588 [[ $($LCTL get_param mdc.*.import) =~ connect_flags.*overstriping ]] ||
1589 skip "server does not support overstriping"
1590 test_mkdir -p $DIR/$tdir
1591 local osts="0,1,1,0"
1592 $LFS setstripe -o $osts $DIR/$tdir/$tfile || error "setstripe failed"
1593 local getstripe=$($LFS getstripe $DIR/$tdir/$tfile)
1596 # Strip getstripe output to a space separated list of OSTs
1597 local getstripe_osts=$(echo "$getstripe" | sed -e '1,/obdidx/d' |\
1598 awk '{print $1}' | tr '\n' '\ ' | sed -e 's/[[:space:]]*$//')
1599 [ "$getstripe_osts" = "${osts//,/ }" ] ||
1600 error "stripes not on specified OSTs"
1602 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=4 || error "dd failed"
1604 run_test 27cd "four stripes on two OSTs"
1607 [[ $OSTCOUNT -ge $(($LOV_MAX_STRIPE_COUNT / 2)) ]] &&
1608 skip_env "too many osts, skipping"
1609 [[ $($LCTL get_param mdc.*.import) =~ connect_flags.*overstriping ]] ||
1610 skip "server does not support overstriping"
1611 # We do one more stripe than we have OSTs
1612 [ $OSTCOUNT -ge 159 ] || large_xattr_enabled ||
1613 skip_env "ea_inode feature disabled"
1615 test_mkdir -p $DIR/$tdir
1617 for i in $(seq 0 $OSTCOUNT);
1620 if [ $i -ne $OSTCOUNT ]; then
1624 $LFS setstripe -o $osts $DIR/$tdir/$tfile || error "setstripe failed"
1625 local getstripe=$($LFS getstripe $DIR/$tdir/$tfile)
1628 # Strip getstripe output to a space separated list of OSTs
1629 local getstripe_osts=$(echo "$getstripe" | sed -e '1,/obdidx/d' |\
1630 awk '{print $1}' | tr '\n' '\ ' | sed -e 's/[[:space:]]*$//')
1631 [ "$getstripe_osts" = "${osts//,/ }" ] ||
1632 error "stripes not on specified OSTs"
1634 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=4 || error "dd failed"
1636 run_test 27ce "more stripes than OSTs with -o"
1639 local osp_proc="osp.$FSNAME-OST0000-osc-MDT000*.active"
1642 test_mkdir -p $DIR/$tdir || error "failed to mkdir $DIR/$tdir"
1643 do_facet $SINGLEMDS "$LCTL set_param -n $osp_proc=0"
1644 stack_trap "do_facet $SINGLEMDS $LCTL set_param -n $osp_proc=1" EXIT
1645 wait_update_facet $SINGLEMDS "$LCTL get_param -n $osp_proc | grep 1" ||
1646 error "failed to set $osp_proc=0"
1648 $LFS setstripe -o 0 $DIR/$tdir/$tfile &
1651 do_facet $SINGLEMDS "$LCTL set_param -n $osp_proc=1"
1652 wait_update_facet $SINGLEMDS "$LCTL get_param -n $osp_proc | grep 0" ||
1653 error "failed to set $osp_proc=1"
1656 error "should return error due to $osp_proc=0"
1658 run_test 27cf "'setstripe -o' on inactive OSTs should return error"
1661 test_mkdir $DIR/$tdir
1662 $LFS setstripe -c 0 -i -1 -S 0 $DIR/$tdir/$tfile ||
1663 error "setstripe failed"
1664 $CHECKSTAT -t file $DIR/$tdir/$tfile || error "checkstat failed"
1665 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=4k count=4 || error "dd failed"
1667 run_test 27d "create file with default settings"
1670 # LU-5839 adds check for existed layout before setting it
1671 [[ $MDS1_VERSION -lt $(version_code 2.7.56) ]] &&
1672 skip "Need MDS version at least 2.7.56"
1674 test_mkdir $DIR/$tdir
1675 $LFS setstripe -c 2 $DIR/$tdir/$tfile || error "setstripe failed"
1676 $LFS setstripe -c 2 $DIR/$tdir/$tfile && error "setstripe worked twice"
1677 $CHECKSTAT -t file $DIR/$tdir/$tfile || error "checkstat failed"
1679 run_test 27e "setstripe existing file (should return error)"
1682 test_mkdir $DIR/$tdir
1683 $LFS setstripe -S 100 -i 0 -c 1 $DIR/$tdir/$tfile &&
1684 error "$LFS setstripe $DIR/$tdir/$tfile failed"
1685 $CHECKSTAT -t file $DIR/$tdir/$tfile &&
1686 error "$CHECKSTAT -t file $DIR/$tdir/$tfile should fail"
1687 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=4k count=4 || error "dd failed"
1688 $LFS getstripe $DIR/$tdir/$tfile || error "$LFS getstripe failed"
1690 run_test 27f "setstripe with bad stripe size (should return error)"
1693 test_mkdir $DIR/$tdir
1694 $MCREATE $DIR/$tdir/$tfile || error "mcreate failed"
1695 $LFS getstripe $DIR/$tdir/$tfile 2>&1 | grep "no stripe info" ||
1696 error "$DIR/$tdir/$tfile has object"
1698 run_test 27g "$LFS getstripe with no objects"
1701 test_mkdir $DIR/$tdir
1702 touch $DIR/$tdir/$tfile || error "touch failed"
1703 ln -s bogus $DIR/$tdir/$tfile.2 || error "ln failed"
1704 $LFS getstripe -m $DIR/$tdir/$tfile $DIR/$tdir/$tfile.2
1706 (( rc == 2 )) || error "getstripe did not return ENOENT"
1708 run_test 27ga "$LFS getstripe with missing file (should return error)"
1711 test_mkdir $DIR/$tdir
1712 touch $DIR/$tdir/$tfile || error "touch failed"
1713 [[ $($LFS getstripe -c $DIR/$tdir/$tfile) -gt 0 ]] ||
1714 error "missing objects"
1716 run_test 27i "$LFS getstripe with some objects"
1719 test_mkdir $DIR/$tdir
1720 $LFS setstripe -i $OSTCOUNT $DIR/$tdir/$tfile &&
1721 error "setstripe failed" || true
1723 run_test 27j "setstripe with bad stripe offset (should return error)"
1725 test_27k() { # bug 2844
1726 test_mkdir $DIR/$tdir
1727 local file=$DIR/$tdir/$tfile
1728 local ll_max_blksize=$((4 * 1024 * 1024))
1729 $LFS setstripe -S 67108864 $file || error "setstripe failed"
1730 local blksize=$(stat $file | awk '/IO Block:/ { print $7 }')
1731 [ $blksize -le $ll_max_blksize ] || error "1:$blksize > $ll_max_blksize"
1732 dd if=/dev/zero of=$file bs=4k count=1
1733 blksize=$(stat $file | awk '/IO Block:/ { print $7 }')
1734 [ $blksize -le $ll_max_blksize ] || error "2:$blksize > $ll_max_blksize"
1736 run_test 27k "limit i_blksize for broken user apps"
1739 mcreate $DIR/$tfile || error "creating file"
1740 $RUNAS $LFS setstripe -c 1 $DIR/$tfile &&
1741 error "setstripe should have failed" || true
1743 run_test 27l "check setstripe permissions (should return error)"
1746 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
1748 [ -n "$RCLIENTS" -o -n "$MOUNT_2" ] &&
1749 skip_env "multiple clients -- skipping"
1751 ORIGFREE=$($LCTL get_param -n lov.$FSNAME-clilov-*.kbytesavail |
1753 if [[ $ORIGFREE -gt $MAXFREE ]]; then
1754 skip "$ORIGFREE > $MAXFREE skipping out-of-space test on OST0"
1756 trap simple_cleanup_common EXIT
1757 test_mkdir $DIR/$tdir
1758 $LFS setstripe -i 0 -c 1 $DIR/$tdir/$tfile.1
1759 dd if=/dev/zero of=$DIR/$tdir/$tfile.1 bs=1024 count=$MAXFREE &&
1760 error "dd should fill OST0"
1762 while $LFS setstripe -i 0 -c 1 $DIR/$tdir/$tfile.$i; do
1764 [ $i -gt 256 ] && break
1767 touch $DIR/$tdir/$tfile.$i
1768 [ $($LFS getstripe $DIR/$tdir/$tfile.$i | grep -A 10 obdidx |
1769 awk '{print $1}'| grep -w "0") ] &&
1770 error "OST0 was full but new created file still use it"
1772 touch $DIR/$tdir/$tfile.$i
1773 [ $($LFS getstripe $DIR/$tdir/$tfile.$i | grep -A 10 obdidx |
1774 awk '{print $1}'| grep -w "0") ] &&
1775 error "OST0 was full but new created file still use it"
1776 simple_cleanup_common
1778 run_test 27m "create file while OST0 was full"
1780 # OSCs keep a NOSPC flag that will be reset after ~5s (qos_maxage)
1781 # if the OST isn't full anymore.
1783 local ostidx=${1:-""}
1788 local list=$(comma_list $(osts_nodes))
1789 [ "$ostidx" ] && list=$(facet_host ost$((ostidx + 1)))
1791 do_nodes $list lctl set_param fail_loc=0
1792 wait_delete_completed # initiate all OST_DESTROYs from MDS to OST
1793 delay=$(do_facet $SINGLEMDS lctl get_param -n lov.*.qos_maxage |
1794 awk '{print $1 * 2;exit;}')
1795 get_prealloc="$LCTL get_param -n osc.*MDT*.prealloc_status |
1797 wait_update_facet $SINGLEMDS "$get_prealloc" "" $delay
1800 __exhaust_precreations() {
1803 local FAILIDX=${3:-$OSTIDX}
1804 local ofacet=ost$((OSTIDX + 1))
1806 test_mkdir -p -c1 $DIR/$tdir
1807 local mdtidx=$($LFS getstripe -m $DIR/$tdir)
1808 local mfacet=mds$((mdtidx + 1))
1809 echo OSTIDX=$OSTIDX MDTIDX=$mdtidx
1811 local OST=$(ostname_from_index $OSTIDX)
1814 local mdtosc_proc1=$(get_mdtosc_proc_path $mfacet $OST)
1815 local last_id=$(do_facet $mfacet lctl get_param -n \
1816 osp.$mdtosc_proc1.prealloc_last_id)
1817 local next_id=$(do_facet $mfacet lctl get_param -n \
1818 osp.$mdtosc_proc1.prealloc_next_id)
1820 local mdtosc_proc2=$(get_mdtosc_proc_path $mfacet)
1821 do_facet $mfacet lctl get_param osp.$mdtosc_proc2.prealloc*
1823 test_mkdir -p $DIR/$tdir/${OST}
1824 $LFS setstripe -i $OSTIDX -c 1 $DIR/$tdir/${OST}
1825 #define OBD_FAIL_OST_ENOSPC 0x215
1826 do_facet $ofacet lctl set_param fail_val=$FAILIDX fail_loc=0x215
1827 echo "Creating to objid $last_id on ost $OST..."
1828 createmany -o $DIR/$tdir/${OST}/f $next_id $((last_id - next_id + 2))
1829 do_facet $mfacet lctl get_param osp.$mdtosc_proc2.prealloc*
1830 do_facet $ofacet lctl set_param fail_loc=$FAILLOC
1833 exhaust_precreations() {
1834 __exhaust_precreations $1 $2 $3
1838 exhaust_all_precreations() {
1840 for (( i=0; i < OSTCOUNT; i++ )) ; do
1841 __exhaust_precreations $i $1 -1
1847 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
1848 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1849 remote_mds_nodsh && skip "remote MDS with nodsh"
1850 remote_ost_nodsh && skip "remote OST with nodsh"
1853 rm -f $DIR/$tdir/$tfile
1854 exhaust_precreations 0 0x80000215
1855 $LFS setstripe -c -1 $DIR/$tdir || error "setstripe failed"
1856 touch $DIR/$tdir/$tfile || error "touch failed"
1857 $LFS getstripe $DIR/$tdir/$tfile
1860 run_test 27n "create file with some full OSTs"
1863 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
1864 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1865 remote_mds_nodsh && skip "remote MDS with nodsh"
1866 remote_ost_nodsh && skip "remote OST with nodsh"
1869 rm -f $DIR/$tdir/$tfile
1870 exhaust_all_precreations 0x215
1872 touch $DIR/$tdir/$tfile && error "able to create $DIR/$tdir/$tfile"
1877 run_test 27o "create file with all full OSTs (should error)"
1880 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
1881 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1882 remote_mds_nodsh && skip "remote MDS with nodsh"
1883 remote_ost_nodsh && skip "remote OST with nodsh"
1886 rm -f $DIR/$tdir/$tfile
1887 test_mkdir $DIR/$tdir
1889 $MCREATE $DIR/$tdir/$tfile || error "mcreate failed"
1890 $TRUNCATE $DIR/$tdir/$tfile 80000000 || error "truncate failed"
1891 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat failed"
1893 exhaust_precreations 0 0x80000215
1894 echo foo >> $DIR/$tdir/$tfile || error "append failed"
1895 $CHECKSTAT -s 80000004 $DIR/$tdir/$tfile || error "checkstat failed"
1896 $LFS getstripe $DIR/$tdir/$tfile
1900 run_test 27p "append to a truncated file with some full OSTs"
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
1911 test_mkdir $DIR/$tdir
1912 $MCREATE $DIR/$tdir/$tfile || error "mcreate $DIR/$tdir/$tfile failed"
1913 $TRUNCATE $DIR/$tdir/$tfile 80000000 ||
1914 error "truncate $DIR/$tdir/$tfile failed"
1915 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat failed"
1917 exhaust_all_precreations 0x215
1919 echo foo >> $DIR/$tdir/$tfile && error "append succeeded"
1920 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat 2 failed"
1924 run_test 27q "append to truncated file with all OSTs full (should error)"
1927 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
1928 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1929 remote_mds_nodsh && skip "remote MDS with nodsh"
1930 remote_ost_nodsh && skip "remote OST with nodsh"
1933 rm -f $DIR/$tdir/$tfile
1934 exhaust_precreations 0 0x80000215
1936 $LFS setstripe -i 0 -c 2 $DIR/$tdir/$tfile || error "setstripe failed"
1940 run_test 27r "stripe file with some full OSTs (shouldn't LBUG) ="
1942 test_27s() { # bug 10725
1943 test_mkdir $DIR/$tdir
1944 local stripe_size=$((4096 * 1024 * 1024)) # 2^32
1945 local stripe_count=0
1946 [ $OSTCOUNT -eq 1 ] || stripe_count=2
1947 $LFS setstripe -S $stripe_size -c $stripe_count $DIR/$tdir &&
1948 error "stripe width >= 2^32 succeeded" || true
1951 run_test 27s "lsm_xfersize overflow (should error) (bug 10725)"
1953 test_27t() { # bug 10864
1958 $WLFS getstripe $tfile
1961 run_test 27t "check that utils parse path correctly"
1963 test_27u() { # bug 4900
1964 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
1965 remote_mds_nodsh && skip "remote MDS with nodsh"
1968 local list=$(comma_list $(mdts_nodes))
1970 #define OBD_FAIL_MDS_OSC_PRECREATE 0x139
1971 do_nodes $list $LCTL set_param fail_loc=0x139
1972 test_mkdir -p $DIR/$tdir
1973 trap simple_cleanup_common EXIT
1974 createmany -o $DIR/$tdir/t- 1000
1975 do_nodes $list $LCTL set_param fail_loc=0
1977 TLOG=$TMP/$tfile.getstripe
1978 $LFS getstripe $DIR/$tdir > $TLOG
1979 OBJS=$(awk -vobj=0 '($1 == 0) { obj += 1 } END { print obj; }' $TLOG)
1980 unlinkmany $DIR/$tdir/t- 1000
1982 [[ $OBJS -gt 0 ]] &&
1983 error "$OBJS objects created on OST-0. See $TLOG" ||
1986 run_test 27u "skip object creation on OSC w/o objects"
1988 test_27v() { # bug 4900
1989 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
1990 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1991 remote_mds_nodsh && skip "remote MDS with nodsh"
1992 remote_ost_nodsh && skip "remote OST with nodsh"
1994 exhaust_all_precreations 0x215
1997 $LFS setstripe -c 1 $DIR/$tdir # 1 stripe / file
1999 touch $DIR/$tdir/$tfile
2000 #define OBD_FAIL_TGT_DELAY_PRECREATE 0x705
2002 for (( i=1; i < OSTCOUNT; i++ )); do
2003 do_facet ost$i lctl set_param fail_loc=0x705
2005 local START=`date +%s`
2006 createmany -o $DIR/$tdir/$tfile 32
2008 local FINISH=`date +%s`
2009 local TIMEOUT=`lctl get_param -n timeout`
2010 local PROCESS=$((FINISH - START))
2011 [ $PROCESS -ge $((TIMEOUT / 2)) ] && \
2012 error "$FINISH - $START >= $TIMEOUT / 2"
2013 sleep $((TIMEOUT / 2 - PROCESS))
2016 run_test 27v "skip object creation on slow OST"
2018 test_27w() { # bug 10997
2019 test_mkdir $DIR/$tdir
2020 $LFS setstripe -S 65536 $DIR/$tdir/f0 || error "setstripe failed"
2021 [ $($LFS getstripe -S $DIR/$tdir/f0) -ne 65536 ] &&
2022 error "stripe size $size != 65536" || true
2023 [ $($LFS getstripe -d $DIR/$tdir | grep -c "stripe_count") -eq 0 ] &&
2024 error "$LFS getstripe -d $DIR/$tdir no 'stripe_count'" || true
2026 run_test 27w "check $LFS setstripe -S and getstrip -d options"
2029 [[ $OSTCOUNT -lt 2 ]] &&
2030 skip_env "skipping multiple stripe count/offset test"
2032 test_mkdir $DIR/$tdir
2033 for i in $(seq 1 $OSTCOUNT); do
2035 $LFS setstripe -c $i -i $offset $DIR/$tdir/f$i ||
2036 error "setstripe -c $i -i $offset failed"
2037 count=$($LFS getstripe -c $DIR/$tdir/f$i)
2038 index=$($LFS getstripe -i $DIR/$tdir/f$i)
2039 [ $count -ne $i ] && error "stripe count $count != $i" || true
2040 [ $index -ne $offset ] &&
2041 error "stripe offset $index != $offset" || true
2044 run_test 27wa "check $LFS setstripe -c -i options"
2047 remote_ost_nodsh && skip "remote OST with nodsh"
2048 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
2049 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2051 OFFSET=$(($OSTCOUNT - 1))
2053 local OST=$(ostname_from_index $OSTIDX)
2055 test_mkdir $DIR/$tdir
2056 $LFS setstripe -c 1 $DIR/$tdir # 1 stripe per file
2057 do_facet ost$((OSTIDX + 1)) lctl set_param -n obdfilter.$OST.degraded 1
2059 createmany -o $DIR/$tdir/$tfile $OSTCOUNT
2060 for i in $(seq 0 $OFFSET); do
2061 [ $($LFS getstripe $DIR/$tdir/$tfile$i | grep -A 10 obdidx |
2062 awk '{print $1}' | grep -w "$OSTIDX") ] &&
2063 error "OST0 was degraded but new created file still use it"
2065 do_facet ost$((OSTIDX + 1)) lctl set_param -n obdfilter.$OST.degraded 0
2067 run_test 27x "create files while OST0 is degraded"
2070 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
2071 remote_mds_nodsh && skip "remote MDS with nodsh"
2072 remote_ost_nodsh && skip "remote OST with nodsh"
2073 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2075 local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS $FSNAME-OST0000)
2076 local last_id=$(do_facet $SINGLEMDS lctl get_param -n \
2077 osp.$mdtosc.prealloc_last_id)
2078 local next_id=$(do_facet $SINGLEMDS lctl get_param -n \
2079 osp.$mdtosc.prealloc_next_id)
2080 local fcount=$((last_id - next_id))
2081 [[ $fcount -eq 0 ]] && skip "not enough space on OST0"
2082 [[ $fcount -gt $OSTCOUNT ]] && fcount=$OSTCOUNT
2084 local MDS_OSCS=$(do_facet $SINGLEMDS lctl dl |
2085 awk '/[oO][sS][cC].*md[ts]/ { print $4 }')
2086 local OST_DEACTIVE_IDX=-1
2091 for OSC in $MDS_OSCS; do
2092 OST=$(osc_to_ost $OSC)
2093 OSTIDX=$(index_from_ostuuid $OST)
2094 if [ $OST_DEACTIVE_IDX == -1 ]; then
2095 OST_DEACTIVE_IDX=$OSTIDX
2097 if [ $OSTIDX != $OST_DEACTIVE_IDX ]; then
2098 echo $OSC "is Deactivated:"
2099 do_facet $SINGLEMDS lctl --device %$OSC deactivate
2103 OSTIDX=$(index_from_ostuuid $OST)
2104 test_mkdir $DIR/$tdir
2105 $LFS setstripe -c 1 $DIR/$tdir # 1 stripe / file
2107 for OSC in $MDS_OSCS; do
2108 OST=$(osc_to_ost $OSC)
2109 OSTIDX=$(index_from_ostuuid $OST)
2110 if [ $OSTIDX == $OST_DEACTIVE_IDX ]; then
2111 echo $OST "is degraded:"
2112 do_facet ost$((OSTIDX+1)) lctl set_param -n \
2113 obdfilter.$OST.degraded=1
2118 createmany -o $DIR/$tdir/$tfile $fcount
2120 for OSC in $MDS_OSCS; do
2121 OST=$(osc_to_ost $OSC)
2122 OSTIDX=$(index_from_ostuuid $OST)
2123 if [ $OSTIDX == $OST_DEACTIVE_IDX ]; then
2124 echo $OST "is recovered from degraded:"
2125 do_facet ost$((OSTIDX+1)) lctl set_param -n \
2126 obdfilter.$OST.degraded=0
2128 do_facet $SINGLEMDS lctl --device %$OSC activate
2132 # all osp devices get activated, hence -1 stripe count restored
2133 local stripe_count=0
2135 # sleep 2*lod_qos_maxage seconds waiting for lod qos to notice osp
2136 # devices get activated.
2138 $LFS setstripe -c -1 $DIR/$tfile
2139 stripe_count=$($LFS getstripe -c $DIR/$tfile)
2141 [ $stripe_count -ne $OSTCOUNT ] &&
2142 error "Of $OSTCOUNT OSTs, only $stripe_count is available"
2145 run_test 27y "create files while OST0 is degraded and the rest inactive"
2151 lmm_count=$($LFS getstripe -c $1)
2152 lmm_seq=$($LFS getstripe -v $1 | awk '/lmm_seq/ { print $2 }')
2153 lmm_oid=$($LFS getstripe -v $1 | awk '/lmm_object_id/ { print $2 }')
2155 local old_ifs="$IFS"
2157 fid=($($LFS path2fid $1))
2160 log "FID seq ${fid[1]}, oid ${fid[2]} ver ${fid[3]}"
2161 log "LOV seq $lmm_seq, oid $lmm_oid, count: $lmm_count"
2163 # compare lmm_seq and lu_fid->f_seq
2164 [ $lmm_seq = ${fid[1]} ] || { error "SEQ mismatch"; return 1; }
2165 # compare lmm_object_id and lu_fid->oid
2166 [ $lmm_oid = ${fid[2]} ] || { error "OID mismatch"; return 2; }
2168 # check the trusted.fid attribute of the OST objects of the file
2169 local have_obdidx=false
2171 $LFS getstripe $1 | while read obdidx oid hex seq; do
2172 # skip lines up to and including "obdidx"
2173 [ -z "$obdidx" ] && break
2174 [ "$obdidx" = "obdidx" ] && have_obdidx=true && continue
2175 $have_obdidx || continue
2177 local ost=$((obdidx + 1))
2178 local dev=$(ostdevname $ost)
2181 log "want: stripe:$stripe_nr ost:$obdidx oid:$oid/$hex seq:$seq"
2183 seq=$(echo $seq | sed -e "s/^0x//g")
2184 if [ $seq == 0 ] || [ $(facet_fstype ost$ost) == zfs ]; then
2185 oid_hex=$(echo $oid)
2187 oid_hex=$(echo $hex | sed -e "s/^0x//g")
2189 local obj_file="O/$seq/d$((oid %32))/$oid_hex"
2193 # Don't unmount/remount the OSTs if we don't need to do that.
2194 # LU-2577 changes filter_fid to be smaller, so debugfs needs
2195 # update too, until that use mount/ll_decode_filter_fid/mount.
2196 # Re-enable when debugfs will understand new filter_fid.
2198 if [ $(facet_fstype ost$ost) == ldiskfs ]; then
2199 ff=$(do_facet ost$ost "$DEBUGFS -c -R 'stat $obj_file' \
2200 $dev 2>/dev/null" | grep "parent=")
2202 if [ -z "$ff" ]; then
2204 mount_fstype ost$ost
2205 ff=$(do_facet ost$ost $LL_DECODE_FILTER_FID \
2206 $(facet_mntpt ost$ost)/$obj_file)
2207 unmount_fstype ost$ost
2208 start ost$ost $dev $OST_MOUNT_OPTS
2212 [ -z "$ff" ] && error "$obj_file: no filter_fid info"
2214 echo "$ff" | sed -e 's#.*objid=#got: objid=#'
2216 # /mnt/O/0/d23/23: objid=23 seq=0 parent=[0x200000400:0x1e:0x1]
2217 # fid: objid=23 seq=0 parent=[0x200000400:0x1e:0x0] stripe=1
2219 # fid: parent=[0x200000400:0x1e:0x0] stripe=1 stripe_count=2 \
2220 # stripe_size=1048576 component_id=1 component_start=0 \
2221 # component_end=33554432
2222 local ff_parent=$(sed -e 's/.*parent=.//' <<<$ff)
2223 local ff_pseq=$(cut -d: -f1 <<<$ff_parent)
2224 local ff_poid=$(cut -d: -f2 <<<$ff_parent)
2226 if grep -q 'stripe=' <<<$ff; then
2227 ff_pstripe=$(sed -e 's/.*stripe=//' -e 's/ .*//' <<<$ff)
2229 # $LL_DECODE_FILTER_FID does not print "stripe="; look
2230 # into f_ver in this case. See comment on ff_parent.
2231 ff_pstripe=$(cut -d: -f3 <<<$ff_parent | sed -e 's/]//')
2234 # compare lmm_seq and filter_fid->ff_parent.f_seq
2235 [ $ff_pseq = $lmm_seq ] ||
2236 error "FF parent SEQ $ff_pseq != $lmm_seq"
2237 # compare lmm_object_id and filter_fid->ff_parent.f_oid
2238 [ $ff_poid = $lmm_oid ] ||
2239 error "FF parent OID $ff_poid != $lmm_oid"
2240 (($ff_pstripe == $stripe_nr)) ||
2241 error "FF stripe $ff_pstripe != $stripe_nr"
2243 stripe_nr=$((stripe_nr + 1))
2244 [ $CLIENT_VERSION -lt $(version_code 2.9.55) ] &&
2246 if grep -q 'stripe_count=' <<<$ff; then
2247 local ff_scnt=$(sed -e 's/.*stripe_count=//' \
2248 -e 's/ .*//' <<<$ff)
2249 [ $lmm_count = $ff_scnt ] ||
2250 error "FF stripe count $lmm_count != $ff_scnt"
2256 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2257 remote_ost_nodsh && skip "remote OST with nodsh"
2259 test_mkdir $DIR/$tdir
2260 $LFS setstripe -c 1 -i 0 -S 64k $DIR/$tdir/$tfile-1 ||
2261 { error "setstripe -c -1 failed"; return 1; }
2262 # We need to send a write to every object to get parent FID info set.
2263 # This _should_ also work for setattr, but does not currently.
2264 # touch $DIR/$tdir/$tfile-1 ||
2265 dd if=/dev/zero of=$DIR/$tdir/$tfile-1 bs=1M count=1 ||
2266 { error "dd $tfile-1 failed"; return 2; }
2267 $LFS setstripe -c -1 -i $((OSTCOUNT - 1)) -S 1M $DIR/$tdir/$tfile-2 ||
2268 { error "setstripe -c -1 failed"; return 3; }
2269 dd if=/dev/zero of=$DIR/$tdir/$tfile-2 bs=1M count=$OSTCOUNT ||
2270 { error "dd $tfile-2 failed"; return 4; }
2272 # make sure write RPCs have been sent to OSTs
2275 check_seq_oid $DIR/$tdir/$tfile-1 || return 5
2276 check_seq_oid $DIR/$tdir/$tfile-2 || return 6
2278 run_test 27z "check SEQ/OID on the MDT and OST filesystems"
2280 test_27A() { # b=19102
2281 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2283 save_layout_restore_at_exit $MOUNT
2284 $LFS setstripe -c 0 -i -1 -S 0 $MOUNT
2285 wait_update $HOSTNAME "$LFS getstripe -c $MOUNT | sed 's/ *//g'" "1" 20 ||
2286 error "stripe count $($LFS getstripe -c $MOUNT) != 1"
2287 local default_size=$($LFS getstripe -S $MOUNT)
2288 local default_offset=$($LFS getstripe -i $MOUNT)
2289 local dsize=$(do_facet $SINGLEMDS \
2290 "$LCTL get_param -n lod.$(facet_svc $SINGLEMDS)*.stripesize")
2291 [ $default_size -eq $dsize ] ||
2292 error "stripe size $default_size != $dsize"
2293 [ $default_offset -eq -1 ] ||
2294 error "stripe offset $default_offset != -1"
2296 run_test 27A "check filesystem-wide default LOV EA values"
2298 test_27B() { # LU-2523
2299 test_mkdir $DIR/$tdir
2300 rm -f $DIR/$tdir/f0 $DIR/$tdir/f1
2302 # open f1 with O_LOV_DELAY_CREATE
2304 # call setstripe ioctl on open file descriptor for f1
2306 multiop $DIR/$tdir/f1 oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:nB1c \
2310 # open f1 with O_LOV_DELAY_CREATE
2312 # call setstripe ioctl on open file descriptor for f1
2314 multiop $DIR/$tdir/f1 oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:uB1c
2316 # Allow multiop to fail in imitation of NFS's busted semantics.
2319 run_test 27B "call setstripe on open unlinked file/rename victim"
2321 # 27C family tests full striping and overstriping
2322 test_27Ca() { #LU-2871
2323 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
2331 test_mkdir $DIR/$tdir
2333 for i in $(seq 0 $((OSTCOUNT - 1))); do
2334 # set stripe across all OSTs starting from OST$i
2335 $LFS setstripe -i $i -c -1 $tfile$i
2336 # get striping information
2337 ost_idx=($($LFS getstripe $tfile$i |
2338 tail -n $((OSTCOUNT + 1)) | awk '{print $1}'))
2342 [ ${#ost_idx[@]} -eq $OSTCOUNT ] ||
2343 error "${#ost_idx[@]} != $OSTCOUNT"
2345 for index in $(seq 0 $((OSTCOUNT - 1))); do
2347 for j in $(echo ${ost_idx[@]}); do
2348 if [ $index -eq $j ]; then
2354 error "Can not find $index in ${ost_idx[@]}"
2358 run_test 27Ca "check full striping across all OSTs"
2361 [[ $($LCTL get_param mdc.*.import) =~ connect_flags.*overstriping ]] ||
2362 skip "server does not support overstriping"
2363 [[ $OSTCOUNT -ge $(($LOV_MAX_STRIPE_COUNT / 2)) ]] &&
2364 skip_env "too many osts, skipping"
2366 test_mkdir -p $DIR/$tdir
2367 local setcount=$(($OSTCOUNT * 2))
2368 [ $setcount -ge 160 ] || large_xattr_enabled ||
2369 skip_env "ea_inode feature disabled"
2371 $LFS setstripe -C $setcount $DIR/$tdir/$tfile ||
2372 error "setstripe failed"
2374 local count=$($LFS getstripe -c $DIR/$tdir/$tfile)
2375 [ $count -eq $setcount ] ||
2376 error "stripe count $count, should be $setcount"
2378 $LFS getstripe $DIR/$tdir/$tfile 2>&1 | grep "overstriped" ||
2379 error "overstriped should be set in pattern"
2381 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=4 conv=notrunc ||
2384 run_test 27Cb "more stripes than OSTs with -C"
2387 [[ $($LCTL get_param mdc.*.import) =~ connect_flags.*overstriping ]] ||
2388 skip "server does not support overstriping"
2389 [[ $OSTCOUNT -lt 2 ]] && skip_env "need > 1 OST"
2391 test_mkdir -p $DIR/$tdir
2392 local setcount=$(($OSTCOUNT - 1))
2394 [ $setcount -ge 160 ] || large_xattr_enabled ||
2395 skip_env "ea_inode feature disabled"
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 not be set in pattern"
2407 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=4 conv=notrunc ||
2410 run_test 27Cc "fewer stripes than OSTs does not set overstriping"
2413 [[ $($LCTL get_param mdc.*.import) =~ connect_flags.*overstriping ]] ||
2414 skip "server does not support overstriping"
2415 [[ $OSTCOUNT -lt 2 ]] && skip_env "need > 1 OST"
2416 large_xattr_enabled || skip_env "ea_inode feature disabled"
2418 test_mkdir -p $DIR/$tdir
2419 local setcount=$LOV_MAX_STRIPE_COUNT
2421 $LFS setstripe -C $setcount $DIR/$tdir/$tfile ||
2422 error "setstripe failed"
2424 local count=$($LFS getstripe -c $DIR/$tdir/$tfile)
2425 [ $count -eq $setcount ] ||
2426 error "stripe count $count, should be $setcount"
2428 $LFS getstripe $DIR/$tdir/$tfile 2>&1 | grep "overstriped" ||
2429 error "overstriped should be set in pattern"
2431 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=4 conv=notrunc ||
2434 rm -f $DIR/$tdir/$tfile || error "Delete $tfile failed"
2436 run_test 27Cd "test maximum stripe count"
2439 [[ $($LCTL get_param mdc.*.import) =~ connect_flags.*overstriping ]] ||
2440 skip "server does not support overstriping"
2441 test_mkdir -p $DIR/$tdir
2443 pool_add $TESTNAME || error "Pool creation failed"
2444 pool_add_targets $TESTNAME 0 || error "pool_add_targets failed"
2448 $LFS setstripe -C $setcount -p "$TESTNAME" $DIR/$tdir/$tfile ||
2449 error "setstripe failed"
2451 local count=$($LFS getstripe -c $DIR/$tdir/$tfile)
2452 [ $count -eq $setcount ] ||
2453 error "stripe count $count, should be $setcount"
2455 $LFS getstripe $DIR/$tdir/$tfile 2>&1 | grep "overstriped" ||
2456 error "overstriped should be set in pattern"
2458 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=4 conv=notrunc ||
2461 rm -f $DIR/$tdir/$tfile || error "Delete $tfile failed"
2463 run_test 27Ce "test pool with overstriping"
2466 [[ $($LCTL get_param mdc.*.import) =~ connect_flags.*overstriping ]] ||
2467 skip "server does not support overstriping"
2468 [[ $OSTCOUNT -ge $(($LOV_MAX_STRIPE_COUNT / 2)) ]] &&
2469 skip_env "too many osts, skipping"
2471 test_mkdir -p $DIR/$tdir
2473 local setcount=$(($OSTCOUNT * 2))
2474 [ $setcount -ge 160 ] || large_xattr_enabled ||
2475 skip_env "ea_inode feature disabled"
2477 $LFS setstripe -C $setcount $DIR/$tdir/ ||
2478 error "setstripe failed"
2480 echo 1 > $DIR/$tdir/$tfile
2482 local count=$($LFS getstripe -c $DIR/$tdir/$tfile)
2483 [ $count -eq $setcount ] ||
2484 error "stripe count $count, should be $setcount"
2486 $LFS getstripe $DIR/$tdir/$tfile 2>&1 | grep "overstriped" ||
2487 error "overstriped should be set in pattern"
2489 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=4 conv=notrunc ||
2492 rm -f $DIR/$tdir/$tfile || error "Delete $tfile failed"
2494 run_test 27Cf "test default inheritance with overstriping"
2497 [ $OSTCOUNT -lt 2 ] && skip_env "needs >= 2 OSTs"
2498 [ -n "$FILESET" ] && skip "SKIP due to FILESET set"
2499 remote_mds_nodsh && skip "remote MDS with nodsh"
2501 local POOL=${POOL:-testpool}
2503 local last_ost=$(($OSTCOUNT - 1))
2505 local ost_list=$(seq $first_ost $ost_step $last_ost)
2506 local ost_range="$first_ost $last_ost $ost_step"
2508 test_mkdir $DIR/$tdir
2509 pool_add $POOL || error "pool_add failed"
2510 pool_add_targets $POOL $ost_range || error "pool_add_targets failed"
2513 [ $MDS1_VERSION -lt $(version_code 2.8.55) ] &&
2515 [ $MDS1_VERSION -lt $(version_code 2.9.55) ] ||
2516 [ $CLIENT_VERSION -lt $(version_code 2.9.55) ] &&
2517 skip27D+=" -s 30,31"
2518 [[ ! $($LCTL get_param mdc.*.import) =~ connect_flags.*overstriping ||
2519 $OSTCOUNT -ge $(($LOV_MAX_STRIPE_COUNT / 2)) ]] &&
2520 skip27D+=" -s 32,33"
2521 [[ $MDS_VERSION -lt $(version_code $SEL_VER) ]] &&
2523 llapi_layout_test -d$DIR/$tdir -p$POOL -o$OSTCOUNT $skip27D ||
2524 error "llapi_layout_test failed"
2526 destroy_test_pools || error "destroy test pools failed"
2528 run_test 27D "validate llapi_layout API"
2530 # Verify that default_easize is increased from its initial value after
2531 # accessing a widely striped file.
2533 [ $OSTCOUNT -lt 2 ] && skip_env "needs >= 2 OSTs"
2534 [ $CLIENT_VERSION -lt $(version_code 2.5.57) ] &&
2535 skip "client does not have LU-3338 fix"
2537 # 72 bytes is the minimum space required to store striping
2538 # information for a file striped across one OST:
2539 # (sizeof(struct lov_user_md_v3) +
2540 # sizeof(struct lov_user_ost_data_v1))
2542 $LCTL set_param -n llite.*.default_easize $min_easize ||
2543 error "lctl set_param failed"
2544 local easize=$($LCTL get_param -n llite.*.default_easize)
2546 [ $easize -eq $min_easize ] ||
2547 error "failed to set default_easize"
2549 $LFS setstripe -c $OSTCOUNT $DIR/$tfile ||
2550 error "setstripe failed"
2551 # In order to ensure stat() call actually talks to MDS we need to
2552 # do something drastic to this file to shake off all lock, e.g.
2553 # rename it (kills lookup lock forcing cache cleaning)
2554 mv $DIR/$tfile $DIR/${tfile}-1
2555 ls -l $DIR/${tfile}-1
2558 easize=$($LCTL get_param -n llite.*.default_easize)
2560 [ $easize -gt $min_easize ] ||
2561 error "default_easize not updated"
2563 run_test 27E "check that default extended attribute size properly increases"
2565 test_27F() { # LU-5346/LU-7975
2566 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2567 [[ $OSTCOUNT -lt 2 ]] && skip "needs >= 2 OSTs"
2568 [[ $MDS1_VERSION -lt $(version_code 2.8.51) ]] &&
2569 skip "Need MDS version at least 2.8.51"
2570 remote_ost_nodsh && skip "remote OST with nodsh"
2572 test_mkdir $DIR/$tdir
2574 $LFS setstripe -c 2 $DIR/$tdir
2576 # stop all OSTs to reproduce situation for LU-7975 ticket
2577 for num in $(seq $OSTCOUNT); do
2581 # open/create f0 with O_LOV_DELAY_CREATE
2582 # truncate f0 to a non-0 size
2584 multiop $DIR/$tdir/f0 oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:T1050000c
2586 $CHECKSTAT -s 1050000 $DIR/$tdir/f0 || error "checkstat failed"
2587 # open/write it again to force delayed layout creation
2588 cat /etc/hosts > $DIR/$tdir/f0 &
2592 for num in $(seq $OSTCOUNT); do
2593 start ost$num $(ostdevname $num) $OST_MOUNT_OPTS ||
2594 error "ost$num failed to start"
2597 wait $catpid || error "cat failed"
2599 cmp /etc/hosts $DIR/$tdir/f0 || error "cmp failed"
2600 [[ $($LFS getstripe -c $DIR/$tdir/f0) == 2 ]] ||
2601 error "wrong stripecount"
2604 run_test 27F "Client resend delayed layout creation with non-zero size"
2606 test_27G() { #LU-10629
2607 [ $MDS1_VERSION -lt $(version_code 2.11.51) ] &&
2608 skip "Need MDS version at least 2.11.51"
2609 [ -n "$FILESET" ] && skip "SKIP due to FILESET set"
2610 remote_mds_nodsh && skip "remote MDS with nodsh"
2611 local POOL=${POOL:-testpool}
2612 local ostrange="0 0 1"
2614 test_mkdir $DIR/$tdir
2615 pool_add $POOL || error "pool_add failed"
2616 pool_add_targets $POOL $ostrange || error "pool_add_targets failed"
2617 $LFS setstripe -p $POOL $DIR/$tdir
2619 local pool=$($LFS getstripe -p $DIR/$tdir)
2621 [ "$pool" = "$POOL" ] || error "Striping failed got '$pool' not '$POOL'"
2623 $LFS setstripe -d $DIR/$tdir
2625 pool=$($LFS getstripe -p $DIR/$tdir)
2629 [ -z "$pool" ] || error "'$pool' is not empty"
2631 run_test 27G "Clear OST pool from stripe"
2634 [[ $MDS1_VERSION -le $(version_code 2.11.54) ]] &&
2635 skip "Need MDS version newer than 2.11.54"
2636 [[ $OSTCOUNT -lt 3 ]] && skip_env "needs >= 3 OSTs"
2637 test_mkdir $DIR/$tdir
2638 $LFS setstripe -o 0 -o 2 $DIR/$tdir || error "setstripe failed"
2639 touch $DIR/$tdir/$tfile
2640 $LFS getstripe -c $DIR/$tdir/$tfile
2641 [ $($LFS getstripe -c $DIR/$tdir/$tfile) -eq 2 ] ||
2642 error "two-stripe file doesn't have two stripes"
2644 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=4k count=4 || error "dd failed"
2645 $LFS getstripe -y $DIR/$tdir/$tfile
2646 (( $($LFS getstripe -y $DIR/$tdir/$tfile |
2647 egrep -c "l_ost_idx: [02]$") == "2" )) ||
2648 error "expected l_ost_idx: [02]$ not matched"
2650 # make sure ost list has been cleared
2651 local stripesize=$($LFS getstripe -S $DIR/$tdir)
2652 $LFS setstripe -S $((stripesize * 4)) -i 1 \
2653 -c $((OSTCOUNT - 1)) $DIR/$tdir || error "setstripe"
2655 $LVERIFY $DIR/$tdir $DIR/$tdir/f3 || error "lverify failed"
2657 run_test 27H "Set specific OSTs stripe"
2660 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2661 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
2662 [[ $MDS1_VERSION -gt $(version_code 2.12.52) ]] ||
2663 skip "Need MDS version newer than 2.12.52"
2664 local pool=$TESTNAME
2665 local ostrange="1 1 1"
2667 save_layout_restore_at_exit $MOUNT
2668 $LFS setstripe -c 2 -i 0 $MOUNT
2669 pool_add $pool || error "pool_add failed"
2670 pool_add_targets $pool $ostrange || "pool_add_targets failed"
2671 test_mkdir $DIR/$tdir
2672 $LFS setstripe -p $pool $DIR/$tdir
2673 $MULTIOP $DIR/$tdir/$tfile Oc || error "multiop failed"
2674 $LFS getstripe $DIR/$tdir/$tfile
2676 run_test 27I "check that root dir striping does not break parent dir one"
2679 [[ $MDS1_VERSION -le $(version_code 2.12.51) ]] &&
2680 skip "Need MDS version newer than 2.12.51"
2682 test_mkdir $DIR/$tdir
2683 local uuid1=$(cat /proc/sys/kernel/random/uuid)
2684 local uuid2=$(cat /proc/sys/kernel/random/uuid)
2686 # create foreign file (raw way)
2687 create_foreign_file -f $DIR/$tdir/$tfile -x "${uuid1}@${uuid2}" \
2688 -t 1 -F 0xda08 || error "create_foreign_file failed"
2690 # verify foreign file (raw way)
2691 parse_foreign_file -f $DIR/$tdir/$tfile |
2692 grep "lov_foreign_magic: 0x0BD70BD0" ||
2693 error "$DIR/$tdir/$tfile: invalid LOV EA foreign magic"
2694 parse_foreign_file -f $DIR/$tdir/$tfile | grep "lov_xattr_size: 89" ||
2695 error "$DIR/$tdir/$tfile: invalid LOV EA foreign size"
2696 parse_foreign_file -f $DIR/$tdir/$tfile |
2697 grep "lov_foreign_size: 73" ||
2698 error "$DIR/$tdir/$tfile: invalid LOV EA foreign size"
2699 parse_foreign_file -f $DIR/$tdir/$tfile |
2700 grep "lov_foreign_type: 1" ||
2701 error "$DIR/$tdir/$tfile: invalid LOV EA foreign type"
2702 parse_foreign_file -f $DIR/$tdir/$tfile |
2703 grep "lov_foreign_flags: 0x0000DA08" ||
2704 error "$DIR/$tdir/$tfile: invalid LOV EA foreign flags"
2705 local lov=$(parse_foreign_file -f $DIR/$tdir/$tfile |
2706 grep "lov_foreign_value: 0x" |
2707 sed -e 's/lov_foreign_value: 0x//')
2708 local lov2=$(echo -n "${uuid1}@${uuid2}" | od -A n -t x1 -w160)
2709 [[ $lov = ${lov2// /} ]] ||
2710 error "$DIR/$tdir/$tfile: invalid LOV EA foreign value"
2712 # create foreign file (lfs + API)
2713 $LFS setstripe --foreign=daos --flags 0xda08 \
2714 -x "${uuid1}@${uuid2}" $DIR/$tdir/${tfile}2 ||
2715 error "$DIR/$tdir/${tfile}2: create failed"
2717 $LFS getstripe -v $DIR/$tdir/${tfile}2 |
2718 grep "lfm_magic:.*0x0BD70BD0" ||
2719 error "$DIR/$tdir/${tfile}2: invalid LOV EA foreign magic"
2720 # lfm_length is LOV EA size - sizeof(lfm_magic) - sizeof(lfm_length)
2721 $LFS getstripe -v $DIR/$tdir/${tfile}2 | grep "lfm_length:.*73" ||
2722 error "$DIR/$tdir/${tfile}2: invalid LOV EA foreign size"
2723 $LFS getstripe -v $DIR/$tdir/${tfile}2 | grep "lfm_type:.*daos" ||
2724 error "$DIR/$tdir/${tfile}2: invalid LOV EA foreign type"
2725 $LFS getstripe -v $DIR/$tdir/${tfile}2 |
2726 grep "lfm_flags:.*0x0000DA08" ||
2727 error "$DIR/$tdir/${tfile}2: invalid LOV EA foreign flags"
2728 $LFS getstripe $DIR/$tdir/${tfile}2 |
2729 grep "lfm_value:.*${uuid1}@${uuid2}" ||
2730 error "$DIR/$tdir/${tfile}2: invalid LOV EA foreign value"
2732 # modify striping should fail
2733 $LFS setstripe -c 2 $DIR/$tdir/$tfile &&
2734 error "$DIR/$tdir/$tfile: setstripe should fail"
2735 $LFS setstripe -c 2 $DIR/$tdir/${tfile}2 &&
2736 error "$DIR/$tdir/${tfile}2: setstripe should fail"
2739 cat $DIR/$tdir/$tfile && error "$DIR/$tdir/$tfile: read should fail"
2740 cat $DIR/$tdir/${tfile}2 &&
2741 error "$DIR/$tdir/${tfile}2: read should fail"
2742 cat /etc/passwd > $DIR/$tdir/$tfile &&
2743 error "$DIR/$tdir/$tfile: write should fail"
2744 cat /etc/passwd > $DIR/$tdir/${tfile}2 &&
2745 error "$DIR/$tdir/${tfile}2: write should fail"
2748 chmod 222 $DIR/$tdir/$tfile ||
2749 error "$DIR/$tdir/$tfile: chmod failed"
2750 chmod 222 $DIR/$tdir/${tfile}2 ||
2751 error "$DIR/$tdir/${tfile}2: chmod failed"
2754 chown $RUNAS_ID:$RUNAS_GID $DIR/$tdir/$tfile ||
2755 error "$DIR/$tdir/$tfile: chown failed"
2756 chown $RUNAS_ID:$RUNAS_GID $DIR/$tdir/${tfile}2 ||
2757 error "$DIR/$tdir/${tfile}2: chown failed"
2759 # rename should work
2760 mv $DIR/$tdir/$tfile $DIR/$tdir/${tfile}.new ||
2761 error "$DIR/$tdir/$tfile: rename of foreign file has failed"
2762 mv $DIR/$tdir/${tfile}2 $DIR/$tdir/${tfile}2.new ||
2763 error "$DIR/$tdir/${tfile}2: rename of foreign file has failed"
2765 #remove foreign file
2766 rm $DIR/$tdir/${tfile}.new ||
2767 error "$DIR/$tdir/${tfile}.new: remove of foreign file has failed"
2768 rm $DIR/$tdir/${tfile}2.new ||
2769 error "$DIR/$tdir/${tfile}2.new: remove of foreign file has failed"
2771 run_test 27J "basic ops on file with foreign LOV"
2774 [[ $MDS1_VERSION -le $(version_code 2.12.49) ]] &&
2775 skip "Need MDS version newer than 2.12.49"
2777 test_mkdir $DIR/$tdir
2778 local uuid1=$(cat /proc/sys/kernel/random/uuid)
2779 local uuid2=$(cat /proc/sys/kernel/random/uuid)
2781 # create foreign dir (raw way)
2782 create_foreign_dir -d $DIR/$tdir/$tdir -x "${uuid1}@${uuid2}" -t 1 ||
2783 error "create_foreign_dir FAILED"
2785 # verify foreign dir (raw way)
2786 parse_foreign_dir -d $DIR/$tdir/$tdir |
2787 grep "lmv_foreign_magic:.*0xcd50cd0" ||
2788 error "$DIR/$tdir/$tfile: invalid LMV EA magic"
2789 parse_foreign_dir -d $DIR/$tdir/$tdir | grep "lmv_xattr_size:.*89$" ||
2790 error "$DIR/$tdir/$tdir: invalid LMV EA size"
2791 parse_foreign_dir -d $DIR/$tdir/$tdir | grep "lmv_foreign_type: 1$" ||
2792 error "$DIR/$tdir/$tdir: invalid LMV EA type"
2793 parse_foreign_dir -d $DIR/$tdir/$tdir | grep "lmv_foreign_flags: 0$" ||
2794 error "$DIR/$tdir/$tdir: invalid LMV EA flags"
2795 local lmv=$(parse_foreign_dir -d $DIR/$tdir/$tdir |
2796 grep "lmv_foreign_value: 0x" |
2797 sed 's/lmv_foreign_value: 0x//')
2798 local lmv2=$(echo -n "${uuid1}@${uuid2}" | od -A n -t x1 -w160 |
2800 [[ $lmv == $lmv2 ]] || error "$DIR/$tdir/$tdir: invalid LMV EA value"
2802 # create foreign dir (lfs + API)
2803 $LFS mkdir --foreign=daos --xattr="${uuid1}@${uuid2}" --flags=0xda05 \
2804 $DIR/$tdir/${tdir}2 ||
2805 error "$DIR/$tdir/${tdir}2: create failed"
2807 $LFS getdirstripe -v $DIR/$tdir/${tdir}2 |
2808 grep "lfm_magic:.*0x0CD50CD0" ||
2809 error "$DIR/$tdir/${tdir}2: invalid LMV EA magic"
2810 # lfm_length is LMV EA size - sizeof(lfm_magic) - sizeof(lfm_length)
2811 # - sizeof(lfm_type) - sizeof(lfm_flags)
2812 $LFS getdirstripe -v $DIR/$tdir/${tdir}2 | grep "lfm_length:.*73" ||
2813 error "$DIR/$tdir/${tdir}2: invalid LMV EA size"
2814 $LFS getdirstripe -v $DIR/$tdir/${tdir}2 | grep "lfm_type:.*daos" ||
2815 error "$DIR/$tdir/${tdir}2: invalid LMV EA type"
2816 $LFS getdirstripe -v $DIR/$tdir/${tdir}2 |
2817 grep "lfm_flags:.*0x0000DA05" ||
2818 error "$DIR/$tdir/${tdir}2: invalid LMV EA flags"
2819 $LFS getdirstripe $DIR/$tdir/${tdir}2 |
2820 grep "lfm_value.*${uuid1}@${uuid2}" ||
2821 error "$DIR/$tdir/${tdir}2: invalid LMV EA value"
2823 # file create in dir should fail
2824 touch $DIR/$tdir/$tdir/$tfile && "$DIR/$tdir: file create should fail"
2825 touch $DIR/$tdir/${tdir}2/$tfile &&
2826 "$DIR/${tdir}2: file create should fail"
2829 chmod 777 $DIR/$tdir/$tdir ||
2830 error "$DIR/$tdir: chmod failed"
2831 chmod 777 $DIR/$tdir/${tdir}2 ||
2832 error "$DIR/${tdir}2: chmod failed"
2835 chown $RUNAS_ID:$RUNAS_GID $DIR/$tdir/$tdir ||
2836 error "$DIR/$tdir: chown failed"
2837 chown $RUNAS_ID:$RUNAS_GID $DIR/$tdir/${tdir}2 ||
2838 error "$DIR/${tdir}2: chown failed"
2840 # rename should work
2841 mv $DIR/$tdir/$tdir $DIR/$tdir/${tdir}.new ||
2842 error "$DIR/$tdir/$tdir: rename of foreign dir has failed"
2843 mv $DIR/$tdir/${tdir}2 $DIR/$tdir/${tdir}2.new ||
2844 error "$DIR/$tdir/${tdir}2: rename of foreign dir has failed"
2847 rmdir $DIR/$tdir/${tdir}.new ||
2848 error "$DIR/$tdir/${tdir}.new: remove of foreign dir has failed"
2849 rmdir $DIR/$tdir/${tdir}2.new ||
2850 error "$DIR/$tdir/${tdir}2.new: remove of foreign dir has failed"
2852 run_test 27K "basic ops on dir with foreign LMV"
2855 remote_mds_nodsh && skip "remote MDS with nodsh"
2857 local POOL=${POOL:-$TESTNAME}
2859 pool_add $POOL || error "pool_add failed"
2861 lfs pool_list $MOUNT | grep -Fx "${FSNAME}.${POOL}" ||
2862 error "pool_list does not contain ${FSNAME}.${POOL}:" \
2863 "$(lfs pool_list $MOUNT | grep -F "${POOL}")"
2865 run_test 27L "lfs pool_list gives correct pool name"
2868 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.12.57) ]] &&
2869 skip "Need MDS version >= than 2.12.57"
2870 remote_mds_nodsh && skip "remote MDS with nodsh"
2871 [[ $OSTCOUNT -lt 2 ]] && skip_env "need > 1 OST"
2873 test_mkdir $DIR/$tdir
2875 # Set default striping on directory
2876 $LFS setstripe -C 4 $DIR/$tdir
2878 echo 1 > $DIR/$tdir/${tfile}.1
2879 local count=$($LFS getstripe -c $DIR/$tdir/${tfile}.1)
2881 [ $count -eq $setcount ] ||
2882 error "(1) stripe count $count, should be $setcount"
2884 # Capture existing append_stripe_count setting for restore
2885 local orig_count=$(do_facet mds1 $LCTL get_param -n mdd.$FSNAME-MDT0000.append_stripe_count)
2886 local mdts=$(comma_list $(mdts_nodes))
2887 stack_trap "do_nodes $mdts $LCTL set_param mdd.*.append_stripe_count=$orig_count" EXIT
2889 local appendcount=$orig_count
2890 echo 1 >> $DIR/$tdir/${tfile}.2_append
2891 count=$($LFS getstripe -c $DIR/$tdir/${tfile}.2_append)
2892 [ $count -eq $appendcount ] ||
2893 error "(2)stripe count $count, should be $appendcount for append"
2895 # Disable O_APPEND striping, verify it works
2896 do_nodes $mdts $LCTL set_param mdd.*.append_stripe_count=0
2898 # Should now get the default striping, which is 4
2900 echo 1 >> $DIR/$tdir/${tfile}.3_append
2901 count=$($LFS getstripe -c $DIR/$tdir/${tfile}.3_append)
2902 [ $count -eq $setcount ] ||
2903 error "(3) stripe count $count, should be $setcount"
2905 # Try changing the stripe count for append files
2906 do_nodes $mdts $LCTL set_param mdd.*.append_stripe_count=2
2908 # Append striping is now 2 (directory default is still 4)
2910 echo 1 >> $DIR/$tdir/${tfile}.4_append
2911 count=$($LFS getstripe -c $DIR/$tdir/${tfile}.4_append)
2912 [ $count -eq $appendcount ] ||
2913 error "(4) stripe count $count, should be $appendcount for append"
2915 # Test append stripe count of -1
2916 do_nodes $mdts $LCTL set_param mdd.*.append_stripe_count=-1
2917 appendcount=$OSTCOUNT
2918 echo 1 >> $DIR/$tdir/${tfile}.5
2919 count=$($LFS getstripe -c $DIR/$tdir/${tfile}.5)
2920 [ $count -eq $appendcount ] ||
2921 error "(5) stripe count $count, should be $appendcount for append"
2923 # Set append striping back to default of 1
2924 do_nodes $mdts $LCTL set_param mdd.*.append_stripe_count=1
2926 # Try a new default striping, PFL + DOM
2927 $LFS setstripe -L mdt -E 1M -E -1 -c 2 $DIR/$tdir
2929 # Create normal DOM file, DOM returns stripe count == 0
2931 touch $DIR/$tdir/${tfile}.6
2932 count=$($LFS getstripe -c $DIR/$tdir/${tfile}.6)
2933 [ $count -eq $setcount ] ||
2934 error "(6) stripe count $count, should be $setcount"
2938 echo 1 >> $DIR/$tdir/${tfile}.7_append
2939 count=$($LFS getstripe -c $DIR/$tdir/${tfile}.7_append)
2940 [ $count -eq $appendcount ] ||
2941 error "(7) stripe count $count, should be $appendcount for append"
2943 # Clean up DOM layout
2944 $LFS setstripe -d $DIR/$tdir
2946 # Now test that append striping works when layout is from root
2947 $LFS setstripe -c 2 $MOUNT
2948 # Make a special directory for this
2949 mkdir $DIR/${tdir}/${tdir}.2
2950 stack_trap "$LFS setstripe -d $MOUNT" EXIT
2952 # Verify for normal file
2954 echo 1 > $DIR/${tdir}/${tdir}.2/${tfile}.8
2955 count=$($LFS getstripe -c $DIR/$tdir/${tdir}.2/${tfile}.8)
2956 [ $count -eq $setcount ] ||
2957 error "(8) stripe count $count, should be $setcount"
2960 echo 1 >> $DIR/${tdir}/${tdir}.2/${tfile}.9_append
2961 count=$($LFS getstripe -c $DIR/${tdir}/${tdir}.2/${tfile}.9_append)
2962 [ $count -eq $appendcount ] ||
2963 error "(9) stripe count $count, should be $appendcount for append"
2965 # Now test O_APPEND striping with pools
2966 do_nodes $mdts $LCTL set_param mdd.*.append_pool="$TESTNAME"
2967 stack_trap "do_nodes $mdts $LCTL set_param mdd.*.append_pool='none'" EXIT
2970 pool_add $TESTNAME || error "pool creation failed"
2971 pool_add_targets $TESTNAME 0 1 || error "Pool add targets failed"
2973 echo 1 >> $DIR/$tdir/${tfile}.10_append
2975 pool=$($LFS getstripe -p $DIR/$tdir/${tfile}.10_append)
2976 [ "$pool" = "$TESTNAME" ] || error "(10) incorrect pool: $pool"
2978 # Check that count is still correct
2980 echo 1 >> $DIR/$tdir/${tfile}.11_append
2981 count=$($LFS getstripe -c $DIR/$tdir/${tfile}.11_append)
2982 [ $count -eq $appendcount ] ||
2983 error "(11) stripe count $count, should be $appendcount for append"
2985 # Disable O_APPEND stripe count, verify pool works separately
2986 do_nodes $mdts $LCTL set_param mdd.*.append_stripe_count=0
2988 echo 1 >> $DIR/$tdir/${tfile}.12_append
2990 pool=$($LFS getstripe -p $DIR/$tdir/${tfile}.12_append)
2991 [ "$pool" = "$TESTNAME" ] || error "(12) incorrect pool: $pool"
2993 # Remove pool setting, verify it's not applied
2994 do_nodes $mdts $LCTL set_param mdd.*.append_pool='none'
2996 echo 1 >> $DIR/$tdir/${tfile}.13_append
2998 pool=$($LFS getstripe -p $DIR/$tdir/${tfile}.13_append)
2999 [ "$pool" = "" ] || error "(13) pool found: $pool"
3001 run_test 27M "test O_APPEND striping"
3004 combined_mgs_mds && skip "needs separate MGS/MDT"
3006 pool_add $TESTNAME || error "pool_add failed"
3007 do_facet mgs "$LCTL pool_list $FSNAME" |
3008 grep -Fx "${FSNAME}.${TESTNAME}" ||
3009 error "lctl pool_list on MGS failed"
3011 run_test 27N "lctl pool_list on separate MGS gives correct pool name"
3013 # createtest also checks that device nodes are created and
3014 # then visible correctly (#2091)
3015 test_28() { # bug 2091
3017 $CREATETEST $DIR/d28/ct || error "createtest failed"
3019 run_test 28 "create/mknod/mkdir with bad file types ============"
3022 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3024 sync; sleep 1; sync # flush out any dirty pages from previous tests
3031 declare -i LOCKCOUNTORIG=0
3032 for lock_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_count); do
3033 let LOCKCOUNTORIG=$LOCKCOUNTORIG+$lock_count
3035 [ $LOCKCOUNTORIG -eq 0 ] && error "No mdc lock count" && return 1
3037 declare -i LOCKUNUSEDCOUNTORIG=0
3038 for unused_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_unused_count); do
3039 let LOCKUNUSEDCOUNTORIG=$LOCKUNUSEDCOUNTORIG+$unused_count
3046 declare -i LOCKCOUNTCURRENT=0
3047 for lock_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_count); do
3048 let LOCKCOUNTCURRENT=$LOCKCOUNTCURRENT+$lock_count
3051 declare -i LOCKUNUSEDCOUNTCURRENT=0
3052 for unused_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_unused_count); do
3053 let LOCKUNUSEDCOUNTCURRENT=$LOCKUNUSEDCOUNTCURRENT+$unused_count
3056 if [[ $LOCKCOUNTCURRENT -gt $LOCKCOUNTORIG ]]; then
3057 $LCTL set_param -n ldlm.dump_namespaces ""
3058 error "CURRENT: $LOCKCOUNTCURRENT > $LOCKCOUNTORIG"
3059 $LCTL dk | sort -k4 -t: > $TMP/test_29.dk
3060 log "dumped log to $TMP/test_29.dk (bug 5793)"
3063 if [[ $LOCKUNUSEDCOUNTCURRENT -gt $LOCKUNUSEDCOUNTORIG ]]; then
3064 error "UNUSED: $LOCKUNUSEDCOUNTCURRENT > $LOCKUNUSEDCOUNTORIG"
3065 $LCTL dk | sort -k4 -t: > $TMP/test_29.dk
3066 log "dumped log to $TMP/test_29.dk (bug 5793)"
3070 run_test 29 "IT_GETATTR regression ============================"
3072 test_30a() { # was test_30
3073 cp $(which ls) $DIR || cp /bin/ls $DIR
3074 $DIR/ls / || error "Can't execute binary from lustre"
3077 run_test 30a "execute binary from Lustre (execve) =============="
3080 cp `which ls` $DIR || cp /bin/ls $DIR
3082 $RUNAS $DIR/ls / || error "Can't execute binary from lustre as non-root"
3085 run_test 30b "execute binary from Lustre as non-root ==========="
3087 test_30c() { # b=22376
3088 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3090 cp $(which ls) $DIR || cp /bin/ls $DIR
3092 cancel_lru_locks mdc
3093 cancel_lru_locks osc
3094 $RUNAS $DIR/ls / || error "Can't execute binary from lustre"
3097 run_test 30c "execute binary from Lustre without read perms ===="
3100 cp $(which dd) $DIR || error "failed to copy dd to $DIR/dd"
3102 for i in {1..10}; do
3103 $DIR/dd bs=1M count=128 if=/dev/zero of=$DIR/$tfile &
3106 $LCTL set_param ldlm.namespaces.*MDT*.lru_size=clear
3107 wait $PID || error "executing dd from Lustre failed"
3113 run_test 30d "execute binary from Lustre while clear locks"
3116 $OPENUNLINK $DIR/f31 $DIR/f31 || error "openunlink failed"
3117 $CHECKSTAT -a $DIR/f31 || error "$DIR/f31 exists"
3119 run_test 31a "open-unlink file =================================="
3122 touch $DIR/f31 || error "touch $DIR/f31 failed"
3123 ln $DIR/f31 $DIR/f31b || error "ln failed"
3124 $MULTIOP $DIR/f31b Ouc || error "multiop failed"
3125 $CHECKSTAT -t file $DIR/f31 || error "$DIR/f31 not file type"
3127 run_test 31b "unlink file with multiple links while open ======="
3130 touch $DIR/f31 || error "touch $DIR/f31 failed"
3131 ln $DIR/f31 $DIR/f31c || error "ln failed"
3132 multiop_bg_pause $DIR/f31 O_uc ||
3133 error "multiop_bg_pause for $DIR/f31 failed"
3135 $MULTIOP $DIR/f31c Ouc
3136 kill -USR1 $MULTIPID
3139 run_test 31c "open-unlink file with multiple links ============="
3142 opendirunlink $DIR/d31d $DIR/d31d || error "opendirunlink failed"
3143 $CHECKSTAT -a $DIR/d31d || error "$DIR/d31d exists"
3145 run_test 31d "remove of open directory ========================="
3147 test_31e() { # bug 2904
3148 openfilleddirunlink $DIR/d31e || error "openfilleddirunlink failed"
3150 run_test 31e "remove of open non-empty directory ==============="
3152 test_31f() { # bug 4554
3153 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3156 test_mkdir $DIR/d31f
3157 $LFS setstripe -S 1048576 -c 1 $DIR/d31f
3158 cp /etc/hosts $DIR/d31f
3160 $LFS getstripe $DIR/d31f/hosts
3161 multiop_bg_pause $DIR/d31f D_c || return 1
3164 rm -rv $DIR/d31f || error "first of $DIR/d31f"
3165 test_mkdir $DIR/d31f
3166 $LFS setstripe -S 1048576 -c 1 $DIR/d31f
3167 cp /etc/hosts $DIR/d31f
3169 $LFS getstripe $DIR/d31f/hosts
3170 multiop_bg_pause $DIR/d31f D_c || return 1
3173 kill -USR1 $MULTIPID || error "first opendir $MULTIPID not running"
3174 wait $MULTIPID || error "first opendir $MULTIPID failed"
3178 kill -USR1 $MULTIPID2 || error "second opendir $MULTIPID not running"
3179 wait $MULTIPID2 || error "second opendir $MULTIPID2 failed"
3182 run_test 31f "remove of open directory with open-unlink file ==="
3185 echo "-- cross directory link --"
3186 test_mkdir -c1 $DIR/${tdir}ga
3187 test_mkdir -c1 $DIR/${tdir}gb
3188 touch $DIR/${tdir}ga/f
3189 ln $DIR/${tdir}ga/f $DIR/${tdir}gb/g
3190 $CHECKSTAT -t file $DIR/${tdir}ga/f || error "source"
3191 [ `stat -c%h $DIR/${tdir}ga/f` == '2' ] || error "source nlink"
3192 $CHECKSTAT -t file $DIR/${tdir}gb/g || error "target"
3193 [ `stat -c%h $DIR/${tdir}gb/g` == '2' ] || error "target nlink"
3195 run_test 31g "cross directory link==============="
3198 echo "-- cross directory link --"
3199 test_mkdir -c1 $DIR/${tdir}
3200 test_mkdir -c1 $DIR/${tdir}/dir
3201 touch $DIR/${tdir}/f
3202 ln $DIR/${tdir}/f $DIR/${tdir}/dir/g
3203 $CHECKSTAT -t file $DIR/${tdir}/f || error "source"
3204 [ `stat -c%h $DIR/${tdir}/f` == '2' ] || error "source nlink"
3205 $CHECKSTAT -t file $DIR/${tdir}/dir/g || error "target"
3206 [ `stat -c%h $DIR/${tdir}/dir/g` == '2' ] || error "target nlink"
3208 run_test 31h "cross directory link under child==============="
3211 echo "-- cross directory link --"
3212 test_mkdir -c1 $DIR/$tdir
3213 test_mkdir -c1 $DIR/$tdir/dir
3214 touch $DIR/$tdir/dir/f
3215 ln $DIR/$tdir/dir/f $DIR/$tdir/g
3216 $CHECKSTAT -t file $DIR/$tdir/dir/f || error "source"
3217 [ `stat -c%h $DIR/$tdir/dir/f` == '2' ] || error "source nlink"
3218 $CHECKSTAT -t file $DIR/$tdir/g || error "target"
3219 [ `stat -c%h $DIR/$tdir/g` == '2' ] || error "target nlink"
3221 run_test 31i "cross directory link under parent==============="
3224 test_mkdir -c1 -p $DIR/$tdir
3225 test_mkdir -c1 -p $DIR/$tdir/dir1
3226 ln $DIR/$tdir/dir1 $DIR/$tdir/dir2 && error "ln for dir"
3227 link $DIR/$tdir/dir1 $DIR/$tdir/dir3 && error "link for dir"
3228 mlink $DIR/$tdir/dir1 $DIR/$tdir/dir4 && error "mlink for dir"
3229 mlink $DIR/$tdir/dir1 $DIR/$tdir/dir1 && error "mlink to the same dir"
3232 run_test 31j "link for directory==============="
3235 test_mkdir -c1 -p $DIR/$tdir
3237 touch $DIR/$tdir/exist
3238 mlink $DIR/$tdir/s $DIR/$tdir/t || error "mlink"
3239 mlink $DIR/$tdir/s $DIR/$tdir/exist && error "mlink to exist file"
3240 mlink $DIR/$tdir/s $DIR/$tdir/s && error "mlink to the same file"
3241 mlink $DIR/$tdir/s $DIR/$tdir && error "mlink to parent dir"
3242 mlink $DIR/$tdir $DIR/$tdir/s && error "mlink parent dir to target"
3243 mlink $DIR/$tdir/not-exist $DIR/$tdir/foo && error "mlink non-existing to new"
3244 mlink $DIR/$tdir/not-exist $DIR/$tdir/s && error "mlink non-existing to exist"
3247 run_test 31k "link to file: the same, non-existing, dir==============="
3253 touch $DIR/d31m2/exist
3254 mlink $DIR/d31m/s $DIR/d31m2/t || error "mlink"
3255 mlink $DIR/d31m/s $DIR/d31m2/exist && error "mlink to exist file"
3256 mlink $DIR/d31m/s $DIR/d31m2 && error "mlink to parent dir"
3257 mlink $DIR/d31m2 $DIR/d31m/s && error "mlink parent dir to target"
3258 mlink $DIR/d31m/not-exist $DIR/d31m2/foo && error "mlink non-existing to new"
3259 mlink $DIR/d31m/not-exist $DIR/d31m2/s && error "mlink non-existing to exist"
3262 run_test 31m "link to file: the same, non-existing, dir==============="
3265 touch $DIR/$tfile || error "cannot create '$DIR/$tfile'"
3266 nlink=$(stat --format=%h $DIR/$tfile)
3267 [ ${nlink:--1} -eq 1 ] || error "nlink is $nlink, expected 1"
3269 local cmd="exec $fd<$DIR/$tfile"
3272 trap "eval $cmd" EXIT
3273 nlink=$(stat --dereference --format=%h /proc/self/fd/$fd)
3274 [ ${nlink:--1} -eq 1 ] || error "nlink is $nlink, expected 1"
3275 rm $DIR/$tfile || error "cannot remove '$DIR/$tfile'"
3276 nlink=$(stat --dereference --format=%h /proc/self/fd/$fd)
3277 [ ${nlink:--1} -eq 0 ] || error "nlink is $nlink, expected 0"
3280 run_test 31n "check link count of unlinked file"
3283 local tempfile=$(mktemp $1_XXXXXX)
3284 mlink $tempfile $1 2> /dev/null &&
3285 echo "$BASHPID: link $tempfile to $1 succeeded"
3289 test_31o() { # LU-2901
3290 test_mkdir $DIR/$tdir
3291 for LOOP in $(seq 100); do
3292 rm -f $DIR/$tdir/$tfile*
3293 for THREAD in $(seq 8); do
3294 link_one $DIR/$tdir/$tfile.$LOOP &
3297 local LINKS=$(ls -1 $DIR/$tdir | grep -c $tfile.$LOOP)
3298 [[ $LINKS -gt 1 ]] && ls $DIR/$tdir &&
3299 error "$LINKS duplicate links to $tfile.$LOOP" &&
3303 run_test 31o "duplicate hard links with same filename"
3306 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
3308 test_mkdir $DIR/$tdir
3309 $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
3310 $LFS setdirstripe -D -c2 -H all_char $DIR/$tdir/striped_dir
3312 opendirunlink $DIR/$tdir/striped_dir/test1 ||
3313 error "open unlink test1 failed"
3314 opendirunlink $DIR/$tdir/striped_dir/test2 ||
3315 error "open unlink test2 failed"
3317 $CHECKSTAT -a $DIR/$tdir/striped_dir/test1 ||
3318 error "test1 still exists"
3319 $CHECKSTAT -a $DIR/$tdir/striped_dir/test2 ||
3320 error "test2 still exists"
3322 run_test 31p "remove of open striped directory"
3324 cleanup_test32_mount() {
3327 local loopdev=$(losetup -a | grep $EXT2_DEV | sed -ne 's/:.*$//p')
3328 $UMOUNT $DIR/$tdir/ext2-mountpoint || rc=$?
3329 losetup -d $loopdev || true
3335 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3337 echo "== more mountpoints and symlinks ================="
3338 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
3339 trap cleanup_test32_mount EXIT
3340 test_mkdir -p $DIR/$tdir/ext2-mountpoint
3341 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
3342 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
3343 $CHECKSTAT -t dir $DIR/$tdir/ext2-mountpoint/.. ||
3344 error "$DIR/$tdir/ext2-mountpoint/.. not dir type"
3345 cleanup_test32_mount
3347 run_test 32a "stat d32a/ext2-mountpoint/.. ====================="
3350 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3352 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
3353 trap cleanup_test32_mount EXIT
3354 test_mkdir -p $DIR/$tdir/ext2-mountpoint
3355 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
3356 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
3357 ls -al $DIR/$tdir/ext2-mountpoint/.. ||
3358 error "Can't list $DIR/$tdir/ext2-mountpoint/.."
3359 cleanup_test32_mount
3361 run_test 32b "open d32b/ext2-mountpoint/.. ====================="
3364 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3366 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
3367 trap cleanup_test32_mount EXIT
3368 test_mkdir -p $DIR/$tdir/ext2-mountpoint
3369 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
3370 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
3371 test_mkdir -p $DIR/$tdir/d2/test_dir
3372 $CHECKSTAT -t dir $DIR/$tdir/ext2-mountpoint/../d2/test_dir ||
3373 error "$DIR/$tdir/ext2-mountpoint/../d2/test_dir not dir type"
3374 cleanup_test32_mount
3376 run_test 32c "stat d32c/ext2-mountpoint/../d2/test_dir ========="
3379 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3381 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
3382 trap cleanup_test32_mount EXIT
3383 test_mkdir -p $DIR/$tdir/ext2-mountpoint
3384 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
3385 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
3386 test_mkdir -p $DIR/$tdir/d2/test_dir
3387 ls -al $DIR/$tdir/ext2-mountpoint/../d2/test_dir ||
3388 error "Can't list $DIR/$tdir/ext2-mountpoint/../d2/test_dir"
3389 cleanup_test32_mount
3391 run_test 32d "open d32d/ext2-mountpoint/../d2/test_dir"
3395 test_mkdir -p $DIR/$tdir/tmp
3396 local tmp_dir=$DIR/$tdir/tmp
3397 ln -s $DIR/$tdir $tmp_dir/symlink11
3398 ln -s $tmp_dir/symlink11 $tmp_dir/../symlink01
3399 $CHECKSTAT -t link $DIR/$tdir/tmp/symlink11 || error "symlink11 bad"
3400 $CHECKSTAT -t link $DIR/$tdir/symlink01 || error "symlink01 bad"
3402 run_test 32e "stat d32e/symlink->tmp/symlink->lustre-subdir"
3406 test_mkdir -p $DIR/$tdir/tmp
3407 local tmp_dir=$DIR/$tdir/tmp
3408 ln -s $DIR/$tdir $tmp_dir/symlink11
3409 ln -s $tmp_dir/symlink11 $tmp_dir/../symlink01
3410 ls $DIR/$tdir/tmp/symlink11 || error "symlink11 bad"
3411 ls $DIR/$tdir/symlink01 || error "symlink01 bad"
3413 run_test 32f "open d32f/symlink->tmp/symlink->lustre-subdir"
3416 local tmp_dir=$DIR/$tdir/tmp
3417 test_mkdir -p $tmp_dir
3418 test_mkdir $DIR/${tdir}2
3419 ln -s $DIR/${tdir}2 $tmp_dir/symlink12
3420 ln -s $tmp_dir/symlink12 $tmp_dir/../symlink02
3421 $CHECKSTAT -t link $tmp_dir/symlink12 || error "symlink12 not a link"
3422 $CHECKSTAT -t link $DIR/$tdir/symlink02 || error "symlink02 not a link"
3423 $CHECKSTAT -t dir -f $tmp_dir/symlink12 || error "symlink12 not a dir"
3424 $CHECKSTAT -t dir -f $DIR/$tdir/symlink02 || error "symlink12 not a dir"
3426 run_test 32g "stat d32g/symlink->tmp/symlink->lustre-subdir/${tdir}2"
3429 rm -fr $DIR/$tdir $DIR/${tdir}2
3430 tmp_dir=$DIR/$tdir/tmp
3431 test_mkdir -p $tmp_dir
3432 test_mkdir $DIR/${tdir}2
3433 ln -s $DIR/${tdir}2 $tmp_dir/symlink12
3434 ln -s $tmp_dir/symlink12 $tmp_dir/../symlink02
3435 ls $tmp_dir/symlink12 || error "listing symlink12"
3436 ls $DIR/$tdir/symlink02 || error "listing symlink02"
3438 run_test 32h "open d32h/symlink->tmp/symlink->lustre-subdir/${tdir}2"
3441 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3443 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
3444 trap cleanup_test32_mount EXIT
3445 test_mkdir -p $DIR/$tdir/ext2-mountpoint
3446 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
3447 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
3448 touch $DIR/$tdir/test_file
3449 $CHECKSTAT -t file $DIR/$tdir/ext2-mountpoint/../test_file ||
3450 error "$DIR/$tdir/ext2-mountpoint/../test_file not file type"
3451 cleanup_test32_mount
3453 run_test 32i "stat d32i/ext2-mountpoint/../test_file ==========="
3456 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3458 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
3459 trap cleanup_test32_mount EXIT
3460 test_mkdir -p $DIR/$tdir/ext2-mountpoint
3461 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
3462 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
3463 touch $DIR/$tdir/test_file
3464 cat $DIR/$tdir/ext2-mountpoint/../test_file ||
3465 error "Can't open $DIR/$tdir/ext2-mountpoint/../test_file"
3466 cleanup_test32_mount
3468 run_test 32j "open d32j/ext2-mountpoint/../test_file ==========="
3471 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3474 trap cleanup_test32_mount EXIT
3475 test_mkdir -p $DIR/$tdir/ext2-mountpoint
3476 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
3477 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
3478 test_mkdir -p $DIR/$tdir/d2
3479 touch $DIR/$tdir/d2/test_file || error "touch failed"
3480 $CHECKSTAT -t file $DIR/$tdir/ext2-mountpoint/../d2/test_file ||
3481 error "$DIR/$tdir/ext2-mountpoint/../d2/test_file not file type"
3482 cleanup_test32_mount
3484 run_test 32k "stat d32k/ext2-mountpoint/../d2/test_file ========"
3487 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3490 trap cleanup_test32_mount EXIT
3491 test_mkdir -p $DIR/$tdir/ext2-mountpoint
3492 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
3493 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
3494 test_mkdir -p $DIR/$tdir/d2
3495 touch $DIR/$tdir/d2/test_file || error "touch failed"
3496 cat $DIR/$tdir/ext2-mountpoint/../d2/test_file ||
3497 error "Can't open $DIR/$tdir/ext2-mountpoint/../d2/test_file"
3498 cleanup_test32_mount
3500 run_test 32l "open d32l/ext2-mountpoint/../d2/test_file ========"
3504 test_mkdir -p $DIR/d32m/tmp
3505 TMP_DIR=$DIR/d32m/tmp
3506 ln -s $DIR $TMP_DIR/symlink11
3507 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
3508 $CHECKSTAT -t link $DIR/d32m/tmp/symlink11 ||
3509 error "symlink11 not a link"
3510 $CHECKSTAT -t link $DIR/d32m/symlink01 ||
3511 error "symlink01 not a link"
3513 run_test 32m "stat d32m/symlink->tmp/symlink->lustre-root ======"
3517 test_mkdir -p $DIR/d32n/tmp
3518 TMP_DIR=$DIR/d32n/tmp
3519 ln -s $DIR $TMP_DIR/symlink11
3520 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
3521 ls -l $DIR/d32n/tmp/symlink11 || error "listing symlink11"
3522 ls -l $DIR/d32n/symlink01 || error "listing symlink01"
3524 run_test 32n "open d32n/symlink->tmp/symlink->lustre-root ======"
3528 test_mkdir -p $DIR/d32o/tmp
3529 TMP_DIR=$DIR/d32o/tmp
3530 ln -s $DIR/$tfile $TMP_DIR/symlink12
3531 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
3532 $CHECKSTAT -t link $DIR/d32o/tmp/symlink12 ||
3533 error "symlink12 not a link"
3534 $CHECKSTAT -t link $DIR/d32o/symlink02 || error "symlink02 not a link"
3535 $CHECKSTAT -t file -f $DIR/d32o/tmp/symlink12 ||
3536 error "$DIR/d32o/tmp/symlink12 not file type"
3537 $CHECKSTAT -t file -f $DIR/d32o/symlink02 ||
3538 error "$DIR/d32o/symlink02 not file type"
3540 run_test 32o "stat d32o/symlink->tmp/symlink->lustre-root/$tfile"
3550 test_mkdir -p $DIR/d32p/tmp
3552 TMP_DIR=$DIR/d32p/tmp
3554 ln -s $DIR/$tfile $TMP_DIR/symlink12
3556 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
3558 cat $DIR/d32p/tmp/symlink12 ||
3559 error "Can't open $DIR/d32p/tmp/symlink12"
3561 cat $DIR/d32p/symlink02 || error "Can't open $DIR/d32p/symlink02"
3564 run_test 32p "open d32p/symlink->tmp/symlink->lustre-root/$tfile"
3567 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3569 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
3570 trap cleanup_test32_mount EXIT
3571 test_mkdir -p $DIR/$tdir/ext2-mountpoint
3572 touch $DIR/$tdir/ext2-mountpoint/under_the_mount || error "touch failed"
3573 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
3574 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
3575 ls $DIR/$tdir/ext2-mountpoint | grep "\<under_the_mount\>" && error
3576 cleanup_test32_mount
3578 run_test 32q "stat follows mountpoints in Lustre (should return error)"
3581 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3583 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
3584 trap cleanup_test32_mount EXIT
3585 test_mkdir -p $DIR/$tdir/ext2-mountpoint
3586 touch $DIR/$tdir/ext2-mountpoint/under_the_mount || error "touch failed"
3587 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
3588 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
3589 ls $DIR/$tdir/ext2-mountpoint | grep -q under_the_mount && error || true
3590 cleanup_test32_mount
3592 run_test 32r "opendir follows mountpoints in Lustre (should return error)"
3597 chmod 444 $DIR/$tfile
3598 chown $RUNAS_ID $DIR/$tfile
3600 $RUNAS $OPENFILE -f O_RDWR $DIR/$tfile && error || true
3603 run_test 33aa "write file with mode 444 (should return error)"
3607 test_mkdir $DIR/$tdir
3608 chown $RUNAS_ID $DIR/$tdir
3609 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $DIR/$tdir/$tfile ||
3610 error "$RUNAS create $tdir/$tfile failed"
3611 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $DIR/$tdir/$tfile &&
3612 error "open RDWR" || true
3614 run_test 33a "test open file(mode=0444) with O_RDWR (should return error)"
3618 test_mkdir $DIR/$tdir
3619 chown $RUNAS_ID $DIR/$tdir
3620 $RUNAS $OPENFILE -f 1286739555 $DIR/$tdir/$tfile || true
3622 run_test 33b "test open file with malformed flags (No panic)"
3625 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3626 remote_ost_nodsh && skip "remote OST with nodsh"
3635 test_mkdir $DIR/$tdir
3636 # Read: 0, Write: 4, create/destroy: 2/0, stat: 1, punch: 0
3639 for ostnum in $(seq $OSTCOUNT); do
3640 # test-framework's OST numbering is one-based, while Lustre's
3642 ostname=$(printf "$FSNAME-OST%.4x" $((ostnum - 1)))
3643 # Parsing llobdstat's output sucks; we could grep the /proc
3644 # path, but that's likely to not be as portable as using the
3645 # llobdstat utility. So we parse lctl output instead.
3646 write_bytes=$(do_facet ost$ostnum lctl get_param -n \
3647 obdfilter/$ostname/stats |
3648 awk '/^write_bytes/ {print $7}' )
3649 echo "baseline_write_bytes@$OSTnum/$ostname=$write_bytes"
3650 if (( ${write_bytes:-0} > 0 ))
3657 $all_zeros || return 0
3660 echo foo > $DIR/$tdir/bar
3664 # Total up write_bytes after writing. We'd better find non-zeros.
3665 for ostnum in $(seq $OSTCOUNT); do
3666 ostname=$(printf "$FSNAME-OST%.4x" $((ostnum - 1)))
3667 write_bytes=$(do_facet ost$ostnum lctl get_param -n \
3668 obdfilter/$ostname/stats |
3669 awk '/^write_bytes/ {print $7}' )
3670 echo "write_bytes@$OSTnum/$ostname=$write_bytes"
3671 if (( ${write_bytes:-0} > 0 ))
3680 for ostnum in $(seq $OSTCOUNT); do
3681 ostname=$(printf "$FSNAME-OST%.4x" $((ostnum - 1)))
3682 echo "Check that write_bytes is present in obdfilter/*/stats:"
3683 do_facet ost$ostnum lctl get_param -n \
3684 obdfilter/$ostname/stats
3686 error "OST not keeping write_bytes stats (b22312)"
3689 run_test 33c "test llobdstat and write_bytes"
3692 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
3693 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3696 local remote_dir=$DIR/$tdir/remote_dir
3698 test_mkdir $DIR/$tdir
3699 $LFS mkdir -i $MDTIDX $remote_dir ||
3700 error "create remote directory failed"
3702 touch $remote_dir/$tfile
3703 chmod 444 $remote_dir/$tfile
3704 chown $RUNAS_ID $remote_dir/$tfile
3706 $RUNAS $OPENFILE -f O_RDWR $DIR/$tfile && error || true
3708 chown $RUNAS_ID $remote_dir
3709 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $remote_dir/f33 ||
3710 error "create" || true
3711 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $remote_dir/f33 &&
3712 error "open RDWR" || true
3713 $RUNAS $OPENFILE -f 1286739555 $remote_dir/f33 || true
3715 run_test 33d "openfile with 444 modes and malformed flags under remote dir"
3718 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
3722 $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
3723 $LFS setdirstripe -i1 -c2 $DIR/$tdir/striped_dir1
3724 mkdir $DIR/$tdir/local_dir
3726 local s0_mode=$(stat -c%f $DIR/$tdir/striped_dir)
3727 local s1_mode=$(stat -c%f $DIR/$tdir/striped_dir1)
3728 local l_mode=$(stat -c%f $DIR/$tdir/local_dir)
3730 [ "$l_mode" = "$s0_mode" -a "$l_mode" = "$s1_mode" ] ||
3731 error "mkdir $l_mode striped0 $s0_mode striped1 $s1_mode"
3733 rmdir $DIR/$tdir/* || error "rmdir failed"
3736 $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
3737 $LFS setdirstripe -i1 -c2 $DIR/$tdir/striped_dir1
3738 mkdir $DIR/$tdir/local_dir
3740 s0_mode=$(stat -c%f $DIR/$tdir/striped_dir)
3741 s1_mode=$(stat -c%f $DIR/$tdir/striped_dir1)
3742 l_mode=$(stat -c%f $DIR/$tdir/local_dir)
3744 [ "$l_mode" = "$s0_mode" -a "$l_mode" = "$s1_mode" ] ||
3745 error "mkdir $l_mode striped0 $s0_mode striped1 $s1_mode 777"
3747 rmdir $DIR/$tdir/* || error "rmdir(umask 777) failed"
3750 $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
3751 $LFS setdirstripe -i1 -c2 $DIR/$tdir/striped_dir1
3752 mkdir $DIR/$tdir/local_dir
3754 s0_mode=$(stat -c%f $DIR/$tdir/striped_dir)
3755 s1_mode=$(stat -c%f $DIR/$tdir/striped_dir1)
3756 l_mode=$(stat -c%f $DIR/$tdir/local_dir)
3758 [ "$l_mode" = "$s0_mode" -a "$l_mode" = "$s1_mode" ] ||
3759 error "mkdir $l_mode striped0 $s0_mode striped1 $s1_mode 0"
3761 run_test 33e "mkdir and striped directory should have same mode"
3765 do_facet $SINGLEMDS $LCTL set_param mdt.*.enable_remote_dir_gid=0
3769 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
3770 remote_mds_nodsh && skip "remote MDS with nodsh"
3773 chmod go+rwx $DIR/$tdir
3774 do_facet $SINGLEMDS $LCTL set_param mdt.*.enable_remote_dir_gid=-1
3775 trap cleanup_33f EXIT
3777 $RUNAS lfs mkdir -i 0 -c$MDSCOUNT $DIR/$tdir/striped_dir ||
3778 error "cannot create striped directory"
3780 $RUNAS touch $DIR/$tdir/striped_dir/{0..16} ||
3781 error "cannot create files in striped directory"
3783 $RUNAS rm $DIR/$tdir/striped_dir/{0..16} ||
3784 error "cannot remove files in striped directory"
3786 $RUNAS rmdir $DIR/$tdir/striped_dir ||
3787 error "cannot remove striped directory"
3791 run_test 33f "nonroot user can create, access, and remove a striped directory"
3794 mkdir -p $DIR/$tdir/dir2
3796 local err=$($RUNAS mkdir $DIR/$tdir/dir2 2>&1)
3798 [[ $err =~ "exists" ]] || error "Not exists error"
3800 run_test 33g "nonroot user create already existing root created file"
3803 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
3804 [ $MDS1_VERSION -lt $(version_code 2.13.50) ] &&
3805 skip "Need MDS version at least 2.13.50"
3807 test_mkdir -c $MDSCOUNT -H crush $DIR/$tdir ||
3808 error "mkdir $tdir failed"
3809 touch $DIR/$tdir/$tfile || error "touch $tfile failed"
3811 local index=$($LFS getstripe -m $DIR/$tdir/$tfile)
3814 for fname in $DIR/$tdir/$tfile.bak \
3815 $DIR/$tdir/$tfile.SAV \
3816 $DIR/$tdir/$tfile.orig \
3817 $DIR/$tdir/$tfile~; do
3818 touch $fname || error "touch $fname failed"
3819 index2=$($LFS getstripe -m $fname)
3820 [ $index -eq $index2 ] ||
3821 error "$fname MDT index mismatch $index != $index2"
3825 for i in {1..50}; do
3826 for fname in $(mktemp -u $DIR/$tdir/.$tfile.XXXXXX) \
3827 $(mktemp $DIR/$tdir/$tfile.XXXXXXXX); do
3828 touch $fname || error "touch $fname failed"
3829 index2=$($LFS getstripe -m $fname)
3830 if [[ $index != $index2 ]]; then
3831 failed=$((failed + 1))
3832 echo "$fname MDT index mismatch $index != $index2"
3836 echo "$failed MDT index mismatches"
3837 (( failed < 4 )) || error "MDT index mismatch $failed times"
3840 run_test 33h "temp file is located on the same MDT as target"
3842 TEST_34_SIZE=${TEST_34_SIZE:-2000000000000}
3845 $MCREATE $DIR/f34 || error "mcreate failed"
3846 $LFS getstripe $DIR/f34 2>&1 | grep -q "no stripe info" ||
3847 error "getstripe failed"
3848 $TRUNCATE $DIR/f34 $TEST_34_SIZE || error "truncate failed"
3849 $LFS getstripe $DIR/f34 2>&1 | grep -q "no stripe info" ||
3850 error "getstripe failed"
3851 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 ||
3852 error "Size of $DIR/f34 not equal to $TEST_34_SIZE bytes"
3854 run_test 34a "truncate file that has not been opened ==========="
3857 [ ! -f $DIR/f34 ] && test_34a
3858 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 ||
3859 error "Size of $DIR/f34 not equal to $TEST_34_SIZE bytes"
3860 $OPENFILE -f O_RDONLY $DIR/f34
3861 $LFS getstripe $DIR/f34 2>&1 | grep -q "no stripe info" ||
3862 error "getstripe failed"
3863 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 ||
3864 error "Size of $DIR/f34 not equal to $TEST_34_SIZE bytes"
3866 run_test 34b "O_RDONLY opening file doesn't create objects ====="
3869 [ ! -f $DIR/f34 ] && test_34a
3870 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 ||
3871 error "Size of $DIR/f34 not equal to $TEST_34_SIZE bytes"
3872 $OPENFILE -f O_RDWR $DIR/f34
3873 $LFS getstripe $DIR/f34 2>&1 | grep -q "no stripe info" &&
3874 error "$LFS getstripe failed"
3875 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 ||
3876 error "Size of $DIR/f34 not equal to $TEST_34_SIZE bytes"
3878 run_test 34c "O_RDWR opening file-with-size works =============="
3881 [ ! -f $DIR/f34 ] && test_34a
3882 dd if=/dev/zero of=$DIR/f34 conv=notrunc bs=4k count=1 ||
3884 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 ||
3885 error "Size of $DIR/f34 not equal to $TEST_34_SIZE bytes"
3888 run_test 34d "write to sparse file ============================="
3892 $MCREATE $DIR/f34e || error "mcreate failed"
3893 $TRUNCATE $DIR/f34e 1000 || error "truncate failed"
3894 $CHECKSTAT -s 1000 $DIR/f34e ||
3895 error "Size of $DIR/f34e not equal to 1000 bytes"
3896 $OPENFILE -f O_RDWR $DIR/f34e
3897 $CHECKSTAT -s 1000 $DIR/f34e ||
3898 error "Size of $DIR/f34e not equal to 1000 bytes"
3900 run_test 34e "create objects, some with size and some without =="
3902 test_34f() { # bug 6242, 6243
3903 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3907 $MCREATE $DIR/f34f || error "mcreate failed"
3908 $TRUNCATE $DIR/f34f $SIZE34F || error "truncating $DIR/f3f to $SIZE34F"