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"
47 selinux_status=$(getenforce)
48 if [ "$selinux_status" != "Disabled" ]; then
53 # skip the grant tests for ARM until they are fixed
54 if [[ $(uname -m) = aarch64 ]]; then
55 # bug number: LU-11596
56 ALWAYS_EXCEPT+=" $GRANT_CHECK_LIST"
57 # bug number: LU-11671 LU-11667
58 ALWAYS_EXCEPT+=" 45 317"
59 # bug number: LU-14067 LU-14067
60 ALWAYS_EXCEPT+=" 400a 400b"
63 # skip splice tests on kernels >= 4.15.0 until they are fixed
64 if [ $LINUX_VERSION_CODE -ge $(version_code 4.15.0) ]; then
65 # bug number: LU-14045
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 64b 68 71 115 135 136 300o"
83 if [ "$mds1_FSTYPE" = "zfs" ]; then
84 # bug number for skipped test:
85 ALWAYS_EXCEPT="$ALWAYS_EXCEPT "
87 [ "$SLOW" = "no" ] && EXCEPT_SLOW="$EXCEPT_SLOW 51b"
90 # Get the SLES distro version
92 # Returns a version string that should only be used in comparing
93 # strings returned by version_code()
96 local version=$(grep VERSION_ID /etc/os-release | cut -d'"' -f2)
98 # All SuSE Linux versions have one decimal. version_code expects two
99 local sles_version=$version.0
100 version_code $sles_version
103 # Check if we are running on Ubuntu or SLES so we can make decisions on
105 if [ -r /etc/SuSE-release ]; then
106 sles_version=$(sles_version_code)
107 [ $sles_version -lt $(version_code 11.4.0) ] &&
108 # bug number for skipped test: LU-4341
109 ALWAYS_EXCEPT="$ALWAYS_EXCEPT 170"
110 [ $sles_version -lt $(version_code 12.0.0) ] &&
111 # bug number for skipped test: LU-3703
112 ALWAYS_EXCEPT="$ALWAYS_EXCEPT 234"
113 elif [ -r /etc/os-release ]; then
114 if grep -qi ubuntu /etc/os-release; then
115 ubuntu_version=$(version_code $(sed -n -e 's/"//g' \
116 -e 's/^VERSION=//p' \
120 if [[ $ubuntu_version -gt $(version_code 16.0.0) ]]; then
121 # bug number for skipped test:
123 ALWAYS_EXCEPT+=" 103a 410"
133 pgrep ll_sa > /dev/null && { echo "There are ll_sa thread not exit!"; exit 20; }
134 cleanupall ${FORCE} $* || { echo "FAILed to clean up"; exit 20; }
143 check_swap_layouts_support()
145 $LCTL get_param -n llite.*.sbi_flags | grep -q layout ||
146 skip "Does not support layout lock."
149 check_swap_layout_no_dom()
152 local SUPP=$(lfs getstripe $FOLDER | grep "pattern: mdt" | wc -l)
153 [ $SUPP -eq 0 ] || skip "layout swap does not support DOM files so far"
156 check_and_setup_lustre
160 MAXFREE=${MAXFREE:-$((200000 * $OSTCOUNT))}
162 [ -f $DIR/d52a/foo ] && chattr -a $DIR/d52a/foo
163 [ -f $DIR/d52b/foo ] && chattr -i $DIR/d52b/foo
164 rm -rf $DIR/[Rdfs][0-9]*
166 # $RUNAS_ID may get set incorrectly somewhere else
167 [ $UID -eq 0 -a $RUNAS_ID -eq 0 ] &&
168 error "\$RUNAS_ID set to 0, but \$UID is also 0!"
170 check_runas_id $RUNAS_ID $RUNAS_GID $RUNAS
172 if [ "${ONLY}" = "MOUNT" ] ; then
173 echo "Lustre is up, please go on"
177 echo "preparing for tests involving mounts"
178 EXT2_DEV=${EXT2_DEV:-$TMP/SANITY.LOOP}
180 mke2fs -j -F $EXT2_DEV 8000 > /dev/null
181 echo # add a newline after mke2fs.
185 OLDDEBUG=$(lctl get_param -n debug 2> /dev/null)
186 lctl set_param debug=-1 2> /dev/null || true
189 $CHECKSTAT -t file $DIR/$tfile || error "$tfile is not a file"
191 $CHECKSTAT -a $DIR/$tfile || error "$tfile was not removed"
193 run_test 0a "touch; rm ====================="
196 chmod 0755 $DIR || error "chmod 0755 $DIR failed"
197 $CHECKSTAT -p 0755 $DIR || error "$DIR permission is not 0755"
199 run_test 0b "chmod 0755 $DIR ============================="
202 $LCTL get_param mdc.*.import | grep "state: FULL" ||
203 error "import not FULL"
204 $LCTL get_param mdc.*.import | grep "target: $FSNAME-MDT" ||
207 run_test 0c "check import proc"
209 test_0d() { # LU-3397
210 [ $MGS_VERSION -lt $(version_code 2.10.57) ] &&
211 skip "proc exports not supported before 2.10.57"
213 local mgs_exp="mgs.MGS.exports"
214 local client_uuid=$($LCTL get_param -n mgc.*.uuid)
216 local exp_client_version
219 local temp_imp=$DIR/$tfile.import
220 local temp_exp=$DIR/$tfile.export
222 # save mgc import file to $temp_imp
223 $LCTL get_param mgc.*.import | tee $temp_imp
224 # Check if client uuid is found in MGS export
225 for exp_client_nid in $(do_facet mgs $LCTL get_param -N $mgs_exp.*); do
226 [ $(do_facet mgs $LCTL get_param -n $exp_client_nid.uuid) == \
230 # save mgs export file to $temp_exp
231 do_facet mgs $LCTL get_param $exp_client_nid.export | tee $temp_exp
233 # Compare the value of field "connect_flags"
234 imp_val=$(grep "connect_flags" $temp_imp)
235 exp_val=$(grep "connect_flags" $temp_exp)
236 [ "$exp_val" == "$imp_val" ] ||
237 error "export flags '$exp_val' != import flags '$imp_val'"
239 # Compare the value of client version
240 exp_client_version=$(awk '/target_version:/ { print $2 }' $temp_exp)
241 exp_val=$(version_code $exp_client_version)
242 imp_val=$CLIENT_VERSION
243 [ "$exp_val" == "$imp_val" ] ||
244 error "export client version '$exp_val' != '$imp_val'"
246 run_test 0d "check export proc ============================="
249 test_mkdir $DIR/$tdir
250 test_mkdir $DIR/$tdir/d2
251 mkdir $DIR/$tdir/d2 && error "we expect EEXIST, but not returned"
252 $CHECKSTAT -t dir $DIR/$tdir/d2 || error "$tdir/d2 is not a dir"
255 $CHECKSTAT -a $DIR/$tdir || error "$tdir was not removed"
257 run_test 1 "mkdir; remkdir; rmdir"
260 test_mkdir $DIR/$tdir
261 touch $DIR/$tdir/$tfile || error "touch $tdir/$tfile failed"
262 $CHECKSTAT -t file $DIR/$tdir/$tfile || error "$tdir/$tfile not a file"
264 $CHECKSTAT -a $DIR/$tdir/$tfile || error "$tdir/$file is not removed"
266 run_test 2 "mkdir; touch; rmdir; check file"
269 test_mkdir $DIR/$tdir
270 $CHECKSTAT -t dir $DIR/$tdir || error "$tdir is not a directory"
271 touch $DIR/$tdir/$tfile
272 $CHECKSTAT -t file $DIR/$tdir/$tfile || error "$tdir/$tfile not a file"
274 $CHECKSTAT -a $DIR/$tdir || error "$tdir is not removed"
276 run_test 3 "mkdir; touch; rmdir; check dir"
278 # LU-4471 - failed rmdir on remote directories still removes directory on MDT0
280 test_mkdir -i 1 $DIR/$tdir
282 touch $DIR/$tdir/$tfile ||
283 error "Create file under remote directory failed"
286 error "Expect error removing in-use dir $DIR/$tdir"
288 test -d $DIR/$tdir || error "Remote directory disappeared"
290 rm -rf $DIR/$tdir || error "remove remote dir error"
292 run_test 4 "mkdir; touch dir/file; rmdir; checkdir (expect error)"
295 test_mkdir $DIR/$tdir
296 test_mkdir $DIR/$tdir/d2
297 chmod 0707 $DIR/$tdir/d2 || error "chmod 0707 $tdir/d2 failed"
298 $CHECKSTAT -t dir -p 0707 $DIR/$tdir/d2 || error "$tdir/d2 not mode 707"
299 $CHECKSTAT -t dir $DIR/$tdir/d2 || error "$tdir/d2 is not a directory"
301 run_test 5 "mkdir .../d5 .../d5/d2; chmod .../d5/d2"
304 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
305 chmod 0666 $DIR/$tfile || error "chmod 0666 $tfile failed"
306 $CHECKSTAT -t file -p 0666 -u \#$UID $DIR/$tfile ||
307 error "$tfile does not have perm 0666 or UID $UID"
308 $RUNAS chmod 0444 $DIR/$tfile && error "chmod $tfile worked on UID $UID"
309 $CHECKSTAT -t file -p 0666 -u \#$UID $DIR/$tfile ||
310 error "$tfile should be 0666 and owned by UID $UID"
312 run_test 6a "touch f6a; chmod f6a; $RUNAS chmod f6a (should return error) =="
315 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID"
318 chown $RUNAS_ID $DIR/$tfile || error "chown $RUNAS_ID $file failed"
319 $CHECKSTAT -t file -u \#$RUNAS_ID $DIR/$tfile ||
320 error "$tfile should be owned by UID $RUNAS_ID"
321 $RUNAS chown $UID $DIR/$tfile && error "chown $UID $file succeeded"
322 $CHECKSTAT -t file -u \#$RUNAS_ID $DIR/$tfile ||
323 error "$tfile should be owned by UID $RUNAS_ID"
325 run_test 6c "touch f6c; chown f6c; $RUNAS chown f6c (should return error) =="
328 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID"
331 chgrp $RUNAS_ID $DIR/$tfile || error "chgrp $RUNAS_ID $file failed"
332 $CHECKSTAT -t file -u \#$UID -g \#$RUNAS_ID $DIR/$tfile ||
333 error "$tfile should be owned by GID $UID"
334 $RUNAS chgrp $UID $DIR/$tfile && error "chgrp $UID $file succeeded"
335 $CHECKSTAT -t file -u \#$UID -g \#$RUNAS_ID $DIR/$tfile ||
336 error "$tfile should be owned by UID $UID and GID $RUNAS_ID"
338 run_test 6e "touch+chgrp $tfile; $RUNAS chgrp $tfile (should return error)"
341 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID"
343 test_mkdir $DIR/$tdir
344 chmod 777 $DIR/$tdir || error "chmod 0777 $tdir failed"
345 $RUNAS mkdir $DIR/$tdir/d || error "mkdir $tdir/d failed"
346 chmod g+s $DIR/$tdir/d || error "chmod g+s $tdir/d failed"
347 test_mkdir $DIR/$tdir/d/subdir
348 $CHECKSTAT -g \#$RUNAS_GID $DIR/$tdir/d/subdir ||
349 error "$tdir/d/subdir should be GID $RUNAS_GID"
350 if [[ $MDSCOUNT -gt 1 ]]; then
351 # check remote dir sgid inherite
352 $LFS mkdir -i 0 $DIR/$tdir.local ||
353 error "mkdir $tdir.local failed"
354 chmod g+s $DIR/$tdir.local ||
355 error "chmod $tdir.local failed"
356 chgrp $RUNAS_GID $DIR/$tdir.local ||
357 error "chgrp $tdir.local failed"
358 $LFS mkdir -i 1 $DIR/$tdir.local/$tdir.remote ||
359 error "mkdir $tdir.remote failed"
360 $CHECKSTAT -g \#$RUNAS_GID $DIR/$tdir.local/$tdir.remote ||
361 error "$tdir.remote should be owned by $UID.$RUNAS_ID"
362 $CHECKSTAT -p 02755 $DIR/$tdir.local/$tdir.remote ||
363 error "$tdir.remote should be mode 02755"
366 run_test 6g "verify new dir in sgid dir inherits group"
368 test_6h() { # bug 7331
369 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID"
371 touch $DIR/$tfile || error "touch failed"
372 chown $RUNAS_ID:$RUNAS_GID $DIR/$tfile || error "initial chown failed"
373 $RUNAS -G$RUNAS_GID chown $RUNAS_ID:0 $DIR/$tfile &&
374 error "chown $RUNAS_ID:0 $tfile worked as GID $RUNAS_GID"
375 $CHECKSTAT -t file -u \#$RUNAS_ID -g \#$RUNAS_GID $DIR/$tfile ||
376 error "$tdir/$tfile should be UID $RUNAS_UID GID $RUNAS_GID"
378 run_test 6h "$RUNAS chown RUNAS_ID.0 .../$tfile (should return error)"
381 test_mkdir $DIR/$tdir
382 $MCREATE $DIR/$tdir/$tfile
383 chmod 0666 $DIR/$tdir/$tfile
384 $CHECKSTAT -t file -p 0666 $DIR/$tdir/$tfile ||
385 error "$tdir/$tfile should be mode 0666"
387 run_test 7a "mkdir .../d7; mcreate .../d7/f; chmod .../d7/f ===="
390 if [ ! -d $DIR/$tdir ]; then
391 test_mkdir $DIR/$tdir
393 $MCREATE $DIR/$tdir/$tfile
394 echo -n foo > $DIR/$tdir/$tfile
395 [ "$(cat $DIR/$tdir/$tfile)" = "foo" ] || error "$tdir/$tfile not 'foo'"
396 $CHECKSTAT -t file -s 3 $DIR/$tdir/$tfile || error "$tfile size not 3"
398 run_test 7b "mkdir .../d7; mcreate d7/f2; echo foo > d7/f2 ====="
401 test_mkdir $DIR/$tdir
402 touch $DIR/$tdir/$tfile
403 chmod 0666 $DIR/$tdir/$tfile
404 $CHECKSTAT -t file -p 0666 $DIR/$tdir/$tfile ||
405 error "$tfile mode not 0666"
407 run_test 8 "mkdir .../d8; touch .../d8/f; chmod .../d8/f ======="
410 test_mkdir $DIR/$tdir
411 test_mkdir $DIR/$tdir/d2
412 test_mkdir $DIR/$tdir/d2/d3
413 $CHECKSTAT -t dir $DIR/$tdir/d2/d3 || error "$tdir/d2/d3 not a dir"
415 run_test 9 "mkdir .../d9 .../d9/d2 .../d9/d2/d3 ================"
418 test_mkdir $DIR/$tdir
419 test_mkdir $DIR/$tdir/d2
420 touch $DIR/$tdir/d2/$tfile
421 $CHECKSTAT -t file $DIR/$tdir/d2/$tfile ||
422 error "$tdir/d2/$tfile not a file"
424 run_test 10 "mkdir .../d10 .../d10/d2; touch .../d10/d2/f ======"
427 test_mkdir $DIR/$tdir
428 test_mkdir $DIR/$tdir/d2
429 chmod 0666 $DIR/$tdir/d2
430 chmod 0705 $DIR/$tdir/d2
431 $CHECKSTAT -t dir -p 0705 $DIR/$tdir/d2 ||
432 error "$tdir/d2 mode not 0705"
434 run_test 11 "mkdir .../d11 d11/d2; chmod .../d11/d2 ============"
437 test_mkdir $DIR/$tdir
438 touch $DIR/$tdir/$tfile
439 chmod 0666 $DIR/$tdir/$tfile
440 chmod 0654 $DIR/$tdir/$tfile
441 $CHECKSTAT -t file -p 0654 $DIR/$tdir/$tfile ||
442 error "$tdir/d2 mode not 0654"
444 run_test 12 "touch .../d12/f; chmod .../d12/f .../d12/f ========"
447 test_mkdir $DIR/$tdir
448 dd if=/dev/zero of=$DIR/$tdir/$tfile count=10
450 $CHECKSTAT -t file -s 0 $DIR/$tdir/$tfile ||
451 error "$tdir/$tfile size not 0 after truncate"
453 run_test 13 "creat .../d13/f; dd .../d13/f; > .../d13/f ========"
456 test_mkdir $DIR/$tdir
457 touch $DIR/$tdir/$tfile
459 $CHECKSTAT -a $DIR/$tdir/$tfile || error "$tdir/$tfile not removed"
461 run_test 14 "touch .../d14/f; rm .../d14/f; rm .../d14/f ======="
464 test_mkdir $DIR/$tdir
465 touch $DIR/$tdir/$tfile
466 mv $DIR/$tdir/$tfile $DIR/$tdir/${tfile}_2
467 $CHECKSTAT -t file $DIR/$tdir/${tfile}_2 ||
468 error "$tdir/${tfile_2} not a file after rename"
469 rm $DIR/$tdir/${tfile}_2 || error "unlink failed after rename"
471 run_test 15 "touch .../d15/f; mv .../d15/f .../d15/f2 =========="
474 test_mkdir $DIR/$tdir
475 touch $DIR/$tdir/$tfile
476 rm -rf $DIR/$tdir/$tfile
477 $CHECKSTAT -a $DIR/$tdir/$tfile || error "$tdir/$tfile not removed"
479 run_test 16 "touch .../d16/f; rm -rf .../d16/f"
482 test_mkdir $DIR/$tdir
483 touch $DIR/$tdir/$tfile
484 ln -s $DIR/$tdir/$tfile $DIR/$tdir/l-exist
486 $CHECKSTAT -l $DIR/$tdir/$tfile $DIR/$tdir/l-exist ||
487 error "$tdir/l-exist not a symlink"
488 $CHECKSTAT -f -t f $DIR/$tdir/l-exist ||
489 error "$tdir/l-exist not referencing a file"
490 rm -f $DIR/$tdir/l-exist
491 $CHECKSTAT -a $DIR/$tdir/l-exist || error "$tdir/l-exist not removed"
493 run_test 17a "symlinks: create, remove (real)"
496 test_mkdir $DIR/$tdir
497 ln -s no-such-file $DIR/$tdir/l-dangle
499 $CHECKSTAT -l no-such-file $DIR/$tdir/l-dangle ||
500 error "$tdir/l-dangle not referencing no-such-file"
501 $CHECKSTAT -fa $DIR/$tdir/l-dangle ||
502 error "$tdir/l-dangle not referencing non-existent file"
503 rm -f $DIR/$tdir/l-dangle
504 $CHECKSTAT -a $DIR/$tdir/l-dangle || error "$tdir/l-dangle not removed"
506 run_test 17b "symlinks: create, remove (dangling)"
508 test_17c() { # bug 3440 - don't save failed open RPC for replay
509 test_mkdir $DIR/$tdir
510 ln -s foo $DIR/$tdir/$tfile
511 cat $DIR/$tdir/$tfile && error "opened non-existent symlink" || true
513 run_test 17c "symlinks: open dangling (should return error)"
516 test_mkdir $DIR/$tdir
517 ln -s foo $DIR/$tdir/$tfile
518 touch $DIR/$tdir/$tfile || error "creating to new symlink"
520 run_test 17d "symlinks: create dangling"
523 test_mkdir $DIR/$tdir
524 local foo=$DIR/$tdir/$tfile
525 ln -s $foo $foo || error "create symlink failed"
526 ls -l $foo || error "ls -l failed"
527 ls $foo && error "ls not failed" || true
529 run_test 17e "symlinks: create recursive symlink (should return error)"
532 test_mkdir $DIR/$tdir
533 ln -s 1234567890/2234567890/3234567890/4234567890 $DIR/$tdir/111
534 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890 $DIR/$tdir/222
535 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890 $DIR/$tdir/333
536 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890/9234567890/a234567890/b234567890 $DIR/$tdir/444
537 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890/9234567890/a234567890/b234567890/c234567890/d234567890/f234567890 $DIR/$tdir/555
538 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
541 run_test 17f "symlinks: long and very long symlink name"
543 # str_repeat(S, N) generate a string that is string S repeated N times
548 while [ $((n -= 1)) -ge 0 ]; do
554 # Long symlinks and LU-2241
556 test_mkdir $DIR/$tdir
557 local TESTS="59 60 61 4094 4095"
559 # Fix for inode size boundary in 2.1.4
560 [ $MDS1_VERSION -lt $(version_code 2.1.4) ] &&
563 # Patch not applied to 2.2 or 2.3 branches
564 [ $MDS1_VERSION -ge $(version_code 2.2.0) ] &&
565 [ $MDS1_VERSION -le $(version_code 2.3.55) ] &&
569 local SYMNAME=$(str_repeat 'x' $i)
570 ln -s $SYMNAME $DIR/$tdir/f$i || error "failed $i-char symlink"
571 readlink $DIR/$tdir/f$i || error "failed $i-char readlink"
574 run_test 17g "symlinks: really long symlink name and inode boundaries"
576 test_17h() { #bug 17378
577 [ $PARALLEL == "yes" ] && skip "skip parallel run"
578 remote_mds_nodsh && skip "remote MDS with nodsh"
582 test_mkdir $DIR/$tdir
583 mdt_idx=$($LFS getdirstripe -i $DIR/$tdir)
584 $LFS setstripe -c -1 $DIR/$tdir
585 #define OBD_FAIL_MDS_LOV_PREP_CREATE 0x141
586 do_facet mds$((mdt_idx + 1)) lctl set_param fail_loc=0x80000141
587 touch $DIR/$tdir/$tfile || true
589 run_test 17h "create objects: lov_free_memmd() doesn't lbug"
591 test_17i() { #bug 20018
592 [ $PARALLEL == "yes" ] && skip "skip parallel run"
593 remote_mds_nodsh && skip "remote MDS with nodsh"
595 local foo=$DIR/$tdir/$tfile
598 test_mkdir -c1 $DIR/$tdir
599 mdt_idx=$($LFS getdirstripe -i $DIR/$tdir)
600 ln -s $foo $foo || error "create symlink failed"
601 #define OBD_FAIL_MDS_READLINK_EPROTO 0x143
602 do_facet mds$((mdt_idx + 1)) lctl set_param fail_loc=0x80000143
603 ls -l $foo && error "error not detected"
606 run_test 17i "don't panic on short symlink (should return error)"
608 test_17k() { #bug 22301
609 [ $PARALLEL == "yes" ] && skip "skip parallel run"
610 [[ -z "$(which rsync 2>/dev/null)" ]] &&
611 skip "no rsync command"
612 rsync --help | grep -q xattr ||
613 skip_env "$(rsync --version | head -n1) does not support xattrs"
614 test_mkdir $DIR/$tdir
615 test_mkdir $DIR/$tdir.new
616 touch $DIR/$tdir/$tfile
617 ln -s $DIR/$tdir/$tfile $DIR/$tdir/$tfile.lnk
618 rsync -av -X $DIR/$tdir/ $DIR/$tdir.new ||
619 error "rsync failed with xattrs enabled"
621 run_test 17k "symlinks: rsync with xattrs enabled"
623 test_17l() { # LU-279
624 [[ -z "$(which getfattr 2>/dev/null)" ]] &&
625 skip "no getfattr command"
627 test_mkdir $DIR/$tdir
628 touch $DIR/$tdir/$tfile
629 ln -s $DIR/$tdir/$tfile $DIR/$tdir/$tfile.lnk
630 for path in "$DIR/$tdir" "$DIR/$tdir/$tfile" "$DIR/$tdir/$tfile.lnk"; do
631 # -h to not follow symlinks. -m '' to list all the xattrs.
632 # grep to remove first line: '# file: $path'.
633 for xattr in `getfattr -hm '' $path 2>/dev/null | grep -v '^#'`;
635 lgetxattr_size_check $path $xattr ||
636 error "lgetxattr_size_check $path $xattr failed"
640 run_test 17l "Ensure lgetxattr's returned xattr size is consistent"
644 [ $PARALLEL == "yes" ] && skip "skip parallel run"
645 [ "$mds1_FSTYPE" != "ldiskfs" ] && skip_env "ldiskfs only test"
646 remote_mds_nodsh && skip "remote MDS with nodsh"
647 [ $MDS1_VERSION -ge $(version_code 2.2.0) ] &&
648 [ $MDS1_VERSION -le $(version_code 2.2.93) ] &&
649 skip "MDS 2.2.0-2.2.93 do not NUL-terminate symlinks"
651 local short_sym="0123456789"
652 local wdir=$DIR/$tdir
657 # create a long symlink file
658 for ((i = 0; i < 4; ++i)); do
659 long_sym=${long_sym}${long_sym}
662 echo "create 512 short and long symlink files under $wdir"
663 for ((i = 0; i < 256; ++i)); do
664 ln -sf ${long_sym}"a5a5" $wdir/long-$i
665 ln -sf ${short_sym}"a5a5" $wdir/short-$i
671 wait_delete_completed
673 echo "recreate the 512 symlink files with a shorter string"
674 for ((i = 0; i < 512; ++i)); do
675 # rewrite the symlink file with a shorter string
676 ln -sf ${long_sym} $wdir/long-$i || error "long_sym failed"
677 ln -sf ${short_sym} $wdir/short-$i || error "short_sym failed"
680 local mds_index=$(($($LFS getstripe -m $wdir) + 1))
681 local devname=$(mdsdevname $mds_index)
683 echo "stop and checking mds${mds_index}:"
684 # e2fsck should not return error
686 run_e2fsck $(facet_active_host mds${mds_index}) $devname -n
689 start mds${mds_index} $devname $MDS_MOUNT_OPTS ||
690 error "start mds${mds_index} failed"
691 df $MOUNT > /dev/null 2>&1
693 error "e2fsck detected error for short/long symlink: rc=$rc"
696 run_test 17m "run e2fsck against MDT which contains short/long symlink"
698 check_fs_consistency_17n() {
702 # create/unlink in 17n only change 2 MDTs(MDT1/MDT2),
703 # so it only check MDT1/MDT2 instead of all of MDTs.
704 for mdt_index in 1 2; do
705 local devname=$(mdsdevname $mdt_index)
706 # e2fsck should not return error
708 run_e2fsck $(facet_active_host mds$mdt_index) $devname -n ||
711 start mds${mdt_index} $devname $MDS_MOUNT_OPTS ||
712 error "mount mds$mdt_index failed"
713 df $MOUNT > /dev/null 2>&1
719 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
720 [ $PARALLEL == "yes" ] && skip "skip parallel run"
721 [ "$mds1_FSTYPE" != "ldiskfs" ] && skip_env "ldiskfs only test"
722 remote_mds_nodsh && skip "remote MDS with nodsh"
723 [ $MDS1_VERSION -ge $(version_code 2.2.0) ] &&
724 [ $MDS1_VERSION -le $(version_code 2.2.93) ] &&
725 skip "MDS 2.2.0-2.2.93 do not NUL-terminate symlinks"
729 test_mkdir $DIR/$tdir
730 for ((i=0; i<10; i++)); do
731 $LFS mkdir -i1 -c2 $DIR/$tdir/remote_dir_${i} ||
732 error "create remote dir error $i"
733 createmany -o $DIR/$tdir/remote_dir_${i}/f 10 ||
734 error "create files under remote dir failed $i"
737 check_fs_consistency_17n ||
738 error "e2fsck report error after create files under remote dir"
740 for ((i = 0; i < 10; i++)); do
741 rm -rf $DIR/$tdir/remote_dir_${i} ||
742 error "destroy remote dir error $i"
745 check_fs_consistency_17n ||
746 error "e2fsck report error after unlink files under remote dir"
748 [ $MDS1_VERSION -lt $(version_code 2.4.50) ] &&
749 skip "lustre < 2.4.50 does not support migrate mv"
751 for ((i = 0; i < 10; i++)); do
752 mkdir -p $DIR/$tdir/remote_dir_${i}
753 createmany -o $DIR/$tdir/remote_dir_${i}/f 10 ||
754 error "create files under remote dir failed $i"
755 $LFS migrate --mdt-index 1 $DIR/$tdir/remote_dir_${i} ||
756 error "migrate remote dir error $i"
758 check_fs_consistency_17n || error "e2fsck report error after migration"
760 for ((i = 0; i < 10; i++)); do
761 rm -rf $DIR/$tdir/remote_dir_${i} ||
762 error "destroy remote dir error $i"
765 check_fs_consistency_17n || error "e2fsck report error after unlink"
767 run_test 17n "run e2fsck against master/slave MDT which contains remote dir"
770 remote_mds_nodsh && skip "remote MDS with nodsh"
771 [ $MDS1_VERSION -lt $(version_code 2.3.64) ] &&
772 skip "Need MDS version at least 2.3.64"
774 local wdir=$DIR/${tdir}o
780 mdt_index=$($LFS getstripe -m $wdir/$tfile)
781 mdt_index=$((mdt_index + 1))
784 #fail mds will wait the failover finish then set
785 #following fail_loc to avoid interfer the recovery process.
788 #define OBD_FAIL_OSD_LMA_INCOMPAT 0x194
789 do_facet mds${mdt_index} lctl set_param fail_loc=0x194
790 ls -l $wdir/$tfile && rc=1
791 do_facet mds${mdt_index} lctl set_param fail_loc=0
792 [[ $rc -eq 0 ]] || error "stat file should fail"
794 run_test 17o "stat file with incompat LMA feature"
797 touch $DIR/$tfile || error "Failed to touch $DIR/$tfile: $?"
798 ls $DIR || error "Failed to ls $DIR: $?"
800 run_test 18 "touch .../f ; ls ... =============================="
806 $CHECKSTAT -a $DIR/$tfile || error "$tfile was not removed"
808 run_test 19a "touch .../f19 ; ls -l ... ; rm .../f19 ==========="
811 ls -l $DIR/$tfile && error "ls -l $tfile failed"|| true
813 run_test 19b "ls -l .../f19 (should return error) =============="
816 [ $RUNAS_ID -eq $UID ] &&
817 skip_env "RUNAS_ID = UID = $UID -- skipping"
819 $RUNAS touch $DIR/$tfile && error "create non-root file failed" || true
821 run_test 19c "$RUNAS touch .../f19 (should return error) =="
824 cat $DIR/f19 && error || true
826 run_test 19d "cat .../f19 (should return error) =============="
835 $CHECKSTAT -a $DIR/$tfile || error "$tfile was not removed"
837 run_test 20 "touch .../f ; ls -l ..."
840 test_mkdir $DIR/$tdir
841 [ -f $DIR/$tdir/dangle ] && rm -f $DIR/$tdir/dangle
842 ln -s dangle $DIR/$tdir/link
843 echo foo >> $DIR/$tdir/link
844 cat $DIR/$tdir/dangle
845 $CHECKSTAT -t link $DIR/$tdir/link || error "$tdir/link not a link"
846 $CHECKSTAT -f -t file $DIR/$tdir/link ||
847 error "$tdir/link not linked to a file"
849 run_test 21 "write to dangling link"
852 local wdir=$DIR/$tdir
854 chown $RUNAS_ID:$RUNAS_GID $wdir
855 (cd $wdir || error "cd $wdir failed";
856 $RUNAS tar cf - /etc/hosts /etc/sysconfig/network |
858 ls -lR $wdir/etc || error "ls -lR $wdir/etc failed"
859 $CHECKSTAT -t dir $wdir/etc || error "checkstat -t dir failed"
860 $CHECKSTAT -u \#$RUNAS_ID -g \#$RUNAS_GID $wdir/etc ||
861 error "checkstat -u failed"
863 run_test 22 "unpack tar archive as non-root user"
867 test_mkdir $DIR/$tdir
868 local file=$DIR/$tdir/$tfile
870 openfile -f O_CREAT:O_EXCL $file || error "$file create failed"
871 openfile -f O_CREAT:O_EXCL $file &&
872 error "$file recreate succeeded" || true
874 run_test 23a "O_CREAT|O_EXCL in subdir"
876 test_23b() { # bug 18988
877 test_mkdir $DIR/$tdir
878 local file=$DIR/$tdir/$tfile
881 echo foo > $file || error "write filed"
882 echo bar >> $file || error "append filed"
883 $CHECKSTAT -s 8 $file || error "wrong size"
886 run_test 23b "O_APPEND check"
888 # LU-9409, size with O_APPEND and tiny writes
890 local file=$DIR/$tfile
893 dd conv=notrunc oflag=append if=/dev/zero of=$file bs=8 count=800
894 $CHECKSTAT -s 6400 $file || error "wrong size, expected 6400"
898 dd conv=notrunc oflag=append if=/dev/zero of=$file bs=8 count=800 &
899 dd conv=notrunc oflag=append if=/dev/zero of=$file bs=8 count=800 &
901 $CHECKSTAT -s 12800 $file || error "wrong size, expected 12800"
904 #racing tiny & normal writes
905 dd conv=notrunc oflag=append if=/dev/zero of=$file bs=4096 count=4 &
906 dd conv=notrunc oflag=append if=/dev/zero of=$file bs=8 count=100 &
908 $CHECKSTAT -s 17184 $file || error "wrong size, expected 17184"
911 #racing tiny & normal writes 2, ugly numbers
912 dd conv=notrunc oflag=append if=/dev/zero of=$file bs=4099 count=11 &
913 dd conv=notrunc oflag=append if=/dev/zero of=$file bs=17 count=173 &
915 $CHECKSTAT -s 48030 $file || error "wrong size, expected 48030"
918 run_test 23c "O_APPEND size checks for tiny writes"
920 # LU-11069 file offset is correct after appending writes
922 local file=$DIR/$tfile
925 echo CentaurHauls > $file
926 offset=$($MULTIOP $file oO_WRONLY:O_APPEND:w13Zp)
927 if ((offset != 26)); then
928 error "wrong offset, expected 26, got '$offset'"
931 run_test 23d "file offset is correct after appending writes"
935 echo '-- same directory rename'
936 test_mkdir $DIR/$tdir
937 touch $DIR/$tdir/$tfile.1
938 mv $DIR/$tdir/$tfile.1 $DIR/$tdir/$tfile.2
939 $CHECKSTAT -t file $DIR/$tdir/$tfile.2 || error "$tfile.2 not a file"
941 run_test 24a "rename file to non-existent target"
944 test_mkdir $DIR/$tdir
945 touch $DIR/$tdir/$tfile.{1,2}
946 mv $DIR/$tdir/$tfile.1 $DIR/$tdir/$tfile.2
947 $CHECKSTAT -a $DIR/$tdir/$tfile.1 || error "$tfile.1 exists"
948 $CHECKSTAT -t file $DIR/$tdir/$tfile.2 || error "$tfile.2 not a file"
950 run_test 24b "rename file to existing target"
953 test_mkdir $DIR/$tdir
954 test_mkdir $DIR/$tdir/d$testnum.1
955 mv $DIR/$tdir/d$testnum.1 $DIR/$tdir/d$testnum.2
956 $CHECKSTAT -a $DIR/$tdir/d$testnum.1 || error "d$testnum.1 exists"
957 $CHECKSTAT -t dir $DIR/$tdir/d$testnum.2 || error "d$testnum.2 not dir"
959 run_test 24c "rename directory to non-existent target"
962 test_mkdir -c1 $DIR/$tdir
963 test_mkdir -c1 $DIR/$tdir/d$testnum.1
964 test_mkdir -c1 $DIR/$tdir/d$testnum.2
965 mrename $DIR/$tdir/d$testnum.1 $DIR/$tdir/d$testnum.2
966 $CHECKSTAT -a $DIR/$tdir/d$testnum.1 || error "d$testnum.1 exists"
967 $CHECKSTAT -t dir $DIR/$tdir/d$testnum.2 || error "d$testnum.2 not dir"
969 run_test 24d "rename directory to existing target"
972 echo '-- cross directory renames --'
976 mv $DIR/R5a/f $DIR/R5b/g
977 $CHECKSTAT -a $DIR/R5a/f || error "$DIR/R5a/f exists"
978 $CHECKSTAT -t file $DIR/R5b/g || error "$DIR/R5b/g not file type"
980 run_test 24e "touch .../R5a/f; rename .../R5a/f .../R5b/g ======"
985 touch $DIR/R6a/f $DIR/R6b/g
986 mv $DIR/R6a/f $DIR/R6b/g
987 $CHECKSTAT -a $DIR/R6a/f || error "$DIR/R6a/f exists"
988 $CHECKSTAT -t file $DIR/R6b/g || error "$DIR/R6b/g not file type"
990 run_test 24f "touch .../R6a/f R6b/g; mv .../R6a/f .../R6b/g ===="
995 test_mkdir $DIR/R7a/d
996 mv $DIR/R7a/d $DIR/R7b/e
997 $CHECKSTAT -a $DIR/R7a/d || error "$DIR/R7a/d exists"
998 $CHECKSTAT -t dir $DIR/R7b/e || error "$DIR/R7b/e not dir type"
1000 run_test 24g "mkdir .../R7{a,b}/d; mv .../R7a/d .../R7b/e ======"
1003 test_mkdir -c1 $DIR/R8a
1004 test_mkdir -c1 $DIR/R8b
1005 test_mkdir -c1 $DIR/R8a/d
1006 test_mkdir -c1 $DIR/R8b/e
1007 mrename $DIR/R8a/d $DIR/R8b/e
1008 $CHECKSTAT -a $DIR/R8a/d || error "$DIR/R8a/d exists"
1009 $CHECKSTAT -t dir $DIR/R8b/e || error "$DIR/R8b/e not dir type"
1011 run_test 24h "mkdir .../R8{a,b}/{d,e}; rename .../R8a/d .../R8b/e"
1014 echo "-- rename error cases"
1016 test_mkdir $DIR/R9/a
1018 mrename $DIR/R9/f $DIR/R9/a
1019 $CHECKSTAT -t file $DIR/R9/f || error "$DIR/R9/f not file type"
1020 $CHECKSTAT -t dir $DIR/R9/a || error "$DIR/R9/a not dir type"
1021 $CHECKSTAT -a $DIR/R9/a/f || error "$DIR/R9/a/f exists"
1023 run_test 24i "rename file to dir error: touch f ; mkdir a ; rename f a"
1027 mrename $DIR/R10/f $DIR/R10/g
1028 $CHECKSTAT -t dir $DIR/R10 || error "$DIR/R10 not dir type"
1029 $CHECKSTAT -a $DIR/R10/f || error "$DIR/R10/f exists"
1030 $CHECKSTAT -a $DIR/R10/g || error "$DIR/R10/g exists"
1032 run_test 24j "source does not exist ============================"
1035 test_mkdir $DIR/R11a
1036 test_mkdir $DIR/R11a/d
1038 mv $DIR/R11a/f $DIR/R11a/d
1039 $CHECKSTAT -a $DIR/R11a/f || error "$DIR/R11a/f exists"
1040 $CHECKSTAT -t file $DIR/R11a/d/f || error "$DIR/R11a/d/f not file type"
1042 run_test 24k "touch .../R11a/f; mv .../R11a/f .../R11a/d ======="
1044 # bug 2429 - rename foo foo foo creates invalid file
1047 $MULTIOP $f OcNs || error "rename of ${f} to itself failed"
1049 run_test 24l "Renaming a file to itself ========================"
1053 $MULTIOP $f OcLN ${f}2 ${f}2 || error "link ${f}2 ${f}2 failed"
1054 # on ext3 this does not remove either the source or target files
1055 # though the "expected" operation would be to remove the source
1056 $CHECKSTAT -t file ${f} || error "${f} missing"
1057 $CHECKSTAT -t file ${f}2 || error "${f}2 missing"
1059 run_test 24m "Renaming a file to a hard link to itself ========="
1063 # this stats the old file after it was renamed, so it should fail
1065 $CHECKSTAT ${f} || error "${f} missing"
1067 $CHECKSTAT ${f}.rename || error "${f}.rename missing"
1068 $CHECKSTAT -a ${f} || error "${f} exists"
1070 run_test 24n "Statting the old file after renaming (Posix rename 2)"
1073 test_mkdir $DIR/$tdir
1074 rename_many -s random -v -n 10 $DIR/$tdir
1076 run_test 24o "rename of files during htree split"
1079 test_mkdir $DIR/R12a
1080 test_mkdir $DIR/R12b
1081 DIRINO=`ls -lid $DIR/R12a | awk '{ print $1 }'`
1082 mrename $DIR/R12a $DIR/R12b
1083 $CHECKSTAT -a $DIR/R12a || error "$DIR/R12a exists"
1084 $CHECKSTAT -t dir $DIR/R12b || error "$DIR/R12b not dir type"
1085 DIRINO2=`ls -lid $DIR/R12b | awk '{ print $1 }'`
1086 [ "$DIRINO" = "$DIRINO2" ] || error "R12a $DIRINO != R12b $DIRINO2"
1088 run_test 24p "mkdir .../R12{a,b}; rename .../R12a .../R12b"
1090 cleanup_multiop_pause() {
1092 kill -USR1 $MULTIPID
1096 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1098 test_mkdir $DIR/R13a
1099 test_mkdir $DIR/R13b
1100 local DIRINO=$(ls -lid $DIR/R13a | awk '{ print $1 }')
1101 multiop_bg_pause $DIR/R13b D_c || error "multiop failed to start"
1104 trap cleanup_multiop_pause EXIT
1105 mrename $DIR/R13a $DIR/R13b
1106 $CHECKSTAT -a $DIR/R13a || error "R13a still exists"
1107 $CHECKSTAT -t dir $DIR/R13b || error "R13b does not exist"
1108 local DIRINO2=$(ls -lid $DIR/R13b | awk '{ print $1 }')
1109 [ "$DIRINO" = "$DIRINO2" ] || error "R13a $DIRINO != R13b $DIRINO2"
1110 cleanup_multiop_pause
1111 wait $MULTIPID || error "multiop close failed"
1113 run_test 24q "mkdir .../R13{a,b}; open R13b rename R13a R13b ==="
1115 test_24r() { #bug 3789
1116 test_mkdir $DIR/R14a
1117 test_mkdir $DIR/R14a/b
1118 mrename $DIR/R14a $DIR/R14a/b && error "rename to subdir worked!"
1119 $CHECKSTAT -t dir $DIR/R14a || error "$DIR/R14a missing"
1120 $CHECKSTAT -t dir $DIR/R14a/b || error "$DIR/R14a/b missing"
1122 run_test 24r "mkdir .../R14a/b; rename .../R14a .../R14a/b ====="
1125 test_mkdir $DIR/R15a
1126 test_mkdir $DIR/R15a/b
1127 test_mkdir $DIR/R15a/b/c
1128 mrename $DIR/R15a $DIR/R15a/b/c && error "rename to sub-subdir worked!"
1129 $CHECKSTAT -t dir $DIR/R15a || error "$DIR/R15a missing"
1130 $CHECKSTAT -t dir $DIR/R15a/b/c || error "$DIR/R15a/b/c missing"
1132 run_test 24s "mkdir .../R15a/b/c; rename .../R15a .../R15a/b/c ="
1134 test_mkdir $DIR/R16a
1135 test_mkdir $DIR/R16a/b
1136 test_mkdir $DIR/R16a/b/c
1137 mrename $DIR/R16a/b/c $DIR/R16a && error "rename to sub-subdir worked!"
1138 $CHECKSTAT -t dir $DIR/R16a || error "$DIR/R16a missing"
1139 $CHECKSTAT -t dir $DIR/R16a/b/c || error "$DIR/R16a/b/c missing"
1141 run_test 24t "mkdir .../R16a/b/c; rename .../R16a/b/c .../R16a ="
1143 test_24u() { # bug12192
1144 $MULTIOP $DIR/$tfile C2w$((2048 * 1024))c || error "multiop failed"
1145 $CHECKSTAT -s $((2048 * 1024)) $DIR/$tfile || error "wrong file size"
1147 run_test 24u "create stripe file"
1149 simple_cleanup_common() {
1152 [ -z "$DIR" ] || [ -z "$tdir" ] && return 0
1154 local start=$SECONDS
1157 wait_delete_completed
1158 echo "cleanup time $((SECONDS - start))"
1162 max_pages_per_rpc() {
1163 local mdtname="$(printf "MDT%04x" ${1:-0})"
1164 $LCTL get_param -n mdc.*$mdtname*.max_pages_per_rpc
1168 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1170 local nrfiles=${COUNT:-100000}
1171 local fname="$DIR/$tdir/$tfile"
1173 # Performance issue on ZFS see LU-4072 (c.f. LU-2887)
1174 [ "$mds1_FSTYPE" = "zfs" ] && nrfiles=${COUNT:-10000}
1176 test_mkdir "$(dirname $fname)"
1177 # assume MDT0000 has the fewest inodes
1178 local stripes=$($LFS getdirstripe -c $(dirname $fname))
1179 local free_inodes=$(($(mdt_free_inodes 0) * stripes))
1180 [[ $free_inodes -lt $nrfiles ]] && nrfiles=$free_inodes
1182 trap simple_cleanup_common EXIT
1184 createmany -m "$fname" $nrfiles
1186 cancel_lru_locks mdc
1187 lctl set_param mdc.*.stats clear
1189 # was previously test_24D: LU-6101
1190 # readdir() returns correct number of entries after cursor reload
1191 local num_ls=$(ls $DIR/$tdir | wc -l)
1192 local num_uniq=$(ls $DIR/$tdir | sort -u | wc -l)
1193 local num_all=$(ls -a $DIR/$tdir | wc -l)
1194 if [ $num_ls -ne $nrfiles ] || [ $num_uniq -ne $nrfiles ] ||
1195 [ $num_all -ne $((nrfiles + 2)) ]; then
1196 error "Expected $nrfiles files, got $num_ls " \
1197 "($num_uniq unique $num_all .&..)"
1199 # LU-5 large readdir
1200 # dirent_size = 32 bytes for sizeof(struct lu_dirent) +
1201 # N bytes for name (len($nrfiles) rounded to 8 bytes) +
1202 # 8 bytes for luda_type (4 bytes rounded to 8 bytes)
1203 # take into account of overhead in lu_dirpage header and end mark in
1204 # each page, plus one in rpc_num calculation.
1205 local dirent_size=$((32 + (${#tfile} | 7) + 1 + 8))
1206 local page_entries=$(((PAGE_SIZE - 24) / dirent_size))
1207 local mdt_idx=$($LFS getdirstripe -i $(dirname $fname))
1208 local rpc_pages=$(max_pages_per_rpc $mdt_idx)
1209 local rpc_max=$((nrfiles / (page_entries * rpc_pages) + stripes))
1210 local mds_readpage=$(calc_stats mdc.*.stats mds_readpage)
1211 echo "readpages: $mds_readpage rpc_max: $rpc_max"
1212 (( $mds_readpage < $rpc_max - 2 || $mds_readpage > $rpc_max + 1)) &&
1213 error "large readdir doesn't take effect: " \
1214 "$mds_readpage should be about $rpc_max"
1216 simple_cleanup_common
1218 run_test 24v "list large directory (test hash collision, b=17560)"
1220 test_24w() { # bug21506
1222 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=4096 || return 1
1223 dd if=/dev/zero bs=$SZ1 count=1 >> $DIR/$tfile || return 2
1224 dd if=$DIR/$tfile of=$DIR/${tfile}_left bs=1M skip=4097 || return 3
1225 SZ2=`ls -l $DIR/${tfile}_left | awk '{print $5}'`
1226 [[ "$SZ1" -eq "$SZ2" ]] ||
1227 error "Error reading at the end of the file $tfile"
1229 run_test 24w "Reading a file larger than 4Gb"
1232 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
1233 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1234 [[ $MDS1_VERSION -lt $(version_code 2.7.56) ]] &&
1235 skip "Need MDS version at least 2.7.56"
1238 local remote_dir=$DIR/$tdir/remote_dir
1240 test_mkdir $DIR/$tdir
1241 $LFS mkdir -i $MDTIDX $remote_dir ||
1242 error "create remote directory failed"
1244 test_mkdir $DIR/$tdir/src_dir
1245 touch $DIR/$tdir/src_file
1246 test_mkdir $remote_dir/tgt_dir
1247 touch $remote_dir/tgt_file
1249 mrename $DIR/$tdir/src_dir $remote_dir/tgt_dir ||
1250 error "rename dir cross MDT failed!"
1252 mrename $DIR/$tdir/src_file $remote_dir/tgt_file ||
1253 error "rename file cross MDT failed!"
1255 touch $DIR/$tdir/ln_file
1256 ln $DIR/$tdir/ln_file $remote_dir/ln_name ||
1257 error "ln file cross MDT failed"
1259 rm -rf $DIR/$tdir || error "Can not delete directories"
1261 run_test 24x "cross MDT rename/link"
1264 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
1265 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1267 local remote_dir=$DIR/$tdir/remote_dir
1270 test_mkdir $DIR/$tdir
1271 $LFS mkdir -i $mdtidx $remote_dir ||
1272 error "create remote directory failed"
1274 test_mkdir $remote_dir/src_dir
1275 touch $remote_dir/src_file
1276 test_mkdir $remote_dir/tgt_dir
1277 touch $remote_dir/tgt_file
1279 mrename $remote_dir/src_dir $remote_dir/tgt_dir ||
1280 error "rename subdir in the same remote dir failed!"
1282 mrename $remote_dir/src_file $remote_dir/tgt_file ||
1283 error "rename files in the same remote dir failed!"
1285 ln $remote_dir/tgt_file $remote_dir/tgt_file1 ||
1286 error "link files in the same remote dir failed!"
1288 rm -rf $DIR/$tdir || error "Can not delete directories"
1290 run_test 24y "rename/link on the same dir should succeed"
1293 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
1294 [[ $MDS1_VERSION -lt $(version_code 2.12.51) ]] &&
1295 skip "Need MDS version at least 2.12.51"
1299 for index in 0 1; do
1300 $LFS mkdir -i $index $DIR/$tdir.$index || error "mkdir failed"
1301 touch $DIR/$tdir.0/$tfile.$index || error "touch failed"
1304 mv $DIR/$tdir.0/$tfile.0 $DIR/$tdir.1 || error "mv $tfile.0 failed"
1306 index=$($LFS getstripe -m $DIR/$tdir.1/$tfile.0)
1307 [ $index -eq 0 ] || error "$tfile.0 is on MDT$index"
1309 local mdts=$(comma_list $(mdts_nodes))
1311 do_nodes $mdts $LCTL set_param mdt.*.enable_remote_rename=0
1312 stack_trap "do_nodes $mdts $LCTL \
1313 set_param mdt.*.enable_remote_rename=1" EXIT
1315 mv $DIR/$tdir.0/$tfile.1 $DIR/$tdir.1 || error "mv $tfile.1 failed"
1317 index=$($LFS getstripe -m $DIR/$tdir.1/$tfile.1)
1318 [ $index -eq 1 ] || error "$tfile.1 is on MDT$index"
1320 run_test 24z "cross-MDT rename is done as cp"
1322 test_24A() { # LU-3182
1326 test_mkdir $DIR/$tdir
1327 trap simple_cleanup_common EXIT
1328 createmany -m $DIR/$tdir/$tfile $NFILES
1329 local t=$(ls $DIR/$tdir | wc -l)
1330 local u=$(ls $DIR/$tdir | sort -u | wc -l)
1331 local v=$(ls -ai $DIR/$tdir | sort -u | wc -l)
1332 if [ $t -ne $NFILES ] || [ $u -ne $NFILES ] ||
1333 [ $v -ne $((NFILES + 2)) ] ; then
1334 error "Expected $NFILES files, got $t ($u unique $v .&..)"
1337 simple_cleanup_common || error "Can not delete directories"
1339 run_test 24A "readdir() returns correct number of entries."
1341 test_24B() { # LU-4805
1342 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
1346 test_mkdir $DIR/$tdir
1347 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR/$tdir/striped_dir ||
1348 error "create striped dir failed"
1350 count=$(ls -ai $DIR/$tdir/striped_dir | wc -l)
1351 [ $count -eq 2 ] || error "Expected 2, got $count"
1353 touch $DIR/$tdir/striped_dir/a
1355 count=$(ls -ai $DIR/$tdir/striped_dir | wc -l)
1356 [ $count -eq 3 ] || error "Expected 3, got $count"
1358 touch $DIR/$tdir/striped_dir/.f
1360 count=$(ls -ai $DIR/$tdir/striped_dir | wc -l)
1361 [ $count -eq 4 ] || error "Expected 4, got $count"
1363 rm -rf $DIR/$tdir || error "Can not delete directories"
1365 run_test 24B "readdir for striped dir return correct number of entries"
1368 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
1374 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR/$tdir/d0/striped_dir ||
1375 error "create striped dir failed"
1377 cd $DIR/$tdir/d0/striped_dir
1379 local d0_ino=$(ls -i -l -a $DIR/$tdir | grep "d0" | awk '{print $1}')
1380 local d1_ino=$(ls -i -l -a $DIR/$tdir | grep "d1" | awk '{print $1}')
1381 local parent_ino=$(ls -i -l -a | grep "\.\." | awk '{print $1}')
1383 [ "$d0_ino" = "$parent_ino" ] ||
1384 error ".. wrong, expect $d0_ino, get $parent_ino"
1386 mv $DIR/$tdir/d0/striped_dir $DIR/$tdir/d1/ ||
1387 error "mv striped dir failed"
1389 parent_ino=$(ls -i -l -a | grep "\.\." | awk '{print $1}')
1391 [ "$d1_ino" = "$parent_ino" ] ||
1392 error ".. wrong after mv, expect $d1_ino, get $parent_ino"
1394 run_test 24C "check .. in striped dir"
1397 [[ $MDSCOUNT -lt 4 ]] && skip_env "needs >= 4 MDTs"
1398 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1401 mkdir $DIR/$tdir/src_dir
1402 $LFS mkdir -i 1 $DIR/$tdir/src_dir/src_child ||
1403 error "create remote source failed"
1405 touch $DIR/$tdir/src_dir/src_child/a
1407 $LFS mkdir -i 2 $DIR/$tdir/tgt_dir ||
1408 error "create remote target dir failed"
1410 $LFS mkdir -i 3 $DIR/$tdir/tgt_dir/tgt_child ||
1411 error "create remote target child failed"
1413 mrename $DIR/$tdir/src_dir/src_child $DIR/$tdir/tgt_dir/tgt_child ||
1414 error "rename dir cross MDT failed!"
1418 $CHECKSTAT -t dir $DIR/$tdir/src_dir/src_child &&
1419 error "src_child still exists after rename"
1421 $CHECKSTAT -t file $DIR/$tdir/tgt_dir/tgt_child/a ||
1422 error "missing file(a) after rename"
1424 rm -rf $DIR/$tdir || error "Can not delete directories"
1426 run_test 24E "cross MDT rename/link"
1429 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
1432 [ "$SLOW" = "no" ] && repeats=100
1436 echo "$repeats repeats"
1437 for ((i = 0; i < repeats; i++)); do
1438 $LFS mkdir -i0 -c2 $DIR/$tdir/test || error "mkdir fails"
1439 touch $DIR/$tdir/test/a || error "touch fails"
1440 mkdir $DIR/$tdir/test/b || error "mkdir fails"
1441 rm -rf $DIR/$tdir/test || error "rmdir fails"
1446 run_test 24F "hash order vs readdir (LU-11330)"
1449 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
1454 $LFS mkdir -i 0 $DIR/$tdir-0 || error "mkdir $tdir-0"
1455 $LFS mkdir -i 1 $DIR/$tdir-1 || error "mkdir $tdir-1"
1456 touch $DIR/$tdir-0/f1 || error "touch f1"
1457 ln -s $DIR/$tdir-0/f1 $DIR/$tdir-0/s1 || error "ln s1"
1458 ino1=$(stat -c%i $DIR/$tdir-0/s1)
1459 mv $DIR/$tdir-0/s1 $DIR/$tdir-1 || error "mv s1"
1460 ino2=$(stat -c%i $DIR/$tdir-1/s1)
1461 [ $ino1 -ne $ino2 ] || error "s1 should be migrated"
1463 run_test 24G "migrate symlink in rename"
1466 echo '== symlink sanity ============================================='
1470 touch $DIR/s25/foo ||
1471 error "File creation in symlinked directory failed"
1473 run_test 25a "create file in symlinked directory ==============="
1476 [ ! -d $DIR/d25 ] && test_25a
1477 $CHECKSTAT -t file $DIR/s25/foo || error "$DIR/s25/foo not file type"
1479 run_test 25b "lookup file in symlinked directory ==============="
1483 test_mkdir $DIR/d26/d26-2
1484 ln -s d26/d26-2 $DIR/s26
1485 touch $DIR/s26/foo || error "File creation failed"
1487 run_test 26a "multiple component symlink ======================="
1490 test_mkdir -p $DIR/$tdir/d26-2
1491 ln -s $tdir/d26-2/foo $DIR/s26-2
1492 touch $DIR/s26-2 || error "File creation failed"
1494 run_test 26b "multiple component symlink at end of lookup ======"
1497 test_mkdir $DIR/d26.2
1498 touch $DIR/d26.2/foo
1499 ln -s d26.2 $DIR/s26.2-1
1500 ln -s s26.2-1 $DIR/s26.2-2
1501 ln -s s26.2-2 $DIR/s26.2-3
1502 chmod 0666 $DIR/s26.2-3/foo
1504 run_test 26c "chain of symlinks"
1506 # recursive symlinks (bug 439)
1508 ln -s d26-3/foo $DIR/d26-3
1510 run_test 26d "create multiple component recursive symlink"
1513 [ ! -h $DIR/d26-3 ] && test_26d
1516 run_test 26e "unlink multiple component recursive symlink"
1518 # recursive symlinks (bug 7022)
1520 test_mkdir $DIR/$tdir
1521 test_mkdir $DIR/$tdir/$tfile
1522 cd $DIR/$tdir/$tfile || error "cd $DIR/$tdir/$tfile failed"
1523 test_mkdir -p lndir/bar1
1524 test_mkdir $DIR/$tdir/$tfile/$tfile
1525 cd $tfile || error "cd $tfile failed"
1526 ln -s .. dotdot || error "ln dotdot failed"
1527 ln -s dotdot/lndir lndir || error "ln lndir failed"
1528 cd $DIR/$tdir || error "cd $DIR/$tdir failed"
1529 output=`ls $tfile/$tfile/lndir/bar1`
1530 [ "$output" = bar1 ] && error "unexpected output"
1531 rm -r $tfile || error "rm $tfile failed"
1532 $CHECKSTAT -a $DIR/$tfile || error "$tfile not gone"
1534 run_test 26f "rm -r of a directory which has recursive symlink"
1537 test_mkdir $DIR/$tdir
1538 $LFS getstripe $DIR/$tdir
1539 $LFS setstripe -c 1 $DIR/$tdir/$tfile || error "setstripe failed"
1540 $CHECKSTAT -t file $DIR/$tdir/$tfile || error "checkstat failed"
1541 cp /etc/hosts $DIR/$tdir/$tfile || error "Can't copy to one stripe file"
1543 run_test 27a "one stripe file"
1546 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
1548 test_mkdir $DIR/$tdir
1549 $LFS setstripe -c 2 $DIR/$tdir/$tfile || error "setstripe failed"
1550 $LFS getstripe -c $DIR/$tdir/$tfile
1551 [ $($LFS getstripe -c $DIR/$tdir/$tfile) -eq 2 ] ||
1552 error "two-stripe file doesn't have two stripes"
1554 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=4k count=4 || error "dd failed"
1556 run_test 27b "create and write to two stripe file"
1558 # 27c family tests specific striping, setstripe -o
1560 [[ $OSTCOUNT -lt 2 ]] && skip_env "skipping 2-stripe test"
1561 test_mkdir -p $DIR/$tdir
1564 $LFS setstripe -o $osts $DIR/$tdir/$tfile || error "setstripe failed"
1565 $LFS getstripe -i $DIR/$tdir/$tfile
1566 [ $($LFS getstripe -i $DIR/$tdir/$tfile ) -eq $osts ] ||
1567 error "stripe not on specified OST"
1569 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=4 || error "dd failed"
1571 run_test 27ca "one stripe on specified OST"
1574 [[ $OSTCOUNT -lt 2 ]] && skip_env "skipping 2-stripe test"
1575 test_mkdir -p $DIR/$tdir
1577 $LFS setstripe -o $osts $DIR/$tdir/$tfile || error "setstripe failed"
1578 local getstripe=$($LFS getstripe $DIR/$tdir/$tfile)
1581 # Strip getstripe output to a space separated list of OSTs
1582 local getstripe_osts=$(echo "$getstripe" | sed -e '1,/obdidx/d' |\
1583 awk '{print $1}' | tr '\n' '\ ' | sed -e 's/[[:space:]]*$//')
1584 [ "$getstripe_osts" = "${osts//,/ }" ] ||
1585 error "stripes not on specified OSTs"
1587 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=4 || error "dd failed"
1589 run_test 27cb "two stripes on specified OSTs"
1592 [[ $OSTCOUNT -lt 2 ]] && skip_env "skipping 2-stripe test"
1593 [[ $($LCTL get_param mdc.*.import) =~ connect_flags.*overstriping ]] ||
1594 skip "server does not support overstriping"
1596 test_mkdir -p $DIR/$tdir
1598 $LFS setstripe -o $osts $DIR/$tdir/$tfile || error "setstripe failed"
1599 local getstripe=$($LFS getstripe $DIR/$tdir/$tfile)
1602 # Strip getstripe output to a space separated list of OSTs
1603 local getstripe_osts=$(echo "$getstripe" | sed -e '1,/obdidx/d' |\
1604 awk '{print $1}' | tr '\n' '\ ' | sed -e 's/[[:space:]]*$//')
1605 [ "$getstripe_osts" = "${osts//,/ }" ] ||
1606 error "stripes not on specified OSTs"
1608 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=4 || error "dd failed"
1610 run_test 27cc "two stripes on the same OST"
1613 [[ $OSTCOUNT -lt 2 ]] && skip_env "skipping 2-stripe test"
1614 [[ $($LCTL get_param mdc.*.import) =~ connect_flags.*overstriping ]] ||
1615 skip "server does not support overstriping"
1616 test_mkdir -p $DIR/$tdir
1617 local osts="0,1,1,0"
1618 $LFS setstripe -o $osts $DIR/$tdir/$tfile || error "setstripe failed"
1619 local getstripe=$($LFS getstripe $DIR/$tdir/$tfile)
1622 # Strip getstripe output to a space separated list of OSTs
1623 local getstripe_osts=$(echo "$getstripe" | sed -e '1,/obdidx/d' |\
1624 awk '{print $1}' | tr '\n' '\ ' | sed -e 's/[[:space:]]*$//')
1625 [ "$getstripe_osts" = "${osts//,/ }" ] ||
1626 error "stripes not on specified OSTs"
1628 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=4 || error "dd failed"
1630 run_test 27cd "four stripes on two OSTs"
1633 [[ $OSTCOUNT -ge $(($LOV_MAX_STRIPE_COUNT / 2)) ]] &&
1634 skip_env "too many osts, skipping"
1635 [[ $($LCTL get_param mdc.*.import) =~ connect_flags.*overstriping ]] ||
1636 skip "server does not support overstriping"
1637 # We do one more stripe than we have OSTs
1638 [ $OSTCOUNT -ge 159 ] || large_xattr_enabled ||
1639 skip_env "ea_inode feature disabled"
1641 test_mkdir -p $DIR/$tdir
1643 for i in $(seq 0 $OSTCOUNT);
1646 if [ $i -ne $OSTCOUNT ]; then
1650 $LFS setstripe -o $osts $DIR/$tdir/$tfile || error "setstripe failed"
1651 local getstripe=$($LFS getstripe $DIR/$tdir/$tfile)
1654 # Strip getstripe output to a space separated list of OSTs
1655 local getstripe_osts=$(echo "$getstripe" | sed -e '1,/obdidx/d' |\
1656 awk '{print $1}' | tr '\n' '\ ' | sed -e 's/[[:space:]]*$//')
1657 [ "$getstripe_osts" = "${osts//,/ }" ] ||
1658 error "stripes not on specified OSTs"
1660 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=4 || error "dd failed"
1662 run_test 27ce "more stripes than OSTs with -o"
1665 local osp_proc="osp.$FSNAME-OST0000-osc-MDT000*.active"
1668 test_mkdir -p $DIR/$tdir || error "failed to mkdir $DIR/$tdir"
1669 do_facet $SINGLEMDS "$LCTL set_param -n $osp_proc=0"
1670 stack_trap "do_facet $SINGLEMDS $LCTL set_param -n $osp_proc=1" EXIT
1671 wait_update_facet $SINGLEMDS "$LCTL get_param -n $osp_proc | grep 1" ||
1672 error "failed to set $osp_proc=0"
1674 $LFS setstripe -o 0 $DIR/$tdir/$tfile &
1677 do_facet $SINGLEMDS "$LCTL set_param -n $osp_proc=1"
1678 wait_update_facet $SINGLEMDS "$LCTL get_param -n $osp_proc | grep 0" ||
1679 error "failed to set $osp_proc=1"
1682 error "should return error due to $osp_proc=0"
1684 run_test 27cf "'setstripe -o' on inactive OSTs should return error"
1687 test_mkdir $DIR/$tdir
1688 $LFS setstripe -c 0 -i -1 -S 0 $DIR/$tdir/$tfile ||
1689 error "setstripe failed"
1690 $CHECKSTAT -t file $DIR/$tdir/$tfile || error "checkstat failed"
1691 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=4k count=4 || error "dd failed"
1693 run_test 27d "create file with default settings"
1696 # LU-5839 adds check for existed layout before setting it
1697 [[ $MDS1_VERSION -lt $(version_code 2.7.56) ]] &&
1698 skip "Need MDS version at least 2.7.56"
1700 test_mkdir $DIR/$tdir
1701 $LFS setstripe -c 2 $DIR/$tdir/$tfile || error "setstripe failed"
1702 $LFS setstripe -c 2 $DIR/$tdir/$tfile && error "setstripe worked twice"
1703 $CHECKSTAT -t file $DIR/$tdir/$tfile || error "checkstat failed"
1705 run_test 27e "setstripe existing file (should return error)"
1708 test_mkdir $DIR/$tdir
1709 $LFS setstripe -S 100 -i 0 -c 1 $DIR/$tdir/$tfile &&
1710 error "$LFS setstripe $DIR/$tdir/$tfile failed"
1711 $CHECKSTAT -t file $DIR/$tdir/$tfile &&
1712 error "$CHECKSTAT -t file $DIR/$tdir/$tfile should fail"
1713 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=4k count=4 || error "dd failed"
1714 $LFS getstripe $DIR/$tdir/$tfile || error "$LFS getstripe failed"
1716 run_test 27f "setstripe with bad stripe size (should return error)"
1719 test_mkdir $DIR/$tdir
1720 $MCREATE $DIR/$tdir/$tfile || error "mcreate failed"
1721 $LFS getstripe $DIR/$tdir/$tfile 2>&1 | grep "no stripe info" ||
1722 error "$DIR/$tdir/$tfile has object"
1724 run_test 27g "$LFS getstripe with no objects"
1727 test_mkdir $DIR/$tdir
1728 touch $DIR/$tdir/$tfile || error "touch failed"
1729 ln -s bogus $DIR/$tdir/$tfile.2 || error "ln failed"
1730 $LFS getstripe -m $DIR/$tdir/$tfile $DIR/$tdir/$tfile.2
1732 (( rc == 2 )) || error "getstripe did not return ENOENT"
1734 run_test 27ga "$LFS getstripe with missing file (should return error)"
1737 test_mkdir $DIR/$tdir
1738 touch $DIR/$tdir/$tfile || error "touch failed"
1739 [[ $($LFS getstripe -c $DIR/$tdir/$tfile) -gt 0 ]] ||
1740 error "missing objects"
1742 run_test 27i "$LFS getstripe with some objects"
1745 test_mkdir $DIR/$tdir
1746 $LFS setstripe -i $OSTCOUNT $DIR/$tdir/$tfile &&
1747 error "setstripe failed" || true
1749 run_test 27j "setstripe with bad stripe offset (should return error)"
1751 test_27k() { # bug 2844
1752 test_mkdir $DIR/$tdir
1753 local file=$DIR/$tdir/$tfile
1754 local ll_max_blksize=$((4 * 1024 * 1024))
1755 $LFS setstripe -S 67108864 $file || error "setstripe failed"
1756 local blksize=$(stat $file | awk '/IO Block:/ { print $7 }')
1757 [ $blksize -le $ll_max_blksize ] || error "1:$blksize > $ll_max_blksize"
1758 dd if=/dev/zero of=$file bs=4k count=1
1759 blksize=$(stat $file | awk '/IO Block:/ { print $7 }')
1760 [ $blksize -le $ll_max_blksize ] || error "2:$blksize > $ll_max_blksize"
1762 run_test 27k "limit i_blksize for broken user apps"
1765 mcreate $DIR/$tfile || error "creating file"
1766 $RUNAS $LFS setstripe -c 1 $DIR/$tfile &&
1767 error "setstripe should have failed" || true
1769 run_test 27l "check setstripe permissions (should return error)"
1772 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
1774 [ -n "$RCLIENTS" -o -n "$MOUNT_2" ] &&
1775 skip_env "multiple clients -- skipping"
1777 ORIGFREE=$($LCTL get_param -n lov.$FSNAME-clilov-*.kbytesavail |
1779 if [[ $ORIGFREE -gt $MAXFREE ]]; then
1780 skip "$ORIGFREE > $MAXFREE skipping out-of-space test on OST0"
1782 trap simple_cleanup_common EXIT
1783 test_mkdir $DIR/$tdir
1784 $LFS setstripe -i 0 -c 1 $DIR/$tdir/$tfile.1
1785 dd if=/dev/zero of=$DIR/$tdir/$tfile.1 bs=1024 count=$MAXFREE &&
1786 error "dd should fill OST0"
1788 while $LFS setstripe -i 0 -c 1 $DIR/$tdir/$tfile.$i; do
1790 [ $i -gt 256 ] && break
1793 touch $DIR/$tdir/$tfile.$i
1794 [ $($LFS getstripe $DIR/$tdir/$tfile.$i | grep -A 10 obdidx |
1795 awk '{print $1}'| grep -w "0") ] &&
1796 error "OST0 was full but new created file still use it"
1798 touch $DIR/$tdir/$tfile.$i
1799 [ $($LFS getstripe $DIR/$tdir/$tfile.$i | grep -A 10 obdidx |
1800 awk '{print $1}'| grep -w "0") ] &&
1801 error "OST0 was full but new created file still use it"
1802 simple_cleanup_common
1804 run_test 27m "create file while OST0 was full"
1806 # OSCs keep a NOSPC flag that will be reset after ~5s (qos_maxage)
1807 # if the OST isn't full anymore.
1809 local ostidx=${1:-""}
1814 local list=$(comma_list $(osts_nodes))
1815 [ "$ostidx" ] && list=$(facet_host ost$((ostidx + 1)))
1817 do_nodes $list lctl set_param fail_loc=0
1818 wait_delete_completed # initiate all OST_DESTROYs from MDS to OST
1819 delay=$(do_facet $SINGLEMDS lctl get_param -n lov.*.qos_maxage |
1820 awk '{print $1 * 2;exit;}')
1821 get_prealloc="$LCTL get_param -n osc.*MDT*.prealloc_status |
1823 wait_update_facet $SINGLEMDS "$get_prealloc" "" $delay
1826 __exhaust_precreations() {
1829 local FAILIDX=${3:-$OSTIDX}
1830 local ofacet=ost$((OSTIDX + 1))
1832 test_mkdir -p -c1 $DIR/$tdir
1833 local mdtidx=$($LFS getstripe -m $DIR/$tdir)
1834 local mfacet=mds$((mdtidx + 1))
1835 echo OSTIDX=$OSTIDX MDTIDX=$mdtidx
1837 local OST=$(ostname_from_index $OSTIDX)
1840 local mdtosc_proc1=$(get_mdtosc_proc_path $mfacet $OST)
1841 local last_id=$(do_facet $mfacet lctl get_param -n \
1842 osp.$mdtosc_proc1.prealloc_last_id)
1843 local next_id=$(do_facet $mfacet lctl get_param -n \
1844 osp.$mdtosc_proc1.prealloc_next_id)
1846 local mdtosc_proc2=$(get_mdtosc_proc_path $mfacet)
1847 do_facet $mfacet lctl get_param osp.$mdtosc_proc2.prealloc*
1849 test_mkdir -p $DIR/$tdir/${OST}
1850 $LFS setstripe -i $OSTIDX -c 1 $DIR/$tdir/${OST}
1851 #define OBD_FAIL_OST_ENOSPC 0x215
1852 do_facet $ofacet lctl set_param fail_val=$FAILIDX fail_loc=0x215
1853 echo "Creating to objid $last_id on ost $OST..."
1854 createmany -o $DIR/$tdir/${OST}/f $next_id $((last_id - next_id + 2))
1855 do_facet $mfacet lctl get_param osp.$mdtosc_proc2.prealloc*
1856 do_facet $ofacet lctl set_param fail_loc=$FAILLOC
1859 exhaust_precreations() {
1860 __exhaust_precreations $1 $2 $3
1864 exhaust_all_precreations() {
1866 for (( i=0; i < OSTCOUNT; i++ )) ; do
1867 __exhaust_precreations $i $1 -1
1873 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
1874 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1875 remote_mds_nodsh && skip "remote MDS with nodsh"
1876 remote_ost_nodsh && skip "remote OST with nodsh"
1879 rm -f $DIR/$tdir/$tfile
1880 exhaust_precreations 0 0x80000215
1881 $LFS setstripe -c -1 $DIR/$tdir || error "setstripe failed"
1882 touch $DIR/$tdir/$tfile || error "touch failed"
1883 $LFS getstripe $DIR/$tdir/$tfile
1886 run_test 27n "create file with some full OSTs"
1889 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
1890 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1891 remote_mds_nodsh && skip "remote MDS with nodsh"
1892 remote_ost_nodsh && skip "remote OST with nodsh"
1895 rm -f $DIR/$tdir/$tfile
1896 exhaust_all_precreations 0x215
1898 touch $DIR/$tdir/$tfile && error "able to create $DIR/$tdir/$tfile"
1903 run_test 27o "create file with all full OSTs (should error)"
1906 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
1907 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1908 remote_mds_nodsh && skip "remote MDS with nodsh"
1909 remote_ost_nodsh && skip "remote OST with nodsh"
1912 rm -f $DIR/$tdir/$tfile
1913 test_mkdir $DIR/$tdir
1915 $MCREATE $DIR/$tdir/$tfile || error "mcreate failed"
1916 $TRUNCATE $DIR/$tdir/$tfile 80000000 || error "truncate failed"
1917 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat failed"
1919 exhaust_precreations 0 0x80000215
1920 echo foo >> $DIR/$tdir/$tfile || error "append failed"
1921 $CHECKSTAT -s 80000004 $DIR/$tdir/$tfile || error "checkstat failed"
1922 $LFS getstripe $DIR/$tdir/$tfile
1926 run_test 27p "append to a truncated file with some full OSTs"
1929 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
1930 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1931 remote_mds_nodsh && skip "remote MDS with nodsh"
1932 remote_ost_nodsh && skip "remote OST with nodsh"
1935 rm -f $DIR/$tdir/$tfile
1937 test_mkdir $DIR/$tdir
1938 $MCREATE $DIR/$tdir/$tfile || error "mcreate $DIR/$tdir/$tfile failed"
1939 $TRUNCATE $DIR/$tdir/$tfile 80000000 ||
1940 error "truncate $DIR/$tdir/$tfile failed"
1941 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat failed"
1943 exhaust_all_precreations 0x215
1945 echo foo >> $DIR/$tdir/$tfile && error "append succeeded"
1946 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat 2 failed"
1950 run_test 27q "append to truncated file with all OSTs full (should error)"
1953 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
1954 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1955 remote_mds_nodsh && skip "remote MDS with nodsh"
1956 remote_ost_nodsh && skip "remote OST with nodsh"
1959 rm -f $DIR/$tdir/$tfile
1960 exhaust_precreations 0 0x80000215
1962 $LFS setstripe -i 0 -c 2 $DIR/$tdir/$tfile || error "setstripe failed"
1966 run_test 27r "stripe file with some full OSTs (shouldn't LBUG) ="
1968 test_27s() { # bug 10725
1969 test_mkdir $DIR/$tdir
1970 local stripe_size=$((4096 * 1024 * 1024)) # 2^32
1971 local stripe_count=0
1972 [ $OSTCOUNT -eq 1 ] || stripe_count=2
1973 $LFS setstripe -S $stripe_size -c $stripe_count $DIR/$tdir &&
1974 error "stripe width >= 2^32 succeeded" || true
1977 run_test 27s "lsm_xfersize overflow (should error) (bug 10725)"
1979 test_27t() { # bug 10864
1984 $WLFS getstripe $tfile
1987 run_test 27t "check that utils parse path correctly"
1989 test_27u() { # bug 4900
1990 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
1991 remote_mds_nodsh && skip "remote MDS with nodsh"
1994 local list=$(comma_list $(mdts_nodes))
1996 #define OBD_FAIL_MDS_OSC_PRECREATE 0x139
1997 do_nodes $list $LCTL set_param fail_loc=0x139
1998 test_mkdir -p $DIR/$tdir
1999 trap simple_cleanup_common EXIT
2000 createmany -o $DIR/$tdir/t- 1000
2001 do_nodes $list $LCTL set_param fail_loc=0
2003 TLOG=$TMP/$tfile.getstripe
2004 $LFS getstripe $DIR/$tdir > $TLOG
2005 OBJS=$(awk -vobj=0 '($1 == 0) { obj += 1 } END { print obj; }' $TLOG)
2006 unlinkmany $DIR/$tdir/t- 1000
2008 [[ $OBJS -gt 0 ]] &&
2009 error "$OBJS objects created on OST-0. See $TLOG" ||
2012 run_test 27u "skip object creation on OSC w/o objects"
2014 test_27v() { # bug 4900
2015 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
2016 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2017 remote_mds_nodsh && skip "remote MDS with nodsh"
2018 remote_ost_nodsh && skip "remote OST with nodsh"
2020 exhaust_all_precreations 0x215
2023 $LFS setstripe -c 1 $DIR/$tdir # 1 stripe / file
2025 touch $DIR/$tdir/$tfile
2026 #define OBD_FAIL_TGT_DELAY_PRECREATE 0x705
2028 for (( i=1; i < OSTCOUNT; i++ )); do
2029 do_facet ost$i lctl set_param fail_loc=0x705
2031 local START=`date +%s`
2032 createmany -o $DIR/$tdir/$tfile 32
2034 local FINISH=`date +%s`
2035 local TIMEOUT=`lctl get_param -n timeout`
2036 local PROCESS=$((FINISH - START))
2037 [ $PROCESS -ge $((TIMEOUT / 2)) ] && \
2038 error "$FINISH - $START >= $TIMEOUT / 2"
2039 sleep $((TIMEOUT / 2 - PROCESS))
2042 run_test 27v "skip object creation on slow OST"
2044 test_27w() { # bug 10997
2045 test_mkdir $DIR/$tdir
2046 $LFS setstripe -S 65536 $DIR/$tdir/f0 || error "setstripe failed"
2047 [ $($LFS getstripe -S $DIR/$tdir/f0) -ne 65536 ] &&
2048 error "stripe size $size != 65536" || true
2049 [ $($LFS getstripe -d $DIR/$tdir | grep -c "stripe_count") -eq 0 ] &&
2050 error "$LFS getstripe -d $DIR/$tdir no 'stripe_count'" || true
2052 run_test 27w "check $LFS setstripe -S and getstrip -d options"
2055 [[ $OSTCOUNT -lt 2 ]] &&
2056 skip_env "skipping multiple stripe count/offset test"
2058 test_mkdir $DIR/$tdir
2059 for i in $(seq 1 $OSTCOUNT); do
2061 $LFS setstripe -c $i -i $offset $DIR/$tdir/f$i ||
2062 error "setstripe -c $i -i $offset failed"
2063 count=$($LFS getstripe -c $DIR/$tdir/f$i)
2064 index=$($LFS getstripe -i $DIR/$tdir/f$i)
2065 [ $count -ne $i ] && error "stripe count $count != $i" || true
2066 [ $index -ne $offset ] &&
2067 error "stripe offset $index != $offset" || true
2070 run_test 27wa "check $LFS setstripe -c -i options"
2073 remote_ost_nodsh && skip "remote OST with nodsh"
2074 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
2075 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2077 OFFSET=$(($OSTCOUNT - 1))
2079 local OST=$(ostname_from_index $OSTIDX)
2081 test_mkdir $DIR/$tdir
2082 $LFS setstripe -c 1 $DIR/$tdir # 1 stripe per file
2083 do_facet ost$((OSTIDX + 1)) lctl set_param -n obdfilter.$OST.degraded 1
2085 createmany -o $DIR/$tdir/$tfile $OSTCOUNT
2086 for i in $(seq 0 $OFFSET); do
2087 [ $($LFS getstripe $DIR/$tdir/$tfile$i | grep -A 10 obdidx |
2088 awk '{print $1}' | grep -w "$OSTIDX") ] &&
2089 error "OST0 was degraded but new created file still use it"
2091 do_facet ost$((OSTIDX + 1)) lctl set_param -n obdfilter.$OST.degraded 0
2093 run_test 27x "create files while OST0 is degraded"
2096 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
2097 remote_mds_nodsh && skip "remote MDS with nodsh"
2098 remote_ost_nodsh && skip "remote OST with nodsh"
2099 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2101 local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS $FSNAME-OST0000)
2102 local last_id=$(do_facet $SINGLEMDS lctl get_param -n \
2103 osp.$mdtosc.prealloc_last_id)
2104 local next_id=$(do_facet $SINGLEMDS lctl get_param -n \
2105 osp.$mdtosc.prealloc_next_id)
2106 local fcount=$((last_id - next_id))
2107 [[ $fcount -eq 0 ]] && skip "not enough space on OST0"
2108 [[ $fcount -gt $OSTCOUNT ]] && fcount=$OSTCOUNT
2110 local MDS_OSCS=$(do_facet $SINGLEMDS lctl dl |
2111 awk '/[oO][sS][cC].*md[ts]/ { print $4 }')
2112 local OST_DEACTIVE_IDX=-1
2117 for OSC in $MDS_OSCS; do
2118 OST=$(osc_to_ost $OSC)
2119 OSTIDX=$(index_from_ostuuid $OST)
2120 if [ $OST_DEACTIVE_IDX == -1 ]; then
2121 OST_DEACTIVE_IDX=$OSTIDX
2123 if [ $OSTIDX != $OST_DEACTIVE_IDX ]; then
2124 echo $OSC "is Deactivated:"
2125 do_facet $SINGLEMDS lctl --device %$OSC deactivate
2129 OSTIDX=$(index_from_ostuuid $OST)
2130 test_mkdir $DIR/$tdir
2131 $LFS setstripe -c 1 $DIR/$tdir # 1 stripe / file
2133 for OSC in $MDS_OSCS; do
2134 OST=$(osc_to_ost $OSC)
2135 OSTIDX=$(index_from_ostuuid $OST)
2136 if [ $OSTIDX == $OST_DEACTIVE_IDX ]; then
2137 echo $OST "is degraded:"
2138 do_facet ost$((OSTIDX+1)) lctl set_param -n \
2139 obdfilter.$OST.degraded=1
2144 createmany -o $DIR/$tdir/$tfile $fcount
2146 for OSC in $MDS_OSCS; do
2147 OST=$(osc_to_ost $OSC)
2148 OSTIDX=$(index_from_ostuuid $OST)
2149 if [ $OSTIDX == $OST_DEACTIVE_IDX ]; then
2150 echo $OST "is recovered from degraded:"
2151 do_facet ost$((OSTIDX+1)) lctl set_param -n \
2152 obdfilter.$OST.degraded=0
2154 do_facet $SINGLEMDS lctl --device %$OSC activate
2158 # all osp devices get activated, hence -1 stripe count restored
2159 local stripe_count=0
2161 # sleep 2*lod_qos_maxage seconds waiting for lod qos to notice osp
2162 # devices get activated.
2164 $LFS setstripe -c -1 $DIR/$tfile
2165 stripe_count=$($LFS getstripe -c $DIR/$tfile)
2167 [ $stripe_count -ne $OSTCOUNT ] &&
2168 error "Of $OSTCOUNT OSTs, only $stripe_count is available"
2171 run_test 27y "create files while OST0 is degraded and the rest inactive"
2177 lmm_count=$($LFS getstripe -c $1)
2178 lmm_seq=$($LFS getstripe -v $1 | awk '/lmm_seq/ { print $2 }')
2179 lmm_oid=$($LFS getstripe -v $1 | awk '/lmm_object_id/ { print $2 }')
2181 local old_ifs="$IFS"
2183 fid=($($LFS path2fid $1))
2186 log "FID seq ${fid[1]}, oid ${fid[2]} ver ${fid[3]}"
2187 log "LOV seq $lmm_seq, oid $lmm_oid, count: $lmm_count"
2189 # compare lmm_seq and lu_fid->f_seq
2190 [ $lmm_seq = ${fid[1]} ] || { error "SEQ mismatch"; return 1; }
2191 # compare lmm_object_id and lu_fid->oid
2192 [ $lmm_oid = ${fid[2]} ] || { error "OID mismatch"; return 2; }
2194 # check the trusted.fid attribute of the OST objects of the file
2195 local have_obdidx=false
2197 $LFS getstripe $1 | while read obdidx oid hex seq; do
2198 # skip lines up to and including "obdidx"
2199 [ -z "$obdidx" ] && break
2200 [ "$obdidx" = "obdidx" ] && have_obdidx=true && continue
2201 $have_obdidx || continue
2203 local ost=$((obdidx + 1))
2204 local dev=$(ostdevname $ost)
2207 log "want: stripe:$stripe_nr ost:$obdidx oid:$oid/$hex seq:$seq"
2209 seq=$(echo $seq | sed -e "s/^0x//g")
2210 if [ $seq == 0 ] || [ $(facet_fstype ost$ost) == zfs ]; then
2211 oid_hex=$(echo $oid)
2213 oid_hex=$(echo $hex | sed -e "s/^0x//g")
2215 local obj_file="O/$seq/d$((oid %32))/$oid_hex"
2219 # Don't unmount/remount the OSTs if we don't need to do that.
2220 # LU-2577 changes filter_fid to be smaller, so debugfs needs
2221 # update too, until that use mount/ll_decode_filter_fid/mount.
2222 # Re-enable when debugfs will understand new filter_fid.
2224 if [ $(facet_fstype ost$ost) == ldiskfs ]; then
2225 ff=$(do_facet ost$ost "$DEBUGFS -c -R 'stat $obj_file' \
2226 $dev 2>/dev/null" | grep "parent=")
2228 if [ -z "$ff" ]; then
2230 mount_fstype ost$ost
2231 ff=$(do_facet ost$ost $LL_DECODE_FILTER_FID \
2232 $(facet_mntpt ost$ost)/$obj_file)
2233 unmount_fstype ost$ost
2234 start ost$ost $dev $OST_MOUNT_OPTS
2238 [ -z "$ff" ] && error "$obj_file: no filter_fid info"
2240 echo "$ff" | sed -e 's#.*objid=#got: objid=#'
2242 # /mnt/O/0/d23/23: objid=23 seq=0 parent=[0x200000400:0x1e:0x1]
2243 # fid: objid=23 seq=0 parent=[0x200000400:0x1e:0x0] stripe=1
2245 # fid: parent=[0x200000400:0x1e:0x0] stripe=1 stripe_count=2 \
2246 # stripe_size=1048576 component_id=1 component_start=0 \
2247 # component_end=33554432
2248 local ff_parent=$(sed -e 's/.*parent=.//' <<<$ff)
2249 local ff_pseq=$(cut -d: -f1 <<<$ff_parent)
2250 local ff_poid=$(cut -d: -f2 <<<$ff_parent)
2252 if grep -q 'stripe=' <<<$ff; then
2253 ff_pstripe=$(sed -e 's/.*stripe=//' -e 's/ .*//' <<<$ff)
2255 # $LL_DECODE_FILTER_FID does not print "stripe="; look
2256 # into f_ver in this case. See comment on ff_parent.
2257 ff_pstripe=$(cut -d: -f3 <<<$ff_parent | sed -e 's/]//')
2260 # compare lmm_seq and filter_fid->ff_parent.f_seq
2261 [ $ff_pseq = $lmm_seq ] ||
2262 error "FF parent SEQ $ff_pseq != $lmm_seq"
2263 # compare lmm_object_id and filter_fid->ff_parent.f_oid
2264 [ $ff_poid = $lmm_oid ] ||
2265 error "FF parent OID $ff_poid != $lmm_oid"
2266 (($ff_pstripe == $stripe_nr)) ||
2267 error "FF stripe $ff_pstripe != $stripe_nr"
2269 stripe_nr=$((stripe_nr + 1))
2270 [ $CLIENT_VERSION -lt $(version_code 2.9.55) ] &&
2272 if grep -q 'stripe_count=' <<<$ff; then
2273 local ff_scnt=$(sed -e 's/.*stripe_count=//' \
2274 -e 's/ .*//' <<<$ff)
2275 [ $lmm_count = $ff_scnt ] ||
2276 error "FF stripe count $lmm_count != $ff_scnt"
2282 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2283 remote_ost_nodsh && skip "remote OST with nodsh"
2285 test_mkdir $DIR/$tdir
2286 $LFS setstripe -c 1 -i 0 -S 64k $DIR/$tdir/$tfile-1 ||
2287 { error "setstripe -c -1 failed"; return 1; }
2288 # We need to send a write to every object to get parent FID info set.
2289 # This _should_ also work for setattr, but does not currently.
2290 # touch $DIR/$tdir/$tfile-1 ||
2291 dd if=/dev/zero of=$DIR/$tdir/$tfile-1 bs=1M count=1 ||
2292 { error "dd $tfile-1 failed"; return 2; }
2293 $LFS setstripe -c -1 -i $((OSTCOUNT - 1)) -S 1M $DIR/$tdir/$tfile-2 ||
2294 { error "setstripe -c -1 failed"; return 3; }
2295 dd if=/dev/zero of=$DIR/$tdir/$tfile-2 bs=1M count=$OSTCOUNT ||
2296 { error "dd $tfile-2 failed"; return 4; }
2298 # make sure write RPCs have been sent to OSTs
2301 check_seq_oid $DIR/$tdir/$tfile-1 || return 5
2302 check_seq_oid $DIR/$tdir/$tfile-2 || return 6
2304 run_test 27z "check SEQ/OID on the MDT and OST filesystems"
2306 test_27A() { # b=19102
2307 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2309 save_layout_restore_at_exit $MOUNT
2310 $LFS setstripe -c 0 -i -1 -S 0 $MOUNT
2311 wait_update $HOSTNAME "$LFS getstripe -c $MOUNT | sed 's/ *//g'" "1" 20 ||
2312 error "stripe count $($LFS getstripe -c $MOUNT) != 1"
2313 local default_size=$($LFS getstripe -S $MOUNT)
2314 local default_offset=$($LFS getstripe -i $MOUNT)
2315 local dsize=$(do_facet $SINGLEMDS \
2316 "$LCTL get_param -n lod.$(facet_svc $SINGLEMDS)*.stripesize")
2317 [ $default_size -eq $dsize ] ||
2318 error "stripe size $default_size != $dsize"
2319 [ $default_offset -eq -1 ] ||
2320 error "stripe offset $default_offset != -1"
2322 run_test 27A "check filesystem-wide default LOV EA values"
2324 test_27B() { # LU-2523
2325 test_mkdir $DIR/$tdir
2326 rm -f $DIR/$tdir/f0 $DIR/$tdir/f1
2328 # open f1 with O_LOV_DELAY_CREATE
2330 # call setstripe ioctl on open file descriptor for f1
2332 multiop $DIR/$tdir/f1 oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:nB1c \
2336 # open f1 with O_LOV_DELAY_CREATE
2338 # call setstripe ioctl on open file descriptor for f1
2340 multiop $DIR/$tdir/f1 oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:uB1c
2342 # Allow multiop to fail in imitation of NFS's busted semantics.
2345 run_test 27B "call setstripe on open unlinked file/rename victim"
2347 # 27C family tests full striping and overstriping
2348 test_27Ca() { #LU-2871
2349 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
2357 test_mkdir $DIR/$tdir
2359 for i in $(seq 0 $((OSTCOUNT - 1))); do
2360 # set stripe across all OSTs starting from OST$i
2361 $LFS setstripe -i $i -c -1 $tfile$i
2362 # get striping information
2363 ost_idx=($($LFS getstripe $tfile$i |
2364 tail -n $((OSTCOUNT + 1)) | awk '{print $1}'))
2368 [ ${#ost_idx[@]} -eq $OSTCOUNT ] ||
2369 error "${#ost_idx[@]} != $OSTCOUNT"
2371 for index in $(seq 0 $((OSTCOUNT - 1))); do
2373 for j in $(echo ${ost_idx[@]}); do
2374 if [ $index -eq $j ]; then
2380 error "Can not find $index in ${ost_idx[@]}"
2384 run_test 27Ca "check full striping across all OSTs"
2387 [[ $($LCTL get_param mdc.*.import) =~ connect_flags.*overstriping ]] ||
2388 skip "server does not support overstriping"
2389 [[ $OSTCOUNT -ge $(($LOV_MAX_STRIPE_COUNT / 2)) ]] &&
2390 skip_env "too many osts, skipping"
2392 test_mkdir -p $DIR/$tdir
2393 local setcount=$(($OSTCOUNT * 2))
2394 [ $setcount -ge 160 ] || large_xattr_enabled ||
2395 skip_env "ea_inode feature disabled"
2397 $LFS setstripe -C $setcount $DIR/$tdir/$tfile ||
2398 error "setstripe failed"
2400 local count=$($LFS getstripe -c $DIR/$tdir/$tfile)
2401 [ $count -eq $setcount ] ||
2402 error "stripe count $count, should be $setcount"
2404 $LFS getstripe $DIR/$tdir/$tfile 2>&1 | grep "overstriped" ||
2405 error "overstriped should be set in pattern"
2407 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=4 conv=notrunc ||
2410 run_test 27Cb "more stripes than OSTs with -C"
2413 [[ $($LCTL get_param mdc.*.import) =~ connect_flags.*overstriping ]] ||
2414 skip "server does not support overstriping"
2415 [[ $OSTCOUNT -lt 2 ]] && skip_env "need > 1 OST"
2417 test_mkdir -p $DIR/$tdir
2418 local setcount=$(($OSTCOUNT - 1))
2420 [ $setcount -ge 160 ] || large_xattr_enabled ||
2421 skip_env "ea_inode feature disabled"
2423 $LFS setstripe -C $setcount $DIR/$tdir/$tfile ||
2424 error "setstripe failed"
2426 local count=$($LFS getstripe -c $DIR/$tdir/$tfile)
2427 [ $count -eq $setcount ] ||
2428 error "stripe count $count, should be $setcount"
2430 $LFS getstripe $DIR/$tdir/$tfile 2>&1 | grep "overstriped" &&
2431 error "overstriped should not be set in pattern"
2433 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=4 conv=notrunc ||
2436 run_test 27Cc "fewer stripes than OSTs does not set overstriping"
2439 [[ $($LCTL get_param mdc.*.import) =~ connect_flags.*overstriping ]] ||
2440 skip "server does not support overstriping"
2441 [[ $OSTCOUNT -lt 2 ]] && skip_env "need > 1 OST"
2442 large_xattr_enabled || skip_env "ea_inode feature disabled"
2444 test_mkdir -p $DIR/$tdir
2445 local setcount=$LOV_MAX_STRIPE_COUNT
2447 $LFS setstripe -C $setcount $DIR/$tdir/$tfile ||
2448 error "setstripe failed"
2450 local count=$($LFS getstripe -c $DIR/$tdir/$tfile)
2451 [ $count -eq $setcount ] ||
2452 error "stripe count $count, should be $setcount"
2454 $LFS getstripe $DIR/$tdir/$tfile 2>&1 | grep "overstriped" ||
2455 error "overstriped should be set in pattern"
2457 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=4 conv=notrunc ||
2460 rm -f $DIR/$tdir/$tfile || error "Delete $tfile failed"
2462 run_test 27Cd "test maximum stripe count"
2465 [[ $($LCTL get_param mdc.*.import) =~ connect_flags.*overstriping ]] ||
2466 skip "server does not support overstriping"
2467 test_mkdir -p $DIR/$tdir
2469 pool_add $TESTNAME || error "Pool creation failed"
2470 pool_add_targets $TESTNAME 0 || error "pool_add_targets failed"
2474 $LFS setstripe -C $setcount -p "$TESTNAME" $DIR/$tdir/$tfile ||
2475 error "setstripe failed"
2477 local count=$($LFS getstripe -c $DIR/$tdir/$tfile)
2478 [ $count -eq $setcount ] ||
2479 error "stripe count $count, should be $setcount"
2481 $LFS getstripe $DIR/$tdir/$tfile 2>&1 | grep "overstriped" ||
2482 error "overstriped should be set in pattern"
2484 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=4 conv=notrunc ||
2487 rm -f $DIR/$tdir/$tfile || error "Delete $tfile failed"
2489 run_test 27Ce "test pool with overstriping"
2492 [[ $($LCTL get_param mdc.*.import) =~ connect_flags.*overstriping ]] ||
2493 skip "server does not support overstriping"
2494 [[ $OSTCOUNT -ge $(($LOV_MAX_STRIPE_COUNT / 2)) ]] &&
2495 skip_env "too many osts, skipping"
2497 test_mkdir -p $DIR/$tdir
2499 local setcount=$(($OSTCOUNT * 2))
2500 [ $setcount -ge 160 ] || large_xattr_enabled ||
2501 skip_env "ea_inode feature disabled"
2503 $LFS setstripe -C $setcount $DIR/$tdir/ ||
2504 error "setstripe failed"
2506 echo 1 > $DIR/$tdir/$tfile
2508 local count=$($LFS getstripe -c $DIR/$tdir/$tfile)
2509 [ $count -eq $setcount ] ||
2510 error "stripe count $count, should be $setcount"
2512 $LFS getstripe $DIR/$tdir/$tfile 2>&1 | grep "overstriped" ||
2513 error "overstriped should be set in pattern"
2515 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=4 conv=notrunc ||
2518 rm -f $DIR/$tdir/$tfile || error "Delete $tfile failed"
2520 run_test 27Cf "test default inheritance with overstriping"
2523 [ $OSTCOUNT -lt 2 ] && skip_env "needs >= 2 OSTs"
2524 [ -n "$FILESET" ] && skip "SKIP due to FILESET set"
2525 remote_mds_nodsh && skip "remote MDS with nodsh"
2527 local POOL=${POOL:-testpool}
2529 local last_ost=$(($OSTCOUNT - 1))
2531 local ost_list=$(seq $first_ost $ost_step $last_ost)
2532 local ost_range="$first_ost $last_ost $ost_step"
2534 test_mkdir $DIR/$tdir
2535 pool_add $POOL || error "pool_add failed"
2536 pool_add_targets $POOL $ost_range || error "pool_add_targets failed"
2539 [ $MDS1_VERSION -lt $(version_code 2.8.55) ] &&
2541 [ $MDS1_VERSION -lt $(version_code 2.9.55) ] ||
2542 [ $CLIENT_VERSION -lt $(version_code 2.9.55) ] &&
2543 skip27D+=" -s 30,31"
2544 [[ ! $($LCTL get_param mdc.*.import) =~ connect_flags.*overstriping ||
2545 $OSTCOUNT -ge $(($LOV_MAX_STRIPE_COUNT / 2)) ]] &&
2546 skip27D+=" -s 32,33"
2547 [[ $MDS_VERSION -lt $(version_code $SEL_VER) ]] &&
2549 llapi_layout_test -d$DIR/$tdir -p$POOL -o$OSTCOUNT $skip27D ||
2550 error "llapi_layout_test failed"
2552 destroy_test_pools || error "destroy test pools failed"
2554 run_test 27D "validate llapi_layout API"
2556 # Verify that default_easize is increased from its initial value after
2557 # accessing a widely striped file.
2559 [ $OSTCOUNT -lt 2 ] && skip_env "needs >= 2 OSTs"
2560 [ $CLIENT_VERSION -lt $(version_code 2.5.57) ] &&
2561 skip "client does not have LU-3338 fix"
2563 # 72 bytes is the minimum space required to store striping
2564 # information for a file striped across one OST:
2565 # (sizeof(struct lov_user_md_v3) +
2566 # sizeof(struct lov_user_ost_data_v1))
2568 $LCTL set_param -n llite.*.default_easize $min_easize ||
2569 error "lctl set_param failed"
2570 local easize=$($LCTL get_param -n llite.*.default_easize)
2572 [ $easize -eq $min_easize ] ||
2573 error "failed to set default_easize"
2575 $LFS setstripe -c $OSTCOUNT $DIR/$tfile ||
2576 error "setstripe failed"
2577 # In order to ensure stat() call actually talks to MDS we need to
2578 # do something drastic to this file to shake off all lock, e.g.
2579 # rename it (kills lookup lock forcing cache cleaning)
2580 mv $DIR/$tfile $DIR/${tfile}-1
2581 ls -l $DIR/${tfile}-1
2584 easize=$($LCTL get_param -n llite.*.default_easize)
2586 [ $easize -gt $min_easize ] ||
2587 error "default_easize not updated"
2589 run_test 27E "check that default extended attribute size properly increases"
2591 test_27F() { # LU-5346/LU-7975
2592 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2593 [[ $OSTCOUNT -lt 2 ]] && skip "needs >= 2 OSTs"
2594 [[ $MDS1_VERSION -lt $(version_code 2.8.51) ]] &&
2595 skip "Need MDS version at least 2.8.51"
2596 remote_ost_nodsh && skip "remote OST with nodsh"
2598 test_mkdir $DIR/$tdir
2600 $LFS setstripe -c 2 $DIR/$tdir
2602 # stop all OSTs to reproduce situation for LU-7975 ticket
2603 for num in $(seq $OSTCOUNT); do
2607 # open/create f0 with O_LOV_DELAY_CREATE
2608 # truncate f0 to a non-0 size
2610 multiop $DIR/$tdir/f0 oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:T1050000c
2612 $CHECKSTAT -s 1050000 $DIR/$tdir/f0 || error "checkstat failed"
2613 # open/write it again to force delayed layout creation
2614 cat /etc/hosts > $DIR/$tdir/f0 &
2618 for num in $(seq $OSTCOUNT); do
2619 start ost$num $(ostdevname $num) $OST_MOUNT_OPTS ||
2620 error "ost$num failed to start"
2623 wait $catpid || error "cat failed"
2625 cmp /etc/hosts $DIR/$tdir/f0 || error "cmp failed"
2626 [[ $($LFS getstripe -c $DIR/$tdir/f0) == 2 ]] ||
2627 error "wrong stripecount"
2630 run_test 27F "Client resend delayed layout creation with non-zero size"
2632 test_27G() { #LU-10629
2633 [ $MDS1_VERSION -lt $(version_code 2.11.51) ] &&
2634 skip "Need MDS version at least 2.11.51"
2635 [ -n "$FILESET" ] && skip "SKIP due to FILESET set"
2636 remote_mds_nodsh && skip "remote MDS with nodsh"
2637 local POOL=${POOL:-testpool}
2638 local ostrange="0 0 1"
2640 test_mkdir $DIR/$tdir
2641 touch $DIR/$tdir/$tfile.nopool
2642 pool_add $POOL || error "pool_add failed"
2643 pool_add_targets $POOL $ostrange || error "pool_add_targets failed"
2644 $LFS setstripe -p $POOL $DIR/$tdir
2646 local pool=$($LFS getstripe -p $DIR/$tdir)
2648 [ "$pool" = "$POOL" ] || error "Striping failed got '$pool' not '$POOL'"
2649 touch $DIR/$tdir/$tfile.default
2650 $LFS setstripe -E 1M --pool $POOL -c 1 -E eof -c 1 $DIR/$tdir/$tfile.pfl
2651 $LFS find $DIR/$tdir -type f --pool $POOL
2652 local found=$($LFS find $DIR/$tdir -type f --pool $POOL | wc -l)
2653 [[ "$found" == "2" ]] ||
2654 error "found $found != 2 files in '$DIR/$tdir' in '$POOL'"
2656 $LFS setstripe -d $DIR/$tdir
2658 pool=$($LFS getstripe -p -d $DIR/$tdir)
2660 [[ "$pool" != "$POOL" ]] || error "$DIR/$tdir is still '$pool'"
2662 run_test 27G "Clear OST pool from stripe"
2665 [[ $MDS1_VERSION -le $(version_code 2.11.54) ]] &&
2666 skip "Need MDS version newer than 2.11.54"
2667 [[ $OSTCOUNT -lt 3 ]] && skip_env "needs >= 3 OSTs"
2668 test_mkdir $DIR/$tdir
2669 $LFS setstripe -o 0 -o 2 $DIR/$tdir || error "setstripe failed"
2670 touch $DIR/$tdir/$tfile
2671 $LFS getstripe -c $DIR/$tdir/$tfile
2672 [ $($LFS getstripe -c $DIR/$tdir/$tfile) -eq 2 ] ||
2673 error "two-stripe file doesn't have two stripes"
2675 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=4k count=4 || error "dd failed"
2676 $LFS getstripe -y $DIR/$tdir/$tfile
2677 (( $($LFS getstripe -y $DIR/$tdir/$tfile |
2678 egrep -c "l_ost_idx: [02]$") == "2" )) ||
2679 error "expected l_ost_idx: [02]$ not matched"
2681 # make sure ost list has been cleared
2682 local stripesize=$($LFS getstripe -S $DIR/$tdir)
2683 $LFS setstripe -S $((stripesize * 4)) -i 1 \
2684 -c $((OSTCOUNT - 1)) $DIR/$tdir || error "setstripe"
2686 $LVERIFY $DIR/$tdir $DIR/$tdir/f3 || error "lverify failed"
2688 run_test 27H "Set specific OSTs stripe"
2691 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2692 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
2693 [[ $MDS1_VERSION -gt $(version_code 2.12.52) ]] ||
2694 skip "Need MDS version newer than 2.12.52"
2695 local pool=$TESTNAME
2696 local ostrange="1 1 1"
2698 save_layout_restore_at_exit $MOUNT
2699 $LFS setstripe -c 2 -i 0 $MOUNT
2700 pool_add $pool || error "pool_add failed"
2701 pool_add_targets $pool $ostrange || "pool_add_targets failed"
2702 test_mkdir $DIR/$tdir
2703 $LFS setstripe -p $pool $DIR/$tdir
2704 $MULTIOP $DIR/$tdir/$tfile Oc || error "multiop failed"
2705 $LFS getstripe $DIR/$tdir/$tfile
2707 run_test 27I "check that root dir striping does not break parent dir one"
2710 [[ $MDS1_VERSION -le $(version_code 2.12.51) ]] &&
2711 skip "Need MDS version newer than 2.12.51"
2713 test_mkdir $DIR/$tdir
2714 local uuid1=$(cat /proc/sys/kernel/random/uuid)
2715 local uuid2=$(cat /proc/sys/kernel/random/uuid)
2717 # create foreign file (raw way)
2718 create_foreign_file -f $DIR/$tdir/$tfile -x "${uuid1}@${uuid2}" \
2719 -t 1 -F 0xda08 || error "create_foreign_file failed"
2721 # verify foreign file (raw way)
2722 parse_foreign_file -f $DIR/$tdir/$tfile |
2723 grep "lov_foreign_magic: 0x0BD70BD0" ||
2724 error "$DIR/$tdir/$tfile: invalid LOV EA foreign magic"
2725 parse_foreign_file -f $DIR/$tdir/$tfile | grep "lov_xattr_size: 89" ||
2726 error "$DIR/$tdir/$tfile: invalid LOV EA foreign size"
2727 parse_foreign_file -f $DIR/$tdir/$tfile |
2728 grep "lov_foreign_size: 73" ||
2729 error "$DIR/$tdir/$tfile: invalid LOV EA foreign size"
2730 parse_foreign_file -f $DIR/$tdir/$tfile |
2731 grep "lov_foreign_type: 1" ||
2732 error "$DIR/$tdir/$tfile: invalid LOV EA foreign type"
2733 parse_foreign_file -f $DIR/$tdir/$tfile |
2734 grep "lov_foreign_flags: 0x0000DA08" ||
2735 error "$DIR/$tdir/$tfile: invalid LOV EA foreign flags"
2736 local lov=$(parse_foreign_file -f $DIR/$tdir/$tfile |
2737 grep "lov_foreign_value: 0x" |
2738 sed -e 's/lov_foreign_value: 0x//')
2739 local lov2=$(echo -n "${uuid1}@${uuid2}" | od -A n -t x1 -w160)
2740 [[ $lov = ${lov2// /} ]] ||
2741 error "$DIR/$tdir/$tfile: invalid LOV EA foreign value"
2743 # create foreign file (lfs + API)
2744 $LFS setstripe --foreign=daos --flags 0xda08 \
2745 -x "${uuid1}@${uuid2}" $DIR/$tdir/${tfile}2 ||
2746 error "$DIR/$tdir/${tfile}2: create failed"
2748 $LFS getstripe -v $DIR/$tdir/${tfile}2 |
2749 grep "lfm_magic:.*0x0BD70BD0" ||
2750 error "$DIR/$tdir/${tfile}2: invalid LOV EA foreign magic"
2751 # lfm_length is LOV EA size - sizeof(lfm_magic) - sizeof(lfm_length)
2752 $LFS getstripe -v $DIR/$tdir/${tfile}2 | grep "lfm_length:.*73" ||
2753 error "$DIR/$tdir/${tfile}2: invalid LOV EA foreign size"
2754 $LFS getstripe -v $DIR/$tdir/${tfile}2 | grep "lfm_type:.*daos" ||
2755 error "$DIR/$tdir/${tfile}2: invalid LOV EA foreign type"
2756 $LFS getstripe -v $DIR/$tdir/${tfile}2 |
2757 grep "lfm_flags:.*0x0000DA08" ||
2758 error "$DIR/$tdir/${tfile}2: invalid LOV EA foreign flags"
2759 $LFS getstripe $DIR/$tdir/${tfile}2 |
2760 grep "lfm_value:.*${uuid1}@${uuid2}" ||
2761 error "$DIR/$tdir/${tfile}2: invalid LOV EA foreign value"
2763 # modify striping should fail
2764 $LFS setstripe -c 2 $DIR/$tdir/$tfile &&
2765 error "$DIR/$tdir/$tfile: setstripe should fail"
2766 $LFS setstripe -c 2 $DIR/$tdir/${tfile}2 &&
2767 error "$DIR/$tdir/${tfile}2: setstripe should fail"
2770 cat $DIR/$tdir/$tfile && error "$DIR/$tdir/$tfile: read should fail"
2771 cat $DIR/$tdir/${tfile}2 &&
2772 error "$DIR/$tdir/${tfile}2: read should fail"
2773 cat /etc/passwd > $DIR/$tdir/$tfile &&
2774 error "$DIR/$tdir/$tfile: write should fail"
2775 cat /etc/passwd > $DIR/$tdir/${tfile}2 &&
2776 error "$DIR/$tdir/${tfile}2: write should fail"
2779 chmod 222 $DIR/$tdir/$tfile ||
2780 error "$DIR/$tdir/$tfile: chmod failed"
2781 chmod 222 $DIR/$tdir/${tfile}2 ||
2782 error "$DIR/$tdir/${tfile}2: chmod failed"
2785 chown $RUNAS_ID:$RUNAS_GID $DIR/$tdir/$tfile ||
2786 error "$DIR/$tdir/$tfile: chown failed"
2787 chown $RUNAS_ID:$RUNAS_GID $DIR/$tdir/${tfile}2 ||
2788 error "$DIR/$tdir/${tfile}2: chown failed"
2790 # rename should work
2791 mv $DIR/$tdir/$tfile $DIR/$tdir/${tfile}.new ||
2792 error "$DIR/$tdir/$tfile: rename of foreign file has failed"
2793 mv $DIR/$tdir/${tfile}2 $DIR/$tdir/${tfile}2.new ||
2794 error "$DIR/$tdir/${tfile}2: rename of foreign file has failed"
2796 #remove foreign file
2797 rm $DIR/$tdir/${tfile}.new ||
2798 error "$DIR/$tdir/${tfile}.new: remove of foreign file has failed"
2799 rm $DIR/$tdir/${tfile}2.new ||
2800 error "$DIR/$tdir/${tfile}2.new: remove of foreign file has failed"
2802 run_test 27J "basic ops on file with foreign LOV"
2805 [[ $MDS1_VERSION -le $(version_code 2.12.49) ]] &&
2806 skip "Need MDS version newer than 2.12.49"
2808 test_mkdir $DIR/$tdir
2809 local uuid1=$(cat /proc/sys/kernel/random/uuid)
2810 local uuid2=$(cat /proc/sys/kernel/random/uuid)
2812 # create foreign dir (raw way)
2813 create_foreign_dir -d $DIR/$tdir/$tdir -x "${uuid1}@${uuid2}" -t 1 ||
2814 error "create_foreign_dir FAILED"
2816 # verify foreign dir (raw way)
2817 parse_foreign_dir -d $DIR/$tdir/$tdir |
2818 grep "lmv_foreign_magic:.*0xcd50cd0" ||
2819 error "$DIR/$tdir/$tfile: invalid LMV EA magic"
2820 parse_foreign_dir -d $DIR/$tdir/$tdir | grep "lmv_xattr_size:.*89$" ||
2821 error "$DIR/$tdir/$tdir: invalid LMV EA size"
2822 parse_foreign_dir -d $DIR/$tdir/$tdir | grep "lmv_foreign_type: 1$" ||
2823 error "$DIR/$tdir/$tdir: invalid LMV EA type"
2824 parse_foreign_dir -d $DIR/$tdir/$tdir | grep "lmv_foreign_flags: 0$" ||
2825 error "$DIR/$tdir/$tdir: invalid LMV EA flags"
2826 local lmv=$(parse_foreign_dir -d $DIR/$tdir/$tdir |
2827 grep "lmv_foreign_value: 0x" |
2828 sed 's/lmv_foreign_value: 0x//')
2829 local lmv2=$(echo -n "${uuid1}@${uuid2}" | od -A n -t x1 -w160 |
2831 [[ $lmv == $lmv2 ]] || error "$DIR/$tdir/$tdir: invalid LMV EA value"
2833 # create foreign dir (lfs + API)
2834 $LFS mkdir --foreign=daos --xattr="${uuid1}@${uuid2}" --flags=0xda05 \
2835 $DIR/$tdir/${tdir}2 ||
2836 error "$DIR/$tdir/${tdir}2: create failed"
2838 $LFS getdirstripe -v $DIR/$tdir/${tdir}2 |
2839 grep "lfm_magic:.*0x0CD50CD0" ||
2840 error "$DIR/$tdir/${tdir}2: invalid LMV EA magic"
2841 # lfm_length is LMV EA size - sizeof(lfm_magic) - sizeof(lfm_length)
2842 # - sizeof(lfm_type) - sizeof(lfm_flags)
2843 $LFS getdirstripe -v $DIR/$tdir/${tdir}2 | grep "lfm_length:.*73" ||
2844 error "$DIR/$tdir/${tdir}2: invalid LMV EA size"
2845 $LFS getdirstripe -v $DIR/$tdir/${tdir}2 | grep "lfm_type:.*daos" ||
2846 error "$DIR/$tdir/${tdir}2: invalid LMV EA type"
2847 $LFS getdirstripe -v $DIR/$tdir/${tdir}2 |
2848 grep "lfm_flags:.*0x0000DA05" ||
2849 error "$DIR/$tdir/${tdir}2: invalid LMV EA flags"
2850 $LFS getdirstripe $DIR/$tdir/${tdir}2 |
2851 grep "lfm_value.*${uuid1}@${uuid2}" ||
2852 error "$DIR/$tdir/${tdir}2: invalid LMV EA value"
2854 # file create in dir should fail
2855 touch $DIR/$tdir/$tdir/$tfile && "$DIR/$tdir: file create should fail"
2856 touch $DIR/$tdir/${tdir}2/$tfile &&
2857 "$DIR/${tdir}2: file create should fail"
2860 chmod 777 $DIR/$tdir/$tdir ||
2861 error "$DIR/$tdir: chmod failed"
2862 chmod 777 $DIR/$tdir/${tdir}2 ||
2863 error "$DIR/${tdir}2: chmod failed"
2866 chown $RUNAS_ID:$RUNAS_GID $DIR/$tdir/$tdir ||
2867 error "$DIR/$tdir: chown failed"
2868 chown $RUNAS_ID:$RUNAS_GID $DIR/$tdir/${tdir}2 ||
2869 error "$DIR/${tdir}2: chown failed"
2871 # rename should work
2872 mv $DIR/$tdir/$tdir $DIR/$tdir/${tdir}.new ||
2873 error "$DIR/$tdir/$tdir: rename of foreign dir has failed"
2874 mv $DIR/$tdir/${tdir}2 $DIR/$tdir/${tdir}2.new ||
2875 error "$DIR/$tdir/${tdir}2: rename of foreign dir has failed"
2878 rmdir $DIR/$tdir/${tdir}.new ||
2879 error "$DIR/$tdir/${tdir}.new: remove of foreign dir has failed"
2880 rmdir $DIR/$tdir/${tdir}2.new ||
2881 error "$DIR/$tdir/${tdir}2.new: remove of foreign dir has failed"
2883 run_test 27K "basic ops on dir with foreign LMV"
2886 remote_mds_nodsh && skip "remote MDS with nodsh"
2888 local POOL=${POOL:-$TESTNAME}
2890 pool_add $POOL || error "pool_add failed"
2892 lfs pool_list $MOUNT | grep -Fx "${FSNAME}.${POOL}" ||
2893 error "pool_list does not contain ${FSNAME}.${POOL}:" \
2894 "$(lfs pool_list $MOUNT | grep -F "${POOL}")"
2896 run_test 27L "lfs pool_list gives correct pool name"
2899 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.12.57) ]] &&
2900 skip "Need MDS version >= than 2.12.57"
2901 remote_mds_nodsh && skip "remote MDS with nodsh"
2902 [[ $OSTCOUNT -lt 2 ]] && skip_env "need > 1 OST"
2904 test_mkdir $DIR/$tdir
2906 # Set default striping on directory
2907 $LFS setstripe -C 4 $DIR/$tdir
2909 echo 1 > $DIR/$tdir/${tfile}.1
2910 local count=$($LFS getstripe -c $DIR/$tdir/${tfile}.1)
2912 [ $count -eq $setcount ] ||
2913 error "(1) stripe count $count, should be $setcount"
2915 # Capture existing append_stripe_count setting for restore
2916 local orig_count=$(do_facet mds1 $LCTL get_param -n mdd.$FSNAME-MDT0000.append_stripe_count)
2917 local mdts=$(comma_list $(mdts_nodes))
2918 stack_trap "do_nodes $mdts $LCTL set_param mdd.*.append_stripe_count=$orig_count" EXIT
2920 local appendcount=$orig_count
2921 echo 1 >> $DIR/$tdir/${tfile}.2_append
2922 count=$($LFS getstripe -c $DIR/$tdir/${tfile}.2_append)
2923 [ $count -eq $appendcount ] ||
2924 error "(2)stripe count $count, should be $appendcount for append"
2926 # Disable O_APPEND striping, verify it works
2927 do_nodes $mdts $LCTL set_param mdd.*.append_stripe_count=0
2929 # Should now get the default striping, which is 4
2931 echo 1 >> $DIR/$tdir/${tfile}.3_append
2932 count=$($LFS getstripe -c $DIR/$tdir/${tfile}.3_append)
2933 [ $count -eq $setcount ] ||
2934 error "(3) stripe count $count, should be $setcount"
2936 # Try changing the stripe count for append files
2937 do_nodes $mdts $LCTL set_param mdd.*.append_stripe_count=2
2939 # Append striping is now 2 (directory default is still 4)
2941 echo 1 >> $DIR/$tdir/${tfile}.4_append
2942 count=$($LFS getstripe -c $DIR/$tdir/${tfile}.4_append)
2943 [ $count -eq $appendcount ] ||
2944 error "(4) stripe count $count, should be $appendcount for append"
2946 # Test append stripe count of -1
2947 do_nodes $mdts $LCTL set_param mdd.*.append_stripe_count=-1
2948 appendcount=$OSTCOUNT
2949 echo 1 >> $DIR/$tdir/${tfile}.5
2950 count=$($LFS getstripe -c $DIR/$tdir/${tfile}.5)
2951 [ $count -eq $appendcount ] ||
2952 error "(5) stripe count $count, should be $appendcount for append"
2954 # Set append striping back to default of 1
2955 do_nodes $mdts $LCTL set_param mdd.*.append_stripe_count=1
2957 # Try a new default striping, PFL + DOM
2958 $LFS setstripe -L mdt -E 1M -E -1 -c 2 $DIR/$tdir
2960 # Create normal DOM file, DOM returns stripe count == 0
2962 touch $DIR/$tdir/${tfile}.6
2963 count=$($LFS getstripe -c $DIR/$tdir/${tfile}.6)
2964 [ $count -eq $setcount ] ||
2965 error "(6) stripe count $count, should be $setcount"
2969 echo 1 >> $DIR/$tdir/${tfile}.7_append
2970 count=$($LFS getstripe -c $DIR/$tdir/${tfile}.7_append)
2971 [ $count -eq $appendcount ] ||
2972 error "(7) stripe count $count, should be $appendcount for append"
2974 # Clean up DOM layout
2975 $LFS setstripe -d $DIR/$tdir
2977 # Now test that append striping works when layout is from root
2978 $LFS setstripe -c 2 $MOUNT
2979 # Make a special directory for this
2980 mkdir $DIR/${tdir}/${tdir}.2
2981 stack_trap "$LFS setstripe -d $MOUNT" EXIT
2983 # Verify for normal file
2985 echo 1 > $DIR/${tdir}/${tdir}.2/${tfile}.8
2986 count=$($LFS getstripe -c $DIR/$tdir/${tdir}.2/${tfile}.8)
2987 [ $count -eq $setcount ] ||
2988 error "(8) stripe count $count, should be $setcount"
2991 echo 1 >> $DIR/${tdir}/${tdir}.2/${tfile}.9_append
2992 count=$($LFS getstripe -c $DIR/${tdir}/${tdir}.2/${tfile}.9_append)
2993 [ $count -eq $appendcount ] ||
2994 error "(9) stripe count $count, should be $appendcount for append"
2996 # Now test O_APPEND striping with pools
2997 do_nodes $mdts $LCTL set_param mdd.*.append_pool="$TESTNAME"
2998 stack_trap "do_nodes $mdts $LCTL set_param mdd.*.append_pool='none'" EXIT
3001 pool_add $TESTNAME || error "pool creation failed"
3002 pool_add_targets $TESTNAME 0 1 || error "Pool add targets failed"
3004 echo 1 >> $DIR/$tdir/${tfile}.10_append
3006 pool=$($LFS getstripe -p $DIR/$tdir/${tfile}.10_append)
3007 [ "$pool" = "$TESTNAME" ] || error "(10) incorrect pool: $pool"
3009 # Check that count is still correct
3011 echo 1 >> $DIR/$tdir/${tfile}.11_append
3012 count=$($LFS getstripe -c $DIR/$tdir/${tfile}.11_append)
3013 [ $count -eq $appendcount ] ||
3014 error "(11) stripe count $count, should be $appendcount for append"
3016 # Disable O_APPEND stripe count, verify pool works separately
3017 do_nodes $mdts $LCTL set_param mdd.*.append_stripe_count=0
3019 echo 1 >> $DIR/$tdir/${tfile}.12_append
3021 pool=$($LFS getstripe -p $DIR/$tdir/${tfile}.12_append)
3022 [ "$pool" = "$TESTNAME" ] || error "(12) incorrect pool: $pool"
3024 # Remove pool setting, verify it's not applied
3025 do_nodes $mdts $LCTL set_param mdd.*.append_pool='none'
3027 echo 1 >> $DIR/$tdir/${tfile}.13_append
3029 pool=$($LFS getstripe -p $DIR/$tdir/${tfile}.13_append)
3030 [ "$pool" = "" ] || error "(13) pool found: $pool"
3032 run_test 27M "test O_APPEND striping"
3035 combined_mgs_mds && skip "needs separate MGS/MDT"
3037 pool_add $TESTNAME || error "pool_add failed"
3038 do_facet mgs "$LCTL pool_list $FSNAME" |
3039 grep -Fx "${FSNAME}.${TESTNAME}" ||
3040 error "lctl pool_list on MGS failed"
3042 run_test 27N "lctl pool_list on separate MGS gives correct pool name"
3044 # createtest also checks that device nodes are created and
3045 # then visible correctly (#2091)
3046 test_28() { # bug 2091
3048 $CREATETEST $DIR/d28/ct || error "createtest failed"
3050 run_test 28 "create/mknod/mkdir with bad file types ============"
3053 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3055 sync; sleep 1; sync # flush out any dirty pages from previous tests
3062 declare -i LOCKCOUNTORIG=0
3063 for lock_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_count); do
3064 let LOCKCOUNTORIG=$LOCKCOUNTORIG+$lock_count
3066 [ $LOCKCOUNTORIG -eq 0 ] && error "No mdc lock count" && return 1
3068 declare -i LOCKUNUSEDCOUNTORIG=0
3069 for unused_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_unused_count); do
3070 let LOCKUNUSEDCOUNTORIG=$LOCKUNUSEDCOUNTORIG+$unused_count
3077 declare -i LOCKCOUNTCURRENT=0
3078 for lock_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_count); do
3079 let LOCKCOUNTCURRENT=$LOCKCOUNTCURRENT+$lock_count
3082 declare -i LOCKUNUSEDCOUNTCURRENT=0
3083 for unused_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_unused_count); do
3084 let LOCKUNUSEDCOUNTCURRENT=$LOCKUNUSEDCOUNTCURRENT+$unused_count
3087 if [[ $LOCKCOUNTCURRENT -gt $LOCKCOUNTORIG ]]; then
3088 $LCTL set_param -n ldlm.dump_namespaces ""
3089 error "CURRENT: $LOCKCOUNTCURRENT > $LOCKCOUNTORIG"
3090 $LCTL dk | sort -k4 -t: > $TMP/test_29.dk
3091 log "dumped log to $TMP/test_29.dk (bug 5793)"
3094 if [[ $LOCKUNUSEDCOUNTCURRENT -gt $LOCKUNUSEDCOUNTORIG ]]; then
3095 error "UNUSED: $LOCKUNUSEDCOUNTCURRENT > $LOCKUNUSEDCOUNTORIG"
3096 $LCTL dk | sort -k4 -t: > $TMP/test_29.dk
3097 log "dumped log to $TMP/test_29.dk (bug 5793)"
3101 run_test 29 "IT_GETATTR regression ============================"
3103 test_30a() { # was test_30
3104 cp $(which ls) $DIR || cp /bin/ls $DIR
3105 $DIR/ls / || error "Can't execute binary from lustre"
3108 run_test 30a "execute binary from Lustre (execve) =============="
3111 cp `which ls` $DIR || cp /bin/ls $DIR
3113 $RUNAS $DIR/ls / || error "Can't execute binary from lustre as non-root"
3116 run_test 30b "execute binary from Lustre as non-root ==========="
3118 test_30c() { # b=22376
3119 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3121 cp $(which ls) $DIR || cp /bin/ls $DIR
3123 cancel_lru_locks mdc
3124 cancel_lru_locks osc
3125 $RUNAS $DIR/ls / || error "Can't execute binary from lustre"
3128 run_test 30c "execute binary from Lustre without read perms ===="
3131 cp $(which dd) $DIR || error "failed to copy dd to $DIR/dd"
3133 for i in {1..10}; do
3134 $DIR/dd bs=1M count=128 if=/dev/zero of=$DIR/$tfile &
3137 $LCTL set_param ldlm.namespaces.*MDT*.lru_size=clear
3138 wait $PID || error "executing dd from Lustre failed"
3144 run_test 30d "execute binary from Lustre while clear locks"
3147 $OPENUNLINK $DIR/f31 $DIR/f31 || error "openunlink failed"
3148 $CHECKSTAT -a $DIR/f31 || error "$DIR/f31 exists"
3150 run_test 31a "open-unlink file =================================="
3153 touch $DIR/f31 || error "touch $DIR/f31 failed"
3154 ln $DIR/f31 $DIR/f31b || error "ln failed"
3155 $MULTIOP $DIR/f31b Ouc || error "multiop failed"
3156 $CHECKSTAT -t file $DIR/f31 || error "$DIR/f31 not file type"
3158 run_test 31b "unlink file with multiple links while open ======="
3161 touch $DIR/f31 || error "touch $DIR/f31 failed"
3162 ln $DIR/f31 $DIR/f31c || error "ln failed"
3163 multiop_bg_pause $DIR/f31 O_uc ||
3164 error "multiop_bg_pause for $DIR/f31 failed"
3166 $MULTIOP $DIR/f31c Ouc
3167 kill -USR1 $MULTIPID
3170 run_test 31c "open-unlink file with multiple links ============="
3173 opendirunlink $DIR/d31d $DIR/d31d || error "opendirunlink failed"
3174 $CHECKSTAT -a $DIR/d31d || error "$DIR/d31d exists"
3176 run_test 31d "remove of open directory ========================="
3178 test_31e() { # bug 2904
3179 openfilleddirunlink $DIR/d31e || error "openfilleddirunlink failed"
3181 run_test 31e "remove of open non-empty directory ==============="
3183 test_31f() { # bug 4554
3184 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3187 test_mkdir $DIR/d31f
3188 $LFS setstripe -S 1048576 -c 1 $DIR/d31f
3189 cp /etc/hosts $DIR/d31f
3191 $LFS getstripe $DIR/d31f/hosts
3192 multiop_bg_pause $DIR/d31f D_c || return 1
3195 rm -rv $DIR/d31f || error "first of $DIR/d31f"
3196 test_mkdir $DIR/d31f
3197 $LFS setstripe -S 1048576 -c 1 $DIR/d31f
3198 cp /etc/hosts $DIR/d31f
3200 $LFS getstripe $DIR/d31f/hosts
3201 multiop_bg_pause $DIR/d31f D_c || return 1
3204 kill -USR1 $MULTIPID || error "first opendir $MULTIPID not running"
3205 wait $MULTIPID || error "first opendir $MULTIPID failed"
3209 kill -USR1 $MULTIPID2 || error "second opendir $MULTIPID not running"
3210 wait $MULTIPID2 || error "second opendir $MULTIPID2 failed"
3213 run_test 31f "remove of open directory with open-unlink file ==="
3216 echo "-- cross directory link --"
3217 test_mkdir -c1 $DIR/${tdir}ga
3218 test_mkdir -c1 $DIR/${tdir}gb
3219 touch $DIR/${tdir}ga/f
3220 ln $DIR/${tdir}ga/f $DIR/${tdir}gb/g
3221 $CHECKSTAT -t file $DIR/${tdir}ga/f || error "source"
3222 [ `stat -c%h $DIR/${tdir}ga/f` == '2' ] || error "source nlink"
3223 $CHECKSTAT -t file $DIR/${tdir}gb/g || error "target"
3224 [ `stat -c%h $DIR/${tdir}gb/g` == '2' ] || error "target nlink"
3226 run_test 31g "cross directory link==============="
3229 echo "-- cross directory link --"
3230 test_mkdir -c1 $DIR/${tdir}
3231 test_mkdir -c1 $DIR/${tdir}/dir
3232 touch $DIR/${tdir}/f
3233 ln $DIR/${tdir}/f $DIR/${tdir}/dir/g
3234 $CHECKSTAT -t file $DIR/${tdir}/f || error "source"
3235 [ `stat -c%h $DIR/${tdir}/f` == '2' ] || error "source nlink"
3236 $CHECKSTAT -t file $DIR/${tdir}/dir/g || error "target"
3237 [ `stat -c%h $DIR/${tdir}/dir/g` == '2' ] || error "target nlink"
3239 run_test 31h "cross directory link under child==============="
3242 echo "-- cross directory link --"
3243 test_mkdir -c1 $DIR/$tdir
3244 test_mkdir -c1 $DIR/$tdir/dir
3245 touch $DIR/$tdir/dir/f
3246 ln $DIR/$tdir/dir/f $DIR/$tdir/g
3247 $CHECKSTAT -t file $DIR/$tdir/dir/f || error "source"
3248 [ `stat -c%h $DIR/$tdir/dir/f` == '2' ] || error "source nlink"
3249 $CHECKSTAT -t file $DIR/$tdir/g || error "target"
3250 [ `stat -c%h $DIR/$tdir/g` == '2' ] || error "target nlink"
3252 run_test 31i "cross directory link under parent==============="
3255 test_mkdir -c1 -p $DIR/$tdir
3256 test_mkdir -c1 -p $DIR/$tdir/dir1
3257 ln $DIR/$tdir/dir1 $DIR/$tdir/dir2 && error "ln for dir"
3258 link $DIR/$tdir/dir1 $DIR/$tdir/dir3 && error "link for dir"
3259 mlink $DIR/$tdir/dir1 $DIR/$tdir/dir4 && error "mlink for dir"
3260 mlink $DIR/$tdir/dir1 $DIR/$tdir/dir1 && error "mlink to the same dir"
3263 run_test 31j "link for directory==============="
3266 test_mkdir -c1 -p $DIR/$tdir
3268 touch $DIR/$tdir/exist
3269 mlink $DIR/$tdir/s $DIR/$tdir/t || error "mlink"
3270 mlink $DIR/$tdir/s $DIR/$tdir/exist && error "mlink to exist file"
3271 mlink $DIR/$tdir/s $DIR/$tdir/s && error "mlink to the same file"
3272 mlink $DIR/$tdir/s $DIR/$tdir && error "mlink to parent dir"
3273 mlink $DIR/$tdir $DIR/$tdir/s && error "mlink parent dir to target"
3274 mlink $DIR/$tdir/not-exist $DIR/$tdir/foo && error "mlink non-existing to new"
3275 mlink $DIR/$tdir/not-exist $DIR/$tdir/s && error "mlink non-existing to exist"
3278 run_test 31k "link to file: the same, non-existing, dir==============="
3284 touch $DIR/d31m2/exist
3285 mlink $DIR/d31m/s $DIR/d31m2/t || error "mlink"
3286 mlink $DIR/d31m/s $DIR/d31m2/exist && error "mlink to exist file"
3287 mlink $DIR/d31m/s $DIR/d31m2 && error "mlink to parent dir"
3288 mlink $DIR/d31m2 $DIR/d31m/s && error "mlink parent dir to target"
3289 mlink $DIR/d31m/not-exist $DIR/d31m2/foo && error "mlink non-existing to new"
3290 mlink $DIR/d31m/not-exist $DIR/d31m2/s && error "mlink non-existing to exist"
3293 run_test 31m "link to file: the same, non-existing, dir==============="
3296 touch $DIR/$tfile || error "cannot create '$DIR/$tfile'"
3297 nlink=$(stat --format=%h $DIR/$tfile)
3298 [ ${nlink:--1} -eq 1 ] || error "nlink is $nlink, expected 1"
3300 local cmd="exec $fd<$DIR/$tfile"
3303 trap "eval $cmd" EXIT
3304 nlink=$(stat --dereference --format=%h /proc/self/fd/$fd)
3305 [ ${nlink:--1} -eq 1 ] || error "nlink is $nlink, expected 1"
3306 rm $DIR/$tfile || error "cannot remove '$DIR/$tfile'"
3307 nlink=$(stat --dereference --format=%h /proc/self/fd/$fd)
3308 [ ${nlink:--1} -eq 0 ] || error "nlink is $nlink, expected 0"
3311 run_test 31n "check link count of unlinked file"
3314 local tempfile=$(mktemp $1_XXXXXX)
3315 mlink $tempfile $1 2> /dev/null &&
3316 echo "$BASHPID: link $tempfile to $1 succeeded"
3320 test_31o() { # LU-2901
3321 test_mkdir $DIR/$tdir
3322 for LOOP in $(seq 100); do
3323 rm -f $DIR/$tdir/$tfile*
3324 for THREAD in $(seq 8); do
3325 link_one $DIR/$tdir/$tfile.$LOOP &
3328 local LINKS=$(ls -1 $DIR/$tdir | grep -c $tfile.$LOOP)
3329 [[ $LINKS -gt 1 ]] && ls $DIR/$tdir &&
3330 error "$LINKS duplicate links to $tfile.$LOOP" &&
3334 run_test 31o "duplicate hard links with same filename"
3337 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
3339 test_mkdir $DIR/$tdir
3340 $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
3341 $LFS setdirstripe -D -c2 -H all_char $DIR/$tdir/striped_dir
3343 opendirunlink $DIR/$tdir/striped_dir/test1 ||
3344 error "open unlink test1 failed"
3345 opendirunlink $DIR/$tdir/striped_dir/test2 ||
3346 error "open unlink test2 failed"
3348 $CHECKSTAT -a $DIR/$tdir/striped_dir/test1 ||
3349 error "test1 still exists"
3350 $CHECKSTAT -a $DIR/$tdir/striped_dir/test2 ||
3351 error "test2 still exists"
3353 run_test 31p "remove of open striped directory"