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
112 MDT0=$($LCTL get_param -n mdc.*.mds_server_uuid |
113 awk '{ gsub(/_UUID/,""); print $1 }' | head -n1)
114 MAXFREE=${MAXFREE:-$((200000 * $OSTCOUNT))}
116 [ -f $DIR/d52a/foo ] && chattr -a $DIR/d52a/foo
117 [ -f $DIR/d52b/foo ] && chattr -i $DIR/d52b/foo
118 rm -rf $DIR/[Rdfs][0-9]*
120 # $RUNAS_ID may get set incorrectly somewhere else
121 [ $UID -eq 0 -a $RUNAS_ID -eq 0 ] && error "\$RUNAS_ID set to 0, but \$UID is also 0!"
123 check_runas_id $RUNAS_ID $RUNAS_GID $RUNAS
127 if [ "${ONLY}" = "MOUNT" ] ; then
128 echo "Lustre is up, please go on"
132 echo "preparing for tests involving mounts"
133 EXT2_DEV=${EXT2_DEV:-$TMP/SANITY.LOOP}
135 mke2fs -j -F $EXT2_DEV 8000 > /dev/null
136 echo # add a newline after mke2fs.
140 OLDDEBUG=$(lctl get_param -n debug 2> /dev/null)
141 lctl set_param debug=-1 2> /dev/null || true
144 $CHECKSTAT -t file $DIR/$tfile || error "$tfile is not a file"
146 $CHECKSTAT -a $DIR/$tfile || error "$tfile was not removed"
148 run_test 0a "touch; rm ====================="
151 chmod 0755 $DIR || error "chmod 0755 $DIR failed"
152 $CHECKSTAT -p 0755 $DIR || error "$DIR permission is not 0755"
154 run_test 0b "chmod 0755 $DIR ============================="
157 $LCTL get_param mdc.*.import | grep "state: FULL" ||
158 error "import not FULL"
159 $LCTL get_param mdc.*.import | grep "target: $FSNAME-MDT" ||
162 run_test 0c "check import proc ============================="
165 test_mkdir -p $DIR/$tdir || error "mkdir $tdir failed"
166 test_mkdir -p $DIR/$tdir/d2 || error "mkdir $tdir/d2 failed"
167 test_mkdir $DIR/$tdir/d2 && error "we expect EEXIST, but not returned"
168 $CHECKSTAT -t dir $DIR/$tdir/d2 || error "$tdir/d2 is not a dir"
171 $CHECKSTAT -a $DIR/$tdir || error "$tdir was not removed"
173 run_test 1 "mkdir; remkdir; rmdir =============================="
176 test_mkdir -p $DIR/$tdir || error "mkdir $tdir failed"
177 touch $DIR/$tdir/$tfile || error "touch $tdir/$tfile failed"
178 $CHECKSTAT -t file $DIR/$tdir/$tfile || error "$tdir/$tfile not a file"
180 $CHECKSTAT -a $DIR/$tdir/$tfile || error "$tdir/$file is not removed"
182 run_test 2 "mkdir; touch; rmdir; check file ===================="
185 test_mkdir -p $DIR/$tdir || error "mkdir $tdir failed"
186 $CHECKSTAT -t dir $DIR/$tdir || error "$tdir is not a directory"
187 touch $DIR/$tdir/$tfile
188 $CHECKSTAT -t file $DIR/$tdir/$tfile || error "$tdir/$tfile not a file"
190 $CHECKSTAT -a $DIR/$tdir || error "$tdir is not removed"
192 run_test 3 "mkdir; touch; rmdir; check dir ====================="
194 # LU-4471 - failed rmdir on remote directories still removes directory on MDT0
198 test_mkdir $DIR/$tdir ||
199 error "Create remote directory failed"
201 touch $DIR/$tdir/$tfile ||
202 error "Create file under remote directory failed"
205 error "Expect error removing in-use dir $DIR/$tdir"
207 test -d $DIR/$tdir || error "Remote directory disappeared"
209 rm -rf $DIR/$tdir || error "remove remote dir error"
211 run_test 4 "mkdir; touch dir/file; rmdir; checkdir (expect error)"
214 test_mkdir -p $DIR/$tdir || error "mkdir $tdir failed"
215 test_mkdir $DIR/$tdir/d2 || error "mkdir $tdir/d2 failed"
216 chmod 0707 $DIR/$tdir/d2 || error "chmod 0707 $tdir/d2 failed"
217 $CHECKSTAT -t dir -p 0707 $DIR/$tdir/d2 || error "$tdir/d2 not mode 707"
218 $CHECKSTAT -t dir $DIR/$tdir/d2 || error "$tdir/d2 is not a directory"
220 run_test 5 "mkdir .../d5 .../d5/d2; chmod .../d5/d2 ============"
223 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
224 chmod 0666 $DIR/$tfile || error "chmod 0666 $tfile failed"
225 $CHECKSTAT -t file -p 0666 -u \#$UID $DIR/$tfile ||
226 error "$tfile does not have perm 0666 or UID $UID"
227 $RUNAS chmod 0444 $DIR/$tfile && error "chmod $tfile worked on UID $UID"
228 $CHECKSTAT -t file -p 0666 -u \#$UID $DIR/$tfile ||
229 error "$tfile should be 0666 and owned by UID $UID"
231 run_test 6a "touch f6a; chmod f6a; $RUNAS chmod f6a (should return error) =="
234 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID" && return
236 chown $RUNAS_ID $DIR/$tfile || error "chown $RUNAS_ID $file failed"
237 $CHECKSTAT -t file -u \#$RUNAS_ID $DIR/$tfile ||
238 error "$tfile should be owned by UID $RUNAS_ID"
239 $RUNAS chown $UID $DIR/$tfile && error "chown $UID $file succeeded"
240 $CHECKSTAT -t file -u \#$RUNAS_ID $DIR/$tfile ||
241 error "$tfile should be owned by UID $RUNAS_ID"
243 run_test 6c "touch f6c; chown f6c; $RUNAS chown f6c (should return error) =="
246 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID" && return
248 chgrp $RUNAS_ID $DIR/$tfile || error "chgrp $RUNAS_ID $file failed"
249 $CHECKSTAT -t file -u \#$UID -g \#$RUNAS_ID $DIR/$tfile ||
250 error "$tfile should be owned by GID $UID"
251 $RUNAS chgrp $UID $DIR/$tfile && error "chgrp $UID $file succeeded"
252 $CHECKSTAT -t file -u \#$UID -g \#$RUNAS_ID $DIR/$tfile ||
253 error "$tfile should be owned by UID $UID and GID $RUNAS_ID"
255 run_test 6e "touch f6e; chgrp f6e; $RUNAS chgrp f6e (should return error) =="
258 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID" && return
259 test_mkdir $DIR/$tdir || error "mkdir $tfile failed"
260 chmod 777 $DIR/$tdir || error "chmod 0777 $tdir failed"
261 $RUNAS mkdir $DIR/$tdir/d || error "mkdir $tdir/d failed"
262 chmod g+s $DIR/$tdir/d || error "chmod g+s $tdir/d failed"
263 test_mkdir $DIR/$tdir/d/subdir || error "mkdir $tdir/d/subdir failed"
264 $CHECKSTAT -g \#$RUNAS_GID $DIR/$tdir/d/subdir ||
265 error "$tdir/d/subdir should be GID $RUNAS_GID"
267 run_test 6g "Is new dir in sgid dir inheriting group?"
269 test_6h() { # bug 7331
270 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID" && return
271 touch $DIR/$tfile || error "touch failed"
272 chown $RUNAS_ID:$RUNAS_GID $DIR/$tfile || error "initial chown failed"
273 $RUNAS -G$RUNAS_GID chown $RUNAS_ID:0 $DIR/$tfile &&
274 error "chown $RUNAS_ID:0 $tfile worked as GID $RUNAS_GID"
275 $CHECKSTAT -t file -u \#$RUNAS_ID -g \#$RUNAS_GID $DIR/$tfile ||
276 error "$tdir/$tfile should be UID $RUNAS_UID GID $RUNAS_GID"
278 run_test 6h "$RUNAS chown RUNAS_ID.0 .../f6h (should return error)"
281 test_mkdir $DIR/$tdir
282 $MCREATE $DIR/$tdir/$tfile
283 chmod 0666 $DIR/$tdir/$tfile
284 $CHECKSTAT -t file -p 0666 $DIR/$tdir/$tfile ||
285 error "$tdir/$tfile should be mode 0666"
287 run_test 7a "mkdir .../d7; mcreate .../d7/f; chmod .../d7/f ===="
290 if [ ! -d $DIR/$tdir ]; then
291 test_mkdir $DIR/$tdir
293 $MCREATE $DIR/$tdir/$tfile
294 echo -n foo > $DIR/$tdir/$tfile
295 [ "$(cat $DIR/$tdir/$tfile)" = "foo" ] || error "$tdir/$tfile not 'foo'"
296 $CHECKSTAT -t file -s 3 $DIR/$tdir/$tfile || error "$tfile size not 3"
298 run_test 7b "mkdir .../d7; mcreate d7/f2; echo foo > d7/f2 ====="
301 test_mkdir $DIR/$tdir
302 touch $DIR/$tdir/$tfile
303 chmod 0666 $DIR/$tdir/$tfile
304 $CHECKSTAT -t file -p 0666 $DIR/$tdir/$tfile ||
305 error "$tfile mode not 0666"
307 run_test 8 "mkdir .../d8; touch .../d8/f; chmod .../d8/f ======="
310 test_mkdir $DIR/$tdir
311 test_mkdir $DIR/$tdir/d2
312 test_mkdir $DIR/$tdir/d2/d3
313 $CHECKSTAT -t dir $DIR/$tdir/d2/d3 || error "$tdir/d2/d3 not a dir"
315 run_test 9 "mkdir .../d9 .../d9/d2 .../d9/d2/d3 ================"
318 test_mkdir $DIR/$tdir
319 test_mkdir $DIR/$tdir/d2
320 touch $DIR/$tdir/d2/$tfile
321 $CHECKSTAT -t file $DIR/$tdir/d2/$tfile ||
322 error "$tdir/d2/$tfile not a file"
324 run_test 10 "mkdir .../d10 .../d10/d2; touch .../d10/d2/f ======"
327 test_mkdir $DIR/$tdir
328 test_mkdir $DIR/$tdir/d2
329 chmod 0666 $DIR/$tdir/d2
330 chmod 0705 $DIR/$tdir/d2
331 $CHECKSTAT -t dir -p 0705 $DIR/$tdir/d2 ||
332 error "$tdir/d2 mode not 0705"
334 run_test 11 "mkdir .../d11 d11/d2; chmod .../d11/d2 ============"
337 test_mkdir $DIR/$tdir
338 touch $DIR/$tdir/$tfile
339 chmod 0666 $DIR/$tdir/$tfile
340 chmod 0654 $DIR/$tdir/$tfile
341 $CHECKSTAT -t file -p 0654 $DIR/$tdir/$tfile ||
342 error "$tdir/d2 mode not 0654"
344 run_test 12 "touch .../d12/f; chmod .../d12/f .../d12/f ========"
347 test_mkdir $DIR/$tdir
348 dd if=/dev/zero of=$DIR/$tdir/$tfile count=10
350 $CHECKSTAT -t file -s 0 $DIR/$tdir/$tfile ||
351 error "$tdir/$tfile size not 0 after truncate"
353 run_test 13 "creat .../d13/f; dd .../d13/f; > .../d13/f ========"
356 test_mkdir $DIR/$tdir
357 touch $DIR/$tdir/$tfile
359 $CHECKSTAT -a $DIR/$tdir/$tfile || error "$tdir/$tfile not removed"
361 run_test 14 "touch .../d14/f; rm .../d14/f; rm .../d14/f ======="
364 test_mkdir $DIR/$tdir
365 touch $DIR/$tdir/$tfile
366 mv $DIR/$tdir/$tfile $DIR/$tdir/${tfile}_2
367 $CHECKSTAT -t file $DIR/$tdir/${tfile}_2 ||
368 error "$tdir/${tfile_2} not a file after rename"
369 rm $DIR/$tdir/${tfile}_2 || error "unlink failed after rename"
371 run_test 15 "touch .../d15/f; mv .../d15/f .../d15/f2 =========="
374 test_mkdir $DIR/$tdir
375 touch $DIR/$tdir/$tfile
376 rm -rf $DIR/$tdir/$tfile
377 $CHECKSTAT -a $DIR/$tdir/$tfile || error "$tdir/$tfile not removed"
379 run_test 16 "touch .../d16/f; rm -rf .../d16/f ================="
382 test_mkdir -p $DIR/$tdir
383 touch $DIR/$tdir/$tfile
384 ln -s $DIR/$tdir/$tfile $DIR/$tdir/l-exist
386 $CHECKSTAT -l $DIR/$tdir/$tfile $DIR/$tdir/l-exist ||
387 error "$tdir/l-exist not a symlink"
388 $CHECKSTAT -f -t f $DIR/$tdir/l-exist ||
389 error "$tdir/l-exist not referencing a file"
390 rm -f $DIR/$tdir/l-exist
391 $CHECKSTAT -a $DIR/$tdir/l-exist || error "$tdir/l-exist not removed"
393 run_test 17a "symlinks: create, remove (real) =================="
396 test_mkdir -p $DIR/$tdir
397 ln -s no-such-file $DIR/$tdir/l-dangle
399 $CHECKSTAT -l no-such-file $DIR/$tdir/l-dangle ||
400 error "$tdir/l-dangle not referencing no-such-file"
401 $CHECKSTAT -fa $DIR/$tdir/l-dangle ||
402 error "$tdir/l-dangle not referencing non-existent file"
403 rm -f $DIR/$tdir/l-dangle
404 $CHECKSTAT -a $DIR/$tdir/l-dangle || error "$tdir/l-dangle not removed"
406 run_test 17b "symlinks: create, remove (dangling) =============="
408 test_17c() { # bug 3440 - don't save failed open RPC for replay
409 test_mkdir -p $DIR/$tdir
410 ln -s foo $DIR/$tdir/$tfile
411 cat $DIR/$tdir/$tfile && error "opened non-existent symlink" || true
413 run_test 17c "symlinks: open dangling (should return error) ===="
416 test_mkdir -p $DIR/$tdir
417 ln -s foo $DIR/$tdir/$tfile
418 touch $DIR/$tdir/$tfile || error "creating to new symlink"
420 run_test 17d "symlinks: create dangling ========================"
423 test_mkdir -p $DIR/$tdir
424 local foo=$DIR/$tdir/$tfile
425 ln -s $foo $foo || error "create symlink failed"
426 ls -l $foo || error "ls -l failed"
427 ls $foo && error "ls not failed" || true
429 run_test 17e "symlinks: create recursive symlink (should return error) ===="
432 test_mkdir -p $DIR/$tdir
433 ln -s 1234567890/2234567890/3234567890/4234567890 $DIR/$tdir/111
434 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890 $DIR/$tdir/222
435 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890 $DIR/$tdir/333
436 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890/9234567890/a234567890/b234567890 $DIR/$tdir/444
437 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890/9234567890/a234567890/b234567890/c234567890/d234567890/f234567890 $DIR/$tdir/555
438 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
441 run_test 17f "symlinks: long and very long symlink name ========================"
443 # str_repeat(S, N) generate a string that is string S repeated N times
448 while [ $((n -= 1)) -ge 0 ]; do
454 # Long symlinks and LU-2241
456 test_mkdir -p $DIR/$tdir
457 local TESTS="59 60 61 4094 4095"
459 # Fix for inode size boundary in 2.1.4
460 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.1.4) ] &&
463 # Patch not applied to 2.2 or 2.3 branches
464 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] &&
465 [ $(lustre_version_code $SINGLEMDS) -le $(version_code 2.3.55) ] &&
468 # skip long symlink name for rhel6.5.
469 # rhel6.5 has a limit (PATH_MAX - sizeof(struct filename))
470 grep -q '6.5' /etc/redhat-release &>/dev/null &&
471 TESTS="59 60 61 4062 4063"
474 local SYMNAME=$(str_repeat 'x' $i)
475 ln -s $SYMNAME $DIR/$tdir/f$i || error "failed $i-char symlink"
476 readlink $DIR/$tdir/f$i || error "failed $i-char readlink"
479 run_test 17g "symlinks: really long symlink name and inode boundaries"
481 test_17h() { #bug 17378
482 remote_mds_nodsh && skip "remote MDS with nodsh" && return
483 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
485 test_mkdir -p $DIR/$tdir
486 if [[ $MDSCOUNT -gt 1 ]]; then
487 mdt_idx=$($LFS getdirstripe -i $DIR/$tdir)
491 $SETSTRIPE -c -1 $DIR/$tdir
492 #define OBD_FAIL_MDS_LOV_PREP_CREATE 0x141
493 do_facet mds$((mdt_idx + 1)) lctl set_param fail_loc=0x80000141
494 touch $DIR/$tdir/$tfile || true
496 run_test 17h "create objects: lov_free_memmd() doesn't lbug"
498 test_17i() { #bug 20018
499 remote_mds_nodsh && skip "remote MDS with nodsh" && return
500 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
501 test_mkdir -c1 $DIR/$tdir
502 local foo=$DIR/$tdir/$tfile
504 if [[ $MDSCOUNT -gt 1 ]]; then
505 mdt_idx=$($LFS getdirstripe -i $DIR/$tdir)
509 ln -s $foo $foo || error "create symlink failed"
510 #define OBD_FAIL_MDS_READLINK_EPROTO 0x143
511 do_facet mds$((mdt_idx + 1)) lctl set_param fail_loc=0x80000143
512 ls -l $foo && error "error not detected"
515 run_test 17i "don't panic on short symlink"
517 test_17k() { #bug 22301
518 [[ -z "$(which rsync 2>/dev/null)" ]] &&
519 skip "no rsync command" && return 0
520 rsync --help | grep -q xattr ||
521 skip_env "$(rsync --version | head -n1) does not support xattrs"
522 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return 0
523 test_mkdir -p $DIR/$tdir
524 test_mkdir -p $DIR/$tdir.new
525 touch $DIR/$tdir/$tfile
526 ln -s $DIR/$tdir/$tfile $DIR/$tdir/$tfile.lnk
527 rsync -av -X $DIR/$tdir/ $DIR/$tdir.new ||
528 error "rsync failed with xattrs enabled"
530 run_test 17k "symlinks: rsync with xattrs enabled ========================="
532 test_17l() { # LU-279
533 [[ -z "$(which getfattr 2>/dev/null)" ]] &&
534 skip "no getfattr command" && return 0
535 test_mkdir -p $DIR/$tdir
536 touch $DIR/$tdir/$tfile
537 ln -s $DIR/$tdir/$tfile $DIR/$tdir/$tfile.lnk
538 for path in "$DIR/$tdir" "$DIR/$tdir/$tfile" "$DIR/$tdir/$tfile.lnk"; do
539 # -h to not follow symlinks. -m '' to list all the xattrs.
540 # grep to remove first line: '# file: $path'.
541 for xattr in `getfattr -hm '' $path 2>/dev/null | grep -v '^#'`;
543 lgetxattr_size_check $path $xattr ||
544 error "lgetxattr_size_check $path $xattr failed"
548 run_test 17l "Ensure lgetxattr's returned xattr size is consistent ========"
552 local short_sym="0123456789"
553 local WDIR=$DIR/${tdir}m
556 remote_mds_nodsh && skip "remote MDS with nodsh" && return
557 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] &&
558 [ $(lustre_version_code $SINGLEMDS) -le $(version_code 2.2.93) ] &&
559 skip "MDS 2.2.0-2.2.93 do not NUL-terminate symlinks" && return
561 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
562 skip "only for ldiskfs MDT" && return 0
564 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
568 # create a long symlink file
569 for ((i = 0; i < 4; ++i)); do
570 long_sym=${long_sym}${long_sym}
573 echo "create 512 short and long symlink files under $WDIR"
574 for ((i = 0; i < 256; ++i)); do
575 ln -sf ${long_sym}"a5a5" $WDIR/long-$i
576 ln -sf ${short_sym}"a5a5" $WDIR/short-$i
582 wait_delete_completed
584 echo "recreate the 512 symlink files with a shorter string"
585 for ((i = 0; i < 512; ++i)); do
586 # rewrite the symlink file with a shorter string
587 ln -sf ${long_sym} $WDIR/long-$i || error "long_sym failed"
588 ln -sf ${short_sym} $WDIR/short-$i || error "short_sym failed"
591 local mds_index=$(($($LFS getstripe -M $WDIR) + 1))
592 local devname=$(mdsdevname $mds_index)
594 echo "stop and checking mds${mds_index}:"
595 # e2fsck should not return error
597 run_e2fsck $(facet_active_host mds${mds_index}) $devname -n
600 start mds${mds_index} $devname $MDS_MOUNT_OPTS || error "start failed"
601 df $MOUNT > /dev/null 2>&1
603 error "e2fsck detected error for short/long symlink: rc=$rc"
605 run_test 17m "run e2fsck against MDT which contains short/long symlink"
607 check_fs_consistency_17n() {
611 # create/unlink in 17n only change 2 MDTs(MDT1/MDT2),
612 # so it only check MDT1/MDT2 instead of all of MDTs.
613 for mdt_index in 1 2; do
614 local devname=$(mdsdevname $mdt_index)
615 # e2fsck should not return error
617 run_e2fsck $(facet_active_host mds$mdt_index) $devname -n ||
620 start mds${mdt_index} $devname $MDS_MOUNT_OPTS ||
621 error "mount mds$mdt_index failed"
622 df $MOUNT > /dev/null 2>&1
630 remote_mds_nodsh && skip "remote MDS with nodsh" && return
631 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] &&
632 [ $(lustre_version_code $SINGLEMDS) -le $(version_code 2.2.93) ] &&
633 skip "MDS 2.2.0-2.2.93 do not NUL-terminate symlinks" && return
635 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
636 skip "only for ldiskfs MDT" && return 0
638 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 2 MDTs" && return
640 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
642 test_mkdir $DIR/$tdir
643 for ((i=0; i<10; i++)); do
644 $LFS mkdir -i1 -c2 $DIR/$tdir/remote_dir_${i} ||
645 error "create remote dir error $i"
646 createmany -o $DIR/$tdir/remote_dir_${i}/f 10 ||
647 error "create files under remote dir failed $i"
650 check_fs_consistency_17n ||
651 error "e2fsck report error after create files under remote dir"
653 for ((i = 0; i < 10; i++)); do
654 rm -rf $DIR/$tdir/remote_dir_${i} ||
655 error "destroy remote dir error $i"
658 check_fs_consistency_17n ||
659 error "e2fsck report error after unlink files under remote dir"
661 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.50) ] &&
662 skip "lustre < 2.4.50 does not support migrate mv " && return
664 for ((i = 0; i < 10; i++)); do
665 mkdir -p $DIR/$tdir/remote_dir_${i}
666 createmany -o $DIR/$tdir/remote_dir_${i}/f 10 ||
667 error "create files under remote dir failed $i"
668 $LFS migrate --mdt-index 1 $DIR/$tdir/remote_dir_${i} ||
669 error "migrate remote dir error $i"
671 check_fs_consistency_17n || error "e2fsck report error after migration"
673 for ((i = 0; i < 10; i++)); do
674 rm -rf $DIR/$tdir/remote_dir_${i} ||
675 error "destroy remote dir error $i"
678 check_fs_consistency_17n || error "e2fsck report error after unlink"
680 run_test 17n "run e2fsck against master/slave MDT which contains remote dir"
683 remote_mds_nodsh && skip "remote MDS with nodsh" && return
684 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.3.64) ] &&
685 skip "Need MDS version at least 2.3.64" && return
687 local WDIR=$DIR/${tdir}o
692 mdt_index=$($LFS getstripe -M $WDIR)
693 mdt_index=$((mdt_index+1))
697 #fail mds will wait the failover finish then set
698 #following fail_loc to avoid interfer the recovery process.
701 #define OBD_FAIL_OSD_LMA_INCOMPAT 0x194
702 do_facet mds${mdt_index} lctl set_param fail_loc=0x194
703 ls -l $WDIR/$tfile && rc=1
704 do_facet mds${mdt_index} lctl set_param fail_loc=0
705 [[ $rc -ne 0 ]] && error "stat file should fail"
708 run_test 17o "stat file with incompat LMA feature"
711 touch $DIR/$tfile || error "Failed to touch $DIR/$tfile: $?"
712 ls $DIR || error "Failed to ls $DIR: $?"
714 run_test 18 "touch .../f ; ls ... =============================="
720 $CHECKSTAT -a $DIR/$tfile || error "$tfile was not removed"
722 run_test 19a "touch .../f19 ; ls -l ... ; rm .../f19 ==========="
725 ls -l $DIR/$tfile && error "ls -l $tfile failed"|| true
727 run_test 19b "ls -l .../f19 (should return error) =============="
730 [ $RUNAS_ID -eq $UID ] &&
731 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
732 $RUNAS touch $DIR/$tfile && error "create non-root file failed" || true
734 run_test 19c "$RUNAS touch .../f19 (should return error) =="
737 cat $DIR/f19 && error || true
739 run_test 19d "cat .../f19 (should return error) =============="
751 $CHECKSTAT -a $DIR/$tfile || error "$tfile was not removed"
753 run_test 20 "touch .../f ; ls -l ... ==========================="
756 test_mkdir -p $DIR/$tdir
757 [ -f $DIR/$tdir/dangle ] && rm -f $DIR/$tdir/dangle
758 ln -s dangle $DIR/$tdir/link
759 echo foo >> $DIR/$tdir/link
760 cat $DIR/$tdir/dangle
761 $CHECKSTAT -t link $DIR/$tdir/link || error "$tdir/link not a link"
762 $CHECKSTAT -f -t file $DIR/$tdir/link ||
763 error "$tdir/link not linked to a file"
765 run_test 21 "write to dangling link ============================"
769 test_mkdir -p $DIR/$tdir
770 chown $RUNAS_ID:$RUNAS_GID $WDIR
771 (cd $WDIR || error "cd $WDIR failed";
772 $RUNAS tar cf - /etc/hosts /etc/sysconfig/network | \
774 ls -lR $WDIR/etc || error "ls -lR $WDIR/etc failed"
775 $CHECKSTAT -t dir $WDIR/etc || error "checkstat -t dir failed"
776 $CHECKSTAT -u \#$RUNAS_ID -g \#$RUNAS_GID $WDIR/etc || error "checkstat -u failed"
778 run_test 22 "unpack tar archive as non-root user ==============="
782 test_mkdir -p $DIR/$tdir
783 local file=$DIR/$tdir/$tfile
785 openfile -f O_CREAT:O_EXCL $file || error "$file create failed"
786 openfile -f O_CREAT:O_EXCL $file &&
787 error "$file recreate succeeded" || true
789 run_test 23a "O_CREAT|O_EXCL in subdir =========================="
791 test_23b() { # bug 18988
792 test_mkdir -p $DIR/$tdir
793 local file=$DIR/$tdir/$tfile
796 echo foo > $file || error "write filed"
797 echo bar >> $file || error "append filed"
798 $CHECKSTAT -s 8 $file || error "wrong size"
801 run_test 23b "O_APPEND check =========================="
805 echo '-- same directory rename'
806 test_mkdir $DIR/$tdir
807 touch $DIR/$tdir/$tfile.1
808 mv $DIR/$tdir/$tfile.1 $DIR/$tdir/$tfile.2
809 $CHECKSTAT -t file $DIR/$tdir/$tfile.2 || error "$tfile.2 not a file"
811 run_test 24a "rename file to non-existent target"
814 test_mkdir $DIR/$tdir
815 touch $DIR/$tdir/$tfile.{1,2}
816 mv $DIR/$tdir/$tfile.1 $DIR/$tdir/$tfile.2
817 $CHECKSTAT -a $DIR/$tdir/$tfile.1 || error "$tfile.1 exists"
818 $CHECKSTAT -t file $DIR/$tdir/$tfile.2 || error "$tfile.2 not a file"
820 run_test 24b "rename file to existing target"
823 test_mkdir $DIR/$tdir
824 test_mkdir $DIR/$tdir/d$testnum.1
825 mv $DIR/$tdir/d$testnum.1 $DIR/$tdir/d$testnum.2
826 $CHECKSTAT -a $DIR/$tdir/d$testnum.1 || error "d$testnum.1 exists"
827 $CHECKSTAT -t dir $DIR/$tdir/d$testnum.2 || error "d$testnum.2 not dir"
829 run_test 24c "rename directory to non-existent target"
832 test_mkdir -c1 $DIR/$tdir
833 test_mkdir -c1 $DIR/$tdir/d$testnum.1
834 test_mkdir -c1 $DIR/$tdir/d$testnum.2
835 mrename $DIR/$tdir/d$testnum.1 $DIR/$tdir/d$testnum.2
836 $CHECKSTAT -a $DIR/$tdir/d$testnum.1 || error "d$testnum.1 exists"
837 $CHECKSTAT -t dir $DIR/$tdir/d$testnum.2 || error "d$testnum.2 not dir"
839 run_test 24d "rename directory to existing target"
842 echo '-- cross directory renames --'
846 mv $DIR/R5a/f $DIR/R5b/g
847 $CHECKSTAT -a $DIR/R5a/f || error
848 $CHECKSTAT -t file $DIR/R5b/g || error
850 run_test 24e "touch .../R5a/f; rename .../R5a/f .../R5b/g ======"
855 touch $DIR/R6a/f $DIR/R6b/g
856 mv $DIR/R6a/f $DIR/R6b/g
857 $CHECKSTAT -a $DIR/R6a/f || error
858 $CHECKSTAT -t file $DIR/R6b/g || error
860 run_test 24f "touch .../R6a/f R6b/g; mv .../R6a/f .../R6b/g ===="
865 test_mkdir $DIR/R7a/d
866 mv $DIR/R7a/d $DIR/R7b/e
867 $CHECKSTAT -a $DIR/R7a/d || error
868 $CHECKSTAT -t dir $DIR/R7b/e || error
870 run_test 24g "mkdir .../R7{a,b}/d; mv .../R7a/d .../R7b/e ======"
873 test_mkdir -c1 $DIR/R8a
874 test_mkdir -c1 $DIR/R8b
875 test_mkdir -c1 $DIR/R8a/d
876 test_mkdir -c1 $DIR/R8b/e
877 mrename $DIR/R8a/d $DIR/R8b/e
878 $CHECKSTAT -a $DIR/R8a/d || error
879 $CHECKSTAT -t dir $DIR/R8b/e || error
881 run_test 24h "mkdir .../R8{a,b}/{d,e}; rename .../R8a/d .../R8b/e"
884 echo "-- rename error cases"
888 mrename $DIR/R9/f $DIR/R9/a
889 $CHECKSTAT -t file $DIR/R9/f || error
890 $CHECKSTAT -t dir $DIR/R9/a || error
891 $CHECKSTAT -a $DIR/R9/a/f || error
893 run_test 24i "rename file to dir error: touch f ; mkdir a ; rename f a"
897 mrename $DIR/R10/f $DIR/R10/g
898 $CHECKSTAT -t dir $DIR/R10 || error
899 $CHECKSTAT -a $DIR/R10/f || error
900 $CHECKSTAT -a $DIR/R10/g || error
902 run_test 24j "source does not exist ============================"
906 test_mkdir $DIR/R11a/d
908 mv $DIR/R11a/f $DIR/R11a/d
909 $CHECKSTAT -a $DIR/R11a/f || error
910 $CHECKSTAT -t file $DIR/R11a/d/f || error
912 run_test 24k "touch .../R11a/f; mv .../R11a/f .../R11a/d ======="
914 # bug 2429 - rename foo foo foo creates invalid file
917 $MULTIOP $f OcNs || error
919 run_test 24l "Renaming a file to itself ========================"
923 $MULTIOP $f OcLN ${f}2 ${f}2 || error "link ${f}2 ${f}2 failed"
924 # on ext3 this does not remove either the source or target files
925 # though the "expected" operation would be to remove the source
926 $CHECKSTAT -t file ${f} || error "${f} missing"
927 $CHECKSTAT -t file ${f}2 || error "${f}2 missing"
929 run_test 24m "Renaming a file to a hard link to itself ========="
933 # this stats the old file after it was renamed, so it should fail
937 $CHECKSTAT ${f}.rename
940 run_test 24n "Statting the old file after renaming (Posix rename 2)"
943 test_mkdir -p $DIR/d24o
944 rename_many -s random -v -n 10 $DIR/d24o
946 run_test 24o "rename of files during htree split ==============="
951 DIRINO=`ls -lid $DIR/R12a | awk '{ print $1 }'`
952 mrename $DIR/R12a $DIR/R12b
953 $CHECKSTAT -a $DIR/R12a || error
954 $CHECKSTAT -t dir $DIR/R12b || error
955 DIRINO2=`ls -lid $DIR/R12b | awk '{ print $1 }'`
956 [ "$DIRINO" = "$DIRINO2" ] || error "R12a $DIRINO != R12b $DIRINO2"
958 run_test 24p "mkdir .../R12{a,b}; rename .../R12a .../R12b"
960 cleanup_multiop_pause() {
966 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
969 local DIRINO=$(ls -lid $DIR/R13a | awk '{ print $1 }')
970 multiop_bg_pause $DIR/R13b D_c || error "multiop failed to start"
973 trap cleanup_multiop_pause EXIT
974 mrename $DIR/R13a $DIR/R13b
975 $CHECKSTAT -a $DIR/R13a || error "R13a still exists"
976 $CHECKSTAT -t dir $DIR/R13b || error "R13b does not exist"
977 local DIRINO2=$(ls -lid $DIR/R13b | awk '{ print $1 }')
978 [ "$DIRINO" = "$DIRINO2" ] || error "R13a $DIRINO != R13b $DIRINO2"
979 cleanup_multiop_pause
980 wait $MULTIPID || error "multiop close failed"
982 run_test 24q "mkdir .../R13{a,b}; open R13b rename R13a R13b ==="
984 test_24r() { #bug 3789
986 test_mkdir $DIR/R14a/b
987 mrename $DIR/R14a $DIR/R14a/b && error "rename to subdir worked!"
988 $CHECKSTAT -t dir $DIR/R14a || error "$DIR/R14a missing"
989 $CHECKSTAT -t dir $DIR/R14a/b || error "$DIR/R14a/b missing"
991 run_test 24r "mkdir .../R14a/b; rename .../R14a .../R14a/b ====="
995 test_mkdir $DIR/R15a/b
996 test_mkdir $DIR/R15a/b/c
997 mrename $DIR/R15a $DIR/R15a/b/c && error "rename to sub-subdir worked!"
998 $CHECKSTAT -t dir $DIR/R15a || error "$DIR/R15a missing"
999 $CHECKSTAT -t dir $DIR/R15a/b/c || error "$DIR/R15a/b/c missing"
1001 run_test 24s "mkdir .../R15a/b/c; rename .../R15a .../R15a/b/c ="
1003 test_mkdir $DIR/R16a
1004 test_mkdir $DIR/R16a/b
1005 test_mkdir $DIR/R16a/b/c
1006 mrename $DIR/R16a/b/c $DIR/R16a && error "rename to sub-subdir worked!"
1007 $CHECKSTAT -t dir $DIR/R16a || error "$DIR/R16a missing"
1008 $CHECKSTAT -t dir $DIR/R16a/b/c || error "$DIR/R16a/b/c missing"
1010 run_test 24t "mkdir .../R16a/b/c; rename .../R16a/b/c .../R16a ="
1012 test_24u() { # bug12192
1013 $MULTIOP $DIR/$tfile C2w$((2048 * 1024))c || error
1014 $CHECKSTAT -s $((2048 * 1024)) $DIR/$tfile || error "wrong file size"
1016 run_test 24u "create stripe file"
1022 simple_cleanup_common() {
1025 wait_delete_completed
1028 max_pages_per_rpc() {
1029 $LCTL get_param -n mdc.*.max_pages_per_rpc | head -n1
1033 local NRFILES=100000
1034 local FREE_INODES=$(mdt_free_inodes 0)
1035 [[ $FREE_INODES -lt $NRFILES ]] &&
1036 skip "not enough free inodes $FREE_INODES required $NRFILES" &&
1039 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1040 trap simple_cleanup_common EXIT
1042 # Performance issue on ZFS see LU-4072 (c.f. LU-2887)
1043 [ $(facet_fstype $SINGLEMDS) = "zfs" ] && NRFILES=10000
1045 test_mkdir -p $DIR/$tdir
1046 createmany -m $DIR/$tdir/$tfile $NRFILES
1048 cancel_lru_locks mdc
1049 lctl set_param mdc.*.stats clear
1051 ls $DIR/$tdir >/dev/null || error "error in listing large dir"
1053 # LU-5 large readdir
1054 # DIRENT_SIZE = 32 bytes for sizeof(struct lu_dirent) +
1055 # 8 bytes for name(filename is mostly 5 in this test) +
1056 # 8 bytes for luda_type
1057 # take into account of overhead in lu_dirpage header and end mark in
1058 # each page, plus one in RPC_NUM calculation.
1060 RPC_SIZE=$(($(max_pages_per_rpc) * $(page_size)))
1061 RPC_NUM=$(((NRFILES * DIRENT_SIZE + RPC_SIZE - 1) / RPC_SIZE + 1))
1062 mds_readpage=$(lctl get_param mdc.*MDT0000*.stats |
1063 awk '/^mds_readpage/ {print $2}')
1064 [[ $mds_readpage -gt $RPC_NUM ]] &&
1065 error "large readdir doesn't take effect"
1067 simple_cleanup_common
1069 run_test 24v "list directory with large files (handle hash collision, bug: 17560)"
1071 test_24w() { # bug21506
1073 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=4096 || return 1
1074 dd if=/dev/zero bs=$SZ1 count=1 >> $DIR/$tfile || return 2
1075 dd if=$DIR/$tfile of=$DIR/${tfile}_left bs=1M skip=4097 || return 3
1076 SZ2=`ls -l $DIR/${tfile}_left | awk '{print $5}'`
1077 [[ "$SZ1" -eq "$SZ2" ]] ||
1078 error "Error reading at the end of the file $tfile"
1080 run_test 24w "Reading a file larger than 4Gb"
1083 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 2 MDTs" && return
1084 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1086 local remote_dir=$DIR/$tdir/remote_dir
1088 test_mkdir -p $DIR/$tdir
1089 $LFS mkdir -i $MDTIDX $remote_dir ||
1090 error "create remote directory failed"
1092 test_mkdir -p $DIR/$tdir/src_dir
1093 touch $DIR/$tdir/src_file
1094 test_mkdir -p $remote_dir/tgt_dir
1095 touch $remote_dir/tgt_file
1097 mrename $DIR/$tdir/src_dir $remote_dir/tgt_dir ||
1098 error "rename dir cross MDT failed!"
1100 mrename $DIR/$tdir/src_file $remote_dir/tgt_file ||
1101 error "rename file cross MDT failed!"
1103 touch $DIR/$tdir/ln_file
1104 ln $DIR/$tdir/ln_file $remote_dir/ln_name ||
1105 error "ln file cross MDT failed"
1107 rm -rf $DIR/$tdir || error "Can not delete directories"
1109 run_test 24x "cross MDT rename/link"
1112 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 2 MDTs" && return
1113 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1115 local remote_dir=$DIR/$tdir/remote_dir
1117 test_mkdir -p $DIR/$tdir
1118 $LFS mkdir -i $MDTIDX $remote_dir ||
1119 error "create remote directory failed"
1121 test_mkdir -p $remote_dir/src_dir
1122 touch $remote_dir/src_file
1123 test_mkdir -p $remote_dir/tgt_dir
1124 touch $remote_dir/tgt_file
1126 mrename $remote_dir/src_dir $remote_dir/tgt_dir ||
1127 error "rename subdir in the same remote dir failed!"
1129 mrename $remote_dir/src_file $remote_dir/tgt_file ||
1130 error "rename files in the same remote dir failed!"
1132 ln $remote_dir/tgt_file $remote_dir/tgt_file1 ||
1133 error "link files in the same remote dir failed!"
1135 rm -rf $DIR/$tdir || error "Can not delete directories"
1137 run_test 24y "rename/link on the same dir should succeed"
1139 test_24A() { # LU-3182
1143 test_mkdir -p $DIR/$tdir
1144 createmany -m $DIR/$tdir/$tfile $NFILES
1145 local t=$(ls $DIR/$tdir | wc -l)
1146 local u=$(ls $DIR/$tdir | sort -u | wc -l)
1147 local v=$(ls -ai $DIR/$tdir | sort -u | wc -l)
1148 if [ $t -ne $NFILES -o $u -ne $NFILES -o $v -ne $((NFILES + 2)) ] ; then
1149 error "Expected $NFILES files, got $t ($u unique $v .&..)"
1152 rm -rf $DIR/$tdir || error "Can not delete directories"
1154 run_test 24A "readdir() returns correct number of entries."
1156 test_24B() { # LU-4805
1157 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
1160 test_mkdir $DIR/$tdir
1161 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR/$tdir/striped_dir ||
1162 error "create striped dir failed"
1164 count=$(ls -ai $DIR/$tdir/striped_dir | wc -l)
1165 [ $count -eq 2 ] || error "Expected 2, got $count"
1167 touch $DIR/$tdir/striped_dir/a
1169 count=$(ls -ai $DIR/$tdir/striped_dir | wc -l)
1170 [ $count -eq 3 ] || error "Expected 3, got $count"
1172 touch $DIR/$tdir/striped_dir/.f
1174 count=$(ls -ai $DIR/$tdir/striped_dir | wc -l)
1175 [ $count -eq 4 ] || error "Expected 4, got $count"
1177 rm -rf $DIR/$tdir || error "Can not delete directories"
1179 run_test 24B "readdir for striped dir return correct number of entries"
1182 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
1188 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR/$tdir/d0/striped_dir ||
1189 error "create striped dir failed"
1191 cd $DIR/$tdir/d0/striped_dir
1193 local d0_ino=$(ls -i -l -a $DIR/$tdir | grep "d0" | awk '{print $1}')
1194 local d1_ino=$(ls -i -l -a $DIR/$tdir | grep "d1" | awk '{print $1}')
1195 local parent_ino=$(ls -i -l -a | grep "\.\." | awk '{print $1}')
1197 [ "$d0_ino" = "$parent_ino" ] ||
1198 error ".. wrong, expect $d0_ino, get $parent_ino"
1200 mv $DIR/$tdir/d0/striped_dir $DIR/$tdir/d1/ ||
1201 error "mv striped dir failed"
1203 parent_ino=$(ls -i -l -a | grep "\.\." | awk '{print $1}')
1205 [ "$d1_ino" = "$parent_ino" ] ||
1206 error ".. wrong after mv, expect $d1_ino, get $parent_ino"
1208 run_test 24C "check .. in striped dir"
1210 test_24D() { # LU-6101
1215 createmany -m $DIR/$tdir/$tfile $NFILES
1216 local t=$(ls $DIR/$tdir | wc -l)
1217 local u=$(ls $DIR/$tdir | sort -u | wc -l)
1218 local v=$(ls -ai $DIR/$tdir | sort -u | wc -l)
1219 if [ $t -ne $NFILES -o $u -ne $NFILES -o $v -ne $((NFILES + 2)) ] ; then
1220 error "Expected $NFILES files, got $t ($u unique $v .&..)"
1223 rm -rf $DIR/$tdir || error "Can not delete directories"
1225 run_test 24D "readdir() returns correct number of entries after cursor reload"
1228 [[ $MDSCOUNT -lt 4 ]] && skip "needs >= 4 MDTs" && return
1229 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1232 mkdir $DIR/$tdir/src_dir
1233 $LFS mkdir -i 1 $DIR/$tdir/src_dir/src_child ||
1234 error "create remote source failed"
1236 touch $DIR/$tdir/src_dir/src_child/a
1238 $LFS mkdir -i 2 $DIR/$tdir/tgt_dir ||
1239 error "create remote target dir failed"
1241 $LFS mkdir -i 3 $DIR/$tdir/tgt_dir/tgt_child ||
1242 error "create remote target child failed"
1244 mrename $DIR/$tdir/src_dir/src_child $DIR/$tdir/tgt_dir/tgt_child ||
1245 error "rename dir cross MDT failed!"
1249 $CHECKSTAT -t dir $DIR/$tdir/src_dir/src_child &&
1250 error "src_child still exists after rename"
1252 $CHECKSTAT -t file $DIR/$tdir/tgt_dir/tgt_child/a ||
1253 error "missing file(a) after rename"
1255 rm -rf $DIR/$tdir || error "Can not delete directories"
1257 run_test 24E "cross MDT rename/link"
1260 echo '== symlink sanity ============================================='
1264 touch $DIR/s25/foo || error
1266 run_test 25a "create file in symlinked directory ==============="
1269 [ ! -d $DIR/d25 ] && test_25a
1270 $CHECKSTAT -t file $DIR/s25/foo || error
1272 run_test 25b "lookup file in symlinked directory ==============="
1276 test_mkdir $DIR/d26/d26-2
1277 ln -s d26/d26-2 $DIR/s26
1278 touch $DIR/s26/foo || error
1280 run_test 26a "multiple component symlink ======================="
1283 test_mkdir -p $DIR/d26b/d26-2
1284 ln -s d26b/d26-2/foo $DIR/s26-2
1285 touch $DIR/s26-2 || error
1287 run_test 26b "multiple component symlink at end of lookup ======"
1290 test_mkdir $DIR/d26.2
1291 touch $DIR/d26.2/foo
1292 ln -s d26.2 $DIR/s26.2-1
1293 ln -s s26.2-1 $DIR/s26.2-2
1294 ln -s s26.2-2 $DIR/s26.2-3
1295 chmod 0666 $DIR/s26.2-3/foo
1297 run_test 26c "chain of symlinks ================================"
1299 # recursive symlinks (bug 439)
1301 ln -s d26-3/foo $DIR/d26-3
1303 run_test 26d "create multiple component recursive symlink ======"
1306 [ ! -h $DIR/d26-3 ] && test_26d
1309 run_test 26e "unlink multiple component recursive symlink ======"
1311 # recursive symlinks (bug 7022)
1313 test_mkdir -p $DIR/$tdir
1314 test_mkdir $DIR/$tdir/$tfile || error "mkdir $DIR/$tdir/$tfile failed"
1315 cd $DIR/$tdir/$tfile || error "cd $DIR/$tdir/$tfile failed"
1316 test_mkdir -p lndir/bar1 || error "mkdir lndir/bar1 failed"
1317 test_mkdir $DIR/$tdir/$tfile/$tfile || error "mkdir $tfile failed"
1318 cd $tfile || error "cd $tfile failed"
1319 ln -s .. dotdot || error "ln dotdot failed"
1320 ln -s dotdot/lndir lndir || error "ln lndir failed"
1321 cd $DIR/$tdir || error "cd $DIR/$tdir failed"
1322 output=`ls $tfile/$tfile/lndir/bar1`
1323 [ "$output" = bar1 ] && error "unexpected output"
1324 rm -r $tfile || error "rm $tfile failed"
1325 $CHECKSTAT -a $DIR/$tfile || error "$tfile not gone"
1327 run_test 26f "rm -r of a directory which has recursive symlink ="
1330 echo '== stripe sanity =============================================='
1331 test_mkdir -p $DIR/d27 || error "mkdir failed"
1333 $SETSTRIPE -c 1 $DIR/d27/f0 || error "setstripe failed"
1334 $CHECKSTAT -t file $DIR/d27/f0 || error "checkstat failed"
1335 log "== test_27a: write to one stripe file ========================="
1336 cp /etc/hosts $DIR/d27/f0 || error
1338 run_test 27a "one stripe file =================================="
1341 [[ $OSTCOUNT -lt 2 ]] && skip_env "skipping 2-stripe test" && return
1342 test_mkdir -p $DIR/d27
1343 $SETSTRIPE -c 2 $DIR/d27/f01 || error "setstripe failed"
1344 $GETSTRIPE -c $DIR/d27/f01
1345 [ $($GETSTRIPE -c $DIR/d27/f01) -eq 2 ] ||
1346 error "two-stripe file doesn't have two stripes"
1348 dd if=/dev/zero of=$DIR/d27/f01 bs=4k count=4 || error "dd failed"
1350 run_test 27b "create and write to two stripe file"
1353 test_mkdir -p $DIR/d27
1354 $SETSTRIPE -c 0 -i -1 -S 0 $DIR/d27/fdef || error "setstripe failed"
1355 $CHECKSTAT -t file $DIR/d27/fdef || error "checkstat failed"
1356 dd if=/dev/zero of=$DIR/d27/fdef bs=4k count=4 || error
1358 run_test 27d "create file with default settings ================"
1361 # LU-5839 adds check for existed layout before setting it
1362 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.56) ]] &&
1363 skip "Need MDS version at least 2.7.56" && return
1364 test_mkdir -p $DIR/d27
1365 $SETSTRIPE -c 2 $DIR/d27/f12 || error "setstripe failed"
1366 $SETSTRIPE -c 2 $DIR/d27/f12 && error "setstripe succeeded twice"
1367 $CHECKSTAT -t file $DIR/d27/f12 || error "checkstat failed"
1369 run_test 27e "setstripe existing file (should return error) ======"
1372 test_mkdir $DIR/$tdir
1373 $SETSTRIPE -S 100 -i 0 -c 1 $DIR/$tdir/$tfile &&
1374 error "$SETSTRIPE $DIR/$tdir/$tfile failed"
1375 $CHECKSTAT -t file $DIR/$tdir/$tfile &&
1376 error "$CHECKSTAT -t file $DIR/$tdir/$tfile should fail"
1377 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=4k count=4 || error "dd failed"
1378 $GETSTRIPE $DIR/$tdir/$tfile || error "$GETSTRIPE failed"
1380 run_test 27f "setstripe with bad stripe size (should return error)"
1383 test_mkdir -p $DIR/d27
1384 $MCREATE $DIR/d27/fnone || error "mcreate failed"
1385 $GETSTRIPE $DIR/d27/fnone 2>&1 | grep "no stripe info" ||
1386 error "$DIR/d27/fnone has object"
1388 run_test 27g "$GETSTRIPE with no objects"
1391 test_mkdir $DIR/$tdir
1392 touch $DIR/$tdir/$tfile || error "touch failed"
1393 [[ $($GETSTRIPE -c $DIR/$tdir/$tfile) -gt 0 ]] ||
1394 error "missing objects"
1396 run_test 27i "$GETSTRIPE with some objects"
1399 test_mkdir -p $DIR/d27
1400 $SETSTRIPE -i $OSTCOUNT $DIR/d27/f27j && error "setstripe failed"||true
1402 run_test 27j "setstripe with bad stripe offset (should return error)"
1404 test_27k() { # bug 2844
1405 test_mkdir -p $DIR/d27
1407 LL_MAX_BLKSIZE=$((4 * 1024 * 1024))
1408 [ ! -d $DIR/d27 ] && test_mkdir -p $DIR d27
1409 $SETSTRIPE -S 67108864 $FILE || error "setstripe failed"
1410 BLKSIZE=`stat $FILE | awk '/IO Block:/ { print $7 }'`
1411 [ $BLKSIZE -le $LL_MAX_BLKSIZE ] || error "1:$BLKSIZE > $LL_MAX_BLKSIZE"
1412 dd if=/dev/zero of=$FILE bs=4k count=1
1413 BLKSIZE=`stat $FILE | awk '/IO Block:/ { print $7 }'`
1414 [ $BLKSIZE -le $LL_MAX_BLKSIZE ] || error "2:$BLKSIZE > $LL_MAX_BLKSIZE"
1416 run_test 27k "limit i_blksize for broken user apps ============="
1419 test_mkdir -p $DIR/d27
1420 mcreate $DIR/f27l || error "creating file"
1421 $RUNAS $SETSTRIPE -c 1 $DIR/f27l && \
1422 error "setstripe should have failed" || true
1424 run_test 27l "check setstripe permissions (should return error)"
1427 [[ $OSTCOUNT -lt 2 ]] && skip_env "$OSTCOUNT < 2 OSTs -- skipping" &&
1430 ORIGFREE=$($LCTL get_param -n lov.$FSNAME-clilov-*.kbytesavail |
1432 if [[ $ORIGFREE -gt $MAXFREE ]]; then
1433 skip "$ORIGFREE > $MAXFREE skipping out-of-space test on OST0"
1436 trap simple_cleanup_common EXIT
1437 test_mkdir -p $DIR/$tdir
1438 $SETSTRIPE -i 0 -c 1 $DIR/$tdir/f27m_1
1439 dd if=/dev/zero of=$DIR/$tdir/f27m_1 bs=1024 count=$MAXFREE &&
1440 error "dd should fill OST0"
1442 while $SETSTRIPE -i 0 -c 1 $DIR/$tdir/f27m_$i; do
1444 [ $i -gt 256 ] && break
1447 touch $DIR/$tdir/f27m_$i
1448 [ `$GETSTRIPE $DIR/$tdir/f27m_$i | grep -A 10 obdidx | awk '{print $1}'| grep -w "0"` ] &&
1449 error "OST0 was full but new created file still use it"
1451 touch $DIR/$tdir/f27m_$i
1452 [ `$GETSTRIPE $DIR/$tdir/f27m_$i | grep -A 10 obdidx | awk '{print $1}'| grep -w "0"` ] &&
1453 error "OST0 was full but new created file still use it"
1454 simple_cleanup_common
1456 run_test 27m "create file while OST0 was full =================="
1459 local DELAY=$(do_facet $SINGLEMDS lctl get_param -n lov.*.qos_maxage | head -n 1 | awk '{print $1 * 2}')
1463 # OSCs keep a NOSPC flag that will be reset after ~5s (qos_maxage)
1464 # if the OST isn't full anymore.
1466 local OSTIDX=${1:-""}
1468 local list=$(comma_list $(osts_nodes))
1469 [ "$OSTIDX" ] && list=$(facet_host ost$((OSTIDX + 1)))
1471 do_nodes $list lctl set_param fail_loc=0
1472 sync # initiate all OST_DESTROYs from MDS to OST
1476 exhaust_precreations() {
1479 local FAILIDX=${3:-$OSTIDX}
1480 local ofacet=ost$((OSTIDX + 1))
1482 test_mkdir -p -c1 $DIR/$tdir
1483 local mdtidx=$($LFS getstripe -M $DIR/$tdir)
1484 local mfacet=mds$((mdtidx + 1))
1485 echo OSTIDX=$OSTIDX MDTIDX=$mdtidx
1487 local OST=$(ostname_from_index $OSTIDX)
1490 local mdtosc_proc1=$(get_mdtosc_proc_path $mfacet $OST)
1491 local last_id=$(do_facet $mfacet lctl get_param -n \
1492 osc.$mdtosc_proc1.prealloc_last_id)
1493 local next_id=$(do_facet $mfacet lctl get_param -n \
1494 osc.$mdtosc_proc1.prealloc_next_id)
1496 local mdtosc_proc2=$(get_mdtosc_proc_path $mfacet)
1497 do_facet $mfacet lctl get_param osc.$mdtosc_proc2.prealloc*
1499 test_mkdir -p $DIR/$tdir/${OST}
1500 $SETSTRIPE -i $OSTIDX -c 1 $DIR/$tdir/${OST}
1501 #define OBD_FAIL_OST_ENOSPC 0x215
1502 do_facet $ofacet lctl set_param fail_val=$FAILIDX fail_loc=0x215
1503 echo "Creating to objid $last_id on ost $OST..."
1504 createmany -o $DIR/$tdir/${OST}/f $next_id $((last_id - next_id + 2))
1505 do_facet $mfacet lctl get_param osc.$mdtosc_proc2.prealloc*
1506 do_facet $ofacet lctl set_param fail_loc=$FAILLOC
1510 exhaust_all_precreations() {
1512 for (( i=0; i < OSTCOUNT; i++ )) ; do
1513 exhaust_precreations $i $1 -1
1518 [[ $OSTCOUNT -lt 2 ]] && skip_env "too few OSTs" && return
1519 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1520 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1521 remote_ost_nodsh && skip "remote OST with nodsh" && return
1524 rm -f $DIR/$tdir/$tfile
1525 exhaust_precreations 0 0x80000215
1526 $SETSTRIPE -c -1 $DIR/$tdir
1527 touch $DIR/$tdir/$tfile || error
1528 $GETSTRIPE $DIR/$tdir/$tfile
1531 run_test 27n "create file with some full OSTs =================="
1534 [[ $OSTCOUNT -lt 2 ]] && skip_env "too few OSTs" && return
1535 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1536 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1537 remote_ost_nodsh && skip "remote OST with nodsh" && return
1540 rm -f $DIR/$tdir/$tfile
1541 exhaust_all_precreations 0x215
1543 touch $DIR/$tdir/$tfile && error "able to create $DIR/$tdir/$tfile"
1548 run_test 27o "create file with all full OSTs (should error) ===="
1551 [[ $OSTCOUNT -lt 2 ]] && skip_env "too few OSTs" && return
1552 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1553 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1554 remote_ost_nodsh && skip "remote OST with nodsh" && return
1557 rm -f $DIR/$tdir/$tfile
1558 test_mkdir -p $DIR/$tdir
1560 $MCREATE $DIR/$tdir/$tfile || error "mcreate failed"
1561 $TRUNCATE $DIR/$tdir/$tfile 80000000 || error "truncate failed"
1562 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat failed"
1564 exhaust_precreations 0 0x80000215
1565 echo foo >> $DIR/$tdir/$tfile || error "append failed"
1566 $CHECKSTAT -s 80000004 $DIR/$tdir/$tfile || error "checkstat failed"
1567 $GETSTRIPE $DIR/$tdir/$tfile
1571 run_test 27p "append to a truncated file with some full OSTs ==="
1574 [[ $OSTCOUNT -lt 2 ]] && skip_env "too few OSTs" && return
1575 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1576 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1577 remote_ost_nodsh && skip "remote OST with nodsh" && return
1580 rm -f $DIR/$tdir/$tfile
1582 test_mkdir -p $DIR/$tdir
1583 $MCREATE $DIR/$tdir/$tfile || error "mcreate $DIR/$tdir/$tfile failed"
1584 $TRUNCATE $DIR/$tdir/$tfile 80000000 ||error "truncate $DIR/$tdir/$tfile failed"
1585 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat failed"
1587 exhaust_all_precreations 0x215
1589 echo foo >> $DIR/$tdir/$tfile && error "append succeeded"
1590 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat 2 failed"
1594 run_test 27q "append to truncated file with all OSTs full (should error) ==="
1597 [[ $OSTCOUNT -lt 2 ]] && skip_env "too few OSTs" && return
1598 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1599 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1600 remote_ost_nodsh && skip "remote OST with nodsh" && return
1603 rm -f $DIR/$tdir/$tfile
1604 exhaust_precreations 0 0x80000215
1606 $SETSTRIPE -i 0 -c 2 $DIR/$tdir/$tfile # && error
1610 run_test 27r "stripe file with some full OSTs (shouldn't LBUG) ="
1612 test_27s() { # bug 10725
1613 test_mkdir -p $DIR/$tdir
1614 local stripe_size=$((4096 * 1024 * 1024)) # 2^32
1615 local stripe_count=0
1616 [ $OSTCOUNT -eq 1 ] || stripe_count=2
1617 $SETSTRIPE -S $stripe_size -c $stripe_count $DIR/$tdir &&
1618 error "stripe width >= 2^32 succeeded" || true
1621 run_test 27s "lsm_xfersize overflow (should error) (bug 10725)"
1623 test_27t() { # bug 10864
1628 $WLFS getstripe $tfile
1631 run_test 27t "check that utils parse path correctly"
1633 test_27u() { # bug 4900
1634 [[ $OSTCOUNT -lt 2 ]] && skip_env "too few OSTs" && return
1635 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1637 local list=$(comma_list $(mdts_nodes))
1639 #define OBD_FAIL_MDS_OSC_PRECREATE 0x139
1640 do_nodes $list $LCTL set_param fail_loc=0x139
1641 test_mkdir -p $DIR/$tdir
1643 createmany -o $DIR/$tdir/t- 1000
1644 do_nodes $list $LCTL set_param fail_loc=0
1646 TLOG=$DIR/$tfile.getstripe
1647 $GETSTRIPE $DIR/$tdir > $TLOG
1648 OBJS=$(awk -vobj=0 '($1 == 0) { obj += 1 } END { print obj; }' $TLOG)
1649 unlinkmany $DIR/$tdir/t- 1000
1650 [[ $OBJS -gt 0 ]] &&
1651 error "$OBJS objects created on OST-0. See $TLOG" || pass
1653 run_test 27u "skip object creation on OSC w/o objects =========="
1655 test_27v() { # bug 4900
1656 [[ $OSTCOUNT -lt 2 ]] && skip_env "too few OSTs" && return
1657 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1658 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1659 remote_ost_nodsh && skip "remote OST with nodsh" && return
1661 exhaust_all_precreations 0x215
1664 test_mkdir -p $DIR/$tdir
1665 $SETSTRIPE -c 1 $DIR/$tdir # 1 stripe / file
1667 touch $DIR/$tdir/$tfile
1668 #define OBD_FAIL_TGT_DELAY_PRECREATE 0x705
1670 for (( i=1; i < OSTCOUNT; i++ )); do
1671 do_facet ost$i lctl set_param fail_loc=0x705
1673 local START=`date +%s`
1674 createmany -o $DIR/$tdir/$tfile 32
1676 local FINISH=`date +%s`
1677 local TIMEOUT=`lctl get_param -n timeout`
1678 local PROCESS=$((FINISH - START))
1679 [ $PROCESS -ge $((TIMEOUT / 2)) ] && \
1680 error "$FINISH - $START >= $TIMEOUT / 2"
1681 sleep $((TIMEOUT / 2 - PROCESS))
1684 run_test 27v "skip object creation on slow OST ================="
1686 test_27w() { # bug 10997
1687 test_mkdir -p $DIR/$tdir || error "mkdir failed"
1688 $SETSTRIPE -S 65536 $DIR/$tdir/f0 || error "setstripe failed"
1689 [ $($GETSTRIPE -S $DIR/$tdir/f0) -ne 65536 ] &&
1690 error "stripe size $size != 65536" || true
1691 [ $($GETSTRIPE -d $DIR/$tdir | grep -c "stripe_count") -ne 1 ] &&
1692 error "$GETSTRIPE -d $DIR/$tdir failed" || true
1694 run_test 27w "check $SETSTRIPE -S option"
1697 [[ $OSTCOUNT -lt 2 ]] &&
1698 skip_env "skipping multiple stripe count/offset test" && return
1700 test_mkdir -p $DIR/$tdir || error "mkdir failed"
1701 for i in $(seq 1 $OSTCOUNT); do
1703 $SETSTRIPE -c $i -i $offset $DIR/$tdir/f$i ||
1704 error "setstripe -c $i -i $offset failed"
1705 count=$($GETSTRIPE -c $DIR/$tdir/f$i)
1706 index=$($GETSTRIPE -i $DIR/$tdir/f$i)
1707 [ $count -ne $i ] && error "stripe count $count != $i" || true
1708 [ $index -ne $offset ] &&
1709 error "stripe offset $index != $offset" || true
1712 run_test 27wa "check $SETSTRIPE -c -i options"
1715 remote_ost_nodsh && skip "remote OST with nodsh" && return
1716 [[ $OSTCOUNT -lt 2 ]] && skip_env "$OSTCOUNT < 2 OSTs" && return
1717 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1718 OFFSET=$(($OSTCOUNT - 1))
1720 local OST=$(ostname_from_index $OSTIDX)
1722 test_mkdir -p $DIR/$tdir
1723 $SETSTRIPE -c 1 $DIR/$tdir # 1 stripe per file
1724 do_facet ost$((OSTIDX + 1)) lctl set_param -n obdfilter.$OST.degraded 1
1726 createmany -o $DIR/$tdir/$tfile $OSTCOUNT
1727 for i in `seq 0 $OFFSET`; do
1728 [ `$GETSTRIPE $DIR/$tdir/$tfile$i | grep -A 10 obdidx | awk '{print $1}' | grep -w "$OSTIDX"` ] &&
1729 error "OST0 was degraded but new created file still use it"
1731 do_facet ost$((OSTIDX + 1)) lctl set_param -n obdfilter.$OST.degraded 0
1733 run_test 27x "create files while OST0 is degraded"
1736 [[ $OSTCOUNT -lt 2 ]] &&
1737 skip_env "$OSTCOUNT < 2 OSTs -- skipping" && return
1738 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1739 remote_ost_nodsh && skip "remote OST with nodsh" && return
1740 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1742 local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS $FSNAME-OST0000)
1743 local last_id=$(do_facet $SINGLEMDS lctl get_param -n \
1744 osc.$mdtosc.prealloc_last_id)
1745 local next_id=$(do_facet $SINGLEMDS lctl get_param -n \
1746 osc.$mdtosc.prealloc_next_id)
1747 local fcount=$((last_id - next_id))
1748 [[ $fcount -eq 0 ]] && skip "not enough space on OST0" && return
1749 [[ $fcount -gt $OSTCOUNT ]] && fcount=$OSTCOUNT
1751 local MDS_OSCS=$(do_facet $SINGLEMDS lctl dl |
1752 awk '/[oO][sS][cC].*md[ts]/ { print $4 }')
1753 local OST_DEACTIVE_IDX=-1
1758 for OSC in $MDS_OSCS; do
1759 OST=$(osc_to_ost $OSC)
1760 OSTIDX=$(index_from_ostuuid $OST)
1761 if [ $OST_DEACTIVE_IDX == -1 ]; then
1762 OST_DEACTIVE_IDX=$OSTIDX
1764 if [ $OSTIDX != $OST_DEACTIVE_IDX ]; then
1765 echo $OSC "is Deactivated:"
1766 do_facet $SINGLEMDS lctl --device %$OSC deactivate
1770 OSTIDX=$(index_from_ostuuid $OST)
1771 test_mkdir -p $DIR/$tdir
1772 $SETSTRIPE -c 1 $DIR/$tdir # 1 stripe / file
1774 for OSC in $MDS_OSCS; do
1775 OST=$(osc_to_ost $OSC)
1776 OSTIDX=$(index_from_ostuuid $OST)
1777 if [ $OSTIDX == $OST_DEACTIVE_IDX ]; then
1778 echo $OST "is degraded:"
1779 do_facet ost$((OSTIDX+1)) lctl set_param -n \
1780 obdfilter.$OST.degraded=1
1785 createmany -o $DIR/$tdir/$tfile $fcount
1787 for OSC in $MDS_OSCS; do
1788 OST=$(osc_to_ost $OSC)
1789 OSTIDX=$(index_from_ostuuid $OST)
1790 if [ $OSTIDX == $OST_DEACTIVE_IDX ]; then
1791 echo $OST "is recovered from degraded:"
1792 do_facet ost$((OSTIDX+1)) lctl set_param -n \
1793 obdfilter.$OST.degraded=0
1795 do_facet $SINGLEMDS lctl --device %$OSC activate
1799 # all osp devices get activated, hence -1 stripe count restored
1802 # sleep 2*lod_qos_maxage seconds waiting for lod qos to notice osp
1803 # devices get activated.
1805 $SETSTRIPE -c -1 $DIR/$tfile
1806 stripecnt=$($GETSTRIPE -c $DIR/$tfile)
1808 [ $stripecnt -ne $OSTCOUNT ] &&
1809 error "Of $OSTCOUNT OSTs, only $stripecnt is available"
1812 run_test 27y "create files while OST0 is degraded and the rest inactive"
1818 lmm_count=$($GETSTRIPE -c $1)
1819 lmm_seq=$($GETSTRIPE -v $1 | awk '/lmm_seq/ { print $2 }')
1820 lmm_oid=$($GETSTRIPE -v $1 | awk '/lmm_object_id/ { print $2 }')
1822 local old_ifs="$IFS"
1824 fid=($($LFS path2fid $1))
1827 log "FID seq ${fid[1]}, oid ${fid[2]} ver ${fid[3]}"
1828 log "LOV seq $lmm_seq, oid $lmm_oid, count: $lmm_count"
1830 # compare lmm_seq and lu_fid->f_seq
1831 [ $lmm_seq = ${fid[1]} ] || { error "SEQ mismatch"; return 1; }
1832 # compare lmm_object_id and lu_fid->oid
1833 [ $lmm_oid = ${fid[2]} ] || { error "OID mismatch"; return 2; }
1835 # check the trusted.fid attribute of the OST objects of the file
1836 local have_obdidx=false
1838 $GETSTRIPE $1 | while read obdidx oid hex seq; do
1839 # skip lines up to and including "obdidx"
1840 [ -z "$obdidx" ] && break
1841 [ "$obdidx" = "obdidx" ] && have_obdidx=true && continue
1842 $have_obdidx || continue
1844 local ost=$((obdidx + 1))
1845 local dev=$(ostdevname $ost)
1848 log "want: stripe:$stripe_nr ost:$obdidx oid:$oid/$hex seq:$seq"
1850 seq=$(echo $seq | sed -e "s/^0x//g")
1851 if [ $seq == 0 ] || [ $(facet_fstype ost$ost) == zfs ]; then
1852 oid_hex=$(echo $oid)
1854 oid_hex=$(echo $hex | sed -e "s/^0x//g")
1856 local obj_file="O/$seq/d$((oid %32))/$oid_hex"
1860 # Don't unmount/remount the OSTs if we don't need to do that.
1861 # LU-2577 changes filter_fid to be smaller, so debugfs needs
1862 # update too, until that use mount/ll_decode_filter_fid/mount.
1863 # Re-enable when debugfs will understand new filter_fid.
1865 if false && [ $(facet_fstype ost$ost) == ldiskfs ]; then
1866 ff=$(do_facet ost$ost "$DEBUGFS -c -R 'stat $obj_file' \
1867 $dev 2>/dev/null" | grep "parent=")
1870 mount_fstype ost$ost
1871 ff=$(do_facet ost$ost $LL_DECODE_FILTER_FID \
1872 $(facet_mntpt ost$ost)/$obj_file)
1873 unmount_fstype ost$ost
1874 start ost$ost $dev $OST_MOUNT_OPTS
1878 [ -z "$ff" ] && error "$obj_file: no filter_fid info"
1880 echo "$ff" | sed -e 's#.*objid=#got: objid=#'
1882 # /mnt/O/0/d23/23: objid=23 seq=0 parent=[0x200000400:0x1e:0x1]
1883 # fid: objid=23 seq=0 parent=[0x200000400:0x1e:0x0] stripe=1
1884 local ff_parent=$(echo $ff|sed -e 's/.*parent=.//')
1885 local ff_pseq=$(echo $ff_parent | cut -d: -f1)
1886 local ff_poid=$(echo $ff_parent | cut -d: -f2)
1888 if echo $ff_parent | grep -q 'stripe='; then
1889 ff_pstripe=$(echo $ff_parent | sed -e 's/.*stripe=//')
1892 # $LL_DECODE_FILTER_FID does not print "stripe="; look
1893 # into f_ver in this case. See the comment on
1896 ff_pstripe=$(echo $ff_parent | cut -d: -f3 |
1900 # compare lmm_seq and filter_fid->ff_parent.f_seq
1901 [ $ff_pseq = $lmm_seq ] ||
1902 error "FF parent SEQ $ff_pseq != $lmm_seq"
1903 # compare lmm_object_id and filter_fid->ff_parent.f_oid
1904 [ $ff_poid = $lmm_oid ] ||
1905 error "FF parent OID $ff_poid != $lmm_oid"
1906 (($ff_pstripe == $stripe_nr)) ||
1907 error "FF stripe $ff_pstripe != $stripe_nr"
1909 stripe_nr=$((stripe_nr + 1))
1914 remote_ost_nodsh && skip "remote OST with nodsh" && return
1915 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1916 test_mkdir -p $DIR/$tdir
1918 $SETSTRIPE -c 1 -i 0 -S 64k $DIR/$tdir/$tfile-1 ||
1919 { error "setstripe -c -1 failed"; return 1; }
1920 # We need to send a write to every object to get parent FID info set.
1921 # This _should_ also work for setattr, but does not currently.
1922 # touch $DIR/$tdir/$tfile-1 ||
1923 dd if=/dev/zero of=$DIR/$tdir/$tfile-1 bs=1M count=1 ||
1924 { error "dd $tfile-1 failed"; return 2; }
1925 $SETSTRIPE -c -1 -i $((OSTCOUNT - 1)) -S 1M $DIR/$tdir/$tfile-2 ||
1926 { error "setstripe -c -1 failed"; return 3; }
1927 dd if=/dev/zero of=$DIR/$tdir/$tfile-2 bs=1M count=$OSTCOUNT ||
1928 { error "dd $tfile-2 failed"; return 4; }
1930 # make sure write RPCs have been sent to OSTs
1933 check_seq_oid $DIR/$tdir/$tfile-1 || return 5
1934 check_seq_oid $DIR/$tdir/$tfile-2 || return 6
1936 run_test 27z "check SEQ/OID on the MDT and OST filesystems"
1938 test_27A() { # b=19102
1939 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1940 local restore_size=$($GETSTRIPE -S $MOUNT)
1941 local restore_count=$($GETSTRIPE -c $MOUNT)
1942 local restore_offset=$($GETSTRIPE -i $MOUNT)
1943 $SETSTRIPE -c 0 -i -1 -S 0 $MOUNT
1944 wait_update $HOSTNAME "$GETSTRIPE -c $MOUNT | sed 's/ *//g'" "1" 20 ||
1945 error "stripe count $($GETSTRIPE -c $MOUNT) != 1"
1946 local default_size=$($GETSTRIPE -S $MOUNT)
1947 local default_offset=$($GETSTRIPE -i $MOUNT)
1948 local dsize=$((1024 * 1024))
1949 [ $default_size -eq $dsize ] ||
1950 error "stripe size $default_size != $dsize"
1951 [ $default_offset -eq -1 ] ||error "stripe offset $default_offset != -1"
1952 $SETSTRIPE -c $restore_count -i $restore_offset -S $restore_size $MOUNT
1954 run_test 27A "check filesystem-wide default LOV EA values"
1956 test_27B() { # LU-2523
1957 test_mkdir -p $DIR/$tdir
1958 rm -f $DIR/$tdir/f0 $DIR/$tdir/f1
1960 # open f1 with O_LOV_DELAY_CREATE
1962 # call setstripe ioctl on open file descriptor for f1
1964 multiop $DIR/$tdir/f1 oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:nB1c \
1968 # open f1 with O_LOV_DELAY_CREATE
1970 # call setstripe ioctl on open file descriptor for f1
1972 multiop $DIR/$tdir/f1 oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:uB1c
1974 # Allow multiop to fail in imitation of NFS's busted semantics.
1977 run_test 27B "call setstripe on open unlinked file/rename victim"
1979 test_27C() { #LU-2871
1980 [[ $OSTCOUNT -lt 2 ]] && skip "needs >= 2 OSTs" && return
1988 test_mkdir -p $DIR/$tdir
1990 for i in $(seq 0 $((OSTCOUNT - 1))); do
1991 # set stripe across all OSTs starting from OST$i
1992 $SETSTRIPE -i $i -c -1 $tfile$i
1993 # get striping information
1994 ost_idx=($($GETSTRIPE $tfile$i |
1995 tail -n $((OSTCOUNT + 1)) | awk '{print $1}'))
1999 [ ${#ost_idx[@]} -eq $OSTCOUNT ] ||
2000 error "${#ost_idx[@]} != $OSTCOUNT"
2002 for index in $(seq 0 $((OSTCOUNT - 1))); do
2004 for j in $(echo ${ost_idx[@]}); do
2005 if [ $index -eq $j ]; then
2011 error "Can not find $index in ${ost_idx[@]}"
2015 run_test 27C "check full striping across all OSTs"
2018 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs" && return
2019 local POOL=${POOL:-testpool}
2021 local last_ost=$(($OSTCOUNT - 1))
2023 local ost_list=$(seq $first_ost $ost_step $last_ost)
2024 local ost_range="$first_ost $last_ost $ost_step"
2026 test_mkdir -p $DIR/$tdir
2027 pool_add $POOL || error "pool_add failed"
2028 pool_add_targets $POOL $ost_range || error "pool_add_targets failed"
2029 llapi_layout_test -d$DIR/$tdir -p$POOL -o$OSTCOUNT ||
2030 error "llapi_layout_test failed"
2031 cleanup_pools || error "cleanup_pools failed"
2033 run_test 27D "validate llapi_layout API"
2035 # Verify that default_easize is increased from its initial value after
2036 # accessing a widely striped file.
2038 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs" && return
2040 # 72 bytes is the minimum space required to store striping
2041 # information for a file striped across one OST:
2042 # (sizeof(struct lov_user_md_v3) +
2043 # sizeof(struct lov_user_ost_data_v1))
2045 $LCTL set_param -n llite.*.default_easize $min_easize ||
2046 error "lctl set_param failed"
2047 local easize=$($LCTL get_param -n llite.*.default_easize)
2049 [ $easize -eq $min_easize ] ||
2050 error "failed to set default_easize"
2052 $LFS setstripe -c $OSTCOUNT $DIR/$tfile ||
2053 error "setstripe failed"
2057 easize=$($LCTL get_param -n llite.*.default_easize)
2059 [ $easize -gt $min_easize ] ||
2060 error "default_easize not updated"
2062 run_test 27E "check that default extended attribute size properly increases"
2064 # createtest also checks that device nodes are created and
2065 # then visible correctly (#2091)
2066 test_28() { # bug 2091
2068 $CREATETEST $DIR/d28/ct || error
2070 run_test 28 "create/mknod/mkdir with bad file types ============"
2073 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2074 cancel_lru_locks mdc
2080 declare -i LOCKCOUNTORIG=0
2081 for lock_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_count); do
2082 let LOCKCOUNTORIG=$LOCKCOUNTORIG+$lock_count
2084 [ $LOCKCOUNTORIG -eq 0 ] && echo "No mdc lock count" && return 1
2086 declare -i LOCKUNUSEDCOUNTORIG=0
2087 for unused_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_unused_count); do
2088 let LOCKUNUSEDCOUNTORIG=$LOCKUNUSEDCOUNTORIG+$unused_count
2095 declare -i LOCKCOUNTCURRENT=0
2096 for lock_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_count); do
2097 let LOCKCOUNTCURRENT=$LOCKCOUNTCURRENT+$lock_count
2100 declare -i LOCKUNUSEDCOUNTCURRENT=0
2101 for unused_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_unused_count); do
2102 let LOCKUNUSEDCOUNTCURRENT=$LOCKUNUSEDCOUNTCURRENT+$unused_count
2105 if [[ $LOCKCOUNTCURRENT -gt $LOCKCOUNTORIG ]]; then
2106 $LCTL set_param -n ldlm.dump_namespaces ""
2107 error "CURRENT: $LOCKCOUNTCURRENT > $LOCKCOUNTORIG"
2108 $LCTL dk | sort -k4 -t: > $TMP/test_29.dk
2109 log "dumped log to $TMP/test_29.dk (bug 5793)"
2112 if [[ $LOCKUNUSEDCOUNTCURRENT -gt $LOCKUNUSEDCOUNTORIG ]]; then
2113 error "UNUSED: $LOCKUNUSEDCOUNTCURRENT > $LOCKUNUSEDCOUNTORIG"
2114 $LCTL dk | sort -k4 -t: > $TMP/test_29.dk
2115 log "dumped log to $TMP/test_29.dk (bug 5793)"
2119 run_test 29 "IT_GETATTR regression ============================"
2121 test_30a() { # was test_30
2122 cp $(which ls) $DIR || cp /bin/ls $DIR
2126 run_test 30a "execute binary from Lustre (execve) =============="
2129 cp `which ls` $DIR || cp /bin/ls $DIR
2131 $RUNAS $DIR/ls / || error
2134 run_test 30b "execute binary from Lustre as non-root ==========="
2136 test_30c() { # b=22376
2137 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2138 cp `which ls` $DIR || cp /bin/ls $DIR
2140 cancel_lru_locks mdc
2141 cancel_lru_locks osc
2142 $RUNAS $DIR/ls / || error
2145 run_test 30c "execute binary from Lustre without read perms ===="
2148 $OPENUNLINK $DIR/f31 $DIR/f31 || error
2149 $CHECKSTAT -a $DIR/f31 || error
2151 run_test 31a "open-unlink file =================================="
2154 touch $DIR/f31 || error
2155 ln $DIR/f31 $DIR/f31b || error
2156 $MULTIOP $DIR/f31b Ouc || error
2157 $CHECKSTAT -t file $DIR/f31 || error
2159 run_test 31b "unlink file with multiple links while open ======="
2162 touch $DIR/f31 || error
2163 ln $DIR/f31 $DIR/f31c || error
2164 multiop_bg_pause $DIR/f31 O_uc || return 1
2166 $MULTIOP $DIR/f31c Ouc
2167 kill -USR1 $MULTIPID
2170 run_test 31c "open-unlink file with multiple links ============="
2173 opendirunlink $DIR/d31d $DIR/d31d || error
2174 $CHECKSTAT -a $DIR/d31d || error
2176 run_test 31d "remove of open directory ========================="
2178 test_31e() { # bug 2904
2179 openfilleddirunlink $DIR/d31e || error
2181 run_test 31e "remove of open non-empty directory ==============="
2183 test_31f() { # bug 4554
2184 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2186 test_mkdir $DIR/d31f
2187 $SETSTRIPE -S 1048576 -c 1 $DIR/d31f
2188 cp /etc/hosts $DIR/d31f
2190 $GETSTRIPE $DIR/d31f/hosts
2191 multiop_bg_pause $DIR/d31f D_c || return 1
2194 rm -rv $DIR/d31f || error "first of $DIR/d31f"
2195 test_mkdir $DIR/d31f
2196 $SETSTRIPE -S 1048576 -c 1 $DIR/d31f
2197 cp /etc/hosts $DIR/d31f
2199 $GETSTRIPE $DIR/d31f/hosts
2200 multiop_bg_pause $DIR/d31f D_c || return 1
2203 kill -USR1 $MULTIPID || error "first opendir $MULTIPID not running"
2204 wait $MULTIPID || error "first opendir $MULTIPID failed"
2208 kill -USR1 $MULTIPID2 || error "second opendir $MULTIPID not running"
2209 wait $MULTIPID2 || error "second opendir $MULTIPID2 failed"
2212 run_test 31f "remove of open directory with open-unlink file ==="
2215 echo "-- cross directory link --"
2216 test_mkdir -c1 $DIR/${tdir}ga
2217 test_mkdir -c1 $DIR/${tdir}gb
2218 touch $DIR/${tdir}ga/f
2219 ln $DIR/${tdir}ga/f $DIR/${tdir}gb/g
2220 $CHECKSTAT -t file $DIR/${tdir}ga/f || error "source"
2221 [ `stat -c%h $DIR/${tdir}ga/f` == '2' ] || error "source nlink"
2222 $CHECKSTAT -t file $DIR/${tdir}gb/g || error "target"
2223 [ `stat -c%h $DIR/${tdir}gb/g` == '2' ] || error "target nlink"
2225 run_test 31g "cross directory link==============="
2228 echo "-- cross directory link --"
2229 test_mkdir -c1 $DIR/${tdir}
2230 test_mkdir -c1 $DIR/${tdir}/dir
2231 touch $DIR/${tdir}/f
2232 ln $DIR/${tdir}/f $DIR/${tdir}/dir/g
2233 $CHECKSTAT -t file $DIR/${tdir}/f || error "source"
2234 [ `stat -c%h $DIR/${tdir}/f` == '2' ] || error "source nlink"
2235 $CHECKSTAT -t file $DIR/${tdir}/dir/g || error "target"
2236 [ `stat -c%h $DIR/${tdir}/dir/g` == '2' ] || error "target nlink"
2238 run_test 31h "cross directory link under child==============="
2241 echo "-- cross directory link --"
2242 test_mkdir -c1 $DIR/$tdir
2243 test_mkdir -c1 $DIR/$tdir/dir
2244 touch $DIR/$tdir/dir/f
2245 ln $DIR/$tdir/dir/f $DIR/$tdir/g
2246 $CHECKSTAT -t file $DIR/$tdir/dir/f || error "source"
2247 [ `stat -c%h $DIR/$tdir/dir/f` == '2' ] || error "source nlink"
2248 $CHECKSTAT -t file $DIR/$tdir/g || error "target"
2249 [ `stat -c%h $DIR/$tdir/g` == '2' ] || error "target nlink"
2251 run_test 31i "cross directory link under parent==============="
2254 test_mkdir -c1 -p $DIR/$tdir
2255 test_mkdir -c1 -p $DIR/$tdir/dir1
2256 ln $DIR/$tdir/dir1 $DIR/$tdir/dir2 && error "ln for dir"
2257 link $DIR/$tdir/dir1 $DIR/$tdir/dir3 && error "link for dir"
2258 mlink $DIR/$tdir/dir1 $DIR/$tdir/dir4 && error "mlink for dir"
2259 mlink $DIR/$tdir/dir1 $DIR/$tdir/dir1 && error "mlink to the same dir"
2262 run_test 31j "link for directory==============="
2265 test_mkdir -c1 -p $DIR/$tdir
2267 touch $DIR/$tdir/exist
2268 mlink $DIR/$tdir/s $DIR/$tdir/t || error "mlink"
2269 mlink $DIR/$tdir/s $DIR/$tdir/exist && error "mlink to exist file"
2270 mlink $DIR/$tdir/s $DIR/$tdir/s && error "mlink to the same file"
2271 mlink $DIR/$tdir/s $DIR/$tdir && error "mlink to parent dir"
2272 mlink $DIR/$tdir $DIR/$tdir/s && error "mlink parent dir to target"
2273 mlink $DIR/$tdir/not-exist $DIR/$tdir/foo && error "mlink non-existing to new"
2274 mlink $DIR/$tdir/not-exist $DIR/$tdir/s && error "mlink non-existing to exist"
2277 run_test 31k "link to file: the same, non-existing, dir==============="
2283 touch $DIR/d31m2/exist
2284 mlink $DIR/d31m/s $DIR/d31m2/t || error "mlink"
2285 mlink $DIR/d31m/s $DIR/d31m2/exist && error "mlink to exist file"
2286 mlink $DIR/d31m/s $DIR/d31m2 && error "mlink to parent dir"
2287 mlink $DIR/d31m2 $DIR/d31m/s && error "mlink parent dir to target"
2288 mlink $DIR/d31m/not-exist $DIR/d31m2/foo && error "mlink non-existing to new"
2289 mlink $DIR/d31m/not-exist $DIR/d31m2/s && error "mlink non-existing to exist"
2292 run_test 31m "link to file: the same, non-existing, dir==============="
2295 touch $DIR/$tfile || error "cannot create '$DIR/$tfile'"
2296 nlink=$(stat --format=%h $DIR/$tfile)
2297 [ ${nlink:--1} -eq 1 ] || error "nlink is $nlink, expected 1"
2299 local cmd="exec $fd<$DIR/$tfile"
2302 trap "eval $cmd" EXIT
2303 nlink=$(stat --dereference --format=%h /proc/self/fd/$fd)
2304 [ ${nlink:--1} -eq 1 ] || error "nlink is $nlink, expected 1"
2305 rm $DIR/$tfile || error "cannot remove '$DIR/$tfile'"
2306 nlink=$(stat --dereference --format=%h /proc/self/fd/$fd)
2307 [ ${nlink:--1} -eq 0 ] || error "nlink is $nlink, expected 0"
2310 run_test 31n "check link count of unlinked file"
2313 local TEMPNAME=$(mktemp $1_XXXXXX)
2314 mlink $TEMPNAME $1 2> /dev/null &&
2315 echo "$BASHPID: link $TEMPNAME to $1 succeeded"
2319 test_31o() { # LU-2901
2320 test_mkdir -p $DIR/$tdir
2321 for LOOP in $(seq 100); do
2322 rm -f $DIR/$tdir/$tfile*
2323 for THREAD in $(seq 8); do
2324 link_one $DIR/$tdir/$tfile.$LOOP &
2327 local LINKS=$(ls -1 $DIR/$tdir | grep -c $tfile.$LOOP)
2328 [[ $LINKS -gt 1 ]] && ls $DIR/$tdir &&
2329 error "$LINKS duplicate links to $tfile.$LOOP" &&
2333 run_test 31o "duplicate hard links with same filename"
2336 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2338 test_mkdir $DIR/$tdir
2339 $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
2340 $LFS setdirstripe -D -c2 -t all_char $DIR/$tdir/striped_dir
2342 opendirunlink $DIR/$tdir/striped_dir/test1 ||
2343 error "open unlink test1 failed"
2344 opendirunlink $DIR/$tdir/striped_dir/test2 ||
2345 error "open unlink test2 failed"
2347 $CHECKSTAT -a $DIR/$tdir/striped_dir/test1 ||
2348 error "test1 still exists"
2349 $CHECKSTAT -a $DIR/$tdir/striped_dir/test2 ||
2350 error "test2 still exists"
2352 run_test 31p "remove of open striped directory"
2354 cleanup_test32_mount() {
2356 $UMOUNT $DIR/$tdir/ext2-mountpoint
2360 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2361 echo "== more mountpoints and symlinks ================="
2362 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2363 trap cleanup_test32_mount EXIT
2364 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2365 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2366 $CHECKSTAT -t dir $DIR/$tdir/ext2-mountpoint/.. || error
2367 cleanup_test32_mount
2369 run_test 32a "stat d32a/ext2-mountpoint/.. ====================="
2372 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2373 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2374 trap cleanup_test32_mount EXIT
2375 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2376 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2377 ls -al $DIR/$tdir/ext2-mountpoint/.. || error
2378 cleanup_test32_mount
2380 run_test 32b "open d32b/ext2-mountpoint/.. ====================="
2383 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2384 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2385 trap cleanup_test32_mount EXIT
2386 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2387 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2388 test_mkdir -p $DIR/$tdir/d2/test_dir
2389 $CHECKSTAT -t dir $DIR/$tdir/ext2-mountpoint/../d2/test_dir || error
2390 cleanup_test32_mount
2392 run_test 32c "stat d32c/ext2-mountpoint/../d2/test_dir ========="
2395 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2396 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2397 trap cleanup_test32_mount EXIT
2398 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2399 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2400 test_mkdir -p $DIR/$tdir/d2/test_dir
2401 ls -al $DIR/$tdir/ext2-mountpoint/../d2/test_dir || error
2402 cleanup_test32_mount
2404 run_test 32d "open d32d/ext2-mountpoint/../d2/test_dir ========="
2407 [ -e $DIR/d32e ] && rm -fr $DIR/d32e
2408 test_mkdir -p $DIR/d32e/tmp
2409 TMP_DIR=$DIR/d32e/tmp
2410 ln -s $DIR/d32e $TMP_DIR/symlink11
2411 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
2412 $CHECKSTAT -t link $DIR/d32e/tmp/symlink11 || error
2413 $CHECKSTAT -t link $DIR/d32e/symlink01 || error
2415 run_test 32e "stat d32e/symlink->tmp/symlink->lustre-subdir ===="
2418 [ -e $DIR/d32f ] && rm -fr $DIR/d32f
2419 test_mkdir -p $DIR/d32f/tmp
2420 TMP_DIR=$DIR/d32f/tmp
2421 ln -s $DIR/d32f $TMP_DIR/symlink11
2422 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
2423 ls $DIR/d32f/tmp/symlink11 || error
2424 ls $DIR/d32f/symlink01 || error
2426 run_test 32f "open d32f/symlink->tmp/symlink->lustre-subdir ===="
2429 TMP_DIR=$DIR/$tdir/tmp
2430 test_mkdir -p $DIR/$tdir/tmp
2431 test_mkdir $DIR/${tdir}2
2432 ln -s $DIR/${tdir}2 $TMP_DIR/symlink12
2433 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
2434 $CHECKSTAT -t link $TMP_DIR/symlink12 || error
2435 $CHECKSTAT -t link $DIR/$tdir/symlink02 || error
2436 $CHECKSTAT -t dir -f $TMP_DIR/symlink12 || error
2437 $CHECKSTAT -t dir -f $DIR/$tdir/symlink02 || error
2439 run_test 32g "stat d32g/symlink->tmp/symlink->lustre-subdir/${tdir}2"
2442 rm -fr $DIR/$tdir $DIR/${tdir}2
2443 TMP_DIR=$DIR/$tdir/tmp
2444 test_mkdir -p $DIR/$tdir/tmp
2445 test_mkdir $DIR/${tdir}2
2446 ln -s $DIR/${tdir}2 $TMP_DIR/symlink12
2447 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
2448 ls $TMP_DIR/symlink12 || error
2449 ls $DIR/$tdir/symlink02 || error
2451 run_test 32h "open d32h/symlink->tmp/symlink->lustre-subdir/${tdir}2"
2454 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2455 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2456 trap cleanup_test32_mount EXIT
2457 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2458 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2459 touch $DIR/$tdir/test_file
2460 $CHECKSTAT -t file $DIR/$tdir/ext2-mountpoint/../test_file || error
2461 cleanup_test32_mount
2463 run_test 32i "stat d32i/ext2-mountpoint/../test_file ==========="
2466 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2467 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2468 trap cleanup_test32_mount EXIT
2469 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2470 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2471 touch $DIR/$tdir/test_file
2472 cat $DIR/$tdir/ext2-mountpoint/../test_file || error
2473 cleanup_test32_mount
2475 run_test 32j "open d32j/ext2-mountpoint/../test_file ==========="
2478 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2480 trap cleanup_test32_mount EXIT
2481 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2482 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint
2483 test_mkdir -p $DIR/$tdir/d2
2484 touch $DIR/$tdir/d2/test_file || error
2485 $CHECKSTAT -t file $DIR/$tdir/ext2-mountpoint/../d2/test_file || error
2486 cleanup_test32_mount
2488 run_test 32k "stat d32k/ext2-mountpoint/../d2/test_file ========"
2491 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2493 trap cleanup_test32_mount EXIT
2494 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2495 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2496 test_mkdir -p $DIR/$tdir/d2
2497 touch $DIR/$tdir/d2/test_file
2498 cat $DIR/$tdir/ext2-mountpoint/../d2/test_file || error
2499 cleanup_test32_mount
2501 run_test 32l "open d32l/ext2-mountpoint/../d2/test_file ========"
2505 test_mkdir -p $DIR/d32m/tmp
2506 TMP_DIR=$DIR/d32m/tmp
2507 ln -s $DIR $TMP_DIR/symlink11
2508 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
2509 $CHECKSTAT -t link $DIR/d32m/tmp/symlink11 || error
2510 $CHECKSTAT -t link $DIR/d32m/symlink01 || error
2512 run_test 32m "stat d32m/symlink->tmp/symlink->lustre-root ======"
2516 test_mkdir -p $DIR/d32n/tmp
2517 TMP_DIR=$DIR/d32n/tmp
2518 ln -s $DIR $TMP_DIR/symlink11
2519 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
2520 ls -l $DIR/d32n/tmp/symlink11 || error
2521 ls -l $DIR/d32n/symlink01 || error
2523 run_test 32n "open d32n/symlink->tmp/symlink->lustre-root ======"
2527 test_mkdir -p $DIR/d32o/tmp
2528 TMP_DIR=$DIR/d32o/tmp
2529 ln -s $DIR/$tfile $TMP_DIR/symlink12
2530 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
2531 $CHECKSTAT -t link $DIR/d32o/tmp/symlink12 || error
2532 $CHECKSTAT -t link $DIR/d32o/symlink02 || error
2533 $CHECKSTAT -t file -f $DIR/d32o/tmp/symlink12 || error
2534 $CHECKSTAT -t file -f $DIR/d32o/symlink02 || error
2536 run_test 32o "stat d32o/symlink->tmp/symlink->lustre-root/$tfile"
2546 test_mkdir -p $DIR/d32p/tmp
2548 TMP_DIR=$DIR/d32p/tmp
2550 ln -s $DIR/$tfile $TMP_DIR/symlink12
2552 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
2554 cat $DIR/d32p/tmp/symlink12 || error
2556 cat $DIR/d32p/symlink02 || error
2559 run_test 32p "open d32p/symlink->tmp/symlink->lustre-root/$tfile"
2561 cleanup_testdir_mount() {
2567 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2568 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2569 trap cleanup_testdir_mount EXIT
2570 test_mkdir -p $DIR/$tdir
2571 touch $DIR/$tdir/under_the_mount
2572 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir
2573 ls $DIR/$tdir | grep "\<under_the_mount\>" && error
2574 cleanup_testdir_mount
2576 run_test 32q "stat follows mountpoints in Lustre (should return error)"
2579 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2580 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2581 trap cleanup_testdir_mount EXIT
2582 test_mkdir -p $DIR/$tdir
2583 touch $DIR/$tdir/under_the_mount
2584 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir
2585 ls $DIR/$tdir | grep -q under_the_mount && error || true
2586 cleanup_testdir_mount
2588 run_test 32r "opendir follows mountpoints in Lustre (should return error)"
2593 chmod 444 $DIR/$tfile
2594 chown $RUNAS_ID $DIR/$tfile
2596 $RUNAS $OPENFILE -f O_RDWR $DIR/$tfile && error || true
2599 run_test 33aa "write file with mode 444 (should return error) ===="
2603 test_mkdir -p $DIR/d33
2604 chown $RUNAS_ID $DIR/d33
2605 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $DIR/d33/f33|| error "create"
2606 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $DIR/d33/f33 && \
2607 error "open RDWR" || true
2609 run_test 33a "test open file(mode=0444) with O_RDWR (should return error)"
2613 test_mkdir -p $DIR/d33
2614 chown $RUNAS_ID $DIR/d33
2615 $RUNAS $OPENFILE -f 1286739555 $DIR/d33/f33 || true
2617 run_test 33b "test open file with malformed flags (No panic)"
2620 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2626 remote_ost_nodsh && skip "remote OST with nodsh" && return
2629 test_mkdir -p $DIR/d33
2630 # Read: 0, Write: 4, create/destroy: 2/0, stat: 1, punch: 0
2633 for ostnum in $(seq $OSTCOUNT); do
2634 # test-framework's OST numbering is one-based, while Lustre's
2636 ostname=$(printf "$FSNAME-OST%.4x" $((ostnum - 1)))
2637 # Parsing llobdstat's output sucks; we could grep the /proc
2638 # path, but that's likely to not be as portable as using the
2639 # llobdstat utility. So we parse lctl output instead.
2640 write_bytes=$(do_facet ost$ostnum lctl get_param -n \
2641 obdfilter/$ostname/stats |
2642 awk '/^write_bytes/ {print $7}' )
2643 echo "baseline_write_bytes@$OSTnum/$ostname=$write_bytes"
2644 if (( ${write_bytes:-0} > 0 ))
2651 $all_zeros || return 0
2654 echo foo > $DIR/d33/bar
2658 # Total up write_bytes after writing. We'd better find non-zeros.
2659 for ostnum in $(seq $OSTCOUNT); do
2660 ostname=$(printf "$FSNAME-OST%.4x" $((ostnum - 1)))
2661 write_bytes=$(do_facet ost$ostnum lctl get_param -n \
2662 obdfilter/$ostname/stats |
2663 awk '/^write_bytes/ {print $7}' )
2664 echo "write_bytes@$OSTnum/$ostname=$write_bytes"
2665 if (( ${write_bytes:-0} > 0 ))
2674 for ostnum in $(seq $OSTCOUNT); do
2675 ostname=$(printf "$FSNAME-OST%.4x" $((ostnum - 1)))
2676 echo "Check that write_bytes is present in obdfilter/*/stats:"
2677 do_facet ost$ostnum lctl get_param -n \
2678 obdfilter/$ostname/stats
2680 error "OST not keeping write_bytes stats (b22312)"
2683 run_test 33c "test llobdstat and write_bytes"
2686 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 2 MDTs" && return
2687 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2689 local remote_dir=$DIR/$tdir/remote_dir
2691 test_mkdir -p $DIR/$tdir
2692 $LFS mkdir -i $MDTIDX $remote_dir ||
2693 error "create remote directory failed"
2695 touch $remote_dir/$tfile
2696 chmod 444 $remote_dir/$tfile
2697 chown $RUNAS_ID $remote_dir/$tfile
2699 $RUNAS $OPENFILE -f O_RDWR $DIR/$tfile && error || true
2701 chown $RUNAS_ID $remote_dir
2702 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $remote_dir/f33 ||
2703 error "create" || true
2704 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $remote_dir/f33 &&
2705 error "open RDWR" || true
2706 $RUNAS $OPENFILE -f 1286739555 $remote_dir/f33 || true
2708 run_test 33d "openfile with 444 modes and malformed flags under remote dir"
2711 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2715 $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
2716 $LFS setdirstripe -i1 -c2 $DIR/$tdir/striped_dir1
2717 mkdir $DIR/$tdir/local_dir
2719 local s0_mode=$(stat -c%f $DIR/$tdir/striped_dir)
2720 local s1_mode=$(stat -c%f $DIR/$tdir/striped_dir1)
2721 local l_mode=$(stat -c%f $DIR/$tdir/local_dir)
2723 [ "$l_mode" = "$s0_mode" -a "$l_mode" = "$s1_mode" ] ||
2724 error "mkdir $l_mode striped0 $s0_mode striped1 $s1_mode"
2726 rmdir $DIR/$tdir/* || error "rmdir failed"
2729 $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
2730 $LFS setdirstripe -i1 -c2 $DIR/$tdir/striped_dir1
2731 mkdir $DIR/$tdir/local_dir
2733 s0_mode=$(stat -c%f $DIR/$tdir/striped_dir)
2734 s1_mode=$(stat -c%f $DIR/$tdir/striped_dir1)
2735 l_mode=$(stat -c%f $DIR/$tdir/local_dir)
2737 [ "$l_mode" = "$s0_mode" -a "$l_mode" = "$s1_mode" ] ||
2738 error "mkdir $l_mode striped0 $s0_mode striped1 $s1_mode 777"
2740 rmdir $DIR/$tdir/* || error "rmdir(umask 777) failed"
2743 $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
2744 $LFS setdirstripe -i1 -c2 $DIR/$tdir/striped_dir1
2745 mkdir $DIR/$tdir/local_dir
2747 s0_mode=$(stat -c%f $DIR/$tdir/striped_dir)
2748 s1_mode=$(stat -c%f $DIR/$tdir/striped_dir1)
2749 l_mode=$(stat -c%f $DIR/$tdir/local_dir)
2751 [ "$l_mode" = "$s0_mode" -a "$l_mode" = "$s1_mode" ] ||
2752 error "mkdir $l_mode striped0 $s0_mode striped1 $s1_mode 0"
2754 run_test 33e "mkdir and striped directory should have same mode"
2758 do_facet $SINGLEMDS $LCTL set_param mdt.*.enable_remote_dir_gid=0
2762 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2765 chmod go+rwx $DIR/$tdir
2766 do_facet $SINGLEMDS $LCTL set_param mdt.*.enable_remote_dir_gid=-1
2767 trap cleanup_33f EXIT
2769 $RUNAS lfs mkdir -c$MDSCOUNT $DIR/$tdir/striped_dir ||
2770 error "cannot create striped directory"
2772 $RUNAS touch $DIR/$tdir/striped_dir/{0..16} ||
2773 error "cannot create files in striped directory"
2775 $RUNAS rm $DIR/$tdir/striped_dir/{0..16} ||
2776 error "cannot remove files in striped directory"
2778 $RUNAS rmdir $DIR/$tdir/striped_dir ||
2779 error "cannot remove striped directory"
2783 run_test 33f "nonroot user can create, access, and remove a striped directory"
2785 TEST_34_SIZE=${TEST_34_SIZE:-2000000000000}
2788 $MCREATE $DIR/f34 || error
2789 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" || error
2790 $TRUNCATE $DIR/f34 $TEST_34_SIZE || error
2791 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" || error
2792 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2794 run_test 34a "truncate file that has not been opened ==========="
2797 [ ! -f $DIR/f34 ] && test_34a
2798 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2799 $OPENFILE -f O_RDONLY $DIR/f34
2800 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" || error
2801 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2803 run_test 34b "O_RDONLY opening file doesn't create objects ====="
2806 [ ! -f $DIR/f34 ] && test_34a
2807 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2808 $OPENFILE -f O_RDWR $DIR/f34
2809 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" && error
2810 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2812 run_test 34c "O_RDWR opening file-with-size works =============="
2815 [ ! -f $DIR/f34 ] && test_34a
2816 dd if=/dev/zero of=$DIR/f34 conv=notrunc bs=4k count=1 || error
2817 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2820 run_test 34d "write to sparse file ============================="
2824 $MCREATE $DIR/f34e || error
2825 $TRUNCATE $DIR/f34e 1000 || error
2826 $CHECKSTAT -s 1000 $DIR/f34e || error
2827 $OPENFILE -f O_RDWR $DIR/f34e
2828 $CHECKSTAT -s 1000 $DIR/f34e || error
2830 run_test 34e "create objects, some with size and some without =="
2832 test_34f() { # bug 6242, 6243
2833 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2836 $MCREATE $DIR/f34f || error
2837 $TRUNCATE $DIR/f34f $SIZE34F || error "truncating $DIR/f3f to $SIZE34F"
2838 dd if=$DIR/f34f of=$TMP/f34f
2839 $CHECKSTAT -s $SIZE34F $TMP/f34f || error "$TMP/f34f not $SIZE34F bytes"
2840 dd if=/dev/zero of=$TMP/f34fzero bs=$SIZE34F count=1
2841 cmp $DIR/f34f $TMP/f34fzero || error "$DIR/f34f not all zero"
2842 cmp $TMP/f34f $TMP/f34fzero || error "$TMP/f34f not all zero"
2843 rm $TMP/f34f $TMP/f34fzero $DIR/f34f
2845 run_test 34f "read from a file with no objects until EOF ======="
2848 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2849 dd if=/dev/zero of=$DIR/$tfile bs=1 count=100 seek=$TEST_34_SIZE || error
2850 $TRUNCATE $DIR/$tfile $((TEST_34_SIZE / 2))|| error
2851 $CHECKSTAT -s $((TEST_34_SIZE / 2)) $DIR/$tfile || error "truncate failed"
2852 cancel_lru_locks osc
2853 $CHECKSTAT -s $((TEST_34_SIZE / 2)) $DIR/$tfile || \
2854 error "wrong size after lock cancel"
2856 $TRUNCATE $DIR/$tfile $TEST_34_SIZE || error
2857 $CHECKSTAT -s $TEST_34_SIZE $DIR/$tfile || \
2858 error "expanding truncate failed"
2859 cancel_lru_locks osc
2860 $CHECKSTAT -s $TEST_34_SIZE $DIR/$tfile || \
2861 error "wrong expanded size after lock cancel"
2863 run_test 34g "truncate long file ==============================="
2866 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2870 dd if=/dev/zero of=$DIR/$tfile bs=1M count=10 || error
2871 sync # Flush the cache so that multiop below does not block on cache
2872 # flush when getting the group lock
2873 $MULTIOP $DIR/$tfile OG${gid}T${sz}g${gid}c &
2876 # Since just timed wait is not good enough, let's do a sync write
2877 # that way we are sure enough time for a roundtrip + processing
2878 # passed + 2 seconds of extra margin.
2879 dd if=/dev/zero of=$DIR/${tfile}-1 bs=4096 oflag=direct count=1
2883 if [[ `ps h -o comm -p $MULTIPID` == "multiop" ]]; then
2884 error "Multiop blocked on ftruncate, pid=$MULTIPID"
2888 local nsz=`stat -c %s $DIR/$tfile`
2889 [[ $nsz == $sz ]] || error "New size wrong $nsz != $sz"
2891 run_test 34h "ftruncate file under grouplock should not block"
2894 cp /bin/sh $DIR/f35a
2896 chown $RUNAS_ID $DIR/f35a
2897 $RUNAS $DIR/f35a && error || true
2900 run_test 35a "exec file with mode 444 (should return and not leak) ====="
2904 utime $DIR/f36 || error
2906 run_test 36a "MDS utime check (mknod, utime) ==================="
2910 utime $DIR/f36 || error
2912 run_test 36b "OST utime check (open, utime) ===================="
2917 chown $RUNAS_ID $DIR/d36
2918 $RUNAS utime $DIR/d36/f36 || error
2920 run_test 36c "non-root MDS utime check (mknod, utime) =========="
2923 [ ! -d $DIR/d36 ] && test_36c
2924 echo "" > $DIR/d36/f36
2925 $RUNAS utime $DIR/d36/f36 || error
2927 run_test 36d "non-root OST utime check (open, utime) ==========="
2930 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID -- skipping" && return
2931 test_mkdir -p $DIR/$tdir
2932 touch $DIR/$tdir/$tfile
2933 $RUNAS utime $DIR/$tdir/$tfile && \
2934 error "utime worked, expected failure" || true
2936 run_test 36e "utime on non-owned file (should return error) ===="
2940 local LANG_SAVE=$LANG
2941 local LC_LANG_SAVE=$LC_LANG
2942 export LANG=C LC_LANG=C # for date language
2944 DATESTR="Dec 20 2000"
2945 test_mkdir -p $DIR/$tdir
2946 lctl set_param fail_loc=$fl
2948 cp /etc/hosts $DIR/$tdir/$tfile
2949 sync & # write RPC generated with "current" inode timestamp, but delayed
2951 touch --date="$DATESTR" $DIR/$tdir/$tfile # setattr timestamp in past
2952 LS_BEFORE="`ls -l $DIR/$tdir/$tfile`" # old timestamp from client cache
2953 cancel_lru_locks osc
2954 LS_AFTER="`ls -l $DIR/$tdir/$tfile`" # timestamp from OST object
2956 [ "$LS_BEFORE" != "$LS_AFTER" ] && \
2957 echo "BEFORE: $LS_BEFORE" && \
2958 echo "AFTER : $LS_AFTER" && \
2959 echo "WANT : $DATESTR" && \
2960 error "$DIR/$tdir/$tfile timestamps changed" || true
2962 export LANG=$LANG_SAVE LC_LANG=$LC_LANG_SAVE
2966 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2967 #define OBD_FAIL_OST_BRW_PAUSE_BULK 0x214
2968 subr_36fh "0x80000214"
2970 run_test 36f "utime on file racing with OST BRW write =========="
2973 remote_ost_nodsh && skip "remote OST with nodsh" && return
2974 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2979 test_mkdir -p $DIR/$tdir
2980 fmd_max_age=$(do_facet ost1 \
2981 "lctl get_param -n obdfilter.*.client_cache_seconds 2> /dev/null | \
2984 fmd_before=$(do_facet ost1 \
2985 "awk '/ll_fmd_cache/ {print \\\$2}' /proc/slabinfo")
2986 touch $DIR/$tdir/$tfile
2987 sleep $((fmd_max_age + 12))
2988 fmd_after=$(do_facet ost1 \
2989 "awk '/ll_fmd_cache/ {print \\\$2}' /proc/slabinfo")
2991 echo "fmd_before: $fmd_before"
2992 echo "fmd_after: $fmd_after"
2993 [[ $fmd_after -gt $fmd_before ]] &&
2994 echo "AFTER: $fmd_after > BEFORE: $fmd_before" &&
2995 error "fmd didn't expire after ping" || true
2997 run_test 36g "filter mod data cache expiry ====================="
3000 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3001 #define OBD_FAIL_OST_BRW_PAUSE_BULK2 0x227
3002 subr_36fh "0x80000227"
3004 run_test 36h "utime on file racing with OST BRW write =========="
3007 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
3009 test_mkdir $DIR/$tdir
3010 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR/$tdir/striped_dir
3012 local mtime=$(stat -c%Y $DIR/$tdir/striped_dir)
3013 local new_mtime=$((mtime + 200))
3015 #change Modify time of striped dir
3016 touch -m -d @$new_mtime $DIR/$tdir/striped_dir ||
3017 error "change mtime failed"
3019 local got=$(stat -c%Y $DIR/$tdir/striped_dir)
3021 [ "$new_mtime" = "$got" ] || error "expect $new_mtime got $got"
3023 run_test 36i "change mtime on striped directory"
3025 # test_37 - duplicate with tests 32q 32r
3028 local file=$DIR/$tfile
3030 openfile -f O_DIRECTORY $file
3033 [ $RC -eq 0 ] && error "opened file $file with O_DIRECTORY" || true
3034 [ $RC -eq $ENOTDIR ] || error "error $RC should be ENOTDIR ($ENOTDIR)"
3036 run_test 38 "open a regular file with O_DIRECTORY should return -ENOTDIR ==="
3040 touch $DIR/${tfile}2
3041 # ls -l $DIR/$tfile $DIR/${tfile}2
3042 # ls -lu $DIR/$tfile $DIR/${tfile}2
3043 # ls -lc $DIR/$tfile $DIR/${tfile}2
3045 $OPENFILE -f O_CREAT:O_TRUNC:O_WRONLY $DIR/${tfile}2
3046 if [ ! $DIR/${tfile}2 -nt $DIR/$tfile ]; then
3048 ls -l --full-time $DIR/$tfile $DIR/${tfile}2
3050 ls -lu --full-time $DIR/$tfile $DIR/${tfile}2
3052 ls -lc --full-time $DIR/$tfile $DIR/${tfile}2
3053 error "O_TRUNC didn't change timestamps"
3056 run_test 39 "mtime changed on create ==========================="
3059 test_mkdir -p -c1 $DIR/$tdir
3060 cp -p /etc/passwd $DIR/$tdir/fopen
3061 cp -p /etc/passwd $DIR/$tdir/flink
3062 cp -p /etc/passwd $DIR/$tdir/funlink
3063 cp -p /etc/passwd $DIR/$tdir/frename
3064 ln $DIR/$tdir/funlink $DIR/$tdir/funlink2
3067 echo "aaaaaa" >> $DIR/$tdir/fopen
3068 echo "aaaaaa" >> $DIR/$tdir/flink
3069 echo "aaaaaa" >> $DIR/$tdir/funlink
3070 echo "aaaaaa" >> $DIR/$tdir/frename
3072 local open_new=`stat -c %Y $DIR/$tdir/fopen`
3073 local link_new=`stat -c %Y $DIR/$tdir/flink`
3074 local unlink_new=`stat -c %Y $DIR/$tdir/funlink`
3075 local rename_new=`stat -c %Y $DIR/$tdir/frename`
3077 cat $DIR/$tdir/fopen > /dev/null
3078 ln $DIR/$tdir/flink $DIR/$tdir/flink2
3079 rm -f $DIR/$tdir/funlink2
3080 mv -f $DIR/$tdir/frename $DIR/$tdir/frename2
3082 for (( i=0; i < 2; i++ )) ; do
3083 local open_new2=`stat -c %Y $DIR/$tdir/fopen`
3084 local link_new2=`stat -c %Y $DIR/$tdir/flink`
3085 local unlink_new2=`stat -c %Y $DIR/$tdir/funlink`
3086 local rename_new2=`stat -c %Y $DIR/$tdir/frename2`
3088 [ $open_new2 -eq $open_new ] || error "open file reverses mtime"
3089 [ $link_new2 -eq $link_new ] || error "link file reverses mtime"
3090 [ $unlink_new2 -eq $unlink_new ] || error "unlink file reverses mtime"
3091 [ $rename_new2 -eq $rename_new ] || error "rename file reverses mtime"
3093 cancel_lru_locks osc
3094 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3097 run_test 39b "mtime change on open, link, unlink, rename ======"
3099 # this should be set to past
3100 TEST_39_MTIME=`date -d "1 year ago" +%s`
3106 local mtime0=`stat -c %Y $DIR1/$tfile`
3108 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3109 local mtime1=`stat -c %Y $DIR1/$tfile`
3110 [ "$mtime1" = $TEST_39_MTIME ] || \
3111 error "mtime is not set to past: $mtime1, should be $TEST_39_MTIME"
3114 echo hello >> $DIR1/$tfile
3116 local mtime2=`stat -c %Y $DIR1/$tfile`
3117 [ "$mtime2" -ge "$d1" ] && [ "$mtime2" -le "$d2" ] || \
3118 error "mtime is not updated on write: $d1 <= $mtime2 <= $d2"
3120 mv $DIR1/$tfile $DIR1/$tfile-1
3122 for (( i=0; i < 2; i++ )) ; do
3123 local mtime3=`stat -c %Y $DIR1/$tfile-1`
3124 [ "$mtime2" = "$mtime3" ] || \
3125 error "mtime ($mtime2) changed (to $mtime3) on rename"
3127 cancel_lru_locks osc
3128 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3131 run_test 39c "mtime change on rename ==========================="
3135 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3138 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3140 for (( i=0; i < 2; i++ )) ; do
3141 local mtime=`stat -c %Y $DIR1/$tfile`
3142 [ $mtime = $TEST_39_MTIME ] || \
3143 error "mtime($mtime) is not set to $TEST_39_MTIME"
3145 cancel_lru_locks osc
3146 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3149 run_test 39d "create, utime, stat =============================="
3153 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3155 local mtime1=`stat -c %Y $DIR1/$tfile`
3157 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3159 for (( i=0; i < 2; i++ )) ; do
3160 local mtime2=`stat -c %Y $DIR1/$tfile`
3161 [ $mtime2 = $TEST_39_MTIME ] || \
3162 error "mtime($mtime2) is not set to $TEST_39_MTIME"
3164 cancel_lru_locks osc
3165 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3168 run_test 39e "create, stat, utime, stat ========================"
3172 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3174 mtime1=`stat -c %Y $DIR1/$tfile`
3177 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3179 for (( i=0; i < 2; i++ )) ; do
3180 local mtime2=`stat -c %Y $DIR1/$tfile`
3181 [ $mtime2 = $TEST_39_MTIME ] || \
3182 error "mtime($mtime2) is not set to $TEST_39_MTIME"
3184 cancel_lru_locks osc
3185 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3188 run_test 39f "create, stat, sleep, utime, stat ================="
3192 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3193 echo hello >> $DIR1/$tfile
3194 local mtime1=`stat -c %Y $DIR1/$tfile`
3197 chmod o+r $DIR1/$tfile
3199 for (( i=0; i < 2; i++ )) ; do
3200 local mtime2=`stat -c %Y $DIR1/$tfile`
3201 [ "$mtime1" = "$mtime2" ] || \
3202 error "lost mtime: $mtime2, should be $mtime1"
3204 cancel_lru_locks osc
3205 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3208 run_test 39g "write, chmod, stat ==============================="
3212 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3217 echo hello >> $DIR1/$tfile
3218 local mtime1=`stat -c %Y $DIR1/$tfile`
3220 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3222 if [ "$d1" != "$d2" ]; then
3223 echo "write and touch not within one second"
3225 for (( i=0; i < 2; i++ )) ; do
3226 local mtime2=`stat -c %Y $DIR1/$tfile`
3227 [ "$mtime2" = $TEST_39_MTIME ] || \
3228 error "lost mtime: $mtime2, should be $TEST_39_MTIME"
3230 cancel_lru_locks osc
3231 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3235 run_test 39h "write, utime within one second, stat ============="
3238 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3242 echo hello >> $DIR1/$tfile
3243 local mtime1=`stat -c %Y $DIR1/$tfile`
3245 mv $DIR1/$tfile $DIR1/$tfile-1
3247 for (( i=0; i < 2; i++ )) ; do
3248 local mtime2=`stat -c %Y $DIR1/$tfile-1`
3250 [ "$mtime1" = "$mtime2" ] || \
3251 error "lost mtime: $mtime2, should be $mtime1"
3253 cancel_lru_locks osc
3254 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3257 run_test 39i "write, rename, stat =============================="
3260 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3261 start_full_debug_logging
3265 #define OBD_FAIL_OSC_DELAY_SETTIME 0x412
3266 lctl set_param fail_loc=0x80000412
3267 multiop_bg_pause $DIR1/$tfile oO_RDWR:w2097152_c ||
3268 error "multiop failed"
3270 local mtime1=`stat -c %Y $DIR1/$tfile`
3272 mv $DIR1/$tfile $DIR1/$tfile-1
3274 kill -USR1 $multipid
3275 wait $multipid || error "multiop close failed"
3277 for (( i=0; i < 2; i++ )) ; do
3278 local mtime2=`stat -c %Y $DIR1/$tfile-1`
3279 [ "$mtime1" = "$mtime2" ] ||
3280 error "mtime is lost on close: $mtime2, " \
3283 cancel_lru_locks osc
3284 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3286 lctl set_param fail_loc=0
3287 stop_full_debug_logging
3289 run_test 39j "write, rename, close, stat ======================="
3292 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3296 multiop_bg_pause $DIR1/$tfile oO_RDWR:w2097152_c || error "multiop failed"
3298 local mtime1=`stat -c %Y $DIR1/$tfile`
3300 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3302 kill -USR1 $multipid
3303 wait $multipid || error "multiop close failed"
3305 for (( i=0; i < 2; i++ )) ; do
3306 local mtime2=`stat -c %Y $DIR1/$tfile`
3308 [ "$mtime2" = $TEST_39_MTIME ] || \
3309 error "mtime is lost on close: $mtime2, should be $TEST_39_MTIME"
3311 cancel_lru_locks osc
3312 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3315 run_test 39k "write, utime, close, stat ========================"
3317 # this should be set to future
3318 TEST_39_ATIME=`date -d "1 year" +%s`
3321 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3322 remote_mds_nodsh && skip "remote MDS with nodsh" && return
3323 local atime_diff=$(do_facet $SINGLEMDS \
3324 lctl get_param -n mdd.*MDT0000*.atime_diff)
3328 # test setting directory atime to future
3329 touch -a -d @$TEST_39_ATIME $DIR/$tdir
3330 local atime=$(stat -c %X $DIR/$tdir)
3331 [ "$atime" = $TEST_39_ATIME ] || \
3332 error "atime is not set to future: $atime, $TEST_39_ATIME"
3334 # test setting directory atime from future to now
3335 local d1=$(date +%s)
3337 local d2=$(date +%s)
3339 cancel_lru_locks mdc
3340 atime=$(stat -c %X $DIR/$tdir)
3341 [ "$atime" -ge "$d1" -a "$atime" -le "$d2" ] || \
3342 error "atime is not updated from future: $atime, $d1<atime<$d2"
3344 do_facet $SINGLEMDS lctl set_param -n mdd.*MDT0000*.atime_diff=2
3347 # test setting directory atime when now > dir atime + atime_diff
3351 cancel_lru_locks mdc
3352 atime=$(stat -c %X $DIR/$tdir)
3353 [ "$atime" -ge "$d1" -a "$atime" -le "$d2" ] || \
3354 error "atime is not updated : $atime, should be $d2"
3356 do_facet $SINGLEMDS lctl set_param -n mdd.*MDT0000*.atime_diff=60
3359 # test not setting directory atime when now < dir atime + atime_diff
3361 cancel_lru_locks mdc
3362 atime=$(stat -c %X $DIR/$tdir)
3363 [ "$atime" -ge "$d1" -a "$atime" -le "$d2" ] || \
3364 error "atime is updated to $atime, should remain $d1<atime<$d2"
3366 do_facet $SINGLEMDS \
3367 lctl set_param -n mdd.*MDT0000*.atime_diff=$atime_diff
3369 run_test 39l "directory atime update ==========================="
3372 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3375 local far_past_mtime=$(date -d "May 29 1953" +%s)
3376 local far_past_atime=$(date -d "Dec 17 1903" +%s)
3378 touch -m -d @$far_past_mtime $DIR1/$tfile
3379 touch -a -d @$far_past_atime $DIR1/$tfile
3381 for (( i=0; i < 2; i++ )) ; do
3382 local timestamps=$(stat -c "%X %Y" $DIR1/$tfile)
3383 [ "$timestamps" = "$far_past_atime $far_past_mtime" ] || \
3384 error "atime or mtime set incorrectly"
3386 cancel_lru_locks osc
3387 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3390 run_test 39m "test atime and mtime before 1970"
3392 test_39n() { # LU-3832
3393 local atime_diff=$(do_facet $SINGLEMDS \
3394 lctl get_param -n mdd.*MDT0000*.atime_diff)
3399 do_facet $SINGLEMDS lctl set_param -n mdd.*MDT0000*.atime_diff=1
3402 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 status=noxfer
3403 atime0=$(stat -c %X $DIR/$tfile)
3406 $MULTIOP $DIR/$tfile oO_RDONLY:O_NOATIME:r4096c
3407 atime1=$(stat -c %X $DIR/$tfile)
3410 cancel_lru_locks mdc
3411 cancel_lru_locks osc
3412 $MULTIOP $DIR/$tfile oO_RDONLY:O_NOATIME:r4096c
3413 atime2=$(stat -c %X $DIR/$tfile)
3415 do_facet $SINGLEMDS \
3416 lctl set_param -n mdd.*MDT0000*.atime_diff=$atime_diff
3418 [ "$atime0" -eq "$atime1" ] || error "atime0 $atime0 != atime1 $atime1"
3419 [ "$atime1" -eq "$atime2" ] || error "atime0 $atime0 != atime1 $atime1"
3421 run_test 39n "check that O_NOATIME is honored"
3424 TESTDIR=$DIR/$tdir/$tfile
3425 [ -e $TESTDIR ] && rm -rf $TESTDIR
3432 links2=$(stat -c %h .)
3433 [ $(($links1 + 2)) != $links2 ] &&
3434 error "wrong links count $(($links1 + 2)) != $links2"
3436 links3=$(stat -c %h .)
3437 [ $(($links1 + 1)) != $links3 ] &&
3438 error "wrong links count $links1 != $links3"
3441 run_test 39o "directory cached attributes updated after create ========"
3444 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 2 MDTs" && return
3446 TESTDIR=$DIR/$tdir/$tfile
3447 [ -e $TESTDIR ] && rm -rf $TESTDIR
3448 test_mkdir -p $TESTDIR
3452 $LFS mkdir -i $MDTIDX $TESTDIR/remote_dir1
3453 $LFS mkdir -i $MDTIDX $TESTDIR/remote_dir2
3455 links2=$(stat -c %h .)
3456 [ $(($links1 + 2)) != $links2 ] &&
3457 error "wrong links count $(($links1 + 2)) != $links2"
3459 links3=$(stat -c %h .)
3460 [ $(($links1 + 1)) != $links3 ] &&
3461 error "wrong links count $links1 != $links3"
3464 run_test 39p "remote directory cached attributes updated after create ========"
3468 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1
3469 $RUNAS $OPENFILE -f O_WRONLY:O_TRUNC $DIR/$tfile &&
3470 error "openfile O_WRONLY:O_TRUNC $tfile failed"
3471 $CHECKSTAT -t file -s 4096 $DIR/$tfile ||
3472 error "$tfile is not 4096 bytes in size"
3474 run_test 40 "failed open(O_TRUNC) doesn't truncate ============="
3478 small_write $DIR/f41 18
3480 run_test 41 "test small file write + fstat ====================="
3482 count_ost_writes() {
3483 lctl get_param -n osc.*.stats |
3484 awk -vwrites=0 '/ost_write/ { writes += $2 } \
3485 END { printf("%0.0f", writes) }'
3492 BG_DIRTY_RATIO_SAVE=10
3493 MAX_BG_DIRTY_RATIO=25
3497 # in 2.6, restore /proc/sys/vm/dirty_writeback_centisecs,
3498 # dirty_ratio, dirty_background_ratio
3499 if [ -f /proc/sys/vm/dirty_writeback_centisecs ]; then
3500 sysctl -w vm.dirty_writeback_centisecs=$WRITEBACK_SAVE
3501 sysctl -w vm.dirty_background_ratio=$BG_DIRTY_RATIO_SAVE
3502 sysctl -w vm.dirty_ratio=$DIRTY_RATIO_SAVE
3504 # if file not here, we are a 2.4 kernel
3505 kill -CONT `pidof kupdated`
3510 # setup the trap first, so someone cannot exit the test at the
3511 # exact wrong time and mess up a machine
3512 trap start_writeback EXIT
3513 # in 2.6, save and 0 /proc/sys/vm/dirty_writeback_centisecs
3514 if [ -f /proc/sys/vm/dirty_writeback_centisecs ]; then
3515 WRITEBACK_SAVE=`sysctl -n vm.dirty_writeback_centisecs`
3516 sysctl -w vm.dirty_writeback_centisecs=0
3517 sysctl -w vm.dirty_writeback_centisecs=0
3518 # save and increase /proc/sys/vm/dirty_ratio
3519 DIRTY_RATIO_SAVE=`sysctl -n vm.dirty_ratio`
3520 sysctl -w vm.dirty_ratio=$MAX_DIRTY_RATIO
3521 # save and increase /proc/sys/vm/dirty_background_ratio
3522 BG_DIRTY_RATIO_SAVE=`sysctl -n vm.dirty_background_ratio`
3523 sysctl -w vm.dirty_background_ratio=$MAX_BG_DIRTY_RATIO
3525 # if file not here, we are a 2.4 kernel
3526 kill -STOP `pidof kupdated`
3530 # ensure that all stripes have some grant before we test client-side cache
3532 for i in `seq -f $DIR/f42-%g 1 $OSTCOUNT`; do
3533 dd if=/dev/zero of=$i bs=4k count=1
3538 # Tests 42* verify that our behaviour is correct WRT caching, file closure,
3539 # file truncation, and file removal.
3541 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3543 cancel_lru_locks osc
3545 sync; sleep 1; sync # just to be safe
3546 BEFOREWRITES=`count_ost_writes`
3547 lctl get_param -n osc.*[oO][sS][cC][_-]*.cur_grant_bytes | grep "[0-9]"
3548 dd if=/dev/zero of=$DIR/f42a bs=1024 count=100
3549 AFTERWRITES=`count_ost_writes`
3550 [ $BEFOREWRITES -eq $AFTERWRITES ] || \
3551 error "$BEFOREWRITES < $AFTERWRITES"
3554 run_test 42a "ensure that we don't flush on close =============="
3557 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3559 cancel_lru_locks osc
3562 dd if=/dev/zero of=$DIR/f42b bs=1024 count=100
3563 BEFOREWRITES=$(count_ost_writes)
3564 $MUNLINK $DIR/f42b || error "$MUNLINK $DIR/f42b: $?"
3565 AFTERWRITES=$(count_ost_writes)
3566 if [[ $BEFOREWRITES -lt $AFTERWRITES ]]; then
3567 error "$BEFOREWRITES < $AFTERWRITES on unlink"
3569 BEFOREWRITES=$(count_ost_writes)
3570 sync || error "sync: $?"
3571 AFTERWRITES=$(count_ost_writes)
3572 if [[ $BEFOREWRITES -lt $AFTERWRITES ]]; then
3573 error "$BEFOREWRITES < $AFTERWRITES on sync"
3575 dmesg | grep 'error from obd_brw_async' && error 'error writing back'
3579 run_test 42b "test destroy of file with cached dirty data ======"
3581 # if these tests just want to test the effect of truncation,
3582 # they have to be very careful. consider:
3583 # - the first open gets a {0,EOF}PR lock
3584 # - the first write conflicts and gets a {0, count-1}PW
3585 # - the rest of the writes are under {count,EOF}PW
3586 # - the open for truncate tries to match a {0,EOF}PR
3587 # for the filesize and cancels the PWs.
3588 # any number of fixes (don't get {0,EOF} on open, match
3589 # composite locks, do smarter file size management) fix
3590 # this, but for now we want these tests to verify that
3591 # the cancellation with truncate intent works, so we
3592 # start the file with a full-file pw lock to match against
3593 # until the truncate.
3598 cancel_lru_locks osc
3600 # prime the file with 0,EOF PW to match
3604 # now the real test..
3605 dd if=/dev/zero of=$file bs=1024 count=100
3606 BEFOREWRITES=`count_ost_writes`
3607 $TRUNCATE $file $offset
3608 cancel_lru_locks osc
3609 AFTERWRITES=`count_ost_writes`
3614 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3616 [ $BEFOREWRITES -eq $AFTERWRITES ] && \
3617 error "beforewrites $BEFOREWRITES == afterwrites $AFTERWRITES on truncate"
3620 run_test 42c "test partial truncate of file with cached dirty data"
3623 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3625 [ $BEFOREWRITES -eq $AFTERWRITES ] || \
3626 error "beforewrites $BEFOREWRITES != afterwrites $AFTERWRITES on truncate"
3629 run_test 42d "test complete truncate of file with cached dirty data"
3631 test_42e() { # bug22074
3632 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3633 local TDIR=$DIR/${tdir}e
3634 local pagesz=$(page_size)
3635 local pages=16 # hardcoded 16 pages, don't change it.
3636 local files=$((OSTCOUNT * 500)) # hopefully 500 files on each OST
3637 local proc_osc0="osc.${FSNAME}-OST0000-osc-[^MDT]*"
3641 test_mkdir -p $DIR/${tdir}e
3642 $SETSTRIPE -c 1 $TDIR
3643 createmany -o $TDIR/f $files
3645 max_dirty_mb=$($LCTL get_param -n $proc_osc0/max_dirty_mb)
3647 # we assume that with $OSTCOUNT files, at least one of them will
3648 # be allocated on OST0.
3649 warmup_files=$((OSTCOUNT * max_dirty_mb))
3650 createmany -o $TDIR/w $warmup_files
3652 # write a large amount of data into one file and sync, to get good
3653 # avail_grant number from OST.
3654 for ((i=0; i<$warmup_files; i++)); do
3655 idx=$($GETSTRIPE -i $TDIR/w$i)
3656 [ $idx -ne 0 ] && continue
3657 dd if=/dev/zero of=$TDIR/w$i bs="$max_dirty_mb"M count=1
3660 [[ $i -gt $warmup_files ]] && error "OST0 is still cold"
3662 $LCTL get_param $proc_osc0/cur_dirty_bytes
3663 $LCTL get_param $proc_osc0/cur_grant_bytes
3665 # create as much dirty pages as we can while not to trigger the actual
3666 # RPCs directly. but depends on the env, VFS may trigger flush during this
3667 # period, hopefully we are good.
3668 for ((i=0; i<$warmup_files; i++)); do
3669 idx=$($GETSTRIPE -i $TDIR/w$i)
3670 [ $idx -ne 0 ] && continue
3671 dd if=/dev/zero of=$TDIR/w$i bs=1M count=1 2>/dev/null
3673 $LCTL get_param $proc_osc0/cur_dirty_bytes
3674 $LCTL get_param $proc_osc0/cur_grant_bytes
3676 # perform the real test
3677 $LCTL set_param $proc_osc0/rpc_stats 0
3678 for ((;i<$files; i++)); do
3679 [ $($GETSTRIPE -i $TDIR/f$i) -eq 0 ] || continue
3680 dd if=/dev/zero of=$TDIR/f$i bs=$pagesz count=$pages 2>/dev/null
3683 $LCTL get_param $proc_osc0/rpc_stats
3686 local have_ppr=false
3687 $LCTL get_param $proc_osc0/rpc_stats |
3688 while read PPR RRPC RPCT RCUM BAR WRPC WPCT WCUM; do
3689 # skip lines until we are at the RPC histogram data
3690 [ "$PPR" == "pages" ] && have_ppr=true && continue
3691 $have_ppr || continue
3693 # we only want the percent stat for < 16 pages
3694 [[ $(echo $PPR | tr -d ':') -ge $pages ]] && break
3696 percent=$((percent + WPCT))
3697 if [[ $percent -gt 15 ]]; then
3698 error "less than 16-pages write RPCs" \
3705 run_test 42e "verify sub-RPC writes are not done synchronously"
3708 test_mkdir -p $DIR/$tdir
3709 cp -p /bin/ls $DIR/$tdir/$tfile
3710 $MULTIOP $DIR/$tdir/$tfile Ow_c &
3712 # give multiop a chance to open
3715 $DIR/$tdir/$tfile && error || true
3718 run_test 43 "execution of file opened for write should return -ETXTBSY"
3721 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3722 test_mkdir -p $DIR/$tdir
3723 cp -p `which $MULTIOP` $DIR/$tdir/multiop ||
3724 cp -p multiop $DIR/$tdir/multiop
3725 MULTIOP_PROG=$DIR/$tdir/multiop multiop_bg_pause $TMP/$tfile.junk O_c ||
3728 $MULTIOP $DIR/$tdir/multiop Oc && error "expected error, got success"
3729 kill -USR1 $MULTIOP_PID || return 2
3730 wait $MULTIOP_PID || return 3
3731 rm $TMP/$tfile.junk $DIR/$tdir/multiop
3733 run_test 43a "open(RDWR) of file being executed should return -ETXTBSY"
3736 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3737 test_mkdir -p $DIR/$tdir
3738 cp -p `which $MULTIOP` $DIR/$tdir/multiop ||
3739 cp -p multiop $DIR/$tdir/multiop
3740 MULTIOP_PROG=$DIR/$tdir/multiop multiop_bg_pause $TMP/$tfile.junk O_c ||
3743 $TRUNCATE $DIR/$tdir/multiop 0 && error "expected error, got success"
3744 kill -USR1 $MULTIOP_PID || return 2
3745 wait $MULTIOP_PID || return 3
3746 rm $TMP/$tfile.junk $DIR/$tdir/multiop
3748 run_test 43b "truncate of file being executed should return -ETXTBSY"
3751 local testdir="$DIR/$tdir"
3752 test_mkdir -p $DIR/$tdir
3754 ( cd $(dirname $SHELL) && md5sum $(basename $SHELL) ) | \
3755 ( cd $testdir && md5sum -c)
3757 run_test 43c "md5sum of copy into lustre========================"
3760 [[ $OSTCOUNT -lt 2 ]] && skip_env "skipping 2-stripe test" && return
3761 dd if=/dev/zero of=$DIR/f1 bs=4k count=1 seek=1023
3762 dd if=$DIR/f1 bs=4k count=1 > /dev/null
3764 run_test 44 "zero length read from a sparse stripe ============="
3767 local nstripe=$($LCTL lov_getconfig $DIR | grep default_stripe_count: |
3769 [ -z "$nstripe" ] && skip "can't get stripe info" && return
3770 [[ $nstripe -gt $OSTCOUNT ]] &&
3771 skip "Wrong default_stripe_count: $nstripe (OSTCOUNT: $OSTCOUNT)" &&
3773 local stride=$($LCTL lov_getconfig $DIR | grep default_stripe_size: |
3775 if [[ $nstripe -eq 0 || $nstripe -eq -1 ]]; then
3776 nstripe=$($LCTL lov_getconfig $DIR | grep obd_count: |
3780 OFFSETS="0 $((stride/2)) $((stride-1))"
3781 for offset in $OFFSETS; do
3782 for i in $(seq 0 $((nstripe-1))); do
3783 local GLOBALOFFSETS=""
3785 local size=$((((i + 2 * $nstripe )*$stride + $offset)))
3786 local myfn=$DIR/d44a-$size
3787 echo "--------writing $myfn at $size"
3788 ll_sparseness_write $myfn $size ||
3789 error "ll_sparseness_write"
3790 GLOBALOFFSETS="$GLOBALOFFSETS $size"
3791 ll_sparseness_verify $myfn $GLOBALOFFSETS ||
3792 error "ll_sparseness_verify $GLOBALOFFSETS"
3794 for j in $(seq 0 $((nstripe-1))); do
3796 size=$((((j + $nstripe )*$stride + $offset)))
3797 ll_sparseness_write $myfn $size ||
3798 error "ll_sparseness_write"
3799 GLOBALOFFSETS="$GLOBALOFFSETS $size"
3801 ll_sparseness_verify $myfn $GLOBALOFFSETS ||
3802 error "ll_sparseness_verify $GLOBALOFFSETS"
3807 run_test 44a "test sparse pwrite ==============================="
3811 for d in `lctl get_param -n osc.*.cur_dirty_bytes`; do
3817 before=`dirty_osc_total`
3818 echo executing "\"$*\""
3820 after=`dirty_osc_total`
3821 echo before $before, after $after
3824 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3826 # Obtain grants from OST if it supports it
3827 echo blah > ${f}_grant
3830 do_dirty_record "echo blah > $f"
3831 [[ $before -eq $after ]] && error "write wasn't cached"
3832 do_dirty_record "> $f"
3833 [[ $before -gt $after ]] || error "truncate didn't lower dirty count"
3834 do_dirty_record "echo blah > $f"
3835 [[ $before -eq $after ]] && error "write wasn't cached"
3836 do_dirty_record "sync"
3837 [[ $before -gt $after ]] || error "writeback didn't lower dirty count"
3838 do_dirty_record "echo blah > $f"
3839 [[ $before -eq $after ]] && error "write wasn't cached"
3840 do_dirty_record "cancel_lru_locks osc"
3841 [[ $before -gt $after ]] ||
3842 error "lock cancellation didn't lower dirty count"
3845 run_test 45 "osc io page accounting ============================"
3847 # in a 2 stripe file (lov.sh), page 1023 maps to page 511 in its object. this
3848 # test tickles a bug where re-dirtying a page was failing to be mapped to the
3849 # objects offset and an assert hit when an rpc was built with 1023's mapped
3850 # offset 511 and 511's raw 511 offset. it also found general redirtying bugs.
3852 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3856 dd if=/dev/zero of=$f bs=`page_size` seek=511 count=1
3858 dd conv=notrunc if=/dev/zero of=$f bs=`page_size` seek=1023 count=1
3859 dd conv=notrunc if=/dev/zero of=$f bs=`page_size` seek=511 count=1
3863 run_test 46 "dirtying a previously written page ================"
3865 # test_47 is removed "Device nodes check" is moved to test_28
3867 test_48a() { # bug 2399
3868 [ $(facet_fstype $SINGLEMDS) = "zfs" ] &&
3869 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.3.63) ] &&
3870 skip "MDS prior to 2.3.63 handle ZFS dir .. incorrectly" &&
3872 test_mkdir $DIR/$tdir
3874 mv $DIR/$tdir $DIR/$tdir.new || error "move directory failed"
3875 test_mkdir $DIR/$tdir || error "recreate directory failed"
3876 touch foo || error "'touch foo' failed after recreating cwd"
3877 test_mkdir bar || error "'mkdir foo' failed after recreating cwd"
3878 touch .foo || error "'touch .foo' failed after recreating cwd"
3879 test_mkdir .bar || error "'mkdir .foo' failed after recreating cwd"
3880 ls . > /dev/null || error "'ls .' failed after recreating cwd"
3881 ls .. > /dev/null || error "'ls ..' failed after removing cwd"
3882 cd . || error "'cd .' failed after recreating cwd"
3883 test_mkdir . && error "'mkdir .' worked after recreating cwd"
3884 rmdir . && error "'rmdir .' worked after recreating cwd"
3885 ln -s . baz || error "'ln -s .' failed after recreating cwd"
3886 cd .. || error "'cd ..' failed after recreating cwd"
3888 run_test 48a "Access renamed working dir (should return errors)="
3890 test_48b() { # bug 2399
3892 test_mkdir $DIR/$tdir
3894 rmdir $DIR/$tdir || error "remove cwd $DIR/$tdir failed"
3895 touch foo && error "'touch foo' worked after removing cwd"
3896 test_mkdir foo && error "'mkdir foo' worked after removing cwd"
3897 touch .foo && error "'touch .foo' worked after removing cwd"
3898 test_mkdir .foo && error "'mkdir .foo' worked after removing cwd"
3899 ls . > /dev/null && error "'ls .' worked after removing cwd"
3900 ls .. > /dev/null || error "'ls ..' failed after removing cwd"
3901 is_patchless || ( cd . && error "'cd .' worked after removing cwd" )
3902 test_mkdir . && error "'mkdir .' worked after removing cwd"
3903 rmdir . && error "'rmdir .' worked after removing cwd"
3904 ln -s . foo && error "'ln -s .' worked after removing cwd"
3905 cd .. || echo "'cd ..' failed after removing cwd `pwd`" #bug 3517
3907 run_test 48b "Access removed working dir (should return errors)="
3909 test_48c() { # bug 2350
3910 #lctl set_param debug=-1
3913 test_mkdir -p $DIR/$tdir/dir
3915 $TRACE rmdir $DIR/$tdir/dir || error "remove cwd $DIR/$tdir/dir failed"
3916 $TRACE touch foo && error "touch foo worked after removing cwd"
3917 $TRACE test_mkdir foo && error "'mkdir foo' worked after removing cwd"
3918 touch .foo && error "touch .foo worked after removing cwd"
3919 test_mkdir .foo && error "mkdir .foo worked after removing cwd"
3920 $TRACE ls . && error "'ls .' worked after removing cwd"
3921 $TRACE ls .. || error "'ls ..' failed after removing cwd"
3922 is_patchless || ( $TRACE cd . &&
3923 error "'cd .' worked after removing cwd" )
3924 $TRACE test_mkdir . && error "'mkdir .' worked after removing cwd"
3925 $TRACE rmdir . && error "'rmdir .' worked after removing cwd"
3926 $TRACE ln -s . foo && error "'ln -s .' worked after removing cwd"
3927 $TRACE cd .. || echo "'cd ..' failed after removing cwd `pwd`" #bug 3415
3929 run_test 48c "Access removed working subdir (should return errors)"
3931 test_48d() { # bug 2350
3932 #lctl set_param debug=-1
3935 test_mkdir -p $DIR/$tdir/dir
3937 $TRACE rmdir $DIR/$tdir/dir || error "remove cwd $DIR/$tdir/dir failed"
3938 $TRACE rmdir $DIR/$tdir || error "remove parent $DIR/$tdir failed"
3939 $TRACE touch foo && error "'touch foo' worked after removing parent"
3940 $TRACE test_mkdir foo && error "mkdir foo worked after removing parent"
3941 touch .foo && error "'touch .foo' worked after removing parent"
3942 test_mkdir .foo && error "mkdir .foo worked after removing parent"
3943 $TRACE ls . && error "'ls .' worked after removing parent"
3944 $TRACE ls .. && error "'ls ..' worked after removing parent"
3945 is_patchless || ( $TRACE cd . &&
3946 error "'cd .' worked after recreate parent" )
3947 $TRACE test_mkdir . && error "'mkdir .' worked after removing parent"
3948 $TRACE rmdir . && error "'rmdir .' worked after removing parent"
3949 $TRACE ln -s . foo && error "'ln -s .' worked after removing parent"
3950 is_patchless || ( $TRACE cd .. &&
3951 error "'cd ..' worked after removing parent" || true )
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 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.53) ] &&
4961 skip "No HSM $(lustre_build_version $SINGLEMDS) MDS < 2.4.53" &&
4965 local dir0=$DIR/$tdir/$testnum
4966 test_mkdir -p $dir0 || error "creating dir $dir0"
4967 local f1=$dir0/file1
4968 local f2=$dir0/file2
4970 touch $f1 || error "creating std file $f1"
4971 $MULTIOP $f2 H2c || error "creating released file $f2"
4973 # a directory can be raid0, so ask only for files
4974 res=$($LFIND $dir0 -L raid0 -type f | wc -l)
4975 [[ $res == 2 ]] || error "search raid0: found $res files != 2"
4977 res=$($LFIND $dir0 \! -L raid0 -type f | wc -l)
4978 [[ $res == 0 ]] || error "search !raid0: found $res files != 0"
4980 # only files can be released, so no need to force file search
4981 res=$($LFIND $dir0 -L released)
4982 [[ $res == $f2 ]] || error "search released: found $res != $f2"
4984 res=$($LFIND $dir0 \! -L released)
4985 [[ $res == $f1 ]] || error "search !released: found $res != $f1"
4988 run_test 56y "lfs find -L raid0|released"
4990 test_56z() { # LU-4824
4991 # This checks to make sure 'lfs find' continues after errors
4992 # There are two classes of errors that should be caught:
4993 # - If multiple paths are provided, all should be searched even if one
4995 # - If errors are encountered during the search, it should not terminate
4998 test_mkdir $DIR/$tdir
4999 for i in d{0..9}; do
5000 test_mkdir $DIR/$tdir/$i
5002 touch $DIR/$tdir/d{0..9}/$tfile
5003 $LFS find $DIR/non_existent_dir $DIR/$tdir &&
5004 error "$LFS find did not return an error"
5005 # Make a directory unsearchable. This should NOT be the last entry in
5006 # directory order. Arbitrarily pick the 6th entry
5007 chmod 700 $($LFS find $DIR/$tdir -type d | sed '6!d')
5008 local count=$($RUNAS $LFS find $DIR/non_existent $DIR/$tdir | wc -l)
5009 # The user should be able to see 10 directories and 9 files
5010 [ $count == 19 ] || error "$LFS find did not continue after error"
5012 run_test 56z "lfs find should continue after an error"
5014 test_56aa() { # LU-5937
5015 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
5018 $LFS setdirstripe -c$MDSCOUNT $DIR/$tdir/striped_dir
5020 createmany -o $DIR/$tdir/striped_dir/${tfile}- 1024
5021 local dirs=$(lfs find --size +8k $DIR/$tdir/)
5023 [ -n "$dirs" ] || error "lfs find --size wrong under striped dir"
5025 run_test 56aa "lfs find --size under striped dir"
5028 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5029 # note test will not do anything if MDS is not local
5030 if [ "$(facet_fstype $SINGLEMDS)" != ldiskfs ]; then
5031 skip "Only applicable to ldiskfs-based MDTs"
5035 remote_mds_nodsh && skip "remote MDS with nodsh" && return
5036 local MNTDEV="osd*.*MDT*.mntdev"
5037 DEV=$(do_facet $SINGLEMDS lctl get_param -n $MNTDEV)
5038 [ -z "$DEV" ] && error "can't access $MNTDEV"
5039 for DEV in $(do_facet $SINGLEMDS lctl get_param -n $MNTDEV); do
5040 do_facet $SINGLEMDS $DUMPE2FS -h $DEV > $TMP/t57a.dump ||
5041 error "can't access $DEV"
5042 DEVISIZE=$(awk '/Inode size:/ { print $3 }' $TMP/t57a.dump)
5043 [[ $DEVISIZE -gt 128 ]] || error "inode size $DEVISIZE"
5047 run_test 57a "verify MDS filesystem created with large inodes =="
5050 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5051 if [ "$(facet_fstype $SINGLEMDS)" != ldiskfs ]; then
5052 skip "Only applicable to ldiskfs-based MDTs"
5056 remote_mds_nodsh && skip "remote MDS with nodsh" && return
5057 local dir=$DIR/$tdir
5061 local FILEN=$dir/f$FILECOUNT
5063 rm -rf $dir || error "removing $dir"
5064 test_mkdir -p -c1 $dir || error "creating $dir"
5065 local mdtidx=$($LFS getstripe -M $dir)
5066 local mdtname=MDT$(printf %04x $mdtidx)
5067 local facet=mds$((mdtidx + 1))
5069 echo "mcreating $FILECOUNT files"
5070 createmany -m $dir/f 1 $FILECOUNT || \
5071 error "creating files in $dir"
5073 # verify that files do not have EAs yet
5074 $GETSTRIPE $FILE1 2>&1 | grep -q "no stripe" || error "$FILE1 has an EA"
5075 $GETSTRIPE $FILEN 2>&1 | grep -q "no stripe" || error "$FILEN has an EA"
5079 df $dir #make sure we get new statfs data
5080 local MDSFREE=$(do_facet $facet \
5081 lctl get_param -n osd*.*$mdtname.kbytesfree)
5082 local MDCFREE=$(lctl get_param -n mdc.*$mdtname-mdc-*.kbytesfree)
5083 echo "opening files to create objects/EAs"
5085 for FILE in `seq -f $dir/f%g 1 $FILECOUNT`; do
5086 $OPENFILE -f O_RDWR $FILE > /dev/null 2>&1 || error "opening $FILE"
5089 # verify that files have EAs now
5090 $GETSTRIPE $FILE1 | grep -q "obdidx" || error "$FILE1 missing EA"
5091 $GETSTRIPE $FILEN | grep -q "obdidx" || error "$FILEN missing EA"
5093 sleep 1 #make sure we get new statfs data
5095 local MDSFREE2=$(do_facet $facet \
5096 lctl get_param -n osd*.*$mdtname.kbytesfree)
5097 local MDCFREE2=$(lctl get_param -n mdc.*$mdtname-mdc-*.kbytesfree)
5098 if [[ $MDCFREE2 -lt $((MDCFREE - 16)) ]]; then
5099 if [ "$MDSFREE" != "$MDSFREE2" ]; then
5100 error "MDC before $MDCFREE != after $MDCFREE2"
5102 echo "MDC before $MDCFREE != after $MDCFREE2"
5103 echo "unable to confirm if MDS has large inodes"
5108 run_test 57b "default LOV EAs are stored inside large inodes ==="
5111 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5112 [ -z "$(which wiretest 2>/dev/null)" ] &&
5113 skip_env "could not find wiretest" && return
5116 run_test 58 "verify cross-platform wire constants =============="
5119 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5120 echo "touch 130 files"
5121 createmany -o $DIR/f59- 130
5123 unlinkmany $DIR/f59- 130
5125 # wait for commitment of removal
5126 wait_delete_completed
5128 run_test 59 "verify cancellation of llog records async ========="
5130 TEST60_HEAD="test_60 run $RANDOM"
5132 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5133 remote_mgs_nodsh && skip "remote MGS with nodsh" && return
5134 do_facet mgs "! which run-llog.sh &> /dev/null" &&
5135 do_facet mgs "! ls run-llog.sh &> /dev/null" &&
5136 skip_env "missing subtest run-llog.sh" && return
5138 log "$TEST60_HEAD - from kernel mode"
5139 do_facet mgs "$LCTL set_param debug=warning; $LCTL dk > /dev/null"
5140 do_facet mgs sh run-llog.sh
5141 do_facet mgs $LCTL dk > $TMP/$tfile
5143 # LU-6388: test llog_reader
5144 local llog_reader=$(do_facet mgs "which llog_reader 2> /dev/null")
5145 llog_reader=${llog_reader:-$LUSTRE/utils/llog_reader}
5146 [ -z $(do_facet mgs ls -d $llog_reader 2> /dev/null) ] &&
5147 skip_env "missing llog_reader" && return
5148 local fstype=$(facet_fstype mgs)
5149 [ $fstype != ldiskfs -a $fstype != zfs ] &&
5150 skip_env "Only for ldiskfs or zfs type mgs" && return
5152 local mntpt=$(facet_mntpt mgs)
5153 local mgsdev=$(mgsdevname 1)
5165 #get fid and record list
5166 fid_list=($(awk '/9_sub.*record/ { print $NF }' /$TMP/$tfile |
5168 rec_list=($(awk '/9_sub.*record/ { print $((NF-3)) }' /$TMP/$tfile |
5170 #remount mgs as ldiskfs or zfs type
5171 stop mgs || error "stop mgs failed"
5172 mount_fstype mgs || error "remount mgs failed"
5173 for ((i = 0; i < ${#fid_list[@]}; i++)); do
5176 seq=$(echo $fid | awk -F ':' '{ print $1 }' | sed -e "s/^0x//g")
5177 oid=$(echo $fid | awk -F ':' '{ print $2 }' | sed -e "s/^0x//g")
5182 obj_file=$mntpt/O/$seq/d$((oid%32))/$oid ;;
5184 obj_file=$mntpt/oi.$(($((16#$seq))&127))/$fid ;;
5186 echo "obj_file is $obj_file"
5187 do_facet mgs $llog_reader $obj_file
5189 rec_type=$(do_facet mgs $llog_reader $obj_file | grep "type=" |
5190 awk '{ print $3 }' | sed -e "s/^type=//g")
5191 if [ $rec_type != $rec ]; then
5192 echo "FAILED test_60a wrong record type $rec_type," \
5198 #check obj path if record type is LLOG_LOGID_MAGIC
5199 if [ "$rec" == "1064553b" ]; then
5200 path=$(do_facet mgs $llog_reader $obj_file |
5201 grep "path=" | awk '{ print $NF }' |
5202 sed -e "s/^path=//g")
5203 if [ $obj_file != $mntpt/$path ]; then
5204 echo "FAILED test_60a wrong obj path" \
5205 "$montpt/$path, should be $obj_file"
5212 #restart mgs before "error", otherwise it will block the next test
5213 stop mgs || error "stop mgs failed"
5214 start mgs $(mgsdevname) $MGS_MOUNT_OPTS || error "start mgs failed"
5215 $pass || error "test failed, see FAILED test_60a messages for specifics"
5217 run_test 60a "llog_test run from kernel module and test llog_reader =========="
5219 test_60b() { # bug 6411
5220 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5222 LLOG_COUNT=`dmesg | awk "/$TEST60_HEAD/{marker = 1; from_marker = 0;}
5234 [[ $LLOG_COUNT -gt 50 ]] &&
5235 error "CDEBUG_LIMIT not limiting messages ($LLOG_COUNT)" || true
5237 run_test 60b "limit repeated messages from CERROR/CWARN ========"
5240 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5241 echo "create 5000 files"
5242 createmany -o $DIR/f60c- 5000
5243 #define OBD_FAIL_MDS_LLOG_CREATE_FAILED 0x137
5244 lctl set_param fail_loc=0x80000137
5245 unlinkmany $DIR/f60c- 5000
5246 lctl set_param fail_loc=0
5248 run_test 60c "unlink file when mds full"
5251 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5252 SAVEPRINTK=$(lctl get_param -n printk)
5254 # verify "lctl mark" is even working"
5255 MESSAGE="test message ID $RANDOM $$"
5256 $LCTL mark "$MESSAGE" || error "$LCTL mark failed"
5257 dmesg | grep -q "$MESSAGE" || error "didn't find debug marker in log"
5259 lctl set_param printk=0 || error "set lnet.printk failed"
5260 lctl get_param -n printk | grep emerg || error "lnet.printk dropped emerg"
5261 MESSAGE="new test message ID $RANDOM $$"
5262 # Assume here that libcfs_debug_mark_buffer() uses D_WARNING
5263 $LCTL mark "$MESSAGE" || error "$LCTL mark failed"
5264 dmesg | grep -q "$MESSAGE" && error "D_WARNING wasn't masked" || true
5266 lctl set_param -n printk="$SAVEPRINTK"
5268 run_test 60d "test printk console message masking"
5271 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5273 #define OBD_FAIL_MDS_LLOG_CREATE_FAILED2 0x15b
5274 do_facet mds1 lctl set_param fail_loc=0x15b
5277 run_test 60e "no space while new llog is being created"
5280 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5282 dd if=/dev/zero of=$f bs=$(page_size) count=1 || error "dd $f failed"
5283 cancel_lru_locks osc
5284 $MULTIOP $f OSMWUc || error "$MULTIOP $f failed"
5287 run_test 61 "mmap() writes don't make sync hang ================"
5289 # bug 2330 - insufficient obd_match error checking causes LBUG
5291 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5294 cancel_lru_locks osc
5295 lctl set_param fail_loc=0x405
5296 cat $f && error "cat succeeded, expect -EIO"
5297 lctl set_param fail_loc=0
5299 # This test is now irrelevant (as of bug 10718 inclusion), we no longer
5300 # match every page all of the time.
5301 #run_test 62 "verify obd_match failure doesn't LBUG (should -EIO)"
5303 # bug 2319 - oig_wait() interrupted causes crash because of invalid waitq.
5304 # Though this test is irrelevant anymore, it helped to reveal some
5305 # other grant bugs (LU-4482), let's keep it.
5306 test_63a() { # was test_63
5307 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5308 MAX_DIRTY_MB=`lctl get_param -n osc.*.max_dirty_mb | head -n 1`
5309 for i in `seq 10` ; do
5310 dd if=/dev/zero of=$DIR/f63 bs=8k &
5316 rm -f $DIR/f63 || true
5318 run_test 63a "Verify oig_wait interruption does not crash ======="
5320 # bug 2248 - async write errors didn't return to application on sync
5321 # bug 3677 - async write errors left page locked
5323 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5325 lctl set_param debug=-1
5327 # ensure we have a grant to do async writes
5328 dd if=/dev/zero of=$DIR/$tfile bs=4k count=1
5331 sync # sync lest earlier test intercept the fail_loc
5333 #define OBD_FAIL_OSC_BRW_PREP_REQ 0x406
5334 lctl set_param fail_loc=0x80000406
5335 $MULTIOP $DIR/$tfile Owy && \
5336 error "sync didn't return ENOMEM"
5337 sync; sleep 2; sync # do a real sync this time to flush page
5338 lctl get_param -n llite.*.dump_page_cache | grep locked && \
5339 error "locked page left in cache after async error" || true
5342 run_test 63b "async write errors should be returned to fsync ==="
5345 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5347 lctl get_param -n osc.*[oO][sS][cC][_-]*.cur* | grep "[0-9]"
5349 run_test 64a "verify filter grant calculations (in kernel) ====="
5352 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5353 sh oos.sh $MOUNT || error "oos.sh failed: $?"
5355 run_test 64b "check out-of-space detection on client ==========="
5358 $LCTL set_param osc.*OST0000-osc-[^mM]*.cur_grant_bytes=0
5360 run_test 64c "verify grant shrink ========================------"
5362 # bug 1414 - set/get directories' stripe info
5364 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5365 test_mkdir -p $DIR/$tdir
5367 $LVERIFY $DIR/$tdir $DIR/$tdir/f1 || error "lverify failed"
5369 run_test 65a "directory with no stripe info ===================="
5372 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5373 test_mkdir -p $DIR/$tdir
5374 local STRIPESIZE=$($GETSTRIPE -S $DIR/$tdir)
5376 $SETSTRIPE -S $((STRIPESIZE * 2)) -i 0 -c 1 $DIR/$tdir ||
5379 $LVERIFY $DIR/$tdir $DIR/$tdir/f2 || error "lverify failed"
5381 run_test 65b "directory setstripe -S stripe_size*2 -i 0 -c 1"
5384 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5385 if [[ $OSTCOUNT -gt 1 ]]; then
5386 test_mkdir -p $DIR/$tdir
5387 local STRIPESIZE=$($GETSTRIPE -S $DIR/$tdir)
5389 $SETSTRIPE -S $(($STRIPESIZE * 4)) -i 1 \
5390 -c $(($OSTCOUNT - 1)) $DIR/$tdir || error "setstripe"
5392 $LVERIFY $DIR/$tdir $DIR/$tdir/f3 || error "lverify failed"
5395 run_test 65c "directory setstripe -S stripe_size*4 -i 1 -c $((OSTCOUNT-1))"
5398 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5399 test_mkdir -p $DIR/$tdir
5400 local STRIPECOUNT=$($GETSTRIPE -c $DIR/$tdir)
5401 local STRIPESIZE=$($GETSTRIPE -S $DIR/$tdir)
5403 if [[ $STRIPECOUNT -le 0 ]]; then
5405 elif [[ $STRIPECOUNT -gt 2000 ]]; then
5406 #LOV_MAX_STRIPE_COUNT is 2000
5407 [[ $OSTCOUNT -gt 2000 ]] && sc=2000 || sc=$(($OSTCOUNT - 1))
5409 sc=$(($STRIPECOUNT - 1))
5411 $SETSTRIPE -S $STRIPESIZE -c $sc $DIR/$tdir || error "setstripe"
5412 touch $DIR/$tdir/f4 $DIR/$tdir/f5
5413 $LVERIFY $DIR/$tdir $DIR/$tdir/f4 $DIR/$tdir/f5 ||
5414 error "lverify failed"
5416 run_test 65d "directory setstripe -S stripe_size -c stripe_count"
5419 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5420 test_mkdir -p $DIR/$tdir
5422 $SETSTRIPE $DIR/$tdir || error "setstripe"
5423 $GETSTRIPE -v $DIR/$tdir | grep "Default" ||
5424 error "no stripe info failed"
5426 $LVERIFY $DIR/$tdir $DIR/$tdir/f6 || error "lverify failed"
5428 run_test 65e "directory setstripe defaults ======================="
5431 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5432 test_mkdir -p $DIR/${tdir}f
5433 $RUNAS $SETSTRIPE $DIR/${tdir}f && error "setstripe succeeded" || true
5435 run_test 65f "dir setstripe permission (should return error) ==="
5438 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5439 test_mkdir -p $DIR/$tdir
5440 local STRIPESIZE=$($GETSTRIPE -S $DIR/$tdir)
5442 $SETSTRIPE -S $((STRIPESIZE * 2)) -i 0 -c 1 $DIR/$tdir ||
5444 $SETSTRIPE -d $DIR/$tdir || error "setstripe"
5445 $GETSTRIPE -v $DIR/$tdir | grep "Default" ||
5446 error "delete default stripe failed"
5448 run_test 65g "directory setstripe -d ==========================="
5451 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5452 test_mkdir -p $DIR/$tdir
5453 local STRIPESIZE=$($GETSTRIPE -S $DIR/$tdir)
5455 $SETSTRIPE -S $((STRIPESIZE * 2)) -i 0 -c 1 $DIR/$tdir ||
5457 test_mkdir -p $DIR/$tdir/dd1
5458 [ $($GETSTRIPE -c $DIR/$tdir) == $($GETSTRIPE -c $DIR/$tdir/dd1) ] ||
5459 error "stripe info inherit failed"
5461 run_test 65h "directory stripe info inherit ===================="
5463 test_65i() { # bug6367
5464 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5465 $SETSTRIPE -S 65536 -c -1 $MOUNT
5467 run_test 65i "set non-default striping on root directory (bug 6367)="
5469 test_65ia() { # bug12836
5470 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5471 $GETSTRIPE $MOUNT || error "getstripe $MOUNT failed"
5473 run_test 65ia "getstripe on -1 default directory striping"
5475 test_65ib() { # bug12836
5476 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5477 $GETSTRIPE -v $MOUNT || error "getstripe -v $MOUNT failed"
5479 run_test 65ib "getstripe -v on -1 default directory striping"
5481 test_65ic() { # bug12836
5482 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5483 $LFS find -mtime -1 $MOUNT > /dev/null || error "find $MOUNT failed"
5485 run_test 65ic "new find on -1 default directory striping"
5487 test_65j() { # bug6367
5488 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5490 # if we aren't already remounting for each test, do so for this test
5491 if [ "$CLEANUP" = ":" -a "$I_MOUNTED" = "yes" ]; then
5492 cleanup || error "failed to unmount"
5495 $SETSTRIPE -d $MOUNT || error "setstripe failed"
5497 run_test 65j "set default striping on root directory (bug 6367)="
5499 test_65k() { # bug11679
5500 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5501 [[ $OSTCOUNT -lt 2 ]] && skip_env "too few OSTs" && return
5502 remote_mds_nodsh && skip "remote MDS with nodsh" && return
5504 echo "Check OST status: "
5505 local MDS_OSCS=`do_facet $SINGLEMDS lctl dl |
5506 awk '/[oO][sS][cC].*md[ts]/ { print $4 }'`
5508 for OSC in $MDS_OSCS; do
5509 echo $OSC "is activate"
5510 do_facet $SINGLEMDS lctl --device %$OSC activate
5514 for INACTIVE_OSC in $MDS_OSCS; do
5515 echo "Deactivate: " $INACTIVE_OSC
5516 do_facet $SINGLEMDS lctl --device %$INACTIVE_OSC deactivate
5517 for STRIPE_OSC in $MDS_OSCS; do
5518 OST=`osc_to_ost $STRIPE_OSC`
5519 IDX=`do_facet $SINGLEMDS lctl get_param -n lov.*md*.target_obd |
5520 awk -F: /$OST/'{ print $1 }' | head -n 1`
5522 [ -f $DIR/$tdir/$IDX ] && continue
5523 echo "$SETSTRIPE -i $IDX -c 1 $DIR/$tdir/$IDX"
5524 $SETSTRIPE -i $IDX -c 1 $DIR/$tdir/$IDX
5526 [ $RC -ne 0 ] && error "setstripe should have succeeded"
5529 echo $INACTIVE_OSC "is Activate."
5530 do_facet $SINGLEMDS lctl --device %$INACTIVE_OSC activate
5533 run_test 65k "validate manual striping works properly with deactivated OSCs"
5535 test_65l() { # bug 12836
5536 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5537 test_mkdir -p $DIR/$tdir/test_dir
5538 $SETSTRIPE -c -1 $DIR/$tdir/test_dir
5539 $LFS find -mtime -1 $DIR/$tdir >/dev/null
5541 run_test 65l "lfs find on -1 stripe dir ========================"
5543 # bug 2543 - update blocks count on client
5545 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5547 dd if=/dev/zero of=$DIR/f66 bs=1k count=$COUNT
5548 sync; sync_all_data; sync; sync_all_data
5549 cancel_lru_locks osc
5550 BLOCKS=`ls -s $DIR/f66 | awk '{ print $1 }'`
5551 [ $BLOCKS -ge $COUNT ] || error "$DIR/f66 blocks $BLOCKS < $COUNT"
5553 run_test 66 "update inode blocks count on client ==============="
5558 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5560 if [ ! -z "$LLOOP" ]; then
5561 if swapon -s | grep -q $LLOOP; then
5562 swapoff $LLOOP || error "swapoff failed"
5565 $LCTL blockdev_detach $LLOOP || error "detach failed"
5569 if [ ! -z "$LLITELOOPLOAD" ]; then
5577 awk '($1 == "'$1':") { print $2 }' /proc/meminfo
5581 swapon -s | awk '($1 == "'$1'") { print $4 }'
5584 # test case for lloop driver, basic function
5586 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5587 [ "$UID" != 0 ] && skip_env "must run as root" && return
5588 llite_lloop_enabled || \
5589 { skip_env "llite_lloop module disabled" && return; }
5591 trap cleanup_68 EXIT
5593 if ! module_loaded llite_lloop; then
5594 if load_module llite/llite_lloop; then
5597 skip_env "can't find module llite_lloop"
5602 LLOOP=$TMP/lloop.`date +%s`.`date +%N`
5603 dd if=/dev/zero of=$DIR/f68a bs=4k count=1024
5604 $LCTL blockdev_attach $DIR/f68a $LLOOP || error "attach failed"
5606 directio rdwr $LLOOP 0 1024 4096 || error "direct write failed"
5607 directio rdwr $LLOOP 0 1025 4096 && error "direct write should fail"
5611 run_test 68a "lloop driver - basic test ========================"
5613 # excercise swapping to lustre by adding a high priority swapfile entry
5614 # and then consuming memory until it is used.
5615 test_68b() { # was test_68
5616 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5617 [ "$UID" != 0 ] && skip_env "must run as root" && return
5618 lctl get_param -n devices | grep -q obdfilter && \
5619 skip "local OST" && return
5621 grep -q llite_lloop /proc/modules
5622 [ $? -ne 0 ] && skip "can't find module llite_lloop" && return
5624 [ -z "`$LCTL list_nids | grep -v tcp`" ] && \
5625 skip "can't reliably test swap with TCP" && return
5627 MEMTOTAL=`meminfo MemTotal`
5628 NR_BLOCKS=$((MEMTOTAL>>8))
5629 [[ $NR_BLOCKS -le 2048 ]] && NR_BLOCKS=2048
5631 LLOOP=$TMP/lloop.`date +%s`.`date +%N`
5632 dd if=/dev/zero of=$DIR/f68b bs=64k seek=$NR_BLOCKS count=1
5635 $LCTL blockdev_attach $DIR/f68b $LLOOP || error "attach failed"
5637 trap cleanup_68 EXIT
5639 swapon -p 32767 $LLOOP || error "swapon $LLOOP failed"
5641 echo "before: `swapon -s | grep $LLOOP`"
5642 $MEMHOG $MEMTOTAL || error "error allocating $MEMTOTAL kB"
5643 echo "after: `swapon -s | grep $LLOOP`"
5644 SWAPUSED=`swap_used $LLOOP`
5648 [ $SWAPUSED -eq 0 ] && echo "no swap used???" || true
5650 run_test 68b "support swapping to Lustre ========================"
5652 # bug5265, obdfilter oa2dentry return -ENOENT
5653 # #define OBD_FAIL_SRV_ENOENT 0x217
5655 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5656 remote_ost_nodsh && skip "remote OST with nodsh" && return
5659 $SETSTRIPE -c 1 -i 0 $f
5661 $DIRECTIO write ${f}.2 0 1 || error "directio write error"
5663 do_facet ost1 lctl set_param fail_loc=0x217
5664 $TRUNCATE $f 1 # vmtruncate() will ignore truncate() error.
5665 $DIRECTIO write $f 0 2 && error "write succeeded, expect -ENOENT"
5667 do_facet ost1 lctl set_param fail_loc=0
5668 $DIRECTIO write $f 0 2 || error "write error"
5670 cancel_lru_locks osc
5671 $DIRECTIO read $f 0 1 || error "read error"
5673 do_facet ost1 lctl set_param fail_loc=0x217
5674 $DIRECTIO read $f 1 1 && error "read succeeded, expect -ENOENT"
5676 do_facet ost1 lctl set_param fail_loc=0
5679 run_test 69 "verify oa2dentry return -ENOENT doesn't LBUG ======"
5682 test_mkdir -p $DIR/$tdir
5683 $LFS setdirstripe -D -c$MDSCOUNT $DIR/$tdir
5684 sh rundbench -C -D $DIR/$tdir 2 || error "dbench failed!"
5686 run_test 71 "Running dbench on lustre (don't segment fault) ===="
5688 test_72a() { # bug 5695 - Test that on 2.6 remove_suid works properly
5689 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5690 [ "$RUNAS_ID" = "$UID" ] &&
5691 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
5693 # Check that testing environment is properly set up. Skip if not
5694 FAIL_ON_ERROR=false check_runas_id_ret $RUNAS_ID $RUNAS_GID $RUNAS || {
5695 skip_env "User $RUNAS_ID does not exist - skipping"
5699 chmod 777 $DIR/$tfile
5700 chmod ug+s $DIR/$tfile
5701 $RUNAS dd if=/dev/zero of=$DIR/$tfile bs=512 count=1 ||
5702 error "$RUNAS dd $DIR/$tfile failed"
5703 # See if we are still setuid/sgid
5704 test -u $DIR/$tfile -o -g $DIR/$tfile &&
5705 error "S/gid is not dropped on write"
5706 # Now test that MDS is updated too
5707 cancel_lru_locks mdc
5708 test -u $DIR/$tfile -o -g $DIR/$tfile &&
5709 error "S/gid is not dropped on MDS"
5712 run_test 72a "Test that remove suid works properly (bug5695) ===="
5714 test_72b() { # bug 24226 -- keep mode setting when size is not changing
5717 [ "$RUNAS_ID" = "$UID" ] && \
5718 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
5719 [ "$RUNAS_ID" -eq 0 ] && \
5720 skip_env "RUNAS_ID = 0 -- skipping" && return
5722 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5723 # Check that testing environment is properly set up. Skip if not
5724 FAIL_ON_ERROR=false check_runas_id_ret $RUNAS_ID $RUNAS_ID $RUNAS || {
5725 skip_env "User $RUNAS_ID does not exist - skipping"
5728 touch $DIR/${tfile}-f{g,u}
5729 test_mkdir $DIR/${tfile}-dg
5730 test_mkdir $DIR/${tfile}-du
5731 chmod 770 $DIR/${tfile}-{f,d}{g,u}
5732 chmod g+s $DIR/${tfile}-{f,d}g
5733 chmod u+s $DIR/${tfile}-{f,d}u
5734 for perm in 777 2777 4777; do
5735 $RUNAS chmod $perm $DIR/${tfile}-fg && error "S/gid file allowed improper chmod to $perm"
5736 $RUNAS chmod $perm $DIR/${tfile}-fu && error "S/uid file allowed improper chmod to $perm"
5737 $RUNAS chmod $perm $DIR/${tfile}-dg && error "S/gid dir allowed improper chmod to $perm"
5738 $RUNAS chmod $perm $DIR/${tfile}-du && error "S/uid dir allowed improper chmod to $perm"
5742 run_test 72b "Test that we keep mode setting if without file data changed (bug 24226)"
5744 # bug 3462 - multiple simultaneous MDC requests
5746 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5747 test_mkdir $DIR/d73-1
5748 test_mkdir $DIR/d73-2
5749 multiop_bg_pause $DIR/d73-1/f73-1 O_c || return 1
5752 lctl set_param fail_loc=0x80000129
5753 $MULTIOP $DIR/d73-1/f73-2 Oc &
5755 lctl set_param fail_loc=0
5757 $MULTIOP $DIR/d73-2/f73-3 Oc &
5761 wait $pid1 || return 1
5765 $CHECKSTAT -t file $DIR/d73-1/f73-1 || return 4
5766 $CHECKSTAT -t file $DIR/d73-1/f73-2 || return 5
5767 $CHECKSTAT -t file $DIR/d73-2/f73-3 || return 6
5771 run_test 73 "multiple MDC requests (should not deadlock)"
5773 test_74a() { # bug 6149, 6184
5774 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5775 #define OBD_FAIL_LDLM_ENQUEUE_OLD_EXPORT 0x30e
5777 # very important to OR with OBD_FAIL_ONCE (0x80000000) -- otherwise it
5778 # will spin in a tight reconnection loop
5780 $LCTL set_param fail_loc=0x8000030e
5781 # get any lock that won't be difficult - lookup works.
5783 $LCTL set_param fail_loc=0
5787 run_test 74a "ldlm_enqueue freed-export error path, ls (shouldn't LBUG)"
5789 test_74b() { # bug 13310
5790 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5791 #define OBD_FAIL_LDLM_ENQUEUE_OLD_EXPORT 0x30e
5793 # very important to OR with OBD_FAIL_ONCE (0x80000000) -- otherwise it
5794 # will spin in a tight reconnection loop
5795 $LCTL set_param fail_loc=0x8000030e
5796 # get a "difficult" lock
5798 $LCTL set_param fail_loc=0
5802 run_test 74b "ldlm_enqueue freed-export error path, touch (shouldn't LBUG)"
5805 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5806 #define OBD_FAIL_LDLM_NEW_LOCK
5807 $LCTL set_param fail_loc=0x319
5808 touch $DIR/$tfile && error "touch successful"
5809 $LCTL set_param fail_loc=0
5812 run_test 74c "ldlm_lock_create error path, (shouldn't LBUG)"
5815 awk '/lustre_inode_cache/ {print $2; exit}' /proc/slabinfo
5818 get_inode_slab_tunables() {
5819 awk '/lustre_inode_cache/ {print $9," ",$10," ",$11; exit}' /proc/slabinfo
5822 set_inode_slab_tunables() {
5823 echo "lustre_inode_cache $1" > /proc/slabinfo
5826 test_76() { # Now for bug 20433, added originally in bug 1443
5827 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5828 local SLAB_SETTINGS=`get_inode_slab_tunables`
5829 local CPUS=`getconf _NPROCESSORS_ONLN`
5830 # we cannot set limit below 1 which means 1 inode in each
5831 # per-cpu cache is still allowed
5832 set_inode_slab_tunables "1 1 0"
5833 cancel_lru_locks osc
5834 BEFORE_INODES=$(num_inodes)
5835 echo "before inodes: $BEFORE_INODES"
5837 [ "$SLOW" = "no" ] && COUNT=100
5838 for i in $(seq $COUNT); do
5842 cancel_lru_locks osc
5843 AFTER_INODES=$(num_inodes)
5844 echo "after inodes: $AFTER_INODES"
5846 while [[ $((AFTER_INODES-1*CPUS)) -gt $BEFORE_INODES ]]; do
5848 AFTER_INODES=$(num_inodes)
5850 echo "wait $wait seconds inodes: $AFTER_INODES"
5851 if [ $wait -gt 30 ]; then
5852 error "inode slab grew from $BEFORE_INODES to $AFTER_INODES"
5855 set_inode_slab_tunables "$SLAB_SETTINGS"
5857 run_test 76 "confirm clients recycle inodes properly ===="
5863 # Note: in sptlrpc modes which enable its own bulk checksum, the
5864 # original crc32_le bulk checksum will be automatically disabled,
5865 # and the OBD_FAIL_OSC_CHECKSUM_SEND/OBD_FAIL_OSC_CHECKSUM_RECEIVE
5866 # will be checked by sptlrpc code against sptlrpc bulk checksum.
5867 # In this case set_checksums() will not be no-op, because sptlrpc
5868 # bulk checksum will be enabled all through the test.
5870 [ "$ORIG_CSUM" ] || ORIG_CSUM=`lctl get_param -n osc.*.checksums | head -n1`
5871 lctl set_param -n osc.*.checksums $1
5875 export ORIG_CSUM_TYPE="`lctl get_param -n osc.*osc-[^mM]*.checksum_type |
5876 sed 's/.*\[\(.*\)\].*/\1/g' | head -n1`"
5877 CKSUM_TYPES=${CKSUM_TYPES:-"crc32 adler"}
5878 [ "$ORIG_CSUM_TYPE" = "crc32c" ] && CKSUM_TYPES="$CKSUM_TYPES crc32c"
5881 lctl set_param -n osc.*osc-[^mM]*.checksum_type $1
5882 log "set checksum type to $1"
5885 F77_TMP=$TMP/f77-temp
5888 dd if=/dev/urandom of=$F77_TMP bs=1M count=$F77SZ || \
5889 error "error writing to $F77_TMP"
5892 test_77a() { # bug 10889
5893 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5894 $GSS && skip "could not run with gss" && return
5895 [ ! -f $F77_TMP ] && setup_f77
5897 dd if=$F77_TMP of=$DIR/$tfile bs=1M count=$F77SZ || error "dd error"
5901 run_test 77a "normal checksum read/write operation"
5903 test_77b() { # bug 10889
5904 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5905 $GSS && skip "could not run with gss" && return
5906 [ ! -f $F77_TMP ] && setup_f77
5907 #define OBD_FAIL_OSC_CHECKSUM_SEND 0x409
5908 $LCTL set_param fail_loc=0x80000409
5911 dd if=$F77_TMP of=$DIR/$tfile bs=1M count=$F77SZ conv=sync ||
5912 error "dd error: $?"
5913 $LCTL set_param fail_loc=0
5915 for algo in $CKSUM_TYPES; do
5916 cancel_lru_locks osc
5917 set_checksum_type $algo
5918 #define OBD_FAIL_OSC_CHECKSUM_RECEIVE 0x408
5919 $LCTL set_param fail_loc=0x80000408
5920 cmp $F77_TMP $DIR/$tfile || error "file compare failed"
5921 $LCTL set_param fail_loc=0
5924 set_checksum_type $ORIG_CSUM_TYPE
5927 run_test 77b "checksum error on client write, read"
5929 test_77d() { # bug 10889
5930 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5931 $GSS && skip "could not run with gss" && return
5932 #define OBD_FAIL_OSC_CHECKSUM_SEND 0x409
5933 $LCTL set_param fail_loc=0x80000409
5935 $DIRECTIO write $DIR/$tfile 0 $F77SZ $((1024 * 1024)) ||
5936 error "direct write: rc=$?"
5937 $LCTL set_param fail_loc=0
5940 #define OBD_FAIL_OSC_CHECKSUM_RECEIVE 0x408
5941 $LCTL set_param fail_loc=0x80000408
5943 cancel_lru_locks osc
5944 $DIRECTIO read $DIR/$tfile 0 $F77SZ $((1024 * 1024)) ||
5945 error "direct read: rc=$?"
5946 $LCTL set_param fail_loc=0
5949 run_test 77d "checksum error on OST direct write, read"
5951 test_77f() { # bug 10889
5952 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5953 $GSS && skip "could not run with gss" && return
5955 for algo in $CKSUM_TYPES; do
5956 cancel_lru_locks osc
5957 set_checksum_type $algo
5958 #define OBD_FAIL_OSC_CHECKSUM_SEND 0x409
5959 $LCTL set_param fail_loc=0x409
5960 $DIRECTIO write $DIR/$tfile 0 $F77SZ $((1024 * 1024)) &&
5961 error "direct write succeeded"
5962 $LCTL set_param fail_loc=0
5964 set_checksum_type $ORIG_CSUM_TYPE
5967 run_test 77f "repeat checksum error on write (expect error)"
5969 test_77g() { # bug 10889
5970 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5971 $GSS && skip "could not run with gss" && return
5972 remote_ost_nodsh && skip "remote OST with nodsh" && return
5974 [ ! -f $F77_TMP ] && setup_f77
5976 $SETSTRIPE -c 1 -i 0 $DIR/$tfile
5977 #define OBD_FAIL_OST_CHECKSUM_RECEIVE 0x21a
5978 do_facet ost1 lctl set_param fail_loc=0x8000021a
5980 dd if=$F77_TMP of=$DIR/$tfile bs=1M count=$F77SZ ||
5981 error "write error: rc=$?"
5982 do_facet ost1 lctl set_param fail_loc=0
5985 cancel_lru_locks osc
5986 #define OBD_FAIL_OST_CHECKSUM_SEND 0x21b
5987 do_facet ost1 lctl set_param fail_loc=0x8000021b
5989 cmp $F77_TMP $DIR/$tfile || error "file compare failed"
5990 do_facet ost1 lctl set_param fail_loc=0
5993 run_test 77g "checksum error on OST write, read"
5995 test_77i() { # bug 13805
5996 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5997 $GSS && skip "could not run with gss" && return
5998 #define OBD_FAIL_OSC_CONNECT_CKSUM 0x40b
5999 lctl set_param fail_loc=0x40b
6000 remount_client $MOUNT
6001 lctl set_param fail_loc=0
6002 for VALUE in `lctl get_param osc.*osc-[^mM]*.checksum_type`; do
6003 PARAM=`echo ${VALUE[0]} | cut -d "=" -f1`
6004 algo=`lctl get_param -n $PARAM | sed 's/.*\[\(.*\)\].*/\1/g'`
6005 [ "$algo" = "adler" ] || error "algo set to $algo instead of adler"
6007 remount_client $MOUNT
6009 run_test 77i "client not supporting OSD_CONNECT_CKSUM"
6011 test_77j() { # bug 13805
6012 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6013 $GSS && skip "could not run with gss" && return
6014 #define OBD_FAIL_OSC_CKSUM_ADLER_ONLY 0x40c
6015 lctl set_param fail_loc=0x40c
6016 remount_client $MOUNT
6017 lctl set_param fail_loc=0
6018 sleep 2 # wait async osc connect to finish
6019 for VALUE in `lctl get_param osc.*osc-[^mM]*.checksum_type`; do
6020 PARAM=`echo ${VALUE[0]} | cut -d "=" -f1`
6021 algo=`lctl get_param -n $PARAM | sed 's/.*\[\(.*\)\].*/\1/g'`
6022 [ "$algo" = "adler" ] || error "algo set to $algo instead of adler"
6024 remount_client $MOUNT
6026 run_test 77j "client only supporting ADLER32"
6028 [ "$ORIG_CSUM" ] && set_checksums $ORIG_CSUM || true
6032 test_78() { # bug 10901
6033 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6034 remote_ost || { skip_env "local OST" && return; }
6037 F78SIZE=$(($(awk '/MemFree:/ { print $2 }' /proc/meminfo) / 1024))
6038 echo "MemFree: $F78SIZE, Max file size: $MAXFREE"
6039 MEMTOTAL=$(($(awk '/MemTotal:/ { print $2 }' /proc/meminfo) / 1024))
6040 echo "MemTotal: $MEMTOTAL"
6042 # reserve 256MB of memory for the kernel and other running processes,
6043 # and then take 1/2 of the remaining memory for the read/write buffers.
6044 if [ $MEMTOTAL -gt 512 ] ;then
6045 MEMTOTAL=$(((MEMTOTAL - 256 ) / 2))
6047 # for those poor memory-starved high-end clusters...
6048 MEMTOTAL=$((MEMTOTAL / 2))
6050 echo "Mem to use for directio: $MEMTOTAL"
6052 [[ $F78SIZE -gt $MEMTOTAL ]] && F78SIZE=$MEMTOTAL
6053 [[ $F78SIZE -gt 512 ]] && F78SIZE=512
6054 [[ $F78SIZE -gt $((MAXFREE / 1024)) ]] && F78SIZE=$((MAXFREE / 1024))
6055 SMALLESTOST=$($LFS df $DIR | grep OST | awk '{ print $4 }' | sort -n |
6057 echo "Smallest OST: $SMALLESTOST"
6058 [[ $SMALLESTOST -lt 10240 ]] &&
6059 skip "too small OSTSIZE, useless to run large O_DIRECT test" && return 0
6061 [[ $F78SIZE -gt $((SMALLESTOST * $OSTCOUNT / 1024 - 80)) ]] &&
6062 F78SIZE=$((SMALLESTOST * $OSTCOUNT / 1024 - 80))
6064 [ "$SLOW" = "no" ] && NSEQ=1 && [ $F78SIZE -gt 32 ] && F78SIZE=32
6065 echo "File size: $F78SIZE"
6066 $SETSTRIPE -c $OSTCOUNT $DIR/$tfile || error "setstripe failed"
6067 for i in $(seq 1 $NSEQ); do
6068 FSIZE=$(($F78SIZE / ($NSEQ - $i + 1)))
6069 echo directIO rdwr round $i of $NSEQ
6070 $DIRECTIO rdwr $DIR/$tfile 0 $FSIZE 1048576||error "rdwr failed"
6075 run_test 78 "handle large O_DIRECT writes correctly ============"
6077 test_79() { # bug 12743
6078 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6079 wait_delete_completed
6081 BKTOTAL=$(calc_osc_kbytes kbytestotal)
6082 BKFREE=$(calc_osc_kbytes kbytesfree)
6083 BKAVAIL=$(calc_osc_kbytes kbytesavail)
6085 STRING=`df -P $MOUNT | tail -n 1 | awk '{print $2","$3","$4}'`
6086 DFTOTAL=`echo $STRING | cut -d, -f1`
6087 DFUSED=`echo $STRING | cut -d, -f2`
6088 DFAVAIL=`echo $STRING | cut -d, -f3`
6089 DFFREE=$(($DFTOTAL - $DFUSED))
6091 ALLOWANCE=$((64 * $OSTCOUNT))
6093 if [ $DFTOTAL -lt $(($BKTOTAL - $ALLOWANCE)) ] ||
6094 [ $DFTOTAL -gt $(($BKTOTAL + $ALLOWANCE)) ] ; then
6095 error "df total($DFTOTAL) mismatch OST total($BKTOTAL)"
6097 if [ $DFFREE -lt $(($BKFREE - $ALLOWANCE)) ] ||
6098 [ $DFFREE -gt $(($BKFREE + $ALLOWANCE)) ] ; then
6099 error "df free($DFFREE) mismatch OST free($BKFREE)"
6101 if [ $DFAVAIL -lt $(($BKAVAIL - $ALLOWANCE)) ] ||
6102 [ $DFAVAIL -gt $(($BKAVAIL + $ALLOWANCE)) ] ; then
6103 error "df avail($DFAVAIL) mismatch OST avail($BKAVAIL)"
6106 run_test 79 "df report consistency check ======================="
6108 test_80() { # bug 10718
6109 remote_ost_nodsh && skip "remote OST with nodsh" && return
6110 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6111 # relax strong synchronous semantics for slow backends like ZFS
6112 local soc="obdfilter.*.sync_on_lock_cancel"
6113 local soc_old=$(do_facet ost1 lctl get_param -n $soc | head -n1)
6115 if [ "$soc_old" != "never" -a "$(facet_fstype ost1)" != "ldiskfs" ]; then
6116 hosts=$(for host in $(seq -f "ost%g" 1 $OSTCOUNT); do
6117 facet_active_host $host; done | sort -u)
6118 do_nodes $hosts lctl set_param $soc=never
6121 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=1M
6123 local BEFORE=`date +%s`
6124 cancel_lru_locks osc
6125 local AFTER=`date +%s`
6126 local DIFF=$((AFTER-BEFORE))
6127 if [ $DIFF -gt 1 ] ; then
6128 error "elapsed for 1M@1T = $DIFF"
6131 [ -n "$hosts" ] && do_nodes $hosts lctl set_param $soc=$soc_old
6135 run_test 80 "Page eviction is equally fast at high offsets too ===="
6137 test_81a() { # LU-456
6138 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6139 remote_ost_nodsh && skip "remote OST with nodsh" && return
6140 # define OBD_FAIL_OST_MAPBLK_ENOSPC 0x228
6141 # MUST OR with the OBD_FAIL_ONCE (0x80000000)
6142 do_facet ost1 lctl set_param fail_loc=0x80000228
6144 # write should trigger a retry and success
6145 $SETSTRIPE -i 0 -c 1 $DIR/$tfile
6146 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
6148 if [ $RC -ne 0 ] ; then
6149 error "write should success, but failed for $RC"
6152 run_test 81a "OST should retry write when get -ENOSPC ==============="
6154 test_81b() { # LU-456
6155 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6156 remote_ost_nodsh && skip "remote OST with nodsh" && return
6157 # define OBD_FAIL_OST_MAPBLK_ENOSPC 0x228
6158 # Don't OR with the OBD_FAIL_ONCE (0x80000000)
6159 do_facet ost1 lctl set_param fail_loc=0x228
6161 # write should retry several times and return -ENOSPC finally
6162 $SETSTRIPE -i 0 -c 1 $DIR/$tfile
6163 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
6166 if [ $RC -ne $ENOSPC ] ; then
6167 error "dd should fail for -ENOSPC, but succeed."
6170 run_test 81b "OST should return -ENOSPC when retry still fails ======="
6172 test_82() { # LU-1031
6173 dd if=/dev/zero of=$DIR/$tfile bs=1M count=10
6177 multiop_bg_pause $DIR/$tfile OG${gid1}_g${gid1}c || return 1
6179 multiop_bg_pause $DIR/$tfile O_G${gid2}r10g${gid2}c || return 2
6181 kill -USR1 $MULTIPID2
6183 if [[ `ps h -o comm -p $MULTIPID2` == "" ]]; then
6184 error "First grouplock does not block second one"
6186 echo "Second grouplock blocks first one"
6188 kill -USR1 $MULTIPID1
6192 run_test 82 "Basic grouplock test ==============================="
6195 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" &&
6197 test_mkdir -p $DIR/d99cvsroot
6198 chown $RUNAS_ID $DIR/d99cvsroot
6199 local oldPWD=$PWD # bug 13584, use $TMP as working dir
6202 $RUNAS cvs -d $DIR/d99cvsroot init || error "cvs init failed"
6205 run_test 99a "cvs init ========================================="
6208 [ -z "$(which cvs 2>/dev/null)" ] &&
6209 skip_env "could not find cvs" && return
6210 [ ! -d $DIR/d99cvsroot ] && test_99a
6212 # some versions of cvs import exit(1) when asked to import links or
6213 # files they can't read. ignore those files.
6214 TOIGNORE=$(find . -type l -printf '-I %f\n' -o \
6215 ! -perm /4 -printf '-I %f\n')
6216 $RUNAS cvs -d $DIR/d99cvsroot import -m "nomesg" $TOIGNORE \
6217 d99reposname vtag rtag
6219 run_test 99b "cvs import ======================================="
6222 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" && return
6223 [ ! -d $DIR/d99cvsroot ] && test_99b
6225 test_mkdir -p $DIR/d99reposname
6226 chown $RUNAS_ID $DIR/d99reposname
6227 $RUNAS cvs -d $DIR/d99cvsroot co d99reposname
6229 run_test 99c "cvs checkout ====================================="
6232 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" && return
6233 [ ! -d $DIR/d99cvsroot ] && test_99c
6234 cd $DIR/d99reposname
6236 $RUNAS cvs add -m 'addmsg' foo99
6238 run_test 99d "cvs add =========================================="
6241 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" && return
6242 [ ! -d $DIR/d99cvsroot ] && test_99c
6243 cd $DIR/d99reposname
6246 run_test 99e "cvs update ======================================="
6249 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" && return
6250 [ ! -d $DIR/d99cvsroot ] && test_99d
6251 cd $DIR/d99reposname
6252 $RUNAS cvs commit -m 'nomsg' foo99
6253 rm -fr $DIR/d99cvsroot
6255 run_test 99f "cvs commit ======================================="
6258 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6259 [ "$NETTYPE" = tcp ] || \
6260 { skip "TCP secure port test, not useful for NETTYPE=$NETTYPE" && \
6263 remote_ost_nodsh && skip "remote OST with nodsh" && return
6264 remote_mds_nodsh && skip "remote MDS with nodsh" && return
6266 { skip "useless for local single node setup" && return; }
6268 netstat -tna | ( rc=1; while read PROT SND RCV LOCAL REMOTE STAT; do
6269 [ "$PROT" != "tcp" ] && continue
6270 RPORT=$(echo $REMOTE | cut -d: -f2)
6271 [ "$RPORT" != "$ACCEPTOR_PORT" ] && continue
6274 LPORT=`echo $LOCAL | cut -d: -f2`
6275 if [ $LPORT -ge 1024 ]; then
6276 echo "bad: $PROT $SND $RCV $LOCAL $REMOTE $STAT"
6278 error_exit "local: $LPORT > 1024, remote: $RPORT"
6281 [ "$rc" = 0 ] || error_exit "privileged port not found" )
6283 run_test 100 "check local port using privileged port ==========="
6285 function get_named_value()
6294 echo $line | sed "s/^$tag[ ]*//"
6301 export CACHE_MAX=$($LCTL get_param -n llite.*.max_cached_mb |
6302 awk '/^max_cached_mb/ { print $2 }')
6305 $LCTL set_param -n llite.*.max_cached_mb $CACHE_MAX
6310 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6311 [ $MDSCOUNT -ge 2 ] && skip "skip now for >= 2 MDTs" && return #LU-4322
6315 local cache_limit=32
6317 $LCTL set_param -n osc.*-osc*.rpc_stats 0
6318 trap cleanup_101a EXIT
6319 $LCTL set_param -n llite.*.read_ahead_stats 0
6320 $LCTL set_param -n llite.*.max_cached_mb $cache_limit
6323 # randomly read 10000 of 64K chunks from file 3x 32MB in size
6325 echo "nreads: $nreads file size: $((cache_limit * 3))MB"
6326 $READS -f $DIR/$tfile -s$((cache_limit * 3192 * 1024)) -b65536 -C -n$nreads -t 180
6329 for s in $($LCTL get_param -n llite.*.read_ahead_stats |
6330 get_named_value 'read but discarded' | cut -d" " -f1); do
6331 discard=$(($discard + $s))
6335 if [[ $(($discard * 10)) -gt $nreads ]]; then
6336 $LCTL get_param osc.*-osc*.rpc_stats
6337 $LCTL get_param llite.*.read_ahead_stats
6338 error "too many ($discard) discarded pages"
6340 rm -f $DIR/$tfile || true
6342 run_test 101a "check read-ahead for random reads ================"
6345 test_mkdir -p $DIR/$tdir
6346 local STRIPE_SIZE=$1
6347 local FILE_LENGTH=$2
6350 local FILE_SIZE_MB=$((FILE_LENGTH / STRIPE_SIZE))
6352 local list=$(comma_list $(osts_nodes))
6353 set_osd_param $list '' read_cache_enable 0
6354 set_osd_param $list '' writethrough_cache_enable 0
6356 trap cleanup_test101bc EXIT
6357 # prepare the read-ahead file
6358 $SETSTRIPE -S $STRIPE_SIZE -i $STRIPE_OFFSET -c $OSTCOUNT $DIR/$tfile
6360 dd if=/dev/zero of=$DIR/$tfile bs=$STRIPE_SIZE \
6361 count=$FILE_SIZE_MB 2> /dev/null
6365 cleanup_test101bc() {
6370 local list=$(comma_list $(osts_nodes))
6371 set_osd_param $list '' read_cache_enable 1
6372 set_osd_param $list '' writethrough_cache_enable 1
6376 awk 'BEGIN{total=0}; {total+=$1}; END{print total}'
6381 local STRIPE_SIZE=$2
6382 local FILE_LENGTH=$3
6383 local RA_INC=1048576
6384 local STRIDE_LENGTH=$((STRIPE_SIZE/READ_SIZE))
6385 local discard_limit=$((((STRIDE_LENGTH - 1)*3/(STRIDE_LENGTH*OSTCOUNT))* \
6386 (STRIDE_LENGTH*OSTCOUNT - STRIDE_LENGTH)))
6387 DISCARD=$($LCTL get_param -n llite.*.read_ahead_stats |
6388 get_named_value 'read but discarded' |
6389 cut -d" " -f1 | calc_total)
6390 if [[ $DISCARD -gt $discard_limit ]]; then
6391 $LCTL get_param llite.*.read_ahead_stats
6392 error "Too many ($DISCARD) discarded pages with size (${READ_SIZE})"
6394 echo "Read-ahead success for size ${READ_SIZE}"
6399 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6400 [[ $OSTCOUNT -lt 2 ]] &&
6401 skip_env "skipping stride IO stride-ahead test" && return
6402 local STRIPE_SIZE=1048576
6403 local STRIDE_SIZE=$((STRIPE_SIZE*OSTCOUNT))
6404 if [ $SLOW == "yes" ]; then
6405 local FILE_LENGTH=$((STRIDE_SIZE * 64))
6407 local FILE_LENGTH=$((STRIDE_SIZE * 8))
6410 local ITERATION=$((FILE_LENGTH / STRIDE_SIZE))
6412 # prepare the read-ahead file
6413 setup_test101bc $STRIPE_SIZE $FILE_LENGTH
6414 cancel_lru_locks osc
6415 for BIDX in 2 4 8 16 32 64 128 256
6417 local BSIZE=$((BIDX*4096))
6418 local READ_COUNT=$((STRIPE_SIZE/BSIZE))
6419 local STRIDE_LENGTH=$((STRIDE_SIZE/BSIZE))
6420 local OFFSET=$((STRIPE_SIZE/BSIZE*(OSTCOUNT - 1)))
6421 $LCTL set_param -n llite.*.read_ahead_stats 0
6422 $READS -f $DIR/$tfile -l $STRIDE_LENGTH -o $OFFSET \
6423 -s $FILE_LENGTH -b $STRIPE_SIZE -a $READ_COUNT -n $ITERATION
6424 cancel_lru_locks osc
6425 ra_check_101 $BSIZE $STRIPE_SIZE $FILE_LENGTH
6430 run_test 101b "check stride-io mode read-ahead ================="
6433 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6434 local STRIPE_SIZE=1048576
6435 local FILE_LENGTH=$((STRIPE_SIZE*100))
6439 setup_test101bc $STRIPE_SIZE $FILE_LENGTH
6441 cancel_lru_locks osc
6442 $LCTL set_param osc.*.rpc_stats 0
6443 $READS -f $DIR/$tfile -s$FILE_LENGTH -b65536 -n$nreads -t 180
6444 for osc_rpc_stats in $($LCTL get_param -N osc.*.rpc_stats); do
6445 local stats=$($LCTL get_param -n $osc_rpc_stats)
6446 local lines=$(echo "$stats" | awk 'END {print NR;}')
6449 if [ $lines -le 20 ]; then
6452 for size in 1 2 4 8; do
6453 local rpc=$(echo "$stats" |
6454 awk '($1 == "'$size':") {print $2; exit; }')
6456 error "Small $((size*4))k read IO $rpc !"
6458 echo "$osc_rpc_stats check passed!"
6463 run_test 101c "check stripe_size aligned read-ahead ================="
6466 $LCTL get_param -n llite.*.max_read_ahead_mb | head -n 1
6467 $LCTL set_param -n llite.*.max_read_ahead_mb $1 > /dev/null 2>&1
6471 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6472 local file=$DIR/$tfile
6473 local sz_MB=${FILESIZE_101d:-500}
6474 local ra_MB=${READAHEAD_MB:-40}
6476 local free_MB=$(($(df -P $DIR | tail -n 1 | awk '{ print $4 }') / 1024))
6477 [ $free_MB -lt $sz_MB ] &&
6478 skip "Need free space ${sz_MB}M, have ${free_MB}M" && return
6480 echo "Create test file $file size ${sz_MB}M, ${free_MB}M free"
6481 $SETSTRIPE -c -1 $file || error "setstripe failed"
6483 dd if=/dev/zero of=$file bs=1M count=$sz_MB || error "dd failed"
6484 echo Cancel LRU locks on lustre client to flush the client cache
6485 cancel_lru_locks osc
6487 echo Disable read-ahead
6488 local old_READAHEAD=$(set_read_ahead 0)
6490 echo Reading the test file $file with read-ahead disabled
6491 local raOFF=$(do_and_time "dd if=$file of=/dev/null bs=1M count=$sz_MB")
6493 echo Cancel LRU locks on lustre client to flush the client cache
6494 cancel_lru_locks osc
6495 echo Enable read-ahead with ${ra_MB}MB
6496 set_read_ahead $ra_MB
6498 echo Reading the test file $file with read-ahead enabled
6499 local raON=$(do_and_time "dd if=$file of=/dev/null bs=1M count=$sz_MB")
6501 echo "read-ahead disabled time read $raOFF"
6502 echo "read-ahead enabled time read $raON"
6504 set_read_ahead $old_READAHEAD
6506 wait_delete_completed
6508 [ $raOFF -le 1 -o $raON -lt $raOFF ] ||
6509 error "readahead ${raON}s > no-readahead ${raOFF}s ${sz_MB}M"
6511 run_test 101d "file read with and without read-ahead enabled"
6514 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6515 local file=$DIR/$tfile
6516 local size_KB=500 #KB
6520 local free_KB=$(df -P $DIR | tail -n 1 | awk '{ print $4 }')
6521 local need_KB=$((count * size_KB))
6522 [[ $free_KB -le $need_KB ]] &&
6523 skip_env "Need free space $need_KB, have $free_KB" && return
6525 echo "Creating $count ${size_KB}K test files"
6526 for ((i = 0; i < $count; i++)); do
6527 dd if=/dev/zero of=$file.$i bs=$bsize count=$size_KB 2>/dev/null
6530 echo "Cancel LRU locks on lustre client to flush the client cache"
6531 cancel_lru_locks osc
6533 echo "Reset readahead stats"
6534 $LCTL set_param -n llite.*.read_ahead_stats 0
6536 for ((i = 0; i < $count; i++)); do
6537 dd if=$file.$i of=/dev/null bs=$bsize count=$size_KB 2>/dev/null
6540 local miss=$($LCTL get_param -n llite.*.read_ahead_stats |
6541 get_named_value 'misses' | cut -d" " -f1 | calc_total)
6543 for ((i = 0; i < $count; i++)); do
6544 rm -rf $file.$i 2>/dev/null
6547 #10000 means 20% reads are missing in readahead
6548 [[ $miss -lt 10000 ]] || error "misses too much for small reads"
6550 run_test 101e "check read-ahead for small read(1k) for small files(500k)"
6552 cleanup_test101f() {
6554 $LCTL set_param -n llite.*.max_read_ahead_whole_mb $MAX_WHOLE_MB
6555 rm -rf $DIR/$tfile 2>/dev/null
6559 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6560 local file=$DIR/$tfile
6563 MAX_WHOLE_MB=$($LCTL get_param -n llite.*.max_read_ahead_whole_mb)
6564 $LCTL set_param -n llite.*.max_read_ahead_whole_mb 2
6565 dd if=/dev/zero of=${file} bs=2097152 count=1 2>/dev/null
6566 trap cleanup_test101f EXIT
6568 echo Cancel LRU locks on lustre client to flush the client cache
6569 cancel_lru_locks osc
6571 echo Reset readahead stats
6572 $LCTL set_param -n llite.*.read_ahead_stats 0
6573 # Random read in a 2M file, because max_read_ahead_whole_mb = 2M,
6574 # readahead should read in 2M file on second read, so only miss
6576 echo Random 4K reads on 2M file for 1000 times
6577 $READS -f $file -s 2097152 -b 4096 -n $nreads
6579 echo checking missing pages
6580 local miss=$($LCTL get_param -n llite.*.read_ahead_stats |
6581 get_named_value 'misses' | cut -d" " -f1 | calc_total)
6583 [ $miss -lt 3 ] || error "misses too much pages!"
6586 run_test 101f "check read-ahead for max_read_ahead_whole_mb"
6589 test_mkdir -p $DIR/$tdir
6590 chown $RUNAS_ID $DIR/$tdir
6593 STRIPE_COUNT=$OSTCOUNT
6594 [[ $OSTCOUNT -gt 4 ]] && STRIPE_COUNT=4
6596 trap cleanup_test102 EXIT
6598 $1 $SETSTRIPE -S $STRIPE_SIZE -i $STRIPE_OFFSET -c $STRIPE_COUNT $tdir
6600 for num in 1 2 3 4; do
6601 for count in $(seq 1 $STRIPE_COUNT); do
6602 for idx in $(seq 0 $[$STRIPE_COUNT - 1]); do
6603 local size=`expr $STRIPE_SIZE \* $num`
6604 local file=file"$num-$idx-$count"
6605 $1 $SETSTRIPE -S $size -i $idx -c $count $file
6611 $1 $TAR cf $TMP/f102.tar $tdir --xattrs
6617 rm -rf $DIR/d0.sanity/d102
6621 local testfile=$DIR/$tfile
6625 [ "$UID" != 0 ] && skip_env "must run as root" && return
6626 [ -z "$(lctl get_param -n mdc.*-mdc-*.connect_flags | grep xattr)" ] &&
6627 skip_env "must have user_xattr" && return
6629 [ -z "$(which setfattr 2>/dev/null)" ] &&
6630 skip_env "could not find setfattr" && return
6632 echo "set/get xattr..."
6633 setfattr -n trusted.name1 -v value1 $testfile ||
6634 error "setfattr -n trusted.name1=value1 $testfile failed"
6635 getfattr -n trusted.name1 $testfile 2> /dev/null |
6636 grep "trusted.name1=.value1" ||
6637 error "$testfile missing trusted.name1=value1"
6639 setfattr -n user.author1 -v author1 $testfile ||
6640 error "setfattr -n user.author1=author1 $testfile failed"
6641 getfattr -n user.author1 $testfile 2> /dev/null |
6642 grep "user.author1=.author1" ||
6643 error "$testfile missing trusted.author1=author1"
6646 setfattr -n trusted.name2 -v value2 $testfile ||
6647 error "$testfile unable to set trusted.name2"
6648 setfattr -n trusted.name3 -v value3 $testfile ||
6649 error "$testfile unable to set trusted.name3"
6650 [ $(getfattr -d -m "^trusted" $testfile 2> /dev/null |
6651 grep "trusted.name" | wc -l) -eq 3 ] ||
6652 error "$testfile missing 3 trusted.name xattrs"
6654 setfattr -n user.author2 -v author2 $testfile ||
6655 error "$testfile unable to set user.author2"
6656 setfattr -n user.author3 -v author3 $testfile ||
6657 error "$testfile unable to set user.author3"
6658 [ $(getfattr -d -m "^user" $testfile 2> /dev/null |
6659 grep "user.author" | wc -l) -eq 3 ] ||
6660 error "$testfile missing 3 user.author xattrs"
6662 echo "remove xattr..."
6663 setfattr -x trusted.name1 $testfile ||
6664 error "$testfile error deleting trusted.name1"
6665 getfattr -d -m trusted $testfile 2> /dev/null | grep "trusted.name1" &&
6666 error "$testfile did not delete trusted.name1 xattr"
6668 setfattr -x user.author1 $testfile ||
6669 error "$testfile error deleting user.author1"
6670 getfattr -d -m user $testfile 2> /dev/null | grep "user.author1" &&
6671 error "$testfile did not delete trusted.name1 xattr"
6673 # b10667: setting lustre special xattr be silently discarded
6674 echo "set lustre special xattr ..."
6675 setfattr -n "trusted.lov" -v "invalid value" $testfile ||
6676 error "$testfile allowed setting trusted.lov"
6678 run_test 102a "user xattr test =================================="
6681 [ -z "$(which setfattr 2>/dev/null)" ] &&
6682 skip_env "could not find setfattr" && return
6684 # b10930: get/set/list trusted.lov xattr
6685 echo "get/set/list trusted.lov xattr ..."
6686 [[ $OSTCOUNT -lt 2 ]] && skip_env "skipping 2-stripe test" && return
6687 local testfile=$DIR/$tfile
6688 $SETSTRIPE -S 65536 -i 1 -c $OSTCOUNT $testfile ||
6689 error "setstripe failed"
6690 local STRIPECOUNT=$($GETSTRIPE -c $testfile) ||
6691 error "getstripe failed"
6692 getfattr -d -m "^trusted" $testfile 2>/dev/null | grep "trusted.lov" ||
6693 error "can't get trusted.lov from $testfile"
6695 local testfile2=${testfile}2
6696 local value=$(getfattr -n trusted.lov $testfile 2>/dev/null |
6697 grep "trusted.lov" | sed -e 's/[^=]\+=//')
6700 setfattr -n trusted.lov -v $value $testfile2
6701 local stripe_size=$($GETSTRIPE -S $testfile2)
6702 local stripe_count=$($GETSTRIPE -c $testfile2)
6703 [[ $stripe_size -eq 65536 ]] ||
6704 error "stripe size $stripe_size != 65536"
6705 [[ $stripe_count -eq $STRIPECOUNT ]] ||
6706 error "stripe count $stripe_count != $STRIPECOUNT"
6709 run_test 102b "getfattr/setfattr for trusted.lov EAs ============"
6712 [ -z "$(which setfattr 2>/dev/null)" ] &&
6713 skip_env "could not find setfattr" && return
6715 # b10930: get/set/list lustre.lov xattr
6716 echo "get/set/list lustre.lov xattr ..."
6717 [[ $OSTCOUNT -lt 2 ]] && skip_env "skipping 2-stripe test" && return
6718 test_mkdir -p $DIR/$tdir
6719 chown $RUNAS_ID $DIR/$tdir
6720 local testfile=$DIR/$tdir/$tfile
6721 $RUNAS $SETSTRIPE -S 65536 -i 1 -c $OSTCOUNT $testfile ||
6722 error "setstripe failed"
6723 local STRIPECOUNT=$($RUNAS $GETSTRIPE -c $testfile) ||
6724 error "getstripe failed"
6725 $RUNAS getfattr -d -m "^lustre" $testfile 2> /dev/null | \
6726 grep "lustre.lov" || error "can't get lustre.lov from $testfile"
6728 local testfile2=${testfile}2
6729 local value=`getfattr -n lustre.lov $testfile 2> /dev/null | \
6730 grep "lustre.lov" |sed -e 's/[^=]\+=//' `
6732 $RUNAS $MCREATE $testfile2
6733 $RUNAS setfattr -n lustre.lov -v $value $testfile2
6734 local stripe_size=$($RUNAS $GETSTRIPE -S $testfile2)
6735 local stripe_count=$($RUNAS $GETSTRIPE -c $testfile2)
6736 [ $stripe_size -eq 65536 ] || error "stripe size $stripe_size != 65536"
6737 [ $stripe_count -eq $STRIPECOUNT ] ||
6738 error "stripe count $stripe_count != $STRIPECOUNT"
6740 run_test 102c "non-root getfattr/setfattr for lustre.lov EAs ==========="
6742 compare_stripe_info1() {
6743 local stripe_index_all_zero=true
6745 for num in 1 2 3 4; do
6746 for count in $(seq 1 $STRIPE_COUNT); do
6747 for offset in $(seq 0 $[$STRIPE_COUNT - 1]); do
6748 local size=$((STRIPE_SIZE * num))
6749 local file=file"$num-$offset-$count"
6750 stripe_size=$($LFS getstripe -S $PWD/$file)
6751 [[ $stripe_size -ne $size ]] &&
6752 error "$file: size $stripe_size != $size"
6753 stripe_count=$($LFS getstripe -c $PWD/$file)
6754 # allow fewer stripes to be created, ORI-601
6755 [[ $stripe_count -lt $(((3 * count + 3) / 4)) ]] &&
6756 error "$file: count $stripe_count != $count"
6757 stripe_index=$($LFS getstripe -i $PWD/$file)
6758 [[ $stripe_index -ne 0 ]] &&
6759 stripe_index_all_zero=false
6763 $stripe_index_all_zero &&
6764 error "all files are being extracted starting from OST index 0"
6769 [ -n "$(which tar 2>/dev/null)" ] &&
6770 strings $(which tar) | grep -q "lustre" && echo tar
6774 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6775 # b10930: tar test for trusted.lov xattr
6776 TAR=$(find_lustre_tar)
6777 [ -z "$TAR" ] && skip_env "lustre-aware tar is not installed" && return
6778 [[ $OSTCOUNT -lt 2 ]] && skip_env "skipping N-stripe test" && return
6780 test_mkdir -p $DIR/d102d
6781 $TAR xf $TMP/f102.tar -C $DIR/d102d --xattrs
6783 compare_stripe_info1
6785 run_test 102d "tar restore stripe info from tarfile,not keep osts ==========="
6788 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6789 # b10930: tar test for trusted.lov xattr
6790 TAR=$(find_lustre_tar)
6791 [ -z "$TAR" ] && skip_env "lustre-aware tar is not installed" && return
6792 [[ $OSTCOUNT -lt 2 ]] && skip_env "skipping N-stripe test" && return
6794 test_mkdir -p $DIR/d102f
6796 $TAR cf - --xattrs $tdir | $TAR xf - --xattrs -C $DIR/d102f
6798 compare_stripe_info1
6800 run_test 102f "tar copy files, not keep osts ==========="
6803 local xsize=${1:-1024} # in bytes
6804 local file=$DIR/$tfile
6806 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep xattr)" ] &&
6807 skip "must have user_xattr" && return 0
6808 [ -z "$(which setfattr 2>/dev/null)" ] &&
6809 skip_env "could not find setfattr" && return 0
6810 [ -z "$(which getfattr 2>/dev/null)" ] &&
6811 skip_env "could not find getfattr" && return 0
6815 local value="$(generate_string $xsize)"
6817 local xbig=trusted.big
6818 log "save $xbig on $file"
6819 setfattr -n $xbig -v $value $file ||
6820 error "saving $xbig on $file failed"
6822 local orig=$(get_xattr_value $xbig $file)
6823 [[ "$orig" != "$value" ]] && error "$xbig different after saving $xbig"
6825 local xsml=trusted.sml
6826 log "save $xsml on $file"
6827 setfattr -n $xsml -v val $file || error "saving $xsml on $file failed"
6829 local new=$(get_xattr_value $xbig $file)
6830 [[ "$new" != "$orig" ]] && error "$xbig different after saving $xsml"
6832 log "grow $xsml on $file"
6833 setfattr -n $xsml -v "$value" $file ||
6834 error "growing $xsml on $file failed"
6836 new=$(get_xattr_value $xbig $file)
6837 [[ "$new" != "$orig" ]] && error "$xbig different after growing $xsml"
6838 log "$xbig still valid after growing $xsml"
6843 test_102h() { # bug 15777
6846 run_test 102h "grow xattr from inside inode to external block"
6849 large_xattr_enabled || { skip "large_xattr disabled" && return; }
6850 grow_xattr $(max_xattr_size)
6852 run_test 102ha "grow xattr from inside inode to external inode"
6854 test_102i() { # bug 17038
6855 [ -z "$(which getfattr 2>/dev/null)" ] &&
6856 skip "could not find getfattr" && return
6858 ln -s $DIR/$tfile $DIR/${tfile}link
6859 getfattr -n trusted.lov $DIR/$tfile ||
6860 error "lgetxattr on $DIR/$tfile failed"
6861 getfattr -h -n trusted.lov $DIR/${tfile}link 2>&1 |
6862 grep -i "no such attr" ||
6863 error "error for lgetxattr on $DIR/${tfile}link is not ENODATA"
6864 rm -f $DIR/$tfile $DIR/${tfile}link
6866 run_test 102i "lgetxattr test on symbolic link ============"
6869 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6870 TAR=$(find_lustre_tar)
6871 [ -z "$TAR" ] && skip_env "lustre-aware tar is not installed" && return
6872 [[ $OSTCOUNT -lt 2 ]] && skip_env "skipping N-stripe test" && return
6873 setup_test102 "$RUNAS"
6874 test_mkdir -p $DIR/d102j
6875 chown $RUNAS_ID $DIR/d102j
6876 $RUNAS $TAR xf $TMP/f102.tar -C $DIR/d102j --xattrs
6878 compare_stripe_info1 "$RUNAS"
6880 run_test 102j "non-root tar restore stripe info from tarfile, not keep osts ==="
6883 [ -z "$(which setfattr 2>/dev/null)" ] &&
6884 skip "could not find setfattr" && return
6886 # b22187 just check that does not crash for regular file.
6887 setfattr -n trusted.lov $DIR/$tfile
6888 # b22187 'setfattr -n trusted.lov' should work as remove LOV EA for directories
6889 local test_kdir=$DIR/d102k
6890 test_mkdir $test_kdir
6891 local default_size=`$GETSTRIPE -S $test_kdir`
6892 local default_count=`$GETSTRIPE -c $test_kdir`
6893 local default_offset=`$GETSTRIPE -i $test_kdir`
6894 $SETSTRIPE -S 65536 -i 0 -c $OSTCOUNT $test_kdir ||
6895 error 'dir setstripe failed'
6896 setfattr -n trusted.lov $test_kdir
6897 local stripe_size=`$GETSTRIPE -S $test_kdir`
6898 local stripe_count=`$GETSTRIPE -c $test_kdir`
6899 local stripe_offset=`$GETSTRIPE -i $test_kdir`
6900 [ $stripe_size -eq $default_size ] ||
6901 error "stripe size $stripe_size != $default_size"
6902 [ $stripe_count -eq $default_count ] ||
6903 error "stripe count $stripe_count != $default_count"
6904 [ $stripe_offset -eq $default_offset ] ||
6905 error "stripe offset $stripe_offset != $default_offset"
6906 rm -rf $DIR/$tfile $test_kdir
6908 run_test 102k "setfattr without parameter of value shouldn't cause a crash"
6911 [ -z "$(which getfattr 2>/dev/null)" ] &&
6912 skip "could not find getfattr" && return
6914 # LU-532 trusted. xattr is invisible to non-root
6915 local testfile=$DIR/$tfile
6919 echo "listxattr as user..."
6920 chown $RUNAS_ID $testfile
6921 $RUNAS getfattr -d -m '.*' $testfile 2>&1 |
6922 grep -q "trusted" &&
6923 error "$testfile trusted xattrs are user visible"
6927 run_test 102l "listxattr size test =================================="
6929 test_102m() { # LU-3403 llite: error of listxattr when buffer is small
6930 local path=$DIR/$tfile
6933 listxattr_size_check $path || error "listattr_size_check $path failed"
6935 run_test 102m "Ensure listxattr fails on small bufffer ========"
6939 getxattr() { # getxattr path name
6940 # Return the base64 encoding of the value of xattr name on path.
6944 # # getfattr --absolute-names --encoding=base64 --name=trusted.lov $path
6946 # trusted.lov=0s0AvRCwEAAAAGAAAAAAAAAAAEAAACAAAAAAAQAAEAA...AAAAAAAAA=
6948 # We print just 0s0AvRCwEAAAAGAAAAAAAAAAAEAAACAAAAAAAQAAEAA...AAAAAAAAA=
6950 getfattr --absolute-names --encoding=base64 --name=$name $path |
6951 awk -F= -v name=$name '$1 == name {
6952 print substr($0, index($0, "=") + 1);
6956 test_102n() { # LU-4101 mdt: protect internal xattrs
6957 local file0=$DIR/$tfile.0
6958 local file1=$DIR/$tfile.1
6959 local xattr0=$TMP/$tfile.0
6960 local xattr1=$TMP/$tfile.1
6964 [ -z "$(which setfattr 2>/dev/null)" ] &&
6965 skip "could not find setfattr" && return
6967 if [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.5.50) ]
6969 skip "MDT < 2.5.50 allows setxattr on internal trusted xattrs"
6973 rm -rf $file0 $file1 $xattr0 $xattr1
6976 # Get 'before' xattrs of $file1.
6977 getfattr --absolute-names --dump --match=- $file1 > $xattr0
6979 for name in lov lma lmv link fid version som hsm lfsck_namespace; do
6980 # Try to copy xattr from $file0 to $file1.
6981 value=$(getxattr $file0 trusted.$name 2> /dev/null)
6983 setfattr --name=trusted.$name --value="$value" $file1 ||
6984 error "setxattr 'trusted.$name' failed"
6986 # Try to set a garbage xattr.
6987 value=0sVGhlIHF1aWNrIGJyb3duIGZveCBqdW1wcyBvdmVyIGl0c2VsZi4=
6989 setfattr --name=trusted.$name --value="$value" $file1 ||
6990 error "setxattr 'trusted.$name' failed"
6992 # Try to remove the xattr from $file1. We don't care if this
6993 # appears to succeed or fail, we just don't want there to be
6994 # any changes or crashes.
6995 setfattr --remove=$trusted.$name $file1 2> /dev/null
6998 if [ $(lustre_version_code $SINGLEMDS) -gt $(version_code 2.6.50) ]
7001 # Try to copy xattr from $file0 to $file1.
7002 value=$(getxattr $file0 trusted.$name 2> /dev/null)
7004 setfattr --name=trusted.$name --value="$value" $file1 ||
7005 error "setxattr 'trusted.$name' failed"
7007 # Try to set a garbage xattr.
7008 value=0sVGhlIHF1aWNrIGJyb3duIGZveCBqdW1wcyBvdmVyIGl0c2VsZi4=
7010 setfattr --name=trusted.$name --value="$value" $file1 ||
7011 error "setxattr 'trusted.$name' failed"
7013 # Try to remove the xattr from $file1. We don't care if this
7014 # appears to succeed or fail, we just don't want there to be
7015 # any changes or crashes.
7016 setfattr --remove=$trusted.$name $file1 2> /dev/null
7019 # Get 'after' xattrs of file1.
7020 getfattr --absolute-names --dump --match=- $file1 > $xattr1
7022 if ! diff $xattr0 $xattr1; then
7023 error "before and after xattrs of '$file1' differ"
7026 rm -rf $file0 $file1 $xattr0 $xattr1
7030 run_test 102n "silently ignore setxattr on internal trusted xattrs"
7032 test_102p() { # LU-4703 setxattr did not check ownership
7033 local testfile=$DIR/$tfile
7035 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.5.56) ] &&
7036 skip "MDS needs to be at least 2.5.56" && return
7040 echo "setfacl as user..."
7041 $RUNAS setfacl -m "u:$RUNAS_ID:rwx" $testfile
7042 [ $? -ne 0 ] || error "setfacl by $RUNAS_ID was allowed on $testfile"
7044 echo "setfattr as user..."
7045 setfacl -m "u:$RUNAS_ID:---" $testfile
7046 $RUNAS setfattr -x system.posix_acl_access $testfile
7047 [ $? -ne 0 ] || error "setfattr by $RUNAS_ID was allowed on $testfile"
7049 run_test 102p "check setxattr(2) correctly fails without permission"
7052 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.6.92) ] &&
7053 skip "MDS needs to be at least 2.6.92" && return
7054 orphan_linkea_check $DIR/$tfile || error "orphan_linkea_check"
7056 run_test 102q "flistxattr should not return trusted.link EAs for orphans"
7059 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.6.93) ] &&
7060 skip "MDS needs to be at least 2.6.93" && return
7061 touch $DIR/$tfile || error "touch"
7062 setfattr -n user.$(basename $tfile) $DIR/$tfile || error "setfattr"
7063 getfattr -n user.$(basename $tfile) $DIR/$tfile || error "getfattr"
7064 rm $DIR/$tfile || error "rm"
7067 mkdir -p $DIR/$tdir || error "mkdir"
7068 setfattr -n user.$(basename $tdir) $DIR/$tdir || error "setfattr dir"
7069 getfattr -n user.$(basename $tdir) $DIR/$tdir || error "getfattr dir"
7070 setfattr -x user.$(basename $tdir) $DIR/$tdir ||
7071 error "$testfile error deleting user.author1"
7072 getfattr -d -m user.$(basename $tdir) 2> /dev/null |
7073 grep "user.$(basename $tdir)" &&
7074 error "$tdir did not delete user.$(basename $tdir)"
7075 rmdir $DIR/$tdir || error "rmdir"
7078 test_mkdir -p $DIR/$tdir || error "make striped dir"
7079 setfattr -n user.$(basename $tdir) $DIR/$tdir || error "setfattr dir"
7080 getfattr -n user.$(basename $tdir) $DIR/$tdir || error "getfattr dir"
7081 setfattr -x user.$(basename $tdir) $DIR/$tdir ||
7082 error "$testfile error deleting user.author1"
7083 getfattr -d -m user.$(basename $tdir) 2> /dev/null |
7084 grep "user.$(basename $tdir)" &&
7085 error "$tdir did not delete user.$(basename $tdir)"
7086 rmdir $DIR/$tdir || error "rm striped dir"
7088 run_test 102r "set EAs with empty values"
7092 $LUSTRE/tests/acl/run $LUSTRE/tests/acl/$1.test
7097 [ "$UID" != 0 ] && skip_env "must run as root" && return
7098 [ -z "$(lctl get_param -n mdc.*-mdc-*.connect_flags | grep acl)" ] &&
7099 skip "must have acl enabled" && return
7100 [ -z "$(which setfacl 2>/dev/null)" ] &&
7101 skip_env "could not find setfacl" && return
7102 $GSS && skip "could not run under gss" && return
7104 gpasswd -a daemon bin # LU-5641
7105 do_facet $SINGLEMDS gpasswd -a daemon bin # LU-5641
7107 declare -a identity_old
7109 for num in $(seq $MDSCOUNT); do
7110 switch_identity $num true || identity_old[$num]=$?
7117 echo "performing cp ..."
7118 run_acl_subtest cp || error "run_acl_subtest cp failed"
7119 echo "performing getfacl-noacl..."
7120 run_acl_subtest getfacl-noacl || error "getfacl-noacl test failed"
7121 echo "performing misc..."
7122 run_acl_subtest misc || error "misc test failed"
7123 echo "performing permissions..."
7124 run_acl_subtest permissions || error "permissions failed"
7125 echo "performing setfacl..."
7126 run_acl_subtest setfacl || error "setfacl test failed"
7128 # inheritance test got from HP
7129 echo "performing inheritance..."
7130 cp $LUSTRE/tests/acl/make-tree . || error "cannot copy make-tree"
7131 chmod +x make-tree || error "chmod +x failed"
7132 run_acl_subtest inheritance || error "inheritance test failed"
7135 echo "LU-974 ignore umask when acl is enabled..."
7136 run_acl_subtest 974 || error "LU-974 umask test failed"
7137 if [ $MDSCOUNT -ge 2 ]; then
7138 run_acl_subtest 974_remote ||
7139 error "LU-974 umask test failed under remote dir"
7142 echo "LU-2561 newly created file is same size as directory..."
7143 if [ $(facet_fstype $SINGLEMDS) != "zfs" ]; then
7144 run_acl_subtest 2561 || error "LU-2561 test failed"
7146 run_acl_subtest 2561_zfs || error "LU-2561 zfs test failed"
7149 run_acl_subtest 4924 || error "LU-4924 test failed"
7154 for num in $(seq $MDSCOUNT); do
7155 if [ "${identity_old[$num]}" = 1 ]; then
7156 switch_identity $num false || identity_old[$num]=$?
7160 run_test 103a "acl test ========================================="
7164 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
7165 local mountopts=$MDS_MOUNT_OPTS
7167 if [[ "$MDS_MOUNT_OPTS" =~ "noacl" ]]; then
7171 stop $SINGLEMDS || error "failed to stop MDT."
7173 if [ -z "$MDS_MOUNT_OPTS" ]; then
7174 MDS_MOUNT_OPTS="-o noacl"
7176 MDS_MOUNT_OPTS="${MDS_MOUNT_OPTS},noacl"
7178 start $SINGLEMDS $MDT_DEV $MDS_MOUNT_OPTS ||
7179 error "failed to start MDT."
7180 MDS_MOUNT_OPTS=$mountopts
7184 setfacl -m u:bin:rw $DIR/$tfile && error "setfacl should fail"
7188 stop $SINGLEMDS || error "failed to stop MDT."
7190 start $SINGLEMDS $MDT_DEV $MDS_MOUNT_OPTS ||
7191 error "failed to start MDT."
7196 run_test 103b "MDS mount option 'noacl'"
7200 cp -rp $DIR/$tdir $DIR/$tdir.bak
7202 [ -n "$(getfattr -d -m. $DIR/$tdir | grep posix_acl_default)" ] &&
7203 error "$DIR/$tdir shouldn't contain default ACL"
7204 [ -n "$(getfattr -d -m. $DIR/$tdir.bak | grep posix_acl_default)" ] &&
7205 error "$DIR/$tdir.bak shouldn't contain default ACL"
7208 run_test 103c "'cp -rp' won't set empty acl"
7211 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7213 lfs df || error "lfs df failed"
7214 lfs df -ih || error "lfs df -ih failed"
7215 lfs df -h $DIR || error "lfs df -h $DIR failed"
7216 lfs df -i $DIR || error "lfs df -i $DIR failed"
7217 lfs df $DIR/$tfile || error "lfs df $DIR/$tfile failed"
7218 lfs df -ih $DIR/$tfile || error "lfs df -ih $DIR/$tfile failed"
7220 local OSC=$(lctl dl | grep OST0000-osc-[^M] | awk '{ print $4 }')
7221 lctl --device %$OSC deactivate
7222 lfs df || error "lfs df with deactivated OSC failed"
7223 lctl --device %$OSC activate
7224 # wait the osc back to normal
7225 wait_osc_import_state client ost FULL
7227 lfs df || error "lfs df with reactivated OSC failed"
7230 run_test 104a "lfs df [-ih] [path] test ========================="
7233 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7234 [ $RUNAS_ID -eq $UID ] &&
7235 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
7237 denied_cnt=$(($($RUNAS $LFS check servers 2>&1 |
7238 grep "Permission denied" | wc -l)))
7239 if [ $denied_cnt -ne 0 ]; then
7240 error "lfs check servers test failed"
7243 run_test 104b "$RUNAS lfs check servers test ===================="
7246 # doesn't work on 2.4 kernels
7248 if $(flock_is_enabled); then
7249 flocks_test 1 on -f $DIR/$tfile || error "fail flock on"
7251 flocks_test 1 off -f $DIR/$tfile || error "fail flock off"
7255 run_test 105a "flock when mounted without -o flock test ========"
7259 if $(flock_is_enabled); then
7260 flocks_test 1 on -c $DIR/$tfile || error "fail flock on"
7262 flocks_test 1 off -c $DIR/$tfile || error "fail flock off"
7266 run_test 105b "fcntl when mounted without -o flock test ========"
7270 if $(flock_is_enabled); then
7271 flocks_test 1 on -l $DIR/$tfile || error "fail flock on"
7273 flocks_test 1 off -l $DIR/$tfile || error "fail flock off"
7277 run_test 105c "lockf when mounted without -o flock test ========"
7279 test_105d() { # bug 15924
7280 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7281 test_mkdir -p $DIR/$tdir
7282 flock_is_enabled || { skip "mount w/o flock enabled" && return; }
7283 #define OBD_FAIL_LDLM_CP_CB_WAIT 0x315
7284 $LCTL set_param fail_loc=0x80000315
7285 flocks_test 2 $DIR/$tdir
7287 run_test 105d "flock race (should not freeze) ========"
7289 test_105e() { # bug 22660 && 22040
7290 flock_is_enabled || { skip "mount w/o flock enabled" && return; }
7292 flocks_test 3 $DIR/$tfile
7294 run_test 105e "Two conflicting flocks from same process ======="
7296 test_106() { #bug 10921
7297 test_mkdir -p $DIR/$tdir
7298 $DIR/$tdir && error "exec $DIR/$tdir succeeded"
7299 chmod 777 $DIR/$tdir || error "chmod $DIR/$tdir failed"
7301 run_test 106 "attempt exec of dir followed by chown of that dir"
7304 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7311 local save_pattern=$(sysctl -n kernel.core_pattern)
7312 local save_uses_pid=$(sysctl -n kernel.core_uses_pid)
7313 sysctl -w kernel.core_pattern=$file
7314 sysctl -w kernel.core_uses_pid=0
7322 kill -s 11 $SLEEPPID
7324 if [ -e $file ]; then
7325 size=`stat -c%s $file`
7326 [ $size -eq 0 ] && error "Fail to create core file $file"
7328 error "Fail to create core file $file"
7331 sysctl -w kernel.core_pattern=$save_pattern
7332 sysctl -w kernel.core_uses_pid=$save_uses_pid
7335 run_test 107 "Coredump on SIG"
7338 test_mkdir -p $DIR/$tdir
7339 test_mkdir $DIR/$tdir/$(str_repeat 'a' 255) ||
7340 error "mkdir with 255 char failed"
7341 test_mkdir $DIR/$tdir/$(str_repeat 'b' 256) &&
7342 error "mkdir with 256 char should fail, but did not"
7343 touch $DIR/$tdir/$(str_repeat 'x' 255) ||
7344 error "create with 255 char failed"
7345 touch $DIR/$tdir/$(str_repeat 'y' 256) &&
7346 error "create with 256 char should fail, but did not"
7351 run_test 110 "filename length checking"
7354 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7355 OSTIO_pre=$(ps -e | grep ll_ost_io | awk '{ print $4 }'| sort -n |
7356 tail -1 | cut -c11-20)
7357 [ -z "$OSTIO_pre" ] && skip "no OSS threads" && return
7358 echo "Starting with $OSTIO_pre threads"
7361 NUMFREE=$(df -i -P $DIR | tail -n 1 | awk '{ print $4 }')
7362 [[ $NUMFREE -lt $NUMTEST ]] && NUMTEST=$(($NUMFREE - 1000))
7363 echo "$NUMTEST creates/unlinks"
7364 test_mkdir -p $DIR/$tdir
7365 createmany -o $DIR/$tdir/$tfile $NUMTEST
7366 unlinkmany $DIR/$tdir/$tfile $NUMTEST
7368 OSTIO_post=$(ps -e | grep ll_ost_io | awk '{ print $4 }' | sort -n |
7369 tail -1 | cut -c11-20)
7371 # don't return an error
7372 [ $OSTIO_post == $OSTIO_pre ] && echo \
7373 "WARNING: No new ll_ost_io threads were created ($OSTIO_pre)" &&
7374 echo "This may be fine, depending on what ran before this test" &&
7375 echo "and how fast this system is." && return
7377 echo "Started with $OSTIO_pre threads, ended with $OSTIO_post"
7379 run_test 115 "verify dynamic thread creation===================="
7382 wait_delete_completed
7383 AVAIL=($(lctl get_param -n osc.*[oO][sS][cC]-[^M]*.kbytesavail))
7384 echo OST kbytes available: ${AVAIL[@]}
7385 MAXI=0; MAXV=${AVAIL[0]}
7386 MINI=0; MINV=${AVAIL[0]}
7387 for ((i = 0; i < ${#AVAIL[@]}; i++)); do
7388 #echo OST $i: ${AVAIL[i]}kb
7389 if [[ ${AVAIL[i]} -gt $MAXV ]]; then
7390 MAXV=${AVAIL[i]}; MAXI=$i
7392 if [[ ${AVAIL[i]} -lt $MINV ]]; then
7393 MINV=${AVAIL[i]}; MINI=$i
7396 echo Min free space: OST $MINI: $MINV
7397 echo Max free space: OST $MAXI: $MAXV
7400 test_116a() { # was previously test_116()
7401 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7402 remote_mds_nodsh && skip "remote MDS with nodsh" && return
7404 [[ $OSTCOUNT -lt 2 ]] && skip_env "$OSTCOUNT < 2 OSTs" && return
7406 echo -n "Free space priority "
7407 do_facet $SINGLEMDS lctl get_param -n lo*.*-mdtlov.qos_prio_free |
7412 [ $MINV -eq 0 ] && skip "no free space in OST$MINI, skip" && return
7413 [ $MINV -gt 10000000 ] && skip "too much free space in OST$MINI, skip" \
7415 trap simple_cleanup_common EXIT
7418 # Check if we need to generate uneven OSTs
7419 test_mkdir -p $DIR/$tdir/OST${MINI}
7420 local FILL=$(($MINV / 4))
7421 local DIFF=$(($MAXV - $MINV))
7422 local DIFF2=$(($DIFF * 100 / $MINV))
7424 local threshold=$(do_facet $SINGLEMDS \
7425 lctl get_param -n *.*MDT0000-mdtlov.qos_threshold_rr | head -n1)
7426 threshold=${threshold%%%}
7427 echo -n "Check for uneven OSTs: "
7428 echo -n "diff=${DIFF}KB (${DIFF2}%) must be > ${threshold}% ..."
7430 if [[ $DIFF2 -gt $threshold ]]; then
7432 echo "Don't need to fill OST$MINI"
7434 # generate uneven OSTs. Write 2% over the QOS threshold value
7436 DIFF=$(($threshold - $DIFF2 + 2))
7437 DIFF2=$(( ($MINV * $DIFF)/100 ))
7438 echo "Fill ${DIFF}% remaining space in OST${MINI} with ${DIFF2}KB"
7439 $SETSTRIPE -i $MINI -c 1 $DIR/$tdir/OST${MINI} ||
7440 error "setstripe failed"
7441 DIFF=$(($DIFF2 / 2048))
7443 while [ $i -lt $DIFF ]; do
7445 dd if=/dev/zero of=$DIR/$tdir/OST${MINI}/$tfile-$i \
7446 bs=2M count=1 2>/dev/null
7455 DIFF=$(($MAXV - $MINV))
7456 DIFF2=$(($DIFF * 100 / $MINV))
7457 echo -n "diff=${DIFF}=${DIFF2}% must be > ${threshold}% for QOS mode..."
7458 if [[ $DIFF2 -gt $threshold ]]; then
7461 echo "failed - QOS mode won't be used"
7462 skip "QOS imbalance criteria not met"
7463 simple_cleanup_common
7467 MINI1=$MINI; MINV1=$MINV
7468 MAXI1=$MAXI; MAXV1=$MAXV
7470 # now fill using QOS
7471 $SETSTRIPE -c 1 $DIR/$tdir
7472 FILL=$(($FILL / 200))
7473 if [ $FILL -gt 600 ]; then
7476 echo "writing $FILL files to QOS-assigned OSTs"
7478 while [ $i -lt $FILL ]; do
7480 dd if=/dev/zero of=$DIR/$tdir/$tfile-$i bs=200k \
7484 echo "wrote $i 200k files"
7488 echo "Note: free space may not be updated, so measurements might be off"
7490 DIFF2=$(($MAXV - $MINV))
7491 echo "free space delta: orig $DIFF final $DIFF2"
7492 [ $DIFF2 -gt $DIFF ] && echo "delta got worse!"
7493 DIFF=$(($MINV1 - ${AVAIL[$MINI1]}))
7494 echo "Wrote ${DIFF}KB to smaller OST $MINI1"
7495 DIFF2=$(($MAXV1 - ${AVAIL[$MAXI1]}))
7496 echo "Wrote ${DIFF2}KB to larger OST $MAXI1"
7497 FILL=$(($DIFF2 * 100 / $DIFF - 100))
7499 echo "Wrote ${FILL}% more data to larger OST $MAXI1"
7501 # Figure out which files were written where
7502 UUID=$(lctl get_param -n lov.${FSNAME}-clilov-*.target_obd |
7503 awk '/'$MINI1': / {print $2; exit}')
7505 MINC=$($GETSTRIPE --ost $UUID $DIR/$tdir | grep $DIR | wc -l)
7506 echo "$MINC files created on smaller OST $MINI1"
7507 UUID=$(lctl get_param -n lov.${FSNAME}-clilov-*.target_obd |
7508 awk '/'$MAXI1': / {print $2; exit}')
7510 MAXC=$($GETSTRIPE --ost $UUID $DIR/$tdir | grep $DIR | wc -l)
7511 echo "$MAXC files created on larger OST $MAXI1"
7512 FILL=$(($MAXC * 100 / $MINC - 100))
7513 [[ $MINC -gt 0 ]] &&
7514 echo "Wrote ${FILL}% more files to larger OST $MAXI1"
7515 [[ $MAXC -gt $MINC ]] ||
7516 error_ignore LU-9 "stripe QOS didn't balance free space"
7517 simple_cleanup_common
7519 run_test 116a "stripe QOS: free space balance ==================="
7521 test_116b() { # LU-2093
7522 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7523 remote_mds_nodsh && skip "remote MDS with nodsh" && return
7525 #define OBD_FAIL_MDS_OSC_CREATE_FAIL 0x147
7526 local old_rr=$(do_facet $SINGLEMDS lctl get_param -n \
7527 lo*.$FSNAME-MDT0000-mdtlov.qos_threshold_rr | head -1)
7528 [ -z "$old_rr" ] && skip "no QOS" && return 0
7529 do_facet $SINGLEMDS lctl set_param \
7530 lo*.$FSNAME-MDT0000-mdtlov.qos_threshold_rr=0
7532 do_facet $SINGLEMDS lctl set_param fail_loc=0x147
7533 createmany -o $DIR/$tdir/f- 20 || error "can't create"
7534 do_facet $SINGLEMDS lctl set_param fail_loc=0
7536 do_facet $SINGLEMDS lctl set_param \
7537 lo*.$FSNAME-MDT0000-mdtlov.qos_threshold_rr=$old_rr
7539 run_test 116b "QoS shouldn't LBUG if not enough OSTs found on the 2nd pass"
7541 test_117() # bug 10891
7543 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7544 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1
7545 #define OBD_FAIL_OST_SETATTR_CREDITS 0x21e
7546 lctl set_param fail_loc=0x21e
7547 > $DIR/$tfile || error "truncate failed"
7548 lctl set_param fail_loc=0
7549 echo "Truncate succeeded."
7552 run_test 117 "verify osd extend =========="
7554 NO_SLOW_RESENDCOUNT=4
7555 export OLD_RESENDCOUNT=""
7556 set_resend_count () {
7557 local PROC_RESENDCOUNT="osc.${FSNAME}-OST*-osc-*.resend_count"
7558 OLD_RESENDCOUNT=$(lctl get_param -n $PROC_RESENDCOUNT | head -n1)
7559 lctl set_param -n $PROC_RESENDCOUNT $1
7560 echo resend_count is set to $(lctl get_param -n $PROC_RESENDCOUNT)
7563 # for reduce test_118* time (b=14842)
7564 [ "$SLOW" = "no" ] && set_resend_count $NO_SLOW_RESENDCOUNT
7566 # Reset async IO behavior after error case
7568 FILE=$DIR/reset_async
7570 # Ensure all OSCs are cleared
7571 $SETSTRIPE -c -1 $FILE
7572 dd if=/dev/zero of=$FILE bs=64k count=$OSTCOUNT
7577 test_118a() #bug 11710
7579 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7582 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
7583 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
7584 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
7586 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
7587 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
7592 run_test 118a "verify O_SYNC works =========="
7596 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7597 remote_ost_nodsh && skip "remote OST with nodsh" && return
7601 #define OBD_FAIL_SRV_ENOENT 0x217
7602 set_nodes_failloc "$(osts_nodes)" 0x217
7603 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
7605 set_nodes_failloc "$(osts_nodes)" 0
7606 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
7607 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
7610 if [[ $RC -eq 0 ]]; then
7611 error "Must return error due to dropped pages, rc=$RC"
7615 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
7616 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
7620 echo "Dirty pages not leaked on ENOENT"
7622 # Due to the above error the OSC will issue all RPCs syncronously
7623 # until a subsequent RPC completes successfully without error.
7624 $MULTIOP $DIR/$tfile Ow4096yc
7629 run_test 118b "Reclaim dirty pages on fatal error =========="
7633 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7635 # for 118c, restore the original resend count, LU-1940
7636 [ "$SLOW" = "no" ] && [ -n "$OLD_RESENDCOUNT" ] &&
7637 set_resend_count $OLD_RESENDCOUNT
7638 remote_ost_nodsh && skip "remote OST with nodsh" && return
7642 #define OBD_FAIL_OST_EROFS 0x216
7643 set_nodes_failloc "$(osts_nodes)" 0x216
7645 # multiop should block due to fsync until pages are written
7646 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
7650 if [[ `ps h -o comm -p $MULTIPID` != "multiop" ]]; then
7651 error "Multiop failed to block on fsync, pid=$MULTIPID"
7654 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
7656 if [[ $WRITEBACK -eq 0 ]]; then
7657 error "No page in writeback, writeback=$WRITEBACK"
7660 set_nodes_failloc "$(osts_nodes)" 0
7663 if [[ $RC -ne 0 ]]; then
7664 error "Multiop fsync failed, rc=$RC"
7667 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
7668 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
7670 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
7671 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
7675 echo "Dirty pages flushed via fsync on EROFS"
7678 run_test 118c "Fsync blocks on EROFS until dirty pages are flushed =========="
7680 # continue to use small resend count to reduce test_118* time (b=14842)
7681 [ "$SLOW" = "no" ] && set_resend_count $NO_SLOW_RESENDCOUNT
7685 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7686 remote_ost_nodsh && skip "remote OST with nodsh" && return
7690 #define OBD_FAIL_OST_BRW_PAUSE_BULK
7691 set_nodes_failloc "$(osts_nodes)" 0x214
7692 # multiop should block due to fsync until pages are written
7693 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
7697 if [[ `ps h -o comm -p $MULTIPID` != "multiop" ]]; then
7698 error "Multiop failed to block on fsync, pid=$MULTIPID"
7701 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
7703 if [[ $WRITEBACK -eq 0 ]]; then
7704 error "No page in writeback, writeback=$WRITEBACK"
7707 wait $MULTIPID || error "Multiop fsync failed, rc=$?"
7708 set_nodes_failloc "$(osts_nodes)" 0
7710 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
7711 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
7713 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
7714 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
7718 echo "Dirty pages gaurenteed flushed via fsync"
7721 run_test 118d "Fsync validation inject a delay of the bulk =========="
7724 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7727 #define OBD_FAIL_OSC_BRW_PREP_REQ2 0x40a
7728 lctl set_param fail_loc=0x8000040a
7730 # Should simulate EINVAL error which is fatal
7731 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
7733 if [[ $RC -eq 0 ]]; then
7734 error "Must return error due to dropped pages, rc=$RC"
7737 lctl set_param fail_loc=0x0
7739 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
7740 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
7741 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
7743 if [[ $LOCKED -ne 0 ]]; then
7744 error "Locked pages remain in cache, locked=$LOCKED"
7747 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
7748 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
7752 echo "No pages locked after fsync"
7757 run_test 118f "Simulate unrecoverable OSC side error =========="
7760 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7763 #define OBD_FAIL_OSC_BRW_PREP_REQ 0x406
7764 lctl set_param fail_loc=0x406
7766 # simulate local -ENOMEM
7767 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
7770 lctl set_param fail_loc=0
7771 if [[ $RC -eq 0 ]]; then
7772 error "Must return error due to dropped pages, rc=$RC"
7775 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
7776 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
7777 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
7779 if [[ $LOCKED -ne 0 ]]; then
7780 error "Locked pages remain in cache, locked=$LOCKED"
7783 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
7784 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
7788 echo "No pages locked after fsync"
7793 run_test 118g "Don't stay in wait if we got local -ENOMEM =========="
7796 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7797 remote_ost_nodsh && skip "remote OST with nodsh" && return
7801 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
7802 set_nodes_failloc "$(osts_nodes)" 0x20e
7803 # Should simulate ENOMEM error which is recoverable and should be handled by timeout
7804 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
7807 set_nodes_failloc "$(osts_nodes)" 0
7808 if [[ $RC -eq 0 ]]; then
7809 error "Must return error due to dropped pages, rc=$RC"
7812 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
7813 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
7814 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
7816 if [[ $LOCKED -ne 0 ]]; then
7817 error "Locked pages remain in cache, locked=$LOCKED"
7820 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
7821 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
7825 echo "No pages locked after fsync"
7829 run_test 118h "Verify timeout in handling recoverables errors =========="
7831 [ "$SLOW" = "no" ] && [ -n "$OLD_RESENDCOUNT" ] && set_resend_count $OLD_RESENDCOUNT
7834 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7835 remote_ost_nodsh && skip "remote OST with nodsh" && return
7839 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
7840 set_nodes_failloc "$(osts_nodes)" 0x20e
7842 # Should simulate ENOMEM error which is recoverable and should be handled by timeout
7843 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
7846 set_nodes_failloc "$(osts_nodes)" 0
7850 if [[ $RC -ne 0 ]]; then
7851 error "got error, but should be not, rc=$RC"
7854 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
7855 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
7856 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
7857 if [[ $LOCKED -ne 0 ]]; then
7858 error "Locked pages remain in cache, locked=$LOCKED"
7861 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
7862 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
7866 echo "No pages locked after fsync"
7870 run_test 118i "Fix error before timeout in recoverable error =========="
7872 [ "$SLOW" = "no" ] && set_resend_count 4
7875 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7876 remote_ost_nodsh && skip "remote OST with nodsh" && return
7880 #define OBD_FAIL_OST_BRW_WRITE_BULK2 0x220
7881 set_nodes_failloc "$(osts_nodes)" 0x220
7883 # return -EIO from OST
7884 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
7886 set_nodes_failloc "$(osts_nodes)" 0x0
7887 if [[ $RC -eq 0 ]]; then
7888 error "Must return error due to dropped pages, rc=$RC"
7891 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
7892 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
7893 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
7894 if [[ $LOCKED -ne 0 ]]; then
7895 error "Locked pages remain in cache, locked=$LOCKED"
7898 # in recoverable error on OST we want resend and stay until it finished
7899 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
7900 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
7904 echo "No pages locked after fsync"
7908 run_test 118j "Simulate unrecoverable OST side error =========="
7912 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7913 remote_ost_nodsh && skip "remote OSTs with nodsh" && return
7915 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
7916 set_nodes_failloc "$(osts_nodes)" 0x20e
7917 test_mkdir -p $DIR/$tdir
7919 for ((i=0;i<10;i++)); do
7920 (dd if=/dev/zero of=$DIR/$tdir/$tfile-$i bs=1M count=10 || \
7921 error "dd to $DIR/$tdir/$tfile-$i failed" )&
7928 set_nodes_failloc "$(osts_nodes)" 0
7931 run_test 118k "bio alloc -ENOMEM and IO TERM handling ========="
7935 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7937 test_mkdir -p $DIR/$tdir
7938 $MULTIOP $DIR/$tdir Dy || error "fsync dir failed"
7941 run_test 118l "fsync dir ========="
7943 test_118m() # LU-3066
7945 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7946 test_mkdir -p $DIR/$tdir
7947 $MULTIOP $DIR/$tdir DY || error "fdatasync dir failed"
7950 run_test 118m "fdatasync dir ========="
7952 [ "$SLOW" = "no" ] && [ -n "$OLD_RESENDCOUNT" ] && set_resend_count $OLD_RESENDCOUNT
7954 test_119a() # bug 11737
7956 BSIZE=$((512 * 1024))
7957 directio write $DIR/$tfile 0 1 $BSIZE
7958 # We ask to read two blocks, which is more than a file size.
7959 # directio will indicate an error when requested and actual
7960 # sizes aren't equeal (a normal situation in this case) and
7961 # print actual read amount.
7962 NOB=`directio read $DIR/$tfile 0 2 $BSIZE | awk '/error/ {print $6}'`
7963 if [ "$NOB" != "$BSIZE" ]; then
7964 error "read $NOB bytes instead of $BSIZE"
7968 run_test 119a "Short directIO read must return actual read amount"
7970 test_119b() # bug 11737
7972 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping 2-stripe test" && return
7974 $SETSTRIPE -c 2 $DIR/$tfile || error "setstripe failed"
7975 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=1 || error "dd failed"
7977 $MULTIOP $DIR/$tfile oO_RDONLY:O_DIRECT:r$((2048 * 1024)) || \
7978 error "direct read failed"
7981 run_test 119b "Sparse directIO read must return actual read amount"
7983 test_119c() # bug 13099
7986 directio write $DIR/$tfile 3 1 $BSIZE || error "direct write failed"
7987 directio readhole $DIR/$tfile 0 2 $BSIZE || error "reading hole failed"
7990 run_test 119c "Testing for direct read hitting hole"
7992 test_119d() # bug 15950
7994 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7995 MAX_RPCS_IN_FLIGHT=`$LCTL get_param -n osc.*OST0000-osc-[^mM]*.max_rpcs_in_flight`
7996 $LCTL set_param -n osc.*OST0000-osc-[^mM]*.max_rpcs_in_flight 1
7998 $SETSTRIPE $DIR/$tfile -i 0 -c 1 || error "setstripe failed"
7999 $DIRECTIO write $DIR/$tfile 0 1 $BSIZE || error "first directio failed"
8000 #define OBD_FAIL_OSC_DIO_PAUSE 0x40d
8001 lctl set_param fail_loc=0x40d
8002 $DIRECTIO write $DIR/$tfile 1 4 $BSIZE &
8005 cat $DIR/$tfile > /dev/null &
8006 lctl set_param fail_loc=0
8009 log "the DIO writes have completed, now wait for the reads (should not block very long)"
8011 [ -n "`ps h -p $pid_reads -o comm`" ] && \
8012 error "the read rpcs have not completed in 2s"
8014 $LCTL set_param -n osc.*OST0000-osc-[^mM]*.max_rpcs_in_flight $MAX_RPCS_IN_FLIGHT
8016 run_test 119d "The DIO path should try to send a new rpc once one is completed"
8019 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8020 test_mkdir -p $DIR/$tdir
8021 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
8022 skip "no early lock cancel on server" && return 0
8024 lru_resize_disable mdc
8025 lru_resize_disable osc
8026 cancel_lru_locks mdc
8027 # asynchronous object destroy at MDT could cause bl ast to client
8028 cancel_lru_locks osc
8030 stat $DIR/$tdir > /dev/null
8031 can1=$(do_facet $SINGLEMDS \
8032 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8033 awk '/ldlm_cancel/ {print $2}')
8034 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8035 awk '/ldlm_bl_callback/ {print $2}')
8036 test_mkdir -c1 $DIR/$tdir/d1
8037 can2=$(do_facet $SINGLEMDS \
8038 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8039 awk '/ldlm_cancel/ {print $2}')
8040 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8041 awk '/ldlm_bl_callback/ {print $2}')
8042 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
8043 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
8044 lru_resize_enable mdc
8045 lru_resize_enable osc
8047 run_test 120a "Early Lock Cancel: mkdir test"
8050 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8051 test_mkdir $DIR/$tdir
8052 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel)" ] && \
8053 skip "no early lock cancel on server" && return 0
8054 lru_resize_disable mdc
8055 lru_resize_disable osc
8056 cancel_lru_locks mdc
8057 stat $DIR/$tdir > /dev/null
8058 can1=$(do_facet $SINGLEMDS \
8059 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8060 awk '/ldlm_cancel/ {print $2}')
8061 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8062 awk '/ldlm_bl_callback/ {print $2}')
8064 can2=$(do_facet $SINGLEMDS \
8065 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8066 awk '/ldlm_cancel/ {print $2}')
8067 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8068 awk '/ldlm_bl_callback/ {print $2}')
8069 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
8070 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
8071 lru_resize_enable mdc
8072 lru_resize_enable osc
8074 run_test 120b "Early Lock Cancel: create test"
8077 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8078 test_mkdir -c1 $DIR/$tdir
8079 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel)" ] && \
8080 skip "no early lock cancel on server" && return 0
8081 lru_resize_disable mdc
8082 lru_resize_disable osc
8083 test_mkdir -p -c1 $DIR/$tdir/d1
8084 test_mkdir -p -c1 $DIR/$tdir/d2
8085 touch $DIR/$tdir/d1/f1
8086 cancel_lru_locks mdc
8087 stat $DIR/$tdir/d1 $DIR/$tdir/d2 $DIR/$tdir/d1/f1 > /dev/null
8088 can1=$(do_facet $SINGLEMDS \
8089 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8090 awk '/ldlm_cancel/ {print $2}')
8091 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8092 awk '/ldlm_bl_callback/ {print $2}')
8093 ln $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2
8094 can2=$(do_facet $SINGLEMDS \
8095 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8096 awk '/ldlm_cancel/ {print $2}')
8097 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8098 awk '/ldlm_bl_callback/ {print $2}')
8099 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
8100 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
8101 lru_resize_enable mdc
8102 lru_resize_enable osc
8104 run_test 120c "Early Lock Cancel: link test"
8107 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8108 test_mkdir -p -c1 $DIR/$tdir
8109 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel)" ] && \
8110 skip "no early lock cancel on server" && return 0
8111 lru_resize_disable mdc
8112 lru_resize_disable osc
8114 cancel_lru_locks mdc
8115 stat $DIR/$tdir > /dev/null
8116 can1=$(do_facet $SINGLEMDS \
8117 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8118 awk '/ldlm_cancel/ {print $2}')
8119 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8120 awk '/ldlm_bl_callback/ {print $2}')
8121 chmod a+x $DIR/$tdir
8122 can2=$(do_facet $SINGLEMDS \
8123 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8124 awk '/ldlm_cancel/ {print $2}')
8125 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8126 awk '/ldlm_bl_callback/ {print $2}')
8127 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
8128 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
8129 lru_resize_enable mdc
8130 lru_resize_enable osc
8132 run_test 120d "Early Lock Cancel: setattr test"
8135 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8136 test_mkdir -p -c1 $DIR/$tdir
8137 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
8138 skip "no early lock cancel on server" && return 0
8139 lru_resize_disable mdc
8140 lru_resize_disable osc
8141 dd if=/dev/zero of=$DIR/$tdir/f1 count=1
8142 cancel_lru_locks mdc
8143 cancel_lru_locks osc
8144 dd if=$DIR/$tdir/f1 of=/dev/null
8145 stat $DIR/$tdir $DIR/$tdir/f1 > /dev/null
8146 # XXX client can not do early lock cancel of OST lock
8147 # during unlink (LU-4206), so cancel osc lock now.
8148 cancel_lru_locks osc
8149 can1=$(do_facet $SINGLEMDS \
8150 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8151 awk '/ldlm_cancel/ {print $2}')
8152 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8153 awk '/ldlm_bl_callback/ {print $2}')
8154 unlink $DIR/$tdir/f1
8156 can2=$(do_facet $SINGLEMDS \
8157 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8158 awk '/ldlm_cancel/ {print $2}')
8159 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8160 awk '/ldlm_bl_callback/ {print $2}')
8161 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
8162 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
8163 lru_resize_enable mdc
8164 lru_resize_enable osc
8166 run_test 120e "Early Lock Cancel: unlink test"
8169 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8170 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
8171 skip "no early lock cancel on server" && return 0
8172 test_mkdir -p -c1 $DIR/$tdir
8173 lru_resize_disable mdc
8174 lru_resize_disable osc
8175 test_mkdir -p -c1 $DIR/$tdir/d1
8176 test_mkdir -p -c1 $DIR/$tdir/d2
8177 dd if=/dev/zero of=$DIR/$tdir/d1/f1 count=1
8178 dd if=/dev/zero of=$DIR/$tdir/d2/f2 count=1
8179 cancel_lru_locks mdc
8180 cancel_lru_locks osc
8181 dd if=$DIR/$tdir/d1/f1 of=/dev/null
8182 dd if=$DIR/$tdir/d2/f2 of=/dev/null
8183 stat $DIR/$tdir/d1 $DIR/$tdir/d2 $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2 > /dev/null
8184 # XXX client can not do early lock cancel of OST lock
8185 # during rename (LU-4206), so cancel osc lock now.
8186 cancel_lru_locks osc
8187 can1=$(do_facet $SINGLEMDS \
8188 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8189 awk '/ldlm_cancel/ {print $2}')
8190 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8191 awk '/ldlm_bl_callback/ {print $2}')
8192 mrename $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2
8194 can2=$(do_facet $SINGLEMDS \
8195 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8196 awk '/ldlm_cancel/ {print $2}')
8197 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8198 awk '/ldlm_bl_callback/ {print $2}')
8199 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
8200 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
8201 lru_resize_enable mdc
8202 lru_resize_enable osc
8204 run_test 120f "Early Lock Cancel: rename test"
8207 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8208 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
8209 skip "no early lock cancel on server" && return 0
8210 lru_resize_disable mdc
8211 lru_resize_disable osc
8213 echo create $count files
8214 test_mkdir -p $DIR/$tdir
8215 cancel_lru_locks mdc
8216 cancel_lru_locks osc
8219 can0=$(do_facet $SINGLEMDS \
8220 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8221 awk '/ldlm_cancel/ {print $2}')
8222 blk0=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8223 awk '/ldlm_bl_callback/ {print $2}')
8224 createmany -o $DIR/$tdir/f $count
8226 can1=$(do_facet $SINGLEMDS \
8227 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8228 awk '/ldlm_cancel/ {print $2}')
8229 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8230 awk '/ldlm_bl_callback/ {print $2}')
8232 echo total: $((can1-can0)) cancels, $((blk1-blk0)) blockings
8233 echo rm $count files
8236 can2=$(do_facet $SINGLEMDS \
8237 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8238 awk '/ldlm_cancel/ {print $2}')
8239 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8240 awk '/ldlm_bl_callback/ {print $2}')
8242 echo total: $count removes in $((t2-t1))
8243 echo total: $((can2-can1)) cancels, $((blk2-blk1)) blockings
8245 # wait for commitment of removal
8246 lru_resize_enable mdc
8247 lru_resize_enable osc
8249 run_test 120g "Early Lock Cancel: performance test"
8251 test_121() { #bug #10589
8252 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8254 writes=$(LANG=C dd if=/dev/zero of=$DIR/$tfile count=1 2>&1 | awk -F '+' '/out$/ {print $1}')
8255 #define OBD_FAIL_LDLM_CANCEL_RACE 0x310
8256 lctl set_param fail_loc=0x310
8257 cancel_lru_locks osc > /dev/null
8258 reads=$(LANG=C dd if=$DIR/$tfile of=/dev/null 2>&1 | awk -F '+' '/in$/ {print $1}')
8259 lctl set_param fail_loc=0
8260 [[ $reads -eq $writes ]] ||
8261 error "read $reads blocks, must be $writes blocks"
8263 run_test 121 "read cancel race ========="
8265 test_123a() { # was test 123, statahead(bug 11401)
8266 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8268 if [ -z "$(grep "processor.*: 1" /proc/cpuinfo)" ]; then
8269 log "testing on UP system. Performance may be not as good as expected."
8274 test_mkdir -p $DIR/$tdir
8275 NUMFREE=$(df -i -P $DIR | tail -n 1 | awk '{ print $4 }')
8276 [[ $NUMFREE -gt 100000 ]] && NUMFREE=100000 || NUMFREE=$((NUMFREE-1000))
8278 for ((i=100, j=0; i<=$NUMFREE; j=$i, i=$((i * MULT)) )); do
8279 createmany -o $DIR/$tdir/$tfile $j $((i - j))
8281 max=`lctl get_param -n llite.*.statahead_max | head -n 1`
8282 lctl set_param -n llite.*.statahead_max 0
8283 lctl get_param llite.*.statahead_max
8284 cancel_lru_locks mdc
8285 cancel_lru_locks osc
8287 time ls -l $DIR/$tdir | wc -l
8289 delta=$((etime - stime))
8290 log "ls $i files without statahead: $delta sec"
8291 lctl set_param llite.*.statahead_max=$max
8293 swrong=`lctl get_param -n llite.*.statahead_stats | grep "statahead wrong:" | awk '{print $3}'`
8294 lctl get_param -n llite.*.statahead_max | grep '[0-9]'
8295 cancel_lru_locks mdc
8296 cancel_lru_locks osc
8298 time ls -l $DIR/$tdir | wc -l
8300 delta_sa=$((etime - stime))
8301 log "ls $i files with statahead: $delta_sa sec"
8302 lctl get_param -n llite.*.statahead_stats
8303 ewrong=`lctl get_param -n llite.*.statahead_stats | grep "statahead wrong:" | awk '{print $3}'`
8305 [[ $swrong -lt $ewrong ]] &&
8306 log "statahead was stopped, maybe too many locks held!"
8307 [[ $delta -eq 0 || $delta_sa -eq 0 ]] && continue
8309 if [ $((delta_sa * 100)) -gt $((delta * 105)) -a $delta_sa -gt $((delta + 2)) ]; then
8310 max=`lctl get_param -n llite.*.statahead_max | head -n 1`
8311 lctl set_param -n llite.*.statahead_max 0
8312 lctl get_param llite.*.statahead_max
8313 cancel_lru_locks mdc
8314 cancel_lru_locks osc
8316 time ls -l $DIR/$tdir | wc -l
8318 delta=$((etime - stime))
8319 log "ls $i files again without statahead: $delta sec"
8320 lctl set_param llite.*.statahead_max=$max
8321 if [ $((delta_sa * 100)) -gt $((delta * 105)) -a $delta_sa -gt $((delta + 2)) ]; then
8322 if [ $SLOWOK -eq 0 ]; then
8323 error "ls $i files is slower with statahead!"
8325 log "ls $i files is slower with statahead!"
8331 [ $delta -gt 20 ] && break
8332 [ $delta -gt 8 ] && MULT=$((50 / delta))
8333 [ "$SLOW" = "no" -a $delta -gt 5 ] && break
8341 delta=$((etime - stime))
8342 log "rm -r $DIR/$tdir/: $delta seconds"
8344 lctl get_param -n llite.*.statahead_stats
8346 run_test 123a "verify statahead work"
8348 test_123b () { # statahead(bug 15027)
8349 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8350 test_mkdir -p $DIR/$tdir
8351 createmany -o $DIR/$tdir/$tfile-%d 1000
8353 cancel_lru_locks mdc
8354 cancel_lru_locks osc
8356 #define OBD_FAIL_MDC_GETATTR_ENQUEUE 0x803
8357 lctl set_param fail_loc=0x80000803
8358 ls -lR $DIR/$tdir > /dev/null
8360 lctl set_param fail_loc=0x0
8361 lctl get_param -n llite.*.statahead_stats
8366 run_test 123b "not panic with network error in statahead enqueue (bug 15027)"
8369 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8370 [ -z "$($LCTL get_param -n mdc.*.connect_flags | grep lru_resize)" ] &&
8371 skip "no lru resize on server" && return 0
8373 test_mkdir -p $DIR/$tdir || error "failed to create $DIR/$tdir"
8375 log "create $NR files at $DIR/$tdir"
8376 createmany -o $DIR/$tdir/f $NR ||
8377 error "failed to create $NR files in $DIR/$tdir"
8379 cancel_lru_locks mdc
8380 ls -l $DIR/$tdir > /dev/null
8384 for VALUE in $($LCTL get_param ldlm.namespaces.*mdc-*.lru_size); do
8385 local PARAM=$(echo ${VALUE[0]} | cut -d "=" -f1)
8386 LRU_SIZE=$($LCTL get_param -n $PARAM)
8387 if [[ $LRU_SIZE -gt $(default_lru_size) ]]; then
8388 NSDIR=$(echo $PARAM | cut -d "." -f1-3)
8390 log "NS=$(basename $NSDIR)"
8395 if [[ -z "$NSDIR" || $LRU_SIZE -lt $(default_lru_size) ]]; then
8396 skip "Not enough cached locks created!"
8403 # We know that lru resize allows one client to hold $LIMIT locks
8404 # for 10h. After that locks begin to be killed by client.
8406 local LIMIT=$($LCTL get_param -n $NSDIR.pool.limit)
8408 if [ $LIMIT -lt $LRU_SIZE ]; then
8409 skip "Limit is too small $LIMIT"
8413 # Make LVF so higher that sleeping for $SLEEP is enough to _start_
8414 # killing locks. Some time was spent for creating locks. This means
8415 # that up to the moment of sleep finish we must have killed some of
8416 # them (10-100 locks). This depends on how fast ther were created.
8417 # Many of them were touched in almost the same moment and thus will
8418 # be killed in groups.
8419 local LVF=$(($MAX_HRS * 60 * 60 / $SLEEP * $LIMIT / $LRU_SIZE))
8421 # Use $LRU_SIZE_B here to take into account real number of locks
8422 # created in the case of CMD, LRU_SIZE_B != $NR in most of cases
8423 local LRU_SIZE_B=$LRU_SIZE
8425 local OLD_LVF=$($LCTL get_param -n $NSDIR.pool.lock_volume_factor)
8426 log "OLD_LVF=$OLD_LVF"
8427 $LCTL set_param -n $NSDIR.pool.lock_volume_factor $LVF
8429 # Let's make sure that we really have some margin. Client checks
8430 # cached locks every 10 sec.
8432 log "Sleep ${SLEEP} sec"
8434 while ((SEC<$SLEEP)); do
8438 LRU_SIZE=$($LCTL get_param -n $NSDIR/lru_size)
8442 $LCTL set_param -n $NSDIR.pool.lock_volume_factor $OLD_LVF
8443 local LRU_SIZE_A=$($LCTL get_param -n $NSDIR.lru_size)
8445 [[ $LRU_SIZE_B -gt $LRU_SIZE_A ]] || {
8446 error "No locks dropped in ${SLEEP}s. LRU size: $LRU_SIZE_A"
8447 unlinkmany $DIR/$tdir/f $NR
8451 log "Dropped "$((LRU_SIZE_B-LRU_SIZE_A))" locks in ${SLEEP}s"
8452 log "unlink $NR files at $DIR/$tdir"
8453 unlinkmany $DIR/$tdir/f $NR
8455 run_test 124a "lru resize ======================================="
8457 get_max_pool_limit()
8459 local limit=$($LCTL get_param \
8460 -n ldlm.namespaces.*-MDT0000-mdc-*.pool.limit)
8463 if [[ $l -gt $max ]]; then
8471 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8472 [ -z "$($LCTL get_param -n mdc.*.connect_flags | grep lru_resize)" ] &&
8473 skip "no lru resize on server" && return 0
8475 LIMIT=$(get_max_pool_limit)
8477 NR=$(($(default_lru_size)*20))
8478 if [[ $NR -gt $LIMIT ]]; then
8479 log "Limit lock number by $LIMIT locks"
8482 lru_resize_disable mdc
8483 test_mkdir -p $DIR/$tdir/disable_lru_resize ||
8484 error "failed to create $DIR/$tdir/disable_lru_resize"
8486 createmany -o $DIR/$tdir/disable_lru_resize/f $NR
8487 log "doing ls -la $DIR/$tdir/disable_lru_resize 3 times"
8488 cancel_lru_locks mdc
8491 ls -la $DIR/$tdir/disable_lru_resize > /dev/null &
8494 ls -la $DIR/$tdir/disable_lru_resize > /dev/null &
8497 ls -la $DIR/$tdir/disable_lru_resize > /dev/null &
8501 nolruresize_delta=$((etime-stime))
8502 log "ls -la time: $nolruresize_delta seconds"
8503 log "lru_size = $(lctl get_param -n ldlm.namespaces.*mdc*.lru_size)"
8504 unlinkmany $DIR/$tdir/disable_lru_resize/f $NR
8506 lru_resize_enable mdc
8507 test_mkdir -p $DIR/$tdir/enable_lru_resize ||
8508 error "failed to create $DIR/$tdir/enable_lru_resize"
8510 createmany -o $DIR/$tdir/enable_lru_resize/f $NR
8511 log "doing ls -la $DIR/$tdir/enable_lru_resize 3 times"
8512 cancel_lru_locks mdc
8515 ls -la $DIR/$tdir/enable_lru_resize > /dev/null &
8518 ls -la $DIR/$tdir/enable_lru_resize > /dev/null &
8521 ls -la $DIR/$tdir/enable_lru_resize > /dev/null &
8525 lruresize_delta=$((etime-stime))
8526 log "ls -la time: $lruresize_delta seconds"
8527 log "lru_size = $(lctl get_param -n ldlm.namespaces.*mdc*.lru_size)"
8529 if [ $lruresize_delta -gt $nolruresize_delta ]; then
8530 log "ls -la is $(((lruresize_delta - $nolruresize_delta) * 100 / $nolruresize_delta))% slower with lru resize enabled"
8531 elif [ $nolruresize_delta -gt $lruresize_delta ]; then
8532 log "ls -la is $(((nolruresize_delta - $lruresize_delta) * 100 / $nolruresize_delta))% faster with lru resize enabled"
8534 log "lru resize performs the same with no lru resize"
8536 unlinkmany $DIR/$tdir/enable_lru_resize/f $NR
8538 run_test 124b "lru resize (performance test) ======================="
8541 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8542 [ -z "$($LCTL get_param -n mdc.*.connect_flags | grep lru_resize)" ] &&
8543 skip "no lru resize on server" && return 0
8545 # cache ununsed locks on client
8547 cancel_lru_locks mdc
8548 test_mkdir -p $DIR/$tdir || error "failed to create $DIR/$tdir"
8549 createmany -o $DIR/$tdir/f $nr ||
8550 error "failed to create $nr files in $DIR/$tdir"
8551 ls -l $DIR/$tdir > /dev/null
8553 local nsdir="ldlm.namespaces.*-MDT0000-mdc-*"
8554 local unused=$($LCTL get_param -n $nsdir.lock_unused_count)
8555 local max_age=$($LCTL get_param -n $nsdir.lru_max_age)
8556 local recalc_p=$($LCTL get_param -n $nsdir.pool.recalc_period)
8557 echo "unused=$unused, max_age=$max_age, recalc_p=$recalc_p"
8559 # set lru_max_age to 1 sec
8560 $LCTL set_param $nsdir.lru_max_age=1000 # jiffies
8561 echo "sleep $((recalc_p * 2)) seconds..."
8562 sleep $((recalc_p * 2))
8564 local remaining=$($LCTL get_param -n $nsdir.lock_unused_count)
8565 # restore lru_max_age
8566 $LCTL set_param -n $nsdir.lru_max_age $max_age
8567 [ $remaining -eq 0 ] || error "$remaining locks are not canceled"
8568 unlinkmany $DIR/$tdir/f $nr
8570 run_test 124c "LRUR cancel very aged locks"
8572 test_125() { # 13358
8573 [ -z "$(lctl get_param -n llite.*.client_type | grep local)" ] && skip "must run as local client" && return
8574 [ -z "$(lctl get_param -n mdc.*-mdc-*.connect_flags | grep acl)" ] && skip "must have acl enabled" && return
8575 [ -z "$(which setfacl)" ] && skip "must have setfacl tool" && return
8576 test_mkdir -p $DIR/d125 || error "mkdir failed"
8577 $SETSTRIPE -S 65536 -c -1 $DIR/d125 || error "setstripe failed"
8578 setfacl -R -m u:bin:rwx $DIR/d125 || error "setfacl $DIR/d125 failed"
8579 ls -ld $DIR/d125 || error "cannot access $DIR/d125"
8581 run_test 125 "don't return EPROTO when a dir has a non-default striping and ACLs"
8583 test_126() { # bug 12829/13455
8584 [ -z "$(lctl get_param -n llite.*.client_type | grep local)" ] && skip "must run as local client" && return
8585 [ "$UID" != 0 ] && skip_env "skipping $TESTNAME (must run as root)" && return
8586 $GSS && skip "must run as gss disabled" && return
8588 $RUNAS -u 0 -g 1 touch $DIR/$tfile || error "touch failed"
8589 gid=`ls -n $DIR/$tfile | awk '{print $4}'`
8591 [ $gid -eq "1" ] || error "gid is set to" $gid "instead of 1"
8593 run_test 126 "check that the fsgid provided by the client is taken into account"
8595 test_127a() { # bug 15521
8596 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8597 $SETSTRIPE -i 0 -c 1 $DIR/$tfile || error "setstripe failed"
8598 $LCTL set_param osc.*.stats=0
8599 FSIZE=$((2048 * 1024))
8600 dd if=/dev/zero of=$DIR/$tfile bs=$FSIZE count=1
8601 cancel_lru_locks osc
8602 dd if=$DIR/$tfile of=/dev/null bs=$FSIZE
8604 $LCTL get_param osc.*0000-osc-*.stats | grep samples > $DIR/${tfile}.tmp
8605 while read NAME COUNT SAMP UNIT MIN MAX SUM SUMSQ; do
8606 echo "got $COUNT $NAME"
8607 [ ! $MIN ] && error "Missing min value for $NAME proc entry"
8608 eval $NAME=$COUNT || error "Wrong proc format"
8611 read_bytes|write_bytes)
8612 [ $MIN -lt 4096 ] && error "min is too small: $MIN"
8613 [ $MIN -gt $FSIZE ] && error "min is too big: $MIN"
8614 [ $MAX -lt 4096 ] && error "max is too small: $MAX"
8615 [ $MAX -gt $FSIZE ] && error "max is too big: $MAX"
8616 [ $SUM -ne $FSIZE ] && error "sum is wrong: $SUM"
8617 [ $SUMSQ -lt $(((FSIZE /4096) * (4096 * 4096))) ] &&
8618 error "sumsquare is too small: $SUMSQ"
8619 [ $SUMSQ -gt $((FSIZE * FSIZE)) ] &&
8620 error "sumsquare is too big: $SUMSQ"
8624 done < $DIR/${tfile}.tmp
8626 #check that we actually got some stats
8627 [ "$read_bytes" ] || error "Missing read_bytes stats"
8628 [ "$write_bytes" ] || error "Missing write_bytes stats"
8629 [ "$read_bytes" != 0 ] || error "no read done"
8630 [ "$write_bytes" != 0 ] || error "no write done"
8632 run_test 127a "verify the client stats are sane"
8634 test_127b() { # bug LU-333
8635 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8636 $LCTL set_param llite.*.stats=0
8637 FSIZE=65536 # sized fixed to match PAGE_SIZE for most clients
8638 # perform 2 reads and writes so MAX is different from SUM.
8639 dd if=/dev/zero of=$DIR/$tfile bs=$FSIZE count=1
8640 dd if=/dev/zero of=$DIR/$tfile bs=$FSIZE count=1
8641 cancel_lru_locks osc
8642 dd if=$DIR/$tfile of=/dev/null bs=$FSIZE count=1
8643 dd if=$DIR/$tfile of=/dev/null bs=$FSIZE count=1
8645 $LCTL get_param llite.*.stats | grep samples > $TMP/${tfile}.tmp
8646 while read NAME COUNT SAMP UNIT MIN MAX SUM SUMSQ; do
8647 echo "got $COUNT $NAME"
8648 eval $NAME=$COUNT || error "Wrong proc format"
8652 [ $COUNT -ne 2 ] && error "count is not 2: $COUNT"
8653 [ $MIN -ne $FSIZE ] && error "min is not $FSIZE: $MIN"
8654 [ $MAX -ne $FSIZE ] && error "max is incorrect: $MAX"
8655 [ $SUM -ne $((FSIZE * 2)) ] && error "sum is wrong: $SUM"
8658 [ $COUNT -ne 2 ] && error "count is not 2: $COUNT"
8659 [ $MIN -ne $FSIZE ] && error "min is not $FSIZE: $MIN"
8660 [ $MAX -ne $FSIZE ] && error "max is incorrect: $MAX"
8661 [ $SUM -ne $((FSIZE * 2)) ] && error "sum is wrong: $SUM"
8665 done < $TMP/${tfile}.tmp
8667 #check that we actually got some stats
8668 [ "$read_bytes" ] || error "Missing read_bytes stats"
8669 [ "$write_bytes" ] || error "Missing write_bytes stats"
8670 [ "$read_bytes" != 0 ] || error "no read done"
8671 [ "$write_bytes" != 0 ] || error "no write done"
8673 run_test 127b "verify the llite client stats are sane"
8675 test_128() { # bug 15212
8677 $LFS 2>&1 <<-EOF | tee $TMP/$tfile.log
8682 result=$(grep error $TMP/$tfile.log)
8684 [ -z "$result" ] || error "consecutive find's under interactive lfs failed"
8686 run_test 128 "interactive lfs for 2 consecutive find's"
8693 local LDPROC=/proc/fs/ldiskfs
8694 local facets=$(get_facets MDS)
8696 for facet in ${facets//,/ }; do
8697 canondev=$(ldiskfs_canon \
8698 *.$(convert_facet2label $facet).mntdev $facet)
8699 do_facet $facet "test -e $LDPROC/$canondev/max_dir_size" ||
8700 LDPROC=/sys/fs/ldiskfs
8701 do_facet $facet "echo $1 >$LDPROC/$canondev/max_dir_size"
8702 do_facet $facet "test -e $LDPROC/$canondev/warning_dir_size" ||
8703 LDPROC=/sys/fs/ldiskfs
8704 do_facet $facet "echo $2 >$LDPROC/$canondev/warning_dir_size"
8709 local facets=$(get_facets MDS)
8710 for facet in ${facets//,/ }; do
8711 do_facet $facet "dmesg | tail -3 | grep -q $1" && return 0
8717 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8718 if [ "$(facet_fstype $SINGLEMDS)" != ldiskfs ]; then
8719 skip "Only applicable to ldiskfs-based MDTs"
8722 remote_mds_nodsh && skip "remote MDS with nodsh" && return
8728 test_mkdir -p $DIR/$tdir
8730 # block size of mds1
8731 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
8732 local MDSBLOCKSIZE=$($LCTL get_param -n mdc.*MDT0000*.blocksize)
8733 local MAX=$((MDSBLOCKSIZE * 5))
8734 set_dir_limits $MAX $MAX
8735 local I=$(stat -c%s "$DIR/$tdir")
8737 local STRIPE_COUNT=1
8738 [[ $MDSCOUNT -ge 2 ]] && STRIPE_COUNT=$($LFS getdirstripe -c $DIR/$tdir)
8739 MAX=$((MAX*STRIPE_COUNT))
8740 while [[ $I -le $MAX ]]; do
8741 $MULTIOP $DIR/$tdir/$J Oc
8743 if [ $has_warning -eq 0 ]; then
8744 check_mds_dmesg '"is approaching"' &&
8747 #check two errors ENOSPC for new version of ext4 max_dir_size patch
8748 #mainline kernel commit df981d03eeff7971ac7e6ff37000bfa702327ef1
8749 #and EFBIG for previous versions
8750 if [ $rc -eq $EFBIG -o $rc -eq $ENOSPC ]; then
8752 echo "return code $rc received as expected"
8753 multiop $DIR/$tdir/$J Oc ||
8754 error_exit "multiop failed w/o dir size limit"
8756 check_mds_dmesg '"has reached"' ||
8757 error_exit "has reached message should be output"
8760 error_exit "warning message should be output"
8762 I=$(stat -c%s "$DIR/$tdir")
8764 if [ $(lustre_version_code $SINGLEMDS) -lt \
8765 $(version_code 2.4.51) ]
8767 [[ $I -eq $MAX ]] && return 0
8769 [[ $I -gt $MAX ]] && return 0
8771 error_exit "current dir size $I, previous limit $MAX"
8772 elif [ $rc -ne 0 ]; then
8774 error_exit "return code $rc received instead of expected " \
8775 "$EFBIG or $ENOSPC, files in dir $I"
8778 I=$(stat -c%s "$DIR/$tdir")
8782 error "exceeded dir size limit $MAX($MDSCOUNT) : $I bytes"
8784 run_test 129 "test directory size limit ========================"
8793 local filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
8794 [ -n "$filefrag_op" ] && skip_env "filefrag does not support FIEMAP" &&
8797 trap cleanup_130 EXIT RETURN
8799 local fm_file=$DIR/$tfile
8800 $SETSTRIPE -S 65536 -c 1 $fm_file || error "setstripe on $fm_file"
8801 dd if=/dev/zero of=$fm_file bs=65536 count=1 ||
8802 error "dd failed for $fm_file"
8804 # LU-1795: test filefrag/FIEMAP once, even if unsupported
8805 filefrag -ves $fm_file
8807 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
8808 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
8809 [ $RC != 0 ] && error "filefrag $fm_file failed"
8811 filefrag_op=$(filefrag -ve $fm_file | grep -A 100 "ext:" |
8812 grep -v "ext:" | grep -v "found")
8813 lun=$($GETSTRIPE -i $fm_file)
8815 start_blk=`echo $filefrag_op | cut -d: -f2 | cut -d. -f1`
8818 for line in $filefrag_op
8820 frag_lun=`echo $line | cut -d: -f5`
8821 ext_len=`echo $line | cut -d: -f4`
8822 if (( $frag_lun != $lun )); then
8824 error "FIEMAP on 1-stripe file($fm_file) failed"
8827 (( tot_len += ext_len ))
8830 if (( lun != frag_lun || start_blk != 0 || tot_len != 64 )); then
8832 error "FIEMAP on 1-stripe file($fm_file) failed;"
8838 echo "FIEMAP on single striped file succeeded"
8840 run_test 130a "FIEMAP (1-stripe file)"
8843 [ "$OSTCOUNT" -lt "2" ] &&
8844 skip_env "skipping FIEMAP on 2-stripe file test" && return
8846 [ "$OSTCOUNT" -ge "10" ] &&
8847 skip_env "skipping FIEMAP with >= 10 OSTs" && return
8849 local filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
8850 [ -n "$filefrag_op" ] && skip_env "filefrag does not support FIEMAP" &&
8853 trap cleanup_130 EXIT RETURN
8855 local fm_file=$DIR/$tfile
8856 $SETSTRIPE -S 65536 -c 2 $fm_file || error "setstripe on $fm_file"
8857 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
8858 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
8860 dd if=/dev/zero of=$fm_file bs=1M count=2 ||
8861 error "dd failed on $fm_file"
8863 filefrag -ves $fm_file || error "filefrag $fm_file failed"
8864 filefrag_op=$(filefrag -ve $fm_file | grep -A 100 "ext:" |
8865 grep -v "ext:" | grep -v "found")
8867 last_lun=$(echo $filefrag_op | cut -d: -f5)
8872 for line in $filefrag_op
8874 frag_lun=`echo $line | cut -d: -f5`
8875 ext_len=`echo $line | cut -d: -f4`
8876 if (( $frag_lun != $last_lun )); then
8877 if (( tot_len != 1024 )); then
8879 error "FIEMAP on $fm_file failed; returned len $tot_len for OST $last_lun instead of 256"
8886 (( tot_len += ext_len ))
8889 if (( num_luns != 2 || tot_len != 1024 )); then
8891 error "FIEMAP on $fm_file failed; returned wrong number of luns or wrong len for OST $last_lun"
8897 echo "FIEMAP on 2-stripe file succeeded"
8899 run_test 130b "FIEMAP (2-stripe file)"
8902 [ "$OSTCOUNT" -lt "2" ] &&
8903 skip_env "skipping FIEMAP on 2-stripe file" && return
8905 [ "$OSTCOUNT" -ge "10" ] &&
8906 skip_env "skipping FIEMAP with >= 10 OSTs" && return
8908 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
8909 [ -n "$filefrag_op" ] && skip "filefrag does not support FIEMAP" &&
8912 trap cleanup_130 EXIT RETURN
8914 local fm_file=$DIR/$tfile
8915 $SETSTRIPE -S 65536 -c 2 $fm_file || error "setstripe on $fm_file"
8916 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
8917 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
8919 dd if=/dev/zero of=$fm_file seek=1 bs=1M count=1 || error "dd failed on $fm_file"
8921 filefrag -ves $fm_file || error "filefrag $fm_file failed"
8922 filefrag_op=`filefrag -ve $fm_file | grep -A 100 "ext:" | grep -v "ext:" | grep -v "found"`
8924 last_lun=`echo $filefrag_op | cut -d: -f5`
8929 for line in $filefrag_op
8931 frag_lun=`echo $line | cut -d: -f5`
8932 ext_len=`echo $line | cut -d: -f4`
8933 if (( $frag_lun != $last_lun )); then
8934 logical=`echo $line | cut -d: -f2 | cut -d. -f1`
8935 if (( logical != 512 )); then
8937 error "FIEMAP on $fm_file failed; returned logical start for lun $logical instead of 512"
8940 if (( tot_len != 512 )); then
8942 error "FIEMAP on $fm_file failed; returned len $tot_len for OST $last_lun instead of 1024"
8949 (( tot_len += ext_len ))
8952 if (( num_luns != 2 || tot_len != 512 )); then
8954 error "FIEMAP on $fm_file failed; returned wrong number of luns or wrong len for OST $last_lun"
8960 echo "FIEMAP on 2-stripe file with hole succeeded"
8962 run_test 130c "FIEMAP (2-stripe file with hole)"
8965 [ "$OSTCOUNT" -lt "3" ] && skip_env "skipping FIEMAP on N-stripe file test" && return
8967 [ "$OSTCOUNT" -ge "10" ] &&
8968 skip_env "skipping FIEMAP with >= 10 OSTs" && return
8970 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
8971 [ -n "$filefrag_op" ] && skip "filefrag does not support FIEMAP" && return
8973 trap cleanup_130 EXIT RETURN
8975 local fm_file=$DIR/$tfile
8976 $SETSTRIPE -S 65536 -c $OSTCOUNT $fm_file||error "setstripe on $fm_file"
8977 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
8978 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
8980 local actual_stripecnt=$($GETSTRIPE -c $fm_file)
8981 dd if=/dev/zero of=$fm_file bs=1M count=$actual_stripecnt ||
8982 error "dd failed on $fm_file"
8984 filefrag -ves $fm_file || error "filefrag $fm_file failed"
8985 filefrag_op=`filefrag -ve $fm_file | grep -A 100 "ext:" |
8986 grep -v "ext:" | grep -v "found"`
8988 last_lun=`echo $filefrag_op | cut -d: -f5`
8993 for line in $filefrag_op
8995 frag_lun=`echo $line | cut -d: -f5`
8996 ext_len=`echo $line | cut -d: -f4`
8997 if (( $frag_lun != $last_lun )); then
8998 if (( tot_len != 1024 )); then
9000 error "FIEMAP on $fm_file failed; returned len $tot_len for OST $last_lun instead of 1024"
9007 (( tot_len += ext_len ))
9010 if (( num_luns != actual_stripecnt || tot_len != 1024 )); then
9012 error "FIEMAP on $fm_file failed; returned wrong number of luns or wrong len for OST $last_lun"
9018 echo "FIEMAP on N-stripe file succeeded"
9020 run_test 130d "FIEMAP (N-stripe file)"
9023 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping continuation FIEMAP test" && return
9025 [ "$OSTCOUNT" -ge "10" ] &&
9026 skip_env "skipping FIEMAP with >= 10 OSTs" && return
9028 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
9029 [ -n "$filefrag_op" ] && skip "filefrag does not support FIEMAP" && return
9031 trap cleanup_130 EXIT RETURN
9033 local fm_file=$DIR/$tfile
9034 $SETSTRIPE -S 131072 -c 2 $fm_file || error "setstripe on $fm_file"
9035 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
9036 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
9039 EXPECTED_LEN=$(( (NUM_BLKS / 2) * 64 ))
9040 for ((i = 0; i < $NUM_BLKS; i++))
9042 dd if=/dev/zero of=$fm_file count=1 bs=64k seek=$((2*$i)) conv=notrunc > /dev/null 2>&1
9045 filefrag -ves $fm_file || error "filefrag $fm_file failed"
9046 filefrag_op=`filefrag -ve $fm_file | grep -A 12000 "ext:" | grep -v "ext:" | grep -v "found"`
9048 last_lun=`echo $filefrag_op | cut -d: -f5`
9053 for line in $filefrag_op
9055 frag_lun=`echo $line | cut -d: -f5`
9056 ext_len=`echo $line | cut -d: -f4`
9057 if (( $frag_lun != $last_lun )); then
9058 if (( tot_len != $EXPECTED_LEN )); then
9060 error "FIEMAP on $fm_file failed; returned len $tot_len for OST $last_lun instead of $EXPECTED_LEN"
9067 (( tot_len += ext_len ))
9070 if (( num_luns != 2 || tot_len != $EXPECTED_LEN )); then
9072 error "FIEMAP on $fm_file failed; returned wrong number of luns or wrong len for OST $last_lun"
9078 echo "FIEMAP with continuation calls succeeded"
9080 run_test 130e "FIEMAP (test continuation FIEMAP calls)"
9082 # Test for writev/readv
9084 rwv -f $DIR/$tfile -w -n 3 524288 1048576 1572864 || \
9085 error "writev test failed"
9086 rwv -f $DIR/$tfile -r -v -n 2 1572864 1048576 || \
9087 error "readv failed"
9090 run_test 131a "test iov's crossing stripe boundary for writev/readv"
9093 rwv -f $DIR/$tfile -w -a -n 3 524288 1048576 1572864 || \
9094 error "append writev test failed"
9095 rwv -f $DIR/$tfile -w -a -n 2 1572864 1048576 || \
9096 error "append writev test failed"
9099 run_test 131b "test append writev"
9102 rwv -f $DIR/$tfile -w -d -n 1 1048576 || return 0
9105 run_test 131c "test read/write on file w/o objects"
9108 rwv -f $DIR/$tfile -w -n 1 1572864
9109 NOB=`rwv -f $DIR/$tfile -r -n 3 524288 524288 1048576 | awk '/error/ {print $6}'`
9110 if [ "$NOB" != 1572864 ]; then
9111 error "Short read filed: read $NOB bytes instead of 1572864"
9115 run_test 131d "test short read"
9118 rwv -f $DIR/$tfile -w -s 1048576 -n 1 1048576
9119 rwv -f $DIR/$tfile -r -z -s 0 -n 1 524288 || \
9120 error "read hitting hole failed"
9123 run_test 131e "test read hitting hole"
9129 $SINGLEMDS) res=`do_facet $SINGLEMDS $LCTL get_param mdt.$FSNAME-MDT0000.md_stats | grep "$2"`
9131 ost) res=`do_facet ost1 $LCTL get_param obdfilter.$FSNAME-OST0000.stats | grep "$2"`
9133 *) error "Wrong argument $1" ;;
9136 [ -z "$res" ] && error "The counter for $2 on $1 was not incremented"
9137 # if the argument $3 is zero, it means any stat increment is ok.
9138 if [[ $3 -gt 0 ]]; then
9139 count=$(echo $res | awk '{ print $2 }')
9140 [[ $count -ne $3 ]] &&
9141 error "The $2 counter on $1 is wrong - expected $3"
9146 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9147 remote_ost_nodsh && skip "remote OST with nodsh" && return
9148 remote_mds_nodsh && skip "remote MDS with nodsh" && return
9150 do_facet $SINGLEMDS $LCTL list_param mdt.*.rename_stats ||
9151 { skip "MDS doesn't support rename stats"; return; }
9152 local testdir=$DIR/${tdir}/stats_testdir
9153 mkdir -p $DIR/${tdir}
9156 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
9157 do_facet ost1 $LCTL set_param obdfilter.*.stats=clear
9159 # verify mdt stats first.
9160 mkdir ${testdir} || error "mkdir failed"
9161 check_stats $SINGLEMDS "mkdir" 1
9162 touch ${testdir}/${tfile} || "touch failed"
9163 check_stats $SINGLEMDS "open" 1
9164 check_stats $SINGLEMDS "close" 1
9165 mknod ${testdir}/${tfile}-pipe p || "mknod failed"
9166 check_stats $SINGLEMDS "mknod" 1
9167 rm -f ${testdir}/${tfile}-pipe || "pipe remove failed"
9168 check_stats $SINGLEMDS "unlink" 1
9169 rm -f ${testdir}/${tfile} || error "file remove failed"
9170 check_stats $SINGLEMDS "unlink" 2
9172 # remove working dir and check mdt stats again.
9173 rmdir ${testdir} || error "rmdir failed"
9174 check_stats $SINGLEMDS "rmdir" 1
9176 local testdir1=$DIR/${tdir}/stats_testdir1
9178 mkdir -p ${testdir1}
9179 touch ${testdir1}/test1
9180 mv ${testdir1}/test1 ${testdir} || error "file crossdir rename"
9181 check_stats $SINGLEMDS "crossdir_rename" 1
9183 mv ${testdir}/test1 ${testdir}/test0 || error "file samedir rename"
9184 check_stats $SINGLEMDS "samedir_rename" 1
9188 run_test 133a "Verifying MDT stats ========================================"
9191 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9192 remote_ost_nodsh && skip "remote OST with nodsh" && return
9193 remote_mds_nodsh && skip "remote MDS with nodsh" && return
9194 local testdir=$DIR/${tdir}/stats_testdir
9195 mkdir -p ${testdir} || error "mkdir failed"
9196 touch ${testdir}/${tfile} || "touch failed"
9197 cancel_lru_locks mdc
9200 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
9201 do_facet ost1 $LCTL set_param obdfilter.*.stats=clear
9203 # extra mdt stats verification.
9204 chmod 444 ${testdir}/${tfile} || error "chmod failed"
9205 check_stats $SINGLEMDS "setattr" 1
9206 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
9207 if [ $(lustre_version_code $SINGLEMDS) -ne $(version_code 2.2.0) ]
9209 ls -l ${testdir}/${tfile} > /dev/null|| error "ls failed"
9210 check_stats $SINGLEMDS "getattr" 1
9212 $LFS df || error "lfs failed"
9213 check_stats $SINGLEMDS "statfs" 1
9217 run_test 133b "Verifying extra MDT stats =================================="
9220 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9221 remote_ost_nodsh && skip "remote OST with nodsh" && return
9222 remote_mds_nodsh && skip "remote MDS with nodsh" && return
9223 local testdir=$DIR/${tdir}/stats_testdir
9224 test_mkdir -p ${testdir} || error "mkdir failed"
9226 # verify obdfilter stats.
9227 $SETSTRIPE -c 1 -i 0 ${testdir}/${tfile}
9229 cancel_lru_locks osc
9230 wait_delete_completed
9233 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
9234 do_facet ost1 $LCTL set_param obdfilter.*.stats=clear
9236 dd if=/dev/zero of=${testdir}/${tfile} conv=notrunc bs=512k count=1 || error "dd failed"
9238 cancel_lru_locks osc
9239 check_stats ost "write" 1
9241 dd if=${testdir}/${tfile} of=/dev/null bs=1k count=1 || error "dd failed"
9242 check_stats ost "read" 1
9244 > ${testdir}/${tfile} || error "truncate failed"
9245 check_stats ost "punch" 1
9247 rm -f ${testdir}/${tfile} || error "file remove failed"
9248 wait_delete_completed
9249 check_stats ost "destroy" 1
9253 run_test 133c "Verifying OST stats ========================================"
9260 while [ $value -ge 2 ]; do
9265 if [ $orig -gt $order ]; then
9273 local size=('K' 'M' 'G' 'T');
9275 local size_string=$value
9277 while [ $value -ge 1024 ]; do
9278 if [ $i -gt 3 ]; then
9279 #T is the biggest unit we get here, if that is bigger,
9281 size_string=${value}T
9284 value=$((value >> 10))
9285 if [ $value -lt 1024 ]; then
9286 size_string=${value}${size[$i]}
9297 local context=${2:-.}
9298 local sample=$(do_facet $SINGLEMDS $LCTL get_param mdt.*.rename_stats |
9300 awk '/ '${size}'/ {print $4}' | sed -e "s/,//g")
9305 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9306 remote_ost_nodsh && skip "remote OST with nodsh" && return
9307 remote_mds_nodsh && skip "remote MDS with nodsh" && return
9308 do_facet $SINGLEMDS $LCTL list_param mdt.*.rename_stats ||
9309 { skip "MDS doesn't support rename stats"; return; }
9311 local testdir1=$DIR/${tdir}/stats_testdir1
9312 local testdir2=$DIR/${tdir}/stats_testdir2
9314 do_facet $SINGLEMDS $LCTL set_param mdt.*.rename_stats=clear
9316 mkdir -p ${testdir1} || error "mkdir failed"
9317 mkdir -p ${testdir2} || error "mkdir failed"
9319 createmany -o $testdir1/test 512 || error "createmany failed"
9321 # check samedir rename size
9322 mv ${testdir1}/test0 ${testdir1}/test_0
9324 local testdir1_size=$(ls -l $DIR/${tdir} |
9325 awk '/stats_testdir1/ {print $5}')
9326 local testdir2_size=$(ls -l $DIR/${tdir} |
9327 awk '/stats_testdir2/ {print $5}')
9329 testdir1_size=$(order_2 $testdir1_size)
9330 testdir2_size=$(order_2 $testdir2_size)
9332 testdir1_size=$(size_in_KMGT $testdir1_size)
9333 testdir2_size=$(size_in_KMGT $testdir2_size)
9335 echo "source rename dir size: ${testdir1_size}"
9336 echo "target rename dir size: ${testdir2_size}"
9338 local cmd="do_facet $SINGLEMDS $LCTL get_param mdt.*.rename_stats"
9339 eval $cmd || error "$cmd failed"
9340 local samedir=$($cmd | grep 'same_dir')
9341 local same_sample=$(get_rename_size $testdir1_size)
9342 [ -z "$samedir" ] && error "samedir_rename_size count error"
9343 [[ $same_sample -eq 1 ]] ||
9344 error "samedir_rename_size error $same_sample"
9345 echo "Check same dir rename stats success"
9347 do_facet $SINGLEMDS $LCTL set_param mdt.*.rename_stats=clear
9349 # check crossdir rename size
9350 mv ${testdir1}/test_0 ${testdir2}/test_0
9352 testdir1_size=$(ls -l $DIR/${tdir} |
9353 awk '/stats_testdir1/ {print $5}')
9354 testdir2_size=$(ls -l $DIR/${tdir} |
9355 awk '/stats_testdir2/ {print $5}')
9357 testdir1_size=$(order_2 $testdir1_size)
9358 testdir2_size=$(order_2 $testdir2_size)
9360 testdir1_size=$(size_in_KMGT $testdir1_size)
9361 testdir2_size=$(size_in_KMGT $testdir2_size)
9363 echo "source rename dir size: ${testdir1_size}"
9364 echo "target rename dir size: ${testdir2_size}"
9366 eval $cmd || error "$cmd failed"
9367 local crossdir=$($cmd | grep 'crossdir')
9368 local src_sample=$(get_rename_size $testdir1_size crossdir_src)
9369 local tgt_sample=$(get_rename_size $testdir2_size crossdir_tgt)
9370 [ -z "$crossdir" ] && error "crossdir_rename_size count error"
9371 [[ $src_sample -eq 1 ]] ||
9372 error "crossdir_rename_size error $src_sample"
9373 [[ $tgt_sample -eq 1 ]] ||
9374 error "crossdir_rename_size error $tgt_sample"
9375 echo "Check cross dir rename stats success"
9378 run_test 133d "Verifying rename_stats ========================================"
9381 remote_mds_nodsh && skip "remote MDS with nodsh" && return
9382 remote_ost_nodsh && skip "remote OST with nodsh" && return
9383 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9384 local testdir=$DIR/${tdir}/stats_testdir
9385 local ctr f0 f1 bs=32768 count=42 sum
9387 mkdir -p ${testdir} || error "mkdir failed"
9389 $SETSTRIPE -c 1 -i 0 ${testdir}/${tfile}
9391 for ctr in {write,read}_bytes; do
9393 cancel_lru_locks osc
9395 do_facet ost1 $LCTL set_param -n \
9396 "obdfilter.*.exports.clear=clear"
9398 if [ $ctr = write_bytes ]; then
9400 f1=${testdir}/${tfile}
9402 f0=${testdir}/${tfile}
9406 dd if=$f0 of=$f1 conv=notrunc bs=$bs count=$count || \
9409 cancel_lru_locks osc
9411 sum=$(do_facet ost1 $LCTL get_param \
9412 "obdfilter.*.exports.*.stats" |
9413 awk -v ctr=$ctr 'BEGIN { sum = 0 }
9414 $1 == ctr { sum += $7 }
9415 END { printf("%0.0f", sum) }')
9417 if ((sum != bs * count)); then
9418 error "Bad $ctr sum, expected $((bs * count)), got $sum"
9424 run_test 133e "Verifying OST {read,write}_bytes nid stats ================="
9429 local dirs="/proc/fs/lustre/ /proc/sys/lnet/ /proc/sys/lustre/ \
9430 /sys/fs/lustre/ /sys/fs/lnet/"
9432 for dir in $dirs; do
9433 if [ -d $dir ]; then
9434 proc_dirs="$proc_dirs $dir"
9440 remote_mds_nodsh && skip "remote MDS with nodsh" && return
9441 remote_ost_nodsh && skip "remote OST with nodsh" && return
9442 # First without trusting modes.
9443 find $proc_dirs -exec cat '{}' \; &> /dev/null
9445 # Second verifying readability.
9448 -exec cat '{}' \; &> /dev/null ||
9449 error "proc file read failed"
9451 for facet in $SINGLEMDS ost1; do
9452 do_facet $facet find $proc_dirs \
9453 ! -name req_history \
9454 -exec cat '{}' \\\; &> /dev/null
9456 do_facet $facet find $proc_dirs \
9457 ! -name req_history \
9459 -exec cat '{}' \\\; &> /dev/null ||
9460 error "proc file read failed"
9463 run_test 133f "Check for LBUGs/Oopses/unreadable files in /proc"
9468 local dirs="/proc/fs/lustre/ /proc/sys/lnet/ /proc/sys/lustre/ \
9469 /sys/fs/lustre/ /sys/fs/lnet/"
9471 for dir in $dirs; do
9472 if [ -d $dir ]; then
9473 proc_dirs="$proc_dirs $dir"
9479 # Second verifying readability.
9482 -not -name force_lbug \
9483 -not -name changelog_mask \
9484 -exec badarea_io '{}' \; &> /dev/null ||
9485 error "find $proc_dirs failed"
9487 [ $(lustre_version_code $SINGLEMDS) -le $(version_code 2.5.54) ] &&
9488 skip "Too old lustre on MDS" && return
9490 [ $(lustre_version_code ost1) -le $(version_code 2.5.54) ] &&
9491 skip "Too old lustre on ost1" && return
9493 for facet in $SINGLEMDS ost1; do
9494 do_facet $facet find $proc_dirs \
9496 -not -name force_lbug \
9497 -not -name changelog_mask \
9498 -exec badarea_io '{}' \\\; &> /dev/null ||
9499 error "$facet find $proc_dirs failed"
9503 # remount the FS in case writes/reads /proc break the FS
9504 cleanup || error "failed to unmount"
9505 setup || error "failed to setup"
9508 run_test 133g "Check for Oopses on bad io area writes/reads in /proc"
9511 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.54) ]] &&
9512 skip "Need MDS version at least 2.7.54" && return
9514 mkdir -p $DIR/$tdir || error "failed to create $DIR/$tdir"
9515 cancel_lru_locks mdc
9517 local nsdir="ldlm.namespaces.*-MDT0000-mdc-*"
9518 local unused=$($LCTL get_param -n $nsdir.lock_unused_count)
9519 [ $unused -eq 0 ] || "$unused locks are not cleared"
9522 createmany -o $DIR/$tdir/f $nr ||
9523 error "failed to create $nr files in $DIR/$tdir"
9524 unused=$($LCTL get_param -n $nsdir.lock_unused_count)
9526 #define OBD_FAIL_LDLM_WATERMARK_LOW 0x327
9527 do_facet mds1 $LCTL set_param fail_loc=0x327
9528 do_facet mds1 $LCTL set_param fail_val=500
9531 echo "sleep 10 seconds ..."
9533 local lck_cnt=$($LCTL get_param -n $nsdir.lock_unused_count)
9535 do_facet mds1 $LCTL set_param fail_loc=0
9536 do_facet mds1 $LCTL set_param fail_val=0
9537 [ $lck_cnt -lt $unused ] ||
9538 error "No locks reclaimed, before:$unused, after:$lck_cnt"
9541 unlinkmany $DIR/$tdir/f $nr
9543 run_test 134a "Server reclaims locks when reaching lock_reclaim_threshold"
9546 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.54) ]] &&
9547 skip "Need MDS version at least 2.7.54" && return
9549 mkdir -p $DIR/$tdir || error "failed to create $DIR/$tdir"
9550 cancel_lru_locks mdc
9552 local low_wm=$(do_facet mds1 $LCTL get_param -n \
9553 ldlm.lock_reclaim_threshold_mb)
9554 # disable reclaim temporarily
9555 do_facet mds1 $LCTL set_param ldlm.lock_reclaim_threshold_mb=0
9557 #define OBD_FAIL_LDLM_WATERMARK_HIGH 0x328
9558 do_facet mds1 $LCTL set_param fail_loc=0x328
9559 do_facet mds1 $LCTL set_param fail_val=500
9561 $LCTL set_param debug=+trace
9564 createmany -o $DIR/$tdir/f $nr &
9567 echo "Sleep $TIMEOUT seconds ..."
9569 if ! ps -p $create_pid > /dev/null 2>&1; then
9570 do_facet mds1 $LCTL set_param fail_loc=0
9571 do_facet mds1 $LCTL set_param fail_val=0
9572 do_facet mds1 $LCTL set_param \
9573 ldlm.lock_reclaim_threshold_mb=${low_wm}m
9574 error "createmany finished incorrectly!"
9576 do_facet mds1 $LCTL set_param fail_loc=0
9577 do_facet mds1 $LCTL set_param fail_val=0
9578 do_facet mds1 $LCTL set_param ldlm.lock_reclaim_threshold_mb=${low_wm}m
9579 wait $create_pid || return 1
9581 unlinkmany $DIR/$tdir/f $nr
9583 run_test 134b "Server rejects lock request when reaching lock_limit_mb"
9585 test_140() { #bug-17379
9586 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9587 test_mkdir -p $DIR/$tdir || error "Creating dir $DIR/$tdir"
9588 cd $DIR/$tdir || error "Changing to $DIR/$tdir"
9589 cp /usr/bin/stat . || error "Copying stat to $DIR/$tdir"
9591 # VFS limits max symlink depth to 5(4KSTACK) or 7(8KSTACK) or 8
9592 # For kernel > 3.5, bellow only tests consecutive symlink (MAX 40)
9594 while i=`expr $i + 1`; do
9595 test_mkdir -p $i || error "Creating dir $i"
9596 cd $i || error "Changing to $i"
9597 ln -s ../stat stat || error "Creating stat symlink"
9598 # Read the symlink until ELOOP present,
9599 # not LBUGing the system is considered success,
9600 # we didn't overrun the stack.
9601 $OPENFILE -f O_RDONLY stat >/dev/null 2>&1; ret=$?
9603 if [ $ret -eq 40 ]; then
9606 error "Open stat symlink"
9612 echo "The symlink depth = $i"
9613 [ $i -eq 5 -o $i -eq 7 -o $i -eq 8 -o $i -eq 40 ] ||
9614 error "Invalid symlink depth"
9616 # Test recursive symlink
9617 ln -s symlink_self symlink_self
9618 $OPENFILE -f O_RDONLY symlink_self >/dev/null 2>&1; ret=$?
9619 echo "open symlink_self returns $ret"
9620 [ $ret -eq 40 ] || error "recursive symlink doesn't return -ELOOP"
9622 run_test 140 "Check reasonable stack depth (shouldn't LBUG) ===="
9625 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9626 local TF="$TMP/$tfile"
9628 dd if=/dev/urandom of=$TF bs=6096 count=1 || error "dd failed"
9630 cancel_lru_locks osc
9631 cmp $TF $DIR/$tfile || error "$TMP/$tfile $DIR/$tfile differ"
9632 remount_client $MOUNT
9634 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (remount)"
9637 $TRUNCATE $DIR/$tfile 6000
9638 cancel_lru_locks osc
9639 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (truncate1)"
9642 echo "12345" >>$DIR/$tfile
9643 cancel_lru_locks osc
9644 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (append1)"
9647 echo "12345" >>$DIR/$tfile
9648 cancel_lru_locks osc
9649 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (append2)"
9654 run_test 150 "truncate/append tests"
9656 #LU-2902 roc_hit was not able to read all values from lproc
9657 function roc_hit_init() {
9658 local list=$(comma_list $(osts_nodes))
9659 local dir=$DIR/$tdir-check
9660 local file=$dir/file
9666 #use setstripe to do a write to every ost
9667 for i in $(seq 0 $((OSTCOUNT-1))); do
9668 $SETSTRIPE -c 1 -i $i $dir || error "$SETSTRIPE $file failed"
9669 dd if=/dev/urandom of=$file bs=4k count=4 2>&1 > /dev/null
9670 idx=$(printf %04x $i)
9671 BEFORE=$(get_osd_param $list *OST*$idx stats |
9672 awk '$1 == "cache_access" {sum += $7}
9673 END { printf("%0.0f", sum) }')
9675 cancel_lru_locks osc
9676 cat $file >/dev/null
9678 AFTER=$(get_osd_param $list *OST*$idx stats |
9679 awk '$1 == "cache_access" {sum += $7}
9680 END { printf("%0.0f", sum) }')
9682 echo BEFORE:$BEFORE AFTER:$AFTER
9683 if ! let "AFTER - BEFORE == 4"; then
9685 error "roc_hit is not safe to use"
9693 function roc_hit() {
9694 local list=$(comma_list $(osts_nodes))
9695 echo $(get_osd_param $list '' stats |
9696 awk '$1 == "cache_hit" {sum += $7}
9697 END { printf("%0.0f", sum) }')
9700 function set_cache() {
9703 if [ "$2" == "off" ]; then
9706 local list=$(comma_list $(osts_nodes))
9707 set_osd_param $list '' $1_cache_enable $on
9709 cancel_lru_locks osc
9713 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9714 remote_ost_nodsh && skip "remote OST with nodsh" && return
9717 local list=$(comma_list $(osts_nodes))
9719 # check whether obdfilter is cache capable at all
9720 if ! get_osd_param $list '' read_cache_enable >/dev/null; then
9721 echo "not cache-capable obdfilter"
9725 # check cache is enabled on all obdfilters
9726 if get_osd_param $list '' read_cache_enable | grep 0; then
9727 echo "oss cache is disabled"
9731 set_osd_param $list '' writethrough_cache_enable 1
9733 # check write cache is enabled on all obdfilters
9734 if get_osd_param $list '' writethrough_cache_enable | grep 0; then
9735 echo "oss write cache is NOT enabled"
9741 #define OBD_FAIL_OBD_NO_LRU 0x609
9742 do_nodes $list $LCTL set_param fail_loc=0x609
9744 # pages should be in the case right after write
9745 dd if=/dev/urandom of=$DIR/$tfile bs=4k count=$CPAGES ||
9748 local BEFORE=$(roc_hit)
9749 cancel_lru_locks osc
9750 cat $DIR/$tfile >/dev/null
9751 local AFTER=$(roc_hit)
9753 do_nodes $list $LCTL set_param fail_loc=0
9755 if ! let "AFTER - BEFORE == CPAGES"; then
9756 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
9759 # the following read invalidates the cache
9760 cancel_lru_locks osc
9761 set_osd_param $list '' read_cache_enable 0
9762 cat $DIR/$tfile >/dev/null
9764 # now data shouldn't be found in the cache
9766 cancel_lru_locks osc
9767 cat $DIR/$tfile >/dev/null
9769 if let "AFTER - BEFORE != 0"; then
9770 error "IN CACHE: before: $BEFORE, after: $AFTER"
9773 set_osd_param $list '' read_cache_enable 1
9776 run_test 151 "test cache on oss and controls ==============================="
9779 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9780 local TF="$TMP/$tfile"
9782 # simulate ENOMEM during write
9783 #define OBD_FAIL_OST_NOMEM 0x226
9784 lctl set_param fail_loc=0x80000226
9785 dd if=/dev/urandom of=$TF bs=6096 count=1 || error "dd failed"
9787 sync || error "sync failed"
9788 lctl set_param fail_loc=0
9790 # discard client's cache
9791 cancel_lru_locks osc
9793 # simulate ENOMEM during read
9794 lctl set_param fail_loc=0x80000226
9795 cmp $TF $DIR/$tfile || error "cmp failed"
9796 lctl set_param fail_loc=0
9800 run_test 152 "test read/write with enomem ============================"
9803 $MULTIOP $DIR/$tfile Ow4096Ycu || error "multiop failed"
9805 run_test 153 "test if fdatasync does not crash ======================="
9807 dot_lustre_fid_permission_check() {
9809 local ffid=$MOUNT/.lustre/fid/$fid
9812 echo "stat fid $fid"
9813 stat $ffid > /dev/null || error "stat $ffid failed."
9814 echo "touch fid $fid"
9815 touch $ffid || error "touch $ffid failed."
9816 echo "write to fid $fid"
9817 cat /etc/hosts > $ffid || error "write $ffid failed."
9818 echo "read fid $fid"
9819 diff /etc/hosts $ffid || error "read $ffid failed."
9820 echo "append write to fid $fid"
9821 cat /etc/hosts >> $ffid || error "append write $ffid failed."
9822 echo "rename fid $fid"
9823 mv $ffid $test_dir/$tfile.1 &&
9824 error "rename $ffid to $tfile.1 should fail."
9825 touch $test_dir/$tfile.1
9826 mv $test_dir/$tfile.1 $ffid &&
9827 error "rename $tfile.1 to $ffid should fail."
9828 rm -f $test_dir/$tfile.1
9829 echo "truncate fid $fid"
9830 $TRUNCATE $ffid 777 || error "truncate $ffid failed."
9831 if [ $MDSCOUNT -lt 2 ]; then #FIXME when cross-MDT hard link is working
9832 echo "link fid $fid"
9833 ln -f $ffid $test_dir/tfile.lnk || error "link $ffid failed."
9835 if [ -n $(lctl get_param -n mdc.*-mdc-*.connect_flags | grep acl) ]; then
9836 echo "setfacl fid $fid"
9837 setfacl -R -m u:bin:rwx $ffid || error "setfacl $ffid failed."
9838 echo "getfacl fid $fid"
9839 getfacl $ffid >/dev/null || error "getfacl $ffid failed."
9841 echo "unlink fid $fid"
9842 unlink $MOUNT/.lustre/fid/$fid && error "unlink $ffid should fail."
9843 echo "mknod fid $fid"
9844 mknod $ffid c 1 3 && error "mknod $ffid should fail."
9846 fid=[0xf00000400:0x1:0x0]
9847 ffid=$MOUNT/.lustre/fid/$fid
9849 echo "stat non-exist fid $fid"
9850 stat $ffid > /dev/null && error "stat non-exist $ffid should fail."
9851 echo "write to non-exist fid $fid"
9852 cat /etc/hosts > $ffid && error "write non-exist $ffid should fail."
9853 echo "link new fid $fid"
9854 ln $test_dir/$tfile $ffid && error "link $ffid should fail."
9856 mkdir -p $test_dir/$tdir
9857 touch $test_dir/$tdir/$tfile
9858 fid=$($LFS path2fid $test_dir/$tdir)
9861 error "error: could not get fid for $test_dir/$dir/$tfile."
9863 ffid=$MOUNT/.lustre/fid/$fid
9866 ls $ffid > /dev/null || error "ls $ffid failed."
9867 echo "touch $fid/$tfile.1"
9868 touch $ffid/$tfile.1 || error "touch $ffid/$tfile.1 failed."
9870 echo "touch $MOUNT/.lustre/fid/$tfile"
9871 touch $MOUNT/.lustre/fid/$tfile && \
9872 error "touch $MOUNT/.lustre/fid/$tfile should fail."
9874 echo "setxattr to $MOUNT/.lustre/fid"
9875 setfattr -n trusted.name1 -v value1 $MOUNT/.lustre/fid
9877 echo "listxattr for $MOUNT/.lustre/fid"
9878 getfattr -d -m "^trusted" $MOUNT/.lustre/fid
9880 echo "delxattr from $MOUNT/.lustre/fid"
9881 setfattr -x trusted.name1 $MOUNT/.lustre/fid
9883 echo "touch invalid fid: $MOUNT/.lustre/fid/[0x200000400:0x2:0x3]"
9884 touch $MOUNT/.lustre/fid/[0x200000400:0x2:0x3] &&
9885 error "touch invalid fid should fail."
9887 echo "touch non-normal fid: $MOUNT/.lustre/fid/[0x1:0x2:0x0]"
9888 touch $MOUNT/.lustre/fid/[0x1:0x2:0x0] &&
9889 error "touch non-normal fid should fail."
9891 echo "rename $tdir to $MOUNT/.lustre/fid"
9892 mrename $test_dir/$tdir $MOUNT/.lustre/fid &&
9893 error "rename to $MOUNT/.lustre/fid should fail."
9895 if [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.3.51) ]
9897 local old_obf_mode=$(stat --format="%a" $DIR/.lustre/fid)
9898 local new_obf_mode=777
9900 echo "change mode of $DIR/.lustre/fid to $new_obf_mode"
9901 chmod $new_obf_mode $DIR/.lustre/fid ||
9902 error "chmod $new_obf_mode $DIR/.lustre/fid failed"
9904 local obf_mode=$(stat --format=%a $DIR/.lustre/fid)
9905 [ $obf_mode -eq $new_obf_mode ] ||
9906 error "stat $DIR/.lustre/fid returned wrong mode $obf_mode"
9908 echo "restore mode of $DIR/.lustre/fid to $old_obf_mode"
9909 chmod $old_obf_mode $DIR/.lustre/fid ||
9910 error "chmod $old_obf_mode $DIR/.lustre/fid failed"
9913 $OPENFILE -f O_LOV_DELAY_CREATE:O_CREAT $test_dir/$tfile-2
9914 fid=$($LFS path2fid $test_dir/$tfile-2)
9916 if [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.6.50) ]
9918 echo "cp /etc/passwd $MOUNT/.lustre/fid/$fid"
9919 cp /etc/passwd $MOUNT/.lustre/fid/$fid ||
9920 error "create lov data thru .lustre failed"
9922 echo "cp /etc/passwd $test_dir/$tfile-2"
9923 cp /etc/passwd $test_dir/$tfile-2 ||
9924 error "copy to $test_dir/$tfile-2 failed."
9925 echo "diff /etc/passwd $MOUNT/.lustre/fid/$fid"
9926 diff /etc/passwd $MOUNT/.lustre/fid/$fid ||
9927 error "diff /etc/passwd $MOUNT/.lustre/fid/$fid failed."
9929 rm -rf $test_dir/tfile.lnk
9930 rm -rf $test_dir/$tfile-2
9934 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.1) ]] &&
9935 skip "Need MDS version at least 2.4.1" && return
9938 local FID=$($LFS path2fid $DIR/$tfile)
9939 [ -z "$FID" ] && error "path2fid unable to get $DIR/$tfile FID"
9941 # check that we get the same pathname back
9942 local FOUND=$($LFS fid2path $MOUNT "$FID")
9943 [ -z "$FOUND" ] && error "fid2path unable to get $FID path"
9944 [ "$FOUND" != "$DIR/$tfile" ] &&
9945 error "fid2path(path2fid($DIR/$tfile)) = $FOUND != $DIR/$tfile"
9949 run_test 154A "lfs path2fid and fid2path basic checks"
9952 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9953 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.51) ]] ||
9954 { skip "Need MDS version at least 2.2.51"; return 0; }
9955 [ -z "$(which setfacl)" ] && skip "must have setfacl tool" && return
9957 cp /etc/hosts $DIR/$tfile
9959 fid=$($LFS path2fid $DIR/$tfile)
9961 [ $rc -ne 0 ] && error "error: could not get fid for $DIR/$tfile."
9963 dot_lustre_fid_permission_check "$fid" $DIR ||
9964 error "dot lustre permission check $fid failed"
9966 rm -rf $MOUNT/.lustre && error ".lustre is not allowed to be unlinked"
9968 touch $MOUNT/.lustre/file &&
9969 error "creation is not allowed under .lustre"
9971 mkdir $MOUNT/.lustre/dir &&
9972 error "mkdir is not allowed under .lustre"
9976 run_test 154a "Open-by-FID"
9979 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9980 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.51) ]] ||
9981 { skip "Need MDS version at least 2.2.51"; return 0; }
9983 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
9985 local remote_dir=$DIR/$tdir/remote_dir
9990 $LFS mkdir -i $MDTIDX $remote_dir ||
9991 error "create remote directory failed"
9993 cp /etc/hosts $remote_dir/$tfile
9995 fid=$($LFS path2fid $remote_dir/$tfile)
9997 [ $rc -ne 0 ] && error "error: could not get fid for $remote_dir/$tfile"
9999 dot_lustre_fid_permission_check "$fid" $remote_dir ||
10000 error "dot lustre permission check $fid failed"
10003 run_test 154b "Open-by-FID for remote directory"
10006 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.1) ]] &&
10007 skip "Need MDS version at least 2.4.1" && return
10009 touch $DIR/$tfile.1 $DIR/$tfile.2 $DIR/$tfile.3
10010 local FID1=$($LFS path2fid $DIR/$tfile.1)
10011 local FID2=$($LFS path2fid $DIR/$tfile.2)
10012 local FID3=$($LFS path2fid $DIR/$tfile.3)
10015 $LFS path2fid $DIR/$tfile.[123] | while read PATHNAME FID; do
10016 [ "$PATHNAME" = "$DIR/$tfile.$N:" ] ||
10017 error "path2fid pathname $PATHNAME != $DIR/$tfile.$N:"
10019 [ "$FID" = "${!want}" ] ||
10020 error "path2fid $PATHNAME FID $FID != FID$N ${!want}"
10024 $LFS fid2path $MOUNT "$FID1" "$FID2" "$FID3" | while read PATHNAME;
10026 [ "$PATHNAME" = "$DIR/$tfile.$N" ] ||
10027 error "fid2path pathname $PATHNAME != $DIR/$tfile.$N:"
10031 run_test 154c "lfs path2fid and fid2path multiple arguments"
10034 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.5.53) ]] &&
10035 skip "Need MDS version at least 2.5.53" && return
10037 if remote_mds; then
10038 nid=$($LCTL list_nids | sed "s/\./\\\./g")
10042 local proc_ofile="mdt.*.exports.'$nid'.open_files"
10049 local fid=$($LFS path2fid $DIR/$tfile)
10052 cmd="exec $fd<$DIR/$tfile"
10054 local fid_list=$(do_facet $SINGLEMDS $LCTL get_param $proc_ofile)
10055 echo "$fid_list" | grep "$fid"
10058 cmd="exec $fd>/dev/null"
10060 if [ $rc -ne 0 ]; then
10061 error "FID $fid not found in open files list $fid_list"
10064 run_test 154d "Verify open file fid"
10068 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.6.50) ]] &&
10069 skip "Need MDS version at least 2.6.50" && return
10071 if ls -a $MOUNT | grep -q '^\.lustre$'; then
10072 error ".lustre returned by readdir"
10075 run_test 154e ".lustre is not returned by readdir"
10078 # create parent directory on a single MDT to avoid cross-MDT hardlinks
10079 test_mkdir -p -c1 $DIR/$tdir/d
10080 # test dirs inherit from its stripe
10081 mkdir -p $DIR/$tdir/d/foo1 || error "mkdir error"
10082 mkdir -p $DIR/$tdir/d/foo2 || error "mkdir error"
10083 cp /etc/hosts $DIR/$tdir/d/foo1/$tfile
10084 ln $DIR/$tdir/d/foo1/$tfile $DIR/$tdir/d/foo2/link
10087 # get fid of parents
10088 local FID0=$($LFS path2fid $DIR/$tdir/d)
10089 local FID1=$($LFS path2fid $DIR/$tdir/d/foo1)
10090 local FID2=$($LFS path2fid $DIR/$tdir/d/foo2)
10091 local FID3=$($LFS path2fid $DIR)
10093 # check that path2fid --parents returns expected <parent_fid>/name
10094 # 1) test for a directory (single parent)
10095 local parent=$($LFS path2fid --parents $DIR/$tdir/d/foo1)
10096 [ "$parent" == "$FID0/foo1" ] ||
10097 error "expected parent: $FID0/foo1, got: $parent"
10099 # 2) test for a file with nlink > 1 (multiple parents)
10100 parent=$($LFS path2fid --parents $DIR/$tdir/d/foo1/$tfile)
10101 echo "$parent" | grep -F "$FID1/$tfile" ||
10102 error "$FID1/$tfile not returned in parent list"
10103 echo "$parent" | grep -F "$FID2/link" ||
10104 error "$FID2/link not returned in parent list"
10106 # 3) get parent by fid
10107 local file_fid=$($LFS path2fid $DIR/$tdir/d/foo1/$tfile)
10108 parent=$($LFS path2fid --parents $MOUNT/.lustre/fid/$file_fid)
10109 echo "$parent" | grep -F "$FID1/$tfile" ||
10110 error "$FID1/$tfile not returned in parent list (by fid)"
10111 echo "$parent" | grep -F "$FID2/link" ||
10112 error "$FID2/link not returned in parent list (by fid)"
10114 # 4) test for entry in root directory
10115 parent=$($LFS path2fid --parents $DIR/f)
10116 echo "$parent" | grep -F "$FID3/f" ||
10117 error "$FID3/f not returned in parent list"
10119 # 5) test it on root directory
10120 [ -z "$($LFS path2fid --parents $MOUNT 2>/dev/null)" ] ||
10121 error "$MOUNT should not have parents"
10123 # enable xattr caching and check that linkea is correctly updated
10124 local save="$TMP/$TESTSUITE-$TESTNAME.parameters"
10125 save_lustre_params client "llite.*.xattr_cache" > $save
10126 lctl set_param llite.*.xattr_cache 1
10128 # 6.1) linkea update on rename
10129 mv $DIR/$tdir/d/foo1/$tfile $DIR/$tdir/d/foo2/$tfile.moved
10131 # get parents by fid
10132 parent=$($LFS path2fid --parents $MOUNT/.lustre/fid/$file_fid)
10133 # foo1 should no longer be returned in parent list
10134 echo "$parent" | grep -F "$FID1" &&
10135 error "$FID1 should no longer be in parent list"
10136 # the new path should appear
10137 echo "$parent" | grep -F "$FID2/$tfile.moved" ||
10138 error "$FID2/$tfile.moved is not in parent list"
10140 # 6.2) linkea update on unlink
10141 rm -f $DIR/$tdir/d/foo2/link
10142 parent=$($LFS path2fid --parents $MOUNT/.lustre/fid/$file_fid)
10143 # foo2/link should no longer be returned in parent list
10144 echo "$parent" | grep -F "$FID2/link" &&
10145 error "$FID2/link should no longer be in parent list"
10149 restore_lustre_params < $save
10151 run_test 154f "get parent fids by reading link ea"
10155 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.6.92) ]] ||
10156 { skip "Need MDS version at least 2.6.92"; return 0; }
10158 mkdir -p $DIR/$tdir
10159 llapi_fid_test -d $DIR/$tdir
10161 run_test 154g "various llapi FID tests"
10163 test_155_small_load() {
10164 local temp=$TMP/$tfile
10165 local file=$DIR/$tfile
10167 dd if=/dev/urandom of=$temp bs=6096 count=1 || \
10168 error "dd of=$temp bs=6096 count=1 failed"
10170 cancel_lru_locks osc
10171 cmp $temp $file || error "$temp $file differ"
10173 $TRUNCATE $temp 6000
10174 $TRUNCATE $file 6000
10175 cmp $temp $file || error "$temp $file differ (truncate1)"
10177 echo "12345" >>$temp
10178 echo "12345" >>$file
10179 cmp $temp $file || error "$temp $file differ (append1)"
10181 echo "12345" >>$temp
10182 echo "12345" >>$file
10183 cmp $temp $file || error "$temp $file differ (append2)"
10189 test_155_big_load() {
10190 remote_ost_nodsh && skip "remote OST with nodsh" && return
10191 local temp=$TMP/$tfile
10192 local file=$DIR/$tfile
10195 local cache_size=$(do_facet ost$((MAXI+1)) \
10196 "awk '/cache/ {sum+=\\\$4} END {print sum}' /proc/cpuinfo")
10197 local large_file_size=$((cache_size * 2))
10199 echo "OSS cache size: $cache_size KB"
10200 echo "Large file size: $large_file_size KB"
10202 [ $MAXV -le $large_file_size ] && \
10203 skip_env "max available OST size needs > $large_file_size KB" && \
10206 $SETSTRIPE $file -c 1 -i $MAXI || error "$SETSTRIPE $file failed"
10208 dd if=/dev/urandom of=$temp bs=$large_file_size count=1k || \
10209 error "dd of=$temp bs=$large_file_size count=1k failed"
10212 cancel_lru_locks osc
10213 cmp $temp $file || error "$temp $file differ"
10220 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10222 set_cache writethrough on
10223 test_155_small_load
10225 run_test 155a "Verify small file correctness: read cache:on write_cache:on"
10228 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10230 set_cache writethrough off
10231 test_155_small_load
10233 run_test 155b "Verify small file correctness: read cache:on write_cache:off"
10236 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10238 set_cache writethrough on
10239 test_155_small_load
10241 run_test 155c "Verify small file correctness: read cache:off write_cache:on"
10244 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10246 set_cache writethrough off
10247 test_155_small_load
10249 run_test 155d "Verify small file correctness: read cache:off write_cache:off"
10252 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10254 set_cache writethrough on
10257 run_test 155e "Verify big file correctness: read cache:on write_cache:on"
10260 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10262 set_cache writethrough off
10265 run_test 155f "Verify big file correctness: read cache:on write_cache:off"
10268 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10270 set_cache writethrough on
10273 run_test 155g "Verify big file correctness: read cache:off write_cache:on"
10276 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10278 set_cache writethrough off
10281 run_test 155h "Verify big file correctness: read cache:off write_cache:off"
10284 remote_ost_nodsh && skip "remote OST with nodsh" && return
10285 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10289 local file="$DIR/$tfile"
10291 [ "$(facet_fstype ost1)" = "zfs" -a \
10292 $(lustre_version_code ost1 -lt $(version_code 2.6.93)) ] &&
10293 skip "LU-1956/LU-2261: stats not implemented on OSD ZFS" &&
10298 log "Turn on read and write cache"
10300 set_cache writethrough on
10302 log "Write data and read it back."
10303 log "Read should be satisfied from the cache."
10304 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
10306 cancel_lru_locks osc
10307 cat $file >/dev/null
10309 if ! let "AFTER - BEFORE == CPAGES"; then
10310 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
10312 log "cache hits:: before: $BEFORE, after: $AFTER"
10315 log "Read again; it should be satisfied from the cache."
10317 cancel_lru_locks osc
10318 cat $file >/dev/null
10320 if ! let "AFTER - BEFORE == CPAGES"; then
10321 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
10323 log "cache hits:: before: $BEFORE, after: $AFTER"
10326 log "Turn off the read cache and turn on the write cache"
10328 set_cache writethrough on
10330 log "Read again; it should be satisfied from the cache."
10332 cancel_lru_locks osc
10333 cat $file >/dev/null
10335 if ! let "AFTER - BEFORE == CPAGES"; then
10336 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
10338 log "cache hits:: before: $BEFORE, after: $AFTER"
10341 log "Read again; it should not be satisfied from the cache."
10343 cancel_lru_locks osc
10344 cat $file >/dev/null
10346 if ! let "AFTER - BEFORE == 0"; then
10347 error "IN CACHE: before: $BEFORE, after: $AFTER"
10349 log "cache hits:: before: $BEFORE, after: $AFTER"
10352 log "Write data and read it back."
10353 log "Read should be satisfied from the cache."
10354 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
10356 cancel_lru_locks osc
10357 cat $file >/dev/null
10359 if ! let "AFTER - BEFORE == CPAGES"; then
10360 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
10362 log "cache hits:: before: $BEFORE, after: $AFTER"
10365 log "Read again; it should not be satisfied from the cache."
10367 cancel_lru_locks osc
10368 cat $file >/dev/null
10370 if ! let "AFTER - BEFORE == 0"; then
10371 error "IN CACHE: before: $BEFORE, after: $AFTER"
10373 log "cache hits:: before: $BEFORE, after: $AFTER"
10376 log "Turn off read and write cache"
10378 set_cache writethrough off
10380 log "Write data and read it back"
10381 log "It should not be satisfied from the cache."
10383 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
10384 cancel_lru_locks osc
10386 cat $file >/dev/null
10388 if ! let "AFTER - BEFORE == 0"; then
10389 error_ignore bz20762 "IN CACHE: before: $BEFORE, after: $AFTER"
10391 log "cache hits:: before: $BEFORE, after: $AFTER"
10394 log "Turn on the read cache and turn off the write cache"
10396 set_cache writethrough off
10398 log "Write data and read it back"
10399 log "It should not be satisfied from the cache."
10401 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
10403 cancel_lru_locks osc
10404 cat $file >/dev/null
10406 if ! let "AFTER - BEFORE == 0"; then
10407 error_ignore bz20762 "IN CACHE: before: $BEFORE, after: $AFTER"
10409 log "cache hits:: before: $BEFORE, after: $AFTER"
10412 log "Read again; it should be satisfied from the cache."
10414 cancel_lru_locks osc
10415 cat $file >/dev/null
10417 if ! let "AFTER - BEFORE == CPAGES"; then
10418 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
10420 log "cache hits:: before: $BEFORE, after: $AFTER"
10425 run_test 156 "Verification of tunables"
10429 if [[ $MDSCOUNT -gt 1 ]]; then
10430 error_ignore bz17935 $*
10438 local CL_MASK_PARAM="mdd.$MDT0.changelog_mask"
10440 MASK=$(do_facet $SINGLEMDS $LCTL get_param $CL_MASK_PARAM| grep -c "$1")
10442 if [ $MASK -eq 1 ]; then
10443 do_facet $SINGLEMDS $LCTL set_param $CL_MASK_PARAM="-$1"
10445 do_facet $SINGLEMDS $LCTL set_param $CL_MASK_PARAM="+$1"
10449 changelog_extract_field() {
10453 local identifier=$4
10455 $LFS changelog $mdt | gawk "/$cltype.*$file$/ {
10456 print gensub(/^.* "$identifier'(\[[^\]]*\]).*$/,"\\1",1)}' |
10461 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10462 remote_mds_nodsh && skip "remote MDS with nodsh" && return
10463 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] ||
10464 { skip "Need MDS version at least 2.2.0"; return; }
10466 local CL_USERS="mdd.$MDT0.changelog_users"
10467 local GET_CL_USERS="do_facet $SINGLEMDS $LCTL get_param -n $CL_USERS"
10468 USER=$(do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_register -n)
10469 echo "Registered as changelog user $USER"
10470 $GET_CL_USERS | grep -q $USER ||
10471 error "User $USER not found in changelog_users"
10474 test_mkdir -p $DIR/$tdir/pics/2008/zachy
10475 touch $DIR/$tdir/pics/2008/zachy/timestamp
10476 cp /etc/hosts $DIR/$tdir/pics/2008/zachy/pic1.jpg
10477 mv $DIR/$tdir/pics/2008/zachy $DIR/$tdir/pics/zach
10478 ln $DIR/$tdir/pics/zach/pic1.jpg $DIR/$tdir/pics/2008/portland.jpg
10479 ln -s $DIR/$tdir/pics/2008/portland.jpg $DIR/$tdir/pics/desktop.jpg
10480 rm $DIR/$tdir/pics/desktop.jpg
10482 $LFS changelog $MDT0 | tail -5
10484 echo "verifying changelog mask"
10485 changelog_chmask "MKDIR"
10486 changelog_chmask "CLOSE"
10488 test_mkdir -p $DIR/$tdir/pics/zach/sofia
10489 echo "zzzzzz" > $DIR/$tdir/pics/zach/file
10491 changelog_chmask "MKDIR"
10492 changelog_chmask "CLOSE"
10494 test_mkdir -p $DIR/$tdir/pics/2008/sofia
10495 echo "zzzzzz" > $DIR/$tdir/pics/zach/file
10497 $LFS changelog $MDT0
10498 MKDIRS=$($LFS changelog $MDT0 | tail -5 | grep -c "MKDIR")
10499 CLOSES=$($LFS changelog $MDT0 | tail -5 | grep -c "CLOSE")
10500 [ $MKDIRS -eq 1 ] || err17935 "MKDIR changelog mask count $DIRS != 1"
10501 [ $CLOSES -eq 1 ] || err17935 "CLOSE changelog mask count $DIRS != 1"
10504 echo "verifying target fid"
10505 fidc=$(changelog_extract_field $MDT0 "CREAT" "timestamp" "t=")
10506 fidf=$($LFS path2fid $DIR/$tdir/pics/zach/timestamp)
10507 [ "$fidc" == "$fidf" ] ||
10508 err17935 "fid in changelog $fidc != file fid $fidf"
10509 echo "verifying parent fid"
10510 fidc=$(changelog_extract_field $MDT0 "CREAT" "timestamp" "p=")
10511 fidf=$($LFS path2fid $DIR/$tdir/pics/zach)
10512 [ "$fidc" == "$fidf" ] ||
10513 err17935 "pfid in changelog $fidc != dir fid $fidf"
10515 USER_REC1=$($GET_CL_USERS | awk "\$1 == \"$USER\" {print \$2}")
10516 $LFS changelog_clear $MDT0 $USER $(($USER_REC1 + 5))
10517 USER_REC2=$($GET_CL_USERS | awk "\$1 == \"$USER\" {print \$2}")
10518 echo "verifying user clear: $(( $USER_REC1 + 5 )) == $USER_REC2"
10519 [ $USER_REC2 == $(($USER_REC1 + 5)) ] ||
10520 err17935 "user index expected $(($USER_REC1 + 5)) is $USER_REC2"
10522 MIN_REC=$($GET_CL_USERS |
10523 awk 'min == "" || $2 < min {min = $2}; END {print min}')
10524 FIRST_REC=$($LFS changelog $MDT0 | head -n1 | awk '{print $1}')
10525 echo "verifying min purge: $(( $MIN_REC + 1 )) == $FIRST_REC"
10526 [ $FIRST_REC == $(($MIN_REC + 1)) ] ||
10527 err17935 "first index should be $(($MIN_REC + 1)) is $FIRST_REC"
10529 # LU-3446 changelog index reset on MDT restart
10530 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
10531 CUR_REC1=$($GET_CL_USERS | head -n1 | cut -f3 -d' ')
10532 $LFS changelog_clear $MDT0 $USER 0
10533 stop $SINGLEMDS || error "Fail to stop MDT."
10534 start $SINGLEMDS $MDT_DEV $MDS_MOUNT_OPTS || error "Fail to start MDT."
10535 CUR_REC2=$($GET_CL_USERS | head -n1 | cut -f3 -d' ')
10536 echo "verifying index survives MDT restart: $CUR_REC1 == $CUR_REC2"
10537 [ $CUR_REC1 == $CUR_REC2 ] ||
10538 err17935 "current index should be $CUR_REC1 is $CUR_REC2"
10540 echo "verifying user deregister"
10541 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister $USER
10542 $GET_CL_USERS | grep -q $USER &&
10543 error "User $USER still in changelog_users"
10545 USERS=$(( $($GET_CL_USERS | wc -l) - 2 ))
10546 if [ $USERS -eq 0 ]; then
10547 LAST_REC1=$($GET_CL_USERS | head -n1 | cut -f3 -d' ')
10548 touch $DIR/$tdir/chloe
10549 LAST_REC2=$($GET_CL_USERS | head -n1 | cut -f3 -d' ')
10550 echo "verify changelogs are off: $LAST_REC1 == $LAST_REC2"
10551 [ $LAST_REC1 == $LAST_REC2 ] || error "changelogs not off"
10553 echo "$USERS other changelog users; can't verify off"
10556 run_test 160a "changelog sanity"
10558 test_160b() { # LU-3587
10559 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10560 remote_mds_nodsh && skip "remote MDS with nodsh" && return
10561 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] ||
10562 { skip "Need MDS version at least 2.2.0"; return; }
10564 local CL_USERS="mdd.$MDT0.changelog_users"
10565 local GET_CL_USERS="do_facet $SINGLEMDS $LCTL get_param -n $CL_USERS"
10566 USER=$(do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_register -n)
10567 echo "Registered as changelog user $USER"
10568 $GET_CL_USERS | grep -q $USER ||
10569 error "User $USER not found in changelog_users"
10571 local LONGNAME1=$(str_repeat a 255)
10572 local LONGNAME2=$(str_repeat b 255)
10575 echo "creating very long named file"
10576 touch $LONGNAME1 || error "create of $LONGNAME1 failed"
10577 echo "moving very long named file"
10578 mv $LONGNAME1 $LONGNAME2
10580 $LFS changelog $MDT0 | grep RENME
10582 echo "deregistering $USER"
10583 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister $USER
10587 run_test 160b "Verify that very long rename doesn't crash in changelog"
10590 remote_mds_nodsh && skip "remote MDS with nodsh" && return
10593 local server_version=$(lustre_version_code $SINGLEMDS)
10595 [[ $server_version -gt $(version_code 2.5.57) ]] ||
10596 [[ $server_version -gt $(version_code 2.5.1) &&
10597 $server_version -lt $(version_code 2.5.50) ]] ||
10598 { skip "Need MDS version at least 2.5.58 or 2.5.2+"; return; }
10599 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10601 # Registration step
10602 local USER=$(do_facet $SINGLEMDS $LCTL --device $MDT0 \
10603 changelog_register -n)
10606 mkdir -p $DIR/$tdir
10607 $MCREATE $DIR/$tdir/foo_160c
10608 changelog_chmask "TRUNC"
10609 $TRUNCATE $DIR/$tdir/foo_160c 200
10610 changelog_chmask "TRUNC"
10611 $TRUNCATE $DIR/$tdir/foo_160c 199
10612 $LFS changelog $MDT0
10613 TRUNCS=$($LFS changelog $MDT0 | tail -5 | grep -c "TRUNC")
10614 [ $TRUNCS -eq 1 ] || err17935 "TRUNC changelog mask count $TRUNCS != 1"
10615 $LFS changelog_clear $MDT0 $USER 0
10617 # Deregistration step
10618 echo "deregistering $USER"
10619 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister $USER
10621 run_test 160c "verify that changelog log catch the truncate event"
10624 remote_mds_nodsh && skip "remote MDS with nodsh" && return
10625 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
10627 local server_version=$(lustre_version_code mds1)
10628 local CL_MASK_PARAM="mdd.$MDT0.changelog_mask"
10630 [[ $server_version -ge $(version_code 2.7.60) ]] ||
10631 { skip "Need MDS version at least 2.7.60+"; return; }
10632 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10634 # Registration step
10635 local USER=$(do_facet mds1 $LCTL --device $MDT0 \
10636 changelog_register -n)
10638 mkdir -p $DIR/$tdir/migrate_dir
10639 $LFS changelog_clear $MDT0 $USER 0
10641 $LFS migrate -m 1 $DIR/$tdir/migrate_dir || error "migrate fails"
10642 $LFS changelog $MDT0
10643 MIGRATES=$($LFS changelog $MDT0 | tail -5 | grep -c "MIGRT")
10644 $LFS changelog_clear $MDT0 $USER 0
10645 [ $MIGRATES -eq 1 ] ||
10646 error "MIGRATE changelog mask count $MIGRATES != 1"
10648 # Deregistration step
10649 do_facet mds1 $LCTL --device $MDT0 changelog_deregister $USER
10651 run_test 160d "verify that changelog log catch the migrate event"
10654 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10655 test_mkdir -p -c1 $DIR/$tdir
10656 cp /etc/hosts $DIR/$tdir/$tfile
10657 test_mkdir -c1 $DIR/$tdir/foo1
10658 test_mkdir -c1 $DIR/$tdir/foo2
10659 ln $DIR/$tdir/$tfile $DIR/$tdir/foo1/sofia
10660 ln $DIR/$tdir/$tfile $DIR/$tdir/foo2/zachary
10661 ln $DIR/$tdir/$tfile $DIR/$tdir/foo1/luna
10662 ln $DIR/$tdir/$tfile $DIR/$tdir/foo2/thor
10663 local FID=$($LFS path2fid $DIR/$tdir/$tfile | tr -d '[]')
10664 if [ "$($LFS fid2path $DIR $FID | wc -l)" != "5" ]; then
10665 $LFS fid2path $DIR $FID
10666 err17935 "bad link ea"
10669 rm $DIR/$tdir/foo2/zachary
10671 rm $DIR/$tdir/foo2/thor
10673 rm $DIR/$tdir/$tfile
10675 mv $DIR/$tdir/foo1/sofia $DIR/$tdir/foo2/maggie
10676 if [ "$($LFS fid2path $FSNAME --link 1 $FID)" != "$tdir/foo2/maggie" ]
10678 $LFS fid2path $DIR $FID
10679 err17935 "bad link rename"
10681 rm $DIR/$tdir/foo2/maggie
10684 local longname=filename_avg_len_is_thirty_two_
10685 createmany -l$DIR/$tdir/foo1/luna $DIR/$tdir/foo2/$longname 1000 ||
10686 error "failed to hardlink many files"
10687 links=$($LFS fid2path $DIR $FID | wc -l)
10688 echo -n "${links}/1000 links in link EA"
10689 [[ $links -gt 60 ]] ||
10690 err17935 "expected at least 60 links in link EA"
10691 unlinkmany $DIR/$tdir/foo2/$longname 1000 ||
10692 error "failed to unlink many hardlinks"
10694 run_test 161a "link ea sanity"
10697 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10698 [ $MDSCOUNT -lt 2 ] &&
10699 skip "skipping remote directory test" && return
10701 local remote_dir=$DIR/$tdir/remote_dir
10703 mkdir -p $DIR/$tdir
10704 $LFS mkdir -i $MDTIDX $remote_dir ||
10705 error "create remote directory failed"
10707 cp /etc/hosts $remote_dir/$tfile
10708 mkdir -p $remote_dir/foo1
10709 mkdir -p $remote_dir/foo2
10710 ln $remote_dir/$tfile $remote_dir/foo1/sofia
10711 ln $remote_dir/$tfile $remote_dir/foo2/zachary
10712 ln $remote_dir/$tfile $remote_dir/foo1/luna
10713 ln $remote_dir/$tfile $remote_dir/foo2/thor
10715 local FID=$($LFS path2fid $remote_dir/$tfile | tr -d '[' |
10717 if [ "$($LFS fid2path $DIR $FID | wc -l)" != "5" ]; then
10718 $LFS fid2path $DIR $FID
10719 err17935 "bad link ea"
10722 rm $remote_dir/foo2/zachary
10724 rm $remote_dir/foo2/thor
10726 rm $remote_dir/$tfile
10728 mv $remote_dir/foo1/sofia $remote_dir/foo2/maggie
10729 local link_path=$($LFS fid2path $FSNAME --link 1 $FID)
10730 if [ "$DIR/$link_path" != "$remote_dir/foo2/maggie" ]; then
10731 $LFS fid2path $DIR $FID
10732 err17935 "bad link rename"
10734 rm $remote_dir/foo2/maggie
10737 local longname=filename_avg_len_is_thirty_two_
10738 createmany -l$remote_dir/foo1/luna $remote_dir/foo2/$longname 1000 ||
10739 error "failed to hardlink many files"
10740 links=$($LFS fid2path $DIR $FID | wc -l)
10741 echo -n "${links}/1000 links in link EA"
10742 [[ ${links} -gt 60 ]] ||
10743 err17935 "expected at least 60 links in link EA"
10744 unlinkmany $remote_dir/foo2/$longname 1000 ||
10745 error "failed to unlink many hardlinks"
10747 run_test 161b "link ea sanity under remote directory"
10750 remote_mds_nodsh && skip "remote MDS with nodsh" && return
10751 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10752 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.1.5) ]] &&
10753 skip "Need MDS version at least 2.1.5" && return
10755 # define CLF_RENAME_LAST 0x0001
10756 # rename overwrite a target having nlink = 1 (changelog flag 0x1)
10757 local USER=$(do_facet $SINGLEMDS $LCTL --device $MDT0 \
10758 changelog_register -n)
10760 mkdir -p $DIR/$tdir
10761 touch $DIR/$tdir/foo_161c
10762 touch $DIR/$tdir/bar_161c
10763 mv -f $DIR/$tdir/foo_161c $DIR/$tdir/bar_161c
10764 $LFS changelog $MDT0 | grep RENME
10765 local flags=$($LFS changelog $MDT0 | grep RENME | tail -1 | \
10767 $LFS changelog_clear $MDT0 $USER 0
10768 if [ x$flags != "x0x1" ]; then
10769 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister \
10771 error "flag $flags is not 0x1"
10773 echo "rename overwrite a target having nlink = 1," \
10774 "changelog record has flags of $flags"
10776 # rename overwrite a target having nlink > 1 (changelog flag 0x0)
10777 touch $DIR/$tdir/foo_161c
10778 touch $DIR/$tdir/bar_161c
10779 ln $DIR/$tdir/bar_161c $DIR/$tdir/foobar_161c
10780 mv -f $DIR/$tdir/foo_161c $DIR/$tdir/bar_161c
10781 $LFS changelog $MDT0 | grep RENME
10782 flags=$($LFS changelog $MDT0 | grep RENME | tail -1 | cut -f5 -d' ')
10783 $LFS changelog_clear $MDT0 $USER 0
10784 if [ x$flags != "x0x0" ]; then
10785 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister \
10787 error "flag $flags is not 0x0"
10789 echo "rename overwrite a target having nlink > 1," \
10790 "changelog record has flags of $flags"
10792 # rename doesn't overwrite a target (changelog flag 0x0)
10793 touch $DIR/$tdir/foo_161c
10794 mv -f $DIR/$tdir/foo_161c $DIR/$tdir/foo2_161c
10795 $LFS changelog $MDT0 | grep RENME
10796 flags=$($LFS changelog $MDT0 | grep RENME | tail -1 | cut -f5 -d' ')
10797 $LFS changelog_clear $MDT0 $USER 0
10798 if [ x$flags != "x0x0" ]; then
10799 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister \
10801 error "flag $flags is not 0x0"
10803 echo "rename doesn't overwrite a target," \
10804 "changelog record has flags of $flags"
10806 # define CLF_UNLINK_LAST 0x0001
10807 # unlink a file having nlink = 1 (changelog flag 0x1)
10808 rm -f $DIR/$tdir/foo2_161c
10809 $LFS changelog $MDT0 | grep UNLNK
10810 flags=$($LFS changelog $MDT0 | grep UNLNK | tail -1 | cut -f5 -d' ')
10811 $LFS changelog_clear $MDT0 $USER 0
10812 if [ x$flags != "x0x1" ]; then
10813 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister \
10815 error "flag $flags is not 0x1"
10817 echo "unlink a file having nlink = 1," \
10818 "changelog record has flags of $flags"
10820 # unlink a file having nlink > 1 (changelog flag 0x0)
10821 ln -f $DIR/$tdir/bar_161c $DIR/$tdir/foobar_161c
10822 rm -f $DIR/$tdir/foobar_161c
10823 $LFS changelog $MDT0 | grep UNLNK
10824 flags=$($LFS changelog $MDT0 | grep UNLNK | tail -1 | cut -f5 -d' ')
10825 $LFS changelog_clear $MDT0 $USER 0
10826 if [ x$flags != "x0x0" ]; then
10827 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister \
10829 error "flag $flags is not 0x0"
10831 echo "unlink a file having nlink > 1," \
10832 "changelog record has flags of $flags"
10833 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister $USER
10835 run_test 161c "check CL_RENME[UNLINK] changelog record flags"
10842 local path=$(${LFS} fid2path $*)
10843 # Remove the '//' indicating a remote directory
10844 path=$(echo $path | sed 's#//#/#g')
10847 if [ $RC -ne 0 ]; then
10848 err17935 "path looked up of $expected failed. Error $RC"
10850 elif [ "${path}" != "${expected}" ]; then
10851 err17935 "path looked up \"${path}\" instead of \"${expected}\""
10854 echo "fid $fid resolves to path $path (expected $expected)"
10857 test_162a() { # was test_162
10858 # Make changes to filesystem
10859 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10860 test_mkdir -p -c1 $DIR/$tdir/d2
10861 touch $DIR/$tdir/d2/$tfile
10862 touch $DIR/$tdir/d2/x1
10863 touch $DIR/$tdir/d2/x2
10864 test_mkdir -p -c1 $DIR/$tdir/d2/a/b/c
10865 test_mkdir -p -c1 $DIR/$tdir/d2/p/q/r
10867 FID=$($LFS path2fid $DIR/$tdir/d2/$tfile | tr -d '[]')
10868 check_path "$tdir/d2/$tfile" $FSNAME $FID --link 0 ||
10869 error "check path $tdir/d2/$tfile failed"
10872 ln -s $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/p/q/r/slink
10873 FID=$($LFS path2fid $DIR/$tdir/d2/p/q/r/slink | tr -d '[]')
10874 check_path "$tdir/d2/p/q/r/slink" $FSNAME $FID --link 0 ||
10875 error "check path $tdir/d2/p/q/r/slink failed"
10877 # softlink to wrong file
10878 ln -s /this/is/garbage $DIR/$tdir/d2/p/q/r/slink.wrong
10879 FID=$($LFS path2fid $DIR/$tdir/d2/p/q/r/slink.wrong | tr -d '[]')
10880 check_path "$tdir/d2/p/q/r/slink.wrong" $FSNAME $FID --link 0 ||
10881 error "check path $tdir/d2/p/q/r/slink.wrong failed"
10884 ln $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/p/q/r/hlink
10885 mv $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/a/b/c/new_file
10886 FID=$($LFS path2fid $DIR/$tdir/d2/a/b/c/new_file | tr -d '[]')
10887 # fid2path dir/fsname should both work
10888 check_path "$tdir/d2/a/b/c/new_file" $FSNAME $FID --link 1 ||
10889 error "check path $tdir/d2/a/b/c/new_file failed"
10890 check_path "$DIR/$tdir/d2/p/q/r/hlink" $DIR $FID --link 0 ||
10891 error "check path $DIR/$tdir/d2/p/q/r/hlink failed"
10893 # hardlink count: check that there are 2 links
10894 # Doesnt work with CMD yet: 17935
10895 ${LFS} fid2path $DIR $FID | wc -l | grep -q 2 || \
10896 err17935 "expected 2 links"
10898 # hardlink indexing: remove the first link
10899 rm $DIR/$tdir/d2/p/q/r/hlink
10900 check_path "$tdir/d2/a/b/c/new_file" $FSNAME $FID --link 0 ||
10901 error "check path $DIR/$tdir/d2/a/b/c/new_file failed"
10905 run_test 162a "path lookup sanity"
10908 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10909 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
10912 $LFS setdirstripe -i0 -c$MDSCOUNT -t all_char $DIR/$tdir/striped_dir ||
10913 error "create striped dir failed"
10915 local FID=$($LFS getdirstripe $DIR/$tdir/striped_dir |
10916 tail -n 1 | awk '{print $2}')
10917 stat $MOUNT/.lustre/fid/$FID && error "sub_stripe can be accessed"
10919 touch $DIR/$tdir/striped_dir/f{0..4} || error "touch f0..4 failed"
10920 mkdir $DIR/$tdir/striped_dir/d{0..4} || error "mkdir d0..4 failed"
10923 for ((i=0;i<5;i++)); do
10924 FID=$($LFS path2fid $DIR/$tdir/striped_dir/f$i | tr -d '[]') ||
10925 error "get fid for f$i failed"
10926 check_path "$tdir/striped_dir/f$i" $FSNAME $FID --link 0 ||
10927 error "check path $tdir/striped_dir/f$i failed"
10929 FID=$($LFS path2fid $DIR/$tdir/striped_dir/d$i | tr -d '[]') ||
10930 error "get fid for d$i failed"
10931 check_path "$tdir/striped_dir/d$i" $FSNAME $FID --link 0 ||
10932 error "check path $tdir/striped_dir/d$i failed"
10937 run_test 162b "striped directory path lookup sanity"
10939 # LU-4239: Verify fid2path works with paths 100 or more directories deep
10941 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.51) ]] &&
10942 skip "Need MDS version at least 2.7.51" && return
10943 test_mkdir $DIR/$tdir.local
10944 test_mkdir $DIR/$tdir.remote
10945 local lpath=$tdir.local
10946 local rpath=$tdir.remote
10948 for ((i = 0; i <= 101; i++)); do
10951 FID=$($LFS path2fid $DIR/$lpath | tr -d '[]') ||
10952 error "get fid for local directory $DIR/$lpath failed"
10953 check_path "$DIR/$lpath" $MOUNT $FID --link 0 ||
10954 error "check path for local directory $DIR/$lpath failed"
10957 test_mkdir $DIR/$rpath
10958 FID=$($LFS path2fid $DIR/$rpath | tr -d '[]') ||
10959 error "get fid for remote directory $DIR/$rpath failed"
10960 check_path "$DIR/$rpath" $MOUNT $FID --link 0 ||
10961 error "check path for remote directory $DIR/$rpath failed"
10966 run_test 162c "fid2path works with paths 100 or more directories deep"
10969 # do directio so as not to populate the page cache
10970 log "creating a 10 Mb file"
10971 $MULTIOP $DIR/$tfile oO_CREAT:O_DIRECT:O_RDWR:w$((10*1048576))c || error "multiop failed while creating a file"
10972 log "starting reads"
10973 dd if=$DIR/$tfile of=/dev/null bs=4096 &
10974 log "truncating the file"
10975 $MULTIOP $DIR/$tfile oO_TRUNC:c || error "multiop failed while truncating the file"
10977 kill %+ || true # reads might have finished
10978 echo "wait until dd is finished"
10980 log "removing the temporary file"
10981 rm -rf $DIR/$tfile || error "tmp file removal failed"
10983 run_test 169 "parallel read and truncate should not deadlock"
10986 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10987 $LCTL clear # bug 18514
10988 $LCTL debug_daemon start $TMP/${tfile}_log_good
10990 $LCTL debug_daemon stop
10991 sed -e "s/^...../a/g" $TMP/${tfile}_log_good > $TMP/${tfile}_log_bad ||
10992 error "sed failed to read log_good"
10994 $LCTL debug_daemon start $TMP/${tfile}_log_good
10996 $LCTL debug_daemon stop
10998 $LCTL df $TMP/${tfile}_log_bad > $TMP/${tfile}_log_bad.out 2>&1 ||
10999 error "lctl df log_bad failed"
11001 local bad_line=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $9}')
11002 local good_line1=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $5}')
11004 $LCTL df $TMP/${tfile}_log_good > $TMP/${tfile}_log_good.out 2>&1
11005 local good_line2=$(tail -n 1 $TMP/${tfile}_log_good.out | awk '{print $5}')
11007 [ "$bad_line" ] && [ "$good_line1" ] && [ "$good_line2" ] ||
11008 error "bad_line good_line1 good_line2 are empty"
11010 cat $TMP/${tfile}_log_good >> $TMP/${tfile}_logs_corrupt
11011 cat $TMP/${tfile}_log_bad >> $TMP/${tfile}_logs_corrupt
11012 cat $TMP/${tfile}_log_good >> $TMP/${tfile}_logs_corrupt
11014 $LCTL df $TMP/${tfile}_logs_corrupt > $TMP/${tfile}_log_bad.out 2>&1
11015 local bad_line_new=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $9}')
11016 local good_line_new=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $5}')
11018 [ "$bad_line_new" ] && [ "$good_line_new" ] ||
11019 error "bad_line_new good_line_new are empty"
11021 local expected_good=$((good_line1 + good_line2*2))
11023 rm -f $TMP/${tfile}*
11024 # LU-231, short malformed line may not be counted into bad lines
11025 if [ $bad_line -ne $bad_line_new ] &&
11026 [ $bad_line -ne $((bad_line_new - 1)) ]; then
11027 error "expected $bad_line bad lines, but got $bad_line_new"
11031 if [ $expected_good -ne $good_line_new ]; then
11032 error "expected $expected_good good lines, but got $good_line_new"
11037 run_test 170 "test lctl df to handle corrupted log ====================="
11039 test_171() { # bug20592
11040 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11041 #define OBD_FAIL_PTLRPC_DUMP_LOG 0x50e
11042 $LCTL set_param fail_loc=0x50e
11043 $LCTL set_param fail_val=3000
11044 multiop_bg_pause $DIR/$tfile O_s || true
11046 kill -USR1 $MULTIPID
11050 if dmesg | grep "recursive fault"; then
11051 error "caught a recursive fault"
11053 $LCTL set_param fail_loc=0
11056 run_test 171 "test libcfs_debug_dumplog_thread stuck in do_exit() ======"
11058 # it would be good to share it with obdfilter-survey/iokit-libecho code
11059 setup_obdecho_osc () {
11062 local obdfilter_name=$2
11063 echo "Creating new osc for $obdfilter_name on $ost_nid"
11064 # make sure we can find loopback nid
11065 $LCTL add_uuid $ost_nid $ost_nid >/dev/null 2>&1
11067 [ $rc -eq 0 ] && { $LCTL attach osc ${obdfilter_name}_osc \
11068 ${obdfilter_name}_osc_UUID || rc=2; }
11069 [ $rc -eq 0 ] && { $LCTL --device ${obdfilter_name}_osc setup \
11070 ${obdfilter_name}_UUID $ost_nid || rc=3; }
11074 cleanup_obdecho_osc () {
11075 local obdfilter_name=$1
11076 $LCTL --device ${obdfilter_name}_osc cleanup >/dev/null
11077 $LCTL --device ${obdfilter_name}_osc detach >/dev/null
11084 local pages=${3:-64}
11089 local obd_size=$(get_obd_size $node $OBD)
11090 local page_size=$(get_page_size $node)
11091 if [[ -n "$obd_size" ]]; then
11092 local new_count=$((obd_size / (pages * page_size / 1024)))
11093 [[ $new_count -ge $count ]] || count=$new_count
11096 do_facet $node "$LCTL attach echo_client ec ec_uuid" || rc=1
11097 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec setup $OBD" ||
11099 if [ $rc -eq 0 ]; then
11100 id=$(do_facet $node "$LCTL --device ec create 1" | awk '/object id/ {print $6}')
11101 [ ${PIPESTATUS[0]} -eq 0 -a -n "$id" ] || rc=3
11103 echo "New object id is $id"
11104 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec getattr $id" ||
11106 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec " \
11107 "test_brw $count w v $pages $id" || rc=4; }
11108 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec destroy $id 1" ||
11110 [ $rc -eq 0 -o $rc -gt 2 ] && { do_facet $node "$LCTL --device ec " \
11111 "cleanup" || rc=5; }
11112 [ $rc -eq 0 -o $rc -gt 1 ] && { do_facet $node "$LCTL --device ec " \
11113 "detach" || rc=6; }
11114 [ $rc -ne 0 ] && echo "obecho_create_test failed: $rc"
11119 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11120 remote_ost_nodsh && skip "remote OST with nodsh" && return
11122 local rmmod_local=0
11124 if ! module_loaded obdecho; then
11125 load_module obdecho/obdecho
11129 local osc=$($LCTL dl | grep -v mdt | awk '$3 == "osc" {print $4; exit}')
11130 local host=$(lctl get_param -n osc.$osc.import |
11131 awk '/current_connection:/ {print $2}' )
11132 local target=$(lctl get_param -n osc.$osc.import |
11133 awk '/target:/ {print $2}' )
11134 target=${target%_UUID}
11136 [[ -n $target ]] && { setup_obdecho_osc $host $target || rc=1; } || rc=1
11137 [ $rc -eq 0 ] && { obdecho_test ${target}_osc client || rc=2; }
11138 [[ -n $target ]] && cleanup_obdecho_osc $target
11139 [ $rmmod_local -eq 1 ] && rmmod obdecho
11142 run_test 180a "test obdecho on osc"
11145 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11146 remote_ost_nodsh && skip "remote OST with nodsh" && return
11148 local rmmod_remote=0
11150 do_facet ost1 "lsmod | grep -q obdecho || " \
11151 "{ insmod ${LUSTRE}/obdecho/obdecho.ko || " \
11152 "modprobe obdecho; }" && rmmod_remote=1
11153 target=$(do_facet ost1 $LCTL dl | awk '/obdfilter/ {print $4;exit}')
11154 [[ -n $target ]] && { obdecho_test $target ost1 || rc=1; }
11155 [ $rmmod_remote -eq 1 ] && do_facet ost1 "rmmod obdecho"
11158 run_test 180b "test obdecho directly on obdfilter"
11160 test_180c() { # LU-2598
11161 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11162 remote_ost_nodsh && skip "remote OST with nodsh" && return
11163 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.0) ]] &&
11164 skip "Need MDS version at least 2.4.0" && return
11167 local rmmod_remote=false
11168 local pages=16384 # 64MB bulk I/O RPC size
11171 do_rpc_nodes $(facet_active_host ost1) load_module obdecho/obdecho &&
11172 rmmod_remote=true || error "failed to load module obdecho"
11174 target=$(do_facet ost1 $LCTL dl | awk '/obdfilter/ { print $4 }' |
11176 if [ -n "$target" ]; then
11177 obdecho_test "$target" ost1 "$pages" || rc=${PIPESTATUS[0]}
11179 echo "there is no obdfilter target on ost1"
11182 $rmmod_remote && do_facet ost1 "rmmod obdecho" || true
11185 run_test 180c "test huge bulk I/O size on obdfilter, don't LASSERT"
11187 test_181() { # bug 22177
11188 test_mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
11189 # create enough files to index the directory
11190 createmany -o $DIR/$tdir/foobar 4000
11191 # print attributes for debug purpose
11194 multiop_bg_pause $DIR/$tdir D_Sc || return 1
11196 # remove the files & current working dir
11197 unlinkmany $DIR/$tdir/foobar 4000
11199 kill -USR1 $MULTIPID
11201 stat $DIR/$tdir && error "open-unlinked dir was not removed!"
11204 run_test 181 "Test open-unlinked dir ========================"
11210 mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
11212 $LCTL set_param mdc.*.rpc_stats=clear
11214 for (( i = 0; i < $tcount; i++ )) ; do
11215 mkdir $DIR/$tdir/$i
11218 for (( i = 0; i < $tcount; i++ )) ; do
11219 createmany -o $DIR/$tdir/$i/f- $fcount &
11223 for (( i = 0; i < $tcount; i++ )) ; do
11224 unlinkmany $DIR/$tdir/$i/f- $fcount &
11228 $LCTL get_param mdc.*.rpc_stats
11232 run_test 182 "Test parallel modify metadata operations ================"
11234 test_183() { # LU-2275
11235 remote_mds_nodsh && skip "remote MDS with nodsh" && return
11236 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.3.56) ]] &&
11237 skip "Need MDS version at least 2.3.56" && return
11239 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11240 mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
11241 echo aaa > $DIR/$tdir/$tfile
11243 #define OBD_FAIL_MDS_NEGATIVE_POSITIVE 0x148
11244 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x148
11246 ls -l $DIR/$tdir && error "ls succeeded, should have failed"
11247 cat $DIR/$tdir/$tfile && error "cat succeeded, should have failed"
11249 do_facet $SINGLEMDS $LCTL set_param fail_loc=0
11251 # Flush negative dentry cache
11252 touch $DIR/$tdir/$tfile
11254 # We are not checking for any leaked references here, they'll
11255 # become evident next time we do cleanup with module unload.
11258 run_test 183 "No crash or request leak in case of strange dispositions ========"
11260 # test suite 184 is for LU-2016, LU-2017
11262 check_swap_layouts_support && return 0
11264 dir0=$DIR/$tdir/$testnum
11265 test_mkdir -p -c1 $dir0 || error "creating dir $dir0"
11270 $SETSTRIPE -c1 $file1
11272 $SETSTRIPE -c2 $file2
11274 gen1=$($GETSTRIPE -g $file1)
11275 gen2=$($GETSTRIPE -g $file2)
11277 $LFS swap_layouts $file1 $file2 || error "swap of file layout failed"
11278 gen=$($GETSTRIPE -g $file1)
11279 [[ $gen1 != $gen ]] ||
11280 "Layout generation on $file1 does not change"
11281 gen=$($GETSTRIPE -g $file2)
11282 [[ $gen2 != $gen ]] ||
11283 "Layout generation on $file2 does not change"
11285 cmp $ref1 $file2 || error "content compare failed ($ref1 != $file2)"
11286 cmp $ref2 $file1 || error "content compare failed ($ref2 != $file1)"
11288 run_test 184a "Basic layout swap"
11291 check_swap_layouts_support && return 0
11293 dir0=$DIR/$tdir/$testnum
11294 mkdir -p $dir0 || error "creating dir $dir0"
11301 $SETSTRIPE -c1 $file1
11302 $SETSTRIPE -c2 $file2
11303 $SETSTRIPE -c1 $file3
11304 chown $RUNAS_ID $file3
11305 gen1=$($GETSTRIPE -g $file1)
11306 gen2=$($GETSTRIPE -g $file2)
11308 $LFS swap_layouts $dir1 $dir2 &&
11309 error "swap of directories layouts should fail"
11310 $LFS swap_layouts $dir1 $file1 &&
11311 error "swap of directory and file layouts should fail"
11312 $RUNAS $LFS swap_layouts $file1 $file2 &&
11313 error "swap of file we cannot write should fail"
11314 $LFS swap_layouts $file1 $file3 &&
11315 error "swap of file with different owner should fail"
11316 /bin/true # to clear error code
11318 run_test 184b "Forbidden layout swap (will generate errors)"
11321 check_swap_layouts_support && return 0
11323 local dir0=$DIR/$tdir/$testnum
11324 mkdir -p $dir0 || error "creating dir $dir0"
11326 local ref1=$dir0/ref1
11327 local ref2=$dir0/ref2
11328 local file1=$dir0/file1
11329 local file2=$dir0/file2
11330 # create a file large enough for the concurrent test
11331 dd if=/dev/urandom of=$ref1 bs=1M count=$((RANDOM % 50 + 20))
11332 dd if=/dev/urandom of=$ref2 bs=1M count=$((RANDOM % 50 + 20))
11333 echo "ref file size: ref1($(stat -c %s $ref1))," \
11334 "ref2($(stat -c %s $ref2))"
11337 dd if=$ref1 of=$file1 bs=16k &
11340 # Make sure dd starts to copy file
11341 while [ ! -f $file1 ]; do sleep 0.1; done
11343 $LFS swap_layouts $file1 $file2
11346 [[ $? == 0 ]] || error "concurrent write on $file1 failed"
11347 [[ $rc == 0 ]] || error "swap of $file1 and $file2 failed"
11349 # how many bytes copied before swapping layout
11350 local copied=$(stat -c %s $file2)
11351 local remaining=$(stat -c %s $ref1)
11352 remaining=$((remaining - copied))
11353 echo "Copied $copied bytes before swapping layout..."
11355 cmp -n $copied $file1 $ref2 | grep differ &&
11356 error "Content mismatch [0, $copied) of ref2 and file1"
11357 cmp -n $copied $file2 $ref1 ||
11358 error "Content mismatch [0, $copied) of ref1 and file2"
11359 cmp -i $copied:$copied -n $remaining $file1 $ref1 ||
11360 error "Content mismatch [$copied, EOF) of ref1 and file1"
11363 rm -f $ref1 $ref2 $file1 $file2
11365 run_test 184c "Concurrent write and layout swap"
11368 check_swap_layouts_support && return 0
11369 [ -z "$(which getfattr 2>/dev/null)" ] &&
11370 skip "no getfattr command" && return 0
11372 local file1=$DIR/$tdir/$tfile-1
11373 local file2=$DIR/$tdir/$tfile-2
11374 local file3=$DIR/$tdir/$tfile-3
11378 mkdir -p $DIR/$tdir
11379 touch $file1 || error "create $file1 failed"
11380 $OPENFILE -f O_CREAT:O_LOV_DELAY_CREATE $file2 ||
11381 error "create $file2 failed"
11382 $OPENFILE -f O_CREAT:O_LOV_DELAY_CREATE $file3 ||
11383 error "create $file3 failed"
11384 lovea1=$($LFS getstripe $file1 | sed 1d)
11386 $LFS swap_layouts $file2 $file3 ||
11387 error "swap $file2 $file3 layouts failed"
11388 $LFS swap_layouts $file1 $file2 ||
11389 error "swap $file1 $file2 layouts failed"
11391 lovea2=$($LFS getstripe $file2 | sed 1d)
11392 [ "$lovea1" == "$lovea2" ] || error "lovea $lovea1 != $lovea2"
11394 lovea1=$(getfattr -n trusted.lov $file1 | grep ^trusted)
11395 [[ -z "$lovea1" ]] || error "$file1 shouldn't have lovea"
11397 run_test 184d "allow stripeless layouts swap"
11400 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.6.94) ]] ||
11401 { skip "Need MDS version at least 2.6.94"; return 0; }
11402 check_swap_layouts_support && return 0
11403 [ -z "$(which getfattr 2>/dev/null)" ] &&
11404 skip "no getfattr command" && return 0
11406 local file1=$DIR/$tdir/$tfile-1
11407 local file2=$DIR/$tdir/$tfile-2
11408 local file3=$DIR/$tdir/$tfile-3
11411 mkdir -p $DIR/$tdir
11412 touch $file1 || error "create $file1 failed"
11413 $OPENFILE -f O_CREAT:O_LOV_DELAY_CREATE $file2 ||
11414 error "create $file2 failed"
11415 $OPENFILE -f O_CREAT:O_LOV_DELAY_CREATE $file3 ||
11416 error "create $file3 failed"
11418 $LFS swap_layouts $file1 $file2 ||
11419 error "swap $file1 $file2 layouts failed"
11421 lovea=$(getfattr -n trusted.lov $file1 | grep ^trusted)
11422 [[ -z "$lovea" ]] || error "$file1 shouldn't have lovea"
11424 echo 123 > $file1 || error "Should be able to write into $file1"
11426 $LFS swap_layouts $file1 $file3 ||
11427 error "swap $file1 $file3 layouts failed"
11429 echo 123 > $file1 || error "Should be able to write into $file1"
11431 rm -rf $file1 $file2 $file3
11433 run_test 184e "Recreate layout after stripeless layout swaps"
11435 test_185() { # LU-2441
11436 # LU-3553 - no volatile file support in old servers
11437 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.3.60) ]] ||
11438 { skip "Need MDS version at least 2.3.60"; return 0; }
11440 mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
11441 touch $DIR/$tdir/spoo
11442 local mtime1=$(stat -c "%Y" $DIR/$tdir)
11443 local fid=$($MULTIOP $DIR/$tdir VFw4096c) ||
11444 error "cannot create/write a volatile file"
11445 $CHECKSTAT -t file $MOUNT/.lustre/fid/$fid 2>/dev/null &&
11446 error "FID is still valid after close"
11448 multiop_bg_pause $DIR/$tdir vVw4096_c
11455 # assume that the next FID for this client is sequential, since stdout
11456 # is unfortunately eaten by multiop_bg_pause
11457 local n=$((${fidv[1]} + 1))
11458 local next_fid="${fidv[0]}:$(printf "0x%x" $n):${fidv[2]}"
11459 $CHECKSTAT -t file $MOUNT/.lustre/fid/$next_fid ||
11460 error "FID is missing before close"
11461 kill -USR1 $multi_pid
11462 # 1 second delay, so if mtime change we will see it
11464 local mtime2=$(stat -c "%Y" $DIR/$tdir)
11465 [[ $mtime1 == $mtime2 ]] || error "mtime has changed"
11467 run_test 185 "Volatile file support"
11470 remote_mds_nodsh && skip "remote MDS with nodsh" && return
11471 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.3.0) ] &&
11472 skip "Need MDS version at least 2.3.0" && return
11474 local dir0=$DIR/$tdir/$testnum
11475 mkdir -p $dir0 || error "creating dir $dir0"
11477 local file=$dir0/file1
11478 dd if=/dev/urandom of=$file count=10 bs=1M conv=fsync
11479 local dv1=$($LFS data_version $file)
11480 dd if=/dev/urandom of=$file seek=10 count=1 bs=1M conv=fsync
11481 local dv2=$($LFS data_version $file)
11482 [[ $dv1 != $dv2 ]] ||
11483 error "data version did not change on write $dv1 == $dv2"
11488 run_test 187a "Test data version change"
11491 remote_mds_nodsh && skip "remote MDS with nodsh" && return
11492 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.3.0) ] &&
11493 skip "Need MDS version at least 2.3.0" && return
11495 local dir0=$DIR/$tdir/$testnum
11496 mkdir -p $dir0 || error "creating dir $dir0"
11498 declare -a DV=$($MULTIOP $dir0 Vw1000xYw1000xY | cut -f3 -d" ")
11499 [[ ${DV[0]} != ${DV[1]} ]] ||
11500 error "data version did not change on write"\
11501 " ${DV[0]} == ${DV[1]}"
11506 run_test 187b "Test data version change on volatile file"
11509 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11510 remote_mgs_nodsh && skip "remote MGS with nodsh" && return
11512 local POOL=${POOL:-cea1}
11513 local POOL_ROOT=${POOL_ROOT:-$DIR/d200.pools}
11514 local POOL_DIR_NAME=${POOL_DIR_NAME:-dir_tst}
11517 local last_ost=$(($OSTCOUNT - 1))
11519 local ost_list=$(seq $first_ost $ost_step $last_ost)
11520 local ost_range="$first_ost $last_ost $ost_step"
11521 local test_path=$POOL_ROOT/$POOL_DIR_NAME
11522 local file_dir=$POOL_ROOT/file_tst
11523 local subdir=$test_path/subdir
11527 # former test_200a test_200b
11528 pool_add $POOL || { rc=$? ; break; }
11529 pool_add_targets $POOL $ost_range || { rc=$? ; break; }
11530 # former test_200c test_200d
11531 mkdir -p $test_path
11532 pool_set_dir $POOL $test_path || { rc=$? ; break; }
11533 pool_check_dir $POOL $test_path || { rc=$? ; break; }
11535 pool_check_dir $POOL $subdir || { rc=$? ; break; }
11536 pool_dir_rel_path $POOL $POOL_DIR_NAME $POOL_ROOT \
11537 || { rc=$? ; break; }
11538 # former test_200e test_200f
11539 local files=$((OSTCOUNT*3))
11540 pool_alloc_files $POOL $test_path $files "$ost_list" \
11541 || { rc=$? ; break; }
11542 pool_create_files $POOL $file_dir $files "$ost_list" \
11543 || { rc=$? ; break; }
11544 # former test_200g test_200h
11545 pool_lfs_df $POOL || { rc=$? ; break; }
11546 pool_file_rel_path $POOL $test_path || { rc=$? ; break; }
11548 # former test_201a test_201b test_201c
11549 pool_remove_first_target $POOL || { rc=$? ; break; }
11551 local f=$test_path/$tfile
11552 pool_remove_all_targets $POOL $f || { rc=$? ; break; }
11553 pool_remove $POOL $f || { rc=$? ; break; }
11560 run_test 200 "OST pools"
11562 # usage: default_attr <count | size | offset>
11564 $LCTL get_param -n lov.$FSNAME-clilov-\*.stripe${1}
11567 # usage: check_default_stripe_attr
11568 check_default_stripe_attr() {
11569 ACTUAL=$($GETSTRIPE $* $DIR/$tdir)
11571 --stripe-count|--count)
11572 [ -n "$2" ] && EXPECTED=0 || EXPECTED=$(default_attr count);;
11573 --stripe-size|--size)
11574 [ -n "$2" ] && EXPECTED=0 || EXPECTED=$(default_attr size);;
11575 --stripe-index|--index)
11578 error "unknown getstripe attr '$1'"
11581 [ $ACTUAL != $EXPECTED ] &&
11582 error "$DIR/$tdir has $1 '$ACTUAL', not '$EXPECTED'"
11586 test_mkdir -p $DIR/$tdir
11587 $SETSTRIPE --stripe-count 0 --stripe-size 0 --stripe-index -1 $DIR/$tdir
11589 check_default_stripe_attr --stripe-count
11590 check_default_stripe_attr --stripe-size
11591 check_default_stripe_attr --stripe-index
11595 run_test 204a "Print default stripe attributes ================="
11598 test_mkdir -p $DIR/$tdir
11599 $SETSTRIPE --stripe-count 1 $DIR/$tdir
11601 check_default_stripe_attr --stripe-size
11602 check_default_stripe_attr --stripe-index
11606 run_test 204b "Print default stripe size and offset ==========="
11609 test_mkdir -p $DIR/$tdir
11610 $SETSTRIPE --stripe-size 65536 $DIR/$tdir
11612 check_default_stripe_attr --stripe-count
11613 check_default_stripe_attr --stripe-index
11617 run_test 204c "Print default stripe count and offset ==========="
11620 test_mkdir -p $DIR/$tdir
11621 $SETSTRIPE --stripe-index 0 $DIR/$tdir
11623 check_default_stripe_attr --stripe-count
11624 check_default_stripe_attr --stripe-size
11628 run_test 204d "Print default stripe count and size ============="
11631 test_mkdir -p $DIR/$tdir
11632 $SETSTRIPE -d $DIR/$tdir
11634 check_default_stripe_attr --stripe-count --raw
11635 check_default_stripe_attr --stripe-size --raw
11636 check_default_stripe_attr --stripe-index --raw
11640 run_test 204e "Print raw stripe attributes ================="
11643 test_mkdir -p $DIR/$tdir
11644 $SETSTRIPE --stripe-count 1 $DIR/$tdir
11646 check_default_stripe_attr --stripe-size --raw
11647 check_default_stripe_attr --stripe-index --raw
11651 run_test 204f "Print raw stripe size and offset ==========="
11654 test_mkdir -p $DIR/$tdir
11655 $SETSTRIPE --stripe-size 65536 $DIR/$tdir
11657 check_default_stripe_attr --stripe-count --raw
11658 check_default_stripe_attr --stripe-index --raw
11662 run_test 204g "Print raw stripe count and offset ==========="
11665 test_mkdir -p $DIR/$tdir
11666 $SETSTRIPE --stripe-index 0 $DIR/$tdir
11668 check_default_stripe_attr --stripe-count --raw
11669 check_default_stripe_attr --stripe-size --raw
11673 run_test 204h "Print raw stripe count and size ============="
11675 # Figure out which job scheduler is being used, if any,
11676 # or use a fake one
11677 if [ -n "$SLURM_JOB_ID" ]; then # SLURM
11678 JOBENV=SLURM_JOB_ID
11679 elif [ -n "$LSB_JOBID" ]; then # Load Sharing Facility
11681 elif [ -n "$PBS_JOBID" ]; then # PBS/Maui/Moab
11683 elif [ -n "$LOADL_STEPID" ]; then # LoadLeveller
11684 JOBENV=LOADL_STEP_ID
11685 elif [ -n "$JOB_ID" ]; then # Sun Grid Engine
11688 $LCTL list_param jobid_name > /dev/null 2>&1
11689 if [ $? -eq 0 ]; then
11696 verify_jobstats() {
11701 # we don't really need to clear the stats for this test to work, since each
11702 # command has a unique jobid, but it makes debugging easier if needed.
11703 # for facet in $facets; do
11704 # local dev=$(convert_facet2label $facet)
11705 # # clear old jobstats
11706 # do_facet $facet lctl set_param *.$dev.job_stats="clear"
11709 # use a new JobID for each test, or we might see an old one
11710 [ "$JOBENV" = "FAKE_JOBID" ] &&
11711 FAKE_JOBID=id.$testnum.$(basename ${cmd[0]}).$RANDOM
11715 [ "$JOBENV" = "nodelocal" ] && {
11716 FAKE_JOBID=id.$testnum.$(basename ${cmd[0]}).$RANDOM
11717 $LCTL set_param jobid_name=$FAKE_JOBID
11721 log "Test: ${cmd[*]}"
11722 log "Using JobID environment variable $JOBENV=$JOBVAL"
11724 if [ $JOBENV = "FAKE_JOBID" ]; then
11725 FAKE_JOBID=$JOBVAL ${cmd[*]}
11730 # all files are created on OST0000
11731 for facet in $facets; do
11732 local stats="*.$(convert_facet2label $facet).job_stats"
11733 if [ $(do_facet $facet lctl get_param $stats |
11734 grep -c $JOBVAL) -ne 1 ]; then
11735 do_facet $facet lctl get_param $stats
11736 error "No jobstats for $JOBVAL found on $facet::$stats"
11743 NEW_JOBENV=${1:-$OLD_JOBENV}
11744 do_facet mgs $LCTL conf_param $FSNAME.sys.jobid_var=$NEW_JOBENV
11745 wait_update $HOSTNAME "$LCTL get_param -n jobid_var" $NEW_JOBENV
11749 do_facet $SINGLEMDS \
11750 $LCTL set_param mdt.*.job_cleanup_interval=$OLD_INTERVAL
11751 [ $OLD_JOBENV != $JOBENV ] && jobstats_set $OLD_JOBENV
11752 do_facet $SINGLEMDS lctl --device $MDT0 changelog_deregister $CL_USER
11755 test_205() { # Job stats
11756 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11757 remote_mgs_nodsh && skip "remote MGS with nodsh" && return
11758 remote_mds_nodsh && skip "remote MDS with nodsh" && return
11759 remote_ost_nodsh && skip "remote OST with nodsh" && return
11761 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep jobstats)" ] &&
11762 skip "Server doesn't support jobstats" && return 0
11763 [[ $JOBID_VAR = disable ]] && skip "jobstats is disabled" && return
11765 OLD_JOBENV=$($LCTL get_param -n jobid_var)
11766 if [ $OLD_JOBENV != $JOBENV ]; then
11767 jobstats_set $JOBENV
11768 trap cleanup_205 EXIT
11771 CL_USER=$(do_facet $SINGLEMDS lctl --device $MDT0 changelog_register -n)
11772 echo "Registered as changelog user $CL_USER"
11774 OLD_INTERVAL=$(do_facet $SINGLEMDS \
11775 lctl get_param -n mdt.*.job_cleanup_interval)
11776 local interval_new=5
11777 do_facet $SINGLEMDS \
11778 $LCTL set_param mdt.*.job_cleanup_interval=$interval_new
11779 local start=$SECONDS
11783 cmd="mkdir $DIR/$tdir"
11784 verify_jobstats "$cmd" "$SINGLEMDS"
11786 cmd="rmdir $DIR/$tdir"
11787 verify_jobstats "$cmd" "$SINGLEMDS"
11788 # mkdir on secondary MDT
11789 if [ $MDSCOUNT -gt 1 ]; then
11790 cmd="lfs mkdir -i 1 $DIR/$tdir.remote"
11791 verify_jobstats "$cmd" "mds2"
11794 cmd="mknod $DIR/$tfile c 1 3"
11795 verify_jobstats "$cmd" "$SINGLEMDS"
11797 cmd="rm -f $DIR/$tfile"
11798 verify_jobstats "$cmd" "$SINGLEMDS"
11799 # create all files on OST0000 so verify_jobstats can find OST stats
11801 cmd="$SETSTRIPE -i 0 -c 1 $DIR/$tfile"
11802 verify_jobstats "$cmd" "$SINGLEMDS"
11804 cmd="touch $DIR/$tfile"
11805 verify_jobstats "$cmd" "$SINGLEMDS ost1"
11807 cmd="dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 oflag=sync"
11808 verify_jobstats "$cmd" "ost1"
11810 cmd="dd if=$DIR/$tfile of=/dev/null bs=1M count=1 iflag=direct"
11811 verify_jobstats "$cmd" "ost1"
11813 cmd="$TRUNCATE $DIR/$tfile 0"
11814 verify_jobstats "$cmd" "$SINGLEMDS ost1"
11816 cmd="mv -f $DIR/$tfile $DIR/$tdir.rename"
11817 verify_jobstats "$cmd" "$SINGLEMDS"
11818 # jobstats expiry - sleep until old stats should be expired
11819 local left=$((interval_new + 2 - (SECONDS - start)))
11820 [ $left -ge 0 ] && echo "sleep $left for expiry" && sleep $((left + 1))
11821 cmd="mkdir $DIR/$tdir.expire"
11822 verify_jobstats "$cmd" "$SINGLEMDS"
11823 [ $(do_facet $SINGLEMDS lctl get_param *.*.job_stats |
11824 grep -c "job_id.*mkdir") -gt 1 ] && error "old jobstats not expired"
11826 # Ensure that jobid are present in changelog (if supported by MDS)
11827 if [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.6.52) ]
11829 $LFS changelog $MDT0 | tail -9
11830 jobids=$($LFS changelog $MDT0 | tail -9 | grep -c "j=")
11831 [ $jobids -eq 9 ] ||
11832 error "Wrong changelog jobid count $jobids != 9"
11836 jobstats_set $JOBENV
11838 $LFS changelog $MDT0 | tail -1
11839 jobids=$($LFS changelog $MDT0 | tail -1 | grep -c "j=")
11840 [ $jobids -eq 0 ] ||
11841 error "Unexpected jobids when jobid_var=$JOBENV"
11846 run_test 205 "Verify job stats"
11848 # LU-1480, LU-1773 and LU-1657
11850 mkdir -p $DIR/$tdir
11851 $SETSTRIPE -c -1 $DIR/$tdir
11852 #define OBD_FAIL_LOV_INIT 0x1403
11853 $LCTL set_param fail_loc=0xa0001403
11854 $LCTL set_param fail_val=1
11855 touch $DIR/$tdir/$tfile || true
11857 run_test 206 "fail lov_init_raid0() doesn't lbug"
11860 dd if=/dev/zero of=$DIR/$tfile bs=4k count=$((RANDOM%10+1))
11861 local fsz=`stat -c %s $DIR/$tfile`
11862 cancel_lru_locks mdc
11864 # do not return layout in getattr intent
11865 #define OBD_FAIL_MDS_NO_LL_GETATTR 0x170
11866 $LCTL set_param fail_loc=0x170
11867 local sz=`stat -c %s $DIR/$tfile`
11869 [ $fsz -eq $sz ] || error "file size expected $fsz, actual $sz"
11873 run_test 207a "can refresh layout at glimpse"
11876 dd if=/dev/zero of=$DIR/$tfile bs=4k count=$((RANDOM%10+1))
11877 local cksum=`md5sum $DIR/$tfile`
11878 local fsz=`stat -c %s $DIR/$tfile`
11879 cancel_lru_locks mdc
11880 cancel_lru_locks osc
11882 # do not return layout in getattr intent
11883 #define OBD_FAIL_MDS_NO_LL_OPEN 0x171
11884 $LCTL set_param fail_loc=0x171
11886 # it will refresh layout after the file is opened but before read issues
11887 echo checksum is "$cksum"
11888 echo "$cksum" |md5sum -c --quiet || error "file differs"
11892 run_test 207b "can refresh layout at open"
11895 # FIXME: in this test suite, only RD lease is used. This is okay
11896 # for now as only exclusive open is supported. After generic lease
11897 # is done, this test suite should be revised. - Jinshan
11899 remote_mds_nodsh && skip "remote MDS with nodsh" && return
11900 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.4.52) ]] ||
11901 { skip "Need MDS version at least 2.4.52"; return 0; }
11903 echo "==== test 1: verify get lease work"
11904 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:eRE+eU || error "get lease error"
11906 echo "==== test 2: verify lease can be broken by upcoming open"
11907 $MULTIOP $DIR/$tfile oO_RDONLY:eR_E-eUc &
11911 $MULTIOP $DIR/$tfile oO_RDONLY:c
11912 kill -USR1 $PID && wait $PID || error "break lease error"
11914 echo "==== test 3: verify lease can't be granted if an open already exists"
11915 $MULTIOP $DIR/$tfile oO_RDONLY:_c &
11919 $MULTIOP $DIR/$tfile oO_RDONLY:eReUc && error "apply lease should fail"
11920 kill -USR1 $PID && wait $PID || error "open file error"
11922 echo "==== test 4: lease can sustain over recovery"
11923 $MULTIOP $DIR/$tfile oO_RDONLY:eR_E+eUc &
11929 kill -USR1 $PID && wait $PID || error "lease broken over recovery"
11931 echo "==== test 5: lease broken can't be regained by replay"
11932 $MULTIOP $DIR/$tfile oO_RDONLY:eR_E-eUc &
11936 # open file to break lease and then recovery
11937 $MULTIOP $DIR/$tfile oO_RDWR:c || error "open file error"
11940 kill -USR1 $PID && wait $PID || error "lease not broken over recovery"
11944 run_test 208 "Exclusive open"
11947 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep disp_stripe)" ] &&
11948 skip_env "must have disp_stripe" && return
11951 sync; sleep 5; sync;
11953 echo 3 > /proc/sys/vm/drop_caches
11954 req_before=$(awk '/ptlrpc_cache / { print $2 }' /proc/slabinfo)
11956 # open/close 500 times
11957 for i in $(seq 500); do
11961 echo 3 > /proc/sys/vm/drop_caches
11962 req_after=$(awk '/ptlrpc_cache / { print $2 }' /proc/slabinfo)
11964 echo "before: $req_before, after: $req_after"
11965 [ $((req_after - req_before)) -ge 300 ] &&
11966 error "open/close requests are not freed"
11969 run_test 209 "read-only open/close requests should be freed promptly"
11973 size=$((size % 8192 + 1))
11974 dd if=/dev/urandom of=$DIR/f212 bs=1k count=$size
11975 sendfile $DIR/f212 $DIR/f212.xyz || error "sendfile wrong"
11976 rm -f $DIR/f212 $DIR/f212.xyz
11978 run_test 212 "Sendfile test ============================================"
11981 dd if=/dev/zero of=$DIR/$tfile bs=4k count=4
11982 cancel_lru_locks osc
11983 lctl set_param fail_loc=0x8000040f
11984 # generate a read lock
11985 cat $DIR/$tfile > /dev/null
11986 # write to the file, it will try to cancel the above read lock.
11987 cat /etc/hosts >> $DIR/$tfile
11989 run_test 213 "OSC lock completion and cancel race don't crash - bug 18829"
11991 test_214() { # for bug 20133
11992 mkdir -p $DIR/$tdir/d214c || error "mkdir $DIR/$tdir/d214c failed"
11993 for (( i=0; i < 340; i++ )) ; do
11994 touch $DIR/$tdir/d214c/a$i
11997 ls -l $DIR/$tdir || error "ls -l $DIR/d214p failed"
11998 mv $DIR/$tdir/d214c $DIR/ || error "mv $DIR/d214p/d214c $DIR/ failed"
11999 ls $DIR/d214c || error "ls $DIR/d214c failed"
12000 rm -rf $DIR/$tdir || error "rm -rf $DIR/d214* failed"
12001 rm -rf $DIR/d214* || error "rm -rf $DIR/d214* failed"
12003 run_test 214 "hash-indexed directory test - bug 20133"
12005 # having "abc" as 1st arg, creates $TMP/lnet_abc.out and $TMP/lnet_abc.sys
12006 create_lnet_proc_files() {
12007 lctl get_param -n $1 >$TMP/lnet_$1.out || error "cannot read lnet.$1"
12008 sysctl lnet.$1 >$TMP/lnet_$1.sys_tmp || error "cannot read lnet.$1"
12010 sed "s/^lnet.$1\ =\ //g" "$TMP/lnet_$1.sys_tmp" >$TMP/lnet_$1.sys
12011 rm -f "$TMP/lnet_$1.sys_tmp"
12014 # counterpart of create_lnet_proc_files
12015 remove_lnet_proc_files() {
12016 rm -f $TMP/lnet_$1.out $TMP/lnet_$1.sys
12019 # uses 1st arg as trailing part of filename, 2nd arg as description for reports,
12020 # 3rd arg as regexp for body
12021 check_lnet_proc_stats() {
12022 local l=$(cat "$TMP/lnet_$1" |wc -l)
12023 [ $l = 1 ] || (cat "$TMP/lnet_$1" && error "$2 is not of 1 line: $l")
12025 grep -E "$3" "$TMP/lnet_$1" || (cat "$TMP/lnet_$1" && error "$2 misformatted")
12028 # uses 1st arg as trailing part of filename, 2nd arg as description for reports,
12029 # 3rd arg as regexp for body, 4th arg as regexp for 1st line, 5th arg is
12030 # optional and can be regexp for 2nd line (lnet.routes case)
12031 check_lnet_proc_entry() {
12032 local blp=2 # blp stands for 'position of 1st line of body'
12033 [ -z "$5" ] || blp=3 # lnet.routes case
12035 local l=$(cat "$TMP/lnet_$1" |wc -l)
12036 # subtracting one from $blp because the body can be empty
12037 [ "$l" -ge "$(($blp - 1))" ] || (cat "$TMP/lnet_$1" && error "$2 is too short: $l")
12039 sed -n '1 p' "$TMP/lnet_$1" |grep -E "$4" >/dev/null ||
12040 (cat "$TMP/lnet_$1" && error "1st line of $2 misformatted")
12042 [ "$5" = "" ] || sed -n '2 p' "$TMP/lnet_$1" |grep -E "$5" >/dev/null ||
12043 (cat "$TMP/lnet_$1" && error "2nd line of $2 misformatted")
12045 # bail out if any unexpected line happened
12046 sed -n "$blp p" "$TMP/lnet_$1" | grep -Ev "$3"
12047 [ "$?" != 0 ] || error "$2 misformatted"
12050 test_215() { # for bugs 18102, 21079, 21517
12051 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12052 local N='(0|[1-9][0-9]*)' # non-negative numeric
12053 local P='[1-9][0-9]*' # positive numeric
12054 local I='(0|-?[1-9][0-9]*|NA)' # any numeric (0 | >0 | <0) or NA if no value
12055 local NET='[a-z][a-z0-9]*' # LNET net like o2ib2
12056 local ADDR='[0-9.]+' # LNET addr like 10.0.0.1
12057 local NID="$ADDR@$NET" # LNET nid like 10.0.0.1@o2ib2
12059 local L1 # regexp for 1st line
12060 local L2 # regexp for 2nd line (optional)
12061 local BR # regexp for the rest (body)
12063 # lnet.stats should look as 11 space-separated non-negative numerics
12064 BR="^$N $N $N $N $N $N $N $N $N $N $N$"
12065 create_lnet_proc_files "stats"
12066 check_lnet_proc_stats "stats.sys" "lnet.stats" "$BR"
12067 remove_lnet_proc_files "stats"
12069 # lnet.routes should look like this:
12070 # Routing disabled/enabled
12071 # net hops priority state router
12072 # where net is a string like tcp0, hops > 0, priority >= 0,
12073 # state is up/down,
12074 # router is a string like 192.168.1.1@tcp2
12075 L1="^Routing (disabled|enabled)$"
12076 L2="^net +hops +priority +state +router$"
12077 BR="^$NET +$N +(0|1) +(up|down) +$NID$"
12078 create_lnet_proc_files "routes"
12079 check_lnet_proc_entry "routes.sys" "lnet.routes" "$BR" "$L1" "$L2"
12080 remove_lnet_proc_files "routes"
12082 # lnet.routers should look like this:
12083 # ref rtr_ref alive_cnt state last_ping ping_sent deadline down_ni router
12084 # where ref > 0, rtr_ref > 0, alive_cnt >= 0, state is up/down,
12085 # last_ping >= 0, ping_sent is boolean (0/1), deadline and down_ni are
12086 # numeric (0 or >0 or <0), router is a string like 192.168.1.1@tcp2
12087 L1="^ref +rtr_ref +alive_cnt +state +last_ping +ping_sent +deadline +down_ni +router$"
12088 BR="^$P +$P +$N +(up|down) +$N +(0|1) +$I +$I +$NID$"
12089 create_lnet_proc_files "routers"
12090 check_lnet_proc_entry "routers.sys" "lnet.routers" "$BR" "$L1"
12091 remove_lnet_proc_files "routers"
12093 # lnet.peers should look like this:
12094 # nid refs state last max rtr min tx min queue
12095 # where nid is a string like 192.168.1.1@tcp2, refs > 0,
12096 # state is up/down/NA, max >= 0. last, rtr, min, tx, min are
12097 # numeric (0 or >0 or <0), queue >= 0.
12098 L1="^nid +refs +state +last +max +rtr +min +tx +min +queue$"
12099 BR="^$NID +$P +(up|down|NA) +$I +$N +$I +$I +$I +$I +$N$"
12100 create_lnet_proc_files "peers"
12101 check_lnet_proc_entry "peers.sys" "lnet.peers" "$BR" "$L1"
12102 remove_lnet_proc_files "peers"
12104 # lnet.buffers should look like this:
12105 # pages count credits min
12106 # where pages >=0, count >=0, credits and min are numeric (0 or >0 or <0)
12107 L1="^pages +count +credits +min$"
12108 BR="^ +$N +$N +$I +$I$"
12109 create_lnet_proc_files "buffers"
12110 check_lnet_proc_entry "buffers.sys" "lnet.buffers" "$BR" "$L1"
12111 remove_lnet_proc_files "buffers"
12113 # lnet.nis should look like this:
12114 # nid status alive refs peer rtr max tx min
12115 # where nid is a string like 192.168.1.1@tcp2, status is up/down,
12116 # alive is numeric (0 or >0 or <0), refs >= 0, peer >= 0,
12117 # rtr >= 0, max >=0, tx and min are numeric (0 or >0 or <0).
12118 L1="^nid +status +alive +refs +peer +rtr +max +tx +min$"
12119 BR="^$NID +(up|down) +$I +$N +$N +$N +$N +$I +$I$"
12120 create_lnet_proc_files "nis"
12121 check_lnet_proc_entry "nis.sys" "lnet.nis" "$BR" "$L1"
12122 remove_lnet_proc_files "nis"
12124 # can we successfully write to lnet.stats?
12125 lctl set_param -n stats=0 || error "cannot write to lnet.stats"
12126 sysctl -w lnet.stats=0 || error "cannot write to lnet.stats"
12128 run_test 215 "lnet exists and has proper content - bugs 18102, 21079, 21517"
12130 test_216() { # bug 20317
12131 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12132 remote_ost_nodsh && skip "remote OST with nodsh" && return
12135 local facets=$(get_facets OST)
12136 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
12138 save_lustre_params client "osc.*.contention_seconds" > $p
12139 save_lustre_params $facets \
12140 "ldlm.namespaces.filter-*.max_nolock_bytes" >> $p
12141 save_lustre_params $facets \
12142 "ldlm.namespaces.filter-*.contended_locks" >> $p
12143 save_lustre_params $facets \
12144 "ldlm.namespaces.filter-*.contention_seconds" >> $p
12147 # agressive lockless i/o settings
12148 for node in $(osts_nodes); do
12149 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'
12151 lctl set_param -n osc.*.contention_seconds 60
12153 $DIRECTIO write $DIR/$tfile 0 10 4096
12154 $CHECKSTAT -s 40960 $DIR/$tfile
12156 # disable lockless i/o
12157 for node in $(osts_nodes); do
12158 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'
12160 lctl set_param -n osc.*.contention_seconds 0
12163 dd if=/dev/zero of=$DIR/$tfile count=0
12164 $CHECKSTAT -s 0 $DIR/$tfile
12166 restore_lustre_params <$p
12170 run_test 216 "check lockless direct write works and updates file size and kms correctly"
12172 test_217() { # bug 22430
12173 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12177 for node in $(nodes_list); do
12178 nid=$(host_nids_address $node $NETTYPE)
12179 if [[ $nid = *-* ]] ; then
12180 echo "lctl ping $nid@$NETTYPE"
12181 lctl ping $nid@$NETTYPE
12183 echo "skipping $node (no hyphen detected)"
12187 run_test 217 "check lctl ping for hostnames with hiphen ('-')"
12190 # do directio so as not to populate the page cache
12191 log "creating a 10 Mb file"
12192 $MULTIOP $DIR/$tfile oO_CREAT:O_DIRECT:O_RDWR:w$((10*1048576))c || error "multiop failed while creating a file"
12193 log "starting reads"
12194 dd if=$DIR/$tfile of=/dev/null bs=4096 &
12195 log "truncating the file"
12196 $MULTIOP $DIR/$tfile oO_TRUNC:c || error "multiop failed while truncating the file"
12198 kill %+ || true # reads might have finished
12199 echo "wait until dd is finished"
12201 log "removing the temporary file"
12202 rm -rf $DIR/$tfile || error "tmp file removal failed"
12204 run_test 218 "parallel read and truncate should not deadlock ======================="
12207 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12208 # write one partial page
12209 dd if=/dev/zero of=$DIR/$tfile bs=1024 count=1
12210 # set no grant so vvp_io_commit_write will do sync write
12211 $LCTL set_param fail_loc=0x411
12212 # write a full page at the end of file
12213 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 seek=1 conv=notrunc
12215 $LCTL set_param fail_loc=0
12216 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 seek=3
12217 $LCTL set_param fail_loc=0x411
12218 dd if=/dev/zero of=$DIR/$tfile bs=1024 count=1 seek=2 conv=notrunc
12221 dd if=/dev/zero of=$DIR/$tfile-2 bs=1024 count=1
12222 $CHECKSTAT -s 1024 $DIR/$tfile-2 || error "checkstat wrong size"
12224 run_test 219 "LU-394: Write partial won't cause uncontiguous pages vec at LND"
12226 test_220() { #LU-325
12227 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12228 remote_ost_nodsh && skip "remote OST with nodsh" && return
12229 remote_mds_nodsh && skip "remote MDS with nodsh" && return
12230 remote_mgs_nodsh && skip "remote MGS with nodsh" && return
12233 # create on MDT0000 so the last_id and next_id are correct
12235 local OST=$($LFS df $DIR | awk '/OST:'$OSTIDX'/ { print $1 }')
12239 local mdtosc_proc1=$(get_mdtosc_proc_path $SINGLEMDS $OST)
12240 local last_id=$(do_facet $SINGLEMDS lctl get_param -n \
12241 osc.$mdtosc_proc1.prealloc_last_id)
12242 local next_id=$(do_facet $SINGLEMDS lctl get_param -n \
12243 osc.$mdtosc_proc1.prealloc_next_id)
12247 do_facet ost$((OSTIDX + 1)) lctl set_param fail_val=-1
12248 #define OBD_FAIL_OST_ENOINO 0x229
12249 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=0x229
12250 do_facet mgs $LCTL pool_new $FSNAME.$TESTNAME || return 1
12251 do_facet mgs $LCTL pool_add $FSNAME.$TESTNAME $OST || return 2
12253 $SETSTRIPE $DIR/$tdir -i $OSTIDX -c 1 -p $FSNAME.$TESTNAME
12255 MDSOBJS=$((last_id - next_id))
12256 echo "preallocated objects on MDS is $MDSOBJS" "($last_id - $next_id)"
12258 blocks=$($LFS df $MOUNT | awk '($1 == '$OSTIDX') { print $4 }')
12259 echo "OST still has $count kbytes free"
12261 echo "create $MDSOBJS files @next_id..."
12262 createmany -o $DIR/$tdir/f $MDSOBJS || return 3
12264 local last_id2=$(do_facet mds${MDSIDX} lctl get_param -n \
12265 osc.$mdtosc_proc1.prealloc_last_id)
12266 local next_id2=$(do_facet mds${MDSIDX} lctl get_param -n \
12267 osc.$mdtosc_proc1.prealloc_next_id)
12269 echo "after creation, last_id=$last_id2, next_id=$next_id2"
12274 do_facet ost$((OSTIDX + 1)) lctl set_param fail_val=0
12275 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=0
12277 do_facet mgs $LCTL pool_remove $FSNAME.$TESTNAME $OST || return 4
12278 do_facet mgs $LCTL pool_destroy $FSNAME.$TESTNAME || return 5
12279 echo "unlink $MDSOBJS files @$next_id..."
12280 unlinkmany $DIR/$tdir/f $MDSOBJS || return 6
12282 run_test 220 "preallocated MDS objects still used if ENOSPC from OST"
12285 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12286 dd if=`which date` of=$MOUNT/date oflag=sync
12287 chmod +x $MOUNT/date
12289 #define OBD_FAIL_LLITE_FAULT_TRUNC_RACE 0x1401
12290 $LCTL set_param fail_loc=0x80001401
12292 $MOUNT/date > /dev/null
12295 run_test 221 "make sure fault and truncate race to not cause OOM"
12298 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12300 test_mkdir -p $DIR/$tdir
12301 $SETSTRIPE -c 1 -i 0 $DIR/$tdir
12302 createmany -o $DIR/$tdir/$tfile 10
12303 cancel_lru_locks mdc
12304 cancel_lru_locks osc
12305 #define OBD_FAIL_LDLM_AGL_DELAY 0x31a
12306 $LCTL set_param fail_loc=0x31a
12307 ls -l $DIR/$tdir > /dev/null || error "AGL for ls failed"
12308 $LCTL set_param fail_loc=0
12311 run_test 222a "AGL for ls should not trigger CLIO lock failure ================"
12314 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12316 test_mkdir -p $DIR/$tdir
12317 $SETSTRIPE -c 1 -i 0 $DIR/$tdir
12318 createmany -o $DIR/$tdir/$tfile 10
12319 cancel_lru_locks mdc
12320 cancel_lru_locks osc
12321 #define OBD_FAIL_LDLM_AGL_DELAY 0x31a
12322 $LCTL set_param fail_loc=0x31a
12323 rm -r $DIR/$tdir || "AGL for rmdir failed"
12324 $LCTL set_param fail_loc=0
12326 run_test 222b "AGL for rmdir should not trigger CLIO lock failure ============="
12329 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12331 test_mkdir -p $DIR/$tdir
12332 $SETSTRIPE -c 1 -i 0 $DIR/$tdir
12333 createmany -o $DIR/$tdir/$tfile 10
12334 cancel_lru_locks mdc
12335 cancel_lru_locks osc
12336 #define OBD_FAIL_LDLM_AGL_NOLOCK 0x31b
12337 $LCTL set_param fail_loc=0x31b
12338 ls -l $DIR/$tdir > /dev/null || error "reenqueue failed"
12339 $LCTL set_param fail_loc=0
12342 run_test 223 "osc reenqueue if without AGL lock granted ======================="
12344 test_224a() { # LU-1039, MRP-303
12345 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12346 #define OBD_FAIL_PTLRPC_CLIENT_BULK_CB 0x508
12347 $LCTL set_param fail_loc=0x508
12348 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 conv=fsync
12349 $LCTL set_param fail_loc=0
12352 run_test 224a "Don't panic on bulk IO failure"
12354 test_224b() { # LU-1039, MRP-303
12355 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12356 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1
12357 cancel_lru_locks osc
12358 #define OBD_FAIL_PTLRPC_CLIENT_BULK_CB2 0x515
12359 $LCTL set_param fail_loc=0x515
12360 dd of=/dev/null if=$DIR/$tfile bs=4096 count=1
12361 $LCTL set_param fail_loc=0
12364 run_test 224b "Don't panic on bulk IO failure"
12366 test_224c() { # LU-6441
12367 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12368 local pages_per_rpc=$($LCTL get_param \
12369 osc.*.max_pages_per_rpc)
12370 local at_max=$($LCTL get_param -n at_max)
12371 local timeout=$($LCTL get_param -n timeout)
12372 local test_at="$LCTL get_param -n at_max"
12373 local param_at="$FSNAME.sys.at_max"
12374 local test_timeout="$LCTL get_param -n timeout"
12375 local param_timeout="$FSNAME.sys.timeout"
12377 $LCTL set_param -n osc.*.max_pages_per_rpc=1024
12379 set_conf_param_and_check client "$test_at" "$param_at" 0 ||
12380 error "conf_param at_max=0 failed"
12381 set_conf_param_and_check client "$test_timeout" "$param_timeout" 5 ||
12382 error "conf_param timeout=5 failed"
12384 #define OBD_FAIL_PTLRPC_CLIENT_BULK_CB3 0x520
12385 $LCTL set_param fail_loc=0x520
12386 dd if=/dev/zero of=$DIR/$tfile bs=8MB count=1
12388 $LCTL set_param fail_loc=0
12390 set_conf_param_and_check client "$test_at" "$param_at" $at_max ||
12391 error "conf_param at_max=$at_max failed"
12392 set_conf_param_and_check client "$test_timeout" "$param_timeout" \
12393 $timeout || error "conf_param timeout=$timeout failed"
12395 $LCTL set_param -n $pages_per_rpc
12397 run_test 224c "Don't hang if one of md lost during large bulk RPC"
12399 MDSSURVEY=${MDSSURVEY:-$(which mds-survey 2>/dev/null || true)}
12401 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12402 remote_mds_nodsh && skip "remote MDS with nodsh" && return
12403 if [ -z ${MDSSURVEY} ]; then
12404 skip_env "mds-survey not found" && return
12407 [ $MDSCOUNT -ge 2 ] &&
12408 skip "skipping now for more than one MDT" && return
12410 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.51) ] ||
12411 { skip "Need MDS version at least 2.2.51"; return; }
12413 local mds=$(facet_host $SINGLEMDS)
12414 local target=$(do_nodes $mds 'lctl dl' | \
12415 awk "{if (\$2 == \"UP\" && \$3 == \"mdt\") {print \$4}}")
12417 local cmd1="file_count=1000 thrhi=4"
12418 local cmd2="dir_count=2 layer=mdd stripe_count=0"
12419 local cmd3="rslt_loc=${TMP} targets=\"$mds:$target\" $MDSSURVEY"
12420 local cmd="$cmd1 $cmd2 $cmd3"
12422 rm -f ${TMP}/mds_survey*
12424 eval $cmd || error "mds-survey with zero-stripe failed"
12425 cat ${TMP}/mds_survey*
12426 rm -f ${TMP}/mds_survey*
12428 run_test 225a "Metadata survey sanity with zero-stripe"
12431 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12432 remote_mds_nodsh && skip "remote MDS with nodsh" && return
12433 if [ -z ${MDSSURVEY} ]; then
12434 skip_env "mds-survey not found" && return
12436 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.51) ] ||
12437 { skip "Need MDS version at least 2.2.51"; return; }
12439 if [ $($LCTL dl | grep -c osc) -eq 0 ]; then
12440 skip_env "Need to mount OST to test" && return
12443 [ $MDSCOUNT -ge 2 ] &&
12444 skip "skipping now for more than one MDT" && return
12445 local mds=$(facet_host $SINGLEMDS)
12446 local target=$(do_nodes $mds 'lctl dl' | \
12447 awk "{if (\$2 == \"UP\" && \$3 == \"mdt\") {print \$4}}")
12449 local cmd1="file_count=1000 thrhi=4"
12450 local cmd2="dir_count=2 layer=mdd stripe_count=1"
12451 local cmd3="rslt_loc=${TMP} targets=\"$mds:$target\" $MDSSURVEY"
12452 local cmd="$cmd1 $cmd2 $cmd3"
12454 rm -f ${TMP}/mds_survey*
12456 eval $cmd || error "mds-survey with stripe_count failed"
12457 cat ${TMP}/mds_survey*
12458 rm -f ${TMP}/mds_survey*
12460 run_test 225b "Metadata survey sanity with stripe_count = 1"
12462 mcreate_path2fid () {
12468 local path=$DIR/$tdir/$name
12473 $MCREATE --mode=$1 --major=$2 --minor=$3 $path ||
12474 error "cannot create $desc"
12476 fid=$($LFS path2fid $path | tr -d '[' | tr -d ']')
12478 [ $rc -ne 0 ] && error "cannot get fid of a $desc"
12480 fid_path=$($LFS fid2path $MOUNT $fid)
12482 [ $rc -ne 0 ] && error "cannot get path of $desc by $DIR $path $fid"
12484 [ "$path" == "$fid_path" ] ||
12485 error "fid2path returned $fid_path, expected $path"
12487 echo "pass with $path and $fid"
12492 mkdir -p $DIR/$tdir
12494 mcreate_path2fid 0010666 0 0 fifo "FIFO"
12495 mcreate_path2fid 0020666 1 3 null "character special file (null)"
12496 mcreate_path2fid 0020666 1 255 none "character special file (no device)"
12497 mcreate_path2fid 0040666 0 0 dir "directory"
12498 mcreate_path2fid 0060666 7 0 loop0 "block special file (loop)"
12499 mcreate_path2fid 0100666 0 0 file "regular file"
12500 mcreate_path2fid 0120666 0 0 link "symbolic link"
12501 mcreate_path2fid 0140666 0 0 sock "socket"
12503 run_test 226a "call path2fid and fid2path on files of all type"
12506 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
12510 mkdir -p $DIR/$tdir
12511 $LFS setdirstripe -i $MDTIDX $DIR/$tdir/remote_dir ||
12512 error "create remote directory failed"
12513 mcreate_path2fid 0010666 0 0 "remote_dir/fifo" "FIFO"
12514 mcreate_path2fid 0020666 1 3 "remote_dir/null" \
12515 "character special file (null)"
12516 mcreate_path2fid 0020666 1 255 "remote_dir/none" \
12517 "character special file (no device)"
12518 mcreate_path2fid 0040666 0 0 "remote_dir/dir" "directory"
12519 mcreate_path2fid 0060666 7 0 "remote_dir/loop0" \
12520 "block special file (loop)"
12521 mcreate_path2fid 0100666 0 0 "remote_dir/file" "regular file"
12522 mcreate_path2fid 0120666 0 0 "remote_dir/link" "symbolic link"
12523 mcreate_path2fid 0140666 0 0 "remote_dir/sock" "socket"
12525 run_test 226b "call path2fid and fid2path on files of all type under remote dir"
12527 # LU-1299 Executing or running ldd on a truncated executable does not
12528 # cause an out-of-memory condition.
12530 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12531 [ -z "$(which ldd)" ] && skip "should have ldd tool" && return
12532 dd if=$(which date) of=$MOUNT/date bs=1k count=1
12533 chmod +x $MOUNT/date
12535 $MOUNT/date > /dev/null
12536 ldd $MOUNT/date > /dev/null
12539 run_test 227 "running truncated executable does not cause OOM"
12541 # LU-1512 try to reuse idle OI blocks
12543 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12544 remote_mds_nodsh && skip "remote MDS with nodsh" && return
12545 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
12546 skip "non-ldiskfs backend" && return
12548 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
12549 local myDIR=$DIR/$tdir
12552 #define OBD_FAIL_SEQ_EXHAUST 0x1002
12553 $LCTL set_param fail_loc=0x80001002
12554 createmany -o $myDIR/t- 10000
12555 $LCTL set_param fail_loc=0
12556 # The guard is current the largest FID holder
12558 local SEQ=$($LFS path2fid $myDIR/guard | awk -F ':' '{print $1}' |
12560 local IDX=$(($SEQ % 64))
12562 do_facet $SINGLEMDS sync
12563 # Make sure journal flushed.
12565 local blk1=$(do_facet $SINGLEMDS \
12566 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
12567 grep Blockcount | awk '{print $4}')
12569 # Remove old files, some OI blocks will become idle.
12570 unlinkmany $myDIR/t- 10000
12571 # Create new files, idle OI blocks should be reused.
12572 createmany -o $myDIR/t- 2000
12573 do_facet $SINGLEMDS sync
12574 # Make sure journal flushed.
12576 local blk2=$(do_facet $SINGLEMDS \
12577 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
12578 grep Blockcount | awk '{print $4}')
12580 [ $blk1 == $blk2 ] || error "old blk1=$blk1, new blk2=$blk2, unmatched!"
12582 run_test 228a "try to reuse idle OI blocks"
12585 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12586 remote_mds_nodsh && skip "remote MDS with nodsh" && return
12587 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
12588 skip "non-ldiskfs backend" && return
12590 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
12591 local myDIR=$DIR/$tdir
12594 #define OBD_FAIL_SEQ_EXHAUST 0x1002
12595 $LCTL set_param fail_loc=0x80001002
12596 createmany -o $myDIR/t- 10000
12597 $LCTL set_param fail_loc=0
12598 # The guard is current the largest FID holder
12600 local SEQ=$($LFS path2fid $myDIR/guard | awk -F ':' '{print $1}' |
12602 local IDX=$(($SEQ % 64))
12604 do_facet $SINGLEMDS sync
12605 # Make sure journal flushed.
12607 local blk1=$(do_facet $SINGLEMDS \
12608 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
12609 grep Blockcount | awk '{print $4}')
12611 # Remove old files, some OI blocks will become idle.
12612 unlinkmany $myDIR/t- 10000
12615 stop $SINGLEMDS || error "Fail to stop MDT."
12617 start $SINGLEMDS $MDT_DEV $MDS_MOUNT_OPTS || error "Fail to start MDT."
12619 df $MOUNT || error "Fail to df."
12620 # Create new files, idle OI blocks should be reused.
12621 createmany -o $myDIR/t- 2000
12622 do_facet $SINGLEMDS sync
12623 # Make sure journal flushed.
12625 local blk2=$(do_facet $SINGLEMDS \
12626 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
12627 grep Blockcount | awk '{print $4}')
12629 [ $blk1 == $blk2 ] || error "old blk1=$blk1, new blk2=$blk2, unmatched!"
12631 run_test 228b "idle OI blocks can be reused after MDT restart"
12635 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12636 remote_mds_nodsh && skip "remote MDS with nodsh" && return
12637 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
12638 skip "non-ldiskfs backend" && return
12640 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
12641 local myDIR=$DIR/$tdir
12644 #define OBD_FAIL_SEQ_EXHAUST 0x1002
12645 $LCTL set_param fail_loc=0x80001002
12646 # 20000 files can guarantee there are index nodes in the OI file
12647 createmany -o $myDIR/t- 20000
12648 $LCTL set_param fail_loc=0
12649 # The guard is current the largest FID holder
12651 local SEQ=$($LFS path2fid $myDIR/guard | awk -F ':' '{print $1}' |
12653 local IDX=$(($SEQ % 64))
12655 do_facet $SINGLEMDS sync
12656 # Make sure journal flushed.
12658 local blk1=$(do_facet $SINGLEMDS \
12659 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
12660 grep Blockcount | awk '{print $4}')
12662 # Remove old files, some OI blocks will become idle.
12663 unlinkmany $myDIR/t- 20000
12665 # The OI file should become empty now
12667 # Create new files, idle OI blocks should be reused.
12668 createmany -o $myDIR/t- 2000
12669 do_facet $SINGLEMDS sync
12670 # Make sure journal flushed.
12672 local blk2=$(do_facet $SINGLEMDS \
12673 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
12674 grep Blockcount | awk '{print $4}')
12676 [ $blk1 == $blk2 ] || error "old blk1=$blk1, new blk2=$blk2, unmatched!"
12678 run_test 228c "NOT shrink the last entry in OI index node to recycle idle leaf"
12680 test_229() { # LU-2482, LU-3448
12681 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.53) ] &&
12682 skip "No HSM $(lustre_build_version $SINGLEMDS) MDS < 2.4.53" &&
12684 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12685 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs" && return
12689 # Create a file with a released layout and stripe count 2.
12690 $MULTIOP $DIR/$tfile H2c ||
12691 error "failed to create file with released layout"
12693 $GETSTRIPE -v $DIR/$tfile
12695 local pattern=$($GETSTRIPE -L $DIR/$tfile)
12696 [ X"$pattern" = X"80000001" ] || error "pattern error ($pattern)"
12698 local stripe_count=$($GETSTRIPE -c $DIR/$tfile) || error "getstripe"
12699 [ $stripe_count -eq 2 ] || error "stripe count not 2 ($stripe_count)"
12700 stat $DIR/$tfile || error "failed to stat released file"
12702 chown $RUNAS_ID $DIR/$tfile ||
12703 error "chown $RUNAS_ID $DIR/$tfile failed"
12705 chgrp $RUNAS_ID $DIR/$tfile ||
12706 error "chgrp $RUNAS_ID $DIR/$tfile failed"
12708 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
12709 rm $DIR/$tfile || error "failed to remove released file"
12711 run_test 229 "getstripe/stat/rm/attr changes work on released files"
12714 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12715 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
12718 test_mkdir $DIR/$tdir
12719 test_mkdir -i0 -c1 $DIR/$tdir/test_230_local
12720 local mdt_idx=$($GETSTRIPE -M $DIR/$tdir/test_230_local)
12721 [ $mdt_idx -ne 0 ] &&
12722 error "create local directory on wrong MDT $mdt_idx"
12724 $LFS mkdir -i $MDTIDX $DIR/$tdir/test_230 ||
12725 error "create remote directory failed"
12726 local mdt_idx=$($GETSTRIPE -M $DIR/$tdir/test_230)
12727 [ $mdt_idx -ne $MDTIDX ] &&
12728 error "create remote directory on wrong MDT $mdt_idx"
12730 createmany -o $DIR/$tdir/test_230/t- 10 ||
12731 error "create files on remote directory failed"
12732 mdt_idx=$($GETSTRIPE -M $DIR/$tdir/test_230/t-0)
12733 [ $mdt_idx -ne $MDTIDX ] && error "create files on wrong MDT $mdt_idx"
12734 rm -r $DIR/$tdir || error "unlink remote directory failed"
12736 run_test 230a "Create remote directory and files under the remote directory"
12739 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12740 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
12747 local migrate_dir=$DIR/$tdir/migrate_dir
12748 local other_dir=$DIR/$tdir/other_dir
12750 test_mkdir $DIR/$tdir
12751 test_mkdir -i0 -c1 $migrate_dir
12752 test_mkdir -i0 -c1 $other_dir
12753 for ((i=0; i<10; i++)); do
12754 mkdir -p $migrate_dir/dir_${i}
12755 createmany -o $migrate_dir/dir_${i}/f 10 ||
12756 error "create files under remote dir failed $i"
12759 cp /etc/passwd $migrate_dir/$tfile
12760 cp /etc/passwd $other_dir/$tfile
12761 chattr +SAD $migrate_dir
12762 chattr +SAD $migrate_dir/$tfile
12764 local old_dir_flag=$(lsattr -a $migrate_dir | awk '/\/\.$/ {print $1}')
12765 local old_file_flag=$(lsattr $migrate_dir/$tfile | awk '{print $1}')
12766 local old_dir_mode=$(stat -c%f $migrate_dir)
12767 local old_file_mode=$(stat -c%f $migrate_dir/$tfile)
12769 mkdir -p $migrate_dir/dir_default_stripe2
12770 $SETSTRIPE -c 2 $migrate_dir/dir_default_stripe2
12771 $SETSTRIPE -c 2 $migrate_dir/${tfile}_stripe2
12773 mkdir -p $other_dir
12774 ln $migrate_dir/$tfile $other_dir/luna
12775 ln $migrate_dir/$tfile $migrate_dir/sofia
12776 ln $other_dir/$tfile $migrate_dir/david
12777 ln -s $migrate_dir/$tfile $other_dir/zachary
12778 ln -s $migrate_dir/$tfile $migrate_dir/${tfile}_ln
12779 ln -s $other_dir/$tfile $migrate_dir/${tfile}_ln_other
12781 $LFS migrate -m $MDTIDX $migrate_dir ||
12782 error "fails on migrating remote dir to MDT1"
12784 echo "migratate to MDT1, then checking.."
12785 for ((i = 0; i < 10; i++)); do
12786 for file in $(find $migrate_dir/dir_${i}); do
12787 mdt_index=$($LFS getstripe -M $file)
12788 [ $mdt_index == $MDTIDX ] ||
12789 error "$file is not on MDT${MDTIDX}"
12793 # the multiple link file should still in MDT0
12794 mdt_index=$($LFS getstripe -M $migrate_dir/$tfile)
12795 [ $mdt_index == 0 ] ||
12796 error "$file is not on MDT${MDTIDX}"
12798 local new_dir_flag=$(lsattr -a $migrate_dir | awk '/\/\.$/ {print $1}')
12799 [ "$old_dir_flag" = "$new_dir_flag" ] ||
12800 error " expect $old_dir_flag get $new_dir_flag"
12802 local new_file_flag=$(lsattr $migrate_dir/$tfile | awk '{print $1}')
12803 [ "$old_file_flag" = "$new_file_flag" ] ||
12804 error " expect $old_file_flag get $new_file_flag"
12806 local new_dir_mode=$(stat -c%f $migrate_dir)
12807 [ "$old_dir_mode" = "$new_dir_mode" ] ||
12808 error "expect mode $old_dir_mode get $new_dir_mode"
12810 local new_file_mode=$(stat -c%f $migrate_dir/$tfile)
12811 [ "$old_file_mode" = "$new_file_mode" ] ||
12812 error "expect mode $old_file_mode get $new_file_mode"
12814 diff /etc/passwd $migrate_dir/$tfile ||
12815 error "$tfile different after migration"
12817 diff /etc/passwd $other_dir/luna ||
12818 error "luna different after migration"
12820 diff /etc/passwd $migrate_dir/sofia ||
12821 error "sofia different after migration"
12823 diff /etc/passwd $migrate_dir/david ||
12824 error "david different after migration"
12826 diff /etc/passwd $other_dir/zachary ||
12827 error "zachary different after migration"
12829 diff /etc/passwd $migrate_dir/${tfile}_ln ||
12830 error "${tfile}_ln different after migration"
12832 diff /etc/passwd $migrate_dir/${tfile}_ln_other ||
12833 error "${tfile}_ln_other different after migration"
12835 stripe_count=$($LFS getstripe -c $migrate_dir/dir_default_stripe2)
12836 [ $stripe_count = 2 ] ||
12837 error "dir strpe_count $d != 2 after migration."
12839 stripe_count=$($LFS getstripe -c $migrate_dir/${tfile}_stripe2)
12840 [ $stripe_count = 2 ] ||
12841 error "file strpe_count $d != 2 after migration."
12843 #migrate back to MDT0
12846 $LFS migrate -m $MDTIDX $migrate_dir ||
12847 error "fails on migrating remote dir to MDT0"
12849 echo "migrate back to MDT0, checking.."
12850 for file in $(find $migrate_dir); do
12851 mdt_index=$($LFS getstripe -M $file)
12852 [ $mdt_index == $MDTIDX ] ||
12853 error "$file is not on MDT${MDTIDX}"
12856 local new_dir_flag=$(lsattr -a $migrate_dir | awk '/\/\.$/ {print $1}')
12857 [ "$old_dir_flag" = "$new_dir_flag" ] ||
12858 error " expect $old_dir_flag get $new_dir_flag"
12860 local new_file_flag=$(lsattr $migrate_dir/$tfile | awk '{print $1}')
12861 [ "$old_file_flag" = "$new_file_flag" ] ||
12862 error " expect $old_file_flag get $new_file_flag"
12864 local new_dir_mode=$(stat -c%f $migrate_dir)
12865 [ "$old_dir_mode" = "$new_dir_mode" ] ||
12866 error "expect mode $old_dir_mode get $new_dir_mode"
12868 local new_file_mode=$(stat -c%f $migrate_dir/$tfile)
12869 [ "$old_file_mode" = "$new_file_mode" ] ||
12870 error "expect mode $old_file_mode get $new_file_mode"
12872 diff /etc/passwd ${migrate_dir}/$tfile ||
12873 error "$tfile different after migration"
12875 diff /etc/passwd ${other_dir}/luna ||
12876 error "luna different after migration"
12878 diff /etc/passwd ${migrate_dir}/sofia ||
12879 error "sofia different after migration"
12881 diff /etc/passwd ${other_dir}/zachary ||
12882 error "zachary different after migration"
12884 diff /etc/passwd $migrate_dir/${tfile}_ln ||
12885 error "${tfile}_ln different after migration"
12887 diff /etc/passwd $migrate_dir/${tfile}_ln_other ||
12888 error "${tfile}_ln_other different after migration"
12890 stripe_count=$($LFS getstripe -c ${migrate_dir}/dir_default_stripe2)
12891 [ $stripe_count = 2 ] ||
12892 error "dir strpe_count $d != 2 after migration."
12894 stripe_count=$($LFS getstripe -c ${migrate_dir}/${tfile}_stripe2)
12895 [ $stripe_count = 2 ] ||
12896 error "file strpe_count $d != 2 after migration."
12898 rm -rf $DIR/$tdir || error "rm dir failed after migration"
12900 run_test 230b "migrate directory"
12903 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12904 remote_mds_nodsh && skip "remote MDS with nodsh" && return
12905 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
12909 local migrate_dir=$DIR/$tdir/migrate_dir
12911 #If migrating directory fails in the middle, all entries of
12912 #the directory is still accessiable.
12913 test_mkdir $DIR/$tdir
12914 test_mkdir -i0 -c1 $migrate_dir
12916 createmany -o $migrate_dir/f 10 ||
12917 error "create files under ${migrate_dir} failed"
12919 #failed after migrating 5 entries
12920 #OBD_FAIL_MIGRATE_ENTRIES 0x1801
12921 do_facet mds1 lctl set_param fail_loc=0x20001801
12922 do_facet mds1 lctl set_param fail_val=5
12923 local t=$(ls $migrate_dir | wc -l)
12924 $LFS migrate --mdt-index $MDTIDX $migrate_dir &&
12925 error "migrate should fail after 5 entries"
12927 mkdir $migrate_dir/dir &&
12928 error "mkdir succeeds under migrating directory"
12929 touch $migrate_dir/file &&
12930 error "touch file succeeds under migrating directory"
12932 local u=$(ls $migrate_dir | wc -l)
12933 [ "$u" == "$t" ] || error "$u != $t during migration"
12935 for file in $(find $migrate_dir); do
12936 stat $file || error "stat $file failed"
12939 do_facet mds1 lctl set_param fail_loc=0
12940 do_facet mds1 lctl set_param fail_val=0
12942 $LFS migrate -m $MDTIDX $migrate_dir ||
12943 error "migrate open files should failed with open files"
12945 echo "Finish migration, then checking.."
12946 for file in $(find $migrate_dir); do
12947 mdt_index=$($LFS getstripe -M $file)
12948 [ $mdt_index == $MDTIDX ] ||
12949 error "$file is not on MDT${MDTIDX}"
12952 rm -rf $DIR/$tdir || error "rm dir failed after migration"
12954 run_test 230c "check directory accessiblity if migration is failed"
12957 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12958 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
12961 local migrate_dir=$DIR/$tdir/migrate_dir
12965 test_mkdir $DIR/$tdir
12966 test_mkdir -i0 -c1 $migrate_dir
12968 for ((i=0; i<100; i++)); do
12969 test_mkdir -i0 -c1 $migrate_dir/dir_${i}
12970 createmany -o $migrate_dir/dir_${i}/f 100 ||
12971 error "create files under remote dir failed $i"
12974 $LFS migrate -m $MDTIDX $migrate_dir ||
12975 error "migrate remote dir error"
12977 echo "Finish migration, then checking.."
12978 for file in $(find $migrate_dir); do
12979 mdt_index=$($LFS getstripe -M $file)
12980 [ $mdt_index == $MDTIDX ] ||
12981 error "$file is not on MDT${MDTIDX}"
12984 rm -rf $DIR/$tdir || error "rm dir failed after migration"
12986 run_test 230d "check migrate big directory"
12989 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12990 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
12996 mkdir -p $DIR/$tdir
12997 mkdir $DIR/$tdir/migrate_dir
12998 mkdir $DIR/$tdir/other_dir
12999 touch $DIR/$tdir/migrate_dir/a
13000 ln $DIR/$tdir/migrate_dir/a $DIR/$tdir/other_dir/b
13001 ls $DIR/$tdir/other_dir
13003 $LFS migrate -m 1 $DIR/$tdir/migrate_dir ||
13004 error "migrate dir fails"
13006 mdt_index=$($LFS getstripe -M $DIR/$tdir/migrate_dir)
13007 [ $mdt_index == 1 ] || error "migrate_dir is not on MDT1"
13009 mdt_index=$($LFS getstripe -M $DIR/$tdir/migrate_dir/a)
13010 [ $mdt_index == 0 ] || error "a is not on MDT0"
13012 $LFS migrate -m 1 $DIR/$tdir/other_dir ||
13013 error "migrate dir fails"
13015 mdt_index=$($LFS getstripe -M $DIR/$tdir/other_dir)
13016 [ $mdt_index == 1 ] || error "other_dir is not on MDT1"
13018 mdt_index=$($LFS getstripe -M $DIR/$tdir/migrate_dir/a)
13019 [ $mdt_index == 1 ] || error "a is not on MDT1"
13021 mdt_index=$($LFS getstripe -M $DIR/$tdir/other_dir/b)
13022 [ $mdt_index == 1 ] || error "b is not on MDT1"
13024 a_fid=$($LFS path2fid $DIR/$tdir/migrate_dir/a)
13025 b_fid=$($LFS path2fid $DIR/$tdir/other_dir/b)
13027 [ "$a_fid" = "$b_fid" ] || error "different fid after migration"
13029 rm -rf $DIR/$tdir || error "rm dir failed after migration"
13031 run_test 230e "migrate mulitple local link files"
13034 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13035 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
13039 mkdir -p $DIR/$tdir
13040 mkdir $DIR/$tdir/migrate_dir
13041 $LFS mkdir -i1 $DIR/$tdir/other_dir
13042 touch $DIR/$tdir/migrate_dir/a
13043 ln $DIR/$tdir/migrate_dir/a $DIR/$tdir/other_dir/ln1
13044 ln $DIR/$tdir/migrate_dir/a $DIR/$tdir/other_dir/ln2
13045 ls $DIR/$tdir/other_dir
13047 # a should be migrated to MDT1, since no other links on MDT0
13048 $LFS migrate -m 1 $DIR/$tdir/migrate_dir ||
13049 error "migrate dir fails"
13050 mdt_index=$($LFS getstripe -M $DIR/$tdir/migrate_dir)
13051 [ $mdt_index == 1 ] || error "migrate_dir is not on MDT1"
13052 mdt_index=$($LFS getstripe -M $DIR/$tdir/migrate_dir/a)
13053 [ $mdt_index == 1 ] || error "a is not on MDT1"
13055 # a should stay on MDT1, because it is a mulitple link file
13056 $LFS migrate -m 0 $DIR/$tdir/migrate_dir ||
13057 error "migrate dir fails"
13058 mdt_index=$($LFS getstripe -M $DIR/$tdir/migrate_dir/a)
13059 [ $mdt_index == 1 ] || error "a is not on MDT1"
13061 $LFS migrate -m 1 $DIR/$tdir/migrate_dir ||
13062 error "migrate dir fails"
13064 a_fid=$($LFS path2fid $DIR/$tdir/migrate_dir/a)
13065 ln_fid=$($LFS path2fid $DIR/$tdir/other_dir/ln1)
13066 [ "$a_fid" = "$ln_fid" ] || error "different fid after migrate to MDT1"
13068 rm -rf $DIR/$tdir/other_dir/ln1 || error "unlink ln1 fails"
13069 rm -rf $DIR/$tdir/other_dir/ln2 || error "unlink ln2 fails"
13071 # a should be migrated to MDT0, since no other links on MDT1
13072 $LFS migrate -m 0 $DIR/$tdir/migrate_dir ||
13073 error "migrate dir fails"
13074 mdt_index=$($LFS getstripe -M $DIR/$tdir/migrate_dir/a)
13075 [ $mdt_index == 0 ] || error "a is not on MDT0"
13077 rm -rf $DIR/$tdir || error "rm dir failed after migration"
13079 run_test 230f "migrate mulitple remote link files"
13082 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13083 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
13085 mkdir -p $DIR/$tdir/migrate_dir
13087 $LFS migrate -m 1000 $DIR/$tdir/migrate_dir &&
13088 error "migrating dir to non-exist MDT succeeds"
13091 run_test 230g "migrate dir to non-exist MDT"
13094 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13095 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
13096 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.64) ] &&
13097 skip "Need MDS version at least 2.7.64" && return
13100 mkdir -p $DIR/$tdir/migrate_dir
13102 $LFS migrate -m1 $DIR &&
13103 error "migrating mountpoint1 should fail"
13105 $LFS migrate -m1 $DIR/$tdir/.. &&
13106 error "migrating mountpoint2 should fail"
13108 $LFS migrate -m1 $DIR/$tdir/migrate_dir/.. ||
13109 error "migrating $tdir fail"
13111 mdt_index=$($LFS getstripe -M $DIR/$tdir)
13112 [ $mdt_index == 1 ] || error "$mdt_index != 1 after migration"
13114 mdt_index=$($LFS getstripe -M $DIR/$tdir/migrate_dir)
13115 [ $mdt_index == 1 ] || error "$mdt_index != 1 after migration"
13118 run_test 230h "migrate .. and root"
13122 # For simplicity this test assumes that max_pages_per_rpc
13123 # is the same across all OSCs
13124 local max_pages=$($LCTL get_param -n osc.*.max_pages_per_rpc | head -n1)
13125 local bulk_size=$((max_pages * 4096))
13127 mkdir -p $DIR/$tdir
13129 # clear the OSC stats
13130 $LCTL set_param osc.*.stats=0 &>/dev/null
13133 # Client writes $bulk_size - there must be 1 rpc for $max_pages.
13134 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=$bulk_size count=1 \
13135 oflag=direct &>/dev/null || error "dd failed"
13137 sync; sleep 1; sync # just to be safe
13138 local nrpcs=$($LCTL get_param osc.*.stats |awk '/ost_write/ {print $2}')
13139 if [ x$nrpcs != "x1" ]; then
13140 $LCTL get_param osc.*.stats
13141 error "found $nrpcs ost_write RPCs, not 1 as expected"
13145 # Drop the OSC cache, otherwise we will read from it
13146 cancel_lru_locks osc
13148 # clear the OSC stats
13149 $LCTL set_param osc.*.stats=0 &>/dev/null
13151 # Client reads $bulk_size.
13152 dd if=$DIR/$tdir/$tfile of=/dev/null bs=$bulk_size count=1 \
13153 iflag=direct &>/dev/null || error "dd failed"
13155 nrpcs=$($LCTL get_param osc.*.stats | awk '/ost_read/ { print $2 }')
13156 if [ x$nrpcs != "x1" ]; then
13157 $LCTL get_param osc.*.stats
13158 error "found $nrpcs ost_read RPCs, not 1 as expected"
13161 run_test 231a "checking that reading/writing of BRW RPC size results in one RPC"
13164 mkdir -p $DIR/$tdir
13166 for i in {0..1023}; do
13167 dd if=/dev/zero of=$DIR/$tdir/$tfile conv=notrunc \
13168 seek=$((2 * i)) bs=4096 count=1 &>/dev/null ||
13169 error "dd of=$DIR/$tdir/$tfile seek=$((2 * i)) failed"
13173 run_test 231b "must not assert on fully utilized OST request buffer"
13176 mkdir -p $DIR/$tdir
13177 #define OBD_FAIL_LDLM_OST_LVB 0x31c
13178 $LCTL set_param fail_loc=0x31c
13180 # ignore dd failure
13181 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=1 || true
13183 $LCTL set_param fail_loc=0
13184 umount_client $MOUNT || error "umount failed"
13185 mount_client $MOUNT || error "mount failed"
13187 run_test 232 "failed lock should not block umount"
13190 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.3.64) ] ||
13191 { skip "Need MDS version at least 2.3.64"; return; }
13193 local fid=$($LFS path2fid $MOUNT)
13194 stat $MOUNT/.lustre/fid/$fid > /dev/null ||
13195 error "cannot access $MOUNT using its FID '$fid'"
13197 run_test 233a "checking that OBF of the FS root succeeds"
13200 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.5.90) ] ||
13201 { skip "Need MDS version at least 2.5.90"; return; }
13203 local fid=$($LFS path2fid $MOUNT/.lustre)
13204 stat $MOUNT/.lustre/fid/$fid > /dev/null ||
13205 error "cannot access $MOUNT/.lustre using its FID '$fid'"
13207 fid=$($LFS path2fid $MOUNT/.lustre/fid)
13208 stat $MOUNT/.lustre/fid/$fid > /dev/null ||
13209 error "cannot access $MOUNT/.lustre/fid using its FID '$fid'"
13211 run_test 233b "checking that OBF of the FS .lustre succeeds"
13214 local p="$TMP/sanityN-$TESTNAME.parameters"
13215 save_lustre_params client "llite.*.xattr_cache" > $p
13216 lctl set_param llite.*.xattr_cache 1 ||
13217 { skip "xattr cache is not supported"; return 0; }
13219 mkdir -p $DIR/$tdir || error "mkdir failed"
13220 touch $DIR/$tdir/$tfile || error "touch failed"
13221 # OBD_FAIL_LLITE_XATTR_ENOMEM
13222 $LCTL set_param fail_loc=0x1405
13223 # output of the form: attr 2 4 44 3 fc13 x86_64
13224 V=($(IFS=".-" rpm -q attr))
13225 if [[ ${V[1]} > 2 || ${V[2]} > 4 || ${V[3]} > 44 ||
13226 ${V[1]} = 2 && ${V[2]} = 4 && ${V[3]} = 44 && ${V[4]} > 6 ]]; then
13227 # attr pre-2.4.44-7 had a bug with rc
13228 # LU-3703 - SLES 11 and FC13 clients have older attr
13229 getfattr -n user.attr $DIR/$tdir/$tfile &&
13230 error "getfattr should have failed with ENOMEM"
13232 skip "LU-3703: attr version $(getfattr --version) too old"
13234 $LCTL set_param fail_loc=0x0
13237 restore_lustre_params < $p
13240 run_test 234 "xattr cache should not crash on ENOMEM"
13243 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.52) ] &&
13244 skip "Need MDS version at least 2.4.52" && return
13245 flock_deadlock $DIR/$tfile
13250 124) error "process hangs on a deadlock"
13252 *) error "error executing flock_deadlock $DIR/$tfile"
13256 run_test 235 "LU-1715: flock deadlock detection does not work properly"
13260 check_swap_layouts_support && return 0
13261 test_mkdir -p -c1 $DIR/$tdir || error "mkdir $tdir failed"
13263 local ref1=/etc/passwd
13264 local ref2=/etc/group
13265 local file1=$DIR/$tdir/f1
13266 local file2=$DIR/$tdir/f2
13268 $SETSTRIPE -c 1 $file1 || error "cannot setstripe on '$file1': rc = $?"
13269 cp $ref1 $file1 || error "cp $ref1 $file1 failed: rc = $?"
13270 $SETSTRIPE -c 2 $file2 || error "cannot setstripe on '$file2': rc = $?"
13271 cp $ref2 $file2 || error "cp $ref2 $file2 failed: rc = $?"
13272 local fd=$(free_fd)
13273 local cmd="exec $fd<>$file2"
13276 $LFS swap_layouts $file1 /proc/self/fd/${fd} ||
13277 error "cannot swap layouts of '$file1' and /proc/self/fd/${fd}"
13280 cmp $ref2 $file1 || error "content compare failed ($ref2 != $file1)"
13285 run_test 236 "Layout swap on open unlinked file"
13287 # test to verify file handle related system calls
13288 # (name_to_handle_at/open_by_handle_at)
13289 # The new system calls are supported in glibc >= 2.14.
13292 echo "Test file_handle syscalls" > $DIR/$tfile ||
13293 error "write failed"
13294 check_fhandle_syscalls $DIR/$tfile ||
13295 error "check_fhandle_syscalls failed"
13297 run_test 237 "Verify name_to_handle_at/open_by_handle_at syscalls"
13299 # LU-4659 linkea consistency
13301 local server_version=$(lustre_version_code $SINGLEMDS)
13303 [[ $server_version -gt $(version_code 2.5.57) ]] ||
13304 [[ $server_version -gt $(version_code 2.5.1) &&
13305 $server_version -lt $(version_code 2.5.50) ]] ||
13306 { skip "Need MDS version at least 2.5.58 or 2.5.2+"; return; }
13309 ln $DIR/$tfile $DIR/$tfile.lnk
13310 touch $DIR/$tfile.new
13311 mv $DIR/$tfile.new $DIR/$tfile
13312 local fid1=$($LFS path2fid $DIR/$tfile)
13313 local fid2=$($LFS path2fid $DIR/$tfile.lnk)
13314 local path1=$($LFS fid2path $FSNAME "$fid1")
13315 [ $tfile == $path1 ] || error "linkea inconsistent: $tfile $fid1 $path1"
13316 local path2=$($LFS fid2path $FSNAME "$fid2")
13317 [ $tfile.lnk == $path2 ] ||
13318 error "linkea inconsistent: $tfile.lnk $fid2 $path2!"
13321 run_test 238 "Verify linkea consistency"
13324 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.5.60) ] &&
13325 skip "Need MDS version at least 2.5.60" && return
13326 local list=$(comma_list $(mdts_nodes))
13328 mkdir -p $DIR/$tdir
13329 createmany -o $DIR/$tdir/f- 5000
13330 unlinkmany $DIR/$tdir/f- 5000
13331 do_nodes $list "lctl set_param -n osp*.*.sync_changes 1"
13332 changes=$(do_nodes $list "lctl get_param -n osc.*MDT*.sync_changes \
13333 osc.*MDT*.sync_in_flight" | calc_sum)
13334 [ "$changes" -eq 0 ] || error "$changes not synced"
13336 run_test 239 "osp_sync test"
13338 test_239a() { #LU-5297
13340 #define OBD_FAIL_OSP_CHECK_INVALID_REC 0x2100
13341 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x2100
13342 chgrp $RUNAS_GID $DIR/$tfile
13343 wait_delete_completed
13345 run_test 239a "process invalid osp sync record correctly"
13347 test_239b() { #LU-5297
13349 #define OBD_FAIL_OSP_CHECK_ENOMEM 0x2101
13350 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x2101
13351 chgrp $RUNAS_GID $DIR/$tfile1
13352 wait_delete_completed
13353 do_facet $SINGLEMDS $LCTL set_param fail_loc=0
13355 chgrp $RUNAS_GID $DIR/$tfile2
13356 wait_delete_completed
13358 run_test 239b "process osp sync record with ENOMEM error correctly"
13361 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
13363 mkdir -p $DIR/$tdir
13365 $LFS mkdir -i 0 $DIR/$tdir/d0 ||
13366 error "failed to mkdir $DIR/$tdir/d0 on MDT0"
13367 $LFS mkdir -i 1 $DIR/$tdir/d0/d1 ||
13368 error "failed to mkdir $DIR/$tdir/d0/d1 on MDT1"
13370 umount_client $MOUNT || error "umount failed"
13371 #define OBD_FAIL_TGT_DELAY_CONDITIONAL 0x713
13372 do_facet mds2 lctl set_param fail_loc=0x713 fail_val=1
13373 mount_client $MOUNT || error "failed to mount client"
13375 echo "stat $DIR/$tdir/d0/d1, should not fail/ASSERT"
13376 stat $DIR/$tdir/d0/d1 || error "fail to stat $DIR/$tdir/d0/d1"
13378 run_test 240 "race between ldlm enqueue and the connection RPC (no ASSERT)"
13381 for LOOP in $(seq $1); do
13382 dd if=$DIR/$tfile of=/dev/null bs=40960 count=1 2>/dev/null
13383 cancel_lru_locks osc
13388 for LOOP in $(seq $1); do
13389 dd if=$DIR/$tfile of=/dev/null bs=40960 count=1 \
13390 iflag=direct 2>/dev/null
13395 dd if=/dev/zero of=$DIR/$tfile count=1 bs=40960
13397 cancel_lru_locks osc
13398 test_241_bio 1000 &
13403 run_test 241 "bio vs dio"
13406 dd if=/dev/zero of=$DIR/$tfile count=1 bs=40960
13408 test_241_dio 1000 &
13413 run_test 241b "dio vs dio"
13416 mkdir -p $DIR/$tdir
13417 touch $DIR/$tdir/$tfile
13419 #define OBD_FAIL_MDS_READPAGE_PACK 0x105
13420 do_facet mds1 lctl set_param fail_loc=0x105
13421 /bin/ls $DIR/$tdir && error "ls $DIR/$tdir should fail"
13423 do_facet mds1 lctl set_param fail_loc=0
13424 /bin/ls $DIR/$tdir || error "ls $DIR/$tdir failed"
13426 run_test 242 "mdt_readpage failure should not cause directory unreadable"
13430 test_mkdir -p $DIR/$tdir
13431 group_lock_test -d $DIR/$tdir || error "A group lock test failed"
13433 run_test 243 "various group lock tests"
13437 test_mkdir -p $DIR/$tdir
13438 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=35
13439 sendfile_grouplock $DIR/$tdir/$tfile || \
13440 error "sendfile+grouplock failed"
13443 run_test 244 "sendfile with group lock tests"
13446 local flagname="multi_mod_rpcs"
13447 local connect_data_name="max_mod_rpcs"
13450 # check if multiple modify RPCs flag is set
13451 out=$($LCTL get_param mdc.$FSNAME-MDT0000-*.import |
13452 grep "connect_flags:")
13455 echo "$out" | grep -qw $flagname
13456 if [ $? -ne 0 ]; then
13457 echo "connect flag $flagname is not set"
13461 # check if multiple modify RPCs data is set
13462 out=$($LCTL get_param mdc.$FSNAME-MDT0000-*.import)
13465 echo "$out" | grep -qw $connect_data_name ||
13466 error "import should have connect data $connect_data_name"
13468 run_test 245 "check mdc connection flag/data: multiple modify RPCs"
13470 test_246() { # LU-7371
13471 [ $(lustre_version_code ost1) -lt $(version_code 2.7.62) ] &&
13472 skip "Need OST version >= 2.7.62" && return 0
13473 do_facet ost1 $LCTL set_param fail_val=4095
13474 #define OBD_FAIL_OST_READ_SIZE 0x234
13475 do_facet ost1 $LCTL set_param fail_loc=0x234
13476 $LFS setstripe $DIR/$tfile -i 0 -c 1
13477 dd if=/dev/zero of=$DIR/$tfile bs=4095 count=1 > /dev/null 2>&1
13478 cancel_lru_locks $FSNAME-OST0000
13479 dd if=$DIR/$tfile of=/dev/null bs=1048576 || error "Read failed"
13481 run_test 246 "Read file of size 4095 should return right length"
13484 [ "$(facet_fstype ost$(($($GETSTRIPE -i $DIR/$tfile) + 1)))" = "zfs" ] \
13485 && skip "no 16TB file size limit on ZFS" && return
13487 $SETSTRIPE -c 1 $DIR/$tfile
13488 # ldiskfs extent file size limit is (16TB - 4KB - 1) bytes
13489 local size=$((16 * 1024 * 1024 * 1024 * 1024 - 4096 - 1))
13490 $TRUNCATE $DIR/$tfile $size || error "truncate $tfile to $size failed"
13491 dd if=/dev/zero of=$DIR/$tfile bs=10 count=1 oflag=append \
13492 conv=notrunc,fsync && error "append succeeded"
13495 run_test 250 "Write above 16T limit"
13498 $SETSTRIPE -c -1 -S 1048576 $DIR/$tfile
13500 #define OBD_FAIL_LLITE_LOST_LAYOUT 0x1407
13501 #Skip once - writing the first stripe will succeed
13502 $LCTL set_param fail_loc=0xa0001407 fail_val=1
13503 $MULTIOP $DIR/$tfile o:O_RDWR:w2097152c 2>&1 | grep -q "short write" &&
13504 error "short write happened"
13506 $LCTL set_param fail_loc=0xa0001407 fail_val=1
13507 $MULTIOP $DIR/$tfile or2097152c 2>&1 | grep -q "short read" &&
13508 error "short read happened"
13512 run_test 251 "Handling short read and write correctly"
13522 if [ "$(facet_fstype ost1)" != "ldiskfs" -o \
13523 "$(facet_fstype mds1)" != "ldiskfs" ]; then
13524 skip "can only run lr_reader on ldiskfs target"
13528 # check lr_reader on OST0000
13530 dev=$(facet_device $tgt)
13531 out=$(do_facet $tgt $LR_READER $dev)
13532 [ $? -eq 0 ] || error "$LR_READER failed on target $tgt device $dev"
13534 uuid=$(echo "$out" | grep -i uuid | awk '{ print $2 }')
13535 [ "$uuid" == "$(ostuuid_from_index 0)" ] ||
13536 error "Invalid uuid returned by $LR_READER on target $tgt"
13537 echo -e "uuid returned by $LR_READER is '$uuid'\n"
13539 # check lr_reader -c on MDT0000
13541 dev=$(facet_device $tgt)
13542 if ! do_facet $tgt $LR_READER -h | grep -q OPTIONS; then
13543 echo "$LR_READER does not support additional options"
13546 out=$(do_facet $tgt $LR_READER -c $dev)
13547 [ $? -eq 0 ] || error "$LR_READER failed on target $tgt device $dev"
13549 num=$(echo "$out" | grep -c "mdtlov")
13550 [ "$num" -eq $((MDSCOUNT - 1)) ] ||
13551 error "Invalid number of mdtlov clients returned by $LR_READER"
13552 echo -e "Number of mdtlov clients returned by $LR_READER is '$num'\n"
13554 # check lr_reader -cr on MDT0000
13555 out=$(do_facet $tgt $LR_READER -cr $dev)
13556 [ $? -eq 0 ] || error "$LR_READER failed on target $tgt device $dev"
13558 echo "$out" | grep -q "^reply_data:$" ||
13559 error "$LR_READER should have returned 'reply_data' section"
13560 num=$(echo "$out" | grep -c "client_generation")
13561 echo -e "Number of reply data returned by $LR_READER is '$num'\n"
13563 run_test 252 "check lr_reader tool"
13566 cleanup_test_300() {
13570 test_striped_dir() {
13575 mkdir -p $DIR/$tdir
13577 SAVE_UMASK=$(umask)
13578 trap cleanup_test_300 RETURN EXIT
13580 $LFS setdirstripe -i $mdt_index -c 2 -t all_char -m 755 \
13581 $DIR/$tdir/striped_dir ||
13582 error "set striped dir error"
13584 local mode=$(stat -c%a $DIR/$tdir/striped_dir)
13585 [ "$mode" = "755" ] || error "expect 755 got $mode"
13587 $LFS getdirstripe $DIR/$tdir/striped_dir > /dev/null 2>&1 ||
13588 error "getdirstripe failed"
13589 stripe_count=$($LFS getdirstripe -c $DIR/$tdir/striped_dir)
13590 if [ "$stripe_count" != "2" ]; then
13591 error "stripe_count is $stripe_count, expect 2"
13594 stripe_index=$($LFS getdirstripe -i $DIR/$tdir/striped_dir)
13595 if [ "$stripe_index" != "$mdt_index" ]; then
13596 error "stripe_index is $stripe_index, expect $mdt_index"
13599 [ $(stat -c%h $DIR/$tdir/striped_dir) == '2' ] ||
13600 error "nlink error after create striped dir"
13602 mkdir $DIR/$tdir/striped_dir/a
13603 mkdir $DIR/$tdir/striped_dir/b
13605 stat $DIR/$tdir/striped_dir/a ||
13606 error "create dir under striped dir failed"
13607 stat $DIR/$tdir/striped_dir/b ||
13608 error "create dir under striped dir failed"
13610 [ $(stat -c%h $DIR/$tdir/striped_dir) == '4' ] ||
13611 error "nlink error after mkdir"
13613 rmdir $DIR/$tdir/striped_dir/a
13614 [ $(stat -c%h $DIR/$tdir/striped_dir) == '3' ] ||
13615 error "nlink error after rmdir"
13617 rmdir $DIR/$tdir/striped_dir/b
13618 [ $(stat -c%h $DIR/$tdir/striped_dir) == '2' ] ||
13619 error "nlink error after rmdir"
13621 chattr +i $DIR/$tdir/striped_dir
13622 createmany -o $DIR/$tdir/striped_dir/f 10 &&
13623 error "immutable flags not working under striped dir!"
13624 chattr -i $DIR/$tdir/striped_dir
13626 rmdir $DIR/$tdir/striped_dir ||
13627 error "rmdir striped dir error"
13635 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13636 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
13638 test_striped_dir 0 || error "failed on striped dir on MDT0"
13639 test_striped_dir 1 || error "failed on striped dir on MDT0"
13641 run_test 300a "basic striped dir sanity test"
13644 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13645 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
13651 test_mkdir $DIR/$tdir || error "mkdir fail"
13652 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir ||
13653 error "set striped dir error"
13654 for ((i=0; i<10; i++)); do
13655 mtime1=$(stat -c %Y $DIR/$tdir/striped_dir)
13657 touch $DIR/$tdir/striped_dir/file_$i ||
13658 error "touch error $i"
13659 mtime2=$(stat -c %Y $DIR/$tdir/striped_dir)
13660 [ $mtime1 -eq $mtime2 ] &&
13661 error "mtime not change after create"
13663 rm -f $DIR/$tdir/striped_dir/file_$i ||
13664 error "unlink error $i"
13665 mtime3=$(stat -c %Y $DIR/$tdir/striped_dir)
13666 [ $mtime2 -eq $mtime3 ] &&
13667 error "mtime did not change after unlink"
13671 run_test 300b "check ctime/mtime for striped dir"
13674 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13675 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
13678 mkdir -p $DIR/$tdir
13679 $LFS setdirstripe -i 0 -c 2 $DIR/$tdir/striped_dir ||
13680 error "set striped dir error"
13682 chown $RUNAS_ID:$RUNAS_GID $DIR/$tdir/striped_dir ||
13683 error "chown striped dir failed"
13685 $RUNAS createmany -o $DIR/$tdir/striped_dir/f 5000 ||
13686 error "create 5k files failed"
13688 file_count=$(ls $DIR/$tdir/striped_dir | wc -l)
13690 [ "$file_count" = 5000 ] || error "file count $file_count != 5000"
13694 run_test 300c "chown && check ls under striped directory"
13697 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13698 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
13702 mkdir -p $DIR/$tdir
13703 $SETSTRIPE -c 2 $DIR/$tdir
13705 #local striped directory
13706 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir ||
13707 error "set striped dir error"
13708 createmany -o $DIR/$tdir/striped_dir/f 10 ||
13709 error "create 10 files failed"
13711 #remote striped directory
13712 $LFS setdirstripe -i 1 -c 2 $DIR/$tdir/remote_striped_dir ||
13713 error "set striped dir error"
13714 createmany -o $DIR/$tdir/remote_striped_dir/f 10 ||
13715 error "create 10 files failed"
13717 for file in $(find $DIR/$tdir); do
13718 stripe_count=$($GETSTRIPE -c $file)
13719 [ $stripe_count -eq 2 ] ||
13720 error "wrong stripe $stripe_count for $file"
13725 run_test 300d "check default stripe under striped directory"
13728 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
13729 skip "Need MDS version at least 2.7.55" && return
13730 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13731 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
13735 mkdir -p $DIR/$tdir
13737 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir ||
13738 error "set striped dir error"
13740 touch $DIR/$tdir/striped_dir/a
13741 touch $DIR/$tdir/striped_dir/b
13742 touch $DIR/$tdir/striped_dir/c
13744 mkdir $DIR/$tdir/striped_dir/dir_a
13745 mkdir $DIR/$tdir/striped_dir/dir_b
13746 mkdir $DIR/$tdir/striped_dir/dir_c
13748 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir/stp_a ||
13749 error "set striped dir under striped dir error"
13751 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir/stp_b ||
13752 error "set striped dir under striped dir error"
13754 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir/stp_c ||
13755 error "set striped dir under striped dir error"
13757 mrename $DIR/$tdir/striped_dir/dir_a $DIR/$tdir/striped_dir/dir_b ||
13758 error "rename dir under striped dir fails"
13760 mrename $DIR/$tdir/striped_dir/stp_a $DIR/$tdir/striped_dir/stp_b ||
13761 error "rename dir under different stripes fails"
13763 mrename $DIR/$tdir/striped_dir/a $DIR/$tdir/striped_dir/c ||
13764 error "rename file under striped dir should succeed"
13766 mrename $DIR/$tdir/striped_dir/dir_b $DIR/$tdir/striped_dir/dir_c ||
13767 error "rename dir under striped dir should succeed"
13771 run_test 300e "check rename under striped directory"
13774 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
13775 skip "Need MDS version at least 2.7.55" && return
13776 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13777 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
13782 mkdir -p $DIR/$tdir
13784 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir ||
13785 error "set striped dir error"
13787 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir1 ||
13788 error "set striped dir error"
13790 touch $DIR/$tdir/striped_dir/a
13791 mkdir $DIR/$tdir/striped_dir/dir_a
13792 $LFS setdirstripe -i 0 -c 2 $DIR/$tdir/striped_dir/stp_a ||
13793 error "create striped dir under striped dir fails"
13795 touch $DIR/$tdir/striped_dir1/b
13796 mkdir $DIR/$tdir/striped_dir1/dir_b
13797 $LFS setdirstripe -i 0 -c 2 $DIR/$tdir/striped_dir/stp_b ||
13798 error "create striped dir under striped dir fails"
13800 mrename $DIR/$tdir/striped_dir/dir_a $DIR/$tdir/striped_dir1/dir_b ||
13801 error "rename dir under different striped dir should fail"
13803 mrename $DIR/$tdir/striped_dir/stp_a $DIR/$tdir/striped_dir1/stp_b ||
13804 error "rename striped dir under diff striped dir should fail"
13806 mrename $DIR/$tdir/striped_dir/a $DIR/$tdir/striped_dir1/a ||
13807 error "rename file under diff striped dirs fails"
13811 run_test 300f "check rename cross striped directory"
13813 test_300_check_default_striped_dir()
13816 local default_count=$2
13817 local default_index=$3
13820 local dir_stripe_index
13823 echo "checking $dirname $default_count $default_index"
13824 $LFS setdirstripe -D -c $default_count -i $default_index \
13825 -t all_char $DIR/$tdir/$dirname ||
13826 error "set default stripe on striped dir error"
13827 stripe_count=$($LFS getdirstripe -D -c $DIR/$tdir/$dirname)
13828 [ $stripe_count -eq $default_count ] ||
13829 error "expect $default_count get $stripe_count for $dirname"
13831 stripe_index=$($LFS getdirstripe -D -i $DIR/$tdir/$dirname)
13832 [ $stripe_index -eq $default_index ] ||
13833 error "expect $default_index get $stripe_index for $dirname"
13835 mkdir $DIR/$tdir/$dirname/{test1,test2,test3,test4} ||
13836 error "create dirs failed"
13838 createmany -o $DIR/$tdir/$dirname/f- 10 || error "create files failed"
13839 unlinkmany $DIR/$tdir/$dirname/f- 10 || error "unlink files failed"
13840 for dir in $(find $DIR/$tdir/$dirname/*); do
13841 stripe_count=$($LFS getdirstripe -c $dir)
13842 [ $stripe_count -eq $default_count ] ||
13843 [ $stripe_count -eq 0 -o $default_count -eq 1 ] ||
13844 error "stripe count $default_count != $stripe_count for $dir"
13846 stripe_index=$($LFS getdirstripe -i $dir)
13847 [ $default_index -eq -1 -o $stripe_index -eq $default_index ] ||
13848 error "$stripe_index != $default_index for $dir"
13850 #check default stripe
13851 stripe_count=$($LFS getdirstripe -D -c $dir)
13852 [ $stripe_count -eq $default_count ] ||
13853 error "default count $default_count != $stripe_count for $dir"
13855 stripe_index=$($LFS getdirstripe -D -i $dir)
13856 [ $stripe_index -eq $default_index ] ||
13857 error "default index $default_index != $stripe_index for $dir"
13859 rmdir $DIR/$tdir/$dirname/* || error "rmdir failed"
13863 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
13864 skip "Need MDS version at least 2.7.55" && return
13865 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
13871 mkdir $DIR/$tdir/normal_dir
13873 test_300_check_default_striped_dir normal_dir $MDSCOUNT 1
13874 test_300_check_default_striped_dir normal_dir 1 0
13875 test_300_check_default_striped_dir normal_dir 2 1
13876 test_300_check_default_striped_dir normal_dir 2 -1
13878 #delete default stripe information
13879 echo "delete default stripeEA"
13880 $LFS setdirstripe -d $DIR/$tdir/normal_dir ||
13881 error "set default stripe on striped dir error"
13883 mkdir -p $DIR/$tdir/normal_dir/{test1,test2,test3,test4}
13884 for dir in $(find $DIR/$tdir/normal_dir/*); do
13885 stripe_count=$($LFS getdirstripe -c $dir)
13886 [ $stripe_count -eq 0 ] ||
13887 error "expect 1 get $stripe_count for $dir"
13888 stripe_index=$($LFS getdirstripe -i $dir)
13889 [ $stripe_index -eq 0 ] ||
13890 error "expect 0 get $stripe_index for $dir"
13893 run_test 300g "check default striped directory for normal directory"
13896 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
13897 skip "Need MDS version at least 2.7.55" && return
13898 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
13903 $LFS setdirstripe -i 0 -c $MDSCOUNT -t all_char \
13904 $DIR/$tdir/striped_dir ||
13905 error "set striped dir error"
13907 test_300_check_default_striped_dir striped_dir $MDSCOUNT 1
13908 test_300_check_default_striped_dir striped_dir 1 0
13909 test_300_check_default_striped_dir striped_dir 2 1
13910 test_300_check_default_striped_dir striped_dir 2 -1
13912 #delete default stripe information
13913 $LFS setdirstripe -d $DIR/$tdir/striped_dir ||
13914 error "set default stripe on striped dir error"
13916 mkdir -p $DIR/$tdir/striped_dir/{test1,test2,test3,test4}
13917 for dir in $(find $DIR/$tdir/striped_dir/*); do
13918 stripe_count=$($LFS getdirstripe -c $dir)
13919 [ $stripe_count -eq 0 ] ||
13920 error "expect 1 get $stripe_count for $dir"
13923 run_test 300h "check default striped directory for striped directory"
13926 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
13927 skip "Need MDS version at least 2.7.55" && return
13928 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13929 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
13935 $LFS setdirstripe -i 0 -c$MDSCOUNT -t all_char $DIR/$tdir/striped_dir ||
13936 error "set striped dir error"
13938 createmany -o $DIR/$tdir/striped_dir/f- 10 ||
13939 error "create files under striped dir failed"
13941 # unfortunately, we need to umount to clear dir layout cache for now
13942 # once we fully implement dir layout, we can drop this
13943 umount_client $MOUNT || error "umount failed"
13944 mount_client $MOUNT || error "mount failed"
13946 #set the stripe to be unknown hash type
13947 #define OBD_FAIL_UNKNOWN_LMV_STRIPE 0x1901
13948 $LCTL set_param fail_loc=0x1901
13949 for ((i = 0; i < 10; i++)); do
13950 $CHECKSTAT -t file $DIR/$tdir/striped_dir/f-$i ||
13951 error "stat f-$i failed"
13952 rm $DIR/$tdir/striped_dir/f-$i || error "unlink f-$i failed"
13955 touch $DIR/$tdir/striped_dir/f0 &&
13956 error "create under striped dir with unknown hash should fail"
13958 $LCTL set_param fail_loc=0
13960 umount_client $MOUNT || error "umount failed"
13961 mount_client $MOUNT || error "mount failed"
13965 run_test 300i "client handle unknown hash type striped directory"
13968 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13969 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
13970 skip "Need MDS version at least 2.7.55" && return
13971 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
13977 #define OBD_FAIL_SPLIT_UPDATE_REC 0x1702
13978 $LCTL set_param fail_loc=0x1702
13979 $LFS setdirstripe -i 0 -c$MDSCOUNT -t all_char $DIR/$tdir/striped_dir ||
13980 error "set striped dir error"
13982 createmany -o $DIR/$tdir/striped_dir/f- 10 ||
13983 error "create files under striped dir failed"
13985 $LCTL set_param fail_loc=0
13987 rm -rf $DIR/$tdir || error "unlink striped dir fails"
13991 run_test 300j "test large update record"
13994 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
13995 skip "Need MDS version at least 2.7.55" && return
13996 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13997 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
14003 #define OBD_FAIL_LARGE_STRIPE 0x1703
14004 $LCTL set_param fail_loc=0x1703
14005 $LFS setdirstripe -i 0 -c512 $DIR/$tdir/striped_dir ||
14006 error "set striped dir error"
14007 $LCTL set_param fail_loc=0
14009 $LFS getdirstripe $DIR/$tdir/striped_dir ||
14010 error "getstripeddir fails"
14011 rm -rf $DIR/$tdir/striped_dir ||
14012 error "unlink striped dir fails"
14016 run_test 300k "test large 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
14025 test_mkdir -p $DIR/$tdir/striped_dir
14026 chown $RUNAS_ID $DIR/$tdir/striped_dir ||
14027 error "chown $RUNAS_ID failed"
14028 $LFS setdirstripe -i 1 -D $DIR/$tdir/striped_dir ||
14029 error "set default striped dir failed"
14031 #define OBD_FAIL_MDS_STALE_DIR_LAYOUT 0x158
14032 $LCTL set_param fail_loc=0x80000158
14033 $RUNAS mkdir $DIR/$tdir/striped_dir/test_dir || error "create dir fails"
14035 stripe_index=$($LFS getdirstripe -i $DIR/$tdir/striped_dir/test_dir)
14036 [ $stripe_index -eq 1 ] ||
14037 error "expect 1 get $stripe_index for $dir"
14039 run_test 300l "non-root user to create dir under striped dir with stale layout"
14042 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
14043 skip "Need MDS version at least 2.7.55" && return
14044 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
14045 [ $MDSCOUNT -ge 2 ] && skip "Only for single MDT" && return
14047 mkdir -p $DIR/$tdir/striped_dir
14048 $LFS setdirstripe -D -c 1 $DIR/$tdir/striped_dir ||
14049 error "set default stripes dir error"
14051 mkdir $DIR/$tdir/striped_dir/a || error "mkdir a fails"
14053 stripe_count=$($LFS getdirstripe -c $DIR/$tdir/striped_dir/a)
14054 [ $stripe_count -eq 0 ] ||
14055 error "expect 0 get $stripe_count for a"
14057 $LFS setdirstripe -D -c 2 $DIR/$tdir/striped_dir ||
14058 error "set default stripes dir error"
14060 mkdir $DIR/$tdir/striped_dir/b || error "mkdir b fails"
14062 stripe_count=$($LFS getdirstripe -c $DIR/$tdir/striped_dir/b)
14063 [ $stripe_count -eq 0 ] ||
14064 error "expect 0 get $stripe_count for b"
14066 $LFS setdirstripe -D -c1 -i2 $DIR/$tdir/striped_dir ||
14067 error "set default stripes dir error"
14069 mkdir $DIR/$tdir/striped_dir/c &&
14070 error "default stripe_index is invalid, mkdir c should fails"
14072 rm -rf $DIR/$tdir || error "rmdir fails"
14074 run_test 300m "setstriped directory on single MDT FS"
14077 local list=$(comma_list $(mdts_nodes))
14080 do_nodes $list $LCTL set_param -n mdt.*.enable_remote_dir_gid=0
14084 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
14085 skip "Need MDS version at least 2.7.55" && return
14086 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
14087 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
14089 local list=$(comma_list $(mdts_nodes))
14091 trap cleanup_300n RETURN EXIT
14092 mkdir -p $DIR/$tdir
14093 chmod 777 $DIR/$tdir
14094 $RUNAS $LFS setdirstripe -i0 -c$MDSCOUNT \
14095 $DIR/$tdir/striped_dir > /dev/null 2>&1 &&
14096 error "create striped dir succeeds with gid=0"
14098 do_nodes $list $LCTL set_param -n mdt.*.enable_remote_dir_gid=-1
14099 $RUNAS $LFS setdirstripe -i0 -c$MDSCOUNT $DIR/$tdir/striped_dir ||
14100 error "create striped dir fails with gid=-1"
14102 do_nodes $list $LCTL set_param -n mdt.*.enable_remote_dir_gid=0
14103 $RUNAS $LFS setdirstripe -i 1 -c$MDSCOUNT -D \
14104 $DIR/$tdir/striped_dir > /dev/null 2>&1 &&
14105 error "set default striped dir succeeds with gid=0"
14108 do_nodes $list $LCTL set_param -n mdt.*.enable_remote_dir_gid=-1
14109 $RUNAS $LFS setdirstripe -i 1 -c$MDSCOUNT -D $DIR/$tdir/striped_dir ||
14110 error "set default striped dir fails with gid=-1"
14113 do_nodes $list $LCTL set_param -n mdt.*.enable_remote_dir_gid=0
14114 $RUNAS mkdir $DIR/$tdir/striped_dir/test_dir ||
14115 error "create test_dir fails"
14116 $RUNAS mkdir $DIR/$tdir/striped_dir/test_dir1 ||
14117 error "create test_dir1 fails"
14118 $RUNAS mkdir $DIR/$tdir/striped_dir/test_dir2 ||
14119 error "create test_dir2 fails"
14122 run_test 300n "non-root user to create dir under striped dir with default EA"
14125 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
14126 skip "Need MDS version at least 2.7.55" && return
14127 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
14128 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
14132 mkdir -p $DIR/$tdir
14134 numfree1=$(lctl get_param -n mdc.*MDT0000*.filesfree)
14135 numfree2=$(lctl get_param -n mdc.*MDT0001*.filesfree)
14136 if [ $numfree1 -lt 66000 -o $numfree2 -lt 66000 ]; then
14137 skip "not enough free inodes $numfree1 $numfree2"
14141 numfree1=$(lctl get_param -n mdc.*MDT0000-mdc-*.kbytesfree)
14142 numfree2=$(lctl get_param -n mdc.*MDT0001-mdc-*.kbytesfree)
14143 if [ $numfree1 -lt 300000 -o $numfree2 -lt 300000 ]; then
14144 skip "not enough free space $numfree1 $numfree2"
14148 $LFS setdirstripe -c2 $DIR/$tdir/striped_dir ||
14149 error "setdirstripe fails"
14151 createmany -d $DIR/$tdir/striped_dir/d 131000 ||
14152 error "create dirs fails"
14154 $LCTL set_param ldlm.namespaces.*mdc-*.lru_size=0
14155 ls $DIR/$tdir/striped_dir > /dev/null ||
14156 error "ls striped dir fails"
14157 unlinkmany -d $DIR/$tdir/striped_dir/d 131000 ||
14158 error "unlink big striped dir fails"
14160 run_test 300o "unlink big sub stripe(> 65000 subdirs)"
14163 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
14164 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
14166 mkdir -p $DIR/$tdir
14168 #define OBD_FAIL_OUT_ENOSPC 0x1704
14169 do_facet mds2 lctl set_param fail_loc=0x80001704
14170 $LFS setdirstripe -c2 $DIR/$tdir/bad_striped_dir > /dev/null 2>&1 &&
14171 error "create striped directory should fail"
14173 [ -e $DIR/$tdir/bad_striped_dir ] && error "striped dir exists"
14176 run_test 300p "create striped directory without space"
14178 prepare_remote_file() {
14179 mkdir $DIR/$tdir/src_dir ||
14180 error "create remote source failed"
14182 cp /etc/hosts $DIR/$tdir/src_dir/a || error
14183 touch $DIR/$tdir/src_dir/a
14185 $LFS mkdir -i 1 $DIR/$tdir/tgt_dir ||
14186 error "create remote target dir failed"
14188 touch $DIR/$tdir/tgt_dir/b
14190 mrename $DIR/$tdir/src_dir/a $DIR/$tdir/tgt_dir/b ||
14191 error "rename dir cross MDT failed!"
14193 $CHECKSTAT -t file $DIR/$tdir/src_dir/a &&
14194 error "src_child still exists after rename"
14196 $CHECKSTAT -t file $DIR/$tdir/tgt_dir/b ||
14197 error "missing file(a) after rename"
14199 diff /etc/hosts $DIR/$tdir/tgt_dir/b ||
14200 error "diff after rename"
14204 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 4 MDTs" && return
14205 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
14206 local remote_file=$DIR/$tdir/tgt_dir/b
14208 mkdir -p $DIR/$tdir
14210 prepare_remote_file || error "prepare remote file failed"
14213 $OPENUNLINK $remote_file $remote_file || error
14214 $CHECKSTAT -a $remote_file || error
14216 run_test 310a "open unlink remote file"
14219 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 4 MDTs" && return
14220 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
14221 local remote_file=$DIR/$tdir/tgt_dir/b
14223 mkdir -p $DIR/$tdir
14225 prepare_remote_file || error "prepare remote file failed"
14227 ln $remote_file $DIR/$tfile || error "link failed for remote file"
14228 $MULTIOP $DIR/$tfile Ouc || error "mulitop failed"
14229 $CHECKSTAT -t file $remote_file || error "check file failed"
14231 run_test 310b "unlink remote file with multiple links while open"
14234 [[ $MDSCOUNT -lt 4 ]] && skip "needs >= 4 MDTs" && return
14235 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
14236 local remote_file=$DIR/$tdir/tgt_dir/b
14238 mkdir -p $DIR/$tdir
14240 prepare_remote_file || error "prepare remote file failed"
14242 ln $remote_file $DIR/$tfile || error "link failed for remote file"
14243 multiop_bg_pause $remote_file O_uc ||
14244 error "mulitop failed for remote file"
14246 $MULTIOP $DIR/$tfile Ouc
14247 kill -USR1 $MULTIPID
14250 run_test 310c "open-unlink remote file with multiple links"
14252 test_400a() { # LU-1606, was conf-sanity test_74
14253 local extra_flags=''
14254 local out=$TMP/$tfile
14255 local prefix=/usr/include/lustre
14258 if ! which $CC > /dev/null 2>&1; then
14259 skip_env "$CC is not installed"
14263 if ! [[ -d $prefix ]]; then
14264 # Assume we're running in tree and fixup the include path.
14265 extra_flags+=" -I$LUSTRE/../libcfs/include"
14266 extra_flags+=" -I$LUSTRE/include"
14267 extra_flags+=" -L$LUSTRE/utils"
14270 for prog in $LUSTRE_TESTS_API_DIR/*.c; do
14271 $CC -Wall -Werror $extra_flags -llustreapi -o $out $prog ||
14272 error "client api broken"
14275 run_test 400a "Lustre client api program can compile and link"
14277 test_400b() { # LU-1606, LU-5011
14279 local out=$TMP/$tfile
14280 local prefix=/usr/include/lustre
14282 # We use a hard coded prefix so that this test will not fail
14283 # when run in tree. There are headers in lustre/include/lustre/
14284 # that are not packaged (like lustre_idl.h) and have more
14285 # complicated include dependencies (like config.h and lnet/types.h).
14286 # Since this test about correct packaging we just skip them when
14287 # they don't exist (see below) rather than try to fixup cppflags.
14289 if ! which $CC > /dev/null 2>&1; then
14290 skip_env "$CC is not installed"
14294 for header in $prefix/*.h; do
14295 if ! [[ -f "$header" ]]; then
14299 if [[ "$(basename $header)" == liblustreapi.h ]]; then
14300 continue # liblustreapi.h is deprecated.
14303 $CC -Wall -Werror -include $header -c -x c /dev/null -o $out ||
14304 error "cannot compile '$header'"
14307 run_test 400b "packaged headers can be compiled"
14309 test_401() { #LU-7437
14313 #count the number of parameters by "list_param -R"
14314 params=$($LCTL list_param -R '*' 2>/dev/null | wc -l)
14315 #count the number of parameters by listing proc files
14316 ls -lRL /proc/{fs,sys}/{lnet,lustre} 2>/dev/null |
14317 grep -v "^t" | grep -v "^d" > $TMP/$tfile
14318 #Since there is no /proc/fs/lnet, we need to remove other
14319 #3 directories, /proc/{fs,sys}/lustre and /proc/sys/lnet.
14320 procs=$(($(sed /^$/d $TMP/$tfile | wc -l)-3))
14322 [ $params -eq $procs ] ||
14323 error "found $params parameters vs. $procs proc files"
14327 run_test 401 "Verify if 'lctl list_param -R' can list parameters recursively"
14330 $LFS setdirstripe -i 0 $DIR/$tdir || error "setdirstripe -i 0 failed"
14331 #define OBD_FAIL_MDS_FLD_LOOKUP 0x15c
14332 do_facet mds1 "lctl set_param fail_loc=0x8000015c"
14333 touch $DIR/$tdir/$tfile && error "touch should fail with ENOENT" ||
14334 echo "Touch failed - OK"
14336 run_test 402 "Return ENOENT to lod_generate_and_set_lovea"
14339 # tests that do cleanup/setup should be run at the end
14343 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
14345 #define OBD_FAIL_MGC_PAUSE_PROCESS_LOG 0x903
14346 $LCTL set_param fail_loc=0x903
14348 cancel_lru_locks MGC
14350 FAIL_ON_ERROR=true cleanup
14351 FAIL_ON_ERROR=true setup
14353 run_test 900 "umount should not race with any mgc requeue thread"
14356 [ -f $EXT2_DEV ] && rm $EXT2_DEV || true
14357 check_and_cleanup_lustre
14358 if [ "$I_MOUNTED" != "yes" ]; then
14359 lctl set_param debug="$OLDDEBUG" 2> /dev/null || true