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: LU-9693 LU-6493 LU-9693 3561 5188
12 ALWAYS_EXCEPT=" 42a 42b 42c 45 68b $SANITY_EXCEPT"
13 # UPDATE THE COMMENT ABOVE WITH BUG NUMBERS WHEN CHANGING ALWAYS_EXCEPT!
15 # skipped tests: LU-8411 LU-9096 LU-9054
16 ALWAYS_EXCEPT=" 407 253 312 $ALWAYS_EXCEPT"
18 # Check Grants after these tests
19 GRANT_CHECK_LIST="$GRANT_CHECK_LIST 42a 42b 42c 42d 42e 63a 63b 64a 64b 64c"
23 if [ -r /etc/SuSE-release ]
25 local vers=$(grep VERSION /etc/SuSE-release | awk '{print $3}')
26 local patchlev=$(grep PATCHLEVEL /etc/SuSE-release |
28 if [ $vers -eq 11 ] && [ $patchlev -ge 3 ]; then
35 if is_sles11; then # LU-4341
36 ALWAYS_EXCEPT="$ALWAYS_EXCEPT 170"
39 SRCDIR=$(cd $(dirname $0); echo $PWD)
40 export PATH=$PATH:/sbin
45 CHECKSTAT=${CHECKSTAT:-"checkstat -v"}
46 CREATETEST=${CREATETEST:-createtest}
48 LFIND=${LFIND:-"$LFS find"}
49 LVERIFY=${LVERIFY:-ll_dirstripe_verify}
51 OPENFILE=${OPENFILE:-openfile}
52 OPENUNLINK=${OPENUNLINK:-openunlink}
53 export MULTIOP=${MULTIOP:-multiop}
54 READS=${READS:-"reads"}
55 MUNLINK=${MUNLINK:-munlink}
56 SOCKETSERVER=${SOCKETSERVER:-socketserver}
57 SOCKETCLIENT=${SOCKETCLIENT:-socketclient}
58 MEMHOG=${MEMHOG:-memhog}
59 DIRECTIO=${DIRECTIO:-directio}
60 ACCEPTOR_PORT=${ACCEPTOR_PORT:-988}
62 CHECK_GRANT=${CHECK_GRANT:-"yes"}
63 GRANT_CHECK_LIST=${GRANT_CHECK_LIST:-""}
64 export PARALLEL=${PARALLEL:-"no"}
66 export NAME=${NAME:-local}
73 LUSTRE=${LUSTRE:-$(cd $(dirname $0)/..; echo $PWD)}
74 LUSTRE_TESTS_API_DIR=${LUSTRE_TESTS_API_DIR:-${LUSTRE}/tests/clientapi}
75 . $LUSTRE/tests/test-framework.sh
77 . ${CONFIG:=$LUSTRE/tests/cfg/${NAME}.sh}
81 [ "$SLOW" = "no" ] && EXCEPT_SLOW="27m 64b 68 71 115 300o"
83 if [ $(facet_fstype $SINGLEMDS) = "zfs" ]; then
84 # bug number for skipped test: LU-4536 LU-1957
85 ALWAYS_EXCEPT="$ALWAYS_EXCEPT 65ic 180"
87 [ "$SLOW" = "no" ] && EXCEPT_SLOW="$EXCEPT_SLOW 51b"
94 pgrep ll_sa > /dev/null && { echo "There are ll_sa thread not exit!"; exit 20; }
95 cleanupall ${FORCE} $* || { echo "FAILed to clean up"; exit 20; }
104 check_swap_layouts_support()
106 $LCTL get_param -n llite.*.sbi_flags | grep -q layout ||
107 { skip "Does not support layout lock."; return 0; }
111 check_and_setup_lustre
115 MDT0=$($LCTL get_param -n mdc.*.mds_server_uuid |
116 awk '{ gsub(/_UUID/,""); print $1 }' | head -n1)
117 MAXFREE=${MAXFREE:-$((200000 * $OSTCOUNT))}
119 [ -f $DIR/d52a/foo ] && chattr -a $DIR/d52a/foo
120 [ -f $DIR/d52b/foo ] && chattr -i $DIR/d52b/foo
121 rm -rf $DIR/[Rdfs][0-9]*
123 # $RUNAS_ID may get set incorrectly somewhere else
124 [ $UID -eq 0 -a $RUNAS_ID -eq 0 ] && error "\$RUNAS_ID set to 0, but \$UID is also 0!"
126 check_runas_id $RUNAS_ID $RUNAS_GID $RUNAS
130 if [ "${ONLY}" = "MOUNT" ] ; then
131 echo "Lustre is up, please go on"
135 echo "preparing for tests involving mounts"
136 EXT2_DEV=${EXT2_DEV:-$TMP/SANITY.LOOP}
138 mke2fs -j -F $EXT2_DEV 8000 > /dev/null
139 echo # add a newline after mke2fs.
143 OLDDEBUG=$(lctl get_param -n debug 2> /dev/null)
144 lctl set_param debug=-1 2> /dev/null || true
147 $CHECKSTAT -t file $DIR/$tfile || error "$tfile is not a file"
149 $CHECKSTAT -a $DIR/$tfile || error "$tfile was not removed"
151 run_test 0a "touch; rm ====================="
154 chmod 0755 $DIR || error "chmod 0755 $DIR failed"
155 $CHECKSTAT -p 0755 $DIR || error "$DIR permission is not 0755"
157 run_test 0b "chmod 0755 $DIR ============================="
160 $LCTL get_param mdc.*.import | grep "state: FULL" ||
161 error "import not FULL"
162 $LCTL get_param mdc.*.import | grep "target: $FSNAME-MDT" ||
165 run_test 0c "check import proc ============================="
168 test_mkdir -p $DIR/$tdir || error "mkdir $tdir failed"
169 test_mkdir -p $DIR/$tdir/d2 || error "mkdir $tdir/d2 failed"
170 test_mkdir $DIR/$tdir/d2 && error "we expect EEXIST, but not returned"
171 $CHECKSTAT -t dir $DIR/$tdir/d2 || error "$tdir/d2 is not a dir"
174 $CHECKSTAT -a $DIR/$tdir || error "$tdir was not removed"
176 run_test 1 "mkdir; remkdir; rmdir =============================="
179 test_mkdir -p $DIR/$tdir || error "mkdir $tdir failed"
180 touch $DIR/$tdir/$tfile || error "touch $tdir/$tfile failed"
181 $CHECKSTAT -t file $DIR/$tdir/$tfile || error "$tdir/$tfile not a file"
183 $CHECKSTAT -a $DIR/$tdir/$tfile || error "$tdir/$file is not removed"
185 run_test 2 "mkdir; touch; rmdir; check file ===================="
188 test_mkdir -p $DIR/$tdir || error "mkdir $tdir failed"
189 $CHECKSTAT -t dir $DIR/$tdir || error "$tdir is not a directory"
190 touch $DIR/$tdir/$tfile
191 $CHECKSTAT -t file $DIR/$tdir/$tfile || error "$tdir/$tfile not a file"
193 $CHECKSTAT -a $DIR/$tdir || error "$tdir is not removed"
195 run_test 3 "mkdir; touch; rmdir; check dir ====================="
197 # LU-4471 - failed rmdir on remote directories still removes directory on MDT0
201 test_mkdir $DIR/$tdir ||
202 error "Create remote directory failed"
204 touch $DIR/$tdir/$tfile ||
205 error "Create file under remote directory failed"
208 error "Expect error removing in-use dir $DIR/$tdir"
210 test -d $DIR/$tdir || error "Remote directory disappeared"
212 rm -rf $DIR/$tdir || error "remove remote dir error"
214 run_test 4 "mkdir; touch dir/file; rmdir; checkdir (expect error)"
217 test_mkdir -p $DIR/$tdir || error "mkdir $tdir failed"
218 test_mkdir $DIR/$tdir/d2 || error "mkdir $tdir/d2 failed"
219 chmod 0707 $DIR/$tdir/d2 || error "chmod 0707 $tdir/d2 failed"
220 $CHECKSTAT -t dir -p 0707 $DIR/$tdir/d2 || error "$tdir/d2 not mode 707"
221 $CHECKSTAT -t dir $DIR/$tdir/d2 || error "$tdir/d2 is not a directory"
223 run_test 5 "mkdir .../d5 .../d5/d2; chmod .../d5/d2 ============"
226 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
227 chmod 0666 $DIR/$tfile || error "chmod 0666 $tfile failed"
228 $CHECKSTAT -t file -p 0666 -u \#$UID $DIR/$tfile ||
229 error "$tfile does not have perm 0666 or UID $UID"
230 $RUNAS chmod 0444 $DIR/$tfile && error "chmod $tfile worked on UID $UID"
231 $CHECKSTAT -t file -p 0666 -u \#$UID $DIR/$tfile ||
232 error "$tfile should be 0666 and owned by UID $UID"
234 run_test 6a "touch f6a; chmod f6a; $RUNAS chmod f6a (should return error) =="
237 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID" && return
239 chown $RUNAS_ID $DIR/$tfile || error "chown $RUNAS_ID $file failed"
240 $CHECKSTAT -t file -u \#$RUNAS_ID $DIR/$tfile ||
241 error "$tfile should be owned by UID $RUNAS_ID"
242 $RUNAS chown $UID $DIR/$tfile && error "chown $UID $file succeeded"
243 $CHECKSTAT -t file -u \#$RUNAS_ID $DIR/$tfile ||
244 error "$tfile should be owned by UID $RUNAS_ID"
246 run_test 6c "touch f6c; chown f6c; $RUNAS chown f6c (should return error) =="
249 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID" && return
251 chgrp $RUNAS_ID $DIR/$tfile || error "chgrp $RUNAS_ID $file failed"
252 $CHECKSTAT -t file -u \#$UID -g \#$RUNAS_ID $DIR/$tfile ||
253 error "$tfile should be owned by GID $UID"
254 $RUNAS chgrp $UID $DIR/$tfile && error "chgrp $UID $file succeeded"
255 $CHECKSTAT -t file -u \#$UID -g \#$RUNAS_ID $DIR/$tfile ||
256 error "$tfile should be owned by UID $UID and GID $RUNAS_ID"
258 run_test 6e "touch f6e; chgrp f6e; $RUNAS chgrp f6e (should return error) =="
261 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID" && return
262 test_mkdir $DIR/$tdir || error "mkdir $tfile failed"
263 chmod 777 $DIR/$tdir || error "chmod 0777 $tdir failed"
264 $RUNAS mkdir $DIR/$tdir/d || error "mkdir $tdir/d failed"
265 chmod g+s $DIR/$tdir/d || error "chmod g+s $tdir/d failed"
266 test_mkdir $DIR/$tdir/d/subdir || error "mkdir $tdir/d/subdir failed"
267 $CHECKSTAT -g \#$RUNAS_GID $DIR/$tdir/d/subdir ||
268 error "$tdir/d/subdir should be GID $RUNAS_GID"
269 if [[ $MDSCOUNT -gt 1 ]]; then
270 # check remote dir sgid inherite
271 $LFS mkdir -i 0 $DIR/$tdir.local ||
272 error "mkdir $tdir.local failed"
273 chmod g+s $DIR/$tdir.local ||
274 error "chmod $tdir.local failed"
275 chgrp $RUNAS_GID $DIR/$tdir.local ||
276 error "chgrp $tdir.local failed"
277 $LFS mkdir -i 1 $DIR/$tdir.local/$tdir.remote ||
278 error "mkdir $tdir.remote failed"
279 $CHECKSTAT -g \#$RUNAS_GID $DIR/$tdir.local/$tdir.remote ||
280 error "$tdir.remote should be owned by $UID.$RUNAS_ID"
281 $CHECKSTAT -p 02755 $DIR/$tdir.local/$tdir.remote ||
282 error "$tdir.remote should be mode 02755"
285 run_test 6g "Is new dir in sgid dir inheriting group?"
287 test_6h() { # bug 7331
288 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID" && return
289 touch $DIR/$tfile || error "touch failed"
290 chown $RUNAS_ID:$RUNAS_GID $DIR/$tfile || error "initial chown failed"
291 $RUNAS -G$RUNAS_GID chown $RUNAS_ID:0 $DIR/$tfile &&
292 error "chown $RUNAS_ID:0 $tfile worked as GID $RUNAS_GID"
293 $CHECKSTAT -t file -u \#$RUNAS_ID -g \#$RUNAS_GID $DIR/$tfile ||
294 error "$tdir/$tfile should be UID $RUNAS_UID GID $RUNAS_GID"
296 run_test 6h "$RUNAS chown RUNAS_ID.0 .../f6h (should return error)"
299 test_mkdir $DIR/$tdir
300 $MCREATE $DIR/$tdir/$tfile
301 chmod 0666 $DIR/$tdir/$tfile
302 $CHECKSTAT -t file -p 0666 $DIR/$tdir/$tfile ||
303 error "$tdir/$tfile should be mode 0666"
305 run_test 7a "mkdir .../d7; mcreate .../d7/f; chmod .../d7/f ===="
308 if [ ! -d $DIR/$tdir ]; then
309 test_mkdir $DIR/$tdir
311 $MCREATE $DIR/$tdir/$tfile
312 echo -n foo > $DIR/$tdir/$tfile
313 [ "$(cat $DIR/$tdir/$tfile)" = "foo" ] || error "$tdir/$tfile not 'foo'"
314 $CHECKSTAT -t file -s 3 $DIR/$tdir/$tfile || error "$tfile size not 3"
316 run_test 7b "mkdir .../d7; mcreate d7/f2; echo foo > d7/f2 ====="
319 test_mkdir $DIR/$tdir
320 touch $DIR/$tdir/$tfile
321 chmod 0666 $DIR/$tdir/$tfile
322 $CHECKSTAT -t file -p 0666 $DIR/$tdir/$tfile ||
323 error "$tfile mode not 0666"
325 run_test 8 "mkdir .../d8; touch .../d8/f; chmod .../d8/f ======="
328 test_mkdir $DIR/$tdir
329 test_mkdir $DIR/$tdir/d2
330 test_mkdir $DIR/$tdir/d2/d3
331 $CHECKSTAT -t dir $DIR/$tdir/d2/d3 || error "$tdir/d2/d3 not a dir"
333 run_test 9 "mkdir .../d9 .../d9/d2 .../d9/d2/d3 ================"
336 test_mkdir $DIR/$tdir
337 test_mkdir $DIR/$tdir/d2
338 touch $DIR/$tdir/d2/$tfile
339 $CHECKSTAT -t file $DIR/$tdir/d2/$tfile ||
340 error "$tdir/d2/$tfile not a file"
342 run_test 10 "mkdir .../d10 .../d10/d2; touch .../d10/d2/f ======"
345 test_mkdir $DIR/$tdir
346 test_mkdir $DIR/$tdir/d2
347 chmod 0666 $DIR/$tdir/d2
348 chmod 0705 $DIR/$tdir/d2
349 $CHECKSTAT -t dir -p 0705 $DIR/$tdir/d2 ||
350 error "$tdir/d2 mode not 0705"
352 run_test 11 "mkdir .../d11 d11/d2; chmod .../d11/d2 ============"
355 test_mkdir $DIR/$tdir
356 touch $DIR/$tdir/$tfile
357 chmod 0666 $DIR/$tdir/$tfile
358 chmod 0654 $DIR/$tdir/$tfile
359 $CHECKSTAT -t file -p 0654 $DIR/$tdir/$tfile ||
360 error "$tdir/d2 mode not 0654"
362 run_test 12 "touch .../d12/f; chmod .../d12/f .../d12/f ========"
365 test_mkdir $DIR/$tdir
366 dd if=/dev/zero of=$DIR/$tdir/$tfile count=10
368 $CHECKSTAT -t file -s 0 $DIR/$tdir/$tfile ||
369 error "$tdir/$tfile size not 0 after truncate"
371 run_test 13 "creat .../d13/f; dd .../d13/f; > .../d13/f ========"
374 test_mkdir $DIR/$tdir
375 touch $DIR/$tdir/$tfile
377 $CHECKSTAT -a $DIR/$tdir/$tfile || error "$tdir/$tfile not removed"
379 run_test 14 "touch .../d14/f; rm .../d14/f; rm .../d14/f ======="
382 test_mkdir $DIR/$tdir
383 touch $DIR/$tdir/$tfile
384 mv $DIR/$tdir/$tfile $DIR/$tdir/${tfile}_2
385 $CHECKSTAT -t file $DIR/$tdir/${tfile}_2 ||
386 error "$tdir/${tfile_2} not a file after rename"
387 rm $DIR/$tdir/${tfile}_2 || error "unlink failed after rename"
389 run_test 15 "touch .../d15/f; mv .../d15/f .../d15/f2 =========="
392 test_mkdir $DIR/$tdir
393 touch $DIR/$tdir/$tfile
394 rm -rf $DIR/$tdir/$tfile
395 $CHECKSTAT -a $DIR/$tdir/$tfile || error "$tdir/$tfile not removed"
397 run_test 16 "touch .../d16/f; rm -rf .../d16/f ================="
400 test_mkdir -p $DIR/$tdir
401 touch $DIR/$tdir/$tfile
402 ln -s $DIR/$tdir/$tfile $DIR/$tdir/l-exist
404 $CHECKSTAT -l $DIR/$tdir/$tfile $DIR/$tdir/l-exist ||
405 error "$tdir/l-exist not a symlink"
406 $CHECKSTAT -f -t f $DIR/$tdir/l-exist ||
407 error "$tdir/l-exist not referencing a file"
408 rm -f $DIR/$tdir/l-exist
409 $CHECKSTAT -a $DIR/$tdir/l-exist || error "$tdir/l-exist not removed"
411 run_test 17a "symlinks: create, remove (real) =================="
414 test_mkdir -p $DIR/$tdir
415 ln -s no-such-file $DIR/$tdir/l-dangle
417 $CHECKSTAT -l no-such-file $DIR/$tdir/l-dangle ||
418 error "$tdir/l-dangle not referencing no-such-file"
419 $CHECKSTAT -fa $DIR/$tdir/l-dangle ||
420 error "$tdir/l-dangle not referencing non-existent file"
421 rm -f $DIR/$tdir/l-dangle
422 $CHECKSTAT -a $DIR/$tdir/l-dangle || error "$tdir/l-dangle not removed"
424 run_test 17b "symlinks: create, remove (dangling) =============="
426 test_17c() { # bug 3440 - don't save failed open RPC for replay
427 test_mkdir -p $DIR/$tdir
428 ln -s foo $DIR/$tdir/$tfile
429 cat $DIR/$tdir/$tfile && error "opened non-existent symlink" || true
431 run_test 17c "symlinks: open dangling (should return error) ===="
434 test_mkdir -p $DIR/$tdir
435 ln -s foo $DIR/$tdir/$tfile
436 touch $DIR/$tdir/$tfile || error "creating to new symlink"
438 run_test 17d "symlinks: create dangling ========================"
441 test_mkdir -p $DIR/$tdir
442 local foo=$DIR/$tdir/$tfile
443 ln -s $foo $foo || error "create symlink failed"
444 ls -l $foo || error "ls -l failed"
445 ls $foo && error "ls not failed" || true
447 run_test 17e "symlinks: create recursive symlink (should return error) ===="
450 test_mkdir -p $DIR/$tdir
451 ln -s 1234567890/2234567890/3234567890/4234567890 $DIR/$tdir/111
452 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890 $DIR/$tdir/222
453 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890 $DIR/$tdir/333
454 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890/9234567890/a234567890/b234567890 $DIR/$tdir/444
455 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890/9234567890/a234567890/b234567890/c234567890/d234567890/f234567890 $DIR/$tdir/555
456 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
459 run_test 17f "symlinks: long and very long symlink name ========================"
461 # str_repeat(S, N) generate a string that is string S repeated N times
466 while [ $((n -= 1)) -ge 0 ]; do
472 # Long symlinks and LU-2241
474 test_mkdir -p $DIR/$tdir
475 local TESTS="59 60 61 4094 4095"
477 # Fix for inode size boundary in 2.1.4
478 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.1.4) ] &&
481 # Patch not applied to 2.2 or 2.3 branches
482 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] &&
483 [ $(lustre_version_code $SINGLEMDS) -le $(version_code 2.3.55) ] &&
486 # skip long symlink name for rhel6.5.
487 # rhel6.5 has a limit (PATH_MAX - sizeof(struct filename))
488 grep -q '6.5' /etc/redhat-release &>/dev/null &&
489 TESTS="59 60 61 4062 4063"
492 local SYMNAME=$(str_repeat 'x' $i)
493 ln -s $SYMNAME $DIR/$tdir/f$i || error "failed $i-char symlink"
494 readlink $DIR/$tdir/f$i || error "failed $i-char readlink"
497 run_test 17g "symlinks: really long symlink name and inode boundaries"
499 test_17h() { #bug 17378
500 remote_mds_nodsh && skip "remote MDS with nodsh" && return
501 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
503 test_mkdir -p $DIR/$tdir
504 if [[ $MDSCOUNT -gt 1 ]]; then
505 mdt_idx=$($LFS getdirstripe -i $DIR/$tdir)
509 $SETSTRIPE -c -1 $DIR/$tdir
510 #define OBD_FAIL_MDS_LOV_PREP_CREATE 0x141
511 do_facet mds$((mdt_idx + 1)) lctl set_param fail_loc=0x80000141
512 touch $DIR/$tdir/$tfile || true
514 run_test 17h "create objects: lov_free_memmd() doesn't lbug"
516 test_17i() { #bug 20018
517 remote_mds_nodsh && skip "remote MDS with nodsh" && return
518 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
519 test_mkdir -c1 $DIR/$tdir
520 local foo=$DIR/$tdir/$tfile
522 if [[ $MDSCOUNT -gt 1 ]]; then
523 mdt_idx=$($LFS getdirstripe -i $DIR/$tdir)
527 ln -s $foo $foo || error "create symlink failed"
528 #define OBD_FAIL_MDS_READLINK_EPROTO 0x143
529 do_facet mds$((mdt_idx + 1)) lctl set_param fail_loc=0x80000143
530 ls -l $foo && error "error not detected"
533 run_test 17i "don't panic on short symlink"
535 test_17k() { #bug 22301
536 [[ -z "$(which rsync 2>/dev/null)" ]] &&
537 skip "no rsync command" && return 0
538 rsync --help | grep -q xattr ||
539 skip_env "$(rsync --version | head -n1) does not support xattrs"
540 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return 0
541 test_mkdir -p $DIR/$tdir
542 test_mkdir -p $DIR/$tdir.new
543 touch $DIR/$tdir/$tfile
544 ln -s $DIR/$tdir/$tfile $DIR/$tdir/$tfile.lnk
545 rsync -av -X $DIR/$tdir/ $DIR/$tdir.new ||
546 error "rsync failed with xattrs enabled"
548 run_test 17k "symlinks: rsync with xattrs enabled ========================="
550 test_17l() { # LU-279
551 [[ -z "$(which getfattr 2>/dev/null)" ]] &&
552 skip "no getfattr command" && return 0
553 test_mkdir -p $DIR/$tdir
554 touch $DIR/$tdir/$tfile
555 ln -s $DIR/$tdir/$tfile $DIR/$tdir/$tfile.lnk
556 for path in "$DIR/$tdir" "$DIR/$tdir/$tfile" "$DIR/$tdir/$tfile.lnk"; do
557 # -h to not follow symlinks. -m '' to list all the xattrs.
558 # grep to remove first line: '# file: $path'.
559 for xattr in `getfattr -hm '' $path 2>/dev/null | grep -v '^#'`;
561 lgetxattr_size_check $path $xattr ||
562 error "lgetxattr_size_check $path $xattr failed"
566 run_test 17l "Ensure lgetxattr's returned xattr size is consistent ========"
570 local short_sym="0123456789"
571 local WDIR=$DIR/${tdir}m
574 remote_mds_nodsh && skip "remote MDS with nodsh" && return
575 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] &&
576 [ $(lustre_version_code $SINGLEMDS) -le $(version_code 2.2.93) ] &&
577 skip "MDS 2.2.0-2.2.93 do not NUL-terminate symlinks" && return
579 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
580 skip "ldiskfs only test" && return 0
582 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
586 # create a long symlink file
587 for ((i = 0; i < 4; ++i)); do
588 long_sym=${long_sym}${long_sym}
591 echo "create 512 short and long symlink files under $WDIR"
592 for ((i = 0; i < 256; ++i)); do
593 ln -sf ${long_sym}"a5a5" $WDIR/long-$i
594 ln -sf ${short_sym}"a5a5" $WDIR/short-$i
600 wait_delete_completed
602 echo "recreate the 512 symlink files with a shorter string"
603 for ((i = 0; i < 512; ++i)); do
604 # rewrite the symlink file with a shorter string
605 ln -sf ${long_sym} $WDIR/long-$i || error "long_sym failed"
606 ln -sf ${short_sym} $WDIR/short-$i || error "short_sym failed"
609 local mds_index=$(($($LFS getstripe -M $WDIR) + 1))
610 local devname=$(mdsdevname $mds_index)
612 echo "stop and checking mds${mds_index}:"
613 # e2fsck should not return error
615 run_e2fsck $(facet_active_host mds${mds_index}) $devname -n
618 start mds${mds_index} $devname $MDS_MOUNT_OPTS || error "start failed"
619 df $MOUNT > /dev/null 2>&1
621 error "e2fsck detected error for short/long symlink: rc=$rc"
623 run_test 17m "run e2fsck against MDT which contains short/long symlink"
625 check_fs_consistency_17n() {
629 # create/unlink in 17n only change 2 MDTs(MDT1/MDT2),
630 # so it only check MDT1/MDT2 instead of all of MDTs.
631 for mdt_index in 1 2; do
632 local devname=$(mdsdevname $mdt_index)
633 # e2fsck should not return error
635 run_e2fsck $(facet_active_host mds$mdt_index) $devname -n ||
638 start mds${mdt_index} $devname $MDS_MOUNT_OPTS ||
639 error "mount mds$mdt_index failed"
640 df $MOUNT > /dev/null 2>&1
648 remote_mds_nodsh && skip "remote MDS with nodsh" && return
649 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] &&
650 [ $(lustre_version_code $SINGLEMDS) -le $(version_code 2.2.93) ] &&
651 skip "MDS 2.2.0-2.2.93 do not NUL-terminate symlinks" && return
653 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
654 skip "ldiskfs only test" && return 0
656 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 2 MDTs" && return
658 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
660 test_mkdir $DIR/$tdir
661 for ((i=0; i<10; i++)); do
662 $LFS mkdir -i1 -c2 $DIR/$tdir/remote_dir_${i} ||
663 error "create remote dir error $i"
664 createmany -o $DIR/$tdir/remote_dir_${i}/f 10 ||
665 error "create files under remote dir failed $i"
668 check_fs_consistency_17n ||
669 error "e2fsck report error after create files under remote dir"
671 for ((i = 0; i < 10; i++)); do
672 rm -rf $DIR/$tdir/remote_dir_${i} ||
673 error "destroy remote dir error $i"
676 check_fs_consistency_17n ||
677 error "e2fsck report error after unlink files under remote dir"
679 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.50) ] &&
680 skip "lustre < 2.4.50 does not support migrate mv " && return
682 for ((i = 0; i < 10; i++)); do
683 mkdir -p $DIR/$tdir/remote_dir_${i}
684 createmany -o $DIR/$tdir/remote_dir_${i}/f 10 ||
685 error "create files under remote dir failed $i"
686 $LFS migrate --mdt-index 1 $DIR/$tdir/remote_dir_${i} ||
687 error "migrate remote dir error $i"
689 check_fs_consistency_17n || error "e2fsck report error after migration"
691 for ((i = 0; i < 10; i++)); do
692 rm -rf $DIR/$tdir/remote_dir_${i} ||
693 error "destroy remote dir error $i"
696 check_fs_consistency_17n || error "e2fsck report error after unlink"
698 run_test 17n "run e2fsck against master/slave MDT which contains remote dir"
701 remote_mds_nodsh && skip "remote MDS with nodsh" && return
702 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.3.64) ] &&
703 skip "Need MDS version at least 2.3.64" && return
705 local WDIR=$DIR/${tdir}o
711 mdt_index=$($LFS getstripe -M $WDIR/$tfile)
712 mdt_index=$((mdt_index+1))
715 #fail mds will wait the failover finish then set
716 #following fail_loc to avoid interfer the recovery process.
719 #define OBD_FAIL_OSD_LMA_INCOMPAT 0x194
720 do_facet mds${mdt_index} lctl set_param fail_loc=0x194
721 ls -l $WDIR/$tfile && rc=1
722 do_facet mds${mdt_index} lctl set_param fail_loc=0
723 [[ $rc -ne 0 ]] && error "stat file should fail"
726 run_test 17o "stat file with incompat LMA feature"
729 touch $DIR/$tfile || error "Failed to touch $DIR/$tfile: $?"
730 ls $DIR || error "Failed to ls $DIR: $?"
732 run_test 18 "touch .../f ; ls ... =============================="
738 $CHECKSTAT -a $DIR/$tfile || error "$tfile was not removed"
740 run_test 19a "touch .../f19 ; ls -l ... ; rm .../f19 ==========="
743 ls -l $DIR/$tfile && error "ls -l $tfile failed"|| true
745 run_test 19b "ls -l .../f19 (should return error) =============="
748 [ $RUNAS_ID -eq $UID ] &&
749 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
750 $RUNAS touch $DIR/$tfile && error "create non-root file failed" || true
752 run_test 19c "$RUNAS touch .../f19 (should return error) =="
755 cat $DIR/f19 && error || true
757 run_test 19d "cat .../f19 (should return error) =============="
766 $CHECKSTAT -a $DIR/$tfile || error "$tfile was not removed"
768 run_test 20 "touch .../f ; ls -l ... ==========================="
771 test_mkdir -p $DIR/$tdir
772 [ -f $DIR/$tdir/dangle ] && rm -f $DIR/$tdir/dangle
773 ln -s dangle $DIR/$tdir/link
774 echo foo >> $DIR/$tdir/link
775 cat $DIR/$tdir/dangle
776 $CHECKSTAT -t link $DIR/$tdir/link || error "$tdir/link not a link"
777 $CHECKSTAT -f -t file $DIR/$tdir/link ||
778 error "$tdir/link not linked to a file"
780 run_test 21 "write to dangling link ============================"
784 test_mkdir -p $DIR/$tdir
785 chown $RUNAS_ID:$RUNAS_GID $WDIR
786 (cd $WDIR || error "cd $WDIR failed";
787 $RUNAS tar cf - /etc/hosts /etc/sysconfig/network | \
789 ls -lR $WDIR/etc || error "ls -lR $WDIR/etc failed"
790 $CHECKSTAT -t dir $WDIR/etc || error "checkstat -t dir failed"
791 $CHECKSTAT -u \#$RUNAS_ID -g \#$RUNAS_GID $WDIR/etc || error "checkstat -u failed"
793 run_test 22 "unpack tar archive as non-root user ==============="
797 test_mkdir -p $DIR/$tdir
798 local file=$DIR/$tdir/$tfile
800 openfile -f O_CREAT:O_EXCL $file || error "$file create failed"
801 openfile -f O_CREAT:O_EXCL $file &&
802 error "$file recreate succeeded" || true
804 run_test 23a "O_CREAT|O_EXCL in subdir =========================="
806 test_23b() { # bug 18988
807 test_mkdir -p $DIR/$tdir
808 local file=$DIR/$tdir/$tfile
811 echo foo > $file || error "write filed"
812 echo bar >> $file || error "append filed"
813 $CHECKSTAT -s 8 $file || error "wrong size"
816 run_test 23b "O_APPEND check =========================="
820 echo '-- same directory rename'
821 test_mkdir $DIR/$tdir
822 touch $DIR/$tdir/$tfile.1
823 mv $DIR/$tdir/$tfile.1 $DIR/$tdir/$tfile.2
824 $CHECKSTAT -t file $DIR/$tdir/$tfile.2 || error "$tfile.2 not a file"
826 run_test 24a "rename file to non-existent target"
829 test_mkdir $DIR/$tdir
830 touch $DIR/$tdir/$tfile.{1,2}
831 mv $DIR/$tdir/$tfile.1 $DIR/$tdir/$tfile.2
832 $CHECKSTAT -a $DIR/$tdir/$tfile.1 || error "$tfile.1 exists"
833 $CHECKSTAT -t file $DIR/$tdir/$tfile.2 || error "$tfile.2 not a file"
835 run_test 24b "rename file to existing target"
838 test_mkdir $DIR/$tdir
839 test_mkdir $DIR/$tdir/d$testnum.1
840 mv $DIR/$tdir/d$testnum.1 $DIR/$tdir/d$testnum.2
841 $CHECKSTAT -a $DIR/$tdir/d$testnum.1 || error "d$testnum.1 exists"
842 $CHECKSTAT -t dir $DIR/$tdir/d$testnum.2 || error "d$testnum.2 not dir"
844 run_test 24c "rename directory to non-existent target"
847 test_mkdir -c1 $DIR/$tdir
848 test_mkdir -c1 $DIR/$tdir/d$testnum.1
849 test_mkdir -c1 $DIR/$tdir/d$testnum.2
850 mrename $DIR/$tdir/d$testnum.1 $DIR/$tdir/d$testnum.2
851 $CHECKSTAT -a $DIR/$tdir/d$testnum.1 || error "d$testnum.1 exists"
852 $CHECKSTAT -t dir $DIR/$tdir/d$testnum.2 || error "d$testnum.2 not dir"
854 run_test 24d "rename directory to existing target"
857 echo '-- cross directory renames --'
861 mv $DIR/R5a/f $DIR/R5b/g
862 $CHECKSTAT -a $DIR/R5a/f || error
863 $CHECKSTAT -t file $DIR/R5b/g || error
865 run_test 24e "touch .../R5a/f; rename .../R5a/f .../R5b/g ======"
870 touch $DIR/R6a/f $DIR/R6b/g
871 mv $DIR/R6a/f $DIR/R6b/g
872 $CHECKSTAT -a $DIR/R6a/f || error
873 $CHECKSTAT -t file $DIR/R6b/g || error
875 run_test 24f "touch .../R6a/f R6b/g; mv .../R6a/f .../R6b/g ===="
880 test_mkdir $DIR/R7a/d
881 mv $DIR/R7a/d $DIR/R7b/e
882 $CHECKSTAT -a $DIR/R7a/d || error
883 $CHECKSTAT -t dir $DIR/R7b/e || error
885 run_test 24g "mkdir .../R7{a,b}/d; mv .../R7a/d .../R7b/e ======"
888 test_mkdir -c1 $DIR/R8a
889 test_mkdir -c1 $DIR/R8b
890 test_mkdir -c1 $DIR/R8a/d
891 test_mkdir -c1 $DIR/R8b/e
892 mrename $DIR/R8a/d $DIR/R8b/e
893 $CHECKSTAT -a $DIR/R8a/d || error
894 $CHECKSTAT -t dir $DIR/R8b/e || error
896 run_test 24h "mkdir .../R8{a,b}/{d,e}; rename .../R8a/d .../R8b/e"
899 echo "-- rename error cases"
903 mrename $DIR/R9/f $DIR/R9/a
904 $CHECKSTAT -t file $DIR/R9/f || error
905 $CHECKSTAT -t dir $DIR/R9/a || error
906 $CHECKSTAT -a $DIR/R9/a/f || error
908 run_test 24i "rename file to dir error: touch f ; mkdir a ; rename f a"
912 mrename $DIR/R10/f $DIR/R10/g
913 $CHECKSTAT -t dir $DIR/R10 || error
914 $CHECKSTAT -a $DIR/R10/f || error
915 $CHECKSTAT -a $DIR/R10/g || error
917 run_test 24j "source does not exist ============================"
921 test_mkdir $DIR/R11a/d
923 mv $DIR/R11a/f $DIR/R11a/d
924 $CHECKSTAT -a $DIR/R11a/f || error
925 $CHECKSTAT -t file $DIR/R11a/d/f || error
927 run_test 24k "touch .../R11a/f; mv .../R11a/f .../R11a/d ======="
929 # bug 2429 - rename foo foo foo creates invalid file
932 $MULTIOP $f OcNs || error
934 run_test 24l "Renaming a file to itself ========================"
938 $MULTIOP $f OcLN ${f}2 ${f}2 || error "link ${f}2 ${f}2 failed"
939 # on ext3 this does not remove either the source or target files
940 # though the "expected" operation would be to remove the source
941 $CHECKSTAT -t file ${f} || error "${f} missing"
942 $CHECKSTAT -t file ${f}2 || error "${f}2 missing"
944 run_test 24m "Renaming a file to a hard link to itself ========="
948 # this stats the old file after it was renamed, so it should fail
952 $CHECKSTAT ${f}.rename
955 run_test 24n "Statting the old file after renaming (Posix rename 2)"
958 test_mkdir -p $DIR/d24o
959 rename_many -s random -v -n 10 $DIR/d24o
961 run_test 24o "rename of files during htree split ==============="
966 DIRINO=`ls -lid $DIR/R12a | awk '{ print $1 }'`
967 mrename $DIR/R12a $DIR/R12b
968 $CHECKSTAT -a $DIR/R12a || error
969 $CHECKSTAT -t dir $DIR/R12b || error
970 DIRINO2=`ls -lid $DIR/R12b | awk '{ print $1 }'`
971 [ "$DIRINO" = "$DIRINO2" ] || error "R12a $DIRINO != R12b $DIRINO2"
973 run_test 24p "mkdir .../R12{a,b}; rename .../R12a .../R12b"
975 cleanup_multiop_pause() {
981 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
984 local DIRINO=$(ls -lid $DIR/R13a | awk '{ print $1 }')
985 multiop_bg_pause $DIR/R13b D_c || error "multiop failed to start"
988 trap cleanup_multiop_pause EXIT
989 mrename $DIR/R13a $DIR/R13b
990 $CHECKSTAT -a $DIR/R13a || error "R13a still exists"
991 $CHECKSTAT -t dir $DIR/R13b || error "R13b does not exist"
992 local DIRINO2=$(ls -lid $DIR/R13b | awk '{ print $1 }')
993 [ "$DIRINO" = "$DIRINO2" ] || error "R13a $DIRINO != R13b $DIRINO2"
994 cleanup_multiop_pause
995 wait $MULTIPID || error "multiop close failed"
997 run_test 24q "mkdir .../R13{a,b}; open R13b rename R13a R13b ==="
999 test_24r() { #bug 3789
1000 test_mkdir $DIR/R14a
1001 test_mkdir $DIR/R14a/b
1002 mrename $DIR/R14a $DIR/R14a/b && error "rename to subdir worked!"
1003 $CHECKSTAT -t dir $DIR/R14a || error "$DIR/R14a missing"
1004 $CHECKSTAT -t dir $DIR/R14a/b || error "$DIR/R14a/b missing"
1006 run_test 24r "mkdir .../R14a/b; rename .../R14a .../R14a/b ====="
1009 test_mkdir $DIR/R15a
1010 test_mkdir $DIR/R15a/b
1011 test_mkdir $DIR/R15a/b/c
1012 mrename $DIR/R15a $DIR/R15a/b/c && error "rename to sub-subdir worked!"
1013 $CHECKSTAT -t dir $DIR/R15a || error "$DIR/R15a missing"
1014 $CHECKSTAT -t dir $DIR/R15a/b/c || error "$DIR/R15a/b/c missing"
1016 run_test 24s "mkdir .../R15a/b/c; rename .../R15a .../R15a/b/c ="
1018 test_mkdir $DIR/R16a
1019 test_mkdir $DIR/R16a/b
1020 test_mkdir $DIR/R16a/b/c
1021 mrename $DIR/R16a/b/c $DIR/R16a && error "rename to sub-subdir worked!"
1022 $CHECKSTAT -t dir $DIR/R16a || error "$DIR/R16a missing"
1023 $CHECKSTAT -t dir $DIR/R16a/b/c || error "$DIR/R16a/b/c missing"
1025 run_test 24t "mkdir .../R16a/b/c; rename .../R16a/b/c .../R16a ="
1027 test_24u() { # bug12192
1028 $MULTIOP $DIR/$tfile C2w$((2048 * 1024))c || error
1029 $CHECKSTAT -s $((2048 * 1024)) $DIR/$tfile || error "wrong file size"
1031 run_test 24u "create stripe file"
1035 size=$(getconf PAGE_SIZE 2>/dev/null)
1036 echo -n ${size:-4096}
1039 simple_cleanup_common() {
1042 [ -z "$DIR" -o -z "$tdir" ] && return 0
1044 local start=$SECONDS
1047 wait_delete_completed
1048 echo "cleanup time $((SECONDS - start))"
1052 max_pages_per_rpc() {
1053 local mdtname="$(printf "MDT%04x" ${1:-0})"
1054 $LCTL get_param -n mdc.*$mdtname*.max_pages_per_rpc
1058 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1059 local nrfiles=${COUNT:-100000}
1060 # Performance issue on ZFS see LU-4072 (c.f. LU-2887)
1061 [ $(facet_fstype $SINGLEMDS) = "zfs" ] && nrfiles=${COUNT:-10000}
1063 local fname="$DIR/$tdir/$tfile"
1064 test_mkdir "$(dirname $fname)"
1065 # assume MDT0000 has the fewest inodes
1066 local stripes=$($LFS getdirstripe -c $(dirname $fname))
1067 local free_inodes=$(($(mdt_free_inodes 0) * stripes))
1068 [[ $free_inodes -lt $nrfiles ]] && nrfiles=$free_inodes
1070 trap simple_cleanup_common EXIT
1072 createmany -m "$fname" $nrfiles
1074 cancel_lru_locks mdc
1075 lctl set_param mdc.*.stats clear
1077 # was previously test_24D: LU-6101
1078 # readdir() returns correct number of entries after cursor reload
1079 local num_ls=$(ls $DIR/$tdir | wc -l)
1080 local num_uniq=$(ls $DIR/$tdir | sort -u | wc -l)
1081 local num_all=$(ls -a $DIR/$tdir | wc -l)
1082 if [ $num_ls -ne $nrfiles -o $num_uniq -ne $nrfiles -o \
1083 $num_all -ne $((nrfiles + 2)) ]; then
1084 error "Expected $nrfiles files, got $num_ls " \
1085 "($num_uniq unique $num_all .&..)"
1087 # LU-5 large readdir
1088 # dirent_size = 32 bytes for sizeof(struct lu_dirent) +
1089 # N bytes for name (len($nrfiles) rounded to 8 bytes) +
1090 # 8 bytes for luda_type (4 bytes rounded to 8 bytes)
1091 # take into account of overhead in lu_dirpage header and end mark in
1092 # each page, plus one in rpc_num calculation.
1093 local dirent_size=$((32 + (${#tfile} | 7) + 1 + 8))
1094 local page_entries=$((($(page_size) - 24) / dirent_size))
1095 local mdt_idx=$($LFS getdirstripe -i $(dirname $fname))
1096 local rpc_pages=$(max_pages_per_rpc $mdt_idx)
1097 local rpc_max=$((nrfiles / (page_entries * rpc_pages) + stripes))
1098 local mds_readpage=$(calc_stats mdc.*.stats mds_readpage)
1099 echo "readpages: $mds_readpage rpc_max: $rpc_max"
1100 (( $mds_readpage < $rpc_max - 2 || $mds_readpage > $rpc_max + 1)) &&
1101 error "large readdir doesn't take effect: " \
1102 "$mds_readpage should be about $rpc_max"
1104 simple_cleanup_common
1106 run_test 24v "list large directory (test hash collision, b=17560)"
1108 test_24w() { # bug21506
1110 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=4096 || return 1
1111 dd if=/dev/zero bs=$SZ1 count=1 >> $DIR/$tfile || return 2
1112 dd if=$DIR/$tfile of=$DIR/${tfile}_left bs=1M skip=4097 || return 3
1113 SZ2=`ls -l $DIR/${tfile}_left | awk '{print $5}'`
1114 [[ "$SZ1" -eq "$SZ2" ]] ||
1115 error "Error reading at the end of the file $tfile"
1117 run_test 24w "Reading a file larger than 4Gb"
1120 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 2 MDTs" && return
1122 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.56) ]] &&
1123 skip "Need MDS version at least 2.7.56" && return
1125 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1127 local remote_dir=$DIR/$tdir/remote_dir
1129 test_mkdir -p $DIR/$tdir
1130 $LFS mkdir -i $MDTIDX $remote_dir ||
1131 error "create remote directory failed"
1133 test_mkdir -p $DIR/$tdir/src_dir
1134 touch $DIR/$tdir/src_file
1135 test_mkdir -p $remote_dir/tgt_dir
1136 touch $remote_dir/tgt_file
1138 mrename $DIR/$tdir/src_dir $remote_dir/tgt_dir ||
1139 error "rename dir cross MDT failed!"
1141 mrename $DIR/$tdir/src_file $remote_dir/tgt_file ||
1142 error "rename file cross MDT failed!"
1144 touch $DIR/$tdir/ln_file
1145 ln $DIR/$tdir/ln_file $remote_dir/ln_name ||
1146 error "ln file cross MDT failed"
1148 rm -rf $DIR/$tdir || error "Can not delete directories"
1150 run_test 24x "cross MDT rename/link"
1153 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 2 MDTs" && return
1154 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1156 local remote_dir=$DIR/$tdir/remote_dir
1158 test_mkdir -p $DIR/$tdir
1159 $LFS mkdir -i $MDTIDX $remote_dir ||
1160 error "create remote directory failed"
1162 test_mkdir -p $remote_dir/src_dir
1163 touch $remote_dir/src_file
1164 test_mkdir -p $remote_dir/tgt_dir
1165 touch $remote_dir/tgt_file
1167 mrename $remote_dir/src_dir $remote_dir/tgt_dir ||
1168 error "rename subdir in the same remote dir failed!"
1170 mrename $remote_dir/src_file $remote_dir/tgt_file ||
1171 error "rename files in the same remote dir failed!"
1173 ln $remote_dir/tgt_file $remote_dir/tgt_file1 ||
1174 error "link files in the same remote dir failed!"
1176 rm -rf $DIR/$tdir || error "Can not delete directories"
1178 run_test 24y "rename/link on the same dir should succeed"
1180 test_24A() { # LU-3182
1184 test_mkdir -p $DIR/$tdir
1185 trap simple_cleanup_common EXIT
1186 createmany -m $DIR/$tdir/$tfile $NFILES
1187 local t=$(ls $DIR/$tdir | wc -l)
1188 local u=$(ls $DIR/$tdir | sort -u | wc -l)
1189 local v=$(ls -ai $DIR/$tdir | sort -u | wc -l)
1190 if [ $t -ne $NFILES -o $u -ne $NFILES -o $v -ne $((NFILES + 2)) ] ; then
1191 error "Expected $NFILES files, got $t ($u unique $v .&..)"
1194 simple_cleanup_common || error "Can not delete directories"
1196 run_test 24A "readdir() returns correct number of entries."
1198 test_24B() { # LU-4805
1199 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
1202 test_mkdir $DIR/$tdir
1203 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR/$tdir/striped_dir ||
1204 error "create striped dir failed"
1206 count=$(ls -ai $DIR/$tdir/striped_dir | wc -l)
1207 [ $count -eq 2 ] || error "Expected 2, got $count"
1209 touch $DIR/$tdir/striped_dir/a
1211 count=$(ls -ai $DIR/$tdir/striped_dir | wc -l)
1212 [ $count -eq 3 ] || error "Expected 3, got $count"
1214 touch $DIR/$tdir/striped_dir/.f
1216 count=$(ls -ai $DIR/$tdir/striped_dir | wc -l)
1217 [ $count -eq 4 ] || error "Expected 4, got $count"
1219 rm -rf $DIR/$tdir || error "Can not delete directories"
1221 run_test 24B "readdir for striped dir return correct number of entries"
1224 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
1230 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR/$tdir/d0/striped_dir ||
1231 error "create striped dir failed"
1233 cd $DIR/$tdir/d0/striped_dir
1235 local d0_ino=$(ls -i -l -a $DIR/$tdir | grep "d0" | awk '{print $1}')
1236 local d1_ino=$(ls -i -l -a $DIR/$tdir | grep "d1" | awk '{print $1}')
1237 local parent_ino=$(ls -i -l -a | grep "\.\." | awk '{print $1}')
1239 [ "$d0_ino" = "$parent_ino" ] ||
1240 error ".. wrong, expect $d0_ino, get $parent_ino"
1242 mv $DIR/$tdir/d0/striped_dir $DIR/$tdir/d1/ ||
1243 error "mv striped dir failed"
1245 parent_ino=$(ls -i -l -a | grep "\.\." | awk '{print $1}')
1247 [ "$d1_ino" = "$parent_ino" ] ||
1248 error ".. wrong after mv, expect $d1_ino, get $parent_ino"
1250 run_test 24C "check .. in striped dir"
1253 [[ $MDSCOUNT -lt 4 ]] && skip "needs >= 4 MDTs" && return
1254 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1257 mkdir $DIR/$tdir/src_dir
1258 $LFS mkdir -i 1 $DIR/$tdir/src_dir/src_child ||
1259 error "create remote source failed"
1261 touch $DIR/$tdir/src_dir/src_child/a
1263 $LFS mkdir -i 2 $DIR/$tdir/tgt_dir ||
1264 error "create remote target dir failed"
1266 $LFS mkdir -i 3 $DIR/$tdir/tgt_dir/tgt_child ||
1267 error "create remote target child failed"
1269 mrename $DIR/$tdir/src_dir/src_child $DIR/$tdir/tgt_dir/tgt_child ||
1270 error "rename dir cross MDT failed!"
1274 $CHECKSTAT -t dir $DIR/$tdir/src_dir/src_child &&
1275 error "src_child still exists after rename"
1277 $CHECKSTAT -t file $DIR/$tdir/tgt_dir/tgt_child/a ||
1278 error "missing file(a) after rename"
1280 rm -rf $DIR/$tdir || error "Can not delete directories"
1282 run_test 24E "cross MDT rename/link"
1285 echo '== symlink sanity ============================================='
1289 touch $DIR/s25/foo || error
1291 run_test 25a "create file in symlinked directory ==============="
1294 [ ! -d $DIR/d25 ] && test_25a
1295 $CHECKSTAT -t file $DIR/s25/foo || error
1297 run_test 25b "lookup file in symlinked directory ==============="
1301 test_mkdir $DIR/d26/d26-2
1302 ln -s d26/d26-2 $DIR/s26
1303 touch $DIR/s26/foo || error
1305 run_test 26a "multiple component symlink ======================="
1308 test_mkdir -p $DIR/d26b/d26-2
1309 ln -s d26b/d26-2/foo $DIR/s26-2
1310 touch $DIR/s26-2 || error
1312 run_test 26b "multiple component symlink at end of lookup ======"
1315 test_mkdir $DIR/d26.2
1316 touch $DIR/d26.2/foo
1317 ln -s d26.2 $DIR/s26.2-1
1318 ln -s s26.2-1 $DIR/s26.2-2
1319 ln -s s26.2-2 $DIR/s26.2-3
1320 chmod 0666 $DIR/s26.2-3/foo
1322 run_test 26c "chain of symlinks ================================"
1324 # recursive symlinks (bug 439)
1326 ln -s d26-3/foo $DIR/d26-3
1328 run_test 26d "create multiple component recursive symlink ======"
1331 [ ! -h $DIR/d26-3 ] && test_26d
1334 run_test 26e "unlink multiple component recursive symlink ======"
1336 # recursive symlinks (bug 7022)
1338 test_mkdir -p $DIR/$tdir
1339 test_mkdir $DIR/$tdir/$tfile || error "mkdir $DIR/$tdir/$tfile failed"
1340 cd $DIR/$tdir/$tfile || error "cd $DIR/$tdir/$tfile failed"
1341 test_mkdir -p lndir/bar1 || error "mkdir lndir/bar1 failed"
1342 test_mkdir $DIR/$tdir/$tfile/$tfile || error "mkdir $tfile failed"
1343 cd $tfile || error "cd $tfile failed"
1344 ln -s .. dotdot || error "ln dotdot failed"
1345 ln -s dotdot/lndir lndir || error "ln lndir failed"
1346 cd $DIR/$tdir || error "cd $DIR/$tdir failed"
1347 output=`ls $tfile/$tfile/lndir/bar1`
1348 [ "$output" = bar1 ] && error "unexpected output"
1349 rm -r $tfile || error "rm $tfile failed"
1350 $CHECKSTAT -a $DIR/$tfile || error "$tfile not gone"
1352 run_test 26f "rm -r of a directory which has recursive symlink"
1355 test_mkdir -p $DIR/d27 || error "mkdir failed"
1356 $LFS getstripe $DIR/d27
1357 $LFS setstripe -c 1 $DIR/d27/f0 || error "setstripe failed"
1358 $CHECKSTAT -t file $DIR/d27/f0 || error "checkstat failed"
1359 cp /etc/hosts $DIR/d27/f0 || error
1361 run_test 27a "one stripe file"
1364 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
1365 test_mkdir -p $DIR/d27
1366 $LFS setstripe -c 2 $DIR/d27/f01 || error "setstripe failed"
1367 $LFS getstripe -c $DIR/d27/f01
1368 [ $($LFS getstripe -c $DIR/d27/f01) -eq 2 ] ||
1369 error "two-stripe file doesn't have two stripes"
1371 dd if=/dev/zero of=$DIR/d27/f01 bs=4k count=4 || error "dd failed"
1373 run_test 27b "create and write to two stripe file"
1376 test_mkdir -p $DIR/d27
1377 $LFS setstripe -c 0 -i -1 -S 0 $DIR/d27/fdef || error "setstripe failed"
1378 $CHECKSTAT -t file $DIR/d27/fdef || error "checkstat failed"
1379 dd if=/dev/zero of=$DIR/d27/fdef bs=4k count=4 || error
1381 run_test 27d "create file with default settings"
1384 # LU-5839 adds check for existed layout before setting it
1385 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.56) ]] &&
1386 skip "Need MDS version at least 2.7.56" && return
1387 test_mkdir -p $DIR/d27
1388 $LFS setstripe -c 2 $DIR/d27/f12 || error "setstripe failed"
1389 $LFS setstripe -c 2 $DIR/d27/f12 && error "setstripe succeeded twice"
1390 $CHECKSTAT -t file $DIR/d27/f12 || error "checkstat failed"
1392 run_test 27e "setstripe existing file (should return error)"
1395 test_mkdir $DIR/$tdir
1396 $LFS setstripe -S 100 -i 0 -c 1 $DIR/$tdir/$tfile &&
1397 error "$SETSTRIPE $DIR/$tdir/$tfile failed"
1398 $CHECKSTAT -t file $DIR/$tdir/$tfile &&
1399 error "$CHECKSTAT -t file $DIR/$tdir/$tfile should fail"
1400 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=4k count=4 || error "dd failed"
1401 $LFS getstripe $DIR/$tdir/$tfile || error "$LFS getstripe failed"
1403 run_test 27f "setstripe with bad stripe size (should return error)"
1406 test_mkdir -p $DIR/d27
1407 $MCREATE $DIR/d27/fnone || error "mcreate failed"
1408 $LFS getstripe $DIR/d27/fnone 2>&1 | grep "no stripe info" ||
1409 error "$DIR/d27/fnone has object"
1411 run_test 27g "$LFS getstripe with no objects"
1414 test_mkdir $DIR/$tdir
1415 touch $DIR/$tdir/$tfile || error "touch failed"
1416 [[ $($LFS getstripe -c $DIR/$tdir/$tfile) -gt 0 ]] ||
1417 error "missing objects"
1419 run_test 27i "$LFS getstripe with some objects"
1422 test_mkdir -p $DIR/d27
1423 $LFS setstripe -i $OSTCOUNT $DIR/d27/f27j &&
1424 error "setstripe failed" || true
1426 run_test 27j "setstripe with bad stripe offset (should return error)"
1428 test_27k() { # bug 2844
1429 test_mkdir -p $DIR/d27
1431 LL_MAX_BLKSIZE=$((4 * 1024 * 1024))
1432 [ ! -d $DIR/d27 ] && test_mkdir -p $DIR d27
1433 $LFS setstripe -S 67108864 $FILE || error "setstripe failed"
1434 BLKSIZE=$(stat $FILE | awk '/IO Block:/ { print $7 }')
1435 [ $BLKSIZE -le $LL_MAX_BLKSIZE ] || error "1:$BLKSIZE > $LL_MAX_BLKSIZE"
1436 dd if=/dev/zero of=$FILE bs=4k count=1
1437 BLKSIZE=$(stat $FILE | awk '/IO Block:/ { print $7 }')
1438 [ $BLKSIZE -le $LL_MAX_BLKSIZE ] || error "2:$BLKSIZE > $LL_MAX_BLKSIZE"
1440 run_test 27k "limit i_blksize for broken user apps"
1443 test_mkdir -p $DIR/d27
1444 mcreate $DIR/f27l || error "creating file"
1445 $RUNAS $SETSTRIPE -c 1 $DIR/f27l &&
1446 error "setstripe should have failed" || true
1448 run_test 27l "check setstripe permissions (should return error)"
1451 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
1453 ORIGFREE=$($LCTL get_param -n lov.$FSNAME-clilov-*.kbytesavail |
1455 if [[ $ORIGFREE -gt $MAXFREE ]]; then
1456 skip "$ORIGFREE > $MAXFREE skipping out-of-space test on OST0"
1459 trap simple_cleanup_common EXIT
1460 test_mkdir -p $DIR/$tdir
1461 $LFS setstripe -i 0 -c 1 $DIR/$tdir/f27m_1
1462 dd if=/dev/zero of=$DIR/$tdir/f27m_1 bs=1024 count=$MAXFREE &&
1463 error "dd should fill OST0"
1465 while $LFS setstripe -i 0 -c 1 $DIR/$tdir/f27m_$i; do
1467 [ $i -gt 256 ] && break
1470 touch $DIR/$tdir/f27m_$i
1471 [ $($LFS getstripe $DIR/$tdir/f27m_$i | grep -A 10 obdidx |
1472 awk '{print $1}' | grep -w "0") ] &&
1473 error "OST0 was full but new created file still use it"
1475 touch $DIR/$tdir/f27m_$i
1476 [ $($LFS getstripe $DIR/$tdir/f27m_$i | grep -A 10 obdidx |
1477 awk '{print $1}'| grep -w "0") ] &&
1478 error "OST0 was full but new created file still use it"
1479 simple_cleanup_common
1481 run_test 27m "create file while OST0 was full"
1484 local DELAY=$(do_facet $SINGLEMDS lctl get_param -n lov.*.qos_maxage |
1485 head -n 1 | awk '{print $1 * 2}')
1489 # OSCs keep a NOSPC flag that will be reset after ~5s (qos_maxage)
1490 # if the OST isn't full anymore.
1492 local OSTIDX=${1:-""}
1494 local list=$(comma_list $(osts_nodes))
1495 [ "$OSTIDX" ] && list=$(facet_host ost$((OSTIDX + 1)))
1497 do_nodes $list lctl set_param fail_loc=0
1498 sync # initiate all OST_DESTROYs from MDS to OST
1502 exhaust_precreations() {
1505 local FAILIDX=${3:-$OSTIDX}
1506 local ofacet=ost$((OSTIDX + 1))
1508 test_mkdir -p -c1 $DIR/$tdir
1509 local mdtidx=$($LFS getstripe -M $DIR/$tdir)
1510 local mfacet=mds$((mdtidx + 1))
1511 echo OSTIDX=$OSTIDX MDTIDX=$mdtidx
1513 local OST=$(ostname_from_index $OSTIDX)
1516 local mdtosc_proc1=$(get_mdtosc_proc_path $mfacet $OST)
1517 local last_id=$(do_facet $mfacet lctl get_param -n \
1518 osc.$mdtosc_proc1.prealloc_last_id)
1519 local next_id=$(do_facet $mfacet lctl get_param -n \
1520 osc.$mdtosc_proc1.prealloc_next_id)
1522 local mdtosc_proc2=$(get_mdtosc_proc_path $mfacet)
1523 do_facet $mfacet lctl get_param osc.$mdtosc_proc2.prealloc*
1525 test_mkdir -p $DIR/$tdir/${OST}
1526 $SETSTRIPE -i $OSTIDX -c 1 $DIR/$tdir/${OST}
1527 #define OBD_FAIL_OST_ENOSPC 0x215
1528 do_facet $ofacet lctl set_param fail_val=$FAILIDX fail_loc=0x215
1529 echo "Creating to objid $last_id on ost $OST..."
1530 createmany -o $DIR/$tdir/${OST}/f $next_id $((last_id - next_id + 2))
1531 do_facet $mfacet lctl get_param osc.$mdtosc_proc2.prealloc*
1532 do_facet $ofacet lctl set_param fail_loc=$FAILLOC
1536 exhaust_all_precreations() {
1538 for (( i=0; i < OSTCOUNT; i++ )) ; do
1539 exhaust_precreations $i $1 -1
1544 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
1545 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1546 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1547 remote_ost_nodsh && skip "remote OST with nodsh" && return
1550 rm -f $DIR/$tdir/$tfile
1551 exhaust_precreations 0 0x80000215
1552 $LFS setstripe -c -1 $DIR/$tdir
1553 touch $DIR/$tdir/$tfile || error
1554 $LFS getstripe $DIR/$tdir/$tfile
1557 run_test 27n "create file with some full OSTs"
1560 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
1561 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1562 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1563 remote_ost_nodsh && skip "remote OST with nodsh" && return
1566 rm -f $DIR/$tdir/$tfile
1567 exhaust_all_precreations 0x215
1569 touch $DIR/$tdir/$tfile && error "able to create $DIR/$tdir/$tfile"
1574 run_test 27o "create file with all full OSTs (should error)"
1577 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
1578 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1579 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1580 remote_ost_nodsh && skip "remote OST with nodsh" && return
1583 rm -f $DIR/$tdir/$tfile
1584 test_mkdir -p $DIR/$tdir
1586 $MCREATE $DIR/$tdir/$tfile || error "mcreate failed"
1587 $TRUNCATE $DIR/$tdir/$tfile 80000000 || error "truncate failed"
1588 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat failed"
1590 exhaust_precreations 0 0x80000215
1591 echo foo >> $DIR/$tdir/$tfile || error "append failed"
1592 $CHECKSTAT -s 80000004 $DIR/$tdir/$tfile || error "checkstat failed"
1593 $LFS getstripe $DIR/$tdir/$tfile
1597 run_test 27p "append to a truncated file with some full OSTs"
1600 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
1601 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1602 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1603 remote_ost_nodsh && skip "remote OST with nodsh" && return
1606 rm -f $DIR/$tdir/$tfile
1608 test_mkdir -p $DIR/$tdir
1609 $MCREATE $DIR/$tdir/$tfile || error "mcreate $DIR/$tdir/$tfile failed"
1610 $TRUNCATE $DIR/$tdir/$tfile 80000000 ||
1611 error "truncate $DIR/$tdir/$tfile failed"
1612 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat failed"
1614 exhaust_all_precreations 0x215
1616 echo foo >> $DIR/$tdir/$tfile && error "append succeeded"
1617 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat 2 failed"
1621 run_test 27q "append to truncated file with all OSTs full (should error)"
1624 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
1625 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1626 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1627 remote_ost_nodsh && skip "remote OST with nodsh" && return
1630 rm -f $DIR/$tdir/$tfile
1631 exhaust_precreations 0 0x80000215
1633 $LFS setstripe -i 0 -c 2 $DIR/$tdir/$tfile # && error
1637 run_test 27r "stripe file with some full OSTs (shouldn't LBUG) ="
1639 test_27s() { # bug 10725
1640 test_mkdir -p $DIR/$tdir
1641 local stripe_size=$((4096 * 1024 * 1024)) # 2^32
1642 local stripe_count=0
1643 [ $OSTCOUNT -eq 1 ] || stripe_count=2
1644 $LFS setstripe -S $stripe_size -c $stripe_count $DIR/$tdir &&
1645 error "stripe width >= 2^32 succeeded" || true
1648 run_test 27s "lsm_xfersize overflow (should error) (bug 10725)"
1650 test_27t() { # bug 10864
1655 $WLFS getstripe $tfile
1658 run_test 27t "check that utils parse path correctly"
1660 test_27u() { # bug 4900
1661 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
1662 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1664 local list=$(comma_list $(mdts_nodes))
1666 #define OBD_FAIL_MDS_OSC_PRECREATE 0x139
1667 do_nodes $list $LCTL set_param fail_loc=0x139
1668 test_mkdir -p $DIR/$tdir
1669 trap simple_cleanup_common EXIT
1670 createmany -o $DIR/$tdir/t- 1000
1671 do_nodes $list $LCTL set_param fail_loc=0
1673 TLOG=$TMP/$tfile.getstripe
1674 $LFS getstripe $DIR/$tdir > $TLOG
1675 OBJS=$(awk -vobj=0 '($1 == 0) { obj += 1 } END { print obj; }' $TLOG)
1676 unlinkmany $DIR/$tdir/t- 1000
1678 [[ $OBJS -gt 0 ]] &&
1679 error "$OBJS objects created on OST-0. See $TLOG" || pass
1681 run_test 27u "skip object creation on OSC w/o objects"
1683 test_27v() { # bug 4900
1684 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
1685 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1686 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1687 remote_ost_nodsh && skip "remote OST with nodsh" && return
1689 exhaust_all_precreations 0x215
1692 test_mkdir $DIR/$tdir
1693 $LFS setstripe -c 1 $DIR/$tdir # 1 stripe / file
1695 touch $DIR/$tdir/$tfile
1696 #define OBD_FAIL_TGT_DELAY_PRECREATE 0x705
1698 for (( i=1; i < OSTCOUNT; i++ )); do
1699 do_facet ost$i lctl set_param fail_loc=0x705
1701 local START=`date +%s`
1702 createmany -o $DIR/$tdir/$tfile 32
1704 local FINISH=`date +%s`
1705 local TIMEOUT=`lctl get_param -n timeout`
1706 local PROCESS=$((FINISH - START))
1707 [ $PROCESS -ge $((TIMEOUT / 2)) ] && \
1708 error "$FINISH - $START >= $TIMEOUT / 2"
1709 sleep $((TIMEOUT / 2 - PROCESS))
1712 run_test 27v "skip object creation on slow OST"
1714 test_27w() { # bug 10997
1715 test_mkdir $DIR/$tdir || error "mkdir failed"
1716 $LFS setstripe -S 65536 $DIR/$tdir/f0 || error "setstripe failed"
1717 [ $($LFS getstripe -S $DIR/$tdir/f0) -ne 65536 ] &&
1718 error "stripe size $size != 65536" || true
1719 [ $($LFS getstripe -d $DIR/$tdir | grep -c "stripe_count") -eq 0 ] &&
1720 error "$LFS getstripe -d $DIR/$tdir no 'stripe_count'" || true
1722 run_test 27w "check $LFS setstripe -S and getstrip -d options"
1725 [[ $OSTCOUNT -lt 2 ]] &&
1726 skip_env "skipping multiple stripe count/offset test" && return
1728 test_mkdir $DIR/$tdir || error "mkdir failed"
1729 for i in $(seq 1 $OSTCOUNT); do
1731 $LFS setstripe -c $i -i $offset $DIR/$tdir/f$i ||
1732 error "setstripe -c $i -i $offset failed"
1733 count=$($LFS getstripe -c $DIR/$tdir/f$i)
1734 index=$($LFS getstripe -i $DIR/$tdir/f$i)
1735 [ $count -ne $i ] && error "stripe count $count != $i" || true
1736 [ $index -ne $offset ] &&
1737 error "stripe offset $index != $offset" || true
1740 run_test 27wa "check $LFS setstripe -c -i options"
1743 remote_ost_nodsh && skip "remote OST with nodsh" && return
1744 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
1745 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1746 OFFSET=$(($OSTCOUNT - 1))
1748 local OST=$(ostname_from_index $OSTIDX)
1750 test_mkdir -p $DIR/$tdir
1751 $LFS setstripe -c 1 $DIR/$tdir # 1 stripe per file
1752 do_facet ost$((OSTIDX + 1)) lctl set_param -n obdfilter.$OST.degraded 1
1754 createmany -o $DIR/$tdir/$tfile $OSTCOUNT
1755 for i in $(seq 0 $OFFSET); do
1756 [ $($LFS getstripe $DIR/$tdir/$tfile$i | grep -A 10 obdidx |
1757 awk '{print $1}' | grep -w "$OSTIDX") ] &&
1758 error "OST0 was degraded but new created file still use it"
1760 do_facet ost$((OSTIDX + 1)) lctl set_param -n obdfilter.$OST.degraded 0
1762 run_test 27x "create files while OST0 is degraded"
1765 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
1766 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1767 remote_ost_nodsh && skip "remote OST with nodsh" && return
1768 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1770 local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS $FSNAME-OST0000)
1771 local last_id=$(do_facet $SINGLEMDS lctl get_param -n \
1772 osc.$mdtosc.prealloc_last_id)
1773 local next_id=$(do_facet $SINGLEMDS lctl get_param -n \
1774 osc.$mdtosc.prealloc_next_id)
1775 local fcount=$((last_id - next_id))
1776 [[ $fcount -eq 0 ]] && skip "not enough space on OST0" && return
1777 [[ $fcount -gt $OSTCOUNT ]] && fcount=$OSTCOUNT
1779 local MDS_OSCS=$(do_facet $SINGLEMDS lctl dl |
1780 awk '/[oO][sS][cC].*md[ts]/ { print $4 }')
1781 local OST_DEACTIVE_IDX=-1
1786 for OSC in $MDS_OSCS; do
1787 OST=$(osc_to_ost $OSC)
1788 OSTIDX=$(index_from_ostuuid $OST)
1789 if [ $OST_DEACTIVE_IDX == -1 ]; then
1790 OST_DEACTIVE_IDX=$OSTIDX
1792 if [ $OSTIDX != $OST_DEACTIVE_IDX ]; then
1793 echo $OSC "is Deactivated:"
1794 do_facet $SINGLEMDS lctl --device %$OSC deactivate
1798 OSTIDX=$(index_from_ostuuid $OST)
1799 test_mkdir -p $DIR/$tdir
1800 $LFS setstripe -c 1 $DIR/$tdir # 1 stripe / file
1802 for OSC in $MDS_OSCS; do
1803 OST=$(osc_to_ost $OSC)
1804 OSTIDX=$(index_from_ostuuid $OST)
1805 if [ $OSTIDX == $OST_DEACTIVE_IDX ]; then
1806 echo $OST "is degraded:"
1807 do_facet ost$((OSTIDX+1)) lctl set_param -n \
1808 obdfilter.$OST.degraded=1
1813 createmany -o $DIR/$tdir/$tfile $fcount
1815 for OSC in $MDS_OSCS; do
1816 OST=$(osc_to_ost $OSC)
1817 OSTIDX=$(index_from_ostuuid $OST)
1818 if [ $OSTIDX == $OST_DEACTIVE_IDX ]; then
1819 echo $OST "is recovered from degraded:"
1820 do_facet ost$((OSTIDX+1)) lctl set_param -n \
1821 obdfilter.$OST.degraded=0
1823 do_facet $SINGLEMDS lctl --device %$OSC activate
1827 # all osp devices get activated, hence -1 stripe count restored
1830 # sleep 2*lod_qos_maxage seconds waiting for lod qos to notice osp
1831 # devices get activated.
1833 $LFS setstripe -c -1 $DIR/$tfile
1834 stripecnt=$($LFS getstripe -c $DIR/$tfile)
1836 [ $stripecnt -ne $OSTCOUNT ] &&
1837 error "Of $OSTCOUNT OSTs, only $stripecnt is available"
1840 run_test 27y "create files while OST0 is degraded and the rest inactive"
1846 lmm_count=$($GETSTRIPE -c $1)
1847 lmm_seq=$($GETSTRIPE -v $1 | awk '/lmm_seq/ { print $2 }')
1848 lmm_oid=$($GETSTRIPE -v $1 | awk '/lmm_object_id/ { print $2 }')
1850 local old_ifs="$IFS"
1852 fid=($($LFS path2fid $1))
1855 log "FID seq ${fid[1]}, oid ${fid[2]} ver ${fid[3]}"
1856 log "LOV seq $lmm_seq, oid $lmm_oid, count: $lmm_count"
1858 # compare lmm_seq and lu_fid->f_seq
1859 [ $lmm_seq = ${fid[1]} ] || { error "SEQ mismatch"; return 1; }
1860 # compare lmm_object_id and lu_fid->oid
1861 [ $lmm_oid = ${fid[2]} ] || { error "OID mismatch"; return 2; }
1863 # check the trusted.fid attribute of the OST objects of the file
1864 local have_obdidx=false
1866 $GETSTRIPE $1 | while read obdidx oid hex seq; do
1867 # skip lines up to and including "obdidx"
1868 [ -z "$obdidx" ] && break
1869 [ "$obdidx" = "obdidx" ] && have_obdidx=true && continue
1870 $have_obdidx || continue
1872 local ost=$((obdidx + 1))
1873 local dev=$(ostdevname $ost)
1876 log "want: stripe:$stripe_nr ost:$obdidx oid:$oid/$hex seq:$seq"
1878 seq=$(echo $seq | sed -e "s/^0x//g")
1879 if [ $seq == 0 ] || [ $(facet_fstype ost$ost) == zfs ]; then
1880 oid_hex=$(echo $oid)
1882 oid_hex=$(echo $hex | sed -e "s/^0x//g")
1884 local obj_file="O/$seq/d$((oid %32))/$oid_hex"
1888 # Don't unmount/remount the OSTs if we don't need to do that.
1889 # LU-2577 changes filter_fid to be smaller, so debugfs needs
1890 # update too, until that use mount/ll_decode_filter_fid/mount.
1891 # Re-enable when debugfs will understand new filter_fid.
1893 if [ $(facet_fstype ost$ost) == ldiskfs ]; then
1894 ff=$(do_facet ost$ost "$DEBUGFS -c -R 'stat $obj_file' \
1895 $dev 2>/dev/null" | grep "parent=")
1897 if [ -z "$ff" ]; then
1899 mount_fstype ost$ost
1900 ff=$(do_facet ost$ost $LL_DECODE_FILTER_FID \
1901 $(facet_mntpt ost$ost)/$obj_file)
1902 unmount_fstype ost$ost
1903 start ost$ost $dev $OST_MOUNT_OPTS
1907 [ -z "$ff" ] && error "$obj_file: no filter_fid info"
1909 echo "$ff" | sed -e 's#.*objid=#got: objid=#'
1911 # /mnt/O/0/d23/23: objid=23 seq=0 parent=[0x200000400:0x1e:0x1]
1912 # fid: objid=23 seq=0 parent=[0x200000400:0x1e:0x0] stripe=1
1914 # fid: parent=[0x200000400:0x1e:0x0] stripe=1 stripe_count=2 \
1915 # stripe_size=1048576 component_id=1 component_start=0 \
1916 # component_end=33554432
1917 local ff_parent=$(sed -e 's/.*parent=.//' <<<$ff)
1918 local ff_pseq=$(cut -d: -f1 <<<$ff_parent)
1919 local ff_poid=$(cut -d: -f2 <<<$ff_parent)
1921 if grep -q 'stripe=' <<<$ff; then
1922 ff_pstripe=$(sed -e 's/.*stripe=//' -e 's/ .*//' <<<$ff)
1924 # $LL_DECODE_FILTER_FID does not print "stripe="; look
1925 # into f_ver in this case. See comment on ff_parent.
1926 ff_pstripe=$(cut -d: -f3 <<<$ff_parent | sed -e 's/]//')
1929 if grep -q 'stripe_count=' <<<$ff; then
1930 local ff_scnt=$(sed -e 's/.*stripe_count=//' \
1931 -e 's/ .*//' <<<$ff)
1932 [ $lmm_count = $ff_scnt ] ||
1933 error "FF stripe count $lmm_count != $ff_scnt"
1935 # compare lmm_seq and filter_fid->ff_parent.f_seq
1936 [ $ff_pseq = $lmm_seq ] ||
1937 error "FF parent SEQ $ff_pseq != $lmm_seq"
1938 # compare lmm_object_id and filter_fid->ff_parent.f_oid
1939 [ $ff_poid = $lmm_oid ] ||
1940 error "FF parent OID $ff_poid != $lmm_oid"
1941 (($ff_pstripe == $stripe_nr)) ||
1942 error "FF stripe $ff_pstripe != $stripe_nr"
1944 stripe_nr=$((stripe_nr + 1))
1949 remote_ost_nodsh && skip "remote OST with nodsh" && return
1950 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1951 test_mkdir -p $DIR/$tdir
1953 $SETSTRIPE -c 1 -i 0 -S 64k $DIR/$tdir/$tfile-1 ||
1954 { error "setstripe -c -1 failed"; return 1; }
1955 # We need to send a write to every object to get parent FID info set.
1956 # This _should_ also work for setattr, but does not currently.
1957 # touch $DIR/$tdir/$tfile-1 ||
1958 dd if=/dev/zero of=$DIR/$tdir/$tfile-1 bs=1M count=1 ||
1959 { error "dd $tfile-1 failed"; return 2; }
1960 $SETSTRIPE -c -1 -i $((OSTCOUNT - 1)) -S 1M $DIR/$tdir/$tfile-2 ||
1961 { error "setstripe -c -1 failed"; return 3; }
1962 dd if=/dev/zero of=$DIR/$tdir/$tfile-2 bs=1M count=$OSTCOUNT ||
1963 { error "dd $tfile-2 failed"; return 4; }
1965 # make sure write RPCs have been sent to OSTs
1968 check_seq_oid $DIR/$tdir/$tfile-1 || return 5
1969 check_seq_oid $DIR/$tdir/$tfile-2 || return 6
1971 run_test 27z "check SEQ/OID on the MDT and OST filesystems"
1973 test_27A() { # b=19102
1974 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1975 local restore_size=$($GETSTRIPE -S $MOUNT)
1976 local restore_count=$($GETSTRIPE -c $MOUNT)
1977 local restore_offset=$($GETSTRIPE -i $MOUNT)
1978 $SETSTRIPE -c 0 -i -1 -S 0 $MOUNT
1979 wait_update $HOSTNAME "$GETSTRIPE -c $MOUNT | sed 's/ *//g'" "1" 20 ||
1980 error "stripe count $($GETSTRIPE -c $MOUNT) != 1"
1981 local default_size=$($GETSTRIPE -S $MOUNT)
1982 local default_offset=$($GETSTRIPE -i $MOUNT)
1983 local dsize=$((1024 * 1024))
1984 [ $default_size -eq $dsize ] ||
1985 error "stripe size $default_size != $dsize"
1986 [ $default_offset -eq -1 ] ||error "stripe offset $default_offset != -1"
1987 $SETSTRIPE -c $restore_count -i $restore_offset -S $restore_size $MOUNT
1989 run_test 27A "check filesystem-wide default LOV EA values"
1991 test_27B() { # LU-2523
1992 test_mkdir -p $DIR/$tdir
1993 rm -f $DIR/$tdir/f0 $DIR/$tdir/f1
1995 # open f1 with O_LOV_DELAY_CREATE
1997 # call setstripe ioctl on open file descriptor for f1
1999 multiop $DIR/$tdir/f1 oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:nB1c \
2003 # open f1 with O_LOV_DELAY_CREATE
2005 # call setstripe ioctl on open file descriptor for f1
2007 multiop $DIR/$tdir/f1 oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:uB1c
2009 # Allow multiop to fail in imitation of NFS's busted semantics.
2012 run_test 27B "call setstripe on open unlinked file/rename victim"
2014 test_27C() { #LU-2871
2015 [[ $OSTCOUNT -lt 2 ]] && skip "needs >= 2 OSTs" && return
2023 test_mkdir -p $DIR/$tdir
2025 for i in $(seq 0 $((OSTCOUNT - 1))); do
2026 # set stripe across all OSTs starting from OST$i
2027 $SETSTRIPE -i $i -c -1 $tfile$i
2028 # get striping information
2029 ost_idx=($($GETSTRIPE $tfile$i |
2030 tail -n $((OSTCOUNT + 1)) | awk '{print $1}'))
2034 [ ${#ost_idx[@]} -eq $OSTCOUNT ] ||
2035 error "${#ost_idx[@]} != $OSTCOUNT"
2037 for index in $(seq 0 $((OSTCOUNT - 1))); do
2039 for j in $(echo ${ost_idx[@]}); do
2040 if [ $index -eq $j ]; then
2046 error "Can not find $index in ${ost_idx[@]}"
2050 run_test 27C "check full striping across all OSTs"
2053 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs" && return
2054 [ -n "$FILESET" ] && skip "SKIP due to FILESET set" && return
2055 remote_mds_nodsh && skip "remote MDS with nodsh" && return
2056 local POOL=${POOL:-testpool}
2058 local last_ost=$(($OSTCOUNT - 1))
2060 local ost_list=$(seq $first_ost $ost_step $last_ost)
2061 local ost_range="$first_ost $last_ost $ost_step"
2063 test_mkdir -p $DIR/$tdir
2064 pool_add $POOL || error "pool_add failed"
2065 pool_add_targets $POOL $ost_range || error "pool_add_targets failed"
2068 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.8.55) ] &&
2070 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.9.55) ] &&
2071 skip27D += "-s 30,31"
2072 llapi_layout_test -d$DIR/$tdir -p$POOL -o$OSTCOUNT $skip27D ||
2073 error "llapi_layout_test failed"
2075 destroy_test_pools || error "destroy test pools failed"
2077 run_test 27D "validate llapi_layout API"
2079 # Verify that default_easize is increased from its initial value after
2080 # accessing a widely striped file.
2082 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs" && return
2083 [ $(lustre_version_code client) -lt $(version_code 2.5.57) ] &&
2084 skip "client does not have LU-3338 fix" && return
2086 # 72 bytes is the minimum space required to store striping
2087 # information for a file striped across one OST:
2088 # (sizeof(struct lov_user_md_v3) +
2089 # sizeof(struct lov_user_ost_data_v1))
2091 $LCTL set_param -n llite.*.default_easize $min_easize ||
2092 error "lctl set_param failed"
2093 local easize=$($LCTL get_param -n llite.*.default_easize)
2095 [ $easize -eq $min_easize ] ||
2096 error "failed to set default_easize"
2098 $LFS setstripe -c $OSTCOUNT $DIR/$tfile ||
2099 error "setstripe failed"
2103 easize=$($LCTL get_param -n llite.*.default_easize)
2105 [ $easize -gt $min_easize ] ||
2106 error "default_easize not updated"
2108 run_test 27E "check that default extended attribute size properly increases"
2110 test_27F() { # LU-5346/LU-7975
2111 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2112 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.8.51) ]] &&
2113 skip "Need MDS version at least 2.8.51" && return
2114 remote_ost_nodsh && skip "remote OST with nodsh" && return
2116 test_mkdir -p $DIR/$tdir
2118 $SETSTRIPE -c 2 $DIR/$tdir
2120 # stop all OSTs to reproduce situation for LU-7975 ticket
2121 for num in $(seq $OSTCOUNT); do
2125 # open/create f0 with O_LOV_DELAY_CREATE
2126 # truncate f0 to a non-0 size
2128 multiop $DIR/$tdir/f0 oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:T1050000c
2130 $CHECKSTAT -s 1050000 $DIR/$tdir/f0 || error "checkstat failed"
2131 # open/write it again to force delayed layout creation
2132 cat /etc/hosts > $DIR/$tdir/f0 &
2136 for num in $(seq $OSTCOUNT); do
2137 start ost$num $(ostdevname $num) $OST_MOUNT_OPTS ||
2138 error "ost$num failed to start"
2141 wait $catpid || error "cat failed"
2143 cmp /etc/hosts $DIR/$tdir/f0 || error "cmp failed"
2144 [[ $($GETSTRIPE -c $DIR/$tdir/f0) == 2 ]] || error "wrong stripecount"
2147 run_test 27F "Client resend delayed layout creation with non-zero size"
2149 # createtest also checks that device nodes are created and
2150 # then visible correctly (#2091)
2151 test_28() { # bug 2091
2153 $CREATETEST $DIR/d28/ct || error
2155 run_test 28 "create/mknod/mkdir with bad file types ============"
2158 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return 0
2159 sync; sleep 1; sync # flush out any dirty pages from previous tests
2166 declare -i LOCKCOUNTORIG=0
2167 for lock_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_count); do
2168 let LOCKCOUNTORIG=$LOCKCOUNTORIG+$lock_count
2170 [ $LOCKCOUNTORIG -eq 0 ] && error "No mdc lock count" && return 1
2172 declare -i LOCKUNUSEDCOUNTORIG=0
2173 for unused_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_unused_count); do
2174 let LOCKUNUSEDCOUNTORIG=$LOCKUNUSEDCOUNTORIG+$unused_count
2181 declare -i LOCKCOUNTCURRENT=0
2182 for lock_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_count); do
2183 let LOCKCOUNTCURRENT=$LOCKCOUNTCURRENT+$lock_count
2186 declare -i LOCKUNUSEDCOUNTCURRENT=0
2187 for unused_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_unused_count); do
2188 let LOCKUNUSEDCOUNTCURRENT=$LOCKUNUSEDCOUNTCURRENT+$unused_count
2191 if [[ $LOCKCOUNTCURRENT -gt $LOCKCOUNTORIG ]]; then
2192 $LCTL set_param -n ldlm.dump_namespaces ""
2193 error "CURRENT: $LOCKCOUNTCURRENT > $LOCKCOUNTORIG"
2194 $LCTL dk | sort -k4 -t: > $TMP/test_29.dk
2195 log "dumped log to $TMP/test_29.dk (bug 5793)"
2198 if [[ $LOCKUNUSEDCOUNTCURRENT -gt $LOCKUNUSEDCOUNTORIG ]]; then
2199 error "UNUSED: $LOCKUNUSEDCOUNTCURRENT > $LOCKUNUSEDCOUNTORIG"
2200 $LCTL dk | sort -k4 -t: > $TMP/test_29.dk
2201 log "dumped log to $TMP/test_29.dk (bug 5793)"
2205 run_test 29 "IT_GETATTR regression ============================"
2207 test_30a() { # was test_30
2208 cp $(which ls) $DIR || cp /bin/ls $DIR
2212 run_test 30a "execute binary from Lustre (execve) =============="
2215 cp `which ls` $DIR || cp /bin/ls $DIR
2217 $RUNAS $DIR/ls / || error
2220 run_test 30b "execute binary from Lustre as non-root ==========="
2222 test_30c() { # b=22376
2223 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2224 cp `which ls` $DIR || cp /bin/ls $DIR
2226 cancel_lru_locks mdc
2227 cancel_lru_locks osc
2228 $RUNAS $DIR/ls / || error
2231 run_test 30c "execute binary from Lustre without read perms ===="
2234 $OPENUNLINK $DIR/f31 $DIR/f31 || error
2235 $CHECKSTAT -a $DIR/f31 || error
2237 run_test 31a "open-unlink file =================================="
2240 touch $DIR/f31 || error
2241 ln $DIR/f31 $DIR/f31b || error
2242 $MULTIOP $DIR/f31b Ouc || error
2243 $CHECKSTAT -t file $DIR/f31 || error
2245 run_test 31b "unlink file with multiple links while open ======="
2248 touch $DIR/f31 || error
2249 ln $DIR/f31 $DIR/f31c || error
2250 multiop_bg_pause $DIR/f31 O_uc || return 1
2252 $MULTIOP $DIR/f31c Ouc
2253 kill -USR1 $MULTIPID
2256 run_test 31c "open-unlink file with multiple links ============="
2259 opendirunlink $DIR/d31d $DIR/d31d || error
2260 $CHECKSTAT -a $DIR/d31d || error
2262 run_test 31d "remove of open directory ========================="
2264 test_31e() { # bug 2904
2265 openfilleddirunlink $DIR/d31e || error
2267 run_test 31e "remove of open non-empty directory ==============="
2269 test_31f() { # bug 4554
2270 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2272 test_mkdir $DIR/d31f
2273 $SETSTRIPE -S 1048576 -c 1 $DIR/d31f
2274 cp /etc/hosts $DIR/d31f
2276 $GETSTRIPE $DIR/d31f/hosts
2277 multiop_bg_pause $DIR/d31f D_c || return 1
2280 rm -rv $DIR/d31f || error "first of $DIR/d31f"
2281 test_mkdir $DIR/d31f
2282 $SETSTRIPE -S 1048576 -c 1 $DIR/d31f
2283 cp /etc/hosts $DIR/d31f
2285 $GETSTRIPE $DIR/d31f/hosts
2286 multiop_bg_pause $DIR/d31f D_c || return 1
2289 kill -USR1 $MULTIPID || error "first opendir $MULTIPID not running"
2290 wait $MULTIPID || error "first opendir $MULTIPID failed"
2294 kill -USR1 $MULTIPID2 || error "second opendir $MULTIPID not running"
2295 wait $MULTIPID2 || error "second opendir $MULTIPID2 failed"
2298 run_test 31f "remove of open directory with open-unlink file ==="
2301 echo "-- cross directory link --"
2302 test_mkdir -c1 $DIR/${tdir}ga
2303 test_mkdir -c1 $DIR/${tdir}gb
2304 touch $DIR/${tdir}ga/f
2305 ln $DIR/${tdir}ga/f $DIR/${tdir}gb/g
2306 $CHECKSTAT -t file $DIR/${tdir}ga/f || error "source"
2307 [ `stat -c%h $DIR/${tdir}ga/f` == '2' ] || error "source nlink"
2308 $CHECKSTAT -t file $DIR/${tdir}gb/g || error "target"
2309 [ `stat -c%h $DIR/${tdir}gb/g` == '2' ] || error "target nlink"
2311 run_test 31g "cross directory link==============="
2314 echo "-- cross directory link --"
2315 test_mkdir -c1 $DIR/${tdir}
2316 test_mkdir -c1 $DIR/${tdir}/dir
2317 touch $DIR/${tdir}/f
2318 ln $DIR/${tdir}/f $DIR/${tdir}/dir/g
2319 $CHECKSTAT -t file $DIR/${tdir}/f || error "source"
2320 [ `stat -c%h $DIR/${tdir}/f` == '2' ] || error "source nlink"
2321 $CHECKSTAT -t file $DIR/${tdir}/dir/g || error "target"
2322 [ `stat -c%h $DIR/${tdir}/dir/g` == '2' ] || error "target nlink"
2324 run_test 31h "cross directory link under child==============="
2327 echo "-- cross directory link --"
2328 test_mkdir -c1 $DIR/$tdir
2329 test_mkdir -c1 $DIR/$tdir/dir
2330 touch $DIR/$tdir/dir/f
2331 ln $DIR/$tdir/dir/f $DIR/$tdir/g
2332 $CHECKSTAT -t file $DIR/$tdir/dir/f || error "source"
2333 [ `stat -c%h $DIR/$tdir/dir/f` == '2' ] || error "source nlink"
2334 $CHECKSTAT -t file $DIR/$tdir/g || error "target"
2335 [ `stat -c%h $DIR/$tdir/g` == '2' ] || error "target nlink"
2337 run_test 31i "cross directory link under parent==============="
2340 test_mkdir -c1 -p $DIR/$tdir
2341 test_mkdir -c1 -p $DIR/$tdir/dir1
2342 ln $DIR/$tdir/dir1 $DIR/$tdir/dir2 && error "ln for dir"
2343 link $DIR/$tdir/dir1 $DIR/$tdir/dir3 && error "link for dir"
2344 mlink $DIR/$tdir/dir1 $DIR/$tdir/dir4 && error "mlink for dir"
2345 mlink $DIR/$tdir/dir1 $DIR/$tdir/dir1 && error "mlink to the same dir"
2348 run_test 31j "link for directory==============="
2351 test_mkdir -c1 -p $DIR/$tdir
2353 touch $DIR/$tdir/exist
2354 mlink $DIR/$tdir/s $DIR/$tdir/t || error "mlink"
2355 mlink $DIR/$tdir/s $DIR/$tdir/exist && error "mlink to exist file"
2356 mlink $DIR/$tdir/s $DIR/$tdir/s && error "mlink to the same file"
2357 mlink $DIR/$tdir/s $DIR/$tdir && error "mlink to parent dir"
2358 mlink $DIR/$tdir $DIR/$tdir/s && error "mlink parent dir to target"
2359 mlink $DIR/$tdir/not-exist $DIR/$tdir/foo && error "mlink non-existing to new"
2360 mlink $DIR/$tdir/not-exist $DIR/$tdir/s && error "mlink non-existing to exist"
2363 run_test 31k "link to file: the same, non-existing, dir==============="
2369 touch $DIR/d31m2/exist
2370 mlink $DIR/d31m/s $DIR/d31m2/t || error "mlink"
2371 mlink $DIR/d31m/s $DIR/d31m2/exist && error "mlink to exist file"
2372 mlink $DIR/d31m/s $DIR/d31m2 && error "mlink to parent dir"
2373 mlink $DIR/d31m2 $DIR/d31m/s && error "mlink parent dir to target"
2374 mlink $DIR/d31m/not-exist $DIR/d31m2/foo && error "mlink non-existing to new"
2375 mlink $DIR/d31m/not-exist $DIR/d31m2/s && error "mlink non-existing to exist"
2378 run_test 31m "link to file: the same, non-existing, dir==============="
2381 touch $DIR/$tfile || error "cannot create '$DIR/$tfile'"
2382 nlink=$(stat --format=%h $DIR/$tfile)
2383 [ ${nlink:--1} -eq 1 ] || error "nlink is $nlink, expected 1"
2385 local cmd="exec $fd<$DIR/$tfile"
2388 trap "eval $cmd" EXIT
2389 nlink=$(stat --dereference --format=%h /proc/self/fd/$fd)
2390 [ ${nlink:--1} -eq 1 ] || error "nlink is $nlink, expected 1"
2391 rm $DIR/$tfile || error "cannot remove '$DIR/$tfile'"
2392 nlink=$(stat --dereference --format=%h /proc/self/fd/$fd)
2393 [ ${nlink:--1} -eq 0 ] || error "nlink is $nlink, expected 0"
2396 run_test 31n "check link count of unlinked file"
2399 local TEMPNAME=$(mktemp $1_XXXXXX)
2400 mlink $TEMPNAME $1 2> /dev/null &&
2401 echo "$BASHPID: link $TEMPNAME to $1 succeeded"
2405 test_31o() { # LU-2901
2406 test_mkdir -p $DIR/$tdir
2407 for LOOP in $(seq 100); do
2408 rm -f $DIR/$tdir/$tfile*
2409 for THREAD in $(seq 8); do
2410 link_one $DIR/$tdir/$tfile.$LOOP &
2413 local LINKS=$(ls -1 $DIR/$tdir | grep -c $tfile.$LOOP)
2414 [[ $LINKS -gt 1 ]] && ls $DIR/$tdir &&
2415 error "$LINKS duplicate links to $tfile.$LOOP" &&
2419 run_test 31o "duplicate hard links with same filename"
2422 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2424 test_mkdir $DIR/$tdir
2425 $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
2426 $LFS setdirstripe -D -c2 -t all_char $DIR/$tdir/striped_dir
2428 opendirunlink $DIR/$tdir/striped_dir/test1 ||
2429 error "open unlink test1 failed"
2430 opendirunlink $DIR/$tdir/striped_dir/test2 ||
2431 error "open unlink test2 failed"
2433 $CHECKSTAT -a $DIR/$tdir/striped_dir/test1 ||
2434 error "test1 still exists"
2435 $CHECKSTAT -a $DIR/$tdir/striped_dir/test2 ||
2436 error "test2 still exists"
2438 run_test 31p "remove of open striped directory"
2440 cleanup_test32_mount() {
2443 local loopdev=$(losetup -a | grep $EXT2_DEV | sed -ne 's/:.*$//p')
2444 $UMOUNT $DIR/$tdir/ext2-mountpoint || rc=$?
2445 losetup -d $loopdev || true
2451 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2452 echo "== more mountpoints and symlinks ================="
2453 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2454 trap cleanup_test32_mount EXIT
2455 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2456 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2457 $CHECKSTAT -t dir $DIR/$tdir/ext2-mountpoint/.. || error
2458 cleanup_test32_mount
2460 run_test 32a "stat d32a/ext2-mountpoint/.. ====================="
2463 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2464 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2465 trap cleanup_test32_mount EXIT
2466 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2467 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2468 ls -al $DIR/$tdir/ext2-mountpoint/.. || error
2469 cleanup_test32_mount
2471 run_test 32b "open d32b/ext2-mountpoint/.. ====================="
2474 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2475 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2476 trap cleanup_test32_mount EXIT
2477 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2478 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2479 test_mkdir -p $DIR/$tdir/d2/test_dir
2480 $CHECKSTAT -t dir $DIR/$tdir/ext2-mountpoint/../d2/test_dir || error
2481 cleanup_test32_mount
2483 run_test 32c "stat d32c/ext2-mountpoint/../d2/test_dir ========="
2486 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2487 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2488 trap cleanup_test32_mount EXIT
2489 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2490 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2491 test_mkdir -p $DIR/$tdir/d2/test_dir
2492 ls -al $DIR/$tdir/ext2-mountpoint/../d2/test_dir || error
2493 cleanup_test32_mount
2495 run_test 32d "open d32d/ext2-mountpoint/../d2/test_dir ========="
2498 [ -e $DIR/d32e ] && rm -fr $DIR/d32e
2499 test_mkdir -p $DIR/d32e/tmp
2500 TMP_DIR=$DIR/d32e/tmp
2501 ln -s $DIR/d32e $TMP_DIR/symlink11
2502 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
2503 $CHECKSTAT -t link $DIR/d32e/tmp/symlink11 || error
2504 $CHECKSTAT -t link $DIR/d32e/symlink01 || error
2506 run_test 32e "stat d32e/symlink->tmp/symlink->lustre-subdir ===="
2509 [ -e $DIR/d32f ] && rm -fr $DIR/d32f
2510 test_mkdir -p $DIR/d32f/tmp
2511 TMP_DIR=$DIR/d32f/tmp
2512 ln -s $DIR/d32f $TMP_DIR/symlink11
2513 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
2514 ls $DIR/d32f/tmp/symlink11 || error
2515 ls $DIR/d32f/symlink01 || error
2517 run_test 32f "open d32f/symlink->tmp/symlink->lustre-subdir ===="
2520 TMP_DIR=$DIR/$tdir/tmp
2521 test_mkdir -p $DIR/$tdir/tmp
2522 test_mkdir $DIR/${tdir}2
2523 ln -s $DIR/${tdir}2 $TMP_DIR/symlink12
2524 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
2525 $CHECKSTAT -t link $TMP_DIR/symlink12 || error
2526 $CHECKSTAT -t link $DIR/$tdir/symlink02 || error
2527 $CHECKSTAT -t dir -f $TMP_DIR/symlink12 || error
2528 $CHECKSTAT -t dir -f $DIR/$tdir/symlink02 || error
2530 run_test 32g "stat d32g/symlink->tmp/symlink->lustre-subdir/${tdir}2"
2533 rm -fr $DIR/$tdir $DIR/${tdir}2
2534 TMP_DIR=$DIR/$tdir/tmp
2535 test_mkdir -p $DIR/$tdir/tmp
2536 test_mkdir $DIR/${tdir}2
2537 ln -s $DIR/${tdir}2 $TMP_DIR/symlink12
2538 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
2539 ls $TMP_DIR/symlink12 || error
2540 ls $DIR/$tdir/symlink02 || error
2542 run_test 32h "open d32h/symlink->tmp/symlink->lustre-subdir/${tdir}2"
2545 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2546 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2547 trap cleanup_test32_mount EXIT
2548 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2549 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2550 touch $DIR/$tdir/test_file
2551 $CHECKSTAT -t file $DIR/$tdir/ext2-mountpoint/../test_file || error
2552 cleanup_test32_mount
2554 run_test 32i "stat d32i/ext2-mountpoint/../test_file ==========="
2557 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2558 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2559 trap cleanup_test32_mount EXIT
2560 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2561 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2562 touch $DIR/$tdir/test_file
2563 cat $DIR/$tdir/ext2-mountpoint/../test_file || error
2564 cleanup_test32_mount
2566 run_test 32j "open d32j/ext2-mountpoint/../test_file ==========="
2569 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2571 trap cleanup_test32_mount EXIT
2572 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2573 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint
2574 test_mkdir -p $DIR/$tdir/d2
2575 touch $DIR/$tdir/d2/test_file || error
2576 $CHECKSTAT -t file $DIR/$tdir/ext2-mountpoint/../d2/test_file || error
2577 cleanup_test32_mount
2579 run_test 32k "stat d32k/ext2-mountpoint/../d2/test_file ========"
2582 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2584 trap cleanup_test32_mount EXIT
2585 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2586 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2587 test_mkdir -p $DIR/$tdir/d2
2588 touch $DIR/$tdir/d2/test_file
2589 cat $DIR/$tdir/ext2-mountpoint/../d2/test_file || error
2590 cleanup_test32_mount
2592 run_test 32l "open d32l/ext2-mountpoint/../d2/test_file ========"
2596 test_mkdir -p $DIR/d32m/tmp
2597 TMP_DIR=$DIR/d32m/tmp
2598 ln -s $DIR $TMP_DIR/symlink11
2599 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
2600 $CHECKSTAT -t link $DIR/d32m/tmp/symlink11 || error
2601 $CHECKSTAT -t link $DIR/d32m/symlink01 || error
2603 run_test 32m "stat d32m/symlink->tmp/symlink->lustre-root ======"
2607 test_mkdir -p $DIR/d32n/tmp
2608 TMP_DIR=$DIR/d32n/tmp
2609 ln -s $DIR $TMP_DIR/symlink11
2610 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
2611 ls -l $DIR/d32n/tmp/symlink11 || error
2612 ls -l $DIR/d32n/symlink01 || error
2614 run_test 32n "open d32n/symlink->tmp/symlink->lustre-root ======"
2618 test_mkdir -p $DIR/d32o/tmp
2619 TMP_DIR=$DIR/d32o/tmp
2620 ln -s $DIR/$tfile $TMP_DIR/symlink12
2621 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
2622 $CHECKSTAT -t link $DIR/d32o/tmp/symlink12 || error
2623 $CHECKSTAT -t link $DIR/d32o/symlink02 || error
2624 $CHECKSTAT -t file -f $DIR/d32o/tmp/symlink12 || error
2625 $CHECKSTAT -t file -f $DIR/d32o/symlink02 || error
2627 run_test 32o "stat d32o/symlink->tmp/symlink->lustre-root/$tfile"
2637 test_mkdir -p $DIR/d32p/tmp
2639 TMP_DIR=$DIR/d32p/tmp
2641 ln -s $DIR/$tfile $TMP_DIR/symlink12
2643 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
2645 cat $DIR/d32p/tmp/symlink12 || error
2647 cat $DIR/d32p/symlink02 || error
2650 run_test 32p "open d32p/symlink->tmp/symlink->lustre-root/$tfile"
2653 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2654 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2655 trap cleanup_test32_mount EXIT
2656 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2657 touch $DIR/$tdir/ext2-mountpoint/under_the_mount
2658 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint
2659 ls $DIR/$tdir/ext2-mountpoint | grep "\<under_the_mount\>" && error
2660 cleanup_test32_mount
2662 run_test 32q "stat follows mountpoints in Lustre (should return error)"
2665 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2666 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2667 trap cleanup_test32_mount EXIT
2668 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2669 touch $DIR/$tdir/ext2-mountpoint/under_the_mount
2670 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint
2671 ls $DIR/$tdir/ext2-mountpoint | grep -q under_the_mount && error || true
2672 cleanup_test32_mount
2674 run_test 32r "opendir follows mountpoints in Lustre (should return error)"
2679 chmod 444 $DIR/$tfile
2680 chown $RUNAS_ID $DIR/$tfile
2682 $RUNAS $OPENFILE -f O_RDWR $DIR/$tfile && error || true
2685 run_test 33aa "write file with mode 444 (should return error) ===="
2689 test_mkdir -p $DIR/d33
2690 chown $RUNAS_ID $DIR/d33
2691 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $DIR/d33/f33|| error "create"
2692 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $DIR/d33/f33 && \
2693 error "open RDWR" || true
2695 run_test 33a "test open file(mode=0444) with O_RDWR (should return error)"
2699 test_mkdir -p $DIR/d33
2700 chown $RUNAS_ID $DIR/d33
2701 $RUNAS $OPENFILE -f 1286739555 $DIR/d33/f33 || true
2703 run_test 33b "test open file with malformed flags (No panic)"
2706 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2712 remote_ost_nodsh && skip "remote OST with nodsh" && return
2715 test_mkdir -p $DIR/d33
2716 # Read: 0, Write: 4, create/destroy: 2/0, stat: 1, punch: 0
2719 for ostnum in $(seq $OSTCOUNT); do
2720 # test-framework's OST numbering is one-based, while Lustre's
2722 ostname=$(printf "$FSNAME-OST%.4x" $((ostnum - 1)))
2723 # Parsing llobdstat's output sucks; we could grep the /proc
2724 # path, but that's likely to not be as portable as using the
2725 # llobdstat utility. So we parse lctl output instead.
2726 write_bytes=$(do_facet ost$ostnum lctl get_param -n \
2727 obdfilter/$ostname/stats |
2728 awk '/^write_bytes/ {print $7}' )
2729 echo "baseline_write_bytes@$OSTnum/$ostname=$write_bytes"
2730 if (( ${write_bytes:-0} > 0 ))
2737 $all_zeros || return 0
2740 echo foo > $DIR/d33/bar
2744 # Total up write_bytes after writing. We'd better find non-zeros.
2745 for ostnum in $(seq $OSTCOUNT); do
2746 ostname=$(printf "$FSNAME-OST%.4x" $((ostnum - 1)))
2747 write_bytes=$(do_facet ost$ostnum lctl get_param -n \
2748 obdfilter/$ostname/stats |
2749 awk '/^write_bytes/ {print $7}' )
2750 echo "write_bytes@$OSTnum/$ostname=$write_bytes"
2751 if (( ${write_bytes:-0} > 0 ))
2760 for ostnum in $(seq $OSTCOUNT); do
2761 ostname=$(printf "$FSNAME-OST%.4x" $((ostnum - 1)))
2762 echo "Check that write_bytes is present in obdfilter/*/stats:"
2763 do_facet ost$ostnum lctl get_param -n \
2764 obdfilter/$ostname/stats
2766 error "OST not keeping write_bytes stats (b22312)"
2769 run_test 33c "test llobdstat and write_bytes"
2772 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 2 MDTs" && return
2773 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2775 local remote_dir=$DIR/$tdir/remote_dir
2777 test_mkdir -p $DIR/$tdir
2778 $LFS mkdir -i $MDTIDX $remote_dir ||
2779 error "create remote directory failed"
2781 touch $remote_dir/$tfile
2782 chmod 444 $remote_dir/$tfile
2783 chown $RUNAS_ID $remote_dir/$tfile
2785 $RUNAS $OPENFILE -f O_RDWR $DIR/$tfile && error || true
2787 chown $RUNAS_ID $remote_dir
2788 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $remote_dir/f33 ||
2789 error "create" || true
2790 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $remote_dir/f33 &&
2791 error "open RDWR" || true
2792 $RUNAS $OPENFILE -f 1286739555 $remote_dir/f33 || true
2794 run_test 33d "openfile with 444 modes and malformed flags under remote dir"
2797 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2801 $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
2802 $LFS setdirstripe -i1 -c2 $DIR/$tdir/striped_dir1
2803 mkdir $DIR/$tdir/local_dir
2805 local s0_mode=$(stat -c%f $DIR/$tdir/striped_dir)
2806 local s1_mode=$(stat -c%f $DIR/$tdir/striped_dir1)
2807 local l_mode=$(stat -c%f $DIR/$tdir/local_dir)
2809 [ "$l_mode" = "$s0_mode" -a "$l_mode" = "$s1_mode" ] ||
2810 error "mkdir $l_mode striped0 $s0_mode striped1 $s1_mode"
2812 rmdir $DIR/$tdir/* || error "rmdir failed"
2815 $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
2816 $LFS setdirstripe -i1 -c2 $DIR/$tdir/striped_dir1
2817 mkdir $DIR/$tdir/local_dir
2819 s0_mode=$(stat -c%f $DIR/$tdir/striped_dir)
2820 s1_mode=$(stat -c%f $DIR/$tdir/striped_dir1)
2821 l_mode=$(stat -c%f $DIR/$tdir/local_dir)
2823 [ "$l_mode" = "$s0_mode" -a "$l_mode" = "$s1_mode" ] ||
2824 error "mkdir $l_mode striped0 $s0_mode striped1 $s1_mode 777"
2826 rmdir $DIR/$tdir/* || error "rmdir(umask 777) failed"
2829 $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
2830 $LFS setdirstripe -i1 -c2 $DIR/$tdir/striped_dir1
2831 mkdir $DIR/$tdir/local_dir
2833 s0_mode=$(stat -c%f $DIR/$tdir/striped_dir)
2834 s1_mode=$(stat -c%f $DIR/$tdir/striped_dir1)
2835 l_mode=$(stat -c%f $DIR/$tdir/local_dir)
2837 [ "$l_mode" = "$s0_mode" -a "$l_mode" = "$s1_mode" ] ||
2838 error "mkdir $l_mode striped0 $s0_mode striped1 $s1_mode 0"
2840 run_test 33e "mkdir and striped directory should have same mode"
2844 do_facet $SINGLEMDS $LCTL set_param mdt.*.enable_remote_dir_gid=0
2848 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2849 remote_mds_nodsh && skip "remote MDS with nodsh" && return
2852 chmod go+rwx $DIR/$tdir
2853 do_facet $SINGLEMDS $LCTL set_param mdt.*.enable_remote_dir_gid=-1
2854 trap cleanup_33f EXIT
2856 $RUNAS lfs mkdir -c$MDSCOUNT $DIR/$tdir/striped_dir ||
2857 error "cannot create striped directory"
2859 $RUNAS touch $DIR/$tdir/striped_dir/{0..16} ||
2860 error "cannot create files in striped directory"
2862 $RUNAS rm $DIR/$tdir/striped_dir/{0..16} ||
2863 error "cannot remove files in striped directory"
2865 $RUNAS rmdir $DIR/$tdir/striped_dir ||
2866 error "cannot remove striped directory"
2870 run_test 33f "nonroot user can create, access, and remove a striped directory"
2873 mkdir -p $DIR/$tdir/dir2
2875 local err=$($RUNAS mkdir $DIR/$tdir/dir2 2>&1)
2877 [[ $err =~ "exists" ]] || error "Not exists error"
2879 run_test 33g "nonroot user create already existing root created file"
2881 TEST_34_SIZE=${TEST_34_SIZE:-2000000000000}
2884 $MCREATE $DIR/f34 || error
2885 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" || error
2886 $TRUNCATE $DIR/f34 $TEST_34_SIZE || error
2887 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" || error
2888 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2890 run_test 34a "truncate file that has not been opened ==========="
2893 [ ! -f $DIR/f34 ] && test_34a
2894 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2895 $OPENFILE -f O_RDONLY $DIR/f34
2896 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" || error
2897 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2899 run_test 34b "O_RDONLY opening file doesn't create objects ====="
2902 [ ! -f $DIR/f34 ] && test_34a
2903 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2904 $OPENFILE -f O_RDWR $DIR/f34
2905 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" && error
2906 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2908 run_test 34c "O_RDWR opening file-with-size works =============="
2911 [ ! -f $DIR/f34 ] && test_34a
2912 dd if=/dev/zero of=$DIR/f34 conv=notrunc bs=4k count=1 || error
2913 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2916 run_test 34d "write to sparse file ============================="
2920 $MCREATE $DIR/f34e || error
2921 $TRUNCATE $DIR/f34e 1000 || error
2922 $CHECKSTAT -s 1000 $DIR/f34e || error
2923 $OPENFILE -f O_RDWR $DIR/f34e
2924 $CHECKSTAT -s 1000 $DIR/f34e || error
2926 run_test 34e "create objects, some with size and some without =="
2928 test_34f() { # bug 6242, 6243
2929 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2932 $MCREATE $DIR/f34f || error
2933 $TRUNCATE $DIR/f34f $SIZE34F || error "truncating $DIR/f3f to $SIZE34F"
2934 dd if=$DIR/f34f of=$TMP/f34f
2935 $CHECKSTAT -s $SIZE34F $TMP/f34f || error "$TMP/f34f not $SIZE34F bytes"
2936 dd if=/dev/zero of=$TMP/f34fzero bs=$SIZE34F count=1
2937 cmp $DIR/f34f $TMP/f34fzero || error "$DIR/f34f not all zero"
2938 cmp $TMP/f34f $TMP/f34fzero || error "$TMP/f34f not all zero"
2939 rm $TMP/f34f $TMP/f34fzero $DIR/f34f
2941 run_test 34f "read from a file with no objects until EOF ======="
2944 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2945 dd if=/dev/zero of=$DIR/$tfile bs=1 count=100 seek=$TEST_34_SIZE || error
2946 $TRUNCATE $DIR/$tfile $((TEST_34_SIZE / 2))|| error
2947 $CHECKSTAT -s $((TEST_34_SIZE / 2)) $DIR/$tfile || error "truncate failed"
2948 cancel_lru_locks osc
2949 $CHECKSTAT -s $((TEST_34_SIZE / 2)) $DIR/$tfile || \
2950 error "wrong size after lock cancel"
2952 $TRUNCATE $DIR/$tfile $TEST_34_SIZE || error
2953 $CHECKSTAT -s $TEST_34_SIZE $DIR/$tfile || \
2954 error "expanding truncate failed"
2955 cancel_lru_locks osc
2956 $CHECKSTAT -s $TEST_34_SIZE $DIR/$tfile || \
2957 error "wrong expanded size after lock cancel"
2959 run_test 34g "truncate long file ==============================="
2962 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2966 dd if=/dev/zero of=$DIR/$tfile bs=1M count=10 || error
2967 sync # Flush the cache so that multiop below does not block on cache
2968 # flush when getting the group lock
2969 $MULTIOP $DIR/$tfile OG${gid}T${sz}g${gid}c &
2972 # Since just timed wait is not good enough, let's do a sync write
2973 # that way we are sure enough time for a roundtrip + processing
2974 # passed + 2 seconds of extra margin.
2975 dd if=/dev/zero of=$DIR/${tfile}-1 bs=4096 oflag=direct count=1
2979 if [[ `ps h -o comm -p $MULTIPID` == "multiop" ]]; then
2980 error "Multiop blocked on ftruncate, pid=$MULTIPID"
2984 local nsz=`stat -c %s $DIR/$tfile`
2985 [[ $nsz == $sz ]] || error "New size wrong $nsz != $sz"
2987 run_test 34h "ftruncate file under grouplock should not block"
2990 cp /bin/sh $DIR/f35a
2992 chown $RUNAS_ID $DIR/f35a
2993 $RUNAS $DIR/f35a && error || true
2996 run_test 35a "exec file with mode 444 (should return and not leak) ====="
3000 utime $DIR/f36 || error
3002 run_test 36a "MDS utime check (mknod, utime) ==================="
3006 utime $DIR/f36 || error
3008 run_test 36b "OST utime check (open, utime) ===================="
3013 chown $RUNAS_ID $DIR/d36
3014 $RUNAS utime $DIR/d36/f36 || error
3016 run_test 36c "non-root MDS utime check (mknod, utime) =========="
3019 [ ! -d $DIR/d36 ] && test_36c
3020 echo "" > $DIR/d36/f36
3021 $RUNAS utime $DIR/d36/f36 || error
3023 run_test 36d "non-root OST utime check (open, utime) ==========="
3026 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID -- skipping" && return
3027 test_mkdir -p $DIR/$tdir
3028 touch $DIR/$tdir/$tfile
3029 $RUNAS utime $DIR/$tdir/$tfile && \
3030 error "utime worked, expected failure" || true
3032 run_test 36e "utime on non-owned file (should return error) ===="
3036 local LANG_SAVE=$LANG
3037 local LC_LANG_SAVE=$LC_LANG
3038 export LANG=C LC_LANG=C # for date language
3040 DATESTR="Dec 20 2000"
3041 test_mkdir -p $DIR/$tdir
3042 lctl set_param fail_loc=$fl
3044 cp /etc/hosts $DIR/$tdir/$tfile
3045 sync & # write RPC generated with "current" inode timestamp, but delayed
3047 touch --date="$DATESTR" $DIR/$tdir/$tfile # setattr timestamp in past
3048 LS_BEFORE="`ls -l $DIR/$tdir/$tfile`" # old timestamp from client cache
3049 cancel_lru_locks osc
3050 LS_AFTER="`ls -l $DIR/$tdir/$tfile`" # timestamp from OST object
3052 [ "$LS_BEFORE" != "$LS_AFTER" ] && \
3053 echo "BEFORE: $LS_BEFORE" && \
3054 echo "AFTER : $LS_AFTER" && \
3055 echo "WANT : $DATESTR" && \
3056 error "$DIR/$tdir/$tfile timestamps changed" || true
3058 export LANG=$LANG_SAVE LC_LANG=$LC_LANG_SAVE
3062 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3063 #define OBD_FAIL_OST_BRW_PAUSE_BULK 0x214
3064 subr_36fh "0x80000214"
3066 run_test 36f "utime on file racing with OST BRW write =========="
3069 remote_ost_nodsh && skip "remote OST with nodsh" && return
3070 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3075 test_mkdir -p $DIR/$tdir
3076 fmd_max_age=$(do_facet ost1 \
3077 "lctl get_param -n obdfilter.*.client_cache_seconds 2> /dev/null | \
3080 fmd_before=$(do_facet ost1 \
3081 "awk '/ll_fmd_cache/ {print \\\$2}' /proc/slabinfo")
3082 touch $DIR/$tdir/$tfile
3083 sleep $((fmd_max_age + 12))
3084 fmd_after=$(do_facet ost1 \
3085 "awk '/ll_fmd_cache/ {print \\\$2}' /proc/slabinfo")
3087 echo "fmd_before: $fmd_before"
3088 echo "fmd_after: $fmd_after"
3089 [[ $fmd_after -gt $fmd_before ]] &&
3090 echo "AFTER: $fmd_after > BEFORE: $fmd_before" &&
3091 error "fmd didn't expire after ping" || true
3093 run_test 36g "filter mod data cache expiry ====================="
3096 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3097 #define OBD_FAIL_OST_BRW_PAUSE_BULK2 0x227
3098 subr_36fh "0x80000227"
3100 run_test 36h "utime on file racing with OST BRW write =========="
3103 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
3105 test_mkdir $DIR/$tdir
3106 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR/$tdir/striped_dir
3108 local mtime=$(stat -c%Y $DIR/$tdir/striped_dir)
3109 local new_mtime=$((mtime + 200))
3111 #change Modify time of striped dir
3112 touch -m -d @$new_mtime $DIR/$tdir/striped_dir ||
3113 error "change mtime failed"
3115 local got=$(stat -c%Y $DIR/$tdir/striped_dir)
3117 [ "$new_mtime" = "$got" ] || error "expect $new_mtime got $got"
3119 run_test 36i "change mtime on striped directory"
3121 # test_37 - duplicate with tests 32q 32r
3124 local file=$DIR/$tfile
3126 openfile -f O_DIRECTORY $file
3129 [ $RC -eq 0 ] && error "opened file $file with O_DIRECTORY" || true
3130 [ $RC -eq $ENOTDIR ] || error "error $RC should be ENOTDIR ($ENOTDIR)"
3132 run_test 38 "open a regular file with O_DIRECTORY should return -ENOTDIR ==="
3134 test_39a() { # was test_39
3136 touch $DIR/${tfile}2
3137 # ls -l $DIR/$tfile $DIR/${tfile}2
3138 # ls -lu $DIR/$tfile $DIR/${tfile}2
3139 # ls -lc $DIR/$tfile $DIR/${tfile}2
3141 $OPENFILE -f O_CREAT:O_TRUNC:O_WRONLY $DIR/${tfile}2
3142 if [ ! $DIR/${tfile}2 -nt $DIR/$tfile ]; then
3144 ls -l --full-time $DIR/$tfile $DIR/${tfile}2
3146 ls -lu --full-time $DIR/$tfile $DIR/${tfile}2
3148 ls -lc --full-time $DIR/$tfile $DIR/${tfile}2
3149 error "O_TRUNC didn't change timestamps"
3152 run_test 39a "mtime changed on create ==========================="
3155 test_mkdir -p -c1 $DIR/$tdir
3156 cp -p /etc/passwd $DIR/$tdir/fopen
3157 cp -p /etc/passwd $DIR/$tdir/flink
3158 cp -p /etc/passwd $DIR/$tdir/funlink
3159 cp -p /etc/passwd $DIR/$tdir/frename
3160 ln $DIR/$tdir/funlink $DIR/$tdir/funlink2
3163 echo "aaaaaa" >> $DIR/$tdir/fopen
3164 echo "aaaaaa" >> $DIR/$tdir/flink
3165 echo "aaaaaa" >> $DIR/$tdir/funlink
3166 echo "aaaaaa" >> $DIR/$tdir/frename
3168 local open_new=`stat -c %Y $DIR/$tdir/fopen`
3169 local link_new=`stat -c %Y $DIR/$tdir/flink`
3170 local unlink_new=`stat -c %Y $DIR/$tdir/funlink`
3171 local rename_new=`stat -c %Y $DIR/$tdir/frename`
3173 cat $DIR/$tdir/fopen > /dev/null
3174 ln $DIR/$tdir/flink $DIR/$tdir/flink2
3175 rm -f $DIR/$tdir/funlink2
3176 mv -f $DIR/$tdir/frename $DIR/$tdir/frename2
3178 for (( i=0; i < 2; i++ )) ; do
3179 local open_new2=`stat -c %Y $DIR/$tdir/fopen`
3180 local link_new2=`stat -c %Y $DIR/$tdir/flink`
3181 local unlink_new2=`stat -c %Y $DIR/$tdir/funlink`
3182 local rename_new2=`stat -c %Y $DIR/$tdir/frename2`
3184 [ $open_new2 -eq $open_new ] || error "open file reverses mtime"
3185 [ $link_new2 -eq $link_new ] || error "link file reverses mtime"
3186 [ $unlink_new2 -eq $unlink_new ] || error "unlink file reverses mtime"
3187 [ $rename_new2 -eq $rename_new ] || error "rename file reverses mtime"
3189 cancel_lru_locks osc
3190 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3193 run_test 39b "mtime change on open, link, unlink, rename ======"
3195 # this should be set to past
3196 TEST_39_MTIME=`date -d "1 year ago" +%s`
3202 local mtime0=`stat -c %Y $DIR1/$tfile`
3204 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3205 local mtime1=`stat -c %Y $DIR1/$tfile`
3206 [ "$mtime1" = $TEST_39_MTIME ] || \
3207 error "mtime is not set to past: $mtime1, should be $TEST_39_MTIME"
3210 echo hello >> $DIR1/$tfile
3212 local mtime2=`stat -c %Y $DIR1/$tfile`
3213 [ "$mtime2" -ge "$d1" ] && [ "$mtime2" -le "$d2" ] || \
3214 error "mtime is not updated on write: $d1 <= $mtime2 <= $d2"
3216 mv $DIR1/$tfile $DIR1/$tfile-1
3218 for (( i=0; i < 2; i++ )) ; do
3219 local mtime3=`stat -c %Y $DIR1/$tfile-1`
3220 [ "$mtime2" = "$mtime3" ] || \
3221 error "mtime ($mtime2) changed (to $mtime3) on rename"
3223 cancel_lru_locks osc
3224 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3227 run_test 39c "mtime change on rename ==========================="
3231 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3234 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3236 for (( i=0; i < 2; i++ )) ; do
3237 local mtime=`stat -c %Y $DIR1/$tfile`
3238 [ $mtime = $TEST_39_MTIME ] || \
3239 error "mtime($mtime) is not set to $TEST_39_MTIME"
3241 cancel_lru_locks osc
3242 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3245 run_test 39d "create, utime, stat =============================="
3249 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3251 local mtime1=`stat -c %Y $DIR1/$tfile`
3253 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3255 for (( i=0; i < 2; i++ )) ; do
3256 local mtime2=`stat -c %Y $DIR1/$tfile`
3257 [ $mtime2 = $TEST_39_MTIME ] || \
3258 error "mtime($mtime2) is not set to $TEST_39_MTIME"
3260 cancel_lru_locks osc
3261 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3264 run_test 39e "create, stat, utime, stat ========================"
3268 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3270 mtime1=`stat -c %Y $DIR1/$tfile`
3273 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3275 for (( i=0; i < 2; i++ )) ; do
3276 local mtime2=`stat -c %Y $DIR1/$tfile`
3277 [ $mtime2 = $TEST_39_MTIME ] || \
3278 error "mtime($mtime2) is not set to $TEST_39_MTIME"
3280 cancel_lru_locks osc
3281 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3284 run_test 39f "create, stat, sleep, utime, stat ================="
3288 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3289 echo hello >> $DIR1/$tfile
3290 local mtime1=`stat -c %Y $DIR1/$tfile`
3293 chmod o+r $DIR1/$tfile
3295 for (( i=0; i < 2; i++ )) ; do
3296 local mtime2=`stat -c %Y $DIR1/$tfile`
3297 [ "$mtime1" = "$mtime2" ] || \
3298 error "lost mtime: $mtime2, should be $mtime1"
3300 cancel_lru_locks osc
3301 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3304 run_test 39g "write, chmod, stat ==============================="
3308 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3313 echo hello >> $DIR1/$tfile
3314 local mtime1=`stat -c %Y $DIR1/$tfile`
3316 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3318 if [ "$d1" != "$d2" ]; then
3319 echo "write and touch not within one second"
3321 for (( i=0; i < 2; i++ )) ; do
3322 local mtime2=`stat -c %Y $DIR1/$tfile`
3323 [ "$mtime2" = $TEST_39_MTIME ] || \
3324 error "lost mtime: $mtime2, should be $TEST_39_MTIME"
3326 cancel_lru_locks osc
3327 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3331 run_test 39h "write, utime within one second, stat ============="
3334 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3338 echo hello >> $DIR1/$tfile
3339 local mtime1=`stat -c %Y $DIR1/$tfile`
3341 mv $DIR1/$tfile $DIR1/$tfile-1
3343 for (( i=0; i < 2; i++ )) ; do
3344 local mtime2=`stat -c %Y $DIR1/$tfile-1`
3346 [ "$mtime1" = "$mtime2" ] || \
3347 error "lost mtime: $mtime2, should be $mtime1"
3349 cancel_lru_locks osc
3350 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3353 run_test 39i "write, rename, stat =============================="
3356 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3357 start_full_debug_logging
3361 #define OBD_FAIL_OSC_DELAY_SETTIME 0x412
3362 lctl set_param fail_loc=0x80000412
3363 multiop_bg_pause $DIR1/$tfile oO_RDWR:w2097152_c ||
3364 error "multiop failed"
3366 local mtime1=`stat -c %Y $DIR1/$tfile`
3368 mv $DIR1/$tfile $DIR1/$tfile-1
3370 kill -USR1 $multipid
3371 wait $multipid || error "multiop close failed"
3373 for (( i=0; i < 2; i++ )) ; do
3374 local mtime2=`stat -c %Y $DIR1/$tfile-1`
3375 [ "$mtime1" = "$mtime2" ] ||
3376 error "mtime is lost on close: $mtime2, " \
3379 cancel_lru_locks osc
3380 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3382 lctl set_param fail_loc=0
3383 stop_full_debug_logging
3385 run_test 39j "write, rename, close, stat ======================="
3388 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3392 multiop_bg_pause $DIR1/$tfile oO_RDWR:w2097152_c || error "multiop failed"
3394 local mtime1=`stat -c %Y $DIR1/$tfile`
3396 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3398 kill -USR1 $multipid
3399 wait $multipid || error "multiop close failed"
3401 for (( i=0; i < 2; i++ )) ; do
3402 local mtime2=`stat -c %Y $DIR1/$tfile`
3404 [ "$mtime2" = $TEST_39_MTIME ] || \
3405 error "mtime is lost on close: $mtime2, should be $TEST_39_MTIME"
3407 cancel_lru_locks osc
3408 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3411 run_test 39k "write, utime, close, stat ========================"
3413 # this should be set to future
3414 TEST_39_ATIME=`date -d "1 year" +%s`
3417 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3418 remote_mds_nodsh && skip "remote MDS with nodsh" && return
3419 local atime_diff=$(do_facet $SINGLEMDS \
3420 lctl get_param -n mdd.*MDT0000*.atime_diff)
3424 # test setting directory atime to future
3425 touch -a -d @$TEST_39_ATIME $DIR/$tdir
3426 local atime=$(stat -c %X $DIR/$tdir)
3427 [ "$atime" = $TEST_39_ATIME ] ||
3428 error "atime is not set to future: $atime, $TEST_39_ATIME"
3430 # test setting directory atime from future to now
3431 local now=$(date +%s)
3432 touch -a -d @$now $DIR/$tdir
3434 atime=$(stat -c %X $DIR/$tdir)
3435 [ "$atime" -eq "$now" ] ||
3436 error "atime is not updated from future: $atime, $now"
3438 do_facet $SINGLEMDS lctl set_param -n mdd.*MDT0000*.atime_diff=2
3441 # test setting directory atime when now > dir atime + atime_diff
3442 local d1=$(date +%s)
3444 local d2=$(date +%s)
3445 cancel_lru_locks mdc
3446 atime=$(stat -c %X $DIR/$tdir)
3447 [ "$atime" -ge "$d1" -a "$atime" -le "$d2" ] ||
3448 error "atime is not updated : $atime, should be $d2"
3450 do_facet $SINGLEMDS lctl set_param -n mdd.*MDT0000*.atime_diff=60
3453 # test not setting directory atime when now < dir atime + atime_diff
3455 cancel_lru_locks mdc
3456 atime=$(stat -c %X $DIR/$tdir)
3457 [ "$atime" -ge "$d1" -a "$atime" -le "$d2" ] ||
3458 error "atime is updated to $atime, should remain $d1<atime<$d2"
3460 do_facet $SINGLEMDS \
3461 lctl set_param -n mdd.*MDT0000*.atime_diff=$atime_diff
3463 run_test 39l "directory atime update ==========================="
3466 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3469 local far_past_mtime=$(date -d "May 29 1953" +%s)
3470 local far_past_atime=$(date -d "Dec 17 1903" +%s)
3472 touch -m -d @$far_past_mtime $DIR1/$tfile
3473 touch -a -d @$far_past_atime $DIR1/$tfile
3475 for (( i=0; i < 2; i++ )) ; do
3476 local timestamps=$(stat -c "%X %Y" $DIR1/$tfile)
3477 [ "$timestamps" = "$far_past_atime $far_past_mtime" ] || \
3478 error "atime or mtime set incorrectly"
3480 cancel_lru_locks osc
3481 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3484 run_test 39m "test atime and mtime before 1970"
3486 test_39n() { # LU-3832
3487 remote_mds_nodsh && skip "remote MDS with nodsh" && return
3488 local atime_diff=$(do_facet $SINGLEMDS \
3489 lctl get_param -n mdd.*MDT0000*.atime_diff)
3494 do_facet $SINGLEMDS lctl set_param -n mdd.*MDT0000*.atime_diff=1
3497 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 status=noxfer
3498 atime0=$(stat -c %X $DIR/$tfile)
3501 $MULTIOP $DIR/$tfile oO_RDONLY:O_NOATIME:r4096c
3502 atime1=$(stat -c %X $DIR/$tfile)
3505 cancel_lru_locks mdc
3506 cancel_lru_locks osc
3507 $MULTIOP $DIR/$tfile oO_RDONLY:O_NOATIME:r4096c
3508 atime2=$(stat -c %X $DIR/$tfile)
3510 do_facet $SINGLEMDS \
3511 lctl set_param -n mdd.*MDT0000*.atime_diff=$atime_diff
3513 [ "$atime0" -eq "$atime1" ] || error "atime0 $atime0 != atime1 $atime1"
3514 [ "$atime1" -eq "$atime2" ] || error "atime0 $atime0 != atime1 $atime1"
3516 run_test 39n "check that O_NOATIME is honored"
3519 TESTDIR=$DIR/$tdir/$tfile
3520 [ -e $TESTDIR ] && rm -rf $TESTDIR
3527 links2=$(stat -c %h .)
3528 [ $(($links1 + 2)) != $links2 ] &&
3529 error "wrong links count $(($links1 + 2)) != $links2"
3531 links3=$(stat -c %h .)
3532 [ $(($links1 + 1)) != $links3 ] &&
3533 error "wrong links count $links1 != $links3"
3536 run_test 39o "directory cached attributes updated after create ========"
3539 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 2 MDTs" && return
3541 TESTDIR=$DIR/$tdir/$tfile
3542 [ -e $TESTDIR ] && rm -rf $TESTDIR
3543 test_mkdir -p $TESTDIR
3547 $LFS mkdir -i $MDTIDX $TESTDIR/remote_dir1
3548 $LFS mkdir -i $MDTIDX $TESTDIR/remote_dir2
3550 links2=$(stat -c %h .)
3551 [ $(($links1 + 2)) != $links2 ] &&
3552 error "wrong links count $(($links1 + 2)) != $links2"
3554 links3=$(stat -c %h .)
3555 [ $(($links1 + 1)) != $links3 ] &&
3556 error "wrong links count $links1 != $links3"
3559 run_test 39p "remote directory cached attributes updated after create ========"
3562 test_39q() { # LU-8041
3563 local testdir=$DIR/$tdir
3565 multiop_bg_pause $testdir D_c || error "multiop failed"
3567 cancel_lru_locks mdc
3568 kill -USR1 $multipid
3569 local atime=$(stat -c %X $testdir)
3570 [ "$atime" -ne 0 ] || error "atime is zero"
3572 run_test 39q "close won't zero out atime"
3575 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1
3576 $RUNAS $OPENFILE -f O_WRONLY:O_TRUNC $DIR/$tfile &&
3577 error "openfile O_WRONLY:O_TRUNC $tfile failed"
3578 $CHECKSTAT -t file -s 4096 $DIR/$tfile ||
3579 error "$tfile is not 4096 bytes in size"
3581 run_test 40 "failed open(O_TRUNC) doesn't truncate ============="
3585 small_write $DIR/f41 18
3587 run_test 41 "test small file write + fstat ====================="
3589 count_ost_writes() {
3590 lctl get_param -n osc.*.stats |
3591 awk -vwrites=0 '/ost_write/ { writes += $2 } \
3592 END { printf("%0.0f", writes) }'
3599 BG_DIRTY_RATIO_SAVE=10
3600 MAX_BG_DIRTY_RATIO=25
3604 # in 2.6, restore /proc/sys/vm/dirty_writeback_centisecs,
3605 # dirty_ratio, dirty_background_ratio
3606 if [ -f /proc/sys/vm/dirty_writeback_centisecs ]; then
3607 sysctl -w vm.dirty_writeback_centisecs=$WRITEBACK_SAVE
3608 sysctl -w vm.dirty_background_ratio=$BG_DIRTY_RATIO_SAVE
3609 sysctl -w vm.dirty_ratio=$DIRTY_RATIO_SAVE
3611 # if file not here, we are a 2.4 kernel
3612 kill -CONT `pidof kupdated`
3617 # setup the trap first, so someone cannot exit the test at the
3618 # exact wrong time and mess up a machine
3619 trap start_writeback EXIT
3620 # in 2.6, save and 0 /proc/sys/vm/dirty_writeback_centisecs
3621 if [ -f /proc/sys/vm/dirty_writeback_centisecs ]; then
3622 WRITEBACK_SAVE=`sysctl -n vm.dirty_writeback_centisecs`
3623 sysctl -w vm.dirty_writeback_centisecs=0
3624 sysctl -w vm.dirty_writeback_centisecs=0
3625 # save and increase /proc/sys/vm/dirty_ratio
3626 DIRTY_RATIO_SAVE=`sysctl -n vm.dirty_ratio`
3627 sysctl -w vm.dirty_ratio=$MAX_DIRTY_RATIO
3628 # save and increase /proc/sys/vm/dirty_background_ratio
3629 BG_DIRTY_RATIO_SAVE=`sysctl -n vm.dirty_background_ratio`
3630 sysctl -w vm.dirty_background_ratio=$MAX_BG_DIRTY_RATIO
3632 # if file not here, we are a 2.4 kernel
3633 kill -STOP `pidof kupdated`
3637 # ensure that all stripes have some grant before we test client-side cache
3639 for i in `seq -f $DIR/f42-%g 1 $OSTCOUNT`; do
3640 dd if=/dev/zero of=$i bs=4k count=1
3645 # Tests 42* verify that our behaviour is correct WRT caching, file closure,
3646 # file truncation, and file removal.
3648 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3650 cancel_lru_locks osc
3652 sync; sleep 1; sync # just to be safe
3653 BEFOREWRITES=`count_ost_writes`
3654 lctl get_param -n osc.*[oO][sS][cC][_-]*.cur_grant_bytes | grep "[0-9]"
3655 dd if=/dev/zero of=$DIR/f42a bs=1024 count=100
3656 AFTERWRITES=`count_ost_writes`
3657 [ $BEFOREWRITES -eq $AFTERWRITES ] || \
3658 error "$BEFOREWRITES < $AFTERWRITES"
3661 run_test 42a "ensure that we don't flush on close"
3664 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3666 cancel_lru_locks osc
3669 dd if=/dev/zero of=$DIR/f42b bs=1024 count=100
3670 BEFOREWRITES=$(count_ost_writes)
3671 $MUNLINK $DIR/f42b || error "$MUNLINK $DIR/f42b: $?"
3672 AFTERWRITES=$(count_ost_writes)
3673 if [[ $BEFOREWRITES -lt $AFTERWRITES ]]; then
3674 error "$BEFOREWRITES < $AFTERWRITES on unlink"
3676 BEFOREWRITES=$(count_ost_writes)
3677 sync || error "sync: $?"
3678 AFTERWRITES=$(count_ost_writes)
3679 if [[ $BEFOREWRITES -lt $AFTERWRITES ]]; then
3680 error "$BEFOREWRITES < $AFTERWRITES on sync"
3682 dmesg | grep 'error from obd_brw_async' && error 'error writing back'
3686 run_test 42b "test destroy of file with cached dirty data ======"
3688 # if these tests just want to test the effect of truncation,
3689 # they have to be very careful. consider:
3690 # - the first open gets a {0,EOF}PR lock
3691 # - the first write conflicts and gets a {0, count-1}PW
3692 # - the rest of the writes are under {count,EOF}PW
3693 # - the open for truncate tries to match a {0,EOF}PR
3694 # for the filesize and cancels the PWs.
3695 # any number of fixes (don't get {0,EOF} on open, match
3696 # composite locks, do smarter file size management) fix
3697 # this, but for now we want these tests to verify that
3698 # the cancellation with truncate intent works, so we
3699 # start the file with a full-file pw lock to match against
3700 # until the truncate.
3705 cancel_lru_locks osc
3707 # prime the file with 0,EOF PW to match
3711 # now the real test..
3712 dd if=/dev/zero of=$file bs=1024 count=100
3713 BEFOREWRITES=`count_ost_writes`
3714 $TRUNCATE $file $offset
3715 cancel_lru_locks osc
3716 AFTERWRITES=`count_ost_writes`
3721 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3723 [ $BEFOREWRITES -eq $AFTERWRITES ] && \
3724 error "beforewrites $BEFOREWRITES == afterwrites $AFTERWRITES on truncate"
3727 run_test 42c "test partial truncate of file with cached dirty data"
3730 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3732 [ $BEFOREWRITES -eq $AFTERWRITES ] || \
3733 error "beforewrites $BEFOREWRITES != afterwrites $AFTERWRITES on truncate"
3736 run_test 42d "test complete truncate of file with cached dirty data"
3738 test_42e() { # bug22074
3739 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3740 local TDIR=$DIR/${tdir}e
3741 local pagesz=$(page_size)
3742 local pages=16 # hardcoded 16 pages, don't change it.
3743 local files=$((OSTCOUNT * 500)) # hopefully 500 files on each OST
3744 local proc_osc0="osc.${FSNAME}-OST0000-osc-[^MDT]*"
3748 test_mkdir -p $DIR/${tdir}e
3749 $SETSTRIPE -c 1 $TDIR
3750 createmany -o $TDIR/f $files
3752 max_dirty_mb=$($LCTL get_param -n $proc_osc0/max_dirty_mb)
3754 # we assume that with $OSTCOUNT files, at least one of them will
3755 # be allocated on OST0.
3756 warmup_files=$((OSTCOUNT * max_dirty_mb))
3757 createmany -o $TDIR/w $warmup_files
3759 # write a large amount of data into one file and sync, to get good
3760 # avail_grant number from OST.
3761 for ((i=0; i<$warmup_files; i++)); do
3762 idx=$($GETSTRIPE -i $TDIR/w$i)
3763 [ $idx -ne 0 ] && continue
3764 dd if=/dev/zero of=$TDIR/w$i bs="$max_dirty_mb"M count=1
3767 [[ $i -gt $warmup_files ]] && error "OST0 is still cold"
3769 $LCTL get_param $proc_osc0/cur_dirty_bytes
3770 $LCTL get_param $proc_osc0/cur_grant_bytes
3772 # create as much dirty pages as we can while not to trigger the actual
3773 # RPCs directly. but depends on the env, VFS may trigger flush during this
3774 # period, hopefully we are good.
3775 for ((i=0; i<$warmup_files; i++)); do
3776 idx=$($GETSTRIPE -i $TDIR/w$i)
3777 [ $idx -ne 0 ] && continue
3778 dd if=/dev/zero of=$TDIR/w$i bs=1M count=1 2>/dev/null
3780 $LCTL get_param $proc_osc0/cur_dirty_bytes
3781 $LCTL get_param $proc_osc0/cur_grant_bytes
3783 # perform the real test
3784 $LCTL set_param $proc_osc0/rpc_stats 0
3785 for ((;i<$files; i++)); do
3786 [ $($GETSTRIPE -i $TDIR/f$i) -eq 0 ] || continue
3787 dd if=/dev/zero of=$TDIR/f$i bs=$pagesz count=$pages 2>/dev/null
3790 $LCTL get_param $proc_osc0/rpc_stats
3793 local have_ppr=false
3794 $LCTL get_param $proc_osc0/rpc_stats |
3795 while read PPR RRPC RPCT RCUM BAR WRPC WPCT WCUM; do
3796 # skip lines until we are at the RPC histogram data
3797 [ "$PPR" == "pages" ] && have_ppr=true && continue
3798 $have_ppr || continue
3800 # we only want the percent stat for < 16 pages
3801 [[ $(echo $PPR | tr -d ':') -ge $pages ]] && break
3803 percent=$((percent + WPCT))
3804 if [[ $percent -gt 15 ]]; then
3805 error "less than 16-pages write RPCs" \
3812 run_test 42e "verify sub-RPC writes are not done synchronously"
3814 test_43A() { # was test_43
3815 test_mkdir -p $DIR/$tdir
3816 cp -p /bin/ls $DIR/$tdir/$tfile
3817 $MULTIOP $DIR/$tdir/$tfile Ow_c &
3819 # give multiop a chance to open
3822 $DIR/$tdir/$tfile && error "execute $DIR/$tdir/$tfile succeeded" || true
3825 run_test 43A "execution of file opened for write should return -ETXTBSY"
3828 test_mkdir $DIR/$tdir
3829 cp -p $(which $MULTIOP) $DIR/$tdir/multiop ||
3830 cp -p multiop $DIR/$tdir/multiop
3831 MULTIOP_PROG=$DIR/$tdir/multiop multiop_bg_pause $TMP/$tfile.junk O_c ||
3832 error "multiop open $TMP/$tfile.junk failed"
3834 $MULTIOP $DIR/$tdir/multiop Oc && error "expected error, got success"
3835 kill -USR1 $MULTIOP_PID || error "kill -USR1 PID $MULTIOP_PID failed"
3836 wait $MULTIOP_PID || error "wait PID $MULTIOP_PID failed"
3838 run_test 43a "open(RDWR) of file being executed should return -ETXTBSY"
3841 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3842 test_mkdir $DIR/$tdir
3843 cp -p $(which $MULTIOP) $DIR/$tdir/multiop ||
3844 cp -p multiop $DIR/$tdir/multiop
3845 MULTIOP_PROG=$DIR/$tdir/multiop multiop_bg_pause $TMP/$tfile.junk O_c ||
3846 error "multiop open $TMP/$tfile.junk failed"
3848 $TRUNCATE $DIR/$tdir/multiop 0 && error "expected error, got success"
3849 kill -USR1 $MULTIOP_PID || error "kill -USR1 PID $MULTIOP_PID failed"
3850 wait $MULTIOP_PID || error "wait PID $MULTIOP_PID failed"
3852 run_test 43b "truncate of file being executed should return -ETXTBSY"
3855 local testdir="$DIR/$tdir"
3858 ( cd $(dirname $SHELL) && md5sum $(basename $SHELL) ) |
3859 ( cd $testdir && md5sum -c )
3861 run_test 43c "md5sum of copy into lustre"
3863 test_44A() { # was test_44
3864 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
3865 dd if=/dev/zero of=$DIR/f1 bs=4k count=1 seek=1023
3866 dd if=$DIR/f1 bs=4k count=1 > /dev/null
3868 run_test 44A "zero length read from a sparse stripe"
3871 local nstripe=$($LCTL lov_getconfig $DIR | grep default_stripe_count: |
3873 [ -z "$nstripe" ] && skip "can't get stripe info" && return
3874 [[ $nstripe -gt $OSTCOUNT ]] &&
3875 skip "Wrong default_stripe_count: $nstripe (OSTCOUNT: $OSTCOUNT)" &&
3877 local stride=$($LCTL lov_getconfig $DIR | grep default_stripe_size: |
3879 if [[ $nstripe -eq 0 || $nstripe -eq -1 ]]; then
3880 nstripe=$($LCTL lov_getconfig $DIR | grep obd_count: |
3884 OFFSETS="0 $((stride/2)) $((stride-1))"
3885 for offset in $OFFSETS; do
3886 for i in $(seq 0 $((nstripe-1))); do
3887 local GLOBALOFFSETS=""
3889 local size=$((((i + 2 * $nstripe )*$stride + $offset)))
3890 local myfn=$DIR/d44a-$size
3891 echo "--------writing $myfn at $size"
3892 ll_sparseness_write $myfn $size ||
3893 error "ll_sparseness_write"
3894 GLOBALOFFSETS="$GLOBALOFFSETS $size"
3895 ll_sparseness_verify $myfn $GLOBALOFFSETS ||
3896 error "ll_sparseness_verify $GLOBALOFFSETS"
3898 for j in $(seq 0 $((nstripe-1))); do
3900 size=$((((j + $nstripe )*$stride + $offset)))
3901 ll_sparseness_write $myfn $size ||
3902 error "ll_sparseness_write"
3903 GLOBALOFFSETS="$GLOBALOFFSETS $size"
3905 ll_sparseness_verify $myfn $GLOBALOFFSETS ||
3906 error "ll_sparseness_verify $GLOBALOFFSETS"
3911 run_test 44a "test sparse pwrite ==============================="
3915 for d in `lctl get_param -n osc.*.cur_dirty_bytes`; do
3921 before=`dirty_osc_total`
3922 echo executing "\"$*\""
3924 after=`dirty_osc_total`
3925 echo before $before, after $after
3928 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3930 # Obtain grants from OST if it supports it
3931 echo blah > ${f}_grant
3934 do_dirty_record "echo blah > $f"
3935 [[ $before -eq $after ]] && error "write wasn't cached"
3936 do_dirty_record "> $f"
3937 [[ $before -gt $after ]] || error "truncate didn't lower dirty count"
3938 do_dirty_record "echo blah > $f"
3939 [[ $before -eq $after ]] && error "write wasn't cached"
3940 do_dirty_record "sync"
3941 [[ $before -gt $after ]] || error "writeback didn't lower dirty count"
3942 do_dirty_record "echo blah > $f"
3943 [[ $before -eq $after ]] && error "write wasn't cached"
3944 do_dirty_record "cancel_lru_locks osc"
3945 [[ $before -gt $after ]] ||
3946 error "lock cancellation didn't lower dirty count"
3949 run_test 45 "osc io page accounting ============================"
3951 # in a 2 stripe file (lov.sh), page 1023 maps to page 511 in its object. this
3952 # test tickles a bug where re-dirtying a page was failing to be mapped to the
3953 # objects offset and an assert hit when an rpc was built with 1023's mapped
3954 # offset 511 and 511's raw 511 offset. it also found general redirtying bugs.
3956 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3960 dd if=/dev/zero of=$f bs=`page_size` seek=511 count=1
3962 dd conv=notrunc if=/dev/zero of=$f bs=`page_size` seek=1023 count=1
3963 dd conv=notrunc if=/dev/zero of=$f bs=`page_size` seek=511 count=1
3967 run_test 46 "dirtying a previously written page ================"
3969 # test_47 is removed "Device nodes check" is moved to test_28
3971 test_48a() { # bug 2399
3972 [ $(facet_fstype $SINGLEMDS) = "zfs" ] &&
3973 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.3.63) ] &&
3974 skip "MDS prior to 2.3.63 handle ZFS dir .. incorrectly" &&
3976 test_mkdir $DIR/$tdir
3978 mv $DIR/$tdir $DIR/$tdir.new || error "move directory failed"
3979 test_mkdir $DIR/$tdir || error "recreate directory failed"
3980 touch foo || error "'touch foo' failed after recreating cwd"
3981 test_mkdir bar || error "'mkdir foo' failed after recreating cwd"
3982 touch .foo || error "'touch .foo' failed after recreating cwd"
3983 test_mkdir .bar || error "'mkdir .foo' failed after recreating cwd"
3984 ls . > /dev/null || error "'ls .' failed after recreating cwd"
3985 ls .. > /dev/null || error "'ls ..' failed after removing cwd"
3986 cd . || error "'cd .' failed after recreating cwd"
3987 test_mkdir . && error "'mkdir .' worked after recreating cwd"
3988 rmdir . && error "'rmdir .' worked after recreating cwd"
3989 ln -s . baz || error "'ln -s .' failed after recreating cwd"
3990 cd .. || error "'cd ..' failed after recreating cwd"
3992 run_test 48a "Access renamed working dir (should return errors)="
3994 test_48b() { # bug 2399
3996 test_mkdir $DIR/$tdir
3998 rmdir $DIR/$tdir || error "remove cwd $DIR/$tdir failed"
3999 touch foo && error "'touch foo' worked after removing cwd"
4000 test_mkdir foo && error "'mkdir foo' worked after removing cwd"
4001 touch .foo && error "'touch .foo' worked after removing cwd"
4002 test_mkdir .foo && error "'mkdir .foo' worked after removing cwd"
4003 ls . > /dev/null && error "'ls .' worked after removing cwd"
4004 ls .. > /dev/null || error "'ls ..' failed after removing cwd"
4005 test_mkdir . && error "'mkdir .' worked after removing cwd"
4006 rmdir . && error "'rmdir .' worked after removing cwd"
4007 ln -s . foo && error "'ln -s .' worked after removing cwd"
4008 cd .. || echo "'cd ..' failed after removing cwd `pwd`" #bug 3517
4010 run_test 48b "Access removed working dir (should return errors)="
4012 test_48c() { # bug 2350
4013 #lctl set_param debug=-1
4016 test_mkdir -p $DIR/$tdir/dir
4018 $TRACE rmdir $DIR/$tdir/dir || error "remove cwd $DIR/$tdir/dir failed"
4019 $TRACE touch foo && error "touch foo worked after removing cwd"
4020 $TRACE test_mkdir foo && error "'mkdir foo' worked after removing cwd"
4021 touch .foo && error "touch .foo worked after removing cwd"
4022 test_mkdir .foo && error "mkdir .foo worked after removing cwd"
4023 $TRACE ls . && error "'ls .' worked after removing cwd"
4024 $TRACE ls .. || error "'ls ..' failed after removing cwd"
4025 $TRACE test_mkdir . && error "'mkdir .' worked after removing cwd"
4026 $TRACE rmdir . && error "'rmdir .' worked after removing cwd"
4027 $TRACE ln -s . foo && error "'ln -s .' worked after removing cwd"
4028 $TRACE cd .. || echo "'cd ..' failed after removing cwd `pwd`" #bug 3415
4030 run_test 48c "Access removed working subdir (should return errors)"
4032 test_48d() { # bug 2350
4033 #lctl set_param debug=-1
4036 test_mkdir -p $DIR/$tdir/dir
4038 $TRACE rmdir $DIR/$tdir/dir || error "remove cwd $DIR/$tdir/dir failed"
4039 $TRACE rmdir $DIR/$tdir || error "remove parent $DIR/$tdir failed"
4040 $TRACE touch foo && error "'touch foo' worked after removing parent"
4041 $TRACE test_mkdir foo && error "mkdir foo worked after removing parent"
4042 touch .foo && error "'touch .foo' worked after removing parent"
4043 test_mkdir .foo && error "mkdir .foo worked after removing parent"
4044 $TRACE ls . && error "'ls .' worked after removing parent"
4045 $TRACE ls .. && error "'ls ..' worked after removing parent"
4046 $TRACE test_mkdir . && error "'mkdir .' worked after removing parent"
4047 $TRACE rmdir . && error "'rmdir .' worked after removing parent"
4048 $TRACE ln -s . foo && error "'ln -s .' worked after removing parent"
4051 run_test 48d "Access removed parent subdir (should return errors)"
4053 test_48e() { # bug 4134
4054 #lctl set_param debug=-1
4057 test_mkdir -p $DIR/$tdir/dir
4059 $TRACE rmdir $DIR/$tdir/dir || error "remove cwd $DIR/$tdir/dir failed"
4060 $TRACE rmdir $DIR/$tdir || error "remove parent $DIR/$tdir failed"
4061 $TRACE touch $DIR/$tdir || error "'touch $DIR/$tdir' failed"
4062 $TRACE chmod +x $DIR/$tdir || error "'chmod +x $DIR/$tdir' failed"
4063 # On a buggy kernel addition of "touch foo" after cd .. will
4064 # produce kernel oops in lookup_hash_it
4065 touch ../foo && error "'cd ..' worked after recreate parent"
4067 $TRACE rm $DIR/$tdir || error "rm '$DIR/$tdir' failed"
4069 run_test 48e "Access to recreated parent subdir (should return errors)"
4071 test_49() { # LU-1030
4072 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4073 remote_ost_nodsh && skip "remote OST with nodsh" && return
4074 # get ost1 size - lustre-OST0000
4075 ost1_size=$(do_facet ost1 $LFS df | grep ${ost1_svc} |
4077 # write 800M at maximum
4078 [[ $ost1_size -lt 2 ]] && ost1_size=2
4079 [[ $ost1_size -gt 819200 ]] && ost1_size=819200
4081 $SETSTRIPE -c 1 -i 0 $DIR/$tfile
4082 dd if=/dev/zero of=$DIR/$tfile bs=4k count=$((ost1_size >> 2)) &
4085 # change max_pages_per_rpc while writing the file
4086 local osc1_mppc=osc.$(get_osc_import_name client ost1).max_pages_per_rpc
4087 local orig_mppc=$($LCTL get_param -n $osc1_mppc)
4088 # loop until dd process exits
4089 while ps ax -opid | grep -wq $dd_pid; do
4090 $LCTL set_param $osc1_mppc=$((RANDOM % 256 + 1))
4091 sleep $((RANDOM % 5 + 1))
4093 # restore original max_pages_per_rpc
4094 $LCTL set_param $osc1_mppc=$orig_mppc
4095 rm $DIR/$tfile || error "rm $DIR/$tfile failed"
4097 run_test 49 "Change max_pages_per_rpc won't break osc extent"
4101 test_mkdir $DIR/$tdir
4103 ls /proc/$$/cwd || error "ls /proc/$$/cwd failed"
4105 run_test 50 "special situations: /proc symlinks ==============="
4107 test_51a() { # was test_51
4108 # bug 1516 - create an empty entry right after ".." then split dir
4109 test_mkdir -c1 $DIR/$tdir
4110 touch $DIR/$tdir/foo
4111 $MCREATE $DIR/$tdir/bar
4113 createmany -m $DIR/$tdir/longfile 201
4115 while [[ $(ls -sd $DIR/$tdir | awk '{ print $1 }') -eq 4 ]]; do
4116 $MCREATE $DIR/$tdir/longfile$FNUM
4121 ls -l $DIR/$tdir > /dev/null || error "ls -l $DIR/$tdir failed"
4123 run_test 51a "special situations: split htree with empty entry =="
4125 cleanup_print_lfs_df () {
4132 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4133 local dir=$DIR/$tdir
4135 local nrdirs=$((65536 + 100))
4137 # cleanup the directory
4140 test_mkdir -p -c1 $dir
4144 local mdtidx=$(printf "%04x" $($LFS getstripe -M $dir))
4145 local numfree=$(lctl get_param -n mdc.$FSNAME-MDT$mdtidx*.filesfree)
4146 [[ $numfree -lt $nrdirs ]] &&
4147 skip "not enough free inodes ($numfree) on MDT$mdtidx" &&
4150 # need to check free space for the directories as well
4151 local blkfree=$(lctl get_param -n mdc.$FSNAME-MDT$mdtidx*.kbytesavail)
4152 numfree=$(( blkfree / $(fs_inode_ksize) ))
4153 [[ $numfree -lt $nrdirs ]] && skip "not enough blocks ($numfree)" &&
4156 trap cleanup_print_lfs_df EXIT
4159 createmany -d $dir/d $nrdirs || {
4160 unlinkmany $dir/d $nrdirs
4161 error "failed to create $nrdirs subdirs in MDT$mdtidx:$dir"
4165 nrdirs=$(ls -U $dir | wc -l)
4167 # unlink all but 100 subdirectories, then check it still works
4169 local delete=$((nrdirs - left))
4174 # for ldiskfs the nlink count should be 1, but this is OSD specific
4175 # and so this is listed for informational purposes only
4176 echo "nlink before: $(stat -c %h $dir), created before: $nrdirs"
4177 unlinkmany -d $dir/d $delete ||
4178 error "unlink of first $delete subdirs failed"
4180 echo "nlink between: $(stat -c %h $dir)"
4181 local found=$(ls -U $dir | wc -l)
4182 [ $found -ne $left ] &&
4183 error "can't find subdirs: found only $found, expected $left"
4185 unlinkmany -d $dir/d $delete $left ||
4186 error "unlink of second $left subdirs failed"
4187 # regardless of whether the backing filesystem tracks nlink accurately
4188 # or not, the nlink count shouldn't be more than "." and ".." here
4189 local after=$(stat -c %h $dir)
4190 [[ $after -gt 2 ]] && error "nlink after: $after > 2" ||
4191 echo "nlink after: $after"
4193 cleanup_print_lfs_df
4195 run_test 51b "exceed 64k subdirectory nlink limit on create, verify unlink"
4198 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4199 [[ $OSTCOUNT -lt 3 ]] && skip_env "needs >= 3 OSTs" && return
4200 test_mkdir -p $DIR/$tdir
4201 createmany -o $DIR/$tdir/t- 1000
4202 $GETSTRIPE $DIR/$tdir > $TMP/$tfile
4203 for N in $(seq 0 $((OSTCOUNT - 1))); do
4204 OBJS[$N]=$(awk -vobjs=0 '($1 == '$N') { objs += 1 } \
4205 END { printf("%0.0f", objs) }' $TMP/$tfile)
4206 OBJS0[$N]=$(grep -A 1 idx $TMP/$tfile | awk -vobjs=0 \
4207 '($1 == '$N') { objs += 1 } \
4208 END { printf("%0.0f", objs) }')
4209 log "OST$N has ${OBJS[$N]} objects, ${OBJS0[$N]} are index 0"
4211 unlinkmany $DIR/$tdir/t- 1000
4214 for N in $(seq 1 $((OSTCOUNT - 1))); do
4215 [[ ${OBJS[$N]} -lt $((${OBJS[$NLAST]} - 20)) ]] &&
4216 error "OST $N has less objects vs OST $NLAST" \
4217 " (${OBJS[$N]} < ${OBJS[$NLAST]}"
4218 [[ ${OBJS[$N]} -gt $((${OBJS[$NLAST]} + 20)) ]] &&
4219 error "OST $N has less objects vs OST $NLAST" \
4220 " (${OBJS[$N]} < ${OBJS[$NLAST]}"
4222 [[ ${OBJS0[$N]} -lt $((${OBJS0[$NLAST]} - 20)) ]] &&
4223 error "OST $N has less #0 objects vs OST $NLAST" \
4224 " (${OBJS0[$N]} < ${OBJS0[$NLAST]}"
4225 [[ ${OBJS0[$N]} -gt $((${OBJS0[$NLAST]} + 20)) ]] &&
4226 error "OST $N has less #0 objects vs OST $NLAST" \
4227 " (${OBJS0[$N]} < ${OBJS0[$NLAST]}"
4232 run_test 51d "check object distribution"
4235 if [ "$(facet_fstype $SINGLEMDS)" != ldiskfs ]; then
4236 skip "ldiskfs only test"
4240 test_mkdir -c1 $DIR/$tdir || error "create $tdir failed"
4241 test_mkdir -c1 $DIR/$tdir/d0 || error "create d0 failed"
4243 touch $DIR/$tdir/d0/foo
4244 createmany -l $DIR/$tdir/d0/foo $DIR/$tdir/d0/f- 65001 &&
4245 error "file exceed 65000 nlink limit!"
4246 unlinkmany $DIR/$tdir/d0/f- 65001
4249 run_test 51e "check file nlink limit"
4252 test_mkdir $DIR/$tdir
4255 local ulimit_old=$(ulimit -n)
4256 local spare=20 # number of spare fd's for scripts/libraries, etc.
4257 local mdt=$(lfs getstripe -M $DIR/$tdir)
4258 local numfree=$(lfs df -i $DIR/$tdir | awk '/MDT:'$mdt'/ { print $4 }')
4260 echo "MDT$mdt numfree=$numfree, max=$max"
4261 [[ $numfree -gt $max ]] && numfree=$max || numfree=$((numfree * 7 / 8))
4262 if [ $((numfree + spare)) -gt $ulimit_old ]; then
4263 while ! ulimit -n $((numfree + spare)); do
4264 numfree=$((numfree * 3 / 4))
4266 echo "changed ulimit from $ulimit_old to $((numfree + spare))"
4268 echo "left ulimit at $ulimit_old"
4271 createmany -o -k -t 120 $DIR/$tdir/f $numfree || {
4272 unlinkmany $DIR/$tdir/f $numfree
4273 error "create+open $numfree files in $DIR/$tdir failed"
4275 ulimit -n $ulimit_old
4277 # if createmany exits at 120s there will be fewer than $numfree files
4278 unlinkmany $DIR/$tdir/f $numfree || true
4280 run_test 51f "check many open files limit"
4283 [ -f $DIR/$tdir/foo ] && chattr -a $DIR/$tdir/foo
4284 test_mkdir -p $DIR/$tdir
4285 touch $DIR/$tdir/foo
4286 chattr +a $DIR/$tdir/foo || error "chattr +a failed"
4287 echo bar >> $DIR/$tdir/foo || error "append bar failed"
4288 cp /etc/hosts $DIR/$tdir/foo && error "cp worked"
4289 rm -f $DIR/$tdir/foo 2>/dev/null && error "rm worked"
4290 link $DIR/$tdir/foo $DIR/$tdir/foo_link 2>/dev/null &&
4292 echo foo >> $DIR/$tdir/foo || error "append foo failed"
4293 mrename $DIR/$tdir/foo $DIR/$tdir/foo_ren && error "rename worked"
4294 lsattr $DIR/$tdir/foo | egrep -q "^-+a[-e]+ $DIR/$tdir/foo" ||
4296 chattr -a $DIR/$tdir/foo || error "chattr -a failed"
4297 cp -r $DIR/$tdir $TMP/
4298 rm -fr $DIR/$tdir $TMP/$tdir || error "cleanup rm failed"
4300 run_test 52a "append-only flag test (should return errors)"
4303 [ -f $DIR/$tdir/foo ] && chattr -i $DIR/$tdir/foo
4304 test_mkdir -p $DIR/$tdir
4305 touch $DIR/$tdir/foo
4306 chattr +i $DIR/$tdir/foo || error "chattr +i failed"
4307 cat test > $DIR/$tdir/foo && error "cat test worked"
4308 cp /etc/hosts $DIR/$tdir/foo && error "cp worked"
4309 rm -f $DIR/$tdir/foo 2>/dev/null && error "rm worked"
4310 link $DIR/$tdir/foo $DIR/$tdir/foo_link 2>/dev/null &&
4312 echo foo >> $DIR/$tdir/foo && error "echo worked"
4313 mrename $DIR/$tdir/foo $DIR/$tdir/foo_ren && error "rename worked"
4314 [ -f $DIR/$tdir/foo ] || error "$tdir/foo is not a file"
4315 [ -f $DIR/$tdir/foo_ren ] && error "$tdir/foo_ren is not a file"
4316 lsattr $DIR/$tdir/foo | egrep -q "^-+i[-e]+ $DIR/$tdir/foo" ||
4318 chattr -i $DIR/$tdir/foo || error "chattr failed"
4320 rm -fr $DIR/$tdir || error "unable to remove $DIR/$tdir"
4322 run_test 52b "immutable flag test (should return errors) ======="
4325 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4326 remote_mds_nodsh && skip "remote MDS with nodsh" && return
4327 remote_ost_nodsh && skip "remote OST with nodsh" && return
4340 local support_last_seq=true
4342 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.3.60) ]] ||
4343 support_last_seq=false
4346 local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS)
4348 for value in $(do_facet $SINGLEMDS \
4349 $LCTL get_param osc.$mdtosc.prealloc_last_id) ; do
4350 param=$(echo ${value[0]} | cut -d "=" -f1)
4351 ostname=$(echo $param | cut -d "." -f2 | cut -d - -f 1-2)
4353 if $support_last_seq; then
4354 param_seq=$(echo $param |
4355 sed -e s/prealloc_last_id/prealloc_last_seq/g)
4356 mds_last_seq=$(do_facet $SINGLEMDS \
4357 $LCTL get_param -n $param_seq)
4359 mds_last=$(do_facet $SINGLEMDS $LCTL get_param -n $param)
4361 ostnum=$(index_from_ostuuid ${ostname}_UUID)
4362 node=$(facet_active_host ost$((ostnum+1)))
4363 param="obdfilter.$ostname.last_id"
4364 for ost_last in $(do_node $node $LCTL get_param -n $param) ; do
4365 echo "$ostname.last_id=$ost_last; MDS.last_id=$mds_last"
4366 ost_last_id=$ost_last
4368 if $support_last_seq; then
4369 ost_last_id=$(echo $ost_last |
4370 awk -F':' '{print $2}' |
4372 ost_last_seq=$(echo $ost_last |
4373 awk -F':' '{print $1}')
4374 [[ $ost_last_seq = $mds_last_seq ]] || continue
4377 if [[ $ost_last_id != $mds_last ]]; then
4378 error "$ost_last_id != $mds_last"
4385 $found || error "can not match last_seq/last_id for $mdtosc"
4388 run_test 53 "verify that MDS and OSTs agree on pre-creation ===="
4391 perl -MSocket -e ';' || { skip "no Socket perl module installed" && return; }
4393 $SOCKETSERVER $DIR/socket ||
4394 error "$SOCKETSERVER $DIR/socket failed: $?"
4395 $SOCKETCLIENT $DIR/socket ||
4396 error "$SOCKETCLIENT $DIR/socket failed: $?"
4397 $MUNLINK $DIR/socket || error "$MUNLINK $DIR/socket failed: $?"
4399 run_test 54a "unix domain socket test =========================="
4405 dd if=/dev/zero of=$f bs=$(page_size) count=1
4407 run_test 54b "char device works in lustre ======================"
4410 [ -b /dev/loop/0 ] && LOOPBASE=/dev/loop/
4411 [ -b /dev/loop0 ] && LOOPBASE=/dev/loop
4412 [ -z "$LOOPBASE" ] && echo "/dev/loop/0 and /dev/loop0 gone?" && return
4414 for i in $(seq 3 7); do
4415 losetup $LOOPBASE$i > /dev/null 2>&1 && continue
4424 loopdev="$DIR/loop54c"
4427 $UMOUNT $DIR/$tdir || rc=$?
4428 losetup -d $loopdev || true
4429 losetup -d $LOOPDEV || true
4430 rm -rf $loopdev $DIR/$tfile $DIR/$tdir
4435 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4436 loopdev="$DIR/loop54c"
4439 [ -z "$LOOPNUM" ] && echo "couldn't find empty loop device" && return
4440 trap cleanup_54c EXIT
4441 mknod $loopdev b 7 $LOOPNUM
4442 echo "make a loop file system with $DIR/$tfile on $loopdev ($LOOPNUM)."
4443 dd if=/dev/zero of=$DIR/$tfile bs=$(get_page_size client) seek=1024 count=1 > /dev/null
4444 losetup $loopdev $DIR/$tfile ||
4445 error "can't set up $loopdev for $DIR/$tfile"
4446 mkfs.ext2 $loopdev || error "mke2fs on $loopdev"
4447 test_mkdir -p $DIR/$tdir
4448 mount -t ext2 $loopdev $DIR/$tdir ||
4449 error "error mounting $loopdev on $DIR/$tdir"
4450 dd if=/dev/zero of=$DIR/$tdir/tmp bs=$(get_page_size client) count=30 ||
4453 dd if=$DIR/$tdir/tmp of=/dev/zero bs=$(get_page_size client) count=30 ||
4457 run_test 54c "block device works in lustre ====================="
4463 [ "$string" = $(echo $string > $f | cat $f) ] || error "$f != $string"
4465 run_test 54d "fifo device works in lustre ======================"
4470 cp -aL /dev/console $f
4471 echo $string > $f || error "echo $string to $f failed"
4473 run_test 54e "console/tty device works in lustre ======================"
4475 #The test_55 used to be iopen test and it was removed by bz#24037.
4476 #run_test 55 "check iopen_connect_dentry() ======================"
4478 test_56a() { # was test_56
4481 test_mkdir -p $DIR/$tdir/dir
4483 NUMFILESx2=$(($NUMFILES * 2))
4484 for i in $(seq 1 $NUMFILES); do
4485 touch $DIR/$tdir/file$i
4486 touch $DIR/$tdir/dir/file$i
4489 # test lfs getstripe with --recursive
4490 FILENUM=$($GETSTRIPE --recursive $DIR/$tdir | grep -c obdidx)
4491 [[ $FILENUM -eq $NUMFILESx2 ]] ||
4492 error "$GETSTRIPE --recursive: found $FILENUM, not $NUMFILESx2"
4493 FILENUM=$($GETSTRIPE $DIR/$tdir | grep -c obdidx)
4494 [[ $FILENUM -eq $NUMFILES ]] ||
4495 error "$GETSTRIPE $DIR/$tdir: found $FILENUM, not $NUMFILES"
4496 echo "$GETSTRIPE --recursive passed."
4498 # test lfs getstripe with file instead of dir
4499 FILENUM=$($GETSTRIPE $DIR/$tdir/file1 | grep -c obdidx)
4500 [[ $FILENUM -eq 1 ]] ||
4501 error "$GETSTRIPE $DIR/$tdir/file1: found $FILENUM, not 1"
4502 echo "$GETSTRIPE file1 passed."
4504 #test lfs getstripe with --verbose
4505 [[ $($GETSTRIPE --verbose $DIR/$tdir |
4506 grep -c lmm_magic) -eq $NUMFILES ]] ||
4507 error "$GETSTRIPE --verbose $DIR/$tdir: want $NUMFILES"
4508 [[ $($GETSTRIPE $DIR/$tdir | grep -c lmm_magic) -eq 0 ]] ||
4509 error "$GETSTRIPE $DIR/$tdir: showed lmm_magic"
4511 #test lfs getstripe with -v prints lmm_fid
4512 [[ $($GETSTRIPE -v $DIR/$tdir | grep -c lmm_fid) -eq $NUMFILES ]] ||
4513 error "$GETSTRIPE -v $DIR/$tdir: want $NUMFILES lmm_fid: lines"
4514 [[ $($GETSTRIPE $DIR/$tdir | grep -c lmm_fid) -eq 0 ]] ||
4515 error "$GETSTRIPE $DIR/$tdir: showed lmm_fid"
4516 echo "$GETSTRIPE --verbose passed."
4518 #check for FID information
4519 local fid1=$($GETSTRIPE --fid $DIR/$tdir/file1)
4520 local fid2=$($GETSTRIPE --verbose $DIR/$tdir/file1 |
4521 awk '/lmm_fid: / { print $2 }')
4522 local fid3=$($LFS path2fid $DIR/$tdir/file1)
4523 [ "$fid1" != "$fid2" ] &&
4524 error "getstripe --fid $fid1 != getstripe --verbose $fid2"
4525 [ "$fid1" != "$fid3" ] &&
4526 error "getstripe --fid $fid1 != lfs path2fid $fid3"
4527 echo "$GETSTRIPE --fid passed."
4529 #test lfs getstripe with --obd
4530 $GETSTRIPE --obd wrong_uuid $DIR/$tdir 2>&1 |
4531 grep -q "unknown obduuid" ||
4532 error "$GETSTRIPE --obd wrong_uuid should return error message"
4534 [[ $OSTCOUNT -lt 2 ]] &&
4535 skip_env "skipping other $GETSTRIPE --obd test" && return
4538 OBDUUID=$(ostuuid_from_index $OSTIDX)
4539 FILENUM=$($GETSTRIPE -ir $DIR/$tdir | grep "^$OSTIDX\$" | wc -l)
4540 FOUND=$($GETSTRIPE -r --obd $OBDUUID $DIR/$tdir | grep obdidx | wc -l)
4541 [[ $FOUND -eq $FILENUM ]] ||
4542 error "$GETSTRIPE --obd wrong: found $FOUND, expected $FILENUM"
4543 [[ $($GETSTRIPE -r -v --obd $OBDUUID $DIR/$tdir |
4544 sed '/^[ ]*'${OSTIDX}'[ ]/d' |
4545 sed -n '/^[ ]*[0-9][0-9]*[ ]/p' | wc -l) -eq 0 ]] ||
4546 error "$GETSTRIPE --obd: should not show file on other obd"
4547 echo "$GETSTRIPE --obd passed"
4549 run_test 56a "check $GETSTRIPE"
4552 test_mkdir $DIR/$tdir
4554 for i in $(seq 1 $NUMDIRS); do
4555 test_mkdir $DIR/$tdir/dir$i
4558 # test lfs getdirstripe default mode is non-recursion, which is
4559 # different from lfs getstripe
4560 dircnt=$($LFS getdirstripe $DIR/$tdir | grep -c lmv_stripe_count)
4561 [[ $dircnt -eq 1 ]] ||
4562 error "$LFS getdirstripe: found $dircnt, not 1"
4563 dircnt=$($LFS getdirstripe --recursive $DIR/$tdir |
4564 grep -c lmv_stripe_count)
4565 [[ $dircnt -eq $((NUMDIRS + 1)) ]] ||
4566 error "$LFS getdirstripe --recursive: found $dircnt, \
4567 not $((NUMDIRS + 1))"
4569 run_test 56b "check $LFS getdirstripe"
4573 local ost_name=$(ostname_from_index $ost_idx)
4575 local old_status=$(ost_dev_status $ost_idx)
4576 [[ -z "$old_status" ]] ||
4577 { skip_env "OST $ost_name is in $old_status status"; return 0; }
4579 do_facet ost1 $LCTL set_param -n obdfilter.$ost_name.degraded=1
4582 local new_status=$(ost_dev_status $ost_idx)
4583 [[ "$new_status" = "D" ]] ||
4584 error "OST $ost_name is in status of '$new_status', not 'D'"
4586 do_facet ost1 $LCTL set_param -n obdfilter.$ost_name.degraded=0
4589 new_status=$(ost_dev_status $ost_idx)
4590 [[ -z "$new_status" ]] ||
4591 error "OST $ost_name is in status of '$new_status', not ''"
4593 run_test 56c "check 'lfs df' showing device status"
4598 local LOCAL_NUMFILES="$1"
4599 local LOCAL_NUMDIRS="$2"
4600 local MKDIR_PARAMS="$3"
4601 local DIR_STRIPE_PARAMS="$4"
4603 if [ ! -d "$TDIR" ] ; then
4604 test_mkdir -p $DIR_STRIPE_PARAMS $TDIR
4605 [ "$MKDIR_PARAMS" ] && $SETSTRIPE $MKDIR_PARAMS $TDIR
4606 for i in `seq 1 $LOCAL_NUMFILES` ; do
4609 for i in `seq 1 $LOCAL_NUMDIRS` ; do
4610 test_mkdir $DIR_STRIPE_PARAMS $TDIR/dir$i
4611 for j in `seq 1 $LOCAL_NUMFILES` ; do
4612 touch $TDIR/dir$i/file$j
4618 setup_56_special() {
4622 if [ ! -e "$TDIR/loop1b" ] ; then
4623 for i in `seq 1 $LOCAL_NUMFILES` ; do
4624 mknod $TDIR/loop${i}b b 7 $i
4625 mknod $TDIR/null${i}c c 1 3
4626 ln -s $TDIR/file1 $TDIR/link${i}l
4628 for i in `seq 1 $LOCAL_NUMDIRS` ; do
4629 mknod $TDIR/dir$i/loop${i}b b 7 $i
4630 mknod $TDIR/dir$i/null${i}c c 1 3
4631 ln -s $TDIR/dir$i/file1 $TDIR/dir$i/link${i}l
4640 setup_56 $NUMFILES $NUMDIRS
4642 EXPECTED=$(($NUMDIRS + 2))
4643 # test lfs find with -name
4644 for i in $(seq 1 $NUMFILES) ; do
4645 NUMS=$($LFIND -name "*$i" $TDIR | wc -l)
4646 [ $NUMS -eq $EXPECTED ] ||
4647 error "lfs find -name \"*$i\" $TDIR wrong: "\
4648 "found $NUMS, expected $EXPECTED"
4651 run_test 56g "check lfs find -name ============================="
4657 setup_56 $NUMFILES $NUMDIRS
4659 EXPECTED=$(((NUMDIRS + 1) * (NUMFILES - 1) + NUMFILES))
4660 # test lfs find with ! -name
4661 for i in $(seq 1 $NUMFILES) ; do
4662 NUMS=$($LFIND ! -name "*$i" $TDIR | wc -l)
4663 [ $NUMS -eq $EXPECTED ] ||
4664 error "lfs find ! -name \"*$i\" $TDIR wrong: "\
4665 "found $NUMS, expected $EXPECTED"
4668 run_test 56h "check lfs find ! -name ============================="
4672 test_mkdir -p $DIR/$tdir
4673 UUID=$(ostuuid_from_index 0 $DIR/$tdir)
4674 CMD="$LFIND -ost $UUID $DIR/$tdir"
4676 [ -z "$OUT" ] || error "\"$CMD\" returned directory '$OUT'"
4678 run_test 56i "check 'lfs find -ost UUID' skips directories ======="
4682 setup_56_special $NUMFILES $NUMDIRS
4684 EXPECTED=$((NUMDIRS + 1))
4685 CMD="$LFIND -type d $TDIR"
4686 NUMS=$($CMD | wc -l)
4687 [ $NUMS -eq $EXPECTED ] ||
4688 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4690 run_test 56j "check lfs find -type d ============================="
4694 setup_56_special $NUMFILES $NUMDIRS
4696 EXPECTED=$(((NUMDIRS + 1) * NUMFILES))
4697 CMD="$LFIND -type f $TDIR"
4698 NUMS=$($CMD | wc -l)
4699 [ $NUMS -eq $EXPECTED ] ||
4700 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4702 run_test 56k "check lfs find -type f ============================="
4706 setup_56_special $NUMFILES $NUMDIRS
4708 EXPECTED=$((NUMDIRS + NUMFILES))
4709 CMD="$LFIND -type b $TDIR"
4710 NUMS=$($CMD | wc -l)
4711 [ $NUMS -eq $EXPECTED ] ||
4712 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4714 run_test 56l "check lfs find -type b ============================="
4718 setup_56_special $NUMFILES $NUMDIRS
4720 EXPECTED=$((NUMDIRS + NUMFILES))
4721 CMD="$LFIND -type c $TDIR"
4722 NUMS=$($CMD | wc -l)
4723 [ $NUMS -eq $EXPECTED ] ||
4724 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4726 run_test 56m "check lfs find -type c ============================="
4730 setup_56_special $NUMFILES $NUMDIRS
4732 EXPECTED=$((NUMDIRS + NUMFILES))
4733 CMD="$LFIND -type l $TDIR"
4734 NUMS=$($CMD | wc -l)
4735 [ $NUMS -eq $EXPECTED ] ||
4736 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4738 run_test 56n "check lfs find -type l ============================="
4742 setup_56 $NUMFILES $NUMDIRS
4743 utime $TDIR/file1 > /dev/null || error "utime (1)"
4744 utime $TDIR/file2 > /dev/null || error "utime (2)"
4745 utime $TDIR/dir1 > /dev/null || error "utime (3)"
4746 utime $TDIR/dir2 > /dev/null || error "utime (4)"
4747 utime $TDIR/dir1/file1 > /dev/null || error "utime (5)"
4748 dd if=/dev/zero count=1 >> $TDIR/dir1/file1 && sync
4751 NUMS=`$LFIND -mtime +0 $TDIR | wc -l`
4752 [ $NUMS -eq $EXPECTED ] || \
4753 error "lfs find -mtime +0 $TDIR wrong: found $NUMS, expected $EXPECTED"
4756 CMD="$LFIND -mtime 0 $TDIR"
4757 NUMS=$($CMD | wc -l)
4758 [ $NUMS -eq $EXPECTED ] ||
4759 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4761 run_test 56o "check lfs find -mtime for old files =========================="
4764 [ $RUNAS_ID -eq $UID ] &&
4765 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
4768 setup_56 $NUMFILES $NUMDIRS
4770 chown $RUNAS_ID $TDIR/file* || error "chown $DIR/${tdir}g/file$i failed"
4772 CMD="$LFIND -uid $RUNAS_ID $TDIR"
4773 NUMS=$($CMD | wc -l)
4774 [ $NUMS -eq $EXPECTED ] || \
4775 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4777 EXPECTED=$(((NUMFILES + 1) * NUMDIRS + 1))
4778 CMD="$LFIND ! -uid $RUNAS_ID $TDIR"
4779 NUMS=$($CMD | wc -l)
4780 [ $NUMS -eq $EXPECTED ] || \
4781 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4783 run_test 56p "check lfs find -uid and ! -uid ==============================="
4786 [ $RUNAS_ID -eq $UID ] &&
4787 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
4790 setup_56 $NUMFILES $NUMDIRS
4792 chgrp $RUNAS_GID $TDIR/file* || error "chown $TDIR/file$i failed"
4795 CMD="$LFIND -gid $RUNAS_GID $TDIR"
4796 NUMS=$($CMD | wc -l)
4797 [ $NUMS -eq $EXPECTED ] ||
4798 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4800 EXPECTED=$(( ($NUMFILES+1) * $NUMDIRS + 1))
4801 CMD="$LFIND ! -gid $RUNAS_GID $TDIR"
4802 NUMS=$($CMD | wc -l)
4803 [ $NUMS -eq $EXPECTED ] ||
4804 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4806 run_test 56q "check lfs find -gid and ! -gid ==============================="
4810 setup_56 $NUMFILES $NUMDIRS
4813 CMD="$LFIND -size 0 -type f $TDIR"
4814 NUMS=$($CMD | wc -l)
4815 [ $NUMS -eq $EXPECTED ] ||
4816 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4818 CMD="$LFIND ! -size 0 -type f $TDIR"
4819 NUMS=$($CMD | wc -l)
4820 [ $NUMS -eq $EXPECTED ] ||
4821 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4822 echo "test" > $TDIR/$tfile
4823 echo "test2" > $TDIR/$tfile.2 && sync
4825 CMD="$LFIND -size 5 -type f $TDIR"
4826 NUMS=$($CMD | wc -l)
4827 [ $NUMS -eq $EXPECTED ] ||
4828 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4830 CMD="$LFIND -size +5 -type f $TDIR"
4831 NUMS=$($CMD | wc -l)
4832 [ $NUMS -eq $EXPECTED ] ||
4833 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4835 CMD="$LFIND -size +0 -type f $TDIR"
4836 NUMS=$($CMD | wc -l)
4837 [ $NUMS -eq $EXPECTED ] ||
4838 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4840 CMD="$LFIND ! -size -5 -type f $TDIR"
4841 NUMS=$($CMD | wc -l)
4842 [ $NUMS -eq $EXPECTED ] ||
4843 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4845 CMD="$LFIND -size -5 -type f $TDIR"
4846 NUMS=$($CMD | wc -l)
4847 [ $NUMS -eq $EXPECTED ] ||
4848 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4850 run_test 56r "check lfs find -size works =========================="
4852 test_56s() { # LU-611
4857 for i in $(seq 1 $NUMDIRS); do
4858 $SETSTRIPE -c $((OSTCOUNT + 1)) $TDIR/dir$i/$tfile
4861 CMD="$LFIND -c $OSTCOUNT $TDIR"
4862 NUMS=$($CMD | wc -l)
4863 [ $NUMS -eq $EXPECTED ] || {
4865 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4869 setup_56 $NUMFILES $NUMDIRS "-c $OSTCOUNT"
4870 if [[ $OSTCOUNT -gt 1 ]]; then
4871 $SETSTRIPE -c 1 $TDIR/$tfile.{0,1,2,3}
4875 ONESTRIPE=$(((NUMDIRS + 1) * NUMFILES))
4879 EXPECTED=$(((NUMDIRS + 1) * NUMFILES))
4880 CMD="$LFIND -stripe-count $OSTCOUNT -type f $TDIR"
4881 NUMS=$($CMD | wc -l)
4882 [ $NUMS -eq $EXPECTED ] || {
4884 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4887 EXPECTED=$(((NUMDIRS + 1) * NUMFILES + EXTRA))
4888 CMD="$LFIND -stripe-count +0 -type f $TDIR"
4889 NUMS=$($CMD | wc -l)
4890 [ $NUMS -eq $EXPECTED ] || {
4892 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4896 CMD="$LFIND -stripe-count 1 -type f $TDIR"
4897 NUMS=$($CMD | wc -l)
4898 [ $NUMS -eq $EXPECTED ] || {
4900 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4903 CMD="$LFIND -stripe-count -2 -type f $TDIR"
4904 NUMS=$($CMD | wc -l)
4905 [ $NUMS -eq $EXPECTED ] || {
4907 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4911 CMD="$LFIND -stripe-count $((OSTCOUNT + 1)) -type f $TDIR"
4912 NUMS=$($CMD | wc -l)
4913 [ $NUMS -eq $EXPECTED ] || {
4915 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4918 run_test 56s "check lfs find -stripe-count works"
4920 test_56t() { # LU-611
4925 for i in $(seq 1 $NUMDIRS); do
4926 $SETSTRIPE -S 4M $TDIR/dir$i/$tfile
4929 CMD="$LFIND -S 4M $TDIR"
4930 NUMS=$($CMD | wc -l)
4931 [ $NUMS -eq $EXPECTED ] || {
4933 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4937 setup_56 $NUMFILES $NUMDIRS "--stripe-size 512k"
4939 $SETSTRIPE -S 256k $TDIR/$tfile.{0,1,2,3}
4941 EXPECTED=$(((NUMDIRS + 1) * NUMFILES))
4942 CMD="$LFIND -stripe-size 512k -type f $TDIR"
4943 NUMS=$($CMD | wc -l)
4944 [ $NUMS -eq $EXPECTED ] ||
4945 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4947 CMD="$LFIND -stripe-size +320k -type f $TDIR"
4948 NUMS=$($CMD | wc -l)
4949 [ $NUMS -eq $EXPECTED ] ||
4950 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4952 EXPECTED=$(((NUMDIRS + 1) * NUMFILES + 4))
4953 CMD="$LFIND -stripe-size +200k -type f $TDIR"
4954 NUMS=$($CMD | wc -l)
4955 [ $NUMS -eq $EXPECTED ] ||
4956 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4958 CMD="$LFIND -stripe-size -640k -type f $TDIR"
4959 NUMS=$($CMD | wc -l)
4960 [ $NUMS -eq $EXPECTED ] ||
4961 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4964 CMD="$LFIND -stripe-size 256k -type f $TDIR"
4965 NUMS=$($CMD | wc -l)
4966 [ $NUMS -eq $EXPECTED ] ||
4967 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4969 CMD="$LFIND -stripe-size -320k -type f $TDIR"
4970 NUMS=$($CMD | wc -l)
4971 [ $NUMS -eq $EXPECTED ] ||
4972 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4975 CMD="$LFIND -stripe-size 1024k -type f $TDIR"
4976 NUMS=$($CMD | wc -l)
4977 [ $NUMS -eq $EXPECTED ] ||
4978 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4980 run_test 56t "check lfs find -stripe-size works"
4982 test_56u() { # LU-611
4984 setup_56 $NUMFILES $NUMDIRS "-i 0"
4986 if [[ $OSTCOUNT -gt 1 ]]; then
4987 $SETSTRIPE -i 1 $TDIR/$tfile.{0,1,2,3}
4993 EXPECTED=$(((NUMDIRS + 1) * NUMFILES))
4994 CMD="$LFIND -stripe-index 0 -type f $TDIR"
4995 NUMS=$($CMD | wc -l)
4996 [ $NUMS -eq $EXPECTED ] ||
4997 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
5000 CMD="$LFIND -stripe-index 1 -type f $TDIR"
5001 NUMS=$($CMD | wc -l)
5002 [ $NUMS -eq $EXPECTED ] ||
5003 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
5005 CMD="$LFIND ! -stripe-index 0 -type f $TDIR"
5006 NUMS=$($CMD | wc -l)
5007 [ $NUMS -eq $EXPECTED ] ||
5008 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
5011 # This should produce an error and not return any files
5012 CMD="$LFIND -stripe-index $OSTCOUNT -type f $TDIR"
5013 NUMS=$($CMD 2>/dev/null | wc -l)
5014 [ $NUMS -eq $EXPECTED ] ||
5015 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
5017 if [[ $OSTCOUNT -gt 1 ]]; then
5018 EXPECTED=$(((NUMDIRS + 1) * NUMFILES + ONESTRIPE))
5019 CMD="$LFIND -stripe-index 0,1 -type f $TDIR"
5020 NUMS=$($CMD | wc -l)
5021 [ $NUMS -eq $EXPECTED ] ||
5022 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
5025 run_test 56u "check lfs find -stripe-index works"
5032 setup_56 $NUMFILES $NUMDIRS
5034 UUID=$(mdtuuid_from_index $MDT_IDX $TDIR)
5035 [ -z "$UUID" ] && error "mdtuuid_from_index cannot find MDT index $MDT_IDX"
5037 for file in $($LFIND -mdt $UUID $TDIR); do
5038 file_mdt_idx=$($GETSTRIPE -M $file)
5039 [ $file_mdt_idx -eq $MDT_IDX ] ||
5040 error "'lfind -mdt $UUID' != 'getstripe -M' ($file_mdt_idx)"
5043 run_test 56v "check 'lfs find -mdt match with lfs getstripe -M' ======="
5046 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
5047 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5050 rm -rf $TDIR || error "remove $TDIR failed"
5051 setup_56 $NUMFILES $NUMDIRS "-c $OSTCOUNT" "-c1"
5054 stripe_size=$($GETSTRIPE -S -d $TDIR) ||
5055 error "$GETSTRIPE -S -d $TDIR failed"
5056 stripe_size=${stripe_size%% *}
5058 local file_size=$((stripe_size * OSTCOUNT))
5059 local file_num=$((NUMDIRS * NUMFILES + NUMFILES))
5060 local required_space=$((file_num * file_size))
5062 local free_space=$($LCTL get_param -n lov.$FSNAME-clilov-*.kbytesavail |
5064 [[ $free_space -le $((required_space / 1024)) ]] &&
5065 skip_env "need at least $required_space bytes free space," \
5066 "have $free_space kbytes" && return
5069 local dd_count=$((file_size / dd_bs))
5071 # write data into the files
5075 for i in $(seq 1 $NUMFILES); do
5077 yes | dd bs=$dd_bs count=$dd_count of=$file >/dev/null 2>&1 ||
5078 error "write data into $file failed"
5080 for i in $(seq 1 $NUMDIRS); do
5081 for j in $(seq 1 $NUMFILES); do
5082 file=$TDIR/dir$i/file$j
5083 yes | dd bs=$dd_bs count=$dd_count of=$file \
5085 error "write data into $file failed"
5090 [[ $OSTCOUNT -gt 1 ]] && expected=$((OSTCOUNT - 1))
5093 local cmd="$LFS_MIGRATE -y -c $expected $TDIR/file1"
5095 eval $cmd || error "$cmd failed"
5097 check_stripe_count $TDIR/file1 $expected
5099 if [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.6.90) ];
5101 # lfs_migrate file onto OST 0 if it is on OST 1, or onto
5102 # OST 1 if it is on OST 0. This file is small enough to
5103 # be on only one stripe.
5104 file=$TDIR/migr_1_ost
5105 dd bs=$dd_bs count=1 if=/dev/urandom of=$file >/dev/null 2>&1 ||
5106 error "write data into $file failed"
5107 local obdidx=$($LFS getstripe -i $file)
5108 local oldmd5=$(md5sum $file)
5110 [[ $obdidx -eq 0 ]] && newobdidx=1
5111 cmd="$LFS migrate -i $newobdidx $file"
5113 eval $cmd || error "$cmd failed"
5114 local realobdix=$($LFS getstripe -i $file)
5115 local newmd5=$(md5sum $file)
5116 [[ $newobdidx -ne $realobdix ]] &&
5117 error "new OST is different (was=$obdidx, wanted=$newobdidx, got=$realobdix)"
5118 [[ "$oldmd5" != "$newmd5" ]] &&
5119 error "md5sum differ: $oldmd5, $newmd5"
5123 cmd="$LFS_MIGRATE -y -c $expected $TDIR/dir1"
5125 eval $cmd || error "$cmd failed"
5127 for j in $(seq 1 $NUMFILES); do
5128 check_stripe_count $TDIR/dir1/file$j $expected
5131 # lfs_migrate works with lfs find
5132 cmd="$LFIND -stripe_count $OSTCOUNT -type f $TDIR |
5133 $LFS_MIGRATE -y -c $expected"
5135 eval $cmd || error "$cmd failed"
5137 for i in $(seq 2 $NUMFILES); do
5138 check_stripe_count $TDIR/file$i $expected
5140 for i in $(seq 2 $NUMDIRS); do
5141 for j in $(seq 1 $NUMFILES); do
5142 check_stripe_count $TDIR/dir$i/file$j $expected
5146 run_test 56w "check lfs_migrate -c stripe_count works"
5149 check_swap_layouts_support && return 0
5150 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
5152 local dir0=$DIR/$tdir/$testnum
5153 test_mkdir -p $dir0 || error "creating dir $dir0"
5155 local ref1=/etc/passwd
5156 local file1=$dir0/file1
5158 $SETSTRIPE -c 2 $file1
5160 $LFS migrate -c 1 $file1 || error "migrate failed rc = $?"
5161 stripe=$($GETSTRIPE -c $file1)
5162 [[ $stripe == 1 ]] || error "stripe of $file1 is $stripe != 1"
5163 cmp $file1 $ref1 || error "content mismatch $file1 differs from $ref1"
5168 run_test 56x "lfs migration support"
5171 check_swap_layouts_support && return 0
5172 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
5174 local dir0=$DIR/$tdir/$testnum
5175 test_mkdir -p $dir0 || error "creating dir $dir0"
5177 local ref1=/etc/passwd
5178 local file1=$dir0/file1
5180 $SETSTRIPE -c 2 $file1
5182 $LFS migrate --block -c 1 $file1 || error "migrate failed rc = $?"
5183 local stripe=$($GETSTRIPE -c $file1)
5184 [[ $stripe == 1 ]] || error "stripe of $file1 is $stripe != 1"
5185 cmp $file1 $ref1 || error "content mismatch $file1 differs from $ref1"
5190 run_test 56xa "lfs migration --block support"
5193 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.53) ] &&
5194 skip "No HSM $(lustre_build_version $SINGLEMDS) MDS < 2.4.53" &&
5198 local dir0=$DIR/$tdir/$testnum
5199 test_mkdir -p $dir0 || error "creating dir $dir0"
5200 local f1=$dir0/file1
5201 local f2=$dir0/file2
5203 touch $f1 || error "creating std file $f1"
5204 $MULTIOP $f2 H2c || error "creating released file $f2"
5206 # a directory can be raid0, so ask only for files
5207 res=$($LFIND $dir0 -L raid0 -type f | wc -l)
5208 [[ $res == 2 ]] || error "search raid0: found $res files != 2"
5210 res=$($LFIND $dir0 \! -L raid0 -type f | wc -l)
5211 [[ $res == 0 ]] || error "search !raid0: found $res files != 0"
5213 # only files can be released, so no need to force file search
5214 res=$($LFIND $dir0 -L released)
5215 [[ $res == $f2 ]] || error "search released: found $res != $f2"
5217 res=$($LFIND $dir0 \! -L released)
5218 [[ $res == $f1 ]] || error "search !released: found $res != $f1"
5221 run_test 56y "lfs find -L raid0|released"
5223 test_56z() { # LU-4824
5224 # This checks to make sure 'lfs find' continues after errors
5225 # There are two classes of errors that should be caught:
5226 # - If multiple paths are provided, all should be searched even if one
5228 # - If errors are encountered during the search, it should not terminate
5231 test_mkdir $DIR/$tdir
5232 for i in d{0..9}; do
5233 test_mkdir $DIR/$tdir/$i
5235 touch $DIR/$tdir/d{0..9}/$tfile
5236 $LFS find $DIR/non_existent_dir $DIR/$tdir &&
5237 error "$LFS find did not return an error"
5238 # Make a directory unsearchable. This should NOT be the last entry in
5239 # directory order. Arbitrarily pick the 6th entry
5240 chmod 700 $($LFS find $DIR/$tdir -type d | sed '6!d')
5241 local count=$($RUNAS $LFS find $DIR/non_existent $DIR/$tdir | wc -l)
5242 # The user should be able to see 10 directories and 9 files
5243 [ $count == 19 ] || error "$LFS find did not continue after error"
5245 run_test 56z "lfs find should continue after an error"
5247 test_56aa() { # LU-5937
5248 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
5251 $LFS setdirstripe -c$MDSCOUNT $DIR/$tdir/striped_dir
5253 createmany -o $DIR/$tdir/striped_dir/${tfile}- 1024
5254 local dirs=$(lfs find --size +8k $DIR/$tdir/)
5256 [ -n "$dirs" ] || error "lfs find --size wrong under striped dir"
5258 run_test 56aa "lfs find --size under striped dir"
5261 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5262 # note test will not do anything if MDS is not local
5263 if [ "$(facet_fstype $SINGLEMDS)" != ldiskfs ]; then
5264 skip "ldiskfs only test"
5268 remote_mds_nodsh && skip "remote MDS with nodsh" && return
5269 local MNTDEV="osd*.*MDT*.mntdev"
5270 DEV=$(do_facet $SINGLEMDS lctl get_param -n $MNTDEV)
5271 [ -z "$DEV" ] && error "can't access $MNTDEV"
5272 for DEV in $(do_facet $SINGLEMDS lctl get_param -n $MNTDEV); do
5273 do_facet $SINGLEMDS $DUMPE2FS -h $DEV > $TMP/t57a.dump ||
5274 error "can't access $DEV"
5275 DEVISIZE=$(awk '/Inode size:/ { print $3 }' $TMP/t57a.dump)
5276 [[ $DEVISIZE -gt 128 ]] || error "inode size $DEVISIZE"
5280 run_test 57a "verify MDS filesystem created with large inodes =="
5283 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5284 if [ "$(facet_fstype $SINGLEMDS)" != ldiskfs ]; then
5285 skip "ldiskfs only test"
5289 remote_mds_nodsh && skip "remote MDS with nodsh" && return
5290 local dir=$DIR/$tdir
5294 local FILEN=$dir/f$FILECOUNT
5296 rm -rf $dir || error "removing $dir"
5297 test_mkdir -p -c1 $dir || error "creating $dir"
5298 local mdtidx=$($LFS getstripe -M $dir)
5299 local mdtname=MDT$(printf %04x $mdtidx)
5300 local facet=mds$((mdtidx + 1))
5302 echo "mcreating $FILECOUNT files"
5303 createmany -m $dir/f 1 $FILECOUNT || \
5304 error "creating files in $dir"
5306 # verify that files do not have EAs yet
5307 $GETSTRIPE $FILE1 2>&1 | grep -q "no stripe" || error "$FILE1 has an EA"
5308 $GETSTRIPE $FILEN 2>&1 | grep -q "no stripe" || error "$FILEN has an EA"
5312 df $dir #make sure we get new statfs data
5313 local MDSFREE=$(do_facet $facet \
5314 lctl get_param -n osd*.*$mdtname.kbytesfree)
5315 local MDCFREE=$(lctl get_param -n mdc.*$mdtname-mdc-*.kbytesfree)
5316 echo "opening files to create objects/EAs"
5318 for FILE in `seq -f $dir/f%g 1 $FILECOUNT`; do
5319 $OPENFILE -f O_RDWR $FILE > /dev/null 2>&1 || error "opening $FILE"
5322 # verify that files have EAs now
5323 $GETSTRIPE $FILE1 | grep -q "obdidx" || error "$FILE1 missing EA"
5324 $GETSTRIPE $FILEN | grep -q "obdidx" || error "$FILEN missing EA"
5326 sleep 1 #make sure we get new statfs data
5328 local MDSFREE2=$(do_facet $facet \
5329 lctl get_param -n osd*.*$mdtname.kbytesfree)
5330 local MDCFREE2=$(lctl get_param -n mdc.*$mdtname-mdc-*.kbytesfree)
5331 if [[ $MDCFREE2 -lt $((MDCFREE - 16)) ]]; then
5332 if [ "$MDSFREE" != "$MDSFREE2" ]; then
5333 error "MDC before $MDCFREE != after $MDCFREE2"
5335 echo "MDC before $MDCFREE != after $MDCFREE2"
5336 echo "unable to confirm if MDS has large inodes"
5341 run_test 57b "default LOV EAs are stored inside large inodes ==="
5344 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5345 [ -z "$(which wiretest 2>/dev/null)" ] &&
5346 skip_env "could not find wiretest" && return
5349 run_test 58 "verify cross-platform wire constants =============="
5352 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5353 echo "touch 130 files"
5354 createmany -o $DIR/f59- 130
5356 unlinkmany $DIR/f59- 130
5358 # wait for commitment of removal
5359 wait_delete_completed
5361 run_test 59 "verify cancellation of llog records async ========="
5363 TEST60_HEAD="test_60 run $RANDOM"
5365 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5366 remote_mgs_nodsh && skip "remote MGS with nodsh" && return
5367 do_facet mgs "! which run-llog.sh &> /dev/null" &&
5368 do_facet mgs "! ls run-llog.sh &> /dev/null" &&
5369 skip_env "missing subtest run-llog.sh" && return
5371 log "$TEST60_HEAD - from kernel mode"
5372 do_facet mgs "$LCTL set_param debug=warning; $LCTL dk > /dev/null"
5373 do_facet mgs sh run-llog.sh
5374 do_facet mgs $LCTL dk > $TMP/$tfile
5376 # LU-6388: test llog_reader
5377 local llog_reader=$(do_facet mgs "which llog_reader 2> /dev/null")
5378 llog_reader=${llog_reader:-$LUSTRE/utils/llog_reader}
5379 [ -z $(do_facet mgs ls -d $llog_reader 2> /dev/null) ] &&
5380 skip_env "missing llog_reader" && return
5381 local fstype=$(facet_fstype mgs)
5382 [ $fstype != ldiskfs -a $fstype != zfs ] &&
5383 skip_env "Only for ldiskfs or zfs type mgs" && return
5385 local mntpt=$(facet_mntpt mgs)
5386 local mgsdev=$(mgsdevname 1)
5398 #get fid and record list
5399 fid_list=($(awk '/9_sub.*record/ { print $NF }' /$TMP/$tfile |
5401 rec_list=($(awk '/9_sub.*record/ { print $((NF-3)) }' /$TMP/$tfile |
5403 #remount mgs as ldiskfs or zfs type
5404 stop mgs || error "stop mgs failed"
5405 mount_fstype mgs || error "remount mgs failed"
5406 for ((i = 0; i < ${#fid_list[@]}; i++)); do
5409 seq=$(echo $fid | awk -F ':' '{ print $1 }' | sed -e "s/^0x//g")
5410 oid=$(echo $fid | awk -F ':' '{ print $2 }' | sed -e "s/^0x//g")
5415 obj_file=$mntpt/O/$seq/d$((oid%32))/$oid ;;
5417 obj_file=$mntpt/oi.$(($((16#$seq))&127))/$fid ;;
5419 echo "obj_file is $obj_file"
5420 do_facet mgs $llog_reader $obj_file
5422 rec_type=$(do_facet mgs $llog_reader $obj_file | grep "type=" |
5423 awk '{ print $3 }' | sed -e "s/^type=//g")
5424 if [ $rec_type != $rec ]; then
5425 echo "FAILED test_60a wrong record type $rec_type," \
5431 #check obj path if record type is LLOG_LOGID_MAGIC
5432 if [ "$rec" == "1064553b" ]; then
5433 path=$(do_facet mgs $llog_reader $obj_file |
5434 grep "path=" | awk '{ print $NF }' |
5435 sed -e "s/^path=//g")
5436 if [ $obj_file != $mntpt/$path ]; then
5437 echo "FAILED test_60a wrong obj path" \
5438 "$montpt/$path, should be $obj_file"
5445 #restart mgs before "error", otherwise it will block the next test
5446 stop mgs || error "stop mgs failed"
5447 start mgs $(mgsdevname) $MGS_MOUNT_OPTS || error "start mgs failed"
5448 $pass || error "test failed, see FAILED test_60a messages for specifics"
5450 run_test 60a "llog_test run from kernel module and test llog_reader"
5453 # test old logid format
5454 if [ $(lustre_version_code mgs) -le $(version_code 3.1.53) ]; then
5455 do_facet mgs $LCTL dl | grep MGS
5456 do_facet mgs "$LCTL --device %MGS llog_print \\\\\\\$$FSNAME-client" ||
5457 error "old llog_print failed"
5460 # test new logid format
5461 if [ $(lustre_version_code mgs) -ge $(version_code 2.9.53) ]; then
5462 do_facet mgs "$LCTL --device MGS llog_print $FSNAME-client" ||
5463 error "new llog_print failed"
5466 run_test 60aa "llog_print works with FIDs and simple names"
5468 test_60b() { # bug 6411
5469 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5471 LLOG_COUNT=$(dmesg | awk "/$TEST60_HEAD/ { marker = 1; from_marker = 0; }
5483 [[ $LLOG_COUNT -gt 100 ]] &&
5484 error "CDEBUG_LIMIT not limiting messages ($LLOG_COUNT)" || true
5486 run_test 60b "limit repeated messages from CERROR/CWARN ========"
5489 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5490 echo "create 5000 files"
5491 createmany -o $DIR/f60c- 5000
5492 #define OBD_FAIL_MDS_LLOG_CREATE_FAILED 0x137
5493 lctl set_param fail_loc=0x80000137
5494 unlinkmany $DIR/f60c- 5000
5495 lctl set_param fail_loc=0
5497 run_test 60c "unlink file when mds full"
5500 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5501 SAVEPRINTK=$(lctl get_param -n printk)
5503 # verify "lctl mark" is even working"
5504 MESSAGE="test message ID $RANDOM $$"
5505 $LCTL mark "$MESSAGE" || error "$LCTL mark failed"
5506 dmesg | grep -q "$MESSAGE" || error "didn't find debug marker in log"
5508 lctl set_param printk=0 || error "set lnet.printk failed"
5509 lctl get_param -n printk | grep emerg || error "lnet.printk dropped emerg"
5510 MESSAGE="new test message ID $RANDOM $$"
5511 # Assume here that libcfs_debug_mark_buffer() uses D_WARNING
5512 $LCTL mark "$MESSAGE" || error "$LCTL mark failed"
5513 dmesg | grep -q "$MESSAGE" && error "D_WARNING wasn't masked" || true
5515 lctl set_param -n printk="$SAVEPRINTK"
5517 run_test 60d "test printk console message masking"
5520 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5521 remote_mds_nodsh && skip "remote MDS with nodsh" && return
5523 #define OBD_FAIL_MDS_LLOG_CREATE_FAILED2 0x15b
5524 do_facet mds1 lctl set_param fail_loc=0x15b
5527 run_test 60e "no space while new llog is being created"
5530 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5532 dd if=/dev/zero of=$f bs=$(page_size) count=1 || error "dd $f failed"
5533 cancel_lru_locks osc
5534 $MULTIOP $f OSMWUc || error "$MULTIOP $f failed"
5537 run_test 61 "mmap() writes don't make sync hang ================"
5539 # bug 2330 - insufficient obd_match error checking causes LBUG
5541 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5544 cancel_lru_locks osc
5545 lctl set_param fail_loc=0x405
5546 cat $f && error "cat succeeded, expect -EIO"
5547 lctl set_param fail_loc=0
5549 # This test is now irrelevant (as of bug 10718 inclusion), we no longer
5550 # match every page all of the time.
5551 #run_test 62 "verify obd_match failure doesn't LBUG (should -EIO)"
5553 # bug 2319 - oig_wait() interrupted causes crash because of invalid waitq.
5554 # Though this test is irrelevant anymore, it helped to reveal some
5555 # other grant bugs (LU-4482), let's keep it.
5556 test_63a() { # was test_63
5557 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5558 MAX_DIRTY_MB=`lctl get_param -n osc.*.max_dirty_mb | head -n 1`
5559 for i in `seq 10` ; do
5560 dd if=/dev/zero of=$DIR/f63 bs=8k &
5566 rm -f $DIR/f63 || true
5568 run_test 63a "Verify oig_wait interruption does not crash ======="
5570 # bug 2248 - async write errors didn't return to application on sync
5571 # bug 3677 - async write errors left page locked
5573 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5575 lctl set_param debug=-1
5577 # ensure we have a grant to do async writes
5578 dd if=/dev/zero of=$DIR/$tfile bs=4k count=1
5581 sync # sync lest earlier test intercept the fail_loc
5583 #define OBD_FAIL_OSC_BRW_PREP_REQ 0x406
5584 lctl set_param fail_loc=0x80000406
5585 $MULTIOP $DIR/$tfile Owy && \
5586 error "sync didn't return ENOMEM"
5587 sync; sleep 2; sync # do a real sync this time to flush page
5588 lctl get_param -n llite.*.dump_page_cache | grep locked && \
5589 error "locked page left in cache after async error" || true
5592 run_test 63b "async write errors should be returned to fsync ==="
5595 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5597 lctl get_param -n osc.*[oO][sS][cC][_-]*.cur* | grep "[0-9]"
5599 run_test 64a "verify filter grant calculations (in kernel) ====="
5602 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5603 sh oos.sh $MOUNT || error "oos.sh failed: $?"
5605 run_test 64b "check out-of-space detection on client ==========="
5608 $LCTL set_param osc.*OST0000-osc-[^mM]*.cur_grant_bytes=0
5610 run_test 64c "verify grant shrink ========================------"
5612 # bug 1414 - set/get directories' stripe info
5614 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5615 test_mkdir -p $DIR/$tdir
5617 $LVERIFY $DIR/$tdir $DIR/$tdir/f1 || error "lverify failed"
5619 run_test 65a "directory with no stripe info ===================="
5622 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5623 test_mkdir -p $DIR/$tdir
5624 local STRIPESIZE=$($GETSTRIPE -S $DIR/$tdir)
5626 $SETSTRIPE -S $((STRIPESIZE * 2)) -i 0 -c 1 $DIR/$tdir ||
5629 $LVERIFY $DIR/$tdir $DIR/$tdir/f2 || error "lverify failed"
5631 run_test 65b "directory setstripe -S stripe_size*2 -i 0 -c 1"
5634 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5635 if [[ $OSTCOUNT -gt 1 ]]; then
5636 test_mkdir -p $DIR/$tdir
5637 local STRIPESIZE=$($GETSTRIPE -S $DIR/$tdir)
5639 $SETSTRIPE -S $(($STRIPESIZE * 4)) -i 1 \
5640 -c $(($OSTCOUNT - 1)) $DIR/$tdir || error "setstripe"
5642 $LVERIFY $DIR/$tdir $DIR/$tdir/f3 || error "lverify failed"
5645 run_test 65c "directory setstripe -S stripe_size*4 -i 1 -c $((OSTCOUNT-1))"
5648 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5649 test_mkdir -p $DIR/$tdir
5650 local STRIPECOUNT=$($GETSTRIPE -c $DIR/$tdir)
5651 local STRIPESIZE=$($GETSTRIPE -S $DIR/$tdir)
5653 if [[ $STRIPECOUNT -le 0 ]]; then
5655 elif [[ $STRIPECOUNT -gt 2000 ]]; then
5656 #LOV_MAX_STRIPE_COUNT is 2000
5657 [[ $OSTCOUNT -gt 2000 ]] && sc=2000 || sc=$(($OSTCOUNT - 1))
5659 sc=$(($STRIPECOUNT - 1))
5661 $SETSTRIPE -S $STRIPESIZE -c $sc $DIR/$tdir || error "setstripe"
5662 touch $DIR/$tdir/f4 $DIR/$tdir/f5
5663 $LVERIFY $DIR/$tdir $DIR/$tdir/f4 $DIR/$tdir/f5 ||
5664 error "lverify failed"
5666 run_test 65d "directory setstripe -S stripe_size -c stripe_count"
5669 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5670 test_mkdir -p $DIR/$tdir
5672 $SETSTRIPE $DIR/$tdir || error "setstripe"
5673 $GETSTRIPE -v $DIR/$tdir | grep "Default" ||
5674 error "no stripe info failed"
5676 $LVERIFY $DIR/$tdir $DIR/$tdir/f6 || error "lverify failed"
5678 run_test 65e "directory setstripe defaults ======================="
5681 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5682 test_mkdir -p $DIR/${tdir}f
5683 $RUNAS $SETSTRIPE $DIR/${tdir}f && error "setstripe succeeded" || true
5685 run_test 65f "dir setstripe permission (should return error) ==="
5688 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5689 test_mkdir -p $DIR/$tdir
5690 local STRIPESIZE=$($GETSTRIPE -S $DIR/$tdir)
5692 $SETSTRIPE -S $((STRIPESIZE * 2)) -i 0 -c 1 $DIR/$tdir ||
5694 $SETSTRIPE -d $DIR/$tdir || error "setstripe"
5695 $GETSTRIPE -v $DIR/$tdir | grep "Default" ||
5696 error "delete default stripe failed"
5698 run_test 65g "directory setstripe -d ==========================="
5701 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5702 test_mkdir -p $DIR/$tdir
5703 local STRIPESIZE=$($GETSTRIPE -S $DIR/$tdir)
5705 $SETSTRIPE -S $((STRIPESIZE * 2)) -i 0 -c 1 $DIR/$tdir ||
5707 test_mkdir -p $DIR/$tdir/dd1
5708 [ $($GETSTRIPE -c $DIR/$tdir) == $($GETSTRIPE -c $DIR/$tdir/dd1) ] ||
5709 error "stripe info inherit failed"
5711 run_test 65h "directory stripe info inherit ===================="
5713 test_65i() { # bug6367
5714 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5715 $SETSTRIPE -S 65536 -c -1 $MOUNT
5717 run_test 65i "set non-default striping on root directory (bug 6367)="
5719 test_65ia() { # bug12836
5720 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5721 $GETSTRIPE $MOUNT || error "getstripe $MOUNT failed"
5723 run_test 65ia "getstripe on -1 default directory striping"
5725 test_65ib() { # bug12836
5726 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5727 $GETSTRIPE -v $MOUNT || error "getstripe -v $MOUNT failed"
5729 run_test 65ib "getstripe -v on -1 default directory striping"
5731 test_65ic() { # bug12836
5732 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5733 $LFS find -mtime -1 $MOUNT > /dev/null || error "find $MOUNT failed"
5735 run_test 65ic "new find on -1 default directory striping"
5737 test_65j() { # bug6367
5738 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5740 # if we aren't already remounting for each test, do so for this test
5741 if [ "$CLEANUP" = ":" -a "$I_MOUNTED" = "yes" ]; then
5742 cleanup || error "failed to unmount"
5745 $SETSTRIPE -d $MOUNT || error "setstripe failed"
5747 run_test 65j "set default striping on root directory (bug 6367)="
5749 test_65k() { # bug11679
5750 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5751 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
5752 remote_mds_nodsh && skip "remote MDS with nodsh" && return
5754 local disable_precreate=true
5755 [ $(lustre_version_code $SINGLEMDS) -le $(version_code 2.8.54) ] &&
5756 disable_precreate=false
5758 echo "Check OST status: "
5759 local MDS_OSCS=$(do_facet $SINGLEMDS lctl dl |
5760 awk '/[oO][sS][cC].*md[ts]/ { print $4 }')
5762 for OSC in $MDS_OSCS; do
5763 echo $OSC "is active"
5764 do_facet $SINGLEMDS lctl --device %$OSC activate
5767 for INACTIVE_OSC in $MDS_OSCS; do
5768 local ost=$(osc_to_ost $INACTIVE_OSC)
5769 local ostnum=$(do_facet $SINGLEMDS lctl get_param -n \
5770 lov.*md*.target_obd |
5771 awk -F: /$ost/'{ print $1 }' | head -n 1)
5774 $SETSTRIPE -i $ostnum -c 1 $DIR/$tdir
5775 createmany -o $DIR/$tdir/$tfile.$ostnum. 1000
5777 echo "Deactivate: " $INACTIVE_OSC
5778 do_facet $SINGLEMDS lctl --device %$INACTIVE_OSC deactivate
5780 local count=$(do_facet $SINGLEMDS "lctl get_param -n \
5781 osp.$ost*MDT0000.create_count")
5782 local max_count=$(do_facet $SINGLEMDS "lctl get_param -n \
5783 osp.$ost*MDT0000.max_create_count")
5784 $disable_precreate &&
5785 do_facet $SINGLEMDS "lctl set_param -n \
5786 osp.$ost*MDT0000.max_create_count=0"
5788 for idx in $(seq 0 $((OSTCOUNT - 1))); do
5789 [ -f $DIR/$tdir/$idx ] && continue
5790 echo "$SETSTRIPE -i $idx -c 1 $DIR/$tdir/$idx"
5791 $SETSTRIPE -i $idx -c 1 $DIR/$tdir/$idx ||
5792 error "setstripe $idx should succeed"
5793 rm -f $DIR/$tdir/$idx || error "rm $idx failed"
5795 unlinkmany $DIR/$tdir/$tfile.$ostnum. 1000
5798 do_facet $SINGLEMDS "lctl set_param -n \
5799 osp.$ost*MDT0000.max_create_count=$max_count"
5800 do_facet $SINGLEMDS "lctl set_param -n \
5801 osp.$ost*MDT0000.create_count=$count"
5802 do_facet $SINGLEMDS lctl --device %$INACTIVE_OSC activate
5803 echo $INACTIVE_OSC "is Activate"
5805 wait_osc_import_state mds ost$ostnum FULL
5808 run_test 65k "validate manual striping works properly with deactivated OSCs"
5810 test_65l() { # bug 12836
5811 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5812 test_mkdir -p $DIR/$tdir/test_dir
5813 $SETSTRIPE -c -1 $DIR/$tdir/test_dir
5814 $LFS find -mtime -1 $DIR/$tdir >/dev/null
5816 run_test 65l "lfs find on -1 stripe dir ========================"
5819 $RUNAS $SETSTRIPE -c 2 $MOUNT && error "setstripe should fail"
5822 run_test 65m "normal user can't set filesystem default stripe"
5824 # bug 2543 - update blocks count on client
5826 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5828 dd if=/dev/zero of=$DIR/f66 bs=1k count=$COUNT
5829 sync; sync_all_data; sync; sync_all_data
5830 cancel_lru_locks osc
5831 BLOCKS=`ls -s $DIR/f66 | awk '{ print $1 }'`
5832 [ $BLOCKS -ge $COUNT ] || error "$DIR/f66 blocks $BLOCKS < $COUNT"
5834 run_test 66 "update inode blocks count on client ==============="
5837 awk '($1 == "'$1':") { print $2 }' /proc/meminfo
5841 swapon -s | awk '($1 == "'$1'") { print $4 }'
5844 # bug5265, obdfilter oa2dentry return -ENOENT
5845 # #define OBD_FAIL_SRV_ENOENT 0x217
5847 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5848 remote_ost_nodsh && skip "remote OST with nodsh" && return
5851 $SETSTRIPE -c 1 -i 0 $f
5853 $DIRECTIO write ${f}.2 0 1 || error "directio write error"
5855 do_facet ost1 lctl set_param fail_loc=0x217
5856 $TRUNCATE $f 1 # vmtruncate() will ignore truncate() error.
5857 $DIRECTIO write $f 0 2 && error "write succeeded, expect -ENOENT"
5859 do_facet ost1 lctl set_param fail_loc=0
5860 $DIRECTIO write $f 0 2 || error "write error"
5862 cancel_lru_locks osc
5863 $DIRECTIO read $f 0 1 || error "read error"
5865 do_facet ost1 lctl set_param fail_loc=0x217
5866 $DIRECTIO read $f 1 1 && error "read succeeded, expect -ENOENT"
5868 do_facet ost1 lctl set_param fail_loc=0
5871 run_test 69 "verify oa2dentry return -ENOENT doesn't LBUG ======"
5874 test_mkdir -p $DIR/$tdir
5875 $LFS setdirstripe -D -c$MDSCOUNT $DIR/$tdir
5876 sh rundbench -C -D $DIR/$tdir 2 || error "dbench failed!"
5878 run_test 71 "Running dbench on lustre (don't segment fault) ===="
5880 test_72a() { # bug 5695 - Test that on 2.6 remove_suid works properly
5881 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5882 [ "$RUNAS_ID" = "$UID" ] &&
5883 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
5885 # Check that testing environment is properly set up. Skip if not
5886 FAIL_ON_ERROR=false check_runas_id_ret $RUNAS_ID $RUNAS_GID $RUNAS || {
5887 skip_env "User $RUNAS_ID does not exist - skipping"
5891 chmod 777 $DIR/$tfile
5892 chmod ug+s $DIR/$tfile
5893 $RUNAS dd if=/dev/zero of=$DIR/$tfile bs=512 count=1 ||
5894 error "$RUNAS dd $DIR/$tfile failed"
5895 # See if we are still setuid/sgid
5896 test -u $DIR/$tfile -o -g $DIR/$tfile &&
5897 error "S/gid is not dropped on write"
5898 # Now test that MDS is updated too
5899 cancel_lru_locks mdc
5900 test -u $DIR/$tfile -o -g $DIR/$tfile &&
5901 error "S/gid is not dropped on MDS"
5904 run_test 72a "Test that remove suid works properly (bug5695) ===="
5906 test_72b() { # bug 24226 -- keep mode setting when size is not changing
5909 [ "$RUNAS_ID" = "$UID" ] && \
5910 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
5911 [ "$RUNAS_ID" -eq 0 ] && \
5912 skip_env "RUNAS_ID = 0 -- skipping" && return
5914 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5915 # Check that testing environment is properly set up. Skip if not
5916 FAIL_ON_ERROR=false check_runas_id_ret $RUNAS_ID $RUNAS_ID $RUNAS || {
5917 skip_env "User $RUNAS_ID does not exist - skipping"
5920 touch $DIR/${tfile}-f{g,u}
5921 test_mkdir $DIR/${tfile}-dg
5922 test_mkdir $DIR/${tfile}-du
5923 chmod 770 $DIR/${tfile}-{f,d}{g,u}
5924 chmod g+s $DIR/${tfile}-{f,d}g
5925 chmod u+s $DIR/${tfile}-{f,d}u
5926 for perm in 777 2777 4777; do
5927 $RUNAS chmod $perm $DIR/${tfile}-fg && error "S/gid file allowed improper chmod to $perm"
5928 $RUNAS chmod $perm $DIR/${tfile}-fu && error "S/uid file allowed improper chmod to $perm"
5929 $RUNAS chmod $perm $DIR/${tfile}-dg && error "S/gid dir allowed improper chmod to $perm"
5930 $RUNAS chmod $perm $DIR/${tfile}-du && error "S/uid dir allowed improper chmod to $perm"
5934 run_test 72b "Test that we keep mode setting if without file data changed (bug 24226)"
5936 # bug 3462 - multiple simultaneous MDC requests
5938 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5939 test_mkdir $DIR/d73-1
5940 test_mkdir $DIR/d73-2
5941 multiop_bg_pause $DIR/d73-1/f73-1 O_c || return 1
5944 lctl set_param fail_loc=0x80000129
5945 $MULTIOP $DIR/d73-1/f73-2 Oc &
5947 lctl set_param fail_loc=0
5949 $MULTIOP $DIR/d73-2/f73-3 Oc &
5953 wait $pid1 || return 1
5957 $CHECKSTAT -t file $DIR/d73-1/f73-1 || return 4
5958 $CHECKSTAT -t file $DIR/d73-1/f73-2 || return 5
5959 $CHECKSTAT -t file $DIR/d73-2/f73-3 || return 6
5963 run_test 73 "multiple MDC requests (should not deadlock)"
5965 test_74a() { # bug 6149, 6184
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
5972 $LCTL set_param fail_loc=0x8000030e
5973 # get any lock that won't be difficult - lookup works.
5975 $LCTL set_param fail_loc=0
5979 run_test 74a "ldlm_enqueue freed-export error path, ls (shouldn't LBUG)"
5981 test_74b() { # bug 13310
5982 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5983 #define OBD_FAIL_LDLM_ENQUEUE_OLD_EXPORT 0x30e
5985 # very important to OR with OBD_FAIL_ONCE (0x80000000) -- otherwise it
5986 # will spin in a tight reconnection loop
5987 $LCTL set_param fail_loc=0x8000030e
5988 # get a "difficult" lock
5990 $LCTL set_param fail_loc=0
5994 run_test 74b "ldlm_enqueue freed-export error path, touch (shouldn't LBUG)"
5997 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5998 #define OBD_FAIL_LDLM_NEW_LOCK
5999 $LCTL set_param fail_loc=0x319
6000 touch $DIR/$tfile && error "touch successful"
6001 $LCTL set_param fail_loc=0
6004 run_test 74c "ldlm_lock_create error path, (shouldn't LBUG)"
6007 awk '/lustre_inode_cache/ {print $2; exit}' /proc/slabinfo
6010 test_76() { # Now for bug 20433, added originally in bug 1443
6011 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6012 local CPUS=$(getconf _NPROCESSORS_ONLN 2>/dev/null)
6013 cancel_lru_locks osc
6014 BEFORE_INODES=$(num_inodes)
6015 echo "before inodes: $BEFORE_INODES"
6017 [ "$SLOW" = "no" ] && COUNT=100
6018 for i in $(seq $COUNT); do
6022 cancel_lru_locks osc
6023 AFTER_INODES=$(num_inodes)
6024 echo "after inodes: $AFTER_INODES"
6026 while [[ $((AFTER_INODES-1*${CPUS:-1})) -gt $BEFORE_INODES ]]; do
6028 AFTER_INODES=$(num_inodes)
6030 echo "wait $wait seconds inodes: $AFTER_INODES"
6031 if [ $wait -gt 30 ]; then
6032 error "inode slab grew from $BEFORE_INODES to $AFTER_INODES"
6036 run_test 76 "confirm clients recycle inodes properly ===="
6042 # Note: in sptlrpc modes which enable its own bulk checksum, the
6043 # original crc32_le bulk checksum will be automatically disabled,
6044 # and the OBD_FAIL_OSC_CHECKSUM_SEND/OBD_FAIL_OSC_CHECKSUM_RECEIVE
6045 # will be checked by sptlrpc code against sptlrpc bulk checksum.
6046 # In this case set_checksums() will not be no-op, because sptlrpc
6047 # bulk checksum will be enabled all through the test.
6049 [ "$ORIG_CSUM" ] || ORIG_CSUM=`lctl get_param -n osc.*.checksums | head -n1`
6050 lctl set_param -n osc.*.checksums $1
6054 export ORIG_CSUM_TYPE="`lctl get_param -n osc.*osc-[^mM]*.checksum_type |
6055 sed 's/.*\[\(.*\)\].*/\1/g' | head -n1`"
6056 CKSUM_TYPES=${CKSUM_TYPES:-"crc32 adler"}
6057 [ "$ORIG_CSUM_TYPE" = "crc32c" ] && CKSUM_TYPES="$CKSUM_TYPES crc32c"
6060 lctl set_param -n osc.*osc-[^mM]*.checksum_type $1
6061 log "set checksum type to $1"
6064 F77_TMP=$TMP/f77-temp
6067 dd if=/dev/urandom of=$F77_TMP bs=1M count=$F77SZ || \
6068 error "error writing to $F77_TMP"
6071 test_77a() { # bug 10889
6072 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6073 $GSS && skip "could not run with gss" && return
6074 [ ! -f $F77_TMP ] && setup_f77
6076 dd if=$F77_TMP of=$DIR/$tfile bs=1M count=$F77SZ || error "dd error"
6080 run_test 77a "normal checksum read/write operation"
6082 test_77b() { # bug 10889
6083 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6084 $GSS && skip "could not run with gss" && return
6085 [ ! -f $F77_TMP ] && setup_f77
6086 #define OBD_FAIL_OSC_CHECKSUM_SEND 0x409
6087 $LCTL set_param fail_loc=0x80000409
6090 dd if=$F77_TMP of=$DIR/$tfile bs=1M count=$F77SZ conv=sync ||
6091 error "dd error: $?"
6092 $LCTL set_param fail_loc=0
6094 for algo in $CKSUM_TYPES; do
6095 cancel_lru_locks osc
6096 set_checksum_type $algo
6097 #define OBD_FAIL_OSC_CHECKSUM_RECEIVE 0x408
6098 $LCTL set_param fail_loc=0x80000408
6099 cmp $F77_TMP $DIR/$tfile || error "file compare failed"
6100 $LCTL set_param fail_loc=0
6103 set_checksum_type $ORIG_CSUM_TYPE
6106 run_test 77b "checksum error on client write, read"
6111 $LCTL set_param osc.*osc-[^mM]*.checksum_dump=0
6113 do_facet ost1 $LCTL set_param obdfilter.*-OST*.checksum_dump=0
6114 [ -n $osc_file_prefix ] && rm -f ${osc_file_prefix}*
6115 $check_ost && [ -n $ost_file_prefix ] &&
6116 do_facet ost1 rm -f ${ost_file_prefix}\*
6120 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6121 $GSS && skip "could not run with gss" && return
6124 local osc_file_prefix
6126 local check_ost=false
6127 local ost_file_prefix
6133 # ensure corruption will occur on first OSS/OST
6134 $LFS setstripe -i 0 $DIR/$tfile
6136 [ ! -f $F77_TMP ] && setup_f77
6137 dd if=$F77_TMP of=$DIR/$tfile bs=1M count=$F77SZ conv=sync ||
6138 error "dd write error: $?"
6139 fid=$($LFS path2fid $DIR/$tfile)
6141 if [ $(lustre_version_code ost1) -ge $(version_code 2.9.57) ]
6144 ost_file_prefix=$(do_facet ost1 $LCTL get_param -n debug_path)
6145 ost_file_prefix=${ost_file_prefix}-checksum_dump-ost-\\${fid}
6147 echo "OSS do not support bulk pages dump upon error"
6150 osc_file_prefix=$($LCTL get_param -n debug_path)
6151 osc_file_prefix=${osc_file_prefix}-checksum_dump-osc-\\${fid}
6153 trap cleanup_77c EXIT
6156 # enable bulk pages dump upon error on Client
6157 $LCTL set_param osc.*osc-[^mM]*.checksum_dump=1
6158 # enable bulk pages dump upon error on OSS
6160 do_facet ost1 $LCTL set_param obdfilter.*-OST*.checksum_dump=1
6162 # flush Client cache to allow next read to reach OSS
6163 cancel_lru_locks osc
6165 #define OBD_FAIL_OSC_CHECKSUM_RECEIVE 0x408
6166 $LCTL set_param fail_loc=0x80000408
6167 dd if=$DIR/$tfile of=/dev/null bs=1M || error "dd read error: $?"
6168 $LCTL set_param fail_loc=0
6172 # check cksum dump on Client
6173 osc_file=$(ls ${osc_file_prefix}*)
6174 [ -n "$osc_file" ] || error "no checksum dump file on Client"
6175 # OBD_FAIL_OSC_CHECKSUM_RECEIVE corrupts with "bad1" at start of file
6176 bad1=$(dd if=$osc_file bs=1 count=4 2>/dev/null) || error "dd error: $?"
6177 [ $bad1 == "bad1" ] || error "unexpected corrupt pattern"
6178 orig_cksum=$(dd if=$F77_TMP bs=1 skip=4 count=1048572 2>/dev/null |
6180 dump_cksum=$(dd if=$osc_file bs=1 skip=4 2>/dev/null | cksum)
6181 [[ "$orig_cksum" == "$dump_cksum" ]] ||
6182 error "dump content does not match on Client"
6184 $check_ost || skip "No need to check cksum dump on OSS"
6186 # check cksum dump on OSS
6187 ost_file=$(do_facet ost1 ls ${ost_file_prefix}\*)
6188 [ -n "$ost_file" ] || error "no checksum dump file on OSS"
6189 orig_cksum=$(dd if=$F77_TMP bs=1048576 count=1 2>/dev/null | cksum)
6190 dump_cksum=$(do_facet ost1 dd if=$ost_file 2>/dev/null \| cksum)
6191 [[ "$orig_cksum" == "$dump_cksum" ]] ||
6192 error "dump content does not match on OSS"
6196 run_test 77c "checksum error on client read with debug"
6198 test_77d() { # bug 10889
6199 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6200 $GSS && skip "could not run with gss" && return
6201 #define OBD_FAIL_OSC_CHECKSUM_SEND 0x409
6202 $LCTL set_param fail_loc=0x80000409
6204 $DIRECTIO write $DIR/$tfile 0 $F77SZ $((1024 * 1024)) ||
6205 error "direct write: rc=$?"
6206 $LCTL set_param fail_loc=0
6209 #define OBD_FAIL_OSC_CHECKSUM_RECEIVE 0x408
6210 $LCTL set_param fail_loc=0x80000408
6212 cancel_lru_locks osc
6213 $DIRECTIO read $DIR/$tfile 0 $F77SZ $((1024 * 1024)) ||
6214 error "direct read: rc=$?"
6215 $LCTL set_param fail_loc=0
6218 run_test 77d "checksum error on OST direct write, read"
6220 test_77f() { # bug 10889
6221 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6222 $GSS && skip "could not run with gss" && return
6224 for algo in $CKSUM_TYPES; do
6225 cancel_lru_locks osc
6226 set_checksum_type $algo
6227 #define OBD_FAIL_OSC_CHECKSUM_SEND 0x409
6228 $LCTL set_param fail_loc=0x409
6229 $DIRECTIO write $DIR/$tfile 0 $F77SZ $((1024 * 1024)) &&
6230 error "direct write succeeded"
6231 $LCTL set_param fail_loc=0
6233 set_checksum_type $ORIG_CSUM_TYPE
6236 run_test 77f "repeat checksum error on write (expect error)"
6238 test_77g() { # bug 10889
6239 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6240 $GSS && skip "could not run with gss" && return
6241 remote_ost_nodsh && skip "remote OST with nodsh" && return
6243 [ ! -f $F77_TMP ] && setup_f77
6245 $SETSTRIPE -c 1 -i 0 $DIR/$tfile
6246 #define OBD_FAIL_OST_CHECKSUM_RECEIVE 0x21a
6247 do_facet ost1 lctl set_param fail_loc=0x8000021a
6249 dd if=$F77_TMP of=$DIR/$tfile bs=1M count=$F77SZ ||
6250 error "write error: rc=$?"
6251 do_facet ost1 lctl set_param fail_loc=0
6254 cancel_lru_locks osc
6255 #define OBD_FAIL_OST_CHECKSUM_SEND 0x21b
6256 do_facet ost1 lctl set_param fail_loc=0x8000021b
6258 cmp $F77_TMP $DIR/$tfile || error "file compare failed"
6259 do_facet ost1 lctl set_param fail_loc=0
6262 run_test 77g "checksum error on OST write, read"
6264 test_77j() { # bug 13805
6265 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6266 $GSS && skip "could not run with gss" && return
6267 #define OBD_FAIL_OSC_CKSUM_ADLER_ONLY 0x40c
6268 lctl set_param fail_loc=0x40c
6269 remount_client $MOUNT
6270 lctl set_param fail_loc=0
6271 # wait async osc connect to finish and reflect updated state value
6273 for (( i=0; i < OSTCOUNT; i++ )) ; do
6274 wait_osc_import_state client ost$((i+1)) FULL
6277 for VALUE in $(lctl get_param osc.*osc-[^mM]*.checksum_type); do
6278 PARAM=$(echo ${VALUE[0]} | cut -d "=" -f1)
6279 algo=$(lctl get_param -n $PARAM | sed 's/.*\[\(.*\)\].*/\1/g')
6280 [ "$algo" = "adler" ] || error "algo set to $algo instead of adler"
6282 remount_client $MOUNT
6284 run_test 77j "client only supporting ADLER32"
6286 [ "$ORIG_CSUM" ] && set_checksums $ORIG_CSUM || true
6295 test_78() { # bug 10901
6296 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6297 remote_ost || { skip_env "local OST" && return; }
6300 F78SIZE=$(($(awk '/MemFree:/ { print $2 }' /proc/meminfo) / 1024))
6301 echo "MemFree: $F78SIZE, Max file size: $MAXFREE"
6302 MEMTOTAL=$(($(awk '/MemTotal:/ { print $2 }' /proc/meminfo) / 1024))
6303 echo "MemTotal: $MEMTOTAL"
6305 # reserve 256MB of memory for the kernel and other running processes,
6306 # and then take 1/2 of the remaining memory for the read/write buffers.
6307 if [ $MEMTOTAL -gt 512 ] ;then
6308 MEMTOTAL=$(((MEMTOTAL - 256 ) / 2))
6310 # for those poor memory-starved high-end clusters...
6311 MEMTOTAL=$((MEMTOTAL / 2))
6313 echo "Mem to use for directio: $MEMTOTAL"
6315 [[ $F78SIZE -gt $MEMTOTAL ]] && F78SIZE=$MEMTOTAL
6316 [[ $F78SIZE -gt 512 ]] && F78SIZE=512
6317 [[ $F78SIZE -gt $((MAXFREE / 1024)) ]] && F78SIZE=$((MAXFREE / 1024))
6318 SMALLESTOST=$($LFS df $DIR | grep OST | awk '{ print $4 }' | sort -n |
6320 echo "Smallest OST: $SMALLESTOST"
6321 [[ $SMALLESTOST -lt 10240 ]] &&
6322 skip "too small OSTSIZE, useless to run large O_DIRECT test" && return 0
6324 trap cleanup_test_78 EXIT
6326 [[ $F78SIZE -gt $((SMALLESTOST * $OSTCOUNT / 1024 - 80)) ]] &&
6327 F78SIZE=$((SMALLESTOST * $OSTCOUNT / 1024 - 80))
6329 [ "$SLOW" = "no" ] && NSEQ=1 && [ $F78SIZE -gt 32 ] && F78SIZE=32
6330 echo "File size: $F78SIZE"
6331 $SETSTRIPE -c $OSTCOUNT $DIR/$tfile || error "setstripe failed"
6332 for i in $(seq 1 $NSEQ); do
6333 FSIZE=$(($F78SIZE / ($NSEQ - $i + 1)))
6334 echo directIO rdwr round $i of $NSEQ
6335 $DIRECTIO rdwr $DIR/$tfile 0 $FSIZE 1048576||error "rdwr failed"
6340 run_test 78 "handle large O_DIRECT writes correctly ============"
6342 test_79() { # bug 12743
6343 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6344 wait_delete_completed
6346 BKTOTAL=$(calc_osc_kbytes kbytestotal)
6347 BKFREE=$(calc_osc_kbytes kbytesfree)
6348 BKAVAIL=$(calc_osc_kbytes kbytesavail)
6350 STRING=`df -P $MOUNT | tail -n 1 | awk '{print $2","$3","$4}'`
6351 DFTOTAL=`echo $STRING | cut -d, -f1`
6352 DFUSED=`echo $STRING | cut -d, -f2`
6353 DFAVAIL=`echo $STRING | cut -d, -f3`
6354 DFFREE=$(($DFTOTAL - $DFUSED))
6356 ALLOWANCE=$((64 * $OSTCOUNT))
6358 if [ $DFTOTAL -lt $(($BKTOTAL - $ALLOWANCE)) ] ||
6359 [ $DFTOTAL -gt $(($BKTOTAL + $ALLOWANCE)) ] ; then
6360 error "df total($DFTOTAL) mismatch OST total($BKTOTAL)"
6362 if [ $DFFREE -lt $(($BKFREE - $ALLOWANCE)) ] ||
6363 [ $DFFREE -gt $(($BKFREE + $ALLOWANCE)) ] ; then
6364 error "df free($DFFREE) mismatch OST free($BKFREE)"
6366 if [ $DFAVAIL -lt $(($BKAVAIL - $ALLOWANCE)) ] ||
6367 [ $DFAVAIL -gt $(($BKAVAIL + $ALLOWANCE)) ] ; then
6368 error "df avail($DFAVAIL) mismatch OST avail($BKAVAIL)"
6371 run_test 79 "df report consistency check ======================="
6373 test_80() { # bug 10718
6374 remote_ost_nodsh && skip "remote OST with nodsh" && return
6375 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6376 # relax strong synchronous semantics for slow backends like ZFS
6377 local soc="obdfilter.*.sync_on_lock_cancel"
6378 local soc_old=$(do_facet ost1 lctl get_param -n $soc | head -n1)
6380 if [ "$soc_old" != "never" -a "$(facet_fstype ost1)" != "ldiskfs" ]; then
6381 hosts=$(for host in $(seq -f "ost%g" 1 $OSTCOUNT); do
6382 facet_active_host $host; done | sort -u)
6383 do_nodes $hosts lctl set_param $soc=never
6386 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=1M
6388 local BEFORE=`date +%s`
6389 cancel_lru_locks osc
6390 local AFTER=`date +%s`
6391 local DIFF=$((AFTER-BEFORE))
6392 if [ $DIFF -gt 1 ] ; then
6393 error "elapsed for 1M@1T = $DIFF"
6396 [ -n "$hosts" ] && do_nodes $hosts lctl set_param $soc=$soc_old
6400 run_test 80 "Page eviction is equally fast at high offsets too ===="
6402 test_81a() { # LU-456
6403 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6404 remote_ost_nodsh && skip "remote OST with nodsh" && return
6405 # define OBD_FAIL_OST_MAPBLK_ENOSPC 0x228
6406 # MUST OR with the OBD_FAIL_ONCE (0x80000000)
6407 do_facet ost1 lctl set_param fail_loc=0x80000228
6409 # write should trigger a retry and success
6410 $SETSTRIPE -i 0 -c 1 $DIR/$tfile
6411 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
6413 if [ $RC -ne 0 ] ; then
6414 error "write should success, but failed for $RC"
6417 run_test 81a "OST should retry write when get -ENOSPC ==============="
6419 test_81b() { # LU-456
6420 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6421 remote_ost_nodsh && skip "remote OST with nodsh" && return
6422 # define OBD_FAIL_OST_MAPBLK_ENOSPC 0x228
6423 # Don't OR with the OBD_FAIL_ONCE (0x80000000)
6424 do_facet ost1 lctl set_param fail_loc=0x228
6426 # write should retry several times and return -ENOSPC finally
6427 $SETSTRIPE -i 0 -c 1 $DIR/$tfile
6428 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
6431 if [ $RC -ne $ENOSPC ] ; then
6432 error "dd should fail for -ENOSPC, but succeed."
6435 run_test 81b "OST should return -ENOSPC when retry still fails ======="
6437 test_82() { # LU-1031
6438 dd if=/dev/zero of=$DIR/$tfile bs=1M count=10
6442 multiop_bg_pause $DIR/$tfile OG${gid1}_g${gid1}c || return 1
6444 multiop_bg_pause $DIR/$tfile O_G${gid2}r10g${gid2}c || return 2
6446 kill -USR1 $MULTIPID2
6448 if [[ `ps h -o comm -p $MULTIPID2` == "" ]]; then
6449 error "First grouplock does not block second one"
6451 echo "Second grouplock blocks first one"
6453 kill -USR1 $MULTIPID1
6457 run_test 82 "Basic grouplock test ==============================="
6460 local sfile="/boot/System.map-$(uname -r)"
6461 # define OBD_FAIL_LLITE_PTASK_IO_FAIL 0x140d
6462 $LCTL set_param fail_loc=0x140d
6463 cp $sfile $DIR/$tfile || error "write failed"
6464 diff -c $sfile $DIR/$tfile || error "files are different"
6465 $LCTL set_param fail_loc=0
6468 run_test 83 "Short write in ptask ==============================="
6471 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" &&
6473 test_mkdir -p $DIR/d99cvsroot
6474 chown $RUNAS_ID $DIR/d99cvsroot
6475 local oldPWD=$PWD # bug 13584, use $TMP as working dir
6478 $RUNAS cvs -d $DIR/d99cvsroot init || error "cvs init failed"
6481 run_test 99a "cvs init ========================================="
6484 [ -z "$(which cvs 2>/dev/null)" ] &&
6485 skip_env "could not find cvs" && return
6486 [ ! -d $DIR/d99cvsroot ] && test_99a
6488 # some versions of cvs import exit(1) when asked to import links or
6489 # files they can't read. ignore those files.
6490 TOIGNORE=$(find . -type l -printf '-I %f\n' -o \
6491 ! -perm /4 -printf '-I %f\n')
6492 $RUNAS cvs -d $DIR/d99cvsroot import -m "nomesg" $TOIGNORE \
6493 d99reposname vtag rtag
6495 run_test 99b "cvs import ======================================="
6498 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" && return
6499 [ ! -d $DIR/d99cvsroot ] && test_99b
6501 test_mkdir -p $DIR/d99reposname
6502 chown $RUNAS_ID $DIR/d99reposname
6503 $RUNAS cvs -d $DIR/d99cvsroot co d99reposname
6505 run_test 99c "cvs checkout ====================================="
6508 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" && return
6509 [ ! -d $DIR/d99cvsroot ] && test_99c
6510 cd $DIR/d99reposname
6512 $RUNAS cvs add -m 'addmsg' foo99
6514 run_test 99d "cvs add =========================================="
6517 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" && return
6518 [ ! -d $DIR/d99cvsroot ] && test_99c
6519 cd $DIR/d99reposname
6522 run_test 99e "cvs update ======================================="
6525 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" && return
6526 [ ! -d $DIR/d99cvsroot ] && test_99d
6527 cd $DIR/d99reposname
6528 $RUNAS cvs commit -m 'nomsg' foo99
6529 rm -fr $DIR/d99cvsroot
6531 run_test 99f "cvs commit ======================================="
6534 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6535 [[ "$NETTYPE" =~ tcp ]] ||
6536 { skip "TCP secure port test, not useful for NETTYPE=$NETTYPE" &&
6539 remote_ost_nodsh && skip "remote OST with nodsh" && return
6540 remote_mds_nodsh && skip "remote MDS with nodsh" && return
6542 { skip "useless for local single node setup" && return; }
6544 netstat -tna | ( rc=1; while read PROT SND RCV LOCAL REMOTE STAT; do
6545 [ "$PROT" != "tcp" ] && continue
6546 RPORT=$(echo $REMOTE | cut -d: -f2)
6547 [ "$RPORT" != "$ACCEPTOR_PORT" ] && continue
6550 LPORT=`echo $LOCAL | cut -d: -f2`
6551 if [ $LPORT -ge 1024 ]; then
6552 echo "bad: $PROT $SND $RCV $LOCAL $REMOTE $STAT"
6554 error_exit "local: $LPORT > 1024, remote: $RPORT"
6557 [ "$rc" = 0 ] || error_exit "privileged port not found" )
6559 run_test 100 "check local port using privileged port ==========="
6561 function get_named_value()
6570 echo $line | sed "s/^$tag[ ]*//"
6577 export CACHE_MAX=$($LCTL get_param -n llite.*.max_cached_mb |
6578 awk '/^max_cached_mb/ { print $2 }')
6581 $LCTL set_param -n llite.*.max_cached_mb $CACHE_MAX
6586 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6587 [ $MDSCOUNT -ge 2 ] && skip "needs < 2 MDTs" && return #LU-4322
6591 local cache_limit=32
6593 $LCTL set_param -n osc.*-osc*.rpc_stats 0
6594 trap cleanup_101a EXIT
6595 $LCTL set_param -n llite.*.read_ahead_stats 0
6596 $LCTL set_param -n llite.*.max_cached_mb $cache_limit
6599 # randomly read 10000 of 64K chunks from file 3x 32MB in size
6601 echo "nreads: $nreads file size: $((cache_limit * 3))MB"
6602 $READS -f $DIR/$tfile -s$((cache_limit * 3192 * 1024)) -b65536 -C -n$nreads -t 180
6605 for s in $($LCTL get_param -n llite.*.read_ahead_stats |
6606 get_named_value 'read but discarded' | cut -d" " -f1); do
6607 discard=$(($discard + $s))
6611 if [[ $(($discard * 10)) -gt $nreads ]]; then
6612 $LCTL get_param osc.*-osc*.rpc_stats
6613 $LCTL get_param llite.*.read_ahead_stats
6614 error "too many ($discard) discarded pages"
6616 rm -f $DIR/$tfile || true
6618 run_test 101a "check read-ahead for random reads ================"
6621 test_mkdir -p $DIR/$tdir
6622 local STRIPE_SIZE=$1
6623 local FILE_LENGTH=$2
6626 local FILE_SIZE_MB=$((FILE_LENGTH / STRIPE_SIZE))
6628 local list=$(comma_list $(osts_nodes))
6629 set_osd_param $list '' read_cache_enable 0
6630 set_osd_param $list '' writethrough_cache_enable 0
6632 trap cleanup_test101bc EXIT
6633 # prepare the read-ahead file
6634 $SETSTRIPE -S $STRIPE_SIZE -i $STRIPE_OFFSET -c $OSTCOUNT $DIR/$tfile
6636 dd if=/dev/zero of=$DIR/$tfile bs=$STRIPE_SIZE \
6637 count=$FILE_SIZE_MB 2> /dev/null
6641 cleanup_test101bc() {
6646 local list=$(comma_list $(osts_nodes))
6647 set_osd_param $list '' read_cache_enable 1
6648 set_osd_param $list '' writethrough_cache_enable 1
6652 awk 'BEGIN{total=0}; {total+=$1}; END{print total}'
6657 local STRIPE_SIZE=$2
6658 local FILE_LENGTH=$3
6659 local RA_INC=1048576
6660 local STRIDE_LENGTH=$((STRIPE_SIZE/READ_SIZE))
6661 local discard_limit=$((((STRIDE_LENGTH - 1)*3/(STRIDE_LENGTH*OSTCOUNT))* \
6662 (STRIDE_LENGTH*OSTCOUNT - STRIDE_LENGTH)))
6663 DISCARD=$($LCTL get_param -n llite.*.read_ahead_stats |
6664 get_named_value 'read but discarded' |
6665 cut -d" " -f1 | calc_total)
6666 if [[ $DISCARD -gt $discard_limit ]]; then
6667 $LCTL get_param llite.*.read_ahead_stats
6668 error "Too many ($DISCARD) discarded pages with size (${READ_SIZE})"
6670 echo "Read-ahead success for size ${READ_SIZE}"
6675 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6676 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
6677 local STRIPE_SIZE=1048576
6678 local STRIDE_SIZE=$((STRIPE_SIZE*OSTCOUNT))
6679 if [ $SLOW == "yes" ]; then
6680 local FILE_LENGTH=$((STRIDE_SIZE * 64))
6682 local FILE_LENGTH=$((STRIDE_SIZE * 8))
6685 local ITERATION=$((FILE_LENGTH / STRIDE_SIZE))
6687 # prepare the read-ahead file
6688 setup_test101bc $STRIPE_SIZE $FILE_LENGTH
6689 cancel_lru_locks osc
6690 for BIDX in 2 4 8 16 32 64 128 256
6692 local BSIZE=$((BIDX*4096))
6693 local READ_COUNT=$((STRIPE_SIZE/BSIZE))
6694 local STRIDE_LENGTH=$((STRIDE_SIZE/BSIZE))
6695 local OFFSET=$((STRIPE_SIZE/BSIZE*(OSTCOUNT - 1)))
6696 $LCTL set_param -n llite.*.read_ahead_stats 0
6697 $READS -f $DIR/$tfile -l $STRIDE_LENGTH -o $OFFSET \
6698 -s $FILE_LENGTH -b $STRIPE_SIZE -a $READ_COUNT -n $ITERATION
6699 cancel_lru_locks osc
6700 ra_check_101 $BSIZE $STRIPE_SIZE $FILE_LENGTH
6705 run_test 101b "check stride-io mode read-ahead ================="
6708 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6709 local STRIPE_SIZE=1048576
6710 local FILE_LENGTH=$((STRIPE_SIZE*100))
6714 setup_test101bc $STRIPE_SIZE $FILE_LENGTH
6716 cancel_lru_locks osc
6717 $LCTL set_param osc.*.rpc_stats 0
6718 $READS -f $DIR/$tfile -s$FILE_LENGTH -b65536 -n$nreads -t 180
6719 for osc_rpc_stats in $($LCTL get_param -N osc.*.rpc_stats); do
6720 local stats=$($LCTL get_param -n $osc_rpc_stats)
6721 local lines=$(echo "$stats" | awk 'END {print NR;}')
6724 if [ $lines -le 20 ]; then
6727 for size in 1 2 4 8; do
6728 local rpc=$(echo "$stats" |
6729 awk '($1 == "'$size':") {print $2; exit; }')
6731 error "Small $((size*4))k read IO $rpc !"
6733 echo "$osc_rpc_stats check passed!"
6738 run_test 101c "check stripe_size aligned read-ahead ================="
6741 $LCTL get_param -n llite.*.max_read_ahead_mb | head -n 1
6742 $LCTL set_param -n llite.*.max_read_ahead_mb $1 > /dev/null 2>&1
6746 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6747 local file=$DIR/$tfile
6748 local sz_MB=${FILESIZE_101d:-500}
6749 local ra_MB=${READAHEAD_MB:-40}
6751 local free_MB=$(($(df -P $DIR | tail -n 1 | awk '{ print $4 }') / 1024))
6752 [ $free_MB -lt $sz_MB ] &&
6753 skip "Need free space ${sz_MB}M, have ${free_MB}M" && return
6755 echo "Create test file $file size ${sz_MB}M, ${free_MB}M free"
6756 $SETSTRIPE -c -1 $file || error "setstripe failed"
6758 dd if=/dev/zero of=$file bs=1M count=$sz_MB || error "dd failed"
6759 echo Cancel LRU locks on lustre client to flush the client cache
6760 cancel_lru_locks osc
6762 echo Disable read-ahead
6763 local old_READAHEAD=$(set_read_ahead 0)
6765 echo Reading the test file $file with read-ahead disabled
6766 local raOFF=$(do_and_time "dd if=$file of=/dev/null bs=1M count=$sz_MB")
6768 echo Cancel LRU locks on lustre client to flush the client cache
6769 cancel_lru_locks osc
6770 echo Enable read-ahead with ${ra_MB}MB
6771 set_read_ahead $ra_MB
6773 echo Reading the test file $file with read-ahead enabled
6774 local raON=$(do_and_time "dd if=$file of=/dev/null bs=1M count=$sz_MB")
6776 echo "read-ahead disabled time read $raOFF"
6777 echo "read-ahead enabled time read $raON"
6779 set_read_ahead $old_READAHEAD
6781 wait_delete_completed
6783 [ $raOFF -le 1 -o $raON -lt $raOFF ] ||
6784 error "readahead ${raON}s > no-readahead ${raOFF}s ${sz_MB}M"
6786 run_test 101d "file read with and without read-ahead enabled"
6789 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6790 local file=$DIR/$tfile
6791 local size_KB=500 #KB
6795 local free_KB=$(df -P $DIR | tail -n 1 | awk '{ print $4 }')
6796 local need_KB=$((count * size_KB))
6797 [[ $free_KB -le $need_KB ]] &&
6798 skip_env "Need free space $need_KB, have $free_KB" && return
6800 echo "Creating $count ${size_KB}K test files"
6801 for ((i = 0; i < $count; i++)); do
6802 dd if=/dev/zero of=$file.$i bs=$bsize count=$size_KB 2>/dev/null
6805 echo "Cancel LRU locks on lustre client to flush the client cache"
6806 cancel_lru_locks osc
6808 echo "Reset readahead stats"
6809 $LCTL set_param -n llite.*.read_ahead_stats 0
6811 for ((i = 0; i < $count; i++)); do
6812 dd if=$file.$i of=/dev/null bs=$bsize count=$size_KB 2>/dev/null
6815 local miss=$($LCTL get_param -n llite.*.read_ahead_stats |
6816 get_named_value 'misses' | cut -d" " -f1 | calc_total)
6818 for ((i = 0; i < $count; i++)); do
6819 rm -rf $file.$i 2>/dev/null
6822 #10000 means 20% reads are missing in readahead
6823 [[ $miss -lt 10000 ]] || error "misses too much for small reads"
6825 run_test 101e "check read-ahead for small read(1k) for small files(500k)"
6828 which iozone || { skip "no iozone installed" && return; }
6830 local old_debug=$($LCTL get_param debug)
6831 old_debug=${old_debug#*=}
6832 $LCTL set_param debug="reada mmap"
6834 # create a test file
6835 iozone -i 0 -+n -r 1m -s 128m -w -f $DIR/$tfile > /dev/null 2>&1
6837 echo Cancel LRU locks on lustre client to flush the client cache
6838 cancel_lru_locks osc
6840 echo Reset readahead stats
6841 $LCTL set_param -n llite.*.read_ahead_stats 0
6843 echo mmap read the file with small block size
6844 iozone -i 1 -u 1 -l 1 -+n -r 32k -s 128m -B -f $DIR/$tfile \
6847 echo checking missing pages
6848 $LCTL get_param llite.*.read_ahead_stats
6849 local miss=$($LCTL get_param -n llite.*.read_ahead_stats |
6850 get_named_value 'misses' | cut -d" " -f1 | calc_total)
6852 $LCTL set_param debug="$old_debug"
6853 [ $miss -lt 3 ] || error "misses too much pages ('$miss')!"
6856 run_test 101f "check mmap read performance"
6858 test_101g_brw_size_test() {
6860 local pages=$((mb * 1048576 / $(page_size)))
6862 $LCTL set_param osc.*.max_pages_per_rpc=${mb}M ||
6863 { error "unable to set max_pages_per_rpc=${mb}M"; return 1; }
6864 for mp in $($LCTL get_param -n osc.*.max_pages_per_rpc); do
6865 [ $mp -ne $pages ] && error "max_pages_per_rpc $mp != $pages" &&
6869 $LCTL set_param -n osc.*.rpc_stats=0
6871 # 10 RPCs should be enough for the test
6873 dd if=/dev/zero of=$DIR/$tfile bs=${mb}M count=$count ||
6874 { error "dd write ${mb} MB blocks failed"; return 3; }
6875 cancel_lru_locks osc
6876 dd of=/dev/null if=$DIR/$tfile bs=${mb}M count=$count ||
6877 { error "dd write ${mb} MB blocks failed"; return 4; }
6879 # calculate number of full-sized read and write RPCs
6880 rpcs=($($LCTL get_param -n 'osc.*.rpc_stats' |
6881 sed -n '/pages per rpc/,/^$/p' |
6882 awk '/'$pages':/ { reads += $2; writes += $6 }; \
6883 END { print reads,writes }'))
6884 [ ${rpcs[0]} -ne $count ] && error "${rpcs[0]} != $count read RPCs" &&
6886 [ ${rpcs[1]} -ne $count ] && error "${rpcs[1]} != $count write RPCs" &&
6894 local osts=$(get_facets OST)
6895 local list=$(comma_list $(osts_nodes))
6896 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
6897 local brw_size="obdfilter.*.brw_size"
6898 local ostver=$(lustre_version_code ost1)
6900 $LFS setstripe -i 0 -c 1 $DIR/$tfile
6902 local orig_mb=$(do_facet ost1 $LCTL get_param -n $brw_size | head -n 1)
6903 if [ $ostver -ge $(version_code 2.8.52) ] ||
6904 [ $ostver -ge $(version_code 2.7.17) -a \
6905 $ostver -lt $(version_code 2.7.50) ]; then
6906 [ $ostver -ge $(version_code 2.9.52) ] && suffix="M"
6907 if [[ $orig_mb -lt 16 ]]; then
6908 save_lustre_params $osts "$brw_size" > $p
6909 do_nodes $list $LCTL set_param -n $brw_size=16$suffix ||
6910 error "set 16MB RPC size failed"
6912 echo "remount client to enable new RPC size"
6913 remount_client $MOUNT || error "remount_client failed"
6916 test_101g_brw_size_test 16 || error "16MB RPC test failed"
6917 # should be able to set brw_size=12, but no rpc_stats for that
6918 test_101g_brw_size_test 8 || error "8MB RPC test failed"
6921 test_101g_brw_size_test 4 || error "4MB RPC test failed"
6923 if [[ $orig_mb -lt 16 ]]; then
6924 restore_lustre_params < $p
6925 remount_client $MOUNT || error "remount_client restore failed"
6928 rm -f $p $DIR/$tfile
6930 run_test 101g "Big bulk(4/16 MiB) readahead"
6933 test_mkdir $DIR/$tdir
6934 chown $RUNAS_ID $DIR/$tdir
6937 STRIPE_COUNT=$OSTCOUNT
6938 [[ $OSTCOUNT -gt 4 ]] && STRIPE_COUNT=4
6940 trap cleanup_test102 EXIT
6942 $1 $SETSTRIPE -S $STRIPE_SIZE -i $STRIPE_OFFSET -c $STRIPE_COUNT $tdir
6944 for num in 1 2 3 4; do
6945 for count in $(seq 1 $STRIPE_COUNT); do
6946 for idx in $(seq 0 $[$STRIPE_COUNT - 1]); do
6947 local size=`expr $STRIPE_SIZE \* $num`
6948 local file=file"$num-$idx-$count"
6949 $1 $SETSTRIPE -S $size -i $idx -c $count $file
6955 $1 tar cf $TMP/f102.tar $tdir --xattrs
6961 rm -rf $DIR/d0.sanity/d102
6965 local testfile=$DIR/$tfile
6969 [ "$UID" != 0 ] && skip_env "must run as root" && return
6970 [ -z "$(lctl get_param -n mdc.*-mdc-*.connect_flags | grep xattr)" ] &&
6971 skip_env "must have user_xattr" && return
6973 [ -z "$(which setfattr 2>/dev/null)" ] &&
6974 skip_env "could not find setfattr" && return
6976 echo "set/get xattr..."
6977 setfattr -n trusted.name1 -v value1 $testfile ||
6978 error "setfattr -n trusted.name1=value1 $testfile failed"
6979 getfattr -n trusted.name1 $testfile 2> /dev/null |
6980 grep "trusted.name1=.value1" ||
6981 error "$testfile missing trusted.name1=value1"
6983 setfattr -n user.author1 -v author1 $testfile ||
6984 error "setfattr -n user.author1=author1 $testfile failed"
6985 getfattr -n user.author1 $testfile 2> /dev/null |
6986 grep "user.author1=.author1" ||
6987 error "$testfile missing trusted.author1=author1"
6990 setfattr -n trusted.name2 -v value2 $testfile ||
6991 error "$testfile unable to set trusted.name2"
6992 setfattr -n trusted.name3 -v value3 $testfile ||
6993 error "$testfile unable to set trusted.name3"
6994 [ $(getfattr -d -m "^trusted" $testfile 2> /dev/null |
6995 grep "trusted.name" | wc -l) -eq 3 ] ||
6996 error "$testfile missing 3 trusted.name xattrs"
6998 setfattr -n user.author2 -v author2 $testfile ||
6999 error "$testfile unable to set user.author2"
7000 setfattr -n user.author3 -v author3 $testfile ||
7001 error "$testfile unable to set user.author3"
7002 [ $(getfattr -d -m "^user" $testfile 2> /dev/null |
7003 grep "user.author" | wc -l) -eq 3 ] ||
7004 error "$testfile missing 3 user.author xattrs"
7006 echo "remove xattr..."
7007 setfattr -x trusted.name1 $testfile ||
7008 error "$testfile error deleting trusted.name1"
7009 getfattr -d -m trusted $testfile 2> /dev/null | grep "trusted.name1" &&
7010 error "$testfile did not delete trusted.name1 xattr"
7012 setfattr -x user.author1 $testfile ||
7013 error "$testfile error deleting user.author1"
7014 echo "set lustre special xattr ..."
7015 $LFS setstripe -c1 $testfile
7016 local lovea=$(getfattr -n "trusted.lov" -e hex $testfile |
7017 awk -F "=" '/trusted.lov/ { print $2 }' )
7018 setfattr -n "trusted.lov" -v $lovea $testfile ||
7019 error "$testfile doesn't ignore setting trusted.lov again"
7020 setfattr -n "trusted.lov" -v "invalid_value" $testfile &&
7021 error "$testfile allow setting invalid trusted.lov"
7024 run_test 102a "user xattr test =================================="
7027 [ -z "$(which setfattr 2>/dev/null)" ] &&
7028 skip_env "could not find setfattr" && return
7030 # b10930: get/set/list trusted.lov xattr
7031 echo "get/set/list trusted.lov xattr ..."
7032 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
7033 local testfile=$DIR/$tfile
7034 $SETSTRIPE -S 65536 -i 1 -c $OSTCOUNT $testfile ||
7035 error "setstripe failed"
7036 local STRIPECOUNT=$($GETSTRIPE -c $testfile) ||
7037 error "getstripe failed"
7038 getfattr -d -m "^trusted" $testfile 2>/dev/null | grep "trusted.lov" ||
7039 error "can't get trusted.lov from $testfile"
7041 local testfile2=${testfile}2
7042 local value=$(getfattr -n trusted.lov $testfile 2>/dev/null |
7043 grep "trusted.lov" | sed -e 's/[^=]\+=//')
7046 setfattr -n trusted.lov -v $value $testfile2
7047 local stripe_size=$($GETSTRIPE -S $testfile2)
7048 local stripe_count=$($GETSTRIPE -c $testfile2)
7049 [[ $stripe_size -eq 65536 ]] ||
7050 error "stripe size $stripe_size != 65536"
7051 [[ $stripe_count -eq $STRIPECOUNT ]] ||
7052 error "stripe count $stripe_count != $STRIPECOUNT"
7055 run_test 102b "getfattr/setfattr for trusted.lov EAs ============"
7058 [ -z "$(which setfattr 2>/dev/null)" ] &&
7059 skip_env "could not find setfattr" && return
7061 # b10930: get/set/list lustre.lov xattr
7062 echo "get/set/list lustre.lov xattr ..."
7063 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
7064 test_mkdir $DIR/$tdir
7065 chown $RUNAS_ID $DIR/$tdir
7066 local testfile=$DIR/$tdir/$tfile
7067 $RUNAS $SETSTRIPE -S 65536 -i 1 -c $OSTCOUNT $testfile ||
7068 error "setstripe failed"
7069 local STRIPECOUNT=$($RUNAS $GETSTRIPE -c $testfile) ||
7070 error "getstripe failed"
7071 $RUNAS getfattr -d -m "^lustre" $testfile 2> /dev/null | \
7072 grep "lustre.lov" || error "can't get lustre.lov from $testfile"
7074 local testfile2=${testfile}2
7075 local value=`getfattr -n lustre.lov $testfile 2> /dev/null | \
7076 grep "lustre.lov" |sed -e 's/[^=]\+=//' `
7078 $RUNAS $MCREATE $testfile2
7079 $RUNAS setfattr -n lustre.lov -v $value $testfile2
7080 local stripe_size=$($RUNAS $GETSTRIPE -S $testfile2)
7081 local stripe_count=$($RUNAS $GETSTRIPE -c $testfile2)
7082 [ $stripe_size -eq 65536 ] || error "stripe size $stripe_size != 65536"
7083 [ $stripe_count -eq $STRIPECOUNT ] ||
7084 error "stripe count $stripe_count != $STRIPECOUNT"
7086 run_test 102c "non-root getfattr/setfattr for lustre.lov EAs ==========="
7088 compare_stripe_info1() {
7089 local stripe_index_all_zero=true
7091 for num in 1 2 3 4; do
7092 for count in $(seq 1 $STRIPE_COUNT); do
7093 for offset in $(seq 0 $[$STRIPE_COUNT - 1]); do
7094 local size=$((STRIPE_SIZE * num))
7095 local file=file"$num-$offset-$count"
7096 stripe_size=$($LFS getstripe -S $PWD/$file)
7097 [[ $stripe_size -ne $size ]] &&
7098 error "$file: size $stripe_size != $size"
7099 stripe_count=$($LFS getstripe -c $PWD/$file)
7100 # allow fewer stripes to be created, ORI-601
7101 [[ $stripe_count -lt $(((3 * count + 3) / 4)) ]] &&
7102 error "$file: count $stripe_count != $count"
7103 stripe_index=$($LFS getstripe -i $PWD/$file)
7104 [[ $stripe_index -ne 0 ]] &&
7105 stripe_index_all_zero=false
7109 $stripe_index_all_zero &&
7110 error "all files are being extracted starting from OST index 0"
7114 have_xattrs_include() {
7115 tar --help | grep -q xattrs-include &&
7116 echo --xattrs-include="lustre.*"
7120 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7121 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
7122 local xinc=$(have_xattrs_include)
7124 tar xf $TMP/f102.tar -C $DIR/$tdir --xattrs $xinc
7126 compare_stripe_info1
7128 run_test 102d "tar restore stripe info from tarfile,not keep osts ==========="
7131 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7132 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
7133 local xinc=$(have_xattrs_include)
7135 test_mkdir $DIR/$tdir.restore
7137 tar cf - --xattrs $tdir | tar xf - \
7138 -C $DIR/$tdir.restore --xattrs $xinc
7139 cd $DIR/$tdir.restore/$tdir
7140 compare_stripe_info1
7142 run_test 102f "tar copy files, not keep osts ==========="
7145 local xsize=${1:-1024} # in bytes
7146 local file=$DIR/$tfile
7148 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep xattr)" ] &&
7149 skip "must have user_xattr" && return 0
7150 [ -z "$(which setfattr 2>/dev/null)" ] &&
7151 skip_env "could not find setfattr" && return 0
7152 [ -z "$(which getfattr 2>/dev/null)" ] &&
7153 skip_env "could not find getfattr" && return 0
7157 local value="$(generate_string $xsize)"
7159 local xbig=trusted.big
7160 log "save $xbig on $file"
7161 setfattr -n $xbig -v $value $file ||
7162 error "saving $xbig on $file failed"
7164 local orig=$(get_xattr_value $xbig $file)
7165 [[ "$orig" != "$value" ]] && error "$xbig different after saving $xbig"
7167 local xsml=trusted.sml
7168 log "save $xsml on $file"
7169 setfattr -n $xsml -v val $file || error "saving $xsml on $file failed"
7171 local new=$(get_xattr_value $xbig $file)
7172 [[ "$new" != "$orig" ]] && error "$xbig different after saving $xsml"
7174 log "grow $xsml on $file"
7175 setfattr -n $xsml -v "$value" $file ||
7176 error "growing $xsml on $file failed"
7178 new=$(get_xattr_value $xbig $file)
7179 [[ "$new" != "$orig" ]] && error "$xbig different after growing $xsml"
7180 log "$xbig still valid after growing $xsml"
7185 test_102h() { # bug 15777
7188 run_test 102h "grow xattr from inside inode to external block"
7191 large_xattr_enabled || { skip "large_xattr disabled" && return; }
7192 grow_xattr $(max_xattr_size)
7194 run_test 102ha "grow xattr from inside inode to external inode"
7196 test_102i() { # bug 17038
7197 [ -z "$(which getfattr 2>/dev/null)" ] &&
7198 skip "could not find getfattr" && return
7200 ln -s $DIR/$tfile $DIR/${tfile}link
7201 getfattr -n trusted.lov $DIR/$tfile ||
7202 error "lgetxattr on $DIR/$tfile failed"
7203 getfattr -h -n trusted.lov $DIR/${tfile}link 2>&1 |
7204 grep -i "no such attr" ||
7205 error "error for lgetxattr on $DIR/${tfile}link is not ENODATA"
7206 rm -f $DIR/$tfile $DIR/${tfile}link
7208 run_test 102i "lgetxattr test on symbolic link ============"
7211 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7212 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
7213 local xinc=$(have_xattrs_include)
7214 setup_test102 "$RUNAS"
7215 chown $RUNAS_ID $DIR/$tdir
7216 $RUNAS tar xf $TMP/f102.tar -C $DIR/$tdir --xattrs $xinc
7218 compare_stripe_info1 "$RUNAS"
7220 run_test 102j "non-root tar restore stripe info from tarfile, not keep osts ==="
7223 [ -z "$(which setfattr 2>/dev/null)" ] &&
7224 skip "could not find setfattr" && return
7226 # b22187 just check that does not crash for regular file.
7227 setfattr -n trusted.lov $DIR/$tfile
7228 # b22187 'setfattr -n trusted.lov' should work as remove LOV EA for directories
7229 local test_kdir=$DIR/$tdir
7230 test_mkdir $test_kdir
7231 local default_size=`$GETSTRIPE -S $test_kdir`
7232 local default_count=`$GETSTRIPE -c $test_kdir`
7233 local default_offset=`$GETSTRIPE -i $test_kdir`
7234 $SETSTRIPE -S 65536 -i 0 -c $OSTCOUNT $test_kdir ||
7235 error 'dir setstripe failed'
7236 setfattr -n trusted.lov $test_kdir
7237 local stripe_size=`$GETSTRIPE -S $test_kdir`
7238 local stripe_count=`$GETSTRIPE -c $test_kdir`
7239 local stripe_offset=`$GETSTRIPE -i $test_kdir`
7240 [ $stripe_size -eq $default_size ] ||
7241 error "stripe size $stripe_size != $default_size"
7242 [ $stripe_count -eq $default_count ] ||
7243 error "stripe count $stripe_count != $default_count"
7244 [ $stripe_offset -eq $default_offset ] ||
7245 error "stripe offset $stripe_offset != $default_offset"
7246 rm -rf $DIR/$tfile $test_kdir
7248 run_test 102k "setfattr without parameter of value shouldn't cause a crash"
7251 [ -z "$(which getfattr 2>/dev/null)" ] &&
7252 skip "could not find getfattr" && return
7254 # LU-532 trusted. xattr is invisible to non-root
7255 local testfile=$DIR/$tfile
7259 echo "listxattr as user..."
7260 chown $RUNAS_ID $testfile
7261 $RUNAS getfattr -d -m '.*' $testfile 2>&1 |
7262 grep -q "trusted" &&
7263 error "$testfile trusted xattrs are user visible"
7267 run_test 102l "listxattr size test =================================="
7269 test_102m() { # LU-3403 llite: error of listxattr when buffer is small
7270 local path=$DIR/$tfile
7273 listxattr_size_check $path || error "listattr_size_check $path failed"
7275 run_test 102m "Ensure listxattr fails on small bufffer ========"
7279 getxattr() { # getxattr path name
7280 # Return the base64 encoding of the value of xattr name on path.
7284 # # getfattr --absolute-names --encoding=base64 --name=trusted.lov $path
7286 # trusted.lov=0s0AvRCwEAAAAGAAAAAAAAAAAEAAACAAAAAAAQAAEAA...AAAAAAAAA=
7288 # We print just 0s0AvRCwEAAAAGAAAAAAAAAAAEAAACAAAAAAAQAAEAA...AAAAAAAAA=
7290 getfattr --absolute-names --encoding=base64 --name=$name $path |
7291 awk -F= -v name=$name '$1 == name {
7292 print substr($0, index($0, "=") + 1);
7296 test_102n() { # LU-4101 mdt: protect internal xattrs
7297 [ -z "$(which setfattr 2>/dev/null)" ] &&
7298 skip "could not find setfattr" && return
7299 if [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.5.50) ]
7301 skip "MDT < 2.5.50 allows setxattr on internal trusted xattrs"
7305 local file0=$DIR/$tfile.0
7306 local file1=$DIR/$tfile.1
7307 local xattr0=$TMP/$tfile.0
7308 local xattr1=$TMP/$tfile.1
7309 local namelist="lov lma lmv link fid version som hsm"
7313 rm -rf $file0 $file1 $xattr0 $xattr1
7316 # Get 'before' xattrs of $file1.
7317 getfattr --absolute-names --dump --match=- $file1 > $xattr0
7319 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.8.53) ] &&
7320 namelist+=" lfsck_namespace"
7321 for name in $namelist; do
7322 # Try to copy xattr from $file0 to $file1.
7323 value=$(getxattr $file0 trusted.$name 2> /dev/null)
7325 setfattr --name=trusted.$name --value="$value" $file1 ||
7326 error "setxattr 'trusted.$name' failed"
7328 # Try to set a garbage xattr.
7329 value=0sVGhlIHF1aWNrIGJyb3duIGZveCBqdW1wcyBvdmVyIGl0c2VsZi4=
7331 if [[ x$name == "xlov" ]]; then
7332 setfattr --name=trusted.lov --value="$value" $file1 &&
7333 error "setxattr invalid 'trusted.lov' success"
7335 setfattr --name=trusted.$name --value="$value" $file1 ||
7336 error "setxattr invalid 'trusted.$name' failed"
7339 # Try to remove the xattr from $file1. We don't care if this
7340 # appears to succeed or fail, we just don't want there to be
7341 # any changes or crashes.
7342 setfattr --remove=$trusted.$name $file1 2> /dev/null
7345 if [ $(lustre_version_code $SINGLEMDS) -gt $(version_code 2.6.50) ]
7348 # Try to copy xattr from $file0 to $file1.
7349 value=$(getxattr $file0 trusted.$name 2> /dev/null)
7351 setfattr --name=trusted.$name --value="$value" $file1 ||
7352 error "setxattr 'trusted.$name' failed"
7354 # Try to set a garbage xattr.
7355 value=0sVGhlIHF1aWNrIGJyb3duIGZveCBqdW1wcyBvdmVyIGl0c2VsZi4=
7357 setfattr --name=trusted.$name --value="$value" $file1 ||
7358 error "setxattr 'trusted.$name' failed"
7360 # Try to remove the xattr from $file1. We don't care if this
7361 # appears to succeed or fail, we just don't want there to be
7362 # any changes or crashes.
7363 setfattr --remove=$trusted.$name $file1 2> /dev/null
7366 # Get 'after' xattrs of file1.
7367 getfattr --absolute-names --dump --match=- $file1 > $xattr1
7369 if ! diff $xattr0 $xattr1; then
7370 error "before and after xattrs of '$file1' differ"
7373 rm -rf $file0 $file1 $xattr0 $xattr1
7377 run_test 102n "silently ignore setxattr on internal trusted xattrs"
7379 test_102p() { # LU-4703 setxattr did not check ownership
7380 local testfile=$DIR/$tfile
7382 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.5.56) ] &&
7383 skip "MDS needs to be at least 2.5.56" && return
7387 echo "setfacl as user..."
7388 $RUNAS setfacl -m "u:$RUNAS_ID:rwx" $testfile
7389 [ $? -ne 0 ] || error "setfacl by $RUNAS_ID was allowed on $testfile"
7391 echo "setfattr as user..."
7392 setfacl -m "u:$RUNAS_ID:---" $testfile
7393 $RUNAS setfattr -x system.posix_acl_access $testfile
7394 [ $? -ne 0 ] || error "setfattr by $RUNAS_ID was allowed on $testfile"
7396 run_test 102p "check setxattr(2) correctly fails without permission"
7399 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.6.92) ] &&
7400 skip "MDS needs to be at least 2.6.92" && return
7401 orphan_linkea_check $DIR/$tfile || error "orphan_linkea_check"
7403 run_test 102q "flistxattr should not return trusted.link EAs for orphans"
7406 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.6.93) ] &&
7407 skip "MDS needs to be at least 2.6.93" && return
7408 touch $DIR/$tfile || error "touch"
7409 setfattr -n user.$(basename $tfile) $DIR/$tfile || error "setfattr"
7410 getfattr -n user.$(basename $tfile) $DIR/$tfile || error "getfattr"
7411 rm $DIR/$tfile || error "rm"
7414 mkdir -p $DIR/$tdir || error "mkdir"
7415 setfattr -n user.$(basename $tdir) $DIR/$tdir || error "setfattr dir"
7416 getfattr -n user.$(basename $tdir) $DIR/$tdir || error "getfattr dir"
7417 setfattr -x user.$(basename $tdir) $DIR/$tdir ||
7418 error "$testfile error deleting user.author1"
7419 getfattr -d -m user.$(basename $tdir) 2> /dev/null |
7420 grep "user.$(basename $tdir)" &&
7421 error "$tdir did not delete user.$(basename $tdir)"
7422 rmdir $DIR/$tdir || error "rmdir"
7425 test_mkdir $DIR/$tdir || error "make striped dir"
7426 setfattr -n user.$(basename $tdir) $DIR/$tdir || error "setfattr dir"
7427 getfattr -n user.$(basename $tdir) $DIR/$tdir || error "getfattr dir"
7428 setfattr -x user.$(basename $tdir) $DIR/$tdir ||
7429 error "$testfile error deleting user.author1"
7430 getfattr -d -m user.$(basename $tdir) 2> /dev/null |
7431 grep "user.$(basename $tdir)" &&
7432 error "$tdir did not delete user.$(basename $tdir)"
7433 rmdir $DIR/$tdir || error "rm striped dir"
7435 run_test 102r "set EAs with empty values"
7439 $LUSTRE/tests/acl/run $LUSTRE/tests/acl/$1.test
7444 [ "$UID" != 0 ] && skip_env "must run as root" && return
7445 [ -z "$(lctl get_param -n mdc.*-mdc-*.connect_flags | grep acl)" ] &&
7446 skip "must have acl enabled" && return
7447 [ -z "$(which setfacl 2>/dev/null)" ] &&
7448 skip_env "could not find setfacl" && return
7449 $GSS && skip "could not run under gss" && return
7450 remote_mds_nodsh && skip "remote MDS with nodsh" && return
7452 gpasswd -a daemon bin # LU-5641
7453 do_facet $SINGLEMDS gpasswd -a daemon bin # LU-5641
7455 declare -a identity_old
7457 for num in $(seq $MDSCOUNT); do
7458 switch_identity $num true || identity_old[$num]=$?
7466 echo "performing cp ..."
7467 run_acl_subtest cp || error "run_acl_subtest cp failed"
7468 echo "performing getfacl-noacl..."
7469 run_acl_subtest getfacl-noacl || error "getfacl-noacl test failed"
7470 echo "performing misc..."
7471 run_acl_subtest misc || error "misc test failed"
7472 echo "performing permissions..."
7473 run_acl_subtest permissions || error "permissions failed"
7474 # LU-1482 mdd: Setting xattr are properly checked with and without ACLs
7475 if [ $(lustre_version_code $SINGLEMDS) -gt $(version_code 2.8.55) -o \
7476 \( $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.6) -a \
7477 $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.5.29) \) ]
7479 echo "performing permissions xattr..."
7480 run_acl_subtest permissions_xattr ||
7481 error "permissions_xattr failed"
7483 echo "performing setfacl..."
7484 run_acl_subtest setfacl || error "setfacl test failed"
7486 # inheritance test got from HP
7487 echo "performing inheritance..."
7488 cp $LUSTRE/tests/acl/make-tree . || error "cannot copy make-tree"
7489 chmod +x make-tree || error "chmod +x failed"
7490 run_acl_subtest inheritance || error "inheritance test failed"
7493 echo "LU-974 ignore umask when acl is enabled..."
7494 run_acl_subtest 974 || error "LU-974 umask test failed"
7495 if [ $MDSCOUNT -ge 2 ]; then
7496 run_acl_subtest 974_remote ||
7497 error "LU-974 umask test failed under remote dir"
7500 echo "LU-2561 newly created file is same size as directory..."
7501 if [ $(facet_fstype $SINGLEMDS) != "zfs" ]; then
7502 run_acl_subtest 2561 || error "LU-2561 test failed"
7504 run_acl_subtest 2561_zfs || error "LU-2561 zfs test failed"
7507 run_acl_subtest 4924 || error "LU-4924 test failed"
7512 for num in $(seq $MDSCOUNT); do
7513 if [ "${identity_old[$num]}" = 1 ]; then
7514 switch_identity $num false || identity_old[$num]=$?
7518 run_test 103a "acl test ========================================="
7521 remote_mds_nodsh && skip "remote MDS with nodsh" && return
7523 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
7524 local mountopts=$MDS_MOUNT_OPTS
7526 if [[ "$MDS_MOUNT_OPTS" =~ "noacl" ]]; then
7530 stop $SINGLEMDS || error "failed to stop MDT."
7532 if [ -z "$MDS_MOUNT_OPTS" ]; then
7533 MDS_MOUNT_OPTS="-o noacl"
7535 MDS_MOUNT_OPTS="${MDS_MOUNT_OPTS},noacl"
7537 start $SINGLEMDS $MDT_DEV $MDS_MOUNT_OPTS ||
7538 error "failed to start MDT."
7539 MDS_MOUNT_OPTS=$mountopts
7543 setfacl -m u:bin:rw $DIR/$tfile && error "setfacl should fail"
7547 stop $SINGLEMDS || error "failed to stop MDT."
7549 start $SINGLEMDS $MDT_DEV $MDS_MOUNT_OPTS ||
7550 error "failed to start MDT."
7555 run_test 103b "MDS mount option 'noacl'"
7559 cp -rp $DIR/$tdir $DIR/$tdir.bak
7561 [ -n "$(getfattr -d -m. $DIR/$tdir | grep posix_acl_default)" ] &&
7562 error "$DIR/$tdir shouldn't contain default ACL"
7563 [ -n "$(getfattr -d -m. $DIR/$tdir.bak | grep posix_acl_default)" ] &&
7564 error "$DIR/$tdir.bak shouldn't contain default ACL"
7567 run_test 103c "'cp -rp' won't set empty acl"
7570 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7572 lfs df || error "lfs df failed"
7573 lfs df -ih || error "lfs df -ih failed"
7574 lfs df -h $DIR || error "lfs df -h $DIR failed"
7575 lfs df -i $DIR || error "lfs df -i $DIR failed"
7576 lfs df $DIR/$tfile || error "lfs df $DIR/$tfile failed"
7577 lfs df -ih $DIR/$tfile || error "lfs df -ih $DIR/$tfile failed"
7579 local OSC=$(lctl dl | grep OST0000-osc-[^M] | awk '{ print $4 }')
7580 lctl --device %$OSC deactivate
7581 lfs df || error "lfs df with deactivated OSC failed"
7582 lctl --device %$OSC activate
7583 # wait the osc back to normal
7584 wait_osc_import_state client ost FULL
7586 lfs df || error "lfs df with reactivated OSC failed"
7589 run_test 104a "lfs df [-ih] [path] test ========================="
7592 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7593 [ $RUNAS_ID -eq $UID ] &&
7594 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
7596 denied_cnt=$(($($RUNAS $LFS check servers 2>&1 |
7597 grep "Permission denied" | wc -l)))
7598 if [ $denied_cnt -ne 0 ]; then
7599 error "lfs check servers test failed"
7602 run_test 104b "$RUNAS lfs check servers test ===================="
7605 # doesn't work on 2.4 kernels
7607 if $(flock_is_enabled); then
7608 flocks_test 1 on -f $DIR/$tfile || error "fail flock on"
7610 flocks_test 1 off -f $DIR/$tfile || error "fail flock off"
7614 run_test 105a "flock when mounted without -o flock test ========"
7618 if $(flock_is_enabled); then
7619 flocks_test 1 on -c $DIR/$tfile || error "fail flock on"
7621 flocks_test 1 off -c $DIR/$tfile || error "fail flock off"
7625 run_test 105b "fcntl when mounted without -o flock test ========"
7629 if $(flock_is_enabled); then
7630 flocks_test 1 on -l $DIR/$tfile || error "fail flock on"
7632 flocks_test 1 off -l $DIR/$tfile || error "fail flock off"
7636 run_test 105c "lockf when mounted without -o flock test ========"
7638 test_105d() { # bug 15924
7639 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7640 test_mkdir -p $DIR/$tdir
7641 flock_is_enabled || { skip "mount w/o flock enabled" && return; }
7642 #define OBD_FAIL_LDLM_CP_CB_WAIT 0x315
7643 $LCTL set_param fail_loc=0x80000315
7644 flocks_test 2 $DIR/$tdir
7646 run_test 105d "flock race (should not freeze) ========"
7648 test_105e() { # bug 22660 && 22040
7649 flock_is_enabled || { skip "mount w/o flock enabled" && return; }
7651 flocks_test 3 $DIR/$tfile
7653 run_test 105e "Two conflicting flocks from same process ======="
7655 test_106() { #bug 10921
7656 test_mkdir -p $DIR/$tdir
7657 $DIR/$tdir && error "exec $DIR/$tdir succeeded"
7658 chmod 777 $DIR/$tdir || error "chmod $DIR/$tdir failed"
7660 run_test 106 "attempt exec of dir followed by chown of that dir"
7663 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7670 local save_pattern=$(sysctl -n kernel.core_pattern)
7671 local save_uses_pid=$(sysctl -n kernel.core_uses_pid)
7672 sysctl -w kernel.core_pattern=$file
7673 sysctl -w kernel.core_uses_pid=0
7681 kill -s 11 $SLEEPPID
7683 if [ -e $file ]; then
7684 size=`stat -c%s $file`
7685 [ $size -eq 0 ] && error "Fail to create core file $file"
7687 error "Fail to create core file $file"
7690 sysctl -w kernel.core_pattern=$save_pattern
7691 sysctl -w kernel.core_uses_pid=$save_uses_pid
7694 run_test 107 "Coredump on SIG"
7697 test_mkdir -p $DIR/$tdir
7698 test_mkdir $DIR/$tdir/$(str_repeat 'a' 255) ||
7699 error "mkdir with 255 char failed"
7700 test_mkdir $DIR/$tdir/$(str_repeat 'b' 256) &&
7701 error "mkdir with 256 char should fail, but did not"
7702 touch $DIR/$tdir/$(str_repeat 'x' 255) ||
7703 error "create with 255 char failed"
7704 touch $DIR/$tdir/$(str_repeat 'y' 256) &&
7705 error "create with 256 char should fail, but did not"
7710 run_test 110 "filename length checking"
7713 # Purpose: To verify dynamic thread (OSS) creation.
7716 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7717 remote_ost_nodsh && skip "remote OST with nodsh" && return
7719 # Lustre does not stop service threads once they are started.
7720 # Reset number of running threads to default.
7725 local save_params="$TMP/sanity-$TESTNAME.parameters"
7727 # Get ll_ost_io count before I/O
7728 OSTIO_pre=$(do_facet ost1 \
7729 "$LCTL get_param ost.OSS.ost_io.threads_started | cut -d= -f2")
7730 # Exit if lustre is not running (ll_ost_io not running).
7731 [ -z "$OSTIO_pre" ] && error "no OSS threads"
7733 echo "Starting with $OSTIO_pre threads"
7734 local thread_max=$((OSTIO_pre * 2))
7735 local rpc_in_flight=$((thread_max * 2))
7736 # Number of I/O Process proposed to be started.
7738 local facets=$(get_facets OST)
7740 save_lustre_params client \
7741 "osc.*OST*.max_rpcs_in_flight" > $save_params
7742 save_lustre_params $facets \
7743 "ost.OSS.ost_io.threads_max" >> $save_params
7745 # Set in_flight to $rpc_in_flight
7746 $LCTL set_param osc.*OST*.max_rpcs_in_flight=$rpc_in_flight ||
7747 error "Failed to set max_rpcs_in_flight to $rpc_in_flight"
7748 nfiles=${rpc_in_flight}
7749 # Set ost thread_max to $thread_max
7751 "$LCTL set_param ost.OSS.ost_io.threads_max=$thread_max"
7753 # 5 Minutes should be sufficient for max number of OSS
7754 # threads(thread_max) to be created.
7758 local WTL=${WTL:-"$LUSTRE/tests/write_time_limit"}
7760 for i in $(seq $nfiles); do
7761 local file=$DIR/$tdir/${tfile}-$i
7762 $LFS setstripe -c -1 -i 0 $file
7763 ($WTL $file $timeout)&
7766 # I/O Started - Wait for thread_started to reach thread_max or report
7767 # error if thread_started is more than thread_max.
7768 echo "Waiting for thread_started to reach thread_max"
7769 local thread_started=0
7770 local end_time=$((SECONDS + timeout))
7772 while [ $SECONDS -le $end_time ] ; do
7774 # Get ost i/o thread_started count.
7775 thread_started=$(do_facet ost1 \
7777 ost.OSS.ost_io.threads_started | cut -d= -f2")
7778 # Break out if thread_started is equal/greater than thread_max
7779 if [[ $thread_started -ge $thread_max ]]; then
7780 echo ll_ost_io thread_started $thread_started, \
7781 equal/greater than thread_max $thread_max
7787 # Cleanup - We have the numbers, Kill i/o jobs if running.
7788 jobcount=($(jobs -p))
7789 for i in $(seq 0 $((${#jobcount[@]}-1)))
7791 kill -9 ${jobcount[$i]}
7792 if [ $? -ne 0 ] ; then
7794 Failed to Kill \'WTL\(I/O\)\' with pid ${jobcount[$i]}
7798 # Cleanup files left by WTL binary.
7799 for i in $(seq $nfiles); do
7800 local file=$DIR/$tdir/${tfile}-$i
7802 if [ $? -ne 0 ] ; then
7803 echo "Warning: Failed to delete file $file"
7807 restore_lustre_params <$save_params
7808 rm -f $save_params || echo "Warning: delete file '$save_params' failed"
7810 # Error out if no new thread has started or Thread started is greater
7812 if [[ $thread_started -le $OSTIO_pre ||
7813 $thread_started -gt $thread_max ]]; then
7814 error "ll_ost_io: thread_started $thread_started" \
7815 "OSTIO_pre $OSTIO_pre, thread_max $thread_max." \
7816 "No new thread started or thread started greater " \
7820 run_test 115 "verify dynamic thread creation===================="
7823 wait_delete_completed
7824 AVAIL=($(lctl get_param -n osc.*[oO][sS][cC]-[^M]*.kbytesavail))
7825 echo "OST kbytes available: ${AVAIL[@]}"
7830 for ((i = 0; i < ${#AVAIL[@]}; i++)); do
7831 #echo OST $i: ${AVAIL[i]}kb
7832 if [[ ${AVAIL[i]} -gt $MAXV ]]; then
7836 if [[ ${AVAIL[i]} -lt $MINV ]]; then
7841 echo "Min free space: OST $MINI: $MINV"
7842 echo "Max free space: OST $MAXI: $MAXV"
7845 test_116a() { # was previously test_116()
7846 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7847 remote_mds_nodsh && skip "remote MDS with nodsh" && return
7849 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
7851 echo -n "Free space priority "
7852 do_facet $SINGLEMDS lctl get_param -n lo*.*-mdtlov.qos_prio_free |
7857 [ $MINV -eq 0 ] && skip "no free space in OST$MINI, skip" && return
7858 [ $MINV -gt 10000000 ] && skip "too much free space in OST$MINI, skip" \
7860 trap simple_cleanup_common EXIT
7863 # Check if we need to generate uneven OSTs
7864 test_mkdir -p $DIR/$tdir/OST${MINI}
7865 local FILL=$((MINV / 4))
7866 local DIFF=$((MAXV - MINV))
7867 local DIFF2=$((DIFF * 100 / MINV))
7869 local threshold=$(do_facet $SINGLEMDS \
7870 lctl get_param -n *.*MDT0000-mdtlov.qos_threshold_rr | head -n1)
7871 threshold=${threshold%%%}
7872 echo -n "Check for uneven OSTs: "
7873 echo -n "diff=${DIFF}KB (${DIFF2}%) must be > ${threshold}% ..."
7875 if [[ $DIFF2 -gt $threshold ]]; then
7877 echo "Don't need to fill OST$MINI"
7879 # generate uneven OSTs. Write 2% over the QOS threshold value
7881 DIFF=$((threshold - DIFF2 + 2))
7882 DIFF2=$((MINV * DIFF / 100))
7883 echo "Fill $DIFF% remaining space in OST$MINI with ${DIFF2}KB"
7884 $SETSTRIPE -i $MINI -c 1 $DIR/$tdir/OST${MINI} ||
7885 error "setstripe failed"
7886 DIFF=$((DIFF2 / 2048))
7888 while [ $i -lt $DIFF ]; do
7890 dd if=/dev/zero of=$DIR/$tdir/OST${MINI}/$tfile-$i \
7891 bs=2M count=1 2>/dev/null
7900 DIFF=$((MAXV - MINV))
7901 DIFF2=$((DIFF * 100 / MINV))
7902 echo -n "diff=$DIFF=$DIFF2% must be > $threshold% for QOS mode..."
7903 if [ $DIFF2 -gt $threshold ]; then
7906 echo "failed - QOS mode won't be used"
7907 skip "QOS imbalance criteria not met"
7908 simple_cleanup_common
7917 # now fill using QOS
7918 $SETSTRIPE -c 1 $DIR/$tdir
7919 FILL=$((FILL / 200))
7920 if [ $FILL -gt 600 ]; then
7923 echo "writing $FILL files to QOS-assigned OSTs"
7925 while [ $i -lt $FILL ]; do
7927 dd if=/dev/zero of=$DIR/$tdir/$tfile-$i bs=200k \
7931 echo "wrote $i 200k files"
7935 echo "Note: free space may not be updated, so measurements might be off"
7937 DIFF2=$((MAXV - MINV))
7938 echo "free space delta: orig $DIFF final $DIFF2"
7939 [ $DIFF2 -gt $DIFF ] && echo "delta got worse!"
7940 DIFF=$((MINV1 - ${AVAIL[$MINI1]}))
7941 echo "Wrote ${DIFF}KB to smaller OST $MINI1"
7942 DIFF2=$((MAXV1 - ${AVAIL[$MAXI1]}))
7943 echo "Wrote ${DIFF2}KB to larger OST $MAXI1"
7944 if [[ $DIFF -gt 0 ]]; then
7945 FILL=$((DIFF2 * 100 / DIFF - 100))
7946 echo "Wrote ${FILL}% more data to larger OST $MAXI1"
7949 # Figure out which files were written where
7950 UUID=$(lctl get_param -n lov.${FSNAME}-clilov-*.target_obd |
7951 awk '/'$MINI1': / {print $2; exit}')
7953 MINC=$($GETSTRIPE --ost $UUID $DIR/$tdir | grep $DIR | wc -l)
7954 echo "$MINC files created on smaller OST $MINI1"
7955 UUID=$(lctl get_param -n lov.${FSNAME}-clilov-*.target_obd |
7956 awk '/'$MAXI1': / {print $2; exit}')
7958 MAXC=$($GETSTRIPE --ost $UUID $DIR/$tdir | grep $DIR | wc -l)
7959 echo "$MAXC files created on larger OST $MAXI1"
7960 if [[ $MINC -gt 0 ]]; then
7961 FILL=$((MAXC * 100 / MINC - 100))
7962 echo "Wrote ${FILL}% more files to larger OST $MAXI1"
7964 [[ $MAXC -gt $MINC ]] ||
7965 error_ignore LU-9 "stripe QOS didn't balance free space"
7966 simple_cleanup_common
7968 run_test 116a "stripe QOS: free space balance ==================="
7970 test_116b() { # LU-2093
7971 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7972 remote_mds_nodsh && skip "remote MDS with nodsh" && return
7974 #define OBD_FAIL_MDS_OSC_CREATE_FAIL 0x147
7975 local old_rr=$(do_facet $SINGLEMDS lctl get_param -n \
7976 lo*.$FSNAME-MDT0000-mdtlov.qos_threshold_rr | head -1)
7977 [ -z "$old_rr" ] && skip "no QOS" && return 0
7978 do_facet $SINGLEMDS lctl set_param \
7979 lo*.$FSNAME-MDT0000-mdtlov.qos_threshold_rr=0
7981 do_facet $SINGLEMDS lctl set_param fail_loc=0x147
7982 createmany -o $DIR/$tdir/f- 20 || error "can't create"
7983 do_facet $SINGLEMDS lctl set_param fail_loc=0
7985 do_facet $SINGLEMDS lctl set_param \
7986 lo*.$FSNAME-MDT0000-mdtlov.qos_threshold_rr=$old_rr
7988 run_test 116b "QoS shouldn't LBUG if not enough OSTs found on the 2nd pass"
7990 test_117() # bug 10891
7992 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7993 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1
7994 #define OBD_FAIL_OST_SETATTR_CREDITS 0x21e
7995 lctl set_param fail_loc=0x21e
7996 > $DIR/$tfile || error "truncate failed"
7997 lctl set_param fail_loc=0
7998 echo "Truncate succeeded."
8001 run_test 117 "verify osd extend =========="
8003 NO_SLOW_RESENDCOUNT=4
8004 export OLD_RESENDCOUNT=""
8005 set_resend_count () {
8006 local PROC_RESENDCOUNT="osc.${FSNAME}-OST*-osc-*.resend_count"
8007 OLD_RESENDCOUNT=$(lctl get_param -n $PROC_RESENDCOUNT | head -n1)
8008 lctl set_param -n $PROC_RESENDCOUNT $1
8009 echo resend_count is set to $(lctl get_param -n $PROC_RESENDCOUNT)
8012 # for reduce test_118* time (b=14842)
8013 [ "$SLOW" = "no" ] && set_resend_count $NO_SLOW_RESENDCOUNT
8015 # Reset async IO behavior after error case
8017 FILE=$DIR/reset_async
8019 # Ensure all OSCs are cleared
8020 $SETSTRIPE -c -1 $FILE
8021 dd if=/dev/zero of=$FILE bs=64k count=$OSTCOUNT
8026 test_118a() #bug 11710
8028 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8031 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
8032 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
8033 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
8035 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
8036 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
8041 run_test 118a "verify O_SYNC works =========="
8045 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8046 remote_ost_nodsh && skip "remote OST with nodsh" && return
8050 #define OBD_FAIL_SRV_ENOENT 0x217
8051 set_nodes_failloc "$(osts_nodes)" 0x217
8052 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
8054 set_nodes_failloc "$(osts_nodes)" 0
8055 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
8056 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
8059 if [[ $RC -eq 0 ]]; then
8060 error "Must return error due to dropped pages, rc=$RC"
8064 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
8065 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
8069 echo "Dirty pages not leaked on ENOENT"
8071 # Due to the above error the OSC will issue all RPCs syncronously
8072 # until a subsequent RPC completes successfully without error.
8073 $MULTIOP $DIR/$tfile Ow4096yc
8078 run_test 118b "Reclaim dirty pages on fatal error =========="
8082 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8084 # for 118c, restore the original resend count, LU-1940
8085 [ "$SLOW" = "no" ] && [ -n "$OLD_RESENDCOUNT" ] &&
8086 set_resend_count $OLD_RESENDCOUNT
8087 remote_ost_nodsh && skip "remote OST with nodsh" && return
8091 #define OBD_FAIL_OST_EROFS 0x216
8092 set_nodes_failloc "$(osts_nodes)" 0x216
8094 # multiop should block due to fsync until pages are written
8095 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
8099 if [[ `ps h -o comm -p $MULTIPID` != "multiop" ]]; then
8100 error "Multiop failed to block on fsync, pid=$MULTIPID"
8103 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
8105 if [[ $WRITEBACK -eq 0 ]]; then
8106 error "No page in writeback, writeback=$WRITEBACK"
8109 set_nodes_failloc "$(osts_nodes)" 0
8112 if [[ $RC -ne 0 ]]; then
8113 error "Multiop fsync failed, rc=$RC"
8116 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
8117 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
8119 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
8120 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
8124 echo "Dirty pages flushed via fsync on EROFS"
8127 run_test 118c "Fsync blocks on EROFS until dirty pages are flushed =========="
8129 # continue to use small resend count to reduce test_118* time (b=14842)
8130 [ "$SLOW" = "no" ] && set_resend_count $NO_SLOW_RESENDCOUNT
8134 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8135 remote_ost_nodsh && skip "remote OST with nodsh" && return
8139 #define OBD_FAIL_OST_BRW_PAUSE_BULK
8140 set_nodes_failloc "$(osts_nodes)" 0x214
8141 # multiop should block due to fsync until pages are written
8142 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
8146 if [[ `ps h -o comm -p $MULTIPID` != "multiop" ]]; then
8147 error "Multiop failed to block on fsync, pid=$MULTIPID"
8150 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
8152 if [[ $WRITEBACK -eq 0 ]]; then
8153 error "No page in writeback, writeback=$WRITEBACK"
8156 wait $MULTIPID || error "Multiop fsync failed, rc=$?"
8157 set_nodes_failloc "$(osts_nodes)" 0
8159 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
8160 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
8162 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
8163 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
8167 echo "Dirty pages gaurenteed flushed via fsync"
8170 run_test 118d "Fsync validation inject a delay of the bulk =========="
8173 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8176 #define OBD_FAIL_OSC_BRW_PREP_REQ2 0x40a
8177 lctl set_param fail_loc=0x8000040a
8179 # Should simulate EINVAL error which is fatal
8180 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
8182 if [[ $RC -eq 0 ]]; then
8183 error "Must return error due to dropped pages, rc=$RC"
8186 lctl set_param fail_loc=0x0
8188 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
8189 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
8190 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
8192 if [[ $LOCKED -ne 0 ]]; then
8193 error "Locked pages remain in cache, locked=$LOCKED"
8196 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
8197 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
8201 echo "No pages locked after fsync"
8206 run_test 118f "Simulate unrecoverable OSC side error =========="
8209 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8212 #define OBD_FAIL_OSC_BRW_PREP_REQ 0x406
8213 lctl set_param fail_loc=0x406
8215 # simulate local -ENOMEM
8216 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
8219 lctl set_param fail_loc=0
8220 if [[ $RC -eq 0 ]]; then
8221 error "Must return error due to dropped pages, rc=$RC"
8224 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
8225 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
8226 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
8228 if [[ $LOCKED -ne 0 ]]; then
8229 error "Locked pages remain in cache, locked=$LOCKED"
8232 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
8233 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
8237 echo "No pages locked after fsync"
8242 run_test 118g "Don't stay in wait if we got local -ENOMEM =========="
8245 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8246 remote_ost_nodsh && skip "remote OST with nodsh" && return
8250 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
8251 set_nodes_failloc "$(osts_nodes)" 0x20e
8252 # Should simulate ENOMEM error which is recoverable and should be handled by timeout
8253 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
8256 set_nodes_failloc "$(osts_nodes)" 0
8257 if [[ $RC -eq 0 ]]; then
8258 error "Must return error due to dropped pages, rc=$RC"
8261 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
8262 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
8263 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
8265 if [[ $LOCKED -ne 0 ]]; then
8266 error "Locked pages remain in cache, locked=$LOCKED"
8269 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
8270 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
8274 echo "No pages locked after fsync"
8278 run_test 118h "Verify timeout in handling recoverables errors =========="
8280 [ "$SLOW" = "no" ] && [ -n "$OLD_RESENDCOUNT" ] && set_resend_count $OLD_RESENDCOUNT
8283 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8284 remote_ost_nodsh && skip "remote OST with nodsh" && return
8288 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
8289 set_nodes_failloc "$(osts_nodes)" 0x20e
8291 # Should simulate ENOMEM error which is recoverable and should be handled by timeout
8292 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
8295 set_nodes_failloc "$(osts_nodes)" 0
8299 if [[ $RC -ne 0 ]]; then
8300 error "got error, but should be not, rc=$RC"
8303 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
8304 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
8305 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
8306 if [[ $LOCKED -ne 0 ]]; then
8307 error "Locked pages remain in cache, locked=$LOCKED"
8310 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
8311 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
8315 echo "No pages locked after fsync"
8319 run_test 118i "Fix error before timeout in recoverable error =========="
8321 [ "$SLOW" = "no" ] && set_resend_count 4
8324 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8325 remote_ost_nodsh && skip "remote OST with nodsh" && return
8329 #define OBD_FAIL_OST_BRW_WRITE_BULK2 0x220
8330 set_nodes_failloc "$(osts_nodes)" 0x220
8332 # return -EIO from OST
8333 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
8335 set_nodes_failloc "$(osts_nodes)" 0x0
8336 if [[ $RC -eq 0 ]]; then
8337 error "Must return error due to dropped pages, rc=$RC"
8340 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
8341 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
8342 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
8343 if [[ $LOCKED -ne 0 ]]; then
8344 error "Locked pages remain in cache, locked=$LOCKED"
8347 # in recoverable error on OST we want resend and stay until it finished
8348 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
8349 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
8353 echo "No pages locked after fsync"
8357 run_test 118j "Simulate unrecoverable OST side error =========="
8361 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8362 remote_ost_nodsh && skip "remote OSTs with nodsh" && return
8364 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
8365 set_nodes_failloc "$(osts_nodes)" 0x20e
8366 test_mkdir -p $DIR/$tdir
8368 for ((i=0;i<10;i++)); do
8369 (dd if=/dev/zero of=$DIR/$tdir/$tfile-$i bs=1M count=10 || \
8370 error "dd to $DIR/$tdir/$tfile-$i failed" )&
8377 set_nodes_failloc "$(osts_nodes)" 0
8380 run_test 118k "bio alloc -ENOMEM and IO TERM handling ========="
8384 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8386 test_mkdir -p $DIR/$tdir
8387 $MULTIOP $DIR/$tdir Dy || error "fsync dir failed"
8390 run_test 118l "fsync dir ========="
8392 test_118m() # LU-3066
8394 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8395 test_mkdir -p $DIR/$tdir
8396 $MULTIOP $DIR/$tdir DY || error "fdatasync dir failed"
8399 run_test 118m "fdatasync dir ========="
8401 [ "$SLOW" = "no" ] && [ -n "$OLD_RESENDCOUNT" ] && set_resend_count $OLD_RESENDCOUNT
8403 test_119a() # bug 11737
8405 BSIZE=$((512 * 1024))
8406 directio write $DIR/$tfile 0 1 $BSIZE
8407 # We ask to read two blocks, which is more than a file size.
8408 # directio will indicate an error when requested and actual
8409 # sizes aren't equeal (a normal situation in this case) and
8410 # print actual read amount.
8411 NOB=`directio read $DIR/$tfile 0 2 $BSIZE | awk '/error/ {print $6}'`
8412 if [ "$NOB" != "$BSIZE" ]; then
8413 error "read $NOB bytes instead of $BSIZE"
8417 run_test 119a "Short directIO read must return actual read amount"
8419 test_119b() # bug 11737
8421 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
8423 $SETSTRIPE -c 2 $DIR/$tfile || error "setstripe failed"
8424 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=1 || error "dd failed"
8426 $MULTIOP $DIR/$tfile oO_RDONLY:O_DIRECT:r$((2048 * 1024)) || \
8427 error "direct read failed"
8430 run_test 119b "Sparse directIO read must return actual read amount"
8432 test_119c() # bug 13099
8435 directio write $DIR/$tfile 3 1 $BSIZE || error "direct write failed"
8436 directio readhole $DIR/$tfile 0 2 $BSIZE || error "reading hole failed"
8439 run_test 119c "Testing for direct read hitting hole"
8441 test_119d() # bug 15950
8443 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8444 MAX_RPCS_IN_FLIGHT=`$LCTL get_param -n osc.*OST0000-osc-[^mM]*.max_rpcs_in_flight`
8445 $LCTL set_param -n osc.*OST0000-osc-[^mM]*.max_rpcs_in_flight 1
8447 $SETSTRIPE $DIR/$tfile -i 0 -c 1 || error "setstripe failed"
8448 $DIRECTIO write $DIR/$tfile 0 1 $BSIZE || error "first directio failed"
8449 #define OBD_FAIL_OSC_DIO_PAUSE 0x40d
8450 lctl set_param fail_loc=0x40d
8451 $DIRECTIO write $DIR/$tfile 1 4 $BSIZE &
8454 cat $DIR/$tfile > /dev/null &
8455 lctl set_param fail_loc=0
8458 log "the DIO writes have completed, now wait for the reads (should not block very long)"
8460 [ -n "`ps h -p $pid_reads -o comm`" ] && \
8461 error "the read rpcs have not completed in 2s"
8463 $LCTL set_param -n osc.*OST0000-osc-[^mM]*.max_rpcs_in_flight $MAX_RPCS_IN_FLIGHT
8465 run_test 119d "The DIO path should try to send a new rpc once one is completed"
8468 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8469 remote_mds_nodsh && skip "remote MDS with nodsh" && return
8470 test_mkdir -p $DIR/$tdir
8471 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
8472 skip "no early lock cancel on server" && return 0
8474 lru_resize_disable mdc
8475 lru_resize_disable osc
8476 cancel_lru_locks mdc
8477 # asynchronous object destroy at MDT could cause bl ast to client
8478 cancel_lru_locks osc
8480 stat $DIR/$tdir > /dev/null
8481 can1=$(do_facet $SINGLEMDS \
8482 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8483 awk '/ldlm_cancel/ {print $2}')
8484 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8485 awk '/ldlm_bl_callback/ {print $2}')
8486 test_mkdir -c1 $DIR/$tdir/d1
8487 can2=$(do_facet $SINGLEMDS \
8488 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8489 awk '/ldlm_cancel/ {print $2}')
8490 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8491 awk '/ldlm_bl_callback/ {print $2}')
8492 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
8493 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
8494 lru_resize_enable mdc
8495 lru_resize_enable osc
8497 run_test 120a "Early Lock Cancel: mkdir test"
8500 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8501 remote_mds_nodsh && skip "remote MDS with nodsh" && return
8502 test_mkdir $DIR/$tdir
8503 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel)" ] && \
8504 skip "no early lock cancel on server" && return 0
8505 lru_resize_disable mdc
8506 lru_resize_disable osc
8507 cancel_lru_locks mdc
8508 stat $DIR/$tdir > /dev/null
8509 can1=$(do_facet $SINGLEMDS \
8510 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8511 awk '/ldlm_cancel/ {print $2}')
8512 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8513 awk '/ldlm_bl_callback/ {print $2}')
8515 can2=$(do_facet $SINGLEMDS \
8516 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8517 awk '/ldlm_cancel/ {print $2}')
8518 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8519 awk '/ldlm_bl_callback/ {print $2}')
8520 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
8521 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
8522 lru_resize_enable mdc
8523 lru_resize_enable osc
8525 run_test 120b "Early Lock Cancel: create test"
8528 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8529 remote_mds_nodsh && skip "remote MDS with nodsh" && return
8530 test_mkdir -c1 $DIR/$tdir
8531 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel)" ] && \
8532 skip "no early lock cancel on server" && return 0
8533 lru_resize_disable mdc
8534 lru_resize_disable osc
8535 test_mkdir -p -c1 $DIR/$tdir/d1
8536 test_mkdir -p -c1 $DIR/$tdir/d2
8537 touch $DIR/$tdir/d1/f1
8538 cancel_lru_locks mdc
8539 stat $DIR/$tdir/d1 $DIR/$tdir/d2 $DIR/$tdir/d1/f1 > /dev/null
8540 can1=$(do_facet $SINGLEMDS \
8541 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8542 awk '/ldlm_cancel/ {print $2}')
8543 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8544 awk '/ldlm_bl_callback/ {print $2}')
8545 ln $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2
8546 can2=$(do_facet $SINGLEMDS \
8547 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8548 awk '/ldlm_cancel/ {print $2}')
8549 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8550 awk '/ldlm_bl_callback/ {print $2}')
8551 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
8552 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
8553 lru_resize_enable mdc
8554 lru_resize_enable osc
8556 run_test 120c "Early Lock Cancel: link test"
8559 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8560 remote_mds_nodsh && skip "remote MDS with nodsh" && return
8561 test_mkdir -p -c1 $DIR/$tdir
8562 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel)" ] && \
8563 skip "no early lock cancel on server" && return 0
8564 lru_resize_disable mdc
8565 lru_resize_disable osc
8567 cancel_lru_locks mdc
8568 stat $DIR/$tdir > /dev/null
8569 can1=$(do_facet $SINGLEMDS \
8570 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8571 awk '/ldlm_cancel/ {print $2}')
8572 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8573 awk '/ldlm_bl_callback/ {print $2}')
8574 chmod a+x $DIR/$tdir
8575 can2=$(do_facet $SINGLEMDS \
8576 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8577 awk '/ldlm_cancel/ {print $2}')
8578 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8579 awk '/ldlm_bl_callback/ {print $2}')
8580 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
8581 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
8582 lru_resize_enable mdc
8583 lru_resize_enable osc
8585 run_test 120d "Early Lock Cancel: setattr test"
8588 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8589 ! $($LCTL get_param -n mdc.*.connect_flags | grep -q early_lock_can) &&
8590 skip "no early lock cancel on server" && return 0
8591 remote_mds_nodsh && skip "remote MDS with nodsh" && return
8592 local dlmtrace_set=false
8594 test_mkdir -p -c1 $DIR/$tdir
8595 lru_resize_disable mdc
8596 lru_resize_disable osc
8597 ! $LCTL get_param debug | grep -q dlmtrace &&
8598 $LCTL set_param debug=+dlmtrace && dlmtrace_set=true
8599 dd if=/dev/zero of=$DIR/$tdir/f1 count=1
8600 cancel_lru_locks mdc
8601 cancel_lru_locks osc
8602 dd if=$DIR/$tdir/f1 of=/dev/null
8603 stat $DIR/$tdir $DIR/$tdir/f1 > /dev/null
8604 # XXX client can not do early lock cancel of OST lock
8605 # during unlink (LU-4206), so cancel osc lock now.
8607 cancel_lru_locks osc
8608 can1=$(do_facet $SINGLEMDS \
8609 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8610 awk '/ldlm_cancel/ {print $2}')
8611 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8612 awk '/ldlm_bl_callback/ {print $2}')
8613 unlink $DIR/$tdir/f1
8615 can2=$(do_facet $SINGLEMDS \
8616 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8617 awk '/ldlm_cancel/ {print $2}')
8618 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8619 awk '/ldlm_bl_callback/ {print $2}')
8620 [ $can1 -ne $can2 ] && error "$((can2 - can1)) cancel RPC occured" &&
8621 $LCTL dk $TMP/cancel.debug.txt
8622 [ $blk1 -ne $blk2 ] && error "$((blk2 - blk1)) blocking RPC occured" &&
8623 $LCTL dk $TMP/blocking.debug.txt
8624 $dlmtrace_set && $LCTL set_param debug=-dlmtrace
8625 lru_resize_enable mdc
8626 lru_resize_enable osc
8628 run_test 120e "Early Lock Cancel: unlink test"
8631 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8632 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
8633 skip "no early lock cancel on server" && return 0
8634 remote_mds_nodsh && skip "remote MDS with nodsh" && return
8635 test_mkdir -p -c1 $DIR/$tdir
8636 lru_resize_disable mdc
8637 lru_resize_disable osc
8638 test_mkdir -p -c1 $DIR/$tdir/d1
8639 test_mkdir -p -c1 $DIR/$tdir/d2
8640 dd if=/dev/zero of=$DIR/$tdir/d1/f1 count=1
8641 dd if=/dev/zero of=$DIR/$tdir/d2/f2 count=1
8642 cancel_lru_locks mdc
8643 cancel_lru_locks osc
8644 dd if=$DIR/$tdir/d1/f1 of=/dev/null
8645 dd if=$DIR/$tdir/d2/f2 of=/dev/null
8646 stat $DIR/$tdir/d1 $DIR/$tdir/d2 $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2 > /dev/null
8647 # XXX client can not do early lock cancel of OST lock
8648 # during rename (LU-4206), so cancel osc lock now.
8650 cancel_lru_locks osc
8651 can1=$(do_facet $SINGLEMDS \
8652 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8653 awk '/ldlm_cancel/ {print $2}')
8654 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8655 awk '/ldlm_bl_callback/ {print $2}')
8656 mrename $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2
8658 can2=$(do_facet $SINGLEMDS \
8659 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8660 awk '/ldlm_cancel/ {print $2}')
8661 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8662 awk '/ldlm_bl_callback/ {print $2}')
8663 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
8664 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
8665 lru_resize_enable mdc
8666 lru_resize_enable osc
8668 run_test 120f "Early Lock Cancel: rename test"
8671 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8672 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
8673 skip "no early lock cancel on server" && return 0
8674 remote_mds_nodsh && skip "remote MDS with nodsh" && return
8675 lru_resize_disable mdc
8676 lru_resize_disable osc
8678 echo create $count files
8679 test_mkdir -p $DIR/$tdir
8680 cancel_lru_locks mdc
8681 cancel_lru_locks osc
8684 can0=$(do_facet $SINGLEMDS \
8685 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8686 awk '/ldlm_cancel/ {print $2}')
8687 blk0=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8688 awk '/ldlm_bl_callback/ {print $2}')
8689 createmany -o $DIR/$tdir/f $count
8691 can1=$(do_facet $SINGLEMDS \
8692 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8693 awk '/ldlm_cancel/ {print $2}')
8694 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8695 awk '/ldlm_bl_callback/ {print $2}')
8697 echo total: $((can1-can0)) cancels, $((blk1-blk0)) blockings
8698 echo rm $count files
8701 can2=$(do_facet $SINGLEMDS \
8702 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8703 awk '/ldlm_cancel/ {print $2}')
8704 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8705 awk '/ldlm_bl_callback/ {print $2}')
8707 echo total: $count removes in $((t2-t1))
8708 echo total: $((can2-can1)) cancels, $((blk2-blk1)) blockings
8710 # wait for commitment of removal
8711 lru_resize_enable mdc
8712 lru_resize_enable osc
8714 run_test 120g "Early Lock Cancel: performance test"
8716 test_121() { #bug #10589
8717 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8719 writes=$(LANG=C dd if=/dev/zero of=$DIR/$tfile count=1 2>&1 | awk -F '+' '/out$/ {print $1}')
8720 #define OBD_FAIL_LDLM_CANCEL_RACE 0x310
8721 lctl set_param fail_loc=0x310
8722 cancel_lru_locks osc > /dev/null
8723 reads=$(LANG=C dd if=$DIR/$tfile of=/dev/null 2>&1 | awk -F '+' '/in$/ {print $1}')
8724 lctl set_param fail_loc=0
8725 [[ $reads -eq $writes ]] ||
8726 error "read $reads blocks, must be $writes blocks"
8728 run_test 121 "read cancel race ========="
8730 test_123a() { # was test 123, statahead(bug 11401)
8731 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8733 if [ -z "$(grep "processor.*: 1" /proc/cpuinfo)" ]; then
8734 log "testing on UP system. Performance may be not as good as expected."
8739 test_mkdir -p $DIR/$tdir
8740 NUMFREE=$(df -i -P $DIR | tail -n 1 | awk '{ print $4 }')
8741 [[ $NUMFREE -gt 100000 ]] && NUMFREE=100000 || NUMFREE=$((NUMFREE-1000))
8743 for ((i=100, j=0; i<=$NUMFREE; j=$i, i=$((i * MULT)) )); do
8744 createmany -o $DIR/$tdir/$tfile $j $((i - j))
8746 max=`lctl get_param -n llite.*.statahead_max | head -n 1`
8747 lctl set_param -n llite.*.statahead_max 0
8748 lctl get_param llite.*.statahead_max
8749 cancel_lru_locks mdc
8750 cancel_lru_locks osc
8752 time ls -l $DIR/$tdir | wc -l
8754 delta=$((etime - stime))
8755 log "ls $i files without statahead: $delta sec"
8756 lctl set_param llite.*.statahead_max=$max
8758 swrong=`lctl get_param -n llite.*.statahead_stats | grep "statahead wrong:" | awk '{print $3}'`
8759 lctl get_param -n llite.*.statahead_max | grep '[0-9]'
8760 cancel_lru_locks mdc
8761 cancel_lru_locks osc
8763 time ls -l $DIR/$tdir | wc -l
8765 delta_sa=$((etime - stime))
8766 log "ls $i files with statahead: $delta_sa sec"
8767 lctl get_param -n llite.*.statahead_stats
8768 ewrong=`lctl get_param -n llite.*.statahead_stats | grep "statahead wrong:" | awk '{print $3}'`
8770 [[ $swrong -lt $ewrong ]] &&
8771 log "statahead was stopped, maybe too many locks held!"
8772 [[ $delta -eq 0 || $delta_sa -eq 0 ]] && continue
8774 if [ $((delta_sa * 100)) -gt $((delta * 105)) -a $delta_sa -gt $((delta + 2)) ]; then
8775 max=`lctl get_param -n llite.*.statahead_max | head -n 1`
8776 lctl set_param -n llite.*.statahead_max 0
8777 lctl get_param llite.*.statahead_max
8778 cancel_lru_locks mdc
8779 cancel_lru_locks osc
8781 time ls -l $DIR/$tdir | wc -l
8783 delta=$((etime - stime))
8784 log "ls $i files again without statahead: $delta sec"
8785 lctl set_param llite.*.statahead_max=$max
8786 if [ $((delta_sa * 100)) -gt $((delta * 105)) -a $delta_sa -gt $((delta + 2)) ]; then
8787 if [ $SLOWOK -eq 0 ]; then
8788 error "ls $i files is slower with statahead!"
8790 log "ls $i files is slower with statahead!"
8796 [ $delta -gt 20 ] && break
8797 [ $delta -gt 8 ] && MULT=$((50 / delta))
8798 [ "$SLOW" = "no" -a $delta -gt 5 ] && break
8806 delta=$((etime - stime))
8807 log "rm -r $DIR/$tdir/: $delta seconds"
8809 lctl get_param -n llite.*.statahead_stats
8811 run_test 123a "verify statahead work"
8813 test_123b () { # statahead(bug 15027)
8814 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8815 test_mkdir -p $DIR/$tdir
8816 createmany -o $DIR/$tdir/$tfile-%d 1000
8818 cancel_lru_locks mdc
8819 cancel_lru_locks osc
8821 #define OBD_FAIL_MDC_GETATTR_ENQUEUE 0x803
8822 lctl set_param fail_loc=0x80000803
8823 ls -lR $DIR/$tdir > /dev/null
8825 lctl set_param fail_loc=0x0
8826 lctl get_param -n llite.*.statahead_stats
8831 run_test 123b "not panic with network error in statahead enqueue (bug 15027)"
8834 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8835 [ -z "$($LCTL get_param -n mdc.*.connect_flags | grep lru_resize)" ] &&
8836 skip "no lru resize on server" && return 0
8838 test_mkdir -p $DIR/$tdir || error "failed to create $DIR/$tdir"
8840 log "create $NR files at $DIR/$tdir"
8841 createmany -o $DIR/$tdir/f $NR ||
8842 error "failed to create $NR files in $DIR/$tdir"
8844 cancel_lru_locks mdc
8845 ls -l $DIR/$tdir > /dev/null
8849 for VALUE in $($LCTL get_param ldlm.namespaces.*mdc-*.lru_size); do
8850 local PARAM=$(echo ${VALUE[0]} | cut -d "=" -f1)
8851 LRU_SIZE=$($LCTL get_param -n $PARAM)
8852 if [[ $LRU_SIZE -gt $(default_lru_size) ]]; then
8853 NSDIR=$(echo $PARAM | cut -d "." -f1-3)
8855 log "NS=$(basename $NSDIR)"
8860 if [[ -z "$NSDIR" || $LRU_SIZE -lt $(default_lru_size) ]]; then
8861 skip "Not enough cached locks created!"
8868 # We know that lru resize allows one client to hold $LIMIT locks
8869 # for 10h. After that locks begin to be killed by client.
8871 local LIMIT=$($LCTL get_param -n $NSDIR.pool.limit)
8873 if [ $LIMIT -lt $LRU_SIZE ]; then
8874 skip "Limit is too small $LIMIT"
8878 # Make LVF so higher that sleeping for $SLEEP is enough to _start_
8879 # killing locks. Some time was spent for creating locks. This means
8880 # that up to the moment of sleep finish we must have killed some of
8881 # them (10-100 locks). This depends on how fast ther were created.
8882 # Many of them were touched in almost the same moment and thus will
8883 # be killed in groups.
8884 local LVF=$(($MAX_HRS * 60 * 60 / $SLEEP * $LIMIT / $LRU_SIZE))
8886 # Use $LRU_SIZE_B here to take into account real number of locks
8887 # created in the case of CMD, LRU_SIZE_B != $NR in most of cases
8888 local LRU_SIZE_B=$LRU_SIZE
8890 local OLD_LVF=$($LCTL get_param -n $NSDIR.pool.lock_volume_factor)
8891 log "OLD_LVF=$OLD_LVF"
8892 $LCTL set_param -n $NSDIR.pool.lock_volume_factor $LVF
8894 # Let's make sure that we really have some margin. Client checks
8895 # cached locks every 10 sec.
8897 log "Sleep ${SLEEP} sec"
8899 while ((SEC<$SLEEP)); do
8903 LRU_SIZE=$($LCTL get_param -n $NSDIR/lru_size)
8907 $LCTL set_param -n $NSDIR.pool.lock_volume_factor $OLD_LVF
8908 local LRU_SIZE_A=$($LCTL get_param -n $NSDIR.lru_size)
8910 [[ $LRU_SIZE_B -gt $LRU_SIZE_A ]] || {
8911 error "No locks dropped in ${SLEEP}s. LRU size: $LRU_SIZE_A"
8912 unlinkmany $DIR/$tdir/f $NR
8916 log "Dropped "$((LRU_SIZE_B-LRU_SIZE_A))" locks in ${SLEEP}s"
8917 log "unlink $NR files at $DIR/$tdir"
8918 unlinkmany $DIR/$tdir/f $NR
8920 run_test 124a "lru resize ======================================="
8922 get_max_pool_limit()
8924 local limit=$($LCTL get_param \
8925 -n ldlm.namespaces.*-MDT0000-mdc-*.pool.limit)
8928 if [[ $l -gt $max ]]; then
8936 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8937 [ -z "$($LCTL get_param -n mdc.*.connect_flags | grep lru_resize)" ] &&
8938 skip "no lru resize on server" && return 0
8940 LIMIT=$(get_max_pool_limit)
8942 NR=$(($(default_lru_size)*20))
8943 if [[ $NR -gt $LIMIT ]]; then
8944 log "Limit lock number by $LIMIT locks"
8948 IFree=$(mdsrate_inodes_available)
8949 if [ $IFree -lt $NR ]; then
8950 log "Limit lock number by $IFree inodes"
8954 lru_resize_disable mdc
8955 test_mkdir -p $DIR/$tdir/disable_lru_resize ||
8956 error "failed to create $DIR/$tdir/disable_lru_resize"
8958 createmany -o $DIR/$tdir/disable_lru_resize/f $NR
8959 log "doing ls -la $DIR/$tdir/disable_lru_resize 3 times"
8960 cancel_lru_locks mdc
8963 ls -la $DIR/$tdir/disable_lru_resize > /dev/null &
8966 ls -la $DIR/$tdir/disable_lru_resize > /dev/null &
8969 ls -la $DIR/$tdir/disable_lru_resize > /dev/null &
8973 nolruresize_delta=$((etime-stime))
8974 log "ls -la time: $nolruresize_delta seconds"
8975 log "lru_size = $(lctl get_param -n ldlm.namespaces.*mdc*.lru_size)"
8976 unlinkmany $DIR/$tdir/disable_lru_resize/f $NR
8978 lru_resize_enable mdc
8979 test_mkdir -p $DIR/$tdir/enable_lru_resize ||
8980 error "failed to create $DIR/$tdir/enable_lru_resize"
8982 createmany -o $DIR/$tdir/enable_lru_resize/f $NR
8983 log "doing ls -la $DIR/$tdir/enable_lru_resize 3 times"
8984 cancel_lru_locks mdc
8987 ls -la $DIR/$tdir/enable_lru_resize > /dev/null &
8990 ls -la $DIR/$tdir/enable_lru_resize > /dev/null &
8993 ls -la $DIR/$tdir/enable_lru_resize > /dev/null &
8997 lruresize_delta=$((etime-stime))
8998 log "ls -la time: $lruresize_delta seconds"
8999 log "lru_size = $(lctl get_param -n ldlm.namespaces.*mdc*.lru_size)"
9001 if [ $lruresize_delta -gt $nolruresize_delta ]; then
9002 log "ls -la is $(((lruresize_delta - $nolruresize_delta) * 100 / $nolruresize_delta))% slower with lru resize enabled"
9003 elif [ $nolruresize_delta -gt $lruresize_delta ]; then
9004 log "ls -la is $(((nolruresize_delta - $lruresize_delta) * 100 / $nolruresize_delta))% faster with lru resize enabled"
9006 log "lru resize performs the same with no lru resize"
9008 unlinkmany $DIR/$tdir/enable_lru_resize/f $NR
9010 run_test 124b "lru resize (performance test) ======================="
9013 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9014 [ -z "$($LCTL get_param -n mdc.*.connect_flags | grep lru_resize)" ] &&
9015 skip "no lru resize on server" && return 0
9017 # cache ununsed locks on client
9019 cancel_lru_locks mdc
9020 test_mkdir -p $DIR/$tdir || error "failed to create $DIR/$tdir"
9021 createmany -o $DIR/$tdir/f $nr ||
9022 error "failed to create $nr files in $DIR/$tdir"
9023 ls -l $DIR/$tdir > /dev/null
9025 local nsdir="ldlm.namespaces.*-MDT0000-mdc-*"
9026 local unused=$($LCTL get_param -n $nsdir.lock_unused_count)
9027 local max_age=$($LCTL get_param -n $nsdir.lru_max_age)
9028 local recalc_p=$($LCTL get_param -n $nsdir.pool.recalc_period)
9029 echo "unused=$unused, max_age=$max_age, recalc_p=$recalc_p"
9031 # set lru_max_age to 1 sec
9032 $LCTL set_param $nsdir.lru_max_age=1000 # milliseconds
9033 echo "sleep $((recalc_p * 2)) seconds..."
9034 sleep $((recalc_p * 2))
9036 local remaining=$($LCTL get_param -n $nsdir.lock_unused_count)
9037 # restore lru_max_age
9038 $LCTL set_param -n $nsdir.lru_max_age $max_age
9039 [ $remaining -eq 0 ] || error "$remaining locks are not canceled"
9040 unlinkmany $DIR/$tdir/f $nr
9042 run_test 124c "LRUR cancel very aged locks"
9044 test_125() { # 13358
9045 [ -z "$(lctl get_param -n llite.*.client_type | grep local)" ] && skip "must run as local client" && return
9046 [ -z "$(lctl get_param -n mdc.*-mdc-*.connect_flags | grep acl)" ] && skip "must have acl enabled" && return
9047 [ -z "$(which setfacl)" ] && skip "must have setfacl tool" && return
9048 test_mkdir -p $DIR/d125 || error "mkdir failed"
9049 $SETSTRIPE -S 65536 -c -1 $DIR/d125 || error "setstripe failed"
9050 setfacl -R -m u:bin:rwx $DIR/d125 || error "setfacl $DIR/d125 failed"
9051 ls -ld $DIR/d125 || error "cannot access $DIR/d125"
9053 run_test 125 "don't return EPROTO when a dir has a non-default striping and ACLs"
9055 test_126() { # bug 12829/13455
9056 [ -z "$(lctl get_param -n llite.*.client_type | grep local)" ] && skip "must run as local client" && return
9057 [ "$UID" != 0 ] && skip_env "skipping $TESTNAME (must run as root)" && return
9058 $GSS && skip "must run as gss disabled" && return
9060 $RUNAS -u 0 -g 1 touch $DIR/$tfile || error "touch failed"
9061 gid=`ls -n $DIR/$tfile | awk '{print $4}'`
9063 [ $gid -eq "1" ] || error "gid is set to" $gid "instead of 1"
9065 run_test 126 "check that the fsgid provided by the client is taken into account"
9067 test_127a() { # bug 15521
9068 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9069 $SETSTRIPE -i 0 -c 1 $DIR/$tfile || error "setstripe failed"
9070 $LCTL set_param osc.*.stats=0
9071 FSIZE=$((2048 * 1024))
9072 dd if=/dev/zero of=$DIR/$tfile bs=$FSIZE count=1
9073 cancel_lru_locks osc
9074 dd if=$DIR/$tfile of=/dev/null bs=$FSIZE
9076 $LCTL get_param osc.*0000-osc-*.stats | grep samples > $DIR/${tfile}.tmp
9077 while read NAME COUNT SAMP UNIT MIN MAX SUM SUMSQ; do
9078 echo "got $COUNT $NAME"
9079 [ ! $MIN ] && error "Missing min value for $NAME proc entry"
9080 eval $NAME=$COUNT || error "Wrong proc format"
9083 read_bytes|write_bytes)
9084 [ $MIN -lt 4096 ] && error "min is too small: $MIN"
9085 [ $MIN -gt $FSIZE ] && error "min is too big: $MIN"
9086 [ $MAX -lt 4096 ] && error "max is too small: $MAX"
9087 [ $MAX -gt $FSIZE ] && error "max is too big: $MAX"
9088 [ $SUM -ne $FSIZE ] && error "sum is wrong: $SUM"
9089 [ $SUMSQ -lt $(((FSIZE /4096) * (4096 * 4096))) ] &&
9090 error "sumsquare is too small: $SUMSQ"
9091 [ $SUMSQ -gt $((FSIZE * FSIZE)) ] &&
9092 error "sumsquare is too big: $SUMSQ"
9096 done < $DIR/${tfile}.tmp
9098 #check that we actually got some stats
9099 [ "$read_bytes" ] || error "Missing read_bytes stats"
9100 [ "$write_bytes" ] || error "Missing write_bytes stats"
9101 [ "$read_bytes" != 0 ] || error "no read done"
9102 [ "$write_bytes" != 0 ] || error "no write done"
9104 run_test 127a "verify the client stats are sane"
9106 test_127b() { # bug LU-333
9107 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9108 $LCTL set_param llite.*.stats=0
9109 FSIZE=65536 # sized fixed to match PAGE_SIZE for most clients
9110 # perform 2 reads and writes so MAX is different from SUM.
9111 dd if=/dev/zero of=$DIR/$tfile bs=$FSIZE count=1
9112 dd if=/dev/zero of=$DIR/$tfile bs=$FSIZE count=1
9113 cancel_lru_locks osc
9114 dd if=$DIR/$tfile of=/dev/null bs=$FSIZE count=1
9115 dd if=$DIR/$tfile of=/dev/null bs=$FSIZE count=1
9117 $LCTL get_param llite.*.stats | grep samples > $TMP/${tfile}.tmp
9118 while read NAME COUNT SAMP UNIT MIN MAX SUM SUMSQ; do
9119 echo "got $COUNT $NAME"
9120 eval $NAME=$COUNT || error "Wrong proc format"
9124 [ $COUNT -ne 2 ] && error "count is not 2: $COUNT"
9125 [ $MIN -ne $FSIZE ] && error "min is not $FSIZE: $MIN"
9126 [ $MAX -ne $FSIZE ] && error "max is incorrect: $MAX"
9127 [ $SUM -ne $((FSIZE * 2)) ] && error "sum is wrong: $SUM"
9130 [ $COUNT -ne 2 ] && error "count is not 2: $COUNT"
9131 [ $MIN -ne $FSIZE ] && error "min is not $FSIZE: $MIN"
9132 [ $MAX -ne $FSIZE ] && error "max is incorrect: $MAX"
9133 [ $SUM -ne $((FSIZE * 2)) ] && error "sum is wrong: $SUM"
9137 done < $TMP/${tfile}.tmp
9139 #check that we actually got some stats
9140 [ "$read_bytes" ] || error "Missing read_bytes stats"
9141 [ "$write_bytes" ] || error "Missing write_bytes stats"
9142 [ "$read_bytes" != 0 ] || error "no read done"
9143 [ "$write_bytes" != 0 ] || error "no write done"
9145 rm -f $TMP/${tfile}.tmp
9147 run_test 127b "verify the llite client stats are sane"
9149 test_128() { # bug 15212
9151 $LFS 2>&1 <<-EOF | tee $TMP/$tfile.log
9156 result=$(grep error $TMP/$tfile.log)
9157 rm -f $DIR/$tfile $TMP/$tfile.log
9159 error "consecutive find's under interactive lfs failed"
9161 run_test 128 "interactive lfs for 2 consecutive find's"
9168 local ldproc=/proc/fs/ldiskfs
9169 local facets=$(get_facets MDS)
9171 for facet in ${facets//,/ }; do
9172 canondev=$(ldiskfs_canon \
9173 *.$(convert_facet2label $facet).mntdev $facet)
9174 do_facet $facet "test -e $ldproc/$canondev/max_dir_size" ||
9175 ldproc=/sys/fs/ldiskfs
9176 do_facet $facet "echo $1 >$ldproc/$canondev/max_dir_size"
9177 do_facet $facet "echo $2 >$ldproc/$canondev/warning_dir_size"
9182 local facets=$(get_facets MDS)
9183 for facet in ${facets//,/ }; do
9184 do_facet $facet "dmesg | tail -3 | grep -q $1" && return 0
9190 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.5.56) ]] ||
9191 { skip "Need MDS version with at least 2.5.56"; return 0; }
9193 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9194 if [ "$(facet_fstype $SINGLEMDS)" != ldiskfs ]; then
9195 skip "ldiskfs only test"
9198 remote_mds_nodsh && skip "remote MDS with nodsh" && return
9201 local has_warning=false
9206 # block size of mds1
9207 local maxsize=$(($($LCTL get_param -n mdc.*MDT0000*.blocksize) * 5))
9208 set_dir_limits $maxsize $maxsize
9209 local dirsize=$(stat -c%s "$DIR/$tdir")
9211 while [[ $dirsize -le $maxsize ]]; do
9212 $MULTIOP $DIR/$tdir/file_base_$nfiles Oc
9214 if ! $has_warning; then
9215 check_mds_dmesg '"is approaching"' && has_warning=true
9218 # ENOSPC for new ext4 max_dir_size (kernel commit df981d03ee)
9219 # EFBIG for previous versions included in ldiskfs series
9220 if [ $rc -eq $EFBIG -o $rc -eq $ENOSPC ]; then
9222 echo "return code $rc received as expected"
9224 createmany -o $DIR/$tdir/file_extra_$nfiles. 5 ||
9225 error_exit "create failed w/o dir size limit"
9227 check_mds_dmesg '"has reached"' ||
9228 error_exit "reached message should be output"
9230 [ $has_warning = "false" ] &&
9231 error_exit "warning message should be output"
9233 dirsize=$(stat -c%s "$DIR/$tdir")
9235 [[ $dirsize -ge $maxsize ]] && return 0
9236 error_exit "current dir size $dirsize, " \
9237 "previous limit $maxsize"
9238 elif [ $rc -ne 0 ]; then
9240 error_exit "return $rc received instead of expected " \
9241 "$EFBIG or $ENOSPC, files in dir $dirsize"
9243 nfiles=$((nfiles + 1))
9244 dirsize=$(stat -c%s "$DIR/$tdir")
9248 error "exceeded dir size limit $maxsize($MDSCOUNT) : $dirsize bytes"
9250 run_test 129 "test directory size limit ========================"
9259 local filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
9260 [ -n "$filefrag_op" ] && skip_env "filefrag does not support FIEMAP" &&
9263 trap cleanup_130 EXIT RETURN
9265 local fm_file=$DIR/$tfile
9266 $SETSTRIPE -S 65536 -c 1 $fm_file || error "setstripe on $fm_file"
9267 dd if=/dev/zero of=$fm_file bs=65536 count=1 ||
9268 error "dd failed for $fm_file"
9270 # LU-1795: test filefrag/FIEMAP once, even if unsupported
9271 filefrag -ves $fm_file
9273 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
9274 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
9275 [ $RC != 0 ] && error "filefrag $fm_file failed"
9277 filefrag_op=$(filefrag -ve $fm_file |
9278 sed -n '/ext:/,/found/{/ext:/d; /found/d; p}')
9279 lun=$($GETSTRIPE -i $fm_file)
9281 start_blk=`echo $filefrag_op | cut -d: -f2 | cut -d. -f1`
9284 for line in $filefrag_op
9286 frag_lun=`echo $line | cut -d: -f5`
9287 ext_len=`echo $line | cut -d: -f4`
9288 if (( $frag_lun != $lun )); then
9290 error "FIEMAP on 1-stripe file($fm_file) failed"
9293 (( tot_len += ext_len ))
9296 if (( lun != frag_lun || start_blk != 0 || tot_len != 64 )); then
9298 error "FIEMAP on 1-stripe file($fm_file) failed;"
9304 echo "FIEMAP on single striped file succeeded"
9306 run_test 130a "FIEMAP (1-stripe file)"
9309 [ "$OSTCOUNT" -lt "2" ] && skip_env "needs >= 2 OSTs" && return
9311 local filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
9312 [ -n "$filefrag_op" ] && skip_env "filefrag does not support FIEMAP" &&
9315 trap cleanup_130 EXIT RETURN
9317 local fm_file=$DIR/$tfile
9318 $SETSTRIPE -S 65536 -c $OSTCOUNT $fm_file ||
9319 error "setstripe on $fm_file"
9320 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
9321 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
9323 dd if=/dev/zero of=$fm_file bs=1M count=$OSTCOUNT ||
9324 error "dd failed on $fm_file"
9326 filefrag -ves $fm_file || error "filefrag $fm_file failed"
9327 filefrag_op=$(filefrag -ve $fm_file |
9328 sed -n '/ext:/,/found/{/ext:/d; /found/d; p}')
9330 last_lun=$(echo $filefrag_op | cut -d: -f5 |
9331 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
9336 for line in $filefrag_op
9338 frag_lun=$(echo $line | cut -d: -f5 |
9339 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
9340 ext_len=$(echo $line | cut -d: -f4)
9341 if (( $frag_lun != $last_lun )); then
9342 if (( tot_len != 1024 )); then
9344 error "FIEMAP on $fm_file failed; returned " \
9345 "len $tot_len for OST $last_lun instead of 1024"
9352 (( tot_len += ext_len ))
9355 if (( num_luns != $OSTCOUNT || tot_len != 1024 )); then
9357 error "FIEMAP on $fm_file failed; returned wrong number of " \
9358 "luns or wrong len for OST $last_lun"
9364 echo "FIEMAP on $OSTCOUNT-stripe file succeeded"
9366 run_test 130b "FIEMAP ($OSTCOUNT-stripe file)"
9369 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
9371 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
9372 [ -n "$filefrag_op" ] && skip "filefrag does not support FIEMAP" &&
9375 trap cleanup_130 EXIT RETURN
9377 local fm_file=$DIR/$tfile
9378 $SETSTRIPE -S 65536 -c 2 $fm_file || error "setstripe on $fm_file"
9379 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
9380 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
9382 dd if=/dev/zero of=$fm_file seek=1 bs=1M count=1 ||
9383 error "dd failed on $fm_file"
9385 filefrag -ves $fm_file || error "filefrag $fm_file failed"
9386 filefrag_op=$(filefrag -ve $fm_file |
9387 sed -n '/ext:/,/found/{/ext:/d; /found/d; p}')
9389 last_lun=$(echo $filefrag_op | cut -d: -f5 |
9390 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
9395 for line in $filefrag_op
9397 frag_lun=$(echo $line | cut -d: -f5 |
9398 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
9399 ext_len=$(echo $line | cut -d: -f4)
9400 if (( $frag_lun != $last_lun )); then
9401 logical=`echo $line | cut -d: -f2 | cut -d. -f1`
9402 if (( logical != 512 )); then
9404 error "FIEMAP on $fm_file failed; returned " \
9405 "logical start for lun $logical instead of 512"
9408 if (( tot_len != 512 )); then
9410 error "FIEMAP on $fm_file failed; returned " \
9411 "len $tot_len for OST $last_lun instead of 1024"
9418 (( tot_len += ext_len ))
9421 if (( num_luns != 2 || tot_len != 512 )); then
9423 error "FIEMAP on $fm_file failed; returned wrong number of " \
9424 "luns or wrong len for OST $last_lun"
9430 echo "FIEMAP on 2-stripe file with hole succeeded"
9432 run_test 130c "FIEMAP (2-stripe file with hole)"
9435 [[ $OSTCOUNT -lt 3 ]] && skip_env "needs >= 3 OSTs" && return
9437 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
9438 [ -n "$filefrag_op" ] && skip "filefrag does not support FIEMAP" &&
9441 trap cleanup_130 EXIT RETURN
9443 local fm_file=$DIR/$tfile
9444 $SETSTRIPE -S 65536 -c $OSTCOUNT $fm_file ||
9445 error "setstripe on $fm_file"
9446 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
9447 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
9449 local actual_stripecnt=$($GETSTRIPE -c $fm_file)
9450 dd if=/dev/zero of=$fm_file bs=1M count=$actual_stripecnt ||
9451 error "dd failed on $fm_file"
9453 filefrag -ves $fm_file || error "filefrag $fm_file failed"
9454 filefrag_op=$(filefrag -ve $fm_file |
9455 sed -n '/ext:/,/found/{/ext:/d; /found/d; p}')
9457 last_lun=$(echo $filefrag_op | cut -d: -f5 |
9458 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
9463 for line in $filefrag_op
9465 frag_lun=$(echo $line | cut -d: -f5 |
9466 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
9467 ext_len=$(echo $line | cut -d: -f4)
9468 if (( $frag_lun != $last_lun )); then
9469 if (( tot_len != 1024 )); then
9471 error "FIEMAP on $fm_file failed; returned " \
9472 "len $tot_len for OST $last_lun instead of 1024"
9479 (( tot_len += ext_len ))
9482 if (( num_luns != actual_stripecnt || tot_len != 1024 )); then
9484 error "FIEMAP on $fm_file failed; returned wrong number of " \
9485 "luns or wrong len for OST $last_lun"
9491 echo "FIEMAP on N-stripe file succeeded"
9493 run_test 130d "FIEMAP (N-stripe file)"
9496 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
9498 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
9499 [ -n "$filefrag_op" ] && skip "filefrag does not support FIEMAP" && return
9501 trap cleanup_130 EXIT RETURN
9503 local fm_file=$DIR/$tfile
9504 $SETSTRIPE -S 131072 -c 2 $fm_file || error "setstripe on $fm_file"
9505 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
9506 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
9509 EXPECTED_LEN=$(( (NUM_BLKS / 2) * 64 ))
9510 for ((i = 0; i < $NUM_BLKS; i++))
9512 dd if=/dev/zero of=$fm_file count=1 bs=64k seek=$((2*$i)) conv=notrunc > /dev/null 2>&1
9515 filefrag -ves $fm_file || error "filefrag $fm_file failed"
9516 filefrag_op=$(filefrag -ve $fm_file |
9517 sed -n '/ext:/,/found/{/ext:/d; /found/d; p}')
9519 last_lun=$(echo $filefrag_op | cut -d: -f5 |
9520 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
9525 for line in $filefrag_op
9527 frag_lun=$(echo $line | cut -d: -f5 |
9528 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
9529 ext_len=$(echo $line | cut -d: -f4)
9530 if (( $frag_lun != $last_lun )); then
9531 if (( tot_len != $EXPECTED_LEN )); then
9533 error "FIEMAP on $fm_file failed; returned " \
9534 "len $tot_len for OST $last_lun instead " \
9542 (( tot_len += ext_len ))
9545 if (( num_luns != 2 || tot_len != $EXPECTED_LEN )); then
9547 error "FIEMAP on $fm_file failed; returned wrong number " \
9548 "of luns or wrong len for OST $last_lun"
9554 echo "FIEMAP with continuation calls succeeded"
9556 run_test 130e "FIEMAP (test continuation FIEMAP calls)"
9558 # Test for writev/readv
9560 rwv -f $DIR/$tfile -w -n 3 524288 1048576 1572864 ||
9561 error "writev test failed"
9562 rwv -f $DIR/$tfile -r -v -n 2 1572864 1048576 ||
9563 error "readv failed"
9566 run_test 131a "test iov's crossing stripe boundary for writev/readv"
9569 local fsize=$((524288 + 1048576 + 1572864))
9570 rwv -f $DIR/$tfile -w -a -n 3 524288 1048576 1572864 &&
9571 $CHECKSTAT -t file $DIR/$tfile -s $fsize ||
9572 error "append writev test failed"
9574 ((fsize += 1572864 + 1048576))
9575 rwv -f $DIR/$tfile -w -a -n 2 1572864 1048576 &&
9576 $CHECKSTAT -t file $DIR/$tfile -s $fsize ||
9577 error "append writev test failed"
9580 run_test 131b "test append writev"
9583 rwv -f $DIR/$tfile -w -d -n 1 1048576 || return 0
9586 run_test 131c "test read/write on file w/o objects"
9589 rwv -f $DIR/$tfile -w -n 1 1572864
9590 NOB=`rwv -f $DIR/$tfile -r -n 3 524288 524288 1048576 | awk '/error/ {print $6}'`
9591 if [ "$NOB" != 1572864 ]; then
9592 error "Short read filed: read $NOB bytes instead of 1572864"
9596 run_test 131d "test short read"
9599 rwv -f $DIR/$tfile -w -s 1048576 -n 1 1048576
9600 rwv -f $DIR/$tfile -r -z -s 0 -n 1 524288 || \
9601 error "read hitting hole failed"
9604 run_test 131e "test read hitting hole"
9613 mds*) res=$(do_facet $facet \
9614 $LCTL get_param mdt.$FSNAME-MDT0000.md_stats | grep "$op")
9616 ost*) res=$(do_facet $facet \
9617 $LCTL get_param obdfilter.$FSNAME-OST0000.stats | grep "$op")
9619 *) error "Wrong facet '$facet'" ;;
9622 [ "$res" ] || error "The counter for $op on $facet was not incremented"
9623 # if the argument $3 is zero, it means any stat increment is ok.
9624 if [[ $want -gt 0 ]]; then
9625 local count=$(echo $res | awk '{ print $2 }')
9626 [[ $count -ne $want ]] &&
9627 error "The $op counter on $facet is $count, not $want"
9632 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9633 remote_ost_nodsh && skip "remote OST with nodsh" && return
9634 remote_mds_nodsh && skip "remote MDS with nodsh" && return
9636 do_facet $SINGLEMDS $LCTL list_param mdt.*.rename_stats ||
9637 { skip "MDS doesn't support rename stats"; return; }
9638 local testdir=$DIR/${tdir}/stats_testdir
9639 mkdir -p $DIR/${tdir}
9642 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
9643 do_facet ost1 $LCTL set_param obdfilter.*.stats=clear
9645 # verify mdt stats first.
9646 mkdir ${testdir} || error "mkdir failed"
9647 check_stats $SINGLEMDS "mkdir" 1
9648 touch ${testdir}/${tfile} || error "touch failed"
9649 check_stats $SINGLEMDS "open" 1
9650 check_stats $SINGLEMDS "close" 1
9651 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.8.54) ] && {
9652 mknod ${testdir}/${tfile}-pipe p || error "mknod failed"
9653 check_stats $SINGLEMDS "mknod" 2
9655 rm -f ${testdir}/${tfile}-pipe || error "pipe remove failed"
9656 check_stats $SINGLEMDS "unlink" 1
9657 rm -f ${testdir}/${tfile} || error "file remove failed"
9658 check_stats $SINGLEMDS "unlink" 2
9660 # remove working dir and check mdt stats again.
9661 rmdir ${testdir} || error "rmdir failed"
9662 check_stats $SINGLEMDS "rmdir" 1
9664 local testdir1=$DIR/${tdir}/stats_testdir1
9666 mkdir -p ${testdir1}
9667 touch ${testdir1}/test1
9668 mv ${testdir1}/test1 ${testdir} || error "file crossdir rename"
9669 check_stats $SINGLEMDS "crossdir_rename" 1
9671 mv ${testdir}/test1 ${testdir}/test0 || error "file samedir rename"
9672 check_stats $SINGLEMDS "samedir_rename" 1
9676 run_test 133a "Verifying MDT stats ========================================"
9679 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9680 remote_ost_nodsh && skip "remote OST with nodsh" && return
9681 remote_mds_nodsh && skip "remote MDS with nodsh" && return
9682 local testdir=$DIR/${tdir}/stats_testdir
9683 mkdir -p ${testdir} || error "mkdir failed"
9684 touch ${testdir}/${tfile} || error "touch failed"
9685 cancel_lru_locks mdc
9688 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
9689 do_facet ost1 $LCTL set_param obdfilter.*.stats=clear
9691 # extra mdt stats verification.
9692 chmod 444 ${testdir}/${tfile} || error "chmod failed"
9693 check_stats $SINGLEMDS "setattr" 1
9694 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
9695 if [ $(lustre_version_code $SINGLEMDS) -ne $(version_code 2.2.0) ]
9697 ls -l ${testdir}/${tfile} > /dev/null|| error "ls failed"
9698 check_stats $SINGLEMDS "getattr" 1
9700 $LFS df || error "lfs failed"
9701 check_stats $SINGLEMDS "statfs" 1
9705 run_test 133b "Verifying extra MDT stats =================================="
9708 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9709 remote_ost_nodsh && skip "remote OST with nodsh" && return
9710 remote_mds_nodsh && skip "remote MDS with nodsh" && return
9711 local testdir=$DIR/${tdir}/stats_testdir
9712 test_mkdir -p ${testdir} || error "mkdir failed"
9714 # verify obdfilter stats.
9715 $SETSTRIPE -c 1 -i 0 ${testdir}/${tfile}
9717 cancel_lru_locks osc
9718 wait_delete_completed
9721 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
9722 do_facet ost1 $LCTL set_param obdfilter.*.stats=clear
9724 dd if=/dev/zero of=${testdir}/${tfile} conv=notrunc bs=512k count=1 || error "dd failed"
9726 cancel_lru_locks osc
9727 check_stats ost1 "write" 1
9729 dd if=${testdir}/${tfile} of=/dev/null bs=1k count=1 || error "dd failed"
9730 check_stats ost1 "read" 1
9732 > ${testdir}/${tfile} || error "truncate failed"
9733 check_stats ost1 "punch" 1
9735 rm -f ${testdir}/${tfile} || error "file remove failed"
9736 wait_delete_completed
9737 check_stats ost1 "destroy" 1
9741 run_test 133c "Verifying OST stats ========================================"
9748 while [ $value -ge 2 ]; do
9753 if [ $orig -gt $order ]; then
9761 local size=('K' 'M' 'G' 'T');
9763 local size_string=$value
9765 while [ $value -ge 1024 ]; do
9766 if [ $i -gt 3 ]; then
9767 #T is the biggest unit we get here, if that is bigger,
9769 size_string=${value}T
9772 value=$((value >> 10))
9773 if [ $value -lt 1024 ]; then
9774 size_string=${value}${size[$i]}
9785 local context=${2:-.}
9786 local sample=$(do_facet $SINGLEMDS $LCTL get_param mdt.*.rename_stats |
9788 awk '/ '${size}'/ {print $4}' | sed -e "s/,//g")
9793 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9794 remote_ost_nodsh && skip "remote OST with nodsh" && return
9795 remote_mds_nodsh && skip "remote MDS with nodsh" && return
9796 do_facet $SINGLEMDS $LCTL list_param mdt.*.rename_stats ||
9797 { skip "MDS doesn't support rename stats"; return; }
9799 local testdir1=$DIR/${tdir}/stats_testdir1
9800 local testdir2=$DIR/${tdir}/stats_testdir2
9802 do_facet $SINGLEMDS $LCTL set_param mdt.*.rename_stats=clear
9804 mkdir -p ${testdir1} || error "mkdir failed"
9805 mkdir -p ${testdir2} || error "mkdir failed"
9807 createmany -o $testdir1/test 512 || error "createmany failed"
9809 # check samedir rename size
9810 mv ${testdir1}/test0 ${testdir1}/test_0
9812 local testdir1_size=$(ls -l $DIR/${tdir} |
9813 awk '/stats_testdir1/ {print $5}')
9814 local testdir2_size=$(ls -l $DIR/${tdir} |
9815 awk '/stats_testdir2/ {print $5}')
9817 testdir1_size=$(order_2 $testdir1_size)
9818 testdir2_size=$(order_2 $testdir2_size)
9820 testdir1_size=$(size_in_KMGT $testdir1_size)
9821 testdir2_size=$(size_in_KMGT $testdir2_size)
9823 echo "source rename dir size: ${testdir1_size}"
9824 echo "target rename dir size: ${testdir2_size}"
9826 local cmd="do_facet $SINGLEMDS $LCTL get_param mdt.*.rename_stats"
9827 eval $cmd || error "$cmd failed"
9828 local samedir=$($cmd | grep 'same_dir')
9829 local same_sample=$(get_rename_size $testdir1_size)
9830 [ -z "$samedir" ] && error "samedir_rename_size count error"
9831 [[ $same_sample -eq 1 ]] ||
9832 error "samedir_rename_size error $same_sample"
9833 echo "Check same dir rename stats success"
9835 do_facet $SINGLEMDS $LCTL set_param mdt.*.rename_stats=clear
9837 # check crossdir rename size
9838 mv ${testdir1}/test_0 ${testdir2}/test_0
9840 testdir1_size=$(ls -l $DIR/${tdir} |
9841 awk '/stats_testdir1/ {print $5}')
9842 testdir2_size=$(ls -l $DIR/${tdir} |
9843 awk '/stats_testdir2/ {print $5}')
9845 testdir1_size=$(order_2 $testdir1_size)
9846 testdir2_size=$(order_2 $testdir2_size)
9848 testdir1_size=$(size_in_KMGT $testdir1_size)
9849 testdir2_size=$(size_in_KMGT $testdir2_size)
9851 echo "source rename dir size: ${testdir1_size}"
9852 echo "target rename dir size: ${testdir2_size}"
9854 eval $cmd || error "$cmd failed"
9855 local crossdir=$($cmd | grep 'crossdir')
9856 local src_sample=$(get_rename_size $testdir1_size crossdir_src)
9857 local tgt_sample=$(get_rename_size $testdir2_size crossdir_tgt)
9858 [ -z "$crossdir" ] && error "crossdir_rename_size count error"
9859 [[ $src_sample -eq 1 ]] ||
9860 error "crossdir_rename_size error $src_sample"
9861 [[ $tgt_sample -eq 1 ]] ||
9862 error "crossdir_rename_size error $tgt_sample"
9863 echo "Check cross dir rename stats success"
9866 run_test 133d "Verifying rename_stats ========================================"
9869 remote_mds_nodsh && skip "remote MDS with nodsh" && return
9870 remote_ost_nodsh && skip "remote OST with nodsh" && return
9871 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9872 local testdir=$DIR/${tdir}/stats_testdir
9873 local ctr f0 f1 bs=32768 count=42 sum
9875 mkdir -p ${testdir} || error "mkdir failed"
9877 $SETSTRIPE -c 1 -i 0 ${testdir}/${tfile}
9879 for ctr in {write,read}_bytes; do
9881 cancel_lru_locks osc
9883 do_facet ost1 $LCTL set_param -n \
9884 "obdfilter.*.exports.clear=clear"
9886 if [ $ctr = write_bytes ]; then
9888 f1=${testdir}/${tfile}
9890 f0=${testdir}/${tfile}
9894 dd if=$f0 of=$f1 conv=notrunc bs=$bs count=$count || \
9897 cancel_lru_locks osc
9899 sum=$(do_facet ost1 $LCTL get_param \
9900 "obdfilter.*.exports.*.stats" |
9901 awk -v ctr=$ctr 'BEGIN { sum = 0 }
9902 $1 == ctr { sum += $7 }
9903 END { printf("%0.0f", sum) }')
9905 if ((sum != bs * count)); then
9906 error "Bad $ctr sum, expected $((bs * count)), got $sum"
9912 run_test 133e "Verifying OST {read,write}_bytes nid stats ================="
9914 proc_regexp="/{proc,sys}/{fs,sys,kernel/debug}/{lustre,lnet}/"
9917 remote_mds_nodsh && skip "remote MDS with nodsh" && return
9918 remote_ost_nodsh && skip "remote OST with nodsh" && return
9919 # First without trusting modes.
9920 local proc_dirs=$(eval \ls -d $proc_regexp 2>/dev/null)
9921 echo "proc_dirs='$proc_dirs'"
9922 [ -n "$proc_dirs" ] || error "no proc_dirs on $HOSTNAME"
9923 find $proc_dirs -exec cat '{}' \; &> /dev/null
9925 # Second verifying readability.
9926 $LCTL get_param -R '*' &> /dev/null || error "proc file read failed"
9928 # eventually, this can also be replaced with "lctl get_param -R",
9929 # but not until that option is always available on the server
9931 for facet in mds1 ost1; do
9932 local facet_proc_dirs=$(do_facet $facet \
9933 \\\ls -d $proc_regexp 2>/dev/null)
9934 echo "${facet}_proc_dirs='$facet_proc_dirs'"
9935 [ -z "$facet_proc_dirs" ] && error "no proc_dirs on $facet"
9936 do_facet $facet find $facet_proc_dirs \
9937 ! -name req_history \
9938 -exec cat '{}' \\\; &> /dev/null
9940 do_facet $facet find $facet_proc_dirs \
9941 ! -name req_history \
9943 -exec cat '{}' \\\; &> /dev/null ||
9944 error "proc file read failed"
9947 run_test 133f "Check for LBUGs/Oopses/unreadable files in /proc"
9950 remote_mds_nodsh && skip "remote MDS with nodsh" && return
9951 remote_ost_nodsh && skip "remote OST with nodsh" && return
9952 # Second verifying writability.
9953 local proc_dirs=$(eval \ls -d $proc_regexp 2>/dev/null)
9954 echo "proc_dirs='$proc_dirs'"
9955 [ -n "$proc_dirs" ] || error "no proc_dirs on $HOSTNAME"
9958 -not -name force_lbug \
9959 -not -name changelog_mask \
9960 -exec badarea_io '{}' \; &> /dev/null ||
9961 error "find $proc_dirs failed"
9964 for facet in mds1 ost1; do
9965 [ $(lustre_version_code $facet) -le $(version_code 2.5.54) ] &&
9966 skip "Too old lustre on $facet" && continue
9967 local facet_proc_dirs=$(do_facet $facet \
9968 \\\ls -d $proc_regexp 2> /dev/null)
9969 echo "${facet}_proc_dirs='$facet_proc_dirs'"
9970 [ -z "$facet_proc_dirs" ] && error "no proc_dirs on $facet"
9971 do_facet $facet find $facet_proc_dirs \
9973 -not -name force_lbug \
9974 -not -name changelog_mask \
9975 -exec badarea_io '{}' \\\; &> /dev/null ||
9976 error "$facet find $facet_proc_dirs failed"
9979 # remount the FS in case writes/reads /proc break the FS
9980 cleanup || error "failed to unmount"
9981 setup || error "failed to setup"
9984 run_test 133g "Check for Oopses on bad io area writes/reads in /proc"
9987 remote_mds_nodsh && skip "remote MDS with nodsh" && return
9988 remote_ost_nodsh && skip "remote OST with nodsh" && return
9989 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.9.54) ]] &&
9990 skip "Need MDS version at least 2.9.54" && return
9993 for facet in client mds1 ost1; do
9994 local facet_proc_dirs=$(do_facet $facet \
9995 \\\ls -d $proc_regexp 2> /dev/null)
9996 [ -z "$facet_proc_dirs" ] && error "no proc_dirs on $facet"
9997 echo "${facet}_proc_dirs='$facet_proc_dirs'"
9998 # Get the list of files that are missing the terminating newline
9999 local missing=($(do_facet $facet \
10000 find ${facet_proc_dirs} -type f \| \
10001 while read F\; do \
10002 awk -v FS='\v' -v RS='\v\v' \
10003 "'END { if(NR>0 && \
10004 \\\$NF !~ /.*\\\n\$/) \
10005 print FILENAME}'" \
10008 [ ${#missing[*]} -eq 0 ] ||
10009 error "files do not end with newline: ${missing[*]}"
10012 run_test 133h "Proc files should end with newlines"
10015 remote_mds_nodsh && skip "remote MDS with nodsh" && return
10016 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.54) ]] &&
10017 skip "Need MDS version at least 2.7.54" && return
10019 mkdir -p $DIR/$tdir || error "failed to create $DIR/$tdir"
10020 cancel_lru_locks mdc
10022 local nsdir="ldlm.namespaces.*-MDT0000-mdc-*"
10023 local unused=$($LCTL get_param -n $nsdir.lock_unused_count)
10024 [ $unused -eq 0 ] || error "$unused locks are not cleared"
10027 createmany -o $DIR/$tdir/f $nr ||
10028 error "failed to create $nr files in $DIR/$tdir"
10029 unused=$($LCTL get_param -n $nsdir.lock_unused_count)
10031 #define OBD_FAIL_LDLM_WATERMARK_LOW 0x327
10032 do_facet mds1 $LCTL set_param fail_loc=0x327
10033 do_facet mds1 $LCTL set_param fail_val=500
10036 echo "sleep 10 seconds ..."
10038 local lck_cnt=$($LCTL get_param -n $nsdir.lock_unused_count)
10040 do_facet mds1 $LCTL set_param fail_loc=0
10041 do_facet mds1 $LCTL set_param fail_val=0
10042 [ $lck_cnt -lt $unused ] ||
10043 error "No locks reclaimed, before:$unused, after:$lck_cnt"
10046 unlinkmany $DIR/$tdir/f $nr
10048 run_test 134a "Server reclaims locks when reaching lock_reclaim_threshold"
10051 remote_mds_nodsh && skip "remote MDS with nodsh" && return
10052 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.54) ]] &&
10053 skip "Need MDS version at least 2.7.54" && return
10055 mkdir -p $DIR/$tdir || error "failed to create $DIR/$tdir"
10056 cancel_lru_locks mdc
10058 local low_wm=$(do_facet mds1 $LCTL get_param -n \
10059 ldlm.lock_reclaim_threshold_mb)
10060 # disable reclaim temporarily
10061 do_facet mds1 $LCTL set_param ldlm.lock_reclaim_threshold_mb=0
10063 #define OBD_FAIL_LDLM_WATERMARK_HIGH 0x328
10064 do_facet mds1 $LCTL set_param fail_loc=0x328
10065 do_facet mds1 $LCTL set_param fail_val=500
10067 $LCTL set_param debug=+trace
10070 createmany -o $DIR/$tdir/f $nr &
10071 local create_pid=$!
10073 echo "Sleep $TIMEOUT seconds ..."
10075 if ! ps -p $create_pid > /dev/null 2>&1; then
10076 do_facet mds1 $LCTL set_param fail_loc=0
10077 do_facet mds1 $LCTL set_param fail_val=0
10078 do_facet mds1 $LCTL set_param \
10079 ldlm.lock_reclaim_threshold_mb=${low_wm}m
10080 error "createmany finished incorrectly!"
10082 do_facet mds1 $LCTL set_param fail_loc=0
10083 do_facet mds1 $LCTL set_param fail_val=0
10084 do_facet mds1 $LCTL set_param ldlm.lock_reclaim_threshold_mb=${low_wm}m
10085 wait $create_pid || return 1
10087 unlinkmany $DIR/$tdir/f $nr
10089 run_test 134b "Server rejects lock request when reaching lock_limit_mb"
10091 test_140() { #bug-17379
10092 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10093 test_mkdir -p $DIR/$tdir || error "Creating dir $DIR/$tdir"
10094 cd $DIR/$tdir || error "Changing to $DIR/$tdir"
10095 cp $(which stat) . || error "Copying stat to $DIR/$tdir"
10097 # VFS limits max symlink depth to 5(4KSTACK) or 7(8KSTACK) or 8
10098 # For kernel > 3.5, bellow only tests consecutive symlink (MAX 40)
10100 while i=`expr $i + 1`; do
10101 test_mkdir -p $i || error "Creating dir $i"
10102 cd $i || error "Changing to $i"
10103 ln -s ../stat stat || error "Creating stat symlink"
10104 # Read the symlink until ELOOP present,
10105 # not LBUGing the system is considered success,
10106 # we didn't overrun the stack.
10107 $OPENFILE -f O_RDONLY stat >/dev/null 2>&1; ret=$?
10108 [ $ret -ne 0 ] && {
10109 if [ $ret -eq 40 ]; then
10112 error "Open stat symlink"
10118 echo "The symlink depth = $i"
10119 [ $i -eq 5 -o $i -eq 7 -o $i -eq 8 -o $i -eq 40 ] ||
10120 error "Invalid symlink depth"
10122 # Test recursive symlink
10123 ln -s symlink_self symlink_self
10124 $OPENFILE -f O_RDONLY symlink_self >/dev/null 2>&1; ret=$?
10125 echo "open symlink_self returns $ret"
10126 [ $ret -eq 40 ] || error "recursive symlink doesn't return -ELOOP"
10128 run_test 140 "Check reasonable stack depth (shouldn't LBUG) ===="
10131 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10132 local TF="$TMP/$tfile"
10134 dd if=/dev/urandom of=$TF bs=6096 count=1 || error "dd failed"
10136 cancel_lru_locks osc
10137 cmp $TF $DIR/$tfile || error "$TMP/$tfile $DIR/$tfile differ"
10138 remount_client $MOUNT
10140 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (remount)"
10143 $TRUNCATE $DIR/$tfile 6000
10144 cancel_lru_locks osc
10145 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (truncate1)"
10148 echo "12345" >>$DIR/$tfile
10149 cancel_lru_locks osc
10150 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (append1)"
10153 echo "12345" >>$DIR/$tfile
10154 cancel_lru_locks osc
10155 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (append2)"
10160 run_test 150 "truncate/append tests"
10162 #LU-2902 roc_hit was not able to read all values from lproc
10163 function roc_hit_init() {
10164 local list=$(comma_list $(osts_nodes))
10165 local dir=$DIR/$tdir-check
10166 local file=$dir/file
10172 #use setstripe to do a write to every ost
10173 for i in $(seq 0 $((OSTCOUNT-1))); do
10174 $SETSTRIPE -c 1 -i $i $dir || error "$SETSTRIPE $file failed"
10175 dd if=/dev/urandom of=$file bs=4k count=4 2>&1 > /dev/null
10176 idx=$(printf %04x $i)
10177 BEFORE=$(get_osd_param $list *OST*$idx stats |
10178 awk '$1 == "cache_access" {sum += $7}
10179 END { printf("%0.0f", sum) }')
10181 cancel_lru_locks osc
10182 cat $file >/dev/null
10184 AFTER=$(get_osd_param $list *OST*$idx stats |
10185 awk '$1 == "cache_access" {sum += $7}
10186 END { printf("%0.0f", sum) }')
10188 echo BEFORE:$BEFORE AFTER:$AFTER
10189 if ! let "AFTER - BEFORE == 4"; then
10191 error "roc_hit is not safe to use"
10199 function roc_hit() {
10200 local list=$(comma_list $(osts_nodes))
10201 echo $(get_osd_param $list '' stats |
10202 awk '$1 == "cache_hit" {sum += $7}
10203 END { printf("%0.0f", sum) }')
10206 function set_cache() {
10209 if [ "$2" == "off" ]; then
10212 local list=$(comma_list $(osts_nodes))
10213 set_osd_param $list '' $1_cache_enable $on
10215 cancel_lru_locks osc
10219 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10220 remote_ost_nodsh && skip "remote OST with nodsh" && return
10223 local list=$(comma_list $(osts_nodes))
10225 # check whether obdfilter is cache capable at all
10226 if ! get_osd_param $list '' read_cache_enable >/dev/null; then
10227 echo "not cache-capable obdfilter"
10231 # check cache is enabled on all obdfilters
10232 if get_osd_param $list '' read_cache_enable | grep 0; then
10233 echo "oss cache is disabled"
10237 set_osd_param $list '' writethrough_cache_enable 1
10239 # check write cache is enabled on all obdfilters
10240 if get_osd_param $list '' writethrough_cache_enable | grep 0; then
10241 echo "oss write cache is NOT enabled"
10247 #define OBD_FAIL_OBD_NO_LRU 0x609
10248 do_nodes $list $LCTL set_param fail_loc=0x609
10250 # pages should be in the case right after write
10251 dd if=/dev/urandom of=$DIR/$tfile bs=4k count=$CPAGES ||
10254 local BEFORE=$(roc_hit)
10255 cancel_lru_locks osc
10256 cat $DIR/$tfile >/dev/null
10257 local AFTER=$(roc_hit)
10259 do_nodes $list $LCTL set_param fail_loc=0
10261 if ! let "AFTER - BEFORE == CPAGES"; then
10262 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
10265 # the following read invalidates the cache
10266 cancel_lru_locks osc
10267 set_osd_param $list '' read_cache_enable 0
10268 cat $DIR/$tfile >/dev/null
10270 # now data shouldn't be found in the cache
10272 cancel_lru_locks osc
10273 cat $DIR/$tfile >/dev/null
10275 if let "AFTER - BEFORE != 0"; then
10276 error "IN CACHE: before: $BEFORE, after: $AFTER"
10279 set_osd_param $list '' read_cache_enable 1
10282 run_test 151 "test cache on oss and controls ==============================="
10285 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10286 local TF="$TMP/$tfile"
10288 # simulate ENOMEM during write
10289 #define OBD_FAIL_OST_NOMEM 0x226
10290 lctl set_param fail_loc=0x80000226
10291 dd if=/dev/urandom of=$TF bs=6096 count=1 || error "dd failed"
10293 sync || error "sync failed"
10294 lctl set_param fail_loc=0
10296 # discard client's cache
10297 cancel_lru_locks osc
10299 # simulate ENOMEM during read
10300 lctl set_param fail_loc=0x80000226
10301 cmp $TF $DIR/$tfile || error "cmp failed"
10302 lctl set_param fail_loc=0
10306 run_test 152 "test read/write with enomem ============================"
10309 $MULTIOP $DIR/$tfile Ow4096Ycu || error "multiop failed"
10311 run_test 153 "test if fdatasync does not crash ======================="
10313 dot_lustre_fid_permission_check() {
10315 local ffid=$MOUNT/.lustre/fid/$fid
10318 echo "stat fid $fid"
10319 stat $ffid > /dev/null || error "stat $ffid failed."
10320 echo "touch fid $fid"
10321 touch $ffid || error "touch $ffid failed."
10322 echo "write to fid $fid"
10323 cat /etc/hosts > $ffid || error "write $ffid failed."
10324 echo "read fid $fid"
10325 diff /etc/hosts $ffid || error "read $ffid failed."
10326 echo "append write to fid $fid"
10327 cat /etc/hosts >> $ffid || error "append write $ffid failed."
10328 echo "rename fid $fid"
10329 mv $ffid $test_dir/$tfile.1 &&
10330 error "rename $ffid to $tfile.1 should fail."
10331 touch $test_dir/$tfile.1
10332 mv $test_dir/$tfile.1 $ffid &&
10333 error "rename $tfile.1 to $ffid should fail."
10334 rm -f $test_dir/$tfile.1
10335 echo "truncate fid $fid"
10336 $TRUNCATE $ffid 777 || error "truncate $ffid failed."
10337 if [ $MDSCOUNT -lt 2 ]; then #FIXME when cross-MDT hard link is working
10338 echo "link fid $fid"
10339 ln -f $ffid $test_dir/tfile.lnk || error "link $ffid failed."
10341 if [ -n $(lctl get_param -n mdc.*-mdc-*.connect_flags | grep acl) ]; then
10342 echo "setfacl fid $fid"
10343 setfacl -R -m u:bin:rwx $ffid || error "setfacl $ffid failed."
10344 echo "getfacl fid $fid"
10345 getfacl $ffid >/dev/null || error "getfacl $ffid failed."
10347 echo "unlink fid $fid"
10348 unlink $MOUNT/.lustre/fid/$fid && error "unlink $ffid should fail."
10349 echo "mknod fid $fid"
10350 mknod $ffid c 1 3 && error "mknod $ffid should fail."
10352 fid=[0xf00000400:0x1:0x0]
10353 ffid=$MOUNT/.lustre/fid/$fid
10355 echo "stat non-exist fid $fid"
10356 stat $ffid > /dev/null && error "stat non-exist $ffid should fail."
10357 echo "write to non-exist fid $fid"
10358 cat /etc/hosts > $ffid && error "write non-exist $ffid should fail."
10359 echo "link new fid $fid"
10360 ln $test_dir/$tfile $ffid && error "link $ffid should fail."
10362 mkdir -p $test_dir/$tdir
10363 touch $test_dir/$tdir/$tfile
10364 fid=$($LFS path2fid $test_dir/$tdir)
10367 error "error: could not get fid for $test_dir/$dir/$tfile."
10369 ffid=$MOUNT/.lustre/fid/$fid
10372 ls $ffid > /dev/null || error "ls $ffid failed."
10373 echo "touch $fid/$tfile.1"
10374 touch $ffid/$tfile.1 || error "touch $ffid/$tfile.1 failed."
10376 echo "touch $MOUNT/.lustre/fid/$tfile"
10377 touch $MOUNT/.lustre/fid/$tfile && \
10378 error "touch $MOUNT/.lustre/fid/$tfile should fail."
10380 echo "setxattr to $MOUNT/.lustre/fid"
10381 setfattr -n trusted.name1 -v value1 $MOUNT/.lustre/fid
10383 echo "listxattr for $MOUNT/.lustre/fid"
10384 getfattr -d -m "^trusted" $MOUNT/.lustre/fid
10386 echo "delxattr from $MOUNT/.lustre/fid"
10387 setfattr -x trusted.name1 $MOUNT/.lustre/fid
10389 echo "touch invalid fid: $MOUNT/.lustre/fid/[0x200000400:0x2:0x3]"
10390 touch $MOUNT/.lustre/fid/[0x200000400:0x2:0x3] &&
10391 error "touch invalid fid should fail."
10393 echo "touch non-normal fid: $MOUNT/.lustre/fid/[0x1:0x2:0x0]"
10394 touch $MOUNT/.lustre/fid/[0x1:0x2:0x0] &&
10395 error "touch non-normal fid should fail."
10397 echo "rename $tdir to $MOUNT/.lustre/fid"
10398 mrename $test_dir/$tdir $MOUNT/.lustre/fid &&
10399 error "rename to $MOUNT/.lustre/fid should fail."
10401 if [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.3.51) ]
10403 local old_obf_mode=$(stat --format="%a" $DIR/.lustre/fid)
10404 local new_obf_mode=777
10406 echo "change mode of $DIR/.lustre/fid to $new_obf_mode"
10407 chmod $new_obf_mode $DIR/.lustre/fid ||
10408 error "chmod $new_obf_mode $DIR/.lustre/fid failed"
10410 local obf_mode=$(stat --format=%a $DIR/.lustre/fid)
10411 [ $obf_mode -eq $new_obf_mode ] ||
10412 error "stat $DIR/.lustre/fid returned wrong mode $obf_mode"
10414 echo "restore mode of $DIR/.lustre/fid to $old_obf_mode"
10415 chmod $old_obf_mode $DIR/.lustre/fid ||
10416 error "chmod $old_obf_mode $DIR/.lustre/fid failed"
10419 $OPENFILE -f O_LOV_DELAY_CREATE:O_CREAT $test_dir/$tfile-2
10420 fid=$($LFS path2fid $test_dir/$tfile-2)
10422 if [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.6.50) ]
10424 echo "cp /etc/passwd $MOUNT/.lustre/fid/$fid"
10425 cp /etc/passwd $MOUNT/.lustre/fid/$fid ||
10426 error "create lov data thru .lustre failed"
10428 echo "cp /etc/passwd $test_dir/$tfile-2"
10429 cp /etc/passwd $test_dir/$tfile-2 ||
10430 error "copy to $test_dir/$tfile-2 failed."
10431 echo "diff /etc/passwd $MOUNT/.lustre/fid/$fid"
10432 diff /etc/passwd $MOUNT/.lustre/fid/$fid ||
10433 error "diff /etc/passwd $MOUNT/.lustre/fid/$fid failed."
10435 rm -rf $test_dir/tfile.lnk
10436 rm -rf $test_dir/$tfile-2
10440 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.1) ]] &&
10441 skip "Need MDS version at least 2.4.1" && return
10443 local tf=$DIR/$tfile
10446 local fid=$($LFS path2fid $tf)
10447 [ -z "$fid" ] && error "path2fid unable to get $tf FID"
10449 # check that we get the same pathname back
10450 local found=$($LFS fid2path $MOUNT "$fid")
10451 [ -z "$found" ] && error "fid2path unable to get '$fid' path"
10452 [ "$found" == "$tf" ] ||
10453 error "fid2path($fid=path2fid($tf)) = $found != $tf"
10455 run_test 154A "lfs path2fid and fid2path basic checks"
10458 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.1) ]] &&
10459 skip "Need MDS version at least 2.4.1" && return
10461 mkdir -p $DIR/$tdir || error "mkdir $tdir failed"
10462 touch $DIR/$tdir/$tfile || error "touch $DIR/$tdir/$tfile failed"
10463 local linkea=$($LL_DECODE_LINKEA $DIR/$tdir/$tfile | grep 'pfid')
10464 [ -z "$linkea" ] && error "decode linkea $DIR/$tdir/$tfile failed"
10466 local name=$(echo $linkea | awk '/pfid/ {print $5}' | sed -e "s/'//g")
10467 local PFID=$(echo $linkea | awk '/pfid/ {print $3}' | sed -e "s/,//g")
10469 # check that we get the same pathname
10470 echo "PFID: $PFID, name: $name"
10471 local FOUND=$($LFS fid2path $MOUNT "$PFID")
10472 [ -z "$FOUND" ] && error "fid2path unable to get $PFID path"
10473 [ "$FOUND/$name" != "$DIR/$tdir/$tfile" ] &&
10474 error "ll_decode_linkea has $FOUND/$name != $DIR/$tdir/$tfile"
10476 rm -rf $DIR/$tdir || error "Can not delete directory $DIR/$tdir"
10478 run_test 154B "verify the ll_decode_linkea tool"
10481 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10482 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.51) ]] ||
10483 { skip "Need MDS version at least 2.2.51"; return 0; }
10484 [ -z "$(which setfacl)" ] && skip "must have setfacl tool" && return
10485 [ -n "$FILESET" ] && skip "SKIP due to FILESET set" && return
10487 cp /etc/hosts $DIR/$tfile
10489 fid=$($LFS path2fid $DIR/$tfile)
10491 [ $rc -ne 0 ] && error "error: could not get fid for $DIR/$tfile."
10493 dot_lustre_fid_permission_check "$fid" $DIR ||
10494 error "dot lustre permission check $fid failed"
10496 rm -rf $MOUNT/.lustre && error ".lustre is not allowed to be unlinked"
10498 touch $MOUNT/.lustre/file &&
10499 error "creation is not allowed under .lustre"
10501 mkdir $MOUNT/.lustre/dir &&
10502 error "mkdir is not allowed under .lustre"
10506 run_test 154a "Open-by-FID"
10509 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10510 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.51) ]] ||
10511 { skip "Need MDS version at least 2.2.51"; return 0; }
10512 [ -n "$FILESET" ] && skip "SKIP due to FILESET set" && return
10514 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
10516 local remote_dir=$DIR/$tdir/remote_dir
10520 mkdir -p $DIR/$tdir
10521 $LFS mkdir -i $MDTIDX $remote_dir ||
10522 error "create remote directory failed"
10524 cp /etc/hosts $remote_dir/$tfile
10526 fid=$($LFS path2fid $remote_dir/$tfile)
10528 [ $rc -ne 0 ] && error "error: could not get fid for $remote_dir/$tfile"
10530 dot_lustre_fid_permission_check "$fid" $remote_dir ||
10531 error "dot lustre permission check $fid failed"
10534 run_test 154b "Open-by-FID for remote directory"
10537 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.1) ]] &&
10538 skip "Need MDS version at least 2.4.1" && return
10540 touch $DIR/$tfile.1 $DIR/$tfile.2 $DIR/$tfile.3
10541 local FID1=$($LFS path2fid $DIR/$tfile.1)
10542 local FID2=$($LFS path2fid $DIR/$tfile.2)
10543 local FID3=$($LFS path2fid $DIR/$tfile.3)
10546 $LFS path2fid $DIR/$tfile.[123] | while read PATHNAME FID; do
10547 [ "$PATHNAME" = "$DIR/$tfile.$N:" ] ||
10548 error "path2fid pathname $PATHNAME != $DIR/$tfile.$N:"
10550 [ "$FID" = "${!want}" ] ||
10551 error "path2fid $PATHNAME FID $FID != FID$N ${!want}"
10555 $LFS fid2path $MOUNT "$FID1" "$FID2" "$FID3" | while read PATHNAME;
10557 [ "$PATHNAME" = "$DIR/$tfile.$N" ] ||
10558 error "fid2path pathname $PATHNAME != $DIR/$tfile.$N:"
10562 run_test 154c "lfs path2fid and fid2path multiple arguments"
10565 remote_mds_nodsh && skip "remote MDS with nodsh" && return
10566 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.5.53) ]] &&
10567 skip "Need MDS version at least 2.5.53" && return
10569 if remote_mds; then
10570 nid=$($LCTL list_nids | sed "s/\./\\\./g")
10574 local proc_ofile="mdt.*.exports.'$nid'.open_files"
10581 local fid=$($LFS path2fid $DIR/$tfile)
10584 cmd="exec $fd<$DIR/$tfile"
10586 local fid_list=$(do_facet $SINGLEMDS $LCTL get_param $proc_ofile)
10587 echo "$fid_list" | grep "$fid"
10590 cmd="exec $fd>/dev/null"
10592 if [ $rc -ne 0 ]; then
10593 error "FID $fid not found in open files list $fid_list"
10596 run_test 154d "Verify open file fid"
10600 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.6.50) ]] &&
10601 skip "Need MDS version at least 2.6.50" && return
10603 if ls -a $MOUNT | grep -q '^\.lustre$'; then
10604 error ".lustre returned by readdir"
10607 run_test 154e ".lustre is not returned by readdir"
10610 [ -n "$FILESET" ] && skip "SKIP due to FILESET set" && return
10611 # create parent directory on a single MDT to avoid cross-MDT hardlinks
10612 test_mkdir -p -c1 $DIR/$tdir/d
10613 # test dirs inherit from its stripe
10614 mkdir -p $DIR/$tdir/d/foo1 || error "mkdir error"
10615 mkdir -p $DIR/$tdir/d/foo2 || error "mkdir error"
10616 cp /etc/hosts $DIR/$tdir/d/foo1/$tfile
10617 ln $DIR/$tdir/d/foo1/$tfile $DIR/$tdir/d/foo2/link
10620 # get fid of parents
10621 local FID0=$($LFS path2fid $DIR/$tdir/d)
10622 local FID1=$($LFS path2fid $DIR/$tdir/d/foo1)
10623 local FID2=$($LFS path2fid $DIR/$tdir/d/foo2)
10624 local FID3=$($LFS path2fid $DIR)
10626 # check that path2fid --parents returns expected <parent_fid>/name
10627 # 1) test for a directory (single parent)
10628 local parent=$($LFS path2fid --parents $DIR/$tdir/d/foo1)
10629 [ "$parent" == "$FID0/foo1" ] ||
10630 error "expected parent: $FID0/foo1, got: $parent"
10632 # 2) test for a file with nlink > 1 (multiple parents)
10633 parent=$($LFS path2fid --parents $DIR/$tdir/d/foo1/$tfile)
10634 echo "$parent" | grep -F "$FID1/$tfile" ||
10635 error "$FID1/$tfile not returned in parent list"
10636 echo "$parent" | grep -F "$FID2/link" ||
10637 error "$FID2/link not returned in parent list"
10639 # 3) get parent by fid
10640 local file_fid=$($LFS path2fid $DIR/$tdir/d/foo1/$tfile)
10641 parent=$($LFS path2fid --parents $MOUNT/.lustre/fid/$file_fid)
10642 echo "$parent" | grep -F "$FID1/$tfile" ||
10643 error "$FID1/$tfile not returned in parent list (by fid)"
10644 echo "$parent" | grep -F "$FID2/link" ||
10645 error "$FID2/link not returned in parent list (by fid)"
10647 # 4) test for entry in root directory
10648 parent=$($LFS path2fid --parents $DIR/f)
10649 echo "$parent" | grep -F "$FID3/f" ||
10650 error "$FID3/f not returned in parent list"
10652 # 5) test it on root directory
10653 [ -z "$($LFS path2fid --parents $MOUNT 2>/dev/null)" ] ||
10654 error "$MOUNT should not have parents"
10656 # enable xattr caching and check that linkea is correctly updated
10657 local save="$TMP/$TESTSUITE-$TESTNAME.parameters"
10658 save_lustre_params client "llite.*.xattr_cache" > $save
10659 lctl set_param llite.*.xattr_cache 1
10661 # 6.1) linkea update on rename
10662 mv $DIR/$tdir/d/foo1/$tfile $DIR/$tdir/d/foo2/$tfile.moved
10664 # get parents by fid
10665 parent=$($LFS path2fid --parents $MOUNT/.lustre/fid/$file_fid)
10666 # foo1 should no longer be returned in parent list
10667 echo "$parent" | grep -F "$FID1" &&
10668 error "$FID1 should no longer be in parent list"
10669 # the new path should appear
10670 echo "$parent" | grep -F "$FID2/$tfile.moved" ||
10671 error "$FID2/$tfile.moved is not in parent list"
10673 # 6.2) linkea update on unlink
10674 rm -f $DIR/$tdir/d/foo2/link
10675 parent=$($LFS path2fid --parents $MOUNT/.lustre/fid/$file_fid)
10676 # foo2/link should no longer be returned in parent list
10677 echo "$parent" | grep -F "$FID2/link" &&
10678 error "$FID2/link should no longer be in parent list"
10682 restore_lustre_params < $save
10685 run_test 154f "get parent fids by reading link ea"
10689 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.6.92) ]] ||
10690 { skip "Need MDS version at least 2.6.92"; return 0; }
10691 [ -n "$FILESET" ] && skip "SKIP due to FILESET set" && return
10693 mkdir -p $DIR/$tdir
10694 llapi_fid_test -d $DIR/$tdir
10696 run_test 154g "various llapi FID tests"
10698 test_155_small_load() {
10699 local temp=$TMP/$tfile
10700 local file=$DIR/$tfile
10702 dd if=/dev/urandom of=$temp bs=6096 count=1 || \
10703 error "dd of=$temp bs=6096 count=1 failed"
10705 cancel_lru_locks osc
10706 cmp $temp $file || error "$temp $file differ"
10708 $TRUNCATE $temp 6000
10709 $TRUNCATE $file 6000
10710 cmp $temp $file || error "$temp $file differ (truncate1)"
10712 echo "12345" >>$temp
10713 echo "12345" >>$file
10714 cmp $temp $file || error "$temp $file differ (append1)"
10716 echo "12345" >>$temp
10717 echo "12345" >>$file
10718 cmp $temp $file || error "$temp $file differ (append2)"
10724 test_155_big_load() {
10725 remote_ost_nodsh && skip "remote OST with nodsh" && return
10726 local temp=$TMP/$tfile
10727 local file=$DIR/$tfile
10730 local cache_size=$(do_facet ost$((MAXI+1)) \
10731 "awk '/cache/ {sum+=\\\$4} END {print sum}' /proc/cpuinfo")
10732 local large_file_size=$((cache_size * 2))
10734 echo "OSS cache size: $cache_size KB"
10735 echo "Large file size: $large_file_size KB"
10737 [ $MAXV -le $large_file_size ] && \
10738 skip_env "max available OST size needs > $large_file_size KB" && \
10741 $SETSTRIPE $file -c 1 -i $MAXI || error "$SETSTRIPE $file failed"
10743 dd if=/dev/urandom of=$temp bs=$large_file_size count=1k || \
10744 error "dd of=$temp bs=$large_file_size count=1k failed"
10747 cancel_lru_locks osc
10748 cmp $temp $file || error "$temp $file differ"
10754 save_writethrough() {
10755 local facets=$(get_facets OST)
10757 save_lustre_params $facets "obdfilter.*.writethrough_cache_enable" > $1
10758 save_lustre_params $facets "osd-*.*.writethrough_cache_enable" >> $1
10762 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10763 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
10764 save_writethrough $p
10767 set_cache writethrough on
10768 test_155_small_load
10769 restore_lustre_params < $p
10772 run_test 155a "Verify small file correctness: read cache:on write_cache:on"
10775 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10776 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
10777 save_writethrough $p
10780 set_cache writethrough off
10781 test_155_small_load
10782 restore_lustre_params < $p
10785 run_test 155b "Verify small file correctness: read cache:on write_cache:off"
10788 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10789 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
10790 save_writethrough $p
10793 set_cache writethrough on
10794 test_155_small_load
10795 restore_lustre_params < $p
10798 run_test 155c "Verify small file correctness: read cache:off write_cache:on"
10801 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10802 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
10803 save_writethrough $p
10806 set_cache writethrough off
10807 test_155_small_load
10808 restore_lustre_params < $p
10811 run_test 155d "Verify small file correctness: read cache:off write_cache:off"
10814 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10815 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
10816 save_writethrough $p
10819 set_cache writethrough on
10821 restore_lustre_params < $p
10824 run_test 155e "Verify big file correctness: read cache:on write_cache:on"
10827 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10828 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
10829 save_writethrough $p
10832 set_cache writethrough off
10834 restore_lustre_params < $p
10837 run_test 155f "Verify big file correctness: read cache:on write_cache:off"
10840 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10841 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
10842 save_writethrough $p
10845 set_cache writethrough on
10847 restore_lustre_params < $p
10850 run_test 155g "Verify big file correctness: read cache:off write_cache:on"
10853 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10854 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
10855 save_writethrough $p
10858 set_cache writethrough off
10860 restore_lustre_params < $p
10863 run_test 155h "Verify big file correctness: read cache:off write_cache:off"
10866 remote_ost_nodsh && skip "remote OST with nodsh" && return
10867 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10871 local file="$DIR/$tfile"
10872 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
10874 [ "$(facet_fstype ost1)" = "zfs" -a \
10875 $(lustre_version_code ost1 -lt $(version_code 2.6.93)) ] &&
10876 skip "LU-1956/LU-2261: stats not implemented on OSD ZFS" &&
10879 save_writethrough $p
10882 log "Turn on read and write cache"
10884 set_cache writethrough on
10886 log "Write data and read it back."
10887 log "Read should be satisfied from the cache."
10888 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
10890 cancel_lru_locks osc
10891 cat $file >/dev/null
10893 if ! let "AFTER - BEFORE == CPAGES"; then
10894 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
10896 log "cache hits:: before: $BEFORE, after: $AFTER"
10899 log "Read again; it should be satisfied from the cache."
10901 cancel_lru_locks osc
10902 cat $file >/dev/null
10904 if ! let "AFTER - BEFORE == CPAGES"; then
10905 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
10907 log "cache hits:: before: $BEFORE, after: $AFTER"
10910 log "Turn off the read cache and turn on the write cache"
10912 set_cache writethrough on
10914 log "Read again; it should be satisfied from the cache."
10916 cancel_lru_locks osc
10917 cat $file >/dev/null
10919 if ! let "AFTER - BEFORE == CPAGES"; then
10920 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
10922 log "cache hits:: before: $BEFORE, after: $AFTER"
10925 log "Read again; it should not be satisfied from the cache."
10927 cancel_lru_locks osc
10928 cat $file >/dev/null
10930 if ! let "AFTER - BEFORE == 0"; then
10931 error "IN CACHE: before: $BEFORE, after: $AFTER"
10933 log "cache hits:: before: $BEFORE, after: $AFTER"
10936 log "Write data and read it back."
10937 log "Read should be satisfied from the cache."
10938 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
10940 cancel_lru_locks osc
10941 cat $file >/dev/null
10943 if ! let "AFTER - BEFORE == CPAGES"; then
10944 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
10946 log "cache hits:: before: $BEFORE, after: $AFTER"
10949 log "Read again; it should not be satisfied from the cache."
10951 cancel_lru_locks osc
10952 cat $file >/dev/null
10954 if ! let "AFTER - BEFORE == 0"; then
10955 error "IN CACHE: before: $BEFORE, after: $AFTER"
10957 log "cache hits:: before: $BEFORE, after: $AFTER"
10960 log "Turn off read and write cache"
10962 set_cache writethrough off
10964 log "Write data and read it back"
10965 log "It should not be satisfied from the cache."
10967 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
10968 cancel_lru_locks osc
10970 cat $file >/dev/null
10972 if ! let "AFTER - BEFORE == 0"; then
10973 error_ignore bz20762 "IN CACHE: before: $BEFORE, after: $AFTER"
10975 log "cache hits:: before: $BEFORE, after: $AFTER"
10978 log "Turn on the read cache and turn off the write cache"
10980 set_cache writethrough off
10982 log "Write data and read it back"
10983 log "It should not be satisfied from the cache."
10985 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
10987 cancel_lru_locks osc
10988 cat $file >/dev/null
10990 if ! let "AFTER - BEFORE == 0"; then
10991 error_ignore bz20762 "IN CACHE: before: $BEFORE, after: $AFTER"
10993 log "cache hits:: before: $BEFORE, after: $AFTER"
10996 log "Read again; it should be satisfied from the cache."
10998 cancel_lru_locks osc
10999 cat $file >/dev/null
11001 if ! let "AFTER - BEFORE == CPAGES"; then
11002 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
11004 log "cache hits:: before: $BEFORE, after: $AFTER"
11008 restore_lustre_params < $p
11011 run_test 156 "Verification of tunables"
11014 cleanup_changelog () {
11016 echo "Deregistering changelog client $CL_USER"
11017 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister $CL_USER
11021 if [[ $MDSCOUNT -gt 1 ]]; then
11022 error_ignore bz17935 $*
11030 local CL_MASK_PARAM="mdd.$MDT0.changelog_mask"
11032 MASK=$(do_facet $SINGLEMDS $LCTL get_param $CL_MASK_PARAM| grep -c "$1")
11034 if [ $MASK -eq 1 ]; then
11035 do_facet $SINGLEMDS $LCTL set_param $CL_MASK_PARAM="-$1"
11037 do_facet $SINGLEMDS $LCTL set_param $CL_MASK_PARAM="+$1"
11041 changelog_extract_field() {
11045 local identifier=$4
11047 $LFS changelog $mdt | gawk "/$cltype.*$file$/ {
11048 print gensub(/^.* "$identifier'(\[[^\]]*\]).*$/,"\\1",1)}' |
11053 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11054 remote_mds_nodsh && skip "remote MDS with nodsh" && return
11055 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] ||
11056 { skip "Need MDS version at least 2.2.0"; return; }
11058 local CL_USERS="mdd.$MDT0.changelog_users"
11059 local GET_CL_USERS="do_facet $SINGLEMDS $LCTL get_param -n $CL_USERS"
11060 CL_USER=$(do_facet $SINGLEMDS $LCTL --device $MDT0 \
11061 changelog_register -n)
11062 echo "Registered as changelog user $CL_USER"
11063 trap cleanup_changelog EXIT
11064 $GET_CL_USERS | grep -q $CL_USER ||
11065 error "User $CL_USER not found in changelog_users"
11068 test_mkdir -p $DIR/$tdir/pics/2008/zachy
11069 touch $DIR/$tdir/pics/2008/zachy/timestamp
11070 cp /etc/hosts $DIR/$tdir/pics/2008/zachy/pic1.jpg
11071 mv $DIR/$tdir/pics/2008/zachy $DIR/$tdir/pics/zach
11072 ln $DIR/$tdir/pics/zach/pic1.jpg $DIR/$tdir/pics/2008/portland.jpg
11073 ln -s $DIR/$tdir/pics/2008/portland.jpg $DIR/$tdir/pics/desktop.jpg
11074 rm $DIR/$tdir/pics/desktop.jpg
11076 $LFS changelog $MDT0 | tail -5
11078 echo "verifying changelog mask"
11079 changelog_chmask "MKDIR"
11080 changelog_chmask "CLOSE"
11082 test_mkdir -p $DIR/$tdir/pics/zach/sofia
11083 echo "zzzzzz" > $DIR/$tdir/pics/zach/file
11085 changelog_chmask "MKDIR"
11086 changelog_chmask "CLOSE"
11088 test_mkdir -p $DIR/$tdir/pics/2008/sofia
11089 echo "zzzzzz" > $DIR/$tdir/pics/zach/file
11091 $LFS changelog $MDT0
11092 MKDIRS=$($LFS changelog $MDT0 | tail -5 | grep -c "MKDIR")
11093 CLOSES=$($LFS changelog $MDT0 | tail -5 | grep -c "CLOSE")
11094 [ $MKDIRS -eq 1 ] || err17935 "MKDIR changelog mask count $DIRS != 1"
11095 [ $CLOSES -eq 1 ] || err17935 "CLOSE changelog mask count $DIRS != 1"
11098 echo "verifying target fid"
11099 fidc=$(changelog_extract_field $MDT0 "CREAT" "timestamp" "t=")
11100 fidf=$($LFS path2fid $DIR/$tdir/pics/zach/timestamp)
11101 [ "$fidc" == "$fidf" ] ||
11102 err17935 "fid in changelog $fidc != file fid $fidf"
11103 echo "verifying parent fid"
11104 fidc=$(changelog_extract_field $MDT0 "CREAT" "timestamp" "p=")
11105 fidf=$($LFS path2fid $DIR/$tdir/pics/zach)
11106 [ "$fidc" == "$fidf" ] ||
11107 err17935 "pfid in changelog $fidc != dir fid $fidf"
11109 USER_REC1=$($GET_CL_USERS | awk "\$1 == \"$CL_USER\" {print \$2}")
11110 $LFS changelog_clear $MDT0 $CL_USER $(($USER_REC1 + 5))
11111 USER_REC2=$($GET_CL_USERS | awk "\$1 == \"$CL_USER\" {print \$2}")
11112 echo "verifying user clear: $(( $USER_REC1 + 5 )) == $USER_REC2"
11113 [ $USER_REC2 == $(($USER_REC1 + 5)) ] ||
11114 err17935 "user index expected $(($USER_REC1 + 5)) is $USER_REC2"
11116 MIN_REC=$($GET_CL_USERS |
11117 awk 'min == "" || $2 < min {min = $2}; END {print min}')
11118 FIRST_REC=$($LFS changelog $MDT0 | head -n1 | awk '{print $1}')
11119 echo "verifying min purge: $(( $MIN_REC + 1 )) == $FIRST_REC"
11120 [ $FIRST_REC == $(($MIN_REC + 1)) ] ||
11121 err17935 "first index should be $(($MIN_REC + 1)) is $FIRST_REC"
11123 # LU-3446 changelog index reset on MDT restart
11124 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
11125 CUR_REC1=$($GET_CL_USERS | head -n1 | cut -f3 -d' ')
11126 $LFS changelog_clear $MDT0 $CL_USER 0
11127 stop $SINGLEMDS || error "Fail to stop MDT."
11128 start $SINGLEMDS $MDT_DEV $MDS_MOUNT_OPTS || error "Fail to start MDT."
11129 CUR_REC2=$($GET_CL_USERS | head -n1 | cut -f3 -d' ')
11130 echo "verifying index survives MDT restart: $CUR_REC1 == $CUR_REC2"
11131 [ $CUR_REC1 == $CUR_REC2 ] ||
11132 err17935 "current index should be $CUR_REC1 is $CUR_REC2"
11134 echo "verifying user deregister"
11136 $GET_CL_USERS | grep -q $CL_USER &&
11137 error "User $CL_USER still in changelog_users"
11139 USERS=$(( $($GET_CL_USERS | wc -l) - 2 ))
11140 if [ $CL_USER -eq 0 ]; then
11141 LAST_REC1=$($GET_CL_USERS | head -n1 | cut -f3 -d' ')
11142 touch $DIR/$tdir/chloe
11143 LAST_REC2=$($GET_CL_USERS | head -n1 | cut -f3 -d' ')
11144 echo "verify changelogs are off: $LAST_REC1 == $LAST_REC2"
11145 [ $LAST_REC1 == $LAST_REC2 ] || error "changelogs not off"
11147 echo "$CL_USER other changelog users; can't verify off"
11150 run_test 160a "changelog sanity"
11152 test_160b() { # LU-3587
11153 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11154 remote_mds_nodsh && skip "remote MDS with nodsh" && return
11155 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] ||
11156 { skip "Need MDS version at least 2.2.0"; return; }
11158 local CL_USERS="mdd.$MDT0.changelog_users"
11159 local GET_CL_USERS="do_facet $SINGLEMDS $LCTL get_param -n $CL_USERS"
11160 CL_USER=$(do_facet $SINGLEMDS $LCTL --device $MDT0 \
11161 changelog_register -n)
11162 echo "Registered as changelog user $CL_USER"
11163 trap cleanup_changelog EXIT
11164 $GET_CL_USERS | grep -q $CL_USER ||
11165 error "User $CL_USER not found in changelog_users"
11167 local LONGNAME1=$(str_repeat a 255)
11168 local LONGNAME2=$(str_repeat b 255)
11171 echo "creating very long named file"
11172 touch $LONGNAME1 || error "create of $LONGNAME1 failed"
11173 echo "moving very long named file"
11174 mv $LONGNAME1 $LONGNAME2
11176 $LFS changelog $MDT0 | grep RENME
11180 run_test 160b "Verify that very long rename doesn't crash in changelog"
11183 remote_mds_nodsh && skip "remote MDS with nodsh" && return
11186 local server_version=$(lustre_version_code $SINGLEMDS)
11188 [[ $server_version -gt $(version_code 2.5.57) ]] ||
11189 [[ $server_version -gt $(version_code 2.5.1) &&
11190 $server_version -lt $(version_code 2.5.50) ]] ||
11191 { skip "Need MDS version at least 2.5.58 or 2.5.2+"; return; }
11192 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11194 # Registration step
11195 CL_USER=$(do_facet $SINGLEMDS $LCTL --device $MDT0 \
11196 changelog_register -n)
11197 trap cleanup_changelog EXIT
11200 mkdir -p $DIR/$tdir
11201 $MCREATE $DIR/$tdir/foo_160c
11202 changelog_chmask "TRUNC"
11203 $TRUNCATE $DIR/$tdir/foo_160c 200
11204 changelog_chmask "TRUNC"
11205 $TRUNCATE $DIR/$tdir/foo_160c 199
11206 $LFS changelog $MDT0
11207 TRUNCS=$($LFS changelog $MDT0 | tail -5 | grep -c "TRUNC")
11208 [ $TRUNCS -eq 1 ] || err17935 "TRUNC changelog mask count $TRUNCS != 1"
11209 $LFS changelog_clear $MDT0 $CL_USER 0
11211 # Deregistration step
11214 run_test 160c "verify that changelog log catch the truncate event"
11217 remote_mds_nodsh && skip "remote MDS with nodsh" && return
11218 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
11220 local server_version=$(lustre_version_code mds1)
11221 local CL_MASK_PARAM="mdd.$MDT0.changelog_mask"
11223 [[ $server_version -ge $(version_code 2.7.60) ]] ||
11224 { skip "Need MDS version at least 2.7.60+"; return; }
11225 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11227 # Registration step
11228 CL_USER=$(do_facet mds1 $LCTL --device $MDT0 \
11229 changelog_register -n)
11231 trap cleanup_changelog EXIT
11232 mkdir -p $DIR/$tdir/migrate_dir
11233 $LFS changelog_clear $MDT0 $CL_USER 0
11235 $LFS migrate -m 1 $DIR/$tdir/migrate_dir || error "migrate fails"
11236 $LFS changelog $MDT0
11237 MIGRATES=$($LFS changelog $MDT0 | tail -5 | grep -c "MIGRT")
11238 $LFS changelog_clear $MDT0 $CL_USER 0
11239 [ $MIGRATES -eq 1 ] ||
11240 error "MIGRATE changelog mask count $MIGRATES != 1"
11242 # Deregistration step
11245 run_test 160d "verify that changelog log catch the migrate event"
11248 remote_mds_nodsh && skip "remote MDS with nodsh" && return
11251 CL_USER=$(do_facet $SINGLEMDS $LCTL --device $MDT0 \
11252 changelog_register -n)
11253 echo "Registered as changelog user $CL_USER"
11254 trap cleanup_changelog EXIT
11256 # Delete a future user (expect fail)
11257 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister cl77
11260 if [ $rc -eq 0 ]; then
11261 error "Deleted non-existant user cl77"
11262 elif [ $rc -ne 2 ]; then
11263 error "changelog_deregister failed with $rc, " \
11264 "expected 2 (ENOENT)"
11267 # Clear to a bad index (1 billion should be safe)
11268 $LFS changelog_clear $MDT0 $CL_USER 1000000000
11271 if [ $rc -eq 0 ]; then
11272 error "Successfully cleared to invalid CL index"
11273 elif [ $rc -ne 22 ]; then
11274 error "changelog_clear failed with $rc, expected 22 (EINVAL)"
11277 run_test 160e "changelog negative testing"
11281 do_facet $SINGLEMDS $LCTL set_param fail_loc=0 fail_val=0
11282 echo "Deregistering changelog client $CL_USER"
11283 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister $CL_USER
11284 echo "Deregistering changelog client $CL_USER2"
11285 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister $CL_USER2
11286 restore_lustre_params < $save_params
11291 # do_facet $SINGLEMDS $LCTL set_param mdd.$MDT0.changelog_gc=1
11292 # should be set by default
11294 local CL_USERS="mdd.$MDT0.changelog_users"
11295 local GET_CL_USERS="do_facet $SINGLEMDS $LCTL get_param -n $CL_USERS"
11296 local save_params="$TMP/sanity-$TESTNAME.parameters"
11298 save_lustre_params $SINGLEMDS \
11299 "mdd.$MDT0.changelog_max_idle_time" > $save_params
11300 save_lustre_params $SINGLEMDS \
11301 "mdd.$MDT0.changelog_min_gc_interval" >> $save_params
11302 save_lustre_params $SINGLEMDS \
11303 "mdd.$MDT0.changelog_min_free_cat_entries" >> $save_params
11305 trap cleanup_160f EXIT
11308 CL_USER=$(do_facet $SINGLEMDS $LCTL --device $MDT0 \
11309 changelog_register -n)
11310 echo "Registered as changelog user $CL_USER"
11311 CL_USER2=$(do_facet $SINGLEMDS $LCTL --device $MDT0 \
11312 changelog_register -n)
11313 echo "Registered as changelog user $CL_USER2"
11314 $GET_CL_USERS | grep -q $CL_USER ||
11315 error "User $CL_USER not found in changelog_users"
11316 $GET_CL_USERS | grep -q $CL_USER2 ||
11317 error "User $CL_USER2 not found in changelog_users"
11319 # generate some changelogs to accumulate
11320 mkdir -p $DIR/$tdir || error "mkdir $tdir failed"
11321 touch $DIR/$tdir/$tfile || error "touch $DIR/$tdir/$tfile failed"
11322 touch $DIR/$tdir/${tfile}2 || error "touch $DIR/$tdir/${tfile}2 failed"
11323 rm -f $DIR/$tdir/$tfile || error "rm -f $tfile failed"
11325 # check changelogs have been generated
11326 nbcl=$($LFS changelog $MDT0 | wc -l)
11327 [[ $nbcl -eq 0 ]] && error "no changelogs found"
11329 do_facet $SINGLEMDS $LCTL set_param \
11330 mdd.$MDT0.changelog_max_idle_time=10
11331 do_facet $SINGLEMDS $LCTL set_param \
11332 mdd.$MDT0.changelog_min_gc_interval=2
11333 do_facet $SINGLEMDS $LCTL set_param \
11334 mdd.$MDT0.changelog_min_free_cat_entries=3
11336 # simulate changelog catalog almost full
11337 #define OBD_FAIL_CAT_FREE_RECORDS 0x1313
11338 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x1313
11339 do_facet $SINGLEMDS $LCTL set_param fail_val=3
11342 USER_REC1=$($GET_CL_USERS | awk "\$1 == \"$CL_USER\" {print \$2}")
11343 $LFS changelog_clear $MDT0 $CL_USER $(($USER_REC1 + 2))
11344 USER_REC2=$($GET_CL_USERS | awk "\$1 == \"$CL_USER\" {print \$2}")
11345 echo "verifying user clear: $(( $USER_REC1 + 2 )) == $USER_REC2"
11346 [ $USER_REC2 == $(($USER_REC1 + 2)) ] ||
11347 error "user index expected $(($USER_REC1 + 2)) is $USER_REC2"
11350 # generate one more changelog to trigger fail_loc
11351 rm -rf $DIR/$tdir || error "rm -rf $tdir failed"
11353 # ensure gc thread is done
11354 wait_update_facet $SINGLEMDS \
11355 "ps -e -o comm= | grep chlg_gc_thread" "" 20
11357 # check user still registered
11358 $GET_CL_USERS | grep -q $CL_USER ||
11359 error "User $CL_USER not found in changelog_users"
11360 # check user2 unregistered
11361 $GET_CL_USERS | grep -q $CL_USER2 &&
11362 error "User $CL_USER2 still found in changelog_users"
11364 # check changelogs are present and starting at $USER_REC2 + 1
11365 FIRST_REC=$($LFS changelog $MDT0 | head -n1 | awk '{print $1}')
11366 echo "verifying min purge: $(( $USER_REC2 + 1 )) == $FIRST_REC"
11367 [ $FIRST_REC == $(($USER_REC2 + 1)) ] ||
11368 error "first index should be $(($USER_REC2 + 1)) is $FIRST_REC"
11372 run_test 160f "changelog garbage collect (timestamped users)"
11375 # do_facet $SINGLEMDS $LCTL set_param mdd.$MDT0.changelog_gc=1
11376 # should be set by default
11378 local CL_USERS="mdd.$MDT0.changelog_users"
11379 local GET_CL_USERS="do_facet $SINGLEMDS $LCTL get_param -n $CL_USERS"
11380 local save_params="$TMP/sanity-$TESTNAME.parameters"
11382 save_lustre_params $SINGLEMDS \
11383 "mdd.$MDT0.changelog_max_idle_indexes" > $save_params
11384 save_lustre_params $SINGLEMDS \
11385 "mdd.$MDT0.changelog_min_gc_interval" >> $save_params
11386 save_lustre_params $SINGLEMDS \
11387 "mdd.$MDT0.changelog_min_free_cat_entries" >> $save_params
11389 trap cleanup_160f EXIT
11391 #define OBD_FAIL_TIME_IN_CHLOG_USER 0x1314
11392 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x1314
11395 CL_USER=$(do_facet $SINGLEMDS $LCTL --device $MDT0 \
11396 changelog_register -n)
11397 echo "Registered as changelog user $CL_USER"
11398 CL_USER2=$(do_facet $SINGLEMDS $LCTL --device $MDT0 \
11399 changelog_register -n)
11400 echo "Registered as changelog user $CL_USER2"
11401 $GET_CL_USERS | grep -q $CL_USER ||
11402 error "User $CL_USER not found in changelog_users"
11403 $GET_CL_USERS | grep -q $CL_USER2 ||
11404 error "User $CL_USER2 not found in changelog_users"
11406 # generate some changelogs to accumulate
11407 mkdir -p $DIR/$tdir || error "mkdir $tdir failed"
11408 touch $DIR/$tdir/$tfile || error "touch $DIR/$tdir/$tfile failed"
11409 touch $DIR/$tdir/${tfile}2 || error "touch $DIR/$tdir/${tfile}2 failed"
11410 rm -f $DIR/$tdir/$tfile || error "rm -f $tfile failed"
11412 # check changelogs have been generated
11413 nbcl=$($LFS changelog $MDT0 | wc -l)
11414 [[ $nbcl -eq 0 ]] && error "no changelogs found"
11416 do_facet $SINGLEMDS $LCTL set_param \
11417 mdd.$MDT0.changelog_max_idle_indexes=$((nbcl - 1))
11418 do_facet $SINGLEMDS $LCTL set_param \
11419 mdd.$MDT0.changelog_min_gc_interval=2
11420 do_facet $SINGLEMDS $LCTL set_param \
11421 mdd.$MDT0.changelog_min_free_cat_entries=3
11423 # simulate changelog catalog almost full
11424 #define OBD_FAIL_CAT_FREE_RECORDS 0x1313
11425 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x1313
11426 do_facet $SINGLEMDS $LCTL set_param fail_val=3
11428 USER_REC1=$($GET_CL_USERS | awk "\$1 == \"$CL_USER\" {print \$2}")
11429 $LFS changelog_clear $MDT0 $CL_USER $(($USER_REC1 + 3))
11430 USER_REC2=$($GET_CL_USERS | awk "\$1 == \"$CL_USER\" {print \$2}")
11431 echo "verifying user clear: $(( $USER_REC1 + 3 )) == $USER_REC2"
11432 [ $USER_REC2 == $(($USER_REC1 + 3)) ] ||
11433 error "user index expected $(($USER_REC1 + 3)) is $USER_REC2"
11435 # generate one more changelog to trigger fail_loc
11436 rm -rf $DIR/$tdir || error "rm -rf $tdir failed"
11438 # ensure gc thread is done
11439 wait_update_facet $SINGLEMDS \
11440 "ps -e -o comm= | grep chlg_gc_thread" "" 20
11442 # check user still registered
11443 $GET_CL_USERS | grep -q $CL_USER ||
11444 error "User $CL_USER not found in changelog_users"
11445 # check user2 unregistered
11446 $GET_CL_USERS | grep -q $CL_USER2 &&
11447 error "User $CL_USER2 still found in changelog_users"
11449 # check changelogs are present and starting at $USER_REC2 + 1
11450 FIRST_REC=$($LFS changelog $MDT0 | head -n1 | awk '{print $1}')
11451 echo "verifying min purge: $(( $USER_REC2 + 1 )) == $FIRST_REC"
11452 [ $FIRST_REC == $(($USER_REC2 + 1)) ] ||
11453 error "first index should be $(($USER_REC2 + 1)) is $FIRST_REC"
11457 run_test 160g "changelog garbage collect (old users)"
11460 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11461 test_mkdir -p -c1 $DIR/$tdir
11462 cp /etc/hosts $DIR/$tdir/$tfile
11463 test_mkdir -c1 $DIR/$tdir/foo1
11464 test_mkdir -c1 $DIR/$tdir/foo2
11465 ln $DIR/$tdir/$tfile $DIR/$tdir/foo1/sofia
11466 ln $DIR/$tdir/$tfile $DIR/$tdir/foo2/zachary
11467 ln $DIR/$tdir/$tfile $DIR/$tdir/foo1/luna
11468 ln $DIR/$tdir/$tfile $DIR/$tdir/foo2/thor
11469 local FID=$($LFS path2fid $DIR/$tdir/$tfile | tr -d '[]')
11470 if [ "$($LFS fid2path $DIR $FID | wc -l)" != "5" ]; then
11471 $LFS fid2path $DIR $FID
11472 err17935 "bad link ea"
11475 rm $DIR/$tdir/foo2/zachary
11477 rm $DIR/$tdir/foo2/thor
11479 rm $DIR/$tdir/$tfile
11481 mv $DIR/$tdir/foo1/sofia $DIR/$tdir/foo2/maggie
11482 if [ "$($LFS fid2path $FSNAME --link 1 $FID)" != "$tdir/foo2/maggie" ]
11484 $LFS fid2path $DIR $FID
11485 err17935 "bad link rename"
11487 rm $DIR/$tdir/foo2/maggie
11490 local longname=filename_avg_len_is_thirty_two_
11491 createmany -l$DIR/$tdir/foo1/luna $DIR/$tdir/foo2/$longname 1000 ||
11492 error "failed to hardlink many files"
11493 links=$($LFS fid2path $DIR $FID | wc -l)
11494 echo -n "${links}/1000 links in link EA"
11495 [[ $links -gt 60 ]] ||
11496 err17935 "expected at least 60 links in link EA"
11497 unlinkmany $DIR/$tdir/foo2/$longname 1000 ||
11498 error "failed to unlink many hardlinks"
11500 run_test 161a "link ea sanity"
11503 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11504 [ $MDSCOUNT -lt 2 ] && skip "skipping remote directory test" && return
11506 local remote_dir=$DIR/$tdir/remote_dir
11508 mkdir -p $DIR/$tdir
11509 $LFS mkdir -i $MDTIDX $remote_dir ||
11510 error "create remote directory failed"
11512 cp /etc/hosts $remote_dir/$tfile
11513 mkdir -p $remote_dir/foo1
11514 mkdir -p $remote_dir/foo2
11515 ln $remote_dir/$tfile $remote_dir/foo1/sofia
11516 ln $remote_dir/$tfile $remote_dir/foo2/zachary
11517 ln $remote_dir/$tfile $remote_dir/foo1/luna
11518 ln $remote_dir/$tfile $remote_dir/foo2/thor
11520 local FID=$($LFS path2fid $remote_dir/$tfile | tr -d '[' |
11522 if [ "$($LFS fid2path $DIR $FID | wc -l)" != "5" ]; then
11523 $LFS fid2path $DIR $FID
11524 err17935 "bad link ea"
11527 rm $remote_dir/foo2/zachary
11529 rm $remote_dir/foo2/thor
11531 rm $remote_dir/$tfile
11533 mv $remote_dir/foo1/sofia $remote_dir/foo2/maggie
11534 local link_path=$($LFS fid2path $FSNAME --link 1 $FID)
11535 if [ "$DIR/$link_path" != "$remote_dir/foo2/maggie" ]; then
11536 $LFS fid2path $DIR $FID
11537 err17935 "bad link rename"
11539 rm $remote_dir/foo2/maggie
11542 local longname=filename_avg_len_is_thirty_two_
11543 createmany -l$remote_dir/foo1/luna $remote_dir/foo2/$longname 1000 ||
11544 error "failed to hardlink many files"
11545 links=$($LFS fid2path $DIR $FID | wc -l)
11546 echo -n "${links}/1000 links in link EA"
11547 [[ ${links} -gt 60 ]] ||
11548 err17935 "expected at least 60 links in link EA"
11549 unlinkmany $remote_dir/foo2/$longname 1000 ||
11550 error "failed to unlink many hardlinks"
11552 run_test 161b "link ea sanity under remote directory"
11555 remote_mds_nodsh && skip "remote MDS with nodsh" && return
11556 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11557 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.1.5) ]] &&
11558 skip "Need MDS version at least 2.1.5" && return
11560 # define CLF_RENAME_LAST 0x0001
11561 # rename overwrite a target having nlink = 1 (changelog flag 0x1)
11562 CL_USER=$(do_facet $SINGLEMDS $LCTL --device $MDT0 \
11563 changelog_register -n)
11565 trap cleanup_changelog EXIT
11567 mkdir -p $DIR/$tdir
11568 touch $DIR/$tdir/foo_161c
11569 touch $DIR/$tdir/bar_161c
11570 mv -f $DIR/$tdir/foo_161c $DIR/$tdir/bar_161c
11571 $LFS changelog $MDT0 | grep RENME
11572 local flags=$($LFS changelog $MDT0 | grep RENME | tail -1 | \
11574 $LFS changelog_clear $MDT0 $CL_USER 0
11575 if [ x$flags != "x0x1" ]; then
11576 error "flag $flags is not 0x1"
11578 echo "rename overwrite a target having nlink = 1," \
11579 "changelog record has flags of $flags"
11581 # rename overwrite a target having nlink > 1 (changelog flag 0x0)
11582 touch $DIR/$tdir/foo_161c
11583 touch $DIR/$tdir/bar_161c
11584 ln $DIR/$tdir/bar_161c $DIR/$tdir/foobar_161c
11585 mv -f $DIR/$tdir/foo_161c $DIR/$tdir/bar_161c
11586 $LFS changelog $MDT0 | grep RENME
11587 flags=$($LFS changelog $MDT0 | grep RENME | tail -1 | cut -f5 -d' ')
11588 $LFS changelog_clear $MDT0 $CL_USER 0
11589 if [ x$flags != "x0x0" ]; then
11590 error "flag $flags is not 0x0"
11592 echo "rename overwrite a target having nlink > 1," \
11593 "changelog record has flags of $flags"
11595 # rename doesn't overwrite a target (changelog flag 0x0)
11596 touch $DIR/$tdir/foo_161c
11597 mv -f $DIR/$tdir/foo_161c $DIR/$tdir/foo2_161c
11598 $LFS changelog $MDT0 | grep RENME
11599 flags=$($LFS changelog $MDT0 | grep RENME | tail -1 | cut -f5 -d' ')
11600 $LFS changelog_clear $MDT0 $CL_USER 0
11601 if [ x$flags != "x0x0" ]; then
11602 error "flag $flags is not 0x0"
11604 echo "rename doesn't overwrite a target," \
11605 "changelog record has flags of $flags"
11607 # define CLF_UNLINK_LAST 0x0001
11608 # unlink a file having nlink = 1 (changelog flag 0x1)
11609 rm -f $DIR/$tdir/foo2_161c
11610 $LFS changelog $MDT0 | grep UNLNK
11611 flags=$($LFS changelog $MDT0 | grep UNLNK | tail -1 | cut -f5 -d' ')
11612 $LFS changelog_clear $MDT0 $CL_USER 0
11613 if [ x$flags != "x0x1" ]; then
11614 error "flag $flags is not 0x1"
11616 echo "unlink a file having nlink = 1," \
11617 "changelog record has flags of $flags"
11619 # unlink a file having nlink > 1 (changelog flag 0x0)
11620 ln -f $DIR/$tdir/bar_161c $DIR/$tdir/foobar_161c
11621 rm -f $DIR/$tdir/foobar_161c
11622 $LFS changelog $MDT0 | grep UNLNK
11623 flags=$($LFS changelog $MDT0 | grep UNLNK | tail -1 | cut -f5 -d' ')
11624 $LFS changelog_clear $MDT0 $CL_USER 0
11625 if [ x$flags != "x0x0" ]; then
11626 error "flag $flags is not 0x0"
11628 echo "unlink a file having nlink > 1," \
11629 "changelog record has flags of $flags"
11632 run_test 161c "check CL_RENME[UNLINK] changelog record flags"
11639 # cleanup previous run
11640 rm -rf $DIR/$tdir/$tfile
11642 user=$(do_facet $SINGLEMDS $LCTL --device $MDT0 \
11643 changelog_register -n)
11644 [[ $? -eq 0 ]] || error "changelog_register failed"
11646 # work in a standalone dir to avoid locking on $DIR/$MOUNT to
11647 # interfer with $MOUNT/.lustre/fid/ access
11649 [[ $? -eq 0 ]] || error "mkdir failed"
11651 #define OBD_FAIL_LLITE_CREATE_NODE_PAUSE 0x140c | OBD_FAIL_ONCE
11652 $LCTL set_param fail_loc=0x8000140c
11654 $LCTL set_param fail_val=5
11657 echo foofoo > $DIR/$tdir/$tfile &
11660 # wait for create to be delayed
11664 [[ $? -eq 0 ]] || error "create should be blocked"
11666 local tempfile=$(mktemp)
11667 fid=$(changelog_extract_field $MDT0 "CREAT" "$tfile" "t=")
11668 cat $MOUNT/.lustre/fid/$fid 2>/dev/null >$tempfile || error "cat failed"
11669 # some delay may occur during ChangeLog publishing and file read just
11670 # above, that could allow file write to happen finally
11671 [[ -s $tempfile ]] && echo "file should be empty"
11673 $LCTL set_param fail_loc=0
11676 [[ $? -eq 0 ]] || error "create failed"
11678 $LFS changelog_clear $MDT0 $user 0
11679 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister $user
11681 run_test 161d "create with concurrent .lustre/fid access"
11688 local path=$(${LFS} fid2path $*)
11689 # Remove the '//' indicating a remote directory
11690 path=$(echo $path | sed 's#//#/#g')
11693 if [ $RC -ne 0 ]; then
11694 err17935 "path looked up of $expected failed. Error $RC"
11696 elif [ "${path}" != "${expected}" ]; then
11697 err17935 "path looked up \"${path}\" instead of \"${expected}\""
11700 echo "fid $fid resolves to path $path (expected $expected)"
11703 test_162a() { # was test_162
11704 # Make changes to filesystem
11705 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11706 test_mkdir -p -c1 $DIR/$tdir/d2
11707 touch $DIR/$tdir/d2/$tfile
11708 touch $DIR/$tdir/d2/x1
11709 touch $DIR/$tdir/d2/x2
11710 test_mkdir -p -c1 $DIR/$tdir/d2/a/b/c
11711 test_mkdir -p -c1 $DIR/$tdir/d2/p/q/r
11713 FID=$($LFS path2fid $DIR/$tdir/d2/$tfile | tr -d '[]')
11714 check_path "$tdir/d2/$tfile" $FSNAME $FID --link 0 ||
11715 error "check path $tdir/d2/$tfile failed"
11718 ln -s $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/p/q/r/slink
11719 FID=$($LFS path2fid $DIR/$tdir/d2/p/q/r/slink | tr -d '[]')
11720 check_path "$tdir/d2/p/q/r/slink" $FSNAME $FID --link 0 ||
11721 error "check path $tdir/d2/p/q/r/slink failed"
11723 # softlink to wrong file
11724 ln -s /this/is/garbage $DIR/$tdir/d2/p/q/r/slink.wrong
11725 FID=$($LFS path2fid $DIR/$tdir/d2/p/q/r/slink.wrong | tr -d '[]')
11726 check_path "$tdir/d2/p/q/r/slink.wrong" $FSNAME $FID --link 0 ||
11727 error "check path $tdir/d2/p/q/r/slink.wrong failed"
11730 ln $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/p/q/r/hlink
11731 mv $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/a/b/c/new_file
11732 FID=$($LFS path2fid $DIR/$tdir/d2/a/b/c/new_file | tr -d '[]')
11733 # fid2path dir/fsname should both work
11734 check_path "$tdir/d2/a/b/c/new_file" $FSNAME $FID --link 1 ||
11735 error "check path $tdir/d2/a/b/c/new_file failed"
11736 check_path "$DIR/$tdir/d2/p/q/r/hlink" $DIR $FID --link 0 ||
11737 error "check path $DIR/$tdir/d2/p/q/r/hlink failed"
11739 # hardlink count: check that there are 2 links
11740 # Doesnt work with CMD yet: 17935
11741 ${LFS} fid2path $DIR $FID | wc -l | grep -q 2 || \
11742 err17935 "expected 2 links"
11744 # hardlink indexing: remove the first link
11745 rm $DIR/$tdir/d2/p/q/r/hlink
11746 check_path "$tdir/d2/a/b/c/new_file" $FSNAME $FID --link 0 ||
11747 error "check path $DIR/$tdir/d2/a/b/c/new_file failed"
11751 run_test 162a "path lookup sanity"
11754 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11755 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
11758 $LFS setdirstripe -i0 -c$MDSCOUNT -t all_char $DIR/$tdir/striped_dir ||
11759 error "create striped dir failed"
11761 local FID=$($LFS getdirstripe $DIR/$tdir/striped_dir |
11762 tail -n 1 | awk '{print $2}')
11763 stat $MOUNT/.lustre/fid/$FID && error "sub_stripe can be accessed"
11765 touch $DIR/$tdir/striped_dir/f{0..4} || error "touch f0..4 failed"
11766 mkdir $DIR/$tdir/striped_dir/d{0..4} || error "mkdir d0..4 failed"
11769 for ((i=0;i<5;i++)); do
11770 FID=$($LFS path2fid $DIR/$tdir/striped_dir/f$i | tr -d '[]') ||
11771 error "get fid for f$i failed"
11772 check_path "$tdir/striped_dir/f$i" $FSNAME $FID --link 0 ||
11773 error "check path $tdir/striped_dir/f$i failed"
11775 FID=$($LFS path2fid $DIR/$tdir/striped_dir/d$i | tr -d '[]') ||
11776 error "get fid for d$i failed"
11777 check_path "$tdir/striped_dir/d$i" $FSNAME $FID --link 0 ||
11778 error "check path $tdir/striped_dir/d$i failed"
11783 run_test 162b "striped directory path lookup sanity"
11785 # LU-4239: Verify fid2path works with paths 100 or more directories deep
11787 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.51) ]] &&
11788 skip "Need MDS version at least 2.7.51" && return
11789 test_mkdir $DIR/$tdir.local
11790 test_mkdir $DIR/$tdir.remote
11791 local lpath=$tdir.local
11792 local rpath=$tdir.remote
11794 for ((i = 0; i <= 101; i++)); do
11797 FID=$($LFS path2fid $DIR/$lpath | tr -d '[]') ||
11798 error "get fid for local directory $DIR/$lpath failed"
11799 check_path "$DIR/$lpath" $MOUNT $FID --link 0 ||
11800 error "check path for local directory $DIR/$lpath failed"
11803 test_mkdir $DIR/$rpath
11804 FID=$($LFS path2fid $DIR/$rpath | tr -d '[]') ||
11805 error "get fid for remote directory $DIR/$rpath failed"
11806 check_path "$DIR/$rpath" $MOUNT $FID --link 0 ||
11807 error "check path for remote directory $DIR/$rpath failed"
11812 run_test 162c "fid2path works with paths 100 or more directories deep"
11815 # do directio so as not to populate the page cache
11816 log "creating a 10 Mb file"
11817 $MULTIOP $DIR/$tfile oO_CREAT:O_DIRECT:O_RDWR:w$((10*1048576))c || error "multiop failed while creating a file"
11818 log "starting reads"
11819 dd if=$DIR/$tfile of=/dev/null bs=4096 &
11820 log "truncating the file"
11821 $MULTIOP $DIR/$tfile oO_TRUNC:c || error "multiop failed while truncating the file"
11823 kill %+ || true # reads might have finished
11824 echo "wait until dd is finished"
11826 log "removing the temporary file"
11827 rm -rf $DIR/$tfile || error "tmp file removal failed"
11829 run_test 169 "parallel read and truncate should not deadlock"
11832 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11833 $LCTL clear # bug 18514
11834 $LCTL debug_daemon start $TMP/${tfile}_log_good
11836 $LCTL debug_daemon stop
11837 sed -e "s/^...../a/g" $TMP/${tfile}_log_good > $TMP/${tfile}_log_bad ||
11838 error "sed failed to read log_good"
11840 $LCTL debug_daemon start $TMP/${tfile}_log_good
11842 $LCTL debug_daemon stop
11844 $LCTL df $TMP/${tfile}_log_bad > $TMP/${tfile}_log_bad.out 2>&1 ||
11845 error "lctl df log_bad failed"
11847 local bad_line=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $9}')
11848 local good_line1=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $5}')
11850 $LCTL df $TMP/${tfile}_log_good > $TMP/${tfile}_log_good.out 2>&1
11851 local good_line2=$(tail -n 1 $TMP/${tfile}_log_good.out | awk '{print $5}')
11853 [ "$bad_line" ] && [ "$good_line1" ] && [ "$good_line2" ] ||
11854 error "bad_line good_line1 good_line2 are empty"
11856 cat $TMP/${tfile}_log_good >> $TMP/${tfile}_logs_corrupt
11857 cat $TMP/${tfile}_log_bad >> $TMP/${tfile}_logs_corrupt
11858 cat $TMP/${tfile}_log_good >> $TMP/${tfile}_logs_corrupt
11860 $LCTL df $TMP/${tfile}_logs_corrupt > $TMP/${tfile}_log_bad.out 2>&1
11861 local bad_line_new=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $9}')
11862 local good_line_new=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $5}')
11864 [ "$bad_line_new" ] && [ "$good_line_new" ] ||
11865 error "bad_line_new good_line_new are empty"
11867 local expected_good=$((good_line1 + good_line2*2))
11869 rm -f $TMP/${tfile}*
11870 # LU-231, short malformed line may not be counted into bad lines
11871 if [ $bad_line -ne $bad_line_new ] &&
11872 [ $bad_line -ne $((bad_line_new - 1)) ]; then
11873 error "expected $bad_line bad lines, but got $bad_line_new"
11877 if [ $expected_good -ne $good_line_new ]; then
11878 error "expected $expected_good good lines, but got $good_line_new"
11883 run_test 170 "test lctl df to handle corrupted log ====================="
11885 test_171() { # bug20592
11886 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11887 #define OBD_FAIL_PTLRPC_DUMP_LOG 0x50e
11888 $LCTL set_param fail_loc=0x50e
11889 $LCTL set_param fail_val=3000
11890 multiop_bg_pause $DIR/$tfile O_s || true
11892 kill -USR1 $MULTIPID
11896 if dmesg | grep "recursive fault"; then
11897 error "caught a recursive fault"
11899 $LCTL set_param fail_loc=0
11902 run_test 171 "test libcfs_debug_dumplog_thread stuck in do_exit() ======"
11904 # it would be good to share it with obdfilter-survey/iokit-libecho code
11905 setup_obdecho_osc () {
11908 local obdfilter_name=$2
11909 echo "Creating new osc for $obdfilter_name on $ost_nid"
11910 # make sure we can find loopback nid
11911 $LCTL add_uuid $ost_nid $ost_nid >/dev/null 2>&1
11913 [ $rc -eq 0 ] && { $LCTL attach osc ${obdfilter_name}_osc \
11914 ${obdfilter_name}_osc_UUID || rc=2; }
11915 [ $rc -eq 0 ] && { $LCTL --device ${obdfilter_name}_osc setup \
11916 ${obdfilter_name}_UUID $ost_nid || rc=3; }
11920 cleanup_obdecho_osc () {
11921 local obdfilter_name=$1
11922 $LCTL --device ${obdfilter_name}_osc cleanup >/dev/null
11923 $LCTL --device ${obdfilter_name}_osc detach >/dev/null
11930 local pages=${3:-64}
11935 local obd_size=$(get_obd_size $node $OBD)
11936 local page_size=$(get_page_size $node)
11937 if [[ -n "$obd_size" ]]; then
11938 local new_count=$((obd_size / (pages * page_size / 1024)))
11939 [[ $new_count -ge $count ]] || count=$new_count
11942 do_facet $node "$LCTL attach echo_client ec ec_uuid" || rc=1
11943 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec setup $OBD" ||
11945 if [ $rc -eq 0 ]; then
11946 id=$(do_facet $node "$LCTL --device ec create 1" | awk '/object id/ {print $6}')
11947 [ ${PIPESTATUS[0]} -eq 0 -a -n "$id" ] || rc=3
11949 echo "New object id is $id"
11950 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec getattr $id" ||
11952 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec " \
11953 "test_brw $count w v $pages $id" || rc=4; }
11954 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec destroy $id 1" ||
11956 [ $rc -eq 0 -o $rc -gt 2 ] && { do_facet $node "$LCTL --device ec " \
11957 "cleanup" || rc=5; }
11958 [ $rc -eq 0 -o $rc -gt 1 ] && { do_facet $node "$LCTL --device ec " \
11959 "detach" || rc=6; }
11960 [ $rc -ne 0 ] && echo "obecho_create_test failed: $rc"
11965 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11966 remote_ost_nodsh && skip "remote OST with nodsh" && return
11968 local rmmod_local=0
11970 if ! module_loaded obdecho; then
11971 load_module obdecho/obdecho
11975 local osc=$($LCTL dl | grep -v mdt | awk '$3 == "osc" {print $4; exit}')
11976 local host=$(lctl get_param -n osc.$osc.import |
11977 awk '/current_connection:/ {print $2}' )
11978 local target=$(lctl get_param -n osc.$osc.import |
11979 awk '/target:/ {print $2}' )
11980 target=${target%_UUID}
11982 [[ -n $target ]] && { setup_obdecho_osc $host $target || rc=1; } || rc=1
11983 [ $rc -eq 0 ] && { obdecho_test ${target}_osc client || rc=2; }
11984 [[ -n $target ]] && cleanup_obdecho_osc $target
11985 [ $rmmod_local -eq 1 ] && rmmod obdecho
11988 run_test 180a "test obdecho on osc"
11991 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11992 remote_ost_nodsh && skip "remote OST with nodsh" && return
11994 local rmmod_remote=0
11996 do_rpc_nodes $(facet_active_host ost1) load_module obdecho/obdecho &&
11997 rmmod_remote=true || error "failed to load module obdecho"
11998 target=$(do_facet ost1 $LCTL dl | awk '/obdfilter/ {print $4;exit}')
11999 [[ -n $target ]] && { obdecho_test $target ost1 || rc=1; }
12000 $rmmod_remote && do_facet ost1 "rmmod obdecho"
12003 run_test 180b "test obdecho directly on obdfilter"
12005 test_180c() { # LU-2598
12006 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12007 remote_ost_nodsh && skip "remote OST with nodsh" && return
12008 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.0) ]] &&
12009 skip "Need MDS version at least 2.4.0" && return
12012 local rmmod_remote=false
12013 local pages=16384 # 64MB bulk I/O RPC size
12016 do_rpc_nodes $(facet_active_host ost1) load_module obdecho/obdecho &&
12017 rmmod_remote=true || error "failed to load module obdecho"
12019 target=$(do_facet ost1 $LCTL dl | awk '/obdfilter/ { print $4 }' |
12021 if [ -n "$target" ]; then
12022 obdecho_test "$target" ost1 "$pages" || rc=${PIPESTATUS[0]}
12024 echo "there is no obdfilter target on ost1"
12027 $rmmod_remote && do_facet ost1 "rmmod obdecho" || true
12030 run_test 180c "test huge bulk I/O size on obdfilter, don't LASSERT"
12032 test_181() { # bug 22177
12033 test_mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
12034 # create enough files to index the directory
12035 createmany -o $DIR/$tdir/foobar 4000
12036 # print attributes for debug purpose
12039 multiop_bg_pause $DIR/$tdir D_Sc || return 1
12041 # remove the files & current working dir
12042 unlinkmany $DIR/$tdir/foobar 4000
12044 kill -USR1 $MULTIPID
12046 stat $DIR/$tdir && error "open-unlinked dir was not removed!"
12049 run_test 181 "Test open-unlinked dir ========================"
12055 mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
12057 $LCTL set_param mdc.*.rpc_stats=clear
12059 for (( i = 0; i < $tcount; i++ )) ; do
12060 mkdir $DIR/$tdir/$i
12063 for (( i = 0; i < $tcount; i++ )) ; do
12064 createmany -o $DIR/$tdir/$i/f- $fcount &
12068 for (( i = 0; i < $tcount; i++ )) ; do
12069 unlinkmany $DIR/$tdir/$i/f- $fcount &
12073 $LCTL get_param mdc.*.rpc_stats
12077 run_test 182 "Test parallel modify metadata operations ================"
12079 test_183() { # LU-2275
12080 remote_mds_nodsh && skip "remote MDS with nodsh" && return
12081 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.3.56) ]] &&
12082 skip "Need MDS version at least 2.3.56" && return
12084 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12085 mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
12086 echo aaa > $DIR/$tdir/$tfile
12088 #define OBD_FAIL_MDS_NEGATIVE_POSITIVE 0x148
12089 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x148
12091 ls -l $DIR/$tdir && error "ls succeeded, should have failed"
12092 cat $DIR/$tdir/$tfile && error "cat succeeded, should have failed"
12094 do_facet $SINGLEMDS $LCTL set_param fail_loc=0
12096 # Flush negative dentry cache
12097 touch $DIR/$tdir/$tfile
12099 # We are not checking for any leaked references here, they'll
12100 # become evident next time we do cleanup with module unload.
12103 run_test 183 "No crash or request leak in case of strange dispositions ========"
12105 # test suite 184 is for LU-2016, LU-2017
12107 check_swap_layouts_support && return 0
12109 dir0=$DIR/$tdir/$testnum
12110 test_mkdir -p -c1 $dir0 || error "creating dir $dir0"
12115 $SETSTRIPE -c1 $file1
12117 $SETSTRIPE -c2 $file2
12119 gen1=$($GETSTRIPE -g $file1)
12120 gen2=$($GETSTRIPE -g $file2)
12122 $LFS swap_layouts $file1 $file2 || error "swap of file layout failed"
12123 gen=$($GETSTRIPE -g $file1)
12124 [[ $gen1 != $gen ]] ||
12125 "Layout generation on $file1 does not change"
12126 gen=$($GETSTRIPE -g $file2)
12127 [[ $gen2 != $gen ]] ||
12128 "Layout generation on $file2 does not change"
12130 cmp $ref1 $file2 || error "content compare failed ($ref1 != $file2)"
12131 cmp $ref2 $file1 || error "content compare failed ($ref2 != $file1)"
12133 run_test 184a "Basic layout swap"
12136 check_swap_layouts_support && return 0
12138 dir0=$DIR/$tdir/$testnum
12139 mkdir -p $dir0 || error "creating dir $dir0"
12146 $SETSTRIPE -c1 $file1
12147 $SETSTRIPE -c2 $file2
12148 $SETSTRIPE -c1 $file3
12149 chown $RUNAS_ID $file3
12150 gen1=$($GETSTRIPE -g $file1)
12151 gen2=$($GETSTRIPE -g $file2)
12153 $LFS swap_layouts $dir1 $dir2 &&
12154 error "swap of directories layouts should fail"
12155 $LFS swap_layouts $dir1 $file1 &&
12156 error "swap of directory and file layouts should fail"
12157 $RUNAS $LFS swap_layouts $file1 $file2 &&
12158 error "swap of file we cannot write should fail"
12159 $LFS swap_layouts $file1 $file3 &&
12160 error "swap of file with different owner should fail"
12161 /bin/true # to clear error code
12163 run_test 184b "Forbidden layout swap (will generate errors)"
12166 local cmpn_arg=$(cmp -n 2>&1 | grep "invalid option")
12167 [ -n "$cmpn_arg" ] && skip_env "cmp does not support -n" && return
12168 check_swap_layouts_support && return 0
12170 local dir0=$DIR/$tdir/$testnum
12171 mkdir -p $dir0 || error "creating dir $dir0"
12173 local ref1=$dir0/ref1
12174 local ref2=$dir0/ref2
12175 local file1=$dir0/file1
12176 local file2=$dir0/file2
12177 # create a file large enough for the concurrent test
12178 dd if=/dev/urandom of=$ref1 bs=1M count=$((RANDOM % 50 + 20))
12179 dd if=/dev/urandom of=$ref2 bs=1M count=$((RANDOM % 50 + 20))
12180 echo "ref file size: ref1($(stat -c %s $ref1))," \
12181 "ref2($(stat -c %s $ref2))"
12184 dd if=$ref1 of=$file1 bs=16k &
12187 # Make sure dd starts to copy file
12188 while [ ! -f $file1 ]; do sleep 0.1; done
12190 $LFS swap_layouts $file1 $file2
12193 [[ $? == 0 ]] || error "concurrent write on $file1 failed"
12194 [[ $rc == 0 ]] || error "swap of $file1 and $file2 failed"
12196 # how many bytes copied before swapping layout
12197 local copied=$(stat -c %s $file2)
12198 local remaining=$(stat -c %s $ref1)
12199 remaining=$((remaining - copied))
12200 echo "Copied $copied bytes before swapping layout..."
12202 cmp -n $copied $file1 $ref2 | grep differ &&
12203 error "Content mismatch [0, $copied) of ref2 and file1"
12204 cmp -n $copied $file2 $ref1 ||
12205 error "Content mismatch [0, $copied) of ref1 and file2"
12206 cmp -i $copied:$copied -n $remaining $file1 $ref1 ||
12207 error "Content mismatch [$copied, EOF) of ref1 and file1"
12210 rm -f $ref1 $ref2 $file1 $file2
12212 run_test 184c "Concurrent write and layout swap"
12215 check_swap_layouts_support && return 0
12216 [ -z "$(which getfattr 2>/dev/null)" ] &&
12217 skip "no getfattr command" && return 0
12219 local file1=$DIR/$tdir/$tfile-1
12220 local file2=$DIR/$tdir/$tfile-2
12221 local file3=$DIR/$tdir/$tfile-3
12225 mkdir -p $DIR/$tdir
12226 touch $file1 || error "create $file1 failed"
12227 $OPENFILE -f O_CREAT:O_LOV_DELAY_CREATE $file2 ||
12228 error "create $file2 failed"
12229 $OPENFILE -f O_CREAT:O_LOV_DELAY_CREATE $file3 ||
12230 error "create $file3 failed"
12231 lovea1=$(get_layout_param $file1)
12233 $LFS swap_layouts $file2 $file3 ||
12234 error "swap $file2 $file3 layouts failed"
12235 $LFS swap_layouts $file1 $file2 ||
12236 error "swap $file1 $file2 layouts failed"
12238 lovea2=$(get_layout_param $file2)
12241 [ "$lovea1" == "$lovea2" ] || error "lovea $lovea1 != $lovea2"
12243 lovea1=$(getfattr -n trusted.lov $file1 | grep ^trusted)
12244 [[ -z "$lovea1" ]] || error "$file1 shouldn't have lovea"
12246 run_test 184d "allow stripeless layouts swap"
12249 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.6.94) ]] ||
12250 { skip "Need MDS version at least 2.6.94"; return 0; }
12251 check_swap_layouts_support && return 0
12252 [ -z "$(which getfattr 2>/dev/null)" ] &&
12253 skip "no getfattr command" && return 0
12255 local file1=$DIR/$tdir/$tfile-1
12256 local file2=$DIR/$tdir/$tfile-2
12257 local file3=$DIR/$tdir/$tfile-3
12260 mkdir -p $DIR/$tdir
12261 touch $file1 || error "create $file1 failed"
12262 $OPENFILE -f O_CREAT:O_LOV_DELAY_CREATE $file2 ||
12263 error "create $file2 failed"
12264 $OPENFILE -f O_CREAT:O_LOV_DELAY_CREATE $file3 ||
12265 error "create $file3 failed"
12267 $LFS swap_layouts $file1 $file2 ||
12268 error "swap $file1 $file2 layouts failed"
12270 lovea=$(getfattr -n trusted.lov $file1 | grep ^trusted)
12271 [[ -z "$lovea" ]] || error "$file1 shouldn't have lovea"
12273 echo 123 > $file1 || error "Should be able to write into $file1"
12275 $LFS swap_layouts $file1 $file3 ||
12276 error "swap $file1 $file3 layouts failed"
12278 echo 123 > $file1 || error "Should be able to write into $file1"
12280 rm -rf $file1 $file2 $file3
12282 run_test 184e "Recreate layout after stripeless layout swaps"
12284 test_185() { # LU-2441
12285 # LU-3553 - no volatile file support in old servers
12286 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.3.60) ]] ||
12287 { skip "Need MDS version at least 2.3.60"; return 0; }
12289 mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
12290 touch $DIR/$tdir/spoo
12291 local mtime1=$(stat -c "%Y" $DIR/$tdir)
12292 local fid=$($MULTIOP $DIR/$tdir VFw4096c) ||
12293 error "cannot create/write a volatile file"
12294 [ "$FILESET" == "" ] &&
12295 $CHECKSTAT -t file $MOUNT/.lustre/fid/$fid 2>/dev/null &&
12296 error "FID is still valid after close"
12298 multiop_bg_pause $DIR/$tdir vVw4096_c
12305 # assume that the next FID for this client is sequential, since stdout
12306 # is unfortunately eaten by multiop_bg_pause
12307 local n=$((${fidv[1]} + 1))
12308 local next_fid="${fidv[0]}:$(printf "0x%x" $n):${fidv[2]}"
12309 if [ "$FILESET" == "" ]; then
12310 $CHECKSTAT -t file $MOUNT/.lustre/fid/$next_fid ||
12311 error "FID is missing before close"
12313 kill -USR1 $multi_pid
12314 # 1 second delay, so if mtime change we will see it
12316 local mtime2=$(stat -c "%Y" $DIR/$tdir)
12317 [[ $mtime1 == $mtime2 ]] || error "mtime has changed"
12319 run_test 185 "Volatile file support"
12322 remote_mds_nodsh && skip "remote MDS with nodsh" && return
12323 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.3.0) ] &&
12324 skip "Need MDS version at least 2.3.0" && return
12326 local dir0=$DIR/$tdir/$testnum
12327 mkdir -p $dir0 || error "creating dir $dir0"
12329 local file=$dir0/file1
12330 dd if=/dev/urandom of=$file count=10 bs=1M conv=fsync
12331 local dv1=$($LFS data_version $file)
12332 dd if=/dev/urandom of=$file seek=10 count=1 bs=1M conv=fsync
12333 local dv2=$($LFS data_version $file)
12334 [[ $dv1 != $dv2 ]] ||
12335 error "data version did not change on write $dv1 == $dv2"
12340 run_test 187a "Test data version change"
12343 remote_mds_nodsh && skip "remote MDS with nodsh" && return
12344 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.3.0) ] &&
12345 skip "Need MDS version at least 2.3.0" && return
12347 local dir0=$DIR/$tdir/$testnum
12348 mkdir -p $dir0 || error "creating dir $dir0"
12350 declare -a DV=$($MULTIOP $dir0 Vw1000xYw1000xY | cut -f3 -d" ")
12351 [[ ${DV[0]} != ${DV[1]} ]] ||
12352 error "data version did not change on write"\
12353 " ${DV[0]} == ${DV[1]}"
12358 run_test 187b "Test data version change on volatile file"
12361 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12362 remote_mgs_nodsh && skip "remote MGS with nodsh" && return
12363 [ -n "$FILESET" ] && skip "SKIP due to FILESET set" && return
12365 local POOL=${POOL:-cea1}
12366 local POOL_ROOT=${POOL_ROOT:-$DIR/d200.pools}
12367 local POOL_DIR_NAME=${POOL_DIR_NAME:-dir_tst}
12370 local last_ost=$(($OSTCOUNT - 1))
12372 local ost_list=$(seq $first_ost $ost_step $last_ost)
12373 local ost_range="$first_ost $last_ost $ost_step"
12374 local test_path=$POOL_ROOT/$POOL_DIR_NAME
12375 local file_dir=$POOL_ROOT/file_tst
12376 local subdir=$test_path/subdir
12380 # former test_200a test_200b
12381 pool_add $POOL || { rc=$? ; break; }
12382 pool_add_targets $POOL $ost_range || { rc=$? ; break; }
12383 # former test_200c test_200d
12384 mkdir -p $test_path
12385 pool_set_dir $POOL $test_path || { rc=$? ; break; }
12386 pool_check_dir $POOL $test_path || { rc=$? ; break; }
12388 pool_check_dir $POOL $subdir || { rc=$? ; break; }
12389 pool_dir_rel_path $POOL $POOL_DIR_NAME $POOL_ROOT \
12390 || { rc=$? ; break; }
12391 # former test_200e test_200f
12392 local files=$((OSTCOUNT*3))
12393 pool_alloc_files $POOL $test_path $files "$ost_list" \
12394 || { rc=$? ; break; }
12395 pool_create_files $POOL $file_dir $files "$ost_list" \
12396 || { rc=$? ; break; }
12397 # former test_200g test_200h
12398 pool_lfs_df $POOL || { rc=$? ; break; }
12399 pool_file_rel_path $POOL $test_path || { rc=$? ; break; }
12401 # former test_201a test_201b test_201c
12402 pool_remove_first_target $POOL || { rc=$? ; break; }
12404 local f=$test_path/$tfile
12405 pool_remove_all_targets $POOL $f || { rc=$? ; break; }
12406 pool_remove $POOL $f || { rc=$? ; break; }
12413 run_test 200 "OST pools"
12415 # usage: default_attr <count | size | offset>
12417 $LCTL get_param -n lov.$FSNAME-clilov-\*.stripe${1}
12420 # usage: check_default_stripe_attr
12421 check_default_stripe_attr() {
12422 ACTUAL=$($GETSTRIPE $* $DIR/$tdir)
12425 [ -n "$2" ] && EXPECTED=0 || EXPECTED=$(default_attr count);;
12427 [ -n "$2" ] && EXPECTED=0 || EXPECTED=$(default_attr size);;
12431 error "unknown getstripe attr '$1'"
12434 [ $ACTUAL != $EXPECTED ] &&
12435 error "$DIR/$tdir has $1 '$ACTUAL', not '$EXPECTED'"
12439 test_mkdir -p $DIR/$tdir
12440 $SETSTRIPE --stripe-count 0 --stripe-size 0 --stripe-index -1 $DIR/$tdir
12442 check_default_stripe_attr --stripe-count
12443 check_default_stripe_attr --stripe-size
12444 check_default_stripe_attr --stripe-index
12448 run_test 204a "Print default stripe attributes ================="
12451 test_mkdir -p $DIR/$tdir
12452 $SETSTRIPE --stripe-count 1 $DIR/$tdir
12454 check_default_stripe_attr --stripe-size
12455 check_default_stripe_attr --stripe-index
12459 run_test 204b "Print default stripe size and offset ==========="
12462 test_mkdir -p $DIR/$tdir
12463 $SETSTRIPE --stripe-size 65536 $DIR/$tdir
12465 check_default_stripe_attr --stripe-count
12466 check_default_stripe_attr --stripe-index
12470 run_test 204c "Print default stripe count and offset ==========="
12473 test_mkdir -p $DIR/$tdir
12474 $SETSTRIPE --stripe-index 0 $DIR/$tdir
12476 check_default_stripe_attr --stripe-count
12477 check_default_stripe_attr --stripe-size
12481 run_test 204d "Print default stripe count and size ============="
12484 test_mkdir -p $DIR/$tdir
12485 $SETSTRIPE -d $DIR/$tdir
12487 check_default_stripe_attr --stripe-count --raw
12488 check_default_stripe_attr --stripe-size --raw
12489 check_default_stripe_attr --stripe-index --raw
12493 run_test 204e "Print raw stripe attributes ================="
12496 test_mkdir -p $DIR/$tdir
12497 $SETSTRIPE --stripe-count 1 $DIR/$tdir
12499 check_default_stripe_attr --stripe-size --raw
12500 check_default_stripe_attr --stripe-index --raw
12504 run_test 204f "Print raw stripe size and offset ==========="
12507 test_mkdir -p $DIR/$tdir
12508 $SETSTRIPE --stripe-size 65536 $DIR/$tdir
12510 check_default_stripe_attr --stripe-count --raw
12511 check_default_stripe_attr --stripe-index --raw
12515 run_test 204g "Print raw stripe count and offset ==========="
12518 test_mkdir -p $DIR/$tdir
12519 $SETSTRIPE --stripe-index 0 $DIR/$tdir
12521 check_default_stripe_attr --stripe-count --raw
12522 check_default_stripe_attr --stripe-size --raw
12526 run_test 204h "Print raw stripe count and size ============="
12528 # Figure out which job scheduler is being used, if any,
12529 # or use a fake one
12530 if [ -n "$SLURM_JOB_ID" ]; then # SLURM
12531 JOBENV=SLURM_JOB_ID
12532 elif [ -n "$LSB_JOBID" ]; then # Load Sharing Facility
12534 elif [ -n "$PBS_JOBID" ]; then # PBS/Maui/Moab
12536 elif [ -n "$LOADL_STEPID" ]; then # LoadLeveller
12537 JOBENV=LOADL_STEP_ID
12538 elif [ -n "$JOB_ID" ]; then # Sun Grid Engine
12541 $LCTL list_param jobid_name > /dev/null 2>&1
12542 if [ $? -eq 0 ]; then
12549 verify_jobstats() {
12554 # we don't really need to clear the stats for this test to work, since each
12555 # command has a unique jobid, but it makes debugging easier if needed.
12556 # for facet in $facets; do
12557 # local dev=$(convert_facet2label $facet)
12558 # # clear old jobstats
12559 # do_facet $facet lctl set_param *.$dev.job_stats="clear"
12562 # use a new JobID for each test, or we might see an old one
12563 [ "$JOBENV" = "FAKE_JOBID" ] &&
12564 FAKE_JOBID=id.$testnum.$(basename ${cmd[0]}).$RANDOM
12568 [ "$JOBENV" = "nodelocal" ] && {
12569 FAKE_JOBID=id.$testnum.$(basename ${cmd[0]}).$RANDOM
12570 $LCTL set_param jobid_name=$FAKE_JOBID
12574 log "Test: ${cmd[*]}"
12575 log "Using JobID environment variable $JOBENV=$JOBVAL"
12577 if [ $JOBENV = "FAKE_JOBID" ]; then
12578 FAKE_JOBID=$JOBVAL ${cmd[*]}
12583 # all files are created on OST0000
12584 for facet in $facets; do
12585 local stats="*.$(convert_facet2label $facet).job_stats"
12586 if [ $(do_facet $facet lctl get_param $stats |
12587 grep -c $JOBVAL) -ne 1 ]; then
12588 do_facet $facet lctl get_param $stats
12589 error "No jobstats for $JOBVAL found on $facet::$stats"
12596 NEW_JOBENV=${1:-$OLD_JOBENV}
12597 do_facet mgs $LCTL conf_param $FSNAME.sys.jobid_var=$NEW_JOBENV
12598 wait_update $HOSTNAME "$LCTL get_param -n jobid_var" $NEW_JOBENV
12603 do_facet $SINGLEMDS \
12604 $LCTL set_param mdt.*.job_cleanup_interval=$OLD_INTERVAL
12605 [ $OLD_JOBENV != $JOBENV ] && jobstats_set $OLD_JOBENV
12609 test_205() { # Job stats
12610 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.7.1) ]] ||
12611 { skip "Need MDS version with at least 2.7.1"; return 0; }
12613 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12614 remote_mgs_nodsh && skip "remote MGS with nodsh" && return
12615 remote_mds_nodsh && skip "remote MDS with nodsh" && return
12616 remote_ost_nodsh && skip "remote OST with nodsh" && return
12618 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep jobstats)" ] &&
12619 skip "Server doesn't support jobstats" && return 0
12620 [[ $JOBID_VAR = disable ]] && skip "jobstats is disabled" && return
12622 OLD_JOBENV=$($LCTL get_param -n jobid_var)
12623 if [ $OLD_JOBENV != $JOBENV ]; then
12624 jobstats_set $JOBENV
12625 trap cleanup_205 EXIT
12628 CL_USER=$(do_facet $SINGLEMDS lctl --device $MDT0 changelog_register -n)
12629 echo "Registered as changelog user $CL_USER"
12631 OLD_INTERVAL=$(do_facet $SINGLEMDS \
12632 lctl get_param -n mdt.*.job_cleanup_interval)
12633 local interval_new=5
12634 do_facet $SINGLEMDS \
12635 $LCTL set_param mdt.*.job_cleanup_interval=$interval_new
12636 local start=$SECONDS
12640 cmd="mkdir $DIR/$tdir"
12641 verify_jobstats "$cmd" "$SINGLEMDS"
12643 cmd="rmdir $DIR/$tdir"
12644 verify_jobstats "$cmd" "$SINGLEMDS"
12645 # mkdir on secondary MDT
12646 if [ $MDSCOUNT -gt 1 ]; then
12647 cmd="lfs mkdir -i 1 $DIR/$tdir.remote"
12648 verify_jobstats "$cmd" "mds2"
12651 cmd="mknod $DIR/$tfile c 1 3"
12652 verify_jobstats "$cmd" "$SINGLEMDS"
12654 cmd="rm -f $DIR/$tfile"
12655 verify_jobstats "$cmd" "$SINGLEMDS"
12656 # create all files on OST0000 so verify_jobstats can find OST stats
12658 cmd="$SETSTRIPE -i 0 -c 1 $DIR/$tfile"
12659 verify_jobstats "$cmd" "$SINGLEMDS"
12661 cmd="touch $DIR/$tfile"
12662 verify_jobstats "$cmd" "$SINGLEMDS ost1"
12664 cmd="dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 oflag=sync"
12665 verify_jobstats "$cmd" "ost1"
12667 cancel_lru_locks osc
12668 cmd="dd if=$DIR/$tfile of=/dev/null bs=1M count=1 iflag=direct"
12669 verify_jobstats "$cmd" "ost1"
12671 cmd="$TRUNCATE $DIR/$tfile 0"
12672 verify_jobstats "$cmd" "$SINGLEMDS ost1"
12674 cmd="mv -f $DIR/$tfile $DIR/$tdir.rename"
12675 verify_jobstats "$cmd" "$SINGLEMDS"
12676 # jobstats expiry - sleep until old stats should be expired
12677 local left=$((interval_new + 5 - (SECONDS - start)))
12678 [ $left -ge 0 ] && wait_update_facet $SINGLEMDS \
12679 "lctl get_param *.*.job_stats | grep -c 'job_id.*mkdir'" \
12681 cmd="mkdir $DIR/$tdir.expire"
12682 verify_jobstats "$cmd" "$SINGLEMDS"
12683 [ $(do_facet $SINGLEMDS lctl get_param *.*.job_stats |
12684 grep -c "job_id.*mkdir") -gt 1 ] && error "old jobstats not expired"
12686 # Ensure that jobid are present in changelog (if supported by MDS)
12687 if [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.6.52) ]
12689 $LFS changelog $MDT0 | tail -9
12690 jobids=$($LFS changelog $MDT0 | tail -9 | grep -c "j=")
12691 [ $jobids -eq 9 ] ||
12692 error "Wrong changelog jobid count $jobids != 9"
12696 jobstats_set $JOBENV
12698 $LFS changelog $MDT0 | tail -1
12699 jobids=$($LFS changelog $MDT0 | tail -1 | grep -c "j=")
12700 [ $jobids -eq 0 ] ||
12701 error "Unexpected jobids when jobid_var=$JOBENV"
12706 run_test 205 "Verify job stats"
12708 # LU-1480, LU-1773 and LU-1657
12710 mkdir -p $DIR/$tdir
12711 $SETSTRIPE -c -1 $DIR/$tdir
12712 #define OBD_FAIL_LOV_INIT 0x1403
12713 $LCTL set_param fail_loc=0xa0001403
12714 $LCTL set_param fail_val=1
12715 touch $DIR/$tdir/$tfile || true
12717 run_test 206 "fail lov_init_raid0() doesn't lbug"
12720 dd if=/dev/zero of=$DIR/$tfile bs=4k count=$((RANDOM%10+1))
12721 local fsz=`stat -c %s $DIR/$tfile`
12722 cancel_lru_locks mdc
12724 # do not return layout in getattr intent
12725 #define OBD_FAIL_MDS_NO_LL_GETATTR 0x170
12726 $LCTL set_param fail_loc=0x170
12727 local sz=`stat -c %s $DIR/$tfile`
12729 [ $fsz -eq $sz ] || error "file size expected $fsz, actual $sz"
12733 run_test 207a "can refresh layout at glimpse"
12736 dd if=/dev/zero of=$DIR/$tfile bs=4k count=$((RANDOM%10+1))
12737 local cksum=`md5sum $DIR/$tfile`
12738 local fsz=`stat -c %s $DIR/$tfile`
12739 cancel_lru_locks mdc
12740 cancel_lru_locks osc
12742 # do not return layout in getattr intent
12743 #define OBD_FAIL_MDS_NO_LL_OPEN 0x171
12744 $LCTL set_param fail_loc=0x171
12746 # it will refresh layout after the file is opened but before read issues
12747 echo checksum is "$cksum"
12748 echo "$cksum" |md5sum -c --quiet || error "file differs"
12752 run_test 207b "can refresh layout at open"
12755 # FIXME: in this test suite, only RD lease is used. This is okay
12756 # for now as only exclusive open is supported. After generic lease
12757 # is done, this test suite should be revised. - Jinshan
12759 remote_mds_nodsh && skip "remote MDS with nodsh" && return
12760 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.4.52) ]] ||
12761 { skip "Need MDS version at least 2.4.52"; return 0; }
12763 echo "==== test 1: verify get lease work"
12764 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:eRE+eU || error "get lease error"
12766 echo "==== test 2: verify lease can be broken by upcoming open"
12767 $MULTIOP $DIR/$tfile oO_RDONLY:eR_E-eUc &
12771 $MULTIOP $DIR/$tfile oO_RDONLY:c
12772 kill -USR1 $PID && wait $PID || error "break lease error"
12774 echo "==== test 3: verify lease can't be granted if an open already exists"
12775 $MULTIOP $DIR/$tfile oO_RDONLY:_c &
12779 $MULTIOP $DIR/$tfile oO_RDONLY:eReUc && error "apply lease should fail"
12780 kill -USR1 $PID && wait $PID || error "open file error"
12782 echo "==== test 4: lease can sustain over recovery"
12783 $MULTIOP $DIR/$tfile oO_RDONLY:eR_E+eUc &
12789 kill -USR1 $PID && wait $PID || error "lease broken over recovery"
12791 echo "==== test 5: lease broken can't be regained by replay"
12792 $MULTIOP $DIR/$tfile oO_RDONLY:eR_E-eUc &
12796 # open file to break lease and then recovery
12797 $MULTIOP $DIR/$tfile oO_RDWR:c || error "open file error"
12800 kill -USR1 $PID && wait $PID || error "lease not broken over recovery"
12804 run_test 208 "Exclusive open"
12807 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep disp_stripe)" ] &&
12808 skip_env "must have disp_stripe" && return
12811 sync; sleep 5; sync;
12813 echo 3 > /proc/sys/vm/drop_caches
12814 req_before=$(awk '/ptlrpc_cache / { print $2 }' /proc/slabinfo)
12816 # open/close 500 times
12817 for i in $(seq 500); do
12821 echo 3 > /proc/sys/vm/drop_caches
12822 req_after=$(awk '/ptlrpc_cache / { print $2 }' /proc/slabinfo)
12824 echo "before: $req_before, after: $req_after"
12825 [ $((req_after - req_before)) -ge 300 ] &&
12826 error "open/close requests are not freed"
12829 run_test 209 "read-only open/close requests should be freed promptly"
12833 size=$((size % 8192 + 1))
12834 dd if=/dev/urandom of=$DIR/f212 bs=1k count=$size
12835 sendfile $DIR/f212 $DIR/f212.xyz || error "sendfile wrong"
12836 rm -f $DIR/f212 $DIR/f212.xyz
12838 run_test 212 "Sendfile test ============================================"
12841 dd if=/dev/zero of=$DIR/$tfile bs=4k count=4
12842 cancel_lru_locks osc
12843 lctl set_param fail_loc=0x8000040f
12844 # generate a read lock
12845 cat $DIR/$tfile > /dev/null
12846 # write to the file, it will try to cancel the above read lock.
12847 cat /etc/hosts >> $DIR/$tfile
12849 run_test 213 "OSC lock completion and cancel race don't crash - bug 18829"
12851 test_214() { # for bug 20133
12852 mkdir -p $DIR/$tdir/d214c || error "mkdir $DIR/$tdir/d214c failed"
12853 for (( i=0; i < 340; i++ )) ; do
12854 touch $DIR/$tdir/d214c/a$i
12857 ls -l $DIR/$tdir || error "ls -l $DIR/d214p failed"
12858 mv $DIR/$tdir/d214c $DIR/ || error "mv $DIR/d214p/d214c $DIR/ failed"
12859 ls $DIR/d214c || error "ls $DIR/d214c failed"
12860 rm -rf $DIR/$tdir || error "rm -rf $DIR/d214* failed"
12861 rm -rf $DIR/d214* || error "rm -rf $DIR/d214* failed"
12863 run_test 214 "hash-indexed directory test - bug 20133"
12865 # having "abc" as 1st arg, creates $TMP/lnet_abc.out and $TMP/lnet_abc.sys
12866 create_lnet_proc_files() {
12867 lctl get_param -n $1 >$TMP/lnet_$1.out || error "cannot read lnet.$1"
12868 sysctl lnet.$1 >$TMP/lnet_$1.sys_tmp || error "cannot read lnet.$1"
12870 sed "s/^lnet.$1\ =\ //g" "$TMP/lnet_$1.sys_tmp" >$TMP/lnet_$1.sys
12871 rm -f "$TMP/lnet_$1.sys_tmp"
12874 # counterpart of create_lnet_proc_files
12875 remove_lnet_proc_files() {
12876 rm -f $TMP/lnet_$1.out $TMP/lnet_$1.sys
12879 # uses 1st arg as trailing part of filename, 2nd arg as description for reports,
12880 # 3rd arg as regexp for body
12881 check_lnet_proc_stats() {
12882 local l=$(cat "$TMP/lnet_$1" |wc -l)
12883 [ $l = 1 ] || (cat "$TMP/lnet_$1" && error "$2 is not of 1 line: $l")
12885 grep -E "$3" "$TMP/lnet_$1" || (cat "$TMP/lnet_$1" && error "$2 misformatted")
12888 # uses 1st arg as trailing part of filename, 2nd arg as description for reports,
12889 # 3rd arg as regexp for body, 4th arg as regexp for 1st line, 5th arg is
12890 # optional and can be regexp for 2nd line (lnet.routes case)
12891 check_lnet_proc_entry() {
12892 local blp=2 # blp stands for 'position of 1st line of body'
12893 [ -z "$5" ] || blp=3 # lnet.routes case
12895 local l=$(cat "$TMP/lnet_$1" |wc -l)
12896 # subtracting one from $blp because the body can be empty
12897 [ "$l" -ge "$(($blp - 1))" ] || (cat "$TMP/lnet_$1" && error "$2 is too short: $l")
12899 sed -n '1 p' "$TMP/lnet_$1" |grep -E "$4" >/dev/null ||
12900 (cat "$TMP/lnet_$1" && error "1st line of $2 misformatted")
12902 [ "$5" = "" ] || sed -n '2 p' "$TMP/lnet_$1" |grep -E "$5" >/dev/null ||
12903 (cat "$TMP/lnet_$1" && error "2nd line of $2 misformatted")
12905 # bail out if any unexpected line happened
12906 sed -n "$blp p" "$TMP/lnet_$1" | grep -Ev "$3"
12907 [ "$?" != 0 ] || error "$2 misformatted"
12910 test_215() { # for bugs 18102, 21079, 21517
12911 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12912 local N='(0|[1-9][0-9]*)' # non-negative numeric
12913 local P='[1-9][0-9]*' # positive numeric
12914 local I='(0|-?[1-9][0-9]*|NA)' # any numeric (0 | >0 | <0) or NA if no value
12915 local NET='[a-z][a-z0-9]*' # LNET net like o2ib2
12916 local ADDR='[0-9.]+' # LNET addr like 10.0.0.1
12917 local NID="$ADDR@$NET" # LNET nid like 10.0.0.1@o2ib2
12919 local L1 # regexp for 1st line
12920 local L2 # regexp for 2nd line (optional)
12921 local BR # regexp for the rest (body)
12923 # lnet.stats should look as 11 space-separated non-negative numerics
12924 BR="^$N $N $N $N $N $N $N $N $N $N $N$"
12925 create_lnet_proc_files "stats"
12926 check_lnet_proc_stats "stats.sys" "lnet.stats" "$BR"
12927 remove_lnet_proc_files "stats"
12929 # lnet.routes should look like this:
12930 # Routing disabled/enabled
12931 # net hops priority state router
12932 # where net is a string like tcp0, hops > 0, priority >= 0,
12933 # state is up/down,
12934 # router is a string like 192.168.1.1@tcp2
12935 L1="^Routing (disabled|enabled)$"
12936 L2="^net +hops +priority +state +router$"
12937 BR="^$NET +$N +(0|1) +(up|down) +$NID$"
12938 create_lnet_proc_files "routes"
12939 check_lnet_proc_entry "routes.sys" "lnet.routes" "$BR" "$L1" "$L2"
12940 remove_lnet_proc_files "routes"
12942 # lnet.routers should look like this:
12943 # ref rtr_ref alive_cnt state last_ping ping_sent deadline down_ni router
12944 # where ref > 0, rtr_ref > 0, alive_cnt >= 0, state is up/down,
12945 # last_ping >= 0, ping_sent is boolean (0/1), deadline and down_ni are
12946 # numeric (0 or >0 or <0), router is a string like 192.168.1.1@tcp2
12947 L1="^ref +rtr_ref +alive_cnt +state +last_ping +ping_sent +deadline +down_ni +router$"
12948 BR="^$P +$P +$N +(up|down) +$N +(0|1) +$I +$I +$NID$"
12949 create_lnet_proc_files "routers"
12950 check_lnet_proc_entry "routers.sys" "lnet.routers" "$BR" "$L1"
12951 remove_lnet_proc_files "routers"
12953 # lnet.peers should look like this:
12954 # nid refs state last max rtr min tx min queue
12955 # where nid is a string like 192.168.1.1@tcp2, refs > 0,
12956 # state is up/down/NA, max >= 0. last, rtr, min, tx, min are
12957 # numeric (0 or >0 or <0), queue >= 0.
12958 L1="^nid +refs +state +last +max +rtr +min +tx +min +queue$"
12959 BR="^$NID +$P +(up|down|NA) +$I +$N +$I +$I +$I +$I +$N$"
12960 create_lnet_proc_files "peers"
12961 check_lnet_proc_entry "peers.sys" "lnet.peers" "$BR" "$L1"
12962 remove_lnet_proc_files "peers"
12964 # lnet.buffers should look like this:
12965 # pages count credits min
12966 # where pages >=0, count >=0, credits and min are numeric (0 or >0 or <0)
12967 L1="^pages +count +credits +min$"
12968 BR="^ +$N +$N +$I +$I$"
12969 create_lnet_proc_files "buffers"
12970 check_lnet_proc_entry "buffers.sys" "lnet.buffers" "$BR" "$L1"
12971 remove_lnet_proc_files "buffers"
12973 # lnet.nis should look like this:
12974 # nid status alive refs peer rtr max tx min
12975 # where nid is a string like 192.168.1.1@tcp2, status is up/down,
12976 # alive is numeric (0 or >0 or <0), refs >= 0, peer >= 0,
12977 # rtr >= 0, max >=0, tx and min are numeric (0 or >0 or <0).
12978 L1="^nid +status +alive +refs +peer +rtr +max +tx +min$"
12979 BR="^$NID +(up|down) +$I +$N +$N +$N +$N +$I +$I$"
12980 create_lnet_proc_files "nis"
12981 check_lnet_proc_entry "nis.sys" "lnet.nis" "$BR" "$L1"
12982 remove_lnet_proc_files "nis"
12984 # can we successfully write to lnet.stats?
12985 lctl set_param -n stats=0 || error "cannot write to lnet.stats"
12986 sysctl -w lnet.stats=0 || error "cannot write to lnet.stats"
12988 run_test 215 "lnet exists and has proper content - bugs 18102, 21079, 21517"
12990 test_216() { # bug 20317
12991 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12992 remote_ost_nodsh && skip "remote OST with nodsh" && return
12995 local facets=$(get_facets OST)
12996 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
12998 save_lustre_params client "osc.*.contention_seconds" > $p
12999 save_lustre_params $facets \
13000 "ldlm.namespaces.filter-*.max_nolock_bytes" >> $p
13001 save_lustre_params $facets \
13002 "ldlm.namespaces.filter-*.contended_locks" >> $p
13003 save_lustre_params $facets \
13004 "ldlm.namespaces.filter-*.contention_seconds" >> $p
13005 clear_stats osc.*.osc_stats
13007 # agressive lockless i/o settings
13008 do_nodes $(comma_list $(osts_nodes)) \
13009 "lctl set_param -n ldlm.namespaces.*.max_nolock_bytes=2000000 \
13010 ldlm.namespaces.filter-*.contended_locks=0 \
13011 ldlm.namespaces.filter-*.contention_seconds=60"
13012 lctl set_param -n osc.*.contention_seconds=60
13014 $DIRECTIO write $DIR/$tfile 0 10 4096
13015 $CHECKSTAT -s 40960 $DIR/$tfile
13017 # disable lockless i/o
13018 do_nodes $(comma_list $(osts_nodes)) \
13019 "lctl set_param -n ldlm.namespaces.filter-*.max_nolock_bytes=0 \
13020 ldlm.namespaces.filter-*.contended_locks=32 \
13021 ldlm.namespaces.filter-*.contention_seconds=0"
13022 lctl set_param -n osc.*.contention_seconds=0
13023 clear_stats osc.*.osc_stats
13025 dd if=/dev/zero of=$DIR/$tfile count=0
13026 $CHECKSTAT -s 0 $DIR/$tfile
13028 restore_lustre_params <$p
13032 run_test 216 "check lockless direct write updates file size and kms correctly"
13034 test_217() { # bug 22430
13035 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13039 for node in $(nodes_list); do
13040 nid=$(host_nids_address $node $NETTYPE)
13041 if [[ $nid = *-* ]] ; then
13042 echo "lctl ping $(h2nettype $nid)"
13043 lctl ping $(h2nettype $nid)
13045 echo "skipping $node (no hyphen detected)"
13049 run_test 217 "check lctl ping for hostnames with hiphen ('-')"
13052 # do directio so as not to populate the page cache
13053 log "creating a 10 Mb file"
13054 $MULTIOP $DIR/$tfile oO_CREAT:O_DIRECT:O_RDWR:w$((10*1048576))c || error "multiop failed while creating a file"
13055 log "starting reads"
13056 dd if=$DIR/$tfile of=/dev/null bs=4096 &
13057 log "truncating the file"
13058 $MULTIOP $DIR/$tfile oO_TRUNC:c || error "multiop failed while truncating the file"
13060 kill %+ || true # reads might have finished
13061 echo "wait until dd is finished"
13063 log "removing the temporary file"
13064 rm -rf $DIR/$tfile || error "tmp file removal failed"
13066 run_test 218 "parallel read and truncate should not deadlock ======================="
13069 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13070 # write one partial page
13071 dd if=/dev/zero of=$DIR/$tfile bs=1024 count=1
13072 # set no grant so vvp_io_commit_write will do sync write
13073 $LCTL set_param fail_loc=0x411
13074 # write a full page at the end of file
13075 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 seek=1 conv=notrunc
13077 $LCTL set_param fail_loc=0
13078 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 seek=3
13079 $LCTL set_param fail_loc=0x411
13080 dd if=/dev/zero of=$DIR/$tfile bs=1024 count=1 seek=2 conv=notrunc
13083 dd if=/dev/zero of=$DIR/$tfile-2 bs=1024 count=1
13084 $CHECKSTAT -s 1024 $DIR/$tfile-2 || error "checkstat wrong size"
13086 run_test 219 "LU-394: Write partial won't cause uncontiguous pages vec at LND"
13088 test_220() { #LU-325
13089 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13090 remote_ost_nodsh && skip "remote OST with nodsh" && return
13091 remote_mds_nodsh && skip "remote MDS with nodsh" && return
13092 remote_mgs_nodsh && skip "remote MGS with nodsh" && return
13095 # create on MDT0000 so the last_id and next_id are correct
13097 local OST=$($LFS df $DIR | awk '/OST:'$OSTIDX'/ { print $1 }')
13101 local mdtosc_proc1=$(get_mdtosc_proc_path $SINGLEMDS $OST)
13102 local last_id=$(do_facet $SINGLEMDS lctl get_param -n \
13103 osc.$mdtosc_proc1.prealloc_last_id)
13104 local next_id=$(do_facet $SINGLEMDS lctl get_param -n \
13105 osc.$mdtosc_proc1.prealloc_next_id)
13109 do_facet ost$((OSTIDX + 1)) lctl set_param fail_val=-1
13110 #define OBD_FAIL_OST_ENOINO 0x229
13111 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=0x229
13112 create_pool $FSNAME.$TESTNAME || return 1
13113 do_facet mgs $LCTL pool_add $FSNAME.$TESTNAME $OST || return 2
13115 $SETSTRIPE $DIR/$tdir -i $OSTIDX -c 1 -p $FSNAME.$TESTNAME
13117 MDSOBJS=$((last_id - next_id))
13118 echo "preallocated objects on MDS is $MDSOBJS" "($last_id - $next_id)"
13120 blocks=$($LFS df $MOUNT | awk '($1 == '$OSTIDX') { print $4 }')
13121 echo "OST still has $count kbytes free"
13123 echo "create $MDSOBJS files @next_id..."
13124 createmany -o $DIR/$tdir/f $MDSOBJS || return 3
13126 local last_id2=$(do_facet mds${MDSIDX} lctl get_param -n \
13127 osc.$mdtosc_proc1.prealloc_last_id)
13128 local next_id2=$(do_facet mds${MDSIDX} lctl get_param -n \
13129 osc.$mdtosc_proc1.prealloc_next_id)
13131 echo "after creation, last_id=$last_id2, next_id=$next_id2"
13136 do_facet ost$((OSTIDX + 1)) lctl set_param fail_val=0
13137 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=0
13139 do_facet mgs $LCTL pool_remove $FSNAME.$TESTNAME $OST || return 4
13140 do_facet mgs $LCTL pool_destroy $FSNAME.$TESTNAME || return 5
13141 echo "unlink $MDSOBJS files @$next_id..."
13142 unlinkmany $DIR/$tdir/f $MDSOBJS || return 6
13144 run_test 220 "preallocated MDS objects still used if ENOSPC from OST"
13147 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13148 dd if=`which date` of=$MOUNT/date oflag=sync
13149 chmod +x $MOUNT/date
13151 #define OBD_FAIL_LLITE_FAULT_TRUNC_RACE 0x1401
13152 $LCTL set_param fail_loc=0x80001401
13154 $MOUNT/date > /dev/null
13157 run_test 221 "make sure fault and truncate race to not cause OOM"
13160 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13162 test_mkdir -p $DIR/$tdir
13163 $SETSTRIPE -c 1 -i 0 $DIR/$tdir
13164 createmany -o $DIR/$tdir/$tfile 10
13165 cancel_lru_locks mdc
13166 cancel_lru_locks osc
13167 #define OBD_FAIL_LDLM_AGL_DELAY 0x31a
13168 $LCTL set_param fail_loc=0x31a
13169 ls -l $DIR/$tdir > /dev/null || error "AGL for ls failed"
13170 $LCTL set_param fail_loc=0
13173 run_test 222a "AGL for ls should not trigger CLIO lock failure ================"
13176 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13178 test_mkdir -p $DIR/$tdir
13179 $SETSTRIPE -c 1 -i 0 $DIR/$tdir
13180 createmany -o $DIR/$tdir/$tfile 10
13181 cancel_lru_locks mdc
13182 cancel_lru_locks osc
13183 #define OBD_FAIL_LDLM_AGL_DELAY 0x31a
13184 $LCTL set_param fail_loc=0x31a
13185 rm -r $DIR/$tdir || error "AGL for rmdir failed"
13186 $LCTL set_param fail_loc=0
13188 run_test 222b "AGL for rmdir should not trigger CLIO lock failure ============="
13191 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13193 test_mkdir -p $DIR/$tdir
13194 $SETSTRIPE -c 1 -i 0 $DIR/$tdir
13195 createmany -o $DIR/$tdir/$tfile 10
13196 cancel_lru_locks mdc
13197 cancel_lru_locks osc
13198 #define OBD_FAIL_LDLM_AGL_NOLOCK 0x31b
13199 $LCTL set_param fail_loc=0x31b
13200 ls -l $DIR/$tdir > /dev/null || error "reenqueue failed"
13201 $LCTL set_param fail_loc=0
13204 run_test 223 "osc reenqueue if without AGL lock granted ======================="
13206 test_224a() { # LU-1039, MRP-303
13207 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13208 #define OBD_FAIL_PTLRPC_CLIENT_BULK_CB 0x508
13209 $LCTL set_param fail_loc=0x508
13210 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 conv=fsync
13211 $LCTL set_param fail_loc=0
13214 run_test 224a "Don't panic on bulk IO failure"
13216 test_224b() { # LU-1039, MRP-303
13217 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13218 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1
13219 cancel_lru_locks osc
13220 #define OBD_FAIL_PTLRPC_CLIENT_BULK_CB2 0x515
13221 $LCTL set_param fail_loc=0x515
13222 dd of=/dev/null if=$DIR/$tfile bs=4096 count=1
13223 $LCTL set_param fail_loc=0
13226 run_test 224b "Don't panic on bulk IO failure"
13228 test_224c() { # LU-6441
13229 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13230 remote_mds_nodsh && skip "remote MDS with nodsh" && return
13232 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
13233 save_writethrough $p
13234 set_cache writethrough on
13236 local pages_per_rpc=$($LCTL get_param \
13237 osc.*.max_pages_per_rpc)
13238 local at_max=$($LCTL get_param -n at_max)
13239 local timeout=$($LCTL get_param -n timeout)
13240 local test_at="$LCTL get_param -n at_max"
13241 local param_at="$FSNAME.sys.at_max"
13242 local test_timeout="$LCTL get_param -n timeout"
13243 local param_timeout="$FSNAME.sys.timeout"
13245 $LCTL set_param -n osc.*.max_pages_per_rpc=1024
13247 set_conf_param_and_check client "$test_at" "$param_at" 0 ||
13248 error "conf_param at_max=0 failed"
13249 set_conf_param_and_check client "$test_timeout" "$param_timeout" 5 ||
13250 error "conf_param timeout=5 failed"
13252 #define OBD_FAIL_PTLRPC_CLIENT_BULK_CB3 0x520
13253 do_facet ost1 $LCTL set_param fail_loc=0x520
13254 $LFS setstripe -c 1 -i 0 $DIR/$tfile
13255 dd if=/dev/zero of=$DIR/$tfile bs=8MB count=1
13257 do_facet ost1 $LCTL set_param fail_loc=0
13259 set_conf_param_and_check client "$test_at" "$param_at" $at_max ||
13260 error "conf_param at_max=$at_max failed"
13261 set_conf_param_and_check client "$test_timeout" "$param_timeout" \
13262 $timeout || error "conf_param timeout=$timeout failed"
13264 $LCTL set_param -n $pages_per_rpc
13265 restore_lustre_params < $p
13268 run_test 224c "Don't hang if one of md lost during large bulk RPC"
13270 MDSSURVEY=${MDSSURVEY:-$(which mds-survey 2>/dev/null || true)}
13272 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13273 remote_mds_nodsh && skip "remote MDS with nodsh" && return
13274 if [ -z ${MDSSURVEY} ]; then
13275 skip_env "mds-survey not found" && return
13278 [ $MDSCOUNT -ge 2 ] &&
13279 skip "skipping now for more than one MDT" && return
13281 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.51) ] ||
13282 { skip "Need MDS version at least 2.2.51"; return; }
13284 local mds=$(facet_host $SINGLEMDS)
13285 local target=$(do_nodes $mds 'lctl dl' | \
13286 awk "{if (\$2 == \"UP\" && \$3 == \"mdt\") {print \$4}}")
13288 local cmd1="file_count=1000 thrhi=4"
13289 local cmd2="dir_count=2 layer=mdd stripe_count=0"
13290 local cmd3="rslt_loc=${TMP} targets=\"$mds:$target\" $MDSSURVEY"
13291 local cmd="$cmd1 $cmd2 $cmd3"
13293 rm -f ${TMP}/mds_survey*
13295 eval $cmd || error "mds-survey with zero-stripe failed"
13296 cat ${TMP}/mds_survey*
13297 rm -f ${TMP}/mds_survey*
13299 run_test 225a "Metadata survey sanity with zero-stripe"
13302 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13303 remote_mds_nodsh && skip "remote MDS with nodsh" && return
13304 if [ -z ${MDSSURVEY} ]; then
13305 skip_env "mds-survey not found" && return
13307 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.51) ] ||
13308 { skip "Need MDS version at least 2.2.51"; return; }
13310 if [ $($LCTL dl | grep -c osc) -eq 0 ]; then
13311 skip_env "Need to mount OST to test" && return
13314 [ $MDSCOUNT -ge 2 ] &&
13315 skip "skipping now for more than one MDT" && return
13316 local mds=$(facet_host $SINGLEMDS)
13317 local target=$(do_nodes $mds 'lctl dl' | \
13318 awk "{if (\$2 == \"UP\" && \$3 == \"mdt\") {print \$4}}")
13320 local cmd1="file_count=1000 thrhi=4"
13321 local cmd2="dir_count=2 layer=mdd stripe_count=1"
13322 local cmd3="rslt_loc=${TMP} targets=\"$mds:$target\" $MDSSURVEY"
13323 local cmd="$cmd1 $cmd2 $cmd3"
13325 rm -f ${TMP}/mds_survey*
13327 eval $cmd || error "mds-survey with stripe_count failed"
13328 cat ${TMP}/mds_survey*
13329 rm -f ${TMP}/mds_survey*
13331 run_test 225b "Metadata survey sanity with stripe_count = 1"
13333 mcreate_path2fid () {
13339 local path=$DIR/$tdir/$name
13344 $MCREATE --mode=$1 --major=$2 --minor=$3 $path ||
13345 error "cannot create $desc"
13347 fid=$($LFS path2fid $path | tr -d '[' | tr -d ']')
13349 [ $rc -ne 0 ] && error "cannot get fid of a $desc"
13351 fid_path=$($LFS fid2path $MOUNT $fid)
13353 [ $rc -ne 0 ] && error "cannot get path of $desc by $DIR $path $fid"
13355 [ "$path" == "$fid_path" ] ||
13356 error "fid2path returned $fid_path, expected $path"
13358 echo "pass with $path and $fid"
13363 mkdir -p $DIR/$tdir
13365 mcreate_path2fid 0010666 0 0 fifo "FIFO"
13366 mcreate_path2fid 0020666 1 3 null "character special file (null)"
13367 mcreate_path2fid 0020666 1 255 none "character special file (no device)"
13368 mcreate_path2fid 0040666 0 0 dir "directory"
13369 mcreate_path2fid 0060666 7 0 loop0 "block special file (loop)"
13370 mcreate_path2fid 0100666 0 0 file "regular file"
13371 mcreate_path2fid 0120666 0 0 link "symbolic link"
13372 mcreate_path2fid 0140666 0 0 sock "socket"
13374 run_test 226a "call path2fid and fid2path on files of all type"
13377 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
13381 mkdir -p $DIR/$tdir
13382 $LFS setdirstripe -i $MDTIDX $DIR/$tdir/remote_dir ||
13383 error "create remote directory failed"
13384 mcreate_path2fid 0010666 0 0 "remote_dir/fifo" "FIFO"
13385 mcreate_path2fid 0020666 1 3 "remote_dir/null" \
13386 "character special file (null)"
13387 mcreate_path2fid 0020666 1 255 "remote_dir/none" \
13388 "character special file (no device)"
13389 mcreate_path2fid 0040666 0 0 "remote_dir/dir" "directory"
13390 mcreate_path2fid 0060666 7 0 "remote_dir/loop0" \
13391 "block special file (loop)"
13392 mcreate_path2fid 0100666 0 0 "remote_dir/file" "regular file"
13393 mcreate_path2fid 0120666 0 0 "remote_dir/link" "symbolic link"
13394 mcreate_path2fid 0140666 0 0 "remote_dir/sock" "socket"
13396 run_test 226b "call path2fid and fid2path on files of all type under remote dir"
13398 # LU-1299 Executing or running ldd on a truncated executable does not
13399 # cause an out-of-memory condition.
13401 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13402 [ -z "$(which ldd)" ] && skip "should have ldd tool" && return
13403 dd if=$(which date) of=$MOUNT/date bs=1k count=1
13404 chmod +x $MOUNT/date
13406 $MOUNT/date > /dev/null
13407 ldd $MOUNT/date > /dev/null
13410 run_test 227 "running truncated executable does not cause OOM"
13412 # LU-1512 try to reuse idle OI blocks
13414 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13415 remote_mds_nodsh && skip "remote MDS with nodsh" && return
13416 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
13417 skip "ldiskfs only test" && return
13419 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
13420 local myDIR=$DIR/$tdir
13423 #define OBD_FAIL_SEQ_EXHAUST 0x1002
13424 $LCTL set_param fail_loc=0x80001002
13425 createmany -o $myDIR/t- 10000
13426 $LCTL set_param fail_loc=0
13427 # The guard is current the largest FID holder
13429 local SEQ=$($LFS path2fid $myDIR/guard | awk -F ':' '{print $1}' |
13431 local IDX=$(($SEQ % 64))
13433 do_facet $SINGLEMDS sync
13434 # Make sure journal flushed.
13436 local blk1=$(do_facet $SINGLEMDS \
13437 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
13438 grep Blockcount | awk '{print $4}')
13440 # Remove old files, some OI blocks will become idle.
13441 unlinkmany $myDIR/t- 10000
13442 # Create new files, idle OI blocks should be reused.
13443 createmany -o $myDIR/t- 2000
13444 do_facet $SINGLEMDS sync
13445 # Make sure journal flushed.
13447 local blk2=$(do_facet $SINGLEMDS \
13448 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
13449 grep Blockcount | awk '{print $4}')
13451 [ $blk1 == $blk2 ] || error "old blk1=$blk1, new blk2=$blk2, unmatched!"
13453 run_test 228a "try to reuse idle OI blocks"
13456 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13457 remote_mds_nodsh && skip "remote MDS with nodsh" && return
13458 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
13459 skip "ldiskfs only test" && return
13461 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
13462 local myDIR=$DIR/$tdir
13465 #define OBD_FAIL_SEQ_EXHAUST 0x1002
13466 $LCTL set_param fail_loc=0x80001002
13467 createmany -o $myDIR/t- 10000
13468 $LCTL set_param fail_loc=0
13469 # The guard is current the largest FID holder
13471 local SEQ=$($LFS path2fid $myDIR/guard | awk -F ':' '{print $1}' |
13473 local IDX=$(($SEQ % 64))
13475 do_facet $SINGLEMDS sync
13476 # Make sure journal flushed.
13478 local blk1=$(do_facet $SINGLEMDS \
13479 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
13480 grep Blockcount | awk '{print $4}')
13482 # Remove old files, some OI blocks will become idle.
13483 unlinkmany $myDIR/t- 10000
13486 stop $SINGLEMDS || error "Fail to stop MDT."
13488 start $SINGLEMDS $MDT_DEV $MDS_MOUNT_OPTS || error "Fail to start MDT."
13490 df $MOUNT || error "Fail to df."
13491 # Create new files, idle OI blocks should be reused.
13492 createmany -o $myDIR/t- 2000
13493 do_facet $SINGLEMDS sync
13494 # Make sure journal flushed.
13496 local blk2=$(do_facet $SINGLEMDS \
13497 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
13498 grep Blockcount | awk '{print $4}')
13500 [ $blk1 == $blk2 ] || error "old blk1=$blk1, new blk2=$blk2, unmatched!"
13502 run_test 228b "idle OI blocks can be reused after MDT restart"
13506 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13507 remote_mds_nodsh && skip "remote MDS with nodsh" && return
13508 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
13509 skip "ldiskfs only test" && return
13511 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
13512 local myDIR=$DIR/$tdir
13515 #define OBD_FAIL_SEQ_EXHAUST 0x1002
13516 $LCTL set_param fail_loc=0x80001002
13517 # 20000 files can guarantee there are index nodes in the OI file
13518 createmany -o $myDIR/t- 20000
13519 $LCTL set_param fail_loc=0
13520 # The guard is current the largest FID holder
13522 local SEQ=$($LFS path2fid $myDIR/guard | awk -F ':' '{print $1}' |
13524 local IDX=$(($SEQ % 64))
13526 do_facet $SINGLEMDS sync
13527 # Make sure journal flushed.
13529 local blk1=$(do_facet $SINGLEMDS \
13530 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
13531 grep Blockcount | awk '{print $4}')
13533 # Remove old files, some OI blocks will become idle.
13534 unlinkmany $myDIR/t- 20000
13536 # The OI file should become empty now
13538 # Create new files, idle OI blocks should be reused.
13539 createmany -o $myDIR/t- 2000
13540 do_facet $SINGLEMDS sync
13541 # Make sure journal flushed.
13543 local blk2=$(do_facet $SINGLEMDS \
13544 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
13545 grep Blockcount | awk '{print $4}')
13547 [ $blk1 == $blk2 ] || error "old blk1=$blk1, new blk2=$blk2, unmatched!"
13549 run_test 228c "NOT shrink the last entry in OI index node to recycle idle leaf"
13551 test_229() { # LU-2482, LU-3448
13552 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.53) ] &&
13553 skip "No HSM $(lustre_build_version $SINGLEMDS) MDS < 2.4.53" &&
13555 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13556 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs" && return
13560 # Create a file with a released layout and stripe count 2.
13561 $MULTIOP $DIR/$tfile H2c ||
13562 error "failed to create file with released layout"
13564 $GETSTRIPE -v $DIR/$tfile
13566 local pattern=$($GETSTRIPE -L $DIR/$tfile)
13567 [ X"$pattern" = X"80000001" ] || error "pattern error ($pattern)"
13569 local stripe_count=$($GETSTRIPE -c $DIR/$tfile) || error "getstripe"
13570 [ $stripe_count -eq 2 ] || error "stripe count not 2 ($stripe_count)"
13571 stat $DIR/$tfile || error "failed to stat released file"
13573 chown $RUNAS_ID $DIR/$tfile ||
13574 error "chown $RUNAS_ID $DIR/$tfile failed"
13576 chgrp $RUNAS_ID $DIR/$tfile ||
13577 error "chgrp $RUNAS_ID $DIR/$tfile failed"
13579 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
13580 rm $DIR/$tfile || error "failed to remove released file"
13582 run_test 229 "getstripe/stat/rm/attr changes work on released files"
13585 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13586 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
13589 test_mkdir $DIR/$tdir
13590 test_mkdir -i0 -c1 $DIR/$tdir/test_230_local
13591 local mdt_idx=$($GETSTRIPE -M $DIR/$tdir/test_230_local)
13592 [ $mdt_idx -ne 0 ] &&
13593 error "create local directory on wrong MDT $mdt_idx"
13595 $LFS mkdir -i $MDTIDX $DIR/$tdir/test_230 ||
13596 error "create remote directory failed"
13597 local mdt_idx=$($GETSTRIPE -M $DIR/$tdir/test_230)
13598 [ $mdt_idx -ne $MDTIDX ] &&
13599 error "create remote directory on wrong MDT $mdt_idx"
13601 createmany -o $DIR/$tdir/test_230/t- 10 ||
13602 error "create files on remote directory failed"
13603 mdt_idx=$($GETSTRIPE -M $DIR/$tdir/test_230/t-0)
13604 [ $mdt_idx -ne $MDTIDX ] && error "create files on wrong MDT $mdt_idx"
13605 rm -r $DIR/$tdir || error "unlink remote directory failed"
13607 run_test 230a "Create remote directory and files under the remote directory"
13610 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13611 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
13618 local migrate_dir=$DIR/$tdir/migrate_dir
13619 local other_dir=$DIR/$tdir/other_dir
13621 test_mkdir $DIR/$tdir
13622 test_mkdir -i0 -c1 $migrate_dir
13623 test_mkdir -i0 -c1 $other_dir
13624 for ((i=0; i<10; i++)); do
13625 mkdir -p $migrate_dir/dir_${i}
13626 createmany -o $migrate_dir/dir_${i}/f 10 ||
13627 error "create files under remote dir failed $i"
13630 cp /etc/passwd $migrate_dir/$tfile
13631 cp /etc/passwd $other_dir/$tfile
13632 chattr +SAD $migrate_dir
13633 chattr +SAD $migrate_dir/$tfile
13635 local old_dir_flag=$(lsattr -a $migrate_dir | awk '/\/\.$/ {print $1}')
13636 local old_file_flag=$(lsattr $migrate_dir/$tfile | awk '{print $1}')
13637 local old_dir_mode=$(stat -c%f $migrate_dir)
13638 local old_file_mode=$(stat -c%f $migrate_dir/$tfile)
13640 mkdir -p $migrate_dir/dir_default_stripe2
13641 $SETSTRIPE -c 2 $migrate_dir/dir_default_stripe2
13642 $SETSTRIPE -c 2 $migrate_dir/${tfile}_stripe2
13644 mkdir -p $other_dir
13645 ln $migrate_dir/$tfile $other_dir/luna
13646 ln $migrate_dir/$tfile $migrate_dir/sofia
13647 ln $other_dir/$tfile $migrate_dir/david
13648 ln -s $migrate_dir/$tfile $other_dir/zachary
13649 ln -s $migrate_dir/$tfile $migrate_dir/${tfile}_ln
13650 ln -s $other_dir/$tfile $migrate_dir/${tfile}_ln_other
13652 $LFS migrate -m $MDTIDX $migrate_dir ||
13653 error "fails on migrating remote dir to MDT1"
13655 echo "migratate to MDT1, then checking.."
13656 for ((i = 0; i < 10; i++)); do
13657 for file in $(find $migrate_dir/dir_${i}); do
13658 mdt_index=$($LFS getstripe -M $file)
13659 [ $mdt_index == $MDTIDX ] ||
13660 error "$file is not on MDT${MDTIDX}"
13664 # the multiple link file should still in MDT0
13665 mdt_index=$($LFS getstripe -M $migrate_dir/$tfile)
13666 [ $mdt_index == 0 ] ||
13667 error "$file is not on MDT${MDTIDX}"
13669 local new_dir_flag=$(lsattr -a $migrate_dir | awk '/\/\.$/ {print $1}')
13670 [ "$old_dir_flag" = "$new_dir_flag" ] ||
13671 error " expect $old_dir_flag get $new_dir_flag"
13673 local new_file_flag=$(lsattr $migrate_dir/$tfile | awk '{print $1}')
13674 [ "$old_file_flag" = "$new_file_flag" ] ||
13675 error " expect $old_file_flag get $new_file_flag"
13677 local new_dir_mode=$(stat -c%f $migrate_dir)
13678 [ "$old_dir_mode" = "$new_dir_mode" ] ||
13679 error "expect mode $old_dir_mode get $new_dir_mode"
13681 local new_file_mode=$(stat -c%f $migrate_dir/$tfile)
13682 [ "$old_file_mode" = "$new_file_mode" ] ||
13683 error "expect mode $old_file_mode get $new_file_mode"
13685 diff /etc/passwd $migrate_dir/$tfile ||
13686 error "$tfile different after migration"
13688 diff /etc/passwd $other_dir/luna ||
13689 error "luna different after migration"
13691 diff /etc/passwd $migrate_dir/sofia ||
13692 error "sofia different after migration"
13694 diff /etc/passwd $migrate_dir/david ||
13695 error "david different after migration"
13697 diff /etc/passwd $other_dir/zachary ||
13698 error "zachary different after migration"
13700 diff /etc/passwd $migrate_dir/${tfile}_ln ||
13701 error "${tfile}_ln different after migration"
13703 diff /etc/passwd $migrate_dir/${tfile}_ln_other ||
13704 error "${tfile}_ln_other different after migration"
13706 stripe_count=$($LFS getstripe -c $migrate_dir/dir_default_stripe2)
13707 [ $stripe_count = 2 ] ||
13708 error "dir strpe_count $d != 2 after migration."
13710 stripe_count=$($LFS getstripe -c $migrate_dir/${tfile}_stripe2)
13711 [ $stripe_count = 2 ] ||
13712 error "file strpe_count $d != 2 after migration."
13714 #migrate back to MDT0
13717 $LFS migrate -m $MDTIDX $migrate_dir ||
13718 error "fails on migrating remote dir to MDT0"
13720 echo "migrate back to MDT0, checking.."
13721 for file in $(find $migrate_dir); do
13722 mdt_index=$($LFS getstripe -M $file)
13723 [ $mdt_index == $MDTIDX ] ||
13724 error "$file is not on MDT${MDTIDX}"
13727 local new_dir_flag=$(lsattr -a $migrate_dir | awk '/\/\.$/ {print $1}')
13728 [ "$old_dir_flag" = "$new_dir_flag" ] ||
13729 error " expect $old_dir_flag get $new_dir_flag"
13731 local new_file_flag=$(lsattr $migrate_dir/$tfile | awk '{print $1}')
13732 [ "$old_file_flag" = "$new_file_flag" ] ||
13733 error " expect $old_file_flag get $new_file_flag"
13735 local new_dir_mode=$(stat -c%f $migrate_dir)
13736 [ "$old_dir_mode" = "$new_dir_mode" ] ||
13737 error "expect mode $old_dir_mode get $new_dir_mode"
13739 local new_file_mode=$(stat -c%f $migrate_dir/$tfile)
13740 [ "$old_file_mode" = "$new_file_mode" ] ||
13741 error "expect mode $old_file_mode get $new_file_mode"
13743 diff /etc/passwd ${migrate_dir}/$tfile ||
13744 error "$tfile different after migration"
13746 diff /etc/passwd ${other_dir}/luna ||
13747 error "luna different after migration"
13749 diff /etc/passwd ${migrate_dir}/sofia ||
13750 error "sofia different after migration"
13752 diff /etc/passwd ${other_dir}/zachary ||
13753 error "zachary different after migration"
13755 diff /etc/passwd $migrate_dir/${tfile}_ln ||
13756 error "${tfile}_ln different after migration"
13758 diff /etc/passwd $migrate_dir/${tfile}_ln_other ||
13759 error "${tfile}_ln_other different after migration"
13761 stripe_count=$($LFS getstripe -c ${migrate_dir}/dir_default_stripe2)
13762 [ $stripe_count = 2 ] ||
13763 error "dir strpe_count $d != 2 after migration."
13765 stripe_count=$($LFS getstripe -c ${migrate_dir}/${tfile}_stripe2)
13766 [ $stripe_count = 2 ] ||
13767 error "file strpe_count $d != 2 after migration."
13769 rm -rf $DIR/$tdir || error "rm dir failed after migration"
13771 run_test 230b "migrate directory"
13774 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13775 remote_mds_nodsh && skip "remote MDS with nodsh" && return
13776 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
13780 local migrate_dir=$DIR/$tdir/migrate_dir
13782 #If migrating directory fails in the middle, all entries of
13783 #the directory is still accessiable.
13784 test_mkdir $DIR/$tdir
13785 test_mkdir -i0 -c1 $migrate_dir
13787 createmany -o $migrate_dir/f 10 ||
13788 error "create files under ${migrate_dir} failed"
13790 #failed after migrating 5 entries
13791 #OBD_FAIL_MIGRATE_ENTRIES 0x1801
13792 do_facet mds1 lctl set_param fail_loc=0x20001801
13793 do_facet mds1 lctl set_param fail_val=5
13794 local t=$(ls $migrate_dir | wc -l)
13795 $LFS migrate --mdt-index $MDTIDX $migrate_dir &&
13796 error "migrate should fail after 5 entries"
13798 mkdir $migrate_dir/dir &&
13799 error "mkdir succeeds under migrating directory"
13800 touch $migrate_dir/file &&
13801 error "touch file succeeds under migrating directory"
13803 local u=$(ls $migrate_dir | wc -l)
13804 [ "$u" == "$t" ] || error "$u != $t during migration"
13806 for file in $(find $migrate_dir); do
13807 stat $file || error "stat $file failed"
13810 do_facet mds1 lctl set_param fail_loc=0
13811 do_facet mds1 lctl set_param fail_val=0
13813 $LFS migrate -m $MDTIDX $migrate_dir ||
13814 error "migrate open files should failed with open files"
13816 echo "Finish migration, then checking.."
13817 for file in $(find $migrate_dir); do
13818 mdt_index=$($LFS getstripe -M $file)
13819 [ $mdt_index == $MDTIDX ] ||
13820 error "$file is not on MDT${MDTIDX}"
13823 rm -rf $DIR/$tdir || error "rm dir failed after migration"
13825 run_test 230c "check directory accessiblity if migration is failed"
13828 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13829 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
13832 local migrate_dir=$DIR/$tdir/migrate_dir
13836 test_mkdir $DIR/$tdir
13837 test_mkdir -i0 -c1 $migrate_dir
13839 for ((i=0; i<100; i++)); do
13840 test_mkdir -i0 -c1 $migrate_dir/dir_${i}
13841 createmany -o $migrate_dir/dir_${i}/f 100 ||
13842 error "create files under remote dir failed $i"
13845 $LFS migrate -m $MDTIDX $migrate_dir ||
13846 error "migrate remote dir error"
13848 echo "Finish migration, then checking.."
13849 for file in $(find $migrate_dir); do
13850 mdt_index=$($LFS getstripe -M $file)
13851 [ $mdt_index == $MDTIDX ] ||
13852 error "$file is not on MDT${MDTIDX}"
13855 rm -rf $DIR/$tdir || error "rm dir failed after migration"
13857 run_test 230d "check migrate big directory"
13860 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13861 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
13867 mkdir -p $DIR/$tdir
13868 mkdir $DIR/$tdir/migrate_dir
13869 mkdir $DIR/$tdir/other_dir
13870 touch $DIR/$tdir/migrate_dir/a
13871 ln $DIR/$tdir/migrate_dir/a $DIR/$tdir/other_dir/b
13872 ls $DIR/$tdir/other_dir
13874 $LFS migrate -m 1 $DIR/$tdir/migrate_dir ||
13875 error "migrate dir fails"
13877 mdt_index=$($LFS getstripe -M $DIR/$tdir/migrate_dir)
13878 [ $mdt_index == 1 ] || error "migrate_dir is not on MDT1"
13880 mdt_index=$($LFS getstripe -M $DIR/$tdir/migrate_dir/a)
13881 [ $mdt_index == 0 ] || error "a is not on MDT0"
13883 $LFS migrate -m 1 $DIR/$tdir/other_dir ||
13884 error "migrate dir fails"
13886 mdt_index=$($LFS getstripe -M $DIR/$tdir/other_dir)
13887 [ $mdt_index == 1 ] || error "other_dir is not on MDT1"
13889 mdt_index=$($LFS getstripe -M $DIR/$tdir/migrate_dir/a)
13890 [ $mdt_index == 1 ] || error "a is not on MDT1"
13892 mdt_index=$($LFS getstripe -M $DIR/$tdir/other_dir/b)
13893 [ $mdt_index == 1 ] || error "b is not on MDT1"
13895 a_fid=$($LFS path2fid $DIR/$tdir/migrate_dir/a)
13896 b_fid=$($LFS path2fid $DIR/$tdir/other_dir/b)
13898 [ "$a_fid" = "$b_fid" ] || error "different fid after migration"
13900 rm -rf $DIR/$tdir || error "rm dir failed after migration"
13902 run_test 230e "migrate mulitple local link files"
13905 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13906 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
13910 mkdir -p $DIR/$tdir
13911 mkdir $DIR/$tdir/migrate_dir
13912 $LFS mkdir -i1 $DIR/$tdir/other_dir
13913 touch $DIR/$tdir/migrate_dir/a
13914 ln $DIR/$tdir/migrate_dir/a $DIR/$tdir/other_dir/ln1
13915 ln $DIR/$tdir/migrate_dir/a $DIR/$tdir/other_dir/ln2
13916 ls $DIR/$tdir/other_dir
13918 # a should be migrated to MDT1, since no other links on MDT0
13919 $LFS migrate -m 1 $DIR/$tdir/migrate_dir ||
13920 error "#1 migrate dir fails"
13921 mdt_index=$($LFS getstripe -M $DIR/$tdir/migrate_dir)
13922 [ $mdt_index == 1 ] || error "migrate_dir is not on MDT1"
13923 mdt_index=$($LFS getstripe -M $DIR/$tdir/migrate_dir/a)
13924 [ $mdt_index == 1 ] || error "a is not on MDT1"
13926 # a should stay on MDT1, because it is a mulitple link file
13927 $LFS migrate -m 0 $DIR/$tdir/migrate_dir ||
13928 error "#2 migrate dir fails"
13929 mdt_index=$($LFS getstripe -M $DIR/$tdir/migrate_dir/a)
13930 [ $mdt_index == 1 ] || error "a is not on MDT1"
13932 $LFS migrate -m 1 $DIR/$tdir/migrate_dir ||
13933 error "#3 migrate dir fails"
13935 a_fid=$($LFS path2fid $DIR/$tdir/migrate_dir/a)
13936 ln_fid=$($LFS path2fid $DIR/$tdir/other_dir/ln1)
13937 [ "$a_fid" = "$ln_fid" ] || error "different fid after migrate to MDT1"
13939 rm -rf $DIR/$tdir/other_dir/ln1 || error "unlink ln1 fails"
13940 rm -rf $DIR/$tdir/other_dir/ln2 || error "unlink ln2 fails"
13942 # a should be migrated to MDT0, since no other links on MDT1
13943 $LFS migrate -m 0 $DIR/$tdir/migrate_dir ||
13944 error "#4 migrate dir fails"
13945 mdt_index=$($LFS getstripe -M $DIR/$tdir/migrate_dir/a)
13946 [ $mdt_index == 0 ] || error "a is not on MDT0"
13948 rm -rf $DIR/$tdir || error "rm dir failed after migration"
13950 run_test 230f "migrate mulitple remote link files"
13953 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13954 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
13956 mkdir -p $DIR/$tdir/migrate_dir
13958 $LFS migrate -m 1000 $DIR/$tdir/migrate_dir &&
13959 error "migrating dir to non-exist MDT succeeds"
13962 run_test 230g "migrate dir to non-exist MDT"
13965 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13966 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
13967 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.64) ] &&
13968 skip "Need MDS version at least 2.7.64" && return
13971 mkdir -p $DIR/$tdir/migrate_dir
13973 $LFS migrate -m1 $DIR &&
13974 error "migrating mountpoint1 should fail"
13976 $LFS migrate -m1 $DIR/$tdir/.. &&
13977 error "migrating mountpoint2 should fail"
13979 $LFS migrate -m1 $DIR/$tdir/migrate_dir/.. ||
13980 error "migrating $tdir fail"
13982 mdt_index=$($LFS getstripe -M $DIR/$tdir)
13983 [ $mdt_index == 1 ] || error "$mdt_index != 1 after migration"
13985 mdt_index=$($LFS getstripe -M $DIR/$tdir/migrate_dir)
13986 [ $mdt_index == 1 ] || error "$mdt_index != 1 after migration"
13989 run_test 230h "migrate .. and root"
13992 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13993 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
13995 mkdir -p $DIR/$tdir/migrate_dir
13997 $LFS migrate -m 1 $DIR/$tdir/migrate_dir/ ||
13998 error "migration fails with a tailing slash"
14000 $LFS migrate -m 0 $DIR/$tdir/migrate_dir// ||
14001 error "migration fails with two tailing slashes"
14003 run_test 230i "lfs migrate -m tolerates trailing slashes"
14007 # For simplicity this test assumes that max_pages_per_rpc
14008 # is the same across all OSCs
14009 local max_pages=$($LCTL get_param -n osc.*.max_pages_per_rpc | head -n1)
14010 local bulk_size=$((max_pages * 4096))
14011 local brw_size=$(do_facet ost1 $LCTL get_param -n obdfilter.*.brw_size |
14014 mkdir -p $DIR/$tdir
14015 $LFS setstripe -S ${brw_size}M $DIR/$tdir ||
14016 error "failed to set stripe with -S ${brw_size}M option"
14018 # clear the OSC stats
14019 $LCTL set_param osc.*.stats=0 &>/dev/null
14022 # Client writes $bulk_size - there must be 1 rpc for $max_pages.
14023 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=$bulk_size count=1 \
14024 oflag=direct &>/dev/null || error "dd failed"
14026 sync; sleep 1; sync # just to be safe
14027 local nrpcs=$($LCTL get_param osc.*.stats |awk '/ost_write/ {print $2}')
14028 if [ x$nrpcs != "x1" ]; then
14029 $LCTL get_param osc.*.stats
14030 error "found $nrpcs ost_write RPCs, not 1 as expected"
14034 # Drop the OSC cache, otherwise we will read from it
14035 cancel_lru_locks osc
14037 # clear the OSC stats
14038 $LCTL set_param osc.*.stats=0 &>/dev/null
14040 # Client reads $bulk_size.
14041 dd if=$DIR/$tdir/$tfile of=/dev/null bs=$bulk_size count=1 \
14042 iflag=direct &>/dev/null || error "dd failed"
14044 nrpcs=$($LCTL get_param osc.*.stats | awk '/ost_read/ { print $2 }')
14045 if [ x$nrpcs != "x1" ]; then
14046 $LCTL get_param osc.*.stats
14047 error "found $nrpcs ost_read RPCs, not 1 as expected"
14050 run_test 231a "checking that reading/writing of BRW RPC size results in one RPC"
14053 mkdir -p $DIR/$tdir
14055 for i in {0..1023}; do
14056 dd if=/dev/zero of=$DIR/$tdir/$tfile conv=notrunc \
14057 seek=$((2 * i)) bs=4096 count=1 &>/dev/null ||
14058 error "dd of=$DIR/$tdir/$tfile seek=$((2 * i)) failed"
14062 run_test 231b "must not assert on fully utilized OST request buffer"
14065 mkdir -p $DIR/$tdir
14066 #define OBD_FAIL_LDLM_OST_LVB 0x31c
14067 $LCTL set_param fail_loc=0x31c
14069 # ignore dd failure
14070 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=1 || true
14072 $LCTL set_param fail_loc=0
14073 umount_client $MOUNT || error "umount failed"
14074 mount_client $MOUNT || error "mount failed"
14076 run_test 232 "failed lock should not block umount"
14079 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.3.64) ] ||
14080 { skip "Need MDS version at least 2.3.64"; return; }
14081 [ -n "$FILESET" ] && skip "SKIP due to FILESET set" && return
14083 local fid=$($LFS path2fid $MOUNT)
14084 stat $MOUNT/.lustre/fid/$fid > /dev/null ||
14085 error "cannot access $MOUNT using its FID '$fid'"
14087 run_test 233a "checking that OBF of the FS root succeeds"
14090 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.5.90) ] ||
14091 { skip "Need MDS version at least 2.5.90"; return; }
14092 [ -n "$FILESET" ] && skip "SKIP due to FILESET set" && return
14094 local fid=$($LFS path2fid $MOUNT/.lustre)
14095 stat $MOUNT/.lustre/fid/$fid > /dev/null ||
14096 error "cannot access $MOUNT/.lustre using its FID '$fid'"
14098 fid=$($LFS path2fid $MOUNT/.lustre/fid)
14099 stat $MOUNT/.lustre/fid/$fid > /dev/null ||
14100 error "cannot access $MOUNT/.lustre/fid using its FID '$fid'"
14102 run_test 233b "checking that OBF of the FS .lustre succeeds"
14105 local p="$TMP/sanityN-$TESTNAME.parameters"
14106 save_lustre_params client "llite.*.xattr_cache" > $p
14107 lctl set_param llite.*.xattr_cache 1 ||
14108 { skip "xattr cache is not supported"; return 0; }
14110 mkdir -p $DIR/$tdir || error "mkdir failed"
14111 touch $DIR/$tdir/$tfile || error "touch failed"
14112 # OBD_FAIL_LLITE_XATTR_ENOMEM
14113 $LCTL set_param fail_loc=0x1405
14114 # output of the form: attr 2 4 44 3 fc13 x86_64
14115 V=($(IFS=".-" rpm -q attr))
14116 if [[ ${V[1]} > 2 || ${V[2]} > 4 || ${V[3]} > 44 ||
14117 ${V[1]} = 2 && ${V[2]} = 4 && ${V[3]} = 44 && ${V[4]} > 6 ]]; then
14118 # attr pre-2.4.44-7 had a bug with rc
14119 # LU-3703 - SLES 11 and FC13 clients have older attr
14120 getfattr -n user.attr $DIR/$tdir/$tfile &&
14121 error "getfattr should have failed with ENOMEM"
14123 skip "LU-3703: attr version $(getfattr --version) too old"
14125 $LCTL set_param fail_loc=0x0
14128 restore_lustre_params < $p
14131 run_test 234 "xattr cache should not crash on ENOMEM"
14134 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.52) ] &&
14135 skip "Need MDS version at least 2.4.52" && return
14136 flock_deadlock $DIR/$tfile
14141 124) error "process hangs on a deadlock"
14143 *) error "error executing flock_deadlock $DIR/$tfile"
14147 run_test 235 "LU-1715: flock deadlock detection does not work properly"
14151 check_swap_layouts_support && return 0
14152 test_mkdir -p -c1 $DIR/$tdir || error "mkdir $tdir failed"
14154 local ref1=/etc/passwd
14155 local ref2=/etc/group
14156 local file1=$DIR/$tdir/f1
14157 local file2=$DIR/$tdir/f2
14159 $SETSTRIPE -c 1 $file1 || error "cannot setstripe on '$file1': rc = $?"
14160 cp $ref1 $file1 || error "cp $ref1 $file1 failed: rc = $?"
14161 $SETSTRIPE -c 2 $file2 || error "cannot setstripe on '$file2': rc = $?"
14162 cp $ref2 $file2 || error "cp $ref2 $file2 failed: rc = $?"
14163 local fd=$(free_fd)
14164 local cmd="exec $fd<>$file2"
14167 $LFS swap_layouts $file1 /proc/self/fd/${fd} ||
14168 error "cannot swap layouts of '$file1' and /proc/self/fd/${fd}"
14171 cmp $ref2 $file1 || error "content compare failed ($ref2 != $file1)"
14176 run_test 236 "Layout swap on open unlinked file"
14178 # test to verify file handle related system calls
14179 # (name_to_handle_at/open_by_handle_at)
14180 # The new system calls are supported in glibc >= 2.14.
14183 echo "Test file_handle syscalls" > $DIR/$tfile ||
14184 error "write failed"
14185 check_fhandle_syscalls $DIR/$tfile ||
14186 error "check_fhandle_syscalls failed"
14188 run_test 237 "Verify name_to_handle_at/open_by_handle_at syscalls"
14190 # LU-4659 linkea consistency
14192 local server_version=$(lustre_version_code $SINGLEMDS)
14194 [[ $server_version -gt $(version_code 2.5.57) ]] ||
14195 [[ $server_version -gt $(version_code 2.5.1) &&
14196 $server_version -lt $(version_code 2.5.50) ]] ||
14197 { skip "Need MDS version at least 2.5.58 or 2.5.2+"; return; }
14200 ln $DIR/$tfile $DIR/$tfile.lnk
14201 touch $DIR/$tfile.new
14202 mv $DIR/$tfile.new $DIR/$tfile
14203 local fid1=$($LFS path2fid $DIR/$tfile)
14204 local fid2=$($LFS path2fid $DIR/$tfile.lnk)
14205 local path1=$($LFS fid2path $FSNAME "$fid1")
14206 [ $tfile == $path1 ] || error "linkea inconsistent: $tfile $fid1 $path1"
14207 local path2=$($LFS fid2path $FSNAME "$fid2")
14208 [ $tfile.lnk == $path2 ] ||
14209 error "linkea inconsistent: $tfile.lnk $fid2 $path2!"
14212 run_test 238 "Verify linkea consistency"
14215 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.5.60) ] &&
14216 skip "Need MDS version at least 2.5.60" && return
14217 local list=$(comma_list $(mdts_nodes))
14219 mkdir -p $DIR/$tdir
14220 createmany -o $DIR/$tdir/f- 5000
14221 unlinkmany $DIR/$tdir/f- 5000
14222 do_nodes $list "lctl set_param -n osp*.*.sync_changes 1"
14223 changes=$(do_nodes $list "lctl get_param -n osc.*MDT*.sync_changes \
14224 osc.*MDT*.sync_in_flight" | calc_sum)
14225 [ "$changes" -eq 0 ] || error "$changes not synced"
14227 run_test 239 "osp_sync test"
14229 test_239a() { #LU-5297
14230 remote_mds_nodsh && skip "remote MDS with nodsh" && return
14232 #define OBD_FAIL_OSP_CHECK_INVALID_REC 0x2100
14233 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x2100
14234 chgrp $RUNAS_GID $DIR/$tfile
14235 wait_delete_completed
14237 run_test 239a "process invalid osp sync record correctly"
14239 test_239b() { #LU-5297
14240 remote_mds_nodsh && skip "remote MDS with nodsh" && return
14242 #define OBD_FAIL_OSP_CHECK_ENOMEM 0x2101
14243 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x2101
14244 chgrp $RUNAS_GID $DIR/$tfile1
14245 wait_delete_completed
14246 do_facet $SINGLEMDS $LCTL set_param fail_loc=0
14248 chgrp $RUNAS_GID $DIR/$tfile2
14249 wait_delete_completed
14251 run_test 239b "process osp sync record with ENOMEM error correctly"
14254 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
14255 remote_mds_nodsh && skip "remote MDS with nodsh" && return
14257 mkdir -p $DIR/$tdir
14259 $LFS mkdir -i 0 $DIR/$tdir/d0 ||
14260 error "failed to mkdir $DIR/$tdir/d0 on MDT0"
14261 $LFS mkdir -i 1 $DIR/$tdir/d0/d1 ||
14262 error "failed to mkdir $DIR/$tdir/d0/d1 on MDT1"
14264 umount_client $MOUNT || error "umount failed"
14265 #define OBD_FAIL_TGT_DELAY_CONDITIONAL 0x713
14266 do_facet mds2 lctl set_param fail_loc=0x713 fail_val=1
14267 mount_client $MOUNT || error "failed to mount client"
14269 echo "stat $DIR/$tdir/d0/d1, should not fail/ASSERT"
14270 stat $DIR/$tdir/d0/d1 || error "fail to stat $DIR/$tdir/d0/d1"
14272 run_test 240 "race between ldlm enqueue and the connection RPC (no ASSERT)"
14275 for LOOP in $(seq $1); do
14276 dd if=$DIR/$tfile of=/dev/null bs=40960 count=1 2>/dev/null
14277 cancel_lru_locks osc || true
14282 for LOOP in $(seq $1); do
14283 dd if=$DIR/$tfile of=/dev/null bs=40960 count=1 \
14284 iflag=direct 2>/dev/null
14288 test_241a() { # was test_241
14289 dd if=/dev/zero of=$DIR/$tfile count=1 bs=40960
14291 cancel_lru_locks osc
14292 test_241_bio 1000 &
14297 run_test 241a "bio vs dio"
14300 dd if=/dev/zero of=$DIR/$tfile count=1 bs=40960
14302 test_241_dio 1000 &
14307 run_test 241b "dio vs dio"
14310 remote_mds_nodsh && skip "remote MDS with nodsh" && return
14311 mkdir -p $DIR/$tdir
14312 touch $DIR/$tdir/$tfile
14314 #define OBD_FAIL_MDS_READPAGE_PACK 0x105
14315 do_facet mds1 lctl set_param fail_loc=0x105
14316 /bin/ls $DIR/$tdir && error "ls $DIR/$tdir should fail"
14318 do_facet mds1 lctl set_param fail_loc=0
14319 /bin/ls $DIR/$tdir || error "ls $DIR/$tdir failed"
14321 run_test 242 "mdt_readpage failure should not cause directory unreadable"
14325 test_mkdir -p $DIR/$tdir
14326 group_lock_test -d $DIR/$tdir || error "A group lock test failed"
14328 run_test 243 "various group lock tests"
14332 test_mkdir -p $DIR/$tdir
14333 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=35
14334 sendfile_grouplock $DIR/$tdir/$tfile || \
14335 error "sendfile+grouplock failed"
14338 run_test 244 "sendfile with group lock tests"
14341 local flagname="multi_mod_rpcs"
14342 local connect_data_name="max_mod_rpcs"
14345 # check if multiple modify RPCs flag is set
14346 out=$($LCTL get_param mdc.$FSNAME-MDT0000-*.import |
14347 grep "connect_flags:")
14350 echo "$out" | grep -qw $flagname
14351 if [ $? -ne 0 ]; then
14352 echo "connect flag $flagname is not set"
14356 # check if multiple modify RPCs data is set
14357 out=$($LCTL get_param mdc.$FSNAME-MDT0000-*.import)
14360 echo "$out" | grep -qw $connect_data_name ||
14361 error "import should have connect data $connect_data_name"
14363 run_test 245 "check mdc connection flag/data: multiple modify RPCs"
14365 test_246() { # LU-7371
14366 remote_ost_nodsh && skip "remote OST with nodsh" && return
14367 [ $(lustre_version_code ost1) -lt $(version_code 2.7.62) ] &&
14368 skip "Need OST version >= 2.7.62" && return 0
14369 do_facet ost1 $LCTL set_param fail_val=4095
14370 #define OBD_FAIL_OST_READ_SIZE 0x234
14371 do_facet ost1 $LCTL set_param fail_loc=0x234
14372 $LFS setstripe $DIR/$tfile -i 0 -c 1
14373 dd if=/dev/zero of=$DIR/$tfile bs=4095 count=1 > /dev/null 2>&1
14374 cancel_lru_locks $FSNAME-OST0000
14375 dd if=$DIR/$tfile of=/dev/null bs=1048576 || error "Read failed"
14377 run_test 246 "Read file of size 4095 should return right length"
14380 lctl get_param -n mdc.$FSNAME-MDT0000*.import |
14382 { skip "Fileset feature is not supported"; return; }
14384 local submount=${MOUNT}_$tdir
14387 mkdir -p $submount || error "mkdir $submount failed"
14388 FILESET="$FILESET/$tdir" mount_client $submount ||
14389 error "mount $submount failed"
14390 echo foo > $submount/$tfile || error "write $submount/$tfile failed"
14391 [ $(cat $MOUNT/$tdir/$tfile) = "foo" ] ||
14392 error "read $MOUNT/$tdir/$tfile failed"
14393 umount_client $submount || error "umount $submount failed"
14396 run_test 247a "mount subdir as fileset"
14399 lctl get_param -n mdc.$FSNAME-MDT0000*.import | grep -q subtree ||
14400 { skip "Fileset feature is not supported"; return; }
14402 local submount=${MOUNT}_$tdir
14404 rm -rf $MOUNT/$tdir
14405 mkdir -p $submount || error "mkdir $submount failed"
14407 FILESET="$FILESET/$tdir" mount_client $submount &&
14408 error "mount $submount should fail"
14411 run_test 247b "mount subdir that dose not exist"
14414 lctl get_param -n mdc.$FSNAME-MDT0000*.import | grep -q subtree ||
14415 { skip "Fileset feature is not supported"; return; }
14417 local submount=${MOUNT}_$tdir
14419 mkdir -p $MOUNT/$tdir/dir1
14420 mkdir -p $submount || error "mkdir $submount failed"
14421 FILESET="$FILESET/$tdir" mount_client $submount ||
14422 error "mount $submount failed"
14423 local fid=$($LFS path2fid $MOUNT/)
14424 $LFS fid2path $submount $fid && error "fid2path should fail"
14425 umount_client $submount || error "umount $submount failed"
14428 run_test 247c "running fid2path outside root"
14431 lctl get_param -n mdc.$FSNAME-MDT0000*.import | grep -q subtree ||
14432 { skip "Fileset feature is not supported"; return; }
14434 local submount=${MOUNT}_$tdir
14436 mkdir -p $MOUNT/$tdir/dir1
14437 mkdir -p $submount || error "mkdir $submount failed"
14438 FILESET="$FILESET/$tdir" mount_client $submount ||
14439 error "mount $submount failed"
14440 local fid=$($LFS path2fid $submount/dir1)
14441 $LFS fid2path $submount $fid || error "fid2path should succeed"
14442 umount_client $submount || error "umount $submount failed"
14445 run_test 247d "running fid2path inside root"
14449 lctl get_param -n mdc.$FSNAME-MDT0000*.import |
14451 { skip "Fileset feature is not supported"; return; }
14453 local submount=${MOUNT}_$tdir
14456 mkdir -p $submount || error "mkdir $submount failed"
14457 FILESET="$FILESET/.." mount_client $submount &&
14458 error "mount $submount should fail"
14461 run_test 247e "mount .. as fileset"
14464 local fast_read_sav=$($LCTL get_param -n llite.*.fast_read 2>/dev/null)
14465 [ -z "$fast_read_sav" ] && skip "no fast read support" && return
14467 # create a large file for fast read verification
14468 dd if=/dev/zero of=$DIR/$tfile bs=1M count=128 > /dev/null 2>&1
14470 # make sure the file is created correctly
14471 $CHECKSTAT -s $((128*1024*1024)) $DIR/$tfile ||
14472 { rm -f $DIR/$tfile; skip "file creation error" && return; }
14474 echo "Test 1: verify that fast read is 4 times faster on cache read"
14476 # small read with fast read enabled
14477 $LCTL set_param -n llite.*.fast_read=1
14478 local t_fast=$(dd if=$DIR/$tfile of=/dev/null bs=4k 2>&1 |
14479 egrep -o '([[:digit:]\.\,e-]+) s' | cut -d's' -f1 |
14480 sed -e 's/,/./' -e 's/[eE]+*/\*10\^/')
14481 # small read with fast read disabled
14482 $LCTL set_param -n llite.*.fast_read=0
14483 local t_slow=$(dd if=$DIR/$tfile of=/dev/null bs=4k 2>&1 |
14484 egrep -o '([[:digit:]\.\,e-]+) s' | cut -d's' -f1 |
14485 sed -e 's/,/./' -e 's/[eE]+*/\*10\^/')
14487 # verify that fast read is 4 times faster for cache read
14488 [ $(bc <<< "4 * $t_fast < $t_slow") -eq 1 ] ||
14489 error_not_in_vm "fast read was not 4 times faster: " \
14490 "$t_fast vs $t_slow"
14492 echo "Test 2: verify the performance between big and small read"
14493 $LCTL set_param -n llite.*.fast_read=1
14495 # 1k non-cache read
14496 cancel_lru_locks osc
14497 local t_1k=$(dd if=$DIR/$tfile of=/dev/null bs=1k 2>&1 |
14498 egrep -o '([[:digit:]\.\,e-]+) s' | cut -d's' -f1 |
14499 sed -e 's/,/./' -e 's/[eE]+*/\*10\^/')
14501 # 1M non-cache read
14502 cancel_lru_locks osc
14503 local t_1m=$(dd if=$DIR/$tfile of=/dev/null bs=1k 2>&1 |
14504 egrep -o '([[:digit:]\.\,e-]+) s' | cut -d's' -f1 |
14505 sed -e 's/,/./' -e 's/[eE]+*/\*10\^/')
14507 # verify that big IO is not 4 times faster than small IO
14508 [ $(bc <<< "4 * $t_1k >= $t_1m") -eq 1 ] ||
14509 error_not_in_vm "bigger IO is way too fast: $t_1k vs $t_1m"
14511 $LCTL set_param -n llite.*.fast_read=$fast_read_sav
14514 run_test 248 "fast read verification"
14516 test_249() { # LU-7890
14518 $SETSTRIPE -c 1 $DIR/$tfile
14520 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.8.53) ] &&
14521 skip "Need at least version 2.8.54"
14523 # Offset 2T == 4k * 512M
14524 dd if=/dev/zero of=$DIR/$tfile bs=4k count=1 seek=512M ||
14525 error "dd to 2T offset failed"
14527 run_test 249 "Write above 2T file size"
14530 [ "$(facet_fstype ost$(($($GETSTRIPE -i $DIR/$tfile) + 1)))" = "zfs" ] \
14531 && skip "no 16TB file size limit on ZFS" && return
14533 $SETSTRIPE -c 1 $DIR/$tfile
14534 # ldiskfs extent file size limit is (16TB - 4KB - 1) bytes
14535 local size=$((16 * 1024 * 1024 * 1024 * 1024 - 4096 - 1))
14536 $TRUNCATE $DIR/$tfile $size || error "truncate $tfile to $size failed"
14537 dd if=/dev/zero of=$DIR/$tfile bs=10 count=1 oflag=append \
14538 conv=notrunc,fsync && error "append succeeded"
14541 run_test 250 "Write above 16T limit"
14544 $SETSTRIPE -c -1 -S 1048576 $DIR/$tfile
14546 #define OBD_FAIL_LLITE_LOST_LAYOUT 0x1407
14547 #Skip once - writing the first stripe will succeed
14548 $LCTL set_param fail_loc=0xa0001407 fail_val=1
14549 $MULTIOP $DIR/$tfile o:O_RDWR:w2097152c 2>&1 | grep -q "short write" &&
14550 error "short write happened"
14552 $LCTL set_param fail_loc=0xa0001407 fail_val=1
14553 $MULTIOP $DIR/$tfile or2097152c 2>&1 | grep -q "short read" &&
14554 error "short read happened"
14558 run_test 251 "Handling short read and write correctly"
14568 remote_mds_nodsh && skip "remote MDS with nodsh" && return
14569 remote_ost_nodsh && skip "remote OST with nodsh" && return
14570 if [ "$(facet_fstype ost1)" != "ldiskfs" -o \
14571 "$(facet_fstype mds1)" != "ldiskfs" ]; then
14572 skip "ldiskfs only test"
14576 # check lr_reader on OST0000
14578 dev=$(facet_device $tgt)
14579 out=$(do_facet $tgt $LR_READER $dev)
14580 [ $? -eq 0 ] || error "$LR_READER failed on target $tgt device $dev"
14582 uuid=$(echo "$out" | grep -i uuid | awk '{ print $2 }')
14583 [ "$uuid" == "$(ostuuid_from_index 0)" ] ||
14584 error "Invalid uuid returned by $LR_READER on target $tgt"
14585 echo -e "uuid returned by $LR_READER is '$uuid'\n"
14587 # check lr_reader -c on MDT0000
14589 dev=$(facet_device $tgt)
14590 if ! do_facet $tgt $LR_READER -h | grep -q OPTIONS; then
14591 echo "$LR_READER does not support additional options"
14594 out=$(do_facet $tgt $LR_READER -c $dev)
14595 [ $? -eq 0 ] || error "$LR_READER failed on target $tgt device $dev"
14597 num=$(echo "$out" | grep -c "mdtlov")
14598 [ "$num" -eq $((MDSCOUNT - 1)) ] ||
14599 error "Invalid number of mdtlov clients returned by $LR_READER"
14600 echo -e "Number of mdtlov clients returned by $LR_READER is '$num'\n"
14602 # check lr_reader -cr on MDT0000
14603 out=$(do_facet $tgt $LR_READER -cr $dev)
14604 [ $? -eq 0 ] || error "$LR_READER failed on target $tgt device $dev"
14606 echo "$out" | grep -q "^reply_data:$" ||
14607 error "$LR_READER should have returned 'reply_data' section"
14608 num=$(echo "$out" | grep -c "client_generation")
14609 echo -e "Number of reply data returned by $LR_READER is '$num'\n"
14611 run_test 252 "check lr_reader tool"
14613 test_253_fill_ost() {
14614 local size_mb #how many MB should we write to pass watermark
14615 local lwm=$3 #low watermark
14616 local free_10mb #10% of free space
14618 free_kb=$($LFS df $MOUNT | grep $1 | awk '{ print $4 }')
14619 size_mb=$((free_kb / 1024 - lwm))
14620 free_10mb=$((free_kb / 10240))
14621 #If 10% of free space cross low watermark use it
14622 if (( free_10mb > size_mb )); then
14625 #At least we need to store 1.1 of difference between
14626 #free space and low watermark
14627 size_mb=$((size_mb + size_mb / 10))
14629 if (( lwm <= $((free_kb / 1024)) )) || [ ! -f $DIR/$tdir/1 ]; then
14630 dd if=/dev/zero of=$DIR/$tdir/1 bs=1M count=$size_mb \
14631 oflag=append conv=notrunc
14636 free_kb=$($LFS df $MOUNT | grep $1 | awk '{ print $4 }')
14637 echo "OST still has $((free_kb / 1024)) mbytes free"
14644 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
14645 remote_mds_nodsh && skip "remote MDS with nodsh" && return
14646 remote_mgs_nodsh && skip "remote MGS with nodsh" && return
14648 local ost_name=$($LFS osts |
14649 sed -n 's/^'$ostidx': \(.*\)_UUID .*/\1/p')
14651 local mdtosc_proc1=$(get_mdtosc_proc_path $SINGLEMDS $ost_name)
14652 do_facet $SINGLEMDS $LCTL get_param -n \
14653 osp.$mdtosc_proc1.reserved_mb_high ||
14654 { skip "remote MDS does not support reserved_mb_high" &&
14659 wait_delete_completed
14662 local last_wm_h=$(do_facet $SINGLEMDS $LCTL get_param -n \
14663 osp.$mdtosc_proc1.reserved_mb_high)
14664 local last_wm_l=$(do_facet $SINGLEMDS $LCTL get_param -n \
14665 osp.$mdtosc_proc1.reserved_mb_low)
14666 echo "prev high watermark $last_wm_h, prev low watermark $last_wm_l"
14668 create_pool $FSNAME.$TESTNAME || error "Pool creation failed"
14669 do_facet mgs $LCTL pool_add $FSNAME.$TESTNAME $ost_name ||
14670 error "Adding $ost_name to pool failed"
14672 # Wait for client to see a OST at pool
14673 wait_update $HOSTNAME "$LCTL get_param -n
14674 lov.$FSNAME-*.pools.$TESTNAME | sort -u |
14675 grep $ost_name" "$ost_name""_UUID" $((TIMEOUT/2)) ||
14676 error "Client can not see the pool"
14677 $SETSTRIPE $DIR/$tdir -i $ostidx -c 1 -p $FSNAME.$TESTNAME ||
14678 error "Setstripe failed"
14680 dd if=/dev/zero of=$DIR/$tdir/0 bs=1M count=10
14681 local blocks=$($LFS df $MOUNT | grep $ost_name | awk '{ print $4 }')
14682 echo "OST still has $((blocks/1024)) mbytes free"
14684 local new_lwm=$((blocks/1024-10))
14685 do_facet $SINGLEMDS $LCTL set_param \
14686 osp.$mdtosc_proc1.reserved_mb_high=$((new_lwm+5))
14687 do_facet $SINGLEMDS $LCTL set_param \
14688 osp.$mdtosc_proc1.reserved_mb_low=$new_lwm
14690 test_253_fill_ost $ost_name $mdtosc_proc1 $new_lwm
14692 #First enospc could execute orphan deletion so repeat.
14693 test_253_fill_ost $ost_name $mdtosc_proc1 $new_lwm
14695 local oa_status=$(do_facet $SINGLEMDS $LCTL get_param -n \
14696 osp.$mdtosc_proc1.prealloc_status)
14697 echo "prealloc_status $oa_status"
14699 dd if=/dev/zero of=$DIR/$tdir/2 bs=1M count=1 &&
14700 error "File creation should fail"
14701 #object allocation was stopped, but we still able to append files
14702 dd if=/dev/zero of=$DIR/$tdir/1 bs=1M seek=6 count=5 oflag=append ||
14703 error "Append failed"
14704 rm -f $DIR/$tdir/1 $DIR/$tdir/0 $DIR/$tdir/r*
14706 wait_delete_completed
14710 for i in $(seq 10 12); do
14711 dd if=/dev/zero of=$DIR/$tdir/$i bs=1M count=1 2>/dev/null ||
14712 error "File creation failed after rm";
14715 oa_status=$(do_facet $SINGLEMDS $LCTL get_param -n \
14716 osp.$mdtosc_proc1.prealloc_status)
14717 echo "prealloc_status $oa_status"
14719 if (( oa_status != 0 )); then
14720 error "Object allocation still disable after rm"
14722 do_facet $SINGLEMDS $LCTL set_param \
14723 osp.$mdtosc_proc1.reserved_mb_high=$last_wm_h
14724 do_facet $SINGLEMDS $LCTL set_param \
14725 osp.$mdtosc_proc1.reserved_mb_low=$last_wm_l
14728 do_facet mgs $LCTL pool_remove $FSNAME.$TESTNAME $ost_name ||
14729 error "Remove $ost_name from pool failed"
14730 do_facet mgs $LCTL pool_destroy $FSNAME.$TESTNAME ||
14731 error "Pool destroy fialed"
14733 run_test 253 "Check object allocation limit"
14738 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
14739 remote_mds_nodsh && skip "remote MDS with nodsh" && return
14740 do_facet mds1 $LCTL get_param -n mdd.$MDT0.changelog_size ||
14741 { skip "MDS does not support changelog_size" && return; }
14743 cl_user=$(do_facet mds1 $LCTL --device $MDT0 changelog_register -n)
14744 echo "Registered as changelog user $cl_user"
14746 $LFS changelog_clear $MDT0 $cl_user 0
14748 local size1=$(do_facet mds1 \
14749 $LCTL get_param -n mdd.$MDT0.changelog_size)
14750 echo "Changelog size $size1"
14753 $LFS mkdir -i 0 $DIR/$tdir
14755 mkdir -p $DIR/$tdir/pics/2008/zachy
14756 touch $DIR/$tdir/pics/2008/zachy/timestamp
14757 cp /etc/hosts $DIR/$tdir/pics/2008/zachy/pic1.jpg
14758 mv $DIR/$tdir/pics/2008/zachy $DIR/$tdir/pics/zach
14759 ln $DIR/$tdir/pics/zach/pic1.jpg $DIR/$tdir/pics/2008/portland.jpg
14760 ln -s $DIR/$tdir/pics/2008/portland.jpg $DIR/$tdir/pics/desktop.jpg
14761 rm $DIR/$tdir/pics/desktop.jpg
14763 local size2=$(do_facet mds1 \
14764 $LCTL get_param -n mdd.$MDT0.changelog_size)
14765 echo "Changelog size after work $size2"
14767 do_facet mds1 $LCTL --device $MDT0 changelog_deregister $cl_user
14769 if (( size2 <= size1 )); then
14770 error "Changelog size after work should be greater than original"
14774 run_test 254 "Check changelog size"
14781 lfs ladvise -a invalid $file 2>&1 | grep "Valid types" |
14782 awk -F: '{print $2}' | grep $type > /dev/null
14783 if [ $? -ne 0 ]; then
14793 lfs ladvise -a willread $file > /dev/null 2>&1
14794 if [ $? -eq 0 ]; then
14798 lfs ladvise -a willread $file 2>&1 |
14799 grep "Inappropriate ioctl for device" > /dev/null
14800 if [ $? -eq 0 ]; then
14807 bc <<<"scale=2; ($1 - $2) * 100 / $2"
14810 # run a random read IO workload
14811 # usage: random_read_iops <filename> <filesize> <iosize>
14812 random_read_iops() {
14815 local iosize=${3:-4096}
14817 $READS -f $file -s $fsize -b $iosize -n $((fsize / iosize)) -t 60 |
14818 sed -e '/^$/d' -e 's#.*s, ##' -e 's#MB/s##'
14821 drop_file_oss_cache() {
14825 $LFS ladvise -a dontneed $file 2>/dev/null ||
14826 do_nodes $nodes "echo 3 > /proc/sys/vm/drop_caches"
14829 ladvise_willread_performance()
14832 local average_origin=0
14833 local average_cache=0
14834 local average_ladvise=0
14836 for ((i = 1; i <= $repeat; i++)); do
14837 echo "Iter $i/$repeat: reading without willread hint"
14838 cancel_lru_locks osc
14839 drop_file_oss_cache $DIR/$tfile $(comma_list $(osts_nodes))
14840 local speed_origin=$(random_read_iops $DIR/$tfile $size)
14841 echo "Iter $i/$repeat: uncached speed: $speed_origin"
14842 average_origin=$(bc <<<"$average_origin + $speed_origin")
14844 cancel_lru_locks osc
14845 local speed_cache=$(random_read_iops $DIR/$tfile $size)
14846 echo "Iter $i/$repeat: OSS cache speed: $speed_cache"
14847 average_cache=$(bc <<<"$average_cache + $speed_cache")
14849 cancel_lru_locks osc
14850 drop_file_oss_cache $DIR/$tfile $(comma_list $(osts_nodes))
14851 $LFS ladvise -a willread $DIR/$tfile || error "ladvise failed"
14852 local speed_ladvise=$(random_read_iops $DIR/$tfile $size)
14853 echo "Iter $i/$repeat: ladvise speed: $speed_ladvise"
14854 average_ladvise=$(bc <<<"$average_ladvise + $speed_ladvise")
14856 average_origin=$(bc <<<"scale=2; $average_origin / $repeat")
14857 average_cache=$(bc <<<"scale=2; $average_cache / $repeat")
14858 average_ladvise=$(bc <<<"scale=2; $average_ladvise / $repeat")
14860 speedup_cache=$(percent $average_cache $average_origin)
14861 speedup_ladvise=$(percent $average_ladvise $average_origin)
14863 echo "Average uncached read: $average_origin"
14864 echo "Average speedup with OSS cached read: " \
14865 "$average_cache = +$speedup_cache%"
14866 echo "Average speedup with ladvise willread: " \
14867 "$average_ladvise = +$speedup_ladvise%"
14869 local lowest_speedup=20
14870 if [ ${average_cache%.*} -lt $lowest_speedup ]; then
14871 echo "Speedup with OSS cached read less than $lowest_speedup%, " \
14872 "got $average_cache%. Skipping ladvise willread check."
14876 # the test won't work on ZFS until it supports 'ladvise dontneed', but
14877 # it is still good to run until then to exercise 'ladvise willread'
14878 ! $LFS ladvise -a dontneed $DIR/$tfile &&
14879 [ "$(facet_fstype ost1)" = "zfs" ] &&
14880 echo "osd-zfs does not support dontneed or drop_caches" &&
14883 lowest_speedup=$(bc <<<"scale=2; $average_cache / 2")
14884 [ ${average_ladvise%.*} -gt $lowest_speedup ] ||
14885 error_not_in_vm "Speedup with willread is less than " \
14886 "$lowest_speedup%, got $average_ladvise%"
14890 [ $(lustre_version_code ost1) -lt $(version_code 2.8.54) ] &&
14891 skip "lustre < 2.8.54 does not support ladvise " && return
14892 remote_ost_nodsh && skip "remote OST with nodsh" && return
14894 lfs setstripe -c -1 -i 0 $DIR/$tfile || error "$tfile failed"
14896 ladvise_no_type willread $DIR/$tfile &&
14897 skip "willread ladvise is not supported" && return
14899 ladvise_no_ioctl $DIR/$tfile &&
14900 skip "ladvise ioctl is not supported" && return
14903 local size=$((size_mb * 1048576))
14904 dd if=/dev/zero of=$DIR/$tfile bs=1048576 count=$size_mb ||
14905 error "dd to $DIR/$tfile failed"
14907 lfs ladvise -a willread $DIR/$tfile ||
14908 error "Ladvise failed with no range argument"
14910 lfs ladvise -a willread -s 0 $DIR/$tfile ||
14911 error "Ladvise failed with no -l or -e argument"
14913 lfs ladvise -a willread -e 1 $DIR/$tfile ||
14914 error "Ladvise failed with only -e argument"
14916 lfs ladvise -a willread -l 1 $DIR/$tfile ||
14917 error "Ladvise failed with only -l argument"
14919 lfs ladvise -a willread -s 2 -e 1 $DIR/$tfile &&
14920 error "End offset should not be smaller than start offset"
14922 lfs ladvise -a willread -s 2 -e 2 $DIR/$tfile &&
14923 error "End offset should not be equal to start offset"
14925 lfs ladvise -a willread -s $size -l 1 $DIR/$tfile ||
14926 error "Ladvise failed with overflowing -s argument"
14928 lfs ladvise -a willread -s 1 -e $((size + 1)) $DIR/$tfile ||
14929 error "Ladvise failed with overflowing -e argument"
14931 lfs ladvise -a willread -s 1 -l $size $DIR/$tfile ||
14932 error "Ladvise failed with overflowing -l argument"
14934 lfs ladvise -a willread -l 1 -e 2 $DIR/$tfile &&
14935 error "Ladvise succeeded with conflicting -l and -e arguments"
14937 echo "Synchronous ladvise should wait"
14939 #define OBD_FAIL_OST_LADVISE_PAUSE 0x237
14940 do_nodes $(comma_list $(osts_nodes)) \
14941 $LCTL set_param fail_val=$delay fail_loc=0x237
14943 local start_ts=$SECONDS
14944 lfs ladvise -a willread $DIR/$tfile ||
14945 error "Ladvise failed with no range argument"
14946 local end_ts=$SECONDS
14947 local inteval_ts=$((end_ts - start_ts))
14949 if [ $inteval_ts -lt $(($delay - 1)) ]; then
14950 error "Synchronous advice didn't wait reply"
14953 echo "Asynchronous ladvise shouldn't wait"
14954 local start_ts=$SECONDS
14955 lfs ladvise -a willread -b $DIR/$tfile ||
14956 error "Ladvise failed with no range argument"
14957 local end_ts=$SECONDS
14958 local inteval_ts=$((end_ts - start_ts))
14960 if [ $inteval_ts -gt $(($delay / 2)) ]; then
14961 error "Asynchronous advice blocked"
14964 do_nodes $(comma_list $(osts_nodes)) $LCTL set_param fail_loc=0
14965 ladvise_willread_performance
14967 run_test 255a "check 'lfs ladvise -a willread'"
14973 do_facet $facet "cat /proc/meminfo | grep ^${info}:" | awk '{print $2}'
14977 remote_ost_nodsh && skip "remote OST with nodsh" && return
14979 lfs setstripe -c 1 -i 0 $DIR/$tfile
14981 ladvise_no_type dontneed $DIR/$tfile &&
14982 skip "dontneed ladvise is not supported" && return
14984 ladvise_no_ioctl $DIR/$tfile &&
14985 skip "ladvise ioctl is not supported" && return
14987 [ $(lustre_version_code ost1) -lt $(version_code 2.8.54) ] &&
14988 skip "lustre < 2.8.54 does not support ladvise" && return
14990 ! $LFS ladvise -a dontneed $DIR/$tfile &&
14991 [ "$(facet_fstype ost1)" = "zfs" ] &&
14992 skip "zfs-osd does not support 'ladvise dontneed'" && return
14995 local size=$((size_mb * 1048576))
14996 # In order to prevent disturbance of other processes, only check 3/4
14997 # of the memory usage
14998 local kibibytes=$((size_mb * 1024 * 3 / 4))
15000 dd if=/dev/zero of=$DIR/$tfile bs=1048576 count=$size_mb ||
15001 error "dd to $DIR/$tfile failed"
15003 local total=$(facet_meminfo ost1 MemTotal)
15004 echo "Total memory: $total KiB"
15006 do_facet ost1 "sync && echo 3 > /proc/sys/vm/drop_caches"
15007 local before_read=$(facet_meminfo ost1 Cached)
15008 echo "Cache used before read: $before_read KiB"
15010 lfs ladvise -a willread $DIR/$tfile ||
15011 error "Ladvise willread failed"
15012 local after_read=$(facet_meminfo ost1 Cached)
15013 echo "Cache used after read: $after_read KiB"
15015 lfs ladvise -a dontneed $DIR/$tfile ||
15016 error "Ladvise dontneed again failed"
15017 local no_read=$(facet_meminfo ost1 Cached)
15018 echo "Cache used after dontneed ladvise: $no_read KiB"
15020 if [ $total -lt $((before_read + kibibytes)) ]; then
15021 echo "Memory is too small, abort checking"
15025 if [ $((before_read + kibibytes)) -gt $after_read ]; then
15026 error "Ladvise willread should use more memory" \
15027 "than $kibibytes KiB"
15030 if [ $((no_read + kibibytes)) -gt $after_read ]; then
15031 error "Ladvise dontneed should release more memory" \
15032 "than $kibibytes KiB"
15035 run_test 255b "check 'lfs ladvise -a dontneed'"
15042 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
15043 remote_mds_nodsh && skip "remote MDS with nodsh" && return
15044 [ "$(facet_fstype mds1)" != "ldiskfs" ] &&
15045 skip "ldiskfs only test" && return
15047 mdt_dev=$(mdsdevname 1)
15049 cl_user=$(do_facet mds1 \
15050 "$LCTL get_param -n mdd.$MDT0.changelog_users | grep cl")
15051 if [[ -n $cl_user ]]; then
15052 skip "active changelog user"
15056 cl_user=$(do_facet mds1 $LCTL --device $MDT0 changelog_register -n)
15057 echo "Registered as changelog user $cl_user"
15060 mkdir -p $DIR/$tdir
15062 $LFS changelog_clear $MDT0 $cl_user 0
15065 touch $DIR/$tdir/{1..10}
15068 stop mds1 || error "Fail to stop MDT."
15071 start mds1 $mdt_dev $MDS_MOUNT_OPTS || error "Fail to start MDT."
15073 #after mount new plainllog is used
15074 touch $DIR/$tdir/{11..19}
15075 local TEMP256FILE=$(mktemp TEMP256XXXXXX)
15076 cat_sl=$(do_facet mds1 \
15077 "$DEBUGFS -R \\\"dump changelog_catalog $TEMP256FILE\\\" $mdt_dev; \
15078 llog_reader $TEMP256FILE | grep \\\"type=1064553b\\\" | wc -l")
15081 if (( cat_sl != 2 )); then
15082 do_facet mds1 $LCTL --device $MDT0 changelog_deregister $cl_user
15083 error "Changelog catalog has wrong number of slots $cat_sl"
15086 $LFS changelog_clear $MDT0 $cl_user 0
15088 TEMP256FILE=$(mktemp TEMP256XXXXXX)
15089 cat_sl=$(do_facet mds1 \
15090 "$DEBUGFS -R \\\"dump changelog_catalog $TEMP256FILE\\\" $mdt_dev; \
15091 llog_reader $TEMP256FILE | grep \\\"type=1064553b\\\" | wc -l")
15094 do_facet mds1 $LCTL --device $MDT0 changelog_deregister $cl_user
15096 if (( cat_sl == 2 )); then
15097 error "Empty plain llog was not deleted from changelog catalog"
15099 if (( cat_sl != 1 )); then
15100 error "Active plain llog shouldn\`t be deleted from catalog"
15103 run_test 256 "Check llog delete for empty and not full state"
15106 remote_mds_nodsh && skip "remote MDS with nodsh" && return
15107 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.8.55) ]] &&
15108 skip "Need MDS version at least 2.8.55" && return
15110 test_mkdir -p $DIR/$tdir
15112 setfattr -n trusted.name1 -v value1 $DIR/$tdir ||
15113 error "setfattr -n trusted.name1=value1 $DIR/$tdir failed"
15116 #define OBD_FAIL_MDS_XATTR_REP 0x161
15117 local mdtidx=$($LFS getstripe -M $DIR/$tdir)
15118 local facet=mds$((mdtidx + 1))
15119 set_nodes_failloc $(facet_active_host $facet) 0x80000161
15120 getfattr -n trusted.name1 $DIR/$tdir 2> /dev/null
15122 stop $facet || error "stop MDS failed"
15123 start $facet $(mdsdevname $((mdtidx + 1))) $MDS_MOUNT_OPTS ||
15124 error "start MDS fail"
15126 run_test 257 "xattr locks are not lost"
15128 # Verify we take the i_mutex when security requires it
15130 #define OBD_FAIL_IMUTEX_SEC 0x141c
15131 $LCTL set_param fail_loc=0x141c
15133 chmod u+s $DIR/$tfile
15134 chmod a+rwx $DIR/$tfile
15135 $RUNAS dd if=/dev/zero of=$DIR/$tfile bs=4k count=1 oflag=append
15137 if [ $RC -ne 0 ]; then
15138 error "error, failed to take i_mutex, rc=$?"
15144 # Verify we do NOT take the i_mutex in the normal case
15146 #define OBD_FAIL_IMUTEX_NOSEC 0x141d
15147 $LCTL set_param fail_loc=0x141d
15150 chmod a+rw $DIR/$tfile
15151 $RUNAS dd if=/dev/zero of=$DIR/$tfile bs=4k count=1 oflag=append
15153 if [ $RC -ne 0 ]; then
15154 error "error, took i_mutex unnecessarily, rc=$?"
15159 run_test 258b "verify i_mutex security behavior"
15162 #define OBD_FAIL_MDC_CLOSE 0x806
15163 $LCTL set_param fail_loc=0x80000806
15167 run_test 260 "Check mdc_close fail"
15169 cleanup_test_300() {
15173 test_striped_dir() {
15178 mkdir -p $DIR/$tdir
15180 SAVE_UMASK=$(umask)
15181 trap cleanup_test_300 RETURN EXIT
15183 $LFS setdirstripe -i $mdt_index -c 2 -t all_char -m 755 \
15184 $DIR/$tdir/striped_dir ||
15185 error "set striped dir error"
15187 local mode=$(stat -c%a $DIR/$tdir/striped_dir)
15188 [ "$mode" = "755" ] || error "expect 755 got $mode"
15190 $LFS getdirstripe $DIR/$tdir/striped_dir > /dev/null 2>&1 ||
15191 error "getdirstripe failed"
15192 stripe_count=$($LFS getdirstripe -c $DIR/$tdir/striped_dir)
15193 if [ "$stripe_count" != "2" ]; then
15194 error "1:stripe_count is $stripe_count, expect 2"
15196 stripe_count=$($LFS getdirstripe -T $DIR/$tdir/striped_dir)
15197 if [ "$stripe_count" != "2" ]; then
15198 error "2:stripe_count is $stripe_count, expect 2"
15201 stripe_index=$($LFS getdirstripe -i $DIR/$tdir/striped_dir)
15202 if [ "$stripe_index" != "$mdt_index" ]; then
15203 error "stripe_index is $stripe_index, expect $mdt_index"
15206 [ $(stat -c%h $DIR/$tdir/striped_dir) == '2' ] ||
15207 error "nlink error after create striped dir"
15209 mkdir $DIR/$tdir/striped_dir/a
15210 mkdir $DIR/$tdir/striped_dir/b
15212 stat $DIR/$tdir/striped_dir/a ||
15213 error "create dir under striped dir failed"
15214 stat $DIR/$tdir/striped_dir/b ||
15215 error "create dir under striped dir failed"
15217 [ $(stat -c%h $DIR/$tdir/striped_dir) == '4' ] ||
15218 error "nlink error after mkdir"
15220 rmdir $DIR/$tdir/striped_dir/a
15221 [ $(stat -c%h $DIR/$tdir/striped_dir) == '3' ] ||
15222 error "nlink error after rmdir"
15224 rmdir $DIR/$tdir/striped_dir/b
15225 [ $(stat -c%h $DIR/$tdir/striped_dir) == '2' ] ||
15226 error "nlink error after rmdir"
15228 chattr +i $DIR/$tdir/striped_dir
15229 createmany -o $DIR/$tdir/striped_dir/f 10 &&
15230 error "immutable flags not working under striped dir!"
15231 chattr -i $DIR/$tdir/striped_dir
15233 rmdir $DIR/$tdir/striped_dir ||
15234 error "rmdir striped dir error"
15242 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.0) ] &&
15243 skip "skipped for lustre < 2.7.0" && return
15244 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
15245 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
15247 test_striped_dir 0 || error "failed on striped dir on MDT0"
15248 test_striped_dir 1 || error "failed on striped dir on MDT0"
15250 run_test 300a "basic striped dir sanity test"
15253 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.0) ] &&
15254 skip "skipped for lustre < 2.7.0" && return
15255 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
15256 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
15262 test_mkdir $DIR/$tdir || error "mkdir fail"
15263 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir ||
15264 error "set striped dir error"
15265 for ((i=0; i<10; i++)); do
15266 mtime1=$(stat -c %Y $DIR/$tdir/striped_dir)
15268 touch $DIR/$tdir/striped_dir/file_$i ||
15269 error "touch error $i"
15270 mtime2=$(stat -c %Y $DIR/$tdir/striped_dir)
15271 [ $mtime1 -eq $mtime2 ] &&
15272 error "mtime not change after create"
15274 rm -f $DIR/$tdir/striped_dir/file_$i ||
15275 error "unlink error $i"
15276 mtime3=$(stat -c %Y $DIR/$tdir/striped_dir)
15277 [ $mtime2 -eq $mtime3 ] &&
15278 error "mtime did not change after unlink"
15282 run_test 300b "check ctime/mtime for striped dir"
15285 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.0) ] &&
15286 skip "skipped for lustre < 2.7.0" && return
15287 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
15288 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
15291 mkdir -p $DIR/$tdir
15292 $LFS setdirstripe -i 0 -c 2 $DIR/$tdir/striped_dir ||
15293 error "set striped dir error"
15295 chown $RUNAS_ID:$RUNAS_GID $DIR/$tdir/striped_dir ||
15296 error "chown striped dir failed"
15298 $RUNAS createmany -o $DIR/$tdir/striped_dir/f 5000 ||
15299 error "create 5k files failed"
15301 file_count=$(ls $DIR/$tdir/striped_dir | wc -l)
15303 [ "$file_count" = 5000 ] || error "file count $file_count != 5000"
15307 run_test 300c "chown && check ls under striped directory"
15310 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.0) ] &&
15311 skip "skipped for lustre < 2.7.0" && return
15312 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
15313 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
15317 mkdir -p $DIR/$tdir
15318 $SETSTRIPE -c 2 $DIR/$tdir
15320 #local striped directory
15321 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir ||
15322 error "set striped dir error"
15323 createmany -o $DIR/$tdir/striped_dir/f 10 ||
15324 error "create 10 files failed"
15326 #remote striped directory
15327 $LFS setdirstripe -i 1 -c 2 $DIR/$tdir/remote_striped_dir ||
15328 error "set striped dir error"
15329 createmany -o $DIR/$tdir/remote_striped_dir/f 10 ||
15330 error "create 10 files failed"
15332 for file in $(find $DIR/$tdir); do
15333 stripe_count=$($GETSTRIPE -c $file)
15334 [ $stripe_count -eq 2 ] ||
15335 error "wrong stripe $stripe_count for $file"
15340 run_test 300d "check default stripe under striped directory"
15343 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
15344 skip "Need MDS version at least 2.7.55" && return
15345 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
15346 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
15350 mkdir -p $DIR/$tdir
15352 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir ||
15353 error "set striped dir error"
15355 touch $DIR/$tdir/striped_dir/a
15356 touch $DIR/$tdir/striped_dir/b
15357 touch $DIR/$tdir/striped_dir/c
15359 mkdir $DIR/$tdir/striped_dir/dir_a
15360 mkdir $DIR/$tdir/striped_dir/dir_b
15361 mkdir $DIR/$tdir/striped_dir/dir_c
15363 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir/stp_a ||
15364 error "set striped adir under striped dir error"
15366 $LFS setdirstripe -i 0 -c 2 -H all_char $DIR/$tdir/striped_dir/stp_b ||
15367 error "set striped bdir under striped dir error"
15369 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir/stp_c ||
15370 error "set striped cdir under striped dir error"
15372 mrename $DIR/$tdir/striped_dir/dir_a $DIR/$tdir/striped_dir/dir_b ||
15373 error "rename dir under striped dir fails"
15375 mrename $DIR/$tdir/striped_dir/stp_a $DIR/$tdir/striped_dir/stp_b ||
15376 error "rename dir under different stripes fails"
15378 mrename $DIR/$tdir/striped_dir/a $DIR/$tdir/striped_dir/c ||
15379 error "rename file under striped dir should succeed"
15381 mrename $DIR/$tdir/striped_dir/dir_b $DIR/$tdir/striped_dir/dir_c ||
15382 error "rename dir under striped dir should succeed"
15386 run_test 300e "check rename under striped directory"
15389 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
15390 skip "Need MDS version at least 2.7.55" && return
15391 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
15392 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
15397 mkdir -p $DIR/$tdir
15399 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir ||
15400 error "set striped dir error"
15402 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir1 ||
15403 error "set striped dir error"
15405 touch $DIR/$tdir/striped_dir/a
15406 mkdir $DIR/$tdir/striped_dir/dir_a
15407 $LFS setdirstripe -i 0 -c 2 $DIR/$tdir/striped_dir/stp_a ||
15408 error "create striped dir under striped dir fails"
15410 touch $DIR/$tdir/striped_dir1/b
15411 mkdir $DIR/$tdir/striped_dir1/dir_b
15412 $LFS setdirstripe -i 0 -c 2 $DIR/$tdir/striped_dir/stp_b ||
15413 error "create striped dir under striped dir fails"
15415 mrename $DIR/$tdir/striped_dir/dir_a $DIR/$tdir/striped_dir1/dir_b ||
15416 error "rename dir under different striped dir should fail"
15418 mrename $DIR/$tdir/striped_dir/stp_a $DIR/$tdir/striped_dir1/stp_b ||
15419 error "rename striped dir under diff striped dir should fail"
15421 mrename $DIR/$tdir/striped_dir/a $DIR/$tdir/striped_dir1/a ||
15422 error "rename file under diff striped dirs fails"
15426 run_test 300f "check rename cross striped directory"
15428 test_300_check_default_striped_dir()
15431 local default_count=$2
15432 local default_index=$3
15435 local dir_stripe_index
15438 echo "checking $dirname $default_count $default_index"
15439 $LFS setdirstripe -D -c $default_count -i $default_index \
15440 -t all_char $DIR/$tdir/$dirname ||
15441 error "set default stripe on striped dir error"
15442 stripe_count=$($LFS getdirstripe -D -c $DIR/$tdir/$dirname)
15443 [ $stripe_count -eq $default_count ] ||
15444 error "expect $default_count get $stripe_count for $dirname"
15446 stripe_index=$($LFS getdirstripe -D -i $DIR/$tdir/$dirname)
15447 [ $stripe_index -eq $default_index ] ||
15448 error "expect $default_index get $stripe_index for $dirname"
15450 mkdir $DIR/$tdir/$dirname/{test1,test2,test3,test4} ||
15451 error "create dirs failed"
15453 createmany -o $DIR/$tdir/$dirname/f- 10 || error "create files failed"
15454 unlinkmany $DIR/$tdir/$dirname/f- 10 || error "unlink files failed"
15455 for dir in $(find $DIR/$tdir/$dirname/*); do
15456 stripe_count=$($LFS getdirstripe -c $dir)
15457 [ $stripe_count -eq $default_count ] ||
15458 [ $stripe_count -eq 0 -o $default_count -eq 1 ] ||
15459 error "stripe count $default_count != $stripe_count for $dir"
15461 stripe_index=$($LFS getdirstripe -i $dir)
15462 [ $default_index -eq -1 -o $stripe_index -eq $default_index ] ||
15463 error "$stripe_index != $default_index for $dir"
15465 #check default stripe
15466 stripe_count=$($LFS getdirstripe -D -c $dir)
15467 [ $stripe_count -eq $default_count ] ||
15468 error "default count $default_count != $stripe_count for $dir"
15470 stripe_index=$($LFS getdirstripe -D -i $dir)
15471 [ $stripe_index -eq $default_index ] ||
15472 error "default index $default_index != $stripe_index for $dir"
15474 rmdir $DIR/$tdir/$dirname/* || error "rmdir failed"
15478 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
15479 skip "Need MDS version at least 2.7.55" && return
15480 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
15486 mkdir $DIR/$tdir/normal_dir
15488 #Checking when client cache stripe index
15489 $LFS setdirstripe -c$MDSCOUNT $DIR/$tdir/striped_dir
15490 $LFS setdirstripe -D -i1 $DIR/$tdir/striped_dir ||
15491 error "create striped_dir failed"
15493 mkdir $DIR/$tdir/striped_dir/dir1 ||
15494 error "create dir1 fails"
15495 stripe_index=$($LFS getdirstripe -i $DIR/$tdir/striped_dir/dir1)
15496 [ $stripe_index -eq 1 ] ||
15497 error "dir1 expect 1 got $stripe_index"
15499 $LFS setdirstripe -i2 $DIR/$tdir/striped_dir/dir2 ||
15500 error "create dir2 fails"
15501 stripe_index=$($LFS getdirstripe -i $DIR/$tdir/striped_dir/dir2)
15502 [ $stripe_index -eq 2 ] ||
15503 error "dir2 expect 2 got $stripe_index"
15505 #check default stripe count/stripe index
15506 test_300_check_default_striped_dir normal_dir $MDSCOUNT 1
15507 test_300_check_default_striped_dir normal_dir 1 0
15508 test_300_check_default_striped_dir normal_dir 2 1
15509 test_300_check_default_striped_dir normal_dir 2 -1
15511 #delete default stripe information
15512 echo "delete default stripeEA"
15513 $LFS setdirstripe -d $DIR/$tdir/normal_dir ||
15514 error "set default stripe on striped dir error"
15516 mkdir -p $DIR/$tdir/normal_dir/{test1,test2,test3,test4}
15517 for dir in $(find $DIR/$tdir/normal_dir/*); do
15518 stripe_count=$($LFS getdirstripe -c $dir)
15519 [ $stripe_count -eq 0 ] ||
15520 error "expect 1 get $stripe_count for $dir"
15521 stripe_index=$($LFS getdirstripe -i $dir)
15522 [ $stripe_index -eq 0 ] ||
15523 error "expect 0 get $stripe_index for $dir"
15526 run_test 300g "check default striped directory for normal directory"
15529 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
15530 skip "Need MDS version at least 2.7.55" && return
15531 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
15536 $LFS setdirstripe -i 0 -c $MDSCOUNT -t all_char \
15537 $DIR/$tdir/striped_dir ||
15538 error "set striped dir error"
15540 test_300_check_default_striped_dir striped_dir $MDSCOUNT 1
15541 test_300_check_default_striped_dir striped_dir 1 0
15542 test_300_check_default_striped_dir striped_dir 2 1
15543 test_300_check_default_striped_dir striped_dir 2 -1
15545 #delete default stripe information
15546 $LFS setdirstripe -d $DIR/$tdir/striped_dir ||
15547 error "set default stripe on striped dir error"
15549 mkdir -p $DIR/$tdir/striped_dir/{test1,test2,test3,test4}
15550 for dir in $(find $DIR/$tdir/striped_dir/*); do
15551 stripe_count=$($LFS getdirstripe -c $dir)
15552 [ $stripe_count -eq 0 ] ||
15553 error "expect 1 get $stripe_count for $dir"
15556 run_test 300h "check default striped directory for striped directory"
15559 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
15560 skip "Need MDS version at least 2.7.55" && return
15561 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
15562 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
15568 $LFS setdirstripe -i 0 -c$MDSCOUNT -t all_char $DIR/$tdir/striped_dir ||
15569 error "set striped dir error"
15571 createmany -o $DIR/$tdir/striped_dir/f- 10 ||
15572 error "create files under striped dir failed"
15574 $LFS setdirstripe -i0 -c$MDSCOUNT -H all_char $DIR/$tdir/hashdir ||
15575 error "set striped hashdir error"
15577 $LFS setdirstripe -i0 -c$MDSCOUNT -H all_char $DIR/$tdir/hashdir/d0 ||
15578 error "create dir0 under hash dir failed"
15579 $LFS setdirstripe -i0 -c$MDSCOUNT -H fnv_1a_64 $DIR/$tdir/hashdir/d1 ||
15580 error "create dir1 under hash dir failed"
15582 # unfortunately, we need to umount to clear dir layout cache for now
15583 # once we fully implement dir layout, we can drop this
15584 umount_client $MOUNT || error "umount failed"
15585 mount_client $MOUNT || error "mount failed"
15587 $LFS find -H fnv_1a_64 $DIR/$tdir/hashdir
15588 local dircnt=$($LFS find -H fnv_1a_64 $DIR/$tdir/hashdir | wc -l)
15589 [ $dircnt -eq 1 ] || error "lfs find striped dir got:$dircnt,except:1"
15591 #set the stripe to be unknown hash type
15592 #define OBD_FAIL_UNKNOWN_LMV_STRIPE 0x1901
15593 $LCTL set_param fail_loc=0x1901
15594 for ((i = 0; i < 10; i++)); do
15595 $CHECKSTAT -t file $DIR/$tdir/striped_dir/f-$i ||
15596 error "stat f-$i failed"
15597 rm $DIR/$tdir/striped_dir/f-$i || error "unlink f-$i failed"
15600 touch $DIR/$tdir/striped_dir/f0 &&
15601 error "create under striped dir with unknown hash should fail"
15603 $LCTL set_param fail_loc=0
15605 umount_client $MOUNT || error "umount failed"
15606 mount_client $MOUNT || error "mount failed"
15610 run_test 300i "client handle unknown hash type striped directory"
15613 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
15614 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
15615 skip "Need MDS version at least 2.7.55" && return
15616 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
15622 #define OBD_FAIL_SPLIT_UPDATE_REC 0x1702
15623 $LCTL set_param fail_loc=0x1702
15624 $LFS setdirstripe -i 0 -c$MDSCOUNT -t all_char $DIR/$tdir/striped_dir ||
15625 error "set striped dir error"
15627 createmany -o $DIR/$tdir/striped_dir/f- 10 ||
15628 error "create files under striped dir failed"
15630 $LCTL set_param fail_loc=0
15632 rm -rf $DIR/$tdir || error "unlink striped dir fails"
15636 run_test 300j "test large update record"
15639 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
15640 skip "Need MDS version at least 2.7.55" && return
15641 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
15642 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
15648 #define OBD_FAIL_LARGE_STRIPE 0x1703
15649 $LCTL set_param fail_loc=0x1703
15650 $LFS setdirstripe -i 0 -c512 $DIR/$tdir/striped_dir ||
15651 error "set striped dir error"
15652 $LCTL set_param fail_loc=0
15654 $LFS getdirstripe $DIR/$tdir/striped_dir ||
15655 error "getstripeddir fails"
15656 rm -rf $DIR/$tdir/striped_dir ||
15657 error "unlink striped dir fails"
15661 run_test 300k "test large striped directory"
15664 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
15665 skip "Need MDS version at least 2.7.55" && return
15666 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
15667 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
15670 test_mkdir -p $DIR/$tdir/striped_dir
15671 chown $RUNAS_ID $DIR/$tdir/striped_dir ||
15672 error "chown $RUNAS_ID failed"
15673 $LFS setdirstripe -i 1 -D $DIR/$tdir/striped_dir ||
15674 error "set default striped dir failed"
15676 #define OBD_FAIL_MDS_STALE_DIR_LAYOUT 0x158
15677 $LCTL set_param fail_loc=0x80000158
15678 $RUNAS mkdir $DIR/$tdir/striped_dir/test_dir || error "create dir fails"
15680 stripe_index=$($LFS getdirstripe -i $DIR/$tdir/striped_dir/test_dir)
15681 [ $stripe_index -eq 1 ] ||
15682 error "expect 1 get $stripe_index for $dir"
15684 run_test 300l "non-root user to create dir under striped dir with stale layout"
15687 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
15688 skip "Need MDS version at least 2.7.55" && return
15689 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
15690 [ $MDSCOUNT -ge 2 ] && skip "Only for single MDT" && return
15692 mkdir -p $DIR/$tdir/striped_dir
15693 $LFS setdirstripe -D -c 1 $DIR/$tdir/striped_dir ||
15694 error "set default stripes dir error"
15696 mkdir $DIR/$tdir/striped_dir/a || error "mkdir a fails"
15698 stripe_count=$($LFS getdirstripe -c $DIR/$tdir/striped_dir/a)
15699 [ $stripe_count -eq 0 ] ||
15700 error "expect 0 get $stripe_count for a"
15702 $LFS setdirstripe -D -c 2 $DIR/$tdir/striped_dir ||
15703 error "set default stripes dir error"
15705 mkdir $DIR/$tdir/striped_dir/b || error "mkdir b fails"
15707 stripe_count=$($LFS getdirstripe -c $DIR/$tdir/striped_dir/b)
15708 [ $stripe_count -eq 0 ] ||
15709 error "expect 0 get $stripe_count for b"
15711 $LFS setdirstripe -D -c1 -i2 $DIR/$tdir/striped_dir ||
15712 error "set default stripes dir error"
15714 mkdir $DIR/$tdir/striped_dir/c &&
15715 error "default stripe_index is invalid, mkdir c should fails"
15717 rm -rf $DIR/$tdir || error "rmdir fails"
15719 run_test 300m "setstriped directory on single MDT FS"
15722 local list=$(comma_list $(mdts_nodes))
15725 do_nodes $list $LCTL set_param -n mdt.*.enable_remote_dir_gid=0
15729 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
15730 skip "Need MDS version at least 2.7.55" && return
15731 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
15732 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
15733 remote_mds_nodsh && skip "remote MDS with nodsh" && return
15736 local list=$(comma_list $(mdts_nodes))
15738 trap cleanup_300n RETURN EXIT
15739 mkdir -p $DIR/$tdir
15740 chmod 777 $DIR/$tdir
15741 $RUNAS $LFS setdirstripe -i0 -c$MDSCOUNT \
15742 $DIR/$tdir/striped_dir > /dev/null 2>&1 &&
15743 error "create striped dir succeeds with gid=0"
15745 do_nodes $list $LCTL set_param -n mdt.*.enable_remote_dir_gid=-1
15746 $RUNAS $LFS setdirstripe -i0 -c$MDSCOUNT $DIR/$tdir/striped_dir ||
15747 error "create striped dir fails with gid=-1"
15749 do_nodes $list $LCTL set_param -n mdt.*.enable_remote_dir_gid=0
15750 $RUNAS $LFS setdirstripe -i 1 -c$MDSCOUNT -D \
15751 $DIR/$tdir/striped_dir > /dev/null 2>&1 &&
15752 error "set default striped dir succeeds with gid=0"
15755 do_nodes $list $LCTL set_param -n mdt.*.enable_remote_dir_gid=-1
15756 $RUNAS $LFS setdirstripe -i 1 -c$MDSCOUNT -D $DIR/$tdir/striped_dir ||
15757 error "set default striped dir fails with gid=-1"
15760 do_nodes $list $LCTL set_param -n mdt.*.enable_remote_dir_gid=0
15761 $RUNAS mkdir $DIR/$tdir/striped_dir/test_dir ||
15762 error "create test_dir fails"
15763 $RUNAS mkdir $DIR/$tdir/striped_dir/test_dir1 ||
15764 error "create test_dir1 fails"
15765 $RUNAS mkdir $DIR/$tdir/striped_dir/test_dir2 ||
15766 error "create test_dir2 fails"
15769 run_test 300n "non-root user to create dir under striped dir with default EA"
15772 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
15773 skip "Need MDS version at least 2.7.55" && return
15774 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
15775 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
15779 mkdir -p $DIR/$tdir
15781 numfree1=$(lctl get_param -n mdc.*MDT0000*.filesfree)
15782 numfree2=$(lctl get_param -n mdc.*MDT0001*.filesfree)
15783 if [ $numfree1 -lt 66000 -o $numfree2 -lt 66000 ]; then
15784 skip "not enough free inodes $numfree1 $numfree2"
15788 numfree1=$(lctl get_param -n mdc.*MDT0000-mdc-*.kbytesfree)
15789 numfree2=$(lctl get_param -n mdc.*MDT0001-mdc-*.kbytesfree)
15790 if [ $numfree1 -lt 300000 -o $numfree2 -lt 300000 ]; then
15791 skip "not enough free space $numfree1 $numfree2"
15795 $LFS setdirstripe -c2 $DIR/$tdir/striped_dir ||
15796 error "setdirstripe fails"
15798 createmany -d $DIR/$tdir/striped_dir/d 131000 ||
15799 error "create dirs fails"
15801 $LCTL set_param ldlm.namespaces.*mdc-*.lru_size=0
15802 ls $DIR/$tdir/striped_dir > /dev/null ||
15803 error "ls striped dir fails"
15804 unlinkmany -d $DIR/$tdir/striped_dir/d 131000 ||
15805 error "unlink big striped dir fails"
15807 run_test 300o "unlink big sub stripe(> 65000 subdirs)"
15810 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
15811 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
15812 remote_mds_nodsh && skip "remote MDS with nodsh" && return
15814 mkdir -p $DIR/$tdir
15816 #define OBD_FAIL_OUT_ENOSPC 0x1704
15817 do_facet mds2 lctl set_param fail_loc=0x80001704
15818 $LFS setdirstripe -c2 $DIR/$tdir/bad_striped_dir > /dev/null 2>&1 &&
15819 error "create striped directory should fail"
15821 [ -e $DIR/$tdir/bad_striped_dir ] && error "striped dir exists"
15823 $LFS setdirstripe -c2 $DIR/$tdir/bad_striped_dir
15826 run_test 300p "create striped directory without space"
15829 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
15830 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
15832 local fd=$(free_fd)
15833 local cmd="exec $fd<$tdir"
15835 $LFS mkdir -c $MDSCOUNT $tdir || error "create $tdir fails"
15838 trap "eval $cmd" EXIT
15839 cd $tdir || error "cd $tdir fails"
15840 rmdir ../$tdir || error "rmdir $tdir fails"
15841 mkdir local_dir && error "create dir succeeds"
15842 $LFS setdirstripe -i1 remote_dir && error "create remote dir succeeds"
15846 run_test 300q "create remote directory under orphan directory"
15848 prepare_remote_file() {
15849 mkdir $DIR/$tdir/src_dir ||
15850 error "create remote source failed"
15852 cp /etc/hosts $DIR/$tdir/src_dir/a || error
15853 touch $DIR/$tdir/src_dir/a
15855 $LFS mkdir -i 1 $DIR/$tdir/tgt_dir ||
15856 error "create remote target dir failed"
15858 touch $DIR/$tdir/tgt_dir/b
15860 mrename $DIR/$tdir/src_dir/a $DIR/$tdir/tgt_dir/b ||
15861 error "rename dir cross MDT failed!"
15863 $CHECKSTAT -t file $DIR/$tdir/src_dir/a &&
15864 error "src_child still exists after rename"
15866 $CHECKSTAT -t file $DIR/$tdir/tgt_dir/b ||
15867 error "missing file(a) after rename"
15869 diff /etc/hosts $DIR/$tdir/tgt_dir/b ||
15870 error "diff after rename"
15874 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 4 MDTs" && return
15875 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
15876 local remote_file=$DIR/$tdir/tgt_dir/b
15878 mkdir -p $DIR/$tdir
15880 prepare_remote_file || error "prepare remote file failed"
15883 $OPENUNLINK $remote_file $remote_file || error
15884 $CHECKSTAT -a $remote_file || error
15886 run_test 310a "open unlink remote file"
15889 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 4 MDTs" && return
15890 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
15891 local remote_file=$DIR/$tdir/tgt_dir/b
15893 mkdir -p $DIR/$tdir
15895 prepare_remote_file || error "prepare remote file failed"
15897 ln $remote_file $DIR/$tfile || error "link failed for remote file"
15898 $MULTIOP $DIR/$tfile Ouc || error "mulitop failed"
15899 $CHECKSTAT -t file $remote_file || error "check file failed"
15901 run_test 310b "unlink remote file with multiple links while open"
15904 [[ $MDSCOUNT -lt 4 ]] && skip "needs >= 4 MDTs" && return
15905 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
15906 local remote_file=$DIR/$tdir/tgt_dir/b
15908 mkdir -p $DIR/$tdir
15910 prepare_remote_file || error "prepare remote file failed"
15912 ln $remote_file $DIR/$tfile || error "link failed for remote file"
15913 multiop_bg_pause $remote_file O_uc ||
15914 error "mulitop failed for remote file"
15916 $MULTIOP $DIR/$tfile Ouc
15917 kill -USR1 $MULTIPID
15920 run_test 310c "open-unlink remote file with multiple links"
15924 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.8.54) ] &&
15925 skip "lustre < 2.8.54 does not contain LU-4825 fix" && return
15926 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
15927 remote_mds_nodsh && skip "remote MDS with nodsh" && return
15929 local old_iused=$($LFS df -i | grep OST0000 | awk '{ print $3 }')
15931 mkdir -p $DIR/$tdir
15932 $SETSTRIPE -i 0 -c 1 $DIR/$tdir
15933 createmany -o $DIR/$tdir/$tfile. 1000
15935 # statfs data is not real time, let's just calculate it
15936 old_iused=$((old_iused + 1000))
15938 local count=$(do_facet $SINGLEMDS "lctl get_param -n \
15939 osp.*OST0000*MDT0000.create_count")
15940 local max_count=$(do_facet $SINGLEMDS "lctl get_param -n \
15941 osp.*OST0000*MDT0000.max_create_count")
15942 for idx in $(seq $MDSCOUNT); do
15943 do_facet mds$idx "lctl set_param -n \
15944 osp.*OST0000*MDT000?.max_create_count=0"
15947 $SETSTRIPE -i 0 $DIR/$tdir/$tfile || error "setstripe failed"
15948 local index=$($GETSTRIPE -i $DIR/$tdir/$tfile)
15949 [ $index -ne 0 ] || error "$tfile stripe index is 0"
15951 unlinkmany $DIR/$tdir/$tfile. 1000
15953 for idx in $(seq $MDSCOUNT); do
15954 do_facet mds$idx "lctl set_param -n \
15955 osp.*OST0000*MDT000?.max_create_count=$max_count"
15956 do_facet mds$idx "lctl set_param -n \
15957 osp.*OST0000*MDT000?.create_count=$count"
15961 for i in $(seq 120); do
15962 new_iused=$($LFS df -i | grep OST0000 | awk '{ print $3 }')
15963 # system may be too busy to destroy all objs in time, use
15964 # a somewhat small value to not fail autotest
15965 [ $((old_iused - new_iused)) -gt 400 ] && break
15969 echo "waited $i sec, old Iused $old_iused, new Iused $new_iused"
15970 [ $((old_iused - new_iused)) -gt 400 ] ||
15971 error "objs not destroyed after unlink"
15973 run_test 311 "disable OSP precreate, and unlink should destroy objs"
15980 local vdevdir=$(dirname $(facet_vdevice $ost))
15981 local cmd="$ZDB -e -p $vdevdir -ddddd $(facet_device $ost)"
15982 local zfs_zapid=$(do_facet $ost $cmd |
15983 grep -w "/O/0/d$((objid%32))" -C 5 |
15984 awk '/Object/{getline; print $1}')
15985 local zfs_objid=$(do_facet $ost $cmd $zfs_zapid |
15986 awk "/$objid = /"'{printf $3}')
15991 zfs_object_blksz() {
15995 local vdevdir=$(dirname $(facet_vdevice $ost))
15996 local cmd="$ZDB -e -p $vdevdir -dddd $(facet_device $ost)"
15997 local blksz=$(do_facet $ost $cmd $objid |
15998 awk '/dblk/{getline; printf $4}')
16000 case "${blksz: -1}" in
16001 k|K) blksz=$((${blksz:0:$((${#blksz} - 1))}*1024)) ;;
16002 m|M) blksz=$((${blksz:0:$((${#blksz} - 1))}*1024*1024)) ;;
16009 test_312() { # LU-4856
16010 remote_ost_nodsh && skip "remote OST with nodsh" && return
16012 [ $(facet_fstype ost1) = "zfs" ] ||
16013 { skip "the test only applies to zfs" && return; }
16015 local max_blksz=$(do_facet ost1 \
16016 $ZFS get -p recordsize $(facet_device ost1) |
16017 awk '!/VALUE/{print $3}')
16018 local min_blksz=$(getconf PAGE_SIZE)
16020 # to make life a little bit easier
16021 $LFS mkdir -c 1 -i 0 $DIR/$tdir
16022 $LFS setstripe -c 1 -i 0 $DIR/$tdir
16024 local tf=$DIR/$tdir/$tfile
16026 local oid=$($LFS getstripe $tf | awk '/obdidx/{getline; print $2}')
16028 # Get ZFS object id
16029 local zfs_objid=$(zfs_oid_to_objid ost1 $oid)
16031 # block size change by sequential over write
16033 for ((bs=$min_blksz; bs <= max_blksz; bs <<= 2)); do
16034 dd if=/dev/zero of=$tf bs=$bs count=1 oflag=sync conv=notrunc
16036 blksz=$(zfs_object_blksz ost1 $zfs_objid)
16037 [ $blksz -eq $bs ] || error "blksz error: $blksz, expected: $bs"
16041 # block size change by sequential append write
16042 dd if=/dev/zero of=$tf bs=$min_blksz count=1 oflag=sync conv=notrunc
16043 oid=$($LFS getstripe $tf | awk '/obdidx/{getline; print $2}')
16044 zfs_objid=$(zfs_oid_to_objid ost1 $oid)
16046 for ((count = 1; count < $((max_blksz / min_blksz)); count *= 2)); do
16047 dd if=/dev/zero of=$tf bs=$min_blksz count=$count seek=$count \
16048 oflag=sync conv=notrunc
16050 blksz=$(zfs_object_blksz ost1 $zfs_objid)
16051 [ $blksz -eq $((2 * count * min_blksz)) ] ||
16052 error "blksz error, actual $blksz, " \
16053 "expected: 2 * $count * $min_blksz"
16059 oid=$($LFS getstripe $tf | awk '/obdidx/{getline; print $2}')
16060 zfs_objid=$(zfs_oid_to_objid ost1 $oid)
16062 dd if=/dev/zero of=$tf bs=1K count=1 oflag=sync conv=notrunc
16063 blksz=$(zfs_object_blksz ost1 $zfs_objid)
16064 [ $blksz -eq $min_blksz ] ||
16065 error "blksz error: $blksz, expected: $min_blksz"
16067 dd if=/dev/zero of=$tf bs=64K count=1 oflag=sync conv=notrunc seek=128
16068 blksz=$(zfs_object_blksz ost1 $zfs_objid)
16069 [ $blksz -eq 65536 ] || error "blksz error: $blksz, expected: 64k"
16071 dd if=/dev/zero of=$tf bs=1M count=1 oflag=sync conv=notrunc
16072 blksz=$(zfs_object_blksz ost1 $zfs_objid)
16073 [ $blksz -eq 65536 ] || error "rewrite error: $blksz, expected: 64k"
16075 run_test 312 "make sure ZFS adjusts its block size by write pattern"
16078 remote_ost_nodsh && skip "remote OST with nodsh" && return
16080 local file=$DIR/$tfile
16082 $SETSTRIPE -c 1 -i 0 $file || error "setstripe failed"
16084 # define OBD_FAIL_TGT_RCVD_EIO 0x720
16085 do_facet ost1 "$LCTL set_param fail_loc=0x720"
16086 dd if=/dev/zero of=$file bs=4096 oflag=direct count=1 &&
16087 error "write should failed"
16088 do_facet ost1 "$LCTL set_param fail_loc=0"
16091 run_test 313 "io should fail after last_rcvd update fail"
16094 local read_write=$1
16095 if [ "$read_write" = "write" ]; then
16096 local dd_cmd="dd if=/dev/zero of=$DIR/$tfile"
16097 elif [ "$read_write" = "read" ]; then
16098 local dd_cmd="dd of=/dev/null if=$DIR/$tfile"
16100 error "argument error"
16103 # turn off debug for performance testing
16104 local saved_debug=$($LCTL get_param -n debug)
16105 $LCTL set_param debug=0
16107 $SETSTRIPE -c 1 -i 0 $DIR/$tfile
16109 # get ost1 size - lustre-OST0000
16110 local ost1_avail_size=$($LFS df | awk /${ost1_svc}/'{ print $4 }')
16111 local blocks=$((ost1_avail_size/2/1024)) # half avail space by megabytes
16112 [ $blocks -gt 1000 ] && blocks=1000 # 1G in maximum
16114 if [ "$read_write" = "read" ]; then
16115 truncate -s $(expr 1048576 \* $blocks) $DIR/$tfile
16118 local start_time=$(date +%s.%N)
16119 $dd_cmd bs=1M count=$blocks oflag=sync ||
16120 error "real dd $read_write error"
16121 local duration=$(bc <<< "$(date +%s.%N) - $start_time")
16123 if [ "$read_write" = "write" ]; then
16127 # define OBD_FAIL_OST_FAKE_RW 0x238
16128 do_facet ost1 $LCTL set_param fail_loc=0x238
16130 local start_time=$(date +%s.%N)
16131 $dd_cmd bs=1M count=$blocks oflag=sync ||
16132 error "fake dd $read_write error"
16133 local duration_fake=$(bc <<< "$(date +%s.%N) - $start_time")
16135 if [ "$read_write" = "write" ]; then
16137 cancel_lru_locks osc
16138 $CHECKSTAT -t file -s $((blocks * 1024 * 1024)) $DIR/$tfile ||
16139 error "$tfile size not $blocks MB"
16141 do_facet ost1 $LCTL set_param fail_loc=0
16143 echo "fake $read_write $duration_fake vs. normal $read_write" \
16144 "$duration in seconds"
16145 [ $(bc <<< "$duration_fake < $duration") -eq 1 ] ||
16146 error_not_in_vm "fake write is slower"
16148 $LCTL set_param -n debug="$saved_debug"
16151 test_399a() { # LU-7655 for OST fake write
16152 remote_ost_nodsh && skip "remote OST with nodsh" && return
16156 run_test 399a "fake write should not be slower than normal write"
16158 test_399b() { # LU-8726 for OST fake read
16159 remote_ost_nodsh && skip "remote OST with nodsh" && return
16161 if [ "$(facet_fstype ost1)" != "ldiskfs" ]; then
16162 skip "ldiskfs only test" && return 0
16166 run_test 399b "fake read should not be slower than normal read"
16168 test_400a() { # LU-1606, was conf-sanity test_74
16169 local extra_flags=''
16170 local out=$TMP/$tfile
16171 local prefix=/usr/include/lustre
16174 if ! which $CC > /dev/null 2>&1; then
16175 skip_env "$CC is not installed"
16179 if ! [[ -d $prefix ]]; then
16180 # Assume we're running in tree and fixup the include path.
16181 extra_flags+=" -I$LUSTRE/../libcfs/include"
16182 extra_flags+=" -I$LUSTRE/include"
16183 extra_flags+=" -L$LUSTRE/utils"
16186 for prog in $LUSTRE_TESTS_API_DIR/*.c; do
16187 $CC -Wall -Werror $extra_flags -llustreapi -o $out $prog ||
16188 error "client api broken"
16192 run_test 400a "Lustre client api program can compile and link"
16194 test_400b() { # LU-1606, LU-5011
16196 local out=$TMP/$tfile
16197 local prefix=/usr/include/lustre
16199 # We use a hard coded prefix so that this test will not fail
16200 # when run in tree. There are headers in lustre/include/lustre/
16201 # that are not packaged (like lustre_idl.h) and have more
16202 # complicated include dependencies (like config.h and lnet/types.h).
16203 # Since this test about correct packaging we just skip them when
16204 # they don't exist (see below) rather than try to fixup cppflags.
16206 if ! which $CC > /dev/null 2>&1; then
16207 skip_env "$CC is not installed"
16211 for header in $prefix/*.h; do
16212 if ! [[ -f "$header" ]]; then
16216 if [[ "$(basename $header)" == liblustreapi.h ]]; then
16217 continue # liblustreapi.h is deprecated.
16220 $CC -Wall -Werror -include $header -c -x c /dev/null -o $out ||
16221 error "cannot compile '$header'"
16225 run_test 400b "packaged headers can be compiled"
16227 test_401a() { #LU-7437
16228 local printf_arg=$(find -printf 2>&1 | grep "unrecognized:")
16229 [ -n "$printf_arg" ] && skip_env "find does not support -printf" &&
16231 #count the number of parameters by "list_param -R"
16232 local params=$($LCTL list_param -R '*' 2>/dev/null | wc -l)
16233 #count the number of parameters by listing proc files
16234 local proc_dirs=$(eval \ls -d $proc_regexp 2>/dev/null)
16235 echo "proc_dirs='$proc_dirs'"
16236 [ -n "$proc_dirs" ] || error "no proc_dirs on $HOSTNAME"
16237 local procs=$(find -L $proc_dirs -mindepth 1 -printf '%P\n' 2>/dev/null|
16240 [ $params -eq $procs ] ||
16241 error "found $params parameters vs. $procs proc files"
16243 # test the list_param -D option only returns directories
16244 params=$($LCTL list_param -R -D '*' 2>/dev/null | wc -l)
16245 #count the number of parameters by listing proc directories
16246 procs=$(find -L $proc_dirs -mindepth 1 -type d -printf '%P\n' 2>/dev/null |
16249 [ $params -eq $procs ] ||
16250 error "found $params parameters vs. $procs proc files"
16252 run_test 401a "Verify if 'lctl list_param -R' can list parameters recursively"
16255 local save=$($LCTL get_param -n jobid_var)
16258 $LCTL set_param foo=bar jobid_var=$tmp bar=baz &&
16259 error "no error returned when setting bad parameters"
16261 local jobid_new=$($LCTL get_param -n foe jobid_var baz)
16262 [[ "$jobid_new" == "$tmp" ]] || error "jobid tmp $jobid_new != $tmp"
16264 $LCTL set_param -n fog=bam jobid_var=$save bat=fog
16265 local jobid_old=$($LCTL get_param -n foe jobid_var bag)
16266 [[ "$jobid_old" == "$save" ]] || error "jobid new $jobid_old != $save"
16268 run_test 401b "Verify 'lctl {get,set}_param' continue after error"
16271 local jobid_var_old=$($LCTL get_param -n jobid_var)
16272 local jobid_var_new
16274 $LCTL set_param jobid_var= &&
16275 error "no error returned for 'set_param a='"
16277 jobid_var_new=$($LCTL get_param -n jobid_var)
16278 [[ "$jobid_var_old" == "$jobid_var_new" ]] ||
16279 error "jobid_var was changed by setting without value"
16281 $LCTL set_param jobid_var &&
16282 error "no error returned for 'set_param a'"
16284 jobid_var_new=$($LCTL get_param -n jobid_var)
16285 [[ "$jobid_var_old" == "$jobid_var_new" ]] ||
16286 error "jobid_var was changed by setting without value"
16288 run_test 401c "Verify 'lctl set_param' without value fails in either format."
16291 local jobid_var_old=$($LCTL get_param -n jobid_var)
16292 local jobid_var_new
16293 local new_value="foo=bar"
16295 $LCTL set_param jobid_var=$new_value ||
16296 error "'set_param a=b' did not accept a value containing '='"
16298 jobid_var_new=$($LCTL get_param -n jobid_var)
16299 [[ "$jobid_var_new" == "$new_value" ]] ||
16300 error "'set_param a=b' failed on a value containing '='"
16302 # Reset the jobid_var to test the other format
16303 $LCTL set_param jobid_var=$jobid_var_old
16304 jobid_var_new=$($LCTL get_param -n jobid_var)
16305 [[ "$jobid_var_new" == "$jobid_var_old" ]] ||
16306 error "failed to reset jobid_var"
16308 $LCTL set_param jobid_var $new_value ||
16309 error "'set_param a b' did not accept a value containing '='"
16311 jobid_var_new=$($LCTL get_param -n jobid_var)
16312 [[ "$jobid_var_new" == "$new_value" ]] ||
16313 error "'set_param a b' failed on a value containing '='"
16315 $LCTL set_param jobid_var $jobid_var_old
16316 jobid_var_new=$($LCTL get_param -n jobid_var)
16317 [[ "$jobid_var_new" == "$jobid_var_old" ]] ||
16318 error "failed to reset jobid_var"
16320 run_test 401d "Verify 'lctl set_param' accepts values containing '='"
16323 local server_version=$(lustre_version_code $SINGLEMDS)
16324 [[ $server_version -ge $(version_code 2.7.66) ]] ||
16325 [[ $server_version -ge $(version_code 2.7.18.4) &&
16326 $server_version -lt $(version_code 2.7.50) ]] ||
16327 [[ $server_version -ge $(version_code 2.7.2) &&
16328 $server_version -lt $(version_code 2.7.11) ]] ||
16329 { skip "Need MDS version 2.7.2+ or 2.7.18.4+ or 2.7.66+";
16331 remote_mds_nodsh && skip "remote MDS with nodsh" && return
16332 $LFS setdirstripe -i 0 $DIR/$tdir || error "setdirstripe -i 0 failed"
16333 #define OBD_FAIL_MDS_FLD_LOOKUP 0x15c
16334 do_facet mds1 "lctl set_param fail_loc=0x8000015c"
16335 touch $DIR/$tdir/$tfile && error "touch should fail with ENOENT" ||
16336 echo "Touch failed - OK"
16338 run_test 402 "Return ENOENT to lod_generate_and_set_lovea"
16341 local file1=$DIR/$tfile.1
16342 local file2=$DIR/$tfile.2
16343 local tfile=$TMP/$tfile
16345 rm -f $file1 $file2 $tfile
16350 # 30 sec OBD_TIMEOUT in ll_getattr()
16351 # right before populating st_nlink
16352 $LCTL set_param fail_loc=0x80001409
16353 stat -c %h $file1 > $tfile &
16355 # create an alias, drop all locks and reclaim the dentry
16357 cancel_lru_locks mdc
16358 cancel_lru_locks osc
16359 sysctl -w vm.drop_caches=2
16363 [ `cat $tfile` -gt 0 ] || error "wrong nlink count: `cat $tfile`"
16365 rm -f $tfile $file1 $file2
16367 run_test 403 "i_nlink should not drop to zero due to aliasing"
16369 test_404() { # LU-6601
16370 local server_version=$(lustre_version_code $SINGLEMDS)
16371 [[ $server_version -ge $(version_code 2.8.53) ]] ||
16372 { skip "Need server version newer than 2.8.52"; return 0; }
16374 remote_mds_nodsh && skip "remote MDS with nodsh" && return
16375 local mosps=$(do_facet $SINGLEMDS $LCTL dl |
16376 awk '/osp .*-osc-MDT/ { print $4}')
16379 for osp in $mosps; do
16380 echo "Deactivate: " $osp
16381 do_facet $SINGLEMDS $LCTL --device %$osp deactivate
16382 local stat=$(do_facet $SINGLEMDS $LCTL dl |
16383 awk -vp=$osp '$4 == p { print $2 }')
16384 [ $stat = IN ] || {
16385 do_facet $SINGLEMDS $LCTL dl | grep -w $osp
16386 error "deactivate error"
16388 echo "Activate: " $osp
16389 do_facet $SINGLEMDS $LCTL --device %$osp activate
16390 local stat=$(do_facet $SINGLEMDS $LCTL dl |
16391 awk -vp=$osp '$4 == p { print $2 }')
16392 [ $stat = UP ] || {
16393 do_facet $SINGLEMDS $LCTL dl | grep -w $osp
16394 error "activate error"
16398 run_test 404 "validate manual {de}activated works properly for OSPs"
16401 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.6.92) ] &&
16402 skip "Layout swap lock is not supported" && return
16404 check_swap_layouts_support && return 0
16406 test_mkdir -p $DIR/$tdir
16407 swap_lock_test -d $DIR/$tdir ||
16408 error "One layout swap locked test failed"
16410 run_test 405 "Various layout swap lock tests"
16413 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
16414 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs" && return
16415 [ -n "$FILESET" ] && skip "SKIP due to FILESET set" && return
16416 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
16417 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.8.50) ] &&
16418 skip "Need MDS version at least 2.8.50" && return
16420 local def_stripenr=$($GETSTRIPE -c $MOUNT)
16421 local def_stripe_size=$($GETSTRIPE -S $MOUNT)
16422 local def_stripe_offset=$($GETSTRIPE -i $MOUNT)
16423 local def_pool=$($GETSTRIPE -p $MOUNT)
16425 local test_pool=$TESTNAME
16426 pool_add $test_pool || error "pool_add failed"
16427 pool_add_targets $test_pool 0 $(($OSTCOUNT - 1)) 1 ||
16428 error "pool_add_targets failed"
16430 # parent set default stripe count only, child will stripe from both
16431 # parent and fs default
16432 $SETSTRIPE -c 1 -i 1 -S $((def_stripe_size * 2)) -p $test_pool $MOUNT ||
16433 error "setstripe $MOUNT failed"
16434 $LFS mkdir -c $MDSCOUNT $DIR/$tdir || error "mkdir $tdir failed"
16435 $SETSTRIPE -c $OSTCOUNT $DIR/$tdir || error "setstripe $tdir failed"
16436 for i in $(seq 10); do
16437 local f=$DIR/$tdir/$tfile.$i
16438 touch $f || error "touch failed"
16439 local count=$($GETSTRIPE -c $f)
16440 [ $count -eq $OSTCOUNT ] ||
16441 error "$f stripe count $count != $OSTCOUNT"
16442 local offset=$($GETSTRIPE -i $f)
16443 [ $offset -eq 1 ] || error "$f stripe offset $offset != 1"
16444 local size=$($GETSTRIPE -S $f)
16445 [ $size -eq $((def_stripe_size * 2)) ] ||
16446 error "$f stripe size $size != $((def_stripe_size * 2))"
16447 local pool=$($GETSTRIPE -p $f)
16448 [ $pool == $test_pool ] || error "$f pool $pool != $test_pool"
16451 # change fs default striping, delete parent default striping, now child
16452 # will stripe from new fs default striping only
16453 $SETSTRIPE -c 1 -S $def_stripe_size -i 0 $MOUNT ||
16454 error "change $MOUNT default stripe failed"
16455 $SETSTRIPE -c 0 $DIR/$tdir || error "delete $tdir default stripe failed"
16456 for i in $(seq 11 20); do
16457 local f=$DIR/$tdir/$tfile.$i
16458 touch $f || error "touch $f failed"
16459 local count=$($GETSTRIPE -c $f)
16460 [ $count -eq 1 ] || error "$f stripe count $count != 1"
16461 local offset=$($GETSTRIPE -i $f)
16462 [ $offset -eq 0 ] || error "$f stripe offset $offset != 0"
16463 local size=$($GETSTRIPE -S $f)
16464 [ $size -eq $def_stripe_size ] ||
16465 error "$f stripe size $size != $def_stripe_size"
16466 local pool=$($GETSTRIPE -p $f)
16467 [ "#$pool" == "#" ] || error "$f pool $pool is set"
16471 unlinkmany $DIR/$tdir/$tfile. 1 20
16473 # restore FS default striping
16474 if [ -z $def_pool ]; then
16475 $SETSTRIPE -c $def_stripenr -S $def_stripe_size \
16476 -i $def_stripe_offset $MOUNT ||
16477 error "restore default striping failed"
16479 $SETSTRIPE -c $def_stripenr -S $def_stripe_size -p $def_pool \
16480 -i $def_stripe_offset $MOUNT ||
16481 error "restore default striping with $def_pool failed"
16484 local f=$DIR/$tdir/$tfile
16485 pool_remove_all_targets $test_pool $f
16486 pool_remove $test_pool $f
16488 run_test 406 "DNE support fs default striping"
16491 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
16492 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.8.55) ]] &&
16493 skip "Need MDS version at least 2.8.55" && return
16494 remote_mds_nodsh && skip "remote MDS with nodsh" && return
16496 $LFS mkdir -i 0 -c 1 $DIR/$tdir.0 ||
16497 error "$LFS mkdir -i 0 -c 1 $tdir.0 failed"
16498 $LFS mkdir -i 1 -c 1 $DIR/$tdir.1 ||
16499 error "$LFS mkdir -i 1 -c 1 $tdir.1 failed"
16500 touch $DIR/$tdir.0/$tfile.0 || error "touch $tdir.0/$tfile.0 failed"
16502 #define OBD_FAIL_DT_TXN_STOP 0x2019
16503 for idx in $(seq $MDSCOUNT); do
16504 do_facet mds$idx "lctl set_param fail_loc=0x2019"
16506 $LFS mkdir -c 2 $DIR/$tdir && error "$LFS mkdir -c 2 $tdir should fail"
16507 mv $DIR/$tdir.0/$tfile.0 $DIR/$tdir.1/$tfile.1 &&
16508 error "mv $tdir.0/$tfile.0 $tdir.1/$tfile.1 should fail"
16511 run_test 407 "transaction fail should cause operation fail"
16514 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 oflag=direct
16516 #define OBD_FAIL_OSC_BRW_PREP_REQ2 0x40a
16517 lctl set_param fail_loc=0x8000040a
16518 # let ll_prepare_partial_page() fail
16519 dd if=/dev/zero of=$DIR/$tfile bs=2048 count=1 conv=notrunc || true
16523 # create at least 100 unused inodes so that
16524 # shrink_icache_memory(0) should not return 0
16525 touch $DIR/$tfile-{0..100}
16526 rm -f $DIR/$tfile-{0..100}
16529 echo 2 > /proc/sys/vm/drop_caches
16531 run_test 408 "drop_caches should not hang due to page leaks"
16535 [ $MDSCOUNT -lt 2 ] &&
16536 skip "We need at least 2 MDTs for this test" && return
16538 check_mount_and_prep
16540 mkdir -p $DIR/$tdir || error "(0) Fail to mkdir"
16541 $LFS mkdir -i 1 -c 2 $DIR/$tdir/foo || error "(1) Fail to mkdir"
16542 touch $DIR/$tdir/guard || error "(2) Fail to create"
16544 local PREFIX=$(str_repeat 'A' 128)
16545 echo "Create 1K hard links start at $(date)"
16546 createmany -l $DIR/$tdir/guard $DIR/$tdir/foo/${PREFIX}_ 1000 ||
16547 error "(3) Fail to hard link"
16549 echo "Links count should be right although linkEA overflow"
16550 stat $DIR/$tdir/guard || error "(4) Fail to stat"
16551 local linkcount=$(stat --format=%h $DIR/$tdir/guard)
16552 [ $linkcount -eq 1001 ] ||
16553 error "(5) Unexpected hard links count: $linkcount"
16555 echo "List all links start at $(date)"
16556 ls -l $DIR/$tdir/foo > /dev/null ||
16557 error "(6) Fail to list $DIR/$tdir/foo"
16559 echo "Unlink hard links start at $(date)"
16560 unlinkmany $DIR/$tdir/foo/${PREFIX}_ 1000 ||
16561 error "(7) Fail to unlink"
16563 run_test 409 "Large amount of cross-MDTs hard links on the same file"
16567 # Create a file, and stat it from the kernel
16568 local testfile=$DIR/$tfile
16571 local run_id=$RANDOM
16572 local my_ino=$(stat --format "%i" $testfile)
16574 # Try to insert the module. This will always fail as the
16575 # module is designed to not be inserted.
16576 insmod $LUSTRE/tests/kernel/kinode.ko run_id=$run_id fname=$testfile \
16579 # Anything but success is a test failure
16581 "lustre_kinode_$run_id: inode numbers are identical: $my_ino" ||
16582 error "no inode match"
16584 run_test 410 "Test inode number returned from kernel thread"
16587 [[ $(lustre_version_code mds1) -lt $(version_code 2.9.55) ]] ||
16588 [[ $(lustre_version_code ost1) -lt $(version_code 2.9.55) ]] &&
16589 skip "Need server version at least 2.9.55" & exit 0
16590 start_full_debug_logging
16594 stop_full_debug_logging
16598 if [ $(lustre_version_code mgs) -le $(version_code 2.10.0) ]; then
16599 local st=$(do_facet mgs $LCTL barrier_stat $FSNAME |
16600 awk '/The barrier for/ { print $7 }')
16603 local st=$(do_facet mgs $LCTL barrier_stat -s $FSNAME)
16608 barrier_expired() {
16611 if [ $(lustre_version_code mgs) -le $(version_code 2.10.0) ]; then
16612 expired=$(do_facet mgs $LCTL barrier_stat $FSNAME |
16613 awk '/will be expired/ { print $7 }')
16615 expired=$(do_facet mgs $LCTL barrier_stat -t $FSNAME)
16624 echo "Start barrier_freeze at: $(date)"
16625 #define OBD_FAIL_BARRIER_DELAY 0x2202
16626 do_facet mgs $LCTL set_param fail_val=5 fail_loc=0x2202
16627 do_facet mgs $LCTL barrier_freeze $FSNAME 10 &
16630 local b_status=$(barrier_stat)
16631 echo "Got barrier status at: $(date)"
16632 [ "$b_status" = "'freezing_p1'" ] ||
16633 error "(1) unexpected barrier status $b_status"
16635 do_facet mgs $LCTL set_param fail_val=0 fail_loc=0
16637 b_status=$(barrier_stat)
16638 [ "$b_status" = "'frozen'" ] ||
16639 error "(2) unexpected barrier status $b_status"
16641 local expired=$(barrier_expired)
16642 echo "sleep $((expired + 3)) seconds, then the barrier will be expired"
16643 sleep $((expired + 3))
16645 b_status=$(barrier_stat)
16646 [ "$b_status" = "'expired'" ] ||
16647 error "(3) unexpected barrier status $b_status"
16649 do_facet mgs $LCTL barrier_freeze $FSNAME 10 ||
16650 error "(4) fail to freeze barrier"
16652 b_status=$(barrier_stat)
16653 [ "$b_status" = "'frozen'" ] ||
16654 error "(5) unexpected barrier status $b_status"
16656 echo "Start barrier_thaw at: $(date)"
16657 #define OBD_FAIL_BARRIER_DELAY 0x2202
16658 do_facet mgs $LCTL set_param fail_val=5 fail_loc=0x2202
16659 do_facet mgs $LCTL barrier_thaw $FSNAME &
16662 b_status=$(barrier_stat)
16663 echo "Got barrier status at: $(date)"
16664 [ "$b_status" = "'thawing'" ] ||
16665 error "(6) unexpected barrier status $b_status"
16667 do_facet mgs $LCTL set_param fail_val=0 fail_loc=0
16669 b_status=$(barrier_stat)
16670 [ "$b_status" = "'thawed'" ] ||
16671 error "(7) unexpected barrier status $b_status"
16673 #define OBD_FAIL_BARRIER_FAILURE 0x2203
16674 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x2203
16675 do_facet mgs $LCTL barrier_freeze $FSNAME
16677 b_status=$(barrier_stat)
16678 [ "$b_status" = "'failed'" ] ||
16679 error "(8) unexpected barrier status $b_status"
16681 do_facet $SINGLEMDS $LCTL set_param fail_loc=0
16682 do_facet mgs $LCTL barrier_thaw $FSNAME
16686 run_test 801a "write barrier user interfaces and stat machine"
16691 mkdir $DIR/$tdir || error "(1) fail to mkdir"
16692 createmany -d $DIR/$tdir/d 6 || "(2) fail to mkdir"
16693 touch $DIR/$tdir/d2/f10 || error "(3) fail to touch"
16694 touch $DIR/$tdir/d3/f11 || error "(4) fail to touch"
16695 touch $DIR/$tdir/d4/f12 || error "(5) fail to touch"
16697 cancel_lru_locks mdc
16699 # 180 seconds should be long enough
16700 do_facet mgs $LCTL barrier_freeze $FSNAME 180
16702 local b_status=$(barrier_stat)
16703 [ "$b_status" = "'frozen'" ] ||
16704 error "(6) unexpected barrier status $b_status"
16706 mkdir $DIR/$tdir/d0/d10 &
16709 touch $DIR/$tdir/d1/f13 &
16712 ln $DIR/$tdir/d2/f10 $DIR/$tdir/d2/f14 &
16715 mv $DIR/$tdir/d3/f11 $DIR/$tdir/d3/f15 &
16718 rm -f $DIR/$tdir/d4/f12 &
16721 stat $DIR/$tdir/d5 || error "(7) stat should succeed"
16723 # To guarantee taht the 'stat' is not blocked
16724 b_status=$(barrier_stat)
16725 [ "$b_status" = "'frozen'" ] ||
16726 error "(8) unexpected barrier status $b_status"
16728 # let above commands to run at background
16731 ps -p $mkdir_pid || error "(9) mkdir should be blocked"
16732 ps -p $touch_pid || error "(10) touch should be blocked"
16733 ps -p $ln_pid || error "(11) link should be blocked"
16734 ps -p $mv_pid || error "(12) rename should be blocked"
16735 ps -p $rm_pid || error "(13) unlink should be blocked"
16737 b_status=$(barrier_stat)
16738 [ "$b_status" = "'frozen'" ] ||
16739 error "(14) unexpected barrier status $b_status"
16741 do_facet mgs $LCTL barrier_thaw $FSNAME
16742 b_status=$(barrier_stat)
16743 [ "$b_status" = "'thawed'" ] ||
16744 error "(15) unexpected barrier status $b_status"
16746 wait $mkdir_pid || error "(16) mkdir should succeed"
16747 wait $touch_pid || error "(17) touch should succeed"
16748 wait $ln_pid || error "(18) link should succeed"
16749 wait $mv_pid || error "(19) rename should succeed"
16750 wait $rm_pid || error "(20) unlink should succeed"
16754 run_test 801b "modification will be blocked by write barrier"
16757 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 2 MDTs" && return
16761 stop mds2 || error "(1) Fail to stop mds2"
16763 do_facet mgs $LCTL barrier_freeze $FSNAME 30
16765 local b_status=$(barrier_stat)
16766 [ "$b_status" = "'expired'" -o "$b_status" = "'failed'" ] || {
16767 do_facet mgs $LCTL barrier_thaw $FSNAME
16768 error "(2) unexpected barrier status $b_status"
16771 do_facet mgs $LCTL barrier_rescan $FSNAME ||
16772 error "(3) Fail to rescan barrier bitmap"
16774 do_facet mgs $LCTL barrier_freeze $FSNAME 10
16776 b_status=$(barrier_stat)
16777 [ "$b_status" = "'frozen'" ] ||
16778 error "(4) unexpected barrier status $b_status"
16780 do_facet mgs $LCTL barrier_thaw $FSNAME
16781 b_status=$(barrier_stat)
16782 [ "$b_status" = "'thawed'" ] ||
16783 error "(5) unexpected barrier status $b_status"
16785 local devname=$(mdsdevname 2)
16787 start mds2 $devname $MDS_MOUNT_OPTS || error "(6) Fail to start mds2"
16789 do_facet mgs $LCTL barrier_rescan $FSNAME ||
16790 error "(7) Fail to rescan barrier bitmap"
16794 run_test 801c "rescan barrier bitmap"
16796 saved_MGS_MOUNT_OPTS=$MGS_MOUNT_OPTS
16797 saved_MDS_MOUNT_OPTS=$MDS_MOUNT_OPTS
16798 saved_OST_MOUNT_OPTS=$OST_MOUNT_OPTS
16804 MGS_MOUNT_OPTS=$saved_MGS_MOUNT_OPTS
16805 MDS_MOUNT_OPTS=$saved_MDS_MOUNT_OPTS
16806 OST_MOUNT_OPTS=$saved_OST_MOUNT_OPTS
16812 [[ $(lustre_version_code mds1) -lt $(version_code 2.9.55) ]] ||
16813 [[ $(lustre_version_code ost1) -lt $(version_code 2.9.55) ]] &&
16814 skip "Need server version at least 2.9.55" & exit 0
16816 mkdir $DIR/$tdir || error "(1) fail to mkdir"
16818 cp $LUSTRE/tests/test-framework.sh $DIR/$tdir/ ||
16819 error "(2) Fail to copy"
16821 trap cleanup_802 EXIT
16823 # sync by force before remount as readonly
16824 sync; sync_all_data; sleep 3; sync_all_data
16828 MGS_MOUNT_OPTS=$(csa_add "$MGS_MOUNT_OPTS" -o rdonly_dev)
16829 MDS_MOUNT_OPTS=$(csa_add "$MDS_MOUNT_OPTS" -o rdonly_dev)
16830 OST_MOUNT_OPTS=$(csa_add "$OST_MOUNT_OPTS" -o rdonly_dev)
16832 echo "Mount the server as read only"
16833 setupall server_only || error "(3) Fail to start servers"
16835 echo "Mount client without ro should fail"
16836 mount_client $MOUNT &&
16837 error "(4) Mount client without 'ro' should fail"
16839 echo "Mount client with ro should succeed"
16840 mount_client $MOUNT ro ||
16841 error "(5) Mount client with 'ro' should succeed"
16843 echo "Modify should be refused"
16844 touch $DIR/$tdir/guard && error "(6) Touch should fail under ro mode"
16846 echo "Read should be allowed"
16847 diff $LUSTRE/tests/test-framework.sh $DIR/$tdir/test-framework.sh ||
16848 error "(7) Read should succeed under ro mode"
16852 run_test 802 "simulate readonly device"
16855 # tests that do cleanup/setup should be run at the end
16859 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
16861 #define OBD_FAIL_MGC_PAUSE_PROCESS_LOG 0x903
16862 $LCTL set_param fail_loc=0x903
16864 cancel_lru_locks MGC
16866 FAIL_ON_ERROR=true cleanup
16867 FAIL_ON_ERROR=true setup
16869 run_test 900 "umount should not race with any mgc requeue thread"
16872 [ -f $EXT2_DEV ] && rm $EXT2_DEV || true
16873 check_and_cleanup_lustre
16874 if [ "$I_MOUNTED" != "yes" ]; then
16875 lctl set_param debug="$OLDDEBUG" 2> /dev/null || true