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 5188
12 ALWAYS_EXCEPT=" 42a 42b 42c 42d 45 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 LU-8411
17 ALWAYS_EXCEPT=" 76 407 $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}
79 [ "$SLOW" = "no" ] && EXCEPT_SLOW="24D 27m 64b 68 71 115 300o"
81 if [ $(facet_fstype $SINGLEMDS) = "zfs" ]; then
82 # bug number for skipped test: LU-4536 LU-1957
83 ALWAYS_EXCEPT="$ALWAYS_EXCEPT 65ic 180"
85 [ "$SLOW" = "no" ] && EXCEPT_SLOW="$EXCEPT_SLOW 51b"
92 pgrep ll_sa > /dev/null && { echo "There are ll_sa thread not exit!"; exit 20; }
93 cleanupall ${FORCE} $* || { echo "FAILed to clean up"; exit 20; }
102 check_swap_layouts_support()
104 $LCTL get_param -n llite.*.sbi_flags | grep -q layout ||
105 { skip "Does not support layout lock."; return 0; }
109 check_and_setup_lustre
113 MDT0=$($LCTL get_param -n mdc.*.mds_server_uuid |
114 awk '{ gsub(/_UUID/,""); print $1 }' | head -n1)
115 MAXFREE=${MAXFREE:-$((200000 * $OSTCOUNT))}
117 [ -f $DIR/d52a/foo ] && chattr -a $DIR/d52a/foo
118 [ -f $DIR/d52b/foo ] && chattr -i $DIR/d52b/foo
119 rm -rf $DIR/[Rdfs][0-9]*
121 # $RUNAS_ID may get set incorrectly somewhere else
122 [ $UID -eq 0 -a $RUNAS_ID -eq 0 ] && error "\$RUNAS_ID set to 0, but \$UID is also 0!"
124 check_runas_id $RUNAS_ID $RUNAS_GID $RUNAS
128 if [ "${ONLY}" = "MOUNT" ] ; then
129 echo "Lustre is up, please go on"
133 echo "preparing for tests involving mounts"
134 EXT2_DEV=${EXT2_DEV:-$TMP/SANITY.LOOP}
136 mke2fs -j -F $EXT2_DEV 8000 > /dev/null
137 echo # add a newline after mke2fs.
141 OLDDEBUG=$(lctl get_param -n debug 2> /dev/null)
142 lctl set_param debug=-1 2> /dev/null || true
145 $CHECKSTAT -t file $DIR/$tfile || error "$tfile is not a file"
147 $CHECKSTAT -a $DIR/$tfile || error "$tfile was not removed"
149 run_test 0a "touch; rm ====================="
152 chmod 0755 $DIR || error "chmod 0755 $DIR failed"
153 $CHECKSTAT -p 0755 $DIR || error "$DIR permission is not 0755"
155 run_test 0b "chmod 0755 $DIR ============================="
158 $LCTL get_param mdc.*.import | grep "state: FULL" ||
159 error "import not FULL"
160 $LCTL get_param mdc.*.import | grep "target: $FSNAME-MDT" ||
163 run_test 0c "check import proc ============================="
166 test_mkdir -p $DIR/$tdir || error "mkdir $tdir failed"
167 test_mkdir -p $DIR/$tdir/d2 || error "mkdir $tdir/d2 failed"
168 test_mkdir $DIR/$tdir/d2 && error "we expect EEXIST, but not returned"
169 $CHECKSTAT -t dir $DIR/$tdir/d2 || error "$tdir/d2 is not a dir"
172 $CHECKSTAT -a $DIR/$tdir || error "$tdir was not removed"
174 run_test 1 "mkdir; remkdir; rmdir =============================="
177 test_mkdir -p $DIR/$tdir || error "mkdir $tdir failed"
178 touch $DIR/$tdir/$tfile || error "touch $tdir/$tfile failed"
179 $CHECKSTAT -t file $DIR/$tdir/$tfile || error "$tdir/$tfile not a file"
181 $CHECKSTAT -a $DIR/$tdir/$tfile || error "$tdir/$file is not removed"
183 run_test 2 "mkdir; touch; rmdir; check file ===================="
186 test_mkdir -p $DIR/$tdir || error "mkdir $tdir failed"
187 $CHECKSTAT -t dir $DIR/$tdir || error "$tdir is not a directory"
188 touch $DIR/$tdir/$tfile
189 $CHECKSTAT -t file $DIR/$tdir/$tfile || error "$tdir/$tfile not a file"
191 $CHECKSTAT -a $DIR/$tdir || error "$tdir is not removed"
193 run_test 3 "mkdir; touch; rmdir; check dir ====================="
195 # LU-4471 - failed rmdir on remote directories still removes directory on MDT0
199 test_mkdir $DIR/$tdir ||
200 error "Create remote directory failed"
202 touch $DIR/$tdir/$tfile ||
203 error "Create file under remote directory failed"
206 error "Expect error removing in-use dir $DIR/$tdir"
208 test -d $DIR/$tdir || error "Remote directory disappeared"
210 rm -rf $DIR/$tdir || error "remove remote dir error"
212 run_test 4 "mkdir; touch dir/file; rmdir; checkdir (expect error)"
215 test_mkdir -p $DIR/$tdir || error "mkdir $tdir failed"
216 test_mkdir $DIR/$tdir/d2 || error "mkdir $tdir/d2 failed"
217 chmod 0707 $DIR/$tdir/d2 || error "chmod 0707 $tdir/d2 failed"
218 $CHECKSTAT -t dir -p 0707 $DIR/$tdir/d2 || error "$tdir/d2 not mode 707"
219 $CHECKSTAT -t dir $DIR/$tdir/d2 || error "$tdir/d2 is not a directory"
221 run_test 5 "mkdir .../d5 .../d5/d2; chmod .../d5/d2 ============"
224 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
225 chmod 0666 $DIR/$tfile || error "chmod 0666 $tfile failed"
226 $CHECKSTAT -t file -p 0666 -u \#$UID $DIR/$tfile ||
227 error "$tfile does not have perm 0666 or UID $UID"
228 $RUNAS chmod 0444 $DIR/$tfile && error "chmod $tfile worked on UID $UID"
229 $CHECKSTAT -t file -p 0666 -u \#$UID $DIR/$tfile ||
230 error "$tfile should be 0666 and owned by UID $UID"
232 run_test 6a "touch f6a; chmod f6a; $RUNAS chmod f6a (should return error) =="
235 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID" && return
237 chown $RUNAS_ID $DIR/$tfile || error "chown $RUNAS_ID $file failed"
238 $CHECKSTAT -t file -u \#$RUNAS_ID $DIR/$tfile ||
239 error "$tfile should be owned by UID $RUNAS_ID"
240 $RUNAS chown $UID $DIR/$tfile && error "chown $UID $file succeeded"
241 $CHECKSTAT -t file -u \#$RUNAS_ID $DIR/$tfile ||
242 error "$tfile should be owned by UID $RUNAS_ID"
244 run_test 6c "touch f6c; chown f6c; $RUNAS chown f6c (should return error) =="
247 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID" && return
249 chgrp $RUNAS_ID $DIR/$tfile || error "chgrp $RUNAS_ID $file failed"
250 $CHECKSTAT -t file -u \#$UID -g \#$RUNAS_ID $DIR/$tfile ||
251 error "$tfile should be owned by GID $UID"
252 $RUNAS chgrp $UID $DIR/$tfile && error "chgrp $UID $file succeeded"
253 $CHECKSTAT -t file -u \#$UID -g \#$RUNAS_ID $DIR/$tfile ||
254 error "$tfile should be owned by UID $UID and GID $RUNAS_ID"
256 run_test 6e "touch f6e; chgrp f6e; $RUNAS chgrp f6e (should return error) =="
259 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID" && return
260 test_mkdir $DIR/$tdir || error "mkdir $tfile failed"
261 chmod 777 $DIR/$tdir || error "chmod 0777 $tdir failed"
262 $RUNAS mkdir $DIR/$tdir/d || error "mkdir $tdir/d failed"
263 chmod g+s $DIR/$tdir/d || error "chmod g+s $tdir/d failed"
264 test_mkdir $DIR/$tdir/d/subdir || error "mkdir $tdir/d/subdir failed"
265 $CHECKSTAT -g \#$RUNAS_GID $DIR/$tdir/d/subdir ||
266 error "$tdir/d/subdir should be GID $RUNAS_GID"
267 if [[ $MDSCOUNT -gt 1 ]]; then
268 # check remote dir sgid inherite
269 $LFS mkdir -i 0 $DIR/$tdir.local ||
270 error "mkdir $tdir.local failed"
271 chmod g+s $DIR/$tdir.local ||
272 error "chmod $tdir.local failed"
273 chgrp $RUNAS_GID $DIR/$tdir.local ||
274 error "chgrp $tdir.local failed"
275 $LFS mkdir -i 1 $DIR/$tdir.local/$tdir.remote ||
276 error "mkdir $tdir.remote failed"
277 $CHECKSTAT -g \#$RUNAS_GID $DIR/$tdir.local/$tdir.remote ||
278 error "$tdir.remote should be owned by $UID.$RUNAS_ID"
279 $CHECKSTAT -p 02755 $DIR/$tdir.local/$tdir.remote ||
280 error "$tdir.remote should be mode 02755"
283 run_test 6g "Is new dir in sgid dir inheriting group?"
285 test_6h() { # bug 7331
286 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID" && return
287 touch $DIR/$tfile || error "touch failed"
288 chown $RUNAS_ID:$RUNAS_GID $DIR/$tfile || error "initial chown failed"
289 $RUNAS -G$RUNAS_GID chown $RUNAS_ID:0 $DIR/$tfile &&
290 error "chown $RUNAS_ID:0 $tfile worked as GID $RUNAS_GID"
291 $CHECKSTAT -t file -u \#$RUNAS_ID -g \#$RUNAS_GID $DIR/$tfile ||
292 error "$tdir/$tfile should be UID $RUNAS_UID GID $RUNAS_GID"
294 run_test 6h "$RUNAS chown RUNAS_ID.0 .../f6h (should return error)"
297 test_mkdir $DIR/$tdir
298 $MCREATE $DIR/$tdir/$tfile
299 chmod 0666 $DIR/$tdir/$tfile
300 $CHECKSTAT -t file -p 0666 $DIR/$tdir/$tfile ||
301 error "$tdir/$tfile should be mode 0666"
303 run_test 7a "mkdir .../d7; mcreate .../d7/f; chmod .../d7/f ===="
306 if [ ! -d $DIR/$tdir ]; then
307 test_mkdir $DIR/$tdir
309 $MCREATE $DIR/$tdir/$tfile
310 echo -n foo > $DIR/$tdir/$tfile
311 [ "$(cat $DIR/$tdir/$tfile)" = "foo" ] || error "$tdir/$tfile not 'foo'"
312 $CHECKSTAT -t file -s 3 $DIR/$tdir/$tfile || error "$tfile size not 3"
314 run_test 7b "mkdir .../d7; mcreate d7/f2; echo foo > d7/f2 ====="
317 test_mkdir $DIR/$tdir
318 touch $DIR/$tdir/$tfile
319 chmod 0666 $DIR/$tdir/$tfile
320 $CHECKSTAT -t file -p 0666 $DIR/$tdir/$tfile ||
321 error "$tfile mode not 0666"
323 run_test 8 "mkdir .../d8; touch .../d8/f; chmod .../d8/f ======="
326 test_mkdir $DIR/$tdir
327 test_mkdir $DIR/$tdir/d2
328 test_mkdir $DIR/$tdir/d2/d3
329 $CHECKSTAT -t dir $DIR/$tdir/d2/d3 || error "$tdir/d2/d3 not a dir"
331 run_test 9 "mkdir .../d9 .../d9/d2 .../d9/d2/d3 ================"
334 test_mkdir $DIR/$tdir
335 test_mkdir $DIR/$tdir/d2
336 touch $DIR/$tdir/d2/$tfile
337 $CHECKSTAT -t file $DIR/$tdir/d2/$tfile ||
338 error "$tdir/d2/$tfile not a file"
340 run_test 10 "mkdir .../d10 .../d10/d2; touch .../d10/d2/f ======"
343 test_mkdir $DIR/$tdir
344 test_mkdir $DIR/$tdir/d2
345 chmod 0666 $DIR/$tdir/d2
346 chmod 0705 $DIR/$tdir/d2
347 $CHECKSTAT -t dir -p 0705 $DIR/$tdir/d2 ||
348 error "$tdir/d2 mode not 0705"
350 run_test 11 "mkdir .../d11 d11/d2; chmod .../d11/d2 ============"
353 test_mkdir $DIR/$tdir
354 touch $DIR/$tdir/$tfile
355 chmod 0666 $DIR/$tdir/$tfile
356 chmod 0654 $DIR/$tdir/$tfile
357 $CHECKSTAT -t file -p 0654 $DIR/$tdir/$tfile ||
358 error "$tdir/d2 mode not 0654"
360 run_test 12 "touch .../d12/f; chmod .../d12/f .../d12/f ========"
363 test_mkdir $DIR/$tdir
364 dd if=/dev/zero of=$DIR/$tdir/$tfile count=10
366 $CHECKSTAT -t file -s 0 $DIR/$tdir/$tfile ||
367 error "$tdir/$tfile size not 0 after truncate"
369 run_test 13 "creat .../d13/f; dd .../d13/f; > .../d13/f ========"
372 test_mkdir $DIR/$tdir
373 touch $DIR/$tdir/$tfile
375 $CHECKSTAT -a $DIR/$tdir/$tfile || error "$tdir/$tfile not removed"
377 run_test 14 "touch .../d14/f; rm .../d14/f; rm .../d14/f ======="
380 test_mkdir $DIR/$tdir
381 touch $DIR/$tdir/$tfile
382 mv $DIR/$tdir/$tfile $DIR/$tdir/${tfile}_2
383 $CHECKSTAT -t file $DIR/$tdir/${tfile}_2 ||
384 error "$tdir/${tfile_2} not a file after rename"
385 rm $DIR/$tdir/${tfile}_2 || error "unlink failed after rename"
387 run_test 15 "touch .../d15/f; mv .../d15/f .../d15/f2 =========="
390 test_mkdir $DIR/$tdir
391 touch $DIR/$tdir/$tfile
392 rm -rf $DIR/$tdir/$tfile
393 $CHECKSTAT -a $DIR/$tdir/$tfile || error "$tdir/$tfile not removed"
395 run_test 16 "touch .../d16/f; rm -rf .../d16/f ================="
398 test_mkdir -p $DIR/$tdir
399 touch $DIR/$tdir/$tfile
400 ln -s $DIR/$tdir/$tfile $DIR/$tdir/l-exist
402 $CHECKSTAT -l $DIR/$tdir/$tfile $DIR/$tdir/l-exist ||
403 error "$tdir/l-exist not a symlink"
404 $CHECKSTAT -f -t f $DIR/$tdir/l-exist ||
405 error "$tdir/l-exist not referencing a file"
406 rm -f $DIR/$tdir/l-exist
407 $CHECKSTAT -a $DIR/$tdir/l-exist || error "$tdir/l-exist not removed"
409 run_test 17a "symlinks: create, remove (real) =================="
412 test_mkdir -p $DIR/$tdir
413 ln -s no-such-file $DIR/$tdir/l-dangle
415 $CHECKSTAT -l no-such-file $DIR/$tdir/l-dangle ||
416 error "$tdir/l-dangle not referencing no-such-file"
417 $CHECKSTAT -fa $DIR/$tdir/l-dangle ||
418 error "$tdir/l-dangle not referencing non-existent file"
419 rm -f $DIR/$tdir/l-dangle
420 $CHECKSTAT -a $DIR/$tdir/l-dangle || error "$tdir/l-dangle not removed"
422 run_test 17b "symlinks: create, remove (dangling) =============="
424 test_17c() { # bug 3440 - don't save failed open RPC for replay
425 test_mkdir -p $DIR/$tdir
426 ln -s foo $DIR/$tdir/$tfile
427 cat $DIR/$tdir/$tfile && error "opened non-existent symlink" || true
429 run_test 17c "symlinks: open dangling (should return error) ===="
432 test_mkdir -p $DIR/$tdir
433 ln -s foo $DIR/$tdir/$tfile
434 touch $DIR/$tdir/$tfile || error "creating to new symlink"
436 run_test 17d "symlinks: create dangling ========================"
439 test_mkdir -p $DIR/$tdir
440 local foo=$DIR/$tdir/$tfile
441 ln -s $foo $foo || error "create symlink failed"
442 ls -l $foo || error "ls -l failed"
443 ls $foo && error "ls not failed" || true
445 run_test 17e "symlinks: create recursive symlink (should return error) ===="
448 test_mkdir -p $DIR/$tdir
449 ln -s 1234567890/2234567890/3234567890/4234567890 $DIR/$tdir/111
450 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890 $DIR/$tdir/222
451 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890 $DIR/$tdir/333
452 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890/9234567890/a234567890/b234567890 $DIR/$tdir/444
453 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890/9234567890/a234567890/b234567890/c234567890/d234567890/f234567890 $DIR/$tdir/555
454 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
457 run_test 17f "symlinks: long and very long symlink name ========================"
459 # str_repeat(S, N) generate a string that is string S repeated N times
464 while [ $((n -= 1)) -ge 0 ]; do
470 # Long symlinks and LU-2241
472 test_mkdir -p $DIR/$tdir
473 local TESTS="59 60 61 4094 4095"
475 # Fix for inode size boundary in 2.1.4
476 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.1.4) ] &&
479 # Patch not applied to 2.2 or 2.3 branches
480 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] &&
481 [ $(lustre_version_code $SINGLEMDS) -le $(version_code 2.3.55) ] &&
484 # skip long symlink name for rhel6.5.
485 # rhel6.5 has a limit (PATH_MAX - sizeof(struct filename))
486 grep -q '6.5' /etc/redhat-release &>/dev/null &&
487 TESTS="59 60 61 4062 4063"
490 local SYMNAME=$(str_repeat 'x' $i)
491 ln -s $SYMNAME $DIR/$tdir/f$i || error "failed $i-char symlink"
492 readlink $DIR/$tdir/f$i || error "failed $i-char readlink"
495 run_test 17g "symlinks: really long symlink name and inode boundaries"
497 test_17h() { #bug 17378
498 remote_mds_nodsh && skip "remote MDS with nodsh" && return
499 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
501 test_mkdir -p $DIR/$tdir
502 if [[ $MDSCOUNT -gt 1 ]]; then
503 mdt_idx=$($LFS getdirstripe -i $DIR/$tdir)
507 $SETSTRIPE -c -1 $DIR/$tdir
508 #define OBD_FAIL_MDS_LOV_PREP_CREATE 0x141
509 do_facet mds$((mdt_idx + 1)) lctl set_param fail_loc=0x80000141
510 touch $DIR/$tdir/$tfile || true
512 run_test 17h "create objects: lov_free_memmd() doesn't lbug"
514 test_17i() { #bug 20018
515 remote_mds_nodsh && skip "remote MDS with nodsh" && return
516 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
517 test_mkdir -c1 $DIR/$tdir
518 local foo=$DIR/$tdir/$tfile
520 if [[ $MDSCOUNT -gt 1 ]]; then
521 mdt_idx=$($LFS getdirstripe -i $DIR/$tdir)
525 ln -s $foo $foo || error "create symlink failed"
526 #define OBD_FAIL_MDS_READLINK_EPROTO 0x143
527 do_facet mds$((mdt_idx + 1)) lctl set_param fail_loc=0x80000143
528 ls -l $foo && error "error not detected"
531 run_test 17i "don't panic on short symlink"
533 test_17k() { #bug 22301
534 [[ -z "$(which rsync 2>/dev/null)" ]] &&
535 skip "no rsync command" && return 0
536 rsync --help | grep -q xattr ||
537 skip_env "$(rsync --version | head -n1) does not support xattrs"
538 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return 0
539 test_mkdir -p $DIR/$tdir
540 test_mkdir -p $DIR/$tdir.new
541 touch $DIR/$tdir/$tfile
542 ln -s $DIR/$tdir/$tfile $DIR/$tdir/$tfile.lnk
543 rsync -av -X $DIR/$tdir/ $DIR/$tdir.new ||
544 error "rsync failed with xattrs enabled"
546 run_test 17k "symlinks: rsync with xattrs enabled ========================="
548 test_17l() { # LU-279
549 [[ -z "$(which getfattr 2>/dev/null)" ]] &&
550 skip "no getfattr command" && return 0
551 test_mkdir -p $DIR/$tdir
552 touch $DIR/$tdir/$tfile
553 ln -s $DIR/$tdir/$tfile $DIR/$tdir/$tfile.lnk
554 for path in "$DIR/$tdir" "$DIR/$tdir/$tfile" "$DIR/$tdir/$tfile.lnk"; do
555 # -h to not follow symlinks. -m '' to list all the xattrs.
556 # grep to remove first line: '# file: $path'.
557 for xattr in `getfattr -hm '' $path 2>/dev/null | grep -v '^#'`;
559 lgetxattr_size_check $path $xattr ||
560 error "lgetxattr_size_check $path $xattr failed"
564 run_test 17l "Ensure lgetxattr's returned xattr size is consistent ========"
568 local short_sym="0123456789"
569 local WDIR=$DIR/${tdir}m
572 remote_mds_nodsh && skip "remote MDS with nodsh" && return
573 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] &&
574 [ $(lustre_version_code $SINGLEMDS) -le $(version_code 2.2.93) ] &&
575 skip "MDS 2.2.0-2.2.93 do not NUL-terminate symlinks" && return
577 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
578 skip "only for ldiskfs MDT" && return 0
580 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
584 # create a long symlink file
585 for ((i = 0; i < 4; ++i)); do
586 long_sym=${long_sym}${long_sym}
589 echo "create 512 short and long symlink files under $WDIR"
590 for ((i = 0; i < 256; ++i)); do
591 ln -sf ${long_sym}"a5a5" $WDIR/long-$i
592 ln -sf ${short_sym}"a5a5" $WDIR/short-$i
598 wait_delete_completed
600 echo "recreate the 512 symlink files with a shorter string"
601 for ((i = 0; i < 512; ++i)); do
602 # rewrite the symlink file with a shorter string
603 ln -sf ${long_sym} $WDIR/long-$i || error "long_sym failed"
604 ln -sf ${short_sym} $WDIR/short-$i || error "short_sym failed"
607 local mds_index=$(($($LFS getstripe -M $WDIR) + 1))
608 local devname=$(mdsdevname $mds_index)
610 echo "stop and checking mds${mds_index}:"
611 # e2fsck should not return error
613 run_e2fsck $(facet_active_host mds${mds_index}) $devname -n
616 start mds${mds_index} $devname $MDS_MOUNT_OPTS || error "start failed"
617 df $MOUNT > /dev/null 2>&1
619 error "e2fsck detected error for short/long symlink: rc=$rc"
621 run_test 17m "run e2fsck against MDT which contains short/long symlink"
623 check_fs_consistency_17n() {
627 # create/unlink in 17n only change 2 MDTs(MDT1/MDT2),
628 # so it only check MDT1/MDT2 instead of all of MDTs.
629 for mdt_index in 1 2; do
630 local devname=$(mdsdevname $mdt_index)
631 # e2fsck should not return error
633 run_e2fsck $(facet_active_host mds$mdt_index) $devname -n ||
636 start mds${mdt_index} $devname $MDS_MOUNT_OPTS ||
637 error "mount mds$mdt_index failed"
638 df $MOUNT > /dev/null 2>&1
646 remote_mds_nodsh && skip "remote MDS with nodsh" && return
647 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] &&
648 [ $(lustre_version_code $SINGLEMDS) -le $(version_code 2.2.93) ] &&
649 skip "MDS 2.2.0-2.2.93 do not NUL-terminate symlinks" && return
651 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
652 skip "only for ldiskfs MDT" && return 0
654 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 2 MDTs" && return
656 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
658 test_mkdir $DIR/$tdir
659 for ((i=0; i<10; i++)); do
660 $LFS mkdir -i1 -c2 $DIR/$tdir/remote_dir_${i} ||
661 error "create remote dir error $i"
662 createmany -o $DIR/$tdir/remote_dir_${i}/f 10 ||
663 error "create files under remote dir failed $i"
666 check_fs_consistency_17n ||
667 error "e2fsck report error after create files under remote dir"
669 for ((i = 0; i < 10; i++)); do
670 rm -rf $DIR/$tdir/remote_dir_${i} ||
671 error "destroy remote dir error $i"
674 check_fs_consistency_17n ||
675 error "e2fsck report error after unlink files under remote dir"
677 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.50) ] &&
678 skip "lustre < 2.4.50 does not support migrate mv " && return
680 for ((i = 0; i < 10; i++)); do
681 mkdir -p $DIR/$tdir/remote_dir_${i}
682 createmany -o $DIR/$tdir/remote_dir_${i}/f 10 ||
683 error "create files under remote dir failed $i"
684 $LFS migrate --mdt-index 1 $DIR/$tdir/remote_dir_${i} ||
685 error "migrate remote dir error $i"
687 check_fs_consistency_17n || error "e2fsck report error after migration"
689 for ((i = 0; i < 10; i++)); do
690 rm -rf $DIR/$tdir/remote_dir_${i} ||
691 error "destroy remote dir error $i"
694 check_fs_consistency_17n || error "e2fsck report error after unlink"
696 run_test 17n "run e2fsck against master/slave MDT which contains remote dir"
699 remote_mds_nodsh && skip "remote MDS with nodsh" && return
700 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.3.64) ] &&
701 skip "Need MDS version at least 2.3.64" && return
703 local WDIR=$DIR/${tdir}o
709 mdt_index=$($LFS getstripe -M $WDIR/$tfile)
710 mdt_index=$((mdt_index+1))
713 #fail mds will wait the failover finish then set
714 #following fail_loc to avoid interfer the recovery process.
717 #define OBD_FAIL_OSD_LMA_INCOMPAT 0x194
718 do_facet mds${mdt_index} lctl set_param fail_loc=0x194
719 ls -l $WDIR/$tfile && rc=1
720 do_facet mds${mdt_index} lctl set_param fail_loc=0
721 [[ $rc -ne 0 ]] && error "stat file should fail"
724 run_test 17o "stat file with incompat LMA feature"
727 touch $DIR/$tfile || error "Failed to touch $DIR/$tfile: $?"
728 ls $DIR || error "Failed to ls $DIR: $?"
730 run_test 18 "touch .../f ; ls ... =============================="
736 $CHECKSTAT -a $DIR/$tfile || error "$tfile was not removed"
738 run_test 19a "touch .../f19 ; ls -l ... ; rm .../f19 ==========="
741 ls -l $DIR/$tfile && error "ls -l $tfile failed"|| true
743 run_test 19b "ls -l .../f19 (should return error) =============="
746 [ $RUNAS_ID -eq $UID ] &&
747 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
748 $RUNAS touch $DIR/$tfile && error "create non-root file failed" || true
750 run_test 19c "$RUNAS touch .../f19 (should return error) =="
753 cat $DIR/f19 && error || true
755 run_test 19d "cat .../f19 (should return error) =============="
767 $CHECKSTAT -a $DIR/$tfile || error "$tfile was not removed"
769 run_test 20 "touch .../f ; ls -l ... ==========================="
772 test_mkdir -p $DIR/$tdir
773 [ -f $DIR/$tdir/dangle ] && rm -f $DIR/$tdir/dangle
774 ln -s dangle $DIR/$tdir/link
775 echo foo >> $DIR/$tdir/link
776 cat $DIR/$tdir/dangle
777 $CHECKSTAT -t link $DIR/$tdir/link || error "$tdir/link not a link"
778 $CHECKSTAT -f -t file $DIR/$tdir/link ||
779 error "$tdir/link not linked to a file"
781 run_test 21 "write to dangling link ============================"
785 test_mkdir -p $DIR/$tdir
786 chown $RUNAS_ID:$RUNAS_GID $WDIR
787 (cd $WDIR || error "cd $WDIR failed";
788 $RUNAS tar cf - /etc/hosts /etc/sysconfig/network | \
790 ls -lR $WDIR/etc || error "ls -lR $WDIR/etc failed"
791 $CHECKSTAT -t dir $WDIR/etc || error "checkstat -t dir failed"
792 $CHECKSTAT -u \#$RUNAS_ID -g \#$RUNAS_GID $WDIR/etc || error "checkstat -u failed"
794 run_test 22 "unpack tar archive as non-root user ==============="
798 test_mkdir -p $DIR/$tdir
799 local file=$DIR/$tdir/$tfile
801 openfile -f O_CREAT:O_EXCL $file || error "$file create failed"
802 openfile -f O_CREAT:O_EXCL $file &&
803 error "$file recreate succeeded" || true
805 run_test 23a "O_CREAT|O_EXCL in subdir =========================="
807 test_23b() { # bug 18988
808 test_mkdir -p $DIR/$tdir
809 local file=$DIR/$tdir/$tfile
812 echo foo > $file || error "write filed"
813 echo bar >> $file || error "append filed"
814 $CHECKSTAT -s 8 $file || error "wrong size"
817 run_test 23b "O_APPEND check =========================="
821 echo '-- same directory rename'
822 test_mkdir $DIR/$tdir
823 touch $DIR/$tdir/$tfile.1
824 mv $DIR/$tdir/$tfile.1 $DIR/$tdir/$tfile.2
825 $CHECKSTAT -t file $DIR/$tdir/$tfile.2 || error "$tfile.2 not a file"
827 run_test 24a "rename file to non-existent target"
830 test_mkdir $DIR/$tdir
831 touch $DIR/$tdir/$tfile.{1,2}
832 mv $DIR/$tdir/$tfile.1 $DIR/$tdir/$tfile.2
833 $CHECKSTAT -a $DIR/$tdir/$tfile.1 || error "$tfile.1 exists"
834 $CHECKSTAT -t file $DIR/$tdir/$tfile.2 || error "$tfile.2 not a file"
836 run_test 24b "rename file to existing target"
839 test_mkdir $DIR/$tdir
840 test_mkdir $DIR/$tdir/d$testnum.1
841 mv $DIR/$tdir/d$testnum.1 $DIR/$tdir/d$testnum.2
842 $CHECKSTAT -a $DIR/$tdir/d$testnum.1 || error "d$testnum.1 exists"
843 $CHECKSTAT -t dir $DIR/$tdir/d$testnum.2 || error "d$testnum.2 not dir"
845 run_test 24c "rename directory to non-existent target"
848 test_mkdir -c1 $DIR/$tdir
849 test_mkdir -c1 $DIR/$tdir/d$testnum.1
850 test_mkdir -c1 $DIR/$tdir/d$testnum.2
851 mrename $DIR/$tdir/d$testnum.1 $DIR/$tdir/d$testnum.2
852 $CHECKSTAT -a $DIR/$tdir/d$testnum.1 || error "d$testnum.1 exists"
853 $CHECKSTAT -t dir $DIR/$tdir/d$testnum.2 || error "d$testnum.2 not dir"
855 run_test 24d "rename directory to existing target"
858 echo '-- cross directory renames --'
862 mv $DIR/R5a/f $DIR/R5b/g
863 $CHECKSTAT -a $DIR/R5a/f || error
864 $CHECKSTAT -t file $DIR/R5b/g || error
866 run_test 24e "touch .../R5a/f; rename .../R5a/f .../R5b/g ======"
871 touch $DIR/R6a/f $DIR/R6b/g
872 mv $DIR/R6a/f $DIR/R6b/g
873 $CHECKSTAT -a $DIR/R6a/f || error
874 $CHECKSTAT -t file $DIR/R6b/g || error
876 run_test 24f "touch .../R6a/f R6b/g; mv .../R6a/f .../R6b/g ===="
881 test_mkdir $DIR/R7a/d
882 mv $DIR/R7a/d $DIR/R7b/e
883 $CHECKSTAT -a $DIR/R7a/d || error
884 $CHECKSTAT -t dir $DIR/R7b/e || error
886 run_test 24g "mkdir .../R7{a,b}/d; mv .../R7a/d .../R7b/e ======"
889 test_mkdir -c1 $DIR/R8a
890 test_mkdir -c1 $DIR/R8b
891 test_mkdir -c1 $DIR/R8a/d
892 test_mkdir -c1 $DIR/R8b/e
893 mrename $DIR/R8a/d $DIR/R8b/e
894 $CHECKSTAT -a $DIR/R8a/d || error
895 $CHECKSTAT -t dir $DIR/R8b/e || error
897 run_test 24h "mkdir .../R8{a,b}/{d,e}; rename .../R8a/d .../R8b/e"
900 echo "-- rename error cases"
904 mrename $DIR/R9/f $DIR/R9/a
905 $CHECKSTAT -t file $DIR/R9/f || error
906 $CHECKSTAT -t dir $DIR/R9/a || error
907 $CHECKSTAT -a $DIR/R9/a/f || error
909 run_test 24i "rename file to dir error: touch f ; mkdir a ; rename f a"
913 mrename $DIR/R10/f $DIR/R10/g
914 $CHECKSTAT -t dir $DIR/R10 || error
915 $CHECKSTAT -a $DIR/R10/f || error
916 $CHECKSTAT -a $DIR/R10/g || error
918 run_test 24j "source does not exist ============================"
922 test_mkdir $DIR/R11a/d
924 mv $DIR/R11a/f $DIR/R11a/d
925 $CHECKSTAT -a $DIR/R11a/f || error
926 $CHECKSTAT -t file $DIR/R11a/d/f || error
928 run_test 24k "touch .../R11a/f; mv .../R11a/f .../R11a/d ======="
930 # bug 2429 - rename foo foo foo creates invalid file
933 $MULTIOP $f OcNs || error
935 run_test 24l "Renaming a file to itself ========================"
939 $MULTIOP $f OcLN ${f}2 ${f}2 || error "link ${f}2 ${f}2 failed"
940 # on ext3 this does not remove either the source or target files
941 # though the "expected" operation would be to remove the source
942 $CHECKSTAT -t file ${f} || error "${f} missing"
943 $CHECKSTAT -t file ${f}2 || error "${f}2 missing"
945 run_test 24m "Renaming a file to a hard link to itself ========="
949 # this stats the old file after it was renamed, so it should fail
953 $CHECKSTAT ${f}.rename
956 run_test 24n "Statting the old file after renaming (Posix rename 2)"
959 test_mkdir -p $DIR/d24o
960 rename_many -s random -v -n 10 $DIR/d24o
962 run_test 24o "rename of files during htree split ==============="
967 DIRINO=`ls -lid $DIR/R12a | awk '{ print $1 }'`
968 mrename $DIR/R12a $DIR/R12b
969 $CHECKSTAT -a $DIR/R12a || error
970 $CHECKSTAT -t dir $DIR/R12b || error
971 DIRINO2=`ls -lid $DIR/R12b | awk '{ print $1 }'`
972 [ "$DIRINO" = "$DIRINO2" ] || error "R12a $DIRINO != R12b $DIRINO2"
974 run_test 24p "mkdir .../R12{a,b}; rename .../R12a .../R12b"
976 cleanup_multiop_pause() {
982 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
985 local DIRINO=$(ls -lid $DIR/R13a | awk '{ print $1 }')
986 multiop_bg_pause $DIR/R13b D_c || error "multiop failed to start"
989 trap cleanup_multiop_pause EXIT
990 mrename $DIR/R13a $DIR/R13b
991 $CHECKSTAT -a $DIR/R13a || error "R13a still exists"
992 $CHECKSTAT -t dir $DIR/R13b || error "R13b does not exist"
993 local DIRINO2=$(ls -lid $DIR/R13b | awk '{ print $1 }')
994 [ "$DIRINO" = "$DIRINO2" ] || error "R13a $DIRINO != R13b $DIRINO2"
995 cleanup_multiop_pause
996 wait $MULTIPID || error "multiop close failed"
998 run_test 24q "mkdir .../R13{a,b}; open R13b rename R13a R13b ==="
1000 test_24r() { #bug 3789
1001 test_mkdir $DIR/R14a
1002 test_mkdir $DIR/R14a/b
1003 mrename $DIR/R14a $DIR/R14a/b && error "rename to subdir worked!"
1004 $CHECKSTAT -t dir $DIR/R14a || error "$DIR/R14a missing"
1005 $CHECKSTAT -t dir $DIR/R14a/b || error "$DIR/R14a/b missing"
1007 run_test 24r "mkdir .../R14a/b; rename .../R14a .../R14a/b ====="
1010 test_mkdir $DIR/R15a
1011 test_mkdir $DIR/R15a/b
1012 test_mkdir $DIR/R15a/b/c
1013 mrename $DIR/R15a $DIR/R15a/b/c && error "rename to sub-subdir worked!"
1014 $CHECKSTAT -t dir $DIR/R15a || error "$DIR/R15a missing"
1015 $CHECKSTAT -t dir $DIR/R15a/b/c || error "$DIR/R15a/b/c missing"
1017 run_test 24s "mkdir .../R15a/b/c; rename .../R15a .../R15a/b/c ="
1019 test_mkdir $DIR/R16a
1020 test_mkdir $DIR/R16a/b
1021 test_mkdir $DIR/R16a/b/c
1022 mrename $DIR/R16a/b/c $DIR/R16a && error "rename to sub-subdir worked!"
1023 $CHECKSTAT -t dir $DIR/R16a || error "$DIR/R16a missing"
1024 $CHECKSTAT -t dir $DIR/R16a/b/c || error "$DIR/R16a/b/c missing"
1026 run_test 24t "mkdir .../R16a/b/c; rename .../R16a/b/c .../R16a ="
1028 test_24u() { # bug12192
1029 $MULTIOP $DIR/$tfile C2w$((2048 * 1024))c || error
1030 $CHECKSTAT -s $((2048 * 1024)) $DIR/$tfile || error "wrong file size"
1032 run_test 24u "create stripe file"
1036 size=$(getconf PAGE_SIZE 2>/dev/null)
1037 echo -n ${size:-4096}
1040 simple_cleanup_common() {
1043 wait_delete_completed
1046 max_pages_per_rpc() {
1047 $LCTL get_param -n mdc.*.max_pages_per_rpc | head -n1
1051 local NRFILES=100000
1052 local FREE_INODES=$(mdt_free_inodes 0)
1053 [[ $FREE_INODES -lt $NRFILES ]] &&
1054 skip "not enough free inodes $FREE_INODES required $NRFILES" &&
1057 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1058 trap simple_cleanup_common EXIT
1060 # Performance issue on ZFS see LU-4072 (c.f. LU-2887)
1061 [ $(facet_fstype $SINGLEMDS) = "zfs" ] && NRFILES=10000
1063 test_mkdir -p $DIR/$tdir
1064 createmany -m $DIR/$tdir/$tfile $NRFILES
1066 cancel_lru_locks mdc
1067 lctl set_param mdc.*.stats clear
1069 ls $DIR/$tdir >/dev/null || error "error in listing large dir"
1071 # LU-5 large readdir
1072 # DIRENT_SIZE = 32 bytes for sizeof(struct lu_dirent) +
1073 # 8 bytes for name(filename is mostly 5 in this test) +
1074 # 8 bytes for luda_type
1075 # take into account of overhead in lu_dirpage header and end mark in
1076 # each page, plus one in RPC_NUM calculation.
1078 RPC_SIZE=$(($(max_pages_per_rpc) * $(page_size)))
1079 RPC_NUM=$(((NRFILES * DIRENT_SIZE + RPC_SIZE - 1) / RPC_SIZE + 1))
1080 mds_readpage=$(lctl get_param mdc.*MDT0000*.stats |
1081 awk '/^mds_readpage/ {print $2}')
1082 [[ $mds_readpage -gt $RPC_NUM ]] &&
1083 error "large readdir doesn't take effect"
1085 simple_cleanup_common
1087 run_test 24v "list directory with large files (handle hash collision, bug: 17560)"
1089 test_24w() { # bug21506
1091 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=4096 || return 1
1092 dd if=/dev/zero bs=$SZ1 count=1 >> $DIR/$tfile || return 2
1093 dd if=$DIR/$tfile of=$DIR/${tfile}_left bs=1M skip=4097 || return 3
1094 SZ2=`ls -l $DIR/${tfile}_left | awk '{print $5}'`
1095 [[ "$SZ1" -eq "$SZ2" ]] ||
1096 error "Error reading at the end of the file $tfile"
1098 run_test 24w "Reading a file larger than 4Gb"
1101 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 2 MDTs" && return
1103 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.56) ]] &&
1104 skip "Need MDS version at least 2.7.56" && return
1106 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1108 local remote_dir=$DIR/$tdir/remote_dir
1110 test_mkdir -p $DIR/$tdir
1111 $LFS mkdir -i $MDTIDX $remote_dir ||
1112 error "create remote directory failed"
1114 test_mkdir -p $DIR/$tdir/src_dir
1115 touch $DIR/$tdir/src_file
1116 test_mkdir -p $remote_dir/tgt_dir
1117 touch $remote_dir/tgt_file
1119 mrename $DIR/$tdir/src_dir $remote_dir/tgt_dir ||
1120 error "rename dir cross MDT failed!"
1122 mrename $DIR/$tdir/src_file $remote_dir/tgt_file ||
1123 error "rename file cross MDT failed!"
1125 touch $DIR/$tdir/ln_file
1126 ln $DIR/$tdir/ln_file $remote_dir/ln_name ||
1127 error "ln file cross MDT failed"
1129 rm -rf $DIR/$tdir || error "Can not delete directories"
1131 run_test 24x "cross MDT rename/link"
1134 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 2 MDTs" && return
1135 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1137 local remote_dir=$DIR/$tdir/remote_dir
1139 test_mkdir -p $DIR/$tdir
1140 $LFS mkdir -i $MDTIDX $remote_dir ||
1141 error "create remote directory failed"
1143 test_mkdir -p $remote_dir/src_dir
1144 touch $remote_dir/src_file
1145 test_mkdir -p $remote_dir/tgt_dir
1146 touch $remote_dir/tgt_file
1148 mrename $remote_dir/src_dir $remote_dir/tgt_dir ||
1149 error "rename subdir in the same remote dir failed!"
1151 mrename $remote_dir/src_file $remote_dir/tgt_file ||
1152 error "rename files in the same remote dir failed!"
1154 ln $remote_dir/tgt_file $remote_dir/tgt_file1 ||
1155 error "link files in the same remote dir failed!"
1157 rm -rf $DIR/$tdir || error "Can not delete directories"
1159 run_test 24y "rename/link on the same dir should succeed"
1161 test_24A() { # LU-3182
1165 test_mkdir -p $DIR/$tdir
1166 createmany -m $DIR/$tdir/$tfile $NFILES
1167 local t=$(ls $DIR/$tdir | wc -l)
1168 local u=$(ls $DIR/$tdir | sort -u | wc -l)
1169 local v=$(ls -ai $DIR/$tdir | sort -u | wc -l)
1170 if [ $t -ne $NFILES -o $u -ne $NFILES -o $v -ne $((NFILES + 2)) ] ; then
1171 error "Expected $NFILES files, got $t ($u unique $v .&..)"
1174 rm -rf $DIR/$tdir || error "Can not delete directories"
1176 run_test 24A "readdir() returns correct number of entries."
1178 test_24B() { # LU-4805
1179 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
1182 test_mkdir $DIR/$tdir
1183 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR/$tdir/striped_dir ||
1184 error "create striped dir failed"
1186 count=$(ls -ai $DIR/$tdir/striped_dir | wc -l)
1187 [ $count -eq 2 ] || error "Expected 2, got $count"
1189 touch $DIR/$tdir/striped_dir/a
1191 count=$(ls -ai $DIR/$tdir/striped_dir | wc -l)
1192 [ $count -eq 3 ] || error "Expected 3, got $count"
1194 touch $DIR/$tdir/striped_dir/.f
1196 count=$(ls -ai $DIR/$tdir/striped_dir | wc -l)
1197 [ $count -eq 4 ] || error "Expected 4, got $count"
1199 rm -rf $DIR/$tdir || error "Can not delete directories"
1201 run_test 24B "readdir for striped dir return correct number of entries"
1204 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
1210 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR/$tdir/d0/striped_dir ||
1211 error "create striped dir failed"
1213 cd $DIR/$tdir/d0/striped_dir
1215 local d0_ino=$(ls -i -l -a $DIR/$tdir | grep "d0" | awk '{print $1}')
1216 local d1_ino=$(ls -i -l -a $DIR/$tdir | grep "d1" | awk '{print $1}')
1217 local parent_ino=$(ls -i -l -a | grep "\.\." | awk '{print $1}')
1219 [ "$d0_ino" = "$parent_ino" ] ||
1220 error ".. wrong, expect $d0_ino, get $parent_ino"
1222 mv $DIR/$tdir/d0/striped_dir $DIR/$tdir/d1/ ||
1223 error "mv striped dir failed"
1225 parent_ino=$(ls -i -l -a | grep "\.\." | awk '{print $1}')
1227 [ "$d1_ino" = "$parent_ino" ] ||
1228 error ".. wrong after mv, expect $d1_ino, get $parent_ino"
1230 run_test 24C "check .. in striped dir"
1232 test_24D() { # LU-6101
1237 createmany -m $DIR/$tdir/$tfile $NFILES
1238 local t=$(ls $DIR/$tdir | wc -l)
1239 local u=$(ls $DIR/$tdir | sort -u | wc -l)
1240 local v=$(ls -ai $DIR/$tdir | sort -u | wc -l)
1241 if [ $t -ne $NFILES -o $u -ne $NFILES -o $v -ne $((NFILES + 2)) ] ; then
1242 error "Expected $NFILES files, got $t ($u unique $v .&..)"
1245 rm -rf $DIR/$tdir || error "Can not delete directories"
1247 run_test 24D "readdir() returns correct number of entries after cursor reload"
1250 [[ $MDSCOUNT -lt 4 ]] && skip "needs >= 4 MDTs" && return
1251 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1254 mkdir $DIR/$tdir/src_dir
1255 $LFS mkdir -i 1 $DIR/$tdir/src_dir/src_child ||
1256 error "create remote source failed"
1258 touch $DIR/$tdir/src_dir/src_child/a
1260 $LFS mkdir -i 2 $DIR/$tdir/tgt_dir ||
1261 error "create remote target dir failed"
1263 $LFS mkdir -i 3 $DIR/$tdir/tgt_dir/tgt_child ||
1264 error "create remote target child failed"
1266 mrename $DIR/$tdir/src_dir/src_child $DIR/$tdir/tgt_dir/tgt_child ||
1267 error "rename dir cross MDT failed!"
1271 $CHECKSTAT -t dir $DIR/$tdir/src_dir/src_child &&
1272 error "src_child still exists after rename"
1274 $CHECKSTAT -t file $DIR/$tdir/tgt_dir/tgt_child/a ||
1275 error "missing file(a) after rename"
1277 rm -rf $DIR/$tdir || error "Can not delete directories"
1279 run_test 24E "cross MDT rename/link"
1282 echo '== symlink sanity ============================================='
1286 touch $DIR/s25/foo || error
1288 run_test 25a "create file in symlinked directory ==============="
1291 [ ! -d $DIR/d25 ] && test_25a
1292 $CHECKSTAT -t file $DIR/s25/foo || error
1294 run_test 25b "lookup file in symlinked directory ==============="
1298 test_mkdir $DIR/d26/d26-2
1299 ln -s d26/d26-2 $DIR/s26
1300 touch $DIR/s26/foo || error
1302 run_test 26a "multiple component symlink ======================="
1305 test_mkdir -p $DIR/d26b/d26-2
1306 ln -s d26b/d26-2/foo $DIR/s26-2
1307 touch $DIR/s26-2 || error
1309 run_test 26b "multiple component symlink at end of lookup ======"
1312 test_mkdir $DIR/d26.2
1313 touch $DIR/d26.2/foo
1314 ln -s d26.2 $DIR/s26.2-1
1315 ln -s s26.2-1 $DIR/s26.2-2
1316 ln -s s26.2-2 $DIR/s26.2-3
1317 chmod 0666 $DIR/s26.2-3/foo
1319 run_test 26c "chain of symlinks ================================"
1321 # recursive symlinks (bug 439)
1323 ln -s d26-3/foo $DIR/d26-3
1325 run_test 26d "create multiple component recursive symlink ======"
1328 [ ! -h $DIR/d26-3 ] && test_26d
1331 run_test 26e "unlink multiple component recursive symlink ======"
1333 # recursive symlinks (bug 7022)
1335 test_mkdir -p $DIR/$tdir
1336 test_mkdir $DIR/$tdir/$tfile || error "mkdir $DIR/$tdir/$tfile failed"
1337 cd $DIR/$tdir/$tfile || error "cd $DIR/$tdir/$tfile failed"
1338 test_mkdir -p lndir/bar1 || error "mkdir lndir/bar1 failed"
1339 test_mkdir $DIR/$tdir/$tfile/$tfile || error "mkdir $tfile failed"
1340 cd $tfile || error "cd $tfile failed"
1341 ln -s .. dotdot || error "ln dotdot failed"
1342 ln -s dotdot/lndir lndir || error "ln lndir failed"
1343 cd $DIR/$tdir || error "cd $DIR/$tdir failed"
1344 output=`ls $tfile/$tfile/lndir/bar1`
1345 [ "$output" = bar1 ] && error "unexpected output"
1346 rm -r $tfile || error "rm $tfile failed"
1347 $CHECKSTAT -a $DIR/$tfile || error "$tfile not gone"
1349 run_test 26f "rm -r of a directory which has recursive symlink ="
1352 echo '== stripe sanity =============================================='
1353 test_mkdir -p $DIR/d27 || error "mkdir failed"
1355 $SETSTRIPE -c 1 $DIR/d27/f0 || error "setstripe failed"
1356 $CHECKSTAT -t file $DIR/d27/f0 || error "checkstat failed"
1357 log "== test_27a: write to one stripe file ========================="
1358 cp /etc/hosts $DIR/d27/f0 || error
1360 run_test 27a "one stripe file =================================="
1363 [[ $OSTCOUNT -lt 2 ]] && skip_env "skipping 2-stripe test" && return
1364 test_mkdir -p $DIR/d27
1365 $SETSTRIPE -c 2 $DIR/d27/f01 || error "setstripe failed"
1366 $GETSTRIPE -c $DIR/d27/f01
1367 [ $($GETSTRIPE -c $DIR/d27/f01) -eq 2 ] ||
1368 error "two-stripe file doesn't have two stripes"
1370 dd if=/dev/zero of=$DIR/d27/f01 bs=4k count=4 || error "dd failed"
1372 run_test 27b "create and write to two stripe file"
1375 test_mkdir -p $DIR/d27
1376 $SETSTRIPE -c 0 -i -1 -S 0 $DIR/d27/fdef || error "setstripe failed"
1377 $CHECKSTAT -t file $DIR/d27/fdef || error "checkstat failed"
1378 dd if=/dev/zero of=$DIR/d27/fdef bs=4k count=4 || error
1380 run_test 27d "create file with default settings ================"
1383 # LU-5839 adds check for existed layout before setting it
1384 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.56) ]] &&
1385 skip "Need MDS version at least 2.7.56" && return
1386 test_mkdir -p $DIR/d27
1387 $SETSTRIPE -c 2 $DIR/d27/f12 || error "setstripe failed"
1388 $SETSTRIPE -c 2 $DIR/d27/f12 && error "setstripe succeeded twice"
1389 $CHECKSTAT -t file $DIR/d27/f12 || error "checkstat failed"
1391 run_test 27e "setstripe existing file (should return error) ======"
1394 test_mkdir $DIR/$tdir
1395 $SETSTRIPE -S 100 -i 0 -c 1 $DIR/$tdir/$tfile &&
1396 error "$SETSTRIPE $DIR/$tdir/$tfile failed"
1397 $CHECKSTAT -t file $DIR/$tdir/$tfile &&
1398 error "$CHECKSTAT -t file $DIR/$tdir/$tfile should fail"
1399 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=4k count=4 || error "dd failed"
1400 $GETSTRIPE $DIR/$tdir/$tfile || error "$GETSTRIPE failed"
1402 run_test 27f "setstripe with bad stripe size (should return error)"
1405 test_mkdir -p $DIR/d27
1406 $MCREATE $DIR/d27/fnone || error "mcreate failed"
1407 $GETSTRIPE $DIR/d27/fnone 2>&1 | grep "no stripe info" ||
1408 error "$DIR/d27/fnone has object"
1410 run_test 27g "$GETSTRIPE with no objects"
1413 test_mkdir $DIR/$tdir
1414 touch $DIR/$tdir/$tfile || error "touch failed"
1415 [[ $($GETSTRIPE -c $DIR/$tdir/$tfile) -gt 0 ]] ||
1416 error "missing objects"
1418 run_test 27i "$GETSTRIPE with some objects"
1421 test_mkdir -p $DIR/d27
1422 $SETSTRIPE -i $OSTCOUNT $DIR/d27/f27j && error "setstripe failed"||true
1424 run_test 27j "setstripe with bad stripe offset (should return error)"
1426 test_27k() { # bug 2844
1427 test_mkdir -p $DIR/d27
1429 LL_MAX_BLKSIZE=$((4 * 1024 * 1024))
1430 [ ! -d $DIR/d27 ] && test_mkdir -p $DIR d27
1431 $SETSTRIPE -S 67108864 $FILE || error "setstripe failed"
1432 BLKSIZE=`stat $FILE | awk '/IO Block:/ { print $7 }'`
1433 [ $BLKSIZE -le $LL_MAX_BLKSIZE ] || error "1:$BLKSIZE > $LL_MAX_BLKSIZE"
1434 dd if=/dev/zero of=$FILE bs=4k count=1
1435 BLKSIZE=`stat $FILE | awk '/IO Block:/ { print $7 }'`
1436 [ $BLKSIZE -le $LL_MAX_BLKSIZE ] || error "2:$BLKSIZE > $LL_MAX_BLKSIZE"
1438 run_test 27k "limit i_blksize for broken user apps ============="
1441 test_mkdir -p $DIR/d27
1442 mcreate $DIR/f27l || error "creating file"
1443 $RUNAS $SETSTRIPE -c 1 $DIR/f27l && \
1444 error "setstripe should have failed" || true
1446 run_test 27l "check setstripe permissions (should return error)"
1449 [[ $OSTCOUNT -lt 2 ]] && skip_env "$OSTCOUNT < 2 OSTs -- skipping" &&
1452 ORIGFREE=$($LCTL get_param -n lov.$FSNAME-clilov-*.kbytesavail |
1454 if [[ $ORIGFREE -gt $MAXFREE ]]; then
1455 skip "$ORIGFREE > $MAXFREE skipping out-of-space test on OST0"
1458 trap simple_cleanup_common EXIT
1459 test_mkdir -p $DIR/$tdir
1460 $SETSTRIPE -i 0 -c 1 $DIR/$tdir/f27m_1
1461 dd if=/dev/zero of=$DIR/$tdir/f27m_1 bs=1024 count=$MAXFREE &&
1462 error "dd should fill OST0"
1464 while $SETSTRIPE -i 0 -c 1 $DIR/$tdir/f27m_$i; do
1466 [ $i -gt 256 ] && break
1469 touch $DIR/$tdir/f27m_$i
1470 [ `$GETSTRIPE $DIR/$tdir/f27m_$i | grep -A 10 obdidx | awk '{print $1}'| grep -w "0"` ] &&
1471 error "OST0 was full but new created file still use it"
1473 touch $DIR/$tdir/f27m_$i
1474 [ `$GETSTRIPE $DIR/$tdir/f27m_$i | grep -A 10 obdidx | awk '{print $1}'| grep -w "0"` ] &&
1475 error "OST0 was full but new created file still use it"
1476 simple_cleanup_common
1478 run_test 27m "create file while OST0 was full =================="
1481 local DELAY=$(do_facet $SINGLEMDS lctl get_param -n lov.*.qos_maxage | head -n 1 | awk '{print $1 * 2}')
1485 # OSCs keep a NOSPC flag that will be reset after ~5s (qos_maxage)
1486 # if the OST isn't full anymore.
1488 local OSTIDX=${1:-""}
1490 local list=$(comma_list $(osts_nodes))
1491 [ "$OSTIDX" ] && list=$(facet_host ost$((OSTIDX + 1)))
1493 do_nodes $list lctl set_param fail_loc=0
1494 sync # initiate all OST_DESTROYs from MDS to OST
1498 exhaust_precreations() {
1501 local FAILIDX=${3:-$OSTIDX}
1502 local ofacet=ost$((OSTIDX + 1))
1504 test_mkdir -p -c1 $DIR/$tdir
1505 local mdtidx=$($LFS getstripe -M $DIR/$tdir)
1506 local mfacet=mds$((mdtidx + 1))
1507 echo OSTIDX=$OSTIDX MDTIDX=$mdtidx
1509 local OST=$(ostname_from_index $OSTIDX)
1512 local mdtosc_proc1=$(get_mdtosc_proc_path $mfacet $OST)
1513 local last_id=$(do_facet $mfacet lctl get_param -n \
1514 osc.$mdtosc_proc1.prealloc_last_id)
1515 local next_id=$(do_facet $mfacet lctl get_param -n \
1516 osc.$mdtosc_proc1.prealloc_next_id)
1518 local mdtosc_proc2=$(get_mdtosc_proc_path $mfacet)
1519 do_facet $mfacet lctl get_param osc.$mdtosc_proc2.prealloc*
1521 test_mkdir -p $DIR/$tdir/${OST}
1522 $SETSTRIPE -i $OSTIDX -c 1 $DIR/$tdir/${OST}
1523 #define OBD_FAIL_OST_ENOSPC 0x215
1524 do_facet $ofacet lctl set_param fail_val=$FAILIDX fail_loc=0x215
1525 echo "Creating to objid $last_id on ost $OST..."
1526 createmany -o $DIR/$tdir/${OST}/f $next_id $((last_id - next_id + 2))
1527 do_facet $mfacet lctl get_param osc.$mdtosc_proc2.prealloc*
1528 do_facet $ofacet lctl set_param fail_loc=$FAILLOC
1532 exhaust_all_precreations() {
1534 for (( i=0; i < OSTCOUNT; i++ )) ; do
1535 exhaust_precreations $i $1 -1
1540 [[ $OSTCOUNT -lt 2 ]] && skip_env "too few OSTs" && return
1541 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1542 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1543 remote_ost_nodsh && skip "remote OST with nodsh" && return
1546 rm -f $DIR/$tdir/$tfile
1547 exhaust_precreations 0 0x80000215
1548 $SETSTRIPE -c -1 $DIR/$tdir
1549 touch $DIR/$tdir/$tfile || error
1550 $GETSTRIPE $DIR/$tdir/$tfile
1553 run_test 27n "create file with some full OSTs =================="
1556 [[ $OSTCOUNT -lt 2 ]] && skip_env "too few OSTs" && return
1557 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1558 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1559 remote_ost_nodsh && skip "remote OST with nodsh" && return
1562 rm -f $DIR/$tdir/$tfile
1563 exhaust_all_precreations 0x215
1565 touch $DIR/$tdir/$tfile && error "able to create $DIR/$tdir/$tfile"
1570 run_test 27o "create file with all full OSTs (should error) ===="
1573 [[ $OSTCOUNT -lt 2 ]] && skip_env "too few OSTs" && return
1574 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1575 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1576 remote_ost_nodsh && skip "remote OST with nodsh" && return
1579 rm -f $DIR/$tdir/$tfile
1580 test_mkdir -p $DIR/$tdir
1582 $MCREATE $DIR/$tdir/$tfile || error "mcreate failed"
1583 $TRUNCATE $DIR/$tdir/$tfile 80000000 || error "truncate failed"
1584 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat failed"
1586 exhaust_precreations 0 0x80000215
1587 echo foo >> $DIR/$tdir/$tfile || error "append failed"
1588 $CHECKSTAT -s 80000004 $DIR/$tdir/$tfile || error "checkstat failed"
1589 $GETSTRIPE $DIR/$tdir/$tfile
1593 run_test 27p "append to a truncated file with some full OSTs ==="
1596 [[ $OSTCOUNT -lt 2 ]] && skip_env "too few OSTs" && return
1597 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1598 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1599 remote_ost_nodsh && skip "remote OST with nodsh" && return
1602 rm -f $DIR/$tdir/$tfile
1604 test_mkdir -p $DIR/$tdir
1605 $MCREATE $DIR/$tdir/$tfile || error "mcreate $DIR/$tdir/$tfile failed"
1606 $TRUNCATE $DIR/$tdir/$tfile 80000000 ||error "truncate $DIR/$tdir/$tfile failed"
1607 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat failed"
1609 exhaust_all_precreations 0x215
1611 echo foo >> $DIR/$tdir/$tfile && error "append succeeded"
1612 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat 2 failed"
1616 run_test 27q "append to truncated file with all OSTs full (should error) ==="
1619 [[ $OSTCOUNT -lt 2 ]] && skip_env "too few OSTs" && return
1620 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1621 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1622 remote_ost_nodsh && skip "remote OST with nodsh" && return
1625 rm -f $DIR/$tdir/$tfile
1626 exhaust_precreations 0 0x80000215
1628 $SETSTRIPE -i 0 -c 2 $DIR/$tdir/$tfile # && error
1632 run_test 27r "stripe file with some full OSTs (shouldn't LBUG) ="
1634 test_27s() { # bug 10725
1635 test_mkdir -p $DIR/$tdir
1636 local stripe_size=$((4096 * 1024 * 1024)) # 2^32
1637 local stripe_count=0
1638 [ $OSTCOUNT -eq 1 ] || stripe_count=2
1639 $SETSTRIPE -S $stripe_size -c $stripe_count $DIR/$tdir &&
1640 error "stripe width >= 2^32 succeeded" || true
1643 run_test 27s "lsm_xfersize overflow (should error) (bug 10725)"
1645 test_27t() { # bug 10864
1650 $WLFS getstripe $tfile
1653 run_test 27t "check that utils parse path correctly"
1655 test_27u() { # bug 4900
1656 [[ $OSTCOUNT -lt 2 ]] && skip_env "too few OSTs" && return
1657 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1659 local list=$(comma_list $(mdts_nodes))
1661 #define OBD_FAIL_MDS_OSC_PRECREATE 0x139
1662 do_nodes $list $LCTL set_param fail_loc=0x139
1663 test_mkdir -p $DIR/$tdir
1665 createmany -o $DIR/$tdir/t- 1000
1666 do_nodes $list $LCTL set_param fail_loc=0
1668 TLOG=$TMP/$tfile.getstripe
1669 $GETSTRIPE $DIR/$tdir > $TLOG
1670 OBJS=$(awk -vobj=0 '($1 == 0) { obj += 1 } END { print obj; }' $TLOG)
1671 unlinkmany $DIR/$tdir/t- 1000
1672 [[ $OBJS -gt 0 ]] &&
1673 error "$OBJS objects created on OST-0. See $TLOG" || pass
1675 run_test 27u "skip object creation on OSC w/o objects =========="
1677 test_27v() { # bug 4900
1678 [[ $OSTCOUNT -lt 2 ]] && skip_env "too few OSTs" && return
1679 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1680 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1681 remote_ost_nodsh && skip "remote OST with nodsh" && return
1683 exhaust_all_precreations 0x215
1686 test_mkdir -p $DIR/$tdir
1687 $SETSTRIPE -c 1 $DIR/$tdir # 1 stripe / file
1689 touch $DIR/$tdir/$tfile
1690 #define OBD_FAIL_TGT_DELAY_PRECREATE 0x705
1692 for (( i=1; i < OSTCOUNT; i++ )); do
1693 do_facet ost$i lctl set_param fail_loc=0x705
1695 local START=`date +%s`
1696 createmany -o $DIR/$tdir/$tfile 32
1698 local FINISH=`date +%s`
1699 local TIMEOUT=`lctl get_param -n timeout`
1700 local PROCESS=$((FINISH - START))
1701 [ $PROCESS -ge $((TIMEOUT / 2)) ] && \
1702 error "$FINISH - $START >= $TIMEOUT / 2"
1703 sleep $((TIMEOUT / 2 - PROCESS))
1706 run_test 27v "skip object creation on slow OST ================="
1708 test_27w() { # bug 10997
1709 test_mkdir -p $DIR/$tdir || error "mkdir failed"
1710 $SETSTRIPE -S 65536 $DIR/$tdir/f0 || error "setstripe failed"
1711 [ $($GETSTRIPE -S $DIR/$tdir/f0) -ne 65536 ] &&
1712 error "stripe size $size != 65536" || true
1713 [ $($GETSTRIPE -d $DIR/$tdir | grep -c "stripe_count") -ne 1 ] &&
1714 error "$GETSTRIPE -d $DIR/$tdir failed" || true
1716 run_test 27w "check $SETSTRIPE -S option"
1719 [[ $OSTCOUNT -lt 2 ]] &&
1720 skip_env "skipping multiple stripe count/offset test" && return
1722 test_mkdir -p $DIR/$tdir || error "mkdir failed"
1723 for i in $(seq 1 $OSTCOUNT); do
1725 $SETSTRIPE -c $i -i $offset $DIR/$tdir/f$i ||
1726 error "setstripe -c $i -i $offset failed"
1727 count=$($GETSTRIPE -c $DIR/$tdir/f$i)
1728 index=$($GETSTRIPE -i $DIR/$tdir/f$i)
1729 [ $count -ne $i ] && error "stripe count $count != $i" || true
1730 [ $index -ne $offset ] &&
1731 error "stripe offset $index != $offset" || true
1734 run_test 27wa "check $SETSTRIPE -c -i options"
1737 remote_ost_nodsh && skip "remote OST with nodsh" && return
1738 [[ $OSTCOUNT -lt 2 ]] && skip_env "$OSTCOUNT < 2 OSTs" && return
1739 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1740 OFFSET=$(($OSTCOUNT - 1))
1742 local OST=$(ostname_from_index $OSTIDX)
1744 test_mkdir -p $DIR/$tdir
1745 $SETSTRIPE -c 1 $DIR/$tdir # 1 stripe per file
1746 do_facet ost$((OSTIDX + 1)) lctl set_param -n obdfilter.$OST.degraded 1
1748 createmany -o $DIR/$tdir/$tfile $OSTCOUNT
1749 for i in `seq 0 $OFFSET`; do
1750 [ `$GETSTRIPE $DIR/$tdir/$tfile$i | grep -A 10 obdidx | awk '{print $1}' | grep -w "$OSTIDX"` ] &&
1751 error "OST0 was degraded but new created file still use it"
1753 do_facet ost$((OSTIDX + 1)) lctl set_param -n obdfilter.$OST.degraded 0
1755 run_test 27x "create files while OST0 is degraded"
1758 [[ $OSTCOUNT -lt 2 ]] &&
1759 skip_env "$OSTCOUNT < 2 OSTs -- skipping" && return
1760 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1761 remote_ost_nodsh && skip "remote OST with nodsh" && return
1762 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1764 local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS $FSNAME-OST0000)
1765 local last_id=$(do_facet $SINGLEMDS lctl get_param -n \
1766 osc.$mdtosc.prealloc_last_id)
1767 local next_id=$(do_facet $SINGLEMDS lctl get_param -n \
1768 osc.$mdtosc.prealloc_next_id)
1769 local fcount=$((last_id - next_id))
1770 [[ $fcount -eq 0 ]] && skip "not enough space on OST0" && return
1771 [[ $fcount -gt $OSTCOUNT ]] && fcount=$OSTCOUNT
1773 local MDS_OSCS=$(do_facet $SINGLEMDS lctl dl |
1774 awk '/[oO][sS][cC].*md[ts]/ { print $4 }')
1775 local OST_DEACTIVE_IDX=-1
1780 for OSC in $MDS_OSCS; do
1781 OST=$(osc_to_ost $OSC)
1782 OSTIDX=$(index_from_ostuuid $OST)
1783 if [ $OST_DEACTIVE_IDX == -1 ]; then
1784 OST_DEACTIVE_IDX=$OSTIDX
1786 if [ $OSTIDX != $OST_DEACTIVE_IDX ]; then
1787 echo $OSC "is Deactivated:"
1788 do_facet $SINGLEMDS lctl --device %$OSC deactivate
1792 OSTIDX=$(index_from_ostuuid $OST)
1793 test_mkdir -p $DIR/$tdir
1794 $SETSTRIPE -c 1 $DIR/$tdir # 1 stripe / file
1796 for OSC in $MDS_OSCS; do
1797 OST=$(osc_to_ost $OSC)
1798 OSTIDX=$(index_from_ostuuid $OST)
1799 if [ $OSTIDX == $OST_DEACTIVE_IDX ]; then
1800 echo $OST "is degraded:"
1801 do_facet ost$((OSTIDX+1)) lctl set_param -n \
1802 obdfilter.$OST.degraded=1
1807 createmany -o $DIR/$tdir/$tfile $fcount
1809 for OSC in $MDS_OSCS; do
1810 OST=$(osc_to_ost $OSC)
1811 OSTIDX=$(index_from_ostuuid $OST)
1812 if [ $OSTIDX == $OST_DEACTIVE_IDX ]; then
1813 echo $OST "is recovered from degraded:"
1814 do_facet ost$((OSTIDX+1)) lctl set_param -n \
1815 obdfilter.$OST.degraded=0
1817 do_facet $SINGLEMDS lctl --device %$OSC activate
1821 # all osp devices get activated, hence -1 stripe count restored
1824 # sleep 2*lod_qos_maxage seconds waiting for lod qos to notice osp
1825 # devices get activated.
1827 $SETSTRIPE -c -1 $DIR/$tfile
1828 stripecnt=$($GETSTRIPE -c $DIR/$tfile)
1830 [ $stripecnt -ne $OSTCOUNT ] &&
1831 error "Of $OSTCOUNT OSTs, only $stripecnt is available"
1834 run_test 27y "create files while OST0 is degraded and the rest inactive"
1840 lmm_count=$($GETSTRIPE -c $1)
1841 lmm_seq=$($GETSTRIPE -v $1 | awk '/lmm_seq/ { print $2 }')
1842 lmm_oid=$($GETSTRIPE -v $1 | awk '/lmm_object_id/ { print $2 }')
1844 local old_ifs="$IFS"
1846 fid=($($LFS path2fid $1))
1849 log "FID seq ${fid[1]}, oid ${fid[2]} ver ${fid[3]}"
1850 log "LOV seq $lmm_seq, oid $lmm_oid, count: $lmm_count"
1852 # compare lmm_seq and lu_fid->f_seq
1853 [ $lmm_seq = ${fid[1]} ] || { error "SEQ mismatch"; return 1; }
1854 # compare lmm_object_id and lu_fid->oid
1855 [ $lmm_oid = ${fid[2]} ] || { error "OID mismatch"; return 2; }
1857 # check the trusted.fid attribute of the OST objects of the file
1858 local have_obdidx=false
1860 $GETSTRIPE $1 | while read obdidx oid hex seq; do
1861 # skip lines up to and including "obdidx"
1862 [ -z "$obdidx" ] && break
1863 [ "$obdidx" = "obdidx" ] && have_obdidx=true && continue
1864 $have_obdidx || continue
1866 local ost=$((obdidx + 1))
1867 local dev=$(ostdevname $ost)
1870 log "want: stripe:$stripe_nr ost:$obdidx oid:$oid/$hex seq:$seq"
1872 seq=$(echo $seq | sed -e "s/^0x//g")
1873 if [ $seq == 0 ] || [ $(facet_fstype ost$ost) == zfs ]; then
1874 oid_hex=$(echo $oid)
1876 oid_hex=$(echo $hex | sed -e "s/^0x//g")
1878 local obj_file="O/$seq/d$((oid %32))/$oid_hex"
1882 # Don't unmount/remount the OSTs if we don't need to do that.
1883 # LU-2577 changes filter_fid to be smaller, so debugfs needs
1884 # update too, until that use mount/ll_decode_filter_fid/mount.
1885 # Re-enable when debugfs will understand new filter_fid.
1887 if false && [ $(facet_fstype ost$ost) == ldiskfs ]; then
1888 ff=$(do_facet ost$ost "$DEBUGFS -c -R 'stat $obj_file' \
1889 $dev 2>/dev/null" | grep "parent=")
1892 mount_fstype ost$ost
1893 ff=$(do_facet ost$ost $LL_DECODE_FILTER_FID \
1894 $(facet_mntpt ost$ost)/$obj_file)
1895 unmount_fstype ost$ost
1896 start ost$ost $dev $OST_MOUNT_OPTS
1900 [ -z "$ff" ] && error "$obj_file: no filter_fid info"
1902 echo "$ff" | sed -e 's#.*objid=#got: objid=#'
1904 # /mnt/O/0/d23/23: objid=23 seq=0 parent=[0x200000400:0x1e:0x1]
1905 # fid: objid=23 seq=0 parent=[0x200000400:0x1e:0x0] stripe=1
1906 local ff_parent=$(echo $ff|sed -e 's/.*parent=.//')
1907 local ff_pseq=$(echo $ff_parent | cut -d: -f1)
1908 local ff_poid=$(echo $ff_parent | cut -d: -f2)
1910 if echo $ff_parent | grep -q 'stripe='; then
1911 ff_pstripe=$(echo $ff_parent | sed -e 's/.*stripe=//')
1912 if echo $ff_pstripe | grep -q 'stripe_size='; then
1913 ff_pstripe=$(echo $ff_pstripe | cut -d' ' -f1)
1917 # $LL_DECODE_FILTER_FID does not print "stripe="; look
1918 # into f_ver in this case. See the comment on
1921 ff_pstripe=$(echo $ff_parent | cut -d: -f3 |
1925 if echo $ff_parent | grep -q 'stripe_count='; then
1926 local ff_scnt=$(echo $ff_parent |
1927 sed -e 's/.*stripe_count=//' |
1930 [ $lmm_count -eq $ff_scnt ] ||
1931 error "FF stripe count $lmm_count != $ff_scnt"
1934 # compare lmm_seq and filter_fid->ff_parent.f_seq
1935 [ $ff_pseq = $lmm_seq ] ||
1936 error "FF parent SEQ $ff_pseq != $lmm_seq"
1937 # compare lmm_object_id and filter_fid->ff_parent.f_oid
1938 [ $ff_poid = $lmm_oid ] ||
1939 error "FF parent OID $ff_poid != $lmm_oid"
1940 (($ff_pstripe == $stripe_nr)) ||
1941 error "FF stripe $ff_pstripe != $stripe_nr"
1943 stripe_nr=$((stripe_nr + 1))
1948 remote_ost_nodsh && skip "remote OST with nodsh" && return
1949 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1950 test_mkdir -p $DIR/$tdir
1952 $SETSTRIPE -c 1 -i 0 -S 64k $DIR/$tdir/$tfile-1 ||
1953 { error "setstripe -c -1 failed"; return 1; }
1954 # We need to send a write to every object to get parent FID info set.
1955 # This _should_ also work for setattr, but does not currently.
1956 # touch $DIR/$tdir/$tfile-1 ||
1957 dd if=/dev/zero of=$DIR/$tdir/$tfile-1 bs=1M count=1 ||
1958 { error "dd $tfile-1 failed"; return 2; }
1959 $SETSTRIPE -c -1 -i $((OSTCOUNT - 1)) -S 1M $DIR/$tdir/$tfile-2 ||
1960 { error "setstripe -c -1 failed"; return 3; }
1961 dd if=/dev/zero of=$DIR/$tdir/$tfile-2 bs=1M count=$OSTCOUNT ||
1962 { error "dd $tfile-2 failed"; return 4; }
1964 # make sure write RPCs have been sent to OSTs
1967 check_seq_oid $DIR/$tdir/$tfile-1 || return 5
1968 check_seq_oid $DIR/$tdir/$tfile-2 || return 6
1970 run_test 27z "check SEQ/OID on the MDT and OST filesystems"
1972 test_27A() { # b=19102
1973 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1974 local restore_size=$($GETSTRIPE -S $MOUNT)
1975 local restore_count=$($GETSTRIPE -c $MOUNT)
1976 local restore_offset=$($GETSTRIPE -i $MOUNT)
1977 $SETSTRIPE -c 0 -i -1 -S 0 $MOUNT
1978 wait_update $HOSTNAME "$GETSTRIPE -c $MOUNT | sed 's/ *//g'" "1" 20 ||
1979 error "stripe count $($GETSTRIPE -c $MOUNT) != 1"
1980 local default_size=$($GETSTRIPE -S $MOUNT)
1981 local default_offset=$($GETSTRIPE -i $MOUNT)
1982 local dsize=$((1024 * 1024))
1983 [ $default_size -eq $dsize ] ||
1984 error "stripe size $default_size != $dsize"
1985 [ $default_offset -eq -1 ] ||error "stripe offset $default_offset != -1"
1986 $SETSTRIPE -c $restore_count -i $restore_offset -S $restore_size $MOUNT
1988 run_test 27A "check filesystem-wide default LOV EA values"
1990 test_27B() { # LU-2523
1991 test_mkdir -p $DIR/$tdir
1992 rm -f $DIR/$tdir/f0 $DIR/$tdir/f1
1994 # open f1 with O_LOV_DELAY_CREATE
1996 # call setstripe ioctl on open file descriptor for f1
1998 multiop $DIR/$tdir/f1 oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:nB1c \
2002 # open f1 with O_LOV_DELAY_CREATE
2004 # call setstripe ioctl on open file descriptor for f1
2006 multiop $DIR/$tdir/f1 oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:uB1c
2008 # Allow multiop to fail in imitation of NFS's busted semantics.
2011 run_test 27B "call setstripe on open unlinked file/rename victim"
2013 test_27C() { #LU-2871
2014 [[ $OSTCOUNT -lt 2 ]] && skip "needs >= 2 OSTs" && return
2022 test_mkdir -p $DIR/$tdir
2024 for i in $(seq 0 $((OSTCOUNT - 1))); do
2025 # set stripe across all OSTs starting from OST$i
2026 $SETSTRIPE -i $i -c -1 $tfile$i
2027 # get striping information
2028 ost_idx=($($GETSTRIPE $tfile$i |
2029 tail -n $((OSTCOUNT + 1)) | awk '{print $1}'))
2033 [ ${#ost_idx[@]} -eq $OSTCOUNT ] ||
2034 error "${#ost_idx[@]} != $OSTCOUNT"
2036 for index in $(seq 0 $((OSTCOUNT - 1))); do
2038 for j in $(echo ${ost_idx[@]}); do
2039 if [ $index -eq $j ]; then
2045 error "Can not find $index in ${ost_idx[@]}"
2049 run_test 27C "check full striping across all OSTs"
2052 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs" && return
2053 [ -n "$FILESET" ] && skip "SKIP due to FILESET set" && return
2054 remote_mds_nodsh && skip "remote MDS with nodsh" && return
2055 local POOL=${POOL:-testpool}
2057 local last_ost=$(($OSTCOUNT - 1))
2059 local ost_list=$(seq $first_ost $ost_step $last_ost)
2060 local ost_range="$first_ost $last_ost $ost_step"
2062 test_mkdir -p $DIR/$tdir
2063 pool_add $POOL || error "pool_add failed"
2064 pool_add_targets $POOL $ost_range || error "pool_add_targets failed"
2067 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.64) ] &&
2068 skip27D = "-s 29,30,31"
2069 llapi_layout_test -d$DIR/$tdir -p$POOL -o$OSTCOUNT $skip27D ||
2070 error "llapi_layout_test failed"
2072 destroy_test_pools || error "destroy test pools failed"
2074 run_test 27D "validate llapi_layout API"
2076 # Verify that default_easize is increased from its initial value after
2077 # accessing a widely striped file.
2079 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs" && return
2080 [ $(lustre_version_code client) -lt $(version_code 2.5.57) ] &&
2081 skip "client does not have LU-3338 fix" && return
2083 # 72 bytes is the minimum space required to store striping
2084 # information for a file striped across one OST:
2085 # (sizeof(struct lov_user_md_v3) +
2086 # sizeof(struct lov_user_ost_data_v1))
2088 $LCTL set_param -n llite.*.default_easize $min_easize ||
2089 error "lctl set_param failed"
2090 local easize=$($LCTL get_param -n llite.*.default_easize)
2092 [ $easize -eq $min_easize ] ||
2093 error "failed to set default_easize"
2095 $LFS setstripe -c $OSTCOUNT $DIR/$tfile ||
2096 error "setstripe failed"
2100 easize=$($LCTL get_param -n llite.*.default_easize)
2102 [ $easize -gt $min_easize ] ||
2103 error "default_easize not updated"
2105 run_test 27E "check that default extended attribute size properly increases"
2107 test_27F() { # LU-5346/LU-7975
2109 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2111 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.8.51) ]] &&
2112 skip "Need MDS version at least 2.8.51" && return
2114 test_mkdir -p $DIR/$tdir
2116 $SETSTRIPE -c 2 $DIR/$tdir
2118 # stop all OSTs to reproduce situation for LU-7975 ticket
2119 for num in $(seq $OSTCOUNT); do
2123 # open/create f0 with O_LOV_DELAY_CREATE
2124 # truncate f0 to a non-0 size
2126 multiop $DIR/$tdir/f0 oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:T1050000c
2128 $CHECKSTAT -s 1050000 $DIR/$tdir/f0 || error "checkstat failed"
2129 # open/write it again to force delayed layout creation
2130 cat /etc/hosts > $DIR/$tdir/f0 &
2134 for num in $(seq $OSTCOUNT); do
2135 start ost$num $(ostdevname $num) $OST_MOUNT_OPTS ||
2136 error "ost$num failed to start"
2139 wait $catpid || error "cat failed"
2141 cmp /etc/hosts $DIR/$tdir/f0 || error "cmp failed"
2142 [[ $($GETSTRIPE -c $DIR/$tdir/f0) == 2 ]] || error "wrong stripecount"
2145 run_test 27F "Client resend delayed layout creation with non-zero size"
2147 # createtest also checks that device nodes are created and
2148 # then visible correctly (#2091)
2149 test_28() { # bug 2091
2151 $CREATETEST $DIR/d28/ct || error
2153 run_test 28 "create/mknod/mkdir with bad file types ============"
2156 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return 0
2157 sync; sleep 1; sync # flush out any dirty pages from previous tests
2164 declare -i LOCKCOUNTORIG=0
2165 for lock_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_count); do
2166 let LOCKCOUNTORIG=$LOCKCOUNTORIG+$lock_count
2168 [ $LOCKCOUNTORIG -eq 0 ] && error "No mdc lock count" && return 1
2170 declare -i LOCKUNUSEDCOUNTORIG=0
2171 for unused_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_unused_count); do
2172 let LOCKUNUSEDCOUNTORIG=$LOCKUNUSEDCOUNTORIG+$unused_count
2179 declare -i LOCKCOUNTCURRENT=0
2180 for lock_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_count); do
2181 let LOCKCOUNTCURRENT=$LOCKCOUNTCURRENT+$lock_count
2184 declare -i LOCKUNUSEDCOUNTCURRENT=0
2185 for unused_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_unused_count); do
2186 let LOCKUNUSEDCOUNTCURRENT=$LOCKUNUSEDCOUNTCURRENT+$unused_count
2189 if [[ $LOCKCOUNTCURRENT -gt $LOCKCOUNTORIG ]]; then
2190 $LCTL set_param -n ldlm.dump_namespaces ""
2191 error "CURRENT: $LOCKCOUNTCURRENT > $LOCKCOUNTORIG"
2192 $LCTL dk | sort -k4 -t: > $TMP/test_29.dk
2193 log "dumped log to $TMP/test_29.dk (bug 5793)"
2196 if [[ $LOCKUNUSEDCOUNTCURRENT -gt $LOCKUNUSEDCOUNTORIG ]]; then
2197 error "UNUSED: $LOCKUNUSEDCOUNTCURRENT > $LOCKUNUSEDCOUNTORIG"
2198 $LCTL dk | sort -k4 -t: > $TMP/test_29.dk
2199 log "dumped log to $TMP/test_29.dk (bug 5793)"
2203 run_test 29 "IT_GETATTR regression ============================"
2205 test_30a() { # was test_30
2206 cp $(which ls) $DIR || cp /bin/ls $DIR
2210 run_test 30a "execute binary from Lustre (execve) =============="
2213 cp `which ls` $DIR || cp /bin/ls $DIR
2215 $RUNAS $DIR/ls / || error
2218 run_test 30b "execute binary from Lustre as non-root ==========="
2220 test_30c() { # b=22376
2221 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2222 cp `which ls` $DIR || cp /bin/ls $DIR
2224 cancel_lru_locks mdc
2225 cancel_lru_locks osc
2226 $RUNAS $DIR/ls / || error
2229 run_test 30c "execute binary from Lustre without read perms ===="
2232 $OPENUNLINK $DIR/f31 $DIR/f31 || error
2233 $CHECKSTAT -a $DIR/f31 || error
2235 run_test 31a "open-unlink file =================================="
2238 touch $DIR/f31 || error
2239 ln $DIR/f31 $DIR/f31b || error
2240 $MULTIOP $DIR/f31b Ouc || error
2241 $CHECKSTAT -t file $DIR/f31 || error
2243 run_test 31b "unlink file with multiple links while open ======="
2246 touch $DIR/f31 || error
2247 ln $DIR/f31 $DIR/f31c || error
2248 multiop_bg_pause $DIR/f31 O_uc || return 1
2250 $MULTIOP $DIR/f31c Ouc
2251 kill -USR1 $MULTIPID
2254 run_test 31c "open-unlink file with multiple links ============="
2257 opendirunlink $DIR/d31d $DIR/d31d || error
2258 $CHECKSTAT -a $DIR/d31d || error
2260 run_test 31d "remove of open directory ========================="
2262 test_31e() { # bug 2904
2263 openfilleddirunlink $DIR/d31e || error
2265 run_test 31e "remove of open non-empty directory ==============="
2267 test_31f() { # bug 4554
2268 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2270 test_mkdir $DIR/d31f
2271 $SETSTRIPE -S 1048576 -c 1 $DIR/d31f
2272 cp /etc/hosts $DIR/d31f
2274 $GETSTRIPE $DIR/d31f/hosts
2275 multiop_bg_pause $DIR/d31f D_c || return 1
2278 rm -rv $DIR/d31f || error "first of $DIR/d31f"
2279 test_mkdir $DIR/d31f
2280 $SETSTRIPE -S 1048576 -c 1 $DIR/d31f
2281 cp /etc/hosts $DIR/d31f
2283 $GETSTRIPE $DIR/d31f/hosts
2284 multiop_bg_pause $DIR/d31f D_c || return 1
2287 kill -USR1 $MULTIPID || error "first opendir $MULTIPID not running"
2288 wait $MULTIPID || error "first opendir $MULTIPID failed"
2292 kill -USR1 $MULTIPID2 || error "second opendir $MULTIPID not running"
2293 wait $MULTIPID2 || error "second opendir $MULTIPID2 failed"
2296 run_test 31f "remove of open directory with open-unlink file ==="
2299 echo "-- cross directory link --"
2300 test_mkdir -c1 $DIR/${tdir}ga
2301 test_mkdir -c1 $DIR/${tdir}gb
2302 touch $DIR/${tdir}ga/f
2303 ln $DIR/${tdir}ga/f $DIR/${tdir}gb/g
2304 $CHECKSTAT -t file $DIR/${tdir}ga/f || error "source"
2305 [ `stat -c%h $DIR/${tdir}ga/f` == '2' ] || error "source nlink"
2306 $CHECKSTAT -t file $DIR/${tdir}gb/g || error "target"
2307 [ `stat -c%h $DIR/${tdir}gb/g` == '2' ] || error "target nlink"
2309 run_test 31g "cross directory link==============="
2312 echo "-- cross directory link --"
2313 test_mkdir -c1 $DIR/${tdir}
2314 test_mkdir -c1 $DIR/${tdir}/dir
2315 touch $DIR/${tdir}/f
2316 ln $DIR/${tdir}/f $DIR/${tdir}/dir/g
2317 $CHECKSTAT -t file $DIR/${tdir}/f || error "source"
2318 [ `stat -c%h $DIR/${tdir}/f` == '2' ] || error "source nlink"
2319 $CHECKSTAT -t file $DIR/${tdir}/dir/g || error "target"
2320 [ `stat -c%h $DIR/${tdir}/dir/g` == '2' ] || error "target nlink"
2322 run_test 31h "cross directory link under child==============="
2325 echo "-- cross directory link --"
2326 test_mkdir -c1 $DIR/$tdir
2327 test_mkdir -c1 $DIR/$tdir/dir
2328 touch $DIR/$tdir/dir/f
2329 ln $DIR/$tdir/dir/f $DIR/$tdir/g
2330 $CHECKSTAT -t file $DIR/$tdir/dir/f || error "source"
2331 [ `stat -c%h $DIR/$tdir/dir/f` == '2' ] || error "source nlink"
2332 $CHECKSTAT -t file $DIR/$tdir/g || error "target"
2333 [ `stat -c%h $DIR/$tdir/g` == '2' ] || error "target nlink"
2335 run_test 31i "cross directory link under parent==============="
2338 test_mkdir -c1 -p $DIR/$tdir
2339 test_mkdir -c1 -p $DIR/$tdir/dir1
2340 ln $DIR/$tdir/dir1 $DIR/$tdir/dir2 && error "ln for dir"
2341 link $DIR/$tdir/dir1 $DIR/$tdir/dir3 && error "link for dir"
2342 mlink $DIR/$tdir/dir1 $DIR/$tdir/dir4 && error "mlink for dir"
2343 mlink $DIR/$tdir/dir1 $DIR/$tdir/dir1 && error "mlink to the same dir"
2346 run_test 31j "link for directory==============="
2349 test_mkdir -c1 -p $DIR/$tdir
2351 touch $DIR/$tdir/exist
2352 mlink $DIR/$tdir/s $DIR/$tdir/t || error "mlink"
2353 mlink $DIR/$tdir/s $DIR/$tdir/exist && error "mlink to exist file"
2354 mlink $DIR/$tdir/s $DIR/$tdir/s && error "mlink to the same file"
2355 mlink $DIR/$tdir/s $DIR/$tdir && error "mlink to parent dir"
2356 mlink $DIR/$tdir $DIR/$tdir/s && error "mlink parent dir to target"
2357 mlink $DIR/$tdir/not-exist $DIR/$tdir/foo && error "mlink non-existing to new"
2358 mlink $DIR/$tdir/not-exist $DIR/$tdir/s && error "mlink non-existing to exist"
2361 run_test 31k "link to file: the same, non-existing, dir==============="
2367 touch $DIR/d31m2/exist
2368 mlink $DIR/d31m/s $DIR/d31m2/t || error "mlink"
2369 mlink $DIR/d31m/s $DIR/d31m2/exist && error "mlink to exist file"
2370 mlink $DIR/d31m/s $DIR/d31m2 && error "mlink to parent dir"
2371 mlink $DIR/d31m2 $DIR/d31m/s && error "mlink parent dir to target"
2372 mlink $DIR/d31m/not-exist $DIR/d31m2/foo && error "mlink non-existing to new"
2373 mlink $DIR/d31m/not-exist $DIR/d31m2/s && error "mlink non-existing to exist"
2376 run_test 31m "link to file: the same, non-existing, dir==============="
2379 touch $DIR/$tfile || error "cannot create '$DIR/$tfile'"
2380 nlink=$(stat --format=%h $DIR/$tfile)
2381 [ ${nlink:--1} -eq 1 ] || error "nlink is $nlink, expected 1"
2383 local cmd="exec $fd<$DIR/$tfile"
2386 trap "eval $cmd" EXIT
2387 nlink=$(stat --dereference --format=%h /proc/self/fd/$fd)
2388 [ ${nlink:--1} -eq 1 ] || error "nlink is $nlink, expected 1"
2389 rm $DIR/$tfile || error "cannot remove '$DIR/$tfile'"
2390 nlink=$(stat --dereference --format=%h /proc/self/fd/$fd)
2391 [ ${nlink:--1} -eq 0 ] || error "nlink is $nlink, expected 0"
2394 run_test 31n "check link count of unlinked file"
2397 local TEMPNAME=$(mktemp $1_XXXXXX)
2398 mlink $TEMPNAME $1 2> /dev/null &&
2399 echo "$BASHPID: link $TEMPNAME to $1 succeeded"
2403 test_31o() { # LU-2901
2404 test_mkdir -p $DIR/$tdir
2405 for LOOP in $(seq 100); do
2406 rm -f $DIR/$tdir/$tfile*
2407 for THREAD in $(seq 8); do
2408 link_one $DIR/$tdir/$tfile.$LOOP &
2411 local LINKS=$(ls -1 $DIR/$tdir | grep -c $tfile.$LOOP)
2412 [[ $LINKS -gt 1 ]] && ls $DIR/$tdir &&
2413 error "$LINKS duplicate links to $tfile.$LOOP" &&
2417 run_test 31o "duplicate hard links with same filename"
2420 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2422 test_mkdir $DIR/$tdir
2423 $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
2424 $LFS setdirstripe -D -c2 -t all_char $DIR/$tdir/striped_dir
2426 opendirunlink $DIR/$tdir/striped_dir/test1 ||
2427 error "open unlink test1 failed"
2428 opendirunlink $DIR/$tdir/striped_dir/test2 ||
2429 error "open unlink test2 failed"
2431 $CHECKSTAT -a $DIR/$tdir/striped_dir/test1 ||
2432 error "test1 still exists"
2433 $CHECKSTAT -a $DIR/$tdir/striped_dir/test2 ||
2434 error "test2 still exists"
2436 run_test 31p "remove of open striped directory"
2438 cleanup_test32_mount() {
2441 local loopdev=$(losetup -a | grep $EXT2_DEV | sed -ne 's/:.*$//p')
2442 $UMOUNT $DIR/$tdir/ext2-mountpoint || rc=$?
2443 losetup -d $loopdev || true
2449 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2450 echo "== more mountpoints and symlinks ================="
2451 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2452 trap cleanup_test32_mount EXIT
2453 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2454 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2455 $CHECKSTAT -t dir $DIR/$tdir/ext2-mountpoint/.. || error
2456 cleanup_test32_mount
2458 run_test 32a "stat d32a/ext2-mountpoint/.. ====================="
2461 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2462 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2463 trap cleanup_test32_mount EXIT
2464 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2465 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2466 ls -al $DIR/$tdir/ext2-mountpoint/.. || error
2467 cleanup_test32_mount
2469 run_test 32b "open d32b/ext2-mountpoint/.. ====================="
2472 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2473 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2474 trap cleanup_test32_mount EXIT
2475 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2476 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2477 test_mkdir -p $DIR/$tdir/d2/test_dir
2478 $CHECKSTAT -t dir $DIR/$tdir/ext2-mountpoint/../d2/test_dir || error
2479 cleanup_test32_mount
2481 run_test 32c "stat d32c/ext2-mountpoint/../d2/test_dir ========="
2484 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2485 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2486 trap cleanup_test32_mount EXIT
2487 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2488 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2489 test_mkdir -p $DIR/$tdir/d2/test_dir
2490 ls -al $DIR/$tdir/ext2-mountpoint/../d2/test_dir || error
2491 cleanup_test32_mount
2493 run_test 32d "open d32d/ext2-mountpoint/../d2/test_dir ========="
2496 [ -e $DIR/d32e ] && rm -fr $DIR/d32e
2497 test_mkdir -p $DIR/d32e/tmp
2498 TMP_DIR=$DIR/d32e/tmp
2499 ln -s $DIR/d32e $TMP_DIR/symlink11
2500 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
2501 $CHECKSTAT -t link $DIR/d32e/tmp/symlink11 || error
2502 $CHECKSTAT -t link $DIR/d32e/symlink01 || error
2504 run_test 32e "stat d32e/symlink->tmp/symlink->lustre-subdir ===="
2507 [ -e $DIR/d32f ] && rm -fr $DIR/d32f
2508 test_mkdir -p $DIR/d32f/tmp
2509 TMP_DIR=$DIR/d32f/tmp
2510 ln -s $DIR/d32f $TMP_DIR/symlink11
2511 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
2512 ls $DIR/d32f/tmp/symlink11 || error
2513 ls $DIR/d32f/symlink01 || error
2515 run_test 32f "open d32f/symlink->tmp/symlink->lustre-subdir ===="
2518 TMP_DIR=$DIR/$tdir/tmp
2519 test_mkdir -p $DIR/$tdir/tmp
2520 test_mkdir $DIR/${tdir}2
2521 ln -s $DIR/${tdir}2 $TMP_DIR/symlink12
2522 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
2523 $CHECKSTAT -t link $TMP_DIR/symlink12 || error
2524 $CHECKSTAT -t link $DIR/$tdir/symlink02 || error
2525 $CHECKSTAT -t dir -f $TMP_DIR/symlink12 || error
2526 $CHECKSTAT -t dir -f $DIR/$tdir/symlink02 || error
2528 run_test 32g "stat d32g/symlink->tmp/symlink->lustre-subdir/${tdir}2"
2531 rm -fr $DIR/$tdir $DIR/${tdir}2
2532 TMP_DIR=$DIR/$tdir/tmp
2533 test_mkdir -p $DIR/$tdir/tmp
2534 test_mkdir $DIR/${tdir}2
2535 ln -s $DIR/${tdir}2 $TMP_DIR/symlink12
2536 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
2537 ls $TMP_DIR/symlink12 || error
2538 ls $DIR/$tdir/symlink02 || error
2540 run_test 32h "open d32h/symlink->tmp/symlink->lustre-subdir/${tdir}2"
2543 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2544 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2545 trap cleanup_test32_mount EXIT
2546 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2547 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2548 touch $DIR/$tdir/test_file
2549 $CHECKSTAT -t file $DIR/$tdir/ext2-mountpoint/../test_file || error
2550 cleanup_test32_mount
2552 run_test 32i "stat d32i/ext2-mountpoint/../test_file ==========="
2555 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2556 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2557 trap cleanup_test32_mount EXIT
2558 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2559 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2560 touch $DIR/$tdir/test_file
2561 cat $DIR/$tdir/ext2-mountpoint/../test_file || error
2562 cleanup_test32_mount
2564 run_test 32j "open d32j/ext2-mountpoint/../test_file ==========="
2567 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2569 trap cleanup_test32_mount EXIT
2570 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2571 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint
2572 test_mkdir -p $DIR/$tdir/d2
2573 touch $DIR/$tdir/d2/test_file || error
2574 $CHECKSTAT -t file $DIR/$tdir/ext2-mountpoint/../d2/test_file || error
2575 cleanup_test32_mount
2577 run_test 32k "stat d32k/ext2-mountpoint/../d2/test_file ========"
2580 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2582 trap cleanup_test32_mount EXIT
2583 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2584 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2585 test_mkdir -p $DIR/$tdir/d2
2586 touch $DIR/$tdir/d2/test_file
2587 cat $DIR/$tdir/ext2-mountpoint/../d2/test_file || error
2588 cleanup_test32_mount
2590 run_test 32l "open d32l/ext2-mountpoint/../d2/test_file ========"
2594 test_mkdir -p $DIR/d32m/tmp
2595 TMP_DIR=$DIR/d32m/tmp
2596 ln -s $DIR $TMP_DIR/symlink11
2597 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
2598 $CHECKSTAT -t link $DIR/d32m/tmp/symlink11 || error
2599 $CHECKSTAT -t link $DIR/d32m/symlink01 || error
2601 run_test 32m "stat d32m/symlink->tmp/symlink->lustre-root ======"
2605 test_mkdir -p $DIR/d32n/tmp
2606 TMP_DIR=$DIR/d32n/tmp
2607 ln -s $DIR $TMP_DIR/symlink11
2608 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
2609 ls -l $DIR/d32n/tmp/symlink11 || error
2610 ls -l $DIR/d32n/symlink01 || error
2612 run_test 32n "open d32n/symlink->tmp/symlink->lustre-root ======"
2616 test_mkdir -p $DIR/d32o/tmp
2617 TMP_DIR=$DIR/d32o/tmp
2618 ln -s $DIR/$tfile $TMP_DIR/symlink12
2619 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
2620 $CHECKSTAT -t link $DIR/d32o/tmp/symlink12 || error
2621 $CHECKSTAT -t link $DIR/d32o/symlink02 || error
2622 $CHECKSTAT -t file -f $DIR/d32o/tmp/symlink12 || error
2623 $CHECKSTAT -t file -f $DIR/d32o/symlink02 || error
2625 run_test 32o "stat d32o/symlink->tmp/symlink->lustre-root/$tfile"
2635 test_mkdir -p $DIR/d32p/tmp
2637 TMP_DIR=$DIR/d32p/tmp
2639 ln -s $DIR/$tfile $TMP_DIR/symlink12
2641 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
2643 cat $DIR/d32p/tmp/symlink12 || error
2645 cat $DIR/d32p/symlink02 || error
2648 run_test 32p "open d32p/symlink->tmp/symlink->lustre-root/$tfile"
2651 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2652 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2653 trap cleanup_test32_mount EXIT
2654 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2655 touch $DIR/$tdir/ext2-mountpoint/under_the_mount
2656 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint
2657 ls $DIR/$tdir/ext2-mountpoint | grep "\<under_the_mount\>" && error
2658 cleanup_test32_mount
2660 run_test 32q "stat follows mountpoints in Lustre (should return error)"
2663 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2664 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2665 trap cleanup_test32_mount EXIT
2666 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2667 touch $DIR/$tdir/ext2-mountpoint/under_the_mount
2668 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint
2669 ls $DIR/$tdir/ext2-mountpoint | grep -q under_the_mount && error || true
2670 cleanup_test32_mount
2672 run_test 32r "opendir follows mountpoints in Lustre (should return error)"
2677 chmod 444 $DIR/$tfile
2678 chown $RUNAS_ID $DIR/$tfile
2680 $RUNAS $OPENFILE -f O_RDWR $DIR/$tfile && error || true
2683 run_test 33aa "write file with mode 444 (should return error) ===="
2687 test_mkdir -p $DIR/d33
2688 chown $RUNAS_ID $DIR/d33
2689 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $DIR/d33/f33|| error "create"
2690 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $DIR/d33/f33 && \
2691 error "open RDWR" || true
2693 run_test 33a "test open file(mode=0444) with O_RDWR (should return error)"
2697 test_mkdir -p $DIR/d33
2698 chown $RUNAS_ID $DIR/d33
2699 $RUNAS $OPENFILE -f 1286739555 $DIR/d33/f33 || true
2701 run_test 33b "test open file with malformed flags (No panic)"
2704 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2710 remote_ost_nodsh && skip "remote OST with nodsh" && return
2713 test_mkdir -p $DIR/d33
2714 # Read: 0, Write: 4, create/destroy: 2/0, stat: 1, punch: 0
2717 for ostnum in $(seq $OSTCOUNT); do
2718 # test-framework's OST numbering is one-based, while Lustre's
2720 ostname=$(printf "$FSNAME-OST%.4x" $((ostnum - 1)))
2721 # Parsing llobdstat's output sucks; we could grep the /proc
2722 # path, but that's likely to not be as portable as using the
2723 # llobdstat utility. So we parse lctl output instead.
2724 write_bytes=$(do_facet ost$ostnum lctl get_param -n \
2725 obdfilter/$ostname/stats |
2726 awk '/^write_bytes/ {print $7}' )
2727 echo "baseline_write_bytes@$OSTnum/$ostname=$write_bytes"
2728 if (( ${write_bytes:-0} > 0 ))
2735 $all_zeros || return 0
2738 echo foo > $DIR/d33/bar
2742 # Total up write_bytes after writing. We'd better find non-zeros.
2743 for ostnum in $(seq $OSTCOUNT); do
2744 ostname=$(printf "$FSNAME-OST%.4x" $((ostnum - 1)))
2745 write_bytes=$(do_facet ost$ostnum lctl get_param -n \
2746 obdfilter/$ostname/stats |
2747 awk '/^write_bytes/ {print $7}' )
2748 echo "write_bytes@$OSTnum/$ostname=$write_bytes"
2749 if (( ${write_bytes:-0} > 0 ))
2758 for ostnum in $(seq $OSTCOUNT); do
2759 ostname=$(printf "$FSNAME-OST%.4x" $((ostnum - 1)))
2760 echo "Check that write_bytes is present in obdfilter/*/stats:"
2761 do_facet ost$ostnum lctl get_param -n \
2762 obdfilter/$ostname/stats
2764 error "OST not keeping write_bytes stats (b22312)"
2767 run_test 33c "test llobdstat and write_bytes"
2770 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 2 MDTs" && return
2771 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2773 local remote_dir=$DIR/$tdir/remote_dir
2775 test_mkdir -p $DIR/$tdir
2776 $LFS mkdir -i $MDTIDX $remote_dir ||
2777 error "create remote directory failed"
2779 touch $remote_dir/$tfile
2780 chmod 444 $remote_dir/$tfile
2781 chown $RUNAS_ID $remote_dir/$tfile
2783 $RUNAS $OPENFILE -f O_RDWR $DIR/$tfile && error || true
2785 chown $RUNAS_ID $remote_dir
2786 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $remote_dir/f33 ||
2787 error "create" || true
2788 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $remote_dir/f33 &&
2789 error "open RDWR" || true
2790 $RUNAS $OPENFILE -f 1286739555 $remote_dir/f33 || true
2792 run_test 33d "openfile with 444 modes and malformed flags under remote dir"
2795 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2799 $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
2800 $LFS setdirstripe -i1 -c2 $DIR/$tdir/striped_dir1
2801 mkdir $DIR/$tdir/local_dir
2803 local s0_mode=$(stat -c%f $DIR/$tdir/striped_dir)
2804 local s1_mode=$(stat -c%f $DIR/$tdir/striped_dir1)
2805 local l_mode=$(stat -c%f $DIR/$tdir/local_dir)
2807 [ "$l_mode" = "$s0_mode" -a "$l_mode" = "$s1_mode" ] ||
2808 error "mkdir $l_mode striped0 $s0_mode striped1 $s1_mode"
2810 rmdir $DIR/$tdir/* || error "rmdir failed"
2813 $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
2814 $LFS setdirstripe -i1 -c2 $DIR/$tdir/striped_dir1
2815 mkdir $DIR/$tdir/local_dir
2817 s0_mode=$(stat -c%f $DIR/$tdir/striped_dir)
2818 s1_mode=$(stat -c%f $DIR/$tdir/striped_dir1)
2819 l_mode=$(stat -c%f $DIR/$tdir/local_dir)
2821 [ "$l_mode" = "$s0_mode" -a "$l_mode" = "$s1_mode" ] ||
2822 error "mkdir $l_mode striped0 $s0_mode striped1 $s1_mode 777"
2824 rmdir $DIR/$tdir/* || error "rmdir(umask 777) failed"
2827 $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
2828 $LFS setdirstripe -i1 -c2 $DIR/$tdir/striped_dir1
2829 mkdir $DIR/$tdir/local_dir
2831 s0_mode=$(stat -c%f $DIR/$tdir/striped_dir)
2832 s1_mode=$(stat -c%f $DIR/$tdir/striped_dir1)
2833 l_mode=$(stat -c%f $DIR/$tdir/local_dir)
2835 [ "$l_mode" = "$s0_mode" -a "$l_mode" = "$s1_mode" ] ||
2836 error "mkdir $l_mode striped0 $s0_mode striped1 $s1_mode 0"
2838 run_test 33e "mkdir and striped directory should have same mode"
2842 do_facet $SINGLEMDS $LCTL set_param mdt.*.enable_remote_dir_gid=0
2846 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2847 remote_mds_nodsh && skip "remote MDS with nodsh" && return
2850 chmod go+rwx $DIR/$tdir
2851 do_facet $SINGLEMDS $LCTL set_param mdt.*.enable_remote_dir_gid=-1
2852 trap cleanup_33f EXIT
2854 $RUNAS lfs mkdir -c$MDSCOUNT $DIR/$tdir/striped_dir ||
2855 error "cannot create striped directory"
2857 $RUNAS touch $DIR/$tdir/striped_dir/{0..16} ||
2858 error "cannot create files in striped directory"
2860 $RUNAS rm $DIR/$tdir/striped_dir/{0..16} ||
2861 error "cannot remove files in striped directory"
2863 $RUNAS rmdir $DIR/$tdir/striped_dir ||
2864 error "cannot remove striped directory"
2868 run_test 33f "nonroot user can create, access, and remove a striped directory"
2871 mkdir -p $DIR/$tdir/dir2
2873 local err=$($RUNAS mkdir $DIR/$tdir/dir2 2>&1)
2875 [[ $err =~ "exists" ]] || error "Not exists error"
2877 run_test 33g "nonroot user create already existing root created file"
2879 TEST_34_SIZE=${TEST_34_SIZE:-2000000000000}
2882 $MCREATE $DIR/f34 || error
2883 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" || error
2884 $TRUNCATE $DIR/f34 $TEST_34_SIZE || error
2885 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" || error
2886 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2888 run_test 34a "truncate file that has not been opened ==========="
2891 [ ! -f $DIR/f34 ] && test_34a
2892 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2893 $OPENFILE -f O_RDONLY $DIR/f34
2894 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" || error
2895 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2897 run_test 34b "O_RDONLY opening file doesn't create objects ====="
2900 [ ! -f $DIR/f34 ] && test_34a
2901 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2902 $OPENFILE -f O_RDWR $DIR/f34
2903 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" && error
2904 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2906 run_test 34c "O_RDWR opening file-with-size works =============="
2909 [ ! -f $DIR/f34 ] && test_34a
2910 dd if=/dev/zero of=$DIR/f34 conv=notrunc bs=4k count=1 || error
2911 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2914 run_test 34d "write to sparse file ============================="
2918 $MCREATE $DIR/f34e || error
2919 $TRUNCATE $DIR/f34e 1000 || error
2920 $CHECKSTAT -s 1000 $DIR/f34e || error
2921 $OPENFILE -f O_RDWR $DIR/f34e
2922 $CHECKSTAT -s 1000 $DIR/f34e || error
2924 run_test 34e "create objects, some with size and some without =="
2926 test_34f() { # bug 6242, 6243
2927 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2930 $MCREATE $DIR/f34f || error
2931 $TRUNCATE $DIR/f34f $SIZE34F || error "truncating $DIR/f3f to $SIZE34F"
2932 dd if=$DIR/f34f of=$TMP/f34f
2933 $CHECKSTAT -s $SIZE34F $TMP/f34f || error "$TMP/f34f not $SIZE34F bytes"
2934 dd if=/dev/zero of=$TMP/f34fzero bs=$SIZE34F count=1
2935 cmp $DIR/f34f $TMP/f34fzero || error "$DIR/f34f not all zero"
2936 cmp $TMP/f34f $TMP/f34fzero || error "$TMP/f34f not all zero"
2937 rm $TMP/f34f $TMP/f34fzero $DIR/f34f
2939 run_test 34f "read from a file with no objects until EOF ======="
2942 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2943 dd if=/dev/zero of=$DIR/$tfile bs=1 count=100 seek=$TEST_34_SIZE || error
2944 $TRUNCATE $DIR/$tfile $((TEST_34_SIZE / 2))|| error
2945 $CHECKSTAT -s $((TEST_34_SIZE / 2)) $DIR/$tfile || error "truncate failed"
2946 cancel_lru_locks osc
2947 $CHECKSTAT -s $((TEST_34_SIZE / 2)) $DIR/$tfile || \
2948 error "wrong size after lock cancel"
2950 $TRUNCATE $DIR/$tfile $TEST_34_SIZE || error
2951 $CHECKSTAT -s $TEST_34_SIZE $DIR/$tfile || \
2952 error "expanding truncate failed"
2953 cancel_lru_locks osc
2954 $CHECKSTAT -s $TEST_34_SIZE $DIR/$tfile || \
2955 error "wrong expanded size after lock cancel"
2957 run_test 34g "truncate long file ==============================="
2960 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2964 dd if=/dev/zero of=$DIR/$tfile bs=1M count=10 || error
2965 sync # Flush the cache so that multiop below does not block on cache
2966 # flush when getting the group lock
2967 $MULTIOP $DIR/$tfile OG${gid}T${sz}g${gid}c &
2970 # Since just timed wait is not good enough, let's do a sync write
2971 # that way we are sure enough time for a roundtrip + processing
2972 # passed + 2 seconds of extra margin.
2973 dd if=/dev/zero of=$DIR/${tfile}-1 bs=4096 oflag=direct count=1
2977 if [[ `ps h -o comm -p $MULTIPID` == "multiop" ]]; then
2978 error "Multiop blocked on ftruncate, pid=$MULTIPID"
2982 local nsz=`stat -c %s $DIR/$tfile`
2983 [[ $nsz == $sz ]] || error "New size wrong $nsz != $sz"
2985 run_test 34h "ftruncate file under grouplock should not block"
2988 cp /bin/sh $DIR/f35a
2990 chown $RUNAS_ID $DIR/f35a
2991 $RUNAS $DIR/f35a && error || true
2994 run_test 35a "exec file with mode 444 (should return and not leak) ====="
2998 utime $DIR/f36 || error
3000 run_test 36a "MDS utime check (mknod, utime) ==================="
3004 utime $DIR/f36 || error
3006 run_test 36b "OST utime check (open, utime) ===================="
3011 chown $RUNAS_ID $DIR/d36
3012 $RUNAS utime $DIR/d36/f36 || error
3014 run_test 36c "non-root MDS utime check (mknod, utime) =========="
3017 [ ! -d $DIR/d36 ] && test_36c
3018 echo "" > $DIR/d36/f36
3019 $RUNAS utime $DIR/d36/f36 || error
3021 run_test 36d "non-root OST utime check (open, utime) ==========="
3024 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID -- skipping" && return
3025 test_mkdir -p $DIR/$tdir
3026 touch $DIR/$tdir/$tfile
3027 $RUNAS utime $DIR/$tdir/$tfile && \
3028 error "utime worked, expected failure" || true
3030 run_test 36e "utime on non-owned file (should return error) ===="
3034 local LANG_SAVE=$LANG
3035 local LC_LANG_SAVE=$LC_LANG
3036 export LANG=C LC_LANG=C # for date language
3038 DATESTR="Dec 20 2000"
3039 test_mkdir -p $DIR/$tdir
3040 lctl set_param fail_loc=$fl
3042 cp /etc/hosts $DIR/$tdir/$tfile
3043 sync & # write RPC generated with "current" inode timestamp, but delayed
3045 touch --date="$DATESTR" $DIR/$tdir/$tfile # setattr timestamp in past
3046 LS_BEFORE="`ls -l $DIR/$tdir/$tfile`" # old timestamp from client cache
3047 cancel_lru_locks osc
3048 LS_AFTER="`ls -l $DIR/$tdir/$tfile`" # timestamp from OST object
3050 [ "$LS_BEFORE" != "$LS_AFTER" ] && \
3051 echo "BEFORE: $LS_BEFORE" && \
3052 echo "AFTER : $LS_AFTER" && \
3053 echo "WANT : $DATESTR" && \
3054 error "$DIR/$tdir/$tfile timestamps changed" || true
3056 export LANG=$LANG_SAVE LC_LANG=$LC_LANG_SAVE
3060 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3061 #define OBD_FAIL_OST_BRW_PAUSE_BULK 0x214
3062 subr_36fh "0x80000214"
3064 run_test 36f "utime on file racing with OST BRW write =========="
3067 remote_ost_nodsh && skip "remote OST with nodsh" && return
3068 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3073 test_mkdir -p $DIR/$tdir
3074 fmd_max_age=$(do_facet ost1 \
3075 "lctl get_param -n obdfilter.*.client_cache_seconds 2> /dev/null | \
3078 fmd_before=$(do_facet ost1 \
3079 "awk '/ll_fmd_cache/ {print \\\$2}' /proc/slabinfo")
3080 touch $DIR/$tdir/$tfile
3081 sleep $((fmd_max_age + 12))
3082 fmd_after=$(do_facet ost1 \
3083 "awk '/ll_fmd_cache/ {print \\\$2}' /proc/slabinfo")
3085 echo "fmd_before: $fmd_before"
3086 echo "fmd_after: $fmd_after"
3087 [[ $fmd_after -gt $fmd_before ]] &&
3088 echo "AFTER: $fmd_after > BEFORE: $fmd_before" &&
3089 error "fmd didn't expire after ping" || true
3091 run_test 36g "filter mod data cache expiry ====================="
3094 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3095 #define OBD_FAIL_OST_BRW_PAUSE_BULK2 0x227
3096 subr_36fh "0x80000227"
3098 run_test 36h "utime on file racing with OST BRW write =========="
3101 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
3103 test_mkdir $DIR/$tdir
3104 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR/$tdir/striped_dir
3106 local mtime=$(stat -c%Y $DIR/$tdir/striped_dir)
3107 local new_mtime=$((mtime + 200))
3109 #change Modify time of striped dir
3110 touch -m -d @$new_mtime $DIR/$tdir/striped_dir ||
3111 error "change mtime failed"
3113 local got=$(stat -c%Y $DIR/$tdir/striped_dir)
3115 [ "$new_mtime" = "$got" ] || error "expect $new_mtime got $got"
3117 run_test 36i "change mtime on striped directory"
3119 # test_37 - duplicate with tests 32q 32r
3122 local file=$DIR/$tfile
3124 openfile -f O_DIRECTORY $file
3127 [ $RC -eq 0 ] && error "opened file $file with O_DIRECTORY" || true
3128 [ $RC -eq $ENOTDIR ] || error "error $RC should be ENOTDIR ($ENOTDIR)"
3130 run_test 38 "open a regular file with O_DIRECTORY should return -ENOTDIR ==="
3132 test_39a() { # was test_39
3134 touch $DIR/${tfile}2
3135 # ls -l $DIR/$tfile $DIR/${tfile}2
3136 # ls -lu $DIR/$tfile $DIR/${tfile}2
3137 # ls -lc $DIR/$tfile $DIR/${tfile}2
3139 $OPENFILE -f O_CREAT:O_TRUNC:O_WRONLY $DIR/${tfile}2
3140 if [ ! $DIR/${tfile}2 -nt $DIR/$tfile ]; then
3142 ls -l --full-time $DIR/$tfile $DIR/${tfile}2
3144 ls -lu --full-time $DIR/$tfile $DIR/${tfile}2
3146 ls -lc --full-time $DIR/$tfile $DIR/${tfile}2
3147 error "O_TRUNC didn't change timestamps"
3150 run_test 39a "mtime changed on create ==========================="
3153 test_mkdir -p -c1 $DIR/$tdir
3154 cp -p /etc/passwd $DIR/$tdir/fopen
3155 cp -p /etc/passwd $DIR/$tdir/flink
3156 cp -p /etc/passwd $DIR/$tdir/funlink
3157 cp -p /etc/passwd $DIR/$tdir/frename
3158 ln $DIR/$tdir/funlink $DIR/$tdir/funlink2
3161 echo "aaaaaa" >> $DIR/$tdir/fopen
3162 echo "aaaaaa" >> $DIR/$tdir/flink
3163 echo "aaaaaa" >> $DIR/$tdir/funlink
3164 echo "aaaaaa" >> $DIR/$tdir/frename
3166 local open_new=`stat -c %Y $DIR/$tdir/fopen`
3167 local link_new=`stat -c %Y $DIR/$tdir/flink`
3168 local unlink_new=`stat -c %Y $DIR/$tdir/funlink`
3169 local rename_new=`stat -c %Y $DIR/$tdir/frename`
3171 cat $DIR/$tdir/fopen > /dev/null
3172 ln $DIR/$tdir/flink $DIR/$tdir/flink2
3173 rm -f $DIR/$tdir/funlink2
3174 mv -f $DIR/$tdir/frename $DIR/$tdir/frename2
3176 for (( i=0; i < 2; i++ )) ; do
3177 local open_new2=`stat -c %Y $DIR/$tdir/fopen`
3178 local link_new2=`stat -c %Y $DIR/$tdir/flink`
3179 local unlink_new2=`stat -c %Y $DIR/$tdir/funlink`
3180 local rename_new2=`stat -c %Y $DIR/$tdir/frename2`
3182 [ $open_new2 -eq $open_new ] || error "open file reverses mtime"
3183 [ $link_new2 -eq $link_new ] || error "link file reverses mtime"
3184 [ $unlink_new2 -eq $unlink_new ] || error "unlink file reverses mtime"
3185 [ $rename_new2 -eq $rename_new ] || error "rename file reverses mtime"
3187 cancel_lru_locks osc
3188 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3191 run_test 39b "mtime change on open, link, unlink, rename ======"
3193 # this should be set to past
3194 TEST_39_MTIME=`date -d "1 year ago" +%s`
3200 local mtime0=`stat -c %Y $DIR1/$tfile`
3202 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3203 local mtime1=`stat -c %Y $DIR1/$tfile`
3204 [ "$mtime1" = $TEST_39_MTIME ] || \
3205 error "mtime is not set to past: $mtime1, should be $TEST_39_MTIME"
3208 echo hello >> $DIR1/$tfile
3210 local mtime2=`stat -c %Y $DIR1/$tfile`
3211 [ "$mtime2" -ge "$d1" ] && [ "$mtime2" -le "$d2" ] || \
3212 error "mtime is not updated on write: $d1 <= $mtime2 <= $d2"
3214 mv $DIR1/$tfile $DIR1/$tfile-1
3216 for (( i=0; i < 2; i++ )) ; do
3217 local mtime3=`stat -c %Y $DIR1/$tfile-1`
3218 [ "$mtime2" = "$mtime3" ] || \
3219 error "mtime ($mtime2) changed (to $mtime3) on rename"
3221 cancel_lru_locks osc
3222 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3225 run_test 39c "mtime change on rename ==========================="
3229 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3232 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3234 for (( i=0; i < 2; i++ )) ; do
3235 local mtime=`stat -c %Y $DIR1/$tfile`
3236 [ $mtime = $TEST_39_MTIME ] || \
3237 error "mtime($mtime) is not set to $TEST_39_MTIME"
3239 cancel_lru_locks osc
3240 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3243 run_test 39d "create, utime, stat =============================="
3247 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3249 local mtime1=`stat -c %Y $DIR1/$tfile`
3251 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3253 for (( i=0; i < 2; i++ )) ; do
3254 local mtime2=`stat -c %Y $DIR1/$tfile`
3255 [ $mtime2 = $TEST_39_MTIME ] || \
3256 error "mtime($mtime2) is not set to $TEST_39_MTIME"
3258 cancel_lru_locks osc
3259 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3262 run_test 39e "create, stat, utime, stat ========================"
3266 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3268 mtime1=`stat -c %Y $DIR1/$tfile`
3271 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3273 for (( i=0; i < 2; i++ )) ; do
3274 local mtime2=`stat -c %Y $DIR1/$tfile`
3275 [ $mtime2 = $TEST_39_MTIME ] || \
3276 error "mtime($mtime2) is not set to $TEST_39_MTIME"
3278 cancel_lru_locks osc
3279 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3282 run_test 39f "create, stat, sleep, utime, stat ================="
3286 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3287 echo hello >> $DIR1/$tfile
3288 local mtime1=`stat -c %Y $DIR1/$tfile`
3291 chmod o+r $DIR1/$tfile
3293 for (( i=0; i < 2; i++ )) ; do
3294 local mtime2=`stat -c %Y $DIR1/$tfile`
3295 [ "$mtime1" = "$mtime2" ] || \
3296 error "lost mtime: $mtime2, should be $mtime1"
3298 cancel_lru_locks osc
3299 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3302 run_test 39g "write, chmod, stat ==============================="
3306 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3311 echo hello >> $DIR1/$tfile
3312 local mtime1=`stat -c %Y $DIR1/$tfile`
3314 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3316 if [ "$d1" != "$d2" ]; then
3317 echo "write and touch not within one second"
3319 for (( i=0; i < 2; i++ )) ; do
3320 local mtime2=`stat -c %Y $DIR1/$tfile`
3321 [ "$mtime2" = $TEST_39_MTIME ] || \
3322 error "lost mtime: $mtime2, should be $TEST_39_MTIME"
3324 cancel_lru_locks osc
3325 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3329 run_test 39h "write, utime within one second, stat ============="
3332 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3336 echo hello >> $DIR1/$tfile
3337 local mtime1=`stat -c %Y $DIR1/$tfile`
3339 mv $DIR1/$tfile $DIR1/$tfile-1
3341 for (( i=0; i < 2; i++ )) ; do
3342 local mtime2=`stat -c %Y $DIR1/$tfile-1`
3344 [ "$mtime1" = "$mtime2" ] || \
3345 error "lost mtime: $mtime2, should be $mtime1"
3347 cancel_lru_locks osc
3348 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3351 run_test 39i "write, rename, stat =============================="
3354 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3355 start_full_debug_logging
3359 #define OBD_FAIL_OSC_DELAY_SETTIME 0x412
3360 lctl set_param fail_loc=0x80000412
3361 multiop_bg_pause $DIR1/$tfile oO_RDWR:w2097152_c ||
3362 error "multiop failed"
3364 local mtime1=`stat -c %Y $DIR1/$tfile`
3366 mv $DIR1/$tfile $DIR1/$tfile-1
3368 kill -USR1 $multipid
3369 wait $multipid || error "multiop close failed"
3371 for (( i=0; i < 2; i++ )) ; do
3372 local mtime2=`stat -c %Y $DIR1/$tfile-1`
3373 [ "$mtime1" = "$mtime2" ] ||
3374 error "mtime is lost on close: $mtime2, " \
3377 cancel_lru_locks osc
3378 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3380 lctl set_param fail_loc=0
3381 stop_full_debug_logging
3383 run_test 39j "write, rename, close, stat ======================="
3386 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3390 multiop_bg_pause $DIR1/$tfile oO_RDWR:w2097152_c || error "multiop failed"
3392 local mtime1=`stat -c %Y $DIR1/$tfile`
3394 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3396 kill -USR1 $multipid
3397 wait $multipid || error "multiop close failed"
3399 for (( i=0; i < 2; i++ )) ; do
3400 local mtime2=`stat -c %Y $DIR1/$tfile`
3402 [ "$mtime2" = $TEST_39_MTIME ] || \
3403 error "mtime is lost on close: $mtime2, should be $TEST_39_MTIME"
3405 cancel_lru_locks osc
3406 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3409 run_test 39k "write, utime, close, stat ========================"
3411 # this should be set to future
3412 TEST_39_ATIME=`date -d "1 year" +%s`
3415 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3416 remote_mds_nodsh && skip "remote MDS with nodsh" && return
3417 local atime_diff=$(do_facet $SINGLEMDS \
3418 lctl get_param -n mdd.*MDT0000*.atime_diff)
3422 # test setting directory atime to future
3423 touch -a -d @$TEST_39_ATIME $DIR/$tdir
3424 local atime=$(stat -c %X $DIR/$tdir)
3425 [ "$atime" = $TEST_39_ATIME ] ||
3426 error "atime is not set to future: $atime, $TEST_39_ATIME"
3428 # test setting directory atime from future to now
3429 local now=$(date +%s)
3430 touch -a -d @$now $DIR/$tdir
3432 atime=$(stat -c %X $DIR/$tdir)
3433 [ "$atime" -eq "$now" ] ||
3434 error "atime is not updated from future: $atime, $now"
3436 do_facet $SINGLEMDS lctl set_param -n mdd.*MDT0000*.atime_diff=2
3439 # test setting directory atime when now > dir atime + atime_diff
3440 local d1=$(date +%s)
3442 local d2=$(date +%s)
3443 cancel_lru_locks mdc
3444 atime=$(stat -c %X $DIR/$tdir)
3445 [ "$atime" -ge "$d1" -a "$atime" -le "$d2" ] ||
3446 error "atime is not updated : $atime, should be $d2"
3448 do_facet $SINGLEMDS lctl set_param -n mdd.*MDT0000*.atime_diff=60
3451 # test not setting directory atime when now < dir atime + atime_diff
3453 cancel_lru_locks mdc
3454 atime=$(stat -c %X $DIR/$tdir)
3455 [ "$atime" -ge "$d1" -a "$atime" -le "$d2" ] ||
3456 error "atime is updated to $atime, should remain $d1<atime<$d2"
3458 do_facet $SINGLEMDS \
3459 lctl set_param -n mdd.*MDT0000*.atime_diff=$atime_diff
3461 run_test 39l "directory atime update ==========================="
3464 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3467 local far_past_mtime=$(date -d "May 29 1953" +%s)
3468 local far_past_atime=$(date -d "Dec 17 1903" +%s)
3470 touch -m -d @$far_past_mtime $DIR1/$tfile
3471 touch -a -d @$far_past_atime $DIR1/$tfile
3473 for (( i=0; i < 2; i++ )) ; do
3474 local timestamps=$(stat -c "%X %Y" $DIR1/$tfile)
3475 [ "$timestamps" = "$far_past_atime $far_past_mtime" ] || \
3476 error "atime or mtime set incorrectly"
3478 cancel_lru_locks osc
3479 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3482 run_test 39m "test atime and mtime before 1970"
3484 test_39n() { # LU-3832
3485 remote_mds_nodsh && skip "remote MDS with nodsh" && return
3486 local atime_diff=$(do_facet $SINGLEMDS \
3487 lctl get_param -n mdd.*MDT0000*.atime_diff)
3492 do_facet $SINGLEMDS lctl set_param -n mdd.*MDT0000*.atime_diff=1
3495 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 status=noxfer
3496 atime0=$(stat -c %X $DIR/$tfile)
3499 $MULTIOP $DIR/$tfile oO_RDONLY:O_NOATIME:r4096c
3500 atime1=$(stat -c %X $DIR/$tfile)
3503 cancel_lru_locks mdc
3504 cancel_lru_locks osc
3505 $MULTIOP $DIR/$tfile oO_RDONLY:O_NOATIME:r4096c
3506 atime2=$(stat -c %X $DIR/$tfile)
3508 do_facet $SINGLEMDS \
3509 lctl set_param -n mdd.*MDT0000*.atime_diff=$atime_diff
3511 [ "$atime0" -eq "$atime1" ] || error "atime0 $atime0 != atime1 $atime1"
3512 [ "$atime1" -eq "$atime2" ] || error "atime0 $atime0 != atime1 $atime1"
3514 run_test 39n "check that O_NOATIME is honored"
3517 TESTDIR=$DIR/$tdir/$tfile
3518 [ -e $TESTDIR ] && rm -rf $TESTDIR
3525 links2=$(stat -c %h .)
3526 [ $(($links1 + 2)) != $links2 ] &&
3527 error "wrong links count $(($links1 + 2)) != $links2"
3529 links3=$(stat -c %h .)
3530 [ $(($links1 + 1)) != $links3 ] &&
3531 error "wrong links count $links1 != $links3"
3534 run_test 39o "directory cached attributes updated after create ========"
3537 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 2 MDTs" && return
3539 TESTDIR=$DIR/$tdir/$tfile
3540 [ -e $TESTDIR ] && rm -rf $TESTDIR
3541 test_mkdir -p $TESTDIR
3545 $LFS mkdir -i $MDTIDX $TESTDIR/remote_dir1
3546 $LFS mkdir -i $MDTIDX $TESTDIR/remote_dir2
3548 links2=$(stat -c %h .)
3549 [ $(($links1 + 2)) != $links2 ] &&
3550 error "wrong links count $(($links1 + 2)) != $links2"
3552 links3=$(stat -c %h .)
3553 [ $(($links1 + 1)) != $links3 ] &&
3554 error "wrong links count $links1 != $links3"
3557 run_test 39p "remote directory cached attributes updated after create ========"
3560 test_39q() { # LU-8041
3561 local testdir=$DIR/$tdir
3563 multiop_bg_pause $testdir D_c || error "multiop failed"
3565 cancel_lru_locks mdc
3566 kill -USR1 $multipid
3567 local atime=$(stat -c %X $testdir)
3568 [ "$atime" -ne 0 ] || error "atime is zero"
3570 run_test 39q "close won't zero out atime"
3573 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1
3574 $RUNAS $OPENFILE -f O_WRONLY:O_TRUNC $DIR/$tfile &&
3575 error "openfile O_WRONLY:O_TRUNC $tfile failed"
3576 $CHECKSTAT -t file -s 4096 $DIR/$tfile ||
3577 error "$tfile is not 4096 bytes in size"
3579 run_test 40 "failed open(O_TRUNC) doesn't truncate ============="
3583 small_write $DIR/f41 18
3585 run_test 41 "test small file write + fstat ====================="
3587 count_ost_writes() {
3588 lctl get_param -n osc.*.stats |
3589 awk -vwrites=0 '/ost_write/ { writes += $2 } \
3590 END { printf("%0.0f", writes) }'
3597 BG_DIRTY_RATIO_SAVE=10
3598 MAX_BG_DIRTY_RATIO=25
3602 # in 2.6, restore /proc/sys/vm/dirty_writeback_centisecs,
3603 # dirty_ratio, dirty_background_ratio
3604 if [ -f /proc/sys/vm/dirty_writeback_centisecs ]; then
3605 sysctl -w vm.dirty_writeback_centisecs=$WRITEBACK_SAVE
3606 sysctl -w vm.dirty_background_ratio=$BG_DIRTY_RATIO_SAVE
3607 sysctl -w vm.dirty_ratio=$DIRTY_RATIO_SAVE
3609 # if file not here, we are a 2.4 kernel
3610 kill -CONT `pidof kupdated`
3615 # setup the trap first, so someone cannot exit the test at the
3616 # exact wrong time and mess up a machine
3617 trap start_writeback EXIT
3618 # in 2.6, save and 0 /proc/sys/vm/dirty_writeback_centisecs
3619 if [ -f /proc/sys/vm/dirty_writeback_centisecs ]; then
3620 WRITEBACK_SAVE=`sysctl -n vm.dirty_writeback_centisecs`
3621 sysctl -w vm.dirty_writeback_centisecs=0
3622 sysctl -w vm.dirty_writeback_centisecs=0
3623 # save and increase /proc/sys/vm/dirty_ratio
3624 DIRTY_RATIO_SAVE=`sysctl -n vm.dirty_ratio`
3625 sysctl -w vm.dirty_ratio=$MAX_DIRTY_RATIO
3626 # save and increase /proc/sys/vm/dirty_background_ratio
3627 BG_DIRTY_RATIO_SAVE=`sysctl -n vm.dirty_background_ratio`
3628 sysctl -w vm.dirty_background_ratio=$MAX_BG_DIRTY_RATIO
3630 # if file not here, we are a 2.4 kernel
3631 kill -STOP `pidof kupdated`
3635 # ensure that all stripes have some grant before we test client-side cache
3637 for i in `seq -f $DIR/f42-%g 1 $OSTCOUNT`; do
3638 dd if=/dev/zero of=$i bs=4k count=1
3643 # Tests 42* verify that our behaviour is correct WRT caching, file closure,
3644 # file truncation, and file removal.
3646 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3648 cancel_lru_locks osc
3650 sync; sleep 1; sync # just to be safe
3651 BEFOREWRITES=`count_ost_writes`
3652 lctl get_param -n osc.*[oO][sS][cC][_-]*.cur_grant_bytes | grep "[0-9]"
3653 dd if=/dev/zero of=$DIR/f42a bs=1024 count=100
3654 AFTERWRITES=`count_ost_writes`
3655 [ $BEFOREWRITES -eq $AFTERWRITES ] || \
3656 error "$BEFOREWRITES < $AFTERWRITES"
3659 run_test 42a "ensure that we don't flush on close"
3662 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3664 cancel_lru_locks osc
3667 dd if=/dev/zero of=$DIR/f42b bs=1024 count=100
3668 BEFOREWRITES=$(count_ost_writes)
3669 $MUNLINK $DIR/f42b || error "$MUNLINK $DIR/f42b: $?"
3670 AFTERWRITES=$(count_ost_writes)
3671 if [[ $BEFOREWRITES -lt $AFTERWRITES ]]; then
3672 error "$BEFOREWRITES < $AFTERWRITES on unlink"
3674 BEFOREWRITES=$(count_ost_writes)
3675 sync || error "sync: $?"
3676 AFTERWRITES=$(count_ost_writes)
3677 if [[ $BEFOREWRITES -lt $AFTERWRITES ]]; then
3678 error "$BEFOREWRITES < $AFTERWRITES on sync"
3680 dmesg | grep 'error from obd_brw_async' && error 'error writing back'
3684 run_test 42b "test destroy of file with cached dirty data ======"
3686 # if these tests just want to test the effect of truncation,
3687 # they have to be very careful. consider:
3688 # - the first open gets a {0,EOF}PR lock
3689 # - the first write conflicts and gets a {0, count-1}PW
3690 # - the rest of the writes are under {count,EOF}PW
3691 # - the open for truncate tries to match a {0,EOF}PR
3692 # for the filesize and cancels the PWs.
3693 # any number of fixes (don't get {0,EOF} on open, match
3694 # composite locks, do smarter file size management) fix
3695 # this, but for now we want these tests to verify that
3696 # the cancellation with truncate intent works, so we
3697 # start the file with a full-file pw lock to match against
3698 # until the truncate.
3703 cancel_lru_locks osc
3705 # prime the file with 0,EOF PW to match
3709 # now the real test..
3710 dd if=/dev/zero of=$file bs=1024 count=100
3711 BEFOREWRITES=`count_ost_writes`
3712 $TRUNCATE $file $offset
3713 cancel_lru_locks osc
3714 AFTERWRITES=`count_ost_writes`
3719 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3721 [ $BEFOREWRITES -eq $AFTERWRITES ] && \
3722 error "beforewrites $BEFOREWRITES == afterwrites $AFTERWRITES on truncate"
3725 run_test 42c "test partial truncate of file with cached dirty data"
3728 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3730 [ $BEFOREWRITES -eq $AFTERWRITES ] || \
3731 error "beforewrites $BEFOREWRITES != afterwrites $AFTERWRITES on truncate"
3734 run_test 42d "test complete truncate of file with cached dirty data"
3736 test_42e() { # bug22074
3737 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3738 local TDIR=$DIR/${tdir}e
3739 local pagesz=$(page_size)
3740 local pages=16 # hardcoded 16 pages, don't change it.
3741 local files=$((OSTCOUNT * 500)) # hopefully 500 files on each OST
3742 local proc_osc0="osc.${FSNAME}-OST0000-osc-[^MDT]*"
3746 test_mkdir -p $DIR/${tdir}e
3747 $SETSTRIPE -c 1 $TDIR
3748 createmany -o $TDIR/f $files
3750 max_dirty_mb=$($LCTL get_param -n $proc_osc0/max_dirty_mb)
3752 # we assume that with $OSTCOUNT files, at least one of them will
3753 # be allocated on OST0.
3754 warmup_files=$((OSTCOUNT * max_dirty_mb))
3755 createmany -o $TDIR/w $warmup_files
3757 # write a large amount of data into one file and sync, to get good
3758 # avail_grant number from OST.
3759 for ((i=0; i<$warmup_files; i++)); do
3760 idx=$($GETSTRIPE -i $TDIR/w$i)
3761 [ $idx -ne 0 ] && continue
3762 dd if=/dev/zero of=$TDIR/w$i bs="$max_dirty_mb"M count=1
3765 [[ $i -gt $warmup_files ]] && error "OST0 is still cold"
3767 $LCTL get_param $proc_osc0/cur_dirty_bytes
3768 $LCTL get_param $proc_osc0/cur_grant_bytes
3770 # create as much dirty pages as we can while not to trigger the actual
3771 # RPCs directly. but depends on the env, VFS may trigger flush during this
3772 # period, hopefully we are good.
3773 for ((i=0; i<$warmup_files; i++)); do
3774 idx=$($GETSTRIPE -i $TDIR/w$i)
3775 [ $idx -ne 0 ] && continue
3776 dd if=/dev/zero of=$TDIR/w$i bs=1M count=1 2>/dev/null
3778 $LCTL get_param $proc_osc0/cur_dirty_bytes
3779 $LCTL get_param $proc_osc0/cur_grant_bytes
3781 # perform the real test
3782 $LCTL set_param $proc_osc0/rpc_stats 0
3783 for ((;i<$files; i++)); do
3784 [ $($GETSTRIPE -i $TDIR/f$i) -eq 0 ] || continue
3785 dd if=/dev/zero of=$TDIR/f$i bs=$pagesz count=$pages 2>/dev/null
3788 $LCTL get_param $proc_osc0/rpc_stats
3791 local have_ppr=false
3792 $LCTL get_param $proc_osc0/rpc_stats |
3793 while read PPR RRPC RPCT RCUM BAR WRPC WPCT WCUM; do
3794 # skip lines until we are at the RPC histogram data
3795 [ "$PPR" == "pages" ] && have_ppr=true && continue
3796 $have_ppr || continue
3798 # we only want the percent stat for < 16 pages
3799 [[ $(echo $PPR | tr -d ':') -ge $pages ]] && break
3801 percent=$((percent + WPCT))
3802 if [[ $percent -gt 15 ]]; then
3803 error "less than 16-pages write RPCs" \
3810 run_test 42e "verify sub-RPC writes are not done synchronously"
3812 test_43A() { # was test_43
3813 test_mkdir -p $DIR/$tdir
3814 cp -p /bin/ls $DIR/$tdir/$tfile
3815 $MULTIOP $DIR/$tdir/$tfile Ow_c &
3817 # give multiop a chance to open
3820 $DIR/$tdir/$tfile && error "execute $DIR/$tdir/$tfile succeeded" || true
3823 run_test 43A "execution of file opened for write should return -ETXTBSY"
3826 test_mkdir $DIR/$tdir
3827 cp -p $(which $MULTIOP) $DIR/$tdir/multiop ||
3828 cp -p multiop $DIR/$tdir/multiop
3829 MULTIOP_PROG=$DIR/$tdir/multiop multiop_bg_pause $TMP/$tfile.junk O_c ||
3830 error "multiop open $TMP/$tfile.junk failed"
3832 $MULTIOP $DIR/$tdir/multiop Oc && error "expected error, got success"
3833 kill -USR1 $MULTIOP_PID || error "kill -USR1 PID $MULTIOP_PID failed"
3834 wait $MULTIOP_PID || error "wait PID $MULTIOP_PID failed"
3836 run_test 43a "open(RDWR) of file being executed should return -ETXTBSY"
3839 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3840 test_mkdir $DIR/$tdir
3841 cp -p $(which $MULTIOP) $DIR/$tdir/multiop ||
3842 cp -p multiop $DIR/$tdir/multiop
3843 MULTIOP_PROG=$DIR/$tdir/multiop multiop_bg_pause $TMP/$tfile.junk O_c ||
3844 error "multiop open $TMP/$tfile.junk failed"
3846 $TRUNCATE $DIR/$tdir/multiop 0 && error "expected error, got success"
3847 kill -USR1 $MULTIOP_PID || error "kill -USR1 PID $MULTIOP_PID failed"
3848 wait $MULTIOP_PID || error "wait PID $MULTIOP_PID failed"
3850 run_test 43b "truncate of file being executed should return -ETXTBSY"
3853 local testdir="$DIR/$tdir"
3856 ( cd $(dirname $SHELL) && md5sum $(basename $SHELL) ) |
3857 ( cd $testdir && md5sum -c )
3859 run_test 43c "md5sum of copy into lustre"
3861 test_44A() { # was test_44
3862 [[ $OSTCOUNT -lt 2 ]] && skip_env "skipping 2-stripe test" && return
3863 dd if=/dev/zero of=$DIR/f1 bs=4k count=1 seek=1023
3864 dd if=$DIR/f1 bs=4k count=1 > /dev/null
3866 run_test 44A "zero length read from a sparse stripe"
3869 local nstripe=$($LCTL lov_getconfig $DIR | grep default_stripe_count: |
3871 [ -z "$nstripe" ] && skip "can't get stripe info" && return
3872 [[ $nstripe -gt $OSTCOUNT ]] &&
3873 skip "Wrong default_stripe_count: $nstripe (OSTCOUNT: $OSTCOUNT)" &&
3875 local stride=$($LCTL lov_getconfig $DIR | grep default_stripe_size: |
3877 if [[ $nstripe -eq 0 || $nstripe -eq -1 ]]; then
3878 nstripe=$($LCTL lov_getconfig $DIR | grep obd_count: |
3882 OFFSETS="0 $((stride/2)) $((stride-1))"
3883 for offset in $OFFSETS; do
3884 for i in $(seq 0 $((nstripe-1))); do
3885 local GLOBALOFFSETS=""
3887 local size=$((((i + 2 * $nstripe )*$stride + $offset)))
3888 local myfn=$DIR/d44a-$size
3889 echo "--------writing $myfn at $size"
3890 ll_sparseness_write $myfn $size ||
3891 error "ll_sparseness_write"
3892 GLOBALOFFSETS="$GLOBALOFFSETS $size"
3893 ll_sparseness_verify $myfn $GLOBALOFFSETS ||
3894 error "ll_sparseness_verify $GLOBALOFFSETS"
3896 for j in $(seq 0 $((nstripe-1))); do
3898 size=$((((j + $nstripe )*$stride + $offset)))
3899 ll_sparseness_write $myfn $size ||
3900 error "ll_sparseness_write"
3901 GLOBALOFFSETS="$GLOBALOFFSETS $size"
3903 ll_sparseness_verify $myfn $GLOBALOFFSETS ||
3904 error "ll_sparseness_verify $GLOBALOFFSETS"
3909 run_test 44a "test sparse pwrite ==============================="
3913 for d in `lctl get_param -n osc.*.cur_dirty_bytes`; do
3919 before=`dirty_osc_total`
3920 echo executing "\"$*\""
3922 after=`dirty_osc_total`
3923 echo before $before, after $after
3926 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3928 # Obtain grants from OST if it supports it
3929 echo blah > ${f}_grant
3932 do_dirty_record "echo blah > $f"
3933 [[ $before -eq $after ]] && error "write wasn't cached"
3934 do_dirty_record "> $f"
3935 [[ $before -gt $after ]] || error "truncate didn't lower dirty count"
3936 do_dirty_record "echo blah > $f"
3937 [[ $before -eq $after ]] && error "write wasn't cached"
3938 do_dirty_record "sync"
3939 [[ $before -gt $after ]] || error "writeback didn't lower dirty count"
3940 do_dirty_record "echo blah > $f"
3941 [[ $before -eq $after ]] && error "write wasn't cached"
3942 do_dirty_record "cancel_lru_locks osc"
3943 [[ $before -gt $after ]] ||
3944 error "lock cancellation didn't lower dirty count"
3947 run_test 45 "osc io page accounting ============================"
3949 # in a 2 stripe file (lov.sh), page 1023 maps to page 511 in its object. this
3950 # test tickles a bug where re-dirtying a page was failing to be mapped to the
3951 # objects offset and an assert hit when an rpc was built with 1023's mapped
3952 # offset 511 and 511's raw 511 offset. it also found general redirtying bugs.
3954 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3958 dd if=/dev/zero of=$f bs=`page_size` seek=511 count=1
3960 dd conv=notrunc if=/dev/zero of=$f bs=`page_size` seek=1023 count=1
3961 dd conv=notrunc if=/dev/zero of=$f bs=`page_size` seek=511 count=1
3965 run_test 46 "dirtying a previously written page ================"
3967 # test_47 is removed "Device nodes check" is moved to test_28
3969 test_48a() { # bug 2399
3970 [ $(facet_fstype $SINGLEMDS) = "zfs" ] &&
3971 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.3.63) ] &&
3972 skip "MDS prior to 2.3.63 handle ZFS dir .. incorrectly" &&
3974 test_mkdir $DIR/$tdir
3976 mv $DIR/$tdir $DIR/$tdir.new || error "move directory failed"
3977 test_mkdir $DIR/$tdir || error "recreate directory failed"
3978 touch foo || error "'touch foo' failed after recreating cwd"
3979 test_mkdir bar || error "'mkdir foo' failed after recreating cwd"
3980 touch .foo || error "'touch .foo' failed after recreating cwd"
3981 test_mkdir .bar || error "'mkdir .foo' failed after recreating cwd"
3982 ls . > /dev/null || error "'ls .' failed after recreating cwd"
3983 ls .. > /dev/null || error "'ls ..' failed after removing cwd"
3984 cd . || error "'cd .' failed after recreating cwd"
3985 test_mkdir . && error "'mkdir .' worked after recreating cwd"
3986 rmdir . && error "'rmdir .' worked after recreating cwd"
3987 ln -s . baz || error "'ln -s .' failed after recreating cwd"
3988 cd .. || error "'cd ..' failed after recreating cwd"
3990 run_test 48a "Access renamed working dir (should return errors)="
3992 test_48b() { # bug 2399
3994 test_mkdir $DIR/$tdir
3996 rmdir $DIR/$tdir || error "remove cwd $DIR/$tdir failed"
3997 touch foo && error "'touch foo' worked after removing cwd"
3998 test_mkdir foo && error "'mkdir foo' worked after removing cwd"
3999 touch .foo && error "'touch .foo' worked after removing cwd"
4000 test_mkdir .foo && error "'mkdir .foo' worked after removing cwd"
4001 ls . > /dev/null && error "'ls .' worked after removing cwd"
4002 ls .. > /dev/null || error "'ls ..' failed after removing cwd"
4003 test_mkdir . && error "'mkdir .' worked after removing cwd"
4004 rmdir . && error "'rmdir .' worked after removing cwd"
4005 ln -s . foo && error "'ln -s .' worked after removing cwd"
4006 cd .. || echo "'cd ..' failed after removing cwd `pwd`" #bug 3517
4008 run_test 48b "Access removed working dir (should return errors)="
4010 test_48c() { # bug 2350
4011 #lctl set_param debug=-1
4014 test_mkdir -p $DIR/$tdir/dir
4016 $TRACE rmdir $DIR/$tdir/dir || error "remove cwd $DIR/$tdir/dir failed"
4017 $TRACE touch foo && error "touch foo worked after removing cwd"
4018 $TRACE test_mkdir foo && error "'mkdir foo' worked after removing cwd"
4019 touch .foo && error "touch .foo worked after removing cwd"
4020 test_mkdir .foo && error "mkdir .foo worked after removing cwd"
4021 $TRACE ls . && error "'ls .' worked after removing cwd"
4022 $TRACE ls .. || error "'ls ..' failed after removing cwd"
4023 $TRACE test_mkdir . && error "'mkdir .' worked after removing cwd"
4024 $TRACE rmdir . && error "'rmdir .' worked after removing cwd"
4025 $TRACE ln -s . foo && error "'ln -s .' worked after removing cwd"
4026 $TRACE cd .. || echo "'cd ..' failed after removing cwd `pwd`" #bug 3415
4028 run_test 48c "Access removed working subdir (should return errors)"
4030 test_48d() { # bug 2350
4031 #lctl set_param debug=-1
4034 test_mkdir -p $DIR/$tdir/dir
4036 $TRACE rmdir $DIR/$tdir/dir || error "remove cwd $DIR/$tdir/dir failed"
4037 $TRACE rmdir $DIR/$tdir || error "remove parent $DIR/$tdir failed"
4038 $TRACE touch foo && error "'touch foo' worked after removing parent"
4039 $TRACE test_mkdir foo && error "mkdir foo worked after removing parent"
4040 touch .foo && error "'touch .foo' worked after removing parent"
4041 test_mkdir .foo && error "mkdir .foo worked after removing parent"
4042 $TRACE ls . && error "'ls .' worked after removing parent"
4043 $TRACE ls .. && error "'ls ..' worked after removing parent"
4044 $TRACE test_mkdir . && error "'mkdir .' worked after removing parent"
4045 $TRACE rmdir . && error "'rmdir .' worked after removing parent"
4046 $TRACE ln -s . foo && error "'ln -s .' worked after removing parent"
4049 run_test 48d "Access removed parent subdir (should return errors)"
4051 test_48e() { # bug 4134
4052 #lctl set_param debug=-1
4055 test_mkdir -p $DIR/$tdir/dir
4057 $TRACE rmdir $DIR/$tdir/dir || error "remove cwd $DIR/$tdir/dir failed"
4058 $TRACE rmdir $DIR/$tdir || error "remove parent $DIR/$tdir failed"
4059 $TRACE touch $DIR/$tdir || error "'touch $DIR/$tdir' failed"
4060 $TRACE chmod +x $DIR/$tdir || error "'chmod +x $DIR/$tdir' failed"
4061 # On a buggy kernel addition of "touch foo" after cd .. will
4062 # produce kernel oops in lookup_hash_it
4063 touch ../foo && error "'cd ..' worked after recreate parent"
4065 $TRACE rm $DIR/$tdir || error "rm '$DIR/$tdir' failed"
4067 run_test 48e "Access to recreated parent subdir (should return errors)"
4069 test_49() { # LU-1030
4070 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4071 remote_ost_nodsh && skip "remote OST with nodsh" && return
4072 # get ost1 size - lustre-OST0000
4073 ost1_size=$(do_facet ost1 $LFS df | grep ${ost1_svc} |
4075 # write 800M at maximum
4076 [[ $ost1_size -lt 2 ]] && ost1_size=2
4077 [[ $ost1_size -gt 819200 ]] && ost1_size=819200
4079 $SETSTRIPE -c 1 -i 0 $DIR/$tfile
4080 dd if=/dev/zero of=$DIR/$tfile bs=4k count=$((ost1_size >> 2)) &
4083 # change max_pages_per_rpc while writing the file
4084 local osc1_mppc=osc.$(get_osc_import_name client ost1).max_pages_per_rpc
4085 local orig_mppc=$($LCTL get_param -n $osc1_mppc)
4086 # loop until dd process exits
4087 while ps ax -opid | grep -wq $dd_pid; do
4088 $LCTL set_param $osc1_mppc=$((RANDOM % 256 + 1))
4089 sleep $((RANDOM % 5 + 1))
4091 # restore original max_pages_per_rpc
4092 $LCTL set_param $osc1_mppc=$orig_mppc
4093 rm $DIR/$tfile || error "rm $DIR/$tfile failed"
4095 run_test 49 "Change max_pages_per_rpc won't break osc extent"
4099 test_mkdir $DIR/$tdir
4101 ls /proc/$$/cwd || error "ls /proc/$$/cwd failed"
4103 run_test 50 "special situations: /proc symlinks ==============="
4105 test_51a() { # was test_51
4106 # bug 1516 - create an empty entry right after ".." then split dir
4107 test_mkdir -c1 $DIR/$tdir
4108 touch $DIR/$tdir/foo
4109 $MCREATE $DIR/$tdir/bar
4111 createmany -m $DIR/$tdir/longfile 201
4113 while [[ $(ls -sd $DIR/$tdir | awk '{ print $1 }') -eq 4 ]]; do
4114 $MCREATE $DIR/$tdir/longfile$FNUM
4119 ls -l $DIR/$tdir > /dev/null || error "ls -l $DIR/$tdir failed"
4121 run_test 51a "special situations: split htree with empty entry =="
4123 cleanup_print_lfs_df () {
4130 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4131 local dir=$DIR/$tdir
4133 local nrdirs=$((65536 + 100))
4135 # cleanup the directory
4138 test_mkdir -p -c1 $dir
4142 local mdtidx=$(printf "%04x" $($LFS getstripe -M $dir))
4143 local numfree=$(lctl get_param -n mdc.$FSNAME-MDT$mdtidx*.filesfree)
4144 [[ $numfree -lt $nrdirs ]] &&
4145 skip "not enough free inodes ($numfree) on MDT$mdtidx" &&
4148 # need to check free space for the directories as well
4149 local blkfree=$(lctl get_param -n mdc.$FSNAME-MDT$mdtidx*.kbytesavail)
4150 numfree=$(( blkfree / $(fs_inode_ksize) ))
4151 [[ $numfree -lt $nrdirs ]] && skip "not enough blocks ($numfree)" &&
4154 trap cleanup_print_lfsdf EXIT
4157 createmany -d $dir/d $nrdirs ||
4158 error "failed to create $nrdirs subdirs in MDT$mdtidx:$dir"
4161 nrdirs=$(ls -U $dir | wc -l)
4163 # unlink all but 100 subdirectories, then check it still works
4165 local delete=$((nrdirs - left))
4170 # for ldiskfs the nlink count should be 1, but this is OSD specific
4171 # and so this is listed for informational purposes only
4172 echo "nlink before: $(stat -c %h $dir), created before: $nrdirs"
4173 unlinkmany -d $dir/d $delete ||
4174 error "unlink of first $delete subdirs failed"
4176 echo "nlink between: $(stat -c %h $dir)"
4177 local found=$(ls -U $dir | wc -l)
4178 [ $found -ne $left ] &&
4179 error "can't find subdirs: found only $found, expected $left"
4181 unlinkmany -d $dir/d $delete $left ||
4182 error "unlink of second $left subdirs failed"
4183 # regardless of whether the backing filesystem tracks nlink accurately
4184 # or not, the nlink count shouldn't be more than "." and ".." here
4185 local after=$(stat -c %h $dir)
4186 [[ $after -gt 2 ]] && error "nlink after: $after > 2" ||
4187 echo "nlink after: $after"
4189 cleanup_print_lfs_df
4191 run_test 51b "exceed 64k subdirectory nlink limit on create, verify unlink"
4194 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4195 [[ $OSTCOUNT -lt 3 ]] &&
4196 skip_env "skipping test with few OSTs" && return
4197 test_mkdir -p $DIR/$tdir
4198 createmany -o $DIR/$tdir/t- 1000
4199 $GETSTRIPE $DIR/$tdir > $TMP/$tfile
4200 for N in $(seq 0 $((OSTCOUNT - 1))); do
4201 OBJS[$N]=$(awk -vobjs=0 '($1 == '$N') { objs += 1 } \
4202 END { printf("%0.0f", objs) }' $TMP/$tfile)
4203 OBJS0[$N]=$(grep -A 1 idx $TMP/$tfile | awk -vobjs=0 \
4204 '($1 == '$N') { objs += 1 } \
4205 END { printf("%0.0f", objs) }')
4206 log "OST$N has ${OBJS[$N]} objects, ${OBJS0[$N]} are index 0"
4208 unlinkmany $DIR/$tdir/t- 1000
4211 for N in $(seq 1 $((OSTCOUNT - 1))); do
4212 [[ ${OBJS[$N]} -lt $((${OBJS[$NLAST]} - 20)) ]] &&
4213 error "OST $N has less objects vs OST $NLAST" \
4214 " (${OBJS[$N]} < ${OBJS[$NLAST]}"
4215 [[ ${OBJS[$N]} -gt $((${OBJS[$NLAST]} + 20)) ]] &&
4216 error "OST $N has less objects vs OST $NLAST" \
4217 " (${OBJS[$N]} < ${OBJS[$NLAST]}"
4219 [[ ${OBJS0[$N]} -lt $((${OBJS0[$NLAST]} - 20)) ]] &&
4220 error "OST $N has less #0 objects vs OST $NLAST" \
4221 " (${OBJS0[$N]} < ${OBJS0[$NLAST]}"
4222 [[ ${OBJS0[$N]} -gt $((${OBJS0[$NLAST]} + 20)) ]] &&
4223 error "OST $N has less #0 objects vs OST $NLAST" \
4224 " (${OBJS0[$N]} < ${OBJS0[$NLAST]}"
4229 run_test 51d "check object distribution"
4232 if [ "$(facet_fstype $SINGLEMDS)" != ldiskfs ]; then
4233 skip "Only applicable to ldiskfs-based MDTs"
4237 test_mkdir -c1 $DIR/$tdir || error "create $tdir failed"
4238 test_mkdir -c1 $DIR/$tdir/d0 || error "create d0 failed"
4240 touch $DIR/$tdir/d0/foo
4241 createmany -l $DIR/$tdir/d0/foo $DIR/$tdir/d0/f- 65001 &&
4242 error "file exceed 65000 nlink limit!"
4243 unlinkmany $DIR/$tdir/d0/f- 65001
4246 run_test 51e "check file nlink limit"
4249 test_mkdir $DIR/$tdir
4252 local ulimit_old=$(ulimit -n)
4253 local spare=20 # number of spare fd's for scripts/libraries, etc.
4254 local mdt=$(lfs getstripe -M $DIR/$tdir)
4255 local numfree=$(lfs df -i $DIR/$tdir | awk '/MDT:'$mdt'/ { print $4 }')
4257 echo "MDT$mdt numfree=$numfree, max=$max"
4258 [[ $numfree -gt $max ]] && numfree=$max || numfree=$((numfree * 7 / 8))
4259 if [ $((numfree + spare)) -gt $ulimit_old ]; then
4260 while ! ulimit -n $((numfree + spare)); do
4261 numfree=$((numfree * 3 / 4))
4263 echo "changed ulimit from $ulimit_old to $((numfree + spare))"
4265 echo "left ulimit at $ulimit_old"
4268 createmany -o -k -t 120 $DIR/$tdir/f $numfree ||
4269 error "create+open $numfree files in $DIR/$tdir failed"
4270 ulimit -n $ulimit_old
4272 # if createmany exits at 120s there will be fewer than $numfree files
4273 unlinkmany $DIR/$tdir/f $numfree || true
4275 run_test 51f "check many open files limit"
4278 [ -f $DIR/$tdir/foo ] && chattr -a $DIR/$tdir/foo
4279 test_mkdir -p $DIR/$tdir
4280 touch $DIR/$tdir/foo
4281 chattr +a $DIR/$tdir/foo || error "chattr +a failed"
4282 echo bar >> $DIR/$tdir/foo || error "append bar failed"
4283 cp /etc/hosts $DIR/$tdir/foo && error "cp worked"
4284 rm -f $DIR/$tdir/foo 2>/dev/null && error "rm worked"
4285 link $DIR/$tdir/foo $DIR/$tdir/foo_link 2>/dev/null &&
4287 echo foo >> $DIR/$tdir/foo || error "append foo failed"
4288 mrename $DIR/$tdir/foo $DIR/$tdir/foo_ren && error "rename worked"
4289 lsattr $DIR/$tdir/foo | egrep -q "^-+a[-e]+ $DIR/$tdir/foo" ||
4291 chattr -a $DIR/$tdir/foo || error "chattr -a failed"
4292 cp -r $DIR/$tdir $TMP/
4293 rm -fr $DIR/$tdir $TMP/$tdir || error "cleanup rm failed"
4295 run_test 52a "append-only flag test (should return errors)"
4298 [ -f $DIR/$tdir/foo ] && chattr -i $DIR/$tdir/foo
4299 test_mkdir -p $DIR/$tdir
4300 touch $DIR/$tdir/foo
4301 chattr +i $DIR/$tdir/foo || error "chattr +i failed"
4302 cat test > $DIR/$tdir/foo && error "cat test worked"
4303 cp /etc/hosts $DIR/$tdir/foo && error "cp worked"
4304 rm -f $DIR/$tdir/foo 2>/dev/null && error "rm worked"
4305 link $DIR/$tdir/foo $DIR/$tdir/foo_link 2>/dev/null &&
4307 echo foo >> $DIR/$tdir/foo && error "echo worked"
4308 mrename $DIR/$tdir/foo $DIR/$tdir/foo_ren && error "rename worked"
4309 [ -f $DIR/$tdir/foo ] || error "$tdir/foo is not a file"
4310 [ -f $DIR/$tdir/foo_ren ] && error "$tdir/foo_ren is not a file"
4311 lsattr $DIR/$tdir/foo | egrep -q "^-+i[-e]+ $DIR/$tdir/foo" ||
4313 chattr -i $DIR/$tdir/foo || error "chattr failed"
4315 rm -fr $DIR/$tdir || error "unable to remove $DIR/$tdir"
4317 run_test 52b "immutable flag test (should return errors) ======="
4320 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4321 remote_mds_nodsh && skip "remote MDS with nodsh" && return
4322 remote_ost_nodsh && skip "remote OST with nodsh" && return
4335 local support_last_seq=true
4337 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.3.60) ]] ||
4338 support_last_seq=false
4341 local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS)
4343 for value in $(do_facet $SINGLEMDS \
4344 $LCTL get_param osc.$mdtosc.prealloc_last_id) ; do
4345 param=$(echo ${value[0]} | cut -d "=" -f1)
4346 ostname=$(echo $param | cut -d "." -f2 | cut -d - -f 1-2)
4348 if $support_last_seq; then
4349 param_seq=$(echo $param |
4350 sed -e s/prealloc_last_id/prealloc_last_seq/g)
4351 mds_last_seq=$(do_facet $SINGLEMDS \
4352 $LCTL get_param -n $param_seq)
4354 mds_last=$(do_facet $SINGLEMDS $LCTL get_param -n $param)
4356 ostnum=$(index_from_ostuuid ${ostname}_UUID)
4357 node=$(facet_active_host ost$((ostnum+1)))
4358 param="obdfilter.$ostname.last_id"
4359 for ost_last in $(do_node $node $LCTL get_param -n $param) ; do
4360 echo "$ostname.last_id=$ost_last; MDS.last_id=$mds_last"
4361 ost_last_id=$ost_last
4363 if $support_last_seq; then
4364 ost_last_id=$(echo $ost_last |
4365 awk -F':' '{print $2}' |
4367 ost_last_seq=$(echo $ost_last |
4368 awk -F':' '{print $1}')
4369 [[ $ost_last_seq = $mds_last_seq ]] || continue
4372 if [[ $ost_last_id != $mds_last ]]; then
4373 error "$ost_last_id != $mds_last"
4380 $found || error "can not match last_seq/last_id for $mdtosc"
4383 run_test 53 "verify that MDS and OSTs agree on pre-creation ===="
4386 $SOCKETSERVER $DIR/socket ||
4387 error "$SOCKETSERVER $DIR/socket failed: $?"
4388 $SOCKETCLIENT $DIR/socket ||
4389 error "$SOCKETCLIENT $DIR/socket failed: $?"
4390 $MUNLINK $DIR/socket || error "$MUNLINK $DIR/socket failed: $?"
4392 run_test 54a "unix domain socket test =========================="
4398 dd if=/dev/zero of=$f bs=$(page_size) count=1
4400 run_test 54b "char device works in lustre ======================"
4403 [ -b /dev/loop/0 ] && LOOPBASE=/dev/loop/
4404 [ -b /dev/loop0 ] && LOOPBASE=/dev/loop
4405 [ -z "$LOOPBASE" ] && echo "/dev/loop/0 and /dev/loop0 gone?" && return
4407 for i in $(seq 3 7); do
4408 losetup $LOOPBASE$i > /dev/null 2>&1 && continue
4417 loopdev="$DIR/loop54c"
4420 $UMOUNT $DIR/$tdir || rc=$?
4421 losetup -d $loopdev || true
4422 losetup -d $LOOPDEV || true
4423 rm -rf $loopdev $DIR/$tfile $DIR/$tdir
4428 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4429 loopdev="$DIR/loop54c"
4432 [ -z "$LOOPNUM" ] && echo "couldn't find empty loop device" && return
4433 trap cleanup_54c EXIT
4434 mknod $loopdev b 7 $LOOPNUM
4435 echo "make a loop file system with $DIR/$tfile on $loopdev ($LOOPNUM)."
4436 dd if=/dev/zero of=$DIR/$tfile bs=$(get_page_size client) seek=1024 count=1 > /dev/null
4437 losetup $loopdev $DIR/$tfile ||
4438 error "can't set up $loopdev for $DIR/$tfile"
4439 mkfs.ext2 $loopdev || error "mke2fs on $loopdev"
4440 test_mkdir -p $DIR/$tdir
4441 mount -t ext2 $loopdev $DIR/$tdir ||
4442 error "error mounting $loopdev on $DIR/$tdir"
4443 dd if=/dev/zero of=$DIR/$tdir/tmp bs=$(get_page_size client) count=30 ||
4446 dd if=$DIR/$tdir/tmp of=/dev/zero bs=$(get_page_size client) count=30 ||
4450 run_test 54c "block device works in lustre ====================="
4456 [ "$string" = $(echo $string > $f | cat $f) ] || error "$f != $string"
4458 run_test 54d "fifo device works in lustre ======================"
4463 cp -aL /dev/console $f
4464 echo $string > $f || error "echo $string to $f failed"
4466 run_test 54e "console/tty device works in lustre ======================"
4468 #The test_55 used to be iopen test and it was removed by bz#24037.
4469 #run_test 55 "check iopen_connect_dentry() ======================"
4471 test_56a() { # was test_56
4474 test_mkdir -p $DIR/$tdir/dir
4476 NUMFILESx2=$(($NUMFILES * 2))
4477 for i in $(seq 1 $NUMFILES); do
4478 touch $DIR/$tdir/file$i
4479 touch $DIR/$tdir/dir/file$i
4482 # test lfs getstripe with --recursive
4483 FILENUM=$($GETSTRIPE --recursive $DIR/$tdir | grep -c obdidx)
4484 [[ $FILENUM -eq $NUMFILESx2 ]] ||
4485 error "$GETSTRIPE --recursive: found $FILENUM, not $NUMFILESx2"
4486 FILENUM=$($GETSTRIPE $DIR/$tdir | grep -c obdidx)
4487 [[ $FILENUM -eq $NUMFILES ]] ||
4488 error "$GETSTRIPE $DIR/$tdir: found $FILENUM, not $NUMFILES"
4489 echo "$GETSTRIPE --recursive passed."
4491 # test lfs getstripe with file instead of dir
4492 FILENUM=$($GETSTRIPE $DIR/$tdir/file1 | grep -c obdidx)
4493 [[ $FILENUM -eq 1 ]] ||
4494 error "$GETSTRIPE $DIR/$tdir/file1: found $FILENUM, not 1"
4495 echo "$GETSTRIPE file1 passed."
4497 #test lfs getstripe with --verbose
4498 [[ $($GETSTRIPE --verbose $DIR/$tdir |
4499 grep -c lmm_magic) -eq $NUMFILES ]] ||
4500 error "$GETSTRIPE --verbose $DIR/$tdir: want $NUMFILES"
4501 [[ $($GETSTRIPE $DIR/$tdir | grep -c lmm_magic) -eq 0 ]] ||
4502 error "$GETSTRIPE $DIR/$tdir: showed lmm_magic"
4504 #test lfs getstripe with -v prints lmm_fid
4505 [[ $($GETSTRIPE -v $DIR/$tdir | grep -c lmm_fid) -eq $NUMFILES ]] ||
4506 error "$GETSTRIPE -v $DIR/$tdir: want $NUMFILES lmm_fid: lines"
4507 [[ $($GETSTRIPE $DIR/$tdir | grep -c lmm_fid) -eq 0 ]] ||
4508 error "$GETSTRIPE $DIR/$tdir: showed lmm_fid"
4509 echo "$GETSTRIPE --verbose passed."
4511 #check for FID information
4512 local fid1=$($GETSTRIPE --fid $DIR/$tdir/file1)
4513 local fid2=$($GETSTRIPE --verbose $DIR/$tdir/file1 |
4514 awk '/lmm_fid: / { print $2 }')
4515 local fid3=$($LFS path2fid $DIR/$tdir/file1)
4516 [ "$fid1" != "$fid2" ] &&
4517 error "getstripe --fid $fid1 != getstripe --verbose $fid2"
4518 [ "$fid1" != "$fid3" ] &&
4519 error "getstripe --fid $fid1 != lfs path2fid $fid3"
4520 echo "$GETSTRIPE --fid passed."
4522 #test lfs getstripe with --obd
4523 $GETSTRIPE --obd wrong_uuid $DIR/$tdir 2>&1 |
4524 grep -q "unknown obduuid" ||
4525 error "$GETSTRIPE --obd wrong_uuid should return error message"
4527 [[ $OSTCOUNT -lt 2 ]] &&
4528 skip_env "skipping other $GETSTRIPE --obd test" && return
4531 OBDUUID=$(ostuuid_from_index $OSTIDX)
4532 FILENUM=$($GETSTRIPE -ir $DIR/$tdir | grep "^$OSTIDX\$" | wc -l)
4533 FOUND=$($GETSTRIPE -r --obd $OBDUUID $DIR/$tdir | grep obdidx | wc -l)
4534 [[ $FOUND -eq $FILENUM ]] ||
4535 error "$GETSTRIPE --obd wrong: found $FOUND, expected $FILENUM"
4536 [[ $($GETSTRIPE -r -v --obd $OBDUUID $DIR/$tdir |
4537 sed '/^[ ]*'${OSTIDX}'[ ]/d' |
4538 sed -n '/^[ ]*[0-9][0-9]*[ ]/p' | wc -l) -eq 0 ]] ||
4539 error "$GETSTRIPE --obd: should not show file on other obd"
4540 echo "$GETSTRIPE --obd passed"
4542 run_test 56a "check $GETSTRIPE"
4545 test_mkdir $DIR/$tdir
4547 for i in $(seq 1 $NUMDIRS); do
4548 test_mkdir $DIR/$tdir/dir$i
4551 # test lfs getdirstripe default mode is non-recursion, which is
4552 # different from lfs getstripe
4553 dircnt=$($LFS getdirstripe $DIR/$tdir | grep -c lmv_stripe_count)
4554 [[ $dircnt -eq 1 ]] ||
4555 error "$LFS getdirstripe: found $dircnt, not 1"
4556 dircnt=$($LFS getdirstripe --recursive $DIR/$tdir |
4557 grep -c lmv_stripe_count)
4558 [[ $dircnt -eq $((NUMDIRS + 1)) ]] ||
4559 error "$LFS getdirstripe --recursive: found $dircnt, \
4560 not $((NUMDIRS + 1))"
4562 run_test 56b "check $LFS getdirstripe"
4566 local ost_name=$(ostname_from_index $ost_idx)
4568 local old_status=$(ost_dev_status $ost_idx)
4569 [[ -z "$old_status" ]] ||
4570 { skip_env "OST $ost_name is in $old_status status"; return 0; }
4572 do_facet ost1 $LCTL set_param -n obdfilter.$ost_name.degraded=1
4575 local new_status=$(ost_dev_status $ost_idx)
4576 [[ "$new_status" = "D" ]] ||
4577 error "OST $ost_name is in status of '$new_status', not 'D'"
4579 do_facet ost1 $LCTL set_param -n obdfilter.$ost_name.degraded=0
4582 new_status=$(ost_dev_status $ost_idx)
4583 [[ -z "$new_status" ]] ||
4584 error "OST $ost_name is in status of '$new_status', not ''"
4586 run_test 56c "check 'lfs df' showing device status"
4591 local LOCAL_NUMFILES="$1"
4592 local LOCAL_NUMDIRS="$2"
4593 local MKDIR_PARAMS="$3"
4594 local DIR_STRIPE_PARAMS="$4"
4596 if [ ! -d "$TDIR" ] ; then
4597 test_mkdir -p $DIR_STRIPE_PARAMS $TDIR
4598 [ "$MKDIR_PARAMS" ] && $SETSTRIPE $MKDIR_PARAMS $TDIR
4599 for i in `seq 1 $LOCAL_NUMFILES` ; do
4602 for i in `seq 1 $LOCAL_NUMDIRS` ; do
4603 test_mkdir $DIR_STRIPE_PARAMS $TDIR/dir$i
4604 for j in `seq 1 $LOCAL_NUMFILES` ; do
4605 touch $TDIR/dir$i/file$j
4611 setup_56_special() {
4615 if [ ! -e "$TDIR/loop1b" ] ; then
4616 for i in `seq 1 $LOCAL_NUMFILES` ; do
4617 mknod $TDIR/loop${i}b b 7 $i
4618 mknod $TDIR/null${i}c c 1 3
4619 ln -s $TDIR/file1 $TDIR/link${i}l
4621 for i in `seq 1 $LOCAL_NUMDIRS` ; do
4622 mknod $TDIR/dir$i/loop${i}b b 7 $i
4623 mknod $TDIR/dir$i/null${i}c c 1 3
4624 ln -s $TDIR/dir$i/file1 $TDIR/dir$i/link${i}l
4633 setup_56 $NUMFILES $NUMDIRS
4635 EXPECTED=$(($NUMDIRS + 2))
4636 # test lfs find with -name
4637 for i in $(seq 1 $NUMFILES) ; do
4638 NUMS=$($LFIND -name "*$i" $TDIR | wc -l)
4639 [ $NUMS -eq $EXPECTED ] ||
4640 error "lfs find -name \"*$i\" $TDIR wrong: "\
4641 "found $NUMS, expected $EXPECTED"
4644 run_test 56g "check lfs find -name ============================="
4650 setup_56 $NUMFILES $NUMDIRS
4652 EXPECTED=$(((NUMDIRS + 1) * (NUMFILES - 1) + NUMFILES))
4653 # test lfs find with ! -name
4654 for i in $(seq 1 $NUMFILES) ; do
4655 NUMS=$($LFIND ! -name "*$i" $TDIR | wc -l)
4656 [ $NUMS -eq $EXPECTED ] ||
4657 error "lfs find ! -name \"*$i\" $TDIR wrong: "\
4658 "found $NUMS, expected $EXPECTED"
4661 run_test 56h "check lfs find ! -name ============================="
4665 test_mkdir -p $DIR/$tdir
4666 UUID=$(ostuuid_from_index 0 $DIR/$tdir)
4667 CMD="$LFIND -ost $UUID $DIR/$tdir"
4669 [ -z "$OUT" ] || error "\"$CMD\" returned directory '$OUT'"
4671 run_test 56i "check 'lfs find -ost UUID' skips directories ======="
4675 setup_56_special $NUMFILES $NUMDIRS
4677 EXPECTED=$((NUMDIRS + 1))
4678 CMD="$LFIND -type d $TDIR"
4679 NUMS=$($CMD | wc -l)
4680 [ $NUMS -eq $EXPECTED ] ||
4681 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4683 run_test 56j "check lfs find -type d ============================="
4687 setup_56_special $NUMFILES $NUMDIRS
4689 EXPECTED=$(((NUMDIRS + 1) * NUMFILES))
4690 CMD="$LFIND -type f $TDIR"
4691 NUMS=$($CMD | wc -l)
4692 [ $NUMS -eq $EXPECTED ] ||
4693 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4695 run_test 56k "check lfs find -type f ============================="
4699 setup_56_special $NUMFILES $NUMDIRS
4701 EXPECTED=$((NUMDIRS + NUMFILES))
4702 CMD="$LFIND -type b $TDIR"
4703 NUMS=$($CMD | wc -l)
4704 [ $NUMS -eq $EXPECTED ] ||
4705 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4707 run_test 56l "check lfs find -type b ============================="
4711 setup_56_special $NUMFILES $NUMDIRS
4713 EXPECTED=$((NUMDIRS + NUMFILES))
4714 CMD="$LFIND -type c $TDIR"
4715 NUMS=$($CMD | wc -l)
4716 [ $NUMS -eq $EXPECTED ] ||
4717 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4719 run_test 56m "check lfs find -type c ============================="
4723 setup_56_special $NUMFILES $NUMDIRS
4725 EXPECTED=$((NUMDIRS + NUMFILES))
4726 CMD="$LFIND -type l $TDIR"
4727 NUMS=$($CMD | wc -l)
4728 [ $NUMS -eq $EXPECTED ] ||
4729 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4731 run_test 56n "check lfs find -type l ============================="
4735 setup_56 $NUMFILES $NUMDIRS
4736 utime $TDIR/file1 > /dev/null || error "utime (1)"
4737 utime $TDIR/file2 > /dev/null || error "utime (2)"
4738 utime $TDIR/dir1 > /dev/null || error "utime (3)"
4739 utime $TDIR/dir2 > /dev/null || error "utime (4)"
4740 utime $TDIR/dir1/file1 > /dev/null || error "utime (5)"
4741 dd if=/dev/zero count=1 >> $TDIR/dir1/file1 && sync
4744 NUMS=`$LFIND -mtime +0 $TDIR | wc -l`
4745 [ $NUMS -eq $EXPECTED ] || \
4746 error "lfs find -mtime +0 $TDIR wrong: found $NUMS, expected $EXPECTED"
4749 CMD="$LFIND -mtime 0 $TDIR"
4750 NUMS=$($CMD | wc -l)
4751 [ $NUMS -eq $EXPECTED ] ||
4752 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4754 run_test 56o "check lfs find -mtime for old files =========================="
4757 [ $RUNAS_ID -eq $UID ] &&
4758 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
4761 setup_56 $NUMFILES $NUMDIRS
4763 chown $RUNAS_ID $TDIR/file* || error "chown $DIR/${tdir}g/file$i failed"
4765 CMD="$LFIND -uid $RUNAS_ID $TDIR"
4766 NUMS=$($CMD | wc -l)
4767 [ $NUMS -eq $EXPECTED ] || \
4768 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4770 EXPECTED=$(((NUMFILES + 1) * NUMDIRS + 1))
4771 CMD="$LFIND ! -uid $RUNAS_ID $TDIR"
4772 NUMS=$($CMD | wc -l)
4773 [ $NUMS -eq $EXPECTED ] || \
4774 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4776 run_test 56p "check lfs find -uid and ! -uid ==============================="
4779 [ $RUNAS_ID -eq $UID ] &&
4780 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
4783 setup_56 $NUMFILES $NUMDIRS
4785 chgrp $RUNAS_GID $TDIR/file* || error "chown $TDIR/file$i failed"
4788 CMD="$LFIND -gid $RUNAS_GID $TDIR"
4789 NUMS=$($CMD | wc -l)
4790 [ $NUMS -eq $EXPECTED ] ||
4791 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4793 EXPECTED=$(( ($NUMFILES+1) * $NUMDIRS + 1))
4794 CMD="$LFIND ! -gid $RUNAS_GID $TDIR"
4795 NUMS=$($CMD | wc -l)
4796 [ $NUMS -eq $EXPECTED ] ||
4797 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4799 run_test 56q "check lfs find -gid and ! -gid ==============================="
4803 setup_56 $NUMFILES $NUMDIRS
4806 CMD="$LFIND -size 0 -type f $TDIR"
4807 NUMS=$($CMD | wc -l)
4808 [ $NUMS -eq $EXPECTED ] ||
4809 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4811 CMD="$LFIND ! -size 0 -type f $TDIR"
4812 NUMS=$($CMD | wc -l)
4813 [ $NUMS -eq $EXPECTED ] ||
4814 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4815 echo "test" > $TDIR/$tfile
4816 echo "test2" > $TDIR/$tfile.2 && sync
4818 CMD="$LFIND -size 5 -type f $TDIR"
4819 NUMS=$($CMD | wc -l)
4820 [ $NUMS -eq $EXPECTED ] ||
4821 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4823 CMD="$LFIND -size +5 -type f $TDIR"
4824 NUMS=$($CMD | wc -l)
4825 [ $NUMS -eq $EXPECTED ] ||
4826 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4828 CMD="$LFIND -size +0 -type f $TDIR"
4829 NUMS=$($CMD | wc -l)
4830 [ $NUMS -eq $EXPECTED ] ||
4831 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4833 CMD="$LFIND ! -size -5 -type f $TDIR"
4834 NUMS=$($CMD | wc -l)
4835 [ $NUMS -eq $EXPECTED ] ||
4836 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4838 CMD="$LFIND -size -5 -type f $TDIR"
4839 NUMS=$($CMD | wc -l)
4840 [ $NUMS -eq $EXPECTED ] ||
4841 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4843 run_test 56r "check lfs find -size works =========================="
4845 test_56s() { # LU-611
4847 setup_56 $NUMFILES $NUMDIRS "-c $OSTCOUNT"
4849 if [[ $OSTCOUNT -gt 1 ]]; then
4850 $SETSTRIPE -c 1 $TDIR/$tfile.{0,1,2,3}
4854 ONESTRIPE=$(((NUMDIRS + 1) * NUMFILES))
4858 EXPECTED=$(((NUMDIRS + 1) * NUMFILES))
4859 CMD="$LFIND -stripe-count $OSTCOUNT -type f $TDIR"
4860 NUMS=$($CMD | wc -l)
4861 [ $NUMS -eq $EXPECTED ] || {
4863 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4866 EXPECTED=$(((NUMDIRS + 1) * NUMFILES + EXTRA))
4867 CMD="$LFIND -stripe-count +0 -type f $TDIR"
4868 NUMS=$($CMD | wc -l)
4869 [ $NUMS -eq $EXPECTED ] || {
4871 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4875 CMD="$LFIND -stripe-count 1 -type f $TDIR"
4876 NUMS=$($CMD | wc -l)
4877 [ $NUMS -eq $EXPECTED ] || {
4879 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4882 CMD="$LFIND -stripe-count -2 -type f $TDIR"
4883 NUMS=$($CMD | wc -l)
4884 [ $NUMS -eq $EXPECTED ] || {
4886 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4890 CMD="$LFIND -stripe-count $((OSTCOUNT + 1)) -type f $TDIR"
4891 NUMS=$($CMD | wc -l)
4892 [ $NUMS -eq $EXPECTED ] || {
4894 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4897 run_test 56s "check lfs find -stripe-count works"
4899 test_56t() { # LU-611
4901 setup_56 $NUMFILES $NUMDIRS "--stripe-size 512k"
4903 $SETSTRIPE -S 256k $TDIR/$tfile.{0,1,2,3}
4905 EXPECTED=$(((NUMDIRS + 1) * NUMFILES))
4906 CMD="$LFIND -stripe-size 512k -type f $TDIR"
4907 NUMS=$($CMD | wc -l)
4908 [ $NUMS -eq $EXPECTED ] ||
4909 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4911 CMD="$LFIND -stripe-size +320k -type f $TDIR"
4912 NUMS=$($CMD | wc -l)
4913 [ $NUMS -eq $EXPECTED ] ||
4914 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4916 EXPECTED=$(((NUMDIRS + 1) * NUMFILES + 4))
4917 CMD="$LFIND -stripe-size +200k -type f $TDIR"
4918 NUMS=$($CMD | wc -l)
4919 [ $NUMS -eq $EXPECTED ] ||
4920 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4922 CMD="$LFIND -stripe-size -640k -type f $TDIR"
4923 NUMS=$($CMD | wc -l)
4924 [ $NUMS -eq $EXPECTED ] ||
4925 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4928 CMD="$LFIND -stripe-size 256k -type f $TDIR"
4929 NUMS=$($CMD | wc -l)
4930 [ $NUMS -eq $EXPECTED ] ||
4931 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4933 CMD="$LFIND -stripe-size -320k -type f $TDIR"
4934 NUMS=$($CMD | wc -l)
4935 [ $NUMS -eq $EXPECTED ] ||
4936 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4939 CMD="$LFIND -stripe-size 1024k -type f $TDIR"
4940 NUMS=$($CMD | wc -l)
4941 [ $NUMS -eq $EXPECTED ] ||
4942 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4944 run_test 56t "check lfs find -stripe-size works"
4946 test_56u() { # LU-611
4948 setup_56 $NUMFILES $NUMDIRS "-i 0"
4950 if [[ $OSTCOUNT -gt 1 ]]; then
4951 $SETSTRIPE -i 1 $TDIR/$tfile.{0,1,2,3}
4957 EXPECTED=$(((NUMDIRS + 1) * NUMFILES))
4958 CMD="$LFIND -stripe-index 0 -type f $TDIR"
4959 NUMS=$($CMD | wc -l)
4960 [ $NUMS -eq $EXPECTED ] ||
4961 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4964 CMD="$LFIND -stripe-index 1 -type f $TDIR"
4965 NUMS=$($CMD | wc -l)
4966 [ $NUMS -eq $EXPECTED ] ||
4967 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4969 CMD="$LFIND ! -stripe-index 0 -type f $TDIR"
4970 NUMS=$($CMD | wc -l)
4971 [ $NUMS -eq $EXPECTED ] ||
4972 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4975 # This should produce an error and not return any files
4976 CMD="$LFIND -stripe-index $OSTCOUNT -type f $TDIR"
4977 NUMS=$($CMD 2>/dev/null | wc -l)
4978 [ $NUMS -eq $EXPECTED ] ||
4979 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4981 if [[ $OSTCOUNT -gt 1 ]]; then
4982 EXPECTED=$(((NUMDIRS + 1) * NUMFILES + ONESTRIPE))
4983 CMD="$LFIND -stripe-index 0,1 -type f $TDIR"
4984 NUMS=$($CMD | wc -l)
4985 [ $NUMS -eq $EXPECTED ] ||
4986 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4989 run_test 56u "check lfs find -stripe-index works"
4996 setup_56 $NUMFILES $NUMDIRS
4998 UUID=$(mdtuuid_from_index $MDT_IDX $TDIR)
4999 [ -z "$UUID" ] && error "mdtuuid_from_index cannot find MDT index $MDT_IDX"
5001 for file in $($LFIND -mdt $UUID $TDIR); do
5002 file_mdt_idx=$($GETSTRIPE -M $file)
5003 [ $file_mdt_idx -eq $MDT_IDX ] ||
5004 error "'lfind -mdt $UUID' != 'getstripe -M' ($file_mdt_idx)"
5007 run_test 56v "check 'lfs find -mdt match with lfs getstripe -M' ======="
5010 [[ $OSTCOUNT -lt 2 ]] && skip_env "$OSTCOUNT < 2 OSTs -- skipping" &&
5012 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5015 rm -rf $TDIR || error "remove $TDIR failed"
5016 setup_56 $NUMFILES $NUMDIRS "-c $OSTCOUNT" "-c1"
5019 stripe_size=$($GETSTRIPE -S -d $TDIR) ||
5020 error "$GETSTRIPE -S -d $TDIR failed"
5021 stripe_size=${stripe_size%% *}
5023 local file_size=$((stripe_size * OSTCOUNT))
5024 local file_num=$((NUMDIRS * NUMFILES + NUMFILES))
5025 local required_space=$((file_num * file_size))
5027 local free_space=$($LCTL get_param -n lov.$FSNAME-clilov-*.kbytesavail |
5029 [[ $free_space -le $((required_space / 1024)) ]] &&
5030 skip_env "need at least $required_space bytes free space," \
5031 "have $free_space kbytes" && return
5034 local dd_count=$((file_size / dd_bs))
5036 # write data into the files
5040 for i in $(seq 1 $NUMFILES); do
5042 yes | dd bs=$dd_bs count=$dd_count of=$file >/dev/null 2>&1 ||
5043 error "write data into $file failed"
5045 for i in $(seq 1 $NUMDIRS); do
5046 for j in $(seq 1 $NUMFILES); do
5047 file=$TDIR/dir$i/file$j
5048 yes | dd bs=$dd_bs count=$dd_count of=$file \
5050 error "write data into $file failed"
5055 [[ $OSTCOUNT -gt 1 ]] && expected=$((OSTCOUNT - 1))
5058 local cmd="$LFS_MIGRATE -y -c $expected $TDIR/file1"
5060 eval $cmd || error "$cmd failed"
5062 check_stripe_count $TDIR/file1 $expected
5064 if [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.6.90) ];
5066 # lfs_migrate file onto OST 0 if it is on OST 1, or onto
5067 # OST 1 if it is on OST 0. This file is small enough to
5068 # be on only one stripe.
5069 file=$TDIR/migr_1_ost
5070 dd bs=$dd_bs count=1 if=/dev/urandom of=$file >/dev/null 2>&1 ||
5071 error "write data into $file failed"
5072 local obdidx=$($LFS getstripe -i $file)
5073 local oldmd5=$(md5sum $file)
5075 [[ $obdidx -eq 0 ]] && newobdidx=1
5076 cmd="$LFS migrate -i $newobdidx $file"
5078 eval $cmd || error "$cmd failed"
5079 local realobdix=$($LFS getstripe -i $file)
5080 local newmd5=$(md5sum $file)
5081 [[ $newobdidx -ne $realobdix ]] &&
5082 error "new OST is different (was=$obdidx, wanted=$newobdidx, got=$realobdix)"
5083 [[ "$oldmd5" != "$newmd5" ]] &&
5084 error "md5sum differ: $oldmd5, $newmd5"
5088 cmd="$LFS_MIGRATE -y -c $expected $TDIR/dir1"
5090 eval $cmd || error "$cmd failed"
5092 for j in $(seq 1 $NUMFILES); do
5093 check_stripe_count $TDIR/dir1/file$j $expected
5096 # lfs_migrate works with lfs find
5097 cmd="$LFIND -stripe_count $OSTCOUNT -type f $TDIR |
5098 $LFS_MIGRATE -y -c $expected"
5100 eval $cmd || error "$cmd failed"
5102 for i in $(seq 2 $NUMFILES); do
5103 check_stripe_count $TDIR/file$i $expected
5105 for i in $(seq 2 $NUMDIRS); do
5106 for j in $(seq 1 $NUMFILES); do
5107 check_stripe_count $TDIR/dir$i/file$j $expected
5111 run_test 56w "check lfs_migrate -c stripe_count works"
5114 check_swap_layouts_support && return 0
5115 [[ $OSTCOUNT -lt 2 ]] &&
5116 skip_env "need 2 OST, skipping test" && return
5118 local dir0=$DIR/$tdir/$testnum
5119 test_mkdir -p $dir0 || error "creating dir $dir0"
5121 local ref1=/etc/passwd
5122 local file1=$dir0/file1
5124 $SETSTRIPE -c 2 $file1
5126 $LFS migrate -c 1 $file1 || error "migrate failed rc = $?"
5127 stripe=$($GETSTRIPE -c $file1)
5128 [[ $stripe == 1 ]] || error "stripe of $file1 is $stripe != 1"
5129 cmp $file1 $ref1 || error "content mismatch $file1 differs from $ref1"
5134 run_test 56x "lfs migration support"
5137 check_swap_layouts_support && return 0
5138 [[ $OSTCOUNT -lt 2 ]] &&
5139 skip_env "need 2 OST, skipping test" && return
5141 local dir0=$DIR/$tdir/$testnum
5142 test_mkdir -p $dir0 || error "creating dir $dir0"
5144 local ref1=/etc/passwd
5145 local file1=$dir0/file1
5147 $SETSTRIPE -c 2 $file1
5149 $LFS migrate --block -c 1 $file1 || error "migrate failed rc = $?"
5150 local stripe=$($GETSTRIPE -c $file1)
5151 [[ $stripe == 1 ]] || error "stripe of $file1 is $stripe != 1"
5152 cmp $file1 $ref1 || error "content mismatch $file1 differs from $ref1"
5157 run_test 56xa "lfs migration --block support"
5160 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.53) ] &&
5161 skip "No HSM $(lustre_build_version $SINGLEMDS) MDS < 2.4.53" &&
5165 local dir0=$DIR/$tdir/$testnum
5166 test_mkdir -p $dir0 || error "creating dir $dir0"
5167 local f1=$dir0/file1
5168 local f2=$dir0/file2
5170 touch $f1 || error "creating std file $f1"
5171 $MULTIOP $f2 H2c || error "creating released file $f2"
5173 # a directory can be raid0, so ask only for files
5174 res=$($LFIND $dir0 -L raid0 -type f | wc -l)
5175 [[ $res == 2 ]] || error "search raid0: found $res files != 2"
5177 res=$($LFIND $dir0 \! -L raid0 -type f | wc -l)
5178 [[ $res == 0 ]] || error "search !raid0: found $res files != 0"
5180 # only files can be released, so no need to force file search
5181 res=$($LFIND $dir0 -L released)
5182 [[ $res == $f2 ]] || error "search released: found $res != $f2"
5184 res=$($LFIND $dir0 \! -L released)
5185 [[ $res == $f1 ]] || error "search !released: found $res != $f1"
5188 run_test 56y "lfs find -L raid0|released"
5190 test_56z() { # LU-4824
5191 # This checks to make sure 'lfs find' continues after errors
5192 # There are two classes of errors that should be caught:
5193 # - If multiple paths are provided, all should be searched even if one
5195 # - If errors are encountered during the search, it should not terminate
5198 test_mkdir $DIR/$tdir
5199 for i in d{0..9}; do
5200 test_mkdir $DIR/$tdir/$i
5202 touch $DIR/$tdir/d{0..9}/$tfile
5203 $LFS find $DIR/non_existent_dir $DIR/$tdir &&
5204 error "$LFS find did not return an error"
5205 # Make a directory unsearchable. This should NOT be the last entry in
5206 # directory order. Arbitrarily pick the 6th entry
5207 chmod 700 $($LFS find $DIR/$tdir -type d | sed '6!d')
5208 local count=$($RUNAS $LFS find $DIR/non_existent $DIR/$tdir | wc -l)
5209 # The user should be able to see 10 directories and 9 files
5210 [ $count == 19 ] || error "$LFS find did not continue after error"
5212 run_test 56z "lfs find should continue after an error"
5214 test_56aa() { # LU-5937
5215 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
5218 $LFS setdirstripe -c$MDSCOUNT $DIR/$tdir/striped_dir
5220 createmany -o $DIR/$tdir/striped_dir/${tfile}- 1024
5221 local dirs=$(lfs find --size +8k $DIR/$tdir/)
5223 [ -n "$dirs" ] || error "lfs find --size wrong under striped dir"
5225 run_test 56aa "lfs find --size under striped dir"
5228 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5229 # note test will not do anything if MDS is not local
5230 if [ "$(facet_fstype $SINGLEMDS)" != ldiskfs ]; then
5231 skip "Only applicable to ldiskfs-based MDTs"
5235 remote_mds_nodsh && skip "remote MDS with nodsh" && return
5236 local MNTDEV="osd*.*MDT*.mntdev"
5237 DEV=$(do_facet $SINGLEMDS lctl get_param -n $MNTDEV)
5238 [ -z "$DEV" ] && error "can't access $MNTDEV"
5239 for DEV in $(do_facet $SINGLEMDS lctl get_param -n $MNTDEV); do
5240 do_facet $SINGLEMDS $DUMPE2FS -h $DEV > $TMP/t57a.dump ||
5241 error "can't access $DEV"
5242 DEVISIZE=$(awk '/Inode size:/ { print $3 }' $TMP/t57a.dump)
5243 [[ $DEVISIZE -gt 128 ]] || error "inode size $DEVISIZE"
5247 run_test 57a "verify MDS filesystem created with large inodes =="
5250 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5251 if [ "$(facet_fstype $SINGLEMDS)" != ldiskfs ]; then
5252 skip "Only applicable to ldiskfs-based MDTs"
5256 remote_mds_nodsh && skip "remote MDS with nodsh" && return
5257 local dir=$DIR/$tdir
5261 local FILEN=$dir/f$FILECOUNT
5263 rm -rf $dir || error "removing $dir"
5264 test_mkdir -p -c1 $dir || error "creating $dir"
5265 local mdtidx=$($LFS getstripe -M $dir)
5266 local mdtname=MDT$(printf %04x $mdtidx)
5267 local facet=mds$((mdtidx + 1))
5269 echo "mcreating $FILECOUNT files"
5270 createmany -m $dir/f 1 $FILECOUNT || \
5271 error "creating files in $dir"
5273 # verify that files do not have EAs yet
5274 $GETSTRIPE $FILE1 2>&1 | grep -q "no stripe" || error "$FILE1 has an EA"
5275 $GETSTRIPE $FILEN 2>&1 | grep -q "no stripe" || error "$FILEN has an EA"
5279 df $dir #make sure we get new statfs data
5280 local MDSFREE=$(do_facet $facet \
5281 lctl get_param -n osd*.*$mdtname.kbytesfree)
5282 local MDCFREE=$(lctl get_param -n mdc.*$mdtname-mdc-*.kbytesfree)
5283 echo "opening files to create objects/EAs"
5285 for FILE in `seq -f $dir/f%g 1 $FILECOUNT`; do
5286 $OPENFILE -f O_RDWR $FILE > /dev/null 2>&1 || error "opening $FILE"
5289 # verify that files have EAs now
5290 $GETSTRIPE $FILE1 | grep -q "obdidx" || error "$FILE1 missing EA"
5291 $GETSTRIPE $FILEN | grep -q "obdidx" || error "$FILEN missing EA"
5293 sleep 1 #make sure we get new statfs data
5295 local MDSFREE2=$(do_facet $facet \
5296 lctl get_param -n osd*.*$mdtname.kbytesfree)
5297 local MDCFREE2=$(lctl get_param -n mdc.*$mdtname-mdc-*.kbytesfree)
5298 if [[ $MDCFREE2 -lt $((MDCFREE - 16)) ]]; then
5299 if [ "$MDSFREE" != "$MDSFREE2" ]; then
5300 error "MDC before $MDCFREE != after $MDCFREE2"
5302 echo "MDC before $MDCFREE != after $MDCFREE2"
5303 echo "unable to confirm if MDS has large inodes"
5308 run_test 57b "default LOV EAs are stored inside large inodes ==="
5311 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5312 [ -z "$(which wiretest 2>/dev/null)" ] &&
5313 skip_env "could not find wiretest" && return
5316 run_test 58 "verify cross-platform wire constants =============="
5319 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5320 echo "touch 130 files"
5321 createmany -o $DIR/f59- 130
5323 unlinkmany $DIR/f59- 130
5325 # wait for commitment of removal
5326 wait_delete_completed
5328 run_test 59 "verify cancellation of llog records async ========="
5330 TEST60_HEAD="test_60 run $RANDOM"
5332 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5333 remote_mgs_nodsh && skip "remote MGS with nodsh" && return
5334 do_facet mgs "! which run-llog.sh &> /dev/null" &&
5335 do_facet mgs "! ls run-llog.sh &> /dev/null" &&
5336 skip_env "missing subtest run-llog.sh" && return
5338 log "$TEST60_HEAD - from kernel mode"
5339 do_facet mgs "$LCTL set_param debug=warning; $LCTL dk > /dev/null"
5340 do_facet mgs sh run-llog.sh
5341 do_facet mgs $LCTL dk > $TMP/$tfile
5343 # LU-6388: test llog_reader
5344 local llog_reader=$(do_facet mgs "which llog_reader 2> /dev/null")
5345 llog_reader=${llog_reader:-$LUSTRE/utils/llog_reader}
5346 [ -z $(do_facet mgs ls -d $llog_reader 2> /dev/null) ] &&
5347 skip_env "missing llog_reader" && return
5348 local fstype=$(facet_fstype mgs)
5349 [ $fstype != ldiskfs -a $fstype != zfs ] &&
5350 skip_env "Only for ldiskfs or zfs type mgs" && return
5352 local mntpt=$(facet_mntpt mgs)
5353 local mgsdev=$(mgsdevname 1)
5365 #get fid and record list
5366 fid_list=($(awk '/9_sub.*record/ { print $NF }' /$TMP/$tfile |
5368 rec_list=($(awk '/9_sub.*record/ { print $((NF-3)) }' /$TMP/$tfile |
5370 #remount mgs as ldiskfs or zfs type
5371 stop mgs || error "stop mgs failed"
5372 mount_fstype mgs || error "remount mgs failed"
5373 for ((i = 0; i < ${#fid_list[@]}; i++)); do
5376 seq=$(echo $fid | awk -F ':' '{ print $1 }' | sed -e "s/^0x//g")
5377 oid=$(echo $fid | awk -F ':' '{ print $2 }' | sed -e "s/^0x//g")
5382 obj_file=$mntpt/O/$seq/d$((oid%32))/$oid ;;
5384 obj_file=$mntpt/oi.$(($((16#$seq))&127))/$fid ;;
5386 echo "obj_file is $obj_file"
5387 do_facet mgs $llog_reader $obj_file
5389 rec_type=$(do_facet mgs $llog_reader $obj_file | grep "type=" |
5390 awk '{ print $3 }' | sed -e "s/^type=//g")
5391 if [ $rec_type != $rec ]; then
5392 echo "FAILED test_60a wrong record type $rec_type," \
5398 #check obj path if record type is LLOG_LOGID_MAGIC
5399 if [ "$rec" == "1064553b" ]; then
5400 path=$(do_facet mgs $llog_reader $obj_file |
5401 grep "path=" | awk '{ print $NF }' |
5402 sed -e "s/^path=//g")
5403 if [ $obj_file != $mntpt/$path ]; then
5404 echo "FAILED test_60a wrong obj path" \
5405 "$montpt/$path, should be $obj_file"
5412 #restart mgs before "error", otherwise it will block the next test
5413 stop mgs || error "stop mgs failed"
5414 start mgs $(mgsdevname) $MGS_MOUNT_OPTS || error "start mgs failed"
5415 $pass || error "test failed, see FAILED test_60a messages for specifics"
5417 run_test 60a "llog_test run from kernel module and test llog_reader"
5420 # test old logid format
5421 if [ $(lustre_version_code mgs) -le $(version_code 3.1.53) ]; then
5422 do_facet mgs $LCTL dl | grep MGS
5423 do_facet mgs "$LCTL --device %MGS llog_print \\\\\\\$$FSNAME-client" ||
5424 error "old llog_print failed"
5427 # test new logid format
5428 if [ $(lustre_version_code mgs) -ge $(version_code 2.9.53) ]; then
5429 do_facet mgs "$LCTL --device MGS llog_print $FSNAME-client" ||
5430 error "new llog_print failed"
5433 run_test 60aa "llog_print works with FIDs and simple names"
5435 test_60b() { # bug 6411
5436 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5438 LLOG_COUNT=$(dmesg | awk "/$TEST60_HEAD/ { marker = 1; from_marker = 0; }
5450 [[ $LLOG_COUNT -gt 100 ]] &&
5451 error "CDEBUG_LIMIT not limiting messages ($LLOG_COUNT)" || true
5453 run_test 60b "limit repeated messages from CERROR/CWARN ========"
5456 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5457 echo "create 5000 files"
5458 createmany -o $DIR/f60c- 5000
5459 #define OBD_FAIL_MDS_LLOG_CREATE_FAILED 0x137
5460 lctl set_param fail_loc=0x80000137
5461 unlinkmany $DIR/f60c- 5000
5462 lctl set_param fail_loc=0
5464 run_test 60c "unlink file when mds full"
5467 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5468 SAVEPRINTK=$(lctl get_param -n printk)
5470 # verify "lctl mark" is even working"
5471 MESSAGE="test message ID $RANDOM $$"
5472 $LCTL mark "$MESSAGE" || error "$LCTL mark failed"
5473 dmesg | grep -q "$MESSAGE" || error "didn't find debug marker in log"
5475 lctl set_param printk=0 || error "set lnet.printk failed"
5476 lctl get_param -n printk | grep emerg || error "lnet.printk dropped emerg"
5477 MESSAGE="new test message ID $RANDOM $$"
5478 # Assume here that libcfs_debug_mark_buffer() uses D_WARNING
5479 $LCTL mark "$MESSAGE" || error "$LCTL mark failed"
5480 dmesg | grep -q "$MESSAGE" && error "D_WARNING wasn't masked" || true
5482 lctl set_param -n printk="$SAVEPRINTK"
5484 run_test 60d "test printk console message masking"
5487 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5488 remote_mds_nodsh && skip "remote MDS with nodsh" && return
5490 #define OBD_FAIL_MDS_LLOG_CREATE_FAILED2 0x15b
5491 do_facet mds1 lctl set_param fail_loc=0x15b
5494 run_test 60e "no space while new llog is being created"
5497 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5499 dd if=/dev/zero of=$f bs=$(page_size) count=1 || error "dd $f failed"
5500 cancel_lru_locks osc
5501 $MULTIOP $f OSMWUc || error "$MULTIOP $f failed"
5504 run_test 61 "mmap() writes don't make sync hang ================"
5506 # bug 2330 - insufficient obd_match error checking causes LBUG
5508 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5511 cancel_lru_locks osc
5512 lctl set_param fail_loc=0x405
5513 cat $f && error "cat succeeded, expect -EIO"
5514 lctl set_param fail_loc=0
5516 # This test is now irrelevant (as of bug 10718 inclusion), we no longer
5517 # match every page all of the time.
5518 #run_test 62 "verify obd_match failure doesn't LBUG (should -EIO)"
5520 # bug 2319 - oig_wait() interrupted causes crash because of invalid waitq.
5521 # Though this test is irrelevant anymore, it helped to reveal some
5522 # other grant bugs (LU-4482), let's keep it.
5523 test_63a() { # was test_63
5524 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5525 MAX_DIRTY_MB=`lctl get_param -n osc.*.max_dirty_mb | head -n 1`
5526 for i in `seq 10` ; do
5527 dd if=/dev/zero of=$DIR/f63 bs=8k &
5533 rm -f $DIR/f63 || true
5535 run_test 63a "Verify oig_wait interruption does not crash ======="
5537 # bug 2248 - async write errors didn't return to application on sync
5538 # bug 3677 - async write errors left page locked
5540 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5542 lctl set_param debug=-1
5544 # ensure we have a grant to do async writes
5545 dd if=/dev/zero of=$DIR/$tfile bs=4k count=1
5548 sync # sync lest earlier test intercept the fail_loc
5550 #define OBD_FAIL_OSC_BRW_PREP_REQ 0x406
5551 lctl set_param fail_loc=0x80000406
5552 $MULTIOP $DIR/$tfile Owy && \
5553 error "sync didn't return ENOMEM"
5554 sync; sleep 2; sync # do a real sync this time to flush page
5555 lctl get_param -n llite.*.dump_page_cache | grep locked && \
5556 error "locked page left in cache after async error" || true
5559 run_test 63b "async write errors should be returned to fsync ==="
5562 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5564 lctl get_param -n osc.*[oO][sS][cC][_-]*.cur* | grep "[0-9]"
5566 run_test 64a "verify filter grant calculations (in kernel) ====="
5569 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5570 sh oos.sh $MOUNT || error "oos.sh failed: $?"
5572 run_test 64b "check out-of-space detection on client ==========="
5575 $LCTL set_param osc.*OST0000-osc-[^mM]*.cur_grant_bytes=0
5577 run_test 64c "verify grant shrink ========================------"
5579 # bug 1414 - set/get directories' stripe info
5581 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5582 test_mkdir -p $DIR/$tdir
5584 $LVERIFY $DIR/$tdir $DIR/$tdir/f1 || error "lverify failed"
5586 run_test 65a "directory with no stripe info ===================="
5589 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5590 test_mkdir -p $DIR/$tdir
5591 local STRIPESIZE=$($GETSTRIPE -S $DIR/$tdir)
5593 $SETSTRIPE -S $((STRIPESIZE * 2)) -i 0 -c 1 $DIR/$tdir ||
5596 $LVERIFY $DIR/$tdir $DIR/$tdir/f2 || error "lverify failed"
5598 run_test 65b "directory setstripe -S stripe_size*2 -i 0 -c 1"
5601 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5602 if [[ $OSTCOUNT -gt 1 ]]; then
5603 test_mkdir -p $DIR/$tdir
5604 local STRIPESIZE=$($GETSTRIPE -S $DIR/$tdir)
5606 $SETSTRIPE -S $(($STRIPESIZE * 4)) -i 1 \
5607 -c $(($OSTCOUNT - 1)) $DIR/$tdir || error "setstripe"
5609 $LVERIFY $DIR/$tdir $DIR/$tdir/f3 || error "lverify failed"
5612 run_test 65c "directory setstripe -S stripe_size*4 -i 1 -c $((OSTCOUNT-1))"
5615 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5616 test_mkdir -p $DIR/$tdir
5617 local STRIPECOUNT=$($GETSTRIPE -c $DIR/$tdir)
5618 local STRIPESIZE=$($GETSTRIPE -S $DIR/$tdir)
5620 if [[ $STRIPECOUNT -le 0 ]]; then
5622 elif [[ $STRIPECOUNT -gt 2000 ]]; then
5623 #LOV_MAX_STRIPE_COUNT is 2000
5624 [[ $OSTCOUNT -gt 2000 ]] && sc=2000 || sc=$(($OSTCOUNT - 1))
5626 sc=$(($STRIPECOUNT - 1))
5628 $SETSTRIPE -S $STRIPESIZE -c $sc $DIR/$tdir || error "setstripe"
5629 touch $DIR/$tdir/f4 $DIR/$tdir/f5
5630 $LVERIFY $DIR/$tdir $DIR/$tdir/f4 $DIR/$tdir/f5 ||
5631 error "lverify failed"
5633 run_test 65d "directory setstripe -S stripe_size -c stripe_count"
5636 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5637 test_mkdir -p $DIR/$tdir
5639 $SETSTRIPE $DIR/$tdir || error "setstripe"
5640 $GETSTRIPE -v $DIR/$tdir | grep "Default" ||
5641 error "no stripe info failed"
5643 $LVERIFY $DIR/$tdir $DIR/$tdir/f6 || error "lverify failed"
5645 run_test 65e "directory setstripe defaults ======================="
5648 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5649 test_mkdir -p $DIR/${tdir}f
5650 $RUNAS $SETSTRIPE $DIR/${tdir}f && error "setstripe succeeded" || true
5652 run_test 65f "dir setstripe permission (should return error) ==="
5655 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5656 test_mkdir -p $DIR/$tdir
5657 local STRIPESIZE=$($GETSTRIPE -S $DIR/$tdir)
5659 $SETSTRIPE -S $((STRIPESIZE * 2)) -i 0 -c 1 $DIR/$tdir ||
5661 $SETSTRIPE -d $DIR/$tdir || error "setstripe"
5662 $GETSTRIPE -v $DIR/$tdir | grep "Default" ||
5663 error "delete default stripe failed"
5665 run_test 65g "directory setstripe -d ==========================="
5668 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5669 test_mkdir -p $DIR/$tdir
5670 local STRIPESIZE=$($GETSTRIPE -S $DIR/$tdir)
5672 $SETSTRIPE -S $((STRIPESIZE * 2)) -i 0 -c 1 $DIR/$tdir ||
5674 test_mkdir -p $DIR/$tdir/dd1
5675 [ $($GETSTRIPE -c $DIR/$tdir) == $($GETSTRIPE -c $DIR/$tdir/dd1) ] ||
5676 error "stripe info inherit failed"
5678 run_test 65h "directory stripe info inherit ===================="
5680 test_65i() { # bug6367
5681 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5682 $SETSTRIPE -S 65536 -c -1 $MOUNT
5684 run_test 65i "set non-default striping on root directory (bug 6367)="
5686 test_65ia() { # bug12836
5687 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5688 $GETSTRIPE $MOUNT || error "getstripe $MOUNT failed"
5690 run_test 65ia "getstripe on -1 default directory striping"
5692 test_65ib() { # bug12836
5693 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5694 $GETSTRIPE -v $MOUNT || error "getstripe -v $MOUNT failed"
5696 run_test 65ib "getstripe -v on -1 default directory striping"
5698 test_65ic() { # bug12836
5699 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5700 $LFS find -mtime -1 $MOUNT > /dev/null || error "find $MOUNT failed"
5702 run_test 65ic "new find on -1 default directory striping"
5704 test_65j() { # bug6367
5705 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5707 # if we aren't already remounting for each test, do so for this test
5708 if [ "$CLEANUP" = ":" -a "$I_MOUNTED" = "yes" ]; then
5709 cleanup || error "failed to unmount"
5712 $SETSTRIPE -d $MOUNT || error "setstripe failed"
5714 run_test 65j "set default striping on root directory (bug 6367)="
5716 test_65k() { # bug11679
5717 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5718 [[ $OSTCOUNT -lt 2 ]] && skip_env "too few OSTs" && return
5719 remote_mds_nodsh && skip "remote MDS with nodsh" && return
5721 local disable_precreate=true
5722 [ $(lustre_version_code $SINGLEMDS) -le $(version_code 2.8.54) ] &&
5723 disable_precreate=false
5725 echo "Check OST status: "
5726 local MDS_OSCS=$(do_facet $SINGLEMDS lctl dl |
5727 awk '/[oO][sS][cC].*md[ts]/ { print $4 }')
5729 for OSC in $MDS_OSCS; do
5730 echo $OSC "is active"
5731 do_facet $SINGLEMDS lctl --device %$OSC activate
5734 for INACTIVE_OSC in $MDS_OSCS; do
5735 local ost=$(osc_to_ost $INACTIVE_OSC)
5736 local ostnum=$(do_facet $SINGLEMDS lctl get_param -n \
5737 lov.*md*.target_obd |
5738 awk -F: /$ost/'{ print $1 }' | head -n 1)
5741 $SETSTRIPE -i $ostnum -c 1 $DIR/$tdir
5742 createmany -o $DIR/$tdir/$tfile.$ostnum. 1000
5744 echo "Deactivate: " $INACTIVE_OSC
5745 do_facet $SINGLEMDS lctl --device %$INACTIVE_OSC deactivate
5747 local count=$(do_facet $SINGLEMDS "lctl get_param -n \
5748 osp.$ost*MDT0000.create_count")
5749 local max_count=$(do_facet $SINGLEMDS "lctl get_param -n \
5750 osp.$ost*MDT0000.max_create_count")
5751 $disable_precreate &&
5752 do_facet $SINGLEMDS "lctl set_param -n \
5753 osp.$ost*MDT0000.max_create_count=0"
5755 for idx in $(seq 0 $((OSTCOUNT - 1))); do
5756 [ -f $DIR/$tdir/$idx ] && continue
5757 echo "$SETSTRIPE -i $idx -c 1 $DIR/$tdir/$idx"
5758 $SETSTRIPE -i $idx -c 1 $DIR/$tdir/$idx ||
5759 error "setstripe $idx should succeed"
5760 rm -f $DIR/$tdir/$idx || error "rm $idx failed"
5762 unlinkmany $DIR/$tdir/$tfile.$ostnum. 1000
5765 do_facet $SINGLEMDS "lctl set_param -n \
5766 osp.$ost*MDT0000.max_create_count=$max_count"
5767 do_facet $SINGLEMDS "lctl set_param -n \
5768 osp.$ost*MDT0000.create_count=$count"
5769 do_facet $SINGLEMDS lctl --device %$INACTIVE_OSC activate
5770 echo $INACTIVE_OSC "is Activate"
5772 wait_osc_import_state mds ost$ostnum FULL
5775 run_test 65k "validate manual striping works properly with deactivated OSCs"
5777 test_65l() { # bug 12836
5778 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5779 test_mkdir -p $DIR/$tdir/test_dir
5780 $SETSTRIPE -c -1 $DIR/$tdir/test_dir
5781 $LFS find -mtime -1 $DIR/$tdir >/dev/null
5783 run_test 65l "lfs find on -1 stripe dir ========================"
5786 $RUNAS $SETSTRIPE -c 2 $MOUNT && error "setstripe should fail"
5789 run_test 65m "normal user can't set filesystem default stripe"
5791 # bug 2543 - update blocks count on client
5793 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5795 dd if=/dev/zero of=$DIR/f66 bs=1k count=$COUNT
5796 sync; sync_all_data; sync; sync_all_data
5797 cancel_lru_locks osc
5798 BLOCKS=`ls -s $DIR/f66 | awk '{ print $1 }'`
5799 [ $BLOCKS -ge $COUNT ] || error "$DIR/f66 blocks $BLOCKS < $COUNT"
5801 run_test 66 "update inode blocks count on client ==============="
5806 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5808 if [ ! -z "$LLOOP" ]; then
5809 if swapon -s | grep -q $LLOOP; then
5810 swapoff $LLOOP || error "swapoff failed"
5813 $LCTL blockdev_detach $LLOOP || error "detach failed"
5821 awk '($1 == "'$1':") { print $2 }' /proc/meminfo
5825 swapon -s | awk '($1 == "'$1'") { print $4 }'
5828 # bug5265, obdfilter oa2dentry return -ENOENT
5829 # #define OBD_FAIL_SRV_ENOENT 0x217
5831 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5832 remote_ost_nodsh && skip "remote OST with nodsh" && return
5835 $SETSTRIPE -c 1 -i 0 $f
5837 $DIRECTIO write ${f}.2 0 1 || error "directio write error"
5839 do_facet ost1 lctl set_param fail_loc=0x217
5840 $TRUNCATE $f 1 # vmtruncate() will ignore truncate() error.
5841 $DIRECTIO write $f 0 2 && error "write succeeded, expect -ENOENT"
5843 do_facet ost1 lctl set_param fail_loc=0
5844 $DIRECTIO write $f 0 2 || error "write error"
5846 cancel_lru_locks osc
5847 $DIRECTIO read $f 0 1 || error "read error"
5849 do_facet ost1 lctl set_param fail_loc=0x217
5850 $DIRECTIO read $f 1 1 && error "read succeeded, expect -ENOENT"
5852 do_facet ost1 lctl set_param fail_loc=0
5855 run_test 69 "verify oa2dentry return -ENOENT doesn't LBUG ======"
5858 test_mkdir -p $DIR/$tdir
5859 $LFS setdirstripe -D -c$MDSCOUNT $DIR/$tdir
5860 sh rundbench -C -D $DIR/$tdir 2 || error "dbench failed!"
5862 run_test 71 "Running dbench on lustre (don't segment fault) ===="
5864 test_72a() { # bug 5695 - Test that on 2.6 remove_suid works properly
5865 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5866 [ "$RUNAS_ID" = "$UID" ] &&
5867 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
5869 # Check that testing environment is properly set up. Skip if not
5870 FAIL_ON_ERROR=false check_runas_id_ret $RUNAS_ID $RUNAS_GID $RUNAS || {
5871 skip_env "User $RUNAS_ID does not exist - skipping"
5875 chmod 777 $DIR/$tfile
5876 chmod ug+s $DIR/$tfile
5877 $RUNAS dd if=/dev/zero of=$DIR/$tfile bs=512 count=1 ||
5878 error "$RUNAS dd $DIR/$tfile failed"
5879 # See if we are still setuid/sgid
5880 test -u $DIR/$tfile -o -g $DIR/$tfile &&
5881 error "S/gid is not dropped on write"
5882 # Now test that MDS is updated too
5883 cancel_lru_locks mdc
5884 test -u $DIR/$tfile -o -g $DIR/$tfile &&
5885 error "S/gid is not dropped on MDS"
5888 run_test 72a "Test that remove suid works properly (bug5695) ===="
5890 test_72b() { # bug 24226 -- keep mode setting when size is not changing
5893 [ "$RUNAS_ID" = "$UID" ] && \
5894 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
5895 [ "$RUNAS_ID" -eq 0 ] && \
5896 skip_env "RUNAS_ID = 0 -- skipping" && return
5898 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5899 # Check that testing environment is properly set up. Skip if not
5900 FAIL_ON_ERROR=false check_runas_id_ret $RUNAS_ID $RUNAS_ID $RUNAS || {
5901 skip_env "User $RUNAS_ID does not exist - skipping"
5904 touch $DIR/${tfile}-f{g,u}
5905 test_mkdir $DIR/${tfile}-dg
5906 test_mkdir $DIR/${tfile}-du
5907 chmod 770 $DIR/${tfile}-{f,d}{g,u}
5908 chmod g+s $DIR/${tfile}-{f,d}g
5909 chmod u+s $DIR/${tfile}-{f,d}u
5910 for perm in 777 2777 4777; do
5911 $RUNAS chmod $perm $DIR/${tfile}-fg && error "S/gid file allowed improper chmod to $perm"
5912 $RUNAS chmod $perm $DIR/${tfile}-fu && error "S/uid file allowed improper chmod to $perm"
5913 $RUNAS chmod $perm $DIR/${tfile}-dg && error "S/gid dir allowed improper chmod to $perm"
5914 $RUNAS chmod $perm $DIR/${tfile}-du && error "S/uid dir allowed improper chmod to $perm"
5918 run_test 72b "Test that we keep mode setting if without file data changed (bug 24226)"
5920 # bug 3462 - multiple simultaneous MDC requests
5922 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5923 test_mkdir $DIR/d73-1
5924 test_mkdir $DIR/d73-2
5925 multiop_bg_pause $DIR/d73-1/f73-1 O_c || return 1
5928 lctl set_param fail_loc=0x80000129
5929 $MULTIOP $DIR/d73-1/f73-2 Oc &
5931 lctl set_param fail_loc=0
5933 $MULTIOP $DIR/d73-2/f73-3 Oc &
5937 wait $pid1 || return 1
5941 $CHECKSTAT -t file $DIR/d73-1/f73-1 || return 4
5942 $CHECKSTAT -t file $DIR/d73-1/f73-2 || return 5
5943 $CHECKSTAT -t file $DIR/d73-2/f73-3 || return 6
5947 run_test 73 "multiple MDC requests (should not deadlock)"
5949 test_74a() { # bug 6149, 6184
5950 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5951 #define OBD_FAIL_LDLM_ENQUEUE_OLD_EXPORT 0x30e
5953 # very important to OR with OBD_FAIL_ONCE (0x80000000) -- otherwise it
5954 # will spin in a tight reconnection loop
5956 $LCTL set_param fail_loc=0x8000030e
5957 # get any lock that won't be difficult - lookup works.
5959 $LCTL set_param fail_loc=0
5963 run_test 74a "ldlm_enqueue freed-export error path, ls (shouldn't LBUG)"
5965 test_74b() { # bug 13310
5966 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5967 #define OBD_FAIL_LDLM_ENQUEUE_OLD_EXPORT 0x30e
5969 # very important to OR with OBD_FAIL_ONCE (0x80000000) -- otherwise it
5970 # will spin in a tight reconnection loop
5971 $LCTL set_param fail_loc=0x8000030e
5972 # get a "difficult" lock
5974 $LCTL set_param fail_loc=0
5978 run_test 74b "ldlm_enqueue freed-export error path, touch (shouldn't LBUG)"
5981 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5982 #define OBD_FAIL_LDLM_NEW_LOCK
5983 $LCTL set_param fail_loc=0x319
5984 touch $DIR/$tfile && error "touch successful"
5985 $LCTL set_param fail_loc=0
5988 run_test 74c "ldlm_lock_create error path, (shouldn't LBUG)"
5991 awk '/lustre_inode_cache/ {print $2; exit}' /proc/slabinfo
5994 get_inode_slab_tunables() {
5995 awk '/lustre_inode_cache/ {print $9," ",$10," ",$11; exit}' /proc/slabinfo
5998 set_inode_slab_tunables() {
5999 echo "lustre_inode_cache $1" > /proc/slabinfo
6002 test_76() { # Now for bug 20433, added originally in bug 1443
6003 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6004 local SLAB_SETTINGS=$(get_inode_slab_tunables)
6005 local CPUS=$(getconf _NPROCESSORS_ONLN 2>/dev/null)
6006 # we cannot set limit below 1 which means 1 inode in each
6007 # per-cpu cache is still allowed
6008 set_inode_slab_tunables "1 1 0"
6009 cancel_lru_locks osc
6010 BEFORE_INODES=$(num_inodes)
6011 echo "before inodes: $BEFORE_INODES"
6013 [ "$SLOW" = "no" ] && COUNT=100
6014 for i in $(seq $COUNT); do
6018 cancel_lru_locks osc
6019 AFTER_INODES=$(num_inodes)
6020 echo "after inodes: $AFTER_INODES"
6022 while [[ $((AFTER_INODES-1*${CPUS:-1})) -gt $BEFORE_INODES ]]; do
6024 AFTER_INODES=$(num_inodes)
6026 echo "wait $wait seconds inodes: $AFTER_INODES"
6027 if [ $wait -gt 30 ]; then
6028 error "inode slab grew from $BEFORE_INODES to $AFTER_INODES"
6031 set_inode_slab_tunables "$SLAB_SETTINGS"
6033 run_test 76 "confirm clients recycle inodes properly ===="
6039 # Note: in sptlrpc modes which enable its own bulk checksum, the
6040 # original crc32_le bulk checksum will be automatically disabled,
6041 # and the OBD_FAIL_OSC_CHECKSUM_SEND/OBD_FAIL_OSC_CHECKSUM_RECEIVE
6042 # will be checked by sptlrpc code against sptlrpc bulk checksum.
6043 # In this case set_checksums() will not be no-op, because sptlrpc
6044 # bulk checksum will be enabled all through the test.
6046 [ "$ORIG_CSUM" ] || ORIG_CSUM=`lctl get_param -n osc.*.checksums | head -n1`
6047 lctl set_param -n osc.*.checksums $1
6051 export ORIG_CSUM_TYPE="`lctl get_param -n osc.*osc-[^mM]*.checksum_type |
6052 sed 's/.*\[\(.*\)\].*/\1/g' | head -n1`"
6053 CKSUM_TYPES=${CKSUM_TYPES:-"crc32 adler"}
6054 [ "$ORIG_CSUM_TYPE" = "crc32c" ] && CKSUM_TYPES="$CKSUM_TYPES crc32c"
6057 lctl set_param -n osc.*osc-[^mM]*.checksum_type $1
6058 log "set checksum type to $1"
6061 F77_TMP=$TMP/f77-temp
6064 dd if=/dev/urandom of=$F77_TMP bs=1M count=$F77SZ || \
6065 error "error writing to $F77_TMP"
6068 test_77a() { # bug 10889
6069 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6070 $GSS && skip "could not run with gss" && return
6071 [ ! -f $F77_TMP ] && setup_f77
6073 dd if=$F77_TMP of=$DIR/$tfile bs=1M count=$F77SZ || error "dd error"
6077 run_test 77a "normal checksum read/write operation"
6079 test_77b() { # bug 10889
6080 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6081 $GSS && skip "could not run with gss" && return
6082 [ ! -f $F77_TMP ] && setup_f77
6083 #define OBD_FAIL_OSC_CHECKSUM_SEND 0x409
6084 $LCTL set_param fail_loc=0x80000409
6087 dd if=$F77_TMP of=$DIR/$tfile bs=1M count=$F77SZ conv=sync ||
6088 error "dd error: $?"
6089 $LCTL set_param fail_loc=0
6091 for algo in $CKSUM_TYPES; do
6092 cancel_lru_locks osc
6093 set_checksum_type $algo
6094 #define OBD_FAIL_OSC_CHECKSUM_RECEIVE 0x408
6095 $LCTL set_param fail_loc=0x80000408
6096 cmp $F77_TMP $DIR/$tfile || error "file compare failed"
6097 $LCTL set_param fail_loc=0
6100 set_checksum_type $ORIG_CSUM_TYPE
6103 run_test 77b "checksum error on client write, read"
6105 test_77d() { # bug 10889
6106 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6107 $GSS && skip "could not run with gss" && return
6108 #define OBD_FAIL_OSC_CHECKSUM_SEND 0x409
6109 $LCTL set_param fail_loc=0x80000409
6111 $DIRECTIO write $DIR/$tfile 0 $F77SZ $((1024 * 1024)) ||
6112 error "direct write: rc=$?"
6113 $LCTL set_param fail_loc=0
6116 #define OBD_FAIL_OSC_CHECKSUM_RECEIVE 0x408
6117 $LCTL set_param fail_loc=0x80000408
6119 cancel_lru_locks osc
6120 $DIRECTIO read $DIR/$tfile 0 $F77SZ $((1024 * 1024)) ||
6121 error "direct read: rc=$?"
6122 $LCTL set_param fail_loc=0
6125 run_test 77d "checksum error on OST direct write, read"
6127 test_77f() { # bug 10889
6128 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6129 $GSS && skip "could not run with gss" && return
6131 for algo in $CKSUM_TYPES; do
6132 cancel_lru_locks osc
6133 set_checksum_type $algo
6134 #define OBD_FAIL_OSC_CHECKSUM_SEND 0x409
6135 $LCTL set_param fail_loc=0x409
6136 $DIRECTIO write $DIR/$tfile 0 $F77SZ $((1024 * 1024)) &&
6137 error "direct write succeeded"
6138 $LCTL set_param fail_loc=0
6140 set_checksum_type $ORIG_CSUM_TYPE
6143 run_test 77f "repeat checksum error on write (expect error)"
6145 test_77g() { # bug 10889
6146 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6147 $GSS && skip "could not run with gss" && return
6148 remote_ost_nodsh && skip "remote OST with nodsh" && return
6150 [ ! -f $F77_TMP ] && setup_f77
6152 $SETSTRIPE -c 1 -i 0 $DIR/$tfile
6153 #define OBD_FAIL_OST_CHECKSUM_RECEIVE 0x21a
6154 do_facet ost1 lctl set_param fail_loc=0x8000021a
6156 dd if=$F77_TMP of=$DIR/$tfile bs=1M count=$F77SZ ||
6157 error "write error: rc=$?"
6158 do_facet ost1 lctl set_param fail_loc=0
6161 cancel_lru_locks osc
6162 #define OBD_FAIL_OST_CHECKSUM_SEND 0x21b
6163 do_facet ost1 lctl set_param fail_loc=0x8000021b
6165 cmp $F77_TMP $DIR/$tfile || error "file compare failed"
6166 do_facet ost1 lctl set_param fail_loc=0
6169 run_test 77g "checksum error on OST write, read"
6171 test_77j() { # bug 13805
6172 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6173 $GSS && skip "could not run with gss" && return
6174 #define OBD_FAIL_OSC_CKSUM_ADLER_ONLY 0x40c
6175 lctl set_param fail_loc=0x40c
6176 remount_client $MOUNT
6177 lctl set_param fail_loc=0
6178 # wait async osc connect to finish and reflect updated state value
6180 for (( i=0; i < OSTCOUNT; i++ )) ; do
6181 wait_osc_import_state client ost$((i+1)) FULL
6184 for VALUE in $(lctl get_param osc.*osc-[^mM]*.checksum_type); do
6185 PARAM=$(echo ${VALUE[0]} | cut -d "=" -f1)
6186 algo=$(lctl get_param -n $PARAM | sed 's/.*\[\(.*\)\].*/\1/g')
6187 [ "$algo" = "adler" ] || error "algo set to $algo instead of adler"
6189 remount_client $MOUNT
6191 run_test 77j "client only supporting ADLER32"
6193 [ "$ORIG_CSUM" ] && set_checksums $ORIG_CSUM || true
6202 test_78() { # bug 10901
6203 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6204 remote_ost || { skip_env "local OST" && return; }
6207 F78SIZE=$(($(awk '/MemFree:/ { print $2 }' /proc/meminfo) / 1024))
6208 echo "MemFree: $F78SIZE, Max file size: $MAXFREE"
6209 MEMTOTAL=$(($(awk '/MemTotal:/ { print $2 }' /proc/meminfo) / 1024))
6210 echo "MemTotal: $MEMTOTAL"
6212 # reserve 256MB of memory for the kernel and other running processes,
6213 # and then take 1/2 of the remaining memory for the read/write buffers.
6214 if [ $MEMTOTAL -gt 512 ] ;then
6215 MEMTOTAL=$(((MEMTOTAL - 256 ) / 2))
6217 # for those poor memory-starved high-end clusters...
6218 MEMTOTAL=$((MEMTOTAL / 2))
6220 echo "Mem to use for directio: $MEMTOTAL"
6222 [[ $F78SIZE -gt $MEMTOTAL ]] && F78SIZE=$MEMTOTAL
6223 [[ $F78SIZE -gt 512 ]] && F78SIZE=512
6224 [[ $F78SIZE -gt $((MAXFREE / 1024)) ]] && F78SIZE=$((MAXFREE / 1024))
6225 SMALLESTOST=$($LFS df $DIR | grep OST | awk '{ print $4 }' | sort -n |
6227 echo "Smallest OST: $SMALLESTOST"
6228 [[ $SMALLESTOST -lt 10240 ]] &&
6229 skip "too small OSTSIZE, useless to run large O_DIRECT test" && return 0
6231 trap cleanup_test_78 EXIT
6233 [[ $F78SIZE -gt $((SMALLESTOST * $OSTCOUNT / 1024 - 80)) ]] &&
6234 F78SIZE=$((SMALLESTOST * $OSTCOUNT / 1024 - 80))
6236 [ "$SLOW" = "no" ] && NSEQ=1 && [ $F78SIZE -gt 32 ] && F78SIZE=32
6237 echo "File size: $F78SIZE"
6238 $SETSTRIPE -c $OSTCOUNT $DIR/$tfile || error "setstripe failed"
6239 for i in $(seq 1 $NSEQ); do
6240 FSIZE=$(($F78SIZE / ($NSEQ - $i + 1)))
6241 echo directIO rdwr round $i of $NSEQ
6242 $DIRECTIO rdwr $DIR/$tfile 0 $FSIZE 1048576||error "rdwr failed"
6247 run_test 78 "handle large O_DIRECT writes correctly ============"
6249 test_79() { # bug 12743
6250 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6251 wait_delete_completed
6253 BKTOTAL=$(calc_osc_kbytes kbytestotal)
6254 BKFREE=$(calc_osc_kbytes kbytesfree)
6255 BKAVAIL=$(calc_osc_kbytes kbytesavail)
6257 STRING=`df -P $MOUNT | tail -n 1 | awk '{print $2","$3","$4}'`
6258 DFTOTAL=`echo $STRING | cut -d, -f1`
6259 DFUSED=`echo $STRING | cut -d, -f2`
6260 DFAVAIL=`echo $STRING | cut -d, -f3`
6261 DFFREE=$(($DFTOTAL - $DFUSED))
6263 ALLOWANCE=$((64 * $OSTCOUNT))
6265 if [ $DFTOTAL -lt $(($BKTOTAL - $ALLOWANCE)) ] ||
6266 [ $DFTOTAL -gt $(($BKTOTAL + $ALLOWANCE)) ] ; then
6267 error "df total($DFTOTAL) mismatch OST total($BKTOTAL)"
6269 if [ $DFFREE -lt $(($BKFREE - $ALLOWANCE)) ] ||
6270 [ $DFFREE -gt $(($BKFREE + $ALLOWANCE)) ] ; then
6271 error "df free($DFFREE) mismatch OST free($BKFREE)"
6273 if [ $DFAVAIL -lt $(($BKAVAIL - $ALLOWANCE)) ] ||
6274 [ $DFAVAIL -gt $(($BKAVAIL + $ALLOWANCE)) ] ; then
6275 error "df avail($DFAVAIL) mismatch OST avail($BKAVAIL)"
6278 run_test 79 "df report consistency check ======================="
6280 test_80() { # bug 10718
6281 remote_ost_nodsh && skip "remote OST with nodsh" && return
6282 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6283 # relax strong synchronous semantics for slow backends like ZFS
6284 local soc="obdfilter.*.sync_on_lock_cancel"
6285 local soc_old=$(do_facet ost1 lctl get_param -n $soc | head -n1)
6287 if [ "$soc_old" != "never" -a "$(facet_fstype ost1)" != "ldiskfs" ]; then
6288 hosts=$(for host in $(seq -f "ost%g" 1 $OSTCOUNT); do
6289 facet_active_host $host; done | sort -u)
6290 do_nodes $hosts lctl set_param $soc=never
6293 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=1M
6295 local BEFORE=`date +%s`
6296 cancel_lru_locks osc
6297 local AFTER=`date +%s`
6298 local DIFF=$((AFTER-BEFORE))
6299 if [ $DIFF -gt 1 ] ; then
6300 error "elapsed for 1M@1T = $DIFF"
6303 [ -n "$hosts" ] && do_nodes $hosts lctl set_param $soc=$soc_old
6307 run_test 80 "Page eviction is equally fast at high offsets too ===="
6309 test_81a() { # LU-456
6310 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6311 remote_ost_nodsh && skip "remote OST with nodsh" && return
6312 # define OBD_FAIL_OST_MAPBLK_ENOSPC 0x228
6313 # MUST OR with the OBD_FAIL_ONCE (0x80000000)
6314 do_facet ost1 lctl set_param fail_loc=0x80000228
6316 # write should trigger a retry and success
6317 $SETSTRIPE -i 0 -c 1 $DIR/$tfile
6318 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
6320 if [ $RC -ne 0 ] ; then
6321 error "write should success, but failed for $RC"
6324 run_test 81a "OST should retry write when get -ENOSPC ==============="
6326 test_81b() { # LU-456
6327 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6328 remote_ost_nodsh && skip "remote OST with nodsh" && return
6329 # define OBD_FAIL_OST_MAPBLK_ENOSPC 0x228
6330 # Don't OR with the OBD_FAIL_ONCE (0x80000000)
6331 do_facet ost1 lctl set_param fail_loc=0x228
6333 # write should retry several times and return -ENOSPC finally
6334 $SETSTRIPE -i 0 -c 1 $DIR/$tfile
6335 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
6338 if [ $RC -ne $ENOSPC ] ; then
6339 error "dd should fail for -ENOSPC, but succeed."
6342 run_test 81b "OST should return -ENOSPC when retry still fails ======="
6344 test_82() { # LU-1031
6345 dd if=/dev/zero of=$DIR/$tfile bs=1M count=10
6349 multiop_bg_pause $DIR/$tfile OG${gid1}_g${gid1}c || return 1
6351 multiop_bg_pause $DIR/$tfile O_G${gid2}r10g${gid2}c || return 2
6353 kill -USR1 $MULTIPID2
6355 if [[ `ps h -o comm -p $MULTIPID2` == "" ]]; then
6356 error "First grouplock does not block second one"
6358 echo "Second grouplock blocks first one"
6360 kill -USR1 $MULTIPID1
6364 run_test 82 "Basic grouplock test ==============================="
6367 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" &&
6369 test_mkdir -p $DIR/d99cvsroot
6370 chown $RUNAS_ID $DIR/d99cvsroot
6371 local oldPWD=$PWD # bug 13584, use $TMP as working dir
6374 $RUNAS cvs -d $DIR/d99cvsroot init || error "cvs init failed"
6377 run_test 99a "cvs init ========================================="
6380 [ -z "$(which cvs 2>/dev/null)" ] &&
6381 skip_env "could not find cvs" && return
6382 [ ! -d $DIR/d99cvsroot ] && test_99a
6384 # some versions of cvs import exit(1) when asked to import links or
6385 # files they can't read. ignore those files.
6386 TOIGNORE=$(find . -type l -printf '-I %f\n' -o \
6387 ! -perm /4 -printf '-I %f\n')
6388 $RUNAS cvs -d $DIR/d99cvsroot import -m "nomesg" $TOIGNORE \
6389 d99reposname vtag rtag
6391 run_test 99b "cvs import ======================================="
6394 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" && return
6395 [ ! -d $DIR/d99cvsroot ] && test_99b
6397 test_mkdir -p $DIR/d99reposname
6398 chown $RUNAS_ID $DIR/d99reposname
6399 $RUNAS cvs -d $DIR/d99cvsroot co d99reposname
6401 run_test 99c "cvs checkout ====================================="
6404 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" && return
6405 [ ! -d $DIR/d99cvsroot ] && test_99c
6406 cd $DIR/d99reposname
6408 $RUNAS cvs add -m 'addmsg' foo99
6410 run_test 99d "cvs add =========================================="
6413 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" && return
6414 [ ! -d $DIR/d99cvsroot ] && test_99c
6415 cd $DIR/d99reposname
6418 run_test 99e "cvs update ======================================="
6421 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" && return
6422 [ ! -d $DIR/d99cvsroot ] && test_99d
6423 cd $DIR/d99reposname
6424 $RUNAS cvs commit -m 'nomsg' foo99
6425 rm -fr $DIR/d99cvsroot
6427 run_test 99f "cvs commit ======================================="
6430 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6431 [ "$NETTYPE" = tcp ] || \
6432 { skip "TCP secure port test, not useful for NETTYPE=$NETTYPE" && \
6435 remote_ost_nodsh && skip "remote OST with nodsh" && return
6436 remote_mds_nodsh && skip "remote MDS with nodsh" && return
6438 { skip "useless for local single node setup" && return; }
6440 netstat -tna | ( rc=1; while read PROT SND RCV LOCAL REMOTE STAT; do
6441 [ "$PROT" != "tcp" ] && continue
6442 RPORT=$(echo $REMOTE | cut -d: -f2)
6443 [ "$RPORT" != "$ACCEPTOR_PORT" ] && continue
6446 LPORT=`echo $LOCAL | cut -d: -f2`
6447 if [ $LPORT -ge 1024 ]; then
6448 echo "bad: $PROT $SND $RCV $LOCAL $REMOTE $STAT"
6450 error_exit "local: $LPORT > 1024, remote: $RPORT"
6453 [ "$rc" = 0 ] || error_exit "privileged port not found" )
6455 run_test 100 "check local port using privileged port ==========="
6457 function get_named_value()
6466 echo $line | sed "s/^$tag[ ]*//"
6473 export CACHE_MAX=$($LCTL get_param -n llite.*.max_cached_mb |
6474 awk '/^max_cached_mb/ { print $2 }')
6477 $LCTL set_param -n llite.*.max_cached_mb $CACHE_MAX
6482 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6483 [ $MDSCOUNT -ge 2 ] && skip "skip now for >= 2 MDTs" && return #LU-4322
6487 local cache_limit=32
6489 $LCTL set_param -n osc.*-osc*.rpc_stats 0
6490 trap cleanup_101a EXIT
6491 $LCTL set_param -n llite.*.read_ahead_stats 0
6492 $LCTL set_param -n llite.*.max_cached_mb $cache_limit
6495 # randomly read 10000 of 64K chunks from file 3x 32MB in size
6497 echo "nreads: $nreads file size: $((cache_limit * 3))MB"
6498 $READS -f $DIR/$tfile -s$((cache_limit * 3192 * 1024)) -b65536 -C -n$nreads -t 180
6501 for s in $($LCTL get_param -n llite.*.read_ahead_stats |
6502 get_named_value 'read but discarded' | cut -d" " -f1); do
6503 discard=$(($discard + $s))
6507 if [[ $(($discard * 10)) -gt $nreads ]]; then
6508 $LCTL get_param osc.*-osc*.rpc_stats
6509 $LCTL get_param llite.*.read_ahead_stats
6510 error "too many ($discard) discarded pages"
6512 rm -f $DIR/$tfile || true
6514 run_test 101a "check read-ahead for random reads ================"
6517 test_mkdir -p $DIR/$tdir
6518 local STRIPE_SIZE=$1
6519 local FILE_LENGTH=$2
6522 local FILE_SIZE_MB=$((FILE_LENGTH / STRIPE_SIZE))
6524 local list=$(comma_list $(osts_nodes))
6525 set_osd_param $list '' read_cache_enable 0
6526 set_osd_param $list '' writethrough_cache_enable 0
6528 trap cleanup_test101bc EXIT
6529 # prepare the read-ahead file
6530 $SETSTRIPE -S $STRIPE_SIZE -i $STRIPE_OFFSET -c $OSTCOUNT $DIR/$tfile
6532 dd if=/dev/zero of=$DIR/$tfile bs=$STRIPE_SIZE \
6533 count=$FILE_SIZE_MB 2> /dev/null
6537 cleanup_test101bc() {
6542 local list=$(comma_list $(osts_nodes))
6543 set_osd_param $list '' read_cache_enable 1
6544 set_osd_param $list '' writethrough_cache_enable 1
6548 awk 'BEGIN{total=0}; {total+=$1}; END{print total}'
6553 local STRIPE_SIZE=$2
6554 local FILE_LENGTH=$3
6555 local RA_INC=1048576
6556 local STRIDE_LENGTH=$((STRIPE_SIZE/READ_SIZE))
6557 local discard_limit=$((((STRIDE_LENGTH - 1)*3/(STRIDE_LENGTH*OSTCOUNT))* \
6558 (STRIDE_LENGTH*OSTCOUNT - STRIDE_LENGTH)))
6559 DISCARD=$($LCTL get_param -n llite.*.read_ahead_stats |
6560 get_named_value 'read but discarded' |
6561 cut -d" " -f1 | calc_total)
6562 if [[ $DISCARD -gt $discard_limit ]]; then
6563 $LCTL get_param llite.*.read_ahead_stats
6564 error "Too many ($DISCARD) discarded pages with size (${READ_SIZE})"
6566 echo "Read-ahead success for size ${READ_SIZE}"
6571 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6572 [[ $OSTCOUNT -lt 2 ]] &&
6573 skip_env "skipping stride IO stride-ahead test" && return
6574 local STRIPE_SIZE=1048576
6575 local STRIDE_SIZE=$((STRIPE_SIZE*OSTCOUNT))
6576 if [ $SLOW == "yes" ]; then
6577 local FILE_LENGTH=$((STRIDE_SIZE * 64))
6579 local FILE_LENGTH=$((STRIDE_SIZE * 8))
6582 local ITERATION=$((FILE_LENGTH / STRIDE_SIZE))
6584 # prepare the read-ahead file
6585 setup_test101bc $STRIPE_SIZE $FILE_LENGTH
6586 cancel_lru_locks osc
6587 for BIDX in 2 4 8 16 32 64 128 256
6589 local BSIZE=$((BIDX*4096))
6590 local READ_COUNT=$((STRIPE_SIZE/BSIZE))
6591 local STRIDE_LENGTH=$((STRIDE_SIZE/BSIZE))
6592 local OFFSET=$((STRIPE_SIZE/BSIZE*(OSTCOUNT - 1)))
6593 $LCTL set_param -n llite.*.read_ahead_stats 0
6594 $READS -f $DIR/$tfile -l $STRIDE_LENGTH -o $OFFSET \
6595 -s $FILE_LENGTH -b $STRIPE_SIZE -a $READ_COUNT -n $ITERATION
6596 cancel_lru_locks osc
6597 ra_check_101 $BSIZE $STRIPE_SIZE $FILE_LENGTH
6602 run_test 101b "check stride-io mode read-ahead ================="
6605 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6606 local STRIPE_SIZE=1048576
6607 local FILE_LENGTH=$((STRIPE_SIZE*100))
6611 setup_test101bc $STRIPE_SIZE $FILE_LENGTH
6613 cancel_lru_locks osc
6614 $LCTL set_param osc.*.rpc_stats 0
6615 $READS -f $DIR/$tfile -s$FILE_LENGTH -b65536 -n$nreads -t 180
6616 for osc_rpc_stats in $($LCTL get_param -N osc.*.rpc_stats); do
6617 local stats=$($LCTL get_param -n $osc_rpc_stats)
6618 local lines=$(echo "$stats" | awk 'END {print NR;}')
6621 if [ $lines -le 20 ]; then
6624 for size in 1 2 4 8; do
6625 local rpc=$(echo "$stats" |
6626 awk '($1 == "'$size':") {print $2; exit; }')
6628 error "Small $((size*4))k read IO $rpc !"
6630 echo "$osc_rpc_stats check passed!"
6635 run_test 101c "check stripe_size aligned read-ahead ================="
6638 $LCTL get_param -n llite.*.max_read_ahead_mb | head -n 1
6639 $LCTL set_param -n llite.*.max_read_ahead_mb $1 > /dev/null 2>&1
6643 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6644 local file=$DIR/$tfile
6645 local sz_MB=${FILESIZE_101d:-500}
6646 local ra_MB=${READAHEAD_MB:-40}
6648 local free_MB=$(($(df -P $DIR | tail -n 1 | awk '{ print $4 }') / 1024))
6649 [ $free_MB -lt $sz_MB ] &&
6650 skip "Need free space ${sz_MB}M, have ${free_MB}M" && return
6652 echo "Create test file $file size ${sz_MB}M, ${free_MB}M free"
6653 $SETSTRIPE -c -1 $file || error "setstripe failed"
6655 dd if=/dev/zero of=$file bs=1M count=$sz_MB || error "dd failed"
6656 echo Cancel LRU locks on lustre client to flush the client cache
6657 cancel_lru_locks osc
6659 echo Disable read-ahead
6660 local old_READAHEAD=$(set_read_ahead 0)
6662 echo Reading the test file $file with read-ahead disabled
6663 local raOFF=$(do_and_time "dd if=$file of=/dev/null bs=1M count=$sz_MB")
6665 echo Cancel LRU locks on lustre client to flush the client cache
6666 cancel_lru_locks osc
6667 echo Enable read-ahead with ${ra_MB}MB
6668 set_read_ahead $ra_MB
6670 echo Reading the test file $file with read-ahead enabled
6671 local raON=$(do_and_time "dd if=$file of=/dev/null bs=1M count=$sz_MB")
6673 echo "read-ahead disabled time read $raOFF"
6674 echo "read-ahead enabled time read $raON"
6676 set_read_ahead $old_READAHEAD
6678 wait_delete_completed
6680 [ $raOFF -le 1 -o $raON -lt $raOFF ] ||
6681 error "readahead ${raON}s > no-readahead ${raOFF}s ${sz_MB}M"
6683 run_test 101d "file read with and without read-ahead enabled"
6686 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6687 local file=$DIR/$tfile
6688 local size_KB=500 #KB
6692 local free_KB=$(df -P $DIR | tail -n 1 | awk '{ print $4 }')
6693 local need_KB=$((count * size_KB))
6694 [[ $free_KB -le $need_KB ]] &&
6695 skip_env "Need free space $need_KB, have $free_KB" && return
6697 echo "Creating $count ${size_KB}K test files"
6698 for ((i = 0; i < $count; i++)); do
6699 dd if=/dev/zero of=$file.$i bs=$bsize count=$size_KB 2>/dev/null
6702 echo "Cancel LRU locks on lustre client to flush the client cache"
6703 cancel_lru_locks osc
6705 echo "Reset readahead stats"
6706 $LCTL set_param -n llite.*.read_ahead_stats 0
6708 for ((i = 0; i < $count; i++)); do
6709 dd if=$file.$i of=/dev/null bs=$bsize count=$size_KB 2>/dev/null
6712 local miss=$($LCTL get_param -n llite.*.read_ahead_stats |
6713 get_named_value 'misses' | cut -d" " -f1 | calc_total)
6715 for ((i = 0; i < $count; i++)); do
6716 rm -rf $file.$i 2>/dev/null
6719 #10000 means 20% reads are missing in readahead
6720 [[ $miss -lt 10000 ]] || error "misses too much for small reads"
6722 run_test 101e "check read-ahead for small read(1k) for small files(500k)"
6725 which iozone || { skip "no iozone installed" && return; }
6727 local old_debug=$($LCTL get_param debug)
6728 old_debug=${old_debug#*=}
6729 $LCTL set_param debug="reada mmap"
6731 # create a test file
6732 iozone -i 0 -+n -r 1m -s 128m -w -f $DIR/$tfile > /dev/null 2>&1
6734 echo Cancel LRU locks on lustre client to flush the client cache
6735 cancel_lru_locks osc
6737 echo Reset readahead stats
6738 $LCTL set_param -n llite.*.read_ahead_stats 0
6740 echo mmap read the file with small block size
6741 iozone -i 1 -u 1 -l 1 -+n -r 32k -s 128m -B -f $DIR/$tfile \
6744 echo checking missing pages
6745 $LCTL get_param llite.*.read_ahead_stats
6746 local miss=$($LCTL get_param -n llite.*.read_ahead_stats |
6747 get_named_value 'misses' | cut -d" " -f1 | calc_total)
6749 $LCTL set_param debug="$old_debug"
6750 [ $miss -lt 3 ] || error "misses too much pages ('$miss')!"
6753 run_test 101f "check mmap read performance"
6755 test_101g_brw_size_test() {
6757 local pages=$((mb * 1048576 / $(page_size)))
6759 $LCTL set_param osc.*.max_pages_per_rpc=${mb}M ||
6760 { error "unable to set max_pages_per_rpc=${mb}M"; return 1; }
6761 for mp in $($LCTL get_param -n osc.*.max_pages_per_rpc); do
6762 [ $mp -ne $pages ] && error "max_pages_per_rpc $mp != $pages" &&
6766 $LCTL set_param -n osc.*.rpc_stats=0
6768 # 10 RPCs should be enough for the test
6770 dd if=/dev/zero of=$DIR/$tfile bs=${mb}M count=$count ||
6771 { error "dd write ${mb} MB blocks failed"; return 3; }
6772 cancel_lru_locks osc
6773 dd of=/dev/null if=$DIR/$tfile bs=${mb}M count=$count ||
6774 { error "dd write ${mb} MB blocks failed"; return 4; }
6776 # calculate number of full-sized read and write RPCs
6777 rpcs=($($LCTL get_param -n 'osc.*.rpc_stats' |
6778 sed -n '/pages per rpc/,/^$/p' |
6779 awk '/'$pages':/ { reads += $2; writes += $5 };' \
6780 'END { print reads,writes }'))
6781 [ ${rpcs[0]} -ne $count ] && error "${rpcs[0]} != $count read RPCs" &&
6783 [ ${rpcs[1]} -ne $count ] && error "${rpcs[1]} != $count write RPCs" &&
6791 local osts=$(get_facets OST)
6792 local list=$(comma_list $(osts_nodes))
6793 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
6794 local brw_size="obdfilter.*.brw_size"
6796 $LFS setstripe -i 0 -c 1 $DIR/$tfile
6798 local orig_mb=$(do_facet ost1 $LCTL get_param -n $brw_size | head -n 1)
6799 if [ $(lustre_version_code ost1) -ge $(version_code 2.8.52) ]; then
6800 [ $(lustre_version_code ost1) -ge $(version_code 2.9.52) ] &&
6802 if [[ $orig_mb < 16 ]]; then
6803 save_lustre_params $osts "$brw_size" > $p
6804 do_nodes $list $LCTL set_param -n $brw_size=16$suffix ||
6805 error "set 16MB RPC size failed"
6807 echo "remount client to enable new RPC size"
6808 remount_client $MOUNT || error "remount_client failed"
6811 test_101g_brw_size_test 16 || error "16MB RPC test failed"
6812 # should be able to set brw_size=12, but no rpc_stats for that
6813 test_101g_brw_size_test 8 || error "8MB RPC test failed"
6816 test_101g_brw_size_test 4 || error "4MB RPC test failed"
6818 if [[ $orig_mb < 16 ]]; then
6819 restore_lustre_params < $p
6820 remount_client $MOUNT || error "remount_client restore failed"
6823 rm -f $p $DIR/$tfile
6825 run_test 101g "Big bulk(4/16 MiB) readahead"
6828 test_mkdir -p $DIR/$tdir
6829 chown $RUNAS_ID $DIR/$tdir
6832 STRIPE_COUNT=$OSTCOUNT
6833 [[ $OSTCOUNT -gt 4 ]] && STRIPE_COUNT=4
6835 trap cleanup_test102 EXIT
6837 $1 $SETSTRIPE -S $STRIPE_SIZE -i $STRIPE_OFFSET -c $STRIPE_COUNT $tdir
6839 for num in 1 2 3 4; do
6840 for count in $(seq 1 $STRIPE_COUNT); do
6841 for idx in $(seq 0 $[$STRIPE_COUNT - 1]); do
6842 local size=`expr $STRIPE_SIZE \* $num`
6843 local file=file"$num-$idx-$count"
6844 $1 $SETSTRIPE -S $size -i $idx -c $count $file
6850 $1 $TAR cf $TMP/f102.tar $tdir --xattrs
6856 rm -rf $DIR/d0.sanity/d102
6860 local testfile=$DIR/$tfile
6864 [ "$UID" != 0 ] && skip_env "must run as root" && return
6865 [ -z "$(lctl get_param -n mdc.*-mdc-*.connect_flags | grep xattr)" ] &&
6866 skip_env "must have user_xattr" && return
6868 [ -z "$(which setfattr 2>/dev/null)" ] &&
6869 skip_env "could not find setfattr" && return
6871 echo "set/get xattr..."
6872 setfattr -n trusted.name1 -v value1 $testfile ||
6873 error "setfattr -n trusted.name1=value1 $testfile failed"
6874 getfattr -n trusted.name1 $testfile 2> /dev/null |
6875 grep "trusted.name1=.value1" ||
6876 error "$testfile missing trusted.name1=value1"
6878 setfattr -n user.author1 -v author1 $testfile ||
6879 error "setfattr -n user.author1=author1 $testfile failed"
6880 getfattr -n user.author1 $testfile 2> /dev/null |
6881 grep "user.author1=.author1" ||
6882 error "$testfile missing trusted.author1=author1"
6885 setfattr -n trusted.name2 -v value2 $testfile ||
6886 error "$testfile unable to set trusted.name2"
6887 setfattr -n trusted.name3 -v value3 $testfile ||
6888 error "$testfile unable to set trusted.name3"
6889 [ $(getfattr -d -m "^trusted" $testfile 2> /dev/null |
6890 grep "trusted.name" | wc -l) -eq 3 ] ||
6891 error "$testfile missing 3 trusted.name xattrs"
6893 setfattr -n user.author2 -v author2 $testfile ||
6894 error "$testfile unable to set user.author2"
6895 setfattr -n user.author3 -v author3 $testfile ||
6896 error "$testfile unable to set user.author3"
6897 [ $(getfattr -d -m "^user" $testfile 2> /dev/null |
6898 grep "user.author" | wc -l) -eq 3 ] ||
6899 error "$testfile missing 3 user.author xattrs"
6901 echo "remove xattr..."
6902 setfattr -x trusted.name1 $testfile ||
6903 error "$testfile error deleting trusted.name1"
6904 getfattr -d -m trusted $testfile 2> /dev/null | grep "trusted.name1" &&
6905 error "$testfile did not delete trusted.name1 xattr"
6907 setfattr -x user.author1 $testfile ||
6908 error "$testfile error deleting user.author1"
6909 getfattr -d -m user $testfile 2> /dev/null | grep "user.author1" &&
6910 error "$testfile did not delete trusted.name1 xattr"
6912 # b10667: setting lustre special xattr be silently discarded
6913 echo "set lustre special xattr ..."
6914 setfattr -n "trusted.lov" -v "invalid value" $testfile ||
6915 error "$testfile allowed setting trusted.lov"
6917 run_test 102a "user xattr test =================================="
6920 [ -z "$(which setfattr 2>/dev/null)" ] &&
6921 skip_env "could not find setfattr" && return
6923 # b10930: get/set/list trusted.lov xattr
6924 echo "get/set/list trusted.lov xattr ..."
6925 [[ $OSTCOUNT -lt 2 ]] && skip_env "skipping 2-stripe test" && return
6926 local testfile=$DIR/$tfile
6927 $SETSTRIPE -S 65536 -i 1 -c $OSTCOUNT $testfile ||
6928 error "setstripe failed"
6929 local STRIPECOUNT=$($GETSTRIPE -c $testfile) ||
6930 error "getstripe failed"
6931 getfattr -d -m "^trusted" $testfile 2>/dev/null | grep "trusted.lov" ||
6932 error "can't get trusted.lov from $testfile"
6934 local testfile2=${testfile}2
6935 local value=$(getfattr -n trusted.lov $testfile 2>/dev/null |
6936 grep "trusted.lov" | sed -e 's/[^=]\+=//')
6939 setfattr -n trusted.lov -v $value $testfile2
6940 local stripe_size=$($GETSTRIPE -S $testfile2)
6941 local stripe_count=$($GETSTRIPE -c $testfile2)
6942 [[ $stripe_size -eq 65536 ]] ||
6943 error "stripe size $stripe_size != 65536"
6944 [[ $stripe_count -eq $STRIPECOUNT ]] ||
6945 error "stripe count $stripe_count != $STRIPECOUNT"
6948 run_test 102b "getfattr/setfattr for trusted.lov EAs ============"
6951 [ -z "$(which setfattr 2>/dev/null)" ] &&
6952 skip_env "could not find setfattr" && return
6954 # b10930: get/set/list lustre.lov xattr
6955 echo "get/set/list lustre.lov xattr ..."
6956 [[ $OSTCOUNT -lt 2 ]] && skip_env "skipping 2-stripe test" && return
6957 test_mkdir -p $DIR/$tdir
6958 chown $RUNAS_ID $DIR/$tdir
6959 local testfile=$DIR/$tdir/$tfile
6960 $RUNAS $SETSTRIPE -S 65536 -i 1 -c $OSTCOUNT $testfile ||
6961 error "setstripe failed"
6962 local STRIPECOUNT=$($RUNAS $GETSTRIPE -c $testfile) ||
6963 error "getstripe failed"
6964 $RUNAS getfattr -d -m "^lustre" $testfile 2> /dev/null | \
6965 grep "lustre.lov" || error "can't get lustre.lov from $testfile"
6967 local testfile2=${testfile}2
6968 local value=`getfattr -n lustre.lov $testfile 2> /dev/null | \
6969 grep "lustre.lov" |sed -e 's/[^=]\+=//' `
6971 $RUNAS $MCREATE $testfile2
6972 $RUNAS setfattr -n lustre.lov -v $value $testfile2
6973 local stripe_size=$($RUNAS $GETSTRIPE -S $testfile2)
6974 local stripe_count=$($RUNAS $GETSTRIPE -c $testfile2)
6975 [ $stripe_size -eq 65536 ] || error "stripe size $stripe_size != 65536"
6976 [ $stripe_count -eq $STRIPECOUNT ] ||
6977 error "stripe count $stripe_count != $STRIPECOUNT"
6979 run_test 102c "non-root getfattr/setfattr for lustre.lov EAs ==========="
6981 compare_stripe_info1() {
6982 local stripe_index_all_zero=true
6984 for num in 1 2 3 4; do
6985 for count in $(seq 1 $STRIPE_COUNT); do
6986 for offset in $(seq 0 $[$STRIPE_COUNT - 1]); do
6987 local size=$((STRIPE_SIZE * num))
6988 local file=file"$num-$offset-$count"
6989 stripe_size=$($LFS getstripe -S $PWD/$file)
6990 [[ $stripe_size -ne $size ]] &&
6991 error "$file: size $stripe_size != $size"
6992 stripe_count=$($LFS getstripe -c $PWD/$file)
6993 # allow fewer stripes to be created, ORI-601
6994 [[ $stripe_count -lt $(((3 * count + 3) / 4)) ]] &&
6995 error "$file: count $stripe_count != $count"
6996 stripe_index=$($LFS getstripe -i $PWD/$file)
6997 [[ $stripe_index -ne 0 ]] &&
6998 stripe_index_all_zero=false
7002 $stripe_index_all_zero &&
7003 error "all files are being extracted starting from OST index 0"
7008 [ -n "$(which tar 2>/dev/null)" ] &&
7009 strings $(which tar) | grep -q "lustre" && echo tar
7013 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7014 # b10930: tar test for trusted.lov xattr
7015 TAR=$(find_lustre_tar)
7016 [ -z "$TAR" ] && skip_env "lustre-aware tar is not installed" && return
7017 [[ $OSTCOUNT -lt 2 ]] && skip_env "skipping N-stripe test" && return
7019 test_mkdir -p $DIR/d102d
7020 $TAR xf $TMP/f102.tar -C $DIR/d102d --xattrs
7022 compare_stripe_info1
7024 run_test 102d "tar restore stripe info from tarfile,not keep osts ==========="
7027 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7028 # b10930: tar test for trusted.lov xattr
7029 TAR=$(find_lustre_tar)
7030 [ -z "$TAR" ] && skip_env "lustre-aware tar is not installed" && return
7031 [[ $OSTCOUNT -lt 2 ]] && skip_env "skipping N-stripe test" && return
7033 test_mkdir -p $DIR/d102f
7035 $TAR cf - --xattrs $tdir | $TAR xf - --xattrs -C $DIR/d102f
7037 compare_stripe_info1
7039 run_test 102f "tar copy files, not keep osts ==========="
7042 local xsize=${1:-1024} # in bytes
7043 local file=$DIR/$tfile
7045 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep xattr)" ] &&
7046 skip "must have user_xattr" && return 0
7047 [ -z "$(which setfattr 2>/dev/null)" ] &&
7048 skip_env "could not find setfattr" && return 0
7049 [ -z "$(which getfattr 2>/dev/null)" ] &&
7050 skip_env "could not find getfattr" && return 0
7054 local value="$(generate_string $xsize)"
7056 local xbig=trusted.big
7057 log "save $xbig on $file"
7058 setfattr -n $xbig -v $value $file ||
7059 error "saving $xbig on $file failed"
7061 local orig=$(get_xattr_value $xbig $file)
7062 [[ "$orig" != "$value" ]] && error "$xbig different after saving $xbig"
7064 local xsml=trusted.sml
7065 log "save $xsml on $file"
7066 setfattr -n $xsml -v val $file || error "saving $xsml on $file failed"
7068 local new=$(get_xattr_value $xbig $file)
7069 [[ "$new" != "$orig" ]] && error "$xbig different after saving $xsml"
7071 log "grow $xsml on $file"
7072 setfattr -n $xsml -v "$value" $file ||
7073 error "growing $xsml on $file failed"
7075 new=$(get_xattr_value $xbig $file)
7076 [[ "$new" != "$orig" ]] && error "$xbig different after growing $xsml"
7077 log "$xbig still valid after growing $xsml"
7082 test_102h() { # bug 15777
7085 run_test 102h "grow xattr from inside inode to external block"
7088 large_xattr_enabled || { skip "large_xattr disabled" && return; }
7089 grow_xattr $(max_xattr_size)
7091 run_test 102ha "grow xattr from inside inode to external inode"
7093 test_102i() { # bug 17038
7094 [ -z "$(which getfattr 2>/dev/null)" ] &&
7095 skip "could not find getfattr" && return
7097 ln -s $DIR/$tfile $DIR/${tfile}link
7098 getfattr -n trusted.lov $DIR/$tfile ||
7099 error "lgetxattr on $DIR/$tfile failed"
7100 getfattr -h -n trusted.lov $DIR/${tfile}link 2>&1 |
7101 grep -i "no such attr" ||
7102 error "error for lgetxattr on $DIR/${tfile}link is not ENODATA"
7103 rm -f $DIR/$tfile $DIR/${tfile}link
7105 run_test 102i "lgetxattr test on symbolic link ============"
7108 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7109 TAR=$(find_lustre_tar)
7110 [ -z "$TAR" ] && skip_env "lustre-aware tar is not installed" && return
7111 [[ $OSTCOUNT -lt 2 ]] && skip_env "skipping N-stripe test" && return
7112 setup_test102 "$RUNAS"
7113 test_mkdir -p $DIR/d102j
7114 chown $RUNAS_ID $DIR/d102j
7115 $RUNAS $TAR xf $TMP/f102.tar -C $DIR/d102j --xattrs
7117 compare_stripe_info1 "$RUNAS"
7119 run_test 102j "non-root tar restore stripe info from tarfile, not keep osts ==="
7122 [ -z "$(which setfattr 2>/dev/null)" ] &&
7123 skip "could not find setfattr" && return
7125 # b22187 just check that does not crash for regular file.
7126 setfattr -n trusted.lov $DIR/$tfile
7127 # b22187 'setfattr -n trusted.lov' should work as remove LOV EA for directories
7128 local test_kdir=$DIR/d102k
7129 test_mkdir $test_kdir
7130 local default_size=`$GETSTRIPE -S $test_kdir`
7131 local default_count=`$GETSTRIPE -c $test_kdir`
7132 local default_offset=`$GETSTRIPE -i $test_kdir`
7133 $SETSTRIPE -S 65536 -i 0 -c $OSTCOUNT $test_kdir ||
7134 error 'dir setstripe failed'
7135 setfattr -n trusted.lov $test_kdir
7136 local stripe_size=`$GETSTRIPE -S $test_kdir`
7137 local stripe_count=`$GETSTRIPE -c $test_kdir`
7138 local stripe_offset=`$GETSTRIPE -i $test_kdir`
7139 [ $stripe_size -eq $default_size ] ||
7140 error "stripe size $stripe_size != $default_size"
7141 [ $stripe_count -eq $default_count ] ||
7142 error "stripe count $stripe_count != $default_count"
7143 [ $stripe_offset -eq $default_offset ] ||
7144 error "stripe offset $stripe_offset != $default_offset"
7145 rm -rf $DIR/$tfile $test_kdir
7147 run_test 102k "setfattr without parameter of value shouldn't cause a crash"
7150 [ -z "$(which getfattr 2>/dev/null)" ] &&
7151 skip "could not find getfattr" && return
7153 # LU-532 trusted. xattr is invisible to non-root
7154 local testfile=$DIR/$tfile
7158 echo "listxattr as user..."
7159 chown $RUNAS_ID $testfile
7160 $RUNAS getfattr -d -m '.*' $testfile 2>&1 |
7161 grep -q "trusted" &&
7162 error "$testfile trusted xattrs are user visible"
7166 run_test 102l "listxattr size test =================================="
7168 test_102m() { # LU-3403 llite: error of listxattr when buffer is small
7169 local path=$DIR/$tfile
7172 listxattr_size_check $path || error "listattr_size_check $path failed"
7174 run_test 102m "Ensure listxattr fails on small bufffer ========"
7178 getxattr() { # getxattr path name
7179 # Return the base64 encoding of the value of xattr name on path.
7183 # # getfattr --absolute-names --encoding=base64 --name=trusted.lov $path
7185 # trusted.lov=0s0AvRCwEAAAAGAAAAAAAAAAAEAAACAAAAAAAQAAEAA...AAAAAAAAA=
7187 # We print just 0s0AvRCwEAAAAGAAAAAAAAAAAEAAACAAAAAAAQAAEAA...AAAAAAAAA=
7189 getfattr --absolute-names --encoding=base64 --name=$name $path |
7190 awk -F= -v name=$name '$1 == name {
7191 print substr($0, index($0, "=") + 1);
7195 test_102n() { # LU-4101 mdt: protect internal xattrs
7196 [ -z "$(which setfattr 2>/dev/null)" ] &&
7197 skip "could not find setfattr" && return
7198 if [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.5.50) ]
7200 skip "MDT < 2.5.50 allows setxattr on internal trusted xattrs"
7204 local file0=$DIR/$tfile.0
7205 local file1=$DIR/$tfile.1
7206 local xattr0=$TMP/$tfile.0
7207 local xattr1=$TMP/$tfile.1
7208 local namelist="lov lma lmv link fid version som hsm"
7212 rm -rf $file0 $file1 $xattr0 $xattr1
7215 # Get 'before' xattrs of $file1.
7216 getfattr --absolute-names --dump --match=- $file1 > $xattr0
7218 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.8.53) ] &&
7219 namelist+=" lfsck_namespace"
7220 for name in $namelist; do
7221 # Try to copy xattr from $file0 to $file1.
7222 value=$(getxattr $file0 trusted.$name 2> /dev/null)
7224 setfattr --name=trusted.$name --value="$value" $file1 ||
7225 error "setxattr 'trusted.$name' failed"
7227 # Try to set a garbage xattr.
7228 value=0sVGhlIHF1aWNrIGJyb3duIGZveCBqdW1wcyBvdmVyIGl0c2VsZi4=
7230 setfattr --name=trusted.$name --value="$value" $file1 ||
7231 error "setxattr 'trusted.$name' failed"
7233 # Try to remove the xattr from $file1. We don't care if this
7234 # appears to succeed or fail, we just don't want there to be
7235 # any changes or crashes.
7236 setfattr --remove=$trusted.$name $file1 2> /dev/null
7239 if [ $(lustre_version_code $SINGLEMDS) -gt $(version_code 2.6.50) ]
7242 # Try to copy xattr from $file0 to $file1.
7243 value=$(getxattr $file0 trusted.$name 2> /dev/null)
7245 setfattr --name=trusted.$name --value="$value" $file1 ||
7246 error "setxattr 'trusted.$name' failed"
7248 # Try to set a garbage xattr.
7249 value=0sVGhlIHF1aWNrIGJyb3duIGZveCBqdW1wcyBvdmVyIGl0c2VsZi4=
7251 setfattr --name=trusted.$name --value="$value" $file1 ||
7252 error "setxattr 'trusted.$name' failed"
7254 # Try to remove the xattr from $file1. We don't care if this
7255 # appears to succeed or fail, we just don't want there to be
7256 # any changes or crashes.
7257 setfattr --remove=$trusted.$name $file1 2> /dev/null
7260 # Get 'after' xattrs of file1.
7261 getfattr --absolute-names --dump --match=- $file1 > $xattr1
7263 if ! diff $xattr0 $xattr1; then
7264 error "before and after xattrs of '$file1' differ"
7267 rm -rf $file0 $file1 $xattr0 $xattr1
7271 run_test 102n "silently ignore setxattr on internal trusted xattrs"
7273 test_102p() { # LU-4703 setxattr did not check ownership
7274 local testfile=$DIR/$tfile
7276 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.5.56) ] &&
7277 skip "MDS needs to be at least 2.5.56" && return
7281 echo "setfacl as user..."
7282 $RUNAS setfacl -m "u:$RUNAS_ID:rwx" $testfile
7283 [ $? -ne 0 ] || error "setfacl by $RUNAS_ID was allowed on $testfile"
7285 echo "setfattr as user..."
7286 setfacl -m "u:$RUNAS_ID:---" $testfile
7287 $RUNAS setfattr -x system.posix_acl_access $testfile
7288 [ $? -ne 0 ] || error "setfattr by $RUNAS_ID was allowed on $testfile"
7290 run_test 102p "check setxattr(2) correctly fails without permission"
7293 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.6.92) ] &&
7294 skip "MDS needs to be at least 2.6.92" && return
7295 orphan_linkea_check $DIR/$tfile || error "orphan_linkea_check"
7297 run_test 102q "flistxattr should not return trusted.link EAs for orphans"
7300 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.6.93) ] &&
7301 skip "MDS needs to be at least 2.6.93" && return
7302 touch $DIR/$tfile || error "touch"
7303 setfattr -n user.$(basename $tfile) $DIR/$tfile || error "setfattr"
7304 getfattr -n user.$(basename $tfile) $DIR/$tfile || error "getfattr"
7305 rm $DIR/$tfile || error "rm"
7308 mkdir -p $DIR/$tdir || error "mkdir"
7309 setfattr -n user.$(basename $tdir) $DIR/$tdir || error "setfattr dir"
7310 getfattr -n user.$(basename $tdir) $DIR/$tdir || error "getfattr dir"
7311 setfattr -x user.$(basename $tdir) $DIR/$tdir ||
7312 error "$testfile error deleting user.author1"
7313 getfattr -d -m user.$(basename $tdir) 2> /dev/null |
7314 grep "user.$(basename $tdir)" &&
7315 error "$tdir did not delete user.$(basename $tdir)"
7316 rmdir $DIR/$tdir || error "rmdir"
7319 test_mkdir -p $DIR/$tdir || error "make striped dir"
7320 setfattr -n user.$(basename $tdir) $DIR/$tdir || error "setfattr dir"
7321 getfattr -n user.$(basename $tdir) $DIR/$tdir || error "getfattr dir"
7322 setfattr -x user.$(basename $tdir) $DIR/$tdir ||
7323 error "$testfile error deleting user.author1"
7324 getfattr -d -m user.$(basename $tdir) 2> /dev/null |
7325 grep "user.$(basename $tdir)" &&
7326 error "$tdir did not delete user.$(basename $tdir)"
7327 rmdir $DIR/$tdir || error "rm striped dir"
7329 run_test 102r "set EAs with empty values"
7333 $LUSTRE/tests/acl/run $LUSTRE/tests/acl/$1.test
7338 [ "$UID" != 0 ] && skip_env "must run as root" && return
7339 [ -z "$(lctl get_param -n mdc.*-mdc-*.connect_flags | grep acl)" ] &&
7340 skip "must have acl enabled" && return
7341 [ -z "$(which setfacl 2>/dev/null)" ] &&
7342 skip_env "could not find setfacl" && return
7343 $GSS && skip "could not run under gss" && return
7344 remote_mds_nodsh && skip "remote MDS with nodsh" && return
7346 gpasswd -a daemon bin # LU-5641
7347 do_facet $SINGLEMDS gpasswd -a daemon bin # LU-5641
7349 declare -a identity_old
7351 for num in $(seq $MDSCOUNT); do
7352 switch_identity $num true || identity_old[$num]=$?
7360 echo "performing cp ..."
7361 run_acl_subtest cp || error "run_acl_subtest cp failed"
7362 echo "performing getfacl-noacl..."
7363 run_acl_subtest getfacl-noacl || error "getfacl-noacl test failed"
7364 echo "performing misc..."
7365 run_acl_subtest misc || error "misc test failed"
7366 echo "performing permissions..."
7367 run_acl_subtest permissions || error "permissions failed"
7368 # LU-1482 mdd: Setting xattr are properly checked with and without ACLs
7369 if [ $(lustre_version_code $SINGLEMDS) -gt $(version_code 2.8.55) -o \
7370 \( $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.6) -a \
7371 $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.5.29) \) ]
7373 echo "performing permissions xattr..."
7374 run_acl_subtest permissions_xattr ||
7375 error "permissions_xattr failed"
7377 echo "performing setfacl..."
7378 run_acl_subtest setfacl || error "setfacl test failed"
7380 # inheritance test got from HP
7381 echo "performing inheritance..."
7382 cp $LUSTRE/tests/acl/make-tree . || error "cannot copy make-tree"
7383 chmod +x make-tree || error "chmod +x failed"
7384 run_acl_subtest inheritance || error "inheritance test failed"
7387 echo "LU-974 ignore umask when acl is enabled..."
7388 run_acl_subtest 974 || error "LU-974 umask test failed"
7389 if [ $MDSCOUNT -ge 2 ]; then
7390 run_acl_subtest 974_remote ||
7391 error "LU-974 umask test failed under remote dir"
7394 echo "LU-2561 newly created file is same size as directory..."
7395 if [ $(facet_fstype $SINGLEMDS) != "zfs" ]; then
7396 run_acl_subtest 2561 || error "LU-2561 test failed"
7398 run_acl_subtest 2561_zfs || error "LU-2561 zfs test failed"
7401 run_acl_subtest 4924 || error "LU-4924 test failed"
7406 for num in $(seq $MDSCOUNT); do
7407 if [ "${identity_old[$num]}" = 1 ]; then
7408 switch_identity $num false || identity_old[$num]=$?
7412 run_test 103a "acl test ========================================="
7415 remote_mds_nodsh && skip "remote MDS with nodsh" && return
7417 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
7418 local mountopts=$MDS_MOUNT_OPTS
7420 if [[ "$MDS_MOUNT_OPTS" =~ "noacl" ]]; then
7424 stop $SINGLEMDS || error "failed to stop MDT."
7426 if [ -z "$MDS_MOUNT_OPTS" ]; then
7427 MDS_MOUNT_OPTS="-o noacl"
7429 MDS_MOUNT_OPTS="${MDS_MOUNT_OPTS},noacl"
7431 start $SINGLEMDS $MDT_DEV $MDS_MOUNT_OPTS ||
7432 error "failed to start MDT."
7433 MDS_MOUNT_OPTS=$mountopts
7437 setfacl -m u:bin:rw $DIR/$tfile && error "setfacl should fail"
7441 stop $SINGLEMDS || error "failed to stop MDT."
7443 start $SINGLEMDS $MDT_DEV $MDS_MOUNT_OPTS ||
7444 error "failed to start MDT."
7449 run_test 103b "MDS mount option 'noacl'"
7453 cp -rp $DIR/$tdir $DIR/$tdir.bak
7455 [ -n "$(getfattr -d -m. $DIR/$tdir | grep posix_acl_default)" ] &&
7456 error "$DIR/$tdir shouldn't contain default ACL"
7457 [ -n "$(getfattr -d -m. $DIR/$tdir.bak | grep posix_acl_default)" ] &&
7458 error "$DIR/$tdir.bak shouldn't contain default ACL"
7461 run_test 103c "'cp -rp' won't set empty acl"
7464 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7466 lfs df || error "lfs df failed"
7467 lfs df -ih || error "lfs df -ih failed"
7468 lfs df -h $DIR || error "lfs df -h $DIR failed"
7469 lfs df -i $DIR || error "lfs df -i $DIR failed"
7470 lfs df $DIR/$tfile || error "lfs df $DIR/$tfile failed"
7471 lfs df -ih $DIR/$tfile || error "lfs df -ih $DIR/$tfile failed"
7473 local OSC=$(lctl dl | grep OST0000-osc-[^M] | awk '{ print $4 }')
7474 lctl --device %$OSC deactivate
7475 lfs df || error "lfs df with deactivated OSC failed"
7476 lctl --device %$OSC activate
7477 # wait the osc back to normal
7478 wait_osc_import_state client ost FULL
7480 lfs df || error "lfs df with reactivated OSC failed"
7483 run_test 104a "lfs df [-ih] [path] test ========================="
7486 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7487 [ $RUNAS_ID -eq $UID ] &&
7488 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
7490 denied_cnt=$(($($RUNAS $LFS check servers 2>&1 |
7491 grep "Permission denied" | wc -l)))
7492 if [ $denied_cnt -ne 0 ]; then
7493 error "lfs check servers test failed"
7496 run_test 104b "$RUNAS lfs check servers test ===================="
7499 # doesn't work on 2.4 kernels
7501 if $(flock_is_enabled); then
7502 flocks_test 1 on -f $DIR/$tfile || error "fail flock on"
7504 flocks_test 1 off -f $DIR/$tfile || error "fail flock off"
7508 run_test 105a "flock when mounted without -o flock test ========"
7512 if $(flock_is_enabled); then
7513 flocks_test 1 on -c $DIR/$tfile || error "fail flock on"
7515 flocks_test 1 off -c $DIR/$tfile || error "fail flock off"
7519 run_test 105b "fcntl when mounted without -o flock test ========"
7523 if $(flock_is_enabled); then
7524 flocks_test 1 on -l $DIR/$tfile || error "fail flock on"
7526 flocks_test 1 off -l $DIR/$tfile || error "fail flock off"
7530 run_test 105c "lockf when mounted without -o flock test ========"
7532 test_105d() { # bug 15924
7533 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7534 test_mkdir -p $DIR/$tdir
7535 flock_is_enabled || { skip "mount w/o flock enabled" && return; }
7536 #define OBD_FAIL_LDLM_CP_CB_WAIT 0x315
7537 $LCTL set_param fail_loc=0x80000315
7538 flocks_test 2 $DIR/$tdir
7540 run_test 105d "flock race (should not freeze) ========"
7542 test_105e() { # bug 22660 && 22040
7543 flock_is_enabled || { skip "mount w/o flock enabled" && return; }
7545 flocks_test 3 $DIR/$tfile
7547 run_test 105e "Two conflicting flocks from same process ======="
7549 test_106() { #bug 10921
7550 test_mkdir -p $DIR/$tdir
7551 $DIR/$tdir && error "exec $DIR/$tdir succeeded"
7552 chmod 777 $DIR/$tdir || error "chmod $DIR/$tdir failed"
7554 run_test 106 "attempt exec of dir followed by chown of that dir"
7557 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7564 local save_pattern=$(sysctl -n kernel.core_pattern)
7565 local save_uses_pid=$(sysctl -n kernel.core_uses_pid)
7566 sysctl -w kernel.core_pattern=$file
7567 sysctl -w kernel.core_uses_pid=0
7575 kill -s 11 $SLEEPPID
7577 if [ -e $file ]; then
7578 size=`stat -c%s $file`
7579 [ $size -eq 0 ] && error "Fail to create core file $file"
7581 error "Fail to create core file $file"
7584 sysctl -w kernel.core_pattern=$save_pattern
7585 sysctl -w kernel.core_uses_pid=$save_uses_pid
7588 run_test 107 "Coredump on SIG"
7591 test_mkdir -p $DIR/$tdir
7592 test_mkdir $DIR/$tdir/$(str_repeat 'a' 255) ||
7593 error "mkdir with 255 char failed"
7594 test_mkdir $DIR/$tdir/$(str_repeat 'b' 256) &&
7595 error "mkdir with 256 char should fail, but did not"
7596 touch $DIR/$tdir/$(str_repeat 'x' 255) ||
7597 error "create with 255 char failed"
7598 touch $DIR/$tdir/$(str_repeat 'y' 256) &&
7599 error "create with 256 char should fail, but did not"
7604 run_test 110 "filename length checking"
7607 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7608 OSTIO_pre=$(ps -e | grep ll_ost_io | awk '{ print $4 }'| sort -n |
7609 tail -1 | cut -c11-20)
7610 [ -z "$OSTIO_pre" ] && skip "no OSS threads" && return
7611 echo "Starting with $OSTIO_pre threads"
7614 NUMFREE=$(df -i -P $DIR | tail -n 1 | awk '{ print $4 }')
7615 [[ $NUMFREE -lt $NUMTEST ]] && NUMTEST=$(($NUMFREE - 1000))
7616 echo "$NUMTEST creates/unlinks"
7617 test_mkdir -p $DIR/$tdir
7618 createmany -o $DIR/$tdir/$tfile $NUMTEST
7619 unlinkmany $DIR/$tdir/$tfile $NUMTEST
7621 OSTIO_post=$(ps -e | grep ll_ost_io | awk '{ print $4 }' | sort -n |
7622 tail -1 | cut -c11-20)
7624 # don't return an error
7625 [ $OSTIO_post == $OSTIO_pre ] && echo \
7626 "WARNING: No new ll_ost_io threads were created ($OSTIO_pre)" &&
7627 echo "This may be fine, depending on what ran before this test" &&
7628 echo "and how fast this system is." && return
7630 echo "Started with $OSTIO_pre threads, ended with $OSTIO_post"
7632 run_test 115 "verify dynamic thread creation===================="
7635 wait_delete_completed
7636 AVAIL=($(lctl get_param -n osc.*[oO][sS][cC]-[^M]*.kbytesavail))
7637 echo "OST kbytes available: ${AVAIL[@]}"
7642 for ((i = 0; i < ${#AVAIL[@]}; i++)); do
7643 #echo OST $i: ${AVAIL[i]}kb
7644 if [[ ${AVAIL[i]} -gt $MAXV ]]; then
7648 if [[ ${AVAIL[i]} -lt $MINV ]]; then
7653 echo "Min free space: OST $MINI: $MINV"
7654 echo "Max free space: OST $MAXI: $MAXV"
7657 test_116a() { # was previously test_116()
7658 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7659 remote_mds_nodsh && skip "remote MDS with nodsh" && return
7661 [[ $OSTCOUNT -lt 2 ]] && skip_env "$OSTCOUNT < 2 OSTs" && return
7663 echo -n "Free space priority "
7664 do_facet $SINGLEMDS lctl get_param -n lo*.*-mdtlov.qos_prio_free |
7669 [ $MINV -eq 0 ] && skip "no free space in OST$MINI, skip" && return
7670 [ $MINV -gt 10000000 ] && skip "too much free space in OST$MINI, skip" \
7672 trap simple_cleanup_common EXIT
7675 # Check if we need to generate uneven OSTs
7676 test_mkdir -p $DIR/$tdir/OST${MINI}
7677 local FILL=$((MINV / 4))
7678 local DIFF=$((MAXV - MINV))
7679 local DIFF2=$((DIFF * 100 / MINV))
7681 local threshold=$(do_facet $SINGLEMDS \
7682 lctl get_param -n *.*MDT0000-mdtlov.qos_threshold_rr | head -n1)
7683 threshold=${threshold%%%}
7684 echo -n "Check for uneven OSTs: "
7685 echo -n "diff=${DIFF}KB (${DIFF2}%) must be > ${threshold}% ..."
7687 if [[ $DIFF2 -gt $threshold ]]; then
7689 echo "Don't need to fill OST$MINI"
7691 # generate uneven OSTs. Write 2% over the QOS threshold value
7693 DIFF=$((threshold - DIFF2 + 2))
7694 DIFF2=$((MINV * DIFF / 100))
7695 echo "Fill $DIFF% remaining space in OST$MINI with ${DIFF2}KB"
7696 $SETSTRIPE -i $MINI -c 1 $DIR/$tdir/OST${MINI} ||
7697 error "setstripe failed"
7698 DIFF=$((DIFF2 / 2048))
7700 while [ $i -lt $DIFF ]; do
7702 dd if=/dev/zero of=$DIR/$tdir/OST${MINI}/$tfile-$i \
7703 bs=2M count=1 2>/dev/null
7712 DIFF=$((MAXV - MINV))
7713 DIFF2=$((DIFF * 100 / MINV))
7714 echo -n "diff=$DIFF=$DIFF2% must be > $threshold% for QOS mode..."
7715 if [ $DIFF2 -gt $threshold ]; then
7718 echo "failed - QOS mode won't be used"
7719 skip "QOS imbalance criteria not met"
7720 simple_cleanup_common
7729 # now fill using QOS
7730 $SETSTRIPE -c 1 $DIR/$tdir
7731 FILL=$((FILL / 200))
7732 if [ $FILL -gt 600 ]; then
7735 echo "writing $FILL files to QOS-assigned OSTs"
7737 while [ $i -lt $FILL ]; do
7739 dd if=/dev/zero of=$DIR/$tdir/$tfile-$i bs=200k \
7743 echo "wrote $i 200k files"
7747 echo "Note: free space may not be updated, so measurements might be off"
7749 DIFF2=$((MAXV - MINV))
7750 echo "free space delta: orig $DIFF final $DIFF2"
7751 [ $DIFF2 -gt $DIFF ] && echo "delta got worse!"
7752 DIFF=$((MINV1 - ${AVAIL[$MINI1]}))
7753 echo "Wrote ${DIFF}KB to smaller OST $MINI1"
7754 DIFF2=$((MAXV1 - ${AVAIL[$MAXI1]}))
7755 echo "Wrote ${DIFF2}KB to larger OST $MAXI1"
7756 if [[ $DIFF -gt 0 ]]; then
7757 FILL=$((DIFF2 * 100 / DIFF - 100))
7758 echo "Wrote ${FILL}% more data to larger OST $MAXI1"
7761 # Figure out which files were written where
7762 UUID=$(lctl get_param -n lov.${FSNAME}-clilov-*.target_obd |
7763 awk '/'$MINI1': / {print $2; exit}')
7765 MINC=$($GETSTRIPE --ost $UUID $DIR/$tdir | grep $DIR | wc -l)
7766 echo "$MINC files created on smaller OST $MINI1"
7767 UUID=$(lctl get_param -n lov.${FSNAME}-clilov-*.target_obd |
7768 awk '/'$MAXI1': / {print $2; exit}')
7770 MAXC=$($GETSTRIPE --ost $UUID $DIR/$tdir | grep $DIR | wc -l)
7771 echo "$MAXC files created on larger OST $MAXI1"
7772 if [[ $MINC -gt 0 ]]; then
7773 FILL=$((MAXC * 100 / MINC - 100))
7774 echo "Wrote ${FILL}% more files to larger OST $MAXI1"
7776 [[ $MAXC -gt $MINC ]] ||
7777 error_ignore LU-9 "stripe QOS didn't balance free space"
7778 simple_cleanup_common
7780 run_test 116a "stripe QOS: free space balance ==================="
7782 test_116b() { # LU-2093
7783 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7784 remote_mds_nodsh && skip "remote MDS with nodsh" && return
7786 #define OBD_FAIL_MDS_OSC_CREATE_FAIL 0x147
7787 local old_rr=$(do_facet $SINGLEMDS lctl get_param -n \
7788 lo*.$FSNAME-MDT0000-mdtlov.qos_threshold_rr | head -1)
7789 [ -z "$old_rr" ] && skip "no QOS" && return 0
7790 do_facet $SINGLEMDS lctl set_param \
7791 lo*.$FSNAME-MDT0000-mdtlov.qos_threshold_rr=0
7793 do_facet $SINGLEMDS lctl set_param fail_loc=0x147
7794 createmany -o $DIR/$tdir/f- 20 || error "can't create"
7795 do_facet $SINGLEMDS lctl set_param fail_loc=0
7797 do_facet $SINGLEMDS lctl set_param \
7798 lo*.$FSNAME-MDT0000-mdtlov.qos_threshold_rr=$old_rr
7800 run_test 116b "QoS shouldn't LBUG if not enough OSTs found on the 2nd pass"
7802 test_117() # bug 10891
7804 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7805 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1
7806 #define OBD_FAIL_OST_SETATTR_CREDITS 0x21e
7807 lctl set_param fail_loc=0x21e
7808 > $DIR/$tfile || error "truncate failed"
7809 lctl set_param fail_loc=0
7810 echo "Truncate succeeded."
7813 run_test 117 "verify osd extend =========="
7815 NO_SLOW_RESENDCOUNT=4
7816 export OLD_RESENDCOUNT=""
7817 set_resend_count () {
7818 local PROC_RESENDCOUNT="osc.${FSNAME}-OST*-osc-*.resend_count"
7819 OLD_RESENDCOUNT=$(lctl get_param -n $PROC_RESENDCOUNT | head -n1)
7820 lctl set_param -n $PROC_RESENDCOUNT $1
7821 echo resend_count is set to $(lctl get_param -n $PROC_RESENDCOUNT)
7824 # for reduce test_118* time (b=14842)
7825 [ "$SLOW" = "no" ] && set_resend_count $NO_SLOW_RESENDCOUNT
7827 # Reset async IO behavior after error case
7829 FILE=$DIR/reset_async
7831 # Ensure all OSCs are cleared
7832 $SETSTRIPE -c -1 $FILE
7833 dd if=/dev/zero of=$FILE bs=64k count=$OSTCOUNT
7838 test_118a() #bug 11710
7840 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7843 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
7844 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
7845 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
7847 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
7848 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
7853 run_test 118a "verify O_SYNC works =========="
7857 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7858 remote_ost_nodsh && skip "remote OST with nodsh" && return
7862 #define OBD_FAIL_SRV_ENOENT 0x217
7863 set_nodes_failloc "$(osts_nodes)" 0x217
7864 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
7866 set_nodes_failloc "$(osts_nodes)" 0
7867 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
7868 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
7871 if [[ $RC -eq 0 ]]; then
7872 error "Must return error due to dropped pages, rc=$RC"
7876 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
7877 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
7881 echo "Dirty pages not leaked on ENOENT"
7883 # Due to the above error the OSC will issue all RPCs syncronously
7884 # until a subsequent RPC completes successfully without error.
7885 $MULTIOP $DIR/$tfile Ow4096yc
7890 run_test 118b "Reclaim dirty pages on fatal error =========="
7894 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7896 # for 118c, restore the original resend count, LU-1940
7897 [ "$SLOW" = "no" ] && [ -n "$OLD_RESENDCOUNT" ] &&
7898 set_resend_count $OLD_RESENDCOUNT
7899 remote_ost_nodsh && skip "remote OST with nodsh" && return
7903 #define OBD_FAIL_OST_EROFS 0x216
7904 set_nodes_failloc "$(osts_nodes)" 0x216
7906 # multiop should block due to fsync until pages are written
7907 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
7911 if [[ `ps h -o comm -p $MULTIPID` != "multiop" ]]; then
7912 error "Multiop failed to block on fsync, pid=$MULTIPID"
7915 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
7917 if [[ $WRITEBACK -eq 0 ]]; then
7918 error "No page in writeback, writeback=$WRITEBACK"
7921 set_nodes_failloc "$(osts_nodes)" 0
7924 if [[ $RC -ne 0 ]]; then
7925 error "Multiop fsync failed, rc=$RC"
7928 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
7929 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
7931 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
7932 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
7936 echo "Dirty pages flushed via fsync on EROFS"
7939 run_test 118c "Fsync blocks on EROFS until dirty pages are flushed =========="
7941 # continue to use small resend count to reduce test_118* time (b=14842)
7942 [ "$SLOW" = "no" ] && set_resend_count $NO_SLOW_RESENDCOUNT
7946 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7947 remote_ost_nodsh && skip "remote OST with nodsh" && return
7951 #define OBD_FAIL_OST_BRW_PAUSE_BULK
7952 set_nodes_failloc "$(osts_nodes)" 0x214
7953 # multiop should block due to fsync until pages are written
7954 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
7958 if [[ `ps h -o comm -p $MULTIPID` != "multiop" ]]; then
7959 error "Multiop failed to block on fsync, pid=$MULTIPID"
7962 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
7964 if [[ $WRITEBACK -eq 0 ]]; then
7965 error "No page in writeback, writeback=$WRITEBACK"
7968 wait $MULTIPID || error "Multiop fsync failed, rc=$?"
7969 set_nodes_failloc "$(osts_nodes)" 0
7971 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
7972 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
7974 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
7975 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
7979 echo "Dirty pages gaurenteed flushed via fsync"
7982 run_test 118d "Fsync validation inject a delay of the bulk =========="
7985 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7988 #define OBD_FAIL_OSC_BRW_PREP_REQ2 0x40a
7989 lctl set_param fail_loc=0x8000040a
7991 # Should simulate EINVAL error which is fatal
7992 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
7994 if [[ $RC -eq 0 ]]; then
7995 error "Must return error due to dropped pages, rc=$RC"
7998 lctl set_param fail_loc=0x0
8000 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
8001 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
8002 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
8004 if [[ $LOCKED -ne 0 ]]; then
8005 error "Locked pages remain in cache, locked=$LOCKED"
8008 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
8009 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
8013 echo "No pages locked after fsync"
8018 run_test 118f "Simulate unrecoverable OSC side error =========="
8021 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8024 #define OBD_FAIL_OSC_BRW_PREP_REQ 0x406
8025 lctl set_param fail_loc=0x406
8027 # simulate local -ENOMEM
8028 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
8031 lctl set_param fail_loc=0
8032 if [[ $RC -eq 0 ]]; then
8033 error "Must return error due to dropped pages, rc=$RC"
8036 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
8037 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
8038 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
8040 if [[ $LOCKED -ne 0 ]]; then
8041 error "Locked pages remain in cache, locked=$LOCKED"
8044 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
8045 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
8049 echo "No pages locked after fsync"
8054 run_test 118g "Don't stay in wait if we got local -ENOMEM =========="
8057 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8058 remote_ost_nodsh && skip "remote OST with nodsh" && return
8062 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
8063 set_nodes_failloc "$(osts_nodes)" 0x20e
8064 # Should simulate ENOMEM error which is recoverable and should be handled by timeout
8065 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
8068 set_nodes_failloc "$(osts_nodes)" 0
8069 if [[ $RC -eq 0 ]]; then
8070 error "Must return error due to dropped pages, rc=$RC"
8073 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
8074 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
8075 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
8077 if [[ $LOCKED -ne 0 ]]; then
8078 error "Locked pages remain in cache, locked=$LOCKED"
8081 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
8082 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
8086 echo "No pages locked after fsync"
8090 run_test 118h "Verify timeout in handling recoverables errors =========="
8092 [ "$SLOW" = "no" ] && [ -n "$OLD_RESENDCOUNT" ] && set_resend_count $OLD_RESENDCOUNT
8095 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8096 remote_ost_nodsh && skip "remote OST with nodsh" && return
8100 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
8101 set_nodes_failloc "$(osts_nodes)" 0x20e
8103 # Should simulate ENOMEM error which is recoverable and should be handled by timeout
8104 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
8107 set_nodes_failloc "$(osts_nodes)" 0
8111 if [[ $RC -ne 0 ]]; then
8112 error "got error, but should be not, rc=$RC"
8115 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
8116 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
8117 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
8118 if [[ $LOCKED -ne 0 ]]; then
8119 error "Locked pages remain in cache, locked=$LOCKED"
8122 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
8123 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
8127 echo "No pages locked after fsync"
8131 run_test 118i "Fix error before timeout in recoverable error =========="
8133 [ "$SLOW" = "no" ] && set_resend_count 4
8136 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8137 remote_ost_nodsh && skip "remote OST with nodsh" && return
8141 #define OBD_FAIL_OST_BRW_WRITE_BULK2 0x220
8142 set_nodes_failloc "$(osts_nodes)" 0x220
8144 # return -EIO from OST
8145 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
8147 set_nodes_failloc "$(osts_nodes)" 0x0
8148 if [[ $RC -eq 0 ]]; then
8149 error "Must return error due to dropped pages, rc=$RC"
8152 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
8153 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
8154 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
8155 if [[ $LOCKED -ne 0 ]]; then
8156 error "Locked pages remain in cache, locked=$LOCKED"
8159 # in recoverable error on OST we want resend and stay until it finished
8160 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
8161 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
8165 echo "No pages locked after fsync"
8169 run_test 118j "Simulate unrecoverable OST side error =========="
8173 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8174 remote_ost_nodsh && skip "remote OSTs with nodsh" && return
8176 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
8177 set_nodes_failloc "$(osts_nodes)" 0x20e
8178 test_mkdir -p $DIR/$tdir
8180 for ((i=0;i<10;i++)); do
8181 (dd if=/dev/zero of=$DIR/$tdir/$tfile-$i bs=1M count=10 || \
8182 error "dd to $DIR/$tdir/$tfile-$i failed" )&
8189 set_nodes_failloc "$(osts_nodes)" 0
8192 run_test 118k "bio alloc -ENOMEM and IO TERM handling ========="
8196 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8198 test_mkdir -p $DIR/$tdir
8199 $MULTIOP $DIR/$tdir Dy || error "fsync dir failed"
8202 run_test 118l "fsync dir ========="
8204 test_118m() # LU-3066
8206 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8207 test_mkdir -p $DIR/$tdir
8208 $MULTIOP $DIR/$tdir DY || error "fdatasync dir failed"
8211 run_test 118m "fdatasync dir ========="
8213 [ "$SLOW" = "no" ] && [ -n "$OLD_RESENDCOUNT" ] && set_resend_count $OLD_RESENDCOUNT
8215 test_119a() # bug 11737
8217 BSIZE=$((512 * 1024))
8218 directio write $DIR/$tfile 0 1 $BSIZE
8219 # We ask to read two blocks, which is more than a file size.
8220 # directio will indicate an error when requested and actual
8221 # sizes aren't equeal (a normal situation in this case) and
8222 # print actual read amount.
8223 NOB=`directio read $DIR/$tfile 0 2 $BSIZE | awk '/error/ {print $6}'`
8224 if [ "$NOB" != "$BSIZE" ]; then
8225 error "read $NOB bytes instead of $BSIZE"
8229 run_test 119a "Short directIO read must return actual read amount"
8231 test_119b() # bug 11737
8233 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping 2-stripe test" && return
8235 $SETSTRIPE -c 2 $DIR/$tfile || error "setstripe failed"
8236 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=1 || error "dd failed"
8238 $MULTIOP $DIR/$tfile oO_RDONLY:O_DIRECT:r$((2048 * 1024)) || \
8239 error "direct read failed"
8242 run_test 119b "Sparse directIO read must return actual read amount"
8244 test_119c() # bug 13099
8247 directio write $DIR/$tfile 3 1 $BSIZE || error "direct write failed"
8248 directio readhole $DIR/$tfile 0 2 $BSIZE || error "reading hole failed"
8251 run_test 119c "Testing for direct read hitting hole"
8253 test_119d() # bug 15950
8255 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8256 MAX_RPCS_IN_FLIGHT=`$LCTL get_param -n osc.*OST0000-osc-[^mM]*.max_rpcs_in_flight`
8257 $LCTL set_param -n osc.*OST0000-osc-[^mM]*.max_rpcs_in_flight 1
8259 $SETSTRIPE $DIR/$tfile -i 0 -c 1 || error "setstripe failed"
8260 $DIRECTIO write $DIR/$tfile 0 1 $BSIZE || error "first directio failed"
8261 #define OBD_FAIL_OSC_DIO_PAUSE 0x40d
8262 lctl set_param fail_loc=0x40d
8263 $DIRECTIO write $DIR/$tfile 1 4 $BSIZE &
8266 cat $DIR/$tfile > /dev/null &
8267 lctl set_param fail_loc=0
8270 log "the DIO writes have completed, now wait for the reads (should not block very long)"
8272 [ -n "`ps h -p $pid_reads -o comm`" ] && \
8273 error "the read rpcs have not completed in 2s"
8275 $LCTL set_param -n osc.*OST0000-osc-[^mM]*.max_rpcs_in_flight $MAX_RPCS_IN_FLIGHT
8277 run_test 119d "The DIO path should try to send a new rpc once one is completed"
8280 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8281 remote_mds_nodsh && skip "remote MDS with nodsh" && return
8282 test_mkdir -p $DIR/$tdir
8283 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
8284 skip "no early lock cancel on server" && return 0
8286 lru_resize_disable mdc
8287 lru_resize_disable osc
8288 cancel_lru_locks mdc
8289 # asynchronous object destroy at MDT could cause bl ast to client
8290 cancel_lru_locks osc
8292 stat $DIR/$tdir > /dev/null
8293 can1=$(do_facet $SINGLEMDS \
8294 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8295 awk '/ldlm_cancel/ {print $2}')
8296 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8297 awk '/ldlm_bl_callback/ {print $2}')
8298 test_mkdir -c1 $DIR/$tdir/d1
8299 can2=$(do_facet $SINGLEMDS \
8300 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8301 awk '/ldlm_cancel/ {print $2}')
8302 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8303 awk '/ldlm_bl_callback/ {print $2}')
8304 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
8305 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
8306 lru_resize_enable mdc
8307 lru_resize_enable osc
8309 run_test 120a "Early Lock Cancel: mkdir test"
8312 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8313 remote_mds_nodsh && skip "remote MDS with nodsh" && return
8314 test_mkdir $DIR/$tdir
8315 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel)" ] && \
8316 skip "no early lock cancel on server" && return 0
8317 lru_resize_disable mdc
8318 lru_resize_disable osc
8319 cancel_lru_locks mdc
8320 stat $DIR/$tdir > /dev/null
8321 can1=$(do_facet $SINGLEMDS \
8322 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8323 awk '/ldlm_cancel/ {print $2}')
8324 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8325 awk '/ldlm_bl_callback/ {print $2}')
8327 can2=$(do_facet $SINGLEMDS \
8328 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8329 awk '/ldlm_cancel/ {print $2}')
8330 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8331 awk '/ldlm_bl_callback/ {print $2}')
8332 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
8333 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
8334 lru_resize_enable mdc
8335 lru_resize_enable osc
8337 run_test 120b "Early Lock Cancel: create test"
8340 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8341 remote_mds_nodsh && skip "remote MDS with nodsh" && return
8342 test_mkdir -c1 $DIR/$tdir
8343 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel)" ] && \
8344 skip "no early lock cancel on server" && return 0
8345 lru_resize_disable mdc
8346 lru_resize_disable osc
8347 test_mkdir -p -c1 $DIR/$tdir/d1
8348 test_mkdir -p -c1 $DIR/$tdir/d2
8349 touch $DIR/$tdir/d1/f1
8350 cancel_lru_locks mdc
8351 stat $DIR/$tdir/d1 $DIR/$tdir/d2 $DIR/$tdir/d1/f1 > /dev/null
8352 can1=$(do_facet $SINGLEMDS \
8353 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8354 awk '/ldlm_cancel/ {print $2}')
8355 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8356 awk '/ldlm_bl_callback/ {print $2}')
8357 ln $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2
8358 can2=$(do_facet $SINGLEMDS \
8359 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8360 awk '/ldlm_cancel/ {print $2}')
8361 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8362 awk '/ldlm_bl_callback/ {print $2}')
8363 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
8364 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
8365 lru_resize_enable mdc
8366 lru_resize_enable osc
8368 run_test 120c "Early Lock Cancel: link test"
8371 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8372 remote_mds_nodsh && skip "remote MDS with nodsh" && return
8373 test_mkdir -p -c1 $DIR/$tdir
8374 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel)" ] && \
8375 skip "no early lock cancel on server" && return 0
8376 lru_resize_disable mdc
8377 lru_resize_disable osc
8379 cancel_lru_locks mdc
8380 stat $DIR/$tdir > /dev/null
8381 can1=$(do_facet $SINGLEMDS \
8382 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8383 awk '/ldlm_cancel/ {print $2}')
8384 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8385 awk '/ldlm_bl_callback/ {print $2}')
8386 chmod a+x $DIR/$tdir
8387 can2=$(do_facet $SINGLEMDS \
8388 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8389 awk '/ldlm_cancel/ {print $2}')
8390 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8391 awk '/ldlm_bl_callback/ {print $2}')
8392 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
8393 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
8394 lru_resize_enable mdc
8395 lru_resize_enable osc
8397 run_test 120d "Early Lock Cancel: setattr test"
8400 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8401 ! $($LCTL get_param -n mdc.*.connect_flags | grep -q early_lock_can) &&
8402 skip "no early lock cancel on server" && return 0
8403 remote_mds_nodsh && skip "remote MDS with nodsh" && return
8404 local dlmtrace_set=false
8406 test_mkdir -p -c1 $DIR/$tdir
8407 lru_resize_disable mdc
8408 lru_resize_disable osc
8409 ! $LCTL get_param debug | grep -q dlmtrace &&
8410 $LCTL set_param debug=+dlmtrace && dlmtrace_set=true
8411 dd if=/dev/zero of=$DIR/$tdir/f1 count=1
8412 cancel_lru_locks mdc
8413 cancel_lru_locks osc
8414 dd if=$DIR/$tdir/f1 of=/dev/null
8415 stat $DIR/$tdir $DIR/$tdir/f1 > /dev/null
8416 # XXX client can not do early lock cancel of OST lock
8417 # during unlink (LU-4206), so cancel osc lock now.
8419 cancel_lru_locks osc
8420 can1=$(do_facet $SINGLEMDS \
8421 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8422 awk '/ldlm_cancel/ {print $2}')
8423 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8424 awk '/ldlm_bl_callback/ {print $2}')
8425 unlink $DIR/$tdir/f1
8427 can2=$(do_facet $SINGLEMDS \
8428 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8429 awk '/ldlm_cancel/ {print $2}')
8430 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8431 awk '/ldlm_bl_callback/ {print $2}')
8432 [ $can1 -ne $can2 ] && error "$((can2 - can1)) cancel RPC occured" &&
8433 $LCTL dk $TMP/cancel.debug.txt
8434 [ $blk1 -ne $blk2 ] && error "$((blk2 - blk1)) blocking RPC occured" &&
8435 $LCTL dk $TMP/blocking.debug.txt
8436 $dlmtrace_set && $LCTL set_param debug=-dlmtrace
8437 lru_resize_enable mdc
8438 lru_resize_enable osc
8440 run_test 120e "Early Lock Cancel: unlink test"
8443 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8444 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
8445 skip "no early lock cancel on server" && return 0
8446 remote_mds_nodsh && skip "remote MDS with nodsh" && return
8447 test_mkdir -p -c1 $DIR/$tdir
8448 lru_resize_disable mdc
8449 lru_resize_disable osc
8450 test_mkdir -p -c1 $DIR/$tdir/d1
8451 test_mkdir -p -c1 $DIR/$tdir/d2
8452 dd if=/dev/zero of=$DIR/$tdir/d1/f1 count=1
8453 dd if=/dev/zero of=$DIR/$tdir/d2/f2 count=1
8454 cancel_lru_locks mdc
8455 cancel_lru_locks osc
8456 dd if=$DIR/$tdir/d1/f1 of=/dev/null
8457 dd if=$DIR/$tdir/d2/f2 of=/dev/null
8458 stat $DIR/$tdir/d1 $DIR/$tdir/d2 $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2 > /dev/null
8459 # XXX client can not do early lock cancel of OST lock
8460 # during rename (LU-4206), so cancel osc lock now.
8462 cancel_lru_locks osc
8463 can1=$(do_facet $SINGLEMDS \
8464 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8465 awk '/ldlm_cancel/ {print $2}')
8466 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8467 awk '/ldlm_bl_callback/ {print $2}')
8468 mrename $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2
8470 can2=$(do_facet $SINGLEMDS \
8471 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8472 awk '/ldlm_cancel/ {print $2}')
8473 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8474 awk '/ldlm_bl_callback/ {print $2}')
8475 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
8476 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
8477 lru_resize_enable mdc
8478 lru_resize_enable osc
8480 run_test 120f "Early Lock Cancel: rename test"
8483 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8484 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
8485 skip "no early lock cancel on server" && return 0
8486 remote_mds_nodsh && skip "remote MDS with nodsh" && return
8487 lru_resize_disable mdc
8488 lru_resize_disable osc
8490 echo create $count files
8491 test_mkdir -p $DIR/$tdir
8492 cancel_lru_locks mdc
8493 cancel_lru_locks osc
8496 can0=$(do_facet $SINGLEMDS \
8497 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8498 awk '/ldlm_cancel/ {print $2}')
8499 blk0=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8500 awk '/ldlm_bl_callback/ {print $2}')
8501 createmany -o $DIR/$tdir/f $count
8503 can1=$(do_facet $SINGLEMDS \
8504 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8505 awk '/ldlm_cancel/ {print $2}')
8506 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8507 awk '/ldlm_bl_callback/ {print $2}')
8509 echo total: $((can1-can0)) cancels, $((blk1-blk0)) blockings
8510 echo rm $count files
8513 can2=$(do_facet $SINGLEMDS \
8514 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8515 awk '/ldlm_cancel/ {print $2}')
8516 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8517 awk '/ldlm_bl_callback/ {print $2}')
8519 echo total: $count removes in $((t2-t1))
8520 echo total: $((can2-can1)) cancels, $((blk2-blk1)) blockings
8522 # wait for commitment of removal
8523 lru_resize_enable mdc
8524 lru_resize_enable osc
8526 run_test 120g "Early Lock Cancel: performance test"
8528 test_121() { #bug #10589
8529 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8531 writes=$(LANG=C dd if=/dev/zero of=$DIR/$tfile count=1 2>&1 | awk -F '+' '/out$/ {print $1}')
8532 #define OBD_FAIL_LDLM_CANCEL_RACE 0x310
8533 lctl set_param fail_loc=0x310
8534 cancel_lru_locks osc > /dev/null
8535 reads=$(LANG=C dd if=$DIR/$tfile of=/dev/null 2>&1 | awk -F '+' '/in$/ {print $1}')
8536 lctl set_param fail_loc=0
8537 [[ $reads -eq $writes ]] ||
8538 error "read $reads blocks, must be $writes blocks"
8540 run_test 121 "read cancel race ========="
8542 test_123a() { # was test 123, statahead(bug 11401)
8543 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8545 if [ -z "$(grep "processor.*: 1" /proc/cpuinfo)" ]; then
8546 log "testing on UP system. Performance may be not as good as expected."
8551 test_mkdir -p $DIR/$tdir
8552 NUMFREE=$(df -i -P $DIR | tail -n 1 | awk '{ print $4 }')
8553 [[ $NUMFREE -gt 100000 ]] && NUMFREE=100000 || NUMFREE=$((NUMFREE-1000))
8555 for ((i=100, j=0; i<=$NUMFREE; j=$i, i=$((i * MULT)) )); do
8556 createmany -o $DIR/$tdir/$tfile $j $((i - j))
8558 max=`lctl get_param -n llite.*.statahead_max | head -n 1`
8559 lctl set_param -n llite.*.statahead_max 0
8560 lctl get_param llite.*.statahead_max
8561 cancel_lru_locks mdc
8562 cancel_lru_locks osc
8564 time ls -l $DIR/$tdir | wc -l
8566 delta=$((etime - stime))
8567 log "ls $i files without statahead: $delta sec"
8568 lctl set_param llite.*.statahead_max=$max
8570 swrong=`lctl get_param -n llite.*.statahead_stats | grep "statahead wrong:" | awk '{print $3}'`
8571 lctl get_param -n llite.*.statahead_max | grep '[0-9]'
8572 cancel_lru_locks mdc
8573 cancel_lru_locks osc
8575 time ls -l $DIR/$tdir | wc -l
8577 delta_sa=$((etime - stime))
8578 log "ls $i files with statahead: $delta_sa sec"
8579 lctl get_param -n llite.*.statahead_stats
8580 ewrong=`lctl get_param -n llite.*.statahead_stats | grep "statahead wrong:" | awk '{print $3}'`
8582 [[ $swrong -lt $ewrong ]] &&
8583 log "statahead was stopped, maybe too many locks held!"
8584 [[ $delta -eq 0 || $delta_sa -eq 0 ]] && continue
8586 if [ $((delta_sa * 100)) -gt $((delta * 105)) -a $delta_sa -gt $((delta + 2)) ]; then
8587 max=`lctl get_param -n llite.*.statahead_max | head -n 1`
8588 lctl set_param -n llite.*.statahead_max 0
8589 lctl get_param llite.*.statahead_max
8590 cancel_lru_locks mdc
8591 cancel_lru_locks osc
8593 time ls -l $DIR/$tdir | wc -l
8595 delta=$((etime - stime))
8596 log "ls $i files again without statahead: $delta sec"
8597 lctl set_param llite.*.statahead_max=$max
8598 if [ $((delta_sa * 100)) -gt $((delta * 105)) -a $delta_sa -gt $((delta + 2)) ]; then
8599 if [ $SLOWOK -eq 0 ]; then
8600 error "ls $i files is slower with statahead!"
8602 log "ls $i files is slower with statahead!"
8608 [ $delta -gt 20 ] && break
8609 [ $delta -gt 8 ] && MULT=$((50 / delta))
8610 [ "$SLOW" = "no" -a $delta -gt 5 ] && break
8618 delta=$((etime - stime))
8619 log "rm -r $DIR/$tdir/: $delta seconds"
8621 lctl get_param -n llite.*.statahead_stats
8623 run_test 123a "verify statahead work"
8625 test_123b () { # statahead(bug 15027)
8626 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8627 test_mkdir -p $DIR/$tdir
8628 createmany -o $DIR/$tdir/$tfile-%d 1000
8630 cancel_lru_locks mdc
8631 cancel_lru_locks osc
8633 #define OBD_FAIL_MDC_GETATTR_ENQUEUE 0x803
8634 lctl set_param fail_loc=0x80000803
8635 ls -lR $DIR/$tdir > /dev/null
8637 lctl set_param fail_loc=0x0
8638 lctl get_param -n llite.*.statahead_stats
8643 run_test 123b "not panic with network error in statahead enqueue (bug 15027)"
8646 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8647 [ -z "$($LCTL get_param -n mdc.*.connect_flags | grep lru_resize)" ] &&
8648 skip "no lru resize on server" && return 0
8650 test_mkdir -p $DIR/$tdir || error "failed to create $DIR/$tdir"
8652 log "create $NR files at $DIR/$tdir"
8653 createmany -o $DIR/$tdir/f $NR ||
8654 error "failed to create $NR files in $DIR/$tdir"
8656 cancel_lru_locks mdc
8657 ls -l $DIR/$tdir > /dev/null
8661 for VALUE in $($LCTL get_param ldlm.namespaces.*mdc-*.lru_size); do
8662 local PARAM=$(echo ${VALUE[0]} | cut -d "=" -f1)
8663 LRU_SIZE=$($LCTL get_param -n $PARAM)
8664 if [[ $LRU_SIZE -gt $(default_lru_size) ]]; then
8665 NSDIR=$(echo $PARAM | cut -d "." -f1-3)
8667 log "NS=$(basename $NSDIR)"
8672 if [[ -z "$NSDIR" || $LRU_SIZE -lt $(default_lru_size) ]]; then
8673 skip "Not enough cached locks created!"
8680 # We know that lru resize allows one client to hold $LIMIT locks
8681 # for 10h. After that locks begin to be killed by client.
8683 local LIMIT=$($LCTL get_param -n $NSDIR.pool.limit)
8685 if [ $LIMIT -lt $LRU_SIZE ]; then
8686 skip "Limit is too small $LIMIT"
8690 # Make LVF so higher that sleeping for $SLEEP is enough to _start_
8691 # killing locks. Some time was spent for creating locks. This means
8692 # that up to the moment of sleep finish we must have killed some of
8693 # them (10-100 locks). This depends on how fast ther were created.
8694 # Many of them were touched in almost the same moment and thus will
8695 # be killed in groups.
8696 local LVF=$(($MAX_HRS * 60 * 60 / $SLEEP * $LIMIT / $LRU_SIZE))
8698 # Use $LRU_SIZE_B here to take into account real number of locks
8699 # created in the case of CMD, LRU_SIZE_B != $NR in most of cases
8700 local LRU_SIZE_B=$LRU_SIZE
8702 local OLD_LVF=$($LCTL get_param -n $NSDIR.pool.lock_volume_factor)
8703 log "OLD_LVF=$OLD_LVF"
8704 $LCTL set_param -n $NSDIR.pool.lock_volume_factor $LVF
8706 # Let's make sure that we really have some margin. Client checks
8707 # cached locks every 10 sec.
8709 log "Sleep ${SLEEP} sec"
8711 while ((SEC<$SLEEP)); do
8715 LRU_SIZE=$($LCTL get_param -n $NSDIR/lru_size)
8719 $LCTL set_param -n $NSDIR.pool.lock_volume_factor $OLD_LVF
8720 local LRU_SIZE_A=$($LCTL get_param -n $NSDIR.lru_size)
8722 [[ $LRU_SIZE_B -gt $LRU_SIZE_A ]] || {
8723 error "No locks dropped in ${SLEEP}s. LRU size: $LRU_SIZE_A"
8724 unlinkmany $DIR/$tdir/f $NR
8728 log "Dropped "$((LRU_SIZE_B-LRU_SIZE_A))" locks in ${SLEEP}s"
8729 log "unlink $NR files at $DIR/$tdir"
8730 unlinkmany $DIR/$tdir/f $NR
8732 run_test 124a "lru resize ======================================="
8734 get_max_pool_limit()
8736 local limit=$($LCTL get_param \
8737 -n ldlm.namespaces.*-MDT0000-mdc-*.pool.limit)
8740 if [[ $l -gt $max ]]; then
8748 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8749 [ -z "$($LCTL get_param -n mdc.*.connect_flags | grep lru_resize)" ] &&
8750 skip "no lru resize on server" && return 0
8752 LIMIT=$(get_max_pool_limit)
8754 NR=$(($(default_lru_size)*20))
8755 if [[ $NR -gt $LIMIT ]]; then
8756 log "Limit lock number by $LIMIT locks"
8760 IFree=$(mdsrate_inodes_available)
8761 if [ $IFree -lt $NR ]; then
8762 log "Limit lock number by $IFree inodes"
8766 lru_resize_disable mdc
8767 test_mkdir -p $DIR/$tdir/disable_lru_resize ||
8768 error "failed to create $DIR/$tdir/disable_lru_resize"
8770 createmany -o $DIR/$tdir/disable_lru_resize/f $NR
8771 log "doing ls -la $DIR/$tdir/disable_lru_resize 3 times"
8772 cancel_lru_locks mdc
8775 ls -la $DIR/$tdir/disable_lru_resize > /dev/null &
8778 ls -la $DIR/$tdir/disable_lru_resize > /dev/null &
8781 ls -la $DIR/$tdir/disable_lru_resize > /dev/null &
8785 nolruresize_delta=$((etime-stime))
8786 log "ls -la time: $nolruresize_delta seconds"
8787 log "lru_size = $(lctl get_param -n ldlm.namespaces.*mdc*.lru_size)"
8788 unlinkmany $DIR/$tdir/disable_lru_resize/f $NR
8790 lru_resize_enable mdc
8791 test_mkdir -p $DIR/$tdir/enable_lru_resize ||
8792 error "failed to create $DIR/$tdir/enable_lru_resize"
8794 createmany -o $DIR/$tdir/enable_lru_resize/f $NR
8795 log "doing ls -la $DIR/$tdir/enable_lru_resize 3 times"
8796 cancel_lru_locks mdc
8799 ls -la $DIR/$tdir/enable_lru_resize > /dev/null &
8802 ls -la $DIR/$tdir/enable_lru_resize > /dev/null &
8805 ls -la $DIR/$tdir/enable_lru_resize > /dev/null &
8809 lruresize_delta=$((etime-stime))
8810 log "ls -la time: $lruresize_delta seconds"
8811 log "lru_size = $(lctl get_param -n ldlm.namespaces.*mdc*.lru_size)"
8813 if [ $lruresize_delta -gt $nolruresize_delta ]; then
8814 log "ls -la is $(((lruresize_delta - $nolruresize_delta) * 100 / $nolruresize_delta))% slower with lru resize enabled"
8815 elif [ $nolruresize_delta -gt $lruresize_delta ]; then
8816 log "ls -la is $(((nolruresize_delta - $lruresize_delta) * 100 / $nolruresize_delta))% faster with lru resize enabled"
8818 log "lru resize performs the same with no lru resize"
8820 unlinkmany $DIR/$tdir/enable_lru_resize/f $NR
8822 run_test 124b "lru resize (performance test) ======================="
8825 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8826 [ -z "$($LCTL get_param -n mdc.*.connect_flags | grep lru_resize)" ] &&
8827 skip "no lru resize on server" && return 0
8829 # cache ununsed locks on client
8831 cancel_lru_locks mdc
8832 test_mkdir -p $DIR/$tdir || error "failed to create $DIR/$tdir"
8833 createmany -o $DIR/$tdir/f $nr ||
8834 error "failed to create $nr files in $DIR/$tdir"
8835 ls -l $DIR/$tdir > /dev/null
8837 local nsdir="ldlm.namespaces.*-MDT0000-mdc-*"
8838 local unused=$($LCTL get_param -n $nsdir.lock_unused_count)
8839 local max_age=$($LCTL get_param -n $nsdir.lru_max_age)
8840 local recalc_p=$($LCTL get_param -n $nsdir.pool.recalc_period)
8841 echo "unused=$unused, max_age=$max_age, recalc_p=$recalc_p"
8843 # set lru_max_age to 1 sec
8844 $LCTL set_param $nsdir.lru_max_age=1000 # jiffies
8845 echo "sleep $((recalc_p * 2)) seconds..."
8846 sleep $((recalc_p * 2))
8848 local remaining=$($LCTL get_param -n $nsdir.lock_unused_count)
8849 # restore lru_max_age
8850 $LCTL set_param -n $nsdir.lru_max_age $max_age
8851 [ $remaining -eq 0 ] || error "$remaining locks are not canceled"
8852 unlinkmany $DIR/$tdir/f $nr
8854 run_test 124c "LRUR cancel very aged locks"
8856 test_125() { # 13358
8857 [ -z "$(lctl get_param -n llite.*.client_type | grep local)" ] && skip "must run as local client" && return
8858 [ -z "$(lctl get_param -n mdc.*-mdc-*.connect_flags | grep acl)" ] && skip "must have acl enabled" && return
8859 [ -z "$(which setfacl)" ] && skip "must have setfacl tool" && return
8860 test_mkdir -p $DIR/d125 || error "mkdir failed"
8861 $SETSTRIPE -S 65536 -c -1 $DIR/d125 || error "setstripe failed"
8862 setfacl -R -m u:bin:rwx $DIR/d125 || error "setfacl $DIR/d125 failed"
8863 ls -ld $DIR/d125 || error "cannot access $DIR/d125"
8865 run_test 125 "don't return EPROTO when a dir has a non-default striping and ACLs"
8867 test_126() { # bug 12829/13455
8868 [ -z "$(lctl get_param -n llite.*.client_type | grep local)" ] && skip "must run as local client" && return
8869 [ "$UID" != 0 ] && skip_env "skipping $TESTNAME (must run as root)" && return
8870 $GSS && skip "must run as gss disabled" && return
8872 $RUNAS -u 0 -g 1 touch $DIR/$tfile || error "touch failed"
8873 gid=`ls -n $DIR/$tfile | awk '{print $4}'`
8875 [ $gid -eq "1" ] || error "gid is set to" $gid "instead of 1"
8877 run_test 126 "check that the fsgid provided by the client is taken into account"
8879 test_127a() { # bug 15521
8880 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8881 $SETSTRIPE -i 0 -c 1 $DIR/$tfile || error "setstripe failed"
8882 $LCTL set_param osc.*.stats=0
8883 FSIZE=$((2048 * 1024))
8884 dd if=/dev/zero of=$DIR/$tfile bs=$FSIZE count=1
8885 cancel_lru_locks osc
8886 dd if=$DIR/$tfile of=/dev/null bs=$FSIZE
8888 $LCTL get_param osc.*0000-osc-*.stats | grep samples > $DIR/${tfile}.tmp
8889 while read NAME COUNT SAMP UNIT MIN MAX SUM SUMSQ; do
8890 echo "got $COUNT $NAME"
8891 [ ! $MIN ] && error "Missing min value for $NAME proc entry"
8892 eval $NAME=$COUNT || error "Wrong proc format"
8895 read_bytes|write_bytes)
8896 [ $MIN -lt 4096 ] && error "min is too small: $MIN"
8897 [ $MIN -gt $FSIZE ] && error "min is too big: $MIN"
8898 [ $MAX -lt 4096 ] && error "max is too small: $MAX"
8899 [ $MAX -gt $FSIZE ] && error "max is too big: $MAX"
8900 [ $SUM -ne $FSIZE ] && error "sum is wrong: $SUM"
8901 [ $SUMSQ -lt $(((FSIZE /4096) * (4096 * 4096))) ] &&
8902 error "sumsquare is too small: $SUMSQ"
8903 [ $SUMSQ -gt $((FSIZE * FSIZE)) ] &&
8904 error "sumsquare is too big: $SUMSQ"
8908 done < $DIR/${tfile}.tmp
8910 #check that we actually got some stats
8911 [ "$read_bytes" ] || error "Missing read_bytes stats"
8912 [ "$write_bytes" ] || error "Missing write_bytes stats"
8913 [ "$read_bytes" != 0 ] || error "no read done"
8914 [ "$write_bytes" != 0 ] || error "no write done"
8916 run_test 127a "verify the client stats are sane"
8918 test_127b() { # bug LU-333
8919 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8920 $LCTL set_param llite.*.stats=0
8921 FSIZE=65536 # sized fixed to match PAGE_SIZE for most clients
8922 # perform 2 reads and writes so MAX is different from SUM.
8923 dd if=/dev/zero of=$DIR/$tfile bs=$FSIZE count=1
8924 dd if=/dev/zero of=$DIR/$tfile bs=$FSIZE count=1
8925 cancel_lru_locks osc
8926 dd if=$DIR/$tfile of=/dev/null bs=$FSIZE count=1
8927 dd if=$DIR/$tfile of=/dev/null bs=$FSIZE count=1
8929 $LCTL get_param llite.*.stats | grep samples > $TMP/${tfile}.tmp
8930 while read NAME COUNT SAMP UNIT MIN MAX SUM SUMSQ; do
8931 echo "got $COUNT $NAME"
8932 eval $NAME=$COUNT || error "Wrong proc format"
8936 [ $COUNT -ne 2 ] && error "count is not 2: $COUNT"
8937 [ $MIN -ne $FSIZE ] && error "min is not $FSIZE: $MIN"
8938 [ $MAX -ne $FSIZE ] && error "max is incorrect: $MAX"
8939 [ $SUM -ne $((FSIZE * 2)) ] && error "sum is wrong: $SUM"
8942 [ $COUNT -ne 2 ] && error "count is not 2: $COUNT"
8943 [ $MIN -ne $FSIZE ] && error "min is not $FSIZE: $MIN"
8944 [ $MAX -ne $FSIZE ] && error "max is incorrect: $MAX"
8945 [ $SUM -ne $((FSIZE * 2)) ] && error "sum is wrong: $SUM"
8949 done < $TMP/${tfile}.tmp
8951 #check that we actually got some stats
8952 [ "$read_bytes" ] || error "Missing read_bytes stats"
8953 [ "$write_bytes" ] || error "Missing write_bytes stats"
8954 [ "$read_bytes" != 0 ] || error "no read done"
8955 [ "$write_bytes" != 0 ] || error "no write done"
8957 rm -f $TMP/${tfile}.tmp
8959 run_test 127b "verify the llite client stats are sane"
8961 test_128() { # bug 15212
8963 $LFS 2>&1 <<-EOF | tee $TMP/$tfile.log
8968 result=$(grep error $TMP/$tfile.log)
8969 rm -f $DIR/$tfile $TMP/$tfile.log
8971 error "consecutive find's under interactive lfs failed"
8973 run_test 128 "interactive lfs for 2 consecutive find's"
8980 local LDPROC=/proc/fs/ldiskfs
8981 local facets=$(get_facets MDS)
8983 for facet in ${facets//,/ }; do
8984 canondev=$(ldiskfs_canon \
8985 *.$(convert_facet2label $facet).mntdev $facet)
8986 do_facet $facet "test -e $LDPROC/$canondev/max_dir_size" ||
8987 LDPROC=/sys/fs/ldiskfs
8988 do_facet $facet "echo $1 >$LDPROC/$canondev/max_dir_size"
8989 do_facet $facet "test -e $LDPROC/$canondev/warning_dir_size" ||
8990 LDPROC=/sys/fs/ldiskfs
8991 do_facet $facet "echo $2 >$LDPROC/$canondev/warning_dir_size"
8996 local facets=$(get_facets MDS)
8997 for facet in ${facets//,/ }; do
8998 do_facet $facet "dmesg | tail -3 | grep -q $1" && return 0
9004 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.5.56) ]] ||
9005 { skip "Need MDS version with at least 2.5.56"; return 0; }
9007 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9008 if [ "$(facet_fstype $SINGLEMDS)" != ldiskfs ]; then
9009 skip "Only applicable to ldiskfs-based MDTs"
9012 remote_mds_nodsh && skip "remote MDS with nodsh" && return
9020 # block size of mds1
9021 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
9022 local MDSBLOCKSIZE=$($LCTL get_param -n mdc.*MDT0000*.blocksize)
9023 local MAX=$((MDSBLOCKSIZE * 5))
9024 set_dir_limits $MAX $MAX
9025 local I=$(stat -c%s "$DIR/$tdir")
9027 while [[ $I -le $MAX ]]; do
9028 $MULTIOP $DIR/$tdir/$J Oc
9030 if [ $has_warning -eq 0 ]; then
9031 check_mds_dmesg '"is approaching"' &&
9034 #check two errors ENOSPC for new version of ext4 max_dir_size patch
9035 #mainline kernel commit df981d03eeff7971ac7e6ff37000bfa702327ef1
9036 #and EFBIG for previous versions
9037 if [ $rc -eq $EFBIG -o $rc -eq $ENOSPC ]; then
9039 echo "return code $rc received as expected"
9041 createmany -o $DIR/$tdir/$J_file_ 1000 ||
9042 error_exit "create failed w/o dir size limit"
9044 check_mds_dmesg '"has reached"' ||
9045 error_exit "has reached message should be output"
9047 [ $has_warning -eq 0 ] &&
9048 error_exit "warning message should be output"
9050 I=$(stat -c%s "$DIR/$tdir")
9052 if [ $(lustre_version_code $SINGLEMDS) -lt \
9053 $(version_code 2.4.51) ]
9055 [[ $I -eq $MAX ]] && return 0
9057 [[ $I -gt $MAX ]] && return 0
9059 error_exit "current dir size $I, previous limit $MAX"
9060 elif [ $rc -ne 0 ]; then
9062 error_exit "return code $rc received instead of expected " \
9063 "$EFBIG or $ENOSPC, files in dir $I"
9066 I=$(stat -c%s "$DIR/$tdir")
9070 error "exceeded dir size limit $MAX($MDSCOUNT) : $I bytes"
9072 run_test 129 "test directory size limit ========================"
9081 local filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
9082 [ -n "$filefrag_op" ] && skip_env "filefrag does not support FIEMAP" &&
9085 trap cleanup_130 EXIT RETURN
9087 local fm_file=$DIR/$tfile
9088 $SETSTRIPE -S 65536 -c 1 $fm_file || error "setstripe on $fm_file"
9089 dd if=/dev/zero of=$fm_file bs=65536 count=1 ||
9090 error "dd failed for $fm_file"
9092 # LU-1795: test filefrag/FIEMAP once, even if unsupported
9093 filefrag -ves $fm_file
9095 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
9096 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
9097 [ $RC != 0 ] && error "filefrag $fm_file failed"
9099 filefrag_op=$(filefrag -ve $fm_file |
9100 sed -n '/ext:/,/found/{/ext:/d; /found/d; p}')
9101 lun=$($GETSTRIPE -i $fm_file)
9103 start_blk=`echo $filefrag_op | cut -d: -f2 | cut -d. -f1`
9106 for line in $filefrag_op
9108 frag_lun=`echo $line | cut -d: -f5`
9109 ext_len=`echo $line | cut -d: -f4`
9110 if (( $frag_lun != $lun )); then
9112 error "FIEMAP on 1-stripe file($fm_file) failed"
9115 (( tot_len += ext_len ))
9118 if (( lun != frag_lun || start_blk != 0 || tot_len != 64 )); then
9120 error "FIEMAP on 1-stripe file($fm_file) failed;"
9126 echo "FIEMAP on single striped file succeeded"
9128 run_test 130a "FIEMAP (1-stripe file)"
9131 [ "$OSTCOUNT" -lt "2" ] &&
9132 skip_env "skipping FIEMAP on $OSTCOUNT-stripe file" && return
9134 local filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
9135 [ -n "$filefrag_op" ] && skip_env "filefrag does not support FIEMAP" &&
9138 trap cleanup_130 EXIT RETURN
9140 local fm_file=$DIR/$tfile
9141 $SETSTRIPE -S 65536 -c $OSTCOUNT $fm_file ||
9142 error "setstripe on $fm_file"
9143 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
9144 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
9146 dd if=/dev/zero of=$fm_file bs=1M count=$OSTCOUNT ||
9147 error "dd failed on $fm_file"
9149 filefrag -ves $fm_file || error "filefrag $fm_file failed"
9150 filefrag_op=$(filefrag -ve $fm_file |
9151 sed -n '/ext:/,/found/{/ext:/d; /found/d; p}')
9153 last_lun=$(echo $filefrag_op | cut -d: -f5 |
9154 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
9159 for line in $filefrag_op
9161 frag_lun=$(echo $line | cut -d: -f5 |
9162 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
9163 ext_len=$(echo $line | cut -d: -f4)
9164 if (( $frag_lun != $last_lun )); then
9165 if (( tot_len != 1024 )); then
9167 error "FIEMAP on $fm_file failed; returned " \
9168 "len $tot_len for OST $last_lun instead of 1024"
9175 (( tot_len += ext_len ))
9178 if (( num_luns != $OSTCOUNT || tot_len != 1024 )); then
9180 error "FIEMAP on $fm_file failed; returned wrong number of " \
9181 "luns or wrong len for OST $last_lun"
9187 echo "FIEMAP on $OSTCOUNT-stripe file succeeded"
9189 run_test 130b "FIEMAP ($OSTCOUNT-stripe file)"
9192 [ "$OSTCOUNT" -lt "2" ] &&
9193 skip_env "skipping FIEMAP on 2-stripe file" && return
9195 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
9196 [ -n "$filefrag_op" ] && skip "filefrag does not support FIEMAP" &&
9199 trap cleanup_130 EXIT RETURN
9201 local fm_file=$DIR/$tfile
9202 $SETSTRIPE -S 65536 -c 2 $fm_file || error "setstripe on $fm_file"
9203 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
9204 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
9206 dd if=/dev/zero of=$fm_file seek=1 bs=1M count=1 ||
9207 error "dd failed on $fm_file"
9209 filefrag -ves $fm_file || error "filefrag $fm_file failed"
9210 filefrag_op=$(filefrag -ve $fm_file |
9211 sed -n '/ext:/,/found/{/ext:/d; /found/d; p}')
9213 last_lun=$(echo $filefrag_op | cut -d: -f5 |
9214 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
9219 for line in $filefrag_op
9221 frag_lun=$(echo $line | cut -d: -f5 |
9222 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
9223 ext_len=$(echo $line | cut -d: -f4)
9224 if (( $frag_lun != $last_lun )); then
9225 logical=`echo $line | cut -d: -f2 | cut -d. -f1`
9226 if (( logical != 512 )); then
9228 error "FIEMAP on $fm_file failed; returned " \
9229 "logical start for lun $logical instead of 512"
9232 if (( tot_len != 512 )); then
9234 error "FIEMAP on $fm_file failed; returned " \
9235 "len $tot_len for OST $last_lun instead of 1024"
9242 (( tot_len += ext_len ))
9245 if (( num_luns != 2 || tot_len != 512 )); then
9247 error "FIEMAP on $fm_file failed; returned wrong number of " \
9248 "luns or wrong len for OST $last_lun"
9254 echo "FIEMAP on 2-stripe file with hole succeeded"
9256 run_test 130c "FIEMAP (2-stripe file with hole)"
9259 [ "$OSTCOUNT" -lt "3" ] &&
9260 skip_env "skipping FIEMAP on N-stripe file test" && return
9262 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
9263 [ -n "$filefrag_op" ] && skip "filefrag does not support FIEMAP" &&
9266 trap cleanup_130 EXIT RETURN
9268 local fm_file=$DIR/$tfile
9269 $SETSTRIPE -S 65536 -c $OSTCOUNT $fm_file ||
9270 error "setstripe on $fm_file"
9271 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
9272 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
9274 local actual_stripecnt=$($GETSTRIPE -c $fm_file)
9275 dd if=/dev/zero of=$fm_file bs=1M count=$actual_stripecnt ||
9276 error "dd failed on $fm_file"
9278 filefrag -ves $fm_file || error "filefrag $fm_file failed"
9279 filefrag_op=$(filefrag -ve $fm_file |
9280 sed -n '/ext:/,/found/{/ext:/d; /found/d; p}')
9282 last_lun=$(echo $filefrag_op | cut -d: -f5 |
9283 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
9288 for line in $filefrag_op
9290 frag_lun=$(echo $line | cut -d: -f5 |
9291 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
9292 ext_len=$(echo $line | cut -d: -f4)
9293 if (( $frag_lun != $last_lun )); then
9294 if (( tot_len != 1024 )); then
9296 error "FIEMAP on $fm_file failed; returned " \
9297 "len $tot_len for OST $last_lun instead of 1024"
9304 (( tot_len += ext_len ))
9307 if (( num_luns != actual_stripecnt || tot_len != 1024 )); then
9309 error "FIEMAP on $fm_file failed; returned wrong number of " \
9310 "luns or wrong len for OST $last_lun"
9316 echo "FIEMAP on N-stripe file succeeded"
9318 run_test 130d "FIEMAP (N-stripe file)"
9321 [ "$OSTCOUNT" -lt "2" ] &&
9322 skip_env "skipping continuation FIEMAP test" && return
9324 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
9325 [ -n "$filefrag_op" ] && skip "filefrag does not support FIEMAP" && return
9327 trap cleanup_130 EXIT RETURN
9329 local fm_file=$DIR/$tfile
9330 $SETSTRIPE -S 131072 -c 2 $fm_file || error "setstripe on $fm_file"
9331 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
9332 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
9335 EXPECTED_LEN=$(( (NUM_BLKS / 2) * 64 ))
9336 for ((i = 0; i < $NUM_BLKS; i++))
9338 dd if=/dev/zero of=$fm_file count=1 bs=64k seek=$((2*$i)) conv=notrunc > /dev/null 2>&1
9341 filefrag -ves $fm_file || error "filefrag $fm_file failed"
9342 filefrag_op=$(filefrag -ve $fm_file |
9343 sed -n '/ext:/,/found/{/ext:/d; /found/d; p}')
9345 last_lun=$(echo $filefrag_op | cut -d: -f5 |
9346 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
9351 for line in $filefrag_op
9353 frag_lun=$(echo $line | cut -d: -f5 |
9354 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
9355 ext_len=$(echo $line | cut -d: -f4)
9356 if (( $frag_lun != $last_lun )); then
9357 if (( tot_len != $EXPECTED_LEN )); then
9359 error "FIEMAP on $fm_file failed; returned " \
9360 "len $tot_len for OST $last_lun instead " \
9368 (( tot_len += ext_len ))
9371 if (( num_luns != 2 || tot_len != $EXPECTED_LEN )); then
9373 error "FIEMAP on $fm_file failed; returned wrong number " \
9374 "of luns or wrong len for OST $last_lun"
9380 echo "FIEMAP with continuation calls succeeded"
9382 run_test 130e "FIEMAP (test continuation FIEMAP calls)"
9384 # Test for writev/readv
9386 rwv -f $DIR/$tfile -w -n 3 524288 1048576 1572864 || \
9387 error "writev test failed"
9388 rwv -f $DIR/$tfile -r -v -n 2 1572864 1048576 || \
9389 error "readv failed"
9392 run_test 131a "test iov's crossing stripe boundary for writev/readv"
9395 rwv -f $DIR/$tfile -w -a -n 3 524288 1048576 1572864 || \
9396 error "append writev test failed"
9397 rwv -f $DIR/$tfile -w -a -n 2 1572864 1048576 || \
9398 error "append writev test failed"
9401 run_test 131b "test append writev"
9404 rwv -f $DIR/$tfile -w -d -n 1 1048576 || return 0
9407 run_test 131c "test read/write on file w/o objects"
9410 rwv -f $DIR/$tfile -w -n 1 1572864
9411 NOB=`rwv -f $DIR/$tfile -r -n 3 524288 524288 1048576 | awk '/error/ {print $6}'`
9412 if [ "$NOB" != 1572864 ]; then
9413 error "Short read filed: read $NOB bytes instead of 1572864"
9417 run_test 131d "test short read"
9420 rwv -f $DIR/$tfile -w -s 1048576 -n 1 1048576
9421 rwv -f $DIR/$tfile -r -z -s 0 -n 1 524288 || \
9422 error "read hitting hole failed"
9425 run_test 131e "test read hitting hole"
9434 mds*) res=$(do_facet $facet \
9435 $LCTL get_param mdt.$FSNAME-MDT0000.md_stats | grep "$op")
9437 ost*) res=$(do_facet $facet \
9438 $LCTL get_param obdfilter.$FSNAME-OST0000.stats | grep "$op")
9440 *) error "Wrong facet '$facet'" ;;
9443 [ "$res" ] || error "The counter for $op on $facet was not incremented"
9444 # if the argument $3 is zero, it means any stat increment is ok.
9445 if [[ $want -gt 0 ]]; then
9446 local count=$(echo $res | awk '{ print $2 }')
9447 [[ $count -ne $want ]] &&
9448 error "The $op counter on $facet is $count, not $want"
9453 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9454 remote_ost_nodsh && skip "remote OST with nodsh" && return
9455 remote_mds_nodsh && skip "remote MDS with nodsh" && return
9457 do_facet $SINGLEMDS $LCTL list_param mdt.*.rename_stats ||
9458 { skip "MDS doesn't support rename stats"; return; }
9459 local testdir=$DIR/${tdir}/stats_testdir
9460 mkdir -p $DIR/${tdir}
9463 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
9464 do_facet ost1 $LCTL set_param obdfilter.*.stats=clear
9466 # verify mdt stats first.
9467 mkdir ${testdir} || error "mkdir failed"
9468 check_stats $SINGLEMDS "mkdir" 1
9469 touch ${testdir}/${tfile} || error "touch failed"
9470 check_stats $SINGLEMDS "open" 1
9471 check_stats $SINGLEMDS "close" 1
9472 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.8.54) ] && {
9473 mknod ${testdir}/${tfile}-pipe p || error "mknod failed"
9474 check_stats $SINGLEMDS "mknod" 2
9476 rm -f ${testdir}/${tfile}-pipe || error "pipe remove failed"
9477 check_stats $SINGLEMDS "unlink" 1
9478 rm -f ${testdir}/${tfile} || error "file remove failed"
9479 check_stats $SINGLEMDS "unlink" 2
9481 # remove working dir and check mdt stats again.
9482 rmdir ${testdir} || error "rmdir failed"
9483 check_stats $SINGLEMDS "rmdir" 1
9485 local testdir1=$DIR/${tdir}/stats_testdir1
9487 mkdir -p ${testdir1}
9488 touch ${testdir1}/test1
9489 mv ${testdir1}/test1 ${testdir} || error "file crossdir rename"
9490 check_stats $SINGLEMDS "crossdir_rename" 1
9492 mv ${testdir}/test1 ${testdir}/test0 || error "file samedir rename"
9493 check_stats $SINGLEMDS "samedir_rename" 1
9497 run_test 133a "Verifying MDT stats ========================================"
9500 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9501 remote_ost_nodsh && skip "remote OST with nodsh" && return
9502 remote_mds_nodsh && skip "remote MDS with nodsh" && return
9503 local testdir=$DIR/${tdir}/stats_testdir
9504 mkdir -p ${testdir} || error "mkdir failed"
9505 touch ${testdir}/${tfile} || error "touch failed"
9506 cancel_lru_locks mdc
9509 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
9510 do_facet ost1 $LCTL set_param obdfilter.*.stats=clear
9512 # extra mdt stats verification.
9513 chmod 444 ${testdir}/${tfile} || error "chmod failed"
9514 check_stats $SINGLEMDS "setattr" 1
9515 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
9516 if [ $(lustre_version_code $SINGLEMDS) -ne $(version_code 2.2.0) ]
9518 ls -l ${testdir}/${tfile} > /dev/null|| error "ls failed"
9519 check_stats $SINGLEMDS "getattr" 1
9521 $LFS df || error "lfs failed"
9522 check_stats $SINGLEMDS "statfs" 1
9526 run_test 133b "Verifying extra MDT stats =================================="
9529 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9530 remote_ost_nodsh && skip "remote OST with nodsh" && return
9531 remote_mds_nodsh && skip "remote MDS with nodsh" && return
9532 local testdir=$DIR/${tdir}/stats_testdir
9533 test_mkdir -p ${testdir} || error "mkdir failed"
9535 # verify obdfilter stats.
9536 $SETSTRIPE -c 1 -i 0 ${testdir}/${tfile}
9538 cancel_lru_locks osc
9539 wait_delete_completed
9542 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
9543 do_facet ost1 $LCTL set_param obdfilter.*.stats=clear
9545 dd if=/dev/zero of=${testdir}/${tfile} conv=notrunc bs=512k count=1 || error "dd failed"
9547 cancel_lru_locks osc
9548 check_stats ost1 "write" 1
9550 dd if=${testdir}/${tfile} of=/dev/null bs=1k count=1 || error "dd failed"
9551 check_stats ost1 "read" 1
9553 > ${testdir}/${tfile} || error "truncate failed"
9554 check_stats ost1 "punch" 1
9556 rm -f ${testdir}/${tfile} || error "file remove failed"
9557 wait_delete_completed
9558 check_stats ost1 "destroy" 1
9562 run_test 133c "Verifying OST stats ========================================"
9569 while [ $value -ge 2 ]; do
9574 if [ $orig -gt $order ]; then
9582 local size=('K' 'M' 'G' 'T');
9584 local size_string=$value
9586 while [ $value -ge 1024 ]; do
9587 if [ $i -gt 3 ]; then
9588 #T is the biggest unit we get here, if that is bigger,
9590 size_string=${value}T
9593 value=$((value >> 10))
9594 if [ $value -lt 1024 ]; then
9595 size_string=${value}${size[$i]}
9606 local context=${2:-.}
9607 local sample=$(do_facet $SINGLEMDS $LCTL get_param mdt.*.rename_stats |
9609 awk '/ '${size}'/ {print $4}' | sed -e "s/,//g")
9614 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9615 remote_ost_nodsh && skip "remote OST with nodsh" && return
9616 remote_mds_nodsh && skip "remote MDS with nodsh" && return
9617 do_facet $SINGLEMDS $LCTL list_param mdt.*.rename_stats ||
9618 { skip "MDS doesn't support rename stats"; return; }
9620 local testdir1=$DIR/${tdir}/stats_testdir1
9621 local testdir2=$DIR/${tdir}/stats_testdir2
9623 do_facet $SINGLEMDS $LCTL set_param mdt.*.rename_stats=clear
9625 mkdir -p ${testdir1} || error "mkdir failed"
9626 mkdir -p ${testdir2} || error "mkdir failed"
9628 createmany -o $testdir1/test 512 || error "createmany failed"
9630 # check samedir rename size
9631 mv ${testdir1}/test0 ${testdir1}/test_0
9633 local testdir1_size=$(ls -l $DIR/${tdir} |
9634 awk '/stats_testdir1/ {print $5}')
9635 local testdir2_size=$(ls -l $DIR/${tdir} |
9636 awk '/stats_testdir2/ {print $5}')
9638 testdir1_size=$(order_2 $testdir1_size)
9639 testdir2_size=$(order_2 $testdir2_size)
9641 testdir1_size=$(size_in_KMGT $testdir1_size)
9642 testdir2_size=$(size_in_KMGT $testdir2_size)
9644 echo "source rename dir size: ${testdir1_size}"
9645 echo "target rename dir size: ${testdir2_size}"
9647 local cmd="do_facet $SINGLEMDS $LCTL get_param mdt.*.rename_stats"
9648 eval $cmd || error "$cmd failed"
9649 local samedir=$($cmd | grep 'same_dir')
9650 local same_sample=$(get_rename_size $testdir1_size)
9651 [ -z "$samedir" ] && error "samedir_rename_size count error"
9652 [[ $same_sample -eq 1 ]] ||
9653 error "samedir_rename_size error $same_sample"
9654 echo "Check same dir rename stats success"
9656 do_facet $SINGLEMDS $LCTL set_param mdt.*.rename_stats=clear
9658 # check crossdir rename size
9659 mv ${testdir1}/test_0 ${testdir2}/test_0
9661 testdir1_size=$(ls -l $DIR/${tdir} |
9662 awk '/stats_testdir1/ {print $5}')
9663 testdir2_size=$(ls -l $DIR/${tdir} |
9664 awk '/stats_testdir2/ {print $5}')
9666 testdir1_size=$(order_2 $testdir1_size)
9667 testdir2_size=$(order_2 $testdir2_size)
9669 testdir1_size=$(size_in_KMGT $testdir1_size)
9670 testdir2_size=$(size_in_KMGT $testdir2_size)
9672 echo "source rename dir size: ${testdir1_size}"
9673 echo "target rename dir size: ${testdir2_size}"
9675 eval $cmd || error "$cmd failed"
9676 local crossdir=$($cmd | grep 'crossdir')
9677 local src_sample=$(get_rename_size $testdir1_size crossdir_src)
9678 local tgt_sample=$(get_rename_size $testdir2_size crossdir_tgt)
9679 [ -z "$crossdir" ] && error "crossdir_rename_size count error"
9680 [[ $src_sample -eq 1 ]] ||
9681 error "crossdir_rename_size error $src_sample"
9682 [[ $tgt_sample -eq 1 ]] ||
9683 error "crossdir_rename_size error $tgt_sample"
9684 echo "Check cross dir rename stats success"
9687 run_test 133d "Verifying rename_stats ========================================"
9690 remote_mds_nodsh && skip "remote MDS with nodsh" && return
9691 remote_ost_nodsh && skip "remote OST with nodsh" && return
9692 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9693 local testdir=$DIR/${tdir}/stats_testdir
9694 local ctr f0 f1 bs=32768 count=42 sum
9696 mkdir -p ${testdir} || error "mkdir failed"
9698 $SETSTRIPE -c 1 -i 0 ${testdir}/${tfile}
9700 for ctr in {write,read}_bytes; do
9702 cancel_lru_locks osc
9704 do_facet ost1 $LCTL set_param -n \
9705 "obdfilter.*.exports.clear=clear"
9707 if [ $ctr = write_bytes ]; then
9709 f1=${testdir}/${tfile}
9711 f0=${testdir}/${tfile}
9715 dd if=$f0 of=$f1 conv=notrunc bs=$bs count=$count || \
9718 cancel_lru_locks osc
9720 sum=$(do_facet ost1 $LCTL get_param \
9721 "obdfilter.*.exports.*.stats" |
9722 awk -v ctr=$ctr 'BEGIN { sum = 0 }
9723 $1 == ctr { sum += $7 }
9724 END { printf("%0.0f", sum) }')
9726 if ((sum != bs * count)); then
9727 error "Bad $ctr sum, expected $((bs * count)), got $sum"
9733 run_test 133e "Verifying OST {read,write}_bytes nid stats ================="
9735 proc_regexp="/{proc,sys}/{fs,sys,kernel/debug}/{lustre,lnet}/"
9738 remote_mds_nodsh && skip "remote MDS with nodsh" && return
9739 remote_ost_nodsh && skip "remote OST with nodsh" && return
9740 # First without trusting modes.
9741 local proc_dirs=$(eval \ls -d $proc_regexp 2>/dev/null)
9742 echo "proc_dirs='$proc_dirs'"
9743 [ -n "$proc_dirs" ] || error "no proc_dirs on $HOSTNAME"
9744 find $proc_dirs -exec cat '{}' \; &> /dev/null
9746 # Second verifying readability.
9747 $LCTL get_param -R '*' &> /dev/null || error "proc file read failed"
9749 # eventually, this can also be replaced with "lctl get_param -R",
9750 # but not until that option is always available on the server
9752 for facet in mds1 ost1; do
9753 local facet_proc_dirs=$(do_facet $facet \
9754 \\\ls -d $proc_regexp 2>/dev/null)
9755 echo "${facet}_proc_dirs='$facet_proc_dirs'"
9756 [ -z "$facet_proc_dirs" ] && error "no proc_dirs on $facet"
9757 do_facet $facet find $facet_proc_dirs \
9758 ! -name req_history \
9759 -exec cat '{}' \\\; &> /dev/null
9761 do_facet $facet find $facet_proc_dirs \
9762 ! -name req_history \
9764 -exec cat '{}' \\\; &> /dev/null ||
9765 error "proc file read failed"
9768 run_test 133f "Check for LBUGs/Oopses/unreadable files in /proc"
9771 remote_mds_nodsh && skip "remote MDS with nodsh" && return
9772 remote_ost_nodsh && skip "remote OST with nodsh" && return
9773 # Second verifying writability.
9774 local proc_dirs=$(eval \ls -d $proc_regexp 2>/dev/null)
9775 echo "proc_dirs='$proc_dirs'"
9776 [ -n "$proc_dirs" ] || error "no proc_dirs on $HOSTNAME"
9779 -not -name force_lbug \
9780 -not -name changelog_mask \
9781 -exec badarea_io '{}' \; &> /dev/null ||
9782 error "find $proc_dirs failed"
9785 for facet in mds1 ost1; do
9786 [ $(lustre_version_code $facet) -le $(version_code 2.5.54) ] &&
9787 skip "Too old lustre on $facet" && continue
9788 local facet_proc_dirs=$(do_facet $facet \
9789 \\\ls -d $proc_regexp 2> /dev/null)
9790 echo "${facet}_proc_dirs='$facet_proc_dirs'"
9791 [ -z "$facet_proc_dirs" ] && error "no proc_dirs on $facet"
9792 do_facet $facet find $facet_proc_dirs \
9794 -not -name force_lbug \
9795 -not -name changelog_mask \
9796 -exec badarea_io '{}' \\\; &> /dev/null ||
9797 error "$facet find $facet_proc_dirs failed"
9800 # remount the FS in case writes/reads /proc break the FS
9801 cleanup || error "failed to unmount"
9802 setup || error "failed to setup"
9805 run_test 133g "Check for Oopses on bad io area writes/reads in /proc"
9808 remote_mds_nodsh && skip "remote MDS with nodsh" && return
9809 remote_ost_nodsh && skip "remote OST with nodsh" && return
9810 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.9.54) ]] &&
9811 skip "Need MDS version at least 2.9.54" && return
9814 for facet in client mds1 ost1; do
9815 local facet_proc_dirs=$(do_facet $facet \
9816 \\\ls -d $proc_regexp 2> /dev/null)
9817 [ -z "$facet_proc_dirs" ] && error "no proc_dirs on $facet"
9818 echo "${facet}_proc_dirs='$facet_proc_dirs'"
9819 # Get the list of files that are missing the terminating newline
9820 local missing=($(do_facet $facet \
9821 find ${facet_proc_dirs} -type f \| \
9823 awk -v FS='\v' -v RS='\v\v' \
9824 "'END { if(NR>0 && \
9825 \\\$NF !~ /.*\\\n\$/) \
9829 [ ${#missing[*]} -eq 0 ] ||
9830 error "files do not end with newline: ${missing[*]}"
9833 run_test 133h "Proc files should end with newlines"
9836 remote_mds_nodsh && skip "remote MDS with nodsh" && return
9837 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.54) ]] &&
9838 skip "Need MDS version at least 2.7.54" && return
9840 mkdir -p $DIR/$tdir || error "failed to create $DIR/$tdir"
9841 cancel_lru_locks mdc
9843 local nsdir="ldlm.namespaces.*-MDT0000-mdc-*"
9844 local unused=$($LCTL get_param -n $nsdir.lock_unused_count)
9845 [ $unused -eq 0 ] || error "$unused locks are not cleared"
9848 createmany -o $DIR/$tdir/f $nr ||
9849 error "failed to create $nr files in $DIR/$tdir"
9850 unused=$($LCTL get_param -n $nsdir.lock_unused_count)
9852 #define OBD_FAIL_LDLM_WATERMARK_LOW 0x327
9853 do_facet mds1 $LCTL set_param fail_loc=0x327
9854 do_facet mds1 $LCTL set_param fail_val=500
9857 echo "sleep 10 seconds ..."
9859 local lck_cnt=$($LCTL get_param -n $nsdir.lock_unused_count)
9861 do_facet mds1 $LCTL set_param fail_loc=0
9862 do_facet mds1 $LCTL set_param fail_val=0
9863 [ $lck_cnt -lt $unused ] ||
9864 error "No locks reclaimed, before:$unused, after:$lck_cnt"
9867 unlinkmany $DIR/$tdir/f $nr
9869 run_test 134a "Server reclaims locks when reaching lock_reclaim_threshold"
9872 remote_mds_nodsh && skip "remote MDS with nodsh" && return
9873 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.54) ]] &&
9874 skip "Need MDS version at least 2.7.54" && return
9876 mkdir -p $DIR/$tdir || error "failed to create $DIR/$tdir"
9877 cancel_lru_locks mdc
9879 local low_wm=$(do_facet mds1 $LCTL get_param -n \
9880 ldlm.lock_reclaim_threshold_mb)
9881 # disable reclaim temporarily
9882 do_facet mds1 $LCTL set_param ldlm.lock_reclaim_threshold_mb=0
9884 #define OBD_FAIL_LDLM_WATERMARK_HIGH 0x328
9885 do_facet mds1 $LCTL set_param fail_loc=0x328
9886 do_facet mds1 $LCTL set_param fail_val=500
9888 $LCTL set_param debug=+trace
9891 createmany -o $DIR/$tdir/f $nr &
9894 echo "Sleep $TIMEOUT seconds ..."
9896 if ! ps -p $create_pid > /dev/null 2>&1; then
9897 do_facet mds1 $LCTL set_param fail_loc=0
9898 do_facet mds1 $LCTL set_param fail_val=0
9899 do_facet mds1 $LCTL set_param \
9900 ldlm.lock_reclaim_threshold_mb=${low_wm}m
9901 error "createmany finished incorrectly!"
9903 do_facet mds1 $LCTL set_param fail_loc=0
9904 do_facet mds1 $LCTL set_param fail_val=0
9905 do_facet mds1 $LCTL set_param ldlm.lock_reclaim_threshold_mb=${low_wm}m
9906 wait $create_pid || return 1
9908 unlinkmany $DIR/$tdir/f $nr
9910 run_test 134b "Server rejects lock request when reaching lock_limit_mb"
9912 test_140() { #bug-17379
9913 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9914 test_mkdir -p $DIR/$tdir || error "Creating dir $DIR/$tdir"
9915 cd $DIR/$tdir || error "Changing to $DIR/$tdir"
9916 cp $(which stat) . || error "Copying stat to $DIR/$tdir"
9918 # VFS limits max symlink depth to 5(4KSTACK) or 7(8KSTACK) or 8
9919 # For kernel > 3.5, bellow only tests consecutive symlink (MAX 40)
9921 while i=`expr $i + 1`; do
9922 test_mkdir -p $i || error "Creating dir $i"
9923 cd $i || error "Changing to $i"
9924 ln -s ../stat stat || error "Creating stat symlink"
9925 # Read the symlink until ELOOP present,
9926 # not LBUGing the system is considered success,
9927 # we didn't overrun the stack.
9928 $OPENFILE -f O_RDONLY stat >/dev/null 2>&1; ret=$?
9930 if [ $ret -eq 40 ]; then
9933 error "Open stat symlink"
9939 echo "The symlink depth = $i"
9940 [ $i -eq 5 -o $i -eq 7 -o $i -eq 8 -o $i -eq 40 ] ||
9941 error "Invalid symlink depth"
9943 # Test recursive symlink
9944 ln -s symlink_self symlink_self
9945 $OPENFILE -f O_RDONLY symlink_self >/dev/null 2>&1; ret=$?
9946 echo "open symlink_self returns $ret"
9947 [ $ret -eq 40 ] || error "recursive symlink doesn't return -ELOOP"
9949 run_test 140 "Check reasonable stack depth (shouldn't LBUG) ===="
9952 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9953 local TF="$TMP/$tfile"
9955 dd if=/dev/urandom of=$TF bs=6096 count=1 || error "dd failed"
9957 cancel_lru_locks osc
9958 cmp $TF $DIR/$tfile || error "$TMP/$tfile $DIR/$tfile differ"
9959 remount_client $MOUNT
9961 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (remount)"
9964 $TRUNCATE $DIR/$tfile 6000
9965 cancel_lru_locks osc
9966 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (truncate1)"
9969 echo "12345" >>$DIR/$tfile
9970 cancel_lru_locks osc
9971 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (append1)"
9974 echo "12345" >>$DIR/$tfile
9975 cancel_lru_locks osc
9976 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (append2)"
9981 run_test 150 "truncate/append tests"
9983 #LU-2902 roc_hit was not able to read all values from lproc
9984 function roc_hit_init() {
9985 local list=$(comma_list $(osts_nodes))
9986 local dir=$DIR/$tdir-check
9987 local file=$dir/file
9993 #use setstripe to do a write to every ost
9994 for i in $(seq 0 $((OSTCOUNT-1))); do
9995 $SETSTRIPE -c 1 -i $i $dir || error "$SETSTRIPE $file failed"
9996 dd if=/dev/urandom of=$file bs=4k count=4 2>&1 > /dev/null
9997 idx=$(printf %04x $i)
9998 BEFORE=$(get_osd_param $list *OST*$idx stats |
9999 awk '$1 == "cache_access" {sum += $7}
10000 END { printf("%0.0f", sum) }')
10002 cancel_lru_locks osc
10003 cat $file >/dev/null
10005 AFTER=$(get_osd_param $list *OST*$idx stats |
10006 awk '$1 == "cache_access" {sum += $7}
10007 END { printf("%0.0f", sum) }')
10009 echo BEFORE:$BEFORE AFTER:$AFTER
10010 if ! let "AFTER - BEFORE == 4"; then
10012 error "roc_hit is not safe to use"
10020 function roc_hit() {
10021 local list=$(comma_list $(osts_nodes))
10022 echo $(get_osd_param $list '' stats |
10023 awk '$1 == "cache_hit" {sum += $7}
10024 END { printf("%0.0f", sum) }')
10027 function set_cache() {
10030 if [ "$2" == "off" ]; then
10033 local list=$(comma_list $(osts_nodes))
10034 set_osd_param $list '' $1_cache_enable $on
10036 cancel_lru_locks osc
10040 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10041 remote_ost_nodsh && skip "remote OST with nodsh" && return
10044 local list=$(comma_list $(osts_nodes))
10046 # check whether obdfilter is cache capable at all
10047 if ! get_osd_param $list '' read_cache_enable >/dev/null; then
10048 echo "not cache-capable obdfilter"
10052 # check cache is enabled on all obdfilters
10053 if get_osd_param $list '' read_cache_enable | grep 0; then
10054 echo "oss cache is disabled"
10058 set_osd_param $list '' writethrough_cache_enable 1
10060 # check write cache is enabled on all obdfilters
10061 if get_osd_param $list '' writethrough_cache_enable | grep 0; then
10062 echo "oss write cache is NOT enabled"
10068 #define OBD_FAIL_OBD_NO_LRU 0x609
10069 do_nodes $list $LCTL set_param fail_loc=0x609
10071 # pages should be in the case right after write
10072 dd if=/dev/urandom of=$DIR/$tfile bs=4k count=$CPAGES ||
10075 local BEFORE=$(roc_hit)
10076 cancel_lru_locks osc
10077 cat $DIR/$tfile >/dev/null
10078 local AFTER=$(roc_hit)
10080 do_nodes $list $LCTL set_param fail_loc=0
10082 if ! let "AFTER - BEFORE == CPAGES"; then
10083 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
10086 # the following read invalidates the cache
10087 cancel_lru_locks osc
10088 set_osd_param $list '' read_cache_enable 0
10089 cat $DIR/$tfile >/dev/null
10091 # now data shouldn't be found in the cache
10093 cancel_lru_locks osc
10094 cat $DIR/$tfile >/dev/null
10096 if let "AFTER - BEFORE != 0"; then
10097 error "IN CACHE: before: $BEFORE, after: $AFTER"
10100 set_osd_param $list '' read_cache_enable 1
10103 run_test 151 "test cache on oss and controls ==============================="
10106 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10107 local TF="$TMP/$tfile"
10109 # simulate ENOMEM during write
10110 #define OBD_FAIL_OST_NOMEM 0x226
10111 lctl set_param fail_loc=0x80000226
10112 dd if=/dev/urandom of=$TF bs=6096 count=1 || error "dd failed"
10114 sync || error "sync failed"
10115 lctl set_param fail_loc=0
10117 # discard client's cache
10118 cancel_lru_locks osc
10120 # simulate ENOMEM during read
10121 lctl set_param fail_loc=0x80000226
10122 cmp $TF $DIR/$tfile || error "cmp failed"
10123 lctl set_param fail_loc=0
10127 run_test 152 "test read/write with enomem ============================"
10130 $MULTIOP $DIR/$tfile Ow4096Ycu || error "multiop failed"
10132 run_test 153 "test if fdatasync does not crash ======================="
10134 dot_lustre_fid_permission_check() {
10136 local ffid=$MOUNT/.lustre/fid/$fid
10139 echo "stat fid $fid"
10140 stat $ffid > /dev/null || error "stat $ffid failed."
10141 echo "touch fid $fid"
10142 touch $ffid || error "touch $ffid failed."
10143 echo "write to fid $fid"
10144 cat /etc/hosts > $ffid || error "write $ffid failed."
10145 echo "read fid $fid"
10146 diff /etc/hosts $ffid || error "read $ffid failed."
10147 echo "append write to fid $fid"
10148 cat /etc/hosts >> $ffid || error "append write $ffid failed."
10149 echo "rename fid $fid"
10150 mv $ffid $test_dir/$tfile.1 &&
10151 error "rename $ffid to $tfile.1 should fail."
10152 touch $test_dir/$tfile.1
10153 mv $test_dir/$tfile.1 $ffid &&
10154 error "rename $tfile.1 to $ffid should fail."
10155 rm -f $test_dir/$tfile.1
10156 echo "truncate fid $fid"
10157 $TRUNCATE $ffid 777 || error "truncate $ffid failed."
10158 if [ $MDSCOUNT -lt 2 ]; then #FIXME when cross-MDT hard link is working
10159 echo "link fid $fid"
10160 ln -f $ffid $test_dir/tfile.lnk || error "link $ffid failed."
10162 if [ -n $(lctl get_param -n mdc.*-mdc-*.connect_flags | grep acl) ]; then
10163 echo "setfacl fid $fid"
10164 setfacl -R -m u:bin:rwx $ffid || error "setfacl $ffid failed."
10165 echo "getfacl fid $fid"
10166 getfacl $ffid >/dev/null || error "getfacl $ffid failed."
10168 echo "unlink fid $fid"
10169 unlink $MOUNT/.lustre/fid/$fid && error "unlink $ffid should fail."
10170 echo "mknod fid $fid"
10171 mknod $ffid c 1 3 && error "mknod $ffid should fail."
10173 fid=[0xf00000400:0x1:0x0]
10174 ffid=$MOUNT/.lustre/fid/$fid
10176 echo "stat non-exist fid $fid"
10177 stat $ffid > /dev/null && error "stat non-exist $ffid should fail."
10178 echo "write to non-exist fid $fid"
10179 cat /etc/hosts > $ffid && error "write non-exist $ffid should fail."
10180 echo "link new fid $fid"
10181 ln $test_dir/$tfile $ffid && error "link $ffid should fail."
10183 mkdir -p $test_dir/$tdir
10184 touch $test_dir/$tdir/$tfile
10185 fid=$($LFS path2fid $test_dir/$tdir)
10188 error "error: could not get fid for $test_dir/$dir/$tfile."
10190 ffid=$MOUNT/.lustre/fid/$fid
10193 ls $ffid > /dev/null || error "ls $ffid failed."
10194 echo "touch $fid/$tfile.1"
10195 touch $ffid/$tfile.1 || error "touch $ffid/$tfile.1 failed."
10197 echo "touch $MOUNT/.lustre/fid/$tfile"
10198 touch $MOUNT/.lustre/fid/$tfile && \
10199 error "touch $MOUNT/.lustre/fid/$tfile should fail."
10201 echo "setxattr to $MOUNT/.lustre/fid"
10202 setfattr -n trusted.name1 -v value1 $MOUNT/.lustre/fid
10204 echo "listxattr for $MOUNT/.lustre/fid"
10205 getfattr -d -m "^trusted" $MOUNT/.lustre/fid
10207 echo "delxattr from $MOUNT/.lustre/fid"
10208 setfattr -x trusted.name1 $MOUNT/.lustre/fid
10210 echo "touch invalid fid: $MOUNT/.lustre/fid/[0x200000400:0x2:0x3]"
10211 touch $MOUNT/.lustre/fid/[0x200000400:0x2:0x3] &&
10212 error "touch invalid fid should fail."
10214 echo "touch non-normal fid: $MOUNT/.lustre/fid/[0x1:0x2:0x0]"
10215 touch $MOUNT/.lustre/fid/[0x1:0x2:0x0] &&
10216 error "touch non-normal fid should fail."
10218 echo "rename $tdir to $MOUNT/.lustre/fid"
10219 mrename $test_dir/$tdir $MOUNT/.lustre/fid &&
10220 error "rename to $MOUNT/.lustre/fid should fail."
10222 if [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.3.51) ]
10224 local old_obf_mode=$(stat --format="%a" $DIR/.lustre/fid)
10225 local new_obf_mode=777
10227 echo "change mode of $DIR/.lustre/fid to $new_obf_mode"
10228 chmod $new_obf_mode $DIR/.lustre/fid ||
10229 error "chmod $new_obf_mode $DIR/.lustre/fid failed"
10231 local obf_mode=$(stat --format=%a $DIR/.lustre/fid)
10232 [ $obf_mode -eq $new_obf_mode ] ||
10233 error "stat $DIR/.lustre/fid returned wrong mode $obf_mode"
10235 echo "restore mode of $DIR/.lustre/fid to $old_obf_mode"
10236 chmod $old_obf_mode $DIR/.lustre/fid ||
10237 error "chmod $old_obf_mode $DIR/.lustre/fid failed"
10240 $OPENFILE -f O_LOV_DELAY_CREATE:O_CREAT $test_dir/$tfile-2
10241 fid=$($LFS path2fid $test_dir/$tfile-2)
10243 if [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.6.50) ]
10245 echo "cp /etc/passwd $MOUNT/.lustre/fid/$fid"
10246 cp /etc/passwd $MOUNT/.lustre/fid/$fid ||
10247 error "create lov data thru .lustre failed"
10249 echo "cp /etc/passwd $test_dir/$tfile-2"
10250 cp /etc/passwd $test_dir/$tfile-2 ||
10251 error "copy to $test_dir/$tfile-2 failed."
10252 echo "diff /etc/passwd $MOUNT/.lustre/fid/$fid"
10253 diff /etc/passwd $MOUNT/.lustre/fid/$fid ||
10254 error "diff /etc/passwd $MOUNT/.lustre/fid/$fid failed."
10256 rm -rf $test_dir/tfile.lnk
10257 rm -rf $test_dir/$tfile-2
10261 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.1) ]] &&
10262 skip "Need MDS version at least 2.4.1" && return
10264 local tf=$DIR/$tfile
10267 local fid=$($LFS path2fid $tf)
10268 [ -z "$fid" ] && error "path2fid unable to get $tf FID"
10270 # check that we get the same pathname back
10271 local found=$($LFS fid2path $MOUNT "$fid")
10272 [ -z "$found" ] && error "fid2path unable to get '$fid' path"
10273 [ "$found" == "$tf" ] ||
10274 error "fid2path($fid=path2fid($tf)) = $found != $tf"
10276 run_test 154A "lfs path2fid and fid2path basic checks"
10279 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.1) ]] &&
10280 skip "Need MDS version at least 2.4.1" && return
10282 mkdir -p $DIR/$tdir || error "mkdir $tdir failed"
10283 touch $DIR/$tdir/$tfile || error "touch $DIR/$tdir/$tfile failed"
10284 local linkea=$($LL_DECODE_LINKEA $DIR/$tdir/$tfile | grep 'pfid')
10285 [ -z "$linkea" ] && error "decode linkea $DIR/$tdir/$tfile failed"
10287 local name=$(echo $linkea | awk '/pfid/ {print $5}' | sed -e "s/'//g")
10288 local PFID=$(echo $linkea | awk '/pfid/ {print $3}' | sed -e "s/,//g")
10290 # check that we get the same pathname
10291 echo "PFID: $PFID, name: $name"
10292 local FOUND=$($LFS fid2path $MOUNT "$PFID")
10293 [ -z "$FOUND" ] && error "fid2path unable to get $PFID path"
10294 [ "$FOUND/$name" != "$DIR/$tdir/$tfile" ] &&
10295 error "ll_decode_linkea has $FOUND/$name != $DIR/$tdir/$tfile"
10297 rm -rf $DIR/$tdir || error "Can not delete directory $DIR/$tdir"
10299 run_test 154B "verify the ll_decode_linkea tool"
10302 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10303 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.51) ]] ||
10304 { skip "Need MDS version at least 2.2.51"; return 0; }
10305 [ -z "$(which setfacl)" ] && skip "must have setfacl tool" && return
10306 [ -n "$FILESET" ] && skip "SKIP due to FILESET set" && return
10308 cp /etc/hosts $DIR/$tfile
10310 fid=$($LFS path2fid $DIR/$tfile)
10312 [ $rc -ne 0 ] && error "error: could not get fid for $DIR/$tfile."
10314 dot_lustre_fid_permission_check "$fid" $DIR ||
10315 error "dot lustre permission check $fid failed"
10317 rm -rf $MOUNT/.lustre && error ".lustre is not allowed to be unlinked"
10319 touch $MOUNT/.lustre/file &&
10320 error "creation is not allowed under .lustre"
10322 mkdir $MOUNT/.lustre/dir &&
10323 error "mkdir is not allowed under .lustre"
10327 run_test 154a "Open-by-FID"
10330 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10331 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.51) ]] ||
10332 { skip "Need MDS version at least 2.2.51"; return 0; }
10333 [ -n "$FILESET" ] && skip "SKIP due to FILESET set" && return
10335 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
10337 local remote_dir=$DIR/$tdir/remote_dir
10341 mkdir -p $DIR/$tdir
10342 $LFS mkdir -i $MDTIDX $remote_dir ||
10343 error "create remote directory failed"
10345 cp /etc/hosts $remote_dir/$tfile
10347 fid=$($LFS path2fid $remote_dir/$tfile)
10349 [ $rc -ne 0 ] && error "error: could not get fid for $remote_dir/$tfile"
10351 dot_lustre_fid_permission_check "$fid" $remote_dir ||
10352 error "dot lustre permission check $fid failed"
10355 run_test 154b "Open-by-FID for remote directory"
10358 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.1) ]] &&
10359 skip "Need MDS version at least 2.4.1" && return
10361 touch $DIR/$tfile.1 $DIR/$tfile.2 $DIR/$tfile.3
10362 local FID1=$($LFS path2fid $DIR/$tfile.1)
10363 local FID2=$($LFS path2fid $DIR/$tfile.2)
10364 local FID3=$($LFS path2fid $DIR/$tfile.3)
10367 $LFS path2fid $DIR/$tfile.[123] | while read PATHNAME FID; do
10368 [ "$PATHNAME" = "$DIR/$tfile.$N:" ] ||
10369 error "path2fid pathname $PATHNAME != $DIR/$tfile.$N:"
10371 [ "$FID" = "${!want}" ] ||
10372 error "path2fid $PATHNAME FID $FID != FID$N ${!want}"
10376 $LFS fid2path $MOUNT "$FID1" "$FID2" "$FID3" | while read PATHNAME;
10378 [ "$PATHNAME" = "$DIR/$tfile.$N" ] ||
10379 error "fid2path pathname $PATHNAME != $DIR/$tfile.$N:"
10383 run_test 154c "lfs path2fid and fid2path multiple arguments"
10386 remote_mds_nodsh && skip "remote MDS with nodsh" && return
10387 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.5.53) ]] &&
10388 skip "Need MDS version at least 2.5.53" && return
10390 if remote_mds; then
10391 nid=$($LCTL list_nids | sed "s/\./\\\./g")
10395 local proc_ofile="mdt.*.exports.'$nid'.open_files"
10402 local fid=$($LFS path2fid $DIR/$tfile)
10405 cmd="exec $fd<$DIR/$tfile"
10407 local fid_list=$(do_facet $SINGLEMDS $LCTL get_param $proc_ofile)
10408 echo "$fid_list" | grep "$fid"
10411 cmd="exec $fd>/dev/null"
10413 if [ $rc -ne 0 ]; then
10414 error "FID $fid not found in open files list $fid_list"
10417 run_test 154d "Verify open file fid"
10421 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.6.50) ]] &&
10422 skip "Need MDS version at least 2.6.50" && return
10424 if ls -a $MOUNT | grep -q '^\.lustre$'; then
10425 error ".lustre returned by readdir"
10428 run_test 154e ".lustre is not returned by readdir"
10431 [ -n "$FILESET" ] && skip "SKIP due to FILESET set" && return
10432 # create parent directory on a single MDT to avoid cross-MDT hardlinks
10433 test_mkdir -p -c1 $DIR/$tdir/d
10434 # test dirs inherit from its stripe
10435 mkdir -p $DIR/$tdir/d/foo1 || error "mkdir error"
10436 mkdir -p $DIR/$tdir/d/foo2 || error "mkdir error"
10437 cp /etc/hosts $DIR/$tdir/d/foo1/$tfile
10438 ln $DIR/$tdir/d/foo1/$tfile $DIR/$tdir/d/foo2/link
10441 # get fid of parents
10442 local FID0=$($LFS path2fid $DIR/$tdir/d)
10443 local FID1=$($LFS path2fid $DIR/$tdir/d/foo1)
10444 local FID2=$($LFS path2fid $DIR/$tdir/d/foo2)
10445 local FID3=$($LFS path2fid $DIR)
10447 # check that path2fid --parents returns expected <parent_fid>/name
10448 # 1) test for a directory (single parent)
10449 local parent=$($LFS path2fid --parents $DIR/$tdir/d/foo1)
10450 [ "$parent" == "$FID0/foo1" ] ||
10451 error "expected parent: $FID0/foo1, got: $parent"
10453 # 2) test for a file with nlink > 1 (multiple parents)
10454 parent=$($LFS path2fid --parents $DIR/$tdir/d/foo1/$tfile)
10455 echo "$parent" | grep -F "$FID1/$tfile" ||
10456 error "$FID1/$tfile not returned in parent list"
10457 echo "$parent" | grep -F "$FID2/link" ||
10458 error "$FID2/link not returned in parent list"
10460 # 3) get parent by fid
10461 local file_fid=$($LFS path2fid $DIR/$tdir/d/foo1/$tfile)
10462 parent=$($LFS path2fid --parents $MOUNT/.lustre/fid/$file_fid)
10463 echo "$parent" | grep -F "$FID1/$tfile" ||
10464 error "$FID1/$tfile not returned in parent list (by fid)"
10465 echo "$parent" | grep -F "$FID2/link" ||
10466 error "$FID2/link not returned in parent list (by fid)"
10468 # 4) test for entry in root directory
10469 parent=$($LFS path2fid --parents $DIR/f)
10470 echo "$parent" | grep -F "$FID3/f" ||
10471 error "$FID3/f not returned in parent list"
10473 # 5) test it on root directory
10474 [ -z "$($LFS path2fid --parents $MOUNT 2>/dev/null)" ] ||
10475 error "$MOUNT should not have parents"
10477 # enable xattr caching and check that linkea is correctly updated
10478 local save="$TMP/$TESTSUITE-$TESTNAME.parameters"
10479 save_lustre_params client "llite.*.xattr_cache" > $save
10480 lctl set_param llite.*.xattr_cache 1
10482 # 6.1) linkea update on rename
10483 mv $DIR/$tdir/d/foo1/$tfile $DIR/$tdir/d/foo2/$tfile.moved
10485 # get parents by fid
10486 parent=$($LFS path2fid --parents $MOUNT/.lustre/fid/$file_fid)
10487 # foo1 should no longer be returned in parent list
10488 echo "$parent" | grep -F "$FID1" &&
10489 error "$FID1 should no longer be in parent list"
10490 # the new path should appear
10491 echo "$parent" | grep -F "$FID2/$tfile.moved" ||
10492 error "$FID2/$tfile.moved is not in parent list"
10494 # 6.2) linkea update on unlink
10495 rm -f $DIR/$tdir/d/foo2/link
10496 parent=$($LFS path2fid --parents $MOUNT/.lustre/fid/$file_fid)
10497 # foo2/link should no longer be returned in parent list
10498 echo "$parent" | grep -F "$FID2/link" &&
10499 error "$FID2/link should no longer be in parent list"
10503 restore_lustre_params < $save
10506 run_test 154f "get parent fids by reading link ea"
10510 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.6.92) ]] ||
10511 { skip "Need MDS version at least 2.6.92"; return 0; }
10512 [ -n "$FILESET" ] && skip "SKIP due to FILESET set" && return
10514 mkdir -p $DIR/$tdir
10515 llapi_fid_test -d $DIR/$tdir
10517 run_test 154g "various llapi FID tests"
10519 test_155_small_load() {
10520 local temp=$TMP/$tfile
10521 local file=$DIR/$tfile
10523 dd if=/dev/urandom of=$temp bs=6096 count=1 || \
10524 error "dd of=$temp bs=6096 count=1 failed"
10526 cancel_lru_locks osc
10527 cmp $temp $file || error "$temp $file differ"
10529 $TRUNCATE $temp 6000
10530 $TRUNCATE $file 6000
10531 cmp $temp $file || error "$temp $file differ (truncate1)"
10533 echo "12345" >>$temp
10534 echo "12345" >>$file
10535 cmp $temp $file || error "$temp $file differ (append1)"
10537 echo "12345" >>$temp
10538 echo "12345" >>$file
10539 cmp $temp $file || error "$temp $file differ (append2)"
10545 test_155_big_load() {
10546 remote_ost_nodsh && skip "remote OST with nodsh" && return
10547 local temp=$TMP/$tfile
10548 local file=$DIR/$tfile
10551 local cache_size=$(do_facet ost$((MAXI+1)) \
10552 "awk '/cache/ {sum+=\\\$4} END {print sum}' /proc/cpuinfo")
10553 local large_file_size=$((cache_size * 2))
10555 echo "OSS cache size: $cache_size KB"
10556 echo "Large file size: $large_file_size KB"
10558 [ $MAXV -le $large_file_size ] && \
10559 skip_env "max available OST size needs > $large_file_size KB" && \
10562 $SETSTRIPE $file -c 1 -i $MAXI || error "$SETSTRIPE $file failed"
10564 dd if=/dev/urandom of=$temp bs=$large_file_size count=1k || \
10565 error "dd of=$temp bs=$large_file_size count=1k failed"
10568 cancel_lru_locks osc
10569 cmp $temp $file || error "$temp $file differ"
10575 save_writethrough() {
10576 local facets=$(get_facets OST)
10578 save_lustre_params $facets "obdfilter.*.writethrough_cache_enable" > $1
10579 save_lustre_params $facets "osd-*.*.writethrough_cache_enable" >> $1
10583 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10584 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
10585 save_writethrough $p
10588 set_cache writethrough on
10589 test_155_small_load
10590 restore_lustre_params < $p
10593 run_test 155a "Verify small file correctness: read cache:on write_cache:on"
10596 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10597 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
10598 save_writethrough $p
10601 set_cache writethrough off
10602 test_155_small_load
10603 restore_lustre_params < $p
10606 run_test 155b "Verify small file correctness: read cache:on write_cache:off"
10609 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10610 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
10611 save_writethrough $p
10614 set_cache writethrough on
10615 test_155_small_load
10616 restore_lustre_params < $p
10619 run_test 155c "Verify small file correctness: read cache:off write_cache:on"
10622 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10623 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
10624 save_writethrough $p
10627 set_cache writethrough off
10628 test_155_small_load
10629 restore_lustre_params < $p
10632 run_test 155d "Verify small file correctness: read cache:off write_cache:off"
10635 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10636 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
10637 save_writethrough $p
10640 set_cache writethrough on
10642 restore_lustre_params < $p
10645 run_test 155e "Verify big file correctness: read cache:on write_cache:on"
10648 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10649 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
10650 save_writethrough $p
10653 set_cache writethrough off
10655 restore_lustre_params < $p
10658 run_test 155f "Verify big file correctness: read cache:on write_cache:off"
10661 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10662 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
10663 save_writethrough $p
10666 set_cache writethrough on
10668 restore_lustre_params < $p
10671 run_test 155g "Verify big file correctness: read cache:off write_cache:on"
10674 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10675 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
10676 save_writethrough $p
10679 set_cache writethrough off
10681 restore_lustre_params < $p
10684 run_test 155h "Verify big file correctness: read cache:off write_cache:off"
10687 remote_ost_nodsh && skip "remote OST with nodsh" && return
10688 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10692 local file="$DIR/$tfile"
10693 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
10695 [ "$(facet_fstype ost1)" = "zfs" -a \
10696 $(lustre_version_code ost1 -lt $(version_code 2.6.93)) ] &&
10697 skip "LU-1956/LU-2261: stats not implemented on OSD ZFS" &&
10700 save_writethrough $p
10703 log "Turn on read and write cache"
10705 set_cache writethrough on
10707 log "Write data and read it back."
10708 log "Read should be satisfied from the cache."
10709 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
10711 cancel_lru_locks osc
10712 cat $file >/dev/null
10714 if ! let "AFTER - BEFORE == CPAGES"; then
10715 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
10717 log "cache hits:: before: $BEFORE, after: $AFTER"
10720 log "Read again; it should be satisfied from the cache."
10722 cancel_lru_locks osc
10723 cat $file >/dev/null
10725 if ! let "AFTER - BEFORE == CPAGES"; then
10726 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
10728 log "cache hits:: before: $BEFORE, after: $AFTER"
10731 log "Turn off the read cache and turn on the write cache"
10733 set_cache writethrough on
10735 log "Read again; it should be satisfied from the cache."
10737 cancel_lru_locks osc
10738 cat $file >/dev/null
10740 if ! let "AFTER - BEFORE == CPAGES"; then
10741 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
10743 log "cache hits:: before: $BEFORE, after: $AFTER"
10746 log "Read again; it should not be satisfied from the cache."
10748 cancel_lru_locks osc
10749 cat $file >/dev/null
10751 if ! let "AFTER - BEFORE == 0"; then
10752 error "IN CACHE: before: $BEFORE, after: $AFTER"
10754 log "cache hits:: before: $BEFORE, after: $AFTER"
10757 log "Write data and read it back."
10758 log "Read should be satisfied from the cache."
10759 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
10761 cancel_lru_locks osc
10762 cat $file >/dev/null
10764 if ! let "AFTER - BEFORE == CPAGES"; then
10765 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
10767 log "cache hits:: before: $BEFORE, after: $AFTER"
10770 log "Read again; it should not be satisfied from the cache."
10772 cancel_lru_locks osc
10773 cat $file >/dev/null
10775 if ! let "AFTER - BEFORE == 0"; then
10776 error "IN CACHE: before: $BEFORE, after: $AFTER"
10778 log "cache hits:: before: $BEFORE, after: $AFTER"
10781 log "Turn off read and write cache"
10783 set_cache writethrough off
10785 log "Write data and read it back"
10786 log "It should not be satisfied from the cache."
10788 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
10789 cancel_lru_locks osc
10791 cat $file >/dev/null
10793 if ! let "AFTER - BEFORE == 0"; then
10794 error_ignore bz20762 "IN CACHE: before: $BEFORE, after: $AFTER"
10796 log "cache hits:: before: $BEFORE, after: $AFTER"
10799 log "Turn on the read cache and turn off the write cache"
10801 set_cache writethrough off
10803 log "Write data and read it back"
10804 log "It should not be satisfied from the cache."
10806 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
10808 cancel_lru_locks osc
10809 cat $file >/dev/null
10811 if ! let "AFTER - BEFORE == 0"; then
10812 error_ignore bz20762 "IN CACHE: before: $BEFORE, after: $AFTER"
10814 log "cache hits:: before: $BEFORE, after: $AFTER"
10817 log "Read again; it should be satisfied from the cache."
10819 cancel_lru_locks osc
10820 cat $file >/dev/null
10822 if ! let "AFTER - BEFORE == CPAGES"; then
10823 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
10825 log "cache hits:: before: $BEFORE, after: $AFTER"
10829 restore_lustre_params < $p
10832 run_test 156 "Verification of tunables"
10835 cleanup_changelog () {
10837 echo "Deregistering changelog client $CL_USER"
10838 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister $CL_USER
10842 if [[ $MDSCOUNT -gt 1 ]]; then
10843 error_ignore bz17935 $*
10851 local CL_MASK_PARAM="mdd.$MDT0.changelog_mask"
10853 MASK=$(do_facet $SINGLEMDS $LCTL get_param $CL_MASK_PARAM| grep -c "$1")
10855 if [ $MASK -eq 1 ]; then
10856 do_facet $SINGLEMDS $LCTL set_param $CL_MASK_PARAM="-$1"
10858 do_facet $SINGLEMDS $LCTL set_param $CL_MASK_PARAM="+$1"
10862 changelog_extract_field() {
10866 local identifier=$4
10868 $LFS changelog $mdt | gawk "/$cltype.*$file$/ {
10869 print gensub(/^.* "$identifier'(\[[^\]]*\]).*$/,"\\1",1)}' |
10874 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10875 remote_mds_nodsh && skip "remote MDS with nodsh" && return
10876 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] ||
10877 { skip "Need MDS version at least 2.2.0"; return; }
10879 local CL_USERS="mdd.$MDT0.changelog_users"
10880 local GET_CL_USERS="do_facet $SINGLEMDS $LCTL get_param -n $CL_USERS"
10881 CL_USER=$(do_facet $SINGLEMDS $LCTL --device $MDT0 \
10882 changelog_register -n)
10883 echo "Registered as changelog user $CL_USER"
10884 trap cleanup_changelog EXIT
10885 $GET_CL_USERS | grep -q $CL_USER ||
10886 error "User $CL_USER not found in changelog_users"
10889 test_mkdir -p $DIR/$tdir/pics/2008/zachy
10890 touch $DIR/$tdir/pics/2008/zachy/timestamp
10891 cp /etc/hosts $DIR/$tdir/pics/2008/zachy/pic1.jpg
10892 mv $DIR/$tdir/pics/2008/zachy $DIR/$tdir/pics/zach
10893 ln $DIR/$tdir/pics/zach/pic1.jpg $DIR/$tdir/pics/2008/portland.jpg
10894 ln -s $DIR/$tdir/pics/2008/portland.jpg $DIR/$tdir/pics/desktop.jpg
10895 rm $DIR/$tdir/pics/desktop.jpg
10897 $LFS changelog $MDT0 | tail -5
10899 echo "verifying changelog mask"
10900 changelog_chmask "MKDIR"
10901 changelog_chmask "CLOSE"
10903 test_mkdir -p $DIR/$tdir/pics/zach/sofia
10904 echo "zzzzzz" > $DIR/$tdir/pics/zach/file
10906 changelog_chmask "MKDIR"
10907 changelog_chmask "CLOSE"
10909 test_mkdir -p $DIR/$tdir/pics/2008/sofia
10910 echo "zzzzzz" > $DIR/$tdir/pics/zach/file
10912 $LFS changelog $MDT0
10913 MKDIRS=$($LFS changelog $MDT0 | tail -5 | grep -c "MKDIR")
10914 CLOSES=$($LFS changelog $MDT0 | tail -5 | grep -c "CLOSE")
10915 [ $MKDIRS -eq 1 ] || err17935 "MKDIR changelog mask count $DIRS != 1"
10916 [ $CLOSES -eq 1 ] || err17935 "CLOSE changelog mask count $DIRS != 1"
10919 echo "verifying target fid"
10920 fidc=$(changelog_extract_field $MDT0 "CREAT" "timestamp" "t=")
10921 fidf=$($LFS path2fid $DIR/$tdir/pics/zach/timestamp)
10922 [ "$fidc" == "$fidf" ] ||
10923 err17935 "fid in changelog $fidc != file fid $fidf"
10924 echo "verifying parent fid"
10925 fidc=$(changelog_extract_field $MDT0 "CREAT" "timestamp" "p=")
10926 fidf=$($LFS path2fid $DIR/$tdir/pics/zach)
10927 [ "$fidc" == "$fidf" ] ||
10928 err17935 "pfid in changelog $fidc != dir fid $fidf"
10930 USER_REC1=$($GET_CL_USERS | awk "\$1 == \"$CL_USER\" {print \$2}")
10931 $LFS changelog_clear $MDT0 $CL_USER $(($USER_REC1 + 5))
10932 USER_REC2=$($GET_CL_USERS | awk "\$1 == \"$CL_USER\" {print \$2}")
10933 echo "verifying user clear: $(( $USER_REC1 + 5 )) == $USER_REC2"
10934 [ $USER_REC2 == $(($USER_REC1 + 5)) ] ||
10935 err17935 "user index expected $(($USER_REC1 + 5)) is $USER_REC2"
10937 MIN_REC=$($GET_CL_USERS |
10938 awk 'min == "" || $2 < min {min = $2}; END {print min}')
10939 FIRST_REC=$($LFS changelog $MDT0 | head -n1 | awk '{print $1}')
10940 echo "verifying min purge: $(( $MIN_REC + 1 )) == $FIRST_REC"
10941 [ $FIRST_REC == $(($MIN_REC + 1)) ] ||
10942 err17935 "first index should be $(($MIN_REC + 1)) is $FIRST_REC"
10944 # LU-3446 changelog index reset on MDT restart
10945 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
10946 CUR_REC1=$($GET_CL_USERS | head -n1 | cut -f3 -d' ')
10947 $LFS changelog_clear $MDT0 $CL_USER 0
10948 stop $SINGLEMDS || error "Fail to stop MDT."
10949 start $SINGLEMDS $MDT_DEV $MDS_MOUNT_OPTS || error "Fail to start MDT."
10950 CUR_REC2=$($GET_CL_USERS | head -n1 | cut -f3 -d' ')
10951 echo "verifying index survives MDT restart: $CUR_REC1 == $CUR_REC2"
10952 [ $CUR_REC1 == $CUR_REC2 ] ||
10953 err17935 "current index should be $CUR_REC1 is $CUR_REC2"
10955 echo "verifying user deregister"
10957 $GET_CL_USERS | grep -q $CL_USER &&
10958 error "User $CL_USER still in changelog_users"
10960 USERS=$(( $($GET_CL_USERS | wc -l) - 2 ))
10961 if [ $CL_USER -eq 0 ]; then
10962 LAST_REC1=$($GET_CL_USERS | head -n1 | cut -f3 -d' ')
10963 touch $DIR/$tdir/chloe
10964 LAST_REC2=$($GET_CL_USERS | head -n1 | cut -f3 -d' ')
10965 echo "verify changelogs are off: $LAST_REC1 == $LAST_REC2"
10966 [ $LAST_REC1 == $LAST_REC2 ] || error "changelogs not off"
10968 echo "$CL_USER other changelog users; can't verify off"
10971 run_test 160a "changelog sanity"
10973 test_160b() { # LU-3587
10974 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10975 remote_mds_nodsh && skip "remote MDS with nodsh" && return
10976 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] ||
10977 { skip "Need MDS version at least 2.2.0"; return; }
10979 local CL_USERS="mdd.$MDT0.changelog_users"
10980 local GET_CL_USERS="do_facet $SINGLEMDS $LCTL get_param -n $CL_USERS"
10981 CL_USER=$(do_facet $SINGLEMDS $LCTL --device $MDT0 \
10982 changelog_register -n)
10983 echo "Registered as changelog user $CL_USER"
10984 trap cleanup_changelog EXIT
10985 $GET_CL_USERS | grep -q $CL_USER ||
10986 error "User $CL_USER not found in changelog_users"
10988 local LONGNAME1=$(str_repeat a 255)
10989 local LONGNAME2=$(str_repeat b 255)
10992 echo "creating very long named file"
10993 touch $LONGNAME1 || error "create of $LONGNAME1 failed"
10994 echo "moving very long named file"
10995 mv $LONGNAME1 $LONGNAME2
10997 $LFS changelog $MDT0 | grep RENME
11001 run_test 160b "Verify that very long rename doesn't crash in changelog"
11004 remote_mds_nodsh && skip "remote MDS with nodsh" && return
11007 local server_version=$(lustre_version_code $SINGLEMDS)
11009 [[ $server_version -gt $(version_code 2.5.57) ]] ||
11010 [[ $server_version -gt $(version_code 2.5.1) &&
11011 $server_version -lt $(version_code 2.5.50) ]] ||
11012 { skip "Need MDS version at least 2.5.58 or 2.5.2+"; return; }
11013 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11015 # Registration step
11016 CL_USER=$(do_facet $SINGLEMDS $LCTL --device $MDT0 \
11017 changelog_register -n)
11018 trap cleanup_changelog EXIT
11021 mkdir -p $DIR/$tdir
11022 $MCREATE $DIR/$tdir/foo_160c
11023 changelog_chmask "TRUNC"
11024 $TRUNCATE $DIR/$tdir/foo_160c 200
11025 changelog_chmask "TRUNC"
11026 $TRUNCATE $DIR/$tdir/foo_160c 199
11027 $LFS changelog $MDT0
11028 TRUNCS=$($LFS changelog $MDT0 | tail -5 | grep -c "TRUNC")
11029 [ $TRUNCS -eq 1 ] || err17935 "TRUNC changelog mask count $TRUNCS != 1"
11030 $LFS changelog_clear $MDT0 $CL_USER 0
11032 # Deregistration step
11035 run_test 160c "verify that changelog log catch the truncate event"
11038 remote_mds_nodsh && skip "remote MDS with nodsh" && return
11039 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
11041 local server_version=$(lustre_version_code mds1)
11042 local CL_MASK_PARAM="mdd.$MDT0.changelog_mask"
11044 [[ $server_version -ge $(version_code 2.7.60) ]] ||
11045 { skip "Need MDS version at least 2.7.60+"; return; }
11046 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11048 # Registration step
11049 CL_USER=$(do_facet mds1 $LCTL --device $MDT0 \
11050 changelog_register -n)
11052 trap cleanup_changelog EXIT
11053 mkdir -p $DIR/$tdir/migrate_dir
11054 $LFS changelog_clear $MDT0 $CL_USER 0
11056 $LFS migrate -m 1 $DIR/$tdir/migrate_dir || error "migrate fails"
11057 $LFS changelog $MDT0
11058 MIGRATES=$($LFS changelog $MDT0 | tail -5 | grep -c "MIGRT")
11059 $LFS changelog_clear $MDT0 $CL_USER 0
11060 [ $MIGRATES -eq 1 ] ||
11061 error "MIGRATE changelog mask count $MIGRATES != 1"
11063 # Deregistration step
11066 run_test 160d "verify that changelog log catch the migrate event"
11070 CL_USER=$(do_facet $SINGLEMDS $LCTL --device $MDT0 \
11071 changelog_register -n)
11072 echo "Registered as changelog user $CL_USER"
11073 trap cleanup_changelog EXIT
11075 # Delete a future user (expect fail)
11076 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister cl77
11079 if [ $rc -eq 0 ]; then
11080 error "Deleted non-existant user cl77"
11081 elif [ $rc -ne 2 ]; then
11082 error "changelog_deregister failed with $rc, " \
11083 "expected 2 (ENOENT)"
11086 # Clear to a bad index (1 billion should be safe)
11087 $LFS changelog_clear $MDT0 $CL_USER 1000000000
11090 if [ $rc -eq 0 ]; then
11091 error "Successfully cleared to invalid CL index"
11092 elif [ $rc -ne 22 ]; then
11093 error "changelog_clear failed with $rc, expected 22 (EINVAL)"
11096 run_test 160e "changelog negative testing"
11099 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11100 test_mkdir -p -c1 $DIR/$tdir
11101 cp /etc/hosts $DIR/$tdir/$tfile
11102 test_mkdir -c1 $DIR/$tdir/foo1
11103 test_mkdir -c1 $DIR/$tdir/foo2
11104 ln $DIR/$tdir/$tfile $DIR/$tdir/foo1/sofia
11105 ln $DIR/$tdir/$tfile $DIR/$tdir/foo2/zachary
11106 ln $DIR/$tdir/$tfile $DIR/$tdir/foo1/luna
11107 ln $DIR/$tdir/$tfile $DIR/$tdir/foo2/thor
11108 local FID=$($LFS path2fid $DIR/$tdir/$tfile | tr -d '[]')
11109 if [ "$($LFS fid2path $DIR $FID | wc -l)" != "5" ]; then
11110 $LFS fid2path $DIR $FID
11111 err17935 "bad link ea"
11114 rm $DIR/$tdir/foo2/zachary
11116 rm $DIR/$tdir/foo2/thor
11118 rm $DIR/$tdir/$tfile
11120 mv $DIR/$tdir/foo1/sofia $DIR/$tdir/foo2/maggie
11121 if [ "$($LFS fid2path $FSNAME --link 1 $FID)" != "$tdir/foo2/maggie" ]
11123 $LFS fid2path $DIR $FID
11124 err17935 "bad link rename"
11126 rm $DIR/$tdir/foo2/maggie
11129 local longname=filename_avg_len_is_thirty_two_
11130 createmany -l$DIR/$tdir/foo1/luna $DIR/$tdir/foo2/$longname 1000 ||
11131 error "failed to hardlink many files"
11132 links=$($LFS fid2path $DIR $FID | wc -l)
11133 echo -n "${links}/1000 links in link EA"
11134 [[ $links -gt 60 ]] ||
11135 err17935 "expected at least 60 links in link EA"
11136 unlinkmany $DIR/$tdir/foo2/$longname 1000 ||
11137 error "failed to unlink many hardlinks"
11139 run_test 161a "link ea sanity"
11142 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11143 [ $MDSCOUNT -lt 2 ] && skip "skipping remote directory test" && return
11145 local remote_dir=$DIR/$tdir/remote_dir
11147 mkdir -p $DIR/$tdir
11148 $LFS mkdir -i $MDTIDX $remote_dir ||
11149 error "create remote directory failed"
11151 cp /etc/hosts $remote_dir/$tfile
11152 mkdir -p $remote_dir/foo1
11153 mkdir -p $remote_dir/foo2
11154 ln $remote_dir/$tfile $remote_dir/foo1/sofia
11155 ln $remote_dir/$tfile $remote_dir/foo2/zachary
11156 ln $remote_dir/$tfile $remote_dir/foo1/luna
11157 ln $remote_dir/$tfile $remote_dir/foo2/thor
11159 local FID=$($LFS path2fid $remote_dir/$tfile | tr -d '[' |
11161 if [ "$($LFS fid2path $DIR $FID | wc -l)" != "5" ]; then
11162 $LFS fid2path $DIR $FID
11163 err17935 "bad link ea"
11166 rm $remote_dir/foo2/zachary
11168 rm $remote_dir/foo2/thor
11170 rm $remote_dir/$tfile
11172 mv $remote_dir/foo1/sofia $remote_dir/foo2/maggie
11173 local link_path=$($LFS fid2path $FSNAME --link 1 $FID)
11174 if [ "$DIR/$link_path" != "$remote_dir/foo2/maggie" ]; then
11175 $LFS fid2path $DIR $FID
11176 err17935 "bad link rename"
11178 rm $remote_dir/foo2/maggie
11181 local longname=filename_avg_len_is_thirty_two_
11182 createmany -l$remote_dir/foo1/luna $remote_dir/foo2/$longname 1000 ||
11183 error "failed to hardlink many files"
11184 links=$($LFS fid2path $DIR $FID | wc -l)
11185 echo -n "${links}/1000 links in link EA"
11186 [[ ${links} -gt 60 ]] ||
11187 err17935 "expected at least 60 links in link EA"
11188 unlinkmany $remote_dir/foo2/$longname 1000 ||
11189 error "failed to unlink many hardlinks"
11191 run_test 161b "link ea sanity under remote directory"
11194 remote_mds_nodsh && skip "remote MDS with nodsh" && return
11195 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11196 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.1.5) ]] &&
11197 skip "Need MDS version at least 2.1.5" && return
11199 # define CLF_RENAME_LAST 0x0001
11200 # rename overwrite a target having nlink = 1 (changelog flag 0x1)
11201 CL_USER=$(do_facet $SINGLEMDS $LCTL --device $MDT0 \
11202 changelog_register -n)
11204 trap cleanup_changelog EXIT
11206 mkdir -p $DIR/$tdir
11207 touch $DIR/$tdir/foo_161c
11208 touch $DIR/$tdir/bar_161c
11209 mv -f $DIR/$tdir/foo_161c $DIR/$tdir/bar_161c
11210 $LFS changelog $MDT0 | grep RENME
11211 local flags=$($LFS changelog $MDT0 | grep RENME | tail -1 | \
11213 $LFS changelog_clear $MDT0 $CL_USER 0
11214 if [ x$flags != "x0x1" ]; then
11215 error "flag $flags is not 0x1"
11217 echo "rename overwrite a target having nlink = 1," \
11218 "changelog record has flags of $flags"
11220 # rename overwrite a target having nlink > 1 (changelog flag 0x0)
11221 touch $DIR/$tdir/foo_161c
11222 touch $DIR/$tdir/bar_161c
11223 ln $DIR/$tdir/bar_161c $DIR/$tdir/foobar_161c
11224 mv -f $DIR/$tdir/foo_161c $DIR/$tdir/bar_161c
11225 $LFS changelog $MDT0 | grep RENME
11226 flags=$($LFS changelog $MDT0 | grep RENME | tail -1 | cut -f5 -d' ')
11227 $LFS changelog_clear $MDT0 $CL_USER 0
11228 if [ x$flags != "x0x0" ]; then
11229 error "flag $flags is not 0x0"
11231 echo "rename overwrite a target having nlink > 1," \
11232 "changelog record has flags of $flags"
11234 # rename doesn't overwrite a target (changelog flag 0x0)
11235 touch $DIR/$tdir/foo_161c
11236 mv -f $DIR/$tdir/foo_161c $DIR/$tdir/foo2_161c
11237 $LFS changelog $MDT0 | grep RENME
11238 flags=$($LFS changelog $MDT0 | grep RENME | tail -1 | cut -f5 -d' ')
11239 $LFS changelog_clear $MDT0 $CL_USER 0
11240 if [ x$flags != "x0x0" ]; then
11241 error "flag $flags is not 0x0"
11243 echo "rename doesn't overwrite a target," \
11244 "changelog record has flags of $flags"
11246 # define CLF_UNLINK_LAST 0x0001
11247 # unlink a file having nlink = 1 (changelog flag 0x1)
11248 rm -f $DIR/$tdir/foo2_161c
11249 $LFS changelog $MDT0 | grep UNLNK
11250 flags=$($LFS changelog $MDT0 | grep UNLNK | tail -1 | cut -f5 -d' ')
11251 $LFS changelog_clear $MDT0 $CL_USER 0
11252 if [ x$flags != "x0x1" ]; then
11253 error "flag $flags is not 0x1"
11255 echo "unlink a file having nlink = 1," \
11256 "changelog record has flags of $flags"
11258 # unlink a file having nlink > 1 (changelog flag 0x0)
11259 ln -f $DIR/$tdir/bar_161c $DIR/$tdir/foobar_161c
11260 rm -f $DIR/$tdir/foobar_161c
11261 $LFS changelog $MDT0 | grep UNLNK
11262 flags=$($LFS changelog $MDT0 | grep UNLNK | tail -1 | cut -f5 -d' ')
11263 $LFS changelog_clear $MDT0 $CL_USER 0
11264 if [ x$flags != "x0x0" ]; then
11265 error "flag $flags is not 0x0"
11267 echo "unlink a file having nlink > 1," \
11268 "changelog record has flags of $flags"
11271 run_test 161c "check CL_RENME[UNLINK] changelog record flags"
11278 # cleanup previous run
11279 rm -rf $DIR/$tdir/$tfile
11281 user=$(do_facet $SINGLEMDS $LCTL --device $MDT0 \
11282 changelog_register -n)
11283 [[ $? -eq 0 ]] || error "changelog_register failed"
11285 # work in a standalone dir to avoid locking on $DIR/$MOUNT to
11286 # interfer with $MOUNT/.lustre/fid/ access
11288 [[ $? -eq 0 ]] || error "mkdir failed"
11290 #define OBD_FAIL_LLITE_CREATE_NODE_PAUSE 0x140c | OBD_FAIL_ONCE
11291 $LCTL set_param fail_loc=0x8000140c
11293 $LCTL set_param fail_val=5
11296 echo foofoo > $DIR/$tdir/$tfile &
11299 # wait for create to be delayed
11303 [[ $? -eq 0 ]] || error "create should be blocked"
11305 local tempfile=$(mktemp)
11306 fid=$(changelog_extract_field $MDT0 "CREAT" "$tfile" "t=")
11307 cat $MOUNT/.lustre/fid/$fid 2>/dev/null >$tempfile || error "cat failed"
11308 # some delay may occur during ChangeLog publishing and file read just
11309 # above, that could allow file write to happen finally
11310 [[ -s $tempfile ]] && echo "file should be empty"
11312 $LCTL set_param fail_loc=0
11315 [[ $? -eq 0 ]] || error "create failed"
11317 $LFS changelog_clear $MDT0 $user 0
11318 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister $user
11320 run_test 161d "create with concurrent .lustre/fid access"
11327 local path=$(${LFS} fid2path $*)
11328 # Remove the '//' indicating a remote directory
11329 path=$(echo $path | sed 's#//#/#g')
11332 if [ $RC -ne 0 ]; then
11333 err17935 "path looked up of $expected failed. Error $RC"
11335 elif [ "${path}" != "${expected}" ]; then
11336 err17935 "path looked up \"${path}\" instead of \"${expected}\""
11339 echo "fid $fid resolves to path $path (expected $expected)"
11342 test_162a() { # was test_162
11343 # Make changes to filesystem
11344 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11345 test_mkdir -p -c1 $DIR/$tdir/d2
11346 touch $DIR/$tdir/d2/$tfile
11347 touch $DIR/$tdir/d2/x1
11348 touch $DIR/$tdir/d2/x2
11349 test_mkdir -p -c1 $DIR/$tdir/d2/a/b/c
11350 test_mkdir -p -c1 $DIR/$tdir/d2/p/q/r
11352 FID=$($LFS path2fid $DIR/$tdir/d2/$tfile | tr -d '[]')
11353 check_path "$tdir/d2/$tfile" $FSNAME $FID --link 0 ||
11354 error "check path $tdir/d2/$tfile failed"
11357 ln -s $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/p/q/r/slink
11358 FID=$($LFS path2fid $DIR/$tdir/d2/p/q/r/slink | tr -d '[]')
11359 check_path "$tdir/d2/p/q/r/slink" $FSNAME $FID --link 0 ||
11360 error "check path $tdir/d2/p/q/r/slink failed"
11362 # softlink to wrong file
11363 ln -s /this/is/garbage $DIR/$tdir/d2/p/q/r/slink.wrong
11364 FID=$($LFS path2fid $DIR/$tdir/d2/p/q/r/slink.wrong | tr -d '[]')
11365 check_path "$tdir/d2/p/q/r/slink.wrong" $FSNAME $FID --link 0 ||
11366 error "check path $tdir/d2/p/q/r/slink.wrong failed"
11369 ln $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/p/q/r/hlink
11370 mv $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/a/b/c/new_file
11371 FID=$($LFS path2fid $DIR/$tdir/d2/a/b/c/new_file | tr -d '[]')
11372 # fid2path dir/fsname should both work
11373 check_path "$tdir/d2/a/b/c/new_file" $FSNAME $FID --link 1 ||
11374 error "check path $tdir/d2/a/b/c/new_file failed"
11375 check_path "$DIR/$tdir/d2/p/q/r/hlink" $DIR $FID --link 0 ||
11376 error "check path $DIR/$tdir/d2/p/q/r/hlink failed"
11378 # hardlink count: check that there are 2 links
11379 # Doesnt work with CMD yet: 17935
11380 ${LFS} fid2path $DIR $FID | wc -l | grep -q 2 || \
11381 err17935 "expected 2 links"
11383 # hardlink indexing: remove the first link
11384 rm $DIR/$tdir/d2/p/q/r/hlink
11385 check_path "$tdir/d2/a/b/c/new_file" $FSNAME $FID --link 0 ||
11386 error "check path $DIR/$tdir/d2/a/b/c/new_file failed"
11390 run_test 162a "path lookup sanity"
11393 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11394 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
11397 $LFS setdirstripe -i0 -c$MDSCOUNT -t all_char $DIR/$tdir/striped_dir ||
11398 error "create striped dir failed"
11400 local FID=$($LFS getdirstripe $DIR/$tdir/striped_dir |
11401 tail -n 1 | awk '{print $2}')
11402 stat $MOUNT/.lustre/fid/$FID && error "sub_stripe can be accessed"
11404 touch $DIR/$tdir/striped_dir/f{0..4} || error "touch f0..4 failed"
11405 mkdir $DIR/$tdir/striped_dir/d{0..4} || error "mkdir d0..4 failed"
11408 for ((i=0;i<5;i++)); do
11409 FID=$($LFS path2fid $DIR/$tdir/striped_dir/f$i | tr -d '[]') ||
11410 error "get fid for f$i failed"
11411 check_path "$tdir/striped_dir/f$i" $FSNAME $FID --link 0 ||
11412 error "check path $tdir/striped_dir/f$i failed"
11414 FID=$($LFS path2fid $DIR/$tdir/striped_dir/d$i | tr -d '[]') ||
11415 error "get fid for d$i failed"
11416 check_path "$tdir/striped_dir/d$i" $FSNAME $FID --link 0 ||
11417 error "check path $tdir/striped_dir/d$i failed"
11422 run_test 162b "striped directory path lookup sanity"
11424 # LU-4239: Verify fid2path works with paths 100 or more directories deep
11426 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.51) ]] &&
11427 skip "Need MDS version at least 2.7.51" && return
11428 test_mkdir $DIR/$tdir.local
11429 test_mkdir $DIR/$tdir.remote
11430 local lpath=$tdir.local
11431 local rpath=$tdir.remote
11433 for ((i = 0; i <= 101; i++)); do
11436 FID=$($LFS path2fid $DIR/$lpath | tr -d '[]') ||
11437 error "get fid for local directory $DIR/$lpath failed"
11438 check_path "$DIR/$lpath" $MOUNT $FID --link 0 ||
11439 error "check path for local directory $DIR/$lpath failed"
11442 test_mkdir $DIR/$rpath
11443 FID=$($LFS path2fid $DIR/$rpath | tr -d '[]') ||
11444 error "get fid for remote directory $DIR/$rpath failed"
11445 check_path "$DIR/$rpath" $MOUNT $FID --link 0 ||
11446 error "check path for remote directory $DIR/$rpath failed"
11451 run_test 162c "fid2path works with paths 100 or more directories deep"
11454 # do directio so as not to populate the page cache
11455 log "creating a 10 Mb file"
11456 $MULTIOP $DIR/$tfile oO_CREAT:O_DIRECT:O_RDWR:w$((10*1048576))c || error "multiop failed while creating a file"
11457 log "starting reads"
11458 dd if=$DIR/$tfile of=/dev/null bs=4096 &
11459 log "truncating the file"
11460 $MULTIOP $DIR/$tfile oO_TRUNC:c || error "multiop failed while truncating the file"
11462 kill %+ || true # reads might have finished
11463 echo "wait until dd is finished"
11465 log "removing the temporary file"
11466 rm -rf $DIR/$tfile || error "tmp file removal failed"
11468 run_test 169 "parallel read and truncate should not deadlock"
11471 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11472 $LCTL clear # bug 18514
11473 $LCTL debug_daemon start $TMP/${tfile}_log_good
11475 $LCTL debug_daemon stop
11476 sed -e "s/^...../a/g" $TMP/${tfile}_log_good > $TMP/${tfile}_log_bad ||
11477 error "sed failed to read log_good"
11479 $LCTL debug_daemon start $TMP/${tfile}_log_good
11481 $LCTL debug_daemon stop
11483 $LCTL df $TMP/${tfile}_log_bad > $TMP/${tfile}_log_bad.out 2>&1 ||
11484 error "lctl df log_bad failed"
11486 local bad_line=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $9}')
11487 local good_line1=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $5}')
11489 $LCTL df $TMP/${tfile}_log_good > $TMP/${tfile}_log_good.out 2>&1
11490 local good_line2=$(tail -n 1 $TMP/${tfile}_log_good.out | awk '{print $5}')
11492 [ "$bad_line" ] && [ "$good_line1" ] && [ "$good_line2" ] ||
11493 error "bad_line good_line1 good_line2 are empty"
11495 cat $TMP/${tfile}_log_good >> $TMP/${tfile}_logs_corrupt
11496 cat $TMP/${tfile}_log_bad >> $TMP/${tfile}_logs_corrupt
11497 cat $TMP/${tfile}_log_good >> $TMP/${tfile}_logs_corrupt
11499 $LCTL df $TMP/${tfile}_logs_corrupt > $TMP/${tfile}_log_bad.out 2>&1
11500 local bad_line_new=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $9}')
11501 local good_line_new=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $5}')
11503 [ "$bad_line_new" ] && [ "$good_line_new" ] ||
11504 error "bad_line_new good_line_new are empty"
11506 local expected_good=$((good_line1 + good_line2*2))
11508 rm -f $TMP/${tfile}*
11509 # LU-231, short malformed line may not be counted into bad lines
11510 if [ $bad_line -ne $bad_line_new ] &&
11511 [ $bad_line -ne $((bad_line_new - 1)) ]; then
11512 error "expected $bad_line bad lines, but got $bad_line_new"
11516 if [ $expected_good -ne $good_line_new ]; then
11517 error "expected $expected_good good lines, but got $good_line_new"
11522 run_test 170 "test lctl df to handle corrupted log ====================="
11524 test_171() { # bug20592
11525 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11526 #define OBD_FAIL_PTLRPC_DUMP_LOG 0x50e
11527 $LCTL set_param fail_loc=0x50e
11528 $LCTL set_param fail_val=3000
11529 multiop_bg_pause $DIR/$tfile O_s || true
11531 kill -USR1 $MULTIPID
11535 if dmesg | grep "recursive fault"; then
11536 error "caught a recursive fault"
11538 $LCTL set_param fail_loc=0
11541 run_test 171 "test libcfs_debug_dumplog_thread stuck in do_exit() ======"
11543 # it would be good to share it with obdfilter-survey/iokit-libecho code
11544 setup_obdecho_osc () {
11547 local obdfilter_name=$2
11548 echo "Creating new osc for $obdfilter_name on $ost_nid"
11549 # make sure we can find loopback nid
11550 $LCTL add_uuid $ost_nid $ost_nid >/dev/null 2>&1
11552 [ $rc -eq 0 ] && { $LCTL attach osc ${obdfilter_name}_osc \
11553 ${obdfilter_name}_osc_UUID || rc=2; }
11554 [ $rc -eq 0 ] && { $LCTL --device ${obdfilter_name}_osc setup \
11555 ${obdfilter_name}_UUID $ost_nid || rc=3; }
11559 cleanup_obdecho_osc () {
11560 local obdfilter_name=$1
11561 $LCTL --device ${obdfilter_name}_osc cleanup >/dev/null
11562 $LCTL --device ${obdfilter_name}_osc detach >/dev/null
11569 local pages=${3:-64}
11574 local obd_size=$(get_obd_size $node $OBD)
11575 local page_size=$(get_page_size $node)
11576 if [[ -n "$obd_size" ]]; then
11577 local new_count=$((obd_size / (pages * page_size / 1024)))
11578 [[ $new_count -ge $count ]] || count=$new_count
11581 do_facet $node "$LCTL attach echo_client ec ec_uuid" || rc=1
11582 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec setup $OBD" ||
11584 if [ $rc -eq 0 ]; then
11585 id=$(do_facet $node "$LCTL --device ec create 1" | awk '/object id/ {print $6}')
11586 [ ${PIPESTATUS[0]} -eq 0 -a -n "$id" ] || rc=3
11588 echo "New object id is $id"
11589 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec getattr $id" ||
11591 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec " \
11592 "test_brw $count w v $pages $id" || rc=4; }
11593 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec destroy $id 1" ||
11595 [ $rc -eq 0 -o $rc -gt 2 ] && { do_facet $node "$LCTL --device ec " \
11596 "cleanup" || rc=5; }
11597 [ $rc -eq 0 -o $rc -gt 1 ] && { do_facet $node "$LCTL --device ec " \
11598 "detach" || rc=6; }
11599 [ $rc -ne 0 ] && echo "obecho_create_test failed: $rc"
11604 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11605 remote_ost_nodsh && skip "remote OST with nodsh" && return
11607 local rmmod_local=0
11609 if ! module_loaded obdecho; then
11610 load_module obdecho/obdecho
11614 local osc=$($LCTL dl | grep -v mdt | awk '$3 == "osc" {print $4; exit}')
11615 local host=$(lctl get_param -n osc.$osc.import |
11616 awk '/current_connection:/ {print $2}' )
11617 local target=$(lctl get_param -n osc.$osc.import |
11618 awk '/target:/ {print $2}' )
11619 target=${target%_UUID}
11621 [[ -n $target ]] && { setup_obdecho_osc $host $target || rc=1; } || rc=1
11622 [ $rc -eq 0 ] && { obdecho_test ${target}_osc client || rc=2; }
11623 [[ -n $target ]] && cleanup_obdecho_osc $target
11624 [ $rmmod_local -eq 1 ] && rmmod obdecho
11627 run_test 180a "test obdecho on osc"
11630 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11631 remote_ost_nodsh && skip "remote OST with nodsh" && return
11633 local rmmod_remote=0
11635 do_facet ost1 "lsmod | grep -q obdecho || " \
11636 "{ insmod ${LUSTRE}/obdecho/obdecho.ko || " \
11637 "modprobe obdecho; }" && rmmod_remote=1
11638 target=$(do_facet ost1 $LCTL dl | awk '/obdfilter/ {print $4;exit}')
11639 [[ -n $target ]] && { obdecho_test $target ost1 || rc=1; }
11640 [ $rmmod_remote -eq 1 ] && do_facet ost1 "rmmod obdecho"
11643 run_test 180b "test obdecho directly on obdfilter"
11645 test_180c() { # LU-2598
11646 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11647 remote_ost_nodsh && skip "remote OST with nodsh" && return
11648 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.0) ]] &&
11649 skip "Need MDS version at least 2.4.0" && return
11652 local rmmod_remote=false
11653 local pages=16384 # 64MB bulk I/O RPC size
11656 do_rpc_nodes $(facet_active_host ost1) load_module obdecho/obdecho &&
11657 rmmod_remote=true || error "failed to load module obdecho"
11659 target=$(do_facet ost1 $LCTL dl | awk '/obdfilter/ { print $4 }' |
11661 if [ -n "$target" ]; then
11662 obdecho_test "$target" ost1 "$pages" || rc=${PIPESTATUS[0]}
11664 echo "there is no obdfilter target on ost1"
11667 $rmmod_remote && do_facet ost1 "rmmod obdecho" || true
11670 run_test 180c "test huge bulk I/O size on obdfilter, don't LASSERT"
11672 test_181() { # bug 22177
11673 test_mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
11674 # create enough files to index the directory
11675 createmany -o $DIR/$tdir/foobar 4000
11676 # print attributes for debug purpose
11679 multiop_bg_pause $DIR/$tdir D_Sc || return 1
11681 # remove the files & current working dir
11682 unlinkmany $DIR/$tdir/foobar 4000
11684 kill -USR1 $MULTIPID
11686 stat $DIR/$tdir && error "open-unlinked dir was not removed!"
11689 run_test 181 "Test open-unlinked dir ========================"
11695 mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
11697 $LCTL set_param mdc.*.rpc_stats=clear
11699 for (( i = 0; i < $tcount; i++ )) ; do
11700 mkdir $DIR/$tdir/$i
11703 for (( i = 0; i < $tcount; i++ )) ; do
11704 createmany -o $DIR/$tdir/$i/f- $fcount &
11708 for (( i = 0; i < $tcount; i++ )) ; do
11709 unlinkmany $DIR/$tdir/$i/f- $fcount &
11713 $LCTL get_param mdc.*.rpc_stats
11717 run_test 182 "Test parallel modify metadata operations ================"
11719 test_183() { # LU-2275
11720 remote_mds_nodsh && skip "remote MDS with nodsh" && return
11721 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.3.56) ]] &&
11722 skip "Need MDS version at least 2.3.56" && return
11724 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11725 mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
11726 echo aaa > $DIR/$tdir/$tfile
11728 #define OBD_FAIL_MDS_NEGATIVE_POSITIVE 0x148
11729 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x148
11731 ls -l $DIR/$tdir && error "ls succeeded, should have failed"
11732 cat $DIR/$tdir/$tfile && error "cat succeeded, should have failed"
11734 do_facet $SINGLEMDS $LCTL set_param fail_loc=0
11736 # Flush negative dentry cache
11737 touch $DIR/$tdir/$tfile
11739 # We are not checking for any leaked references here, they'll
11740 # become evident next time we do cleanup with module unload.
11743 run_test 183 "No crash or request leak in case of strange dispositions ========"
11745 # test suite 184 is for LU-2016, LU-2017
11747 check_swap_layouts_support && return 0
11749 dir0=$DIR/$tdir/$testnum
11750 test_mkdir -p -c1 $dir0 || error "creating dir $dir0"
11755 $SETSTRIPE -c1 $file1
11757 $SETSTRIPE -c2 $file2
11759 gen1=$($GETSTRIPE -g $file1)
11760 gen2=$($GETSTRIPE -g $file2)
11762 $LFS swap_layouts $file1 $file2 || error "swap of file layout failed"
11763 gen=$($GETSTRIPE -g $file1)
11764 [[ $gen1 != $gen ]] ||
11765 "Layout generation on $file1 does not change"
11766 gen=$($GETSTRIPE -g $file2)
11767 [[ $gen2 != $gen ]] ||
11768 "Layout generation on $file2 does not change"
11770 cmp $ref1 $file2 || error "content compare failed ($ref1 != $file2)"
11771 cmp $ref2 $file1 || error "content compare failed ($ref2 != $file1)"
11773 run_test 184a "Basic layout swap"
11776 check_swap_layouts_support && return 0
11778 dir0=$DIR/$tdir/$testnum
11779 mkdir -p $dir0 || error "creating dir $dir0"
11786 $SETSTRIPE -c1 $file1
11787 $SETSTRIPE -c2 $file2
11788 $SETSTRIPE -c1 $file3
11789 chown $RUNAS_ID $file3
11790 gen1=$($GETSTRIPE -g $file1)
11791 gen2=$($GETSTRIPE -g $file2)
11793 $LFS swap_layouts $dir1 $dir2 &&
11794 error "swap of directories layouts should fail"
11795 $LFS swap_layouts $dir1 $file1 &&
11796 error "swap of directory and file layouts should fail"
11797 $RUNAS $LFS swap_layouts $file1 $file2 &&
11798 error "swap of file we cannot write should fail"
11799 $LFS swap_layouts $file1 $file3 &&
11800 error "swap of file with different owner should fail"
11801 /bin/true # to clear error code
11803 run_test 184b "Forbidden layout swap (will generate errors)"
11806 local cmpn_arg=$(cmp -n 2>&1 | grep "invalid option")
11807 [ -n "$cmpn_arg" ] && skip_env "cmp does not support -n" && return
11808 check_swap_layouts_support && return 0
11810 local dir0=$DIR/$tdir/$testnum
11811 mkdir -p $dir0 || error "creating dir $dir0"
11813 local ref1=$dir0/ref1
11814 local ref2=$dir0/ref2
11815 local file1=$dir0/file1
11816 local file2=$dir0/file2
11817 # create a file large enough for the concurrent test
11818 dd if=/dev/urandom of=$ref1 bs=1M count=$((RANDOM % 50 + 20))
11819 dd if=/dev/urandom of=$ref2 bs=1M count=$((RANDOM % 50 + 20))
11820 echo "ref file size: ref1($(stat -c %s $ref1))," \
11821 "ref2($(stat -c %s $ref2))"
11824 dd if=$ref1 of=$file1 bs=16k &
11827 # Make sure dd starts to copy file
11828 while [ ! -f $file1 ]; do sleep 0.1; done
11830 $LFS swap_layouts $file1 $file2
11833 [[ $? == 0 ]] || error "concurrent write on $file1 failed"
11834 [[ $rc == 0 ]] || error "swap of $file1 and $file2 failed"
11836 # how many bytes copied before swapping layout
11837 local copied=$(stat -c %s $file2)
11838 local remaining=$(stat -c %s $ref1)
11839 remaining=$((remaining - copied))
11840 echo "Copied $copied bytes before swapping layout..."
11842 cmp -n $copied $file1 $ref2 | grep differ &&
11843 error "Content mismatch [0, $copied) of ref2 and file1"
11844 cmp -n $copied $file2 $ref1 ||
11845 error "Content mismatch [0, $copied) of ref1 and file2"
11846 cmp -i $copied:$copied -n $remaining $file1 $ref1 ||
11847 error "Content mismatch [$copied, EOF) of ref1 and file1"
11850 rm -f $ref1 $ref2 $file1 $file2
11852 run_test 184c "Concurrent write and layout swap"
11855 check_swap_layouts_support && return 0
11856 [ -z "$(which getfattr 2>/dev/null)" ] &&
11857 skip "no getfattr command" && return 0
11859 local file1=$DIR/$tdir/$tfile-1
11860 local file2=$DIR/$tdir/$tfile-2
11861 local file3=$DIR/$tdir/$tfile-3
11865 mkdir -p $DIR/$tdir
11866 touch $file1 || error "create $file1 failed"
11867 $OPENFILE -f O_CREAT:O_LOV_DELAY_CREATE $file2 ||
11868 error "create $file2 failed"
11869 $OPENFILE -f O_CREAT:O_LOV_DELAY_CREATE $file3 ||
11870 error "create $file3 failed"
11871 lovea1=$($LFS getstripe $file1 | sed 1d)
11873 $LFS swap_layouts $file2 $file3 ||
11874 error "swap $file2 $file3 layouts failed"
11875 $LFS swap_layouts $file1 $file2 ||
11876 error "swap $file1 $file2 layouts failed"
11878 lovea2=$($LFS getstripe $file2 | sed 1d)
11879 [ "$lovea1" == "$lovea2" ] || error "lovea $lovea1 != $lovea2"
11881 lovea1=$(getfattr -n trusted.lov $file1 | grep ^trusted)
11882 [[ -z "$lovea1" ]] || error "$file1 shouldn't have lovea"
11884 run_test 184d "allow stripeless layouts swap"
11887 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.6.94) ]] ||
11888 { skip "Need MDS version at least 2.6.94"; return 0; }
11889 check_swap_layouts_support && return 0
11890 [ -z "$(which getfattr 2>/dev/null)" ] &&
11891 skip "no getfattr command" && return 0
11893 local file1=$DIR/$tdir/$tfile-1
11894 local file2=$DIR/$tdir/$tfile-2
11895 local file3=$DIR/$tdir/$tfile-3
11898 mkdir -p $DIR/$tdir
11899 touch $file1 || error "create $file1 failed"
11900 $OPENFILE -f O_CREAT:O_LOV_DELAY_CREATE $file2 ||
11901 error "create $file2 failed"
11902 $OPENFILE -f O_CREAT:O_LOV_DELAY_CREATE $file3 ||
11903 error "create $file3 failed"
11905 $LFS swap_layouts $file1 $file2 ||
11906 error "swap $file1 $file2 layouts failed"
11908 lovea=$(getfattr -n trusted.lov $file1 | grep ^trusted)
11909 [[ -z "$lovea" ]] || error "$file1 shouldn't have lovea"
11911 echo 123 > $file1 || error "Should be able to write into $file1"
11913 $LFS swap_layouts $file1 $file3 ||
11914 error "swap $file1 $file3 layouts failed"
11916 echo 123 > $file1 || error "Should be able to write into $file1"
11918 rm -rf $file1 $file2 $file3
11920 run_test 184e "Recreate layout after stripeless layout swaps"
11922 test_185() { # LU-2441
11923 # LU-3553 - no volatile file support in old servers
11924 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.3.60) ]] ||
11925 { skip "Need MDS version at least 2.3.60"; return 0; }
11927 mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
11928 touch $DIR/$tdir/spoo
11929 local mtime1=$(stat -c "%Y" $DIR/$tdir)
11930 local fid=$($MULTIOP $DIR/$tdir VFw4096c) ||
11931 error "cannot create/write a volatile file"
11932 [ "$FILESET" == "" ] &&
11933 $CHECKSTAT -t file $MOUNT/.lustre/fid/$fid 2>/dev/null &&
11934 error "FID is still valid after close"
11936 multiop_bg_pause $DIR/$tdir vVw4096_c
11943 # assume that the next FID for this client is sequential, since stdout
11944 # is unfortunately eaten by multiop_bg_pause
11945 local n=$((${fidv[1]} + 1))
11946 local next_fid="${fidv[0]}:$(printf "0x%x" $n):${fidv[2]}"
11947 if [ "$FILESET" == "" ]; then
11948 $CHECKSTAT -t file $MOUNT/.lustre/fid/$next_fid ||
11949 error "FID is missing before close"
11951 kill -USR1 $multi_pid
11952 # 1 second delay, so if mtime change we will see it
11954 local mtime2=$(stat -c "%Y" $DIR/$tdir)
11955 [[ $mtime1 == $mtime2 ]] || error "mtime has changed"
11957 run_test 185 "Volatile file support"
11960 remote_mds_nodsh && skip "remote MDS with nodsh" && return
11961 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.3.0) ] &&
11962 skip "Need MDS version at least 2.3.0" && return
11964 local dir0=$DIR/$tdir/$testnum
11965 mkdir -p $dir0 || error "creating dir $dir0"
11967 local file=$dir0/file1
11968 dd if=/dev/urandom of=$file count=10 bs=1M conv=fsync
11969 local dv1=$($LFS data_version $file)
11970 dd if=/dev/urandom of=$file seek=10 count=1 bs=1M conv=fsync
11971 local dv2=$($LFS data_version $file)
11972 [[ $dv1 != $dv2 ]] ||
11973 error "data version did not change on write $dv1 == $dv2"
11978 run_test 187a "Test data version change"
11981 remote_mds_nodsh && skip "remote MDS with nodsh" && return
11982 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.3.0) ] &&
11983 skip "Need MDS version at least 2.3.0" && return
11985 local dir0=$DIR/$tdir/$testnum
11986 mkdir -p $dir0 || error "creating dir $dir0"
11988 declare -a DV=$($MULTIOP $dir0 Vw1000xYw1000xY | cut -f3 -d" ")
11989 [[ ${DV[0]} != ${DV[1]} ]] ||
11990 error "data version did not change on write"\
11991 " ${DV[0]} == ${DV[1]}"
11996 run_test 187b "Test data version change on volatile file"
11999 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12000 remote_mgs_nodsh && skip "remote MGS with nodsh" && return
12001 [ -n "$FILESET" ] && skip "SKIP due to FILESET set" && return
12003 local POOL=${POOL:-cea1}
12004 local POOL_ROOT=${POOL_ROOT:-$DIR/d200.pools}
12005 local POOL_DIR_NAME=${POOL_DIR_NAME:-dir_tst}
12008 local last_ost=$(($OSTCOUNT - 1))
12010 local ost_list=$(seq $first_ost $ost_step $last_ost)
12011 local ost_range="$first_ost $last_ost $ost_step"
12012 local test_path=$POOL_ROOT/$POOL_DIR_NAME
12013 local file_dir=$POOL_ROOT/file_tst
12014 local subdir=$test_path/subdir
12018 # former test_200a test_200b
12019 pool_add $POOL || { rc=$? ; break; }
12020 pool_add_targets $POOL $ost_range || { rc=$? ; break; }
12021 # former test_200c test_200d
12022 mkdir -p $test_path
12023 pool_set_dir $POOL $test_path || { rc=$? ; break; }
12024 pool_check_dir $POOL $test_path || { rc=$? ; break; }
12026 pool_check_dir $POOL $subdir || { rc=$? ; break; }
12027 pool_dir_rel_path $POOL $POOL_DIR_NAME $POOL_ROOT \
12028 || { rc=$? ; break; }
12029 # former test_200e test_200f
12030 local files=$((OSTCOUNT*3))
12031 pool_alloc_files $POOL $test_path $files "$ost_list" \
12032 || { rc=$? ; break; }
12033 pool_create_files $POOL $file_dir $files "$ost_list" \
12034 || { rc=$? ; break; }
12035 # former test_200g test_200h
12036 pool_lfs_df $POOL || { rc=$? ; break; }
12037 pool_file_rel_path $POOL $test_path || { rc=$? ; break; }
12039 # former test_201a test_201b test_201c
12040 pool_remove_first_target $POOL || { rc=$? ; break; }
12042 local f=$test_path/$tfile
12043 pool_remove_all_targets $POOL $f || { rc=$? ; break; }
12044 pool_remove $POOL $f || { rc=$? ; break; }
12051 run_test 200 "OST pools"
12053 # usage: default_attr <count | size | offset>
12055 $LCTL get_param -n lov.$FSNAME-clilov-\*.stripe${1}
12058 # usage: check_default_stripe_attr
12059 check_default_stripe_attr() {
12060 ACTUAL=$($GETSTRIPE $* $DIR/$tdir)
12062 --stripe-count|--count)
12063 [ -n "$2" ] && EXPECTED=0 || EXPECTED=$(default_attr count);;
12064 --stripe-size|--size)
12065 [ -n "$2" ] && EXPECTED=0 || EXPECTED=$(default_attr size);;
12066 --stripe-index|--index)
12069 error "unknown getstripe attr '$1'"
12072 [ $ACTUAL != $EXPECTED ] &&
12073 error "$DIR/$tdir has $1 '$ACTUAL', not '$EXPECTED'"
12077 test_mkdir -p $DIR/$tdir
12078 $SETSTRIPE --stripe-count 0 --stripe-size 0 --stripe-index -1 $DIR/$tdir
12080 check_default_stripe_attr --stripe-count
12081 check_default_stripe_attr --stripe-size
12082 check_default_stripe_attr --stripe-index
12086 run_test 204a "Print default stripe attributes ================="
12089 test_mkdir -p $DIR/$tdir
12090 $SETSTRIPE --stripe-count 1 $DIR/$tdir
12092 check_default_stripe_attr --stripe-size
12093 check_default_stripe_attr --stripe-index
12097 run_test 204b "Print default stripe size and offset ==========="
12100 test_mkdir -p $DIR/$tdir
12101 $SETSTRIPE --stripe-size 65536 $DIR/$tdir
12103 check_default_stripe_attr --stripe-count
12104 check_default_stripe_attr --stripe-index
12108 run_test 204c "Print default stripe count and offset ==========="
12111 test_mkdir -p $DIR/$tdir
12112 $SETSTRIPE --stripe-index 0 $DIR/$tdir
12114 check_default_stripe_attr --stripe-count
12115 check_default_stripe_attr --stripe-size
12119 run_test 204d "Print default stripe count and size ============="
12122 test_mkdir -p $DIR/$tdir
12123 $SETSTRIPE -d $DIR/$tdir
12125 check_default_stripe_attr --stripe-count --raw
12126 check_default_stripe_attr --stripe-size --raw
12127 check_default_stripe_attr --stripe-index --raw
12131 run_test 204e "Print raw stripe attributes ================="
12134 test_mkdir -p $DIR/$tdir
12135 $SETSTRIPE --stripe-count 1 $DIR/$tdir
12137 check_default_stripe_attr --stripe-size --raw
12138 check_default_stripe_attr --stripe-index --raw
12142 run_test 204f "Print raw stripe size and offset ==========="
12145 test_mkdir -p $DIR/$tdir
12146 $SETSTRIPE --stripe-size 65536 $DIR/$tdir
12148 check_default_stripe_attr --stripe-count --raw
12149 check_default_stripe_attr --stripe-index --raw
12153 run_test 204g "Print raw stripe count and offset ==========="
12156 test_mkdir -p $DIR/$tdir
12157 $SETSTRIPE --stripe-index 0 $DIR/$tdir
12159 check_default_stripe_attr --stripe-count --raw
12160 check_default_stripe_attr --stripe-size --raw
12164 run_test 204h "Print raw stripe count and size ============="
12166 # Figure out which job scheduler is being used, if any,
12167 # or use a fake one
12168 if [ -n "$SLURM_JOB_ID" ]; then # SLURM
12169 JOBENV=SLURM_JOB_ID
12170 elif [ -n "$LSB_JOBID" ]; then # Load Sharing Facility
12172 elif [ -n "$PBS_JOBID" ]; then # PBS/Maui/Moab
12174 elif [ -n "$LOADL_STEPID" ]; then # LoadLeveller
12175 JOBENV=LOADL_STEP_ID
12176 elif [ -n "$JOB_ID" ]; then # Sun Grid Engine
12179 $LCTL list_param jobid_name > /dev/null 2>&1
12180 if [ $? -eq 0 ]; then
12187 verify_jobstats() {
12192 # we don't really need to clear the stats for this test to work, since each
12193 # command has a unique jobid, but it makes debugging easier if needed.
12194 # for facet in $facets; do
12195 # local dev=$(convert_facet2label $facet)
12196 # # clear old jobstats
12197 # do_facet $facet lctl set_param *.$dev.job_stats="clear"
12200 # use a new JobID for each test, or we might see an old one
12201 [ "$JOBENV" = "FAKE_JOBID" ] &&
12202 FAKE_JOBID=id.$testnum.$(basename ${cmd[0]}).$RANDOM
12206 [ "$JOBENV" = "nodelocal" ] && {
12207 FAKE_JOBID=id.$testnum.$(basename ${cmd[0]}).$RANDOM
12208 $LCTL set_param jobid_name=$FAKE_JOBID
12212 log "Test: ${cmd[*]}"
12213 log "Using JobID environment variable $JOBENV=$JOBVAL"
12215 if [ $JOBENV = "FAKE_JOBID" ]; then
12216 FAKE_JOBID=$JOBVAL ${cmd[*]}
12221 # all files are created on OST0000
12222 for facet in $facets; do
12223 local stats="*.$(convert_facet2label $facet).job_stats"
12224 if [ $(do_facet $facet lctl get_param $stats |
12225 grep -c $JOBVAL) -ne 1 ]; then
12226 do_facet $facet lctl get_param $stats
12227 error "No jobstats for $JOBVAL found on $facet::$stats"
12234 NEW_JOBENV=${1:-$OLD_JOBENV}
12235 do_facet mgs $LCTL conf_param $FSNAME.sys.jobid_var=$NEW_JOBENV
12236 wait_update $HOSTNAME "$LCTL get_param -n jobid_var" $NEW_JOBENV
12241 do_facet $SINGLEMDS \
12242 $LCTL set_param mdt.*.job_cleanup_interval=$OLD_INTERVAL
12243 [ $OLD_JOBENV != $JOBENV ] && jobstats_set $OLD_JOBENV
12247 test_205() { # Job stats
12248 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.7.1) ]] ||
12249 { skip "Need MDS version with at least 2.7.1"; return 0; }
12251 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12252 remote_mgs_nodsh && skip "remote MGS with nodsh" && return
12253 remote_mds_nodsh && skip "remote MDS with nodsh" && return
12254 remote_ost_nodsh && skip "remote OST with nodsh" && return
12256 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep jobstats)" ] &&
12257 skip "Server doesn't support jobstats" && return 0
12258 [[ $JOBID_VAR = disable ]] && skip "jobstats is disabled" && return
12260 OLD_JOBENV=$($LCTL get_param -n jobid_var)
12261 if [ $OLD_JOBENV != $JOBENV ]; then
12262 jobstats_set $JOBENV
12263 trap cleanup_205 EXIT
12266 CL_USER=$(do_facet $SINGLEMDS lctl --device $MDT0 changelog_register -n)
12267 echo "Registered as changelog user $CL_USER"
12269 OLD_INTERVAL=$(do_facet $SINGLEMDS \
12270 lctl get_param -n mdt.*.job_cleanup_interval)
12271 local interval_new=5
12272 do_facet $SINGLEMDS \
12273 $LCTL set_param mdt.*.job_cleanup_interval=$interval_new
12274 local start=$SECONDS
12278 cmd="mkdir $DIR/$tdir"
12279 verify_jobstats "$cmd" "$SINGLEMDS"
12281 cmd="rmdir $DIR/$tdir"
12282 verify_jobstats "$cmd" "$SINGLEMDS"
12283 # mkdir on secondary MDT
12284 if [ $MDSCOUNT -gt 1 ]; then
12285 cmd="lfs mkdir -i 1 $DIR/$tdir.remote"
12286 verify_jobstats "$cmd" "mds2"
12289 cmd="mknod $DIR/$tfile c 1 3"
12290 verify_jobstats "$cmd" "$SINGLEMDS"
12292 cmd="rm -f $DIR/$tfile"
12293 verify_jobstats "$cmd" "$SINGLEMDS"
12294 # create all files on OST0000 so verify_jobstats can find OST stats
12296 cmd="$SETSTRIPE -i 0 -c 1 $DIR/$tfile"
12297 verify_jobstats "$cmd" "$SINGLEMDS"
12299 cmd="touch $DIR/$tfile"
12300 verify_jobstats "$cmd" "$SINGLEMDS ost1"
12302 cmd="dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 oflag=sync"
12303 verify_jobstats "$cmd" "ost1"
12305 cancel_lru_locks osc
12306 cmd="dd if=$DIR/$tfile of=/dev/null bs=1M count=1 iflag=direct"
12307 verify_jobstats "$cmd" "ost1"
12309 cmd="$TRUNCATE $DIR/$tfile 0"
12310 verify_jobstats "$cmd" "$SINGLEMDS ost1"
12312 cmd="mv -f $DIR/$tfile $DIR/$tdir.rename"
12313 verify_jobstats "$cmd" "$SINGLEMDS"
12314 # jobstats expiry - sleep until old stats should be expired
12315 local left=$((interval_new + 5 - (SECONDS - start)))
12316 [ $left -ge 0 ] && wait_update_facet $SINGLEMDS \
12317 "lctl get_param *.*.job_stats | grep -c 'job_id.*mkdir'" \
12319 cmd="mkdir $DIR/$tdir.expire"
12320 verify_jobstats "$cmd" "$SINGLEMDS"
12321 [ $(do_facet $SINGLEMDS lctl get_param *.*.job_stats |
12322 grep -c "job_id.*mkdir") -gt 1 ] && error "old jobstats not expired"
12324 # Ensure that jobid are present in changelog (if supported by MDS)
12325 if [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.6.52) ]
12327 $LFS changelog $MDT0 | tail -9
12328 jobids=$($LFS changelog $MDT0 | tail -9 | grep -c "j=")
12329 [ $jobids -eq 9 ] ||
12330 error "Wrong changelog jobid count $jobids != 9"
12334 jobstats_set $JOBENV
12336 $LFS changelog $MDT0 | tail -1
12337 jobids=$($LFS changelog $MDT0 | tail -1 | grep -c "j=")
12338 [ $jobids -eq 0 ] ||
12339 error "Unexpected jobids when jobid_var=$JOBENV"
12344 run_test 205 "Verify job stats"
12346 # LU-1480, LU-1773 and LU-1657
12348 mkdir -p $DIR/$tdir
12349 $SETSTRIPE -c -1 $DIR/$tdir
12350 #define OBD_FAIL_LOV_INIT 0x1403
12351 $LCTL set_param fail_loc=0xa0001403
12352 $LCTL set_param fail_val=1
12353 touch $DIR/$tdir/$tfile || true
12355 run_test 206 "fail lov_init_raid0() doesn't lbug"
12358 dd if=/dev/zero of=$DIR/$tfile bs=4k count=$((RANDOM%10+1))
12359 local fsz=`stat -c %s $DIR/$tfile`
12360 cancel_lru_locks mdc
12362 # do not return layout in getattr intent
12363 #define OBD_FAIL_MDS_NO_LL_GETATTR 0x170
12364 $LCTL set_param fail_loc=0x170
12365 local sz=`stat -c %s $DIR/$tfile`
12367 [ $fsz -eq $sz ] || error "file size expected $fsz, actual $sz"
12371 run_test 207a "can refresh layout at glimpse"
12374 dd if=/dev/zero of=$DIR/$tfile bs=4k count=$((RANDOM%10+1))
12375 local cksum=`md5sum $DIR/$tfile`
12376 local fsz=`stat -c %s $DIR/$tfile`
12377 cancel_lru_locks mdc
12378 cancel_lru_locks osc
12380 # do not return layout in getattr intent
12381 #define OBD_FAIL_MDS_NO_LL_OPEN 0x171
12382 $LCTL set_param fail_loc=0x171
12384 # it will refresh layout after the file is opened but before read issues
12385 echo checksum is "$cksum"
12386 echo "$cksum" |md5sum -c --quiet || error "file differs"
12390 run_test 207b "can refresh layout at open"
12393 # FIXME: in this test suite, only RD lease is used. This is okay
12394 # for now as only exclusive open is supported. After generic lease
12395 # is done, this test suite should be revised. - Jinshan
12397 remote_mds_nodsh && skip "remote MDS with nodsh" && return
12398 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.4.52) ]] ||
12399 { skip "Need MDS version at least 2.4.52"; return 0; }
12401 echo "==== test 1: verify get lease work"
12402 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:eRE+eU || error "get lease error"
12404 echo "==== test 2: verify lease can be broken by upcoming open"
12405 $MULTIOP $DIR/$tfile oO_RDONLY:eR_E-eUc &
12409 $MULTIOP $DIR/$tfile oO_RDONLY:c
12410 kill -USR1 $PID && wait $PID || error "break lease error"
12412 echo "==== test 3: verify lease can't be granted if an open already exists"
12413 $MULTIOP $DIR/$tfile oO_RDONLY:_c &
12417 $MULTIOP $DIR/$tfile oO_RDONLY:eReUc && error "apply lease should fail"
12418 kill -USR1 $PID && wait $PID || error "open file error"
12420 echo "==== test 4: lease can sustain over recovery"
12421 $MULTIOP $DIR/$tfile oO_RDONLY:eR_E+eUc &
12427 kill -USR1 $PID && wait $PID || error "lease broken over recovery"
12429 echo "==== test 5: lease broken can't be regained by replay"
12430 $MULTIOP $DIR/$tfile oO_RDONLY:eR_E-eUc &
12434 # open file to break lease and then recovery
12435 $MULTIOP $DIR/$tfile oO_RDWR:c || error "open file error"
12438 kill -USR1 $PID && wait $PID || error "lease not broken over recovery"
12442 run_test 208 "Exclusive open"
12445 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep disp_stripe)" ] &&
12446 skip_env "must have disp_stripe" && return
12449 sync; sleep 5; sync;
12451 echo 3 > /proc/sys/vm/drop_caches
12452 req_before=$(awk '/ptlrpc_cache / { print $2 }' /proc/slabinfo)
12454 # open/close 500 times
12455 for i in $(seq 500); do
12459 echo 3 > /proc/sys/vm/drop_caches
12460 req_after=$(awk '/ptlrpc_cache / { print $2 }' /proc/slabinfo)
12462 echo "before: $req_before, after: $req_after"
12463 [ $((req_after - req_before)) -ge 300 ] &&
12464 error "open/close requests are not freed"
12467 run_test 209 "read-only open/close requests should be freed promptly"
12471 size=$((size % 8192 + 1))
12472 dd if=/dev/urandom of=$DIR/f212 bs=1k count=$size
12473 sendfile $DIR/f212 $DIR/f212.xyz || error "sendfile wrong"
12474 rm -f $DIR/f212 $DIR/f212.xyz
12476 run_test 212 "Sendfile test ============================================"
12479 dd if=/dev/zero of=$DIR/$tfile bs=4k count=4
12480 cancel_lru_locks osc
12481 lctl set_param fail_loc=0x8000040f
12482 # generate a read lock
12483 cat $DIR/$tfile > /dev/null
12484 # write to the file, it will try to cancel the above read lock.
12485 cat /etc/hosts >> $DIR/$tfile
12487 run_test 213 "OSC lock completion and cancel race don't crash - bug 18829"
12489 test_214() { # for bug 20133
12490 mkdir -p $DIR/$tdir/d214c || error "mkdir $DIR/$tdir/d214c failed"
12491 for (( i=0; i < 340; i++ )) ; do
12492 touch $DIR/$tdir/d214c/a$i
12495 ls -l $DIR/$tdir || error "ls -l $DIR/d214p failed"
12496 mv $DIR/$tdir/d214c $DIR/ || error "mv $DIR/d214p/d214c $DIR/ failed"
12497 ls $DIR/d214c || error "ls $DIR/d214c failed"
12498 rm -rf $DIR/$tdir || error "rm -rf $DIR/d214* failed"
12499 rm -rf $DIR/d214* || error "rm -rf $DIR/d214* failed"
12501 run_test 214 "hash-indexed directory test - bug 20133"
12503 # having "abc" as 1st arg, creates $TMP/lnet_abc.out and $TMP/lnet_abc.sys
12504 create_lnet_proc_files() {
12505 lctl get_param -n $1 >$TMP/lnet_$1.out || error "cannot read lnet.$1"
12506 sysctl lnet.$1 >$TMP/lnet_$1.sys_tmp || error "cannot read lnet.$1"
12508 sed "s/^lnet.$1\ =\ //g" "$TMP/lnet_$1.sys_tmp" >$TMP/lnet_$1.sys
12509 rm -f "$TMP/lnet_$1.sys_tmp"
12512 # counterpart of create_lnet_proc_files
12513 remove_lnet_proc_files() {
12514 rm -f $TMP/lnet_$1.out $TMP/lnet_$1.sys
12517 # uses 1st arg as trailing part of filename, 2nd arg as description for reports,
12518 # 3rd arg as regexp for body
12519 check_lnet_proc_stats() {
12520 local l=$(cat "$TMP/lnet_$1" |wc -l)
12521 [ $l = 1 ] || (cat "$TMP/lnet_$1" && error "$2 is not of 1 line: $l")
12523 grep -E "$3" "$TMP/lnet_$1" || (cat "$TMP/lnet_$1" && error "$2 misformatted")
12526 # uses 1st arg as trailing part of filename, 2nd arg as description for reports,
12527 # 3rd arg as regexp for body, 4th arg as regexp for 1st line, 5th arg is
12528 # optional and can be regexp for 2nd line (lnet.routes case)
12529 check_lnet_proc_entry() {
12530 local blp=2 # blp stands for 'position of 1st line of body'
12531 [ -z "$5" ] || blp=3 # lnet.routes case
12533 local l=$(cat "$TMP/lnet_$1" |wc -l)
12534 # subtracting one from $blp because the body can be empty
12535 [ "$l" -ge "$(($blp - 1))" ] || (cat "$TMP/lnet_$1" && error "$2 is too short: $l")
12537 sed -n '1 p' "$TMP/lnet_$1" |grep -E "$4" >/dev/null ||
12538 (cat "$TMP/lnet_$1" && error "1st line of $2 misformatted")
12540 [ "$5" = "" ] || sed -n '2 p' "$TMP/lnet_$1" |grep -E "$5" >/dev/null ||
12541 (cat "$TMP/lnet_$1" && error "2nd line of $2 misformatted")
12543 # bail out if any unexpected line happened
12544 sed -n "$blp p" "$TMP/lnet_$1" | grep -Ev "$3"
12545 [ "$?" != 0 ] || error "$2 misformatted"
12548 test_215() { # for bugs 18102, 21079, 21517
12549 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12550 local N='(0|[1-9][0-9]*)' # non-negative numeric
12551 local P='[1-9][0-9]*' # positive numeric
12552 local I='(0|-?[1-9][0-9]*|NA)' # any numeric (0 | >0 | <0) or NA if no value
12553 local NET='[a-z][a-z0-9]*' # LNET net like o2ib2
12554 local ADDR='[0-9.]+' # LNET addr like 10.0.0.1
12555 local NID="$ADDR@$NET" # LNET nid like 10.0.0.1@o2ib2
12557 local L1 # regexp for 1st line
12558 local L2 # regexp for 2nd line (optional)
12559 local BR # regexp for the rest (body)
12561 # lnet.stats should look as 11 space-separated non-negative numerics
12562 BR="^$N $N $N $N $N $N $N $N $N $N $N$"
12563 create_lnet_proc_files "stats"
12564 check_lnet_proc_stats "stats.sys" "lnet.stats" "$BR"
12565 remove_lnet_proc_files "stats"
12567 # lnet.routes should look like this:
12568 # Routing disabled/enabled
12569 # net hops priority state router
12570 # where net is a string like tcp0, hops > 0, priority >= 0,
12571 # state is up/down,
12572 # router is a string like 192.168.1.1@tcp2
12573 L1="^Routing (disabled|enabled)$"
12574 L2="^net +hops +priority +state +router$"
12575 BR="^$NET +$N +(0|1) +(up|down) +$NID$"
12576 create_lnet_proc_files "routes"
12577 check_lnet_proc_entry "routes.sys" "lnet.routes" "$BR" "$L1" "$L2"
12578 remove_lnet_proc_files "routes"
12580 # lnet.routers should look like this:
12581 # ref rtr_ref alive_cnt state last_ping ping_sent deadline down_ni router
12582 # where ref > 0, rtr_ref > 0, alive_cnt >= 0, state is up/down,
12583 # last_ping >= 0, ping_sent is boolean (0/1), deadline and down_ni are
12584 # numeric (0 or >0 or <0), router is a string like 192.168.1.1@tcp2
12585 L1="^ref +rtr_ref +alive_cnt +state +last_ping +ping_sent +deadline +down_ni +router$"
12586 BR="^$P +$P +$N +(up|down) +$N +(0|1) +$I +$I +$NID$"
12587 create_lnet_proc_files "routers"
12588 check_lnet_proc_entry "routers.sys" "lnet.routers" "$BR" "$L1"
12589 remove_lnet_proc_files "routers"
12591 # lnet.peers should look like this:
12592 # nid refs state last max rtr min tx min queue
12593 # where nid is a string like 192.168.1.1@tcp2, refs > 0,
12594 # state is up/down/NA, max >= 0. last, rtr, min, tx, min are
12595 # numeric (0 or >0 or <0), queue >= 0.
12596 L1="^nid +refs +state +last +max +rtr +min +tx +min +queue$"
12597 BR="^$NID +$P +(up|down|NA) +$I +$N +$I +$I +$I +$I +$N$"
12598 create_lnet_proc_files "peers"
12599 check_lnet_proc_entry "peers.sys" "lnet.peers" "$BR" "$L1"
12600 remove_lnet_proc_files "peers"
12602 # lnet.buffers should look like this:
12603 # pages count credits min
12604 # where pages >=0, count >=0, credits and min are numeric (0 or >0 or <0)
12605 L1="^pages +count +credits +min$"
12606 BR="^ +$N +$N +$I +$I$"
12607 create_lnet_proc_files "buffers"
12608 check_lnet_proc_entry "buffers.sys" "lnet.buffers" "$BR" "$L1"
12609 remove_lnet_proc_files "buffers"
12611 # lnet.nis should look like this:
12612 # nid status alive refs peer rtr max tx min
12613 # where nid is a string like 192.168.1.1@tcp2, status is up/down,
12614 # alive is numeric (0 or >0 or <0), refs >= 0, peer >= 0,
12615 # rtr >= 0, max >=0, tx and min are numeric (0 or >0 or <0).
12616 L1="^nid +status +alive +refs +peer +rtr +max +tx +min$"
12617 BR="^$NID +(up|down) +$I +$N +$N +$N +$N +$I +$I$"
12618 create_lnet_proc_files "nis"
12619 check_lnet_proc_entry "nis.sys" "lnet.nis" "$BR" "$L1"
12620 remove_lnet_proc_files "nis"
12622 # can we successfully write to lnet.stats?
12623 lctl set_param -n stats=0 || error "cannot write to lnet.stats"
12624 sysctl -w lnet.stats=0 || error "cannot write to lnet.stats"
12626 run_test 215 "lnet exists and has proper content - bugs 18102, 21079, 21517"
12628 test_216() { # bug 20317
12629 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12630 remote_ost_nodsh && skip "remote OST with nodsh" && return
12633 local facets=$(get_facets OST)
12634 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
12636 save_lustre_params client "osc.*.contention_seconds" > $p
12637 save_lustre_params $facets \
12638 "ldlm.namespaces.filter-*.max_nolock_bytes" >> $p
12639 save_lustre_params $facets \
12640 "ldlm.namespaces.filter-*.contended_locks" >> $p
12641 save_lustre_params $facets \
12642 "ldlm.namespaces.filter-*.contention_seconds" >> $p
12645 # agressive lockless i/o settings
12646 for node in $(osts_nodes); do
12647 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'
12649 lctl set_param -n osc.*.contention_seconds 60
12651 $DIRECTIO write $DIR/$tfile 0 10 4096
12652 $CHECKSTAT -s 40960 $DIR/$tfile
12654 # disable lockless i/o
12655 for node in $(osts_nodes); do
12656 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'
12658 lctl set_param -n osc.*.contention_seconds 0
12661 dd if=/dev/zero of=$DIR/$tfile count=0
12662 $CHECKSTAT -s 0 $DIR/$tfile
12664 restore_lustre_params <$p
12668 run_test 216 "check lockless direct write works and updates file size and kms correctly"
12670 test_217() { # bug 22430
12671 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12675 for node in $(nodes_list); do
12676 nid=$(host_nids_address $node $NETTYPE)
12677 if [[ $nid = *-* ]] ; then
12678 echo "lctl ping $nid@$NETTYPE"
12679 lctl ping $nid@$NETTYPE
12681 echo "skipping $node (no hyphen detected)"
12685 run_test 217 "check lctl ping for hostnames with hiphen ('-')"
12688 # do directio so as not to populate the page cache
12689 log "creating a 10 Mb file"
12690 $MULTIOP $DIR/$tfile oO_CREAT:O_DIRECT:O_RDWR:w$((10*1048576))c || error "multiop failed while creating a file"
12691 log "starting reads"
12692 dd if=$DIR/$tfile of=/dev/null bs=4096 &
12693 log "truncating the file"
12694 $MULTIOP $DIR/$tfile oO_TRUNC:c || error "multiop failed while truncating the file"
12696 kill %+ || true # reads might have finished
12697 echo "wait until dd is finished"
12699 log "removing the temporary file"
12700 rm -rf $DIR/$tfile || error "tmp file removal failed"
12702 run_test 218 "parallel read and truncate should not deadlock ======================="
12705 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12706 # write one partial page
12707 dd if=/dev/zero of=$DIR/$tfile bs=1024 count=1
12708 # set no grant so vvp_io_commit_write will do sync write
12709 $LCTL set_param fail_loc=0x411
12710 # write a full page at the end of file
12711 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 seek=1 conv=notrunc
12713 $LCTL set_param fail_loc=0
12714 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 seek=3
12715 $LCTL set_param fail_loc=0x411
12716 dd if=/dev/zero of=$DIR/$tfile bs=1024 count=1 seek=2 conv=notrunc
12719 dd if=/dev/zero of=$DIR/$tfile-2 bs=1024 count=1
12720 $CHECKSTAT -s 1024 $DIR/$tfile-2 || error "checkstat wrong size"
12722 run_test 219 "LU-394: Write partial won't cause uncontiguous pages vec at LND"
12724 test_220() { #LU-325
12725 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12726 remote_ost_nodsh && skip "remote OST with nodsh" && return
12727 remote_mds_nodsh && skip "remote MDS with nodsh" && return
12728 remote_mgs_nodsh && skip "remote MGS with nodsh" && return
12731 # create on MDT0000 so the last_id and next_id are correct
12733 local OST=$($LFS df $DIR | awk '/OST:'$OSTIDX'/ { print $1 }')
12737 local mdtosc_proc1=$(get_mdtosc_proc_path $SINGLEMDS $OST)
12738 local last_id=$(do_facet $SINGLEMDS lctl get_param -n \
12739 osc.$mdtosc_proc1.prealloc_last_id)
12740 local next_id=$(do_facet $SINGLEMDS lctl get_param -n \
12741 osc.$mdtosc_proc1.prealloc_next_id)
12745 do_facet ost$((OSTIDX + 1)) lctl set_param fail_val=-1
12746 #define OBD_FAIL_OST_ENOINO 0x229
12747 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=0x229
12748 create_pool $FSNAME.$TESTNAME || return 1
12749 do_facet mgs $LCTL pool_add $FSNAME.$TESTNAME $OST || return 2
12751 $SETSTRIPE $DIR/$tdir -i $OSTIDX -c 1 -p $FSNAME.$TESTNAME
12753 MDSOBJS=$((last_id - next_id))
12754 echo "preallocated objects on MDS is $MDSOBJS" "($last_id - $next_id)"
12756 blocks=$($LFS df $MOUNT | awk '($1 == '$OSTIDX') { print $4 }')
12757 echo "OST still has $count kbytes free"
12759 echo "create $MDSOBJS files @next_id..."
12760 createmany -o $DIR/$tdir/f $MDSOBJS || return 3
12762 local last_id2=$(do_facet mds${MDSIDX} lctl get_param -n \
12763 osc.$mdtosc_proc1.prealloc_last_id)
12764 local next_id2=$(do_facet mds${MDSIDX} lctl get_param -n \
12765 osc.$mdtosc_proc1.prealloc_next_id)
12767 echo "after creation, last_id=$last_id2, next_id=$next_id2"
12772 do_facet ost$((OSTIDX + 1)) lctl set_param fail_val=0
12773 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=0
12775 do_facet mgs $LCTL pool_remove $FSNAME.$TESTNAME $OST || return 4
12776 do_facet mgs $LCTL pool_destroy $FSNAME.$TESTNAME || return 5
12777 echo "unlink $MDSOBJS files @$next_id..."
12778 unlinkmany $DIR/$tdir/f $MDSOBJS || return 6
12780 run_test 220 "preallocated MDS objects still used if ENOSPC from OST"
12783 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12784 dd if=`which date` of=$MOUNT/date oflag=sync
12785 chmod +x $MOUNT/date
12787 #define OBD_FAIL_LLITE_FAULT_TRUNC_RACE 0x1401
12788 $LCTL set_param fail_loc=0x80001401
12790 $MOUNT/date > /dev/null
12793 run_test 221 "make sure fault and truncate race to not cause OOM"
12796 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12798 test_mkdir -p $DIR/$tdir
12799 $SETSTRIPE -c 1 -i 0 $DIR/$tdir
12800 createmany -o $DIR/$tdir/$tfile 10
12801 cancel_lru_locks mdc
12802 cancel_lru_locks osc
12803 #define OBD_FAIL_LDLM_AGL_DELAY 0x31a
12804 $LCTL set_param fail_loc=0x31a
12805 ls -l $DIR/$tdir > /dev/null || error "AGL for ls failed"
12806 $LCTL set_param fail_loc=0
12809 run_test 222a "AGL for ls should not trigger CLIO lock failure ================"
12812 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12814 test_mkdir -p $DIR/$tdir
12815 $SETSTRIPE -c 1 -i 0 $DIR/$tdir
12816 createmany -o $DIR/$tdir/$tfile 10
12817 cancel_lru_locks mdc
12818 cancel_lru_locks osc
12819 #define OBD_FAIL_LDLM_AGL_DELAY 0x31a
12820 $LCTL set_param fail_loc=0x31a
12821 rm -r $DIR/$tdir || error "AGL for rmdir failed"
12822 $LCTL set_param fail_loc=0
12824 run_test 222b "AGL for rmdir should not trigger CLIO lock failure ============="
12827 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12829 test_mkdir -p $DIR/$tdir
12830 $SETSTRIPE -c 1 -i 0 $DIR/$tdir
12831 createmany -o $DIR/$tdir/$tfile 10
12832 cancel_lru_locks mdc
12833 cancel_lru_locks osc
12834 #define OBD_FAIL_LDLM_AGL_NOLOCK 0x31b
12835 $LCTL set_param fail_loc=0x31b
12836 ls -l $DIR/$tdir > /dev/null || error "reenqueue failed"
12837 $LCTL set_param fail_loc=0
12840 run_test 223 "osc reenqueue if without AGL lock granted ======================="
12842 test_224a() { # LU-1039, MRP-303
12843 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12844 #define OBD_FAIL_PTLRPC_CLIENT_BULK_CB 0x508
12845 $LCTL set_param fail_loc=0x508
12846 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 conv=fsync
12847 $LCTL set_param fail_loc=0
12850 run_test 224a "Don't panic on bulk IO failure"
12852 test_224b() { # LU-1039, MRP-303
12853 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12854 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1
12855 cancel_lru_locks osc
12856 #define OBD_FAIL_PTLRPC_CLIENT_BULK_CB2 0x515
12857 $LCTL set_param fail_loc=0x515
12858 dd of=/dev/null if=$DIR/$tfile bs=4096 count=1
12859 $LCTL set_param fail_loc=0
12862 run_test 224b "Don't panic on bulk IO failure"
12864 test_224c() { # LU-6441
12865 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12866 remote_mds_nodsh && skip "remote MDS with nodsh" && return
12868 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
12869 save_writethrough $p
12870 set_cache writethrough on
12872 local pages_per_rpc=$($LCTL get_param \
12873 osc.*.max_pages_per_rpc)
12874 local at_max=$($LCTL get_param -n at_max)
12875 local timeout=$($LCTL get_param -n timeout)
12876 local test_at="$LCTL get_param -n at_max"
12877 local param_at="$FSNAME.sys.at_max"
12878 local test_timeout="$LCTL get_param -n timeout"
12879 local param_timeout="$FSNAME.sys.timeout"
12881 $LCTL set_param -n osc.*.max_pages_per_rpc=1024
12883 set_conf_param_and_check client "$test_at" "$param_at" 0 ||
12884 error "conf_param at_max=0 failed"
12885 set_conf_param_and_check client "$test_timeout" "$param_timeout" 5 ||
12886 error "conf_param timeout=5 failed"
12888 #define OBD_FAIL_PTLRPC_CLIENT_BULK_CB3 0x520
12889 do_facet ost1 $LCTL set_param fail_loc=0x520
12890 $LFS setstripe -c 1 -i 0 $DIR/$tfile
12891 dd if=/dev/zero of=$DIR/$tfile bs=8MB count=1
12893 do_facet ost1 $LCTL set_param fail_loc=0
12895 set_conf_param_and_check client "$test_at" "$param_at" $at_max ||
12896 error "conf_param at_max=$at_max failed"
12897 set_conf_param_and_check client "$test_timeout" "$param_timeout" \
12898 $timeout || error "conf_param timeout=$timeout failed"
12900 $LCTL set_param -n $pages_per_rpc
12901 restore_lustre_params < $p
12904 run_test 224c "Don't hang if one of md lost during large bulk RPC"
12906 MDSSURVEY=${MDSSURVEY:-$(which mds-survey 2>/dev/null || true)}
12908 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12909 remote_mds_nodsh && skip "remote MDS with nodsh" && return
12910 if [ -z ${MDSSURVEY} ]; then
12911 skip_env "mds-survey not found" && return
12914 [ $MDSCOUNT -ge 2 ] &&
12915 skip "skipping now for more than one MDT" && return
12917 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.51) ] ||
12918 { skip "Need MDS version at least 2.2.51"; return; }
12920 local mds=$(facet_host $SINGLEMDS)
12921 local target=$(do_nodes $mds 'lctl dl' | \
12922 awk "{if (\$2 == \"UP\" && \$3 == \"mdt\") {print \$4}}")
12924 local cmd1="file_count=1000 thrhi=4"
12925 local cmd2="dir_count=2 layer=mdd stripe_count=0"
12926 local cmd3="rslt_loc=${TMP} targets=\"$mds:$target\" $MDSSURVEY"
12927 local cmd="$cmd1 $cmd2 $cmd3"
12929 rm -f ${TMP}/mds_survey*
12931 eval $cmd || error "mds-survey with zero-stripe failed"
12932 cat ${TMP}/mds_survey*
12933 rm -f ${TMP}/mds_survey*
12935 run_test 225a "Metadata survey sanity with zero-stripe"
12938 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12939 remote_mds_nodsh && skip "remote MDS with nodsh" && return
12940 if [ -z ${MDSSURVEY} ]; then
12941 skip_env "mds-survey not found" && return
12943 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.51) ] ||
12944 { skip "Need MDS version at least 2.2.51"; return; }
12946 if [ $($LCTL dl | grep -c osc) -eq 0 ]; then
12947 skip_env "Need to mount OST to test" && return
12950 [ $MDSCOUNT -ge 2 ] &&
12951 skip "skipping now for more than one MDT" && return
12952 local mds=$(facet_host $SINGLEMDS)
12953 local target=$(do_nodes $mds 'lctl dl' | \
12954 awk "{if (\$2 == \"UP\" && \$3 == \"mdt\") {print \$4}}")
12956 local cmd1="file_count=1000 thrhi=4"
12957 local cmd2="dir_count=2 layer=mdd stripe_count=1"
12958 local cmd3="rslt_loc=${TMP} targets=\"$mds:$target\" $MDSSURVEY"
12959 local cmd="$cmd1 $cmd2 $cmd3"
12961 rm -f ${TMP}/mds_survey*
12963 eval $cmd || error "mds-survey with stripe_count failed"
12964 cat ${TMP}/mds_survey*
12965 rm -f ${TMP}/mds_survey*
12967 run_test 225b "Metadata survey sanity with stripe_count = 1"
12969 mcreate_path2fid () {
12975 local path=$DIR/$tdir/$name
12980 $MCREATE --mode=$1 --major=$2 --minor=$3 $path ||
12981 error "cannot create $desc"
12983 fid=$($LFS path2fid $path | tr -d '[' | tr -d ']')
12985 [ $rc -ne 0 ] && error "cannot get fid of a $desc"
12987 fid_path=$($LFS fid2path $MOUNT $fid)
12989 [ $rc -ne 0 ] && error "cannot get path of $desc by $DIR $path $fid"
12991 [ "$path" == "$fid_path" ] ||
12992 error "fid2path returned $fid_path, expected $path"
12994 echo "pass with $path and $fid"
12999 mkdir -p $DIR/$tdir
13001 mcreate_path2fid 0010666 0 0 fifo "FIFO"
13002 mcreate_path2fid 0020666 1 3 null "character special file (null)"
13003 mcreate_path2fid 0020666 1 255 none "character special file (no device)"
13004 mcreate_path2fid 0040666 0 0 dir "directory"
13005 mcreate_path2fid 0060666 7 0 loop0 "block special file (loop)"
13006 mcreate_path2fid 0100666 0 0 file "regular file"
13007 mcreate_path2fid 0120666 0 0 link "symbolic link"
13008 mcreate_path2fid 0140666 0 0 sock "socket"
13010 run_test 226a "call path2fid and fid2path on files of all type"
13013 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
13017 mkdir -p $DIR/$tdir
13018 $LFS setdirstripe -i $MDTIDX $DIR/$tdir/remote_dir ||
13019 error "create remote directory failed"
13020 mcreate_path2fid 0010666 0 0 "remote_dir/fifo" "FIFO"
13021 mcreate_path2fid 0020666 1 3 "remote_dir/null" \
13022 "character special file (null)"
13023 mcreate_path2fid 0020666 1 255 "remote_dir/none" \
13024 "character special file (no device)"
13025 mcreate_path2fid 0040666 0 0 "remote_dir/dir" "directory"
13026 mcreate_path2fid 0060666 7 0 "remote_dir/loop0" \
13027 "block special file (loop)"
13028 mcreate_path2fid 0100666 0 0 "remote_dir/file" "regular file"
13029 mcreate_path2fid 0120666 0 0 "remote_dir/link" "symbolic link"
13030 mcreate_path2fid 0140666 0 0 "remote_dir/sock" "socket"
13032 run_test 226b "call path2fid and fid2path on files of all type under remote dir"
13034 # LU-1299 Executing or running ldd on a truncated executable does not
13035 # cause an out-of-memory condition.
13037 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13038 [ -z "$(which ldd)" ] && skip "should have ldd tool" && return
13039 dd if=$(which date) of=$MOUNT/date bs=1k count=1
13040 chmod +x $MOUNT/date
13042 $MOUNT/date > /dev/null
13043 ldd $MOUNT/date > /dev/null
13046 run_test 227 "running truncated executable does not cause OOM"
13048 # LU-1512 try to reuse idle OI blocks
13050 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13051 remote_mds_nodsh && skip "remote MDS with nodsh" && return
13052 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
13053 skip "non-ldiskfs backend" && return
13055 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
13056 local myDIR=$DIR/$tdir
13059 #define OBD_FAIL_SEQ_EXHAUST 0x1002
13060 $LCTL set_param fail_loc=0x80001002
13061 createmany -o $myDIR/t- 10000
13062 $LCTL set_param fail_loc=0
13063 # The guard is current the largest FID holder
13065 local SEQ=$($LFS path2fid $myDIR/guard | awk -F ':' '{print $1}' |
13067 local IDX=$(($SEQ % 64))
13069 do_facet $SINGLEMDS sync
13070 # Make sure journal flushed.
13072 local blk1=$(do_facet $SINGLEMDS \
13073 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
13074 grep Blockcount | awk '{print $4}')
13076 # Remove old files, some OI blocks will become idle.
13077 unlinkmany $myDIR/t- 10000
13078 # Create new files, idle OI blocks should be reused.
13079 createmany -o $myDIR/t- 2000
13080 do_facet $SINGLEMDS sync
13081 # Make sure journal flushed.
13083 local blk2=$(do_facet $SINGLEMDS \
13084 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
13085 grep Blockcount | awk '{print $4}')
13087 [ $blk1 == $blk2 ] || error "old blk1=$blk1, new blk2=$blk2, unmatched!"
13089 run_test 228a "try to reuse idle OI blocks"
13092 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13093 remote_mds_nodsh && skip "remote MDS with nodsh" && return
13094 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
13095 skip "non-ldiskfs backend" && return
13097 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
13098 local myDIR=$DIR/$tdir
13101 #define OBD_FAIL_SEQ_EXHAUST 0x1002
13102 $LCTL set_param fail_loc=0x80001002
13103 createmany -o $myDIR/t- 10000
13104 $LCTL set_param fail_loc=0
13105 # The guard is current the largest FID holder
13107 local SEQ=$($LFS path2fid $myDIR/guard | awk -F ':' '{print $1}' |
13109 local IDX=$(($SEQ % 64))
13111 do_facet $SINGLEMDS sync
13112 # Make sure journal flushed.
13114 local blk1=$(do_facet $SINGLEMDS \
13115 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
13116 grep Blockcount | awk '{print $4}')
13118 # Remove old files, some OI blocks will become idle.
13119 unlinkmany $myDIR/t- 10000
13122 stop $SINGLEMDS || error "Fail to stop MDT."
13124 start $SINGLEMDS $MDT_DEV $MDS_MOUNT_OPTS || error "Fail to start MDT."
13126 df $MOUNT || error "Fail to df."
13127 # Create new files, idle OI blocks should be reused.
13128 createmany -o $myDIR/t- 2000
13129 do_facet $SINGLEMDS sync
13130 # Make sure journal flushed.
13132 local blk2=$(do_facet $SINGLEMDS \
13133 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
13134 grep Blockcount | awk '{print $4}')
13136 [ $blk1 == $blk2 ] || error "old blk1=$blk1, new blk2=$blk2, unmatched!"
13138 run_test 228b "idle OI blocks can be reused after MDT restart"
13142 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13143 remote_mds_nodsh && skip "remote MDS with nodsh" && return
13144 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
13145 skip "non-ldiskfs backend" && return
13147 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
13148 local myDIR=$DIR/$tdir
13151 #define OBD_FAIL_SEQ_EXHAUST 0x1002
13152 $LCTL set_param fail_loc=0x80001002
13153 # 20000 files can guarantee there are index nodes in the OI file
13154 createmany -o $myDIR/t- 20000
13155 $LCTL set_param fail_loc=0
13156 # The guard is current the largest FID holder
13158 local SEQ=$($LFS path2fid $myDIR/guard | awk -F ':' '{print $1}' |
13160 local IDX=$(($SEQ % 64))
13162 do_facet $SINGLEMDS sync
13163 # Make sure journal flushed.
13165 local blk1=$(do_facet $SINGLEMDS \
13166 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
13167 grep Blockcount | awk '{print $4}')
13169 # Remove old files, some OI blocks will become idle.
13170 unlinkmany $myDIR/t- 20000
13172 # The OI file should become empty now
13174 # Create new files, idle OI blocks should be reused.
13175 createmany -o $myDIR/t- 2000
13176 do_facet $SINGLEMDS sync
13177 # Make sure journal flushed.
13179 local blk2=$(do_facet $SINGLEMDS \
13180 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
13181 grep Blockcount | awk '{print $4}')
13183 [ $blk1 == $blk2 ] || error "old blk1=$blk1, new blk2=$blk2, unmatched!"
13185 run_test 228c "NOT shrink the last entry in OI index node to recycle idle leaf"
13187 test_229() { # LU-2482, LU-3448
13188 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.53) ] &&
13189 skip "No HSM $(lustre_build_version $SINGLEMDS) MDS < 2.4.53" &&
13191 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13192 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs" && return
13196 # Create a file with a released layout and stripe count 2.
13197 $MULTIOP $DIR/$tfile H2c ||
13198 error "failed to create file with released layout"
13200 $GETSTRIPE -v $DIR/$tfile
13202 local pattern=$($GETSTRIPE -L $DIR/$tfile)
13203 [ X"$pattern" = X"80000001" ] || error "pattern error ($pattern)"
13205 local stripe_count=$($GETSTRIPE -c $DIR/$tfile) || error "getstripe"
13206 [ $stripe_count -eq 2 ] || error "stripe count not 2 ($stripe_count)"
13207 stat $DIR/$tfile || error "failed to stat released file"
13209 chown $RUNAS_ID $DIR/$tfile ||
13210 error "chown $RUNAS_ID $DIR/$tfile failed"
13212 chgrp $RUNAS_ID $DIR/$tfile ||
13213 error "chgrp $RUNAS_ID $DIR/$tfile failed"
13215 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
13216 rm $DIR/$tfile || error "failed to remove released file"
13218 run_test 229 "getstripe/stat/rm/attr changes work on released files"
13221 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13222 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
13225 test_mkdir $DIR/$tdir
13226 test_mkdir -i0 -c1 $DIR/$tdir/test_230_local
13227 local mdt_idx=$($GETSTRIPE -M $DIR/$tdir/test_230_local)
13228 [ $mdt_idx -ne 0 ] &&
13229 error "create local directory on wrong MDT $mdt_idx"
13231 $LFS mkdir -i $MDTIDX $DIR/$tdir/test_230 ||
13232 error "create remote directory failed"
13233 local mdt_idx=$($GETSTRIPE -M $DIR/$tdir/test_230)
13234 [ $mdt_idx -ne $MDTIDX ] &&
13235 error "create remote directory on wrong MDT $mdt_idx"
13237 createmany -o $DIR/$tdir/test_230/t- 10 ||
13238 error "create files on remote directory failed"
13239 mdt_idx=$($GETSTRIPE -M $DIR/$tdir/test_230/t-0)
13240 [ $mdt_idx -ne $MDTIDX ] && error "create files on wrong MDT $mdt_idx"
13241 rm -r $DIR/$tdir || error "unlink remote directory failed"
13243 run_test 230a "Create remote directory and files under the remote directory"
13246 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13247 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
13254 local migrate_dir=$DIR/$tdir/migrate_dir
13255 local other_dir=$DIR/$tdir/other_dir
13257 test_mkdir $DIR/$tdir
13258 test_mkdir -i0 -c1 $migrate_dir
13259 test_mkdir -i0 -c1 $other_dir
13260 for ((i=0; i<10; i++)); do
13261 mkdir -p $migrate_dir/dir_${i}
13262 createmany -o $migrate_dir/dir_${i}/f 10 ||
13263 error "create files under remote dir failed $i"
13266 cp /etc/passwd $migrate_dir/$tfile
13267 cp /etc/passwd $other_dir/$tfile
13268 chattr +SAD $migrate_dir
13269 chattr +SAD $migrate_dir/$tfile
13271 local old_dir_flag=$(lsattr -a $migrate_dir | awk '/\/\.$/ {print $1}')
13272 local old_file_flag=$(lsattr $migrate_dir/$tfile | awk '{print $1}')
13273 local old_dir_mode=$(stat -c%f $migrate_dir)
13274 local old_file_mode=$(stat -c%f $migrate_dir/$tfile)
13276 mkdir -p $migrate_dir/dir_default_stripe2
13277 $SETSTRIPE -c 2 $migrate_dir/dir_default_stripe2
13278 $SETSTRIPE -c 2 $migrate_dir/${tfile}_stripe2
13280 mkdir -p $other_dir
13281 ln $migrate_dir/$tfile $other_dir/luna
13282 ln $migrate_dir/$tfile $migrate_dir/sofia
13283 ln $other_dir/$tfile $migrate_dir/david
13284 ln -s $migrate_dir/$tfile $other_dir/zachary
13285 ln -s $migrate_dir/$tfile $migrate_dir/${tfile}_ln
13286 ln -s $other_dir/$tfile $migrate_dir/${tfile}_ln_other
13288 $LFS migrate -m $MDTIDX $migrate_dir ||
13289 error "fails on migrating remote dir to MDT1"
13291 echo "migratate to MDT1, then checking.."
13292 for ((i = 0; i < 10; i++)); do
13293 for file in $(find $migrate_dir/dir_${i}); do
13294 mdt_index=$($LFS getstripe -M $file)
13295 [ $mdt_index == $MDTIDX ] ||
13296 error "$file is not on MDT${MDTIDX}"
13300 # the multiple link file should still in MDT0
13301 mdt_index=$($LFS getstripe -M $migrate_dir/$tfile)
13302 [ $mdt_index == 0 ] ||
13303 error "$file is not on MDT${MDTIDX}"
13305 local new_dir_flag=$(lsattr -a $migrate_dir | awk '/\/\.$/ {print $1}')
13306 [ "$old_dir_flag" = "$new_dir_flag" ] ||
13307 error " expect $old_dir_flag get $new_dir_flag"
13309 local new_file_flag=$(lsattr $migrate_dir/$tfile | awk '{print $1}')
13310 [ "$old_file_flag" = "$new_file_flag" ] ||
13311 error " expect $old_file_flag get $new_file_flag"
13313 local new_dir_mode=$(stat -c%f $migrate_dir)
13314 [ "$old_dir_mode" = "$new_dir_mode" ] ||
13315 error "expect mode $old_dir_mode get $new_dir_mode"
13317 local new_file_mode=$(stat -c%f $migrate_dir/$tfile)
13318 [ "$old_file_mode" = "$new_file_mode" ] ||
13319 error "expect mode $old_file_mode get $new_file_mode"
13321 diff /etc/passwd $migrate_dir/$tfile ||
13322 error "$tfile different after migration"
13324 diff /etc/passwd $other_dir/luna ||
13325 error "luna different after migration"
13327 diff /etc/passwd $migrate_dir/sofia ||
13328 error "sofia different after migration"
13330 diff /etc/passwd $migrate_dir/david ||
13331 error "david different after migration"
13333 diff /etc/passwd $other_dir/zachary ||
13334 error "zachary different after migration"
13336 diff /etc/passwd $migrate_dir/${tfile}_ln ||
13337 error "${tfile}_ln different after migration"
13339 diff /etc/passwd $migrate_dir/${tfile}_ln_other ||
13340 error "${tfile}_ln_other different after migration"
13342 stripe_count=$($LFS getstripe -c $migrate_dir/dir_default_stripe2)
13343 [ $stripe_count = 2 ] ||
13344 error "dir strpe_count $d != 2 after migration."
13346 stripe_count=$($LFS getstripe -c $migrate_dir/${tfile}_stripe2)
13347 [ $stripe_count = 2 ] ||
13348 error "file strpe_count $d != 2 after migration."
13350 #migrate back to MDT0
13353 $LFS migrate -m $MDTIDX $migrate_dir ||
13354 error "fails on migrating remote dir to MDT0"
13356 echo "migrate back to MDT0, checking.."
13357 for file in $(find $migrate_dir); do
13358 mdt_index=$($LFS getstripe -M $file)
13359 [ $mdt_index == $MDTIDX ] ||
13360 error "$file is not on MDT${MDTIDX}"
13363 local new_dir_flag=$(lsattr -a $migrate_dir | awk '/\/\.$/ {print $1}')
13364 [ "$old_dir_flag" = "$new_dir_flag" ] ||
13365 error " expect $old_dir_flag get $new_dir_flag"
13367 local new_file_flag=$(lsattr $migrate_dir/$tfile | awk '{print $1}')
13368 [ "$old_file_flag" = "$new_file_flag" ] ||
13369 error " expect $old_file_flag get $new_file_flag"
13371 local new_dir_mode=$(stat -c%f $migrate_dir)
13372 [ "$old_dir_mode" = "$new_dir_mode" ] ||
13373 error "expect mode $old_dir_mode get $new_dir_mode"
13375 local new_file_mode=$(stat -c%f $migrate_dir/$tfile)
13376 [ "$old_file_mode" = "$new_file_mode" ] ||
13377 error "expect mode $old_file_mode get $new_file_mode"
13379 diff /etc/passwd ${migrate_dir}/$tfile ||
13380 error "$tfile different after migration"
13382 diff /etc/passwd ${other_dir}/luna ||
13383 error "luna different after migration"
13385 diff /etc/passwd ${migrate_dir}/sofia ||
13386 error "sofia different after migration"
13388 diff /etc/passwd ${other_dir}/zachary ||
13389 error "zachary different after migration"
13391 diff /etc/passwd $migrate_dir/${tfile}_ln ||
13392 error "${tfile}_ln different after migration"
13394 diff /etc/passwd $migrate_dir/${tfile}_ln_other ||
13395 error "${tfile}_ln_other different after migration"
13397 stripe_count=$($LFS getstripe -c ${migrate_dir}/dir_default_stripe2)
13398 [ $stripe_count = 2 ] ||
13399 error "dir strpe_count $d != 2 after migration."
13401 stripe_count=$($LFS getstripe -c ${migrate_dir}/${tfile}_stripe2)
13402 [ $stripe_count = 2 ] ||
13403 error "file strpe_count $d != 2 after migration."
13405 rm -rf $DIR/$tdir || error "rm dir failed after migration"
13407 run_test 230b "migrate directory"
13410 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13411 remote_mds_nodsh && skip "remote MDS with nodsh" && return
13412 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
13416 local migrate_dir=$DIR/$tdir/migrate_dir
13418 #If migrating directory fails in the middle, all entries of
13419 #the directory is still accessiable.
13420 test_mkdir $DIR/$tdir
13421 test_mkdir -i0 -c1 $migrate_dir
13423 createmany -o $migrate_dir/f 10 ||
13424 error "create files under ${migrate_dir} failed"
13426 #failed after migrating 5 entries
13427 #OBD_FAIL_MIGRATE_ENTRIES 0x1801
13428 do_facet mds1 lctl set_param fail_loc=0x20001801
13429 do_facet mds1 lctl set_param fail_val=5
13430 local t=$(ls $migrate_dir | wc -l)
13431 $LFS migrate --mdt-index $MDTIDX $migrate_dir &&
13432 error "migrate should fail after 5 entries"
13434 mkdir $migrate_dir/dir &&
13435 error "mkdir succeeds under migrating directory"
13436 touch $migrate_dir/file &&
13437 error "touch file succeeds under migrating directory"
13439 local u=$(ls $migrate_dir | wc -l)
13440 [ "$u" == "$t" ] || error "$u != $t during migration"
13442 for file in $(find $migrate_dir); do
13443 stat $file || error "stat $file failed"
13446 do_facet mds1 lctl set_param fail_loc=0
13447 do_facet mds1 lctl set_param fail_val=0
13449 $LFS migrate -m $MDTIDX $migrate_dir ||
13450 error "migrate open files should failed with open files"
13452 echo "Finish migration, then checking.."
13453 for file in $(find $migrate_dir); do
13454 mdt_index=$($LFS getstripe -M $file)
13455 [ $mdt_index == $MDTIDX ] ||
13456 error "$file is not on MDT${MDTIDX}"
13459 rm -rf $DIR/$tdir || error "rm dir failed after migration"
13461 run_test 230c "check directory accessiblity if migration is failed"
13464 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13465 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
13468 local migrate_dir=$DIR/$tdir/migrate_dir
13472 test_mkdir $DIR/$tdir
13473 test_mkdir -i0 -c1 $migrate_dir
13475 for ((i=0; i<100; i++)); do
13476 test_mkdir -i0 -c1 $migrate_dir/dir_${i}
13477 createmany -o $migrate_dir/dir_${i}/f 100 ||
13478 error "create files under remote dir failed $i"
13481 $LFS migrate -m $MDTIDX $migrate_dir ||
13482 error "migrate remote dir error"
13484 echo "Finish migration, then checking.."
13485 for file in $(find $migrate_dir); do
13486 mdt_index=$($LFS getstripe -M $file)
13487 [ $mdt_index == $MDTIDX ] ||
13488 error "$file is not on MDT${MDTIDX}"
13491 rm -rf $DIR/$tdir || error "rm dir failed after migration"
13493 run_test 230d "check migrate big directory"
13496 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13497 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
13503 mkdir -p $DIR/$tdir
13504 mkdir $DIR/$tdir/migrate_dir
13505 mkdir $DIR/$tdir/other_dir
13506 touch $DIR/$tdir/migrate_dir/a
13507 ln $DIR/$tdir/migrate_dir/a $DIR/$tdir/other_dir/b
13508 ls $DIR/$tdir/other_dir
13510 $LFS migrate -m 1 $DIR/$tdir/migrate_dir ||
13511 error "migrate dir fails"
13513 mdt_index=$($LFS getstripe -M $DIR/$tdir/migrate_dir)
13514 [ $mdt_index == 1 ] || error "migrate_dir is not on MDT1"
13516 mdt_index=$($LFS getstripe -M $DIR/$tdir/migrate_dir/a)
13517 [ $mdt_index == 0 ] || error "a is not on MDT0"
13519 $LFS migrate -m 1 $DIR/$tdir/other_dir ||
13520 error "migrate dir fails"
13522 mdt_index=$($LFS getstripe -M $DIR/$tdir/other_dir)
13523 [ $mdt_index == 1 ] || error "other_dir is not on MDT1"
13525 mdt_index=$($LFS getstripe -M $DIR/$tdir/migrate_dir/a)
13526 [ $mdt_index == 1 ] || error "a is not on MDT1"
13528 mdt_index=$($LFS getstripe -M $DIR/$tdir/other_dir/b)
13529 [ $mdt_index == 1 ] || error "b is not on MDT1"
13531 a_fid=$($LFS path2fid $DIR/$tdir/migrate_dir/a)
13532 b_fid=$($LFS path2fid $DIR/$tdir/other_dir/b)
13534 [ "$a_fid" = "$b_fid" ] || error "different fid after migration"
13536 rm -rf $DIR/$tdir || error "rm dir failed after migration"
13538 run_test 230e "migrate mulitple local link files"
13541 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13542 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
13546 mkdir -p $DIR/$tdir
13547 mkdir $DIR/$tdir/migrate_dir
13548 $LFS mkdir -i1 $DIR/$tdir/other_dir
13549 touch $DIR/$tdir/migrate_dir/a
13550 ln $DIR/$tdir/migrate_dir/a $DIR/$tdir/other_dir/ln1
13551 ln $DIR/$tdir/migrate_dir/a $DIR/$tdir/other_dir/ln2
13552 ls $DIR/$tdir/other_dir
13554 # a should be migrated to MDT1, since no other links on MDT0
13555 $LFS migrate -m 1 $DIR/$tdir/migrate_dir ||
13556 error "#1 migrate dir fails"
13557 mdt_index=$($LFS getstripe -M $DIR/$tdir/migrate_dir)
13558 [ $mdt_index == 1 ] || error "migrate_dir is not on MDT1"
13559 mdt_index=$($LFS getstripe -M $DIR/$tdir/migrate_dir/a)
13560 [ $mdt_index == 1 ] || error "a is not on MDT1"
13562 # a should stay on MDT1, because it is a mulitple link file
13563 $LFS migrate -m 0 $DIR/$tdir/migrate_dir ||
13564 error "#2 migrate dir fails"
13565 mdt_index=$($LFS getstripe -M $DIR/$tdir/migrate_dir/a)
13566 [ $mdt_index == 1 ] || error "a is not on MDT1"
13568 $LFS migrate -m 1 $DIR/$tdir/migrate_dir ||
13569 error "#3 migrate dir fails"
13571 a_fid=$($LFS path2fid $DIR/$tdir/migrate_dir/a)
13572 ln_fid=$($LFS path2fid $DIR/$tdir/other_dir/ln1)
13573 [ "$a_fid" = "$ln_fid" ] || error "different fid after migrate to MDT1"
13575 rm -rf $DIR/$tdir/other_dir/ln1 || error "unlink ln1 fails"
13576 rm -rf $DIR/$tdir/other_dir/ln2 || error "unlink ln2 fails"
13578 # a should be migrated to MDT0, since no other links on MDT1
13579 $LFS migrate -m 0 $DIR/$tdir/migrate_dir ||
13580 error "#4 migrate dir fails"
13581 mdt_index=$($LFS getstripe -M $DIR/$tdir/migrate_dir/a)
13582 [ $mdt_index == 0 ] || error "a is not on MDT0"
13584 rm -rf $DIR/$tdir || error "rm dir failed after migration"
13586 run_test 230f "migrate mulitple remote link files"
13589 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13590 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
13592 mkdir -p $DIR/$tdir/migrate_dir
13594 $LFS migrate -m 1000 $DIR/$tdir/migrate_dir &&
13595 error "migrating dir to non-exist MDT succeeds"
13598 run_test 230g "migrate dir to non-exist MDT"
13601 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13602 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
13603 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.64) ] &&
13604 skip "Need MDS version at least 2.7.64" && return
13607 mkdir -p $DIR/$tdir/migrate_dir
13609 $LFS migrate -m1 $DIR &&
13610 error "migrating mountpoint1 should fail"
13612 $LFS migrate -m1 $DIR/$tdir/.. &&
13613 error "migrating mountpoint2 should fail"
13615 $LFS migrate -m1 $DIR/$tdir/migrate_dir/.. ||
13616 error "migrating $tdir fail"
13618 mdt_index=$($LFS getstripe -M $DIR/$tdir)
13619 [ $mdt_index == 1 ] || error "$mdt_index != 1 after migration"
13621 mdt_index=$($LFS getstripe -M $DIR/$tdir/migrate_dir)
13622 [ $mdt_index == 1 ] || error "$mdt_index != 1 after migration"
13625 run_test 230h "migrate .. and root"
13628 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13629 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
13631 mkdir -p $DIR/$tdir/migrate_dir
13633 $LFS migrate -m 1 $DIR/$tdir/migrate_dir/ ||
13634 error "migration fails with a tailing slash"
13636 $LFS migrate -m 0 $DIR/$tdir/migrate_dir// ||
13637 error "migration fails with two tailing slashes"
13639 run_test 230i "lfs migrate -m tolerates trailing slashes"
13643 # For simplicity this test assumes that max_pages_per_rpc
13644 # is the same across all OSCs
13645 local max_pages=$($LCTL get_param -n osc.*.max_pages_per_rpc | head -n1)
13646 local bulk_size=$((max_pages * 4096))
13648 mkdir -p $DIR/$tdir
13650 # clear the OSC stats
13651 $LCTL set_param osc.*.stats=0 &>/dev/null
13654 # Client writes $bulk_size - there must be 1 rpc for $max_pages.
13655 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=$bulk_size count=1 \
13656 oflag=direct &>/dev/null || error "dd failed"
13658 sync; sleep 1; sync # just to be safe
13659 local nrpcs=$($LCTL get_param osc.*.stats |awk '/ost_write/ {print $2}')
13660 if [ x$nrpcs != "x1" ]; then
13661 $LCTL get_param osc.*.stats
13662 error "found $nrpcs ost_write RPCs, not 1 as expected"
13666 # Drop the OSC cache, otherwise we will read from it
13667 cancel_lru_locks osc
13669 # clear the OSC stats
13670 $LCTL set_param osc.*.stats=0 &>/dev/null
13672 # Client reads $bulk_size.
13673 dd if=$DIR/$tdir/$tfile of=/dev/null bs=$bulk_size count=1 \
13674 iflag=direct &>/dev/null || error "dd failed"
13676 nrpcs=$($LCTL get_param osc.*.stats | awk '/ost_read/ { print $2 }')
13677 if [ x$nrpcs != "x1" ]; then
13678 $LCTL get_param osc.*.stats
13679 error "found $nrpcs ost_read RPCs, not 1 as expected"
13682 run_test 231a "checking that reading/writing of BRW RPC size results in one RPC"
13685 mkdir -p $DIR/$tdir
13687 for i in {0..1023}; do
13688 dd if=/dev/zero of=$DIR/$tdir/$tfile conv=notrunc \
13689 seek=$((2 * i)) bs=4096 count=1 &>/dev/null ||
13690 error "dd of=$DIR/$tdir/$tfile seek=$((2 * i)) failed"
13694 run_test 231b "must not assert on fully utilized OST request buffer"
13697 mkdir -p $DIR/$tdir
13698 #define OBD_FAIL_LDLM_OST_LVB 0x31c
13699 $LCTL set_param fail_loc=0x31c
13701 # ignore dd failure
13702 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=1 || true
13704 $LCTL set_param fail_loc=0
13705 umount_client $MOUNT || error "umount failed"
13706 mount_client $MOUNT || error "mount failed"
13708 run_test 232 "failed lock should not block umount"
13711 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.3.64) ] ||
13712 { skip "Need MDS version at least 2.3.64"; return; }
13713 [ -n "$FILESET" ] && skip "SKIP due to FILESET set" && return
13715 local fid=$($LFS path2fid $MOUNT)
13716 stat $MOUNT/.lustre/fid/$fid > /dev/null ||
13717 error "cannot access $MOUNT using its FID '$fid'"
13719 run_test 233a "checking that OBF of the FS root succeeds"
13722 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.5.90) ] ||
13723 { skip "Need MDS version at least 2.5.90"; return; }
13724 [ -n "$FILESET" ] && skip "SKIP due to FILESET set" && return
13726 local fid=$($LFS path2fid $MOUNT/.lustre)
13727 stat $MOUNT/.lustre/fid/$fid > /dev/null ||
13728 error "cannot access $MOUNT/.lustre using its FID '$fid'"
13730 fid=$($LFS path2fid $MOUNT/.lustre/fid)
13731 stat $MOUNT/.lustre/fid/$fid > /dev/null ||
13732 error "cannot access $MOUNT/.lustre/fid using its FID '$fid'"
13734 run_test 233b "checking that OBF of the FS .lustre succeeds"
13737 local p="$TMP/sanityN-$TESTNAME.parameters"
13738 save_lustre_params client "llite.*.xattr_cache" > $p
13739 lctl set_param llite.*.xattr_cache 1 ||
13740 { skip "xattr cache is not supported"; return 0; }
13742 mkdir -p $DIR/$tdir || error "mkdir failed"
13743 touch $DIR/$tdir/$tfile || error "touch failed"
13744 # OBD_FAIL_LLITE_XATTR_ENOMEM
13745 $LCTL set_param fail_loc=0x1405
13746 # output of the form: attr 2 4 44 3 fc13 x86_64
13747 V=($(IFS=".-" rpm -q attr))
13748 if [[ ${V[1]} > 2 || ${V[2]} > 4 || ${V[3]} > 44 ||
13749 ${V[1]} = 2 && ${V[2]} = 4 && ${V[3]} = 44 && ${V[4]} > 6 ]]; then
13750 # attr pre-2.4.44-7 had a bug with rc
13751 # LU-3703 - SLES 11 and FC13 clients have older attr
13752 getfattr -n user.attr $DIR/$tdir/$tfile &&
13753 error "getfattr should have failed with ENOMEM"
13755 skip "LU-3703: attr version $(getfattr --version) too old"
13757 $LCTL set_param fail_loc=0x0
13760 restore_lustre_params < $p
13763 run_test 234 "xattr cache should not crash on ENOMEM"
13766 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.52) ] &&
13767 skip "Need MDS version at least 2.4.52" && return
13768 flock_deadlock $DIR/$tfile
13773 124) error "process hangs on a deadlock"
13775 *) error "error executing flock_deadlock $DIR/$tfile"
13779 run_test 235 "LU-1715: flock deadlock detection does not work properly"
13783 check_swap_layouts_support && return 0
13784 test_mkdir -p -c1 $DIR/$tdir || error "mkdir $tdir failed"
13786 local ref1=/etc/passwd
13787 local ref2=/etc/group
13788 local file1=$DIR/$tdir/f1
13789 local file2=$DIR/$tdir/f2
13791 $SETSTRIPE -c 1 $file1 || error "cannot setstripe on '$file1': rc = $?"
13792 cp $ref1 $file1 || error "cp $ref1 $file1 failed: rc = $?"
13793 $SETSTRIPE -c 2 $file2 || error "cannot setstripe on '$file2': rc = $?"
13794 cp $ref2 $file2 || error "cp $ref2 $file2 failed: rc = $?"
13795 local fd=$(free_fd)
13796 local cmd="exec $fd<>$file2"
13799 $LFS swap_layouts $file1 /proc/self/fd/${fd} ||
13800 error "cannot swap layouts of '$file1' and /proc/self/fd/${fd}"
13803 cmp $ref2 $file1 || error "content compare failed ($ref2 != $file1)"
13808 run_test 236 "Layout swap on open unlinked file"
13810 # test to verify file handle related system calls
13811 # (name_to_handle_at/open_by_handle_at)
13812 # The new system calls are supported in glibc >= 2.14.
13815 echo "Test file_handle syscalls" > $DIR/$tfile ||
13816 error "write failed"
13817 check_fhandle_syscalls $DIR/$tfile ||
13818 error "check_fhandle_syscalls failed"
13820 run_test 237 "Verify name_to_handle_at/open_by_handle_at syscalls"
13822 # LU-4659 linkea consistency
13824 local server_version=$(lustre_version_code $SINGLEMDS)
13826 [[ $server_version -gt $(version_code 2.5.57) ]] ||
13827 [[ $server_version -gt $(version_code 2.5.1) &&
13828 $server_version -lt $(version_code 2.5.50) ]] ||
13829 { skip "Need MDS version at least 2.5.58 or 2.5.2+"; return; }
13832 ln $DIR/$tfile $DIR/$tfile.lnk
13833 touch $DIR/$tfile.new
13834 mv $DIR/$tfile.new $DIR/$tfile
13835 local fid1=$($LFS path2fid $DIR/$tfile)
13836 local fid2=$($LFS path2fid $DIR/$tfile.lnk)
13837 local path1=$($LFS fid2path $FSNAME "$fid1")
13838 [ $tfile == $path1 ] || error "linkea inconsistent: $tfile $fid1 $path1"
13839 local path2=$($LFS fid2path $FSNAME "$fid2")
13840 [ $tfile.lnk == $path2 ] ||
13841 error "linkea inconsistent: $tfile.lnk $fid2 $path2!"
13844 run_test 238 "Verify linkea consistency"
13847 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.5.60) ] &&
13848 skip "Need MDS version at least 2.5.60" && return
13849 local list=$(comma_list $(mdts_nodes))
13851 mkdir -p $DIR/$tdir
13852 createmany -o $DIR/$tdir/f- 5000
13853 unlinkmany $DIR/$tdir/f- 5000
13854 do_nodes $list "lctl set_param -n osp*.*.sync_changes 1"
13855 changes=$(do_nodes $list "lctl get_param -n osc.*MDT*.sync_changes \
13856 osc.*MDT*.sync_in_flight" | calc_sum)
13857 [ "$changes" -eq 0 ] || error "$changes not synced"
13859 run_test 239 "osp_sync test"
13861 test_239a() { #LU-5297
13862 remote_mds_nodsh && skip "remote MDS with nodsh" && return
13864 #define OBD_FAIL_OSP_CHECK_INVALID_REC 0x2100
13865 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x2100
13866 chgrp $RUNAS_GID $DIR/$tfile
13867 wait_delete_completed
13869 run_test 239a "process invalid osp sync record correctly"
13871 test_239b() { #LU-5297
13872 remote_mds_nodsh && skip "remote MDS with nodsh" && return
13874 #define OBD_FAIL_OSP_CHECK_ENOMEM 0x2101
13875 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x2101
13876 chgrp $RUNAS_GID $DIR/$tfile1
13877 wait_delete_completed
13878 do_facet $SINGLEMDS $LCTL set_param fail_loc=0
13880 chgrp $RUNAS_GID $DIR/$tfile2
13881 wait_delete_completed
13883 run_test 239b "process osp sync record with ENOMEM error correctly"
13886 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
13887 remote_mds_nodsh && skip "remote MDS with nodsh" && return
13889 mkdir -p $DIR/$tdir
13891 $LFS mkdir -i 0 $DIR/$tdir/d0 ||
13892 error "failed to mkdir $DIR/$tdir/d0 on MDT0"
13893 $LFS mkdir -i 1 $DIR/$tdir/d0/d1 ||
13894 error "failed to mkdir $DIR/$tdir/d0/d1 on MDT1"
13896 umount_client $MOUNT || error "umount failed"
13897 #define OBD_FAIL_TGT_DELAY_CONDITIONAL 0x713
13898 do_facet mds2 lctl set_param fail_loc=0x713 fail_val=1
13899 mount_client $MOUNT || error "failed to mount client"
13901 echo "stat $DIR/$tdir/d0/d1, should not fail/ASSERT"
13902 stat $DIR/$tdir/d0/d1 || error "fail to stat $DIR/$tdir/d0/d1"
13904 run_test 240 "race between ldlm enqueue and the connection RPC (no ASSERT)"
13907 for LOOP in $(seq $1); do
13908 dd if=$DIR/$tfile of=/dev/null bs=40960 count=1 2>/dev/null
13909 cancel_lru_locks osc || true
13914 for LOOP in $(seq $1); do
13915 dd if=$DIR/$tfile of=/dev/null bs=40960 count=1 \
13916 iflag=direct 2>/dev/null
13920 test_241a() { # was test_241
13921 dd if=/dev/zero of=$DIR/$tfile count=1 bs=40960
13923 cancel_lru_locks osc
13924 test_241_bio 1000 &
13929 run_test 241a "bio vs dio"
13932 dd if=/dev/zero of=$DIR/$tfile count=1 bs=40960
13934 test_241_dio 1000 &
13939 run_test 241b "dio vs dio"
13942 remote_mds_nodsh && skip "remote MDS with nodsh" && return
13943 mkdir -p $DIR/$tdir
13944 touch $DIR/$tdir/$tfile
13946 #define OBD_FAIL_MDS_READPAGE_PACK 0x105
13947 do_facet mds1 lctl set_param fail_loc=0x105
13948 /bin/ls $DIR/$tdir && error "ls $DIR/$tdir should fail"
13950 do_facet mds1 lctl set_param fail_loc=0
13951 /bin/ls $DIR/$tdir || error "ls $DIR/$tdir failed"
13953 run_test 242 "mdt_readpage failure should not cause directory unreadable"
13957 test_mkdir -p $DIR/$tdir
13958 group_lock_test -d $DIR/$tdir || error "A group lock test failed"
13960 run_test 243 "various group lock tests"
13964 test_mkdir -p $DIR/$tdir
13965 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=35
13966 sendfile_grouplock $DIR/$tdir/$tfile || \
13967 error "sendfile+grouplock failed"
13970 run_test 244 "sendfile with group lock tests"
13973 local flagname="multi_mod_rpcs"
13974 local connect_data_name="max_mod_rpcs"
13977 # check if multiple modify RPCs flag is set
13978 out=$($LCTL get_param mdc.$FSNAME-MDT0000-*.import |
13979 grep "connect_flags:")
13982 echo "$out" | grep -qw $flagname
13983 if [ $? -ne 0 ]; then
13984 echo "connect flag $flagname is not set"
13988 # check if multiple modify RPCs data is set
13989 out=$($LCTL get_param mdc.$FSNAME-MDT0000-*.import)
13992 echo "$out" | grep -qw $connect_data_name ||
13993 error "import should have connect data $connect_data_name"
13995 run_test 245 "check mdc connection flag/data: multiple modify RPCs"
13997 test_246() { # LU-7371
13998 remote_ost_nodsh && skip "remote OST with nodsh" && return
13999 [ $(lustre_version_code ost1) -lt $(version_code 2.7.62) ] &&
14000 skip "Need OST version >= 2.7.62" && return 0
14001 do_facet ost1 $LCTL set_param fail_val=4095
14002 #define OBD_FAIL_OST_READ_SIZE 0x234
14003 do_facet ost1 $LCTL set_param fail_loc=0x234
14004 $LFS setstripe $DIR/$tfile -i 0 -c 1
14005 dd if=/dev/zero of=$DIR/$tfile bs=4095 count=1 > /dev/null 2>&1
14006 cancel_lru_locks $FSNAME-OST0000
14007 dd if=$DIR/$tfile of=/dev/null bs=1048576 || error "Read failed"
14009 run_test 246 "Read file of size 4095 should return right length"
14012 lctl get_param -n mdc.$FSNAME-MDT0000*.import |
14014 { skip "Fileset feature is not supported"; return; }
14016 local submount=${MOUNT}_$tdir
14019 mkdir -p $submount || error "mkdir $submount failed"
14020 FILESET="$FILESET/$tdir" mount_client $submount ||
14021 error "mount $submount failed"
14022 echo foo > $submount/$tfile || error "write $submount/$tfile failed"
14023 [ $(cat $MOUNT/$tdir/$tfile) = "foo" ] ||
14024 error "read $MOUNT/$tdir/$tfile failed"
14025 umount_client $submount || error "umount $submount failed"
14028 run_test 247a "mount subdir as fileset"
14031 lctl get_param -n mdc.$FSNAME-MDT0000*.import | grep -q subtree ||
14032 { skip "Fileset feature is not supported"; return; }
14034 local submount=${MOUNT}_$tdir
14036 rm -rf $MOUNT/$tdir
14037 mkdir -p $submount || error "mkdir $submount failed"
14039 FILESET="$FILESET/$tdir" mount_client $submount &&
14040 error "mount $submount should fail"
14043 run_test 247b "mount subdir that dose not exist"
14046 lctl get_param -n mdc.$FSNAME-MDT0000*.import | grep -q subtree ||
14047 { skip "Fileset feature is not supported"; return; }
14049 local submount=${MOUNT}_$tdir
14051 mkdir -p $MOUNT/$tdir/dir1
14052 mkdir -p $submount || error "mkdir $submount failed"
14053 FILESET="$FILESET/$tdir" mount_client $submount ||
14054 error "mount $submount failed"
14055 local fid=$($LFS path2fid $MOUNT/)
14056 $LFS fid2path $submount $fid && error "fid2path should fail"
14057 umount_client $submount || error "umount $submount failed"
14060 run_test 247c "running fid2path outside root"
14063 lctl get_param -n mdc.$FSNAME-MDT0000*.import | grep -q subtree ||
14064 { skip "Fileset feature is not supported"; return; }
14066 local submount=${MOUNT}_$tdir
14068 mkdir -p $MOUNT/$tdir/dir1
14069 mkdir -p $submount || error "mkdir $submount failed"
14070 FILESET="$FILESET/$tdir" mount_client $submount ||
14071 error "mount $submount failed"
14072 local fid=$($LFS path2fid $submount/dir1)
14073 $LFS fid2path $submount $fid || error "fid2path should succeed"
14074 umount_client $submount || error "umount $submount failed"
14077 run_test 247d "running fid2path inside root"
14081 lctl get_param -n mdc.$FSNAME-MDT0000*.import |
14083 { skip "Fileset feature is not supported"; return; }
14085 local submount=${MOUNT}_$tdir
14088 mkdir -p $submount || error "mkdir $submount failed"
14089 FILESET="$FILESET/.." mount_client $submount &&
14090 error "mount $submount should fail"
14093 run_test 247e "mount .. as fileset"
14096 local fast_read_sav=$($LCTL get_param -n llite.*.fast_read 2>/dev/null)
14097 [ -z "$fast_read_sav" ] && skip "no fast read support" && return
14099 # create a large file for fast read verification
14100 dd if=/dev/zero of=$DIR/$tfile bs=1M count=128 > /dev/null 2>&1
14102 # make sure the file is created correctly
14103 $CHECKSTAT -s $((128*1024*1024)) $DIR/$tfile ||
14104 { rm -f $DIR/$tfile; skip "file creation error" && return; }
14106 echo "Test 1: verify that fast read is 4 times faster on cache read"
14108 # small read with fast read enabled
14109 $LCTL set_param -n llite.*.fast_read=1
14110 local t_fast=$(dd if=$DIR/$tfile of=/dev/null bs=4k 2>&1 |
14111 awk '/copied/ { print $6 }')
14113 # small read with fast read disabled
14114 $LCTL set_param -n llite.*.fast_read=0
14115 local t_slow=$(dd if=$DIR/$tfile of=/dev/null bs=4k 2>&1 |
14116 awk '/copied/ { print $6 }')
14118 # verify that fast read is 4 times faster for cache read
14119 [ $(bc <<< "4 * $t_fast < $t_slow") -eq 1 ] ||
14120 error_not_in_vm "fast read was not 4 times faster: " \
14121 "$t_fast vs $t_slow"
14123 echo "Test 2: verify the performance between big and small read"
14124 $LCTL set_param -n llite.*.fast_read=1
14126 # 1k non-cache read
14127 cancel_lru_locks osc
14128 local t_1k=$(dd if=$DIR/$tfile of=/dev/null bs=1k 2>&1 |
14129 awk '/copied/ { print $6 }')
14131 # 1M non-cache read
14132 cancel_lru_locks osc
14133 local t_1m=$(dd if=$DIR/$tfile of=/dev/null bs=1k 2>&1 |
14134 awk '/copied/ { print $6 }')
14136 # verify that big IO is not 4 times faster than small IO
14137 [ $(bc <<< "4 * $t_1k >= $t_1m") -eq 1 ] ||
14138 error_not_in_vm "bigger IO is way too fast: $t_1k vs $t_1m"
14140 $LCTL set_param -n llite.*.fast_read=$fast_read_sav
14143 run_test 248 "fast read verification"
14145 test_249() { # LU-7890
14147 $SETSTRIPE -c 1 $DIR/$tfile
14149 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.8.53) ] &&
14150 skip "Need at least version 2.8.54"
14152 # Offset 2T == 4k * 512M
14153 dd if=/dev/zero of=$DIR/$tfile bs=4k count=1 seek=512M ||
14154 error "dd to 2T offset failed"
14156 run_test 249 "Write above 2T file size"
14159 [ "$(facet_fstype ost$(($($GETSTRIPE -i $DIR/$tfile) + 1)))" = "zfs" ] \
14160 && skip "no 16TB file size limit on ZFS" && return
14162 $SETSTRIPE -c 1 $DIR/$tfile
14163 # ldiskfs extent file size limit is (16TB - 4KB - 1) bytes
14164 local size=$((16 * 1024 * 1024 * 1024 * 1024 - 4096 - 1))
14165 $TRUNCATE $DIR/$tfile $size || error "truncate $tfile to $size failed"
14166 dd if=/dev/zero of=$DIR/$tfile bs=10 count=1 oflag=append \
14167 conv=notrunc,fsync && error "append succeeded"
14170 run_test 250 "Write above 16T limit"
14173 $SETSTRIPE -c -1 -S 1048576 $DIR/$tfile
14175 #define OBD_FAIL_LLITE_LOST_LAYOUT 0x1407
14176 #Skip once - writing the first stripe will succeed
14177 $LCTL set_param fail_loc=0xa0001407 fail_val=1
14178 $MULTIOP $DIR/$tfile o:O_RDWR:w2097152c 2>&1 | grep -q "short write" &&
14179 error "short write happened"
14181 $LCTL set_param fail_loc=0xa0001407 fail_val=1
14182 $MULTIOP $DIR/$tfile or2097152c 2>&1 | grep -q "short read" &&
14183 error "short read happened"
14187 run_test 251 "Handling short read and write correctly"
14197 remote_mds_nodsh && skip "remote MDS with nodsh" && return
14198 remote_ost_nodsh && skip "remote OST with nodsh" && return
14199 if [ "$(facet_fstype ost1)" != "ldiskfs" -o \
14200 "$(facet_fstype mds1)" != "ldiskfs" ]; then
14201 skip "can only run lr_reader on ldiskfs target"
14205 # check lr_reader on OST0000
14207 dev=$(facet_device $tgt)
14208 out=$(do_facet $tgt $LR_READER $dev)
14209 [ $? -eq 0 ] || error "$LR_READER failed on target $tgt device $dev"
14211 uuid=$(echo "$out" | grep -i uuid | awk '{ print $2 }')
14212 [ "$uuid" == "$(ostuuid_from_index 0)" ] ||
14213 error "Invalid uuid returned by $LR_READER on target $tgt"
14214 echo -e "uuid returned by $LR_READER is '$uuid'\n"
14216 # check lr_reader -c on MDT0000
14218 dev=$(facet_device $tgt)
14219 if ! do_facet $tgt $LR_READER -h | grep -q OPTIONS; then
14220 echo "$LR_READER does not support additional options"
14223 out=$(do_facet $tgt $LR_READER -c $dev)
14224 [ $? -eq 0 ] || error "$LR_READER failed on target $tgt device $dev"
14226 num=$(echo "$out" | grep -c "mdtlov")
14227 [ "$num" -eq $((MDSCOUNT - 1)) ] ||
14228 error "Invalid number of mdtlov clients returned by $LR_READER"
14229 echo -e "Number of mdtlov clients returned by $LR_READER is '$num'\n"
14231 # check lr_reader -cr on MDT0000
14232 out=$(do_facet $tgt $LR_READER -cr $dev)
14233 [ $? -eq 0 ] || error "$LR_READER failed on target $tgt device $dev"
14235 echo "$out" | grep -q "^reply_data:$" ||
14236 error "$LR_READER should have returned 'reply_data' section"
14237 num=$(echo "$out" | grep -c "client_generation")
14238 echo -e "Number of reply data returned by $LR_READER is '$num'\n"
14240 run_test 252 "check lr_reader tool"
14242 test_253_fill_ost() {
14243 local size_mb #how many MB should we write to pass watermark
14244 local lwm=$3 #low watermark
14245 local free_10mb #10% of free space
14247 free_kb=$($LFS df $MOUNT | grep $1 | awk '{ print $4 }')
14248 size_mb=$((free_kb / 1024 - lwm))
14249 free_10mb=$((free_kb / 10240))
14250 #If 10% of free space cross low watermark use it
14251 if (( free_10mb > size_mb )); then
14254 #At least we need to store 1.1 of difference between
14255 #free space and low watermark
14256 size_mb=$((size_mb + size_mb / 10))
14258 if (( lwm <= $((free_kb / 1024)) )) || [ ! -f $DIR/$tdir/1 ]; then
14259 dd if=/dev/zero of=$DIR/$tdir/1 bs=1M count=$size_mb \
14260 oflag=append conv=notrunc
14265 free_kb=$($LFS df $MOUNT | grep $1 | awk '{ print $4 }')
14266 echo "OST still has $((free_kb / 1024)) mbytes free"
14273 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
14274 remote_mds_nodsh && skip "remote MDS with nodsh" && return
14275 remote_mgs_nodsh && skip "remote MGS with nodsh" && return
14277 local ost_name=$($LFS osts |
14278 sed -n 's/^'$ostidx': \(.*\)_UUID .*/\1/p')
14280 local mdtosc_proc1=$(get_mdtosc_proc_path $SINGLEMDS $ost_name)
14281 do_facet $SINGLEMDS $LCTL get_param -n \
14282 osp.$mdtosc_proc1.reserved_mb_high ||
14283 { skip "remote MDS does not support reserved_mb_high" &&
14288 wait_delete_completed
14291 local last_wm_h=$(do_facet $SINGLEMDS $LCTL get_param -n \
14292 osp.$mdtosc_proc1.reserved_mb_high)
14293 local last_wm_l=$(do_facet $SINGLEMDS $LCTL get_param -n \
14294 osp.$mdtosc_proc1.reserved_mb_low)
14295 echo "prev high watermark $last_wm_h, prev low watermark $last_wm_l"
14297 create_pool $FSNAME.$TESTNAME || error "Pool creation failed"
14298 do_facet mgs $LCTL pool_add $FSNAME.$TESTNAME $ost_name ||
14299 error "Adding $ost_name to pool failed"
14301 # Wait for client to see a OST at pool
14302 wait_update $HOSTNAME "$LCTL get_param -n
14303 lov.$FSNAME-*.pools.$TESTNAME | sort -u |
14304 grep $ost_name" "$ost_name""_UUID" $((TIMEOUT/2)) ||
14305 error "Client can not see the pool"
14306 $SETSTRIPE $DIR/$tdir -i $ostidx -c 1 -p $FSNAME.$TESTNAME ||
14307 error "Setstripe failed"
14309 dd if=/dev/zero of=$DIR/$tdir/0 bs=1M count=10
14310 local blocks=$($LFS df $MOUNT | grep $ost_name | awk '{ print $4 }')
14311 echo "OST still has $((blocks/1024)) mbytes free"
14313 local new_lwm=$((blocks/1024-10))
14314 do_facet $SINGLEMDS $LCTL set_param \
14315 osp.$mdtosc_proc1.reserved_mb_high=$((new_lwm+5))
14316 do_facet $SINGLEMDS $LCTL set_param \
14317 osp.$mdtosc_proc1.reserved_mb_low=$new_lwm
14319 test_253_fill_ost $ost_name $mdtosc_proc1 $new_lwm
14321 #First enospc could execute orphan deletion so repeat.
14322 test_253_fill_ost $ost_name $mdtosc_proc1 $new_lwm
14324 local oa_status=$(do_facet $SINGLEMDS $LCTL get_param -n \
14325 osp.$mdtosc_proc1.prealloc_status)
14326 echo "prealloc_status $oa_status"
14328 dd if=/dev/zero of=$DIR/$tdir/2 bs=1M count=1 &&
14329 error "File creation should fail"
14330 #object allocation was stopped, but we still able to append files
14331 dd if=/dev/zero of=$DIR/$tdir/1 bs=1M seek=6 count=5 oflag=append ||
14332 error "Append failed"
14333 rm -f $DIR/$tdir/1 $DIR/$tdir/0 $DIR/$tdir/r*
14335 wait_delete_completed
14339 for i in $(seq 10 12); do
14340 dd if=/dev/zero of=$DIR/$tdir/$i bs=1M count=1 2>/dev/null ||
14341 error "File creation failed after rm";
14344 oa_status=$(do_facet $SINGLEMDS $LCTL get_param -n \
14345 osp.$mdtosc_proc1.prealloc_status)
14346 echo "prealloc_status $oa_status"
14348 if (( oa_status != 0 )); then
14349 error "Object allocation still disable after rm"
14351 do_facet $SINGLEMDS $LCTL set_param \
14352 osp.$mdtosc_proc1.reserved_mb_high=$last_wm_h
14353 do_facet $SINGLEMDS $LCTL set_param \
14354 osp.$mdtosc_proc1.reserved_mb_low=$last_wm_l
14357 do_facet mgs $LCTL pool_remove $FSNAME.$TESTNAME $ost_name ||
14358 error "Remove $ost_name from pool failed"
14359 do_facet mgs $LCTL pool_destroy $FSNAME.$TESTNAME ||
14360 error "Pool destroy fialed"
14362 run_test 253 "Check object allocation limit"
14367 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
14368 remote_mds_nodsh && skip "remote MDS with nodsh" && return
14369 do_facet mds1 $LCTL get_param -n mdd.$MDT0.changelog_size ||
14370 { skip "MDS does not support changelog_size" && return; }
14372 cl_user=$(do_facet mds1 $LCTL --device $MDT0 changelog_register -n)
14373 echo "Registered as changelog user $cl_user"
14375 $LFS changelog_clear $MDT0 $cl_user 0
14377 local size1=$(do_facet mds1 \
14378 $LCTL get_param -n mdd.$MDT0.changelog_size)
14379 echo "Changelog size $size1"
14382 $LFS mkdir -i 0 $DIR/$tdir
14384 mkdir -p $DIR/$tdir/pics/2008/zachy
14385 touch $DIR/$tdir/pics/2008/zachy/timestamp
14386 cp /etc/hosts $DIR/$tdir/pics/2008/zachy/pic1.jpg
14387 mv $DIR/$tdir/pics/2008/zachy $DIR/$tdir/pics/zach
14388 ln $DIR/$tdir/pics/zach/pic1.jpg $DIR/$tdir/pics/2008/portland.jpg
14389 ln -s $DIR/$tdir/pics/2008/portland.jpg $DIR/$tdir/pics/desktop.jpg
14390 rm $DIR/$tdir/pics/desktop.jpg
14392 local size2=$(do_facet mds1 \
14393 $LCTL get_param -n mdd.$MDT0.changelog_size)
14394 echo "Changelog size after work $size2"
14396 do_facet mds1 $LCTL --device $MDT0 changelog_deregister $cl_user
14398 if (( size2 <= size1 )); then
14399 error "Changelog size after work should be greater than original"
14403 run_test 254 "Check changelog size"
14410 lfs ladvise -a invalid $file 2>&1 | grep "Valid types" |
14411 awk -F: '{print $2}' | grep $type > /dev/null
14412 if [ $? -ne 0 ]; then
14422 lfs ladvise -a willread $file > /dev/null 2>&1
14423 if [ $? -eq 0 ]; then
14427 lfs ladvise -a willread $file 2>&1 |
14428 grep "Inappropriate ioctl for device" > /dev/null
14429 if [ $? -eq 0 ]; then
14435 ladvise_willread_performance()
14438 local average_cache=0
14439 local average_ladvise=0
14441 for ((i = 1; i <= $repeat; i++)); do
14442 echo "Iter $i/$repeat: reading without willread hint"
14443 cancel_lru_locks osc
14444 do_nodes $(comma_list $(osts_nodes)) \
14445 "echo 3 > /proc/sys/vm/drop_caches"
14446 local speed_origin=$($READS -f $DIR/$tfile -s $size \
14447 -b 4096 -n $((size / 4096)) -t 60 |
14448 sed -e '/^$/d' -e 's#.*s, ##' -e 's#MB/s##')
14450 echo "Iter $i/$repeat: Reading again without willread hint"
14451 cancel_lru_locks osc
14452 local speed_cache=$($READS -f $DIR/$tfile -s $size \
14453 -b 4096 -n $((size / 4096)) -t 60 |
14454 sed -e '/^$/d' -e 's#.*s, ##' -e 's#MB/s##')
14456 echo "Iter $i/$repeat: reading with willread hint"
14457 cancel_lru_locks osc
14458 do_nodes $(comma_list $(osts_nodes)) \
14459 "echo 3 > /proc/sys/vm/drop_caches"
14460 lfs ladvise -a willread $DIR/$tfile ||
14461 error "Ladvise failed"
14462 local speed_ladvise=$($READS -f $DIR/$tfile -s $size \
14463 -b 4096 -n $((size / 4096)) -t 60 |
14464 sed -e '/^$/d' -e 's#.*s, ##' -e 's#MB/s##')
14466 local cache_speedup=$(echo "scale=2; \
14467 ($speed_cache-$speed_origin)/$speed_origin*100" | bc)
14468 cache_speedup=$(echo ${cache_speedup%.*})
14469 echo "Iter $i/$repeat: cache speedup: $cache_speedup%"
14470 average_cache=$((average_cache + cache_speedup))
14472 local ladvise_speedup=$(echo "scale=2; \
14473 ($speed_ladvise-$speed_origin)/$speed_origin*100" | bc)
14474 ladvise_speedup=$(echo ${ladvise_speedup%.*})
14475 echo "Iter $i/$repeat: ladvise speedup: $ladvise_speedup%"
14476 average_ladvise=$((average_ladvise + ladvise_speedup))
14478 average_cache=$((average_cache / repeat))
14479 average_ladvise=$((average_ladvise / repeat))
14481 if [ $average_cache -lt 20 ]; then
14482 echo "Speedup with cache is less than 20% ($average_cache%),"\
14483 "skipping check of speedup with willread:"\
14484 "$average_ladvise%"
14488 local lowest_speedup=$((average_cache / 2))
14489 [ $average_ladvise -gt $lowest_speedup ] ||
14490 error_not_in_vm "Speedup with willread is less than " \
14491 "$lowest_speedup%, got $average_ladvise%"
14492 echo "Speedup with willread ladvise: $average_ladvise%"
14493 echo "Speedup with cache: $average_cache%"
14497 [ $(lustre_version_code ost1) -lt $(version_code 2.8.54) ] &&
14498 skip "lustre < 2.8.54 does not support ladvise " && return
14500 lfs setstripe -c -1 -i 0 $DIR/$tfile || error "$tfile failed"
14502 ladvise_no_type willread $DIR/$tfile &&
14503 skip "willread ladvise is not supported" && return
14505 ladvise_no_ioctl $DIR/$tfile &&
14506 skip "ladvise ioctl is not supported" && return
14509 local size=$((size_mb * 1048576))
14510 dd if=/dev/zero of=$DIR/$tfile bs=1048576 count=$size_mb ||
14511 error "dd to $DIR/$tfile failed"
14513 lfs ladvise -a willread $DIR/$tfile ||
14514 error "Ladvise failed with no range argument"
14516 lfs ladvise -a willread -s 0 $DIR/$tfile ||
14517 error "Ladvise failed with no -l or -e argument"
14519 lfs ladvise -a willread -e 1 $DIR/$tfile ||
14520 error "Ladvise failed with only -e argument"
14522 lfs ladvise -a willread -l 1 $DIR/$tfile ||
14523 error "Ladvise failed with only -l argument"
14525 lfs ladvise -a willread -s 2 -e 1 $DIR/$tfile &&
14526 error "End offset should not be smaller than start offset"
14528 lfs ladvise -a willread -s 2 -e 2 $DIR/$tfile &&
14529 error "End offset should not be equal to start offset"
14531 lfs ladvise -a willread -s $size -l 1 $DIR/$tfile ||
14532 error "Ladvise failed with overflowing -s argument"
14534 lfs ladvise -a willread -s 1 -e $((size + 1)) $DIR/$tfile ||
14535 error "Ladvise failed with overflowing -e argument"
14537 lfs ladvise -a willread -s 1 -l $size $DIR/$tfile ||
14538 error "Ladvise failed with overflowing -l argument"
14540 lfs ladvise -a willread -l 1 -e 2 $DIR/$tfile &&
14541 error "Ladvise succeeded with conflicting -l and -e arguments"
14543 echo "Synchronous ladvise should wait"
14545 #define OBD_FAIL_OST_LADVISE_PAUSE 0x237
14546 do_nodes $(comma_list $(osts_nodes)) \
14547 $LCTL set_param fail_val=$delay fail_loc=0x237
14549 local start_ts=$SECONDS
14550 lfs ladvise -a willread $DIR/$tfile ||
14551 error "Ladvise failed with no range argument"
14552 local end_ts=$SECONDS
14553 local inteval_ts=$((end_ts - start_ts))
14555 if [ $inteval_ts -lt $(($delay - 1)) ]; then
14556 error "Synchronous advice didn't wait reply"
14559 echo "Asynchronous ladvise shouldn't wait"
14560 local start_ts=$SECONDS
14561 lfs ladvise -a willread -b $DIR/$tfile ||
14562 error "Ladvise failed with no range argument"
14563 local end_ts=$SECONDS
14564 local inteval_ts=$((end_ts - start_ts))
14566 if [ $inteval_ts -gt $(($delay / 2)) ]; then
14567 error "Asynchronous advice blocked"
14570 do_nodes $(comma_list $(osts_nodes)) $LCTL set_param fail_loc=0
14571 ladvise_willread_performance
14573 run_test 255a "check 'lfs ladvise -a willread'"
14579 do_facet $facet "cat /proc/meminfo | grep ^${info}:" | awk '{print $2}'
14583 ladvise_no_type dontneed $DIR/$tfile &&
14584 skip "dontneed ladvise is not supported" && return
14586 ladvise_no_ioctl $DIR/$tfile &&
14587 skip "ladvise ioctl is not supported" && return
14589 [ $(lustre_version_code ost1) -lt $(version_code 2.8.54) ] &&
14590 skip "lustre < 2.8.54 does not support ladvise" && return
14592 [ "$(facet_fstype ost1)" = "zfs" ] &&
14593 skip "zfs-osd does not support dontneed advice" && return
14595 lfs setstripe -c 1 -i 0 $DIR/$tfile
14598 local size=$((size_mb * 1048576))
14599 # In order to prevent disturbance of other processes, only check 3/4
14600 # of the memory usage
14601 local kibibytes=$((size_mb * 1024 * 3 / 4))
14603 dd if=/dev/zero of=$DIR/$tfile bs=1048576 count=$size_mb ||
14604 error "dd to $DIR/$tfile failed"
14606 local total=$(facet_meminfo ost1 MemTotal)
14607 echo "Total memory: $total KiB"
14609 do_facet ost1 "sync && echo 3 > /proc/sys/vm/drop_caches"
14610 local before_read=$(facet_meminfo ost1 Cached)
14611 echo "Cache used before read: $before_read KiB"
14613 lfs ladvise -a willread $DIR/$tfile ||
14614 error "Ladvise willread failed"
14615 local after_read=$(facet_meminfo ost1 Cached)
14616 echo "Cache used after read: $after_read KiB"
14618 lfs ladvise -a dontneed $DIR/$tfile ||
14619 error "Ladvise dontneed again failed"
14620 local no_read=$(facet_meminfo ost1 Cached)
14621 echo "Cache used after dontneed ladvise: $no_read KiB"
14623 if [ $total -lt $((before_read + kibibytes)) ]; then
14624 echo "Memory is too small, abort checking"
14628 if [ $((before_read + kibibytes)) -gt $after_read ]; then
14629 error "Ladvise willread should use more memory" \
14630 "than $kibibytes KiB"
14633 if [ $((no_read + kibibytes)) -gt $after_read ]; then
14634 error "Ladvise dontneed should release more memory" \
14635 "than $kibibytes KiB"
14638 run_test 255b "check 'lfs ladvise -a dontneed'"
14645 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
14646 remote_mds_nodsh && skip "remote MDS with nodsh" && return
14647 [ "$(facet_fstype mds1)" != "ldiskfs" ] &&
14648 skip "non-ldiskfs backend" && return
14650 mdt_dev=$(mdsdevname 1)
14652 cl_user=$(do_facet mds1 \
14653 "$LCTL get_param -n mdd.$MDT0.changelog_users | grep cl")
14654 if [[ -n $cl_user ]]; then
14655 skip "active changelog user"
14659 cl_user=$(do_facet mds1 $LCTL --device $MDT0 changelog_register -n)
14660 echo "Registered as changelog user $cl_user"
14663 mkdir -p $DIR/$tdir
14665 $LFS changelog_clear $MDT0 $cl_user 0
14668 touch $DIR/$tdir/{1..10}
14671 stop mds1 || error "Fail to stop MDT."
14674 start mds1 $mdt_dev $MDS_MOUNT_OPTS || error "Fail to start MDT."
14676 #after mount new plainllog is used
14677 touch $DIR/$tdir/{11..19}
14678 cat_sl=$(do_facet mds1 \
14679 "$DEBUGFS -R \\\"dump changelog_catalog cat.dmp\\\" $mdt_dev; \
14680 llog_reader cat.dmp | grep \\\"type=1064553b\\\" | wc -l")
14682 if (( cat_sl != 2 )); then
14683 do_facet mds1 $LCTL --device $MDT0 changelog_deregister $cl_user
14684 error "Changelog catalog has wrong number of slots $cat_sl"
14687 $LFS changelog_clear $MDT0 $cl_user 0
14689 cat_sl=$(do_facet mds1 \
14690 "$DEBUGFS -R \\\"dump changelog_catalog cat.dmp\\\" $mdt_dev; \
14691 llog_reader cat.dmp | grep \\\"type=1064553b\\\" | wc -l")
14693 do_facet mds1 $LCTL --device $MDT0 changelog_deregister $cl_user
14695 if (( cat_sl == 2 )); then
14696 error "Empty plain llog was not deleted from changelog catalog"
14698 if (( cat_sl != 1 )); then
14699 error "Active plain llog shouldn\`t be deleted from catalog"
14702 run_test 256 "Check llog delete for empty and not full state"
14705 remote_mds_nodsh && skip "remote MDS with nodsh" && return
14706 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.8.55) ]] &&
14707 skip "Need MDS version at least 2.8.55" && return
14709 test_mkdir -p $DIR/$tdir
14711 setfattr -n trusted.name1 -v value1 $DIR/$tdir ||
14712 error "setfattr -n trusted.name1=value1 $DIR/$tdir failed"
14715 #define OBD_FAIL_MDS_XATTR_REP 0x161
14716 local mdtidx=$($LFS getstripe -M $DIR/$tdir)
14717 local facet=mds$((mdtidx + 1))
14718 set_nodes_failloc $(facet_active_host $facet) 0x80000161
14719 getfattr -n trusted.name1 $DIR/$tdir 2> /dev/null
14721 stop $facet || error "stop MDS failed"
14722 start $facet $(mdsdevname $((mdtidx + 1))) $MDS_MOUNT_OPTS ||
14723 error "start MDS fail"
14725 run_test 257 "xattr locks are not lost"
14728 #define OBD_FAIL_MDC_CLOSE 0x806
14729 $LCTL set_param fail_loc=0x80000806
14733 run_test 260 "Check mdc_close fail"
14735 cleanup_test_300() {
14739 test_striped_dir() {
14744 mkdir -p $DIR/$tdir
14746 SAVE_UMASK=$(umask)
14747 trap cleanup_test_300 RETURN EXIT
14749 $LFS setdirstripe -i $mdt_index -c 2 -t all_char -m 755 \
14750 $DIR/$tdir/striped_dir ||
14751 error "set striped dir error"
14753 local mode=$(stat -c%a $DIR/$tdir/striped_dir)
14754 [ "$mode" = "755" ] || error "expect 755 got $mode"
14756 $LFS getdirstripe $DIR/$tdir/striped_dir > /dev/null 2>&1 ||
14757 error "getdirstripe failed"
14758 stripe_count=$($LFS getdirstripe -c $DIR/$tdir/striped_dir)
14759 if [ "$stripe_count" != "2" ]; then
14760 error "1:stripe_count is $stripe_count, expect 2"
14762 stripe_count=$($LFS getdirstripe -T $DIR/$tdir/striped_dir)
14763 if [ "$stripe_count" != "2" ]; then
14764 error "2:stripe_count is $stripe_count, expect 2"
14767 stripe_index=$($LFS getdirstripe -i $DIR/$tdir/striped_dir)
14768 if [ "$stripe_index" != "$mdt_index" ]; then
14769 error "stripe_index is $stripe_index, expect $mdt_index"
14772 [ $(stat -c%h $DIR/$tdir/striped_dir) == '2' ] ||
14773 error "nlink error after create striped dir"
14775 mkdir $DIR/$tdir/striped_dir/a
14776 mkdir $DIR/$tdir/striped_dir/b
14778 stat $DIR/$tdir/striped_dir/a ||
14779 error "create dir under striped dir failed"
14780 stat $DIR/$tdir/striped_dir/b ||
14781 error "create dir under striped dir failed"
14783 [ $(stat -c%h $DIR/$tdir/striped_dir) == '4' ] ||
14784 error "nlink error after mkdir"
14786 rmdir $DIR/$tdir/striped_dir/a
14787 [ $(stat -c%h $DIR/$tdir/striped_dir) == '3' ] ||
14788 error "nlink error after rmdir"
14790 rmdir $DIR/$tdir/striped_dir/b
14791 [ $(stat -c%h $DIR/$tdir/striped_dir) == '2' ] ||
14792 error "nlink error after rmdir"
14794 chattr +i $DIR/$tdir/striped_dir
14795 createmany -o $DIR/$tdir/striped_dir/f 10 &&
14796 error "immutable flags not working under striped dir!"
14797 chattr -i $DIR/$tdir/striped_dir
14799 rmdir $DIR/$tdir/striped_dir ||
14800 error "rmdir striped dir error"
14808 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.0) ] &&
14809 skip "skipped for lustre < 2.7.0" && return
14810 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
14811 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
14813 test_striped_dir 0 || error "failed on striped dir on MDT0"
14814 test_striped_dir 1 || error "failed on striped dir on MDT0"
14816 run_test 300a "basic striped dir sanity test"
14819 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.0) ] &&
14820 skip "skipped for lustre < 2.7.0" && return
14821 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
14822 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
14828 test_mkdir $DIR/$tdir || error "mkdir fail"
14829 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir ||
14830 error "set striped dir error"
14831 for ((i=0; i<10; i++)); do
14832 mtime1=$(stat -c %Y $DIR/$tdir/striped_dir)
14834 touch $DIR/$tdir/striped_dir/file_$i ||
14835 error "touch error $i"
14836 mtime2=$(stat -c %Y $DIR/$tdir/striped_dir)
14837 [ $mtime1 -eq $mtime2 ] &&
14838 error "mtime not change after create"
14840 rm -f $DIR/$tdir/striped_dir/file_$i ||
14841 error "unlink error $i"
14842 mtime3=$(stat -c %Y $DIR/$tdir/striped_dir)
14843 [ $mtime2 -eq $mtime3 ] &&
14844 error "mtime did not change after unlink"
14848 run_test 300b "check ctime/mtime for striped dir"
14851 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.0) ] &&
14852 skip "skipped for lustre < 2.7.0" && return
14853 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
14854 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
14857 mkdir -p $DIR/$tdir
14858 $LFS setdirstripe -i 0 -c 2 $DIR/$tdir/striped_dir ||
14859 error "set striped dir error"
14861 chown $RUNAS_ID:$RUNAS_GID $DIR/$tdir/striped_dir ||
14862 error "chown striped dir failed"
14864 $RUNAS createmany -o $DIR/$tdir/striped_dir/f 5000 ||
14865 error "create 5k files failed"
14867 file_count=$(ls $DIR/$tdir/striped_dir | wc -l)
14869 [ "$file_count" = 5000 ] || error "file count $file_count != 5000"
14873 run_test 300c "chown && check ls under striped directory"
14876 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.0) ] &&
14877 skip "skipped for lustre < 2.7.0" && return
14878 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
14879 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
14883 mkdir -p $DIR/$tdir
14884 $SETSTRIPE -c 2 $DIR/$tdir
14886 #local striped directory
14887 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir ||
14888 error "set striped dir error"
14889 createmany -o $DIR/$tdir/striped_dir/f 10 ||
14890 error "create 10 files failed"
14892 #remote striped directory
14893 $LFS setdirstripe -i 1 -c 2 $DIR/$tdir/remote_striped_dir ||
14894 error "set striped dir error"
14895 createmany -o $DIR/$tdir/remote_striped_dir/f 10 ||
14896 error "create 10 files failed"
14898 for file in $(find $DIR/$tdir); do
14899 stripe_count=$($GETSTRIPE -c $file)
14900 [ $stripe_count -eq 2 ] ||
14901 error "wrong stripe $stripe_count for $file"
14906 run_test 300d "check default stripe under striped directory"
14909 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
14910 skip "Need MDS version at least 2.7.55" && return
14911 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
14912 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
14916 mkdir -p $DIR/$tdir
14918 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir ||
14919 error "set striped dir error"
14921 touch $DIR/$tdir/striped_dir/a
14922 touch $DIR/$tdir/striped_dir/b
14923 touch $DIR/$tdir/striped_dir/c
14925 mkdir $DIR/$tdir/striped_dir/dir_a
14926 mkdir $DIR/$tdir/striped_dir/dir_b
14927 mkdir $DIR/$tdir/striped_dir/dir_c
14929 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir/stp_a ||
14930 error "set striped adir under striped dir error"
14932 $LFS setdirstripe -i 0 -c 2 -H all_char $DIR/$tdir/striped_dir/stp_b ||
14933 error "set striped bdir under striped dir error"
14935 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir/stp_c ||
14936 error "set striped cdir under striped dir error"
14938 mrename $DIR/$tdir/striped_dir/dir_a $DIR/$tdir/striped_dir/dir_b ||
14939 error "rename dir under striped dir fails"
14941 mrename $DIR/$tdir/striped_dir/stp_a $DIR/$tdir/striped_dir/stp_b ||
14942 error "rename dir under different stripes fails"
14944 mrename $DIR/$tdir/striped_dir/a $DIR/$tdir/striped_dir/c ||
14945 error "rename file under striped dir should succeed"
14947 mrename $DIR/$tdir/striped_dir/dir_b $DIR/$tdir/striped_dir/dir_c ||
14948 error "rename dir under striped dir should succeed"
14952 run_test 300e "check rename under striped directory"
14955 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
14956 skip "Need MDS version at least 2.7.55" && return
14957 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
14958 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
14963 mkdir -p $DIR/$tdir
14965 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir ||
14966 error "set striped dir error"
14968 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir1 ||
14969 error "set striped dir error"
14971 touch $DIR/$tdir/striped_dir/a
14972 mkdir $DIR/$tdir/striped_dir/dir_a
14973 $LFS setdirstripe -i 0 -c 2 $DIR/$tdir/striped_dir/stp_a ||
14974 error "create striped dir under striped dir fails"
14976 touch $DIR/$tdir/striped_dir1/b
14977 mkdir $DIR/$tdir/striped_dir1/dir_b
14978 $LFS setdirstripe -i 0 -c 2 $DIR/$tdir/striped_dir/stp_b ||
14979 error "create striped dir under striped dir fails"
14981 mrename $DIR/$tdir/striped_dir/dir_a $DIR/$tdir/striped_dir1/dir_b ||
14982 error "rename dir under different striped dir should fail"
14984 mrename $DIR/$tdir/striped_dir/stp_a $DIR/$tdir/striped_dir1/stp_b ||
14985 error "rename striped dir under diff striped dir should fail"
14987 mrename $DIR/$tdir/striped_dir/a $DIR/$tdir/striped_dir1/a ||
14988 error "rename file under diff striped dirs fails"
14992 run_test 300f "check rename cross striped directory"
14994 test_300_check_default_striped_dir()
14997 local default_count=$2
14998 local default_index=$3
15001 local dir_stripe_index
15004 echo "checking $dirname $default_count $default_index"
15005 $LFS setdirstripe -D -c $default_count -i $default_index \
15006 -t all_char $DIR/$tdir/$dirname ||
15007 error "set default stripe on striped dir error"
15008 stripe_count=$($LFS getdirstripe -D -c $DIR/$tdir/$dirname)
15009 [ $stripe_count -eq $default_count ] ||
15010 error "expect $default_count get $stripe_count for $dirname"
15012 stripe_index=$($LFS getdirstripe -D -i $DIR/$tdir/$dirname)
15013 [ $stripe_index -eq $default_index ] ||
15014 error "expect $default_index get $stripe_index for $dirname"
15016 mkdir $DIR/$tdir/$dirname/{test1,test2,test3,test4} ||
15017 error "create dirs failed"
15019 createmany -o $DIR/$tdir/$dirname/f- 10 || error "create files failed"
15020 unlinkmany $DIR/$tdir/$dirname/f- 10 || error "unlink files failed"
15021 for dir in $(find $DIR/$tdir/$dirname/*); do
15022 stripe_count=$($LFS getdirstripe -c $dir)
15023 [ $stripe_count -eq $default_count ] ||
15024 [ $stripe_count -eq 0 -o $default_count -eq 1 ] ||
15025 error "stripe count $default_count != $stripe_count for $dir"
15027 stripe_index=$($LFS getdirstripe -i $dir)
15028 [ $default_index -eq -1 -o $stripe_index -eq $default_index ] ||
15029 error "$stripe_index != $default_index for $dir"
15031 #check default stripe
15032 stripe_count=$($LFS getdirstripe -D -c $dir)
15033 [ $stripe_count -eq $default_count ] ||
15034 error "default count $default_count != $stripe_count for $dir"
15036 stripe_index=$($LFS getdirstripe -D -i $dir)
15037 [ $stripe_index -eq $default_index ] ||
15038 error "default index $default_index != $stripe_index for $dir"
15040 rmdir $DIR/$tdir/$dirname/* || error "rmdir failed"
15044 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
15045 skip "Need MDS version at least 2.7.55" && return
15046 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
15052 mkdir $DIR/$tdir/normal_dir
15054 #Checking when client cache stripe index
15055 $LFS setdirstripe -c$MDSCOUNT $DIR/$tdir/striped_dir
15056 $LFS setdirstripe -D -i1 $DIR/$tdir/striped_dir ||
15057 error "create striped_dir failed"
15059 mkdir $DIR/$tdir/striped_dir/dir1 ||
15060 error "create dir1 fails"
15061 stripe_index=$($LFS getdirstripe -i $DIR/$tdir/striped_dir/dir1)
15062 [ $stripe_index -eq 1 ] ||
15063 error "dir1 expect 1 got $stripe_index"
15065 $LFS setdirstripe -i2 $DIR/$tdir/striped_dir/dir2 ||
15066 error "create dir2 fails"
15067 stripe_index=$($LFS getdirstripe -i $DIR/$tdir/striped_dir/dir2)
15068 [ $stripe_index -eq 2 ] ||
15069 error "dir2 expect 2 got $stripe_index"
15071 #check default stripe count/stripe index
15072 test_300_check_default_striped_dir normal_dir $MDSCOUNT 1
15073 test_300_check_default_striped_dir normal_dir 1 0
15074 test_300_check_default_striped_dir normal_dir 2 1
15075 test_300_check_default_striped_dir normal_dir 2 -1
15077 #delete default stripe information
15078 echo "delete default stripeEA"
15079 $LFS setdirstripe -d $DIR/$tdir/normal_dir ||
15080 error "set default stripe on striped dir error"
15082 mkdir -p $DIR/$tdir/normal_dir/{test1,test2,test3,test4}
15083 for dir in $(find $DIR/$tdir/normal_dir/*); do
15084 stripe_count=$($LFS getdirstripe -c $dir)
15085 [ $stripe_count -eq 0 ] ||
15086 error "expect 1 get $stripe_count for $dir"
15087 stripe_index=$($LFS getdirstripe -i $dir)
15088 [ $stripe_index -eq 0 ] ||
15089 error "expect 0 get $stripe_index for $dir"
15092 run_test 300g "check default striped directory for normal directory"
15095 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
15096 skip "Need MDS version at least 2.7.55" && return
15097 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
15102 $LFS setdirstripe -i 0 -c $MDSCOUNT -t all_char \
15103 $DIR/$tdir/striped_dir ||
15104 error "set striped dir error"
15106 test_300_check_default_striped_dir striped_dir $MDSCOUNT 1
15107 test_300_check_default_striped_dir striped_dir 1 0
15108 test_300_check_default_striped_dir striped_dir 2 1
15109 test_300_check_default_striped_dir striped_dir 2 -1
15111 #delete default stripe information
15112 $LFS setdirstripe -d $DIR/$tdir/striped_dir ||
15113 error "set default stripe on striped dir error"
15115 mkdir -p $DIR/$tdir/striped_dir/{test1,test2,test3,test4}
15116 for dir in $(find $DIR/$tdir/striped_dir/*); do
15117 stripe_count=$($LFS getdirstripe -c $dir)
15118 [ $stripe_count -eq 0 ] ||
15119 error "expect 1 get $stripe_count for $dir"
15122 run_test 300h "check default striped directory for striped directory"
15125 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
15126 skip "Need MDS version at least 2.7.55" && return
15127 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
15128 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
15134 $LFS setdirstripe -i 0 -c$MDSCOUNT -t all_char $DIR/$tdir/striped_dir ||
15135 error "set striped dir error"
15137 createmany -o $DIR/$tdir/striped_dir/f- 10 ||
15138 error "create files under striped dir failed"
15140 $LFS setdirstripe -i0 -c$MDSCOUNT -H all_char $DIR/$tdir/hashdir ||
15141 error "set striped hashdir error"
15143 $LFS setdirstripe -i0 -c$MDSCOUNT -H all_char $DIR/$tdir/hashdir/d0 ||
15144 error "create dir0 under hash dir failed"
15145 $LFS setdirstripe -i0 -c$MDSCOUNT -H fnv_1a_64 $DIR/$tdir/hashdir/d1 ||
15146 error "create dir1 under hash dir failed"
15148 # unfortunately, we need to umount to clear dir layout cache for now
15149 # once we fully implement dir layout, we can drop this
15150 umount_client $MOUNT || error "umount failed"
15151 mount_client $MOUNT || error "mount failed"
15153 $LFS find -H fnv_1a_64 $DIR/$tdir/hashdir
15154 local dircnt=$($LFS find -H fnv_1a_64 $DIR/$tdir/hashdir | wc -l)
15155 [ $dircnt -eq 1 ] || error "lfs find striped dir got:$dircnt,except:1"
15157 #set the stripe to be unknown hash type
15158 #define OBD_FAIL_UNKNOWN_LMV_STRIPE 0x1901
15159 $LCTL set_param fail_loc=0x1901
15160 for ((i = 0; i < 10; i++)); do
15161 $CHECKSTAT -t file $DIR/$tdir/striped_dir/f-$i ||
15162 error "stat f-$i failed"
15163 rm $DIR/$tdir/striped_dir/f-$i || error "unlink f-$i failed"
15166 touch $DIR/$tdir/striped_dir/f0 &&
15167 error "create under striped dir with unknown hash should fail"
15169 $LCTL set_param fail_loc=0
15171 umount_client $MOUNT || error "umount failed"
15172 mount_client $MOUNT || error "mount failed"
15176 run_test 300i "client handle unknown hash type striped directory"
15179 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
15180 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
15181 skip "Need MDS version at least 2.7.55" && return
15182 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
15188 #define OBD_FAIL_SPLIT_UPDATE_REC 0x1702
15189 $LCTL set_param fail_loc=0x1702
15190 $LFS setdirstripe -i 0 -c$MDSCOUNT -t all_char $DIR/$tdir/striped_dir ||
15191 error "set striped dir error"
15193 createmany -o $DIR/$tdir/striped_dir/f- 10 ||
15194 error "create files under striped dir failed"
15196 $LCTL set_param fail_loc=0
15198 rm -rf $DIR/$tdir || error "unlink striped dir fails"
15202 run_test 300j "test large update record"
15205 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
15206 skip "Need MDS version at least 2.7.55" && return
15207 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
15208 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
15214 #define OBD_FAIL_LARGE_STRIPE 0x1703
15215 $LCTL set_param fail_loc=0x1703
15216 $LFS setdirstripe -i 0 -c512 $DIR/$tdir/striped_dir ||
15217 error "set striped dir error"
15218 $LCTL set_param fail_loc=0
15220 $LFS getdirstripe $DIR/$tdir/striped_dir ||
15221 error "getstripeddir fails"
15222 rm -rf $DIR/$tdir/striped_dir ||
15223 error "unlink striped dir fails"
15227 run_test 300k "test large striped directory"
15230 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
15231 skip "Need MDS version at least 2.7.55" && return
15232 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
15233 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
15236 test_mkdir -p $DIR/$tdir/striped_dir
15237 chown $RUNAS_ID $DIR/$tdir/striped_dir ||
15238 error "chown $RUNAS_ID failed"
15239 $LFS setdirstripe -i 1 -D $DIR/$tdir/striped_dir ||
15240 error "set default striped dir failed"
15242 #define OBD_FAIL_MDS_STALE_DIR_LAYOUT 0x158
15243 $LCTL set_param fail_loc=0x80000158
15244 $RUNAS mkdir $DIR/$tdir/striped_dir/test_dir || error "create dir fails"
15246 stripe_index=$($LFS getdirstripe -i $DIR/$tdir/striped_dir/test_dir)
15247 [ $stripe_index -eq 1 ] ||
15248 error "expect 1 get $stripe_index for $dir"
15250 run_test 300l "non-root user to create dir under striped dir with stale layout"
15253 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
15254 skip "Need MDS version at least 2.7.55" && return
15255 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
15256 [ $MDSCOUNT -ge 2 ] && skip "Only for single MDT" && return
15258 mkdir -p $DIR/$tdir/striped_dir
15259 $LFS setdirstripe -D -c 1 $DIR/$tdir/striped_dir ||
15260 error "set default stripes dir error"
15262 mkdir $DIR/$tdir/striped_dir/a || error "mkdir a fails"
15264 stripe_count=$($LFS getdirstripe -c $DIR/$tdir/striped_dir/a)
15265 [ $stripe_count -eq 0 ] ||
15266 error "expect 0 get $stripe_count for a"
15268 $LFS setdirstripe -D -c 2 $DIR/$tdir/striped_dir ||
15269 error "set default stripes dir error"
15271 mkdir $DIR/$tdir/striped_dir/b || error "mkdir b fails"
15273 stripe_count=$($LFS getdirstripe -c $DIR/$tdir/striped_dir/b)
15274 [ $stripe_count -eq 0 ] ||
15275 error "expect 0 get $stripe_count for b"
15277 $LFS setdirstripe -D -c1 -i2 $DIR/$tdir/striped_dir ||
15278 error "set default stripes dir error"
15280 mkdir $DIR/$tdir/striped_dir/c &&
15281 error "default stripe_index is invalid, mkdir c should fails"
15283 rm -rf $DIR/$tdir || error "rmdir fails"
15285 run_test 300m "setstriped directory on single MDT FS"
15288 local list=$(comma_list $(mdts_nodes))
15291 do_nodes $list $LCTL set_param -n mdt.*.enable_remote_dir_gid=0
15295 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
15296 skip "Need MDS version at least 2.7.55" && return
15297 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
15298 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
15300 local list=$(comma_list $(mdts_nodes))
15302 trap cleanup_300n RETURN EXIT
15303 mkdir -p $DIR/$tdir
15304 chmod 777 $DIR/$tdir
15305 $RUNAS $LFS setdirstripe -i0 -c$MDSCOUNT \
15306 $DIR/$tdir/striped_dir > /dev/null 2>&1 &&
15307 error "create striped dir succeeds with gid=0"
15309 do_nodes $list $LCTL set_param -n mdt.*.enable_remote_dir_gid=-1
15310 $RUNAS $LFS setdirstripe -i0 -c$MDSCOUNT $DIR/$tdir/striped_dir ||
15311 error "create striped dir fails with gid=-1"
15313 do_nodes $list $LCTL set_param -n mdt.*.enable_remote_dir_gid=0
15314 $RUNAS $LFS setdirstripe -i 1 -c$MDSCOUNT -D \
15315 $DIR/$tdir/striped_dir > /dev/null 2>&1 &&
15316 error "set default striped dir succeeds with gid=0"
15319 do_nodes $list $LCTL set_param -n mdt.*.enable_remote_dir_gid=-1
15320 $RUNAS $LFS setdirstripe -i 1 -c$MDSCOUNT -D $DIR/$tdir/striped_dir ||
15321 error "set default striped dir fails with gid=-1"
15324 do_nodes $list $LCTL set_param -n mdt.*.enable_remote_dir_gid=0
15325 $RUNAS mkdir $DIR/$tdir/striped_dir/test_dir ||
15326 error "create test_dir fails"
15327 $RUNAS mkdir $DIR/$tdir/striped_dir/test_dir1 ||
15328 error "create test_dir1 fails"
15329 $RUNAS mkdir $DIR/$tdir/striped_dir/test_dir2 ||
15330 error "create test_dir2 fails"
15333 run_test 300n "non-root user to create dir under striped dir with default EA"
15336 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
15337 skip "Need MDS version at least 2.7.55" && return
15338 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
15339 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
15343 mkdir -p $DIR/$tdir
15345 numfree1=$(lctl get_param -n mdc.*MDT0000*.filesfree)
15346 numfree2=$(lctl get_param -n mdc.*MDT0001*.filesfree)
15347 if [ $numfree1 -lt 66000 -o $numfree2 -lt 66000 ]; then
15348 skip "not enough free inodes $numfree1 $numfree2"
15352 numfree1=$(lctl get_param -n mdc.*MDT0000-mdc-*.kbytesfree)
15353 numfree2=$(lctl get_param -n mdc.*MDT0001-mdc-*.kbytesfree)
15354 if [ $numfree1 -lt 300000 -o $numfree2 -lt 300000 ]; then
15355 skip "not enough free space $numfree1 $numfree2"
15359 $LFS setdirstripe -c2 $DIR/$tdir/striped_dir ||
15360 error "setdirstripe fails"
15362 createmany -d $DIR/$tdir/striped_dir/d 131000 ||
15363 error "create dirs fails"
15365 $LCTL set_param ldlm.namespaces.*mdc-*.lru_size=0
15366 ls $DIR/$tdir/striped_dir > /dev/null ||
15367 error "ls striped dir fails"
15368 unlinkmany -d $DIR/$tdir/striped_dir/d 131000 ||
15369 error "unlink big striped dir fails"
15371 run_test 300o "unlink big sub stripe(> 65000 subdirs)"
15374 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
15375 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
15376 remote_mds_nodsh && skip "remote MDS with nodsh" && return
15378 mkdir -p $DIR/$tdir
15380 #define OBD_FAIL_OUT_ENOSPC 0x1704
15381 do_facet mds2 lctl set_param fail_loc=0x80001704
15382 $LFS setdirstripe -c2 $DIR/$tdir/bad_striped_dir > /dev/null 2>&1 &&
15383 error "create striped directory should fail"
15385 [ -e $DIR/$tdir/bad_striped_dir ] && error "striped dir exists"
15387 $LFS setdirstripe -c2 $DIR/$tdir/bad_striped_dir
15390 run_test 300p "create striped directory without space"
15393 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
15394 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
15396 local fd=$(free_fd)
15397 local cmd="exec $fd<$tdir"
15399 $LFS mkdir -c $MDSCOUNT $tdir || error "create $tdir fails"
15402 trap "eval $cmd" EXIT
15403 cd $tdir || error "cd $tdir fails"
15404 rmdir ../$tdir || error "rmdir $tdir fails"
15405 mkdir local_dir && error "create dir succeeds"
15406 $LFS setdirstripe -i1 remote_dir && error "create remote dir succeeds"
15410 run_test 300q "create remote directory under orphan directory"
15412 prepare_remote_file() {
15413 mkdir $DIR/$tdir/src_dir ||
15414 error "create remote source failed"
15416 cp /etc/hosts $DIR/$tdir/src_dir/a || error
15417 touch $DIR/$tdir/src_dir/a
15419 $LFS mkdir -i 1 $DIR/$tdir/tgt_dir ||
15420 error "create remote target dir failed"
15422 touch $DIR/$tdir/tgt_dir/b
15424 mrename $DIR/$tdir/src_dir/a $DIR/$tdir/tgt_dir/b ||
15425 error "rename dir cross MDT failed!"
15427 $CHECKSTAT -t file $DIR/$tdir/src_dir/a &&
15428 error "src_child still exists after rename"
15430 $CHECKSTAT -t file $DIR/$tdir/tgt_dir/b ||
15431 error "missing file(a) after rename"
15433 diff /etc/hosts $DIR/$tdir/tgt_dir/b ||
15434 error "diff after rename"
15438 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 4 MDTs" && return
15439 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
15440 local remote_file=$DIR/$tdir/tgt_dir/b
15442 mkdir -p $DIR/$tdir
15444 prepare_remote_file || error "prepare remote file failed"
15447 $OPENUNLINK $remote_file $remote_file || error
15448 $CHECKSTAT -a $remote_file || error
15450 run_test 310a "open unlink remote file"
15453 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 4 MDTs" && return
15454 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
15455 local remote_file=$DIR/$tdir/tgt_dir/b
15457 mkdir -p $DIR/$tdir
15459 prepare_remote_file || error "prepare remote file failed"
15461 ln $remote_file $DIR/$tfile || error "link failed for remote file"
15462 $MULTIOP $DIR/$tfile Ouc || error "mulitop failed"
15463 $CHECKSTAT -t file $remote_file || error "check file failed"
15465 run_test 310b "unlink remote file with multiple links while open"
15468 [[ $MDSCOUNT -lt 4 ]] && skip "needs >= 4 MDTs" && return
15469 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
15470 local remote_file=$DIR/$tdir/tgt_dir/b
15472 mkdir -p $DIR/$tdir
15474 prepare_remote_file || error "prepare remote file failed"
15476 ln $remote_file $DIR/$tfile || error "link failed for remote file"
15477 multiop_bg_pause $remote_file O_uc ||
15478 error "mulitop failed for remote file"
15480 $MULTIOP $DIR/$tfile Ouc
15481 kill -USR1 $MULTIPID
15484 run_test 310c "open-unlink remote file with multiple links"
15488 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.8.54) ] &&
15489 skip "lustre < 2.8.54 does not contain LU-4825 fix" && return
15490 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
15492 local old_iused=$($LFS df -i | grep OST0000 | awk '{ print $3 }')
15494 mkdir -p $DIR/$tdir
15495 $SETSTRIPE -i 0 -c 1 $DIR/$tdir
15496 createmany -o $DIR/$tdir/$tfile. 1000
15498 # statfs data is not real time, let's just calculate it
15499 old_iused=$((old_iused + 1000))
15501 local count=$(do_facet $SINGLEMDS "lctl get_param -n \
15502 osp.*OST0000*MDT0000.create_count")
15503 local max_count=$(do_facet $SINGLEMDS "lctl get_param -n \
15504 osp.*OST0000*MDT0000.max_create_count")
15505 for idx in $(seq $MDSCOUNT); do
15506 do_facet mds$idx "lctl set_param -n \
15507 osp.*OST0000*MDT000?.max_create_count=0"
15510 $SETSTRIPE -i 0 $DIR/$tdir/$tfile || error "setstripe failed"
15511 local index=$($GETSTRIPE -i $DIR/$tdir/$tfile)
15512 [ $index -ne 0 ] || error "$tfile stripe index is 0"
15514 unlinkmany $DIR/$tdir/$tfile. 1000
15516 for idx in $(seq $MDSCOUNT); do
15517 do_facet mds$idx "lctl set_param -n \
15518 osp.*OST0000*MDT000?.max_create_count=$max_count"
15519 do_facet mds$idx "lctl set_param -n \
15520 osp.*OST0000*MDT000?.create_count=$count"
15524 for i in $(seq 120); do
15525 new_iused=$($LFS df -i | grep OST0000 | awk '{ print $3 }')
15526 # system may be too busy to destroy all objs in time, use
15527 # a somewhat small value to not fail autotest
15528 [ $((old_iused - new_iused)) -gt 400 ] && break
15532 echo "waited $i sec, old Iused $old_iused, new Iused $new_iused"
15533 [ $((old_iused - new_iused)) -gt 400 ] ||
15534 error "objs not destroyed after unlink"
15536 run_test 311 "disable OSP precreate, and unlink should destroy objs"
15543 local vdevdir=$(dirname $(facet_vdevice $ost))
15544 local cmd="$ZDB -e -p $vdevdir -dddd $(facet_device $ost)"
15545 local zfs_zapid=$(do_facet $ost $cmd |
15546 grep -w "/O/0/d$((objid%32))" -C 5 |
15547 awk '/Object/{getline; print $1}')
15548 local zfs_objid=$(do_facet $ost $cmd $zfs_zapid |
15549 awk "/$objid = /"'{printf $3}')
15554 zfs_object_blksz() {
15558 local vdevdir=$(dirname $(facet_vdevice $ost))
15559 local cmd="$ZDB -e -p $vdevdir -dddd $(facet_device $ost)"
15560 local blksz=$(do_facet $ost $cmd $objid |
15561 awk '/dblk/{getline; printf $4}')
15563 case "${blksz: -1}" in
15564 k|K) blksz=$((${blksz:0:$((${#blksz} - 1))}*1024)) ;;
15565 m|M) blksz=$((${blksz:0:$((${#blksz} - 1))}*1024*1024)) ;;
15572 test_312() { # LU-4856
15573 [ $(facet_fstype ost1) = "zfs" ] ||
15574 { skip "the test only applies to zfs" && return; }
15576 local max_blksz=$(do_facet ost1 \
15577 $ZFS get -p recordsize $(facet_device ost1) |
15578 awk '!/VALUE/{print $3}')
15580 # to make life a little bit easier
15581 $LFS mkdir -c 1 -i 0 $DIR/$tdir
15582 $LFS setstripe -c 1 -i 0 $DIR/$tdir
15584 local tf=$DIR/$tdir/$tfile
15586 local oid=$($LFS getstripe $tf | awk '/obdidx/{getline; print $2}')
15588 # Get ZFS object id
15589 local zfs_objid=$(zfs_oid_to_objid ost1 $oid)
15591 # block size change by sequential over write
15593 for ((bs=4096; bs <= max_blksz; bs <<= 2)); do
15594 dd if=/dev/zero of=$tf bs=$bs count=1 oflag=sync conv=notrunc
15596 blksz=$(zfs_object_blksz ost1 $zfs_objid)
15597 [ $blksz -eq $bs ] || error "blksz error: $blksz, expected: $bs"
15601 # block size change by sequential append write
15602 dd if=/dev/zero of=$tf bs=4K count=1 oflag=sync conv=notrunc
15603 oid=$($LFS getstripe $tf | awk '/obdidx/{getline; print $2}')
15604 zfs_objid=$(zfs_oid_to_objid ost1 $oid)
15606 for ((count = 1; count < $((max_blksz / 4096)); count *= 2)); do
15607 dd if=/dev/zero of=$tf bs=4K count=$count seek=$count \
15608 oflag=sync conv=notrunc
15610 blksz=$(zfs_object_blksz ost1 $zfs_objid)
15611 blksz=$((blksz / 8192)) # in 2*4K unit
15612 [ $blksz -eq $count ] ||
15613 error "blksz error(in 8k): $blksz, expected: $count"
15619 oid=$($LFS getstripe $tf | awk '/obdidx/{getline; print $2}')
15620 zfs_objid=$(zfs_oid_to_objid ost1 $oid)
15622 dd if=/dev/zero of=$tf bs=8K count=1 oflag=sync conv=notrunc
15623 blksz=$(zfs_object_blksz ost1 $zfs_objid)
15624 [ $blksz -eq 8192 ] || error "blksz error: $blksz, expected: 8k"
15626 dd if=/dev/zero of=$tf bs=64K count=1 oflag=sync conv=notrunc seek=128
15627 blksz=$(zfs_object_blksz ost1 $zfs_objid)
15628 [ $blksz -eq 65536 ] || error "blksz error: $blksz, expected: 64k"
15630 dd if=/dev/zero of=$tf bs=1M count=1 oflag=sync conv=notrunc
15631 blksz=$(zfs_object_blksz ost1 $zfs_objid)
15632 [ $blksz -eq 65536 ] || error "rewrite error: $blksz, expected: 64k"
15634 run_test 312 "make sure ZFS adjusts its block size by write pattern"
15637 local file=$DIR/$tfile
15639 $SETSTRIPE -c 1 -i 0 $file || error "setstripe failed"
15641 # define OBD_FAIL_TGT_RCVD_EIO 0x720
15642 do_facet ost1 "$LCTL set_param fail_loc=0x720"
15643 dd if=/dev/zero of=$file bs=4096 oflag=direct count=1 &&
15644 error "write should failed"
15645 do_facet ost1 "$LCTL set_param fail_loc=0"
15648 run_test 313 "io should fail after last_rcvd update fail"
15651 local read_write=$1
15652 if [ "$read_write" = "write" ]; then
15653 local dd_cmd="dd if=/dev/zero of=$DIR/$tfile"
15654 elif [ "$read_write" = "read" ]; then
15655 local dd_cmd="dd of=/dev/null if=$DIR/$tfile"
15657 error "argument error"
15660 # turn off debug for performance testing
15661 local saved_debug=$($LCTL get_param -n debug)
15662 $LCTL set_param debug=0
15664 $SETSTRIPE -c 1 -i 0 $DIR/$tfile
15666 # get ost1 size - lustre-OST0000
15667 local ost1_avail_size=$($LFS df | awk /${ost1_svc}/'{ print $4 }')
15668 local blocks=$((ost1_avail_size/2/1024)) # half avail space by megabytes
15669 [ $blocks -gt 1000 ] && blocks=1000 # 1G in maximum
15671 if [ "$read_write" = "read" ]; then
15672 truncate -s $(expr 1048576 \* $blocks) $DIR/$tfile
15675 local start_time=$(date +%s.%N)
15676 $dd_cmd bs=1M count=$blocks oflag=sync ||
15677 error "real dd $read_write error"
15678 local duration=$(bc <<< "$(date +%s.%N) - $start_time")
15680 if [ "$read_write" = "write" ]; then
15684 # define OBD_FAIL_OST_FAKE_RW 0x238
15685 do_facet ost1 $LCTL set_param fail_loc=0x238
15687 local start_time=$(date +%s.%N)
15688 $dd_cmd bs=1M count=$blocks oflag=sync ||
15689 error "fake dd $read_write error"
15690 local duration_fake=$(bc <<< "$(date +%s.%N) - $start_time")
15692 if [ "$read_write" = "write" ]; then
15694 cancel_lru_locks osc
15695 $CHECKSTAT -t file -s $((blocks * 1024 * 1024)) $DIR/$tfile ||
15696 error "$tfile size not $blocks MB"
15698 do_facet ost1 $LCTL set_param fail_loc=0
15700 echo "fake $read_write $duration_fake vs. normal $read_write" \
15701 "$duration in seconds"
15702 [ $(bc <<< "$duration_fake < $duration") -eq 1 ] ||
15703 error_not_in_vm "fake write is slower"
15705 $LCTL set_param -n debug="$saved_debug"
15708 test_399a() { # LU-7655 for OST fake write
15711 run_test 399a "fake write should not be slower than normal write"
15714 test_399b() { # LU-8726 for OST fake read
15715 if [ "$(facet_fstype ost1)" != "ldiskfs" ]; then
15716 skip "only for ldiskfs" && return 0
15720 run_test 399b "fake read should not be slower than normal read"
15722 test_400a() { # LU-1606, was conf-sanity test_74
15723 local extra_flags=''
15724 local out=$TMP/$tfile
15725 local prefix=/usr/include/lustre
15728 if ! which $CC > /dev/null 2>&1; then
15729 skip_env "$CC is not installed"
15733 if ! [[ -d $prefix ]]; then
15734 # Assume we're running in tree and fixup the include path.
15735 extra_flags+=" -I$LUSTRE/../libcfs/include"
15736 extra_flags+=" -I$LUSTRE/include"
15737 extra_flags+=" -L$LUSTRE/utils"
15740 for prog in $LUSTRE_TESTS_API_DIR/*.c; do
15741 $CC -Wall -Werror $extra_flags -llustreapi -o $out $prog ||
15742 error "client api broken"
15746 run_test 400a "Lustre client api program can compile and link"
15748 test_400b() { # LU-1606, LU-5011
15750 local out=$TMP/$tfile
15751 local prefix=/usr/include/lustre
15753 # We use a hard coded prefix so that this test will not fail
15754 # when run in tree. There are headers in lustre/include/lustre/
15755 # that are not packaged (like lustre_idl.h) and have more
15756 # complicated include dependencies (like config.h and lnet/types.h).
15757 # Since this test about correct packaging we just skip them when
15758 # they don't exist (see below) rather than try to fixup cppflags.
15760 if ! which $CC > /dev/null 2>&1; then
15761 skip_env "$CC is not installed"
15765 for header in $prefix/*.h; do
15766 if ! [[ -f "$header" ]]; then
15770 if [[ "$(basename $header)" == liblustreapi.h ]]; then
15771 continue # liblustreapi.h is deprecated.
15774 $CC -Wall -Werror -include $header -c -x c /dev/null -o $out ||
15775 error "cannot compile '$header'"
15779 run_test 400b "packaged headers can be compiled"
15781 test_401a() { #LU-7437
15782 local printf_arg=$(find -printf 2>&1 | grep "unrecognized:")
15783 [ -n "$printf_arg" ] && skip_env "find does not support -printf" &&
15785 #count the number of parameters by "list_param -R"
15786 local params=$($LCTL list_param -R '*' 2>/dev/null | wc -l)
15787 #count the number of parameters by listing proc files
15788 local proc_dirs=$(eval \ls -d $proc_regexp 2>/dev/null)
15789 echo "proc_dirs='$proc_dirs'"
15790 [ -n "$proc_dirs" ] || error "no proc_dirs on $HOSTNAME"
15791 local procs=$(find -L $proc_dirs -mindepth 1 -printf '%P\n' 2>/dev/null|
15794 [ $params -eq $procs ] ||
15795 error "found $params parameters vs. $procs proc files"
15797 # test the list_param -D option only returns directories
15798 params=$($LCTL list_param -R -D '*' 2>/dev/null | wc -l)
15799 #count the number of parameters by listing proc directories
15800 procs=$(find -L $proc_dirs -mindepth 1 -type d -printf '%P\n' 2>/dev/null |
15803 [ $params -eq $procs ] ||
15804 error "found $params parameters vs. $procs proc files"
15806 run_test 401a "Verify if 'lctl list_param -R' can list parameters recursively"
15809 local save=$($LCTL get_param -n jobid_var)
15812 $LCTL set_param foo=bar jobid_var=$tmp bar=baz &&
15813 error "no error returned when setting bad parameters"
15815 local jobid_new=$($LCTL get_param -n foe jobid_var baz)
15816 [[ "$jobid_new" == "$tmp" ]] || error "jobid tmp $jobid_new != $tmp"
15818 $LCTL set_param -n fog=bam jobid_var=$save bat=fog
15819 local jobid_old=$($LCTL get_param -n foe jobid_var bag)
15820 [[ "$jobid_old" == "$save" ]] || error "jobid new $jobid_old != $save"
15822 run_test 401b "Verify 'lctl {get,set}_param' continue after error"
15825 local jobid_var_old=$($LCTL get_param -n jobid_var)
15826 local jobid_var_new
15828 $LCTL set_param jobid_var= &&
15829 error "no error returned for 'set_param a='"
15831 jobid_var_new=$($LCTL get_param -n jobid_var)
15832 [[ "$jobid_var_old" == "$jobid_var_new" ]] ||
15833 error "jobid_var was changed by setting without value"
15835 $LCTL set_param jobid_var &&
15836 error "no error returned for 'set_param a'"
15838 jobid_var_new=$($LCTL get_param -n jobid_var)
15839 [[ "$jobid_var_old" == "$jobid_var_new" ]] ||
15840 error "jobid_var was changed by setting without value"
15842 run_test 401c "Verify 'lctl set_param' without value fails in either format."
15845 local jobid_var_old=$($LCTL get_param -n jobid_var)
15846 local jobid_var_new
15847 local new_value="foo=bar"
15849 $LCTL set_param jobid_var=$new_value ||
15850 error "'set_param a=b' did not accept a value containing '='"
15852 jobid_var_new=$($LCTL get_param -n jobid_var)
15853 [[ "$jobid_var_new" == "$new_value" ]] ||
15854 error "'set_param a=b' failed on a value containing '='"
15856 # Reset the jobid_var to test the other format
15857 $LCTL set_param jobid_var=$jobid_var_old
15858 jobid_var_new=$($LCTL get_param -n jobid_var)
15859 [[ "$jobid_var_new" == "$jobid_var_old" ]] ||
15860 error "failed to reset jobid_var"
15862 $LCTL set_param jobid_var $new_value ||
15863 error "'set_param a b' did not accept a value containing '='"
15865 jobid_var_new=$($LCTL get_param -n jobid_var)
15866 [[ "$jobid_var_new" == "$new_value" ]] ||
15867 error "'set_param a b' failed on a value containing '='"
15869 $LCTL set_param jobid_var $jobid_var_old
15870 jobid_var_new=$($LCTL get_param -n jobid_var)
15871 [[ "$jobid_var_new" == "$jobid_var_old" ]] ||
15872 error "failed to reset jobid_var"
15874 run_test 401d "Verify 'lctl set_param' accepts values containing '='"
15877 local server_version=$(lustre_version_code $SINGLEMDS)
15878 [[ $server_version -ge $(version_code 2.7.66) ]] ||
15879 [[ $server_version -ge $(version_code 2.7.18.4) &&
15880 $server_version -lt $(version_code 2.7.50) ]] ||
15881 [[ $server_version -ge $(version_code 2.7.2) &&
15882 $server_version -lt $(version_code 2.7.11) ]] ||
15883 { skip "Need MDS version 2.7.2+ or 2.7.18.4+ or 2.7.66+";
15885 remote_mds_nodsh && skip "remote MDS with nodsh" && return
15886 $LFS setdirstripe -i 0 $DIR/$tdir || error "setdirstripe -i 0 failed"
15887 #define OBD_FAIL_MDS_FLD_LOOKUP 0x15c
15888 do_facet mds1 "lctl set_param fail_loc=0x8000015c"
15889 touch $DIR/$tdir/$tfile && error "touch should fail with ENOENT" ||
15890 echo "Touch failed - OK"
15892 run_test 402 "Return ENOENT to lod_generate_and_set_lovea"
15895 local file1=$DIR/$tfile.1
15896 local file2=$DIR/$tfile.2
15897 local tfile=$TMP/$tfile
15899 rm -f $file1 $file2 $tfile
15904 # 30 sec OBD_TIMEOUT in ll_getattr()
15905 # right before populating st_nlink
15906 $LCTL set_param fail_loc=0x80001409
15907 stat -c %h $file1 > $tfile &
15909 # create an alias, drop all locks and reclaim the dentry
15911 cancel_lru_locks mdc
15912 cancel_lru_locks osc
15913 sysctl -w vm.drop_caches=2
15917 [ `cat $tfile` -gt 0 ] || error "wrong nlink count: `cat $tfile`"
15919 rm -f $tfile $file1 $file2
15921 run_test 403 "i_nlink should not drop to zero due to aliasing"
15923 test_404() { # LU-6601
15924 remote_mds_nodsh && skip "remote MDS with nodsh" && return
15925 local mosps=$(do_facet $SINGLEMDS $LCTL dl |
15926 awk '/osp .*-osc-MDT/ { print $4}')
15929 for osp in $mosps; do
15930 echo "Deactivate: " $osp
15931 do_facet $SINGLEMDS $LCTL --device %$osp deactivate
15932 local stat=$(do_facet $SINGLEMDS $LCTL dl |
15933 awk -vp=$osp '$4 == p { print $2 }')
15934 [ $stat = IN ] || {
15935 do_facet $SINGLEMDS $LCTL dl | grep -w $osp
15936 error "deactivate error"
15938 echo "Activate: " $osp
15939 do_facet $SINGLEMDS $LCTL --device %$osp activate
15940 local stat=$(do_facet $SINGLEMDS $LCTL dl |
15941 awk -vp=$osp '$4 == p { print $2 }')
15942 [ $stat = UP ] || {
15943 do_facet $SINGLEMDS $LCTL dl | grep -w $osp
15944 error "activate error"
15948 run_test 404 "validate manual {de}activated works properly for OSPs"
15951 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.6.92) ] &&
15952 skip "Layout swap lock is not supported" && return
15954 check_swap_layouts_support && return 0
15956 test_mkdir -p $DIR/$tdir
15957 swap_lock_test -d $DIR/$tdir ||
15958 error "One layout swap locked test failed"
15960 run_test 405 "Various layout swap lock tests"
15963 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
15964 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs" && return
15965 [ -n "$FILESET" ] && skip "SKIP due to FILESET set" && return
15966 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
15967 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.8.50) ] &&
15968 skip "Need MDS version at least 2.8.50" && return
15970 local def_stripenr=$($GETSTRIPE -c $MOUNT)
15971 local def_stripe_size=$($GETSTRIPE -S $MOUNT)
15972 local def_stripe_offset=$($GETSTRIPE -i $MOUNT)
15973 local def_pool=$($GETSTRIPE -p $MOUNT)
15975 local test_pool=$TESTNAME
15976 pool_add $test_pool || error "pool_add failed"
15977 pool_add_targets $test_pool 0 $(($OSTCOUNT - 1)) 1 ||
15978 error "pool_add_targets failed"
15980 # parent set default stripe count only, child will stripe from both
15981 # parent and fs default
15982 $SETSTRIPE -c 1 -i 1 -S $((def_stripe_size * 2)) -p $test_pool $MOUNT ||
15983 error "setstripe $MOUNT failed"
15984 $LFS mkdir -c $MDSCOUNT $DIR/$tdir || error "mkdir $tdir failed"
15985 $SETSTRIPE -c $OSTCOUNT $DIR/$tdir || error "setstripe $tdir failed"
15986 for i in $(seq 10); do
15987 local f=$DIR/$tdir/$tfile.$i
15988 touch $f || error "touch failed"
15989 local count=$($GETSTRIPE -c $f)
15990 [ $count -eq $OSTCOUNT ] ||
15991 error "$f stripe count $count != $OSTCOUNT"
15992 local offset=$($GETSTRIPE -i $f)
15993 [ $offset -eq 1 ] || error "$f stripe offset $offset != 1"
15994 local size=$($GETSTRIPE -S $f)
15995 [ $size -eq $((def_stripe_size * 2)) ] ||
15996 error "$f stripe size $size != $((def_stripe_size * 2))"
15997 local pool=$($GETSTRIPE -p $f)
15998 [ $pool == $test_pool ] || error "$f pool $pool != $test_pool"
16001 # change fs default striping, delete parent default striping, now child
16002 # will stripe from new fs default striping only
16003 $SETSTRIPE -c 1 -S $def_stripe_size -i 0 $MOUNT ||
16004 error "change $MOUNT default stripe failed"
16005 $SETSTRIPE -c 0 $DIR/$tdir || error "delete $tdir default stripe failed"
16006 for i in $(seq 11 20); do
16007 local f=$DIR/$tdir/$tfile.$i
16008 touch $f || error "touch $f failed"
16009 local count=$($GETSTRIPE -c $f)
16010 [ $count -eq 1 ] || error "$f stripe count $count != 1"
16011 local offset=$($GETSTRIPE -i $f)
16012 [ $offset -eq 0 ] || error "$f stripe offset $offset != 0"
16013 local size=$($GETSTRIPE -S $f)
16014 [ $size -eq $def_stripe_size ] ||
16015 error "$f stripe size $size != $def_stripe_size"
16016 local pool=$($GETSTRIPE -p $f)
16017 [ "#$pool" == "#" ] || error "$f pool $pool is set"
16021 unlinkmany $DIR/$tdir/$tfile. 1 20
16023 # restore FS default striping
16024 if [ -z $def_pool ]; then
16025 $SETSTRIPE -c $def_stripenr -S $def_stripe_size \
16026 -i $def_stripe_offset $MOUNT ||
16027 error "restore default striping failed"
16029 $SETSTRIPE -c $def_stripenr -S $def_stripe_size -p $def_pool \
16030 -i $def_stripe_offset $MOUNT ||
16031 error "restore default striping with $def_pool failed"
16034 local f=$DIR/$tdir/$tfile
16035 pool_remove_all_targets $test_pool $f
16036 pool_remove $test_pool $f
16038 run_test 406 "DNE support fs default striping"
16041 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
16043 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.8.55) ]] &&
16044 skip "Need MDS version at least 2.8.55" && return
16046 $LFS mkdir -i 0 -c 1 $DIR/$tdir.0 ||
16047 error "$LFS mkdir -i 0 -c 1 $tdir.0 failed"
16048 $LFS mkdir -i 1 -c 1 $DIR/$tdir.1 ||
16049 error "$LFS mkdir -i 1 -c 1 $tdir.1 failed"
16050 touch $DIR/$tdir.0/$tfile.0 || error "touch $tdir.0/$tfile.0 failed"
16052 #define OBD_FAIL_DT_TXN_STOP 0x2019
16053 for idx in $(seq $MDSCOUNT); do
16054 do_facet mds$idx "lctl set_param fail_loc=0x2019"
16056 $LFS mkdir -c 2 $DIR/$tdir && error "$LFS mkdir -c 2 $tdir should fail"
16057 mv $DIR/$tdir.0/$tfile.0 $DIR/$tdir.1/$tfile.1 &&
16058 error "mv $tdir.0/$tfile.0 $tdir.1/$tfile.1 should fail"
16061 run_test 407 "transaction fail should cause operation fail"
16064 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 oflag=direct
16066 #define OBD_FAIL_OSC_BRW_PREP_REQ2 0x40a
16067 lctl set_param fail_loc=0x8000040a
16068 # let ll_prepare_partial_page() fail
16069 dd if=/dev/zero of=$DIR/$tfile bs=2048 count=1 conv=notrunc || true
16073 # create at least 100 unused inodes so that
16074 # shrink_icache_memory(0) should not return 0
16075 touch $DIR/$tfile-{0..100}
16076 rm -f $DIR/$tfile-{0..100}
16079 echo 2 > /proc/sys/vm/drop_caches
16081 run_test 408 "drop_caches should not hang due to page leaks"
16085 [ $MDSCOUNT -lt 2 ] &&
16086 skip "We need at least 2 MDTs for this test" && return
16088 check_mount_and_prep
16090 mkdir -p $DIR/$tdir || error "(0) Fail to mkdir"
16091 $LFS mkdir -i 1 -c 2 $DIR/$tdir/foo || error "(1) Fail to mkdir"
16092 touch $DIR/$tdir/guard || error "(2) Fail to create"
16094 local PREFIX=$(str_repeat 'A' 128)
16095 echo "Create 1K hard links start at $(date)"
16096 createmany -l $DIR/$tdir/guard $DIR/$tdir/foo/${PREFIX}_ 1000 ||
16097 error "(3) Fail to hard link"
16099 echo "Links count should be right although linkEA overflow"
16100 stat $DIR/$tdir/guard || error "(4) Fail to stat"
16101 local linkcount=$(stat --format=%h $DIR/$tdir/guard)
16102 [ $linkcount -eq 1001 ] ||
16103 error "(5) Unexpected hard links count: $linkcount"
16105 echo "List all links start at $(date)"
16106 ls -l $DIR/$tdir/foo > /dev/null ||
16107 error "(6) Fail to list $DIR/$tdir/foo"
16109 echo "Unlink hard links start at $(date)"
16110 unlinkmany $DIR/$tdir/foo/${PREFIX}_ 1000 ||
16111 error "(7) Fail to unlink"
16113 run_test 409 "Large amount of cross-MDTs hard links on the same file"
16116 start_full_debug_logging
16117 # cleanup unused barrier locks before test
16118 do_facet mgs $LCTL barrier_rescan $FSNAME ||
16119 error "Fail to prep barrier test env"
16123 stop_full_debug_logging
16129 #define OBD_FAIL_BARRIER_DELAY 0x2202
16130 do_facet mgs $LCTL set_param fail_val=3 fail_loc=0x2202
16131 do_facet mgs $LCTL barrier_freeze $FSNAME 10 &
16134 local b_status=$(do_facet mgs $LCTL barrier_stat $FSNAME |
16135 awk '/The barrier for/ { print $7 }')
16136 [ "$b_status" = "'freezing_p1'" ] ||
16137 error "(1) unexpected barrier status $b_status"
16139 do_facet mgs $LCTL set_param fail_val=0 fail_loc=0
16141 b_status=$(do_facet mgs $LCTL barrier_stat $FSNAME |
16142 awk '/The barrier for/ { print $7 }')
16143 [ "$b_status" = "'frozen'" ] ||
16144 error "(2) unexpected barrier status $b_status"
16146 local expired=$(do_facet mgs $LCTL barrier_stat $FSNAME |
16147 awk '/will be expired/ { print $7 }')
16148 echo "sleep $((expired + 3)) seconds, then the barrier will be expired"
16149 sleep $((expired + 3))
16151 b_status=$(do_facet mgs $LCTL barrier_stat $FSNAME |
16152 awk '/The barrier for/ { print $7 }')
16153 [ "$b_status" = "'expired'" ] ||
16154 error "(3) unexpected barrier status $b_status"
16156 do_facet mgs $LCTL barrier_freeze $FSNAME 10 ||
16157 error "(4) fail to freeze barrier"
16159 b_status=$(do_facet mgs $LCTL barrier_stat $FSNAME |
16160 awk '/The barrier for/ { print $7 }')
16161 [ "$b_status" = "'frozen'" ] ||
16162 error "(5) unexpected barrier status $b_status"
16164 #define OBD_FAIL_BARRIER_DELAY 0x2202
16165 do_facet mgs $LCTL set_param fail_val=3 fail_loc=0x2202
16166 do_facet mgs $LCTL barrier_thaw $FSNAME &
16169 b_status=$(do_facet mgs $LCTL barrier_stat $FSNAME |
16170 awk '/The barrier for/ { print $7 }')
16171 [ "$b_status" = "'thawing'" ] ||
16172 error "(6) unexpected barrier status $b_status"
16174 do_facet mgs $LCTL set_param fail_val=0 fail_loc=0
16176 b_status=$(do_facet mgs $LCTL barrier_stat $FSNAME |
16177 awk '/The barrier for/ { print $7 }')
16178 [ "$b_status" = "'thawed'" ] ||
16179 error "(7) unexpected barrier status $b_status"
16181 #define OBD_FAIL_BARRIER_FAILURE 0x2203
16182 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x2203
16183 do_facet mgs $LCTL barrier_freeze $FSNAME
16185 b_status=$(do_facet mgs $LCTL barrier_stat $FSNAME |
16186 awk '/The barrier for/ { print $7 }')
16187 [ "$b_status" = "'failed'" ] ||
16188 error "(8) unexpected barrier status $b_status"
16190 do_facet $SINGLEMDS $LCTL set_param fail_loc=0
16191 do_facet mgs $LCTL barrier_thaw $FSNAME
16195 run_test 801a "write barrier user interfaces and stat machine"
16200 mkdir $DIR/$tdir || error "(1) fail to mkdir"
16201 createmany -d $DIR/$tdir/d 6 || "(2) fail to mkdir"
16202 touch $DIR/$tdir/d2/f10 || error "(3) fail to touch"
16203 touch $DIR/$tdir/d3/f11 || error "(4) fail to touch"
16204 touch $DIR/$tdir/d4/f12 || error "(5) fail to touch"
16206 cancel_lru_locks mdc
16208 # 180 seconds should be long enough
16209 do_facet mgs $LCTL barrier_freeze $FSNAME 180
16211 local b_status=$(do_facet mgs $LCTL barrier_stat $FSNAME |
16212 awk '/The barrier for/ { print $7 }')
16213 [ "$b_status" = "'frozen'" ] ||
16214 error "(6) unexpected barrier status $b_status"
16216 mkdir $DIR/$tdir/d0/d10 &
16219 touch $DIR/$tdir/d1/f13 &
16222 ln $DIR/$tdir/d2/f10 $DIR/$tdir/d2/f14 &
16225 mv $DIR/$tdir/d3/f11 $DIR/$tdir/d3/f15 &
16228 rm -f $DIR/$tdir/d4/f12 &
16231 stat $DIR/$tdir/d5 || error "(7) stat should succeed"
16233 # To guarantee taht the 'stat' is not blocked
16234 b_status=$(do_facet mgs $LCTL barrier_stat $FSNAME |
16235 awk '/The barrier for/ { print $7 }')
16236 [ "$b_status" = "'frozen'" ] ||
16237 error "(8) unexpected barrier status $b_status"
16239 # let above commands to run at background
16242 ps -p $mkdir_pid || error "(9) mkdir should be blocked"
16243 ps -p $touch_pid || error "(10) touch should be blocked"
16244 ps -p $ln_pid || error "(11) link should be blocked"
16245 ps -p $mv_pid || error "(12) rename should be blocked"
16246 ps -p $rm_pid || error "(13) unlink should be blocked"
16248 b_status=$(do_facet mgs $LCTL barrier_stat $FSNAME |
16249 awk '/The barrier for/ { print $7 }')
16250 [ "$b_status" = "'frozen'" ] ||
16251 error "(14) unexpected barrier status $b_status"
16253 do_facet mgs $LCTL barrier_thaw $FSNAME
16254 b_status=$(do_facet mgs $LCTL barrier_stat $FSNAME |
16255 awk '/The barrier for/ { print $7 }')
16256 [ "$b_status" = "'thawed'" ] ||
16257 error "(15) unexpected barrier status $b_status"
16259 wait $mkdir_pid || error "(16) mkdir should succeed"
16260 wait $touch_pid || error "(17) touch should succeed"
16261 wait $ln_pid || error "(18) link should succeed"
16262 wait $mv_pid || error "(19) rename should succeed"
16263 wait $rm_pid || error "(20) unlink should succeed"
16267 run_test 801b "modification will be blocked by write barrier"
16270 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 2 MDTs" && return
16274 stop mds2 || error "(1) Fail to stop mds2"
16276 do_facet mgs $LCTL barrier_freeze $FSNAME 30
16278 local b_status=$(do_facet mgs $LCTL barrier_stat $FSNAME |
16279 awk '/The barrier for/ { print $7 }')
16280 [ "$b_status" = "'expired'" -o "$b_status" = "'failed'" ] || {
16281 do_facet mgs $LCTL barrier_thaw $FSNAME
16282 error "(2) unexpected barrier status $b_status"
16285 do_facet mgs $LCTL barrier_rescan $FSNAME ||
16286 error "(3) Fail to rescan barrier bitmap"
16288 do_facet mgs $LCTL barrier_freeze $FSNAME 10
16290 b_status=$(do_facet mgs $LCTL barrier_stat $FSNAME |
16291 awk '/The barrier for/ { print $7 }')
16292 [ "$b_status" = "'frozen'" ] ||
16293 error "(4) unexpected barrier status $b_status"
16295 do_facet mgs $LCTL barrier_thaw $FSNAME
16296 b_status=$(do_facet mgs $LCTL barrier_stat $FSNAME |
16297 awk '/The barrier for/ { print $7 }')
16298 [ "$b_status" = "'thawed'" ] ||
16299 error "(5) unexpected barrier status $b_status"
16301 local devname=$(mdsdevname 2)
16303 start mds2 $devname $MDS_MOUNT_OPTS || error "(6) Fail to start mds2"
16305 do_facet mgs $LCTL barrier_rescan $FSNAME ||
16306 error "(7) Fail to rescan barrier bitmap"
16310 run_test 801c "rescan barrier bitmap"
16312 saved_MGS_MOUNT_OPTS=$MGS_MOUNT_OPTS
16313 saved_MDS_MOUNT_OPTS=$MDS_MOUNT_OPTS
16314 saved_OST_MOUNT_OPTS=$OST_MOUNT_OPTS
16320 MGS_MOUNT_OPTS=$saved_MGS_MOUNT_OPTS
16321 MDS_MOUNT_OPTS=$saved_MDS_MOUNT_OPTS
16322 OST_MOUNT_OPTS=$saved_OST_MOUNT_OPTS
16327 mkdir $DIR/$tdir || error "(1) fail to mkdir"
16329 cp $LUSTRE/tests/test-framework.sh $DIR/$tdir/ ||
16330 error "(2) Fail to copy"
16332 trap cleanup_802 EXIT
16334 # sync by force before remount as readonly
16335 sync; sync_all_data; sleep 3; sync_all_data
16339 MGS_MOUNT_OPTS=$(csa_add "$MGS_MOUNT_OPTS" -o rdonly_dev)
16340 MDS_MOUNT_OPTS=$(csa_add "$MDS_MOUNT_OPTS" -o rdonly_dev)
16341 OST_MOUNT_OPTS=$(csa_add "$OST_MOUNT_OPTS" -o rdonly_dev)
16343 echo "Mount the server as read only"
16344 setupall server_only || error "(3) Fail to start servers"
16346 echo "Mount client without ro should fail"
16347 mount_client $MOUNT &&
16348 error "(4) Mount client without 'ro' should fail"
16350 echo "Mount client with ro should succeed"
16351 mount_client $MOUNT ro ||
16352 error "(5) Mount client with 'ro' should succeed"
16354 echo "Modify should be refused"
16355 touch $DIR/$tdir/guard && error "(6) Touch should fail under ro mode"
16357 echo "Read should be allowed"
16358 diff $LUSTRE/tests/test-framework.sh $DIR/$tdir/test-framework.sh ||
16359 error "(7) Read should succeed under ro mode"
16363 run_test 802 "simulate readonly device"
16366 # tests that do cleanup/setup should be run at the end
16370 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
16372 #define OBD_FAIL_MGC_PAUSE_PROCESS_LOG 0x903
16373 $LCTL set_param fail_loc=0x903
16375 cancel_lru_locks MGC
16377 FAIL_ON_ERROR=true cleanup
16378 FAIL_ON_ERROR=true setup
16380 run_test 900 "umount should not race with any mgc requeue thread"
16383 [ -f $EXT2_DEV ] && rm $EXT2_DEV || true
16384 check_and_cleanup_lustre
16385 if [ "$I_MOUNTED" != "yes" ]; then
16386 lctl set_param debug="$OLDDEBUG" 2> /dev/null || true