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
45 ALWAYS_EXCEPT+=" 407 312"
48 # bug number: LU-14181 LU-14181
49 ALWAYS_EXCEPT+=" 64e 64f"
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"
64 # bug number: LU-14067 LU-14067
65 ALWAYS_EXCEPT+=" 400a 400b"
68 # skip nfs tests on kernels >= 4.12.0 until they are fixed
69 if [ $LINUX_VERSION_CODE -ge $(version_code 4.12.0) ]; then
70 # bug number: LU-12661
73 # skip cgroup tests on RHEL8.1 kernels until they are fixed
74 if (( $LINUX_VERSION_CODE >= $(version_code 4.18.0) &&
75 $LINUX_VERSION_CODE < $(version_code 5.4.0) )); then
76 # bug number: LU-13063
81 [ "$SLOW" = "no" ] && EXCEPT_SLOW="27m 60i 64b 68 71 115 135 136 300o"
83 if [ "$mds1_FSTYPE" = "zfs" ]; then
84 # bug number for skipped test:
87 [ "$SLOW" = "no" ] && EXCEPT_SLOW="$EXCEPT_SLOW 51b"
90 if [ "$ost1_FSTYPE" = "zfs" ]; then
91 # bug number for skipped test: LU-1941 LU-1941 LU-1941 LU-1941
92 ALWAYS_EXCEPT+=" 130a 130b 130c 130d 130e 130f 130g"
95 proc_regexp="/{proc,sys}/{fs,sys,kernel/debug}/{lustre,lnet}/"
97 # Get the SLES distro version
99 # Returns a version string that should only be used in comparing
100 # strings returned by version_code()
103 local version=$(grep VERSION_ID /etc/os-release | cut -d'"' -f2)
105 # All SuSE Linux versions have one decimal. version_code expects two
106 local sles_version=$version.0
107 version_code $sles_version
110 # Check if we are running on Ubuntu or SLES so we can make decisions on
112 if [ -r /etc/SuSE-release ]; then
113 sles_version=$(sles_version_code)
114 [ $sles_version -lt $(version_code 11.4.0) ] &&
115 # bug number for skipped test: LU-4341
116 ALWAYS_EXCEPT="$ALWAYS_EXCEPT 170"
117 [ $sles_version -lt $(version_code 12.0.0) ] &&
118 # bug number for skipped test: LU-3703
119 ALWAYS_EXCEPT="$ALWAYS_EXCEPT 234"
120 elif [ -r /etc/os-release ]; then
121 if grep -qi ubuntu /etc/os-release; then
122 ubuntu_version=$(version_code $(sed -n -e 's/"//g' \
123 -e 's/^VERSION=//p' \
127 if [[ $ubuntu_version -gt $(version_code 16.0.0) ]]; then
128 # bug number for skipped test:
130 ALWAYS_EXCEPT+=" 103a 410"
140 pgrep ll_sa > /dev/null && { echo "There are ll_sa thread not exit!"; exit 20; }
141 cleanupall ${FORCE} $* || { echo "FAILed to clean up"; exit 20; }
150 check_swap_layouts_support()
152 $LCTL get_param -n llite.*.sbi_flags | grep -q layout ||
153 skip "Does not support layout lock."
156 check_swap_layout_no_dom()
159 local SUPP=$(lfs getstripe $FOLDER | grep "pattern: mdt" | wc -l)
160 [ $SUPP -eq 0 ] || skip "layout swap does not support DOM files so far"
163 check_and_setup_lustre
167 MAXFREE=${MAXFREE:-$((300000 * $OSTCOUNT))}
169 [ -f $DIR/d52a/foo ] && chattr -a $DIR/d52a/foo
170 [ -f $DIR/d52b/foo ] && chattr -i $DIR/d52b/foo
171 rm -rf $DIR/[Rdfs][0-9]*
173 # $RUNAS_ID may get set incorrectly somewhere else
174 [ $UID -eq 0 -a $RUNAS_ID -eq 0 ] &&
175 error "\$RUNAS_ID set to 0, but \$UID is also 0!"
177 check_runas_id $RUNAS_ID $RUNAS_GID $RUNAS
179 if [ "${ONLY}" = "MOUNT" ] ; then
180 echo "Lustre is up, please go on"
184 echo "preparing for tests involving mounts"
185 EXT2_DEV=${EXT2_DEV:-$TMP/SANITY.LOOP}
187 mke2fs -j -F $EXT2_DEV 8000 > /dev/null
188 echo # add a newline after mke2fs.
192 OLDDEBUG=$(lctl get_param -n debug 2> /dev/null)
193 lctl set_param debug=-1 2> /dev/null || true
196 $CHECKSTAT -t file $DIR/$tfile || error "$tfile is not a file"
198 $CHECKSTAT -a $DIR/$tfile || error "$tfile was not removed"
200 run_test 0a "touch; rm ====================="
203 chmod 0755 $DIR || error "chmod 0755 $DIR failed"
204 $CHECKSTAT -p 0755 $DIR || error "$DIR permission is not 0755"
206 run_test 0b "chmod 0755 $DIR ============================="
209 $LCTL get_param mdc.*.import | grep "state: FULL" ||
210 error "import not FULL"
211 $LCTL get_param mdc.*.import | grep "target: $FSNAME-MDT" ||
214 run_test 0c "check import proc"
216 test_0d() { # LU-3397
217 [ $MGS_VERSION -lt $(version_code 2.10.57) ] &&
218 skip "proc exports not supported before 2.10.57"
220 local mgs_exp="mgs.MGS.exports"
221 local client_uuid=$($LCTL get_param -n mgc.*.uuid)
223 local exp_client_version
226 local temp_imp=$DIR/$tfile.import
227 local temp_exp=$DIR/$tfile.export
229 # save mgc import file to $temp_imp
230 $LCTL get_param mgc.*.import | tee $temp_imp
231 # Check if client uuid is found in MGS export
232 for exp_client_nid in $(do_facet mgs $LCTL get_param -N $mgs_exp.*); do
233 [ $(do_facet mgs $LCTL get_param -n $exp_client_nid.uuid) == \
237 # save mgs export file to $temp_exp
238 do_facet mgs $LCTL get_param $exp_client_nid.export | tee $temp_exp
240 # Compare the value of field "connect_flags"
241 imp_val=$(grep "connect_flags" $temp_imp)
242 exp_val=$(grep "connect_flags" $temp_exp)
243 [ "$exp_val" == "$imp_val" ] ||
244 error "export flags '$exp_val' != import flags '$imp_val'"
246 # Compare client versions. Only compare top-3 fields for compatibility
247 exp_client_version=$(awk '/target_version:/ { print $2 }' $temp_exp)
248 exp_val=$(version_code $(cut -d. -f1,2,3 <<<$exp_client_version))
249 imp_val=$(version_code $(lustre_build_version client | cut -d. -f1,2,3))
250 [ "$exp_val" == "$imp_val" ] ||
251 error "exp version '$exp_client_version'($exp_val) != " \
252 "'$(lustre_build_version client)'($imp_val)"
254 run_test 0d "check export proc ============================="
257 test_mkdir $DIR/$tdir
258 test_mkdir $DIR/$tdir/d2
259 mkdir $DIR/$tdir/d2 && error "we expect EEXIST, but not returned"
260 $CHECKSTAT -t dir $DIR/$tdir/d2 || error "$tdir/d2 is not a dir"
263 $CHECKSTAT -a $DIR/$tdir || error "$tdir was not removed"
265 run_test 1 "mkdir; remkdir; rmdir"
268 test_mkdir $DIR/$tdir
269 touch $DIR/$tdir/$tfile || error "touch $tdir/$tfile failed"
270 $CHECKSTAT -t file $DIR/$tdir/$tfile || error "$tdir/$tfile not a file"
272 $CHECKSTAT -a $DIR/$tdir/$tfile || error "$tdir/$file is not removed"
274 run_test 2 "mkdir; touch; rmdir; check file"
277 test_mkdir $DIR/$tdir
278 $CHECKSTAT -t dir $DIR/$tdir || error "$tdir is not a directory"
279 touch $DIR/$tdir/$tfile
280 $CHECKSTAT -t file $DIR/$tdir/$tfile || error "$tdir/$tfile not a file"
282 $CHECKSTAT -a $DIR/$tdir || error "$tdir is not removed"
284 run_test 3 "mkdir; touch; rmdir; check dir"
286 # LU-4471 - failed rmdir on remote directories still removes directory on MDT0
288 test_mkdir -i 1 $DIR/$tdir
290 touch $DIR/$tdir/$tfile ||
291 error "Create file under remote directory failed"
294 error "Expect error removing in-use dir $DIR/$tdir"
296 test -d $DIR/$tdir || error "Remote directory disappeared"
298 rm -rf $DIR/$tdir || error "remove remote dir error"
300 run_test 4 "mkdir; touch dir/file; rmdir; checkdir (expect error)"
303 test_mkdir $DIR/$tdir
304 test_mkdir $DIR/$tdir/d2
305 chmod 0707 $DIR/$tdir/d2 || error "chmod 0707 $tdir/d2 failed"
306 $CHECKSTAT -t dir -p 0707 $DIR/$tdir/d2 || error "$tdir/d2 not mode 707"
307 $CHECKSTAT -t dir $DIR/$tdir/d2 || error "$tdir/d2 is not a directory"
309 run_test 5 "mkdir .../d5 .../d5/d2; chmod .../d5/d2"
312 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
313 chmod 0666 $DIR/$tfile || error "chmod 0666 $tfile failed"
314 $CHECKSTAT -t file -p 0666 -u \#$UID $DIR/$tfile ||
315 error "$tfile does not have perm 0666 or UID $UID"
316 $RUNAS chmod 0444 $DIR/$tfile && error "chmod $tfile worked on UID $UID"
317 $CHECKSTAT -t file -p 0666 -u \#$UID $DIR/$tfile ||
318 error "$tfile should be 0666 and owned by UID $UID"
320 run_test 6a "touch f6a; chmod f6a; $RUNAS chmod f6a (should return error) =="
323 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID"
326 chown $RUNAS_ID $DIR/$tfile || error "chown $RUNAS_ID $file failed"
327 $CHECKSTAT -t file -u \#$RUNAS_ID $DIR/$tfile ||
328 error "$tfile should be owned by UID $RUNAS_ID"
329 $RUNAS chown $UID $DIR/$tfile && error "chown $UID $file succeeded"
330 $CHECKSTAT -t file -u \#$RUNAS_ID $DIR/$tfile ||
331 error "$tfile should be owned by UID $RUNAS_ID"
333 run_test 6c "touch f6c; chown f6c; $RUNAS chown f6c (should return error) =="
336 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID"
339 chgrp $RUNAS_ID $DIR/$tfile || error "chgrp $RUNAS_ID $file failed"
340 $CHECKSTAT -t file -u \#$UID -g \#$RUNAS_ID $DIR/$tfile ||
341 error "$tfile should be owned by GID $UID"
342 $RUNAS chgrp $UID $DIR/$tfile && error "chgrp $UID $file succeeded"
343 $CHECKSTAT -t file -u \#$UID -g \#$RUNAS_ID $DIR/$tfile ||
344 error "$tfile should be owned by UID $UID and GID $RUNAS_ID"
346 run_test 6e "touch+chgrp $tfile; $RUNAS chgrp $tfile (should return error)"
349 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID"
351 test_mkdir $DIR/$tdir
352 chmod 777 $DIR/$tdir || error "chmod 0777 $tdir failed"
353 $RUNAS mkdir $DIR/$tdir/d || error "mkdir $tdir/d failed"
354 chmod g+s $DIR/$tdir/d || error "chmod g+s $tdir/d failed"
355 test_mkdir $DIR/$tdir/d/subdir
356 $CHECKSTAT -g \#$RUNAS_GID $DIR/$tdir/d/subdir ||
357 error "$tdir/d/subdir should be GID $RUNAS_GID"
358 if [[ $MDSCOUNT -gt 1 ]]; then
359 # check remote dir sgid inherite
360 $LFS mkdir -i 0 $DIR/$tdir.local ||
361 error "mkdir $tdir.local failed"
362 chmod g+s $DIR/$tdir.local ||
363 error "chmod $tdir.local failed"
364 chgrp $RUNAS_GID $DIR/$tdir.local ||
365 error "chgrp $tdir.local failed"
366 $LFS mkdir -i 1 $DIR/$tdir.local/$tdir.remote ||
367 error "mkdir $tdir.remote failed"
368 $CHECKSTAT -g \#$RUNAS_GID $DIR/$tdir.local/$tdir.remote ||
369 error "$tdir.remote should be owned by $UID.$RUNAS_ID"
370 $CHECKSTAT -p 02755 $DIR/$tdir.local/$tdir.remote ||
371 error "$tdir.remote should be mode 02755"
374 run_test 6g "verify new dir in sgid dir inherits group"
376 test_6h() { # bug 7331
377 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID"
379 touch $DIR/$tfile || error "touch failed"
380 chown $RUNAS_ID:$RUNAS_GID $DIR/$tfile || error "initial chown failed"
381 $RUNAS -G$RUNAS_GID chown $RUNAS_ID:0 $DIR/$tfile &&
382 error "chown $RUNAS_ID:0 $tfile worked as GID $RUNAS_GID"
383 $CHECKSTAT -t file -u \#$RUNAS_ID -g \#$RUNAS_GID $DIR/$tfile ||
384 error "$tdir/$tfile should be UID $RUNAS_UID GID $RUNAS_GID"
386 run_test 6h "$RUNAS chown RUNAS_ID.0 .../$tfile (should return error)"
389 test_mkdir $DIR/$tdir
390 $MCREATE $DIR/$tdir/$tfile
391 chmod 0666 $DIR/$tdir/$tfile
392 $CHECKSTAT -t file -p 0666 $DIR/$tdir/$tfile ||
393 error "$tdir/$tfile should be mode 0666"
395 run_test 7a "mkdir .../d7; mcreate .../d7/f; chmod .../d7/f ===="
398 if [ ! -d $DIR/$tdir ]; then
399 test_mkdir $DIR/$tdir
401 $MCREATE $DIR/$tdir/$tfile
402 echo -n foo > $DIR/$tdir/$tfile
403 [ "$(cat $DIR/$tdir/$tfile)" = "foo" ] || error "$tdir/$tfile not 'foo'"
404 $CHECKSTAT -t file -s 3 $DIR/$tdir/$tfile || error "$tfile size not 3"
406 run_test 7b "mkdir .../d7; mcreate d7/f2; echo foo > d7/f2 ====="
409 test_mkdir $DIR/$tdir
410 touch $DIR/$tdir/$tfile
411 chmod 0666 $DIR/$tdir/$tfile
412 $CHECKSTAT -t file -p 0666 $DIR/$tdir/$tfile ||
413 error "$tfile mode not 0666"
415 run_test 8 "mkdir .../d8; touch .../d8/f; chmod .../d8/f ======="
418 test_mkdir $DIR/$tdir
419 test_mkdir $DIR/$tdir/d2
420 test_mkdir $DIR/$tdir/d2/d3
421 $CHECKSTAT -t dir $DIR/$tdir/d2/d3 || error "$tdir/d2/d3 not a dir"
423 run_test 9 "mkdir .../d9 .../d9/d2 .../d9/d2/d3 ================"
426 test_mkdir $DIR/$tdir
427 test_mkdir $DIR/$tdir/d2
428 touch $DIR/$tdir/d2/$tfile
429 $CHECKSTAT -t file $DIR/$tdir/d2/$tfile ||
430 error "$tdir/d2/$tfile not a file"
432 run_test 10 "mkdir .../d10 .../d10/d2; touch .../d10/d2/f ======"
435 test_mkdir $DIR/$tdir
436 test_mkdir $DIR/$tdir/d2
437 chmod 0666 $DIR/$tdir/d2
438 chmod 0705 $DIR/$tdir/d2
439 $CHECKSTAT -t dir -p 0705 $DIR/$tdir/d2 ||
440 error "$tdir/d2 mode not 0705"
442 run_test 11 "mkdir .../d11 d11/d2; chmod .../d11/d2 ============"
445 test_mkdir $DIR/$tdir
446 touch $DIR/$tdir/$tfile
447 chmod 0666 $DIR/$tdir/$tfile
448 chmod 0654 $DIR/$tdir/$tfile
449 $CHECKSTAT -t file -p 0654 $DIR/$tdir/$tfile ||
450 error "$tdir/d2 mode not 0654"
452 run_test 12 "touch .../d12/f; chmod .../d12/f .../d12/f ========"
455 test_mkdir $DIR/$tdir
456 dd if=/dev/zero of=$DIR/$tdir/$tfile count=10
458 $CHECKSTAT -t file -s 0 $DIR/$tdir/$tfile ||
459 error "$tdir/$tfile size not 0 after truncate"
461 run_test 13 "creat .../d13/f; dd .../d13/f; > .../d13/f ========"
464 test_mkdir $DIR/$tdir
465 touch $DIR/$tdir/$tfile
467 $CHECKSTAT -a $DIR/$tdir/$tfile || error "$tdir/$tfile not removed"
469 run_test 14 "touch .../d14/f; rm .../d14/f; rm .../d14/f ======="
472 test_mkdir $DIR/$tdir
473 touch $DIR/$tdir/$tfile
474 mv $DIR/$tdir/$tfile $DIR/$tdir/${tfile}_2
475 $CHECKSTAT -t file $DIR/$tdir/${tfile}_2 ||
476 error "$tdir/${tfile_2} not a file after rename"
477 rm $DIR/$tdir/${tfile}_2 || error "unlink failed after rename"
479 run_test 15 "touch .../d15/f; mv .../d15/f .../d15/f2 =========="
482 test_mkdir $DIR/$tdir
483 touch $DIR/$tdir/$tfile
484 rm -rf $DIR/$tdir/$tfile
485 $CHECKSTAT -a $DIR/$tdir/$tfile || error "$tdir/$tfile not removed"
487 run_test 16 "touch .../d16/f; rm -rf .../d16/f"
490 test_mkdir $DIR/$tdir
491 touch $DIR/$tdir/$tfile
492 ln -s $DIR/$tdir/$tfile $DIR/$tdir/l-exist
494 $CHECKSTAT -l $DIR/$tdir/$tfile $DIR/$tdir/l-exist ||
495 error "$tdir/l-exist not a symlink"
496 $CHECKSTAT -f -t f $DIR/$tdir/l-exist ||
497 error "$tdir/l-exist not referencing a file"
498 rm -f $DIR/$tdir/l-exist
499 $CHECKSTAT -a $DIR/$tdir/l-exist || error "$tdir/l-exist not removed"
501 run_test 17a "symlinks: create, remove (real)"
504 test_mkdir $DIR/$tdir
505 ln -s no-such-file $DIR/$tdir/l-dangle
507 $CHECKSTAT -l no-such-file $DIR/$tdir/l-dangle ||
508 error "$tdir/l-dangle not referencing no-such-file"
509 $CHECKSTAT -fa $DIR/$tdir/l-dangle ||
510 error "$tdir/l-dangle not referencing non-existent file"
511 rm -f $DIR/$tdir/l-dangle
512 $CHECKSTAT -a $DIR/$tdir/l-dangle || error "$tdir/l-dangle not removed"
514 run_test 17b "symlinks: create, remove (dangling)"
516 test_17c() { # bug 3440 - don't save failed open RPC for replay
517 test_mkdir $DIR/$tdir
518 ln -s foo $DIR/$tdir/$tfile
519 cat $DIR/$tdir/$tfile && error "opened non-existent symlink" || true
521 run_test 17c "symlinks: open dangling (should return error)"
524 test_mkdir $DIR/$tdir
525 ln -s foo $DIR/$tdir/$tfile
526 touch $DIR/$tdir/$tfile || error "creating to new symlink"
528 run_test 17d "symlinks: create dangling"
531 test_mkdir $DIR/$tdir
532 local foo=$DIR/$tdir/$tfile
533 ln -s $foo $foo || error "create symlink failed"
534 ls -l $foo || error "ls -l failed"
535 ls $foo && error "ls not failed" || true
537 run_test 17e "symlinks: create recursive symlink (should return error)"
540 test_mkdir $DIR/$tdir
541 ln -s 1234567890/2234567890/3234567890/4234567890 $DIR/$tdir/111
542 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890 $DIR/$tdir/222
543 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890 $DIR/$tdir/333
544 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890/9234567890/a234567890/b234567890 $DIR/$tdir/444
545 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890/9234567890/a234567890/b234567890/c234567890/d234567890/f234567890 $DIR/$tdir/555
546 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
549 run_test 17f "symlinks: long and very long symlink name"
551 # str_repeat(S, N) generate a string that is string S repeated N times
556 while [ $((n -= 1)) -ge 0 ]; do
562 # Long symlinks and LU-2241
564 test_mkdir $DIR/$tdir
565 local TESTS="59 60 61 4094 4095"
567 # Fix for inode size boundary in 2.1.4
568 [ $MDS1_VERSION -lt $(version_code 2.1.4) ] &&
571 # Patch not applied to 2.2 or 2.3 branches
572 [ $MDS1_VERSION -ge $(version_code 2.2.0) ] &&
573 [ $MDS1_VERSION -le $(version_code 2.3.55) ] &&
577 local SYMNAME=$(str_repeat 'x' $i)
578 ln -s $SYMNAME $DIR/$tdir/f$i || error "failed $i-char symlink"
579 readlink $DIR/$tdir/f$i || error "failed $i-char readlink"
582 run_test 17g "symlinks: really long symlink name and inode boundaries"
584 test_17h() { #bug 17378
585 [ $PARALLEL == "yes" ] && skip "skip parallel run"
586 remote_mds_nodsh && skip "remote MDS with nodsh"
590 test_mkdir $DIR/$tdir
591 mdt_idx=$($LFS getdirstripe -i $DIR/$tdir)
592 $LFS setstripe -c -1 $DIR/$tdir
593 #define OBD_FAIL_MDS_LOV_PREP_CREATE 0x141
594 do_facet mds$((mdt_idx + 1)) lctl set_param fail_loc=0x80000141
595 touch $DIR/$tdir/$tfile || true
597 run_test 17h "create objects: lov_free_memmd() doesn't lbug"
599 test_17i() { #bug 20018
600 [ $PARALLEL == "yes" ] && skip "skip parallel run"
601 remote_mds_nodsh && skip "remote MDS with nodsh"
603 local foo=$DIR/$tdir/$tfile
606 test_mkdir -c1 $DIR/$tdir
607 mdt_idx=$($LFS getdirstripe -i $DIR/$tdir)
608 ln -s $foo $foo || error "create symlink failed"
609 #define OBD_FAIL_MDS_READLINK_EPROTO 0x143
610 do_facet mds$((mdt_idx + 1)) lctl set_param fail_loc=0x80000143
611 ls -l $foo && error "error not detected"
614 run_test 17i "don't panic on short symlink (should return error)"
616 test_17k() { #bug 22301
617 [ $PARALLEL == "yes" ] && skip "skip parallel run"
618 [[ -z "$(which rsync 2>/dev/null)" ]] &&
619 skip "no rsync command"
620 rsync --help | grep -q xattr ||
621 skip_env "$(rsync --version | head -n1) does not support xattrs"
622 test_mkdir $DIR/$tdir
623 test_mkdir $DIR/$tdir.new
624 touch $DIR/$tdir/$tfile
625 ln -s $DIR/$tdir/$tfile $DIR/$tdir/$tfile.lnk
626 rsync -av -X $DIR/$tdir/ $DIR/$tdir.new ||
627 error "rsync failed with xattrs enabled"
629 run_test 17k "symlinks: rsync with xattrs enabled"
631 test_17l() { # LU-279
632 [[ -z "$(which getfattr 2>/dev/null)" ]] &&
633 skip "no getfattr command"
635 test_mkdir $DIR/$tdir
636 touch $DIR/$tdir/$tfile
637 ln -s $DIR/$tdir/$tfile $DIR/$tdir/$tfile.lnk
638 for path in "$DIR/$tdir" "$DIR/$tdir/$tfile" "$DIR/$tdir/$tfile.lnk"; do
639 # -h to not follow symlinks. -m '' to list all the xattrs.
640 # grep to remove first line: '# file: $path'.
641 for xattr in `getfattr -hm '' $path 2>/dev/null | grep -v '^#'`;
643 lgetxattr_size_check $path $xattr ||
644 error "lgetxattr_size_check $path $xattr failed"
648 run_test 17l "Ensure lgetxattr's returned xattr size is consistent"
652 [ $PARALLEL == "yes" ] && skip "skip parallel run"
653 [ "$mds1_FSTYPE" != "ldiskfs" ] && skip_env "ldiskfs only test"
654 remote_mds_nodsh && skip "remote MDS with nodsh"
655 [ $MDS1_VERSION -ge $(version_code 2.2.0) ] &&
656 [ $MDS1_VERSION -le $(version_code 2.2.93) ] &&
657 skip "MDS 2.2.0-2.2.93 do not NUL-terminate symlinks"
659 local short_sym="0123456789"
660 local wdir=$DIR/$tdir
665 # create a long symlink file
666 for ((i = 0; i < 4; ++i)); do
667 long_sym=${long_sym}${long_sym}
670 echo "create 512 short and long symlink files under $wdir"
671 for ((i = 0; i < 256; ++i)); do
672 ln -sf ${long_sym}"a5a5" $wdir/long-$i
673 ln -sf ${short_sym}"a5a5" $wdir/short-$i
679 wait_delete_completed
681 echo "recreate the 512 symlink files with a shorter string"
682 for ((i = 0; i < 512; ++i)); do
683 # rewrite the symlink file with a shorter string
684 ln -sf ${long_sym} $wdir/long-$i || error "long_sym failed"
685 ln -sf ${short_sym} $wdir/short-$i || error "short_sym failed"
688 local mds_index=$(($($LFS getstripe -m $wdir) + 1))
689 local devname=$(mdsdevname $mds_index)
691 echo "stop and checking mds${mds_index}:"
692 # e2fsck should not return error
694 run_e2fsck $(facet_active_host mds${mds_index}) $devname -n
697 start mds${mds_index} $devname $MDS_MOUNT_OPTS ||
698 error "start mds${mds_index} failed"
699 df $MOUNT > /dev/null 2>&1
701 error "e2fsck detected error for short/long symlink: rc=$rc"
704 run_test 17m "run e2fsck against MDT which contains short/long symlink"
706 check_fs_consistency_17n() {
710 # create/unlink in 17n only change 2 MDTs(MDT1/MDT2),
711 # so it only check MDT1/MDT2 instead of all of MDTs.
712 for mdt_index in 1 2; do
713 local devname=$(mdsdevname $mdt_index)
714 # e2fsck should not return error
716 run_e2fsck $(facet_active_host mds$mdt_index) $devname -n ||
719 start mds${mdt_index} $devname $MDS_MOUNT_OPTS ||
720 error "mount mds$mdt_index failed"
721 df $MOUNT > /dev/null 2>&1
727 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
728 [ $PARALLEL == "yes" ] && skip "skip parallel run"
729 [ "$mds1_FSTYPE" != "ldiskfs" ] && skip_env "ldiskfs only test"
730 remote_mds_nodsh && skip "remote MDS with nodsh"
731 [ $MDS1_VERSION -ge $(version_code 2.2.0) ] &&
732 [ $MDS1_VERSION -le $(version_code 2.2.93) ] &&
733 skip "MDS 2.2.0-2.2.93 do not NUL-terminate symlinks"
737 test_mkdir $DIR/$tdir
738 for ((i=0; i<10; i++)); do
739 $LFS mkdir -i1 -c2 $DIR/$tdir/remote_dir_${i} ||
740 error "create remote dir error $i"
741 createmany -o $DIR/$tdir/remote_dir_${i}/f 10 ||
742 error "create files under remote dir failed $i"
745 check_fs_consistency_17n ||
746 error "e2fsck report error after create files under remote dir"
748 for ((i = 0; i < 10; i++)); do
749 rm -rf $DIR/$tdir/remote_dir_${i} ||
750 error "destroy remote dir error $i"
753 check_fs_consistency_17n ||
754 error "e2fsck report error after unlink files under remote dir"
756 [ $MDS1_VERSION -lt $(version_code 2.4.50) ] &&
757 skip "lustre < 2.4.50 does not support migrate mv"
759 for ((i = 0; i < 10; i++)); do
760 mkdir -p $DIR/$tdir/remote_dir_${i}
761 createmany -o $DIR/$tdir/remote_dir_${i}/f 10 ||
762 error "create files under remote dir failed $i"
763 $LFS migrate --mdt-index 1 $DIR/$tdir/remote_dir_${i} ||
764 error "migrate remote dir error $i"
766 check_fs_consistency_17n || error "e2fsck report error after migration"
768 for ((i = 0; i < 10; i++)); do
769 rm -rf $DIR/$tdir/remote_dir_${i} ||
770 error "destroy remote dir error $i"
773 check_fs_consistency_17n || error "e2fsck report error after unlink"
775 run_test 17n "run e2fsck against master/slave MDT which contains remote dir"
778 remote_mds_nodsh && skip "remote MDS with nodsh"
779 [ $MDS1_VERSION -lt $(version_code 2.3.64) ] &&
780 skip "Need MDS version at least 2.3.64"
782 local wdir=$DIR/${tdir}o
788 mdt_index=$($LFS getstripe -m $wdir/$tfile)
789 mdt_index=$((mdt_index + 1))
792 #fail mds will wait the failover finish then set
793 #following fail_loc to avoid interfer the recovery process.
796 #define OBD_FAIL_OSD_LMA_INCOMPAT 0x194
797 do_facet mds${mdt_index} lctl set_param fail_loc=0x194
798 ls -l $wdir/$tfile && rc=1
799 do_facet mds${mdt_index} lctl set_param fail_loc=0
800 [[ $rc -eq 0 ]] || error "stat file should fail"
802 run_test 17o "stat file with incompat LMA feature"
805 touch $DIR/$tfile || error "Failed to touch $DIR/$tfile: $?"
806 ls $DIR || error "Failed to ls $DIR: $?"
808 run_test 18 "touch .../f ; ls ... =============================="
814 $CHECKSTAT -a $DIR/$tfile || error "$tfile was not removed"
816 run_test 19a "touch .../f19 ; ls -l ... ; rm .../f19 ==========="
819 ls -l $DIR/$tfile && error "ls -l $tfile failed"|| true
821 run_test 19b "ls -l .../f19 (should return error) =============="
824 [ $RUNAS_ID -eq $UID ] &&
825 skip_env "RUNAS_ID = UID = $UID -- skipping"
827 $RUNAS touch $DIR/$tfile && error "create non-root file failed" || true
829 run_test 19c "$RUNAS touch .../f19 (should return error) =="
832 cat $DIR/f19 && error || true
834 run_test 19d "cat .../f19 (should return error) =============="
843 $CHECKSTAT -a $DIR/$tfile || error "$tfile was not removed"
845 run_test 20 "touch .../f ; ls -l ..."
848 test_mkdir $DIR/$tdir
849 [ -f $DIR/$tdir/dangle ] && rm -f $DIR/$tdir/dangle
850 ln -s dangle $DIR/$tdir/link
851 echo foo >> $DIR/$tdir/link
852 cat $DIR/$tdir/dangle
853 $CHECKSTAT -t link $DIR/$tdir/link || error "$tdir/link not a link"
854 $CHECKSTAT -f -t file $DIR/$tdir/link ||
855 error "$tdir/link not linked to a file"
857 run_test 21 "write to dangling link"
860 local wdir=$DIR/$tdir
862 chown $RUNAS_ID:$RUNAS_GID $wdir
863 (cd $wdir || error "cd $wdir failed";
864 $RUNAS tar cf - /etc/hosts /etc/sysconfig/network |
866 ls -lR $wdir/etc || error "ls -lR $wdir/etc failed"
867 $CHECKSTAT -t dir $wdir/etc || error "checkstat -t dir failed"
868 $CHECKSTAT -u \#$RUNAS_ID -g \#$RUNAS_GID $wdir/etc ||
869 error "checkstat -u failed"
871 run_test 22 "unpack tar archive as non-root user"
875 test_mkdir $DIR/$tdir
876 local file=$DIR/$tdir/$tfile
878 openfile -f O_CREAT:O_EXCL $file || error "$file create failed"
879 openfile -f O_CREAT:O_EXCL $file &&
880 error "$file recreate succeeded" || true
882 run_test 23a "O_CREAT|O_EXCL in subdir"
884 test_23b() { # bug 18988
885 test_mkdir $DIR/$tdir
886 local file=$DIR/$tdir/$tfile
889 echo foo > $file || error "write filed"
890 echo bar >> $file || error "append filed"
891 $CHECKSTAT -s 8 $file || error "wrong size"
894 run_test 23b "O_APPEND check"
896 # LU-9409, size with O_APPEND and tiny writes
898 local file=$DIR/$tfile
901 dd conv=notrunc oflag=append if=/dev/zero of=$file bs=8 count=800
902 $CHECKSTAT -s 6400 $file || error "wrong size, expected 6400"
906 dd conv=notrunc oflag=append if=/dev/zero of=$file bs=8 count=800 &
907 dd conv=notrunc oflag=append if=/dev/zero of=$file bs=8 count=800 &
909 $CHECKSTAT -s 12800 $file || error "wrong size, expected 12800"
912 #racing tiny & normal writes
913 dd conv=notrunc oflag=append if=/dev/zero of=$file bs=4096 count=4 &
914 dd conv=notrunc oflag=append if=/dev/zero of=$file bs=8 count=100 &
916 $CHECKSTAT -s 17184 $file || error "wrong size, expected 17184"
919 #racing tiny & normal writes 2, ugly numbers
920 dd conv=notrunc oflag=append if=/dev/zero of=$file bs=4099 count=11 &
921 dd conv=notrunc oflag=append if=/dev/zero of=$file bs=17 count=173 &
923 $CHECKSTAT -s 48030 $file || error "wrong size, expected 48030"
926 run_test 23c "O_APPEND size checks for tiny writes"
928 # LU-11069 file offset is correct after appending writes
930 local file=$DIR/$tfile
933 echo CentaurHauls > $file
934 offset=$($MULTIOP $file oO_WRONLY:O_APPEND:w13Zp)
935 if ((offset != 26)); then
936 error "wrong offset, expected 26, got '$offset'"
939 run_test 23d "file offset is correct after appending writes"
943 echo '-- same directory rename'
944 test_mkdir $DIR/$tdir
945 touch $DIR/$tdir/$tfile.1
946 mv $DIR/$tdir/$tfile.1 $DIR/$tdir/$tfile.2
947 $CHECKSTAT -t file $DIR/$tdir/$tfile.2 || error "$tfile.2 not a file"
949 run_test 24a "rename file to non-existent target"
952 test_mkdir $DIR/$tdir
953 touch $DIR/$tdir/$tfile.{1,2}
954 mv $DIR/$tdir/$tfile.1 $DIR/$tdir/$tfile.2
955 $CHECKSTAT -a $DIR/$tdir/$tfile.1 || error "$tfile.1 exists"
956 $CHECKSTAT -t file $DIR/$tdir/$tfile.2 || error "$tfile.2 not a file"
958 run_test 24b "rename file to existing target"
961 test_mkdir $DIR/$tdir
962 test_mkdir $DIR/$tdir/d$testnum.1
963 mv $DIR/$tdir/d$testnum.1 $DIR/$tdir/d$testnum.2
964 $CHECKSTAT -a $DIR/$tdir/d$testnum.1 || error "d$testnum.1 exists"
965 $CHECKSTAT -t dir $DIR/$tdir/d$testnum.2 || error "d$testnum.2 not dir"
967 run_test 24c "rename directory to non-existent target"
970 test_mkdir -c1 $DIR/$tdir
971 test_mkdir -c1 $DIR/$tdir/d$testnum.1
972 test_mkdir -c1 $DIR/$tdir/d$testnum.2
973 mrename $DIR/$tdir/d$testnum.1 $DIR/$tdir/d$testnum.2
974 $CHECKSTAT -a $DIR/$tdir/d$testnum.1 || error "d$testnum.1 exists"
975 $CHECKSTAT -t dir $DIR/$tdir/d$testnum.2 || error "d$testnum.2 not dir"
977 run_test 24d "rename directory to existing target"
980 echo '-- cross directory renames --'
984 mv $DIR/R5a/f $DIR/R5b/g
985 $CHECKSTAT -a $DIR/R5a/f || error "$DIR/R5a/f exists"
986 $CHECKSTAT -t file $DIR/R5b/g || error "$DIR/R5b/g not file type"
988 run_test 24e "touch .../R5a/f; rename .../R5a/f .../R5b/g ======"
993 touch $DIR/R6a/f $DIR/R6b/g
994 mv $DIR/R6a/f $DIR/R6b/g
995 $CHECKSTAT -a $DIR/R6a/f || error "$DIR/R6a/f exists"
996 $CHECKSTAT -t file $DIR/R6b/g || error "$DIR/R6b/g not file type"
998 run_test 24f "touch .../R6a/f R6b/g; mv .../R6a/f .../R6b/g ===="
1003 test_mkdir $DIR/R7a/d
1004 mv $DIR/R7a/d $DIR/R7b/e
1005 $CHECKSTAT -a $DIR/R7a/d || error "$DIR/R7a/d exists"
1006 $CHECKSTAT -t dir $DIR/R7b/e || error "$DIR/R7b/e not dir type"
1008 run_test 24g "mkdir .../R7{a,b}/d; mv .../R7a/d .../R7b/e ======"
1011 test_mkdir -c1 $DIR/R8a
1012 test_mkdir -c1 $DIR/R8b
1013 test_mkdir -c1 $DIR/R8a/d
1014 test_mkdir -c1 $DIR/R8b/e
1015 mrename $DIR/R8a/d $DIR/R8b/e
1016 $CHECKSTAT -a $DIR/R8a/d || error "$DIR/R8a/d exists"
1017 $CHECKSTAT -t dir $DIR/R8b/e || error "$DIR/R8b/e not dir type"
1019 run_test 24h "mkdir .../R8{a,b}/{d,e}; rename .../R8a/d .../R8b/e"
1022 echo "-- rename error cases"
1024 test_mkdir $DIR/R9/a
1026 mrename $DIR/R9/f $DIR/R9/a
1027 $CHECKSTAT -t file $DIR/R9/f || error "$DIR/R9/f not file type"
1028 $CHECKSTAT -t dir $DIR/R9/a || error "$DIR/R9/a not dir type"
1029 $CHECKSTAT -a $DIR/R9/a/f || error "$DIR/R9/a/f exists"
1031 run_test 24i "rename file to dir error: touch f ; mkdir a ; rename f a"
1035 mrename $DIR/R10/f $DIR/R10/g
1036 $CHECKSTAT -t dir $DIR/R10 || error "$DIR/R10 not dir type"
1037 $CHECKSTAT -a $DIR/R10/f || error "$DIR/R10/f exists"
1038 $CHECKSTAT -a $DIR/R10/g || error "$DIR/R10/g exists"
1040 run_test 24j "source does not exist ============================"
1043 test_mkdir $DIR/R11a
1044 test_mkdir $DIR/R11a/d
1046 mv $DIR/R11a/f $DIR/R11a/d
1047 $CHECKSTAT -a $DIR/R11a/f || error "$DIR/R11a/f exists"
1048 $CHECKSTAT -t file $DIR/R11a/d/f || error "$DIR/R11a/d/f not file type"
1050 run_test 24k "touch .../R11a/f; mv .../R11a/f .../R11a/d ======="
1052 # bug 2429 - rename foo foo foo creates invalid file
1055 $MULTIOP $f OcNs || error "rename of ${f} to itself failed"
1057 run_test 24l "Renaming a file to itself ========================"
1061 $MULTIOP $f OcLN ${f}2 ${f}2 || error "link ${f}2 ${f}2 failed"
1062 # on ext3 this does not remove either the source or target files
1063 # though the "expected" operation would be to remove the source
1064 $CHECKSTAT -t file ${f} || error "${f} missing"
1065 $CHECKSTAT -t file ${f}2 || error "${f}2 missing"
1067 run_test 24m "Renaming a file to a hard link to itself ========="
1071 # this stats the old file after it was renamed, so it should fail
1073 $CHECKSTAT ${f} || error "${f} missing"
1075 $CHECKSTAT ${f}.rename || error "${f}.rename missing"
1076 $CHECKSTAT -a ${f} || error "${f} exists"
1078 run_test 24n "Statting the old file after renaming (Posix rename 2)"
1081 test_mkdir $DIR/$tdir
1082 rename_many -s random -v -n 10 $DIR/$tdir
1084 run_test 24o "rename of files during htree split"
1087 test_mkdir $DIR/R12a
1088 test_mkdir $DIR/R12b
1089 DIRINO=`ls -lid $DIR/R12a | awk '{ print $1 }'`
1090 mrename $DIR/R12a $DIR/R12b
1091 $CHECKSTAT -a $DIR/R12a || error "$DIR/R12a exists"
1092 $CHECKSTAT -t dir $DIR/R12b || error "$DIR/R12b not dir type"
1093 DIRINO2=`ls -lid $DIR/R12b | awk '{ print $1 }'`
1094 [ "$DIRINO" = "$DIRINO2" ] || error "R12a $DIRINO != R12b $DIRINO2"
1096 run_test 24p "mkdir .../R12{a,b}; rename .../R12a .../R12b"
1098 cleanup_multiop_pause() {
1100 kill -USR1 $MULTIPID
1104 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1106 test_mkdir $DIR/R13a
1107 test_mkdir $DIR/R13b
1108 local DIRINO=$(ls -lid $DIR/R13a | awk '{ print $1 }')
1109 multiop_bg_pause $DIR/R13b D_c || error "multiop failed to start"
1112 trap cleanup_multiop_pause EXIT
1113 mrename $DIR/R13a $DIR/R13b
1114 $CHECKSTAT -a $DIR/R13a || error "R13a still exists"
1115 $CHECKSTAT -t dir $DIR/R13b || error "R13b does not exist"
1116 local DIRINO2=$(ls -lid $DIR/R13b | awk '{ print $1 }')
1117 [ "$DIRINO" = "$DIRINO2" ] || error "R13a $DIRINO != R13b $DIRINO2"
1118 cleanup_multiop_pause
1119 wait $MULTIPID || error "multiop close failed"
1121 run_test 24q "mkdir .../R13{a,b}; open R13b rename R13a R13b ==="
1123 test_24r() { #bug 3789
1124 test_mkdir $DIR/R14a
1125 test_mkdir $DIR/R14a/b
1126 mrename $DIR/R14a $DIR/R14a/b && error "rename to subdir worked!"
1127 $CHECKSTAT -t dir $DIR/R14a || error "$DIR/R14a missing"
1128 $CHECKSTAT -t dir $DIR/R14a/b || error "$DIR/R14a/b missing"
1130 run_test 24r "mkdir .../R14a/b; rename .../R14a .../R14a/b ====="
1133 test_mkdir $DIR/R15a
1134 test_mkdir $DIR/R15a/b
1135 test_mkdir $DIR/R15a/b/c
1136 mrename $DIR/R15a $DIR/R15a/b/c && error "rename to sub-subdir worked!"
1137 $CHECKSTAT -t dir $DIR/R15a || error "$DIR/R15a missing"
1138 $CHECKSTAT -t dir $DIR/R15a/b/c || error "$DIR/R15a/b/c missing"
1140 run_test 24s "mkdir .../R15a/b/c; rename .../R15a .../R15a/b/c ="
1142 test_mkdir $DIR/R16a
1143 test_mkdir $DIR/R16a/b
1144 test_mkdir $DIR/R16a/b/c
1145 mrename $DIR/R16a/b/c $DIR/R16a && error "rename to sub-subdir worked!"
1146 $CHECKSTAT -t dir $DIR/R16a || error "$DIR/R16a missing"
1147 $CHECKSTAT -t dir $DIR/R16a/b/c || error "$DIR/R16a/b/c missing"
1149 run_test 24t "mkdir .../R16a/b/c; rename .../R16a/b/c .../R16a ="
1151 test_24u() { # bug12192
1152 $MULTIOP $DIR/$tfile C2w$((2048 * 1024))c || error "multiop failed"
1153 $CHECKSTAT -s $((2048 * 1024)) $DIR/$tfile || error "wrong file size"
1155 run_test 24u "create stripe file"
1157 simple_cleanup_common() {
1160 [ -z "$DIR" ] || [ -z "$tdir" ] && return 0
1162 local start=$SECONDS
1165 wait_delete_completed
1166 echo "cleanup time $((SECONDS - start))"
1170 max_pages_per_rpc() {
1171 local mdtname="$(printf "MDT%04x" ${1:-0})"
1172 $LCTL get_param -n mdc.*$mdtname*.max_pages_per_rpc
1176 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1178 local nrfiles=${COUNT:-100000}
1179 local fname="$DIR/$tdir/$tfile"
1181 # Performance issue on ZFS see LU-4072 (c.f. LU-2887)
1182 [ "$mds1_FSTYPE" = "zfs" ] && nrfiles=${COUNT:-10000}
1184 test_mkdir "$(dirname $fname)"
1185 # assume MDT0000 has the fewest inodes
1186 local stripes=$($LFS getdirstripe -c $(dirname $fname))
1187 local free_inodes=$(($(mdt_free_inodes 0) * stripes))
1188 [[ $free_inodes -lt $nrfiles ]] && nrfiles=$free_inodes
1190 trap simple_cleanup_common EXIT
1192 createmany -m "$fname" $nrfiles
1194 cancel_lru_locks mdc
1195 lctl set_param mdc.*.stats clear
1197 # was previously test_24D: LU-6101
1198 # readdir() returns correct number of entries after cursor reload
1199 local num_ls=$(ls $DIR/$tdir | wc -l)
1200 local num_uniq=$(ls $DIR/$tdir | sort -u | wc -l)
1201 local num_all=$(ls -a $DIR/$tdir | wc -l)
1202 if [ $num_ls -ne $nrfiles ] || [ $num_uniq -ne $nrfiles ] ||
1203 [ $num_all -ne $((nrfiles + 2)) ]; then
1204 error "Expected $nrfiles files, got $num_ls " \
1205 "($num_uniq unique $num_all .&..)"
1207 # LU-5 large readdir
1208 # dirent_size = 32 bytes for sizeof(struct lu_dirent) +
1209 # N bytes for name (len($nrfiles) rounded to 8 bytes) +
1210 # 8 bytes for luda_type (4 bytes rounded to 8 bytes)
1211 # take into account of overhead in lu_dirpage header and end mark in
1212 # each page, plus one in rpc_num calculation.
1213 local dirent_size=$((32 + (${#tfile} | 7) + 1 + 8))
1214 local page_entries=$(((PAGE_SIZE - 24) / dirent_size))
1215 local mdt_idx=$($LFS getdirstripe -i $(dirname $fname))
1216 local rpc_pages=$(max_pages_per_rpc $mdt_idx)
1217 local rpc_max=$((nrfiles / (page_entries * rpc_pages) + stripes))
1218 local mds_readpage=$(calc_stats mdc.*.stats mds_readpage)
1219 echo "readpages: $mds_readpage rpc_max: $rpc_max"
1220 (( $mds_readpage < $rpc_max - 2 || $mds_readpage > $rpc_max + 1)) &&
1221 error "large readdir doesn't take effect: " \
1222 "$mds_readpage should be about $rpc_max"
1224 simple_cleanup_common
1226 run_test 24v "list large directory (test hash collision, b=17560)"
1228 test_24w() { # bug21506
1230 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=4096 || return 1
1231 dd if=/dev/zero bs=$SZ1 count=1 >> $DIR/$tfile || return 2
1232 dd if=$DIR/$tfile of=$DIR/${tfile}_left bs=1M skip=4097 || return 3
1233 SZ2=`ls -l $DIR/${tfile}_left | awk '{print $5}'`
1234 [[ "$SZ1" -eq "$SZ2" ]] ||
1235 error "Error reading at the end of the file $tfile"
1237 run_test 24w "Reading a file larger than 4Gb"
1240 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
1241 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1242 [[ $MDS1_VERSION -lt $(version_code 2.7.56) ]] &&
1243 skip "Need MDS version at least 2.7.56"
1246 local remote_dir=$DIR/$tdir/remote_dir
1248 test_mkdir $DIR/$tdir
1249 $LFS mkdir -i $MDTIDX $remote_dir ||
1250 error "create remote directory failed"
1252 test_mkdir $DIR/$tdir/src_dir
1253 touch $DIR/$tdir/src_file
1254 test_mkdir $remote_dir/tgt_dir
1255 touch $remote_dir/tgt_file
1257 mrename $DIR/$tdir/src_dir $remote_dir/tgt_dir ||
1258 error "rename dir cross MDT failed!"
1260 mrename $DIR/$tdir/src_file $remote_dir/tgt_file ||
1261 error "rename file cross MDT failed!"
1263 touch $DIR/$tdir/ln_file
1264 ln $DIR/$tdir/ln_file $remote_dir/ln_name ||
1265 error "ln file cross MDT failed"
1267 rm -rf $DIR/$tdir || error "Can not delete directories"
1269 run_test 24x "cross MDT rename/link"
1272 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
1273 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1275 local remote_dir=$DIR/$tdir/remote_dir
1278 test_mkdir $DIR/$tdir
1279 $LFS mkdir -i $mdtidx $remote_dir ||
1280 error "create remote directory failed"
1282 test_mkdir $remote_dir/src_dir
1283 touch $remote_dir/src_file
1284 test_mkdir $remote_dir/tgt_dir
1285 touch $remote_dir/tgt_file
1287 mrename $remote_dir/src_dir $remote_dir/tgt_dir ||
1288 error "rename subdir in the same remote dir failed!"
1290 mrename $remote_dir/src_file $remote_dir/tgt_file ||
1291 error "rename files in the same remote dir failed!"
1293 ln $remote_dir/tgt_file $remote_dir/tgt_file1 ||
1294 error "link files in the same remote dir failed!"
1296 rm -rf $DIR/$tdir || error "Can not delete directories"
1298 run_test 24y "rename/link on the same dir should succeed"
1301 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
1302 [[ $MDS1_VERSION -lt $(version_code 2.12.51) ]] &&
1303 skip "Need MDS version at least 2.12.51"
1307 for index in 0 1; do
1308 $LFS mkdir -i $index $DIR/$tdir.$index || error "mkdir failed"
1309 touch $DIR/$tdir.0/$tfile.$index || error "touch failed"
1312 mv $DIR/$tdir.0/$tfile.0 $DIR/$tdir.1 || error "mv $tfile.0 failed"
1314 index=$($LFS getstripe -m $DIR/$tdir.1/$tfile.0)
1315 [ $index -eq 0 ] || error "$tfile.0 is on MDT$index"
1317 local mdts=$(comma_list $(mdts_nodes))
1319 do_nodes $mdts $LCTL set_param mdt.*.enable_remote_rename=0
1320 stack_trap "do_nodes $mdts $LCTL \
1321 set_param mdt.*.enable_remote_rename=1" EXIT
1323 mv $DIR/$tdir.0/$tfile.1 $DIR/$tdir.1 || error "mv $tfile.1 failed"
1325 index=$($LFS getstripe -m $DIR/$tdir.1/$tfile.1)
1326 [ $index -eq 1 ] || error "$tfile.1 is on MDT$index"
1328 run_test 24z "cross-MDT rename is done as cp"
1330 test_24A() { # LU-3182
1334 test_mkdir $DIR/$tdir
1335 trap simple_cleanup_common EXIT
1336 createmany -m $DIR/$tdir/$tfile $NFILES
1337 local t=$(ls $DIR/$tdir | wc -l)
1338 local u=$(ls $DIR/$tdir | sort -u | wc -l)
1339 local v=$(ls -ai $DIR/$tdir | sort -u | wc -l)
1340 if [ $t -ne $NFILES ] || [ $u -ne $NFILES ] ||
1341 [ $v -ne $((NFILES + 2)) ] ; then
1342 error "Expected $NFILES files, got $t ($u unique $v .&..)"
1345 simple_cleanup_common || error "Can not delete directories"
1347 run_test 24A "readdir() returns correct number of entries."
1349 test_24B() { # LU-4805
1350 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
1354 test_mkdir $DIR/$tdir
1355 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR/$tdir/striped_dir ||
1356 error "create striped dir failed"
1358 count=$(ls -ai $DIR/$tdir/striped_dir | wc -l)
1359 [ $count -eq 2 ] || error "Expected 2, got $count"
1361 touch $DIR/$tdir/striped_dir/a
1363 count=$(ls -ai $DIR/$tdir/striped_dir | wc -l)
1364 [ $count -eq 3 ] || error "Expected 3, got $count"
1366 touch $DIR/$tdir/striped_dir/.f
1368 count=$(ls -ai $DIR/$tdir/striped_dir | wc -l)
1369 [ $count -eq 4 ] || error "Expected 4, got $count"
1371 rm -rf $DIR/$tdir || error "Can not delete directories"
1373 run_test 24B "readdir for striped dir return correct number of entries"
1376 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
1382 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR/$tdir/d0/striped_dir ||
1383 error "create striped dir failed"
1385 cd $DIR/$tdir/d0/striped_dir
1387 local d0_ino=$(ls -i -l -a $DIR/$tdir | grep "d0" | awk '{print $1}')
1388 local d1_ino=$(ls -i -l -a $DIR/$tdir | grep "d1" | awk '{print $1}')
1389 local parent_ino=$(ls -i -l -a | grep "\.\." | awk '{print $1}')
1391 [ "$d0_ino" = "$parent_ino" ] ||
1392 error ".. wrong, expect $d0_ino, get $parent_ino"
1394 mv $DIR/$tdir/d0/striped_dir $DIR/$tdir/d1/ ||
1395 error "mv striped dir failed"
1397 parent_ino=$(ls -i -l -a | grep "\.\." | awk '{print $1}')
1399 [ "$d1_ino" = "$parent_ino" ] ||
1400 error ".. wrong after mv, expect $d1_ino, get $parent_ino"
1402 run_test 24C "check .. in striped dir"
1405 [[ $MDSCOUNT -lt 4 ]] && skip_env "needs >= 4 MDTs"
1406 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1409 mkdir $DIR/$tdir/src_dir
1410 $LFS mkdir -i 1 $DIR/$tdir/src_dir/src_child ||
1411 error "create remote source failed"
1413 touch $DIR/$tdir/src_dir/src_child/a
1415 $LFS mkdir -i 2 $DIR/$tdir/tgt_dir ||
1416 error "create remote target dir failed"
1418 $LFS mkdir -i 3 $DIR/$tdir/tgt_dir/tgt_child ||
1419 error "create remote target child failed"
1421 mrename $DIR/$tdir/src_dir/src_child $DIR/$tdir/tgt_dir/tgt_child ||
1422 error "rename dir cross MDT failed!"
1426 $CHECKSTAT -t dir $DIR/$tdir/src_dir/src_child &&
1427 error "src_child still exists after rename"
1429 $CHECKSTAT -t file $DIR/$tdir/tgt_dir/tgt_child/a ||
1430 error "missing file(a) after rename"
1432 rm -rf $DIR/$tdir || error "Can not delete directories"
1434 run_test 24E "cross MDT rename/link"
1437 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
1440 [ "$SLOW" = "no" ] && repeats=100
1444 echo "$repeats repeats"
1445 for ((i = 0; i < repeats; i++)); do
1446 $LFS mkdir -i0 -c2 $DIR/$tdir/test || error "mkdir fails"
1447 touch $DIR/$tdir/test/a || error "touch fails"
1448 mkdir $DIR/$tdir/test/b || error "mkdir fails"
1449 rm -rf $DIR/$tdir/test || error "rmdir fails"
1454 run_test 24F "hash order vs readdir (LU-11330)"
1457 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
1462 $LFS mkdir -i 0 $DIR/$tdir-0 || error "mkdir $tdir-0"
1463 $LFS mkdir -i 1 $DIR/$tdir-1 || error "mkdir $tdir-1"
1464 touch $DIR/$tdir-0/f1 || error "touch f1"
1465 ln -s $DIR/$tdir-0/f1 $DIR/$tdir-0/s1 || error "ln s1"
1466 ino1=$(stat -c%i $DIR/$tdir-0/s1)
1467 mv $DIR/$tdir-0/s1 $DIR/$tdir-1 || error "mv s1"
1468 ino2=$(stat -c%i $DIR/$tdir-1/s1)
1469 [ $ino1 -ne $ino2 ] || error "s1 should be migrated"
1471 run_test 24G "migrate symlink in rename"
1474 echo '== symlink sanity ============================================='
1478 touch $DIR/s25/foo ||
1479 error "File creation in symlinked directory failed"
1481 run_test 25a "create file in symlinked directory ==============="
1484 [ ! -d $DIR/d25 ] && test_25a
1485 $CHECKSTAT -t file $DIR/s25/foo || error "$DIR/s25/foo not file type"
1487 run_test 25b "lookup file in symlinked directory ==============="
1491 test_mkdir $DIR/d26/d26-2
1492 ln -s d26/d26-2 $DIR/s26
1493 touch $DIR/s26/foo || error "File creation failed"
1495 run_test 26a "multiple component symlink ======================="
1498 test_mkdir -p $DIR/$tdir/d26-2
1499 ln -s $tdir/d26-2/foo $DIR/s26-2
1500 touch $DIR/s26-2 || error "File creation failed"
1502 run_test 26b "multiple component symlink at end of lookup ======"
1505 test_mkdir $DIR/d26.2
1506 touch $DIR/d26.2/foo
1507 ln -s d26.2 $DIR/s26.2-1
1508 ln -s s26.2-1 $DIR/s26.2-2
1509 ln -s s26.2-2 $DIR/s26.2-3
1510 chmod 0666 $DIR/s26.2-3/foo
1512 run_test 26c "chain of symlinks"
1514 # recursive symlinks (bug 439)
1516 ln -s d26-3/foo $DIR/d26-3
1518 run_test 26d "create multiple component recursive symlink"
1521 [ ! -h $DIR/d26-3 ] && test_26d
1524 run_test 26e "unlink multiple component recursive symlink"
1526 # recursive symlinks (bug 7022)
1528 test_mkdir $DIR/$tdir
1529 test_mkdir $DIR/$tdir/$tfile
1530 cd $DIR/$tdir/$tfile || error "cd $DIR/$tdir/$tfile failed"
1531 test_mkdir -p lndir/bar1
1532 test_mkdir $DIR/$tdir/$tfile/$tfile
1533 cd $tfile || error "cd $tfile failed"
1534 ln -s .. dotdot || error "ln dotdot failed"
1535 ln -s dotdot/lndir lndir || error "ln lndir failed"
1536 cd $DIR/$tdir || error "cd $DIR/$tdir failed"
1537 output=`ls $tfile/$tfile/lndir/bar1`
1538 [ "$output" = bar1 ] && error "unexpected output"
1539 rm -r $tfile || error "rm $tfile failed"
1540 $CHECKSTAT -a $DIR/$tfile || error "$tfile not gone"
1542 run_test 26f "rm -r of a directory which has recursive symlink"
1545 test_mkdir $DIR/$tdir
1546 $LFS getstripe $DIR/$tdir
1547 $LFS setstripe -c 1 $DIR/$tdir/$tfile || error "setstripe failed"
1548 $CHECKSTAT -t file $DIR/$tdir/$tfile || error "checkstat failed"
1549 cp /etc/hosts $DIR/$tdir/$tfile || error "Can't copy to one stripe file"
1551 run_test 27a "one stripe file"
1554 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
1556 test_mkdir $DIR/$tdir
1557 $LFS setstripe -c 2 $DIR/$tdir/$tfile || error "setstripe failed"
1558 $LFS getstripe -c $DIR/$tdir/$tfile
1559 [ $($LFS getstripe -c $DIR/$tdir/$tfile) -eq 2 ] ||
1560 error "two-stripe file doesn't have two stripes"
1562 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=4k count=4 || error "dd failed"
1564 run_test 27b "create and write to two stripe file"
1566 # 27c family tests specific striping, setstripe -o
1568 [[ $OSTCOUNT -lt 2 ]] && skip_env "skipping 2-stripe test"
1569 test_mkdir -p $DIR/$tdir
1572 $LFS setstripe -o $osts $DIR/$tdir/$tfile || error "setstripe failed"
1573 $LFS getstripe -i $DIR/$tdir/$tfile
1574 [ $($LFS getstripe -i $DIR/$tdir/$tfile ) -eq $osts ] ||
1575 error "stripe not on specified OST"
1577 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=4 || error "dd failed"
1579 run_test 27ca "one stripe on specified OST"
1582 [[ $OSTCOUNT -lt 2 ]] && skip_env "skipping 2-stripe test"
1583 test_mkdir -p $DIR/$tdir
1585 $LFS setstripe -o $osts $DIR/$tdir/$tfile || error "setstripe failed"
1586 local getstripe=$($LFS getstripe $DIR/$tdir/$tfile)
1589 # Strip getstripe output to a space separated list of OSTs
1590 local getstripe_osts=$(echo "$getstripe" | sed -e '1,/obdidx/d' |\
1591 awk '{print $1}' | tr '\n' ' ' | sed -e 's/[[:space:]]*$//')
1592 [ "$getstripe_osts" = "${osts//,/ }" ] ||
1593 error "stripes not on specified OSTs"
1595 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=4 || error "dd failed"
1597 run_test 27cb "two stripes on specified OSTs"
1600 [[ $OSTCOUNT -lt 2 ]] && skip_env "skipping 2-stripe test"
1601 [[ $($LCTL get_param mdc.*.import) =~ connect_flags.*overstriping ]] ||
1602 skip "server does not support overstriping"
1604 test_mkdir -p $DIR/$tdir
1606 $LFS setstripe -o $osts $DIR/$tdir/$tfile || error "setstripe failed"
1607 local getstripe=$($LFS getstripe $DIR/$tdir/$tfile)
1610 # Strip getstripe output to a space separated list of OSTs
1611 local getstripe_osts=$(echo "$getstripe" | sed -e '1,/obdidx/d' |\
1612 awk '{print $1}' | tr '\n' ' ' | sed -e 's/[[:space:]]*$//')
1613 [ "$getstripe_osts" = "${osts//,/ }" ] ||
1614 error "stripes not on specified OSTs"
1616 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=4 || error "dd failed"
1618 run_test 27cc "two stripes on the same OST"
1621 [[ $OSTCOUNT -lt 2 ]] && skip_env "skipping 2-stripe test"
1622 [[ $($LCTL get_param mdc.*.import) =~ connect_flags.*overstriping ]] ||
1623 skip "server does not support overstriping"
1624 test_mkdir -p $DIR/$tdir
1625 local osts="0,1,1,0"
1626 $LFS setstripe -o $osts $DIR/$tdir/$tfile || error "setstripe failed"
1627 local getstripe=$($LFS getstripe $DIR/$tdir/$tfile)
1630 # Strip getstripe output to a space separated list of OSTs
1631 local getstripe_osts=$(echo "$getstripe" | sed -e '1,/obdidx/d' |\
1632 awk '{print $1}' | tr '\n' ' ' | sed -e 's/[[:space:]]*$//')
1633 [ "$getstripe_osts" = "${osts//,/ }" ] ||
1634 error "stripes not on specified OSTs"
1636 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=4 || error "dd failed"
1638 run_test 27cd "four stripes on two OSTs"
1641 [[ $OSTCOUNT -ge $(($LOV_MAX_STRIPE_COUNT / 2)) ]] &&
1642 skip_env "too many osts, skipping"
1643 [[ $($LCTL get_param mdc.*.import) =~ connect_flags.*overstriping ]] ||
1644 skip "server does not support overstriping"
1645 # We do one more stripe than we have OSTs
1646 [ $OSTCOUNT -lt 159 ] || large_xattr_enabled ||
1647 skip_env "ea_inode feature disabled"
1649 test_mkdir -p $DIR/$tdir
1651 for i in $(seq 0 $OSTCOUNT);
1654 if [ $i -ne $OSTCOUNT ]; then
1658 $LFS setstripe -o $osts $DIR/$tdir/$tfile || error "setstripe failed"
1659 local getstripe=$($LFS getstripe $DIR/$tdir/$tfile)
1662 # Strip getstripe output to a space separated list of OSTs
1663 local getstripe_osts=$(echo "$getstripe" | sed -e '1,/obdidx/d' |\
1664 awk '{print $1}' | tr '\n' ' ' | sed -e 's/[[:space:]]*$//')
1665 [ "$getstripe_osts" = "${osts//,/ }" ] ||
1666 error "stripes not on specified OSTs"
1668 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=4 || error "dd failed"
1670 run_test 27ce "more stripes than OSTs with -o"
1673 local osp_proc="osp.$FSNAME-OST0000-osc-MDT000*.active"
1676 test_mkdir -p $DIR/$tdir || error "failed to mkdir $DIR/$tdir"
1677 do_facet $SINGLEMDS "$LCTL set_param -n $osp_proc=0"
1678 stack_trap "do_facet $SINGLEMDS $LCTL set_param -n $osp_proc=1" EXIT
1679 wait_update_facet $SINGLEMDS "$LCTL get_param -n $osp_proc | grep 1" ||
1680 error "failed to set $osp_proc=0"
1682 $LFS setstripe -o 0 $DIR/$tdir/$tfile &
1685 do_facet $SINGLEMDS "$LCTL set_param -n $osp_proc=1"
1686 wait_update_facet $SINGLEMDS "$LCTL get_param -n $osp_proc | grep 0" ||
1687 error "failed to set $osp_proc=1"
1690 error "should return error due to $osp_proc=0"
1692 run_test 27cf "'setstripe -o' on inactive OSTs should return error"
1695 test_mkdir $DIR/$tdir
1696 $LFS setstripe -c 0 -i -1 -S 0 $DIR/$tdir/$tfile ||
1697 error "setstripe failed"
1698 $CHECKSTAT -t file $DIR/$tdir/$tfile || error "checkstat failed"
1699 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=4k count=4 || error "dd failed"
1701 run_test 27d "create file with default settings"
1704 # LU-5839 adds check for existed layout before setting it
1705 [[ $MDS1_VERSION -lt $(version_code 2.7.56) ]] &&
1706 skip "Need MDS version at least 2.7.56"
1708 test_mkdir $DIR/$tdir
1709 $LFS setstripe -c 2 $DIR/$tdir/$tfile || error "setstripe failed"
1710 $LFS setstripe -c 2 $DIR/$tdir/$tfile && error "setstripe worked twice"
1711 $CHECKSTAT -t file $DIR/$tdir/$tfile || error "checkstat failed"
1713 run_test 27e "setstripe existing file (should return error)"
1716 test_mkdir $DIR/$tdir
1717 $LFS setstripe -S 100 -i 0 -c 1 $DIR/$tdir/$tfile &&
1718 error "$LFS setstripe $DIR/$tdir/$tfile failed"
1719 $CHECKSTAT -t file $DIR/$tdir/$tfile &&
1720 error "$CHECKSTAT -t file $DIR/$tdir/$tfile should fail"
1721 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=4k count=4 || error "dd failed"
1722 $LFS getstripe $DIR/$tdir/$tfile || error "$LFS getstripe failed"
1724 run_test 27f "setstripe with bad stripe size (should return error)"
1727 test_mkdir $DIR/$tdir
1728 $MCREATE $DIR/$tdir/$tfile || error "mcreate failed"
1729 $LFS getstripe $DIR/$tdir/$tfile 2>&1 | grep "no stripe info" ||
1730 error "$DIR/$tdir/$tfile has object"
1732 run_test 27g "$LFS getstripe with no objects"
1735 test_mkdir $DIR/$tdir
1736 touch $DIR/$tdir/$tfile || error "touch failed"
1737 ln -s bogus $DIR/$tdir/$tfile.2 || error "ln failed"
1738 $LFS getstripe -m $DIR/$tdir/$tfile $DIR/$tdir/$tfile.2
1740 (( rc == 2 )) || error "getstripe did not return ENOENT"
1742 run_test 27ga "$LFS getstripe with missing file (should return error)"
1745 test_mkdir $DIR/$tdir
1746 touch $DIR/$tdir/$tfile || error "touch failed"
1747 [[ $($LFS getstripe -c $DIR/$tdir/$tfile) -gt 0 ]] ||
1748 error "missing objects"
1750 run_test 27i "$LFS getstripe with some objects"
1753 test_mkdir $DIR/$tdir
1754 $LFS setstripe -i $OSTCOUNT $DIR/$tdir/$tfile &&
1755 error "setstripe failed" || true
1757 run_test 27j "setstripe with bad stripe offset (should return error)"
1759 test_27k() { # bug 2844
1760 test_mkdir $DIR/$tdir
1761 local file=$DIR/$tdir/$tfile
1762 local ll_max_blksize=$((4 * 1024 * 1024))
1763 $LFS setstripe -S 67108864 $file || error "setstripe failed"
1764 local blksize=$(stat $file | awk '/IO Block:/ { print $7 }')
1765 [ $blksize -le $ll_max_blksize ] || error "1:$blksize > $ll_max_blksize"
1766 dd if=/dev/zero of=$file bs=4k count=1
1767 blksize=$(stat $file | awk '/IO Block:/ { print $7 }')
1768 [ $blksize -le $ll_max_blksize ] || error "2:$blksize > $ll_max_blksize"
1770 run_test 27k "limit i_blksize for broken user apps"
1773 mcreate $DIR/$tfile || error "creating file"
1774 $RUNAS $LFS setstripe -c 1 $DIR/$tfile &&
1775 error "setstripe should have failed" || true
1777 run_test 27l "check setstripe permissions (should return error)"
1780 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
1782 [ -n "$RCLIENTS" -o -n "$MOUNT_2" ] &&
1783 skip_env "multiple clients -- skipping"
1785 ORIGFREE=$($LCTL get_param -n lov.$FSNAME-clilov-*.kbytesavail |
1787 if [[ $ORIGFREE -gt $MAXFREE ]]; then
1788 skip "$ORIGFREE > $MAXFREE skipping out-of-space test on OST0"
1790 trap simple_cleanup_common EXIT
1791 test_mkdir $DIR/$tdir
1792 $LFS setstripe -i 0 -c 1 $DIR/$tdir/$tfile.1
1793 dd if=/dev/zero of=$DIR/$tdir/$tfile.1 bs=1024 count=$MAXFREE &&
1794 error "dd should fill OST0"
1796 while $LFS setstripe -i 0 -c 1 $DIR/$tdir/$tfile.$i; do
1798 [ $i -gt 256 ] && break
1801 touch $DIR/$tdir/$tfile.$i
1802 [ $($LFS getstripe $DIR/$tdir/$tfile.$i | grep -A 10 obdidx |
1803 awk '{print $1}'| grep -w "0") ] &&
1804 error "OST0 was full but new created file still use it"
1806 touch $DIR/$tdir/$tfile.$i
1807 [ $($LFS getstripe $DIR/$tdir/$tfile.$i | grep -A 10 obdidx |
1808 awk '{print $1}'| grep -w "0") ] &&
1809 error "OST0 was full but new created file still use it"
1810 simple_cleanup_common
1812 run_test 27m "create file while OST0 was full"
1814 # OSCs keep a NOSPC flag that will be reset after ~5s (qos_maxage)
1815 # if the OST isn't full anymore.
1817 local ostidx=${1:-""}
1822 local list=$(comma_list $(osts_nodes))
1823 [ "$ostidx" ] && list=$(facet_host ost$((ostidx + 1)))
1825 do_nodes $list lctl set_param fail_loc=0
1826 wait_delete_completed # initiate all OST_DESTROYs from MDS to OST
1827 delay=$(do_facet $SINGLEMDS lctl get_param -n lov.*.qos_maxage |
1828 awk '{print $1 * 2;exit;}')
1829 get_prealloc="$LCTL get_param -n osc.*MDT*.prealloc_status |
1831 wait_update_facet $SINGLEMDS "$get_prealloc" "" $delay
1834 __exhaust_precreations() {
1837 local FAILIDX=${3:-$OSTIDX}
1838 local ofacet=ost$((OSTIDX + 1))
1840 mkdir_on_mdt0 $DIR/$tdir
1841 local mdtidx=$($LFS getstripe -m $DIR/$tdir)
1842 local mfacet=mds$((mdtidx + 1))
1843 echo OSTIDX=$OSTIDX MDTIDX=$mdtidx
1845 local OST=$(ostname_from_index $OSTIDX)
1848 local mdtosc_proc1=$(get_mdtosc_proc_path $mfacet $OST)
1849 local last_id=$(do_facet $mfacet lctl get_param -n \
1850 osp.$mdtosc_proc1.prealloc_last_id)
1851 local next_id=$(do_facet $mfacet lctl get_param -n \
1852 osp.$mdtosc_proc1.prealloc_next_id)
1854 local mdtosc_proc2=$(get_mdtosc_proc_path $mfacet)
1855 do_facet $mfacet lctl get_param osp.$mdtosc_proc2.prealloc*
1857 test_mkdir -p $DIR/$tdir/${OST}
1858 $LFS setstripe -i $OSTIDX -c 1 $DIR/$tdir/${OST}
1859 #define OBD_FAIL_OST_ENOSPC 0x215
1860 do_facet $ofacet lctl set_param fail_val=$FAILIDX fail_loc=0x215
1861 echo "Creating to objid $last_id on ost $OST..."
1862 createmany -o $DIR/$tdir/${OST}/f $next_id $((last_id - next_id + 2))
1863 do_facet $mfacet lctl get_param osp.$mdtosc_proc2.prealloc*
1864 do_facet $ofacet lctl set_param fail_loc=$FAILLOC
1867 exhaust_precreations() {
1868 __exhaust_precreations $1 $2 $3
1872 exhaust_all_precreations() {
1874 for (( i=0; i < OSTCOUNT; i++ )) ; do
1875 __exhaust_precreations $i $1 -1
1881 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
1882 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1883 remote_mds_nodsh && skip "remote MDS with nodsh"
1884 remote_ost_nodsh && skip "remote OST with nodsh"
1887 rm -f $DIR/$tdir/$tfile
1888 exhaust_precreations 0 0x80000215
1889 $LFS setstripe -c -1 $DIR/$tdir || error "setstripe failed"
1890 touch $DIR/$tdir/$tfile || error "touch failed"
1891 $LFS getstripe $DIR/$tdir/$tfile
1894 run_test 27n "create file with some full OSTs"
1897 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
1898 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1899 remote_mds_nodsh && skip "remote MDS with nodsh"
1900 remote_ost_nodsh && skip "remote OST with nodsh"
1903 rm -f $DIR/$tdir/$tfile
1904 exhaust_all_precreations 0x215
1906 touch $DIR/$tdir/$tfile && error "able to create $DIR/$tdir/$tfile"
1911 run_test 27o "create file with all full OSTs (should error)"
1913 function create_and_checktime() {
1918 for ((i=0; i < $loops; i++)); do
1919 local start=$SECONDS
1920 multiop $fname-$i Oc
1921 ((SECONDS-start < TIMEOUT)) ||
1922 error "creation took " $((SECONDS-$start)) && return 1
1927 local mdts=$(comma_list $(mdts_nodes))
1929 [ $MDS1_VERSION -lt $(version_code 2.13.57) ] &&
1930 skip "Need MDS version at least 2.13.57"
1932 local f0=$DIR/${tfile}-0
1933 local f1=$DIR/${tfile}-1
1935 wait_delete_completed
1937 # refill precreated objects
1938 $LFS setstripe -i0 -c1 $f0
1940 saved=$(do_facet mds1 $LCTL get_param -n lov.*0000*.qos_threshold_rr)
1941 # force QoS allocation policy
1942 do_nodes $mdts $LCTL set_param lov.*.qos_threshold_rr=0%
1943 stack_trap "do_nodes $mdts $LCTL set_param \
1944 lov.*.qos_threshold_rr=$saved" EXIT
1947 # one OST is unavailable, but still have few objects preallocated
1949 stack_trap "start ost1 $(ostdevname 1) $OST_MOUNT_OPTS; \
1950 rm -rf $f1 $DIR/$tdir*" EXIT
1952 for ((i=0; i < 7; i++)); do
1953 mkdir $DIR/$tdir$i || error "can't create dir"
1954 $LFS setstripe -c$((OSTCOUNT-1)) $DIR/$tdir$i ||
1955 error "can't set striping"
1957 for ((i=0; i < 7; i++)); do
1958 create_and_checktime $DIR/$tdir$i/$tfile 100 &
1962 run_test 27oo "don't let few threads to reserve too many objects"
1965 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
1966 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1967 remote_mds_nodsh && skip "remote MDS with nodsh"
1968 remote_ost_nodsh && skip "remote OST with nodsh"
1971 rm -f $DIR/$tdir/$tfile
1972 test_mkdir $DIR/$tdir
1974 $MCREATE $DIR/$tdir/$tfile || error "mcreate failed"
1975 $TRUNCATE $DIR/$tdir/$tfile 80000000 || error "truncate failed"
1976 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat failed"
1978 exhaust_precreations 0 0x80000215
1979 echo foo >> $DIR/$tdir/$tfile || error "append failed"
1980 $CHECKSTAT -s 80000004 $DIR/$tdir/$tfile || error "checkstat failed"
1981 $LFS getstripe $DIR/$tdir/$tfile
1985 run_test 27p "append to a truncated file with some full OSTs"
1988 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
1989 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1990 remote_mds_nodsh && skip "remote MDS with nodsh"
1991 remote_ost_nodsh && skip "remote OST with nodsh"
1994 rm -f $DIR/$tdir/$tfile
1996 mkdir_on_mdt0 $DIR/$tdir
1997 $MCREATE $DIR/$tdir/$tfile || error "mcreate $DIR/$tdir/$tfile failed"
1998 $TRUNCATE $DIR/$tdir/$tfile 80000000 ||
1999 error "truncate $DIR/$tdir/$tfile failed"
2000 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat failed"
2002 exhaust_all_precreations 0x215
2004 echo foo >> $DIR/$tdir/$tfile && error "append succeeded"
2005 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat 2 failed"
2009 run_test 27q "append to truncated file with all OSTs full (should error)"
2012 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
2013 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2014 remote_mds_nodsh && skip "remote MDS with nodsh"
2015 remote_ost_nodsh && skip "remote OST with nodsh"
2018 rm -f $DIR/$tdir/$tfile
2019 exhaust_precreations 0 0x80000215
2021 $LFS setstripe -i 0 -c 2 $DIR/$tdir/$tfile || error "setstripe failed"
2025 run_test 27r "stripe file with some full OSTs (shouldn't LBUG) ="
2027 test_27s() { # bug 10725
2028 test_mkdir $DIR/$tdir
2029 local stripe_size=$((4096 * 1024 * 1024)) # 2^32
2030 local stripe_count=0
2031 [ $OSTCOUNT -eq 1 ] || stripe_count=2
2032 $LFS setstripe -S $stripe_size -c $stripe_count $DIR/$tdir &&
2033 error "stripe width >= 2^32 succeeded" || true
2036 run_test 27s "lsm_xfersize overflow (should error) (bug 10725)"
2038 test_27t() { # bug 10864
2043 $WLFS getstripe $tfile
2046 run_test 27t "check that utils parse path correctly"
2048 test_27u() { # bug 4900
2049 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
2050 remote_mds_nodsh && skip "remote MDS with nodsh"
2053 local list=$(comma_list $(mdts_nodes))
2055 #define OBD_FAIL_MDS_OSC_PRECREATE 0x139
2056 do_nodes $list $LCTL set_param fail_loc=0x139
2057 test_mkdir -p $DIR/$tdir
2058 trap simple_cleanup_common EXIT
2059 createmany -o $DIR/$tdir/t- 1000
2060 do_nodes $list $LCTL set_param fail_loc=0
2062 TLOG=$TMP/$tfile.getstripe
2063 $LFS getstripe $DIR/$tdir > $TLOG
2064 OBJS=$(awk -vobj=0 '($1 == 0) { obj += 1 } END { print obj; }' $TLOG)
2065 unlinkmany $DIR/$tdir/t- 1000
2067 [[ $OBJS -gt 0 ]] &&
2068 error "$OBJS objects created on OST-0. See $TLOG" ||
2071 run_test 27u "skip object creation on OSC w/o objects"
2073 test_27v() { # bug 4900
2074 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
2075 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2076 remote_mds_nodsh && skip "remote MDS with nodsh"
2077 remote_ost_nodsh && skip "remote OST with nodsh"
2079 exhaust_all_precreations 0x215
2082 $LFS setstripe -c 1 $DIR/$tdir # 1 stripe / file
2084 touch $DIR/$tdir/$tfile
2085 #define OBD_FAIL_TGT_DELAY_PRECREATE 0x705
2087 for (( i=1; i < OSTCOUNT; i++ )); do
2088 do_facet ost$i lctl set_param fail_loc=0x705
2090 local START=`date +%s`
2091 createmany -o $DIR/$tdir/$tfile 32
2093 local FINISH=`date +%s`
2094 local TIMEOUT=`lctl get_param -n timeout`
2095 local PROCESS=$((FINISH - START))
2096 [ $PROCESS -ge $((TIMEOUT / 2)) ] && \
2097 error "$FINISH - $START >= $TIMEOUT / 2"
2098 sleep $((TIMEOUT / 2 - PROCESS))
2101 run_test 27v "skip object creation on slow OST"
2103 test_27w() { # bug 10997
2104 test_mkdir $DIR/$tdir
2105 $LFS setstripe -S 65536 $DIR/$tdir/f0 || error "setstripe failed"
2106 [ $($LFS getstripe -S $DIR/$tdir/f0) -ne 65536 ] &&
2107 error "stripe size $size != 65536" || true
2108 [ $($LFS getstripe -d $DIR/$tdir | grep -c "stripe_count") -eq 0 ] &&
2109 error "$LFS getstripe -d $DIR/$tdir no 'stripe_count'" || true
2111 run_test 27w "check $LFS setstripe -S and getstrip -d options"
2114 [[ $OSTCOUNT -lt 2 ]] &&
2115 skip_env "skipping multiple stripe count/offset test"
2117 test_mkdir $DIR/$tdir
2118 for i in $(seq 1 $OSTCOUNT); do
2120 $LFS setstripe -c $i -i $offset $DIR/$tdir/f$i ||
2121 error "setstripe -c $i -i $offset failed"
2122 count=$($LFS getstripe -c $DIR/$tdir/f$i)
2123 index=$($LFS getstripe -i $DIR/$tdir/f$i)
2124 [ $count -ne $i ] && error "stripe count $count != $i" || true
2125 [ $index -ne $offset ] &&
2126 error "stripe offset $index != $offset" || true
2129 run_test 27wa "check $LFS setstripe -c -i options"
2132 remote_ost_nodsh && skip "remote OST with nodsh"
2133 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
2134 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2136 OFFSET=$(($OSTCOUNT - 1))
2138 local OST=$(ostname_from_index $OSTIDX)
2140 test_mkdir $DIR/$tdir
2141 $LFS setstripe -c 1 $DIR/$tdir # 1 stripe per file
2142 do_facet ost$((OSTIDX + 1)) lctl set_param -n obdfilter.$OST.degraded 1
2144 createmany -o $DIR/$tdir/$tfile $OSTCOUNT
2145 for i in $(seq 0 $OFFSET); do
2146 [ $($LFS getstripe $DIR/$tdir/$tfile$i | grep -A 10 obdidx |
2147 awk '{print $1}' | grep -w "$OSTIDX") ] &&
2148 error "OST0 was degraded but new created file still use it"
2150 do_facet ost$((OSTIDX + 1)) lctl set_param -n obdfilter.$OST.degraded 0
2152 run_test 27x "create files while OST0 is degraded"
2155 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
2156 remote_mds_nodsh && skip "remote MDS with nodsh"
2157 remote_ost_nodsh && skip "remote OST with nodsh"
2158 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2160 local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS $FSNAME-OST0000)
2161 local last_id=$(do_facet $SINGLEMDS lctl get_param -n \
2162 osp.$mdtosc.prealloc_last_id)
2163 local next_id=$(do_facet $SINGLEMDS lctl get_param -n \
2164 osp.$mdtosc.prealloc_next_id)
2165 local fcount=$((last_id - next_id))
2166 [[ $fcount -eq 0 ]] && skip "not enough space on OST0"
2167 [[ $fcount -gt $OSTCOUNT ]] && fcount=$OSTCOUNT
2169 local MDS_OSCS=$(do_facet $SINGLEMDS lctl dl |
2170 awk '/[oO][sS][cC].*md[ts]/ { print $4 }')
2171 local OST_DEACTIVE_IDX=-1
2176 for OSC in $MDS_OSCS; do
2177 OST=$(osc_to_ost $OSC)
2178 OSTIDX=$(index_from_ostuuid $OST)
2179 if [ $OST_DEACTIVE_IDX == -1 ]; then
2180 OST_DEACTIVE_IDX=$OSTIDX
2182 if [ $OSTIDX != $OST_DEACTIVE_IDX ]; then
2183 echo $OSC "is Deactivated:"
2184 do_facet $SINGLEMDS lctl --device %$OSC deactivate
2188 OSTIDX=$(index_from_ostuuid $OST)
2189 test_mkdir $DIR/$tdir
2190 $LFS setstripe -c 1 $DIR/$tdir # 1 stripe / file
2192 for OSC in $MDS_OSCS; do
2193 OST=$(osc_to_ost $OSC)
2194 OSTIDX=$(index_from_ostuuid $OST)
2195 if [ $OSTIDX == $OST_DEACTIVE_IDX ]; then
2196 echo $OST "is degraded:"
2197 do_facet ost$((OSTIDX+1)) lctl set_param -n \
2198 obdfilter.$OST.degraded=1
2203 createmany -o $DIR/$tdir/$tfile $fcount
2205 for OSC in $MDS_OSCS; do
2206 OST=$(osc_to_ost $OSC)
2207 OSTIDX=$(index_from_ostuuid $OST)
2208 if [ $OSTIDX == $OST_DEACTIVE_IDX ]; then
2209 echo $OST "is recovered from degraded:"
2210 do_facet ost$((OSTIDX+1)) lctl set_param -n \
2211 obdfilter.$OST.degraded=0
2213 do_facet $SINGLEMDS lctl --device %$OSC activate
2217 # all osp devices get activated, hence -1 stripe count restored
2218 local stripe_count=0
2220 # sleep 2*lod_qos_maxage seconds waiting for lod qos to notice osp
2221 # devices get activated.
2223 $LFS setstripe -c -1 $DIR/$tfile
2224 stripe_count=$($LFS getstripe -c $DIR/$tfile)
2226 [ $stripe_count -ne $OSTCOUNT ] &&
2227 error "Of $OSTCOUNT OSTs, only $stripe_count is available"
2230 run_test 27y "create files while OST0 is degraded and the rest inactive"
2236 lmm_count=$($LFS getstripe -c $1)
2237 lmm_seq=$($LFS getstripe -v $1 | awk '/lmm_seq/ { print $2 }')
2238 lmm_oid=$($LFS getstripe -v $1 | awk '/lmm_object_id/ { print $2 }')
2240 local old_ifs="$IFS"
2242 fid=($($LFS path2fid $1))
2245 log "FID seq ${fid[1]}, oid ${fid[2]} ver ${fid[3]}"
2246 log "LOV seq $lmm_seq, oid $lmm_oid, count: $lmm_count"
2248 # compare lmm_seq and lu_fid->f_seq
2249 [ $lmm_seq = ${fid[1]} ] || { error "SEQ mismatch"; return 1; }
2250 # compare lmm_object_id and lu_fid->oid
2251 [ $lmm_oid = ${fid[2]} ] || { error "OID mismatch"; return 2; }
2253 # check the trusted.fid attribute of the OST objects of the file
2254 local have_obdidx=false
2256 $LFS getstripe $1 | while read obdidx oid hex seq; do
2257 # skip lines up to and including "obdidx"
2258 [ -z "$obdidx" ] && break
2259 [ "$obdidx" = "obdidx" ] && have_obdidx=true && continue
2260 $have_obdidx || continue
2262 local ost=$((obdidx + 1))
2263 local dev=$(ostdevname $ost)
2266 log "want: stripe:$stripe_nr ost:$obdidx oid:$oid/$hex seq:$seq"
2268 seq=$(echo $seq | sed -e "s/^0x//g")
2269 if [ $seq == 0 ] || [ $(facet_fstype ost$ost) == zfs ]; then
2270 oid_hex=$(echo $oid)
2272 oid_hex=$(echo $hex | sed -e "s/^0x//g")
2274 local obj_file="O/$seq/d$((oid %32))/$oid_hex"
2278 # Don't unmount/remount the OSTs if we don't need to do that.
2279 # LU-2577 changes filter_fid to be smaller, so debugfs needs
2280 # update too, until that use mount/ll_decode_filter_fid/mount.
2281 # Re-enable when debugfs will understand new filter_fid.
2283 if [ $(facet_fstype ost$ost) == ldiskfs ]; then
2284 ff=$(do_facet ost$ost "$DEBUGFS -c -R 'stat $obj_file' \
2285 $dev 2>/dev/null" | grep "parent=")
2287 if [ -z "$ff" ]; then
2289 mount_fstype ost$ost
2290 ff=$(do_facet ost$ost $LL_DECODE_FILTER_FID \
2291 $(facet_mntpt ost$ost)/$obj_file)
2292 unmount_fstype ost$ost
2293 start ost$ost $dev $OST_MOUNT_OPTS
2297 [ -z "$ff" ] && error "$obj_file: no filter_fid info"
2299 echo "$ff" | sed -e 's#.*objid=#got: objid=#'
2301 # /mnt/O/0/d23/23: objid=23 seq=0 parent=[0x200000400:0x1e:0x1]
2302 # fid: objid=23 seq=0 parent=[0x200000400:0x1e:0x0] stripe=1
2304 # fid: parent=[0x200000400:0x1e:0x0] stripe=1 stripe_count=2 \
2305 # stripe_size=1048576 component_id=1 component_start=0 \
2306 # component_end=33554432
2307 local ff_parent=$(sed -e 's/.*parent=.//' <<<$ff)
2308 local ff_pseq=$(cut -d: -f1 <<<$ff_parent)
2309 local ff_poid=$(cut -d: -f2 <<<$ff_parent)
2311 if grep -q 'stripe=' <<<$ff; then
2312 ff_pstripe=$(sed -e 's/.*stripe=//' -e 's/ .*//' <<<$ff)
2314 # $LL_DECODE_FILTER_FID does not print "stripe="; look
2315 # into f_ver in this case. See comment on ff_parent.
2316 ff_pstripe=$(cut -d: -f3 <<<$ff_parent | sed -e 's/]//')
2319 # compare lmm_seq and filter_fid->ff_parent.f_seq
2320 [ $ff_pseq = $lmm_seq ] ||
2321 error "FF parent SEQ $ff_pseq != $lmm_seq"
2322 # compare lmm_object_id and filter_fid->ff_parent.f_oid
2323 [ $ff_poid = $lmm_oid ] ||
2324 error "FF parent OID $ff_poid != $lmm_oid"
2325 (($ff_pstripe == $stripe_nr)) ||
2326 error "FF stripe $ff_pstripe != $stripe_nr"
2328 stripe_nr=$((stripe_nr + 1))
2329 [ $CLIENT_VERSION -lt $(version_code 2.9.55) ] &&
2331 if grep -q 'stripe_count=' <<<$ff; then
2332 local ff_scnt=$(sed -e 's/.*stripe_count=//' \
2333 -e 's/ .*//' <<<$ff)
2334 [ $lmm_count = $ff_scnt ] ||
2335 error "FF stripe count $lmm_count != $ff_scnt"
2341 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2342 remote_ost_nodsh && skip "remote OST with nodsh"
2344 test_mkdir $DIR/$tdir
2345 $LFS setstripe -c 1 -i 0 -S 64k $DIR/$tdir/$tfile-1 ||
2346 { error "setstripe -c -1 failed"; return 1; }
2347 # We need to send a write to every object to get parent FID info set.
2348 # This _should_ also work for setattr, but does not currently.
2349 # touch $DIR/$tdir/$tfile-1 ||
2350 dd if=/dev/zero of=$DIR/$tdir/$tfile-1 bs=1M count=1 ||
2351 { error "dd $tfile-1 failed"; return 2; }
2352 $LFS setstripe -c -1 -i $((OSTCOUNT - 1)) -S 1M $DIR/$tdir/$tfile-2 ||
2353 { error "setstripe -c -1 failed"; return 3; }
2354 dd if=/dev/zero of=$DIR/$tdir/$tfile-2 bs=1M count=$OSTCOUNT ||
2355 { error "dd $tfile-2 failed"; return 4; }
2357 # make sure write RPCs have been sent to OSTs
2360 check_seq_oid $DIR/$tdir/$tfile-1 || return 5
2361 check_seq_oid $DIR/$tdir/$tfile-2 || return 6
2363 run_test 27z "check SEQ/OID on the MDT and OST filesystems"
2365 test_27A() { # b=19102
2366 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2368 save_layout_restore_at_exit $MOUNT
2369 $LFS setstripe -c 0 -i -1 -S 0 $MOUNT
2370 wait_update $HOSTNAME "$LFS getstripe -c $MOUNT | sed 's/ *//g'" "1" 20 ||
2371 error "stripe count $($LFS getstripe -c $MOUNT) != 1"
2372 local default_size=$($LFS getstripe -S $MOUNT)
2373 local default_offset=$($LFS getstripe -i $MOUNT)
2374 local dsize=$(do_facet $SINGLEMDS \
2375 "$LCTL get_param -n lod.$(facet_svc $SINGLEMDS)*.stripesize")
2376 [ $default_size -eq $dsize ] ||
2377 error "stripe size $default_size != $dsize"
2378 [ $default_offset -eq -1 ] ||
2379 error "stripe offset $default_offset != -1"
2381 run_test 27A "check filesystem-wide default LOV EA values"
2383 test_27B() { # LU-2523
2384 test_mkdir $DIR/$tdir
2385 rm -f $DIR/$tdir/f0 $DIR/$tdir/f1
2387 # open f1 with O_LOV_DELAY_CREATE
2389 # call setstripe ioctl on open file descriptor for f1
2391 multiop $DIR/$tdir/f1 oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:nB1c \
2395 # open f1 with O_LOV_DELAY_CREATE
2397 # call setstripe ioctl on open file descriptor for f1
2399 multiop $DIR/$tdir/f1 oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:uB1c
2401 # Allow multiop to fail in imitation of NFS's busted semantics.
2404 run_test 27B "call setstripe on open unlinked file/rename victim"
2406 # 27C family tests full striping and overstriping
2407 test_27Ca() { #LU-2871
2408 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
2416 test_mkdir $DIR/$tdir
2418 for i in $(seq 0 $((OSTCOUNT - 1))); do
2419 # set stripe across all OSTs starting from OST$i
2420 $LFS setstripe -i $i -c -1 $tfile$i
2421 # get striping information
2422 ost_idx=($($LFS getstripe $tfile$i |
2423 tail -n $((OSTCOUNT + 1)) | awk '{print $1}'))
2427 [ ${#ost_idx[@]} -eq $OSTCOUNT ] ||
2428 error "${#ost_idx[@]} != $OSTCOUNT"
2430 for index in $(seq 0 $((OSTCOUNT - 1))); do
2432 for j in $(echo ${ost_idx[@]}); do
2433 if [ $index -eq $j ]; then
2439 error "Can not find $index in ${ost_idx[@]}"
2443 run_test 27Ca "check full striping across all OSTs"
2446 [[ $($LCTL get_param mdc.*.import) =~ connect_flags.*overstriping ]] ||
2447 skip "server does not support overstriping"
2448 [[ $OSTCOUNT -ge $(($LOV_MAX_STRIPE_COUNT / 2)) ]] &&
2449 skip_env "too many osts, skipping"
2451 test_mkdir -p $DIR/$tdir
2452 local setcount=$(($OSTCOUNT * 2))
2453 [ $setcount -lt 160 ] || large_xattr_enabled ||
2454 skip_env "ea_inode feature disabled"
2456 $LFS setstripe -C $setcount $DIR/$tdir/$tfile ||
2457 error "setstripe failed"
2459 local count=$($LFS getstripe -c $DIR/$tdir/$tfile)
2460 [ $count -eq $setcount ] ||
2461 error "stripe count $count, should be $setcount"
2463 $LFS getstripe $DIR/$tdir/$tfile 2>&1 | grep "overstriped" ||
2464 error "overstriped should be set in pattern"
2466 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=4 conv=notrunc ||
2469 run_test 27Cb "more stripes than OSTs with -C"
2472 [[ $($LCTL get_param mdc.*.import) =~ connect_flags.*overstriping ]] ||
2473 skip "server does not support overstriping"
2474 [[ $OSTCOUNT -lt 2 ]] && skip_env "need > 1 OST"
2476 test_mkdir -p $DIR/$tdir
2477 local setcount=$(($OSTCOUNT - 1))
2479 [ $setcount -lt 160 ] || large_xattr_enabled ||
2480 skip_env "ea_inode feature disabled"
2482 $LFS setstripe -C $setcount $DIR/$tdir/$tfile ||
2483 error "setstripe failed"
2485 local count=$($LFS getstripe -c $DIR/$tdir/$tfile)
2486 [ $count -eq $setcount ] ||
2487 error "stripe count $count, should be $setcount"
2489 $LFS getstripe $DIR/$tdir/$tfile 2>&1 | grep "overstriped" &&
2490 error "overstriped should not be set in pattern"
2492 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=4 conv=notrunc ||
2495 run_test 27Cc "fewer stripes than OSTs does not set overstriping"
2498 [[ $($LCTL get_param mdc.*.import) =~ connect_flags.*overstriping ]] ||
2499 skip "server does not support overstriping"
2500 [[ $OSTCOUNT -lt 2 ]] && skip_env "need > 1 OST"
2501 large_xattr_enabled || skip_env "ea_inode feature disabled"
2503 test_mkdir -p $DIR/$tdir
2504 local setcount=$LOV_MAX_STRIPE_COUNT
2506 $LFS setstripe -C $setcount $DIR/$tdir/$tfile ||
2507 error "setstripe failed"
2509 local count=$($LFS getstripe -c $DIR/$tdir/$tfile)
2510 [ $count -eq $setcount ] ||
2511 error "stripe count $count, should be $setcount"
2513 $LFS getstripe $DIR/$tdir/$tfile 2>&1 | grep "overstriped" ||
2514 error "overstriped should be set in pattern"
2516 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=4 conv=notrunc ||
2519 rm -f $DIR/$tdir/$tfile || error "Delete $tfile failed"
2521 run_test 27Cd "test maximum stripe count"
2524 [[ $($LCTL get_param mdc.*.import) =~ connect_flags.*overstriping ]] ||
2525 skip "server does not support overstriping"
2526 test_mkdir -p $DIR/$tdir
2528 pool_add $TESTNAME || error "Pool creation failed"
2529 pool_add_targets $TESTNAME 0 || error "pool_add_targets failed"
2533 $LFS setstripe -C $setcount -p "$TESTNAME" $DIR/$tdir/$tfile ||
2534 error "setstripe failed"
2536 local count=$($LFS getstripe -c $DIR/$tdir/$tfile)
2537 [ $count -eq $setcount ] ||
2538 error "stripe count $count, should be $setcount"
2540 $LFS getstripe $DIR/$tdir/$tfile 2>&1 | grep "overstriped" ||
2541 error "overstriped should be set in pattern"
2543 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=4 conv=notrunc ||
2546 rm -f $DIR/$tdir/$tfile || error "Delete $tfile failed"
2548 run_test 27Ce "test pool with overstriping"
2551 [[ $($LCTL get_param mdc.*.import) =~ connect_flags.*overstriping ]] ||
2552 skip "server does not support overstriping"
2553 [[ $OSTCOUNT -ge $(($LOV_MAX_STRIPE_COUNT / 2)) ]] &&
2554 skip_env "too many osts, skipping"
2556 test_mkdir -p $DIR/$tdir
2558 local setcount=$(($OSTCOUNT * 2))
2559 [ $setcount -lt 160 ] || large_xattr_enabled ||
2560 skip_env "ea_inode feature disabled"
2562 $LFS setstripe -C $setcount $DIR/$tdir/ ||
2563 error "setstripe failed"
2565 echo 1 > $DIR/$tdir/$tfile
2567 local count=$($LFS getstripe -c $DIR/$tdir/$tfile)
2568 [ $count -eq $setcount ] ||
2569 error "stripe count $count, should be $setcount"
2571 $LFS getstripe $DIR/$tdir/$tfile 2>&1 | grep "overstriped" ||
2572 error "overstriped should be set in pattern"
2574 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=4 conv=notrunc ||
2577 rm -f $DIR/$tdir/$tfile || error "Delete $tfile failed"
2579 run_test 27Cf "test default inheritance with overstriping"
2582 [ $OSTCOUNT -lt 2 ] && skip_env "needs >= 2 OSTs"
2583 [ -n "$FILESET" ] && skip "SKIP due to FILESET set"
2584 remote_mds_nodsh && skip "remote MDS with nodsh"
2586 local POOL=${POOL:-testpool}
2588 local last_ost=$(($OSTCOUNT - 1))
2590 local ost_list=$(seq $first_ost $ost_step $last_ost)
2591 local ost_range="$first_ost $last_ost $ost_step"
2593 test_mkdir $DIR/$tdir
2594 pool_add $POOL || error "pool_add failed"
2595 pool_add_targets $POOL $ost_range || error "pool_add_targets failed"
2598 [ $MDS1_VERSION -lt $(version_code 2.8.55) ] &&
2600 [ $MDS1_VERSION -lt $(version_code 2.9.55) ] ||
2601 [ $CLIENT_VERSION -lt $(version_code 2.9.55) ] &&
2602 skip27D+=" -s 30,31"
2603 [[ ! $($LCTL get_param mdc.*.import) =~ connect_flags.*overstriping ||
2604 $OSTCOUNT -ge $(($LOV_MAX_STRIPE_COUNT / 2)) ]] &&
2605 skip27D+=" -s 32,33"
2606 [[ $MDS_VERSION -lt $(version_code $SEL_VER) ]] &&
2608 llapi_layout_test -d$DIR/$tdir -p$POOL -o$OSTCOUNT $skip27D ||
2609 error "llapi_layout_test failed"
2611 destroy_test_pools || error "destroy test pools failed"
2613 run_test 27D "validate llapi_layout API"
2615 # Verify that default_easize is increased from its initial value after
2616 # accessing a widely striped file.
2618 [ $OSTCOUNT -lt 2 ] && skip_env "needs >= 2 OSTs"
2619 [ $CLIENT_VERSION -lt $(version_code 2.5.57) ] &&
2620 skip "client does not have LU-3338 fix"
2622 # 72 bytes is the minimum space required to store striping
2623 # information for a file striped across one OST:
2624 # (sizeof(struct lov_user_md_v3) +
2625 # sizeof(struct lov_user_ost_data_v1))
2627 $LCTL set_param -n llite.*.default_easize $min_easize ||
2628 error "lctl set_param failed"
2629 local easize=$($LCTL get_param -n llite.*.default_easize)
2631 [ $easize -eq $min_easize ] ||
2632 error "failed to set default_easize"
2634 $LFS setstripe -c $OSTCOUNT $DIR/$tfile ||
2635 error "setstripe failed"
2636 # In order to ensure stat() call actually talks to MDS we need to
2637 # do something drastic to this file to shake off all lock, e.g.
2638 # rename it (kills lookup lock forcing cache cleaning)
2639 mv $DIR/$tfile $DIR/${tfile}-1
2640 ls -l $DIR/${tfile}-1
2643 easize=$($LCTL get_param -n llite.*.default_easize)
2645 [ $easize -gt $min_easize ] ||
2646 error "default_easize not updated"
2648 run_test 27E "check that default extended attribute size properly increases"
2650 test_27F() { # LU-5346/LU-7975
2651 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2652 [[ $OSTCOUNT -lt 2 ]] && skip "needs >= 2 OSTs"
2653 [[ $MDS1_VERSION -lt $(version_code 2.8.51) ]] &&
2654 skip "Need MDS version at least 2.8.51"
2655 remote_ost_nodsh && skip "remote OST with nodsh"
2657 test_mkdir $DIR/$tdir
2659 $LFS setstripe -c 2 $DIR/$tdir
2661 # stop all OSTs to reproduce situation for LU-7975 ticket
2662 for num in $(seq $OSTCOUNT); do
2666 # open/create f0 with O_LOV_DELAY_CREATE
2667 # truncate f0 to a non-0 size
2669 multiop $DIR/$tdir/f0 oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:T1050000c
2671 $CHECKSTAT -s 1050000 $DIR/$tdir/f0 || error "checkstat failed"
2672 # open/write it again to force delayed layout creation
2673 cat /etc/hosts > $DIR/$tdir/f0 &
2677 for num in $(seq $OSTCOUNT); do
2678 start ost$num $(ostdevname $num) $OST_MOUNT_OPTS ||
2679 error "ost$num failed to start"
2682 wait $catpid || error "cat failed"
2684 cmp /etc/hosts $DIR/$tdir/f0 || error "cmp failed"
2685 [[ $($LFS getstripe -c $DIR/$tdir/f0) == 2 ]] ||
2686 error "wrong stripecount"
2689 run_test 27F "Client resend delayed layout creation with non-zero size"
2691 test_27G() { #LU-10629
2692 [ $MDS1_VERSION -lt $(version_code 2.11.51) ] &&
2693 skip "Need MDS version at least 2.11.51"
2694 [ -n "$FILESET" ] && skip "SKIP due to FILESET set"
2695 remote_mds_nodsh && skip "remote MDS with nodsh"
2696 local POOL=${POOL:-testpool}
2697 local ostrange="0 0 1"
2699 test_mkdir $DIR/$tdir
2700 touch $DIR/$tdir/$tfile.nopool
2701 pool_add $POOL || error "pool_add failed"
2702 pool_add_targets $POOL $ostrange || error "pool_add_targets failed"
2703 $LFS setstripe -p $POOL $DIR/$tdir
2705 local pool=$($LFS getstripe -p $DIR/$tdir)
2707 [ "$pool" = "$POOL" ] || error "Striping failed got '$pool' not '$POOL'"
2708 touch $DIR/$tdir/$tfile.default
2709 $LFS setstripe -E 1M --pool $POOL -c 1 -E eof -c 1 $DIR/$tdir/$tfile.pfl
2710 $LFS find $DIR/$tdir -type f --pool $POOL
2711 local found=$($LFS find $DIR/$tdir -type f --pool $POOL | wc -l)
2712 [[ "$found" == "2" ]] ||
2713 error "found $found != 2 files in '$DIR/$tdir' in '$POOL'"
2715 $LFS setstripe -d $DIR/$tdir
2717 pool=$($LFS getstripe -p -d $DIR/$tdir)
2719 [[ "$pool" != "$POOL" ]] || error "$DIR/$tdir is still '$pool'"
2721 run_test 27G "Clear OST pool from stripe"
2724 [[ $MDS1_VERSION -le $(version_code 2.11.54) ]] &&
2725 skip "Need MDS version newer than 2.11.54"
2726 [[ $OSTCOUNT -lt 3 ]] && skip_env "needs >= 3 OSTs"
2727 test_mkdir $DIR/$tdir
2728 $LFS setstripe -o 0 -o 2 $DIR/$tdir || error "setstripe failed"
2729 touch $DIR/$tdir/$tfile
2730 $LFS getstripe -c $DIR/$tdir/$tfile
2731 [ $($LFS getstripe -c $DIR/$tdir/$tfile) -eq 2 ] ||
2732 error "two-stripe file doesn't have two stripes"
2734 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=4k count=4 || error "dd failed"
2735 $LFS getstripe -y $DIR/$tdir/$tfile
2736 (( $($LFS getstripe -y $DIR/$tdir/$tfile |
2737 egrep -c "l_ost_idx: [02]$") == "2" )) ||
2738 error "expected l_ost_idx: [02]$ not matched"
2740 # make sure ost list has been cleared
2741 local stripesize=$($LFS getstripe -S $DIR/$tdir)
2742 $LFS setstripe -S $((stripesize * 4)) -i 1 \
2743 -c $((OSTCOUNT - 1)) $DIR/$tdir || error "setstripe"
2745 $LVERIFY $DIR/$tdir $DIR/$tdir/f3 || error "lverify failed"
2747 run_test 27H "Set specific OSTs stripe"
2750 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2751 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
2752 [[ $MDS1_VERSION -gt $(version_code 2.12.52) ]] ||
2753 skip "Need MDS version newer than 2.12.52"
2754 local pool=$TESTNAME
2755 local ostrange="1 1 1"
2757 save_layout_restore_at_exit $MOUNT
2758 $LFS setstripe -c 2 -i 0 $MOUNT
2759 pool_add $pool || error "pool_add failed"
2760 pool_add_targets $pool $ostrange ||
2761 error "pool_add_targets failed"
2762 test_mkdir $DIR/$tdir
2763 $LFS setstripe -p $pool $DIR/$tdir
2764 $MULTIOP $DIR/$tdir/$tfile Oc || error "multiop failed"
2765 $LFS getstripe $DIR/$tdir/$tfile
2767 run_test 27I "check that root dir striping does not break parent dir one"
2770 [[ $MDS1_VERSION -le $(version_code 2.12.51) ]] &&
2771 skip "Need MDS version newer than 2.12.51"
2773 test_mkdir $DIR/$tdir
2774 local uuid1=$(cat /proc/sys/kernel/random/uuid)
2775 local uuid2=$(cat /proc/sys/kernel/random/uuid)
2777 # create foreign file (raw way)
2778 ! $LFS setstripe --flags 0xda08 $DIR/$tdir/$tfile ||
2779 error "creating $tfile w/ hex flags w/o --foreign should fail"
2781 ! $LFS setstripe --foreign --flags foo \
2782 --xattr ${uuid1}@${uuid2} $DIR/$tdir/$tfile ||
2783 error "creating $tfile with '--flags foo' should fail"
2785 ! $LFS setstripe --foreign --flags 0xffffffff \
2786 --xattr ${uuid1}@${uuid2} $DIR/$tdir/$tfile ||
2787 error "creating $tfile w/ 0xffffffff flags should fail"
2789 create_foreign_file -f $DIR/$tdir/$tfile -x "${uuid1}@${uuid2}" \
2790 -t 1 -F 0xda08 || error "create_foreign_file failed"
2792 # verify foreign file (raw way)
2793 parse_foreign_file -f $DIR/$tdir/$tfile |
2794 grep "lov_foreign_magic: 0x0BD70BD0" ||
2795 error "$DIR/$tdir/$tfile: invalid LOV EA foreign magic"
2796 parse_foreign_file -f $DIR/$tdir/$tfile | grep "lov_xattr_size: 89" ||
2797 error "$DIR/$tdir/$tfile: invalid LOV EA foreign size"
2798 parse_foreign_file -f $DIR/$tdir/$tfile |
2799 grep "lov_foreign_size: 73" ||
2800 error "$DIR/$tdir/$tfile: invalid LOV EA foreign size"
2801 parse_foreign_file -f $DIR/$tdir/$tfile |
2802 grep "lov_foreign_type: 1" ||
2803 error "$DIR/$tdir/$tfile: invalid LOV EA foreign type"
2804 parse_foreign_file -f $DIR/$tdir/$tfile |
2805 grep "lov_foreign_flags: 0x0000DA08" ||
2806 error "$DIR/$tdir/$tfile: invalid LOV EA foreign flags"
2807 local lov=$(parse_foreign_file -f $DIR/$tdir/$tfile |
2808 grep "lov_foreign_value: 0x" |
2809 sed -e 's/lov_foreign_value: 0x//')
2810 local lov2=$(echo -n "${uuid1}@${uuid2}" | od -A n -t x1 -w160)
2811 [[ $lov = ${lov2// /} ]] ||
2812 error "$DIR/$tdir/$tfile: invalid LOV EA foreign value"
2814 # create foreign file (lfs + API)
2815 $LFS setstripe --foreign=none --flags 0xda08 \
2816 -x "${uuid1}@${uuid2}" $DIR/$tdir/${tfile}2 ||
2817 error "$DIR/$tdir/${tfile}2: create failed"
2819 $LFS getstripe -v $DIR/$tdir/${tfile}2 |
2820 grep "lfm_magic:.*0x0BD70BD0" ||
2821 error "$DIR/$tdir/${tfile}2: invalid LOV EA foreign magic"
2822 # lfm_length is LOV EA size - sizeof(lfm_magic) - sizeof(lfm_length)
2823 $LFS getstripe -v $DIR/$tdir/${tfile}2 | grep "lfm_length:.*73" ||
2824 error "$DIR/$tdir/${tfile}2: invalid LOV EA foreign size"
2825 $LFS getstripe -v $DIR/$tdir/${tfile}2 | grep "lfm_type:.*none" ||
2826 error "$DIR/$tdir/${tfile}2: invalid LOV EA foreign type"
2827 $LFS getstripe -v $DIR/$tdir/${tfile}2 |
2828 grep "lfm_flags:.*0x0000DA08" ||
2829 error "$DIR/$tdir/${tfile}2: invalid LOV EA foreign flags"
2830 $LFS getstripe $DIR/$tdir/${tfile}2 |
2831 grep "lfm_value:.*${uuid1}@${uuid2}" ||
2832 error "$DIR/$tdir/${tfile}2: invalid LOV EA foreign value"
2834 # modify striping should fail
2835 $LFS setstripe -c 2 $DIR/$tdir/$tfile &&
2836 error "$DIR/$tdir/$tfile: setstripe should fail"
2837 $LFS setstripe -c 2 $DIR/$tdir/${tfile}2 &&
2838 error "$DIR/$tdir/${tfile}2: setstripe should fail"
2841 cat $DIR/$tdir/$tfile && error "$DIR/$tdir/$tfile: read should fail"
2842 cat $DIR/$tdir/${tfile}2 &&
2843 error "$DIR/$tdir/${tfile}2: read should fail"
2844 cat /etc/passwd > $DIR/$tdir/$tfile &&
2845 error "$DIR/$tdir/$tfile: write should fail"
2846 cat /etc/passwd > $DIR/$tdir/${tfile}2 &&
2847 error "$DIR/$tdir/${tfile}2: write should fail"
2850 chmod 222 $DIR/$tdir/$tfile ||
2851 error "$DIR/$tdir/$tfile: chmod failed"
2852 chmod 222 $DIR/$tdir/${tfile}2 ||
2853 error "$DIR/$tdir/${tfile}2: chmod failed"
2856 chown $RUNAS_ID:$RUNAS_GID $DIR/$tdir/$tfile ||
2857 error "$DIR/$tdir/$tfile: chown failed"
2858 chown $RUNAS_ID:$RUNAS_GID $DIR/$tdir/${tfile}2 ||
2859 error "$DIR/$tdir/${tfile}2: chown failed"
2861 # rename should work
2862 mv $DIR/$tdir/$tfile $DIR/$tdir/${tfile}.new ||
2863 error "$DIR/$tdir/$tfile: rename of foreign file has failed"
2864 mv $DIR/$tdir/${tfile}2 $DIR/$tdir/${tfile}2.new ||
2865 error "$DIR/$tdir/${tfile}2: rename of foreign file has failed"
2867 #remove foreign file
2868 rm $DIR/$tdir/${tfile}.new ||
2869 error "$DIR/$tdir/${tfile}.new: remove of foreign file has failed"
2870 rm $DIR/$tdir/${tfile}2.new ||
2871 error "$DIR/$tdir/${tfile}2.new: remove of foreign file has failed"
2873 run_test 27J "basic ops on file with foreign LOV"
2876 [[ $MDS1_VERSION -le $(version_code 2.12.49) ]] &&
2877 skip "Need MDS version newer than 2.12.49"
2879 test_mkdir $DIR/$tdir
2880 local uuid1=$(cat /proc/sys/kernel/random/uuid)
2881 local uuid2=$(cat /proc/sys/kernel/random/uuid)
2883 # create foreign dir (raw way)
2884 ! $LFS setdirstripe --flags 0xda08 $DIR/$tdir/$tdir ||
2885 error "creating $tdir w/ hex flags w/o --foreign should fail"
2887 ! $LFS setdirstripe --foreign --flags foo \
2888 --xattr ${uuid1}@${uuid2} $DIR/$tdir/$tdir ||
2889 error "creating $tdir with '--flags foo' should fail"
2891 ! $LFS setdirstripe --foreign --flags 0xffffffff \
2892 --xattr ${uuid1}@${uuid2} $DIR/$tdir/$tdir ||
2893 error "creating $tdir w/ 0xffffffff flags should fail"
2895 create_foreign_dir -d $DIR/$tdir/$tdir -x "${uuid1}@${uuid2}" -t 1 ||
2896 error "create_foreign_dir FAILED"
2898 # verify foreign dir (raw way)
2899 parse_foreign_dir -d $DIR/$tdir/$tdir |
2900 grep "lmv_foreign_magic:.*0xcd50cd0" ||
2901 error "$DIR/$tdir/$tfile: invalid LMV EA magic"
2902 parse_foreign_dir -d $DIR/$tdir/$tdir | grep "lmv_xattr_size:.*89$" ||
2903 error "$DIR/$tdir/$tdir: invalid LMV EA size"
2904 parse_foreign_dir -d $DIR/$tdir/$tdir | grep "lmv_foreign_type: 1$" ||
2905 error "$DIR/$tdir/$tdir: invalid LMV EA type"
2906 parse_foreign_dir -d $DIR/$tdir/$tdir |
2907 grep "lmv_foreign_flags: 55813$" ||
2908 error "$DIR/$tdir/$tdir: invalid LMV EA flags"
2909 local lmv=$(parse_foreign_dir -d $DIR/$tdir/$tdir |
2910 grep "lmv_foreign_value: 0x" |
2911 sed 's/lmv_foreign_value: 0x//')
2912 local lmv2=$(echo -n "${uuid1}@${uuid2}" | od -A n -t x1 -w160 |
2914 [[ $lmv == $lmv2 ]] || error "$DIR/$tdir/$tdir: invalid LMV EA value"
2916 # create foreign dir (lfs + API)
2917 $LFS mkdir --foreign=none --xattr="${uuid1}@${uuid2}" --flags=0xda05 \
2918 $DIR/$tdir/${tdir}2 ||
2919 error "$DIR/$tdir/${tdir}2: create failed"
2921 $LFS getdirstripe -v $DIR/$tdir/${tdir}2 |
2922 grep "lfm_magic:.*0x0CD50CD0" ||
2923 error "$DIR/$tdir/${tdir}2: invalid LMV EA magic"
2924 # lfm_length is LMV EA size - sizeof(lfm_magic) - sizeof(lfm_length)
2925 # - sizeof(lfm_type) - sizeof(lfm_flags)
2926 $LFS getdirstripe -v $DIR/$tdir/${tdir}2 | grep "lfm_length:.*73" ||
2927 error "$DIR/$tdir/${tdir}2: invalid LMV EA size"
2928 $LFS getdirstripe -v $DIR/$tdir/${tdir}2 | grep "lfm_type:.*none" ||
2929 error "$DIR/$tdir/${tdir}2: invalid LMV EA type"
2930 $LFS getdirstripe -v $DIR/$tdir/${tdir}2 |
2931 grep "lfm_flags:.*0x0000DA05" ||
2932 error "$DIR/$tdir/${tdir}2: invalid LMV EA flags"
2933 $LFS getdirstripe $DIR/$tdir/${tdir}2 |
2934 grep "lfm_value.*${uuid1}@${uuid2}" ||
2935 error "$DIR/$tdir/${tdir}2: invalid LMV EA value"
2937 # file create in dir should fail
2938 touch $DIR/$tdir/$tdir/$tfile && "$DIR/$tdir: file create should fail"
2939 touch $DIR/$tdir/${tdir}2/$tfile &&
2940 "$DIR/${tdir}2: file create should fail"
2943 chmod 777 $DIR/$tdir/$tdir ||
2944 error "$DIR/$tdir: chmod failed"
2945 chmod 777 $DIR/$tdir/${tdir}2 ||
2946 error "$DIR/${tdir}2: chmod failed"
2949 chown $RUNAS_ID:$RUNAS_GID $DIR/$tdir/$tdir ||
2950 error "$DIR/$tdir: chown failed"
2951 chown $RUNAS_ID:$RUNAS_GID $DIR/$tdir/${tdir}2 ||
2952 error "$DIR/${tdir}2: chown failed"
2954 # rename should work
2955 mv $DIR/$tdir/$tdir $DIR/$tdir/${tdir}.new ||
2956 error "$DIR/$tdir/$tdir: rename of foreign dir has failed"
2957 mv $DIR/$tdir/${tdir}2 $DIR/$tdir/${tdir}2.new ||
2958 error "$DIR/$tdir/${tdir}2: rename of foreign dir has failed"
2961 rmdir $DIR/$tdir/${tdir}.new ||
2962 error "$DIR/$tdir/${tdir}.new: remove of foreign dir has failed"
2963 rmdir $DIR/$tdir/${tdir}2.new ||
2964 error "$DIR/$tdir/${tdir}2.new: remove of foreign dir has failed"
2966 run_test 27K "basic ops on dir with foreign LMV"
2969 remote_mds_nodsh && skip "remote MDS with nodsh"
2971 local POOL=${POOL:-$TESTNAME}
2973 pool_add $POOL || error "pool_add failed"
2975 lfs pool_list $MOUNT | grep -Fx "${FSNAME}.${POOL}" ||
2976 error "pool_list does not contain ${FSNAME}.${POOL}:" \
2977 "$(lfs pool_list $MOUNT | grep -F "${POOL}")"
2979 run_test 27L "lfs pool_list gives correct pool name"
2982 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.12.57) ]] &&
2983 skip "Need MDS version >= than 2.12.57"
2984 remote_mds_nodsh && skip "remote MDS with nodsh"
2985 [[ $OSTCOUNT -lt 2 ]] && skip_env "need > 1 OST"
2987 test_mkdir $DIR/$tdir
2989 # Set default striping on directory
2990 $LFS setstripe -C 4 $DIR/$tdir
2992 echo 1 > $DIR/$tdir/${tfile}.1
2993 local count=$($LFS getstripe -c $DIR/$tdir/${tfile}.1)
2995 [ $count -eq $setcount ] ||
2996 error "(1) stripe count $count, should be $setcount"
2998 # Capture existing append_stripe_count setting for restore
2999 local orig_count=$(do_facet mds1 $LCTL get_param -n mdd.$FSNAME-MDT0000.append_stripe_count)
3000 local mdts=$(comma_list $(mdts_nodes))
3001 stack_trap "do_nodes $mdts $LCTL set_param mdd.*.append_stripe_count=$orig_count" EXIT
3003 local appendcount=$orig_count
3004 echo 1 >> $DIR/$tdir/${tfile}.2_append
3005 count=$($LFS getstripe -c $DIR/$tdir/${tfile}.2_append)
3006 [ $count -eq $appendcount ] ||
3007 error "(2)stripe count $count, should be $appendcount for append"
3009 # Disable O_APPEND striping, verify it works
3010 do_nodes $mdts $LCTL set_param mdd.*.append_stripe_count=0
3012 # Should now get the default striping, which is 4
3014 echo 1 >> $DIR/$tdir/${tfile}.3_append
3015 count=$($LFS getstripe -c $DIR/$tdir/${tfile}.3_append)
3016 [ $count -eq $setcount ] ||
3017 error "(3) stripe count $count, should be $setcount"
3019 # Try changing the stripe count for append files
3020 do_nodes $mdts $LCTL set_param mdd.*.append_stripe_count=2
3022 # Append striping is now 2 (directory default is still 4)
3024 echo 1 >> $DIR/$tdir/${tfile}.4_append
3025 count=$($LFS getstripe -c $DIR/$tdir/${tfile}.4_append)
3026 [ $count -eq $appendcount ] ||
3027 error "(4) stripe count $count, should be $appendcount for append"
3029 # Test append stripe count of -1
3030 do_nodes $mdts $LCTL set_param mdd.*.append_stripe_count=-1
3031 appendcount=$OSTCOUNT
3032 echo 1 >> $DIR/$tdir/${tfile}.5
3033 count=$($LFS getstripe -c $DIR/$tdir/${tfile}.5)
3034 [ $count -eq $appendcount ] ||
3035 error "(5) stripe count $count, should be $appendcount for append"
3037 # Set append striping back to default of 1
3038 do_nodes $mdts $LCTL set_param mdd.*.append_stripe_count=1
3040 # Try a new default striping, PFL + DOM
3041 $LFS setstripe -L mdt -E 1M -E -1 -c 2 $DIR/$tdir
3043 # Create normal DOM file, DOM returns stripe count == 0
3045 touch $DIR/$tdir/${tfile}.6
3046 count=$($LFS getstripe -c $DIR/$tdir/${tfile}.6)
3047 [ $count -eq $setcount ] ||
3048 error "(6) stripe count $count, should be $setcount"
3052 echo 1 >> $DIR/$tdir/${tfile}.7_append
3053 count=$($LFS getstripe -c $DIR/$tdir/${tfile}.7_append)
3054 [ $count -eq $appendcount ] ||
3055 error "(7) stripe count $count, should be $appendcount for append"
3057 # Clean up DOM layout
3058 $LFS setstripe -d $DIR/$tdir
3060 # Now test that append striping works when layout is from root
3061 $LFS setstripe -c 2 $MOUNT
3062 # Make a special directory for this
3063 mkdir $DIR/${tdir}/${tdir}.2
3064 stack_trap "$LFS setstripe -d $MOUNT" EXIT
3066 # Verify for normal file
3068 echo 1 > $DIR/${tdir}/${tdir}.2/${tfile}.8
3069 count=$($LFS getstripe -c $DIR/$tdir/${tdir}.2/${tfile}.8)
3070 [ $count -eq $setcount ] ||
3071 error "(8) stripe count $count, should be $setcount"
3074 echo 1 >> $DIR/${tdir}/${tdir}.2/${tfile}.9_append
3075 count=$($LFS getstripe -c $DIR/${tdir}/${tdir}.2/${tfile}.9_append)
3076 [ $count -eq $appendcount ] ||
3077 error "(9) stripe count $count, should be $appendcount for append"
3079 # Now test O_APPEND striping with pools
3080 do_nodes $mdts $LCTL set_param mdd.*.append_pool="$TESTNAME"
3081 stack_trap "do_nodes $mdts $LCTL set_param mdd.*.append_pool='none'" EXIT
3084 pool_add $TESTNAME || error "pool creation failed"
3085 pool_add_targets $TESTNAME 0 1 || error "Pool add targets failed"
3087 echo 1 >> $DIR/$tdir/${tfile}.10_append
3089 pool=$($LFS getstripe -p $DIR/$tdir/${tfile}.10_append)
3090 [ "$pool" = "$TESTNAME" ] || error "(10) incorrect pool: $pool"
3092 # Check that count is still correct
3094 echo 1 >> $DIR/$tdir/${tfile}.11_append
3095 count=$($LFS getstripe -c $DIR/$tdir/${tfile}.11_append)
3096 [ $count -eq $appendcount ] ||
3097 error "(11) stripe count $count, should be $appendcount for append"
3099 # Disable O_APPEND stripe count, verify pool works separately
3100 do_nodes $mdts $LCTL set_param mdd.*.append_stripe_count=0
3102 echo 1 >> $DIR/$tdir/${tfile}.12_append
3104 pool=$($LFS getstripe -p $DIR/$tdir/${tfile}.12_append)
3105 [ "$pool" = "$TESTNAME" ] || error "(12) incorrect pool: $pool"
3107 # Remove pool setting, verify it's not applied
3108 do_nodes $mdts $LCTL set_param mdd.*.append_pool='none'
3110 echo 1 >> $DIR/$tdir/${tfile}.13_append
3112 pool=$($LFS getstripe -p $DIR/$tdir/${tfile}.13_append)
3113 [ "$pool" = "" ] || error "(13) pool found: $pool"
3115 run_test 27M "test O_APPEND striping"
3118 combined_mgs_mds && skip "needs separate MGS/MDT"
3120 pool_add $TESTNAME || error "pool_add failed"
3121 do_facet mgs "$LCTL pool_list $FSNAME" |
3122 grep -Fx "${FSNAME}.${TESTNAME}" ||
3123 error "lctl pool_list on MGS failed"
3125 run_test 27N "lctl pool_list on separate MGS gives correct pool name"
3127 clean_foreign_symlink() {
3129 lctl set_param llite/$FSNAME-*/foreign_symlink_enable=0
3130 for i in $DIR/$tdir/* ; do
3131 $LFS unlink_foreign $i || true
3136 [[ $(lustre_version_code $SINGLEMDS) -le $(version_code 2.12.51) ]] &&
3137 skip "Need MDS version newer than 2.12.51"
3139 test_mkdir $DIR/$tdir
3140 local uuid1=$(cat /proc/sys/kernel/random/uuid)
3141 local uuid2=$(cat /proc/sys/kernel/random/uuid)
3143 trap clean_foreign_symlink EXIT
3145 # enable foreign_symlink behaviour
3146 $LCTL set_param llite/$FSNAME-*/foreign_symlink_enable=1
3148 # foreign symlink LOV format is a partial path by default
3150 # create foreign file (lfs + API)
3151 $LFS setstripe --foreign=symlink --flags 0xda05 \
3152 -x "${uuid1}/${uuid2}" --mode 0600 $DIR/$tdir/${tfile} ||
3153 error "$DIR/$tdir/${tfile}: create failed"
3155 $LFS getstripe -v $DIR/$tdir/${tfile} |
3156 grep "lfm_magic:.*0x0BD70BD0" ||
3157 error "$DIR/$tdir/${tfile}: invalid LOV EA foreign magic"
3158 $LFS getstripe -v $DIR/$tdir/${tfile} | grep "lfm_type:.*symlink" ||
3159 error "$DIR/$tdir/${tfile}: invalid LOV EA foreign type"
3160 $LFS getstripe -v $DIR/$tdir/${tfile} |
3161 grep "lfm_flags:.*0x0000DA05" ||
3162 error "$DIR/$tdir/${tfile}: invalid LOV EA foreign flags"
3163 $LFS getstripe $DIR/$tdir/${tfile} |
3164 grep "lfm_value:.*${uuid1}/${uuid2}" ||
3165 error "$DIR/$tdir/${tfile}: invalid LOV EA foreign value"
3167 # modify striping should fail
3168 $LFS setstripe -c 2 $DIR/$tdir/$tfile &&
3169 error "$DIR/$tdir/$tfile: setstripe should fail"
3171 # R/W should fail ("/{foreign_symlink_prefix}/${uuid1}/" missing)
3172 cat $DIR/$tdir/$tfile && error "$DIR/$tdir/$tfile: read should fail"
3173 cat /etc/passwd > $DIR/$tdir/$tfile &&
3174 error "$DIR/$tdir/$tfile: write should fail"
3176 # rename should succeed
3177 mv $DIR/$tdir/$tfile $DIR/$tdir/${tfile}.new ||
3178 error "$DIR/$tdir/$tfile: rename has failed"
3180 #remove foreign_symlink file should fail
3181 rm $DIR/$tdir/${tfile}.new &&
3182 error "$DIR/$tdir/${tfile}.new: remove of foreign_symlink file should fail"
3185 mkdir /tmp/${uuid1} ||
3186 error "/tmp/${uuid1}: mkdir has failed"
3187 echo FOOFOO > /tmp/${uuid1}/${uuid2} ||
3188 error "/tmp/${uuid1}/${uuid2}: echo has failed"
3189 $LCTL set_param llite/$FSNAME-*/foreign_symlink_prefix=/tmp/
3190 $CHECKSTAT -t link -l /tmp/${uuid1}/${uuid2} $DIR/$tdir/${tfile}.new ||
3191 error "$DIR/$tdir/${tfile}.new: not seen as a symlink"
3192 #read should succeed now
3193 cat $DIR/$tdir/${tfile}.new | grep FOOFOO ||
3194 error "$DIR/$tdir/${tfile}.new: symlink resolution has failed"
3195 #write should succeed now
3196 cat /etc/passwd > $DIR/$tdir/${tfile}.new ||
3197 error "$DIR/$tdir/${tfile}.new: write should succeed"
3198 diff /etc/passwd $DIR/$tdir/${tfile}.new ||
3199 error "$DIR/$tdir/${tfile}.new: diff has failed"
3200 diff /etc/passwd /tmp/${uuid1}/${uuid2} ||
3201 error "/tmp/${uuid1}/${uuid2}: diff has failed"
3203 #check that getstripe still works
3204 $LFS getstripe $DIR/$tdir/${tfile}.new ||
3205 error "$DIR/$tdir/${tfile}.new: getstripe should still work with foreign_symlink enabled"
3207 # chmod should still succeed
3208 chmod 644 $DIR/$tdir/${tfile}.new ||
3209 error "$DIR/$tdir/${tfile}.new: chmod has failed"
3211 # chown should still succeed
3212 chown $RUNAS_ID:$RUNAS_GID $DIR/$tdir/${tfile}.new ||
3213 error "$DIR/$tdir/${tfile}.new: chown has failed"
3215 # rename should still succeed
3216 mv $DIR/$tdir/${tfile}.new $DIR/$tdir/${tfile} ||
3217 error "$DIR/$tdir/${tfile}.new: rename has failed"
3219 #remove foreign_symlink file should still fail
3220 rm $DIR/$tdir/${tfile} &&
3221 error "$DIR/$tdir/${tfile}: remove of foreign_symlink file should fail"
3223 #use special ioctl() to unlink foreign_symlink file
3224 $LFS unlink_foreign $DIR/$tdir/${tfile} ||
3225 error "$DIR/$tdir/$tfile: unlink/ioctl failed"
3228 run_test 27O "basic ops on foreign file of symlink type"
3231 [[ $(lustre_version_code $SINGLEMDS) -le $(version_code 2.12.49) ]] &&
3232 skip "Need MDS version newer than 2.12.49"
3234 test_mkdir $DIR/$tdir
3235 local uuid1=$(cat /proc/sys/kernel/random/uuid)
3236 local uuid2=$(cat /proc/sys/kernel/random/uuid)
3238 trap clean_foreign_symlink EXIT
3240 # enable foreign_symlink behaviour
3241 $LCTL set_param llite/$FSNAME-*/foreign_symlink_enable=1
3243 # foreign symlink LMV format is a partial path by default
3245 # create foreign dir (lfs + API)
3246 $LFS mkdir --foreign=symlink --xattr="${uuid1}/${uuid2}" \
3247 --flags=0xda05 --mode 0750 $DIR/$tdir/${tdir} ||
3248 error "$DIR/$tdir/${tdir}: create failed"
3250 $LFS getdirstripe -v $DIR/$tdir/${tdir} |
3251 grep "lfm_magic:.*0x0CD50CD0" ||
3252 error "$DIR/$tdir/${tdir}: invalid LMV EA magic"
3253 $LFS getdirstripe -v $DIR/$tdir/${tdir} | grep "lfm_type:.*symlink" ||
3254 error "$DIR/$tdir/${tdir}: invalid LMV EA type"
3255 $LFS getdirstripe -v $DIR/$tdir/${tdir} |
3256 grep "lfm_flags:.*0x0000DA05" ||
3257 error "$DIR/$tdir/${tdir}: invalid LMV EA flags"
3258 $LFS getdirstripe $DIR/$tdir/${tdir} |
3259 grep "lfm_value.*${uuid1}/${uuid2}" ||
3260 error "$DIR/$tdir/${tdir}: invalid LMV EA value"
3262 # file create in dir should fail
3263 # ("/{foreign_symlink_prefix}/${uuid1}/${uuid2}/" missing)
3264 touch $DIR/$tdir/$tdir/$tfile && "$DIR/$tdir: file create should fail"
3266 # rename should succeed
3267 mv $DIR/$tdir/$tdir $DIR/$tdir/${tdir}.new ||
3268 error "$DIR/$tdir/$tdir: rename of foreign_symlink dir has failed"
3270 #remove foreign_symlink dir should fail
3271 rmdir $DIR/$tdir/${tdir}.new &&
3272 error "$DIR/$tdir/${tdir}.new: remove of foreign_symlink dir should fail"
3275 mkdir -p /tmp/${uuid1}/${uuid2} ||
3276 error "/tmp/${uuid1}/${uuid2}: mkdir has failed"
3277 echo FOOFOO > /tmp/${uuid1}/${uuid2}/foo ||
3278 error "/tmp/${uuid1}/${uuid2}/foo: echo has failed"
3279 $LCTL set_param llite/$FSNAME-*/foreign_symlink_prefix=/tmp/
3280 $CHECKSTAT -t link -l /tmp/${uuid1}/${uuid2} $DIR/$tdir/${tdir}.new ||
3281 error "$DIR/$tdir/${tdir}.new: not seen as a symlink"
3282 cat $DIR/$tdir/${tdir}.new/foo | grep FOOFOO ||
3283 error "$DIR/$tdir/${tdir}.new: symlink resolution has failed"
3285 #check that getstripe fails now that foreign_symlink enabled
3286 $LFS getdirstripe $DIR/$tdir/${tdir}.new ||
3287 error "$DIR/$tdir/${tdir}.new: getdirstripe should still work with foreign_symlink enabled"
3289 # file create in dir should work now
3290 cp /etc/passwd $DIR/$tdir/${tdir}.new/$tfile ||
3291 error "$DIR/$tdir/${tdir}.new/$tfile: file create should fail"
3292 diff /etc/passwd $DIR/$tdir/${tdir}.new/$tfile ||
3293 error "$DIR/$tdir/${tdir}.new/$tfile: diff has failed"
3294 diff /etc/passwd /tmp/${uuid1}/${uuid2}/$tfile ||
3295 error "/tmp/${uuid1}/${uuid2}/$tfile: diff has failed"
3297 # chmod should still succeed
3298 chmod 755 $DIR/$tdir/${tdir}.new ||
3299 error "$DIR/$tdir/${tdir}.new: chmod has failed"
3301 # chown should still succeed
3302 chown $RUNAS_ID:$RUNAS_GID $DIR/$tdir/${tdir}.new ||
3303 error "$DIR/$tdir/${tdir}.new: chown has failed"
3305 # rename should still succeed
3306 mv $DIR/$tdir/${tdir}.new $DIR/$tdir/${tdir} ||
3307 error "$DIR/$tdir/${tdir}.new: rename of foreign_symlink dir has failed"
3309 #remove foreign_symlink dir should still fail
3310 rmdir $DIR/$tdir/${tdir} &&
3311 error "$DIR/$tdir/${tdir}: remove of foreign_symlink dir should fail"
3313 #use special ioctl() to unlink foreign_symlink file
3314 $LFS unlink_foreign $DIR/$tdir/${tdir} ||
3315 error "$DIR/$tdir/$tdir: unlink/ioctl failed"
3317 #created file should still exist
3318 [[ -f /tmp/${uuid1}/${uuid2}/$tfile ]] ||
3319 error "/tmp/${uuid1}/${uuid2}/$tfile has been removed"
3320 diff /etc/passwd /tmp/${uuid1}/${uuid2}/$tfile ||
3321 error "/tmp/${uuid1}/${uuid2}/$tfile: diff has failed"
3323 run_test 27P "basic ops on foreign dir of foreign_symlink type"
3326 rm -f $TMP/$tfile $TMP/$tfile.loop $TMP/$tfile.none $TMP/$tfile.broken
3327 stack_trap "rm -f $TMP/$tfile*"
3329 test_mkdir $DIR/$tdir-1
3330 test_mkdir $DIR/$tdir-2
3332 echo 'It is what it is' > $DIR/$tdir-1/$tfile
3333 lov_getstripe_old $DIR/$tdir-1/$tfile || error "$DIR/$tdir-1/$tfile: rc = $?"
3335 ln -s $DIR/$tdir-1/$tfile $DIR/$tdir-2/$tfile
3336 lov_getstripe_old $DIR/$tdir-2/$tfile || error "$DIR/$tdir-2/$tfile: rc = $?"
3338 ln -s $DIR/$tdir-1/$tfile $TMP/$tfile
3339 lov_getstripe_old $TMP/$tfile || error "$TMP/$tfile: rc = $?"