3 # Run select tests by setting ONLY, or as arguments to the script.
4 # Skip specific tests by setting EXCEPT.
6 # e.g. ONLY="22 23" or ONLY="`seq 32 39`" or EXCEPT="31"
11 # Check Grants after these tests
12 GRANT_CHECK_LIST="$GRANT_CHECK_LIST 42a 42b 42c 42d 42e 63a 63b 64a 64b 64c 64d"
17 CREATETEST=${CREATETEST:-createtest}
18 LVERIFY=${LVERIFY:-ll_dirstripe_verify}
19 OPENFILE=${OPENFILE:-openfile}
20 OPENUNLINK=${OPENUNLINK:-openunlink}
21 READS=${READS:-"reads"}
22 MUNLINK=${MUNLINK:-munlink}
23 SOCKETSERVER=${SOCKETSERVER:-socketserver}
24 SOCKETCLIENT=${SOCKETCLIENT:-socketclient}
25 MEMHOG=${MEMHOG:-memhog}
26 DIRECTIO=${DIRECTIO:-directio}
27 ACCEPTOR_PORT=${ACCEPTOR_PORT:-988}
29 CHECK_GRANT=${CHECK_GRANT:-"yes"}
30 GRANT_CHECK_LIST=${GRANT_CHECK_LIST:-""}
31 export PARALLEL=${PARALLEL:-"no"}
34 LUSTRE=${LUSTRE:-$(dirname $0)/..}
35 LUSTRE_TESTS_API_DIR=${LUSTRE_TESTS_API_DIR:-${LUSTRE}/tests/clientapi}
36 . $LUSTRE/tests/test-framework.sh
41 ALWAYS_EXCEPT="$SANITY_EXCEPT "
42 # bug number for skipped test: LU-9693 LU-6493 LU-9693
43 ALWAYS_EXCEPT+=" 42a 42b 42c "
44 # bug number: LU-8411 LU-9054
45 ALWAYS_EXCEPT+=" 407 312"
48 # bug number: LU-14181 LU-14181
49 ALWAYS_EXCEPT+=" 64e 64f"
52 selinux_status=$(getenforce)
53 if [ "$selinux_status" != "Disabled" ]; then
58 # skip the grant tests for ARM until they are fixed
59 if [[ $(uname -m) = aarch64 ]]; then
60 # bug number: LU-11596
61 ALWAYS_EXCEPT+=" $GRANT_CHECK_LIST"
62 # bug number: LU-11671
64 # bug number: LU-14067 LU-14067
65 ALWAYS_EXCEPT+=" 400a 400b"
68 # skip nfs tests on kernels >= 4.12.0 until they are fixed
69 if [ $LINUX_VERSION_CODE -ge $(version_code 4.12.0) ]; then
70 # bug number: LU-12661
73 # skip cgroup tests on RHEL8.1 kernels until they are fixed
74 if (( $LINUX_VERSION_CODE >= $(version_code 4.18.0) &&
75 $LINUX_VERSION_CODE < $(version_code 5.4.0) )); then
76 # bug number: LU-13063
81 [ "$SLOW" = "no" ] && EXCEPT_SLOW="27m 60i 64b 68 71 115 135 136 230d 300o"
83 if [ "$mds1_FSTYPE" = "zfs" ]; then
84 # bug number for skipped test:
87 [ "$SLOW" = "no" ] && EXCEPT_SLOW="$EXCEPT_SLOW 51b"
90 if [ "$ost1_FSTYPE" = "zfs" ]; then
91 # bug number for skipped test: LU-1941 LU-1941 LU-1941 LU-1941
92 ALWAYS_EXCEPT+=" 130a 130b 130c 130d 130e 130f 130g"
95 proc_regexp="/{proc,sys}/{fs,sys,kernel/debug}/{lustre,lnet}/"
97 # Get the SLES distro version
99 # Returns a version string that should only be used in comparing
100 # strings returned by version_code()
103 local version=$(grep VERSION_ID /etc/os-release | cut -d'"' -f2)
105 # All SuSE Linux versions have one decimal. version_code expects two
106 local sles_version=$version.0
107 version_code $sles_version
110 # Check if we are running on Ubuntu or SLES so we can make decisions on
112 if [ -r /etc/SuSE-release ]; then
113 sles_version=$(sles_version_code)
114 [ $sles_version -lt $(version_code 11.4.0) ] &&
115 # bug number for skipped test: LU-4341
116 ALWAYS_EXCEPT="$ALWAYS_EXCEPT 170"
117 [ $sles_version -lt $(version_code 12.0.0) ] &&
118 # bug number for skipped test: LU-3703
119 ALWAYS_EXCEPT="$ALWAYS_EXCEPT 234"
120 elif [ -r /etc/os-release ]; then
121 if grep -qi ubuntu /etc/os-release; then
122 ubuntu_version=$(version_code $(sed -n -e 's/"//g' \
123 -e 's/^VERSION=//p' \
127 if [[ $ubuntu_version -gt $(version_code 16.0.0) ]]; then
128 # bug number for skipped test:
130 ALWAYS_EXCEPT+=" 103a 410"
140 pgrep ll_sa > /dev/null && { echo "There are ll_sa thread not exit!"; exit 20; }
141 cleanupall ${FORCE} $* || { echo "FAILed to clean up"; exit 20; }
150 check_swap_layouts_support()
152 $LCTL get_param -n llite.*.sbi_flags | grep -q layout ||
153 skip "Does not support layout lock."
156 check_swap_layout_no_dom()
159 local SUPP=$(lfs getstripe $FOLDER | grep "pattern: mdt" | wc -l)
160 [ $SUPP -eq 0 ] || skip "layout swap does not support DOM files so far"
163 check_and_setup_lustre
167 MAXFREE=${MAXFREE:-$((300000 * $OSTCOUNT))}
169 [ -f $DIR/d52a/foo ] && chattr -a $DIR/d52a/foo
170 [ -f $DIR/d52b/foo ] && chattr -i $DIR/d52b/foo
171 rm -rf $DIR/[Rdfs][0-9]*
173 # $RUNAS_ID may get set incorrectly somewhere else
174 [ $UID -eq 0 -a $RUNAS_ID -eq 0 ] &&
175 error "\$RUNAS_ID set to 0, but \$UID is also 0!"
177 check_runas_id $RUNAS_ID $RUNAS_GID $RUNAS
179 if [ "${ONLY}" = "MOUNT" ] ; then
180 echo "Lustre is up, please go on"
184 echo "preparing for tests involving mounts"
185 EXT2_DEV=${EXT2_DEV:-$TMP/SANITY.LOOP}
187 mke2fs -j -F $EXT2_DEV 8000 > /dev/null
188 echo # add a newline after mke2fs.
192 OLDDEBUG=$(lctl get_param -n debug 2> /dev/null)
193 lctl set_param debug=-1 2> /dev/null || true
196 $CHECKSTAT -t file $DIR/$tfile || error "$tfile is not a file"
198 $CHECKSTAT -a $DIR/$tfile || error "$tfile was not removed"
200 run_test 0a "touch; rm ====================="
203 chmod 0755 $DIR || error "chmod 0755 $DIR failed"
204 $CHECKSTAT -p 0755 $DIR || error "$DIR permission is not 0755"
206 run_test 0b "chmod 0755 $DIR ============================="
209 $LCTL get_param mdc.*.import | grep "state: FULL" ||
210 error "import not FULL"
211 $LCTL get_param mdc.*.import | grep "target: $FSNAME-MDT" ||
214 run_test 0c "check import proc"
216 test_0d() { # LU-3397
217 [ $MGS_VERSION -lt $(version_code 2.10.57) ] &&
218 skip "proc exports not supported before 2.10.57"
220 local mgs_exp="mgs.MGS.exports"
221 local client_uuid=$($LCTL get_param -n mgc.*.uuid)
223 local exp_client_version
226 local temp_imp=$DIR/$tfile.import
227 local temp_exp=$DIR/$tfile.export
229 # save mgc import file to $temp_imp
230 $LCTL get_param mgc.*.import | tee $temp_imp
231 # Check if client uuid is found in MGS export
232 for exp_client_nid in $(do_facet mgs $LCTL get_param -N $mgs_exp.*); do
233 [ $(do_facet mgs $LCTL get_param -n $exp_client_nid.uuid) == \
237 # save mgs export file to $temp_exp
238 do_facet mgs $LCTL get_param $exp_client_nid.export | tee $temp_exp
240 # Compare the value of field "connect_flags"
241 imp_val=$(grep "connect_flags" $temp_imp)
242 exp_val=$(grep "connect_flags" $temp_exp)
243 [ "$exp_val" == "$imp_val" ] ||
244 error "export flags '$exp_val' != import flags '$imp_val'"
246 # Compare client versions. Only compare top-3 fields for compatibility
247 exp_client_version=$(awk '/target_version:/ { print $2 }' $temp_exp)
248 exp_val=$(version_code $(cut -d. -f1,2,3 <<<$exp_client_version))
249 imp_val=$(version_code $(lustre_build_version client | cut -d. -f1,2,3))
250 [ "$exp_val" == "$imp_val" ] ||
251 error "exp version '$exp_client_version'($exp_val) != " \
252 "'$(lustre_build_version client)'($imp_val)"
254 run_test 0d "check export proc ============================="
256 test_0e() { # LU-13417
257 (( $MDSCOUNT > 1 )) ||
258 skip "We need at least 2 MDTs for this test"
260 (( $MDS1_VERSION >= $(version_code 2.14.51) )) ||
261 skip "Need server version at least 2.14.51"
263 local default_lmv_count=$($LFS getdirstripe -D -c $MOUNT)
264 local default_lmv_index=$($LFS getdirstripe -D -i $MOUNT)
266 [ $default_lmv_count -eq 1 ] ||
267 error "$MOUNT default stripe count $default_lmv_count"
269 [ $default_lmv_index -eq -1 ] ||
270 error "$MOUNT default stripe index $default_lmv_index"
272 mkdir $MOUNT/$tdir.1 || error "mkdir $MOUNT/$tdir.1 failed"
273 mkdir $MOUNT/$tdir.2 || error "mkdir $MOUNT/$tdir.2 failed"
275 local mdt_index1=$($LFS getdirstripe -i $MOUNT/$tdir.1)
276 local mdt_index2=$($LFS getdirstripe -i $MOUNT/$tdir.2)
278 [ $mdt_index1 -eq $mdt_index2 ] &&
279 error "directories are on the same MDT $mdt_index1=$mdt_index2"
281 rmdir $MOUNT/$tdir.1 $MOUNT/$tdir.2
283 run_test 0e "Enable DNE MDT balancing for mkdir in the ROOT"
286 test_mkdir $DIR/$tdir
287 test_mkdir $DIR/$tdir/d2
288 mkdir $DIR/$tdir/d2 && error "we expect EEXIST, but not returned"
289 $CHECKSTAT -t dir $DIR/$tdir/d2 || error "$tdir/d2 is not a dir"
292 $CHECKSTAT -a $DIR/$tdir || error "$tdir was not removed"
294 run_test 1 "mkdir; remkdir; rmdir"
297 test_mkdir $DIR/$tdir
298 touch $DIR/$tdir/$tfile || error "touch $tdir/$tfile failed"
299 $CHECKSTAT -t file $DIR/$tdir/$tfile || error "$tdir/$tfile not a file"
301 $CHECKSTAT -a $DIR/$tdir/$tfile || error "$tdir/$file is not removed"
303 run_test 2 "mkdir; touch; rmdir; check file"
306 test_mkdir $DIR/$tdir
307 $CHECKSTAT -t dir $DIR/$tdir || error "$tdir is not a directory"
308 touch $DIR/$tdir/$tfile
309 $CHECKSTAT -t file $DIR/$tdir/$tfile || error "$tdir/$tfile not a file"
311 $CHECKSTAT -a $DIR/$tdir || error "$tdir is not removed"
313 run_test 3 "mkdir; touch; rmdir; check dir"
315 # LU-4471 - failed rmdir on remote directories still removes directory on MDT0
317 test_mkdir -i 1 $DIR/$tdir
319 touch $DIR/$tdir/$tfile ||
320 error "Create file under remote directory failed"
323 error "Expect error removing in-use dir $DIR/$tdir"
325 test -d $DIR/$tdir || error "Remote directory disappeared"
327 rm -rf $DIR/$tdir || error "remove remote dir error"
329 run_test 4 "mkdir; touch dir/file; rmdir; checkdir (expect error)"
332 test_mkdir $DIR/$tdir
333 test_mkdir $DIR/$tdir/d2
334 chmod 0707 $DIR/$tdir/d2 || error "chmod 0707 $tdir/d2 failed"
335 $CHECKSTAT -t dir -p 0707 $DIR/$tdir/d2 || error "$tdir/d2 not mode 707"
336 $CHECKSTAT -t dir $DIR/$tdir/d2 || error "$tdir/d2 is not a directory"
338 run_test 5 "mkdir .../d5 .../d5/d2; chmod .../d5/d2"
341 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
342 chmod 0666 $DIR/$tfile || error "chmod 0666 $tfile failed"
343 $CHECKSTAT -t file -p 0666 -u \#$UID $DIR/$tfile ||
344 error "$tfile does not have perm 0666 or UID $UID"
345 $RUNAS chmod 0444 $DIR/$tfile && error "chmod $tfile worked on UID $UID"
346 $CHECKSTAT -t file -p 0666 -u \#$UID $DIR/$tfile ||
347 error "$tfile should be 0666 and owned by UID $UID"
349 run_test 6a "touch f6a; chmod f6a; $RUNAS chmod f6a (should return error) =="
352 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID"
355 chown $RUNAS_ID $DIR/$tfile || error "chown $RUNAS_ID $file failed"
356 $CHECKSTAT -t file -u \#$RUNAS_ID $DIR/$tfile ||
357 error "$tfile should be owned by UID $RUNAS_ID"
358 $RUNAS chown $UID $DIR/$tfile && error "chown $UID $file succeeded"
359 $CHECKSTAT -t file -u \#$RUNAS_ID $DIR/$tfile ||
360 error "$tfile should be owned by UID $RUNAS_ID"
362 run_test 6c "touch f6c; chown f6c; $RUNAS chown f6c (should return error) =="
365 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID"
368 chgrp $RUNAS_ID $DIR/$tfile || error "chgrp $RUNAS_ID $file failed"
369 $CHECKSTAT -t file -u \#$UID -g \#$RUNAS_ID $DIR/$tfile ||
370 error "$tfile should be owned by GID $UID"
371 $RUNAS chgrp $UID $DIR/$tfile && error "chgrp $UID $file succeeded"
372 $CHECKSTAT -t file -u \#$UID -g \#$RUNAS_ID $DIR/$tfile ||
373 error "$tfile should be owned by UID $UID and GID $RUNAS_ID"
375 run_test 6e "touch+chgrp $tfile; $RUNAS chgrp $tfile (should return error)"
378 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID"
380 test_mkdir $DIR/$tdir
381 chmod 777 $DIR/$tdir || error "chmod 0777 $tdir failed"
382 $RUNAS mkdir $DIR/$tdir/d || error "mkdir $tdir/d failed"
383 chmod g+s $DIR/$tdir/d || error "chmod g+s $tdir/d failed"
384 test_mkdir $DIR/$tdir/d/subdir
385 $CHECKSTAT -g \#$RUNAS_GID $DIR/$tdir/d/subdir ||
386 error "$tdir/d/subdir should be GID $RUNAS_GID"
387 if [[ $MDSCOUNT -gt 1 ]]; then
388 # check remote dir sgid inherite
389 $LFS mkdir -i 0 $DIR/$tdir.local ||
390 error "mkdir $tdir.local failed"
391 chmod g+s $DIR/$tdir.local ||
392 error "chmod $tdir.local failed"
393 chgrp $RUNAS_GID $DIR/$tdir.local ||
394 error "chgrp $tdir.local failed"
395 $LFS mkdir -i 1 $DIR/$tdir.local/$tdir.remote ||
396 error "mkdir $tdir.remote failed"
397 $CHECKSTAT -g \#$RUNAS_GID $DIR/$tdir.local/$tdir.remote ||
398 error "$tdir.remote should be owned by $UID.$RUNAS_ID"
399 $CHECKSTAT -p 02755 $DIR/$tdir.local/$tdir.remote ||
400 error "$tdir.remote should be mode 02755"
403 run_test 6g "verify new dir in sgid dir inherits group"
405 test_6h() { # bug 7331
406 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID"
408 touch $DIR/$tfile || error "touch failed"
409 chown $RUNAS_ID:$RUNAS_GID $DIR/$tfile || error "initial chown failed"
410 $RUNAS -G$RUNAS_GID chown $RUNAS_ID:0 $DIR/$tfile &&
411 error "chown $RUNAS_ID:0 $tfile worked as GID $RUNAS_GID"
412 $CHECKSTAT -t file -u \#$RUNAS_ID -g \#$RUNAS_GID $DIR/$tfile ||
413 error "$tdir/$tfile should be UID $RUNAS_UID GID $RUNAS_GID"
415 run_test 6h "$RUNAS chown RUNAS_ID.0 .../$tfile (should return error)"
418 test_mkdir $DIR/$tdir
419 $MCREATE $DIR/$tdir/$tfile
420 chmod 0666 $DIR/$tdir/$tfile
421 $CHECKSTAT -t file -p 0666 $DIR/$tdir/$tfile ||
422 error "$tdir/$tfile should be mode 0666"
424 run_test 7a "mkdir .../d7; mcreate .../d7/f; chmod .../d7/f ===="
427 if [ ! -d $DIR/$tdir ]; then
428 test_mkdir $DIR/$tdir
430 $MCREATE $DIR/$tdir/$tfile
431 echo -n foo > $DIR/$tdir/$tfile
432 [ "$(cat $DIR/$tdir/$tfile)" = "foo" ] || error "$tdir/$tfile not 'foo'"
433 $CHECKSTAT -t file -s 3 $DIR/$tdir/$tfile || error "$tfile size not 3"
435 run_test 7b "mkdir .../d7; mcreate d7/f2; echo foo > d7/f2 ====="
438 test_mkdir $DIR/$tdir
439 touch $DIR/$tdir/$tfile
440 chmod 0666 $DIR/$tdir/$tfile
441 $CHECKSTAT -t file -p 0666 $DIR/$tdir/$tfile ||
442 error "$tfile mode not 0666"
444 run_test 8 "mkdir .../d8; touch .../d8/f; chmod .../d8/f ======="
447 test_mkdir $DIR/$tdir
448 test_mkdir $DIR/$tdir/d2
449 test_mkdir $DIR/$tdir/d2/d3
450 $CHECKSTAT -t dir $DIR/$tdir/d2/d3 || error "$tdir/d2/d3 not a dir"
452 run_test 9 "mkdir .../d9 .../d9/d2 .../d9/d2/d3 ================"
455 test_mkdir $DIR/$tdir
456 test_mkdir $DIR/$tdir/d2
457 touch $DIR/$tdir/d2/$tfile
458 $CHECKSTAT -t file $DIR/$tdir/d2/$tfile ||
459 error "$tdir/d2/$tfile not a file"
461 run_test 10 "mkdir .../d10 .../d10/d2; touch .../d10/d2/f ======"
464 test_mkdir $DIR/$tdir
465 test_mkdir $DIR/$tdir/d2
466 chmod 0666 $DIR/$tdir/d2
467 chmod 0705 $DIR/$tdir/d2
468 $CHECKSTAT -t dir -p 0705 $DIR/$tdir/d2 ||
469 error "$tdir/d2 mode not 0705"
471 run_test 11 "mkdir .../d11 d11/d2; chmod .../d11/d2 ============"
474 test_mkdir $DIR/$tdir
475 touch $DIR/$tdir/$tfile
476 chmod 0666 $DIR/$tdir/$tfile
477 chmod 0654 $DIR/$tdir/$tfile
478 $CHECKSTAT -t file -p 0654 $DIR/$tdir/$tfile ||
479 error "$tdir/d2 mode not 0654"
481 run_test 12 "touch .../d12/f; chmod .../d12/f .../d12/f ========"
484 test_mkdir $DIR/$tdir
485 dd if=/dev/zero of=$DIR/$tdir/$tfile count=10
487 $CHECKSTAT -t file -s 0 $DIR/$tdir/$tfile ||
488 error "$tdir/$tfile size not 0 after truncate"
490 run_test 13 "creat .../d13/f; dd .../d13/f; > .../d13/f ========"
493 test_mkdir $DIR/$tdir
494 touch $DIR/$tdir/$tfile
496 $CHECKSTAT -a $DIR/$tdir/$tfile || error "$tdir/$tfile not removed"
498 run_test 14 "touch .../d14/f; rm .../d14/f; rm .../d14/f ======="
501 test_mkdir $DIR/$tdir
502 touch $DIR/$tdir/$tfile
503 mv $DIR/$tdir/$tfile $DIR/$tdir/${tfile}_2
504 $CHECKSTAT -t file $DIR/$tdir/${tfile}_2 ||
505 error "$tdir/${tfile_2} not a file after rename"
506 rm $DIR/$tdir/${tfile}_2 || error "unlink failed after rename"
508 run_test 15 "touch .../d15/f; mv .../d15/f .../d15/f2 =========="
511 test_mkdir $DIR/$tdir
512 touch $DIR/$tdir/$tfile
513 rm -rf $DIR/$tdir/$tfile
514 $CHECKSTAT -a $DIR/$tdir/$tfile || error "$tdir/$tfile not removed"
516 run_test 16 "touch .../d16/f; rm -rf .../d16/f"
519 test_mkdir $DIR/$tdir
520 touch $DIR/$tdir/$tfile
521 ln -s $DIR/$tdir/$tfile $DIR/$tdir/l-exist
523 $CHECKSTAT -l $DIR/$tdir/$tfile $DIR/$tdir/l-exist ||
524 error "$tdir/l-exist not a symlink"
525 $CHECKSTAT -f -t f $DIR/$tdir/l-exist ||
526 error "$tdir/l-exist not referencing a file"
527 rm -f $DIR/$tdir/l-exist
528 $CHECKSTAT -a $DIR/$tdir/l-exist || error "$tdir/l-exist not removed"
530 run_test 17a "symlinks: create, remove (real)"
533 test_mkdir $DIR/$tdir
534 ln -s no-such-file $DIR/$tdir/l-dangle
536 $CHECKSTAT -l no-such-file $DIR/$tdir/l-dangle ||
537 error "$tdir/l-dangle not referencing no-such-file"
538 $CHECKSTAT -fa $DIR/$tdir/l-dangle ||
539 error "$tdir/l-dangle not referencing non-existent file"
540 rm -f $DIR/$tdir/l-dangle
541 $CHECKSTAT -a $DIR/$tdir/l-dangle || error "$tdir/l-dangle not removed"
543 run_test 17b "symlinks: create, remove (dangling)"
545 test_17c() { # bug 3440 - don't save failed open RPC for replay
546 test_mkdir $DIR/$tdir
547 ln -s foo $DIR/$tdir/$tfile
548 cat $DIR/$tdir/$tfile && error "opened non-existent symlink" || true
550 run_test 17c "symlinks: open dangling (should return error)"
553 test_mkdir $DIR/$tdir
554 ln -s foo $DIR/$tdir/$tfile
555 touch $DIR/$tdir/$tfile || error "creating to new symlink"
557 run_test 17d "symlinks: create dangling"
560 test_mkdir $DIR/$tdir
561 local foo=$DIR/$tdir/$tfile
562 ln -s $foo $foo || error "create symlink failed"
563 ls -l $foo || error "ls -l failed"
564 ls $foo && error "ls not failed" || true
566 run_test 17e "symlinks: create recursive symlink (should return error)"
569 test_mkdir $DIR/$tdir
570 ln -s 1234567890/2234567890/3234567890/4234567890 $DIR/$tdir/111
571 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890 $DIR/$tdir/222
572 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890 $DIR/$tdir/333
573 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890/9234567890/a234567890/b234567890 $DIR/$tdir/444
574 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890/9234567890/a234567890/b234567890/c234567890/d234567890/f234567890 $DIR/$tdir/555
575 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
578 run_test 17f "symlinks: long and very long symlink name"
580 # str_repeat(S, N) generate a string that is string S repeated N times
585 while [ $((n -= 1)) -ge 0 ]; do
591 # Long symlinks and LU-2241
593 test_mkdir $DIR/$tdir
594 local TESTS="59 60 61 4094 4095"
596 # Fix for inode size boundary in 2.1.4
597 [ $MDS1_VERSION -lt $(version_code 2.1.4) ] &&
600 # Patch not applied to 2.2 or 2.3 branches
601 [ $MDS1_VERSION -ge $(version_code 2.2.0) ] &&
602 [ $MDS1_VERSION -le $(version_code 2.3.55) ] &&
606 local SYMNAME=$(str_repeat 'x' $i)
607 ln -s $SYMNAME $DIR/$tdir/f$i || error "failed $i-char symlink"
608 readlink $DIR/$tdir/f$i || error "failed $i-char readlink"
611 run_test 17g "symlinks: really long symlink name and inode boundaries"
613 test_17h() { #bug 17378
614 [ $PARALLEL == "yes" ] && skip "skip parallel run"
615 remote_mds_nodsh && skip "remote MDS with nodsh"
619 test_mkdir $DIR/$tdir
620 mdt_idx=$($LFS getdirstripe -i $DIR/$tdir)
621 $LFS setstripe -c -1 $DIR/$tdir
622 #define OBD_FAIL_MDS_LOV_PREP_CREATE 0x141
623 do_facet mds$((mdt_idx + 1)) lctl set_param fail_loc=0x80000141
624 touch $DIR/$tdir/$tfile || true
626 run_test 17h "create objects: lov_free_memmd() doesn't lbug"
628 test_17i() { #bug 20018
629 [ $PARALLEL == "yes" ] && skip "skip parallel run"
630 remote_mds_nodsh && skip "remote MDS with nodsh"
632 local foo=$DIR/$tdir/$tfile
635 test_mkdir -c1 $DIR/$tdir
636 mdt_idx=$($LFS getdirstripe -i $DIR/$tdir)
637 ln -s $foo $foo || error "create symlink failed"
638 #define OBD_FAIL_MDS_READLINK_EPROTO 0x143
639 do_facet mds$((mdt_idx + 1)) lctl set_param fail_loc=0x80000143
640 ls -l $foo && error "error not detected"
643 run_test 17i "don't panic on short symlink (should return error)"
645 test_17k() { #bug 22301
646 [ $PARALLEL == "yes" ] && skip "skip parallel run"
647 [[ -z "$(which rsync 2>/dev/null)" ]] &&
648 skip "no rsync command"
649 rsync --help | grep -q xattr ||
650 skip_env "$(rsync --version | head -n1) does not support xattrs"
651 test_mkdir $DIR/$tdir
652 test_mkdir $DIR/$tdir.new
653 touch $DIR/$tdir/$tfile
654 ln -s $DIR/$tdir/$tfile $DIR/$tdir/$tfile.lnk
655 rsync -av -X $DIR/$tdir/ $DIR/$tdir.new ||
656 error "rsync failed with xattrs enabled"
658 run_test 17k "symlinks: rsync with xattrs enabled"
660 test_17l() { # LU-279
661 [[ -z "$(which getfattr 2>/dev/null)" ]] &&
662 skip "no getfattr command"
664 test_mkdir $DIR/$tdir
665 touch $DIR/$tdir/$tfile
666 ln -s $DIR/$tdir/$tfile $DIR/$tdir/$tfile.lnk
667 for path in "$DIR/$tdir" "$DIR/$tdir/$tfile" "$DIR/$tdir/$tfile.lnk"; do
668 # -h to not follow symlinks. -m '' to list all the xattrs.
669 # grep to remove first line: '# file: $path'.
670 for xattr in `getfattr -hm '' $path 2>/dev/null | grep -v '^#'`;
672 lgetxattr_size_check $path $xattr ||
673 error "lgetxattr_size_check $path $xattr failed"
677 run_test 17l "Ensure lgetxattr's returned xattr size is consistent"
681 [ $PARALLEL == "yes" ] && skip "skip parallel run"
682 [ "$mds1_FSTYPE" != "ldiskfs" ] && skip_env "ldiskfs only test"
683 remote_mds_nodsh && skip "remote MDS with nodsh"
684 [ $MDS1_VERSION -ge $(version_code 2.2.0) ] &&
685 [ $MDS1_VERSION -le $(version_code 2.2.93) ] &&
686 skip "MDS 2.2.0-2.2.93 do not NUL-terminate symlinks"
688 local short_sym="0123456789"
689 local wdir=$DIR/$tdir
694 # create a long symlink file
695 for ((i = 0; i < 4; ++i)); do
696 long_sym=${long_sym}${long_sym}
699 echo "create 512 short and long symlink files under $wdir"
700 for ((i = 0; i < 256; ++i)); do
701 ln -sf ${long_sym}"a5a5" $wdir/long-$i
702 ln -sf ${short_sym}"a5a5" $wdir/short-$i
708 wait_delete_completed
710 echo "recreate the 512 symlink files with a shorter string"
711 for ((i = 0; i < 512; ++i)); do
712 # rewrite the symlink file with a shorter string
713 ln -sf ${long_sym} $wdir/long-$i || error "long_sym failed"
714 ln -sf ${short_sym} $wdir/short-$i || error "short_sym failed"
717 local mds_index=$(($($LFS getstripe -m $wdir) + 1))
718 local devname=$(mdsdevname $mds_index)
720 echo "stop and checking mds${mds_index}:"
721 # e2fsck should not return error
723 run_e2fsck $(facet_active_host mds${mds_index}) $devname -n
726 start mds${mds_index} $devname $MDS_MOUNT_OPTS ||
727 error "start mds${mds_index} failed"
728 df $MOUNT > /dev/null 2>&1
730 error "e2fsck detected error for short/long symlink: rc=$rc"
733 run_test 17m "run e2fsck against MDT which contains short/long symlink"
735 check_fs_consistency_17n() {
739 # create/unlink in 17n only change 2 MDTs(MDT1/MDT2),
740 # so it only check MDT1/MDT2 instead of all of MDTs.
741 for mdt_index in 1 2; do
742 local devname=$(mdsdevname $mdt_index)
743 # e2fsck should not return error
745 run_e2fsck $(facet_active_host mds$mdt_index) $devname -n ||
748 start mds${mdt_index} $devname $MDS_MOUNT_OPTS ||
749 error "mount mds$mdt_index failed"
750 df $MOUNT > /dev/null 2>&1
756 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
757 [ $PARALLEL == "yes" ] && skip "skip parallel run"
758 [ "$mds1_FSTYPE" != "ldiskfs" ] && skip_env "ldiskfs only test"
759 remote_mds_nodsh && skip "remote MDS with nodsh"
760 [ $MDS1_VERSION -ge $(version_code 2.2.0) ] &&
761 [ $MDS1_VERSION -le $(version_code 2.2.93) ] &&
762 skip "MDS 2.2.0-2.2.93 do not NUL-terminate symlinks"
766 test_mkdir $DIR/$tdir
767 for ((i=0; i<10; i++)); do
768 $LFS mkdir -i1 -c2 $DIR/$tdir/remote_dir_${i} ||
769 error "create remote dir error $i"
770 createmany -o $DIR/$tdir/remote_dir_${i}/f 10 ||
771 error "create files under remote dir failed $i"
774 check_fs_consistency_17n ||
775 error "e2fsck report error after create files under remote dir"
777 for ((i = 0; i < 10; i++)); do
778 rm -rf $DIR/$tdir/remote_dir_${i} ||
779 error "destroy remote dir error $i"
782 check_fs_consistency_17n ||
783 error "e2fsck report error after unlink files under remote dir"
785 [ $MDS1_VERSION -lt $(version_code 2.4.50) ] &&
786 skip "lustre < 2.4.50 does not support migrate mv"
788 for ((i = 0; i < 10; i++)); do
789 mkdir -p $DIR/$tdir/remote_dir_${i}
790 createmany -o $DIR/$tdir/remote_dir_${i}/f 10 ||
791 error "create files under remote dir failed $i"
792 $LFS migrate --mdt-index 1 $DIR/$tdir/remote_dir_${i} ||
793 error "migrate remote dir error $i"
795 check_fs_consistency_17n || error "e2fsck report error after migration"
797 for ((i = 0; i < 10; i++)); do
798 rm -rf $DIR/$tdir/remote_dir_${i} ||
799 error "destroy remote dir error $i"
802 check_fs_consistency_17n || error "e2fsck report error after unlink"
804 run_test 17n "run e2fsck against master/slave MDT which contains remote dir"
807 remote_mds_nodsh && skip "remote MDS with nodsh"
808 [ $MDS1_VERSION -lt $(version_code 2.3.64) ] &&
809 skip "Need MDS version at least 2.3.64"
811 local wdir=$DIR/${tdir}o
817 mdt_index=$($LFS getstripe -m $wdir/$tfile)
818 mdt_index=$((mdt_index + 1))
821 #fail mds will wait the failover finish then set
822 #following fail_loc to avoid interfer the recovery process.
825 #define OBD_FAIL_OSD_LMA_INCOMPAT 0x194
826 do_facet mds${mdt_index} lctl set_param fail_loc=0x194
827 ls -l $wdir/$tfile && rc=1
828 do_facet mds${mdt_index} lctl set_param fail_loc=0
829 [[ $rc -eq 0 ]] || error "stat file should fail"
831 run_test 17o "stat file with incompat LMA feature"
834 touch $DIR/$tfile || error "Failed to touch $DIR/$tfile: $?"
835 ls $DIR || error "Failed to ls $DIR: $?"
837 run_test 18 "touch .../f ; ls ... =============================="
843 $CHECKSTAT -a $DIR/$tfile || error "$tfile was not removed"
845 run_test 19a "touch .../f19 ; ls -l ... ; rm .../f19 ==========="
848 ls -l $DIR/$tfile && error "ls -l $tfile failed"|| true
850 run_test 19b "ls -l .../f19 (should return error) =============="
853 [ $RUNAS_ID -eq $UID ] &&
854 skip_env "RUNAS_ID = UID = $UID -- skipping"
856 $RUNAS touch $DIR/$tfile && error "create non-root file failed" || true
858 run_test 19c "$RUNAS touch .../f19 (should return error) =="
861 cat $DIR/f19 && error || true
863 run_test 19d "cat .../f19 (should return error) =============="
872 $CHECKSTAT -a $DIR/$tfile || error "$tfile was not removed"
874 run_test 20 "touch .../f ; ls -l ..."
877 test_mkdir $DIR/$tdir
878 [ -f $DIR/$tdir/dangle ] && rm -f $DIR/$tdir/dangle
879 ln -s dangle $DIR/$tdir/link
880 echo foo >> $DIR/$tdir/link
881 cat $DIR/$tdir/dangle
882 $CHECKSTAT -t link $DIR/$tdir/link || error "$tdir/link not a link"
883 $CHECKSTAT -f -t file $DIR/$tdir/link ||
884 error "$tdir/link not linked to a file"
886 run_test 21 "write to dangling link"
889 local wdir=$DIR/$tdir
891 chown $RUNAS_ID:$RUNAS_GID $wdir
892 (cd $wdir || error "cd $wdir failed";
893 $RUNAS tar cf - /etc/hosts /etc/sysconfig/network |
895 ls -lR $wdir/etc || error "ls -lR $wdir/etc failed"
896 $CHECKSTAT -t dir $wdir/etc || error "checkstat -t dir failed"
897 $CHECKSTAT -u \#$RUNAS_ID -g \#$RUNAS_GID $wdir/etc ||
898 error "checkstat -u failed"
900 run_test 22 "unpack tar archive as non-root user"
904 test_mkdir $DIR/$tdir
905 local file=$DIR/$tdir/$tfile
907 openfile -f O_CREAT:O_EXCL $file || error "$file create failed"
908 openfile -f O_CREAT:O_EXCL $file &&
909 error "$file recreate succeeded" || true
911 run_test 23a "O_CREAT|O_EXCL in subdir"
913 test_23b() { # bug 18988
914 test_mkdir $DIR/$tdir
915 local file=$DIR/$tdir/$tfile
918 echo foo > $file || error "write filed"
919 echo bar >> $file || error "append filed"
920 $CHECKSTAT -s 8 $file || error "wrong size"
923 run_test 23b "O_APPEND check"
925 # LU-9409, size with O_APPEND and tiny writes
927 local file=$DIR/$tfile
930 dd conv=notrunc oflag=append if=/dev/zero of=$file bs=8 count=800
931 $CHECKSTAT -s 6400 $file || error "wrong size, expected 6400"
935 dd conv=notrunc oflag=append if=/dev/zero of=$file bs=8 count=800 &
936 dd conv=notrunc oflag=append if=/dev/zero of=$file bs=8 count=800 &
938 $CHECKSTAT -s 12800 $file || error "wrong size, expected 12800"
941 #racing tiny & normal writes
942 dd conv=notrunc oflag=append if=/dev/zero of=$file bs=4096 count=4 &
943 dd conv=notrunc oflag=append if=/dev/zero of=$file bs=8 count=100 &
945 $CHECKSTAT -s 17184 $file || error "wrong size, expected 17184"
948 #racing tiny & normal writes 2, ugly numbers
949 dd conv=notrunc oflag=append if=/dev/zero of=$file bs=4099 count=11 &
950 dd conv=notrunc oflag=append if=/dev/zero of=$file bs=17 count=173 &
952 $CHECKSTAT -s 48030 $file || error "wrong size, expected 48030"
955 run_test 23c "O_APPEND size checks for tiny writes"
957 # LU-11069 file offset is correct after appending writes
959 local file=$DIR/$tfile
962 echo CentaurHauls > $file
963 offset=$($MULTIOP $file oO_WRONLY:O_APPEND:w13Zp)
964 if ((offset != 26)); then
965 error "wrong offset, expected 26, got '$offset'"
968 run_test 23d "file offset is correct after appending writes"
972 echo '-- same directory rename'
973 test_mkdir $DIR/$tdir
974 touch $DIR/$tdir/$tfile.1
975 mv $DIR/$tdir/$tfile.1 $DIR/$tdir/$tfile.2
976 $CHECKSTAT -t file $DIR/$tdir/$tfile.2 || error "$tfile.2 not a file"
978 run_test 24a "rename file to non-existent target"
981 test_mkdir $DIR/$tdir
982 touch $DIR/$tdir/$tfile.{1,2}
983 mv $DIR/$tdir/$tfile.1 $DIR/$tdir/$tfile.2
984 $CHECKSTAT -a $DIR/$tdir/$tfile.1 || error "$tfile.1 exists"
985 $CHECKSTAT -t file $DIR/$tdir/$tfile.2 || error "$tfile.2 not a file"
987 run_test 24b "rename file to existing target"
990 test_mkdir $DIR/$tdir
991 test_mkdir $DIR/$tdir/d$testnum.1
992 mv $DIR/$tdir/d$testnum.1 $DIR/$tdir/d$testnum.2
993 $CHECKSTAT -a $DIR/$tdir/d$testnum.1 || error "d$testnum.1 exists"
994 $CHECKSTAT -t dir $DIR/$tdir/d$testnum.2 || error "d$testnum.2 not dir"
996 run_test 24c "rename directory to non-existent target"
999 test_mkdir -c1 $DIR/$tdir
1000 test_mkdir -c1 $DIR/$tdir/d$testnum.1
1001 test_mkdir -c1 $DIR/$tdir/d$testnum.2
1002 mrename $DIR/$tdir/d$testnum.1 $DIR/$tdir/d$testnum.2
1003 $CHECKSTAT -a $DIR/$tdir/d$testnum.1 || error "d$testnum.1 exists"
1004 $CHECKSTAT -t dir $DIR/$tdir/d$testnum.2 || error "d$testnum.2 not dir"
1006 run_test 24d "rename directory to existing target"
1009 echo '-- cross directory renames --'
1013 mv $DIR/R5a/f $DIR/R5b/g
1014 $CHECKSTAT -a $DIR/R5a/f || error "$DIR/R5a/f exists"
1015 $CHECKSTAT -t file $DIR/R5b/g || error "$DIR/R5b/g not file type"
1017 run_test 24e "touch .../R5a/f; rename .../R5a/f .../R5b/g ======"
1022 touch $DIR/R6a/f $DIR/R6b/g
1023 mv $DIR/R6a/f $DIR/R6b/g
1024 $CHECKSTAT -a $DIR/R6a/f || error "$DIR/R6a/f exists"
1025 $CHECKSTAT -t file $DIR/R6b/g || error "$DIR/R6b/g not file type"
1027 run_test 24f "touch .../R6a/f R6b/g; mv .../R6a/f .../R6b/g ===="
1032 test_mkdir $DIR/R7a/d
1033 mv $DIR/R7a/d $DIR/R7b/e
1034 $CHECKSTAT -a $DIR/R7a/d || error "$DIR/R7a/d exists"
1035 $CHECKSTAT -t dir $DIR/R7b/e || error "$DIR/R7b/e not dir type"
1037 run_test 24g "mkdir .../R7{a,b}/d; mv .../R7a/d .../R7b/e ======"
1040 test_mkdir -c1 $DIR/R8a
1041 test_mkdir -c1 $DIR/R8b
1042 test_mkdir -c1 $DIR/R8a/d
1043 test_mkdir -c1 $DIR/R8b/e
1044 mrename $DIR/R8a/d $DIR/R8b/e
1045 $CHECKSTAT -a $DIR/R8a/d || error "$DIR/R8a/d exists"
1046 $CHECKSTAT -t dir $DIR/R8b/e || error "$DIR/R8b/e not dir type"
1048 run_test 24h "mkdir .../R8{a,b}/{d,e}; rename .../R8a/d .../R8b/e"
1051 echo "-- rename error cases"
1053 test_mkdir $DIR/R9/a
1055 mrename $DIR/R9/f $DIR/R9/a
1056 $CHECKSTAT -t file $DIR/R9/f || error "$DIR/R9/f not file type"
1057 $CHECKSTAT -t dir $DIR/R9/a || error "$DIR/R9/a not dir type"
1058 $CHECKSTAT -a $DIR/R9/a/f || error "$DIR/R9/a/f exists"
1060 run_test 24i "rename file to dir error: touch f ; mkdir a ; rename f a"
1064 mrename $DIR/R10/f $DIR/R10/g
1065 $CHECKSTAT -t dir $DIR/R10 || error "$DIR/R10 not dir type"
1066 $CHECKSTAT -a $DIR/R10/f || error "$DIR/R10/f exists"
1067 $CHECKSTAT -a $DIR/R10/g || error "$DIR/R10/g exists"
1069 run_test 24j "source does not exist ============================"
1072 test_mkdir $DIR/R11a
1073 test_mkdir $DIR/R11a/d
1075 mv $DIR/R11a/f $DIR/R11a/d
1076 $CHECKSTAT -a $DIR/R11a/f || error "$DIR/R11a/f exists"
1077 $CHECKSTAT -t file $DIR/R11a/d/f || error "$DIR/R11a/d/f not file type"
1079 run_test 24k "touch .../R11a/f; mv .../R11a/f .../R11a/d ======="
1081 # bug 2429 - rename foo foo foo creates invalid file
1084 $MULTIOP $f OcNs || error "rename of ${f} to itself failed"
1086 run_test 24l "Renaming a file to itself ========================"
1090 $MULTIOP $f OcLN ${f}2 ${f}2 || error "link ${f}2 ${f}2 failed"
1091 # on ext3 this does not remove either the source or target files
1092 # though the "expected" operation would be to remove the source
1093 $CHECKSTAT -t file ${f} || error "${f} missing"
1094 $CHECKSTAT -t file ${f}2 || error "${f}2 missing"
1096 run_test 24m "Renaming a file to a hard link to itself ========="
1100 # this stats the old file after it was renamed, so it should fail
1102 $CHECKSTAT ${f} || error "${f} missing"
1104 $CHECKSTAT ${f}.rename || error "${f}.rename missing"
1105 $CHECKSTAT -a ${f} || error "${f} exists"
1107 run_test 24n "Statting the old file after renaming (Posix rename 2)"
1110 test_mkdir $DIR/$tdir
1111 rename_many -s random -v -n 10 $DIR/$tdir
1113 run_test 24o "rename of files during htree split"
1116 test_mkdir $DIR/R12a
1117 test_mkdir $DIR/R12b
1118 DIRINO=`ls -lid $DIR/R12a | awk '{ print $1 }'`
1119 mrename $DIR/R12a $DIR/R12b
1120 $CHECKSTAT -a $DIR/R12a || error "$DIR/R12a exists"
1121 $CHECKSTAT -t dir $DIR/R12b || error "$DIR/R12b not dir type"
1122 DIRINO2=`ls -lid $DIR/R12b | awk '{ print $1 }'`
1123 [ "$DIRINO" = "$DIRINO2" ] || error "R12a $DIRINO != R12b $DIRINO2"
1125 run_test 24p "mkdir .../R12{a,b}; rename .../R12a .../R12b"
1127 cleanup_multiop_pause() {
1129 kill -USR1 $MULTIPID
1133 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1135 test_mkdir $DIR/R13a
1136 test_mkdir $DIR/R13b
1137 local DIRINO=$(ls -lid $DIR/R13a | awk '{ print $1 }')
1138 multiop_bg_pause $DIR/R13b D_c || error "multiop failed to start"
1141 trap cleanup_multiop_pause EXIT
1142 mrename $DIR/R13a $DIR/R13b
1143 $CHECKSTAT -a $DIR/R13a || error "R13a still exists"
1144 $CHECKSTAT -t dir $DIR/R13b || error "R13b does not exist"
1145 local DIRINO2=$(ls -lid $DIR/R13b | awk '{ print $1 }')
1146 [ "$DIRINO" = "$DIRINO2" ] || error "R13a $DIRINO != R13b $DIRINO2"
1147 cleanup_multiop_pause
1148 wait $MULTIPID || error "multiop close failed"
1150 run_test 24q "mkdir .../R13{a,b}; open R13b rename R13a R13b ==="
1152 test_24r() { #bug 3789
1153 test_mkdir $DIR/R14a
1154 test_mkdir $DIR/R14a/b
1155 mrename $DIR/R14a $DIR/R14a/b && error "rename to subdir worked!"
1156 $CHECKSTAT -t dir $DIR/R14a || error "$DIR/R14a missing"
1157 $CHECKSTAT -t dir $DIR/R14a/b || error "$DIR/R14a/b missing"
1159 run_test 24r "mkdir .../R14a/b; rename .../R14a .../R14a/b ====="
1162 test_mkdir $DIR/R15a
1163 test_mkdir $DIR/R15a/b
1164 test_mkdir $DIR/R15a/b/c
1165 mrename $DIR/R15a $DIR/R15a/b/c && error "rename to sub-subdir worked!"
1166 $CHECKSTAT -t dir $DIR/R15a || error "$DIR/R15a missing"
1167 $CHECKSTAT -t dir $DIR/R15a/b/c || error "$DIR/R15a/b/c missing"
1169 run_test 24s "mkdir .../R15a/b/c; rename .../R15a .../R15a/b/c ="
1171 test_mkdir $DIR/R16a
1172 test_mkdir $DIR/R16a/b
1173 test_mkdir $DIR/R16a/b/c
1174 mrename $DIR/R16a/b/c $DIR/R16a && error "rename to sub-subdir worked!"
1175 $CHECKSTAT -t dir $DIR/R16a || error "$DIR/R16a missing"
1176 $CHECKSTAT -t dir $DIR/R16a/b/c || error "$DIR/R16a/b/c missing"
1178 run_test 24t "mkdir .../R16a/b/c; rename .../R16a/b/c .../R16a ="
1180 test_24u() { # bug12192
1181 $MULTIOP $DIR/$tfile C2w$((2048 * 1024))c || error "multiop failed"
1182 $CHECKSTAT -s $((2048 * 1024)) $DIR/$tfile || error "wrong file size"
1184 run_test 24u "create stripe file"
1186 simple_cleanup_common() {
1190 [[ -z "$DIR" || -z "$tdir" || ! -d "$DIR/$tdir" ]] && return 0
1192 local start=$SECONDS
1194 [[ -n "$createmany" ]] && unlinkmany $DIR/$tdir/$tfile $createmany
1195 rm -rf $DIR/$tdir || error "cleanup $DIR/$tdir failed"
1197 wait_delete_completed
1198 echo "cleanup time $((SECONDS - start))"
1202 max_pages_per_rpc() {
1203 local mdtname="$(printf "MDT%04x" ${1:-0})"
1204 $LCTL get_param -n mdc.*$mdtname*.max_pages_per_rpc
1208 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1210 local nrfiles=${COUNT:-100000}
1211 local fname="$DIR/$tdir/$tfile"
1213 # Performance issue on ZFS see LU-4072 (c.f. LU-2887)
1214 [ "$mds1_FSTYPE" = "zfs" ] && nrfiles=${COUNT:-10000}
1216 test_mkdir "$(dirname $fname)"
1217 # assume MDT0000 has the fewest inodes
1218 local stripes=$($LFS getdirstripe -c $(dirname $fname))
1219 local free_inodes=$(($(mdt_free_inodes 0) * ${stripes/#0/1}))
1220 [[ $free_inodes -lt $nrfiles ]] && nrfiles=$free_inodes
1222 stack_trap "simple_cleanup_common $nrfiles"
1224 createmany -m "$fname" $nrfiles
1226 cancel_lru_locks mdc
1227 lctl set_param mdc.*.stats clear
1229 # was previously test_24D: LU-6101
1230 # readdir() returns correct number of entries after cursor reload
1231 local num_ls=$(ls $DIR/$tdir | wc -l)
1232 local num_uniq=$(ls $DIR/$tdir | sort -u | wc -l)
1233 local num_all=$(ls -a $DIR/$tdir | wc -l)
1234 if [ $num_ls -ne $nrfiles ] || [ $num_uniq -ne $nrfiles ] ||
1235 [ $num_all -ne $((nrfiles + 2)) ]; then
1236 error "Expected $nrfiles files, got $num_ls " \
1237 "($num_uniq unique $num_all .&..)"
1239 # LU-5 large readdir
1240 # dirent_size = 32 bytes for sizeof(struct lu_dirent) +
1241 # N bytes for name (len($nrfiles) rounded to 8 bytes) +
1242 # 8 bytes for luda_type (4 bytes rounded to 8 bytes)
1243 # take into account of overhead in lu_dirpage header and end mark in
1244 # each page, plus one in rpc_num calculation.
1245 local dirent_size=$((32 + (${#tfile} | 7) + 1 + 8))
1246 local page_entries=$(((PAGE_SIZE - 24) / dirent_size))
1247 local mdt_idx=$($LFS getdirstripe -i $(dirname $fname))
1248 local rpc_pages=$(max_pages_per_rpc $mdt_idx)
1249 local rpc_max=$((nrfiles / (page_entries * rpc_pages) + stripes))
1250 local mds_readpage=$(calc_stats mdc.*.stats mds_readpage)
1251 echo "readpages: $mds_readpage rpc_max: $rpc_max-2/+1"
1252 (( $mds_readpage >= $rpc_max - 2 && $mds_readpage <= $rpc_max + 1)) ||
1253 error "large readdir doesn't take effect: " \
1254 "$mds_readpage should be about $rpc_max"
1256 run_test 24v "list large directory (test hash collision, b=17560)"
1258 test_24w() { # bug21506
1260 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=4096 || return 1
1261 dd if=/dev/zero bs=$SZ1 count=1 >> $DIR/$tfile || return 2
1262 dd if=$DIR/$tfile of=$DIR/${tfile}_left bs=1M skip=4097 || return 3
1263 SZ2=`ls -l $DIR/${tfile}_left | awk '{print $5}'`
1264 [[ "$SZ1" -eq "$SZ2" ]] ||
1265 error "Error reading at the end of the file $tfile"
1267 run_test 24w "Reading a file larger than 4Gb"
1270 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
1271 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1272 [[ $MDS1_VERSION -lt $(version_code 2.7.56) ]] &&
1273 skip "Need MDS version at least 2.7.56"
1276 local remote_dir=$DIR/$tdir/remote_dir
1278 test_mkdir $DIR/$tdir
1279 $LFS mkdir -i $MDTIDX $remote_dir ||
1280 error "create remote directory failed"
1282 test_mkdir $DIR/$tdir/src_dir
1283 touch $DIR/$tdir/src_file
1284 test_mkdir $remote_dir/tgt_dir
1285 touch $remote_dir/tgt_file
1287 mrename $DIR/$tdir/src_dir $remote_dir/tgt_dir ||
1288 error "rename dir cross MDT failed!"
1290 mrename $DIR/$tdir/src_file $remote_dir/tgt_file ||
1291 error "rename file cross MDT failed!"
1293 touch $DIR/$tdir/ln_file
1294 ln $DIR/$tdir/ln_file $remote_dir/ln_name ||
1295 error "ln file cross MDT failed"
1297 rm -rf $DIR/$tdir || error "Can not delete directories"
1299 run_test 24x "cross MDT rename/link"
1302 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
1303 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1305 local remote_dir=$DIR/$tdir/remote_dir
1308 test_mkdir $DIR/$tdir
1309 $LFS mkdir -i $mdtidx $remote_dir ||
1310 error "create remote directory failed"
1312 test_mkdir $remote_dir/src_dir
1313 touch $remote_dir/src_file
1314 test_mkdir $remote_dir/tgt_dir
1315 touch $remote_dir/tgt_file
1317 mrename $remote_dir/src_dir $remote_dir/tgt_dir ||
1318 error "rename subdir in the same remote dir failed!"
1320 mrename $remote_dir/src_file $remote_dir/tgt_file ||
1321 error "rename files in the same remote dir failed!"
1323 ln $remote_dir/tgt_file $remote_dir/tgt_file1 ||
1324 error "link files in the same remote dir failed!"
1326 rm -rf $DIR/$tdir || error "Can not delete directories"
1328 run_test 24y "rename/link on the same dir should succeed"
1331 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
1332 [[ $MDS1_VERSION -lt $(version_code 2.12.51) ]] &&
1333 skip "Need MDS version at least 2.12.51"
1337 for index in 0 1; do
1338 $LFS mkdir -i $index $DIR/$tdir.$index || error "mkdir failed"
1339 touch $DIR/$tdir.0/$tfile.$index || error "touch failed"
1342 mv $DIR/$tdir.0/$tfile.0 $DIR/$tdir.1 || error "mv $tfile.0 failed"
1344 index=$($LFS getstripe -m $DIR/$tdir.1/$tfile.0)
1345 [ $index -eq 0 ] || error "$tfile.0 is on MDT$index"
1347 local mdts=$(comma_list $(mdts_nodes))
1349 do_nodes $mdts $LCTL set_param mdt.*.enable_remote_rename=0
1350 stack_trap "do_nodes $mdts $LCTL \
1351 set_param mdt.*.enable_remote_rename=1" EXIT
1353 mv $DIR/$tdir.0/$tfile.1 $DIR/$tdir.1 || error "mv $tfile.1 failed"
1355 index=$($LFS getstripe -m $DIR/$tdir.1/$tfile.1)
1356 [ $index -eq 1 ] || error "$tfile.1 is on MDT$index"
1358 run_test 24z "cross-MDT rename is done as cp"
1360 test_24A() { # LU-3182
1363 test_mkdir $DIR/$tdir
1364 stack_trap "simple_cleanup_common $NFILES"
1365 createmany -m $DIR/$tdir/$tfile $NFILES
1366 local t=$(ls $DIR/$tdir | wc -l)
1367 local u=$(ls $DIR/$tdir | sort -u | wc -l)
1368 local v=$(ls -ai $DIR/$tdir | sort -u | wc -l)
1370 (( $t == $NFILES && $u == $NFILES && $v == NFILES + 2 )) ||
1371 error "Expected $NFILES files, got $t ($u unique $v .&..)"
1373 run_test 24A "readdir() returns correct number of entries."
1375 test_24B() { # LU-4805
1376 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
1380 test_mkdir $DIR/$tdir
1381 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR/$tdir/striped_dir ||
1382 error "create striped dir failed"
1384 count=$(ls -ai $DIR/$tdir/striped_dir | wc -l)
1385 [ $count -eq 2 ] || error "Expected 2, got $count"
1387 touch $DIR/$tdir/striped_dir/a
1389 count=$(ls -ai $DIR/$tdir/striped_dir | wc -l)
1390 [ $count -eq 3 ] || error "Expected 3, got $count"
1392 touch $DIR/$tdir/striped_dir/.f
1394 count=$(ls -ai $DIR/$tdir/striped_dir | wc -l)
1395 [ $count -eq 4 ] || error "Expected 4, got $count"
1397 rm -rf $DIR/$tdir || error "Can not delete directories"
1399 run_test 24B "readdir for striped dir return correct number of entries"
1402 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
1408 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR/$tdir/d0/striped_dir ||
1409 error "create striped dir failed"
1411 cd $DIR/$tdir/d0/striped_dir
1413 local d0_ino=$(ls -i -l -a $DIR/$tdir | grep "d0" | awk '{print $1}')
1414 local d1_ino=$(ls -i -l -a $DIR/$tdir | grep "d1" | awk '{print $1}')
1415 local parent_ino=$(ls -i -l -a | grep "\.\." | awk '{print $1}')
1417 [ "$d0_ino" = "$parent_ino" ] ||
1418 error ".. wrong, expect $d0_ino, get $parent_ino"
1420 mv $DIR/$tdir/d0/striped_dir $DIR/$tdir/d1/ ||
1421 error "mv striped dir failed"
1423 parent_ino=$(ls -i -l -a | grep "\.\." | awk '{print $1}')
1425 [ "$d1_ino" = "$parent_ino" ] ||
1426 error ".. wrong after mv, expect $d1_ino, get $parent_ino"
1428 run_test 24C "check .. in striped dir"
1431 [[ $MDSCOUNT -lt 4 ]] && skip_env "needs >= 4 MDTs"
1432 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1435 mkdir $DIR/$tdir/src_dir
1436 $LFS mkdir -i 1 $DIR/$tdir/src_dir/src_child ||
1437 error "create remote source failed"
1439 touch $DIR/$tdir/src_dir/src_child/a
1441 $LFS mkdir -i 2 $DIR/$tdir/tgt_dir ||
1442 error "create remote target dir failed"
1444 $LFS mkdir -i 3 $DIR/$tdir/tgt_dir/tgt_child ||
1445 error "create remote target child failed"
1447 mrename $DIR/$tdir/src_dir/src_child $DIR/$tdir/tgt_dir/tgt_child ||
1448 error "rename dir cross MDT failed!"
1452 $CHECKSTAT -t dir $DIR/$tdir/src_dir/src_child &&
1453 error "src_child still exists after rename"
1455 $CHECKSTAT -t file $DIR/$tdir/tgt_dir/tgt_child/a ||
1456 error "missing file(a) after rename"
1458 rm -rf $DIR/$tdir || error "Can not delete directories"
1460 run_test 24E "cross MDT rename/link"
1463 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
1466 [ "$SLOW" = "no" ] && repeats=100
1470 echo "$repeats repeats"
1471 for ((i = 0; i < repeats; i++)); do
1472 $LFS mkdir -i0 -c2 $DIR/$tdir/test || error "mkdir fails"
1473 touch $DIR/$tdir/test/a || error "touch fails"
1474 mkdir $DIR/$tdir/test/b || error "mkdir fails"
1475 rm -rf $DIR/$tdir/test || error "rmdir fails"
1480 run_test 24F "hash order vs readdir (LU-11330)"
1483 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
1488 $LFS mkdir -i 0 $DIR/$tdir-0 || error "mkdir $tdir-0"
1489 $LFS mkdir -i 1 $DIR/$tdir-1 || error "mkdir $tdir-1"
1490 touch $DIR/$tdir-0/f1 || error "touch f1"
1491 ln -s $DIR/$tdir-0/f1 $DIR/$tdir-0/s1 || error "ln s1"
1492 ino1=$(stat -c%i $DIR/$tdir-0/s1)
1493 mv $DIR/$tdir-0/s1 $DIR/$tdir-1 || error "mv s1"
1494 ino2=$(stat -c%i $DIR/$tdir-1/s1)
1495 [ $ino1 -ne $ino2 ] || error "s1 should be migrated"
1497 run_test 24G "migrate symlink in rename"
1500 echo '== symlink sanity ============================================='
1504 touch $DIR/s25/foo ||
1505 error "File creation in symlinked directory failed"
1507 run_test 25a "create file in symlinked directory ==============="
1510 [ ! -d $DIR/d25 ] && test_25a
1511 $CHECKSTAT -t file $DIR/s25/foo || error "$DIR/s25/foo not file type"
1513 run_test 25b "lookup file in symlinked directory ==============="
1517 test_mkdir $DIR/d26/d26-2
1518 ln -s d26/d26-2 $DIR/s26
1519 touch $DIR/s26/foo || error "File creation failed"
1521 run_test 26a "multiple component symlink ======================="
1524 test_mkdir -p $DIR/$tdir/d26-2
1525 ln -s $tdir/d26-2/foo $DIR/s26-2
1526 touch $DIR/s26-2 || error "File creation failed"
1528 run_test 26b "multiple component symlink at end of lookup ======"
1531 test_mkdir $DIR/d26.2
1532 touch $DIR/d26.2/foo
1533 ln -s d26.2 $DIR/s26.2-1
1534 ln -s s26.2-1 $DIR/s26.2-2
1535 ln -s s26.2-2 $DIR/s26.2-3
1536 chmod 0666 $DIR/s26.2-3/foo
1538 run_test 26c "chain of symlinks"
1540 # recursive symlinks (bug 439)
1542 ln -s d26-3/foo $DIR/d26-3
1544 run_test 26d "create multiple component recursive symlink"
1547 [ ! -h $DIR/d26-3 ] && test_26d
1550 run_test 26e "unlink multiple component recursive symlink"
1552 # recursive symlinks (bug 7022)
1554 test_mkdir $DIR/$tdir
1555 test_mkdir $DIR/$tdir/$tfile
1556 cd $DIR/$tdir/$tfile || error "cd $DIR/$tdir/$tfile failed"
1557 test_mkdir -p lndir/bar1
1558 test_mkdir $DIR/$tdir/$tfile/$tfile
1559 cd $tfile || error "cd $tfile failed"
1560 ln -s .. dotdot || error "ln dotdot failed"
1561 ln -s dotdot/lndir lndir || error "ln lndir failed"
1562 cd $DIR/$tdir || error "cd $DIR/$tdir failed"
1563 output=`ls $tfile/$tfile/lndir/bar1`
1564 [ "$output" = bar1 ] && error "unexpected output"
1565 rm -r $tfile || error "rm $tfile failed"
1566 $CHECKSTAT -a $DIR/$tfile || error "$tfile not gone"
1568 run_test 26f "rm -r of a directory which has recursive symlink"
1571 test_mkdir $DIR/$tdir
1572 $LFS getstripe $DIR/$tdir
1573 $LFS setstripe -c 1 $DIR/$tdir/$tfile || error "setstripe failed"
1574 $CHECKSTAT -t file $DIR/$tdir/$tfile || error "checkstat failed"
1575 cp /etc/hosts $DIR/$tdir/$tfile || error "Can't copy to one stripe file"
1577 run_test 27a "one stripe file"
1580 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
1582 test_mkdir $DIR/$tdir
1583 $LFS setstripe -c 2 $DIR/$tdir/$tfile || error "setstripe failed"
1584 $LFS getstripe -c $DIR/$tdir/$tfile
1585 [ $($LFS getstripe -c $DIR/$tdir/$tfile) -eq 2 ] ||
1586 error "two-stripe file doesn't have two stripes"
1588 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=4k count=4 || error "dd failed"
1590 run_test 27b "create and write to two stripe file"
1592 # 27c family tests specific striping, setstripe -o
1594 [[ $OSTCOUNT -lt 2 ]] && skip_env "skipping 2-stripe test"
1595 test_mkdir -p $DIR/$tdir
1598 $LFS setstripe -o $osts $DIR/$tdir/$tfile || error "setstripe failed"
1599 $LFS getstripe -i $DIR/$tdir/$tfile
1600 [ $($LFS getstripe -i $DIR/$tdir/$tfile ) -eq $osts ] ||
1601 error "stripe not on specified OST"
1603 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=4 || error "dd failed"
1605 run_test 27ca "one stripe on specified OST"
1608 [[ $OSTCOUNT -lt 2 ]] && skip_env "skipping 2-stripe test"
1609 test_mkdir -p $DIR/$tdir
1611 $LFS setstripe -o $osts $DIR/$tdir/$tfile || error "setstripe failed"
1612 local getstripe=$($LFS getstripe $DIR/$tdir/$tfile)
1615 # Strip getstripe output to a space separated list of OSTs
1616 local getstripe_osts=$(echo "$getstripe" | sed -e '1,/obdidx/d' |\
1617 awk '{print $1}' | tr '\n' ' ' | sed -e 's/[[:space:]]*$//')
1618 [ "$getstripe_osts" = "${osts//,/ }" ] ||
1619 error "stripes not on specified OSTs"
1621 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=4 || error "dd failed"
1623 run_test 27cb "two stripes on specified OSTs"
1626 [[ $OSTCOUNT -lt 2 ]] && skip_env "skipping 2-stripe test"
1627 [[ $($LCTL get_param mdc.*.import) =~ connect_flags.*overstriping ]] ||
1628 skip "server does not support overstriping"
1630 test_mkdir -p $DIR/$tdir
1632 $LFS setstripe -o $osts $DIR/$tdir/$tfile || error "setstripe failed"
1633 local getstripe=$($LFS getstripe $DIR/$tdir/$tfile)
1636 # Strip getstripe output to a space separated list of OSTs
1637 local getstripe_osts=$(echo "$getstripe" | sed -e '1,/obdidx/d' |\
1638 awk '{print $1}' | tr '\n' ' ' | sed -e 's/[[:space:]]*$//')
1639 [ "$getstripe_osts" = "${osts//,/ }" ] ||
1640 error "stripes not on specified OSTs"
1642 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=4 || error "dd failed"
1644 run_test 27cc "two stripes on the same OST"
1647 [[ $OSTCOUNT -lt 2 ]] && skip_env "skipping 2-stripe test"
1648 [[ $($LCTL get_param mdc.*.import) =~ connect_flags.*overstriping ]] ||
1649 skip "server does not support overstriping"
1650 test_mkdir -p $DIR/$tdir
1651 local osts="0,1,1,0"
1652 $LFS setstripe -o $osts $DIR/$tdir/$tfile || error "setstripe failed"
1653 local getstripe=$($LFS getstripe $DIR/$tdir/$tfile)
1656 # Strip getstripe output to a space separated list of OSTs
1657 local getstripe_osts=$(echo "$getstripe" | sed -e '1,/obdidx/d' |\
1658 awk '{print $1}' | tr '\n' ' ' | sed -e 's/[[:space:]]*$//')
1659 [ "$getstripe_osts" = "${osts//,/ }" ] ||
1660 error "stripes not on specified OSTs"
1662 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=4 || error "dd failed"
1664 run_test 27cd "four stripes on two OSTs"
1667 [[ $OSTCOUNT -ge $(($LOV_MAX_STRIPE_COUNT / 2)) ]] &&
1668 skip_env "too many osts, skipping"
1669 [[ $($LCTL get_param mdc.*.import) =~ connect_flags.*overstriping ]] ||
1670 skip "server does not support overstriping"
1671 # We do one more stripe than we have OSTs
1672 [ $OSTCOUNT -lt 159 ] || large_xattr_enabled ||
1673 skip_env "ea_inode feature disabled"
1675 test_mkdir -p $DIR/$tdir
1677 for i in $(seq 0 $OSTCOUNT);
1680 if [ $i -ne $OSTCOUNT ]; then
1684 $LFS setstripe -o $osts $DIR/$tdir/$tfile || error "setstripe failed"
1685 local getstripe=$($LFS getstripe $DIR/$tdir/$tfile)
1688 # Strip getstripe output to a space separated list of OSTs
1689 local getstripe_osts=$(echo "$getstripe" | sed -e '1,/obdidx/d' |\
1690 awk '{print $1}' | tr '\n' ' ' | sed -e 's/[[:space:]]*$//')
1691 [ "$getstripe_osts" = "${osts//,/ }" ] ||
1692 error "stripes not on specified OSTs"
1694 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=4 || error "dd failed"
1696 run_test 27ce "more stripes than OSTs with -o"
1699 local osp_proc="osp.$FSNAME-OST0000-osc-MDT000*.active"
1702 test_mkdir -p $DIR/$tdir || error "failed to mkdir $DIR/$tdir"
1703 do_facet $SINGLEMDS "$LCTL set_param -n $osp_proc=0"
1704 stack_trap "do_facet $SINGLEMDS $LCTL set_param -n $osp_proc=1" EXIT
1705 wait_update_facet $SINGLEMDS "$LCTL get_param -n $osp_proc | grep 1" ||
1706 error "failed to set $osp_proc=0"
1708 $LFS setstripe -o 0 $DIR/$tdir/$tfile &
1711 do_facet $SINGLEMDS "$LCTL set_param -n $osp_proc=1"
1712 wait_update_facet $SINGLEMDS "$LCTL get_param -n $osp_proc | grep 0" ||
1713 error "failed to set $osp_proc=1"
1716 error "should return error due to $osp_proc=0"
1718 run_test 27cf "'setstripe -o' on inactive OSTs should return error"
1721 test_mkdir $DIR/$tdir
1722 $LFS setstripe -c 0 -i -1 -S 0 $DIR/$tdir/$tfile ||
1723 error "setstripe failed"
1724 $CHECKSTAT -t file $DIR/$tdir/$tfile || error "checkstat failed"
1725 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=4k count=4 || error "dd failed"
1727 run_test 27d "create file with default settings"
1730 # LU-5839 adds check for existed layout before setting it
1731 [[ $MDS1_VERSION -lt $(version_code 2.7.56) ]] &&
1732 skip "Need MDS version at least 2.7.56"
1734 test_mkdir $DIR/$tdir
1735 $LFS setstripe -c 2 $DIR/$tdir/$tfile || error "setstripe failed"
1736 $LFS setstripe -c 2 $DIR/$tdir/$tfile && error "setstripe worked twice"
1737 $CHECKSTAT -t file $DIR/$tdir/$tfile || error "checkstat failed"
1739 run_test 27e "setstripe existing file (should return error)"
1742 test_mkdir $DIR/$tdir
1743 $LFS setstripe -S 100 -i 0 -c 1 $DIR/$tdir/$tfile &&
1744 error "$LFS setstripe $DIR/$tdir/$tfile failed"
1745 $CHECKSTAT -t file $DIR/$tdir/$tfile &&
1746 error "$CHECKSTAT -t file $DIR/$tdir/$tfile should fail"
1747 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=4k count=4 || error "dd failed"
1748 $LFS getstripe $DIR/$tdir/$tfile || error "$LFS getstripe failed"
1750 run_test 27f "setstripe with bad stripe size (should return error)"
1753 test_mkdir $DIR/$tdir
1754 $MCREATE $DIR/$tdir/$tfile || error "mcreate failed"
1755 $LFS getstripe $DIR/$tdir/$tfile 2>&1 | grep "no stripe info" ||
1756 error "$DIR/$tdir/$tfile has object"
1758 run_test 27g "$LFS getstripe with no objects"
1761 test_mkdir $DIR/$tdir
1762 touch $DIR/$tdir/$tfile || error "touch failed"
1763 ln -s bogus $DIR/$tdir/$tfile.2 || error "ln failed"
1764 $LFS getstripe -m $DIR/$tdir/$tfile $DIR/$tdir/$tfile.2
1766 (( rc == 2 )) || error "getstripe did not return ENOENT"
1768 run_test 27ga "$LFS getstripe with missing file (should return error)"
1771 test_mkdir $DIR/$tdir
1772 touch $DIR/$tdir/$tfile || error "touch failed"
1773 [[ $($LFS getstripe -c $DIR/$tdir/$tfile) -gt 0 ]] ||
1774 error "missing objects"
1776 run_test 27i "$LFS getstripe with some objects"
1779 test_mkdir $DIR/$tdir
1780 $LFS setstripe -i $OSTCOUNT $DIR/$tdir/$tfile &&
1781 error "setstripe failed" || true
1783 run_test 27j "setstripe with bad stripe offset (should return error)"
1785 test_27k() { # bug 2844
1786 test_mkdir $DIR/$tdir
1787 local file=$DIR/$tdir/$tfile
1788 local ll_max_blksize=$((4 * 1024 * 1024))
1789 $LFS setstripe -S 67108864 $file || error "setstripe failed"
1790 local blksize=$(stat $file | awk '/IO Block:/ { print $7 }')
1791 [ $blksize -le $ll_max_blksize ] || error "1:$blksize > $ll_max_blksize"
1792 dd if=/dev/zero of=$file bs=4k count=1
1793 blksize=$(stat $file | awk '/IO Block:/ { print $7 }')
1794 [ $blksize -le $ll_max_blksize ] || error "2:$blksize > $ll_max_blksize"
1796 run_test 27k "limit i_blksize for broken user apps"
1799 mcreate $DIR/$tfile || error "creating file"
1800 $RUNAS $LFS setstripe -c 1 $DIR/$tfile &&
1801 error "setstripe should have failed" || true
1803 run_test 27l "check setstripe permissions (should return error)"
1806 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
1808 [ -n "$RCLIENTS" -o -n "$MOUNT_2" ] &&
1809 skip_env "multiple clients -- skipping"
1811 ORIGFREE=$($LCTL get_param -n lov.$FSNAME-clilov-*.kbytesavail |
1813 if [[ $ORIGFREE -gt $MAXFREE ]]; then
1814 skip "$ORIGFREE > $MAXFREE skipping out-of-space test on OST0"
1816 stack_trap simple_cleanup_common
1817 test_mkdir $DIR/$tdir
1818 $LFS setstripe -i 0 -c 1 $DIR/$tdir/$tfile.1
1819 dd if=/dev/zero of=$DIR/$tdir/$tfile.1 bs=1024 count=$MAXFREE &&
1820 error "dd should fill OST0"
1822 while $LFS setstripe -i 0 -c 1 $DIR/$tdir/$tfile.$i; do
1824 [ $i -gt 256 ] && break
1827 touch $DIR/$tdir/$tfile.$i
1828 [ $($LFS getstripe $DIR/$tdir/$tfile.$i | grep -A 10 obdidx |
1829 awk '{print $1}'| grep -w "0") ] &&
1830 error "OST0 was full but new created file still use it"
1832 touch $DIR/$tdir/$tfile.$i
1833 [ $($LFS getstripe $DIR/$tdir/$tfile.$i | grep -A 10 obdidx |
1834 awk '{print $1}'| grep -w "0") ] &&
1835 error "OST0 was full but new created file still use it" || true
1837 run_test 27m "create file while OST0 was full"
1839 # OSCs keep a NOSPC flag that will be reset after ~5s (qos_maxage)
1840 # if the OST isn't full anymore.
1842 local ostidx=${1:-""}
1847 local list=$(comma_list $(osts_nodes))
1848 [ "$ostidx" ] && list=$(facet_host ost$((ostidx + 1)))
1850 do_nodes $list lctl set_param fail_loc=0
1851 wait_delete_completed # initiate all OST_DESTROYs from MDS to OST
1852 delay=$(do_facet $SINGLEMDS lctl get_param -n lov.*.qos_maxage |
1853 awk '{print $1 * 2;exit;}')
1854 get_prealloc="$LCTL get_param -n osc.*MDT*.prealloc_status |
1856 wait_update_facet $SINGLEMDS "$get_prealloc" "" $delay
1860 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
1861 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1862 remote_mds_nodsh && skip "remote MDS with nodsh"
1863 remote_ost_nodsh && skip "remote OST with nodsh"
1866 rm -f $DIR/$tdir/$tfile
1867 exhaust_precreations 0 0x80000215
1868 $LFS setstripe -c -1 $DIR/$tdir || error "setstripe failed"
1869 touch $DIR/$tdir/$tfile || error "touch failed"
1870 $LFS getstripe $DIR/$tdir/$tfile
1873 run_test 27n "create file with some full OSTs"
1876 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
1877 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1878 remote_mds_nodsh && skip "remote MDS with nodsh"
1879 remote_ost_nodsh && skip "remote OST with nodsh"
1882 rm -f $DIR/$tdir/$tfile
1883 exhaust_all_precreations 0x215
1885 touch $DIR/$tdir/$tfile && error "able to create $DIR/$tdir/$tfile"
1890 run_test 27o "create file with all full OSTs (should error)"
1892 function create_and_checktime() {
1897 for ((i=0; i < $loops; i++)); do
1898 local start=$SECONDS
1899 multiop $fname-$i Oc
1900 ((SECONDS-start < TIMEOUT)) ||
1901 error "creation took " $((SECONDS-$start)) && return 1
1906 local mdts=$(comma_list $(mdts_nodes))
1908 [ $MDS1_VERSION -lt $(version_code 2.13.57) ] &&
1909 skip "Need MDS version at least 2.13.57"
1911 local f0=$DIR/${tfile}-0
1912 local f1=$DIR/${tfile}-1
1914 wait_delete_completed
1916 # refill precreated objects
1917 $LFS setstripe -i0 -c1 $f0
1919 saved=$(do_facet mds1 $LCTL get_param -n lov.*0000*.qos_threshold_rr)
1920 # force QoS allocation policy
1921 do_nodes $mdts $LCTL set_param lov.*.qos_threshold_rr=0%
1922 stack_trap "do_nodes $mdts $LCTL set_param \
1923 lov.*.qos_threshold_rr=$saved" EXIT
1926 # one OST is unavailable, but still have few objects preallocated
1928 stack_trap "start ost1 $(ostdevname 1) $OST_MOUNT_OPTS; \
1929 rm -rf $f1 $DIR/$tdir*" EXIT
1931 for ((i=0; i < 7; i++)); do
1932 mkdir $DIR/$tdir$i || error "can't create dir"
1933 $LFS setstripe -c$((OSTCOUNT-1)) $DIR/$tdir$i ||
1934 error "can't set striping"
1936 for ((i=0; i < 7; i++)); do
1937 create_and_checktime $DIR/$tdir$i/$tfile 100 &
1941 run_test 27oo "don't let few threads to reserve too many objects"
1944 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
1945 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1946 remote_mds_nodsh && skip "remote MDS with nodsh"
1947 remote_ost_nodsh && skip "remote OST with nodsh"
1950 rm -f $DIR/$tdir/$tfile
1951 test_mkdir $DIR/$tdir
1953 $MCREATE $DIR/$tdir/$tfile || error "mcreate failed"
1954 $TRUNCATE $DIR/$tdir/$tfile 80000000 || error "truncate failed"
1955 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat failed"
1957 exhaust_precreations 0 0x80000215
1958 echo foo >> $DIR/$tdir/$tfile || error "append failed"
1959 $CHECKSTAT -s 80000004 $DIR/$tdir/$tfile || error "checkstat failed"
1960 $LFS getstripe $DIR/$tdir/$tfile
1964 run_test 27p "append to a truncated file with some full OSTs"
1967 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
1968 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1969 remote_mds_nodsh && skip "remote MDS with nodsh"
1970 remote_ost_nodsh && skip "remote OST with nodsh"
1973 rm -f $DIR/$tdir/$tfile
1975 mkdir_on_mdt0 $DIR/$tdir
1976 $MCREATE $DIR/$tdir/$tfile || error "mcreate $DIR/$tdir/$tfile failed"
1977 $TRUNCATE $DIR/$tdir/$tfile 80000000 ||
1978 error "truncate $DIR/$tdir/$tfile failed"
1979 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat failed"
1981 exhaust_all_precreations 0x215
1983 echo foo >> $DIR/$tdir/$tfile && error "append succeeded"
1984 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat 2 failed"
1988 run_test 27q "append to truncated file with all OSTs full (should error)"
1991 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
1992 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1993 remote_mds_nodsh && skip "remote MDS with nodsh"
1994 remote_ost_nodsh && skip "remote OST with nodsh"
1997 rm -f $DIR/$tdir/$tfile
1998 exhaust_precreations 0 0x80000215
2000 $LFS setstripe -i 0 -c 2 $DIR/$tdir/$tfile || error "setstripe failed"
2004 run_test 27r "stripe file with some full OSTs (shouldn't LBUG) ="
2006 test_27s() { # bug 10725
2007 test_mkdir $DIR/$tdir
2008 local stripe_size=$((4096 * 1024 * 1024)) # 2^32
2009 local stripe_count=0
2010 [ $OSTCOUNT -eq 1 ] || stripe_count=2
2011 $LFS setstripe -S $stripe_size -c $stripe_count $DIR/$tdir &&
2012 error "stripe width >= 2^32 succeeded" || true
2015 run_test 27s "lsm_xfersize overflow (should error) (bug 10725)"
2017 test_27t() { # bug 10864
2022 $WLFS getstripe $tfile
2025 run_test 27t "check that utils parse path correctly"
2027 test_27u() { # bug 4900
2028 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
2029 remote_mds_nodsh && skip "remote MDS with nodsh"
2032 local list=$(comma_list $(mdts_nodes))
2034 #define OBD_FAIL_MDS_OSC_PRECREATE 0x139
2035 do_nodes $list $LCTL set_param fail_loc=0x139
2036 test_mkdir -p $DIR/$tdir
2037 stack_trap "simple_cleanup_common 1000"
2038 createmany -o $DIR/$tdir/$tfile 1000
2039 do_nodes $list $LCTL set_param fail_loc=0
2041 TLOG=$TMP/$tfile.getstripe
2042 $LFS getstripe $DIR/$tdir > $TLOG
2043 OBJS=$(awk -vobj=0 '($1 == 0) { obj += 1 } END { print obj; }' $TLOG)
2044 [[ $OBJS -gt 0 ]] &&
2045 error "$OBJS objects created on OST-0. See $TLOG" ||
2048 run_test 27u "skip object creation on OSC w/o objects"
2050 test_27v() { # bug 4900
2051 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
2052 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2053 remote_mds_nodsh && skip "remote MDS with nodsh"
2054 remote_ost_nodsh && skip "remote OST with nodsh"
2056 exhaust_all_precreations 0x215
2059 $LFS setstripe -c 1 $DIR/$tdir # 1 stripe / file
2061 touch $DIR/$tdir/$tfile
2062 #define OBD_FAIL_TGT_DELAY_PRECREATE 0x705
2064 for (( i=1; i < OSTCOUNT; i++ )); do
2065 do_facet ost$i lctl set_param fail_loc=0x705
2067 local START=`date +%s`
2068 createmany -o $DIR/$tdir/$tfile 32
2070 local FINISH=`date +%s`
2071 local TIMEOUT=`lctl get_param -n timeout`
2072 local PROCESS=$((FINISH - START))
2073 [ $PROCESS -ge $((TIMEOUT / 2)) ] && \
2074 error "$FINISH - $START >= $TIMEOUT / 2"
2075 sleep $((TIMEOUT / 2 - PROCESS))
2078 run_test 27v "skip object creation on slow OST"
2080 test_27w() { # bug 10997
2081 test_mkdir $DIR/$tdir
2082 $LFS setstripe -S 65536 $DIR/$tdir/f0 || error "setstripe failed"
2083 [ $($LFS getstripe -S $DIR/$tdir/f0) -ne 65536 ] &&
2084 error "stripe size $size != 65536" || true
2085 [ $($LFS getstripe -d $DIR/$tdir | grep -c "stripe_count") -eq 0 ] &&
2086 error "$LFS getstripe -d $DIR/$tdir no 'stripe_count'" || true
2088 run_test 27w "check $LFS setstripe -S and getstrip -d options"
2091 [[ $OSTCOUNT -lt 2 ]] &&
2092 skip_env "skipping multiple stripe count/offset test"
2094 test_mkdir $DIR/$tdir
2095 for i in $(seq 1 $OSTCOUNT); do
2097 $LFS setstripe -c $i -i $offset $DIR/$tdir/f$i ||
2098 error "setstripe -c $i -i $offset failed"
2099 count=$($LFS getstripe -c $DIR/$tdir/f$i)
2100 index=$($LFS getstripe -i $DIR/$tdir/f$i)
2101 [ $count -ne $i ] && error "stripe count $count != $i" || true
2102 [ $index -ne $offset ] &&
2103 error "stripe offset $index != $offset" || true
2106 run_test 27wa "check $LFS setstripe -c -i options"
2109 remote_ost_nodsh && skip "remote OST with nodsh"
2110 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
2111 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2113 OFFSET=$(($OSTCOUNT - 1))
2115 local OST=$(ostname_from_index $OSTIDX)
2117 test_mkdir $DIR/$tdir
2118 $LFS setstripe -c 1 $DIR/$tdir # 1 stripe per file
2119 do_facet ost$((OSTIDX + 1)) lctl set_param -n obdfilter.$OST.degraded 1
2121 createmany -o $DIR/$tdir/$tfile $OSTCOUNT
2122 for i in $(seq 0 $OFFSET); do
2123 [ $($LFS getstripe $DIR/$tdir/$tfile$i | grep -A 10 obdidx |
2124 awk '{print $1}' | grep -w "$OSTIDX") ] &&
2125 error "OST0 was degraded but new created file still use it"
2127 do_facet ost$((OSTIDX + 1)) lctl set_param -n obdfilter.$OST.degraded 0
2129 run_test 27x "create files while OST0 is degraded"
2132 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
2133 remote_mds_nodsh && skip "remote MDS with nodsh"
2134 remote_ost_nodsh && skip "remote OST with nodsh"
2135 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2137 local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS $FSNAME-OST0000)
2138 local last_id=$(do_facet $SINGLEMDS lctl get_param -n \
2139 osp.$mdtosc.prealloc_last_id)
2140 local next_id=$(do_facet $SINGLEMDS lctl get_param -n \
2141 osp.$mdtosc.prealloc_next_id)
2142 local fcount=$((last_id - next_id))
2143 [[ $fcount -eq 0 ]] && skip "not enough space on OST0"
2144 [[ $fcount -gt $OSTCOUNT ]] && fcount=$OSTCOUNT
2146 local MDS_OSCS=$(do_facet $SINGLEMDS lctl dl |
2147 awk '/[oO][sS][cC].*md[ts]/ { print $4 }')
2148 local OST_DEACTIVE_IDX=-1
2153 for OSC in $MDS_OSCS; do
2154 OST=$(osc_to_ost $OSC)
2155 OSTIDX=$(index_from_ostuuid $OST)
2156 if [ $OST_DEACTIVE_IDX == -1 ]; then
2157 OST_DEACTIVE_IDX=$OSTIDX
2159 if [ $OSTIDX != $OST_DEACTIVE_IDX ]; then
2160 echo $OSC "is Deactivated:"
2161 do_facet $SINGLEMDS lctl --device %$OSC deactivate
2165 OSTIDX=$(index_from_ostuuid $OST)
2166 test_mkdir $DIR/$tdir
2167 $LFS setstripe -c 1 $DIR/$tdir # 1 stripe / file
2169 for OSC in $MDS_OSCS; do
2170 OST=$(osc_to_ost $OSC)
2171 OSTIDX=$(index_from_ostuuid $OST)
2172 if [ $OSTIDX == $OST_DEACTIVE_IDX ]; then
2173 echo $OST "is degraded:"
2174 do_facet ost$((OSTIDX+1)) lctl set_param -n \
2175 obdfilter.$OST.degraded=1
2180 createmany -o $DIR/$tdir/$tfile $fcount
2182 for OSC in $MDS_OSCS; do
2183 OST=$(osc_to_ost $OSC)
2184 OSTIDX=$(index_from_ostuuid $OST)
2185 if [ $OSTIDX == $OST_DEACTIVE_IDX ]; then
2186 echo $OST "is recovered from degraded:"
2187 do_facet ost$((OSTIDX+1)) lctl set_param -n \
2188 obdfilter.$OST.degraded=0
2190 do_facet $SINGLEMDS lctl --device %$OSC activate
2194 # all osp devices get activated, hence -1 stripe count restored
2195 local stripe_count=0
2197 # sleep 2*lod_qos_maxage seconds waiting for lod qos to notice osp
2198 # devices get activated.
2200 $LFS setstripe -c -1 $DIR/$tfile
2201 stripe_count=$($LFS getstripe -c $DIR/$tfile)
2203 [ $stripe_count -ne $OSTCOUNT ] &&
2204 error "Of $OSTCOUNT OSTs, only $stripe_count is available"
2207 run_test 27y "create files while OST0 is degraded and the rest inactive"
2213 lmm_count=$($LFS getstripe -c $1)
2214 lmm_seq=$($LFS getstripe -v $1 | awk '/lmm_seq/ { print $2 }')
2215 lmm_oid=$($LFS getstripe -v $1 | awk '/lmm_object_id/ { print $2 }')
2217 local old_ifs="$IFS"
2219 fid=($($LFS path2fid $1))
2222 log "FID seq ${fid[1]}, oid ${fid[2]} ver ${fid[3]}"
2223 log "LOV seq $lmm_seq, oid $lmm_oid, count: $lmm_count"
2225 # compare lmm_seq and lu_fid->f_seq
2226 [ $lmm_seq = ${fid[1]} ] || { error "SEQ mismatch"; return 1; }
2227 # compare lmm_object_id and lu_fid->oid
2228 [ $lmm_oid = ${fid[2]} ] || { error "OID mismatch"; return 2; }
2230 # check the trusted.fid attribute of the OST objects of the file
2231 local have_obdidx=false
2233 $LFS getstripe $1 | while read obdidx oid hex seq; do
2234 # skip lines up to and including "obdidx"
2235 [ -z "$obdidx" ] && break
2236 [ "$obdidx" = "obdidx" ] && have_obdidx=true && continue
2237 $have_obdidx || continue
2239 local ost=$((obdidx + 1))
2240 local dev=$(ostdevname $ost)
2243 log "want: stripe:$stripe_nr ost:$obdidx oid:$oid/$hex seq:$seq"
2245 seq=$(echo $seq | sed -e "s/^0x//g")
2246 if [ $seq == 0 ] || [ $(facet_fstype ost$ost) == zfs ]; then
2247 oid_hex=$(echo $oid)
2249 oid_hex=$(echo $hex | sed -e "s/^0x//g")
2251 local obj_file="O/$seq/d$((oid %32))/$oid_hex"
2255 # Don't unmount/remount the OSTs if we don't need to do that.
2256 # LU-2577 changes filter_fid to be smaller, so debugfs needs
2257 # update too, until that use mount/ll_decode_filter_fid/mount.
2258 # Re-enable when debugfs will understand new filter_fid.
2260 if [ $(facet_fstype ost$ost) == ldiskfs ]; then
2261 ff=$(do_facet ost$ost "$DEBUGFS -c -R 'stat $obj_file' \
2262 $dev 2>/dev/null" | grep "parent=")
2264 if [ -z "$ff" ]; then
2266 mount_fstype ost$ost
2267 ff=$(do_facet ost$ost $LL_DECODE_FILTER_FID \
2268 $(facet_mntpt ost$ost)/$obj_file)
2269 unmount_fstype ost$ost
2270 start ost$ost $dev $OST_MOUNT_OPTS
2274 [ -z "$ff" ] && error "$obj_file: no filter_fid info"
2276 echo "$ff" | sed -e 's#.*objid=#got: objid=#'
2278 # /mnt/O/0/d23/23: objid=23 seq=0 parent=[0x200000400:0x1e:0x1]
2279 # fid: objid=23 seq=0 parent=[0x200000400:0x1e:0x0] stripe=1
2281 # fid: parent=[0x200000400:0x1e:0x0] stripe=1 stripe_count=2 \
2282 # stripe_size=1048576 component_id=1 component_start=0 \
2283 # component_end=33554432
2284 local ff_parent=$(sed -e 's/.*parent=.//' <<<$ff)
2285 local ff_pseq=$(cut -d: -f1 <<<$ff_parent)
2286 local ff_poid=$(cut -d: -f2 <<<$ff_parent)
2288 if grep -q 'stripe=' <<<$ff; then
2289 ff_pstripe=$(sed -e 's/.*stripe=//' -e 's/ .*//' <<<$ff)
2291 # $LL_DECODE_FILTER_FID does not print "stripe="; look
2292 # into f_ver in this case. See comment on ff_parent.
2293 ff_pstripe=$(cut -d: -f3 <<<$ff_parent | sed -e 's/]//')
2296 # compare lmm_seq and filter_fid->ff_parent.f_seq
2297 [ $ff_pseq = $lmm_seq ] ||
2298 error "FF parent SEQ $ff_pseq != $lmm_seq"
2299 # compare lmm_object_id and filter_fid->ff_parent.f_oid
2300 [ $ff_poid = $lmm_oid ] ||
2301 error "FF parent OID $ff_poid != $lmm_oid"
2302 (($ff_pstripe == $stripe_nr)) ||
2303 error "FF stripe $ff_pstripe != $stripe_nr"
2305 stripe_nr=$((stripe_nr + 1))
2306 [ $CLIENT_VERSION -lt $(version_code 2.9.55) ] &&
2308 if grep -q 'stripe_count=' <<<$ff; then
2309 local ff_scnt=$(sed -e 's/.*stripe_count=//' \
2310 -e 's/ .*//' <<<$ff)
2311 [ $lmm_count = $ff_scnt ] ||
2312 error "FF stripe count $lmm_count != $ff_scnt"
2318 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2319 remote_ost_nodsh && skip "remote OST with nodsh"
2321 test_mkdir $DIR/$tdir
2322 $LFS setstripe -c 1 -i 0 -S 64k $DIR/$tdir/$tfile-1 ||
2323 { error "setstripe -c -1 failed"; return 1; }
2324 # We need to send a write to every object to get parent FID info set.
2325 # This _should_ also work for setattr, but does not currently.
2326 # touch $DIR/$tdir/$tfile-1 ||
2327 dd if=/dev/zero of=$DIR/$tdir/$tfile-1 bs=1M count=1 ||
2328 { error "dd $tfile-1 failed"; return 2; }
2329 $LFS setstripe -c -1 -i $((OSTCOUNT - 1)) -S 1M $DIR/$tdir/$tfile-2 ||
2330 { error "setstripe -c -1 failed"; return 3; }
2331 dd if=/dev/zero of=$DIR/$tdir/$tfile-2 bs=1M count=$OSTCOUNT ||
2332 { error "dd $tfile-2 failed"; return 4; }
2334 # make sure write RPCs have been sent to OSTs
2337 check_seq_oid $DIR/$tdir/$tfile-1 || return 5
2338 check_seq_oid $DIR/$tdir/$tfile-2 || return 6
2340 run_test 27z "check SEQ/OID on the MDT and OST filesystems"
2342 test_27A() { # b=19102
2343 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2345 save_layout_restore_at_exit $MOUNT
2346 $LFS setstripe -c 0 -i -1 -S 0 $MOUNT
2347 wait_update $HOSTNAME "$LFS getstripe -c $MOUNT | sed 's/ *//g'" "1" 20 ||
2348 error "stripe count $($LFS getstripe -c $MOUNT) != 1"
2349 local default_size=$($LFS getstripe -S $MOUNT)
2350 local default_offset=$($LFS getstripe -i $MOUNT)
2351 local dsize=$(do_facet $SINGLEMDS \
2352 "$LCTL get_param -n lod.$(facet_svc $SINGLEMDS)*.stripesize")
2353 [ $default_size -eq $dsize ] ||
2354 error "stripe size $default_size != $dsize"
2355 [ $default_offset -eq -1 ] ||
2356 error "stripe offset $default_offset != -1"
2358 run_test 27A "check filesystem-wide default LOV EA values"
2360 test_27B() { # LU-2523
2361 test_mkdir $DIR/$tdir
2362 rm -f $DIR/$tdir/f0 $DIR/$tdir/f1
2364 # open f1 with O_LOV_DELAY_CREATE
2366 # call setstripe ioctl on open file descriptor for f1
2368 multiop $DIR/$tdir/f1 oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:nB1c \
2372 # open f1 with O_LOV_DELAY_CREATE
2374 # call setstripe ioctl on open file descriptor for f1
2376 multiop $DIR/$tdir/f1 oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:uB1c
2378 # Allow multiop to fail in imitation of NFS's busted semantics.
2381 run_test 27B "call setstripe on open unlinked file/rename victim"
2383 # 27C family tests full striping and overstriping
2384 test_27Ca() { #LU-2871
2385 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
2393 test_mkdir $DIR/$tdir
2395 for i in $(seq 0 $((OSTCOUNT - 1))); do
2396 # set stripe across all OSTs starting from OST$i
2397 $LFS setstripe -i $i -c -1 $tfile$i
2398 # get striping information
2399 ost_idx=($($LFS getstripe $tfile$i |
2400 tail -n $((OSTCOUNT + 1)) | awk '{print $1}'))
2404 [ ${#ost_idx[@]} -eq $OSTCOUNT ] ||
2405 error "${#ost_idx[@]} != $OSTCOUNT"
2407 for index in $(seq 0 $((OSTCOUNT - 1))); do
2409 for j in $(echo ${ost_idx[@]}); do
2410 if [ $index -eq $j ]; then
2416 error "Can not find $index in ${ost_idx[@]}"
2420 run_test 27Ca "check full striping across all OSTs"
2423 [[ $($LCTL get_param mdc.*.import) =~ connect_flags.*overstriping ]] ||
2424 skip "server does not support overstriping"
2425 [[ $OSTCOUNT -ge $(($LOV_MAX_STRIPE_COUNT / 2)) ]] &&
2426 skip_env "too many osts, skipping"
2428 test_mkdir -p $DIR/$tdir
2429 local setcount=$(($OSTCOUNT * 2))
2430 [ $setcount -lt 160 ] || large_xattr_enabled ||
2431 skip_env "ea_inode feature disabled"
2433 $LFS setstripe -C $setcount $DIR/$tdir/$tfile ||
2434 error "setstripe failed"
2436 local count=$($LFS getstripe -c $DIR/$tdir/$tfile)
2437 [ $count -eq $setcount ] ||
2438 error "stripe count $count, should be $setcount"
2440 $LFS getstripe $DIR/$tdir/$tfile 2>&1 | grep "overstriped" ||
2441 error "overstriped should be set in pattern"
2443 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=4 conv=notrunc ||
2446 run_test 27Cb "more stripes than OSTs with -C"
2449 [[ $($LCTL get_param mdc.*.import) =~ connect_flags.*overstriping ]] ||
2450 skip "server does not support overstriping"
2451 [[ $OSTCOUNT -lt 2 ]] && skip_env "need > 1 OST"
2453 test_mkdir -p $DIR/$tdir
2454 local setcount=$(($OSTCOUNT - 1))
2456 [ $setcount -lt 160 ] || large_xattr_enabled ||
2457 skip_env "ea_inode feature disabled"
2459 $LFS setstripe -C $setcount $DIR/$tdir/$tfile ||
2460 error "setstripe failed"
2462 local count=$($LFS getstripe -c $DIR/$tdir/$tfile)
2463 [ $count -eq $setcount ] ||
2464 error "stripe count $count, should be $setcount"
2466 $LFS getstripe $DIR/$tdir/$tfile 2>&1 | grep "overstriped" &&
2467 error "overstriped should not be set in pattern"
2469 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=4 conv=notrunc ||
2472 run_test 27Cc "fewer stripes than OSTs does not set overstriping"
2475 [[ $($LCTL get_param mdc.*.import) =~ connect_flags.*overstriping ]] ||
2476 skip "server does not support overstriping"
2477 [[ $OSTCOUNT -lt 2 ]] && skip_env "need > 1 OST"
2478 large_xattr_enabled || skip_env "ea_inode feature disabled"
2480 test_mkdir -p $DIR/$tdir
2481 local setcount=$LOV_MAX_STRIPE_COUNT
2483 $LFS setstripe -C $setcount $DIR/$tdir/$tfile ||
2484 error "setstripe failed"
2486 local count=$($LFS getstripe -c $DIR/$tdir/$tfile)
2487 [ $count -eq $setcount ] ||
2488 error "stripe count $count, should be $setcount"
2490 $LFS getstripe $DIR/$tdir/$tfile 2>&1 | grep "overstriped" ||
2491 error "overstriped should be set in pattern"
2493 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=4 conv=notrunc ||
2496 rm -f $DIR/$tdir/$tfile || error "Delete $tfile failed"
2498 run_test 27Cd "test maximum stripe count"
2501 [[ $($LCTL get_param mdc.*.import) =~ connect_flags.*overstriping ]] ||
2502 skip "server does not support overstriping"
2503 test_mkdir -p $DIR/$tdir
2505 pool_add $TESTNAME || error "Pool creation failed"
2506 pool_add_targets $TESTNAME 0 || error "pool_add_targets failed"
2510 $LFS setstripe -C $setcount -p "$TESTNAME" $DIR/$tdir/$tfile ||
2511 error "setstripe failed"
2513 local count=$($LFS getstripe -c $DIR/$tdir/$tfile)
2514 [ $count -eq $setcount ] ||
2515 error "stripe count $count, should be $setcount"
2517 $LFS getstripe $DIR/$tdir/$tfile 2>&1 | grep "overstriped" ||
2518 error "overstriped should be set in pattern"
2520 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=4 conv=notrunc ||
2523 rm -f $DIR/$tdir/$tfile || error "Delete $tfile failed"
2525 run_test 27Ce "test pool with overstriping"
2528 [[ $($LCTL get_param mdc.*.import) =~ connect_flags.*overstriping ]] ||
2529 skip "server does not support overstriping"
2530 [[ $OSTCOUNT -ge $(($LOV_MAX_STRIPE_COUNT / 2)) ]] &&
2531 skip_env "too many osts, skipping"
2533 test_mkdir -p $DIR/$tdir
2535 local setcount=$(($OSTCOUNT * 2))
2536 [ $setcount -lt 160 ] || large_xattr_enabled ||
2537 skip_env "ea_inode feature disabled"
2539 $LFS setstripe -C $setcount $DIR/$tdir/ ||
2540 error "setstripe failed"
2542 echo 1 > $DIR/$tdir/$tfile
2544 local count=$($LFS getstripe -c $DIR/$tdir/$tfile)
2545 [ $count -eq $setcount ] ||
2546 error "stripe count $count, should be $setcount"
2548 $LFS getstripe $DIR/$tdir/$tfile 2>&1 | grep "overstriped" ||
2549 error "overstriped should be set in pattern"
2551 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=4 conv=notrunc ||
2554 rm -f $DIR/$tdir/$tfile || error "Delete $tfile failed"
2556 run_test 27Cf "test default inheritance with overstriping"
2559 [ $OSTCOUNT -lt 2 ] && skip_env "needs >= 2 OSTs"
2560 [ -n "$FILESET" ] && skip "SKIP due to FILESET set"
2561 remote_mds_nodsh && skip "remote MDS with nodsh"
2563 local POOL=${POOL:-testpool}
2565 local last_ost=$(($OSTCOUNT - 1))
2567 local ost_list=$(seq $first_ost $ost_step $last_ost)
2568 local ost_range="$first_ost $last_ost $ost_step"
2570 test_mkdir $DIR/$tdir
2571 pool_add $POOL || error "pool_add failed"
2572 pool_add_targets $POOL $ost_range || error "pool_add_targets failed"
2575 [ $MDS1_VERSION -lt $(version_code 2.8.55) ] &&
2577 [ $MDS1_VERSION -lt $(version_code 2.9.55) ] ||
2578 [ $CLIENT_VERSION -lt $(version_code 2.9.55) ] &&
2579 skip27D+=" -s 30,31"
2580 [[ ! $($LCTL get_param mdc.*.import) =~ connect_flags.*overstriping ||
2581 $OSTCOUNT -ge $(($LOV_MAX_STRIPE_COUNT / 2)) ]] &&
2582 skip27D+=" -s 32,33"
2583 [[ $MDS_VERSION -lt $(version_code $SEL_VER) ]] &&
2585 llapi_layout_test -d$DIR/$tdir -p$POOL -o$OSTCOUNT $skip27D ||
2586 error "llapi_layout_test failed"
2588 destroy_test_pools || error "destroy test pools failed"
2590 run_test 27D "validate llapi_layout API"
2592 # Verify that default_easize is increased from its initial value after
2593 # accessing a widely striped file.
2595 [ $OSTCOUNT -lt 2 ] && skip_env "needs >= 2 OSTs"
2596 [ $CLIENT_VERSION -lt $(version_code 2.5.57) ] &&
2597 skip "client does not have LU-3338 fix"
2599 # 72 bytes is the minimum space required to store striping
2600 # information for a file striped across one OST:
2601 # (sizeof(struct lov_user_md_v3) +
2602 # sizeof(struct lov_user_ost_data_v1))
2604 $LCTL set_param -n llite.*.default_easize $min_easize ||
2605 error "lctl set_param failed"
2606 local easize=$($LCTL get_param -n llite.*.default_easize)
2608 [ $easize -eq $min_easize ] ||
2609 error "failed to set default_easize"
2611 $LFS setstripe -c $OSTCOUNT $DIR/$tfile ||
2612 error "setstripe failed"
2613 # In order to ensure stat() call actually talks to MDS we need to
2614 # do something drastic to this file to shake off all lock, e.g.
2615 # rename it (kills lookup lock forcing cache cleaning)
2616 mv $DIR/$tfile $DIR/${tfile}-1
2617 ls -l $DIR/${tfile}-1
2620 easize=$($LCTL get_param -n llite.*.default_easize)
2622 [ $easize -gt $min_easize ] ||
2623 error "default_easize not updated"
2625 run_test 27E "check that default extended attribute size properly increases"
2627 test_27F() { # LU-5346/LU-7975
2628 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2629 [[ $OSTCOUNT -lt 2 ]] && skip "needs >= 2 OSTs"
2630 [[ $MDS1_VERSION -lt $(version_code 2.8.51) ]] &&
2631 skip "Need MDS version at least 2.8.51"
2632 remote_ost_nodsh && skip "remote OST with nodsh"
2634 test_mkdir $DIR/$tdir
2636 $LFS setstripe -c 2 $DIR/$tdir
2638 # stop all OSTs to reproduce situation for LU-7975 ticket
2639 for num in $(seq $OSTCOUNT); do
2643 # open/create f0 with O_LOV_DELAY_CREATE
2644 # truncate f0 to a non-0 size
2646 multiop $DIR/$tdir/f0 oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:T1050000c
2648 $CHECKSTAT -s 1050000 $DIR/$tdir/f0 || error "checkstat failed"
2649 # open/write it again to force delayed layout creation
2650 cat /etc/hosts > $DIR/$tdir/f0 &
2654 for num in $(seq $OSTCOUNT); do
2655 start ost$num $(ostdevname $num) $OST_MOUNT_OPTS ||
2656 error "ost$num failed to start"
2659 wait $catpid || error "cat failed"
2661 cmp /etc/hosts $DIR/$tdir/f0 || error "cmp failed"
2662 [[ $($LFS getstripe -c $DIR/$tdir/f0) == 2 ]] ||
2663 error "wrong stripecount"
2666 run_test 27F "Client resend delayed layout creation with non-zero size"
2668 test_27G() { #LU-10629
2669 [ $MDS1_VERSION -lt $(version_code 2.11.51) ] &&
2670 skip "Need MDS version at least 2.11.51"
2671 [ -n "$FILESET" ] && skip "SKIP due to FILESET set"
2672 remote_mds_nodsh && skip "remote MDS with nodsh"
2673 local POOL=${POOL:-testpool}
2674 local ostrange="0 0 1"
2676 test_mkdir $DIR/$tdir
2677 touch $DIR/$tdir/$tfile.nopool
2678 pool_add $POOL || error "pool_add failed"
2679 pool_add_targets $POOL $ostrange || error "pool_add_targets failed"
2680 $LFS setstripe -p $POOL $DIR/$tdir
2682 local pool=$($LFS getstripe -p $DIR/$tdir)
2684 [ "$pool" = "$POOL" ] || error "Striping failed got '$pool' not '$POOL'"
2685 touch $DIR/$tdir/$tfile.default
2686 $LFS setstripe -E 1M --pool $POOL -c 1 -E eof -c 1 $DIR/$tdir/$tfile.pfl
2687 $LFS find $DIR/$tdir -type f --pool $POOL
2688 local found=$($LFS find $DIR/$tdir -type f --pool $POOL | wc -l)
2689 [[ "$found" == "2" ]] ||
2690 error "found $found != 2 files in '$DIR/$tdir' in '$POOL'"
2692 $LFS setstripe -d $DIR/$tdir
2694 pool=$($LFS getstripe -p -d $DIR/$tdir)
2696 [[ "$pool" != "$POOL" ]] || error "$DIR/$tdir is still '$pool'"
2698 run_test 27G "Clear OST pool from stripe"
2701 [[ $MDS1_VERSION -le $(version_code 2.11.54) ]] &&
2702 skip "Need MDS version newer than 2.11.54"
2703 [[ $OSTCOUNT -lt 3 ]] && skip_env "needs >= 3 OSTs"
2704 test_mkdir $DIR/$tdir
2705 $LFS setstripe -o 0 -o 2 $DIR/$tdir || error "setstripe failed"
2706 touch $DIR/$tdir/$tfile
2707 $LFS getstripe -c $DIR/$tdir/$tfile
2708 [ $($LFS getstripe -c $DIR/$tdir/$tfile) -eq 2 ] ||
2709 error "two-stripe file doesn't have two stripes"
2711 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=4k count=4 || error "dd failed"
2712 $LFS getstripe -y $DIR/$tdir/$tfile
2713 (( $($LFS getstripe -y $DIR/$tdir/$tfile |
2714 egrep -c "l_ost_idx: [02]$") == "2" )) ||
2715 error "expected l_ost_idx: [02]$ not matched"
2717 # make sure ost list has been cleared
2718 local stripesize=$($LFS getstripe -S $DIR/$tdir)
2719 $LFS setstripe -S $((stripesize * 4)) -i 1 \
2720 -c $((OSTCOUNT - 1)) $DIR/$tdir || error "setstripe"
2722 $LVERIFY $DIR/$tdir $DIR/$tdir/f3 || error "lverify failed"
2724 run_test 27H "Set specific OSTs stripe"
2727 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2728 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
2729 [[ $MDS1_VERSION -gt $(version_code 2.12.52) ]] ||
2730 skip "Need MDS version newer than 2.12.52"
2731 local pool=$TESTNAME
2732 local ostrange="1 1 1"
2734 save_layout_restore_at_exit $MOUNT
2735 $LFS setstripe -c 2 -i 0 $MOUNT
2736 pool_add $pool || error "pool_add failed"
2737 pool_add_targets $pool $ostrange ||
2738 error "pool_add_targets failed"
2739 test_mkdir $DIR/$tdir
2740 $LFS setstripe -p $pool $DIR/$tdir
2741 $MULTIOP $DIR/$tdir/$tfile Oc || error "multiop failed"
2742 $LFS getstripe $DIR/$tdir/$tfile
2744 run_test 27I "check that root dir striping does not break parent dir one"
2747 [[ $MDS1_VERSION -le $(version_code 2.12.51) ]] &&
2748 skip "Need MDS version newer than 2.12.51"
2750 test_mkdir $DIR/$tdir
2751 local uuid1=$(cat /proc/sys/kernel/random/uuid)
2752 local uuid2=$(cat /proc/sys/kernel/random/uuid)
2754 # create foreign file (raw way)
2755 ! $LFS setstripe --flags 0xda08 $DIR/$tdir/$tfile ||
2756 error "creating $tfile w/ hex flags w/o --foreign should fail"
2758 ! $LFS setstripe --foreign --flags foo \
2759 --xattr ${uuid1}@${uuid2} $DIR/$tdir/$tfile ||
2760 error "creating $tfile with '--flags foo' should fail"
2762 ! $LFS setstripe --foreign --flags 0xffffffff \
2763 --xattr ${uuid1}@${uuid2} $DIR/$tdir/$tfile ||
2764 error "creating $tfile w/ 0xffffffff flags should fail"
2766 create_foreign_file -f $DIR/$tdir/$tfile -x "${uuid1}@${uuid2}" \
2767 -t 1 -F 0xda08 || error "create_foreign_file failed"
2769 # verify foreign file (raw way)
2770 parse_foreign_file -f $DIR/$tdir/$tfile |
2771 grep "lov_foreign_magic: 0x0BD70BD0" ||
2772 error "$DIR/$tdir/$tfile: invalid LOV EA foreign magic"
2773 parse_foreign_file -f $DIR/$tdir/$tfile | grep "lov_xattr_size: 89" ||
2774 error "$DIR/$tdir/$tfile: invalid LOV EA foreign size"
2775 parse_foreign_file -f $DIR/$tdir/$tfile |
2776 grep "lov_foreign_size: 73" ||
2777 error "$DIR/$tdir/$tfile: invalid LOV EA foreign size"
2778 parse_foreign_file -f $DIR/$tdir/$tfile |
2779 grep "lov_foreign_type: 1" ||
2780 error "$DIR/$tdir/$tfile: invalid LOV EA foreign type"
2781 parse_foreign_file -f $DIR/$tdir/$tfile |
2782 grep "lov_foreign_flags: 0x0000DA08" ||
2783 error "$DIR/$tdir/$tfile: invalid LOV EA foreign flags"
2784 local lov=$(parse_foreign_file -f $DIR/$tdir/$tfile |
2785 grep "lov_foreign_value: 0x" |
2786 sed -e 's/lov_foreign_value: 0x//')
2787 local lov2=$(echo -n "${uuid1}@${uuid2}" | od -A n -t x1 -w160)
2788 [[ $lov = ${lov2// /} ]] ||
2789 error "$DIR/$tdir/$tfile: invalid LOV EA foreign value"
2791 # create foreign file (lfs + API)
2792 $LFS setstripe --foreign=none --flags 0xda08 \
2793 -x "${uuid1}@${uuid2}" $DIR/$tdir/${tfile}2 ||
2794 error "$DIR/$tdir/${tfile}2: create failed"
2796 $LFS getstripe -v $DIR/$tdir/${tfile}2 |
2797 grep "lfm_magic:.*0x0BD70BD0" ||
2798 error "$DIR/$tdir/${tfile}2: invalid LOV EA foreign magic"
2799 # lfm_length is LOV EA size - sizeof(lfm_magic) - sizeof(lfm_length)
2800 $LFS getstripe -v $DIR/$tdir/${tfile}2 | grep "lfm_length:.*73" ||
2801 error "$DIR/$tdir/${tfile}2: invalid LOV EA foreign size"
2802 $LFS getstripe -v $DIR/$tdir/${tfile}2 | grep "lfm_type:.*none" ||
2803 error "$DIR/$tdir/${tfile}2: invalid LOV EA foreign type"
2804 $LFS getstripe -v $DIR/$tdir/${tfile}2 |
2805 grep "lfm_flags:.*0x0000DA08" ||
2806 error "$DIR/$tdir/${tfile}2: invalid LOV EA foreign flags"
2807 $LFS getstripe $DIR/$tdir/${tfile}2 |
2808 grep "lfm_value:.*${uuid1}@${uuid2}" ||
2809 error "$DIR/$tdir/${tfile}2: invalid LOV EA foreign value"
2811 # modify striping should fail
2812 $LFS setstripe -c 2 $DIR/$tdir/$tfile &&
2813 error "$DIR/$tdir/$tfile: setstripe should fail"
2814 $LFS setstripe -c 2 $DIR/$tdir/${tfile}2 &&
2815 error "$DIR/$tdir/${tfile}2: setstripe should fail"
2818 cat $DIR/$tdir/$tfile && error "$DIR/$tdir/$tfile: read should fail"
2819 cat $DIR/$tdir/${tfile}2 &&
2820 error "$DIR/$tdir/${tfile}2: read should fail"
2821 cat /etc/passwd > $DIR/$tdir/$tfile &&
2822 error "$DIR/$tdir/$tfile: write should fail"
2823 cat /etc/passwd > $DIR/$tdir/${tfile}2 &&
2824 error "$DIR/$tdir/${tfile}2: write should fail"
2827 chmod 222 $DIR/$tdir/$tfile ||
2828 error "$DIR/$tdir/$tfile: chmod failed"
2829 chmod 222 $DIR/$tdir/${tfile}2 ||
2830 error "$DIR/$tdir/${tfile}2: chmod failed"
2833 chown $RUNAS_ID:$RUNAS_GID $DIR/$tdir/$tfile ||
2834 error "$DIR/$tdir/$tfile: chown failed"
2835 chown $RUNAS_ID:$RUNAS_GID $DIR/$tdir/${tfile}2 ||
2836 error "$DIR/$tdir/${tfile}2: chown failed"
2838 # rename should work
2839 mv $DIR/$tdir/$tfile $DIR/$tdir/${tfile}.new ||
2840 error "$DIR/$tdir/$tfile: rename of foreign file has failed"
2841 mv $DIR/$tdir/${tfile}2 $DIR/$tdir/${tfile}2.new ||
2842 error "$DIR/$tdir/${tfile}2: rename of foreign file has failed"
2844 #remove foreign file
2845 rm $DIR/$tdir/${tfile}.new ||
2846 error "$DIR/$tdir/${tfile}.new: remove of foreign file has failed"
2847 rm $DIR/$tdir/${tfile}2.new ||
2848 error "$DIR/$tdir/${tfile}2.new: remove of foreign file has failed"
2850 run_test 27J "basic ops on file with foreign LOV"
2853 [[ $MDS1_VERSION -le $(version_code 2.12.49) ]] &&
2854 skip "Need MDS version newer than 2.12.49"
2856 test_mkdir $DIR/$tdir
2857 local uuid1=$(cat /proc/sys/kernel/random/uuid)
2858 local uuid2=$(cat /proc/sys/kernel/random/uuid)
2860 # create foreign dir (raw way)
2861 ! $LFS setdirstripe --flags 0xda08 $DIR/$tdir/$tdir ||
2862 error "creating $tdir w/ hex flags w/o --foreign should fail"
2864 ! $LFS setdirstripe --foreign --flags foo \
2865 --xattr ${uuid1}@${uuid2} $DIR/$tdir/$tdir ||
2866 error "creating $tdir with '--flags foo' should fail"
2868 ! $LFS setdirstripe --foreign --flags 0xffffffff \
2869 --xattr ${uuid1}@${uuid2} $DIR/$tdir/$tdir ||
2870 error "creating $tdir w/ 0xffffffff flags should fail"
2872 create_foreign_dir -d $DIR/$tdir/$tdir -x "${uuid1}@${uuid2}" -t 1 ||
2873 error "create_foreign_dir FAILED"
2875 # verify foreign dir (raw way)
2876 parse_foreign_dir -d $DIR/$tdir/$tdir |
2877 grep "lmv_foreign_magic:.*0xcd50cd0" ||
2878 error "$DIR/$tdir/$tfile: invalid LMV EA magic"
2879 parse_foreign_dir -d $DIR/$tdir/$tdir | grep "lmv_xattr_size:.*89$" ||
2880 error "$DIR/$tdir/$tdir: invalid LMV EA size"
2881 parse_foreign_dir -d $DIR/$tdir/$tdir | grep "lmv_foreign_type: 1$" ||
2882 error "$DIR/$tdir/$tdir: invalid LMV EA type"
2883 parse_foreign_dir -d $DIR/$tdir/$tdir |
2884 grep "lmv_foreign_flags: 55813$" ||
2885 error "$DIR/$tdir/$tdir: invalid LMV EA flags"
2886 local lmv=$(parse_foreign_dir -d $DIR/$tdir/$tdir |
2887 grep "lmv_foreign_value: 0x" |
2888 sed 's/lmv_foreign_value: 0x//')
2889 local lmv2=$(echo -n "${uuid1}@${uuid2}" | od -A n -t x1 -w160 |
2891 [[ $lmv == $lmv2 ]] || error "$DIR/$tdir/$tdir: invalid LMV EA value"
2893 # create foreign dir (lfs + API)
2894 $LFS mkdir --foreign=none --xattr="${uuid1}@${uuid2}" --flags=0xda05 \
2895 $DIR/$tdir/${tdir}2 ||
2896 error "$DIR/$tdir/${tdir}2: create failed"
2898 $LFS getdirstripe -v $DIR/$tdir/${tdir}2 |
2899 grep "lfm_magic:.*0x0CD50CD0" ||
2900 error "$DIR/$tdir/${tdir}2: invalid LMV EA magic"
2901 # lfm_length is LMV EA size - sizeof(lfm_magic) - sizeof(lfm_length)
2902 # - sizeof(lfm_type) - sizeof(lfm_flags)
2903 $LFS getdirstripe -v $DIR/$tdir/${tdir}2 | grep "lfm_length:.*73" ||
2904 error "$DIR/$tdir/${tdir}2: invalid LMV EA size"
2905 $LFS getdirstripe -v $DIR/$tdir/${tdir}2 | grep "lfm_type:.*none" ||
2906 error "$DIR/$tdir/${tdir}2: invalid LMV EA type"
2907 $LFS getdirstripe -v $DIR/$tdir/${tdir}2 |
2908 grep "lfm_flags:.*0x0000DA05" ||
2909 error "$DIR/$tdir/${tdir}2: invalid LMV EA flags"
2910 $LFS getdirstripe $DIR/$tdir/${tdir}2 |
2911 grep "lfm_value.*${uuid1}@${uuid2}" ||
2912 error "$DIR/$tdir/${tdir}2: invalid LMV EA value"
2914 # file create in dir should fail
2915 touch $DIR/$tdir/$tdir/$tfile && "$DIR/$tdir: file create should fail"
2916 touch $DIR/$tdir/${tdir}2/$tfile &&
2917 "$DIR/${tdir}2: file create should fail"
2920 chmod 777 $DIR/$tdir/$tdir ||
2921 error "$DIR/$tdir: chmod failed"
2922 chmod 777 $DIR/$tdir/${tdir}2 ||
2923 error "$DIR/${tdir}2: chmod failed"
2926 chown $RUNAS_ID:$RUNAS_GID $DIR/$tdir/$tdir ||
2927 error "$DIR/$tdir: chown failed"
2928 chown $RUNAS_ID:$RUNAS_GID $DIR/$tdir/${tdir}2 ||
2929 error "$DIR/${tdir}2: chown failed"
2931 # rename should work
2932 mv $DIR/$tdir/$tdir $DIR/$tdir/${tdir}.new ||
2933 error "$DIR/$tdir/$tdir: rename of foreign dir has failed"
2934 mv $DIR/$tdir/${tdir}2 $DIR/$tdir/${tdir}2.new ||
2935 error "$DIR/$tdir/${tdir}2: rename of foreign dir has failed"
2938 rmdir $DIR/$tdir/${tdir}.new ||
2939 error "$DIR/$tdir/${tdir}.new: remove of foreign dir has failed"
2940 rmdir $DIR/$tdir/${tdir}2.new ||
2941 error "$DIR/$tdir/${tdir}2.new: remove of foreign dir has failed"
2943 run_test 27K "basic ops on dir with foreign LMV"
2946 remote_mds_nodsh && skip "remote MDS with nodsh"
2948 local POOL=${POOL:-$TESTNAME}
2950 pool_add $POOL || error "pool_add failed"
2952 lfs pool_list $MOUNT | grep -Fx "${FSNAME}.${POOL}" ||
2953 error "pool_list does not contain ${FSNAME}.${POOL}:" \
2954 "$(lfs pool_list $MOUNT | grep -F "${POOL}")"
2956 run_test 27L "lfs pool_list gives correct pool name"
2959 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.12.57) ]] &&
2960 skip "Need MDS version >= than 2.12.57"
2961 remote_mds_nodsh && skip "remote MDS with nodsh"
2962 [[ $OSTCOUNT -lt 2 ]] && skip_env "need > 1 OST"
2964 test_mkdir $DIR/$tdir
2966 # Set default striping on directory
2970 # if we run against a 2.12 server which lacks overstring support
2971 # then the connect_flag will not report overstriping, even if client
2973 if [[ $($LCTL get_param mdc.*.connect_flags) =~ overstriping ]]; then
2974 stripe_opt="-C $setcount"
2975 elif (( $OSTCOUNT >= $setcount )); then
2976 stripe_opt="-c $setcount"
2978 skip "server does not support overstriping"
2980 $LFS setstripe $stripe_opt $DIR/$tdir
2982 echo 1 > $DIR/$tdir/${tfile}.1
2983 local count=$($LFS getstripe -c $DIR/$tdir/${tfile}.1)
2984 [ $count -eq $setcount ] ||
2985 error "(1) stripe count $count, should be $setcount"
2987 # Capture existing append_stripe_count setting for restore
2988 local orig_count=$(do_facet mds1 $LCTL get_param -n mdd.$FSNAME-MDT0000.append_stripe_count)
2989 local mdts=$(comma_list $(mdts_nodes))
2990 stack_trap "do_nodes $mdts $LCTL set_param mdd.*.append_stripe_count=$orig_count" EXIT
2992 local appendcount=$orig_count
2993 echo 1 >> $DIR/$tdir/${tfile}.2_append
2994 count=$($LFS getstripe -c $DIR/$tdir/${tfile}.2_append)
2995 [ $count -eq $appendcount ] ||
2996 error "(2)stripe count $count, should be $appendcount for append"
2998 # Disable O_APPEND striping, verify it works
2999 do_nodes $mdts $LCTL set_param mdd.*.append_stripe_count=0
3001 # Should now get the default striping, which is 4
3003 echo 1 >> $DIR/$tdir/${tfile}.3_append
3004 count=$($LFS getstripe -c $DIR/$tdir/${tfile}.3_append)
3005 [ $count -eq $setcount ] ||
3006 error "(3) stripe count $count, should be $setcount"
3008 # Try changing the stripe count for append files
3009 do_nodes $mdts $LCTL set_param mdd.*.append_stripe_count=2
3011 # Append striping is now 2 (directory default is still 4)
3013 echo 1 >> $DIR/$tdir/${tfile}.4_append
3014 count=$($LFS getstripe -c $DIR/$tdir/${tfile}.4_append)
3015 [ $count -eq $appendcount ] ||
3016 error "(4) stripe count $count, should be $appendcount for append"
3018 # Test append stripe count of -1
3019 do_nodes $mdts $LCTL set_param mdd.*.append_stripe_count=-1
3020 appendcount=$OSTCOUNT
3021 echo 1 >> $DIR/$tdir/${tfile}.5
3022 count=$($LFS getstripe -c $DIR/$tdir/${tfile}.5)
3023 [ $count -eq $appendcount ] ||
3024 error "(5) stripe count $count, should be $appendcount for append"
3026 # Set append striping back to default of 1
3027 do_nodes $mdts $LCTL set_param mdd.*.append_stripe_count=1
3029 # Try a new default striping, PFL + DOM
3030 $LFS setstripe -L mdt -E 1M -E -1 -c 2 $DIR/$tdir
3032 # Create normal DOM file, DOM returns stripe count == 0
3034 touch $DIR/$tdir/${tfile}.6
3035 count=$($LFS getstripe -c $DIR/$tdir/${tfile}.6)
3036 [ $count -eq $setcount ] ||
3037 error "(6) stripe count $count, should be $setcount"
3041 echo 1 >> $DIR/$tdir/${tfile}.7_append
3042 count=$($LFS getstripe -c $DIR/$tdir/${tfile}.7_append)
3043 [ $count -eq $appendcount ] ||
3044 error "(7) stripe count $count, should be $appendcount for append"
3046 # Clean up DOM layout
3047 $LFS setstripe -d $DIR/$tdir
3049 save_layout_restore_at_exit $MOUNT
3050 # Now test that append striping works when layout is from root
3051 $LFS setstripe -c 2 $MOUNT
3052 # Make a special directory for this
3053 mkdir $DIR/${tdir}/${tdir}.2
3055 # Verify for normal file
3057 echo 1 > $DIR/${tdir}/${tdir}.2/${tfile}.8
3058 count=$($LFS getstripe -c $DIR/$tdir/${tdir}.2/${tfile}.8)
3059 [ $count -eq $setcount ] ||
3060 error "(8) stripe count $count, should be $setcount"
3063 echo 1 >> $DIR/${tdir}/${tdir}.2/${tfile}.9_append
3064 count=$($LFS getstripe -c $DIR/${tdir}/${tdir}.2/${tfile}.9_append)
3065 [ $count -eq $appendcount ] ||
3066 error "(9) stripe count $count, should be $appendcount for append"
3068 # Now test O_APPEND striping with pools
3069 do_nodes $mdts $LCTL set_param mdd.*.append_pool="$TESTNAME"
3070 stack_trap "do_nodes $mdts $LCTL set_param mdd.*.append_pool='none'" EXIT
3073 pool_add $TESTNAME || error "pool creation failed"
3074 pool_add_targets $TESTNAME 0 1 || error "Pool add targets failed"
3076 echo 1 >> $DIR/$tdir/${tfile}.10_append
3078 pool=$($LFS getstripe -p $DIR/$tdir/${tfile}.10_append)
3079 [ "$pool" = "$TESTNAME" ] || error "(10) incorrect pool: $pool"
3081 # Check that count is still correct
3083 echo 1 >> $DIR/$tdir/${tfile}.11_append
3084 count=$($LFS getstripe -c $DIR/$tdir/${tfile}.11_append)
3085 [ $count -eq $appendcount ] ||
3086 error "(11) stripe count $count, should be $appendcount for append"
3088 # Disable O_APPEND stripe count, verify pool works separately
3089 do_nodes $mdts $LCTL set_param mdd.*.append_stripe_count=0
3091 echo 1 >> $DIR/$tdir/${tfile}.12_append
3093 pool=$($LFS getstripe -p $DIR/$tdir/${tfile}.12_append)
3094 [ "$pool" = "$TESTNAME" ] || error "(12) incorrect pool: $pool"
3096 # Remove pool setting, verify it's not applied
3097 do_nodes $mdts $LCTL set_param mdd.*.append_pool='none'
3099 echo 1 >> $DIR/$tdir/${tfile}.13_append
3101 pool=$($LFS getstripe -p $DIR/$tdir/${tfile}.13_append)
3102 [ "$pool" = "" ] || error "(13) pool found: $pool"
3104 run_test 27M "test O_APPEND striping"
3107 combined_mgs_mds && skip "needs separate MGS/MDT"
3109 pool_add $TESTNAME || error "pool_add failed"
3110 do_facet mgs "$LCTL pool_list $FSNAME" |
3111 grep -Fx "${FSNAME}.${TESTNAME}" ||
3112 error "lctl pool_list on MGS failed"
3114 run_test 27N "lctl pool_list on separate MGS gives correct pool name"
3116 clean_foreign_symlink() {
3118 lctl set_param llite/$FSNAME-*/foreign_symlink_enable=0
3119 for i in $DIR/$tdir/* ; do
3120 $LFS unlink_foreign $i || true
3125 [[ $(lustre_version_code $SINGLEMDS) -le $(version_code 2.12.51) ]] &&
3126 skip "Need MDS version newer than 2.12.51"
3128 test_mkdir $DIR/$tdir
3129 local uuid1=$(cat /proc/sys/kernel/random/uuid)
3130 local uuid2=$(cat /proc/sys/kernel/random/uuid)
3132 trap clean_foreign_symlink EXIT
3134 # enable foreign_symlink behaviour
3135 $LCTL set_param llite/$FSNAME-*/foreign_symlink_enable=1
3137 # foreign symlink LOV format is a partial path by default
3139 # create foreign file (lfs + API)
3140 $LFS setstripe --foreign=symlink --flags 0xda05 \
3141 -x "${uuid1}/${uuid2}" --mode 0600 $DIR/$tdir/${tfile} ||
3142 error "$DIR/$tdir/${tfile}: create failed"
3144 $LFS getstripe -v $DIR/$tdir/${tfile} |
3145 grep "lfm_magic:.*0x0BD70BD0" ||
3146 error "$DIR/$tdir/${tfile}: invalid LOV EA foreign magic"
3147 $LFS getstripe -v $DIR/$tdir/${tfile} | grep "lfm_type:.*symlink" ||
3148 error "$DIR/$tdir/${tfile}: invalid LOV EA foreign type"
3149 $LFS getstripe -v $DIR/$tdir/${tfile} |
3150 grep "lfm_flags:.*0x0000DA05" ||
3151 error "$DIR/$tdir/${tfile}: invalid LOV EA foreign flags"
3152 $LFS getstripe $DIR/$tdir/${tfile} |
3153 grep "lfm_value:.*${uuid1}/${uuid2}" ||
3154 error "$DIR/$tdir/${tfile}: invalid LOV EA foreign value"
3156 # modify striping should fail
3157 $LFS setstripe -c 2 $DIR/$tdir/$tfile &&
3158 error "$DIR/$tdir/$tfile: setstripe should fail"
3160 # R/W should fail ("/{foreign_symlink_prefix}/${uuid1}/" missing)
3161 cat $DIR/$tdir/$tfile && error "$DIR/$tdir/$tfile: read should fail"
3162 cat /etc/passwd > $DIR/$tdir/$tfile &&
3163 error "$DIR/$tdir/$tfile: write should fail"
3165 # rename should succeed
3166 mv $DIR/$tdir/$tfile $DIR/$tdir/${tfile}.new ||
3167 error "$DIR/$tdir/$tfile: rename has failed"
3169 #remove foreign_symlink file should fail
3170 rm $DIR/$tdir/${tfile}.new &&
3171 error "$DIR/$tdir/${tfile}.new: remove of foreign_symlink file should fail"
3174 mkdir /tmp/${uuid1} ||
3175 error "/tmp/${uuid1}: mkdir has failed"
3176 echo FOOFOO > /tmp/${uuid1}/${uuid2} ||
3177 error "/tmp/${uuid1}/${uuid2}: echo has failed"
3178 $LCTL set_param llite/$FSNAME-*/foreign_symlink_prefix=/tmp/
3179 $CHECKSTAT -t link -l /tmp/${uuid1}/${uuid2} $DIR/$tdir/${tfile}.new ||
3180 error "$DIR/$tdir/${tfile}.new: not seen as a symlink"
3181 #read should succeed now
3182 cat $DIR/$tdir/${tfile}.new | grep FOOFOO ||
3183 error "$DIR/$tdir/${tfile}.new: symlink resolution has failed"
3184 #write should succeed now
3185 cat /etc/passwd > $DIR/$tdir/${tfile}.new ||
3186 error "$DIR/$tdir/${tfile}.new: write should succeed"
3187 diff /etc/passwd $DIR/$tdir/${tfile}.new ||
3188 error "$DIR/$tdir/${tfile}.new: diff has failed"
3189 diff /etc/passwd /tmp/${uuid1}/${uuid2} ||
3190 error "/tmp/${uuid1}/${uuid2}: diff has failed"
3192 #check that getstripe still works
3193 $LFS getstripe $DIR/$tdir/${tfile}.new ||
3194 error "$DIR/$tdir/${tfile}.new: getstripe should still work with foreign_symlink enabled"
3196 # chmod should still succeed
3197 chmod 644 $DIR/$tdir/${tfile}.new ||
3198 error "$DIR/$tdir/${tfile}.new: chmod has failed"
3200 # chown should still succeed
3201 chown $RUNAS_ID:$RUNAS_GID $DIR/$tdir/${tfile}.new ||
3202 error "$DIR/$tdir/${tfile}.new: chown has failed"
3204 # rename should still succeed
3205 mv $DIR/$tdir/${tfile}.new $DIR/$tdir/${tfile} ||
3206 error "$DIR/$tdir/${tfile}.new: rename has failed"
3208 #remove foreign_symlink file should still fail
3209 rm $DIR/$tdir/${tfile} &&
3210 error "$DIR/$tdir/${tfile}: remove of foreign_symlink file should fail"
3212 #use special ioctl() to unlink foreign_symlink file
3213 $LFS unlink_foreign $DIR/$tdir/${tfile} ||
3214 error "$DIR/$tdir/$tfile: unlink/ioctl failed"
3217 run_test 27O "basic ops on foreign file of symlink type"
3220 [[ $(lustre_version_code $SINGLEMDS) -le $(version_code 2.12.49) ]] &&
3221 skip "Need MDS version newer than 2.12.49"
3223 test_mkdir $DIR/$tdir
3224 local uuid1=$(cat /proc/sys/kernel/random/uuid)
3225 local uuid2=$(cat /proc/sys/kernel/random/uuid)
3227 trap clean_foreign_symlink EXIT
3229 # enable foreign_symlink behaviour
3230 $LCTL set_param llite/$FSNAME-*/foreign_symlink_enable=1
3232 # foreign symlink LMV format is a partial path by default
3234 # create foreign dir (lfs + API)
3235 $LFS mkdir --foreign=symlink --xattr="${uuid1}/${uuid2}" \
3236 --flags=0xda05 --mode 0750 $DIR/$tdir/${tdir} ||
3237 error "$DIR/$tdir/${tdir}: create failed"
3239 $LFS getdirstripe -v $DIR/$tdir/${tdir} |
3240 grep "lfm_magic:.*0x0CD50CD0" ||
3241 error "$DIR/$tdir/${tdir}: invalid LMV EA magic"
3242 $LFS getdirstripe -v $DIR/$tdir/${tdir} | grep "lfm_type:.*symlink" ||
3243 error "$DIR/$tdir/${tdir}: invalid LMV EA type"
3244 $LFS getdirstripe -v $DIR/$tdir/${tdir} |
3245 grep "lfm_flags:.*0x0000DA05" ||
3246 error "$DIR/$tdir/${tdir}: invalid LMV EA flags"
3247 $LFS getdirstripe $DIR/$tdir/${tdir} |
3248 grep "lfm_value.*${uuid1}/${uuid2}" ||
3249 error "$DIR/$tdir/${tdir}: invalid LMV EA value"
3251 # file create in dir should fail
3252 # ("/{foreign_symlink_prefix}/${uuid1}/${uuid2}/" missing)
3253 touch $DIR/$tdir/$tdir/$tfile && "$DIR/$tdir: file create should fail"
3255 # rename should succeed
3256 mv $DIR/$tdir/$tdir $DIR/$tdir/${tdir}.new ||
3257 error "$DIR/$tdir/$tdir: rename of foreign_symlink dir has failed"
3259 #remove foreign_symlink dir should fail
3260 rmdir $DIR/$tdir/${tdir}.new &&
3261 error "$DIR/$tdir/${tdir}.new: remove of foreign_symlink dir should fail"
3264 mkdir -p /tmp/${uuid1}/${uuid2} ||
3265 error "/tmp/${uuid1}/${uuid2}: mkdir has failed"
3266 echo FOOFOO > /tmp/${uuid1}/${uuid2}/foo ||
3267 error "/tmp/${uuid1}/${uuid2}/foo: echo has failed"
3268 $LCTL set_param llite/$FSNAME-*/foreign_symlink_prefix=/tmp/
3269 $CHECKSTAT -t link -l /tmp/${uuid1}/${uuid2} $DIR/$tdir/${tdir}.new ||
3270 error "$DIR/$tdir/${tdir}.new: not seen as a symlink"
3271 cat $DIR/$tdir/${tdir}.new/foo | grep FOOFOO ||
3272 error "$DIR/$tdir/${tdir}.new: symlink resolution has failed"
3274 #check that getstripe fails now that foreign_symlink enabled
3275 $LFS getdirstripe $DIR/$tdir/${tdir}.new ||
3276 error "$DIR/$tdir/${tdir}.new: getdirstripe should still work with foreign_symlink enabled"
3278 # file create in dir should work now
3279 cp /etc/passwd $DIR/$tdir/${tdir}.new/$tfile ||
3280 error "$DIR/$tdir/${tdir}.new/$tfile: file create should fail"
3281 diff /etc/passwd $DIR/$tdir/${tdir}.new/$tfile ||
3282 error "$DIR/$tdir/${tdir}.new/$tfile: diff has failed"
3283 diff /etc/passwd /tmp/${uuid1}/${uuid2}/$tfile ||
3284 error "/tmp/${uuid1}/${uuid2}/$tfile: diff has failed"
3286 # chmod should still succeed
3287 chmod 755 $DIR/$tdir/${tdir}.new ||
3288 error "$DIR/$tdir/${tdir}.new: chmod has failed"
3290 # chown should still succeed
3291 chown $RUNAS_ID:$RUNAS_GID $DIR/$tdir/${tdir}.new ||
3292 error "$DIR/$tdir/${tdir}.new: chown has failed"
3294 # rename should still succeed
3295 mv $DIR/$tdir/${tdir}.new $DIR/$tdir/${tdir} ||
3296 error "$DIR/$tdir/${tdir}.new: rename of foreign_symlink dir has failed"
3298 #remove foreign_symlink dir should still fail
3299 rmdir $DIR/$tdir/${tdir} &&
3300 error "$DIR/$tdir/${tdir}: remove of foreign_symlink dir should fail"
3302 #use special ioctl() to unlink foreign_symlink file
3303 $LFS unlink_foreign $DIR/$tdir/${tdir} ||
3304 error "$DIR/$tdir/$tdir: unlink/ioctl failed"
3306 #created file should still exist
3307 [[ -f /tmp/${uuid1}/${uuid2}/$tfile ]] ||
3308 error "/tmp/${uuid1}/${uuid2}/$tfile has been removed"
3309 diff /etc/passwd /tmp/${uuid1}/${uuid2}/$tfile ||
3310 error "/tmp/${uuid1}/${uuid2}/$tfile: diff has failed"
3312 run_test 27P "basic ops on foreign dir of foreign_symlink type"
3315 rm -f $TMP/$tfile $TMP/$tfile.loop $TMP/$tfile.none $TMP/$tfile.broken
3316 stack_trap "rm -f $TMP/$tfile*"
3318 test_mkdir $DIR/$tdir-1
3319 test_mkdir $DIR/$tdir-2
3321 echo 'It is what it is' > $DIR/$tdir-1/$tfile
3322 lov_getstripe_old $DIR/$tdir-1/$tfile || error "$DIR/$tdir-1/$tfile: rc = $?"
3324 ln -s $DIR/$tdir-1/$tfile $DIR/$tdir-2/$tfile
3325 lov_getstripe_old $DIR/$tdir-2/$tfile || error "$DIR/$tdir-2/$tfile: rc = $?"
3327 ln -s $DIR/$tdir-1/$tfile $TMP/$tfile
3328 lov_getstripe_old $TMP/$tfile || error "$TMP/$tfile: rc = $?"
3330 # Create some bad symlinks and ensure that we don't loop
3331 # forever or something. These should return ELOOP (40) and
3332 # ENOENT (2) but I don't want to test for that because there's
3333 # always some weirdo architecture that needs to ruin
3334 # everything by defining these error numbers differently.
3336 ln -s $TMP/$tfile.loop $TMP/$tfile.loop