2 # -*- tab-width: 8; indent-tabs-mode: t; -*-
4 # Run select tests by setting ONLY, or as arguments to the script.
5 # Skip specific tests by setting EXCEPT.
7 # e.g. ONLY="22 23" or ONLY="`seq 32 39`" or EXCEPT="31"
11 # bug number for skipped test: 13297 2108 9789 3637 9789 3561 12622 5188
12 ALWAYS_EXCEPT=" 42a 42b 42c 42d 45 51d 68b $SANITY_EXCEPT"
13 # UPDATE THE COMMENT ABOVE WITH BUG NUMBERS WHEN CHANGING ALWAYS_EXCEPT!
15 # with LOD/OSP landing
16 # bug number for skipped tests: LU-2036
17 ALWAYS_EXCEPT=" 76 $ALWAYS_EXCEPT"
21 if [ -r /etc/SuSE-release ]
23 local vers=$(grep VERSION /etc/SuSE-release | awk '{print $3}')
24 local patchlev=$(grep PATCHLEVEL /etc/SuSE-release |
26 if [ $vers -eq 11 ] && [ $patchlev -ge 3 ]; then
33 if is_sles11; then # LU-4341
34 ALWAYS_EXCEPT="$ALWAYS_EXCEPT 170"
37 SRCDIR=$(cd $(dirname $0); echo $PWD)
38 export PATH=$PATH:/sbin
43 CHECKSTAT=${CHECKSTAT:-"checkstat -v"}
44 CREATETEST=${CREATETEST:-createtest}
46 LFIND=${LFIND:-"$LFS find"}
47 LVERIFY=${LVERIFY:-ll_dirstripe_verify}
49 OPENFILE=${OPENFILE:-openfile}
50 OPENUNLINK=${OPENUNLINK:-openunlink}
51 export MULTIOP=${MULTIOP:-multiop}
52 READS=${READS:-"reads"}
53 MUNLINK=${MUNLINK:-munlink}
54 SOCKETSERVER=${SOCKETSERVER:-socketserver}
55 SOCKETCLIENT=${SOCKETCLIENT:-socketclient}
56 MEMHOG=${MEMHOG:-memhog}
57 DIRECTIO=${DIRECTIO:-directio}
58 ACCEPTOR_PORT=${ACCEPTOR_PORT:-988}
60 CHECK_GRANT=${CHECK_GRANT:-"yes"}
61 GRANT_CHECK_LIST=${GRANT_CHECK_LIST:-""}
62 export PARALLEL=${PARALLEL:-"no"}
64 export NAME=${NAME:-local}
71 LUSTRE=${LUSTRE:-$(cd $(dirname $0)/..; echo $PWD)}
72 LUSTRE_TESTS_API_DIR=${LUSTRE_TESTS_API_DIR:-${LUSTRE}/tests/clientapi}
73 . $LUSTRE/tests/test-framework.sh
75 . ${CONFIG:=$LUSTRE/tests/cfg/${NAME}.sh}
78 [ "$SLOW" = "no" ] && EXCEPT_SLOW="24o 24D 27m 64b 68 71 77f 78 115 124b 300o"
80 if [ $(facet_fstype $SINGLEMDS) = "zfs" ]; then
81 # bug number for skipped test: LU-4536 LU-1957 LU-2805
82 ALWAYS_EXCEPT="$ALWAYS_EXCEPT 65ic 180 184c"
83 [ "$SLOW" = "no" ] && EXCEPT_SLOW="$EXCEPT_SLOW 51b 51ba"
90 pgrep ll_sa > /dev/null && { echo "There are ll_sa thread not exit!"; exit 20; }
91 cleanupall ${FORCE} $* || { echo "FAILed to clean up"; exit 20; }
100 check_swap_layouts_support()
102 $LCTL get_param -n llite.*.sbi_flags | grep -q layout ||
103 { skip "Does not support layout lock."; return 0; }
107 check_and_setup_lustre
111 MDT0=$($LCTL get_param -n mdc.*.mds_server_uuid |
112 awk '{ gsub(/_UUID/,""); print $1 }' | head -n1)
113 MAXFREE=${MAXFREE:-$((200000 * $OSTCOUNT))}
115 [ -f $DIR/d52a/foo ] && chattr -a $DIR/d52a/foo
116 [ -f $DIR/d52b/foo ] && chattr -i $DIR/d52b/foo
117 rm -rf $DIR/[Rdfs][0-9]*
119 # $RUNAS_ID may get set incorrectly somewhere else
120 [ $UID -eq 0 -a $RUNAS_ID -eq 0 ] && error "\$RUNAS_ID set to 0, but \$UID is also 0!"
122 check_runas_id $RUNAS_ID $RUNAS_GID $RUNAS
126 if [ "${ONLY}" = "MOUNT" ] ; then
127 echo "Lustre is up, please go on"
131 echo "preparing for tests involving mounts"
132 EXT2_DEV=${EXT2_DEV:-$TMP/SANITY.LOOP}
134 mke2fs -j -F $EXT2_DEV 8000 > /dev/null
135 echo # add a newline after mke2fs.
139 OLDDEBUG=$(lctl get_param -n debug 2> /dev/null)
140 lctl set_param debug=-1 2> /dev/null || true
143 $CHECKSTAT -t file $DIR/$tfile || error "$tfile is not a file"
145 $CHECKSTAT -a $DIR/$tfile || error "$tfile was not removed"
147 run_test 0a "touch; rm ====================="
150 chmod 0755 $DIR || error "chmod 0755 $DIR failed"
151 $CHECKSTAT -p 0755 $DIR || error "$DIR permission is not 0755"
153 run_test 0b "chmod 0755 $DIR ============================="
156 $LCTL get_param mdc.*.import | grep "state: FULL" ||
157 error "import not FULL"
158 $LCTL get_param mdc.*.import | grep "target: $FSNAME-MDT" ||
161 run_test 0c "check import proc ============================="
164 test_mkdir -p $DIR/$tdir || error "mkdir $tdir failed"
165 test_mkdir -p $DIR/$tdir/d2 || error "mkdir $tdir/d2 failed"
166 test_mkdir $DIR/$tdir/d2 && error "we expect EEXIST, but not returned"
167 $CHECKSTAT -t dir $DIR/$tdir/d2 || error "$tdir/d2 is not a dir"
170 $CHECKSTAT -a $DIR/$tdir || error "$tdir was not removed"
172 run_test 1 "mkdir; remkdir; rmdir =============================="
175 test_mkdir -p $DIR/$tdir || error "mkdir $tdir failed"
176 touch $DIR/$tdir/$tfile || error "touch $tdir/$tfile failed"
177 $CHECKSTAT -t file $DIR/$tdir/$tfile || error "$tdir/$tfile not a file"
179 $CHECKSTAT -a $DIR/$tdir/$tfile || error "$tdir/$file is not removed"
181 run_test 2 "mkdir; touch; rmdir; check file ===================="
184 test_mkdir -p $DIR/$tdir || error "mkdir $tdir failed"
185 $CHECKSTAT -t dir $DIR/$tdir || error "$tdir is not a directory"
186 touch $DIR/$tdir/$tfile
187 $CHECKSTAT -t file $DIR/$tdir/$tfile || error "$tdir/$tfile not a file"
189 $CHECKSTAT -a $DIR/$tdir || error "$tdir is not removed"
191 run_test 3 "mkdir; touch; rmdir; check dir ====================="
193 # LU-4471 - failed rmdir on remote directories still removes directory on MDT0
197 test_mkdir $DIR/$tdir ||
198 error "Create remote directory failed"
200 touch $DIR/$tdir/$tfile ||
201 error "Create file under remote directory failed"
204 error "Expect error removing in-use dir $DIR/$tdir"
206 test -d $DIR/$tdir || error "Remote directory disappeared"
208 rm -rf $DIR/$tdir || error "remove remote dir error"
210 run_test 4 "mkdir; touch dir/file; rmdir; checkdir (expect error)"
213 test_mkdir -p $DIR/$tdir || error "mkdir $tdir failed"
214 test_mkdir $DIR/$tdir/d2 || error "mkdir $tdir/d2 failed"
215 chmod 0707 $DIR/$tdir/d2 || error "chmod 0707 $tdir/d2 failed"
216 $CHECKSTAT -t dir -p 0707 $DIR/$tdir/d2 || error "$tdir/d2 not mode 707"
217 $CHECKSTAT -t dir $DIR/$tdir/d2 || error "$tdir/d2 is not a directory"
219 run_test 5 "mkdir .../d5 .../d5/d2; chmod .../d5/d2 ============"
222 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
223 chmod 0666 $DIR/$tfile || error "chmod 0666 $tfile failed"
224 $CHECKSTAT -t file -p 0666 -u \#$UID $DIR/$tfile ||
225 error "$tfile does not have perm 0666 or UID $UID"
226 $RUNAS chmod 0444 $DIR/$tfile && error "chmod $tfile worked on UID $UID"
227 $CHECKSTAT -t file -p 0666 -u \#$UID $DIR/$tfile ||
228 error "$tfile should be 0666 and owned by UID $UID"
230 run_test 6a "touch f6a; chmod f6a; $RUNAS chmod f6a (should return error) =="
233 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID" && return
235 chown $RUNAS_ID $DIR/$tfile || error "chown $RUNAS_ID $file failed"
236 $CHECKSTAT -t file -u \#$RUNAS_ID $DIR/$tfile ||
237 error "$tfile should be owned by UID $RUNAS_ID"
238 $RUNAS chown $UID $DIR/$tfile && error "chown $UID $file succeeded"
239 $CHECKSTAT -t file -u \#$RUNAS_ID $DIR/$tfile ||
240 error "$tfile should be owned by UID $RUNAS_ID"
242 run_test 6c "touch f6c; chown f6c; $RUNAS chown f6c (should return error) =="
245 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID" && return
247 chgrp $RUNAS_ID $DIR/$tfile || error "chgrp $RUNAS_ID $file failed"
248 $CHECKSTAT -t file -u \#$UID -g \#$RUNAS_ID $DIR/$tfile ||
249 error "$tfile should be owned by GID $UID"
250 $RUNAS chgrp $UID $DIR/$tfile && error "chgrp $UID $file succeeded"
251 $CHECKSTAT -t file -u \#$UID -g \#$RUNAS_ID $DIR/$tfile ||
252 error "$tfile should be owned by UID $UID and GID $RUNAS_ID"
254 run_test 6e "touch f6e; chgrp f6e; $RUNAS chgrp f6e (should return error) =="
257 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID" && return
258 test_mkdir $DIR/$tdir || error "mkdir $tfile failed"
259 chmod 777 $DIR/$tdir || error "chmod 0777 $tdir failed"
260 $RUNAS mkdir $DIR/$tdir/d || error "mkdir $tdir/d failed"
261 chmod g+s $DIR/$tdir/d || error "chmod g+s $tdir/d failed"
262 test_mkdir $DIR/$tdir/d/subdir || error "mkdir $tdir/d/subdir failed"
263 $CHECKSTAT -g \#$RUNAS_GID $DIR/$tdir/d/subdir ||
264 error "$tdir/d/subdir should be GID $RUNAS_GID"
266 run_test 6g "Is new dir in sgid dir inheriting group?"
268 test_6h() { # bug 7331
269 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID" && return
270 touch $DIR/$tfile || error "touch failed"
271 chown $RUNAS_ID:$RUNAS_GID $DIR/$tfile || error "initial chown failed"
272 $RUNAS -G$RUNAS_GID chown $RUNAS_ID:0 $DIR/$tfile &&
273 error "chown $RUNAS_ID:0 $tfile worked as GID $RUNAS_GID"
274 $CHECKSTAT -t file -u \#$RUNAS_ID -g \#$RUNAS_GID $DIR/$tfile ||
275 error "$tdir/$tfile should be UID $RUNAS_UID GID $RUNAS_GID"
277 run_test 6h "$RUNAS chown RUNAS_ID.0 .../f6h (should return error)"
280 test_mkdir $DIR/$tdir
281 $MCREATE $DIR/$tdir/$tfile
282 chmod 0666 $DIR/$tdir/$tfile
283 $CHECKSTAT -t file -p 0666 $DIR/$tdir/$tfile ||
284 error "$tdir/$tfile should be mode 0666"
286 run_test 7a "mkdir .../d7; mcreate .../d7/f; chmod .../d7/f ===="
289 if [ ! -d $DIR/$tdir ]; then
290 test_mkdir $DIR/$tdir
292 $MCREATE $DIR/$tdir/$tfile
293 echo -n foo > $DIR/$tdir/$tfile
294 [ "$(cat $DIR/$tdir/$tfile)" = "foo" ] || error "$tdir/$tfile not 'foo'"
295 $CHECKSTAT -t file -s 3 $DIR/$tdir/$tfile || error "$tfile size not 3"
297 run_test 7b "mkdir .../d7; mcreate d7/f2; echo foo > d7/f2 ====="
300 test_mkdir $DIR/$tdir
301 touch $DIR/$tdir/$tfile
302 chmod 0666 $DIR/$tdir/$tfile
303 $CHECKSTAT -t file -p 0666 $DIR/$tdir/$tfile ||
304 error "$tfile mode not 0666"
306 run_test 8 "mkdir .../d8; touch .../d8/f; chmod .../d8/f ======="
309 test_mkdir $DIR/$tdir
310 test_mkdir $DIR/$tdir/d2
311 test_mkdir $DIR/$tdir/d2/d3
312 $CHECKSTAT -t dir $DIR/$tdir/d2/d3 || error "$tdir/d2/d3 not a dir"
314 run_test 9 "mkdir .../d9 .../d9/d2 .../d9/d2/d3 ================"
317 test_mkdir $DIR/$tdir
318 test_mkdir $DIR/$tdir/d2
319 touch $DIR/$tdir/d2/$tfile
320 $CHECKSTAT -t file $DIR/$tdir/d2/$tfile ||
321 error "$tdir/d2/$tfile not a file"
323 run_test 10 "mkdir .../d10 .../d10/d2; touch .../d10/d2/f ======"
326 test_mkdir $DIR/$tdir
327 test_mkdir $DIR/$tdir/d2
328 chmod 0666 $DIR/$tdir/d2
329 chmod 0705 $DIR/$tdir/d2
330 $CHECKSTAT -t dir -p 0705 $DIR/$tdir/d2 ||
331 error "$tdir/d2 mode not 0705"
333 run_test 11 "mkdir .../d11 d11/d2; chmod .../d11/d2 ============"
336 test_mkdir $DIR/$tdir
337 touch $DIR/$tdir/$tfile
338 chmod 0666 $DIR/$tdir/$tfile
339 chmod 0654 $DIR/$tdir/$tfile
340 $CHECKSTAT -t file -p 0654 $DIR/$tdir/$tfile ||
341 error "$tdir/d2 mode not 0654"
343 run_test 12 "touch .../d12/f; chmod .../d12/f .../d12/f ========"
346 test_mkdir $DIR/$tdir
347 dd if=/dev/zero of=$DIR/$tdir/$tfile count=10
349 $CHECKSTAT -t file -s 0 $DIR/$tdir/$tfile ||
350 error "$tdir/$tfile size not 0 after truncate"
352 run_test 13 "creat .../d13/f; dd .../d13/f; > .../d13/f ========"
355 test_mkdir $DIR/$tdir
356 touch $DIR/$tdir/$tfile
358 $CHECKSTAT -a $DIR/$tdir/$tfile || error "$tdir/$tfile not removed"
360 run_test 14 "touch .../d14/f; rm .../d14/f; rm .../d14/f ======="
363 test_mkdir $DIR/$tdir
364 touch $DIR/$tdir/$tfile
365 mv $DIR/$tdir/$tfile $DIR/$tdir/${tfile}_2
366 $CHECKSTAT -t file $DIR/$tdir/${tfile}_2 ||
367 error "$tdir/${tfile_2} not a file after rename"
368 rm $DIR/$tdir/${tfile}_2 || error "unlink failed after rename"
370 run_test 15 "touch .../d15/f; mv .../d15/f .../d15/f2 =========="
373 test_mkdir $DIR/$tdir
374 touch $DIR/$tdir/$tfile
375 rm -rf $DIR/$tdir/$tfile
376 $CHECKSTAT -a $DIR/$tdir/$tfile || error "$tdir/$tfile not removed"
378 run_test 16 "touch .../d16/f; rm -rf .../d16/f ================="
381 test_mkdir -p $DIR/$tdir
382 touch $DIR/$tdir/$tfile
383 ln -s $DIR/$tdir/$tfile $DIR/$tdir/l-exist
385 $CHECKSTAT -l $DIR/$tdir/$tfile $DIR/$tdir/l-exist ||
386 error "$tdir/l-exist not a symlink"
387 $CHECKSTAT -f -t f $DIR/$tdir/l-exist ||
388 error "$tdir/l-exist not referencing a file"
389 rm -f $DIR/$tdir/l-exist
390 $CHECKSTAT -a $DIR/$tdir/l-exist || error "$tdir/l-exist not removed"
392 run_test 17a "symlinks: create, remove (real) =================="
395 test_mkdir -p $DIR/$tdir
396 ln -s no-such-file $DIR/$tdir/l-dangle
398 $CHECKSTAT -l no-such-file $DIR/$tdir/l-dangle ||
399 error "$tdir/l-dangle not referencing no-such-file"
400 $CHECKSTAT -fa $DIR/$tdir/l-dangle ||
401 error "$tdir/l-dangle not referencing non-existent file"
402 rm -f $DIR/$tdir/l-dangle
403 $CHECKSTAT -a $DIR/$tdir/l-dangle || error "$tdir/l-dangle not removed"
405 run_test 17b "symlinks: create, remove (dangling) =============="
407 test_17c() { # bug 3440 - don't save failed open RPC for replay
408 test_mkdir -p $DIR/$tdir
409 ln -s foo $DIR/$tdir/$tfile
410 cat $DIR/$tdir/$tfile && error "opened non-existent symlink" || true
412 run_test 17c "symlinks: open dangling (should return error) ===="
415 test_mkdir -p $DIR/$tdir
416 ln -s foo $DIR/$tdir/$tfile
417 touch $DIR/$tdir/$tfile || error "creating to new symlink"
419 run_test 17d "symlinks: create dangling ========================"
422 test_mkdir -p $DIR/$tdir
423 local foo=$DIR/$tdir/$tfile
424 ln -s $foo $foo || error "create symlink failed"
425 ls -l $foo || error "ls -l failed"
426 ls $foo && error "ls not failed" || true
428 run_test 17e "symlinks: create recursive symlink (should return error) ===="
431 test_mkdir -p $DIR/$tdir
432 ln -s 1234567890/2234567890/3234567890/4234567890 $DIR/$tdir/111
433 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890 $DIR/$tdir/222
434 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890 $DIR/$tdir/333
435 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890/9234567890/a234567890/b234567890 $DIR/$tdir/444
436 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890/9234567890/a234567890/b234567890/c234567890/d234567890/f234567890 $DIR/$tdir/555
437 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
440 run_test 17f "symlinks: long and very long symlink name ========================"
442 # str_repeat(S, N) generate a string that is string S repeated N times
447 while [ $((n -= 1)) -ge 0 ]; do
453 # Long symlinks and LU-2241
455 test_mkdir -p $DIR/$tdir
456 local TESTS="59 60 61 4094 4095"
458 # Fix for inode size boundary in 2.1.4
459 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.1.4) ] &&
462 # Patch not applied to 2.2 or 2.3 branches
463 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] &&
464 [ $(lustre_version_code $SINGLEMDS) -le $(version_code 2.3.55) ] &&
467 # skip long symlink name for rhel6.5.
468 # rhel6.5 has a limit (PATH_MAX - sizeof(struct filename))
469 grep -q '6.5' /etc/redhat-release &>/dev/null &&
470 TESTS="59 60 61 4062 4063"
473 local SYMNAME=$(str_repeat 'x' $i)
474 ln -s $SYMNAME $DIR/$tdir/f$i || error "failed $i-char symlink"
475 readlink $DIR/$tdir/f$i || error "failed $i-char readlink"
478 run_test 17g "symlinks: really long symlink name and inode boundaries"
480 test_17h() { #bug 17378
481 remote_mds_nodsh && skip "remote MDS with nodsh" && return
482 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
484 test_mkdir -p $DIR/$tdir
485 if [[ $MDSCOUNT -gt 1 ]]; then
486 mdt_idx=$($LFS getdirstripe -i $DIR/$tdir)
490 $SETSTRIPE -c -1 $DIR/$tdir
491 #define OBD_FAIL_MDS_LOV_PREP_CREATE 0x141
492 do_facet mds$((mdt_idx + 1)) lctl set_param fail_loc=0x80000141
493 touch $DIR/$tdir/$tfile || true
495 run_test 17h "create objects: lov_free_memmd() doesn't lbug"
497 test_17i() { #bug 20018
498 remote_mds_nodsh && skip "remote MDS with nodsh" && return
499 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
500 test_mkdir -c1 $DIR/$tdir
501 local foo=$DIR/$tdir/$tfile
503 if [[ $MDSCOUNT -gt 1 ]]; then
504 mdt_idx=$($LFS getdirstripe -i $DIR/$tdir)
508 ln -s $foo $foo || error "create symlink failed"
509 #define OBD_FAIL_MDS_READLINK_EPROTO 0x143
510 do_facet mds$((mdt_idx + 1)) lctl set_param fail_loc=0x80000143
511 ls -l $foo && error "error not detected"
514 run_test 17i "don't panic on short symlink"
516 test_17k() { #bug 22301
517 [[ -z "$(which rsync 2>/dev/null)" ]] &&
518 skip "no rsync command" && return 0
519 rsync --help | grep -q xattr ||
520 skip_env "$(rsync --version | head -n1) does not support xattrs"
521 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return 0
522 test_mkdir -p $DIR/$tdir
523 test_mkdir -p $DIR/$tdir.new
524 touch $DIR/$tdir/$tfile
525 ln -s $DIR/$tdir/$tfile $DIR/$tdir/$tfile.lnk
526 rsync -av -X $DIR/$tdir/ $DIR/$tdir.new ||
527 error "rsync failed with xattrs enabled"
529 run_test 17k "symlinks: rsync with xattrs enabled ========================="
531 test_17l() { # LU-279
532 [[ -z "$(which getfattr 2>/dev/null)" ]] &&
533 skip "no getfattr command" && return 0
534 test_mkdir -p $DIR/$tdir
535 touch $DIR/$tdir/$tfile
536 ln -s $DIR/$tdir/$tfile $DIR/$tdir/$tfile.lnk
537 for path in "$DIR/$tdir" "$DIR/$tdir/$tfile" "$DIR/$tdir/$tfile.lnk"; do
538 # -h to not follow symlinks. -m '' to list all the xattrs.
539 # grep to remove first line: '# file: $path'.
540 for xattr in `getfattr -hm '' $path 2>/dev/null | grep -v '^#'`;
542 lgetxattr_size_check $path $xattr ||
543 error "lgetxattr_size_check $path $xattr failed"
547 run_test 17l "Ensure lgetxattr's returned xattr size is consistent ========"
551 local short_sym="0123456789"
552 local WDIR=$DIR/${tdir}m
555 remote_mds_nodsh && skip "remote MDS with nodsh" && return
556 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] &&
557 [ $(lustre_version_code $SINGLEMDS) -le $(version_code 2.2.93) ] &&
558 skip "MDS 2.2.0-2.2.93 do not NUL-terminate symlinks" && return
560 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
561 skip "only for ldiskfs MDT" && return 0
563 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
567 # create a long symlink file
568 for ((i = 0; i < 4; ++i)); do
569 long_sym=${long_sym}${long_sym}
572 echo "create 512 short and long symlink files under $WDIR"
573 for ((i = 0; i < 256; ++i)); do
574 ln -sf ${long_sym}"a5a5" $WDIR/long-$i
575 ln -sf ${short_sym}"a5a5" $WDIR/short-$i
581 wait_delete_completed
583 echo "recreate the 512 symlink files with a shorter string"
584 for ((i = 0; i < 512; ++i)); do
585 # rewrite the symlink file with a shorter string
586 ln -sf ${long_sym} $WDIR/long-$i || error "long_sym failed"
587 ln -sf ${short_sym} $WDIR/short-$i || error "short_sym failed"
590 local mds_index=$(($($LFS getstripe -M $WDIR) + 1))
591 local devname=$(mdsdevname $mds_index)
593 echo "stop and checking mds${mds_index}:"
594 # e2fsck should not return error
596 run_e2fsck $(facet_active_host mds${mds_index}) $devname -n
599 start mds${mds_index} $devname $MDS_MOUNT_OPTS || error "start failed"
600 df $MOUNT > /dev/null 2>&1
602 error "e2fsck detected error for short/long symlink: rc=$rc"
604 run_test 17m "run e2fsck against MDT which contains short/long symlink"
606 check_fs_consistency_17n() {
610 # create/unlink in 17n only change 2 MDTs(MDT1/MDT2),
611 # so it only check MDT1/MDT2 instead of all of MDTs.
612 for mdt_index in 1 2; do
613 local devname=$(mdsdevname $mdt_index)
614 # e2fsck should not return error
616 run_e2fsck $(facet_active_host mds$mdt_index) $devname -n ||
619 start mds${mdt_index} $devname $MDS_MOUNT_OPTS ||
620 error "mount mds$mdt_index failed"
621 df $MOUNT > /dev/null 2>&1
629 remote_mds_nodsh && skip "remote MDS with nodsh" && return
630 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] &&
631 [ $(lustre_version_code $SINGLEMDS) -le $(version_code 2.2.93) ] &&
632 skip "MDS 2.2.0-2.2.93 do not NUL-terminate symlinks" && return
634 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
635 skip "only for ldiskfs MDT" && return 0
637 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 2 MDTs" && return
639 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
641 test_mkdir $DIR/$tdir
642 for ((i=0; i<10; i++)); do
643 $LFS mkdir -i1 -c2 $DIR/$tdir/remote_dir_${i} ||
644 error "create remote dir error $i"
645 createmany -o $DIR/$tdir/remote_dir_${i}/f 10 ||
646 error "create files under remote dir failed $i"
649 check_fs_consistency_17n ||
650 error "e2fsck report error after create files under remote dir"
652 for ((i = 0; i < 10; i++)); do
653 rm -rf $DIR/$tdir/remote_dir_${i} ||
654 error "destroy remote dir error $i"
657 check_fs_consistency_17n ||
658 error "e2fsck report error after unlink files under remote dir"
660 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.50) ] &&
661 skip "lustre < 2.4.50 does not support migrate mv " && return
663 for ((i = 0; i < 10; i++)); do
664 mkdir -p $DIR/$tdir/remote_dir_${i}
665 createmany -o $DIR/$tdir/remote_dir_${i}/f 10 ||
666 error "create files under remote dir failed $i"
667 $LFS migrate --mdt-index 1 $DIR/$tdir/remote_dir_${i} ||
668 error "migrate remote dir error $i"
670 check_fs_consistency_17n || error "e2fsck report error after migration"
672 for ((i = 0; i < 10; i++)); do
673 rm -rf $DIR/$tdir/remote_dir_${i} ||
674 error "destroy remote dir error $i"
677 check_fs_consistency_17n || error "e2fsck report error after unlink"
679 run_test 17n "run e2fsck against master/slave MDT which contains remote dir"
682 remote_mds_nodsh && skip "remote MDS with nodsh" && return
683 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.3.64) ] &&
684 skip "Need MDS version at least 2.3.64" && return
686 local WDIR=$DIR/${tdir}o
691 mdt_index=$($LFS getstripe -M $WDIR)
692 mdt_index=$((mdt_index+1))
696 #fail mds will wait the failover finish then set
697 #following fail_loc to avoid interfer the recovery process.
700 #define OBD_FAIL_OSD_LMA_INCOMPAT 0x194
701 do_facet mds${mdt_index} lctl set_param fail_loc=0x194
702 ls -l $WDIR/$tfile && rc=1
703 do_facet mds${mdt_index} lctl set_param fail_loc=0
704 [[ $rc -ne 0 ]] && error "stat file should fail"
707 run_test 17o "stat file with incompat LMA feature"
710 touch $DIR/$tfile || error "Failed to touch $DIR/$tfile: $?"
711 ls $DIR || error "Failed to ls $DIR: $?"
713 run_test 18 "touch .../f ; ls ... =============================="
719 $CHECKSTAT -a $DIR/$tfile || error "$tfile was not removed"
721 run_test 19a "touch .../f19 ; ls -l ... ; rm .../f19 ==========="
724 ls -l $DIR/$tfile && error "ls -l $tfile failed"|| true
726 run_test 19b "ls -l .../f19 (should return error) =============="
729 [ $RUNAS_ID -eq $UID ] &&
730 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
731 $RUNAS touch $DIR/$tfile && error "create non-root file failed" || true
733 run_test 19c "$RUNAS touch .../f19 (should return error) =="
736 cat $DIR/f19 && error || true
738 run_test 19d "cat .../f19 (should return error) =============="
750 $CHECKSTAT -a $DIR/$tfile || error "$tfile was not removed"
752 run_test 20 "touch .../f ; ls -l ... ==========================="
755 test_mkdir -p $DIR/$tdir
756 [ -f $DIR/$tdir/dangle ] && rm -f $DIR/$tdir/dangle
757 ln -s dangle $DIR/$tdir/link
758 echo foo >> $DIR/$tdir/link
759 cat $DIR/$tdir/dangle
760 $CHECKSTAT -t link $DIR/$tdir/link || error "$tdir/link not a link"
761 $CHECKSTAT -f -t file $DIR/$tdir/link ||
762 error "$tdir/link not linked to a file"
764 run_test 21 "write to dangling link ============================"
768 test_mkdir -p $DIR/$tdir
769 chown $RUNAS_ID:$RUNAS_GID $WDIR
770 (cd $WDIR || error "cd $WDIR failed";
771 $RUNAS tar cf - /etc/hosts /etc/sysconfig/network | \
773 ls -lR $WDIR/etc || error "ls -lR $WDIR/etc failed"
774 $CHECKSTAT -t dir $WDIR/etc || error "checkstat -t dir failed"
775 $CHECKSTAT -u \#$RUNAS_ID -g \#$RUNAS_GID $WDIR/etc || error "checkstat -u failed"
777 run_test 22 "unpack tar archive as non-root user ==============="
781 test_mkdir -p $DIR/$tdir
782 local file=$DIR/$tdir/$tfile
784 openfile -f O_CREAT:O_EXCL $file || error "$file create failed"
785 openfile -f O_CREAT:O_EXCL $file &&
786 error "$file recreate succeeded" || true
788 run_test 23a "O_CREAT|O_EXCL in subdir =========================="
790 test_23b() { # bug 18988
791 test_mkdir -p $DIR/$tdir
792 local file=$DIR/$tdir/$tfile
795 echo foo > $file || error "write filed"
796 echo bar >> $file || error "append filed"
797 $CHECKSTAT -s 8 $file || error "wrong size"
800 run_test 23b "O_APPEND check =========================="
804 echo '-- same directory rename'
805 test_mkdir $DIR/$tdir
806 touch $DIR/$tdir/$tfile.1
807 mv $DIR/$tdir/$tfile.1 $DIR/$tdir/$tfile.2
808 $CHECKSTAT -t file $DIR/$tdir/$tfile.2 || error "$tfile.2 not a file"
810 run_test 24a "rename file to non-existent target"
813 test_mkdir $DIR/$tdir
814 touch $DIR/$tdir/$tfile.{1,2}
815 mv $DIR/$tdir/$tfile.1 $DIR/$tdir/$tfile.2
816 $CHECKSTAT -a $DIR/$tdir/$tfile.1 || error "$tfile.1 exists"
817 $CHECKSTAT -t file $DIR/$tdir/$tfile.2 || error "$tfile.2 not a file"
819 run_test 24b "rename file to existing target"
822 test_mkdir $DIR/$tdir
823 test_mkdir $DIR/$tdir/d$testnum.1
824 mv $DIR/$tdir/d$testnum.1 $DIR/$tdir/d$testnum.2
825 $CHECKSTAT -a $DIR/$tdir/d$testnum.1 || error "d$testnum.1 exists"
826 $CHECKSTAT -t dir $DIR/$tdir/d$testnum.2 || error "d$testnum.2 not dir"
828 run_test 24c "rename directory to non-existent target"
831 test_mkdir -c1 $DIR/$tdir
832 test_mkdir -c1 $DIR/$tdir/d$testnum.1
833 test_mkdir -c1 $DIR/$tdir/d$testnum.2
834 mrename $DIR/$tdir/d$testnum.1 $DIR/$tdir/d$testnum.2
835 $CHECKSTAT -a $DIR/$tdir/d$testnum.1 || error "d$testnum.1 exists"
836 $CHECKSTAT -t dir $DIR/$tdir/d$testnum.2 || error "d$testnum.2 not dir"
838 run_test 24d "rename directory to existing target"
841 echo '-- cross directory renames --'
845 mv $DIR/R5a/f $DIR/R5b/g
846 $CHECKSTAT -a $DIR/R5a/f || error
847 $CHECKSTAT -t file $DIR/R5b/g || error
849 run_test 24e "touch .../R5a/f; rename .../R5a/f .../R5b/g ======"
854 touch $DIR/R6a/f $DIR/R6b/g
855 mv $DIR/R6a/f $DIR/R6b/g
856 $CHECKSTAT -a $DIR/R6a/f || error
857 $CHECKSTAT -t file $DIR/R6b/g || error
859 run_test 24f "touch .../R6a/f R6b/g; mv .../R6a/f .../R6b/g ===="
864 test_mkdir $DIR/R7a/d
865 mv $DIR/R7a/d $DIR/R7b/e
866 $CHECKSTAT -a $DIR/R7a/d || error
867 $CHECKSTAT -t dir $DIR/R7b/e || error
869 run_test 24g "mkdir .../R7{a,b}/d; mv .../R7a/d .../R7b/e ======"
872 test_mkdir -c1 $DIR/R8a
873 test_mkdir -c1 $DIR/R8b
874 test_mkdir -c1 $DIR/R8a/d
875 test_mkdir -c1 $DIR/R8b/e
876 mrename $DIR/R8a/d $DIR/R8b/e
877 $CHECKSTAT -a $DIR/R8a/d || error
878 $CHECKSTAT -t dir $DIR/R8b/e || error
880 run_test 24h "mkdir .../R8{a,b}/{d,e}; rename .../R8a/d .../R8b/e"
883 echo "-- rename error cases"
887 mrename $DIR/R9/f $DIR/R9/a
888 $CHECKSTAT -t file $DIR/R9/f || error
889 $CHECKSTAT -t dir $DIR/R9/a || error
890 $CHECKSTAT -a $DIR/R9/a/f || error
892 run_test 24i "rename file to dir error: touch f ; mkdir a ; rename f a"
896 mrename $DIR/R10/f $DIR/R10/g
897 $CHECKSTAT -t dir $DIR/R10 || error
898 $CHECKSTAT -a $DIR/R10/f || error
899 $CHECKSTAT -a $DIR/R10/g || error
901 run_test 24j "source does not exist ============================"
905 test_mkdir $DIR/R11a/d
907 mv $DIR/R11a/f $DIR/R11a/d
908 $CHECKSTAT -a $DIR/R11a/f || error
909 $CHECKSTAT -t file $DIR/R11a/d/f || error
911 run_test 24k "touch .../R11a/f; mv .../R11a/f .../R11a/d ======="
913 # bug 2429 - rename foo foo foo creates invalid file
916 $MULTIOP $f OcNs || error
918 run_test 24l "Renaming a file to itself ========================"
922 $MULTIOP $f OcLN ${f}2 ${f}2 || error "link ${f}2 ${f}2 failed"
923 # on ext3 this does not remove either the source or target files
924 # though the "expected" operation would be to remove the source
925 $CHECKSTAT -t file ${f} || error "${f} missing"
926 $CHECKSTAT -t file ${f}2 || error "${f}2 missing"
928 run_test 24m "Renaming a file to a hard link to itself ========="
932 # this stats the old file after it was renamed, so it should fail
936 $CHECKSTAT ${f}.rename
939 run_test 24n "Statting the old file after renaming (Posix rename 2)"
942 test_mkdir -p $DIR/d24o
943 rename_many -s random -v -n 10 $DIR/d24o
945 run_test 24o "rename of files during htree split ==============="
950 DIRINO=`ls -lid $DIR/R12a | awk '{ print $1 }'`
951 mrename $DIR/R12a $DIR/R12b
952 $CHECKSTAT -a $DIR/R12a || error
953 $CHECKSTAT -t dir $DIR/R12b || error
954 DIRINO2=`ls -lid $DIR/R12b | awk '{ print $1 }'`
955 [ "$DIRINO" = "$DIRINO2" ] || error "R12a $DIRINO != R12b $DIRINO2"
957 run_test 24p "mkdir .../R12{a,b}; rename .../R12a .../R12b"
959 cleanup_multiop_pause() {
965 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
968 local DIRINO=$(ls -lid $DIR/R13a | awk '{ print $1 }')
969 multiop_bg_pause $DIR/R13b D_c || error "multiop failed to start"
972 trap cleanup_multiop_pause EXIT
973 mrename $DIR/R13a $DIR/R13b
974 $CHECKSTAT -a $DIR/R13a || error "R13a still exists"
975 $CHECKSTAT -t dir $DIR/R13b || error "R13b does not exist"
976 local DIRINO2=$(ls -lid $DIR/R13b | awk '{ print $1 }')
977 [ "$DIRINO" = "$DIRINO2" ] || error "R13a $DIRINO != R13b $DIRINO2"
978 cleanup_multiop_pause
979 wait $MULTIPID || error "multiop close failed"
981 run_test 24q "mkdir .../R13{a,b}; open R13b rename R13a R13b ==="
983 test_24r() { #bug 3789
985 test_mkdir $DIR/R14a/b
986 mrename $DIR/R14a $DIR/R14a/b && error "rename to subdir worked!"
987 $CHECKSTAT -t dir $DIR/R14a || error "$DIR/R14a missing"
988 $CHECKSTAT -t dir $DIR/R14a/b || error "$DIR/R14a/b missing"
990 run_test 24r "mkdir .../R14a/b; rename .../R14a .../R14a/b ====="
994 test_mkdir $DIR/R15a/b
995 test_mkdir $DIR/R15a/b/c
996 mrename $DIR/R15a $DIR/R15a/b/c && error "rename to sub-subdir worked!"
997 $CHECKSTAT -t dir $DIR/R15a || error "$DIR/R15a missing"
998 $CHECKSTAT -t dir $DIR/R15a/b/c || error "$DIR/R15a/b/c missing"
1000 run_test 24s "mkdir .../R15a/b/c; rename .../R15a .../R15a/b/c ="
1002 test_mkdir $DIR/R16a
1003 test_mkdir $DIR/R16a/b
1004 test_mkdir $DIR/R16a/b/c
1005 mrename $DIR/R16a/b/c $DIR/R16a && error "rename to sub-subdir worked!"
1006 $CHECKSTAT -t dir $DIR/R16a || error "$DIR/R16a missing"
1007 $CHECKSTAT -t dir $DIR/R16a/b/c || error "$DIR/R16a/b/c missing"
1009 run_test 24t "mkdir .../R16a/b/c; rename .../R16a/b/c .../R16a ="
1011 test_24u() { # bug12192
1012 $MULTIOP $DIR/$tfile C2w$((2048 * 1024))c || error
1013 $CHECKSTAT -s $((2048 * 1024)) $DIR/$tfile || error "wrong file size"
1015 run_test 24u "create stripe file"
1021 simple_cleanup_common() {
1024 wait_delete_completed
1027 max_pages_per_rpc() {
1028 $LCTL get_param -n mdc.*.max_pages_per_rpc | head -n1
1032 local NRFILES=100000
1033 local FREE_INODES=$(mdt_free_inodes 0)
1034 [[ $FREE_INODES -lt $NRFILES ]] &&
1035 skip "not enough free inodes $FREE_INODES required $NRFILES" &&
1038 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1039 trap simple_cleanup_common EXIT
1041 # Performance issue on ZFS see LU-4072 (c.f. LU-2887)
1042 [ $(facet_fstype $SINGLEMDS) = "zfs" ] && NRFILES=10000
1044 test_mkdir -p $DIR/$tdir
1045 createmany -m $DIR/$tdir/$tfile $NRFILES
1047 cancel_lru_locks mdc
1048 lctl set_param mdc.*.stats clear
1050 ls $DIR/$tdir >/dev/null || error "error in listing large dir"
1052 # LU-5 large readdir
1053 # DIRENT_SIZE = 32 bytes for sizeof(struct lu_dirent) +
1054 # 8 bytes for name(filename is mostly 5 in this test) +
1055 # 8 bytes for luda_type
1056 # take into account of overhead in lu_dirpage header and end mark in
1057 # each page, plus one in RPC_NUM calculation.
1059 RPC_SIZE=$(($(max_pages_per_rpc) * $(page_size)))
1060 RPC_NUM=$(((NRFILES * DIRENT_SIZE + RPC_SIZE - 1) / RPC_SIZE + 1))
1061 mds_readpage=$(lctl get_param mdc.*MDT0000*.stats |
1062 awk '/^mds_readpage/ {print $2}')
1063 [[ $mds_readpage -gt $RPC_NUM ]] &&
1064 error "large readdir doesn't take effect"
1066 simple_cleanup_common
1068 run_test 24v "list directory with large files (handle hash collision, bug: 17560)"
1070 test_24w() { # bug21506
1072 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=4096 || return 1
1073 dd if=/dev/zero bs=$SZ1 count=1 >> $DIR/$tfile || return 2
1074 dd if=$DIR/$tfile of=$DIR/${tfile}_left bs=1M skip=4097 || return 3
1075 SZ2=`ls -l $DIR/${tfile}_left | awk '{print $5}'`
1076 [[ "$SZ1" -eq "$SZ2" ]] ||
1077 error "Error reading at the end of the file $tfile"
1079 run_test 24w "Reading a file larger than 4Gb"
1082 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 2 MDTs" && return
1084 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.56) ]] &&
1085 skip "Need MDS version at least 2.7.56" && return
1087 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1089 local remote_dir=$DIR/$tdir/remote_dir
1091 test_mkdir -p $DIR/$tdir
1092 $LFS mkdir -i $MDTIDX $remote_dir ||
1093 error "create remote directory failed"
1095 test_mkdir -p $DIR/$tdir/src_dir
1096 touch $DIR/$tdir/src_file
1097 test_mkdir -p $remote_dir/tgt_dir
1098 touch $remote_dir/tgt_file
1100 mrename $DIR/$tdir/src_dir $remote_dir/tgt_dir ||
1101 error "rename dir cross MDT failed!"
1103 mrename $DIR/$tdir/src_file $remote_dir/tgt_file ||
1104 error "rename file cross MDT failed!"
1106 touch $DIR/$tdir/ln_file
1107 ln $DIR/$tdir/ln_file $remote_dir/ln_name ||
1108 error "ln file cross MDT failed"
1110 rm -rf $DIR/$tdir || error "Can not delete directories"
1112 run_test 24x "cross MDT rename/link"
1115 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 2 MDTs" && return
1116 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1118 local remote_dir=$DIR/$tdir/remote_dir
1120 test_mkdir -p $DIR/$tdir
1121 $LFS mkdir -i $MDTIDX $remote_dir ||
1122 error "create remote directory failed"
1124 test_mkdir -p $remote_dir/src_dir
1125 touch $remote_dir/src_file
1126 test_mkdir -p $remote_dir/tgt_dir
1127 touch $remote_dir/tgt_file
1129 mrename $remote_dir/src_dir $remote_dir/tgt_dir ||
1130 error "rename subdir in the same remote dir failed!"
1132 mrename $remote_dir/src_file $remote_dir/tgt_file ||
1133 error "rename files in the same remote dir failed!"
1135 ln $remote_dir/tgt_file $remote_dir/tgt_file1 ||
1136 error "link files in the same remote dir failed!"
1138 rm -rf $DIR/$tdir || error "Can not delete directories"
1140 run_test 24y "rename/link on the same dir should succeed"
1142 test_24A() { # LU-3182
1146 test_mkdir -p $DIR/$tdir
1147 createmany -m $DIR/$tdir/$tfile $NFILES
1148 local t=$(ls $DIR/$tdir | wc -l)
1149 local u=$(ls $DIR/$tdir | sort -u | wc -l)
1150 local v=$(ls -ai $DIR/$tdir | sort -u | wc -l)
1151 if [ $t -ne $NFILES -o $u -ne $NFILES -o $v -ne $((NFILES + 2)) ] ; then
1152 error "Expected $NFILES files, got $t ($u unique $v .&..)"
1155 rm -rf $DIR/$tdir || error "Can not delete directories"
1157 run_test 24A "readdir() returns correct number of entries."
1159 test_24B() { # LU-4805
1160 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
1163 test_mkdir $DIR/$tdir
1164 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR/$tdir/striped_dir ||
1165 error "create striped dir failed"
1167 count=$(ls -ai $DIR/$tdir/striped_dir | wc -l)
1168 [ $count -eq 2 ] || error "Expected 2, got $count"
1170 touch $DIR/$tdir/striped_dir/a
1172 count=$(ls -ai $DIR/$tdir/striped_dir | wc -l)
1173 [ $count -eq 3 ] || error "Expected 3, got $count"
1175 touch $DIR/$tdir/striped_dir/.f
1177 count=$(ls -ai $DIR/$tdir/striped_dir | wc -l)
1178 [ $count -eq 4 ] || error "Expected 4, got $count"
1180 rm -rf $DIR/$tdir || error "Can not delete directories"
1182 run_test 24B "readdir for striped dir return correct number of entries"
1185 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
1191 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR/$tdir/d0/striped_dir ||
1192 error "create striped dir failed"
1194 cd $DIR/$tdir/d0/striped_dir
1196 local d0_ino=$(ls -i -l -a $DIR/$tdir | grep "d0" | awk '{print $1}')
1197 local d1_ino=$(ls -i -l -a $DIR/$tdir | grep "d1" | awk '{print $1}')
1198 local parent_ino=$(ls -i -l -a | grep "\.\." | awk '{print $1}')
1200 [ "$d0_ino" = "$parent_ino" ] ||
1201 error ".. wrong, expect $d0_ino, get $parent_ino"
1203 mv $DIR/$tdir/d0/striped_dir $DIR/$tdir/d1/ ||
1204 error "mv striped dir failed"
1206 parent_ino=$(ls -i -l -a | grep "\.\." | awk '{print $1}')
1208 [ "$d1_ino" = "$parent_ino" ] ||
1209 error ".. wrong after mv, expect $d1_ino, get $parent_ino"
1211 run_test 24C "check .. in striped dir"
1213 test_24D() { # LU-6101
1218 createmany -m $DIR/$tdir/$tfile $NFILES
1219 local t=$(ls $DIR/$tdir | wc -l)
1220 local u=$(ls $DIR/$tdir | sort -u | wc -l)
1221 local v=$(ls -ai $DIR/$tdir | sort -u | wc -l)
1222 if [ $t -ne $NFILES -o $u -ne $NFILES -o $v -ne $((NFILES + 2)) ] ; then
1223 error "Expected $NFILES files, got $t ($u unique $v .&..)"
1226 rm -rf $DIR/$tdir || error "Can not delete directories"
1228 run_test 24D "readdir() returns correct number of entries after cursor reload"
1231 [[ $MDSCOUNT -lt 4 ]] && skip "needs >= 4 MDTs" && return
1232 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1235 mkdir $DIR/$tdir/src_dir
1236 $LFS mkdir -i 1 $DIR/$tdir/src_dir/src_child ||
1237 error "create remote source failed"
1239 touch $DIR/$tdir/src_dir/src_child/a
1241 $LFS mkdir -i 2 $DIR/$tdir/tgt_dir ||
1242 error "create remote target dir failed"
1244 $LFS mkdir -i 3 $DIR/$tdir/tgt_dir/tgt_child ||
1245 error "create remote target child failed"
1247 mrename $DIR/$tdir/src_dir/src_child $DIR/$tdir/tgt_dir/tgt_child ||
1248 error "rename dir cross MDT failed!"
1252 $CHECKSTAT -t dir $DIR/$tdir/src_dir/src_child &&
1253 error "src_child still exists after rename"
1255 $CHECKSTAT -t file $DIR/$tdir/tgt_dir/tgt_child/a ||
1256 error "missing file(a) after rename"
1258 rm -rf $DIR/$tdir || error "Can not delete directories"
1260 run_test 24E "cross MDT rename/link"
1263 echo '== symlink sanity ============================================='
1267 touch $DIR/s25/foo || error
1269 run_test 25a "create file in symlinked directory ==============="
1272 [ ! -d $DIR/d25 ] && test_25a
1273 $CHECKSTAT -t file $DIR/s25/foo || error
1275 run_test 25b "lookup file in symlinked directory ==============="
1279 test_mkdir $DIR/d26/d26-2
1280 ln -s d26/d26-2 $DIR/s26
1281 touch $DIR/s26/foo || error
1283 run_test 26a "multiple component symlink ======================="
1286 test_mkdir -p $DIR/d26b/d26-2
1287 ln -s d26b/d26-2/foo $DIR/s26-2
1288 touch $DIR/s26-2 || error
1290 run_test 26b "multiple component symlink at end of lookup ======"
1293 test_mkdir $DIR/d26.2
1294 touch $DIR/d26.2/foo
1295 ln -s d26.2 $DIR/s26.2-1
1296 ln -s s26.2-1 $DIR/s26.2-2
1297 ln -s s26.2-2 $DIR/s26.2-3
1298 chmod 0666 $DIR/s26.2-3/foo
1300 run_test 26c "chain of symlinks ================================"
1302 # recursive symlinks (bug 439)
1304 ln -s d26-3/foo $DIR/d26-3
1306 run_test 26d "create multiple component recursive symlink ======"
1309 [ ! -h $DIR/d26-3 ] && test_26d
1312 run_test 26e "unlink multiple component recursive symlink ======"
1314 # recursive symlinks (bug 7022)
1316 test_mkdir -p $DIR/$tdir
1317 test_mkdir $DIR/$tdir/$tfile || error "mkdir $DIR/$tdir/$tfile failed"
1318 cd $DIR/$tdir/$tfile || error "cd $DIR/$tdir/$tfile failed"
1319 test_mkdir -p lndir/bar1 || error "mkdir lndir/bar1 failed"
1320 test_mkdir $DIR/$tdir/$tfile/$tfile || error "mkdir $tfile failed"
1321 cd $tfile || error "cd $tfile failed"
1322 ln -s .. dotdot || error "ln dotdot failed"
1323 ln -s dotdot/lndir lndir || error "ln lndir failed"
1324 cd $DIR/$tdir || error "cd $DIR/$tdir failed"
1325 output=`ls $tfile/$tfile/lndir/bar1`
1326 [ "$output" = bar1 ] && error "unexpected output"
1327 rm -r $tfile || error "rm $tfile failed"
1328 $CHECKSTAT -a $DIR/$tfile || error "$tfile not gone"
1330 run_test 26f "rm -r of a directory which has recursive symlink ="
1333 echo '== stripe sanity =============================================='
1334 test_mkdir -p $DIR/d27 || error "mkdir failed"
1336 $SETSTRIPE -c 1 $DIR/d27/f0 || error "setstripe failed"
1337 $CHECKSTAT -t file $DIR/d27/f0 || error "checkstat failed"
1338 log "== test_27a: write to one stripe file ========================="
1339 cp /etc/hosts $DIR/d27/f0 || error
1341 run_test 27a "one stripe file =================================="
1344 [[ $OSTCOUNT -lt 2 ]] && skip_env "skipping 2-stripe test" && return
1345 test_mkdir -p $DIR/d27
1346 $SETSTRIPE -c 2 $DIR/d27/f01 || error "setstripe failed"
1347 $GETSTRIPE -c $DIR/d27/f01
1348 [ $($GETSTRIPE -c $DIR/d27/f01) -eq 2 ] ||
1349 error "two-stripe file doesn't have two stripes"
1351 dd if=/dev/zero of=$DIR/d27/f01 bs=4k count=4 || error "dd failed"
1353 run_test 27b "create and write to two stripe file"
1356 test_mkdir -p $DIR/d27
1357 $SETSTRIPE -c 0 -i -1 -S 0 $DIR/d27/fdef || error "setstripe failed"
1358 $CHECKSTAT -t file $DIR/d27/fdef || error "checkstat failed"
1359 dd if=/dev/zero of=$DIR/d27/fdef bs=4k count=4 || error
1361 run_test 27d "create file with default settings ================"
1364 # LU-5839 adds check for existed layout before setting it
1365 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.56) ]] &&
1366 skip "Need MDS version at least 2.7.56" && return
1367 test_mkdir -p $DIR/d27
1368 $SETSTRIPE -c 2 $DIR/d27/f12 || error "setstripe failed"
1369 $SETSTRIPE -c 2 $DIR/d27/f12 && error "setstripe succeeded twice"
1370 $CHECKSTAT -t file $DIR/d27/f12 || error "checkstat failed"
1372 run_test 27e "setstripe existing file (should return error) ======"
1375 test_mkdir $DIR/$tdir
1376 $SETSTRIPE -S 100 -i 0 -c 1 $DIR/$tdir/$tfile &&
1377 error "$SETSTRIPE $DIR/$tdir/$tfile failed"
1378 $CHECKSTAT -t file $DIR/$tdir/$tfile &&
1379 error "$CHECKSTAT -t file $DIR/$tdir/$tfile should fail"
1380 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=4k count=4 || error "dd failed"
1381 $GETSTRIPE $DIR/$tdir/$tfile || error "$GETSTRIPE failed"
1383 run_test 27f "setstripe with bad stripe size (should return error)"
1386 test_mkdir -p $DIR/d27
1387 $MCREATE $DIR/d27/fnone || error "mcreate failed"
1388 $GETSTRIPE $DIR/d27/fnone 2>&1 | grep "no stripe info" ||
1389 error "$DIR/d27/fnone has object"
1391 run_test 27g "$GETSTRIPE with no objects"
1394 test_mkdir $DIR/$tdir
1395 touch $DIR/$tdir/$tfile || error "touch failed"
1396 [[ $($GETSTRIPE -c $DIR/$tdir/$tfile) -gt 0 ]] ||
1397 error "missing objects"
1399 run_test 27i "$GETSTRIPE with some objects"
1402 test_mkdir -p $DIR/d27
1403 $SETSTRIPE -i $OSTCOUNT $DIR/d27/f27j && error "setstripe failed"||true
1405 run_test 27j "setstripe with bad stripe offset (should return error)"
1407 test_27k() { # bug 2844
1408 test_mkdir -p $DIR/d27
1410 LL_MAX_BLKSIZE=$((4 * 1024 * 1024))
1411 [ ! -d $DIR/d27 ] && test_mkdir -p $DIR d27
1412 $SETSTRIPE -S 67108864 $FILE || error "setstripe failed"
1413 BLKSIZE=`stat $FILE | awk '/IO Block:/ { print $7 }'`
1414 [ $BLKSIZE -le $LL_MAX_BLKSIZE ] || error "1:$BLKSIZE > $LL_MAX_BLKSIZE"
1415 dd if=/dev/zero of=$FILE bs=4k count=1
1416 BLKSIZE=`stat $FILE | awk '/IO Block:/ { print $7 }'`
1417 [ $BLKSIZE -le $LL_MAX_BLKSIZE ] || error "2:$BLKSIZE > $LL_MAX_BLKSIZE"
1419 run_test 27k "limit i_blksize for broken user apps ============="
1422 test_mkdir -p $DIR/d27
1423 mcreate $DIR/f27l || error "creating file"
1424 $RUNAS $SETSTRIPE -c 1 $DIR/f27l && \
1425 error "setstripe should have failed" || true
1427 run_test 27l "check setstripe permissions (should return error)"
1430 [[ $OSTCOUNT -lt 2 ]] && skip_env "$OSTCOUNT < 2 OSTs -- skipping" &&
1433 ORIGFREE=$($LCTL get_param -n lov.$FSNAME-clilov-*.kbytesavail |
1435 if [[ $ORIGFREE -gt $MAXFREE ]]; then
1436 skip "$ORIGFREE > $MAXFREE skipping out-of-space test on OST0"
1439 trap simple_cleanup_common EXIT
1440 test_mkdir -p $DIR/$tdir
1441 $SETSTRIPE -i 0 -c 1 $DIR/$tdir/f27m_1
1442 dd if=/dev/zero of=$DIR/$tdir/f27m_1 bs=1024 count=$MAXFREE &&
1443 error "dd should fill OST0"
1445 while $SETSTRIPE -i 0 -c 1 $DIR/$tdir/f27m_$i; do
1447 [ $i -gt 256 ] && break
1450 touch $DIR/$tdir/f27m_$i
1451 [ `$GETSTRIPE $DIR/$tdir/f27m_$i | grep -A 10 obdidx | awk '{print $1}'| grep -w "0"` ] &&
1452 error "OST0 was full but new created file still use it"
1454 touch $DIR/$tdir/f27m_$i
1455 [ `$GETSTRIPE $DIR/$tdir/f27m_$i | grep -A 10 obdidx | awk '{print $1}'| grep -w "0"` ] &&
1456 error "OST0 was full but new created file still use it"
1457 simple_cleanup_common
1459 run_test 27m "create file while OST0 was full =================="
1462 local DELAY=$(do_facet $SINGLEMDS lctl get_param -n lov.*.qos_maxage | head -n 1 | awk '{print $1 * 2}')
1466 # OSCs keep a NOSPC flag that will be reset after ~5s (qos_maxage)
1467 # if the OST isn't full anymore.
1469 local OSTIDX=${1:-""}
1471 local list=$(comma_list $(osts_nodes))
1472 [ "$OSTIDX" ] && list=$(facet_host ost$((OSTIDX + 1)))
1474 do_nodes $list lctl set_param fail_loc=0
1475 sync # initiate all OST_DESTROYs from MDS to OST
1479 exhaust_precreations() {
1482 local FAILIDX=${3:-$OSTIDX}
1483 local ofacet=ost$((OSTIDX + 1))
1485 test_mkdir -p -c1 $DIR/$tdir
1486 local mdtidx=$($LFS getstripe -M $DIR/$tdir)
1487 local mfacet=mds$((mdtidx + 1))
1488 echo OSTIDX=$OSTIDX MDTIDX=$mdtidx
1490 local OST=$(ostname_from_index $OSTIDX)
1493 local mdtosc_proc1=$(get_mdtosc_proc_path $mfacet $OST)
1494 local last_id=$(do_facet $mfacet lctl get_param -n \
1495 osc.$mdtosc_proc1.prealloc_last_id)
1496 local next_id=$(do_facet $mfacet lctl get_param -n \
1497 osc.$mdtosc_proc1.prealloc_next_id)
1499 local mdtosc_proc2=$(get_mdtosc_proc_path $mfacet)
1500 do_facet $mfacet lctl get_param osc.$mdtosc_proc2.prealloc*
1502 test_mkdir -p $DIR/$tdir/${OST}
1503 $SETSTRIPE -i $OSTIDX -c 1 $DIR/$tdir/${OST}
1504 #define OBD_FAIL_OST_ENOSPC 0x215
1505 do_facet $ofacet lctl set_param fail_val=$FAILIDX fail_loc=0x215
1506 echo "Creating to objid $last_id on ost $OST..."
1507 createmany -o $DIR/$tdir/${OST}/f $next_id $((last_id - next_id + 2))
1508 do_facet $mfacet lctl get_param osc.$mdtosc_proc2.prealloc*
1509 do_facet $ofacet lctl set_param fail_loc=$FAILLOC
1513 exhaust_all_precreations() {
1515 for (( i=0; i < OSTCOUNT; i++ )) ; do
1516 exhaust_precreations $i $1 -1
1521 [[ $OSTCOUNT -lt 2 ]] && skip_env "too few OSTs" && return
1522 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1523 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1524 remote_ost_nodsh && skip "remote OST with nodsh" && return
1527 rm -f $DIR/$tdir/$tfile
1528 exhaust_precreations 0 0x80000215
1529 $SETSTRIPE -c -1 $DIR/$tdir
1530 touch $DIR/$tdir/$tfile || error
1531 $GETSTRIPE $DIR/$tdir/$tfile
1534 run_test 27n "create file with some full OSTs =================="
1537 [[ $OSTCOUNT -lt 2 ]] && skip_env "too few OSTs" && return
1538 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1539 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1540 remote_ost_nodsh && skip "remote OST with nodsh" && return
1543 rm -f $DIR/$tdir/$tfile
1544 exhaust_all_precreations 0x215
1546 touch $DIR/$tdir/$tfile && error "able to create $DIR/$tdir/$tfile"
1551 run_test 27o "create file with all full OSTs (should error) ===="
1554 [[ $OSTCOUNT -lt 2 ]] && skip_env "too few OSTs" && return
1555 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1556 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1557 remote_ost_nodsh && skip "remote OST with nodsh" && return
1560 rm -f $DIR/$tdir/$tfile
1561 test_mkdir -p $DIR/$tdir
1563 $MCREATE $DIR/$tdir/$tfile || error "mcreate failed"
1564 $TRUNCATE $DIR/$tdir/$tfile 80000000 || error "truncate failed"
1565 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat failed"
1567 exhaust_precreations 0 0x80000215
1568 echo foo >> $DIR/$tdir/$tfile || error "append failed"
1569 $CHECKSTAT -s 80000004 $DIR/$tdir/$tfile || error "checkstat failed"
1570 $GETSTRIPE $DIR/$tdir/$tfile
1574 run_test 27p "append to a truncated file with some full OSTs ==="
1577 [[ $OSTCOUNT -lt 2 ]] && skip_env "too few OSTs" && return
1578 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1579 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1580 remote_ost_nodsh && skip "remote OST with nodsh" && return
1583 rm -f $DIR/$tdir/$tfile
1585 test_mkdir -p $DIR/$tdir
1586 $MCREATE $DIR/$tdir/$tfile || error "mcreate $DIR/$tdir/$tfile failed"
1587 $TRUNCATE $DIR/$tdir/$tfile 80000000 ||error "truncate $DIR/$tdir/$tfile failed"
1588 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat failed"
1590 exhaust_all_precreations 0x215
1592 echo foo >> $DIR/$tdir/$tfile && error "append succeeded"
1593 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat 2 failed"
1597 run_test 27q "append to truncated file with all OSTs full (should error) ==="
1600 [[ $OSTCOUNT -lt 2 ]] && skip_env "too few OSTs" && return
1601 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1602 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1603 remote_ost_nodsh && skip "remote OST with nodsh" && return
1606 rm -f $DIR/$tdir/$tfile
1607 exhaust_precreations 0 0x80000215
1609 $SETSTRIPE -i 0 -c 2 $DIR/$tdir/$tfile # && error
1613 run_test 27r "stripe file with some full OSTs (shouldn't LBUG) ="
1615 test_27s() { # bug 10725
1616 test_mkdir -p $DIR/$tdir
1617 local stripe_size=$((4096 * 1024 * 1024)) # 2^32
1618 local stripe_count=0
1619 [ $OSTCOUNT -eq 1 ] || stripe_count=2
1620 $SETSTRIPE -S $stripe_size -c $stripe_count $DIR/$tdir &&
1621 error "stripe width >= 2^32 succeeded" || true
1624 run_test 27s "lsm_xfersize overflow (should error) (bug 10725)"
1626 test_27t() { # bug 10864
1631 $WLFS getstripe $tfile
1634 run_test 27t "check that utils parse path correctly"
1636 test_27u() { # bug 4900
1637 [[ $OSTCOUNT -lt 2 ]] && skip_env "too few OSTs" && return
1638 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1640 local list=$(comma_list $(mdts_nodes))
1642 #define OBD_FAIL_MDS_OSC_PRECREATE 0x139
1643 do_nodes $list $LCTL set_param fail_loc=0x139
1644 test_mkdir -p $DIR/$tdir
1646 createmany -o $DIR/$tdir/t- 1000
1647 do_nodes $list $LCTL set_param fail_loc=0
1649 TLOG=$DIR/$tfile.getstripe
1650 $GETSTRIPE $DIR/$tdir > $TLOG
1651 OBJS=$(awk -vobj=0 '($1 == 0) { obj += 1 } END { print obj; }' $TLOG)
1652 unlinkmany $DIR/$tdir/t- 1000
1653 [[ $OBJS -gt 0 ]] &&
1654 error "$OBJS objects created on OST-0. See $TLOG" || pass
1656 run_test 27u "skip object creation on OSC w/o objects =========="
1658 test_27v() { # bug 4900
1659 [[ $OSTCOUNT -lt 2 ]] && skip_env "too few OSTs" && return
1660 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1661 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1662 remote_ost_nodsh && skip "remote OST with nodsh" && return
1664 exhaust_all_precreations 0x215
1667 test_mkdir -p $DIR/$tdir
1668 $SETSTRIPE -c 1 $DIR/$tdir # 1 stripe / file
1670 touch $DIR/$tdir/$tfile
1671 #define OBD_FAIL_TGT_DELAY_PRECREATE 0x705
1673 for (( i=1; i < OSTCOUNT; i++ )); do
1674 do_facet ost$i lctl set_param fail_loc=0x705
1676 local START=`date +%s`
1677 createmany -o $DIR/$tdir/$tfile 32
1679 local FINISH=`date +%s`
1680 local TIMEOUT=`lctl get_param -n timeout`
1681 local PROCESS=$((FINISH - START))
1682 [ $PROCESS -ge $((TIMEOUT / 2)) ] && \
1683 error "$FINISH - $START >= $TIMEOUT / 2"
1684 sleep $((TIMEOUT / 2 - PROCESS))
1687 run_test 27v "skip object creation on slow OST ================="
1689 test_27w() { # bug 10997
1690 test_mkdir -p $DIR/$tdir || error "mkdir failed"
1691 $SETSTRIPE -S 65536 $DIR/$tdir/f0 || error "setstripe failed"
1692 [ $($GETSTRIPE -S $DIR/$tdir/f0) -ne 65536 ] &&
1693 error "stripe size $size != 65536" || true
1694 [ $($GETSTRIPE -d $DIR/$tdir | grep -c "stripe_count") -ne 1 ] &&
1695 error "$GETSTRIPE -d $DIR/$tdir failed" || true
1697 run_test 27w "check $SETSTRIPE -S option"
1700 [[ $OSTCOUNT -lt 2 ]] &&
1701 skip_env "skipping multiple stripe count/offset test" && return
1703 test_mkdir -p $DIR/$tdir || error "mkdir failed"
1704 for i in $(seq 1 $OSTCOUNT); do
1706 $SETSTRIPE -c $i -i $offset $DIR/$tdir/f$i ||
1707 error "setstripe -c $i -i $offset failed"
1708 count=$($GETSTRIPE -c $DIR/$tdir/f$i)
1709 index=$($GETSTRIPE -i $DIR/$tdir/f$i)
1710 [ $count -ne $i ] && error "stripe count $count != $i" || true
1711 [ $index -ne $offset ] &&
1712 error "stripe offset $index != $offset" || true
1715 run_test 27wa "check $SETSTRIPE -c -i options"
1718 remote_ost_nodsh && skip "remote OST with nodsh" && return
1719 [[ $OSTCOUNT -lt 2 ]] && skip_env "$OSTCOUNT < 2 OSTs" && return
1720 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1721 OFFSET=$(($OSTCOUNT - 1))
1723 local OST=$(ostname_from_index $OSTIDX)
1725 test_mkdir -p $DIR/$tdir
1726 $SETSTRIPE -c 1 $DIR/$tdir # 1 stripe per file
1727 do_facet ost$((OSTIDX + 1)) lctl set_param -n obdfilter.$OST.degraded 1
1729 createmany -o $DIR/$tdir/$tfile $OSTCOUNT
1730 for i in `seq 0 $OFFSET`; do
1731 [ `$GETSTRIPE $DIR/$tdir/$tfile$i | grep -A 10 obdidx | awk '{print $1}' | grep -w "$OSTIDX"` ] &&
1732 error "OST0 was degraded but new created file still use it"
1734 do_facet ost$((OSTIDX + 1)) lctl set_param -n obdfilter.$OST.degraded 0
1736 run_test 27x "create files while OST0 is degraded"
1739 [[ $OSTCOUNT -lt 2 ]] &&
1740 skip_env "$OSTCOUNT < 2 OSTs -- skipping" && return
1741 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1742 remote_ost_nodsh && skip "remote OST with nodsh" && return
1743 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1745 local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS $FSNAME-OST0000)
1746 local last_id=$(do_facet $SINGLEMDS lctl get_param -n \
1747 osc.$mdtosc.prealloc_last_id)
1748 local next_id=$(do_facet $SINGLEMDS lctl get_param -n \
1749 osc.$mdtosc.prealloc_next_id)
1750 local fcount=$((last_id - next_id))
1751 [[ $fcount -eq 0 ]] && skip "not enough space on OST0" && return
1752 [[ $fcount -gt $OSTCOUNT ]] && fcount=$OSTCOUNT
1754 local MDS_OSCS=$(do_facet $SINGLEMDS lctl dl |
1755 awk '/[oO][sS][cC].*md[ts]/ { print $4 }')
1756 local OST_DEACTIVE_IDX=-1
1761 for OSC in $MDS_OSCS; do
1762 OST=$(osc_to_ost $OSC)
1763 OSTIDX=$(index_from_ostuuid $OST)
1764 if [ $OST_DEACTIVE_IDX == -1 ]; then
1765 OST_DEACTIVE_IDX=$OSTIDX
1767 if [ $OSTIDX != $OST_DEACTIVE_IDX ]; then
1768 echo $OSC "is Deactivated:"
1769 do_facet $SINGLEMDS lctl --device %$OSC deactivate
1773 OSTIDX=$(index_from_ostuuid $OST)
1774 test_mkdir -p $DIR/$tdir
1775 $SETSTRIPE -c 1 $DIR/$tdir # 1 stripe / file
1777 for OSC in $MDS_OSCS; do
1778 OST=$(osc_to_ost $OSC)
1779 OSTIDX=$(index_from_ostuuid $OST)
1780 if [ $OSTIDX == $OST_DEACTIVE_IDX ]; then
1781 echo $OST "is degraded:"
1782 do_facet ost$((OSTIDX+1)) lctl set_param -n \
1783 obdfilter.$OST.degraded=1
1788 createmany -o $DIR/$tdir/$tfile $fcount
1790 for OSC in $MDS_OSCS; do
1791 OST=$(osc_to_ost $OSC)
1792 OSTIDX=$(index_from_ostuuid $OST)
1793 if [ $OSTIDX == $OST_DEACTIVE_IDX ]; then
1794 echo $OST "is recovered from degraded:"
1795 do_facet ost$((OSTIDX+1)) lctl set_param -n \
1796 obdfilter.$OST.degraded=0
1798 do_facet $SINGLEMDS lctl --device %$OSC activate
1802 # all osp devices get activated, hence -1 stripe count restored
1805 # sleep 2*lod_qos_maxage seconds waiting for lod qos to notice osp
1806 # devices get activated.
1808 $SETSTRIPE -c -1 $DIR/$tfile
1809 stripecnt=$($GETSTRIPE -c $DIR/$tfile)
1811 [ $stripecnt -ne $OSTCOUNT ] &&
1812 error "Of $OSTCOUNT OSTs, only $stripecnt is available"
1815 run_test 27y "create files while OST0 is degraded and the rest inactive"
1821 lmm_count=$($GETSTRIPE -c $1)
1822 lmm_seq=$($GETSTRIPE -v $1 | awk '/lmm_seq/ { print $2 }')
1823 lmm_oid=$($GETSTRIPE -v $1 | awk '/lmm_object_id/ { print $2 }')
1825 local old_ifs="$IFS"
1827 fid=($($LFS path2fid $1))
1830 log "FID seq ${fid[1]}, oid ${fid[2]} ver ${fid[3]}"
1831 log "LOV seq $lmm_seq, oid $lmm_oid, count: $lmm_count"
1833 # compare lmm_seq and lu_fid->f_seq
1834 [ $lmm_seq = ${fid[1]} ] || { error "SEQ mismatch"; return 1; }
1835 # compare lmm_object_id and lu_fid->oid
1836 [ $lmm_oid = ${fid[2]} ] || { error "OID mismatch"; return 2; }
1838 # check the trusted.fid attribute of the OST objects of the file
1839 local have_obdidx=false
1841 $GETSTRIPE $1 | while read obdidx oid hex seq; do
1842 # skip lines up to and including "obdidx"
1843 [ -z "$obdidx" ] && break
1844 [ "$obdidx" = "obdidx" ] && have_obdidx=true && continue
1845 $have_obdidx || continue
1847 local ost=$((obdidx + 1))
1848 local dev=$(ostdevname $ost)
1851 log "want: stripe:$stripe_nr ost:$obdidx oid:$oid/$hex seq:$seq"
1853 seq=$(echo $seq | sed -e "s/^0x//g")
1854 if [ $seq == 0 ] || [ $(facet_fstype ost$ost) == zfs ]; then
1855 oid_hex=$(echo $oid)
1857 oid_hex=$(echo $hex | sed -e "s/^0x//g")
1859 local obj_file="O/$seq/d$((oid %32))/$oid_hex"
1863 # Don't unmount/remount the OSTs if we don't need to do that.
1864 # LU-2577 changes filter_fid to be smaller, so debugfs needs
1865 # update too, until that use mount/ll_decode_filter_fid/mount.
1866 # Re-enable when debugfs will understand new filter_fid.
1868 if false && [ $(facet_fstype ost$ost) == ldiskfs ]; then
1869 ff=$(do_facet ost$ost "$DEBUGFS -c -R 'stat $obj_file' \
1870 $dev 2>/dev/null" | grep "parent=")
1873 mount_fstype ost$ost
1874 ff=$(do_facet ost$ost $LL_DECODE_FILTER_FID \
1875 $(facet_mntpt ost$ost)/$obj_file)
1876 unmount_fstype ost$ost
1877 start ost$ost $dev $OST_MOUNT_OPTS
1881 [ -z "$ff" ] && error "$obj_file: no filter_fid info"
1883 echo "$ff" | sed -e 's#.*objid=#got: objid=#'
1885 # /mnt/O/0/d23/23: objid=23 seq=0 parent=[0x200000400:0x1e:0x1]
1886 # fid: objid=23 seq=0 parent=[0x200000400:0x1e:0x0] stripe=1
1887 local ff_parent=$(echo $ff|sed -e 's/.*parent=.//')
1888 local ff_pseq=$(echo $ff_parent | cut -d: -f1)
1889 local ff_poid=$(echo $ff_parent | cut -d: -f2)
1891 if echo $ff_parent | grep -q 'stripe='; then
1892 ff_pstripe=$(echo $ff_parent | sed -e 's/.*stripe=//')
1895 # $LL_DECODE_FILTER_FID does not print "stripe="; look
1896 # into f_ver in this case. See the comment on
1899 ff_pstripe=$(echo $ff_parent | cut -d: -f3 |
1903 # compare lmm_seq and filter_fid->ff_parent.f_seq
1904 [ $ff_pseq = $lmm_seq ] ||
1905 error "FF parent SEQ $ff_pseq != $lmm_seq"
1906 # compare lmm_object_id and filter_fid->ff_parent.f_oid
1907 [ $ff_poid = $lmm_oid ] ||
1908 error "FF parent OID $ff_poid != $lmm_oid"
1909 (($ff_pstripe == $stripe_nr)) ||
1910 error "FF stripe $ff_pstripe != $stripe_nr"
1912 stripe_nr=$((stripe_nr + 1))
1917 remote_ost_nodsh && skip "remote OST with nodsh" && return
1918 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1919 test_mkdir -p $DIR/$tdir
1921 $SETSTRIPE -c 1 -i 0 -S 64k $DIR/$tdir/$tfile-1 ||
1922 { error "setstripe -c -1 failed"; return 1; }
1923 # We need to send a write to every object to get parent FID info set.
1924 # This _should_ also work for setattr, but does not currently.
1925 # touch $DIR/$tdir/$tfile-1 ||
1926 dd if=/dev/zero of=$DIR/$tdir/$tfile-1 bs=1M count=1 ||
1927 { error "dd $tfile-1 failed"; return 2; }
1928 $SETSTRIPE -c -1 -i $((OSTCOUNT - 1)) -S 1M $DIR/$tdir/$tfile-2 ||
1929 { error "setstripe -c -1 failed"; return 3; }
1930 dd if=/dev/zero of=$DIR/$tdir/$tfile-2 bs=1M count=$OSTCOUNT ||
1931 { error "dd $tfile-2 failed"; return 4; }
1933 # make sure write RPCs have been sent to OSTs
1936 check_seq_oid $DIR/$tdir/$tfile-1 || return 5
1937 check_seq_oid $DIR/$tdir/$tfile-2 || return 6
1939 run_test 27z "check SEQ/OID on the MDT and OST filesystems"
1941 test_27A() { # b=19102
1942 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1943 local restore_size=$($GETSTRIPE -S $MOUNT)
1944 local restore_count=$($GETSTRIPE -c $MOUNT)
1945 local restore_offset=$($GETSTRIPE -i $MOUNT)
1946 $SETSTRIPE -c 0 -i -1 -S 0 $MOUNT
1947 wait_update $HOSTNAME "$GETSTRIPE -c $MOUNT | sed 's/ *//g'" "1" 20 ||
1948 error "stripe count $($GETSTRIPE -c $MOUNT) != 1"
1949 local default_size=$($GETSTRIPE -S $MOUNT)
1950 local default_offset=$($GETSTRIPE -i $MOUNT)
1951 local dsize=$((1024 * 1024))
1952 [ $default_size -eq $dsize ] ||
1953 error "stripe size $default_size != $dsize"
1954 [ $default_offset -eq -1 ] ||error "stripe offset $default_offset != -1"
1955 $SETSTRIPE -c $restore_count -i $restore_offset -S $restore_size $MOUNT
1957 run_test 27A "check filesystem-wide default LOV EA values"
1959 test_27B() { # LU-2523
1960 test_mkdir -p $DIR/$tdir
1961 rm -f $DIR/$tdir/f0 $DIR/$tdir/f1
1963 # open f1 with O_LOV_DELAY_CREATE
1965 # call setstripe ioctl on open file descriptor for f1
1967 multiop $DIR/$tdir/f1 oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:nB1c \
1971 # open f1 with O_LOV_DELAY_CREATE
1973 # call setstripe ioctl on open file descriptor for f1
1975 multiop $DIR/$tdir/f1 oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:uB1c
1977 # Allow multiop to fail in imitation of NFS's busted semantics.
1980 run_test 27B "call setstripe on open unlinked file/rename victim"
1982 test_27C() { #LU-2871
1983 [[ $OSTCOUNT -lt 2 ]] && skip "needs >= 2 OSTs" && return
1991 test_mkdir -p $DIR/$tdir
1993 for i in $(seq 0 $((OSTCOUNT - 1))); do
1994 # set stripe across all OSTs starting from OST$i
1995 $SETSTRIPE -i $i -c -1 $tfile$i
1996 # get striping information
1997 ost_idx=($($GETSTRIPE $tfile$i |
1998 tail -n $((OSTCOUNT + 1)) | awk '{print $1}'))
2002 [ ${#ost_idx[@]} -eq $OSTCOUNT ] ||
2003 error "${#ost_idx[@]} != $OSTCOUNT"
2005 for index in $(seq 0 $((OSTCOUNT - 1))); do
2007 for j in $(echo ${ost_idx[@]}); do
2008 if [ $index -eq $j ]; then
2014 error "Can not find $index in ${ost_idx[@]}"
2018 run_test 27C "check full striping across all OSTs"
2021 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs" && return
2022 [ -n "$FILESET" ] && skip "SKIP due to FILESET set" && return
2023 local POOL=${POOL:-testpool}
2025 local last_ost=$(($OSTCOUNT - 1))
2027 local ost_list=$(seq $first_ost $ost_step $last_ost)
2028 local ost_range="$first_ost $last_ost $ost_step"
2030 test_mkdir -p $DIR/$tdir
2031 pool_add $POOL || error "pool_add failed"
2032 pool_add_targets $POOL $ost_range || error "pool_add_targets failed"
2033 llapi_layout_test -d$DIR/$tdir -p$POOL -o$OSTCOUNT ||
2034 error "llapi_layout_test failed"
2035 cleanup_pools || error "cleanup_pools failed"
2037 run_test 27D "validate llapi_layout API"
2039 # Verify that default_easize is increased from its initial value after
2040 # accessing a widely striped file.
2042 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs" && return
2043 [ $(lustre_version_code client) -lt $(version_code 2.5.57) ] &&
2044 skip "client does not have LU-3338 fix" && return
2046 # 72 bytes is the minimum space required to store striping
2047 # information for a file striped across one OST:
2048 # (sizeof(struct lov_user_md_v3) +
2049 # sizeof(struct lov_user_ost_data_v1))
2051 $LCTL set_param -n llite.*.default_easize $min_easize ||
2052 error "lctl set_param failed"
2053 local easize=$($LCTL get_param -n llite.*.default_easize)
2055 [ $easize -eq $min_easize ] ||
2056 error "failed to set default_easize"
2058 $LFS setstripe -c $OSTCOUNT $DIR/$tfile ||
2059 error "setstripe failed"
2063 easize=$($LCTL get_param -n llite.*.default_easize)
2065 [ $easize -gt $min_easize ] ||
2066 error "default_easize not updated"
2068 run_test 27E "check that default extended attribute size properly increases"
2070 # createtest also checks that device nodes are created and
2071 # then visible correctly (#2091)
2072 test_28() { # bug 2091
2074 $CREATETEST $DIR/d28/ct || error
2076 run_test 28 "create/mknod/mkdir with bad file types ============"
2079 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return 0
2080 cancel_lru_locks mdc
2086 declare -i LOCKCOUNTORIG=0
2087 for lock_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_count); do
2088 let LOCKCOUNTORIG=$LOCKCOUNTORIG+$lock_count
2090 [ $LOCKCOUNTORIG -eq 0 ] && error "No mdc lock count" && return 1
2092 declare -i LOCKUNUSEDCOUNTORIG=0
2093 for unused_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_unused_count); do
2094 let LOCKUNUSEDCOUNTORIG=$LOCKUNUSEDCOUNTORIG+$unused_count
2101 declare -i LOCKCOUNTCURRENT=0
2102 for lock_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_count); do
2103 let LOCKCOUNTCURRENT=$LOCKCOUNTCURRENT+$lock_count
2106 declare -i LOCKUNUSEDCOUNTCURRENT=0
2107 for unused_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_unused_count); do
2108 let LOCKUNUSEDCOUNTCURRENT=$LOCKUNUSEDCOUNTCURRENT+$unused_count
2111 if [[ $LOCKCOUNTCURRENT -gt $LOCKCOUNTORIG ]]; then
2112 $LCTL set_param -n ldlm.dump_namespaces ""
2113 error "CURRENT: $LOCKCOUNTCURRENT > $LOCKCOUNTORIG"
2114 $LCTL dk | sort -k4 -t: > $TMP/test_29.dk
2115 log "dumped log to $TMP/test_29.dk (bug 5793)"
2118 if [[ $LOCKUNUSEDCOUNTCURRENT -gt $LOCKUNUSEDCOUNTORIG ]]; then
2119 error "UNUSED: $LOCKUNUSEDCOUNTCURRENT > $LOCKUNUSEDCOUNTORIG"
2120 $LCTL dk | sort -k4 -t: > $TMP/test_29.dk
2121 log "dumped log to $TMP/test_29.dk (bug 5793)"
2125 run_test 29 "IT_GETATTR regression ============================"
2127 test_30a() { # was test_30
2128 cp $(which ls) $DIR || cp /bin/ls $DIR
2132 run_test 30a "execute binary from Lustre (execve) =============="
2135 cp `which ls` $DIR || cp /bin/ls $DIR
2137 $RUNAS $DIR/ls / || error
2140 run_test 30b "execute binary from Lustre as non-root ==========="
2142 test_30c() { # b=22376
2143 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2144 cp `which ls` $DIR || cp /bin/ls $DIR
2146 cancel_lru_locks mdc
2147 cancel_lru_locks osc
2148 $RUNAS $DIR/ls / || error
2151 run_test 30c "execute binary from Lustre without read perms ===="
2154 $OPENUNLINK $DIR/f31 $DIR/f31 || error
2155 $CHECKSTAT -a $DIR/f31 || error
2157 run_test 31a "open-unlink file =================================="
2160 touch $DIR/f31 || error
2161 ln $DIR/f31 $DIR/f31b || error
2162 $MULTIOP $DIR/f31b Ouc || error
2163 $CHECKSTAT -t file $DIR/f31 || error
2165 run_test 31b "unlink file with multiple links while open ======="
2168 touch $DIR/f31 || error
2169 ln $DIR/f31 $DIR/f31c || error
2170 multiop_bg_pause $DIR/f31 O_uc || return 1
2172 $MULTIOP $DIR/f31c Ouc
2173 kill -USR1 $MULTIPID
2176 run_test 31c "open-unlink file with multiple links ============="
2179 opendirunlink $DIR/d31d $DIR/d31d || error
2180 $CHECKSTAT -a $DIR/d31d || error
2182 run_test 31d "remove of open directory ========================="
2184 test_31e() { # bug 2904
2185 openfilleddirunlink $DIR/d31e || error
2187 run_test 31e "remove of open non-empty directory ==============="
2189 test_31f() { # bug 4554
2190 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2192 test_mkdir $DIR/d31f
2193 $SETSTRIPE -S 1048576 -c 1 $DIR/d31f
2194 cp /etc/hosts $DIR/d31f
2196 $GETSTRIPE $DIR/d31f/hosts
2197 multiop_bg_pause $DIR/d31f D_c || return 1
2200 rm -rv $DIR/d31f || error "first of $DIR/d31f"
2201 test_mkdir $DIR/d31f
2202 $SETSTRIPE -S 1048576 -c 1 $DIR/d31f
2203 cp /etc/hosts $DIR/d31f
2205 $GETSTRIPE $DIR/d31f/hosts
2206 multiop_bg_pause $DIR/d31f D_c || return 1
2209 kill -USR1 $MULTIPID || error "first opendir $MULTIPID not running"
2210 wait $MULTIPID || error "first opendir $MULTIPID failed"
2214 kill -USR1 $MULTIPID2 || error "second opendir $MULTIPID not running"
2215 wait $MULTIPID2 || error "second opendir $MULTIPID2 failed"
2218 run_test 31f "remove of open directory with open-unlink file ==="
2221 echo "-- cross directory link --"
2222 test_mkdir -c1 $DIR/${tdir}ga
2223 test_mkdir -c1 $DIR/${tdir}gb
2224 touch $DIR/${tdir}ga/f
2225 ln $DIR/${tdir}ga/f $DIR/${tdir}gb/g
2226 $CHECKSTAT -t file $DIR/${tdir}ga/f || error "source"
2227 [ `stat -c%h $DIR/${tdir}ga/f` == '2' ] || error "source nlink"
2228 $CHECKSTAT -t file $DIR/${tdir}gb/g || error "target"
2229 [ `stat -c%h $DIR/${tdir}gb/g` == '2' ] || error "target nlink"
2231 run_test 31g "cross directory link==============="
2234 echo "-- cross directory link --"
2235 test_mkdir -c1 $DIR/${tdir}
2236 test_mkdir -c1 $DIR/${tdir}/dir
2237 touch $DIR/${tdir}/f
2238 ln $DIR/${tdir}/f $DIR/${tdir}/dir/g
2239 $CHECKSTAT -t file $DIR/${tdir}/f || error "source"
2240 [ `stat -c%h $DIR/${tdir}/f` == '2' ] || error "source nlink"
2241 $CHECKSTAT -t file $DIR/${tdir}/dir/g || error "target"
2242 [ `stat -c%h $DIR/${tdir}/dir/g` == '2' ] || error "target nlink"
2244 run_test 31h "cross directory link under child==============="
2247 echo "-- cross directory link --"
2248 test_mkdir -c1 $DIR/$tdir
2249 test_mkdir -c1 $DIR/$tdir/dir
2250 touch $DIR/$tdir/dir/f
2251 ln $DIR/$tdir/dir/f $DIR/$tdir/g
2252 $CHECKSTAT -t file $DIR/$tdir/dir/f || error "source"
2253 [ `stat -c%h $DIR/$tdir/dir/f` == '2' ] || error "source nlink"
2254 $CHECKSTAT -t file $DIR/$tdir/g || error "target"
2255 [ `stat -c%h $DIR/$tdir/g` == '2' ] || error "target nlink"
2257 run_test 31i "cross directory link under parent==============="
2260 test_mkdir -c1 -p $DIR/$tdir
2261 test_mkdir -c1 -p $DIR/$tdir/dir1
2262 ln $DIR/$tdir/dir1 $DIR/$tdir/dir2 && error "ln for dir"
2263 link $DIR/$tdir/dir1 $DIR/$tdir/dir3 && error "link for dir"
2264 mlink $DIR/$tdir/dir1 $DIR/$tdir/dir4 && error "mlink for dir"
2265 mlink $DIR/$tdir/dir1 $DIR/$tdir/dir1 && error "mlink to the same dir"
2268 run_test 31j "link for directory==============="
2271 test_mkdir -c1 -p $DIR/$tdir
2273 touch $DIR/$tdir/exist
2274 mlink $DIR/$tdir/s $DIR/$tdir/t || error "mlink"
2275 mlink $DIR/$tdir/s $DIR/$tdir/exist && error "mlink to exist file"
2276 mlink $DIR/$tdir/s $DIR/$tdir/s && error "mlink to the same file"
2277 mlink $DIR/$tdir/s $DIR/$tdir && error "mlink to parent dir"
2278 mlink $DIR/$tdir $DIR/$tdir/s && error "mlink parent dir to target"
2279 mlink $DIR/$tdir/not-exist $DIR/$tdir/foo && error "mlink non-existing to new"
2280 mlink $DIR/$tdir/not-exist $DIR/$tdir/s && error "mlink non-existing to exist"
2283 run_test 31k "link to file: the same, non-existing, dir==============="
2289 touch $DIR/d31m2/exist
2290 mlink $DIR/d31m/s $DIR/d31m2/t || error "mlink"
2291 mlink $DIR/d31m/s $DIR/d31m2/exist && error "mlink to exist file"
2292 mlink $DIR/d31m/s $DIR/d31m2 && error "mlink to parent dir"
2293 mlink $DIR/d31m2 $DIR/d31m/s && error "mlink parent dir to target"
2294 mlink $DIR/d31m/not-exist $DIR/d31m2/foo && error "mlink non-existing to new"
2295 mlink $DIR/d31m/not-exist $DIR/d31m2/s && error "mlink non-existing to exist"
2298 run_test 31m "link to file: the same, non-existing, dir==============="
2301 touch $DIR/$tfile || error "cannot create '$DIR/$tfile'"
2302 nlink=$(stat --format=%h $DIR/$tfile)
2303 [ ${nlink:--1} -eq 1 ] || error "nlink is $nlink, expected 1"
2305 local cmd="exec $fd<$DIR/$tfile"
2308 trap "eval $cmd" EXIT
2309 nlink=$(stat --dereference --format=%h /proc/self/fd/$fd)
2310 [ ${nlink:--1} -eq 1 ] || error "nlink is $nlink, expected 1"
2311 rm $DIR/$tfile || error "cannot remove '$DIR/$tfile'"
2312 nlink=$(stat --dereference --format=%h /proc/self/fd/$fd)
2313 [ ${nlink:--1} -eq 0 ] || error "nlink is $nlink, expected 0"
2316 run_test 31n "check link count of unlinked file"
2319 local TEMPNAME=$(mktemp $1_XXXXXX)
2320 mlink $TEMPNAME $1 2> /dev/null &&
2321 echo "$BASHPID: link $TEMPNAME to $1 succeeded"
2325 test_31o() { # LU-2901
2326 test_mkdir -p $DIR/$tdir
2327 for LOOP in $(seq 100); do
2328 rm -f $DIR/$tdir/$tfile*
2329 for THREAD in $(seq 8); do
2330 link_one $DIR/$tdir/$tfile.$LOOP &
2333 local LINKS=$(ls -1 $DIR/$tdir | grep -c $tfile.$LOOP)
2334 [[ $LINKS -gt 1 ]] && ls $DIR/$tdir &&
2335 error "$LINKS duplicate links to $tfile.$LOOP" &&
2339 run_test 31o "duplicate hard links with same filename"
2342 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2344 test_mkdir $DIR/$tdir
2345 $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
2346 $LFS setdirstripe -D -c2 -t all_char $DIR/$tdir/striped_dir
2348 opendirunlink $DIR/$tdir/striped_dir/test1 ||
2349 error "open unlink test1 failed"
2350 opendirunlink $DIR/$tdir/striped_dir/test2 ||
2351 error "open unlink test2 failed"
2353 $CHECKSTAT -a $DIR/$tdir/striped_dir/test1 ||
2354 error "test1 still exists"
2355 $CHECKSTAT -a $DIR/$tdir/striped_dir/test2 ||
2356 error "test2 still exists"
2358 run_test 31p "remove of open striped directory"
2360 cleanup_test32_mount() {
2362 $UMOUNT $DIR/$tdir/ext2-mountpoint
2366 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2367 echo "== more mountpoints and symlinks ================="
2368 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2369 trap cleanup_test32_mount EXIT
2370 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2371 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2372 $CHECKSTAT -t dir $DIR/$tdir/ext2-mountpoint/.. || error
2373 cleanup_test32_mount
2375 run_test 32a "stat d32a/ext2-mountpoint/.. ====================="
2378 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2379 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2380 trap cleanup_test32_mount EXIT
2381 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2382 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2383 ls -al $DIR/$tdir/ext2-mountpoint/.. || error
2384 cleanup_test32_mount
2386 run_test 32b "open d32b/ext2-mountpoint/.. ====================="
2389 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2390 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2391 trap cleanup_test32_mount EXIT
2392 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2393 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2394 test_mkdir -p $DIR/$tdir/d2/test_dir
2395 $CHECKSTAT -t dir $DIR/$tdir/ext2-mountpoint/../d2/test_dir || error
2396 cleanup_test32_mount
2398 run_test 32c "stat d32c/ext2-mountpoint/../d2/test_dir ========="
2401 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2402 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2403 trap cleanup_test32_mount EXIT
2404 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2405 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2406 test_mkdir -p $DIR/$tdir/d2/test_dir
2407 ls -al $DIR/$tdir/ext2-mountpoint/../d2/test_dir || error
2408 cleanup_test32_mount
2410 run_test 32d "open d32d/ext2-mountpoint/../d2/test_dir ========="
2413 [ -e $DIR/d32e ] && rm -fr $DIR/d32e
2414 test_mkdir -p $DIR/d32e/tmp
2415 TMP_DIR=$DIR/d32e/tmp
2416 ln -s $DIR/d32e $TMP_DIR/symlink11
2417 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
2418 $CHECKSTAT -t link $DIR/d32e/tmp/symlink11 || error
2419 $CHECKSTAT -t link $DIR/d32e/symlink01 || error
2421 run_test 32e "stat d32e/symlink->tmp/symlink->lustre-subdir ===="
2424 [ -e $DIR/d32f ] && rm -fr $DIR/d32f
2425 test_mkdir -p $DIR/d32f/tmp
2426 TMP_DIR=$DIR/d32f/tmp
2427 ln -s $DIR/d32f $TMP_DIR/symlink11
2428 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
2429 ls $DIR/d32f/tmp/symlink11 || error
2430 ls $DIR/d32f/symlink01 || error
2432 run_test 32f "open d32f/symlink->tmp/symlink->lustre-subdir ===="
2435 TMP_DIR=$DIR/$tdir/tmp
2436 test_mkdir -p $DIR/$tdir/tmp
2437 test_mkdir $DIR/${tdir}2
2438 ln -s $DIR/${tdir}2 $TMP_DIR/symlink12
2439 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
2440 $CHECKSTAT -t link $TMP_DIR/symlink12 || error
2441 $CHECKSTAT -t link $DIR/$tdir/symlink02 || error
2442 $CHECKSTAT -t dir -f $TMP_DIR/symlink12 || error
2443 $CHECKSTAT -t dir -f $DIR/$tdir/symlink02 || error
2445 run_test 32g "stat d32g/symlink->tmp/symlink->lustre-subdir/${tdir}2"
2448 rm -fr $DIR/$tdir $DIR/${tdir}2
2449 TMP_DIR=$DIR/$tdir/tmp
2450 test_mkdir -p $DIR/$tdir/tmp
2451 test_mkdir $DIR/${tdir}2
2452 ln -s $DIR/${tdir}2 $TMP_DIR/symlink12
2453 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
2454 ls $TMP_DIR/symlink12 || error
2455 ls $DIR/$tdir/symlink02 || error
2457 run_test 32h "open d32h/symlink->tmp/symlink->lustre-subdir/${tdir}2"
2460 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2461 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2462 trap cleanup_test32_mount EXIT
2463 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2464 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2465 touch $DIR/$tdir/test_file
2466 $CHECKSTAT -t file $DIR/$tdir/ext2-mountpoint/../test_file || error
2467 cleanup_test32_mount
2469 run_test 32i "stat d32i/ext2-mountpoint/../test_file ==========="
2472 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2473 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2474 trap cleanup_test32_mount EXIT
2475 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2476 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2477 touch $DIR/$tdir/test_file
2478 cat $DIR/$tdir/ext2-mountpoint/../test_file || error
2479 cleanup_test32_mount
2481 run_test 32j "open d32j/ext2-mountpoint/../test_file ==========="
2484 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2486 trap cleanup_test32_mount EXIT
2487 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2488 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint
2489 test_mkdir -p $DIR/$tdir/d2
2490 touch $DIR/$tdir/d2/test_file || error
2491 $CHECKSTAT -t file $DIR/$tdir/ext2-mountpoint/../d2/test_file || error
2492 cleanup_test32_mount
2494 run_test 32k "stat d32k/ext2-mountpoint/../d2/test_file ========"
2497 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2499 trap cleanup_test32_mount EXIT
2500 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2501 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2502 test_mkdir -p $DIR/$tdir/d2
2503 touch $DIR/$tdir/d2/test_file
2504 cat $DIR/$tdir/ext2-mountpoint/../d2/test_file || error
2505 cleanup_test32_mount
2507 run_test 32l "open d32l/ext2-mountpoint/../d2/test_file ========"
2511 test_mkdir -p $DIR/d32m/tmp
2512 TMP_DIR=$DIR/d32m/tmp
2513 ln -s $DIR $TMP_DIR/symlink11
2514 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
2515 $CHECKSTAT -t link $DIR/d32m/tmp/symlink11 || error
2516 $CHECKSTAT -t link $DIR/d32m/symlink01 || error
2518 run_test 32m "stat d32m/symlink->tmp/symlink->lustre-root ======"
2522 test_mkdir -p $DIR/d32n/tmp
2523 TMP_DIR=$DIR/d32n/tmp
2524 ln -s $DIR $TMP_DIR/symlink11
2525 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
2526 ls -l $DIR/d32n/tmp/symlink11 || error
2527 ls -l $DIR/d32n/symlink01 || error
2529 run_test 32n "open d32n/symlink->tmp/symlink->lustre-root ======"
2533 test_mkdir -p $DIR/d32o/tmp
2534 TMP_DIR=$DIR/d32o/tmp
2535 ln -s $DIR/$tfile $TMP_DIR/symlink12
2536 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
2537 $CHECKSTAT -t link $DIR/d32o/tmp/symlink12 || error
2538 $CHECKSTAT -t link $DIR/d32o/symlink02 || error
2539 $CHECKSTAT -t file -f $DIR/d32o/tmp/symlink12 || error
2540 $CHECKSTAT -t file -f $DIR/d32o/symlink02 || error
2542 run_test 32o "stat d32o/symlink->tmp/symlink->lustre-root/$tfile"
2552 test_mkdir -p $DIR/d32p/tmp
2554 TMP_DIR=$DIR/d32p/tmp
2556 ln -s $DIR/$tfile $TMP_DIR/symlink12
2558 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
2560 cat $DIR/d32p/tmp/symlink12 || error
2562 cat $DIR/d32p/symlink02 || error
2565 run_test 32p "open d32p/symlink->tmp/symlink->lustre-root/$tfile"
2567 cleanup_testdir_mount() {
2573 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2574 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2575 trap cleanup_testdir_mount EXIT
2576 test_mkdir -p $DIR/$tdir
2577 touch $DIR/$tdir/under_the_mount
2578 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir
2579 ls $DIR/$tdir | grep "\<under_the_mount\>" && error
2580 cleanup_testdir_mount
2582 run_test 32q "stat follows mountpoints in Lustre (should return error)"
2585 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2586 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2587 trap cleanup_testdir_mount EXIT
2588 test_mkdir -p $DIR/$tdir
2589 touch $DIR/$tdir/under_the_mount
2590 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir
2591 ls $DIR/$tdir | grep -q under_the_mount && error || true
2592 cleanup_testdir_mount
2594 run_test 32r "opendir follows mountpoints in Lustre (should return error)"
2599 chmod 444 $DIR/$tfile
2600 chown $RUNAS_ID $DIR/$tfile
2602 $RUNAS $OPENFILE -f O_RDWR $DIR/$tfile && error || true
2605 run_test 33aa "write file with mode 444 (should return error) ===="
2609 test_mkdir -p $DIR/d33
2610 chown $RUNAS_ID $DIR/d33
2611 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $DIR/d33/f33|| error "create"
2612 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $DIR/d33/f33 && \
2613 error "open RDWR" || true
2615 run_test 33a "test open file(mode=0444) with O_RDWR (should return error)"
2619 test_mkdir -p $DIR/d33
2620 chown $RUNAS_ID $DIR/d33
2621 $RUNAS $OPENFILE -f 1286739555 $DIR/d33/f33 || true
2623 run_test 33b "test open file with malformed flags (No panic)"
2626 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2632 remote_ost_nodsh && skip "remote OST with nodsh" && return
2635 test_mkdir -p $DIR/d33
2636 # Read: 0, Write: 4, create/destroy: 2/0, stat: 1, punch: 0
2639 for ostnum in $(seq $OSTCOUNT); do
2640 # test-framework's OST numbering is one-based, while Lustre's
2642 ostname=$(printf "$FSNAME-OST%.4x" $((ostnum - 1)))
2643 # Parsing llobdstat's output sucks; we could grep the /proc
2644 # path, but that's likely to not be as portable as using the
2645 # llobdstat utility. So we parse lctl output instead.
2646 write_bytes=$(do_facet ost$ostnum lctl get_param -n \
2647 obdfilter/$ostname/stats |
2648 awk '/^write_bytes/ {print $7}' )
2649 echo "baseline_write_bytes@$OSTnum/$ostname=$write_bytes"
2650 if (( ${write_bytes:-0} > 0 ))
2657 $all_zeros || return 0
2660 echo foo > $DIR/d33/bar
2664 # Total up write_bytes after writing. We'd better find non-zeros.
2665 for ostnum in $(seq $OSTCOUNT); do
2666 ostname=$(printf "$FSNAME-OST%.4x" $((ostnum - 1)))
2667 write_bytes=$(do_facet ost$ostnum lctl get_param -n \
2668 obdfilter/$ostname/stats |
2669 awk '/^write_bytes/ {print $7}' )
2670 echo "write_bytes@$OSTnum/$ostname=$write_bytes"
2671 if (( ${write_bytes:-0} > 0 ))
2680 for ostnum in $(seq $OSTCOUNT); do
2681 ostname=$(printf "$FSNAME-OST%.4x" $((ostnum - 1)))
2682 echo "Check that write_bytes is present in obdfilter/*/stats:"
2683 do_facet ost$ostnum lctl get_param -n \
2684 obdfilter/$ostname/stats
2686 error "OST not keeping write_bytes stats (b22312)"
2689 run_test 33c "test llobdstat and write_bytes"
2692 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 2 MDTs" && return
2693 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2695 local remote_dir=$DIR/$tdir/remote_dir
2697 test_mkdir -p $DIR/$tdir
2698 $LFS mkdir -i $MDTIDX $remote_dir ||
2699 error "create remote directory failed"
2701 touch $remote_dir/$tfile
2702 chmod 444 $remote_dir/$tfile
2703 chown $RUNAS_ID $remote_dir/$tfile
2705 $RUNAS $OPENFILE -f O_RDWR $DIR/$tfile && error || true
2707 chown $RUNAS_ID $remote_dir
2708 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $remote_dir/f33 ||
2709 error "create" || true
2710 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $remote_dir/f33 &&
2711 error "open RDWR" || true
2712 $RUNAS $OPENFILE -f 1286739555 $remote_dir/f33 || true
2714 run_test 33d "openfile with 444 modes and malformed flags under remote dir"
2717 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2721 $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
2722 $LFS setdirstripe -i1 -c2 $DIR/$tdir/striped_dir1
2723 mkdir $DIR/$tdir/local_dir
2725 local s0_mode=$(stat -c%f $DIR/$tdir/striped_dir)
2726 local s1_mode=$(stat -c%f $DIR/$tdir/striped_dir1)
2727 local l_mode=$(stat -c%f $DIR/$tdir/local_dir)
2729 [ "$l_mode" = "$s0_mode" -a "$l_mode" = "$s1_mode" ] ||
2730 error "mkdir $l_mode striped0 $s0_mode striped1 $s1_mode"
2732 rmdir $DIR/$tdir/* || error "rmdir failed"
2735 $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
2736 $LFS setdirstripe -i1 -c2 $DIR/$tdir/striped_dir1
2737 mkdir $DIR/$tdir/local_dir
2739 s0_mode=$(stat -c%f $DIR/$tdir/striped_dir)
2740 s1_mode=$(stat -c%f $DIR/$tdir/striped_dir1)
2741 l_mode=$(stat -c%f $DIR/$tdir/local_dir)
2743 [ "$l_mode" = "$s0_mode" -a "$l_mode" = "$s1_mode" ] ||
2744 error "mkdir $l_mode striped0 $s0_mode striped1 $s1_mode 777"
2746 rmdir $DIR/$tdir/* || error "rmdir(umask 777) failed"
2749 $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
2750 $LFS setdirstripe -i1 -c2 $DIR/$tdir/striped_dir1
2751 mkdir $DIR/$tdir/local_dir
2753 s0_mode=$(stat -c%f $DIR/$tdir/striped_dir)
2754 s1_mode=$(stat -c%f $DIR/$tdir/striped_dir1)
2755 l_mode=$(stat -c%f $DIR/$tdir/local_dir)
2757 [ "$l_mode" = "$s0_mode" -a "$l_mode" = "$s1_mode" ] ||
2758 error "mkdir $l_mode striped0 $s0_mode striped1 $s1_mode 0"
2760 run_test 33e "mkdir and striped directory should have same mode"
2764 do_facet $SINGLEMDS $LCTL set_param mdt.*.enable_remote_dir_gid=0
2768 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2771 chmod go+rwx $DIR/$tdir
2772 do_facet $SINGLEMDS $LCTL set_param mdt.*.enable_remote_dir_gid=-1
2773 trap cleanup_33f EXIT
2775 $RUNAS lfs mkdir -c$MDSCOUNT $DIR/$tdir/striped_dir ||
2776 error "cannot create striped directory"
2778 $RUNAS touch $DIR/$tdir/striped_dir/{0..16} ||
2779 error "cannot create files in striped directory"
2781 $RUNAS rm $DIR/$tdir/striped_dir/{0..16} ||
2782 error "cannot remove files in striped directory"
2784 $RUNAS rmdir $DIR/$tdir/striped_dir ||
2785 error "cannot remove striped directory"
2789 run_test 33f "nonroot user can create, access, and remove a striped directory"
2791 TEST_34_SIZE=${TEST_34_SIZE:-2000000000000}
2794 $MCREATE $DIR/f34 || error
2795 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" || error
2796 $TRUNCATE $DIR/f34 $TEST_34_SIZE || error
2797 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" || error
2798 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2800 run_test 34a "truncate file that has not been opened ==========="
2803 [ ! -f $DIR/f34 ] && test_34a
2804 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2805 $OPENFILE -f O_RDONLY $DIR/f34
2806 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" || error
2807 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2809 run_test 34b "O_RDONLY opening file doesn't create objects ====="
2812 [ ! -f $DIR/f34 ] && test_34a
2813 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2814 $OPENFILE -f O_RDWR $DIR/f34
2815 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" && error
2816 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2818 run_test 34c "O_RDWR opening file-with-size works =============="
2821 [ ! -f $DIR/f34 ] && test_34a
2822 dd if=/dev/zero of=$DIR/f34 conv=notrunc bs=4k count=1 || error
2823 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2826 run_test 34d "write to sparse file ============================="
2830 $MCREATE $DIR/f34e || error
2831 $TRUNCATE $DIR/f34e 1000 || error
2832 $CHECKSTAT -s 1000 $DIR/f34e || error
2833 $OPENFILE -f O_RDWR $DIR/f34e
2834 $CHECKSTAT -s 1000 $DIR/f34e || error
2836 run_test 34e "create objects, some with size and some without =="
2838 test_34f() { # bug 6242, 6243
2839 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2842 $MCREATE $DIR/f34f || error
2843 $TRUNCATE $DIR/f34f $SIZE34F || error "truncating $DIR/f3f to $SIZE34F"
2844 dd if=$DIR/f34f of=$TMP/f34f
2845 $CHECKSTAT -s $SIZE34F $TMP/f34f || error "$TMP/f34f not $SIZE34F bytes"
2846 dd if=/dev/zero of=$TMP/f34fzero bs=$SIZE34F count=1
2847 cmp $DIR/f34f $TMP/f34fzero || error "$DIR/f34f not all zero"
2848 cmp $TMP/f34f $TMP/f34fzero || error "$TMP/f34f not all zero"
2849 rm $TMP/f34f $TMP/f34fzero $DIR/f34f
2851 run_test 34f "read from a file with no objects until EOF ======="
2854 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2855 dd if=/dev/zero of=$DIR/$tfile bs=1 count=100 seek=$TEST_34_SIZE || error
2856 $TRUNCATE $DIR/$tfile $((TEST_34_SIZE / 2))|| error
2857 $CHECKSTAT -s $((TEST_34_SIZE / 2)) $DIR/$tfile || error "truncate failed"
2858 cancel_lru_locks osc
2859 $CHECKSTAT -s $((TEST_34_SIZE / 2)) $DIR/$tfile || \
2860 error "wrong size after lock cancel"
2862 $TRUNCATE $DIR/$tfile $TEST_34_SIZE || error
2863 $CHECKSTAT -s $TEST_34_SIZE $DIR/$tfile || \
2864 error "expanding truncate failed"
2865 cancel_lru_locks osc
2866 $CHECKSTAT -s $TEST_34_SIZE $DIR/$tfile || \
2867 error "wrong expanded size after lock cancel"
2869 run_test 34g "truncate long file ==============================="
2872 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2876 dd if=/dev/zero of=$DIR/$tfile bs=1M count=10 || error
2877 sync # Flush the cache so that multiop below does not block on cache
2878 # flush when getting the group lock
2879 $MULTIOP $DIR/$tfile OG${gid}T${sz}g${gid}c &
2882 # Since just timed wait is not good enough, let's do a sync write
2883 # that way we are sure enough time for a roundtrip + processing
2884 # passed + 2 seconds of extra margin.
2885 dd if=/dev/zero of=$DIR/${tfile}-1 bs=4096 oflag=direct count=1
2889 if [[ `ps h -o comm -p $MULTIPID` == "multiop" ]]; then
2890 error "Multiop blocked on ftruncate, pid=$MULTIPID"
2894 local nsz=`stat -c %s $DIR/$tfile`
2895 [[ $nsz == $sz ]] || error "New size wrong $nsz != $sz"
2897 run_test 34h "ftruncate file under grouplock should not block"
2900 cp /bin/sh $DIR/f35a
2902 chown $RUNAS_ID $DIR/f35a
2903 $RUNAS $DIR/f35a && error || true
2906 run_test 35a "exec file with mode 444 (should return and not leak) ====="
2910 utime $DIR/f36 || error
2912 run_test 36a "MDS utime check (mknod, utime) ==================="
2916 utime $DIR/f36 || error
2918 run_test 36b "OST utime check (open, utime) ===================="
2923 chown $RUNAS_ID $DIR/d36
2924 $RUNAS utime $DIR/d36/f36 || error
2926 run_test 36c "non-root MDS utime check (mknod, utime) =========="
2929 [ ! -d $DIR/d36 ] && test_36c
2930 echo "" > $DIR/d36/f36
2931 $RUNAS utime $DIR/d36/f36 || error
2933 run_test 36d "non-root OST utime check (open, utime) ==========="
2936 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID -- skipping" && return
2937 test_mkdir -p $DIR/$tdir
2938 touch $DIR/$tdir/$tfile
2939 $RUNAS utime $DIR/$tdir/$tfile && \
2940 error "utime worked, expected failure" || true
2942 run_test 36e "utime on non-owned file (should return error) ===="
2946 local LANG_SAVE=$LANG
2947 local LC_LANG_SAVE=$LC_LANG
2948 export LANG=C LC_LANG=C # for date language
2950 DATESTR="Dec 20 2000"
2951 test_mkdir -p $DIR/$tdir
2952 lctl set_param fail_loc=$fl
2954 cp /etc/hosts $DIR/$tdir/$tfile
2955 sync & # write RPC generated with "current" inode timestamp, but delayed
2957 touch --date="$DATESTR" $DIR/$tdir/$tfile # setattr timestamp in past
2958 LS_BEFORE="`ls -l $DIR/$tdir/$tfile`" # old timestamp from client cache
2959 cancel_lru_locks osc
2960 LS_AFTER="`ls -l $DIR/$tdir/$tfile`" # timestamp from OST object
2962 [ "$LS_BEFORE" != "$LS_AFTER" ] && \
2963 echo "BEFORE: $LS_BEFORE" && \
2964 echo "AFTER : $LS_AFTER" && \
2965 echo "WANT : $DATESTR" && \
2966 error "$DIR/$tdir/$tfile timestamps changed" || true
2968 export LANG=$LANG_SAVE LC_LANG=$LC_LANG_SAVE
2972 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2973 #define OBD_FAIL_OST_BRW_PAUSE_BULK 0x214
2974 subr_36fh "0x80000214"
2976 run_test 36f "utime on file racing with OST BRW write =========="
2979 remote_ost_nodsh && skip "remote OST with nodsh" && return
2980 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2985 test_mkdir -p $DIR/$tdir
2986 fmd_max_age=$(do_facet ost1 \
2987 "lctl get_param -n obdfilter.*.client_cache_seconds 2> /dev/null | \
2990 fmd_before=$(do_facet ost1 \
2991 "awk '/ll_fmd_cache/ {print \\\$2}' /proc/slabinfo")
2992 touch $DIR/$tdir/$tfile
2993 sleep $((fmd_max_age + 12))
2994 fmd_after=$(do_facet ost1 \
2995 "awk '/ll_fmd_cache/ {print \\\$2}' /proc/slabinfo")
2997 echo "fmd_before: $fmd_before"
2998 echo "fmd_after: $fmd_after"
2999 [[ $fmd_after -gt $fmd_before ]] &&
3000 echo "AFTER: $fmd_after > BEFORE: $fmd_before" &&
3001 error "fmd didn't expire after ping" || true
3003 run_test 36g "filter mod data cache expiry ====================="
3006 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3007 #define OBD_FAIL_OST_BRW_PAUSE_BULK2 0x227
3008 subr_36fh "0x80000227"
3010 run_test 36h "utime on file racing with OST BRW write =========="
3013 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
3015 test_mkdir $DIR/$tdir
3016 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR/$tdir/striped_dir
3018 local mtime=$(stat -c%Y $DIR/$tdir/striped_dir)
3019 local new_mtime=$((mtime + 200))
3021 #change Modify time of striped dir
3022 touch -m -d @$new_mtime $DIR/$tdir/striped_dir ||
3023 error "change mtime failed"
3025 local got=$(stat -c%Y $DIR/$tdir/striped_dir)
3027 [ "$new_mtime" = "$got" ] || error "expect $new_mtime got $got"
3029 run_test 36i "change mtime on striped directory"
3031 # test_37 - duplicate with tests 32q 32r
3034 local file=$DIR/$tfile
3036 openfile -f O_DIRECTORY $file
3039 [ $RC -eq 0 ] && error "opened file $file with O_DIRECTORY" || true
3040 [ $RC -eq $ENOTDIR ] || error "error $RC should be ENOTDIR ($ENOTDIR)"
3042 run_test 38 "open a regular file with O_DIRECTORY should return -ENOTDIR ==="
3046 touch $DIR/${tfile}2
3047 # ls -l $DIR/$tfile $DIR/${tfile}2
3048 # ls -lu $DIR/$tfile $DIR/${tfile}2
3049 # ls -lc $DIR/$tfile $DIR/${tfile}2
3051 $OPENFILE -f O_CREAT:O_TRUNC:O_WRONLY $DIR/${tfile}2
3052 if [ ! $DIR/${tfile}2 -nt $DIR/$tfile ]; then
3054 ls -l --full-time $DIR/$tfile $DIR/${tfile}2
3056 ls -lu --full-time $DIR/$tfile $DIR/${tfile}2
3058 ls -lc --full-time $DIR/$tfile $DIR/${tfile}2
3059 error "O_TRUNC didn't change timestamps"
3062 run_test 39 "mtime changed on create ==========================="
3065 test_mkdir -p -c1 $DIR/$tdir
3066 cp -p /etc/passwd $DIR/$tdir/fopen
3067 cp -p /etc/passwd $DIR/$tdir/flink
3068 cp -p /etc/passwd $DIR/$tdir/funlink
3069 cp -p /etc/passwd $DIR/$tdir/frename
3070 ln $DIR/$tdir/funlink $DIR/$tdir/funlink2
3073 echo "aaaaaa" >> $DIR/$tdir/fopen
3074 echo "aaaaaa" >> $DIR/$tdir/flink
3075 echo "aaaaaa" >> $DIR/$tdir/funlink
3076 echo "aaaaaa" >> $DIR/$tdir/frename
3078 local open_new=`stat -c %Y $DIR/$tdir/fopen`
3079 local link_new=`stat -c %Y $DIR/$tdir/flink`
3080 local unlink_new=`stat -c %Y $DIR/$tdir/funlink`
3081 local rename_new=`stat -c %Y $DIR/$tdir/frename`
3083 cat $DIR/$tdir/fopen > /dev/null
3084 ln $DIR/$tdir/flink $DIR/$tdir/flink2
3085 rm -f $DIR/$tdir/funlink2
3086 mv -f $DIR/$tdir/frename $DIR/$tdir/frename2
3088 for (( i=0; i < 2; i++ )) ; do
3089 local open_new2=`stat -c %Y $DIR/$tdir/fopen`
3090 local link_new2=`stat -c %Y $DIR/$tdir/flink`
3091 local unlink_new2=`stat -c %Y $DIR/$tdir/funlink`
3092 local rename_new2=`stat -c %Y $DIR/$tdir/frename2`
3094 [ $open_new2 -eq $open_new ] || error "open file reverses mtime"
3095 [ $link_new2 -eq $link_new ] || error "link file reverses mtime"
3096 [ $unlink_new2 -eq $unlink_new ] || error "unlink file reverses mtime"
3097 [ $rename_new2 -eq $rename_new ] || error "rename file reverses mtime"
3099 cancel_lru_locks osc
3100 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3103 run_test 39b "mtime change on open, link, unlink, rename ======"
3105 # this should be set to past
3106 TEST_39_MTIME=`date -d "1 year ago" +%s`
3112 local mtime0=`stat -c %Y $DIR1/$tfile`
3114 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3115 local mtime1=`stat -c %Y $DIR1/$tfile`
3116 [ "$mtime1" = $TEST_39_MTIME ] || \
3117 error "mtime is not set to past: $mtime1, should be $TEST_39_MTIME"
3120 echo hello >> $DIR1/$tfile
3122 local mtime2=`stat -c %Y $DIR1/$tfile`
3123 [ "$mtime2" -ge "$d1" ] && [ "$mtime2" -le "$d2" ] || \
3124 error "mtime is not updated on write: $d1 <= $mtime2 <= $d2"
3126 mv $DIR1/$tfile $DIR1/$tfile-1
3128 for (( i=0; i < 2; i++ )) ; do
3129 local mtime3=`stat -c %Y $DIR1/$tfile-1`
3130 [ "$mtime2" = "$mtime3" ] || \
3131 error "mtime ($mtime2) changed (to $mtime3) on rename"
3133 cancel_lru_locks osc
3134 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3137 run_test 39c "mtime change on rename ==========================="
3141 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3144 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3146 for (( i=0; i < 2; i++ )) ; do
3147 local mtime=`stat -c %Y $DIR1/$tfile`
3148 [ $mtime = $TEST_39_MTIME ] || \
3149 error "mtime($mtime) is not set to $TEST_39_MTIME"
3151 cancel_lru_locks osc
3152 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3155 run_test 39d "create, utime, stat =============================="
3159 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3161 local mtime1=`stat -c %Y $DIR1/$tfile`
3163 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3165 for (( i=0; i < 2; i++ )) ; do
3166 local mtime2=`stat -c %Y $DIR1/$tfile`
3167 [ $mtime2 = $TEST_39_MTIME ] || \
3168 error "mtime($mtime2) is not set to $TEST_39_MTIME"
3170 cancel_lru_locks osc
3171 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3174 run_test 39e "create, stat, utime, stat ========================"
3178 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3180 mtime1=`stat -c %Y $DIR1/$tfile`
3183 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3185 for (( i=0; i < 2; i++ )) ; do
3186 local mtime2=`stat -c %Y $DIR1/$tfile`
3187 [ $mtime2 = $TEST_39_MTIME ] || \
3188 error "mtime($mtime2) is not set to $TEST_39_MTIME"
3190 cancel_lru_locks osc
3191 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3194 run_test 39f "create, stat, sleep, utime, stat ================="
3198 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3199 echo hello >> $DIR1/$tfile
3200 local mtime1=`stat -c %Y $DIR1/$tfile`
3203 chmod o+r $DIR1/$tfile
3205 for (( i=0; i < 2; i++ )) ; do
3206 local mtime2=`stat -c %Y $DIR1/$tfile`
3207 [ "$mtime1" = "$mtime2" ] || \
3208 error "lost mtime: $mtime2, should be $mtime1"
3210 cancel_lru_locks osc
3211 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3214 run_test 39g "write, chmod, stat ==============================="
3218 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3223 echo hello >> $DIR1/$tfile
3224 local mtime1=`stat -c %Y $DIR1/$tfile`
3226 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3228 if [ "$d1" != "$d2" ]; then
3229 echo "write and touch not within one second"
3231 for (( i=0; i < 2; i++ )) ; do
3232 local mtime2=`stat -c %Y $DIR1/$tfile`
3233 [ "$mtime2" = $TEST_39_MTIME ] || \
3234 error "lost mtime: $mtime2, should be $TEST_39_MTIME"
3236 cancel_lru_locks osc
3237 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3241 run_test 39h "write, utime within one second, stat ============="
3244 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3248 echo hello >> $DIR1/$tfile
3249 local mtime1=`stat -c %Y $DIR1/$tfile`
3251 mv $DIR1/$tfile $DIR1/$tfile-1
3253 for (( i=0; i < 2; i++ )) ; do
3254 local mtime2=`stat -c %Y $DIR1/$tfile-1`
3256 [ "$mtime1" = "$mtime2" ] || \
3257 error "lost mtime: $mtime2, should be $mtime1"
3259 cancel_lru_locks osc
3260 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3263 run_test 39i "write, rename, stat =============================="
3266 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3267 start_full_debug_logging
3271 #define OBD_FAIL_OSC_DELAY_SETTIME 0x412
3272 lctl set_param fail_loc=0x80000412
3273 multiop_bg_pause $DIR1/$tfile oO_RDWR:w2097152_c ||
3274 error "multiop failed"
3276 local mtime1=`stat -c %Y $DIR1/$tfile`
3278 mv $DIR1/$tfile $DIR1/$tfile-1
3280 kill -USR1 $multipid
3281 wait $multipid || error "multiop close failed"
3283 for (( i=0; i < 2; i++ )) ; do
3284 local mtime2=`stat -c %Y $DIR1/$tfile-1`
3285 [ "$mtime1" = "$mtime2" ] ||
3286 error "mtime is lost on close: $mtime2, " \
3289 cancel_lru_locks osc
3290 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3292 lctl set_param fail_loc=0
3293 stop_full_debug_logging
3295 run_test 39j "write, rename, close, stat ======================="
3298 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3302 multiop_bg_pause $DIR1/$tfile oO_RDWR:w2097152_c || error "multiop failed"
3304 local mtime1=`stat -c %Y $DIR1/$tfile`
3306 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3308 kill -USR1 $multipid
3309 wait $multipid || error "multiop close failed"
3311 for (( i=0; i < 2; i++ )) ; do
3312 local mtime2=`stat -c %Y $DIR1/$tfile`
3314 [ "$mtime2" = $TEST_39_MTIME ] || \
3315 error "mtime is lost on close: $mtime2, should be $TEST_39_MTIME"
3317 cancel_lru_locks osc
3318 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3321 run_test 39k "write, utime, close, stat ========================"
3323 # this should be set to future
3324 TEST_39_ATIME=`date -d "1 year" +%s`
3327 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3328 remote_mds_nodsh && skip "remote MDS with nodsh" && return
3329 local atime_diff=$(do_facet $SINGLEMDS \
3330 lctl get_param -n mdd.*MDT0000*.atime_diff)
3334 # test setting directory atime to future
3335 touch -a -d @$TEST_39_ATIME $DIR/$tdir
3336 local atime=$(stat -c %X $DIR/$tdir)
3337 [ "$atime" = $TEST_39_ATIME ] || \
3338 error "atime is not set to future: $atime, $TEST_39_ATIME"
3340 # test setting directory atime from future to now
3341 local d1=$(date +%s)
3343 local d2=$(date +%s)
3345 cancel_lru_locks mdc
3346 atime=$(stat -c %X $DIR/$tdir)
3347 [ "$atime" -ge "$d1" -a "$atime" -le "$d2" ] || \
3348 error "atime is not updated from future: $atime, $d1<atime<$d2"
3350 do_facet $SINGLEMDS lctl set_param -n mdd.*MDT0000*.atime_diff=2
3353 # test setting directory atime when now > dir atime + atime_diff
3357 cancel_lru_locks mdc
3358 atime=$(stat -c %X $DIR/$tdir)
3359 [ "$atime" -ge "$d1" -a "$atime" -le "$d2" ] || \
3360 error "atime is not updated : $atime, should be $d2"
3362 do_facet $SINGLEMDS lctl set_param -n mdd.*MDT0000*.atime_diff=60
3365 # test not setting directory atime when now < dir atime + atime_diff
3367 cancel_lru_locks mdc
3368 atime=$(stat -c %X $DIR/$tdir)
3369 [ "$atime" -ge "$d1" -a "$atime" -le "$d2" ] || \
3370 error "atime is updated to $atime, should remain $d1<atime<$d2"
3372 do_facet $SINGLEMDS \
3373 lctl set_param -n mdd.*MDT0000*.atime_diff=$atime_diff
3375 run_test 39l "directory atime update ==========================="
3378 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3381 local far_past_mtime=$(date -d "May 29 1953" +%s)
3382 local far_past_atime=$(date -d "Dec 17 1903" +%s)
3384 touch -m -d @$far_past_mtime $DIR1/$tfile
3385 touch -a -d @$far_past_atime $DIR1/$tfile
3387 for (( i=0; i < 2; i++ )) ; do
3388 local timestamps=$(stat -c "%X %Y" $DIR1/$tfile)
3389 [ "$timestamps" = "$far_past_atime $far_past_mtime" ] || \
3390 error "atime or mtime set incorrectly"
3392 cancel_lru_locks osc
3393 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3396 run_test 39m "test atime and mtime before 1970"
3398 test_39n() { # LU-3832
3399 local atime_diff=$(do_facet $SINGLEMDS \
3400 lctl get_param -n mdd.*MDT0000*.atime_diff)
3405 do_facet $SINGLEMDS lctl set_param -n mdd.*MDT0000*.atime_diff=1
3408 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 status=noxfer
3409 atime0=$(stat -c %X $DIR/$tfile)
3412 $MULTIOP $DIR/$tfile oO_RDONLY:O_NOATIME:r4096c
3413 atime1=$(stat -c %X $DIR/$tfile)
3416 cancel_lru_locks mdc
3417 cancel_lru_locks osc
3418 $MULTIOP $DIR/$tfile oO_RDONLY:O_NOATIME:r4096c
3419 atime2=$(stat -c %X $DIR/$tfile)
3421 do_facet $SINGLEMDS \
3422 lctl set_param -n mdd.*MDT0000*.atime_diff=$atime_diff
3424 [ "$atime0" -eq "$atime1" ] || error "atime0 $atime0 != atime1 $atime1"
3425 [ "$atime1" -eq "$atime2" ] || error "atime0 $atime0 != atime1 $atime1"
3427 run_test 39n "check that O_NOATIME is honored"
3430 TESTDIR=$DIR/$tdir/$tfile
3431 [ -e $TESTDIR ] && rm -rf $TESTDIR
3438 links2=$(stat -c %h .)
3439 [ $(($links1 + 2)) != $links2 ] &&
3440 error "wrong links count $(($links1 + 2)) != $links2"
3442 links3=$(stat -c %h .)
3443 [ $(($links1 + 1)) != $links3 ] &&
3444 error "wrong links count $links1 != $links3"
3447 run_test 39o "directory cached attributes updated after create ========"
3450 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 2 MDTs" && return
3452 TESTDIR=$DIR/$tdir/$tfile
3453 [ -e $TESTDIR ] && rm -rf $TESTDIR
3454 test_mkdir -p $TESTDIR
3458 $LFS mkdir -i $MDTIDX $TESTDIR/remote_dir1
3459 $LFS mkdir -i $MDTIDX $TESTDIR/remote_dir2
3461 links2=$(stat -c %h .)
3462 [ $(($links1 + 2)) != $links2 ] &&
3463 error "wrong links count $(($links1 + 2)) != $links2"
3465 links3=$(stat -c %h .)
3466 [ $(($links1 + 1)) != $links3 ] &&
3467 error "wrong links count $links1 != $links3"
3470 run_test 39p "remote directory cached attributes updated after create ========"
3474 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1
3475 $RUNAS $OPENFILE -f O_WRONLY:O_TRUNC $DIR/$tfile &&
3476 error "openfile O_WRONLY:O_TRUNC $tfile failed"
3477 $CHECKSTAT -t file -s 4096 $DIR/$tfile ||
3478 error "$tfile is not 4096 bytes in size"
3480 run_test 40 "failed open(O_TRUNC) doesn't truncate ============="
3484 small_write $DIR/f41 18
3486 run_test 41 "test small file write + fstat ====================="
3488 count_ost_writes() {
3489 lctl get_param -n osc.*.stats |
3490 awk -vwrites=0 '/ost_write/ { writes += $2 } \
3491 END { printf("%0.0f", writes) }'
3498 BG_DIRTY_RATIO_SAVE=10
3499 MAX_BG_DIRTY_RATIO=25
3503 # in 2.6, restore /proc/sys/vm/dirty_writeback_centisecs,
3504 # dirty_ratio, dirty_background_ratio
3505 if [ -f /proc/sys/vm/dirty_writeback_centisecs ]; then
3506 sysctl -w vm.dirty_writeback_centisecs=$WRITEBACK_SAVE
3507 sysctl -w vm.dirty_background_ratio=$BG_DIRTY_RATIO_SAVE
3508 sysctl -w vm.dirty_ratio=$DIRTY_RATIO_SAVE
3510 # if file not here, we are a 2.4 kernel
3511 kill -CONT `pidof kupdated`
3516 # setup the trap first, so someone cannot exit the test at the
3517 # exact wrong time and mess up a machine
3518 trap start_writeback EXIT
3519 # in 2.6, save and 0 /proc/sys/vm/dirty_writeback_centisecs
3520 if [ -f /proc/sys/vm/dirty_writeback_centisecs ]; then
3521 WRITEBACK_SAVE=`sysctl -n vm.dirty_writeback_centisecs`
3522 sysctl -w vm.dirty_writeback_centisecs=0
3523 sysctl -w vm.dirty_writeback_centisecs=0
3524 # save and increase /proc/sys/vm/dirty_ratio
3525 DIRTY_RATIO_SAVE=`sysctl -n vm.dirty_ratio`
3526 sysctl -w vm.dirty_ratio=$MAX_DIRTY_RATIO
3527 # save and increase /proc/sys/vm/dirty_background_ratio
3528 BG_DIRTY_RATIO_SAVE=`sysctl -n vm.dirty_background_ratio`
3529 sysctl -w vm.dirty_background_ratio=$MAX_BG_DIRTY_RATIO
3531 # if file not here, we are a 2.4 kernel
3532 kill -STOP `pidof kupdated`
3536 # ensure that all stripes have some grant before we test client-side cache
3538 for i in `seq -f $DIR/f42-%g 1 $OSTCOUNT`; do
3539 dd if=/dev/zero of=$i bs=4k count=1
3544 # Tests 42* verify that our behaviour is correct WRT caching, file closure,
3545 # file truncation, and file removal.
3547 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3549 cancel_lru_locks osc
3551 sync; sleep 1; sync # just to be safe
3552 BEFOREWRITES=`count_ost_writes`
3553 lctl get_param -n osc.*[oO][sS][cC][_-]*.cur_grant_bytes | grep "[0-9]"
3554 dd if=/dev/zero of=$DIR/f42a bs=1024 count=100
3555 AFTERWRITES=`count_ost_writes`
3556 [ $BEFOREWRITES -eq $AFTERWRITES ] || \
3557 error "$BEFOREWRITES < $AFTERWRITES"
3560 run_test 42a "ensure that we don't flush on close =============="
3563 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3565 cancel_lru_locks osc
3568 dd if=/dev/zero of=$DIR/f42b bs=1024 count=100
3569 BEFOREWRITES=$(count_ost_writes)
3570 $MUNLINK $DIR/f42b || error "$MUNLINK $DIR/f42b: $?"
3571 AFTERWRITES=$(count_ost_writes)
3572 if [[ $BEFOREWRITES -lt $AFTERWRITES ]]; then
3573 error "$BEFOREWRITES < $AFTERWRITES on unlink"
3575 BEFOREWRITES=$(count_ost_writes)
3576 sync || error "sync: $?"
3577 AFTERWRITES=$(count_ost_writes)
3578 if [[ $BEFOREWRITES -lt $AFTERWRITES ]]; then
3579 error "$BEFOREWRITES < $AFTERWRITES on sync"
3581 dmesg | grep 'error from obd_brw_async' && error 'error writing back'
3585 run_test 42b "test destroy of file with cached dirty data ======"
3587 # if these tests just want to test the effect of truncation,
3588 # they have to be very careful. consider:
3589 # - the first open gets a {0,EOF}PR lock
3590 # - the first write conflicts and gets a {0, count-1}PW
3591 # - the rest of the writes are under {count,EOF}PW
3592 # - the open for truncate tries to match a {0,EOF}PR
3593 # for the filesize and cancels the PWs.
3594 # any number of fixes (don't get {0,EOF} on open, match
3595 # composite locks, do smarter file size management) fix
3596 # this, but for now we want these tests to verify that
3597 # the cancellation with truncate intent works, so we
3598 # start the file with a full-file pw lock to match against
3599 # until the truncate.
3604 cancel_lru_locks osc
3606 # prime the file with 0,EOF PW to match
3610 # now the real test..
3611 dd if=/dev/zero of=$file bs=1024 count=100
3612 BEFOREWRITES=`count_ost_writes`
3613 $TRUNCATE $file $offset
3614 cancel_lru_locks osc
3615 AFTERWRITES=`count_ost_writes`
3620 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3622 [ $BEFOREWRITES -eq $AFTERWRITES ] && \
3623 error "beforewrites $BEFOREWRITES == afterwrites $AFTERWRITES on truncate"
3626 run_test 42c "test partial truncate of file with cached dirty data"
3629 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3631 [ $BEFOREWRITES -eq $AFTERWRITES ] || \
3632 error "beforewrites $BEFOREWRITES != afterwrites $AFTERWRITES on truncate"
3635 run_test 42d "test complete truncate of file with cached dirty data"
3637 test_42e() { # bug22074
3638 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3639 local TDIR=$DIR/${tdir}e
3640 local pagesz=$(page_size)
3641 local pages=16 # hardcoded 16 pages, don't change it.
3642 local files=$((OSTCOUNT * 500)) # hopefully 500 files on each OST
3643 local proc_osc0="osc.${FSNAME}-OST0000-osc-[^MDT]*"
3647 test_mkdir -p $DIR/${tdir}e
3648 $SETSTRIPE -c 1 $TDIR
3649 createmany -o $TDIR/f $files
3651 max_dirty_mb=$($LCTL get_param -n $proc_osc0/max_dirty_mb)
3653 # we assume that with $OSTCOUNT files, at least one of them will
3654 # be allocated on OST0.
3655 warmup_files=$((OSTCOUNT * max_dirty_mb))
3656 createmany -o $TDIR/w $warmup_files
3658 # write a large amount of data into one file and sync, to get good
3659 # avail_grant number from OST.
3660 for ((i=0; i<$warmup_files; i++)); do
3661 idx=$($GETSTRIPE -i $TDIR/w$i)
3662 [ $idx -ne 0 ] && continue
3663 dd if=/dev/zero of=$TDIR/w$i bs="$max_dirty_mb"M count=1
3666 [[ $i -gt $warmup_files ]] && error "OST0 is still cold"
3668 $LCTL get_param $proc_osc0/cur_dirty_bytes
3669 $LCTL get_param $proc_osc0/cur_grant_bytes
3671 # create as much dirty pages as we can while not to trigger the actual
3672 # RPCs directly. but depends on the env, VFS may trigger flush during this
3673 # period, hopefully we are good.
3674 for ((i=0; i<$warmup_files; i++)); do
3675 idx=$($GETSTRIPE -i $TDIR/w$i)
3676 [ $idx -ne 0 ] && continue
3677 dd if=/dev/zero of=$TDIR/w$i bs=1M count=1 2>/dev/null
3679 $LCTL get_param $proc_osc0/cur_dirty_bytes
3680 $LCTL get_param $proc_osc0/cur_grant_bytes
3682 # perform the real test
3683 $LCTL set_param $proc_osc0/rpc_stats 0
3684 for ((;i<$files; i++)); do
3685 [ $($GETSTRIPE -i $TDIR/f$i) -eq 0 ] || continue
3686 dd if=/dev/zero of=$TDIR/f$i bs=$pagesz count=$pages 2>/dev/null
3689 $LCTL get_param $proc_osc0/rpc_stats
3692 local have_ppr=false
3693 $LCTL get_param $proc_osc0/rpc_stats |
3694 while read PPR RRPC RPCT RCUM BAR WRPC WPCT WCUM; do
3695 # skip lines until we are at the RPC histogram data
3696 [ "$PPR" == "pages" ] && have_ppr=true && continue
3697 $have_ppr || continue
3699 # we only want the percent stat for < 16 pages
3700 [[ $(echo $PPR | tr -d ':') -ge $pages ]] && break
3702 percent=$((percent + WPCT))
3703 if [[ $percent -gt 15 ]]; then
3704 error "less than 16-pages write RPCs" \
3711 run_test 42e "verify sub-RPC writes are not done synchronously"
3714 test_mkdir -p $DIR/$tdir
3715 cp -p /bin/ls $DIR/$tdir/$tfile
3716 $MULTIOP $DIR/$tdir/$tfile Ow_c &
3718 # give multiop a chance to open
3721 $DIR/$tdir/$tfile && error || true
3724 run_test 43 "execution of file opened for write should return -ETXTBSY"
3727 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3728 test_mkdir -p $DIR/$tdir
3729 cp -p `which $MULTIOP` $DIR/$tdir/multiop ||
3730 cp -p multiop $DIR/$tdir/multiop
3731 MULTIOP_PROG=$DIR/$tdir/multiop multiop_bg_pause $TMP/$tfile.junk O_c ||
3734 $MULTIOP $DIR/$tdir/multiop Oc && error "expected error, got success"
3735 kill -USR1 $MULTIOP_PID || return 2
3736 wait $MULTIOP_PID || return 3
3737 rm $TMP/$tfile.junk $DIR/$tdir/multiop
3739 run_test 43a "open(RDWR) of file being executed should return -ETXTBSY"
3742 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3743 test_mkdir -p $DIR/$tdir
3744 cp -p `which $MULTIOP` $DIR/$tdir/multiop ||
3745 cp -p multiop $DIR/$tdir/multiop
3746 MULTIOP_PROG=$DIR/$tdir/multiop multiop_bg_pause $TMP/$tfile.junk O_c ||
3749 $TRUNCATE $DIR/$tdir/multiop 0 && error "expected error, got success"
3750 kill -USR1 $MULTIOP_PID || return 2
3751 wait $MULTIOP_PID || return 3
3752 rm $TMP/$tfile.junk $DIR/$tdir/multiop
3754 run_test 43b "truncate of file being executed should return -ETXTBSY"
3757 local testdir="$DIR/$tdir"
3758 test_mkdir -p $DIR/$tdir
3760 ( cd $(dirname $SHELL) && md5sum $(basename $SHELL) ) | \
3761 ( cd $testdir && md5sum -c)
3763 run_test 43c "md5sum of copy into lustre========================"
3766 [[ $OSTCOUNT -lt 2 ]] && skip_env "skipping 2-stripe test" && return
3767 dd if=/dev/zero of=$DIR/f1 bs=4k count=1 seek=1023
3768 dd if=$DIR/f1 bs=4k count=1 > /dev/null
3770 run_test 44 "zero length read from a sparse stripe ============="
3773 local nstripe=$($LCTL lov_getconfig $DIR | grep default_stripe_count: |
3775 [ -z "$nstripe" ] && skip "can't get stripe info" && return
3776 [[ $nstripe -gt $OSTCOUNT ]] &&
3777 skip "Wrong default_stripe_count: $nstripe (OSTCOUNT: $OSTCOUNT)" &&
3779 local stride=$($LCTL lov_getconfig $DIR | grep default_stripe_size: |
3781 if [[ $nstripe -eq 0 || $nstripe -eq -1 ]]; then
3782 nstripe=$($LCTL lov_getconfig $DIR | grep obd_count: |
3786 OFFSETS="0 $((stride/2)) $((stride-1))"
3787 for offset in $OFFSETS; do
3788 for i in $(seq 0 $((nstripe-1))); do
3789 local GLOBALOFFSETS=""
3791 local size=$((((i + 2 * $nstripe )*$stride + $offset)))
3792 local myfn=$DIR/d44a-$size
3793 echo "--------writing $myfn at $size"
3794 ll_sparseness_write $myfn $size ||
3795 error "ll_sparseness_write"
3796 GLOBALOFFSETS="$GLOBALOFFSETS $size"
3797 ll_sparseness_verify $myfn $GLOBALOFFSETS ||
3798 error "ll_sparseness_verify $GLOBALOFFSETS"
3800 for j in $(seq 0 $((nstripe-1))); do
3802 size=$((((j + $nstripe )*$stride + $offset)))
3803 ll_sparseness_write $myfn $size ||
3804 error "ll_sparseness_write"
3805 GLOBALOFFSETS="$GLOBALOFFSETS $size"
3807 ll_sparseness_verify $myfn $GLOBALOFFSETS ||
3808 error "ll_sparseness_verify $GLOBALOFFSETS"
3813 run_test 44a "test sparse pwrite ==============================="
3817 for d in `lctl get_param -n osc.*.cur_dirty_bytes`; do
3823 before=`dirty_osc_total`
3824 echo executing "\"$*\""
3826 after=`dirty_osc_total`
3827 echo before $before, after $after
3830 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3832 # Obtain grants from OST if it supports it
3833 echo blah > ${f}_grant
3836 do_dirty_record "echo blah > $f"
3837 [[ $before -eq $after ]] && error "write wasn't cached"
3838 do_dirty_record "> $f"
3839 [[ $before -gt $after ]] || error "truncate didn't lower dirty count"
3840 do_dirty_record "echo blah > $f"
3841 [[ $before -eq $after ]] && error "write wasn't cached"
3842 do_dirty_record "sync"
3843 [[ $before -gt $after ]] || error "writeback didn't lower dirty count"
3844 do_dirty_record "echo blah > $f"
3845 [[ $before -eq $after ]] && error "write wasn't cached"
3846 do_dirty_record "cancel_lru_locks osc"
3847 [[ $before -gt $after ]] ||
3848 error "lock cancellation didn't lower dirty count"
3851 run_test 45 "osc io page accounting ============================"
3853 # in a 2 stripe file (lov.sh), page 1023 maps to page 511 in its object. this
3854 # test tickles a bug where re-dirtying a page was failing to be mapped to the
3855 # objects offset and an assert hit when an rpc was built with 1023's mapped
3856 # offset 511 and 511's raw 511 offset. it also found general redirtying bugs.
3858 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3862 dd if=/dev/zero of=$f bs=`page_size` seek=511 count=1
3864 dd conv=notrunc if=/dev/zero of=$f bs=`page_size` seek=1023 count=1
3865 dd conv=notrunc if=/dev/zero of=$f bs=`page_size` seek=511 count=1
3869 run_test 46 "dirtying a previously written page ================"
3871 # test_47 is removed "Device nodes check" is moved to test_28
3873 test_48a() { # bug 2399
3874 [ $(facet_fstype $SINGLEMDS) = "zfs" ] &&
3875 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.3.63) ] &&
3876 skip "MDS prior to 2.3.63 handle ZFS dir .. incorrectly" &&
3878 test_mkdir $DIR/$tdir
3880 mv $DIR/$tdir $DIR/$tdir.new || error "move directory failed"
3881 test_mkdir $DIR/$tdir || error "recreate directory failed"
3882 touch foo || error "'touch foo' failed after recreating cwd"
3883 test_mkdir bar || error "'mkdir foo' failed after recreating cwd"
3884 touch .foo || error "'touch .foo' failed after recreating cwd"
3885 test_mkdir .bar || error "'mkdir .foo' failed after recreating cwd"
3886 ls . > /dev/null || error "'ls .' failed after recreating cwd"
3887 ls .. > /dev/null || error "'ls ..' failed after removing cwd"
3888 cd . || error "'cd .' failed after recreating cwd"
3889 test_mkdir . && error "'mkdir .' worked after recreating cwd"
3890 rmdir . && error "'rmdir .' worked after recreating cwd"
3891 ln -s . baz || error "'ln -s .' failed after recreating cwd"
3892 cd .. || error "'cd ..' failed after recreating cwd"
3894 run_test 48a "Access renamed working dir (should return errors)="
3896 test_48b() { # bug 2399
3898 test_mkdir $DIR/$tdir
3900 rmdir $DIR/$tdir || error "remove cwd $DIR/$tdir failed"
3901 touch foo && error "'touch foo' worked after removing cwd"
3902 test_mkdir foo && error "'mkdir foo' worked after removing cwd"
3903 touch .foo && error "'touch .foo' worked after removing cwd"
3904 test_mkdir .foo && error "'mkdir .foo' worked after removing cwd"
3905 ls . > /dev/null && error "'ls .' worked after removing cwd"
3906 ls .. > /dev/null || error "'ls ..' failed after removing cwd"
3907 test_mkdir . && error "'mkdir .' worked after removing cwd"
3908 rmdir . && error "'rmdir .' worked after removing cwd"
3909 ln -s . foo && error "'ln -s .' worked after removing cwd"
3910 cd .. || echo "'cd ..' failed after removing cwd `pwd`" #bug 3517
3912 run_test 48b "Access removed working dir (should return errors)="
3914 test_48c() { # bug 2350
3915 #lctl set_param debug=-1
3918 test_mkdir -p $DIR/$tdir/dir
3920 $TRACE rmdir $DIR/$tdir/dir || error "remove cwd $DIR/$tdir/dir failed"
3921 $TRACE touch foo && error "touch foo worked after removing cwd"
3922 $TRACE test_mkdir foo && error "'mkdir foo' worked after removing cwd"
3923 touch .foo && error "touch .foo worked after removing cwd"
3924 test_mkdir .foo && error "mkdir .foo worked after removing cwd"
3925 $TRACE ls . && error "'ls .' worked after removing cwd"
3926 $TRACE ls .. || error "'ls ..' failed after removing cwd"
3927 $TRACE test_mkdir . && error "'mkdir .' worked after removing cwd"
3928 $TRACE rmdir . && error "'rmdir .' worked after removing cwd"
3929 $TRACE ln -s . foo && error "'ln -s .' worked after removing cwd"
3930 $TRACE cd .. || echo "'cd ..' failed after removing cwd `pwd`" #bug 3415
3932 run_test 48c "Access removed working subdir (should return errors)"
3934 test_48d() { # bug 2350
3935 #lctl set_param debug=-1
3938 test_mkdir -p $DIR/$tdir/dir
3940 $TRACE rmdir $DIR/$tdir/dir || error "remove cwd $DIR/$tdir/dir failed"
3941 $TRACE rmdir $DIR/$tdir || error "remove parent $DIR/$tdir failed"
3942 $TRACE touch foo && error "'touch foo' worked after removing parent"
3943 $TRACE test_mkdir foo && error "mkdir foo worked after removing parent"
3944 touch .foo && error "'touch .foo' worked after removing parent"
3945 test_mkdir .foo && error "mkdir .foo worked after removing parent"
3946 $TRACE ls . && error "'ls .' worked after removing parent"
3947 $TRACE ls .. && error "'ls ..' worked after removing parent"
3948 $TRACE test_mkdir . && error "'mkdir .' worked after removing parent"
3949 $TRACE rmdir . && error "'rmdir .' worked after removing parent"
3950 $TRACE ln -s . foo && error "'ln -s .' worked after removing parent"
3953 run_test 48d "Access removed parent subdir (should return errors)"
3955 test_48e() { # bug 4134
3956 #lctl set_param debug=-1
3959 test_mkdir -p $DIR/$tdir/dir
3961 $TRACE rmdir $DIR/$tdir/dir || error "remove cwd $DIR/$tdir/dir failed"
3962 $TRACE rmdir $DIR/$tdir || error "remove parent $DIR/$tdir failed"
3963 $TRACE touch $DIR/$tdir || error "'touch $DIR/$tdir' failed"
3964 $TRACE chmod +x $DIR/$tdir || error "'chmod +x $DIR/$tdir' failed"
3965 # On a buggy kernel addition of "touch foo" after cd .. will
3966 # produce kernel oops in lookup_hash_it
3967 touch ../foo && error "'cd ..' worked after recreate parent"
3969 $TRACE rm $DIR/$tdir || error "rm '$DIR/$tdir' failed"
3971 run_test 48e "Access to recreated parent subdir (should return errors)"
3973 test_49() { # LU-1030
3974 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3975 # get ost1 size - lustre-OST0000
3976 ost1_size=$(do_facet ost1 $LFS df | grep ${ost1_svc} |
3978 # write 800M at maximum
3979 [[ $ost1_size -lt 2 ]] && ost1_size=2
3980 [[ $ost1_size -gt 819200 ]] && ost1_size=819200
3982 $SETSTRIPE -c 1 -i 0 $DIR/$tfile
3983 dd if=/dev/zero of=$DIR/$tfile bs=4k count=$((ost1_size >> 2)) &
3986 # change max_pages_per_rpc while writing the file
3987 local osc1_mppc=osc.$(get_osc_import_name client ost1).max_pages_per_rpc
3988 local orig_mppc=$($LCTL get_param -n $osc1_mppc)
3989 # loop until dd process exits
3990 while ps ax -opid | grep -wq $dd_pid; do
3991 $LCTL set_param $osc1_mppc=$((RANDOM % 256 + 1))
3992 sleep $((RANDOM % 5 + 1))
3994 # restore original max_pages_per_rpc
3995 $LCTL set_param $osc1_mppc=$orig_mppc
3996 rm $DIR/$tfile || error "rm $DIR/$tfile failed"
3998 run_test 49 "Change max_pages_per_rpc won't break osc extent"
4002 test_mkdir $DIR/$tdir
4004 ls /proc/$$/cwd || error "ls /proc/$$/cwd failed"
4006 run_test 50 "special situations: /proc symlinks ==============="
4008 test_51a() { # was test_51
4009 # bug 1516 - create an empty entry right after ".." then split dir
4010 test_mkdir -c1 $DIR/$tdir
4011 touch $DIR/$tdir/foo
4012 $MCREATE $DIR/$tdir/bar
4014 createmany -m $DIR/$tdir/longfile 201
4016 while [[ $(ls -sd $DIR/$tdir | awk '{ print $1 }') -eq 4 ]]; do
4017 $MCREATE $DIR/$tdir/longfile$FNUM
4022 ls -l $DIR/$tdir > /dev/null || error "ls -l $DIR/$tdir failed"
4024 run_test 51a "special situations: split htree with empty entry =="
4026 export NUMTEST=70000
4028 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4029 local BASE=$DIR/d${base}.${TESTSUITE}
4031 # cleanup the directory
4034 test_mkdir -p -c1 $BASE
4038 local mdtidx=$(printf "%04x" $($LFS getstripe -M $BASE))
4039 local numfree=$(lctl get_param -n mdc.$FSNAME-MDT$mdtidx*.filesfree)
4040 [[ $numfree -lt 21000 ]] &&
4041 skip "not enough free inodes ($numfree) on MDT$mdtidx" &&
4044 [[ $numfree -lt $NUMTEST ]] && NUMTEST=$(($numfree - 50)) &&
4045 echo "reduced count to $NUMTEST due to inodes on MDT$mdtidx"
4047 # need to check free space for the directories as well
4048 local blkfree=$(lctl get_param -n mdc.$FSNAME-MDT$mdtidx*.kbytesavail)
4049 numfree=$((blkfree / 4))
4050 [[ $numfree -lt $NUMTEST ]] && NUMTEST=$((numfree - 50)) &&
4051 echo "reduced count to $NUMTEST due to blocks on MDT$mdtidx"
4053 createmany -d $BASE/d $NUMTEST && echo $NUMTEST > $BASE/fnum ||
4057 echo "failed" > $BASE/fnum
4058 error "failed to create $NUMTEST subdirs in MDT$mdtidx:$BASE"
4061 run_test 51b "exceed 64k subdirectory nlink limit"
4063 test_51ba() { # LU-993
4064 local BASE=$DIR/d${base}.${TESTSUITE}
4065 # unlink all but 100 subdirectories, then check it still works
4067 [ -f $BASE/fnum ] && local NUMPREV=$(cat $BASE/fnum) && rm $BASE/fnum
4069 [ "$NUMPREV" != "failed" ] && NUMTEST=$NUMPREV
4070 local DELETE=$((NUMTEST - LEFT))
4072 # continue on to run this test even if 51b didn't finish,
4073 # just to delete the many subdirectories created.
4074 [ ! -d "${BASE}/d1" ] && skip "test_51b() not run" && return 0
4076 # for ldiskfs the nlink count should be 1, but this is OSD specific
4077 # and so this is listed for informational purposes only
4078 echo "nlink before: $(stat -c %h $BASE), created before: $NUMTEST"
4079 unlinkmany -d $BASE/d $DELETE
4082 if [ $RC -ne 0 ]; then
4083 if [ "$NUMPREV" == "failed" ]; then
4084 skip "previous setup failed"
4087 error "unlink of first $DELETE subdirs failed"
4092 echo "nlink between: $(stat -c %h $BASE)"
4093 # trim the first line of ls output
4094 local FOUND=$(($(ls -l ${BASE} | wc -l) - 1))
4095 [ $FOUND -ne $LEFT ] &&
4096 error "can't find subdirs: found only $FOUND/$LEFT"
4098 unlinkmany -d $BASE/d $DELETE $LEFT ||
4099 error "unlink of second $LEFT subdirs failed"
4100 # regardless of whether the backing filesystem tracks nlink accurately
4101 # or not, the nlink count shouldn't be more than "." and ".." here
4102 local AFTER=$(stat -c %h $BASE)
4103 [[ $AFTER -gt 2 ]] && error "nlink after: $AFTER > 2" ||
4104 echo "nlink after: $AFTER"
4106 run_test 51ba "verify nlink for many subdirectory cleanup"
4109 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4110 [[ $OSTCOUNT -lt 3 ]] &&
4111 skip_env "skipping test with few OSTs" && return
4112 test_mkdir -p $DIR/$tdir
4113 createmany -o $DIR/$tdir/t- 1000
4114 $GETSTRIPE $DIR/$tdir > $TMP/files
4115 for N in $(seq 0 $((OSTCOUNT - 1))); do
4116 OBJS[$N]=$(awk -vobjs=0 '($1 == '$N') { objs += 1 } \
4117 END { printf("%0.0f", objs) }' $TMP/files)
4118 OBJS0[$N]=$(grep -A 1 idx $TMP/files | awk -vobjs=0 \
4119 '($1 == '$N') { objs += 1 } \
4120 END { printf("%0.0f", objs) }')
4121 log "OST$N has ${OBJS[$N]} objects, ${OBJS0[$N]} are index 0"
4123 unlinkmany $DIR/$tdir/t- 1000
4126 for N in $(seq 1 $((OSTCOUNT - 1))); do
4127 [[ ${OBJS[$N]} -lt $((${OBJS[$NLAST]} - 20)) ]] &&
4128 error "OST $N has less objects vs OST $NLAST" \
4129 " (${OBJS[$N]} < ${OBJS[$NLAST]}"
4130 [[ ${OBJS[$N]} -gt $((${OBJS[$NLAST]} + 20)) ]] &&
4131 error "OST $N has less objects vs OST $NLAST" \
4132 " (${OBJS[$N]} < ${OBJS[$NLAST]}"
4134 [[ ${OBJS0[$N]} -lt $((${OBJS0[$NLAST]} - 20)) ]] &&
4135 error "OST $N has less #0 objects vs OST $NLAST" \
4136 " (${OBJS0[$N]} < ${OBJS0[$NLAST]}"
4137 [[ ${OBJS0[$N]} -gt $((${OBJS0[$NLAST]} + 20)) ]] &&
4138 error "OST $N has less #0 objects vs OST $NLAST" \
4139 " (${OBJS0[$N]} < ${OBJS0[$NLAST]}"
4143 run_test 51d "check object distribution ===================="
4146 if [ "$(facet_fstype $SINGLEMDS)" != ldiskfs ]; then
4147 skip "Only applicable to ldiskfs-based MDTs"
4151 test_mkdir -c1 $DIR/$tdir || error "create $tdir failed"
4152 test_mkdir -c1 $DIR/$tdir/d0 || error "create d0 failed"
4154 touch $DIR/$tdir/d0/foo
4155 createmany -l $DIR/$tdir/d0/foo $DIR/$tdir/d0/f- 65001 &&
4156 error "file exceed 65000 nlink limit!"
4157 unlinkmany $DIR/$tdir/d0/f- 65001
4160 run_test 51e "check file nlink limit"
4163 [ -f $DIR/$tdir/foo ] && chattr -a $DIR/$tdir/foo
4164 test_mkdir -p $DIR/$tdir
4165 touch $DIR/$tdir/foo
4166 chattr +a $DIR/$tdir/foo || error "chattr +a failed"
4167 echo bar >> $DIR/$tdir/foo || error "append bar failed"
4168 cp /etc/hosts $DIR/$tdir/foo && error "cp worked"
4169 rm -f $DIR/$tdir/foo 2>/dev/null && error "rm worked"
4170 link $DIR/$tdir/foo $DIR/$tdir/foo_link 2>/dev/null &&
4172 echo foo >> $DIR/$tdir/foo || error "append foo failed"
4173 mrename $DIR/$tdir/foo $DIR/$tdir/foo_ren && error "rename worked"
4174 lsattr $DIR/$tdir/foo | egrep -q "^-+a[-e]+ $DIR/$tdir/foo" ||
4176 chattr -a $DIR/$tdir/foo || error "chattr -a failed"
4177 cp -r $DIR/$tdir /tmp/
4178 rm -fr $DIR/$tdir || error "cleanup rm failed"
4180 run_test 52a "append-only flag test (should return errors) ====="
4183 [ -f $DIR/$tdir/foo ] && chattr -i $DIR/$tdir/foo
4184 test_mkdir -p $DIR/$tdir
4185 touch $DIR/$tdir/foo
4186 chattr +i $DIR/$tdir/foo || error "chattr +i failed"
4187 cat test > $DIR/$tdir/foo && error "cat test worked"
4188 cp /etc/hosts $DIR/$tdir/foo && error "cp worked"
4189 rm -f $DIR/$tdir/foo 2>/dev/null && error "rm worked"
4190 link $DIR/$tdir/foo $DIR/$tdir/foo_link 2>/dev/null &&
4192 echo foo >> $DIR/$tdir/foo && error "echo worked"
4193 mrename $DIR/$tdir/foo $DIR/$tdir/foo_ren && error "rename worked"
4194 [ -f $DIR/$tdir/foo ] || error "$tdir/foo is not a file"
4195 [ -f $DIR/$tdir/foo_ren ] && error "$tdir/foo_ren is not a file"
4196 lsattr $DIR/$tdir/foo | egrep -q "^-+i[-e]+ $DIR/$tdir/foo" ||
4198 chattr -i $DIR/$tdir/foo || error "chattr failed"
4200 rm -fr $DIR/$tdir || error "unable to remove $DIR/$tdir"
4202 run_test 52b "immutable flag test (should return errors) ======="
4205 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4206 remote_mds_nodsh && skip "remote MDS with nodsh" && return
4207 remote_ost_nodsh && skip "remote OST with nodsh" && return
4220 local support_last_seq=true
4222 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.3.60) ]] ||
4223 support_last_seq=false
4226 local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS)
4228 for value in $(do_facet $SINGLEMDS \
4229 $LCTL get_param osc.$mdtosc.prealloc_last_id) ; do
4230 param=$(echo ${value[0]} | cut -d "=" -f1)
4231 ostname=$(echo $param | cut -d "." -f2 | cut -d - -f 1-2)
4233 if $support_last_seq; then
4234 param_seq=$(echo $param |
4235 sed -e s/prealloc_last_id/prealloc_last_seq/g)
4236 mds_last_seq=$(do_facet $SINGLEMDS \
4237 $LCTL get_param -n $param_seq)
4239 mds_last=$(do_facet $SINGLEMDS $LCTL get_param -n $param)
4241 ostnum=$(index_from_ostuuid ${ostname}_UUID)
4242 node=$(facet_active_host ost$((ostnum+1)))
4243 param="obdfilter.$ostname.last_id"
4244 for ost_last in $(do_node $node $LCTL get_param -n $param) ; do
4245 echo "$ostname.last_id=$ost_last; MDS.last_id=$mds_last"
4246 ost_last_id=$ost_last
4248 if $support_last_seq; then
4249 ost_last_id=$(echo $ost_last |
4250 awk -F':' '{print $2}' |
4252 ost_last_seq=$(echo $ost_last |
4253 awk -F':' '{print $1}')
4254 [[ $ost_last_seq = $mds_last_seq ]] || continue
4257 if [[ $ost_last_id != $mds_last ]]; then
4258 error "$ost_last_id != $mds_last"
4265 $found || error "can not match last_seq/last_id for $mdtosc"
4268 run_test 53 "verify that MDS and OSTs agree on pre-creation ===="
4271 $SOCKETSERVER $DIR/socket ||
4272 error "$SOCKETSERVER $DIR/socket failed: $?"
4273 $SOCKETCLIENT $DIR/socket ||
4274 error "$SOCKETCLIENT $DIR/socket failed: $?"
4275 $MUNLINK $DIR/socket || error "$MUNLINK $DIR/socket failed: $?"
4277 run_test 54a "unix domain socket test =========================="
4283 dd if=/dev/zero of=$f bs=$(page_size) count=1
4285 run_test 54b "char device works in lustre ======================"
4288 [ -b /dev/loop/0 ] && LOOPBASE=/dev/loop/
4289 [ -b /dev/loop0 ] && LOOPBASE=/dev/loop
4290 [ -z "$LOOPBASE" ] && echo "/dev/loop/0 and /dev/loop0 gone?" && return
4292 for i in $(seq 3 7); do
4293 losetup $LOOPBASE$i > /dev/null 2>&1 && continue
4301 loopdev="$DIR/loop54c"
4304 $UMOUNT $DIR/$tdir || rc=$?
4305 losetup -d $loopdev || true
4306 losetup -d $LOOPDEV || true
4307 rm -rf $loopdev $DIR/$tfile $DIR/$tdir
4312 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4313 loopdev="$DIR/loop54c"
4316 [ -z "$LOOPNUM" ] && echo "couldn't find empty loop device" && return
4317 trap cleanup_54c EXIT
4318 mknod $loopdev b 7 $LOOPNUM
4319 echo "make a loop file system with $DIR/$tfile on $loopdev ($LOOPNUM)."
4320 dd if=/dev/zero of=$DIR/$tfile bs=$(get_page_size client) seek=1024 count=1 > /dev/null
4321 losetup $loopdev $DIR/$tfile ||
4322 error "can't set up $loopdev for $DIR/$tfile"
4323 mkfs.ext2 $loopdev || error "mke2fs on $loopdev"
4324 test_mkdir -p $DIR/$tdir
4325 mount -t ext2 $loopdev $DIR/$tdir ||
4326 error "error mounting $loopdev on $DIR/$tdir"
4327 dd if=/dev/zero of=$DIR/$tdir/tmp bs=$(get_page_size client) count=30 ||
4330 dd if=$DIR/$tdir/tmp of=/dev/zero bs=$(get_page_size client) count=30 ||
4334 run_test 54c "block device works in lustre ====================="
4340 [ "$string" = $(echo $string > $f | cat $f) ] || error "$f != $string"
4342 run_test 54d "fifo device works in lustre ======================"
4347 cp -aL /dev/console $f
4348 echo $string > $f || error "echo $string to $f failed"
4350 run_test 54e "console/tty device works in lustre ======================"
4352 #The test_55 used to be iopen test and it was removed by bz#24037.
4353 #run_test 55 "check iopen_connect_dentry() ======================"
4355 test_56a() { # was test_56
4358 test_mkdir -p $DIR/$tdir/dir
4360 NUMFILESx2=$(($NUMFILES * 2))
4361 for i in $(seq 1 $NUMFILES); do
4362 touch $DIR/$tdir/file$i
4363 touch $DIR/$tdir/dir/file$i
4366 # test lfs getstripe with --recursive
4367 FILENUM=$($GETSTRIPE --recursive $DIR/$tdir | grep -c obdidx)
4368 [[ $FILENUM -eq $NUMFILESx2 ]] ||
4369 error "$GETSTRIPE --recursive: found $FILENUM, not $NUMFILESx2"
4370 FILENUM=$($GETSTRIPE $DIR/$tdir | grep -c obdidx)
4371 [[ $FILENUM -eq $NUMFILES ]] ||
4372 error "$GETSTRIPE $DIR/$tdir: found $FILENUM, not $NUMFILES"
4373 echo "$GETSTRIPE --recursive passed."
4375 # test lfs getstripe with file instead of dir
4376 FILENUM=$($GETSTRIPE $DIR/$tdir/file1 | grep -c obdidx)
4377 [[ $FILENUM -eq 1 ]] ||
4378 error "$GETSTRIPE $DIR/$tdir/file1: found $FILENUM, not 1"
4379 echo "$GETSTRIPE file1 passed."
4381 #test lfs getstripe with --verbose
4382 [[ $($GETSTRIPE --verbose $DIR/$tdir |
4383 grep -c lmm_magic) -eq $NUMFILES ]] ||
4384 error "$GETSTRIPE --verbose $DIR/$tdir: want $NUMFILES"
4385 [[ $($GETSTRIPE $DIR/$tdir | grep -c lmm_magic) -eq 0 ]] ||
4386 rror "$GETSTRIPE $DIR/$tdir: showed lmm_magic"
4387 echo "$GETSTRIPE --verbose passed."
4389 #test lfs getstripe with --obd
4390 $GETSTRIPE --obd wrong_uuid $DIR/$tdir 2>&1 |
4391 grep -q "unknown obduuid" ||
4392 error "$GETSTRIPE --obd wrong_uuid should return error message"
4394 [[ $OSTCOUNT -lt 2 ]] &&
4395 skip_env "skipping other $GETSTRIPE --obd test" && return
4398 OBDUUID=$(ostuuid_from_index $OSTIDX)
4399 FILENUM=$($GETSTRIPE -ir $DIR/$tdir | grep "^$OSTIDX\$" | wc -l)
4400 FOUND=$($GETSTRIPE -r --obd $OBDUUID $DIR/$tdir | grep obdidx | wc -l)
4401 [[ $FOUND -eq $FILENUM ]] ||
4402 error "$GETSTRIPE --obd wrong: found $FOUND, expected $FILENUM"
4403 [[ $($GETSTRIPE -r -v --obd $OBDUUID $DIR/$tdir |
4404 sed '/^[ ]*'${OSTIDX}'[ ]/d' |
4405 sed -n '/^[ ]*[0-9][0-9]*[ ]/p' | wc -l) -eq 0 ]] ||
4406 error "$GETSTRIPE --obd: should not show file on other obd"
4407 echo "$GETSTRIPE --obd passed"
4409 run_test 56a "check $GETSTRIPE"
4414 local LOCAL_NUMFILES="$1"
4415 local LOCAL_NUMDIRS="$2"
4416 local MKDIR_PARAMS="$3"
4417 local DIR_STRIPE_PARAMS="$4"
4419 if [ ! -d "$TDIR" ] ; then
4420 test_mkdir -p $DIR_STRIPE_PARAMS $TDIR
4421 [ "$MKDIR_PARAMS" ] && $SETSTRIPE $MKDIR_PARAMS $TDIR
4422 for i in `seq 1 $LOCAL_NUMFILES` ; do
4425 for i in `seq 1 $LOCAL_NUMDIRS` ; do
4426 test_mkdir $DIR_STRIPE_PARAMS $TDIR/dir$i
4427 for j in `seq 1 $LOCAL_NUMFILES` ; do
4428 touch $TDIR/dir$i/file$j
4434 setup_56_special() {
4438 if [ ! -e "$TDIR/loop1b" ] ; then
4439 for i in `seq 1 $LOCAL_NUMFILES` ; do
4440 mknod $TDIR/loop${i}b b 7 $i
4441 mknod $TDIR/null${i}c c 1 3
4442 ln -s $TDIR/file1 $TDIR/link${i}l
4444 for i in `seq 1 $LOCAL_NUMDIRS` ; do
4445 mknod $TDIR/dir$i/loop${i}b b 7 $i
4446 mknod $TDIR/dir$i/null${i}c c 1 3
4447 ln -s $TDIR/dir$i/file1 $TDIR/dir$i/link${i}l
4456 setup_56 $NUMFILES $NUMDIRS
4458 EXPECTED=$(($NUMDIRS + 2))
4459 # test lfs find with -name
4460 for i in $(seq 1 $NUMFILES) ; do
4461 NUMS=$($LFIND -name "*$i" $TDIR | wc -l)
4462 [ $NUMS -eq $EXPECTED ] ||
4463 error "lfs find -name \"*$i\" $TDIR wrong: "\
4464 "found $NUMS, expected $EXPECTED"
4467 run_test 56g "check lfs find -name ============================="
4473 setup_56 $NUMFILES $NUMDIRS
4475 EXPECTED=$(((NUMDIRS + 1) * (NUMFILES - 1) + NUMFILES))
4476 # test lfs find with ! -name
4477 for i in $(seq 1 $NUMFILES) ; do
4478 NUMS=$($LFIND ! -name "*$i" $TDIR | wc -l)
4479 [ $NUMS -eq $EXPECTED ] ||
4480 error "lfs find ! -name \"*$i\" $TDIR wrong: "\
4481 "found $NUMS, expected $EXPECTED"
4484 run_test 56h "check lfs find ! -name ============================="
4488 test_mkdir -p $DIR/$tdir
4489 UUID=$(ostuuid_from_index 0 $DIR/$tdir)
4490 CMD="$LFIND -ost $UUID $DIR/$tdir"
4492 [ -z "$OUT" ] || error "\"$CMD\" returned directory '$OUT'"
4494 run_test 56i "check 'lfs find -ost UUID' skips directories ======="
4498 setup_56_special $NUMFILES $NUMDIRS
4500 EXPECTED=$((NUMDIRS + 1))
4501 CMD="$LFIND -type d $TDIR"
4502 NUMS=$($CMD | wc -l)
4503 [ $NUMS -eq $EXPECTED ] ||
4504 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4506 run_test 56j "check lfs find -type d ============================="
4510 setup_56_special $NUMFILES $NUMDIRS
4512 EXPECTED=$(((NUMDIRS + 1) * NUMFILES))
4513 CMD="$LFIND -type f $TDIR"
4514 NUMS=$($CMD | wc -l)
4515 [ $NUMS -eq $EXPECTED ] ||
4516 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4518 run_test 56k "check lfs find -type f ============================="
4522 setup_56_special $NUMFILES $NUMDIRS
4524 EXPECTED=$((NUMDIRS + NUMFILES))
4525 CMD="$LFIND -type b $TDIR"
4526 NUMS=$($CMD | wc -l)
4527 [ $NUMS -eq $EXPECTED ] ||
4528 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4530 run_test 56l "check lfs find -type b ============================="
4534 setup_56_special $NUMFILES $NUMDIRS
4536 EXPECTED=$((NUMDIRS + NUMFILES))
4537 CMD="$LFIND -type c $TDIR"
4538 NUMS=$($CMD | wc -l)
4539 [ $NUMS -eq $EXPECTED ] ||
4540 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4542 run_test 56m "check lfs find -type c ============================="
4546 setup_56_special $NUMFILES $NUMDIRS
4548 EXPECTED=$((NUMDIRS + NUMFILES))
4549 CMD="$LFIND -type l $TDIR"
4550 NUMS=$($CMD | wc -l)
4551 [ $NUMS -eq $EXPECTED ] ||
4552 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4554 run_test 56n "check lfs find -type l ============================="
4558 setup_56 $NUMFILES $NUMDIRS
4559 utime $TDIR/file1 > /dev/null || error "utime (1)"
4560 utime $TDIR/file2 > /dev/null || error "utime (2)"
4561 utime $TDIR/dir1 > /dev/null || error "utime (3)"
4562 utime $TDIR/dir2 > /dev/null || error "utime (4)"
4563 utime $TDIR/dir1/file1 > /dev/null || error "utime (5)"
4564 dd if=/dev/zero count=1 >> $TDIR/dir1/file1 && sync
4567 NUMS=`$LFIND -mtime +0 $TDIR | wc -l`
4568 [ $NUMS -eq $EXPECTED ] || \
4569 error "lfs find -mtime +0 $TDIR wrong: found $NUMS, expected $EXPECTED"
4572 CMD="$LFIND -mtime 0 $TDIR"
4573 NUMS=$($CMD | wc -l)
4574 [ $NUMS -eq $EXPECTED ] ||
4575 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4577 run_test 56o "check lfs find -mtime for old files =========================="
4580 [ $RUNAS_ID -eq $UID ] &&
4581 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
4584 setup_56 $NUMFILES $NUMDIRS
4586 chown $RUNAS_ID $TDIR/file* || error "chown $DIR/${tdir}g/file$i failed"
4588 CMD="$LFIND -uid $RUNAS_ID $TDIR"
4589 NUMS=$($CMD | wc -l)
4590 [ $NUMS -eq $EXPECTED ] || \
4591 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4593 EXPECTED=$(((NUMFILES + 1) * NUMDIRS + 1))
4594 CMD="$LFIND ! -uid $RUNAS_ID $TDIR"
4595 NUMS=$($CMD | wc -l)
4596 [ $NUMS -eq $EXPECTED ] || \
4597 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4599 run_test 56p "check lfs find -uid and ! -uid ==============================="
4602 [ $RUNAS_ID -eq $UID ] &&
4603 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
4606 setup_56 $NUMFILES $NUMDIRS
4608 chgrp $RUNAS_GID $TDIR/file* || error "chown $TDIR/file$i failed"
4611 CMD="$LFIND -gid $RUNAS_GID $TDIR"
4612 NUMS=$($CMD | wc -l)
4613 [ $NUMS -eq $EXPECTED ] ||
4614 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4616 EXPECTED=$(( ($NUMFILES+1) * $NUMDIRS + 1))
4617 CMD="$LFIND ! -gid $RUNAS_GID $TDIR"
4618 NUMS=$($CMD | wc -l)
4619 [ $NUMS -eq $EXPECTED ] ||
4620 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4622 run_test 56q "check lfs find -gid and ! -gid ==============================="
4626 setup_56 $NUMFILES $NUMDIRS
4629 CMD="$LFIND -size 0 -type f $TDIR"
4630 NUMS=$($CMD | wc -l)
4631 [ $NUMS -eq $EXPECTED ] ||
4632 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4634 CMD="$LFIND ! -size 0 -type f $TDIR"
4635 NUMS=$($CMD | wc -l)
4636 [ $NUMS -eq $EXPECTED ] ||
4637 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4638 echo "test" > $TDIR/$tfile
4639 echo "test2" > $TDIR/$tfile.2 && sync
4641 CMD="$LFIND -size 5 -type f $TDIR"
4642 NUMS=$($CMD | wc -l)
4643 [ $NUMS -eq $EXPECTED ] ||
4644 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4646 CMD="$LFIND -size +5 -type f $TDIR"
4647 NUMS=$($CMD | wc -l)
4648 [ $NUMS -eq $EXPECTED ] ||
4649 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4651 CMD="$LFIND -size +0 -type f $TDIR"
4652 NUMS=$($CMD | wc -l)
4653 [ $NUMS -eq $EXPECTED ] ||
4654 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4656 CMD="$LFIND ! -size -5 -type f $TDIR"
4657 NUMS=$($CMD | wc -l)
4658 [ $NUMS -eq $EXPECTED ] ||
4659 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4661 CMD="$LFIND -size -5 -type f $TDIR"
4662 NUMS=$($CMD | wc -l)
4663 [ $NUMS -eq $EXPECTED ] ||
4664 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4666 run_test 56r "check lfs find -size works =========================="
4668 test_56s() { # LU-611
4670 setup_56 $NUMFILES $NUMDIRS "-c $OSTCOUNT"
4672 if [[ $OSTCOUNT -gt 1 ]]; then
4673 $SETSTRIPE -c 1 $TDIR/$tfile.{0,1,2,3}
4677 ONESTRIPE=$(((NUMDIRS + 1) * NUMFILES))
4681 EXPECTED=$(((NUMDIRS + 1) * NUMFILES))
4682 CMD="$LFIND -stripe-count $OSTCOUNT -type f $TDIR"
4683 NUMS=$($CMD | wc -l)
4684 [ $NUMS -eq $EXPECTED ] || {
4686 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4689 EXPECTED=$(((NUMDIRS + 1) * NUMFILES + EXTRA))
4690 CMD="$LFIND -stripe-count +0 -type f $TDIR"
4691 NUMS=$($CMD | wc -l)
4692 [ $NUMS -eq $EXPECTED ] || {
4694 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4698 CMD="$LFIND -stripe-count 1 -type f $TDIR"
4699 NUMS=$($CMD | wc -l)
4700 [ $NUMS -eq $EXPECTED ] || {
4702 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4705 CMD="$LFIND -stripe-count -2 -type f $TDIR"
4706 NUMS=$($CMD | wc -l)
4707 [ $NUMS -eq $EXPECTED ] || {
4709 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4713 CMD="$LFIND -stripe-count $((OSTCOUNT + 1)) -type f $TDIR"
4714 NUMS=$($CMD | wc -l)
4715 [ $NUMS -eq $EXPECTED ] || {
4717 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4720 run_test 56s "check lfs find -stripe-count works"
4722 test_56t() { # LU-611
4724 setup_56 $NUMFILES $NUMDIRS "-s 512k"
4726 $SETSTRIPE -S 256k $TDIR/$tfile.{0,1,2,3}
4728 EXPECTED=$(((NUMDIRS + 1) * NUMFILES))
4729 CMD="$LFIND -stripe-size 512k -type f $TDIR"
4730 NUMS=$($CMD | wc -l)
4731 [ $NUMS -eq $EXPECTED ] ||
4732 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4734 CMD="$LFIND -stripe-size +320k -type f $TDIR"
4735 NUMS=$($CMD | wc -l)
4736 [ $NUMS -eq $EXPECTED ] ||
4737 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4739 EXPECTED=$(((NUMDIRS + 1) * NUMFILES + 4))
4740 CMD="$LFIND -stripe-size +200k -type f $TDIR"
4741 NUMS=$($CMD | wc -l)
4742 [ $NUMS -eq $EXPECTED ] ||
4743 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4745 CMD="$LFIND -stripe-size -640k -type f $TDIR"
4746 NUMS=$($CMD | wc -l)
4747 [ $NUMS -eq $EXPECTED ] ||
4748 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4751 CMD="$LFIND -stripe-size 256k -type f $TDIR"
4752 NUMS=$($CMD | wc -l)
4753 [ $NUMS -eq $EXPECTED ] ||
4754 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4756 CMD="$LFIND -stripe-size -320k -type f $TDIR"
4757 NUMS=$($CMD | wc -l)
4758 [ $NUMS -eq $EXPECTED ] ||
4759 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4762 CMD="$LFIND -stripe-size 1024k -type f $TDIR"
4763 NUMS=$($CMD | wc -l)
4764 [ $NUMS -eq $EXPECTED ] ||
4765 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4767 run_test 56t "check lfs find -stripe-size works"
4769 test_56u() { # LU-611
4771 setup_56 $NUMFILES $NUMDIRS "-i 0"
4773 if [[ $OSTCOUNT -gt 1 ]]; then
4774 $SETSTRIPE -i 1 $TDIR/$tfile.{0,1,2,3}
4780 EXPECTED=$(((NUMDIRS + 1) * NUMFILES))
4781 CMD="$LFIND -stripe-index 0 -type f $TDIR"
4782 NUMS=$($CMD | wc -l)
4783 [ $NUMS -eq $EXPECTED ] ||
4784 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4787 CMD="$LFIND -stripe-index 1 -type f $TDIR"
4788 NUMS=$($CMD | wc -l)
4789 [ $NUMS -eq $EXPECTED ] ||
4790 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4792 CMD="$LFIND ! -stripe-index 0 -type f $TDIR"
4793 NUMS=$($CMD | wc -l)
4794 [ $NUMS -eq $EXPECTED ] ||
4795 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4798 # This should produce an error and not return any files
4799 CMD="$LFIND -stripe-index $OSTCOUNT -type f $TDIR"
4800 NUMS=$($CMD 2>/dev/null | wc -l)
4801 [ $NUMS -eq $EXPECTED ] ||
4802 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4804 if [[ $OSTCOUNT -gt 1 ]]; then
4805 EXPECTED=$(((NUMDIRS + 1) * NUMFILES + ONESTRIPE))
4806 CMD="$LFIND -stripe-index 0,1 -type f $TDIR"
4807 NUMS=$($CMD | wc -l)
4808 [ $NUMS -eq $EXPECTED ] ||
4809 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4812 run_test 56u "check lfs find -stripe-index works"
4819 setup_56 $NUMFILES $NUMDIRS
4821 UUID=$(mdtuuid_from_index $MDT_IDX $TDIR)
4822 [ -z "$UUID" ] && error "mdtuuid_from_index cannot find MDT index $MDT_IDX"
4824 for file in $($LFIND -mdt $UUID $TDIR); do
4825 file_mdt_idx=$($GETSTRIPE -M $file)
4826 [ $file_mdt_idx -eq $MDT_IDX ] ||
4827 error "'lfind -mdt $UUID' != 'getstripe -M' ($file_mdt_idx)"
4830 run_test 56v "check 'lfs find -mdt match with lfs getstripe -M' ======="
4833 [[ $OSTCOUNT -lt 2 ]] && skip_env "$OSTCOUNT < 2 OSTs -- skipping" &&
4835 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4838 rm -rf $TDIR || error "remove $TDIR failed"
4839 setup_56 $NUMFILES $NUMDIRS "-c $OSTCOUNT" "-c1"
4842 stripe_size=$($GETSTRIPE -S -d $TDIR) ||
4843 error "$GETSTRIPE -S -d $TDIR failed"
4844 stripe_size=${stripe_size%% *}
4846 local file_size=$((stripe_size * OSTCOUNT))
4847 local file_num=$((NUMDIRS * NUMFILES + NUMFILES))
4848 local required_space=$((file_num * file_size))
4850 local free_space=$($LCTL get_param -n lov.$FSNAME-clilov-*.kbytesavail |
4852 [[ $free_space -le $((required_space / 1024)) ]] &&
4853 skip_env "need at least $required_space bytes free space," \
4854 "have $free_space kbytes" && return
4857 local dd_count=$((file_size / dd_bs))
4859 # write data into the files
4863 for i in $(seq 1 $NUMFILES); do
4865 yes | dd bs=$dd_bs count=$dd_count of=$file >/dev/null 2>&1 ||
4866 error "write data into $file failed"
4868 for i in $(seq 1 $NUMDIRS); do
4869 for j in $(seq 1 $NUMFILES); do
4870 file=$TDIR/dir$i/file$j
4871 yes | dd bs=$dd_bs count=$dd_count of=$file \
4873 error "write data into $file failed"
4878 [[ $OSTCOUNT -gt 1 ]] && expected=$((OSTCOUNT - 1))
4881 local cmd="$LFS_MIGRATE -y -c $expected $TDIR/file1"
4883 eval $cmd || error "$cmd failed"
4885 check_stripe_count $TDIR/file1 $expected
4887 if [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.6.90) ];
4889 # lfs_migrate file onto OST 0 if it is on OST 1, or onto
4890 # OST 1 if it is on OST 0. This file is small enough to
4891 # be on only one stripe.
4892 file=$TDIR/migr_1_ost
4893 dd bs=$dd_bs count=1 if=/dev/urandom of=$file >/dev/null 2>&1 ||
4894 error "write data into $file failed"
4895 local obdidx=$($LFS getstripe -i $file)
4896 local oldmd5=$(md5sum $file)
4898 [[ $obdidx -eq 0 ]] && newobdidx=1
4899 cmd="$LFS migrate -i $newobdidx $file"
4901 eval $cmd || error "$cmd failed"
4902 local realobdix=$($LFS getstripe -i $file)
4903 local newmd5=$(md5sum $file)
4904 [[ $newobdidx -ne $realobdix ]] &&
4905 error "new OST is different (was=$obdidx, wanted=$newobdidx, got=$realobdix)"
4906 [[ "$oldmd5" != "$newmd5" ]] &&
4907 error "md5sum differ: $oldmd5, $newmd5"
4911 cmd="$LFS_MIGRATE -y -c $expected $TDIR/dir1"
4913 eval $cmd || error "$cmd failed"
4915 for j in $(seq 1 $NUMFILES); do
4916 check_stripe_count $TDIR/dir1/file$j $expected
4919 # lfs_migrate works with lfs find
4920 cmd="$LFIND -stripe_count $OSTCOUNT -type f $TDIR |
4921 $LFS_MIGRATE -y -c $expected"
4923 eval $cmd || error "$cmd failed"
4925 for i in $(seq 2 $NUMFILES); do
4926 check_stripe_count $TDIR/file$i $expected
4928 for i in $(seq 2 $NUMDIRS); do
4929 for j in $(seq 1 $NUMFILES); do
4930 check_stripe_count $TDIR/dir$i/file$j $expected
4934 run_test 56w "check lfs_migrate -c stripe_count works"
4937 check_swap_layouts_support && return 0
4938 [[ $OSTCOUNT -lt 2 ]] &&
4939 skip_env "need 2 OST, skipping test" && return
4941 local dir0=$DIR/$tdir/$testnum
4942 test_mkdir -p $dir0 || error "creating dir $dir0"
4944 local ref1=/etc/passwd
4945 local file1=$dir0/file1
4947 $SETSTRIPE -c 2 $file1
4949 $LFS migrate -c 1 $file1 || error "migrate failed rc = $?"
4950 stripe=$($GETSTRIPE -c $file1)
4951 [[ $stripe == 1 ]] || error "stripe of $file1 is $stripe != 1"
4952 cmp $file1 $ref1 || error "content mismatch $file1 differs from $ref1"
4957 run_test 56x "lfs migration support"
4960 check_swap_layouts_support && return 0
4961 [[ $OSTCOUNT -lt 2 ]] &&
4962 skip_env "need 2 OST, skipping test" && return
4964 local dir0=$DIR/$tdir/$testnum
4965 test_mkdir -p $dir0 || error "creating dir $dir0"
4967 local ref1=/etc/passwd
4968 local file1=$dir0/file1
4970 $SETSTRIPE -c 2 $file1
4972 $LFS migrate --block -c 1 $file1 || error "migrate failed rc = $?"
4973 local stripe=$($GETSTRIPE -c $file1)
4974 [[ $stripe == 1 ]] || error "stripe of $file1 is $stripe != 1"
4975 cmp $file1 $ref1 || error "content mismatch $file1 differs from $ref1"
4980 run_test 56xa "lfs migration --block support"
4983 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.53) ] &&
4984 skip "No HSM $(lustre_build_version $SINGLEMDS) MDS < 2.4.53" &&
4988 local dir0=$DIR/$tdir/$testnum
4989 test_mkdir -p $dir0 || error "creating dir $dir0"
4990 local f1=$dir0/file1
4991 local f2=$dir0/file2
4993 touch $f1 || error "creating std file $f1"
4994 $MULTIOP $f2 H2c || error "creating released file $f2"
4996 # a directory can be raid0, so ask only for files
4997 res=$($LFIND $dir0 -L raid0 -type f | wc -l)
4998 [[ $res == 2 ]] || error "search raid0: found $res files != 2"
5000 res=$($LFIND $dir0 \! -L raid0 -type f | wc -l)
5001 [[ $res == 0 ]] || error "search !raid0: found $res files != 0"
5003 # only files can be released, so no need to force file search
5004 res=$($LFIND $dir0 -L released)
5005 [[ $res == $f2 ]] || error "search released: found $res != $f2"
5007 res=$($LFIND $dir0 \! -L released)
5008 [[ $res == $f1 ]] || error "search !released: found $res != $f1"
5011 run_test 56y "lfs find -L raid0|released"
5013 test_56z() { # LU-4824
5014 # This checks to make sure 'lfs find' continues after errors
5015 # There are two classes of errors that should be caught:
5016 # - If multiple paths are provided, all should be searched even if one
5018 # - If errors are encountered during the search, it should not terminate
5021 test_mkdir $DIR/$tdir
5022 for i in d{0..9}; do
5023 test_mkdir $DIR/$tdir/$i
5025 touch $DIR/$tdir/d{0..9}/$tfile
5026 $LFS find $DIR/non_existent_dir $DIR/$tdir &&
5027 error "$LFS find did not return an error"
5028 # Make a directory unsearchable. This should NOT be the last entry in
5029 # directory order. Arbitrarily pick the 6th entry
5030 chmod 700 $($LFS find $DIR/$tdir -type d | sed '6!d')
5031 local count=$($RUNAS $LFS find $DIR/non_existent $DIR/$tdir | wc -l)
5032 # The user should be able to see 10 directories and 9 files
5033 [ $count == 19 ] || error "$LFS find did not continue after error"
5035 run_test 56z "lfs find should continue after an error"
5037 test_56aa() { # LU-5937
5038 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
5041 $LFS setdirstripe -c$MDSCOUNT $DIR/$tdir/striped_dir
5043 createmany -o $DIR/$tdir/striped_dir/${tfile}- 1024
5044 local dirs=$(lfs find --size +8k $DIR/$tdir/)
5046 [ -n "$dirs" ] || error "lfs find --size wrong under striped dir"
5048 run_test 56aa "lfs find --size under striped dir"
5051 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5052 # note test will not do anything if MDS is not local
5053 if [ "$(facet_fstype $SINGLEMDS)" != ldiskfs ]; then
5054 skip "Only applicable to ldiskfs-based MDTs"
5058 remote_mds_nodsh && skip "remote MDS with nodsh" && return
5059 local MNTDEV="osd*.*MDT*.mntdev"
5060 DEV=$(do_facet $SINGLEMDS lctl get_param -n $MNTDEV)
5061 [ -z "$DEV" ] && error "can't access $MNTDEV"
5062 for DEV in $(do_facet $SINGLEMDS lctl get_param -n $MNTDEV); do
5063 do_facet $SINGLEMDS $DUMPE2FS -h $DEV > $TMP/t57a.dump ||
5064 error "can't access $DEV"
5065 DEVISIZE=$(awk '/Inode size:/ { print $3 }' $TMP/t57a.dump)
5066 [[ $DEVISIZE -gt 128 ]] || error "inode size $DEVISIZE"
5070 run_test 57a "verify MDS filesystem created with large inodes =="
5073 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5074 if [ "$(facet_fstype $SINGLEMDS)" != ldiskfs ]; then
5075 skip "Only applicable to ldiskfs-based MDTs"
5079 remote_mds_nodsh && skip "remote MDS with nodsh" && return
5080 local dir=$DIR/$tdir
5084 local FILEN=$dir/f$FILECOUNT
5086 rm -rf $dir || error "removing $dir"
5087 test_mkdir -p -c1 $dir || error "creating $dir"
5088 local mdtidx=$($LFS getstripe -M $dir)
5089 local mdtname=MDT$(printf %04x $mdtidx)
5090 local facet=mds$((mdtidx + 1))
5092 echo "mcreating $FILECOUNT files"
5093 createmany -m $dir/f 1 $FILECOUNT || \
5094 error "creating files in $dir"
5096 # verify that files do not have EAs yet
5097 $GETSTRIPE $FILE1 2>&1 | grep -q "no stripe" || error "$FILE1 has an EA"
5098 $GETSTRIPE $FILEN 2>&1 | grep -q "no stripe" || error "$FILEN has an EA"
5102 df $dir #make sure we get new statfs data
5103 local MDSFREE=$(do_facet $facet \
5104 lctl get_param -n osd*.*$mdtname.kbytesfree)
5105 local MDCFREE=$(lctl get_param -n mdc.*$mdtname-mdc-*.kbytesfree)
5106 echo "opening files to create objects/EAs"
5108 for FILE in `seq -f $dir/f%g 1 $FILECOUNT`; do
5109 $OPENFILE -f O_RDWR $FILE > /dev/null 2>&1 || error "opening $FILE"
5112 # verify that files have EAs now
5113 $GETSTRIPE $FILE1 | grep -q "obdidx" || error "$FILE1 missing EA"
5114 $GETSTRIPE $FILEN | grep -q "obdidx" || error "$FILEN missing EA"
5116 sleep 1 #make sure we get new statfs data
5118 local MDSFREE2=$(do_facet $facet \
5119 lctl get_param -n osd*.*$mdtname.kbytesfree)
5120 local MDCFREE2=$(lctl get_param -n mdc.*$mdtname-mdc-*.kbytesfree)
5121 if [[ $MDCFREE2 -lt $((MDCFREE - 16)) ]]; then
5122 if [ "$MDSFREE" != "$MDSFREE2" ]; then
5123 error "MDC before $MDCFREE != after $MDCFREE2"
5125 echo "MDC before $MDCFREE != after $MDCFREE2"
5126 echo "unable to confirm if MDS has large inodes"
5131 run_test 57b "default LOV EAs are stored inside large inodes ==="
5134 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5135 [ -z "$(which wiretest 2>/dev/null)" ] &&
5136 skip_env "could not find wiretest" && return
5139 run_test 58 "verify cross-platform wire constants =============="
5142 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5143 echo "touch 130 files"
5144 createmany -o $DIR/f59- 130
5146 unlinkmany $DIR/f59- 130
5148 # wait for commitment of removal
5149 wait_delete_completed
5151 run_test 59 "verify cancellation of llog records async ========="
5153 TEST60_HEAD="test_60 run $RANDOM"
5155 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5156 remote_mgs_nodsh && skip "remote MGS with nodsh" && return
5157 do_facet mgs "! which run-llog.sh &> /dev/null" &&
5158 do_facet mgs "! ls run-llog.sh &> /dev/null" &&
5159 skip_env "missing subtest run-llog.sh" && return
5161 log "$TEST60_HEAD - from kernel mode"
5162 do_facet mgs "$LCTL set_param debug=warning; $LCTL dk > /dev/null"
5163 do_facet mgs sh run-llog.sh
5164 do_facet mgs $LCTL dk > $TMP/$tfile
5166 # LU-6388: test llog_reader
5167 local llog_reader=$(do_facet mgs "which llog_reader 2> /dev/null")
5168 llog_reader=${llog_reader:-$LUSTRE/utils/llog_reader}
5169 [ -z $(do_facet mgs ls -d $llog_reader 2> /dev/null) ] &&
5170 skip_env "missing llog_reader" && return
5171 local fstype=$(facet_fstype mgs)
5172 [ $fstype != ldiskfs -a $fstype != zfs ] &&
5173 skip_env "Only for ldiskfs or zfs type mgs" && return
5175 local mntpt=$(facet_mntpt mgs)
5176 local mgsdev=$(mgsdevname 1)
5188 #get fid and record list
5189 fid_list=($(awk '/9_sub.*record/ { print $NF }' /$TMP/$tfile |
5191 rec_list=($(awk '/9_sub.*record/ { print $((NF-3)) }' /$TMP/$tfile |
5193 #remount mgs as ldiskfs or zfs type
5194 stop mgs || error "stop mgs failed"
5195 mount_fstype mgs || error "remount mgs failed"
5196 for ((i = 0; i < ${#fid_list[@]}; i++)); do
5199 seq=$(echo $fid | awk -F ':' '{ print $1 }' | sed -e "s/^0x//g")
5200 oid=$(echo $fid | awk -F ':' '{ print $2 }' | sed -e "s/^0x//g")
5205 obj_file=$mntpt/O/$seq/d$((oid%32))/$oid ;;
5207 obj_file=$mntpt/oi.$(($((16#$seq))&127))/$fid ;;
5209 echo "obj_file is $obj_file"
5210 do_facet mgs $llog_reader $obj_file
5212 rec_type=$(do_facet mgs $llog_reader $obj_file | grep "type=" |
5213 awk '{ print $3 }' | sed -e "s/^type=//g")
5214 if [ $rec_type != $rec ]; then
5215 echo "FAILED test_60a wrong record type $rec_type," \
5221 #check obj path if record type is LLOG_LOGID_MAGIC
5222 if [ "$rec" == "1064553b" ]; then
5223 path=$(do_facet mgs $llog_reader $obj_file |
5224 grep "path=" | awk '{ print $NF }' |
5225 sed -e "s/^path=//g")
5226 if [ $obj_file != $mntpt/$path ]; then
5227 echo "FAILED test_60a wrong obj path" \
5228 "$montpt/$path, should be $obj_file"
5235 #restart mgs before "error", otherwise it will block the next test
5236 stop mgs || error "stop mgs failed"
5237 start mgs $(mgsdevname) $MGS_MOUNT_OPTS || error "start mgs failed"
5238 $pass || error "test failed, see FAILED test_60a messages for specifics"
5240 run_test 60a "llog_test run from kernel module and test llog_reader =========="
5242 test_60b() { # bug 6411
5243 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5245 LLOG_COUNT=$(dmesg | awk "/$TEST60_HEAD/ { marker = 1; from_marker = 0; }
5257 [[ $LLOG_COUNT -gt 100 ]] &&
5258 error "CDEBUG_LIMIT not limiting messages ($LLOG_COUNT)" || true
5260 run_test 60b "limit repeated messages from CERROR/CWARN ========"
5263 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5264 echo "create 5000 files"
5265 createmany -o $DIR/f60c- 5000
5266 #define OBD_FAIL_MDS_LLOG_CREATE_FAILED 0x137
5267 lctl set_param fail_loc=0x80000137
5268 unlinkmany $DIR/f60c- 5000
5269 lctl set_param fail_loc=0
5271 run_test 60c "unlink file when mds full"
5274 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5275 SAVEPRINTK=$(lctl get_param -n printk)
5277 # verify "lctl mark" is even working"
5278 MESSAGE="test message ID $RANDOM $$"
5279 $LCTL mark "$MESSAGE" || error "$LCTL mark failed"
5280 dmesg | grep -q "$MESSAGE" || error "didn't find debug marker in log"
5282 lctl set_param printk=0 || error "set lnet.printk failed"
5283 lctl get_param -n printk | grep emerg || error "lnet.printk dropped emerg"
5284 MESSAGE="new test message ID $RANDOM $$"
5285 # Assume here that libcfs_debug_mark_buffer() uses D_WARNING
5286 $LCTL mark "$MESSAGE" || error "$LCTL mark failed"
5287 dmesg | grep -q "$MESSAGE" && error "D_WARNING wasn't masked" || true
5289 lctl set_param -n printk="$SAVEPRINTK"
5291 run_test 60d "test printk console message masking"
5294 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5296 #define OBD_FAIL_MDS_LLOG_CREATE_FAILED2 0x15b
5297 do_facet mds1 lctl set_param fail_loc=0x15b
5300 run_test 60e "no space while new llog is being created"
5303 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5305 dd if=/dev/zero of=$f bs=$(page_size) count=1 || error "dd $f failed"
5306 cancel_lru_locks osc
5307 $MULTIOP $f OSMWUc || error "$MULTIOP $f failed"
5310 run_test 61 "mmap() writes don't make sync hang ================"
5312 # bug 2330 - insufficient obd_match error checking causes LBUG
5314 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5317 cancel_lru_locks osc
5318 lctl set_param fail_loc=0x405
5319 cat $f && error "cat succeeded, expect -EIO"
5320 lctl set_param fail_loc=0
5322 # This test is now irrelevant (as of bug 10718 inclusion), we no longer
5323 # match every page all of the time.
5324 #run_test 62 "verify obd_match failure doesn't LBUG (should -EIO)"
5326 # bug 2319 - oig_wait() interrupted causes crash because of invalid waitq.
5327 # Though this test is irrelevant anymore, it helped to reveal some
5328 # other grant bugs (LU-4482), let's keep it.
5329 test_63a() { # was test_63
5330 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5331 MAX_DIRTY_MB=`lctl get_param -n osc.*.max_dirty_mb | head -n 1`
5332 for i in `seq 10` ; do
5333 dd if=/dev/zero of=$DIR/f63 bs=8k &
5339 rm -f $DIR/f63 || true
5341 run_test 63a "Verify oig_wait interruption does not crash ======="
5343 # bug 2248 - async write errors didn't return to application on sync
5344 # bug 3677 - async write errors left page locked
5346 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5348 lctl set_param debug=-1
5350 # ensure we have a grant to do async writes
5351 dd if=/dev/zero of=$DIR/$tfile bs=4k count=1
5354 sync # sync lest earlier test intercept the fail_loc
5356 #define OBD_FAIL_OSC_BRW_PREP_REQ 0x406
5357 lctl set_param fail_loc=0x80000406
5358 $MULTIOP $DIR/$tfile Owy && \
5359 error "sync didn't return ENOMEM"
5360 sync; sleep 2; sync # do a real sync this time to flush page
5361 lctl get_param -n llite.*.dump_page_cache | grep locked && \
5362 error "locked page left in cache after async error" || true
5365 run_test 63b "async write errors should be returned to fsync ==="
5368 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5370 lctl get_param -n osc.*[oO][sS][cC][_-]*.cur* | grep "[0-9]"
5372 run_test 64a "verify filter grant calculations (in kernel) ====="
5375 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5376 sh oos.sh $MOUNT || error "oos.sh failed: $?"
5378 run_test 64b "check out-of-space detection on client ==========="
5381 $LCTL set_param osc.*OST0000-osc-[^mM]*.cur_grant_bytes=0
5383 run_test 64c "verify grant shrink ========================------"
5385 # bug 1414 - set/get directories' stripe info
5387 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5388 test_mkdir -p $DIR/$tdir
5390 $LVERIFY $DIR/$tdir $DIR/$tdir/f1 || error "lverify failed"
5392 run_test 65a "directory with no stripe info ===================="
5395 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5396 test_mkdir -p $DIR/$tdir
5397 local STRIPESIZE=$($GETSTRIPE -S $DIR/$tdir)
5399 $SETSTRIPE -S $((STRIPESIZE * 2)) -i 0 -c 1 $DIR/$tdir ||
5402 $LVERIFY $DIR/$tdir $DIR/$tdir/f2 || error "lverify failed"
5404 run_test 65b "directory setstripe -S stripe_size*2 -i 0 -c 1"
5407 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5408 if [[ $OSTCOUNT -gt 1 ]]; then
5409 test_mkdir -p $DIR/$tdir
5410 local STRIPESIZE=$($GETSTRIPE -S $DIR/$tdir)
5412 $SETSTRIPE -S $(($STRIPESIZE * 4)) -i 1 \
5413 -c $(($OSTCOUNT - 1)) $DIR/$tdir || error "setstripe"
5415 $LVERIFY $DIR/$tdir $DIR/$tdir/f3 || error "lverify failed"
5418 run_test 65c "directory setstripe -S stripe_size*4 -i 1 -c $((OSTCOUNT-1))"
5421 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5422 test_mkdir -p $DIR/$tdir
5423 local STRIPECOUNT=$($GETSTRIPE -c $DIR/$tdir)
5424 local STRIPESIZE=$($GETSTRIPE -S $DIR/$tdir)
5426 if [[ $STRIPECOUNT -le 0 ]]; then
5428 elif [[ $STRIPECOUNT -gt 2000 ]]; then
5429 #LOV_MAX_STRIPE_COUNT is 2000
5430 [[ $OSTCOUNT -gt 2000 ]] && sc=2000 || sc=$(($OSTCOUNT - 1))
5432 sc=$(($STRIPECOUNT - 1))
5434 $SETSTRIPE -S $STRIPESIZE -c $sc $DIR/$tdir || error "setstripe"
5435 touch $DIR/$tdir/f4 $DIR/$tdir/f5
5436 $LVERIFY $DIR/$tdir $DIR/$tdir/f4 $DIR/$tdir/f5 ||
5437 error "lverify failed"
5439 run_test 65d "directory setstripe -S stripe_size -c stripe_count"
5442 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5443 test_mkdir -p $DIR/$tdir
5445 $SETSTRIPE $DIR/$tdir || error "setstripe"
5446 $GETSTRIPE -v $DIR/$tdir | grep "Default" ||
5447 error "no stripe info failed"
5449 $LVERIFY $DIR/$tdir $DIR/$tdir/f6 || error "lverify failed"
5451 run_test 65e "directory setstripe defaults ======================="
5454 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5455 test_mkdir -p $DIR/${tdir}f
5456 $RUNAS $SETSTRIPE $DIR/${tdir}f && error "setstripe succeeded" || true
5458 run_test 65f "dir setstripe permission (should return error) ==="
5461 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5462 test_mkdir -p $DIR/$tdir
5463 local STRIPESIZE=$($GETSTRIPE -S $DIR/$tdir)
5465 $SETSTRIPE -S $((STRIPESIZE * 2)) -i 0 -c 1 $DIR/$tdir ||
5467 $SETSTRIPE -d $DIR/$tdir || error "setstripe"
5468 $GETSTRIPE -v $DIR/$tdir | grep "Default" ||
5469 error "delete default stripe failed"
5471 run_test 65g "directory setstripe -d ==========================="
5474 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5475 test_mkdir -p $DIR/$tdir
5476 local STRIPESIZE=$($GETSTRIPE -S $DIR/$tdir)
5478 $SETSTRIPE -S $((STRIPESIZE * 2)) -i 0 -c 1 $DIR/$tdir ||
5480 test_mkdir -p $DIR/$tdir/dd1
5481 [ $($GETSTRIPE -c $DIR/$tdir) == $($GETSTRIPE -c $DIR/$tdir/dd1) ] ||
5482 error "stripe info inherit failed"
5484 run_test 65h "directory stripe info inherit ===================="
5486 test_65i() { # bug6367
5487 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5488 $SETSTRIPE -S 65536 -c -1 $MOUNT
5490 run_test 65i "set non-default striping on root directory (bug 6367)="
5492 test_65ia() { # bug12836
5493 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5494 $GETSTRIPE $MOUNT || error "getstripe $MOUNT failed"
5496 run_test 65ia "getstripe on -1 default directory striping"
5498 test_65ib() { # bug12836
5499 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5500 $GETSTRIPE -v $MOUNT || error "getstripe -v $MOUNT failed"
5502 run_test 65ib "getstripe -v on -1 default directory striping"
5504 test_65ic() { # bug12836
5505 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5506 $LFS find -mtime -1 $MOUNT > /dev/null || error "find $MOUNT failed"
5508 run_test 65ic "new find on -1 default directory striping"
5510 test_65j() { # bug6367
5511 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5513 # if we aren't already remounting for each test, do so for this test
5514 if [ "$CLEANUP" = ":" -a "$I_MOUNTED" = "yes" ]; then
5515 cleanup || error "failed to unmount"
5518 $SETSTRIPE -d $MOUNT || error "setstripe failed"
5520 run_test 65j "set default striping on root directory (bug 6367)="
5522 test_65k() { # bug11679
5523 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5524 [[ $OSTCOUNT -lt 2 ]] && skip_env "too few OSTs" && return
5525 remote_mds_nodsh && skip "remote MDS with nodsh" && return
5527 echo "Check OST status: "
5528 local MDS_OSCS=`do_facet $SINGLEMDS lctl dl |
5529 awk '/[oO][sS][cC].*md[ts]/ { print $4 }'`
5531 for OSC in $MDS_OSCS; do
5532 echo $OSC "is activate"
5533 do_facet $SINGLEMDS lctl --device %$OSC activate
5537 for INACTIVE_OSC in $MDS_OSCS; do
5538 echo "Deactivate: " $INACTIVE_OSC
5539 do_facet $SINGLEMDS lctl --device %$INACTIVE_OSC deactivate
5540 for STRIPE_OSC in $MDS_OSCS; do
5541 OST=`osc_to_ost $STRIPE_OSC`
5542 IDX=`do_facet $SINGLEMDS lctl get_param -n lov.*md*.target_obd |
5543 awk -F: /$OST/'{ print $1 }' | head -n 1`
5545 [ -f $DIR/$tdir/$IDX ] && continue
5546 echo "$SETSTRIPE -i $IDX -c 1 $DIR/$tdir/$IDX"
5547 $SETSTRIPE -i $IDX -c 1 $DIR/$tdir/$IDX
5549 [ $RC -ne 0 ] && error "setstripe should have succeeded"
5552 echo $INACTIVE_OSC "is Activate."
5553 do_facet $SINGLEMDS lctl --device %$INACTIVE_OSC activate
5556 run_test 65k "validate manual striping works properly with deactivated OSCs"
5558 test_65l() { # bug 12836
5559 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5560 test_mkdir -p $DIR/$tdir/test_dir
5561 $SETSTRIPE -c -1 $DIR/$tdir/test_dir
5562 $LFS find -mtime -1 $DIR/$tdir >/dev/null
5564 run_test 65l "lfs find on -1 stripe dir ========================"
5566 # bug 2543 - update blocks count on client
5568 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5570 dd if=/dev/zero of=$DIR/f66 bs=1k count=$COUNT
5571 sync; sync_all_data; sync; sync_all_data
5572 cancel_lru_locks osc
5573 BLOCKS=`ls -s $DIR/f66 | awk '{ print $1 }'`
5574 [ $BLOCKS -ge $COUNT ] || error "$DIR/f66 blocks $BLOCKS < $COUNT"
5576 run_test 66 "update inode blocks count on client ==============="
5581 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5583 if [ ! -z "$LLOOP" ]; then
5584 if swapon -s | grep -q $LLOOP; then
5585 swapoff $LLOOP || error "swapoff failed"
5588 $LCTL blockdev_detach $LLOOP || error "detach failed"
5592 if [ ! -z "$LLITELOOPLOAD" ]; then
5600 awk '($1 == "'$1':") { print $2 }' /proc/meminfo
5604 swapon -s | awk '($1 == "'$1'") { print $4 }'
5607 # test case for lloop driver, basic function
5609 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5610 [ "$UID" != 0 ] && skip_env "must run as root" && return
5611 llite_lloop_enabled || \
5612 { skip_env "llite_lloop module disabled" && return; }
5614 trap cleanup_68 EXIT
5616 if ! module_loaded llite_lloop; then
5617 if load_module llite/llite_lloop; then
5620 skip_env "can't find module llite_lloop"
5625 LLOOP=$TMP/lloop.`date +%s`.`date +%N`
5626 dd if=/dev/zero of=$DIR/f68a bs=4k count=1024
5627 $LCTL blockdev_attach $DIR/f68a $LLOOP || error "attach failed"
5629 directio rdwr $LLOOP 0 1024 4096 || error "direct write failed"
5630 directio rdwr $LLOOP 0 1025 4096 && error "direct write should fail"
5634 run_test 68a "lloop driver - basic test ========================"
5636 # excercise swapping to lustre by adding a high priority swapfile entry
5637 # and then consuming memory until it is used.
5638 test_68b() { # was test_68
5639 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5640 [ "$UID" != 0 ] && skip_env "must run as root" && return
5641 lctl get_param -n devices | grep -q obdfilter && \
5642 skip "local OST" && return
5644 grep -q llite_lloop /proc/modules
5645 [ $? -ne 0 ] && skip "can't find module llite_lloop" && return
5647 [ -z "`$LCTL list_nids | grep -v tcp`" ] && \
5648 skip "can't reliably test swap with TCP" && return
5650 MEMTOTAL=`meminfo MemTotal`
5651 NR_BLOCKS=$((MEMTOTAL>>8))
5652 [[ $NR_BLOCKS -le 2048 ]] && NR_BLOCKS=2048
5654 LLOOP=$TMP/lloop.`date +%s`.`date +%N`
5655 dd if=/dev/zero of=$DIR/f68b bs=64k seek=$NR_BLOCKS count=1
5658 $LCTL blockdev_attach $DIR/f68b $LLOOP || error "attach failed"
5660 trap cleanup_68 EXIT
5662 swapon -p 32767 $LLOOP || error "swapon $LLOOP failed"
5664 echo "before: `swapon -s | grep $LLOOP`"
5665 $MEMHOG $MEMTOTAL || error "error allocating $MEMTOTAL kB"
5666 echo "after: `swapon -s | grep $LLOOP`"
5667 SWAPUSED=`swap_used $LLOOP`
5671 [ $SWAPUSED -eq 0 ] && echo "no swap used???" || true
5673 run_test 68b "support swapping to Lustre ========================"
5675 # bug5265, obdfilter oa2dentry return -ENOENT
5676 # #define OBD_FAIL_SRV_ENOENT 0x217
5678 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5679 remote_ost_nodsh && skip "remote OST with nodsh" && return
5682 $SETSTRIPE -c 1 -i 0 $f
5684 $DIRECTIO write ${f}.2 0 1 || error "directio write error"
5686 do_facet ost1 lctl set_param fail_loc=0x217
5687 $TRUNCATE $f 1 # vmtruncate() will ignore truncate() error.
5688 $DIRECTIO write $f 0 2 && error "write succeeded, expect -ENOENT"
5690 do_facet ost1 lctl set_param fail_loc=0
5691 $DIRECTIO write $f 0 2 || error "write error"
5693 cancel_lru_locks osc
5694 $DIRECTIO read $f 0 1 || error "read error"
5696 do_facet ost1 lctl set_param fail_loc=0x217
5697 $DIRECTIO read $f 1 1 && error "read succeeded, expect -ENOENT"
5699 do_facet ost1 lctl set_param fail_loc=0
5702 run_test 69 "verify oa2dentry return -ENOENT doesn't LBUG ======"
5705 test_mkdir -p $DIR/$tdir
5706 $LFS setdirstripe -D -c$MDSCOUNT $DIR/$tdir
5707 sh rundbench -C -D $DIR/$tdir 2 || error "dbench failed!"
5709 run_test 71 "Running dbench on lustre (don't segment fault) ===="
5711 test_72a() { # bug 5695 - Test that on 2.6 remove_suid works properly
5712 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5713 [ "$RUNAS_ID" = "$UID" ] &&
5714 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
5716 # Check that testing environment is properly set up. Skip if not
5717 FAIL_ON_ERROR=false check_runas_id_ret $RUNAS_ID $RUNAS_GID $RUNAS || {
5718 skip_env "User $RUNAS_ID does not exist - skipping"
5722 chmod 777 $DIR/$tfile
5723 chmod ug+s $DIR/$tfile
5724 $RUNAS dd if=/dev/zero of=$DIR/$tfile bs=512 count=1 ||
5725 error "$RUNAS dd $DIR/$tfile failed"
5726 # See if we are still setuid/sgid
5727 test -u $DIR/$tfile -o -g $DIR/$tfile &&
5728 error "S/gid is not dropped on write"
5729 # Now test that MDS is updated too
5730 cancel_lru_locks mdc
5731 test -u $DIR/$tfile -o -g $DIR/$tfile &&
5732 error "S/gid is not dropped on MDS"
5735 run_test 72a "Test that remove suid works properly (bug5695) ===="
5737 test_72b() { # bug 24226 -- keep mode setting when size is not changing
5740 [ "$RUNAS_ID" = "$UID" ] && \
5741 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
5742 [ "$RUNAS_ID" -eq 0 ] && \
5743 skip_env "RUNAS_ID = 0 -- skipping" && return
5745 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5746 # Check that testing environment is properly set up. Skip if not
5747 FAIL_ON_ERROR=false check_runas_id_ret $RUNAS_ID $RUNAS_ID $RUNAS || {
5748 skip_env "User $RUNAS_ID does not exist - skipping"
5751 touch $DIR/${tfile}-f{g,u}
5752 test_mkdir $DIR/${tfile}-dg
5753 test_mkdir $DIR/${tfile}-du
5754 chmod 770 $DIR/${tfile}-{f,d}{g,u}
5755 chmod g+s $DIR/${tfile}-{f,d}g
5756 chmod u+s $DIR/${tfile}-{f,d}u
5757 for perm in 777 2777 4777; do
5758 $RUNAS chmod $perm $DIR/${tfile}-fg && error "S/gid file allowed improper chmod to $perm"
5759 $RUNAS chmod $perm $DIR/${tfile}-fu && error "S/uid file allowed improper chmod to $perm"
5760 $RUNAS chmod $perm $DIR/${tfile}-dg && error "S/gid dir allowed improper chmod to $perm"
5761 $RUNAS chmod $perm $DIR/${tfile}-du && error "S/uid dir allowed improper chmod to $perm"
5765 run_test 72b "Test that we keep mode setting if without file data changed (bug 24226)"
5767 # bug 3462 - multiple simultaneous MDC requests
5769 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5770 test_mkdir $DIR/d73-1
5771 test_mkdir $DIR/d73-2
5772 multiop_bg_pause $DIR/d73-1/f73-1 O_c || return 1
5775 lctl set_param fail_loc=0x80000129
5776 $MULTIOP $DIR/d73-1/f73-2 Oc &
5778 lctl set_param fail_loc=0
5780 $MULTIOP $DIR/d73-2/f73-3 Oc &
5784 wait $pid1 || return 1
5788 $CHECKSTAT -t file $DIR/d73-1/f73-1 || return 4
5789 $CHECKSTAT -t file $DIR/d73-1/f73-2 || return 5
5790 $CHECKSTAT -t file $DIR/d73-2/f73-3 || return 6
5794 run_test 73 "multiple MDC requests (should not deadlock)"
5796 test_74a() { # bug 6149, 6184
5797 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5798 #define OBD_FAIL_LDLM_ENQUEUE_OLD_EXPORT 0x30e
5800 # very important to OR with OBD_FAIL_ONCE (0x80000000) -- otherwise it
5801 # will spin in a tight reconnection loop
5803 $LCTL set_param fail_loc=0x8000030e
5804 # get any lock that won't be difficult - lookup works.
5806 $LCTL set_param fail_loc=0
5810 run_test 74a "ldlm_enqueue freed-export error path, ls (shouldn't LBUG)"
5812 test_74b() { # bug 13310
5813 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5814 #define OBD_FAIL_LDLM_ENQUEUE_OLD_EXPORT 0x30e
5816 # very important to OR with OBD_FAIL_ONCE (0x80000000) -- otherwise it
5817 # will spin in a tight reconnection loop
5818 $LCTL set_param fail_loc=0x8000030e
5819 # get a "difficult" lock
5821 $LCTL set_param fail_loc=0
5825 run_test 74b "ldlm_enqueue freed-export error path, touch (shouldn't LBUG)"
5828 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5829 #define OBD_FAIL_LDLM_NEW_LOCK
5830 $LCTL set_param fail_loc=0x319
5831 touch $DIR/$tfile && error "touch successful"
5832 $LCTL set_param fail_loc=0
5835 run_test 74c "ldlm_lock_create error path, (shouldn't LBUG)"
5838 awk '/lustre_inode_cache/ {print $2; exit}' /proc/slabinfo
5841 get_inode_slab_tunables() {
5842 awk '/lustre_inode_cache/ {print $9," ",$10," ",$11; exit}' /proc/slabinfo
5845 set_inode_slab_tunables() {
5846 echo "lustre_inode_cache $1" > /proc/slabinfo
5849 test_76() { # Now for bug 20433, added originally in bug 1443
5850 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5851 local SLAB_SETTINGS=`get_inode_slab_tunables`
5852 local CPUS=`getconf _NPROCESSORS_ONLN`
5853 # we cannot set limit below 1 which means 1 inode in each
5854 # per-cpu cache is still allowed
5855 set_inode_slab_tunables "1 1 0"
5856 cancel_lru_locks osc
5857 BEFORE_INODES=$(num_inodes)
5858 echo "before inodes: $BEFORE_INODES"
5860 [ "$SLOW" = "no" ] && COUNT=100
5861 for i in $(seq $COUNT); do
5865 cancel_lru_locks osc
5866 AFTER_INODES=$(num_inodes)
5867 echo "after inodes: $AFTER_INODES"
5869 while [[ $((AFTER_INODES-1*CPUS)) -gt $BEFORE_INODES ]]; do
5871 AFTER_INODES=$(num_inodes)
5873 echo "wait $wait seconds inodes: $AFTER_INODES"
5874 if [ $wait -gt 30 ]; then
5875 error "inode slab grew from $BEFORE_INODES to $AFTER_INODES"
5878 set_inode_slab_tunables "$SLAB_SETTINGS"
5880 run_test 76 "confirm clients recycle inodes properly ===="
5886 # Note: in sptlrpc modes which enable its own bulk checksum, the
5887 # original crc32_le bulk checksum will be automatically disabled,
5888 # and the OBD_FAIL_OSC_CHECKSUM_SEND/OBD_FAIL_OSC_CHECKSUM_RECEIVE
5889 # will be checked by sptlrpc code against sptlrpc bulk checksum.
5890 # In this case set_checksums() will not be no-op, because sptlrpc
5891 # bulk checksum will be enabled all through the test.
5893 [ "$ORIG_CSUM" ] || ORIG_CSUM=`lctl get_param -n osc.*.checksums | head -n1`
5894 lctl set_param -n osc.*.checksums $1
5898 export ORIG_CSUM_TYPE="`lctl get_param -n osc.*osc-[^mM]*.checksum_type |
5899 sed 's/.*\[\(.*\)\].*/\1/g' | head -n1`"
5900 CKSUM_TYPES=${CKSUM_TYPES:-"crc32 adler"}
5901 [ "$ORIG_CSUM_TYPE" = "crc32c" ] && CKSUM_TYPES="$CKSUM_TYPES crc32c"
5904 lctl set_param -n osc.*osc-[^mM]*.checksum_type $1
5905 log "set checksum type to $1"
5908 F77_TMP=$TMP/f77-temp
5911 dd if=/dev/urandom of=$F77_TMP bs=1M count=$F77SZ || \
5912 error "error writing to $F77_TMP"
5915 test_77a() { # bug 10889
5916 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5917 $GSS && skip "could not run with gss" && return
5918 [ ! -f $F77_TMP ] && setup_f77
5920 dd if=$F77_TMP of=$DIR/$tfile bs=1M count=$F77SZ || error "dd error"
5924 run_test 77a "normal checksum read/write operation"
5926 test_77b() { # bug 10889
5927 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5928 $GSS && skip "could not run with gss" && return
5929 [ ! -f $F77_TMP ] && setup_f77
5930 #define OBD_FAIL_OSC_CHECKSUM_SEND 0x409
5931 $LCTL set_param fail_loc=0x80000409
5934 dd if=$F77_TMP of=$DIR/$tfile bs=1M count=$F77SZ conv=sync ||
5935 error "dd error: $?"
5936 $LCTL set_param fail_loc=0
5938 for algo in $CKSUM_TYPES; do
5939 cancel_lru_locks osc
5940 set_checksum_type $algo
5941 #define OBD_FAIL_OSC_CHECKSUM_RECEIVE 0x408
5942 $LCTL set_param fail_loc=0x80000408
5943 cmp $F77_TMP $DIR/$tfile || error "file compare failed"
5944 $LCTL set_param fail_loc=0
5947 set_checksum_type $ORIG_CSUM_TYPE
5950 run_test 77b "checksum error on client write, read"
5952 test_77d() { # bug 10889
5953 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5954 $GSS && skip "could not run with gss" && return
5955 #define OBD_FAIL_OSC_CHECKSUM_SEND 0x409
5956 $LCTL set_param fail_loc=0x80000409
5958 $DIRECTIO write $DIR/$tfile 0 $F77SZ $((1024 * 1024)) ||
5959 error "direct write: rc=$?"
5960 $LCTL set_param fail_loc=0
5963 #define OBD_FAIL_OSC_CHECKSUM_RECEIVE 0x408
5964 $LCTL set_param fail_loc=0x80000408
5966 cancel_lru_locks osc
5967 $DIRECTIO read $DIR/$tfile 0 $F77SZ $((1024 * 1024)) ||
5968 error "direct read: rc=$?"
5969 $LCTL set_param fail_loc=0
5972 run_test 77d "checksum error on OST direct write, read"
5974 test_77f() { # bug 10889
5975 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5976 $GSS && skip "could not run with gss" && return
5978 for algo in $CKSUM_TYPES; do
5979 cancel_lru_locks osc
5980 set_checksum_type $algo
5981 #define OBD_FAIL_OSC_CHECKSUM_SEND 0x409
5982 $LCTL set_param fail_loc=0x409
5983 $DIRECTIO write $DIR/$tfile 0 $F77SZ $((1024 * 1024)) &&
5984 error "direct write succeeded"
5985 $LCTL set_param fail_loc=0
5987 set_checksum_type $ORIG_CSUM_TYPE
5990 run_test 77f "repeat checksum error on write (expect error)"
5992 test_77g() { # bug 10889
5993 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5994 $GSS && skip "could not run with gss" && return
5995 remote_ost_nodsh && skip "remote OST with nodsh" && return
5997 [ ! -f $F77_TMP ] && setup_f77
5999 $SETSTRIPE -c 1 -i 0 $DIR/$tfile
6000 #define OBD_FAIL_OST_CHECKSUM_RECEIVE 0x21a
6001 do_facet ost1 lctl set_param fail_loc=0x8000021a
6003 dd if=$F77_TMP of=$DIR/$tfile bs=1M count=$F77SZ ||
6004 error "write error: rc=$?"
6005 do_facet ost1 lctl set_param fail_loc=0
6008 cancel_lru_locks osc
6009 #define OBD_FAIL_OST_CHECKSUM_SEND 0x21b
6010 do_facet ost1 lctl set_param fail_loc=0x8000021b
6012 cmp $F77_TMP $DIR/$tfile || error "file compare failed"
6013 do_facet ost1 lctl set_param fail_loc=0
6016 run_test 77g "checksum error on OST write, read"
6018 test_77i() { # bug 13805
6019 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6020 $GSS && skip "could not run with gss" && return
6021 #define OBD_FAIL_OSC_CONNECT_CKSUM 0x40b
6022 lctl set_param fail_loc=0x40b
6023 remount_client $MOUNT
6024 lctl set_param fail_loc=0
6025 for VALUE in `lctl get_param osc.*osc-[^mM]*.checksum_type`; do
6026 PARAM=`echo ${VALUE[0]} | cut -d "=" -f1`
6027 algo=`lctl get_param -n $PARAM | sed 's/.*\[\(.*\)\].*/\1/g'`
6028 [ "$algo" = "adler" ] || error "algo set to $algo instead of adler"
6030 remount_client $MOUNT
6032 run_test 77i "client not supporting OSD_CONNECT_CKSUM"
6034 test_77j() { # bug 13805
6035 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6036 $GSS && skip "could not run with gss" && return
6037 #define OBD_FAIL_OSC_CKSUM_ADLER_ONLY 0x40c
6038 lctl set_param fail_loc=0x40c
6039 remount_client $MOUNT
6040 lctl set_param fail_loc=0
6041 sleep 2 # wait async osc connect to finish
6042 for VALUE in `lctl get_param osc.*osc-[^mM]*.checksum_type`; do
6043 PARAM=`echo ${VALUE[0]} | cut -d "=" -f1`
6044 algo=`lctl get_param -n $PARAM | sed 's/.*\[\(.*\)\].*/\1/g'`
6045 [ "$algo" = "adler" ] || error "algo set to $algo instead of adler"
6047 remount_client $MOUNT
6049 run_test 77j "client only supporting ADLER32"
6051 [ "$ORIG_CSUM" ] && set_checksums $ORIG_CSUM || true
6055 test_78() { # bug 10901
6056 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6057 remote_ost || { skip_env "local OST" && return; }
6060 F78SIZE=$(($(awk '/MemFree:/ { print $2 }' /proc/meminfo) / 1024))
6061 echo "MemFree: $F78SIZE, Max file size: $MAXFREE"
6062 MEMTOTAL=$(($(awk '/MemTotal:/ { print $2 }' /proc/meminfo) / 1024))
6063 echo "MemTotal: $MEMTOTAL"
6065 # reserve 256MB of memory for the kernel and other running processes,
6066 # and then take 1/2 of the remaining memory for the read/write buffers.
6067 if [ $MEMTOTAL -gt 512 ] ;then
6068 MEMTOTAL=$(((MEMTOTAL - 256 ) / 2))
6070 # for those poor memory-starved high-end clusters...
6071 MEMTOTAL=$((MEMTOTAL / 2))
6073 echo "Mem to use for directio: $MEMTOTAL"
6075 [[ $F78SIZE -gt $MEMTOTAL ]] && F78SIZE=$MEMTOTAL
6076 [[ $F78SIZE -gt 512 ]] && F78SIZE=512
6077 [[ $F78SIZE -gt $((MAXFREE / 1024)) ]] && F78SIZE=$((MAXFREE / 1024))
6078 SMALLESTOST=$($LFS df $DIR | grep OST | awk '{ print $4 }' | sort -n |
6080 echo "Smallest OST: $SMALLESTOST"
6081 [[ $SMALLESTOST -lt 10240 ]] &&
6082 skip "too small OSTSIZE, useless to run large O_DIRECT test" && return 0
6084 [[ $F78SIZE -gt $((SMALLESTOST * $OSTCOUNT / 1024 - 80)) ]] &&
6085 F78SIZE=$((SMALLESTOST * $OSTCOUNT / 1024 - 80))
6087 [ "$SLOW" = "no" ] && NSEQ=1 && [ $F78SIZE -gt 32 ] && F78SIZE=32
6088 echo "File size: $F78SIZE"
6089 $SETSTRIPE -c $OSTCOUNT $DIR/$tfile || error "setstripe failed"
6090 for i in $(seq 1 $NSEQ); do
6091 FSIZE=$(($F78SIZE / ($NSEQ - $i + 1)))
6092 echo directIO rdwr round $i of $NSEQ
6093 $DIRECTIO rdwr $DIR/$tfile 0 $FSIZE 1048576||error "rdwr failed"
6098 run_test 78 "handle large O_DIRECT writes correctly ============"
6100 test_79() { # bug 12743
6101 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6102 wait_delete_completed
6104 BKTOTAL=$(calc_osc_kbytes kbytestotal)
6105 BKFREE=$(calc_osc_kbytes kbytesfree)
6106 BKAVAIL=$(calc_osc_kbytes kbytesavail)
6108 STRING=`df -P $MOUNT | tail -n 1 | awk '{print $2","$3","$4}'`
6109 DFTOTAL=`echo $STRING | cut -d, -f1`
6110 DFUSED=`echo $STRING | cut -d, -f2`
6111 DFAVAIL=`echo $STRING | cut -d, -f3`
6112 DFFREE=$(($DFTOTAL - $DFUSED))
6114 ALLOWANCE=$((64 * $OSTCOUNT))
6116 if [ $DFTOTAL -lt $(($BKTOTAL - $ALLOWANCE)) ] ||
6117 [ $DFTOTAL -gt $(($BKTOTAL + $ALLOWANCE)) ] ; then
6118 error "df total($DFTOTAL) mismatch OST total($BKTOTAL)"
6120 if [ $DFFREE -lt $(($BKFREE - $ALLOWANCE)) ] ||
6121 [ $DFFREE -gt $(($BKFREE + $ALLOWANCE)) ] ; then
6122 error "df free($DFFREE) mismatch OST free($BKFREE)"
6124 if [ $DFAVAIL -lt $(($BKAVAIL - $ALLOWANCE)) ] ||
6125 [ $DFAVAIL -gt $(($BKAVAIL + $ALLOWANCE)) ] ; then
6126 error "df avail($DFAVAIL) mismatch OST avail($BKAVAIL)"
6129 run_test 79 "df report consistency check ======================="
6131 test_80() { # bug 10718
6132 remote_ost_nodsh && skip "remote OST with nodsh" && return
6133 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6134 # relax strong synchronous semantics for slow backends like ZFS
6135 local soc="obdfilter.*.sync_on_lock_cancel"
6136 local soc_old=$(do_facet ost1 lctl get_param -n $soc | head -n1)
6138 if [ "$soc_old" != "never" -a "$(facet_fstype ost1)" != "ldiskfs" ]; then
6139 hosts=$(for host in $(seq -f "ost%g" 1 $OSTCOUNT); do
6140 facet_active_host $host; done | sort -u)
6141 do_nodes $hosts lctl set_param $soc=never
6144 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=1M
6146 local BEFORE=`date +%s`
6147 cancel_lru_locks osc
6148 local AFTER=`date +%s`
6149 local DIFF=$((AFTER-BEFORE))
6150 if [ $DIFF -gt 1 ] ; then
6151 error "elapsed for 1M@1T = $DIFF"
6154 [ -n "$hosts" ] && do_nodes $hosts lctl set_param $soc=$soc_old
6158 run_test 80 "Page eviction is equally fast at high offsets too ===="
6160 test_81a() { # LU-456
6161 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6162 remote_ost_nodsh && skip "remote OST with nodsh" && return
6163 # define OBD_FAIL_OST_MAPBLK_ENOSPC 0x228
6164 # MUST OR with the OBD_FAIL_ONCE (0x80000000)
6165 do_facet ost1 lctl set_param fail_loc=0x80000228
6167 # write should trigger a retry and success
6168 $SETSTRIPE -i 0 -c 1 $DIR/$tfile
6169 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
6171 if [ $RC -ne 0 ] ; then
6172 error "write should success, but failed for $RC"
6175 run_test 81a "OST should retry write when get -ENOSPC ==============="
6177 test_81b() { # LU-456
6178 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6179 remote_ost_nodsh && skip "remote OST with nodsh" && return
6180 # define OBD_FAIL_OST_MAPBLK_ENOSPC 0x228
6181 # Don't OR with the OBD_FAIL_ONCE (0x80000000)
6182 do_facet ost1 lctl set_param fail_loc=0x228
6184 # write should retry several times and return -ENOSPC finally
6185 $SETSTRIPE -i 0 -c 1 $DIR/$tfile
6186 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
6189 if [ $RC -ne $ENOSPC ] ; then
6190 error "dd should fail for -ENOSPC, but succeed."
6193 run_test 81b "OST should return -ENOSPC when retry still fails ======="
6195 test_82() { # LU-1031
6196 dd if=/dev/zero of=$DIR/$tfile bs=1M count=10
6200 multiop_bg_pause $DIR/$tfile OG${gid1}_g${gid1}c || return 1
6202 multiop_bg_pause $DIR/$tfile O_G${gid2}r10g${gid2}c || return 2
6204 kill -USR1 $MULTIPID2
6206 if [[ `ps h -o comm -p $MULTIPID2` == "" ]]; then
6207 error "First grouplock does not block second one"
6209 echo "Second grouplock blocks first one"
6211 kill -USR1 $MULTIPID1
6215 run_test 82 "Basic grouplock test ==============================="
6218 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" &&
6220 test_mkdir -p $DIR/d99cvsroot
6221 chown $RUNAS_ID $DIR/d99cvsroot
6222 local oldPWD=$PWD # bug 13584, use $TMP as working dir
6225 $RUNAS cvs -d $DIR/d99cvsroot init || error "cvs init failed"
6228 run_test 99a "cvs init ========================================="
6231 [ -z "$(which cvs 2>/dev/null)" ] &&
6232 skip_env "could not find cvs" && return
6233 [ ! -d $DIR/d99cvsroot ] && test_99a
6235 # some versions of cvs import exit(1) when asked to import links or
6236 # files they can't read. ignore those files.
6237 TOIGNORE=$(find . -type l -printf '-I %f\n' -o \
6238 ! -perm /4 -printf '-I %f\n')
6239 $RUNAS cvs -d $DIR/d99cvsroot import -m "nomesg" $TOIGNORE \
6240 d99reposname vtag rtag
6242 run_test 99b "cvs import ======================================="
6245 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" && return
6246 [ ! -d $DIR/d99cvsroot ] && test_99b
6248 test_mkdir -p $DIR/d99reposname
6249 chown $RUNAS_ID $DIR/d99reposname
6250 $RUNAS cvs -d $DIR/d99cvsroot co d99reposname
6252 run_test 99c "cvs checkout ====================================="
6255 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" && return
6256 [ ! -d $DIR/d99cvsroot ] && test_99c
6257 cd $DIR/d99reposname
6259 $RUNAS cvs add -m 'addmsg' foo99
6261 run_test 99d "cvs add =========================================="
6264 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" && return
6265 [ ! -d $DIR/d99cvsroot ] && test_99c
6266 cd $DIR/d99reposname
6269 run_test 99e "cvs update ======================================="
6272 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" && return
6273 [ ! -d $DIR/d99cvsroot ] && test_99d
6274 cd $DIR/d99reposname
6275 $RUNAS cvs commit -m 'nomsg' foo99
6276 rm -fr $DIR/d99cvsroot
6278 run_test 99f "cvs commit ======================================="
6281 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6282 [ "$NETTYPE" = tcp ] || \
6283 { skip "TCP secure port test, not useful for NETTYPE=$NETTYPE" && \
6286 remote_ost_nodsh && skip "remote OST with nodsh" && return
6287 remote_mds_nodsh && skip "remote MDS with nodsh" && return
6289 { skip "useless for local single node setup" && return; }
6291 netstat -tna | ( rc=1; while read PROT SND RCV LOCAL REMOTE STAT; do
6292 [ "$PROT" != "tcp" ] && continue
6293 RPORT=$(echo $REMOTE | cut -d: -f2)
6294 [ "$RPORT" != "$ACCEPTOR_PORT" ] && continue
6297 LPORT=`echo $LOCAL | cut -d: -f2`
6298 if [ $LPORT -ge 1024 ]; then
6299 echo "bad: $PROT $SND $RCV $LOCAL $REMOTE $STAT"
6301 error_exit "local: $LPORT > 1024, remote: $RPORT"
6304 [ "$rc" = 0 ] || error_exit "privileged port not found" )
6306 run_test 100 "check local port using privileged port ==========="
6308 function get_named_value()
6317 echo $line | sed "s/^$tag[ ]*//"
6324 export CACHE_MAX=$($LCTL get_param -n llite.*.max_cached_mb |
6325 awk '/^max_cached_mb/ { print $2 }')
6328 $LCTL set_param -n llite.*.max_cached_mb $CACHE_MAX
6333 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6334 [ $MDSCOUNT -ge 2 ] && skip "skip now for >= 2 MDTs" && return #LU-4322
6338 local cache_limit=32
6340 $LCTL set_param -n osc.*-osc*.rpc_stats 0
6341 trap cleanup_101a EXIT
6342 $LCTL set_param -n llite.*.read_ahead_stats 0
6343 $LCTL set_param -n llite.*.max_cached_mb $cache_limit
6346 # randomly read 10000 of 64K chunks from file 3x 32MB in size
6348 echo "nreads: $nreads file size: $((cache_limit * 3))MB"
6349 $READS -f $DIR/$tfile -s$((cache_limit * 3192 * 1024)) -b65536 -C -n$nreads -t 180
6352 for s in $($LCTL get_param -n llite.*.read_ahead_stats |
6353 get_named_value 'read but discarded' | cut -d" " -f1); do
6354 discard=$(($discard + $s))
6358 if [[ $(($discard * 10)) -gt $nreads ]]; then
6359 $LCTL get_param osc.*-osc*.rpc_stats
6360 $LCTL get_param llite.*.read_ahead_stats
6361 error "too many ($discard) discarded pages"
6363 rm -f $DIR/$tfile || true
6365 run_test 101a "check read-ahead for random reads ================"
6368 test_mkdir -p $DIR/$tdir
6369 local STRIPE_SIZE=$1
6370 local FILE_LENGTH=$2
6373 local FILE_SIZE_MB=$((FILE_LENGTH / STRIPE_SIZE))
6375 local list=$(comma_list $(osts_nodes))
6376 set_osd_param $list '' read_cache_enable 0
6377 set_osd_param $list '' writethrough_cache_enable 0
6379 trap cleanup_test101bc EXIT
6380 # prepare the read-ahead file
6381 $SETSTRIPE -S $STRIPE_SIZE -i $STRIPE_OFFSET -c $OSTCOUNT $DIR/$tfile
6383 dd if=/dev/zero of=$DIR/$tfile bs=$STRIPE_SIZE \
6384 count=$FILE_SIZE_MB 2> /dev/null
6388 cleanup_test101bc() {
6393 local list=$(comma_list $(osts_nodes))
6394 set_osd_param $list '' read_cache_enable 1
6395 set_osd_param $list '' writethrough_cache_enable 1
6399 awk 'BEGIN{total=0}; {total+=$1}; END{print total}'
6404 local STRIPE_SIZE=$2
6405 local FILE_LENGTH=$3
6406 local RA_INC=1048576
6407 local STRIDE_LENGTH=$((STRIPE_SIZE/READ_SIZE))
6408 local discard_limit=$((((STRIDE_LENGTH - 1)*3/(STRIDE_LENGTH*OSTCOUNT))* \
6409 (STRIDE_LENGTH*OSTCOUNT - STRIDE_LENGTH)))
6410 DISCARD=$($LCTL get_param -n llite.*.read_ahead_stats |
6411 get_named_value 'read but discarded' |
6412 cut -d" " -f1 | calc_total)
6413 if [[ $DISCARD -gt $discard_limit ]]; then
6414 $LCTL get_param llite.*.read_ahead_stats
6415 error "Too many ($DISCARD) discarded pages with size (${READ_SIZE})"
6417 echo "Read-ahead success for size ${READ_SIZE}"
6422 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6423 [[ $OSTCOUNT -lt 2 ]] &&
6424 skip_env "skipping stride IO stride-ahead test" && return
6425 local STRIPE_SIZE=1048576
6426 local STRIDE_SIZE=$((STRIPE_SIZE*OSTCOUNT))
6427 if [ $SLOW == "yes" ]; then
6428 local FILE_LENGTH=$((STRIDE_SIZE * 64))
6430 local FILE_LENGTH=$((STRIDE_SIZE * 8))
6433 local ITERATION=$((FILE_LENGTH / STRIDE_SIZE))
6435 # prepare the read-ahead file
6436 setup_test101bc $STRIPE_SIZE $FILE_LENGTH
6437 cancel_lru_locks osc
6438 for BIDX in 2 4 8 16 32 64 128 256
6440 local BSIZE=$((BIDX*4096))
6441 local READ_COUNT=$((STRIPE_SIZE/BSIZE))
6442 local STRIDE_LENGTH=$((STRIDE_SIZE/BSIZE))
6443 local OFFSET=$((STRIPE_SIZE/BSIZE*(OSTCOUNT - 1)))
6444 $LCTL set_param -n llite.*.read_ahead_stats 0
6445 $READS -f $DIR/$tfile -l $STRIDE_LENGTH -o $OFFSET \
6446 -s $FILE_LENGTH -b $STRIPE_SIZE -a $READ_COUNT -n $ITERATION
6447 cancel_lru_locks osc
6448 ra_check_101 $BSIZE $STRIPE_SIZE $FILE_LENGTH
6453 run_test 101b "check stride-io mode read-ahead ================="
6456 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6457 local STRIPE_SIZE=1048576
6458 local FILE_LENGTH=$((STRIPE_SIZE*100))
6462 setup_test101bc $STRIPE_SIZE $FILE_LENGTH
6464 cancel_lru_locks osc
6465 $LCTL set_param osc.*.rpc_stats 0
6466 $READS -f $DIR/$tfile -s$FILE_LENGTH -b65536 -n$nreads -t 180
6467 for osc_rpc_stats in $($LCTL get_param -N osc.*.rpc_stats); do
6468 local stats=$($LCTL get_param -n $osc_rpc_stats)
6469 local lines=$(echo "$stats" | awk 'END {print NR;}')
6472 if [ $lines -le 20 ]; then
6475 for size in 1 2 4 8; do
6476 local rpc=$(echo "$stats" |
6477 awk '($1 == "'$size':") {print $2; exit; }')
6479 error "Small $((size*4))k read IO $rpc !"
6481 echo "$osc_rpc_stats check passed!"
6486 run_test 101c "check stripe_size aligned read-ahead ================="
6489 $LCTL get_param -n llite.*.max_read_ahead_mb | head -n 1
6490 $LCTL set_param -n llite.*.max_read_ahead_mb $1 > /dev/null 2>&1
6494 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6495 local file=$DIR/$tfile
6496 local sz_MB=${FILESIZE_101d:-500}
6497 local ra_MB=${READAHEAD_MB:-40}
6499 local free_MB=$(($(df -P $DIR | tail -n 1 | awk '{ print $4 }') / 1024))
6500 [ $free_MB -lt $sz_MB ] &&
6501 skip "Need free space ${sz_MB}M, have ${free_MB}M" && return
6503 echo "Create test file $file size ${sz_MB}M, ${free_MB}M free"
6504 $SETSTRIPE -c -1 $file || error "setstripe failed"
6506 dd if=/dev/zero of=$file bs=1M count=$sz_MB || error "dd failed"
6507 echo Cancel LRU locks on lustre client to flush the client cache
6508 cancel_lru_locks osc
6510 echo Disable read-ahead
6511 local old_READAHEAD=$(set_read_ahead 0)
6513 echo Reading the test file $file with read-ahead disabled
6514 local raOFF=$(do_and_time "dd if=$file of=/dev/null bs=1M count=$sz_MB")
6516 echo Cancel LRU locks on lustre client to flush the client cache
6517 cancel_lru_locks osc
6518 echo Enable read-ahead with ${ra_MB}MB
6519 set_read_ahead $ra_MB
6521 echo Reading the test file $file with read-ahead enabled
6522 local raON=$(do_and_time "dd if=$file of=/dev/null bs=1M count=$sz_MB")
6524 echo "read-ahead disabled time read $raOFF"
6525 echo "read-ahead enabled time read $raON"
6527 set_read_ahead $old_READAHEAD
6529 wait_delete_completed
6531 [ $raOFF -le 1 -o $raON -lt $raOFF ] ||
6532 error "readahead ${raON}s > no-readahead ${raOFF}s ${sz_MB}M"
6534 run_test 101d "file read with and without read-ahead enabled"
6537 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6538 local file=$DIR/$tfile
6539 local size_KB=500 #KB
6543 local free_KB=$(df -P $DIR | tail -n 1 | awk '{ print $4 }')
6544 local need_KB=$((count * size_KB))
6545 [[ $free_KB -le $need_KB ]] &&
6546 skip_env "Need free space $need_KB, have $free_KB" && return
6548 echo "Creating $count ${size_KB}K test files"
6549 for ((i = 0; i < $count; i++)); do
6550 dd if=/dev/zero of=$file.$i bs=$bsize count=$size_KB 2>/dev/null
6553 echo "Cancel LRU locks on lustre client to flush the client cache"
6554 cancel_lru_locks osc
6556 echo "Reset readahead stats"
6557 $LCTL set_param -n llite.*.read_ahead_stats 0
6559 for ((i = 0; i < $count; i++)); do
6560 dd if=$file.$i of=/dev/null bs=$bsize count=$size_KB 2>/dev/null
6563 local miss=$($LCTL get_param -n llite.*.read_ahead_stats |
6564 get_named_value 'misses' | cut -d" " -f1 | calc_total)
6566 for ((i = 0; i < $count; i++)); do
6567 rm -rf $file.$i 2>/dev/null
6570 #10000 means 20% reads are missing in readahead
6571 [[ $miss -lt 10000 ]] || error "misses too much for small reads"
6573 run_test 101e "check read-ahead for small read(1k) for small files(500k)"
6576 which iozone || { skip "no iozone installed" && return; }
6578 # create a test file
6579 iozone -i 0 -+n -r 1m -s 128m -w -f $DIR/$tfile > /dev/null 2>&1
6581 echo Cancel LRU locks on lustre client to flush the client cache
6582 cancel_lru_locks osc
6584 echo Reset readahead stats
6585 $LCTL set_param -n llite.*.read_ahead_stats 0
6587 echo mmap read the file with small block size
6588 iozone -i 1 -+n -r 32k -s 128m -B -f $DIR/$tfile > /dev/null 2>&1
6590 echo checking missing pages
6591 local miss=$($LCTL get_param -n llite.*.read_ahead_stats |
6592 get_named_value 'misses' | cut -d" " -f1 | calc_total)
6594 [ $miss -lt 3 ] || error "misses too much pages!"
6597 run_test 101f "check mmap read performance"
6601 local osts=$(get_facets OST)
6602 local list=$(comma_list $(osts_nodes))
6603 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
6605 save_lustre_params $osts "obdfilter.*.brw_size" > $p
6607 $LFS setstripe -c 1 $DIR/$tfile
6609 if [ $(lustre_version_code ost1) -ge $(version_code 2.8.52) ]; then
6610 set_osd_param $list '' brw_size 16M
6612 echo "remount client to enable large RPC size"
6613 remount_client $MOUNT || error "remount_client failed"
6615 for mp in $($LCTL get_param -n osc.*.max_pages_per_rpc); do
6616 [ "$mp" -eq 4096 ] ||
6617 error "max_pages_per_rpc not correctly set"
6620 $LCTL set_param -n osc.*.rpc_stats=0
6622 # 10*16 MiB should be enough for the test
6623 dd if=/dev/zero of=$DIR/$tfile bs=16M count=10
6624 cancel_lru_locks osc
6625 dd of=/dev/null if=$DIR/$tfile bs=16M count=10
6627 # calculate 16 MiB RPCs
6628 rpcs=$($LCTL get_param 'osc.*.rpc_stats' |
6629 sed -n '/pages per rpc/,/^$/p' |
6630 awk 'BEGIN { sum = 0 }; /4096:/ { sum += $2 };
6633 [ "$rpcs" -eq 10 ] || error "not all RPCs are 16 MiB BRW rpcs"
6636 echo "set RPC size to 4MB"
6638 $LCTL set_param -n osc.*.max_pages_per_rpc=4M osc.*.rpc_stats=0
6639 dd if=/dev/zero of=$DIR/$tfile bs=4M count=25
6640 cancel_lru_locks osc
6641 dd of=/dev/null if=$DIR/$tfile bs=4M count=25
6643 # calculate 4 MiB RPCs
6644 rpcs=$($LCTL get_param 'osc.*.rpc_stats' |
6645 sed -n '/pages per rpc/,/^$/p' |
6646 awk 'BEGIN { sum = 0 }; /1024:/ { sum += $2 };
6649 [ "$rpcs" -eq 25 ] || error "not all RPCs are 4 MiB BRW rpcs"
6651 restore_lustre_params < $p
6652 remount_client $MOUNT || error "remount_client failed"
6654 rm -f $p $DIR/$tfile
6656 run_test 101g "Big bulk(4/16 MiB) readahead"
6659 test_mkdir -p $DIR/$tdir
6660 chown $RUNAS_ID $DIR/$tdir
6663 STRIPE_COUNT=$OSTCOUNT
6664 [[ $OSTCOUNT -gt 4 ]] && STRIPE_COUNT=4
6666 trap cleanup_test102 EXIT
6668 $1 $SETSTRIPE -S $STRIPE_SIZE -i $STRIPE_OFFSET -c $STRIPE_COUNT $tdir
6670 for num in 1 2 3 4; do
6671 for count in $(seq 1 $STRIPE_COUNT); do
6672 for idx in $(seq 0 $[$STRIPE_COUNT - 1]); do
6673 local size=`expr $STRIPE_SIZE \* $num`
6674 local file=file"$num-$idx-$count"
6675 $1 $SETSTRIPE -S $size -i $idx -c $count $file
6681 $1 $TAR cf $TMP/f102.tar $tdir --xattrs
6687 rm -rf $DIR/d0.sanity/d102
6691 local testfile=$DIR/$tfile
6695 [ "$UID" != 0 ] && skip_env "must run as root" && return
6696 [ -z "$(lctl get_param -n mdc.*-mdc-*.connect_flags | grep xattr)" ] &&
6697 skip_env "must have user_xattr" && return
6699 [ -z "$(which setfattr 2>/dev/null)" ] &&
6700 skip_env "could not find setfattr" && return
6702 echo "set/get xattr..."
6703 setfattr -n trusted.name1 -v value1 $testfile ||
6704 error "setfattr -n trusted.name1=value1 $testfile failed"
6705 getfattr -n trusted.name1 $testfile 2> /dev/null |
6706 grep "trusted.name1=.value1" ||
6707 error "$testfile missing trusted.name1=value1"
6709 setfattr -n user.author1 -v author1 $testfile ||
6710 error "setfattr -n user.author1=author1 $testfile failed"
6711 getfattr -n user.author1 $testfile 2> /dev/null |
6712 grep "user.author1=.author1" ||
6713 error "$testfile missing trusted.author1=author1"
6716 setfattr -n trusted.name2 -v value2 $testfile ||
6717 error "$testfile unable to set trusted.name2"
6718 setfattr -n trusted.name3 -v value3 $testfile ||
6719 error "$testfile unable to set trusted.name3"
6720 [ $(getfattr -d -m "^trusted" $testfile 2> /dev/null |
6721 grep "trusted.name" | wc -l) -eq 3 ] ||
6722 error "$testfile missing 3 trusted.name xattrs"
6724 setfattr -n user.author2 -v author2 $testfile ||
6725 error "$testfile unable to set user.author2"
6726 setfattr -n user.author3 -v author3 $testfile ||
6727 error "$testfile unable to set user.author3"
6728 [ $(getfattr -d -m "^user" $testfile 2> /dev/null |
6729 grep "user.author" | wc -l) -eq 3 ] ||
6730 error "$testfile missing 3 user.author xattrs"
6732 echo "remove xattr..."
6733 setfattr -x trusted.name1 $testfile ||
6734 error "$testfile error deleting trusted.name1"
6735 getfattr -d -m trusted $testfile 2> /dev/null | grep "trusted.name1" &&
6736 error "$testfile did not delete trusted.name1 xattr"
6738 setfattr -x user.author1 $testfile ||
6739 error "$testfile error deleting user.author1"
6740 getfattr -d -m user $testfile 2> /dev/null | grep "user.author1" &&
6741 error "$testfile did not delete trusted.name1 xattr"
6743 # b10667: setting lustre special xattr be silently discarded
6744 echo "set lustre special xattr ..."
6745 setfattr -n "trusted.lov" -v "invalid value" $testfile ||
6746 error "$testfile allowed setting trusted.lov"
6748 run_test 102a "user xattr test =================================="
6751 [ -z "$(which setfattr 2>/dev/null)" ] &&
6752 skip_env "could not find setfattr" && return
6754 # b10930: get/set/list trusted.lov xattr
6755 echo "get/set/list trusted.lov xattr ..."
6756 [[ $OSTCOUNT -lt 2 ]] && skip_env "skipping 2-stripe test" && return
6757 local testfile=$DIR/$tfile
6758 $SETSTRIPE -S 65536 -i 1 -c $OSTCOUNT $testfile ||
6759 error "setstripe failed"
6760 local STRIPECOUNT=$($GETSTRIPE -c $testfile) ||
6761 error "getstripe failed"
6762 getfattr -d -m "^trusted" $testfile 2>/dev/null | grep "trusted.lov" ||
6763 error "can't get trusted.lov from $testfile"
6765 local testfile2=${testfile}2
6766 local value=$(getfattr -n trusted.lov $testfile 2>/dev/null |
6767 grep "trusted.lov" | sed -e 's/[^=]\+=//')
6770 setfattr -n trusted.lov -v $value $testfile2
6771 local stripe_size=$($GETSTRIPE -S $testfile2)
6772 local stripe_count=$($GETSTRIPE -c $testfile2)
6773 [[ $stripe_size -eq 65536 ]] ||
6774 error "stripe size $stripe_size != 65536"
6775 [[ $stripe_count -eq $STRIPECOUNT ]] ||
6776 error "stripe count $stripe_count != $STRIPECOUNT"
6779 run_test 102b "getfattr/setfattr for trusted.lov EAs ============"
6782 [ -z "$(which setfattr 2>/dev/null)" ] &&
6783 skip_env "could not find setfattr" && return
6785 # b10930: get/set/list lustre.lov xattr
6786 echo "get/set/list lustre.lov xattr ..."
6787 [[ $OSTCOUNT -lt 2 ]] && skip_env "skipping 2-stripe test" && return
6788 test_mkdir -p $DIR/$tdir
6789 chown $RUNAS_ID $DIR/$tdir
6790 local testfile=$DIR/$tdir/$tfile
6791 $RUNAS $SETSTRIPE -S 65536 -i 1 -c $OSTCOUNT $testfile ||
6792 error "setstripe failed"
6793 local STRIPECOUNT=$($RUNAS $GETSTRIPE -c $testfile) ||
6794 error "getstripe failed"
6795 $RUNAS getfattr -d -m "^lustre" $testfile 2> /dev/null | \
6796 grep "lustre.lov" || error "can't get lustre.lov from $testfile"
6798 local testfile2=${testfile}2
6799 local value=`getfattr -n lustre.lov $testfile 2> /dev/null | \
6800 grep "lustre.lov" |sed -e 's/[^=]\+=//' `
6802 $RUNAS $MCREATE $testfile2
6803 $RUNAS setfattr -n lustre.lov -v $value $testfile2
6804 local stripe_size=$($RUNAS $GETSTRIPE -S $testfile2)
6805 local stripe_count=$($RUNAS $GETSTRIPE -c $testfile2)
6806 [ $stripe_size -eq 65536 ] || error "stripe size $stripe_size != 65536"
6807 [ $stripe_count -eq $STRIPECOUNT ] ||
6808 error "stripe count $stripe_count != $STRIPECOUNT"
6810 run_test 102c "non-root getfattr/setfattr for lustre.lov EAs ==========="
6812 compare_stripe_info1() {
6813 local stripe_index_all_zero=true
6815 for num in 1 2 3 4; do
6816 for count in $(seq 1 $STRIPE_COUNT); do
6817 for offset in $(seq 0 $[$STRIPE_COUNT - 1]); do
6818 local size=$((STRIPE_SIZE * num))
6819 local file=file"$num-$offset-$count"
6820 stripe_size=$($LFS getstripe -S $PWD/$file)
6821 [[ $stripe_size -ne $size ]] &&
6822 error "$file: size $stripe_size != $size"
6823 stripe_count=$($LFS getstripe -c $PWD/$file)
6824 # allow fewer stripes to be created, ORI-601
6825 [[ $stripe_count -lt $(((3 * count + 3) / 4)) ]] &&
6826 error "$file: count $stripe_count != $count"
6827 stripe_index=$($LFS getstripe -i $PWD/$file)
6828 [[ $stripe_index -ne 0 ]] &&
6829 stripe_index_all_zero=false
6833 $stripe_index_all_zero &&
6834 error "all files are being extracted starting from OST index 0"
6839 [ -n "$(which tar 2>/dev/null)" ] &&
6840 strings $(which tar) | grep -q "lustre" && echo tar
6844 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6845 # b10930: tar test for trusted.lov xattr
6846 TAR=$(find_lustre_tar)
6847 [ -z "$TAR" ] && skip_env "lustre-aware tar is not installed" && return
6848 [[ $OSTCOUNT -lt 2 ]] && skip_env "skipping N-stripe test" && return
6850 test_mkdir -p $DIR/d102d
6851 $TAR xf $TMP/f102.tar -C $DIR/d102d --xattrs
6853 compare_stripe_info1
6855 run_test 102d "tar restore stripe info from tarfile,not keep osts ==========="
6858 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6859 # b10930: tar test for trusted.lov xattr
6860 TAR=$(find_lustre_tar)
6861 [ -z "$TAR" ] && skip_env "lustre-aware tar is not installed" && return
6862 [[ $OSTCOUNT -lt 2 ]] && skip_env "skipping N-stripe test" && return
6864 test_mkdir -p $DIR/d102f
6866 $TAR cf - --xattrs $tdir | $TAR xf - --xattrs -C $DIR/d102f
6868 compare_stripe_info1
6870 run_test 102f "tar copy files, not keep osts ==========="
6873 local xsize=${1:-1024} # in bytes
6874 local file=$DIR/$tfile
6876 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep xattr)" ] &&
6877 skip "must have user_xattr" && return 0
6878 [ -z "$(which setfattr 2>/dev/null)" ] &&
6879 skip_env "could not find setfattr" && return 0
6880 [ -z "$(which getfattr 2>/dev/null)" ] &&
6881 skip_env "could not find getfattr" && return 0
6885 local value="$(generate_string $xsize)"
6887 local xbig=trusted.big
6888 log "save $xbig on $file"
6889 setfattr -n $xbig -v $value $file ||
6890 error "saving $xbig on $file failed"
6892 local orig=$(get_xattr_value $xbig $file)
6893 [[ "$orig" != "$value" ]] && error "$xbig different after saving $xbig"
6895 local xsml=trusted.sml
6896 log "save $xsml on $file"
6897 setfattr -n $xsml -v val $file || error "saving $xsml on $file failed"
6899 local new=$(get_xattr_value $xbig $file)
6900 [[ "$new" != "$orig" ]] && error "$xbig different after saving $xsml"
6902 log "grow $xsml on $file"
6903 setfattr -n $xsml -v "$value" $file ||
6904 error "growing $xsml on $file failed"
6906 new=$(get_xattr_value $xbig $file)
6907 [[ "$new" != "$orig" ]] && error "$xbig different after growing $xsml"
6908 log "$xbig still valid after growing $xsml"
6913 test_102h() { # bug 15777
6916 run_test 102h "grow xattr from inside inode to external block"
6919 large_xattr_enabled || { skip "large_xattr disabled" && return; }
6920 grow_xattr $(max_xattr_size)
6922 run_test 102ha "grow xattr from inside inode to external inode"
6924 test_102i() { # bug 17038
6925 [ -z "$(which getfattr 2>/dev/null)" ] &&
6926 skip "could not find getfattr" && return
6928 ln -s $DIR/$tfile $DIR/${tfile}link
6929 getfattr -n trusted.lov $DIR/$tfile ||
6930 error "lgetxattr on $DIR/$tfile failed"
6931 getfattr -h -n trusted.lov $DIR/${tfile}link 2>&1 |
6932 grep -i "no such attr" ||
6933 error "error for lgetxattr on $DIR/${tfile}link is not ENODATA"
6934 rm -f $DIR/$tfile $DIR/${tfile}link
6936 run_test 102i "lgetxattr test on symbolic link ============"
6939 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6940 TAR=$(find_lustre_tar)
6941 [ -z "$TAR" ] && skip_env "lustre-aware tar is not installed" && return
6942 [[ $OSTCOUNT -lt 2 ]] && skip_env "skipping N-stripe test" && return
6943 setup_test102 "$RUNAS"
6944 test_mkdir -p $DIR/d102j
6945 chown $RUNAS_ID $DIR/d102j
6946 $RUNAS $TAR xf $TMP/f102.tar -C $DIR/d102j --xattrs
6948 compare_stripe_info1 "$RUNAS"
6950 run_test 102j "non-root tar restore stripe info from tarfile, not keep osts ==="
6953 [ -z "$(which setfattr 2>/dev/null)" ] &&
6954 skip "could not find setfattr" && return
6956 # b22187 just check that does not crash for regular file.
6957 setfattr -n trusted.lov $DIR/$tfile
6958 # b22187 'setfattr -n trusted.lov' should work as remove LOV EA for directories
6959 local test_kdir=$DIR/d102k
6960 test_mkdir $test_kdir
6961 local default_size=`$GETSTRIPE -S $test_kdir`
6962 local default_count=`$GETSTRIPE -c $test_kdir`
6963 local default_offset=`$GETSTRIPE -i $test_kdir`
6964 $SETSTRIPE -S 65536 -i 0 -c $OSTCOUNT $test_kdir ||
6965 error 'dir setstripe failed'
6966 setfattr -n trusted.lov $test_kdir
6967 local stripe_size=`$GETSTRIPE -S $test_kdir`
6968 local stripe_count=`$GETSTRIPE -c $test_kdir`
6969 local stripe_offset=`$GETSTRIPE -i $test_kdir`
6970 [ $stripe_size -eq $default_size ] ||
6971 error "stripe size $stripe_size != $default_size"
6972 [ $stripe_count -eq $default_count ] ||
6973 error "stripe count $stripe_count != $default_count"
6974 [ $stripe_offset -eq $default_offset ] ||
6975 error "stripe offset $stripe_offset != $default_offset"
6976 rm -rf $DIR/$tfile $test_kdir
6978 run_test 102k "setfattr without parameter of value shouldn't cause a crash"
6981 [ -z "$(which getfattr 2>/dev/null)" ] &&
6982 skip "could not find getfattr" && return
6984 # LU-532 trusted. xattr is invisible to non-root
6985 local testfile=$DIR/$tfile
6989 echo "listxattr as user..."
6990 chown $RUNAS_ID $testfile
6991 $RUNAS getfattr -d -m '.*' $testfile 2>&1 |
6992 grep -q "trusted" &&
6993 error "$testfile trusted xattrs are user visible"
6997 run_test 102l "listxattr size test =================================="
6999 test_102m() { # LU-3403 llite: error of listxattr when buffer is small
7000 local path=$DIR/$tfile
7003 listxattr_size_check $path || error "listattr_size_check $path failed"
7005 run_test 102m "Ensure listxattr fails on small bufffer ========"
7009 getxattr() { # getxattr path name
7010 # Return the base64 encoding of the value of xattr name on path.
7014 # # getfattr --absolute-names --encoding=base64 --name=trusted.lov $path
7016 # trusted.lov=0s0AvRCwEAAAAGAAAAAAAAAAAEAAACAAAAAAAQAAEAA...AAAAAAAAA=
7018 # We print just 0s0AvRCwEAAAAGAAAAAAAAAAAEAAACAAAAAAAQAAEAA...AAAAAAAAA=
7020 getfattr --absolute-names --encoding=base64 --name=$name $path |
7021 awk -F= -v name=$name '$1 == name {
7022 print substr($0, index($0, "=") + 1);
7026 test_102n() { # LU-4101 mdt: protect internal xattrs
7027 local file0=$DIR/$tfile.0
7028 local file1=$DIR/$tfile.1
7029 local xattr0=$TMP/$tfile.0
7030 local xattr1=$TMP/$tfile.1
7034 [ -z "$(which setfattr 2>/dev/null)" ] &&
7035 skip "could not find setfattr" && return
7037 if [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.5.50) ]
7039 skip "MDT < 2.5.50 allows setxattr on internal trusted xattrs"
7043 rm -rf $file0 $file1 $xattr0 $xattr1
7046 # Get 'before' xattrs of $file1.
7047 getfattr --absolute-names --dump --match=- $file1 > $xattr0
7049 for name in lov lma lmv link fid version som hsm lfsck_namespace; do
7050 # Try to copy xattr from $file0 to $file1.
7051 value=$(getxattr $file0 trusted.$name 2> /dev/null)
7053 setfattr --name=trusted.$name --value="$value" $file1 ||
7054 error "setxattr 'trusted.$name' failed"
7056 # Try to set a garbage xattr.
7057 value=0sVGhlIHF1aWNrIGJyb3duIGZveCBqdW1wcyBvdmVyIGl0c2VsZi4=
7059 setfattr --name=trusted.$name --value="$value" $file1 ||
7060 error "setxattr 'trusted.$name' failed"
7062 # Try to remove the xattr from $file1. We don't care if this
7063 # appears to succeed or fail, we just don't want there to be
7064 # any changes or crashes.
7065 setfattr --remove=$trusted.$name $file1 2> /dev/null
7068 if [ $(lustre_version_code $SINGLEMDS) -gt $(version_code 2.6.50) ]
7071 # Try to copy xattr from $file0 to $file1.
7072 value=$(getxattr $file0 trusted.$name 2> /dev/null)
7074 setfattr --name=trusted.$name --value="$value" $file1 ||
7075 error "setxattr 'trusted.$name' failed"
7077 # Try to set a garbage xattr.
7078 value=0sVGhlIHF1aWNrIGJyb3duIGZveCBqdW1wcyBvdmVyIGl0c2VsZi4=
7080 setfattr --name=trusted.$name --value="$value" $file1 ||
7081 error "setxattr 'trusted.$name' failed"
7083 # Try to remove the xattr from $file1. We don't care if this
7084 # appears to succeed or fail, we just don't want there to be
7085 # any changes or crashes.
7086 setfattr --remove=$trusted.$name $file1 2> /dev/null
7089 # Get 'after' xattrs of file1.
7090 getfattr --absolute-names --dump --match=- $file1 > $xattr1
7092 if ! diff $xattr0 $xattr1; then
7093 error "before and after xattrs of '$file1' differ"
7096 rm -rf $file0 $file1 $xattr0 $xattr1
7100 run_test 102n "silently ignore setxattr on internal trusted xattrs"
7102 test_102p() { # LU-4703 setxattr did not check ownership
7103 local testfile=$DIR/$tfile
7105 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.5.56) ] &&
7106 skip "MDS needs to be at least 2.5.56" && return
7110 echo "setfacl as user..."
7111 $RUNAS setfacl -m "u:$RUNAS_ID:rwx" $testfile
7112 [ $? -ne 0 ] || error "setfacl by $RUNAS_ID was allowed on $testfile"
7114 echo "setfattr as user..."
7115 setfacl -m "u:$RUNAS_ID:---" $testfile
7116 $RUNAS setfattr -x system.posix_acl_access $testfile
7117 [ $? -ne 0 ] || error "setfattr by $RUNAS_ID was allowed on $testfile"
7119 run_test 102p "check setxattr(2) correctly fails without permission"
7122 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.6.92) ] &&
7123 skip "MDS needs to be at least 2.6.92" && return
7124 orphan_linkea_check $DIR/$tfile || error "orphan_linkea_check"
7126 run_test 102q "flistxattr should not return trusted.link EAs for orphans"
7129 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.6.93) ] &&
7130 skip "MDS needs to be at least 2.6.93" && return
7131 touch $DIR/$tfile || error "touch"
7132 setfattr -n user.$(basename $tfile) $DIR/$tfile || error "setfattr"
7133 getfattr -n user.$(basename $tfile) $DIR/$tfile || error "getfattr"
7134 rm $DIR/$tfile || error "rm"
7137 mkdir -p $DIR/$tdir || error "mkdir"
7138 setfattr -n user.$(basename $tdir) $DIR/$tdir || error "setfattr dir"
7139 getfattr -n user.$(basename $tdir) $DIR/$tdir || error "getfattr dir"
7140 setfattr -x user.$(basename $tdir) $DIR/$tdir ||
7141 error "$testfile error deleting user.author1"
7142 getfattr -d -m user.$(basename $tdir) 2> /dev/null |
7143 grep "user.$(basename $tdir)" &&
7144 error "$tdir did not delete user.$(basename $tdir)"
7145 rmdir $DIR/$tdir || error "rmdir"
7148 test_mkdir -p $DIR/$tdir || error "make striped dir"
7149 setfattr -n user.$(basename $tdir) $DIR/$tdir || error "setfattr dir"
7150 getfattr -n user.$(basename $tdir) $DIR/$tdir || error "getfattr dir"
7151 setfattr -x user.$(basename $tdir) $DIR/$tdir ||
7152 error "$testfile error deleting user.author1"
7153 getfattr -d -m user.$(basename $tdir) 2> /dev/null |
7154 grep "user.$(basename $tdir)" &&
7155 error "$tdir did not delete user.$(basename $tdir)"
7156 rmdir $DIR/$tdir || error "rm striped dir"
7158 run_test 102r "set EAs with empty values"
7162 $LUSTRE/tests/acl/run $LUSTRE/tests/acl/$1.test
7167 [ "$UID" != 0 ] && skip_env "must run as root" && return
7168 [ -z "$(lctl get_param -n mdc.*-mdc-*.connect_flags | grep acl)" ] &&
7169 skip "must have acl enabled" && return
7170 [ -z "$(which setfacl 2>/dev/null)" ] &&
7171 skip_env "could not find setfacl" && return
7172 $GSS && skip "could not run under gss" && return
7174 gpasswd -a daemon bin # LU-5641
7175 do_facet $SINGLEMDS gpasswd -a daemon bin # LU-5641
7177 declare -a identity_old
7179 for num in $(seq $MDSCOUNT); do
7180 switch_identity $num true || identity_old[$num]=$?
7187 echo "performing cp ..."
7188 run_acl_subtest cp || error "run_acl_subtest cp failed"
7189 echo "performing getfacl-noacl..."
7190 run_acl_subtest getfacl-noacl || error "getfacl-noacl test failed"
7191 echo "performing misc..."
7192 run_acl_subtest misc || error "misc test failed"
7193 echo "performing permissions..."
7194 run_acl_subtest permissions || error "permissions failed"
7195 echo "performing setfacl..."
7196 run_acl_subtest setfacl || error "setfacl test failed"
7198 # inheritance test got from HP
7199 echo "performing inheritance..."
7200 cp $LUSTRE/tests/acl/make-tree . || error "cannot copy make-tree"
7201 chmod +x make-tree || error "chmod +x failed"
7202 run_acl_subtest inheritance || error "inheritance test failed"
7205 echo "LU-974 ignore umask when acl is enabled..."
7206 run_acl_subtest 974 || error "LU-974 umask test failed"
7207 if [ $MDSCOUNT -ge 2 ]; then
7208 run_acl_subtest 974_remote ||
7209 error "LU-974 umask test failed under remote dir"
7212 echo "LU-2561 newly created file is same size as directory..."
7213 if [ $(facet_fstype $SINGLEMDS) != "zfs" ]; then
7214 run_acl_subtest 2561 || error "LU-2561 test failed"
7216 run_acl_subtest 2561_zfs || error "LU-2561 zfs test failed"
7219 run_acl_subtest 4924 || error "LU-4924 test failed"
7224 for num in $(seq $MDSCOUNT); do
7225 if [ "${identity_old[$num]}" = 1 ]; then
7226 switch_identity $num false || identity_old[$num]=$?
7230 run_test 103a "acl test ========================================="
7234 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
7235 local mountopts=$MDS_MOUNT_OPTS
7237 if [[ "$MDS_MOUNT_OPTS" =~ "noacl" ]]; then
7241 stop $SINGLEMDS || error "failed to stop MDT."
7243 if [ -z "$MDS_MOUNT_OPTS" ]; then
7244 MDS_MOUNT_OPTS="-o noacl"
7246 MDS_MOUNT_OPTS="${MDS_MOUNT_OPTS},noacl"
7248 start $SINGLEMDS $MDT_DEV $MDS_MOUNT_OPTS ||
7249 error "failed to start MDT."
7250 MDS_MOUNT_OPTS=$mountopts
7254 setfacl -m u:bin:rw $DIR/$tfile && error "setfacl should fail"
7258 stop $SINGLEMDS || error "failed to stop MDT."
7260 start $SINGLEMDS $MDT_DEV $MDS_MOUNT_OPTS ||
7261 error "failed to start MDT."
7266 run_test 103b "MDS mount option 'noacl'"
7270 cp -rp $DIR/$tdir $DIR/$tdir.bak
7272 [ -n "$(getfattr -d -m. $DIR/$tdir | grep posix_acl_default)" ] &&
7273 error "$DIR/$tdir shouldn't contain default ACL"
7274 [ -n "$(getfattr -d -m. $DIR/$tdir.bak | grep posix_acl_default)" ] &&
7275 error "$DIR/$tdir.bak shouldn't contain default ACL"
7278 run_test 103c "'cp -rp' won't set empty acl"
7281 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7283 lfs df || error "lfs df failed"
7284 lfs df -ih || error "lfs df -ih failed"
7285 lfs df -h $DIR || error "lfs df -h $DIR failed"
7286 lfs df -i $DIR || error "lfs df -i $DIR failed"
7287 lfs df $DIR/$tfile || error "lfs df $DIR/$tfile failed"
7288 lfs df -ih $DIR/$tfile || error "lfs df -ih $DIR/$tfile failed"
7290 local OSC=$(lctl dl | grep OST0000-osc-[^M] | awk '{ print $4 }')
7291 lctl --device %$OSC deactivate
7292 lfs df || error "lfs df with deactivated OSC failed"
7293 lctl --device %$OSC activate
7294 # wait the osc back to normal
7295 wait_osc_import_state client ost FULL
7297 lfs df || error "lfs df with reactivated OSC failed"
7300 run_test 104a "lfs df [-ih] [path] test ========================="
7303 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7304 [ $RUNAS_ID -eq $UID ] &&
7305 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
7307 denied_cnt=$(($($RUNAS $LFS check servers 2>&1 |
7308 grep "Permission denied" | wc -l)))
7309 if [ $denied_cnt -ne 0 ]; then
7310 error "lfs check servers test failed"
7313 run_test 104b "$RUNAS lfs check servers test ===================="
7316 # doesn't work on 2.4 kernels
7318 if $(flock_is_enabled); then
7319 flocks_test 1 on -f $DIR/$tfile || error "fail flock on"
7321 flocks_test 1 off -f $DIR/$tfile || error "fail flock off"
7325 run_test 105a "flock when mounted without -o flock test ========"
7329 if $(flock_is_enabled); then
7330 flocks_test 1 on -c $DIR/$tfile || error "fail flock on"
7332 flocks_test 1 off -c $DIR/$tfile || error "fail flock off"
7336 run_test 105b "fcntl when mounted without -o flock test ========"
7340 if $(flock_is_enabled); then
7341 flocks_test 1 on -l $DIR/$tfile || error "fail flock on"
7343 flocks_test 1 off -l $DIR/$tfile || error "fail flock off"
7347 run_test 105c "lockf when mounted without -o flock test ========"
7349 test_105d() { # bug 15924
7350 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7351 test_mkdir -p $DIR/$tdir
7352 flock_is_enabled || { skip "mount w/o flock enabled" && return; }
7353 #define OBD_FAIL_LDLM_CP_CB_WAIT 0x315
7354 $LCTL set_param fail_loc=0x80000315
7355 flocks_test 2 $DIR/$tdir
7357 run_test 105d "flock race (should not freeze) ========"
7359 test_105e() { # bug 22660 && 22040
7360 flock_is_enabled || { skip "mount w/o flock enabled" && return; }
7362 flocks_test 3 $DIR/$tfile
7364 run_test 105e "Two conflicting flocks from same process ======="
7366 test_106() { #bug 10921
7367 test_mkdir -p $DIR/$tdir
7368 $DIR/$tdir && error "exec $DIR/$tdir succeeded"
7369 chmod 777 $DIR/$tdir || error "chmod $DIR/$tdir failed"
7371 run_test 106 "attempt exec of dir followed by chown of that dir"
7374 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7381 local save_pattern=$(sysctl -n kernel.core_pattern)
7382 local save_uses_pid=$(sysctl -n kernel.core_uses_pid)
7383 sysctl -w kernel.core_pattern=$file
7384 sysctl -w kernel.core_uses_pid=0
7392 kill -s 11 $SLEEPPID
7394 if [ -e $file ]; then
7395 size=`stat -c%s $file`
7396 [ $size -eq 0 ] && error "Fail to create core file $file"
7398 error "Fail to create core file $file"
7401 sysctl -w kernel.core_pattern=$save_pattern
7402 sysctl -w kernel.core_uses_pid=$save_uses_pid
7405 run_test 107 "Coredump on SIG"
7408 test_mkdir -p $DIR/$tdir
7409 test_mkdir $DIR/$tdir/$(str_repeat 'a' 255) ||
7410 error "mkdir with 255 char failed"
7411 test_mkdir $DIR/$tdir/$(str_repeat 'b' 256) &&
7412 error "mkdir with 256 char should fail, but did not"
7413 touch $DIR/$tdir/$(str_repeat 'x' 255) ||
7414 error "create with 255 char failed"
7415 touch $DIR/$tdir/$(str_repeat 'y' 256) &&
7416 error "create with 256 char should fail, but did not"
7421 run_test 110 "filename length checking"
7424 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7425 OSTIO_pre=$(ps -e | grep ll_ost_io | awk '{ print $4 }'| sort -n |
7426 tail -1 | cut -c11-20)
7427 [ -z "$OSTIO_pre" ] && skip "no OSS threads" && return
7428 echo "Starting with $OSTIO_pre threads"
7431 NUMFREE=$(df -i -P $DIR | tail -n 1 | awk '{ print $4 }')
7432 [[ $NUMFREE -lt $NUMTEST ]] && NUMTEST=$(($NUMFREE - 1000))
7433 echo "$NUMTEST creates/unlinks"
7434 test_mkdir -p $DIR/$tdir
7435 createmany -o $DIR/$tdir/$tfile $NUMTEST
7436 unlinkmany $DIR/$tdir/$tfile $NUMTEST
7438 OSTIO_post=$(ps -e | grep ll_ost_io | awk '{ print $4 }' | sort -n |
7439 tail -1 | cut -c11-20)
7441 # don't return an error
7442 [ $OSTIO_post == $OSTIO_pre ] && echo \
7443 "WARNING: No new ll_ost_io threads were created ($OSTIO_pre)" &&
7444 echo "This may be fine, depending on what ran before this test" &&
7445 echo "and how fast this system is." && return
7447 echo "Started with $OSTIO_pre threads, ended with $OSTIO_post"
7449 run_test 115 "verify dynamic thread creation===================="
7452 wait_delete_completed
7453 AVAIL=($(lctl get_param -n osc.*[oO][sS][cC]-[^M]*.kbytesavail))
7454 echo OST kbytes available: ${AVAIL[@]}
7455 MAXI=0; MAXV=${AVAIL[0]}
7456 MINI=0; MINV=${AVAIL[0]}
7457 for ((i = 0; i < ${#AVAIL[@]}; i++)); do
7458 #echo OST $i: ${AVAIL[i]}kb
7459 if [[ ${AVAIL[i]} -gt $MAXV ]]; then
7460 MAXV=${AVAIL[i]}; MAXI=$i
7462 if [[ ${AVAIL[i]} -lt $MINV ]]; then
7463 MINV=${AVAIL[i]}; MINI=$i
7466 echo Min free space: OST $MINI: $MINV
7467 echo Max free space: OST $MAXI: $MAXV
7470 test_116a() { # was previously test_116()
7471 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7472 remote_mds_nodsh && skip "remote MDS with nodsh" && return
7474 [[ $OSTCOUNT -lt 2 ]] && skip_env "$OSTCOUNT < 2 OSTs" && return
7476 echo -n "Free space priority "
7477 do_facet $SINGLEMDS lctl get_param -n lo*.*-mdtlov.qos_prio_free |
7482 [ $MINV -eq 0 ] && skip "no free space in OST$MINI, skip" && return
7483 [ $MINV -gt 10000000 ] && skip "too much free space in OST$MINI, skip" \
7485 trap simple_cleanup_common EXIT
7488 # Check if we need to generate uneven OSTs
7489 test_mkdir -p $DIR/$tdir/OST${MINI}
7490 local FILL=$(($MINV / 4))
7491 local DIFF=$(($MAXV - $MINV))
7492 local DIFF2=$(($DIFF * 100 / $MINV))
7494 local threshold=$(do_facet $SINGLEMDS \
7495 lctl get_param -n *.*MDT0000-mdtlov.qos_threshold_rr | head -n1)
7496 threshold=${threshold%%%}
7497 echo -n "Check for uneven OSTs: "
7498 echo -n "diff=${DIFF}KB (${DIFF2}%) must be > ${threshold}% ..."
7500 if [[ $DIFF2 -gt $threshold ]]; then
7502 echo "Don't need to fill OST$MINI"
7504 # generate uneven OSTs. Write 2% over the QOS threshold value
7506 DIFF=$(($threshold - $DIFF2 + 2))
7507 DIFF2=$(( ($MINV * $DIFF)/100 ))
7508 echo "Fill ${DIFF}% remaining space in OST${MINI} with ${DIFF2}KB"
7509 $SETSTRIPE -i $MINI -c 1 $DIR/$tdir/OST${MINI} ||
7510 error "setstripe failed"
7511 DIFF=$(($DIFF2 / 2048))
7513 while [ $i -lt $DIFF ]; do
7515 dd if=/dev/zero of=$DIR/$tdir/OST${MINI}/$tfile-$i \
7516 bs=2M count=1 2>/dev/null
7525 DIFF=$(($MAXV - $MINV))
7526 DIFF2=$(($DIFF * 100 / $MINV))
7527 echo -n "diff=${DIFF}=${DIFF2}% must be > ${threshold}% for QOS mode..."
7528 if [[ $DIFF2 -gt $threshold ]]; then
7531 echo "failed - QOS mode won't be used"
7532 skip "QOS imbalance criteria not met"
7533 simple_cleanup_common
7537 MINI1=$MINI; MINV1=$MINV
7538 MAXI1=$MAXI; MAXV1=$MAXV
7540 # now fill using QOS
7541 $SETSTRIPE -c 1 $DIR/$tdir
7542 FILL=$(($FILL / 200))
7543 if [ $FILL -gt 600 ]; then
7546 echo "writing $FILL files to QOS-assigned OSTs"
7548 while [ $i -lt $FILL ]; do
7550 dd if=/dev/zero of=$DIR/$tdir/$tfile-$i bs=200k \
7554 echo "wrote $i 200k files"
7558 echo "Note: free space may not be updated, so measurements might be off"
7560 DIFF2=$(($MAXV - $MINV))
7561 echo "free space delta: orig $DIFF final $DIFF2"
7562 [ $DIFF2 -gt $DIFF ] && echo "delta got worse!"
7563 DIFF=$(($MINV1 - ${AVAIL[$MINI1]}))
7564 echo "Wrote ${DIFF}KB to smaller OST $MINI1"
7565 DIFF2=$(($MAXV1 - ${AVAIL[$MAXI1]}))
7566 echo "Wrote ${DIFF2}KB to larger OST $MAXI1"
7567 FILL=$(($DIFF2 * 100 / $DIFF - 100))
7569 echo "Wrote ${FILL}% more data to larger OST $MAXI1"
7571 # Figure out which files were written where
7572 UUID=$(lctl get_param -n lov.${FSNAME}-clilov-*.target_obd |
7573 awk '/'$MINI1': / {print $2; exit}')
7575 MINC=$($GETSTRIPE --ost $UUID $DIR/$tdir | grep $DIR | wc -l)
7576 echo "$MINC files created on smaller OST $MINI1"
7577 UUID=$(lctl get_param -n lov.${FSNAME}-clilov-*.target_obd |
7578 awk '/'$MAXI1': / {print $2; exit}')
7580 MAXC=$($GETSTRIPE --ost $UUID $DIR/$tdir | grep $DIR | wc -l)
7581 echo "$MAXC files created on larger OST $MAXI1"
7582 FILL=$(($MAXC * 100 / $MINC - 100))
7583 [[ $MINC -gt 0 ]] &&
7584 echo "Wrote ${FILL}% more files to larger OST $MAXI1"
7585 [[ $MAXC -gt $MINC ]] ||
7586 error_ignore LU-9 "stripe QOS didn't balance free space"
7587 simple_cleanup_common
7589 run_test 116a "stripe QOS: free space balance ==================="
7591 test_116b() { # LU-2093
7592 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7593 remote_mds_nodsh && skip "remote MDS with nodsh" && return
7595 #define OBD_FAIL_MDS_OSC_CREATE_FAIL 0x147
7596 local old_rr=$(do_facet $SINGLEMDS lctl get_param -n \
7597 lo*.$FSNAME-MDT0000-mdtlov.qos_threshold_rr | head -1)
7598 [ -z "$old_rr" ] && skip "no QOS" && return 0
7599 do_facet $SINGLEMDS lctl set_param \
7600 lo*.$FSNAME-MDT0000-mdtlov.qos_threshold_rr=0
7602 do_facet $SINGLEMDS lctl set_param fail_loc=0x147
7603 createmany -o $DIR/$tdir/f- 20 || error "can't create"
7604 do_facet $SINGLEMDS lctl set_param fail_loc=0
7606 do_facet $SINGLEMDS lctl set_param \
7607 lo*.$FSNAME-MDT0000-mdtlov.qos_threshold_rr=$old_rr
7609 run_test 116b "QoS shouldn't LBUG if not enough OSTs found on the 2nd pass"
7611 test_117() # bug 10891
7613 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7614 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1
7615 #define OBD_FAIL_OST_SETATTR_CREDITS 0x21e
7616 lctl set_param fail_loc=0x21e
7617 > $DIR/$tfile || error "truncate failed"
7618 lctl set_param fail_loc=0
7619 echo "Truncate succeeded."
7622 run_test 117 "verify osd extend =========="
7624 NO_SLOW_RESENDCOUNT=4
7625 export OLD_RESENDCOUNT=""
7626 set_resend_count () {
7627 local PROC_RESENDCOUNT="osc.${FSNAME}-OST*-osc-*.resend_count"
7628 OLD_RESENDCOUNT=$(lctl get_param -n $PROC_RESENDCOUNT | head -n1)
7629 lctl set_param -n $PROC_RESENDCOUNT $1
7630 echo resend_count is set to $(lctl get_param -n $PROC_RESENDCOUNT)
7633 # for reduce test_118* time (b=14842)
7634 [ "$SLOW" = "no" ] && set_resend_count $NO_SLOW_RESENDCOUNT
7636 # Reset async IO behavior after error case
7638 FILE=$DIR/reset_async
7640 # Ensure all OSCs are cleared
7641 $SETSTRIPE -c -1 $FILE
7642 dd if=/dev/zero of=$FILE bs=64k count=$OSTCOUNT
7647 test_118a() #bug 11710
7649 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7652 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
7653 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
7654 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
7656 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
7657 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
7662 run_test 118a "verify O_SYNC works =========="
7666 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7667 remote_ost_nodsh && skip "remote OST with nodsh" && return
7671 #define OBD_FAIL_SRV_ENOENT 0x217
7672 set_nodes_failloc "$(osts_nodes)" 0x217
7673 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
7675 set_nodes_failloc "$(osts_nodes)" 0
7676 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
7677 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
7680 if [[ $RC -eq 0 ]]; then
7681 error "Must return error due to dropped pages, rc=$RC"
7685 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
7686 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
7690 echo "Dirty pages not leaked on ENOENT"
7692 # Due to the above error the OSC will issue all RPCs syncronously
7693 # until a subsequent RPC completes successfully without error.
7694 $MULTIOP $DIR/$tfile Ow4096yc
7699 run_test 118b "Reclaim dirty pages on fatal error =========="
7703 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7705 # for 118c, restore the original resend count, LU-1940
7706 [ "$SLOW" = "no" ] && [ -n "$OLD_RESENDCOUNT" ] &&
7707 set_resend_count $OLD_RESENDCOUNT
7708 remote_ost_nodsh && skip "remote OST with nodsh" && return
7712 #define OBD_FAIL_OST_EROFS 0x216
7713 set_nodes_failloc "$(osts_nodes)" 0x216
7715 # multiop should block due to fsync until pages are written
7716 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
7720 if [[ `ps h -o comm -p $MULTIPID` != "multiop" ]]; then
7721 error "Multiop failed to block on fsync, pid=$MULTIPID"
7724 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
7726 if [[ $WRITEBACK -eq 0 ]]; then
7727 error "No page in writeback, writeback=$WRITEBACK"
7730 set_nodes_failloc "$(osts_nodes)" 0
7733 if [[ $RC -ne 0 ]]; then
7734 error "Multiop fsync failed, rc=$RC"
7737 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
7738 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
7740 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
7741 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
7745 echo "Dirty pages flushed via fsync on EROFS"
7748 run_test 118c "Fsync blocks on EROFS until dirty pages are flushed =========="
7750 # continue to use small resend count to reduce test_118* time (b=14842)
7751 [ "$SLOW" = "no" ] && set_resend_count $NO_SLOW_RESENDCOUNT
7755 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7756 remote_ost_nodsh && skip "remote OST with nodsh" && return
7760 #define OBD_FAIL_OST_BRW_PAUSE_BULK
7761 set_nodes_failloc "$(osts_nodes)" 0x214
7762 # multiop should block due to fsync until pages are written
7763 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
7767 if [[ `ps h -o comm -p $MULTIPID` != "multiop" ]]; then
7768 error "Multiop failed to block on fsync, pid=$MULTIPID"
7771 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
7773 if [[ $WRITEBACK -eq 0 ]]; then
7774 error "No page in writeback, writeback=$WRITEBACK"
7777 wait $MULTIPID || error "Multiop fsync failed, rc=$?"
7778 set_nodes_failloc "$(osts_nodes)" 0
7780 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
7781 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
7783 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
7784 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
7788 echo "Dirty pages gaurenteed flushed via fsync"
7791 run_test 118d "Fsync validation inject a delay of the bulk =========="
7794 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7797 #define OBD_FAIL_OSC_BRW_PREP_REQ2 0x40a
7798 lctl set_param fail_loc=0x8000040a
7800 # Should simulate EINVAL error which is fatal
7801 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
7803 if [[ $RC -eq 0 ]]; then
7804 error "Must return error due to dropped pages, rc=$RC"
7807 lctl set_param fail_loc=0x0
7809 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
7810 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
7811 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
7813 if [[ $LOCKED -ne 0 ]]; then
7814 error "Locked pages remain in cache, locked=$LOCKED"
7817 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
7818 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
7822 echo "No pages locked after fsync"
7827 run_test 118f "Simulate unrecoverable OSC side error =========="
7830 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7833 #define OBD_FAIL_OSC_BRW_PREP_REQ 0x406
7834 lctl set_param fail_loc=0x406
7836 # simulate local -ENOMEM
7837 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
7840 lctl set_param fail_loc=0
7841 if [[ $RC -eq 0 ]]; then
7842 error "Must return error due to dropped pages, rc=$RC"
7845 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
7846 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
7847 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
7849 if [[ $LOCKED -ne 0 ]]; then
7850 error "Locked pages remain in cache, locked=$LOCKED"
7853 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
7854 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
7858 echo "No pages locked after fsync"
7863 run_test 118g "Don't stay in wait if we got local -ENOMEM =========="
7866 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7867 remote_ost_nodsh && skip "remote OST with nodsh" && return
7871 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
7872 set_nodes_failloc "$(osts_nodes)" 0x20e
7873 # Should simulate ENOMEM error which is recoverable and should be handled by timeout
7874 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
7877 set_nodes_failloc "$(osts_nodes)" 0
7878 if [[ $RC -eq 0 ]]; then
7879 error "Must return error due to dropped pages, rc=$RC"
7882 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
7883 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
7884 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
7886 if [[ $LOCKED -ne 0 ]]; then
7887 error "Locked pages remain in cache, locked=$LOCKED"
7890 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
7891 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
7895 echo "No pages locked after fsync"
7899 run_test 118h "Verify timeout in handling recoverables errors =========="
7901 [ "$SLOW" = "no" ] && [ -n "$OLD_RESENDCOUNT" ] && set_resend_count $OLD_RESENDCOUNT
7904 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7905 remote_ost_nodsh && skip "remote OST with nodsh" && return
7909 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
7910 set_nodes_failloc "$(osts_nodes)" 0x20e
7912 # Should simulate ENOMEM error which is recoverable and should be handled by timeout
7913 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
7916 set_nodes_failloc "$(osts_nodes)" 0
7920 if [[ $RC -ne 0 ]]; then
7921 error "got error, but should be not, rc=$RC"
7924 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
7925 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
7926 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
7927 if [[ $LOCKED -ne 0 ]]; then
7928 error "Locked pages remain in cache, locked=$LOCKED"
7931 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
7932 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
7936 echo "No pages locked after fsync"
7940 run_test 118i "Fix error before timeout in recoverable error =========="
7942 [ "$SLOW" = "no" ] && set_resend_count 4
7945 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7946 remote_ost_nodsh && skip "remote OST with nodsh" && return
7950 #define OBD_FAIL_OST_BRW_WRITE_BULK2 0x220
7951 set_nodes_failloc "$(osts_nodes)" 0x220
7953 # return -EIO from OST
7954 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
7956 set_nodes_failloc "$(osts_nodes)" 0x0
7957 if [[ $RC -eq 0 ]]; then
7958 error "Must return error due to dropped pages, rc=$RC"
7961 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
7962 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
7963 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
7964 if [[ $LOCKED -ne 0 ]]; then
7965 error "Locked pages remain in cache, locked=$LOCKED"
7968 # in recoverable error on OST we want resend and stay until it finished
7969 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
7970 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
7974 echo "No pages locked after fsync"
7978 run_test 118j "Simulate unrecoverable OST side error =========="
7982 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7983 remote_ost_nodsh && skip "remote OSTs with nodsh" && return
7985 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
7986 set_nodes_failloc "$(osts_nodes)" 0x20e
7987 test_mkdir -p $DIR/$tdir
7989 for ((i=0;i<10;i++)); do
7990 (dd if=/dev/zero of=$DIR/$tdir/$tfile-$i bs=1M count=10 || \
7991 error "dd to $DIR/$tdir/$tfile-$i failed" )&
7998 set_nodes_failloc "$(osts_nodes)" 0
8001 run_test 118k "bio alloc -ENOMEM and IO TERM handling ========="
8005 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8007 test_mkdir -p $DIR/$tdir
8008 $MULTIOP $DIR/$tdir Dy || error "fsync dir failed"
8011 run_test 118l "fsync dir ========="
8013 test_118m() # LU-3066
8015 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8016 test_mkdir -p $DIR/$tdir
8017 $MULTIOP $DIR/$tdir DY || error "fdatasync dir failed"
8020 run_test 118m "fdatasync dir ========="
8022 [ "$SLOW" = "no" ] && [ -n "$OLD_RESENDCOUNT" ] && set_resend_count $OLD_RESENDCOUNT
8024 test_119a() # bug 11737
8026 BSIZE=$((512 * 1024))
8027 directio write $DIR/$tfile 0 1 $BSIZE
8028 # We ask to read two blocks, which is more than a file size.
8029 # directio will indicate an error when requested and actual
8030 # sizes aren't equeal (a normal situation in this case) and
8031 # print actual read amount.
8032 NOB=`directio read $DIR/$tfile 0 2 $BSIZE | awk '/error/ {print $6}'`
8033 if [ "$NOB" != "$BSIZE" ]; then
8034 error "read $NOB bytes instead of $BSIZE"
8038 run_test 119a "Short directIO read must return actual read amount"
8040 test_119b() # bug 11737
8042 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping 2-stripe test" && return
8044 $SETSTRIPE -c 2 $DIR/$tfile || error "setstripe failed"
8045 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=1 || error "dd failed"
8047 $MULTIOP $DIR/$tfile oO_RDONLY:O_DIRECT:r$((2048 * 1024)) || \
8048 error "direct read failed"
8051 run_test 119b "Sparse directIO read must return actual read amount"
8053 test_119c() # bug 13099
8056 directio write $DIR/$tfile 3 1 $BSIZE || error "direct write failed"
8057 directio readhole $DIR/$tfile 0 2 $BSIZE || error "reading hole failed"
8060 run_test 119c "Testing for direct read hitting hole"
8062 test_119d() # bug 15950
8064 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8065 MAX_RPCS_IN_FLIGHT=`$LCTL get_param -n osc.*OST0000-osc-[^mM]*.max_rpcs_in_flight`
8066 $LCTL set_param -n osc.*OST0000-osc-[^mM]*.max_rpcs_in_flight 1
8068 $SETSTRIPE $DIR/$tfile -i 0 -c 1 || error "setstripe failed"
8069 $DIRECTIO write $DIR/$tfile 0 1 $BSIZE || error "first directio failed"
8070 #define OBD_FAIL_OSC_DIO_PAUSE 0x40d
8071 lctl set_param fail_loc=0x40d
8072 $DIRECTIO write $DIR/$tfile 1 4 $BSIZE &
8075 cat $DIR/$tfile > /dev/null &
8076 lctl set_param fail_loc=0
8079 log "the DIO writes have completed, now wait for the reads (should not block very long)"
8081 [ -n "`ps h -p $pid_reads -o comm`" ] && \
8082 error "the read rpcs have not completed in 2s"
8084 $LCTL set_param -n osc.*OST0000-osc-[^mM]*.max_rpcs_in_flight $MAX_RPCS_IN_FLIGHT
8086 run_test 119d "The DIO path should try to send a new rpc once one is completed"
8089 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8090 test_mkdir -p $DIR/$tdir
8091 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
8092 skip "no early lock cancel on server" && return 0
8094 lru_resize_disable mdc
8095 lru_resize_disable osc
8096 cancel_lru_locks mdc
8097 # asynchronous object destroy at MDT could cause bl ast to client
8098 cancel_lru_locks osc
8100 stat $DIR/$tdir > /dev/null
8101 can1=$(do_facet $SINGLEMDS \
8102 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8103 awk '/ldlm_cancel/ {print $2}')
8104 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8105 awk '/ldlm_bl_callback/ {print $2}')
8106 test_mkdir -c1 $DIR/$tdir/d1
8107 can2=$(do_facet $SINGLEMDS \
8108 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8109 awk '/ldlm_cancel/ {print $2}')
8110 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8111 awk '/ldlm_bl_callback/ {print $2}')
8112 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
8113 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
8114 lru_resize_enable mdc
8115 lru_resize_enable osc
8117 run_test 120a "Early Lock Cancel: mkdir test"
8120 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8121 test_mkdir $DIR/$tdir
8122 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel)" ] && \
8123 skip "no early lock cancel on server" && return 0
8124 lru_resize_disable mdc
8125 lru_resize_disable osc
8126 cancel_lru_locks mdc
8127 stat $DIR/$tdir > /dev/null
8128 can1=$(do_facet $SINGLEMDS \
8129 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8130 awk '/ldlm_cancel/ {print $2}')
8131 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8132 awk '/ldlm_bl_callback/ {print $2}')
8134 can2=$(do_facet $SINGLEMDS \
8135 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8136 awk '/ldlm_cancel/ {print $2}')
8137 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8138 awk '/ldlm_bl_callback/ {print $2}')
8139 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
8140 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
8141 lru_resize_enable mdc
8142 lru_resize_enable osc
8144 run_test 120b "Early Lock Cancel: create test"
8147 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8148 test_mkdir -c1 $DIR/$tdir
8149 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel)" ] && \
8150 skip "no early lock cancel on server" && return 0
8151 lru_resize_disable mdc
8152 lru_resize_disable osc
8153 test_mkdir -p -c1 $DIR/$tdir/d1
8154 test_mkdir -p -c1 $DIR/$tdir/d2
8155 touch $DIR/$tdir/d1/f1
8156 cancel_lru_locks mdc
8157 stat $DIR/$tdir/d1 $DIR/$tdir/d2 $DIR/$tdir/d1/f1 > /dev/null
8158 can1=$(do_facet $SINGLEMDS \
8159 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8160 awk '/ldlm_cancel/ {print $2}')
8161 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8162 awk '/ldlm_bl_callback/ {print $2}')
8163 ln $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2
8164 can2=$(do_facet $SINGLEMDS \
8165 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8166 awk '/ldlm_cancel/ {print $2}')
8167 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8168 awk '/ldlm_bl_callback/ {print $2}')
8169 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
8170 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
8171 lru_resize_enable mdc
8172 lru_resize_enable osc
8174 run_test 120c "Early Lock Cancel: link test"
8177 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8178 test_mkdir -p -c1 $DIR/$tdir
8179 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel)" ] && \
8180 skip "no early lock cancel on server" && return 0
8181 lru_resize_disable mdc
8182 lru_resize_disable osc
8184 cancel_lru_locks mdc
8185 stat $DIR/$tdir > /dev/null
8186 can1=$(do_facet $SINGLEMDS \
8187 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8188 awk '/ldlm_cancel/ {print $2}')
8189 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8190 awk '/ldlm_bl_callback/ {print $2}')
8191 chmod a+x $DIR/$tdir
8192 can2=$(do_facet $SINGLEMDS \
8193 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8194 awk '/ldlm_cancel/ {print $2}')
8195 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8196 awk '/ldlm_bl_callback/ {print $2}')
8197 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
8198 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
8199 lru_resize_enable mdc
8200 lru_resize_enable osc
8202 run_test 120d "Early Lock Cancel: setattr test"
8205 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8206 ! $($LCTL get_param -n mdc.*.connect_flags | grep -q early_lock_can) &&
8207 skip "no early lock cancel on server" && return 0
8208 local dlmtrace_set=false
8210 test_mkdir -p -c1 $DIR/$tdir
8211 lru_resize_disable mdc
8212 lru_resize_disable osc
8213 ! $LCTL get_param debug | grep -q dlmtrace &&
8214 $LCTL set_param debug=+dlmtrace && dlmtrace_set=true
8215 dd if=/dev/zero of=$DIR/$tdir/f1 count=1
8216 cancel_lru_locks mdc
8217 cancel_lru_locks osc
8218 dd if=$DIR/$tdir/f1 of=/dev/null
8219 stat $DIR/$tdir $DIR/$tdir/f1 > /dev/null
8220 # XXX client can not do early lock cancel of OST lock
8221 # during unlink (LU-4206), so cancel osc lock now.
8222 cancel_lru_locks osc
8223 can1=$(do_facet $SINGLEMDS \
8224 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8225 awk '/ldlm_cancel/ {print $2}')
8226 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8227 awk '/ldlm_bl_callback/ {print $2}')
8228 unlink $DIR/$tdir/f1
8230 can2=$(do_facet $SINGLEMDS \
8231 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8232 awk '/ldlm_cancel/ {print $2}')
8233 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8234 awk '/ldlm_bl_callback/ {print $2}')
8235 [ $can1 -ne $can2 ] && error "$((can2 - can1)) cancel RPC occured" &&
8236 $LCTL dk $TMP/cancel.debug.txt
8237 [ $blk1 -ne $blk2 ] && error "$((blk2 - blk1)) blocking RPC occured" &&
8238 $LCTL dk $TMP/blocking.debug.txt
8239 $dlmtrace_set && $LCTL set_param debug=-dlmtrace
8240 lru_resize_enable mdc
8241 lru_resize_enable osc
8243 run_test 120e "Early Lock Cancel: unlink test"
8246 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8247 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
8248 skip "no early lock cancel on server" && return 0
8249 test_mkdir -p -c1 $DIR/$tdir
8250 lru_resize_disable mdc
8251 lru_resize_disable osc
8252 test_mkdir -p -c1 $DIR/$tdir/d1
8253 test_mkdir -p -c1 $DIR/$tdir/d2
8254 dd if=/dev/zero of=$DIR/$tdir/d1/f1 count=1
8255 dd if=/dev/zero of=$DIR/$tdir/d2/f2 count=1
8256 cancel_lru_locks mdc
8257 cancel_lru_locks osc
8258 dd if=$DIR/$tdir/d1/f1 of=/dev/null
8259 dd if=$DIR/$tdir/d2/f2 of=/dev/null
8260 stat $DIR/$tdir/d1 $DIR/$tdir/d2 $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2 > /dev/null
8261 # XXX client can not do early lock cancel of OST lock
8262 # during rename (LU-4206), so cancel osc lock now.
8263 cancel_lru_locks osc
8264 can1=$(do_facet $SINGLEMDS \
8265 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8266 awk '/ldlm_cancel/ {print $2}')
8267 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8268 awk '/ldlm_bl_callback/ {print $2}')
8269 mrename $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2
8271 can2=$(do_facet $SINGLEMDS \
8272 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8273 awk '/ldlm_cancel/ {print $2}')
8274 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8275 awk '/ldlm_bl_callback/ {print $2}')
8276 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
8277 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
8278 lru_resize_enable mdc
8279 lru_resize_enable osc
8281 run_test 120f "Early Lock Cancel: rename test"
8284 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8285 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
8286 skip "no early lock cancel on server" && return 0
8287 lru_resize_disable mdc
8288 lru_resize_disable osc
8290 echo create $count files
8291 test_mkdir -p $DIR/$tdir
8292 cancel_lru_locks mdc
8293 cancel_lru_locks osc
8296 can0=$(do_facet $SINGLEMDS \
8297 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8298 awk '/ldlm_cancel/ {print $2}')
8299 blk0=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8300 awk '/ldlm_bl_callback/ {print $2}')
8301 createmany -o $DIR/$tdir/f $count
8303 can1=$(do_facet $SINGLEMDS \
8304 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8305 awk '/ldlm_cancel/ {print $2}')
8306 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8307 awk '/ldlm_bl_callback/ {print $2}')
8309 echo total: $((can1-can0)) cancels, $((blk1-blk0)) blockings
8310 echo rm $count files
8313 can2=$(do_facet $SINGLEMDS \
8314 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8315 awk '/ldlm_cancel/ {print $2}')
8316 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8317 awk '/ldlm_bl_callback/ {print $2}')
8319 echo total: $count removes in $((t2-t1))
8320 echo total: $((can2-can1)) cancels, $((blk2-blk1)) blockings
8322 # wait for commitment of removal
8323 lru_resize_enable mdc
8324 lru_resize_enable osc
8326 run_test 120g "Early Lock Cancel: performance test"
8328 test_121() { #bug #10589
8329 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8331 writes=$(LANG=C dd if=/dev/zero of=$DIR/$tfile count=1 2>&1 | awk -F '+' '/out$/ {print $1}')
8332 #define OBD_FAIL_LDLM_CANCEL_RACE 0x310
8333 lctl set_param fail_loc=0x310
8334 cancel_lru_locks osc > /dev/null
8335 reads=$(LANG=C dd if=$DIR/$tfile of=/dev/null 2>&1 | awk -F '+' '/in$/ {print $1}')
8336 lctl set_param fail_loc=0
8337 [[ $reads -eq $writes ]] ||
8338 error "read $reads blocks, must be $writes blocks"
8340 run_test 121 "read cancel race ========="
8342 test_123a() { # was test 123, statahead(bug 11401)
8343 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8345 if [ -z "$(grep "processor.*: 1" /proc/cpuinfo)" ]; then
8346 log "testing on UP system. Performance may be not as good as expected."
8351 test_mkdir -p $DIR/$tdir
8352 NUMFREE=$(df -i -P $DIR | tail -n 1 | awk '{ print $4 }')
8353 [[ $NUMFREE -gt 100000 ]] && NUMFREE=100000 || NUMFREE=$((NUMFREE-1000))
8355 for ((i=100, j=0; i<=$NUMFREE; j=$i, i=$((i * MULT)) )); do
8356 createmany -o $DIR/$tdir/$tfile $j $((i - j))
8358 max=`lctl get_param -n llite.*.statahead_max | head -n 1`
8359 lctl set_param -n llite.*.statahead_max 0
8360 lctl get_param llite.*.statahead_max
8361 cancel_lru_locks mdc
8362 cancel_lru_locks osc
8364 time ls -l $DIR/$tdir | wc -l
8366 delta=$((etime - stime))
8367 log "ls $i files without statahead: $delta sec"
8368 lctl set_param llite.*.statahead_max=$max
8370 swrong=`lctl get_param -n llite.*.statahead_stats | grep "statahead wrong:" | awk '{print $3}'`
8371 lctl get_param -n llite.*.statahead_max | grep '[0-9]'
8372 cancel_lru_locks mdc
8373 cancel_lru_locks osc
8375 time ls -l $DIR/$tdir | wc -l
8377 delta_sa=$((etime - stime))
8378 log "ls $i files with statahead: $delta_sa sec"
8379 lctl get_param -n llite.*.statahead_stats
8380 ewrong=`lctl get_param -n llite.*.statahead_stats | grep "statahead wrong:" | awk '{print $3}'`
8382 [[ $swrong -lt $ewrong ]] &&
8383 log "statahead was stopped, maybe too many locks held!"
8384 [[ $delta -eq 0 || $delta_sa -eq 0 ]] && continue
8386 if [ $((delta_sa * 100)) -gt $((delta * 105)) -a $delta_sa -gt $((delta + 2)) ]; then
8387 max=`lctl get_param -n llite.*.statahead_max | head -n 1`
8388 lctl set_param -n llite.*.statahead_max 0
8389 lctl get_param llite.*.statahead_max
8390 cancel_lru_locks mdc
8391 cancel_lru_locks osc
8393 time ls -l $DIR/$tdir | wc -l
8395 delta=$((etime - stime))
8396 log "ls $i files again without statahead: $delta sec"
8397 lctl set_param llite.*.statahead_max=$max
8398 if [ $((delta_sa * 100)) -gt $((delta * 105)) -a $delta_sa -gt $((delta + 2)) ]; then
8399 if [ $SLOWOK -eq 0 ]; then
8400 error "ls $i files is slower with statahead!"
8402 log "ls $i files is slower with statahead!"
8408 [ $delta -gt 20 ] && break
8409 [ $delta -gt 8 ] && MULT=$((50 / delta))
8410 [ "$SLOW" = "no" -a $delta -gt 5 ] && break
8418 delta=$((etime - stime))
8419 log "rm -r $DIR/$tdir/: $delta seconds"
8421 lctl get_param -n llite.*.statahead_stats
8423 run_test 123a "verify statahead work"
8425 test_123b () { # statahead(bug 15027)
8426 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8427 test_mkdir -p $DIR/$tdir
8428 createmany -o $DIR/$tdir/$tfile-%d 1000
8430 cancel_lru_locks mdc
8431 cancel_lru_locks osc
8433 #define OBD_FAIL_MDC_GETATTR_ENQUEUE 0x803
8434 lctl set_param fail_loc=0x80000803
8435 ls -lR $DIR/$tdir > /dev/null
8437 lctl set_param fail_loc=0x0
8438 lctl get_param -n llite.*.statahead_stats
8443 run_test 123b "not panic with network error in statahead enqueue (bug 15027)"
8446 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8447 [ -z "$($LCTL get_param -n mdc.*.connect_flags | grep lru_resize)" ] &&
8448 skip "no lru resize on server" && return 0
8450 test_mkdir -p $DIR/$tdir || error "failed to create $DIR/$tdir"
8452 log "create $NR files at $DIR/$tdir"
8453 createmany -o $DIR/$tdir/f $NR ||
8454 error "failed to create $NR files in $DIR/$tdir"
8456 cancel_lru_locks mdc
8457 ls -l $DIR/$tdir > /dev/null
8461 for VALUE in $($LCTL get_param ldlm.namespaces.*mdc-*.lru_size); do
8462 local PARAM=$(echo ${VALUE[0]} | cut -d "=" -f1)
8463 LRU_SIZE=$($LCTL get_param -n $PARAM)
8464 if [[ $LRU_SIZE -gt $(default_lru_size) ]]; then
8465 NSDIR=$(echo $PARAM | cut -d "." -f1-3)
8467 log "NS=$(basename $NSDIR)"
8472 if [[ -z "$NSDIR" || $LRU_SIZE -lt $(default_lru_size) ]]; then
8473 skip "Not enough cached locks created!"
8480 # We know that lru resize allows one client to hold $LIMIT locks
8481 # for 10h. After that locks begin to be killed by client.
8483 local LIMIT=$($LCTL get_param -n $NSDIR.pool.limit)
8485 if [ $LIMIT -lt $LRU_SIZE ]; then
8486 skip "Limit is too small $LIMIT"
8490 # Make LVF so higher that sleeping for $SLEEP is enough to _start_
8491 # killing locks. Some time was spent for creating locks. This means
8492 # that up to the moment of sleep finish we must have killed some of
8493 # them (10-100 locks). This depends on how fast ther were created.
8494 # Many of them were touched in almost the same moment and thus will
8495 # be killed in groups.
8496 local LVF=$(($MAX_HRS * 60 * 60 / $SLEEP * $LIMIT / $LRU_SIZE))
8498 # Use $LRU_SIZE_B here to take into account real number of locks
8499 # created in the case of CMD, LRU_SIZE_B != $NR in most of cases
8500 local LRU_SIZE_B=$LRU_SIZE
8502 local OLD_LVF=$($LCTL get_param -n $NSDIR.pool.lock_volume_factor)
8503 log "OLD_LVF=$OLD_LVF"
8504 $LCTL set_param -n $NSDIR.pool.lock_volume_factor $LVF
8506 # Let's make sure that we really have some margin. Client checks
8507 # cached locks every 10 sec.
8509 log "Sleep ${SLEEP} sec"
8511 while ((SEC<$SLEEP)); do
8515 LRU_SIZE=$($LCTL get_param -n $NSDIR/lru_size)
8519 $LCTL set_param -n $NSDIR.pool.lock_volume_factor $OLD_LVF
8520 local LRU_SIZE_A=$($LCTL get_param -n $NSDIR.lru_size)
8522 [[ $LRU_SIZE_B -gt $LRU_SIZE_A ]] || {
8523 error "No locks dropped in ${SLEEP}s. LRU size: $LRU_SIZE_A"
8524 unlinkmany $DIR/$tdir/f $NR
8528 log "Dropped "$((LRU_SIZE_B-LRU_SIZE_A))" locks in ${SLEEP}s"
8529 log "unlink $NR files at $DIR/$tdir"
8530 unlinkmany $DIR/$tdir/f $NR
8532 run_test 124a "lru resize ======================================="
8534 get_max_pool_limit()
8536 local limit=$($LCTL get_param \
8537 -n ldlm.namespaces.*-MDT0000-mdc-*.pool.limit)
8540 if [[ $l -gt $max ]]; then
8548 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8549 [ -z "$($LCTL get_param -n mdc.*.connect_flags | grep lru_resize)" ] &&
8550 skip "no lru resize on server" && return 0
8552 LIMIT=$(get_max_pool_limit)
8554 NR=$(($(default_lru_size)*20))
8555 if [[ $NR -gt $LIMIT ]]; then
8556 log "Limit lock number by $LIMIT locks"
8559 lru_resize_disable mdc
8560 test_mkdir -p $DIR/$tdir/disable_lru_resize ||
8561 error "failed to create $DIR/$tdir/disable_lru_resize"
8563 createmany -o $DIR/$tdir/disable_lru_resize/f $NR
8564 log "doing ls -la $DIR/$tdir/disable_lru_resize 3 times"
8565 cancel_lru_locks mdc
8568 ls -la $DIR/$tdir/disable_lru_resize > /dev/null &
8571 ls -la $DIR/$tdir/disable_lru_resize > /dev/null &
8574 ls -la $DIR/$tdir/disable_lru_resize > /dev/null &
8578 nolruresize_delta=$((etime-stime))
8579 log "ls -la time: $nolruresize_delta seconds"
8580 log "lru_size = $(lctl get_param -n ldlm.namespaces.*mdc*.lru_size)"
8581 unlinkmany $DIR/$tdir/disable_lru_resize/f $NR
8583 lru_resize_enable mdc
8584 test_mkdir -p $DIR/$tdir/enable_lru_resize ||
8585 error "failed to create $DIR/$tdir/enable_lru_resize"
8587 createmany -o $DIR/$tdir/enable_lru_resize/f $NR
8588 log "doing ls -la $DIR/$tdir/enable_lru_resize 3 times"
8589 cancel_lru_locks mdc
8592 ls -la $DIR/$tdir/enable_lru_resize > /dev/null &
8595 ls -la $DIR/$tdir/enable_lru_resize > /dev/null &
8598 ls -la $DIR/$tdir/enable_lru_resize > /dev/null &
8602 lruresize_delta=$((etime-stime))
8603 log "ls -la time: $lruresize_delta seconds"
8604 log "lru_size = $(lctl get_param -n ldlm.namespaces.*mdc*.lru_size)"
8606 if [ $lruresize_delta -gt $nolruresize_delta ]; then
8607 log "ls -la is $(((lruresize_delta - $nolruresize_delta) * 100 / $nolruresize_delta))% slower with lru resize enabled"
8608 elif [ $nolruresize_delta -gt $lruresize_delta ]; then
8609 log "ls -la is $(((nolruresize_delta - $lruresize_delta) * 100 / $nolruresize_delta))% faster with lru resize enabled"
8611 log "lru resize performs the same with no lru resize"
8613 unlinkmany $DIR/$tdir/enable_lru_resize/f $NR
8615 run_test 124b "lru resize (performance test) ======================="
8618 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8619 [ -z "$($LCTL get_param -n mdc.*.connect_flags | grep lru_resize)" ] &&
8620 skip "no lru resize on server" && return 0
8622 # cache ununsed locks on client
8624 cancel_lru_locks mdc
8625 test_mkdir -p $DIR/$tdir || error "failed to create $DIR/$tdir"
8626 createmany -o $DIR/$tdir/f $nr ||
8627 error "failed to create $nr files in $DIR/$tdir"
8628 ls -l $DIR/$tdir > /dev/null
8630 local nsdir="ldlm.namespaces.*-MDT0000-mdc-*"
8631 local unused=$($LCTL get_param -n $nsdir.lock_unused_count)
8632 local max_age=$($LCTL get_param -n $nsdir.lru_max_age)
8633 local recalc_p=$($LCTL get_param -n $nsdir.pool.recalc_period)
8634 echo "unused=$unused, max_age=$max_age, recalc_p=$recalc_p"
8636 # set lru_max_age to 1 sec
8637 $LCTL set_param $nsdir.lru_max_age=1000 # jiffies
8638 echo "sleep $((recalc_p * 2)) seconds..."
8639 sleep $((recalc_p * 2))
8641 local remaining=$($LCTL get_param -n $nsdir.lock_unused_count)
8642 # restore lru_max_age
8643 $LCTL set_param -n $nsdir.lru_max_age $max_age
8644 [ $remaining -eq 0 ] || error "$remaining locks are not canceled"
8645 unlinkmany $DIR/$tdir/f $nr
8647 run_test 124c "LRUR cancel very aged locks"
8649 test_125() { # 13358
8650 [ -z "$(lctl get_param -n llite.*.client_type | grep local)" ] && skip "must run as local client" && return
8651 [ -z "$(lctl get_param -n mdc.*-mdc-*.connect_flags | grep acl)" ] && skip "must have acl enabled" && return
8652 [ -z "$(which setfacl)" ] && skip "must have setfacl tool" && return
8653 test_mkdir -p $DIR/d125 || error "mkdir failed"
8654 $SETSTRIPE -S 65536 -c -1 $DIR/d125 || error "setstripe failed"
8655 setfacl -R -m u:bin:rwx $DIR/d125 || error "setfacl $DIR/d125 failed"
8656 ls -ld $DIR/d125 || error "cannot access $DIR/d125"
8658 run_test 125 "don't return EPROTO when a dir has a non-default striping and ACLs"
8660 test_126() { # bug 12829/13455
8661 [ -z "$(lctl get_param -n llite.*.client_type | grep local)" ] && skip "must run as local client" && return
8662 [ "$UID" != 0 ] && skip_env "skipping $TESTNAME (must run as root)" && return
8663 $GSS && skip "must run as gss disabled" && return
8665 $RUNAS -u 0 -g 1 touch $DIR/$tfile || error "touch failed"
8666 gid=`ls -n $DIR/$tfile | awk '{print $4}'`
8668 [ $gid -eq "1" ] || error "gid is set to" $gid "instead of 1"
8670 run_test 126 "check that the fsgid provided by the client is taken into account"
8672 test_127a() { # bug 15521
8673 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8674 $SETSTRIPE -i 0 -c 1 $DIR/$tfile || error "setstripe failed"
8675 $LCTL set_param osc.*.stats=0
8676 FSIZE=$((2048 * 1024))
8677 dd if=/dev/zero of=$DIR/$tfile bs=$FSIZE count=1
8678 cancel_lru_locks osc
8679 dd if=$DIR/$tfile of=/dev/null bs=$FSIZE
8681 $LCTL get_param osc.*0000-osc-*.stats | grep samples > $DIR/${tfile}.tmp
8682 while read NAME COUNT SAMP UNIT MIN MAX SUM SUMSQ; do
8683 echo "got $COUNT $NAME"
8684 [ ! $MIN ] && error "Missing min value for $NAME proc entry"
8685 eval $NAME=$COUNT || error "Wrong proc format"
8688 read_bytes|write_bytes)
8689 [ $MIN -lt 4096 ] && error "min is too small: $MIN"
8690 [ $MIN -gt $FSIZE ] && error "min is too big: $MIN"
8691 [ $MAX -lt 4096 ] && error "max is too small: $MAX"
8692 [ $MAX -gt $FSIZE ] && error "max is too big: $MAX"
8693 [ $SUM -ne $FSIZE ] && error "sum is wrong: $SUM"
8694 [ $SUMSQ -lt $(((FSIZE /4096) * (4096 * 4096))) ] &&
8695 error "sumsquare is too small: $SUMSQ"
8696 [ $SUMSQ -gt $((FSIZE * FSIZE)) ] &&
8697 error "sumsquare is too big: $SUMSQ"
8701 done < $DIR/${tfile}.tmp
8703 #check that we actually got some stats
8704 [ "$read_bytes" ] || error "Missing read_bytes stats"
8705 [ "$write_bytes" ] || error "Missing write_bytes stats"
8706 [ "$read_bytes" != 0 ] || error "no read done"
8707 [ "$write_bytes" != 0 ] || error "no write done"
8709 run_test 127a "verify the client stats are sane"
8711 test_127b() { # bug LU-333
8712 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8713 $LCTL set_param llite.*.stats=0
8714 FSIZE=65536 # sized fixed to match PAGE_SIZE for most clients
8715 # perform 2 reads and writes so MAX is different from SUM.
8716 dd if=/dev/zero of=$DIR/$tfile bs=$FSIZE count=1
8717 dd if=/dev/zero of=$DIR/$tfile bs=$FSIZE count=1
8718 cancel_lru_locks osc
8719 dd if=$DIR/$tfile of=/dev/null bs=$FSIZE count=1
8720 dd if=$DIR/$tfile of=/dev/null bs=$FSIZE count=1
8722 $LCTL get_param llite.*.stats | grep samples > $TMP/${tfile}.tmp
8723 while read NAME COUNT SAMP UNIT MIN MAX SUM SUMSQ; do
8724 echo "got $COUNT $NAME"
8725 eval $NAME=$COUNT || error "Wrong proc format"
8729 [ $COUNT -ne 2 ] && error "count is not 2: $COUNT"
8730 [ $MIN -ne $FSIZE ] && error "min is not $FSIZE: $MIN"
8731 [ $MAX -ne $FSIZE ] && error "max is incorrect: $MAX"
8732 [ $SUM -ne $((FSIZE * 2)) ] && error "sum is wrong: $SUM"
8735 [ $COUNT -ne 2 ] && error "count is not 2: $COUNT"
8736 [ $MIN -ne $FSIZE ] && error "min is not $FSIZE: $MIN"
8737 [ $MAX -ne $FSIZE ] && error "max is incorrect: $MAX"
8738 [ $SUM -ne $((FSIZE * 2)) ] && error "sum is wrong: $SUM"
8742 done < $TMP/${tfile}.tmp
8744 #check that we actually got some stats
8745 [ "$read_bytes" ] || error "Missing read_bytes stats"
8746 [ "$write_bytes" ] || error "Missing write_bytes stats"
8747 [ "$read_bytes" != 0 ] || error "no read done"
8748 [ "$write_bytes" != 0 ] || error "no write done"
8750 run_test 127b "verify the llite client stats are sane"
8752 test_128() { # bug 15212
8754 $LFS 2>&1 <<-EOF | tee $TMP/$tfile.log
8759 result=$(grep error $TMP/$tfile.log)
8761 [ -z "$result" ] || error "consecutive find's under interactive lfs failed"
8763 run_test 128 "interactive lfs for 2 consecutive find's"
8770 local LDPROC=/proc/fs/ldiskfs
8771 local facets=$(get_facets MDS)
8773 for facet in ${facets//,/ }; do
8774 canondev=$(ldiskfs_canon \
8775 *.$(convert_facet2label $facet).mntdev $facet)
8776 do_facet $facet "test -e $LDPROC/$canondev/max_dir_size" ||
8777 LDPROC=/sys/fs/ldiskfs
8778 do_facet $facet "echo $1 >$LDPROC/$canondev/max_dir_size"
8779 do_facet $facet "test -e $LDPROC/$canondev/warning_dir_size" ||
8780 LDPROC=/sys/fs/ldiskfs
8781 do_facet $facet "echo $2 >$LDPROC/$canondev/warning_dir_size"
8786 local facets=$(get_facets MDS)
8787 for facet in ${facets//,/ }; do
8788 do_facet $facet "dmesg | tail -3 | grep -q $1" && return 0
8794 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8795 if [ "$(facet_fstype $SINGLEMDS)" != ldiskfs ]; then
8796 skip "Only applicable to ldiskfs-based MDTs"
8799 remote_mds_nodsh && skip "remote MDS with nodsh" && return
8807 # block size of mds1
8808 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
8809 local MDSBLOCKSIZE=$($LCTL get_param -n mdc.*MDT0000*.blocksize)
8810 local MAX=$((MDSBLOCKSIZE * 5))
8811 set_dir_limits $MAX $MAX
8812 local I=$(stat -c%s "$DIR/$tdir")
8814 while [[ $I -le $MAX ]]; do
8815 $MULTIOP $DIR/$tdir/$J Oc
8817 if [ $has_warning -eq 0 ]; then
8818 check_mds_dmesg '"is approaching"' &&
8821 #check two errors ENOSPC for new version of ext4 max_dir_size patch
8822 #mainline kernel commit df981d03eeff7971ac7e6ff37000bfa702327ef1
8823 #and EFBIG for previous versions
8824 if [ $rc -eq $EFBIG -o $rc -eq $ENOSPC ]; then
8826 echo "return code $rc received as expected"
8828 createmany -o $DIR/$tdir/$J_file_ 1000 ||
8829 error_exit "create failed w/o dir size limit"
8831 check_mds_dmesg '"has reached"' ||
8832 error_exit "has reached message should be output"
8835 error_exit "warning message should be output"
8837 I=$(stat -c%s "$DIR/$tdir")
8839 if [ $(lustre_version_code $SINGLEMDS) -lt \
8840 $(version_code 2.4.51) ]
8842 [[ $I -eq $MAX ]] && return 0
8844 [[ $I -gt $MAX ]] && return 0
8846 error_exit "current dir size $I, previous limit $MAX"
8847 elif [ $rc -ne 0 ]; then
8849 error_exit "return code $rc received instead of expected " \
8850 "$EFBIG or $ENOSPC, files in dir $I"
8853 I=$(stat -c%s "$DIR/$tdir")
8857 error "exceeded dir size limit $MAX($MDSCOUNT) : $I bytes"
8859 run_test 129 "test directory size limit ========================"
8868 local filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
8869 [ -n "$filefrag_op" ] && skip_env "filefrag does not support FIEMAP" &&
8872 trap cleanup_130 EXIT RETURN
8874 local fm_file=$DIR/$tfile
8875 $SETSTRIPE -S 65536 -c 1 $fm_file || error "setstripe on $fm_file"
8876 dd if=/dev/zero of=$fm_file bs=65536 count=1 ||
8877 error "dd failed for $fm_file"
8879 # LU-1795: test filefrag/FIEMAP once, even if unsupported
8880 filefrag -ves $fm_file
8882 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
8883 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
8884 [ $RC != 0 ] && error "filefrag $fm_file failed"
8886 filefrag_op=$(filefrag -ve $fm_file |
8887 sed -n '/ext:/,/found/{/ext:/d; /found/d; p}')
8888 lun=$($GETSTRIPE -i $fm_file)
8890 start_blk=`echo $filefrag_op | cut -d: -f2 | cut -d. -f1`
8893 for line in $filefrag_op
8895 frag_lun=`echo $line | cut -d: -f5`
8896 ext_len=`echo $line | cut -d: -f4`
8897 if (( $frag_lun != $lun )); then
8899 error "FIEMAP on 1-stripe file($fm_file) failed"
8902 (( tot_len += ext_len ))
8905 if (( lun != frag_lun || start_blk != 0 || tot_len != 64 )); then
8907 error "FIEMAP on 1-stripe file($fm_file) failed;"
8913 echo "FIEMAP on single striped file succeeded"
8915 run_test 130a "FIEMAP (1-stripe file)"
8918 [ "$OSTCOUNT" -lt "2" ] &&
8919 skip_env "skipping FIEMAP on $OSTCOUNT-stripe file" && return
8921 local filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
8922 [ -n "$filefrag_op" ] && skip_env "filefrag does not support FIEMAP" &&
8925 trap cleanup_130 EXIT RETURN
8927 local fm_file=$DIR/$tfile
8928 $SETSTRIPE -S 65536 -c $OSTCOUNT $fm_file ||
8929 error "setstripe on $fm_file"
8930 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
8931 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
8933 dd if=/dev/zero of=$fm_file bs=1M count=$OSTCOUNT ||
8934 error "dd failed on $fm_file"
8936 filefrag -ves $fm_file || error "filefrag $fm_file failed"
8937 filefrag_op=$(filefrag -ve $fm_file |
8938 sed -n '/ext:/,/found/{/ext:/d; /found/d; p}')
8940 last_lun=$(echo $filefrag_op | cut -d: -f5 |
8941 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
8946 for line in $filefrag_op
8948 frag_lun=$(echo $line | cut -d: -f5 |
8949 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
8950 ext_len=$(echo $line | cut -d: -f4)
8951 if (( $frag_lun != $last_lun )); then
8952 if (( tot_len != 1024 )); then
8954 error "FIEMAP on $fm_file failed; returned " \
8955 "len $tot_len for OST $last_lun instead of 1024"
8962 (( tot_len += ext_len ))
8965 if (( num_luns != $OSTCOUNT || tot_len != 1024 )); then
8967 error "FIEMAP on $fm_file failed; returned wrong number of " \
8968 "luns or wrong len for OST $last_lun"
8974 echo "FIEMAP on $OSTCOUNT-stripe file succeeded"
8976 run_test 130b "FIEMAP ($OSTCOUNT-stripe file)"
8979 [ "$OSTCOUNT" -lt "2" ] &&
8980 skip_env "skipping FIEMAP on 2-stripe file" && return
8982 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
8983 [ -n "$filefrag_op" ] && skip "filefrag does not support FIEMAP" &&
8986 trap cleanup_130 EXIT RETURN
8988 local fm_file=$DIR/$tfile
8989 $SETSTRIPE -S 65536 -c 2 $fm_file || error "setstripe on $fm_file"
8990 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
8991 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
8993 dd if=/dev/zero of=$fm_file seek=1 bs=1M count=1 ||
8994 error "dd failed on $fm_file"
8996 filefrag -ves $fm_file || error "filefrag $fm_file failed"
8997 filefrag_op=$(filefrag -ve $fm_file |
8998 sed -n '/ext:/,/found/{/ext:/d; /found/d; p}')
9000 last_lun=$(echo $filefrag_op | cut -d: -f5 |
9001 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
9006 for line in $filefrag_op
9008 frag_lun=$(echo $line | cut -d: -f5 |
9009 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
9010 ext_len=$(echo $line | cut -d: -f4)
9011 if (( $frag_lun != $last_lun )); then
9012 logical=`echo $line | cut -d: -f2 | cut -d. -f1`
9013 if (( logical != 512 )); then
9015 error "FIEMAP on $fm_file failed; returned " \
9016 "logical start for lun $logical instead of 512"
9019 if (( tot_len != 512 )); then
9021 error "FIEMAP on $fm_file failed; returned " \
9022 "len $tot_len for OST $last_lun instead of 1024"
9029 (( tot_len += ext_len ))
9032 if (( num_luns != 2 || tot_len != 512 )); then
9034 error "FIEMAP on $fm_file failed; returned wrong number of " \
9035 "luns or wrong len for OST $last_lun"
9041 echo "FIEMAP on 2-stripe file with hole succeeded"
9043 run_test 130c "FIEMAP (2-stripe file with hole)"
9046 [ "$OSTCOUNT" -lt "3" ] &&
9047 skip_env "skipping FIEMAP on N-stripe file test" && return
9049 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
9050 [ -n "$filefrag_op" ] && skip "filefrag does not support FIEMAP" &&
9053 trap cleanup_130 EXIT RETURN
9055 local fm_file=$DIR/$tfile
9056 $SETSTRIPE -S 65536 -c $OSTCOUNT $fm_file ||
9057 error "setstripe on $fm_file"
9058 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
9059 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
9061 local actual_stripecnt=$($GETSTRIPE -c $fm_file)
9062 dd if=/dev/zero of=$fm_file bs=1M count=$actual_stripecnt ||
9063 error "dd failed on $fm_file"
9065 filefrag -ves $fm_file || error "filefrag $fm_file failed"
9066 filefrag_op=$(filefrag -ve $fm_file |
9067 sed -n '/ext:/,/found/{/ext:/d; /found/d; p}')
9069 last_lun=$(echo $filefrag_op | cut -d: -f5 |
9070 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
9075 for line in $filefrag_op
9077 frag_lun=$(echo $line | cut -d: -f5 |
9078 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
9079 ext_len=$(echo $line | cut -d: -f4)
9080 if (( $frag_lun != $last_lun )); then
9081 if (( tot_len != 1024 )); then
9083 error "FIEMAP on $fm_file failed; returned " \
9084 "len $tot_len for OST $last_lun instead of 1024"
9091 (( tot_len += ext_len ))
9094 if (( num_luns != actual_stripecnt || tot_len != 1024 )); then
9096 error "FIEMAP on $fm_file failed; returned wrong number of " \
9097 "luns or wrong len for OST $last_lun"
9103 echo "FIEMAP on N-stripe file succeeded"
9105 run_test 130d "FIEMAP (N-stripe file)"
9108 [ "$OSTCOUNT" -lt "2" ] &&
9109 skip_env "skipping continuation FIEMAP test" && return
9111 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
9112 [ -n "$filefrag_op" ] && skip "filefrag does not support FIEMAP" && return
9114 trap cleanup_130 EXIT RETURN
9116 local fm_file=$DIR/$tfile
9117 $SETSTRIPE -S 131072 -c 2 $fm_file || error "setstripe on $fm_file"
9118 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
9119 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
9122 EXPECTED_LEN=$(( (NUM_BLKS / 2) * 64 ))
9123 for ((i = 0; i < $NUM_BLKS; i++))
9125 dd if=/dev/zero of=$fm_file count=1 bs=64k seek=$((2*$i)) conv=notrunc > /dev/null 2>&1
9128 filefrag -ves $fm_file || error "filefrag $fm_file failed"
9129 filefrag_op=$(filefrag -ve $fm_file |
9130 sed -n '/ext:/,/found/{/ext:/d; /found/d; p}')
9132 last_lun=$(echo $filefrag_op | cut -d: -f5 |
9133 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
9138 for line in $filefrag_op
9140 frag_lun=$(echo $line | cut -d: -f5 |
9141 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
9142 ext_len=$(echo $line | cut -d: -f4)
9143 if (( $frag_lun != $last_lun )); then
9144 if (( tot_len != $EXPECTED_LEN )); then
9146 error "FIEMAP on $fm_file failed; returned " \
9147 "len $tot_len for OST $last_lun instead " \
9155 (( tot_len += ext_len ))
9158 if (( num_luns != 2 || tot_len != $EXPECTED_LEN )); then
9160 error "FIEMAP on $fm_file failed; returned wrong number " \
9161 "of luns or wrong len for OST $last_lun"
9167 echo "FIEMAP with continuation calls succeeded"
9169 run_test 130e "FIEMAP (test continuation FIEMAP calls)"
9171 # Test for writev/readv
9173 rwv -f $DIR/$tfile -w -n 3 524288 1048576 1572864 || \
9174 error "writev test failed"
9175 rwv -f $DIR/$tfile -r -v -n 2 1572864 1048576 || \
9176 error "readv failed"
9179 run_test 131a "test iov's crossing stripe boundary for writev/readv"
9182 rwv -f $DIR/$tfile -w -a -n 3 524288 1048576 1572864 || \
9183 error "append writev test failed"
9184 rwv -f $DIR/$tfile -w -a -n 2 1572864 1048576 || \
9185 error "append writev test failed"
9188 run_test 131b "test append writev"
9191 rwv -f $DIR/$tfile -w -d -n 1 1048576 || return 0
9194 run_test 131c "test read/write on file w/o objects"
9197 rwv -f $DIR/$tfile -w -n 1 1572864
9198 NOB=`rwv -f $DIR/$tfile -r -n 3 524288 524288 1048576 | awk '/error/ {print $6}'`
9199 if [ "$NOB" != 1572864 ]; then
9200 error "Short read filed: read $NOB bytes instead of 1572864"
9204 run_test 131d "test short read"
9207 rwv -f $DIR/$tfile -w -s 1048576 -n 1 1048576
9208 rwv -f $DIR/$tfile -r -z -s 0 -n 1 524288 || \
9209 error "read hitting hole failed"
9212 run_test 131e "test read hitting hole"
9218 $SINGLEMDS) res=`do_facet $SINGLEMDS $LCTL get_param mdt.$FSNAME-MDT0000.md_stats | grep "$2"`
9220 ost) res=`do_facet ost1 $LCTL get_param obdfilter.$FSNAME-OST0000.stats | grep "$2"`
9222 *) error "Wrong argument $1" ;;
9225 [ -z "$res" ] && error "The counter for $2 on $1 was not incremented"
9226 # if the argument $3 is zero, it means any stat increment is ok.
9227 if [[ $3 -gt 0 ]]; then
9228 count=$(echo $res | awk '{ print $2 }')
9229 [[ $count -ne $3 ]] &&
9230 error "The $2 counter on $1 is wrong - expected $3"
9235 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9236 remote_ost_nodsh && skip "remote OST with nodsh" && return
9237 remote_mds_nodsh && skip "remote MDS with nodsh" && return
9239 do_facet $SINGLEMDS $LCTL list_param mdt.*.rename_stats ||
9240 { skip "MDS doesn't support rename stats"; return; }
9241 local testdir=$DIR/${tdir}/stats_testdir
9242 mkdir -p $DIR/${tdir}
9245 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
9246 do_facet ost1 $LCTL set_param obdfilter.*.stats=clear
9248 # verify mdt stats first.
9249 mkdir ${testdir} || error "mkdir failed"
9250 check_stats $SINGLEMDS "mkdir" 1
9251 touch ${testdir}/${tfile} || "touch failed"
9252 check_stats $SINGLEMDS "open" 1
9253 check_stats $SINGLEMDS "close" 1
9254 mknod ${testdir}/${tfile}-pipe p || "mknod failed"
9255 check_stats $SINGLEMDS "mknod" 1
9256 rm -f ${testdir}/${tfile}-pipe || "pipe remove failed"
9257 check_stats $SINGLEMDS "unlink" 1
9258 rm -f ${testdir}/${tfile} || error "file remove failed"
9259 check_stats $SINGLEMDS "unlink" 2
9261 # remove working dir and check mdt stats again.
9262 rmdir ${testdir} || error "rmdir failed"
9263 check_stats $SINGLEMDS "rmdir" 1
9265 local testdir1=$DIR/${tdir}/stats_testdir1
9267 mkdir -p ${testdir1}
9268 touch ${testdir1}/test1
9269 mv ${testdir1}/test1 ${testdir} || error "file crossdir rename"
9270 check_stats $SINGLEMDS "crossdir_rename" 1
9272 mv ${testdir}/test1 ${testdir}/test0 || error "file samedir rename"
9273 check_stats $SINGLEMDS "samedir_rename" 1
9277 run_test 133a "Verifying MDT stats ========================================"
9280 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9281 remote_ost_nodsh && skip "remote OST with nodsh" && return
9282 remote_mds_nodsh && skip "remote MDS with nodsh" && return
9283 local testdir=$DIR/${tdir}/stats_testdir
9284 mkdir -p ${testdir} || error "mkdir failed"
9285 touch ${testdir}/${tfile} || "touch failed"
9286 cancel_lru_locks mdc
9289 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
9290 do_facet ost1 $LCTL set_param obdfilter.*.stats=clear
9292 # extra mdt stats verification.
9293 chmod 444 ${testdir}/${tfile} || error "chmod failed"
9294 check_stats $SINGLEMDS "setattr" 1
9295 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
9296 if [ $(lustre_version_code $SINGLEMDS) -ne $(version_code 2.2.0) ]
9298 ls -l ${testdir}/${tfile} > /dev/null|| error "ls failed"
9299 check_stats $SINGLEMDS "getattr" 1
9301 $LFS df || error "lfs failed"
9302 check_stats $SINGLEMDS "statfs" 1
9306 run_test 133b "Verifying extra MDT stats =================================="
9309 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9310 remote_ost_nodsh && skip "remote OST with nodsh" && return
9311 remote_mds_nodsh && skip "remote MDS with nodsh" && return
9312 local testdir=$DIR/${tdir}/stats_testdir
9313 test_mkdir -p ${testdir} || error "mkdir failed"
9315 # verify obdfilter stats.
9316 $SETSTRIPE -c 1 -i 0 ${testdir}/${tfile}
9318 cancel_lru_locks osc
9319 wait_delete_completed
9322 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
9323 do_facet ost1 $LCTL set_param obdfilter.*.stats=clear
9325 dd if=/dev/zero of=${testdir}/${tfile} conv=notrunc bs=512k count=1 || error "dd failed"
9327 cancel_lru_locks osc
9328 check_stats ost "write" 1
9330 dd if=${testdir}/${tfile} of=/dev/null bs=1k count=1 || error "dd failed"
9331 check_stats ost "read" 1
9333 > ${testdir}/${tfile} || error "truncate failed"
9334 check_stats ost "punch" 1
9336 rm -f ${testdir}/${tfile} || error "file remove failed"
9337 wait_delete_completed
9338 check_stats ost "destroy" 1
9342 run_test 133c "Verifying OST stats ========================================"
9349 while [ $value -ge 2 ]; do
9354 if [ $orig -gt $order ]; then
9362 local size=('K' 'M' 'G' 'T');
9364 local size_string=$value
9366 while [ $value -ge 1024 ]; do
9367 if [ $i -gt 3 ]; then
9368 #T is the biggest unit we get here, if that is bigger,
9370 size_string=${value}T
9373 value=$((value >> 10))
9374 if [ $value -lt 1024 ]; then
9375 size_string=${value}${size[$i]}
9386 local context=${2:-.}
9387 local sample=$(do_facet $SINGLEMDS $LCTL get_param mdt.*.rename_stats |
9389 awk '/ '${size}'/ {print $4}' | sed -e "s/,//g")
9394 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9395 remote_ost_nodsh && skip "remote OST with nodsh" && return
9396 remote_mds_nodsh && skip "remote MDS with nodsh" && return
9397 do_facet $SINGLEMDS $LCTL list_param mdt.*.rename_stats ||
9398 { skip "MDS doesn't support rename stats"; return; }
9400 local testdir1=$DIR/${tdir}/stats_testdir1
9401 local testdir2=$DIR/${tdir}/stats_testdir2
9403 do_facet $SINGLEMDS $LCTL set_param mdt.*.rename_stats=clear
9405 mkdir -p ${testdir1} || error "mkdir failed"
9406 mkdir -p ${testdir2} || error "mkdir failed"
9408 createmany -o $testdir1/test 512 || error "createmany failed"
9410 # check samedir rename size
9411 mv ${testdir1}/test0 ${testdir1}/test_0
9413 local testdir1_size=$(ls -l $DIR/${tdir} |
9414 awk '/stats_testdir1/ {print $5}')
9415 local testdir2_size=$(ls -l $DIR/${tdir} |
9416 awk '/stats_testdir2/ {print $5}')
9418 testdir1_size=$(order_2 $testdir1_size)
9419 testdir2_size=$(order_2 $testdir2_size)
9421 testdir1_size=$(size_in_KMGT $testdir1_size)
9422 testdir2_size=$(size_in_KMGT $testdir2_size)
9424 echo "source rename dir size: ${testdir1_size}"
9425 echo "target rename dir size: ${testdir2_size}"
9427 local cmd="do_facet $SINGLEMDS $LCTL get_param mdt.*.rename_stats"
9428 eval $cmd || error "$cmd failed"
9429 local samedir=$($cmd | grep 'same_dir')
9430 local same_sample=$(get_rename_size $testdir1_size)
9431 [ -z "$samedir" ] && error "samedir_rename_size count error"
9432 [[ $same_sample -eq 1 ]] ||
9433 error "samedir_rename_size error $same_sample"
9434 echo "Check same dir rename stats success"
9436 do_facet $SINGLEMDS $LCTL set_param mdt.*.rename_stats=clear
9438 # check crossdir rename size
9439 mv ${testdir1}/test_0 ${testdir2}/test_0
9441 testdir1_size=$(ls -l $DIR/${tdir} |
9442 awk '/stats_testdir1/ {print $5}')
9443 testdir2_size=$(ls -l $DIR/${tdir} |
9444 awk '/stats_testdir2/ {print $5}')
9446 testdir1_size=$(order_2 $testdir1_size)
9447 testdir2_size=$(order_2 $testdir2_size)
9449 testdir1_size=$(size_in_KMGT $testdir1_size)
9450 testdir2_size=$(size_in_KMGT $testdir2_size)
9452 echo "source rename dir size: ${testdir1_size}"
9453 echo "target rename dir size: ${testdir2_size}"
9455 eval $cmd || error "$cmd failed"
9456 local crossdir=$($cmd | grep 'crossdir')
9457 local src_sample=$(get_rename_size $testdir1_size crossdir_src)
9458 local tgt_sample=$(get_rename_size $testdir2_size crossdir_tgt)
9459 [ -z "$crossdir" ] && error "crossdir_rename_size count error"
9460 [[ $src_sample -eq 1 ]] ||
9461 error "crossdir_rename_size error $src_sample"
9462 [[ $tgt_sample -eq 1 ]] ||
9463 error "crossdir_rename_size error $tgt_sample"
9464 echo "Check cross dir rename stats success"
9467 run_test 133d "Verifying rename_stats ========================================"
9470 remote_mds_nodsh && skip "remote MDS with nodsh" && return
9471 remote_ost_nodsh && skip "remote OST with nodsh" && return
9472 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9473 local testdir=$DIR/${tdir}/stats_testdir
9474 local ctr f0 f1 bs=32768 count=42 sum
9476 mkdir -p ${testdir} || error "mkdir failed"
9478 $SETSTRIPE -c 1 -i 0 ${testdir}/${tfile}
9480 for ctr in {write,read}_bytes; do
9482 cancel_lru_locks osc
9484 do_facet ost1 $LCTL set_param -n \
9485 "obdfilter.*.exports.clear=clear"
9487 if [ $ctr = write_bytes ]; then
9489 f1=${testdir}/${tfile}
9491 f0=${testdir}/${tfile}
9495 dd if=$f0 of=$f1 conv=notrunc bs=$bs count=$count || \
9498 cancel_lru_locks osc
9500 sum=$(do_facet ost1 $LCTL get_param \
9501 "obdfilter.*.exports.*.stats" |
9502 awk -v ctr=$ctr 'BEGIN { sum = 0 }
9503 $1 == ctr { sum += $7 }
9504 END { printf("%0.0f", sum) }')
9506 if ((sum != bs * count)); then
9507 error "Bad $ctr sum, expected $((bs * count)), got $sum"
9513 run_test 133e "Verifying OST {read,write}_bytes nid stats ================="
9516 for dir in /proc/fs/lustre/ /proc/sys/lnet/ /proc/sys/lustre/ \
9517 /sys/fs/lustre/ /sys/fs/lnet/ /sys/kernel/debug/lnet/ \
9518 /sys/kernel/debug/lustre/; do
9519 [[ -d $dir ]] && proc_dirs+=" $dir"
9523 remote_mds_nodsh && skip "remote MDS with nodsh" && return
9524 remote_ost_nodsh && skip "remote OST with nodsh" && return
9525 # First without trusting modes.
9526 find $proc_dirs -exec cat '{}' \; &> /dev/null
9528 # Second verifying readability.
9529 $LCTL get_param -R '*' &> /dev/null || error "proc file read failed"
9531 # eventually, this can also be replaced with "lctl get_param -R",
9532 # but not until that option is always available on the server
9534 for facet in $SINGLEMDS ost1; do
9535 do_facet $facet find $proc_dirs \
9536 ! -name req_history \
9537 -exec cat '{}' \\\; &> /dev/null
9539 do_facet $facet find $proc_dirs \
9540 ! -name req_history \
9542 -exec cat '{}' \\\; &> /dev/null ||
9543 error "proc file read failed"
9546 run_test 133f "Check for LBUGs/Oopses/unreadable files in /proc"
9549 # Second verifying writability.
9552 -not -name force_lbug \
9553 -not -name changelog_mask \
9554 -exec badarea_io '{}' \; &> /dev/null ||
9555 error "find $proc_dirs failed"
9557 [ $(lustre_version_code $SINGLEMDS) -le $(version_code 2.5.54) ] &&
9558 skip "Too old lustre on MDS" && return
9560 [ $(lustre_version_code ost1) -le $(version_code 2.5.54) ] &&
9561 skip "Too old lustre on ost1" && return
9564 for facet in $SINGLEMDS ost1; do
9565 do_facet $facet find $proc_dirs \
9567 -not -name force_lbug \
9568 -not -name changelog_mask \
9569 -exec badarea_io '{}' \\\; &> /dev/null ||
9570 error "$facet find $proc_dirs failed"
9574 # remount the FS in case writes/reads /proc break the FS
9575 cleanup || error "failed to unmount"
9576 setup || error "failed to setup"
9579 run_test 133g "Check for Oopses on bad io area writes/reads in /proc"
9582 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.54) ]] &&
9583 skip "Need MDS version at least 2.7.54" && return
9585 mkdir -p $DIR/$tdir || error "failed to create $DIR/$tdir"
9586 cancel_lru_locks mdc
9588 local nsdir="ldlm.namespaces.*-MDT0000-mdc-*"
9589 local unused=$($LCTL get_param -n $nsdir.lock_unused_count)
9590 [ $unused -eq 0 ] || "$unused locks are not cleared"
9593 createmany -o $DIR/$tdir/f $nr ||
9594 error "failed to create $nr files in $DIR/$tdir"
9595 unused=$($LCTL get_param -n $nsdir.lock_unused_count)
9597 #define OBD_FAIL_LDLM_WATERMARK_LOW 0x327
9598 do_facet mds1 $LCTL set_param fail_loc=0x327
9599 do_facet mds1 $LCTL set_param fail_val=500
9602 echo "sleep 10 seconds ..."
9604 local lck_cnt=$($LCTL get_param -n $nsdir.lock_unused_count)
9606 do_facet mds1 $LCTL set_param fail_loc=0
9607 do_facet mds1 $LCTL set_param fail_val=0
9608 [ $lck_cnt -lt $unused ] ||
9609 error "No locks reclaimed, before:$unused, after:$lck_cnt"
9612 unlinkmany $DIR/$tdir/f $nr
9614 run_test 134a "Server reclaims locks when reaching lock_reclaim_threshold"
9617 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.54) ]] &&
9618 skip "Need MDS version at least 2.7.54" && return
9620 mkdir -p $DIR/$tdir || error "failed to create $DIR/$tdir"
9621 cancel_lru_locks mdc
9623 local low_wm=$(do_facet mds1 $LCTL get_param -n \
9624 ldlm.lock_reclaim_threshold_mb)
9625 # disable reclaim temporarily
9626 do_facet mds1 $LCTL set_param ldlm.lock_reclaim_threshold_mb=0
9628 #define OBD_FAIL_LDLM_WATERMARK_HIGH 0x328
9629 do_facet mds1 $LCTL set_param fail_loc=0x328
9630 do_facet mds1 $LCTL set_param fail_val=500
9632 $LCTL set_param debug=+trace
9635 createmany -o $DIR/$tdir/f $nr &
9638 echo "Sleep $TIMEOUT seconds ..."
9640 if ! ps -p $create_pid > /dev/null 2>&1; then
9641 do_facet mds1 $LCTL set_param fail_loc=0
9642 do_facet mds1 $LCTL set_param fail_val=0
9643 do_facet mds1 $LCTL set_param \
9644 ldlm.lock_reclaim_threshold_mb=${low_wm}m
9645 error "createmany finished incorrectly!"
9647 do_facet mds1 $LCTL set_param fail_loc=0
9648 do_facet mds1 $LCTL set_param fail_val=0
9649 do_facet mds1 $LCTL set_param ldlm.lock_reclaim_threshold_mb=${low_wm}m
9650 wait $create_pid || return 1
9652 unlinkmany $DIR/$tdir/f $nr
9654 run_test 134b "Server rejects lock request when reaching lock_limit_mb"
9656 test_140() { #bug-17379
9657 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9658 test_mkdir -p $DIR/$tdir || error "Creating dir $DIR/$tdir"
9659 cd $DIR/$tdir || error "Changing to $DIR/$tdir"
9660 cp /usr/bin/stat . || error "Copying stat to $DIR/$tdir"
9662 # VFS limits max symlink depth to 5(4KSTACK) or 7(8KSTACK) or 8
9663 # For kernel > 3.5, bellow only tests consecutive symlink (MAX 40)
9665 while i=`expr $i + 1`; do
9666 test_mkdir -p $i || error "Creating dir $i"
9667 cd $i || error "Changing to $i"
9668 ln -s ../stat stat || error "Creating stat symlink"
9669 # Read the symlink until ELOOP present,
9670 # not LBUGing the system is considered success,
9671 # we didn't overrun the stack.
9672 $OPENFILE -f O_RDONLY stat >/dev/null 2>&1; ret=$?
9674 if [ $ret -eq 40 ]; then
9677 error "Open stat symlink"
9683 echo "The symlink depth = $i"
9684 [ $i -eq 5 -o $i -eq 7 -o $i -eq 8 -o $i -eq 40 ] ||
9685 error "Invalid symlink depth"
9687 # Test recursive symlink
9688 ln -s symlink_self symlink_self
9689 $OPENFILE -f O_RDONLY symlink_self >/dev/null 2>&1; ret=$?
9690 echo "open symlink_self returns $ret"
9691 [ $ret -eq 40 ] || error "recursive symlink doesn't return -ELOOP"
9693 run_test 140 "Check reasonable stack depth (shouldn't LBUG) ===="
9696 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9697 local TF="$TMP/$tfile"
9699 dd if=/dev/urandom of=$TF bs=6096 count=1 || error "dd failed"
9701 cancel_lru_locks osc
9702 cmp $TF $DIR/$tfile || error "$TMP/$tfile $DIR/$tfile differ"
9703 remount_client $MOUNT
9705 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (remount)"
9708 $TRUNCATE $DIR/$tfile 6000
9709 cancel_lru_locks osc
9710 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (truncate1)"
9713 echo "12345" >>$DIR/$tfile
9714 cancel_lru_locks osc
9715 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (append1)"
9718 echo "12345" >>$DIR/$tfile
9719 cancel_lru_locks osc
9720 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (append2)"
9725 run_test 150 "truncate/append tests"
9727 #LU-2902 roc_hit was not able to read all values from lproc
9728 function roc_hit_init() {
9729 local list=$(comma_list $(osts_nodes))
9730 local dir=$DIR/$tdir-check
9731 local file=$dir/file
9737 #use setstripe to do a write to every ost
9738 for i in $(seq 0 $((OSTCOUNT-1))); do
9739 $SETSTRIPE -c 1 -i $i $dir || error "$SETSTRIPE $file failed"
9740 dd if=/dev/urandom of=$file bs=4k count=4 2>&1 > /dev/null
9741 idx=$(printf %04x $i)
9742 BEFORE=$(get_osd_param $list *OST*$idx stats |
9743 awk '$1 == "cache_access" {sum += $7}
9744 END { printf("%0.0f", sum) }')
9746 cancel_lru_locks osc
9747 cat $file >/dev/null
9749 AFTER=$(get_osd_param $list *OST*$idx stats |
9750 awk '$1 == "cache_access" {sum += $7}
9751 END { printf("%0.0f", sum) }')
9753 echo BEFORE:$BEFORE AFTER:$AFTER
9754 if ! let "AFTER - BEFORE == 4"; then
9756 error "roc_hit is not safe to use"
9764 function roc_hit() {
9765 local list=$(comma_list $(osts_nodes))
9766 echo $(get_osd_param $list '' stats |
9767 awk '$1 == "cache_hit" {sum += $7}
9768 END { printf("%0.0f", sum) }')
9771 function set_cache() {
9774 if [ "$2" == "off" ]; then
9777 local list=$(comma_list $(osts_nodes))
9778 set_osd_param $list '' $1_cache_enable $on
9780 cancel_lru_locks osc
9784 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9785 remote_ost_nodsh && skip "remote OST with nodsh" && return
9788 local list=$(comma_list $(osts_nodes))
9790 # check whether obdfilter is cache capable at all
9791 if ! get_osd_param $list '' read_cache_enable >/dev/null; then
9792 echo "not cache-capable obdfilter"
9796 # check cache is enabled on all obdfilters
9797 if get_osd_param $list '' read_cache_enable | grep 0; then
9798 echo "oss cache is disabled"
9802 set_osd_param $list '' writethrough_cache_enable 1
9804 # check write cache is enabled on all obdfilters
9805 if get_osd_param $list '' writethrough_cache_enable | grep 0; then
9806 echo "oss write cache is NOT enabled"
9812 #define OBD_FAIL_OBD_NO_LRU 0x609
9813 do_nodes $list $LCTL set_param fail_loc=0x609
9815 # pages should be in the case right after write
9816 dd if=/dev/urandom of=$DIR/$tfile bs=4k count=$CPAGES ||
9819 local BEFORE=$(roc_hit)
9820 cancel_lru_locks osc
9821 cat $DIR/$tfile >/dev/null
9822 local AFTER=$(roc_hit)
9824 do_nodes $list $LCTL set_param fail_loc=0
9826 if ! let "AFTER - BEFORE == CPAGES"; then
9827 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
9830 # the following read invalidates the cache
9831 cancel_lru_locks osc
9832 set_osd_param $list '' read_cache_enable 0
9833 cat $DIR/$tfile >/dev/null
9835 # now data shouldn't be found in the cache
9837 cancel_lru_locks osc
9838 cat $DIR/$tfile >/dev/null
9840 if let "AFTER - BEFORE != 0"; then
9841 error "IN CACHE: before: $BEFORE, after: $AFTER"
9844 set_osd_param $list '' read_cache_enable 1
9847 run_test 151 "test cache on oss and controls ==============================="
9850 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9851 local TF="$TMP/$tfile"
9853 # simulate ENOMEM during write
9854 #define OBD_FAIL_OST_NOMEM 0x226
9855 lctl set_param fail_loc=0x80000226
9856 dd if=/dev/urandom of=$TF bs=6096 count=1 || error "dd failed"
9858 sync || error "sync failed"
9859 lctl set_param fail_loc=0
9861 # discard client's cache
9862 cancel_lru_locks osc
9864 # simulate ENOMEM during read
9865 lctl set_param fail_loc=0x80000226
9866 cmp $TF $DIR/$tfile || error "cmp failed"
9867 lctl set_param fail_loc=0
9871 run_test 152 "test read/write with enomem ============================"
9874 $MULTIOP $DIR/$tfile Ow4096Ycu || error "multiop failed"
9876 run_test 153 "test if fdatasync does not crash ======================="
9878 dot_lustre_fid_permission_check() {
9880 local ffid=$MOUNT/.lustre/fid/$fid
9883 echo "stat fid $fid"
9884 stat $ffid > /dev/null || error "stat $ffid failed."
9885 echo "touch fid $fid"
9886 touch $ffid || error "touch $ffid failed."
9887 echo "write to fid $fid"
9888 cat /etc/hosts > $ffid || error "write $ffid failed."
9889 echo "read fid $fid"
9890 diff /etc/hosts $ffid || error "read $ffid failed."
9891 echo "append write to fid $fid"
9892 cat /etc/hosts >> $ffid || error "append write $ffid failed."
9893 echo "rename fid $fid"
9894 mv $ffid $test_dir/$tfile.1 &&
9895 error "rename $ffid to $tfile.1 should fail."
9896 touch $test_dir/$tfile.1
9897 mv $test_dir/$tfile.1 $ffid &&
9898 error "rename $tfile.1 to $ffid should fail."
9899 rm -f $test_dir/$tfile.1
9900 echo "truncate fid $fid"
9901 $TRUNCATE $ffid 777 || error "truncate $ffid failed."
9902 if [ $MDSCOUNT -lt 2 ]; then #FIXME when cross-MDT hard link is working
9903 echo "link fid $fid"
9904 ln -f $ffid $test_dir/tfile.lnk || error "link $ffid failed."
9906 if [ -n $(lctl get_param -n mdc.*-mdc-*.connect_flags | grep acl) ]; then
9907 echo "setfacl fid $fid"
9908 setfacl -R -m u:bin:rwx $ffid || error "setfacl $ffid failed."
9909 echo "getfacl fid $fid"
9910 getfacl $ffid >/dev/null || error "getfacl $ffid failed."
9912 echo "unlink fid $fid"
9913 unlink $MOUNT/.lustre/fid/$fid && error "unlink $ffid should fail."
9914 echo "mknod fid $fid"
9915 mknod $ffid c 1 3 && error "mknod $ffid should fail."
9917 fid=[0xf00000400:0x1:0x0]
9918 ffid=$MOUNT/.lustre/fid/$fid
9920 echo "stat non-exist fid $fid"
9921 stat $ffid > /dev/null && error "stat non-exist $ffid should fail."
9922 echo "write to non-exist fid $fid"
9923 cat /etc/hosts > $ffid && error "write non-exist $ffid should fail."
9924 echo "link new fid $fid"
9925 ln $test_dir/$tfile $ffid && error "link $ffid should fail."
9927 mkdir -p $test_dir/$tdir
9928 touch $test_dir/$tdir/$tfile
9929 fid=$($LFS path2fid $test_dir/$tdir)
9932 error "error: could not get fid for $test_dir/$dir/$tfile."
9934 ffid=$MOUNT/.lustre/fid/$fid
9937 ls $ffid > /dev/null || error "ls $ffid failed."
9938 echo "touch $fid/$tfile.1"
9939 touch $ffid/$tfile.1 || error "touch $ffid/$tfile.1 failed."
9941 echo "touch $MOUNT/.lustre/fid/$tfile"
9942 touch $MOUNT/.lustre/fid/$tfile && \
9943 error "touch $MOUNT/.lustre/fid/$tfile should fail."
9945 echo "setxattr to $MOUNT/.lustre/fid"
9946 setfattr -n trusted.name1 -v value1 $MOUNT/.lustre/fid
9948 echo "listxattr for $MOUNT/.lustre/fid"
9949 getfattr -d -m "^trusted" $MOUNT/.lustre/fid
9951 echo "delxattr from $MOUNT/.lustre/fid"
9952 setfattr -x trusted.name1 $MOUNT/.lustre/fid
9954 echo "touch invalid fid: $MOUNT/.lustre/fid/[0x200000400:0x2:0x3]"
9955 touch $MOUNT/.lustre/fid/[0x200000400:0x2:0x3] &&
9956 error "touch invalid fid should fail."
9958 echo "touch non-normal fid: $MOUNT/.lustre/fid/[0x1:0x2:0x0]"
9959 touch $MOUNT/.lustre/fid/[0x1:0x2:0x0] &&
9960 error "touch non-normal fid should fail."
9962 echo "rename $tdir to $MOUNT/.lustre/fid"
9963 mrename $test_dir/$tdir $MOUNT/.lustre/fid &&
9964 error "rename to $MOUNT/.lustre/fid should fail."
9966 if [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.3.51) ]
9968 local old_obf_mode=$(stat --format="%a" $DIR/.lustre/fid)
9969 local new_obf_mode=777
9971 echo "change mode of $DIR/.lustre/fid to $new_obf_mode"
9972 chmod $new_obf_mode $DIR/.lustre/fid ||
9973 error "chmod $new_obf_mode $DIR/.lustre/fid failed"
9975 local obf_mode=$(stat --format=%a $DIR/.lustre/fid)
9976 [ $obf_mode -eq $new_obf_mode ] ||
9977 error "stat $DIR/.lustre/fid returned wrong mode $obf_mode"
9979 echo "restore mode of $DIR/.lustre/fid to $old_obf_mode"
9980 chmod $old_obf_mode $DIR/.lustre/fid ||
9981 error "chmod $old_obf_mode $DIR/.lustre/fid failed"
9984 $OPENFILE -f O_LOV_DELAY_CREATE:O_CREAT $test_dir/$tfile-2
9985 fid=$($LFS path2fid $test_dir/$tfile-2)
9987 if [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.6.50) ]
9989 echo "cp /etc/passwd $MOUNT/.lustre/fid/$fid"
9990 cp /etc/passwd $MOUNT/.lustre/fid/$fid ||
9991 error "create lov data thru .lustre failed"
9993 echo "cp /etc/passwd $test_dir/$tfile-2"
9994 cp /etc/passwd $test_dir/$tfile-2 ||
9995 error "copy to $test_dir/$tfile-2 failed."
9996 echo "diff /etc/passwd $MOUNT/.lustre/fid/$fid"
9997 diff /etc/passwd $MOUNT/.lustre/fid/$fid ||
9998 error "diff /etc/passwd $MOUNT/.lustre/fid/$fid failed."
10000 rm -rf $test_dir/tfile.lnk
10001 rm -rf $test_dir/$tfile-2
10005 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.1) ]] &&
10006 skip "Need MDS version at least 2.4.1" && return
10009 local FID=$($LFS path2fid $DIR/$tfile)
10010 [ -z "$FID" ] && error "path2fid unable to get $DIR/$tfile FID"
10012 # check that we get the same pathname back
10013 local FOUND=$($LFS fid2path $MOUNT "$FID")
10014 [ -z "$FOUND" ] && error "fid2path unable to get $FID path"
10015 [ "$FOUND" != "$DIR/$tfile" ] &&
10016 error "fid2path(path2fid($DIR/$tfile)) = $FOUND != $DIR/$tfile"
10020 run_test 154A "lfs path2fid and fid2path basic checks"
10023 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10024 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.51) ]] ||
10025 { skip "Need MDS version at least 2.2.51"; return 0; }
10026 [ -z "$(which setfacl)" ] && skip "must have setfacl tool" && return
10027 [ -n "$FILESET" ] && skip "SKIP due to FILESET set" && return
10029 cp /etc/hosts $DIR/$tfile
10031 fid=$($LFS path2fid $DIR/$tfile)
10033 [ $rc -ne 0 ] && error "error: could not get fid for $DIR/$tfile."
10035 dot_lustre_fid_permission_check "$fid" $DIR ||
10036 error "dot lustre permission check $fid failed"
10038 rm -rf $MOUNT/.lustre && error ".lustre is not allowed to be unlinked"
10040 touch $MOUNT/.lustre/file &&
10041 error "creation is not allowed under .lustre"
10043 mkdir $MOUNT/.lustre/dir &&
10044 error "mkdir is not allowed under .lustre"
10048 run_test 154a "Open-by-FID"
10051 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10052 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.51) ]] ||
10053 { skip "Need MDS version at least 2.2.51"; return 0; }
10054 [ -n "$FILESET" ] && skip "SKIP due to FILESET set" && return
10056 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
10058 local remote_dir=$DIR/$tdir/remote_dir
10062 mkdir -p $DIR/$tdir
10063 $LFS mkdir -i $MDTIDX $remote_dir ||
10064 error "create remote directory failed"
10066 cp /etc/hosts $remote_dir/$tfile
10068 fid=$($LFS path2fid $remote_dir/$tfile)
10070 [ $rc -ne 0 ] && error "error: could not get fid for $remote_dir/$tfile"
10072 dot_lustre_fid_permission_check "$fid" $remote_dir ||
10073 error "dot lustre permission check $fid failed"
10076 run_test 154b "Open-by-FID for remote directory"
10079 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.1) ]] &&
10080 skip "Need MDS version at least 2.4.1" && return
10082 touch $DIR/$tfile.1 $DIR/$tfile.2 $DIR/$tfile.3
10083 local FID1=$($LFS path2fid $DIR/$tfile.1)
10084 local FID2=$($LFS path2fid $DIR/$tfile.2)
10085 local FID3=$($LFS path2fid $DIR/$tfile.3)
10088 $LFS path2fid $DIR/$tfile.[123] | while read PATHNAME FID; do
10089 [ "$PATHNAME" = "$DIR/$tfile.$N:" ] ||
10090 error "path2fid pathname $PATHNAME != $DIR/$tfile.$N:"
10092 [ "$FID" = "${!want}" ] ||
10093 error "path2fid $PATHNAME FID $FID != FID$N ${!want}"
10097 $LFS fid2path $MOUNT "$FID1" "$FID2" "$FID3" | while read PATHNAME;
10099 [ "$PATHNAME" = "$DIR/$tfile.$N" ] ||
10100 error "fid2path pathname $PATHNAME != $DIR/$tfile.$N:"
10104 run_test 154c "lfs path2fid and fid2path multiple arguments"
10107 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.5.53) ]] &&
10108 skip "Need MDS version at least 2.5.53" && return
10110 if remote_mds; then
10111 nid=$($LCTL list_nids | sed "s/\./\\\./g")
10115 local proc_ofile="mdt.*.exports.'$nid'.open_files"
10122 local fid=$($LFS path2fid $DIR/$tfile)
10125 cmd="exec $fd<$DIR/$tfile"
10127 local fid_list=$(do_facet $SINGLEMDS $LCTL get_param $proc_ofile)
10128 echo "$fid_list" | grep "$fid"
10131 cmd="exec $fd>/dev/null"
10133 if [ $rc -ne 0 ]; then
10134 error "FID $fid not found in open files list $fid_list"
10137 run_test 154d "Verify open file fid"
10141 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.6.50) ]] &&
10142 skip "Need MDS version at least 2.6.50" && return
10144 if ls -a $MOUNT | grep -q '^\.lustre$'; then
10145 error ".lustre returned by readdir"
10148 run_test 154e ".lustre is not returned by readdir"
10151 [ -n "$FILESET" ] && skip "SKIP due to FILESET set" && return
10152 # create parent directory on a single MDT to avoid cross-MDT hardlinks
10153 test_mkdir -p -c1 $DIR/$tdir/d
10154 # test dirs inherit from its stripe
10155 mkdir -p $DIR/$tdir/d/foo1 || error "mkdir error"
10156 mkdir -p $DIR/$tdir/d/foo2 || error "mkdir error"
10157 cp /etc/hosts $DIR/$tdir/d/foo1/$tfile
10158 ln $DIR/$tdir/d/foo1/$tfile $DIR/$tdir/d/foo2/link
10161 # get fid of parents
10162 local FID0=$($LFS path2fid $DIR/$tdir/d)
10163 local FID1=$($LFS path2fid $DIR/$tdir/d/foo1)
10164 local FID2=$($LFS path2fid $DIR/$tdir/d/foo2)
10165 local FID3=$($LFS path2fid $DIR)
10167 # check that path2fid --parents returns expected <parent_fid>/name
10168 # 1) test for a directory (single parent)
10169 local parent=$($LFS path2fid --parents $DIR/$tdir/d/foo1)
10170 [ "$parent" == "$FID0/foo1" ] ||
10171 error "expected parent: $FID0/foo1, got: $parent"
10173 # 2) test for a file with nlink > 1 (multiple parents)
10174 parent=$($LFS path2fid --parents $DIR/$tdir/d/foo1/$tfile)
10175 echo "$parent" | grep -F "$FID1/$tfile" ||
10176 error "$FID1/$tfile not returned in parent list"
10177 echo "$parent" | grep -F "$FID2/link" ||
10178 error "$FID2/link not returned in parent list"
10180 # 3) get parent by fid
10181 local file_fid=$($LFS path2fid $DIR/$tdir/d/foo1/$tfile)
10182 parent=$($LFS path2fid --parents $MOUNT/.lustre/fid/$file_fid)
10183 echo "$parent" | grep -F "$FID1/$tfile" ||
10184 error "$FID1/$tfile not returned in parent list (by fid)"
10185 echo "$parent" | grep -F "$FID2/link" ||
10186 error "$FID2/link not returned in parent list (by fid)"
10188 # 4) test for entry in root directory
10189 parent=$($LFS path2fid --parents $DIR/f)
10190 echo "$parent" | grep -F "$FID3/f" ||
10191 error "$FID3/f not returned in parent list"
10193 # 5) test it on root directory
10194 [ -z "$($LFS path2fid --parents $MOUNT 2>/dev/null)" ] ||
10195 error "$MOUNT should not have parents"
10197 # enable xattr caching and check that linkea is correctly updated
10198 local save="$TMP/$TESTSUITE-$TESTNAME.parameters"
10199 save_lustre_params client "llite.*.xattr_cache" > $save
10200 lctl set_param llite.*.xattr_cache 1
10202 # 6.1) linkea update on rename
10203 mv $DIR/$tdir/d/foo1/$tfile $DIR/$tdir/d/foo2/$tfile.moved
10205 # get parents by fid
10206 parent=$($LFS path2fid --parents $MOUNT/.lustre/fid/$file_fid)
10207 # foo1 should no longer be returned in parent list
10208 echo "$parent" | grep -F "$FID1" &&
10209 error "$FID1 should no longer be in parent list"
10210 # the new path should appear
10211 echo "$parent" | grep -F "$FID2/$tfile.moved" ||
10212 error "$FID2/$tfile.moved is not in parent list"
10214 # 6.2) linkea update on unlink
10215 rm -f $DIR/$tdir/d/foo2/link
10216 parent=$($LFS path2fid --parents $MOUNT/.lustre/fid/$file_fid)
10217 # foo2/link should no longer be returned in parent list
10218 echo "$parent" | grep -F "$FID2/link" &&
10219 error "$FID2/link should no longer be in parent list"
10223 restore_lustre_params < $save
10225 run_test 154f "get parent fids by reading link ea"
10229 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.6.92) ]] ||
10230 { skip "Need MDS version at least 2.6.92"; return 0; }
10231 [ -n "$FILESET" ] && skip "SKIP due to FILESET set" && return
10233 mkdir -p $DIR/$tdir
10234 llapi_fid_test -d $DIR/$tdir
10236 run_test 154g "various llapi FID tests"
10238 test_155_small_load() {
10239 local temp=$TMP/$tfile
10240 local file=$DIR/$tfile
10242 dd if=/dev/urandom of=$temp bs=6096 count=1 || \
10243 error "dd of=$temp bs=6096 count=1 failed"
10245 cancel_lru_locks osc
10246 cmp $temp $file || error "$temp $file differ"
10248 $TRUNCATE $temp 6000
10249 $TRUNCATE $file 6000
10250 cmp $temp $file || error "$temp $file differ (truncate1)"
10252 echo "12345" >>$temp
10253 echo "12345" >>$file
10254 cmp $temp $file || error "$temp $file differ (append1)"
10256 echo "12345" >>$temp
10257 echo "12345" >>$file
10258 cmp $temp $file || error "$temp $file differ (append2)"
10264 test_155_big_load() {
10265 remote_ost_nodsh && skip "remote OST with nodsh" && return
10266 local temp=$TMP/$tfile
10267 local file=$DIR/$tfile
10270 local cache_size=$(do_facet ost$((MAXI+1)) \
10271 "awk '/cache/ {sum+=\\\$4} END {print sum}' /proc/cpuinfo")
10272 local large_file_size=$((cache_size * 2))
10274 echo "OSS cache size: $cache_size KB"
10275 echo "Large file size: $large_file_size KB"
10277 [ $MAXV -le $large_file_size ] && \
10278 skip_env "max available OST size needs > $large_file_size KB" && \
10281 $SETSTRIPE $file -c 1 -i $MAXI || error "$SETSTRIPE $file failed"
10283 dd if=/dev/urandom of=$temp bs=$large_file_size count=1k || \
10284 error "dd of=$temp bs=$large_file_size count=1k failed"
10287 cancel_lru_locks osc
10288 cmp $temp $file || error "$temp $file differ"
10295 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10297 set_cache writethrough on
10298 test_155_small_load
10300 run_test 155a "Verify small file correctness: read cache:on write_cache:on"
10303 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10305 set_cache writethrough off
10306 test_155_small_load
10308 run_test 155b "Verify small file correctness: read cache:on write_cache:off"
10311 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10313 set_cache writethrough on
10314 test_155_small_load
10316 run_test 155c "Verify small file correctness: read cache:off write_cache:on"
10319 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10321 set_cache writethrough off
10322 test_155_small_load
10324 run_test 155d "Verify small file correctness: read cache:off write_cache:off"
10327 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10329 set_cache writethrough on
10332 run_test 155e "Verify big file correctness: read cache:on write_cache:on"
10335 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10337 set_cache writethrough off
10340 run_test 155f "Verify big file correctness: read cache:on write_cache:off"
10343 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10345 set_cache writethrough on
10348 run_test 155g "Verify big file correctness: read cache:off write_cache:on"
10351 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10353 set_cache writethrough off
10356 run_test 155h "Verify big file correctness: read cache:off write_cache:off"
10359 remote_ost_nodsh && skip "remote OST with nodsh" && return
10360 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10364 local file="$DIR/$tfile"
10366 [ "$(facet_fstype ost1)" = "zfs" -a \
10367 $(lustre_version_code ost1 -lt $(version_code 2.6.93)) ] &&
10368 skip "LU-1956/LU-2261: stats not implemented on OSD ZFS" &&
10373 log "Turn on read and write cache"
10375 set_cache writethrough on
10377 log "Write data and read it back."
10378 log "Read should be satisfied from the cache."
10379 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
10381 cancel_lru_locks osc
10382 cat $file >/dev/null
10384 if ! let "AFTER - BEFORE == CPAGES"; then
10385 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
10387 log "cache hits:: before: $BEFORE, after: $AFTER"
10390 log "Read again; it should be satisfied from the cache."
10392 cancel_lru_locks osc
10393 cat $file >/dev/null
10395 if ! let "AFTER - BEFORE == CPAGES"; then
10396 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
10398 log "cache hits:: before: $BEFORE, after: $AFTER"
10401 log "Turn off the read cache and turn on the write cache"
10403 set_cache writethrough on
10405 log "Read again; it should be satisfied from the cache."
10407 cancel_lru_locks osc
10408 cat $file >/dev/null
10410 if ! let "AFTER - BEFORE == CPAGES"; then
10411 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
10413 log "cache hits:: before: $BEFORE, after: $AFTER"
10416 log "Read again; it should not be satisfied from the cache."
10418 cancel_lru_locks osc
10419 cat $file >/dev/null
10421 if ! let "AFTER - BEFORE == 0"; then
10422 error "IN CACHE: before: $BEFORE, after: $AFTER"
10424 log "cache hits:: before: $BEFORE, after: $AFTER"
10427 log "Write data and read it back."
10428 log "Read should be satisfied from the cache."
10429 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
10431 cancel_lru_locks osc
10432 cat $file >/dev/null
10434 if ! let "AFTER - BEFORE == CPAGES"; then
10435 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
10437 log "cache hits:: before: $BEFORE, after: $AFTER"
10440 log "Read again; it should not be satisfied from the cache."
10442 cancel_lru_locks osc
10443 cat $file >/dev/null
10445 if ! let "AFTER - BEFORE == 0"; then
10446 error "IN CACHE: before: $BEFORE, after: $AFTER"
10448 log "cache hits:: before: $BEFORE, after: $AFTER"
10451 log "Turn off read and write cache"
10453 set_cache writethrough off
10455 log "Write data and read it back"
10456 log "It should not be satisfied from the cache."
10458 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
10459 cancel_lru_locks osc
10461 cat $file >/dev/null
10463 if ! let "AFTER - BEFORE == 0"; then
10464 error_ignore bz20762 "IN CACHE: before: $BEFORE, after: $AFTER"
10466 log "cache hits:: before: $BEFORE, after: $AFTER"
10469 log "Turn on the read cache and turn off the write cache"
10471 set_cache writethrough off
10473 log "Write data and read it back"
10474 log "It should not be satisfied from the cache."
10476 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
10478 cancel_lru_locks osc
10479 cat $file >/dev/null
10481 if ! let "AFTER - BEFORE == 0"; then
10482 error_ignore bz20762 "IN CACHE: before: $BEFORE, after: $AFTER"
10484 log "cache hits:: before: $BEFORE, after: $AFTER"
10487 log "Read again; it should be satisfied from the cache."
10489 cancel_lru_locks osc
10490 cat $file >/dev/null
10492 if ! let "AFTER - BEFORE == CPAGES"; then
10493 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
10495 log "cache hits:: before: $BEFORE, after: $AFTER"
10500 run_test 156 "Verification of tunables"
10504 if [[ $MDSCOUNT -gt 1 ]]; then
10505 error_ignore bz17935 $*
10513 local CL_MASK_PARAM="mdd.$MDT0.changelog_mask"
10515 MASK=$(do_facet $SINGLEMDS $LCTL get_param $CL_MASK_PARAM| grep -c "$1")
10517 if [ $MASK -eq 1 ]; then
10518 do_facet $SINGLEMDS $LCTL set_param $CL_MASK_PARAM="-$1"
10520 do_facet $SINGLEMDS $LCTL set_param $CL_MASK_PARAM="+$1"
10524 changelog_extract_field() {
10528 local identifier=$4
10530 $LFS changelog $mdt | gawk "/$cltype.*$file$/ {
10531 print gensub(/^.* "$identifier'(\[[^\]]*\]).*$/,"\\1",1)}' |
10536 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10537 remote_mds_nodsh && skip "remote MDS with nodsh" && return
10538 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] ||
10539 { skip "Need MDS version at least 2.2.0"; return; }
10541 local CL_USERS="mdd.$MDT0.changelog_users"
10542 local GET_CL_USERS="do_facet $SINGLEMDS $LCTL get_param -n $CL_USERS"
10543 USER=$(do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_register -n)
10544 echo "Registered as changelog user $USER"
10545 $GET_CL_USERS | grep -q $USER ||
10546 error "User $USER not found in changelog_users"
10549 test_mkdir -p $DIR/$tdir/pics/2008/zachy
10550 touch $DIR/$tdir/pics/2008/zachy/timestamp
10551 cp /etc/hosts $DIR/$tdir/pics/2008/zachy/pic1.jpg
10552 mv $DIR/$tdir/pics/2008/zachy $DIR/$tdir/pics/zach
10553 ln $DIR/$tdir/pics/zach/pic1.jpg $DIR/$tdir/pics/2008/portland.jpg
10554 ln -s $DIR/$tdir/pics/2008/portland.jpg $DIR/$tdir/pics/desktop.jpg
10555 rm $DIR/$tdir/pics/desktop.jpg
10557 $LFS changelog $MDT0 | tail -5
10559 echo "verifying changelog mask"
10560 changelog_chmask "MKDIR"
10561 changelog_chmask "CLOSE"
10563 test_mkdir -p $DIR/$tdir/pics/zach/sofia
10564 echo "zzzzzz" > $DIR/$tdir/pics/zach/file
10566 changelog_chmask "MKDIR"
10567 changelog_chmask "CLOSE"
10569 test_mkdir -p $DIR/$tdir/pics/2008/sofia
10570 echo "zzzzzz" > $DIR/$tdir/pics/zach/file
10572 $LFS changelog $MDT0
10573 MKDIRS=$($LFS changelog $MDT0 | tail -5 | grep -c "MKDIR")
10574 CLOSES=$($LFS changelog $MDT0 | tail -5 | grep -c "CLOSE")
10575 [ $MKDIRS -eq 1 ] || err17935 "MKDIR changelog mask count $DIRS != 1"
10576 [ $CLOSES -eq 1 ] || err17935 "CLOSE changelog mask count $DIRS != 1"
10579 echo "verifying target fid"
10580 fidc=$(changelog_extract_field $MDT0 "CREAT" "timestamp" "t=")
10581 fidf=$($LFS path2fid $DIR/$tdir/pics/zach/timestamp)
10582 [ "$fidc" == "$fidf" ] ||
10583 err17935 "fid in changelog $fidc != file fid $fidf"
10584 echo "verifying parent fid"
10585 fidc=$(changelog_extract_field $MDT0 "CREAT" "timestamp" "p=")
10586 fidf=$($LFS path2fid $DIR/$tdir/pics/zach)
10587 [ "$fidc" == "$fidf" ] ||
10588 err17935 "pfid in changelog $fidc != dir fid $fidf"
10590 USER_REC1=$($GET_CL_USERS | awk "\$1 == \"$USER\" {print \$2}")
10591 $LFS changelog_clear $MDT0 $USER $(($USER_REC1 + 5))
10592 USER_REC2=$($GET_CL_USERS | awk "\$1 == \"$USER\" {print \$2}")
10593 echo "verifying user clear: $(( $USER_REC1 + 5 )) == $USER_REC2"
10594 [ $USER_REC2 == $(($USER_REC1 + 5)) ] ||
10595 err17935 "user index expected $(($USER_REC1 + 5)) is $USER_REC2"
10597 MIN_REC=$($GET_CL_USERS |
10598 awk 'min == "" || $2 < min {min = $2}; END {print min}')
10599 FIRST_REC=$($LFS changelog $MDT0 | head -n1 | awk '{print $1}')
10600 echo "verifying min purge: $(( $MIN_REC + 1 )) == $FIRST_REC"
10601 [ $FIRST_REC == $(($MIN_REC + 1)) ] ||
10602 err17935 "first index should be $(($MIN_REC + 1)) is $FIRST_REC"
10604 # LU-3446 changelog index reset on MDT restart
10605 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
10606 CUR_REC1=$($GET_CL_USERS | head -n1 | cut -f3 -d' ')
10607 $LFS changelog_clear $MDT0 $USER 0
10608 stop $SINGLEMDS || error "Fail to stop MDT."
10609 start $SINGLEMDS $MDT_DEV $MDS_MOUNT_OPTS || error "Fail to start MDT."
10610 CUR_REC2=$($GET_CL_USERS | head -n1 | cut -f3 -d' ')
10611 echo "verifying index survives MDT restart: $CUR_REC1 == $CUR_REC2"
10612 [ $CUR_REC1 == $CUR_REC2 ] ||
10613 err17935 "current index should be $CUR_REC1 is $CUR_REC2"
10615 echo "verifying user deregister"
10616 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister $USER
10617 $GET_CL_USERS | grep -q $USER &&
10618 error "User $USER still in changelog_users"
10620 USERS=$(( $($GET_CL_USERS | wc -l) - 2 ))
10621 if [ $USERS -eq 0 ]; then
10622 LAST_REC1=$($GET_CL_USERS | head -n1 | cut -f3 -d' ')
10623 touch $DIR/$tdir/chloe
10624 LAST_REC2=$($GET_CL_USERS | head -n1 | cut -f3 -d' ')
10625 echo "verify changelogs are off: $LAST_REC1 == $LAST_REC2"
10626 [ $LAST_REC1 == $LAST_REC2 ] || error "changelogs not off"
10628 echo "$USERS other changelog users; can't verify off"
10631 run_test 160a "changelog sanity"
10633 test_160b() { # LU-3587
10634 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10635 remote_mds_nodsh && skip "remote MDS with nodsh" && return
10636 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] ||
10637 { skip "Need MDS version at least 2.2.0"; return; }
10639 local CL_USERS="mdd.$MDT0.changelog_users"
10640 local GET_CL_USERS="do_facet $SINGLEMDS $LCTL get_param -n $CL_USERS"
10641 USER=$(do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_register -n)
10642 echo "Registered as changelog user $USER"
10643 $GET_CL_USERS | grep -q $USER ||
10644 error "User $USER not found in changelog_users"
10646 local LONGNAME1=$(str_repeat a 255)
10647 local LONGNAME2=$(str_repeat b 255)
10650 echo "creating very long named file"
10651 touch $LONGNAME1 || error "create of $LONGNAME1 failed"
10652 echo "moving very long named file"
10653 mv $LONGNAME1 $LONGNAME2
10655 $LFS changelog $MDT0 | grep RENME
10657 echo "deregistering $USER"
10658 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister $USER
10662 run_test 160b "Verify that very long rename doesn't crash in changelog"
10665 remote_mds_nodsh && skip "remote MDS with nodsh" && return
10668 local server_version=$(lustre_version_code $SINGLEMDS)
10670 [[ $server_version -gt $(version_code 2.5.57) ]] ||
10671 [[ $server_version -gt $(version_code 2.5.1) &&
10672 $server_version -lt $(version_code 2.5.50) ]] ||
10673 { skip "Need MDS version at least 2.5.58 or 2.5.2+"; return; }
10674 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10676 # Registration step
10677 local USER=$(do_facet $SINGLEMDS $LCTL --device $MDT0 \
10678 changelog_register -n)
10681 mkdir -p $DIR/$tdir
10682 $MCREATE $DIR/$tdir/foo_160c
10683 changelog_chmask "TRUNC"
10684 $TRUNCATE $DIR/$tdir/foo_160c 200
10685 changelog_chmask "TRUNC"
10686 $TRUNCATE $DIR/$tdir/foo_160c 199
10687 $LFS changelog $MDT0
10688 TRUNCS=$($LFS changelog $MDT0 | tail -5 | grep -c "TRUNC")
10689 [ $TRUNCS -eq 1 ] || err17935 "TRUNC changelog mask count $TRUNCS != 1"
10690 $LFS changelog_clear $MDT0 $USER 0
10692 # Deregistration step
10693 echo "deregistering $USER"
10694 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister $USER
10696 run_test 160c "verify that changelog log catch the truncate event"
10699 remote_mds_nodsh && skip "remote MDS with nodsh" && return
10700 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
10702 local server_version=$(lustre_version_code mds1)
10703 local CL_MASK_PARAM="mdd.$MDT0.changelog_mask"
10705 [[ $server_version -ge $(version_code 2.7.60) ]] ||
10706 { skip "Need MDS version at least 2.7.60+"; return; }
10707 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10709 # Registration step
10710 local USER=$(do_facet mds1 $LCTL --device $MDT0 \
10711 changelog_register -n)
10713 mkdir -p $DIR/$tdir/migrate_dir
10714 $LFS changelog_clear $MDT0 $USER 0
10716 $LFS migrate -m 1 $DIR/$tdir/migrate_dir || error "migrate fails"
10717 $LFS changelog $MDT0
10718 MIGRATES=$($LFS changelog $MDT0 | tail -5 | grep -c "MIGRT")
10719 $LFS changelog_clear $MDT0 $USER 0
10720 [ $MIGRATES -eq 1 ] ||
10721 error "MIGRATE changelog mask count $MIGRATES != 1"
10723 # Deregistration step
10724 do_facet mds1 $LCTL --device $MDT0 changelog_deregister $USER
10726 run_test 160d "verify that changelog log catch the migrate event"
10729 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10730 test_mkdir -p -c1 $DIR/$tdir
10731 cp /etc/hosts $DIR/$tdir/$tfile
10732 test_mkdir -c1 $DIR/$tdir/foo1
10733 test_mkdir -c1 $DIR/$tdir/foo2
10734 ln $DIR/$tdir/$tfile $DIR/$tdir/foo1/sofia
10735 ln $DIR/$tdir/$tfile $DIR/$tdir/foo2/zachary
10736 ln $DIR/$tdir/$tfile $DIR/$tdir/foo1/luna
10737 ln $DIR/$tdir/$tfile $DIR/$tdir/foo2/thor
10738 local FID=$($LFS path2fid $DIR/$tdir/$tfile | tr -d '[]')
10739 if [ "$($LFS fid2path $DIR $FID | wc -l)" != "5" ]; then
10740 $LFS fid2path $DIR $FID
10741 err17935 "bad link ea"
10744 rm $DIR/$tdir/foo2/zachary
10746 rm $DIR/$tdir/foo2/thor
10748 rm $DIR/$tdir/$tfile
10750 mv $DIR/$tdir/foo1/sofia $DIR/$tdir/foo2/maggie
10751 if [ "$($LFS fid2path $FSNAME --link 1 $FID)" != "$tdir/foo2/maggie" ]
10753 $LFS fid2path $DIR $FID
10754 err17935 "bad link rename"
10756 rm $DIR/$tdir/foo2/maggie
10759 local longname=filename_avg_len_is_thirty_two_
10760 createmany -l$DIR/$tdir/foo1/luna $DIR/$tdir/foo2/$longname 1000 ||
10761 error "failed to hardlink many files"
10762 links=$($LFS fid2path $DIR $FID | wc -l)
10763 echo -n "${links}/1000 links in link EA"
10764 [[ $links -gt 60 ]] ||
10765 err17935 "expected at least 60 links in link EA"
10766 unlinkmany $DIR/$tdir/foo2/$longname 1000 ||
10767 error "failed to unlink many hardlinks"
10769 run_test 161a "link ea sanity"
10772 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10773 [ $MDSCOUNT -lt 2 ] && skip "skipping remote directory test" && return
10775 local remote_dir=$DIR/$tdir/remote_dir
10777 mkdir -p $DIR/$tdir
10778 $LFS mkdir -i $MDTIDX $remote_dir ||
10779 error "create remote directory failed"
10781 cp /etc/hosts $remote_dir/$tfile
10782 mkdir -p $remote_dir/foo1
10783 mkdir -p $remote_dir/foo2
10784 ln $remote_dir/$tfile $remote_dir/foo1/sofia
10785 ln $remote_dir/$tfile $remote_dir/foo2/zachary
10786 ln $remote_dir/$tfile $remote_dir/foo1/luna
10787 ln $remote_dir/$tfile $remote_dir/foo2/thor
10789 local FID=$($LFS path2fid $remote_dir/$tfile | tr -d '[' |
10791 if [ "$($LFS fid2path $DIR $FID | wc -l)" != "5" ]; then
10792 $LFS fid2path $DIR $FID
10793 err17935 "bad link ea"
10796 rm $remote_dir/foo2/zachary
10798 rm $remote_dir/foo2/thor
10800 rm $remote_dir/$tfile
10802 mv $remote_dir/foo1/sofia $remote_dir/foo2/maggie
10803 local link_path=$($LFS fid2path $FSNAME --link 1 $FID)
10804 if [ "$DIR/$link_path" != "$remote_dir/foo2/maggie" ]; then
10805 $LFS fid2path $DIR $FID
10806 err17935 "bad link rename"
10808 rm $remote_dir/foo2/maggie
10811 local longname=filename_avg_len_is_thirty_two_
10812 createmany -l$remote_dir/foo1/luna $remote_dir/foo2/$longname 1000 ||
10813 error "failed to hardlink many files"
10814 links=$($LFS fid2path $DIR $FID | wc -l)
10815 echo -n "${links}/1000 links in link EA"
10816 [[ ${links} -gt 60 ]] ||
10817 err17935 "expected at least 60 links in link EA"
10818 unlinkmany $remote_dir/foo2/$longname 1000 ||
10819 error "failed to unlink many hardlinks"
10821 run_test 161b "link ea sanity under remote directory"
10824 remote_mds_nodsh && skip "remote MDS with nodsh" && return
10825 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10826 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.1.5) ]] &&
10827 skip "Need MDS version at least 2.1.5" && return
10829 # define CLF_RENAME_LAST 0x0001
10830 # rename overwrite a target having nlink = 1 (changelog flag 0x1)
10831 local USER=$(do_facet $SINGLEMDS $LCTL --device $MDT0 \
10832 changelog_register -n)
10834 mkdir -p $DIR/$tdir
10835 touch $DIR/$tdir/foo_161c
10836 touch $DIR/$tdir/bar_161c
10837 mv -f $DIR/$tdir/foo_161c $DIR/$tdir/bar_161c
10838 $LFS changelog $MDT0 | grep RENME
10839 local flags=$($LFS changelog $MDT0 | grep RENME | tail -1 | \
10841 $LFS changelog_clear $MDT0 $USER 0
10842 if [ x$flags != "x0x1" ]; then
10843 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister \
10845 error "flag $flags is not 0x1"
10847 echo "rename overwrite a target having nlink = 1," \
10848 "changelog record has flags of $flags"
10850 # rename overwrite a target having nlink > 1 (changelog flag 0x0)
10851 touch $DIR/$tdir/foo_161c
10852 touch $DIR/$tdir/bar_161c
10853 ln $DIR/$tdir/bar_161c $DIR/$tdir/foobar_161c
10854 mv -f $DIR/$tdir/foo_161c $DIR/$tdir/bar_161c
10855 $LFS changelog $MDT0 | grep RENME
10856 flags=$($LFS changelog $MDT0 | grep RENME | tail -1 | cut -f5 -d' ')
10857 $LFS changelog_clear $MDT0 $USER 0
10858 if [ x$flags != "x0x0" ]; then
10859 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister \
10861 error "flag $flags is not 0x0"
10863 echo "rename overwrite a target having nlink > 1," \
10864 "changelog record has flags of $flags"
10866 # rename doesn't overwrite a target (changelog flag 0x0)
10867 touch $DIR/$tdir/foo_161c
10868 mv -f $DIR/$tdir/foo_161c $DIR/$tdir/foo2_161c
10869 $LFS changelog $MDT0 | grep RENME
10870 flags=$($LFS changelog $MDT0 | grep RENME | tail -1 | cut -f5 -d' ')
10871 $LFS changelog_clear $MDT0 $USER 0
10872 if [ x$flags != "x0x0" ]; then
10873 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister \
10875 error "flag $flags is not 0x0"
10877 echo "rename doesn't overwrite a target," \
10878 "changelog record has flags of $flags"
10880 # define CLF_UNLINK_LAST 0x0001
10881 # unlink a file having nlink = 1 (changelog flag 0x1)
10882 rm -f $DIR/$tdir/foo2_161c
10883 $LFS changelog $MDT0 | grep UNLNK
10884 flags=$($LFS changelog $MDT0 | grep UNLNK | tail -1 | cut -f5 -d' ')
10885 $LFS changelog_clear $MDT0 $USER 0
10886 if [ x$flags != "x0x1" ]; then
10887 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister \
10889 error "flag $flags is not 0x1"
10891 echo "unlink a file having nlink = 1," \
10892 "changelog record has flags of $flags"
10894 # unlink a file having nlink > 1 (changelog flag 0x0)
10895 ln -f $DIR/$tdir/bar_161c $DIR/$tdir/foobar_161c
10896 rm -f $DIR/$tdir/foobar_161c
10897 $LFS changelog $MDT0 | grep UNLNK
10898 flags=$($LFS changelog $MDT0 | grep UNLNK | tail -1 | cut -f5 -d' ')
10899 $LFS changelog_clear $MDT0 $USER 0
10900 if [ x$flags != "x0x0" ]; then
10901 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister \
10903 error "flag $flags is not 0x0"
10905 echo "unlink a file having nlink > 1," \
10906 "changelog record has flags of $flags"
10907 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister $USER
10909 run_test 161c "check CL_RENME[UNLINK] changelog record flags"
10916 local path=$(${LFS} fid2path $*)
10917 # Remove the '//' indicating a remote directory
10918 path=$(echo $path | sed 's#//#/#g')
10921 if [ $RC -ne 0 ]; then
10922 err17935 "path looked up of $expected failed. Error $RC"
10924 elif [ "${path}" != "${expected}" ]; then
10925 err17935 "path looked up \"${path}\" instead of \"${expected}\""
10928 echo "fid $fid resolves to path $path (expected $expected)"
10931 test_162a() { # was test_162
10932 # Make changes to filesystem
10933 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10934 test_mkdir -p -c1 $DIR/$tdir/d2
10935 touch $DIR/$tdir/d2/$tfile
10936 touch $DIR/$tdir/d2/x1
10937 touch $DIR/$tdir/d2/x2
10938 test_mkdir -p -c1 $DIR/$tdir/d2/a/b/c
10939 test_mkdir -p -c1 $DIR/$tdir/d2/p/q/r
10941 FID=$($LFS path2fid $DIR/$tdir/d2/$tfile | tr -d '[]')
10942 check_path "$tdir/d2/$tfile" $FSNAME $FID --link 0 ||
10943 error "check path $tdir/d2/$tfile failed"
10946 ln -s $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/p/q/r/slink
10947 FID=$($LFS path2fid $DIR/$tdir/d2/p/q/r/slink | tr -d '[]')
10948 check_path "$tdir/d2/p/q/r/slink" $FSNAME $FID --link 0 ||
10949 error "check path $tdir/d2/p/q/r/slink failed"
10951 # softlink to wrong file
10952 ln -s /this/is/garbage $DIR/$tdir/d2/p/q/r/slink.wrong
10953 FID=$($LFS path2fid $DIR/$tdir/d2/p/q/r/slink.wrong | tr -d '[]')
10954 check_path "$tdir/d2/p/q/r/slink.wrong" $FSNAME $FID --link 0 ||
10955 error "check path $tdir/d2/p/q/r/slink.wrong failed"
10958 ln $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/p/q/r/hlink
10959 mv $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/a/b/c/new_file
10960 FID=$($LFS path2fid $DIR/$tdir/d2/a/b/c/new_file | tr -d '[]')
10961 # fid2path dir/fsname should both work
10962 check_path "$tdir/d2/a/b/c/new_file" $FSNAME $FID --link 1 ||
10963 error "check path $tdir/d2/a/b/c/new_file failed"
10964 check_path "$DIR/$tdir/d2/p/q/r/hlink" $DIR $FID --link 0 ||
10965 error "check path $DIR/$tdir/d2/p/q/r/hlink failed"
10967 # hardlink count: check that there are 2 links
10968 # Doesnt work with CMD yet: 17935
10969 ${LFS} fid2path $DIR $FID | wc -l | grep -q 2 || \
10970 err17935 "expected 2 links"
10972 # hardlink indexing: remove the first link
10973 rm $DIR/$tdir/d2/p/q/r/hlink
10974 check_path "$tdir/d2/a/b/c/new_file" $FSNAME $FID --link 0 ||
10975 error "check path $DIR/$tdir/d2/a/b/c/new_file failed"
10979 run_test 162a "path lookup sanity"
10982 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10983 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
10986 $LFS setdirstripe -i0 -c$MDSCOUNT -t all_char $DIR/$tdir/striped_dir ||
10987 error "create striped dir failed"
10989 local FID=$($LFS getdirstripe $DIR/$tdir/striped_dir |
10990 tail -n 1 | awk '{print $2}')
10991 stat $MOUNT/.lustre/fid/$FID && error "sub_stripe can be accessed"
10993 touch $DIR/$tdir/striped_dir/f{0..4} || error "touch f0..4 failed"
10994 mkdir $DIR/$tdir/striped_dir/d{0..4} || error "mkdir d0..4 failed"
10997 for ((i=0;i<5;i++)); do
10998 FID=$($LFS path2fid $DIR/$tdir/striped_dir/f$i | tr -d '[]') ||
10999 error "get fid for f$i failed"
11000 check_path "$tdir/striped_dir/f$i" $FSNAME $FID --link 0 ||
11001 error "check path $tdir/striped_dir/f$i failed"
11003 FID=$($LFS path2fid $DIR/$tdir/striped_dir/d$i | tr -d '[]') ||
11004 error "get fid for d$i failed"
11005 check_path "$tdir/striped_dir/d$i" $FSNAME $FID --link 0 ||
11006 error "check path $tdir/striped_dir/d$i failed"
11011 run_test 162b "striped directory path lookup sanity"
11013 # LU-4239: Verify fid2path works with paths 100 or more directories deep
11015 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.51) ]] &&
11016 skip "Need MDS version at least 2.7.51" && return
11017 test_mkdir $DIR/$tdir.local
11018 test_mkdir $DIR/$tdir.remote
11019 local lpath=$tdir.local
11020 local rpath=$tdir.remote
11022 for ((i = 0; i <= 101; i++)); do
11025 FID=$($LFS path2fid $DIR/$lpath | tr -d '[]') ||
11026 error "get fid for local directory $DIR/$lpath failed"
11027 check_path "$DIR/$lpath" $MOUNT $FID --link 0 ||
11028 error "check path for local directory $DIR/$lpath failed"
11031 test_mkdir $DIR/$rpath
11032 FID=$($LFS path2fid $DIR/$rpath | tr -d '[]') ||
11033 error "get fid for remote directory $DIR/$rpath failed"
11034 check_path "$DIR/$rpath" $MOUNT $FID --link 0 ||
11035 error "check path for remote directory $DIR/$rpath failed"
11040 run_test 162c "fid2path works with paths 100 or more directories deep"
11043 # do directio so as not to populate the page cache
11044 log "creating a 10 Mb file"
11045 $MULTIOP $DIR/$tfile oO_CREAT:O_DIRECT:O_RDWR:w$((10*1048576))c || error "multiop failed while creating a file"
11046 log "starting reads"
11047 dd if=$DIR/$tfile of=/dev/null bs=4096 &
11048 log "truncating the file"
11049 $MULTIOP $DIR/$tfile oO_TRUNC:c || error "multiop failed while truncating the file"
11051 kill %+ || true # reads might have finished
11052 echo "wait until dd is finished"
11054 log "removing the temporary file"
11055 rm -rf $DIR/$tfile || error "tmp file removal failed"
11057 run_test 169 "parallel read and truncate should not deadlock"
11060 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11061 $LCTL clear # bug 18514
11062 $LCTL debug_daemon start $TMP/${tfile}_log_good
11064 $LCTL debug_daemon stop
11065 sed -e "s/^...../a/g" $TMP/${tfile}_log_good > $TMP/${tfile}_log_bad ||
11066 error "sed failed to read log_good"
11068 $LCTL debug_daemon start $TMP/${tfile}_log_good
11070 $LCTL debug_daemon stop
11072 $LCTL df $TMP/${tfile}_log_bad > $TMP/${tfile}_log_bad.out 2>&1 ||
11073 error "lctl df log_bad failed"
11075 local bad_line=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $9}')
11076 local good_line1=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $5}')
11078 $LCTL df $TMP/${tfile}_log_good > $TMP/${tfile}_log_good.out 2>&1
11079 local good_line2=$(tail -n 1 $TMP/${tfile}_log_good.out | awk '{print $5}')
11081 [ "$bad_line" ] && [ "$good_line1" ] && [ "$good_line2" ] ||
11082 error "bad_line good_line1 good_line2 are empty"
11084 cat $TMP/${tfile}_log_good >> $TMP/${tfile}_logs_corrupt
11085 cat $TMP/${tfile}_log_bad >> $TMP/${tfile}_logs_corrupt
11086 cat $TMP/${tfile}_log_good >> $TMP/${tfile}_logs_corrupt
11088 $LCTL df $TMP/${tfile}_logs_corrupt > $TMP/${tfile}_log_bad.out 2>&1
11089 local bad_line_new=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $9}')
11090 local good_line_new=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $5}')
11092 [ "$bad_line_new" ] && [ "$good_line_new" ] ||
11093 error "bad_line_new good_line_new are empty"
11095 local expected_good=$((good_line1 + good_line2*2))
11097 rm -f $TMP/${tfile}*
11098 # LU-231, short malformed line may not be counted into bad lines
11099 if [ $bad_line -ne $bad_line_new ] &&
11100 [ $bad_line -ne $((bad_line_new - 1)) ]; then
11101 error "expected $bad_line bad lines, but got $bad_line_new"
11105 if [ $expected_good -ne $good_line_new ]; then
11106 error "expected $expected_good good lines, but got $good_line_new"
11111 run_test 170 "test lctl df to handle corrupted log ====================="
11113 test_171() { # bug20592
11114 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11115 #define OBD_FAIL_PTLRPC_DUMP_LOG 0x50e
11116 $LCTL set_param fail_loc=0x50e
11117 $LCTL set_param fail_val=3000
11118 multiop_bg_pause $DIR/$tfile O_s || true
11120 kill -USR1 $MULTIPID
11124 if dmesg | grep "recursive fault"; then
11125 error "caught a recursive fault"
11127 $LCTL set_param fail_loc=0
11130 run_test 171 "test libcfs_debug_dumplog_thread stuck in do_exit() ======"
11132 # it would be good to share it with obdfilter-survey/iokit-libecho code
11133 setup_obdecho_osc () {
11136 local obdfilter_name=$2
11137 echo "Creating new osc for $obdfilter_name on $ost_nid"
11138 # make sure we can find loopback nid
11139 $LCTL add_uuid $ost_nid $ost_nid >/dev/null 2>&1
11141 [ $rc -eq 0 ] && { $LCTL attach osc ${obdfilter_name}_osc \
11142 ${obdfilter_name}_osc_UUID || rc=2; }
11143 [ $rc -eq 0 ] && { $LCTL --device ${obdfilter_name}_osc setup \
11144 ${obdfilter_name}_UUID $ost_nid || rc=3; }
11148 cleanup_obdecho_osc () {
11149 local obdfilter_name=$1
11150 $LCTL --device ${obdfilter_name}_osc cleanup >/dev/null
11151 $LCTL --device ${obdfilter_name}_osc detach >/dev/null
11158 local pages=${3:-64}
11163 local obd_size=$(get_obd_size $node $OBD)
11164 local page_size=$(get_page_size $node)
11165 if [[ -n "$obd_size" ]]; then
11166 local new_count=$((obd_size / (pages * page_size / 1024)))
11167 [[ $new_count -ge $count ]] || count=$new_count
11170 do_facet $node "$LCTL attach echo_client ec ec_uuid" || rc=1
11171 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec setup $OBD" ||
11173 if [ $rc -eq 0 ]; then
11174 id=$(do_facet $node "$LCTL --device ec create 1" | awk '/object id/ {print $6}')
11175 [ ${PIPESTATUS[0]} -eq 0 -a -n "$id" ] || rc=3
11177 echo "New object id is $id"
11178 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec getattr $id" ||
11180 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec " \
11181 "test_brw $count w v $pages $id" || rc=4; }
11182 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec destroy $id 1" ||
11184 [ $rc -eq 0 -o $rc -gt 2 ] && { do_facet $node "$LCTL --device ec " \
11185 "cleanup" || rc=5; }
11186 [ $rc -eq 0 -o $rc -gt 1 ] && { do_facet $node "$LCTL --device ec " \
11187 "detach" || rc=6; }
11188 [ $rc -ne 0 ] && echo "obecho_create_test failed: $rc"
11193 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11194 remote_ost_nodsh && skip "remote OST with nodsh" && return
11196 local rmmod_local=0
11198 if ! module_loaded obdecho; then
11199 load_module obdecho/obdecho
11203 local osc=$($LCTL dl | grep -v mdt | awk '$3 == "osc" {print $4; exit}')
11204 local host=$(lctl get_param -n osc.$osc.import |
11205 awk '/current_connection:/ {print $2}' )
11206 local target=$(lctl get_param -n osc.$osc.import |
11207 awk '/target:/ {print $2}' )
11208 target=${target%_UUID}
11210 [[ -n $target ]] && { setup_obdecho_osc $host $target || rc=1; } || rc=1
11211 [ $rc -eq 0 ] && { obdecho_test ${target}_osc client || rc=2; }
11212 [[ -n $target ]] && cleanup_obdecho_osc $target
11213 [ $rmmod_local -eq 1 ] && rmmod obdecho
11216 run_test 180a "test obdecho on osc"
11219 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11220 remote_ost_nodsh && skip "remote OST with nodsh" && return
11222 local rmmod_remote=0
11224 do_facet ost1 "lsmod | grep -q obdecho || " \
11225 "{ insmod ${LUSTRE}/obdecho/obdecho.ko || " \
11226 "modprobe obdecho; }" && rmmod_remote=1
11227 target=$(do_facet ost1 $LCTL dl | awk '/obdfilter/ {print $4;exit}')
11228 [[ -n $target ]] && { obdecho_test $target ost1 || rc=1; }
11229 [ $rmmod_remote -eq 1 ] && do_facet ost1 "rmmod obdecho"
11232 run_test 180b "test obdecho directly on obdfilter"
11234 test_180c() { # LU-2598
11235 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11236 remote_ost_nodsh && skip "remote OST with nodsh" && return
11237 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.0) ]] &&
11238 skip "Need MDS version at least 2.4.0" && return
11241 local rmmod_remote=false
11242 local pages=16384 # 64MB bulk I/O RPC size
11245 do_rpc_nodes $(facet_active_host ost1) load_module obdecho/obdecho &&
11246 rmmod_remote=true || error "failed to load module obdecho"
11248 target=$(do_facet ost1 $LCTL dl | awk '/obdfilter/ { print $4 }' |
11250 if [ -n "$target" ]; then
11251 obdecho_test "$target" ost1 "$pages" || rc=${PIPESTATUS[0]}
11253 echo "there is no obdfilter target on ost1"
11256 $rmmod_remote && do_facet ost1 "rmmod obdecho" || true
11259 run_test 180c "test huge bulk I/O size on obdfilter, don't LASSERT"
11261 test_181() { # bug 22177
11262 test_mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
11263 # create enough files to index the directory
11264 createmany -o $DIR/$tdir/foobar 4000
11265 # print attributes for debug purpose
11268 multiop_bg_pause $DIR/$tdir D_Sc || return 1
11270 # remove the files & current working dir
11271 unlinkmany $DIR/$tdir/foobar 4000
11273 kill -USR1 $MULTIPID
11275 stat $DIR/$tdir && error "open-unlinked dir was not removed!"
11278 run_test 181 "Test open-unlinked dir ========================"
11284 mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
11286 $LCTL set_param mdc.*.rpc_stats=clear
11288 for (( i = 0; i < $tcount; i++ )) ; do
11289 mkdir $DIR/$tdir/$i
11292 for (( i = 0; i < $tcount; i++ )) ; do
11293 createmany -o $DIR/$tdir/$i/f- $fcount &
11297 for (( i = 0; i < $tcount; i++ )) ; do
11298 unlinkmany $DIR/$tdir/$i/f- $fcount &
11302 $LCTL get_param mdc.*.rpc_stats
11306 run_test 182 "Test parallel modify metadata operations ================"
11308 test_183() { # LU-2275
11309 remote_mds_nodsh && skip "remote MDS with nodsh" && return
11310 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.3.56) ]] &&
11311 skip "Need MDS version at least 2.3.56" && return
11313 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11314 mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
11315 echo aaa > $DIR/$tdir/$tfile
11317 #define OBD_FAIL_MDS_NEGATIVE_POSITIVE 0x148
11318 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x148
11320 ls -l $DIR/$tdir && error "ls succeeded, should have failed"
11321 cat $DIR/$tdir/$tfile && error "cat succeeded, should have failed"
11323 do_facet $SINGLEMDS $LCTL set_param fail_loc=0
11325 # Flush negative dentry cache
11326 touch $DIR/$tdir/$tfile
11328 # We are not checking for any leaked references here, they'll
11329 # become evident next time we do cleanup with module unload.
11332 run_test 183 "No crash or request leak in case of strange dispositions ========"
11334 # test suite 184 is for LU-2016, LU-2017
11336 check_swap_layouts_support && return 0
11338 dir0=$DIR/$tdir/$testnum
11339 test_mkdir -p -c1 $dir0 || error "creating dir $dir0"
11344 $SETSTRIPE -c1 $file1
11346 $SETSTRIPE -c2 $file2
11348 gen1=$($GETSTRIPE -g $file1)
11349 gen2=$($GETSTRIPE -g $file2)
11351 $LFS swap_layouts $file1 $file2 || error "swap of file layout failed"
11352 gen=$($GETSTRIPE -g $file1)
11353 [[ $gen1 != $gen ]] ||
11354 "Layout generation on $file1 does not change"
11355 gen=$($GETSTRIPE -g $file2)
11356 [[ $gen2 != $gen ]] ||
11357 "Layout generation on $file2 does not change"
11359 cmp $ref1 $file2 || error "content compare failed ($ref1 != $file2)"
11360 cmp $ref2 $file1 || error "content compare failed ($ref2 != $file1)"
11362 run_test 184a "Basic layout swap"
11365 check_swap_layouts_support && return 0
11367 dir0=$DIR/$tdir/$testnum
11368 mkdir -p $dir0 || error "creating dir $dir0"
11375 $SETSTRIPE -c1 $file1
11376 $SETSTRIPE -c2 $file2
11377 $SETSTRIPE -c1 $file3
11378 chown $RUNAS_ID $file3
11379 gen1=$($GETSTRIPE -g $file1)
11380 gen2=$($GETSTRIPE -g $file2)
11382 $LFS swap_layouts $dir1 $dir2 &&
11383 error "swap of directories layouts should fail"
11384 $LFS swap_layouts $dir1 $file1 &&
11385 error "swap of directory and file layouts should fail"
11386 $RUNAS $LFS swap_layouts $file1 $file2 &&
11387 error "swap of file we cannot write should fail"
11388 $LFS swap_layouts $file1 $file3 &&
11389 error "swap of file with different owner should fail"
11390 /bin/true # to clear error code
11392 run_test 184b "Forbidden layout swap (will generate errors)"
11395 check_swap_layouts_support && return 0
11397 local dir0=$DIR/$tdir/$testnum
11398 mkdir -p $dir0 || error "creating dir $dir0"
11400 local ref1=$dir0/ref1
11401 local ref2=$dir0/ref2
11402 local file1=$dir0/file1
11403 local file2=$dir0/file2
11404 # create a file large enough for the concurrent test
11405 dd if=/dev/urandom of=$ref1 bs=1M count=$((RANDOM % 50 + 20))
11406 dd if=/dev/urandom of=$ref2 bs=1M count=$((RANDOM % 50 + 20))
11407 echo "ref file size: ref1($(stat -c %s $ref1))," \
11408 "ref2($(stat -c %s $ref2))"
11411 dd if=$ref1 of=$file1 bs=16k &
11414 # Make sure dd starts to copy file
11415 while [ ! -f $file1 ]; do sleep 0.1; done
11417 $LFS swap_layouts $file1 $file2
11420 [[ $? == 0 ]] || error "concurrent write on $file1 failed"
11421 [[ $rc == 0 ]] || error "swap of $file1 and $file2 failed"
11423 # how many bytes copied before swapping layout
11424 local copied=$(stat -c %s $file2)
11425 local remaining=$(stat -c %s $ref1)
11426 remaining=$((remaining - copied))
11427 echo "Copied $copied bytes before swapping layout..."
11429 cmp -n $copied $file1 $ref2 | grep differ &&
11430 error "Content mismatch [0, $copied) of ref2 and file1"
11431 cmp -n $copied $file2 $ref1 ||
11432 error "Content mismatch [0, $copied) of ref1 and file2"
11433 cmp -i $copied:$copied -n $remaining $file1 $ref1 ||
11434 error "Content mismatch [$copied, EOF) of ref1 and file1"
11437 rm -f $ref1 $ref2 $file1 $file2
11439 run_test 184c "Concurrent write and layout swap"
11442 check_swap_layouts_support && return 0
11443 [ -z "$(which getfattr 2>/dev/null)" ] &&
11444 skip "no getfattr command" && return 0
11446 local file1=$DIR/$tdir/$tfile-1
11447 local file2=$DIR/$tdir/$tfile-2
11448 local file3=$DIR/$tdir/$tfile-3
11452 mkdir -p $DIR/$tdir
11453 touch $file1 || error "create $file1 failed"
11454 $OPENFILE -f O_CREAT:O_LOV_DELAY_CREATE $file2 ||
11455 error "create $file2 failed"
11456 $OPENFILE -f O_CREAT:O_LOV_DELAY_CREATE $file3 ||
11457 error "create $file3 failed"
11458 lovea1=$($LFS getstripe $file1 | sed 1d)
11460 $LFS swap_layouts $file2 $file3 ||
11461 error "swap $file2 $file3 layouts failed"
11462 $LFS swap_layouts $file1 $file2 ||
11463 error "swap $file1 $file2 layouts failed"
11465 lovea2=$($LFS getstripe $file2 | sed 1d)
11466 [ "$lovea1" == "$lovea2" ] || error "lovea $lovea1 != $lovea2"
11468 lovea1=$(getfattr -n trusted.lov $file1 | grep ^trusted)
11469 [[ -z "$lovea1" ]] || error "$file1 shouldn't have lovea"
11471 run_test 184d "allow stripeless layouts swap"
11474 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.6.94) ]] ||
11475 { skip "Need MDS version at least 2.6.94"; return 0; }
11476 check_swap_layouts_support && return 0
11477 [ -z "$(which getfattr 2>/dev/null)" ] &&
11478 skip "no getfattr command" && return 0
11480 local file1=$DIR/$tdir/$tfile-1
11481 local file2=$DIR/$tdir/$tfile-2
11482 local file3=$DIR/$tdir/$tfile-3
11485 mkdir -p $DIR/$tdir
11486 touch $file1 || error "create $file1 failed"
11487 $OPENFILE -f O_CREAT:O_LOV_DELAY_CREATE $file2 ||
11488 error "create $file2 failed"
11489 $OPENFILE -f O_CREAT:O_LOV_DELAY_CREATE $file3 ||
11490 error "create $file3 failed"
11492 $LFS swap_layouts $file1 $file2 ||
11493 error "swap $file1 $file2 layouts failed"
11495 lovea=$(getfattr -n trusted.lov $file1 | grep ^trusted)
11496 [[ -z "$lovea" ]] || error "$file1 shouldn't have lovea"
11498 echo 123 > $file1 || error "Should be able to write into $file1"
11500 $LFS swap_layouts $file1 $file3 ||
11501 error "swap $file1 $file3 layouts failed"
11503 echo 123 > $file1 || error "Should be able to write into $file1"
11505 rm -rf $file1 $file2 $file3
11507 run_test 184e "Recreate layout after stripeless layout swaps"
11509 test_185() { # LU-2441
11510 # LU-3553 - no volatile file support in old servers
11511 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.3.60) ]] ||
11512 { skip "Need MDS version at least 2.3.60"; return 0; }
11514 mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
11515 touch $DIR/$tdir/spoo
11516 local mtime1=$(stat -c "%Y" $DIR/$tdir)
11517 local fid=$($MULTIOP $DIR/$tdir VFw4096c) ||
11518 error "cannot create/write a volatile file"
11519 [ "$FILESET" == "" ] &&
11520 $CHECKSTAT -t file $MOUNT/.lustre/fid/$fid 2>/dev/null &&
11521 error "FID is still valid after close"
11523 multiop_bg_pause $DIR/$tdir vVw4096_c
11530 # assume that the next FID for this client is sequential, since stdout
11531 # is unfortunately eaten by multiop_bg_pause
11532 local n=$((${fidv[1]} + 1))
11533 local next_fid="${fidv[0]}:$(printf "0x%x" $n):${fidv[2]}"
11534 if [ "$FILESET" == "" ]; then
11535 $CHECKSTAT -t file $MOUNT/.lustre/fid/$next_fid ||
11536 error "FID is missing before close"
11538 kill -USR1 $multi_pid
11539 # 1 second delay, so if mtime change we will see it
11541 local mtime2=$(stat -c "%Y" $DIR/$tdir)
11542 [[ $mtime1 == $mtime2 ]] || error "mtime has changed"
11544 run_test 185 "Volatile file support"
11547 remote_mds_nodsh && skip "remote MDS with nodsh" && return
11548 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.3.0) ] &&
11549 skip "Need MDS version at least 2.3.0" && return
11551 local dir0=$DIR/$tdir/$testnum
11552 mkdir -p $dir0 || error "creating dir $dir0"
11554 local file=$dir0/file1
11555 dd if=/dev/urandom of=$file count=10 bs=1M conv=fsync
11556 local dv1=$($LFS data_version $file)
11557 dd if=/dev/urandom of=$file seek=10 count=1 bs=1M conv=fsync
11558 local dv2=$($LFS data_version $file)
11559 [[ $dv1 != $dv2 ]] ||
11560 error "data version did not change on write $dv1 == $dv2"
11565 run_test 187a "Test data version change"
11568 remote_mds_nodsh && skip "remote MDS with nodsh" && return
11569 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.3.0) ] &&
11570 skip "Need MDS version at least 2.3.0" && return
11572 local dir0=$DIR/$tdir/$testnum
11573 mkdir -p $dir0 || error "creating dir $dir0"
11575 declare -a DV=$($MULTIOP $dir0 Vw1000xYw1000xY | cut -f3 -d" ")
11576 [[ ${DV[0]} != ${DV[1]} ]] ||
11577 error "data version did not change on write"\
11578 " ${DV[0]} == ${DV[1]}"
11583 run_test 187b "Test data version change on volatile file"
11586 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11587 remote_mgs_nodsh && skip "remote MGS with nodsh" && return
11588 [ -n "$FILESET" ] && skip "SKIP due to FILESET set" && return
11590 local POOL=${POOL:-cea1}
11591 local POOL_ROOT=${POOL_ROOT:-$DIR/d200.pools}
11592 local POOL_DIR_NAME=${POOL_DIR_NAME:-dir_tst}
11595 local last_ost=$(($OSTCOUNT - 1))
11597 local ost_list=$(seq $first_ost $ost_step $last_ost)
11598 local ost_range="$first_ost $last_ost $ost_step"
11599 local test_path=$POOL_ROOT/$POOL_DIR_NAME
11600 local file_dir=$POOL_ROOT/file_tst
11601 local subdir=$test_path/subdir
11605 # former test_200a test_200b
11606 pool_add $POOL || { rc=$? ; break; }
11607 pool_add_targets $POOL $ost_range || { rc=$? ; break; }
11608 # former test_200c test_200d
11609 mkdir -p $test_path
11610 pool_set_dir $POOL $test_path || { rc=$? ; break; }
11611 pool_check_dir $POOL $test_path || { rc=$? ; break; }
11613 pool_check_dir $POOL $subdir || { rc=$? ; break; }
11614 pool_dir_rel_path $POOL $POOL_DIR_NAME $POOL_ROOT \
11615 || { rc=$? ; break; }
11616 # former test_200e test_200f
11617 local files=$((OSTCOUNT*3))
11618 pool_alloc_files $POOL $test_path $files "$ost_list" \
11619 || { rc=$? ; break; }
11620 pool_create_files $POOL $file_dir $files "$ost_list" \
11621 || { rc=$? ; break; }
11622 # former test_200g test_200h
11623 pool_lfs_df $POOL || { rc=$? ; break; }
11624 pool_file_rel_path $POOL $test_path || { rc=$? ; break; }
11626 # former test_201a test_201b test_201c
11627 pool_remove_first_target $POOL || { rc=$? ; break; }
11629 local f=$test_path/$tfile
11630 pool_remove_all_targets $POOL $f || { rc=$? ; break; }
11631 pool_remove $POOL $f || { rc=$? ; break; }
11638 run_test 200 "OST pools"
11640 # usage: default_attr <count | size | offset>
11642 $LCTL get_param -n lov.$FSNAME-clilov-\*.stripe${1}
11645 # usage: check_default_stripe_attr
11646 check_default_stripe_attr() {
11647 ACTUAL=$($GETSTRIPE $* $DIR/$tdir)
11649 --stripe-count|--count)
11650 [ -n "$2" ] && EXPECTED=0 || EXPECTED=$(default_attr count);;
11651 --stripe-size|--size)
11652 [ -n "$2" ] && EXPECTED=0 || EXPECTED=$(default_attr size);;
11653 --stripe-index|--index)
11656 error "unknown getstripe attr '$1'"
11659 [ $ACTUAL != $EXPECTED ] &&
11660 error "$DIR/$tdir has $1 '$ACTUAL', not '$EXPECTED'"
11664 test_mkdir -p $DIR/$tdir
11665 $SETSTRIPE --stripe-count 0 --stripe-size 0 --stripe-index -1 $DIR/$tdir
11667 check_default_stripe_attr --stripe-count
11668 check_default_stripe_attr --stripe-size
11669 check_default_stripe_attr --stripe-index
11673 run_test 204a "Print default stripe attributes ================="
11676 test_mkdir -p $DIR/$tdir
11677 $SETSTRIPE --stripe-count 1 $DIR/$tdir
11679 check_default_stripe_attr --stripe-size
11680 check_default_stripe_attr --stripe-index
11684 run_test 204b "Print default stripe size and offset ==========="
11687 test_mkdir -p $DIR/$tdir
11688 $SETSTRIPE --stripe-size 65536 $DIR/$tdir
11690 check_default_stripe_attr --stripe-count
11691 check_default_stripe_attr --stripe-index
11695 run_test 204c "Print default stripe count and offset ==========="
11698 test_mkdir -p $DIR/$tdir
11699 $SETSTRIPE --stripe-index 0 $DIR/$tdir
11701 check_default_stripe_attr --stripe-count
11702 check_default_stripe_attr --stripe-size
11706 run_test 204d "Print default stripe count and size ============="
11709 test_mkdir -p $DIR/$tdir
11710 $SETSTRIPE -d $DIR/$tdir
11712 check_default_stripe_attr --stripe-count --raw
11713 check_default_stripe_attr --stripe-size --raw
11714 check_default_stripe_attr --stripe-index --raw
11718 run_test 204e "Print raw stripe attributes ================="
11721 test_mkdir -p $DIR/$tdir
11722 $SETSTRIPE --stripe-count 1 $DIR/$tdir
11724 check_default_stripe_attr --stripe-size --raw
11725 check_default_stripe_attr --stripe-index --raw
11729 run_test 204f "Print raw stripe size and offset ==========="
11732 test_mkdir -p $DIR/$tdir
11733 $SETSTRIPE --stripe-size 65536 $DIR/$tdir
11735 check_default_stripe_attr --stripe-count --raw
11736 check_default_stripe_attr --stripe-index --raw
11740 run_test 204g "Print raw stripe count and offset ==========="
11743 test_mkdir -p $DIR/$tdir
11744 $SETSTRIPE --stripe-index 0 $DIR/$tdir
11746 check_default_stripe_attr --stripe-count --raw
11747 check_default_stripe_attr --stripe-size --raw
11751 run_test 204h "Print raw stripe count and size ============="
11753 # Figure out which job scheduler is being used, if any,
11754 # or use a fake one
11755 if [ -n "$SLURM_JOB_ID" ]; then # SLURM
11756 JOBENV=SLURM_JOB_ID
11757 elif [ -n "$LSB_JOBID" ]; then # Load Sharing Facility
11759 elif [ -n "$PBS_JOBID" ]; then # PBS/Maui/Moab
11761 elif [ -n "$LOADL_STEPID" ]; then # LoadLeveller
11762 JOBENV=LOADL_STEP_ID
11763 elif [ -n "$JOB_ID" ]; then # Sun Grid Engine
11766 $LCTL list_param jobid_name > /dev/null 2>&1
11767 if [ $? -eq 0 ]; then
11774 verify_jobstats() {
11779 # we don't really need to clear the stats for this test to work, since each
11780 # command has a unique jobid, but it makes debugging easier if needed.
11781 # for facet in $facets; do
11782 # local dev=$(convert_facet2label $facet)
11783 # # clear old jobstats
11784 # do_facet $facet lctl set_param *.$dev.job_stats="clear"
11787 # use a new JobID for each test, or we might see an old one
11788 [ "$JOBENV" = "FAKE_JOBID" ] &&
11789 FAKE_JOBID=id.$testnum.$(basename ${cmd[0]}).$RANDOM
11793 [ "$JOBENV" = "nodelocal" ] && {
11794 FAKE_JOBID=id.$testnum.$(basename ${cmd[0]}).$RANDOM
11795 $LCTL set_param jobid_name=$FAKE_JOBID
11799 log "Test: ${cmd[*]}"
11800 log "Using JobID environment variable $JOBENV=$JOBVAL"
11802 if [ $JOBENV = "FAKE_JOBID" ]; then
11803 FAKE_JOBID=$JOBVAL ${cmd[*]}
11808 # all files are created on OST0000
11809 for facet in $facets; do
11810 local stats="*.$(convert_facet2label $facet).job_stats"
11811 if [ $(do_facet $facet lctl get_param $stats |
11812 grep -c $JOBVAL) -ne 1 ]; then
11813 do_facet $facet lctl get_param $stats
11814 error "No jobstats for $JOBVAL found on $facet::$stats"
11821 NEW_JOBENV=${1:-$OLD_JOBENV}
11822 do_facet mgs $LCTL conf_param $FSNAME.sys.jobid_var=$NEW_JOBENV
11823 wait_update $HOSTNAME "$LCTL get_param -n jobid_var" $NEW_JOBENV
11827 do_facet $SINGLEMDS \
11828 $LCTL set_param mdt.*.job_cleanup_interval=$OLD_INTERVAL
11829 [ $OLD_JOBENV != $JOBENV ] && jobstats_set $OLD_JOBENV
11830 do_facet $SINGLEMDS lctl --device $MDT0 changelog_deregister $CL_USER
11833 test_205() { # Job stats
11834 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11835 remote_mgs_nodsh && skip "remote MGS with nodsh" && return
11836 remote_mds_nodsh && skip "remote MDS with nodsh" && return
11837 remote_ost_nodsh && skip "remote OST with nodsh" && return
11839 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep jobstats)" ] &&
11840 skip "Server doesn't support jobstats" && return 0
11841 [[ $JOBID_VAR = disable ]] && skip "jobstats is disabled" && return
11843 OLD_JOBENV=$($LCTL get_param -n jobid_var)
11844 if [ $OLD_JOBENV != $JOBENV ]; then
11845 jobstats_set $JOBENV
11846 trap cleanup_205 EXIT
11849 CL_USER=$(do_facet $SINGLEMDS lctl --device $MDT0 changelog_register -n)
11850 echo "Registered as changelog user $CL_USER"
11852 OLD_INTERVAL=$(do_facet $SINGLEMDS \
11853 lctl get_param -n mdt.*.job_cleanup_interval)
11854 local interval_new=5
11855 do_facet $SINGLEMDS \
11856 $LCTL set_param mdt.*.job_cleanup_interval=$interval_new
11857 local start=$SECONDS
11861 cmd="mkdir $DIR/$tdir"
11862 verify_jobstats "$cmd" "$SINGLEMDS"
11864 cmd="rmdir $DIR/$tdir"
11865 verify_jobstats "$cmd" "$SINGLEMDS"
11866 # mkdir on secondary MDT
11867 if [ $MDSCOUNT -gt 1 ]; then
11868 cmd="lfs mkdir -i 1 $DIR/$tdir.remote"
11869 verify_jobstats "$cmd" "mds2"
11872 cmd="mknod $DIR/$tfile c 1 3"
11873 verify_jobstats "$cmd" "$SINGLEMDS"
11875 cmd="rm -f $DIR/$tfile"
11876 verify_jobstats "$cmd" "$SINGLEMDS"
11877 # create all files on OST0000 so verify_jobstats can find OST stats
11879 cmd="$SETSTRIPE -i 0 -c 1 $DIR/$tfile"
11880 verify_jobstats "$cmd" "$SINGLEMDS"
11882 cmd="touch $DIR/$tfile"
11883 verify_jobstats "$cmd" "$SINGLEMDS ost1"
11885 cmd="dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 oflag=sync"
11886 verify_jobstats "$cmd" "ost1"
11888 cancel_lru_locks osc
11889 cmd="dd if=$DIR/$tfile of=/dev/null bs=1M count=1 iflag=direct"
11890 verify_jobstats "$cmd" "ost1"
11892 cmd="$TRUNCATE $DIR/$tfile 0"
11893 verify_jobstats "$cmd" "$SINGLEMDS ost1"
11895 cmd="mv -f $DIR/$tfile $DIR/$tdir.rename"
11896 verify_jobstats "$cmd" "$SINGLEMDS"
11897 # jobstats expiry - sleep until old stats should be expired
11898 local left=$((interval_new + 2 - (SECONDS - start)))
11899 [ $left -ge 0 ] && echo "sleep $left for expiry" && sleep $((left + 1))
11900 cmd="mkdir $DIR/$tdir.expire"
11901 verify_jobstats "$cmd" "$SINGLEMDS"
11902 [ $(do_facet $SINGLEMDS lctl get_param *.*.job_stats |
11903 grep -c "job_id.*mkdir") -gt 1 ] && error "old jobstats not expired"
11905 # Ensure that jobid are present in changelog (if supported by MDS)
11906 if [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.6.52) ]
11908 $LFS changelog $MDT0 | tail -9
11909 jobids=$($LFS changelog $MDT0 | tail -9 | grep -c "j=")
11910 [ $jobids -eq 9 ] ||
11911 error "Wrong changelog jobid count $jobids != 9"
11915 jobstats_set $JOBENV
11917 $LFS changelog $MDT0 | tail -1
11918 jobids=$($LFS changelog $MDT0 | tail -1 | grep -c "j=")
11919 [ $jobids -eq 0 ] ||
11920 error "Unexpected jobids when jobid_var=$JOBENV"
11925 run_test 205 "Verify job stats"
11927 # LU-1480, LU-1773 and LU-1657
11929 mkdir -p $DIR/$tdir
11930 $SETSTRIPE -c -1 $DIR/$tdir
11931 #define OBD_FAIL_LOV_INIT 0x1403
11932 $LCTL set_param fail_loc=0xa0001403
11933 $LCTL set_param fail_val=1
11934 touch $DIR/$tdir/$tfile || true
11936 run_test 206 "fail lov_init_raid0() doesn't lbug"
11939 dd if=/dev/zero of=$DIR/$tfile bs=4k count=$((RANDOM%10+1))
11940 local fsz=`stat -c %s $DIR/$tfile`
11941 cancel_lru_locks mdc
11943 # do not return layout in getattr intent
11944 #define OBD_FAIL_MDS_NO_LL_GETATTR 0x170
11945 $LCTL set_param fail_loc=0x170
11946 local sz=`stat -c %s $DIR/$tfile`
11948 [ $fsz -eq $sz ] || error "file size expected $fsz, actual $sz"
11952 run_test 207a "can refresh layout at glimpse"
11955 dd if=/dev/zero of=$DIR/$tfile bs=4k count=$((RANDOM%10+1))
11956 local cksum=`md5sum $DIR/$tfile`
11957 local fsz=`stat -c %s $DIR/$tfile`
11958 cancel_lru_locks mdc
11959 cancel_lru_locks osc
11961 # do not return layout in getattr intent
11962 #define OBD_FAIL_MDS_NO_LL_OPEN 0x171
11963 $LCTL set_param fail_loc=0x171
11965 # it will refresh layout after the file is opened but before read issues
11966 echo checksum is "$cksum"
11967 echo "$cksum" |md5sum -c --quiet || error "file differs"
11971 run_test 207b "can refresh layout at open"
11974 # FIXME: in this test suite, only RD lease is used. This is okay
11975 # for now as only exclusive open is supported. After generic lease
11976 # is done, this test suite should be revised. - Jinshan
11978 remote_mds_nodsh && skip "remote MDS with nodsh" && return
11979 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.4.52) ]] ||
11980 { skip "Need MDS version at least 2.4.52"; return 0; }
11982 echo "==== test 1: verify get lease work"
11983 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:eRE+eU || error "get lease error"
11985 echo "==== test 2: verify lease can be broken by upcoming open"
11986 $MULTIOP $DIR/$tfile oO_RDONLY:eR_E-eUc &
11990 $MULTIOP $DIR/$tfile oO_RDONLY:c
11991 kill -USR1 $PID && wait $PID || error "break lease error"
11993 echo "==== test 3: verify lease can't be granted if an open already exists"
11994 $MULTIOP $DIR/$tfile oO_RDONLY:_c &
11998 $MULTIOP $DIR/$tfile oO_RDONLY:eReUc && error "apply lease should fail"
11999 kill -USR1 $PID && wait $PID || error "open file error"
12001 echo "==== test 4: lease can sustain over recovery"
12002 $MULTIOP $DIR/$tfile oO_RDONLY:eR_E+eUc &
12008 kill -USR1 $PID && wait $PID || error "lease broken over recovery"
12010 echo "==== test 5: lease broken can't be regained by replay"
12011 $MULTIOP $DIR/$tfile oO_RDONLY:eR_E-eUc &
12015 # open file to break lease and then recovery
12016 $MULTIOP $DIR/$tfile oO_RDWR:c || error "open file error"
12019 kill -USR1 $PID && wait $PID || error "lease not broken over recovery"
12023 run_test 208 "Exclusive open"
12026 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep disp_stripe)" ] &&
12027 skip_env "must have disp_stripe" && return
12030 sync; sleep 5; sync;
12032 echo 3 > /proc/sys/vm/drop_caches
12033 req_before=$(awk '/ptlrpc_cache / { print $2 }' /proc/slabinfo)
12035 # open/close 500 times
12036 for i in $(seq 500); do
12040 echo 3 > /proc/sys/vm/drop_caches
12041 req_after=$(awk '/ptlrpc_cache / { print $2 }' /proc/slabinfo)
12043 echo "before: $req_before, after: $req_after"
12044 [ $((req_after - req_before)) -ge 300 ] &&
12045 error "open/close requests are not freed"
12048 run_test 209 "read-only open/close requests should be freed promptly"
12052 size=$((size % 8192 + 1))
12053 dd if=/dev/urandom of=$DIR/f212 bs=1k count=$size
12054 sendfile $DIR/f212 $DIR/f212.xyz || error "sendfile wrong"
12055 rm -f $DIR/f212 $DIR/f212.xyz
12057 run_test 212 "Sendfile test ============================================"
12060 dd if=/dev/zero of=$DIR/$tfile bs=4k count=4
12061 cancel_lru_locks osc
12062 lctl set_param fail_loc=0x8000040f
12063 # generate a read lock
12064 cat $DIR/$tfile > /dev/null
12065 # write to the file, it will try to cancel the above read lock.
12066 cat /etc/hosts >> $DIR/$tfile
12068 run_test 213 "OSC lock completion and cancel race don't crash - bug 18829"
12070 test_214() { # for bug 20133
12071 mkdir -p $DIR/$tdir/d214c || error "mkdir $DIR/$tdir/d214c failed"
12072 for (( i=0; i < 340; i++ )) ; do
12073 touch $DIR/$tdir/d214c/a$i
12076 ls -l $DIR/$tdir || error "ls -l $DIR/d214p failed"
12077 mv $DIR/$tdir/d214c $DIR/ || error "mv $DIR/d214p/d214c $DIR/ failed"
12078 ls $DIR/d214c || error "ls $DIR/d214c failed"
12079 rm -rf $DIR/$tdir || error "rm -rf $DIR/d214* failed"
12080 rm -rf $DIR/d214* || error "rm -rf $DIR/d214* failed"
12082 run_test 214 "hash-indexed directory test - bug 20133"
12084 # having "abc" as 1st arg, creates $TMP/lnet_abc.out and $TMP/lnet_abc.sys
12085 create_lnet_proc_files() {
12086 lctl get_param -n $1 >$TMP/lnet_$1.out || error "cannot read lnet.$1"
12087 sysctl lnet.$1 >$TMP/lnet_$1.sys_tmp || error "cannot read lnet.$1"
12089 sed "s/^lnet.$1\ =\ //g" "$TMP/lnet_$1.sys_tmp" >$TMP/lnet_$1.sys
12090 rm -f "$TMP/lnet_$1.sys_tmp"
12093 # counterpart of create_lnet_proc_files
12094 remove_lnet_proc_files() {
12095 rm -f $TMP/lnet_$1.out $TMP/lnet_$1.sys
12098 # uses 1st arg as trailing part of filename, 2nd arg as description for reports,
12099 # 3rd arg as regexp for body
12100 check_lnet_proc_stats() {
12101 local l=$(cat "$TMP/lnet_$1" |wc -l)
12102 [ $l = 1 ] || (cat "$TMP/lnet_$1" && error "$2 is not of 1 line: $l")
12104 grep -E "$3" "$TMP/lnet_$1" || (cat "$TMP/lnet_$1" && error "$2 misformatted")
12107 # uses 1st arg as trailing part of filename, 2nd arg as description for reports,
12108 # 3rd arg as regexp for body, 4th arg as regexp for 1st line, 5th arg is
12109 # optional and can be regexp for 2nd line (lnet.routes case)
12110 check_lnet_proc_entry() {
12111 local blp=2 # blp stands for 'position of 1st line of body'
12112 [ -z "$5" ] || blp=3 # lnet.routes case
12114 local l=$(cat "$TMP/lnet_$1" |wc -l)
12115 # subtracting one from $blp because the body can be empty
12116 [ "$l" -ge "$(($blp - 1))" ] || (cat "$TMP/lnet_$1" && error "$2 is too short: $l")
12118 sed -n '1 p' "$TMP/lnet_$1" |grep -E "$4" >/dev/null ||
12119 (cat "$TMP/lnet_$1" && error "1st line of $2 misformatted")
12121 [ "$5" = "" ] || sed -n '2 p' "$TMP/lnet_$1" |grep -E "$5" >/dev/null ||
12122 (cat "$TMP/lnet_$1" && error "2nd line of $2 misformatted")
12124 # bail out if any unexpected line happened
12125 sed -n "$blp p" "$TMP/lnet_$1" | grep -Ev "$3"
12126 [ "$?" != 0 ] || error "$2 misformatted"
12129 test_215() { # for bugs 18102, 21079, 21517
12130 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12131 local N='(0|[1-9][0-9]*)' # non-negative numeric
12132 local P='[1-9][0-9]*' # positive numeric
12133 local I='(0|-?[1-9][0-9]*|NA)' # any numeric (0 | >0 | <0) or NA if no value
12134 local NET='[a-z][a-z0-9]*' # LNET net like o2ib2
12135 local ADDR='[0-9.]+' # LNET addr like 10.0.0.1
12136 local NID="$ADDR@$NET" # LNET nid like 10.0.0.1@o2ib2
12138 local L1 # regexp for 1st line
12139 local L2 # regexp for 2nd line (optional)
12140 local BR # regexp for the rest (body)
12142 # lnet.stats should look as 11 space-separated non-negative numerics
12143 BR="^$N $N $N $N $N $N $N $N $N $N $N$"
12144 create_lnet_proc_files "stats"
12145 check_lnet_proc_stats "stats.sys" "lnet.stats" "$BR"
12146 remove_lnet_proc_files "stats"
12148 # lnet.routes should look like this:
12149 # Routing disabled/enabled
12150 # net hops priority state router
12151 # where net is a string like tcp0, hops > 0, priority >= 0,
12152 # state is up/down,
12153 # router is a string like 192.168.1.1@tcp2
12154 L1="^Routing (disabled|enabled)$"
12155 L2="^net +hops +priority +state +router$"
12156 BR="^$NET +$N +(0|1) +(up|down) +$NID$"
12157 create_lnet_proc_files "routes"
12158 check_lnet_proc_entry "routes.sys" "lnet.routes" "$BR" "$L1" "$L2"
12159 remove_lnet_proc_files "routes"
12161 # lnet.routers should look like this:
12162 # ref rtr_ref alive_cnt state last_ping ping_sent deadline down_ni router
12163 # where ref > 0, rtr_ref > 0, alive_cnt >= 0, state is up/down,
12164 # last_ping >= 0, ping_sent is boolean (0/1), deadline and down_ni are
12165 # numeric (0 or >0 or <0), router is a string like 192.168.1.1@tcp2
12166 L1="^ref +rtr_ref +alive_cnt +state +last_ping +ping_sent +deadline +down_ni +router$"
12167 BR="^$P +$P +$N +(up|down) +$N +(0|1) +$I +$I +$NID$"
12168 create_lnet_proc_files "routers"
12169 check_lnet_proc_entry "routers.sys" "lnet.routers" "$BR" "$L1"
12170 remove_lnet_proc_files "routers"
12172 # lnet.peers should look like this:
12173 # nid refs state last max rtr min tx min queue
12174 # where nid is a string like 192.168.1.1@tcp2, refs > 0,
12175 # state is up/down/NA, max >= 0. last, rtr, min, tx, min are
12176 # numeric (0 or >0 or <0), queue >= 0.
12177 L1="^nid +refs +state +last +max +rtr +min +tx +min +queue$"
12178 BR="^$NID +$P +(up|down|NA) +$I +$N +$I +$I +$I +$I +$N$"
12179 create_lnet_proc_files "peers"
12180 check_lnet_proc_entry "peers.sys" "lnet.peers" "$BR" "$L1"
12181 remove_lnet_proc_files "peers"
12183 # lnet.buffers should look like this:
12184 # pages count credits min
12185 # where pages >=0, count >=0, credits and min are numeric (0 or >0 or <0)
12186 L1="^pages +count +credits +min$"
12187 BR="^ +$N +$N +$I +$I$"
12188 create_lnet_proc_files "buffers"
12189 check_lnet_proc_entry "buffers.sys" "lnet.buffers" "$BR" "$L1"
12190 remove_lnet_proc_files "buffers"
12192 # lnet.nis should look like this:
12193 # nid status alive refs peer rtr max tx min
12194 # where nid is a string like 192.168.1.1@tcp2, status is up/down,
12195 # alive is numeric (0 or >0 or <0), refs >= 0, peer >= 0,
12196 # rtr >= 0, max >=0, tx and min are numeric (0 or >0 or <0).
12197 L1="^nid +status +alive +refs +peer +rtr +max +tx +min$"
12198 BR="^$NID +(up|down) +$I +$N +$N +$N +$N +$I +$I$"
12199 create_lnet_proc_files "nis"
12200 check_lnet_proc_entry "nis.sys" "lnet.nis" "$BR" "$L1"
12201 remove_lnet_proc_files "nis"
12203 # can we successfully write to lnet.stats?
12204 lctl set_param -n stats=0 || error "cannot write to lnet.stats"
12205 sysctl -w lnet.stats=0 || error "cannot write to lnet.stats"
12207 run_test 215 "lnet exists and has proper content - bugs 18102, 21079, 21517"
12209 test_216() { # bug 20317
12210 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12211 remote_ost_nodsh && skip "remote OST with nodsh" && return
12214 local facets=$(get_facets OST)
12215 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
12217 save_lustre_params client "osc.*.contention_seconds" > $p
12218 save_lustre_params $facets \
12219 "ldlm.namespaces.filter-*.max_nolock_bytes" >> $p
12220 save_lustre_params $facets \
12221 "ldlm.namespaces.filter-*.contended_locks" >> $p
12222 save_lustre_params $facets \
12223 "ldlm.namespaces.filter-*.contention_seconds" >> $p
12226 # agressive lockless i/o settings
12227 for node in $(osts_nodes); do
12228 do_node $node 'lctl set_param -n ldlm.namespaces.filter-*.max_nolock_bytes 2000000; lctl set_param -n ldlm.namespaces.filter-*.contended_locks 0; lctl set_param -n ldlm.namespaces.filter-*.contention_seconds 60'
12230 lctl set_param -n osc.*.contention_seconds 60
12232 $DIRECTIO write $DIR/$tfile 0 10 4096
12233 $CHECKSTAT -s 40960 $DIR/$tfile
12235 # disable lockless i/o
12236 for node in $(osts_nodes); do
12237 do_node $node 'lctl set_param -n ldlm.namespaces.filter-*.max_nolock_bytes 0; lctl set_param -n ldlm.namespaces.filter-*.contended_locks 32; lctl set_param -n ldlm.namespaces.filter-*.contention_seconds 0'
12239 lctl set_param -n osc.*.contention_seconds 0
12242 dd if=/dev/zero of=$DIR/$tfile count=0
12243 $CHECKSTAT -s 0 $DIR/$tfile
12245 restore_lustre_params <$p
12249 run_test 216 "check lockless direct write works and updates file size and kms correctly"
12251 test_217() { # bug 22430
12252 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12256 for node in $(nodes_list); do
12257 nid=$(host_nids_address $node $NETTYPE)
12258 if [[ $nid = *-* ]] ; then
12259 echo "lctl ping $nid@$NETTYPE"
12260 lctl ping $nid@$NETTYPE
12262 echo "skipping $node (no hyphen detected)"
12266 run_test 217 "check lctl ping for hostnames with hiphen ('-')"
12269 # do directio so as not to populate the page cache
12270 log "creating a 10 Mb file"
12271 $MULTIOP $DIR/$tfile oO_CREAT:O_DIRECT:O_RDWR:w$((10*1048576))c || error "multiop failed while creating a file"
12272 log "starting reads"
12273 dd if=$DIR/$tfile of=/dev/null bs=4096 &
12274 log "truncating the file"
12275 $MULTIOP $DIR/$tfile oO_TRUNC:c || error "multiop failed while truncating the file"
12277 kill %+ || true # reads might have finished
12278 echo "wait until dd is finished"
12280 log "removing the temporary file"
12281 rm -rf $DIR/$tfile || error "tmp file removal failed"
12283 run_test 218 "parallel read and truncate should not deadlock ======================="
12286 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12287 # write one partial page
12288 dd if=/dev/zero of=$DIR/$tfile bs=1024 count=1
12289 # set no grant so vvp_io_commit_write will do sync write
12290 $LCTL set_param fail_loc=0x411
12291 # write a full page at the end of file
12292 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 seek=1 conv=notrunc
12294 $LCTL set_param fail_loc=0
12295 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 seek=3
12296 $LCTL set_param fail_loc=0x411
12297 dd if=/dev/zero of=$DIR/$tfile bs=1024 count=1 seek=2 conv=notrunc
12300 dd if=/dev/zero of=$DIR/$tfile-2 bs=1024 count=1
12301 $CHECKSTAT -s 1024 $DIR/$tfile-2 || error "checkstat wrong size"
12303 run_test 219 "LU-394: Write partial won't cause uncontiguous pages vec at LND"
12305 test_220() { #LU-325
12306 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12307 remote_ost_nodsh && skip "remote OST with nodsh" && return
12308 remote_mds_nodsh && skip "remote MDS with nodsh" && return
12309 remote_mgs_nodsh && skip "remote MGS with nodsh" && return
12312 # create on MDT0000 so the last_id and next_id are correct
12314 local OST=$($LFS df $DIR | awk '/OST:'$OSTIDX'/ { print $1 }')
12318 local mdtosc_proc1=$(get_mdtosc_proc_path $SINGLEMDS $OST)
12319 local last_id=$(do_facet $SINGLEMDS lctl get_param -n \
12320 osc.$mdtosc_proc1.prealloc_last_id)
12321 local next_id=$(do_facet $SINGLEMDS lctl get_param -n \
12322 osc.$mdtosc_proc1.prealloc_next_id)
12326 do_facet ost$((OSTIDX + 1)) lctl set_param fail_val=-1
12327 #define OBD_FAIL_OST_ENOINO 0x229
12328 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=0x229
12329 do_facet mgs $LCTL pool_new $FSNAME.$TESTNAME || return 1
12330 do_facet mgs $LCTL pool_add $FSNAME.$TESTNAME $OST || return 2
12332 $SETSTRIPE $DIR/$tdir -i $OSTIDX -c 1 -p $FSNAME.$TESTNAME
12334 MDSOBJS=$((last_id - next_id))
12335 echo "preallocated objects on MDS is $MDSOBJS" "($last_id - $next_id)"
12337 blocks=$($LFS df $MOUNT | awk '($1 == '$OSTIDX') { print $4 }')
12338 echo "OST still has $count kbytes free"
12340 echo "create $MDSOBJS files @next_id..."
12341 createmany -o $DIR/$tdir/f $MDSOBJS || return 3
12343 local last_id2=$(do_facet mds${MDSIDX} lctl get_param -n \
12344 osc.$mdtosc_proc1.prealloc_last_id)
12345 local next_id2=$(do_facet mds${MDSIDX} lctl get_param -n \
12346 osc.$mdtosc_proc1.prealloc_next_id)
12348 echo "after creation, last_id=$last_id2, next_id=$next_id2"
12353 do_facet ost$((OSTIDX + 1)) lctl set_param fail_val=0
12354 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=0
12356 do_facet mgs $LCTL pool_remove $FSNAME.$TESTNAME $OST || return 4
12357 do_facet mgs $LCTL pool_destroy $FSNAME.$TESTNAME || return 5
12358 echo "unlink $MDSOBJS files @$next_id..."
12359 unlinkmany $DIR/$tdir/f $MDSOBJS || return 6
12361 run_test 220 "preallocated MDS objects still used if ENOSPC from OST"
12364 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12365 dd if=`which date` of=$MOUNT/date oflag=sync
12366 chmod +x $MOUNT/date
12368 #define OBD_FAIL_LLITE_FAULT_TRUNC_RACE 0x1401
12369 $LCTL set_param fail_loc=0x80001401
12371 $MOUNT/date > /dev/null
12374 run_test 221 "make sure fault and truncate race to not cause OOM"
12377 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12379 test_mkdir -p $DIR/$tdir
12380 $SETSTRIPE -c 1 -i 0 $DIR/$tdir
12381 createmany -o $DIR/$tdir/$tfile 10
12382 cancel_lru_locks mdc
12383 cancel_lru_locks osc
12384 #define OBD_FAIL_LDLM_AGL_DELAY 0x31a
12385 $LCTL set_param fail_loc=0x31a
12386 ls -l $DIR/$tdir > /dev/null || error "AGL for ls failed"
12387 $LCTL set_param fail_loc=0
12390 run_test 222a "AGL for ls should not trigger CLIO lock failure ================"
12393 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12395 test_mkdir -p $DIR/$tdir
12396 $SETSTRIPE -c 1 -i 0 $DIR/$tdir
12397 createmany -o $DIR/$tdir/$tfile 10
12398 cancel_lru_locks mdc
12399 cancel_lru_locks osc
12400 #define OBD_FAIL_LDLM_AGL_DELAY 0x31a
12401 $LCTL set_param fail_loc=0x31a
12402 rm -r $DIR/$tdir || "AGL for rmdir failed"
12403 $LCTL set_param fail_loc=0
12405 run_test 222b "AGL for rmdir should not trigger CLIO lock failure ============="
12408 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12410 test_mkdir -p $DIR/$tdir
12411 $SETSTRIPE -c 1 -i 0 $DIR/$tdir
12412 createmany -o $DIR/$tdir/$tfile 10
12413 cancel_lru_locks mdc
12414 cancel_lru_locks osc
12415 #define OBD_FAIL_LDLM_AGL_NOLOCK 0x31b
12416 $LCTL set_param fail_loc=0x31b
12417 ls -l $DIR/$tdir > /dev/null || error "reenqueue failed"
12418 $LCTL set_param fail_loc=0
12421 run_test 223 "osc reenqueue if without AGL lock granted ======================="
12423 test_224a() { # LU-1039, MRP-303
12424 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12425 #define OBD_FAIL_PTLRPC_CLIENT_BULK_CB 0x508
12426 $LCTL set_param fail_loc=0x508
12427 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 conv=fsync
12428 $LCTL set_param fail_loc=0
12431 run_test 224a "Don't panic on bulk IO failure"
12433 test_224b() { # LU-1039, MRP-303
12434 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12435 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1
12436 cancel_lru_locks osc
12437 #define OBD_FAIL_PTLRPC_CLIENT_BULK_CB2 0x515
12438 $LCTL set_param fail_loc=0x515
12439 dd of=/dev/null if=$DIR/$tfile bs=4096 count=1
12440 $LCTL set_param fail_loc=0
12443 run_test 224b "Don't panic on bulk IO failure"
12445 test_224c() { # LU-6441
12446 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12447 local pages_per_rpc=$($LCTL get_param \
12448 osc.*.max_pages_per_rpc)
12449 local at_max=$($LCTL get_param -n at_max)
12450 local timeout=$($LCTL get_param -n timeout)
12451 local test_at="$LCTL get_param -n at_max"
12452 local param_at="$FSNAME.sys.at_max"
12453 local test_timeout="$LCTL get_param -n timeout"
12454 local param_timeout="$FSNAME.sys.timeout"
12456 $LCTL set_param -n osc.*.max_pages_per_rpc=1024
12458 set_conf_param_and_check client "$test_at" "$param_at" 0 ||
12459 error "conf_param at_max=0 failed"
12460 set_conf_param_and_check client "$test_timeout" "$param_timeout" 5 ||
12461 error "conf_param timeout=5 failed"
12463 #define OBD_FAIL_PTLRPC_CLIENT_BULK_CB3 0x520
12464 $LCTL set_param fail_loc=0x520
12465 dd if=/dev/zero of=$DIR/$tfile bs=8MB count=1
12467 $LCTL set_param fail_loc=0
12469 set_conf_param_and_check client "$test_at" "$param_at" $at_max ||
12470 error "conf_param at_max=$at_max failed"
12471 set_conf_param_and_check client "$test_timeout" "$param_timeout" \
12472 $timeout || error "conf_param timeout=$timeout failed"
12474 $LCTL set_param -n $pages_per_rpc
12476 run_test 224c "Don't hang if one of md lost during large bulk RPC"
12478 MDSSURVEY=${MDSSURVEY:-$(which mds-survey 2>/dev/null || true)}
12480 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12481 remote_mds_nodsh && skip "remote MDS with nodsh" && return
12482 if [ -z ${MDSSURVEY} ]; then
12483 skip_env "mds-survey not found" && return
12486 [ $MDSCOUNT -ge 2 ] &&
12487 skip "skipping now for more than one MDT" && return
12489 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.51) ] ||
12490 { skip "Need MDS version at least 2.2.51"; return; }
12492 local mds=$(facet_host $SINGLEMDS)
12493 local target=$(do_nodes $mds 'lctl dl' | \
12494 awk "{if (\$2 == \"UP\" && \$3 == \"mdt\") {print \$4}}")
12496 local cmd1="file_count=1000 thrhi=4"
12497 local cmd2="dir_count=2 layer=mdd stripe_count=0"
12498 local cmd3="rslt_loc=${TMP} targets=\"$mds:$target\" $MDSSURVEY"
12499 local cmd="$cmd1 $cmd2 $cmd3"
12501 rm -f ${TMP}/mds_survey*
12503 eval $cmd || error "mds-survey with zero-stripe failed"
12504 cat ${TMP}/mds_survey*
12505 rm -f ${TMP}/mds_survey*
12507 run_test 225a "Metadata survey sanity with zero-stripe"
12510 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12511 remote_mds_nodsh && skip "remote MDS with nodsh" && return
12512 if [ -z ${MDSSURVEY} ]; then
12513 skip_env "mds-survey not found" && return
12515 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.51) ] ||
12516 { skip "Need MDS version at least 2.2.51"; return; }
12518 if [ $($LCTL dl | grep -c osc) -eq 0 ]; then
12519 skip_env "Need to mount OST to test" && return
12522 [ $MDSCOUNT -ge 2 ] &&
12523 skip "skipping now for more than one MDT" && return
12524 local mds=$(facet_host $SINGLEMDS)
12525 local target=$(do_nodes $mds 'lctl dl' | \
12526 awk "{if (\$2 == \"UP\" && \$3 == \"mdt\") {print \$4}}")
12528 local cmd1="file_count=1000 thrhi=4"
12529 local cmd2="dir_count=2 layer=mdd stripe_count=1"
12530 local cmd3="rslt_loc=${TMP} targets=\"$mds:$target\" $MDSSURVEY"
12531 local cmd="$cmd1 $cmd2 $cmd3"
12533 rm -f ${TMP}/mds_survey*
12535 eval $cmd || error "mds-survey with stripe_count failed"
12536 cat ${TMP}/mds_survey*
12537 rm -f ${TMP}/mds_survey*
12539 run_test 225b "Metadata survey sanity with stripe_count = 1"
12541 mcreate_path2fid () {
12547 local path=$DIR/$tdir/$name
12552 $MCREATE --mode=$1 --major=$2 --minor=$3 $path ||
12553 error "cannot create $desc"
12555 fid=$($LFS path2fid $path | tr -d '[' | tr -d ']')
12557 [ $rc -ne 0 ] && error "cannot get fid of a $desc"
12559 fid_path=$($LFS fid2path $MOUNT $fid)
12561 [ $rc -ne 0 ] && error "cannot get path of $desc by $DIR $path $fid"
12563 [ "$path" == "$fid_path" ] ||
12564 error "fid2path returned $fid_path, expected $path"
12566 echo "pass with $path and $fid"
12571 mkdir -p $DIR/$tdir
12573 mcreate_path2fid 0010666 0 0 fifo "FIFO"
12574 mcreate_path2fid 0020666 1 3 null "character special file (null)"
12575 mcreate_path2fid 0020666 1 255 none "character special file (no device)"
12576 mcreate_path2fid 0040666 0 0 dir "directory"
12577 mcreate_path2fid 0060666 7 0 loop0 "block special file (loop)"
12578 mcreate_path2fid 0100666 0 0 file "regular file"
12579 mcreate_path2fid 0120666 0 0 link "symbolic link"
12580 mcreate_path2fid 0140666 0 0 sock "socket"
12582 run_test 226a "call path2fid and fid2path on files of all type"
12585 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
12589 mkdir -p $DIR/$tdir
12590 $LFS setdirstripe -i $MDTIDX $DIR/$tdir/remote_dir ||
12591 error "create remote directory failed"
12592 mcreate_path2fid 0010666 0 0 "remote_dir/fifo" "FIFO"
12593 mcreate_path2fid 0020666 1 3 "remote_dir/null" \
12594 "character special file (null)"
12595 mcreate_path2fid 0020666 1 255 "remote_dir/none" \
12596 "character special file (no device)"
12597 mcreate_path2fid 0040666 0 0 "remote_dir/dir" "directory"
12598 mcreate_path2fid 0060666 7 0 "remote_dir/loop0" \
12599 "block special file (loop)"
12600 mcreate_path2fid 0100666 0 0 "remote_dir/file" "regular file"
12601 mcreate_path2fid 0120666 0 0 "remote_dir/link" "symbolic link"
12602 mcreate_path2fid 0140666 0 0 "remote_dir/sock" "socket"
12604 run_test 226b "call path2fid and fid2path on files of all type under remote dir"
12606 # LU-1299 Executing or running ldd on a truncated executable does not
12607 # cause an out-of-memory condition.
12609 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12610 [ -z "$(which ldd)" ] && skip "should have ldd tool" && return
12611 dd if=$(which date) of=$MOUNT/date bs=1k count=1
12612 chmod +x $MOUNT/date
12614 $MOUNT/date > /dev/null
12615 ldd $MOUNT/date > /dev/null
12618 run_test 227 "running truncated executable does not cause OOM"
12620 # LU-1512 try to reuse idle OI blocks
12622 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12623 remote_mds_nodsh && skip "remote MDS with nodsh" && return
12624 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
12625 skip "non-ldiskfs backend" && return
12627 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
12628 local myDIR=$DIR/$tdir
12631 #define OBD_FAIL_SEQ_EXHAUST 0x1002
12632 $LCTL set_param fail_loc=0x80001002
12633 createmany -o $myDIR/t- 10000
12634 $LCTL set_param fail_loc=0
12635 # The guard is current the largest FID holder
12637 local SEQ=$($LFS path2fid $myDIR/guard | awk -F ':' '{print $1}' |
12639 local IDX=$(($SEQ % 64))
12641 do_facet $SINGLEMDS sync
12642 # Make sure journal flushed.
12644 local blk1=$(do_facet $SINGLEMDS \
12645 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
12646 grep Blockcount | awk '{print $4}')
12648 # Remove old files, some OI blocks will become idle.
12649 unlinkmany $myDIR/t- 10000
12650 # Create new files, idle OI blocks should be reused.
12651 createmany -o $myDIR/t- 2000
12652 do_facet $SINGLEMDS sync
12653 # Make sure journal flushed.
12655 local blk2=$(do_facet $SINGLEMDS \
12656 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
12657 grep Blockcount | awk '{print $4}')
12659 [ $blk1 == $blk2 ] || error "old blk1=$blk1, new blk2=$blk2, unmatched!"
12661 run_test 228a "try to reuse idle OI blocks"
12664 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12665 remote_mds_nodsh && skip "remote MDS with nodsh" && return
12666 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
12667 skip "non-ldiskfs backend" && return
12669 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
12670 local myDIR=$DIR/$tdir
12673 #define OBD_FAIL_SEQ_EXHAUST 0x1002
12674 $LCTL set_param fail_loc=0x80001002
12675 createmany -o $myDIR/t- 10000
12676 $LCTL set_param fail_loc=0
12677 # The guard is current the largest FID holder
12679 local SEQ=$($LFS path2fid $myDIR/guard | awk -F ':' '{print $1}' |
12681 local IDX=$(($SEQ % 64))
12683 do_facet $SINGLEMDS sync
12684 # Make sure journal flushed.
12686 local blk1=$(do_facet $SINGLEMDS \
12687 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
12688 grep Blockcount | awk '{print $4}')
12690 # Remove old files, some OI blocks will become idle.
12691 unlinkmany $myDIR/t- 10000
12694 stop $SINGLEMDS || error "Fail to stop MDT."
12696 start $SINGLEMDS $MDT_DEV $MDS_MOUNT_OPTS || error "Fail to start MDT."
12698 df $MOUNT || error "Fail to df."
12699 # Create new files, idle OI blocks should be reused.
12700 createmany -o $myDIR/t- 2000
12701 do_facet $SINGLEMDS sync
12702 # Make sure journal flushed.
12704 local blk2=$(do_facet $SINGLEMDS \
12705 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
12706 grep Blockcount | awk '{print $4}')
12708 [ $blk1 == $blk2 ] || error "old blk1=$blk1, new blk2=$blk2, unmatched!"
12710 run_test 228b "idle OI blocks can be reused after MDT restart"
12714 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12715 remote_mds_nodsh && skip "remote MDS with nodsh" && return
12716 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
12717 skip "non-ldiskfs backend" && return
12719 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
12720 local myDIR=$DIR/$tdir
12723 #define OBD_FAIL_SEQ_EXHAUST 0x1002
12724 $LCTL set_param fail_loc=0x80001002
12725 # 20000 files can guarantee there are index nodes in the OI file
12726 createmany -o $myDIR/t- 20000
12727 $LCTL set_param fail_loc=0
12728 # The guard is current the largest FID holder
12730 local SEQ=$($LFS path2fid $myDIR/guard | awk -F ':' '{print $1}' |
12732 local IDX=$(($SEQ % 64))
12734 do_facet $SINGLEMDS sync
12735 # Make sure journal flushed.
12737 local blk1=$(do_facet $SINGLEMDS \
12738 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
12739 grep Blockcount | awk '{print $4}')
12741 # Remove old files, some OI blocks will become idle.
12742 unlinkmany $myDIR/t- 20000
12744 # The OI file should become empty now
12746 # Create new files, idle OI blocks should be reused.
12747 createmany -o $myDIR/t- 2000
12748 do_facet $SINGLEMDS sync
12749 # Make sure journal flushed.
12751 local blk2=$(do_facet $SINGLEMDS \
12752 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
12753 grep Blockcount | awk '{print $4}')
12755 [ $blk1 == $blk2 ] || error "old blk1=$blk1, new blk2=$blk2, unmatched!"
12757 run_test 228c "NOT shrink the last entry in OI index node to recycle idle leaf"
12759 test_229() { # LU-2482, LU-3448
12760 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.53) ] &&
12761 skip "No HSM $(lustre_build_version $SINGLEMDS) MDS < 2.4.53" &&
12763 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12764 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs" && return
12768 # Create a file with a released layout and stripe count 2.
12769 $MULTIOP $DIR/$tfile H2c ||
12770 error "failed to create file with released layout"
12772 $GETSTRIPE -v $DIR/$tfile
12774 local pattern=$($GETSTRIPE -L $DIR/$tfile)
12775 [ X"$pattern" = X"80000001" ] || error "pattern error ($pattern)"
12777 local stripe_count=$($GETSTRIPE -c $DIR/$tfile) || error "getstripe"
12778 [ $stripe_count -eq 2 ] || error "stripe count not 2 ($stripe_count)"
12779 stat $DIR/$tfile || error "failed to stat released file"
12781 chown $RUNAS_ID $DIR/$tfile ||
12782 error "chown $RUNAS_ID $DIR/$tfile failed"
12784 chgrp $RUNAS_ID $DIR/$tfile ||
12785 error "chgrp $RUNAS_ID $DIR/$tfile failed"
12787 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
12788 rm $DIR/$tfile || error "failed to remove released file"
12790 run_test 229 "getstripe/stat/rm/attr changes work on released files"
12793 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12794 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
12797 test_mkdir $DIR/$tdir
12798 test_mkdir -i0 -c1 $DIR/$tdir/test_230_local
12799 local mdt_idx=$($GETSTRIPE -M $DIR/$tdir/test_230_local)
12800 [ $mdt_idx -ne 0 ] &&
12801 error "create local directory on wrong MDT $mdt_idx"
12803 $LFS mkdir -i $MDTIDX $DIR/$tdir/test_230 ||
12804 error "create remote directory failed"
12805 local mdt_idx=$($GETSTRIPE -M $DIR/$tdir/test_230)
12806 [ $mdt_idx -ne $MDTIDX ] &&
12807 error "create remote directory on wrong MDT $mdt_idx"
12809 createmany -o $DIR/$tdir/test_230/t- 10 ||
12810 error "create files on remote directory failed"
12811 mdt_idx=$($GETSTRIPE -M $DIR/$tdir/test_230/t-0)
12812 [ $mdt_idx -ne $MDTIDX ] && error "create files on wrong MDT $mdt_idx"
12813 rm -r $DIR/$tdir || error "unlink remote directory failed"
12815 run_test 230a "Create remote directory and files under the remote directory"
12818 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12819 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
12826 local migrate_dir=$DIR/$tdir/migrate_dir
12827 local other_dir=$DIR/$tdir/other_dir
12829 test_mkdir $DIR/$tdir
12830 test_mkdir -i0 -c1 $migrate_dir
12831 test_mkdir -i0 -c1 $other_dir
12832 for ((i=0; i<10; i++)); do
12833 mkdir -p $migrate_dir/dir_${i}
12834 createmany -o $migrate_dir/dir_${i}/f 10 ||
12835 error "create files under remote dir failed $i"
12838 cp /etc/passwd $migrate_dir/$tfile
12839 cp /etc/passwd $other_dir/$tfile
12840 chattr +SAD $migrate_dir
12841 chattr +SAD $migrate_dir/$tfile
12843 local old_dir_flag=$(lsattr -a $migrate_dir | awk '/\/\.$/ {print $1}')
12844 local old_file_flag=$(lsattr $migrate_dir/$tfile | awk '{print $1}')
12845 local old_dir_mode=$(stat -c%f $migrate_dir)
12846 local old_file_mode=$(stat -c%f $migrate_dir/$tfile)
12848 mkdir -p $migrate_dir/dir_default_stripe2
12849 $SETSTRIPE -c 2 $migrate_dir/dir_default_stripe2
12850 $SETSTRIPE -c 2 $migrate_dir/${tfile}_stripe2
12852 mkdir -p $other_dir
12853 ln $migrate_dir/$tfile $other_dir/luna
12854 ln $migrate_dir/$tfile $migrate_dir/sofia
12855 ln $other_dir/$tfile $migrate_dir/david
12856 ln -s $migrate_dir/$tfile $other_dir/zachary
12857 ln -s $migrate_dir/$tfile $migrate_dir/${tfile}_ln
12858 ln -s $other_dir/$tfile $migrate_dir/${tfile}_ln_other
12860 $LFS migrate -m $MDTIDX $migrate_dir ||
12861 error "fails on migrating remote dir to MDT1"
12863 echo "migratate to MDT1, then checking.."
12864 for ((i = 0; i < 10; i++)); do
12865 for file in $(find $migrate_dir/dir_${i}); do
12866 mdt_index=$($LFS getstripe -M $file)
12867 [ $mdt_index == $MDTIDX ] ||
12868 error "$file is not on MDT${MDTIDX}"
12872 # the multiple link file should still in MDT0
12873 mdt_index=$($LFS getstripe -M $migrate_dir/$tfile)
12874 [ $mdt_index == 0 ] ||
12875 error "$file is not on MDT${MDTIDX}"
12877 local new_dir_flag=$(lsattr -a $migrate_dir | awk '/\/\.$/ {print $1}')
12878 [ "$old_dir_flag" = "$new_dir_flag" ] ||
12879 error " expect $old_dir_flag get $new_dir_flag"
12881 local new_file_flag=$(lsattr $migrate_dir/$tfile | awk '{print $1}')
12882 [ "$old_file_flag" = "$new_file_flag" ] ||
12883 error " expect $old_file_flag get $new_file_flag"
12885 local new_dir_mode=$(stat -c%f $migrate_dir)
12886 [ "$old_dir_mode" = "$new_dir_mode" ] ||
12887 error "expect mode $old_dir_mode get $new_dir_mode"
12889 local new_file_mode=$(stat -c%f $migrate_dir/$tfile)
12890 [ "$old_file_mode" = "$new_file_mode" ] ||
12891 error "expect mode $old_file_mode get $new_file_mode"
12893 diff /etc/passwd $migrate_dir/$tfile ||
12894 error "$tfile different after migration"
12896 diff /etc/passwd $other_dir/luna ||
12897 error "luna different after migration"
12899 diff /etc/passwd $migrate_dir/sofia ||
12900 error "sofia different after migration"
12902 diff /etc/passwd $migrate_dir/david ||
12903 error "david different after migration"
12905 diff /etc/passwd $other_dir/zachary ||
12906 error "zachary different after migration"
12908 diff /etc/passwd $migrate_dir/${tfile}_ln ||
12909 error "${tfile}_ln different after migration"
12911 diff /etc/passwd $migrate_dir/${tfile}_ln_other ||
12912 error "${tfile}_ln_other different after migration"
12914 stripe_count=$($LFS getstripe -c $migrate_dir/dir_default_stripe2)
12915 [ $stripe_count = 2 ] ||
12916 error "dir strpe_count $d != 2 after migration."
12918 stripe_count=$($LFS getstripe -c $migrate_dir/${tfile}_stripe2)
12919 [ $stripe_count = 2 ] ||
12920 error "file strpe_count $d != 2 after migration."
12922 #migrate back to MDT0
12925 $LFS migrate -m $MDTIDX $migrate_dir ||
12926 error "fails on migrating remote dir to MDT0"
12928 echo "migrate back to MDT0, checking.."
12929 for file in $(find $migrate_dir); do
12930 mdt_index=$($LFS getstripe -M $file)
12931 [ $mdt_index == $MDTIDX ] ||
12932 error "$file is not on MDT${MDTIDX}"
12935 local new_dir_flag=$(lsattr -a $migrate_dir | awk '/\/\.$/ {print $1}')
12936 [ "$old_dir_flag" = "$new_dir_flag" ] ||
12937 error " expect $old_dir_flag get $new_dir_flag"
12939 local new_file_flag=$(lsattr $migrate_dir/$tfile | awk '{print $1}')
12940 [ "$old_file_flag" = "$new_file_flag" ] ||
12941 error " expect $old_file_flag get $new_file_flag"
12943 local new_dir_mode=$(stat -c%f $migrate_dir)
12944 [ "$old_dir_mode" = "$new_dir_mode" ] ||
12945 error "expect mode $old_dir_mode get $new_dir_mode"
12947 local new_file_mode=$(stat -c%f $migrate_dir/$tfile)
12948 [ "$old_file_mode" = "$new_file_mode" ] ||
12949 error "expect mode $old_file_mode get $new_file_mode"
12951 diff /etc/passwd ${migrate_dir}/$tfile ||
12952 error "$tfile different after migration"
12954 diff /etc/passwd ${other_dir}/luna ||
12955 error "luna different after migration"
12957 diff /etc/passwd ${migrate_dir}/sofia ||
12958 error "sofia different after migration"
12960 diff /etc/passwd ${other_dir}/zachary ||
12961 error "zachary different after migration"
12963 diff /etc/passwd $migrate_dir/${tfile}_ln ||
12964 error "${tfile}_ln different after migration"
12966 diff /etc/passwd $migrate_dir/${tfile}_ln_other ||
12967 error "${tfile}_ln_other different after migration"
12969 stripe_count=$($LFS getstripe -c ${migrate_dir}/dir_default_stripe2)
12970 [ $stripe_count = 2 ] ||
12971 error "dir strpe_count $d != 2 after migration."
12973 stripe_count=$($LFS getstripe -c ${migrate_dir}/${tfile}_stripe2)
12974 [ $stripe_count = 2 ] ||
12975 error "file strpe_count $d != 2 after migration."
12977 rm -rf $DIR/$tdir || error "rm dir failed after migration"
12979 run_test 230b "migrate directory"
12982 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12983 remote_mds_nodsh && skip "remote MDS with nodsh" && return
12984 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
12988 local migrate_dir=$DIR/$tdir/migrate_dir
12990 #If migrating directory fails in the middle, all entries of
12991 #the directory is still accessiable.
12992 test_mkdir $DIR/$tdir
12993 test_mkdir -i0 -c1 $migrate_dir
12995 createmany -o $migrate_dir/f 10 ||
12996 error "create files under ${migrate_dir} failed"
12998 #failed after migrating 5 entries
12999 #OBD_FAIL_MIGRATE_ENTRIES 0x1801
13000 do_facet mds1 lctl set_param fail_loc=0x20001801
13001 do_facet mds1 lctl set_param fail_val=5
13002 local t=$(ls $migrate_dir | wc -l)
13003 $LFS migrate --mdt-index $MDTIDX $migrate_dir &&
13004 error "migrate should fail after 5 entries"
13006 mkdir $migrate_dir/dir &&
13007 error "mkdir succeeds under migrating directory"
13008 touch $migrate_dir/file &&
13009 error "touch file succeeds under migrating directory"
13011 local u=$(ls $migrate_dir | wc -l)
13012 [ "$u" == "$t" ] || error "$u != $t during migration"
13014 for file in $(find $migrate_dir); do
13015 stat $file || error "stat $file failed"
13018 do_facet mds1 lctl set_param fail_loc=0
13019 do_facet mds1 lctl set_param fail_val=0
13021 $LFS migrate -m $MDTIDX $migrate_dir ||
13022 error "migrate open files should failed with open files"
13024 echo "Finish migration, then checking.."
13025 for file in $(find $migrate_dir); do
13026 mdt_index=$($LFS getstripe -M $file)
13027 [ $mdt_index == $MDTIDX ] ||
13028 error "$file is not on MDT${MDTIDX}"
13031 rm -rf $DIR/$tdir || error "rm dir failed after migration"
13033 run_test 230c "check directory accessiblity if migration is failed"
13036 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13037 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
13040 local migrate_dir=$DIR/$tdir/migrate_dir
13044 test_mkdir $DIR/$tdir
13045 test_mkdir -i0 -c1 $migrate_dir
13047 for ((i=0; i<100; i++)); do
13048 test_mkdir -i0 -c1 $migrate_dir/dir_${i}
13049 createmany -o $migrate_dir/dir_${i}/f 100 ||
13050 error "create files under remote dir failed $i"
13053 $LFS migrate -m $MDTIDX $migrate_dir ||
13054 error "migrate remote dir error"
13056 echo "Finish migration, then checking.."
13057 for file in $(find $migrate_dir); do
13058 mdt_index=$($LFS getstripe -M $file)
13059 [ $mdt_index == $MDTIDX ] ||
13060 error "$file is not on MDT${MDTIDX}"
13063 rm -rf $DIR/$tdir || error "rm dir failed after migration"
13065 run_test 230d "check migrate big directory"
13068 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13069 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
13075 mkdir -p $DIR/$tdir
13076 mkdir $DIR/$tdir/migrate_dir
13077 mkdir $DIR/$tdir/other_dir
13078 touch $DIR/$tdir/migrate_dir/a
13079 ln $DIR/$tdir/migrate_dir/a $DIR/$tdir/other_dir/b
13080 ls $DIR/$tdir/other_dir
13082 $LFS migrate -m 1 $DIR/$tdir/migrate_dir ||
13083 error "migrate dir fails"
13085 mdt_index=$($LFS getstripe -M $DIR/$tdir/migrate_dir)
13086 [ $mdt_index == 1 ] || error "migrate_dir is not on MDT1"
13088 mdt_index=$($LFS getstripe -M $DIR/$tdir/migrate_dir/a)
13089 [ $mdt_index == 0 ] || error "a is not on MDT0"
13091 $LFS migrate -m 1 $DIR/$tdir/other_dir ||
13092 error "migrate dir fails"
13094 mdt_index=$($LFS getstripe -M $DIR/$tdir/other_dir)
13095 [ $mdt_index == 1 ] || error "other_dir is not on MDT1"
13097 mdt_index=$($LFS getstripe -M $DIR/$tdir/migrate_dir/a)
13098 [ $mdt_index == 1 ] || error "a is not on MDT1"
13100 mdt_index=$($LFS getstripe -M $DIR/$tdir/other_dir/b)
13101 [ $mdt_index == 1 ] || error "b is not on MDT1"
13103 a_fid=$($LFS path2fid $DIR/$tdir/migrate_dir/a)
13104 b_fid=$($LFS path2fid $DIR/$tdir/other_dir/b)
13106 [ "$a_fid" = "$b_fid" ] || error "different fid after migration"
13108 rm -rf $DIR/$tdir || error "rm dir failed after migration"
13110 run_test 230e "migrate mulitple local link files"
13113 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13114 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
13118 mkdir -p $DIR/$tdir
13119 mkdir $DIR/$tdir/migrate_dir
13120 $LFS mkdir -i1 $DIR/$tdir/other_dir
13121 touch $DIR/$tdir/migrate_dir/a
13122 ln $DIR/$tdir/migrate_dir/a $DIR/$tdir/other_dir/ln1
13123 ln $DIR/$tdir/migrate_dir/a $DIR/$tdir/other_dir/ln2
13124 ls $DIR/$tdir/other_dir
13126 # a should be migrated to MDT1, since no other links on MDT0
13127 $LFS migrate -m 1 $DIR/$tdir/migrate_dir ||
13128 error "migrate dir fails"
13129 mdt_index=$($LFS getstripe -M $DIR/$tdir/migrate_dir)
13130 [ $mdt_index == 1 ] || error "migrate_dir is not on MDT1"
13131 mdt_index=$($LFS getstripe -M $DIR/$tdir/migrate_dir/a)
13132 [ $mdt_index == 1 ] || error "a is not on MDT1"
13134 # a should stay on MDT1, because it is a mulitple link file
13135 $LFS migrate -m 0 $DIR/$tdir/migrate_dir ||
13136 error "migrate dir fails"
13137 mdt_index=$($LFS getstripe -M $DIR/$tdir/migrate_dir/a)
13138 [ $mdt_index == 1 ] || error "a is not on MDT1"
13140 $LFS migrate -m 1 $DIR/$tdir/migrate_dir ||
13141 error "migrate dir fails"
13143 a_fid=$($LFS path2fid $DIR/$tdir/migrate_dir/a)
13144 ln_fid=$($LFS path2fid $DIR/$tdir/other_dir/ln1)
13145 [ "$a_fid" = "$ln_fid" ] || error "different fid after migrate to MDT1"
13147 rm -rf $DIR/$tdir/other_dir/ln1 || error "unlink ln1 fails"
13148 rm -rf $DIR/$tdir/other_dir/ln2 || error "unlink ln2 fails"
13150 # a should be migrated to MDT0, since no other links on MDT1
13151 $LFS migrate -m 0 $DIR/$tdir/migrate_dir ||
13152 error "migrate dir fails"
13153 mdt_index=$($LFS getstripe -M $DIR/$tdir/migrate_dir/a)
13154 [ $mdt_index == 0 ] || error "a is not on MDT0"
13156 rm -rf $DIR/$tdir || error "rm dir failed after migration"
13158 run_test 230f "migrate mulitple remote link files"
13161 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13162 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
13164 mkdir -p $DIR/$tdir/migrate_dir
13166 $LFS migrate -m 1000 $DIR/$tdir/migrate_dir &&
13167 error "migrating dir to non-exist MDT succeeds"
13170 run_test 230g "migrate dir to non-exist MDT"
13173 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13174 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
13175 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.64) ] &&
13176 skip "Need MDS version at least 2.7.64" && return
13179 mkdir -p $DIR/$tdir/migrate_dir
13181 $LFS migrate -m1 $DIR &&
13182 error "migrating mountpoint1 should fail"
13184 $LFS migrate -m1 $DIR/$tdir/.. &&
13185 error "migrating mountpoint2 should fail"
13187 $LFS migrate -m1 $DIR/$tdir/migrate_dir/.. ||
13188 error "migrating $tdir fail"
13190 mdt_index=$($LFS getstripe -M $DIR/$tdir)
13191 [ $mdt_index == 1 ] || error "$mdt_index != 1 after migration"
13193 mdt_index=$($LFS getstripe -M $DIR/$tdir/migrate_dir)
13194 [ $mdt_index == 1 ] || error "$mdt_index != 1 after migration"
13197 run_test 230h "migrate .. and root"
13200 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13201 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
13203 mkdir -p $DIR/$tdir/migrate_dir
13205 $LFS migrate -m 1 $DIR/$tdir/migrate_dir/ ||
13206 error "migration fails with a tailing slash"
13208 $LFS migrate -m 0 $DIR/$tdir/migrate_dir// ||
13209 error "migration fails with two tailing slashes"
13211 run_test 230i "lfs migrate -m tolerates trailing slashes"
13215 # For simplicity this test assumes that max_pages_per_rpc
13216 # is the same across all OSCs
13217 local max_pages=$($LCTL get_param -n osc.*.max_pages_per_rpc | head -n1)
13218 local bulk_size=$((max_pages * 4096))
13220 mkdir -p $DIR/$tdir
13222 # clear the OSC stats
13223 $LCTL set_param osc.*.stats=0 &>/dev/null
13226 # Client writes $bulk_size - there must be 1 rpc for $max_pages.
13227 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=$bulk_size count=1 \
13228 oflag=direct &>/dev/null || error "dd failed"
13230 sync; sleep 1; sync # just to be safe
13231 local nrpcs=$($LCTL get_param osc.*.stats |awk '/ost_write/ {print $2}')
13232 if [ x$nrpcs != "x1" ]; then
13233 $LCTL get_param osc.*.stats
13234 error "found $nrpcs ost_write RPCs, not 1 as expected"
13238 # Drop the OSC cache, otherwise we will read from it
13239 cancel_lru_locks osc
13241 # clear the OSC stats
13242 $LCTL set_param osc.*.stats=0 &>/dev/null
13244 # Client reads $bulk_size.
13245 dd if=$DIR/$tdir/$tfile of=/dev/null bs=$bulk_size count=1 \
13246 iflag=direct &>/dev/null || error "dd failed"
13248 nrpcs=$($LCTL get_param osc.*.stats | awk '/ost_read/ { print $2 }')
13249 if [ x$nrpcs != "x1" ]; then
13250 $LCTL get_param osc.*.stats
13251 error "found $nrpcs ost_read RPCs, not 1 as expected"
13254 run_test 231a "checking that reading/writing of BRW RPC size results in one RPC"
13257 mkdir -p $DIR/$tdir
13259 for i in {0..1023}; do
13260 dd if=/dev/zero of=$DIR/$tdir/$tfile conv=notrunc \
13261 seek=$((2 * i)) bs=4096 count=1 &>/dev/null ||
13262 error "dd of=$DIR/$tdir/$tfile seek=$((2 * i)) failed"
13266 run_test 231b "must not assert on fully utilized OST request buffer"
13269 mkdir -p $DIR/$tdir
13270 #define OBD_FAIL_LDLM_OST_LVB 0x31c
13271 $LCTL set_param fail_loc=0x31c
13273 # ignore dd failure
13274 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=1 || true
13276 $LCTL set_param fail_loc=0
13277 umount_client $MOUNT || error "umount failed"
13278 mount_client $MOUNT || error "mount failed"
13280 run_test 232 "failed lock should not block umount"
13283 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.3.64) ] ||
13284 { skip "Need MDS version at least 2.3.64"; return; }
13285 [ -n "$FILESET" ] && skip "SKIP due to FILESET set" && return
13287 local fid=$($LFS path2fid $MOUNT)
13288 stat $MOUNT/.lustre/fid/$fid > /dev/null ||
13289 error "cannot access $MOUNT using its FID '$fid'"
13291 run_test 233a "checking that OBF of the FS root succeeds"
13294 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.5.90) ] ||
13295 { skip "Need MDS version at least 2.5.90"; return; }
13296 [ -n "$FILESET" ] && skip "SKIP due to FILESET set" && return
13298 local fid=$($LFS path2fid $MOUNT/.lustre)
13299 stat $MOUNT/.lustre/fid/$fid > /dev/null ||
13300 error "cannot access $MOUNT/.lustre using its FID '$fid'"
13302 fid=$($LFS path2fid $MOUNT/.lustre/fid)
13303 stat $MOUNT/.lustre/fid/$fid > /dev/null ||
13304 error "cannot access $MOUNT/.lustre/fid using its FID '$fid'"
13306 run_test 233b "checking that OBF of the FS .lustre succeeds"
13309 local p="$TMP/sanityN-$TESTNAME.parameters"
13310 save_lustre_params client "llite.*.xattr_cache" > $p
13311 lctl set_param llite.*.xattr_cache 1 ||
13312 { skip "xattr cache is not supported"; return 0; }
13314 mkdir -p $DIR/$tdir || error "mkdir failed"
13315 touch $DIR/$tdir/$tfile || error "touch failed"
13316 # OBD_FAIL_LLITE_XATTR_ENOMEM
13317 $LCTL set_param fail_loc=0x1405
13318 # output of the form: attr 2 4 44 3 fc13 x86_64
13319 V=($(IFS=".-" rpm -q attr))
13320 if [[ ${V[1]} > 2 || ${V[2]} > 4 || ${V[3]} > 44 ||
13321 ${V[1]} = 2 && ${V[2]} = 4 && ${V[3]} = 44 && ${V[4]} > 6 ]]; then
13322 # attr pre-2.4.44-7 had a bug with rc
13323 # LU-3703 - SLES 11 and FC13 clients have older attr
13324 getfattr -n user.attr $DIR/$tdir/$tfile &&
13325 error "getfattr should have failed with ENOMEM"
13327 skip "LU-3703: attr version $(getfattr --version) too old"
13329 $LCTL set_param fail_loc=0x0
13332 restore_lustre_params < $p
13335 run_test 234 "xattr cache should not crash on ENOMEM"
13338 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.52) ] &&
13339 skip "Need MDS version at least 2.4.52" && return
13340 flock_deadlock $DIR/$tfile
13345 124) error "process hangs on a deadlock"
13347 *) error "error executing flock_deadlock $DIR/$tfile"
13351 run_test 235 "LU-1715: flock deadlock detection does not work properly"
13355 check_swap_layouts_support && return 0
13356 test_mkdir -p -c1 $DIR/$tdir || error "mkdir $tdir failed"
13358 local ref1=/etc/passwd
13359 local ref2=/etc/group
13360 local file1=$DIR/$tdir/f1
13361 local file2=$DIR/$tdir/f2
13363 $SETSTRIPE -c 1 $file1 || error "cannot setstripe on '$file1': rc = $?"
13364 cp $ref1 $file1 || error "cp $ref1 $file1 failed: rc = $?"
13365 $SETSTRIPE -c 2 $file2 || error "cannot setstripe on '$file2': rc = $?"
13366 cp $ref2 $file2 || error "cp $ref2 $file2 failed: rc = $?"
13367 local fd=$(free_fd)
13368 local cmd="exec $fd<>$file2"
13371 $LFS swap_layouts $file1 /proc/self/fd/${fd} ||
13372 error "cannot swap layouts of '$file1' and /proc/self/fd/${fd}"
13375 cmp $ref2 $file1 || error "content compare failed ($ref2 != $file1)"
13380 run_test 236 "Layout swap on open unlinked file"
13382 # test to verify file handle related system calls
13383 # (name_to_handle_at/open_by_handle_at)
13384 # The new system calls are supported in glibc >= 2.14.
13387 echo "Test file_handle syscalls" > $DIR/$tfile ||
13388 error "write failed"
13389 check_fhandle_syscalls $DIR/$tfile ||
13390 error "check_fhandle_syscalls failed"
13392 run_test 237 "Verify name_to_handle_at/open_by_handle_at syscalls"
13394 # LU-4659 linkea consistency
13396 local server_version=$(lustre_version_code $SINGLEMDS)
13398 [[ $server_version -gt $(version_code 2.5.57) ]] ||
13399 [[ $server_version -gt $(version_code 2.5.1) &&
13400 $server_version -lt $(version_code 2.5.50) ]] ||
13401 { skip "Need MDS version at least 2.5.58 or 2.5.2+"; return; }
13404 ln $DIR/$tfile $DIR/$tfile.lnk
13405 touch $DIR/$tfile.new
13406 mv $DIR/$tfile.new $DIR/$tfile
13407 local fid1=$($LFS path2fid $DIR/$tfile)
13408 local fid2=$($LFS path2fid $DIR/$tfile.lnk)
13409 local path1=$($LFS fid2path $FSNAME "$fid1")
13410 [ $tfile == $path1 ] || error "linkea inconsistent: $tfile $fid1 $path1"
13411 local path2=$($LFS fid2path $FSNAME "$fid2")
13412 [ $tfile.lnk == $path2 ] ||
13413 error "linkea inconsistent: $tfile.lnk $fid2 $path2!"
13416 run_test 238 "Verify linkea consistency"
13419 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.5.60) ] &&
13420 skip "Need MDS version at least 2.5.60" && return
13421 local list=$(comma_list $(mdts_nodes))
13423 mkdir -p $DIR/$tdir
13424 createmany -o $DIR/$tdir/f- 5000
13425 unlinkmany $DIR/$tdir/f- 5000
13426 do_nodes $list "lctl set_param -n osp*.*.sync_changes 1"
13427 changes=$(do_nodes $list "lctl get_param -n osc.*MDT*.sync_changes \
13428 osc.*MDT*.sync_in_flight" | calc_sum)
13429 [ "$changes" -eq 0 ] || error "$changes not synced"
13431 run_test 239 "osp_sync test"
13433 test_239a() { #LU-5297
13435 #define OBD_FAIL_OSP_CHECK_INVALID_REC 0x2100
13436 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x2100
13437 chgrp $RUNAS_GID $DIR/$tfile
13438 wait_delete_completed
13440 run_test 239a "process invalid osp sync record correctly"
13442 test_239b() { #LU-5297
13444 #define OBD_FAIL_OSP_CHECK_ENOMEM 0x2101
13445 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x2101
13446 chgrp $RUNAS_GID $DIR/$tfile1
13447 wait_delete_completed
13448 do_facet $SINGLEMDS $LCTL set_param fail_loc=0
13450 chgrp $RUNAS_GID $DIR/$tfile2
13451 wait_delete_completed
13453 run_test 239b "process osp sync record with ENOMEM error correctly"
13456 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
13458 mkdir -p $DIR/$tdir
13460 $LFS mkdir -i 0 $DIR/$tdir/d0 ||
13461 error "failed to mkdir $DIR/$tdir/d0 on MDT0"
13462 $LFS mkdir -i 1 $DIR/$tdir/d0/d1 ||
13463 error "failed to mkdir $DIR/$tdir/d0/d1 on MDT1"
13465 umount_client $MOUNT || error "umount failed"
13466 #define OBD_FAIL_TGT_DELAY_CONDITIONAL 0x713
13467 do_facet mds2 lctl set_param fail_loc=0x713 fail_val=1
13468 mount_client $MOUNT || error "failed to mount client"
13470 echo "stat $DIR/$tdir/d0/d1, should not fail/ASSERT"
13471 stat $DIR/$tdir/d0/d1 || error "fail to stat $DIR/$tdir/d0/d1"
13473 run_test 240 "race between ldlm enqueue and the connection RPC (no ASSERT)"
13476 for LOOP in $(seq $1); do
13477 dd if=$DIR/$tfile of=/dev/null bs=40960 count=1 2>/dev/null
13478 cancel_lru_locks osc || true
13483 for LOOP in $(seq $1); do
13484 dd if=$DIR/$tfile of=/dev/null bs=40960 count=1 \
13485 iflag=direct 2>/dev/null
13490 dd if=/dev/zero of=$DIR/$tfile count=1 bs=40960
13492 cancel_lru_locks osc
13493 test_241_bio 1000 &
13498 run_test 241 "bio vs dio"
13501 dd if=/dev/zero of=$DIR/$tfile count=1 bs=40960
13503 test_241_dio 1000 &
13508 run_test 241b "dio vs dio"
13511 mkdir -p $DIR/$tdir
13512 touch $DIR/$tdir/$tfile
13514 #define OBD_FAIL_MDS_READPAGE_PACK 0x105
13515 do_facet mds1 lctl set_param fail_loc=0x105
13516 /bin/ls $DIR/$tdir && error "ls $DIR/$tdir should fail"
13518 do_facet mds1 lctl set_param fail_loc=0
13519 /bin/ls $DIR/$tdir || error "ls $DIR/$tdir failed"
13521 run_test 242 "mdt_readpage failure should not cause directory unreadable"
13525 test_mkdir -p $DIR/$tdir
13526 group_lock_test -d $DIR/$tdir || error "A group lock test failed"
13528 run_test 243 "various group lock tests"
13532 test_mkdir -p $DIR/$tdir
13533 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=35
13534 sendfile_grouplock $DIR/$tdir/$tfile || \
13535 error "sendfile+grouplock failed"
13538 run_test 244 "sendfile with group lock tests"
13541 local flagname="multi_mod_rpcs"
13542 local connect_data_name="max_mod_rpcs"
13545 # check if multiple modify RPCs flag is set
13546 out=$($LCTL get_param mdc.$FSNAME-MDT0000-*.import |
13547 grep "connect_flags:")
13550 echo "$out" | grep -qw $flagname
13551 if [ $? -ne 0 ]; then
13552 echo "connect flag $flagname is not set"
13556 # check if multiple modify RPCs data is set
13557 out=$($LCTL get_param mdc.$FSNAME-MDT0000-*.import)
13560 echo "$out" | grep -qw $connect_data_name ||
13561 error "import should have connect data $connect_data_name"
13563 run_test 245 "check mdc connection flag/data: multiple modify RPCs"
13565 test_246() { # LU-7371
13566 [ $(lustre_version_code ost1) -lt $(version_code 2.7.62) ] &&
13567 skip "Need OST version >= 2.7.62" && return 0
13568 do_facet ost1 $LCTL set_param fail_val=4095
13569 #define OBD_FAIL_OST_READ_SIZE 0x234
13570 do_facet ost1 $LCTL set_param fail_loc=0x234
13571 $LFS setstripe $DIR/$tfile -i 0 -c 1
13572 dd if=/dev/zero of=$DIR/$tfile bs=4095 count=1 > /dev/null 2>&1
13573 cancel_lru_locks $FSNAME-OST0000
13574 dd if=$DIR/$tfile of=/dev/null bs=1048576 || error "Read failed"
13576 run_test 246 "Read file of size 4095 should return right length"
13579 lctl get_param -n mdc.$FSNAME-MDT0000*.import |
13581 { skip "Fileset feature is not supported"; return; }
13583 local submount=${MOUNT}_$tdir
13586 mkdir -p $submount || error "mkdir $submount failed"
13587 FILESET="$FILESET/$tdir" mount_client $submount ||
13588 error "mount $submount failed"
13589 echo foo > $submount/$tfile || error "write $submount/$tfile failed"
13590 [ $(cat $MOUNT/$tdir/$tfile) = "foo" ] ||
13591 error "read $MOUNT/$tdir/$tfile failed"
13592 umount_client $submount || error "umount $submount failed"
13595 run_test 247a "mount subdir as fileset"
13598 lctl get_param -n mdc.$FSNAME-MDT0000*.import | grep -q subtree ||
13599 { skip "Fileset feature is not supported"; return; }
13601 local submount=${MOUNT}_$tdir
13603 rm -rf $MOUNT/$tdir
13604 mkdir -p $submount || error "mkdir $submount failed"
13606 FILESET="$FILESET/$tdir" mount_client $submount &&
13607 error "mount $submount should fail"
13610 run_test 247b "mount subdir that dose not exist"
13613 lctl get_param -n mdc.$FSNAME-MDT0000*.import | grep -q subtree ||
13614 { skip "Fileset feature is not supported"; return; }
13616 local submount=${MOUNT}_$tdir
13618 mkdir -p $MOUNT/$tdir/dir1
13619 mkdir -p $submount || error "mkdir $submount failed"
13620 FILESET="$FILESET/$tdir" mount_client $submount ||
13621 error "mount $submount failed"
13622 local fid=$($LFS path2fid $MOUNT/)
13623 $LFS fid2path $submount $fid && error "fid2path should fail"
13624 umount_client $submount || error "umount $submount failed"
13627 run_test 247c "running fid2path outside root"
13630 lctl get_param -n mdc.$FSNAME-MDT0000*.import | grep -q subtree ||
13631 { skip "Fileset feature is not supported"; return; }
13633 local submount=${MOUNT}_$tdir
13635 mkdir -p $MOUNT/$tdir/dir1
13636 mkdir -p $submount || error "mkdir $submount failed"
13637 FILESET="$FILESET/$tdir" mount_client $submount ||
13638 error "mount $submount failed"
13639 local fid=$($LFS path2fid $submount/dir1)
13640 $LFS fid2path $submount $fid || error "fid2path should succeed"
13641 umount_client $submount || error "umount $submount failed"
13644 run_test 247d "running fid2path inside root"
13648 lctl get_param -n mdc.$FSNAME-MDT0000*.import |
13650 { skip "Fileset feature is not supported"; return; }
13652 local submount=${MOUNT}_$tdir
13655 mkdir -p $submount || error "mkdir $submount failed"
13656 FILESET="$FILESET/.." mount_client $submount &&
13657 error "mount $submount should fail"
13660 run_test 247e "mount .. as fileset"
13663 [ "$(facet_fstype ost$(($($GETSTRIPE -i $DIR/$tfile) + 1)))" = "zfs" ] \
13664 && skip "no 16TB file size limit on ZFS" && return
13666 $SETSTRIPE -c 1 $DIR/$tfile
13667 # ldiskfs extent file size limit is (16TB - 4KB - 1) bytes
13668 local size=$((16 * 1024 * 1024 * 1024 * 1024 - 4096 - 1))
13669 $TRUNCATE $DIR/$tfile $size || error "truncate $tfile to $size failed"
13670 dd if=/dev/zero of=$DIR/$tfile bs=10 count=1 oflag=append \
13671 conv=notrunc,fsync && error "append succeeded"
13674 run_test 250 "Write above 16T limit"
13677 $SETSTRIPE -c -1 -S 1048576 $DIR/$tfile
13679 #define OBD_FAIL_LLITE_LOST_LAYOUT 0x1407
13680 #Skip once - writing the first stripe will succeed
13681 $LCTL set_param fail_loc=0xa0001407 fail_val=1
13682 $MULTIOP $DIR/$tfile o:O_RDWR:w2097152c 2>&1 | grep -q "short write" &&
13683 error "short write happened"
13685 $LCTL set_param fail_loc=0xa0001407 fail_val=1
13686 $MULTIOP $DIR/$tfile or2097152c 2>&1 | grep -q "short read" &&
13687 error "short read happened"
13691 run_test 251 "Handling short read and write correctly"
13701 if [ "$(facet_fstype ost1)" != "ldiskfs" -o \
13702 "$(facet_fstype mds1)" != "ldiskfs" ]; then
13703 skip "can only run lr_reader on ldiskfs target"
13707 # check lr_reader on OST0000
13709 dev=$(facet_device $tgt)
13710 out=$(do_facet $tgt $LR_READER $dev)
13711 [ $? -eq 0 ] || error "$LR_READER failed on target $tgt device $dev"
13713 uuid=$(echo "$out" | grep -i uuid | awk '{ print $2 }')
13714 [ "$uuid" == "$(ostuuid_from_index 0)" ] ||
13715 error "Invalid uuid returned by $LR_READER on target $tgt"
13716 echo -e "uuid returned by $LR_READER is '$uuid'\n"
13718 # check lr_reader -c on MDT0000
13720 dev=$(facet_device $tgt)
13721 if ! do_facet $tgt $LR_READER -h | grep -q OPTIONS; then
13722 echo "$LR_READER does not support additional options"
13725 out=$(do_facet $tgt $LR_READER -c $dev)
13726 [ $? -eq 0 ] || error "$LR_READER failed on target $tgt device $dev"
13728 num=$(echo "$out" | grep -c "mdtlov")
13729 [ "$num" -eq $((MDSCOUNT - 1)) ] ||
13730 error "Invalid number of mdtlov clients returned by $LR_READER"
13731 echo -e "Number of mdtlov clients returned by $LR_READER is '$num'\n"
13733 # check lr_reader -cr on MDT0000
13734 out=$(do_facet $tgt $LR_READER -cr $dev)
13735 [ $? -eq 0 ] || error "$LR_READER failed on target $tgt device $dev"
13737 echo "$out" | grep -q "^reply_data:$" ||
13738 error "$LR_READER should have returned 'reply_data' section"
13739 num=$(echo "$out" | grep -c "client_generation")
13740 echo -e "Number of reply data returned by $LR_READER is '$num'\n"
13742 run_test 252 "check lr_reader tool"
13747 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13748 remote_mds_nodsh && skip "remote MDS with nodsh" && return
13749 do_facet mds1 $LCTL get_param -n mdd.$MDT0.changelog_size ||
13750 { skip "MDS does not support changelog_size" && return; }
13752 cl_user=$(do_facet mds1 $LCTL --device $MDT0 changelog_register -n)
13753 echo "Registered as changelog user $cl_user"
13755 $LFS changelog_clear $MDT0 $cl_user 0
13757 local size1=$(do_facet mds1 \
13758 $LCTL get_param -n mdd.$MDT0.changelog_size)
13759 echo "Changelog size $size1"
13762 $LFS mkdir -i 0 $DIR/$tdir
13764 mkdir -p $DIR/$tdir/pics/2008/zachy
13765 touch $DIR/$tdir/pics/2008/zachy/timestamp
13766 cp /etc/hosts $DIR/$tdir/pics/2008/zachy/pic1.jpg
13767 mv $DIR/$tdir/pics/2008/zachy $DIR/$tdir/pics/zach
13768 ln $DIR/$tdir/pics/zach/pic1.jpg $DIR/$tdir/pics/2008/portland.jpg
13769 ln -s $DIR/$tdir/pics/2008/portland.jpg $DIR/$tdir/pics/desktop.jpg
13770 rm $DIR/$tdir/pics/desktop.jpg
13772 local size2=$(do_facet mds1 \
13773 $LCTL get_param -n mdd.$MDT0.changelog_size)
13774 echo "Changelog size after work $size2"
13776 do_facet mds1 $LCTL --device $MDT0 changelog_deregister $cl_user
13778 if (( size2 <= size1 )); then
13779 error "Changelog size after work should be greater than original"
13783 run_test 254 "Check changelog size"
13790 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13791 remote_mds_nodsh && skip "remote MDS with nodsh" && return
13792 [ "$(facet_fstype mds1)" != "ldiskfs" ] &&
13793 skip "non-ldiskfs backend" && return
13795 mdt_dev=$(mdsdevname 1)
13797 cl_user=$(do_facet mds1 \
13798 "$LCTL get_param -n mdd.$MDT0.changelog_users | grep cl")
13799 if [[ -n $cl_user ]]; then
13800 skip "active changelog user"
13804 cl_user=$(do_facet mds1 $LCTL --device $MDT0 changelog_register -n)
13805 echo "Registered as changelog user $cl_user"
13808 mkdir -p $DIR/$tdir
13810 $LFS changelog_clear $MDT0 $cl_user 0
13813 touch $DIR/$tdir/{1..10}
13816 stop mds1 || error "Fail to stop MDT."
13819 start mds1 $mdt_dev $MDS_MOUNT_OPTS || error "Fail to start MDT."
13821 #after mount new plainllog is used
13822 touch $DIR/$tdir/{11..19}
13823 cat_sl=$(do_facet mds1 \
13824 "$DEBUGFS -R \\\"dump changelog_catalog cat.dmp\\\" $mdt_dev; \
13825 llog_reader cat.dmp | grep \\\"type=1064553b\\\" | wc -l")
13827 if (( cat_sl != 2 )); then
13828 do_facet mds1 $LCTL --device $MDT0 changelog_deregister $cl_user
13829 error "Changelog catalog has wrong number of slots $cat_sl"
13832 $LFS changelog_clear $MDT0 $cl_user 0
13834 cat_sl=$(do_facet mds1 \
13835 "$DEBUGFS -R \\\"dump changelog_catalog cat.dmp\\\" $mdt_dev; \
13836 llog_reader cat.dmp | grep \\\"type=1064553b\\\" | wc -l")
13838 do_facet mds1 $LCTL --device $MDT0 changelog_deregister $cl_user
13840 if (( cat_sl == 2 )); then
13841 error "Empty plain llog was not deleted from changelog catalog"
13843 if (( cat_sl != 1 )); then
13844 error "Active plain llog shouldn\`t be deleted from catalog"
13847 run_test 256 "Check llog delete for empty and not full state"
13849 cleanup_test_300() {
13853 test_striped_dir() {
13858 mkdir -p $DIR/$tdir
13860 SAVE_UMASK=$(umask)
13861 trap cleanup_test_300 RETURN EXIT
13863 $LFS setdirstripe -i $mdt_index -c 2 -t all_char -m 755 \
13864 $DIR/$tdir/striped_dir ||
13865 error "set striped dir error"
13867 local mode=$(stat -c%a $DIR/$tdir/striped_dir)
13868 [ "$mode" = "755" ] || error "expect 755 got $mode"
13870 $LFS getdirstripe $DIR/$tdir/striped_dir > /dev/null 2>&1 ||
13871 error "getdirstripe failed"
13872 stripe_count=$($LFS getdirstripe -c $DIR/$tdir/striped_dir)
13873 if [ "$stripe_count" != "2" ]; then
13874 error "stripe_count is $stripe_count, expect 2"
13877 stripe_index=$($LFS getdirstripe -i $DIR/$tdir/striped_dir)
13878 if [ "$stripe_index" != "$mdt_index" ]; then
13879 error "stripe_index is $stripe_index, expect $mdt_index"
13882 [ $(stat -c%h $DIR/$tdir/striped_dir) == '2' ] ||
13883 error "nlink error after create striped dir"
13885 mkdir $DIR/$tdir/striped_dir/a
13886 mkdir $DIR/$tdir/striped_dir/b
13888 stat $DIR/$tdir/striped_dir/a ||
13889 error "create dir under striped dir failed"
13890 stat $DIR/$tdir/striped_dir/b ||
13891 error "create dir under striped dir failed"
13893 [ $(stat -c%h $DIR/$tdir/striped_dir) == '4' ] ||
13894 error "nlink error after mkdir"
13896 rmdir $DIR/$tdir/striped_dir/a
13897 [ $(stat -c%h $DIR/$tdir/striped_dir) == '3' ] ||
13898 error "nlink error after rmdir"
13900 rmdir $DIR/$tdir/striped_dir/b
13901 [ $(stat -c%h $DIR/$tdir/striped_dir) == '2' ] ||
13902 error "nlink error after rmdir"
13904 chattr +i $DIR/$tdir/striped_dir
13905 createmany -o $DIR/$tdir/striped_dir/f 10 &&
13906 error "immutable flags not working under striped dir!"
13907 chattr -i $DIR/$tdir/striped_dir
13909 rmdir $DIR/$tdir/striped_dir ||
13910 error "rmdir striped dir error"
13918 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.0) ] &&
13919 skip "skipped for lustre < 2.7.0" && return
13920 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13921 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
13923 test_striped_dir 0 || error "failed on striped dir on MDT0"
13924 test_striped_dir 1 || error "failed on striped dir on MDT0"
13926 run_test 300a "basic striped dir sanity test"
13929 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.0) ] &&
13930 skip "skipped for lustre < 2.7.0" && return
13931 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13932 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
13938 test_mkdir $DIR/$tdir || error "mkdir fail"
13939 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir ||
13940 error "set striped dir error"
13941 for ((i=0; i<10; i++)); do
13942 mtime1=$(stat -c %Y $DIR/$tdir/striped_dir)
13944 touch $DIR/$tdir/striped_dir/file_$i ||
13945 error "touch error $i"
13946 mtime2=$(stat -c %Y $DIR/$tdir/striped_dir)
13947 [ $mtime1 -eq $mtime2 ] &&
13948 error "mtime not change after create"
13950 rm -f $DIR/$tdir/striped_dir/file_$i ||
13951 error "unlink error $i"
13952 mtime3=$(stat -c %Y $DIR/$tdir/striped_dir)
13953 [ $mtime2 -eq $mtime3 ] &&
13954 error "mtime did not change after unlink"
13958 run_test 300b "check ctime/mtime for striped dir"
13961 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.0) ] &&
13962 skip "skipped for lustre < 2.7.0" && return
13963 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13964 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
13967 mkdir -p $DIR/$tdir
13968 $LFS setdirstripe -i 0 -c 2 $DIR/$tdir/striped_dir ||
13969 error "set striped dir error"
13971 chown $RUNAS_ID:$RUNAS_GID $DIR/$tdir/striped_dir ||
13972 error "chown striped dir failed"
13974 $RUNAS createmany -o $DIR/$tdir/striped_dir/f 5000 ||
13975 error "create 5k files failed"
13977 file_count=$(ls $DIR/$tdir/striped_dir | wc -l)
13979 [ "$file_count" = 5000 ] || error "file count $file_count != 5000"
13983 run_test 300c "chown && check ls under striped directory"
13986 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.0) ] &&
13987 skip "skipped for lustre < 2.7.0" && return
13988 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13989 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
13993 mkdir -p $DIR/$tdir
13994 $SETSTRIPE -c 2 $DIR/$tdir
13996 #local striped directory
13997 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir ||
13998 error "set striped dir error"
13999 createmany -o $DIR/$tdir/striped_dir/f 10 ||
14000 error "create 10 files failed"
14002 #remote striped directory
14003 $LFS setdirstripe -i 1 -c 2 $DIR/$tdir/remote_striped_dir ||
14004 error "set striped dir error"
14005 createmany -o $DIR/$tdir/remote_striped_dir/f 10 ||
14006 error "create 10 files failed"
14008 for file in $(find $DIR/$tdir); do
14009 stripe_count=$($GETSTRIPE -c $file)
14010 [ $stripe_count -eq 2 ] ||
14011 error "wrong stripe $stripe_count for $file"
14016 run_test 300d "check default stripe under striped directory"
14019 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
14020 skip "Need MDS version at least 2.7.55" && return
14021 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
14022 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
14026 mkdir -p $DIR/$tdir
14028 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir ||
14029 error "set striped dir error"
14031 touch $DIR/$tdir/striped_dir/a
14032 touch $DIR/$tdir/striped_dir/b
14033 touch $DIR/$tdir/striped_dir/c
14035 mkdir $DIR/$tdir/striped_dir/dir_a
14036 mkdir $DIR/$tdir/striped_dir/dir_b
14037 mkdir $DIR/$tdir/striped_dir/dir_c
14039 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir/stp_a ||
14040 error "set striped dir under striped dir error"
14042 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir/stp_b ||
14043 error "set striped dir under striped dir error"
14045 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir/stp_c ||
14046 error "set striped dir under striped dir error"
14048 mrename $DIR/$tdir/striped_dir/dir_a $DIR/$tdir/striped_dir/dir_b ||
14049 error "rename dir under striped dir fails"
14051 mrename $DIR/$tdir/striped_dir/stp_a $DIR/$tdir/striped_dir/stp_b ||
14052 error "rename dir under different stripes fails"
14054 mrename $DIR/$tdir/striped_dir/a $DIR/$tdir/striped_dir/c ||
14055 error "rename file under striped dir should succeed"
14057 mrename $DIR/$tdir/striped_dir/dir_b $DIR/$tdir/striped_dir/dir_c ||
14058 error "rename dir under striped dir should succeed"
14062 run_test 300e "check rename under striped directory"
14065 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
14066 skip "Need MDS version at least 2.7.55" && return
14067 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
14068 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
14073 mkdir -p $DIR/$tdir
14075 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir ||
14076 error "set striped dir error"
14078 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir1 ||
14079 error "set striped dir error"
14081 touch $DIR/$tdir/striped_dir/a
14082 mkdir $DIR/$tdir/striped_dir/dir_a
14083 $LFS setdirstripe -i 0 -c 2 $DIR/$tdir/striped_dir/stp_a ||
14084 error "create striped dir under striped dir fails"
14086 touch $DIR/$tdir/striped_dir1/b
14087 mkdir $DIR/$tdir/striped_dir1/dir_b
14088 $LFS setdirstripe -i 0 -c 2 $DIR/$tdir/striped_dir/stp_b ||
14089 error "create striped dir under striped dir fails"
14091 mrename $DIR/$tdir/striped_dir/dir_a $DIR/$tdir/striped_dir1/dir_b ||
14092 error "rename dir under different striped dir should fail"
14094 mrename $DIR/$tdir/striped_dir/stp_a $DIR/$tdir/striped_dir1/stp_b ||
14095 error "rename striped dir under diff striped dir should fail"
14097 mrename $DIR/$tdir/striped_dir/a $DIR/$tdir/striped_dir1/a ||
14098 error "rename file under diff striped dirs fails"
14102 run_test 300f "check rename cross striped directory"
14104 test_300_check_default_striped_dir()
14107 local default_count=$2
14108 local default_index=$3
14111 local dir_stripe_index
14114 echo "checking $dirname $default_count $default_index"
14115 $LFS setdirstripe -D -c $default_count -i $default_index \
14116 -t all_char $DIR/$tdir/$dirname ||
14117 error "set default stripe on striped dir error"
14118 stripe_count=$($LFS getdirstripe -D -c $DIR/$tdir/$dirname)
14119 [ $stripe_count -eq $default_count ] ||
14120 error "expect $default_count get $stripe_count for $dirname"
14122 stripe_index=$($LFS getdirstripe -D -i $DIR/$tdir/$dirname)
14123 [ $stripe_index -eq $default_index ] ||
14124 error "expect $default_index get $stripe_index for $dirname"
14126 mkdir $DIR/$tdir/$dirname/{test1,test2,test3,test4} ||
14127 error "create dirs failed"
14129 createmany -o $DIR/$tdir/$dirname/f- 10 || error "create files failed"
14130 unlinkmany $DIR/$tdir/$dirname/f- 10 || error "unlink files failed"
14131 for dir in $(find $DIR/$tdir/$dirname/*); do
14132 stripe_count=$($LFS getdirstripe -c $dir)
14133 [ $stripe_count -eq $default_count ] ||
14134 [ $stripe_count -eq 0 -o $default_count -eq 1 ] ||
14135 error "stripe count $default_count != $stripe_count for $dir"
14137 stripe_index=$($LFS getdirstripe -i $dir)
14138 [ $default_index -eq -1 -o $stripe_index -eq $default_index ] ||
14139 error "$stripe_index != $default_index for $dir"
14141 #check default stripe
14142 stripe_count=$($LFS getdirstripe -D -c $dir)
14143 [ $stripe_count -eq $default_count ] ||
14144 error "default count $default_count != $stripe_count for $dir"
14146 stripe_index=$($LFS getdirstripe -D -i $dir)
14147 [ $stripe_index -eq $default_index ] ||
14148 error "default index $default_index != $stripe_index for $dir"
14150 rmdir $DIR/$tdir/$dirname/* || error "rmdir failed"
14154 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
14155 skip "Need MDS version at least 2.7.55" && return
14156 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
14162 mkdir $DIR/$tdir/normal_dir
14164 test_300_check_default_striped_dir normal_dir $MDSCOUNT 1
14165 test_300_check_default_striped_dir normal_dir 1 0
14166 test_300_check_default_striped_dir normal_dir 2 1
14167 test_300_check_default_striped_dir normal_dir 2 -1
14169 #delete default stripe information
14170 echo "delete default stripeEA"
14171 $LFS setdirstripe -d $DIR/$tdir/normal_dir ||
14172 error "set default stripe on striped dir error"
14174 mkdir -p $DIR/$tdir/normal_dir/{test1,test2,test3,test4}
14175 for dir in $(find $DIR/$tdir/normal_dir/*); do
14176 stripe_count=$($LFS getdirstripe -c $dir)
14177 [ $stripe_count -eq 0 ] ||
14178 error "expect 1 get $stripe_count for $dir"
14179 stripe_index=$($LFS getdirstripe -i $dir)
14180 [ $stripe_index -eq 0 ] ||
14181 error "expect 0 get $stripe_index for $dir"
14184 run_test 300g "check default striped directory for normal directory"
14187 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
14188 skip "Need MDS version at least 2.7.55" && return
14189 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
14194 $LFS setdirstripe -i 0 -c $MDSCOUNT -t all_char \
14195 $DIR/$tdir/striped_dir ||
14196 error "set striped dir error"
14198 test_300_check_default_striped_dir striped_dir $MDSCOUNT 1
14199 test_300_check_default_striped_dir striped_dir 1 0
14200 test_300_check_default_striped_dir striped_dir 2 1
14201 test_300_check_default_striped_dir striped_dir 2 -1
14203 #delete default stripe information
14204 $LFS setdirstripe -d $DIR/$tdir/striped_dir ||
14205 error "set default stripe on striped dir error"
14207 mkdir -p $DIR/$tdir/striped_dir/{test1,test2,test3,test4}
14208 for dir in $(find $DIR/$tdir/striped_dir/*); do
14209 stripe_count=$($LFS getdirstripe -c $dir)
14210 [ $stripe_count -eq 0 ] ||
14211 error "expect 1 get $stripe_count for $dir"
14214 run_test 300h "check default striped directory for striped directory"
14217 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
14218 skip "Need MDS version at least 2.7.55" && return
14219 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
14220 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
14226 $LFS setdirstripe -i 0 -c$MDSCOUNT -t all_char $DIR/$tdir/striped_dir ||
14227 error "set striped dir error"
14229 createmany -o $DIR/$tdir/striped_dir/f- 10 ||
14230 error "create files under striped dir failed"
14232 # unfortunately, we need to umount to clear dir layout cache for now
14233 # once we fully implement dir layout, we can drop this
14234 umount_client $MOUNT || error "umount failed"
14235 mount_client $MOUNT || error "mount failed"
14237 #set the stripe to be unknown hash type
14238 #define OBD_FAIL_UNKNOWN_LMV_STRIPE 0x1901
14239 $LCTL set_param fail_loc=0x1901
14240 for ((i = 0; i < 10; i++)); do
14241 $CHECKSTAT -t file $DIR/$tdir/striped_dir/f-$i ||
14242 error "stat f-$i failed"
14243 rm $DIR/$tdir/striped_dir/f-$i || error "unlink f-$i failed"
14246 touch $DIR/$tdir/striped_dir/f0 &&
14247 error "create under striped dir with unknown hash should fail"
14249 $LCTL set_param fail_loc=0
14251 umount_client $MOUNT || error "umount failed"
14252 mount_client $MOUNT || error "mount failed"
14256 run_test 300i "client handle unknown hash type striped directory"
14259 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
14260 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
14261 skip "Need MDS version at least 2.7.55" && return
14262 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
14268 #define OBD_FAIL_SPLIT_UPDATE_REC 0x1702
14269 $LCTL set_param fail_loc=0x1702
14270 $LFS setdirstripe -i 0 -c$MDSCOUNT -t all_char $DIR/$tdir/striped_dir ||
14271 error "set striped dir error"
14273 createmany -o $DIR/$tdir/striped_dir/f- 10 ||
14274 error "create files under striped dir failed"
14276 $LCTL set_param fail_loc=0
14278 rm -rf $DIR/$tdir || error "unlink striped dir fails"
14282 run_test 300j "test large update record"
14285 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
14286 skip "Need MDS version at least 2.7.55" && return
14287 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
14288 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
14294 #define OBD_FAIL_LARGE_STRIPE 0x1703
14295 $LCTL set_param fail_loc=0x1703
14296 $LFS setdirstripe -i 0 -c512 $DIR/$tdir/striped_dir ||
14297 error "set striped dir error"
14298 $LCTL set_param fail_loc=0
14300 $LFS getdirstripe $DIR/$tdir/striped_dir ||
14301 error "getstripeddir fails"
14302 rm -rf $DIR/$tdir/striped_dir ||
14303 error "unlink striped dir fails"
14307 run_test 300k "test large striped directory"
14310 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
14311 skip "Need MDS version at least 2.7.55" && return
14312 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
14313 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
14316 test_mkdir -p $DIR/$tdir/striped_dir
14317 chown $RUNAS_ID $DIR/$tdir/striped_dir ||
14318 error "chown $RUNAS_ID failed"
14319 $LFS setdirstripe -i 1 -D $DIR/$tdir/striped_dir ||
14320 error "set default striped dir failed"
14322 #define OBD_FAIL_MDS_STALE_DIR_LAYOUT 0x158
14323 $LCTL set_param fail_loc=0x80000158
14324 $RUNAS mkdir $DIR/$tdir/striped_dir/test_dir || error "create dir fails"
14326 stripe_index=$($LFS getdirstripe -i $DIR/$tdir/striped_dir/test_dir)
14327 [ $stripe_index -eq 1 ] ||
14328 error "expect 1 get $stripe_index for $dir"
14330 run_test 300l "non-root user to create dir under striped dir with stale layout"
14333 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
14334 skip "Need MDS version at least 2.7.55" && return
14335 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
14336 [ $MDSCOUNT -ge 2 ] && skip "Only for single MDT" && return
14338 mkdir -p $DIR/$tdir/striped_dir
14339 $LFS setdirstripe -D -c 1 $DIR/$tdir/striped_dir ||
14340 error "set default stripes dir error"
14342 mkdir $DIR/$tdir/striped_dir/a || error "mkdir a fails"
14344 stripe_count=$($LFS getdirstripe -c $DIR/$tdir/striped_dir/a)
14345 [ $stripe_count -eq 0 ] ||
14346 error "expect 0 get $stripe_count for a"
14348 $LFS setdirstripe -D -c 2 $DIR/$tdir/striped_dir ||
14349 error "set default stripes dir error"
14351 mkdir $DIR/$tdir/striped_dir/b || error "mkdir b fails"
14353 stripe_count=$($LFS getdirstripe -c $DIR/$tdir/striped_dir/b)
14354 [ $stripe_count -eq 0 ] ||
14355 error "expect 0 get $stripe_count for b"
14357 $LFS setdirstripe -D -c1 -i2 $DIR/$tdir/striped_dir ||
14358 error "set default stripes dir error"
14360 mkdir $DIR/$tdir/striped_dir/c &&
14361 error "default stripe_index is invalid, mkdir c should fails"
14363 rm -rf $DIR/$tdir || error "rmdir fails"
14365 run_test 300m "setstriped directory on single MDT FS"
14368 local list=$(comma_list $(mdts_nodes))
14371 do_nodes $list $LCTL set_param -n mdt.*.enable_remote_dir_gid=0
14375 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
14376 skip "Need MDS version at least 2.7.55" && return
14377 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
14378 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
14380 local list=$(comma_list $(mdts_nodes))
14382 trap cleanup_300n RETURN EXIT
14383 mkdir -p $DIR/$tdir
14384 chmod 777 $DIR/$tdir
14385 $RUNAS $LFS setdirstripe -i0 -c$MDSCOUNT \
14386 $DIR/$tdir/striped_dir > /dev/null 2>&1 &&
14387 error "create striped dir succeeds with gid=0"
14389 do_nodes $list $LCTL set_param -n mdt.*.enable_remote_dir_gid=-1
14390 $RUNAS $LFS setdirstripe -i0 -c$MDSCOUNT $DIR/$tdir/striped_dir ||
14391 error "create striped dir fails with gid=-1"
14393 do_nodes $list $LCTL set_param -n mdt.*.enable_remote_dir_gid=0
14394 $RUNAS $LFS setdirstripe -i 1 -c$MDSCOUNT -D \
14395 $DIR/$tdir/striped_dir > /dev/null 2>&1 &&
14396 error "set default striped dir succeeds with gid=0"
14399 do_nodes $list $LCTL set_param -n mdt.*.enable_remote_dir_gid=-1
14400 $RUNAS $LFS setdirstripe -i 1 -c$MDSCOUNT -D $DIR/$tdir/striped_dir ||
14401 error "set default striped dir fails with gid=-1"
14404 do_nodes $list $LCTL set_param -n mdt.*.enable_remote_dir_gid=0
14405 $RUNAS mkdir $DIR/$tdir/striped_dir/test_dir ||
14406 error "create test_dir fails"
14407 $RUNAS mkdir $DIR/$tdir/striped_dir/test_dir1 ||
14408 error "create test_dir1 fails"
14409 $RUNAS mkdir $DIR/$tdir/striped_dir/test_dir2 ||
14410 error "create test_dir2 fails"
14413 run_test 300n "non-root user to create dir under striped dir with default EA"
14416 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
14417 skip "Need MDS version at least 2.7.55" && return
14418 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
14419 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
14423 mkdir -p $DIR/$tdir
14425 numfree1=$(lctl get_param -n mdc.*MDT0000*.filesfree)
14426 numfree2=$(lctl get_param -n mdc.*MDT0001*.filesfree)
14427 if [ $numfree1 -lt 66000 -o $numfree2 -lt 66000 ]; then
14428 skip "not enough free inodes $numfree1 $numfree2"
14432 numfree1=$(lctl get_param -n mdc.*MDT0000-mdc-*.kbytesfree)
14433 numfree2=$(lctl get_param -n mdc.*MDT0001-mdc-*.kbytesfree)
14434 if [ $numfree1 -lt 300000 -o $numfree2 -lt 300000 ]; then
14435 skip "not enough free space $numfree1 $numfree2"
14439 $LFS setdirstripe -c2 $DIR/$tdir/striped_dir ||
14440 error "setdirstripe fails"
14442 createmany -d $DIR/$tdir/striped_dir/d 131000 ||
14443 error "create dirs fails"
14445 $LCTL set_param ldlm.namespaces.*mdc-*.lru_size=0
14446 ls $DIR/$tdir/striped_dir > /dev/null ||
14447 error "ls striped dir fails"
14448 unlinkmany -d $DIR/$tdir/striped_dir/d 131000 ||
14449 error "unlink big striped dir fails"
14451 run_test 300o "unlink big sub stripe(> 65000 subdirs)"
14454 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
14455 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
14457 mkdir -p $DIR/$tdir
14459 #define OBD_FAIL_OUT_ENOSPC 0x1704
14460 do_facet mds2 lctl set_param fail_loc=0x80001704
14461 $LFS setdirstripe -c2 $DIR/$tdir/bad_striped_dir > /dev/null 2>&1 &&
14462 error "create striped directory should fail"
14464 [ -e $DIR/$tdir/bad_striped_dir ] && error "striped dir exists"
14466 $LFS setdirstripe -c2 $DIR/$tdir/bad_striped_dir
14469 run_test 300p "create striped directory without space"
14472 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
14473 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
14475 local fd=$(free_fd)
14476 local cmd="exec $fd<$tdir"
14478 $LFS mkdir -c $MDSCOUNT $tdir || error "create $tdir fails"
14481 trap "eval $cmd" EXIT
14482 cd $tdir || error "cd $tdir fails"
14483 rmdir ../$tdir || error "rmdir $tdir fails"
14484 mkdir local_dir && error "create dir succeeds"
14485 $LFS setdirstripe -i1 remote_dir && error "create remote dir succeeds"
14489 run_test 300q "create remote directory under orphan directory"
14491 prepare_remote_file() {
14492 mkdir $DIR/$tdir/src_dir ||
14493 error "create remote source failed"
14495 cp /etc/hosts $DIR/$tdir/src_dir/a || error
14496 touch $DIR/$tdir/src_dir/a
14498 $LFS mkdir -i 1 $DIR/$tdir/tgt_dir ||
14499 error "create remote target dir failed"
14501 touch $DIR/$tdir/tgt_dir/b
14503 mrename $DIR/$tdir/src_dir/a $DIR/$tdir/tgt_dir/b ||
14504 error "rename dir cross MDT failed!"
14506 $CHECKSTAT -t file $DIR/$tdir/src_dir/a &&
14507 error "src_child still exists after rename"
14509 $CHECKSTAT -t file $DIR/$tdir/tgt_dir/b ||
14510 error "missing file(a) after rename"
14512 diff /etc/hosts $DIR/$tdir/tgt_dir/b ||
14513 error "diff after rename"
14517 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 4 MDTs" && return
14518 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
14519 local remote_file=$DIR/$tdir/tgt_dir/b
14521 mkdir -p $DIR/$tdir
14523 prepare_remote_file || error "prepare remote file failed"
14526 $OPENUNLINK $remote_file $remote_file || error
14527 $CHECKSTAT -a $remote_file || error
14529 run_test 310a "open unlink remote file"
14532 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 4 MDTs" && return
14533 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
14534 local remote_file=$DIR/$tdir/tgt_dir/b
14536 mkdir -p $DIR/$tdir
14538 prepare_remote_file || error "prepare remote file failed"
14540 ln $remote_file $DIR/$tfile || error "link failed for remote file"
14541 $MULTIOP $DIR/$tfile Ouc || error "mulitop failed"
14542 $CHECKSTAT -t file $remote_file || error "check file failed"
14544 run_test 310b "unlink remote file with multiple links while open"
14547 [[ $MDSCOUNT -lt 4 ]] && skip "needs >= 4 MDTs" && return
14548 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
14549 local remote_file=$DIR/$tdir/tgt_dir/b
14551 mkdir -p $DIR/$tdir
14553 prepare_remote_file || error "prepare remote file failed"
14555 ln $remote_file $DIR/$tfile || error "link failed for remote file"
14556 multiop_bg_pause $remote_file O_uc ||
14557 error "mulitop failed for remote file"
14559 $MULTIOP $DIR/$tfile Ouc
14560 kill -USR1 $MULTIPID
14563 run_test 310c "open-unlink remote file with multiple links"
14565 test_400a() { # LU-1606, was conf-sanity test_74
14566 local extra_flags=''
14567 local out=$TMP/$tfile
14568 local prefix=/usr/include/lustre
14571 if ! which $CC > /dev/null 2>&1; then
14572 skip_env "$CC is not installed"
14576 if ! [[ -d $prefix ]]; then
14577 # Assume we're running in tree and fixup the include path.
14578 extra_flags+=" -I$LUSTRE/../libcfs/include"
14579 extra_flags+=" -I$LUSTRE/include"
14580 extra_flags+=" -L$LUSTRE/utils"
14583 for prog in $LUSTRE_TESTS_API_DIR/*.c; do
14584 $CC -Wall -Werror $extra_flags -llustreapi -o $out $prog ||
14585 error "client api broken"
14588 run_test 400a "Lustre client api program can compile and link"
14590 test_400b() { # LU-1606, LU-5011
14592 local out=$TMP/$tfile
14593 local prefix=/usr/include/lustre
14595 # We use a hard coded prefix so that this test will not fail
14596 # when run in tree. There are headers in lustre/include/lustre/
14597 # that are not packaged (like lustre_idl.h) and have more
14598 # complicated include dependencies (like config.h and lnet/types.h).
14599 # Since this test about correct packaging we just skip them when
14600 # they don't exist (see below) rather than try to fixup cppflags.
14602 if ! which $CC > /dev/null 2>&1; then
14603 skip_env "$CC is not installed"
14607 for header in $prefix/*.h; do
14608 if ! [[ -f "$header" ]]; then
14612 if [[ "$(basename $header)" == liblustreapi.h ]]; then
14613 continue # liblustreapi.h is deprecated.
14616 $CC -Wall -Werror -include $header -c -x c /dev/null -o $out ||
14617 error "cannot compile '$header'"
14620 run_test 400b "packaged headers can be compiled"
14622 test_401a() { #LU-7437
14623 #count the number of parameters by "list_param -R"
14624 local params=$($LCTL list_param -R '*' 2>/dev/null | wc -l)
14625 #count the number of parameters by listing proc files
14626 local procs=$(find -L $proc_dirs -mindepth 1 -printf '%P\n' 2>/dev/null|
14629 [ $params -eq $procs ] ||
14630 error "found $params parameters vs. $procs proc files"
14632 # test the list_param -D option only returns directories
14633 params=$($LCTL list_param -R -D '*' 2>/dev/null | wc -l)
14634 #count the number of parameters by listing proc directories
14635 procs=$(find -L $proc_dirs -mindepth 1 -type d -printf '%P\n' 2>/dev/null |
14638 [ $params -eq $procs ] ||
14639 error "found $params parameters vs. $procs proc files"
14641 run_test 401a "Verify if 'lctl list_param -R' can list parameters recursively"
14644 local save=$($LCTL get_param -n jobid_var)
14647 $LCTL set_param foo=bar jobid_var=$tmp bar=baz &&
14648 error "no error returned when setting bad parameters"
14650 local jobid_new=$($LCTL get_param -n foe jobid_var baz)
14651 [[ "$jobid_new" == "$tmp" ]] || error "jobid tmp $jobid_new != $tmp"
14653 $LCTL set_param -n fog=bam jobid_var=$save bat=fog
14654 local jobid_old=$($LCTL get_param -n foe jobid_var bag)
14655 [[ "$jobid_old" == "$save" ]] || error "jobid new $jobid_old != $save"
14657 run_test 401b "Verify 'lctl {get,set}_param' continue after error"
14660 local jobid_var_old=$($LCTL get_param -n jobid_var)
14661 local jobid_var_new
14663 $LCTL set_param jobid_var= &&
14664 error "no error returned for 'set_param a='"
14666 jobid_var_new=$($LCTL get_param -n jobid_var)
14667 [[ "$jobid_var_old" == "$jobid_var_new" ]] ||
14668 error "jobid_var was changed by setting without value"
14670 $LCTL set_param jobid_var &&
14671 error "no error returned for 'set_param a'"
14673 jobid_var_new=$($LCTL get_param -n jobid_var)
14674 [[ "$jobid_var_old" == "$jobid_var_new" ]] ||
14675 error "jobid_var was changed by setting without value"
14677 run_test 401c "Verify 'lctl set_param' without value fails in either format."
14680 local jobid_var_old=$($LCTL get_param -n jobid_var)
14681 local jobid_var_new
14682 local new_value="foo=bar"
14684 $LCTL set_param jobid_var=$new_value ||
14685 error "'set_param a=b' did not accept a value containing '='"
14687 jobid_var_new=$($LCTL get_param -n jobid_var)
14688 [[ "$jobid_var_new" == "$new_value" ]] ||
14689 error "'set_param a=b' failed on a value containing '='"
14691 # Reset the jobid_var to test the other format
14692 $LCTL set_param jobid_var=$jobid_var_old
14693 jobid_var_new=$($LCTL get_param -n jobid_var)
14694 [[ "$jobid_var_new" == "$jobid_var_old" ]] ||
14695 error "failed to reset jobid_var"
14697 $LCTL set_param jobid_var $new_value ||
14698 error "'set_param a b' did not accept a value containing '='"
14700 jobid_var_new=$($LCTL get_param -n jobid_var)
14701 [[ "$jobid_var_new" == "$new_value" ]] ||
14702 error "'set_param a b' failed on a value containing '='"
14704 $LCTL set_param jobid_var $jobid_var_old
14705 jobid_var_new=$($LCTL get_param -n jobid_var)
14706 [[ "$jobid_var_new" == "$jobid_var_old" ]] ||
14707 error "failed to reset jobid_var"
14709 run_test 401d "Verify 'lctl set_param' accepts values containing '='"
14712 $LFS setdirstripe -i 0 $DIR/$tdir || error "setdirstripe -i 0 failed"
14713 #define OBD_FAIL_MDS_FLD_LOOKUP 0x15c
14714 do_facet mds1 "lctl set_param fail_loc=0x8000015c"
14715 touch $DIR/$tdir/$tfile && error "touch should fail with ENOENT" ||
14716 echo "Touch failed - OK"
14718 run_test 402 "Return ENOENT to lod_generate_and_set_lovea"
14721 local file1=$DIR/$tfile.1
14722 local file2=$DIR/$tfile.2
14723 local tfile=$TMP/$tfile
14725 rm -f $file1 $file2 $tfile
14730 # 30 sec OBD_TIMEOUT in ll_getattr()
14731 # right before populating st_nlink
14732 $LCTL set_param fail_loc=0x80001409
14733 stat -c %h $file1 > $tfile &
14735 # create an alias, drop all locks and reclaim the dentry
14737 cancel_lru_locks mdc
14738 cancel_lru_locks osc
14739 sysctl -w vm.drop_caches=2
14743 [ `cat $tfile` -gt 0 ] || error "wrong nlink count: `cat $tfile`"
14745 rm -f $tfile $file1 $file2
14747 run_test 403 "i_nlink should not drop to zero due to aliasing"
14749 test_404() { # LU-6601
14750 local mosps=$(do_facet $SINGLEMDS $LCTL dl |
14751 awk '/osp .*-osc-MDT/ { print $4}')
14754 for osp in $mosps; do
14755 echo "Deactivate: " $osp
14756 do_facet $SINGLEMDS $LCTL --device %$osp deactivate
14757 local stat=$(do_facet $SINGLEMDS $LCTL dl |
14758 awk -vp=$osp '$4 == p { print $2 }')
14759 [ $stat = IN ] || {
14760 do_facet $SINGLEMDS $LCTL dl | grep -w $osp
14761 error "deactivate error"
14763 echo "Activate: " $osp
14764 do_facet $SINGLEMDS $LCTL --device %$osp activate
14765 local stat=$(do_facet $SINGLEMDS $LCTL dl |
14766 awk -vp=$osp '$4 == p { print $2 }')
14767 [ $stat = UP ] || {
14768 do_facet $SINGLEMDS $LCTL dl | grep -w $osp
14769 error "activate error"
14773 run_test 404 "validate manual {de}activated works properly for OSPs"
14776 # tests that do cleanup/setup should be run at the end
14780 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
14782 #define OBD_FAIL_MGC_PAUSE_PROCESS_LOG 0x903
14783 $LCTL set_param fail_loc=0x903
14785 cancel_lru_locks MGC
14787 FAIL_ON_ERROR=true cleanup
14788 FAIL_ON_ERROR=true setup
14790 run_test 900 "umount should not race with any mgc requeue thread"
14793 [ -f $EXT2_DEV ] && rm $EXT2_DEV || true
14794 check_and_cleanup_lustre
14795 if [ "$I_MOUNTED" != "yes" ]; then
14796 lctl set_param debug="$OLDDEBUG" 2> /dev/null || true