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
1085 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.56) ]] &&
1086 skip "Need MDS version at least 2.7.56" && return
1088 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1090 local remote_dir=$DIR/$tdir/remote_dir
1092 test_mkdir -p $DIR/$tdir
1093 $LFS mkdir -i $MDTIDX $remote_dir ||
1094 error "create remote directory failed"
1096 test_mkdir -p $DIR/$tdir/src_dir
1097 touch $DIR/$tdir/src_file
1098 test_mkdir -p $remote_dir/tgt_dir
1099 touch $remote_dir/tgt_file
1101 mrename $DIR/$tdir/src_dir $remote_dir/tgt_dir ||
1102 error "rename dir cross MDT failed!"
1104 mrename $DIR/$tdir/src_file $remote_dir/tgt_file ||
1105 error "rename file cross MDT failed!"
1107 touch $DIR/$tdir/ln_file
1108 ln $DIR/$tdir/ln_file $remote_dir/ln_name ||
1109 error "ln file cross MDT failed"
1111 rm -rf $DIR/$tdir || error "Can not delete directories"
1113 run_test 24x "cross MDT rename/link"
1116 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 2 MDTs" && return
1117 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1119 local remote_dir=$DIR/$tdir/remote_dir
1121 test_mkdir -p $DIR/$tdir
1122 $LFS mkdir -i $MDTIDX $remote_dir ||
1123 error "create remote directory failed"
1125 test_mkdir -p $remote_dir/src_dir
1126 touch $remote_dir/src_file
1127 test_mkdir -p $remote_dir/tgt_dir
1128 touch $remote_dir/tgt_file
1130 mrename $remote_dir/src_dir $remote_dir/tgt_dir ||
1131 error "rename subdir in the same remote dir failed!"
1133 mrename $remote_dir/src_file $remote_dir/tgt_file ||
1134 error "rename files in the same remote dir failed!"
1136 ln $remote_dir/tgt_file $remote_dir/tgt_file1 ||
1137 error "link files in the same remote dir failed!"
1139 rm -rf $DIR/$tdir || error "Can not delete directories"
1141 run_test 24y "rename/link on the same dir should succeed"
1143 test_24A() { # LU-3182
1147 test_mkdir -p $DIR/$tdir
1148 createmany -m $DIR/$tdir/$tfile $NFILES
1149 local t=$(ls $DIR/$tdir | wc -l)
1150 local u=$(ls $DIR/$tdir | sort -u | wc -l)
1151 local v=$(ls -ai $DIR/$tdir | sort -u | wc -l)
1152 if [ $t -ne $NFILES -o $u -ne $NFILES -o $v -ne $((NFILES + 2)) ] ; then
1153 error "Expected $NFILES files, got $t ($u unique $v .&..)"
1156 rm -rf $DIR/$tdir || error "Can not delete directories"
1158 run_test 24A "readdir() returns correct number of entries."
1160 test_24B() { # LU-4805
1161 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
1164 test_mkdir $DIR/$tdir
1165 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR/$tdir/striped_dir ||
1166 error "create striped dir failed"
1168 count=$(ls -ai $DIR/$tdir/striped_dir | wc -l)
1169 [ $count -eq 2 ] || error "Expected 2, got $count"
1171 touch $DIR/$tdir/striped_dir/a
1173 count=$(ls -ai $DIR/$tdir/striped_dir | wc -l)
1174 [ $count -eq 3 ] || error "Expected 3, got $count"
1176 touch $DIR/$tdir/striped_dir/.f
1178 count=$(ls -ai $DIR/$tdir/striped_dir | wc -l)
1179 [ $count -eq 4 ] || error "Expected 4, got $count"
1181 rm -rf $DIR/$tdir || error "Can not delete directories"
1183 run_test 24B "readdir for striped dir return correct number of entries"
1186 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
1192 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR/$tdir/d0/striped_dir ||
1193 error "create striped dir failed"
1195 cd $DIR/$tdir/d0/striped_dir
1197 local d0_ino=$(ls -i -l -a $DIR/$tdir | grep "d0" | awk '{print $1}')
1198 local d1_ino=$(ls -i -l -a $DIR/$tdir | grep "d1" | awk '{print $1}')
1199 local parent_ino=$(ls -i -l -a | grep "\.\." | awk '{print $1}')
1201 [ "$d0_ino" = "$parent_ino" ] ||
1202 error ".. wrong, expect $d0_ino, get $parent_ino"
1204 mv $DIR/$tdir/d0/striped_dir $DIR/$tdir/d1/ ||
1205 error "mv striped dir failed"
1207 parent_ino=$(ls -i -l -a | grep "\.\." | awk '{print $1}')
1209 [ "$d1_ino" = "$parent_ino" ] ||
1210 error ".. wrong after mv, expect $d1_ino, get $parent_ino"
1212 run_test 24C "check .. in striped dir"
1214 test_24D() { # LU-6101
1219 createmany -m $DIR/$tdir/$tfile $NFILES
1220 local t=$(ls $DIR/$tdir | wc -l)
1221 local u=$(ls $DIR/$tdir | sort -u | wc -l)
1222 local v=$(ls -ai $DIR/$tdir | sort -u | wc -l)
1223 if [ $t -ne $NFILES -o $u -ne $NFILES -o $v -ne $((NFILES + 2)) ] ; then
1224 error "Expected $NFILES files, got $t ($u unique $v .&..)"
1227 rm -rf $DIR/$tdir || error "Can not delete directories"
1229 run_test 24D "readdir() returns correct number of entries after cursor reload"
1232 [[ $MDSCOUNT -lt 4 ]] && skip "needs >= 4 MDTs" && return
1233 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1236 mkdir $DIR/$tdir/src_dir
1237 $LFS mkdir -i 1 $DIR/$tdir/src_dir/src_child ||
1238 error "create remote source failed"
1240 touch $DIR/$tdir/src_dir/src_child/a
1242 $LFS mkdir -i 2 $DIR/$tdir/tgt_dir ||
1243 error "create remote target dir failed"
1245 $LFS mkdir -i 3 $DIR/$tdir/tgt_dir/tgt_child ||
1246 error "create remote target child failed"
1248 mrename $DIR/$tdir/src_dir/src_child $DIR/$tdir/tgt_dir/tgt_child ||
1249 error "rename dir cross MDT failed!"
1253 $CHECKSTAT -t dir $DIR/$tdir/src_dir/src_child &&
1254 error "src_child still exists after rename"
1256 $CHECKSTAT -t file $DIR/$tdir/tgt_dir/tgt_child/a ||
1257 error "missing file(a) after rename"
1259 rm -rf $DIR/$tdir || error "Can not delete directories"
1261 run_test 24E "cross MDT rename/link"
1264 echo '== symlink sanity ============================================='
1268 touch $DIR/s25/foo || error
1270 run_test 25a "create file in symlinked directory ==============="
1273 [ ! -d $DIR/d25 ] && test_25a
1274 $CHECKSTAT -t file $DIR/s25/foo || error
1276 run_test 25b "lookup file in symlinked directory ==============="
1280 test_mkdir $DIR/d26/d26-2
1281 ln -s d26/d26-2 $DIR/s26
1282 touch $DIR/s26/foo || error
1284 run_test 26a "multiple component symlink ======================="
1287 test_mkdir -p $DIR/d26b/d26-2
1288 ln -s d26b/d26-2/foo $DIR/s26-2
1289 touch $DIR/s26-2 || error
1291 run_test 26b "multiple component symlink at end of lookup ======"
1294 test_mkdir $DIR/d26.2
1295 touch $DIR/d26.2/foo
1296 ln -s d26.2 $DIR/s26.2-1
1297 ln -s s26.2-1 $DIR/s26.2-2
1298 ln -s s26.2-2 $DIR/s26.2-3
1299 chmod 0666 $DIR/s26.2-3/foo
1301 run_test 26c "chain of symlinks ================================"
1303 # recursive symlinks (bug 439)
1305 ln -s d26-3/foo $DIR/d26-3
1307 run_test 26d "create multiple component recursive symlink ======"
1310 [ ! -h $DIR/d26-3 ] && test_26d
1313 run_test 26e "unlink multiple component recursive symlink ======"
1315 # recursive symlinks (bug 7022)
1317 test_mkdir -p $DIR/$tdir
1318 test_mkdir $DIR/$tdir/$tfile || error "mkdir $DIR/$tdir/$tfile failed"
1319 cd $DIR/$tdir/$tfile || error "cd $DIR/$tdir/$tfile failed"
1320 test_mkdir -p lndir/bar1 || error "mkdir lndir/bar1 failed"
1321 test_mkdir $DIR/$tdir/$tfile/$tfile || error "mkdir $tfile failed"
1322 cd $tfile || error "cd $tfile failed"
1323 ln -s .. dotdot || error "ln dotdot failed"
1324 ln -s dotdot/lndir lndir || error "ln lndir failed"
1325 cd $DIR/$tdir || error "cd $DIR/$tdir failed"
1326 output=`ls $tfile/$tfile/lndir/bar1`
1327 [ "$output" = bar1 ] && error "unexpected output"
1328 rm -r $tfile || error "rm $tfile failed"
1329 $CHECKSTAT -a $DIR/$tfile || error "$tfile not gone"
1331 run_test 26f "rm -r of a directory which has recursive symlink ="
1334 echo '== stripe sanity =============================================='
1335 test_mkdir -p $DIR/d27 || error "mkdir failed"
1337 $SETSTRIPE -c 1 $DIR/d27/f0 || error "setstripe failed"
1338 $CHECKSTAT -t file $DIR/d27/f0 || error "checkstat failed"
1339 log "== test_27a: write to one stripe file ========================="
1340 cp /etc/hosts $DIR/d27/f0 || error
1342 run_test 27a "one stripe file =================================="
1345 [[ $OSTCOUNT -lt 2 ]] && skip_env "skipping 2-stripe test" && return
1346 test_mkdir -p $DIR/d27
1347 $SETSTRIPE -c 2 $DIR/d27/f01 || error "setstripe failed"
1348 $GETSTRIPE -c $DIR/d27/f01
1349 [ $($GETSTRIPE -c $DIR/d27/f01) -eq 2 ] ||
1350 error "two-stripe file doesn't have two stripes"
1352 dd if=/dev/zero of=$DIR/d27/f01 bs=4k count=4 || error "dd failed"
1354 run_test 27b "create and write to two stripe file"
1357 test_mkdir -p $DIR/d27
1358 $SETSTRIPE -c 0 -i -1 -S 0 $DIR/d27/fdef || error "setstripe failed"
1359 $CHECKSTAT -t file $DIR/d27/fdef || error "checkstat failed"
1360 dd if=/dev/zero of=$DIR/d27/fdef bs=4k count=4 || error
1362 run_test 27d "create file with default settings ================"
1365 # LU-5839 adds check for existed layout before setting it
1366 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.56) ]] &&
1367 skip "Need MDS version at least 2.7.56" && return
1368 test_mkdir -p $DIR/d27
1369 $SETSTRIPE -c 2 $DIR/d27/f12 || error "setstripe failed"
1370 $SETSTRIPE -c 2 $DIR/d27/f12 && error "setstripe succeeded twice"
1371 $CHECKSTAT -t file $DIR/d27/f12 || error "checkstat failed"
1373 run_test 27e "setstripe existing file (should return error) ======"
1376 test_mkdir $DIR/$tdir
1377 $SETSTRIPE -S 100 -i 0 -c 1 $DIR/$tdir/$tfile &&
1378 error "$SETSTRIPE $DIR/$tdir/$tfile failed"
1379 $CHECKSTAT -t file $DIR/$tdir/$tfile &&
1380 error "$CHECKSTAT -t file $DIR/$tdir/$tfile should fail"
1381 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=4k count=4 || error "dd failed"
1382 $GETSTRIPE $DIR/$tdir/$tfile || error "$GETSTRIPE failed"
1384 run_test 27f "setstripe with bad stripe size (should return error)"
1387 test_mkdir -p $DIR/d27
1388 $MCREATE $DIR/d27/fnone || error "mcreate failed"
1389 $GETSTRIPE $DIR/d27/fnone 2>&1 | grep "no stripe info" ||
1390 error "$DIR/d27/fnone has object"
1392 run_test 27g "$GETSTRIPE with no objects"
1395 test_mkdir $DIR/$tdir
1396 touch $DIR/$tdir/$tfile || error "touch failed"
1397 [[ $($GETSTRIPE -c $DIR/$tdir/$tfile) -gt 0 ]] ||
1398 error "missing objects"
1400 run_test 27i "$GETSTRIPE with some objects"
1403 test_mkdir -p $DIR/d27
1404 $SETSTRIPE -i $OSTCOUNT $DIR/d27/f27j && error "setstripe failed"||true
1406 run_test 27j "setstripe with bad stripe offset (should return error)"
1408 test_27k() { # bug 2844
1409 test_mkdir -p $DIR/d27
1411 LL_MAX_BLKSIZE=$((4 * 1024 * 1024))
1412 [ ! -d $DIR/d27 ] && test_mkdir -p $DIR d27
1413 $SETSTRIPE -S 67108864 $FILE || error "setstripe failed"
1414 BLKSIZE=`stat $FILE | awk '/IO Block:/ { print $7 }'`
1415 [ $BLKSIZE -le $LL_MAX_BLKSIZE ] || error "1:$BLKSIZE > $LL_MAX_BLKSIZE"
1416 dd if=/dev/zero of=$FILE bs=4k count=1
1417 BLKSIZE=`stat $FILE | awk '/IO Block:/ { print $7 }'`
1418 [ $BLKSIZE -le $LL_MAX_BLKSIZE ] || error "2:$BLKSIZE > $LL_MAX_BLKSIZE"
1420 run_test 27k "limit i_blksize for broken user apps ============="
1423 test_mkdir -p $DIR/d27
1424 mcreate $DIR/f27l || error "creating file"
1425 $RUNAS $SETSTRIPE -c 1 $DIR/f27l && \
1426 error "setstripe should have failed" || true
1428 run_test 27l "check setstripe permissions (should return error)"
1431 [[ $OSTCOUNT -lt 2 ]] && skip_env "$OSTCOUNT < 2 OSTs -- skipping" &&
1434 ORIGFREE=$($LCTL get_param -n lov.$FSNAME-clilov-*.kbytesavail |
1436 if [[ $ORIGFREE -gt $MAXFREE ]]; then
1437 skip "$ORIGFREE > $MAXFREE skipping out-of-space test on OST0"
1440 trap simple_cleanup_common EXIT
1441 test_mkdir -p $DIR/$tdir
1442 $SETSTRIPE -i 0 -c 1 $DIR/$tdir/f27m_1
1443 dd if=/dev/zero of=$DIR/$tdir/f27m_1 bs=1024 count=$MAXFREE &&
1444 error "dd should fill OST0"
1446 while $SETSTRIPE -i 0 -c 1 $DIR/$tdir/f27m_$i; do
1448 [ $i -gt 256 ] && break
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"
1455 touch $DIR/$tdir/f27m_$i
1456 [ `$GETSTRIPE $DIR/$tdir/f27m_$i | grep -A 10 obdidx | awk '{print $1}'| grep -w "0"` ] &&
1457 error "OST0 was full but new created file still use it"
1458 simple_cleanup_common
1460 run_test 27m "create file while OST0 was full =================="
1463 local DELAY=$(do_facet $SINGLEMDS lctl get_param -n lov.*.qos_maxage | head -n 1 | awk '{print $1 * 2}')
1467 # OSCs keep a NOSPC flag that will be reset after ~5s (qos_maxage)
1468 # if the OST isn't full anymore.
1470 local OSTIDX=${1:-""}
1472 local list=$(comma_list $(osts_nodes))
1473 [ "$OSTIDX" ] && list=$(facet_host ost$((OSTIDX + 1)))
1475 do_nodes $list lctl set_param fail_loc=0
1476 sync # initiate all OST_DESTROYs from MDS to OST
1480 exhaust_precreations() {
1483 local FAILIDX=${3:-$OSTIDX}
1484 local ofacet=ost$((OSTIDX + 1))
1486 test_mkdir -p -c1 $DIR/$tdir
1487 local mdtidx=$($LFS getstripe -M $DIR/$tdir)
1488 local mfacet=mds$((mdtidx + 1))
1489 echo OSTIDX=$OSTIDX MDTIDX=$mdtidx
1491 local OST=$(ostname_from_index $OSTIDX)
1494 local mdtosc_proc1=$(get_mdtosc_proc_path $mfacet $OST)
1495 local last_id=$(do_facet $mfacet lctl get_param -n \
1496 osc.$mdtosc_proc1.prealloc_last_id)
1497 local next_id=$(do_facet $mfacet lctl get_param -n \
1498 osc.$mdtosc_proc1.prealloc_next_id)
1500 local mdtosc_proc2=$(get_mdtosc_proc_path $mfacet)
1501 do_facet $mfacet lctl get_param osc.$mdtosc_proc2.prealloc*
1503 test_mkdir -p $DIR/$tdir/${OST}
1504 $SETSTRIPE -i $OSTIDX -c 1 $DIR/$tdir/${OST}
1505 #define OBD_FAIL_OST_ENOSPC 0x215
1506 do_facet $ofacet lctl set_param fail_val=$FAILIDX fail_loc=0x215
1507 echo "Creating to objid $last_id on ost $OST..."
1508 createmany -o $DIR/$tdir/${OST}/f $next_id $((last_id - next_id + 2))
1509 do_facet $mfacet lctl get_param osc.$mdtosc_proc2.prealloc*
1510 do_facet $ofacet lctl set_param fail_loc=$FAILLOC
1514 exhaust_all_precreations() {
1516 for (( i=0; i < OSTCOUNT; i++ )) ; do
1517 exhaust_precreations $i $1 -1
1522 [[ $OSTCOUNT -lt 2 ]] && skip_env "too few OSTs" && return
1523 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1524 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1525 remote_ost_nodsh && skip "remote OST with nodsh" && return
1528 rm -f $DIR/$tdir/$tfile
1529 exhaust_precreations 0 0x80000215
1530 $SETSTRIPE -c -1 $DIR/$tdir
1531 touch $DIR/$tdir/$tfile || error
1532 $GETSTRIPE $DIR/$tdir/$tfile
1535 run_test 27n "create file with some full OSTs =================="
1538 [[ $OSTCOUNT -lt 2 ]] && skip_env "too few OSTs" && return
1539 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1540 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1541 remote_ost_nodsh && skip "remote OST with nodsh" && return
1544 rm -f $DIR/$tdir/$tfile
1545 exhaust_all_precreations 0x215
1547 touch $DIR/$tdir/$tfile && error "able to create $DIR/$tdir/$tfile"
1552 run_test 27o "create file with all full OSTs (should error) ===="
1555 [[ $OSTCOUNT -lt 2 ]] && skip_env "too few OSTs" && return
1556 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1557 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1558 remote_ost_nodsh && skip "remote OST with nodsh" && return
1561 rm -f $DIR/$tdir/$tfile
1562 test_mkdir -p $DIR/$tdir
1564 $MCREATE $DIR/$tdir/$tfile || error "mcreate failed"
1565 $TRUNCATE $DIR/$tdir/$tfile 80000000 || error "truncate failed"
1566 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat failed"
1568 exhaust_precreations 0 0x80000215
1569 echo foo >> $DIR/$tdir/$tfile || error "append failed"
1570 $CHECKSTAT -s 80000004 $DIR/$tdir/$tfile || error "checkstat failed"
1571 $GETSTRIPE $DIR/$tdir/$tfile
1575 run_test 27p "append to a truncated file with some full OSTs ==="
1578 [[ $OSTCOUNT -lt 2 ]] && skip_env "too few OSTs" && return
1579 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1580 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1581 remote_ost_nodsh && skip "remote OST with nodsh" && return
1584 rm -f $DIR/$tdir/$tfile
1586 test_mkdir -p $DIR/$tdir
1587 $MCREATE $DIR/$tdir/$tfile || error "mcreate $DIR/$tdir/$tfile failed"
1588 $TRUNCATE $DIR/$tdir/$tfile 80000000 ||error "truncate $DIR/$tdir/$tfile failed"
1589 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat failed"
1591 exhaust_all_precreations 0x215
1593 echo foo >> $DIR/$tdir/$tfile && error "append succeeded"
1594 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat 2 failed"
1598 run_test 27q "append to truncated file with all OSTs full (should error) ==="
1601 [[ $OSTCOUNT -lt 2 ]] && skip_env "too few OSTs" && return
1602 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1603 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1604 remote_ost_nodsh && skip "remote OST with nodsh" && return
1607 rm -f $DIR/$tdir/$tfile
1608 exhaust_precreations 0 0x80000215
1610 $SETSTRIPE -i 0 -c 2 $DIR/$tdir/$tfile # && error
1614 run_test 27r "stripe file with some full OSTs (shouldn't LBUG) ="
1616 test_27s() { # bug 10725
1617 test_mkdir -p $DIR/$tdir
1618 local stripe_size=$((4096 * 1024 * 1024)) # 2^32
1619 local stripe_count=0
1620 [ $OSTCOUNT -eq 1 ] || stripe_count=2
1621 $SETSTRIPE -S $stripe_size -c $stripe_count $DIR/$tdir &&
1622 error "stripe width >= 2^32 succeeded" || true
1625 run_test 27s "lsm_xfersize overflow (should error) (bug 10725)"
1627 test_27t() { # bug 10864
1632 $WLFS getstripe $tfile
1635 run_test 27t "check that utils parse path correctly"
1637 test_27u() { # bug 4900
1638 [[ $OSTCOUNT -lt 2 ]] && skip_env "too few OSTs" && return
1639 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1641 local list=$(comma_list $(mdts_nodes))
1643 #define OBD_FAIL_MDS_OSC_PRECREATE 0x139
1644 do_nodes $list $LCTL set_param fail_loc=0x139
1645 test_mkdir -p $DIR/$tdir
1647 createmany -o $DIR/$tdir/t- 1000
1648 do_nodes $list $LCTL set_param fail_loc=0
1650 TLOG=$DIR/$tfile.getstripe
1651 $GETSTRIPE $DIR/$tdir > $TLOG
1652 OBJS=$(awk -vobj=0 '($1 == 0) { obj += 1 } END { print obj; }' $TLOG)
1653 unlinkmany $DIR/$tdir/t- 1000
1654 [[ $OBJS -gt 0 ]] &&
1655 error "$OBJS objects created on OST-0. See $TLOG" || pass
1657 run_test 27u "skip object creation on OSC w/o objects =========="
1659 test_27v() { # bug 4900
1660 [[ $OSTCOUNT -lt 2 ]] && skip_env "too few OSTs" && return
1661 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1662 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1663 remote_ost_nodsh && skip "remote OST with nodsh" && return
1665 exhaust_all_precreations 0x215
1668 test_mkdir -p $DIR/$tdir
1669 $SETSTRIPE -c 1 $DIR/$tdir # 1 stripe / file
1671 touch $DIR/$tdir/$tfile
1672 #define OBD_FAIL_TGT_DELAY_PRECREATE 0x705
1674 for (( i=1; i < OSTCOUNT; i++ )); do
1675 do_facet ost$i lctl set_param fail_loc=0x705
1677 local START=`date +%s`
1678 createmany -o $DIR/$tdir/$tfile 32
1680 local FINISH=`date +%s`
1681 local TIMEOUT=`lctl get_param -n timeout`
1682 local PROCESS=$((FINISH - START))
1683 [ $PROCESS -ge $((TIMEOUT / 2)) ] && \
1684 error "$FINISH - $START >= $TIMEOUT / 2"
1685 sleep $((TIMEOUT / 2 - PROCESS))
1688 run_test 27v "skip object creation on slow OST ================="
1690 test_27w() { # bug 10997
1691 test_mkdir -p $DIR/$tdir || error "mkdir failed"
1692 $SETSTRIPE -S 65536 $DIR/$tdir/f0 || error "setstripe failed"
1693 [ $($GETSTRIPE -S $DIR/$tdir/f0) -ne 65536 ] &&
1694 error "stripe size $size != 65536" || true
1695 [ $($GETSTRIPE -d $DIR/$tdir | grep -c "stripe_count") -ne 1 ] &&
1696 error "$GETSTRIPE -d $DIR/$tdir failed" || true
1698 run_test 27w "check $SETSTRIPE -S option"
1701 [[ $OSTCOUNT -lt 2 ]] &&
1702 skip_env "skipping multiple stripe count/offset test" && return
1704 test_mkdir -p $DIR/$tdir || error "mkdir failed"
1705 for i in $(seq 1 $OSTCOUNT); do
1707 $SETSTRIPE -c $i -i $offset $DIR/$tdir/f$i ||
1708 error "setstripe -c $i -i $offset failed"
1709 count=$($GETSTRIPE -c $DIR/$tdir/f$i)
1710 index=$($GETSTRIPE -i $DIR/$tdir/f$i)
1711 [ $count -ne $i ] && error "stripe count $count != $i" || true
1712 [ $index -ne $offset ] &&
1713 error "stripe offset $index != $offset" || true
1716 run_test 27wa "check $SETSTRIPE -c -i options"
1719 remote_ost_nodsh && skip "remote OST with nodsh" && return
1720 [[ $OSTCOUNT -lt 2 ]] && skip_env "$OSTCOUNT < 2 OSTs" && return
1721 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1722 OFFSET=$(($OSTCOUNT - 1))
1724 local OST=$(ostname_from_index $OSTIDX)
1726 test_mkdir -p $DIR/$tdir
1727 $SETSTRIPE -c 1 $DIR/$tdir # 1 stripe per file
1728 do_facet ost$((OSTIDX + 1)) lctl set_param -n obdfilter.$OST.degraded 1
1730 createmany -o $DIR/$tdir/$tfile $OSTCOUNT
1731 for i in `seq 0 $OFFSET`; do
1732 [ `$GETSTRIPE $DIR/$tdir/$tfile$i | grep -A 10 obdidx | awk '{print $1}' | grep -w "$OSTIDX"` ] &&
1733 error "OST0 was degraded but new created file still use it"
1735 do_facet ost$((OSTIDX + 1)) lctl set_param -n obdfilter.$OST.degraded 0
1737 run_test 27x "create files while OST0 is degraded"
1740 [[ $OSTCOUNT -lt 2 ]] &&
1741 skip_env "$OSTCOUNT < 2 OSTs -- skipping" && return
1742 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1743 remote_ost_nodsh && skip "remote OST with nodsh" && return
1744 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1746 local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS $FSNAME-OST0000)
1747 local last_id=$(do_facet $SINGLEMDS lctl get_param -n \
1748 osc.$mdtosc.prealloc_last_id)
1749 local next_id=$(do_facet $SINGLEMDS lctl get_param -n \
1750 osc.$mdtosc.prealloc_next_id)
1751 local fcount=$((last_id - next_id))
1752 [[ $fcount -eq 0 ]] && skip "not enough space on OST0" && return
1753 [[ $fcount -gt $OSTCOUNT ]] && fcount=$OSTCOUNT
1755 local MDS_OSCS=$(do_facet $SINGLEMDS lctl dl |
1756 awk '/[oO][sS][cC].*md[ts]/ { print $4 }')
1757 local OST_DEACTIVE_IDX=-1
1762 for OSC in $MDS_OSCS; do
1763 OST=$(osc_to_ost $OSC)
1764 OSTIDX=$(index_from_ostuuid $OST)
1765 if [ $OST_DEACTIVE_IDX == -1 ]; then
1766 OST_DEACTIVE_IDX=$OSTIDX
1768 if [ $OSTIDX != $OST_DEACTIVE_IDX ]; then
1769 echo $OSC "is Deactivated:"
1770 do_facet $SINGLEMDS lctl --device %$OSC deactivate
1774 OSTIDX=$(index_from_ostuuid $OST)
1775 test_mkdir -p $DIR/$tdir
1776 $SETSTRIPE -c 1 $DIR/$tdir # 1 stripe / file
1778 for OSC in $MDS_OSCS; do
1779 OST=$(osc_to_ost $OSC)
1780 OSTIDX=$(index_from_ostuuid $OST)
1781 if [ $OSTIDX == $OST_DEACTIVE_IDX ]; then
1782 echo $OST "is degraded:"
1783 do_facet ost$((OSTIDX+1)) lctl set_param -n \
1784 obdfilter.$OST.degraded=1
1789 createmany -o $DIR/$tdir/$tfile $fcount
1791 for OSC in $MDS_OSCS; do
1792 OST=$(osc_to_ost $OSC)
1793 OSTIDX=$(index_from_ostuuid $OST)
1794 if [ $OSTIDX == $OST_DEACTIVE_IDX ]; then
1795 echo $OST "is recovered from degraded:"
1796 do_facet ost$((OSTIDX+1)) lctl set_param -n \
1797 obdfilter.$OST.degraded=0
1799 do_facet $SINGLEMDS lctl --device %$OSC activate
1803 # all osp devices get activated, hence -1 stripe count restored
1806 # sleep 2*lod_qos_maxage seconds waiting for lod qos to notice osp
1807 # devices get activated.
1809 $SETSTRIPE -c -1 $DIR/$tfile
1810 stripecnt=$($GETSTRIPE -c $DIR/$tfile)
1812 [ $stripecnt -ne $OSTCOUNT ] &&
1813 error "Of $OSTCOUNT OSTs, only $stripecnt is available"
1816 run_test 27y "create files while OST0 is degraded and the rest inactive"
1822 lmm_count=$($GETSTRIPE -c $1)
1823 lmm_seq=$($GETSTRIPE -v $1 | awk '/lmm_seq/ { print $2 }')
1824 lmm_oid=$($GETSTRIPE -v $1 | awk '/lmm_object_id/ { print $2 }')
1826 local old_ifs="$IFS"
1828 fid=($($LFS path2fid $1))
1831 log "FID seq ${fid[1]}, oid ${fid[2]} ver ${fid[3]}"
1832 log "LOV seq $lmm_seq, oid $lmm_oid, count: $lmm_count"
1834 # compare lmm_seq and lu_fid->f_seq
1835 [ $lmm_seq = ${fid[1]} ] || { error "SEQ mismatch"; return 1; }
1836 # compare lmm_object_id and lu_fid->oid
1837 [ $lmm_oid = ${fid[2]} ] || { error "OID mismatch"; return 2; }
1839 # check the trusted.fid attribute of the OST objects of the file
1840 local have_obdidx=false
1842 $GETSTRIPE $1 | while read obdidx oid hex seq; do
1843 # skip lines up to and including "obdidx"
1844 [ -z "$obdidx" ] && break
1845 [ "$obdidx" = "obdidx" ] && have_obdidx=true && continue
1846 $have_obdidx || continue
1848 local ost=$((obdidx + 1))
1849 local dev=$(ostdevname $ost)
1852 log "want: stripe:$stripe_nr ost:$obdidx oid:$oid/$hex seq:$seq"
1854 seq=$(echo $seq | sed -e "s/^0x//g")
1855 if [ $seq == 0 ] || [ $(facet_fstype ost$ost) == zfs ]; then
1856 oid_hex=$(echo $oid)
1858 oid_hex=$(echo $hex | sed -e "s/^0x//g")
1860 local obj_file="O/$seq/d$((oid %32))/$oid_hex"
1864 # Don't unmount/remount the OSTs if we don't need to do that.
1865 # LU-2577 changes filter_fid to be smaller, so debugfs needs
1866 # update too, until that use mount/ll_decode_filter_fid/mount.
1867 # Re-enable when debugfs will understand new filter_fid.
1869 if false && [ $(facet_fstype ost$ost) == ldiskfs ]; then
1870 ff=$(do_facet ost$ost "$DEBUGFS -c -R 'stat $obj_file' \
1871 $dev 2>/dev/null" | grep "parent=")
1874 mount_fstype ost$ost
1875 ff=$(do_facet ost$ost $LL_DECODE_FILTER_FID \
1876 $(facet_mntpt ost$ost)/$obj_file)
1877 unmount_fstype ost$ost
1878 start ost$ost $dev $OST_MOUNT_OPTS
1882 [ -z "$ff" ] && error "$obj_file: no filter_fid info"
1884 echo "$ff" | sed -e 's#.*objid=#got: objid=#'
1886 # /mnt/O/0/d23/23: objid=23 seq=0 parent=[0x200000400:0x1e:0x1]
1887 # fid: objid=23 seq=0 parent=[0x200000400:0x1e:0x0] stripe=1
1888 local ff_parent=$(echo $ff|sed -e 's/.*parent=.//')
1889 local ff_pseq=$(echo $ff_parent | cut -d: -f1)
1890 local ff_poid=$(echo $ff_parent | cut -d: -f2)
1892 if echo $ff_parent | grep -q 'stripe='; then
1893 ff_pstripe=$(echo $ff_parent | sed -e 's/.*stripe=//')
1896 # $LL_DECODE_FILTER_FID does not print "stripe="; look
1897 # into f_ver in this case. See the comment on
1900 ff_pstripe=$(echo $ff_parent | cut -d: -f3 |
1904 # compare lmm_seq and filter_fid->ff_parent.f_seq
1905 [ $ff_pseq = $lmm_seq ] ||
1906 error "FF parent SEQ $ff_pseq != $lmm_seq"
1907 # compare lmm_object_id and filter_fid->ff_parent.f_oid
1908 [ $ff_poid = $lmm_oid ] ||
1909 error "FF parent OID $ff_poid != $lmm_oid"
1910 (($ff_pstripe == $stripe_nr)) ||
1911 error "FF stripe $ff_pstripe != $stripe_nr"
1913 stripe_nr=$((stripe_nr + 1))
1918 remote_ost_nodsh && skip "remote OST with nodsh" && return
1919 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1920 test_mkdir -p $DIR/$tdir
1922 $SETSTRIPE -c 1 -i 0 -S 64k $DIR/$tdir/$tfile-1 ||
1923 { error "setstripe -c -1 failed"; return 1; }
1924 # We need to send a write to every object to get parent FID info set.
1925 # This _should_ also work for setattr, but does not currently.
1926 # touch $DIR/$tdir/$tfile-1 ||
1927 dd if=/dev/zero of=$DIR/$tdir/$tfile-1 bs=1M count=1 ||
1928 { error "dd $tfile-1 failed"; return 2; }
1929 $SETSTRIPE -c -1 -i $((OSTCOUNT - 1)) -S 1M $DIR/$tdir/$tfile-2 ||
1930 { error "setstripe -c -1 failed"; return 3; }
1931 dd if=/dev/zero of=$DIR/$tdir/$tfile-2 bs=1M count=$OSTCOUNT ||
1932 { error "dd $tfile-2 failed"; return 4; }
1934 # make sure write RPCs have been sent to OSTs
1937 check_seq_oid $DIR/$tdir/$tfile-1 || return 5
1938 check_seq_oid $DIR/$tdir/$tfile-2 || return 6
1940 run_test 27z "check SEQ/OID on the MDT and OST filesystems"
1942 test_27A() { # b=19102
1943 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1944 local restore_size=$($GETSTRIPE -S $MOUNT)
1945 local restore_count=$($GETSTRIPE -c $MOUNT)
1946 local restore_offset=$($GETSTRIPE -i $MOUNT)
1947 $SETSTRIPE -c 0 -i -1 -S 0 $MOUNT
1948 wait_update $HOSTNAME "$GETSTRIPE -c $MOUNT | sed 's/ *//g'" "1" 20 ||
1949 error "stripe count $($GETSTRIPE -c $MOUNT) != 1"
1950 local default_size=$($GETSTRIPE -S $MOUNT)
1951 local default_offset=$($GETSTRIPE -i $MOUNT)
1952 local dsize=$((1024 * 1024))
1953 [ $default_size -eq $dsize ] ||
1954 error "stripe size $default_size != $dsize"
1955 [ $default_offset -eq -1 ] ||error "stripe offset $default_offset != -1"
1956 $SETSTRIPE -c $restore_count -i $restore_offset -S $restore_size $MOUNT
1958 run_test 27A "check filesystem-wide default LOV EA values"
1960 test_27B() { # LU-2523
1961 test_mkdir -p $DIR/$tdir
1962 rm -f $DIR/$tdir/f0 $DIR/$tdir/f1
1964 # open f1 with O_LOV_DELAY_CREATE
1966 # call setstripe ioctl on open file descriptor for f1
1968 multiop $DIR/$tdir/f1 oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:nB1c \
1972 # open f1 with O_LOV_DELAY_CREATE
1974 # call setstripe ioctl on open file descriptor for f1
1976 multiop $DIR/$tdir/f1 oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:uB1c
1978 # Allow multiop to fail in imitation of NFS's busted semantics.
1981 run_test 27B "call setstripe on open unlinked file/rename victim"
1983 test_27C() { #LU-2871
1984 [[ $OSTCOUNT -lt 2 ]] && skip "needs >= 2 OSTs" && return
1992 test_mkdir -p $DIR/$tdir
1994 for i in $(seq 0 $((OSTCOUNT - 1))); do
1995 # set stripe across all OSTs starting from OST$i
1996 $SETSTRIPE -i $i -c -1 $tfile$i
1997 # get striping information
1998 ost_idx=($($GETSTRIPE $tfile$i |
1999 tail -n $((OSTCOUNT + 1)) | awk '{print $1}'))
2003 [ ${#ost_idx[@]} -eq $OSTCOUNT ] ||
2004 error "${#ost_idx[@]} != $OSTCOUNT"
2006 for index in $(seq 0 $((OSTCOUNT - 1))); do
2008 for j in $(echo ${ost_idx[@]}); do
2009 if [ $index -eq $j ]; then
2015 error "Can not find $index in ${ost_idx[@]}"
2019 run_test 27C "check full striping across all OSTs"
2022 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs" && return
2023 local POOL=${POOL:-testpool}
2025 local last_ost=$(($OSTCOUNT - 1))
2027 local ost_list=$(seq $first_ost $ost_step $last_ost)
2028 local ost_range="$first_ost $last_ost $ost_step"
2030 test_mkdir -p $DIR/$tdir
2031 pool_add $POOL || error "pool_add failed"
2032 pool_add_targets $POOL $ost_range || error "pool_add_targets failed"
2033 llapi_layout_test -d$DIR/$tdir -p$POOL -o$OSTCOUNT ||
2034 error "llapi_layout_test failed"
2035 cleanup_pools || error "cleanup_pools failed"
2037 run_test 27D "validate llapi_layout API"
2039 # Verify that default_easize is increased from its initial value after
2040 # accessing a widely striped file.
2042 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs" && return
2044 # 72 bytes is the minimum space required to store striping
2045 # information for a file striped across one OST:
2046 # (sizeof(struct lov_user_md_v3) +
2047 # sizeof(struct lov_user_ost_data_v1))
2049 $LCTL set_param -n llite.*.default_easize $min_easize ||
2050 error "lctl set_param failed"
2051 local easize=$($LCTL get_param -n llite.*.default_easize)
2053 [ $easize -eq $min_easize ] ||
2054 error "failed to set default_easize"
2056 $LFS setstripe -c $OSTCOUNT $DIR/$tfile ||
2057 error "setstripe failed"
2061 easize=$($LCTL get_param -n llite.*.default_easize)
2063 [ $easize -gt $min_easize ] ||
2064 error "default_easize not updated"
2066 run_test 27E "check that default extended attribute size properly increases"
2068 # createtest also checks that device nodes are created and
2069 # then visible correctly (#2091)
2070 test_28() { # bug 2091
2072 $CREATETEST $DIR/d28/ct || error
2074 run_test 28 "create/mknod/mkdir with bad file types ============"
2077 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2078 cancel_lru_locks mdc
2084 declare -i LOCKCOUNTORIG=0
2085 for lock_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_count); do
2086 let LOCKCOUNTORIG=$LOCKCOUNTORIG+$lock_count
2088 [ $LOCKCOUNTORIG -eq 0 ] && echo "No mdc lock count" && return 1
2090 declare -i LOCKUNUSEDCOUNTORIG=0
2091 for unused_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_unused_count); do
2092 let LOCKUNUSEDCOUNTORIG=$LOCKUNUSEDCOUNTORIG+$unused_count
2099 declare -i LOCKCOUNTCURRENT=0
2100 for lock_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_count); do
2101 let LOCKCOUNTCURRENT=$LOCKCOUNTCURRENT+$lock_count
2104 declare -i LOCKUNUSEDCOUNTCURRENT=0
2105 for unused_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_unused_count); do
2106 let LOCKUNUSEDCOUNTCURRENT=$LOCKUNUSEDCOUNTCURRENT+$unused_count
2109 if [[ $LOCKCOUNTCURRENT -gt $LOCKCOUNTORIG ]]; then
2110 $LCTL set_param -n ldlm.dump_namespaces ""
2111 error "CURRENT: $LOCKCOUNTCURRENT > $LOCKCOUNTORIG"
2112 $LCTL dk | sort -k4 -t: > $TMP/test_29.dk
2113 log "dumped log to $TMP/test_29.dk (bug 5793)"
2116 if [[ $LOCKUNUSEDCOUNTCURRENT -gt $LOCKUNUSEDCOUNTORIG ]]; then
2117 error "UNUSED: $LOCKUNUSEDCOUNTCURRENT > $LOCKUNUSEDCOUNTORIG"
2118 $LCTL dk | sort -k4 -t: > $TMP/test_29.dk
2119 log "dumped log to $TMP/test_29.dk (bug 5793)"
2123 run_test 29 "IT_GETATTR regression ============================"
2125 test_30a() { # was test_30
2126 cp $(which ls) $DIR || cp /bin/ls $DIR
2130 run_test 30a "execute binary from Lustre (execve) =============="
2133 cp `which ls` $DIR || cp /bin/ls $DIR
2135 $RUNAS $DIR/ls / || error
2138 run_test 30b "execute binary from Lustre as non-root ==========="
2140 test_30c() { # b=22376
2141 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2142 cp `which ls` $DIR || cp /bin/ls $DIR
2144 cancel_lru_locks mdc
2145 cancel_lru_locks osc
2146 $RUNAS $DIR/ls / || error
2149 run_test 30c "execute binary from Lustre without read perms ===="
2152 $OPENUNLINK $DIR/f31 $DIR/f31 || error
2153 $CHECKSTAT -a $DIR/f31 || error
2155 run_test 31a "open-unlink file =================================="
2158 touch $DIR/f31 || error
2159 ln $DIR/f31 $DIR/f31b || error
2160 $MULTIOP $DIR/f31b Ouc || error
2161 $CHECKSTAT -t file $DIR/f31 || error
2163 run_test 31b "unlink file with multiple links while open ======="
2166 touch $DIR/f31 || error
2167 ln $DIR/f31 $DIR/f31c || error
2168 multiop_bg_pause $DIR/f31 O_uc || return 1
2170 $MULTIOP $DIR/f31c Ouc
2171 kill -USR1 $MULTIPID
2174 run_test 31c "open-unlink file with multiple links ============="
2177 opendirunlink $DIR/d31d $DIR/d31d || error
2178 $CHECKSTAT -a $DIR/d31d || error
2180 run_test 31d "remove of open directory ========================="
2182 test_31e() { # bug 2904
2183 openfilleddirunlink $DIR/d31e || error
2185 run_test 31e "remove of open non-empty directory ==============="
2187 test_31f() { # bug 4554
2188 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2190 test_mkdir $DIR/d31f
2191 $SETSTRIPE -S 1048576 -c 1 $DIR/d31f
2192 cp /etc/hosts $DIR/d31f
2194 $GETSTRIPE $DIR/d31f/hosts
2195 multiop_bg_pause $DIR/d31f D_c || return 1
2198 rm -rv $DIR/d31f || error "first of $DIR/d31f"
2199 test_mkdir $DIR/d31f
2200 $SETSTRIPE -S 1048576 -c 1 $DIR/d31f
2201 cp /etc/hosts $DIR/d31f
2203 $GETSTRIPE $DIR/d31f/hosts
2204 multiop_bg_pause $DIR/d31f D_c || return 1
2207 kill -USR1 $MULTIPID || error "first opendir $MULTIPID not running"
2208 wait $MULTIPID || error "first opendir $MULTIPID failed"
2212 kill -USR1 $MULTIPID2 || error "second opendir $MULTIPID not running"
2213 wait $MULTIPID2 || error "second opendir $MULTIPID2 failed"
2216 run_test 31f "remove of open directory with open-unlink file ==="
2219 echo "-- cross directory link --"
2220 test_mkdir -c1 $DIR/${tdir}ga
2221 test_mkdir -c1 $DIR/${tdir}gb
2222 touch $DIR/${tdir}ga/f
2223 ln $DIR/${tdir}ga/f $DIR/${tdir}gb/g
2224 $CHECKSTAT -t file $DIR/${tdir}ga/f || error "source"
2225 [ `stat -c%h $DIR/${tdir}ga/f` == '2' ] || error "source nlink"
2226 $CHECKSTAT -t file $DIR/${tdir}gb/g || error "target"
2227 [ `stat -c%h $DIR/${tdir}gb/g` == '2' ] || error "target nlink"
2229 run_test 31g "cross directory link==============="
2232 echo "-- cross directory link --"
2233 test_mkdir -c1 $DIR/${tdir}
2234 test_mkdir -c1 $DIR/${tdir}/dir
2235 touch $DIR/${tdir}/f
2236 ln $DIR/${tdir}/f $DIR/${tdir}/dir/g
2237 $CHECKSTAT -t file $DIR/${tdir}/f || error "source"
2238 [ `stat -c%h $DIR/${tdir}/f` == '2' ] || error "source nlink"
2239 $CHECKSTAT -t file $DIR/${tdir}/dir/g || error "target"
2240 [ `stat -c%h $DIR/${tdir}/dir/g` == '2' ] || error "target nlink"
2242 run_test 31h "cross directory link under child==============="
2245 echo "-- cross directory link --"
2246 test_mkdir -c1 $DIR/$tdir
2247 test_mkdir -c1 $DIR/$tdir/dir
2248 touch $DIR/$tdir/dir/f
2249 ln $DIR/$tdir/dir/f $DIR/$tdir/g
2250 $CHECKSTAT -t file $DIR/$tdir/dir/f || error "source"
2251 [ `stat -c%h $DIR/$tdir/dir/f` == '2' ] || error "source nlink"
2252 $CHECKSTAT -t file $DIR/$tdir/g || error "target"
2253 [ `stat -c%h $DIR/$tdir/g` == '2' ] || error "target nlink"
2255 run_test 31i "cross directory link under parent==============="
2258 test_mkdir -c1 -p $DIR/$tdir
2259 test_mkdir -c1 -p $DIR/$tdir/dir1
2260 ln $DIR/$tdir/dir1 $DIR/$tdir/dir2 && error "ln for dir"
2261 link $DIR/$tdir/dir1 $DIR/$tdir/dir3 && error "link for dir"
2262 mlink $DIR/$tdir/dir1 $DIR/$tdir/dir4 && error "mlink for dir"
2263 mlink $DIR/$tdir/dir1 $DIR/$tdir/dir1 && error "mlink to the same dir"
2266 run_test 31j "link for directory==============="
2269 test_mkdir -c1 -p $DIR/$tdir
2271 touch $DIR/$tdir/exist
2272 mlink $DIR/$tdir/s $DIR/$tdir/t || error "mlink"
2273 mlink $DIR/$tdir/s $DIR/$tdir/exist && error "mlink to exist file"
2274 mlink $DIR/$tdir/s $DIR/$tdir/s && error "mlink to the same file"
2275 mlink $DIR/$tdir/s $DIR/$tdir && error "mlink to parent dir"
2276 mlink $DIR/$tdir $DIR/$tdir/s && error "mlink parent dir to target"
2277 mlink $DIR/$tdir/not-exist $DIR/$tdir/foo && error "mlink non-existing to new"
2278 mlink $DIR/$tdir/not-exist $DIR/$tdir/s && error "mlink non-existing to exist"
2281 run_test 31k "link to file: the same, non-existing, dir==============="
2287 touch $DIR/d31m2/exist
2288 mlink $DIR/d31m/s $DIR/d31m2/t || error "mlink"
2289 mlink $DIR/d31m/s $DIR/d31m2/exist && error "mlink to exist file"
2290 mlink $DIR/d31m/s $DIR/d31m2 && error "mlink to parent dir"
2291 mlink $DIR/d31m2 $DIR/d31m/s && error "mlink parent dir to target"
2292 mlink $DIR/d31m/not-exist $DIR/d31m2/foo && error "mlink non-existing to new"
2293 mlink $DIR/d31m/not-exist $DIR/d31m2/s && error "mlink non-existing to exist"
2296 run_test 31m "link to file: the same, non-existing, dir==============="
2299 touch $DIR/$tfile || error "cannot create '$DIR/$tfile'"
2300 nlink=$(stat --format=%h $DIR/$tfile)
2301 [ ${nlink:--1} -eq 1 ] || error "nlink is $nlink, expected 1"
2303 local cmd="exec $fd<$DIR/$tfile"
2306 trap "eval $cmd" EXIT
2307 nlink=$(stat --dereference --format=%h /proc/self/fd/$fd)
2308 [ ${nlink:--1} -eq 1 ] || error "nlink is $nlink, expected 1"
2309 rm $DIR/$tfile || error "cannot remove '$DIR/$tfile'"
2310 nlink=$(stat --dereference --format=%h /proc/self/fd/$fd)
2311 [ ${nlink:--1} -eq 0 ] || error "nlink is $nlink, expected 0"
2314 run_test 31n "check link count of unlinked file"
2317 local TEMPNAME=$(mktemp $1_XXXXXX)
2318 mlink $TEMPNAME $1 2> /dev/null &&
2319 echo "$BASHPID: link $TEMPNAME to $1 succeeded"
2323 test_31o() { # LU-2901
2324 test_mkdir -p $DIR/$tdir
2325 for LOOP in $(seq 100); do
2326 rm -f $DIR/$tdir/$tfile*
2327 for THREAD in $(seq 8); do
2328 link_one $DIR/$tdir/$tfile.$LOOP &
2331 local LINKS=$(ls -1 $DIR/$tdir | grep -c $tfile.$LOOP)
2332 [[ $LINKS -gt 1 ]] && ls $DIR/$tdir &&
2333 error "$LINKS duplicate links to $tfile.$LOOP" &&
2337 run_test 31o "duplicate hard links with same filename"
2340 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2342 test_mkdir $DIR/$tdir
2343 $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
2344 $LFS setdirstripe -D -c2 -t all_char $DIR/$tdir/striped_dir
2346 opendirunlink $DIR/$tdir/striped_dir/test1 ||
2347 error "open unlink test1 failed"
2348 opendirunlink $DIR/$tdir/striped_dir/test2 ||
2349 error "open unlink test2 failed"
2351 $CHECKSTAT -a $DIR/$tdir/striped_dir/test1 ||
2352 error "test1 still exists"
2353 $CHECKSTAT -a $DIR/$tdir/striped_dir/test2 ||
2354 error "test2 still exists"
2356 run_test 31p "remove of open striped directory"
2358 cleanup_test32_mount() {
2360 $UMOUNT $DIR/$tdir/ext2-mountpoint
2364 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2365 echo "== more mountpoints and symlinks ================="
2366 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2367 trap cleanup_test32_mount EXIT
2368 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2369 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2370 $CHECKSTAT -t dir $DIR/$tdir/ext2-mountpoint/.. || error
2371 cleanup_test32_mount
2373 run_test 32a "stat d32a/ext2-mountpoint/.. ====================="
2376 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2377 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2378 trap cleanup_test32_mount EXIT
2379 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2380 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2381 ls -al $DIR/$tdir/ext2-mountpoint/.. || error
2382 cleanup_test32_mount
2384 run_test 32b "open d32b/ext2-mountpoint/.. ====================="
2387 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2388 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2389 trap cleanup_test32_mount EXIT
2390 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2391 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2392 test_mkdir -p $DIR/$tdir/d2/test_dir
2393 $CHECKSTAT -t dir $DIR/$tdir/ext2-mountpoint/../d2/test_dir || error
2394 cleanup_test32_mount
2396 run_test 32c "stat d32c/ext2-mountpoint/../d2/test_dir ========="
2399 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2400 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2401 trap cleanup_test32_mount EXIT
2402 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2403 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2404 test_mkdir -p $DIR/$tdir/d2/test_dir
2405 ls -al $DIR/$tdir/ext2-mountpoint/../d2/test_dir || error
2406 cleanup_test32_mount
2408 run_test 32d "open d32d/ext2-mountpoint/../d2/test_dir ========="
2411 [ -e $DIR/d32e ] && rm -fr $DIR/d32e
2412 test_mkdir -p $DIR/d32e/tmp
2413 TMP_DIR=$DIR/d32e/tmp
2414 ln -s $DIR/d32e $TMP_DIR/symlink11
2415 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
2416 $CHECKSTAT -t link $DIR/d32e/tmp/symlink11 || error
2417 $CHECKSTAT -t link $DIR/d32e/symlink01 || error
2419 run_test 32e "stat d32e/symlink->tmp/symlink->lustre-subdir ===="
2422 [ -e $DIR/d32f ] && rm -fr $DIR/d32f
2423 test_mkdir -p $DIR/d32f/tmp
2424 TMP_DIR=$DIR/d32f/tmp
2425 ln -s $DIR/d32f $TMP_DIR/symlink11
2426 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
2427 ls $DIR/d32f/tmp/symlink11 || error
2428 ls $DIR/d32f/symlink01 || error
2430 run_test 32f "open d32f/symlink->tmp/symlink->lustre-subdir ===="
2433 TMP_DIR=$DIR/$tdir/tmp
2434 test_mkdir -p $DIR/$tdir/tmp
2435 test_mkdir $DIR/${tdir}2
2436 ln -s $DIR/${tdir}2 $TMP_DIR/symlink12
2437 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
2438 $CHECKSTAT -t link $TMP_DIR/symlink12 || error
2439 $CHECKSTAT -t link $DIR/$tdir/symlink02 || error
2440 $CHECKSTAT -t dir -f $TMP_DIR/symlink12 || error
2441 $CHECKSTAT -t dir -f $DIR/$tdir/symlink02 || error
2443 run_test 32g "stat d32g/symlink->tmp/symlink->lustre-subdir/${tdir}2"
2446 rm -fr $DIR/$tdir $DIR/${tdir}2
2447 TMP_DIR=$DIR/$tdir/tmp
2448 test_mkdir -p $DIR/$tdir/tmp
2449 test_mkdir $DIR/${tdir}2
2450 ln -s $DIR/${tdir}2 $TMP_DIR/symlink12
2451 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
2452 ls $TMP_DIR/symlink12 || error
2453 ls $DIR/$tdir/symlink02 || error
2455 run_test 32h "open d32h/symlink->tmp/symlink->lustre-subdir/${tdir}2"
2458 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2459 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2460 trap cleanup_test32_mount EXIT
2461 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2462 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2463 touch $DIR/$tdir/test_file
2464 $CHECKSTAT -t file $DIR/$tdir/ext2-mountpoint/../test_file || error
2465 cleanup_test32_mount
2467 run_test 32i "stat d32i/ext2-mountpoint/../test_file ==========="
2470 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2471 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2472 trap cleanup_test32_mount EXIT
2473 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2474 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2475 touch $DIR/$tdir/test_file
2476 cat $DIR/$tdir/ext2-mountpoint/../test_file || error
2477 cleanup_test32_mount
2479 run_test 32j "open d32j/ext2-mountpoint/../test_file ==========="
2482 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2484 trap cleanup_test32_mount EXIT
2485 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2486 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint
2487 test_mkdir -p $DIR/$tdir/d2
2488 touch $DIR/$tdir/d2/test_file || error
2489 $CHECKSTAT -t file $DIR/$tdir/ext2-mountpoint/../d2/test_file || error
2490 cleanup_test32_mount
2492 run_test 32k "stat d32k/ext2-mountpoint/../d2/test_file ========"
2495 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2497 trap cleanup_test32_mount EXIT
2498 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2499 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2500 test_mkdir -p $DIR/$tdir/d2
2501 touch $DIR/$tdir/d2/test_file
2502 cat $DIR/$tdir/ext2-mountpoint/../d2/test_file || error
2503 cleanup_test32_mount
2505 run_test 32l "open d32l/ext2-mountpoint/../d2/test_file ========"
2509 test_mkdir -p $DIR/d32m/tmp
2510 TMP_DIR=$DIR/d32m/tmp
2511 ln -s $DIR $TMP_DIR/symlink11
2512 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
2513 $CHECKSTAT -t link $DIR/d32m/tmp/symlink11 || error
2514 $CHECKSTAT -t link $DIR/d32m/symlink01 || error
2516 run_test 32m "stat d32m/symlink->tmp/symlink->lustre-root ======"
2520 test_mkdir -p $DIR/d32n/tmp
2521 TMP_DIR=$DIR/d32n/tmp
2522 ln -s $DIR $TMP_DIR/symlink11
2523 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
2524 ls -l $DIR/d32n/tmp/symlink11 || error
2525 ls -l $DIR/d32n/symlink01 || error
2527 run_test 32n "open d32n/symlink->tmp/symlink->lustre-root ======"
2531 test_mkdir -p $DIR/d32o/tmp
2532 TMP_DIR=$DIR/d32o/tmp
2533 ln -s $DIR/$tfile $TMP_DIR/symlink12
2534 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
2535 $CHECKSTAT -t link $DIR/d32o/tmp/symlink12 || error
2536 $CHECKSTAT -t link $DIR/d32o/symlink02 || error
2537 $CHECKSTAT -t file -f $DIR/d32o/tmp/symlink12 || error
2538 $CHECKSTAT -t file -f $DIR/d32o/symlink02 || error
2540 run_test 32o "stat d32o/symlink->tmp/symlink->lustre-root/$tfile"
2550 test_mkdir -p $DIR/d32p/tmp
2552 TMP_DIR=$DIR/d32p/tmp
2554 ln -s $DIR/$tfile $TMP_DIR/symlink12
2556 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
2558 cat $DIR/d32p/tmp/symlink12 || error
2560 cat $DIR/d32p/symlink02 || error
2563 run_test 32p "open d32p/symlink->tmp/symlink->lustre-root/$tfile"
2565 cleanup_testdir_mount() {
2571 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2572 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2573 trap cleanup_testdir_mount EXIT
2574 test_mkdir -p $DIR/$tdir
2575 touch $DIR/$tdir/under_the_mount
2576 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir
2577 ls $DIR/$tdir | grep "\<under_the_mount\>" && error
2578 cleanup_testdir_mount
2580 run_test 32q "stat follows mountpoints in Lustre (should return error)"
2583 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2584 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2585 trap cleanup_testdir_mount EXIT
2586 test_mkdir -p $DIR/$tdir
2587 touch $DIR/$tdir/under_the_mount
2588 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir
2589 ls $DIR/$tdir | grep -q under_the_mount && error || true
2590 cleanup_testdir_mount
2592 run_test 32r "opendir follows mountpoints in Lustre (should return error)"
2597 chmod 444 $DIR/$tfile
2598 chown $RUNAS_ID $DIR/$tfile
2600 $RUNAS $OPENFILE -f O_RDWR $DIR/$tfile && error || true
2603 run_test 33aa "write file with mode 444 (should return error) ===="
2607 test_mkdir -p $DIR/d33
2608 chown $RUNAS_ID $DIR/d33
2609 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $DIR/d33/f33|| error "create"
2610 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $DIR/d33/f33 && \
2611 error "open RDWR" || true
2613 run_test 33a "test open file(mode=0444) with O_RDWR (should return error)"
2617 test_mkdir -p $DIR/d33
2618 chown $RUNAS_ID $DIR/d33
2619 $RUNAS $OPENFILE -f 1286739555 $DIR/d33/f33 || true
2621 run_test 33b "test open file with malformed flags (No panic)"
2624 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2630 remote_ost_nodsh && skip "remote OST with nodsh" && return
2633 test_mkdir -p $DIR/d33
2634 # Read: 0, Write: 4, create/destroy: 2/0, stat: 1, punch: 0
2637 for ostnum in $(seq $OSTCOUNT); do
2638 # test-framework's OST numbering is one-based, while Lustre's
2640 ostname=$(printf "$FSNAME-OST%.4x" $((ostnum - 1)))
2641 # Parsing llobdstat's output sucks; we could grep the /proc
2642 # path, but that's likely to not be as portable as using the
2643 # llobdstat utility. So we parse lctl output instead.
2644 write_bytes=$(do_facet ost$ostnum lctl get_param -n \
2645 obdfilter/$ostname/stats |
2646 awk '/^write_bytes/ {print $7}' )
2647 echo "baseline_write_bytes@$OSTnum/$ostname=$write_bytes"
2648 if (( ${write_bytes:-0} > 0 ))
2655 $all_zeros || return 0
2658 echo foo > $DIR/d33/bar
2662 # Total up write_bytes after writing. We'd better find non-zeros.
2663 for ostnum in $(seq $OSTCOUNT); do
2664 ostname=$(printf "$FSNAME-OST%.4x" $((ostnum - 1)))
2665 write_bytes=$(do_facet ost$ostnum lctl get_param -n \
2666 obdfilter/$ostname/stats |
2667 awk '/^write_bytes/ {print $7}' )
2668 echo "write_bytes@$OSTnum/$ostname=$write_bytes"
2669 if (( ${write_bytes:-0} > 0 ))
2678 for ostnum in $(seq $OSTCOUNT); do
2679 ostname=$(printf "$FSNAME-OST%.4x" $((ostnum - 1)))
2680 echo "Check that write_bytes is present in obdfilter/*/stats:"
2681 do_facet ost$ostnum lctl get_param -n \
2682 obdfilter/$ostname/stats
2684 error "OST not keeping write_bytes stats (b22312)"
2687 run_test 33c "test llobdstat and write_bytes"
2690 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 2 MDTs" && return
2691 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2693 local remote_dir=$DIR/$tdir/remote_dir
2695 test_mkdir -p $DIR/$tdir
2696 $LFS mkdir -i $MDTIDX $remote_dir ||
2697 error "create remote directory failed"
2699 touch $remote_dir/$tfile
2700 chmod 444 $remote_dir/$tfile
2701 chown $RUNAS_ID $remote_dir/$tfile
2703 $RUNAS $OPENFILE -f O_RDWR $DIR/$tfile && error || true
2705 chown $RUNAS_ID $remote_dir
2706 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $remote_dir/f33 ||
2707 error "create" || true
2708 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $remote_dir/f33 &&
2709 error "open RDWR" || true
2710 $RUNAS $OPENFILE -f 1286739555 $remote_dir/f33 || true
2712 run_test 33d "openfile with 444 modes and malformed flags under remote dir"
2715 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2719 $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
2720 $LFS setdirstripe -i1 -c2 $DIR/$tdir/striped_dir1
2721 mkdir $DIR/$tdir/local_dir
2723 local s0_mode=$(stat -c%f $DIR/$tdir/striped_dir)
2724 local s1_mode=$(stat -c%f $DIR/$tdir/striped_dir1)
2725 local l_mode=$(stat -c%f $DIR/$tdir/local_dir)
2727 [ "$l_mode" = "$s0_mode" -a "$l_mode" = "$s1_mode" ] ||
2728 error "mkdir $l_mode striped0 $s0_mode striped1 $s1_mode"
2730 rmdir $DIR/$tdir/* || error "rmdir failed"
2733 $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
2734 $LFS setdirstripe -i1 -c2 $DIR/$tdir/striped_dir1
2735 mkdir $DIR/$tdir/local_dir
2737 s0_mode=$(stat -c%f $DIR/$tdir/striped_dir)
2738 s1_mode=$(stat -c%f $DIR/$tdir/striped_dir1)
2739 l_mode=$(stat -c%f $DIR/$tdir/local_dir)
2741 [ "$l_mode" = "$s0_mode" -a "$l_mode" = "$s1_mode" ] ||
2742 error "mkdir $l_mode striped0 $s0_mode striped1 $s1_mode 777"
2744 rmdir $DIR/$tdir/* || error "rmdir(umask 777) failed"
2747 $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
2748 $LFS setdirstripe -i1 -c2 $DIR/$tdir/striped_dir1
2749 mkdir $DIR/$tdir/local_dir
2751 s0_mode=$(stat -c%f $DIR/$tdir/striped_dir)
2752 s1_mode=$(stat -c%f $DIR/$tdir/striped_dir1)
2753 l_mode=$(stat -c%f $DIR/$tdir/local_dir)
2755 [ "$l_mode" = "$s0_mode" -a "$l_mode" = "$s1_mode" ] ||
2756 error "mkdir $l_mode striped0 $s0_mode striped1 $s1_mode 0"
2758 run_test 33e "mkdir and striped directory should have same mode"
2762 do_facet $SINGLEMDS $LCTL set_param mdt.*.enable_remote_dir_gid=0
2766 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2769 chmod go+rwx $DIR/$tdir
2770 do_facet $SINGLEMDS $LCTL set_param mdt.*.enable_remote_dir_gid=-1
2771 trap cleanup_33f EXIT
2773 $RUNAS lfs mkdir -c$MDSCOUNT $DIR/$tdir/striped_dir ||
2774 error "cannot create striped directory"
2776 $RUNAS touch $DIR/$tdir/striped_dir/{0..16} ||
2777 error "cannot create files in striped directory"
2779 $RUNAS rm $DIR/$tdir/striped_dir/{0..16} ||
2780 error "cannot remove files in striped directory"
2782 $RUNAS rmdir $DIR/$tdir/striped_dir ||
2783 error "cannot remove striped directory"
2787 run_test 33f "nonroot user can create, access, and remove a striped directory"
2789 TEST_34_SIZE=${TEST_34_SIZE:-2000000000000}
2792 $MCREATE $DIR/f34 || error
2793 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" || error
2794 $TRUNCATE $DIR/f34 $TEST_34_SIZE || error
2795 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" || error
2796 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2798 run_test 34a "truncate file that has not been opened ==========="
2801 [ ! -f $DIR/f34 ] && test_34a
2802 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2803 $OPENFILE -f O_RDONLY $DIR/f34
2804 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" || error
2805 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2807 run_test 34b "O_RDONLY opening file doesn't create objects ====="
2810 [ ! -f $DIR/f34 ] && test_34a
2811 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2812 $OPENFILE -f O_RDWR $DIR/f34
2813 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" && error
2814 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2816 run_test 34c "O_RDWR opening file-with-size works =============="
2819 [ ! -f $DIR/f34 ] && test_34a
2820 dd if=/dev/zero of=$DIR/f34 conv=notrunc bs=4k count=1 || error
2821 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2824 run_test 34d "write to sparse file ============================="
2828 $MCREATE $DIR/f34e || error
2829 $TRUNCATE $DIR/f34e 1000 || error
2830 $CHECKSTAT -s 1000 $DIR/f34e || error
2831 $OPENFILE -f O_RDWR $DIR/f34e
2832 $CHECKSTAT -s 1000 $DIR/f34e || error
2834 run_test 34e "create objects, some with size and some without =="
2836 test_34f() { # bug 6242, 6243
2837 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2840 $MCREATE $DIR/f34f || error
2841 $TRUNCATE $DIR/f34f $SIZE34F || error "truncating $DIR/f3f to $SIZE34F"
2842 dd if=$DIR/f34f of=$TMP/f34f
2843 $CHECKSTAT -s $SIZE34F $TMP/f34f || error "$TMP/f34f not $SIZE34F bytes"
2844 dd if=/dev/zero of=$TMP/f34fzero bs=$SIZE34F count=1
2845 cmp $DIR/f34f $TMP/f34fzero || error "$DIR/f34f not all zero"
2846 cmp $TMP/f34f $TMP/f34fzero || error "$TMP/f34f not all zero"
2847 rm $TMP/f34f $TMP/f34fzero $DIR/f34f
2849 run_test 34f "read from a file with no objects until EOF ======="
2852 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2853 dd if=/dev/zero of=$DIR/$tfile bs=1 count=100 seek=$TEST_34_SIZE || error
2854 $TRUNCATE $DIR/$tfile $((TEST_34_SIZE / 2))|| error
2855 $CHECKSTAT -s $((TEST_34_SIZE / 2)) $DIR/$tfile || error "truncate failed"
2856 cancel_lru_locks osc
2857 $CHECKSTAT -s $((TEST_34_SIZE / 2)) $DIR/$tfile || \
2858 error "wrong size after lock cancel"
2860 $TRUNCATE $DIR/$tfile $TEST_34_SIZE || error
2861 $CHECKSTAT -s $TEST_34_SIZE $DIR/$tfile || \
2862 error "expanding truncate failed"
2863 cancel_lru_locks osc
2864 $CHECKSTAT -s $TEST_34_SIZE $DIR/$tfile || \
2865 error "wrong expanded size after lock cancel"
2867 run_test 34g "truncate long file ==============================="
2870 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2874 dd if=/dev/zero of=$DIR/$tfile bs=1M count=10 || error
2875 sync # Flush the cache so that multiop below does not block on cache
2876 # flush when getting the group lock
2877 $MULTIOP $DIR/$tfile OG${gid}T${sz}g${gid}c &
2880 # Since just timed wait is not good enough, let's do a sync write
2881 # that way we are sure enough time for a roundtrip + processing
2882 # passed + 2 seconds of extra margin.
2883 dd if=/dev/zero of=$DIR/${tfile}-1 bs=4096 oflag=direct count=1
2887 if [[ `ps h -o comm -p $MULTIPID` == "multiop" ]]; then
2888 error "Multiop blocked on ftruncate, pid=$MULTIPID"
2892 local nsz=`stat -c %s $DIR/$tfile`
2893 [[ $nsz == $sz ]] || error "New size wrong $nsz != $sz"
2895 run_test 34h "ftruncate file under grouplock should not block"
2898 cp /bin/sh $DIR/f35a
2900 chown $RUNAS_ID $DIR/f35a
2901 $RUNAS $DIR/f35a && error || true
2904 run_test 35a "exec file with mode 444 (should return and not leak) ====="
2908 utime $DIR/f36 || error
2910 run_test 36a "MDS utime check (mknod, utime) ==================="
2914 utime $DIR/f36 || error
2916 run_test 36b "OST utime check (open, utime) ===================="
2921 chown $RUNAS_ID $DIR/d36
2922 $RUNAS utime $DIR/d36/f36 || error
2924 run_test 36c "non-root MDS utime check (mknod, utime) =========="
2927 [ ! -d $DIR/d36 ] && test_36c
2928 echo "" > $DIR/d36/f36
2929 $RUNAS utime $DIR/d36/f36 || error
2931 run_test 36d "non-root OST utime check (open, utime) ==========="
2934 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID -- skipping" && return
2935 test_mkdir -p $DIR/$tdir
2936 touch $DIR/$tdir/$tfile
2937 $RUNAS utime $DIR/$tdir/$tfile && \
2938 error "utime worked, expected failure" || true
2940 run_test 36e "utime on non-owned file (should return error) ===="
2944 local LANG_SAVE=$LANG
2945 local LC_LANG_SAVE=$LC_LANG
2946 export LANG=C LC_LANG=C # for date language
2948 DATESTR="Dec 20 2000"
2949 test_mkdir -p $DIR/$tdir
2950 lctl set_param fail_loc=$fl
2952 cp /etc/hosts $DIR/$tdir/$tfile
2953 sync & # write RPC generated with "current" inode timestamp, but delayed
2955 touch --date="$DATESTR" $DIR/$tdir/$tfile # setattr timestamp in past
2956 LS_BEFORE="`ls -l $DIR/$tdir/$tfile`" # old timestamp from client cache
2957 cancel_lru_locks osc
2958 LS_AFTER="`ls -l $DIR/$tdir/$tfile`" # timestamp from OST object
2960 [ "$LS_BEFORE" != "$LS_AFTER" ] && \
2961 echo "BEFORE: $LS_BEFORE" && \
2962 echo "AFTER : $LS_AFTER" && \
2963 echo "WANT : $DATESTR" && \
2964 error "$DIR/$tdir/$tfile timestamps changed" || true
2966 export LANG=$LANG_SAVE LC_LANG=$LC_LANG_SAVE
2970 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2971 #define OBD_FAIL_OST_BRW_PAUSE_BULK 0x214
2972 subr_36fh "0x80000214"
2974 run_test 36f "utime on file racing with OST BRW write =========="
2977 remote_ost_nodsh && skip "remote OST with nodsh" && return
2978 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2983 test_mkdir -p $DIR/$tdir
2984 fmd_max_age=$(do_facet ost1 \
2985 "lctl get_param -n obdfilter.*.client_cache_seconds 2> /dev/null | \
2988 fmd_before=$(do_facet ost1 \
2989 "awk '/ll_fmd_cache/ {print \\\$2}' /proc/slabinfo")
2990 touch $DIR/$tdir/$tfile
2991 sleep $((fmd_max_age + 12))
2992 fmd_after=$(do_facet ost1 \
2993 "awk '/ll_fmd_cache/ {print \\\$2}' /proc/slabinfo")
2995 echo "fmd_before: $fmd_before"
2996 echo "fmd_after: $fmd_after"
2997 [[ $fmd_after -gt $fmd_before ]] &&
2998 echo "AFTER: $fmd_after > BEFORE: $fmd_before" &&
2999 error "fmd didn't expire after ping" || true
3001 run_test 36g "filter mod data cache expiry ====================="
3004 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3005 #define OBD_FAIL_OST_BRW_PAUSE_BULK2 0x227
3006 subr_36fh "0x80000227"
3008 run_test 36h "utime on file racing with OST BRW write =========="
3011 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
3013 test_mkdir $DIR/$tdir
3014 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR/$tdir/striped_dir
3016 local mtime=$(stat -c%Y $DIR/$tdir/striped_dir)
3017 local new_mtime=$((mtime + 200))
3019 #change Modify time of striped dir
3020 touch -m -d @$new_mtime $DIR/$tdir/striped_dir ||
3021 error "change mtime failed"
3023 local got=$(stat -c%Y $DIR/$tdir/striped_dir)
3025 [ "$new_mtime" = "$got" ] || error "expect $new_mtime got $got"
3027 run_test 36i "change mtime on striped directory"
3029 # test_37 - duplicate with tests 32q 32r
3032 local file=$DIR/$tfile
3034 openfile -f O_DIRECTORY $file
3037 [ $RC -eq 0 ] && error "opened file $file with O_DIRECTORY" || true
3038 [ $RC -eq $ENOTDIR ] || error "error $RC should be ENOTDIR ($ENOTDIR)"
3040 run_test 38 "open a regular file with O_DIRECTORY should return -ENOTDIR ==="
3044 touch $DIR/${tfile}2
3045 # ls -l $DIR/$tfile $DIR/${tfile}2
3046 # ls -lu $DIR/$tfile $DIR/${tfile}2
3047 # ls -lc $DIR/$tfile $DIR/${tfile}2
3049 $OPENFILE -f O_CREAT:O_TRUNC:O_WRONLY $DIR/${tfile}2
3050 if [ ! $DIR/${tfile}2 -nt $DIR/$tfile ]; then
3052 ls -l --full-time $DIR/$tfile $DIR/${tfile}2
3054 ls -lu --full-time $DIR/$tfile $DIR/${tfile}2
3056 ls -lc --full-time $DIR/$tfile $DIR/${tfile}2
3057 error "O_TRUNC didn't change timestamps"
3060 run_test 39 "mtime changed on create ==========================="
3063 test_mkdir -p -c1 $DIR/$tdir
3064 cp -p /etc/passwd $DIR/$tdir/fopen
3065 cp -p /etc/passwd $DIR/$tdir/flink
3066 cp -p /etc/passwd $DIR/$tdir/funlink
3067 cp -p /etc/passwd $DIR/$tdir/frename
3068 ln $DIR/$tdir/funlink $DIR/$tdir/funlink2
3071 echo "aaaaaa" >> $DIR/$tdir/fopen
3072 echo "aaaaaa" >> $DIR/$tdir/flink
3073 echo "aaaaaa" >> $DIR/$tdir/funlink
3074 echo "aaaaaa" >> $DIR/$tdir/frename
3076 local open_new=`stat -c %Y $DIR/$tdir/fopen`
3077 local link_new=`stat -c %Y $DIR/$tdir/flink`
3078 local unlink_new=`stat -c %Y $DIR/$tdir/funlink`
3079 local rename_new=`stat -c %Y $DIR/$tdir/frename`
3081 cat $DIR/$tdir/fopen > /dev/null
3082 ln $DIR/$tdir/flink $DIR/$tdir/flink2
3083 rm -f $DIR/$tdir/funlink2
3084 mv -f $DIR/$tdir/frename $DIR/$tdir/frename2
3086 for (( i=0; i < 2; i++ )) ; do
3087 local open_new2=`stat -c %Y $DIR/$tdir/fopen`
3088 local link_new2=`stat -c %Y $DIR/$tdir/flink`
3089 local unlink_new2=`stat -c %Y $DIR/$tdir/funlink`
3090 local rename_new2=`stat -c %Y $DIR/$tdir/frename2`
3092 [ $open_new2 -eq $open_new ] || error "open file reverses mtime"
3093 [ $link_new2 -eq $link_new ] || error "link file reverses mtime"
3094 [ $unlink_new2 -eq $unlink_new ] || error "unlink file reverses mtime"
3095 [ $rename_new2 -eq $rename_new ] || error "rename file reverses mtime"
3097 cancel_lru_locks osc
3098 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3101 run_test 39b "mtime change on open, link, unlink, rename ======"
3103 # this should be set to past
3104 TEST_39_MTIME=`date -d "1 year ago" +%s`
3110 local mtime0=`stat -c %Y $DIR1/$tfile`
3112 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3113 local mtime1=`stat -c %Y $DIR1/$tfile`
3114 [ "$mtime1" = $TEST_39_MTIME ] || \
3115 error "mtime is not set to past: $mtime1, should be $TEST_39_MTIME"
3118 echo hello >> $DIR1/$tfile
3120 local mtime2=`stat -c %Y $DIR1/$tfile`
3121 [ "$mtime2" -ge "$d1" ] && [ "$mtime2" -le "$d2" ] || \
3122 error "mtime is not updated on write: $d1 <= $mtime2 <= $d2"
3124 mv $DIR1/$tfile $DIR1/$tfile-1
3126 for (( i=0; i < 2; i++ )) ; do
3127 local mtime3=`stat -c %Y $DIR1/$tfile-1`
3128 [ "$mtime2" = "$mtime3" ] || \
3129 error "mtime ($mtime2) changed (to $mtime3) on rename"
3131 cancel_lru_locks osc
3132 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3135 run_test 39c "mtime change on rename ==========================="
3139 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3142 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3144 for (( i=0; i < 2; i++ )) ; do
3145 local mtime=`stat -c %Y $DIR1/$tfile`
3146 [ $mtime = $TEST_39_MTIME ] || \
3147 error "mtime($mtime) is not set to $TEST_39_MTIME"
3149 cancel_lru_locks osc
3150 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3153 run_test 39d "create, utime, stat =============================="
3157 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3159 local mtime1=`stat -c %Y $DIR1/$tfile`
3161 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3163 for (( i=0; i < 2; i++ )) ; do
3164 local mtime2=`stat -c %Y $DIR1/$tfile`
3165 [ $mtime2 = $TEST_39_MTIME ] || \
3166 error "mtime($mtime2) is not set to $TEST_39_MTIME"
3168 cancel_lru_locks osc
3169 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3172 run_test 39e "create, stat, utime, stat ========================"
3176 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3178 mtime1=`stat -c %Y $DIR1/$tfile`
3181 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3183 for (( i=0; i < 2; i++ )) ; do
3184 local mtime2=`stat -c %Y $DIR1/$tfile`
3185 [ $mtime2 = $TEST_39_MTIME ] || \
3186 error "mtime($mtime2) is not set to $TEST_39_MTIME"
3188 cancel_lru_locks osc
3189 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3192 run_test 39f "create, stat, sleep, utime, stat ================="
3196 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3197 echo hello >> $DIR1/$tfile
3198 local mtime1=`stat -c %Y $DIR1/$tfile`
3201 chmod o+r $DIR1/$tfile
3203 for (( i=0; i < 2; i++ )) ; do
3204 local mtime2=`stat -c %Y $DIR1/$tfile`
3205 [ "$mtime1" = "$mtime2" ] || \
3206 error "lost mtime: $mtime2, should be $mtime1"
3208 cancel_lru_locks osc
3209 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3212 run_test 39g "write, chmod, stat ==============================="
3216 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3221 echo hello >> $DIR1/$tfile
3222 local mtime1=`stat -c %Y $DIR1/$tfile`
3224 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3226 if [ "$d1" != "$d2" ]; then
3227 echo "write and touch not within one second"
3229 for (( i=0; i < 2; i++ )) ; do
3230 local mtime2=`stat -c %Y $DIR1/$tfile`
3231 [ "$mtime2" = $TEST_39_MTIME ] || \
3232 error "lost mtime: $mtime2, should be $TEST_39_MTIME"
3234 cancel_lru_locks osc
3235 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3239 run_test 39h "write, utime within one second, stat ============="
3242 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3246 echo hello >> $DIR1/$tfile
3247 local mtime1=`stat -c %Y $DIR1/$tfile`
3249 mv $DIR1/$tfile $DIR1/$tfile-1
3251 for (( i=0; i < 2; i++ )) ; do
3252 local mtime2=`stat -c %Y $DIR1/$tfile-1`
3254 [ "$mtime1" = "$mtime2" ] || \
3255 error "lost mtime: $mtime2, should be $mtime1"
3257 cancel_lru_locks osc
3258 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3261 run_test 39i "write, rename, stat =============================="
3264 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3265 start_full_debug_logging
3269 #define OBD_FAIL_OSC_DELAY_SETTIME 0x412
3270 lctl set_param fail_loc=0x80000412
3271 multiop_bg_pause $DIR1/$tfile oO_RDWR:w2097152_c ||
3272 error "multiop failed"
3274 local mtime1=`stat -c %Y $DIR1/$tfile`
3276 mv $DIR1/$tfile $DIR1/$tfile-1
3278 kill -USR1 $multipid
3279 wait $multipid || error "multiop close failed"
3281 for (( i=0; i < 2; i++ )) ; do
3282 local mtime2=`stat -c %Y $DIR1/$tfile-1`
3283 [ "$mtime1" = "$mtime2" ] ||
3284 error "mtime is lost on close: $mtime2, " \
3287 cancel_lru_locks osc
3288 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3290 lctl set_param fail_loc=0
3291 stop_full_debug_logging
3293 run_test 39j "write, rename, close, stat ======================="
3296 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3300 multiop_bg_pause $DIR1/$tfile oO_RDWR:w2097152_c || error "multiop failed"
3302 local mtime1=`stat -c %Y $DIR1/$tfile`
3304 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3306 kill -USR1 $multipid
3307 wait $multipid || error "multiop close failed"
3309 for (( i=0; i < 2; i++ )) ; do
3310 local mtime2=`stat -c %Y $DIR1/$tfile`
3312 [ "$mtime2" = $TEST_39_MTIME ] || \
3313 error "mtime is lost on close: $mtime2, should be $TEST_39_MTIME"
3315 cancel_lru_locks osc
3316 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3319 run_test 39k "write, utime, close, stat ========================"
3321 # this should be set to future
3322 TEST_39_ATIME=`date -d "1 year" +%s`
3325 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3326 remote_mds_nodsh && skip "remote MDS with nodsh" && return
3327 local atime_diff=$(do_facet $SINGLEMDS \
3328 lctl get_param -n mdd.*MDT0000*.atime_diff)
3332 # test setting directory atime to future
3333 touch -a -d @$TEST_39_ATIME $DIR/$tdir
3334 local atime=$(stat -c %X $DIR/$tdir)
3335 [ "$atime" = $TEST_39_ATIME ] || \
3336 error "atime is not set to future: $atime, $TEST_39_ATIME"
3338 # test setting directory atime from future to now
3339 local d1=$(date +%s)
3341 local d2=$(date +%s)
3343 cancel_lru_locks mdc
3344 atime=$(stat -c %X $DIR/$tdir)
3345 [ "$atime" -ge "$d1" -a "$atime" -le "$d2" ] || \
3346 error "atime is not updated from future: $atime, $d1<atime<$d2"
3348 do_facet $SINGLEMDS lctl set_param -n mdd.*MDT0000*.atime_diff=2
3351 # test setting directory atime when now > dir atime + atime_diff
3355 cancel_lru_locks mdc
3356 atime=$(stat -c %X $DIR/$tdir)
3357 [ "$atime" -ge "$d1" -a "$atime" -le "$d2" ] || \
3358 error "atime is not updated : $atime, should be $d2"
3360 do_facet $SINGLEMDS lctl set_param -n mdd.*MDT0000*.atime_diff=60
3363 # test not setting directory atime when now < dir atime + atime_diff
3365 cancel_lru_locks mdc
3366 atime=$(stat -c %X $DIR/$tdir)
3367 [ "$atime" -ge "$d1" -a "$atime" -le "$d2" ] || \
3368 error "atime is updated to $atime, should remain $d1<atime<$d2"
3370 do_facet $SINGLEMDS \
3371 lctl set_param -n mdd.*MDT0000*.atime_diff=$atime_diff
3373 run_test 39l "directory atime update ==========================="
3376 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3379 local far_past_mtime=$(date -d "May 29 1953" +%s)
3380 local far_past_atime=$(date -d "Dec 17 1903" +%s)
3382 touch -m -d @$far_past_mtime $DIR1/$tfile
3383 touch -a -d @$far_past_atime $DIR1/$tfile
3385 for (( i=0; i < 2; i++ )) ; do
3386 local timestamps=$(stat -c "%X %Y" $DIR1/$tfile)
3387 [ "$timestamps" = "$far_past_atime $far_past_mtime" ] || \
3388 error "atime or mtime set incorrectly"
3390 cancel_lru_locks osc
3391 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3394 run_test 39m "test atime and mtime before 1970"
3396 test_39n() { # LU-3832
3397 local atime_diff=$(do_facet $SINGLEMDS \
3398 lctl get_param -n mdd.*MDT0000*.atime_diff)
3403 do_facet $SINGLEMDS lctl set_param -n mdd.*MDT0000*.atime_diff=1
3406 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 status=noxfer
3407 atime0=$(stat -c %X $DIR/$tfile)
3410 $MULTIOP $DIR/$tfile oO_RDONLY:O_NOATIME:r4096c
3411 atime1=$(stat -c %X $DIR/$tfile)
3414 cancel_lru_locks mdc
3415 cancel_lru_locks osc
3416 $MULTIOP $DIR/$tfile oO_RDONLY:O_NOATIME:r4096c
3417 atime2=$(stat -c %X $DIR/$tfile)
3419 do_facet $SINGLEMDS \
3420 lctl set_param -n mdd.*MDT0000*.atime_diff=$atime_diff
3422 [ "$atime0" -eq "$atime1" ] || error "atime0 $atime0 != atime1 $atime1"
3423 [ "$atime1" -eq "$atime2" ] || error "atime0 $atime0 != atime1 $atime1"
3425 run_test 39n "check that O_NOATIME is honored"
3428 TESTDIR=$DIR/$tdir/$tfile
3429 [ -e $TESTDIR ] && rm -rf $TESTDIR
3436 links2=$(stat -c %h .)
3437 [ $(($links1 + 2)) != $links2 ] &&
3438 error "wrong links count $(($links1 + 2)) != $links2"
3440 links3=$(stat -c %h .)
3441 [ $(($links1 + 1)) != $links3 ] &&
3442 error "wrong links count $links1 != $links3"
3445 run_test 39o "directory cached attributes updated after create ========"
3448 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 2 MDTs" && return
3450 TESTDIR=$DIR/$tdir/$tfile
3451 [ -e $TESTDIR ] && rm -rf $TESTDIR
3452 test_mkdir -p $TESTDIR
3456 $LFS mkdir -i $MDTIDX $TESTDIR/remote_dir1
3457 $LFS mkdir -i $MDTIDX $TESTDIR/remote_dir2
3459 links2=$(stat -c %h .)
3460 [ $(($links1 + 2)) != $links2 ] &&
3461 error "wrong links count $(($links1 + 2)) != $links2"
3463 links3=$(stat -c %h .)
3464 [ $(($links1 + 1)) != $links3 ] &&
3465 error "wrong links count $links1 != $links3"
3468 run_test 39p "remote directory cached attributes updated after create ========"
3472 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1
3473 $RUNAS $OPENFILE -f O_WRONLY:O_TRUNC $DIR/$tfile &&
3474 error "openfile O_WRONLY:O_TRUNC $tfile failed"
3475 $CHECKSTAT -t file -s 4096 $DIR/$tfile ||
3476 error "$tfile is not 4096 bytes in size"
3478 run_test 40 "failed open(O_TRUNC) doesn't truncate ============="
3482 small_write $DIR/f41 18
3484 run_test 41 "test small file write + fstat ====================="
3486 count_ost_writes() {
3487 lctl get_param -n osc.*.stats |
3488 awk -vwrites=0 '/ost_write/ { writes += $2 } \
3489 END { printf("%0.0f", writes) }'
3496 BG_DIRTY_RATIO_SAVE=10
3497 MAX_BG_DIRTY_RATIO=25
3501 # in 2.6, restore /proc/sys/vm/dirty_writeback_centisecs,
3502 # dirty_ratio, dirty_background_ratio
3503 if [ -f /proc/sys/vm/dirty_writeback_centisecs ]; then
3504 sysctl -w vm.dirty_writeback_centisecs=$WRITEBACK_SAVE
3505 sysctl -w vm.dirty_background_ratio=$BG_DIRTY_RATIO_SAVE
3506 sysctl -w vm.dirty_ratio=$DIRTY_RATIO_SAVE
3508 # if file not here, we are a 2.4 kernel
3509 kill -CONT `pidof kupdated`
3514 # setup the trap first, so someone cannot exit the test at the
3515 # exact wrong time and mess up a machine
3516 trap start_writeback EXIT
3517 # in 2.6, save and 0 /proc/sys/vm/dirty_writeback_centisecs
3518 if [ -f /proc/sys/vm/dirty_writeback_centisecs ]; then
3519 WRITEBACK_SAVE=`sysctl -n vm.dirty_writeback_centisecs`
3520 sysctl -w vm.dirty_writeback_centisecs=0
3521 sysctl -w vm.dirty_writeback_centisecs=0
3522 # save and increase /proc/sys/vm/dirty_ratio
3523 DIRTY_RATIO_SAVE=`sysctl -n vm.dirty_ratio`
3524 sysctl -w vm.dirty_ratio=$MAX_DIRTY_RATIO
3525 # save and increase /proc/sys/vm/dirty_background_ratio
3526 BG_DIRTY_RATIO_SAVE=`sysctl -n vm.dirty_background_ratio`
3527 sysctl -w vm.dirty_background_ratio=$MAX_BG_DIRTY_RATIO
3529 # if file not here, we are a 2.4 kernel
3530 kill -STOP `pidof kupdated`
3534 # ensure that all stripes have some grant before we test client-side cache
3536 for i in `seq -f $DIR/f42-%g 1 $OSTCOUNT`; do
3537 dd if=/dev/zero of=$i bs=4k count=1
3542 # Tests 42* verify that our behaviour is correct WRT caching, file closure,
3543 # file truncation, and file removal.
3545 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3547 cancel_lru_locks osc
3549 sync; sleep 1; sync # just to be safe
3550 BEFOREWRITES=`count_ost_writes`
3551 lctl get_param -n osc.*[oO][sS][cC][_-]*.cur_grant_bytes | grep "[0-9]"
3552 dd if=/dev/zero of=$DIR/f42a bs=1024 count=100
3553 AFTERWRITES=`count_ost_writes`
3554 [ $BEFOREWRITES -eq $AFTERWRITES ] || \
3555 error "$BEFOREWRITES < $AFTERWRITES"
3558 run_test 42a "ensure that we don't flush on close =============="
3561 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3563 cancel_lru_locks osc
3566 dd if=/dev/zero of=$DIR/f42b bs=1024 count=100
3567 BEFOREWRITES=$(count_ost_writes)
3568 $MUNLINK $DIR/f42b || error "$MUNLINK $DIR/f42b: $?"
3569 AFTERWRITES=$(count_ost_writes)
3570 if [[ $BEFOREWRITES -lt $AFTERWRITES ]]; then
3571 error "$BEFOREWRITES < $AFTERWRITES on unlink"
3573 BEFOREWRITES=$(count_ost_writes)
3574 sync || error "sync: $?"
3575 AFTERWRITES=$(count_ost_writes)
3576 if [[ $BEFOREWRITES -lt $AFTERWRITES ]]; then
3577 error "$BEFOREWRITES < $AFTERWRITES on sync"
3579 dmesg | grep 'error from obd_brw_async' && error 'error writing back'
3583 run_test 42b "test destroy of file with cached dirty data ======"
3585 # if these tests just want to test the effect of truncation,
3586 # they have to be very careful. consider:
3587 # - the first open gets a {0,EOF}PR lock
3588 # - the first write conflicts and gets a {0, count-1}PW
3589 # - the rest of the writes are under {count,EOF}PW
3590 # - the open for truncate tries to match a {0,EOF}PR
3591 # for the filesize and cancels the PWs.
3592 # any number of fixes (don't get {0,EOF} on open, match
3593 # composite locks, do smarter file size management) fix
3594 # this, but for now we want these tests to verify that
3595 # the cancellation with truncate intent works, so we
3596 # start the file with a full-file pw lock to match against
3597 # until the truncate.
3602 cancel_lru_locks osc
3604 # prime the file with 0,EOF PW to match
3608 # now the real test..
3609 dd if=/dev/zero of=$file bs=1024 count=100
3610 BEFOREWRITES=`count_ost_writes`
3611 $TRUNCATE $file $offset
3612 cancel_lru_locks osc
3613 AFTERWRITES=`count_ost_writes`
3618 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3620 [ $BEFOREWRITES -eq $AFTERWRITES ] && \
3621 error "beforewrites $BEFOREWRITES == afterwrites $AFTERWRITES on truncate"
3624 run_test 42c "test partial truncate of file with cached dirty data"
3627 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3629 [ $BEFOREWRITES -eq $AFTERWRITES ] || \
3630 error "beforewrites $BEFOREWRITES != afterwrites $AFTERWRITES on truncate"
3633 run_test 42d "test complete truncate of file with cached dirty data"
3635 test_42e() { # bug22074
3636 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3637 local TDIR=$DIR/${tdir}e
3638 local pagesz=$(page_size)
3639 local pages=16 # hardcoded 16 pages, don't change it.
3640 local files=$((OSTCOUNT * 500)) # hopefully 500 files on each OST
3641 local proc_osc0="osc.${FSNAME}-OST0000-osc-[^MDT]*"
3645 test_mkdir -p $DIR/${tdir}e
3646 $SETSTRIPE -c 1 $TDIR
3647 createmany -o $TDIR/f $files
3649 max_dirty_mb=$($LCTL get_param -n $proc_osc0/max_dirty_mb)
3651 # we assume that with $OSTCOUNT files, at least one of them will
3652 # be allocated on OST0.
3653 warmup_files=$((OSTCOUNT * max_dirty_mb))
3654 createmany -o $TDIR/w $warmup_files
3656 # write a large amount of data into one file and sync, to get good
3657 # avail_grant number from OST.
3658 for ((i=0; i<$warmup_files; i++)); do
3659 idx=$($GETSTRIPE -i $TDIR/w$i)
3660 [ $idx -ne 0 ] && continue
3661 dd if=/dev/zero of=$TDIR/w$i bs="$max_dirty_mb"M count=1
3664 [[ $i -gt $warmup_files ]] && error "OST0 is still cold"
3666 $LCTL get_param $proc_osc0/cur_dirty_bytes
3667 $LCTL get_param $proc_osc0/cur_grant_bytes
3669 # create as much dirty pages as we can while not to trigger the actual
3670 # RPCs directly. but depends on the env, VFS may trigger flush during this
3671 # period, hopefully we are good.
3672 for ((i=0; i<$warmup_files; i++)); do
3673 idx=$($GETSTRIPE -i $TDIR/w$i)
3674 [ $idx -ne 0 ] && continue
3675 dd if=/dev/zero of=$TDIR/w$i bs=1M count=1 2>/dev/null
3677 $LCTL get_param $proc_osc0/cur_dirty_bytes
3678 $LCTL get_param $proc_osc0/cur_grant_bytes
3680 # perform the real test
3681 $LCTL set_param $proc_osc0/rpc_stats 0
3682 for ((;i<$files; i++)); do
3683 [ $($GETSTRIPE -i $TDIR/f$i) -eq 0 ] || continue
3684 dd if=/dev/zero of=$TDIR/f$i bs=$pagesz count=$pages 2>/dev/null
3687 $LCTL get_param $proc_osc0/rpc_stats
3690 local have_ppr=false
3691 $LCTL get_param $proc_osc0/rpc_stats |
3692 while read PPR RRPC RPCT RCUM BAR WRPC WPCT WCUM; do
3693 # skip lines until we are at the RPC histogram data
3694 [ "$PPR" == "pages" ] && have_ppr=true && continue
3695 $have_ppr || continue
3697 # we only want the percent stat for < 16 pages
3698 [[ $(echo $PPR | tr -d ':') -ge $pages ]] && break
3700 percent=$((percent + WPCT))
3701 if [[ $percent -gt 15 ]]; then
3702 error "less than 16-pages write RPCs" \
3709 run_test 42e "verify sub-RPC writes are not done synchronously"
3712 test_mkdir -p $DIR/$tdir
3713 cp -p /bin/ls $DIR/$tdir/$tfile
3714 $MULTIOP $DIR/$tdir/$tfile Ow_c &
3716 # give multiop a chance to open
3719 $DIR/$tdir/$tfile && error || true
3722 run_test 43 "execution of file opened for write should return -ETXTBSY"
3725 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3726 test_mkdir -p $DIR/$tdir
3727 cp -p `which $MULTIOP` $DIR/$tdir/multiop ||
3728 cp -p multiop $DIR/$tdir/multiop
3729 MULTIOP_PROG=$DIR/$tdir/multiop multiop_bg_pause $TMP/$tfile.junk O_c ||
3732 $MULTIOP $DIR/$tdir/multiop Oc && error "expected error, got success"
3733 kill -USR1 $MULTIOP_PID || return 2
3734 wait $MULTIOP_PID || return 3
3735 rm $TMP/$tfile.junk $DIR/$tdir/multiop
3737 run_test 43a "open(RDWR) of file being executed should return -ETXTBSY"
3740 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3741 test_mkdir -p $DIR/$tdir
3742 cp -p `which $MULTIOP` $DIR/$tdir/multiop ||
3743 cp -p multiop $DIR/$tdir/multiop
3744 MULTIOP_PROG=$DIR/$tdir/multiop multiop_bg_pause $TMP/$tfile.junk O_c ||
3747 $TRUNCATE $DIR/$tdir/multiop 0 && error "expected error, got success"
3748 kill -USR1 $MULTIOP_PID || return 2
3749 wait $MULTIOP_PID || return 3
3750 rm $TMP/$tfile.junk $DIR/$tdir/multiop
3752 run_test 43b "truncate of file being executed should return -ETXTBSY"
3755 local testdir="$DIR/$tdir"
3756 test_mkdir -p $DIR/$tdir
3758 ( cd $(dirname $SHELL) && md5sum $(basename $SHELL) ) | \
3759 ( cd $testdir && md5sum -c)
3761 run_test 43c "md5sum of copy into lustre========================"
3764 [[ $OSTCOUNT -lt 2 ]] && skip_env "skipping 2-stripe test" && return
3765 dd if=/dev/zero of=$DIR/f1 bs=4k count=1 seek=1023
3766 dd if=$DIR/f1 bs=4k count=1 > /dev/null
3768 run_test 44 "zero length read from a sparse stripe ============="
3771 local nstripe=$($LCTL lov_getconfig $DIR | grep default_stripe_count: |
3773 [ -z "$nstripe" ] && skip "can't get stripe info" && return
3774 [[ $nstripe -gt $OSTCOUNT ]] &&
3775 skip "Wrong default_stripe_count: $nstripe (OSTCOUNT: $OSTCOUNT)" &&
3777 local stride=$($LCTL lov_getconfig $DIR | grep default_stripe_size: |
3779 if [[ $nstripe -eq 0 || $nstripe -eq -1 ]]; then
3780 nstripe=$($LCTL lov_getconfig $DIR | grep obd_count: |
3784 OFFSETS="0 $((stride/2)) $((stride-1))"
3785 for offset in $OFFSETS; do
3786 for i in $(seq 0 $((nstripe-1))); do
3787 local GLOBALOFFSETS=""
3789 local size=$((((i + 2 * $nstripe )*$stride + $offset)))
3790 local myfn=$DIR/d44a-$size
3791 echo "--------writing $myfn at $size"
3792 ll_sparseness_write $myfn $size ||
3793 error "ll_sparseness_write"
3794 GLOBALOFFSETS="$GLOBALOFFSETS $size"
3795 ll_sparseness_verify $myfn $GLOBALOFFSETS ||
3796 error "ll_sparseness_verify $GLOBALOFFSETS"
3798 for j in $(seq 0 $((nstripe-1))); do
3800 size=$((((j + $nstripe )*$stride + $offset)))
3801 ll_sparseness_write $myfn $size ||
3802 error "ll_sparseness_write"
3803 GLOBALOFFSETS="$GLOBALOFFSETS $size"
3805 ll_sparseness_verify $myfn $GLOBALOFFSETS ||
3806 error "ll_sparseness_verify $GLOBALOFFSETS"
3811 run_test 44a "test sparse pwrite ==============================="
3815 for d in `lctl get_param -n osc.*.cur_dirty_bytes`; do
3821 before=`dirty_osc_total`
3822 echo executing "\"$*\""
3824 after=`dirty_osc_total`
3825 echo before $before, after $after
3828 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3830 # Obtain grants from OST if it supports it
3831 echo blah > ${f}_grant
3834 do_dirty_record "echo blah > $f"
3835 [[ $before -eq $after ]] && error "write wasn't cached"
3836 do_dirty_record "> $f"
3837 [[ $before -gt $after ]] || error "truncate 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 "sync"
3841 [[ $before -gt $after ]] || error "writeback didn't lower dirty count"
3842 do_dirty_record "echo blah > $f"
3843 [[ $before -eq $after ]] && error "write wasn't cached"
3844 do_dirty_record "cancel_lru_locks osc"
3845 [[ $before -gt $after ]] ||
3846 error "lock cancellation didn't lower dirty count"
3849 run_test 45 "osc io page accounting ============================"
3851 # in a 2 stripe file (lov.sh), page 1023 maps to page 511 in its object. this
3852 # test tickles a bug where re-dirtying a page was failing to be mapped to the
3853 # objects offset and an assert hit when an rpc was built with 1023's mapped
3854 # offset 511 and 511's raw 511 offset. it also found general redirtying bugs.
3856 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3860 dd if=/dev/zero of=$f bs=`page_size` seek=511 count=1
3862 dd conv=notrunc if=/dev/zero of=$f bs=`page_size` seek=1023 count=1
3863 dd conv=notrunc if=/dev/zero of=$f bs=`page_size` seek=511 count=1
3867 run_test 46 "dirtying a previously written page ================"
3869 # test_47 is removed "Device nodes check" is moved to test_28
3871 test_48a() { # bug 2399
3872 [ $(facet_fstype $SINGLEMDS) = "zfs" ] &&
3873 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.3.63) ] &&
3874 skip "MDS prior to 2.3.63 handle ZFS dir .. incorrectly" &&
3876 test_mkdir $DIR/$tdir
3878 mv $DIR/$tdir $DIR/$tdir.new || error "move directory failed"
3879 test_mkdir $DIR/$tdir || error "recreate directory failed"
3880 touch foo || error "'touch foo' failed after recreating cwd"
3881 test_mkdir bar || error "'mkdir foo' failed after recreating cwd"
3882 touch .foo || error "'touch .foo' failed after recreating cwd"
3883 test_mkdir .bar || error "'mkdir .foo' failed after recreating cwd"
3884 ls . > /dev/null || error "'ls .' failed after recreating cwd"
3885 ls .. > /dev/null || error "'ls ..' failed after removing cwd"
3886 cd . || error "'cd .' failed after recreating cwd"
3887 test_mkdir . && error "'mkdir .' worked after recreating cwd"
3888 rmdir . && error "'rmdir .' worked after recreating cwd"
3889 ln -s . baz || error "'ln -s .' failed after recreating cwd"
3890 cd .. || error "'cd ..' failed after recreating cwd"
3892 run_test 48a "Access renamed working dir (should return errors)="
3894 test_48b() { # bug 2399
3896 test_mkdir $DIR/$tdir
3898 rmdir $DIR/$tdir || error "remove cwd $DIR/$tdir failed"
3899 touch foo && error "'touch foo' worked after removing cwd"
3900 test_mkdir foo && error "'mkdir foo' worked after removing cwd"
3901 touch .foo && error "'touch .foo' worked after removing cwd"
3902 test_mkdir .foo && error "'mkdir .foo' worked after removing cwd"
3903 ls . > /dev/null && error "'ls .' worked after removing cwd"
3904 ls .. > /dev/null || error "'ls ..' failed after removing cwd"
3905 is_patchless || ( cd . && error "'cd .' worked after removing cwd" )
3906 test_mkdir . && error "'mkdir .' worked after removing cwd"
3907 rmdir . && error "'rmdir .' worked after removing cwd"
3908 ln -s . foo && error "'ln -s .' worked after removing cwd"
3909 cd .. || echo "'cd ..' failed after removing cwd `pwd`" #bug 3517
3911 run_test 48b "Access removed working dir (should return errors)="
3913 test_48c() { # bug 2350
3914 #lctl set_param debug=-1
3917 test_mkdir -p $DIR/$tdir/dir
3919 $TRACE rmdir $DIR/$tdir/dir || error "remove cwd $DIR/$tdir/dir failed"
3920 $TRACE touch foo && error "touch foo worked after removing cwd"
3921 $TRACE test_mkdir foo && error "'mkdir foo' worked after removing cwd"
3922 touch .foo && error "touch .foo worked after removing cwd"
3923 test_mkdir .foo && error "mkdir .foo worked after removing cwd"
3924 $TRACE ls . && error "'ls .' worked after removing cwd"
3925 $TRACE ls .. || error "'ls ..' failed after removing cwd"
3926 is_patchless || ( $TRACE cd . &&
3927 error "'cd .' worked after removing cwd" )
3928 $TRACE test_mkdir . && error "'mkdir .' worked after removing cwd"
3929 $TRACE rmdir . && error "'rmdir .' worked after removing cwd"
3930 $TRACE ln -s . foo && error "'ln -s .' worked after removing cwd"
3931 $TRACE cd .. || echo "'cd ..' failed after removing cwd `pwd`" #bug 3415
3933 run_test 48c "Access removed working subdir (should return errors)"
3935 test_48d() { # bug 2350
3936 #lctl set_param debug=-1
3939 test_mkdir -p $DIR/$tdir/dir
3941 $TRACE rmdir $DIR/$tdir/dir || error "remove cwd $DIR/$tdir/dir failed"
3942 $TRACE rmdir $DIR/$tdir || error "remove parent $DIR/$tdir failed"
3943 $TRACE touch foo && error "'touch foo' worked after removing parent"
3944 $TRACE test_mkdir foo && error "mkdir foo worked after removing parent"
3945 touch .foo && error "'touch .foo' worked after removing parent"
3946 test_mkdir .foo && error "mkdir .foo worked after removing parent"
3947 $TRACE ls . && error "'ls .' worked after removing parent"
3948 $TRACE ls .. && error "'ls ..' worked after removing parent"
3949 is_patchless || ( $TRACE cd . &&
3950 error "'cd .' worked after recreate parent" )
3951 $TRACE test_mkdir . && error "'mkdir .' worked after removing parent"
3952 $TRACE rmdir . && error "'rmdir .' worked after removing parent"
3953 $TRACE ln -s . foo && error "'ln -s .' worked after removing parent"
3954 is_patchless || ( $TRACE cd .. &&
3955 error "'cd ..' worked after removing parent" || true )
3957 run_test 48d "Access removed parent subdir (should return errors)"
3959 test_48e() { # bug 4134
3960 #lctl set_param debug=-1
3963 test_mkdir -p $DIR/$tdir/dir
3965 $TRACE rmdir $DIR/$tdir/dir || error "remove cwd $DIR/$tdir/dir failed"
3966 $TRACE rmdir $DIR/$tdir || error "remove parent $DIR/$tdir failed"
3967 $TRACE touch $DIR/$tdir || error "'touch $DIR/$tdir' failed"
3968 $TRACE chmod +x $DIR/$tdir || error "'chmod +x $DIR/$tdir' failed"
3969 # On a buggy kernel addition of "touch foo" after cd .. will
3970 # produce kernel oops in lookup_hash_it
3971 touch ../foo && error "'cd ..' worked after recreate parent"
3973 $TRACE rm $DIR/$tdir || error "rm '$DIR/$tdir' failed"
3975 run_test 48e "Access to recreated parent subdir (should return errors)"
3977 test_49() { # LU-1030
3978 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3979 # get ost1 size - lustre-OST0000
3980 ost1_size=$(do_facet ost1 $LFS df | grep ${ost1_svc} |
3982 # write 800M at maximum
3983 [[ $ost1_size -lt 2 ]] && ost1_size=2
3984 [[ $ost1_size -gt 819200 ]] && ost1_size=819200
3986 $SETSTRIPE -c 1 -i 0 $DIR/$tfile
3987 dd if=/dev/zero of=$DIR/$tfile bs=4k count=$((ost1_size >> 2)) &
3990 # change max_pages_per_rpc while writing the file
3991 local osc1_mppc=osc.$(get_osc_import_name client ost1).max_pages_per_rpc
3992 local orig_mppc=$($LCTL get_param -n $osc1_mppc)
3993 # loop until dd process exits
3994 while ps ax -opid | grep -wq $dd_pid; do
3995 $LCTL set_param $osc1_mppc=$((RANDOM % 256 + 1))
3996 sleep $((RANDOM % 5 + 1))
3998 # restore original max_pages_per_rpc
3999 $LCTL set_param $osc1_mppc=$orig_mppc
4000 rm $DIR/$tfile || error "rm $DIR/$tfile failed"
4002 run_test 49 "Change max_pages_per_rpc won't break osc extent"
4006 test_mkdir $DIR/$tdir
4008 ls /proc/$$/cwd || error "ls /proc/$$/cwd failed"
4010 run_test 50 "special situations: /proc symlinks ==============="
4012 test_51a() { # was test_51
4013 # bug 1516 - create an empty entry right after ".." then split dir
4014 test_mkdir -c1 $DIR/$tdir
4015 touch $DIR/$tdir/foo
4016 $MCREATE $DIR/$tdir/bar
4018 createmany -m $DIR/$tdir/longfile 201
4020 while [[ $(ls -sd $DIR/$tdir | awk '{ print $1 }') -eq 4 ]]; do
4021 $MCREATE $DIR/$tdir/longfile$FNUM
4026 ls -l $DIR/$tdir > /dev/null || error "ls -l $DIR/$tdir failed"
4028 run_test 51a "special situations: split htree with empty entry =="
4030 export NUMTEST=70000
4032 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4033 local BASE=$DIR/d${base}.${TESTSUITE}
4035 # cleanup the directory
4038 test_mkdir -p -c1 $BASE
4042 local mdtidx=$(printf "%04x" $($LFS getstripe -M $BASE))
4043 local numfree=$(lctl get_param -n mdc.$FSNAME-MDT$mdtidx*.filesfree)
4044 [[ $numfree -lt 21000 ]] &&
4045 skip "not enough free inodes ($numfree) on MDT$mdtidx" &&
4048 [[ $numfree -lt $NUMTEST ]] && NUMTEST=$(($numfree - 50)) &&
4049 echo "reduced count to $NUMTEST due to inodes on MDT$mdtidx"
4051 # need to check free space for the directories as well
4052 local blkfree=$(lctl get_param -n mdc.$FSNAME-MDT$mdtidx*.kbytesavail)
4053 numfree=$((blkfree / 4))
4054 [[ $numfree -lt $NUMTEST ]] && NUMTEST=$((numfree - 50)) &&
4055 echo "reduced count to $NUMTEST due to blocks on MDT$mdtidx"
4057 createmany -d $BASE/d $NUMTEST && echo $NUMTEST > $BASE/fnum ||
4061 echo "failed" > $BASE/fnum
4062 error "failed to create $NUMTEST subdirs in MDT$mdtidx:$BASE"
4065 run_test 51b "exceed 64k subdirectory nlink limit"
4067 test_51ba() { # LU-993
4068 local BASE=$DIR/d${base}.${TESTSUITE}
4069 # unlink all but 100 subdirectories, then check it still works
4071 [ -f $BASE/fnum ] && local NUMPREV=$(cat $BASE/fnum) && rm $BASE/fnum
4073 [ "$NUMPREV" != "failed" ] && NUMTEST=$NUMPREV
4074 local DELETE=$((NUMTEST - LEFT))
4076 # continue on to run this test even if 51b didn't finish,
4077 # just to delete the many subdirectories created.
4078 [ ! -d "${BASE}/d1" ] && skip "test_51b() not run" && return 0
4080 # for ldiskfs the nlink count should be 1, but this is OSD specific
4081 # and so this is listed for informational purposes only
4082 echo "nlink before: $(stat -c %h $BASE), created before: $NUMTEST"
4083 unlinkmany -d $BASE/d $DELETE
4086 if [ $RC -ne 0 ]; then
4087 if [ "$NUMPREV" == "failed" ]; then
4088 skip "previous setup failed"
4091 error "unlink of first $DELETE subdirs failed"
4096 echo "nlink between: $(stat -c %h $BASE)"
4097 # trim the first line of ls output
4098 local FOUND=$(($(ls -l ${BASE} | wc -l) - 1))
4099 [ $FOUND -ne $LEFT ] &&
4100 error "can't find subdirs: found only $FOUND/$LEFT"
4102 unlinkmany -d $BASE/d $DELETE $LEFT ||
4103 error "unlink of second $LEFT subdirs failed"
4104 # regardless of whether the backing filesystem tracks nlink accurately
4105 # or not, the nlink count shouldn't be more than "." and ".." here
4106 local AFTER=$(stat -c %h $BASE)
4107 [[ $AFTER -gt 2 ]] && error "nlink after: $AFTER > 2" ||
4108 echo "nlink after: $AFTER"
4110 run_test 51ba "verify nlink for many subdirectory cleanup"
4113 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4114 [[ $OSTCOUNT -lt 3 ]] &&
4115 skip_env "skipping test with few OSTs" && return
4116 test_mkdir -p $DIR/$tdir
4117 createmany -o $DIR/$tdir/t- 1000
4118 $GETSTRIPE $DIR/$tdir > $TMP/files
4119 for N in $(seq 0 $((OSTCOUNT - 1))); do
4120 OBJS[$N]=$(awk -vobjs=0 '($1 == '$N') { objs += 1 } \
4121 END { printf("%0.0f", objs) }' $TMP/files)
4122 OBJS0[$N]=$(grep -A 1 idx $TMP/files | awk -vobjs=0 \
4123 '($1 == '$N') { objs += 1 } \
4124 END { printf("%0.0f", objs) }')
4125 log "OST$N has ${OBJS[$N]} objects, ${OBJS0[$N]} are index 0"
4127 unlinkmany $DIR/$tdir/t- 1000
4130 for N in $(seq 1 $((OSTCOUNT - 1))); do
4131 [[ ${OBJS[$N]} -lt $((${OBJS[$NLAST]} - 20)) ]] &&
4132 error "OST $N has less objects vs OST $NLAST" \
4133 " (${OBJS[$N]} < ${OBJS[$NLAST]}"
4134 [[ ${OBJS[$N]} -gt $((${OBJS[$NLAST]} + 20)) ]] &&
4135 error "OST $N has less objects vs OST $NLAST" \
4136 " (${OBJS[$N]} < ${OBJS[$NLAST]}"
4138 [[ ${OBJS0[$N]} -lt $((${OBJS0[$NLAST]} - 20)) ]] &&
4139 error "OST $N has less #0 objects vs OST $NLAST" \
4140 " (${OBJS0[$N]} < ${OBJS0[$NLAST]}"
4141 [[ ${OBJS0[$N]} -gt $((${OBJS0[$NLAST]} + 20)) ]] &&
4142 error "OST $N has less #0 objects vs OST $NLAST" \
4143 " (${OBJS0[$N]} < ${OBJS0[$NLAST]}"
4147 run_test 51d "check object distribution ===================="
4150 if [ "$(facet_fstype $SINGLEMDS)" != ldiskfs ]; then
4151 skip "Only applicable to ldiskfs-based MDTs"
4155 test_mkdir -c1 $DIR/$tdir || error "create $tdir failed"
4156 test_mkdir -c1 $DIR/$tdir/d0 || error "create d0 failed"
4158 touch $DIR/$tdir/d0/foo
4159 createmany -l $DIR/$tdir/d0/foo $DIR/$tdir/d0/f- 65001 &&
4160 error "file exceed 65000 nlink limit!"
4161 unlinkmany $DIR/$tdir/d0/f- 65001
4164 run_test 51e "check file nlink limit"
4167 [ -f $DIR/$tdir/foo ] && chattr -a $DIR/$tdir/foo
4168 test_mkdir -p $DIR/$tdir
4169 touch $DIR/$tdir/foo
4170 chattr +a $DIR/$tdir/foo || error "chattr +a failed"
4171 echo bar >> $DIR/$tdir/foo || error "append bar failed"
4172 cp /etc/hosts $DIR/$tdir/foo && error "cp worked"
4173 rm -f $DIR/$tdir/foo 2>/dev/null && error "rm worked"
4174 link $DIR/$tdir/foo $DIR/$tdir/foo_link 2>/dev/null &&
4176 echo foo >> $DIR/$tdir/foo || error "append foo failed"
4177 mrename $DIR/$tdir/foo $DIR/$tdir/foo_ren && error "rename worked"
4178 lsattr $DIR/$tdir/foo | egrep -q "^-+a[-e]+ $DIR/$tdir/foo" ||
4180 chattr -a $DIR/$tdir/foo || error "chattr -a failed"
4181 cp -r $DIR/$tdir /tmp/
4182 rm -fr $DIR/$tdir || error "cleanup rm failed"
4184 run_test 52a "append-only flag test (should return errors) ====="
4187 [ -f $DIR/$tdir/foo ] && chattr -i $DIR/$tdir/foo
4188 test_mkdir -p $DIR/$tdir
4189 touch $DIR/$tdir/foo
4190 chattr +i $DIR/$tdir/foo || error "chattr +i failed"
4191 cat test > $DIR/$tdir/foo && error "cat test worked"
4192 cp /etc/hosts $DIR/$tdir/foo && error "cp worked"
4193 rm -f $DIR/$tdir/foo 2>/dev/null && error "rm worked"
4194 link $DIR/$tdir/foo $DIR/$tdir/foo_link 2>/dev/null &&
4196 echo foo >> $DIR/$tdir/foo && error "echo worked"
4197 mrename $DIR/$tdir/foo $DIR/$tdir/foo_ren && error "rename worked"
4198 [ -f $DIR/$tdir/foo ] || error "$tdir/foo is not a file"
4199 [ -f $DIR/$tdir/foo_ren ] && error "$tdir/foo_ren is not a file"
4200 lsattr $DIR/$tdir/foo | egrep -q "^-+i[-e]+ $DIR/$tdir/foo" ||
4202 chattr -i $DIR/$tdir/foo || error "chattr failed"
4204 rm -fr $DIR/$tdir || error "unable to remove $DIR/$tdir"
4206 run_test 52b "immutable flag test (should return errors) ======="
4209 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4210 remote_mds_nodsh && skip "remote MDS with nodsh" && return
4211 remote_ost_nodsh && skip "remote OST with nodsh" && return
4224 local support_last_seq=true
4226 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.3.60) ]] ||
4227 support_last_seq=false
4230 local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS)
4232 for value in $(do_facet $SINGLEMDS \
4233 $LCTL get_param osc.$mdtosc.prealloc_last_id) ; do
4234 param=$(echo ${value[0]} | cut -d "=" -f1)
4235 ostname=$(echo $param | cut -d "." -f2 | cut -d - -f 1-2)
4237 if $support_last_seq; then
4238 param_seq=$(echo $param |
4239 sed -e s/prealloc_last_id/prealloc_last_seq/g)
4240 mds_last_seq=$(do_facet $SINGLEMDS \
4241 $LCTL get_param -n $param_seq)
4243 mds_last=$(do_facet $SINGLEMDS $LCTL get_param -n $param)
4245 ostnum=$(index_from_ostuuid ${ostname}_UUID)
4246 node=$(facet_active_host ost$((ostnum+1)))
4247 param="obdfilter.$ostname.last_id"
4248 for ost_last in $(do_node $node $LCTL get_param -n $param) ; do
4249 echo "$ostname.last_id=$ost_last; MDS.last_id=$mds_last"
4250 ost_last_id=$ost_last
4252 if $support_last_seq; then
4253 ost_last_id=$(echo $ost_last |
4254 awk -F':' '{print $2}' |
4256 ost_last_seq=$(echo $ost_last |
4257 awk -F':' '{print $1}')
4258 [[ $ost_last_seq = $mds_last_seq ]] || continue
4261 if [[ $ost_last_id != $mds_last ]]; then
4262 error "$ost_last_id != $mds_last"
4269 $found || error "can not match last_seq/last_id for $mdtosc"
4272 run_test 53 "verify that MDS and OSTs agree on pre-creation ===="
4275 $SOCKETSERVER $DIR/socket ||
4276 error "$SOCKETSERVER $DIR/socket failed: $?"
4277 $SOCKETCLIENT $DIR/socket ||
4278 error "$SOCKETCLIENT $DIR/socket failed: $?"
4279 $MUNLINK $DIR/socket || error "$MUNLINK $DIR/socket failed: $?"
4281 run_test 54a "unix domain socket test =========================="
4287 dd if=/dev/zero of=$f bs=$(page_size) count=1
4289 run_test 54b "char device works in lustre ======================"
4292 [ -b /dev/loop/0 ] && LOOPBASE=/dev/loop/
4293 [ -b /dev/loop0 ] && LOOPBASE=/dev/loop
4294 [ -z "$LOOPBASE" ] && echo "/dev/loop/0 and /dev/loop0 gone?" && return
4296 for i in $(seq 3 7); do
4297 losetup $LOOPBASE$i > /dev/null 2>&1 && continue
4305 loopdev="$DIR/loop54c"
4308 $UMOUNT $DIR/$tdir || rc=$?
4309 losetup -d $loopdev || true
4310 losetup -d $LOOPDEV || true
4311 rm -rf $loopdev $DIR/$tfile $DIR/$tdir
4316 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4317 loopdev="$DIR/loop54c"
4320 [ -z "$LOOPNUM" ] && echo "couldn't find empty loop device" && return
4321 trap cleanup_54c EXIT
4322 mknod $loopdev b 7 $LOOPNUM
4323 echo "make a loop file system with $DIR/$tfile on $loopdev ($LOOPNUM)."
4324 dd if=/dev/zero of=$DIR/$tfile bs=$(get_page_size client) seek=1024 count=1 > /dev/null
4325 losetup $loopdev $DIR/$tfile ||
4326 error "can't set up $loopdev for $DIR/$tfile"
4327 mkfs.ext2 $loopdev || error "mke2fs on $loopdev"
4328 test_mkdir -p $DIR/$tdir
4329 mount -t ext2 $loopdev $DIR/$tdir ||
4330 error "error mounting $loopdev on $DIR/$tdir"
4331 dd if=/dev/zero of=$DIR/$tdir/tmp bs=$(get_page_size client) count=30 ||
4334 dd if=$DIR/$tdir/tmp of=/dev/zero bs=$(get_page_size client) count=30 ||
4338 run_test 54c "block device works in lustre ====================="
4344 [ "$string" = $(echo $string > $f | cat $f) ] || error "$f != $string"
4346 run_test 54d "fifo device works in lustre ======================"
4351 cp -aL /dev/console $f
4352 echo $string > $f || error "echo $string to $f failed"
4354 run_test 54e "console/tty device works in lustre ======================"
4356 #The test_55 used to be iopen test and it was removed by bz#24037.
4357 #run_test 55 "check iopen_connect_dentry() ======================"
4359 test_56a() { # was test_56
4362 test_mkdir -p $DIR/$tdir/dir
4364 NUMFILESx2=$(($NUMFILES * 2))
4365 for i in $(seq 1 $NUMFILES); do
4366 touch $DIR/$tdir/file$i
4367 touch $DIR/$tdir/dir/file$i
4370 # test lfs getstripe with --recursive
4371 FILENUM=$($GETSTRIPE --recursive $DIR/$tdir | grep -c obdidx)
4372 [[ $FILENUM -eq $NUMFILESx2 ]] ||
4373 error "$GETSTRIPE --recursive: found $FILENUM, not $NUMFILESx2"
4374 FILENUM=$($GETSTRIPE $DIR/$tdir | grep -c obdidx)
4375 [[ $FILENUM -eq $NUMFILES ]] ||
4376 error "$GETSTRIPE $DIR/$tdir: found $FILENUM, not $NUMFILES"
4377 echo "$GETSTRIPE --recursive passed."
4379 # test lfs getstripe with file instead of dir
4380 FILENUM=$($GETSTRIPE $DIR/$tdir/file1 | grep -c obdidx)
4381 [[ $FILENUM -eq 1 ]] ||
4382 error "$GETSTRIPE $DIR/$tdir/file1: found $FILENUM, not 1"
4383 echo "$GETSTRIPE file1 passed."
4385 #test lfs getstripe with --verbose
4386 [[ $($GETSTRIPE --verbose $DIR/$tdir |
4387 grep -c lmm_magic) -eq $NUMFILES ]] ||
4388 error "$GETSTRIPE --verbose $DIR/$tdir: want $NUMFILES"
4389 [[ $($GETSTRIPE $DIR/$tdir | grep -c lmm_magic) -eq 0 ]] ||
4390 rror "$GETSTRIPE $DIR/$tdir: showed lmm_magic"
4391 echo "$GETSTRIPE --verbose passed."
4393 #test lfs getstripe with --obd
4394 $GETSTRIPE --obd wrong_uuid $DIR/$tdir 2>&1 |
4395 grep -q "unknown obduuid" ||
4396 error "$GETSTRIPE --obd wrong_uuid should return error message"
4398 [[ $OSTCOUNT -lt 2 ]] &&
4399 skip_env "skipping other $GETSTRIPE --obd test" && return
4402 OBDUUID=$(ostuuid_from_index $OSTIDX)
4403 FILENUM=$($GETSTRIPE -ir $DIR/$tdir | grep "^$OSTIDX\$" | wc -l)
4404 FOUND=$($GETSTRIPE -r --obd $OBDUUID $DIR/$tdir | grep obdidx | wc -l)
4405 [[ $FOUND -eq $FILENUM ]] ||
4406 error "$GETSTRIPE --obd wrong: found $FOUND, expected $FILENUM"
4407 [[ $($GETSTRIPE -r -v --obd $OBDUUID $DIR/$tdir |
4408 sed '/^[ ]*'${OSTIDX}'[ ]/d' |
4409 sed -n '/^[ ]*[0-9][0-9]*[ ]/p' | wc -l) -eq 0 ]] ||
4410 error "$GETSTRIPE --obd: should not show file on other obd"
4411 echo "$GETSTRIPE --obd passed"
4413 run_test 56a "check $GETSTRIPE"
4418 local LOCAL_NUMFILES="$1"
4419 local LOCAL_NUMDIRS="$2"
4420 local MKDIR_PARAMS="$3"
4421 local DIR_STRIPE_PARAMS="$4"
4423 if [ ! -d "$TDIR" ] ; then
4424 test_mkdir -p $DIR_STRIPE_PARAMS $TDIR
4425 [ "$MKDIR_PARAMS" ] && $SETSTRIPE $MKDIR_PARAMS $TDIR
4426 for i in `seq 1 $LOCAL_NUMFILES` ; do
4429 for i in `seq 1 $LOCAL_NUMDIRS` ; do
4430 test_mkdir $DIR_STRIPE_PARAMS $TDIR/dir$i
4431 for j in `seq 1 $LOCAL_NUMFILES` ; do
4432 touch $TDIR/dir$i/file$j
4438 setup_56_special() {
4442 if [ ! -e "$TDIR/loop1b" ] ; then
4443 for i in `seq 1 $LOCAL_NUMFILES` ; do
4444 mknod $TDIR/loop${i}b b 7 $i
4445 mknod $TDIR/null${i}c c 1 3
4446 ln -s $TDIR/file1 $TDIR/link${i}l
4448 for i in `seq 1 $LOCAL_NUMDIRS` ; do
4449 mknod $TDIR/dir$i/loop${i}b b 7 $i
4450 mknod $TDIR/dir$i/null${i}c c 1 3
4451 ln -s $TDIR/dir$i/file1 $TDIR/dir$i/link${i}l
4460 setup_56 $NUMFILES $NUMDIRS
4462 EXPECTED=$(($NUMDIRS + 2))
4463 # test lfs find with -name
4464 for i in $(seq 1 $NUMFILES) ; do
4465 NUMS=$($LFIND -name "*$i" $TDIR | wc -l)
4466 [ $NUMS -eq $EXPECTED ] ||
4467 error "lfs find -name \"*$i\" $TDIR wrong: "\
4468 "found $NUMS, expected $EXPECTED"
4471 run_test 56g "check lfs find -name ============================="
4477 setup_56 $NUMFILES $NUMDIRS
4479 EXPECTED=$(((NUMDIRS + 1) * (NUMFILES - 1) + NUMFILES))
4480 # test lfs find with ! -name
4481 for i in $(seq 1 $NUMFILES) ; do
4482 NUMS=$($LFIND ! -name "*$i" $TDIR | wc -l)
4483 [ $NUMS -eq $EXPECTED ] ||
4484 error "lfs find ! -name \"*$i\" $TDIR wrong: "\
4485 "found $NUMS, expected $EXPECTED"
4488 run_test 56h "check lfs find ! -name ============================="
4492 test_mkdir -p $DIR/$tdir
4493 UUID=$(ostuuid_from_index 0 $DIR/$tdir)
4494 CMD="$LFIND -ost $UUID $DIR/$tdir"
4496 [ -z "$OUT" ] || error "\"$CMD\" returned directory '$OUT'"
4498 run_test 56i "check 'lfs find -ost UUID' skips directories ======="
4502 setup_56_special $NUMFILES $NUMDIRS
4504 EXPECTED=$((NUMDIRS + 1))
4505 CMD="$LFIND -type d $TDIR"
4506 NUMS=$($CMD | wc -l)
4507 [ $NUMS -eq $EXPECTED ] ||
4508 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4510 run_test 56j "check lfs find -type d ============================="
4514 setup_56_special $NUMFILES $NUMDIRS
4516 EXPECTED=$(((NUMDIRS + 1) * NUMFILES))
4517 CMD="$LFIND -type f $TDIR"
4518 NUMS=$($CMD | wc -l)
4519 [ $NUMS -eq $EXPECTED ] ||
4520 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4522 run_test 56k "check lfs find -type f ============================="
4526 setup_56_special $NUMFILES $NUMDIRS
4528 EXPECTED=$((NUMDIRS + NUMFILES))
4529 CMD="$LFIND -type b $TDIR"
4530 NUMS=$($CMD | wc -l)
4531 [ $NUMS -eq $EXPECTED ] ||
4532 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4534 run_test 56l "check lfs find -type b ============================="
4538 setup_56_special $NUMFILES $NUMDIRS
4540 EXPECTED=$((NUMDIRS + NUMFILES))
4541 CMD="$LFIND -type c $TDIR"
4542 NUMS=$($CMD | wc -l)
4543 [ $NUMS -eq $EXPECTED ] ||
4544 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4546 run_test 56m "check lfs find -type c ============================="
4550 setup_56_special $NUMFILES $NUMDIRS
4552 EXPECTED=$((NUMDIRS + NUMFILES))
4553 CMD="$LFIND -type l $TDIR"
4554 NUMS=$($CMD | wc -l)
4555 [ $NUMS -eq $EXPECTED ] ||
4556 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4558 run_test 56n "check lfs find -type l ============================="
4562 setup_56 $NUMFILES $NUMDIRS
4563 utime $TDIR/file1 > /dev/null || error "utime (1)"
4564 utime $TDIR/file2 > /dev/null || error "utime (2)"
4565 utime $TDIR/dir1 > /dev/null || error "utime (3)"
4566 utime $TDIR/dir2 > /dev/null || error "utime (4)"
4567 utime $TDIR/dir1/file1 > /dev/null || error "utime (5)"
4568 dd if=/dev/zero count=1 >> $TDIR/dir1/file1 && sync
4571 NUMS=`$LFIND -mtime +0 $TDIR | wc -l`
4572 [ $NUMS -eq $EXPECTED ] || \
4573 error "lfs find -mtime +0 $TDIR wrong: found $NUMS, expected $EXPECTED"
4576 CMD="$LFIND -mtime 0 $TDIR"
4577 NUMS=$($CMD | wc -l)
4578 [ $NUMS -eq $EXPECTED ] ||
4579 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4581 run_test 56o "check lfs find -mtime for old files =========================="
4584 [ $RUNAS_ID -eq $UID ] &&
4585 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
4588 setup_56 $NUMFILES $NUMDIRS
4590 chown $RUNAS_ID $TDIR/file* || error "chown $DIR/${tdir}g/file$i failed"
4592 CMD="$LFIND -uid $RUNAS_ID $TDIR"
4593 NUMS=$($CMD | wc -l)
4594 [ $NUMS -eq $EXPECTED ] || \
4595 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4597 EXPECTED=$(((NUMFILES + 1) * NUMDIRS + 1))
4598 CMD="$LFIND ! -uid $RUNAS_ID $TDIR"
4599 NUMS=$($CMD | wc -l)
4600 [ $NUMS -eq $EXPECTED ] || \
4601 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4603 run_test 56p "check lfs find -uid and ! -uid ==============================="
4606 [ $RUNAS_ID -eq $UID ] &&
4607 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
4610 setup_56 $NUMFILES $NUMDIRS
4612 chgrp $RUNAS_GID $TDIR/file* || error "chown $TDIR/file$i failed"
4615 CMD="$LFIND -gid $RUNAS_GID $TDIR"
4616 NUMS=$($CMD | wc -l)
4617 [ $NUMS -eq $EXPECTED ] ||
4618 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4620 EXPECTED=$(( ($NUMFILES+1) * $NUMDIRS + 1))
4621 CMD="$LFIND ! -gid $RUNAS_GID $TDIR"
4622 NUMS=$($CMD | wc -l)
4623 [ $NUMS -eq $EXPECTED ] ||
4624 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4626 run_test 56q "check lfs find -gid and ! -gid ==============================="
4630 setup_56 $NUMFILES $NUMDIRS
4633 CMD="$LFIND -size 0 -type f $TDIR"
4634 NUMS=$($CMD | wc -l)
4635 [ $NUMS -eq $EXPECTED ] ||
4636 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4638 CMD="$LFIND ! -size 0 -type f $TDIR"
4639 NUMS=$($CMD | wc -l)
4640 [ $NUMS -eq $EXPECTED ] ||
4641 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4642 echo "test" > $TDIR/$tfile
4643 echo "test2" > $TDIR/$tfile.2 && sync
4645 CMD="$LFIND -size 5 -type f $TDIR"
4646 NUMS=$($CMD | wc -l)
4647 [ $NUMS -eq $EXPECTED ] ||
4648 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4650 CMD="$LFIND -size +5 -type f $TDIR"
4651 NUMS=$($CMD | wc -l)
4652 [ $NUMS -eq $EXPECTED ] ||
4653 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4655 CMD="$LFIND -size +0 -type f $TDIR"
4656 NUMS=$($CMD | wc -l)
4657 [ $NUMS -eq $EXPECTED ] ||
4658 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4660 CMD="$LFIND ! -size -5 -type f $TDIR"
4661 NUMS=$($CMD | wc -l)
4662 [ $NUMS -eq $EXPECTED ] ||
4663 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4665 CMD="$LFIND -size -5 -type f $TDIR"
4666 NUMS=$($CMD | wc -l)
4667 [ $NUMS -eq $EXPECTED ] ||
4668 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4670 run_test 56r "check lfs find -size works =========================="
4672 test_56s() { # LU-611
4674 setup_56 $NUMFILES $NUMDIRS "-c $OSTCOUNT"
4676 if [[ $OSTCOUNT -gt 1 ]]; then
4677 $SETSTRIPE -c 1 $TDIR/$tfile.{0,1,2,3}
4681 ONESTRIPE=$(((NUMDIRS + 1) * NUMFILES))
4685 EXPECTED=$(((NUMDIRS + 1) * NUMFILES))
4686 CMD="$LFIND -stripe-count $OSTCOUNT -type f $TDIR"
4687 NUMS=$($CMD | wc -l)
4688 [ $NUMS -eq $EXPECTED ] || {
4690 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4693 EXPECTED=$(((NUMDIRS + 1) * NUMFILES + EXTRA))
4694 CMD="$LFIND -stripe-count +0 -type f $TDIR"
4695 NUMS=$($CMD | wc -l)
4696 [ $NUMS -eq $EXPECTED ] || {
4698 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4702 CMD="$LFIND -stripe-count 1 -type f $TDIR"
4703 NUMS=$($CMD | wc -l)
4704 [ $NUMS -eq $EXPECTED ] || {
4706 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4709 CMD="$LFIND -stripe-count -2 -type f $TDIR"
4710 NUMS=$($CMD | wc -l)
4711 [ $NUMS -eq $EXPECTED ] || {
4713 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4717 CMD="$LFIND -stripe-count $((OSTCOUNT + 1)) -type f $TDIR"
4718 NUMS=$($CMD | wc -l)
4719 [ $NUMS -eq $EXPECTED ] || {
4721 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4724 run_test 56s "check lfs find -stripe-count works"
4726 test_56t() { # LU-611
4728 setup_56 $NUMFILES $NUMDIRS "-s 512k"
4730 $SETSTRIPE -S 256k $TDIR/$tfile.{0,1,2,3}
4732 EXPECTED=$(((NUMDIRS + 1) * NUMFILES))
4733 CMD="$LFIND -stripe-size 512k -type f $TDIR"
4734 NUMS=$($CMD | wc -l)
4735 [ $NUMS -eq $EXPECTED ] ||
4736 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4738 CMD="$LFIND -stripe-size +320k -type f $TDIR"
4739 NUMS=$($CMD | wc -l)
4740 [ $NUMS -eq $EXPECTED ] ||
4741 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4743 EXPECTED=$(((NUMDIRS + 1) * NUMFILES + 4))
4744 CMD="$LFIND -stripe-size +200k -type f $TDIR"
4745 NUMS=$($CMD | wc -l)
4746 [ $NUMS -eq $EXPECTED ] ||
4747 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4749 CMD="$LFIND -stripe-size -640k -type f $TDIR"
4750 NUMS=$($CMD | wc -l)
4751 [ $NUMS -eq $EXPECTED ] ||
4752 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4755 CMD="$LFIND -stripe-size 256k -type f $TDIR"
4756 NUMS=$($CMD | wc -l)
4757 [ $NUMS -eq $EXPECTED ] ||
4758 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4760 CMD="$LFIND -stripe-size -320k -type f $TDIR"
4761 NUMS=$($CMD | wc -l)
4762 [ $NUMS -eq $EXPECTED ] ||
4763 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4766 CMD="$LFIND -stripe-size 1024k -type f $TDIR"
4767 NUMS=$($CMD | wc -l)
4768 [ $NUMS -eq $EXPECTED ] ||
4769 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4771 run_test 56t "check lfs find -stripe-size works"
4773 test_56u() { # LU-611
4775 setup_56 $NUMFILES $NUMDIRS "-i 0"
4777 if [[ $OSTCOUNT -gt 1 ]]; then
4778 $SETSTRIPE -i 1 $TDIR/$tfile.{0,1,2,3}
4784 EXPECTED=$(((NUMDIRS + 1) * NUMFILES))
4785 CMD="$LFIND -stripe-index 0 -type f $TDIR"
4786 NUMS=$($CMD | wc -l)
4787 [ $NUMS -eq $EXPECTED ] ||
4788 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4791 CMD="$LFIND -stripe-index 1 -type f $TDIR"
4792 NUMS=$($CMD | wc -l)
4793 [ $NUMS -eq $EXPECTED ] ||
4794 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4796 CMD="$LFIND ! -stripe-index 0 -type f $TDIR"
4797 NUMS=$($CMD | wc -l)
4798 [ $NUMS -eq $EXPECTED ] ||
4799 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4802 # This should produce an error and not return any files
4803 CMD="$LFIND -stripe-index $OSTCOUNT -type f $TDIR"
4804 NUMS=$($CMD 2>/dev/null | wc -l)
4805 [ $NUMS -eq $EXPECTED ] ||
4806 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4808 if [[ $OSTCOUNT -gt 1 ]]; then
4809 EXPECTED=$(((NUMDIRS + 1) * NUMFILES + ONESTRIPE))
4810 CMD="$LFIND -stripe-index 0,1 -type f $TDIR"
4811 NUMS=$($CMD | wc -l)
4812 [ $NUMS -eq $EXPECTED ] ||
4813 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4816 run_test 56u "check lfs find -stripe-index works"
4823 setup_56 $NUMFILES $NUMDIRS
4825 UUID=$(mdtuuid_from_index $MDT_IDX $TDIR)
4826 [ -z "$UUID" ] && error "mdtuuid_from_index cannot find MDT index $MDT_IDX"
4828 for file in $($LFIND -mdt $UUID $TDIR); do
4829 file_mdt_idx=$($GETSTRIPE -M $file)
4830 [ $file_mdt_idx -eq $MDT_IDX ] ||
4831 error "'lfind -mdt $UUID' != 'getstripe -M' ($file_mdt_idx)"
4834 run_test 56v "check 'lfs find -mdt match with lfs getstripe -M' ======="
4837 [[ $OSTCOUNT -lt 2 ]] && skip_env "$OSTCOUNT < 2 OSTs -- skipping" &&
4839 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4842 rm -rf $TDIR || error "remove $TDIR failed"
4843 setup_56 $NUMFILES $NUMDIRS "-c $OSTCOUNT" "-c1"
4846 stripe_size=$($GETSTRIPE -S -d $TDIR) ||
4847 error "$GETSTRIPE -S -d $TDIR failed"
4848 stripe_size=${stripe_size%% *}
4850 local file_size=$((stripe_size * OSTCOUNT))
4851 local file_num=$((NUMDIRS * NUMFILES + NUMFILES))
4852 local required_space=$((file_num * file_size))
4854 local free_space=$($LCTL get_param -n lov.$FSNAME-clilov-*.kbytesavail |
4856 [[ $free_space -le $((required_space / 1024)) ]] &&
4857 skip_env "need at least $required_space bytes free space," \
4858 "have $free_space kbytes" && return
4861 local dd_count=$((file_size / dd_bs))
4863 # write data into the files
4867 for i in $(seq 1 $NUMFILES); do
4869 yes | dd bs=$dd_bs count=$dd_count of=$file >/dev/null 2>&1 ||
4870 error "write data into $file failed"
4872 for i in $(seq 1 $NUMDIRS); do
4873 for j in $(seq 1 $NUMFILES); do
4874 file=$TDIR/dir$i/file$j
4875 yes | dd bs=$dd_bs count=$dd_count of=$file \
4877 error "write data into $file failed"
4882 [[ $OSTCOUNT -gt 1 ]] && expected=$((OSTCOUNT - 1))
4885 local cmd="$LFS_MIGRATE -y -c $expected $TDIR/file1"
4887 eval $cmd || error "$cmd failed"
4889 check_stripe_count $TDIR/file1 $expected
4891 if [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.6.90) ];
4893 # lfs_migrate file onto OST 0 if it is on OST 1, or onto
4894 # OST 1 if it is on OST 0. This file is small enough to
4895 # be on only one stripe.
4896 file=$TDIR/migr_1_ost
4897 dd bs=$dd_bs count=1 if=/dev/urandom of=$file >/dev/null 2>&1 ||
4898 error "write data into $file failed"
4899 local obdidx=$($LFS getstripe -i $file)
4900 local oldmd5=$(md5sum $file)
4902 [[ $obdidx -eq 0 ]] && newobdidx=1
4903 cmd="$LFS migrate -i $newobdidx $file"
4905 eval $cmd || error "$cmd failed"
4906 local realobdix=$($LFS getstripe -i $file)
4907 local newmd5=$(md5sum $file)
4908 [[ $newobdidx -ne $realobdix ]] &&
4909 error "new OST is different (was=$obdidx, wanted=$newobdidx, got=$realobdix)"
4910 [[ "$oldmd5" != "$newmd5" ]] &&
4911 error "md5sum differ: $oldmd5, $newmd5"
4915 cmd="$LFS_MIGRATE -y -c $expected $TDIR/dir1"
4917 eval $cmd || error "$cmd failed"
4919 for j in $(seq 1 $NUMFILES); do
4920 check_stripe_count $TDIR/dir1/file$j $expected
4923 # lfs_migrate works with lfs find
4924 cmd="$LFIND -stripe_count $OSTCOUNT -type f $TDIR |
4925 $LFS_MIGRATE -y -c $expected"
4927 eval $cmd || error "$cmd failed"
4929 for i in $(seq 2 $NUMFILES); do
4930 check_stripe_count $TDIR/file$i $expected
4932 for i in $(seq 2 $NUMDIRS); do
4933 for j in $(seq 1 $NUMFILES); do
4934 check_stripe_count $TDIR/dir$i/file$j $expected
4938 run_test 56w "check lfs_migrate -c stripe_count works"
4941 check_swap_layouts_support && return 0
4942 [[ $OSTCOUNT -lt 2 ]] &&
4943 skip_env "need 2 OST, skipping test" && return
4945 local dir0=$DIR/$tdir/$testnum
4946 test_mkdir -p $dir0 || error "creating dir $dir0"
4948 local ref1=/etc/passwd
4949 local file1=$dir0/file1
4951 $SETSTRIPE -c 2 $file1
4953 $LFS migrate -c 1 $file1 || error "migrate failed rc = $?"
4954 stripe=$($GETSTRIPE -c $file1)
4955 [[ $stripe == 1 ]] || error "stripe of $file1 is $stripe != 1"
4956 cmp $file1 $ref1 || error "content mismatch $file1 differs from $ref1"
4961 run_test 56x "lfs migration support"
4964 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.53) ] &&
4965 skip "No HSM $(lustre_build_version $SINGLEMDS) MDS < 2.4.53" &&
4969 local dir0=$DIR/$tdir/$testnum
4970 test_mkdir -p $dir0 || error "creating dir $dir0"
4971 local f1=$dir0/file1
4972 local f2=$dir0/file2
4974 touch $f1 || error "creating std file $f1"
4975 $MULTIOP $f2 H2c || error "creating released file $f2"
4977 # a directory can be raid0, so ask only for files
4978 res=$($LFIND $dir0 -L raid0 -type f | wc -l)
4979 [[ $res == 2 ]] || error "search raid0: found $res files != 2"
4981 res=$($LFIND $dir0 \! -L raid0 -type f | wc -l)
4982 [[ $res == 0 ]] || error "search !raid0: found $res files != 0"
4984 # only files can be released, so no need to force file search
4985 res=$($LFIND $dir0 -L released)
4986 [[ $res == $f2 ]] || error "search released: found $res != $f2"
4988 res=$($LFIND $dir0 \! -L released)
4989 [[ $res == $f1 ]] || error "search !released: found $res != $f1"
4992 run_test 56y "lfs find -L raid0|released"
4994 test_56z() { # LU-4824
4995 # This checks to make sure 'lfs find' continues after errors
4996 # There are two classes of errors that should be caught:
4997 # - If multiple paths are provided, all should be searched even if one
4999 # - If errors are encountered during the search, it should not terminate
5002 test_mkdir $DIR/$tdir
5003 for i in d{0..9}; do
5004 test_mkdir $DIR/$tdir/$i
5006 touch $DIR/$tdir/d{0..9}/$tfile
5007 $LFS find $DIR/non_existent_dir $DIR/$tdir &&
5008 error "$LFS find did not return an error"
5009 # Make a directory unsearchable. This should NOT be the last entry in
5010 # directory order. Arbitrarily pick the 6th entry
5011 chmod 700 $($LFS find $DIR/$tdir -type d | sed '6!d')
5012 local count=$($RUNAS $LFS find $DIR/non_existent $DIR/$tdir | wc -l)
5013 # The user should be able to see 10 directories and 9 files
5014 [ $count == 19 ] || error "$LFS find did not continue after error"
5016 run_test 56z "lfs find should continue after an error"
5018 test_56aa() { # LU-5937
5019 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
5022 $LFS setdirstripe -c$MDSCOUNT $DIR/$tdir/striped_dir
5024 createmany -o $DIR/$tdir/striped_dir/${tfile}- 1024
5025 local dirs=$(lfs find --size +8k $DIR/$tdir/)
5027 [ -n "$dirs" ] || error "lfs find --size wrong under striped dir"
5029 run_test 56aa "lfs find --size under striped dir"
5032 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5033 # note test will not do anything if MDS is not local
5034 if [ "$(facet_fstype $SINGLEMDS)" != ldiskfs ]; then
5035 skip "Only applicable to ldiskfs-based MDTs"
5039 remote_mds_nodsh && skip "remote MDS with nodsh" && return
5040 local MNTDEV="osd*.*MDT*.mntdev"
5041 DEV=$(do_facet $SINGLEMDS lctl get_param -n $MNTDEV)
5042 [ -z "$DEV" ] && error "can't access $MNTDEV"
5043 for DEV in $(do_facet $SINGLEMDS lctl get_param -n $MNTDEV); do
5044 do_facet $SINGLEMDS $DUMPE2FS -h $DEV > $TMP/t57a.dump ||
5045 error "can't access $DEV"
5046 DEVISIZE=$(awk '/Inode size:/ { print $3 }' $TMP/t57a.dump)
5047 [[ $DEVISIZE -gt 128 ]] || error "inode size $DEVISIZE"
5051 run_test 57a "verify MDS filesystem created with large inodes =="
5054 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5055 if [ "$(facet_fstype $SINGLEMDS)" != ldiskfs ]; then
5056 skip "Only applicable to ldiskfs-based MDTs"
5060 remote_mds_nodsh && skip "remote MDS with nodsh" && return
5061 local dir=$DIR/$tdir
5065 local FILEN=$dir/f$FILECOUNT
5067 rm -rf $dir || error "removing $dir"
5068 test_mkdir -p -c1 $dir || error "creating $dir"
5069 local mdtidx=$($LFS getstripe -M $dir)
5070 local mdtname=MDT$(printf %04x $mdtidx)
5071 local facet=mds$((mdtidx + 1))
5073 echo "mcreating $FILECOUNT files"
5074 createmany -m $dir/f 1 $FILECOUNT || \
5075 error "creating files in $dir"
5077 # verify that files do not have EAs yet
5078 $GETSTRIPE $FILE1 2>&1 | grep -q "no stripe" || error "$FILE1 has an EA"
5079 $GETSTRIPE $FILEN 2>&1 | grep -q "no stripe" || error "$FILEN has an EA"
5083 df $dir #make sure we get new statfs data
5084 local MDSFREE=$(do_facet $facet \
5085 lctl get_param -n osd*.*$mdtname.kbytesfree)
5086 local MDCFREE=$(lctl get_param -n mdc.*$mdtname-mdc-*.kbytesfree)
5087 echo "opening files to create objects/EAs"
5089 for FILE in `seq -f $dir/f%g 1 $FILECOUNT`; do
5090 $OPENFILE -f O_RDWR $FILE > /dev/null 2>&1 || error "opening $FILE"
5093 # verify that files have EAs now
5094 $GETSTRIPE $FILE1 | grep -q "obdidx" || error "$FILE1 missing EA"
5095 $GETSTRIPE $FILEN | grep -q "obdidx" || error "$FILEN missing EA"
5097 sleep 1 #make sure we get new statfs data
5099 local MDSFREE2=$(do_facet $facet \
5100 lctl get_param -n osd*.*$mdtname.kbytesfree)
5101 local MDCFREE2=$(lctl get_param -n mdc.*$mdtname-mdc-*.kbytesfree)
5102 if [[ $MDCFREE2 -lt $((MDCFREE - 16)) ]]; then
5103 if [ "$MDSFREE" != "$MDSFREE2" ]; then
5104 error "MDC before $MDCFREE != after $MDCFREE2"
5106 echo "MDC before $MDCFREE != after $MDCFREE2"
5107 echo "unable to confirm if MDS has large inodes"
5112 run_test 57b "default LOV EAs are stored inside large inodes ==="
5115 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5116 [ -z "$(which wiretest 2>/dev/null)" ] &&
5117 skip_env "could not find wiretest" && return
5120 run_test 58 "verify cross-platform wire constants =============="
5123 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5124 echo "touch 130 files"
5125 createmany -o $DIR/f59- 130
5127 unlinkmany $DIR/f59- 130
5129 # wait for commitment of removal
5130 wait_delete_completed
5132 run_test 59 "verify cancellation of llog records async ========="
5134 TEST60_HEAD="test_60 run $RANDOM"
5136 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5137 remote_mgs_nodsh && skip "remote MGS with nodsh" && return
5138 do_facet mgs "! which run-llog.sh &> /dev/null" &&
5139 do_facet mgs "! ls run-llog.sh &> /dev/null" &&
5140 skip_env "missing subtest run-llog.sh" && return
5142 log "$TEST60_HEAD - from kernel mode"
5143 do_facet mgs "$LCTL set_param debug=warning; $LCTL dk > /dev/null"
5144 do_facet mgs sh run-llog.sh
5145 do_facet mgs $LCTL dk > $TMP/$tfile
5147 # LU-6388: test llog_reader
5148 local llog_reader=$(do_facet mgs "which llog_reader 2> /dev/null")
5149 llog_reader=${llog_reader:-$LUSTRE/utils/llog_reader}
5150 [ -z $(do_facet mgs ls -d $llog_reader 2> /dev/null) ] &&
5151 skip_env "missing llog_reader" && return
5152 local fstype=$(facet_fstype mgs)
5153 [ $fstype != ldiskfs -a $fstype != zfs ] &&
5154 skip_env "Only for ldiskfs or zfs type mgs" && return
5156 local mntpt=$(facet_mntpt mgs)
5157 local mgsdev=$(mgsdevname 1)
5169 #get fid and record list
5170 fid_list=($(awk '/9_sub.*record/ { print $NF }' /$TMP/$tfile |
5172 rec_list=($(awk '/9_sub.*record/ { print $((NF-3)) }' /$TMP/$tfile |
5174 #remount mgs as ldiskfs or zfs type
5175 stop mgs || error "stop mgs failed"
5176 mount_fstype mgs || error "remount mgs failed"
5177 for ((i = 0; i < ${#fid_list[@]}; i++)); do
5180 seq=$(echo $fid | awk -F ':' '{ print $1 }' | sed -e "s/^0x//g")
5181 oid=$(echo $fid | awk -F ':' '{ print $2 }' | sed -e "s/^0x//g")
5186 obj_file=$mntpt/O/$seq/d$((oid%32))/$oid ;;
5188 obj_file=$mntpt/oi.$(($((16#$seq))&127))/$fid ;;
5190 echo "obj_file is $obj_file"
5191 do_facet mgs $llog_reader $obj_file
5193 rec_type=$(do_facet mgs $llog_reader $obj_file | grep "type=" |
5194 awk '{ print $3 }' | sed -e "s/^type=//g")
5195 if [ $rec_type != $rec ]; then
5196 echo "FAILED test_60a wrong record type $rec_type," \
5202 #check obj path if record type is LLOG_LOGID_MAGIC
5203 if [ "$rec" == "1064553b" ]; then
5204 path=$(do_facet mgs $llog_reader $obj_file |
5205 grep "path=" | awk '{ print $NF }' |
5206 sed -e "s/^path=//g")
5207 if [ $obj_file != $mntpt/$path ]; then
5208 echo "FAILED test_60a wrong obj path" \
5209 "$montpt/$path, should be $obj_file"
5216 #restart mgs before "error", otherwise it will block the next test
5217 stop mgs || error "stop mgs failed"
5218 start mgs $(mgsdevname) $MGS_MOUNT_OPTS || error "start mgs failed"
5219 $pass || error "test failed, see FAILED test_60a messages for specifics"
5221 run_test 60a "llog_test run from kernel module and test llog_reader =========="
5223 test_60b() { # bug 6411
5224 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5226 LLOG_COUNT=$(dmesg | awk "/$TEST60_HEAD/ { marker = 1; from_marker = 0; }
5238 [[ $LLOG_COUNT -gt 100 ]] &&
5239 error "CDEBUG_LIMIT not limiting messages ($LLOG_COUNT)" || true
5241 run_test 60b "limit repeated messages from CERROR/CWARN ========"
5244 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5245 echo "create 5000 files"
5246 createmany -o $DIR/f60c- 5000
5247 #define OBD_FAIL_MDS_LLOG_CREATE_FAILED 0x137
5248 lctl set_param fail_loc=0x80000137
5249 unlinkmany $DIR/f60c- 5000
5250 lctl set_param fail_loc=0
5252 run_test 60c "unlink file when mds full"
5255 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5256 SAVEPRINTK=$(lctl get_param -n printk)
5258 # verify "lctl mark" is even working"
5259 MESSAGE="test message ID $RANDOM $$"
5260 $LCTL mark "$MESSAGE" || error "$LCTL mark failed"
5261 dmesg | grep -q "$MESSAGE" || error "didn't find debug marker in log"
5263 lctl set_param printk=0 || error "set lnet.printk failed"
5264 lctl get_param -n printk | grep emerg || error "lnet.printk dropped emerg"
5265 MESSAGE="new test message ID $RANDOM $$"
5266 # Assume here that libcfs_debug_mark_buffer() uses D_WARNING
5267 $LCTL mark "$MESSAGE" || error "$LCTL mark failed"
5268 dmesg | grep -q "$MESSAGE" && error "D_WARNING wasn't masked" || true
5270 lctl set_param -n printk="$SAVEPRINTK"
5272 run_test 60d "test printk console message masking"
5275 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5277 #define OBD_FAIL_MDS_LLOG_CREATE_FAILED2 0x15b
5278 do_facet mds1 lctl set_param fail_loc=0x15b
5281 run_test 60e "no space while new llog is being created"
5284 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5286 dd if=/dev/zero of=$f bs=$(page_size) count=1 || error "dd $f failed"
5287 cancel_lru_locks osc
5288 $MULTIOP $f OSMWUc || error "$MULTIOP $f failed"
5291 run_test 61 "mmap() writes don't make sync hang ================"
5293 # bug 2330 - insufficient obd_match error checking causes LBUG
5295 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5298 cancel_lru_locks osc
5299 lctl set_param fail_loc=0x405
5300 cat $f && error "cat succeeded, expect -EIO"
5301 lctl set_param fail_loc=0
5303 # This test is now irrelevant (as of bug 10718 inclusion), we no longer
5304 # match every page all of the time.
5305 #run_test 62 "verify obd_match failure doesn't LBUG (should -EIO)"
5307 # bug 2319 - oig_wait() interrupted causes crash because of invalid waitq.
5308 # Though this test is irrelevant anymore, it helped to reveal some
5309 # other grant bugs (LU-4482), let's keep it.
5310 test_63a() { # was test_63
5311 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5312 MAX_DIRTY_MB=`lctl get_param -n osc.*.max_dirty_mb | head -n 1`
5313 for i in `seq 10` ; do
5314 dd if=/dev/zero of=$DIR/f63 bs=8k &
5320 rm -f $DIR/f63 || true
5322 run_test 63a "Verify oig_wait interruption does not crash ======="
5324 # bug 2248 - async write errors didn't return to application on sync
5325 # bug 3677 - async write errors left page locked
5327 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5329 lctl set_param debug=-1
5331 # ensure we have a grant to do async writes
5332 dd if=/dev/zero of=$DIR/$tfile bs=4k count=1
5335 sync # sync lest earlier test intercept the fail_loc
5337 #define OBD_FAIL_OSC_BRW_PREP_REQ 0x406
5338 lctl set_param fail_loc=0x80000406
5339 $MULTIOP $DIR/$tfile Owy && \
5340 error "sync didn't return ENOMEM"
5341 sync; sleep 2; sync # do a real sync this time to flush page
5342 lctl get_param -n llite.*.dump_page_cache | grep locked && \
5343 error "locked page left in cache after async error" || true
5346 run_test 63b "async write errors should be returned to fsync ==="
5349 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5351 lctl get_param -n osc.*[oO][sS][cC][_-]*.cur* | grep "[0-9]"
5353 run_test 64a "verify filter grant calculations (in kernel) ====="
5356 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5357 sh oos.sh $MOUNT || error "oos.sh failed: $?"
5359 run_test 64b "check out-of-space detection on client ==========="
5362 $LCTL set_param osc.*OST0000-osc-[^mM]*.cur_grant_bytes=0
5364 run_test 64c "verify grant shrink ========================------"
5366 # bug 1414 - set/get directories' stripe info
5368 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5369 test_mkdir -p $DIR/$tdir
5371 $LVERIFY $DIR/$tdir $DIR/$tdir/f1 || error "lverify failed"
5373 run_test 65a "directory with no stripe info ===================="
5376 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5377 test_mkdir -p $DIR/$tdir
5378 local STRIPESIZE=$($GETSTRIPE -S $DIR/$tdir)
5380 $SETSTRIPE -S $((STRIPESIZE * 2)) -i 0 -c 1 $DIR/$tdir ||
5383 $LVERIFY $DIR/$tdir $DIR/$tdir/f2 || error "lverify failed"
5385 run_test 65b "directory setstripe -S stripe_size*2 -i 0 -c 1"
5388 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5389 if [[ $OSTCOUNT -gt 1 ]]; then
5390 test_mkdir -p $DIR/$tdir
5391 local STRIPESIZE=$($GETSTRIPE -S $DIR/$tdir)
5393 $SETSTRIPE -S $(($STRIPESIZE * 4)) -i 1 \
5394 -c $(($OSTCOUNT - 1)) $DIR/$tdir || error "setstripe"
5396 $LVERIFY $DIR/$tdir $DIR/$tdir/f3 || error "lverify failed"
5399 run_test 65c "directory setstripe -S stripe_size*4 -i 1 -c $((OSTCOUNT-1))"
5402 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5403 test_mkdir -p $DIR/$tdir
5404 local STRIPECOUNT=$($GETSTRIPE -c $DIR/$tdir)
5405 local STRIPESIZE=$($GETSTRIPE -S $DIR/$tdir)
5407 if [[ $STRIPECOUNT -le 0 ]]; then
5409 elif [[ $STRIPECOUNT -gt 2000 ]]; then
5410 #LOV_MAX_STRIPE_COUNT is 2000
5411 [[ $OSTCOUNT -gt 2000 ]] && sc=2000 || sc=$(($OSTCOUNT - 1))
5413 sc=$(($STRIPECOUNT - 1))
5415 $SETSTRIPE -S $STRIPESIZE -c $sc $DIR/$tdir || error "setstripe"
5416 touch $DIR/$tdir/f4 $DIR/$tdir/f5
5417 $LVERIFY $DIR/$tdir $DIR/$tdir/f4 $DIR/$tdir/f5 ||
5418 error "lverify failed"
5420 run_test 65d "directory setstripe -S stripe_size -c stripe_count"
5423 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5424 test_mkdir -p $DIR/$tdir
5426 $SETSTRIPE $DIR/$tdir || error "setstripe"
5427 $GETSTRIPE -v $DIR/$tdir | grep "Default" ||
5428 error "no stripe info failed"
5430 $LVERIFY $DIR/$tdir $DIR/$tdir/f6 || error "lverify failed"
5432 run_test 65e "directory setstripe defaults ======================="
5435 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5436 test_mkdir -p $DIR/${tdir}f
5437 $RUNAS $SETSTRIPE $DIR/${tdir}f && error "setstripe succeeded" || true
5439 run_test 65f "dir setstripe permission (should return error) ==="
5442 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5443 test_mkdir -p $DIR/$tdir
5444 local STRIPESIZE=$($GETSTRIPE -S $DIR/$tdir)
5446 $SETSTRIPE -S $((STRIPESIZE * 2)) -i 0 -c 1 $DIR/$tdir ||
5448 $SETSTRIPE -d $DIR/$tdir || error "setstripe"
5449 $GETSTRIPE -v $DIR/$tdir | grep "Default" ||
5450 error "delete default stripe failed"
5452 run_test 65g "directory setstripe -d ==========================="
5455 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5456 test_mkdir -p $DIR/$tdir
5457 local STRIPESIZE=$($GETSTRIPE -S $DIR/$tdir)
5459 $SETSTRIPE -S $((STRIPESIZE * 2)) -i 0 -c 1 $DIR/$tdir ||
5461 test_mkdir -p $DIR/$tdir/dd1
5462 [ $($GETSTRIPE -c $DIR/$tdir) == $($GETSTRIPE -c $DIR/$tdir/dd1) ] ||
5463 error "stripe info inherit failed"
5465 run_test 65h "directory stripe info inherit ===================="
5467 test_65i() { # bug6367
5468 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5469 $SETSTRIPE -S 65536 -c -1 $MOUNT
5471 run_test 65i "set non-default striping on root directory (bug 6367)="
5473 test_65ia() { # bug12836
5474 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5475 $GETSTRIPE $MOUNT || error "getstripe $MOUNT failed"
5477 run_test 65ia "getstripe on -1 default directory striping"
5479 test_65ib() { # bug12836
5480 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5481 $GETSTRIPE -v $MOUNT || error "getstripe -v $MOUNT failed"
5483 run_test 65ib "getstripe -v on -1 default directory striping"
5485 test_65ic() { # bug12836
5486 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5487 $LFS find -mtime -1 $MOUNT > /dev/null || error "find $MOUNT failed"
5489 run_test 65ic "new find on -1 default directory striping"
5491 test_65j() { # bug6367
5492 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5494 # if we aren't already remounting for each test, do so for this test
5495 if [ "$CLEANUP" = ":" -a "$I_MOUNTED" = "yes" ]; then
5496 cleanup || error "failed to unmount"
5499 $SETSTRIPE -d $MOUNT || error "setstripe failed"
5501 run_test 65j "set default striping on root directory (bug 6367)="
5503 test_65k() { # bug11679
5504 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5505 [[ $OSTCOUNT -lt 2 ]] && skip_env "too few OSTs" && return
5506 remote_mds_nodsh && skip "remote MDS with nodsh" && return
5508 echo "Check OST status: "
5509 local MDS_OSCS=`do_facet $SINGLEMDS lctl dl |
5510 awk '/[oO][sS][cC].*md[ts]/ { print $4 }'`
5512 for OSC in $MDS_OSCS; do
5513 echo $OSC "is activate"
5514 do_facet $SINGLEMDS lctl --device %$OSC activate
5518 for INACTIVE_OSC in $MDS_OSCS; do
5519 echo "Deactivate: " $INACTIVE_OSC
5520 do_facet $SINGLEMDS lctl --device %$INACTIVE_OSC deactivate
5521 for STRIPE_OSC in $MDS_OSCS; do
5522 OST=`osc_to_ost $STRIPE_OSC`
5523 IDX=`do_facet $SINGLEMDS lctl get_param -n lov.*md*.target_obd |
5524 awk -F: /$OST/'{ print $1 }' | head -n 1`
5526 [ -f $DIR/$tdir/$IDX ] && continue
5527 echo "$SETSTRIPE -i $IDX -c 1 $DIR/$tdir/$IDX"
5528 $SETSTRIPE -i $IDX -c 1 $DIR/$tdir/$IDX
5530 [ $RC -ne 0 ] && error "setstripe should have succeeded"
5533 echo $INACTIVE_OSC "is Activate."
5534 do_facet $SINGLEMDS lctl --device %$INACTIVE_OSC activate
5537 run_test 65k "validate manual striping works properly with deactivated OSCs"
5539 test_65l() { # bug 12836
5540 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5541 test_mkdir -p $DIR/$tdir/test_dir
5542 $SETSTRIPE -c -1 $DIR/$tdir/test_dir
5543 $LFS find -mtime -1 $DIR/$tdir >/dev/null
5545 run_test 65l "lfs find on -1 stripe dir ========================"
5547 # bug 2543 - update blocks count on client
5549 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5551 dd if=/dev/zero of=$DIR/f66 bs=1k count=$COUNT
5552 sync; sync_all_data; sync; sync_all_data
5553 cancel_lru_locks osc
5554 BLOCKS=`ls -s $DIR/f66 | awk '{ print $1 }'`
5555 [ $BLOCKS -ge $COUNT ] || error "$DIR/f66 blocks $BLOCKS < $COUNT"
5557 run_test 66 "update inode blocks count on client ==============="
5562 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5564 if [ ! -z "$LLOOP" ]; then
5565 if swapon -s | grep -q $LLOOP; then
5566 swapoff $LLOOP || error "swapoff failed"
5569 $LCTL blockdev_detach $LLOOP || error "detach failed"
5573 if [ ! -z "$LLITELOOPLOAD" ]; then
5581 awk '($1 == "'$1':") { print $2 }' /proc/meminfo
5585 swapon -s | awk '($1 == "'$1'") { print $4 }'
5588 # test case for lloop driver, basic function
5590 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5591 [ "$UID" != 0 ] && skip_env "must run as root" && return
5592 llite_lloop_enabled || \
5593 { skip_env "llite_lloop module disabled" && return; }
5595 trap cleanup_68 EXIT
5597 if ! module_loaded llite_lloop; then
5598 if load_module llite/llite_lloop; then
5601 skip_env "can't find module llite_lloop"
5606 LLOOP=$TMP/lloop.`date +%s`.`date +%N`
5607 dd if=/dev/zero of=$DIR/f68a bs=4k count=1024
5608 $LCTL blockdev_attach $DIR/f68a $LLOOP || error "attach failed"
5610 directio rdwr $LLOOP 0 1024 4096 || error "direct write failed"
5611 directio rdwr $LLOOP 0 1025 4096 && error "direct write should fail"
5615 run_test 68a "lloop driver - basic test ========================"
5617 # excercise swapping to lustre by adding a high priority swapfile entry
5618 # and then consuming memory until it is used.
5619 test_68b() { # was test_68
5620 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5621 [ "$UID" != 0 ] && skip_env "must run as root" && return
5622 lctl get_param -n devices | grep -q obdfilter && \
5623 skip "local OST" && return
5625 grep -q llite_lloop /proc/modules
5626 [ $? -ne 0 ] && skip "can't find module llite_lloop" && return
5628 [ -z "`$LCTL list_nids | grep -v tcp`" ] && \
5629 skip "can't reliably test swap with TCP" && return
5631 MEMTOTAL=`meminfo MemTotal`
5632 NR_BLOCKS=$((MEMTOTAL>>8))
5633 [[ $NR_BLOCKS -le 2048 ]] && NR_BLOCKS=2048
5635 LLOOP=$TMP/lloop.`date +%s`.`date +%N`
5636 dd if=/dev/zero of=$DIR/f68b bs=64k seek=$NR_BLOCKS count=1
5639 $LCTL blockdev_attach $DIR/f68b $LLOOP || error "attach failed"
5641 trap cleanup_68 EXIT
5643 swapon -p 32767 $LLOOP || error "swapon $LLOOP failed"
5645 echo "before: `swapon -s | grep $LLOOP`"
5646 $MEMHOG $MEMTOTAL || error "error allocating $MEMTOTAL kB"
5647 echo "after: `swapon -s | grep $LLOOP`"
5648 SWAPUSED=`swap_used $LLOOP`
5652 [ $SWAPUSED -eq 0 ] && echo "no swap used???" || true
5654 run_test 68b "support swapping to Lustre ========================"
5656 # bug5265, obdfilter oa2dentry return -ENOENT
5657 # #define OBD_FAIL_SRV_ENOENT 0x217
5659 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5660 remote_ost_nodsh && skip "remote OST with nodsh" && return
5663 $SETSTRIPE -c 1 -i 0 $f
5665 $DIRECTIO write ${f}.2 0 1 || error "directio write error"
5667 do_facet ost1 lctl set_param fail_loc=0x217
5668 $TRUNCATE $f 1 # vmtruncate() will ignore truncate() error.
5669 $DIRECTIO write $f 0 2 && error "write succeeded, expect -ENOENT"
5671 do_facet ost1 lctl set_param fail_loc=0
5672 $DIRECTIO write $f 0 2 || error "write error"
5674 cancel_lru_locks osc
5675 $DIRECTIO read $f 0 1 || error "read error"
5677 do_facet ost1 lctl set_param fail_loc=0x217
5678 $DIRECTIO read $f 1 1 && error "read succeeded, expect -ENOENT"
5680 do_facet ost1 lctl set_param fail_loc=0
5683 run_test 69 "verify oa2dentry return -ENOENT doesn't LBUG ======"
5686 test_mkdir -p $DIR/$tdir
5687 $LFS setdirstripe -D -c$MDSCOUNT $DIR/$tdir
5688 sh rundbench -C -D $DIR/$tdir 2 || error "dbench failed!"
5690 run_test 71 "Running dbench on lustre (don't segment fault) ===="
5692 test_72a() { # bug 5695 - Test that on 2.6 remove_suid works properly
5693 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5694 [ "$RUNAS_ID" = "$UID" ] &&
5695 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
5697 # Check that testing environment is properly set up. Skip if not
5698 FAIL_ON_ERROR=false check_runas_id_ret $RUNAS_ID $RUNAS_GID $RUNAS || {
5699 skip_env "User $RUNAS_ID does not exist - skipping"
5703 chmod 777 $DIR/$tfile
5704 chmod ug+s $DIR/$tfile
5705 $RUNAS dd if=/dev/zero of=$DIR/$tfile bs=512 count=1 ||
5706 error "$RUNAS dd $DIR/$tfile failed"
5707 # See if we are still setuid/sgid
5708 test -u $DIR/$tfile -o -g $DIR/$tfile &&
5709 error "S/gid is not dropped on write"
5710 # Now test that MDS is updated too
5711 cancel_lru_locks mdc
5712 test -u $DIR/$tfile -o -g $DIR/$tfile &&
5713 error "S/gid is not dropped on MDS"
5716 run_test 72a "Test that remove suid works properly (bug5695) ===="
5718 test_72b() { # bug 24226 -- keep mode setting when size is not changing
5721 [ "$RUNAS_ID" = "$UID" ] && \
5722 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
5723 [ "$RUNAS_ID" -eq 0 ] && \
5724 skip_env "RUNAS_ID = 0 -- skipping" && return
5726 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5727 # Check that testing environment is properly set up. Skip if not
5728 FAIL_ON_ERROR=false check_runas_id_ret $RUNAS_ID $RUNAS_ID $RUNAS || {
5729 skip_env "User $RUNAS_ID does not exist - skipping"
5732 touch $DIR/${tfile}-f{g,u}
5733 test_mkdir $DIR/${tfile}-dg
5734 test_mkdir $DIR/${tfile}-du
5735 chmod 770 $DIR/${tfile}-{f,d}{g,u}
5736 chmod g+s $DIR/${tfile}-{f,d}g
5737 chmod u+s $DIR/${tfile}-{f,d}u
5738 for perm in 777 2777 4777; do
5739 $RUNAS chmod $perm $DIR/${tfile}-fg && error "S/gid file allowed improper chmod to $perm"
5740 $RUNAS chmod $perm $DIR/${tfile}-fu && error "S/uid file allowed improper chmod to $perm"
5741 $RUNAS chmod $perm $DIR/${tfile}-dg && error "S/gid dir allowed improper chmod to $perm"
5742 $RUNAS chmod $perm $DIR/${tfile}-du && error "S/uid dir allowed improper chmod to $perm"
5746 run_test 72b "Test that we keep mode setting if without file data changed (bug 24226)"
5748 # bug 3462 - multiple simultaneous MDC requests
5750 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5751 test_mkdir $DIR/d73-1
5752 test_mkdir $DIR/d73-2
5753 multiop_bg_pause $DIR/d73-1/f73-1 O_c || return 1
5756 lctl set_param fail_loc=0x80000129
5757 $MULTIOP $DIR/d73-1/f73-2 Oc &
5759 lctl set_param fail_loc=0
5761 $MULTIOP $DIR/d73-2/f73-3 Oc &
5765 wait $pid1 || return 1
5769 $CHECKSTAT -t file $DIR/d73-1/f73-1 || return 4
5770 $CHECKSTAT -t file $DIR/d73-1/f73-2 || return 5
5771 $CHECKSTAT -t file $DIR/d73-2/f73-3 || return 6
5775 run_test 73 "multiple MDC requests (should not deadlock)"
5777 test_74a() { # bug 6149, 6184
5778 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5779 #define OBD_FAIL_LDLM_ENQUEUE_OLD_EXPORT 0x30e
5781 # very important to OR with OBD_FAIL_ONCE (0x80000000) -- otherwise it
5782 # will spin in a tight reconnection loop
5784 $LCTL set_param fail_loc=0x8000030e
5785 # get any lock that won't be difficult - lookup works.
5787 $LCTL set_param fail_loc=0
5791 run_test 74a "ldlm_enqueue freed-export error path, ls (shouldn't LBUG)"
5793 test_74b() { # bug 13310
5794 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5795 #define OBD_FAIL_LDLM_ENQUEUE_OLD_EXPORT 0x30e
5797 # very important to OR with OBD_FAIL_ONCE (0x80000000) -- otherwise it
5798 # will spin in a tight reconnection loop
5799 $LCTL set_param fail_loc=0x8000030e
5800 # get a "difficult" lock
5802 $LCTL set_param fail_loc=0
5806 run_test 74b "ldlm_enqueue freed-export error path, touch (shouldn't LBUG)"
5809 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5810 #define OBD_FAIL_LDLM_NEW_LOCK
5811 $LCTL set_param fail_loc=0x319
5812 touch $DIR/$tfile && error "touch successful"
5813 $LCTL set_param fail_loc=0
5816 run_test 74c "ldlm_lock_create error path, (shouldn't LBUG)"
5819 awk '/lustre_inode_cache/ {print $2; exit}' /proc/slabinfo
5822 get_inode_slab_tunables() {
5823 awk '/lustre_inode_cache/ {print $9," ",$10," ",$11; exit}' /proc/slabinfo
5826 set_inode_slab_tunables() {
5827 echo "lustre_inode_cache $1" > /proc/slabinfo
5830 test_76() { # Now for bug 20433, added originally in bug 1443
5831 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5832 local SLAB_SETTINGS=`get_inode_slab_tunables`
5833 local CPUS=`getconf _NPROCESSORS_ONLN`
5834 # we cannot set limit below 1 which means 1 inode in each
5835 # per-cpu cache is still allowed
5836 set_inode_slab_tunables "1 1 0"
5837 cancel_lru_locks osc
5838 BEFORE_INODES=$(num_inodes)
5839 echo "before inodes: $BEFORE_INODES"
5841 [ "$SLOW" = "no" ] && COUNT=100
5842 for i in $(seq $COUNT); do
5846 cancel_lru_locks osc
5847 AFTER_INODES=$(num_inodes)
5848 echo "after inodes: $AFTER_INODES"
5850 while [[ $((AFTER_INODES-1*CPUS)) -gt $BEFORE_INODES ]]; do
5852 AFTER_INODES=$(num_inodes)
5854 echo "wait $wait seconds inodes: $AFTER_INODES"
5855 if [ $wait -gt 30 ]; then
5856 error "inode slab grew from $BEFORE_INODES to $AFTER_INODES"
5859 set_inode_slab_tunables "$SLAB_SETTINGS"
5861 run_test 76 "confirm clients recycle inodes properly ===="
5867 # Note: in sptlrpc modes which enable its own bulk checksum, the
5868 # original crc32_le bulk checksum will be automatically disabled,
5869 # and the OBD_FAIL_OSC_CHECKSUM_SEND/OBD_FAIL_OSC_CHECKSUM_RECEIVE
5870 # will be checked by sptlrpc code against sptlrpc bulk checksum.
5871 # In this case set_checksums() will not be no-op, because sptlrpc
5872 # bulk checksum will be enabled all through the test.
5874 [ "$ORIG_CSUM" ] || ORIG_CSUM=`lctl get_param -n osc.*.checksums | head -n1`
5875 lctl set_param -n osc.*.checksums $1
5879 export ORIG_CSUM_TYPE="`lctl get_param -n osc.*osc-[^mM]*.checksum_type |
5880 sed 's/.*\[\(.*\)\].*/\1/g' | head -n1`"
5881 CKSUM_TYPES=${CKSUM_TYPES:-"crc32 adler"}
5882 [ "$ORIG_CSUM_TYPE" = "crc32c" ] && CKSUM_TYPES="$CKSUM_TYPES crc32c"
5885 lctl set_param -n osc.*osc-[^mM]*.checksum_type $1
5886 log "set checksum type to $1"
5889 F77_TMP=$TMP/f77-temp
5892 dd if=/dev/urandom of=$F77_TMP bs=1M count=$F77SZ || \
5893 error "error writing to $F77_TMP"
5896 test_77a() { # bug 10889
5897 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5898 $GSS && skip "could not run with gss" && return
5899 [ ! -f $F77_TMP ] && setup_f77
5901 dd if=$F77_TMP of=$DIR/$tfile bs=1M count=$F77SZ || error "dd error"
5905 run_test 77a "normal checksum read/write operation"
5907 test_77b() { # bug 10889
5908 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5909 $GSS && skip "could not run with gss" && return
5910 [ ! -f $F77_TMP ] && setup_f77
5911 #define OBD_FAIL_OSC_CHECKSUM_SEND 0x409
5912 $LCTL set_param fail_loc=0x80000409
5915 dd if=$F77_TMP of=$DIR/$tfile bs=1M count=$F77SZ conv=sync ||
5916 error "dd error: $?"
5917 $LCTL set_param fail_loc=0
5919 for algo in $CKSUM_TYPES; do
5920 cancel_lru_locks osc
5921 set_checksum_type $algo
5922 #define OBD_FAIL_OSC_CHECKSUM_RECEIVE 0x408
5923 $LCTL set_param fail_loc=0x80000408
5924 cmp $F77_TMP $DIR/$tfile || error "file compare failed"
5925 $LCTL set_param fail_loc=0
5928 set_checksum_type $ORIG_CSUM_TYPE
5931 run_test 77b "checksum error on client write, read"
5933 test_77d() { # bug 10889
5934 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5935 $GSS && skip "could not run with gss" && return
5936 #define OBD_FAIL_OSC_CHECKSUM_SEND 0x409
5937 $LCTL set_param fail_loc=0x80000409
5939 $DIRECTIO write $DIR/$tfile 0 $F77SZ $((1024 * 1024)) ||
5940 error "direct write: rc=$?"
5941 $LCTL set_param fail_loc=0
5944 #define OBD_FAIL_OSC_CHECKSUM_RECEIVE 0x408
5945 $LCTL set_param fail_loc=0x80000408
5947 cancel_lru_locks osc
5948 $DIRECTIO read $DIR/$tfile 0 $F77SZ $((1024 * 1024)) ||
5949 error "direct read: rc=$?"
5950 $LCTL set_param fail_loc=0
5953 run_test 77d "checksum error on OST direct write, read"
5955 test_77f() { # bug 10889
5956 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5957 $GSS && skip "could not run with gss" && return
5959 for algo in $CKSUM_TYPES; do
5960 cancel_lru_locks osc
5961 set_checksum_type $algo
5962 #define OBD_FAIL_OSC_CHECKSUM_SEND 0x409
5963 $LCTL set_param fail_loc=0x409
5964 $DIRECTIO write $DIR/$tfile 0 $F77SZ $((1024 * 1024)) &&
5965 error "direct write succeeded"
5966 $LCTL set_param fail_loc=0
5968 set_checksum_type $ORIG_CSUM_TYPE
5971 run_test 77f "repeat checksum error on write (expect error)"
5973 test_77g() { # bug 10889
5974 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5975 $GSS && skip "could not run with gss" && return
5976 remote_ost_nodsh && skip "remote OST with nodsh" && return
5978 [ ! -f $F77_TMP ] && setup_f77
5980 $SETSTRIPE -c 1 -i 0 $DIR/$tfile
5981 #define OBD_FAIL_OST_CHECKSUM_RECEIVE 0x21a
5982 do_facet ost1 lctl set_param fail_loc=0x8000021a
5984 dd if=$F77_TMP of=$DIR/$tfile bs=1M count=$F77SZ ||
5985 error "write error: rc=$?"
5986 do_facet ost1 lctl set_param fail_loc=0
5989 cancel_lru_locks osc
5990 #define OBD_FAIL_OST_CHECKSUM_SEND 0x21b
5991 do_facet ost1 lctl set_param fail_loc=0x8000021b
5993 cmp $F77_TMP $DIR/$tfile || error "file compare failed"
5994 do_facet ost1 lctl set_param fail_loc=0
5997 run_test 77g "checksum error on OST write, read"
5999 test_77i() { # bug 13805
6000 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6001 $GSS && skip "could not run with gss" && return
6002 #define OBD_FAIL_OSC_CONNECT_CKSUM 0x40b
6003 lctl set_param fail_loc=0x40b
6004 remount_client $MOUNT
6005 lctl set_param fail_loc=0
6006 for VALUE in `lctl get_param osc.*osc-[^mM]*.checksum_type`; do
6007 PARAM=`echo ${VALUE[0]} | cut -d "=" -f1`
6008 algo=`lctl get_param -n $PARAM | sed 's/.*\[\(.*\)\].*/\1/g'`
6009 [ "$algo" = "adler" ] || error "algo set to $algo instead of adler"
6011 remount_client $MOUNT
6013 run_test 77i "client not supporting OSD_CONNECT_CKSUM"
6015 test_77j() { # bug 13805
6016 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6017 $GSS && skip "could not run with gss" && return
6018 #define OBD_FAIL_OSC_CKSUM_ADLER_ONLY 0x40c
6019 lctl set_param fail_loc=0x40c
6020 remount_client $MOUNT
6021 lctl set_param fail_loc=0
6022 sleep 2 # wait async osc connect to finish
6023 for VALUE in `lctl get_param osc.*osc-[^mM]*.checksum_type`; do
6024 PARAM=`echo ${VALUE[0]} | cut -d "=" -f1`
6025 algo=`lctl get_param -n $PARAM | sed 's/.*\[\(.*\)\].*/\1/g'`
6026 [ "$algo" = "adler" ] || error "algo set to $algo instead of adler"
6028 remount_client $MOUNT
6030 run_test 77j "client only supporting ADLER32"
6032 [ "$ORIG_CSUM" ] && set_checksums $ORIG_CSUM || true
6036 test_78() { # bug 10901
6037 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6038 remote_ost || { skip_env "local OST" && return; }
6041 F78SIZE=$(($(awk '/MemFree:/ { print $2 }' /proc/meminfo) / 1024))
6042 echo "MemFree: $F78SIZE, Max file size: $MAXFREE"
6043 MEMTOTAL=$(($(awk '/MemTotal:/ { print $2 }' /proc/meminfo) / 1024))
6044 echo "MemTotal: $MEMTOTAL"
6046 # reserve 256MB of memory for the kernel and other running processes,
6047 # and then take 1/2 of the remaining memory for the read/write buffers.
6048 if [ $MEMTOTAL -gt 512 ] ;then
6049 MEMTOTAL=$(((MEMTOTAL - 256 ) / 2))
6051 # for those poor memory-starved high-end clusters...
6052 MEMTOTAL=$((MEMTOTAL / 2))
6054 echo "Mem to use for directio: $MEMTOTAL"
6056 [[ $F78SIZE -gt $MEMTOTAL ]] && F78SIZE=$MEMTOTAL
6057 [[ $F78SIZE -gt 512 ]] && F78SIZE=512
6058 [[ $F78SIZE -gt $((MAXFREE / 1024)) ]] && F78SIZE=$((MAXFREE / 1024))
6059 SMALLESTOST=$($LFS df $DIR | grep OST | awk '{ print $4 }' | sort -n |
6061 echo "Smallest OST: $SMALLESTOST"
6062 [[ $SMALLESTOST -lt 10240 ]] &&
6063 skip "too small OSTSIZE, useless to run large O_DIRECT test" && return 0
6065 [[ $F78SIZE -gt $((SMALLESTOST * $OSTCOUNT / 1024 - 80)) ]] &&
6066 F78SIZE=$((SMALLESTOST * $OSTCOUNT / 1024 - 80))
6068 [ "$SLOW" = "no" ] && NSEQ=1 && [ $F78SIZE -gt 32 ] && F78SIZE=32
6069 echo "File size: $F78SIZE"
6070 $SETSTRIPE -c $OSTCOUNT $DIR/$tfile || error "setstripe failed"
6071 for i in $(seq 1 $NSEQ); do
6072 FSIZE=$(($F78SIZE / ($NSEQ - $i + 1)))
6073 echo directIO rdwr round $i of $NSEQ
6074 $DIRECTIO rdwr $DIR/$tfile 0 $FSIZE 1048576||error "rdwr failed"
6079 run_test 78 "handle large O_DIRECT writes correctly ============"
6081 test_79() { # bug 12743
6082 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6083 wait_delete_completed
6085 BKTOTAL=$(calc_osc_kbytes kbytestotal)
6086 BKFREE=$(calc_osc_kbytes kbytesfree)
6087 BKAVAIL=$(calc_osc_kbytes kbytesavail)
6089 STRING=`df -P $MOUNT | tail -n 1 | awk '{print $2","$3","$4}'`
6090 DFTOTAL=`echo $STRING | cut -d, -f1`
6091 DFUSED=`echo $STRING | cut -d, -f2`
6092 DFAVAIL=`echo $STRING | cut -d, -f3`
6093 DFFREE=$(($DFTOTAL - $DFUSED))
6095 ALLOWANCE=$((64 * $OSTCOUNT))
6097 if [ $DFTOTAL -lt $(($BKTOTAL - $ALLOWANCE)) ] ||
6098 [ $DFTOTAL -gt $(($BKTOTAL + $ALLOWANCE)) ] ; then
6099 error "df total($DFTOTAL) mismatch OST total($BKTOTAL)"
6101 if [ $DFFREE -lt $(($BKFREE - $ALLOWANCE)) ] ||
6102 [ $DFFREE -gt $(($BKFREE + $ALLOWANCE)) ] ; then
6103 error "df free($DFFREE) mismatch OST free($BKFREE)"
6105 if [ $DFAVAIL -lt $(($BKAVAIL - $ALLOWANCE)) ] ||
6106 [ $DFAVAIL -gt $(($BKAVAIL + $ALLOWANCE)) ] ; then
6107 error "df avail($DFAVAIL) mismatch OST avail($BKAVAIL)"
6110 run_test 79 "df report consistency check ======================="
6112 test_80() { # bug 10718
6113 remote_ost_nodsh && skip "remote OST with nodsh" && return
6114 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6115 # relax strong synchronous semantics for slow backends like ZFS
6116 local soc="obdfilter.*.sync_on_lock_cancel"
6117 local soc_old=$(do_facet ost1 lctl get_param -n $soc | head -n1)
6119 if [ "$soc_old" != "never" -a "$(facet_fstype ost1)" != "ldiskfs" ]; then
6120 hosts=$(for host in $(seq -f "ost%g" 1 $OSTCOUNT); do
6121 facet_active_host $host; done | sort -u)
6122 do_nodes $hosts lctl set_param $soc=never
6125 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=1M
6127 local BEFORE=`date +%s`
6128 cancel_lru_locks osc
6129 local AFTER=`date +%s`
6130 local DIFF=$((AFTER-BEFORE))
6131 if [ $DIFF -gt 1 ] ; then
6132 error "elapsed for 1M@1T = $DIFF"
6135 [ -n "$hosts" ] && do_nodes $hosts lctl set_param $soc=$soc_old
6139 run_test 80 "Page eviction is equally fast at high offsets too ===="
6141 test_81a() { # LU-456
6142 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6143 remote_ost_nodsh && skip "remote OST with nodsh" && return
6144 # define OBD_FAIL_OST_MAPBLK_ENOSPC 0x228
6145 # MUST OR with the OBD_FAIL_ONCE (0x80000000)
6146 do_facet ost1 lctl set_param fail_loc=0x80000228
6148 # write should trigger a retry and success
6149 $SETSTRIPE -i 0 -c 1 $DIR/$tfile
6150 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
6152 if [ $RC -ne 0 ] ; then
6153 error "write should success, but failed for $RC"
6156 run_test 81a "OST should retry write when get -ENOSPC ==============="
6158 test_81b() { # LU-456
6159 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6160 remote_ost_nodsh && skip "remote OST with nodsh" && return
6161 # define OBD_FAIL_OST_MAPBLK_ENOSPC 0x228
6162 # Don't OR with the OBD_FAIL_ONCE (0x80000000)
6163 do_facet ost1 lctl set_param fail_loc=0x228
6165 # write should retry several times and return -ENOSPC finally
6166 $SETSTRIPE -i 0 -c 1 $DIR/$tfile
6167 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
6170 if [ $RC -ne $ENOSPC ] ; then
6171 error "dd should fail for -ENOSPC, but succeed."
6174 run_test 81b "OST should return -ENOSPC when retry still fails ======="
6176 test_82() { # LU-1031
6177 dd if=/dev/zero of=$DIR/$tfile bs=1M count=10
6181 multiop_bg_pause $DIR/$tfile OG${gid1}_g${gid1}c || return 1
6183 multiop_bg_pause $DIR/$tfile O_G${gid2}r10g${gid2}c || return 2
6185 kill -USR1 $MULTIPID2
6187 if [[ `ps h -o comm -p $MULTIPID2` == "" ]]; then
6188 error "First grouplock does not block second one"
6190 echo "Second grouplock blocks first one"
6192 kill -USR1 $MULTIPID1
6196 run_test 82 "Basic grouplock test ==============================="
6199 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" &&
6201 test_mkdir -p $DIR/d99cvsroot
6202 chown $RUNAS_ID $DIR/d99cvsroot
6203 local oldPWD=$PWD # bug 13584, use $TMP as working dir
6206 $RUNAS cvs -d $DIR/d99cvsroot init || error "cvs init failed"
6209 run_test 99a "cvs init ========================================="
6212 [ -z "$(which cvs 2>/dev/null)" ] &&
6213 skip_env "could not find cvs" && return
6214 [ ! -d $DIR/d99cvsroot ] && test_99a
6216 # some versions of cvs import exit(1) when asked to import links or
6217 # files they can't read. ignore those files.
6218 TOIGNORE=$(find . -type l -printf '-I %f\n' -o \
6219 ! -perm /4 -printf '-I %f\n')
6220 $RUNAS cvs -d $DIR/d99cvsroot import -m "nomesg" $TOIGNORE \
6221 d99reposname vtag rtag
6223 run_test 99b "cvs import ======================================="
6226 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" && return
6227 [ ! -d $DIR/d99cvsroot ] && test_99b
6229 test_mkdir -p $DIR/d99reposname
6230 chown $RUNAS_ID $DIR/d99reposname
6231 $RUNAS cvs -d $DIR/d99cvsroot co d99reposname
6233 run_test 99c "cvs checkout ====================================="
6236 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" && return
6237 [ ! -d $DIR/d99cvsroot ] && test_99c
6238 cd $DIR/d99reposname
6240 $RUNAS cvs add -m 'addmsg' foo99
6242 run_test 99d "cvs add =========================================="
6245 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" && return
6246 [ ! -d $DIR/d99cvsroot ] && test_99c
6247 cd $DIR/d99reposname
6250 run_test 99e "cvs update ======================================="
6253 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" && return
6254 [ ! -d $DIR/d99cvsroot ] && test_99d
6255 cd $DIR/d99reposname
6256 $RUNAS cvs commit -m 'nomsg' foo99
6257 rm -fr $DIR/d99cvsroot
6259 run_test 99f "cvs commit ======================================="
6262 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6263 [ "$NETTYPE" = tcp ] || \
6264 { skip "TCP secure port test, not useful for NETTYPE=$NETTYPE" && \
6267 remote_ost_nodsh && skip "remote OST with nodsh" && return
6268 remote_mds_nodsh && skip "remote MDS with nodsh" && return
6270 { skip "useless for local single node setup" && return; }
6272 netstat -tna | ( rc=1; while read PROT SND RCV LOCAL REMOTE STAT; do
6273 [ "$PROT" != "tcp" ] && continue
6274 RPORT=$(echo $REMOTE | cut -d: -f2)
6275 [ "$RPORT" != "$ACCEPTOR_PORT" ] && continue
6278 LPORT=`echo $LOCAL | cut -d: -f2`
6279 if [ $LPORT -ge 1024 ]; then
6280 echo "bad: $PROT $SND $RCV $LOCAL $REMOTE $STAT"
6282 error_exit "local: $LPORT > 1024, remote: $RPORT"
6285 [ "$rc" = 0 ] || error_exit "privileged port not found" )
6287 run_test 100 "check local port using privileged port ==========="
6289 function get_named_value()
6298 echo $line | sed "s/^$tag[ ]*//"
6305 export CACHE_MAX=$($LCTL get_param -n llite.*.max_cached_mb |
6306 awk '/^max_cached_mb/ { print $2 }')
6309 $LCTL set_param -n llite.*.max_cached_mb $CACHE_MAX
6314 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6315 [ $MDSCOUNT -ge 2 ] && skip "skip now for >= 2 MDTs" && return #LU-4322
6319 local cache_limit=32
6321 $LCTL set_param -n osc.*-osc*.rpc_stats 0
6322 trap cleanup_101a EXIT
6323 $LCTL set_param -n llite.*.read_ahead_stats 0
6324 $LCTL set_param -n llite.*.max_cached_mb $cache_limit
6327 # randomly read 10000 of 64K chunks from file 3x 32MB in size
6329 echo "nreads: $nreads file size: $((cache_limit * 3))MB"
6330 $READS -f $DIR/$tfile -s$((cache_limit * 3192 * 1024)) -b65536 -C -n$nreads -t 180
6333 for s in $($LCTL get_param -n llite.*.read_ahead_stats |
6334 get_named_value 'read but discarded' | cut -d" " -f1); do
6335 discard=$(($discard + $s))
6339 if [[ $(($discard * 10)) -gt $nreads ]]; then
6340 $LCTL get_param osc.*-osc*.rpc_stats
6341 $LCTL get_param llite.*.read_ahead_stats
6342 error "too many ($discard) discarded pages"
6344 rm -f $DIR/$tfile || true
6346 run_test 101a "check read-ahead for random reads ================"
6349 test_mkdir -p $DIR/$tdir
6350 local STRIPE_SIZE=$1
6351 local FILE_LENGTH=$2
6354 local FILE_SIZE_MB=$((FILE_LENGTH / STRIPE_SIZE))
6356 local list=$(comma_list $(osts_nodes))
6357 set_osd_param $list '' read_cache_enable 0
6358 set_osd_param $list '' writethrough_cache_enable 0
6360 trap cleanup_test101bc EXIT
6361 # prepare the read-ahead file
6362 $SETSTRIPE -S $STRIPE_SIZE -i $STRIPE_OFFSET -c $OSTCOUNT $DIR/$tfile
6364 dd if=/dev/zero of=$DIR/$tfile bs=$STRIPE_SIZE \
6365 count=$FILE_SIZE_MB 2> /dev/null
6369 cleanup_test101bc() {
6374 local list=$(comma_list $(osts_nodes))
6375 set_osd_param $list '' read_cache_enable 1
6376 set_osd_param $list '' writethrough_cache_enable 1
6380 awk 'BEGIN{total=0}; {total+=$1}; END{print total}'
6385 local STRIPE_SIZE=$2
6386 local FILE_LENGTH=$3
6387 local RA_INC=1048576
6388 local STRIDE_LENGTH=$((STRIPE_SIZE/READ_SIZE))
6389 local discard_limit=$((((STRIDE_LENGTH - 1)*3/(STRIDE_LENGTH*OSTCOUNT))* \
6390 (STRIDE_LENGTH*OSTCOUNT - STRIDE_LENGTH)))
6391 DISCARD=$($LCTL get_param -n llite.*.read_ahead_stats |
6392 get_named_value 'read but discarded' |
6393 cut -d" " -f1 | calc_total)
6394 if [[ $DISCARD -gt $discard_limit ]]; then
6395 $LCTL get_param llite.*.read_ahead_stats
6396 error "Too many ($DISCARD) discarded pages with size (${READ_SIZE})"
6398 echo "Read-ahead success for size ${READ_SIZE}"
6403 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6404 [[ $OSTCOUNT -lt 2 ]] &&
6405 skip_env "skipping stride IO stride-ahead test" && return
6406 local STRIPE_SIZE=1048576
6407 local STRIDE_SIZE=$((STRIPE_SIZE*OSTCOUNT))
6408 if [ $SLOW == "yes" ]; then
6409 local FILE_LENGTH=$((STRIDE_SIZE * 64))
6411 local FILE_LENGTH=$((STRIDE_SIZE * 8))
6414 local ITERATION=$((FILE_LENGTH / STRIDE_SIZE))
6416 # prepare the read-ahead file
6417 setup_test101bc $STRIPE_SIZE $FILE_LENGTH
6418 cancel_lru_locks osc
6419 for BIDX in 2 4 8 16 32 64 128 256
6421 local BSIZE=$((BIDX*4096))
6422 local READ_COUNT=$((STRIPE_SIZE/BSIZE))
6423 local STRIDE_LENGTH=$((STRIDE_SIZE/BSIZE))
6424 local OFFSET=$((STRIPE_SIZE/BSIZE*(OSTCOUNT - 1)))
6425 $LCTL set_param -n llite.*.read_ahead_stats 0
6426 $READS -f $DIR/$tfile -l $STRIDE_LENGTH -o $OFFSET \
6427 -s $FILE_LENGTH -b $STRIPE_SIZE -a $READ_COUNT -n $ITERATION
6428 cancel_lru_locks osc
6429 ra_check_101 $BSIZE $STRIPE_SIZE $FILE_LENGTH
6434 run_test 101b "check stride-io mode read-ahead ================="
6437 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6438 local STRIPE_SIZE=1048576
6439 local FILE_LENGTH=$((STRIPE_SIZE*100))
6443 setup_test101bc $STRIPE_SIZE $FILE_LENGTH
6445 cancel_lru_locks osc
6446 $LCTL set_param osc.*.rpc_stats 0
6447 $READS -f $DIR/$tfile -s$FILE_LENGTH -b65536 -n$nreads -t 180
6448 for osc_rpc_stats in $($LCTL get_param -N osc.*.rpc_stats); do
6449 local stats=$($LCTL get_param -n $osc_rpc_stats)
6450 local lines=$(echo "$stats" | awk 'END {print NR;}')
6453 if [ $lines -le 20 ]; then
6456 for size in 1 2 4 8; do
6457 local rpc=$(echo "$stats" |
6458 awk '($1 == "'$size':") {print $2; exit; }')
6460 error "Small $((size*4))k read IO $rpc !"
6462 echo "$osc_rpc_stats check passed!"
6467 run_test 101c "check stripe_size aligned read-ahead ================="
6470 $LCTL get_param -n llite.*.max_read_ahead_mb | head -n 1
6471 $LCTL set_param -n llite.*.max_read_ahead_mb $1 > /dev/null 2>&1
6475 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6476 local file=$DIR/$tfile
6477 local sz_MB=${FILESIZE_101d:-500}
6478 local ra_MB=${READAHEAD_MB:-40}
6480 local free_MB=$(($(df -P $DIR | tail -n 1 | awk '{ print $4 }') / 1024))
6481 [ $free_MB -lt $sz_MB ] &&
6482 skip "Need free space ${sz_MB}M, have ${free_MB}M" && return
6484 echo "Create test file $file size ${sz_MB}M, ${free_MB}M free"
6485 $SETSTRIPE -c -1 $file || error "setstripe failed"
6487 dd if=/dev/zero of=$file bs=1M count=$sz_MB || error "dd failed"
6488 echo Cancel LRU locks on lustre client to flush the client cache
6489 cancel_lru_locks osc
6491 echo Disable read-ahead
6492 local old_READAHEAD=$(set_read_ahead 0)
6494 echo Reading the test file $file with read-ahead disabled
6495 local raOFF=$(do_and_time "dd if=$file of=/dev/null bs=1M count=$sz_MB")
6497 echo Cancel LRU locks on lustre client to flush the client cache
6498 cancel_lru_locks osc
6499 echo Enable read-ahead with ${ra_MB}MB
6500 set_read_ahead $ra_MB
6502 echo Reading the test file $file with read-ahead enabled
6503 local raON=$(do_and_time "dd if=$file of=/dev/null bs=1M count=$sz_MB")
6505 echo "read-ahead disabled time read $raOFF"
6506 echo "read-ahead enabled time read $raON"
6508 set_read_ahead $old_READAHEAD
6510 wait_delete_completed
6512 [ $raOFF -le 1 -o $raON -lt $raOFF ] ||
6513 error "readahead ${raON}s > no-readahead ${raOFF}s ${sz_MB}M"
6515 run_test 101d "file read with and without read-ahead enabled"
6518 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6519 local file=$DIR/$tfile
6520 local size_KB=500 #KB
6524 local free_KB=$(df -P $DIR | tail -n 1 | awk '{ print $4 }')
6525 local need_KB=$((count * size_KB))
6526 [[ $free_KB -le $need_KB ]] &&
6527 skip_env "Need free space $need_KB, have $free_KB" && return
6529 echo "Creating $count ${size_KB}K test files"
6530 for ((i = 0; i < $count; i++)); do
6531 dd if=/dev/zero of=$file.$i bs=$bsize count=$size_KB 2>/dev/null
6534 echo "Cancel LRU locks on lustre client to flush the client cache"
6535 cancel_lru_locks osc
6537 echo "Reset readahead stats"
6538 $LCTL set_param -n llite.*.read_ahead_stats 0
6540 for ((i = 0; i < $count; i++)); do
6541 dd if=$file.$i of=/dev/null bs=$bsize count=$size_KB 2>/dev/null
6544 local miss=$($LCTL get_param -n llite.*.read_ahead_stats |
6545 get_named_value 'misses' | cut -d" " -f1 | calc_total)
6547 for ((i = 0; i < $count; i++)); do
6548 rm -rf $file.$i 2>/dev/null
6551 #10000 means 20% reads are missing in readahead
6552 [[ $miss -lt 10000 ]] || error "misses too much for small reads"
6554 run_test 101e "check read-ahead for small read(1k) for small files(500k)"
6557 which iozone || { skip "no iozone installed" && return; }
6559 # create a test file
6560 iozone -i 0 -+n -r 1m -s 128m -w -f $DIR/$tfile > /dev/null 2>&1
6562 echo Cancel LRU locks on lustre client to flush the client cache
6563 cancel_lru_locks osc
6565 echo Reset readahead stats
6566 $LCTL set_param -n llite.*.read_ahead_stats 0
6568 echo mmap read the file with small block size
6569 iozone -i 1 -+n -r 32k -s 128m -B -f $DIR/$tfile > /dev/null 2>&1
6571 echo checking missing pages
6572 local miss=$($LCTL get_param -n llite.*.read_ahead_stats |
6573 get_named_value 'misses' | cut -d" " -f1 | calc_total)
6575 [ $miss -lt 3 ] || error "misses too much pages!"
6578 run_test 101f "check mmap read performance"
6581 test_mkdir -p $DIR/$tdir
6582 chown $RUNAS_ID $DIR/$tdir
6585 STRIPE_COUNT=$OSTCOUNT
6586 [[ $OSTCOUNT -gt 4 ]] && STRIPE_COUNT=4
6588 trap cleanup_test102 EXIT
6590 $1 $SETSTRIPE -S $STRIPE_SIZE -i $STRIPE_OFFSET -c $STRIPE_COUNT $tdir
6592 for num in 1 2 3 4; do
6593 for count in $(seq 1 $STRIPE_COUNT); do
6594 for idx in $(seq 0 $[$STRIPE_COUNT - 1]); do
6595 local size=`expr $STRIPE_SIZE \* $num`
6596 local file=file"$num-$idx-$count"
6597 $1 $SETSTRIPE -S $size -i $idx -c $count $file
6603 $1 $TAR cf $TMP/f102.tar $tdir --xattrs
6609 rm -rf $DIR/d0.sanity/d102
6613 local testfile=$DIR/$tfile
6617 [ "$UID" != 0 ] && skip_env "must run as root" && return
6618 [ -z "$(lctl get_param -n mdc.*-mdc-*.connect_flags | grep xattr)" ] &&
6619 skip_env "must have user_xattr" && return
6621 [ -z "$(which setfattr 2>/dev/null)" ] &&
6622 skip_env "could not find setfattr" && return
6624 echo "set/get xattr..."
6625 setfattr -n trusted.name1 -v value1 $testfile ||
6626 error "setfattr -n trusted.name1=value1 $testfile failed"
6627 getfattr -n trusted.name1 $testfile 2> /dev/null |
6628 grep "trusted.name1=.value1" ||
6629 error "$testfile missing trusted.name1=value1"
6631 setfattr -n user.author1 -v author1 $testfile ||
6632 error "setfattr -n user.author1=author1 $testfile failed"
6633 getfattr -n user.author1 $testfile 2> /dev/null |
6634 grep "user.author1=.author1" ||
6635 error "$testfile missing trusted.author1=author1"
6638 setfattr -n trusted.name2 -v value2 $testfile ||
6639 error "$testfile unable to set trusted.name2"
6640 setfattr -n trusted.name3 -v value3 $testfile ||
6641 error "$testfile unable to set trusted.name3"
6642 [ $(getfattr -d -m "^trusted" $testfile 2> /dev/null |
6643 grep "trusted.name" | wc -l) -eq 3 ] ||
6644 error "$testfile missing 3 trusted.name xattrs"
6646 setfattr -n user.author2 -v author2 $testfile ||
6647 error "$testfile unable to set user.author2"
6648 setfattr -n user.author3 -v author3 $testfile ||
6649 error "$testfile unable to set user.author3"
6650 [ $(getfattr -d -m "^user" $testfile 2> /dev/null |
6651 grep "user.author" | wc -l) -eq 3 ] ||
6652 error "$testfile missing 3 user.author xattrs"
6654 echo "remove xattr..."
6655 setfattr -x trusted.name1 $testfile ||
6656 error "$testfile error deleting trusted.name1"
6657 getfattr -d -m trusted $testfile 2> /dev/null | grep "trusted.name1" &&
6658 error "$testfile did not delete trusted.name1 xattr"
6660 setfattr -x user.author1 $testfile ||
6661 error "$testfile error deleting user.author1"
6662 getfattr -d -m user $testfile 2> /dev/null | grep "user.author1" &&
6663 error "$testfile did not delete trusted.name1 xattr"
6665 # b10667: setting lustre special xattr be silently discarded
6666 echo "set lustre special xattr ..."
6667 setfattr -n "trusted.lov" -v "invalid value" $testfile ||
6668 error "$testfile allowed setting trusted.lov"
6670 run_test 102a "user xattr test =================================="
6673 [ -z "$(which setfattr 2>/dev/null)" ] &&
6674 skip_env "could not find setfattr" && return
6676 # b10930: get/set/list trusted.lov xattr
6677 echo "get/set/list trusted.lov xattr ..."
6678 [[ $OSTCOUNT -lt 2 ]] && skip_env "skipping 2-stripe test" && return
6679 local testfile=$DIR/$tfile
6680 $SETSTRIPE -S 65536 -i 1 -c $OSTCOUNT $testfile ||
6681 error "setstripe failed"
6682 local STRIPECOUNT=$($GETSTRIPE -c $testfile) ||
6683 error "getstripe failed"
6684 getfattr -d -m "^trusted" $testfile 2>/dev/null | grep "trusted.lov" ||
6685 error "can't get trusted.lov from $testfile"
6687 local testfile2=${testfile}2
6688 local value=$(getfattr -n trusted.lov $testfile 2>/dev/null |
6689 grep "trusted.lov" | sed -e 's/[^=]\+=//')
6692 setfattr -n trusted.lov -v $value $testfile2
6693 local stripe_size=$($GETSTRIPE -S $testfile2)
6694 local stripe_count=$($GETSTRIPE -c $testfile2)
6695 [[ $stripe_size -eq 65536 ]] ||
6696 error "stripe size $stripe_size != 65536"
6697 [[ $stripe_count -eq $STRIPECOUNT ]] ||
6698 error "stripe count $stripe_count != $STRIPECOUNT"
6701 run_test 102b "getfattr/setfattr for trusted.lov EAs ============"
6704 [ -z "$(which setfattr 2>/dev/null)" ] &&
6705 skip_env "could not find setfattr" && return
6707 # b10930: get/set/list lustre.lov xattr
6708 echo "get/set/list lustre.lov xattr ..."
6709 [[ $OSTCOUNT -lt 2 ]] && skip_env "skipping 2-stripe test" && return
6710 test_mkdir -p $DIR/$tdir
6711 chown $RUNAS_ID $DIR/$tdir
6712 local testfile=$DIR/$tdir/$tfile
6713 $RUNAS $SETSTRIPE -S 65536 -i 1 -c $OSTCOUNT $testfile ||
6714 error "setstripe failed"
6715 local STRIPECOUNT=$($RUNAS $GETSTRIPE -c $testfile) ||
6716 error "getstripe failed"
6717 $RUNAS getfattr -d -m "^lustre" $testfile 2> /dev/null | \
6718 grep "lustre.lov" || error "can't get lustre.lov from $testfile"
6720 local testfile2=${testfile}2
6721 local value=`getfattr -n lustre.lov $testfile 2> /dev/null | \
6722 grep "lustre.lov" |sed -e 's/[^=]\+=//' `
6724 $RUNAS $MCREATE $testfile2
6725 $RUNAS setfattr -n lustre.lov -v $value $testfile2
6726 local stripe_size=$($RUNAS $GETSTRIPE -S $testfile2)
6727 local stripe_count=$($RUNAS $GETSTRIPE -c $testfile2)
6728 [ $stripe_size -eq 65536 ] || error "stripe size $stripe_size != 65536"
6729 [ $stripe_count -eq $STRIPECOUNT ] ||
6730 error "stripe count $stripe_count != $STRIPECOUNT"
6732 run_test 102c "non-root getfattr/setfattr for lustre.lov EAs ==========="
6734 compare_stripe_info1() {
6735 local stripe_index_all_zero=true
6737 for num in 1 2 3 4; do
6738 for count in $(seq 1 $STRIPE_COUNT); do
6739 for offset in $(seq 0 $[$STRIPE_COUNT - 1]); do
6740 local size=$((STRIPE_SIZE * num))
6741 local file=file"$num-$offset-$count"
6742 stripe_size=$($LFS getstripe -S $PWD/$file)
6743 [[ $stripe_size -ne $size ]] &&
6744 error "$file: size $stripe_size != $size"
6745 stripe_count=$($LFS getstripe -c $PWD/$file)
6746 # allow fewer stripes to be created, ORI-601
6747 [[ $stripe_count -lt $(((3 * count + 3) / 4)) ]] &&
6748 error "$file: count $stripe_count != $count"
6749 stripe_index=$($LFS getstripe -i $PWD/$file)
6750 [[ $stripe_index -ne 0 ]] &&
6751 stripe_index_all_zero=false
6755 $stripe_index_all_zero &&
6756 error "all files are being extracted starting from OST index 0"
6761 [ -n "$(which tar 2>/dev/null)" ] &&
6762 strings $(which tar) | grep -q "lustre" && echo tar
6766 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6767 # b10930: tar test for trusted.lov xattr
6768 TAR=$(find_lustre_tar)
6769 [ -z "$TAR" ] && skip_env "lustre-aware tar is not installed" && return
6770 [[ $OSTCOUNT -lt 2 ]] && skip_env "skipping N-stripe test" && return
6772 test_mkdir -p $DIR/d102d
6773 $TAR xf $TMP/f102.tar -C $DIR/d102d --xattrs
6775 compare_stripe_info1
6777 run_test 102d "tar restore stripe info from tarfile,not keep osts ==========="
6780 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6781 # b10930: tar test for trusted.lov xattr
6782 TAR=$(find_lustre_tar)
6783 [ -z "$TAR" ] && skip_env "lustre-aware tar is not installed" && return
6784 [[ $OSTCOUNT -lt 2 ]] && skip_env "skipping N-stripe test" && return
6786 test_mkdir -p $DIR/d102f
6788 $TAR cf - --xattrs $tdir | $TAR xf - --xattrs -C $DIR/d102f
6790 compare_stripe_info1
6792 run_test 102f "tar copy files, not keep osts ==========="
6795 local xsize=${1:-1024} # in bytes
6796 local file=$DIR/$tfile
6798 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep xattr)" ] &&
6799 skip "must have user_xattr" && return 0
6800 [ -z "$(which setfattr 2>/dev/null)" ] &&
6801 skip_env "could not find setfattr" && return 0
6802 [ -z "$(which getfattr 2>/dev/null)" ] &&
6803 skip_env "could not find getfattr" && return 0
6807 local value="$(generate_string $xsize)"
6809 local xbig=trusted.big
6810 log "save $xbig on $file"
6811 setfattr -n $xbig -v $value $file ||
6812 error "saving $xbig on $file failed"
6814 local orig=$(get_xattr_value $xbig $file)
6815 [[ "$orig" != "$value" ]] && error "$xbig different after saving $xbig"
6817 local xsml=trusted.sml
6818 log "save $xsml on $file"
6819 setfattr -n $xsml -v val $file || error "saving $xsml on $file failed"
6821 local new=$(get_xattr_value $xbig $file)
6822 [[ "$new" != "$orig" ]] && error "$xbig different after saving $xsml"
6824 log "grow $xsml on $file"
6825 setfattr -n $xsml -v "$value" $file ||
6826 error "growing $xsml on $file failed"
6828 new=$(get_xattr_value $xbig $file)
6829 [[ "$new" != "$orig" ]] && error "$xbig different after growing $xsml"
6830 log "$xbig still valid after growing $xsml"
6835 test_102h() { # bug 15777
6838 run_test 102h "grow xattr from inside inode to external block"
6841 large_xattr_enabled || { skip "large_xattr disabled" && return; }
6842 grow_xattr $(max_xattr_size)
6844 run_test 102ha "grow xattr from inside inode to external inode"
6846 test_102i() { # bug 17038
6847 [ -z "$(which getfattr 2>/dev/null)" ] &&
6848 skip "could not find getfattr" && return
6850 ln -s $DIR/$tfile $DIR/${tfile}link
6851 getfattr -n trusted.lov $DIR/$tfile ||
6852 error "lgetxattr on $DIR/$tfile failed"
6853 getfattr -h -n trusted.lov $DIR/${tfile}link 2>&1 |
6854 grep -i "no such attr" ||
6855 error "error for lgetxattr on $DIR/${tfile}link is not ENODATA"
6856 rm -f $DIR/$tfile $DIR/${tfile}link
6858 run_test 102i "lgetxattr test on symbolic link ============"
6861 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6862 TAR=$(find_lustre_tar)
6863 [ -z "$TAR" ] && skip_env "lustre-aware tar is not installed" && return
6864 [[ $OSTCOUNT -lt 2 ]] && skip_env "skipping N-stripe test" && return
6865 setup_test102 "$RUNAS"
6866 test_mkdir -p $DIR/d102j
6867 chown $RUNAS_ID $DIR/d102j
6868 $RUNAS $TAR xf $TMP/f102.tar -C $DIR/d102j --xattrs
6870 compare_stripe_info1 "$RUNAS"
6872 run_test 102j "non-root tar restore stripe info from tarfile, not keep osts ==="
6875 [ -z "$(which setfattr 2>/dev/null)" ] &&
6876 skip "could not find setfattr" && return
6878 # b22187 just check that does not crash for regular file.
6879 setfattr -n trusted.lov $DIR/$tfile
6880 # b22187 'setfattr -n trusted.lov' should work as remove LOV EA for directories
6881 local test_kdir=$DIR/d102k
6882 test_mkdir $test_kdir
6883 local default_size=`$GETSTRIPE -S $test_kdir`
6884 local default_count=`$GETSTRIPE -c $test_kdir`
6885 local default_offset=`$GETSTRIPE -i $test_kdir`
6886 $SETSTRIPE -S 65536 -i 0 -c $OSTCOUNT $test_kdir ||
6887 error 'dir setstripe failed'
6888 setfattr -n trusted.lov $test_kdir
6889 local stripe_size=`$GETSTRIPE -S $test_kdir`
6890 local stripe_count=`$GETSTRIPE -c $test_kdir`
6891 local stripe_offset=`$GETSTRIPE -i $test_kdir`
6892 [ $stripe_size -eq $default_size ] ||
6893 error "stripe size $stripe_size != $default_size"
6894 [ $stripe_count -eq $default_count ] ||
6895 error "stripe count $stripe_count != $default_count"
6896 [ $stripe_offset -eq $default_offset ] ||
6897 error "stripe offset $stripe_offset != $default_offset"
6898 rm -rf $DIR/$tfile $test_kdir
6900 run_test 102k "setfattr without parameter of value shouldn't cause a crash"
6903 [ -z "$(which getfattr 2>/dev/null)" ] &&
6904 skip "could not find getfattr" && return
6906 # LU-532 trusted. xattr is invisible to non-root
6907 local testfile=$DIR/$tfile
6911 echo "listxattr as user..."
6912 chown $RUNAS_ID $testfile
6913 $RUNAS getfattr -d -m '.*' $testfile 2>&1 |
6914 grep -q "trusted" &&
6915 error "$testfile trusted xattrs are user visible"
6919 run_test 102l "listxattr size test =================================="
6921 test_102m() { # LU-3403 llite: error of listxattr when buffer is small
6922 local path=$DIR/$tfile
6925 listxattr_size_check $path || error "listattr_size_check $path failed"
6927 run_test 102m "Ensure listxattr fails on small bufffer ========"
6931 getxattr() { # getxattr path name
6932 # Return the base64 encoding of the value of xattr name on path.
6936 # # getfattr --absolute-names --encoding=base64 --name=trusted.lov $path
6938 # trusted.lov=0s0AvRCwEAAAAGAAAAAAAAAAAEAAACAAAAAAAQAAEAA...AAAAAAAAA=
6940 # We print just 0s0AvRCwEAAAAGAAAAAAAAAAAEAAACAAAAAAAQAAEAA...AAAAAAAAA=
6942 getfattr --absolute-names --encoding=base64 --name=$name $path |
6943 awk -F= -v name=$name '$1 == name {
6944 print substr($0, index($0, "=") + 1);
6948 test_102n() { # LU-4101 mdt: protect internal xattrs
6949 local file0=$DIR/$tfile.0
6950 local file1=$DIR/$tfile.1
6951 local xattr0=$TMP/$tfile.0
6952 local xattr1=$TMP/$tfile.1
6956 [ -z "$(which setfattr 2>/dev/null)" ] &&
6957 skip "could not find setfattr" && return
6959 if [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.5.50) ]
6961 skip "MDT < 2.5.50 allows setxattr on internal trusted xattrs"
6965 rm -rf $file0 $file1 $xattr0 $xattr1
6968 # Get 'before' xattrs of $file1.
6969 getfattr --absolute-names --dump --match=- $file1 > $xattr0
6971 for name in lov lma lmv link fid version som hsm lfsck_namespace; do
6972 # Try to copy xattr from $file0 to $file1.
6973 value=$(getxattr $file0 trusted.$name 2> /dev/null)
6975 setfattr --name=trusted.$name --value="$value" $file1 ||
6976 error "setxattr 'trusted.$name' failed"
6978 # Try to set a garbage xattr.
6979 value=0sVGhlIHF1aWNrIGJyb3duIGZveCBqdW1wcyBvdmVyIGl0c2VsZi4=
6981 setfattr --name=trusted.$name --value="$value" $file1 ||
6982 error "setxattr 'trusted.$name' failed"
6984 # Try to remove the xattr from $file1. We don't care if this
6985 # appears to succeed or fail, we just don't want there to be
6986 # any changes or crashes.
6987 setfattr --remove=$trusted.$name $file1 2> /dev/null
6990 if [ $(lustre_version_code $SINGLEMDS) -gt $(version_code 2.6.50) ]
6993 # Try to copy xattr from $file0 to $file1.
6994 value=$(getxattr $file0 trusted.$name 2> /dev/null)
6996 setfattr --name=trusted.$name --value="$value" $file1 ||
6997 error "setxattr 'trusted.$name' failed"
6999 # Try to set a garbage xattr.
7000 value=0sVGhlIHF1aWNrIGJyb3duIGZveCBqdW1wcyBvdmVyIGl0c2VsZi4=
7002 setfattr --name=trusted.$name --value="$value" $file1 ||
7003 error "setxattr 'trusted.$name' failed"
7005 # Try to remove the xattr from $file1. We don't care if this
7006 # appears to succeed or fail, we just don't want there to be
7007 # any changes or crashes.
7008 setfattr --remove=$trusted.$name $file1 2> /dev/null
7011 # Get 'after' xattrs of file1.
7012 getfattr --absolute-names --dump --match=- $file1 > $xattr1
7014 if ! diff $xattr0 $xattr1; then
7015 error "before and after xattrs of '$file1' differ"
7018 rm -rf $file0 $file1 $xattr0 $xattr1
7022 run_test 102n "silently ignore setxattr on internal trusted xattrs"
7024 test_102p() { # LU-4703 setxattr did not check ownership
7025 local testfile=$DIR/$tfile
7027 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.5.56) ] &&
7028 skip "MDS needs to be at least 2.5.56" && return
7032 echo "setfacl as user..."
7033 $RUNAS setfacl -m "u:$RUNAS_ID:rwx" $testfile
7034 [ $? -ne 0 ] || error "setfacl by $RUNAS_ID was allowed on $testfile"
7036 echo "setfattr as user..."
7037 setfacl -m "u:$RUNAS_ID:---" $testfile
7038 $RUNAS setfattr -x system.posix_acl_access $testfile
7039 [ $? -ne 0 ] || error "setfattr by $RUNAS_ID was allowed on $testfile"
7041 run_test 102p "check setxattr(2) correctly fails without permission"
7044 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.6.92) ] &&
7045 skip "MDS needs to be at least 2.6.92" && return
7046 orphan_linkea_check $DIR/$tfile || error "orphan_linkea_check"
7048 run_test 102q "flistxattr should not return trusted.link EAs for orphans"
7051 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.6.93) ] &&
7052 skip "MDS needs to be at least 2.6.93" && return
7053 touch $DIR/$tfile || error "touch"
7054 setfattr -n user.$(basename $tfile) $DIR/$tfile || error "setfattr"
7055 getfattr -n user.$(basename $tfile) $DIR/$tfile || error "getfattr"
7056 rm $DIR/$tfile || error "rm"
7059 mkdir -p $DIR/$tdir || error "mkdir"
7060 setfattr -n user.$(basename $tdir) $DIR/$tdir || error "setfattr dir"
7061 getfattr -n user.$(basename $tdir) $DIR/$tdir || error "getfattr dir"
7062 setfattr -x user.$(basename $tdir) $DIR/$tdir ||
7063 error "$testfile error deleting user.author1"
7064 getfattr -d -m user.$(basename $tdir) 2> /dev/null |
7065 grep "user.$(basename $tdir)" &&
7066 error "$tdir did not delete user.$(basename $tdir)"
7067 rmdir $DIR/$tdir || error "rmdir"
7070 test_mkdir -p $DIR/$tdir || error "make striped dir"
7071 setfattr -n user.$(basename $tdir) $DIR/$tdir || error "setfattr dir"
7072 getfattr -n user.$(basename $tdir) $DIR/$tdir || error "getfattr dir"
7073 setfattr -x user.$(basename $tdir) $DIR/$tdir ||
7074 error "$testfile error deleting user.author1"
7075 getfattr -d -m user.$(basename $tdir) 2> /dev/null |
7076 grep "user.$(basename $tdir)" &&
7077 error "$tdir did not delete user.$(basename $tdir)"
7078 rmdir $DIR/$tdir || error "rm striped dir"
7080 run_test 102r "set EAs with empty values"
7084 $LUSTRE/tests/acl/run $LUSTRE/tests/acl/$1.test
7089 [ "$UID" != 0 ] && skip_env "must run as root" && return
7090 [ -z "$(lctl get_param -n mdc.*-mdc-*.connect_flags | grep acl)" ] &&
7091 skip "must have acl enabled" && return
7092 [ -z "$(which setfacl 2>/dev/null)" ] &&
7093 skip_env "could not find setfacl" && return
7094 $GSS && skip "could not run under gss" && return
7096 gpasswd -a daemon bin # LU-5641
7097 do_facet $SINGLEMDS gpasswd -a daemon bin # LU-5641
7099 declare -a identity_old
7101 for num in $(seq $MDSCOUNT); do
7102 switch_identity $num true || identity_old[$num]=$?
7109 echo "performing cp ..."
7110 run_acl_subtest cp || error "run_acl_subtest cp failed"
7111 echo "performing getfacl-noacl..."
7112 run_acl_subtest getfacl-noacl || error "getfacl-noacl test failed"
7113 echo "performing misc..."
7114 run_acl_subtest misc || error "misc test failed"
7115 echo "performing permissions..."
7116 run_acl_subtest permissions || error "permissions failed"
7117 echo "performing setfacl..."
7118 run_acl_subtest setfacl || error "setfacl test failed"
7120 # inheritance test got from HP
7121 echo "performing inheritance..."
7122 cp $LUSTRE/tests/acl/make-tree . || error "cannot copy make-tree"
7123 chmod +x make-tree || error "chmod +x failed"
7124 run_acl_subtest inheritance || error "inheritance test failed"
7127 echo "LU-974 ignore umask when acl is enabled..."
7128 run_acl_subtest 974 || error "LU-974 umask test failed"
7129 if [ $MDSCOUNT -ge 2 ]; then
7130 run_acl_subtest 974_remote ||
7131 error "LU-974 umask test failed under remote dir"
7134 echo "LU-2561 newly created file is same size as directory..."
7135 if [ $(facet_fstype $SINGLEMDS) != "zfs" ]; then
7136 run_acl_subtest 2561 || error "LU-2561 test failed"
7138 run_acl_subtest 2561_zfs || error "LU-2561 zfs test failed"
7141 run_acl_subtest 4924 || error "LU-4924 test failed"
7146 for num in $(seq $MDSCOUNT); do
7147 if [ "${identity_old[$num]}" = 1 ]; then
7148 switch_identity $num false || identity_old[$num]=$?
7152 run_test 103a "acl test ========================================="
7156 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
7157 local mountopts=$MDS_MOUNT_OPTS
7159 if [[ "$MDS_MOUNT_OPTS" =~ "noacl" ]]; then
7163 stop $SINGLEMDS || error "failed to stop MDT."
7165 if [ -z "$MDS_MOUNT_OPTS" ]; then
7166 MDS_MOUNT_OPTS="-o noacl"
7168 MDS_MOUNT_OPTS="${MDS_MOUNT_OPTS},noacl"
7170 start $SINGLEMDS $MDT_DEV $MDS_MOUNT_OPTS ||
7171 error "failed to start MDT."
7172 MDS_MOUNT_OPTS=$mountopts
7176 setfacl -m u:bin:rw $DIR/$tfile && error "setfacl should fail"
7180 stop $SINGLEMDS || error "failed to stop MDT."
7182 start $SINGLEMDS $MDT_DEV $MDS_MOUNT_OPTS ||
7183 error "failed to start MDT."
7188 run_test 103b "MDS mount option 'noacl'"
7192 cp -rp $DIR/$tdir $DIR/$tdir.bak
7194 [ -n "$(getfattr -d -m. $DIR/$tdir | grep posix_acl_default)" ] &&
7195 error "$DIR/$tdir shouldn't contain default ACL"
7196 [ -n "$(getfattr -d -m. $DIR/$tdir.bak | grep posix_acl_default)" ] &&
7197 error "$DIR/$tdir.bak shouldn't contain default ACL"
7200 run_test 103c "'cp -rp' won't set empty acl"
7203 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7205 lfs df || error "lfs df failed"
7206 lfs df -ih || error "lfs df -ih failed"
7207 lfs df -h $DIR || error "lfs df -h $DIR failed"
7208 lfs df -i $DIR || error "lfs df -i $DIR failed"
7209 lfs df $DIR/$tfile || error "lfs df $DIR/$tfile failed"
7210 lfs df -ih $DIR/$tfile || error "lfs df -ih $DIR/$tfile failed"
7212 local OSC=$(lctl dl | grep OST0000-osc-[^M] | awk '{ print $4 }')
7213 lctl --device %$OSC deactivate
7214 lfs df || error "lfs df with deactivated OSC failed"
7215 lctl --device %$OSC activate
7216 # wait the osc back to normal
7217 wait_osc_import_state client ost FULL
7219 lfs df || error "lfs df with reactivated OSC failed"
7222 run_test 104a "lfs df [-ih] [path] test ========================="
7225 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7226 [ $RUNAS_ID -eq $UID ] &&
7227 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
7229 denied_cnt=$(($($RUNAS $LFS check servers 2>&1 |
7230 grep "Permission denied" | wc -l)))
7231 if [ $denied_cnt -ne 0 ]; then
7232 error "lfs check servers test failed"
7235 run_test 104b "$RUNAS lfs check servers test ===================="
7238 # doesn't work on 2.4 kernels
7240 if $(flock_is_enabled); then
7241 flocks_test 1 on -f $DIR/$tfile || error "fail flock on"
7243 flocks_test 1 off -f $DIR/$tfile || error "fail flock off"
7247 run_test 105a "flock when mounted without -o flock test ========"
7251 if $(flock_is_enabled); then
7252 flocks_test 1 on -c $DIR/$tfile || error "fail flock on"
7254 flocks_test 1 off -c $DIR/$tfile || error "fail flock off"
7258 run_test 105b "fcntl when mounted without -o flock test ========"
7262 if $(flock_is_enabled); then
7263 flocks_test 1 on -l $DIR/$tfile || error "fail flock on"
7265 flocks_test 1 off -l $DIR/$tfile || error "fail flock off"
7269 run_test 105c "lockf when mounted without -o flock test ========"
7271 test_105d() { # bug 15924
7272 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7273 test_mkdir -p $DIR/$tdir
7274 flock_is_enabled || { skip "mount w/o flock enabled" && return; }
7275 #define OBD_FAIL_LDLM_CP_CB_WAIT 0x315
7276 $LCTL set_param fail_loc=0x80000315
7277 flocks_test 2 $DIR/$tdir
7279 run_test 105d "flock race (should not freeze) ========"
7281 test_105e() { # bug 22660 && 22040
7282 flock_is_enabled || { skip "mount w/o flock enabled" && return; }
7284 flocks_test 3 $DIR/$tfile
7286 run_test 105e "Two conflicting flocks from same process ======="
7288 test_106() { #bug 10921
7289 test_mkdir -p $DIR/$tdir
7290 $DIR/$tdir && error "exec $DIR/$tdir succeeded"
7291 chmod 777 $DIR/$tdir || error "chmod $DIR/$tdir failed"
7293 run_test 106 "attempt exec of dir followed by chown of that dir"
7296 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7303 local save_pattern=$(sysctl -n kernel.core_pattern)
7304 local save_uses_pid=$(sysctl -n kernel.core_uses_pid)
7305 sysctl -w kernel.core_pattern=$file
7306 sysctl -w kernel.core_uses_pid=0
7314 kill -s 11 $SLEEPPID
7316 if [ -e $file ]; then
7317 size=`stat -c%s $file`
7318 [ $size -eq 0 ] && error "Fail to create core file $file"
7320 error "Fail to create core file $file"
7323 sysctl -w kernel.core_pattern=$save_pattern
7324 sysctl -w kernel.core_uses_pid=$save_uses_pid
7327 run_test 107 "Coredump on SIG"
7330 test_mkdir -p $DIR/$tdir
7331 test_mkdir $DIR/$tdir/$(str_repeat 'a' 255) ||
7332 error "mkdir with 255 char failed"
7333 test_mkdir $DIR/$tdir/$(str_repeat 'b' 256) &&
7334 error "mkdir with 256 char should fail, but did not"
7335 touch $DIR/$tdir/$(str_repeat 'x' 255) ||
7336 error "create with 255 char failed"
7337 touch $DIR/$tdir/$(str_repeat 'y' 256) &&
7338 error "create with 256 char should fail, but did not"
7343 run_test 110 "filename length checking"
7346 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7347 OSTIO_pre=$(ps -e | grep ll_ost_io | awk '{ print $4 }'| sort -n |
7348 tail -1 | cut -c11-20)
7349 [ -z "$OSTIO_pre" ] && skip "no OSS threads" && return
7350 echo "Starting with $OSTIO_pre threads"
7353 NUMFREE=$(df -i -P $DIR | tail -n 1 | awk '{ print $4 }')
7354 [[ $NUMFREE -lt $NUMTEST ]] && NUMTEST=$(($NUMFREE - 1000))
7355 echo "$NUMTEST creates/unlinks"
7356 test_mkdir -p $DIR/$tdir
7357 createmany -o $DIR/$tdir/$tfile $NUMTEST
7358 unlinkmany $DIR/$tdir/$tfile $NUMTEST
7360 OSTIO_post=$(ps -e | grep ll_ost_io | awk '{ print $4 }' | sort -n |
7361 tail -1 | cut -c11-20)
7363 # don't return an error
7364 [ $OSTIO_post == $OSTIO_pre ] && echo \
7365 "WARNING: No new ll_ost_io threads were created ($OSTIO_pre)" &&
7366 echo "This may be fine, depending on what ran before this test" &&
7367 echo "and how fast this system is." && return
7369 echo "Started with $OSTIO_pre threads, ended with $OSTIO_post"
7371 run_test 115 "verify dynamic thread creation===================="
7374 wait_delete_completed
7375 AVAIL=($(lctl get_param -n osc.*[oO][sS][cC]-[^M]*.kbytesavail))
7376 echo OST kbytes available: ${AVAIL[@]}
7377 MAXI=0; MAXV=${AVAIL[0]}
7378 MINI=0; MINV=${AVAIL[0]}
7379 for ((i = 0; i < ${#AVAIL[@]}; i++)); do
7380 #echo OST $i: ${AVAIL[i]}kb
7381 if [[ ${AVAIL[i]} -gt $MAXV ]]; then
7382 MAXV=${AVAIL[i]}; MAXI=$i
7384 if [[ ${AVAIL[i]} -lt $MINV ]]; then
7385 MINV=${AVAIL[i]}; MINI=$i
7388 echo Min free space: OST $MINI: $MINV
7389 echo Max free space: OST $MAXI: $MAXV
7392 test_116a() { # was previously test_116()
7393 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7394 remote_mds_nodsh && skip "remote MDS with nodsh" && return
7396 [[ $OSTCOUNT -lt 2 ]] && skip_env "$OSTCOUNT < 2 OSTs" && return
7398 echo -n "Free space priority "
7399 do_facet $SINGLEMDS lctl get_param -n lo*.*-mdtlov.qos_prio_free |
7404 [ $MINV -eq 0 ] && skip "no free space in OST$MINI, skip" && return
7405 [ $MINV -gt 10000000 ] && skip "too much free space in OST$MINI, skip" \
7407 trap simple_cleanup_common EXIT
7410 # Check if we need to generate uneven OSTs
7411 test_mkdir -p $DIR/$tdir/OST${MINI}
7412 local FILL=$(($MINV / 4))
7413 local DIFF=$(($MAXV - $MINV))
7414 local DIFF2=$(($DIFF * 100 / $MINV))
7416 local threshold=$(do_facet $SINGLEMDS \
7417 lctl get_param -n *.*MDT0000-mdtlov.qos_threshold_rr | head -n1)
7418 threshold=${threshold%%%}
7419 echo -n "Check for uneven OSTs: "
7420 echo -n "diff=${DIFF}KB (${DIFF2}%) must be > ${threshold}% ..."
7422 if [[ $DIFF2 -gt $threshold ]]; then
7424 echo "Don't need to fill OST$MINI"
7426 # generate uneven OSTs. Write 2% over the QOS threshold value
7428 DIFF=$(($threshold - $DIFF2 + 2))
7429 DIFF2=$(( ($MINV * $DIFF)/100 ))
7430 echo "Fill ${DIFF}% remaining space in OST${MINI} with ${DIFF2}KB"
7431 $SETSTRIPE -i $MINI -c 1 $DIR/$tdir/OST${MINI} ||
7432 error "setstripe failed"
7433 DIFF=$(($DIFF2 / 2048))
7435 while [ $i -lt $DIFF ]; do
7437 dd if=/dev/zero of=$DIR/$tdir/OST${MINI}/$tfile-$i \
7438 bs=2M count=1 2>/dev/null
7447 DIFF=$(($MAXV - $MINV))
7448 DIFF2=$(($DIFF * 100 / $MINV))
7449 echo -n "diff=${DIFF}=${DIFF2}% must be > ${threshold}% for QOS mode..."
7450 if [[ $DIFF2 -gt $threshold ]]; then
7453 echo "failed - QOS mode won't be used"
7454 skip "QOS imbalance criteria not met"
7455 simple_cleanup_common
7459 MINI1=$MINI; MINV1=$MINV
7460 MAXI1=$MAXI; MAXV1=$MAXV
7462 # now fill using QOS
7463 $SETSTRIPE -c 1 $DIR/$tdir
7464 FILL=$(($FILL / 200))
7465 if [ $FILL -gt 600 ]; then
7468 echo "writing $FILL files to QOS-assigned OSTs"
7470 while [ $i -lt $FILL ]; do
7472 dd if=/dev/zero of=$DIR/$tdir/$tfile-$i bs=200k \
7476 echo "wrote $i 200k files"
7480 echo "Note: free space may not be updated, so measurements might be off"
7482 DIFF2=$(($MAXV - $MINV))
7483 echo "free space delta: orig $DIFF final $DIFF2"
7484 [ $DIFF2 -gt $DIFF ] && echo "delta got worse!"
7485 DIFF=$(($MINV1 - ${AVAIL[$MINI1]}))
7486 echo "Wrote ${DIFF}KB to smaller OST $MINI1"
7487 DIFF2=$(($MAXV1 - ${AVAIL[$MAXI1]}))
7488 echo "Wrote ${DIFF2}KB to larger OST $MAXI1"
7489 FILL=$(($DIFF2 * 100 / $DIFF - 100))
7491 echo "Wrote ${FILL}% more data to larger OST $MAXI1"
7493 # Figure out which files were written where
7494 UUID=$(lctl get_param -n lov.${FSNAME}-clilov-*.target_obd |
7495 awk '/'$MINI1': / {print $2; exit}')
7497 MINC=$($GETSTRIPE --ost $UUID $DIR/$tdir | grep $DIR | wc -l)
7498 echo "$MINC files created on smaller OST $MINI1"
7499 UUID=$(lctl get_param -n lov.${FSNAME}-clilov-*.target_obd |
7500 awk '/'$MAXI1': / {print $2; exit}')
7502 MAXC=$($GETSTRIPE --ost $UUID $DIR/$tdir | grep $DIR | wc -l)
7503 echo "$MAXC files created on larger OST $MAXI1"
7504 FILL=$(($MAXC * 100 / $MINC - 100))
7505 [[ $MINC -gt 0 ]] &&
7506 echo "Wrote ${FILL}% more files to larger OST $MAXI1"
7507 [[ $MAXC -gt $MINC ]] ||
7508 error_ignore LU-9 "stripe QOS didn't balance free space"
7509 simple_cleanup_common
7511 run_test 116a "stripe QOS: free space balance ==================="
7513 test_116b() { # LU-2093
7514 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7515 remote_mds_nodsh && skip "remote MDS with nodsh" && return
7517 #define OBD_FAIL_MDS_OSC_CREATE_FAIL 0x147
7518 local old_rr=$(do_facet $SINGLEMDS lctl get_param -n \
7519 lo*.$FSNAME-MDT0000-mdtlov.qos_threshold_rr | head -1)
7520 [ -z "$old_rr" ] && skip "no QOS" && return 0
7521 do_facet $SINGLEMDS lctl set_param \
7522 lo*.$FSNAME-MDT0000-mdtlov.qos_threshold_rr=0
7524 do_facet $SINGLEMDS lctl set_param fail_loc=0x147
7525 createmany -o $DIR/$tdir/f- 20 || error "can't create"
7526 do_facet $SINGLEMDS lctl set_param fail_loc=0
7528 do_facet $SINGLEMDS lctl set_param \
7529 lo*.$FSNAME-MDT0000-mdtlov.qos_threshold_rr=$old_rr
7531 run_test 116b "QoS shouldn't LBUG if not enough OSTs found on the 2nd pass"
7533 test_117() # bug 10891
7535 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7536 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1
7537 #define OBD_FAIL_OST_SETATTR_CREDITS 0x21e
7538 lctl set_param fail_loc=0x21e
7539 > $DIR/$tfile || error "truncate failed"
7540 lctl set_param fail_loc=0
7541 echo "Truncate succeeded."
7544 run_test 117 "verify osd extend =========="
7546 NO_SLOW_RESENDCOUNT=4
7547 export OLD_RESENDCOUNT=""
7548 set_resend_count () {
7549 local PROC_RESENDCOUNT="osc.${FSNAME}-OST*-osc-*.resend_count"
7550 OLD_RESENDCOUNT=$(lctl get_param -n $PROC_RESENDCOUNT | head -n1)
7551 lctl set_param -n $PROC_RESENDCOUNT $1
7552 echo resend_count is set to $(lctl get_param -n $PROC_RESENDCOUNT)
7555 # for reduce test_118* time (b=14842)
7556 [ "$SLOW" = "no" ] && set_resend_count $NO_SLOW_RESENDCOUNT
7558 # Reset async IO behavior after error case
7560 FILE=$DIR/reset_async
7562 # Ensure all OSCs are cleared
7563 $SETSTRIPE -c -1 $FILE
7564 dd if=/dev/zero of=$FILE bs=64k count=$OSTCOUNT
7569 test_118a() #bug 11710
7571 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7574 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
7575 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
7576 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
7578 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
7579 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
7584 run_test 118a "verify O_SYNC works =========="
7588 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7589 remote_ost_nodsh && skip "remote OST with nodsh" && return
7593 #define OBD_FAIL_SRV_ENOENT 0x217
7594 set_nodes_failloc "$(osts_nodes)" 0x217
7595 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
7597 set_nodes_failloc "$(osts_nodes)" 0
7598 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
7599 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
7602 if [[ $RC -eq 0 ]]; then
7603 error "Must return error due to dropped pages, rc=$RC"
7607 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
7608 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
7612 echo "Dirty pages not leaked on ENOENT"
7614 # Due to the above error the OSC will issue all RPCs syncronously
7615 # until a subsequent RPC completes successfully without error.
7616 $MULTIOP $DIR/$tfile Ow4096yc
7621 run_test 118b "Reclaim dirty pages on fatal error =========="
7625 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7627 # for 118c, restore the original resend count, LU-1940
7628 [ "$SLOW" = "no" ] && [ -n "$OLD_RESENDCOUNT" ] &&
7629 set_resend_count $OLD_RESENDCOUNT
7630 remote_ost_nodsh && skip "remote OST with nodsh" && return
7634 #define OBD_FAIL_OST_EROFS 0x216
7635 set_nodes_failloc "$(osts_nodes)" 0x216
7637 # multiop should block due to fsync until pages are written
7638 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
7642 if [[ `ps h -o comm -p $MULTIPID` != "multiop" ]]; then
7643 error "Multiop failed to block on fsync, pid=$MULTIPID"
7646 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
7648 if [[ $WRITEBACK -eq 0 ]]; then
7649 error "No page in writeback, writeback=$WRITEBACK"
7652 set_nodes_failloc "$(osts_nodes)" 0
7655 if [[ $RC -ne 0 ]]; then
7656 error "Multiop fsync failed, rc=$RC"
7659 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
7660 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
7662 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
7663 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
7667 echo "Dirty pages flushed via fsync on EROFS"
7670 run_test 118c "Fsync blocks on EROFS until dirty pages are flushed =========="
7672 # continue to use small resend count to reduce test_118* time (b=14842)
7673 [ "$SLOW" = "no" ] && set_resend_count $NO_SLOW_RESENDCOUNT
7677 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7678 remote_ost_nodsh && skip "remote OST with nodsh" && return
7682 #define OBD_FAIL_OST_BRW_PAUSE_BULK
7683 set_nodes_failloc "$(osts_nodes)" 0x214
7684 # multiop should block due to fsync until pages are written
7685 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
7689 if [[ `ps h -o comm -p $MULTIPID` != "multiop" ]]; then
7690 error "Multiop failed to block on fsync, pid=$MULTIPID"
7693 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
7695 if [[ $WRITEBACK -eq 0 ]]; then
7696 error "No page in writeback, writeback=$WRITEBACK"
7699 wait $MULTIPID || error "Multiop fsync failed, rc=$?"
7700 set_nodes_failloc "$(osts_nodes)" 0
7702 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
7703 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
7705 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
7706 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
7710 echo "Dirty pages gaurenteed flushed via fsync"
7713 run_test 118d "Fsync validation inject a delay of the bulk =========="
7716 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7719 #define OBD_FAIL_OSC_BRW_PREP_REQ2 0x40a
7720 lctl set_param fail_loc=0x8000040a
7722 # Should simulate EINVAL error which is fatal
7723 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
7725 if [[ $RC -eq 0 ]]; then
7726 error "Must return error due to dropped pages, rc=$RC"
7729 lctl set_param fail_loc=0x0
7731 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
7732 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
7733 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
7735 if [[ $LOCKED -ne 0 ]]; then
7736 error "Locked pages remain in cache, locked=$LOCKED"
7739 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
7740 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
7744 echo "No pages locked after fsync"
7749 run_test 118f "Simulate unrecoverable OSC side error =========="
7752 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7755 #define OBD_FAIL_OSC_BRW_PREP_REQ 0x406
7756 lctl set_param fail_loc=0x406
7758 # simulate local -ENOMEM
7759 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
7762 lctl set_param fail_loc=0
7763 if [[ $RC -eq 0 ]]; then
7764 error "Must return error due to dropped pages, rc=$RC"
7767 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
7768 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
7769 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
7771 if [[ $LOCKED -ne 0 ]]; then
7772 error "Locked pages remain in cache, locked=$LOCKED"
7775 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
7776 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
7780 echo "No pages locked after fsync"
7785 run_test 118g "Don't stay in wait if we got local -ENOMEM =========="
7788 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7789 remote_ost_nodsh && skip "remote OST with nodsh" && return
7793 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
7794 set_nodes_failloc "$(osts_nodes)" 0x20e
7795 # Should simulate ENOMEM error which is recoverable and should be handled by timeout
7796 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
7799 set_nodes_failloc "$(osts_nodes)" 0
7800 if [[ $RC -eq 0 ]]; then
7801 error "Must return error due to dropped pages, rc=$RC"
7804 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
7805 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
7806 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
7808 if [[ $LOCKED -ne 0 ]]; then
7809 error "Locked pages remain in cache, locked=$LOCKED"
7812 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
7813 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
7817 echo "No pages locked after fsync"
7821 run_test 118h "Verify timeout in handling recoverables errors =========="
7823 [ "$SLOW" = "no" ] && [ -n "$OLD_RESENDCOUNT" ] && set_resend_count $OLD_RESENDCOUNT
7826 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7827 remote_ost_nodsh && skip "remote OST with nodsh" && return
7831 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
7832 set_nodes_failloc "$(osts_nodes)" 0x20e
7834 # Should simulate ENOMEM error which is recoverable and should be handled by timeout
7835 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
7838 set_nodes_failloc "$(osts_nodes)" 0
7842 if [[ $RC -ne 0 ]]; then
7843 error "got error, but should be not, rc=$RC"
7846 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
7847 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
7848 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
7849 if [[ $LOCKED -ne 0 ]]; then
7850 error "Locked pages remain in cache, locked=$LOCKED"
7853 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
7854 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
7858 echo "No pages locked after fsync"
7862 run_test 118i "Fix error before timeout in recoverable error =========="
7864 [ "$SLOW" = "no" ] && set_resend_count 4
7867 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7868 remote_ost_nodsh && skip "remote OST with nodsh" && return
7872 #define OBD_FAIL_OST_BRW_WRITE_BULK2 0x220
7873 set_nodes_failloc "$(osts_nodes)" 0x220
7875 # return -EIO from OST
7876 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
7878 set_nodes_failloc "$(osts_nodes)" 0x0
7879 if [[ $RC -eq 0 ]]; then
7880 error "Must return error due to dropped pages, rc=$RC"
7883 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
7884 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
7885 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
7886 if [[ $LOCKED -ne 0 ]]; then
7887 error "Locked pages remain in cache, locked=$LOCKED"
7890 # in recoverable error on OST we want resend and stay until it finished
7891 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
7892 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
7896 echo "No pages locked after fsync"
7900 run_test 118j "Simulate unrecoverable OST side error =========="
7904 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7905 remote_ost_nodsh && skip "remote OSTs with nodsh" && return
7907 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
7908 set_nodes_failloc "$(osts_nodes)" 0x20e
7909 test_mkdir -p $DIR/$tdir
7911 for ((i=0;i<10;i++)); do
7912 (dd if=/dev/zero of=$DIR/$tdir/$tfile-$i bs=1M count=10 || \
7913 error "dd to $DIR/$tdir/$tfile-$i failed" )&
7920 set_nodes_failloc "$(osts_nodes)" 0
7923 run_test 118k "bio alloc -ENOMEM and IO TERM handling ========="
7927 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7929 test_mkdir -p $DIR/$tdir
7930 $MULTIOP $DIR/$tdir Dy || error "fsync dir failed"
7933 run_test 118l "fsync dir ========="
7935 test_118m() # LU-3066
7937 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7938 test_mkdir -p $DIR/$tdir
7939 $MULTIOP $DIR/$tdir DY || error "fdatasync dir failed"
7942 run_test 118m "fdatasync dir ========="
7944 [ "$SLOW" = "no" ] && [ -n "$OLD_RESENDCOUNT" ] && set_resend_count $OLD_RESENDCOUNT
7946 test_119a() # bug 11737
7948 BSIZE=$((512 * 1024))
7949 directio write $DIR/$tfile 0 1 $BSIZE
7950 # We ask to read two blocks, which is more than a file size.
7951 # directio will indicate an error when requested and actual
7952 # sizes aren't equeal (a normal situation in this case) and
7953 # print actual read amount.
7954 NOB=`directio read $DIR/$tfile 0 2 $BSIZE | awk '/error/ {print $6}'`
7955 if [ "$NOB" != "$BSIZE" ]; then
7956 error "read $NOB bytes instead of $BSIZE"
7960 run_test 119a "Short directIO read must return actual read amount"
7962 test_119b() # bug 11737
7964 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping 2-stripe test" && return
7966 $SETSTRIPE -c 2 $DIR/$tfile || error "setstripe failed"
7967 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=1 || error "dd failed"
7969 $MULTIOP $DIR/$tfile oO_RDONLY:O_DIRECT:r$((2048 * 1024)) || \
7970 error "direct read failed"
7973 run_test 119b "Sparse directIO read must return actual read amount"
7975 test_119c() # bug 13099
7978 directio write $DIR/$tfile 3 1 $BSIZE || error "direct write failed"
7979 directio readhole $DIR/$tfile 0 2 $BSIZE || error "reading hole failed"
7982 run_test 119c "Testing for direct read hitting hole"
7984 test_119d() # bug 15950
7986 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7987 MAX_RPCS_IN_FLIGHT=`$LCTL get_param -n osc.*OST0000-osc-[^mM]*.max_rpcs_in_flight`
7988 $LCTL set_param -n osc.*OST0000-osc-[^mM]*.max_rpcs_in_flight 1
7990 $SETSTRIPE $DIR/$tfile -i 0 -c 1 || error "setstripe failed"
7991 $DIRECTIO write $DIR/$tfile 0 1 $BSIZE || error "first directio failed"
7992 #define OBD_FAIL_OSC_DIO_PAUSE 0x40d
7993 lctl set_param fail_loc=0x40d
7994 $DIRECTIO write $DIR/$tfile 1 4 $BSIZE &
7997 cat $DIR/$tfile > /dev/null &
7998 lctl set_param fail_loc=0
8001 log "the DIO writes have completed, now wait for the reads (should not block very long)"
8003 [ -n "`ps h -p $pid_reads -o comm`" ] && \
8004 error "the read rpcs have not completed in 2s"
8006 $LCTL set_param -n osc.*OST0000-osc-[^mM]*.max_rpcs_in_flight $MAX_RPCS_IN_FLIGHT
8008 run_test 119d "The DIO path should try to send a new rpc once one is completed"
8011 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8012 test_mkdir -p $DIR/$tdir
8013 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
8014 skip "no early lock cancel on server" && return 0
8016 lru_resize_disable mdc
8017 lru_resize_disable osc
8018 cancel_lru_locks mdc
8019 # asynchronous object destroy at MDT could cause bl ast to client
8020 cancel_lru_locks osc
8022 stat $DIR/$tdir > /dev/null
8023 can1=$(do_facet $SINGLEMDS \
8024 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8025 awk '/ldlm_cancel/ {print $2}')
8026 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8027 awk '/ldlm_bl_callback/ {print $2}')
8028 test_mkdir -c1 $DIR/$tdir/d1
8029 can2=$(do_facet $SINGLEMDS \
8030 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8031 awk '/ldlm_cancel/ {print $2}')
8032 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8033 awk '/ldlm_bl_callback/ {print $2}')
8034 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
8035 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
8036 lru_resize_enable mdc
8037 lru_resize_enable osc
8039 run_test 120a "Early Lock Cancel: mkdir test"
8042 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8043 test_mkdir $DIR/$tdir
8044 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel)" ] && \
8045 skip "no early lock cancel on server" && return 0
8046 lru_resize_disable mdc
8047 lru_resize_disable osc
8048 cancel_lru_locks mdc
8049 stat $DIR/$tdir > /dev/null
8050 can1=$(do_facet $SINGLEMDS \
8051 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8052 awk '/ldlm_cancel/ {print $2}')
8053 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8054 awk '/ldlm_bl_callback/ {print $2}')
8056 can2=$(do_facet $SINGLEMDS \
8057 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8058 awk '/ldlm_cancel/ {print $2}')
8059 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8060 awk '/ldlm_bl_callback/ {print $2}')
8061 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
8062 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
8063 lru_resize_enable mdc
8064 lru_resize_enable osc
8066 run_test 120b "Early Lock Cancel: create test"
8069 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8070 test_mkdir -c1 $DIR/$tdir
8071 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel)" ] && \
8072 skip "no early lock cancel on server" && return 0
8073 lru_resize_disable mdc
8074 lru_resize_disable osc
8075 test_mkdir -p -c1 $DIR/$tdir/d1
8076 test_mkdir -p -c1 $DIR/$tdir/d2
8077 touch $DIR/$tdir/d1/f1
8078 cancel_lru_locks mdc
8079 stat $DIR/$tdir/d1 $DIR/$tdir/d2 $DIR/$tdir/d1/f1 > /dev/null
8080 can1=$(do_facet $SINGLEMDS \
8081 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8082 awk '/ldlm_cancel/ {print $2}')
8083 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8084 awk '/ldlm_bl_callback/ {print $2}')
8085 ln $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2
8086 can2=$(do_facet $SINGLEMDS \
8087 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8088 awk '/ldlm_cancel/ {print $2}')
8089 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8090 awk '/ldlm_bl_callback/ {print $2}')
8091 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
8092 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
8093 lru_resize_enable mdc
8094 lru_resize_enable osc
8096 run_test 120c "Early Lock Cancel: link test"
8099 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8100 test_mkdir -p -c1 $DIR/$tdir
8101 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel)" ] && \
8102 skip "no early lock cancel on server" && return 0
8103 lru_resize_disable mdc
8104 lru_resize_disable osc
8106 cancel_lru_locks mdc
8107 stat $DIR/$tdir > /dev/null
8108 can1=$(do_facet $SINGLEMDS \
8109 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8110 awk '/ldlm_cancel/ {print $2}')
8111 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8112 awk '/ldlm_bl_callback/ {print $2}')
8113 chmod a+x $DIR/$tdir
8114 can2=$(do_facet $SINGLEMDS \
8115 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8116 awk '/ldlm_cancel/ {print $2}')
8117 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8118 awk '/ldlm_bl_callback/ {print $2}')
8119 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
8120 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
8121 lru_resize_enable mdc
8122 lru_resize_enable osc
8124 run_test 120d "Early Lock Cancel: setattr test"
8127 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8128 test_mkdir -p -c1 $DIR/$tdir
8129 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
8130 skip "no early lock cancel on server" && return 0
8131 lru_resize_disable mdc
8132 lru_resize_disable osc
8133 dd if=/dev/zero of=$DIR/$tdir/f1 count=1
8134 cancel_lru_locks mdc
8135 cancel_lru_locks osc
8136 dd if=$DIR/$tdir/f1 of=/dev/null
8137 stat $DIR/$tdir $DIR/$tdir/f1 > /dev/null
8138 # XXX client can not do early lock cancel of OST lock
8139 # during unlink (LU-4206), so cancel osc lock now.
8140 cancel_lru_locks osc
8141 can1=$(do_facet $SINGLEMDS \
8142 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8143 awk '/ldlm_cancel/ {print $2}')
8144 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8145 awk '/ldlm_bl_callback/ {print $2}')
8146 unlink $DIR/$tdir/f1
8148 can2=$(do_facet $SINGLEMDS \
8149 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8150 awk '/ldlm_cancel/ {print $2}')
8151 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8152 awk '/ldlm_bl_callback/ {print $2}')
8153 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
8154 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
8155 lru_resize_enable mdc
8156 lru_resize_enable osc
8158 run_test 120e "Early Lock Cancel: unlink test"
8161 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8162 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
8163 skip "no early lock cancel on server" && return 0
8164 test_mkdir -p -c1 $DIR/$tdir
8165 lru_resize_disable mdc
8166 lru_resize_disable osc
8167 test_mkdir -p -c1 $DIR/$tdir/d1
8168 test_mkdir -p -c1 $DIR/$tdir/d2
8169 dd if=/dev/zero of=$DIR/$tdir/d1/f1 count=1
8170 dd if=/dev/zero of=$DIR/$tdir/d2/f2 count=1
8171 cancel_lru_locks mdc
8172 cancel_lru_locks osc
8173 dd if=$DIR/$tdir/d1/f1 of=/dev/null
8174 dd if=$DIR/$tdir/d2/f2 of=/dev/null
8175 stat $DIR/$tdir/d1 $DIR/$tdir/d2 $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2 > /dev/null
8176 # XXX client can not do early lock cancel of OST lock
8177 # during rename (LU-4206), so cancel osc lock now.
8178 cancel_lru_locks osc
8179 can1=$(do_facet $SINGLEMDS \
8180 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8181 awk '/ldlm_cancel/ {print $2}')
8182 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8183 awk '/ldlm_bl_callback/ {print $2}')
8184 mrename $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2
8186 can2=$(do_facet $SINGLEMDS \
8187 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8188 awk '/ldlm_cancel/ {print $2}')
8189 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8190 awk '/ldlm_bl_callback/ {print $2}')
8191 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
8192 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
8193 lru_resize_enable mdc
8194 lru_resize_enable osc
8196 run_test 120f "Early Lock Cancel: rename test"
8199 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8200 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
8201 skip "no early lock cancel on server" && return 0
8202 lru_resize_disable mdc
8203 lru_resize_disable osc
8205 echo create $count files
8206 test_mkdir -p $DIR/$tdir
8207 cancel_lru_locks mdc
8208 cancel_lru_locks osc
8211 can0=$(do_facet $SINGLEMDS \
8212 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8213 awk '/ldlm_cancel/ {print $2}')
8214 blk0=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8215 awk '/ldlm_bl_callback/ {print $2}')
8216 createmany -o $DIR/$tdir/f $count
8218 can1=$(do_facet $SINGLEMDS \
8219 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8220 awk '/ldlm_cancel/ {print $2}')
8221 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8222 awk '/ldlm_bl_callback/ {print $2}')
8224 echo total: $((can1-can0)) cancels, $((blk1-blk0)) blockings
8225 echo rm $count files
8228 can2=$(do_facet $SINGLEMDS \
8229 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8230 awk '/ldlm_cancel/ {print $2}')
8231 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8232 awk '/ldlm_bl_callback/ {print $2}')
8234 echo total: $count removes in $((t2-t1))
8235 echo total: $((can2-can1)) cancels, $((blk2-blk1)) blockings
8237 # wait for commitment of removal
8238 lru_resize_enable mdc
8239 lru_resize_enable osc
8241 run_test 120g "Early Lock Cancel: performance test"
8243 test_121() { #bug #10589
8244 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8246 writes=$(LANG=C dd if=/dev/zero of=$DIR/$tfile count=1 2>&1 | awk -F '+' '/out$/ {print $1}')
8247 #define OBD_FAIL_LDLM_CANCEL_RACE 0x310
8248 lctl set_param fail_loc=0x310
8249 cancel_lru_locks osc > /dev/null
8250 reads=$(LANG=C dd if=$DIR/$tfile of=/dev/null 2>&1 | awk -F '+' '/in$/ {print $1}')
8251 lctl set_param fail_loc=0
8252 [[ $reads -eq $writes ]] ||
8253 error "read $reads blocks, must be $writes blocks"
8255 run_test 121 "read cancel race ========="
8257 test_123a() { # was test 123, statahead(bug 11401)
8258 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8260 if [ -z "$(grep "processor.*: 1" /proc/cpuinfo)" ]; then
8261 log "testing on UP system. Performance may be not as good as expected."
8266 test_mkdir -p $DIR/$tdir
8267 NUMFREE=$(df -i -P $DIR | tail -n 1 | awk '{ print $4 }')
8268 [[ $NUMFREE -gt 100000 ]] && NUMFREE=100000 || NUMFREE=$((NUMFREE-1000))
8270 for ((i=100, j=0; i<=$NUMFREE; j=$i, i=$((i * MULT)) )); do
8271 createmany -o $DIR/$tdir/$tfile $j $((i - j))
8273 max=`lctl get_param -n llite.*.statahead_max | head -n 1`
8274 lctl set_param -n llite.*.statahead_max 0
8275 lctl get_param llite.*.statahead_max
8276 cancel_lru_locks mdc
8277 cancel_lru_locks osc
8279 time ls -l $DIR/$tdir | wc -l
8281 delta=$((etime - stime))
8282 log "ls $i files without statahead: $delta sec"
8283 lctl set_param llite.*.statahead_max=$max
8285 swrong=`lctl get_param -n llite.*.statahead_stats | grep "statahead wrong:" | awk '{print $3}'`
8286 lctl get_param -n llite.*.statahead_max | grep '[0-9]'
8287 cancel_lru_locks mdc
8288 cancel_lru_locks osc
8290 time ls -l $DIR/$tdir | wc -l
8292 delta_sa=$((etime - stime))
8293 log "ls $i files with statahead: $delta_sa sec"
8294 lctl get_param -n llite.*.statahead_stats
8295 ewrong=`lctl get_param -n llite.*.statahead_stats | grep "statahead wrong:" | awk '{print $3}'`
8297 [[ $swrong -lt $ewrong ]] &&
8298 log "statahead was stopped, maybe too many locks held!"
8299 [[ $delta -eq 0 || $delta_sa -eq 0 ]] && continue
8301 if [ $((delta_sa * 100)) -gt $((delta * 105)) -a $delta_sa -gt $((delta + 2)) ]; then
8302 max=`lctl get_param -n llite.*.statahead_max | head -n 1`
8303 lctl set_param -n llite.*.statahead_max 0
8304 lctl get_param llite.*.statahead_max
8305 cancel_lru_locks mdc
8306 cancel_lru_locks osc
8308 time ls -l $DIR/$tdir | wc -l
8310 delta=$((etime - stime))
8311 log "ls $i files again without statahead: $delta sec"
8312 lctl set_param llite.*.statahead_max=$max
8313 if [ $((delta_sa * 100)) -gt $((delta * 105)) -a $delta_sa -gt $((delta + 2)) ]; then
8314 if [ $SLOWOK -eq 0 ]; then
8315 error "ls $i files is slower with statahead!"
8317 log "ls $i files is slower with statahead!"
8323 [ $delta -gt 20 ] && break
8324 [ $delta -gt 8 ] && MULT=$((50 / delta))
8325 [ "$SLOW" = "no" -a $delta -gt 5 ] && break
8333 delta=$((etime - stime))
8334 log "rm -r $DIR/$tdir/: $delta seconds"
8336 lctl get_param -n llite.*.statahead_stats
8338 run_test 123a "verify statahead work"
8340 test_123b () { # statahead(bug 15027)
8341 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8342 test_mkdir -p $DIR/$tdir
8343 createmany -o $DIR/$tdir/$tfile-%d 1000
8345 cancel_lru_locks mdc
8346 cancel_lru_locks osc
8348 #define OBD_FAIL_MDC_GETATTR_ENQUEUE 0x803
8349 lctl set_param fail_loc=0x80000803
8350 ls -lR $DIR/$tdir > /dev/null
8352 lctl set_param fail_loc=0x0
8353 lctl get_param -n llite.*.statahead_stats
8358 run_test 123b "not panic with network error in statahead enqueue (bug 15027)"
8361 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8362 [ -z "$($LCTL get_param -n mdc.*.connect_flags | grep lru_resize)" ] &&
8363 skip "no lru resize on server" && return 0
8365 test_mkdir -p $DIR/$tdir || error "failed to create $DIR/$tdir"
8367 log "create $NR files at $DIR/$tdir"
8368 createmany -o $DIR/$tdir/f $NR ||
8369 error "failed to create $NR files in $DIR/$tdir"
8371 cancel_lru_locks mdc
8372 ls -l $DIR/$tdir > /dev/null
8376 for VALUE in $($LCTL get_param ldlm.namespaces.*mdc-*.lru_size); do
8377 local PARAM=$(echo ${VALUE[0]} | cut -d "=" -f1)
8378 LRU_SIZE=$($LCTL get_param -n $PARAM)
8379 if [[ $LRU_SIZE -gt $(default_lru_size) ]]; then
8380 NSDIR=$(echo $PARAM | cut -d "." -f1-3)
8382 log "NS=$(basename $NSDIR)"
8387 if [[ -z "$NSDIR" || $LRU_SIZE -lt $(default_lru_size) ]]; then
8388 skip "Not enough cached locks created!"
8395 # We know that lru resize allows one client to hold $LIMIT locks
8396 # for 10h. After that locks begin to be killed by client.
8398 local LIMIT=$($LCTL get_param -n $NSDIR.pool.limit)
8400 if [ $LIMIT -lt $LRU_SIZE ]; then
8401 skip "Limit is too small $LIMIT"
8405 # Make LVF so higher that sleeping for $SLEEP is enough to _start_
8406 # killing locks. Some time was spent for creating locks. This means
8407 # that up to the moment of sleep finish we must have killed some of
8408 # them (10-100 locks). This depends on how fast ther were created.
8409 # Many of them were touched in almost the same moment and thus will
8410 # be killed in groups.
8411 local LVF=$(($MAX_HRS * 60 * 60 / $SLEEP * $LIMIT / $LRU_SIZE))
8413 # Use $LRU_SIZE_B here to take into account real number of locks
8414 # created in the case of CMD, LRU_SIZE_B != $NR in most of cases
8415 local LRU_SIZE_B=$LRU_SIZE
8417 local OLD_LVF=$($LCTL get_param -n $NSDIR.pool.lock_volume_factor)
8418 log "OLD_LVF=$OLD_LVF"
8419 $LCTL set_param -n $NSDIR.pool.lock_volume_factor $LVF
8421 # Let's make sure that we really have some margin. Client checks
8422 # cached locks every 10 sec.
8424 log "Sleep ${SLEEP} sec"
8426 while ((SEC<$SLEEP)); do
8430 LRU_SIZE=$($LCTL get_param -n $NSDIR/lru_size)
8434 $LCTL set_param -n $NSDIR.pool.lock_volume_factor $OLD_LVF
8435 local LRU_SIZE_A=$($LCTL get_param -n $NSDIR.lru_size)
8437 [[ $LRU_SIZE_B -gt $LRU_SIZE_A ]] || {
8438 error "No locks dropped in ${SLEEP}s. LRU size: $LRU_SIZE_A"
8439 unlinkmany $DIR/$tdir/f $NR
8443 log "Dropped "$((LRU_SIZE_B-LRU_SIZE_A))" locks in ${SLEEP}s"
8444 log "unlink $NR files at $DIR/$tdir"
8445 unlinkmany $DIR/$tdir/f $NR
8447 run_test 124a "lru resize ======================================="
8449 get_max_pool_limit()
8451 local limit=$($LCTL get_param \
8452 -n ldlm.namespaces.*-MDT0000-mdc-*.pool.limit)
8455 if [[ $l -gt $max ]]; then
8463 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8464 [ -z "$($LCTL get_param -n mdc.*.connect_flags | grep lru_resize)" ] &&
8465 skip "no lru resize on server" && return 0
8467 LIMIT=$(get_max_pool_limit)
8469 NR=$(($(default_lru_size)*20))
8470 if [[ $NR -gt $LIMIT ]]; then
8471 log "Limit lock number by $LIMIT locks"
8474 lru_resize_disable mdc
8475 test_mkdir -p $DIR/$tdir/disable_lru_resize ||
8476 error "failed to create $DIR/$tdir/disable_lru_resize"
8478 createmany -o $DIR/$tdir/disable_lru_resize/f $NR
8479 log "doing ls -la $DIR/$tdir/disable_lru_resize 3 times"
8480 cancel_lru_locks mdc
8483 ls -la $DIR/$tdir/disable_lru_resize > /dev/null &
8486 ls -la $DIR/$tdir/disable_lru_resize > /dev/null &
8489 ls -la $DIR/$tdir/disable_lru_resize > /dev/null &
8493 nolruresize_delta=$((etime-stime))
8494 log "ls -la time: $nolruresize_delta seconds"
8495 log "lru_size = $(lctl get_param -n ldlm.namespaces.*mdc*.lru_size)"
8496 unlinkmany $DIR/$tdir/disable_lru_resize/f $NR
8498 lru_resize_enable mdc
8499 test_mkdir -p $DIR/$tdir/enable_lru_resize ||
8500 error "failed to create $DIR/$tdir/enable_lru_resize"
8502 createmany -o $DIR/$tdir/enable_lru_resize/f $NR
8503 log "doing ls -la $DIR/$tdir/enable_lru_resize 3 times"
8504 cancel_lru_locks mdc
8507 ls -la $DIR/$tdir/enable_lru_resize > /dev/null &
8510 ls -la $DIR/$tdir/enable_lru_resize > /dev/null &
8513 ls -la $DIR/$tdir/enable_lru_resize > /dev/null &
8517 lruresize_delta=$((etime-stime))
8518 log "ls -la time: $lruresize_delta seconds"
8519 log "lru_size = $(lctl get_param -n ldlm.namespaces.*mdc*.lru_size)"
8521 if [ $lruresize_delta -gt $nolruresize_delta ]; then
8522 log "ls -la is $(((lruresize_delta - $nolruresize_delta) * 100 / $nolruresize_delta))% slower with lru resize enabled"
8523 elif [ $nolruresize_delta -gt $lruresize_delta ]; then
8524 log "ls -la is $(((nolruresize_delta - $lruresize_delta) * 100 / $nolruresize_delta))% faster with lru resize enabled"
8526 log "lru resize performs the same with no lru resize"
8528 unlinkmany $DIR/$tdir/enable_lru_resize/f $NR
8530 run_test 124b "lru resize (performance test) ======================="
8533 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8534 [ -z "$($LCTL get_param -n mdc.*.connect_flags | grep lru_resize)" ] &&
8535 skip "no lru resize on server" && return 0
8537 # cache ununsed locks on client
8539 cancel_lru_locks mdc
8540 test_mkdir -p $DIR/$tdir || error "failed to create $DIR/$tdir"
8541 createmany -o $DIR/$tdir/f $nr ||
8542 error "failed to create $nr files in $DIR/$tdir"
8543 ls -l $DIR/$tdir > /dev/null
8545 local nsdir="ldlm.namespaces.*-MDT0000-mdc-*"
8546 local unused=$($LCTL get_param -n $nsdir.lock_unused_count)
8547 local max_age=$($LCTL get_param -n $nsdir.lru_max_age)
8548 local recalc_p=$($LCTL get_param -n $nsdir.pool.recalc_period)
8549 echo "unused=$unused, max_age=$max_age, recalc_p=$recalc_p"
8551 # set lru_max_age to 1 sec
8552 $LCTL set_param $nsdir.lru_max_age=1000 # jiffies
8553 echo "sleep $((recalc_p * 2)) seconds..."
8554 sleep $((recalc_p * 2))
8556 local remaining=$($LCTL get_param -n $nsdir.lock_unused_count)
8557 # restore lru_max_age
8558 $LCTL set_param -n $nsdir.lru_max_age $max_age
8559 [ $remaining -eq 0 ] || error "$remaining locks are not canceled"
8560 unlinkmany $DIR/$tdir/f $nr
8562 run_test 124c "LRUR cancel very aged locks"
8564 test_125() { # 13358
8565 [ -z "$(lctl get_param -n llite.*.client_type | grep local)" ] && skip "must run as local client" && return
8566 [ -z "$(lctl get_param -n mdc.*-mdc-*.connect_flags | grep acl)" ] && skip "must have acl enabled" && return
8567 [ -z "$(which setfacl)" ] && skip "must have setfacl tool" && return
8568 test_mkdir -p $DIR/d125 || error "mkdir failed"
8569 $SETSTRIPE -S 65536 -c -1 $DIR/d125 || error "setstripe failed"
8570 setfacl -R -m u:bin:rwx $DIR/d125 || error "setfacl $DIR/d125 failed"
8571 ls -ld $DIR/d125 || error "cannot access $DIR/d125"
8573 run_test 125 "don't return EPROTO when a dir has a non-default striping and ACLs"
8575 test_126() { # bug 12829/13455
8576 [ -z "$(lctl get_param -n llite.*.client_type | grep local)" ] && skip "must run as local client" && return
8577 [ "$UID" != 0 ] && skip_env "skipping $TESTNAME (must run as root)" && return
8578 $GSS && skip "must run as gss disabled" && return
8580 $RUNAS -u 0 -g 1 touch $DIR/$tfile || error "touch failed"
8581 gid=`ls -n $DIR/$tfile | awk '{print $4}'`
8583 [ $gid -eq "1" ] || error "gid is set to" $gid "instead of 1"
8585 run_test 126 "check that the fsgid provided by the client is taken into account"
8587 test_127a() { # bug 15521
8588 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8589 $SETSTRIPE -i 0 -c 1 $DIR/$tfile || error "setstripe failed"
8590 $LCTL set_param osc.*.stats=0
8591 FSIZE=$((2048 * 1024))
8592 dd if=/dev/zero of=$DIR/$tfile bs=$FSIZE count=1
8593 cancel_lru_locks osc
8594 dd if=$DIR/$tfile of=/dev/null bs=$FSIZE
8596 $LCTL get_param osc.*0000-osc-*.stats | grep samples > $DIR/${tfile}.tmp
8597 while read NAME COUNT SAMP UNIT MIN MAX SUM SUMSQ; do
8598 echo "got $COUNT $NAME"
8599 [ ! $MIN ] && error "Missing min value for $NAME proc entry"
8600 eval $NAME=$COUNT || error "Wrong proc format"
8603 read_bytes|write_bytes)
8604 [ $MIN -lt 4096 ] && error "min is too small: $MIN"
8605 [ $MIN -gt $FSIZE ] && error "min is too big: $MIN"
8606 [ $MAX -lt 4096 ] && error "max is too small: $MAX"
8607 [ $MAX -gt $FSIZE ] && error "max is too big: $MAX"
8608 [ $SUM -ne $FSIZE ] && error "sum is wrong: $SUM"
8609 [ $SUMSQ -lt $(((FSIZE /4096) * (4096 * 4096))) ] &&
8610 error "sumsquare is too small: $SUMSQ"
8611 [ $SUMSQ -gt $((FSIZE * FSIZE)) ] &&
8612 error "sumsquare is too big: $SUMSQ"
8616 done < $DIR/${tfile}.tmp
8618 #check that we actually got some stats
8619 [ "$read_bytes" ] || error "Missing read_bytes stats"
8620 [ "$write_bytes" ] || error "Missing write_bytes stats"
8621 [ "$read_bytes" != 0 ] || error "no read done"
8622 [ "$write_bytes" != 0 ] || error "no write done"
8624 run_test 127a "verify the client stats are sane"
8626 test_127b() { # bug LU-333
8627 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8628 $LCTL set_param llite.*.stats=0
8629 FSIZE=65536 # sized fixed to match PAGE_SIZE for most clients
8630 # perform 2 reads and writes so MAX is different from SUM.
8631 dd if=/dev/zero of=$DIR/$tfile bs=$FSIZE count=1
8632 dd if=/dev/zero of=$DIR/$tfile bs=$FSIZE count=1
8633 cancel_lru_locks osc
8634 dd if=$DIR/$tfile of=/dev/null bs=$FSIZE count=1
8635 dd if=$DIR/$tfile of=/dev/null bs=$FSIZE count=1
8637 $LCTL get_param llite.*.stats | grep samples > $TMP/${tfile}.tmp
8638 while read NAME COUNT SAMP UNIT MIN MAX SUM SUMSQ; do
8639 echo "got $COUNT $NAME"
8640 eval $NAME=$COUNT || error "Wrong proc format"
8644 [ $COUNT -ne 2 ] && error "count is not 2: $COUNT"
8645 [ $MIN -ne $FSIZE ] && error "min is not $FSIZE: $MIN"
8646 [ $MAX -ne $FSIZE ] && error "max is incorrect: $MAX"
8647 [ $SUM -ne $((FSIZE * 2)) ] && error "sum is wrong: $SUM"
8650 [ $COUNT -ne 2 ] && error "count is not 2: $COUNT"
8651 [ $MIN -ne $FSIZE ] && error "min is not $FSIZE: $MIN"
8652 [ $MAX -ne $FSIZE ] && error "max is incorrect: $MAX"
8653 [ $SUM -ne $((FSIZE * 2)) ] && error "sum is wrong: $SUM"
8657 done < $TMP/${tfile}.tmp
8659 #check that we actually got some stats
8660 [ "$read_bytes" ] || error "Missing read_bytes stats"
8661 [ "$write_bytes" ] || error "Missing write_bytes stats"
8662 [ "$read_bytes" != 0 ] || error "no read done"
8663 [ "$write_bytes" != 0 ] || error "no write done"
8665 run_test 127b "verify the llite client stats are sane"
8667 test_128() { # bug 15212
8669 $LFS 2>&1 <<-EOF | tee $TMP/$tfile.log
8674 result=$(grep error $TMP/$tfile.log)
8676 [ -z "$result" ] || error "consecutive find's under interactive lfs failed"
8678 run_test 128 "interactive lfs for 2 consecutive find's"
8685 local LDPROC=/proc/fs/ldiskfs
8686 local facets=$(get_facets MDS)
8688 for facet in ${facets//,/ }; do
8689 canondev=$(ldiskfs_canon \
8690 *.$(convert_facet2label $facet).mntdev $facet)
8691 do_facet $facet "test -e $LDPROC/$canondev/max_dir_size" ||
8692 LDPROC=/sys/fs/ldiskfs
8693 do_facet $facet "echo $1 >$LDPROC/$canondev/max_dir_size"
8694 do_facet $facet "test -e $LDPROC/$canondev/warning_dir_size" ||
8695 LDPROC=/sys/fs/ldiskfs
8696 do_facet $facet "echo $2 >$LDPROC/$canondev/warning_dir_size"
8701 local facets=$(get_facets MDS)
8702 for facet in ${facets//,/ }; do
8703 do_facet $facet "dmesg | tail -3 | grep -q $1" && return 0
8709 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8710 if [ "$(facet_fstype $SINGLEMDS)" != ldiskfs ]; then
8711 skip "Only applicable to ldiskfs-based MDTs"
8714 remote_mds_nodsh && skip "remote MDS with nodsh" && return
8722 # block size of mds1
8723 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
8724 local MDSBLOCKSIZE=$($LCTL get_param -n mdc.*MDT0000*.blocksize)
8725 local MAX=$((MDSBLOCKSIZE * 5))
8726 set_dir_limits $MAX $MAX
8727 local I=$(stat -c%s "$DIR/$tdir")
8729 while [[ $I -le $MAX ]]; do
8730 $MULTIOP $DIR/$tdir/$J Oc
8732 if [ $has_warning -eq 0 ]; then
8733 check_mds_dmesg '"is approaching"' &&
8736 #check two errors ENOSPC for new version of ext4 max_dir_size patch
8737 #mainline kernel commit df981d03eeff7971ac7e6ff37000bfa702327ef1
8738 #and EFBIG for previous versions
8739 if [ $rc -eq $EFBIG -o $rc -eq $ENOSPC ]; then
8741 echo "return code $rc received as expected"
8743 createmany -o $DIR/$tdir/$J_file_ 1000 ||
8744 error_exit "create failed w/o dir size limit"
8746 check_mds_dmesg '"has reached"' ||
8747 error_exit "has reached message should be output"
8750 error_exit "warning message should be output"
8752 I=$(stat -c%s "$DIR/$tdir")
8754 if [ $(lustre_version_code $SINGLEMDS) -lt \
8755 $(version_code 2.4.51) ]
8757 [[ $I -eq $MAX ]] && return 0
8759 [[ $I -gt $MAX ]] && return 0
8761 error_exit "current dir size $I, previous limit $MAX"
8762 elif [ $rc -ne 0 ]; then
8764 error_exit "return code $rc received instead of expected " \
8765 "$EFBIG or $ENOSPC, files in dir $I"
8768 I=$(stat -c%s "$DIR/$tdir")
8772 error "exceeded dir size limit $MAX($MDSCOUNT) : $I bytes"
8774 run_test 129 "test directory size limit ========================"
8783 local filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
8784 [ -n "$filefrag_op" ] && skip_env "filefrag does not support FIEMAP" &&
8787 trap cleanup_130 EXIT RETURN
8789 local fm_file=$DIR/$tfile
8790 $SETSTRIPE -S 65536 -c 1 $fm_file || error "setstripe on $fm_file"
8791 dd if=/dev/zero of=$fm_file bs=65536 count=1 ||
8792 error "dd failed for $fm_file"
8794 # LU-1795: test filefrag/FIEMAP once, even if unsupported
8795 filefrag -ves $fm_file
8797 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
8798 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
8799 [ $RC != 0 ] && error "filefrag $fm_file failed"
8801 filefrag_op=$(filefrag -ve $fm_file |
8802 sed -n '/ext:/,/found/{/ext:/d; /found/d; p}')
8803 lun=$($GETSTRIPE -i $fm_file)
8805 start_blk=`echo $filefrag_op | cut -d: -f2 | cut -d. -f1`
8808 for line in $filefrag_op
8810 frag_lun=`echo $line | cut -d: -f5`
8811 ext_len=`echo $line | cut -d: -f4`
8812 if (( $frag_lun != $lun )); then
8814 error "FIEMAP on 1-stripe file($fm_file) failed"
8817 (( tot_len += ext_len ))
8820 if (( lun != frag_lun || start_blk != 0 || tot_len != 64 )); then
8822 error "FIEMAP on 1-stripe file($fm_file) failed;"
8828 echo "FIEMAP on single striped file succeeded"
8830 run_test 130a "FIEMAP (1-stripe file)"
8833 [ "$OSTCOUNT" -lt "2" ] &&
8834 skip_env "skipping FIEMAP on $OSTCOUNT-stripe file" && return
8836 local filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
8837 [ -n "$filefrag_op" ] && skip_env "filefrag does not support FIEMAP" &&
8840 trap cleanup_130 EXIT RETURN
8842 local fm_file=$DIR/$tfile
8843 $SETSTRIPE -S 65536 -c $OSTCOUNT $fm_file ||
8844 error "setstripe on $fm_file"
8845 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
8846 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
8848 dd if=/dev/zero of=$fm_file bs=1M count=$OSTCOUNT ||
8849 error "dd failed on $fm_file"
8851 filefrag -ves $fm_file || error "filefrag $fm_file failed"
8852 filefrag_op=$(filefrag -ve $fm_file |
8853 sed -n '/ext:/,/found/{/ext:/d; /found/d; p}')
8855 last_lun=$(echo $filefrag_op | cut -d: -f5 |
8856 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
8861 for line in $filefrag_op
8863 frag_lun=$(echo $line | cut -d: -f5 |
8864 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
8865 ext_len=$(echo $line | cut -d: -f4)
8866 if (( $frag_lun != $last_lun )); then
8867 if (( tot_len != 1024 )); then
8869 error "FIEMAP on $fm_file failed; returned " \
8870 "len $tot_len for OST $last_lun instead of 1024"
8877 (( tot_len += ext_len ))
8880 if (( num_luns != $OSTCOUNT || tot_len != 1024 )); then
8882 error "FIEMAP on $fm_file failed; returned wrong number of " \
8883 "luns or wrong len for OST $last_lun"
8889 echo "FIEMAP on $OSTCOUNT-stripe file succeeded"
8891 run_test 130b "FIEMAP ($OSTCOUNT-stripe file)"
8894 [ "$OSTCOUNT" -lt "2" ] &&
8895 skip_env "skipping FIEMAP on 2-stripe file" && return
8897 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
8898 [ -n "$filefrag_op" ] && skip "filefrag does not support FIEMAP" &&
8901 trap cleanup_130 EXIT RETURN
8903 local fm_file=$DIR/$tfile
8904 $SETSTRIPE -S 65536 -c 2 $fm_file || error "setstripe on $fm_file"
8905 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
8906 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
8908 dd if=/dev/zero of=$fm_file seek=1 bs=1M count=1 ||
8909 error "dd failed on $fm_file"
8911 filefrag -ves $fm_file || error "filefrag $fm_file failed"
8912 filefrag_op=$(filefrag -ve $fm_file |
8913 sed -n '/ext:/,/found/{/ext:/d; /found/d; p}')
8915 last_lun=$(echo $filefrag_op | cut -d: -f5 |
8916 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
8921 for line in $filefrag_op
8923 frag_lun=$(echo $line | cut -d: -f5 |
8924 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
8925 ext_len=$(echo $line | cut -d: -f4)
8926 if (( $frag_lun != $last_lun )); then
8927 logical=`echo $line | cut -d: -f2 | cut -d. -f1`
8928 if (( logical != 512 )); then
8930 error "FIEMAP on $fm_file failed; returned " \
8931 "logical start for lun $logical instead of 512"
8934 if (( tot_len != 512 )); then
8936 error "FIEMAP on $fm_file failed; returned " \
8937 "len $tot_len for OST $last_lun instead of 1024"
8944 (( tot_len += ext_len ))
8947 if (( num_luns != 2 || tot_len != 512 )); then
8949 error "FIEMAP on $fm_file failed; returned wrong number of " \
8950 "luns or wrong len for OST $last_lun"
8956 echo "FIEMAP on 2-stripe file with hole succeeded"
8958 run_test 130c "FIEMAP (2-stripe file with hole)"
8961 [ "$OSTCOUNT" -lt "3" ] &&
8962 skip_env "skipping FIEMAP on N-stripe file test" && return
8964 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
8965 [ -n "$filefrag_op" ] && skip "filefrag does not support FIEMAP" &&
8968 trap cleanup_130 EXIT RETURN
8970 local fm_file=$DIR/$tfile
8971 $SETSTRIPE -S 65536 -c $OSTCOUNT $fm_file ||
8972 error "setstripe on $fm_file"
8973 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
8974 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
8976 local actual_stripecnt=$($GETSTRIPE -c $fm_file)
8977 dd if=/dev/zero of=$fm_file bs=1M count=$actual_stripecnt ||
8978 error "dd failed on $fm_file"
8980 filefrag -ves $fm_file || error "filefrag $fm_file failed"
8981 filefrag_op=$(filefrag -ve $fm_file |
8982 sed -n '/ext:/,/found/{/ext:/d; /found/d; p}')
8984 last_lun=$(echo $filefrag_op | cut -d: -f5 |
8985 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
8990 for line in $filefrag_op
8992 frag_lun=$(echo $line | cut -d: -f5 |
8993 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
8994 ext_len=$(echo $line | cut -d: -f4)
8995 if (( $frag_lun != $last_lun )); then
8996 if (( tot_len != 1024 )); then
8998 error "FIEMAP on $fm_file failed; returned " \
8999 "len $tot_len for OST $last_lun instead of 1024"
9006 (( tot_len += ext_len ))
9009 if (( num_luns != actual_stripecnt || tot_len != 1024 )); then
9011 error "FIEMAP on $fm_file failed; returned wrong number of " \
9012 "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" ] &&
9024 skip_env "skipping continuation FIEMAP test" && return
9026 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
9027 [ -n "$filefrag_op" ] && skip "filefrag does not support FIEMAP" && return
9029 trap cleanup_130 EXIT RETURN
9031 local fm_file=$DIR/$tfile
9032 $SETSTRIPE -S 131072 -c 2 $fm_file || error "setstripe on $fm_file"
9033 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
9034 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
9037 EXPECTED_LEN=$(( (NUM_BLKS / 2) * 64 ))
9038 for ((i = 0; i < $NUM_BLKS; i++))
9040 dd if=/dev/zero of=$fm_file count=1 bs=64k seek=$((2*$i)) conv=notrunc > /dev/null 2>&1
9043 filefrag -ves $fm_file || error "filefrag $fm_file failed"
9044 filefrag_op=$(filefrag -ve $fm_file |
9045 sed -n '/ext:/,/found/{/ext:/d; /found/d; p}')
9047 last_lun=$(echo $filefrag_op | cut -d: -f5 |
9048 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
9053 for line in $filefrag_op
9055 frag_lun=$(echo $line | cut -d: -f5 |
9056 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
9057 ext_len=$(echo $line | cut -d: -f4)
9058 if (( $frag_lun != $last_lun )); then
9059 if (( tot_len != $EXPECTED_LEN )); then
9061 error "FIEMAP on $fm_file failed; returned " \
9062 "len $tot_len for OST $last_lun instead " \
9070 (( tot_len += ext_len ))
9073 if (( num_luns != 2 || tot_len != $EXPECTED_LEN )); then
9075 error "FIEMAP on $fm_file failed; returned wrong number " \
9076 "of luns or wrong len for OST $last_lun"
9082 echo "FIEMAP with continuation calls succeeded"
9084 run_test 130e "FIEMAP (test continuation FIEMAP calls)"
9086 # Test for writev/readv
9088 rwv -f $DIR/$tfile -w -n 3 524288 1048576 1572864 || \
9089 error "writev test failed"
9090 rwv -f $DIR/$tfile -r -v -n 2 1572864 1048576 || \
9091 error "readv failed"
9094 run_test 131a "test iov's crossing stripe boundary for writev/readv"
9097 rwv -f $DIR/$tfile -w -a -n 3 524288 1048576 1572864 || \
9098 error "append writev test failed"
9099 rwv -f $DIR/$tfile -w -a -n 2 1572864 1048576 || \
9100 error "append writev test failed"
9103 run_test 131b "test append writev"
9106 rwv -f $DIR/$tfile -w -d -n 1 1048576 || return 0
9109 run_test 131c "test read/write on file w/o objects"
9112 rwv -f $DIR/$tfile -w -n 1 1572864
9113 NOB=`rwv -f $DIR/$tfile -r -n 3 524288 524288 1048576 | awk '/error/ {print $6}'`
9114 if [ "$NOB" != 1572864 ]; then
9115 error "Short read filed: read $NOB bytes instead of 1572864"
9119 run_test 131d "test short read"
9122 rwv -f $DIR/$tfile -w -s 1048576 -n 1 1048576
9123 rwv -f $DIR/$tfile -r -z -s 0 -n 1 524288 || \
9124 error "read hitting hole failed"
9127 run_test 131e "test read hitting hole"
9133 $SINGLEMDS) res=`do_facet $SINGLEMDS $LCTL get_param mdt.$FSNAME-MDT0000.md_stats | grep "$2"`
9135 ost) res=`do_facet ost1 $LCTL get_param obdfilter.$FSNAME-OST0000.stats | grep "$2"`
9137 *) error "Wrong argument $1" ;;
9140 [ -z "$res" ] && error "The counter for $2 on $1 was not incremented"
9141 # if the argument $3 is zero, it means any stat increment is ok.
9142 if [[ $3 -gt 0 ]]; then
9143 count=$(echo $res | awk '{ print $2 }')
9144 [[ $count -ne $3 ]] &&
9145 error "The $2 counter on $1 is wrong - expected $3"
9150 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9151 remote_ost_nodsh && skip "remote OST with nodsh" && return
9152 remote_mds_nodsh && skip "remote MDS with nodsh" && return
9154 do_facet $SINGLEMDS $LCTL list_param mdt.*.rename_stats ||
9155 { skip "MDS doesn't support rename stats"; return; }
9156 local testdir=$DIR/${tdir}/stats_testdir
9157 mkdir -p $DIR/${tdir}
9160 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
9161 do_facet ost1 $LCTL set_param obdfilter.*.stats=clear
9163 # verify mdt stats first.
9164 mkdir ${testdir} || error "mkdir failed"
9165 check_stats $SINGLEMDS "mkdir" 1
9166 touch ${testdir}/${tfile} || "touch failed"
9167 check_stats $SINGLEMDS "open" 1
9168 check_stats $SINGLEMDS "close" 1
9169 mknod ${testdir}/${tfile}-pipe p || "mknod failed"
9170 check_stats $SINGLEMDS "mknod" 1
9171 rm -f ${testdir}/${tfile}-pipe || "pipe remove failed"
9172 check_stats $SINGLEMDS "unlink" 1
9173 rm -f ${testdir}/${tfile} || error "file remove failed"
9174 check_stats $SINGLEMDS "unlink" 2
9176 # remove working dir and check mdt stats again.
9177 rmdir ${testdir} || error "rmdir failed"
9178 check_stats $SINGLEMDS "rmdir" 1
9180 local testdir1=$DIR/${tdir}/stats_testdir1
9182 mkdir -p ${testdir1}
9183 touch ${testdir1}/test1
9184 mv ${testdir1}/test1 ${testdir} || error "file crossdir rename"
9185 check_stats $SINGLEMDS "crossdir_rename" 1
9187 mv ${testdir}/test1 ${testdir}/test0 || error "file samedir rename"
9188 check_stats $SINGLEMDS "samedir_rename" 1
9192 run_test 133a "Verifying MDT stats ========================================"
9195 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9196 remote_ost_nodsh && skip "remote OST with nodsh" && return
9197 remote_mds_nodsh && skip "remote MDS with nodsh" && return
9198 local testdir=$DIR/${tdir}/stats_testdir
9199 mkdir -p ${testdir} || error "mkdir failed"
9200 touch ${testdir}/${tfile} || "touch failed"
9201 cancel_lru_locks mdc
9204 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
9205 do_facet ost1 $LCTL set_param obdfilter.*.stats=clear
9207 # extra mdt stats verification.
9208 chmod 444 ${testdir}/${tfile} || error "chmod failed"
9209 check_stats $SINGLEMDS "setattr" 1
9210 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
9211 if [ $(lustre_version_code $SINGLEMDS) -ne $(version_code 2.2.0) ]
9213 ls -l ${testdir}/${tfile} > /dev/null|| error "ls failed"
9214 check_stats $SINGLEMDS "getattr" 1
9216 $LFS df || error "lfs failed"
9217 check_stats $SINGLEMDS "statfs" 1
9221 run_test 133b "Verifying extra MDT stats =================================="
9224 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9225 remote_ost_nodsh && skip "remote OST with nodsh" && return
9226 remote_mds_nodsh && skip "remote MDS with nodsh" && return
9227 local testdir=$DIR/${tdir}/stats_testdir
9228 test_mkdir -p ${testdir} || error "mkdir failed"
9230 # verify obdfilter stats.
9231 $SETSTRIPE -c 1 -i 0 ${testdir}/${tfile}
9233 cancel_lru_locks osc
9234 wait_delete_completed
9237 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
9238 do_facet ost1 $LCTL set_param obdfilter.*.stats=clear
9240 dd if=/dev/zero of=${testdir}/${tfile} conv=notrunc bs=512k count=1 || error "dd failed"
9242 cancel_lru_locks osc
9243 check_stats ost "write" 1
9245 dd if=${testdir}/${tfile} of=/dev/null bs=1k count=1 || error "dd failed"
9246 check_stats ost "read" 1
9248 > ${testdir}/${tfile} || error "truncate failed"
9249 check_stats ost "punch" 1
9251 rm -f ${testdir}/${tfile} || error "file remove failed"
9252 wait_delete_completed
9253 check_stats ost "destroy" 1
9257 run_test 133c "Verifying OST stats ========================================"
9264 while [ $value -ge 2 ]; do
9269 if [ $orig -gt $order ]; then
9277 local size=('K' 'M' 'G' 'T');
9279 local size_string=$value
9281 while [ $value -ge 1024 ]; do
9282 if [ $i -gt 3 ]; then
9283 #T is the biggest unit we get here, if that is bigger,
9285 size_string=${value}T
9288 value=$((value >> 10))
9289 if [ $value -lt 1024 ]; then
9290 size_string=${value}${size[$i]}
9301 local context=${2:-.}
9302 local sample=$(do_facet $SINGLEMDS $LCTL get_param mdt.*.rename_stats |
9304 awk '/ '${size}'/ {print $4}' | sed -e "s/,//g")
9309 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9310 remote_ost_nodsh && skip "remote OST with nodsh" && return
9311 remote_mds_nodsh && skip "remote MDS with nodsh" && return
9312 do_facet $SINGLEMDS $LCTL list_param mdt.*.rename_stats ||
9313 { skip "MDS doesn't support rename stats"; return; }
9315 local testdir1=$DIR/${tdir}/stats_testdir1
9316 local testdir2=$DIR/${tdir}/stats_testdir2
9318 do_facet $SINGLEMDS $LCTL set_param mdt.*.rename_stats=clear
9320 mkdir -p ${testdir1} || error "mkdir failed"
9321 mkdir -p ${testdir2} || error "mkdir failed"
9323 createmany -o $testdir1/test 512 || error "createmany failed"
9325 # check samedir rename size
9326 mv ${testdir1}/test0 ${testdir1}/test_0
9328 local testdir1_size=$(ls -l $DIR/${tdir} |
9329 awk '/stats_testdir1/ {print $5}')
9330 local testdir2_size=$(ls -l $DIR/${tdir} |
9331 awk '/stats_testdir2/ {print $5}')
9333 testdir1_size=$(order_2 $testdir1_size)
9334 testdir2_size=$(order_2 $testdir2_size)
9336 testdir1_size=$(size_in_KMGT $testdir1_size)
9337 testdir2_size=$(size_in_KMGT $testdir2_size)
9339 echo "source rename dir size: ${testdir1_size}"
9340 echo "target rename dir size: ${testdir2_size}"
9342 local cmd="do_facet $SINGLEMDS $LCTL get_param mdt.*.rename_stats"
9343 eval $cmd || error "$cmd failed"
9344 local samedir=$($cmd | grep 'same_dir')
9345 local same_sample=$(get_rename_size $testdir1_size)
9346 [ -z "$samedir" ] && error "samedir_rename_size count error"
9347 [[ $same_sample -eq 1 ]] ||
9348 error "samedir_rename_size error $same_sample"
9349 echo "Check same dir rename stats success"
9351 do_facet $SINGLEMDS $LCTL set_param mdt.*.rename_stats=clear
9353 # check crossdir rename size
9354 mv ${testdir1}/test_0 ${testdir2}/test_0
9356 testdir1_size=$(ls -l $DIR/${tdir} |
9357 awk '/stats_testdir1/ {print $5}')
9358 testdir2_size=$(ls -l $DIR/${tdir} |
9359 awk '/stats_testdir2/ {print $5}')
9361 testdir1_size=$(order_2 $testdir1_size)
9362 testdir2_size=$(order_2 $testdir2_size)
9364 testdir1_size=$(size_in_KMGT $testdir1_size)
9365 testdir2_size=$(size_in_KMGT $testdir2_size)
9367 echo "source rename dir size: ${testdir1_size}"
9368 echo "target rename dir size: ${testdir2_size}"
9370 eval $cmd || error "$cmd failed"
9371 local crossdir=$($cmd | grep 'crossdir')
9372 local src_sample=$(get_rename_size $testdir1_size crossdir_src)
9373 local tgt_sample=$(get_rename_size $testdir2_size crossdir_tgt)
9374 [ -z "$crossdir" ] && error "crossdir_rename_size count error"
9375 [[ $src_sample -eq 1 ]] ||
9376 error "crossdir_rename_size error $src_sample"
9377 [[ $tgt_sample -eq 1 ]] ||
9378 error "crossdir_rename_size error $tgt_sample"
9379 echo "Check cross dir rename stats success"
9382 run_test 133d "Verifying rename_stats ========================================"
9385 remote_mds_nodsh && skip "remote MDS with nodsh" && return
9386 remote_ost_nodsh && skip "remote OST with nodsh" && return
9387 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9388 local testdir=$DIR/${tdir}/stats_testdir
9389 local ctr f0 f1 bs=32768 count=42 sum
9391 mkdir -p ${testdir} || error "mkdir failed"
9393 $SETSTRIPE -c 1 -i 0 ${testdir}/${tfile}
9395 for ctr in {write,read}_bytes; do
9397 cancel_lru_locks osc
9399 do_facet ost1 $LCTL set_param -n \
9400 "obdfilter.*.exports.clear=clear"
9402 if [ $ctr = write_bytes ]; then
9404 f1=${testdir}/${tfile}
9406 f0=${testdir}/${tfile}
9410 dd if=$f0 of=$f1 conv=notrunc bs=$bs count=$count || \
9413 cancel_lru_locks osc
9415 sum=$(do_facet ost1 $LCTL get_param \
9416 "obdfilter.*.exports.*.stats" |
9417 awk -v ctr=$ctr 'BEGIN { sum = 0 }
9418 $1 == ctr { sum += $7 }
9419 END { printf("%0.0f", sum) }')
9421 if ((sum != bs * count)); then
9422 error "Bad $ctr sum, expected $((bs * count)), got $sum"
9428 run_test 133e "Verifying OST {read,write}_bytes nid stats ================="
9431 for dir in /proc/fs/lustre/ /proc/sys/lnet/ /proc/sys/lustre/ \
9432 /sys/fs/lustre/ /sys/fs/lnet/ /sys/kernel/debug/lnet/ \
9433 /sys/kernel/debug/lustre/; do
9434 [[ -d $dir ]] && proc_dirs+=" $dir"
9438 remote_mds_nodsh && skip "remote MDS with nodsh" && return
9439 remote_ost_nodsh && skip "remote OST with nodsh" && return
9440 # First without trusting modes.
9441 find $proc_dirs -exec cat '{}' \; &> /dev/null
9443 # Second verifying readability.
9444 $LCTL get_param -R '*' &> /dev/null || error "proc file read failed"
9446 # eventually, this can also be replaced with "lctl get_param -R",
9447 # but not until that option is always available on the server
9449 for facet in $SINGLEMDS ost1; do
9450 do_facet $facet find $proc_dirs \
9451 ! -name req_history \
9452 -exec cat '{}' \\\; &> /dev/null
9454 do_facet $facet find $proc_dirs \
9455 ! -name req_history \
9457 -exec cat '{}' \\\; &> /dev/null ||
9458 error "proc file read failed"
9461 run_test 133f "Check for LBUGs/Oopses/unreadable files in /proc"
9464 # Second verifying writability.
9467 -not -name force_lbug \
9468 -not -name changelog_mask \
9469 -exec badarea_io '{}' \; &> /dev/null ||
9470 error "find $proc_dirs failed"
9472 [ $(lustre_version_code $SINGLEMDS) -le $(version_code 2.5.54) ] &&
9473 skip "Too old lustre on MDS" && return
9475 [ $(lustre_version_code ost1) -le $(version_code 2.5.54) ] &&
9476 skip "Too old lustre on ost1" && return
9479 for facet in $SINGLEMDS ost1; do
9480 do_facet $facet find $proc_dirs \
9482 -not -name force_lbug \
9483 -not -name changelog_mask \
9484 -exec badarea_io '{}' \\\; &> /dev/null ||
9485 error "$facet find $proc_dirs failed"
9489 # remount the FS in case writes/reads /proc break the FS
9490 cleanup || error "failed to unmount"
9491 setup || error "failed to setup"
9494 run_test 133g "Check for Oopses on bad io area writes/reads in /proc"
9497 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.54) ]] &&
9498 skip "Need MDS version at least 2.7.54" && return
9500 mkdir -p $DIR/$tdir || error "failed to create $DIR/$tdir"
9501 cancel_lru_locks mdc
9503 local nsdir="ldlm.namespaces.*-MDT0000-mdc-*"
9504 local unused=$($LCTL get_param -n $nsdir.lock_unused_count)
9505 [ $unused -eq 0 ] || "$unused locks are not cleared"
9508 createmany -o $DIR/$tdir/f $nr ||
9509 error "failed to create $nr files in $DIR/$tdir"
9510 unused=$($LCTL get_param -n $nsdir.lock_unused_count)
9512 #define OBD_FAIL_LDLM_WATERMARK_LOW 0x327
9513 do_facet mds1 $LCTL set_param fail_loc=0x327
9514 do_facet mds1 $LCTL set_param fail_val=500
9517 echo "sleep 10 seconds ..."
9519 local lck_cnt=$($LCTL get_param -n $nsdir.lock_unused_count)
9521 do_facet mds1 $LCTL set_param fail_loc=0
9522 do_facet mds1 $LCTL set_param fail_val=0
9523 [ $lck_cnt -lt $unused ] ||
9524 error "No locks reclaimed, before:$unused, after:$lck_cnt"
9527 unlinkmany $DIR/$tdir/f $nr
9529 run_test 134a "Server reclaims locks when reaching lock_reclaim_threshold"
9532 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.54) ]] &&
9533 skip "Need MDS version at least 2.7.54" && return
9535 mkdir -p $DIR/$tdir || error "failed to create $DIR/$tdir"
9536 cancel_lru_locks mdc
9538 local low_wm=$(do_facet mds1 $LCTL get_param -n \
9539 ldlm.lock_reclaim_threshold_mb)
9540 # disable reclaim temporarily
9541 do_facet mds1 $LCTL set_param ldlm.lock_reclaim_threshold_mb=0
9543 #define OBD_FAIL_LDLM_WATERMARK_HIGH 0x328
9544 do_facet mds1 $LCTL set_param fail_loc=0x328
9545 do_facet mds1 $LCTL set_param fail_val=500
9547 $LCTL set_param debug=+trace
9550 createmany -o $DIR/$tdir/f $nr &
9553 echo "Sleep $TIMEOUT seconds ..."
9555 if ! ps -p $create_pid > /dev/null 2>&1; then
9556 do_facet mds1 $LCTL set_param fail_loc=0
9557 do_facet mds1 $LCTL set_param fail_val=0
9558 do_facet mds1 $LCTL set_param \
9559 ldlm.lock_reclaim_threshold_mb=${low_wm}m
9560 error "createmany finished incorrectly!"
9562 do_facet mds1 $LCTL set_param fail_loc=0
9563 do_facet mds1 $LCTL set_param fail_val=0
9564 do_facet mds1 $LCTL set_param ldlm.lock_reclaim_threshold_mb=${low_wm}m
9565 wait $create_pid || return 1
9567 unlinkmany $DIR/$tdir/f $nr
9569 run_test 134b "Server rejects lock request when reaching lock_limit_mb"
9571 test_140() { #bug-17379
9572 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9573 test_mkdir -p $DIR/$tdir || error "Creating dir $DIR/$tdir"
9574 cd $DIR/$tdir || error "Changing to $DIR/$tdir"
9575 cp /usr/bin/stat . || error "Copying stat to $DIR/$tdir"
9577 # VFS limits max symlink depth to 5(4KSTACK) or 7(8KSTACK) or 8
9578 # For kernel > 3.5, bellow only tests consecutive symlink (MAX 40)
9580 while i=`expr $i + 1`; do
9581 test_mkdir -p $i || error "Creating dir $i"
9582 cd $i || error "Changing to $i"
9583 ln -s ../stat stat || error "Creating stat symlink"
9584 # Read the symlink until ELOOP present,
9585 # not LBUGing the system is considered success,
9586 # we didn't overrun the stack.
9587 $OPENFILE -f O_RDONLY stat >/dev/null 2>&1; ret=$?
9589 if [ $ret -eq 40 ]; then
9592 error "Open stat symlink"
9598 echo "The symlink depth = $i"
9599 [ $i -eq 5 -o $i -eq 7 -o $i -eq 8 -o $i -eq 40 ] ||
9600 error "Invalid symlink depth"
9602 # Test recursive symlink
9603 ln -s symlink_self symlink_self
9604 $OPENFILE -f O_RDONLY symlink_self >/dev/null 2>&1; ret=$?
9605 echo "open symlink_self returns $ret"
9606 [ $ret -eq 40 ] || error "recursive symlink doesn't return -ELOOP"
9608 run_test 140 "Check reasonable stack depth (shouldn't LBUG) ===="
9611 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9612 local TF="$TMP/$tfile"
9614 dd if=/dev/urandom of=$TF bs=6096 count=1 || error "dd failed"
9616 cancel_lru_locks osc
9617 cmp $TF $DIR/$tfile || error "$TMP/$tfile $DIR/$tfile differ"
9618 remount_client $MOUNT
9620 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (remount)"
9623 $TRUNCATE $DIR/$tfile 6000
9624 cancel_lru_locks osc
9625 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (truncate1)"
9628 echo "12345" >>$DIR/$tfile
9629 cancel_lru_locks osc
9630 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (append1)"
9633 echo "12345" >>$DIR/$tfile
9634 cancel_lru_locks osc
9635 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (append2)"
9640 run_test 150 "truncate/append tests"
9642 #LU-2902 roc_hit was not able to read all values from lproc
9643 function roc_hit_init() {
9644 local list=$(comma_list $(osts_nodes))
9645 local dir=$DIR/$tdir-check
9646 local file=$dir/file
9652 #use setstripe to do a write to every ost
9653 for i in $(seq 0 $((OSTCOUNT-1))); do
9654 $SETSTRIPE -c 1 -i $i $dir || error "$SETSTRIPE $file failed"
9655 dd if=/dev/urandom of=$file bs=4k count=4 2>&1 > /dev/null
9656 idx=$(printf %04x $i)
9657 BEFORE=$(get_osd_param $list *OST*$idx stats |
9658 awk '$1 == "cache_access" {sum += $7}
9659 END { printf("%0.0f", sum) }')
9661 cancel_lru_locks osc
9662 cat $file >/dev/null
9664 AFTER=$(get_osd_param $list *OST*$idx stats |
9665 awk '$1 == "cache_access" {sum += $7}
9666 END { printf("%0.0f", sum) }')
9668 echo BEFORE:$BEFORE AFTER:$AFTER
9669 if ! let "AFTER - BEFORE == 4"; then
9671 error "roc_hit is not safe to use"
9679 function roc_hit() {
9680 local list=$(comma_list $(osts_nodes))
9681 echo $(get_osd_param $list '' stats |
9682 awk '$1 == "cache_hit" {sum += $7}
9683 END { printf("%0.0f", sum) }')
9686 function set_cache() {
9689 if [ "$2" == "off" ]; then
9692 local list=$(comma_list $(osts_nodes))
9693 set_osd_param $list '' $1_cache_enable $on
9695 cancel_lru_locks osc
9699 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9700 remote_ost_nodsh && skip "remote OST with nodsh" && return
9703 local list=$(comma_list $(osts_nodes))
9705 # check whether obdfilter is cache capable at all
9706 if ! get_osd_param $list '' read_cache_enable >/dev/null; then
9707 echo "not cache-capable obdfilter"
9711 # check cache is enabled on all obdfilters
9712 if get_osd_param $list '' read_cache_enable | grep 0; then
9713 echo "oss cache is disabled"
9717 set_osd_param $list '' writethrough_cache_enable 1
9719 # check write cache is enabled on all obdfilters
9720 if get_osd_param $list '' writethrough_cache_enable | grep 0; then
9721 echo "oss write cache is NOT enabled"
9727 #define OBD_FAIL_OBD_NO_LRU 0x609
9728 do_nodes $list $LCTL set_param fail_loc=0x609
9730 # pages should be in the case right after write
9731 dd if=/dev/urandom of=$DIR/$tfile bs=4k count=$CPAGES ||
9734 local BEFORE=$(roc_hit)
9735 cancel_lru_locks osc
9736 cat $DIR/$tfile >/dev/null
9737 local AFTER=$(roc_hit)
9739 do_nodes $list $LCTL set_param fail_loc=0
9741 if ! let "AFTER - BEFORE == CPAGES"; then
9742 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
9745 # the following read invalidates the cache
9746 cancel_lru_locks osc
9747 set_osd_param $list '' read_cache_enable 0
9748 cat $DIR/$tfile >/dev/null
9750 # now data shouldn't be found in the cache
9752 cancel_lru_locks osc
9753 cat $DIR/$tfile >/dev/null
9755 if let "AFTER - BEFORE != 0"; then
9756 error "IN CACHE: before: $BEFORE, after: $AFTER"
9759 set_osd_param $list '' read_cache_enable 1
9762 run_test 151 "test cache on oss and controls ==============================="
9765 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9766 local TF="$TMP/$tfile"
9768 # simulate ENOMEM during write
9769 #define OBD_FAIL_OST_NOMEM 0x226
9770 lctl set_param fail_loc=0x80000226
9771 dd if=/dev/urandom of=$TF bs=6096 count=1 || error "dd failed"
9773 sync || error "sync failed"
9774 lctl set_param fail_loc=0
9776 # discard client's cache
9777 cancel_lru_locks osc
9779 # simulate ENOMEM during read
9780 lctl set_param fail_loc=0x80000226
9781 cmp $TF $DIR/$tfile || error "cmp failed"
9782 lctl set_param fail_loc=0
9786 run_test 152 "test read/write with enomem ============================"
9789 $MULTIOP $DIR/$tfile Ow4096Ycu || error "multiop failed"
9791 run_test 153 "test if fdatasync does not crash ======================="
9793 dot_lustre_fid_permission_check() {
9795 local ffid=$MOUNT/.lustre/fid/$fid
9798 echo "stat fid $fid"
9799 stat $ffid > /dev/null || error "stat $ffid failed."
9800 echo "touch fid $fid"
9801 touch $ffid || error "touch $ffid failed."
9802 echo "write to fid $fid"
9803 cat /etc/hosts > $ffid || error "write $ffid failed."
9804 echo "read fid $fid"
9805 diff /etc/hosts $ffid || error "read $ffid failed."
9806 echo "append write to fid $fid"
9807 cat /etc/hosts >> $ffid || error "append write $ffid failed."
9808 echo "rename fid $fid"
9809 mv $ffid $test_dir/$tfile.1 &&
9810 error "rename $ffid to $tfile.1 should fail."
9811 touch $test_dir/$tfile.1
9812 mv $test_dir/$tfile.1 $ffid &&
9813 error "rename $tfile.1 to $ffid should fail."
9814 rm -f $test_dir/$tfile.1
9815 echo "truncate fid $fid"
9816 $TRUNCATE $ffid 777 || error "truncate $ffid failed."
9817 if [ $MDSCOUNT -lt 2 ]; then #FIXME when cross-MDT hard link is working
9818 echo "link fid $fid"
9819 ln -f $ffid $test_dir/tfile.lnk || error "link $ffid failed."
9821 if [ -n $(lctl get_param -n mdc.*-mdc-*.connect_flags | grep acl) ]; then
9822 echo "setfacl fid $fid"
9823 setfacl -R -m u:bin:rwx $ffid || error "setfacl $ffid failed."
9824 echo "getfacl fid $fid"
9825 getfacl $ffid >/dev/null || error "getfacl $ffid failed."
9827 echo "unlink fid $fid"
9828 unlink $MOUNT/.lustre/fid/$fid && error "unlink $ffid should fail."
9829 echo "mknod fid $fid"
9830 mknod $ffid c 1 3 && error "mknod $ffid should fail."
9832 fid=[0xf00000400:0x1:0x0]
9833 ffid=$MOUNT/.lustre/fid/$fid
9835 echo "stat non-exist fid $fid"
9836 stat $ffid > /dev/null && error "stat non-exist $ffid should fail."
9837 echo "write to non-exist fid $fid"
9838 cat /etc/hosts > $ffid && error "write non-exist $ffid should fail."
9839 echo "link new fid $fid"
9840 ln $test_dir/$tfile $ffid && error "link $ffid should fail."
9842 mkdir -p $test_dir/$tdir
9843 touch $test_dir/$tdir/$tfile
9844 fid=$($LFS path2fid $test_dir/$tdir)
9847 error "error: could not get fid for $test_dir/$dir/$tfile."
9849 ffid=$MOUNT/.lustre/fid/$fid
9852 ls $ffid > /dev/null || error "ls $ffid failed."
9853 echo "touch $fid/$tfile.1"
9854 touch $ffid/$tfile.1 || error "touch $ffid/$tfile.1 failed."
9856 echo "touch $MOUNT/.lustre/fid/$tfile"
9857 touch $MOUNT/.lustre/fid/$tfile && \
9858 error "touch $MOUNT/.lustre/fid/$tfile should fail."
9860 echo "setxattr to $MOUNT/.lustre/fid"
9861 setfattr -n trusted.name1 -v value1 $MOUNT/.lustre/fid
9863 echo "listxattr for $MOUNT/.lustre/fid"
9864 getfattr -d -m "^trusted" $MOUNT/.lustre/fid
9866 echo "delxattr from $MOUNT/.lustre/fid"
9867 setfattr -x trusted.name1 $MOUNT/.lustre/fid
9869 echo "touch invalid fid: $MOUNT/.lustre/fid/[0x200000400:0x2:0x3]"
9870 touch $MOUNT/.lustre/fid/[0x200000400:0x2:0x3] &&
9871 error "touch invalid fid should fail."
9873 echo "touch non-normal fid: $MOUNT/.lustre/fid/[0x1:0x2:0x0]"
9874 touch $MOUNT/.lustre/fid/[0x1:0x2:0x0] &&
9875 error "touch non-normal fid should fail."
9877 echo "rename $tdir to $MOUNT/.lustre/fid"
9878 mrename $test_dir/$tdir $MOUNT/.lustre/fid &&
9879 error "rename to $MOUNT/.lustre/fid should fail."
9881 if [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.3.51) ]
9883 local old_obf_mode=$(stat --format="%a" $DIR/.lustre/fid)
9884 local new_obf_mode=777
9886 echo "change mode of $DIR/.lustre/fid to $new_obf_mode"
9887 chmod $new_obf_mode $DIR/.lustre/fid ||
9888 error "chmod $new_obf_mode $DIR/.lustre/fid failed"
9890 local obf_mode=$(stat --format=%a $DIR/.lustre/fid)
9891 [ $obf_mode -eq $new_obf_mode ] ||
9892 error "stat $DIR/.lustre/fid returned wrong mode $obf_mode"
9894 echo "restore mode of $DIR/.lustre/fid to $old_obf_mode"
9895 chmod $old_obf_mode $DIR/.lustre/fid ||
9896 error "chmod $old_obf_mode $DIR/.lustre/fid failed"
9899 $OPENFILE -f O_LOV_DELAY_CREATE:O_CREAT $test_dir/$tfile-2
9900 fid=$($LFS path2fid $test_dir/$tfile-2)
9902 if [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.6.50) ]
9904 echo "cp /etc/passwd $MOUNT/.lustre/fid/$fid"
9905 cp /etc/passwd $MOUNT/.lustre/fid/$fid ||
9906 error "create lov data thru .lustre failed"
9908 echo "cp /etc/passwd $test_dir/$tfile-2"
9909 cp /etc/passwd $test_dir/$tfile-2 ||
9910 error "copy to $test_dir/$tfile-2 failed."
9911 echo "diff /etc/passwd $MOUNT/.lustre/fid/$fid"
9912 diff /etc/passwd $MOUNT/.lustre/fid/$fid ||
9913 error "diff /etc/passwd $MOUNT/.lustre/fid/$fid failed."
9915 rm -rf $test_dir/tfile.lnk
9916 rm -rf $test_dir/$tfile-2
9920 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.1) ]] &&
9921 skip "Need MDS version at least 2.4.1" && return
9924 local FID=$($LFS path2fid $DIR/$tfile)
9925 [ -z "$FID" ] && error "path2fid unable to get $DIR/$tfile FID"
9927 # check that we get the same pathname back
9928 local FOUND=$($LFS fid2path $MOUNT "$FID")
9929 [ -z "$FOUND" ] && error "fid2path unable to get $FID path"
9930 [ "$FOUND" != "$DIR/$tfile" ] &&
9931 error "fid2path(path2fid($DIR/$tfile)) = $FOUND != $DIR/$tfile"
9935 run_test 154A "lfs path2fid and fid2path basic checks"
9938 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9939 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.51) ]] ||
9940 { skip "Need MDS version at least 2.2.51"; return 0; }
9941 [ -z "$(which setfacl)" ] && skip "must have setfacl tool" && return
9943 cp /etc/hosts $DIR/$tfile
9945 fid=$($LFS path2fid $DIR/$tfile)
9947 [ $rc -ne 0 ] && error "error: could not get fid for $DIR/$tfile."
9949 dot_lustre_fid_permission_check "$fid" $DIR ||
9950 error "dot lustre permission check $fid failed"
9952 rm -rf $MOUNT/.lustre && error ".lustre is not allowed to be unlinked"
9954 touch $MOUNT/.lustre/file &&
9955 error "creation is not allowed under .lustre"
9957 mkdir $MOUNT/.lustre/dir &&
9958 error "mkdir is not allowed under .lustre"
9962 run_test 154a "Open-by-FID"
9965 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9966 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.51) ]] ||
9967 { skip "Need MDS version at least 2.2.51"; return 0; }
9969 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
9971 local remote_dir=$DIR/$tdir/remote_dir
9976 $LFS mkdir -i $MDTIDX $remote_dir ||
9977 error "create remote directory failed"
9979 cp /etc/hosts $remote_dir/$tfile
9981 fid=$($LFS path2fid $remote_dir/$tfile)
9983 [ $rc -ne 0 ] && error "error: could not get fid for $remote_dir/$tfile"
9985 dot_lustre_fid_permission_check "$fid" $remote_dir ||
9986 error "dot lustre permission check $fid failed"
9989 run_test 154b "Open-by-FID for remote directory"
9992 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.1) ]] &&
9993 skip "Need MDS version at least 2.4.1" && return
9995 touch $DIR/$tfile.1 $DIR/$tfile.2 $DIR/$tfile.3
9996 local FID1=$($LFS path2fid $DIR/$tfile.1)
9997 local FID2=$($LFS path2fid $DIR/$tfile.2)
9998 local FID3=$($LFS path2fid $DIR/$tfile.3)
10001 $LFS path2fid $DIR/$tfile.[123] | while read PATHNAME FID; do
10002 [ "$PATHNAME" = "$DIR/$tfile.$N:" ] ||
10003 error "path2fid pathname $PATHNAME != $DIR/$tfile.$N:"
10005 [ "$FID" = "${!want}" ] ||
10006 error "path2fid $PATHNAME FID $FID != FID$N ${!want}"
10010 $LFS fid2path $MOUNT "$FID1" "$FID2" "$FID3" | while read PATHNAME;
10012 [ "$PATHNAME" = "$DIR/$tfile.$N" ] ||
10013 error "fid2path pathname $PATHNAME != $DIR/$tfile.$N:"
10017 run_test 154c "lfs path2fid and fid2path multiple arguments"
10020 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.5.53) ]] &&
10021 skip "Need MDS version at least 2.5.53" && return
10023 if remote_mds; then
10024 nid=$($LCTL list_nids | sed "s/\./\\\./g")
10028 local proc_ofile="mdt.*.exports.'$nid'.open_files"
10035 local fid=$($LFS path2fid $DIR/$tfile)
10038 cmd="exec $fd<$DIR/$tfile"
10040 local fid_list=$(do_facet $SINGLEMDS $LCTL get_param $proc_ofile)
10041 echo "$fid_list" | grep "$fid"
10044 cmd="exec $fd>/dev/null"
10046 if [ $rc -ne 0 ]; then
10047 error "FID $fid not found in open files list $fid_list"
10050 run_test 154d "Verify open file fid"
10054 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.6.50) ]] &&
10055 skip "Need MDS version at least 2.6.50" && return
10057 if ls -a $MOUNT | grep -q '^\.lustre$'; then
10058 error ".lustre returned by readdir"
10061 run_test 154e ".lustre is not returned by readdir"
10064 # create parent directory on a single MDT to avoid cross-MDT hardlinks
10065 test_mkdir -p -c1 $DIR/$tdir/d
10066 # test dirs inherit from its stripe
10067 mkdir -p $DIR/$tdir/d/foo1 || error "mkdir error"
10068 mkdir -p $DIR/$tdir/d/foo2 || error "mkdir error"
10069 cp /etc/hosts $DIR/$tdir/d/foo1/$tfile
10070 ln $DIR/$tdir/d/foo1/$tfile $DIR/$tdir/d/foo2/link
10073 # get fid of parents
10074 local FID0=$($LFS path2fid $DIR/$tdir/d)
10075 local FID1=$($LFS path2fid $DIR/$tdir/d/foo1)
10076 local FID2=$($LFS path2fid $DIR/$tdir/d/foo2)
10077 local FID3=$($LFS path2fid $DIR)
10079 # check that path2fid --parents returns expected <parent_fid>/name
10080 # 1) test for a directory (single parent)
10081 local parent=$($LFS path2fid --parents $DIR/$tdir/d/foo1)
10082 [ "$parent" == "$FID0/foo1" ] ||
10083 error "expected parent: $FID0/foo1, got: $parent"
10085 # 2) test for a file with nlink > 1 (multiple parents)
10086 parent=$($LFS path2fid --parents $DIR/$tdir/d/foo1/$tfile)
10087 echo "$parent" | grep -F "$FID1/$tfile" ||
10088 error "$FID1/$tfile not returned in parent list"
10089 echo "$parent" | grep -F "$FID2/link" ||
10090 error "$FID2/link not returned in parent list"
10092 # 3) get parent by fid
10093 local file_fid=$($LFS path2fid $DIR/$tdir/d/foo1/$tfile)
10094 parent=$($LFS path2fid --parents $MOUNT/.lustre/fid/$file_fid)
10095 echo "$parent" | grep -F "$FID1/$tfile" ||
10096 error "$FID1/$tfile not returned in parent list (by fid)"
10097 echo "$parent" | grep -F "$FID2/link" ||
10098 error "$FID2/link not returned in parent list (by fid)"
10100 # 4) test for entry in root directory
10101 parent=$($LFS path2fid --parents $DIR/f)
10102 echo "$parent" | grep -F "$FID3/f" ||
10103 error "$FID3/f not returned in parent list"
10105 # 5) test it on root directory
10106 [ -z "$($LFS path2fid --parents $MOUNT 2>/dev/null)" ] ||
10107 error "$MOUNT should not have parents"
10109 # enable xattr caching and check that linkea is correctly updated
10110 local save="$TMP/$TESTSUITE-$TESTNAME.parameters"
10111 save_lustre_params client "llite.*.xattr_cache" > $save
10112 lctl set_param llite.*.xattr_cache 1
10114 # 6.1) linkea update on rename
10115 mv $DIR/$tdir/d/foo1/$tfile $DIR/$tdir/d/foo2/$tfile.moved
10117 # get parents by fid
10118 parent=$($LFS path2fid --parents $MOUNT/.lustre/fid/$file_fid)
10119 # foo1 should no longer be returned in parent list
10120 echo "$parent" | grep -F "$FID1" &&
10121 error "$FID1 should no longer be in parent list"
10122 # the new path should appear
10123 echo "$parent" | grep -F "$FID2/$tfile.moved" ||
10124 error "$FID2/$tfile.moved is not in parent list"
10126 # 6.2) linkea update on unlink
10127 rm -f $DIR/$tdir/d/foo2/link
10128 parent=$($LFS path2fid --parents $MOUNT/.lustre/fid/$file_fid)
10129 # foo2/link should no longer be returned in parent list
10130 echo "$parent" | grep -F "$FID2/link" &&
10131 error "$FID2/link should no longer be in parent list"
10135 restore_lustre_params < $save
10137 run_test 154f "get parent fids by reading link ea"
10141 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.6.92) ]] ||
10142 { skip "Need MDS version at least 2.6.92"; return 0; }
10144 mkdir -p $DIR/$tdir
10145 llapi_fid_test -d $DIR/$tdir
10147 run_test 154g "various llapi FID tests"
10149 test_155_small_load() {
10150 local temp=$TMP/$tfile
10151 local file=$DIR/$tfile
10153 dd if=/dev/urandom of=$temp bs=6096 count=1 || \
10154 error "dd of=$temp bs=6096 count=1 failed"
10156 cancel_lru_locks osc
10157 cmp $temp $file || error "$temp $file differ"
10159 $TRUNCATE $temp 6000
10160 $TRUNCATE $file 6000
10161 cmp $temp $file || error "$temp $file differ (truncate1)"
10163 echo "12345" >>$temp
10164 echo "12345" >>$file
10165 cmp $temp $file || error "$temp $file differ (append1)"
10167 echo "12345" >>$temp
10168 echo "12345" >>$file
10169 cmp $temp $file || error "$temp $file differ (append2)"
10175 test_155_big_load() {
10176 remote_ost_nodsh && skip "remote OST with nodsh" && return
10177 local temp=$TMP/$tfile
10178 local file=$DIR/$tfile
10181 local cache_size=$(do_facet ost$((MAXI+1)) \
10182 "awk '/cache/ {sum+=\\\$4} END {print sum}' /proc/cpuinfo")
10183 local large_file_size=$((cache_size * 2))
10185 echo "OSS cache size: $cache_size KB"
10186 echo "Large file size: $large_file_size KB"
10188 [ $MAXV -le $large_file_size ] && \
10189 skip_env "max available OST size needs > $large_file_size KB" && \
10192 $SETSTRIPE $file -c 1 -i $MAXI || error "$SETSTRIPE $file failed"
10194 dd if=/dev/urandom of=$temp bs=$large_file_size count=1k || \
10195 error "dd of=$temp bs=$large_file_size count=1k failed"
10198 cancel_lru_locks osc
10199 cmp $temp $file || error "$temp $file differ"
10206 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10208 set_cache writethrough on
10209 test_155_small_load
10211 run_test 155a "Verify small file correctness: read cache:on write_cache:on"
10214 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10216 set_cache writethrough off
10217 test_155_small_load
10219 run_test 155b "Verify small file correctness: read cache:on write_cache:off"
10222 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10224 set_cache writethrough on
10225 test_155_small_load
10227 run_test 155c "Verify small file correctness: read cache:off write_cache:on"
10230 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10232 set_cache writethrough off
10233 test_155_small_load
10235 run_test 155d "Verify small file correctness: read cache:off write_cache:off"
10238 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10240 set_cache writethrough on
10243 run_test 155e "Verify big file correctness: read cache:on write_cache:on"
10246 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10248 set_cache writethrough off
10251 run_test 155f "Verify big file correctness: read cache:on write_cache:off"
10254 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10256 set_cache writethrough on
10259 run_test 155g "Verify big file correctness: read cache:off write_cache:on"
10262 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10264 set_cache writethrough off
10267 run_test 155h "Verify big file correctness: read cache:off write_cache:off"
10270 remote_ost_nodsh && skip "remote OST with nodsh" && return
10271 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10275 local file="$DIR/$tfile"
10277 [ "$(facet_fstype ost1)" = "zfs" -a \
10278 $(lustre_version_code ost1 -lt $(version_code 2.6.93)) ] &&
10279 skip "LU-1956/LU-2261: stats not implemented on OSD ZFS" &&
10284 log "Turn on read and write cache"
10286 set_cache writethrough on
10288 log "Write data and read it back."
10289 log "Read should be satisfied from the cache."
10290 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
10292 cancel_lru_locks osc
10293 cat $file >/dev/null
10295 if ! let "AFTER - BEFORE == CPAGES"; then
10296 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
10298 log "cache hits:: before: $BEFORE, after: $AFTER"
10301 log "Read again; it should be satisfied from the cache."
10303 cancel_lru_locks osc
10304 cat $file >/dev/null
10306 if ! let "AFTER - BEFORE == CPAGES"; then
10307 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
10309 log "cache hits:: before: $BEFORE, after: $AFTER"
10312 log "Turn off the read cache and turn on the write cache"
10314 set_cache writethrough on
10316 log "Read again; it should be satisfied from the cache."
10318 cancel_lru_locks osc
10319 cat $file >/dev/null
10321 if ! let "AFTER - BEFORE == CPAGES"; then
10322 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
10324 log "cache hits:: before: $BEFORE, after: $AFTER"
10327 log "Read again; it should not be satisfied from the cache."
10329 cancel_lru_locks osc
10330 cat $file >/dev/null
10332 if ! let "AFTER - BEFORE == 0"; then
10333 error "IN CACHE: before: $BEFORE, after: $AFTER"
10335 log "cache hits:: before: $BEFORE, after: $AFTER"
10338 log "Write data and read it back."
10339 log "Read should be satisfied from the cache."
10340 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
10342 cancel_lru_locks osc
10343 cat $file >/dev/null
10345 if ! let "AFTER - BEFORE == CPAGES"; then
10346 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
10348 log "cache hits:: before: $BEFORE, after: $AFTER"
10351 log "Read again; it should not be satisfied from the cache."
10353 cancel_lru_locks osc
10354 cat $file >/dev/null
10356 if ! let "AFTER - BEFORE == 0"; then
10357 error "IN CACHE: before: $BEFORE, after: $AFTER"
10359 log "cache hits:: before: $BEFORE, after: $AFTER"
10362 log "Turn off read and write cache"
10364 set_cache writethrough off
10366 log "Write data and read it back"
10367 log "It should not be satisfied from the cache."
10369 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
10370 cancel_lru_locks osc
10372 cat $file >/dev/null
10374 if ! let "AFTER - BEFORE == 0"; then
10375 error_ignore bz20762 "IN CACHE: before: $BEFORE, after: $AFTER"
10377 log "cache hits:: before: $BEFORE, after: $AFTER"
10380 log "Turn on the read cache and turn off the write cache"
10382 set_cache writethrough off
10384 log "Write data and read it back"
10385 log "It should not be satisfied from the cache."
10387 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
10389 cancel_lru_locks osc
10390 cat $file >/dev/null
10392 if ! let "AFTER - BEFORE == 0"; then
10393 error_ignore bz20762 "IN CACHE: before: $BEFORE, after: $AFTER"
10395 log "cache hits:: before: $BEFORE, after: $AFTER"
10398 log "Read again; it should be satisfied from the cache."
10400 cancel_lru_locks osc
10401 cat $file >/dev/null
10403 if ! let "AFTER - BEFORE == CPAGES"; then
10404 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
10406 log "cache hits:: before: $BEFORE, after: $AFTER"
10411 run_test 156 "Verification of tunables"
10415 if [[ $MDSCOUNT -gt 1 ]]; then
10416 error_ignore bz17935 $*
10424 local CL_MASK_PARAM="mdd.$MDT0.changelog_mask"
10426 MASK=$(do_facet $SINGLEMDS $LCTL get_param $CL_MASK_PARAM| grep -c "$1")
10428 if [ $MASK -eq 1 ]; then
10429 do_facet $SINGLEMDS $LCTL set_param $CL_MASK_PARAM="-$1"
10431 do_facet $SINGLEMDS $LCTL set_param $CL_MASK_PARAM="+$1"
10435 changelog_extract_field() {
10439 local identifier=$4
10441 $LFS changelog $mdt | gawk "/$cltype.*$file$/ {
10442 print gensub(/^.* "$identifier'(\[[^\]]*\]).*$/,"\\1",1)}' |
10447 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10448 remote_mds_nodsh && skip "remote MDS with nodsh" && return
10449 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] ||
10450 { skip "Need MDS version at least 2.2.0"; return; }
10452 local CL_USERS="mdd.$MDT0.changelog_users"
10453 local GET_CL_USERS="do_facet $SINGLEMDS $LCTL get_param -n $CL_USERS"
10454 USER=$(do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_register -n)
10455 echo "Registered as changelog user $USER"
10456 $GET_CL_USERS | grep -q $USER ||
10457 error "User $USER not found in changelog_users"
10460 test_mkdir -p $DIR/$tdir/pics/2008/zachy
10461 touch $DIR/$tdir/pics/2008/zachy/timestamp
10462 cp /etc/hosts $DIR/$tdir/pics/2008/zachy/pic1.jpg
10463 mv $DIR/$tdir/pics/2008/zachy $DIR/$tdir/pics/zach
10464 ln $DIR/$tdir/pics/zach/pic1.jpg $DIR/$tdir/pics/2008/portland.jpg
10465 ln -s $DIR/$tdir/pics/2008/portland.jpg $DIR/$tdir/pics/desktop.jpg
10466 rm $DIR/$tdir/pics/desktop.jpg
10468 $LFS changelog $MDT0 | tail -5
10470 echo "verifying changelog mask"
10471 changelog_chmask "MKDIR"
10472 changelog_chmask "CLOSE"
10474 test_mkdir -p $DIR/$tdir/pics/zach/sofia
10475 echo "zzzzzz" > $DIR/$tdir/pics/zach/file
10477 changelog_chmask "MKDIR"
10478 changelog_chmask "CLOSE"
10480 test_mkdir -p $DIR/$tdir/pics/2008/sofia
10481 echo "zzzzzz" > $DIR/$tdir/pics/zach/file
10483 $LFS changelog $MDT0
10484 MKDIRS=$($LFS changelog $MDT0 | tail -5 | grep -c "MKDIR")
10485 CLOSES=$($LFS changelog $MDT0 | tail -5 | grep -c "CLOSE")
10486 [ $MKDIRS -eq 1 ] || err17935 "MKDIR changelog mask count $DIRS != 1"
10487 [ $CLOSES -eq 1 ] || err17935 "CLOSE changelog mask count $DIRS != 1"
10490 echo "verifying target fid"
10491 fidc=$(changelog_extract_field $MDT0 "CREAT" "timestamp" "t=")
10492 fidf=$($LFS path2fid $DIR/$tdir/pics/zach/timestamp)
10493 [ "$fidc" == "$fidf" ] ||
10494 err17935 "fid in changelog $fidc != file fid $fidf"
10495 echo "verifying parent fid"
10496 fidc=$(changelog_extract_field $MDT0 "CREAT" "timestamp" "p=")
10497 fidf=$($LFS path2fid $DIR/$tdir/pics/zach)
10498 [ "$fidc" == "$fidf" ] ||
10499 err17935 "pfid in changelog $fidc != dir fid $fidf"
10501 USER_REC1=$($GET_CL_USERS | awk "\$1 == \"$USER\" {print \$2}")
10502 $LFS changelog_clear $MDT0 $USER $(($USER_REC1 + 5))
10503 USER_REC2=$($GET_CL_USERS | awk "\$1 == \"$USER\" {print \$2}")
10504 echo "verifying user clear: $(( $USER_REC1 + 5 )) == $USER_REC2"
10505 [ $USER_REC2 == $(($USER_REC1 + 5)) ] ||
10506 err17935 "user index expected $(($USER_REC1 + 5)) is $USER_REC2"
10508 MIN_REC=$($GET_CL_USERS |
10509 awk 'min == "" || $2 < min {min = $2}; END {print min}')
10510 FIRST_REC=$($LFS changelog $MDT0 | head -n1 | awk '{print $1}')
10511 echo "verifying min purge: $(( $MIN_REC + 1 )) == $FIRST_REC"
10512 [ $FIRST_REC == $(($MIN_REC + 1)) ] ||
10513 err17935 "first index should be $(($MIN_REC + 1)) is $FIRST_REC"
10515 # LU-3446 changelog index reset on MDT restart
10516 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
10517 CUR_REC1=$($GET_CL_USERS | head -n1 | cut -f3 -d' ')
10518 $LFS changelog_clear $MDT0 $USER 0
10519 stop $SINGLEMDS || error "Fail to stop MDT."
10520 start $SINGLEMDS $MDT_DEV $MDS_MOUNT_OPTS || error "Fail to start MDT."
10521 CUR_REC2=$($GET_CL_USERS | head -n1 | cut -f3 -d' ')
10522 echo "verifying index survives MDT restart: $CUR_REC1 == $CUR_REC2"
10523 [ $CUR_REC1 == $CUR_REC2 ] ||
10524 err17935 "current index should be $CUR_REC1 is $CUR_REC2"
10526 echo "verifying user deregister"
10527 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister $USER
10528 $GET_CL_USERS | grep -q $USER &&
10529 error "User $USER still in changelog_users"
10531 USERS=$(( $($GET_CL_USERS | wc -l) - 2 ))
10532 if [ $USERS -eq 0 ]; then
10533 LAST_REC1=$($GET_CL_USERS | head -n1 | cut -f3 -d' ')
10534 touch $DIR/$tdir/chloe
10535 LAST_REC2=$($GET_CL_USERS | head -n1 | cut -f3 -d' ')
10536 echo "verify changelogs are off: $LAST_REC1 == $LAST_REC2"
10537 [ $LAST_REC1 == $LAST_REC2 ] || error "changelogs not off"
10539 echo "$USERS other changelog users; can't verify off"
10542 run_test 160a "changelog sanity"
10544 test_160b() { # LU-3587
10545 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10546 remote_mds_nodsh && skip "remote MDS with nodsh" && return
10547 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] ||
10548 { skip "Need MDS version at least 2.2.0"; return; }
10550 local CL_USERS="mdd.$MDT0.changelog_users"
10551 local GET_CL_USERS="do_facet $SINGLEMDS $LCTL get_param -n $CL_USERS"
10552 USER=$(do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_register -n)
10553 echo "Registered as changelog user $USER"
10554 $GET_CL_USERS | grep -q $USER ||
10555 error "User $USER not found in changelog_users"
10557 local LONGNAME1=$(str_repeat a 255)
10558 local LONGNAME2=$(str_repeat b 255)
10561 echo "creating very long named file"
10562 touch $LONGNAME1 || error "create of $LONGNAME1 failed"
10563 echo "moving very long named file"
10564 mv $LONGNAME1 $LONGNAME2
10566 $LFS changelog $MDT0 | grep RENME
10568 echo "deregistering $USER"
10569 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister $USER
10573 run_test 160b "Verify that very long rename doesn't crash in changelog"
10576 remote_mds_nodsh && skip "remote MDS with nodsh" && return
10579 local server_version=$(lustre_version_code $SINGLEMDS)
10581 [[ $server_version -gt $(version_code 2.5.57) ]] ||
10582 [[ $server_version -gt $(version_code 2.5.1) &&
10583 $server_version -lt $(version_code 2.5.50) ]] ||
10584 { skip "Need MDS version at least 2.5.58 or 2.5.2+"; return; }
10585 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10587 # Registration step
10588 local USER=$(do_facet $SINGLEMDS $LCTL --device $MDT0 \
10589 changelog_register -n)
10592 mkdir -p $DIR/$tdir
10593 $MCREATE $DIR/$tdir/foo_160c
10594 changelog_chmask "TRUNC"
10595 $TRUNCATE $DIR/$tdir/foo_160c 200
10596 changelog_chmask "TRUNC"
10597 $TRUNCATE $DIR/$tdir/foo_160c 199
10598 $LFS changelog $MDT0
10599 TRUNCS=$($LFS changelog $MDT0 | tail -5 | grep -c "TRUNC")
10600 [ $TRUNCS -eq 1 ] || err17935 "TRUNC changelog mask count $TRUNCS != 1"
10601 $LFS changelog_clear $MDT0 $USER 0
10603 # Deregistration step
10604 echo "deregistering $USER"
10605 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister $USER
10607 run_test 160c "verify that changelog log catch the truncate event"
10610 remote_mds_nodsh && skip "remote MDS with nodsh" && return
10611 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
10613 local server_version=$(lustre_version_code mds1)
10614 local CL_MASK_PARAM="mdd.$MDT0.changelog_mask"
10616 [[ $server_version -ge $(version_code 2.7.60) ]] ||
10617 { skip "Need MDS version at least 2.7.60+"; return; }
10618 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10620 # Registration step
10621 local USER=$(do_facet mds1 $LCTL --device $MDT0 \
10622 changelog_register -n)
10624 mkdir -p $DIR/$tdir/migrate_dir
10625 $LFS changelog_clear $MDT0 $USER 0
10627 $LFS migrate -m 1 $DIR/$tdir/migrate_dir || error "migrate fails"
10628 $LFS changelog $MDT0
10629 MIGRATES=$($LFS changelog $MDT0 | tail -5 | grep -c "MIGRT")
10630 $LFS changelog_clear $MDT0 $USER 0
10631 [ $MIGRATES -eq 1 ] ||
10632 error "MIGRATE changelog mask count $MIGRATES != 1"
10634 # Deregistration step
10635 do_facet mds1 $LCTL --device $MDT0 changelog_deregister $USER
10637 run_test 160d "verify that changelog log catch the migrate event"
10640 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10641 test_mkdir -p -c1 $DIR/$tdir
10642 cp /etc/hosts $DIR/$tdir/$tfile
10643 test_mkdir -c1 $DIR/$tdir/foo1
10644 test_mkdir -c1 $DIR/$tdir/foo2
10645 ln $DIR/$tdir/$tfile $DIR/$tdir/foo1/sofia
10646 ln $DIR/$tdir/$tfile $DIR/$tdir/foo2/zachary
10647 ln $DIR/$tdir/$tfile $DIR/$tdir/foo1/luna
10648 ln $DIR/$tdir/$tfile $DIR/$tdir/foo2/thor
10649 local FID=$($LFS path2fid $DIR/$tdir/$tfile | tr -d '[]')
10650 if [ "$($LFS fid2path $DIR $FID | wc -l)" != "5" ]; then
10651 $LFS fid2path $DIR $FID
10652 err17935 "bad link ea"
10655 rm $DIR/$tdir/foo2/zachary
10657 rm $DIR/$tdir/foo2/thor
10659 rm $DIR/$tdir/$tfile
10661 mv $DIR/$tdir/foo1/sofia $DIR/$tdir/foo2/maggie
10662 if [ "$($LFS fid2path $FSNAME --link 1 $FID)" != "$tdir/foo2/maggie" ]
10664 $LFS fid2path $DIR $FID
10665 err17935 "bad link rename"
10667 rm $DIR/$tdir/foo2/maggie
10670 local longname=filename_avg_len_is_thirty_two_
10671 createmany -l$DIR/$tdir/foo1/luna $DIR/$tdir/foo2/$longname 1000 ||
10672 error "failed to hardlink many files"
10673 links=$($LFS fid2path $DIR $FID | wc -l)
10674 echo -n "${links}/1000 links in link EA"
10675 [[ $links -gt 60 ]] ||
10676 err17935 "expected at least 60 links in link EA"
10677 unlinkmany $DIR/$tdir/foo2/$longname 1000 ||
10678 error "failed to unlink many hardlinks"
10680 run_test 161a "link ea sanity"
10683 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10684 [ $MDSCOUNT -lt 2 ] &&
10685 skip "skipping remote directory test" && return
10687 local remote_dir=$DIR/$tdir/remote_dir
10689 mkdir -p $DIR/$tdir
10690 $LFS mkdir -i $MDTIDX $remote_dir ||
10691 error "create remote directory failed"
10693 cp /etc/hosts $remote_dir/$tfile
10694 mkdir -p $remote_dir/foo1
10695 mkdir -p $remote_dir/foo2
10696 ln $remote_dir/$tfile $remote_dir/foo1/sofia
10697 ln $remote_dir/$tfile $remote_dir/foo2/zachary
10698 ln $remote_dir/$tfile $remote_dir/foo1/luna
10699 ln $remote_dir/$tfile $remote_dir/foo2/thor
10701 local FID=$($LFS path2fid $remote_dir/$tfile | tr -d '[' |
10703 if [ "$($LFS fid2path $DIR $FID | wc -l)" != "5" ]; then
10704 $LFS fid2path $DIR $FID
10705 err17935 "bad link ea"
10708 rm $remote_dir/foo2/zachary
10710 rm $remote_dir/foo2/thor
10712 rm $remote_dir/$tfile
10714 mv $remote_dir/foo1/sofia $remote_dir/foo2/maggie
10715 local link_path=$($LFS fid2path $FSNAME --link 1 $FID)
10716 if [ "$DIR/$link_path" != "$remote_dir/foo2/maggie" ]; then
10717 $LFS fid2path $DIR $FID
10718 err17935 "bad link rename"
10720 rm $remote_dir/foo2/maggie
10723 local longname=filename_avg_len_is_thirty_two_
10724 createmany -l$remote_dir/foo1/luna $remote_dir/foo2/$longname 1000 ||
10725 error "failed to hardlink many files"
10726 links=$($LFS fid2path $DIR $FID | wc -l)
10727 echo -n "${links}/1000 links in link EA"
10728 [[ ${links} -gt 60 ]] ||
10729 err17935 "expected at least 60 links in link EA"
10730 unlinkmany $remote_dir/foo2/$longname 1000 ||
10731 error "failed to unlink many hardlinks"
10733 run_test 161b "link ea sanity under remote directory"
10736 remote_mds_nodsh && skip "remote MDS with nodsh" && return
10737 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10738 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.1.5) ]] &&
10739 skip "Need MDS version at least 2.1.5" && return
10741 # define CLF_RENAME_LAST 0x0001
10742 # rename overwrite a target having nlink = 1 (changelog flag 0x1)
10743 local USER=$(do_facet $SINGLEMDS $LCTL --device $MDT0 \
10744 changelog_register -n)
10746 mkdir -p $DIR/$tdir
10747 touch $DIR/$tdir/foo_161c
10748 touch $DIR/$tdir/bar_161c
10749 mv -f $DIR/$tdir/foo_161c $DIR/$tdir/bar_161c
10750 $LFS changelog $MDT0 | grep RENME
10751 local flags=$($LFS changelog $MDT0 | grep RENME | tail -1 | \
10753 $LFS changelog_clear $MDT0 $USER 0
10754 if [ x$flags != "x0x1" ]; then
10755 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister \
10757 error "flag $flags is not 0x1"
10759 echo "rename overwrite a target having nlink = 1," \
10760 "changelog record has flags of $flags"
10762 # rename overwrite a target having nlink > 1 (changelog flag 0x0)
10763 touch $DIR/$tdir/foo_161c
10764 touch $DIR/$tdir/bar_161c
10765 ln $DIR/$tdir/bar_161c $DIR/$tdir/foobar_161c
10766 mv -f $DIR/$tdir/foo_161c $DIR/$tdir/bar_161c
10767 $LFS changelog $MDT0 | grep RENME
10768 flags=$($LFS changelog $MDT0 | grep RENME | tail -1 | cut -f5 -d' ')
10769 $LFS changelog_clear $MDT0 $USER 0
10770 if [ x$flags != "x0x0" ]; then
10771 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister \
10773 error "flag $flags is not 0x0"
10775 echo "rename overwrite a target having nlink > 1," \
10776 "changelog record has flags of $flags"
10778 # rename doesn't overwrite a target (changelog flag 0x0)
10779 touch $DIR/$tdir/foo_161c
10780 mv -f $DIR/$tdir/foo_161c $DIR/$tdir/foo2_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 doesn't overwrite a target," \
10790 "changelog record has flags of $flags"
10792 # define CLF_UNLINK_LAST 0x0001
10793 # unlink a file having nlink = 1 (changelog flag 0x1)
10794 rm -f $DIR/$tdir/foo2_161c
10795 $LFS changelog $MDT0 | grep UNLNK
10796 flags=$($LFS changelog $MDT0 | grep UNLNK | tail -1 | cut -f5 -d' ')
10797 $LFS changelog_clear $MDT0 $USER 0
10798 if [ x$flags != "x0x1" ]; then
10799 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister \
10801 error "flag $flags is not 0x1"
10803 echo "unlink a file having nlink = 1," \
10804 "changelog record has flags of $flags"
10806 # unlink a file having nlink > 1 (changelog flag 0x0)
10807 ln -f $DIR/$tdir/bar_161c $DIR/$tdir/foobar_161c
10808 rm -f $DIR/$tdir/foobar_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 != "x0x0" ]; then
10813 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister \
10815 error "flag $flags is not 0x0"
10817 echo "unlink a file having nlink > 1," \
10818 "changelog record has flags of $flags"
10819 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister $USER
10821 run_test 161c "check CL_RENME[UNLINK] changelog record flags"
10828 local path=$(${LFS} fid2path $*)
10829 # Remove the '//' indicating a remote directory
10830 path=$(echo $path | sed 's#//#/#g')
10833 if [ $RC -ne 0 ]; then
10834 err17935 "path looked up of $expected failed. Error $RC"
10836 elif [ "${path}" != "${expected}" ]; then
10837 err17935 "path looked up \"${path}\" instead of \"${expected}\""
10840 echo "fid $fid resolves to path $path (expected $expected)"
10843 test_162a() { # was test_162
10844 # Make changes to filesystem
10845 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10846 test_mkdir -p -c1 $DIR/$tdir/d2
10847 touch $DIR/$tdir/d2/$tfile
10848 touch $DIR/$tdir/d2/x1
10849 touch $DIR/$tdir/d2/x2
10850 test_mkdir -p -c1 $DIR/$tdir/d2/a/b/c
10851 test_mkdir -p -c1 $DIR/$tdir/d2/p/q/r
10853 FID=$($LFS path2fid $DIR/$tdir/d2/$tfile | tr -d '[]')
10854 check_path "$tdir/d2/$tfile" $FSNAME $FID --link 0 ||
10855 error "check path $tdir/d2/$tfile failed"
10858 ln -s $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/p/q/r/slink
10859 FID=$($LFS path2fid $DIR/$tdir/d2/p/q/r/slink | tr -d '[]')
10860 check_path "$tdir/d2/p/q/r/slink" $FSNAME $FID --link 0 ||
10861 error "check path $tdir/d2/p/q/r/slink failed"
10863 # softlink to wrong file
10864 ln -s /this/is/garbage $DIR/$tdir/d2/p/q/r/slink.wrong
10865 FID=$($LFS path2fid $DIR/$tdir/d2/p/q/r/slink.wrong | tr -d '[]')
10866 check_path "$tdir/d2/p/q/r/slink.wrong" $FSNAME $FID --link 0 ||
10867 error "check path $tdir/d2/p/q/r/slink.wrong failed"
10870 ln $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/p/q/r/hlink
10871 mv $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/a/b/c/new_file
10872 FID=$($LFS path2fid $DIR/$tdir/d2/a/b/c/new_file | tr -d '[]')
10873 # fid2path dir/fsname should both work
10874 check_path "$tdir/d2/a/b/c/new_file" $FSNAME $FID --link 1 ||
10875 error "check path $tdir/d2/a/b/c/new_file failed"
10876 check_path "$DIR/$tdir/d2/p/q/r/hlink" $DIR $FID --link 0 ||
10877 error "check path $DIR/$tdir/d2/p/q/r/hlink failed"
10879 # hardlink count: check that there are 2 links
10880 # Doesnt work with CMD yet: 17935
10881 ${LFS} fid2path $DIR $FID | wc -l | grep -q 2 || \
10882 err17935 "expected 2 links"
10884 # hardlink indexing: remove the first link
10885 rm $DIR/$tdir/d2/p/q/r/hlink
10886 check_path "$tdir/d2/a/b/c/new_file" $FSNAME $FID --link 0 ||
10887 error "check path $DIR/$tdir/d2/a/b/c/new_file failed"
10891 run_test 162a "path lookup sanity"
10894 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10895 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
10898 $LFS setdirstripe -i0 -c$MDSCOUNT -t all_char $DIR/$tdir/striped_dir ||
10899 error "create striped dir failed"
10901 local FID=$($LFS getdirstripe $DIR/$tdir/striped_dir |
10902 tail -n 1 | awk '{print $2}')
10903 stat $MOUNT/.lustre/fid/$FID && error "sub_stripe can be accessed"
10905 touch $DIR/$tdir/striped_dir/f{0..4} || error "touch f0..4 failed"
10906 mkdir $DIR/$tdir/striped_dir/d{0..4} || error "mkdir d0..4 failed"
10909 for ((i=0;i<5;i++)); do
10910 FID=$($LFS path2fid $DIR/$tdir/striped_dir/f$i | tr -d '[]') ||
10911 error "get fid for f$i failed"
10912 check_path "$tdir/striped_dir/f$i" $FSNAME $FID --link 0 ||
10913 error "check path $tdir/striped_dir/f$i failed"
10915 FID=$($LFS path2fid $DIR/$tdir/striped_dir/d$i | tr -d '[]') ||
10916 error "get fid for d$i failed"
10917 check_path "$tdir/striped_dir/d$i" $FSNAME $FID --link 0 ||
10918 error "check path $tdir/striped_dir/d$i failed"
10923 run_test 162b "striped directory path lookup sanity"
10925 # LU-4239: Verify fid2path works with paths 100 or more directories deep
10927 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.51) ]] &&
10928 skip "Need MDS version at least 2.7.51" && return
10929 test_mkdir $DIR/$tdir.local
10930 test_mkdir $DIR/$tdir.remote
10931 local lpath=$tdir.local
10932 local rpath=$tdir.remote
10934 for ((i = 0; i <= 101; i++)); do
10937 FID=$($LFS path2fid $DIR/$lpath | tr -d '[]') ||
10938 error "get fid for local directory $DIR/$lpath failed"
10939 check_path "$DIR/$lpath" $MOUNT $FID --link 0 ||
10940 error "check path for local directory $DIR/$lpath failed"
10943 test_mkdir $DIR/$rpath
10944 FID=$($LFS path2fid $DIR/$rpath | tr -d '[]') ||
10945 error "get fid for remote directory $DIR/$rpath failed"
10946 check_path "$DIR/$rpath" $MOUNT $FID --link 0 ||
10947 error "check path for remote directory $DIR/$rpath failed"
10952 run_test 162c "fid2path works with paths 100 or more directories deep"
10955 # do directio so as not to populate the page cache
10956 log "creating a 10 Mb file"
10957 $MULTIOP $DIR/$tfile oO_CREAT:O_DIRECT:O_RDWR:w$((10*1048576))c || error "multiop failed while creating a file"
10958 log "starting reads"
10959 dd if=$DIR/$tfile of=/dev/null bs=4096 &
10960 log "truncating the file"
10961 $MULTIOP $DIR/$tfile oO_TRUNC:c || error "multiop failed while truncating the file"
10963 kill %+ || true # reads might have finished
10964 echo "wait until dd is finished"
10966 log "removing the temporary file"
10967 rm -rf $DIR/$tfile || error "tmp file removal failed"
10969 run_test 169 "parallel read and truncate should not deadlock"
10972 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10973 $LCTL clear # bug 18514
10974 $LCTL debug_daemon start $TMP/${tfile}_log_good
10976 $LCTL debug_daemon stop
10977 sed -e "s/^...../a/g" $TMP/${tfile}_log_good > $TMP/${tfile}_log_bad ||
10978 error "sed failed to read log_good"
10980 $LCTL debug_daemon start $TMP/${tfile}_log_good
10982 $LCTL debug_daemon stop
10984 $LCTL df $TMP/${tfile}_log_bad > $TMP/${tfile}_log_bad.out 2>&1 ||
10985 error "lctl df log_bad failed"
10987 local bad_line=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $9}')
10988 local good_line1=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $5}')
10990 $LCTL df $TMP/${tfile}_log_good > $TMP/${tfile}_log_good.out 2>&1
10991 local good_line2=$(tail -n 1 $TMP/${tfile}_log_good.out | awk '{print $5}')
10993 [ "$bad_line" ] && [ "$good_line1" ] && [ "$good_line2" ] ||
10994 error "bad_line good_line1 good_line2 are empty"
10996 cat $TMP/${tfile}_log_good >> $TMP/${tfile}_logs_corrupt
10997 cat $TMP/${tfile}_log_bad >> $TMP/${tfile}_logs_corrupt
10998 cat $TMP/${tfile}_log_good >> $TMP/${tfile}_logs_corrupt
11000 $LCTL df $TMP/${tfile}_logs_corrupt > $TMP/${tfile}_log_bad.out 2>&1
11001 local bad_line_new=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $9}')
11002 local good_line_new=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $5}')
11004 [ "$bad_line_new" ] && [ "$good_line_new" ] ||
11005 error "bad_line_new good_line_new are empty"
11007 local expected_good=$((good_line1 + good_line2*2))
11009 rm -f $TMP/${tfile}*
11010 # LU-231, short malformed line may not be counted into bad lines
11011 if [ $bad_line -ne $bad_line_new ] &&
11012 [ $bad_line -ne $((bad_line_new - 1)) ]; then
11013 error "expected $bad_line bad lines, but got $bad_line_new"
11017 if [ $expected_good -ne $good_line_new ]; then
11018 error "expected $expected_good good lines, but got $good_line_new"
11023 run_test 170 "test lctl df to handle corrupted log ====================="
11025 test_171() { # bug20592
11026 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11027 #define OBD_FAIL_PTLRPC_DUMP_LOG 0x50e
11028 $LCTL set_param fail_loc=0x50e
11029 $LCTL set_param fail_val=3000
11030 multiop_bg_pause $DIR/$tfile O_s || true
11032 kill -USR1 $MULTIPID
11036 if dmesg | grep "recursive fault"; then
11037 error "caught a recursive fault"
11039 $LCTL set_param fail_loc=0
11042 run_test 171 "test libcfs_debug_dumplog_thread stuck in do_exit() ======"
11044 # it would be good to share it with obdfilter-survey/iokit-libecho code
11045 setup_obdecho_osc () {
11048 local obdfilter_name=$2
11049 echo "Creating new osc for $obdfilter_name on $ost_nid"
11050 # make sure we can find loopback nid
11051 $LCTL add_uuid $ost_nid $ost_nid >/dev/null 2>&1
11053 [ $rc -eq 0 ] && { $LCTL attach osc ${obdfilter_name}_osc \
11054 ${obdfilter_name}_osc_UUID || rc=2; }
11055 [ $rc -eq 0 ] && { $LCTL --device ${obdfilter_name}_osc setup \
11056 ${obdfilter_name}_UUID $ost_nid || rc=3; }
11060 cleanup_obdecho_osc () {
11061 local obdfilter_name=$1
11062 $LCTL --device ${obdfilter_name}_osc cleanup >/dev/null
11063 $LCTL --device ${obdfilter_name}_osc detach >/dev/null
11070 local pages=${3:-64}
11075 local obd_size=$(get_obd_size $node $OBD)
11076 local page_size=$(get_page_size $node)
11077 if [[ -n "$obd_size" ]]; then
11078 local new_count=$((obd_size / (pages * page_size / 1024)))
11079 [[ $new_count -ge $count ]] || count=$new_count
11082 do_facet $node "$LCTL attach echo_client ec ec_uuid" || rc=1
11083 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec setup $OBD" ||
11085 if [ $rc -eq 0 ]; then
11086 id=$(do_facet $node "$LCTL --device ec create 1" | awk '/object id/ {print $6}')
11087 [ ${PIPESTATUS[0]} -eq 0 -a -n "$id" ] || rc=3
11089 echo "New object id is $id"
11090 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec getattr $id" ||
11092 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec " \
11093 "test_brw $count w v $pages $id" || rc=4; }
11094 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec destroy $id 1" ||
11096 [ $rc -eq 0 -o $rc -gt 2 ] && { do_facet $node "$LCTL --device ec " \
11097 "cleanup" || rc=5; }
11098 [ $rc -eq 0 -o $rc -gt 1 ] && { do_facet $node "$LCTL --device ec " \
11099 "detach" || rc=6; }
11100 [ $rc -ne 0 ] && echo "obecho_create_test failed: $rc"
11105 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11106 remote_ost_nodsh && skip "remote OST with nodsh" && return
11108 local rmmod_local=0
11110 if ! module_loaded obdecho; then
11111 load_module obdecho/obdecho
11115 local osc=$($LCTL dl | grep -v mdt | awk '$3 == "osc" {print $4; exit}')
11116 local host=$(lctl get_param -n osc.$osc.import |
11117 awk '/current_connection:/ {print $2}' )
11118 local target=$(lctl get_param -n osc.$osc.import |
11119 awk '/target:/ {print $2}' )
11120 target=${target%_UUID}
11122 [[ -n $target ]] && { setup_obdecho_osc $host $target || rc=1; } || rc=1
11123 [ $rc -eq 0 ] && { obdecho_test ${target}_osc client || rc=2; }
11124 [[ -n $target ]] && cleanup_obdecho_osc $target
11125 [ $rmmod_local -eq 1 ] && rmmod obdecho
11128 run_test 180a "test obdecho on osc"
11131 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11132 remote_ost_nodsh && skip "remote OST with nodsh" && return
11134 local rmmod_remote=0
11136 do_facet ost1 "lsmod | grep -q obdecho || " \
11137 "{ insmod ${LUSTRE}/obdecho/obdecho.ko || " \
11138 "modprobe obdecho; }" && rmmod_remote=1
11139 target=$(do_facet ost1 $LCTL dl | awk '/obdfilter/ {print $4;exit}')
11140 [[ -n $target ]] && { obdecho_test $target ost1 || rc=1; }
11141 [ $rmmod_remote -eq 1 ] && do_facet ost1 "rmmod obdecho"
11144 run_test 180b "test obdecho directly on obdfilter"
11146 test_180c() { # LU-2598
11147 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11148 remote_ost_nodsh && skip "remote OST with nodsh" && return
11149 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.0) ]] &&
11150 skip "Need MDS version at least 2.4.0" && return
11153 local rmmod_remote=false
11154 local pages=16384 # 64MB bulk I/O RPC size
11157 do_rpc_nodes $(facet_active_host ost1) load_module obdecho/obdecho &&
11158 rmmod_remote=true || error "failed to load module obdecho"
11160 target=$(do_facet ost1 $LCTL dl | awk '/obdfilter/ { print $4 }' |
11162 if [ -n "$target" ]; then
11163 obdecho_test "$target" ost1 "$pages" || rc=${PIPESTATUS[0]}
11165 echo "there is no obdfilter target on ost1"
11168 $rmmod_remote && do_facet ost1 "rmmod obdecho" || true
11171 run_test 180c "test huge bulk I/O size on obdfilter, don't LASSERT"
11173 test_181() { # bug 22177
11174 test_mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
11175 # create enough files to index the directory
11176 createmany -o $DIR/$tdir/foobar 4000
11177 # print attributes for debug purpose
11180 multiop_bg_pause $DIR/$tdir D_Sc || return 1
11182 # remove the files & current working dir
11183 unlinkmany $DIR/$tdir/foobar 4000
11185 kill -USR1 $MULTIPID
11187 stat $DIR/$tdir && error "open-unlinked dir was not removed!"
11190 run_test 181 "Test open-unlinked dir ========================"
11196 mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
11198 $LCTL set_param mdc.*.rpc_stats=clear
11200 for (( i = 0; i < $tcount; i++ )) ; do
11201 mkdir $DIR/$tdir/$i
11204 for (( i = 0; i < $tcount; i++ )) ; do
11205 createmany -o $DIR/$tdir/$i/f- $fcount &
11209 for (( i = 0; i < $tcount; i++ )) ; do
11210 unlinkmany $DIR/$tdir/$i/f- $fcount &
11214 $LCTL get_param mdc.*.rpc_stats
11218 run_test 182 "Test parallel modify metadata operations ================"
11220 test_183() { # LU-2275
11221 remote_mds_nodsh && skip "remote MDS with nodsh" && return
11222 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.3.56) ]] &&
11223 skip "Need MDS version at least 2.3.56" && return
11225 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11226 mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
11227 echo aaa > $DIR/$tdir/$tfile
11229 #define OBD_FAIL_MDS_NEGATIVE_POSITIVE 0x148
11230 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x148
11232 ls -l $DIR/$tdir && error "ls succeeded, should have failed"
11233 cat $DIR/$tdir/$tfile && error "cat succeeded, should have failed"
11235 do_facet $SINGLEMDS $LCTL set_param fail_loc=0
11237 # Flush negative dentry cache
11238 touch $DIR/$tdir/$tfile
11240 # We are not checking for any leaked references here, they'll
11241 # become evident next time we do cleanup with module unload.
11244 run_test 183 "No crash or request leak in case of strange dispositions ========"
11246 # test suite 184 is for LU-2016, LU-2017
11248 check_swap_layouts_support && return 0
11250 dir0=$DIR/$tdir/$testnum
11251 test_mkdir -p -c1 $dir0 || error "creating dir $dir0"
11256 $SETSTRIPE -c1 $file1
11258 $SETSTRIPE -c2 $file2
11260 gen1=$($GETSTRIPE -g $file1)
11261 gen2=$($GETSTRIPE -g $file2)
11263 $LFS swap_layouts $file1 $file2 || error "swap of file layout failed"
11264 gen=$($GETSTRIPE -g $file1)
11265 [[ $gen1 != $gen ]] ||
11266 "Layout generation on $file1 does not change"
11267 gen=$($GETSTRIPE -g $file2)
11268 [[ $gen2 != $gen ]] ||
11269 "Layout generation on $file2 does not change"
11271 cmp $ref1 $file2 || error "content compare failed ($ref1 != $file2)"
11272 cmp $ref2 $file1 || error "content compare failed ($ref2 != $file1)"
11274 run_test 184a "Basic layout swap"
11277 check_swap_layouts_support && return 0
11279 dir0=$DIR/$tdir/$testnum
11280 mkdir -p $dir0 || error "creating dir $dir0"
11287 $SETSTRIPE -c1 $file1
11288 $SETSTRIPE -c2 $file2
11289 $SETSTRIPE -c1 $file3
11290 chown $RUNAS_ID $file3
11291 gen1=$($GETSTRIPE -g $file1)
11292 gen2=$($GETSTRIPE -g $file2)
11294 $LFS swap_layouts $dir1 $dir2 &&
11295 error "swap of directories layouts should fail"
11296 $LFS swap_layouts $dir1 $file1 &&
11297 error "swap of directory and file layouts should fail"
11298 $RUNAS $LFS swap_layouts $file1 $file2 &&
11299 error "swap of file we cannot write should fail"
11300 $LFS swap_layouts $file1 $file3 &&
11301 error "swap of file with different owner should fail"
11302 /bin/true # to clear error code
11304 run_test 184b "Forbidden layout swap (will generate errors)"
11307 check_swap_layouts_support && return 0
11309 local dir0=$DIR/$tdir/$testnum
11310 mkdir -p $dir0 || error "creating dir $dir0"
11312 local ref1=$dir0/ref1
11313 local ref2=$dir0/ref2
11314 local file1=$dir0/file1
11315 local file2=$dir0/file2
11316 # create a file large enough for the concurrent test
11317 dd if=/dev/urandom of=$ref1 bs=1M count=$((RANDOM % 50 + 20))
11318 dd if=/dev/urandom of=$ref2 bs=1M count=$((RANDOM % 50 + 20))
11319 echo "ref file size: ref1($(stat -c %s $ref1))," \
11320 "ref2($(stat -c %s $ref2))"
11323 dd if=$ref1 of=$file1 bs=16k &
11326 # Make sure dd starts to copy file
11327 while [ ! -f $file1 ]; do sleep 0.1; done
11329 $LFS swap_layouts $file1 $file2
11332 [[ $? == 0 ]] || error "concurrent write on $file1 failed"
11333 [[ $rc == 0 ]] || error "swap of $file1 and $file2 failed"
11335 # how many bytes copied before swapping layout
11336 local copied=$(stat -c %s $file2)
11337 local remaining=$(stat -c %s $ref1)
11338 remaining=$((remaining - copied))
11339 echo "Copied $copied bytes before swapping layout..."
11341 cmp -n $copied $file1 $ref2 | grep differ &&
11342 error "Content mismatch [0, $copied) of ref2 and file1"
11343 cmp -n $copied $file2 $ref1 ||
11344 error "Content mismatch [0, $copied) of ref1 and file2"
11345 cmp -i $copied:$copied -n $remaining $file1 $ref1 ||
11346 error "Content mismatch [$copied, EOF) of ref1 and file1"
11349 rm -f $ref1 $ref2 $file1 $file2
11351 run_test 184c "Concurrent write and layout swap"
11354 check_swap_layouts_support && return 0
11355 [ -z "$(which getfattr 2>/dev/null)" ] &&
11356 skip "no getfattr command" && return 0
11358 local file1=$DIR/$tdir/$tfile-1
11359 local file2=$DIR/$tdir/$tfile-2
11360 local file3=$DIR/$tdir/$tfile-3
11364 mkdir -p $DIR/$tdir
11365 touch $file1 || error "create $file1 failed"
11366 $OPENFILE -f O_CREAT:O_LOV_DELAY_CREATE $file2 ||
11367 error "create $file2 failed"
11368 $OPENFILE -f O_CREAT:O_LOV_DELAY_CREATE $file3 ||
11369 error "create $file3 failed"
11370 lovea1=$($LFS getstripe $file1 | sed 1d)
11372 $LFS swap_layouts $file2 $file3 ||
11373 error "swap $file2 $file3 layouts failed"
11374 $LFS swap_layouts $file1 $file2 ||
11375 error "swap $file1 $file2 layouts failed"
11377 lovea2=$($LFS getstripe $file2 | sed 1d)
11378 [ "$lovea1" == "$lovea2" ] || error "lovea $lovea1 != $lovea2"
11380 lovea1=$(getfattr -n trusted.lov $file1 | grep ^trusted)
11381 [[ -z "$lovea1" ]] || error "$file1 shouldn't have lovea"
11383 run_test 184d "allow stripeless layouts swap"
11386 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.6.94) ]] ||
11387 { skip "Need MDS version at least 2.6.94"; return 0; }
11388 check_swap_layouts_support && return 0
11389 [ -z "$(which getfattr 2>/dev/null)" ] &&
11390 skip "no getfattr command" && return 0
11392 local file1=$DIR/$tdir/$tfile-1
11393 local file2=$DIR/$tdir/$tfile-2
11394 local file3=$DIR/$tdir/$tfile-3
11397 mkdir -p $DIR/$tdir
11398 touch $file1 || error "create $file1 failed"
11399 $OPENFILE -f O_CREAT:O_LOV_DELAY_CREATE $file2 ||
11400 error "create $file2 failed"
11401 $OPENFILE -f O_CREAT:O_LOV_DELAY_CREATE $file3 ||
11402 error "create $file3 failed"
11404 $LFS swap_layouts $file1 $file2 ||
11405 error "swap $file1 $file2 layouts failed"
11407 lovea=$(getfattr -n trusted.lov $file1 | grep ^trusted)
11408 [[ -z "$lovea" ]] || error "$file1 shouldn't have lovea"
11410 echo 123 > $file1 || error "Should be able to write into $file1"
11412 $LFS swap_layouts $file1 $file3 ||
11413 error "swap $file1 $file3 layouts failed"
11415 echo 123 > $file1 || error "Should be able to write into $file1"
11417 rm -rf $file1 $file2 $file3
11419 run_test 184e "Recreate layout after stripeless layout swaps"
11421 test_185() { # LU-2441
11422 # LU-3553 - no volatile file support in old servers
11423 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.3.60) ]] ||
11424 { skip "Need MDS version at least 2.3.60"; return 0; }
11426 mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
11427 touch $DIR/$tdir/spoo
11428 local mtime1=$(stat -c "%Y" $DIR/$tdir)
11429 local fid=$($MULTIOP $DIR/$tdir VFw4096c) ||
11430 error "cannot create/write a volatile file"
11431 $CHECKSTAT -t file $MOUNT/.lustre/fid/$fid 2>/dev/null &&
11432 error "FID is still valid after close"
11434 multiop_bg_pause $DIR/$tdir vVw4096_c
11441 # assume that the next FID for this client is sequential, since stdout
11442 # is unfortunately eaten by multiop_bg_pause
11443 local n=$((${fidv[1]} + 1))
11444 local next_fid="${fidv[0]}:$(printf "0x%x" $n):${fidv[2]}"
11445 $CHECKSTAT -t file $MOUNT/.lustre/fid/$next_fid ||
11446 error "FID is missing before close"
11447 kill -USR1 $multi_pid
11448 # 1 second delay, so if mtime change we will see it
11450 local mtime2=$(stat -c "%Y" $DIR/$tdir)
11451 [[ $mtime1 == $mtime2 ]] || error "mtime has changed"
11453 run_test 185 "Volatile file support"
11456 remote_mds_nodsh && skip "remote MDS with nodsh" && return
11457 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.3.0) ] &&
11458 skip "Need MDS version at least 2.3.0" && return
11460 local dir0=$DIR/$tdir/$testnum
11461 mkdir -p $dir0 || error "creating dir $dir0"
11463 local file=$dir0/file1
11464 dd if=/dev/urandom of=$file count=10 bs=1M conv=fsync
11465 local dv1=$($LFS data_version $file)
11466 dd if=/dev/urandom of=$file seek=10 count=1 bs=1M conv=fsync
11467 local dv2=$($LFS data_version $file)
11468 [[ $dv1 != $dv2 ]] ||
11469 error "data version did not change on write $dv1 == $dv2"
11474 run_test 187a "Test data version change"
11477 remote_mds_nodsh && skip "remote MDS with nodsh" && return
11478 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.3.0) ] &&
11479 skip "Need MDS version at least 2.3.0" && return
11481 local dir0=$DIR/$tdir/$testnum
11482 mkdir -p $dir0 || error "creating dir $dir0"
11484 declare -a DV=$($MULTIOP $dir0 Vw1000xYw1000xY | cut -f3 -d" ")
11485 [[ ${DV[0]} != ${DV[1]} ]] ||
11486 error "data version did not change on write"\
11487 " ${DV[0]} == ${DV[1]}"
11492 run_test 187b "Test data version change on volatile file"
11495 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11496 remote_mgs_nodsh && skip "remote MGS with nodsh" && return
11498 local POOL=${POOL:-cea1}
11499 local POOL_ROOT=${POOL_ROOT:-$DIR/d200.pools}
11500 local POOL_DIR_NAME=${POOL_DIR_NAME:-dir_tst}
11503 local last_ost=$(($OSTCOUNT - 1))
11505 local ost_list=$(seq $first_ost $ost_step $last_ost)
11506 local ost_range="$first_ost $last_ost $ost_step"
11507 local test_path=$POOL_ROOT/$POOL_DIR_NAME
11508 local file_dir=$POOL_ROOT/file_tst
11509 local subdir=$test_path/subdir
11513 # former test_200a test_200b
11514 pool_add $POOL || { rc=$? ; break; }
11515 pool_add_targets $POOL $ost_range || { rc=$? ; break; }
11516 # former test_200c test_200d
11517 mkdir -p $test_path
11518 pool_set_dir $POOL $test_path || { rc=$? ; break; }
11519 pool_check_dir $POOL $test_path || { rc=$? ; break; }
11521 pool_check_dir $POOL $subdir || { rc=$? ; break; }
11522 pool_dir_rel_path $POOL $POOL_DIR_NAME $POOL_ROOT \
11523 || { rc=$? ; break; }
11524 # former test_200e test_200f
11525 local files=$((OSTCOUNT*3))
11526 pool_alloc_files $POOL $test_path $files "$ost_list" \
11527 || { rc=$? ; break; }
11528 pool_create_files $POOL $file_dir $files "$ost_list" \
11529 || { rc=$? ; break; }
11530 # former test_200g test_200h
11531 pool_lfs_df $POOL || { rc=$? ; break; }
11532 pool_file_rel_path $POOL $test_path || { rc=$? ; break; }
11534 # former test_201a test_201b test_201c
11535 pool_remove_first_target $POOL || { rc=$? ; break; }
11537 local f=$test_path/$tfile
11538 pool_remove_all_targets $POOL $f || { rc=$? ; break; }
11539 pool_remove $POOL $f || { rc=$? ; break; }
11546 run_test 200 "OST pools"
11548 # usage: default_attr <count | size | offset>
11550 $LCTL get_param -n lov.$FSNAME-clilov-\*.stripe${1}
11553 # usage: check_default_stripe_attr
11554 check_default_stripe_attr() {
11555 ACTUAL=$($GETSTRIPE $* $DIR/$tdir)
11557 --stripe-count|--count)
11558 [ -n "$2" ] && EXPECTED=0 || EXPECTED=$(default_attr count);;
11559 --stripe-size|--size)
11560 [ -n "$2" ] && EXPECTED=0 || EXPECTED=$(default_attr size);;
11561 --stripe-index|--index)
11564 error "unknown getstripe attr '$1'"
11567 [ $ACTUAL != $EXPECTED ] &&
11568 error "$DIR/$tdir has $1 '$ACTUAL', not '$EXPECTED'"
11572 test_mkdir -p $DIR/$tdir
11573 $SETSTRIPE --stripe-count 0 --stripe-size 0 --stripe-index -1 $DIR/$tdir
11575 check_default_stripe_attr --stripe-count
11576 check_default_stripe_attr --stripe-size
11577 check_default_stripe_attr --stripe-index
11581 run_test 204a "Print default stripe attributes ================="
11584 test_mkdir -p $DIR/$tdir
11585 $SETSTRIPE --stripe-count 1 $DIR/$tdir
11587 check_default_stripe_attr --stripe-size
11588 check_default_stripe_attr --stripe-index
11592 run_test 204b "Print default stripe size and offset ==========="
11595 test_mkdir -p $DIR/$tdir
11596 $SETSTRIPE --stripe-size 65536 $DIR/$tdir
11598 check_default_stripe_attr --stripe-count
11599 check_default_stripe_attr --stripe-index
11603 run_test 204c "Print default stripe count and offset ==========="
11606 test_mkdir -p $DIR/$tdir
11607 $SETSTRIPE --stripe-index 0 $DIR/$tdir
11609 check_default_stripe_attr --stripe-count
11610 check_default_stripe_attr --stripe-size
11614 run_test 204d "Print default stripe count and size ============="
11617 test_mkdir -p $DIR/$tdir
11618 $SETSTRIPE -d $DIR/$tdir
11620 check_default_stripe_attr --stripe-count --raw
11621 check_default_stripe_attr --stripe-size --raw
11622 check_default_stripe_attr --stripe-index --raw
11626 run_test 204e "Print raw stripe attributes ================="
11629 test_mkdir -p $DIR/$tdir
11630 $SETSTRIPE --stripe-count 1 $DIR/$tdir
11632 check_default_stripe_attr --stripe-size --raw
11633 check_default_stripe_attr --stripe-index --raw
11637 run_test 204f "Print raw stripe size and offset ==========="
11640 test_mkdir -p $DIR/$tdir
11641 $SETSTRIPE --stripe-size 65536 $DIR/$tdir
11643 check_default_stripe_attr --stripe-count --raw
11644 check_default_stripe_attr --stripe-index --raw
11648 run_test 204g "Print raw stripe count and offset ==========="
11651 test_mkdir -p $DIR/$tdir
11652 $SETSTRIPE --stripe-index 0 $DIR/$tdir
11654 check_default_stripe_attr --stripe-count --raw
11655 check_default_stripe_attr --stripe-size --raw
11659 run_test 204h "Print raw stripe count and size ============="
11661 # Figure out which job scheduler is being used, if any,
11662 # or use a fake one
11663 if [ -n "$SLURM_JOB_ID" ]; then # SLURM
11664 JOBENV=SLURM_JOB_ID
11665 elif [ -n "$LSB_JOBID" ]; then # Load Sharing Facility
11667 elif [ -n "$PBS_JOBID" ]; then # PBS/Maui/Moab
11669 elif [ -n "$LOADL_STEPID" ]; then # LoadLeveller
11670 JOBENV=LOADL_STEP_ID
11671 elif [ -n "$JOB_ID" ]; then # Sun Grid Engine
11674 $LCTL list_param jobid_name > /dev/null 2>&1
11675 if [ $? -eq 0 ]; then
11682 verify_jobstats() {
11687 # we don't really need to clear the stats for this test to work, since each
11688 # command has a unique jobid, but it makes debugging easier if needed.
11689 # for facet in $facets; do
11690 # local dev=$(convert_facet2label $facet)
11691 # # clear old jobstats
11692 # do_facet $facet lctl set_param *.$dev.job_stats="clear"
11695 # use a new JobID for each test, or we might see an old one
11696 [ "$JOBENV" = "FAKE_JOBID" ] &&
11697 FAKE_JOBID=id.$testnum.$(basename ${cmd[0]}).$RANDOM
11701 [ "$JOBENV" = "nodelocal" ] && {
11702 FAKE_JOBID=id.$testnum.$(basename ${cmd[0]}).$RANDOM
11703 $LCTL set_param jobid_name=$FAKE_JOBID
11707 log "Test: ${cmd[*]}"
11708 log "Using JobID environment variable $JOBENV=$JOBVAL"
11710 if [ $JOBENV = "FAKE_JOBID" ]; then
11711 FAKE_JOBID=$JOBVAL ${cmd[*]}
11716 # all files are created on OST0000
11717 for facet in $facets; do
11718 local stats="*.$(convert_facet2label $facet).job_stats"
11719 if [ $(do_facet $facet lctl get_param $stats |
11720 grep -c $JOBVAL) -ne 1 ]; then
11721 do_facet $facet lctl get_param $stats
11722 error "No jobstats for $JOBVAL found on $facet::$stats"
11729 NEW_JOBENV=${1:-$OLD_JOBENV}
11730 do_facet mgs $LCTL conf_param $FSNAME.sys.jobid_var=$NEW_JOBENV
11731 wait_update $HOSTNAME "$LCTL get_param -n jobid_var" $NEW_JOBENV
11735 do_facet $SINGLEMDS \
11736 $LCTL set_param mdt.*.job_cleanup_interval=$OLD_INTERVAL
11737 [ $OLD_JOBENV != $JOBENV ] && jobstats_set $OLD_JOBENV
11738 do_facet $SINGLEMDS lctl --device $MDT0 changelog_deregister $CL_USER
11741 test_205() { # Job stats
11742 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11743 remote_mgs_nodsh && skip "remote MGS with nodsh" && return
11744 remote_mds_nodsh && skip "remote MDS with nodsh" && return
11745 remote_ost_nodsh && skip "remote OST with nodsh" && return
11747 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep jobstats)" ] &&
11748 skip "Server doesn't support jobstats" && return 0
11749 [[ $JOBID_VAR = disable ]] && skip "jobstats is disabled" && return
11751 OLD_JOBENV=$($LCTL get_param -n jobid_var)
11752 if [ $OLD_JOBENV != $JOBENV ]; then
11753 jobstats_set $JOBENV
11754 trap cleanup_205 EXIT
11757 CL_USER=$(do_facet $SINGLEMDS lctl --device $MDT0 changelog_register -n)
11758 echo "Registered as changelog user $CL_USER"
11760 OLD_INTERVAL=$(do_facet $SINGLEMDS \
11761 lctl get_param -n mdt.*.job_cleanup_interval)
11762 local interval_new=5
11763 do_facet $SINGLEMDS \
11764 $LCTL set_param mdt.*.job_cleanup_interval=$interval_new
11765 local start=$SECONDS
11769 cmd="mkdir $DIR/$tdir"
11770 verify_jobstats "$cmd" "$SINGLEMDS"
11772 cmd="rmdir $DIR/$tdir"
11773 verify_jobstats "$cmd" "$SINGLEMDS"
11774 # mkdir on secondary MDT
11775 if [ $MDSCOUNT -gt 1 ]; then
11776 cmd="lfs mkdir -i 1 $DIR/$tdir.remote"
11777 verify_jobstats "$cmd" "mds2"
11780 cmd="mknod $DIR/$tfile c 1 3"
11781 verify_jobstats "$cmd" "$SINGLEMDS"
11783 cmd="rm -f $DIR/$tfile"
11784 verify_jobstats "$cmd" "$SINGLEMDS"
11785 # create all files on OST0000 so verify_jobstats can find OST stats
11787 cmd="$SETSTRIPE -i 0 -c 1 $DIR/$tfile"
11788 verify_jobstats "$cmd" "$SINGLEMDS"
11790 cmd="touch $DIR/$tfile"
11791 verify_jobstats "$cmd" "$SINGLEMDS ost1"
11793 cmd="dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 oflag=sync"
11794 verify_jobstats "$cmd" "ost1"
11796 cancel_lru_locks osc
11797 cmd="dd if=$DIR/$tfile of=/dev/null bs=1M count=1 iflag=direct"
11798 verify_jobstats "$cmd" "ost1"
11800 cmd="$TRUNCATE $DIR/$tfile 0"
11801 verify_jobstats "$cmd" "$SINGLEMDS ost1"
11803 cmd="mv -f $DIR/$tfile $DIR/$tdir.rename"
11804 verify_jobstats "$cmd" "$SINGLEMDS"
11805 # jobstats expiry - sleep until old stats should be expired
11806 local left=$((interval_new + 2 - (SECONDS - start)))
11807 [ $left -ge 0 ] && echo "sleep $left for expiry" && sleep $((left + 1))
11808 cmd="mkdir $DIR/$tdir.expire"
11809 verify_jobstats "$cmd" "$SINGLEMDS"
11810 [ $(do_facet $SINGLEMDS lctl get_param *.*.job_stats |
11811 grep -c "job_id.*mkdir") -gt 1 ] && error "old jobstats not expired"
11813 # Ensure that jobid are present in changelog (if supported by MDS)
11814 if [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.6.52) ]
11816 $LFS changelog $MDT0 | tail -9
11817 jobids=$($LFS changelog $MDT0 | tail -9 | grep -c "j=")
11818 [ $jobids -eq 9 ] ||
11819 error "Wrong changelog jobid count $jobids != 9"
11823 jobstats_set $JOBENV
11825 $LFS changelog $MDT0 | tail -1
11826 jobids=$($LFS changelog $MDT0 | tail -1 | grep -c "j=")
11827 [ $jobids -eq 0 ] ||
11828 error "Unexpected jobids when jobid_var=$JOBENV"
11833 run_test 205 "Verify job stats"
11835 # LU-1480, LU-1773 and LU-1657
11837 mkdir -p $DIR/$tdir
11838 $SETSTRIPE -c -1 $DIR/$tdir
11839 #define OBD_FAIL_LOV_INIT 0x1403
11840 $LCTL set_param fail_loc=0xa0001403
11841 $LCTL set_param fail_val=1
11842 touch $DIR/$tdir/$tfile || true
11844 run_test 206 "fail lov_init_raid0() doesn't lbug"
11847 dd if=/dev/zero of=$DIR/$tfile bs=4k count=$((RANDOM%10+1))
11848 local fsz=`stat -c %s $DIR/$tfile`
11849 cancel_lru_locks mdc
11851 # do not return layout in getattr intent
11852 #define OBD_FAIL_MDS_NO_LL_GETATTR 0x170
11853 $LCTL set_param fail_loc=0x170
11854 local sz=`stat -c %s $DIR/$tfile`
11856 [ $fsz -eq $sz ] || error "file size expected $fsz, actual $sz"
11860 run_test 207a "can refresh layout at glimpse"
11863 dd if=/dev/zero of=$DIR/$tfile bs=4k count=$((RANDOM%10+1))
11864 local cksum=`md5sum $DIR/$tfile`
11865 local fsz=`stat -c %s $DIR/$tfile`
11866 cancel_lru_locks mdc
11867 cancel_lru_locks osc
11869 # do not return layout in getattr intent
11870 #define OBD_FAIL_MDS_NO_LL_OPEN 0x171
11871 $LCTL set_param fail_loc=0x171
11873 # it will refresh layout after the file is opened but before read issues
11874 echo checksum is "$cksum"
11875 echo "$cksum" |md5sum -c --quiet || error "file differs"
11879 run_test 207b "can refresh layout at open"
11882 # FIXME: in this test suite, only RD lease is used. This is okay
11883 # for now as only exclusive open is supported. After generic lease
11884 # is done, this test suite should be revised. - Jinshan
11886 remote_mds_nodsh && skip "remote MDS with nodsh" && return
11887 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.4.52) ]] ||
11888 { skip "Need MDS version at least 2.4.52"; return 0; }
11890 echo "==== test 1: verify get lease work"
11891 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:eRE+eU || error "get lease error"
11893 echo "==== test 2: verify lease can be broken by upcoming open"
11894 $MULTIOP $DIR/$tfile oO_RDONLY:eR_E-eUc &
11898 $MULTIOP $DIR/$tfile oO_RDONLY:c
11899 kill -USR1 $PID && wait $PID || error "break lease error"
11901 echo "==== test 3: verify lease can't be granted if an open already exists"
11902 $MULTIOP $DIR/$tfile oO_RDONLY:_c &
11906 $MULTIOP $DIR/$tfile oO_RDONLY:eReUc && error "apply lease should fail"
11907 kill -USR1 $PID && wait $PID || error "open file error"
11909 echo "==== test 4: lease can sustain over recovery"
11910 $MULTIOP $DIR/$tfile oO_RDONLY:eR_E+eUc &
11916 kill -USR1 $PID && wait $PID || error "lease broken over recovery"
11918 echo "==== test 5: lease broken can't be regained by replay"
11919 $MULTIOP $DIR/$tfile oO_RDONLY:eR_E-eUc &
11923 # open file to break lease and then recovery
11924 $MULTIOP $DIR/$tfile oO_RDWR:c || error "open file error"
11927 kill -USR1 $PID && wait $PID || error "lease not broken over recovery"
11931 run_test 208 "Exclusive open"
11934 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep disp_stripe)" ] &&
11935 skip_env "must have disp_stripe" && return
11938 sync; sleep 5; sync;
11940 echo 3 > /proc/sys/vm/drop_caches
11941 req_before=$(awk '/ptlrpc_cache / { print $2 }' /proc/slabinfo)
11943 # open/close 500 times
11944 for i in $(seq 500); do
11948 echo 3 > /proc/sys/vm/drop_caches
11949 req_after=$(awk '/ptlrpc_cache / { print $2 }' /proc/slabinfo)
11951 echo "before: $req_before, after: $req_after"
11952 [ $((req_after - req_before)) -ge 300 ] &&
11953 error "open/close requests are not freed"
11956 run_test 209 "read-only open/close requests should be freed promptly"
11960 size=$((size % 8192 + 1))
11961 dd if=/dev/urandom of=$DIR/f212 bs=1k count=$size
11962 sendfile $DIR/f212 $DIR/f212.xyz || error "sendfile wrong"
11963 rm -f $DIR/f212 $DIR/f212.xyz
11965 run_test 212 "Sendfile test ============================================"
11968 dd if=/dev/zero of=$DIR/$tfile bs=4k count=4
11969 cancel_lru_locks osc
11970 lctl set_param fail_loc=0x8000040f
11971 # generate a read lock
11972 cat $DIR/$tfile > /dev/null
11973 # write to the file, it will try to cancel the above read lock.
11974 cat /etc/hosts >> $DIR/$tfile
11976 run_test 213 "OSC lock completion and cancel race don't crash - bug 18829"
11978 test_214() { # for bug 20133
11979 mkdir -p $DIR/$tdir/d214c || error "mkdir $DIR/$tdir/d214c failed"
11980 for (( i=0; i < 340; i++ )) ; do
11981 touch $DIR/$tdir/d214c/a$i
11984 ls -l $DIR/$tdir || error "ls -l $DIR/d214p failed"
11985 mv $DIR/$tdir/d214c $DIR/ || error "mv $DIR/d214p/d214c $DIR/ failed"
11986 ls $DIR/d214c || error "ls $DIR/d214c failed"
11987 rm -rf $DIR/$tdir || error "rm -rf $DIR/d214* failed"
11988 rm -rf $DIR/d214* || error "rm -rf $DIR/d214* failed"
11990 run_test 214 "hash-indexed directory test - bug 20133"
11992 # having "abc" as 1st arg, creates $TMP/lnet_abc.out and $TMP/lnet_abc.sys
11993 create_lnet_proc_files() {
11994 lctl get_param -n $1 >$TMP/lnet_$1.out || error "cannot read lnet.$1"
11995 sysctl lnet.$1 >$TMP/lnet_$1.sys_tmp || error "cannot read lnet.$1"
11997 sed "s/^lnet.$1\ =\ //g" "$TMP/lnet_$1.sys_tmp" >$TMP/lnet_$1.sys
11998 rm -f "$TMP/lnet_$1.sys_tmp"
12001 # counterpart of create_lnet_proc_files
12002 remove_lnet_proc_files() {
12003 rm -f $TMP/lnet_$1.out $TMP/lnet_$1.sys
12006 # uses 1st arg as trailing part of filename, 2nd arg as description for reports,
12007 # 3rd arg as regexp for body
12008 check_lnet_proc_stats() {
12009 local l=$(cat "$TMP/lnet_$1" |wc -l)
12010 [ $l = 1 ] || (cat "$TMP/lnet_$1" && error "$2 is not of 1 line: $l")
12012 grep -E "$3" "$TMP/lnet_$1" || (cat "$TMP/lnet_$1" && error "$2 misformatted")
12015 # uses 1st arg as trailing part of filename, 2nd arg as description for reports,
12016 # 3rd arg as regexp for body, 4th arg as regexp for 1st line, 5th arg is
12017 # optional and can be regexp for 2nd line (lnet.routes case)
12018 check_lnet_proc_entry() {
12019 local blp=2 # blp stands for 'position of 1st line of body'
12020 [ -z "$5" ] || blp=3 # lnet.routes case
12022 local l=$(cat "$TMP/lnet_$1" |wc -l)
12023 # subtracting one from $blp because the body can be empty
12024 [ "$l" -ge "$(($blp - 1))" ] || (cat "$TMP/lnet_$1" && error "$2 is too short: $l")
12026 sed -n '1 p' "$TMP/lnet_$1" |grep -E "$4" >/dev/null ||
12027 (cat "$TMP/lnet_$1" && error "1st line of $2 misformatted")
12029 [ "$5" = "" ] || sed -n '2 p' "$TMP/lnet_$1" |grep -E "$5" >/dev/null ||
12030 (cat "$TMP/lnet_$1" && error "2nd line of $2 misformatted")
12032 # bail out if any unexpected line happened
12033 sed -n "$blp p" "$TMP/lnet_$1" | grep -Ev "$3"
12034 [ "$?" != 0 ] || error "$2 misformatted"
12037 test_215() { # for bugs 18102, 21079, 21517
12038 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12039 local N='(0|[1-9][0-9]*)' # non-negative numeric
12040 local P='[1-9][0-9]*' # positive numeric
12041 local I='(0|-?[1-9][0-9]*|NA)' # any numeric (0 | >0 | <0) or NA if no value
12042 local NET='[a-z][a-z0-9]*' # LNET net like o2ib2
12043 local ADDR='[0-9.]+' # LNET addr like 10.0.0.1
12044 local NID="$ADDR@$NET" # LNET nid like 10.0.0.1@o2ib2
12046 local L1 # regexp for 1st line
12047 local L2 # regexp for 2nd line (optional)
12048 local BR # regexp for the rest (body)
12050 # lnet.stats should look as 11 space-separated non-negative numerics
12051 BR="^$N $N $N $N $N $N $N $N $N $N $N$"
12052 create_lnet_proc_files "stats"
12053 check_lnet_proc_stats "stats.sys" "lnet.stats" "$BR"
12054 remove_lnet_proc_files "stats"
12056 # lnet.routes should look like this:
12057 # Routing disabled/enabled
12058 # net hops priority state router
12059 # where net is a string like tcp0, hops > 0, priority >= 0,
12060 # state is up/down,
12061 # router is a string like 192.168.1.1@tcp2
12062 L1="^Routing (disabled|enabled)$"
12063 L2="^net +hops +priority +state +router$"
12064 BR="^$NET +$N +(0|1) +(up|down) +$NID$"
12065 create_lnet_proc_files "routes"
12066 check_lnet_proc_entry "routes.sys" "lnet.routes" "$BR" "$L1" "$L2"
12067 remove_lnet_proc_files "routes"
12069 # lnet.routers should look like this:
12070 # ref rtr_ref alive_cnt state last_ping ping_sent deadline down_ni router
12071 # where ref > 0, rtr_ref > 0, alive_cnt >= 0, state is up/down,
12072 # last_ping >= 0, ping_sent is boolean (0/1), deadline and down_ni are
12073 # numeric (0 or >0 or <0), router is a string like 192.168.1.1@tcp2
12074 L1="^ref +rtr_ref +alive_cnt +state +last_ping +ping_sent +deadline +down_ni +router$"
12075 BR="^$P +$P +$N +(up|down) +$N +(0|1) +$I +$I +$NID$"
12076 create_lnet_proc_files "routers"
12077 check_lnet_proc_entry "routers.sys" "lnet.routers" "$BR" "$L1"
12078 remove_lnet_proc_files "routers"
12080 # lnet.peers should look like this:
12081 # nid refs state last max rtr min tx min queue
12082 # where nid is a string like 192.168.1.1@tcp2, refs > 0,
12083 # state is up/down/NA, max >= 0. last, rtr, min, tx, min are
12084 # numeric (0 or >0 or <0), queue >= 0.
12085 L1="^nid +refs +state +last +max +rtr +min +tx +min +queue$"
12086 BR="^$NID +$P +(up|down|NA) +$I +$N +$I +$I +$I +$I +$N$"
12087 create_lnet_proc_files "peers"
12088 check_lnet_proc_entry "peers.sys" "lnet.peers" "$BR" "$L1"
12089 remove_lnet_proc_files "peers"
12091 # lnet.buffers should look like this:
12092 # pages count credits min
12093 # where pages >=0, count >=0, credits and min are numeric (0 or >0 or <0)
12094 L1="^pages +count +credits +min$"
12095 BR="^ +$N +$N +$I +$I$"
12096 create_lnet_proc_files "buffers"
12097 check_lnet_proc_entry "buffers.sys" "lnet.buffers" "$BR" "$L1"
12098 remove_lnet_proc_files "buffers"
12100 # lnet.nis should look like this:
12101 # nid status alive refs peer rtr max tx min
12102 # where nid is a string like 192.168.1.1@tcp2, status is up/down,
12103 # alive is numeric (0 or >0 or <0), refs >= 0, peer >= 0,
12104 # rtr >= 0, max >=0, tx and min are numeric (0 or >0 or <0).
12105 L1="^nid +status +alive +refs +peer +rtr +max +tx +min$"
12106 BR="^$NID +(up|down) +$I +$N +$N +$N +$N +$I +$I$"
12107 create_lnet_proc_files "nis"
12108 check_lnet_proc_entry "nis.sys" "lnet.nis" "$BR" "$L1"
12109 remove_lnet_proc_files "nis"
12111 # can we successfully write to lnet.stats?
12112 lctl set_param -n stats=0 || error "cannot write to lnet.stats"
12113 sysctl -w lnet.stats=0 || error "cannot write to lnet.stats"
12115 run_test 215 "lnet exists and has proper content - bugs 18102, 21079, 21517"
12117 test_216() { # bug 20317
12118 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12119 remote_ost_nodsh && skip "remote OST with nodsh" && return
12122 local facets=$(get_facets OST)
12123 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
12125 save_lustre_params client "osc.*.contention_seconds" > $p
12126 save_lustre_params $facets \
12127 "ldlm.namespaces.filter-*.max_nolock_bytes" >> $p
12128 save_lustre_params $facets \
12129 "ldlm.namespaces.filter-*.contended_locks" >> $p
12130 save_lustre_params $facets \
12131 "ldlm.namespaces.filter-*.contention_seconds" >> $p
12134 # agressive lockless i/o settings
12135 for node in $(osts_nodes); do
12136 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'
12138 lctl set_param -n osc.*.contention_seconds 60
12140 $DIRECTIO write $DIR/$tfile 0 10 4096
12141 $CHECKSTAT -s 40960 $DIR/$tfile
12143 # disable lockless i/o
12144 for node in $(osts_nodes); do
12145 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'
12147 lctl set_param -n osc.*.contention_seconds 0
12150 dd if=/dev/zero of=$DIR/$tfile count=0
12151 $CHECKSTAT -s 0 $DIR/$tfile
12153 restore_lustre_params <$p
12157 run_test 216 "check lockless direct write works and updates file size and kms correctly"
12159 test_217() { # bug 22430
12160 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12164 for node in $(nodes_list); do
12165 nid=$(host_nids_address $node $NETTYPE)
12166 if [[ $nid = *-* ]] ; then
12167 echo "lctl ping $nid@$NETTYPE"
12168 lctl ping $nid@$NETTYPE
12170 echo "skipping $node (no hyphen detected)"
12174 run_test 217 "check lctl ping for hostnames with hiphen ('-')"
12177 # do directio so as not to populate the page cache
12178 log "creating a 10 Mb file"
12179 $MULTIOP $DIR/$tfile oO_CREAT:O_DIRECT:O_RDWR:w$((10*1048576))c || error "multiop failed while creating a file"
12180 log "starting reads"
12181 dd if=$DIR/$tfile of=/dev/null bs=4096 &
12182 log "truncating the file"
12183 $MULTIOP $DIR/$tfile oO_TRUNC:c || error "multiop failed while truncating the file"
12185 kill %+ || true # reads might have finished
12186 echo "wait until dd is finished"
12188 log "removing the temporary file"
12189 rm -rf $DIR/$tfile || error "tmp file removal failed"
12191 run_test 218 "parallel read and truncate should not deadlock ======================="
12194 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12195 # write one partial page
12196 dd if=/dev/zero of=$DIR/$tfile bs=1024 count=1
12197 # set no grant so vvp_io_commit_write will do sync write
12198 $LCTL set_param fail_loc=0x411
12199 # write a full page at the end of file
12200 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 seek=1 conv=notrunc
12202 $LCTL set_param fail_loc=0
12203 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 seek=3
12204 $LCTL set_param fail_loc=0x411
12205 dd if=/dev/zero of=$DIR/$tfile bs=1024 count=1 seek=2 conv=notrunc
12208 dd if=/dev/zero of=$DIR/$tfile-2 bs=1024 count=1
12209 $CHECKSTAT -s 1024 $DIR/$tfile-2 || error "checkstat wrong size"
12211 run_test 219 "LU-394: Write partial won't cause uncontiguous pages vec at LND"
12213 test_220() { #LU-325
12214 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12215 remote_ost_nodsh && skip "remote OST with nodsh" && return
12216 remote_mds_nodsh && skip "remote MDS with nodsh" && return
12217 remote_mgs_nodsh && skip "remote MGS with nodsh" && return
12220 # create on MDT0000 so the last_id and next_id are correct
12222 local OST=$($LFS df $DIR | awk '/OST:'$OSTIDX'/ { print $1 }')
12226 local mdtosc_proc1=$(get_mdtosc_proc_path $SINGLEMDS $OST)
12227 local last_id=$(do_facet $SINGLEMDS lctl get_param -n \
12228 osc.$mdtosc_proc1.prealloc_last_id)
12229 local next_id=$(do_facet $SINGLEMDS lctl get_param -n \
12230 osc.$mdtosc_proc1.prealloc_next_id)
12234 do_facet ost$((OSTIDX + 1)) lctl set_param fail_val=-1
12235 #define OBD_FAIL_OST_ENOINO 0x229
12236 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=0x229
12237 do_facet mgs $LCTL pool_new $FSNAME.$TESTNAME || return 1
12238 do_facet mgs $LCTL pool_add $FSNAME.$TESTNAME $OST || return 2
12240 $SETSTRIPE $DIR/$tdir -i $OSTIDX -c 1 -p $FSNAME.$TESTNAME
12242 MDSOBJS=$((last_id - next_id))
12243 echo "preallocated objects on MDS is $MDSOBJS" "($last_id - $next_id)"
12245 blocks=$($LFS df $MOUNT | awk '($1 == '$OSTIDX') { print $4 }')
12246 echo "OST still has $count kbytes free"
12248 echo "create $MDSOBJS files @next_id..."
12249 createmany -o $DIR/$tdir/f $MDSOBJS || return 3
12251 local last_id2=$(do_facet mds${MDSIDX} lctl get_param -n \
12252 osc.$mdtosc_proc1.prealloc_last_id)
12253 local next_id2=$(do_facet mds${MDSIDX} lctl get_param -n \
12254 osc.$mdtosc_proc1.prealloc_next_id)
12256 echo "after creation, last_id=$last_id2, next_id=$next_id2"
12261 do_facet ost$((OSTIDX + 1)) lctl set_param fail_val=0
12262 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=0
12264 do_facet mgs $LCTL pool_remove $FSNAME.$TESTNAME $OST || return 4
12265 do_facet mgs $LCTL pool_destroy $FSNAME.$TESTNAME || return 5
12266 echo "unlink $MDSOBJS files @$next_id..."
12267 unlinkmany $DIR/$tdir/f $MDSOBJS || return 6
12269 run_test 220 "preallocated MDS objects still used if ENOSPC from OST"
12272 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12273 dd if=`which date` of=$MOUNT/date oflag=sync
12274 chmod +x $MOUNT/date
12276 #define OBD_FAIL_LLITE_FAULT_TRUNC_RACE 0x1401
12277 $LCTL set_param fail_loc=0x80001401
12279 $MOUNT/date > /dev/null
12282 run_test 221 "make sure fault and truncate race to not cause OOM"
12285 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12287 test_mkdir -p $DIR/$tdir
12288 $SETSTRIPE -c 1 -i 0 $DIR/$tdir
12289 createmany -o $DIR/$tdir/$tfile 10
12290 cancel_lru_locks mdc
12291 cancel_lru_locks osc
12292 #define OBD_FAIL_LDLM_AGL_DELAY 0x31a
12293 $LCTL set_param fail_loc=0x31a
12294 ls -l $DIR/$tdir > /dev/null || error "AGL for ls failed"
12295 $LCTL set_param fail_loc=0
12298 run_test 222a "AGL for ls should not trigger CLIO lock failure ================"
12301 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12303 test_mkdir -p $DIR/$tdir
12304 $SETSTRIPE -c 1 -i 0 $DIR/$tdir
12305 createmany -o $DIR/$tdir/$tfile 10
12306 cancel_lru_locks mdc
12307 cancel_lru_locks osc
12308 #define OBD_FAIL_LDLM_AGL_DELAY 0x31a
12309 $LCTL set_param fail_loc=0x31a
12310 rm -r $DIR/$tdir || "AGL for rmdir failed"
12311 $LCTL set_param fail_loc=0
12313 run_test 222b "AGL for rmdir should not trigger CLIO lock failure ============="
12316 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12318 test_mkdir -p $DIR/$tdir
12319 $SETSTRIPE -c 1 -i 0 $DIR/$tdir
12320 createmany -o $DIR/$tdir/$tfile 10
12321 cancel_lru_locks mdc
12322 cancel_lru_locks osc
12323 #define OBD_FAIL_LDLM_AGL_NOLOCK 0x31b
12324 $LCTL set_param fail_loc=0x31b
12325 ls -l $DIR/$tdir > /dev/null || error "reenqueue failed"
12326 $LCTL set_param fail_loc=0
12329 run_test 223 "osc reenqueue if without AGL lock granted ======================="
12331 test_224a() { # LU-1039, MRP-303
12332 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12333 #define OBD_FAIL_PTLRPC_CLIENT_BULK_CB 0x508
12334 $LCTL set_param fail_loc=0x508
12335 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 conv=fsync
12336 $LCTL set_param fail_loc=0
12339 run_test 224a "Don't panic on bulk IO failure"
12341 test_224b() { # LU-1039, MRP-303
12342 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12343 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1
12344 cancel_lru_locks osc
12345 #define OBD_FAIL_PTLRPC_CLIENT_BULK_CB2 0x515
12346 $LCTL set_param fail_loc=0x515
12347 dd of=/dev/null if=$DIR/$tfile bs=4096 count=1
12348 $LCTL set_param fail_loc=0
12351 run_test 224b "Don't panic on bulk IO failure"
12353 test_224c() { # LU-6441
12354 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12355 local pages_per_rpc=$($LCTL get_param \
12356 osc.*.max_pages_per_rpc)
12357 local at_max=$($LCTL get_param -n at_max)
12358 local timeout=$($LCTL get_param -n timeout)
12359 local test_at="$LCTL get_param -n at_max"
12360 local param_at="$FSNAME.sys.at_max"
12361 local test_timeout="$LCTL get_param -n timeout"
12362 local param_timeout="$FSNAME.sys.timeout"
12364 $LCTL set_param -n osc.*.max_pages_per_rpc=1024
12366 set_conf_param_and_check client "$test_at" "$param_at" 0 ||
12367 error "conf_param at_max=0 failed"
12368 set_conf_param_and_check client "$test_timeout" "$param_timeout" 5 ||
12369 error "conf_param timeout=5 failed"
12371 #define OBD_FAIL_PTLRPC_CLIENT_BULK_CB3 0x520
12372 $LCTL set_param fail_loc=0x520
12373 dd if=/dev/zero of=$DIR/$tfile bs=8MB count=1
12375 $LCTL set_param fail_loc=0
12377 set_conf_param_and_check client "$test_at" "$param_at" $at_max ||
12378 error "conf_param at_max=$at_max failed"
12379 set_conf_param_and_check client "$test_timeout" "$param_timeout" \
12380 $timeout || error "conf_param timeout=$timeout failed"
12382 $LCTL set_param -n $pages_per_rpc
12384 run_test 224c "Don't hang if one of md lost during large bulk RPC"
12386 MDSSURVEY=${MDSSURVEY:-$(which mds-survey 2>/dev/null || true)}
12388 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12389 remote_mds_nodsh && skip "remote MDS with nodsh" && return
12390 if [ -z ${MDSSURVEY} ]; then
12391 skip_env "mds-survey not found" && return
12394 [ $MDSCOUNT -ge 2 ] &&
12395 skip "skipping now for more than one MDT" && return
12397 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.51) ] ||
12398 { skip "Need MDS version at least 2.2.51"; return; }
12400 local mds=$(facet_host $SINGLEMDS)
12401 local target=$(do_nodes $mds 'lctl dl' | \
12402 awk "{if (\$2 == \"UP\" && \$3 == \"mdt\") {print \$4}}")
12404 local cmd1="file_count=1000 thrhi=4"
12405 local cmd2="dir_count=2 layer=mdd stripe_count=0"
12406 local cmd3="rslt_loc=${TMP} targets=\"$mds:$target\" $MDSSURVEY"
12407 local cmd="$cmd1 $cmd2 $cmd3"
12409 rm -f ${TMP}/mds_survey*
12411 eval $cmd || error "mds-survey with zero-stripe failed"
12412 cat ${TMP}/mds_survey*
12413 rm -f ${TMP}/mds_survey*
12415 run_test 225a "Metadata survey sanity with zero-stripe"
12418 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12419 remote_mds_nodsh && skip "remote MDS with nodsh" && return
12420 if [ -z ${MDSSURVEY} ]; then
12421 skip_env "mds-survey not found" && return
12423 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.51) ] ||
12424 { skip "Need MDS version at least 2.2.51"; return; }
12426 if [ $($LCTL dl | grep -c osc) -eq 0 ]; then
12427 skip_env "Need to mount OST to test" && return
12430 [ $MDSCOUNT -ge 2 ] &&
12431 skip "skipping now for more than one MDT" && return
12432 local mds=$(facet_host $SINGLEMDS)
12433 local target=$(do_nodes $mds 'lctl dl' | \
12434 awk "{if (\$2 == \"UP\" && \$3 == \"mdt\") {print \$4}}")
12436 local cmd1="file_count=1000 thrhi=4"
12437 local cmd2="dir_count=2 layer=mdd stripe_count=1"
12438 local cmd3="rslt_loc=${TMP} targets=\"$mds:$target\" $MDSSURVEY"
12439 local cmd="$cmd1 $cmd2 $cmd3"
12441 rm -f ${TMP}/mds_survey*
12443 eval $cmd || error "mds-survey with stripe_count failed"
12444 cat ${TMP}/mds_survey*
12445 rm -f ${TMP}/mds_survey*
12447 run_test 225b "Metadata survey sanity with stripe_count = 1"
12449 mcreate_path2fid () {
12455 local path=$DIR/$tdir/$name
12460 $MCREATE --mode=$1 --major=$2 --minor=$3 $path ||
12461 error "cannot create $desc"
12463 fid=$($LFS path2fid $path | tr -d '[' | tr -d ']')
12465 [ $rc -ne 0 ] && error "cannot get fid of a $desc"
12467 fid_path=$($LFS fid2path $MOUNT $fid)
12469 [ $rc -ne 0 ] && error "cannot get path of $desc by $DIR $path $fid"
12471 [ "$path" == "$fid_path" ] ||
12472 error "fid2path returned $fid_path, expected $path"
12474 echo "pass with $path and $fid"
12479 mkdir -p $DIR/$tdir
12481 mcreate_path2fid 0010666 0 0 fifo "FIFO"
12482 mcreate_path2fid 0020666 1 3 null "character special file (null)"
12483 mcreate_path2fid 0020666 1 255 none "character special file (no device)"
12484 mcreate_path2fid 0040666 0 0 dir "directory"
12485 mcreate_path2fid 0060666 7 0 loop0 "block special file (loop)"
12486 mcreate_path2fid 0100666 0 0 file "regular file"
12487 mcreate_path2fid 0120666 0 0 link "symbolic link"
12488 mcreate_path2fid 0140666 0 0 sock "socket"
12490 run_test 226a "call path2fid and fid2path on files of all type"
12493 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
12497 mkdir -p $DIR/$tdir
12498 $LFS setdirstripe -i $MDTIDX $DIR/$tdir/remote_dir ||
12499 error "create remote directory failed"
12500 mcreate_path2fid 0010666 0 0 "remote_dir/fifo" "FIFO"
12501 mcreate_path2fid 0020666 1 3 "remote_dir/null" \
12502 "character special file (null)"
12503 mcreate_path2fid 0020666 1 255 "remote_dir/none" \
12504 "character special file (no device)"
12505 mcreate_path2fid 0040666 0 0 "remote_dir/dir" "directory"
12506 mcreate_path2fid 0060666 7 0 "remote_dir/loop0" \
12507 "block special file (loop)"
12508 mcreate_path2fid 0100666 0 0 "remote_dir/file" "regular file"
12509 mcreate_path2fid 0120666 0 0 "remote_dir/link" "symbolic link"
12510 mcreate_path2fid 0140666 0 0 "remote_dir/sock" "socket"
12512 run_test 226b "call path2fid and fid2path on files of all type under remote dir"
12514 # LU-1299 Executing or running ldd on a truncated executable does not
12515 # cause an out-of-memory condition.
12517 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12518 [ -z "$(which ldd)" ] && skip "should have ldd tool" && return
12519 dd if=$(which date) of=$MOUNT/date bs=1k count=1
12520 chmod +x $MOUNT/date
12522 $MOUNT/date > /dev/null
12523 ldd $MOUNT/date > /dev/null
12526 run_test 227 "running truncated executable does not cause OOM"
12528 # LU-1512 try to reuse idle OI blocks
12530 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12531 remote_mds_nodsh && skip "remote MDS with nodsh" && return
12532 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
12533 skip "non-ldiskfs backend" && return
12535 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
12536 local myDIR=$DIR/$tdir
12539 #define OBD_FAIL_SEQ_EXHAUST 0x1002
12540 $LCTL set_param fail_loc=0x80001002
12541 createmany -o $myDIR/t- 10000
12542 $LCTL set_param fail_loc=0
12543 # The guard is current the largest FID holder
12545 local SEQ=$($LFS path2fid $myDIR/guard | awk -F ':' '{print $1}' |
12547 local IDX=$(($SEQ % 64))
12549 do_facet $SINGLEMDS sync
12550 # Make sure journal flushed.
12552 local blk1=$(do_facet $SINGLEMDS \
12553 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
12554 grep Blockcount | awk '{print $4}')
12556 # Remove old files, some OI blocks will become idle.
12557 unlinkmany $myDIR/t- 10000
12558 # Create new files, idle OI blocks should be reused.
12559 createmany -o $myDIR/t- 2000
12560 do_facet $SINGLEMDS sync
12561 # Make sure journal flushed.
12563 local blk2=$(do_facet $SINGLEMDS \
12564 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
12565 grep Blockcount | awk '{print $4}')
12567 [ $blk1 == $blk2 ] || error "old blk1=$blk1, new blk2=$blk2, unmatched!"
12569 run_test 228a "try to reuse idle OI blocks"
12572 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12573 remote_mds_nodsh && skip "remote MDS with nodsh" && return
12574 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
12575 skip "non-ldiskfs backend" && return
12577 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
12578 local myDIR=$DIR/$tdir
12581 #define OBD_FAIL_SEQ_EXHAUST 0x1002
12582 $LCTL set_param fail_loc=0x80001002
12583 createmany -o $myDIR/t- 10000
12584 $LCTL set_param fail_loc=0
12585 # The guard is current the largest FID holder
12587 local SEQ=$($LFS path2fid $myDIR/guard | awk -F ':' '{print $1}' |
12589 local IDX=$(($SEQ % 64))
12591 do_facet $SINGLEMDS sync
12592 # Make sure journal flushed.
12594 local blk1=$(do_facet $SINGLEMDS \
12595 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
12596 grep Blockcount | awk '{print $4}')
12598 # Remove old files, some OI blocks will become idle.
12599 unlinkmany $myDIR/t- 10000
12602 stop $SINGLEMDS || error "Fail to stop MDT."
12604 start $SINGLEMDS $MDT_DEV $MDS_MOUNT_OPTS || error "Fail to start MDT."
12606 df $MOUNT || error "Fail to df."
12607 # Create new files, idle OI blocks should be reused.
12608 createmany -o $myDIR/t- 2000
12609 do_facet $SINGLEMDS sync
12610 # Make sure journal flushed.
12612 local blk2=$(do_facet $SINGLEMDS \
12613 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
12614 grep Blockcount | awk '{print $4}')
12616 [ $blk1 == $blk2 ] || error "old blk1=$blk1, new blk2=$blk2, unmatched!"
12618 run_test 228b "idle OI blocks can be reused after MDT restart"
12622 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12623 remote_mds_nodsh && skip "remote MDS with nodsh" && return
12624 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
12625 skip "non-ldiskfs backend" && return
12627 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
12628 local myDIR=$DIR/$tdir
12631 #define OBD_FAIL_SEQ_EXHAUST 0x1002
12632 $LCTL set_param fail_loc=0x80001002
12633 # 20000 files can guarantee there are index nodes in the OI file
12634 createmany -o $myDIR/t- 20000
12635 $LCTL set_param fail_loc=0
12636 # The guard is current the largest FID holder
12638 local SEQ=$($LFS path2fid $myDIR/guard | awk -F ':' '{print $1}' |
12640 local IDX=$(($SEQ % 64))
12642 do_facet $SINGLEMDS sync
12643 # Make sure journal flushed.
12645 local blk1=$(do_facet $SINGLEMDS \
12646 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
12647 grep Blockcount | awk '{print $4}')
12649 # Remove old files, some OI blocks will become idle.
12650 unlinkmany $myDIR/t- 20000
12652 # The OI file should become empty now
12654 # Create new files, idle OI blocks should be reused.
12655 createmany -o $myDIR/t- 2000
12656 do_facet $SINGLEMDS sync
12657 # Make sure journal flushed.
12659 local blk2=$(do_facet $SINGLEMDS \
12660 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
12661 grep Blockcount | awk '{print $4}')
12663 [ $blk1 == $blk2 ] || error "old blk1=$blk1, new blk2=$blk2, unmatched!"
12665 run_test 228c "NOT shrink the last entry in OI index node to recycle idle leaf"
12667 test_229() { # LU-2482, LU-3448
12668 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.53) ] &&
12669 skip "No HSM $(lustre_build_version $SINGLEMDS) MDS < 2.4.53" &&
12671 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12672 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs" && return
12676 # Create a file with a released layout and stripe count 2.
12677 $MULTIOP $DIR/$tfile H2c ||
12678 error "failed to create file with released layout"
12680 $GETSTRIPE -v $DIR/$tfile
12682 local pattern=$($GETSTRIPE -L $DIR/$tfile)
12683 [ X"$pattern" = X"80000001" ] || error "pattern error ($pattern)"
12685 local stripe_count=$($GETSTRIPE -c $DIR/$tfile) || error "getstripe"
12686 [ $stripe_count -eq 2 ] || error "stripe count not 2 ($stripe_count)"
12687 stat $DIR/$tfile || error "failed to stat released file"
12689 chown $RUNAS_ID $DIR/$tfile ||
12690 error "chown $RUNAS_ID $DIR/$tfile failed"
12692 chgrp $RUNAS_ID $DIR/$tfile ||
12693 error "chgrp $RUNAS_ID $DIR/$tfile failed"
12695 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
12696 rm $DIR/$tfile || error "failed to remove released file"
12698 run_test 229 "getstripe/stat/rm/attr changes work on released files"
12701 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12702 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
12705 test_mkdir $DIR/$tdir
12706 test_mkdir -i0 -c1 $DIR/$tdir/test_230_local
12707 local mdt_idx=$($GETSTRIPE -M $DIR/$tdir/test_230_local)
12708 [ $mdt_idx -ne 0 ] &&
12709 error "create local directory on wrong MDT $mdt_idx"
12711 $LFS mkdir -i $MDTIDX $DIR/$tdir/test_230 ||
12712 error "create remote directory failed"
12713 local mdt_idx=$($GETSTRIPE -M $DIR/$tdir/test_230)
12714 [ $mdt_idx -ne $MDTIDX ] &&
12715 error "create remote directory on wrong MDT $mdt_idx"
12717 createmany -o $DIR/$tdir/test_230/t- 10 ||
12718 error "create files on remote directory failed"
12719 mdt_idx=$($GETSTRIPE -M $DIR/$tdir/test_230/t-0)
12720 [ $mdt_idx -ne $MDTIDX ] && error "create files on wrong MDT $mdt_idx"
12721 rm -r $DIR/$tdir || error "unlink remote directory failed"
12723 run_test 230a "Create remote directory and files under the remote directory"
12726 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12727 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
12734 local migrate_dir=$DIR/$tdir/migrate_dir
12735 local other_dir=$DIR/$tdir/other_dir
12737 test_mkdir $DIR/$tdir
12738 test_mkdir -i0 -c1 $migrate_dir
12739 test_mkdir -i0 -c1 $other_dir
12740 for ((i=0; i<10; i++)); do
12741 mkdir -p $migrate_dir/dir_${i}
12742 createmany -o $migrate_dir/dir_${i}/f 10 ||
12743 error "create files under remote dir failed $i"
12746 cp /etc/passwd $migrate_dir/$tfile
12747 cp /etc/passwd $other_dir/$tfile
12748 chattr +SAD $migrate_dir
12749 chattr +SAD $migrate_dir/$tfile
12751 local old_dir_flag=$(lsattr -a $migrate_dir | awk '/\/\.$/ {print $1}')
12752 local old_file_flag=$(lsattr $migrate_dir/$tfile | awk '{print $1}')
12753 local old_dir_mode=$(stat -c%f $migrate_dir)
12754 local old_file_mode=$(stat -c%f $migrate_dir/$tfile)
12756 mkdir -p $migrate_dir/dir_default_stripe2
12757 $SETSTRIPE -c 2 $migrate_dir/dir_default_stripe2
12758 $SETSTRIPE -c 2 $migrate_dir/${tfile}_stripe2
12760 mkdir -p $other_dir
12761 ln $migrate_dir/$tfile $other_dir/luna
12762 ln $migrate_dir/$tfile $migrate_dir/sofia
12763 ln $other_dir/$tfile $migrate_dir/david
12764 ln -s $migrate_dir/$tfile $other_dir/zachary
12765 ln -s $migrate_dir/$tfile $migrate_dir/${tfile}_ln
12766 ln -s $other_dir/$tfile $migrate_dir/${tfile}_ln_other
12768 $LFS migrate -m $MDTIDX $migrate_dir ||
12769 error "fails on migrating remote dir to MDT1"
12771 echo "migratate to MDT1, then checking.."
12772 for ((i = 0; i < 10; i++)); do
12773 for file in $(find $migrate_dir/dir_${i}); do
12774 mdt_index=$($LFS getstripe -M $file)
12775 [ $mdt_index == $MDTIDX ] ||
12776 error "$file is not on MDT${MDTIDX}"
12780 # the multiple link file should still in MDT0
12781 mdt_index=$($LFS getstripe -M $migrate_dir/$tfile)
12782 [ $mdt_index == 0 ] ||
12783 error "$file is not on MDT${MDTIDX}"
12785 local new_dir_flag=$(lsattr -a $migrate_dir | awk '/\/\.$/ {print $1}')
12786 [ "$old_dir_flag" = "$new_dir_flag" ] ||
12787 error " expect $old_dir_flag get $new_dir_flag"
12789 local new_file_flag=$(lsattr $migrate_dir/$tfile | awk '{print $1}')
12790 [ "$old_file_flag" = "$new_file_flag" ] ||
12791 error " expect $old_file_flag get $new_file_flag"
12793 local new_dir_mode=$(stat -c%f $migrate_dir)
12794 [ "$old_dir_mode" = "$new_dir_mode" ] ||
12795 error "expect mode $old_dir_mode get $new_dir_mode"
12797 local new_file_mode=$(stat -c%f $migrate_dir/$tfile)
12798 [ "$old_file_mode" = "$new_file_mode" ] ||
12799 error "expect mode $old_file_mode get $new_file_mode"
12801 diff /etc/passwd $migrate_dir/$tfile ||
12802 error "$tfile different after migration"
12804 diff /etc/passwd $other_dir/luna ||
12805 error "luna different after migration"
12807 diff /etc/passwd $migrate_dir/sofia ||
12808 error "sofia different after migration"
12810 diff /etc/passwd $migrate_dir/david ||
12811 error "david different after migration"
12813 diff /etc/passwd $other_dir/zachary ||
12814 error "zachary different after migration"
12816 diff /etc/passwd $migrate_dir/${tfile}_ln ||
12817 error "${tfile}_ln different after migration"
12819 diff /etc/passwd $migrate_dir/${tfile}_ln_other ||
12820 error "${tfile}_ln_other different after migration"
12822 stripe_count=$($LFS getstripe -c $migrate_dir/dir_default_stripe2)
12823 [ $stripe_count = 2 ] ||
12824 error "dir strpe_count $d != 2 after migration."
12826 stripe_count=$($LFS getstripe -c $migrate_dir/${tfile}_stripe2)
12827 [ $stripe_count = 2 ] ||
12828 error "file strpe_count $d != 2 after migration."
12830 #migrate back to MDT0
12833 $LFS migrate -m $MDTIDX $migrate_dir ||
12834 error "fails on migrating remote dir to MDT0"
12836 echo "migrate back to MDT0, checking.."
12837 for file in $(find $migrate_dir); do
12838 mdt_index=$($LFS getstripe -M $file)
12839 [ $mdt_index == $MDTIDX ] ||
12840 error "$file is not on MDT${MDTIDX}"
12843 local new_dir_flag=$(lsattr -a $migrate_dir | awk '/\/\.$/ {print $1}')
12844 [ "$old_dir_flag" = "$new_dir_flag" ] ||
12845 error " expect $old_dir_flag get $new_dir_flag"
12847 local new_file_flag=$(lsattr $migrate_dir/$tfile | awk '{print $1}')
12848 [ "$old_file_flag" = "$new_file_flag" ] ||
12849 error " expect $old_file_flag get $new_file_flag"
12851 local new_dir_mode=$(stat -c%f $migrate_dir)
12852 [ "$old_dir_mode" = "$new_dir_mode" ] ||
12853 error "expect mode $old_dir_mode get $new_dir_mode"
12855 local new_file_mode=$(stat -c%f $migrate_dir/$tfile)
12856 [ "$old_file_mode" = "$new_file_mode" ] ||
12857 error "expect mode $old_file_mode get $new_file_mode"
12859 diff /etc/passwd ${migrate_dir}/$tfile ||
12860 error "$tfile different after migration"
12862 diff /etc/passwd ${other_dir}/luna ||
12863 error "luna different after migration"
12865 diff /etc/passwd ${migrate_dir}/sofia ||
12866 error "sofia different after migration"
12868 diff /etc/passwd ${other_dir}/zachary ||
12869 error "zachary different after migration"
12871 diff /etc/passwd $migrate_dir/${tfile}_ln ||
12872 error "${tfile}_ln different after migration"
12874 diff /etc/passwd $migrate_dir/${tfile}_ln_other ||
12875 error "${tfile}_ln_other different after migration"
12877 stripe_count=$($LFS getstripe -c ${migrate_dir}/dir_default_stripe2)
12878 [ $stripe_count = 2 ] ||
12879 error "dir strpe_count $d != 2 after migration."
12881 stripe_count=$($LFS getstripe -c ${migrate_dir}/${tfile}_stripe2)
12882 [ $stripe_count = 2 ] ||
12883 error "file strpe_count $d != 2 after migration."
12885 rm -rf $DIR/$tdir || error "rm dir failed after migration"
12887 run_test 230b "migrate directory"
12890 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12891 remote_mds_nodsh && skip "remote MDS with nodsh" && return
12892 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
12896 local migrate_dir=$DIR/$tdir/migrate_dir
12898 #If migrating directory fails in the middle, all entries of
12899 #the directory is still accessiable.
12900 test_mkdir $DIR/$tdir
12901 test_mkdir -i0 -c1 $migrate_dir
12903 createmany -o $migrate_dir/f 10 ||
12904 error "create files under ${migrate_dir} failed"
12906 #failed after migrating 5 entries
12907 #OBD_FAIL_MIGRATE_ENTRIES 0x1801
12908 do_facet mds1 lctl set_param fail_loc=0x20001801
12909 do_facet mds1 lctl set_param fail_val=5
12910 local t=$(ls $migrate_dir | wc -l)
12911 $LFS migrate --mdt-index $MDTIDX $migrate_dir &&
12912 error "migrate should fail after 5 entries"
12914 mkdir $migrate_dir/dir &&
12915 error "mkdir succeeds under migrating directory"
12916 touch $migrate_dir/file &&
12917 error "touch file succeeds under migrating directory"
12919 local u=$(ls $migrate_dir | wc -l)
12920 [ "$u" == "$t" ] || error "$u != $t during migration"
12922 for file in $(find $migrate_dir); do
12923 stat $file || error "stat $file failed"
12926 do_facet mds1 lctl set_param fail_loc=0
12927 do_facet mds1 lctl set_param fail_val=0
12929 $LFS migrate -m $MDTIDX $migrate_dir ||
12930 error "migrate open files should failed with open files"
12932 echo "Finish migration, then checking.."
12933 for file in $(find $migrate_dir); do
12934 mdt_index=$($LFS getstripe -M $file)
12935 [ $mdt_index == $MDTIDX ] ||
12936 error "$file is not on MDT${MDTIDX}"
12939 rm -rf $DIR/$tdir || error "rm dir failed after migration"
12941 run_test 230c "check directory accessiblity if migration is failed"
12944 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12945 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
12948 local migrate_dir=$DIR/$tdir/migrate_dir
12952 test_mkdir $DIR/$tdir
12953 test_mkdir -i0 -c1 $migrate_dir
12955 for ((i=0; i<100; i++)); do
12956 test_mkdir -i0 -c1 $migrate_dir/dir_${i}
12957 createmany -o $migrate_dir/dir_${i}/f 100 ||
12958 error "create files under remote dir failed $i"
12961 $LFS migrate -m $MDTIDX $migrate_dir ||
12962 error "migrate remote dir error"
12964 echo "Finish migration, then checking.."
12965 for file in $(find $migrate_dir); do
12966 mdt_index=$($LFS getstripe -M $file)
12967 [ $mdt_index == $MDTIDX ] ||
12968 error "$file is not on MDT${MDTIDX}"
12971 rm -rf $DIR/$tdir || error "rm dir failed after migration"
12973 run_test 230d "check migrate big directory"
12976 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12977 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
12983 mkdir -p $DIR/$tdir
12984 mkdir $DIR/$tdir/migrate_dir
12985 mkdir $DIR/$tdir/other_dir
12986 touch $DIR/$tdir/migrate_dir/a
12987 ln $DIR/$tdir/migrate_dir/a $DIR/$tdir/other_dir/b
12988 ls $DIR/$tdir/other_dir
12990 $LFS migrate -m 1 $DIR/$tdir/migrate_dir ||
12991 error "migrate dir fails"
12993 mdt_index=$($LFS getstripe -M $DIR/$tdir/migrate_dir)
12994 [ $mdt_index == 1 ] || error "migrate_dir is not on MDT1"
12996 mdt_index=$($LFS getstripe -M $DIR/$tdir/migrate_dir/a)
12997 [ $mdt_index == 0 ] || error "a is not on MDT0"
12999 $LFS migrate -m 1 $DIR/$tdir/other_dir ||
13000 error "migrate dir fails"
13002 mdt_index=$($LFS getstripe -M $DIR/$tdir/other_dir)
13003 [ $mdt_index == 1 ] || error "other_dir is not on MDT1"
13005 mdt_index=$($LFS getstripe -M $DIR/$tdir/migrate_dir/a)
13006 [ $mdt_index == 1 ] || error "a is not on MDT1"
13008 mdt_index=$($LFS getstripe -M $DIR/$tdir/other_dir/b)
13009 [ $mdt_index == 1 ] || error "b is not on MDT1"
13011 a_fid=$($LFS path2fid $DIR/$tdir/migrate_dir/a)
13012 b_fid=$($LFS path2fid $DIR/$tdir/other_dir/b)
13014 [ "$a_fid" = "$b_fid" ] || error "different fid after migration"
13016 rm -rf $DIR/$tdir || error "rm dir failed after migration"
13018 run_test 230e "migrate mulitple local link files"
13021 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13022 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
13026 mkdir -p $DIR/$tdir
13027 mkdir $DIR/$tdir/migrate_dir
13028 $LFS mkdir -i1 $DIR/$tdir/other_dir
13029 touch $DIR/$tdir/migrate_dir/a
13030 ln $DIR/$tdir/migrate_dir/a $DIR/$tdir/other_dir/ln1
13031 ln $DIR/$tdir/migrate_dir/a $DIR/$tdir/other_dir/ln2
13032 ls $DIR/$tdir/other_dir
13034 # a should be migrated to MDT1, since no other links on MDT0
13035 $LFS migrate -m 1 $DIR/$tdir/migrate_dir ||
13036 error "migrate dir fails"
13037 mdt_index=$($LFS getstripe -M $DIR/$tdir/migrate_dir)
13038 [ $mdt_index == 1 ] || error "migrate_dir is not on MDT1"
13039 mdt_index=$($LFS getstripe -M $DIR/$tdir/migrate_dir/a)
13040 [ $mdt_index == 1 ] || error "a is not on MDT1"
13042 # a should stay on MDT1, because it is a mulitple link file
13043 $LFS migrate -m 0 $DIR/$tdir/migrate_dir ||
13044 error "migrate dir fails"
13045 mdt_index=$($LFS getstripe -M $DIR/$tdir/migrate_dir/a)
13046 [ $mdt_index == 1 ] || error "a is not on MDT1"
13048 $LFS migrate -m 1 $DIR/$tdir/migrate_dir ||
13049 error "migrate dir fails"
13051 a_fid=$($LFS path2fid $DIR/$tdir/migrate_dir/a)
13052 ln_fid=$($LFS path2fid $DIR/$tdir/other_dir/ln1)
13053 [ "$a_fid" = "$ln_fid" ] || error "different fid after migrate to MDT1"
13055 rm -rf $DIR/$tdir/other_dir/ln1 || error "unlink ln1 fails"
13056 rm -rf $DIR/$tdir/other_dir/ln2 || error "unlink ln2 fails"
13058 # a should be migrated to MDT0, since no other links on MDT1
13059 $LFS migrate -m 0 $DIR/$tdir/migrate_dir ||
13060 error "migrate dir fails"
13061 mdt_index=$($LFS getstripe -M $DIR/$tdir/migrate_dir/a)
13062 [ $mdt_index == 0 ] || error "a is not on MDT0"
13064 rm -rf $DIR/$tdir || error "rm dir failed after migration"
13066 run_test 230f "migrate mulitple remote link files"
13069 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13070 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
13072 mkdir -p $DIR/$tdir/migrate_dir
13074 $LFS migrate -m 1000 $DIR/$tdir/migrate_dir &&
13075 error "migrating dir to non-exist MDT succeeds"
13078 run_test 230g "migrate dir to non-exist MDT"
13081 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13082 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
13083 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.64) ] &&
13084 skip "Need MDS version at least 2.7.64" && return
13087 mkdir -p $DIR/$tdir/migrate_dir
13089 $LFS migrate -m1 $DIR &&
13090 error "migrating mountpoint1 should fail"
13092 $LFS migrate -m1 $DIR/$tdir/.. &&
13093 error "migrating mountpoint2 should fail"
13095 $LFS migrate -m1 $DIR/$tdir/migrate_dir/.. ||
13096 error "migrating $tdir fail"
13098 mdt_index=$($LFS getstripe -M $DIR/$tdir)
13099 [ $mdt_index == 1 ] || error "$mdt_index != 1 after migration"
13101 mdt_index=$($LFS getstripe -M $DIR/$tdir/migrate_dir)
13102 [ $mdt_index == 1 ] || error "$mdt_index != 1 after migration"
13105 run_test 230h "migrate .. and root"
13108 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13109 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
13111 mkdir -p $DIR/$tdir/migrate_dir
13113 $LFS migrate -m 1 $DIR/$tdir/migrate_dir/ ||
13114 error "migration fails with a tailing slash"
13116 $LFS migrate -m 0 $DIR/$tdir/migrate_dir// ||
13117 error "migration fails with two tailing slashes"
13119 run_test 230i "lfs migrate -m tolerates trailing slashes"
13123 # For simplicity this test assumes that max_pages_per_rpc
13124 # is the same across all OSCs
13125 local max_pages=$($LCTL get_param -n osc.*.max_pages_per_rpc | head -n1)
13126 local bulk_size=$((max_pages * 4096))
13128 mkdir -p $DIR/$tdir
13130 # clear the OSC stats
13131 $LCTL set_param osc.*.stats=0 &>/dev/null
13134 # Client writes $bulk_size - there must be 1 rpc for $max_pages.
13135 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=$bulk_size count=1 \
13136 oflag=direct &>/dev/null || error "dd failed"
13138 sync; sleep 1; sync # just to be safe
13139 local nrpcs=$($LCTL get_param osc.*.stats |awk '/ost_write/ {print $2}')
13140 if [ x$nrpcs != "x1" ]; then
13141 $LCTL get_param osc.*.stats
13142 error "found $nrpcs ost_write RPCs, not 1 as expected"
13146 # Drop the OSC cache, otherwise we will read from it
13147 cancel_lru_locks osc
13149 # clear the OSC stats
13150 $LCTL set_param osc.*.stats=0 &>/dev/null
13152 # Client reads $bulk_size.
13153 dd if=$DIR/$tdir/$tfile of=/dev/null bs=$bulk_size count=1 \
13154 iflag=direct &>/dev/null || error "dd failed"
13156 nrpcs=$($LCTL get_param osc.*.stats | awk '/ost_read/ { print $2 }')
13157 if [ x$nrpcs != "x1" ]; then
13158 $LCTL get_param osc.*.stats
13159 error "found $nrpcs ost_read RPCs, not 1 as expected"
13162 run_test 231a "checking that reading/writing of BRW RPC size results in one RPC"
13165 mkdir -p $DIR/$tdir
13167 for i in {0..1023}; do
13168 dd if=/dev/zero of=$DIR/$tdir/$tfile conv=notrunc \
13169 seek=$((2 * i)) bs=4096 count=1 &>/dev/null ||
13170 error "dd of=$DIR/$tdir/$tfile seek=$((2 * i)) failed"
13174 run_test 231b "must not assert on fully utilized OST request buffer"
13177 mkdir -p $DIR/$tdir
13178 #define OBD_FAIL_LDLM_OST_LVB 0x31c
13179 $LCTL set_param fail_loc=0x31c
13181 # ignore dd failure
13182 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=1 || true
13184 $LCTL set_param fail_loc=0
13185 umount_client $MOUNT || error "umount failed"
13186 mount_client $MOUNT || error "mount failed"
13188 run_test 232 "failed lock should not block umount"
13191 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.3.64) ] ||
13192 { skip "Need MDS version at least 2.3.64"; return; }
13194 local fid=$($LFS path2fid $MOUNT)
13195 stat $MOUNT/.lustre/fid/$fid > /dev/null ||
13196 error "cannot access $MOUNT using its FID '$fid'"
13198 run_test 233a "checking that OBF of the FS root succeeds"
13201 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.5.90) ] ||
13202 { skip "Need MDS version at least 2.5.90"; return; }
13204 local fid=$($LFS path2fid $MOUNT/.lustre)
13205 stat $MOUNT/.lustre/fid/$fid > /dev/null ||
13206 error "cannot access $MOUNT/.lustre using its FID '$fid'"
13208 fid=$($LFS path2fid $MOUNT/.lustre/fid)
13209 stat $MOUNT/.lustre/fid/$fid > /dev/null ||
13210 error "cannot access $MOUNT/.lustre/fid using its FID '$fid'"
13212 run_test 233b "checking that OBF of the FS .lustre succeeds"
13215 local p="$TMP/sanityN-$TESTNAME.parameters"
13216 save_lustre_params client "llite.*.xattr_cache" > $p
13217 lctl set_param llite.*.xattr_cache 1 ||
13218 { skip "xattr cache is not supported"; return 0; }
13220 mkdir -p $DIR/$tdir || error "mkdir failed"
13221 touch $DIR/$tdir/$tfile || error "touch failed"
13222 # OBD_FAIL_LLITE_XATTR_ENOMEM
13223 $LCTL set_param fail_loc=0x1405
13224 # output of the form: attr 2 4 44 3 fc13 x86_64
13225 V=($(IFS=".-" rpm -q attr))
13226 if [[ ${V[1]} > 2 || ${V[2]} > 4 || ${V[3]} > 44 ||
13227 ${V[1]} = 2 && ${V[2]} = 4 && ${V[3]} = 44 && ${V[4]} > 6 ]]; then
13228 # attr pre-2.4.44-7 had a bug with rc
13229 # LU-3703 - SLES 11 and FC13 clients have older attr
13230 getfattr -n user.attr $DIR/$tdir/$tfile &&
13231 error "getfattr should have failed with ENOMEM"
13233 skip "LU-3703: attr version $(getfattr --version) too old"
13235 $LCTL set_param fail_loc=0x0
13238 restore_lustre_params < $p
13241 run_test 234 "xattr cache should not crash on ENOMEM"
13244 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.52) ] &&
13245 skip "Need MDS version at least 2.4.52" && return
13246 flock_deadlock $DIR/$tfile
13251 124) error "process hangs on a deadlock"
13253 *) error "error executing flock_deadlock $DIR/$tfile"
13257 run_test 235 "LU-1715: flock deadlock detection does not work properly"
13261 check_swap_layouts_support && return 0
13262 test_mkdir -p -c1 $DIR/$tdir || error "mkdir $tdir failed"
13264 local ref1=/etc/passwd
13265 local ref2=/etc/group
13266 local file1=$DIR/$tdir/f1
13267 local file2=$DIR/$tdir/f2
13269 $SETSTRIPE -c 1 $file1 || error "cannot setstripe on '$file1': rc = $?"
13270 cp $ref1 $file1 || error "cp $ref1 $file1 failed: rc = $?"
13271 $SETSTRIPE -c 2 $file2 || error "cannot setstripe on '$file2': rc = $?"
13272 cp $ref2 $file2 || error "cp $ref2 $file2 failed: rc = $?"
13273 local fd=$(free_fd)
13274 local cmd="exec $fd<>$file2"
13277 $LFS swap_layouts $file1 /proc/self/fd/${fd} ||
13278 error "cannot swap layouts of '$file1' and /proc/self/fd/${fd}"
13281 cmp $ref2 $file1 || error "content compare failed ($ref2 != $file1)"
13286 run_test 236 "Layout swap on open unlinked file"
13288 # test to verify file handle related system calls
13289 # (name_to_handle_at/open_by_handle_at)
13290 # The new system calls are supported in glibc >= 2.14.
13293 echo "Test file_handle syscalls" > $DIR/$tfile ||
13294 error "write failed"
13295 check_fhandle_syscalls $DIR/$tfile ||
13296 error "check_fhandle_syscalls failed"
13298 run_test 237 "Verify name_to_handle_at/open_by_handle_at syscalls"
13300 # LU-4659 linkea consistency
13302 local server_version=$(lustre_version_code $SINGLEMDS)
13304 [[ $server_version -gt $(version_code 2.5.57) ]] ||
13305 [[ $server_version -gt $(version_code 2.5.1) &&
13306 $server_version -lt $(version_code 2.5.50) ]] ||
13307 { skip "Need MDS version at least 2.5.58 or 2.5.2+"; return; }
13310 ln $DIR/$tfile $DIR/$tfile.lnk
13311 touch $DIR/$tfile.new
13312 mv $DIR/$tfile.new $DIR/$tfile
13313 local fid1=$($LFS path2fid $DIR/$tfile)
13314 local fid2=$($LFS path2fid $DIR/$tfile.lnk)
13315 local path1=$($LFS fid2path $FSNAME "$fid1")
13316 [ $tfile == $path1 ] || error "linkea inconsistent: $tfile $fid1 $path1"
13317 local path2=$($LFS fid2path $FSNAME "$fid2")
13318 [ $tfile.lnk == $path2 ] ||
13319 error "linkea inconsistent: $tfile.lnk $fid2 $path2!"
13322 run_test 238 "Verify linkea consistency"
13325 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.5.60) ] &&
13326 skip "Need MDS version at least 2.5.60" && return
13327 local list=$(comma_list $(mdts_nodes))
13329 mkdir -p $DIR/$tdir
13330 createmany -o $DIR/$tdir/f- 5000
13331 unlinkmany $DIR/$tdir/f- 5000
13332 do_nodes $list "lctl set_param -n osp*.*.sync_changes 1"
13333 changes=$(do_nodes $list "lctl get_param -n osc.*MDT*.sync_changes \
13334 osc.*MDT*.sync_in_flight" | calc_sum)
13335 [ "$changes" -eq 0 ] || error "$changes not synced"
13337 run_test 239 "osp_sync test"
13339 test_239a() { #LU-5297
13341 #define OBD_FAIL_OSP_CHECK_INVALID_REC 0x2100
13342 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x2100
13343 chgrp $RUNAS_GID $DIR/$tfile
13344 wait_delete_completed
13346 run_test 239a "process invalid osp sync record correctly"
13348 test_239b() { #LU-5297
13350 #define OBD_FAIL_OSP_CHECK_ENOMEM 0x2101
13351 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x2101
13352 chgrp $RUNAS_GID $DIR/$tfile1
13353 wait_delete_completed
13354 do_facet $SINGLEMDS $LCTL set_param fail_loc=0
13356 chgrp $RUNAS_GID $DIR/$tfile2
13357 wait_delete_completed
13359 run_test 239b "process osp sync record with ENOMEM error correctly"
13362 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
13364 mkdir -p $DIR/$tdir
13366 $LFS mkdir -i 0 $DIR/$tdir/d0 ||
13367 error "failed to mkdir $DIR/$tdir/d0 on MDT0"
13368 $LFS mkdir -i 1 $DIR/$tdir/d0/d1 ||
13369 error "failed to mkdir $DIR/$tdir/d0/d1 on MDT1"
13371 umount_client $MOUNT || error "umount failed"
13372 #define OBD_FAIL_TGT_DELAY_CONDITIONAL 0x713
13373 do_facet mds2 lctl set_param fail_loc=0x713 fail_val=1
13374 mount_client $MOUNT || error "failed to mount client"
13376 echo "stat $DIR/$tdir/d0/d1, should not fail/ASSERT"
13377 stat $DIR/$tdir/d0/d1 || error "fail to stat $DIR/$tdir/d0/d1"
13379 run_test 240 "race between ldlm enqueue and the connection RPC (no ASSERT)"
13382 for LOOP in $(seq $1); do
13383 dd if=$DIR/$tfile of=/dev/null bs=40960 count=1 2>/dev/null
13384 cancel_lru_locks osc || true
13389 for LOOP in $(seq $1); do
13390 dd if=$DIR/$tfile of=/dev/null bs=40960 count=1 \
13391 iflag=direct 2>/dev/null
13396 dd if=/dev/zero of=$DIR/$tfile count=1 bs=40960
13398 cancel_lru_locks osc
13399 test_241_bio 1000 &
13404 run_test 241 "bio vs dio"
13407 dd if=/dev/zero of=$DIR/$tfile count=1 bs=40960
13409 test_241_dio 1000 &
13414 run_test 241b "dio vs dio"
13417 mkdir -p $DIR/$tdir
13418 touch $DIR/$tdir/$tfile
13420 #define OBD_FAIL_MDS_READPAGE_PACK 0x105
13421 do_facet mds1 lctl set_param fail_loc=0x105
13422 /bin/ls $DIR/$tdir && error "ls $DIR/$tdir should fail"
13424 do_facet mds1 lctl set_param fail_loc=0
13425 /bin/ls $DIR/$tdir || error "ls $DIR/$tdir failed"
13427 run_test 242 "mdt_readpage failure should not cause directory unreadable"
13431 test_mkdir -p $DIR/$tdir
13432 group_lock_test -d $DIR/$tdir || error "A group lock test failed"
13434 run_test 243 "various group lock tests"
13438 test_mkdir -p $DIR/$tdir
13439 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=35
13440 sendfile_grouplock $DIR/$tdir/$tfile || \
13441 error "sendfile+grouplock failed"
13444 run_test 244 "sendfile with group lock tests"
13447 local flagname="multi_mod_rpcs"
13448 local connect_data_name="max_mod_rpcs"
13451 # check if multiple modify RPCs flag is set
13452 out=$($LCTL get_param mdc.$FSNAME-MDT0000-*.import |
13453 grep "connect_flags:")
13456 echo "$out" | grep -qw $flagname
13457 if [ $? -ne 0 ]; then
13458 echo "connect flag $flagname is not set"
13462 # check if multiple modify RPCs data is set
13463 out=$($LCTL get_param mdc.$FSNAME-MDT0000-*.import)
13466 echo "$out" | grep -qw $connect_data_name ||
13467 error "import should have connect data $connect_data_name"
13469 run_test 245 "check mdc connection flag/data: multiple modify RPCs"
13471 test_246() { # LU-7371
13472 [ $(lustre_version_code ost1) -lt $(version_code 2.7.62) ] &&
13473 skip "Need OST version >= 2.7.62" && return 0
13474 do_facet ost1 $LCTL set_param fail_val=4095
13475 #define OBD_FAIL_OST_READ_SIZE 0x234
13476 do_facet ost1 $LCTL set_param fail_loc=0x234
13477 $LFS setstripe $DIR/$tfile -i 0 -c 1
13478 dd if=/dev/zero of=$DIR/$tfile bs=4095 count=1 > /dev/null 2>&1
13479 cancel_lru_locks $FSNAME-OST0000
13480 dd if=$DIR/$tfile of=/dev/null bs=1048576 || error "Read failed"
13482 run_test 246 "Read file of size 4095 should return right length"
13485 [ "$(facet_fstype ost$(($($GETSTRIPE -i $DIR/$tfile) + 1)))" = "zfs" ] \
13486 && skip "no 16TB file size limit on ZFS" && return
13488 $SETSTRIPE -c 1 $DIR/$tfile
13489 # ldiskfs extent file size limit is (16TB - 4KB - 1) bytes
13490 local size=$((16 * 1024 * 1024 * 1024 * 1024 - 4096 - 1))
13491 $TRUNCATE $DIR/$tfile $size || error "truncate $tfile to $size failed"
13492 dd if=/dev/zero of=$DIR/$tfile bs=10 count=1 oflag=append \
13493 conv=notrunc,fsync && error "append succeeded"
13496 run_test 250 "Write above 16T limit"
13499 $SETSTRIPE -c -1 -S 1048576 $DIR/$tfile
13501 #define OBD_FAIL_LLITE_LOST_LAYOUT 0x1407
13502 #Skip once - writing the first stripe will succeed
13503 $LCTL set_param fail_loc=0xa0001407 fail_val=1
13504 $MULTIOP $DIR/$tfile o:O_RDWR:w2097152c 2>&1 | grep -q "short write" &&
13505 error "short write happened"
13507 $LCTL set_param fail_loc=0xa0001407 fail_val=1
13508 $MULTIOP $DIR/$tfile or2097152c 2>&1 | grep -q "short read" &&
13509 error "short read happened"
13513 run_test 251 "Handling short read and write correctly"
13523 if [ "$(facet_fstype ost1)" != "ldiskfs" -o \
13524 "$(facet_fstype mds1)" != "ldiskfs" ]; then
13525 skip "can only run lr_reader on ldiskfs target"
13529 # check lr_reader on OST0000
13531 dev=$(facet_device $tgt)
13532 out=$(do_facet $tgt $LR_READER $dev)
13533 [ $? -eq 0 ] || error "$LR_READER failed on target $tgt device $dev"
13535 uuid=$(echo "$out" | grep -i uuid | awk '{ print $2 }')
13536 [ "$uuid" == "$(ostuuid_from_index 0)" ] ||
13537 error "Invalid uuid returned by $LR_READER on target $tgt"
13538 echo -e "uuid returned by $LR_READER is '$uuid'\n"
13540 # check lr_reader -c on MDT0000
13542 dev=$(facet_device $tgt)
13543 if ! do_facet $tgt $LR_READER -h | grep -q OPTIONS; then
13544 echo "$LR_READER does not support additional options"
13547 out=$(do_facet $tgt $LR_READER -c $dev)
13548 [ $? -eq 0 ] || error "$LR_READER failed on target $tgt device $dev"
13550 num=$(echo "$out" | grep -c "mdtlov")
13551 [ "$num" -eq $((MDSCOUNT - 1)) ] ||
13552 error "Invalid number of mdtlov clients returned by $LR_READER"
13553 echo -e "Number of mdtlov clients returned by $LR_READER is '$num'\n"
13555 # check lr_reader -cr on MDT0000
13556 out=$(do_facet $tgt $LR_READER -cr $dev)
13557 [ $? -eq 0 ] || error "$LR_READER failed on target $tgt device $dev"
13559 echo "$out" | grep -q "^reply_data:$" ||
13560 error "$LR_READER should have returned 'reply_data' section"
13561 num=$(echo "$out" | grep -c "client_generation")
13562 echo -e "Number of reply data returned by $LR_READER is '$num'\n"
13564 run_test 252 "check lr_reader tool"
13571 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13572 remote_mds_nodsh && skip "remote MDS with nodsh" && return
13573 [ "$(facet_fstype mds1)" != "ldiskfs" ] &&
13574 skip "non-ldiskfs backend" && return
13576 mdt_dev=$(mdsdevname 1)
13578 cl_user=$(do_facet mds1 \
13579 "$LCTL get_param -n mdd.$MDT0.changelog_users | grep cl")
13580 if [[ -n $cl_user ]]; then
13581 skip "active changelog user"
13585 cl_user=$(do_facet mds1 $LCTL --device $MDT0 changelog_register -n)
13586 echo "Registered as changelog user $cl_user"
13589 mkdir -p $DIR/$tdir
13591 $LFS changelog_clear $MDT0 $cl_user 0
13594 touch $DIR/$tdir/{1..10}
13597 stop mds1 || error "Fail to stop MDT."
13600 start mds1 $mdt_dev $MDS_MOUNT_OPTS || error "Fail to start MDT."
13602 #after mount new plainllog is used
13603 touch $DIR/$tdir/{11..19}
13604 cat_sl=$(do_facet mds1 \
13605 "$DEBUGFS -R \\\"dump changelog_catalog cat.dmp\\\" $mdt_dev; \
13606 llog_reader cat.dmp | grep \\\"type=1064553b\\\" | wc -l")
13608 if (( cat_sl != 2 )); then
13609 do_facet mds1 $LCTL --device $MDT0 changelog_deregister $cl_user
13610 error "Changelog catalog has wrong number of slots $cat_sl"
13613 $LFS changelog_clear $MDT0 $cl_user 0
13615 cat_sl=$(do_facet mds1 \
13616 "$DEBUGFS -R \\\"dump changelog_catalog cat.dmp\\\" $mdt_dev; \
13617 llog_reader cat.dmp | grep \\\"type=1064553b\\\" | wc -l")
13619 do_facet mds1 $LCTL --device $MDT0 changelog_deregister $cl_user
13621 if (( cat_sl == 2 )); then
13622 error "Empty plain llog was not deleted from changelog catalog"
13624 if (( cat_sl != 1 )); then
13625 error "Active plain llog shouldn\`t be deleted from catalog"
13628 run_test 256 "Check llog delete for empty and not full state"
13630 cleanup_test_300() {
13634 test_striped_dir() {
13639 mkdir -p $DIR/$tdir
13641 SAVE_UMASK=$(umask)
13642 trap cleanup_test_300 RETURN EXIT
13644 $LFS setdirstripe -i $mdt_index -c 2 -t all_char -m 755 \
13645 $DIR/$tdir/striped_dir ||
13646 error "set striped dir error"
13648 local mode=$(stat -c%a $DIR/$tdir/striped_dir)
13649 [ "$mode" = "755" ] || error "expect 755 got $mode"
13651 $LFS getdirstripe $DIR/$tdir/striped_dir > /dev/null 2>&1 ||
13652 error "getdirstripe failed"
13653 stripe_count=$($LFS getdirstripe -c $DIR/$tdir/striped_dir)
13654 if [ "$stripe_count" != "2" ]; then
13655 error "stripe_count is $stripe_count, expect 2"
13658 stripe_index=$($LFS getdirstripe -i $DIR/$tdir/striped_dir)
13659 if [ "$stripe_index" != "$mdt_index" ]; then
13660 error "stripe_index is $stripe_index, expect $mdt_index"
13663 [ $(stat -c%h $DIR/$tdir/striped_dir) == '2' ] ||
13664 error "nlink error after create striped dir"
13666 mkdir $DIR/$tdir/striped_dir/a
13667 mkdir $DIR/$tdir/striped_dir/b
13669 stat $DIR/$tdir/striped_dir/a ||
13670 error "create dir under striped dir failed"
13671 stat $DIR/$tdir/striped_dir/b ||
13672 error "create dir under striped dir failed"
13674 [ $(stat -c%h $DIR/$tdir/striped_dir) == '4' ] ||
13675 error "nlink error after mkdir"
13677 rmdir $DIR/$tdir/striped_dir/a
13678 [ $(stat -c%h $DIR/$tdir/striped_dir) == '3' ] ||
13679 error "nlink error after rmdir"
13681 rmdir $DIR/$tdir/striped_dir/b
13682 [ $(stat -c%h $DIR/$tdir/striped_dir) == '2' ] ||
13683 error "nlink error after rmdir"
13685 chattr +i $DIR/$tdir/striped_dir
13686 createmany -o $DIR/$tdir/striped_dir/f 10 &&
13687 error "immutable flags not working under striped dir!"
13688 chattr -i $DIR/$tdir/striped_dir
13690 rmdir $DIR/$tdir/striped_dir ||
13691 error "rmdir striped dir error"
13699 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13700 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
13702 test_striped_dir 0 || error "failed on striped dir on MDT0"
13703 test_striped_dir 1 || error "failed on striped dir on MDT0"
13705 run_test 300a "basic striped dir sanity test"
13708 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13709 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
13715 test_mkdir $DIR/$tdir || error "mkdir fail"
13716 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir ||
13717 error "set striped dir error"
13718 for ((i=0; i<10; i++)); do
13719 mtime1=$(stat -c %Y $DIR/$tdir/striped_dir)
13721 touch $DIR/$tdir/striped_dir/file_$i ||
13722 error "touch error $i"
13723 mtime2=$(stat -c %Y $DIR/$tdir/striped_dir)
13724 [ $mtime1 -eq $mtime2 ] &&
13725 error "mtime not change after create"
13727 rm -f $DIR/$tdir/striped_dir/file_$i ||
13728 error "unlink error $i"
13729 mtime3=$(stat -c %Y $DIR/$tdir/striped_dir)
13730 [ $mtime2 -eq $mtime3 ] &&
13731 error "mtime did not change after unlink"
13735 run_test 300b "check ctime/mtime for striped dir"
13738 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13739 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
13742 mkdir -p $DIR/$tdir
13743 $LFS setdirstripe -i 0 -c 2 $DIR/$tdir/striped_dir ||
13744 error "set striped dir error"
13746 chown $RUNAS_ID:$RUNAS_GID $DIR/$tdir/striped_dir ||
13747 error "chown striped dir failed"
13749 $RUNAS createmany -o $DIR/$tdir/striped_dir/f 5000 ||
13750 error "create 5k files failed"
13752 file_count=$(ls $DIR/$tdir/striped_dir | wc -l)
13754 [ "$file_count" = 5000 ] || error "file count $file_count != 5000"
13758 run_test 300c "chown && check ls under striped directory"
13761 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13762 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
13766 mkdir -p $DIR/$tdir
13767 $SETSTRIPE -c 2 $DIR/$tdir
13769 #local striped directory
13770 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir ||
13771 error "set striped dir error"
13772 createmany -o $DIR/$tdir/striped_dir/f 10 ||
13773 error "create 10 files failed"
13775 #remote striped directory
13776 $LFS setdirstripe -i 1 -c 2 $DIR/$tdir/remote_striped_dir ||
13777 error "set striped dir error"
13778 createmany -o $DIR/$tdir/remote_striped_dir/f 10 ||
13779 error "create 10 files failed"
13781 for file in $(find $DIR/$tdir); do
13782 stripe_count=$($GETSTRIPE -c $file)
13783 [ $stripe_count -eq 2 ] ||
13784 error "wrong stripe $stripe_count for $file"
13789 run_test 300d "check default stripe under striped directory"
13792 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
13793 skip "Need MDS version at least 2.7.55" && return
13794 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13795 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
13799 mkdir -p $DIR/$tdir
13801 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir ||
13802 error "set striped dir error"
13804 touch $DIR/$tdir/striped_dir/a
13805 touch $DIR/$tdir/striped_dir/b
13806 touch $DIR/$tdir/striped_dir/c
13808 mkdir $DIR/$tdir/striped_dir/dir_a
13809 mkdir $DIR/$tdir/striped_dir/dir_b
13810 mkdir $DIR/$tdir/striped_dir/dir_c
13812 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir/stp_a ||
13813 error "set striped dir under striped dir error"
13815 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir/stp_b ||
13816 error "set striped dir under striped dir error"
13818 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir/stp_c ||
13819 error "set striped dir under striped dir error"
13821 mrename $DIR/$tdir/striped_dir/dir_a $DIR/$tdir/striped_dir/dir_b ||
13822 error "rename dir under striped dir fails"
13824 mrename $DIR/$tdir/striped_dir/stp_a $DIR/$tdir/striped_dir/stp_b ||
13825 error "rename dir under different stripes fails"
13827 mrename $DIR/$tdir/striped_dir/a $DIR/$tdir/striped_dir/c ||
13828 error "rename file under striped dir should succeed"
13830 mrename $DIR/$tdir/striped_dir/dir_b $DIR/$tdir/striped_dir/dir_c ||
13831 error "rename dir under striped dir should succeed"
13835 run_test 300e "check rename under striped directory"
13838 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
13839 skip "Need MDS version at least 2.7.55" && return
13840 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13841 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
13846 mkdir -p $DIR/$tdir
13848 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir ||
13849 error "set striped dir error"
13851 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir1 ||
13852 error "set striped dir error"
13854 touch $DIR/$tdir/striped_dir/a
13855 mkdir $DIR/$tdir/striped_dir/dir_a
13856 $LFS setdirstripe -i 0 -c 2 $DIR/$tdir/striped_dir/stp_a ||
13857 error "create striped dir under striped dir fails"
13859 touch $DIR/$tdir/striped_dir1/b
13860 mkdir $DIR/$tdir/striped_dir1/dir_b
13861 $LFS setdirstripe -i 0 -c 2 $DIR/$tdir/striped_dir/stp_b ||
13862 error "create striped dir under striped dir fails"
13864 mrename $DIR/$tdir/striped_dir/dir_a $DIR/$tdir/striped_dir1/dir_b ||
13865 error "rename dir under different striped dir should fail"
13867 mrename $DIR/$tdir/striped_dir/stp_a $DIR/$tdir/striped_dir1/stp_b ||
13868 error "rename striped dir under diff striped dir should fail"
13870 mrename $DIR/$tdir/striped_dir/a $DIR/$tdir/striped_dir1/a ||
13871 error "rename file under diff striped dirs fails"
13875 run_test 300f "check rename cross striped directory"
13877 test_300_check_default_striped_dir()
13880 local default_count=$2
13881 local default_index=$3
13884 local dir_stripe_index
13887 echo "checking $dirname $default_count $default_index"
13888 $LFS setdirstripe -D -c $default_count -i $default_index \
13889 -t all_char $DIR/$tdir/$dirname ||
13890 error "set default stripe on striped dir error"
13891 stripe_count=$($LFS getdirstripe -D -c $DIR/$tdir/$dirname)
13892 [ $stripe_count -eq $default_count ] ||
13893 error "expect $default_count get $stripe_count for $dirname"
13895 stripe_index=$($LFS getdirstripe -D -i $DIR/$tdir/$dirname)
13896 [ $stripe_index -eq $default_index ] ||
13897 error "expect $default_index get $stripe_index for $dirname"
13899 mkdir $DIR/$tdir/$dirname/{test1,test2,test3,test4} ||
13900 error "create dirs failed"
13902 createmany -o $DIR/$tdir/$dirname/f- 10 || error "create files failed"
13903 unlinkmany $DIR/$tdir/$dirname/f- 10 || error "unlink files failed"
13904 for dir in $(find $DIR/$tdir/$dirname/*); do
13905 stripe_count=$($LFS getdirstripe -c $dir)
13906 [ $stripe_count -eq $default_count ] ||
13907 [ $stripe_count -eq 0 -o $default_count -eq 1 ] ||
13908 error "stripe count $default_count != $stripe_count for $dir"
13910 stripe_index=$($LFS getdirstripe -i $dir)
13911 [ $default_index -eq -1 -o $stripe_index -eq $default_index ] ||
13912 error "$stripe_index != $default_index for $dir"
13914 #check default stripe
13915 stripe_count=$($LFS getdirstripe -D -c $dir)
13916 [ $stripe_count -eq $default_count ] ||
13917 error "default count $default_count != $stripe_count for $dir"
13919 stripe_index=$($LFS getdirstripe -D -i $dir)
13920 [ $stripe_index -eq $default_index ] ||
13921 error "default index $default_index != $stripe_index for $dir"
13923 rmdir $DIR/$tdir/$dirname/* || error "rmdir failed"
13927 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
13928 skip "Need MDS version at least 2.7.55" && return
13929 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
13935 mkdir $DIR/$tdir/normal_dir
13937 test_300_check_default_striped_dir normal_dir $MDSCOUNT 1
13938 test_300_check_default_striped_dir normal_dir 1 0
13939 test_300_check_default_striped_dir normal_dir 2 1
13940 test_300_check_default_striped_dir normal_dir 2 -1
13942 #delete default stripe information
13943 echo "delete default stripeEA"
13944 $LFS setdirstripe -d $DIR/$tdir/normal_dir ||
13945 error "set default stripe on striped dir error"
13947 mkdir -p $DIR/$tdir/normal_dir/{test1,test2,test3,test4}
13948 for dir in $(find $DIR/$tdir/normal_dir/*); do
13949 stripe_count=$($LFS getdirstripe -c $dir)
13950 [ $stripe_count -eq 0 ] ||
13951 error "expect 1 get $stripe_count for $dir"
13952 stripe_index=$($LFS getdirstripe -i $dir)
13953 [ $stripe_index -eq 0 ] ||
13954 error "expect 0 get $stripe_index for $dir"
13957 run_test 300g "check default striped directory for normal directory"
13960 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
13961 skip "Need MDS version at least 2.7.55" && return
13962 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
13967 $LFS setdirstripe -i 0 -c $MDSCOUNT -t all_char \
13968 $DIR/$tdir/striped_dir ||
13969 error "set striped dir error"
13971 test_300_check_default_striped_dir striped_dir $MDSCOUNT 1
13972 test_300_check_default_striped_dir striped_dir 1 0
13973 test_300_check_default_striped_dir striped_dir 2 1
13974 test_300_check_default_striped_dir striped_dir 2 -1
13976 #delete default stripe information
13977 $LFS setdirstripe -d $DIR/$tdir/striped_dir ||
13978 error "set default stripe on striped dir error"
13980 mkdir -p $DIR/$tdir/striped_dir/{test1,test2,test3,test4}
13981 for dir in $(find $DIR/$tdir/striped_dir/*); do
13982 stripe_count=$($LFS getdirstripe -c $dir)
13983 [ $stripe_count -eq 0 ] ||
13984 error "expect 1 get $stripe_count for $dir"
13987 run_test 300h "check default striped directory for striped directory"
13990 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
13991 skip "Need MDS version at least 2.7.55" && return
13992 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13993 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
13999 $LFS setdirstripe -i 0 -c$MDSCOUNT -t all_char $DIR/$tdir/striped_dir ||
14000 error "set striped dir error"
14002 createmany -o $DIR/$tdir/striped_dir/f- 10 ||
14003 error "create files under striped dir failed"
14005 # unfortunately, we need to umount to clear dir layout cache for now
14006 # once we fully implement dir layout, we can drop this
14007 umount_client $MOUNT || error "umount failed"
14008 mount_client $MOUNT || error "mount failed"
14010 #set the stripe to be unknown hash type
14011 #define OBD_FAIL_UNKNOWN_LMV_STRIPE 0x1901
14012 $LCTL set_param fail_loc=0x1901
14013 for ((i = 0; i < 10; i++)); do
14014 $CHECKSTAT -t file $DIR/$tdir/striped_dir/f-$i ||
14015 error "stat f-$i failed"
14016 rm $DIR/$tdir/striped_dir/f-$i || error "unlink f-$i failed"
14019 touch $DIR/$tdir/striped_dir/f0 &&
14020 error "create under striped dir with unknown hash should fail"
14022 $LCTL set_param fail_loc=0
14024 umount_client $MOUNT || error "umount failed"
14025 mount_client $MOUNT || error "mount failed"
14029 run_test 300i "client handle unknown hash type striped directory"
14032 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
14033 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
14034 skip "Need MDS version at least 2.7.55" && return
14035 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
14041 #define OBD_FAIL_SPLIT_UPDATE_REC 0x1702
14042 $LCTL set_param fail_loc=0x1702
14043 $LFS setdirstripe -i 0 -c$MDSCOUNT -t all_char $DIR/$tdir/striped_dir ||
14044 error "set striped dir error"
14046 createmany -o $DIR/$tdir/striped_dir/f- 10 ||
14047 error "create files under striped dir failed"
14049 $LCTL set_param fail_loc=0
14051 rm -rf $DIR/$tdir || error "unlink striped dir fails"
14055 run_test 300j "test large update record"
14058 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
14059 skip "Need MDS version at least 2.7.55" && return
14060 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
14061 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
14067 #define OBD_FAIL_LARGE_STRIPE 0x1703
14068 $LCTL set_param fail_loc=0x1703
14069 $LFS setdirstripe -i 0 -c512 $DIR/$tdir/striped_dir ||
14070 error "set striped dir error"
14071 $LCTL set_param fail_loc=0
14073 $LFS getdirstripe $DIR/$tdir/striped_dir ||
14074 error "getstripeddir fails"
14075 rm -rf $DIR/$tdir/striped_dir ||
14076 error "unlink striped dir fails"
14080 run_test 300k "test large striped directory"
14083 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
14084 skip "Need MDS version at least 2.7.55" && return
14085 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
14086 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
14089 test_mkdir -p $DIR/$tdir/striped_dir
14090 chown $RUNAS_ID $DIR/$tdir/striped_dir ||
14091 error "chown $RUNAS_ID failed"
14092 $LFS setdirstripe -i 1 -D $DIR/$tdir/striped_dir ||
14093 error "set default striped dir failed"
14095 #define OBD_FAIL_MDS_STALE_DIR_LAYOUT 0x158
14096 $LCTL set_param fail_loc=0x80000158
14097 $RUNAS mkdir $DIR/$tdir/striped_dir/test_dir || error "create dir fails"
14099 stripe_index=$($LFS getdirstripe -i $DIR/$tdir/striped_dir/test_dir)
14100 [ $stripe_index -eq 1 ] ||
14101 error "expect 1 get $stripe_index for $dir"
14103 run_test 300l "non-root user to create dir under striped dir with stale layout"
14106 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
14107 skip "Need MDS version at least 2.7.55" && return
14108 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
14109 [ $MDSCOUNT -ge 2 ] && skip "Only for single MDT" && return
14111 mkdir -p $DIR/$tdir/striped_dir
14112 $LFS setdirstripe -D -c 1 $DIR/$tdir/striped_dir ||
14113 error "set default stripes dir error"
14115 mkdir $DIR/$tdir/striped_dir/a || error "mkdir a fails"
14117 stripe_count=$($LFS getdirstripe -c $DIR/$tdir/striped_dir/a)
14118 [ $stripe_count -eq 0 ] ||
14119 error "expect 0 get $stripe_count for a"
14121 $LFS setdirstripe -D -c 2 $DIR/$tdir/striped_dir ||
14122 error "set default stripes dir error"
14124 mkdir $DIR/$tdir/striped_dir/b || error "mkdir b fails"
14126 stripe_count=$($LFS getdirstripe -c $DIR/$tdir/striped_dir/b)
14127 [ $stripe_count -eq 0 ] ||
14128 error "expect 0 get $stripe_count for b"
14130 $LFS setdirstripe -D -c1 -i2 $DIR/$tdir/striped_dir ||
14131 error "set default stripes dir error"
14133 mkdir $DIR/$tdir/striped_dir/c &&
14134 error "default stripe_index is invalid, mkdir c should fails"
14136 rm -rf $DIR/$tdir || error "rmdir fails"
14138 run_test 300m "setstriped directory on single MDT FS"
14141 local list=$(comma_list $(mdts_nodes))
14144 do_nodes $list $LCTL set_param -n mdt.*.enable_remote_dir_gid=0
14148 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
14149 skip "Need MDS version at least 2.7.55" && return
14150 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
14151 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
14153 local list=$(comma_list $(mdts_nodes))
14155 trap cleanup_300n RETURN EXIT
14156 mkdir -p $DIR/$tdir
14157 chmod 777 $DIR/$tdir
14158 $RUNAS $LFS setdirstripe -i0 -c$MDSCOUNT \
14159 $DIR/$tdir/striped_dir > /dev/null 2>&1 &&
14160 error "create striped dir succeeds with gid=0"
14162 do_nodes $list $LCTL set_param -n mdt.*.enable_remote_dir_gid=-1
14163 $RUNAS $LFS setdirstripe -i0 -c$MDSCOUNT $DIR/$tdir/striped_dir ||
14164 error "create striped dir fails with gid=-1"
14166 do_nodes $list $LCTL set_param -n mdt.*.enable_remote_dir_gid=0
14167 $RUNAS $LFS setdirstripe -i 1 -c$MDSCOUNT -D \
14168 $DIR/$tdir/striped_dir > /dev/null 2>&1 &&
14169 error "set default striped dir succeeds with gid=0"
14172 do_nodes $list $LCTL set_param -n mdt.*.enable_remote_dir_gid=-1
14173 $RUNAS $LFS setdirstripe -i 1 -c$MDSCOUNT -D $DIR/$tdir/striped_dir ||
14174 error "set default striped dir fails with gid=-1"
14177 do_nodes $list $LCTL set_param -n mdt.*.enable_remote_dir_gid=0
14178 $RUNAS mkdir $DIR/$tdir/striped_dir/test_dir ||
14179 error "create test_dir fails"
14180 $RUNAS mkdir $DIR/$tdir/striped_dir/test_dir1 ||
14181 error "create test_dir1 fails"
14182 $RUNAS mkdir $DIR/$tdir/striped_dir/test_dir2 ||
14183 error "create test_dir2 fails"
14186 run_test 300n "non-root user to create dir under striped dir with default EA"
14189 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
14190 skip "Need MDS version at least 2.7.55" && return
14191 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
14192 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
14196 mkdir -p $DIR/$tdir
14198 numfree1=$(lctl get_param -n mdc.*MDT0000*.filesfree)
14199 numfree2=$(lctl get_param -n mdc.*MDT0001*.filesfree)
14200 if [ $numfree1 -lt 66000 -o $numfree2 -lt 66000 ]; then
14201 skip "not enough free inodes $numfree1 $numfree2"
14205 numfree1=$(lctl get_param -n mdc.*MDT0000-mdc-*.kbytesfree)
14206 numfree2=$(lctl get_param -n mdc.*MDT0001-mdc-*.kbytesfree)
14207 if [ $numfree1 -lt 300000 -o $numfree2 -lt 300000 ]; then
14208 skip "not enough free space $numfree1 $numfree2"
14212 $LFS setdirstripe -c2 $DIR/$tdir/striped_dir ||
14213 error "setdirstripe fails"
14215 createmany -d $DIR/$tdir/striped_dir/d 131000 ||
14216 error "create dirs fails"
14218 $LCTL set_param ldlm.namespaces.*mdc-*.lru_size=0
14219 ls $DIR/$tdir/striped_dir > /dev/null ||
14220 error "ls striped dir fails"
14221 unlinkmany -d $DIR/$tdir/striped_dir/d 131000 ||
14222 error "unlink big striped dir fails"
14224 run_test 300o "unlink big sub stripe(> 65000 subdirs)"
14227 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
14228 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
14230 mkdir -p $DIR/$tdir
14232 #define OBD_FAIL_OUT_ENOSPC 0x1704
14233 do_facet mds2 lctl set_param fail_loc=0x80001704
14234 $LFS setdirstripe -c2 $DIR/$tdir/bad_striped_dir > /dev/null 2>&1 &&
14235 error "create striped directory should fail"
14237 [ -e $DIR/$tdir/bad_striped_dir ] && error "striped dir exists"
14239 $LFS setdirstripe -c2 $DIR/$tdir/bad_striped_dir
14242 run_test 300p "create striped directory without space"
14245 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
14246 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
14248 local fd=$(free_fd)
14249 local cmd="exec $fd<$tdir"
14251 $LFS mkdir -c $MDSCOUNT $tdir || error "create $tdir fails"
14254 trap "eval $cmd" EXIT
14255 cd $tdir || error "cd $tdir fails"
14256 rmdir ../$tdir || error "rmdir $tdir fails"
14257 mkdir local_dir && error "create dir succeeds"
14258 $LFS setdirstripe -i1 remote_dir && error "create remote dir succeeds"
14262 run_test 300q "create remote directory under orphan directory"
14264 prepare_remote_file() {
14265 mkdir $DIR/$tdir/src_dir ||
14266 error "create remote source failed"
14268 cp /etc/hosts $DIR/$tdir/src_dir/a || error
14269 touch $DIR/$tdir/src_dir/a
14271 $LFS mkdir -i 1 $DIR/$tdir/tgt_dir ||
14272 error "create remote target dir failed"
14274 touch $DIR/$tdir/tgt_dir/b
14276 mrename $DIR/$tdir/src_dir/a $DIR/$tdir/tgt_dir/b ||
14277 error "rename dir cross MDT failed!"
14279 $CHECKSTAT -t file $DIR/$tdir/src_dir/a &&
14280 error "src_child still exists after rename"
14282 $CHECKSTAT -t file $DIR/$tdir/tgt_dir/b ||
14283 error "missing file(a) after rename"
14285 diff /etc/hosts $DIR/$tdir/tgt_dir/b ||
14286 error "diff after rename"
14290 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 4 MDTs" && return
14291 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
14292 local remote_file=$DIR/$tdir/tgt_dir/b
14294 mkdir -p $DIR/$tdir
14296 prepare_remote_file || error "prepare remote file failed"
14299 $OPENUNLINK $remote_file $remote_file || error
14300 $CHECKSTAT -a $remote_file || error
14302 run_test 310a "open unlink remote file"
14305 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 4 MDTs" && return
14306 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
14307 local remote_file=$DIR/$tdir/tgt_dir/b
14309 mkdir -p $DIR/$tdir
14311 prepare_remote_file || error "prepare remote file failed"
14313 ln $remote_file $DIR/$tfile || error "link failed for remote file"
14314 $MULTIOP $DIR/$tfile Ouc || error "mulitop failed"
14315 $CHECKSTAT -t file $remote_file || error "check file failed"
14317 run_test 310b "unlink remote file with multiple links while open"
14320 [[ $MDSCOUNT -lt 4 ]] && skip "needs >= 4 MDTs" && return
14321 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
14322 local remote_file=$DIR/$tdir/tgt_dir/b
14324 mkdir -p $DIR/$tdir
14326 prepare_remote_file || error "prepare remote file failed"
14328 ln $remote_file $DIR/$tfile || error "link failed for remote file"
14329 multiop_bg_pause $remote_file O_uc ||
14330 error "mulitop failed for remote file"
14332 $MULTIOP $DIR/$tfile Ouc
14333 kill -USR1 $MULTIPID
14336 run_test 310c "open-unlink remote file with multiple links"
14338 test_400a() { # LU-1606, was conf-sanity test_74
14339 local extra_flags=''
14340 local out=$TMP/$tfile
14341 local prefix=/usr/include/lustre
14344 if ! which $CC > /dev/null 2>&1; then
14345 skip_env "$CC is not installed"
14349 if ! [[ -d $prefix ]]; then
14350 # Assume we're running in tree and fixup the include path.
14351 extra_flags+=" -I$LUSTRE/../libcfs/include"
14352 extra_flags+=" -I$LUSTRE/include"
14353 extra_flags+=" -L$LUSTRE/utils"
14356 for prog in $LUSTRE_TESTS_API_DIR/*.c; do
14357 $CC -Wall -Werror $extra_flags -llustreapi -o $out $prog ||
14358 error "client api broken"
14361 run_test 400a "Lustre client api program can compile and link"
14363 test_400b() { # LU-1606, LU-5011
14365 local out=$TMP/$tfile
14366 local prefix=/usr/include/lustre
14368 # We use a hard coded prefix so that this test will not fail
14369 # when run in tree. There are headers in lustre/include/lustre/
14370 # that are not packaged (like lustre_idl.h) and have more
14371 # complicated include dependencies (like config.h and lnet/types.h).
14372 # Since this test about correct packaging we just skip them when
14373 # they don't exist (see below) rather than try to fixup cppflags.
14375 if ! which $CC > /dev/null 2>&1; then
14376 skip_env "$CC is not installed"
14380 for header in $prefix/*.h; do
14381 if ! [[ -f "$header" ]]; then
14385 if [[ "$(basename $header)" == liblustreapi.h ]]; then
14386 continue # liblustreapi.h is deprecated.
14389 $CC -Wall -Werror -include $header -c -x c /dev/null -o $out ||
14390 error "cannot compile '$header'"
14393 run_test 400b "packaged headers can be compiled"
14395 test_401a() { #LU-7437
14396 #count the number of parameters by "list_param -R"
14397 local params=$($LCTL list_param -R '*' 2>/dev/null | wc -l)
14398 #count the number of parameters by listing proc files
14399 local procs=$(find -L $proc_dirs -mindepth 1 -printf '%P\n' 2>/dev/null|
14402 [ $params -eq $procs ] ||
14403 error "found $params parameters vs. $procs proc files"
14405 # test the list_param -D option only returns directories
14406 params=$($LCTL list_param -R -D '*' 2>/dev/null | wc -l)
14407 #count the number of parameters by listing proc directories
14408 procs=$(find -L $proc_dirs -mindepth 1 -type d -printf '%P\n' 2>/dev/null |
14411 [ $params -eq $procs ] ||
14412 error "found $params parameters vs. $procs proc files"
14414 run_test 401a "Verify if 'lctl list_param -R' can list parameters recursively"
14417 local save=$($LCTL get_param -n jobid_var)
14420 $LCTL set_param foo=bar jobid_var=$tmp bar=baz &&
14421 error "no error returned when setting bad parameters"
14423 local jobid_new=$($LCTL get_param -n foe jobid_var baz)
14424 [[ "$jobid_new" == "$tmp" ]] || error "jobid tmp $jobid_new != $tmp"
14426 $LCTL set_param -n fog=bam jobid_var=$save bat=fog
14427 local jobid_old=$($LCTL get_param -n foe jobid_var bag)
14428 [[ "$jobid_old" == "$save" ]] || error "jobid new $jobid_old != $save"
14430 run_test 401b "Verify 'lctl {get,set}_param' continue after error"
14433 $LFS setdirstripe -i 0 $DIR/$tdir || error "setdirstripe -i 0 failed"
14434 #define OBD_FAIL_MDS_FLD_LOOKUP 0x15c
14435 do_facet mds1 "lctl set_param fail_loc=0x8000015c"
14436 touch $DIR/$tdir/$tfile && error "touch should fail with ENOENT" ||
14437 echo "Touch failed - OK"
14439 run_test 402 "Return ENOENT to lod_generate_and_set_lovea"
14442 # tests that do cleanup/setup should be run at the end
14446 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
14448 #define OBD_FAIL_MGC_PAUSE_PROCESS_LOG 0x903
14449 $LCTL set_param fail_loc=0x903
14451 cancel_lru_locks MGC
14453 FAIL_ON_ERROR=true cleanup
14454 FAIL_ON_ERROR=true setup
14456 run_test 900 "umount should not race with any mgc requeue thread"
14459 [ -f $EXT2_DEV ] && rm $EXT2_DEV || true
14460 check_and_cleanup_lustre
14461 if [ "$I_MOUNTED" != "yes" ]; then
14462 lctl set_param debug="$OLDDEBUG" 2> /dev/null || true