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"
6899 $LFS setstripe -i 0 -c 1 $DIR/$tfile
6901 local orig_mb=$(do_facet ost1 $LCTL get_param -n $brw_size | head -n 1)
6902 if [ $(lustre_version_code ost1) -ge $(version_code 2.8.52) ]; then
6903 [ $(lustre_version_code ost1) -ge $(version_code 2.9.52) ] &&
6905 if [[ $orig_mb -lt 16 ]]; then
6906 save_lustre_params $osts "$brw_size" > $p
6907 do_nodes $list $LCTL set_param -n $brw_size=16$suffix ||
6908 error "set 16MB RPC size failed"
6910 echo "remount client to enable new RPC size"
6911 remount_client $MOUNT || error "remount_client failed"
6914 test_101g_brw_size_test 16 || error "16MB RPC test failed"
6915 # should be able to set brw_size=12, but no rpc_stats for that
6916 test_101g_brw_size_test 8 || error "8MB RPC test failed"
6919 test_101g_brw_size_test 4 || error "4MB RPC test failed"
6921 if [[ $orig_mb -lt 16 ]]; then
6922 restore_lustre_params < $p
6923 remount_client $MOUNT || error "remount_client restore failed"
6926 rm -f $p $DIR/$tfile
6928 run_test 101g "Big bulk(4/16 MiB) readahead"
6931 test_mkdir $DIR/$tdir
6932 chown $RUNAS_ID $DIR/$tdir
6935 STRIPE_COUNT=$OSTCOUNT
6936 [[ $OSTCOUNT -gt 4 ]] && STRIPE_COUNT=4
6938 trap cleanup_test102 EXIT
6940 $1 $SETSTRIPE -S $STRIPE_SIZE -i $STRIPE_OFFSET -c $STRIPE_COUNT $tdir
6942 for num in 1 2 3 4; do
6943 for count in $(seq 1 $STRIPE_COUNT); do
6944 for idx in $(seq 0 $[$STRIPE_COUNT - 1]); do
6945 local size=`expr $STRIPE_SIZE \* $num`
6946 local file=file"$num-$idx-$count"
6947 $1 $SETSTRIPE -S $size -i $idx -c $count $file
6953 $1 tar cf $TMP/f102.tar $tdir --xattrs
6959 rm -rf $DIR/d0.sanity/d102
6963 local testfile=$DIR/$tfile
6967 [ "$UID" != 0 ] && skip_env "must run as root" && return
6968 [ -z "$(lctl get_param -n mdc.*-mdc-*.connect_flags | grep xattr)" ] &&
6969 skip_env "must have user_xattr" && return
6971 [ -z "$(which setfattr 2>/dev/null)" ] &&
6972 skip_env "could not find setfattr" && return
6974 echo "set/get xattr..."
6975 setfattr -n trusted.name1 -v value1 $testfile ||
6976 error "setfattr -n trusted.name1=value1 $testfile failed"
6977 getfattr -n trusted.name1 $testfile 2> /dev/null |
6978 grep "trusted.name1=.value1" ||
6979 error "$testfile missing trusted.name1=value1"
6981 setfattr -n user.author1 -v author1 $testfile ||
6982 error "setfattr -n user.author1=author1 $testfile failed"
6983 getfattr -n user.author1 $testfile 2> /dev/null |
6984 grep "user.author1=.author1" ||
6985 error "$testfile missing trusted.author1=author1"
6988 setfattr -n trusted.name2 -v value2 $testfile ||
6989 error "$testfile unable to set trusted.name2"
6990 setfattr -n trusted.name3 -v value3 $testfile ||
6991 error "$testfile unable to set trusted.name3"
6992 [ $(getfattr -d -m "^trusted" $testfile 2> /dev/null |
6993 grep "trusted.name" | wc -l) -eq 3 ] ||
6994 error "$testfile missing 3 trusted.name xattrs"
6996 setfattr -n user.author2 -v author2 $testfile ||
6997 error "$testfile unable to set user.author2"
6998 setfattr -n user.author3 -v author3 $testfile ||
6999 error "$testfile unable to set user.author3"
7000 [ $(getfattr -d -m "^user" $testfile 2> /dev/null |
7001 grep "user.author" | wc -l) -eq 3 ] ||
7002 error "$testfile missing 3 user.author xattrs"
7004 echo "remove xattr..."
7005 setfattr -x trusted.name1 $testfile ||
7006 error "$testfile error deleting trusted.name1"
7007 getfattr -d -m trusted $testfile 2> /dev/null | grep "trusted.name1" &&
7008 error "$testfile did not delete trusted.name1 xattr"
7010 setfattr -x user.author1 $testfile ||
7011 error "$testfile error deleting user.author1"
7012 echo "set lustre special xattr ..."
7013 $LFS setstripe -c1 $testfile
7014 local lovea=$(getfattr -n "trusted.lov" -e hex $testfile |
7015 awk -F "=" '/trusted.lov/ { print $2 }' )
7016 setfattr -n "trusted.lov" -v $lovea $testfile ||
7017 error "$testfile doesn't ignore setting trusted.lov again"
7018 setfattr -n "trusted.lov" -v "invalid_value" $testfile &&
7019 error "$testfile allow setting invalid trusted.lov"
7022 run_test 102a "user xattr test =================================="
7025 [ -z "$(which setfattr 2>/dev/null)" ] &&
7026 skip_env "could not find setfattr" && return
7028 # b10930: get/set/list trusted.lov xattr
7029 echo "get/set/list trusted.lov xattr ..."
7030 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
7031 local testfile=$DIR/$tfile
7032 $SETSTRIPE -S 65536 -i 1 -c $OSTCOUNT $testfile ||
7033 error "setstripe failed"
7034 local STRIPECOUNT=$($GETSTRIPE -c $testfile) ||
7035 error "getstripe failed"
7036 getfattr -d -m "^trusted" $testfile 2>/dev/null | grep "trusted.lov" ||
7037 error "can't get trusted.lov from $testfile"
7039 local testfile2=${testfile}2
7040 local value=$(getfattr -n trusted.lov $testfile 2>/dev/null |
7041 grep "trusted.lov" | sed -e 's/[^=]\+=//')
7044 setfattr -n trusted.lov -v $value $testfile2
7045 local stripe_size=$($GETSTRIPE -S $testfile2)
7046 local stripe_count=$($GETSTRIPE -c $testfile2)
7047 [[ $stripe_size -eq 65536 ]] ||
7048 error "stripe size $stripe_size != 65536"
7049 [[ $stripe_count -eq $STRIPECOUNT ]] ||
7050 error "stripe count $stripe_count != $STRIPECOUNT"
7053 run_test 102b "getfattr/setfattr for trusted.lov EAs ============"
7056 [ -z "$(which setfattr 2>/dev/null)" ] &&
7057 skip_env "could not find setfattr" && return
7059 # b10930: get/set/list lustre.lov xattr
7060 echo "get/set/list lustre.lov xattr ..."
7061 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
7062 test_mkdir $DIR/$tdir
7063 chown $RUNAS_ID $DIR/$tdir
7064 local testfile=$DIR/$tdir/$tfile
7065 $RUNAS $SETSTRIPE -S 65536 -i 1 -c $OSTCOUNT $testfile ||
7066 error "setstripe failed"
7067 local STRIPECOUNT=$($RUNAS $GETSTRIPE -c $testfile) ||
7068 error "getstripe failed"
7069 $RUNAS getfattr -d -m "^lustre" $testfile 2> /dev/null | \
7070 grep "lustre.lov" || error "can't get lustre.lov from $testfile"
7072 local testfile2=${testfile}2
7073 local value=`getfattr -n lustre.lov $testfile 2> /dev/null | \
7074 grep "lustre.lov" |sed -e 's/[^=]\+=//' `
7076 $RUNAS $MCREATE $testfile2
7077 $RUNAS setfattr -n lustre.lov -v $value $testfile2
7078 local stripe_size=$($RUNAS $GETSTRIPE -S $testfile2)
7079 local stripe_count=$($RUNAS $GETSTRIPE -c $testfile2)
7080 [ $stripe_size -eq 65536 ] || error "stripe size $stripe_size != 65536"
7081 [ $stripe_count -eq $STRIPECOUNT ] ||
7082 error "stripe count $stripe_count != $STRIPECOUNT"
7084 run_test 102c "non-root getfattr/setfattr for lustre.lov EAs ==========="
7086 compare_stripe_info1() {
7087 local stripe_index_all_zero=true
7089 for num in 1 2 3 4; do
7090 for count in $(seq 1 $STRIPE_COUNT); do
7091 for offset in $(seq 0 $[$STRIPE_COUNT - 1]); do
7092 local size=$((STRIPE_SIZE * num))
7093 local file=file"$num-$offset-$count"
7094 stripe_size=$($LFS getstripe -S $PWD/$file)
7095 [[ $stripe_size -ne $size ]] &&
7096 error "$file: size $stripe_size != $size"
7097 stripe_count=$($LFS getstripe -c $PWD/$file)
7098 # allow fewer stripes to be created, ORI-601
7099 [[ $stripe_count -lt $(((3 * count + 3) / 4)) ]] &&
7100 error "$file: count $stripe_count != $count"
7101 stripe_index=$($LFS getstripe -i $PWD/$file)
7102 [[ $stripe_index -ne 0 ]] &&
7103 stripe_index_all_zero=false
7107 $stripe_index_all_zero &&
7108 error "all files are being extracted starting from OST index 0"
7112 have_xattrs_include() {
7113 tar --help | grep -q xattrs-include &&
7114 echo --xattrs-include="lustre.*"
7118 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7119 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
7120 local xinc=$(have_xattrs_include)
7122 tar xf $TMP/f102.tar -C $DIR/$tdir --xattrs $xinc
7124 compare_stripe_info1
7126 run_test 102d "tar restore stripe info from tarfile,not keep osts ==========="
7129 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7130 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
7131 local xinc=$(have_xattrs_include)
7133 test_mkdir $DIR/$tdir.restore
7135 tar cf - --xattrs $tdir | tar xf - \
7136 -C $DIR/$tdir.restore --xattrs $xinc
7137 cd $DIR/$tdir.restore/$tdir
7138 compare_stripe_info1
7140 run_test 102f "tar copy files, not keep osts ==========="
7143 local xsize=${1:-1024} # in bytes
7144 local file=$DIR/$tfile
7146 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep xattr)" ] &&
7147 skip "must have user_xattr" && return 0
7148 [ -z "$(which setfattr 2>/dev/null)" ] &&
7149 skip_env "could not find setfattr" && return 0
7150 [ -z "$(which getfattr 2>/dev/null)" ] &&
7151 skip_env "could not find getfattr" && return 0
7155 local value="$(generate_string $xsize)"
7157 local xbig=trusted.big
7158 log "save $xbig on $file"
7159 setfattr -n $xbig -v $value $file ||
7160 error "saving $xbig on $file failed"
7162 local orig=$(get_xattr_value $xbig $file)
7163 [[ "$orig" != "$value" ]] && error "$xbig different after saving $xbig"
7165 local xsml=trusted.sml
7166 log "save $xsml on $file"
7167 setfattr -n $xsml -v val $file || error "saving $xsml on $file failed"
7169 local new=$(get_xattr_value $xbig $file)
7170 [[ "$new" != "$orig" ]] && error "$xbig different after saving $xsml"
7172 log "grow $xsml on $file"
7173 setfattr -n $xsml -v "$value" $file ||
7174 error "growing $xsml on $file failed"
7176 new=$(get_xattr_value $xbig $file)
7177 [[ "$new" != "$orig" ]] && error "$xbig different after growing $xsml"
7178 log "$xbig still valid after growing $xsml"
7183 test_102h() { # bug 15777
7186 run_test 102h "grow xattr from inside inode to external block"
7189 large_xattr_enabled || { skip "large_xattr disabled" && return; }
7190 grow_xattr $(max_xattr_size)
7192 run_test 102ha "grow xattr from inside inode to external inode"
7194 test_102i() { # bug 17038
7195 [ -z "$(which getfattr 2>/dev/null)" ] &&
7196 skip "could not find getfattr" && return
7198 ln -s $DIR/$tfile $DIR/${tfile}link
7199 getfattr -n trusted.lov $DIR/$tfile ||
7200 error "lgetxattr on $DIR/$tfile failed"
7201 getfattr -h -n trusted.lov $DIR/${tfile}link 2>&1 |
7202 grep -i "no such attr" ||
7203 error "error for lgetxattr on $DIR/${tfile}link is not ENODATA"
7204 rm -f $DIR/$tfile $DIR/${tfile}link
7206 run_test 102i "lgetxattr test on symbolic link ============"
7209 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7210 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
7211 local xinc=$(have_xattrs_include)
7212 setup_test102 "$RUNAS"
7213 chown $RUNAS_ID $DIR/$tdir
7214 $RUNAS tar xf $TMP/f102.tar -C $DIR/$tdir --xattrs $xinc
7216 compare_stripe_info1 "$RUNAS"
7218 run_test 102j "non-root tar restore stripe info from tarfile, not keep osts ==="
7221 [ -z "$(which setfattr 2>/dev/null)" ] &&
7222 skip "could not find setfattr" && return
7224 # b22187 just check that does not crash for regular file.
7225 setfattr -n trusted.lov $DIR/$tfile
7226 # b22187 'setfattr -n trusted.lov' should work as remove LOV EA for directories
7227 local test_kdir=$DIR/$tdir
7228 test_mkdir $test_kdir
7229 local default_size=`$GETSTRIPE -S $test_kdir`
7230 local default_count=`$GETSTRIPE -c $test_kdir`
7231 local default_offset=`$GETSTRIPE -i $test_kdir`
7232 $SETSTRIPE -S 65536 -i 0 -c $OSTCOUNT $test_kdir ||
7233 error 'dir setstripe failed'
7234 setfattr -n trusted.lov $test_kdir
7235 local stripe_size=`$GETSTRIPE -S $test_kdir`
7236 local stripe_count=`$GETSTRIPE -c $test_kdir`
7237 local stripe_offset=`$GETSTRIPE -i $test_kdir`
7238 [ $stripe_size -eq $default_size ] ||
7239 error "stripe size $stripe_size != $default_size"
7240 [ $stripe_count -eq $default_count ] ||
7241 error "stripe count $stripe_count != $default_count"
7242 [ $stripe_offset -eq $default_offset ] ||
7243 error "stripe offset $stripe_offset != $default_offset"
7244 rm -rf $DIR/$tfile $test_kdir
7246 run_test 102k "setfattr without parameter of value shouldn't cause a crash"
7249 [ -z "$(which getfattr 2>/dev/null)" ] &&
7250 skip "could not find getfattr" && return
7252 # LU-532 trusted. xattr is invisible to non-root
7253 local testfile=$DIR/$tfile
7257 echo "listxattr as user..."
7258 chown $RUNAS_ID $testfile
7259 $RUNAS getfattr -d -m '.*' $testfile 2>&1 |
7260 grep -q "trusted" &&
7261 error "$testfile trusted xattrs are user visible"
7265 run_test 102l "listxattr size test =================================="
7267 test_102m() { # LU-3403 llite: error of listxattr when buffer is small
7268 local path=$DIR/$tfile
7271 listxattr_size_check $path || error "listattr_size_check $path failed"
7273 run_test 102m "Ensure listxattr fails on small bufffer ========"
7277 getxattr() { # getxattr path name
7278 # Return the base64 encoding of the value of xattr name on path.
7282 # # getfattr --absolute-names --encoding=base64 --name=trusted.lov $path
7284 # trusted.lov=0s0AvRCwEAAAAGAAAAAAAAAAAEAAACAAAAAAAQAAEAA...AAAAAAAAA=
7286 # We print just 0s0AvRCwEAAAAGAAAAAAAAAAAEAAACAAAAAAAQAAEAA...AAAAAAAAA=
7288 getfattr --absolute-names --encoding=base64 --name=$name $path |
7289 awk -F= -v name=$name '$1 == name {
7290 print substr($0, index($0, "=") + 1);
7294 test_102n() { # LU-4101 mdt: protect internal xattrs
7295 [ -z "$(which setfattr 2>/dev/null)" ] &&
7296 skip "could not find setfattr" && return
7297 if [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.5.50) ]
7299 skip "MDT < 2.5.50 allows setxattr on internal trusted xattrs"
7303 local file0=$DIR/$tfile.0
7304 local file1=$DIR/$tfile.1
7305 local xattr0=$TMP/$tfile.0
7306 local xattr1=$TMP/$tfile.1
7307 local namelist="lov lma lmv link fid version som hsm"
7311 rm -rf $file0 $file1 $xattr0 $xattr1
7314 # Get 'before' xattrs of $file1.
7315 getfattr --absolute-names --dump --match=- $file1 > $xattr0
7317 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.8.53) ] &&
7318 namelist+=" lfsck_namespace"
7319 for name in $namelist; do
7320 # Try to copy xattr from $file0 to $file1.
7321 value=$(getxattr $file0 trusted.$name 2> /dev/null)
7323 setfattr --name=trusted.$name --value="$value" $file1 ||
7324 error "setxattr 'trusted.$name' failed"
7326 # Try to set a garbage xattr.
7327 value=0sVGhlIHF1aWNrIGJyb3duIGZveCBqdW1wcyBvdmVyIGl0c2VsZi4=
7329 if [[ x$name == "xlov" ]]; then
7330 setfattr --name=trusted.lov --value="$value" $file1 &&
7331 error "setxattr invalid 'trusted.lov' success"
7333 setfattr --name=trusted.$name --value="$value" $file1 ||
7334 error "setxattr invalid 'trusted.$name' failed"
7337 # Try to remove the xattr from $file1. We don't care if this
7338 # appears to succeed or fail, we just don't want there to be
7339 # any changes or crashes.
7340 setfattr --remove=$trusted.$name $file1 2> /dev/null
7343 if [ $(lustre_version_code $SINGLEMDS) -gt $(version_code 2.6.50) ]
7346 # Try to copy xattr from $file0 to $file1.
7347 value=$(getxattr $file0 trusted.$name 2> /dev/null)
7349 setfattr --name=trusted.$name --value="$value" $file1 ||
7350 error "setxattr 'trusted.$name' failed"
7352 # Try to set a garbage xattr.
7353 value=0sVGhlIHF1aWNrIGJyb3duIGZveCBqdW1wcyBvdmVyIGl0c2VsZi4=
7355 setfattr --name=trusted.$name --value="$value" $file1 ||
7356 error "setxattr 'trusted.$name' failed"
7358 # Try to remove the xattr from $file1. We don't care if this
7359 # appears to succeed or fail, we just don't want there to be
7360 # any changes or crashes.
7361 setfattr --remove=$trusted.$name $file1 2> /dev/null
7364 # Get 'after' xattrs of file1.
7365 getfattr --absolute-names --dump --match=- $file1 > $xattr1
7367 if ! diff $xattr0 $xattr1; then
7368 error "before and after xattrs of '$file1' differ"
7371 rm -rf $file0 $file1 $xattr0 $xattr1
7375 run_test 102n "silently ignore setxattr on internal trusted xattrs"
7377 test_102p() { # LU-4703 setxattr did not check ownership
7378 local testfile=$DIR/$tfile
7380 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.5.56) ] &&
7381 skip "MDS needs to be at least 2.5.56" && return
7385 echo "setfacl as user..."
7386 $RUNAS setfacl -m "u:$RUNAS_ID:rwx" $testfile
7387 [ $? -ne 0 ] || error "setfacl by $RUNAS_ID was allowed on $testfile"
7389 echo "setfattr as user..."
7390 setfacl -m "u:$RUNAS_ID:---" $testfile
7391 $RUNAS setfattr -x system.posix_acl_access $testfile
7392 [ $? -ne 0 ] || error "setfattr by $RUNAS_ID was allowed on $testfile"
7394 run_test 102p "check setxattr(2) correctly fails without permission"
7397 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.6.92) ] &&
7398 skip "MDS needs to be at least 2.6.92" && return
7399 orphan_linkea_check $DIR/$tfile || error "orphan_linkea_check"
7401 run_test 102q "flistxattr should not return trusted.link EAs for orphans"
7404 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.6.93) ] &&
7405 skip "MDS needs to be at least 2.6.93" && return
7406 touch $DIR/$tfile || error "touch"
7407 setfattr -n user.$(basename $tfile) $DIR/$tfile || error "setfattr"
7408 getfattr -n user.$(basename $tfile) $DIR/$tfile || error "getfattr"
7409 rm $DIR/$tfile || error "rm"
7412 mkdir -p $DIR/$tdir || error "mkdir"
7413 setfattr -n user.$(basename $tdir) $DIR/$tdir || error "setfattr dir"
7414 getfattr -n user.$(basename $tdir) $DIR/$tdir || error "getfattr dir"
7415 setfattr -x user.$(basename $tdir) $DIR/$tdir ||
7416 error "$testfile error deleting user.author1"
7417 getfattr -d -m user.$(basename $tdir) 2> /dev/null |
7418 grep "user.$(basename $tdir)" &&
7419 error "$tdir did not delete user.$(basename $tdir)"
7420 rmdir $DIR/$tdir || error "rmdir"
7423 test_mkdir $DIR/$tdir || error "make striped dir"
7424 setfattr -n user.$(basename $tdir) $DIR/$tdir || error "setfattr dir"
7425 getfattr -n user.$(basename $tdir) $DIR/$tdir || error "getfattr dir"
7426 setfattr -x user.$(basename $tdir) $DIR/$tdir ||
7427 error "$testfile error deleting user.author1"
7428 getfattr -d -m user.$(basename $tdir) 2> /dev/null |
7429 grep "user.$(basename $tdir)" &&
7430 error "$tdir did not delete user.$(basename $tdir)"
7431 rmdir $DIR/$tdir || error "rm striped dir"
7433 run_test 102r "set EAs with empty values"
7437 $LUSTRE/tests/acl/run $LUSTRE/tests/acl/$1.test
7442 [ "$UID" != 0 ] && skip_env "must run as root" && return
7443 [ -z "$(lctl get_param -n mdc.*-mdc-*.connect_flags | grep acl)" ] &&
7444 skip "must have acl enabled" && return
7445 [ -z "$(which setfacl 2>/dev/null)" ] &&
7446 skip_env "could not find setfacl" && return
7447 $GSS && skip "could not run under gss" && return
7448 remote_mds_nodsh && skip "remote MDS with nodsh" && return
7450 gpasswd -a daemon bin # LU-5641
7451 do_facet $SINGLEMDS gpasswd -a daemon bin # LU-5641
7453 declare -a identity_old
7455 for num in $(seq $MDSCOUNT); do
7456 switch_identity $num true || identity_old[$num]=$?
7464 echo "performing cp ..."
7465 run_acl_subtest cp || error "run_acl_subtest cp failed"
7466 echo "performing getfacl-noacl..."
7467 run_acl_subtest getfacl-noacl || error "getfacl-noacl test failed"
7468 echo "performing misc..."
7469 run_acl_subtest misc || error "misc test failed"
7470 echo "performing permissions..."
7471 run_acl_subtest permissions || error "permissions failed"
7472 # LU-1482 mdd: Setting xattr are properly checked with and without ACLs
7473 if [ $(lustre_version_code $SINGLEMDS) -gt $(version_code 2.8.55) -o \
7474 \( $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.6) -a \
7475 $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.5.29) \) ]
7477 echo "performing permissions xattr..."
7478 run_acl_subtest permissions_xattr ||
7479 error "permissions_xattr failed"
7481 echo "performing setfacl..."
7482 run_acl_subtest setfacl || error "setfacl test failed"
7484 # inheritance test got from HP
7485 echo "performing inheritance..."
7486 cp $LUSTRE/tests/acl/make-tree . || error "cannot copy make-tree"
7487 chmod +x make-tree || error "chmod +x failed"
7488 run_acl_subtest inheritance || error "inheritance test failed"
7491 echo "LU-974 ignore umask when acl is enabled..."
7492 run_acl_subtest 974 || error "LU-974 umask test failed"
7493 if [ $MDSCOUNT -ge 2 ]; then
7494 run_acl_subtest 974_remote ||
7495 error "LU-974 umask test failed under remote dir"
7498 echo "LU-2561 newly created file is same size as directory..."
7499 if [ $(facet_fstype $SINGLEMDS) != "zfs" ]; then
7500 run_acl_subtest 2561 || error "LU-2561 test failed"
7502 run_acl_subtest 2561_zfs || error "LU-2561 zfs test failed"
7505 run_acl_subtest 4924 || error "LU-4924 test failed"
7510 for num in $(seq $MDSCOUNT); do
7511 if [ "${identity_old[$num]}" = 1 ]; then
7512 switch_identity $num false || identity_old[$num]=$?
7516 run_test 103a "acl test ========================================="
7519 remote_mds_nodsh && skip "remote MDS with nodsh" && return
7521 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
7522 local mountopts=$MDS_MOUNT_OPTS
7524 if [[ "$MDS_MOUNT_OPTS" =~ "noacl" ]]; then
7528 stop $SINGLEMDS || error "failed to stop MDT."
7530 if [ -z "$MDS_MOUNT_OPTS" ]; then
7531 MDS_MOUNT_OPTS="-o noacl"
7533 MDS_MOUNT_OPTS="${MDS_MOUNT_OPTS},noacl"
7535 start $SINGLEMDS $MDT_DEV $MDS_MOUNT_OPTS ||
7536 error "failed to start MDT."
7537 MDS_MOUNT_OPTS=$mountopts
7541 setfacl -m u:bin:rw $DIR/$tfile && error "setfacl should fail"
7545 stop $SINGLEMDS || error "failed to stop MDT."
7547 start $SINGLEMDS $MDT_DEV $MDS_MOUNT_OPTS ||
7548 error "failed to start MDT."
7553 run_test 103b "MDS mount option 'noacl'"
7557 cp -rp $DIR/$tdir $DIR/$tdir.bak
7559 [ -n "$(getfattr -d -m. $DIR/$tdir | grep posix_acl_default)" ] &&
7560 error "$DIR/$tdir shouldn't contain default ACL"
7561 [ -n "$(getfattr -d -m. $DIR/$tdir.bak | grep posix_acl_default)" ] &&
7562 error "$DIR/$tdir.bak shouldn't contain default ACL"
7565 run_test 103c "'cp -rp' won't set empty acl"
7568 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7570 lfs df || error "lfs df failed"
7571 lfs df -ih || error "lfs df -ih failed"
7572 lfs df -h $DIR || error "lfs df -h $DIR failed"
7573 lfs df -i $DIR || error "lfs df -i $DIR failed"
7574 lfs df $DIR/$tfile || error "lfs df $DIR/$tfile failed"
7575 lfs df -ih $DIR/$tfile || error "lfs df -ih $DIR/$tfile failed"
7577 local OSC=$(lctl dl | grep OST0000-osc-[^M] | awk '{ print $4 }')
7578 lctl --device %$OSC deactivate
7579 lfs df || error "lfs df with deactivated OSC failed"
7580 lctl --device %$OSC activate
7581 # wait the osc back to normal
7582 wait_osc_import_state client ost FULL
7584 lfs df || error "lfs df with reactivated OSC failed"
7587 run_test 104a "lfs df [-ih] [path] test ========================="
7590 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7591 [ $RUNAS_ID -eq $UID ] &&
7592 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
7594 denied_cnt=$(($($RUNAS $LFS check servers 2>&1 |
7595 grep "Permission denied" | wc -l)))
7596 if [ $denied_cnt -ne 0 ]; then
7597 error "lfs check servers test failed"
7600 run_test 104b "$RUNAS lfs check servers test ===================="
7603 # doesn't work on 2.4 kernels
7605 if $(flock_is_enabled); then
7606 flocks_test 1 on -f $DIR/$tfile || error "fail flock on"
7608 flocks_test 1 off -f $DIR/$tfile || error "fail flock off"
7612 run_test 105a "flock when mounted without -o flock test ========"
7616 if $(flock_is_enabled); then
7617 flocks_test 1 on -c $DIR/$tfile || error "fail flock on"
7619 flocks_test 1 off -c $DIR/$tfile || error "fail flock off"
7623 run_test 105b "fcntl when mounted without -o flock test ========"
7627 if $(flock_is_enabled); then
7628 flocks_test 1 on -l $DIR/$tfile || error "fail flock on"
7630 flocks_test 1 off -l $DIR/$tfile || error "fail flock off"
7634 run_test 105c "lockf when mounted without -o flock test ========"
7636 test_105d() { # bug 15924
7637 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7638 test_mkdir -p $DIR/$tdir
7639 flock_is_enabled || { skip "mount w/o flock enabled" && return; }
7640 #define OBD_FAIL_LDLM_CP_CB_WAIT 0x315
7641 $LCTL set_param fail_loc=0x80000315
7642 flocks_test 2 $DIR/$tdir
7644 run_test 105d "flock race (should not freeze) ========"
7646 test_105e() { # bug 22660 && 22040
7647 flock_is_enabled || { skip "mount w/o flock enabled" && return; }
7649 flocks_test 3 $DIR/$tfile
7651 run_test 105e "Two conflicting flocks from same process ======="
7653 test_106() { #bug 10921
7654 test_mkdir -p $DIR/$tdir
7655 $DIR/$tdir && error "exec $DIR/$tdir succeeded"
7656 chmod 777 $DIR/$tdir || error "chmod $DIR/$tdir failed"
7658 run_test 106 "attempt exec of dir followed by chown of that dir"
7661 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7668 local save_pattern=$(sysctl -n kernel.core_pattern)
7669 local save_uses_pid=$(sysctl -n kernel.core_uses_pid)
7670 sysctl -w kernel.core_pattern=$file
7671 sysctl -w kernel.core_uses_pid=0
7679 kill -s 11 $SLEEPPID
7681 if [ -e $file ]; then
7682 size=`stat -c%s $file`
7683 [ $size -eq 0 ] && error "Fail to create core file $file"
7685 error "Fail to create core file $file"
7688 sysctl -w kernel.core_pattern=$save_pattern
7689 sysctl -w kernel.core_uses_pid=$save_uses_pid
7692 run_test 107 "Coredump on SIG"
7695 test_mkdir -p $DIR/$tdir
7696 test_mkdir $DIR/$tdir/$(str_repeat 'a' 255) ||
7697 error "mkdir with 255 char failed"
7698 test_mkdir $DIR/$tdir/$(str_repeat 'b' 256) &&
7699 error "mkdir with 256 char should fail, but did not"
7700 touch $DIR/$tdir/$(str_repeat 'x' 255) ||
7701 error "create with 255 char failed"
7702 touch $DIR/$tdir/$(str_repeat 'y' 256) &&
7703 error "create with 256 char should fail, but did not"
7708 run_test 110 "filename length checking"
7711 # Purpose: To verify dynamic thread (OSS) creation.
7714 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7715 remote_ost_nodsh && skip "remote OST with nodsh" && return
7717 # Lustre does not stop service threads once they are started.
7718 # Reset number of running threads to default.
7723 local save_params="$TMP/sanity-$TESTNAME.parameters"
7725 # Get ll_ost_io count before I/O
7726 OSTIO_pre=$(do_facet ost1 \
7727 "$LCTL get_param ost.OSS.ost_io.threads_started | cut -d= -f2")
7728 # Exit if lustre is not running (ll_ost_io not running).
7729 [ -z "$OSTIO_pre" ] && error "no OSS threads"
7731 echo "Starting with $OSTIO_pre threads"
7732 local thread_max=$((OSTIO_pre * 2))
7733 local rpc_in_flight=$((thread_max * 2))
7734 # Number of I/O Process proposed to be started.
7736 local facets=$(get_facets OST)
7738 save_lustre_params client \
7739 "osc.*OST*.max_rpcs_in_flight" > $save_params
7740 save_lustre_params $facets \
7741 "ost.OSS.ost_io.threads_max" >> $save_params
7743 # Set in_flight to $rpc_in_flight
7744 $LCTL set_param osc.*OST*.max_rpcs_in_flight=$rpc_in_flight ||
7745 error "Failed to set max_rpcs_in_flight to $rpc_in_flight"
7746 nfiles=${rpc_in_flight}
7747 # Set ost thread_max to $thread_max
7749 "$LCTL set_param ost.OSS.ost_io.threads_max=$thread_max"
7751 # 5 Minutes should be sufficient for max number of OSS
7752 # threads(thread_max) to be created.
7756 local WTL=${WTL:-"$LUSTRE/tests/write_time_limit"}
7758 for i in $(seq $nfiles); do
7759 local file=$DIR/$tdir/${tfile}-$i
7760 $LFS setstripe -c -1 -i 0 $file
7761 ($WTL $file $timeout)&
7764 # I/O Started - Wait for thread_started to reach thread_max or report
7765 # error if thread_started is more than thread_max.
7766 echo "Waiting for thread_started to reach thread_max"
7767 local thread_started=0
7768 local end_time=$((SECONDS + timeout))
7770 while [ $SECONDS -le $end_time ] ; do
7772 # Get ost i/o thread_started count.
7773 thread_started=$(do_facet ost1 \
7775 ost.OSS.ost_io.threads_started | cut -d= -f2")
7776 # Break out if thread_started is equal/greater than thread_max
7777 if [[ $thread_started -ge $thread_max ]]; then
7778 echo ll_ost_io thread_started $thread_started, \
7779 equal/greater than thread_max $thread_max
7785 # Cleanup - We have the numbers, Kill i/o jobs if running.
7786 jobcount=($(jobs -p))
7787 for i in $(seq 0 $((${#jobcount[@]}-1)))
7789 kill -9 ${jobcount[$i]}
7790 if [ $? -ne 0 ] ; then
7792 Failed to Kill \'WTL\(I/O\)\' with pid ${jobcount[$i]}
7796 # Cleanup files left by WTL binary.
7797 for i in $(seq $nfiles); do
7798 local file=$DIR/$tdir/${tfile}-$i
7800 if [ $? -ne 0 ] ; then
7801 echo "Warning: Failed to delete file $file"
7805 restore_lustre_params <$save_params
7806 rm -f $save_params || echo "Warning: delete file '$save_params' failed"
7808 # Error out if no new thread has started or Thread started is greater
7810 if [[ $thread_started -le $OSTIO_pre ||
7811 $thread_started -gt $thread_max ]]; then
7812 error "ll_ost_io: thread_started $thread_started" \
7813 "OSTIO_pre $OSTIO_pre, thread_max $thread_max." \
7814 "No new thread started or thread started greater " \
7818 run_test 115 "verify dynamic thread creation===================="
7821 wait_delete_completed
7822 AVAIL=($(lctl get_param -n osc.*[oO][sS][cC]-[^M]*.kbytesavail))
7823 echo "OST kbytes available: ${AVAIL[@]}"
7828 for ((i = 0; i < ${#AVAIL[@]}; i++)); do
7829 #echo OST $i: ${AVAIL[i]}kb
7830 if [[ ${AVAIL[i]} -gt $MAXV ]]; then
7834 if [[ ${AVAIL[i]} -lt $MINV ]]; then
7839 echo "Min free space: OST $MINI: $MINV"
7840 echo "Max free space: OST $MAXI: $MAXV"
7843 test_116a() { # was previously test_116()
7844 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7845 remote_mds_nodsh && skip "remote MDS with nodsh" && return
7847 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
7849 echo -n "Free space priority "
7850 do_facet $SINGLEMDS lctl get_param -n lo*.*-mdtlov.qos_prio_free |
7855 [ $MINV -eq 0 ] && skip "no free space in OST$MINI, skip" && return
7856 [ $MINV -gt 10000000 ] && skip "too much free space in OST$MINI, skip" \
7858 trap simple_cleanup_common EXIT
7861 # Check if we need to generate uneven OSTs
7862 test_mkdir -p $DIR/$tdir/OST${MINI}
7863 local FILL=$((MINV / 4))
7864 local DIFF=$((MAXV - MINV))
7865 local DIFF2=$((DIFF * 100 / MINV))
7867 local threshold=$(do_facet $SINGLEMDS \
7868 lctl get_param -n *.*MDT0000-mdtlov.qos_threshold_rr | head -n1)
7869 threshold=${threshold%%%}
7870 echo -n "Check for uneven OSTs: "
7871 echo -n "diff=${DIFF}KB (${DIFF2}%) must be > ${threshold}% ..."
7873 if [[ $DIFF2 -gt $threshold ]]; then
7875 echo "Don't need to fill OST$MINI"
7877 # generate uneven OSTs. Write 2% over the QOS threshold value
7879 DIFF=$((threshold - DIFF2 + 2))
7880 DIFF2=$((MINV * DIFF / 100))
7881 echo "Fill $DIFF% remaining space in OST$MINI with ${DIFF2}KB"
7882 $SETSTRIPE -i $MINI -c 1 $DIR/$tdir/OST${MINI} ||
7883 error "setstripe failed"
7884 DIFF=$((DIFF2 / 2048))
7886 while [ $i -lt $DIFF ]; do
7888 dd if=/dev/zero of=$DIR/$tdir/OST${MINI}/$tfile-$i \
7889 bs=2M count=1 2>/dev/null
7898 DIFF=$((MAXV - MINV))
7899 DIFF2=$((DIFF * 100 / MINV))
7900 echo -n "diff=$DIFF=$DIFF2% must be > $threshold% for QOS mode..."
7901 if [ $DIFF2 -gt $threshold ]; then
7904 echo "failed - QOS mode won't be used"
7905 skip "QOS imbalance criteria not met"
7906 simple_cleanup_common
7915 # now fill using QOS
7916 $SETSTRIPE -c 1 $DIR/$tdir
7917 FILL=$((FILL / 200))
7918 if [ $FILL -gt 600 ]; then
7921 echo "writing $FILL files to QOS-assigned OSTs"
7923 while [ $i -lt $FILL ]; do
7925 dd if=/dev/zero of=$DIR/$tdir/$tfile-$i bs=200k \
7929 echo "wrote $i 200k files"
7933 echo "Note: free space may not be updated, so measurements might be off"
7935 DIFF2=$((MAXV - MINV))
7936 echo "free space delta: orig $DIFF final $DIFF2"
7937 [ $DIFF2 -gt $DIFF ] && echo "delta got worse!"
7938 DIFF=$((MINV1 - ${AVAIL[$MINI1]}))
7939 echo "Wrote ${DIFF}KB to smaller OST $MINI1"
7940 DIFF2=$((MAXV1 - ${AVAIL[$MAXI1]}))
7941 echo "Wrote ${DIFF2}KB to larger OST $MAXI1"
7942 if [[ $DIFF -gt 0 ]]; then
7943 FILL=$((DIFF2 * 100 / DIFF - 100))
7944 echo "Wrote ${FILL}% more data to larger OST $MAXI1"
7947 # Figure out which files were written where
7948 UUID=$(lctl get_param -n lov.${FSNAME}-clilov-*.target_obd |
7949 awk '/'$MINI1': / {print $2; exit}')
7951 MINC=$($GETSTRIPE --ost $UUID $DIR/$tdir | grep $DIR | wc -l)
7952 echo "$MINC files created on smaller OST $MINI1"
7953 UUID=$(lctl get_param -n lov.${FSNAME}-clilov-*.target_obd |
7954 awk '/'$MAXI1': / {print $2; exit}')
7956 MAXC=$($GETSTRIPE --ost $UUID $DIR/$tdir | grep $DIR | wc -l)
7957 echo "$MAXC files created on larger OST $MAXI1"
7958 if [[ $MINC -gt 0 ]]; then
7959 FILL=$((MAXC * 100 / MINC - 100))
7960 echo "Wrote ${FILL}% more files to larger OST $MAXI1"
7962 [[ $MAXC -gt $MINC ]] ||
7963 error_ignore LU-9 "stripe QOS didn't balance free space"
7964 simple_cleanup_common
7966 run_test 116a "stripe QOS: free space balance ==================="
7968 test_116b() { # LU-2093
7969 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7970 remote_mds_nodsh && skip "remote MDS with nodsh" && return
7972 #define OBD_FAIL_MDS_OSC_CREATE_FAIL 0x147
7973 local old_rr=$(do_facet $SINGLEMDS lctl get_param -n \
7974 lo*.$FSNAME-MDT0000-mdtlov.qos_threshold_rr | head -1)
7975 [ -z "$old_rr" ] && skip "no QOS" && return 0
7976 do_facet $SINGLEMDS lctl set_param \
7977 lo*.$FSNAME-MDT0000-mdtlov.qos_threshold_rr=0
7979 do_facet $SINGLEMDS lctl set_param fail_loc=0x147
7980 createmany -o $DIR/$tdir/f- 20 || error "can't create"
7981 do_facet $SINGLEMDS lctl set_param fail_loc=0
7983 do_facet $SINGLEMDS lctl set_param \
7984 lo*.$FSNAME-MDT0000-mdtlov.qos_threshold_rr=$old_rr
7986 run_test 116b "QoS shouldn't LBUG if not enough OSTs found on the 2nd pass"
7988 test_117() # bug 10891
7990 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7991 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1
7992 #define OBD_FAIL_OST_SETATTR_CREDITS 0x21e
7993 lctl set_param fail_loc=0x21e
7994 > $DIR/$tfile || error "truncate failed"
7995 lctl set_param fail_loc=0
7996 echo "Truncate succeeded."
7999 run_test 117 "verify osd extend =========="
8001 NO_SLOW_RESENDCOUNT=4
8002 export OLD_RESENDCOUNT=""
8003 set_resend_count () {
8004 local PROC_RESENDCOUNT="osc.${FSNAME}-OST*-osc-*.resend_count"
8005 OLD_RESENDCOUNT=$(lctl get_param -n $PROC_RESENDCOUNT | head -n1)
8006 lctl set_param -n $PROC_RESENDCOUNT $1
8007 echo resend_count is set to $(lctl get_param -n $PROC_RESENDCOUNT)
8010 # for reduce test_118* time (b=14842)
8011 [ "$SLOW" = "no" ] && set_resend_count $NO_SLOW_RESENDCOUNT
8013 # Reset async IO behavior after error case
8015 FILE=$DIR/reset_async
8017 # Ensure all OSCs are cleared
8018 $SETSTRIPE -c -1 $FILE
8019 dd if=/dev/zero of=$FILE bs=64k count=$OSTCOUNT
8024 test_118a() #bug 11710
8026 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8029 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
8030 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
8031 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
8033 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
8034 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
8039 run_test 118a "verify O_SYNC works =========="
8043 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8044 remote_ost_nodsh && skip "remote OST with nodsh" && return
8048 #define OBD_FAIL_SRV_ENOENT 0x217
8049 set_nodes_failloc "$(osts_nodes)" 0x217
8050 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
8052 set_nodes_failloc "$(osts_nodes)" 0
8053 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
8054 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
8057 if [[ $RC -eq 0 ]]; then
8058 error "Must return error due to dropped pages, rc=$RC"
8062 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
8063 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
8067 echo "Dirty pages not leaked on ENOENT"
8069 # Due to the above error the OSC will issue all RPCs syncronously
8070 # until a subsequent RPC completes successfully without error.
8071 $MULTIOP $DIR/$tfile Ow4096yc
8076 run_test 118b "Reclaim dirty pages on fatal error =========="
8080 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8082 # for 118c, restore the original resend count, LU-1940
8083 [ "$SLOW" = "no" ] && [ -n "$OLD_RESENDCOUNT" ] &&
8084 set_resend_count $OLD_RESENDCOUNT
8085 remote_ost_nodsh && skip "remote OST with nodsh" && return
8089 #define OBD_FAIL_OST_EROFS 0x216
8090 set_nodes_failloc "$(osts_nodes)" 0x216
8092 # multiop should block due to fsync until pages are written
8093 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
8097 if [[ `ps h -o comm -p $MULTIPID` != "multiop" ]]; then
8098 error "Multiop failed to block on fsync, pid=$MULTIPID"
8101 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
8103 if [[ $WRITEBACK -eq 0 ]]; then
8104 error "No page in writeback, writeback=$WRITEBACK"
8107 set_nodes_failloc "$(osts_nodes)" 0
8110 if [[ $RC -ne 0 ]]; then
8111 error "Multiop fsync failed, rc=$RC"
8114 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
8115 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
8117 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
8118 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
8122 echo "Dirty pages flushed via fsync on EROFS"
8125 run_test 118c "Fsync blocks on EROFS until dirty pages are flushed =========="
8127 # continue to use small resend count to reduce test_118* time (b=14842)
8128 [ "$SLOW" = "no" ] && set_resend_count $NO_SLOW_RESENDCOUNT
8132 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8133 remote_ost_nodsh && skip "remote OST with nodsh" && return
8137 #define OBD_FAIL_OST_BRW_PAUSE_BULK
8138 set_nodes_failloc "$(osts_nodes)" 0x214
8139 # multiop should block due to fsync until pages are written
8140 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
8144 if [[ `ps h -o comm -p $MULTIPID` != "multiop" ]]; then
8145 error "Multiop failed to block on fsync, pid=$MULTIPID"
8148 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
8150 if [[ $WRITEBACK -eq 0 ]]; then
8151 error "No page in writeback, writeback=$WRITEBACK"
8154 wait $MULTIPID || error "Multiop fsync failed, rc=$?"
8155 set_nodes_failloc "$(osts_nodes)" 0
8157 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
8158 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
8160 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
8161 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
8165 echo "Dirty pages gaurenteed flushed via fsync"
8168 run_test 118d "Fsync validation inject a delay of the bulk =========="
8171 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8174 #define OBD_FAIL_OSC_BRW_PREP_REQ2 0x40a
8175 lctl set_param fail_loc=0x8000040a
8177 # Should simulate EINVAL error which is fatal
8178 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
8180 if [[ $RC -eq 0 ]]; then
8181 error "Must return error due to dropped pages, rc=$RC"
8184 lctl set_param fail_loc=0x0
8186 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
8187 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
8188 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
8190 if [[ $LOCKED -ne 0 ]]; then
8191 error "Locked pages remain in cache, locked=$LOCKED"
8194 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
8195 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
8199 echo "No pages locked after fsync"
8204 run_test 118f "Simulate unrecoverable OSC side error =========="
8207 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8210 #define OBD_FAIL_OSC_BRW_PREP_REQ 0x406
8211 lctl set_param fail_loc=0x406
8213 # simulate local -ENOMEM
8214 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
8217 lctl set_param fail_loc=0
8218 if [[ $RC -eq 0 ]]; then
8219 error "Must return error due to dropped pages, rc=$RC"
8222 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
8223 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
8224 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
8226 if [[ $LOCKED -ne 0 ]]; then
8227 error "Locked pages remain in cache, locked=$LOCKED"
8230 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
8231 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
8235 echo "No pages locked after fsync"
8240 run_test 118g "Don't stay in wait if we got local -ENOMEM =========="
8243 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8244 remote_ost_nodsh && skip "remote OST with nodsh" && return
8248 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
8249 set_nodes_failloc "$(osts_nodes)" 0x20e
8250 # Should simulate ENOMEM error which is recoverable and should be handled by timeout
8251 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
8254 set_nodes_failloc "$(osts_nodes)" 0
8255 if [[ $RC -eq 0 ]]; then
8256 error "Must return error due to dropped pages, rc=$RC"
8259 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
8260 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
8261 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
8263 if [[ $LOCKED -ne 0 ]]; then
8264 error "Locked pages remain in cache, locked=$LOCKED"
8267 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
8268 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
8272 echo "No pages locked after fsync"
8276 run_test 118h "Verify timeout in handling recoverables errors =========="
8278 [ "$SLOW" = "no" ] && [ -n "$OLD_RESENDCOUNT" ] && set_resend_count $OLD_RESENDCOUNT
8281 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8282 remote_ost_nodsh && skip "remote OST with nodsh" && return
8286 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
8287 set_nodes_failloc "$(osts_nodes)" 0x20e
8289 # Should simulate ENOMEM error which is recoverable and should be handled by timeout
8290 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
8293 set_nodes_failloc "$(osts_nodes)" 0
8297 if [[ $RC -ne 0 ]]; then
8298 error "got error, but should be not, rc=$RC"
8301 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
8302 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
8303 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
8304 if [[ $LOCKED -ne 0 ]]; then
8305 error "Locked pages remain in cache, locked=$LOCKED"
8308 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
8309 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
8313 echo "No pages locked after fsync"
8317 run_test 118i "Fix error before timeout in recoverable error =========="
8319 [ "$SLOW" = "no" ] && set_resend_count 4
8322 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8323 remote_ost_nodsh && skip "remote OST with nodsh" && return
8327 #define OBD_FAIL_OST_BRW_WRITE_BULK2 0x220
8328 set_nodes_failloc "$(osts_nodes)" 0x220
8330 # return -EIO from OST
8331 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
8333 set_nodes_failloc "$(osts_nodes)" 0x0
8334 if [[ $RC -eq 0 ]]; then
8335 error "Must return error due to dropped pages, rc=$RC"
8338 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
8339 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
8340 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
8341 if [[ $LOCKED -ne 0 ]]; then
8342 error "Locked pages remain in cache, locked=$LOCKED"
8345 # in recoverable error on OST we want resend and stay until it finished
8346 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
8347 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
8351 echo "No pages locked after fsync"
8355 run_test 118j "Simulate unrecoverable OST side error =========="
8359 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8360 remote_ost_nodsh && skip "remote OSTs with nodsh" && return
8362 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
8363 set_nodes_failloc "$(osts_nodes)" 0x20e
8364 test_mkdir -p $DIR/$tdir
8366 for ((i=0;i<10;i++)); do
8367 (dd if=/dev/zero of=$DIR/$tdir/$tfile-$i bs=1M count=10 || \
8368 error "dd to $DIR/$tdir/$tfile-$i failed" )&
8375 set_nodes_failloc "$(osts_nodes)" 0
8378 run_test 118k "bio alloc -ENOMEM and IO TERM handling ========="
8382 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8384 test_mkdir -p $DIR/$tdir
8385 $MULTIOP $DIR/$tdir Dy || error "fsync dir failed"
8388 run_test 118l "fsync dir ========="
8390 test_118m() # LU-3066
8392 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8393 test_mkdir -p $DIR/$tdir
8394 $MULTIOP $DIR/$tdir DY || error "fdatasync dir failed"
8397 run_test 118m "fdatasync dir ========="
8399 [ "$SLOW" = "no" ] && [ -n "$OLD_RESENDCOUNT" ] && set_resend_count $OLD_RESENDCOUNT
8401 test_119a() # bug 11737
8403 BSIZE=$((512 * 1024))
8404 directio write $DIR/$tfile 0 1 $BSIZE
8405 # We ask to read two blocks, which is more than a file size.
8406 # directio will indicate an error when requested and actual
8407 # sizes aren't equeal (a normal situation in this case) and
8408 # print actual read amount.
8409 NOB=`directio read $DIR/$tfile 0 2 $BSIZE | awk '/error/ {print $6}'`
8410 if [ "$NOB" != "$BSIZE" ]; then
8411 error "read $NOB bytes instead of $BSIZE"
8415 run_test 119a "Short directIO read must return actual read amount"
8417 test_119b() # bug 11737
8419 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
8421 $SETSTRIPE -c 2 $DIR/$tfile || error "setstripe failed"
8422 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=1 || error "dd failed"
8424 $MULTIOP $DIR/$tfile oO_RDONLY:O_DIRECT:r$((2048 * 1024)) || \
8425 error "direct read failed"
8428 run_test 119b "Sparse directIO read must return actual read amount"
8430 test_119c() # bug 13099
8433 directio write $DIR/$tfile 3 1 $BSIZE || error "direct write failed"
8434 directio readhole $DIR/$tfile 0 2 $BSIZE || error "reading hole failed"
8437 run_test 119c "Testing for direct read hitting hole"
8439 test_119d() # bug 15950
8441 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8442 MAX_RPCS_IN_FLIGHT=`$LCTL get_param -n osc.*OST0000-osc-[^mM]*.max_rpcs_in_flight`
8443 $LCTL set_param -n osc.*OST0000-osc-[^mM]*.max_rpcs_in_flight 1
8445 $SETSTRIPE $DIR/$tfile -i 0 -c 1 || error "setstripe failed"
8446 $DIRECTIO write $DIR/$tfile 0 1 $BSIZE || error "first directio failed"
8447 #define OBD_FAIL_OSC_DIO_PAUSE 0x40d
8448 lctl set_param fail_loc=0x40d
8449 $DIRECTIO write $DIR/$tfile 1 4 $BSIZE &
8452 cat $DIR/$tfile > /dev/null &
8453 lctl set_param fail_loc=0
8456 log "the DIO writes have completed, now wait for the reads (should not block very long)"
8458 [ -n "`ps h -p $pid_reads -o comm`" ] && \
8459 error "the read rpcs have not completed in 2s"
8461 $LCTL set_param -n osc.*OST0000-osc-[^mM]*.max_rpcs_in_flight $MAX_RPCS_IN_FLIGHT
8463 run_test 119d "The DIO path should try to send a new rpc once one is completed"
8466 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8467 remote_mds_nodsh && skip "remote MDS with nodsh" && return
8468 test_mkdir -p $DIR/$tdir
8469 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
8470 skip "no early lock cancel on server" && return 0
8472 lru_resize_disable mdc
8473 lru_resize_disable osc
8474 cancel_lru_locks mdc
8475 # asynchronous object destroy at MDT could cause bl ast to client
8476 cancel_lru_locks osc
8478 stat $DIR/$tdir > /dev/null
8479 can1=$(do_facet $SINGLEMDS \
8480 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8481 awk '/ldlm_cancel/ {print $2}')
8482 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8483 awk '/ldlm_bl_callback/ {print $2}')
8484 test_mkdir -c1 $DIR/$tdir/d1
8485 can2=$(do_facet $SINGLEMDS \
8486 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8487 awk '/ldlm_cancel/ {print $2}')
8488 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8489 awk '/ldlm_bl_callback/ {print $2}')
8490 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
8491 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
8492 lru_resize_enable mdc
8493 lru_resize_enable osc
8495 run_test 120a "Early Lock Cancel: mkdir test"
8498 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8499 remote_mds_nodsh && skip "remote MDS with nodsh" && return
8500 test_mkdir $DIR/$tdir
8501 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel)" ] && \
8502 skip "no early lock cancel on server" && return 0
8503 lru_resize_disable mdc
8504 lru_resize_disable osc
8505 cancel_lru_locks mdc
8506 stat $DIR/$tdir > /dev/null
8507 can1=$(do_facet $SINGLEMDS \
8508 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8509 awk '/ldlm_cancel/ {print $2}')
8510 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8511 awk '/ldlm_bl_callback/ {print $2}')
8513 can2=$(do_facet $SINGLEMDS \
8514 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8515 awk '/ldlm_cancel/ {print $2}')
8516 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8517 awk '/ldlm_bl_callback/ {print $2}')
8518 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
8519 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
8520 lru_resize_enable mdc
8521 lru_resize_enable osc
8523 run_test 120b "Early Lock Cancel: create test"
8526 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8527 remote_mds_nodsh && skip "remote MDS with nodsh" && return
8528 test_mkdir -c1 $DIR/$tdir
8529 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel)" ] && \
8530 skip "no early lock cancel on server" && return 0
8531 lru_resize_disable mdc
8532 lru_resize_disable osc
8533 test_mkdir -p -c1 $DIR/$tdir/d1
8534 test_mkdir -p -c1 $DIR/$tdir/d2
8535 touch $DIR/$tdir/d1/f1
8536 cancel_lru_locks mdc
8537 stat $DIR/$tdir/d1 $DIR/$tdir/d2 $DIR/$tdir/d1/f1 > /dev/null
8538 can1=$(do_facet $SINGLEMDS \
8539 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8540 awk '/ldlm_cancel/ {print $2}')
8541 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8542 awk '/ldlm_bl_callback/ {print $2}')
8543 ln $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2
8544 can2=$(do_facet $SINGLEMDS \
8545 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8546 awk '/ldlm_cancel/ {print $2}')
8547 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8548 awk '/ldlm_bl_callback/ {print $2}')
8549 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
8550 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
8551 lru_resize_enable mdc
8552 lru_resize_enable osc
8554 run_test 120c "Early Lock Cancel: link test"
8557 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8558 remote_mds_nodsh && skip "remote MDS with nodsh" && return
8559 test_mkdir -p -c1 $DIR/$tdir
8560 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel)" ] && \
8561 skip "no early lock cancel on server" && return 0
8562 lru_resize_disable mdc
8563 lru_resize_disable osc
8565 cancel_lru_locks mdc
8566 stat $DIR/$tdir > /dev/null
8567 can1=$(do_facet $SINGLEMDS \
8568 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8569 awk '/ldlm_cancel/ {print $2}')
8570 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8571 awk '/ldlm_bl_callback/ {print $2}')
8572 chmod a+x $DIR/$tdir
8573 can2=$(do_facet $SINGLEMDS \
8574 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8575 awk '/ldlm_cancel/ {print $2}')
8576 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8577 awk '/ldlm_bl_callback/ {print $2}')
8578 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
8579 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
8580 lru_resize_enable mdc
8581 lru_resize_enable osc
8583 run_test 120d "Early Lock Cancel: setattr test"
8586 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8587 ! $($LCTL get_param -n mdc.*.connect_flags | grep -q early_lock_can) &&
8588 skip "no early lock cancel on server" && return 0
8589 remote_mds_nodsh && skip "remote MDS with nodsh" && return
8590 local dlmtrace_set=false
8592 test_mkdir -p -c1 $DIR/$tdir
8593 lru_resize_disable mdc
8594 lru_resize_disable osc
8595 ! $LCTL get_param debug | grep -q dlmtrace &&
8596 $LCTL set_param debug=+dlmtrace && dlmtrace_set=true
8597 dd if=/dev/zero of=$DIR/$tdir/f1 count=1
8598 cancel_lru_locks mdc
8599 cancel_lru_locks osc
8600 dd if=$DIR/$tdir/f1 of=/dev/null
8601 stat $DIR/$tdir $DIR/$tdir/f1 > /dev/null
8602 # XXX client can not do early lock cancel of OST lock
8603 # during unlink (LU-4206), so cancel osc lock now.
8605 cancel_lru_locks osc
8606 can1=$(do_facet $SINGLEMDS \
8607 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8608 awk '/ldlm_cancel/ {print $2}')
8609 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8610 awk '/ldlm_bl_callback/ {print $2}')
8611 unlink $DIR/$tdir/f1
8613 can2=$(do_facet $SINGLEMDS \
8614 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8615 awk '/ldlm_cancel/ {print $2}')
8616 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8617 awk '/ldlm_bl_callback/ {print $2}')
8618 [ $can1 -ne $can2 ] && error "$((can2 - can1)) cancel RPC occured" &&
8619 $LCTL dk $TMP/cancel.debug.txt
8620 [ $blk1 -ne $blk2 ] && error "$((blk2 - blk1)) blocking RPC occured" &&
8621 $LCTL dk $TMP/blocking.debug.txt
8622 $dlmtrace_set && $LCTL set_param debug=-dlmtrace
8623 lru_resize_enable mdc
8624 lru_resize_enable osc
8626 run_test 120e "Early Lock Cancel: unlink test"
8629 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8630 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
8631 skip "no early lock cancel on server" && return 0
8632 remote_mds_nodsh && skip "remote MDS with nodsh" && return
8633 test_mkdir -p -c1 $DIR/$tdir
8634 lru_resize_disable mdc
8635 lru_resize_disable osc
8636 test_mkdir -p -c1 $DIR/$tdir/d1
8637 test_mkdir -p -c1 $DIR/$tdir/d2
8638 dd if=/dev/zero of=$DIR/$tdir/d1/f1 count=1
8639 dd if=/dev/zero of=$DIR/$tdir/d2/f2 count=1
8640 cancel_lru_locks mdc
8641 cancel_lru_locks osc
8642 dd if=$DIR/$tdir/d1/f1 of=/dev/null
8643 dd if=$DIR/$tdir/d2/f2 of=/dev/null
8644 stat $DIR/$tdir/d1 $DIR/$tdir/d2 $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2 > /dev/null
8645 # XXX client can not do early lock cancel of OST lock
8646 # during rename (LU-4206), so cancel osc lock now.
8648 cancel_lru_locks osc
8649 can1=$(do_facet $SINGLEMDS \
8650 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8651 awk '/ldlm_cancel/ {print $2}')
8652 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8653 awk '/ldlm_bl_callback/ {print $2}')
8654 mrename $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2
8656 can2=$(do_facet $SINGLEMDS \
8657 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8658 awk '/ldlm_cancel/ {print $2}')
8659 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8660 awk '/ldlm_bl_callback/ {print $2}')
8661 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
8662 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
8663 lru_resize_enable mdc
8664 lru_resize_enable osc
8666 run_test 120f "Early Lock Cancel: rename test"
8669 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8670 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
8671 skip "no early lock cancel on server" && return 0
8672 remote_mds_nodsh && skip "remote MDS with nodsh" && return
8673 lru_resize_disable mdc
8674 lru_resize_disable osc
8676 echo create $count files
8677 test_mkdir -p $DIR/$tdir
8678 cancel_lru_locks mdc
8679 cancel_lru_locks osc
8682 can0=$(do_facet $SINGLEMDS \
8683 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8684 awk '/ldlm_cancel/ {print $2}')
8685 blk0=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8686 awk '/ldlm_bl_callback/ {print $2}')
8687 createmany -o $DIR/$tdir/f $count
8689 can1=$(do_facet $SINGLEMDS \
8690 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8691 awk '/ldlm_cancel/ {print $2}')
8692 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8693 awk '/ldlm_bl_callback/ {print $2}')
8695 echo total: $((can1-can0)) cancels, $((blk1-blk0)) blockings
8696 echo rm $count files
8699 can2=$(do_facet $SINGLEMDS \
8700 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8701 awk '/ldlm_cancel/ {print $2}')
8702 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8703 awk '/ldlm_bl_callback/ {print $2}')
8705 echo total: $count removes in $((t2-t1))
8706 echo total: $((can2-can1)) cancels, $((blk2-blk1)) blockings
8708 # wait for commitment of removal
8709 lru_resize_enable mdc
8710 lru_resize_enable osc
8712 run_test 120g "Early Lock Cancel: performance test"
8714 test_121() { #bug #10589
8715 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8717 writes=$(LANG=C dd if=/dev/zero of=$DIR/$tfile count=1 2>&1 | awk -F '+' '/out$/ {print $1}')
8718 #define OBD_FAIL_LDLM_CANCEL_RACE 0x310
8719 lctl set_param fail_loc=0x310
8720 cancel_lru_locks osc > /dev/null
8721 reads=$(LANG=C dd if=$DIR/$tfile of=/dev/null 2>&1 | awk -F '+' '/in$/ {print $1}')
8722 lctl set_param fail_loc=0
8723 [[ $reads -eq $writes ]] ||
8724 error "read $reads blocks, must be $writes blocks"
8726 run_test 121 "read cancel race ========="
8728 test_123a() { # was test 123, statahead(bug 11401)
8729 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8731 if [ -z "$(grep "processor.*: 1" /proc/cpuinfo)" ]; then
8732 log "testing on UP system. Performance may be not as good as expected."
8737 test_mkdir -p $DIR/$tdir
8738 NUMFREE=$(df -i -P $DIR | tail -n 1 | awk '{ print $4 }')
8739 [[ $NUMFREE -gt 100000 ]] && NUMFREE=100000 || NUMFREE=$((NUMFREE-1000))
8741 for ((i=100, j=0; i<=$NUMFREE; j=$i, i=$((i * MULT)) )); do
8742 createmany -o $DIR/$tdir/$tfile $j $((i - j))
8744 max=`lctl get_param -n llite.*.statahead_max | head -n 1`
8745 lctl set_param -n llite.*.statahead_max 0
8746 lctl get_param llite.*.statahead_max
8747 cancel_lru_locks mdc
8748 cancel_lru_locks osc
8750 time ls -l $DIR/$tdir | wc -l
8752 delta=$((etime - stime))
8753 log "ls $i files without statahead: $delta sec"
8754 lctl set_param llite.*.statahead_max=$max
8756 swrong=`lctl get_param -n llite.*.statahead_stats | grep "statahead wrong:" | awk '{print $3}'`
8757 lctl get_param -n llite.*.statahead_max | grep '[0-9]'
8758 cancel_lru_locks mdc
8759 cancel_lru_locks osc
8761 time ls -l $DIR/$tdir | wc -l
8763 delta_sa=$((etime - stime))
8764 log "ls $i files with statahead: $delta_sa sec"
8765 lctl get_param -n llite.*.statahead_stats
8766 ewrong=`lctl get_param -n llite.*.statahead_stats | grep "statahead wrong:" | awk '{print $3}'`
8768 [[ $swrong -lt $ewrong ]] &&
8769 log "statahead was stopped, maybe too many locks held!"
8770 [[ $delta -eq 0 || $delta_sa -eq 0 ]] && continue
8772 if [ $((delta_sa * 100)) -gt $((delta * 105)) -a $delta_sa -gt $((delta + 2)) ]; then
8773 max=`lctl get_param -n llite.*.statahead_max | head -n 1`
8774 lctl set_param -n llite.*.statahead_max 0
8775 lctl get_param llite.*.statahead_max
8776 cancel_lru_locks mdc
8777 cancel_lru_locks osc
8779 time ls -l $DIR/$tdir | wc -l
8781 delta=$((etime - stime))
8782 log "ls $i files again without statahead: $delta sec"
8783 lctl set_param llite.*.statahead_max=$max
8784 if [ $((delta_sa * 100)) -gt $((delta * 105)) -a $delta_sa -gt $((delta + 2)) ]; then
8785 if [ $SLOWOK -eq 0 ]; then
8786 error "ls $i files is slower with statahead!"
8788 log "ls $i files is slower with statahead!"
8794 [ $delta -gt 20 ] && break
8795 [ $delta -gt 8 ] && MULT=$((50 / delta))
8796 [ "$SLOW" = "no" -a $delta -gt 5 ] && break
8804 delta=$((etime - stime))
8805 log "rm -r $DIR/$tdir/: $delta seconds"
8807 lctl get_param -n llite.*.statahead_stats
8809 run_test 123a "verify statahead work"
8811 test_123b () { # statahead(bug 15027)
8812 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8813 test_mkdir -p $DIR/$tdir
8814 createmany -o $DIR/$tdir/$tfile-%d 1000
8816 cancel_lru_locks mdc
8817 cancel_lru_locks osc
8819 #define OBD_FAIL_MDC_GETATTR_ENQUEUE 0x803
8820 lctl set_param fail_loc=0x80000803
8821 ls -lR $DIR/$tdir > /dev/null
8823 lctl set_param fail_loc=0x0
8824 lctl get_param -n llite.*.statahead_stats
8829 run_test 123b "not panic with network error in statahead enqueue (bug 15027)"
8832 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8833 [ -z "$($LCTL get_param -n mdc.*.connect_flags | grep lru_resize)" ] &&
8834 skip "no lru resize on server" && return 0
8836 test_mkdir -p $DIR/$tdir || error "failed to create $DIR/$tdir"
8838 log "create $NR files at $DIR/$tdir"
8839 createmany -o $DIR/$tdir/f $NR ||
8840 error "failed to create $NR files in $DIR/$tdir"
8842 cancel_lru_locks mdc
8843 ls -l $DIR/$tdir > /dev/null
8847 for VALUE in $($LCTL get_param ldlm.namespaces.*mdc-*.lru_size); do
8848 local PARAM=$(echo ${VALUE[0]} | cut -d "=" -f1)
8849 LRU_SIZE=$($LCTL get_param -n $PARAM)
8850 if [[ $LRU_SIZE -gt $(default_lru_size) ]]; then
8851 NSDIR=$(echo $PARAM | cut -d "." -f1-3)
8853 log "NS=$(basename $NSDIR)"
8858 if [[ -z "$NSDIR" || $LRU_SIZE -lt $(default_lru_size) ]]; then
8859 skip "Not enough cached locks created!"
8866 # We know that lru resize allows one client to hold $LIMIT locks
8867 # for 10h. After that locks begin to be killed by client.
8869 local LIMIT=$($LCTL get_param -n $NSDIR.pool.limit)
8871 if [ $LIMIT -lt $LRU_SIZE ]; then
8872 skip "Limit is too small $LIMIT"
8876 # Make LVF so higher that sleeping for $SLEEP is enough to _start_
8877 # killing locks. Some time was spent for creating locks. This means
8878 # that up to the moment of sleep finish we must have killed some of
8879 # them (10-100 locks). This depends on how fast ther were created.
8880 # Many of them were touched in almost the same moment and thus will
8881 # be killed in groups.
8882 local LVF=$(($MAX_HRS * 60 * 60 / $SLEEP * $LIMIT / $LRU_SIZE))
8884 # Use $LRU_SIZE_B here to take into account real number of locks
8885 # created in the case of CMD, LRU_SIZE_B != $NR in most of cases
8886 local LRU_SIZE_B=$LRU_SIZE
8888 local OLD_LVF=$($LCTL get_param -n $NSDIR.pool.lock_volume_factor)
8889 log "OLD_LVF=$OLD_LVF"
8890 $LCTL set_param -n $NSDIR.pool.lock_volume_factor $LVF
8892 # Let's make sure that we really have some margin. Client checks
8893 # cached locks every 10 sec.
8895 log "Sleep ${SLEEP} sec"
8897 while ((SEC<$SLEEP)); do
8901 LRU_SIZE=$($LCTL get_param -n $NSDIR/lru_size)
8905 $LCTL set_param -n $NSDIR.pool.lock_volume_factor $OLD_LVF
8906 local LRU_SIZE_A=$($LCTL get_param -n $NSDIR.lru_size)
8908 [[ $LRU_SIZE_B -gt $LRU_SIZE_A ]] || {
8909 error "No locks dropped in ${SLEEP}s. LRU size: $LRU_SIZE_A"
8910 unlinkmany $DIR/$tdir/f $NR
8914 log "Dropped "$((LRU_SIZE_B-LRU_SIZE_A))" locks in ${SLEEP}s"
8915 log "unlink $NR files at $DIR/$tdir"
8916 unlinkmany $DIR/$tdir/f $NR
8918 run_test 124a "lru resize ======================================="
8920 get_max_pool_limit()
8922 local limit=$($LCTL get_param \
8923 -n ldlm.namespaces.*-MDT0000-mdc-*.pool.limit)
8926 if [[ $l -gt $max ]]; then
8934 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8935 [ -z "$($LCTL get_param -n mdc.*.connect_flags | grep lru_resize)" ] &&
8936 skip "no lru resize on server" && return 0
8938 LIMIT=$(get_max_pool_limit)
8940 NR=$(($(default_lru_size)*20))
8941 if [[ $NR -gt $LIMIT ]]; then
8942 log "Limit lock number by $LIMIT locks"
8946 IFree=$(mdsrate_inodes_available)
8947 if [ $IFree -lt $NR ]; then
8948 log "Limit lock number by $IFree inodes"
8952 lru_resize_disable mdc
8953 test_mkdir -p $DIR/$tdir/disable_lru_resize ||
8954 error "failed to create $DIR/$tdir/disable_lru_resize"
8956 createmany -o $DIR/$tdir/disable_lru_resize/f $NR
8957 log "doing ls -la $DIR/$tdir/disable_lru_resize 3 times"
8958 cancel_lru_locks mdc
8961 ls -la $DIR/$tdir/disable_lru_resize > /dev/null &
8964 ls -la $DIR/$tdir/disable_lru_resize > /dev/null &
8967 ls -la $DIR/$tdir/disable_lru_resize > /dev/null &
8971 nolruresize_delta=$((etime-stime))
8972 log "ls -la time: $nolruresize_delta seconds"
8973 log "lru_size = $(lctl get_param -n ldlm.namespaces.*mdc*.lru_size)"
8974 unlinkmany $DIR/$tdir/disable_lru_resize/f $NR
8976 lru_resize_enable mdc
8977 test_mkdir -p $DIR/$tdir/enable_lru_resize ||
8978 error "failed to create $DIR/$tdir/enable_lru_resize"
8980 createmany -o $DIR/$tdir/enable_lru_resize/f $NR
8981 log "doing ls -la $DIR/$tdir/enable_lru_resize 3 times"
8982 cancel_lru_locks mdc
8985 ls -la $DIR/$tdir/enable_lru_resize > /dev/null &
8988 ls -la $DIR/$tdir/enable_lru_resize > /dev/null &
8991 ls -la $DIR/$tdir/enable_lru_resize > /dev/null &
8995 lruresize_delta=$((etime-stime))
8996 log "ls -la time: $lruresize_delta seconds"
8997 log "lru_size = $(lctl get_param -n ldlm.namespaces.*mdc*.lru_size)"
8999 if [ $lruresize_delta -gt $nolruresize_delta ]; then
9000 log "ls -la is $(((lruresize_delta - $nolruresize_delta) * 100 / $nolruresize_delta))% slower with lru resize enabled"
9001 elif [ $nolruresize_delta -gt $lruresize_delta ]; then
9002 log "ls -la is $(((nolruresize_delta - $lruresize_delta) * 100 / $nolruresize_delta))% faster with lru resize enabled"
9004 log "lru resize performs the same with no lru resize"
9006 unlinkmany $DIR/$tdir/enable_lru_resize/f $NR
9008 run_test 124b "lru resize (performance test) ======================="
9011 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9012 [ -z "$($LCTL get_param -n mdc.*.connect_flags | grep lru_resize)" ] &&
9013 skip "no lru resize on server" && return 0
9015 # cache ununsed locks on client
9017 cancel_lru_locks mdc
9018 test_mkdir -p $DIR/$tdir || error "failed to create $DIR/$tdir"
9019 createmany -o $DIR/$tdir/f $nr ||
9020 error "failed to create $nr files in $DIR/$tdir"
9021 ls -l $DIR/$tdir > /dev/null
9023 local nsdir="ldlm.namespaces.*-MDT0000-mdc-*"
9024 local unused=$($LCTL get_param -n $nsdir.lock_unused_count)
9025 local max_age=$($LCTL get_param -n $nsdir.lru_max_age)
9026 local recalc_p=$($LCTL get_param -n $nsdir.pool.recalc_period)
9027 echo "unused=$unused, max_age=$max_age, recalc_p=$recalc_p"
9029 # set lru_max_age to 1 sec
9030 $LCTL set_param $nsdir.lru_max_age=1000 # milliseconds
9031 echo "sleep $((recalc_p * 2)) seconds..."
9032 sleep $((recalc_p * 2))
9034 local remaining=$($LCTL get_param -n $nsdir.lock_unused_count)
9035 # restore lru_max_age
9036 $LCTL set_param -n $nsdir.lru_max_age $max_age
9037 [ $remaining -eq 0 ] || error "$remaining locks are not canceled"
9038 unlinkmany $DIR/$tdir/f $nr
9040 run_test 124c "LRUR cancel very aged locks"
9042 test_125() { # 13358
9043 [ -z "$(lctl get_param -n llite.*.client_type | grep local)" ] && skip "must run as local client" && return
9044 [ -z "$(lctl get_param -n mdc.*-mdc-*.connect_flags | grep acl)" ] && skip "must have acl enabled" && return
9045 [ -z "$(which setfacl)" ] && skip "must have setfacl tool" && return
9046 test_mkdir -p $DIR/d125 || error "mkdir failed"
9047 $SETSTRIPE -S 65536 -c -1 $DIR/d125 || error "setstripe failed"
9048 setfacl -R -m u:bin:rwx $DIR/d125 || error "setfacl $DIR/d125 failed"
9049 ls -ld $DIR/d125 || error "cannot access $DIR/d125"
9051 run_test 125 "don't return EPROTO when a dir has a non-default striping and ACLs"
9053 test_126() { # bug 12829/13455
9054 [ -z "$(lctl get_param -n llite.*.client_type | grep local)" ] && skip "must run as local client" && return
9055 [ "$UID" != 0 ] && skip_env "skipping $TESTNAME (must run as root)" && return
9056 $GSS && skip "must run as gss disabled" && return
9058 $RUNAS -u 0 -g 1 touch $DIR/$tfile || error "touch failed"
9059 gid=`ls -n $DIR/$tfile | awk '{print $4}'`
9061 [ $gid -eq "1" ] || error "gid is set to" $gid "instead of 1"
9063 run_test 126 "check that the fsgid provided by the client is taken into account"
9065 test_127a() { # bug 15521
9066 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9067 $SETSTRIPE -i 0 -c 1 $DIR/$tfile || error "setstripe failed"
9068 $LCTL set_param osc.*.stats=0
9069 FSIZE=$((2048 * 1024))
9070 dd if=/dev/zero of=$DIR/$tfile bs=$FSIZE count=1
9071 cancel_lru_locks osc
9072 dd if=$DIR/$tfile of=/dev/null bs=$FSIZE
9074 $LCTL get_param osc.*0000-osc-*.stats | grep samples > $DIR/${tfile}.tmp
9075 while read NAME COUNT SAMP UNIT MIN MAX SUM SUMSQ; do
9076 echo "got $COUNT $NAME"
9077 [ ! $MIN ] && error "Missing min value for $NAME proc entry"
9078 eval $NAME=$COUNT || error "Wrong proc format"
9081 read_bytes|write_bytes)
9082 [ $MIN -lt 4096 ] && error "min is too small: $MIN"
9083 [ $MIN -gt $FSIZE ] && error "min is too big: $MIN"
9084 [ $MAX -lt 4096 ] && error "max is too small: $MAX"
9085 [ $MAX -gt $FSIZE ] && error "max is too big: $MAX"
9086 [ $SUM -ne $FSIZE ] && error "sum is wrong: $SUM"
9087 [ $SUMSQ -lt $(((FSIZE /4096) * (4096 * 4096))) ] &&
9088 error "sumsquare is too small: $SUMSQ"
9089 [ $SUMSQ -gt $((FSIZE * FSIZE)) ] &&
9090 error "sumsquare is too big: $SUMSQ"
9094 done < $DIR/${tfile}.tmp
9096 #check that we actually got some stats
9097 [ "$read_bytes" ] || error "Missing read_bytes stats"
9098 [ "$write_bytes" ] || error "Missing write_bytes stats"
9099 [ "$read_bytes" != 0 ] || error "no read done"
9100 [ "$write_bytes" != 0 ] || error "no write done"
9102 run_test 127a "verify the client stats are sane"
9104 test_127b() { # bug LU-333
9105 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9106 $LCTL set_param llite.*.stats=0
9107 FSIZE=65536 # sized fixed to match PAGE_SIZE for most clients
9108 # perform 2 reads and writes so MAX is different from SUM.
9109 dd if=/dev/zero of=$DIR/$tfile bs=$FSIZE count=1
9110 dd if=/dev/zero of=$DIR/$tfile bs=$FSIZE count=1
9111 cancel_lru_locks osc
9112 dd if=$DIR/$tfile of=/dev/null bs=$FSIZE count=1
9113 dd if=$DIR/$tfile of=/dev/null bs=$FSIZE count=1
9115 $LCTL get_param llite.*.stats | grep samples > $TMP/${tfile}.tmp
9116 while read NAME COUNT SAMP UNIT MIN MAX SUM SUMSQ; do
9117 echo "got $COUNT $NAME"
9118 eval $NAME=$COUNT || error "Wrong proc format"
9122 [ $COUNT -ne 2 ] && error "count is not 2: $COUNT"
9123 [ $MIN -ne $FSIZE ] && error "min is not $FSIZE: $MIN"
9124 [ $MAX -ne $FSIZE ] && error "max is incorrect: $MAX"
9125 [ $SUM -ne $((FSIZE * 2)) ] && error "sum is wrong: $SUM"
9128 [ $COUNT -ne 2 ] && error "count is not 2: $COUNT"
9129 [ $MIN -ne $FSIZE ] && error "min is not $FSIZE: $MIN"
9130 [ $MAX -ne $FSIZE ] && error "max is incorrect: $MAX"
9131 [ $SUM -ne $((FSIZE * 2)) ] && error "sum is wrong: $SUM"
9135 done < $TMP/${tfile}.tmp
9137 #check that we actually got some stats
9138 [ "$read_bytes" ] || error "Missing read_bytes stats"
9139 [ "$write_bytes" ] || error "Missing write_bytes stats"
9140 [ "$read_bytes" != 0 ] || error "no read done"
9141 [ "$write_bytes" != 0 ] || error "no write done"
9143 rm -f $TMP/${tfile}.tmp
9145 run_test 127b "verify the llite client stats are sane"
9147 test_128() { # bug 15212
9149 $LFS 2>&1 <<-EOF | tee $TMP/$tfile.log
9154 result=$(grep error $TMP/$tfile.log)
9155 rm -f $DIR/$tfile $TMP/$tfile.log
9157 error "consecutive find's under interactive lfs failed"
9159 run_test 128 "interactive lfs for 2 consecutive find's"
9166 local ldproc=/proc/fs/ldiskfs
9167 local facets=$(get_facets MDS)
9169 for facet in ${facets//,/ }; do
9170 canondev=$(ldiskfs_canon \
9171 *.$(convert_facet2label $facet).mntdev $facet)
9172 do_facet $facet "test -e $ldproc/$canondev/max_dir_size" ||
9173 ldproc=/sys/fs/ldiskfs
9174 do_facet $facet "echo $1 >$ldproc/$canondev/max_dir_size"
9175 do_facet $facet "echo $2 >$ldproc/$canondev/warning_dir_size"
9180 local facets=$(get_facets MDS)
9181 for facet in ${facets//,/ }; do
9182 do_facet $facet "dmesg | tail -3 | grep -q $1" && return 0
9188 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.5.56) ]] ||
9189 { skip "Need MDS version with at least 2.5.56"; return 0; }
9191 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9192 if [ "$(facet_fstype $SINGLEMDS)" != ldiskfs ]; then
9193 skip "ldiskfs only test"
9196 remote_mds_nodsh && skip "remote MDS with nodsh" && return
9199 local has_warning=false
9204 # block size of mds1
9205 local maxsize=$(($($LCTL get_param -n mdc.*MDT0000*.blocksize) * 5))
9206 set_dir_limits $maxsize $maxsize
9207 local dirsize=$(stat -c%s "$DIR/$tdir")
9209 while [[ $dirsize -le $maxsize ]]; do
9210 $MULTIOP $DIR/$tdir/file_base_$nfiles Oc
9212 if ! $has_warning; then
9213 check_mds_dmesg '"is approaching"' && has_warning=true
9216 # ENOSPC for new ext4 max_dir_size (kernel commit df981d03ee)
9217 # EFBIG for previous versions included in ldiskfs series
9218 if [ $rc -eq $EFBIG -o $rc -eq $ENOSPC ]; then
9220 echo "return code $rc received as expected"
9222 createmany -o $DIR/$tdir/file_extra_$nfiles. 5 ||
9223 error_exit "create failed w/o dir size limit"
9225 check_mds_dmesg '"has reached"' ||
9226 error_exit "reached message should be output"
9228 [ $has_warning -eq 0 ] &&
9229 error_exit "warning message should be output"
9231 dirsize=$(stat -c%s "$DIR/$tdir")
9233 [[ $dirsize -ge $maxsize ]] && return 0
9234 error_exit "current dir size $dirsize, " \
9235 "previous limit $maxsize"
9236 elif [ $rc -ne 0 ]; then
9238 error_exit "return $rc received instead of expected " \
9239 "$EFBIG or $ENOSPC, files in dir $dirsize"
9241 nfiles=$((nfiles + 1))
9242 dirsize=$(stat -c%s "$DIR/$tdir")
9246 error "exceeded dir size limit $maxsize($MDSCOUNT) : $dirsize bytes"
9248 run_test 129 "test directory size limit ========================"
9257 local filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
9258 [ -n "$filefrag_op" ] && skip_env "filefrag does not support FIEMAP" &&
9261 trap cleanup_130 EXIT RETURN
9263 local fm_file=$DIR/$tfile
9264 $SETSTRIPE -S 65536 -c 1 $fm_file || error "setstripe on $fm_file"
9265 dd if=/dev/zero of=$fm_file bs=65536 count=1 ||
9266 error "dd failed for $fm_file"
9268 # LU-1795: test filefrag/FIEMAP once, even if unsupported
9269 filefrag -ves $fm_file
9271 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
9272 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
9273 [ $RC != 0 ] && error "filefrag $fm_file failed"
9275 filefrag_op=$(filefrag -ve $fm_file |
9276 sed -n '/ext:/,/found/{/ext:/d; /found/d; p}')
9277 lun=$($GETSTRIPE -i $fm_file)
9279 start_blk=`echo $filefrag_op | cut -d: -f2 | cut -d. -f1`
9282 for line in $filefrag_op
9284 frag_lun=`echo $line | cut -d: -f5`
9285 ext_len=`echo $line | cut -d: -f4`
9286 if (( $frag_lun != $lun )); then
9288 error "FIEMAP on 1-stripe file($fm_file) failed"
9291 (( tot_len += ext_len ))
9294 if (( lun != frag_lun || start_blk != 0 || tot_len != 64 )); then
9296 error "FIEMAP on 1-stripe file($fm_file) failed;"
9302 echo "FIEMAP on single striped file succeeded"
9304 run_test 130a "FIEMAP (1-stripe file)"
9307 [ "$OSTCOUNT" -lt "2" ] && skip_env "needs >= 2 OSTs" && return
9309 local filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
9310 [ -n "$filefrag_op" ] && skip_env "filefrag does not support FIEMAP" &&
9313 trap cleanup_130 EXIT RETURN
9315 local fm_file=$DIR/$tfile
9316 $SETSTRIPE -S 65536 -c $OSTCOUNT $fm_file ||
9317 error "setstripe on $fm_file"
9318 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
9319 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
9321 dd if=/dev/zero of=$fm_file bs=1M count=$OSTCOUNT ||
9322 error "dd failed on $fm_file"
9324 filefrag -ves $fm_file || error "filefrag $fm_file failed"
9325 filefrag_op=$(filefrag -ve $fm_file |
9326 sed -n '/ext:/,/found/{/ext:/d; /found/d; p}')
9328 last_lun=$(echo $filefrag_op | cut -d: -f5 |
9329 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
9334 for line in $filefrag_op
9336 frag_lun=$(echo $line | cut -d: -f5 |
9337 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
9338 ext_len=$(echo $line | cut -d: -f4)
9339 if (( $frag_lun != $last_lun )); then
9340 if (( tot_len != 1024 )); then
9342 error "FIEMAP on $fm_file failed; returned " \
9343 "len $tot_len for OST $last_lun instead of 1024"
9350 (( tot_len += ext_len ))
9353 if (( num_luns != $OSTCOUNT || tot_len != 1024 )); then
9355 error "FIEMAP on $fm_file failed; returned wrong number of " \
9356 "luns or wrong len for OST $last_lun"
9362 echo "FIEMAP on $OSTCOUNT-stripe file succeeded"
9364 run_test 130b "FIEMAP ($OSTCOUNT-stripe file)"
9367 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
9369 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
9370 [ -n "$filefrag_op" ] && skip "filefrag does not support FIEMAP" &&
9373 trap cleanup_130 EXIT RETURN
9375 local fm_file=$DIR/$tfile
9376 $SETSTRIPE -S 65536 -c 2 $fm_file || error "setstripe on $fm_file"
9377 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
9378 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
9380 dd if=/dev/zero of=$fm_file seek=1 bs=1M count=1 ||
9381 error "dd failed on $fm_file"
9383 filefrag -ves $fm_file || error "filefrag $fm_file failed"
9384 filefrag_op=$(filefrag -ve $fm_file |
9385 sed -n '/ext:/,/found/{/ext:/d; /found/d; p}')
9387 last_lun=$(echo $filefrag_op | cut -d: -f5 |
9388 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
9393 for line in $filefrag_op
9395 frag_lun=$(echo $line | cut -d: -f5 |
9396 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
9397 ext_len=$(echo $line | cut -d: -f4)
9398 if (( $frag_lun != $last_lun )); then
9399 logical=`echo $line | cut -d: -f2 | cut -d. -f1`
9400 if (( logical != 512 )); then
9402 error "FIEMAP on $fm_file failed; returned " \
9403 "logical start for lun $logical instead of 512"
9406 if (( tot_len != 512 )); then
9408 error "FIEMAP on $fm_file failed; returned " \
9409 "len $tot_len for OST $last_lun instead of 1024"
9416 (( tot_len += ext_len ))
9419 if (( num_luns != 2 || tot_len != 512 )); then
9421 error "FIEMAP on $fm_file failed; returned wrong number of " \
9422 "luns or wrong len for OST $last_lun"
9428 echo "FIEMAP on 2-stripe file with hole succeeded"
9430 run_test 130c "FIEMAP (2-stripe file with hole)"
9433 [[ $OSTCOUNT -lt 3 ]] && skip_env "needs >= 3 OSTs" && return
9435 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
9436 [ -n "$filefrag_op" ] && skip "filefrag does not support FIEMAP" &&
9439 trap cleanup_130 EXIT RETURN
9441 local fm_file=$DIR/$tfile
9442 $SETSTRIPE -S 65536 -c $OSTCOUNT $fm_file ||
9443 error "setstripe on $fm_file"
9444 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
9445 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
9447 local actual_stripecnt=$($GETSTRIPE -c $fm_file)
9448 dd if=/dev/zero of=$fm_file bs=1M count=$actual_stripecnt ||
9449 error "dd failed on $fm_file"
9451 filefrag -ves $fm_file || error "filefrag $fm_file failed"
9452 filefrag_op=$(filefrag -ve $fm_file |
9453 sed -n '/ext:/,/found/{/ext:/d; /found/d; p}')
9455 last_lun=$(echo $filefrag_op | cut -d: -f5 |
9456 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
9461 for line in $filefrag_op
9463 frag_lun=$(echo $line | cut -d: -f5 |
9464 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
9465 ext_len=$(echo $line | cut -d: -f4)
9466 if (( $frag_lun != $last_lun )); then
9467 if (( tot_len != 1024 )); then
9469 error "FIEMAP on $fm_file failed; returned " \
9470 "len $tot_len for OST $last_lun instead of 1024"
9477 (( tot_len += ext_len ))
9480 if (( num_luns != actual_stripecnt || tot_len != 1024 )); then
9482 error "FIEMAP on $fm_file failed; returned wrong number of " \
9483 "luns or wrong len for OST $last_lun"
9489 echo "FIEMAP on N-stripe file succeeded"
9491 run_test 130d "FIEMAP (N-stripe file)"
9494 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
9496 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
9497 [ -n "$filefrag_op" ] && skip "filefrag does not support FIEMAP" && return
9499 trap cleanup_130 EXIT RETURN
9501 local fm_file=$DIR/$tfile
9502 $SETSTRIPE -S 131072 -c 2 $fm_file || error "setstripe on $fm_file"
9503 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
9504 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
9507 EXPECTED_LEN=$(( (NUM_BLKS / 2) * 64 ))
9508 for ((i = 0; i < $NUM_BLKS; i++))
9510 dd if=/dev/zero of=$fm_file count=1 bs=64k seek=$((2*$i)) conv=notrunc > /dev/null 2>&1
9513 filefrag -ves $fm_file || error "filefrag $fm_file failed"
9514 filefrag_op=$(filefrag -ve $fm_file |
9515 sed -n '/ext:/,/found/{/ext:/d; /found/d; p}')
9517 last_lun=$(echo $filefrag_op | cut -d: -f5 |
9518 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
9523 for line in $filefrag_op
9525 frag_lun=$(echo $line | cut -d: -f5 |
9526 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
9527 ext_len=$(echo $line | cut -d: -f4)
9528 if (( $frag_lun != $last_lun )); then
9529 if (( tot_len != $EXPECTED_LEN )); then
9531 error "FIEMAP on $fm_file failed; returned " \
9532 "len $tot_len for OST $last_lun instead " \
9540 (( tot_len += ext_len ))
9543 if (( num_luns != 2 || tot_len != $EXPECTED_LEN )); then
9545 error "FIEMAP on $fm_file failed; returned wrong number " \
9546 "of luns or wrong len for OST $last_lun"
9552 echo "FIEMAP with continuation calls succeeded"
9554 run_test 130e "FIEMAP (test continuation FIEMAP calls)"
9556 # Test for writev/readv
9558 rwv -f $DIR/$tfile -w -n 3 524288 1048576 1572864 ||
9559 error "writev test failed"
9560 rwv -f $DIR/$tfile -r -v -n 2 1572864 1048576 ||
9561 error "readv failed"
9564 run_test 131a "test iov's crossing stripe boundary for writev/readv"
9567 local fsize=$((524288 + 1048576 + 1572864))
9568 rwv -f $DIR/$tfile -w -a -n 3 524288 1048576 1572864 &&
9569 $CHECKSTAT -t file $DIR/$tfile -s $fsize ||
9570 error "append writev test failed"
9572 ((fsize += 1572864 + 1048576))
9573 rwv -f $DIR/$tfile -w -a -n 2 1572864 1048576 &&
9574 $CHECKSTAT -t file $DIR/$tfile -s $fsize ||
9575 error "append writev test failed"
9578 run_test 131b "test append writev"
9581 rwv -f $DIR/$tfile -w -d -n 1 1048576 || return 0
9584 run_test 131c "test read/write on file w/o objects"
9587 rwv -f $DIR/$tfile -w -n 1 1572864
9588 NOB=`rwv -f $DIR/$tfile -r -n 3 524288 524288 1048576 | awk '/error/ {print $6}'`
9589 if [ "$NOB" != 1572864 ]; then
9590 error "Short read filed: read $NOB bytes instead of 1572864"
9594 run_test 131d "test short read"
9597 rwv -f $DIR/$tfile -w -s 1048576 -n 1 1048576
9598 rwv -f $DIR/$tfile -r -z -s 0 -n 1 524288 || \
9599 error "read hitting hole failed"
9602 run_test 131e "test read hitting hole"
9611 mds*) res=$(do_facet $facet \
9612 $LCTL get_param mdt.$FSNAME-MDT0000.md_stats | grep "$op")
9614 ost*) res=$(do_facet $facet \
9615 $LCTL get_param obdfilter.$FSNAME-OST0000.stats | grep "$op")
9617 *) error "Wrong facet '$facet'" ;;
9620 [ "$res" ] || error "The counter for $op on $facet was not incremented"
9621 # if the argument $3 is zero, it means any stat increment is ok.
9622 if [[ $want -gt 0 ]]; then
9623 local count=$(echo $res | awk '{ print $2 }')
9624 [[ $count -ne $want ]] &&
9625 error "The $op counter on $facet is $count, not $want"
9630 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9631 remote_ost_nodsh && skip "remote OST with nodsh" && return
9632 remote_mds_nodsh && skip "remote MDS with nodsh" && return
9634 do_facet $SINGLEMDS $LCTL list_param mdt.*.rename_stats ||
9635 { skip "MDS doesn't support rename stats"; return; }
9636 local testdir=$DIR/${tdir}/stats_testdir
9637 mkdir -p $DIR/${tdir}
9640 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
9641 do_facet ost1 $LCTL set_param obdfilter.*.stats=clear
9643 # verify mdt stats first.
9644 mkdir ${testdir} || error "mkdir failed"
9645 check_stats $SINGLEMDS "mkdir" 1
9646 touch ${testdir}/${tfile} || error "touch failed"
9647 check_stats $SINGLEMDS "open" 1
9648 check_stats $SINGLEMDS "close" 1
9649 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.8.54) ] && {
9650 mknod ${testdir}/${tfile}-pipe p || error "mknod failed"
9651 check_stats $SINGLEMDS "mknod" 2
9653 rm -f ${testdir}/${tfile}-pipe || error "pipe remove failed"
9654 check_stats $SINGLEMDS "unlink" 1
9655 rm -f ${testdir}/${tfile} || error "file remove failed"
9656 check_stats $SINGLEMDS "unlink" 2
9658 # remove working dir and check mdt stats again.
9659 rmdir ${testdir} || error "rmdir failed"
9660 check_stats $SINGLEMDS "rmdir" 1
9662 local testdir1=$DIR/${tdir}/stats_testdir1
9664 mkdir -p ${testdir1}
9665 touch ${testdir1}/test1
9666 mv ${testdir1}/test1 ${testdir} || error "file crossdir rename"
9667 check_stats $SINGLEMDS "crossdir_rename" 1
9669 mv ${testdir}/test1 ${testdir}/test0 || error "file samedir rename"
9670 check_stats $SINGLEMDS "samedir_rename" 1
9674 run_test 133a "Verifying MDT stats ========================================"
9677 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9678 remote_ost_nodsh && skip "remote OST with nodsh" && return
9679 remote_mds_nodsh && skip "remote MDS with nodsh" && return
9680 local testdir=$DIR/${tdir}/stats_testdir
9681 mkdir -p ${testdir} || error "mkdir failed"
9682 touch ${testdir}/${tfile} || error "touch failed"
9683 cancel_lru_locks mdc
9686 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
9687 do_facet ost1 $LCTL set_param obdfilter.*.stats=clear
9689 # extra mdt stats verification.
9690 chmod 444 ${testdir}/${tfile} || error "chmod failed"
9691 check_stats $SINGLEMDS "setattr" 1
9692 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
9693 if [ $(lustre_version_code $SINGLEMDS) -ne $(version_code 2.2.0) ]
9695 ls -l ${testdir}/${tfile} > /dev/null|| error "ls failed"
9696 check_stats $SINGLEMDS "getattr" 1
9698 $LFS df || error "lfs failed"
9699 check_stats $SINGLEMDS "statfs" 1
9703 run_test 133b "Verifying extra MDT stats =================================="
9706 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9707 remote_ost_nodsh && skip "remote OST with nodsh" && return
9708 remote_mds_nodsh && skip "remote MDS with nodsh" && return
9709 local testdir=$DIR/${tdir}/stats_testdir
9710 test_mkdir -p ${testdir} || error "mkdir failed"
9712 # verify obdfilter stats.
9713 $SETSTRIPE -c 1 -i 0 ${testdir}/${tfile}
9715 cancel_lru_locks osc
9716 wait_delete_completed
9719 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
9720 do_facet ost1 $LCTL set_param obdfilter.*.stats=clear
9722 dd if=/dev/zero of=${testdir}/${tfile} conv=notrunc bs=512k count=1 || error "dd failed"
9724 cancel_lru_locks osc
9725 check_stats ost1 "write" 1
9727 dd if=${testdir}/${tfile} of=/dev/null bs=1k count=1 || error "dd failed"
9728 check_stats ost1 "read" 1
9730 > ${testdir}/${tfile} || error "truncate failed"
9731 check_stats ost1 "punch" 1
9733 rm -f ${testdir}/${tfile} || error "file remove failed"
9734 wait_delete_completed
9735 check_stats ost1 "destroy" 1
9739 run_test 133c "Verifying OST stats ========================================"
9746 while [ $value -ge 2 ]; do
9751 if [ $orig -gt $order ]; then
9759 local size=('K' 'M' 'G' 'T');
9761 local size_string=$value
9763 while [ $value -ge 1024 ]; do
9764 if [ $i -gt 3 ]; then
9765 #T is the biggest unit we get here, if that is bigger,
9767 size_string=${value}T
9770 value=$((value >> 10))
9771 if [ $value -lt 1024 ]; then
9772 size_string=${value}${size[$i]}
9783 local context=${2:-.}
9784 local sample=$(do_facet $SINGLEMDS $LCTL get_param mdt.*.rename_stats |
9786 awk '/ '${size}'/ {print $4}' | sed -e "s/,//g")
9791 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9792 remote_ost_nodsh && skip "remote OST with nodsh" && return
9793 remote_mds_nodsh && skip "remote MDS with nodsh" && return
9794 do_facet $SINGLEMDS $LCTL list_param mdt.*.rename_stats ||
9795 { skip "MDS doesn't support rename stats"; return; }
9797 local testdir1=$DIR/${tdir}/stats_testdir1
9798 local testdir2=$DIR/${tdir}/stats_testdir2
9800 do_facet $SINGLEMDS $LCTL set_param mdt.*.rename_stats=clear
9802 mkdir -p ${testdir1} || error "mkdir failed"
9803 mkdir -p ${testdir2} || error "mkdir failed"
9805 createmany -o $testdir1/test 512 || error "createmany failed"
9807 # check samedir rename size
9808 mv ${testdir1}/test0 ${testdir1}/test_0
9810 local testdir1_size=$(ls -l $DIR/${tdir} |
9811 awk '/stats_testdir1/ {print $5}')
9812 local testdir2_size=$(ls -l $DIR/${tdir} |
9813 awk '/stats_testdir2/ {print $5}')
9815 testdir1_size=$(order_2 $testdir1_size)
9816 testdir2_size=$(order_2 $testdir2_size)
9818 testdir1_size=$(size_in_KMGT $testdir1_size)
9819 testdir2_size=$(size_in_KMGT $testdir2_size)
9821 echo "source rename dir size: ${testdir1_size}"
9822 echo "target rename dir size: ${testdir2_size}"
9824 local cmd="do_facet $SINGLEMDS $LCTL get_param mdt.*.rename_stats"
9825 eval $cmd || error "$cmd failed"
9826 local samedir=$($cmd | grep 'same_dir')
9827 local same_sample=$(get_rename_size $testdir1_size)
9828 [ -z "$samedir" ] && error "samedir_rename_size count error"
9829 [[ $same_sample -eq 1 ]] ||
9830 error "samedir_rename_size error $same_sample"
9831 echo "Check same dir rename stats success"
9833 do_facet $SINGLEMDS $LCTL set_param mdt.*.rename_stats=clear
9835 # check crossdir rename size
9836 mv ${testdir1}/test_0 ${testdir2}/test_0
9838 testdir1_size=$(ls -l $DIR/${tdir} |
9839 awk '/stats_testdir1/ {print $5}')
9840 testdir2_size=$(ls -l $DIR/${tdir} |
9841 awk '/stats_testdir2/ {print $5}')
9843 testdir1_size=$(order_2 $testdir1_size)
9844 testdir2_size=$(order_2 $testdir2_size)
9846 testdir1_size=$(size_in_KMGT $testdir1_size)
9847 testdir2_size=$(size_in_KMGT $testdir2_size)
9849 echo "source rename dir size: ${testdir1_size}"
9850 echo "target rename dir size: ${testdir2_size}"
9852 eval $cmd || error "$cmd failed"
9853 local crossdir=$($cmd | grep 'crossdir')
9854 local src_sample=$(get_rename_size $testdir1_size crossdir_src)
9855 local tgt_sample=$(get_rename_size $testdir2_size crossdir_tgt)
9856 [ -z "$crossdir" ] && error "crossdir_rename_size count error"
9857 [[ $src_sample -eq 1 ]] ||
9858 error "crossdir_rename_size error $src_sample"
9859 [[ $tgt_sample -eq 1 ]] ||
9860 error "crossdir_rename_size error $tgt_sample"
9861 echo "Check cross dir rename stats success"
9864 run_test 133d "Verifying rename_stats ========================================"
9867 remote_mds_nodsh && skip "remote MDS with nodsh" && return
9868 remote_ost_nodsh && skip "remote OST with nodsh" && return
9869 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9870 local testdir=$DIR/${tdir}/stats_testdir
9871 local ctr f0 f1 bs=32768 count=42 sum
9873 mkdir -p ${testdir} || error "mkdir failed"
9875 $SETSTRIPE -c 1 -i 0 ${testdir}/${tfile}
9877 for ctr in {write,read}_bytes; do
9879 cancel_lru_locks osc
9881 do_facet ost1 $LCTL set_param -n \
9882 "obdfilter.*.exports.clear=clear"
9884 if [ $ctr = write_bytes ]; then
9886 f1=${testdir}/${tfile}
9888 f0=${testdir}/${tfile}
9892 dd if=$f0 of=$f1 conv=notrunc bs=$bs count=$count || \
9895 cancel_lru_locks osc
9897 sum=$(do_facet ost1 $LCTL get_param \
9898 "obdfilter.*.exports.*.stats" |
9899 awk -v ctr=$ctr 'BEGIN { sum = 0 }
9900 $1 == ctr { sum += $7 }
9901 END { printf("%0.0f", sum) }')
9903 if ((sum != bs * count)); then
9904 error "Bad $ctr sum, expected $((bs * count)), got $sum"
9910 run_test 133e "Verifying OST {read,write}_bytes nid stats ================="
9912 proc_regexp="/{proc,sys}/{fs,sys,kernel/debug}/{lustre,lnet}/"
9915 remote_mds_nodsh && skip "remote MDS with nodsh" && return
9916 remote_ost_nodsh && skip "remote OST with nodsh" && return
9917 # First without trusting modes.
9918 local proc_dirs=$(eval \ls -d $proc_regexp 2>/dev/null)
9919 echo "proc_dirs='$proc_dirs'"
9920 [ -n "$proc_dirs" ] || error "no proc_dirs on $HOSTNAME"
9921 find $proc_dirs -exec cat '{}' \; &> /dev/null
9923 # Second verifying readability.
9924 $LCTL get_param -R '*' &> /dev/null || error "proc file read failed"
9926 # eventually, this can also be replaced with "lctl get_param -R",
9927 # but not until that option is always available on the server
9929 for facet in mds1 ost1; do
9930 local facet_proc_dirs=$(do_facet $facet \
9931 \\\ls -d $proc_regexp 2>/dev/null)
9932 echo "${facet}_proc_dirs='$facet_proc_dirs'"
9933 [ -z "$facet_proc_dirs" ] && error "no proc_dirs on $facet"
9934 do_facet $facet find $facet_proc_dirs \
9935 ! -name req_history \
9936 -exec cat '{}' \\\; &> /dev/null
9938 do_facet $facet find $facet_proc_dirs \
9939 ! -name req_history \
9941 -exec cat '{}' \\\; &> /dev/null ||
9942 error "proc file read failed"
9945 run_test 133f "Check for LBUGs/Oopses/unreadable files in /proc"
9948 remote_mds_nodsh && skip "remote MDS with nodsh" && return
9949 remote_ost_nodsh && skip "remote OST with nodsh" && return
9950 # Second verifying writability.
9951 local proc_dirs=$(eval \ls -d $proc_regexp 2>/dev/null)
9952 echo "proc_dirs='$proc_dirs'"
9953 [ -n "$proc_dirs" ] || error "no proc_dirs on $HOSTNAME"
9956 -not -name force_lbug \
9957 -not -name changelog_mask \
9958 -exec badarea_io '{}' \; &> /dev/null ||
9959 error "find $proc_dirs failed"
9962 for facet in mds1 ost1; do
9963 [ $(lustre_version_code $facet) -le $(version_code 2.5.54) ] &&
9964 skip "Too old lustre on $facet" && continue
9965 local facet_proc_dirs=$(do_facet $facet \
9966 \\\ls -d $proc_regexp 2> /dev/null)
9967 echo "${facet}_proc_dirs='$facet_proc_dirs'"
9968 [ -z "$facet_proc_dirs" ] && error "no proc_dirs on $facet"
9969 do_facet $facet find $facet_proc_dirs \
9971 -not -name force_lbug \
9972 -not -name changelog_mask \
9973 -exec badarea_io '{}' \\\; &> /dev/null ||
9974 error "$facet find $facet_proc_dirs failed"
9977 # remount the FS in case writes/reads /proc break the FS
9978 cleanup || error "failed to unmount"
9979 setup || error "failed to setup"
9982 run_test 133g "Check for Oopses on bad io area writes/reads in /proc"
9985 remote_mds_nodsh && skip "remote MDS with nodsh" && return
9986 remote_ost_nodsh && skip "remote OST with nodsh" && return
9987 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.9.54) ]] &&
9988 skip "Need MDS version at least 2.9.54" && return
9991 for facet in client mds1 ost1; do
9992 local facet_proc_dirs=$(do_facet $facet \
9993 \\\ls -d $proc_regexp 2> /dev/null)
9994 [ -z "$facet_proc_dirs" ] && error "no proc_dirs on $facet"
9995 echo "${facet}_proc_dirs='$facet_proc_dirs'"
9996 # Get the list of files that are missing the terminating newline
9997 local missing=($(do_facet $facet \
9998 find ${facet_proc_dirs} -type f \| \
10000 awk -v FS='\v' -v RS='\v\v' \
10001 "'END { if(NR>0 && \
10002 \\\$NF !~ /.*\\\n\$/) \
10003 print FILENAME}'" \
10006 [ ${#missing[*]} -eq 0 ] ||
10007 error "files do not end with newline: ${missing[*]}"
10010 run_test 133h "Proc files should end with newlines"
10013 remote_mds_nodsh && skip "remote MDS with nodsh" && return
10014 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.54) ]] &&
10015 skip "Need MDS version at least 2.7.54" && return
10017 mkdir -p $DIR/$tdir || error "failed to create $DIR/$tdir"
10018 cancel_lru_locks mdc
10020 local nsdir="ldlm.namespaces.*-MDT0000-mdc-*"
10021 local unused=$($LCTL get_param -n $nsdir.lock_unused_count)
10022 [ $unused -eq 0 ] || error "$unused locks are not cleared"
10025 createmany -o $DIR/$tdir/f $nr ||
10026 error "failed to create $nr files in $DIR/$tdir"
10027 unused=$($LCTL get_param -n $nsdir.lock_unused_count)
10029 #define OBD_FAIL_LDLM_WATERMARK_LOW 0x327
10030 do_facet mds1 $LCTL set_param fail_loc=0x327
10031 do_facet mds1 $LCTL set_param fail_val=500
10034 echo "sleep 10 seconds ..."
10036 local lck_cnt=$($LCTL get_param -n $nsdir.lock_unused_count)
10038 do_facet mds1 $LCTL set_param fail_loc=0
10039 do_facet mds1 $LCTL set_param fail_val=0
10040 [ $lck_cnt -lt $unused ] ||
10041 error "No locks reclaimed, before:$unused, after:$lck_cnt"
10044 unlinkmany $DIR/$tdir/f $nr
10046 run_test 134a "Server reclaims locks when reaching lock_reclaim_threshold"
10049 remote_mds_nodsh && skip "remote MDS with nodsh" && return
10050 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.54) ]] &&
10051 skip "Need MDS version at least 2.7.54" && return
10053 mkdir -p $DIR/$tdir || error "failed to create $DIR/$tdir"
10054 cancel_lru_locks mdc
10056 local low_wm=$(do_facet mds1 $LCTL get_param -n \
10057 ldlm.lock_reclaim_threshold_mb)
10058 # disable reclaim temporarily
10059 do_facet mds1 $LCTL set_param ldlm.lock_reclaim_threshold_mb=0
10061 #define OBD_FAIL_LDLM_WATERMARK_HIGH 0x328
10062 do_facet mds1 $LCTL set_param fail_loc=0x328
10063 do_facet mds1 $LCTL set_param fail_val=500
10065 $LCTL set_param debug=+trace
10068 createmany -o $DIR/$tdir/f $nr &
10069 local create_pid=$!
10071 echo "Sleep $TIMEOUT seconds ..."
10073 if ! ps -p $create_pid > /dev/null 2>&1; then
10074 do_facet mds1 $LCTL set_param fail_loc=0
10075 do_facet mds1 $LCTL set_param fail_val=0
10076 do_facet mds1 $LCTL set_param \
10077 ldlm.lock_reclaim_threshold_mb=${low_wm}m
10078 error "createmany finished incorrectly!"
10080 do_facet mds1 $LCTL set_param fail_loc=0
10081 do_facet mds1 $LCTL set_param fail_val=0
10082 do_facet mds1 $LCTL set_param ldlm.lock_reclaim_threshold_mb=${low_wm}m
10083 wait $create_pid || return 1
10085 unlinkmany $DIR/$tdir/f $nr
10087 run_test 134b "Server rejects lock request when reaching lock_limit_mb"
10089 test_140() { #bug-17379
10090 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10091 test_mkdir -p $DIR/$tdir || error "Creating dir $DIR/$tdir"
10092 cd $DIR/$tdir || error "Changing to $DIR/$tdir"
10093 cp $(which stat) . || error "Copying stat to $DIR/$tdir"
10095 # VFS limits max symlink depth to 5(4KSTACK) or 7(8KSTACK) or 8
10096 # For kernel > 3.5, bellow only tests consecutive symlink (MAX 40)
10098 while i=`expr $i + 1`; do
10099 test_mkdir -p $i || error "Creating dir $i"
10100 cd $i || error "Changing to $i"
10101 ln -s ../stat stat || error "Creating stat symlink"
10102 # Read the symlink until ELOOP present,
10103 # not LBUGing the system is considered success,
10104 # we didn't overrun the stack.
10105 $OPENFILE -f O_RDONLY stat >/dev/null 2>&1; ret=$?
10106 [ $ret -ne 0 ] && {
10107 if [ $ret -eq 40 ]; then
10110 error "Open stat symlink"
10116 echo "The symlink depth = $i"
10117 [ $i -eq 5 -o $i -eq 7 -o $i -eq 8 -o $i -eq 40 ] ||
10118 error "Invalid symlink depth"
10120 # Test recursive symlink
10121 ln -s symlink_self symlink_self
10122 $OPENFILE -f O_RDONLY symlink_self >/dev/null 2>&1; ret=$?
10123 echo "open symlink_self returns $ret"
10124 [ $ret -eq 40 ] || error "recursive symlink doesn't return -ELOOP"
10126 run_test 140 "Check reasonable stack depth (shouldn't LBUG) ===="
10129 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10130 local TF="$TMP/$tfile"
10132 dd if=/dev/urandom of=$TF bs=6096 count=1 || error "dd failed"
10134 cancel_lru_locks osc
10135 cmp $TF $DIR/$tfile || error "$TMP/$tfile $DIR/$tfile differ"
10136 remount_client $MOUNT
10138 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (remount)"
10141 $TRUNCATE $DIR/$tfile 6000
10142 cancel_lru_locks osc
10143 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (truncate1)"
10146 echo "12345" >>$DIR/$tfile
10147 cancel_lru_locks osc
10148 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (append1)"
10151 echo "12345" >>$DIR/$tfile
10152 cancel_lru_locks osc
10153 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (append2)"
10158 run_test 150 "truncate/append tests"
10160 #LU-2902 roc_hit was not able to read all values from lproc
10161 function roc_hit_init() {
10162 local list=$(comma_list $(osts_nodes))
10163 local dir=$DIR/$tdir-check
10164 local file=$dir/file
10170 #use setstripe to do a write to every ost
10171 for i in $(seq 0 $((OSTCOUNT-1))); do
10172 $SETSTRIPE -c 1 -i $i $dir || error "$SETSTRIPE $file failed"
10173 dd if=/dev/urandom of=$file bs=4k count=4 2>&1 > /dev/null
10174 idx=$(printf %04x $i)
10175 BEFORE=$(get_osd_param $list *OST*$idx stats |
10176 awk '$1 == "cache_access" {sum += $7}
10177 END { printf("%0.0f", sum) }')
10179 cancel_lru_locks osc
10180 cat $file >/dev/null
10182 AFTER=$(get_osd_param $list *OST*$idx stats |
10183 awk '$1 == "cache_access" {sum += $7}
10184 END { printf("%0.0f", sum) }')
10186 echo BEFORE:$BEFORE AFTER:$AFTER
10187 if ! let "AFTER - BEFORE == 4"; then
10189 error "roc_hit is not safe to use"
10197 function roc_hit() {
10198 local list=$(comma_list $(osts_nodes))
10199 echo $(get_osd_param $list '' stats |
10200 awk '$1 == "cache_hit" {sum += $7}
10201 END { printf("%0.0f", sum) }')
10204 function set_cache() {
10207 if [ "$2" == "off" ]; then
10210 local list=$(comma_list $(osts_nodes))
10211 set_osd_param $list '' $1_cache_enable $on
10213 cancel_lru_locks osc
10217 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10218 remote_ost_nodsh && skip "remote OST with nodsh" && return
10221 local list=$(comma_list $(osts_nodes))
10223 # check whether obdfilter is cache capable at all
10224 if ! get_osd_param $list '' read_cache_enable >/dev/null; then
10225 echo "not cache-capable obdfilter"
10229 # check cache is enabled on all obdfilters
10230 if get_osd_param $list '' read_cache_enable | grep 0; then
10231 echo "oss cache is disabled"
10235 set_osd_param $list '' writethrough_cache_enable 1
10237 # check write cache is enabled on all obdfilters
10238 if get_osd_param $list '' writethrough_cache_enable | grep 0; then
10239 echo "oss write cache is NOT enabled"
10245 #define OBD_FAIL_OBD_NO_LRU 0x609
10246 do_nodes $list $LCTL set_param fail_loc=0x609
10248 # pages should be in the case right after write
10249 dd if=/dev/urandom of=$DIR/$tfile bs=4k count=$CPAGES ||
10252 local BEFORE=$(roc_hit)
10253 cancel_lru_locks osc
10254 cat $DIR/$tfile >/dev/null
10255 local AFTER=$(roc_hit)
10257 do_nodes $list $LCTL set_param fail_loc=0
10259 if ! let "AFTER - BEFORE == CPAGES"; then
10260 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
10263 # the following read invalidates the cache
10264 cancel_lru_locks osc
10265 set_osd_param $list '' read_cache_enable 0
10266 cat $DIR/$tfile >/dev/null
10268 # now data shouldn't be found in the cache
10270 cancel_lru_locks osc
10271 cat $DIR/$tfile >/dev/null
10273 if let "AFTER - BEFORE != 0"; then
10274 error "IN CACHE: before: $BEFORE, after: $AFTER"
10277 set_osd_param $list '' read_cache_enable 1
10280 run_test 151 "test cache on oss and controls ==============================="
10283 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10284 local TF="$TMP/$tfile"
10286 # simulate ENOMEM during write
10287 #define OBD_FAIL_OST_NOMEM 0x226
10288 lctl set_param fail_loc=0x80000226
10289 dd if=/dev/urandom of=$TF bs=6096 count=1 || error "dd failed"
10291 sync || error "sync failed"
10292 lctl set_param fail_loc=0
10294 # discard client's cache
10295 cancel_lru_locks osc
10297 # simulate ENOMEM during read
10298 lctl set_param fail_loc=0x80000226
10299 cmp $TF $DIR/$tfile || error "cmp failed"
10300 lctl set_param fail_loc=0
10304 run_test 152 "test read/write with enomem ============================"
10307 $MULTIOP $DIR/$tfile Ow4096Ycu || error "multiop failed"
10309 run_test 153 "test if fdatasync does not crash ======================="
10311 dot_lustre_fid_permission_check() {
10313 local ffid=$MOUNT/.lustre/fid/$fid
10316 echo "stat fid $fid"
10317 stat $ffid > /dev/null || error "stat $ffid failed."
10318 echo "touch fid $fid"
10319 touch $ffid || error "touch $ffid failed."
10320 echo "write to fid $fid"
10321 cat /etc/hosts > $ffid || error "write $ffid failed."
10322 echo "read fid $fid"
10323 diff /etc/hosts $ffid || error "read $ffid failed."
10324 echo "append write to fid $fid"
10325 cat /etc/hosts >> $ffid || error "append write $ffid failed."
10326 echo "rename fid $fid"
10327 mv $ffid $test_dir/$tfile.1 &&
10328 error "rename $ffid to $tfile.1 should fail."
10329 touch $test_dir/$tfile.1
10330 mv $test_dir/$tfile.1 $ffid &&
10331 error "rename $tfile.1 to $ffid should fail."
10332 rm -f $test_dir/$tfile.1
10333 echo "truncate fid $fid"
10334 $TRUNCATE $ffid 777 || error "truncate $ffid failed."
10335 if [ $MDSCOUNT -lt 2 ]; then #FIXME when cross-MDT hard link is working
10336 echo "link fid $fid"
10337 ln -f $ffid $test_dir/tfile.lnk || error "link $ffid failed."
10339 if [ -n $(lctl get_param -n mdc.*-mdc-*.connect_flags | grep acl) ]; then
10340 echo "setfacl fid $fid"
10341 setfacl -R -m u:bin:rwx $ffid || error "setfacl $ffid failed."
10342 echo "getfacl fid $fid"
10343 getfacl $ffid >/dev/null || error "getfacl $ffid failed."
10345 echo "unlink fid $fid"
10346 unlink $MOUNT/.lustre/fid/$fid && error "unlink $ffid should fail."
10347 echo "mknod fid $fid"
10348 mknod $ffid c 1 3 && error "mknod $ffid should fail."
10350 fid=[0xf00000400:0x1:0x0]
10351 ffid=$MOUNT/.lustre/fid/$fid
10353 echo "stat non-exist fid $fid"
10354 stat $ffid > /dev/null && error "stat non-exist $ffid should fail."
10355 echo "write to non-exist fid $fid"
10356 cat /etc/hosts > $ffid && error "write non-exist $ffid should fail."
10357 echo "link new fid $fid"
10358 ln $test_dir/$tfile $ffid && error "link $ffid should fail."
10360 mkdir -p $test_dir/$tdir
10361 touch $test_dir/$tdir/$tfile
10362 fid=$($LFS path2fid $test_dir/$tdir)
10365 error "error: could not get fid for $test_dir/$dir/$tfile."
10367 ffid=$MOUNT/.lustre/fid/$fid
10370 ls $ffid > /dev/null || error "ls $ffid failed."
10371 echo "touch $fid/$tfile.1"
10372 touch $ffid/$tfile.1 || error "touch $ffid/$tfile.1 failed."
10374 echo "touch $MOUNT/.lustre/fid/$tfile"
10375 touch $MOUNT/.lustre/fid/$tfile && \
10376 error "touch $MOUNT/.lustre/fid/$tfile should fail."
10378 echo "setxattr to $MOUNT/.lustre/fid"
10379 setfattr -n trusted.name1 -v value1 $MOUNT/.lustre/fid
10381 echo "listxattr for $MOUNT/.lustre/fid"
10382 getfattr -d -m "^trusted" $MOUNT/.lustre/fid
10384 echo "delxattr from $MOUNT/.lustre/fid"
10385 setfattr -x trusted.name1 $MOUNT/.lustre/fid
10387 echo "touch invalid fid: $MOUNT/.lustre/fid/[0x200000400:0x2:0x3]"
10388 touch $MOUNT/.lustre/fid/[0x200000400:0x2:0x3] &&
10389 error "touch invalid fid should fail."
10391 echo "touch non-normal fid: $MOUNT/.lustre/fid/[0x1:0x2:0x0]"
10392 touch $MOUNT/.lustre/fid/[0x1:0x2:0x0] &&
10393 error "touch non-normal fid should fail."
10395 echo "rename $tdir to $MOUNT/.lustre/fid"
10396 mrename $test_dir/$tdir $MOUNT/.lustre/fid &&
10397 error "rename to $MOUNT/.lustre/fid should fail."
10399 if [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.3.51) ]
10401 local old_obf_mode=$(stat --format="%a" $DIR/.lustre/fid)
10402 local new_obf_mode=777
10404 echo "change mode of $DIR/.lustre/fid to $new_obf_mode"
10405 chmod $new_obf_mode $DIR/.lustre/fid ||
10406 error "chmod $new_obf_mode $DIR/.lustre/fid failed"
10408 local obf_mode=$(stat --format=%a $DIR/.lustre/fid)
10409 [ $obf_mode -eq $new_obf_mode ] ||
10410 error "stat $DIR/.lustre/fid returned wrong mode $obf_mode"
10412 echo "restore mode of $DIR/.lustre/fid to $old_obf_mode"
10413 chmod $old_obf_mode $DIR/.lustre/fid ||
10414 error "chmod $old_obf_mode $DIR/.lustre/fid failed"
10417 $OPENFILE -f O_LOV_DELAY_CREATE:O_CREAT $test_dir/$tfile-2
10418 fid=$($LFS path2fid $test_dir/$tfile-2)
10420 if [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.6.50) ]
10422 echo "cp /etc/passwd $MOUNT/.lustre/fid/$fid"
10423 cp /etc/passwd $MOUNT/.lustre/fid/$fid ||
10424 error "create lov data thru .lustre failed"
10426 echo "cp /etc/passwd $test_dir/$tfile-2"
10427 cp /etc/passwd $test_dir/$tfile-2 ||
10428 error "copy to $test_dir/$tfile-2 failed."
10429 echo "diff /etc/passwd $MOUNT/.lustre/fid/$fid"
10430 diff /etc/passwd $MOUNT/.lustre/fid/$fid ||
10431 error "diff /etc/passwd $MOUNT/.lustre/fid/$fid failed."
10433 rm -rf $test_dir/tfile.lnk
10434 rm -rf $test_dir/$tfile-2
10438 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.1) ]] &&
10439 skip "Need MDS version at least 2.4.1" && return
10441 local tf=$DIR/$tfile
10444 local fid=$($LFS path2fid $tf)
10445 [ -z "$fid" ] && error "path2fid unable to get $tf FID"
10447 # check that we get the same pathname back
10448 local found=$($LFS fid2path $MOUNT "$fid")
10449 [ -z "$found" ] && error "fid2path unable to get '$fid' path"
10450 [ "$found" == "$tf" ] ||
10451 error "fid2path($fid=path2fid($tf)) = $found != $tf"
10453 run_test 154A "lfs path2fid and fid2path basic checks"
10456 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.1) ]] &&
10457 skip "Need MDS version at least 2.4.1" && return
10459 mkdir -p $DIR/$tdir || error "mkdir $tdir failed"
10460 touch $DIR/$tdir/$tfile || error "touch $DIR/$tdir/$tfile failed"
10461 local linkea=$($LL_DECODE_LINKEA $DIR/$tdir/$tfile | grep 'pfid')
10462 [ -z "$linkea" ] && error "decode linkea $DIR/$tdir/$tfile failed"
10464 local name=$(echo $linkea | awk '/pfid/ {print $5}' | sed -e "s/'//g")
10465 local PFID=$(echo $linkea | awk '/pfid/ {print $3}' | sed -e "s/,//g")
10467 # check that we get the same pathname
10468 echo "PFID: $PFID, name: $name"
10469 local FOUND=$($LFS fid2path $MOUNT "$PFID")
10470 [ -z "$FOUND" ] && error "fid2path unable to get $PFID path"
10471 [ "$FOUND/$name" != "$DIR/$tdir/$tfile" ] &&
10472 error "ll_decode_linkea has $FOUND/$name != $DIR/$tdir/$tfile"
10474 rm -rf $DIR/$tdir || error "Can not delete directory $DIR/$tdir"
10476 run_test 154B "verify the ll_decode_linkea tool"
10479 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10480 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.51) ]] ||
10481 { skip "Need MDS version at least 2.2.51"; return 0; }
10482 [ -z "$(which setfacl)" ] && skip "must have setfacl tool" && return
10483 [ -n "$FILESET" ] && skip "SKIP due to FILESET set" && return
10485 cp /etc/hosts $DIR/$tfile
10487 fid=$($LFS path2fid $DIR/$tfile)
10489 [ $rc -ne 0 ] && error "error: could not get fid for $DIR/$tfile."
10491 dot_lustre_fid_permission_check "$fid" $DIR ||
10492 error "dot lustre permission check $fid failed"
10494 rm -rf $MOUNT/.lustre && error ".lustre is not allowed to be unlinked"
10496 touch $MOUNT/.lustre/file &&
10497 error "creation is not allowed under .lustre"
10499 mkdir $MOUNT/.lustre/dir &&
10500 error "mkdir is not allowed under .lustre"
10504 run_test 154a "Open-by-FID"
10507 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10508 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.51) ]] ||
10509 { skip "Need MDS version at least 2.2.51"; return 0; }
10510 [ -n "$FILESET" ] && skip "SKIP due to FILESET set" && return
10512 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
10514 local remote_dir=$DIR/$tdir/remote_dir
10518 mkdir -p $DIR/$tdir
10519 $LFS mkdir -i $MDTIDX $remote_dir ||
10520 error "create remote directory failed"
10522 cp /etc/hosts $remote_dir/$tfile
10524 fid=$($LFS path2fid $remote_dir/$tfile)
10526 [ $rc -ne 0 ] && error "error: could not get fid for $remote_dir/$tfile"
10528 dot_lustre_fid_permission_check "$fid" $remote_dir ||
10529 error "dot lustre permission check $fid failed"
10532 run_test 154b "Open-by-FID for remote directory"
10535 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.1) ]] &&
10536 skip "Need MDS version at least 2.4.1" && return
10538 touch $DIR/$tfile.1 $DIR/$tfile.2 $DIR/$tfile.3
10539 local FID1=$($LFS path2fid $DIR/$tfile.1)
10540 local FID2=$($LFS path2fid $DIR/$tfile.2)
10541 local FID3=$($LFS path2fid $DIR/$tfile.3)
10544 $LFS path2fid $DIR/$tfile.[123] | while read PATHNAME FID; do
10545 [ "$PATHNAME" = "$DIR/$tfile.$N:" ] ||
10546 error "path2fid pathname $PATHNAME != $DIR/$tfile.$N:"
10548 [ "$FID" = "${!want}" ] ||
10549 error "path2fid $PATHNAME FID $FID != FID$N ${!want}"
10553 $LFS fid2path $MOUNT "$FID1" "$FID2" "$FID3" | while read PATHNAME;
10555 [ "$PATHNAME" = "$DIR/$tfile.$N" ] ||
10556 error "fid2path pathname $PATHNAME != $DIR/$tfile.$N:"
10560 run_test 154c "lfs path2fid and fid2path multiple arguments"
10563 remote_mds_nodsh && skip "remote MDS with nodsh" && return
10564 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.5.53) ]] &&
10565 skip "Need MDS version at least 2.5.53" && return
10567 if remote_mds; then
10568 nid=$($LCTL list_nids | sed "s/\./\\\./g")
10572 local proc_ofile="mdt.*.exports.'$nid'.open_files"
10579 local fid=$($LFS path2fid $DIR/$tfile)
10582 cmd="exec $fd<$DIR/$tfile"
10584 local fid_list=$(do_facet $SINGLEMDS $LCTL get_param $proc_ofile)
10585 echo "$fid_list" | grep "$fid"
10588 cmd="exec $fd>/dev/null"
10590 if [ $rc -ne 0 ]; then
10591 error "FID $fid not found in open files list $fid_list"
10594 run_test 154d "Verify open file fid"
10598 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.6.50) ]] &&
10599 skip "Need MDS version at least 2.6.50" && return
10601 if ls -a $MOUNT | grep -q '^\.lustre$'; then
10602 error ".lustre returned by readdir"
10605 run_test 154e ".lustre is not returned by readdir"
10608 [ -n "$FILESET" ] && skip "SKIP due to FILESET set" && return
10609 # create parent directory on a single MDT to avoid cross-MDT hardlinks
10610 test_mkdir -p -c1 $DIR/$tdir/d
10611 # test dirs inherit from its stripe
10612 mkdir -p $DIR/$tdir/d/foo1 || error "mkdir error"
10613 mkdir -p $DIR/$tdir/d/foo2 || error "mkdir error"
10614 cp /etc/hosts $DIR/$tdir/d/foo1/$tfile
10615 ln $DIR/$tdir/d/foo1/$tfile $DIR/$tdir/d/foo2/link
10618 # get fid of parents
10619 local FID0=$($LFS path2fid $DIR/$tdir/d)
10620 local FID1=$($LFS path2fid $DIR/$tdir/d/foo1)
10621 local FID2=$($LFS path2fid $DIR/$tdir/d/foo2)
10622 local FID3=$($LFS path2fid $DIR)
10624 # check that path2fid --parents returns expected <parent_fid>/name
10625 # 1) test for a directory (single parent)
10626 local parent=$($LFS path2fid --parents $DIR/$tdir/d/foo1)
10627 [ "$parent" == "$FID0/foo1" ] ||
10628 error "expected parent: $FID0/foo1, got: $parent"
10630 # 2) test for a file with nlink > 1 (multiple parents)
10631 parent=$($LFS path2fid --parents $DIR/$tdir/d/foo1/$tfile)
10632 echo "$parent" | grep -F "$FID1/$tfile" ||
10633 error "$FID1/$tfile not returned in parent list"
10634 echo "$parent" | grep -F "$FID2/link" ||
10635 error "$FID2/link not returned in parent list"
10637 # 3) get parent by fid
10638 local file_fid=$($LFS path2fid $DIR/$tdir/d/foo1/$tfile)
10639 parent=$($LFS path2fid --parents $MOUNT/.lustre/fid/$file_fid)
10640 echo "$parent" | grep -F "$FID1/$tfile" ||
10641 error "$FID1/$tfile not returned in parent list (by fid)"
10642 echo "$parent" | grep -F "$FID2/link" ||
10643 error "$FID2/link not returned in parent list (by fid)"
10645 # 4) test for entry in root directory
10646 parent=$($LFS path2fid --parents $DIR/f)
10647 echo "$parent" | grep -F "$FID3/f" ||
10648 error "$FID3/f not returned in parent list"
10650 # 5) test it on root directory
10651 [ -z "$($LFS path2fid --parents $MOUNT 2>/dev/null)" ] ||
10652 error "$MOUNT should not have parents"
10654 # enable xattr caching and check that linkea is correctly updated
10655 local save="$TMP/$TESTSUITE-$TESTNAME.parameters"
10656 save_lustre_params client "llite.*.xattr_cache" > $save
10657 lctl set_param llite.*.xattr_cache 1
10659 # 6.1) linkea update on rename
10660 mv $DIR/$tdir/d/foo1/$tfile $DIR/$tdir/d/foo2/$tfile.moved
10662 # get parents by fid
10663 parent=$($LFS path2fid --parents $MOUNT/.lustre/fid/$file_fid)
10664 # foo1 should no longer be returned in parent list
10665 echo "$parent" | grep -F "$FID1" &&
10666 error "$FID1 should no longer be in parent list"
10667 # the new path should appear
10668 echo "$parent" | grep -F "$FID2/$tfile.moved" ||
10669 error "$FID2/$tfile.moved is not in parent list"
10671 # 6.2) linkea update on unlink
10672 rm -f $DIR/$tdir/d/foo2/link
10673 parent=$($LFS path2fid --parents $MOUNT/.lustre/fid/$file_fid)
10674 # foo2/link should no longer be returned in parent list
10675 echo "$parent" | grep -F "$FID2/link" &&
10676 error "$FID2/link should no longer be in parent list"
10680 restore_lustre_params < $save
10683 run_test 154f "get parent fids by reading link ea"
10687 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.6.92) ]] ||
10688 { skip "Need MDS version at least 2.6.92"; return 0; }
10689 [ -n "$FILESET" ] && skip "SKIP due to FILESET set" && return
10691 mkdir -p $DIR/$tdir
10692 llapi_fid_test -d $DIR/$tdir
10694 run_test 154g "various llapi FID tests"
10696 test_155_small_load() {
10697 local temp=$TMP/$tfile
10698 local file=$DIR/$tfile
10700 dd if=/dev/urandom of=$temp bs=6096 count=1 || \
10701 error "dd of=$temp bs=6096 count=1 failed"
10703 cancel_lru_locks osc
10704 cmp $temp $file || error "$temp $file differ"
10706 $TRUNCATE $temp 6000
10707 $TRUNCATE $file 6000
10708 cmp $temp $file || error "$temp $file differ (truncate1)"
10710 echo "12345" >>$temp
10711 echo "12345" >>$file
10712 cmp $temp $file || error "$temp $file differ (append1)"
10714 echo "12345" >>$temp
10715 echo "12345" >>$file
10716 cmp $temp $file || error "$temp $file differ (append2)"
10722 test_155_big_load() {
10723 remote_ost_nodsh && skip "remote OST with nodsh" && return
10724 local temp=$TMP/$tfile
10725 local file=$DIR/$tfile
10728 local cache_size=$(do_facet ost$((MAXI+1)) \
10729 "awk '/cache/ {sum+=\\\$4} END {print sum}' /proc/cpuinfo")
10730 local large_file_size=$((cache_size * 2))
10732 echo "OSS cache size: $cache_size KB"
10733 echo "Large file size: $large_file_size KB"
10735 [ $MAXV -le $large_file_size ] && \
10736 skip_env "max available OST size needs > $large_file_size KB" && \
10739 $SETSTRIPE $file -c 1 -i $MAXI || error "$SETSTRIPE $file failed"
10741 dd if=/dev/urandom of=$temp bs=$large_file_size count=1k || \
10742 error "dd of=$temp bs=$large_file_size count=1k failed"
10745 cancel_lru_locks osc
10746 cmp $temp $file || error "$temp $file differ"
10752 save_writethrough() {
10753 local facets=$(get_facets OST)
10755 save_lustre_params $facets "obdfilter.*.writethrough_cache_enable" > $1
10756 save_lustre_params $facets "osd-*.*.writethrough_cache_enable" >> $1
10760 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10761 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
10762 save_writethrough $p
10765 set_cache writethrough on
10766 test_155_small_load
10767 restore_lustre_params < $p
10770 run_test 155a "Verify small file correctness: read cache:on write_cache:on"
10773 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10774 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
10775 save_writethrough $p
10778 set_cache writethrough off
10779 test_155_small_load
10780 restore_lustre_params < $p
10783 run_test 155b "Verify small file correctness: read cache:on write_cache:off"
10786 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10787 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
10788 save_writethrough $p
10791 set_cache writethrough on
10792 test_155_small_load
10793 restore_lustre_params < $p
10796 run_test 155c "Verify small file correctness: read cache:off write_cache:on"
10799 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10800 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
10801 save_writethrough $p
10804 set_cache writethrough off
10805 test_155_small_load
10806 restore_lustre_params < $p
10809 run_test 155d "Verify small file correctness: read cache:off write_cache:off"
10812 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10813 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
10814 save_writethrough $p
10817 set_cache writethrough on
10819 restore_lustre_params < $p
10822 run_test 155e "Verify big file correctness: read cache:on write_cache:on"
10825 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10826 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
10827 save_writethrough $p
10830 set_cache writethrough off
10832 restore_lustre_params < $p
10835 run_test 155f "Verify big file correctness: read cache:on write_cache:off"
10838 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10839 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
10840 save_writethrough $p
10843 set_cache writethrough on
10845 restore_lustre_params < $p
10848 run_test 155g "Verify big file correctness: read cache:off write_cache:on"
10851 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10852 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
10853 save_writethrough $p
10856 set_cache writethrough off
10858 restore_lustre_params < $p
10861 run_test 155h "Verify big file correctness: read cache:off write_cache:off"
10864 remote_ost_nodsh && skip "remote OST with nodsh" && return
10865 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10869 local file="$DIR/$tfile"
10870 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
10872 [ "$(facet_fstype ost1)" = "zfs" -a \
10873 $(lustre_version_code ost1 -lt $(version_code 2.6.93)) ] &&
10874 skip "LU-1956/LU-2261: stats not implemented on OSD ZFS" &&
10877 save_writethrough $p
10880 log "Turn on read and write cache"
10882 set_cache writethrough on
10884 log "Write data and read it back."
10885 log "Read should be satisfied from the cache."
10886 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
10888 cancel_lru_locks osc
10889 cat $file >/dev/null
10891 if ! let "AFTER - BEFORE == CPAGES"; then
10892 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
10894 log "cache hits:: before: $BEFORE, after: $AFTER"
10897 log "Read again; it should be satisfied from the cache."
10899 cancel_lru_locks osc
10900 cat $file >/dev/null
10902 if ! let "AFTER - BEFORE == CPAGES"; then
10903 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
10905 log "cache hits:: before: $BEFORE, after: $AFTER"
10908 log "Turn off the read cache and turn on the write cache"
10910 set_cache writethrough on
10912 log "Read again; it should be satisfied from the cache."
10914 cancel_lru_locks osc
10915 cat $file >/dev/null
10917 if ! let "AFTER - BEFORE == CPAGES"; then
10918 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
10920 log "cache hits:: before: $BEFORE, after: $AFTER"
10923 log "Read again; it should not be satisfied from the cache."
10925 cancel_lru_locks osc
10926 cat $file >/dev/null
10928 if ! let "AFTER - BEFORE == 0"; then
10929 error "IN CACHE: before: $BEFORE, after: $AFTER"
10931 log "cache hits:: before: $BEFORE, after: $AFTER"
10934 log "Write data and read it back."
10935 log "Read should be satisfied from the cache."
10936 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
10938 cancel_lru_locks osc
10939 cat $file >/dev/null
10941 if ! let "AFTER - BEFORE == CPAGES"; then
10942 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
10944 log "cache hits:: before: $BEFORE, after: $AFTER"
10947 log "Read again; it should not be satisfied from the cache."
10949 cancel_lru_locks osc
10950 cat $file >/dev/null
10952 if ! let "AFTER - BEFORE == 0"; then
10953 error "IN CACHE: before: $BEFORE, after: $AFTER"
10955 log "cache hits:: before: $BEFORE, after: $AFTER"
10958 log "Turn off read and write cache"
10960 set_cache writethrough off
10962 log "Write data and read it back"
10963 log "It should not be satisfied from the cache."
10965 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
10966 cancel_lru_locks osc
10968 cat $file >/dev/null
10970 if ! let "AFTER - BEFORE == 0"; then
10971 error_ignore bz20762 "IN CACHE: before: $BEFORE, after: $AFTER"
10973 log "cache hits:: before: $BEFORE, after: $AFTER"
10976 log "Turn on the read cache and turn off the write cache"
10978 set_cache writethrough off
10980 log "Write data and read it back"
10981 log "It should not be satisfied from the cache."
10983 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
10985 cancel_lru_locks osc
10986 cat $file >/dev/null
10988 if ! let "AFTER - BEFORE == 0"; then
10989 error_ignore bz20762 "IN CACHE: before: $BEFORE, after: $AFTER"
10991 log "cache hits:: before: $BEFORE, after: $AFTER"
10994 log "Read again; it should be satisfied from the cache."
10996 cancel_lru_locks osc
10997 cat $file >/dev/null
10999 if ! let "AFTER - BEFORE == CPAGES"; then
11000 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
11002 log "cache hits:: before: $BEFORE, after: $AFTER"
11006 restore_lustre_params < $p
11009 run_test 156 "Verification of tunables"
11012 cleanup_changelog () {
11014 echo "Deregistering changelog client $CL_USER"
11015 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister $CL_USER
11019 if [[ $MDSCOUNT -gt 1 ]]; then
11020 error_ignore bz17935 $*
11028 local CL_MASK_PARAM="mdd.$MDT0.changelog_mask"
11030 MASK=$(do_facet $SINGLEMDS $LCTL get_param $CL_MASK_PARAM| grep -c "$1")
11032 if [ $MASK -eq 1 ]; then
11033 do_facet $SINGLEMDS $LCTL set_param $CL_MASK_PARAM="-$1"
11035 do_facet $SINGLEMDS $LCTL set_param $CL_MASK_PARAM="+$1"
11039 changelog_extract_field() {
11043 local identifier=$4
11045 $LFS changelog $mdt | gawk "/$cltype.*$file$/ {
11046 print gensub(/^.* "$identifier'(\[[^\]]*\]).*$/,"\\1",1)}' |
11051 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11052 remote_mds_nodsh && skip "remote MDS with nodsh" && return
11053 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] ||
11054 { skip "Need MDS version at least 2.2.0"; return; }
11056 local CL_USERS="mdd.$MDT0.changelog_users"
11057 local GET_CL_USERS="do_facet $SINGLEMDS $LCTL get_param -n $CL_USERS"
11058 CL_USER=$(do_facet $SINGLEMDS $LCTL --device $MDT0 \
11059 changelog_register -n)
11060 echo "Registered as changelog user $CL_USER"
11061 trap cleanup_changelog EXIT
11062 $GET_CL_USERS | grep -q $CL_USER ||
11063 error "User $CL_USER not found in changelog_users"
11066 test_mkdir -p $DIR/$tdir/pics/2008/zachy
11067 touch $DIR/$tdir/pics/2008/zachy/timestamp
11068 cp /etc/hosts $DIR/$tdir/pics/2008/zachy/pic1.jpg
11069 mv $DIR/$tdir/pics/2008/zachy $DIR/$tdir/pics/zach
11070 ln $DIR/$tdir/pics/zach/pic1.jpg $DIR/$tdir/pics/2008/portland.jpg
11071 ln -s $DIR/$tdir/pics/2008/portland.jpg $DIR/$tdir/pics/desktop.jpg
11072 rm $DIR/$tdir/pics/desktop.jpg
11074 $LFS changelog $MDT0 | tail -5
11076 echo "verifying changelog mask"
11077 changelog_chmask "MKDIR"
11078 changelog_chmask "CLOSE"
11080 test_mkdir -p $DIR/$tdir/pics/zach/sofia
11081 echo "zzzzzz" > $DIR/$tdir/pics/zach/file
11083 changelog_chmask "MKDIR"
11084 changelog_chmask "CLOSE"
11086 test_mkdir -p $DIR/$tdir/pics/2008/sofia
11087 echo "zzzzzz" > $DIR/$tdir/pics/zach/file
11089 $LFS changelog $MDT0
11090 MKDIRS=$($LFS changelog $MDT0 | tail -5 | grep -c "MKDIR")
11091 CLOSES=$($LFS changelog $MDT0 | tail -5 | grep -c "CLOSE")
11092 [ $MKDIRS -eq 1 ] || err17935 "MKDIR changelog mask count $DIRS != 1"
11093 [ $CLOSES -eq 1 ] || err17935 "CLOSE changelog mask count $DIRS != 1"
11096 echo "verifying target fid"
11097 fidc=$(changelog_extract_field $MDT0 "CREAT" "timestamp" "t=")
11098 fidf=$($LFS path2fid $DIR/$tdir/pics/zach/timestamp)
11099 [ "$fidc" == "$fidf" ] ||
11100 err17935 "fid in changelog $fidc != file fid $fidf"
11101 echo "verifying parent fid"
11102 fidc=$(changelog_extract_field $MDT0 "CREAT" "timestamp" "p=")
11103 fidf=$($LFS path2fid $DIR/$tdir/pics/zach)
11104 [ "$fidc" == "$fidf" ] ||
11105 err17935 "pfid in changelog $fidc != dir fid $fidf"
11107 USER_REC1=$($GET_CL_USERS | awk "\$1 == \"$CL_USER\" {print \$2}")
11108 $LFS changelog_clear $MDT0 $CL_USER $(($USER_REC1 + 5))
11109 USER_REC2=$($GET_CL_USERS | awk "\$1 == \"$CL_USER\" {print \$2}")
11110 echo "verifying user clear: $(( $USER_REC1 + 5 )) == $USER_REC2"
11111 [ $USER_REC2 == $(($USER_REC1 + 5)) ] ||
11112 err17935 "user index expected $(($USER_REC1 + 5)) is $USER_REC2"
11114 MIN_REC=$($GET_CL_USERS |
11115 awk 'min == "" || $2 < min {min = $2}; END {print min}')
11116 FIRST_REC=$($LFS changelog $MDT0 | head -n1 | awk '{print $1}')
11117 echo "verifying min purge: $(( $MIN_REC + 1 )) == $FIRST_REC"
11118 [ $FIRST_REC == $(($MIN_REC + 1)) ] ||
11119 err17935 "first index should be $(($MIN_REC + 1)) is $FIRST_REC"
11121 # LU-3446 changelog index reset on MDT restart
11122 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
11123 CUR_REC1=$($GET_CL_USERS | head -n1 | cut -f3 -d' ')
11124 $LFS changelog_clear $MDT0 $CL_USER 0
11125 stop $SINGLEMDS || error "Fail to stop MDT."
11126 start $SINGLEMDS $MDT_DEV $MDS_MOUNT_OPTS || error "Fail to start MDT."
11127 CUR_REC2=$($GET_CL_USERS | head -n1 | cut -f3 -d' ')
11128 echo "verifying index survives MDT restart: $CUR_REC1 == $CUR_REC2"
11129 [ $CUR_REC1 == $CUR_REC2 ] ||
11130 err17935 "current index should be $CUR_REC1 is $CUR_REC2"
11132 echo "verifying user deregister"
11134 $GET_CL_USERS | grep -q $CL_USER &&
11135 error "User $CL_USER still in changelog_users"
11137 USERS=$(( $($GET_CL_USERS | wc -l) - 2 ))
11138 if [ $CL_USER -eq 0 ]; then
11139 LAST_REC1=$($GET_CL_USERS | head -n1 | cut -f3 -d' ')
11140 touch $DIR/$tdir/chloe
11141 LAST_REC2=$($GET_CL_USERS | head -n1 | cut -f3 -d' ')
11142 echo "verify changelogs are off: $LAST_REC1 == $LAST_REC2"
11143 [ $LAST_REC1 == $LAST_REC2 ] || error "changelogs not off"
11145 echo "$CL_USER other changelog users; can't verify off"
11148 run_test 160a "changelog sanity"
11150 test_160b() { # LU-3587
11151 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11152 remote_mds_nodsh && skip "remote MDS with nodsh" && return
11153 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] ||
11154 { skip "Need MDS version at least 2.2.0"; return; }
11156 local CL_USERS="mdd.$MDT0.changelog_users"
11157 local GET_CL_USERS="do_facet $SINGLEMDS $LCTL get_param -n $CL_USERS"
11158 CL_USER=$(do_facet $SINGLEMDS $LCTL --device $MDT0 \
11159 changelog_register -n)
11160 echo "Registered as changelog user $CL_USER"
11161 trap cleanup_changelog EXIT
11162 $GET_CL_USERS | grep -q $CL_USER ||
11163 error "User $CL_USER not found in changelog_users"
11165 local LONGNAME1=$(str_repeat a 255)
11166 local LONGNAME2=$(str_repeat b 255)
11169 echo "creating very long named file"
11170 touch $LONGNAME1 || error "create of $LONGNAME1 failed"
11171 echo "moving very long named file"
11172 mv $LONGNAME1 $LONGNAME2
11174 $LFS changelog $MDT0 | grep RENME
11178 run_test 160b "Verify that very long rename doesn't crash in changelog"
11181 remote_mds_nodsh && skip "remote MDS with nodsh" && return
11184 local server_version=$(lustre_version_code $SINGLEMDS)
11186 [[ $server_version -gt $(version_code 2.5.57) ]] ||
11187 [[ $server_version -gt $(version_code 2.5.1) &&
11188 $server_version -lt $(version_code 2.5.50) ]] ||
11189 { skip "Need MDS version at least 2.5.58 or 2.5.2+"; return; }
11190 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11192 # Registration step
11193 CL_USER=$(do_facet $SINGLEMDS $LCTL --device $MDT0 \
11194 changelog_register -n)
11195 trap cleanup_changelog EXIT
11198 mkdir -p $DIR/$tdir
11199 $MCREATE $DIR/$tdir/foo_160c
11200 changelog_chmask "TRUNC"
11201 $TRUNCATE $DIR/$tdir/foo_160c 200
11202 changelog_chmask "TRUNC"
11203 $TRUNCATE $DIR/$tdir/foo_160c 199
11204 $LFS changelog $MDT0
11205 TRUNCS=$($LFS changelog $MDT0 | tail -5 | grep -c "TRUNC")
11206 [ $TRUNCS -eq 1 ] || err17935 "TRUNC changelog mask count $TRUNCS != 1"
11207 $LFS changelog_clear $MDT0 $CL_USER 0
11209 # Deregistration step
11212 run_test 160c "verify that changelog log catch the truncate event"
11215 remote_mds_nodsh && skip "remote MDS with nodsh" && return
11216 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
11218 local server_version=$(lustre_version_code mds1)
11219 local CL_MASK_PARAM="mdd.$MDT0.changelog_mask"
11221 [[ $server_version -ge $(version_code 2.7.60) ]] ||
11222 { skip "Need MDS version at least 2.7.60+"; return; }
11223 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11225 # Registration step
11226 CL_USER=$(do_facet mds1 $LCTL --device $MDT0 \
11227 changelog_register -n)
11229 trap cleanup_changelog EXIT
11230 mkdir -p $DIR/$tdir/migrate_dir
11231 $LFS changelog_clear $MDT0 $CL_USER 0
11233 $LFS migrate -m 1 $DIR/$tdir/migrate_dir || error "migrate fails"
11234 $LFS changelog $MDT0
11235 MIGRATES=$($LFS changelog $MDT0 | tail -5 | grep -c "MIGRT")
11236 $LFS changelog_clear $MDT0 $CL_USER 0
11237 [ $MIGRATES -eq 1 ] ||
11238 error "MIGRATE changelog mask count $MIGRATES != 1"
11240 # Deregistration step
11243 run_test 160d "verify that changelog log catch the migrate event"
11246 remote_mds_nodsh && skip "remote MDS with nodsh" && return
11249 CL_USER=$(do_facet $SINGLEMDS $LCTL --device $MDT0 \
11250 changelog_register -n)
11251 echo "Registered as changelog user $CL_USER"
11252 trap cleanup_changelog EXIT
11254 # Delete a future user (expect fail)
11255 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister cl77
11258 if [ $rc -eq 0 ]; then
11259 error "Deleted non-existant user cl77"
11260 elif [ $rc -ne 2 ]; then
11261 error "changelog_deregister failed with $rc, " \
11262 "expected 2 (ENOENT)"
11265 # Clear to a bad index (1 billion should be safe)
11266 $LFS changelog_clear $MDT0 $CL_USER 1000000000
11269 if [ $rc -eq 0 ]; then
11270 error "Successfully cleared to invalid CL index"
11271 elif [ $rc -ne 22 ]; then
11272 error "changelog_clear failed with $rc, expected 22 (EINVAL)"
11275 run_test 160e "changelog negative testing"
11278 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11279 test_mkdir -p -c1 $DIR/$tdir
11280 cp /etc/hosts $DIR/$tdir/$tfile
11281 test_mkdir -c1 $DIR/$tdir/foo1
11282 test_mkdir -c1 $DIR/$tdir/foo2
11283 ln $DIR/$tdir/$tfile $DIR/$tdir/foo1/sofia
11284 ln $DIR/$tdir/$tfile $DIR/$tdir/foo2/zachary
11285 ln $DIR/$tdir/$tfile $DIR/$tdir/foo1/luna
11286 ln $DIR/$tdir/$tfile $DIR/$tdir/foo2/thor
11287 local FID=$($LFS path2fid $DIR/$tdir/$tfile | tr -d '[]')
11288 if [ "$($LFS fid2path $DIR $FID | wc -l)" != "5" ]; then
11289 $LFS fid2path $DIR $FID
11290 err17935 "bad link ea"
11293 rm $DIR/$tdir/foo2/zachary
11295 rm $DIR/$tdir/foo2/thor
11297 rm $DIR/$tdir/$tfile
11299 mv $DIR/$tdir/foo1/sofia $DIR/$tdir/foo2/maggie
11300 if [ "$($LFS fid2path $FSNAME --link 1 $FID)" != "$tdir/foo2/maggie" ]
11302 $LFS fid2path $DIR $FID
11303 err17935 "bad link rename"
11305 rm $DIR/$tdir/foo2/maggie
11308 local longname=filename_avg_len_is_thirty_two_
11309 createmany -l$DIR/$tdir/foo1/luna $DIR/$tdir/foo2/$longname 1000 ||
11310 error "failed to hardlink many files"
11311 links=$($LFS fid2path $DIR $FID | wc -l)
11312 echo -n "${links}/1000 links in link EA"
11313 [[ $links -gt 60 ]] ||
11314 err17935 "expected at least 60 links in link EA"
11315 unlinkmany $DIR/$tdir/foo2/$longname 1000 ||
11316 error "failed to unlink many hardlinks"
11318 run_test 161a "link ea sanity"
11321 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11322 [ $MDSCOUNT -lt 2 ] && skip "skipping remote directory test" && return
11324 local remote_dir=$DIR/$tdir/remote_dir
11326 mkdir -p $DIR/$tdir
11327 $LFS mkdir -i $MDTIDX $remote_dir ||
11328 error "create remote directory failed"
11330 cp /etc/hosts $remote_dir/$tfile
11331 mkdir -p $remote_dir/foo1
11332 mkdir -p $remote_dir/foo2
11333 ln $remote_dir/$tfile $remote_dir/foo1/sofia
11334 ln $remote_dir/$tfile $remote_dir/foo2/zachary
11335 ln $remote_dir/$tfile $remote_dir/foo1/luna
11336 ln $remote_dir/$tfile $remote_dir/foo2/thor
11338 local FID=$($LFS path2fid $remote_dir/$tfile | tr -d '[' |
11340 if [ "$($LFS fid2path $DIR $FID | wc -l)" != "5" ]; then
11341 $LFS fid2path $DIR $FID
11342 err17935 "bad link ea"
11345 rm $remote_dir/foo2/zachary
11347 rm $remote_dir/foo2/thor
11349 rm $remote_dir/$tfile
11351 mv $remote_dir/foo1/sofia $remote_dir/foo2/maggie
11352 local link_path=$($LFS fid2path $FSNAME --link 1 $FID)
11353 if [ "$DIR/$link_path" != "$remote_dir/foo2/maggie" ]; then
11354 $LFS fid2path $DIR $FID
11355 err17935 "bad link rename"
11357 rm $remote_dir/foo2/maggie
11360 local longname=filename_avg_len_is_thirty_two_
11361 createmany -l$remote_dir/foo1/luna $remote_dir/foo2/$longname 1000 ||
11362 error "failed to hardlink many files"
11363 links=$($LFS fid2path $DIR $FID | wc -l)
11364 echo -n "${links}/1000 links in link EA"
11365 [[ ${links} -gt 60 ]] ||
11366 err17935 "expected at least 60 links in link EA"
11367 unlinkmany $remote_dir/foo2/$longname 1000 ||
11368 error "failed to unlink many hardlinks"
11370 run_test 161b "link ea sanity under remote directory"
11373 remote_mds_nodsh && skip "remote MDS with nodsh" && return
11374 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11375 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.1.5) ]] &&
11376 skip "Need MDS version at least 2.1.5" && return
11378 # define CLF_RENAME_LAST 0x0001
11379 # rename overwrite a target having nlink = 1 (changelog flag 0x1)
11380 CL_USER=$(do_facet $SINGLEMDS $LCTL --device $MDT0 \
11381 changelog_register -n)
11383 trap cleanup_changelog EXIT
11385 mkdir -p $DIR/$tdir
11386 touch $DIR/$tdir/foo_161c
11387 touch $DIR/$tdir/bar_161c
11388 mv -f $DIR/$tdir/foo_161c $DIR/$tdir/bar_161c
11389 $LFS changelog $MDT0 | grep RENME
11390 local flags=$($LFS changelog $MDT0 | grep RENME | tail -1 | \
11392 $LFS changelog_clear $MDT0 $CL_USER 0
11393 if [ x$flags != "x0x1" ]; then
11394 error "flag $flags is not 0x1"
11396 echo "rename overwrite a target having nlink = 1," \
11397 "changelog record has flags of $flags"
11399 # rename overwrite a target having nlink > 1 (changelog flag 0x0)
11400 touch $DIR/$tdir/foo_161c
11401 touch $DIR/$tdir/bar_161c
11402 ln $DIR/$tdir/bar_161c $DIR/$tdir/foobar_161c
11403 mv -f $DIR/$tdir/foo_161c $DIR/$tdir/bar_161c
11404 $LFS changelog $MDT0 | grep RENME
11405 flags=$($LFS changelog $MDT0 | grep RENME | tail -1 | cut -f5 -d' ')
11406 $LFS changelog_clear $MDT0 $CL_USER 0
11407 if [ x$flags != "x0x0" ]; then
11408 error "flag $flags is not 0x0"
11410 echo "rename overwrite a target having nlink > 1," \
11411 "changelog record has flags of $flags"
11413 # rename doesn't overwrite a target (changelog flag 0x0)
11414 touch $DIR/$tdir/foo_161c
11415 mv -f $DIR/$tdir/foo_161c $DIR/$tdir/foo2_161c
11416 $LFS changelog $MDT0 | grep RENME
11417 flags=$($LFS changelog $MDT0 | grep RENME | tail -1 | cut -f5 -d' ')
11418 $LFS changelog_clear $MDT0 $CL_USER 0
11419 if [ x$flags != "x0x0" ]; then
11420 error "flag $flags is not 0x0"
11422 echo "rename doesn't overwrite a target," \
11423 "changelog record has flags of $flags"
11425 # define CLF_UNLINK_LAST 0x0001
11426 # unlink a file having nlink = 1 (changelog flag 0x1)
11427 rm -f $DIR/$tdir/foo2_161c
11428 $LFS changelog $MDT0 | grep UNLNK
11429 flags=$($LFS changelog $MDT0 | grep UNLNK | tail -1 | cut -f5 -d' ')
11430 $LFS changelog_clear $MDT0 $CL_USER 0
11431 if [ x$flags != "x0x1" ]; then
11432 error "flag $flags is not 0x1"
11434 echo "unlink a file having nlink = 1," \
11435 "changelog record has flags of $flags"
11437 # unlink a file having nlink > 1 (changelog flag 0x0)
11438 ln -f $DIR/$tdir/bar_161c $DIR/$tdir/foobar_161c
11439 rm -f $DIR/$tdir/foobar_161c
11440 $LFS changelog $MDT0 | grep UNLNK
11441 flags=$($LFS changelog $MDT0 | grep UNLNK | tail -1 | cut -f5 -d' ')
11442 $LFS changelog_clear $MDT0 $CL_USER 0
11443 if [ x$flags != "x0x0" ]; then
11444 error "flag $flags is not 0x0"
11446 echo "unlink a file having nlink > 1," \
11447 "changelog record has flags of $flags"
11450 run_test 161c "check CL_RENME[UNLINK] changelog record flags"
11457 # cleanup previous run
11458 rm -rf $DIR/$tdir/$tfile
11460 user=$(do_facet $SINGLEMDS $LCTL --device $MDT0 \
11461 changelog_register -n)
11462 [[ $? -eq 0 ]] || error "changelog_register failed"
11464 # work in a standalone dir to avoid locking on $DIR/$MOUNT to
11465 # interfer with $MOUNT/.lustre/fid/ access
11467 [[ $? -eq 0 ]] || error "mkdir failed"
11469 #define OBD_FAIL_LLITE_CREATE_NODE_PAUSE 0x140c | OBD_FAIL_ONCE
11470 $LCTL set_param fail_loc=0x8000140c
11472 $LCTL set_param fail_val=5
11475 echo foofoo > $DIR/$tdir/$tfile &
11478 # wait for create to be delayed
11482 [[ $? -eq 0 ]] || error "create should be blocked"
11484 local tempfile=$(mktemp)
11485 fid=$(changelog_extract_field $MDT0 "CREAT" "$tfile" "t=")
11486 cat $MOUNT/.lustre/fid/$fid 2>/dev/null >$tempfile || error "cat failed"
11487 # some delay may occur during ChangeLog publishing and file read just
11488 # above, that could allow file write to happen finally
11489 [[ -s $tempfile ]] && echo "file should be empty"
11491 $LCTL set_param fail_loc=0
11494 [[ $? -eq 0 ]] || error "create failed"
11496 $LFS changelog_clear $MDT0 $user 0
11497 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister $user
11499 run_test 161d "create with concurrent .lustre/fid access"
11506 local path=$(${LFS} fid2path $*)
11507 # Remove the '//' indicating a remote directory
11508 path=$(echo $path | sed 's#//#/#g')
11511 if [ $RC -ne 0 ]; then
11512 err17935 "path looked up of $expected failed. Error $RC"
11514 elif [ "${path}" != "${expected}" ]; then
11515 err17935 "path looked up \"${path}\" instead of \"${expected}\""
11518 echo "fid $fid resolves to path $path (expected $expected)"
11521 test_162a() { # was test_162
11522 # Make changes to filesystem
11523 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11524 test_mkdir -p -c1 $DIR/$tdir/d2
11525 touch $DIR/$tdir/d2/$tfile
11526 touch $DIR/$tdir/d2/x1
11527 touch $DIR/$tdir/d2/x2
11528 test_mkdir -p -c1 $DIR/$tdir/d2/a/b/c
11529 test_mkdir -p -c1 $DIR/$tdir/d2/p/q/r
11531 FID=$($LFS path2fid $DIR/$tdir/d2/$tfile | tr -d '[]')
11532 check_path "$tdir/d2/$tfile" $FSNAME $FID --link 0 ||
11533 error "check path $tdir/d2/$tfile failed"
11536 ln -s $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/p/q/r/slink
11537 FID=$($LFS path2fid $DIR/$tdir/d2/p/q/r/slink | tr -d '[]')
11538 check_path "$tdir/d2/p/q/r/slink" $FSNAME $FID --link 0 ||
11539 error "check path $tdir/d2/p/q/r/slink failed"
11541 # softlink to wrong file
11542 ln -s /this/is/garbage $DIR/$tdir/d2/p/q/r/slink.wrong
11543 FID=$($LFS path2fid $DIR/$tdir/d2/p/q/r/slink.wrong | tr -d '[]')
11544 check_path "$tdir/d2/p/q/r/slink.wrong" $FSNAME $FID --link 0 ||
11545 error "check path $tdir/d2/p/q/r/slink.wrong failed"
11548 ln $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/p/q/r/hlink
11549 mv $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/a/b/c/new_file
11550 FID=$($LFS path2fid $DIR/$tdir/d2/a/b/c/new_file | tr -d '[]')
11551 # fid2path dir/fsname should both work
11552 check_path "$tdir/d2/a/b/c/new_file" $FSNAME $FID --link 1 ||
11553 error "check path $tdir/d2/a/b/c/new_file failed"
11554 check_path "$DIR/$tdir/d2/p/q/r/hlink" $DIR $FID --link 0 ||
11555 error "check path $DIR/$tdir/d2/p/q/r/hlink failed"
11557 # hardlink count: check that there are 2 links
11558 # Doesnt work with CMD yet: 17935
11559 ${LFS} fid2path $DIR $FID | wc -l | grep -q 2 || \
11560 err17935 "expected 2 links"
11562 # hardlink indexing: remove the first link
11563 rm $DIR/$tdir/d2/p/q/r/hlink
11564 check_path "$tdir/d2/a/b/c/new_file" $FSNAME $FID --link 0 ||
11565 error "check path $DIR/$tdir/d2/a/b/c/new_file failed"
11569 run_test 162a "path lookup sanity"
11572 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11573 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
11576 $LFS setdirstripe -i0 -c$MDSCOUNT -t all_char $DIR/$tdir/striped_dir ||
11577 error "create striped dir failed"
11579 local FID=$($LFS getdirstripe $DIR/$tdir/striped_dir |
11580 tail -n 1 | awk '{print $2}')
11581 stat $MOUNT/.lustre/fid/$FID && error "sub_stripe can be accessed"
11583 touch $DIR/$tdir/striped_dir/f{0..4} || error "touch f0..4 failed"
11584 mkdir $DIR/$tdir/striped_dir/d{0..4} || error "mkdir d0..4 failed"
11587 for ((i=0;i<5;i++)); do
11588 FID=$($LFS path2fid $DIR/$tdir/striped_dir/f$i | tr -d '[]') ||
11589 error "get fid for f$i failed"
11590 check_path "$tdir/striped_dir/f$i" $FSNAME $FID --link 0 ||
11591 error "check path $tdir/striped_dir/f$i failed"
11593 FID=$($LFS path2fid $DIR/$tdir/striped_dir/d$i | tr -d '[]') ||
11594 error "get fid for d$i failed"
11595 check_path "$tdir/striped_dir/d$i" $FSNAME $FID --link 0 ||
11596 error "check path $tdir/striped_dir/d$i failed"
11601 run_test 162b "striped directory path lookup sanity"
11603 # LU-4239: Verify fid2path works with paths 100 or more directories deep
11605 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.51) ]] &&
11606 skip "Need MDS version at least 2.7.51" && return
11607 test_mkdir $DIR/$tdir.local
11608 test_mkdir $DIR/$tdir.remote
11609 local lpath=$tdir.local
11610 local rpath=$tdir.remote
11612 for ((i = 0; i <= 101; i++)); do
11615 FID=$($LFS path2fid $DIR/$lpath | tr -d '[]') ||
11616 error "get fid for local directory $DIR/$lpath failed"
11617 check_path "$DIR/$lpath" $MOUNT $FID --link 0 ||
11618 error "check path for local directory $DIR/$lpath failed"
11621 test_mkdir $DIR/$rpath
11622 FID=$($LFS path2fid $DIR/$rpath | tr -d '[]') ||
11623 error "get fid for remote directory $DIR/$rpath failed"
11624 check_path "$DIR/$rpath" $MOUNT $FID --link 0 ||
11625 error "check path for remote directory $DIR/$rpath failed"
11630 run_test 162c "fid2path works with paths 100 or more directories deep"
11633 # do directio so as not to populate the page cache
11634 log "creating a 10 Mb file"
11635 $MULTIOP $DIR/$tfile oO_CREAT:O_DIRECT:O_RDWR:w$((10*1048576))c || error "multiop failed while creating a file"
11636 log "starting reads"
11637 dd if=$DIR/$tfile of=/dev/null bs=4096 &
11638 log "truncating the file"
11639 $MULTIOP $DIR/$tfile oO_TRUNC:c || error "multiop failed while truncating the file"
11641 kill %+ || true # reads might have finished
11642 echo "wait until dd is finished"
11644 log "removing the temporary file"
11645 rm -rf $DIR/$tfile || error "tmp file removal failed"
11647 run_test 169 "parallel read and truncate should not deadlock"
11650 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11651 $LCTL clear # bug 18514
11652 $LCTL debug_daemon start $TMP/${tfile}_log_good
11654 $LCTL debug_daemon stop
11655 sed -e "s/^...../a/g" $TMP/${tfile}_log_good > $TMP/${tfile}_log_bad ||
11656 error "sed failed to read log_good"
11658 $LCTL debug_daemon start $TMP/${tfile}_log_good
11660 $LCTL debug_daemon stop
11662 $LCTL df $TMP/${tfile}_log_bad > $TMP/${tfile}_log_bad.out 2>&1 ||
11663 error "lctl df log_bad failed"
11665 local bad_line=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $9}')
11666 local good_line1=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $5}')
11668 $LCTL df $TMP/${tfile}_log_good > $TMP/${tfile}_log_good.out 2>&1
11669 local good_line2=$(tail -n 1 $TMP/${tfile}_log_good.out | awk '{print $5}')
11671 [ "$bad_line" ] && [ "$good_line1" ] && [ "$good_line2" ] ||
11672 error "bad_line good_line1 good_line2 are empty"
11674 cat $TMP/${tfile}_log_good >> $TMP/${tfile}_logs_corrupt
11675 cat $TMP/${tfile}_log_bad >> $TMP/${tfile}_logs_corrupt
11676 cat $TMP/${tfile}_log_good >> $TMP/${tfile}_logs_corrupt
11678 $LCTL df $TMP/${tfile}_logs_corrupt > $TMP/${tfile}_log_bad.out 2>&1
11679 local bad_line_new=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $9}')
11680 local good_line_new=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $5}')
11682 [ "$bad_line_new" ] && [ "$good_line_new" ] ||
11683 error "bad_line_new good_line_new are empty"
11685 local expected_good=$((good_line1 + good_line2*2))
11687 rm -f $TMP/${tfile}*
11688 # LU-231, short malformed line may not be counted into bad lines
11689 if [ $bad_line -ne $bad_line_new ] &&
11690 [ $bad_line -ne $((bad_line_new - 1)) ]; then
11691 error "expected $bad_line bad lines, but got $bad_line_new"
11695 if [ $expected_good -ne $good_line_new ]; then
11696 error "expected $expected_good good lines, but got $good_line_new"
11701 run_test 170 "test lctl df to handle corrupted log ====================="
11703 test_171() { # bug20592
11704 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11705 #define OBD_FAIL_PTLRPC_DUMP_LOG 0x50e
11706 $LCTL set_param fail_loc=0x50e
11707 $LCTL set_param fail_val=3000
11708 multiop_bg_pause $DIR/$tfile O_s || true
11710 kill -USR1 $MULTIPID
11714 if dmesg | grep "recursive fault"; then
11715 error "caught a recursive fault"
11717 $LCTL set_param fail_loc=0
11720 run_test 171 "test libcfs_debug_dumplog_thread stuck in do_exit() ======"
11722 # it would be good to share it with obdfilter-survey/iokit-libecho code
11723 setup_obdecho_osc () {
11726 local obdfilter_name=$2
11727 echo "Creating new osc for $obdfilter_name on $ost_nid"
11728 # make sure we can find loopback nid
11729 $LCTL add_uuid $ost_nid $ost_nid >/dev/null 2>&1
11731 [ $rc -eq 0 ] && { $LCTL attach osc ${obdfilter_name}_osc \
11732 ${obdfilter_name}_osc_UUID || rc=2; }
11733 [ $rc -eq 0 ] && { $LCTL --device ${obdfilter_name}_osc setup \
11734 ${obdfilter_name}_UUID $ost_nid || rc=3; }
11738 cleanup_obdecho_osc () {
11739 local obdfilter_name=$1
11740 $LCTL --device ${obdfilter_name}_osc cleanup >/dev/null
11741 $LCTL --device ${obdfilter_name}_osc detach >/dev/null
11748 local pages=${3:-64}
11753 local obd_size=$(get_obd_size $node $OBD)
11754 local page_size=$(get_page_size $node)
11755 if [[ -n "$obd_size" ]]; then
11756 local new_count=$((obd_size / (pages * page_size / 1024)))
11757 [[ $new_count -ge $count ]] || count=$new_count
11760 do_facet $node "$LCTL attach echo_client ec ec_uuid" || rc=1
11761 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec setup $OBD" ||
11763 if [ $rc -eq 0 ]; then
11764 id=$(do_facet $node "$LCTL --device ec create 1" | awk '/object id/ {print $6}')
11765 [ ${PIPESTATUS[0]} -eq 0 -a -n "$id" ] || rc=3
11767 echo "New object id is $id"
11768 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec getattr $id" ||
11770 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec " \
11771 "test_brw $count w v $pages $id" || rc=4; }
11772 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec destroy $id 1" ||
11774 [ $rc -eq 0 -o $rc -gt 2 ] && { do_facet $node "$LCTL --device ec " \
11775 "cleanup" || rc=5; }
11776 [ $rc -eq 0 -o $rc -gt 1 ] && { do_facet $node "$LCTL --device ec " \
11777 "detach" || rc=6; }
11778 [ $rc -ne 0 ] && echo "obecho_create_test failed: $rc"
11783 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11784 remote_ost_nodsh && skip "remote OST with nodsh" && return
11786 local rmmod_local=0
11788 if ! module_loaded obdecho; then
11789 load_module obdecho/obdecho
11793 local osc=$($LCTL dl | grep -v mdt | awk '$3 == "osc" {print $4; exit}')
11794 local host=$(lctl get_param -n osc.$osc.import |
11795 awk '/current_connection:/ {print $2}' )
11796 local target=$(lctl get_param -n osc.$osc.import |
11797 awk '/target:/ {print $2}' )
11798 target=${target%_UUID}
11800 [[ -n $target ]] && { setup_obdecho_osc $host $target || rc=1; } || rc=1
11801 [ $rc -eq 0 ] && { obdecho_test ${target}_osc client || rc=2; }
11802 [[ -n $target ]] && cleanup_obdecho_osc $target
11803 [ $rmmod_local -eq 1 ] && rmmod obdecho
11806 run_test 180a "test obdecho on osc"
11809 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11810 remote_ost_nodsh && skip "remote OST with nodsh" && return
11812 local rmmod_remote=0
11814 do_rpc_nodes $(facet_active_host ost1) load_module obdecho/obdecho &&
11815 rmmod_remote=true || error "failed to load module obdecho"
11816 target=$(do_facet ost1 $LCTL dl | awk '/obdfilter/ {print $4;exit}')
11817 [[ -n $target ]] && { obdecho_test $target ost1 || rc=1; }
11818 $rmmod_remote && do_facet ost1 "rmmod obdecho"
11821 run_test 180b "test obdecho directly on obdfilter"
11823 test_180c() { # LU-2598
11824 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11825 remote_ost_nodsh && skip "remote OST with nodsh" && return
11826 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.0) ]] &&
11827 skip "Need MDS version at least 2.4.0" && return
11830 local rmmod_remote=false
11831 local pages=16384 # 64MB bulk I/O RPC size
11834 do_rpc_nodes $(facet_active_host ost1) load_module obdecho/obdecho &&
11835 rmmod_remote=true || error "failed to load module obdecho"
11837 target=$(do_facet ost1 $LCTL dl | awk '/obdfilter/ { print $4 }' |
11839 if [ -n "$target" ]; then
11840 obdecho_test "$target" ost1 "$pages" || rc=${PIPESTATUS[0]}
11842 echo "there is no obdfilter target on ost1"
11845 $rmmod_remote && do_facet ost1 "rmmod obdecho" || true
11848 run_test 180c "test huge bulk I/O size on obdfilter, don't LASSERT"
11850 test_181() { # bug 22177
11851 test_mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
11852 # create enough files to index the directory
11853 createmany -o $DIR/$tdir/foobar 4000
11854 # print attributes for debug purpose
11857 multiop_bg_pause $DIR/$tdir D_Sc || return 1
11859 # remove the files & current working dir
11860 unlinkmany $DIR/$tdir/foobar 4000
11862 kill -USR1 $MULTIPID
11864 stat $DIR/$tdir && error "open-unlinked dir was not removed!"
11867 run_test 181 "Test open-unlinked dir ========================"
11873 mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
11875 $LCTL set_param mdc.*.rpc_stats=clear
11877 for (( i = 0; i < $tcount; i++ )) ; do
11878 mkdir $DIR/$tdir/$i
11881 for (( i = 0; i < $tcount; i++ )) ; do
11882 createmany -o $DIR/$tdir/$i/f- $fcount &
11886 for (( i = 0; i < $tcount; i++ )) ; do
11887 unlinkmany $DIR/$tdir/$i/f- $fcount &
11891 $LCTL get_param mdc.*.rpc_stats
11895 run_test 182 "Test parallel modify metadata operations ================"
11897 test_183() { # LU-2275
11898 remote_mds_nodsh && skip "remote MDS with nodsh" && return
11899 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.3.56) ]] &&
11900 skip "Need MDS version at least 2.3.56" && return
11902 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11903 mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
11904 echo aaa > $DIR/$tdir/$tfile
11906 #define OBD_FAIL_MDS_NEGATIVE_POSITIVE 0x148
11907 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x148
11909 ls -l $DIR/$tdir && error "ls succeeded, should have failed"
11910 cat $DIR/$tdir/$tfile && error "cat succeeded, should have failed"
11912 do_facet $SINGLEMDS $LCTL set_param fail_loc=0
11914 # Flush negative dentry cache
11915 touch $DIR/$tdir/$tfile
11917 # We are not checking for any leaked references here, they'll
11918 # become evident next time we do cleanup with module unload.
11921 run_test 183 "No crash or request leak in case of strange dispositions ========"
11923 # test suite 184 is for LU-2016, LU-2017
11925 check_swap_layouts_support && return 0
11927 dir0=$DIR/$tdir/$testnum
11928 test_mkdir -p -c1 $dir0 || error "creating dir $dir0"
11933 $SETSTRIPE -c1 $file1
11935 $SETSTRIPE -c2 $file2
11937 gen1=$($GETSTRIPE -g $file1)
11938 gen2=$($GETSTRIPE -g $file2)
11940 $LFS swap_layouts $file1 $file2 || error "swap of file layout failed"
11941 gen=$($GETSTRIPE -g $file1)
11942 [[ $gen1 != $gen ]] ||
11943 "Layout generation on $file1 does not change"
11944 gen=$($GETSTRIPE -g $file2)
11945 [[ $gen2 != $gen ]] ||
11946 "Layout generation on $file2 does not change"
11948 cmp $ref1 $file2 || error "content compare failed ($ref1 != $file2)"
11949 cmp $ref2 $file1 || error "content compare failed ($ref2 != $file1)"
11951 run_test 184a "Basic layout swap"
11954 check_swap_layouts_support && return 0
11956 dir0=$DIR/$tdir/$testnum
11957 mkdir -p $dir0 || error "creating dir $dir0"
11964 $SETSTRIPE -c1 $file1
11965 $SETSTRIPE -c2 $file2
11966 $SETSTRIPE -c1 $file3
11967 chown $RUNAS_ID $file3
11968 gen1=$($GETSTRIPE -g $file1)
11969 gen2=$($GETSTRIPE -g $file2)
11971 $LFS swap_layouts $dir1 $dir2 &&
11972 error "swap of directories layouts should fail"
11973 $LFS swap_layouts $dir1 $file1 &&
11974 error "swap of directory and file layouts should fail"
11975 $RUNAS $LFS swap_layouts $file1 $file2 &&
11976 error "swap of file we cannot write should fail"
11977 $LFS swap_layouts $file1 $file3 &&
11978 error "swap of file with different owner should fail"
11979 /bin/true # to clear error code
11981 run_test 184b "Forbidden layout swap (will generate errors)"
11984 local cmpn_arg=$(cmp -n 2>&1 | grep "invalid option")
11985 [ -n "$cmpn_arg" ] && skip_env "cmp does not support -n" && return
11986 check_swap_layouts_support && return 0
11988 local dir0=$DIR/$tdir/$testnum
11989 mkdir -p $dir0 || error "creating dir $dir0"
11991 local ref1=$dir0/ref1
11992 local ref2=$dir0/ref2
11993 local file1=$dir0/file1
11994 local file2=$dir0/file2
11995 # create a file large enough for the concurrent test
11996 dd if=/dev/urandom of=$ref1 bs=1M count=$((RANDOM % 50 + 20))
11997 dd if=/dev/urandom of=$ref2 bs=1M count=$((RANDOM % 50 + 20))
11998 echo "ref file size: ref1($(stat -c %s $ref1))," \
11999 "ref2($(stat -c %s $ref2))"
12002 dd if=$ref1 of=$file1 bs=16k &
12005 # Make sure dd starts to copy file
12006 while [ ! -f $file1 ]; do sleep 0.1; done
12008 $LFS swap_layouts $file1 $file2
12011 [[ $? == 0 ]] || error "concurrent write on $file1 failed"
12012 [[ $rc == 0 ]] || error "swap of $file1 and $file2 failed"
12014 # how many bytes copied before swapping layout
12015 local copied=$(stat -c %s $file2)
12016 local remaining=$(stat -c %s $ref1)
12017 remaining=$((remaining - copied))
12018 echo "Copied $copied bytes before swapping layout..."
12020 cmp -n $copied $file1 $ref2 | grep differ &&
12021 error "Content mismatch [0, $copied) of ref2 and file1"
12022 cmp -n $copied $file2 $ref1 ||
12023 error "Content mismatch [0, $copied) of ref1 and file2"
12024 cmp -i $copied:$copied -n $remaining $file1 $ref1 ||
12025 error "Content mismatch [$copied, EOF) of ref1 and file1"
12028 rm -f $ref1 $ref2 $file1 $file2
12030 run_test 184c "Concurrent write and layout swap"
12033 check_swap_layouts_support && return 0
12034 [ -z "$(which getfattr 2>/dev/null)" ] &&
12035 skip "no getfattr command" && return 0
12037 local file1=$DIR/$tdir/$tfile-1
12038 local file2=$DIR/$tdir/$tfile-2
12039 local file3=$DIR/$tdir/$tfile-3
12043 mkdir -p $DIR/$tdir
12044 touch $file1 || error "create $file1 failed"
12045 $OPENFILE -f O_CREAT:O_LOV_DELAY_CREATE $file2 ||
12046 error "create $file2 failed"
12047 $OPENFILE -f O_CREAT:O_LOV_DELAY_CREATE $file3 ||
12048 error "create $file3 failed"
12049 lovea1=$(get_layout_param $file1)
12051 $LFS swap_layouts $file2 $file3 ||
12052 error "swap $file2 $file3 layouts failed"
12053 $LFS swap_layouts $file1 $file2 ||
12054 error "swap $file1 $file2 layouts failed"
12056 lovea2=$(get_layout_param $file2)
12059 [ "$lovea1" == "$lovea2" ] || error "lovea $lovea1 != $lovea2"
12061 lovea1=$(getfattr -n trusted.lov $file1 | grep ^trusted)
12062 [[ -z "$lovea1" ]] || error "$file1 shouldn't have lovea"
12064 run_test 184d "allow stripeless layouts swap"
12067 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.6.94) ]] ||
12068 { skip "Need MDS version at least 2.6.94"; return 0; }
12069 check_swap_layouts_support && return 0
12070 [ -z "$(which getfattr 2>/dev/null)" ] &&
12071 skip "no getfattr command" && return 0
12073 local file1=$DIR/$tdir/$tfile-1
12074 local file2=$DIR/$tdir/$tfile-2
12075 local file3=$DIR/$tdir/$tfile-3
12078 mkdir -p $DIR/$tdir
12079 touch $file1 || error "create $file1 failed"
12080 $OPENFILE -f O_CREAT:O_LOV_DELAY_CREATE $file2 ||
12081 error "create $file2 failed"
12082 $OPENFILE -f O_CREAT:O_LOV_DELAY_CREATE $file3 ||
12083 error "create $file3 failed"
12085 $LFS swap_layouts $file1 $file2 ||
12086 error "swap $file1 $file2 layouts failed"
12088 lovea=$(getfattr -n trusted.lov $file1 | grep ^trusted)
12089 [[ -z "$lovea" ]] || error "$file1 shouldn't have lovea"
12091 echo 123 > $file1 || error "Should be able to write into $file1"
12093 $LFS swap_layouts $file1 $file3 ||
12094 error "swap $file1 $file3 layouts failed"
12096 echo 123 > $file1 || error "Should be able to write into $file1"
12098 rm -rf $file1 $file2 $file3
12100 run_test 184e "Recreate layout after stripeless layout swaps"
12102 test_185() { # LU-2441
12103 # LU-3553 - no volatile file support in old servers
12104 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.3.60) ]] ||
12105 { skip "Need MDS version at least 2.3.60"; return 0; }
12107 mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
12108 touch $DIR/$tdir/spoo
12109 local mtime1=$(stat -c "%Y" $DIR/$tdir)
12110 local fid=$($MULTIOP $DIR/$tdir VFw4096c) ||
12111 error "cannot create/write a volatile file"
12112 [ "$FILESET" == "" ] &&
12113 $CHECKSTAT -t file $MOUNT/.lustre/fid/$fid 2>/dev/null &&
12114 error "FID is still valid after close"
12116 multiop_bg_pause $DIR/$tdir vVw4096_c
12123 # assume that the next FID for this client is sequential, since stdout
12124 # is unfortunately eaten by multiop_bg_pause
12125 local n=$((${fidv[1]} + 1))
12126 local next_fid="${fidv[0]}:$(printf "0x%x" $n):${fidv[2]}"
12127 if [ "$FILESET" == "" ]; then
12128 $CHECKSTAT -t file $MOUNT/.lustre/fid/$next_fid ||
12129 error "FID is missing before close"
12131 kill -USR1 $multi_pid
12132 # 1 second delay, so if mtime change we will see it
12134 local mtime2=$(stat -c "%Y" $DIR/$tdir)
12135 [[ $mtime1 == $mtime2 ]] || error "mtime has changed"
12137 run_test 185 "Volatile file support"
12140 remote_mds_nodsh && skip "remote MDS with nodsh" && return
12141 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.3.0) ] &&
12142 skip "Need MDS version at least 2.3.0" && return
12144 local dir0=$DIR/$tdir/$testnum
12145 mkdir -p $dir0 || error "creating dir $dir0"
12147 local file=$dir0/file1
12148 dd if=/dev/urandom of=$file count=10 bs=1M conv=fsync
12149 local dv1=$($LFS data_version $file)
12150 dd if=/dev/urandom of=$file seek=10 count=1 bs=1M conv=fsync
12151 local dv2=$($LFS data_version $file)
12152 [[ $dv1 != $dv2 ]] ||
12153 error "data version did not change on write $dv1 == $dv2"
12158 run_test 187a "Test data version change"
12161 remote_mds_nodsh && skip "remote MDS with nodsh" && return
12162 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.3.0) ] &&
12163 skip "Need MDS version at least 2.3.0" && return
12165 local dir0=$DIR/$tdir/$testnum
12166 mkdir -p $dir0 || error "creating dir $dir0"
12168 declare -a DV=$($MULTIOP $dir0 Vw1000xYw1000xY | cut -f3 -d" ")
12169 [[ ${DV[0]} != ${DV[1]} ]] ||
12170 error "data version did not change on write"\
12171 " ${DV[0]} == ${DV[1]}"
12176 run_test 187b "Test data version change on volatile file"
12179 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12180 remote_mgs_nodsh && skip "remote MGS with nodsh" && return
12181 [ -n "$FILESET" ] && skip "SKIP due to FILESET set" && return
12183 local POOL=${POOL:-cea1}
12184 local POOL_ROOT=${POOL_ROOT:-$DIR/d200.pools}
12185 local POOL_DIR_NAME=${POOL_DIR_NAME:-dir_tst}
12188 local last_ost=$(($OSTCOUNT - 1))
12190 local ost_list=$(seq $first_ost $ost_step $last_ost)
12191 local ost_range="$first_ost $last_ost $ost_step"
12192 local test_path=$POOL_ROOT/$POOL_DIR_NAME
12193 local file_dir=$POOL_ROOT/file_tst
12194 local subdir=$test_path/subdir
12198 # former test_200a test_200b
12199 pool_add $POOL || { rc=$? ; break; }
12200 pool_add_targets $POOL $ost_range || { rc=$? ; break; }
12201 # former test_200c test_200d
12202 mkdir -p $test_path
12203 pool_set_dir $POOL $test_path || { rc=$? ; break; }
12204 pool_check_dir $POOL $test_path || { rc=$? ; break; }
12206 pool_check_dir $POOL $subdir || { rc=$? ; break; }
12207 pool_dir_rel_path $POOL $POOL_DIR_NAME $POOL_ROOT \
12208 || { rc=$? ; break; }
12209 # former test_200e test_200f
12210 local files=$((OSTCOUNT*3))
12211 pool_alloc_files $POOL $test_path $files "$ost_list" \
12212 || { rc=$? ; break; }
12213 pool_create_files $POOL $file_dir $files "$ost_list" \
12214 || { rc=$? ; break; }
12215 # former test_200g test_200h
12216 pool_lfs_df $POOL || { rc=$? ; break; }
12217 pool_file_rel_path $POOL $test_path || { rc=$? ; break; }
12219 # former test_201a test_201b test_201c
12220 pool_remove_first_target $POOL || { rc=$? ; break; }
12222 local f=$test_path/$tfile
12223 pool_remove_all_targets $POOL $f || { rc=$? ; break; }
12224 pool_remove $POOL $f || { rc=$? ; break; }
12231 run_test 200 "OST pools"
12233 # usage: default_attr <count | size | offset>
12235 $LCTL get_param -n lov.$FSNAME-clilov-\*.stripe${1}
12238 # usage: check_default_stripe_attr
12239 check_default_stripe_attr() {
12240 ACTUAL=$($GETSTRIPE $* $DIR/$tdir)
12243 [ -n "$2" ] && EXPECTED=0 || EXPECTED=$(default_attr count);;
12245 [ -n "$2" ] && EXPECTED=0 || EXPECTED=$(default_attr size);;
12249 error "unknown getstripe attr '$1'"
12252 [ $ACTUAL != $EXPECTED ] &&
12253 error "$DIR/$tdir has $1 '$ACTUAL', not '$EXPECTED'"
12257 test_mkdir -p $DIR/$tdir
12258 $SETSTRIPE --stripe-count 0 --stripe-size 0 --stripe-index -1 $DIR/$tdir
12260 check_default_stripe_attr --stripe-count
12261 check_default_stripe_attr --stripe-size
12262 check_default_stripe_attr --stripe-index
12266 run_test 204a "Print default stripe attributes ================="
12269 test_mkdir -p $DIR/$tdir
12270 $SETSTRIPE --stripe-count 1 $DIR/$tdir
12272 check_default_stripe_attr --stripe-size
12273 check_default_stripe_attr --stripe-index
12277 run_test 204b "Print default stripe size and offset ==========="
12280 test_mkdir -p $DIR/$tdir
12281 $SETSTRIPE --stripe-size 65536 $DIR/$tdir
12283 check_default_stripe_attr --stripe-count
12284 check_default_stripe_attr --stripe-index
12288 run_test 204c "Print default stripe count and offset ==========="
12291 test_mkdir -p $DIR/$tdir
12292 $SETSTRIPE --stripe-index 0 $DIR/$tdir
12294 check_default_stripe_attr --stripe-count
12295 check_default_stripe_attr --stripe-size
12299 run_test 204d "Print default stripe count and size ============="
12302 test_mkdir -p $DIR/$tdir
12303 $SETSTRIPE -d $DIR/$tdir
12305 check_default_stripe_attr --stripe-count --raw
12306 check_default_stripe_attr --stripe-size --raw
12307 check_default_stripe_attr --stripe-index --raw
12311 run_test 204e "Print raw stripe attributes ================="
12314 test_mkdir -p $DIR/$tdir
12315 $SETSTRIPE --stripe-count 1 $DIR/$tdir
12317 check_default_stripe_attr --stripe-size --raw
12318 check_default_stripe_attr --stripe-index --raw
12322 run_test 204f "Print raw stripe size and offset ==========="
12325 test_mkdir -p $DIR/$tdir
12326 $SETSTRIPE --stripe-size 65536 $DIR/$tdir
12328 check_default_stripe_attr --stripe-count --raw
12329 check_default_stripe_attr --stripe-index --raw
12333 run_test 204g "Print raw stripe count and offset ==========="
12336 test_mkdir -p $DIR/$tdir
12337 $SETSTRIPE --stripe-index 0 $DIR/$tdir
12339 check_default_stripe_attr --stripe-count --raw
12340 check_default_stripe_attr --stripe-size --raw
12344 run_test 204h "Print raw stripe count and size ============="
12346 # Figure out which job scheduler is being used, if any,
12347 # or use a fake one
12348 if [ -n "$SLURM_JOB_ID" ]; then # SLURM
12349 JOBENV=SLURM_JOB_ID
12350 elif [ -n "$LSB_JOBID" ]; then # Load Sharing Facility
12352 elif [ -n "$PBS_JOBID" ]; then # PBS/Maui/Moab
12354 elif [ -n "$LOADL_STEPID" ]; then # LoadLeveller
12355 JOBENV=LOADL_STEP_ID
12356 elif [ -n "$JOB_ID" ]; then # Sun Grid Engine
12359 $LCTL list_param jobid_name > /dev/null 2>&1
12360 if [ $? -eq 0 ]; then
12367 verify_jobstats() {
12372 # we don't really need to clear the stats for this test to work, since each
12373 # command has a unique jobid, but it makes debugging easier if needed.
12374 # for facet in $facets; do
12375 # local dev=$(convert_facet2label $facet)
12376 # # clear old jobstats
12377 # do_facet $facet lctl set_param *.$dev.job_stats="clear"
12380 # use a new JobID for each test, or we might see an old one
12381 [ "$JOBENV" = "FAKE_JOBID" ] &&
12382 FAKE_JOBID=id.$testnum.$(basename ${cmd[0]}).$RANDOM
12386 [ "$JOBENV" = "nodelocal" ] && {
12387 FAKE_JOBID=id.$testnum.$(basename ${cmd[0]}).$RANDOM
12388 $LCTL set_param jobid_name=$FAKE_JOBID
12392 log "Test: ${cmd[*]}"
12393 log "Using JobID environment variable $JOBENV=$JOBVAL"
12395 if [ $JOBENV = "FAKE_JOBID" ]; then
12396 FAKE_JOBID=$JOBVAL ${cmd[*]}
12401 # all files are created on OST0000
12402 for facet in $facets; do
12403 local stats="*.$(convert_facet2label $facet).job_stats"
12404 if [ $(do_facet $facet lctl get_param $stats |
12405 grep -c $JOBVAL) -ne 1 ]; then
12406 do_facet $facet lctl get_param $stats
12407 error "No jobstats for $JOBVAL found on $facet::$stats"
12414 NEW_JOBENV=${1:-$OLD_JOBENV}
12415 do_facet mgs $LCTL conf_param $FSNAME.sys.jobid_var=$NEW_JOBENV
12416 wait_update $HOSTNAME "$LCTL get_param -n jobid_var" $NEW_JOBENV
12421 do_facet $SINGLEMDS \
12422 $LCTL set_param mdt.*.job_cleanup_interval=$OLD_INTERVAL
12423 [ $OLD_JOBENV != $JOBENV ] && jobstats_set $OLD_JOBENV
12427 test_205() { # Job stats
12428 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.7.1) ]] ||
12429 { skip "Need MDS version with at least 2.7.1"; return 0; }
12431 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12432 remote_mgs_nodsh && skip "remote MGS with nodsh" && return
12433 remote_mds_nodsh && skip "remote MDS with nodsh" && return
12434 remote_ost_nodsh && skip "remote OST with nodsh" && return
12436 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep jobstats)" ] &&
12437 skip "Server doesn't support jobstats" && return 0
12438 [[ $JOBID_VAR = disable ]] && skip "jobstats is disabled" && return
12440 OLD_JOBENV=$($LCTL get_param -n jobid_var)
12441 if [ $OLD_JOBENV != $JOBENV ]; then
12442 jobstats_set $JOBENV
12443 trap cleanup_205 EXIT
12446 CL_USER=$(do_facet $SINGLEMDS lctl --device $MDT0 changelog_register -n)
12447 echo "Registered as changelog user $CL_USER"
12449 OLD_INTERVAL=$(do_facet $SINGLEMDS \
12450 lctl get_param -n mdt.*.job_cleanup_interval)
12451 local interval_new=5
12452 do_facet $SINGLEMDS \
12453 $LCTL set_param mdt.*.job_cleanup_interval=$interval_new
12454 local start=$SECONDS
12458 cmd="mkdir $DIR/$tdir"
12459 verify_jobstats "$cmd" "$SINGLEMDS"
12461 cmd="rmdir $DIR/$tdir"
12462 verify_jobstats "$cmd" "$SINGLEMDS"
12463 # mkdir on secondary MDT
12464 if [ $MDSCOUNT -gt 1 ]; then
12465 cmd="lfs mkdir -i 1 $DIR/$tdir.remote"
12466 verify_jobstats "$cmd" "mds2"
12469 cmd="mknod $DIR/$tfile c 1 3"
12470 verify_jobstats "$cmd" "$SINGLEMDS"
12472 cmd="rm -f $DIR/$tfile"
12473 verify_jobstats "$cmd" "$SINGLEMDS"
12474 # create all files on OST0000 so verify_jobstats can find OST stats
12476 cmd="$SETSTRIPE -i 0 -c 1 $DIR/$tfile"
12477 verify_jobstats "$cmd" "$SINGLEMDS"
12479 cmd="touch $DIR/$tfile"
12480 verify_jobstats "$cmd" "$SINGLEMDS ost1"
12482 cmd="dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 oflag=sync"
12483 verify_jobstats "$cmd" "ost1"
12485 cancel_lru_locks osc
12486 cmd="dd if=$DIR/$tfile of=/dev/null bs=1M count=1 iflag=direct"
12487 verify_jobstats "$cmd" "ost1"
12489 cmd="$TRUNCATE $DIR/$tfile 0"
12490 verify_jobstats "$cmd" "$SINGLEMDS ost1"
12492 cmd="mv -f $DIR/$tfile $DIR/$tdir.rename"
12493 verify_jobstats "$cmd" "$SINGLEMDS"
12494 # jobstats expiry - sleep until old stats should be expired
12495 local left=$((interval_new + 5 - (SECONDS - start)))
12496 [ $left -ge 0 ] && wait_update_facet $SINGLEMDS \
12497 "lctl get_param *.*.job_stats | grep -c 'job_id.*mkdir'" \
12499 cmd="mkdir $DIR/$tdir.expire"
12500 verify_jobstats "$cmd" "$SINGLEMDS"
12501 [ $(do_facet $SINGLEMDS lctl get_param *.*.job_stats |
12502 grep -c "job_id.*mkdir") -gt 1 ] && error "old jobstats not expired"
12504 # Ensure that jobid are present in changelog (if supported by MDS)
12505 if [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.6.52) ]
12507 $LFS changelog $MDT0 | tail -9
12508 jobids=$($LFS changelog $MDT0 | tail -9 | grep -c "j=")
12509 [ $jobids -eq 9 ] ||
12510 error "Wrong changelog jobid count $jobids != 9"
12514 jobstats_set $JOBENV
12516 $LFS changelog $MDT0 | tail -1
12517 jobids=$($LFS changelog $MDT0 | tail -1 | grep -c "j=")
12518 [ $jobids -eq 0 ] ||
12519 error "Unexpected jobids when jobid_var=$JOBENV"
12524 run_test 205 "Verify job stats"
12526 # LU-1480, LU-1773 and LU-1657
12528 mkdir -p $DIR/$tdir
12529 $SETSTRIPE -c -1 $DIR/$tdir
12530 #define OBD_FAIL_LOV_INIT 0x1403
12531 $LCTL set_param fail_loc=0xa0001403
12532 $LCTL set_param fail_val=1
12533 touch $DIR/$tdir/$tfile || true
12535 run_test 206 "fail lov_init_raid0() doesn't lbug"
12538 dd if=/dev/zero of=$DIR/$tfile bs=4k count=$((RANDOM%10+1))
12539 local fsz=`stat -c %s $DIR/$tfile`
12540 cancel_lru_locks mdc
12542 # do not return layout in getattr intent
12543 #define OBD_FAIL_MDS_NO_LL_GETATTR 0x170
12544 $LCTL set_param fail_loc=0x170
12545 local sz=`stat -c %s $DIR/$tfile`
12547 [ $fsz -eq $sz ] || error "file size expected $fsz, actual $sz"
12551 run_test 207a "can refresh layout at glimpse"
12554 dd if=/dev/zero of=$DIR/$tfile bs=4k count=$((RANDOM%10+1))
12555 local cksum=`md5sum $DIR/$tfile`
12556 local fsz=`stat -c %s $DIR/$tfile`
12557 cancel_lru_locks mdc
12558 cancel_lru_locks osc
12560 # do not return layout in getattr intent
12561 #define OBD_FAIL_MDS_NO_LL_OPEN 0x171
12562 $LCTL set_param fail_loc=0x171
12564 # it will refresh layout after the file is opened but before read issues
12565 echo checksum is "$cksum"
12566 echo "$cksum" |md5sum -c --quiet || error "file differs"
12570 run_test 207b "can refresh layout at open"
12573 # FIXME: in this test suite, only RD lease is used. This is okay
12574 # for now as only exclusive open is supported. After generic lease
12575 # is done, this test suite should be revised. - Jinshan
12577 remote_mds_nodsh && skip "remote MDS with nodsh" && return
12578 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.4.52) ]] ||
12579 { skip "Need MDS version at least 2.4.52"; return 0; }
12581 echo "==== test 1: verify get lease work"
12582 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:eRE+eU || error "get lease error"
12584 echo "==== test 2: verify lease can be broken by upcoming open"
12585 $MULTIOP $DIR/$tfile oO_RDONLY:eR_E-eUc &
12589 $MULTIOP $DIR/$tfile oO_RDONLY:c
12590 kill -USR1 $PID && wait $PID || error "break lease error"
12592 echo "==== test 3: verify lease can't be granted if an open already exists"
12593 $MULTIOP $DIR/$tfile oO_RDONLY:_c &
12597 $MULTIOP $DIR/$tfile oO_RDONLY:eReUc && error "apply lease should fail"
12598 kill -USR1 $PID && wait $PID || error "open file error"
12600 echo "==== test 4: lease can sustain over recovery"
12601 $MULTIOP $DIR/$tfile oO_RDONLY:eR_E+eUc &
12607 kill -USR1 $PID && wait $PID || error "lease broken over recovery"
12609 echo "==== test 5: lease broken can't be regained by replay"
12610 $MULTIOP $DIR/$tfile oO_RDONLY:eR_E-eUc &
12614 # open file to break lease and then recovery
12615 $MULTIOP $DIR/$tfile oO_RDWR:c || error "open file error"
12618 kill -USR1 $PID && wait $PID || error "lease not broken over recovery"
12622 run_test 208 "Exclusive open"
12625 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep disp_stripe)" ] &&
12626 skip_env "must have disp_stripe" && return
12629 sync; sleep 5; sync;
12631 echo 3 > /proc/sys/vm/drop_caches
12632 req_before=$(awk '/ptlrpc_cache / { print $2 }' /proc/slabinfo)
12634 # open/close 500 times
12635 for i in $(seq 500); do
12639 echo 3 > /proc/sys/vm/drop_caches
12640 req_after=$(awk '/ptlrpc_cache / { print $2 }' /proc/slabinfo)
12642 echo "before: $req_before, after: $req_after"
12643 [ $((req_after - req_before)) -ge 300 ] &&
12644 error "open/close requests are not freed"
12647 run_test 209 "read-only open/close requests should be freed promptly"
12651 size=$((size % 8192 + 1))
12652 dd if=/dev/urandom of=$DIR/f212 bs=1k count=$size
12653 sendfile $DIR/f212 $DIR/f212.xyz || error "sendfile wrong"
12654 rm -f $DIR/f212 $DIR/f212.xyz
12656 run_test 212 "Sendfile test ============================================"
12659 dd if=/dev/zero of=$DIR/$tfile bs=4k count=4
12660 cancel_lru_locks osc
12661 lctl set_param fail_loc=0x8000040f
12662 # generate a read lock
12663 cat $DIR/$tfile > /dev/null
12664 # write to the file, it will try to cancel the above read lock.
12665 cat /etc/hosts >> $DIR/$tfile
12667 run_test 213 "OSC lock completion and cancel race don't crash - bug 18829"
12669 test_214() { # for bug 20133
12670 mkdir -p $DIR/$tdir/d214c || error "mkdir $DIR/$tdir/d214c failed"
12671 for (( i=0; i < 340; i++ )) ; do
12672 touch $DIR/$tdir/d214c/a$i
12675 ls -l $DIR/$tdir || error "ls -l $DIR/d214p failed"
12676 mv $DIR/$tdir/d214c $DIR/ || error "mv $DIR/d214p/d214c $DIR/ failed"
12677 ls $DIR/d214c || error "ls $DIR/d214c failed"
12678 rm -rf $DIR/$tdir || error "rm -rf $DIR/d214* failed"
12679 rm -rf $DIR/d214* || error "rm -rf $DIR/d214* failed"
12681 run_test 214 "hash-indexed directory test - bug 20133"
12683 # having "abc" as 1st arg, creates $TMP/lnet_abc.out and $TMP/lnet_abc.sys
12684 create_lnet_proc_files() {
12685 lctl get_param -n $1 >$TMP/lnet_$1.out || error "cannot read lnet.$1"
12686 sysctl lnet.$1 >$TMP/lnet_$1.sys_tmp || error "cannot read lnet.$1"
12688 sed "s/^lnet.$1\ =\ //g" "$TMP/lnet_$1.sys_tmp" >$TMP/lnet_$1.sys
12689 rm -f "$TMP/lnet_$1.sys_tmp"
12692 # counterpart of create_lnet_proc_files
12693 remove_lnet_proc_files() {
12694 rm -f $TMP/lnet_$1.out $TMP/lnet_$1.sys
12697 # uses 1st arg as trailing part of filename, 2nd arg as description for reports,
12698 # 3rd arg as regexp for body
12699 check_lnet_proc_stats() {
12700 local l=$(cat "$TMP/lnet_$1" |wc -l)
12701 [ $l = 1 ] || (cat "$TMP/lnet_$1" && error "$2 is not of 1 line: $l")
12703 grep -E "$3" "$TMP/lnet_$1" || (cat "$TMP/lnet_$1" && error "$2 misformatted")
12706 # uses 1st arg as trailing part of filename, 2nd arg as description for reports,
12707 # 3rd arg as regexp for body, 4th arg as regexp for 1st line, 5th arg is
12708 # optional and can be regexp for 2nd line (lnet.routes case)
12709 check_lnet_proc_entry() {
12710 local blp=2 # blp stands for 'position of 1st line of body'
12711 [ -z "$5" ] || blp=3 # lnet.routes case
12713 local l=$(cat "$TMP/lnet_$1" |wc -l)
12714 # subtracting one from $blp because the body can be empty
12715 [ "$l" -ge "$(($blp - 1))" ] || (cat "$TMP/lnet_$1" && error "$2 is too short: $l")
12717 sed -n '1 p' "$TMP/lnet_$1" |grep -E "$4" >/dev/null ||
12718 (cat "$TMP/lnet_$1" && error "1st line of $2 misformatted")
12720 [ "$5" = "" ] || sed -n '2 p' "$TMP/lnet_$1" |grep -E "$5" >/dev/null ||
12721 (cat "$TMP/lnet_$1" && error "2nd line of $2 misformatted")
12723 # bail out if any unexpected line happened
12724 sed -n "$blp p" "$TMP/lnet_$1" | grep -Ev "$3"
12725 [ "$?" != 0 ] || error "$2 misformatted"
12728 test_215() { # for bugs 18102, 21079, 21517
12729 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12730 local N='(0|[1-9][0-9]*)' # non-negative numeric
12731 local P='[1-9][0-9]*' # positive numeric
12732 local I='(0|-?[1-9][0-9]*|NA)' # any numeric (0 | >0 | <0) or NA if no value
12733 local NET='[a-z][a-z0-9]*' # LNET net like o2ib2
12734 local ADDR='[0-9.]+' # LNET addr like 10.0.0.1
12735 local NID="$ADDR@$NET" # LNET nid like 10.0.0.1@o2ib2
12737 local L1 # regexp for 1st line
12738 local L2 # regexp for 2nd line (optional)
12739 local BR # regexp for the rest (body)
12741 # lnet.stats should look as 11 space-separated non-negative numerics
12742 BR="^$N $N $N $N $N $N $N $N $N $N $N$"
12743 create_lnet_proc_files "stats"
12744 check_lnet_proc_stats "stats.sys" "lnet.stats" "$BR"
12745 remove_lnet_proc_files "stats"
12747 # lnet.routes should look like this:
12748 # Routing disabled/enabled
12749 # net hops priority state router
12750 # where net is a string like tcp0, hops > 0, priority >= 0,
12751 # state is up/down,
12752 # router is a string like 192.168.1.1@tcp2
12753 L1="^Routing (disabled|enabled)$"
12754 L2="^net +hops +priority +state +router$"
12755 BR="^$NET +$N +(0|1) +(up|down) +$NID$"
12756 create_lnet_proc_files "routes"
12757 check_lnet_proc_entry "routes.sys" "lnet.routes" "$BR" "$L1" "$L2"
12758 remove_lnet_proc_files "routes"
12760 # lnet.routers should look like this:
12761 # ref rtr_ref alive_cnt state last_ping ping_sent deadline down_ni router
12762 # where ref > 0, rtr_ref > 0, alive_cnt >= 0, state is up/down,
12763 # last_ping >= 0, ping_sent is boolean (0/1), deadline and down_ni are
12764 # numeric (0 or >0 or <0), router is a string like 192.168.1.1@tcp2
12765 L1="^ref +rtr_ref +alive_cnt +state +last_ping +ping_sent +deadline +down_ni +router$"
12766 BR="^$P +$P +$N +(up|down) +$N +(0|1) +$I +$I +$NID$"
12767 create_lnet_proc_files "routers"
12768 check_lnet_proc_entry "routers.sys" "lnet.routers" "$BR" "$L1"
12769 remove_lnet_proc_files "routers"
12771 # lnet.peers should look like this:
12772 # nid refs state last max rtr min tx min queue
12773 # where nid is a string like 192.168.1.1@tcp2, refs > 0,
12774 # state is up/down/NA, max >= 0. last, rtr, min, tx, min are
12775 # numeric (0 or >0 or <0), queue >= 0.
12776 L1="^nid +refs +state +last +max +rtr +min +tx +min +queue$"
12777 BR="^$NID +$P +(up|down|NA) +$I +$N +$I +$I +$I +$I +$N$"
12778 create_lnet_proc_files "peers"
12779 check_lnet_proc_entry "peers.sys" "lnet.peers" "$BR" "$L1"
12780 remove_lnet_proc_files "peers"
12782 # lnet.buffers should look like this:
12783 # pages count credits min
12784 # where pages >=0, count >=0, credits and min are numeric (0 or >0 or <0)
12785 L1="^pages +count +credits +min$"
12786 BR="^ +$N +$N +$I +$I$"
12787 create_lnet_proc_files "buffers"
12788 check_lnet_proc_entry "buffers.sys" "lnet.buffers" "$BR" "$L1"
12789 remove_lnet_proc_files "buffers"
12791 # lnet.nis should look like this:
12792 # nid status alive refs peer rtr max tx min
12793 # where nid is a string like 192.168.1.1@tcp2, status is up/down,
12794 # alive is numeric (0 or >0 or <0), refs >= 0, peer >= 0,
12795 # rtr >= 0, max >=0, tx and min are numeric (0 or >0 or <0).
12796 L1="^nid +status +alive +refs +peer +rtr +max +tx +min$"
12797 BR="^$NID +(up|down) +$I +$N +$N +$N +$N +$I +$I$"
12798 create_lnet_proc_files "nis"
12799 check_lnet_proc_entry "nis.sys" "lnet.nis" "$BR" "$L1"
12800 remove_lnet_proc_files "nis"
12802 # can we successfully write to lnet.stats?
12803 lctl set_param -n stats=0 || error "cannot write to lnet.stats"
12804 sysctl -w lnet.stats=0 || error "cannot write to lnet.stats"
12806 run_test 215 "lnet exists and has proper content - bugs 18102, 21079, 21517"
12808 test_216() { # bug 20317
12809 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12810 remote_ost_nodsh && skip "remote OST with nodsh" && return
12813 local facets=$(get_facets OST)
12814 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
12816 save_lustre_params client "osc.*.contention_seconds" > $p
12817 save_lustre_params $facets \
12818 "ldlm.namespaces.filter-*.max_nolock_bytes" >> $p
12819 save_lustre_params $facets \
12820 "ldlm.namespaces.filter-*.contended_locks" >> $p
12821 save_lustre_params $facets \
12822 "ldlm.namespaces.filter-*.contention_seconds" >> $p
12823 clear_stats osc.*.osc_stats
12825 # agressive lockless i/o settings
12826 do_nodes $(comma_list $(osts_nodes)) \
12827 "lctl set_param -n ldlm.namespaces.*.max_nolock_bytes=2000000 \
12828 ldlm.namespaces.filter-*.contended_locks=0 \
12829 ldlm.namespaces.filter-*.contention_seconds=60"
12830 lctl set_param -n osc.*.contention_seconds=60
12832 $DIRECTIO write $DIR/$tfile 0 10 4096
12833 $CHECKSTAT -s 40960 $DIR/$tfile
12835 # disable lockless i/o
12836 do_nodes $(comma_list $(osts_nodes)) \
12837 "lctl set_param -n ldlm.namespaces.filter-*.max_nolock_bytes=0 \
12838 ldlm.namespaces.filter-*.contended_locks=32 \
12839 ldlm.namespaces.filter-*.contention_seconds=0"
12840 lctl set_param -n osc.*.contention_seconds=0
12841 clear_stats osc.*.osc_stats
12843 dd if=/dev/zero of=$DIR/$tfile count=0
12844 $CHECKSTAT -s 0 $DIR/$tfile
12846 restore_lustre_params <$p
12850 run_test 216 "check lockless direct write updates file size and kms correctly"
12852 test_217() { # bug 22430
12853 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12857 for node in $(nodes_list); do
12858 nid=$(host_nids_address $node $NETTYPE)
12859 if [[ $nid = *-* ]] ; then
12860 echo "lctl ping $(h2nettype $nid)"
12861 lctl ping $(h2nettype $nid)
12863 echo "skipping $node (no hyphen detected)"
12867 run_test 217 "check lctl ping for hostnames with hiphen ('-')"
12870 # do directio so as not to populate the page cache
12871 log "creating a 10 Mb file"
12872 $MULTIOP $DIR/$tfile oO_CREAT:O_DIRECT:O_RDWR:w$((10*1048576))c || error "multiop failed while creating a file"
12873 log "starting reads"
12874 dd if=$DIR/$tfile of=/dev/null bs=4096 &
12875 log "truncating the file"
12876 $MULTIOP $DIR/$tfile oO_TRUNC:c || error "multiop failed while truncating the file"
12878 kill %+ || true # reads might have finished
12879 echo "wait until dd is finished"
12881 log "removing the temporary file"
12882 rm -rf $DIR/$tfile || error "tmp file removal failed"
12884 run_test 218 "parallel read and truncate should not deadlock ======================="
12887 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12888 # write one partial page
12889 dd if=/dev/zero of=$DIR/$tfile bs=1024 count=1
12890 # set no grant so vvp_io_commit_write will do sync write
12891 $LCTL set_param fail_loc=0x411
12892 # write a full page at the end of file
12893 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 seek=1 conv=notrunc
12895 $LCTL set_param fail_loc=0
12896 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 seek=3
12897 $LCTL set_param fail_loc=0x411
12898 dd if=/dev/zero of=$DIR/$tfile bs=1024 count=1 seek=2 conv=notrunc
12901 dd if=/dev/zero of=$DIR/$tfile-2 bs=1024 count=1
12902 $CHECKSTAT -s 1024 $DIR/$tfile-2 || error "checkstat wrong size"
12904 run_test 219 "LU-394: Write partial won't cause uncontiguous pages vec at LND"
12906 test_220() { #LU-325
12907 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12908 remote_ost_nodsh && skip "remote OST with nodsh" && return
12909 remote_mds_nodsh && skip "remote MDS with nodsh" && return
12910 remote_mgs_nodsh && skip "remote MGS with nodsh" && return
12913 # create on MDT0000 so the last_id and next_id are correct
12915 local OST=$($LFS df $DIR | awk '/OST:'$OSTIDX'/ { print $1 }')
12919 local mdtosc_proc1=$(get_mdtosc_proc_path $SINGLEMDS $OST)
12920 local last_id=$(do_facet $SINGLEMDS lctl get_param -n \
12921 osc.$mdtosc_proc1.prealloc_last_id)
12922 local next_id=$(do_facet $SINGLEMDS lctl get_param -n \
12923 osc.$mdtosc_proc1.prealloc_next_id)
12927 do_facet ost$((OSTIDX + 1)) lctl set_param fail_val=-1
12928 #define OBD_FAIL_OST_ENOINO 0x229
12929 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=0x229
12930 create_pool $FSNAME.$TESTNAME || return 1
12931 do_facet mgs $LCTL pool_add $FSNAME.$TESTNAME $OST || return 2
12933 $SETSTRIPE $DIR/$tdir -i $OSTIDX -c 1 -p $FSNAME.$TESTNAME
12935 MDSOBJS=$((last_id - next_id))
12936 echo "preallocated objects on MDS is $MDSOBJS" "($last_id - $next_id)"
12938 blocks=$($LFS df $MOUNT | awk '($1 == '$OSTIDX') { print $4 }')
12939 echo "OST still has $count kbytes free"
12941 echo "create $MDSOBJS files @next_id..."
12942 createmany -o $DIR/$tdir/f $MDSOBJS || return 3
12944 local last_id2=$(do_facet mds${MDSIDX} lctl get_param -n \
12945 osc.$mdtosc_proc1.prealloc_last_id)
12946 local next_id2=$(do_facet mds${MDSIDX} lctl get_param -n \
12947 osc.$mdtosc_proc1.prealloc_next_id)
12949 echo "after creation, last_id=$last_id2, next_id=$next_id2"
12954 do_facet ost$((OSTIDX + 1)) lctl set_param fail_val=0
12955 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=0
12957 do_facet mgs $LCTL pool_remove $FSNAME.$TESTNAME $OST || return 4
12958 do_facet mgs $LCTL pool_destroy $FSNAME.$TESTNAME || return 5
12959 echo "unlink $MDSOBJS files @$next_id..."
12960 unlinkmany $DIR/$tdir/f $MDSOBJS || return 6
12962 run_test 220 "preallocated MDS objects still used if ENOSPC from OST"
12965 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12966 dd if=`which date` of=$MOUNT/date oflag=sync
12967 chmod +x $MOUNT/date
12969 #define OBD_FAIL_LLITE_FAULT_TRUNC_RACE 0x1401
12970 $LCTL set_param fail_loc=0x80001401
12972 $MOUNT/date > /dev/null
12975 run_test 221 "make sure fault and truncate race to not cause OOM"
12978 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12980 test_mkdir -p $DIR/$tdir
12981 $SETSTRIPE -c 1 -i 0 $DIR/$tdir
12982 createmany -o $DIR/$tdir/$tfile 10
12983 cancel_lru_locks mdc
12984 cancel_lru_locks osc
12985 #define OBD_FAIL_LDLM_AGL_DELAY 0x31a
12986 $LCTL set_param fail_loc=0x31a
12987 ls -l $DIR/$tdir > /dev/null || error "AGL for ls failed"
12988 $LCTL set_param fail_loc=0
12991 run_test 222a "AGL for ls should not trigger CLIO lock failure ================"
12994 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12996 test_mkdir -p $DIR/$tdir
12997 $SETSTRIPE -c 1 -i 0 $DIR/$tdir
12998 createmany -o $DIR/$tdir/$tfile 10
12999 cancel_lru_locks mdc
13000 cancel_lru_locks osc
13001 #define OBD_FAIL_LDLM_AGL_DELAY 0x31a
13002 $LCTL set_param fail_loc=0x31a
13003 rm -r $DIR/$tdir || error "AGL for rmdir failed"
13004 $LCTL set_param fail_loc=0
13006 run_test 222b "AGL for rmdir should not trigger CLIO lock failure ============="
13009 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13011 test_mkdir -p $DIR/$tdir
13012 $SETSTRIPE -c 1 -i 0 $DIR/$tdir
13013 createmany -o $DIR/$tdir/$tfile 10
13014 cancel_lru_locks mdc
13015 cancel_lru_locks osc
13016 #define OBD_FAIL_LDLM_AGL_NOLOCK 0x31b
13017 $LCTL set_param fail_loc=0x31b
13018 ls -l $DIR/$tdir > /dev/null || error "reenqueue failed"
13019 $LCTL set_param fail_loc=0
13022 run_test 223 "osc reenqueue if without AGL lock granted ======================="
13024 test_224a() { # LU-1039, MRP-303
13025 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13026 #define OBD_FAIL_PTLRPC_CLIENT_BULK_CB 0x508
13027 $LCTL set_param fail_loc=0x508
13028 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 conv=fsync
13029 $LCTL set_param fail_loc=0
13032 run_test 224a "Don't panic on bulk IO failure"
13034 test_224b() { # LU-1039, MRP-303
13035 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13036 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1
13037 cancel_lru_locks osc
13038 #define OBD_FAIL_PTLRPC_CLIENT_BULK_CB2 0x515
13039 $LCTL set_param fail_loc=0x515
13040 dd of=/dev/null if=$DIR/$tfile bs=4096 count=1
13041 $LCTL set_param fail_loc=0
13044 run_test 224b "Don't panic on bulk IO failure"
13046 test_224c() { # LU-6441
13047 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13048 remote_mds_nodsh && skip "remote MDS with nodsh" && return
13050 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
13051 save_writethrough $p
13052 set_cache writethrough on
13054 local pages_per_rpc=$($LCTL get_param \
13055 osc.*.max_pages_per_rpc)
13056 local at_max=$($LCTL get_param -n at_max)
13057 local timeout=$($LCTL get_param -n timeout)
13058 local test_at="$LCTL get_param -n at_max"
13059 local param_at="$FSNAME.sys.at_max"
13060 local test_timeout="$LCTL get_param -n timeout"
13061 local param_timeout="$FSNAME.sys.timeout"
13063 $LCTL set_param -n osc.*.max_pages_per_rpc=1024
13065 set_conf_param_and_check client "$test_at" "$param_at" 0 ||
13066 error "conf_param at_max=0 failed"
13067 set_conf_param_and_check client "$test_timeout" "$param_timeout" 5 ||
13068 error "conf_param timeout=5 failed"
13070 #define OBD_FAIL_PTLRPC_CLIENT_BULK_CB3 0x520
13071 do_facet ost1 $LCTL set_param fail_loc=0x520
13072 $LFS setstripe -c 1 -i 0 $DIR/$tfile
13073 dd if=/dev/zero of=$DIR/$tfile bs=8MB count=1
13075 do_facet ost1 $LCTL set_param fail_loc=0
13077 set_conf_param_and_check client "$test_at" "$param_at" $at_max ||
13078 error "conf_param at_max=$at_max failed"
13079 set_conf_param_and_check client "$test_timeout" "$param_timeout" \
13080 $timeout || error "conf_param timeout=$timeout failed"
13082 $LCTL set_param -n $pages_per_rpc
13083 restore_lustre_params < $p
13086 run_test 224c "Don't hang if one of md lost during large bulk RPC"
13088 MDSSURVEY=${MDSSURVEY:-$(which mds-survey 2>/dev/null || true)}
13090 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13091 remote_mds_nodsh && skip "remote MDS with nodsh" && return
13092 if [ -z ${MDSSURVEY} ]; then
13093 skip_env "mds-survey not found" && return
13096 [ $MDSCOUNT -ge 2 ] &&
13097 skip "skipping now for more than one MDT" && return
13099 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.51) ] ||
13100 { skip "Need MDS version at least 2.2.51"; return; }
13102 local mds=$(facet_host $SINGLEMDS)
13103 local target=$(do_nodes $mds 'lctl dl' | \
13104 awk "{if (\$2 == \"UP\" && \$3 == \"mdt\") {print \$4}}")
13106 local cmd1="file_count=1000 thrhi=4"
13107 local cmd2="dir_count=2 layer=mdd stripe_count=0"
13108 local cmd3="rslt_loc=${TMP} targets=\"$mds:$target\" $MDSSURVEY"
13109 local cmd="$cmd1 $cmd2 $cmd3"
13111 rm -f ${TMP}/mds_survey*
13113 eval $cmd || error "mds-survey with zero-stripe failed"
13114 cat ${TMP}/mds_survey*
13115 rm -f ${TMP}/mds_survey*
13117 run_test 225a "Metadata survey sanity with zero-stripe"
13120 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13121 remote_mds_nodsh && skip "remote MDS with nodsh" && return
13122 if [ -z ${MDSSURVEY} ]; then
13123 skip_env "mds-survey not found" && return
13125 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.51) ] ||
13126 { skip "Need MDS version at least 2.2.51"; return; }
13128 if [ $($LCTL dl | grep -c osc) -eq 0 ]; then
13129 skip_env "Need to mount OST to test" && return
13132 [ $MDSCOUNT -ge 2 ] &&
13133 skip "skipping now for more than one MDT" && return
13134 local mds=$(facet_host $SINGLEMDS)
13135 local target=$(do_nodes $mds 'lctl dl' | \
13136 awk "{if (\$2 == \"UP\" && \$3 == \"mdt\") {print \$4}}")
13138 local cmd1="file_count=1000 thrhi=4"
13139 local cmd2="dir_count=2 layer=mdd stripe_count=1"
13140 local cmd3="rslt_loc=${TMP} targets=\"$mds:$target\" $MDSSURVEY"
13141 local cmd="$cmd1 $cmd2 $cmd3"
13143 rm -f ${TMP}/mds_survey*
13145 eval $cmd || error "mds-survey with stripe_count failed"
13146 cat ${TMP}/mds_survey*
13147 rm -f ${TMP}/mds_survey*
13149 run_test 225b "Metadata survey sanity with stripe_count = 1"
13151 mcreate_path2fid () {
13157 local path=$DIR/$tdir/$name
13162 $MCREATE --mode=$1 --major=$2 --minor=$3 $path ||
13163 error "cannot create $desc"
13165 fid=$($LFS path2fid $path | tr -d '[' | tr -d ']')
13167 [ $rc -ne 0 ] && error "cannot get fid of a $desc"
13169 fid_path=$($LFS fid2path $MOUNT $fid)
13171 [ $rc -ne 0 ] && error "cannot get path of $desc by $DIR $path $fid"
13173 [ "$path" == "$fid_path" ] ||
13174 error "fid2path returned $fid_path, expected $path"
13176 echo "pass with $path and $fid"
13181 mkdir -p $DIR/$tdir
13183 mcreate_path2fid 0010666 0 0 fifo "FIFO"
13184 mcreate_path2fid 0020666 1 3 null "character special file (null)"
13185 mcreate_path2fid 0020666 1 255 none "character special file (no device)"
13186 mcreate_path2fid 0040666 0 0 dir "directory"
13187 mcreate_path2fid 0060666 7 0 loop0 "block special file (loop)"
13188 mcreate_path2fid 0100666 0 0 file "regular file"
13189 mcreate_path2fid 0120666 0 0 link "symbolic link"
13190 mcreate_path2fid 0140666 0 0 sock "socket"
13192 run_test 226a "call path2fid and fid2path on files of all type"
13195 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
13199 mkdir -p $DIR/$tdir
13200 $LFS setdirstripe -i $MDTIDX $DIR/$tdir/remote_dir ||
13201 error "create remote directory failed"
13202 mcreate_path2fid 0010666 0 0 "remote_dir/fifo" "FIFO"
13203 mcreate_path2fid 0020666 1 3 "remote_dir/null" \
13204 "character special file (null)"
13205 mcreate_path2fid 0020666 1 255 "remote_dir/none" \
13206 "character special file (no device)"
13207 mcreate_path2fid 0040666 0 0 "remote_dir/dir" "directory"
13208 mcreate_path2fid 0060666 7 0 "remote_dir/loop0" \
13209 "block special file (loop)"
13210 mcreate_path2fid 0100666 0 0 "remote_dir/file" "regular file"
13211 mcreate_path2fid 0120666 0 0 "remote_dir/link" "symbolic link"
13212 mcreate_path2fid 0140666 0 0 "remote_dir/sock" "socket"
13214 run_test 226b "call path2fid and fid2path on files of all type under remote dir"
13216 # LU-1299 Executing or running ldd on a truncated executable does not
13217 # cause an out-of-memory condition.
13219 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13220 [ -z "$(which ldd)" ] && skip "should have ldd tool" && return
13221 dd if=$(which date) of=$MOUNT/date bs=1k count=1
13222 chmod +x $MOUNT/date
13224 $MOUNT/date > /dev/null
13225 ldd $MOUNT/date > /dev/null
13228 run_test 227 "running truncated executable does not cause OOM"
13230 # LU-1512 try to reuse idle OI blocks
13232 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13233 remote_mds_nodsh && skip "remote MDS with nodsh" && return
13234 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
13235 skip "ldiskfs only test" && return
13237 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
13238 local myDIR=$DIR/$tdir
13241 #define OBD_FAIL_SEQ_EXHAUST 0x1002
13242 $LCTL set_param fail_loc=0x80001002
13243 createmany -o $myDIR/t- 10000
13244 $LCTL set_param fail_loc=0
13245 # The guard is current the largest FID holder
13247 local SEQ=$($LFS path2fid $myDIR/guard | awk -F ':' '{print $1}' |
13249 local IDX=$(($SEQ % 64))
13251 do_facet $SINGLEMDS sync
13252 # Make sure journal flushed.
13254 local blk1=$(do_facet $SINGLEMDS \
13255 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
13256 grep Blockcount | awk '{print $4}')
13258 # Remove old files, some OI blocks will become idle.
13259 unlinkmany $myDIR/t- 10000
13260 # Create new files, idle OI blocks should be reused.
13261 createmany -o $myDIR/t- 2000
13262 do_facet $SINGLEMDS sync
13263 # Make sure journal flushed.
13265 local blk2=$(do_facet $SINGLEMDS \
13266 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
13267 grep Blockcount | awk '{print $4}')
13269 [ $blk1 == $blk2 ] || error "old blk1=$blk1, new blk2=$blk2, unmatched!"
13271 run_test 228a "try to reuse idle OI blocks"
13274 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13275 remote_mds_nodsh && skip "remote MDS with nodsh" && return
13276 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
13277 skip "ldiskfs only test" && return
13279 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
13280 local myDIR=$DIR/$tdir
13283 #define OBD_FAIL_SEQ_EXHAUST 0x1002
13284 $LCTL set_param fail_loc=0x80001002
13285 createmany -o $myDIR/t- 10000
13286 $LCTL set_param fail_loc=0
13287 # The guard is current the largest FID holder
13289 local SEQ=$($LFS path2fid $myDIR/guard | awk -F ':' '{print $1}' |
13291 local IDX=$(($SEQ % 64))
13293 do_facet $SINGLEMDS sync
13294 # Make sure journal flushed.
13296 local blk1=$(do_facet $SINGLEMDS \
13297 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
13298 grep Blockcount | awk '{print $4}')
13300 # Remove old files, some OI blocks will become idle.
13301 unlinkmany $myDIR/t- 10000
13304 stop $SINGLEMDS || error "Fail to stop MDT."
13306 start $SINGLEMDS $MDT_DEV $MDS_MOUNT_OPTS || error "Fail to start MDT."
13308 df $MOUNT || error "Fail to df."
13309 # Create new files, idle OI blocks should be reused.
13310 createmany -o $myDIR/t- 2000
13311 do_facet $SINGLEMDS sync
13312 # Make sure journal flushed.
13314 local blk2=$(do_facet $SINGLEMDS \
13315 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
13316 grep Blockcount | awk '{print $4}')
13318 [ $blk1 == $blk2 ] || error "old blk1=$blk1, new blk2=$blk2, unmatched!"
13320 run_test 228b "idle OI blocks can be reused after MDT restart"
13324 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13325 remote_mds_nodsh && skip "remote MDS with nodsh" && return
13326 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
13327 skip "ldiskfs only test" && return
13329 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
13330 local myDIR=$DIR/$tdir
13333 #define OBD_FAIL_SEQ_EXHAUST 0x1002
13334 $LCTL set_param fail_loc=0x80001002
13335 # 20000 files can guarantee there are index nodes in the OI file
13336 createmany -o $myDIR/t- 20000
13337 $LCTL set_param fail_loc=0
13338 # The guard is current the largest FID holder
13340 local SEQ=$($LFS path2fid $myDIR/guard | awk -F ':' '{print $1}' |
13342 local IDX=$(($SEQ % 64))
13344 do_facet $SINGLEMDS sync
13345 # Make sure journal flushed.
13347 local blk1=$(do_facet $SINGLEMDS \
13348 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
13349 grep Blockcount | awk '{print $4}')
13351 # Remove old files, some OI blocks will become idle.
13352 unlinkmany $myDIR/t- 20000
13354 # The OI file should become empty now
13356 # Create new files, idle OI blocks should be reused.
13357 createmany -o $myDIR/t- 2000
13358 do_facet $SINGLEMDS sync
13359 # Make sure journal flushed.
13361 local blk2=$(do_facet $SINGLEMDS \
13362 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
13363 grep Blockcount | awk '{print $4}')
13365 [ $blk1 == $blk2 ] || error "old blk1=$blk1, new blk2=$blk2, unmatched!"
13367 run_test 228c "NOT shrink the last entry in OI index node to recycle idle leaf"
13369 test_229() { # LU-2482, LU-3448
13370 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.53) ] &&
13371 skip "No HSM $(lustre_build_version $SINGLEMDS) MDS < 2.4.53" &&
13373 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13374 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs" && return
13378 # Create a file with a released layout and stripe count 2.
13379 $MULTIOP $DIR/$tfile H2c ||
13380 error "failed to create file with released layout"
13382 $GETSTRIPE -v $DIR/$tfile
13384 local pattern=$($GETSTRIPE -L $DIR/$tfile)
13385 [ X"$pattern" = X"80000001" ] || error "pattern error ($pattern)"
13387 local stripe_count=$($GETSTRIPE -c $DIR/$tfile) || error "getstripe"
13388 [ $stripe_count -eq 2 ] || error "stripe count not 2 ($stripe_count)"
13389 stat $DIR/$tfile || error "failed to stat released file"
13391 chown $RUNAS_ID $DIR/$tfile ||
13392 error "chown $RUNAS_ID $DIR/$tfile failed"
13394 chgrp $RUNAS_ID $DIR/$tfile ||
13395 error "chgrp $RUNAS_ID $DIR/$tfile failed"
13397 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
13398 rm $DIR/$tfile || error "failed to remove released file"
13400 run_test 229 "getstripe/stat/rm/attr changes work on released files"
13403 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13404 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
13407 test_mkdir $DIR/$tdir
13408 test_mkdir -i0 -c1 $DIR/$tdir/test_230_local
13409 local mdt_idx=$($GETSTRIPE -M $DIR/$tdir/test_230_local)
13410 [ $mdt_idx -ne 0 ] &&
13411 error "create local directory on wrong MDT $mdt_idx"
13413 $LFS mkdir -i $MDTIDX $DIR/$tdir/test_230 ||
13414 error "create remote directory failed"
13415 local mdt_idx=$($GETSTRIPE -M $DIR/$tdir/test_230)
13416 [ $mdt_idx -ne $MDTIDX ] &&
13417 error "create remote directory on wrong MDT $mdt_idx"
13419 createmany -o $DIR/$tdir/test_230/t- 10 ||
13420 error "create files on remote directory failed"
13421 mdt_idx=$($GETSTRIPE -M $DIR/$tdir/test_230/t-0)
13422 [ $mdt_idx -ne $MDTIDX ] && error "create files on wrong MDT $mdt_idx"
13423 rm -r $DIR/$tdir || error "unlink remote directory failed"
13425 run_test 230a "Create remote directory and files under the remote directory"
13428 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13429 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
13436 local migrate_dir=$DIR/$tdir/migrate_dir
13437 local other_dir=$DIR/$tdir/other_dir
13439 test_mkdir $DIR/$tdir
13440 test_mkdir -i0 -c1 $migrate_dir
13441 test_mkdir -i0 -c1 $other_dir
13442 for ((i=0; i<10; i++)); do
13443 mkdir -p $migrate_dir/dir_${i}
13444 createmany -o $migrate_dir/dir_${i}/f 10 ||
13445 error "create files under remote dir failed $i"
13448 cp /etc/passwd $migrate_dir/$tfile
13449 cp /etc/passwd $other_dir/$tfile
13450 chattr +SAD $migrate_dir
13451 chattr +SAD $migrate_dir/$tfile
13453 local old_dir_flag=$(lsattr -a $migrate_dir | awk '/\/\.$/ {print $1}')
13454 local old_file_flag=$(lsattr $migrate_dir/$tfile | awk '{print $1}')
13455 local old_dir_mode=$(stat -c%f $migrate_dir)
13456 local old_file_mode=$(stat -c%f $migrate_dir/$tfile)
13458 mkdir -p $migrate_dir/dir_default_stripe2
13459 $SETSTRIPE -c 2 $migrate_dir/dir_default_stripe2
13460 $SETSTRIPE -c 2 $migrate_dir/${tfile}_stripe2
13462 mkdir -p $other_dir
13463 ln $migrate_dir/$tfile $other_dir/luna
13464 ln $migrate_dir/$tfile $migrate_dir/sofia
13465 ln $other_dir/$tfile $migrate_dir/david
13466 ln -s $migrate_dir/$tfile $other_dir/zachary
13467 ln -s $migrate_dir/$tfile $migrate_dir/${tfile}_ln
13468 ln -s $other_dir/$tfile $migrate_dir/${tfile}_ln_other
13470 $LFS migrate -m $MDTIDX $migrate_dir ||
13471 error "fails on migrating remote dir to MDT1"
13473 echo "migratate to MDT1, then checking.."
13474 for ((i = 0; i < 10; i++)); do
13475 for file in $(find $migrate_dir/dir_${i}); do
13476 mdt_index=$($LFS getstripe -M $file)
13477 [ $mdt_index == $MDTIDX ] ||
13478 error "$file is not on MDT${MDTIDX}"
13482 # the multiple link file should still in MDT0
13483 mdt_index=$($LFS getstripe -M $migrate_dir/$tfile)
13484 [ $mdt_index == 0 ] ||
13485 error "$file is not on MDT${MDTIDX}"
13487 local new_dir_flag=$(lsattr -a $migrate_dir | awk '/\/\.$/ {print $1}')
13488 [ "$old_dir_flag" = "$new_dir_flag" ] ||
13489 error " expect $old_dir_flag get $new_dir_flag"
13491 local new_file_flag=$(lsattr $migrate_dir/$tfile | awk '{print $1}')
13492 [ "$old_file_flag" = "$new_file_flag" ] ||
13493 error " expect $old_file_flag get $new_file_flag"
13495 local new_dir_mode=$(stat -c%f $migrate_dir)
13496 [ "$old_dir_mode" = "$new_dir_mode" ] ||
13497 error "expect mode $old_dir_mode get $new_dir_mode"
13499 local new_file_mode=$(stat -c%f $migrate_dir/$tfile)
13500 [ "$old_file_mode" = "$new_file_mode" ] ||
13501 error "expect mode $old_file_mode get $new_file_mode"
13503 diff /etc/passwd $migrate_dir/$tfile ||
13504 error "$tfile different after migration"
13506 diff /etc/passwd $other_dir/luna ||
13507 error "luna different after migration"
13509 diff /etc/passwd $migrate_dir/sofia ||
13510 error "sofia different after migration"
13512 diff /etc/passwd $migrate_dir/david ||
13513 error "david different after migration"
13515 diff /etc/passwd $other_dir/zachary ||
13516 error "zachary different after migration"
13518 diff /etc/passwd $migrate_dir/${tfile}_ln ||
13519 error "${tfile}_ln different after migration"
13521 diff /etc/passwd $migrate_dir/${tfile}_ln_other ||
13522 error "${tfile}_ln_other different after migration"
13524 stripe_count=$($LFS getstripe -c $migrate_dir/dir_default_stripe2)
13525 [ $stripe_count = 2 ] ||
13526 error "dir strpe_count $d != 2 after migration."
13528 stripe_count=$($LFS getstripe -c $migrate_dir/${tfile}_stripe2)
13529 [ $stripe_count = 2 ] ||
13530 error "file strpe_count $d != 2 after migration."
13532 #migrate back to MDT0
13535 $LFS migrate -m $MDTIDX $migrate_dir ||
13536 error "fails on migrating remote dir to MDT0"
13538 echo "migrate back to MDT0, checking.."
13539 for file in $(find $migrate_dir); do
13540 mdt_index=$($LFS getstripe -M $file)
13541 [ $mdt_index == $MDTIDX ] ||
13542 error "$file is not on MDT${MDTIDX}"
13545 local new_dir_flag=$(lsattr -a $migrate_dir | awk '/\/\.$/ {print $1}')
13546 [ "$old_dir_flag" = "$new_dir_flag" ] ||
13547 error " expect $old_dir_flag get $new_dir_flag"
13549 local new_file_flag=$(lsattr $migrate_dir/$tfile | awk '{print $1}')
13550 [ "$old_file_flag" = "$new_file_flag" ] ||
13551 error " expect $old_file_flag get $new_file_flag"
13553 local new_dir_mode=$(stat -c%f $migrate_dir)
13554 [ "$old_dir_mode" = "$new_dir_mode" ] ||
13555 error "expect mode $old_dir_mode get $new_dir_mode"
13557 local new_file_mode=$(stat -c%f $migrate_dir/$tfile)
13558 [ "$old_file_mode" = "$new_file_mode" ] ||
13559 error "expect mode $old_file_mode get $new_file_mode"
13561 diff /etc/passwd ${migrate_dir}/$tfile ||
13562 error "$tfile different after migration"
13564 diff /etc/passwd ${other_dir}/luna ||
13565 error "luna different after migration"
13567 diff /etc/passwd ${migrate_dir}/sofia ||
13568 error "sofia different after migration"
13570 diff /etc/passwd ${other_dir}/zachary ||
13571 error "zachary different after migration"
13573 diff /etc/passwd $migrate_dir/${tfile}_ln ||
13574 error "${tfile}_ln different after migration"
13576 diff /etc/passwd $migrate_dir/${tfile}_ln_other ||
13577 error "${tfile}_ln_other different after migration"
13579 stripe_count=$($LFS getstripe -c ${migrate_dir}/dir_default_stripe2)
13580 [ $stripe_count = 2 ] ||
13581 error "dir strpe_count $d != 2 after migration."
13583 stripe_count=$($LFS getstripe -c ${migrate_dir}/${tfile}_stripe2)
13584 [ $stripe_count = 2 ] ||
13585 error "file strpe_count $d != 2 after migration."
13587 rm -rf $DIR/$tdir || error "rm dir failed after migration"
13589 run_test 230b "migrate directory"
13592 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13593 remote_mds_nodsh && skip "remote MDS with nodsh" && return
13594 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
13598 local migrate_dir=$DIR/$tdir/migrate_dir
13600 #If migrating directory fails in the middle, all entries of
13601 #the directory is still accessiable.
13602 test_mkdir $DIR/$tdir
13603 test_mkdir -i0 -c1 $migrate_dir
13605 createmany -o $migrate_dir/f 10 ||
13606 error "create files under ${migrate_dir} failed"
13608 #failed after migrating 5 entries
13609 #OBD_FAIL_MIGRATE_ENTRIES 0x1801
13610 do_facet mds1 lctl set_param fail_loc=0x20001801
13611 do_facet mds1 lctl set_param fail_val=5
13612 local t=$(ls $migrate_dir | wc -l)
13613 $LFS migrate --mdt-index $MDTIDX $migrate_dir &&
13614 error "migrate should fail after 5 entries"
13616 mkdir $migrate_dir/dir &&
13617 error "mkdir succeeds under migrating directory"
13618 touch $migrate_dir/file &&
13619 error "touch file succeeds under migrating directory"
13621 local u=$(ls $migrate_dir | wc -l)
13622 [ "$u" == "$t" ] || error "$u != $t during migration"
13624 for file in $(find $migrate_dir); do
13625 stat $file || error "stat $file failed"
13628 do_facet mds1 lctl set_param fail_loc=0
13629 do_facet mds1 lctl set_param fail_val=0
13631 $LFS migrate -m $MDTIDX $migrate_dir ||
13632 error "migrate open files should failed with open files"
13634 echo "Finish migration, then checking.."
13635 for file in $(find $migrate_dir); do
13636 mdt_index=$($LFS getstripe -M $file)
13637 [ $mdt_index == $MDTIDX ] ||
13638 error "$file is not on MDT${MDTIDX}"
13641 rm -rf $DIR/$tdir || error "rm dir failed after migration"
13643 run_test 230c "check directory accessiblity if migration is failed"
13646 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13647 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
13650 local migrate_dir=$DIR/$tdir/migrate_dir
13654 test_mkdir $DIR/$tdir
13655 test_mkdir -i0 -c1 $migrate_dir
13657 for ((i=0; i<100; i++)); do
13658 test_mkdir -i0 -c1 $migrate_dir/dir_${i}
13659 createmany -o $migrate_dir/dir_${i}/f 100 ||
13660 error "create files under remote dir failed $i"
13663 $LFS migrate -m $MDTIDX $migrate_dir ||
13664 error "migrate remote dir error"
13666 echo "Finish migration, then checking.."
13667 for file in $(find $migrate_dir); do
13668 mdt_index=$($LFS getstripe -M $file)
13669 [ $mdt_index == $MDTIDX ] ||
13670 error "$file is not on MDT${MDTIDX}"
13673 rm -rf $DIR/$tdir || error "rm dir failed after migration"
13675 run_test 230d "check migrate big directory"
13678 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13679 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
13685 mkdir -p $DIR/$tdir
13686 mkdir $DIR/$tdir/migrate_dir
13687 mkdir $DIR/$tdir/other_dir
13688 touch $DIR/$tdir/migrate_dir/a
13689 ln $DIR/$tdir/migrate_dir/a $DIR/$tdir/other_dir/b
13690 ls $DIR/$tdir/other_dir
13692 $LFS migrate -m 1 $DIR/$tdir/migrate_dir ||
13693 error "migrate dir fails"
13695 mdt_index=$($LFS getstripe -M $DIR/$tdir/migrate_dir)
13696 [ $mdt_index == 1 ] || error "migrate_dir is not on MDT1"
13698 mdt_index=$($LFS getstripe -M $DIR/$tdir/migrate_dir/a)
13699 [ $mdt_index == 0 ] || error "a is not on MDT0"
13701 $LFS migrate -m 1 $DIR/$tdir/other_dir ||
13702 error "migrate dir fails"
13704 mdt_index=$($LFS getstripe -M $DIR/$tdir/other_dir)
13705 [ $mdt_index == 1 ] || error "other_dir is not on MDT1"
13707 mdt_index=$($LFS getstripe -M $DIR/$tdir/migrate_dir/a)
13708 [ $mdt_index == 1 ] || error "a is not on MDT1"
13710 mdt_index=$($LFS getstripe -M $DIR/$tdir/other_dir/b)
13711 [ $mdt_index == 1 ] || error "b is not on MDT1"
13713 a_fid=$($LFS path2fid $DIR/$tdir/migrate_dir/a)
13714 b_fid=$($LFS path2fid $DIR/$tdir/other_dir/b)
13716 [ "$a_fid" = "$b_fid" ] || error "different fid after migration"
13718 rm -rf $DIR/$tdir || error "rm dir failed after migration"
13720 run_test 230e "migrate mulitple local link files"
13723 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13724 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
13728 mkdir -p $DIR/$tdir
13729 mkdir $DIR/$tdir/migrate_dir
13730 $LFS mkdir -i1 $DIR/$tdir/other_dir
13731 touch $DIR/$tdir/migrate_dir/a
13732 ln $DIR/$tdir/migrate_dir/a $DIR/$tdir/other_dir/ln1
13733 ln $DIR/$tdir/migrate_dir/a $DIR/$tdir/other_dir/ln2
13734 ls $DIR/$tdir/other_dir
13736 # a should be migrated to MDT1, since no other links on MDT0
13737 $LFS migrate -m 1 $DIR/$tdir/migrate_dir ||
13738 error "#1 migrate dir fails"
13739 mdt_index=$($LFS getstripe -M $DIR/$tdir/migrate_dir)
13740 [ $mdt_index == 1 ] || error "migrate_dir is not on MDT1"
13741 mdt_index=$($LFS getstripe -M $DIR/$tdir/migrate_dir/a)
13742 [ $mdt_index == 1 ] || error "a is not on MDT1"
13744 # a should stay on MDT1, because it is a mulitple link file
13745 $LFS migrate -m 0 $DIR/$tdir/migrate_dir ||
13746 error "#2 migrate dir fails"
13747 mdt_index=$($LFS getstripe -M $DIR/$tdir/migrate_dir/a)
13748 [ $mdt_index == 1 ] || error "a is not on MDT1"
13750 $LFS migrate -m 1 $DIR/$tdir/migrate_dir ||
13751 error "#3 migrate dir fails"
13753 a_fid=$($LFS path2fid $DIR/$tdir/migrate_dir/a)
13754 ln_fid=$($LFS path2fid $DIR/$tdir/other_dir/ln1)
13755 [ "$a_fid" = "$ln_fid" ] || error "different fid after migrate to MDT1"
13757 rm -rf $DIR/$tdir/other_dir/ln1 || error "unlink ln1 fails"
13758 rm -rf $DIR/$tdir/other_dir/ln2 || error "unlink ln2 fails"
13760 # a should be migrated to MDT0, since no other links on MDT1
13761 $LFS migrate -m 0 $DIR/$tdir/migrate_dir ||
13762 error "#4 migrate dir fails"
13763 mdt_index=$($LFS getstripe -M $DIR/$tdir/migrate_dir/a)
13764 [ $mdt_index == 0 ] || error "a is not on MDT0"
13766 rm -rf $DIR/$tdir || error "rm dir failed after migration"
13768 run_test 230f "migrate mulitple remote link files"
13771 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13772 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
13774 mkdir -p $DIR/$tdir/migrate_dir
13776 $LFS migrate -m 1000 $DIR/$tdir/migrate_dir &&
13777 error "migrating dir to non-exist MDT succeeds"
13780 run_test 230g "migrate dir to non-exist MDT"
13783 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13784 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
13785 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.64) ] &&
13786 skip "Need MDS version at least 2.7.64" && return
13789 mkdir -p $DIR/$tdir/migrate_dir
13791 $LFS migrate -m1 $DIR &&
13792 error "migrating mountpoint1 should fail"
13794 $LFS migrate -m1 $DIR/$tdir/.. &&
13795 error "migrating mountpoint2 should fail"
13797 $LFS migrate -m1 $DIR/$tdir/migrate_dir/.. ||
13798 error "migrating $tdir fail"
13800 mdt_index=$($LFS getstripe -M $DIR/$tdir)
13801 [ $mdt_index == 1 ] || error "$mdt_index != 1 after migration"
13803 mdt_index=$($LFS getstripe -M $DIR/$tdir/migrate_dir)
13804 [ $mdt_index == 1 ] || error "$mdt_index != 1 after migration"
13807 run_test 230h "migrate .. and root"
13810 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13811 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
13813 mkdir -p $DIR/$tdir/migrate_dir
13815 $LFS migrate -m 1 $DIR/$tdir/migrate_dir/ ||
13816 error "migration fails with a tailing slash"
13818 $LFS migrate -m 0 $DIR/$tdir/migrate_dir// ||
13819 error "migration fails with two tailing slashes"
13821 run_test 230i "lfs migrate -m tolerates trailing slashes"
13825 # For simplicity this test assumes that max_pages_per_rpc
13826 # is the same across all OSCs
13827 local max_pages=$($LCTL get_param -n osc.*.max_pages_per_rpc | head -n1)
13828 local bulk_size=$((max_pages * 4096))
13829 local brw_size=$(do_facet ost1 $LCTL get_param -n obdfilter.*.brw_size |
13832 mkdir -p $DIR/$tdir
13833 $LFS setstripe -S ${brw_size}M $DIR/$tdir ||
13834 error "failed to set stripe with -S ${brw_size}M option"
13836 # clear the OSC stats
13837 $LCTL set_param osc.*.stats=0 &>/dev/null
13840 # Client writes $bulk_size - there must be 1 rpc for $max_pages.
13841 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=$bulk_size count=1 \
13842 oflag=direct &>/dev/null || error "dd failed"
13844 sync; sleep 1; sync # just to be safe
13845 local nrpcs=$($LCTL get_param osc.*.stats |awk '/ost_write/ {print $2}')
13846 if [ x$nrpcs != "x1" ]; then
13847 $LCTL get_param osc.*.stats
13848 error "found $nrpcs ost_write RPCs, not 1 as expected"
13852 # Drop the OSC cache, otherwise we will read from it
13853 cancel_lru_locks osc
13855 # clear the OSC stats
13856 $LCTL set_param osc.*.stats=0 &>/dev/null
13858 # Client reads $bulk_size.
13859 dd if=$DIR/$tdir/$tfile of=/dev/null bs=$bulk_size count=1 \
13860 iflag=direct &>/dev/null || error "dd failed"
13862 nrpcs=$($LCTL get_param osc.*.stats | awk '/ost_read/ { print $2 }')
13863 if [ x$nrpcs != "x1" ]; then
13864 $LCTL get_param osc.*.stats
13865 error "found $nrpcs ost_read RPCs, not 1 as expected"
13868 run_test 231a "checking that reading/writing of BRW RPC size results in one RPC"
13871 mkdir -p $DIR/$tdir
13873 for i in {0..1023}; do
13874 dd if=/dev/zero of=$DIR/$tdir/$tfile conv=notrunc \
13875 seek=$((2 * i)) bs=4096 count=1 &>/dev/null ||
13876 error "dd of=$DIR/$tdir/$tfile seek=$((2 * i)) failed"
13880 run_test 231b "must not assert on fully utilized OST request buffer"
13883 mkdir -p $DIR/$tdir
13884 #define OBD_FAIL_LDLM_OST_LVB 0x31c
13885 $LCTL set_param fail_loc=0x31c
13887 # ignore dd failure
13888 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=1 || true
13890 $LCTL set_param fail_loc=0
13891 umount_client $MOUNT || error "umount failed"
13892 mount_client $MOUNT || error "mount failed"
13894 run_test 232 "failed lock should not block umount"
13897 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.3.64) ] ||
13898 { skip "Need MDS version at least 2.3.64"; return; }
13899 [ -n "$FILESET" ] && skip "SKIP due to FILESET set" && return
13901 local fid=$($LFS path2fid $MOUNT)
13902 stat $MOUNT/.lustre/fid/$fid > /dev/null ||
13903 error "cannot access $MOUNT using its FID '$fid'"
13905 run_test 233a "checking that OBF of the FS root succeeds"
13908 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.5.90) ] ||
13909 { skip "Need MDS version at least 2.5.90"; return; }
13910 [ -n "$FILESET" ] && skip "SKIP due to FILESET set" && return
13912 local fid=$($LFS path2fid $MOUNT/.lustre)
13913 stat $MOUNT/.lustre/fid/$fid > /dev/null ||
13914 error "cannot access $MOUNT/.lustre using its FID '$fid'"
13916 fid=$($LFS path2fid $MOUNT/.lustre/fid)
13917 stat $MOUNT/.lustre/fid/$fid > /dev/null ||
13918 error "cannot access $MOUNT/.lustre/fid using its FID '$fid'"
13920 run_test 233b "checking that OBF of the FS .lustre succeeds"
13923 local p="$TMP/sanityN-$TESTNAME.parameters"
13924 save_lustre_params client "llite.*.xattr_cache" > $p
13925 lctl set_param llite.*.xattr_cache 1 ||
13926 { skip "xattr cache is not supported"; return 0; }
13928 mkdir -p $DIR/$tdir || error "mkdir failed"
13929 touch $DIR/$tdir/$tfile || error "touch failed"
13930 # OBD_FAIL_LLITE_XATTR_ENOMEM
13931 $LCTL set_param fail_loc=0x1405
13932 # output of the form: attr 2 4 44 3 fc13 x86_64
13933 V=($(IFS=".-" rpm -q attr))
13934 if [[ ${V[1]} > 2 || ${V[2]} > 4 || ${V[3]} > 44 ||
13935 ${V[1]} = 2 && ${V[2]} = 4 && ${V[3]} = 44 && ${V[4]} > 6 ]]; then
13936 # attr pre-2.4.44-7 had a bug with rc
13937 # LU-3703 - SLES 11 and FC13 clients have older attr
13938 getfattr -n user.attr $DIR/$tdir/$tfile &&
13939 error "getfattr should have failed with ENOMEM"
13941 skip "LU-3703: attr version $(getfattr --version) too old"
13943 $LCTL set_param fail_loc=0x0
13946 restore_lustre_params < $p
13949 run_test 234 "xattr cache should not crash on ENOMEM"
13952 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.52) ] &&
13953 skip "Need MDS version at least 2.4.52" && return
13954 flock_deadlock $DIR/$tfile
13959 124) error "process hangs on a deadlock"
13961 *) error "error executing flock_deadlock $DIR/$tfile"
13965 run_test 235 "LU-1715: flock deadlock detection does not work properly"
13969 check_swap_layouts_support && return 0
13970 test_mkdir -p -c1 $DIR/$tdir || error "mkdir $tdir failed"
13972 local ref1=/etc/passwd
13973 local ref2=/etc/group
13974 local file1=$DIR/$tdir/f1
13975 local file2=$DIR/$tdir/f2
13977 $SETSTRIPE -c 1 $file1 || error "cannot setstripe on '$file1': rc = $?"
13978 cp $ref1 $file1 || error "cp $ref1 $file1 failed: rc = $?"
13979 $SETSTRIPE -c 2 $file2 || error "cannot setstripe on '$file2': rc = $?"
13980 cp $ref2 $file2 || error "cp $ref2 $file2 failed: rc = $?"
13981 local fd=$(free_fd)
13982 local cmd="exec $fd<>$file2"
13985 $LFS swap_layouts $file1 /proc/self/fd/${fd} ||
13986 error "cannot swap layouts of '$file1' and /proc/self/fd/${fd}"
13989 cmp $ref2 $file1 || error "content compare failed ($ref2 != $file1)"
13994 run_test 236 "Layout swap on open unlinked file"
13996 # test to verify file handle related system calls
13997 # (name_to_handle_at/open_by_handle_at)
13998 # The new system calls are supported in glibc >= 2.14.
14001 echo "Test file_handle syscalls" > $DIR/$tfile ||
14002 error "write failed"
14003 check_fhandle_syscalls $DIR/$tfile ||
14004 error "check_fhandle_syscalls failed"
14006 run_test 237 "Verify name_to_handle_at/open_by_handle_at syscalls"
14008 # LU-4659 linkea consistency
14010 local server_version=$(lustre_version_code $SINGLEMDS)
14012 [[ $server_version -gt $(version_code 2.5.57) ]] ||
14013 [[ $server_version -gt $(version_code 2.5.1) &&
14014 $server_version -lt $(version_code 2.5.50) ]] ||
14015 { skip "Need MDS version at least 2.5.58 or 2.5.2+"; return; }
14018 ln $DIR/$tfile $DIR/$tfile.lnk
14019 touch $DIR/$tfile.new
14020 mv $DIR/$tfile.new $DIR/$tfile
14021 local fid1=$($LFS path2fid $DIR/$tfile)
14022 local fid2=$($LFS path2fid $DIR/$tfile.lnk)
14023 local path1=$($LFS fid2path $FSNAME "$fid1")
14024 [ $tfile == $path1 ] || error "linkea inconsistent: $tfile $fid1 $path1"
14025 local path2=$($LFS fid2path $FSNAME "$fid2")
14026 [ $tfile.lnk == $path2 ] ||
14027 error "linkea inconsistent: $tfile.lnk $fid2 $path2!"
14030 run_test 238 "Verify linkea consistency"
14033 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.5.60) ] &&
14034 skip "Need MDS version at least 2.5.60" && return
14035 local list=$(comma_list $(mdts_nodes))
14037 mkdir -p $DIR/$tdir
14038 createmany -o $DIR/$tdir/f- 5000
14039 unlinkmany $DIR/$tdir/f- 5000
14040 do_nodes $list "lctl set_param -n osp*.*.sync_changes 1"
14041 changes=$(do_nodes $list "lctl get_param -n osc.*MDT*.sync_changes \
14042 osc.*MDT*.sync_in_flight" | calc_sum)
14043 [ "$changes" -eq 0 ] || error "$changes not synced"
14045 run_test 239 "osp_sync test"
14047 test_239a() { #LU-5297
14048 remote_mds_nodsh && skip "remote MDS with nodsh" && return
14050 #define OBD_FAIL_OSP_CHECK_INVALID_REC 0x2100
14051 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x2100
14052 chgrp $RUNAS_GID $DIR/$tfile
14053 wait_delete_completed
14055 run_test 239a "process invalid osp sync record correctly"
14057 test_239b() { #LU-5297
14058 remote_mds_nodsh && skip "remote MDS with nodsh" && return
14060 #define OBD_FAIL_OSP_CHECK_ENOMEM 0x2101
14061 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x2101
14062 chgrp $RUNAS_GID $DIR/$tfile1
14063 wait_delete_completed
14064 do_facet $SINGLEMDS $LCTL set_param fail_loc=0
14066 chgrp $RUNAS_GID $DIR/$tfile2
14067 wait_delete_completed
14069 run_test 239b "process osp sync record with ENOMEM error correctly"
14072 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
14073 remote_mds_nodsh && skip "remote MDS with nodsh" && return
14075 mkdir -p $DIR/$tdir
14077 $LFS mkdir -i 0 $DIR/$tdir/d0 ||
14078 error "failed to mkdir $DIR/$tdir/d0 on MDT0"
14079 $LFS mkdir -i 1 $DIR/$tdir/d0/d1 ||
14080 error "failed to mkdir $DIR/$tdir/d0/d1 on MDT1"
14082 umount_client $MOUNT || error "umount failed"
14083 #define OBD_FAIL_TGT_DELAY_CONDITIONAL 0x713
14084 do_facet mds2 lctl set_param fail_loc=0x713 fail_val=1
14085 mount_client $MOUNT || error "failed to mount client"
14087 echo "stat $DIR/$tdir/d0/d1, should not fail/ASSERT"
14088 stat $DIR/$tdir/d0/d1 || error "fail to stat $DIR/$tdir/d0/d1"
14090 run_test 240 "race between ldlm enqueue and the connection RPC (no ASSERT)"
14093 for LOOP in $(seq $1); do
14094 dd if=$DIR/$tfile of=/dev/null bs=40960 count=1 2>/dev/null
14095 cancel_lru_locks osc || true
14100 for LOOP in $(seq $1); do
14101 dd if=$DIR/$tfile of=/dev/null bs=40960 count=1 \
14102 iflag=direct 2>/dev/null
14106 test_241a() { # was test_241
14107 dd if=/dev/zero of=$DIR/$tfile count=1 bs=40960
14109 cancel_lru_locks osc
14110 test_241_bio 1000 &
14115 run_test 241a "bio vs dio"
14118 dd if=/dev/zero of=$DIR/$tfile count=1 bs=40960
14120 test_241_dio 1000 &
14125 run_test 241b "dio vs dio"
14128 remote_mds_nodsh && skip "remote MDS with nodsh" && return
14129 mkdir -p $DIR/$tdir
14130 touch $DIR/$tdir/$tfile
14132 #define OBD_FAIL_MDS_READPAGE_PACK 0x105
14133 do_facet mds1 lctl set_param fail_loc=0x105
14134 /bin/ls $DIR/$tdir && error "ls $DIR/$tdir should fail"
14136 do_facet mds1 lctl set_param fail_loc=0
14137 /bin/ls $DIR/$tdir || error "ls $DIR/$tdir failed"
14139 run_test 242 "mdt_readpage failure should not cause directory unreadable"
14143 test_mkdir -p $DIR/$tdir
14144 group_lock_test -d $DIR/$tdir || error "A group lock test failed"
14146 run_test 243 "various group lock tests"
14150 test_mkdir -p $DIR/$tdir
14151 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=35
14152 sendfile_grouplock $DIR/$tdir/$tfile || \
14153 error "sendfile+grouplock failed"
14156 run_test 244 "sendfile with group lock tests"
14159 local flagname="multi_mod_rpcs"
14160 local connect_data_name="max_mod_rpcs"
14163 # check if multiple modify RPCs flag is set
14164 out=$($LCTL get_param mdc.$FSNAME-MDT0000-*.import |
14165 grep "connect_flags:")
14168 echo "$out" | grep -qw $flagname
14169 if [ $? -ne 0 ]; then
14170 echo "connect flag $flagname is not set"
14174 # check if multiple modify RPCs data is set
14175 out=$($LCTL get_param mdc.$FSNAME-MDT0000-*.import)
14178 echo "$out" | grep -qw $connect_data_name ||
14179 error "import should have connect data $connect_data_name"
14181 run_test 245 "check mdc connection flag/data: multiple modify RPCs"
14183 test_246() { # LU-7371
14184 remote_ost_nodsh && skip "remote OST with nodsh" && return
14185 [ $(lustre_version_code ost1) -lt $(version_code 2.7.62) ] &&
14186 skip "Need OST version >= 2.7.62" && return 0
14187 do_facet ost1 $LCTL set_param fail_val=4095
14188 #define OBD_FAIL_OST_READ_SIZE 0x234
14189 do_facet ost1 $LCTL set_param fail_loc=0x234
14190 $LFS setstripe $DIR/$tfile -i 0 -c 1
14191 dd if=/dev/zero of=$DIR/$tfile bs=4095 count=1 > /dev/null 2>&1
14192 cancel_lru_locks $FSNAME-OST0000
14193 dd if=$DIR/$tfile of=/dev/null bs=1048576 || error "Read failed"
14195 run_test 246 "Read file of size 4095 should return right length"
14198 lctl get_param -n mdc.$FSNAME-MDT0000*.import |
14200 { skip "Fileset feature is not supported"; return; }
14202 local submount=${MOUNT}_$tdir
14205 mkdir -p $submount || error "mkdir $submount failed"
14206 FILESET="$FILESET/$tdir" mount_client $submount ||
14207 error "mount $submount failed"
14208 echo foo > $submount/$tfile || error "write $submount/$tfile failed"
14209 [ $(cat $MOUNT/$tdir/$tfile) = "foo" ] ||
14210 error "read $MOUNT/$tdir/$tfile failed"
14211 umount_client $submount || error "umount $submount failed"
14214 run_test 247a "mount subdir as fileset"
14217 lctl get_param -n mdc.$FSNAME-MDT0000*.import | grep -q subtree ||
14218 { skip "Fileset feature is not supported"; return; }
14220 local submount=${MOUNT}_$tdir
14222 rm -rf $MOUNT/$tdir
14223 mkdir -p $submount || error "mkdir $submount failed"
14225 FILESET="$FILESET/$tdir" mount_client $submount &&
14226 error "mount $submount should fail"
14229 run_test 247b "mount subdir that dose not exist"
14232 lctl get_param -n mdc.$FSNAME-MDT0000*.import | grep -q subtree ||
14233 { skip "Fileset feature is not supported"; return; }
14235 local submount=${MOUNT}_$tdir
14237 mkdir -p $MOUNT/$tdir/dir1
14238 mkdir -p $submount || error "mkdir $submount failed"
14239 FILESET="$FILESET/$tdir" mount_client $submount ||
14240 error "mount $submount failed"
14241 local fid=$($LFS path2fid $MOUNT/)
14242 $LFS fid2path $submount $fid && error "fid2path should fail"
14243 umount_client $submount || error "umount $submount failed"
14246 run_test 247c "running fid2path outside root"
14249 lctl get_param -n mdc.$FSNAME-MDT0000*.import | grep -q subtree ||
14250 { skip "Fileset feature is not supported"; return; }
14252 local submount=${MOUNT}_$tdir
14254 mkdir -p $MOUNT/$tdir/dir1
14255 mkdir -p $submount || error "mkdir $submount failed"
14256 FILESET="$FILESET/$tdir" mount_client $submount ||
14257 error "mount $submount failed"
14258 local fid=$($LFS path2fid $submount/dir1)
14259 $LFS fid2path $submount $fid || error "fid2path should succeed"
14260 umount_client $submount || error "umount $submount failed"
14263 run_test 247d "running fid2path inside root"
14267 lctl get_param -n mdc.$FSNAME-MDT0000*.import |
14269 { skip "Fileset feature is not supported"; return; }
14271 local submount=${MOUNT}_$tdir
14274 mkdir -p $submount || error "mkdir $submount failed"
14275 FILESET="$FILESET/.." mount_client $submount &&
14276 error "mount $submount should fail"
14279 run_test 247e "mount .. as fileset"
14282 local fast_read_sav=$($LCTL get_param -n llite.*.fast_read 2>/dev/null)
14283 [ -z "$fast_read_sav" ] && skip "no fast read support" && return
14285 # create a large file for fast read verification
14286 dd if=/dev/zero of=$DIR/$tfile bs=1M count=128 > /dev/null 2>&1
14288 # make sure the file is created correctly
14289 $CHECKSTAT -s $((128*1024*1024)) $DIR/$tfile ||
14290 { rm -f $DIR/$tfile; skip "file creation error" && return; }
14292 echo "Test 1: verify that fast read is 4 times faster on cache read"
14294 # small read with fast read enabled
14295 $LCTL set_param -n llite.*.fast_read=1
14296 local t_fast=$(dd if=$DIR/$tfile of=/dev/null bs=4k 2>&1 |
14297 awk '/copied/ { print $6 }')
14299 # small read with fast read disabled
14300 $LCTL set_param -n llite.*.fast_read=0
14301 local t_slow=$(dd if=$DIR/$tfile of=/dev/null bs=4k 2>&1 |
14302 awk '/copied/ { print $6 }')
14304 # verify that fast read is 4 times faster for cache read
14305 [ $(bc <<< "4 * $t_fast < $t_slow") -eq 1 ] ||
14306 error_not_in_vm "fast read was not 4 times faster: " \
14307 "$t_fast vs $t_slow"
14309 echo "Test 2: verify the performance between big and small read"
14310 $LCTL set_param -n llite.*.fast_read=1
14312 # 1k non-cache read
14313 cancel_lru_locks osc
14314 local t_1k=$(dd if=$DIR/$tfile of=/dev/null bs=1k 2>&1 |
14315 awk '/copied/ { print $6 }')
14317 # 1M non-cache read
14318 cancel_lru_locks osc
14319 local t_1m=$(dd if=$DIR/$tfile of=/dev/null bs=1k 2>&1 |
14320 awk '/copied/ { print $6 }')
14322 # verify that big IO is not 4 times faster than small IO
14323 [ $(bc <<< "4 * $t_1k >= $t_1m") -eq 1 ] ||
14324 error_not_in_vm "bigger IO is way too fast: $t_1k vs $t_1m"
14326 $LCTL set_param -n llite.*.fast_read=$fast_read_sav
14329 run_test 248 "fast read verification"
14331 test_249() { # LU-7890
14333 $SETSTRIPE -c 1 $DIR/$tfile
14335 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.8.53) ] &&
14336 skip "Need at least version 2.8.54"
14338 # Offset 2T == 4k * 512M
14339 dd if=/dev/zero of=$DIR/$tfile bs=4k count=1 seek=512M ||
14340 error "dd to 2T offset failed"
14342 run_test 249 "Write above 2T file size"
14345 [ "$(facet_fstype ost$(($($GETSTRIPE -i $DIR/$tfile) + 1)))" = "zfs" ] \
14346 && skip "no 16TB file size limit on ZFS" && return
14348 $SETSTRIPE -c 1 $DIR/$tfile
14349 # ldiskfs extent file size limit is (16TB - 4KB - 1) bytes
14350 local size=$((16 * 1024 * 1024 * 1024 * 1024 - 4096 - 1))
14351 $TRUNCATE $DIR/$tfile $size || error "truncate $tfile to $size failed"
14352 dd if=/dev/zero of=$DIR/$tfile bs=10 count=1 oflag=append \
14353 conv=notrunc,fsync && error "append succeeded"
14356 run_test 250 "Write above 16T limit"
14359 $SETSTRIPE -c -1 -S 1048576 $DIR/$tfile
14361 #define OBD_FAIL_LLITE_LOST_LAYOUT 0x1407
14362 #Skip once - writing the first stripe will succeed
14363 $LCTL set_param fail_loc=0xa0001407 fail_val=1
14364 $MULTIOP $DIR/$tfile o:O_RDWR:w2097152c 2>&1 | grep -q "short write" &&
14365 error "short write happened"
14367 $LCTL set_param fail_loc=0xa0001407 fail_val=1
14368 $MULTIOP $DIR/$tfile or2097152c 2>&1 | grep -q "short read" &&
14369 error "short read happened"
14373 run_test 251 "Handling short read and write correctly"
14383 remote_mds_nodsh && skip "remote MDS with nodsh" && return
14384 remote_ost_nodsh && skip "remote OST with nodsh" && return
14385 if [ "$(facet_fstype ost1)" != "ldiskfs" -o \
14386 "$(facet_fstype mds1)" != "ldiskfs" ]; then
14387 skip "ldiskfs only test"
14391 # check lr_reader on OST0000
14393 dev=$(facet_device $tgt)
14394 out=$(do_facet $tgt $LR_READER $dev)
14395 [ $? -eq 0 ] || error "$LR_READER failed on target $tgt device $dev"
14397 uuid=$(echo "$out" | grep -i uuid | awk '{ print $2 }')
14398 [ "$uuid" == "$(ostuuid_from_index 0)" ] ||
14399 error "Invalid uuid returned by $LR_READER on target $tgt"
14400 echo -e "uuid returned by $LR_READER is '$uuid'\n"
14402 # check lr_reader -c on MDT0000
14404 dev=$(facet_device $tgt)
14405 if ! do_facet $tgt $LR_READER -h | grep -q OPTIONS; then
14406 echo "$LR_READER does not support additional options"
14409 out=$(do_facet $tgt $LR_READER -c $dev)
14410 [ $? -eq 0 ] || error "$LR_READER failed on target $tgt device $dev"
14412 num=$(echo "$out" | grep -c "mdtlov")
14413 [ "$num" -eq $((MDSCOUNT - 1)) ] ||
14414 error "Invalid number of mdtlov clients returned by $LR_READER"
14415 echo -e "Number of mdtlov clients returned by $LR_READER is '$num'\n"
14417 # check lr_reader -cr on MDT0000
14418 out=$(do_facet $tgt $LR_READER -cr $dev)
14419 [ $? -eq 0 ] || error "$LR_READER failed on target $tgt device $dev"
14421 echo "$out" | grep -q "^reply_data:$" ||
14422 error "$LR_READER should have returned 'reply_data' section"
14423 num=$(echo "$out" | grep -c "client_generation")
14424 echo -e "Number of reply data returned by $LR_READER is '$num'\n"
14426 run_test 252 "check lr_reader tool"
14428 test_253_fill_ost() {
14429 local size_mb #how many MB should we write to pass watermark
14430 local lwm=$3 #low watermark
14431 local free_10mb #10% of free space
14433 free_kb=$($LFS df $MOUNT | grep $1 | awk '{ print $4 }')
14434 size_mb=$((free_kb / 1024 - lwm))
14435 free_10mb=$((free_kb / 10240))
14436 #If 10% of free space cross low watermark use it
14437 if (( free_10mb > size_mb )); then
14440 #At least we need to store 1.1 of difference between
14441 #free space and low watermark
14442 size_mb=$((size_mb + size_mb / 10))
14444 if (( lwm <= $((free_kb / 1024)) )) || [ ! -f $DIR/$tdir/1 ]; then
14445 dd if=/dev/zero of=$DIR/$tdir/1 bs=1M count=$size_mb \
14446 oflag=append conv=notrunc
14451 free_kb=$($LFS df $MOUNT | grep $1 | awk '{ print $4 }')
14452 echo "OST still has $((free_kb / 1024)) mbytes free"
14459 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
14460 remote_mds_nodsh && skip "remote MDS with nodsh" && return
14461 remote_mgs_nodsh && skip "remote MGS with nodsh" && return
14463 local ost_name=$($LFS osts |
14464 sed -n 's/^'$ostidx': \(.*\)_UUID .*/\1/p')
14466 local mdtosc_proc1=$(get_mdtosc_proc_path $SINGLEMDS $ost_name)
14467 do_facet $SINGLEMDS $LCTL get_param -n \
14468 osp.$mdtosc_proc1.reserved_mb_high ||
14469 { skip "remote MDS does not support reserved_mb_high" &&
14474 wait_delete_completed
14477 local last_wm_h=$(do_facet $SINGLEMDS $LCTL get_param -n \
14478 osp.$mdtosc_proc1.reserved_mb_high)
14479 local last_wm_l=$(do_facet $SINGLEMDS $LCTL get_param -n \
14480 osp.$mdtosc_proc1.reserved_mb_low)
14481 echo "prev high watermark $last_wm_h, prev low watermark $last_wm_l"
14483 create_pool $FSNAME.$TESTNAME || error "Pool creation failed"
14484 do_facet mgs $LCTL pool_add $FSNAME.$TESTNAME $ost_name ||
14485 error "Adding $ost_name to pool failed"
14487 # Wait for client to see a OST at pool
14488 wait_update $HOSTNAME "$LCTL get_param -n
14489 lov.$FSNAME-*.pools.$TESTNAME | sort -u |
14490 grep $ost_name" "$ost_name""_UUID" $((TIMEOUT/2)) ||
14491 error "Client can not see the pool"
14492 $SETSTRIPE $DIR/$tdir -i $ostidx -c 1 -p $FSNAME.$TESTNAME ||
14493 error "Setstripe failed"
14495 dd if=/dev/zero of=$DIR/$tdir/0 bs=1M count=10
14496 local blocks=$($LFS df $MOUNT | grep $ost_name | awk '{ print $4 }')
14497 echo "OST still has $((blocks/1024)) mbytes free"
14499 local new_lwm=$((blocks/1024-10))
14500 do_facet $SINGLEMDS $LCTL set_param \
14501 osp.$mdtosc_proc1.reserved_mb_high=$((new_lwm+5))
14502 do_facet $SINGLEMDS $LCTL set_param \
14503 osp.$mdtosc_proc1.reserved_mb_low=$new_lwm
14505 test_253_fill_ost $ost_name $mdtosc_proc1 $new_lwm
14507 #First enospc could execute orphan deletion so repeat.
14508 test_253_fill_ost $ost_name $mdtosc_proc1 $new_lwm
14510 local oa_status=$(do_facet $SINGLEMDS $LCTL get_param -n \
14511 osp.$mdtosc_proc1.prealloc_status)
14512 echo "prealloc_status $oa_status"
14514 dd if=/dev/zero of=$DIR/$tdir/2 bs=1M count=1 &&
14515 error "File creation should fail"
14516 #object allocation was stopped, but we still able to append files
14517 dd if=/dev/zero of=$DIR/$tdir/1 bs=1M seek=6 count=5 oflag=append ||
14518 error "Append failed"
14519 rm -f $DIR/$tdir/1 $DIR/$tdir/0 $DIR/$tdir/r*
14521 wait_delete_completed
14525 for i in $(seq 10 12); do
14526 dd if=/dev/zero of=$DIR/$tdir/$i bs=1M count=1 2>/dev/null ||
14527 error "File creation failed after rm";
14530 oa_status=$(do_facet $SINGLEMDS $LCTL get_param -n \
14531 osp.$mdtosc_proc1.prealloc_status)
14532 echo "prealloc_status $oa_status"
14534 if (( oa_status != 0 )); then
14535 error "Object allocation still disable after rm"
14537 do_facet $SINGLEMDS $LCTL set_param \
14538 osp.$mdtosc_proc1.reserved_mb_high=$last_wm_h
14539 do_facet $SINGLEMDS $LCTL set_param \
14540 osp.$mdtosc_proc1.reserved_mb_low=$last_wm_l
14543 do_facet mgs $LCTL pool_remove $FSNAME.$TESTNAME $ost_name ||
14544 error "Remove $ost_name from pool failed"
14545 do_facet mgs $LCTL pool_destroy $FSNAME.$TESTNAME ||
14546 error "Pool destroy fialed"
14548 run_test 253 "Check object allocation limit"
14553 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
14554 remote_mds_nodsh && skip "remote MDS with nodsh" && return
14555 do_facet mds1 $LCTL get_param -n mdd.$MDT0.changelog_size ||
14556 { skip "MDS does not support changelog_size" && return; }
14558 cl_user=$(do_facet mds1 $LCTL --device $MDT0 changelog_register -n)
14559 echo "Registered as changelog user $cl_user"
14561 $LFS changelog_clear $MDT0 $cl_user 0
14563 local size1=$(do_facet mds1 \
14564 $LCTL get_param -n mdd.$MDT0.changelog_size)
14565 echo "Changelog size $size1"
14568 $LFS mkdir -i 0 $DIR/$tdir
14570 mkdir -p $DIR/$tdir/pics/2008/zachy
14571 touch $DIR/$tdir/pics/2008/zachy/timestamp
14572 cp /etc/hosts $DIR/$tdir/pics/2008/zachy/pic1.jpg
14573 mv $DIR/$tdir/pics/2008/zachy $DIR/$tdir/pics/zach
14574 ln $DIR/$tdir/pics/zach/pic1.jpg $DIR/$tdir/pics/2008/portland.jpg
14575 ln -s $DIR/$tdir/pics/2008/portland.jpg $DIR/$tdir/pics/desktop.jpg
14576 rm $DIR/$tdir/pics/desktop.jpg
14578 local size2=$(do_facet mds1 \
14579 $LCTL get_param -n mdd.$MDT0.changelog_size)
14580 echo "Changelog size after work $size2"
14582 do_facet mds1 $LCTL --device $MDT0 changelog_deregister $cl_user
14584 if (( size2 <= size1 )); then
14585 error "Changelog size after work should be greater than original"
14589 run_test 254 "Check changelog size"
14596 lfs ladvise -a invalid $file 2>&1 | grep "Valid types" |
14597 awk -F: '{print $2}' | grep $type > /dev/null
14598 if [ $? -ne 0 ]; then
14608 lfs ladvise -a willread $file > /dev/null 2>&1
14609 if [ $? -eq 0 ]; then
14613 lfs ladvise -a willread $file 2>&1 |
14614 grep "Inappropriate ioctl for device" > /dev/null
14615 if [ $? -eq 0 ]; then
14622 bc <<<"scale=2; ($1 - $2) * 100 / $2"
14625 # run a random read IO workload
14626 # usage: random_read_iops <filename> <filesize> <iosize>
14627 random_read_iops() {
14630 local iosize=${3:-4096}
14632 $READS -f $file -s $fsize -b $iosize -n $((fsize / iosize)) -t 60 |
14633 sed -e '/^$/d' -e 's#.*s, ##' -e 's#MB/s##'
14636 drop_file_oss_cache() {
14640 $LFS ladvise -a dontneed $file 2>/dev/null ||
14641 do_nodes $nodes "echo 3 > /proc/sys/vm/drop_caches"
14644 ladvise_willread_performance()
14647 local average_origin=0
14648 local average_cache=0
14649 local average_ladvise=0
14651 for ((i = 1; i <= $repeat; i++)); do
14652 echo "Iter $i/$repeat: reading without willread hint"
14653 cancel_lru_locks osc
14654 drop_file_oss_cache $DIR/$tfile $(comma_list $(osts_nodes))
14655 local speed_origin=$(random_read_iops $DIR/$tfile $size)
14656 echo "Iter $i/$repeat: uncached speed: $speed_origin"
14657 average_origin=$(bc <<<"$average_origin + $speed_origin")
14659 cancel_lru_locks osc
14660 local speed_cache=$(random_read_iops $DIR/$tfile $size)
14661 echo "Iter $i/$repeat: OSS cache speed: $speed_cache"
14662 average_cache=$(bc <<<"$average_cache + $speed_cache")
14664 cancel_lru_locks osc
14665 drop_file_oss_cache $DIR/$tfile $(comma_list $(osts_nodes))
14666 $LFS ladvise -a willread $DIR/$tfile || error "ladvise failed"
14667 local speed_ladvise=$(random_read_iops $DIR/$tfile $size)
14668 echo "Iter $i/$repeat: ladvise speed: $speed_ladvise"
14669 average_ladvise=$(bc <<<"$average_ladvise + $speed_ladvise")
14671 average_origin=$(bc <<<"scale=2; $average_origin / $repeat")
14672 average_cache=$(bc <<<"scale=2; $average_cache / $repeat")
14673 average_ladvise=$(bc <<<"scale=2; $average_ladvise / $repeat")
14675 speedup_cache=$(percent $average_cache $average_origin)
14676 speedup_ladvise=$(percent $average_ladvise $average_origin)
14678 echo "Average uncached read: $average_origin"
14679 echo "Average speedup with OSS cached read: " \
14680 "$average_cache = +$speedup_cache%"
14681 echo "Average speedup with ladvise willread: " \
14682 "$average_ladvise = +$speedup_ladvise%"
14684 local lowest_speedup=20
14685 if [ ${average_cache%.*} -lt $lowest_speedup ]; then
14686 echo "Speedup with OSS cached read less than $lowest_speedup%, " \
14687 "got $average_cache%. Skipping ladvise willread check."
14691 # the test won't work on ZFS until it supports 'ladvise dontneed', but
14692 # it is still good to run until then to exercise 'ladvise willread'
14693 ! $LFS ladvise -a dontneed $DIR/$tfile &&
14694 [ "$(facet_fstype ost1)" = "zfs" ] &&
14695 echo "osd-zfs does not support dontneed or drop_caches" &&
14698 lowest_speedup=$(bc <<<"scale=2; $average_cache / 2")
14699 [ ${average_ladvise%.*} -gt $lowest_speedup ] ||
14700 error_not_in_vm "Speedup with willread is less than " \
14701 "$lowest_speedup%, got $average_ladvise%"
14705 [ $(lustre_version_code ost1) -lt $(version_code 2.8.54) ] &&
14706 skip "lustre < 2.8.54 does not support ladvise " && return
14707 remote_ost_nodsh && skip "remote OST with nodsh" && return
14709 lfs setstripe -c -1 -i 0 $DIR/$tfile || error "$tfile failed"
14711 ladvise_no_type willread $DIR/$tfile &&
14712 skip "willread ladvise is not supported" && return
14714 ladvise_no_ioctl $DIR/$tfile &&
14715 skip "ladvise ioctl is not supported" && return
14718 local size=$((size_mb * 1048576))
14719 dd if=/dev/zero of=$DIR/$tfile bs=1048576 count=$size_mb ||
14720 error "dd to $DIR/$tfile failed"
14722 lfs ladvise -a willread $DIR/$tfile ||
14723 error "Ladvise failed with no range argument"
14725 lfs ladvise -a willread -s 0 $DIR/$tfile ||
14726 error "Ladvise failed with no -l or -e argument"
14728 lfs ladvise -a willread -e 1 $DIR/$tfile ||
14729 error "Ladvise failed with only -e argument"
14731 lfs ladvise -a willread -l 1 $DIR/$tfile ||
14732 error "Ladvise failed with only -l argument"
14734 lfs ladvise -a willread -s 2 -e 1 $DIR/$tfile &&
14735 error "End offset should not be smaller than start offset"
14737 lfs ladvise -a willread -s 2 -e 2 $DIR/$tfile &&
14738 error "End offset should not be equal to start offset"
14740 lfs ladvise -a willread -s $size -l 1 $DIR/$tfile ||
14741 error "Ladvise failed with overflowing -s argument"
14743 lfs ladvise -a willread -s 1 -e $((size + 1)) $DIR/$tfile ||
14744 error "Ladvise failed with overflowing -e argument"
14746 lfs ladvise -a willread -s 1 -l $size $DIR/$tfile ||
14747 error "Ladvise failed with overflowing -l argument"
14749 lfs ladvise -a willread -l 1 -e 2 $DIR/$tfile &&
14750 error "Ladvise succeeded with conflicting -l and -e arguments"
14752 echo "Synchronous ladvise should wait"
14754 #define OBD_FAIL_OST_LADVISE_PAUSE 0x237
14755 do_nodes $(comma_list $(osts_nodes)) \
14756 $LCTL set_param fail_val=$delay fail_loc=0x237
14758 local start_ts=$SECONDS
14759 lfs ladvise -a willread $DIR/$tfile ||
14760 error "Ladvise failed with no range argument"
14761 local end_ts=$SECONDS
14762 local inteval_ts=$((end_ts - start_ts))
14764 if [ $inteval_ts -lt $(($delay - 1)) ]; then
14765 error "Synchronous advice didn't wait reply"
14768 echo "Asynchronous ladvise shouldn't wait"
14769 local start_ts=$SECONDS
14770 lfs ladvise -a willread -b $DIR/$tfile ||
14771 error "Ladvise failed with no range argument"
14772 local end_ts=$SECONDS
14773 local inteval_ts=$((end_ts - start_ts))
14775 if [ $inteval_ts -gt $(($delay / 2)) ]; then
14776 error "Asynchronous advice blocked"
14779 do_nodes $(comma_list $(osts_nodes)) $LCTL set_param fail_loc=0
14780 ladvise_willread_performance
14782 run_test 255a "check 'lfs ladvise -a willread'"
14788 do_facet $facet "cat /proc/meminfo | grep ^${info}:" | awk '{print $2}'
14792 remote_ost_nodsh && skip "remote OST with nodsh" && return
14794 lfs setstripe -c 1 -i 0 $DIR/$tfile
14796 ladvise_no_type dontneed $DIR/$tfile &&
14797 skip "dontneed ladvise is not supported" && return
14799 ladvise_no_ioctl $DIR/$tfile &&
14800 skip "ladvise ioctl is not supported" && return
14802 [ $(lustre_version_code ost1) -lt $(version_code 2.8.54) ] &&
14803 skip "lustre < 2.8.54 does not support ladvise" && return
14805 ! $LFS ladvise -a dontneed $DIR/$tfile &&
14806 [ "$(facet_fstype ost1)" = "zfs" ] &&
14807 skip "zfs-osd does not support 'ladvise dontneed'" && return
14810 local size=$((size_mb * 1048576))
14811 # In order to prevent disturbance of other processes, only check 3/4
14812 # of the memory usage
14813 local kibibytes=$((size_mb * 1024 * 3 / 4))
14815 dd if=/dev/zero of=$DIR/$tfile bs=1048576 count=$size_mb ||
14816 error "dd to $DIR/$tfile failed"
14818 local total=$(facet_meminfo ost1 MemTotal)
14819 echo "Total memory: $total KiB"
14821 do_facet ost1 "sync && echo 3 > /proc/sys/vm/drop_caches"
14822 local before_read=$(facet_meminfo ost1 Cached)
14823 echo "Cache used before read: $before_read KiB"
14825 lfs ladvise -a willread $DIR/$tfile ||
14826 error "Ladvise willread failed"
14827 local after_read=$(facet_meminfo ost1 Cached)
14828 echo "Cache used after read: $after_read KiB"
14830 lfs ladvise -a dontneed $DIR/$tfile ||
14831 error "Ladvise dontneed again failed"
14832 local no_read=$(facet_meminfo ost1 Cached)
14833 echo "Cache used after dontneed ladvise: $no_read KiB"
14835 if [ $total -lt $((before_read + kibibytes)) ]; then
14836 echo "Memory is too small, abort checking"
14840 if [ $((before_read + kibibytes)) -gt $after_read ]; then
14841 error "Ladvise willread should use more memory" \
14842 "than $kibibytes KiB"
14845 if [ $((no_read + kibibytes)) -gt $after_read ]; then
14846 error "Ladvise dontneed should release more memory" \
14847 "than $kibibytes KiB"
14850 run_test 255b "check 'lfs ladvise -a dontneed'"
14857 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
14858 remote_mds_nodsh && skip "remote MDS with nodsh" && return
14859 [ "$(facet_fstype mds1)" != "ldiskfs" ] &&
14860 skip "ldiskfs only test" && return
14862 mdt_dev=$(mdsdevname 1)
14864 cl_user=$(do_facet mds1 \
14865 "$LCTL get_param -n mdd.$MDT0.changelog_users | grep cl")
14866 if [[ -n $cl_user ]]; then
14867 skip "active changelog user"
14871 cl_user=$(do_facet mds1 $LCTL --device $MDT0 changelog_register -n)
14872 echo "Registered as changelog user $cl_user"
14875 mkdir -p $DIR/$tdir
14877 $LFS changelog_clear $MDT0 $cl_user 0
14880 touch $DIR/$tdir/{1..10}
14883 stop mds1 || error "Fail to stop MDT."
14886 start mds1 $mdt_dev $MDS_MOUNT_OPTS || error "Fail to start MDT."
14888 #after mount new plainllog is used
14889 touch $DIR/$tdir/{11..19}
14890 local TEMP256FILE=$(mktemp TEMP256XXXXXX)
14891 cat_sl=$(do_facet mds1 \
14892 "$DEBUGFS -R \\\"dump changelog_catalog $TEMP256FILE\\\" $mdt_dev; \
14893 llog_reader $TEMP256FILE | grep \\\"type=1064553b\\\" | wc -l")
14896 if (( cat_sl != 2 )); then
14897 do_facet mds1 $LCTL --device $MDT0 changelog_deregister $cl_user
14898 error "Changelog catalog has wrong number of slots $cat_sl"
14901 $LFS changelog_clear $MDT0 $cl_user 0
14903 TEMP256FILE=$(mktemp TEMP256XXXXXX)
14904 cat_sl=$(do_facet mds1 \
14905 "$DEBUGFS -R \\\"dump changelog_catalog $TEMP256FILE\\\" $mdt_dev; \
14906 llog_reader $TEMP256FILE | grep \\\"type=1064553b\\\" | wc -l")
14909 do_facet mds1 $LCTL --device $MDT0 changelog_deregister $cl_user
14911 if (( cat_sl == 2 )); then
14912 error "Empty plain llog was not deleted from changelog catalog"
14914 if (( cat_sl != 1 )); then
14915 error "Active plain llog shouldn\`t be deleted from catalog"
14918 run_test 256 "Check llog delete for empty and not full state"
14921 remote_mds_nodsh && skip "remote MDS with nodsh" && return
14922 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.8.55) ]] &&
14923 skip "Need MDS version at least 2.8.55" && return
14925 test_mkdir -p $DIR/$tdir
14927 setfattr -n trusted.name1 -v value1 $DIR/$tdir ||
14928 error "setfattr -n trusted.name1=value1 $DIR/$tdir failed"
14931 #define OBD_FAIL_MDS_XATTR_REP 0x161
14932 local mdtidx=$($LFS getstripe -M $DIR/$tdir)
14933 local facet=mds$((mdtidx + 1))
14934 set_nodes_failloc $(facet_active_host $facet) 0x80000161
14935 getfattr -n trusted.name1 $DIR/$tdir 2> /dev/null
14937 stop $facet || error "stop MDS failed"
14938 start $facet $(mdsdevname $((mdtidx + 1))) $MDS_MOUNT_OPTS ||
14939 error "start MDS fail"
14941 run_test 257 "xattr locks are not lost"
14943 # Verify we take the i_mutex when security requires it
14945 #define OBD_FAIL_IMUTEX_SEC 0x141c
14946 $LCTL set_param fail_loc=0x141c
14948 chmod u+s $DIR/$tfile
14949 chmod a+rwx $DIR/$tfile
14950 $RUNAS dd if=/dev/zero of=$DIR/$tfile bs=4k count=1 oflag=append
14952 if [ $RC -ne 0 ]; then
14953 error "error, failed to take i_mutex, rc=$?"
14959 # Verify we do NOT take the i_mutex in the normal case
14961 #define OBD_FAIL_IMUTEX_NOSEC 0x141d
14962 $LCTL set_param fail_loc=0x141d
14965 chmod a+rw $DIR/$tfile
14966 $RUNAS dd if=/dev/zero of=$DIR/$tfile bs=4k count=1 oflag=append
14968 if [ $RC -ne 0 ]; then
14969 error "error, took i_mutex unnecessarily, rc=$?"
14974 run_test 258b "verify i_mutex security behavior"
14977 #define OBD_FAIL_MDC_CLOSE 0x806
14978 $LCTL set_param fail_loc=0x80000806
14982 run_test 260 "Check mdc_close fail"
14984 cleanup_test_300() {
14988 test_striped_dir() {
14993 mkdir -p $DIR/$tdir
14995 SAVE_UMASK=$(umask)
14996 trap cleanup_test_300 RETURN EXIT
14998 $LFS setdirstripe -i $mdt_index -c 2 -t all_char -m 755 \
14999 $DIR/$tdir/striped_dir ||
15000 error "set striped dir error"
15002 local mode=$(stat -c%a $DIR/$tdir/striped_dir)
15003 [ "$mode" = "755" ] || error "expect 755 got $mode"
15005 $LFS getdirstripe $DIR/$tdir/striped_dir > /dev/null 2>&1 ||
15006 error "getdirstripe failed"
15007 stripe_count=$($LFS getdirstripe -c $DIR/$tdir/striped_dir)
15008 if [ "$stripe_count" != "2" ]; then
15009 error "1:stripe_count is $stripe_count, expect 2"
15011 stripe_count=$($LFS getdirstripe -T $DIR/$tdir/striped_dir)
15012 if [ "$stripe_count" != "2" ]; then
15013 error "2:stripe_count is $stripe_count, expect 2"
15016 stripe_index=$($LFS getdirstripe -i $DIR/$tdir/striped_dir)
15017 if [ "$stripe_index" != "$mdt_index" ]; then
15018 error "stripe_index is $stripe_index, expect $mdt_index"
15021 [ $(stat -c%h $DIR/$tdir/striped_dir) == '2' ] ||
15022 error "nlink error after create striped dir"
15024 mkdir $DIR/$tdir/striped_dir/a
15025 mkdir $DIR/$tdir/striped_dir/b
15027 stat $DIR/$tdir/striped_dir/a ||
15028 error "create dir under striped dir failed"
15029 stat $DIR/$tdir/striped_dir/b ||
15030 error "create dir under striped dir failed"
15032 [ $(stat -c%h $DIR/$tdir/striped_dir) == '4' ] ||
15033 error "nlink error after mkdir"
15035 rmdir $DIR/$tdir/striped_dir/a
15036 [ $(stat -c%h $DIR/$tdir/striped_dir) == '3' ] ||
15037 error "nlink error after rmdir"
15039 rmdir $DIR/$tdir/striped_dir/b
15040 [ $(stat -c%h $DIR/$tdir/striped_dir) == '2' ] ||
15041 error "nlink error after rmdir"
15043 chattr +i $DIR/$tdir/striped_dir
15044 createmany -o $DIR/$tdir/striped_dir/f 10 &&
15045 error "immutable flags not working under striped dir!"
15046 chattr -i $DIR/$tdir/striped_dir
15048 rmdir $DIR/$tdir/striped_dir ||
15049 error "rmdir striped dir error"
15057 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.0) ] &&
15058 skip "skipped for lustre < 2.7.0" && return
15059 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
15060 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
15062 test_striped_dir 0 || error "failed on striped dir on MDT0"
15063 test_striped_dir 1 || error "failed on striped dir on MDT0"
15065 run_test 300a "basic striped dir sanity test"
15068 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.0) ] &&
15069 skip "skipped for lustre < 2.7.0" && return
15070 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
15071 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
15077 test_mkdir $DIR/$tdir || error "mkdir fail"
15078 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir ||
15079 error "set striped dir error"
15080 for ((i=0; i<10; i++)); do
15081 mtime1=$(stat -c %Y $DIR/$tdir/striped_dir)
15083 touch $DIR/$tdir/striped_dir/file_$i ||
15084 error "touch error $i"
15085 mtime2=$(stat -c %Y $DIR/$tdir/striped_dir)
15086 [ $mtime1 -eq $mtime2 ] &&
15087 error "mtime not change after create"
15089 rm -f $DIR/$tdir/striped_dir/file_$i ||
15090 error "unlink error $i"
15091 mtime3=$(stat -c %Y $DIR/$tdir/striped_dir)
15092 [ $mtime2 -eq $mtime3 ] &&
15093 error "mtime did not change after unlink"
15097 run_test 300b "check ctime/mtime for striped dir"
15100 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.0) ] &&
15101 skip "skipped for lustre < 2.7.0" && return
15102 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
15103 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
15106 mkdir -p $DIR/$tdir
15107 $LFS setdirstripe -i 0 -c 2 $DIR/$tdir/striped_dir ||
15108 error "set striped dir error"
15110 chown $RUNAS_ID:$RUNAS_GID $DIR/$tdir/striped_dir ||
15111 error "chown striped dir failed"
15113 $RUNAS createmany -o $DIR/$tdir/striped_dir/f 5000 ||
15114 error "create 5k files failed"
15116 file_count=$(ls $DIR/$tdir/striped_dir | wc -l)
15118 [ "$file_count" = 5000 ] || error "file count $file_count != 5000"
15122 run_test 300c "chown && check ls under striped directory"
15125 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.0) ] &&
15126 skip "skipped for lustre < 2.7.0" && return
15127 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
15128 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
15132 mkdir -p $DIR/$tdir
15133 $SETSTRIPE -c 2 $DIR/$tdir
15135 #local striped directory
15136 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir ||
15137 error "set striped dir error"
15138 createmany -o $DIR/$tdir/striped_dir/f 10 ||
15139 error "create 10 files failed"
15141 #remote striped directory
15142 $LFS setdirstripe -i 1 -c 2 $DIR/$tdir/remote_striped_dir ||
15143 error "set striped dir error"
15144 createmany -o $DIR/$tdir/remote_striped_dir/f 10 ||
15145 error "create 10 files failed"
15147 for file in $(find $DIR/$tdir); do
15148 stripe_count=$($GETSTRIPE -c $file)
15149 [ $stripe_count -eq 2 ] ||
15150 error "wrong stripe $stripe_count for $file"
15155 run_test 300d "check default stripe under striped directory"
15158 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
15159 skip "Need MDS version at least 2.7.55" && return
15160 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
15161 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
15165 mkdir -p $DIR/$tdir
15167 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir ||
15168 error "set striped dir error"
15170 touch $DIR/$tdir/striped_dir/a
15171 touch $DIR/$tdir/striped_dir/b
15172 touch $DIR/$tdir/striped_dir/c
15174 mkdir $DIR/$tdir/striped_dir/dir_a
15175 mkdir $DIR/$tdir/striped_dir/dir_b
15176 mkdir $DIR/$tdir/striped_dir/dir_c
15178 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir/stp_a ||
15179 error "set striped adir under striped dir error"
15181 $LFS setdirstripe -i 0 -c 2 -H all_char $DIR/$tdir/striped_dir/stp_b ||
15182 error "set striped bdir under striped dir error"
15184 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir/stp_c ||
15185 error "set striped cdir under striped dir error"
15187 mrename $DIR/$tdir/striped_dir/dir_a $DIR/$tdir/striped_dir/dir_b ||
15188 error "rename dir under striped dir fails"
15190 mrename $DIR/$tdir/striped_dir/stp_a $DIR/$tdir/striped_dir/stp_b ||
15191 error "rename dir under different stripes fails"
15193 mrename $DIR/$tdir/striped_dir/a $DIR/$tdir/striped_dir/c ||
15194 error "rename file under striped dir should succeed"
15196 mrename $DIR/$tdir/striped_dir/dir_b $DIR/$tdir/striped_dir/dir_c ||
15197 error "rename dir under striped dir should succeed"
15201 run_test 300e "check rename under striped directory"
15204 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
15205 skip "Need MDS version at least 2.7.55" && return
15206 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
15207 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
15212 mkdir -p $DIR/$tdir
15214 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir ||
15215 error "set striped dir error"
15217 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir1 ||
15218 error "set striped dir error"
15220 touch $DIR/$tdir/striped_dir/a
15221 mkdir $DIR/$tdir/striped_dir/dir_a
15222 $LFS setdirstripe -i 0 -c 2 $DIR/$tdir/striped_dir/stp_a ||
15223 error "create striped dir under striped dir fails"
15225 touch $DIR/$tdir/striped_dir1/b
15226 mkdir $DIR/$tdir/striped_dir1/dir_b
15227 $LFS setdirstripe -i 0 -c 2 $DIR/$tdir/striped_dir/stp_b ||
15228 error "create striped dir under striped dir fails"
15230 mrename $DIR/$tdir/striped_dir/dir_a $DIR/$tdir/striped_dir1/dir_b ||
15231 error "rename dir under different striped dir should fail"
15233 mrename $DIR/$tdir/striped_dir/stp_a $DIR/$tdir/striped_dir1/stp_b ||
15234 error "rename striped dir under diff striped dir should fail"
15236 mrename $DIR/$tdir/striped_dir/a $DIR/$tdir/striped_dir1/a ||
15237 error "rename file under diff striped dirs fails"
15241 run_test 300f "check rename cross striped directory"
15243 test_300_check_default_striped_dir()
15246 local default_count=$2
15247 local default_index=$3
15250 local dir_stripe_index
15253 echo "checking $dirname $default_count $default_index"
15254 $LFS setdirstripe -D -c $default_count -i $default_index \
15255 -t all_char $DIR/$tdir/$dirname ||
15256 error "set default stripe on striped dir error"
15257 stripe_count=$($LFS getdirstripe -D -c $DIR/$tdir/$dirname)
15258 [ $stripe_count -eq $default_count ] ||
15259 error "expect $default_count get $stripe_count for $dirname"
15261 stripe_index=$($LFS getdirstripe -D -i $DIR/$tdir/$dirname)
15262 [ $stripe_index -eq $default_index ] ||
15263 error "expect $default_index get $stripe_index for $dirname"
15265 mkdir $DIR/$tdir/$dirname/{test1,test2,test3,test4} ||
15266 error "create dirs failed"
15268 createmany -o $DIR/$tdir/$dirname/f- 10 || error "create files failed"
15269 unlinkmany $DIR/$tdir/$dirname/f- 10 || error "unlink files failed"
15270 for dir in $(find $DIR/$tdir/$dirname/*); do
15271 stripe_count=$($LFS getdirstripe -c $dir)
15272 [ $stripe_count -eq $default_count ] ||
15273 [ $stripe_count -eq 0 -o $default_count -eq 1 ] ||
15274 error "stripe count $default_count != $stripe_count for $dir"
15276 stripe_index=$($LFS getdirstripe -i $dir)
15277 [ $default_index -eq -1 -o $stripe_index -eq $default_index ] ||
15278 error "$stripe_index != $default_index for $dir"
15280 #check default stripe
15281 stripe_count=$($LFS getdirstripe -D -c $dir)
15282 [ $stripe_count -eq $default_count ] ||
15283 error "default count $default_count != $stripe_count for $dir"
15285 stripe_index=$($LFS getdirstripe -D -i $dir)
15286 [ $stripe_index -eq $default_index ] ||
15287 error "default index $default_index != $stripe_index for $dir"
15289 rmdir $DIR/$tdir/$dirname/* || error "rmdir failed"
15293 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
15294 skip "Need MDS version at least 2.7.55" && return
15295 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
15301 mkdir $DIR/$tdir/normal_dir
15303 #Checking when client cache stripe index
15304 $LFS setdirstripe -c$MDSCOUNT $DIR/$tdir/striped_dir
15305 $LFS setdirstripe -D -i1 $DIR/$tdir/striped_dir ||
15306 error "create striped_dir failed"
15308 mkdir $DIR/$tdir/striped_dir/dir1 ||
15309 error "create dir1 fails"
15310 stripe_index=$($LFS getdirstripe -i $DIR/$tdir/striped_dir/dir1)
15311 [ $stripe_index -eq 1 ] ||
15312 error "dir1 expect 1 got $stripe_index"
15314 $LFS setdirstripe -i2 $DIR/$tdir/striped_dir/dir2 ||
15315 error "create dir2 fails"
15316 stripe_index=$($LFS getdirstripe -i $DIR/$tdir/striped_dir/dir2)
15317 [ $stripe_index -eq 2 ] ||
15318 error "dir2 expect 2 got $stripe_index"
15320 #check default stripe count/stripe index
15321 test_300_check_default_striped_dir normal_dir $MDSCOUNT 1
15322 test_300_check_default_striped_dir normal_dir 1 0
15323 test_300_check_default_striped_dir normal_dir 2 1
15324 test_300_check_default_striped_dir normal_dir 2 -1
15326 #delete default stripe information
15327 echo "delete default stripeEA"
15328 $LFS setdirstripe -d $DIR/$tdir/normal_dir ||
15329 error "set default stripe on striped dir error"
15331 mkdir -p $DIR/$tdir/normal_dir/{test1,test2,test3,test4}
15332 for dir in $(find $DIR/$tdir/normal_dir/*); do
15333 stripe_count=$($LFS getdirstripe -c $dir)
15334 [ $stripe_count -eq 0 ] ||
15335 error "expect 1 get $stripe_count for $dir"
15336 stripe_index=$($LFS getdirstripe -i $dir)
15337 [ $stripe_index -eq 0 ] ||
15338 error "expect 0 get $stripe_index for $dir"
15341 run_test 300g "check default striped directory for normal directory"
15344 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
15345 skip "Need MDS version at least 2.7.55" && return
15346 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
15351 $LFS setdirstripe -i 0 -c $MDSCOUNT -t all_char \
15352 $DIR/$tdir/striped_dir ||
15353 error "set striped dir error"
15355 test_300_check_default_striped_dir striped_dir $MDSCOUNT 1
15356 test_300_check_default_striped_dir striped_dir 1 0
15357 test_300_check_default_striped_dir striped_dir 2 1
15358 test_300_check_default_striped_dir striped_dir 2 -1
15360 #delete default stripe information
15361 $LFS setdirstripe -d $DIR/$tdir/striped_dir ||
15362 error "set default stripe on striped dir error"
15364 mkdir -p $DIR/$tdir/striped_dir/{test1,test2,test3,test4}
15365 for dir in $(find $DIR/$tdir/striped_dir/*); do
15366 stripe_count=$($LFS getdirstripe -c $dir)
15367 [ $stripe_count -eq 0 ] ||
15368 error "expect 1 get $stripe_count for $dir"
15371 run_test 300h "check default striped directory for striped directory"
15374 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
15375 skip "Need MDS version at least 2.7.55" && return
15376 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
15377 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
15383 $LFS setdirstripe -i 0 -c$MDSCOUNT -t all_char $DIR/$tdir/striped_dir ||
15384 error "set striped dir error"
15386 createmany -o $DIR/$tdir/striped_dir/f- 10 ||
15387 error "create files under striped dir failed"
15389 $LFS setdirstripe -i0 -c$MDSCOUNT -H all_char $DIR/$tdir/hashdir ||
15390 error "set striped hashdir error"
15392 $LFS setdirstripe -i0 -c$MDSCOUNT -H all_char $DIR/$tdir/hashdir/d0 ||
15393 error "create dir0 under hash dir failed"
15394 $LFS setdirstripe -i0 -c$MDSCOUNT -H fnv_1a_64 $DIR/$tdir/hashdir/d1 ||
15395 error "create dir1 under hash dir failed"
15397 # unfortunately, we need to umount to clear dir layout cache for now
15398 # once we fully implement dir layout, we can drop this
15399 umount_client $MOUNT || error "umount failed"
15400 mount_client $MOUNT || error "mount failed"
15402 $LFS find -H fnv_1a_64 $DIR/$tdir/hashdir
15403 local dircnt=$($LFS find -H fnv_1a_64 $DIR/$tdir/hashdir | wc -l)
15404 [ $dircnt -eq 1 ] || error "lfs find striped dir got:$dircnt,except:1"
15406 #set the stripe to be unknown hash type
15407 #define OBD_FAIL_UNKNOWN_LMV_STRIPE 0x1901
15408 $LCTL set_param fail_loc=0x1901
15409 for ((i = 0; i < 10; i++)); do
15410 $CHECKSTAT -t file $DIR/$tdir/striped_dir/f-$i ||
15411 error "stat f-$i failed"
15412 rm $DIR/$tdir/striped_dir/f-$i || error "unlink f-$i failed"
15415 touch $DIR/$tdir/striped_dir/f0 &&
15416 error "create under striped dir with unknown hash should fail"
15418 $LCTL set_param fail_loc=0
15420 umount_client $MOUNT || error "umount failed"
15421 mount_client $MOUNT || error "mount failed"
15425 run_test 300i "client handle unknown hash type striped directory"
15428 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
15429 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
15430 skip "Need MDS version at least 2.7.55" && return
15431 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
15437 #define OBD_FAIL_SPLIT_UPDATE_REC 0x1702
15438 $LCTL set_param fail_loc=0x1702
15439 $LFS setdirstripe -i 0 -c$MDSCOUNT -t all_char $DIR/$tdir/striped_dir ||
15440 error "set striped dir error"
15442 createmany -o $DIR/$tdir/striped_dir/f- 10 ||
15443 error "create files under striped dir failed"
15445 $LCTL set_param fail_loc=0
15447 rm -rf $DIR/$tdir || error "unlink striped dir fails"
15451 run_test 300j "test large update record"
15454 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
15455 skip "Need MDS version at least 2.7.55" && return
15456 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
15457 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
15463 #define OBD_FAIL_LARGE_STRIPE 0x1703
15464 $LCTL set_param fail_loc=0x1703
15465 $LFS setdirstripe -i 0 -c512 $DIR/$tdir/striped_dir ||
15466 error "set striped dir error"
15467 $LCTL set_param fail_loc=0
15469 $LFS getdirstripe $DIR/$tdir/striped_dir ||
15470 error "getstripeddir fails"
15471 rm -rf $DIR/$tdir/striped_dir ||
15472 error "unlink striped dir fails"
15476 run_test 300k "test large striped directory"
15479 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
15480 skip "Need MDS version at least 2.7.55" && return
15481 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
15482 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
15485 test_mkdir -p $DIR/$tdir/striped_dir
15486 chown $RUNAS_ID $DIR/$tdir/striped_dir ||
15487 error "chown $RUNAS_ID failed"
15488 $LFS setdirstripe -i 1 -D $DIR/$tdir/striped_dir ||
15489 error "set default striped dir failed"
15491 #define OBD_FAIL_MDS_STALE_DIR_LAYOUT 0x158
15492 $LCTL set_param fail_loc=0x80000158
15493 $RUNAS mkdir $DIR/$tdir/striped_dir/test_dir || error "create dir fails"
15495 stripe_index=$($LFS getdirstripe -i $DIR/$tdir/striped_dir/test_dir)
15496 [ $stripe_index -eq 1 ] ||
15497 error "expect 1 get $stripe_index for $dir"
15499 run_test 300l "non-root user to create dir under striped dir with stale layout"
15502 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
15503 skip "Need MDS version at least 2.7.55" && return
15504 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
15505 [ $MDSCOUNT -ge 2 ] && skip "Only for single MDT" && return
15507 mkdir -p $DIR/$tdir/striped_dir
15508 $LFS setdirstripe -D -c 1 $DIR/$tdir/striped_dir ||
15509 error "set default stripes dir error"
15511 mkdir $DIR/$tdir/striped_dir/a || error "mkdir a fails"
15513 stripe_count=$($LFS getdirstripe -c $DIR/$tdir/striped_dir/a)
15514 [ $stripe_count -eq 0 ] ||
15515 error "expect 0 get $stripe_count for a"
15517 $LFS setdirstripe -D -c 2 $DIR/$tdir/striped_dir ||
15518 error "set default stripes dir error"
15520 mkdir $DIR/$tdir/striped_dir/b || error "mkdir b fails"
15522 stripe_count=$($LFS getdirstripe -c $DIR/$tdir/striped_dir/b)
15523 [ $stripe_count -eq 0 ] ||
15524 error "expect 0 get $stripe_count for b"
15526 $LFS setdirstripe -D -c1 -i2 $DIR/$tdir/striped_dir ||
15527 error "set default stripes dir error"
15529 mkdir $DIR/$tdir/striped_dir/c &&
15530 error "default stripe_index is invalid, mkdir c should fails"
15532 rm -rf $DIR/$tdir || error "rmdir fails"
15534 run_test 300m "setstriped directory on single MDT FS"
15537 local list=$(comma_list $(mdts_nodes))
15540 do_nodes $list $LCTL set_param -n mdt.*.enable_remote_dir_gid=0
15544 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
15545 skip "Need MDS version at least 2.7.55" && return
15546 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
15547 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
15548 remote_mds_nodsh && skip "remote MDS with nodsh" && return
15551 local list=$(comma_list $(mdts_nodes))
15553 trap cleanup_300n RETURN EXIT
15554 mkdir -p $DIR/$tdir
15555 chmod 777 $DIR/$tdir
15556 $RUNAS $LFS setdirstripe -i0 -c$MDSCOUNT \
15557 $DIR/$tdir/striped_dir > /dev/null 2>&1 &&
15558 error "create striped dir succeeds with gid=0"
15560 do_nodes $list $LCTL set_param -n mdt.*.enable_remote_dir_gid=-1
15561 $RUNAS $LFS setdirstripe -i0 -c$MDSCOUNT $DIR/$tdir/striped_dir ||
15562 error "create striped dir fails with gid=-1"
15564 do_nodes $list $LCTL set_param -n mdt.*.enable_remote_dir_gid=0
15565 $RUNAS $LFS setdirstripe -i 1 -c$MDSCOUNT -D \
15566 $DIR/$tdir/striped_dir > /dev/null 2>&1 &&
15567 error "set default striped dir succeeds with gid=0"
15570 do_nodes $list $LCTL set_param -n mdt.*.enable_remote_dir_gid=-1
15571 $RUNAS $LFS setdirstripe -i 1 -c$MDSCOUNT -D $DIR/$tdir/striped_dir ||
15572 error "set default striped dir fails with gid=-1"
15575 do_nodes $list $LCTL set_param -n mdt.*.enable_remote_dir_gid=0
15576 $RUNAS mkdir $DIR/$tdir/striped_dir/test_dir ||
15577 error "create test_dir fails"
15578 $RUNAS mkdir $DIR/$tdir/striped_dir/test_dir1 ||
15579 error "create test_dir1 fails"
15580 $RUNAS mkdir $DIR/$tdir/striped_dir/test_dir2 ||
15581 error "create test_dir2 fails"
15584 run_test 300n "non-root user to create dir under striped dir with default EA"
15587 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
15588 skip "Need MDS version at least 2.7.55" && return
15589 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
15590 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
15594 mkdir -p $DIR/$tdir
15596 numfree1=$(lctl get_param -n mdc.*MDT0000*.filesfree)
15597 numfree2=$(lctl get_param -n mdc.*MDT0001*.filesfree)
15598 if [ $numfree1 -lt 66000 -o $numfree2 -lt 66000 ]; then
15599 skip "not enough free inodes $numfree1 $numfree2"
15603 numfree1=$(lctl get_param -n mdc.*MDT0000-mdc-*.kbytesfree)
15604 numfree2=$(lctl get_param -n mdc.*MDT0001-mdc-*.kbytesfree)
15605 if [ $numfree1 -lt 300000 -o $numfree2 -lt 300000 ]; then
15606 skip "not enough free space $numfree1 $numfree2"
15610 $LFS setdirstripe -c2 $DIR/$tdir/striped_dir ||
15611 error "setdirstripe fails"
15613 createmany -d $DIR/$tdir/striped_dir/d 131000 ||
15614 error "create dirs fails"
15616 $LCTL set_param ldlm.namespaces.*mdc-*.lru_size=0
15617 ls $DIR/$tdir/striped_dir > /dev/null ||
15618 error "ls striped dir fails"
15619 unlinkmany -d $DIR/$tdir/striped_dir/d 131000 ||
15620 error "unlink big striped dir fails"
15622 run_test 300o "unlink big sub stripe(> 65000 subdirs)"
15625 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
15626 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
15627 remote_mds_nodsh && skip "remote MDS with nodsh" && return
15629 mkdir -p $DIR/$tdir
15631 #define OBD_FAIL_OUT_ENOSPC 0x1704
15632 do_facet mds2 lctl set_param fail_loc=0x80001704
15633 $LFS setdirstripe -c2 $DIR/$tdir/bad_striped_dir > /dev/null 2>&1 &&
15634 error "create striped directory should fail"
15636 [ -e $DIR/$tdir/bad_striped_dir ] && error "striped dir exists"
15638 $LFS setdirstripe -c2 $DIR/$tdir/bad_striped_dir
15641 run_test 300p "create striped directory without space"
15644 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
15645 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
15647 local fd=$(free_fd)
15648 local cmd="exec $fd<$tdir"
15650 $LFS mkdir -c $MDSCOUNT $tdir || error "create $tdir fails"
15653 trap "eval $cmd" EXIT
15654 cd $tdir || error "cd $tdir fails"
15655 rmdir ../$tdir || error "rmdir $tdir fails"
15656 mkdir local_dir && error "create dir succeeds"
15657 $LFS setdirstripe -i1 remote_dir && error "create remote dir succeeds"
15661 run_test 300q "create remote directory under orphan directory"
15663 prepare_remote_file() {
15664 mkdir $DIR/$tdir/src_dir ||
15665 error "create remote source failed"
15667 cp /etc/hosts $DIR/$tdir/src_dir/a || error
15668 touch $DIR/$tdir/src_dir/a
15670 $LFS mkdir -i 1 $DIR/$tdir/tgt_dir ||
15671 error "create remote target dir failed"
15673 touch $DIR/$tdir/tgt_dir/b
15675 mrename $DIR/$tdir/src_dir/a $DIR/$tdir/tgt_dir/b ||
15676 error "rename dir cross MDT failed!"
15678 $CHECKSTAT -t file $DIR/$tdir/src_dir/a &&
15679 error "src_child still exists after rename"
15681 $CHECKSTAT -t file $DIR/$tdir/tgt_dir/b ||
15682 error "missing file(a) after rename"
15684 diff /etc/hosts $DIR/$tdir/tgt_dir/b ||
15685 error "diff after rename"
15689 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 4 MDTs" && return
15690 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
15691 local remote_file=$DIR/$tdir/tgt_dir/b
15693 mkdir -p $DIR/$tdir
15695 prepare_remote_file || error "prepare remote file failed"
15698 $OPENUNLINK $remote_file $remote_file || error
15699 $CHECKSTAT -a $remote_file || error
15701 run_test 310a "open unlink remote file"
15704 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 4 MDTs" && return
15705 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
15706 local remote_file=$DIR/$tdir/tgt_dir/b
15708 mkdir -p $DIR/$tdir
15710 prepare_remote_file || error "prepare remote file failed"
15712 ln $remote_file $DIR/$tfile || error "link failed for remote file"
15713 $MULTIOP $DIR/$tfile Ouc || error "mulitop failed"
15714 $CHECKSTAT -t file $remote_file || error "check file failed"
15716 run_test 310b "unlink remote file with multiple links while open"
15719 [[ $MDSCOUNT -lt 4 ]] && skip "needs >= 4 MDTs" && return
15720 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
15721 local remote_file=$DIR/$tdir/tgt_dir/b
15723 mkdir -p $DIR/$tdir
15725 prepare_remote_file || error "prepare remote file failed"
15727 ln $remote_file $DIR/$tfile || error "link failed for remote file"
15728 multiop_bg_pause $remote_file O_uc ||
15729 error "mulitop failed for remote file"
15731 $MULTIOP $DIR/$tfile Ouc
15732 kill -USR1 $MULTIPID
15735 run_test 310c "open-unlink remote file with multiple links"
15739 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.8.54) ] &&
15740 skip "lustre < 2.8.54 does not contain LU-4825 fix" && return
15741 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
15742 remote_mds_nodsh && skip "remote MDS with nodsh" && return
15744 local old_iused=$($LFS df -i | grep OST0000 | awk '{ print $3 }')
15746 mkdir -p $DIR/$tdir
15747 $SETSTRIPE -i 0 -c 1 $DIR/$tdir
15748 createmany -o $DIR/$tdir/$tfile. 1000
15750 # statfs data is not real time, let's just calculate it
15751 old_iused=$((old_iused + 1000))
15753 local count=$(do_facet $SINGLEMDS "lctl get_param -n \
15754 osp.*OST0000*MDT0000.create_count")
15755 local max_count=$(do_facet $SINGLEMDS "lctl get_param -n \
15756 osp.*OST0000*MDT0000.max_create_count")
15757 for idx in $(seq $MDSCOUNT); do
15758 do_facet mds$idx "lctl set_param -n \
15759 osp.*OST0000*MDT000?.max_create_count=0"
15762 $SETSTRIPE -i 0 $DIR/$tdir/$tfile || error "setstripe failed"
15763 local index=$($GETSTRIPE -i $DIR/$tdir/$tfile)
15764 [ $index -ne 0 ] || error "$tfile stripe index is 0"
15766 unlinkmany $DIR/$tdir/$tfile. 1000
15768 for idx in $(seq $MDSCOUNT); do
15769 do_facet mds$idx "lctl set_param -n \
15770 osp.*OST0000*MDT000?.max_create_count=$max_count"
15771 do_facet mds$idx "lctl set_param -n \
15772 osp.*OST0000*MDT000?.create_count=$count"
15776 for i in $(seq 120); do
15777 new_iused=$($LFS df -i | grep OST0000 | awk '{ print $3 }')
15778 # system may be too busy to destroy all objs in time, use
15779 # a somewhat small value to not fail autotest
15780 [ $((old_iused - new_iused)) -gt 400 ] && break
15784 echo "waited $i sec, old Iused $old_iused, new Iused $new_iused"
15785 [ $((old_iused - new_iused)) -gt 400 ] ||
15786 error "objs not destroyed after unlink"
15788 run_test 311 "disable OSP precreate, and unlink should destroy objs"
15795 local vdevdir=$(dirname $(facet_vdevice $ost))
15796 local cmd="$ZDB -e -p $vdevdir -ddddd $(facet_device $ost)"
15797 local zfs_zapid=$(do_facet $ost $cmd |
15798 grep -w "/O/0/d$((objid%32))" -C 5 |
15799 awk '/Object/{getline; print $1}')
15800 local zfs_objid=$(do_facet $ost $cmd $zfs_zapid |
15801 awk "/$objid = /"'{printf $3}')
15806 zfs_object_blksz() {
15810 local vdevdir=$(dirname $(facet_vdevice $ost))
15811 local cmd="$ZDB -e -p $vdevdir -dddd $(facet_device $ost)"
15812 local blksz=$(do_facet $ost $cmd $objid |
15813 awk '/dblk/{getline; printf $4}')
15815 case "${blksz: -1}" in
15816 k|K) blksz=$((${blksz:0:$((${#blksz} - 1))}*1024)) ;;
15817 m|M) blksz=$((${blksz:0:$((${#blksz} - 1))}*1024*1024)) ;;
15824 test_312() { # LU-4856
15825 remote_ost_nodsh && skip "remote OST with nodsh" && return
15827 [ $(facet_fstype ost1) = "zfs" ] ||
15828 { skip "the test only applies to zfs" && return; }
15830 local max_blksz=$(do_facet ost1 \
15831 $ZFS get -p recordsize $(facet_device ost1) |
15832 awk '!/VALUE/{print $3}')
15833 local min_blksz=$(getconf PAGE_SIZE)
15835 # to make life a little bit easier
15836 $LFS mkdir -c 1 -i 0 $DIR/$tdir
15837 $LFS setstripe -c 1 -i 0 $DIR/$tdir
15839 local tf=$DIR/$tdir/$tfile
15841 local oid=$($LFS getstripe $tf | awk '/obdidx/{getline; print $2}')
15843 # Get ZFS object id
15844 local zfs_objid=$(zfs_oid_to_objid ost1 $oid)
15846 # block size change by sequential over write
15848 for ((bs=$min_blksz; bs <= max_blksz; bs <<= 2)); do
15849 dd if=/dev/zero of=$tf bs=$bs count=1 oflag=sync conv=notrunc
15851 blksz=$(zfs_object_blksz ost1 $zfs_objid)
15852 [ $blksz -eq $bs ] || error "blksz error: $blksz, expected: $bs"
15856 # block size change by sequential append write
15857 dd if=/dev/zero of=$tf bs=$min_blksz count=1 oflag=sync conv=notrunc
15858 oid=$($LFS getstripe $tf | awk '/obdidx/{getline; print $2}')
15859 zfs_objid=$(zfs_oid_to_objid ost1 $oid)
15861 for ((count = 1; count < $((max_blksz / min_blksz)); count *= 2)); do
15862 dd if=/dev/zero of=$tf bs=$min_blksz count=$count seek=$count \
15863 oflag=sync conv=notrunc
15865 blksz=$(zfs_object_blksz ost1 $zfs_objid)
15866 [ $blksz -eq $((2 * count * min_blksz)) ] ||
15867 error "blksz error, actual $blksz, " \
15868 "expected: 2 * $count * $min_blksz"
15874 oid=$($LFS getstripe $tf | awk '/obdidx/{getline; print $2}')
15875 zfs_objid=$(zfs_oid_to_objid ost1 $oid)
15877 dd if=/dev/zero of=$tf bs=1K count=1 oflag=sync conv=notrunc
15878 blksz=$(zfs_object_blksz ost1 $zfs_objid)
15879 [ $blksz -eq $min_blksz ] ||
15880 error "blksz error: $blksz, expected: $min_blksz"
15882 dd if=/dev/zero of=$tf bs=64K count=1 oflag=sync conv=notrunc seek=128
15883 blksz=$(zfs_object_blksz ost1 $zfs_objid)
15884 [ $blksz -eq 65536 ] || error "blksz error: $blksz, expected: 64k"
15886 dd if=/dev/zero of=$tf bs=1M count=1 oflag=sync conv=notrunc
15887 blksz=$(zfs_object_blksz ost1 $zfs_objid)
15888 [ $blksz -eq 65536 ] || error "rewrite error: $blksz, expected: 64k"
15890 run_test 312 "make sure ZFS adjusts its block size by write pattern"
15893 remote_ost_nodsh && skip "remote OST with nodsh" && return
15895 local file=$DIR/$tfile
15897 $SETSTRIPE -c 1 -i 0 $file || error "setstripe failed"
15899 # define OBD_FAIL_TGT_RCVD_EIO 0x720
15900 do_facet ost1 "$LCTL set_param fail_loc=0x720"
15901 dd if=/dev/zero of=$file bs=4096 oflag=direct count=1 &&
15902 error "write should failed"
15903 do_facet ost1 "$LCTL set_param fail_loc=0"
15906 run_test 313 "io should fail after last_rcvd update fail"
15909 local read_write=$1
15910 if [ "$read_write" = "write" ]; then
15911 local dd_cmd="dd if=/dev/zero of=$DIR/$tfile"
15912 elif [ "$read_write" = "read" ]; then
15913 local dd_cmd="dd of=/dev/null if=$DIR/$tfile"
15915 error "argument error"
15918 # turn off debug for performance testing
15919 local saved_debug=$($LCTL get_param -n debug)
15920 $LCTL set_param debug=0
15922 $SETSTRIPE -c 1 -i 0 $DIR/$tfile
15924 # get ost1 size - lustre-OST0000
15925 local ost1_avail_size=$($LFS df | awk /${ost1_svc}/'{ print $4 }')
15926 local blocks=$((ost1_avail_size/2/1024)) # half avail space by megabytes
15927 [ $blocks -gt 1000 ] && blocks=1000 # 1G in maximum
15929 if [ "$read_write" = "read" ]; then
15930 truncate -s $(expr 1048576 \* $blocks) $DIR/$tfile
15933 local start_time=$(date +%s.%N)
15934 $dd_cmd bs=1M count=$blocks oflag=sync ||
15935 error "real dd $read_write error"
15936 local duration=$(bc <<< "$(date +%s.%N) - $start_time")
15938 if [ "$read_write" = "write" ]; then
15942 # define OBD_FAIL_OST_FAKE_RW 0x238
15943 do_facet ost1 $LCTL set_param fail_loc=0x238
15945 local start_time=$(date +%s.%N)
15946 $dd_cmd bs=1M count=$blocks oflag=sync ||
15947 error "fake dd $read_write error"
15948 local duration_fake=$(bc <<< "$(date +%s.%N) - $start_time")
15950 if [ "$read_write" = "write" ]; then
15952 cancel_lru_locks osc
15953 $CHECKSTAT -t file -s $((blocks * 1024 * 1024)) $DIR/$tfile ||
15954 error "$tfile size not $blocks MB"
15956 do_facet ost1 $LCTL set_param fail_loc=0
15958 echo "fake $read_write $duration_fake vs. normal $read_write" \
15959 "$duration in seconds"
15960 [ $(bc <<< "$duration_fake < $duration") -eq 1 ] ||
15961 error_not_in_vm "fake write is slower"
15963 $LCTL set_param -n debug="$saved_debug"
15966 test_399a() { # LU-7655 for OST fake write
15967 remote_ost_nodsh && skip "remote OST with nodsh" && return
15971 run_test 399a "fake write should not be slower than normal write"
15973 test_399b() { # LU-8726 for OST fake read
15974 remote_ost_nodsh && skip "remote OST with nodsh" && return
15976 if [ "$(facet_fstype ost1)" != "ldiskfs" ]; then
15977 skip "ldiskfs only test" && return 0
15981 run_test 399b "fake read should not be slower than normal read"
15983 test_400a() { # LU-1606, was conf-sanity test_74
15984 local extra_flags=''
15985 local out=$TMP/$tfile
15986 local prefix=/usr/include/lustre
15989 if ! which $CC > /dev/null 2>&1; then
15990 skip_env "$CC is not installed"
15994 if ! [[ -d $prefix ]]; then
15995 # Assume we're running in tree and fixup the include path.
15996 extra_flags+=" -I$LUSTRE/../libcfs/include"
15997 extra_flags+=" -I$LUSTRE/include"
15998 extra_flags+=" -L$LUSTRE/utils"
16001 for prog in $LUSTRE_TESTS_API_DIR/*.c; do
16002 $CC -Wall -Werror $extra_flags -llustreapi -o $out $prog ||
16003 error "client api broken"
16007 run_test 400a "Lustre client api program can compile and link"
16009 test_400b() { # LU-1606, LU-5011
16011 local out=$TMP/$tfile
16012 local prefix=/usr/include/lustre
16014 # We use a hard coded prefix so that this test will not fail
16015 # when run in tree. There are headers in lustre/include/lustre/
16016 # that are not packaged (like lustre_idl.h) and have more
16017 # complicated include dependencies (like config.h and lnet/types.h).
16018 # Since this test about correct packaging we just skip them when
16019 # they don't exist (see below) rather than try to fixup cppflags.
16021 if ! which $CC > /dev/null 2>&1; then
16022 skip_env "$CC is not installed"
16026 for header in $prefix/*.h; do
16027 if ! [[ -f "$header" ]]; then
16031 if [[ "$(basename $header)" == liblustreapi.h ]]; then
16032 continue # liblustreapi.h is deprecated.
16035 $CC -Wall -Werror -include $header -c -x c /dev/null -o $out ||
16036 error "cannot compile '$header'"
16040 run_test 400b "packaged headers can be compiled"
16042 test_401a() { #LU-7437
16043 local printf_arg=$(find -printf 2>&1 | grep "unrecognized:")
16044 [ -n "$printf_arg" ] && skip_env "find does not support -printf" &&
16046 #count the number of parameters by "list_param -R"
16047 local params=$($LCTL list_param -R '*' 2>/dev/null | wc -l)
16048 #count the number of parameters by listing proc files
16049 local proc_dirs=$(eval \ls -d $proc_regexp 2>/dev/null)
16050 echo "proc_dirs='$proc_dirs'"
16051 [ -n "$proc_dirs" ] || error "no proc_dirs on $HOSTNAME"
16052 local procs=$(find -L $proc_dirs -mindepth 1 -printf '%P\n' 2>/dev/null|
16055 [ $params -eq $procs ] ||
16056 error "found $params parameters vs. $procs proc files"
16058 # test the list_param -D option only returns directories
16059 params=$($LCTL list_param -R -D '*' 2>/dev/null | wc -l)
16060 #count the number of parameters by listing proc directories
16061 procs=$(find -L $proc_dirs -mindepth 1 -type d -printf '%P\n' 2>/dev/null |
16064 [ $params -eq $procs ] ||
16065 error "found $params parameters vs. $procs proc files"
16067 run_test 401a "Verify if 'lctl list_param -R' can list parameters recursively"
16070 local save=$($LCTL get_param -n jobid_var)
16073 $LCTL set_param foo=bar jobid_var=$tmp bar=baz &&
16074 error "no error returned when setting bad parameters"
16076 local jobid_new=$($LCTL get_param -n foe jobid_var baz)
16077 [[ "$jobid_new" == "$tmp" ]] || error "jobid tmp $jobid_new != $tmp"
16079 $LCTL set_param -n fog=bam jobid_var=$save bat=fog
16080 local jobid_old=$($LCTL get_param -n foe jobid_var bag)
16081 [[ "$jobid_old" == "$save" ]] || error "jobid new $jobid_old != $save"
16083 run_test 401b "Verify 'lctl {get,set}_param' continue after error"
16086 local jobid_var_old=$($LCTL get_param -n jobid_var)
16087 local jobid_var_new
16089 $LCTL set_param jobid_var= &&
16090 error "no error returned for 'set_param a='"
16092 jobid_var_new=$($LCTL get_param -n jobid_var)
16093 [[ "$jobid_var_old" == "$jobid_var_new" ]] ||
16094 error "jobid_var was changed by setting without value"
16096 $LCTL set_param jobid_var &&
16097 error "no error returned for 'set_param a'"
16099 jobid_var_new=$($LCTL get_param -n jobid_var)
16100 [[ "$jobid_var_old" == "$jobid_var_new" ]] ||
16101 error "jobid_var was changed by setting without value"
16103 run_test 401c "Verify 'lctl set_param' without value fails in either format."
16106 local jobid_var_old=$($LCTL get_param -n jobid_var)
16107 local jobid_var_new
16108 local new_value="foo=bar"
16110 $LCTL set_param jobid_var=$new_value ||
16111 error "'set_param a=b' did not accept a value containing '='"
16113 jobid_var_new=$($LCTL get_param -n jobid_var)
16114 [[ "$jobid_var_new" == "$new_value" ]] ||
16115 error "'set_param a=b' failed on a value containing '='"
16117 # Reset the jobid_var to test the other format
16118 $LCTL set_param jobid_var=$jobid_var_old
16119 jobid_var_new=$($LCTL get_param -n jobid_var)
16120 [[ "$jobid_var_new" == "$jobid_var_old" ]] ||
16121 error "failed to reset jobid_var"
16123 $LCTL set_param jobid_var $new_value ||
16124 error "'set_param a b' did not accept a value containing '='"
16126 jobid_var_new=$($LCTL get_param -n jobid_var)
16127 [[ "$jobid_var_new" == "$new_value" ]] ||
16128 error "'set_param a b' failed on a value containing '='"
16130 $LCTL set_param jobid_var $jobid_var_old
16131 jobid_var_new=$($LCTL get_param -n jobid_var)
16132 [[ "$jobid_var_new" == "$jobid_var_old" ]] ||
16133 error "failed to reset jobid_var"
16135 run_test 401d "Verify 'lctl set_param' accepts values containing '='"
16138 local server_version=$(lustre_version_code $SINGLEMDS)
16139 [[ $server_version -ge $(version_code 2.7.66) ]] ||
16140 [[ $server_version -ge $(version_code 2.7.18.4) &&
16141 $server_version -lt $(version_code 2.7.50) ]] ||
16142 [[ $server_version -ge $(version_code 2.7.2) &&
16143 $server_version -lt $(version_code 2.7.11) ]] ||
16144 { skip "Need MDS version 2.7.2+ or 2.7.18.4+ or 2.7.66+";
16146 remote_mds_nodsh && skip "remote MDS with nodsh" && return
16147 $LFS setdirstripe -i 0 $DIR/$tdir || error "setdirstripe -i 0 failed"
16148 #define OBD_FAIL_MDS_FLD_LOOKUP 0x15c
16149 do_facet mds1 "lctl set_param fail_loc=0x8000015c"
16150 touch $DIR/$tdir/$tfile && error "touch should fail with ENOENT" ||
16151 echo "Touch failed - OK"
16153 run_test 402 "Return ENOENT to lod_generate_and_set_lovea"
16156 local file1=$DIR/$tfile.1
16157 local file2=$DIR/$tfile.2
16158 local tfile=$TMP/$tfile
16160 rm -f $file1 $file2 $tfile
16165 # 30 sec OBD_TIMEOUT in ll_getattr()
16166 # right before populating st_nlink
16167 $LCTL set_param fail_loc=0x80001409
16168 stat -c %h $file1 > $tfile &
16170 # create an alias, drop all locks and reclaim the dentry
16172 cancel_lru_locks mdc
16173 cancel_lru_locks osc
16174 sysctl -w vm.drop_caches=2
16178 [ `cat $tfile` -gt 0 ] || error "wrong nlink count: `cat $tfile`"
16180 rm -f $tfile $file1 $file2
16182 run_test 403 "i_nlink should not drop to zero due to aliasing"
16184 test_404() { # LU-6601
16185 local server_version=$(lustre_version_code $SINGLEMDS)
16186 [[ $server_version -ge $(version_code 2.8.53) ]] ||
16187 { skip "Need server version newer than 2.8.52"; return 0; }
16189 remote_mds_nodsh && skip "remote MDS with nodsh" && return
16190 local mosps=$(do_facet $SINGLEMDS $LCTL dl |
16191 awk '/osp .*-osc-MDT/ { print $4}')
16194 for osp in $mosps; do
16195 echo "Deactivate: " $osp
16196 do_facet $SINGLEMDS $LCTL --device %$osp deactivate
16197 local stat=$(do_facet $SINGLEMDS $LCTL dl |
16198 awk -vp=$osp '$4 == p { print $2 }')
16199 [ $stat = IN ] || {
16200 do_facet $SINGLEMDS $LCTL dl | grep -w $osp
16201 error "deactivate error"
16203 echo "Activate: " $osp
16204 do_facet $SINGLEMDS $LCTL --device %$osp activate
16205 local stat=$(do_facet $SINGLEMDS $LCTL dl |
16206 awk -vp=$osp '$4 == p { print $2 }')
16207 [ $stat = UP ] || {
16208 do_facet $SINGLEMDS $LCTL dl | grep -w $osp
16209 error "activate error"
16213 run_test 404 "validate manual {de}activated works properly for OSPs"
16216 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.6.92) ] &&
16217 skip "Layout swap lock is not supported" && return
16219 check_swap_layouts_support && return 0
16221 test_mkdir -p $DIR/$tdir
16222 swap_lock_test -d $DIR/$tdir ||
16223 error "One layout swap locked test failed"
16225 run_test 405 "Various layout swap lock tests"
16228 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
16229 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs" && return
16230 [ -n "$FILESET" ] && skip "SKIP due to FILESET set" && return
16231 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
16232 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.8.50) ] &&
16233 skip "Need MDS version at least 2.8.50" && return
16235 local def_stripenr=$($GETSTRIPE -c $MOUNT)
16236 local def_stripe_size=$($GETSTRIPE -S $MOUNT)
16237 local def_stripe_offset=$($GETSTRIPE -i $MOUNT)
16238 local def_pool=$($GETSTRIPE -p $MOUNT)
16240 local test_pool=$TESTNAME
16241 pool_add $test_pool || error "pool_add failed"
16242 pool_add_targets $test_pool 0 $(($OSTCOUNT - 1)) 1 ||
16243 error "pool_add_targets failed"
16245 # parent set default stripe count only, child will stripe from both
16246 # parent and fs default
16247 $SETSTRIPE -c 1 -i 1 -S $((def_stripe_size * 2)) -p $test_pool $MOUNT ||
16248 error "setstripe $MOUNT failed"
16249 $LFS mkdir -c $MDSCOUNT $DIR/$tdir || error "mkdir $tdir failed"
16250 $SETSTRIPE -c $OSTCOUNT $DIR/$tdir || error "setstripe $tdir failed"
16251 for i in $(seq 10); do
16252 local f=$DIR/$tdir/$tfile.$i
16253 touch $f || error "touch failed"
16254 local count=$($GETSTRIPE -c $f)
16255 [ $count -eq $OSTCOUNT ] ||
16256 error "$f stripe count $count != $OSTCOUNT"
16257 local offset=$($GETSTRIPE -i $f)
16258 [ $offset -eq 1 ] || error "$f stripe offset $offset != 1"
16259 local size=$($GETSTRIPE -S $f)
16260 [ $size -eq $((def_stripe_size * 2)) ] ||
16261 error "$f stripe size $size != $((def_stripe_size * 2))"
16262 local pool=$($GETSTRIPE -p $f)
16263 [ $pool == $test_pool ] || error "$f pool $pool != $test_pool"
16266 # change fs default striping, delete parent default striping, now child
16267 # will stripe from new fs default striping only
16268 $SETSTRIPE -c 1 -S $def_stripe_size -i 0 $MOUNT ||
16269 error "change $MOUNT default stripe failed"
16270 $SETSTRIPE -c 0 $DIR/$tdir || error "delete $tdir default stripe failed"
16271 for i in $(seq 11 20); do
16272 local f=$DIR/$tdir/$tfile.$i
16273 touch $f || error "touch $f failed"
16274 local count=$($GETSTRIPE -c $f)
16275 [ $count -eq 1 ] || error "$f stripe count $count != 1"
16276 local offset=$($GETSTRIPE -i $f)
16277 [ $offset -eq 0 ] || error "$f stripe offset $offset != 0"
16278 local size=$($GETSTRIPE -S $f)
16279 [ $size -eq $def_stripe_size ] ||
16280 error "$f stripe size $size != $def_stripe_size"
16281 local pool=$($GETSTRIPE -p $f)
16282 [ "#$pool" == "#" ] || error "$f pool $pool is set"
16286 unlinkmany $DIR/$tdir/$tfile. 1 20
16288 # restore FS default striping
16289 if [ -z $def_pool ]; then
16290 $SETSTRIPE -c $def_stripenr -S $def_stripe_size \
16291 -i $def_stripe_offset $MOUNT ||
16292 error "restore default striping failed"
16294 $SETSTRIPE -c $def_stripenr -S $def_stripe_size -p $def_pool \
16295 -i $def_stripe_offset $MOUNT ||
16296 error "restore default striping with $def_pool failed"
16299 local f=$DIR/$tdir/$tfile
16300 pool_remove_all_targets $test_pool $f
16301 pool_remove $test_pool $f
16303 run_test 406 "DNE support fs default striping"
16306 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
16307 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.8.55) ]] &&
16308 skip "Need MDS version at least 2.8.55" && return
16309 remote_mds_nodsh && skip "remote MDS with nodsh" && return
16311 $LFS mkdir -i 0 -c 1 $DIR/$tdir.0 ||
16312 error "$LFS mkdir -i 0 -c 1 $tdir.0 failed"
16313 $LFS mkdir -i 1 -c 1 $DIR/$tdir.1 ||
16314 error "$LFS mkdir -i 1 -c 1 $tdir.1 failed"
16315 touch $DIR/$tdir.0/$tfile.0 || error "touch $tdir.0/$tfile.0 failed"
16317 #define OBD_FAIL_DT_TXN_STOP 0x2019
16318 for idx in $(seq $MDSCOUNT); do
16319 do_facet mds$idx "lctl set_param fail_loc=0x2019"
16321 $LFS mkdir -c 2 $DIR/$tdir && error "$LFS mkdir -c 2 $tdir should fail"
16322 mv $DIR/$tdir.0/$tfile.0 $DIR/$tdir.1/$tfile.1 &&
16323 error "mv $tdir.0/$tfile.0 $tdir.1/$tfile.1 should fail"
16326 run_test 407 "transaction fail should cause operation fail"
16329 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 oflag=direct
16331 #define OBD_FAIL_OSC_BRW_PREP_REQ2 0x40a
16332 lctl set_param fail_loc=0x8000040a
16333 # let ll_prepare_partial_page() fail
16334 dd if=/dev/zero of=$DIR/$tfile bs=2048 count=1 conv=notrunc || true
16338 # create at least 100 unused inodes so that
16339 # shrink_icache_memory(0) should not return 0
16340 touch $DIR/$tfile-{0..100}
16341 rm -f $DIR/$tfile-{0..100}
16344 echo 2 > /proc/sys/vm/drop_caches
16346 run_test 408 "drop_caches should not hang due to page leaks"
16350 [ $MDSCOUNT -lt 2 ] &&
16351 skip "We need at least 2 MDTs for this test" && return
16353 check_mount_and_prep
16355 mkdir -p $DIR/$tdir || error "(0) Fail to mkdir"
16356 $LFS mkdir -i 1 -c 2 $DIR/$tdir/foo || error "(1) Fail to mkdir"
16357 touch $DIR/$tdir/guard || error "(2) Fail to create"
16359 local PREFIX=$(str_repeat 'A' 128)
16360 echo "Create 1K hard links start at $(date)"
16361 createmany -l $DIR/$tdir/guard $DIR/$tdir/foo/${PREFIX}_ 1000 ||
16362 error "(3) Fail to hard link"
16364 echo "Links count should be right although linkEA overflow"
16365 stat $DIR/$tdir/guard || error "(4) Fail to stat"
16366 local linkcount=$(stat --format=%h $DIR/$tdir/guard)
16367 [ $linkcount -eq 1001 ] ||
16368 error "(5) Unexpected hard links count: $linkcount"
16370 echo "List all links start at $(date)"
16371 ls -l $DIR/$tdir/foo > /dev/null ||
16372 error "(6) Fail to list $DIR/$tdir/foo"
16374 echo "Unlink hard links start at $(date)"
16375 unlinkmany $DIR/$tdir/foo/${PREFIX}_ 1000 ||
16376 error "(7) Fail to unlink"
16378 run_test 409 "Large amount of cross-MDTs hard links on the same file"
16382 # Create a file, and stat it from the kernel
16383 local testfile=$DIR/$tfile
16386 local run_id=$RANDOM
16387 local my_ino=$(stat --format "%i" $testfile)
16389 # Try to insert the module. This will always fail as the
16390 # module is designed to not be inserted.
16391 insmod $LUSTRE/tests/kernel/kinode.ko run_id=$run_id fname=$testfile \
16394 # Anything but success is a test failure
16396 "lustre_kinode_$run_id: inode numbers are identical: $my_ino" ||
16397 error "no inode match"
16399 run_test 410 "Test inode number returned from kernel thread"
16402 [[ $(lustre_version_code mds1) -lt $(version_code 2.9.55) ]] ||
16403 [[ $(lustre_version_code ost1) -lt $(version_code 2.9.55) ]] &&
16404 skip "Need server version at least 2.9.55" & exit 0
16405 start_full_debug_logging
16409 stop_full_debug_logging
16413 if [ $(lustre_version_code mgs) -le $(version_code 2.10.0) ]; then
16414 local st=$(do_facet mgs $LCTL barrier_stat $FSNAME |
16415 awk '/The barrier for/ { print $7 }')
16418 local st=$(do_facet mgs $LCTL barrier_stat -s $FSNAME)
16423 barrier_expired() {
16426 if [ $(lustre_version_code mgs) -le $(version_code 2.10.0) ]; then
16427 expired=$(do_facet mgs $LCTL barrier_stat $FSNAME |
16428 awk '/will be expired/ { print $7 }')
16430 expired=$(do_facet mgs $LCTL barrier_stat -t $FSNAME)
16439 echo "Start barrier_freeze at: $(date)"
16440 #define OBD_FAIL_BARRIER_DELAY 0x2202
16441 do_facet mgs $LCTL set_param fail_val=5 fail_loc=0x2202
16442 do_facet mgs $LCTL barrier_freeze $FSNAME 10 &
16445 local b_status=$(barrier_stat)
16446 echo "Got barrier status at: $(date)"
16447 [ "$b_status" = "'freezing_p1'" ] ||
16448 error "(1) unexpected barrier status $b_status"
16450 do_facet mgs $LCTL set_param fail_val=0 fail_loc=0
16452 b_status=$(barrier_stat)
16453 [ "$b_status" = "'frozen'" ] ||
16454 error "(2) unexpected barrier status $b_status"
16456 local expired=$(barrier_expired)
16457 echo "sleep $((expired + 3)) seconds, then the barrier will be expired"
16458 sleep $((expired + 3))
16460 b_status=$(barrier_stat)
16461 [ "$b_status" = "'expired'" ] ||
16462 error "(3) unexpected barrier status $b_status"
16464 do_facet mgs $LCTL barrier_freeze $FSNAME 10 ||
16465 error "(4) fail to freeze barrier"
16467 b_status=$(barrier_stat)
16468 [ "$b_status" = "'frozen'" ] ||
16469 error "(5) unexpected barrier status $b_status"
16471 echo "Start barrier_thaw at: $(date)"
16472 #define OBD_FAIL_BARRIER_DELAY 0x2202
16473 do_facet mgs $LCTL set_param fail_val=5 fail_loc=0x2202
16474 do_facet mgs $LCTL barrier_thaw $FSNAME &
16477 b_status=$(barrier_stat)
16478 echo "Got barrier status at: $(date)"
16479 [ "$b_status" = "'thawing'" ] ||
16480 error "(6) unexpected barrier status $b_status"
16482 do_facet mgs $LCTL set_param fail_val=0 fail_loc=0
16484 b_status=$(barrier_stat)
16485 [ "$b_status" = "'thawed'" ] ||
16486 error "(7) unexpected barrier status $b_status"
16488 #define OBD_FAIL_BARRIER_FAILURE 0x2203
16489 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x2203
16490 do_facet mgs $LCTL barrier_freeze $FSNAME
16492 b_status=$(barrier_stat)
16493 [ "$b_status" = "'failed'" ] ||
16494 error "(8) unexpected barrier status $b_status"
16496 do_facet $SINGLEMDS $LCTL set_param fail_loc=0
16497 do_facet mgs $LCTL barrier_thaw $FSNAME
16501 run_test 801a "write barrier user interfaces and stat machine"
16506 mkdir $DIR/$tdir || error "(1) fail to mkdir"
16507 createmany -d $DIR/$tdir/d 6 || "(2) fail to mkdir"
16508 touch $DIR/$tdir/d2/f10 || error "(3) fail to touch"
16509 touch $DIR/$tdir/d3/f11 || error "(4) fail to touch"
16510 touch $DIR/$tdir/d4/f12 || error "(5) fail to touch"
16512 cancel_lru_locks mdc
16514 # 180 seconds should be long enough
16515 do_facet mgs $LCTL barrier_freeze $FSNAME 180
16517 local b_status=$(barrier_stat)
16518 [ "$b_status" = "'frozen'" ] ||
16519 error "(6) unexpected barrier status $b_status"
16521 mkdir $DIR/$tdir/d0/d10 &
16524 touch $DIR/$tdir/d1/f13 &
16527 ln $DIR/$tdir/d2/f10 $DIR/$tdir/d2/f14 &
16530 mv $DIR/$tdir/d3/f11 $DIR/$tdir/d3/f15 &
16533 rm -f $DIR/$tdir/d4/f12 &
16536 stat $DIR/$tdir/d5 || error "(7) stat should succeed"
16538 # To guarantee taht the 'stat' is not blocked
16539 b_status=$(barrier_stat)
16540 [ "$b_status" = "'frozen'" ] ||
16541 error "(8) unexpected barrier status $b_status"
16543 # let above commands to run at background
16546 ps -p $mkdir_pid || error "(9) mkdir should be blocked"
16547 ps -p $touch_pid || error "(10) touch should be blocked"
16548 ps -p $ln_pid || error "(11) link should be blocked"
16549 ps -p $mv_pid || error "(12) rename should be blocked"
16550 ps -p $rm_pid || error "(13) unlink should be blocked"
16552 b_status=$(barrier_stat)
16553 [ "$b_status" = "'frozen'" ] ||
16554 error "(14) unexpected barrier status $b_status"
16556 do_facet mgs $LCTL barrier_thaw $FSNAME
16557 b_status=$(barrier_stat)
16558 [ "$b_status" = "'thawed'" ] ||
16559 error "(15) unexpected barrier status $b_status"
16561 wait $mkdir_pid || error "(16) mkdir should succeed"
16562 wait $touch_pid || error "(17) touch should succeed"
16563 wait $ln_pid || error "(18) link should succeed"
16564 wait $mv_pid || error "(19) rename should succeed"
16565 wait $rm_pid || error "(20) unlink should succeed"
16569 run_test 801b "modification will be blocked by write barrier"
16572 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 2 MDTs" && return
16576 stop mds2 || error "(1) Fail to stop mds2"
16578 do_facet mgs $LCTL barrier_freeze $FSNAME 30
16580 local b_status=$(barrier_stat)
16581 [ "$b_status" = "'expired'" -o "$b_status" = "'failed'" ] || {
16582 do_facet mgs $LCTL barrier_thaw $FSNAME
16583 error "(2) unexpected barrier status $b_status"
16586 do_facet mgs $LCTL barrier_rescan $FSNAME ||
16587 error "(3) Fail to rescan barrier bitmap"
16589 do_facet mgs $LCTL barrier_freeze $FSNAME 10
16591 b_status=$(barrier_stat)
16592 [ "$b_status" = "'frozen'" ] ||
16593 error "(4) unexpected barrier status $b_status"
16595 do_facet mgs $LCTL barrier_thaw $FSNAME
16596 b_status=$(barrier_stat)
16597 [ "$b_status" = "'thawed'" ] ||
16598 error "(5) unexpected barrier status $b_status"
16600 local devname=$(mdsdevname 2)
16602 start mds2 $devname $MDS_MOUNT_OPTS || error "(6) Fail to start mds2"
16604 do_facet mgs $LCTL barrier_rescan $FSNAME ||
16605 error "(7) Fail to rescan barrier bitmap"
16609 run_test 801c "rescan barrier bitmap"
16611 saved_MGS_MOUNT_OPTS=$MGS_MOUNT_OPTS
16612 saved_MDS_MOUNT_OPTS=$MDS_MOUNT_OPTS
16613 saved_OST_MOUNT_OPTS=$OST_MOUNT_OPTS
16619 MGS_MOUNT_OPTS=$saved_MGS_MOUNT_OPTS
16620 MDS_MOUNT_OPTS=$saved_MDS_MOUNT_OPTS
16621 OST_MOUNT_OPTS=$saved_OST_MOUNT_OPTS
16627 [[ $(lustre_version_code mds1) -lt $(version_code 2.9.55) ]] ||
16628 [[ $(lustre_version_code ost1) -lt $(version_code 2.9.55) ]] &&
16629 skip "Need server version at least 2.9.55" & exit 0
16631 mkdir $DIR/$tdir || error "(1) fail to mkdir"
16633 cp $LUSTRE/tests/test-framework.sh $DIR/$tdir/ ||
16634 error "(2) Fail to copy"
16636 trap cleanup_802 EXIT
16638 # sync by force before remount as readonly
16639 sync; sync_all_data; sleep 3; sync_all_data
16643 MGS_MOUNT_OPTS=$(csa_add "$MGS_MOUNT_OPTS" -o rdonly_dev)
16644 MDS_MOUNT_OPTS=$(csa_add "$MDS_MOUNT_OPTS" -o rdonly_dev)
16645 OST_MOUNT_OPTS=$(csa_add "$OST_MOUNT_OPTS" -o rdonly_dev)
16647 echo "Mount the server as read only"
16648 setupall server_only || error "(3) Fail to start servers"
16650 echo "Mount client without ro should fail"
16651 mount_client $MOUNT &&
16652 error "(4) Mount client without 'ro' should fail"
16654 echo "Mount client with ro should succeed"
16655 mount_client $MOUNT ro ||
16656 error "(5) Mount client with 'ro' should succeed"
16658 echo "Modify should be refused"
16659 touch $DIR/$tdir/guard && error "(6) Touch should fail under ro mode"
16661 echo "Read should be allowed"
16662 diff $LUSTRE/tests/test-framework.sh $DIR/$tdir/test-framework.sh ||
16663 error "(7) Read should succeed under ro mode"
16667 run_test 802 "simulate readonly device"
16670 # tests that do cleanup/setup should be run at the end
16674 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
16676 #define OBD_FAIL_MGC_PAUSE_PROCESS_LOG 0x903
16677 $LCTL set_param fail_loc=0x903
16679 cancel_lru_locks MGC
16681 FAIL_ON_ERROR=true cleanup
16682 FAIL_ON_ERROR=true setup
16684 run_test 900 "umount should not race with any mgc requeue thread"
16687 [ -f $EXT2_DEV ] && rm $EXT2_DEV || true
16688 check_and_cleanup_lustre
16689 if [ "$I_MOUNTED" != "yes" ]; then
16690 lctl set_param debug="$OLDDEBUG" 2> /dev/null || true