2 # -*- tab-width: 8; indent-tabs-mode: t; -*-
4 # Run select tests by setting ONLY, or as arguments to the script.
5 # Skip specific tests by setting EXCEPT.
7 # e.g. ONLY="22 23" or ONLY="`seq 32 39`" or EXCEPT="31"
11 # bug number for skipped test: 13297 2108 9789 3637 9789 3561 12622 5188
12 ALWAYS_EXCEPT=" 42a 42b 42c 42d 45 51d 68b $SANITY_EXCEPT"
13 # UPDATE THE COMMENT ABOVE WITH BUG NUMBERS WHEN CHANGING ALWAYS_EXCEPT!
15 # with LOD/OSP landing
16 # bug number for skipped tests: LU-2036
17 ALWAYS_EXCEPT=" 76 $ALWAYS_EXCEPT"
21 if [ -r /etc/SuSE-release ]
23 local vers=$(grep VERSION /etc/SuSE-release | awk '{print $3}')
24 local patchlev=$(grep PATCHLEVEL /etc/SuSE-release |
26 if [ $vers -eq 11 ] && [ $patchlev -ge 3 ]; then
33 if is_sles11; then # LU-4341
34 ALWAYS_EXCEPT="$ALWAYS_EXCEPT 170"
37 SRCDIR=$(cd $(dirname $0); echo $PWD)
38 export PATH=$PATH:/sbin
43 CHECKSTAT=${CHECKSTAT:-"checkstat -v"}
44 CREATETEST=${CREATETEST:-createtest}
46 LFIND=${LFIND:-"$LFS find"}
47 LVERIFY=${LVERIFY:-ll_dirstripe_verify}
49 OPENFILE=${OPENFILE:-openfile}
50 OPENUNLINK=${OPENUNLINK:-openunlink}
51 export MULTIOP=${MULTIOP:-multiop}
52 READS=${READS:-"reads"}
53 MUNLINK=${MUNLINK:-munlink}
54 SOCKETSERVER=${SOCKETSERVER:-socketserver}
55 SOCKETCLIENT=${SOCKETCLIENT:-socketclient}
56 MEMHOG=${MEMHOG:-memhog}
57 DIRECTIO=${DIRECTIO:-directio}
58 ACCEPTOR_PORT=${ACCEPTOR_PORT:-988}
59 UMOUNT=${UMOUNT:-"umount -d"}
61 CHECK_GRANT=${CHECK_GRANT:-"yes"}
62 GRANT_CHECK_LIST=${GRANT_CHECK_LIST:-""}
63 export PARALLEL=${PARALLEL:-"no"}
65 export NAME=${NAME:-local}
72 LUSTRE=${LUSTRE:-$(cd $(dirname $0)/..; echo $PWD)}
73 LUSTRE_TESTS_API_DIR=${LUSTRE_TESTS_API_DIR:-${LUSTRE}/tests/clientapi}
74 . $LUSTRE/tests/test-framework.sh
76 . ${CONFIG:=$LUSTRE/tests/cfg/${NAME}.sh}
79 [ "$SLOW" = "no" ] && EXCEPT_SLOW="24o 24D 27m 64b 68 71 77f 78 115 124b 300o"
81 if [ $(facet_fstype $SINGLEMDS) = "zfs" ]; then
82 # bug number for skipped test: LU-4536 LU-1957 LU-2805
83 ALWAYS_EXCEPT="$ALWAYS_EXCEPT 65ic 180 184c"
84 [ "$SLOW" = "no" ] && EXCEPT_SLOW="$EXCEPT_SLOW 51b 51ba"
91 pgrep ll_sa > /dev/null && { echo "There are ll_sa thread not exit!"; exit 20; }
92 cleanupall ${FORCE} $* || { echo "FAILed to clean up"; exit 20; }
101 check_swap_layouts_support()
103 $LCTL get_param -n llite.*.sbi_flags | grep -q layout ||
104 { skip "Does not support layout lock."; return 0; }
108 check_and_setup_lustre
113 MDT0=$($LCTL get_param -n mdc.*.mds_server_uuid |
114 awk '{ gsub(/_UUID/,""); print $1 }' | head -n1)
115 LOVNAME=$($LCTL get_param -n llite.*.lov.common_name | tail -n 1)
116 OSTCOUNT=$($LCTL get_param -n lov.$LOVNAME.numobd)
117 STRIPECOUNT=$($LCTL get_param -n lov.$LOVNAME.stripecount)
118 STRIPESIZE=$($LCTL get_param -n lov.$LOVNAME.stripesize)
119 ORIGFREE=$($LCTL get_param -n lov.$LOVNAME.kbytesavail)
120 MAXFREE=${MAXFREE:-$((200000 * $OSTCOUNT))}
122 [ -f $DIR/d52a/foo ] && chattr -a $DIR/d52a/foo
123 [ -f $DIR/d52b/foo ] && chattr -i $DIR/d52b/foo
124 rm -rf $DIR/[Rdfs][0-9]*
126 # $RUNAS_ID may get set incorrectly somewhere else
127 [ $UID -eq 0 -a $RUNAS_ID -eq 0 ] && error "\$RUNAS_ID set to 0, but \$UID is also 0!"
129 check_runas_id $RUNAS_ID $RUNAS_GID $RUNAS
133 if [ "${ONLY}" = "MOUNT" ] ; then
134 echo "Lustre is up, please go on"
138 echo "preparing for tests involving mounts"
139 EXT2_DEV=${EXT2_DEV:-$TMP/SANITY.LOOP}
141 mke2fs -j -F $EXT2_DEV 8000 > /dev/null
142 echo # add a newline after mke2fs.
146 OLDDEBUG=$(lctl get_param -n debug 2> /dev/null)
147 lctl set_param debug=-1 2> /dev/null || true
150 $CHECKSTAT -t file $DIR/$tfile || error "$tfile is not a file"
152 $CHECKSTAT -a $DIR/$tfile || error "$tfile was not removed"
154 run_test 0a "touch; rm ====================="
157 chmod 0755 $DIR || error "chmod 0755 $DIR failed"
158 $CHECKSTAT -p 0755 $DIR || error "$DIR permission is not 0755"
160 run_test 0b "chmod 0755 $DIR ============================="
163 $LCTL get_param mdc.*.import | grep "state: FULL" ||
164 error "import not FULL"
165 $LCTL get_param mdc.*.import | grep "target: $FSNAME-MDT" ||
168 run_test 0c "check import proc ============================="
171 test_mkdir -p $DIR/$tdir || error "mkdir $tdir failed"
172 test_mkdir -p $DIR/$tdir/d2 || error "mkdir $tdir/d2 failed"
173 test_mkdir $DIR/$tdir/d2 && error "we expect EEXIST, but not returned"
174 $CHECKSTAT -t dir $DIR/$tdir/d2 || error "$tdir/d2 is not a dir"
177 $CHECKSTAT -a $DIR/$tdir || error "$tdir was not removed"
179 run_test 1 "mkdir; remkdir; rmdir =============================="
182 test_mkdir -p $DIR/$tdir || error "mkdir $tdir failed"
183 touch $DIR/$tdir/$tfile || error "touch $tdir/$tfile failed"
184 $CHECKSTAT -t file $DIR/$tdir/$tfile || error "$tdir/$tfile not a file"
186 $CHECKSTAT -a $DIR/$tdir/$tfile || error "$tdir/$file is not removed"
188 run_test 2 "mkdir; touch; rmdir; check file ===================="
191 test_mkdir -p $DIR/$tdir || error "mkdir $tdir failed"
192 $CHECKSTAT -t dir $DIR/$tdir || error "$tdir is not a directory"
193 touch $DIR/$tdir/$tfile
194 $CHECKSTAT -t file $DIR/$tdir/$tfile || error "$tdir/$tfile not a file"
196 $CHECKSTAT -a $DIR/$tdir || error "$tdir is not removed"
198 run_test 3 "mkdir; touch; rmdir; check dir ====================="
200 # LU-4471 - failed rmdir on remote directories still removes directory on MDT0
204 test_mkdir $DIR/$tdir ||
205 error "Create remote directory failed"
207 touch $DIR/$tdir/$tfile ||
208 error "Create file under remote directory failed"
211 error "Expect error removing in-use dir $DIR/$tdir"
213 test -d $DIR/$tdir || error "Remote directory disappeared"
215 rm -rf $DIR/$tdir || error "remove remote dir error"
217 run_test 4 "mkdir; touch dir/file; rmdir; checkdir (expect error)"
220 test_mkdir -p $DIR/$tdir || error "mkdir $tdir failed"
221 test_mkdir $DIR/$tdir/d2 || error "mkdir $tdir/d2 failed"
222 chmod 0707 $DIR/$tdir/d2 || error "chmod 0707 $tdir/d2 failed"
223 $CHECKSTAT -t dir -p 0707 $DIR/$tdir/d2 || error "$tdir/d2 not mode 707"
224 $CHECKSTAT -t dir $DIR/$tdir/d2 || error "$tdir/d2 is not a directory"
226 run_test 5 "mkdir .../d5 .../d5/d2; chmod .../d5/d2 ============"
229 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
230 chmod 0666 $DIR/$tfile || error "chmod 0666 $tfile failed"
231 $CHECKSTAT -t file -p 0666 -u \#$UID $DIR/$tfile ||
232 error "$tfile does not have perm 0666 or UID $UID"
233 $RUNAS chmod 0444 $DIR/$tfile && error "chmod $tfile worked on UID $UID"
234 $CHECKSTAT -t file -p 0666 -u \#$UID $DIR/$tfile ||
235 error "$tfile should be 0666 and owned by UID $UID"
237 run_test 6a "touch f6a; chmod f6a; $RUNAS chmod f6a (should return error) =="
240 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID" && return
242 chown $RUNAS_ID $DIR/$tfile || error "chown $RUNAS_ID $file failed"
243 $CHECKSTAT -t file -u \#$RUNAS_ID $DIR/$tfile ||
244 error "$tfile should be owned by UID $RUNAS_ID"
245 $RUNAS chown $UID $DIR/$tfile && error "chown $UID $file succeeded"
246 $CHECKSTAT -t file -u \#$RUNAS_ID $DIR/$tfile ||
247 error "$tfile should be owned by UID $RUNAS_ID"
249 run_test 6c "touch f6c; chown f6c; $RUNAS chown f6c (should return error) =="
252 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID" && return
254 chgrp $RUNAS_ID $DIR/$tfile || error "chgrp $RUNAS_ID $file failed"
255 $CHECKSTAT -t file -u \#$UID -g \#$RUNAS_ID $DIR/$tfile ||
256 error "$tfile should be owned by GID $UID"
257 $RUNAS chgrp $UID $DIR/$tfile && error "chgrp $UID $file succeeded"
258 $CHECKSTAT -t file -u \#$UID -g \#$RUNAS_ID $DIR/$tfile ||
259 error "$tfile should be owned by UID $UID and GID $RUNAS_ID"
261 run_test 6e "touch f6e; chgrp f6e; $RUNAS chgrp f6e (should return error) =="
264 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID" && return
265 test_mkdir $DIR/$tdir || error "mkdir $tfile failed"
266 chmod 777 $DIR/$tdir || error "chmod 0777 $tdir failed"
267 $RUNAS mkdir $DIR/$tdir/d || error "mkdir $tdir/d failed"
268 chmod g+s $DIR/$tdir/d || error "chmod g+s $tdir/d failed"
269 test_mkdir $DIR/$tdir/d/subdir || error "mkdir $tdir/d/subdir failed"
270 $CHECKSTAT -g \#$RUNAS_GID $DIR/$tdir/d/subdir ||
271 error "$tdir/d/subdir should be GID $RUNAS_GID"
273 run_test 6g "Is new dir in sgid dir inheriting group?"
275 test_6h() { # bug 7331
276 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID" && return
277 touch $DIR/$tfile || error "touch failed"
278 chown $RUNAS_ID:$RUNAS_GID $DIR/$tfile || error "initial chown failed"
279 $RUNAS -G$RUNAS_GID chown $RUNAS_ID:0 $DIR/$tfile &&
280 error "chown $RUNAS_ID:0 $tfile worked as GID $RUNAS_GID"
281 $CHECKSTAT -t file -u \#$RUNAS_ID -g \#$RUNAS_GID $DIR/$tfile ||
282 error "$tdir/$tfile should be UID $RUNAS_UID GID $RUNAS_GID"
284 run_test 6h "$RUNAS chown RUNAS_ID.0 .../f6h (should return error)"
287 test_mkdir $DIR/$tdir
288 $MCREATE $DIR/$tdir/$tfile
289 chmod 0666 $DIR/$tdir/$tfile
290 $CHECKSTAT -t file -p 0666 $DIR/$tdir/$tfile ||
291 error "$tdir/$tfile should be mode 0666"
293 run_test 7a "mkdir .../d7; mcreate .../d7/f; chmod .../d7/f ===="
296 if [ ! -d $DIR/$tdir ]; then
297 test_mkdir $DIR/$tdir
299 $MCREATE $DIR/$tdir/$tfile
300 echo -n foo > $DIR/$tdir/$tfile
301 [ "$(cat $DIR/$tdir/$tfile)" = "foo" ] || error "$tdir/$tfile not 'foo'"
302 $CHECKSTAT -t file -s 3 $DIR/$tdir/$tfile || error "$tfile size not 3"
304 run_test 7b "mkdir .../d7; mcreate d7/f2; echo foo > d7/f2 ====="
307 test_mkdir $DIR/$tdir
308 touch $DIR/$tdir/$tfile
309 chmod 0666 $DIR/$tdir/$tfile
310 $CHECKSTAT -t file -p 0666 $DIR/$tdir/$tfile ||
311 error "$tfile mode not 0666"
313 run_test 8 "mkdir .../d8; touch .../d8/f; chmod .../d8/f ======="
316 test_mkdir $DIR/$tdir
317 test_mkdir $DIR/$tdir/d2
318 test_mkdir $DIR/$tdir/d2/d3
319 $CHECKSTAT -t dir $DIR/$tdir/d2/d3 || error "$tdir/d2/d3 not a dir"
321 run_test 9 "mkdir .../d9 .../d9/d2 .../d9/d2/d3 ================"
324 test_mkdir $DIR/$tdir
325 test_mkdir $DIR/$tdir/d2
326 touch $DIR/$tdir/d2/$tfile
327 $CHECKSTAT -t file $DIR/$tdir/d2/$tfile ||
328 error "$tdir/d2/$tfile not a file"
330 run_test 10 "mkdir .../d10 .../d10/d2; touch .../d10/d2/f ======"
333 test_mkdir $DIR/$tdir
334 test_mkdir $DIR/$tdir/d2
335 chmod 0666 $DIR/$tdir/d2
336 chmod 0705 $DIR/$tdir/d2
337 $CHECKSTAT -t dir -p 0705 $DIR/$tdir/d2 ||
338 error "$tdir/d2 mode not 0705"
340 run_test 11 "mkdir .../d11 d11/d2; chmod .../d11/d2 ============"
343 test_mkdir $DIR/$tdir
344 touch $DIR/$tdir/$tfile
345 chmod 0666 $DIR/$tdir/$tfile
346 chmod 0654 $DIR/$tdir/$tfile
347 $CHECKSTAT -t file -p 0654 $DIR/$tdir/$tfile ||
348 error "$tdir/d2 mode not 0654"
350 run_test 12 "touch .../d12/f; chmod .../d12/f .../d12/f ========"
353 test_mkdir $DIR/$tdir
354 dd if=/dev/zero of=$DIR/$tdir/$tfile count=10
356 $CHECKSTAT -t file -s 0 $DIR/$tdir/$tfile ||
357 error "$tdir/$tfile size not 0 after truncate"
359 run_test 13 "creat .../d13/f; dd .../d13/f; > .../d13/f ========"
362 test_mkdir $DIR/$tdir
363 touch $DIR/$tdir/$tfile
365 $CHECKSTAT -a $DIR/$tdir/$tfile || error "$tdir/$tfile not removed"
367 run_test 14 "touch .../d14/f; rm .../d14/f; rm .../d14/f ======="
370 test_mkdir $DIR/$tdir
371 touch $DIR/$tdir/$tfile
372 mv $DIR/$tdir/$tfile $DIR/$tdir/${tfile}_2
373 $CHECKSTAT -t file $DIR/$tdir/${tfile}_2 ||
374 error "$tdir/${tfile_2} not a file after rename"
375 rm $DIR/$tdir/${tfile}_2 || error "unlink failed after rename"
377 run_test 15 "touch .../d15/f; mv .../d15/f .../d15/f2 =========="
380 test_mkdir $DIR/$tdir
381 touch $DIR/$tdir/$tfile
382 rm -rf $DIR/$tdir/$tfile
383 $CHECKSTAT -a $DIR/$tdir/$tfile || error "$tdir/$tfile not removed"
385 run_test 16 "touch .../d16/f; rm -rf .../d16/f ================="
388 test_mkdir -p $DIR/$tdir
389 touch $DIR/$tdir/$tfile
390 ln -s $DIR/$tdir/$tfile $DIR/$tdir/l-exist
392 $CHECKSTAT -l $DIR/$tdir/$tfile $DIR/$tdir/l-exist ||
393 error "$tdir/l-exist not a symlink"
394 $CHECKSTAT -f -t f $DIR/$tdir/l-exist ||
395 error "$tdir/l-exist not referencing a file"
396 rm -f $DIR/$tdir/l-exist
397 $CHECKSTAT -a $DIR/$tdir/l-exist || error "$tdir/l-exist not removed"
399 run_test 17a "symlinks: create, remove (real) =================="
402 test_mkdir -p $DIR/$tdir
403 ln -s no-such-file $DIR/$tdir/l-dangle
405 $CHECKSTAT -l no-such-file $DIR/$tdir/l-dangle ||
406 error "$tdir/l-dangle not referencing no-such-file"
407 $CHECKSTAT -fa $DIR/$tdir/l-dangle ||
408 error "$tdir/l-dangle not referencing non-existent file"
409 rm -f $DIR/$tdir/l-dangle
410 $CHECKSTAT -a $DIR/$tdir/l-dangle || error "$tdir/l-dangle not removed"
412 run_test 17b "symlinks: create, remove (dangling) =============="
414 test_17c() { # bug 3440 - don't save failed open RPC for replay
415 test_mkdir -p $DIR/$tdir
416 ln -s foo $DIR/$tdir/$tfile
417 cat $DIR/$tdir/$tfile && error "opened non-existent symlink" || true
419 run_test 17c "symlinks: open dangling (should return error) ===="
422 test_mkdir -p $DIR/$tdir
423 ln -s foo $DIR/$tdir/$tfile
424 touch $DIR/$tdir/$tfile || error "creating to new symlink"
426 run_test 17d "symlinks: create dangling ========================"
429 test_mkdir -p $DIR/$tdir
430 local foo=$DIR/$tdir/$tfile
431 ln -s $foo $foo || error "create symlink failed"
432 ls -l $foo || error "ls -l failed"
433 ls $foo && error "ls not failed" || true
435 run_test 17e "symlinks: create recursive symlink (should return error) ===="
438 test_mkdir -p $DIR/$tdir
439 ln -s 1234567890/2234567890/3234567890/4234567890 $DIR/$tdir/111
440 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890 $DIR/$tdir/222
441 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890 $DIR/$tdir/333
442 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890/9234567890/a234567890/b234567890 $DIR/$tdir/444
443 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890/9234567890/a234567890/b234567890/c234567890/d234567890/f234567890 $DIR/$tdir/555
444 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
447 run_test 17f "symlinks: long and very long symlink name ========================"
449 # str_repeat(S, N) generate a string that is string S repeated N times
454 while [ $((n -= 1)) -ge 0 ]; do
460 # Long symlinks and LU-2241
462 test_mkdir -p $DIR/$tdir
463 local TESTS="59 60 61 4094 4095"
465 # Fix for inode size boundary in 2.1.4
466 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.1.4) ] &&
469 # Patch not applied to 2.2 or 2.3 branches
470 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] &&
471 [ $(lustre_version_code $SINGLEMDS) -le $(version_code 2.3.55) ] &&
474 # skip long symlink name for rhel6.5.
475 # rhel6.5 has a limit (PATH_MAX - sizeof(struct filename))
476 grep -q '6.5' /etc/redhat-release &>/dev/null &&
477 TESTS="59 60 61 4062 4063"
480 local SYMNAME=$(str_repeat 'x' $i)
481 ln -s $SYMNAME $DIR/$tdir/f$i || error "failed $i-char symlink"
482 readlink $DIR/$tdir/f$i || error "failed $i-char readlink"
485 run_test 17g "symlinks: really long symlink name and inode boundaries"
487 test_17h() { #bug 17378
488 remote_mds_nodsh && skip "remote MDS with nodsh" && return
489 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
491 test_mkdir -p $DIR/$tdir
492 if [[ $MDSCOUNT -gt 1 ]]; then
493 mdt_idx=$($LFS getdirstripe -i $DIR/$tdir)
497 $SETSTRIPE -c -1 $DIR/$tdir
498 #define OBD_FAIL_MDS_LOV_PREP_CREATE 0x141
499 do_facet mds$((mdt_idx + 1)) lctl set_param fail_loc=0x80000141
500 touch $DIR/$tdir/$tfile || true
502 run_test 17h "create objects: lov_free_memmd() doesn't lbug"
504 test_17i() { #bug 20018
505 remote_mds_nodsh && skip "remote MDS with nodsh" && return
506 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
507 test_mkdir -c1 $DIR/$tdir
508 local foo=$DIR/$tdir/$tfile
510 if [[ $MDSCOUNT -gt 1 ]]; then
511 mdt_idx=$($LFS getdirstripe -i $DIR/$tdir)
515 ln -s $foo $foo || error "create symlink failed"
516 #define OBD_FAIL_MDS_READLINK_EPROTO 0x143
517 do_facet mds$((mdt_idx + 1)) lctl set_param fail_loc=0x80000143
518 ls -l $foo && error "error not detected"
521 run_test 17i "don't panic on short symlink"
523 test_17k() { #bug 22301
524 [[ -z "$(which rsync 2>/dev/null)" ]] &&
525 skip "no rsync command" && return 0
526 rsync --help | grep -q xattr ||
527 skip_env "$(rsync --version | head -n1) does not support xattrs"
528 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return 0
529 test_mkdir -p $DIR/$tdir
530 test_mkdir -p $DIR/$tdir.new
531 touch $DIR/$tdir/$tfile
532 ln -s $DIR/$tdir/$tfile $DIR/$tdir/$tfile.lnk
533 rsync -av -X $DIR/$tdir/ $DIR/$tdir.new ||
534 error "rsync failed with xattrs enabled"
536 run_test 17k "symlinks: rsync with xattrs enabled ========================="
538 test_17l() { # LU-279
539 [[ -z "$(which getfattr 2>/dev/null)" ]] &&
540 skip "no getfattr command" && return 0
541 test_mkdir -p $DIR/$tdir
542 touch $DIR/$tdir/$tfile
543 ln -s $DIR/$tdir/$tfile $DIR/$tdir/$tfile.lnk
544 for path in "$DIR/$tdir" "$DIR/$tdir/$tfile" "$DIR/$tdir/$tfile.lnk"; do
545 # -h to not follow symlinks. -m '' to list all the xattrs.
546 # grep to remove first line: '# file: $path'.
547 for xattr in `getfattr -hm '' $path 2>/dev/null | grep -v '^#'`;
549 lgetxattr_size_check $path $xattr ||
550 error "lgetxattr_size_check $path $xattr failed"
554 run_test 17l "Ensure lgetxattr's returned xattr size is consistent ========"
558 local short_sym="0123456789"
559 local WDIR=$DIR/${tdir}m
566 remote_mds_nodsh && skip "remote MDS with nodsh" && return
567 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] &&
568 [ $(lustre_version_code $SINGLEMDS) -le $(version_code 2.2.93) ] &&
569 skip "MDS 2.2.0-2.2.93 do not NUL-terminate symlinks" && return
571 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
572 skip "only for ldiskfs MDT" && return 0
574 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
578 # create a long symlink file
579 for ((i = 0; i < 4; ++i)); do
580 long_sym=${long_sym}${long_sym}
583 echo "create 512 short and long symlink files under $WDIR"
584 for ((i = 0; i < 256; ++i)); do
585 ln -sf ${long_sym}"a5a5" $WDIR/long-$i
586 ln -sf ${short_sym}"a5a5" $WDIR/short-$i
592 wait_delete_completed
594 echo "recreate the 512 symlink files with a shorter string"
595 for ((i = 0; i < 512; ++i)); do
596 # rewrite the symlink file with a shorter string
597 ln -sf ${long_sym} $WDIR/long-$i
598 ln -sf ${short_sym} $WDIR/short-$i
601 mds_index=$($LFS getstripe -M $WDIR)
602 mds_index=$((mds_index+1))
603 devname=$(mdsdevname $mds_index)
604 cmd="$E2FSCK -fnvd $devname"
606 echo "stop and checking mds${mds_index}: $cmd"
607 # e2fsck should not return error
609 do_facet mds${mds_index} $cmd || rc=$?
611 start mds${mds_index} $devname $MDS_MOUNT_OPTS || error "start failed"
612 df $MOUNT > /dev/null 2>&1
613 [ $rc -ne 0 ] && error "e2fsck should not report error upon "\
614 "short/long symlink MDT: rc=$rc"
617 run_test 17m "run e2fsck against MDT which contains short/long symlink"
619 check_fs_consistency_17n() {
625 # create/unlink in 17n only change 2 MDTs(MDT1/MDT2),
626 # so it only check MDT1/MDT2 instead of all of MDTs.
627 for mdt_index in $(seq 1 2); do
628 devname=$(mdsdevname $mdt_index)
629 cmd="$E2FSCK -fnvd $devname"
631 echo "stop and checking mds${mdt_index}: $cmd"
632 # e2fsck should not return error
634 do_facet mds${mdt_index} $cmd || rc=$?
636 start mds${mdt_index} $devname $MDS_MOUNT_OPTS ||
637 error "mount mds${mdt_index} failed"
638 df $MOUNT > /dev/null 2>&1
639 [ $rc -ne 0 ] && break
647 remote_mds_nodsh && skip "remote MDS with nodsh" && return
648 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] &&
649 [ $(lustre_version_code $SINGLEMDS) -le $(version_code 2.2.93) ] &&
650 skip "MDS 2.2.0-2.2.93 do not NUL-terminate symlinks" && return
652 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
653 skip "only for ldiskfs MDT" && return 0
655 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 2 MDTs" && return
657 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
659 test_mkdir $DIR/$tdir
660 for ((i=0; i<10; i++)); do
661 $LFS mkdir -i1 -c2 $DIR/$tdir/remote_dir_${i} ||
662 error "create remote dir error $i"
663 createmany -o $DIR/$tdir/remote_dir_${i}/f 10 ||
664 error "create files under remote dir failed $i"
667 check_fs_consistency_17n ||
668 error "e2fsck report error after create files under remote dir"
670 for ((i = 0; i < 10; i++)); do
671 rm -rf $DIR/$tdir/remote_dir_${i} ||
672 error "destroy remote dir error $i"
675 check_fs_consistency_17n ||
676 error "e2fsck report error after unlink files under remote dir"
678 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.50) ] &&
679 skip "lustre < 2.4.50 does not support migrate mv " && return
681 for ((i = 0; i < 10; i++)); do
682 mkdir -p $DIR/$tdir/remote_dir_${i}
683 createmany -o $DIR/$tdir/remote_dir_${i}/f 10 ||
684 error "create files under remote dir failed $i"
685 $LFS migrate --mdt-index 1 $DIR/$tdir/remote_dir_${i} ||
686 error "migrate remote dir error $i"
688 check_fs_consistency_17n || error "e2fsck report error after migration"
690 for ((i = 0; i < 10; i++)); do
691 rm -rf $DIR/$tdir/remote_dir_${i} ||
692 error "destroy remote dir error $i"
695 check_fs_consistency_17n || error "e2fsck report error after unlink"
697 run_test 17n "run e2fsck against master/slave MDT which contains remote dir"
700 remote_mds_nodsh && skip "remote MDS with nodsh" && return
701 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.3.64) ] &&
702 skip "Need MDS version at least 2.3.64" && return
704 local WDIR=$DIR/${tdir}o
709 mdt_index=$($LFS getstripe -M $WDIR)
710 mdt_index=$((mdt_index+1))
714 #fail mds will wait the failover finish then set
715 #following fail_loc to avoid interfer the recovery process.
718 #define OBD_FAIL_OSD_LMA_INCOMPAT 0x194
719 do_facet mds${mdt_index} lctl set_param fail_loc=0x194
720 ls -l $WDIR/$tfile && rc=1
721 do_facet mds${mdt_index} lctl set_param fail_loc=0
722 [[ $rc -ne 0 ]] && error "stat file should fail"
725 run_test 17o "stat file with incompat LMA feature"
728 touch $DIR/$tfile || error "Failed to touch $DIR/$tfile: $?"
729 ls $DIR || error "Failed to ls $DIR: $?"
731 run_test 18 "touch .../f ; ls ... =============================="
737 $CHECKSTAT -a $DIR/$tfile || error "$tfile was not removed"
739 run_test 19a "touch .../f19 ; ls -l ... ; rm .../f19 ==========="
742 ls -l $DIR/$tfile && error "ls -l $tfile failed"|| true
744 run_test 19b "ls -l .../f19 (should return error) =============="
747 [ $RUNAS_ID -eq $UID ] &&
748 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
749 $RUNAS touch $DIR/$tfile && error "create non-root file failed" || true
751 run_test 19c "$RUNAS touch .../f19 (should return error) =="
754 cat $DIR/f19 && error || true
756 run_test 19d "cat .../f19 (should return error) =============="
768 $CHECKSTAT -a $DIR/$tfile || error "$tfile was not removed"
770 run_test 20 "touch .../f ; ls -l ... ==========================="
773 test_mkdir -p $DIR/$tdir
774 [ -f $DIR/$tdir/dangle ] && rm -f $DIR/$tdir/dangle
775 ln -s dangle $DIR/$tdir/link
776 echo foo >> $DIR/$tdir/link
777 cat $DIR/$tdir/dangle
778 $CHECKSTAT -t link $DIR/$tdir/link || error "$tdir/link not a link"
779 $CHECKSTAT -f -t file $DIR/$tdir/link ||
780 error "$tdir/link not linked to a file"
782 run_test 21 "write to dangling link ============================"
786 test_mkdir -p $DIR/$tdir
787 chown $RUNAS_ID:$RUNAS_GID $WDIR
788 (cd $WDIR || error "cd $WDIR failed";
789 $RUNAS tar cf - /etc/hosts /etc/sysconfig/network | \
791 ls -lR $WDIR/etc || error "ls -lR $WDIR/etc failed"
792 $CHECKSTAT -t dir $WDIR/etc || error "checkstat -t dir failed"
793 $CHECKSTAT -u \#$RUNAS_ID -g \#$RUNAS_GID $WDIR/etc || error "checkstat -u failed"
795 run_test 22 "unpack tar archive as non-root user ==============="
799 test_mkdir -p $DIR/$tdir
800 local file=$DIR/$tdir/$tfile
802 openfile -f O_CREAT:O_EXCL $file || error "$file create failed"
803 openfile -f O_CREAT:O_EXCL $file &&
804 error "$file recreate succeeded" || true
806 run_test 23a "O_CREAT|O_EXCL in subdir =========================="
808 test_23b() { # bug 18988
809 test_mkdir -p $DIR/$tdir
810 local file=$DIR/$tdir/$tfile
813 echo foo > $file || error "write filed"
814 echo bar >> $file || error "append filed"
815 $CHECKSTAT -s 8 $file || error "wrong size"
818 run_test 23b "O_APPEND check =========================="
822 echo '-- same directory rename'
823 test_mkdir $DIR/$tdir
824 touch $DIR/$tdir/$tfile.1
825 mv $DIR/$tdir/$tfile.1 $DIR/$tdir/$tfile.2
826 $CHECKSTAT -t file $DIR/$tdir/$tfile.2 || error "$tfile.2 not a file"
828 run_test 24a "rename file to non-existent target"
831 test_mkdir $DIR/$tdir
832 touch $DIR/$tdir/$tfile.{1,2}
833 mv $DIR/$tdir/$tfile.1 $DIR/$tdir/$tfile.2
834 $CHECKSTAT -a $DIR/$tdir/$tfile.1 || error "$tfile.1 exists"
835 $CHECKSTAT -t file $DIR/$tdir/$tfile.2 || error "$tfile.2 not a file"
837 run_test 24b "rename file to existing target"
840 test_mkdir $DIR/$tdir
841 test_mkdir $DIR/$tdir/d$testnum.1
842 mv $DIR/$tdir/d$testnum.1 $DIR/$tdir/d$testnum.2
843 $CHECKSTAT -a $DIR/$tdir/d$testnum.1 || error "d$testnum.1 exists"
844 $CHECKSTAT -t dir $DIR/$tdir/d$testnum.2 || error "d$testnum.2 not dir"
846 run_test 24c "rename directory to non-existent target"
849 test_mkdir -c1 $DIR/$tdir
850 test_mkdir -c1 $DIR/$tdir/d$testnum.1
851 test_mkdir -c1 $DIR/$tdir/d$testnum.2
852 mrename $DIR/$tdir/d$testnum.1 $DIR/$tdir/d$testnum.2
853 $CHECKSTAT -a $DIR/$tdir/d$testnum.1 || error "d$testnum.1 exists"
854 $CHECKSTAT -t dir $DIR/$tdir/d$testnum.2 || error "d$testnum.2 not dir"
856 run_test 24d "rename directory to existing target"
859 echo '-- cross directory renames --'
863 mv $DIR/R5a/f $DIR/R5b/g
864 $CHECKSTAT -a $DIR/R5a/f || error
865 $CHECKSTAT -t file $DIR/R5b/g || error
867 run_test 24e "touch .../R5a/f; rename .../R5a/f .../R5b/g ======"
872 touch $DIR/R6a/f $DIR/R6b/g
873 mv $DIR/R6a/f $DIR/R6b/g
874 $CHECKSTAT -a $DIR/R6a/f || error
875 $CHECKSTAT -t file $DIR/R6b/g || error
877 run_test 24f "touch .../R6a/f R6b/g; mv .../R6a/f .../R6b/g ===="
882 test_mkdir $DIR/R7a/d
883 mv $DIR/R7a/d $DIR/R7b/e
884 $CHECKSTAT -a $DIR/R7a/d || error
885 $CHECKSTAT -t dir $DIR/R7b/e || error
887 run_test 24g "mkdir .../R7{a,b}/d; mv .../R7a/d .../R7b/e ======"
890 test_mkdir -c1 $DIR/R8a
891 test_mkdir -c1 $DIR/R8b
892 test_mkdir -c1 $DIR/R8a/d
893 test_mkdir -c1 $DIR/R8b/e
894 mrename $DIR/R8a/d $DIR/R8b/e
895 $CHECKSTAT -a $DIR/R8a/d || error
896 $CHECKSTAT -t dir $DIR/R8b/e || error
898 run_test 24h "mkdir .../R8{a,b}/{d,e}; rename .../R8a/d .../R8b/e"
901 echo "-- rename error cases"
905 mrename $DIR/R9/f $DIR/R9/a
906 $CHECKSTAT -t file $DIR/R9/f || error
907 $CHECKSTAT -t dir $DIR/R9/a || error
908 $CHECKSTAT -a $DIR/R9/a/f || error
910 run_test 24i "rename file to dir error: touch f ; mkdir a ; rename f a"
914 mrename $DIR/R10/f $DIR/R10/g
915 $CHECKSTAT -t dir $DIR/R10 || error
916 $CHECKSTAT -a $DIR/R10/f || error
917 $CHECKSTAT -a $DIR/R10/g || error
919 run_test 24j "source does not exist ============================"
923 test_mkdir $DIR/R11a/d
925 mv $DIR/R11a/f $DIR/R11a/d
926 $CHECKSTAT -a $DIR/R11a/f || error
927 $CHECKSTAT -t file $DIR/R11a/d/f || error
929 run_test 24k "touch .../R11a/f; mv .../R11a/f .../R11a/d ======="
931 # bug 2429 - rename foo foo foo creates invalid file
934 $MULTIOP $f OcNs || error
936 run_test 24l "Renaming a file to itself ========================"
940 $MULTIOP $f OcLN ${f}2 ${f}2 || error "link ${f}2 ${f}2 failed"
941 # on ext3 this does not remove either the source or target files
942 # though the "expected" operation would be to remove the source
943 $CHECKSTAT -t file ${f} || error "${f} missing"
944 $CHECKSTAT -t file ${f}2 || error "${f}2 missing"
946 run_test 24m "Renaming a file to a hard link to itself ========="
950 # this stats the old file after it was renamed, so it should fail
954 $CHECKSTAT ${f}.rename
957 run_test 24n "Statting the old file after renaming (Posix rename 2)"
960 test_mkdir -p $DIR/d24o
961 rename_many -s random -v -n 10 $DIR/d24o
963 run_test 24o "rename of files during htree split ==============="
968 DIRINO=`ls -lid $DIR/R12a | awk '{ print $1 }'`
969 mrename $DIR/R12a $DIR/R12b
970 $CHECKSTAT -a $DIR/R12a || error
971 $CHECKSTAT -t dir $DIR/R12b || error
972 DIRINO2=`ls -lid $DIR/R12b | awk '{ print $1 }'`
973 [ "$DIRINO" = "$DIRINO2" ] || error "R12a $DIRINO != R12b $DIRINO2"
975 run_test 24p "mkdir .../R12{a,b}; rename .../R12a .../R12b"
977 cleanup_multiop_pause() {
983 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
986 local DIRINO=$(ls -lid $DIR/R13a | awk '{ print $1 }')
987 multiop_bg_pause $DIR/R13b D_c || error "multiop failed to start"
990 trap cleanup_multiop_pause EXIT
991 mrename $DIR/R13a $DIR/R13b
992 $CHECKSTAT -a $DIR/R13a || error "R13a still exists"
993 $CHECKSTAT -t dir $DIR/R13b || error "R13b does not exist"
994 local DIRINO2=$(ls -lid $DIR/R13b | awk '{ print $1 }')
995 [ "$DIRINO" = "$DIRINO2" ] || error "R13a $DIRINO != R13b $DIRINO2"
996 cleanup_multiop_pause
997 wait $MULTIPID || error "multiop close failed"
999 run_test 24q "mkdir .../R13{a,b}; open R13b rename R13a R13b ==="
1001 test_24r() { #bug 3789
1002 test_mkdir $DIR/R14a
1003 test_mkdir $DIR/R14a/b
1004 mrename $DIR/R14a $DIR/R14a/b && error "rename to subdir worked!"
1005 $CHECKSTAT -t dir $DIR/R14a || error "$DIR/R14a missing"
1006 $CHECKSTAT -t dir $DIR/R14a/b || error "$DIR/R14a/b missing"
1008 run_test 24r "mkdir .../R14a/b; rename .../R14a .../R14a/b ====="
1011 test_mkdir $DIR/R15a
1012 test_mkdir $DIR/R15a/b
1013 test_mkdir $DIR/R15a/b/c
1014 mrename $DIR/R15a $DIR/R15a/b/c && error "rename to sub-subdir worked!"
1015 $CHECKSTAT -t dir $DIR/R15a || error "$DIR/R15a missing"
1016 $CHECKSTAT -t dir $DIR/R15a/b/c || error "$DIR/R15a/b/c missing"
1018 run_test 24s "mkdir .../R15a/b/c; rename .../R15a .../R15a/b/c ="
1020 test_mkdir $DIR/R16a
1021 test_mkdir $DIR/R16a/b
1022 test_mkdir $DIR/R16a/b/c
1023 mrename $DIR/R16a/b/c $DIR/R16a && error "rename to sub-subdir worked!"
1024 $CHECKSTAT -t dir $DIR/R16a || error "$DIR/R16a missing"
1025 $CHECKSTAT -t dir $DIR/R16a/b/c || error "$DIR/R16a/b/c missing"
1027 run_test 24t "mkdir .../R16a/b/c; rename .../R16a/b/c .../R16a ="
1029 test_24u() { # bug12192
1030 $MULTIOP $DIR/$tfile C2w$((2048 * 1024))c || error
1031 $CHECKSTAT -s $((2048 * 1024)) $DIR/$tfile || error "wrong file size"
1033 run_test 24u "create stripe file"
1039 simple_cleanup_common() {
1042 wait_delete_completed
1045 max_pages_per_rpc() {
1046 $LCTL get_param -n mdc.*.max_pages_per_rpc | head -n1
1050 local NRFILES=100000
1051 local FREE_INODES=$(mdt_free_inodes 0)
1052 [[ $FREE_INODES -lt $NRFILES ]] &&
1053 skip "not enough free inodes $FREE_INODES required $NRFILES" &&
1056 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1057 trap simple_cleanup_common EXIT
1059 # Performance issue on ZFS see LU-4072 (c.f. LU-2887)
1060 [ $(facet_fstype $SINGLEMDS) = "zfs" ] && NRFILES=10000
1062 test_mkdir -p $DIR/$tdir
1063 createmany -m $DIR/$tdir/$tfile $NRFILES
1065 cancel_lru_locks mdc
1066 lctl set_param mdc.*.stats clear
1068 ls $DIR/$tdir >/dev/null || error "error in listing large dir"
1070 # LU-5 large readdir
1071 # DIRENT_SIZE = 32 bytes for sizeof(struct lu_dirent) +
1072 # 8 bytes for name(filename is mostly 5 in this test) +
1073 # 8 bytes for luda_type
1074 # take into account of overhead in lu_dirpage header and end mark in
1075 # each page, plus one in RPC_NUM calculation.
1077 RPC_SIZE=$(($(max_pages_per_rpc) * $(page_size)))
1078 RPC_NUM=$(((NRFILES * DIRENT_SIZE + RPC_SIZE - 1) / RPC_SIZE + 1))
1079 mds_readpage=$(lctl get_param mdc.*MDT0000*.stats |
1080 awk '/^mds_readpage/ {print $2}')
1081 [[ $mds_readpage -gt $RPC_NUM ]] &&
1082 error "large readdir doesn't take effect"
1084 simple_cleanup_common
1086 run_test 24v "list directory with large files (handle hash collision, bug: 17560)"
1088 test_24w() { # bug21506
1090 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=4096 || return 1
1091 dd if=/dev/zero bs=$SZ1 count=1 >> $DIR/$tfile || return 2
1092 dd if=$DIR/$tfile of=$DIR/${tfile}_left bs=1M skip=4097 || return 3
1093 SZ2=`ls -l $DIR/${tfile}_left | awk '{print $5}'`
1094 [[ "$SZ1" -eq "$SZ2" ]] ||
1095 error "Error reading at the end of the file $tfile"
1097 run_test 24w "Reading a file larger than 4Gb"
1100 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 2 MDTs" && return
1101 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1103 local remote_dir=$DIR/$tdir/remote_dir
1105 test_mkdir -p $DIR/$tdir
1106 $LFS mkdir -i $MDTIDX $remote_dir ||
1107 error "create remote directory failed"
1109 test_mkdir -p $DIR/$tdir/src_dir
1110 touch $DIR/$tdir/src_file
1111 test_mkdir -p $remote_dir/tgt_dir
1112 touch $remote_dir/tgt_file
1114 mrename $DIR/$tdir/src_dir $remote_dir/tgt_dir ||
1115 error "rename dir cross MDT failed!"
1117 mrename $DIR/$tdir/src_file $remote_dir/tgt_file ||
1118 error "rename file cross MDT failed!"
1120 touch $DIR/$tdir/ln_file
1121 ln $DIR/$tdir/ln_file $remote_dir/ln_name ||
1122 error "ln file cross MDT failed"
1124 rm -rf $DIR/$tdir || error "Can not delete directories"
1126 run_test 24x "cross MDT rename/link"
1129 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 2 MDTs" && return
1130 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1132 local remote_dir=$DIR/$tdir/remote_dir
1134 test_mkdir -p $DIR/$tdir
1135 $LFS mkdir -i $MDTIDX $remote_dir ||
1136 error "create remote directory failed"
1138 test_mkdir -p $remote_dir/src_dir
1139 touch $remote_dir/src_file
1140 test_mkdir -p $remote_dir/tgt_dir
1141 touch $remote_dir/tgt_file
1143 mrename $remote_dir/src_dir $remote_dir/tgt_dir ||
1144 error "rename subdir in the same remote dir failed!"
1146 mrename $remote_dir/src_file $remote_dir/tgt_file ||
1147 error "rename files in the same remote dir failed!"
1149 ln $remote_dir/tgt_file $remote_dir/tgt_file1 ||
1150 error "link files in the same remote dir failed!"
1152 rm -rf $DIR/$tdir || error "Can not delete directories"
1154 run_test 24y "rename/link on the same dir should succeed"
1156 test_24A() { # LU-3182
1160 test_mkdir -p $DIR/$tdir
1161 createmany -m $DIR/$tdir/$tfile $NFILES
1162 local t=$(ls $DIR/$tdir | wc -l)
1163 local u=$(ls $DIR/$tdir | sort -u | wc -l)
1164 local v=$(ls -ai $DIR/$tdir | sort -u | wc -l)
1165 if [ $t -ne $NFILES -o $u -ne $NFILES -o $v -ne $((NFILES + 2)) ] ; then
1166 error "Expected $NFILES files, got $t ($u unique $v .&..)"
1169 rm -rf $DIR/$tdir || error "Can not delete directories"
1171 run_test 24A "readdir() returns correct number of entries."
1173 test_24B() { # LU-4805
1174 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
1177 test_mkdir $DIR/$tdir
1178 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR/$tdir/striped_dir ||
1179 error "create striped dir failed"
1181 count=$(ls -ai $DIR/$tdir/striped_dir | wc -l)
1182 [ $count -eq 2 ] || error "Expected 2, got $count"
1184 touch $DIR/$tdir/striped_dir/a
1186 count=$(ls -ai $DIR/$tdir/striped_dir | wc -l)
1187 [ $count -eq 3 ] || error "Expected 3, got $count"
1189 touch $DIR/$tdir/striped_dir/.f
1191 count=$(ls -ai $DIR/$tdir/striped_dir | wc -l)
1192 [ $count -eq 4 ] || error "Expected 4, got $count"
1194 rm -rf $DIR/$tdir || error "Can not delete directories"
1196 run_test 24B "readdir for striped dir return correct number of entries"
1199 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
1205 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR/$tdir/d0/striped_dir ||
1206 error "create striped dir failed"
1208 cd $DIR/$tdir/d0/striped_dir
1210 local d0_ino=$(ls -i -l -a $DIR/$tdir | grep "d0" | awk '{print $1}')
1211 local d1_ino=$(ls -i -l -a $DIR/$tdir | grep "d1" | awk '{print $1}')
1212 local parent_ino=$(ls -i -l -a | grep "\.\." | awk '{print $1}')
1214 [ "$d0_ino" = "$parent_ino" ] ||
1215 error ".. wrong, expect $d0_ino, get $parent_ino"
1217 mv $DIR/$tdir/d0/striped_dir $DIR/$tdir/d1/ ||
1218 error "mv striped dir failed"
1220 parent_ino=$(ls -i -l -a | grep "\.\." | awk '{print $1}')
1222 [ "$d1_ino" = "$parent_ino" ] ||
1223 error ".. wrong after mv, expect $d1_ino, get $parent_ino"
1225 run_test 24C "check .. in striped dir"
1227 test_24D() { # LU-6101
1232 createmany -m $DIR/$tdir/$tfile $NFILES
1233 local t=$(ls $DIR/$tdir | wc -l)
1234 local u=$(ls $DIR/$tdir | sort -u | wc -l)
1235 local v=$(ls -ai $DIR/$tdir | sort -u | wc -l)
1236 if [ $t -ne $NFILES -o $u -ne $NFILES -o $v -ne $((NFILES + 2)) ] ; then
1237 error "Expected $NFILES files, got $t ($u unique $v .&..)"
1240 rm -rf $DIR/$tdir || error "Can not delete directories"
1242 run_test 24D "readdir() returns correct number of entries after cursor reload"
1245 [[ $MDSCOUNT -lt 4 ]] && skip "needs >= 4 MDTs" && return
1246 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1249 mkdir $DIR/$tdir/src_dir
1250 $LFS mkdir -i 1 $DIR/$tdir/src_dir/src_child ||
1251 error "create remote source failed"
1253 touch $DIR/$tdir/src_dir/src_child/a
1255 $LFS mkdir -i 2 $DIR/$tdir/tgt_dir ||
1256 error "create remote target dir failed"
1258 $LFS mkdir -i 3 $DIR/$tdir/tgt_dir/tgt_child ||
1259 error "create remote target child failed"
1261 mrename $DIR/$tdir/src_dir/src_child $DIR/$tdir/tgt_dir/tgt_child ||
1262 error "rename dir cross MDT failed!"
1266 $CHECKSTAT -t dir $DIR/$tdir/src_dir/src_child &&
1267 error "src_child still exists after rename"
1269 $CHECKSTAT -t file $DIR/$tdir/tgt_dir/tgt_child/a ||
1270 error "missing file(a) after rename"
1272 rm -rf $DIR/$tdir || error "Can not delete directories"
1274 run_test 24E "cross MDT rename/link"
1277 echo '== symlink sanity ============================================='
1281 touch $DIR/s25/foo || error
1283 run_test 25a "create file in symlinked directory ==============="
1286 [ ! -d $DIR/d25 ] && test_25a
1287 $CHECKSTAT -t file $DIR/s25/foo || error
1289 run_test 25b "lookup file in symlinked directory ==============="
1293 test_mkdir $DIR/d26/d26-2
1294 ln -s d26/d26-2 $DIR/s26
1295 touch $DIR/s26/foo || error
1297 run_test 26a "multiple component symlink ======================="
1300 test_mkdir -p $DIR/d26b/d26-2
1301 ln -s d26b/d26-2/foo $DIR/s26-2
1302 touch $DIR/s26-2 || error
1304 run_test 26b "multiple component symlink at end of lookup ======"
1307 test_mkdir $DIR/d26.2
1308 touch $DIR/d26.2/foo
1309 ln -s d26.2 $DIR/s26.2-1
1310 ln -s s26.2-1 $DIR/s26.2-2
1311 ln -s s26.2-2 $DIR/s26.2-3
1312 chmod 0666 $DIR/s26.2-3/foo
1314 run_test 26c "chain of symlinks ================================"
1316 # recursive symlinks (bug 439)
1318 ln -s d26-3/foo $DIR/d26-3
1320 run_test 26d "create multiple component recursive symlink ======"
1323 [ ! -h $DIR/d26-3 ] && test_26d
1326 run_test 26e "unlink multiple component recursive symlink ======"
1328 # recursive symlinks (bug 7022)
1330 test_mkdir -p $DIR/$tdir
1331 test_mkdir $DIR/$tdir/$tfile || error "mkdir $DIR/$tdir/$tfile failed"
1332 cd $DIR/$tdir/$tfile || error "cd $DIR/$tdir/$tfile failed"
1333 test_mkdir -p lndir/bar1 || error "mkdir lndir/bar1 failed"
1334 test_mkdir $DIR/$tdir/$tfile/$tfile || error "mkdir $tfile failed"
1335 cd $tfile || error "cd $tfile failed"
1336 ln -s .. dotdot || error "ln dotdot failed"
1337 ln -s dotdot/lndir lndir || error "ln lndir failed"
1338 cd $DIR/$tdir || error "cd $DIR/$tdir failed"
1339 output=`ls $tfile/$tfile/lndir/bar1`
1340 [ "$output" = bar1 ] && error "unexpected output"
1341 rm -r $tfile || error "rm $tfile failed"
1342 $CHECKSTAT -a $DIR/$tfile || error "$tfile not gone"
1344 run_test 26f "rm -r of a directory which has recursive symlink ="
1347 echo '== stripe sanity =============================================='
1348 test_mkdir -p $DIR/d27 || error "mkdir failed"
1350 $SETSTRIPE -c 1 $DIR/d27/f0 || error "setstripe failed"
1351 $CHECKSTAT -t file $DIR/d27/f0 || error "checkstat failed"
1352 log "== test_27a: write to one stripe file ========================="
1353 cp /etc/hosts $DIR/d27/f0 || error
1355 run_test 27a "one stripe file =================================="
1358 [[ $OSTCOUNT -lt 2 ]] && skip_env "skipping 2-stripe test" && return
1359 test_mkdir -p $DIR/d27
1360 $SETSTRIPE -c 2 $DIR/d27/f01 || error "setstripe failed"
1361 $GETSTRIPE -c $DIR/d27/f01
1362 [ $($GETSTRIPE -c $DIR/d27/f01) -eq 2 ] ||
1363 error "two-stripe file doesn't have two stripes"
1365 dd if=/dev/zero of=$DIR/d27/f01 bs=4k count=4 || error "dd failed"
1367 run_test 27b "create and write to two stripe file"
1370 test_mkdir -p $DIR/d27
1371 $SETSTRIPE -c 0 -i -1 -S 0 $DIR/d27/fdef || error "setstripe failed"
1372 $CHECKSTAT -t file $DIR/d27/fdef || error "checkstat failed"
1373 dd if=/dev/zero of=$DIR/d27/fdef bs=4k count=4 || error
1375 run_test 27d "create file with default settings ================"
1378 # LU-5839 adds check for existed layout before setting it
1379 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.56) ]] &&
1380 skip "Need MDS version at least 2.7.56" && return
1381 test_mkdir -p $DIR/d27
1382 $SETSTRIPE -c 2 $DIR/d27/f12 || error "setstripe failed"
1383 $SETSTRIPE -c 2 $DIR/d27/f12 && error "setstripe succeeded twice"
1384 $CHECKSTAT -t file $DIR/d27/f12 || error "checkstat failed"
1386 run_test 27e "setstripe existing file (should return error) ======"
1389 test_mkdir $DIR/$tdir
1390 $SETSTRIPE -S 100 -i 0 -c 1 $DIR/$tdir/$tfile &&
1391 error "$SETSTRIPE $DIR/$tdir/$tfile failed"
1392 $CHECKSTAT -t file $DIR/$tdir/$tfile &&
1393 error "$CHECKSTAT -t file $DIR/$tdir/$tfile should fail"
1394 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=4k count=4 || error "dd failed"
1395 $GETSTRIPE $DIR/$tdir/$tfile || error "$GETSTRIPE failed"
1397 run_test 27f "setstripe with bad stripe size (should return error)"
1400 test_mkdir -p $DIR/d27
1401 $MCREATE $DIR/d27/fnone || error "mcreate failed"
1402 $GETSTRIPE $DIR/d27/fnone 2>&1 | grep "no stripe info" ||
1403 error "$DIR/d27/fnone has object"
1405 run_test 27g "$GETSTRIPE with no objects"
1408 test_mkdir $DIR/$tdir
1409 touch $DIR/$tdir/$tfile || error "touch failed"
1410 [[ $($GETSTRIPE -c $DIR/$tdir/$tfile) -gt 0 ]] ||
1411 error "missing objects"
1413 run_test 27i "$GETSTRIPE with some objects"
1416 test_mkdir -p $DIR/d27
1417 $SETSTRIPE -i $OSTCOUNT $DIR/d27/f27j && error "setstripe failed"||true
1419 run_test 27j "setstripe with bad stripe offset (should return error)"
1421 test_27k() { # bug 2844
1422 test_mkdir -p $DIR/d27
1424 LL_MAX_BLKSIZE=$((4 * 1024 * 1024))
1425 [ ! -d $DIR/d27 ] && test_mkdir -p $DIR d27
1426 $SETSTRIPE -S 67108864 $FILE || error "setstripe failed"
1427 BLKSIZE=`stat $FILE | awk '/IO Block:/ { print $7 }'`
1428 [ $BLKSIZE -le $LL_MAX_BLKSIZE ] || error "1:$BLKSIZE > $LL_MAX_BLKSIZE"
1429 dd if=/dev/zero of=$FILE bs=4k count=1
1430 BLKSIZE=`stat $FILE | awk '/IO Block:/ { print $7 }'`
1431 [ $BLKSIZE -le $LL_MAX_BLKSIZE ] || error "2:$BLKSIZE > $LL_MAX_BLKSIZE"
1433 run_test 27k "limit i_blksize for broken user apps ============="
1436 test_mkdir -p $DIR/d27
1437 mcreate $DIR/f27l || error "creating file"
1438 $RUNAS $SETSTRIPE -c 1 $DIR/f27l && \
1439 error "setstripe should have failed" || true
1441 run_test 27l "check setstripe permissions (should return error)"
1444 [[ $OSTCOUNT -lt 2 ]] && skip_env "$OSTCOUNT < 2 OSTs -- skipping" &&
1446 if [[ $ORIGFREE -gt $MAXFREE ]]; then
1447 skip "$ORIGFREE > $MAXFREE skipping out-of-space test on OST0"
1450 trap simple_cleanup_common EXIT
1451 test_mkdir -p $DIR/$tdir
1452 $SETSTRIPE -i 0 -c 1 $DIR/$tdir/f27m_1
1453 dd if=/dev/zero of=$DIR/$tdir/f27m_1 bs=1024 count=$MAXFREE &&
1454 error "dd should fill OST0"
1456 while $SETSTRIPE -i 0 -c 1 $DIR/$tdir/f27m_$i; do
1458 [ $i -gt 256 ] && break
1461 touch $DIR/$tdir/f27m_$i
1462 [ `$GETSTRIPE $DIR/$tdir/f27m_$i | grep -A 10 obdidx | awk '{print $1}'| grep -w "0"` ] &&
1463 error "OST0 was full but new created file still use it"
1465 touch $DIR/$tdir/f27m_$i
1466 [ `$GETSTRIPE $DIR/$tdir/f27m_$i | grep -A 10 obdidx | awk '{print $1}'| grep -w "0"` ] &&
1467 error "OST0 was full but new created file still use it"
1468 simple_cleanup_common
1470 run_test 27m "create file while OST0 was full =================="
1473 local DELAY=$(do_facet $SINGLEMDS lctl get_param -n lov.*.qos_maxage | head -n 1 | awk '{print $1 * 2}')
1477 # OSCs keep a NOSPC flag that will be reset after ~5s (qos_maxage)
1478 # if the OST isn't full anymore.
1480 local OSTIDX=${1:-""}
1482 local list=$(comma_list $(osts_nodes))
1483 [ "$OSTIDX" ] && list=$(facet_host ost$((OSTIDX + 1)))
1485 do_nodes $list lctl set_param fail_loc=0
1486 sync # initiate all OST_DESTROYs from MDS to OST
1490 exhaust_precreations() {
1493 local FAILIDX=${3:-$OSTIDX}
1494 local ofacet=ost$((OSTIDX + 1))
1496 test_mkdir -p -c1 $DIR/$tdir
1497 local mdtidx=$($LFS getstripe -M $DIR/$tdir)
1498 local mfacet=mds$((mdtidx + 1))
1499 echo OSTIDX=$OSTIDX MDTIDX=$mdtidx
1501 local OST=$(ostname_from_index $OSTIDX)
1504 local mdtosc_proc1=$(get_mdtosc_proc_path $mfacet $OST)
1505 local last_id=$(do_facet $mfacet lctl get_param -n \
1506 osc.$mdtosc_proc1.prealloc_last_id)
1507 local next_id=$(do_facet $mfacet lctl get_param -n \
1508 osc.$mdtosc_proc1.prealloc_next_id)
1510 local mdtosc_proc2=$(get_mdtosc_proc_path $mfacet)
1511 do_facet $mfacet lctl get_param osc.$mdtosc_proc2.prealloc*
1513 test_mkdir -p $DIR/$tdir/${OST}
1514 $SETSTRIPE -i $OSTIDX -c 1 $DIR/$tdir/${OST}
1515 #define OBD_FAIL_OST_ENOSPC 0x215
1516 do_facet $ofacet lctl set_param fail_val=$FAILIDX fail_loc=0x215
1517 echo "Creating to objid $last_id on ost $OST..."
1518 createmany -o $DIR/$tdir/${OST}/f $next_id $((last_id - next_id + 2))
1519 do_facet $mfacet lctl get_param osc.$mdtosc_proc2.prealloc*
1520 do_facet $ofacet lctl set_param fail_loc=$FAILLOC
1524 exhaust_all_precreations() {
1526 for (( i=0; i < OSTCOUNT; i++ )) ; do
1527 exhaust_precreations $i $1 -1
1532 [[ $OSTCOUNT -lt 2 ]] && skip_env "too few OSTs" && return
1533 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1534 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1535 remote_ost_nodsh && skip "remote OST with nodsh" && return
1538 rm -f $DIR/$tdir/$tfile
1539 exhaust_precreations 0 0x80000215
1540 $SETSTRIPE -c -1 $DIR/$tdir
1541 touch $DIR/$tdir/$tfile || error
1542 $GETSTRIPE $DIR/$tdir/$tfile
1545 run_test 27n "create file with some full OSTs =================="
1548 [[ $OSTCOUNT -lt 2 ]] && skip_env "too few OSTs" && return
1549 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1550 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1551 remote_ost_nodsh && skip "remote OST with nodsh" && return
1554 rm -f $DIR/$tdir/$tfile
1555 exhaust_all_precreations 0x215
1557 touch $DIR/$tdir/$tfile && error "able to create $DIR/$tdir/$tfile"
1562 run_test 27o "create file with all full OSTs (should error) ===="
1565 [[ $OSTCOUNT -lt 2 ]] && skip_env "too few OSTs" && return
1566 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1567 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1568 remote_ost_nodsh && skip "remote OST with nodsh" && return
1571 rm -f $DIR/$tdir/$tfile
1572 test_mkdir -p $DIR/$tdir
1574 $MCREATE $DIR/$tdir/$tfile || error "mcreate failed"
1575 $TRUNCATE $DIR/$tdir/$tfile 80000000 || error "truncate failed"
1576 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat failed"
1578 exhaust_precreations 0 0x80000215
1579 echo foo >> $DIR/$tdir/$tfile || error "append failed"
1580 $CHECKSTAT -s 80000004 $DIR/$tdir/$tfile || error "checkstat failed"
1581 $GETSTRIPE $DIR/$tdir/$tfile
1585 run_test 27p "append to a truncated file with some full OSTs ==="
1588 [[ $OSTCOUNT -lt 2 ]] && skip_env "too few OSTs" && return
1589 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1590 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1591 remote_ost_nodsh && skip "remote OST with nodsh" && return
1594 rm -f $DIR/$tdir/$tfile
1596 test_mkdir -p $DIR/$tdir
1597 $MCREATE $DIR/$tdir/$tfile || error "mcreate $DIR/$tdir/$tfile failed"
1598 $TRUNCATE $DIR/$tdir/$tfile 80000000 ||error "truncate $DIR/$tdir/$tfile failed"
1599 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat failed"
1601 exhaust_all_precreations 0x215
1603 echo foo >> $DIR/$tdir/$tfile && error "append succeeded"
1604 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat 2 failed"
1608 run_test 27q "append to truncated file with all OSTs full (should error) ==="
1611 [[ $OSTCOUNT -lt 2 ]] && skip_env "too few OSTs" && return
1612 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1613 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1614 remote_ost_nodsh && skip "remote OST with nodsh" && return
1617 rm -f $DIR/$tdir/$tfile
1618 exhaust_precreations 0 0x80000215
1620 $SETSTRIPE -i 0 -c 2 $DIR/$tdir/$tfile # && error
1624 run_test 27r "stripe file with some full OSTs (shouldn't LBUG) ="
1626 test_27s() { # bug 10725
1627 test_mkdir -p $DIR/$tdir
1628 local stripe_size=$((4096 * 1024 * 1024)) # 2^32
1629 local stripe_count=0
1630 [ $OSTCOUNT -eq 1 ] || stripe_count=2
1631 $SETSTRIPE -S $stripe_size -c $stripe_count $DIR/$tdir &&
1632 error "stripe width >= 2^32 succeeded" || true
1635 run_test 27s "lsm_xfersize overflow (should error) (bug 10725)"
1637 test_27t() { # bug 10864
1642 $WLFS getstripe $tfile
1645 run_test 27t "check that utils parse path correctly"
1647 test_27u() { # bug 4900
1648 [[ $OSTCOUNT -lt 2 ]] && skip_env "too few OSTs" && return
1649 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1651 local list=$(comma_list $(mdts_nodes))
1653 #define OBD_FAIL_MDS_OSC_PRECREATE 0x139
1654 do_nodes $list $LCTL set_param fail_loc=0x139
1655 test_mkdir -p $DIR/$tdir
1657 createmany -o $DIR/$tdir/t- 1000
1658 do_nodes $list $LCTL set_param fail_loc=0
1660 TLOG=$DIR/$tfile.getstripe
1661 $GETSTRIPE $DIR/$tdir > $TLOG
1662 OBJS=$(awk -vobj=0 '($1 == 0) { obj += 1 } END { print obj; }' $TLOG)
1663 unlinkmany $DIR/$tdir/t- 1000
1664 [[ $OBJS -gt 0 ]] &&
1665 error "$OBJS objects created on OST-0. See $TLOG" || pass
1667 run_test 27u "skip object creation on OSC w/o objects =========="
1669 test_27v() { # bug 4900
1670 [[ $OSTCOUNT -lt 2 ]] && skip_env "too few OSTs" && return
1671 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1672 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1673 remote_ost_nodsh && skip "remote OST with nodsh" && return
1675 exhaust_all_precreations 0x215
1678 test_mkdir -p $DIR/$tdir
1679 $SETSTRIPE -c 1 $DIR/$tdir # 1 stripe / file
1681 touch $DIR/$tdir/$tfile
1682 #define OBD_FAIL_TGT_DELAY_PRECREATE 0x705
1684 for (( i=1; i < OSTCOUNT; i++ )); do
1685 do_facet ost$i lctl set_param fail_loc=0x705
1687 local START=`date +%s`
1688 createmany -o $DIR/$tdir/$tfile 32
1690 local FINISH=`date +%s`
1691 local TIMEOUT=`lctl get_param -n timeout`
1692 local PROCESS=$((FINISH - START))
1693 [ $PROCESS -ge $((TIMEOUT / 2)) ] && \
1694 error "$FINISH - $START >= $TIMEOUT / 2"
1695 sleep $((TIMEOUT / 2 - PROCESS))
1698 run_test 27v "skip object creation on slow OST ================="
1700 test_27w() { # bug 10997
1701 test_mkdir -p $DIR/$tdir || error "mkdir failed"
1702 $SETSTRIPE -S 65536 $DIR/$tdir/f0 || error "setstripe failed"
1703 [ $($GETSTRIPE -S $DIR/$tdir/f0) -ne 65536 ] &&
1704 error "stripe size $size != 65536" || true
1705 [ $($GETSTRIPE -d $DIR/$tdir | grep -c "stripe_count") -ne 1 ] &&
1706 error "$GETSTRIPE -d $DIR/$tdir failed" || true
1708 run_test 27w "check $SETSTRIPE -S option"
1711 [[ $OSTCOUNT -lt 2 ]] &&
1712 skip_env "skipping multiple stripe count/offset test" && return
1714 test_mkdir -p $DIR/$tdir || error "mkdir failed"
1715 for i in $(seq 1 $OSTCOUNT); do
1717 $SETSTRIPE -c $i -i $offset $DIR/$tdir/f$i ||
1718 error "setstripe -c $i -i $offset failed"
1719 count=$($GETSTRIPE -c $DIR/$tdir/f$i)
1720 index=$($GETSTRIPE -i $DIR/$tdir/f$i)
1721 [ $count -ne $i ] && error "stripe count $count != $i" || true
1722 [ $index -ne $offset ] &&
1723 error "stripe offset $index != $offset" || true
1726 run_test 27wa "check $SETSTRIPE -c -i options"
1729 remote_ost_nodsh && skip "remote OST with nodsh" && return
1730 [[ $OSTCOUNT -lt 2 ]] && skip_env "$OSTCOUNT < 2 OSTs" && return
1731 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1732 OFFSET=$(($OSTCOUNT - 1))
1734 local OST=$(ostname_from_index $OSTIDX)
1736 test_mkdir -p $DIR/$tdir
1737 $SETSTRIPE -c 1 $DIR/$tdir # 1 stripe per file
1738 do_facet ost$((OSTIDX + 1)) lctl set_param -n obdfilter.$OST.degraded 1
1740 createmany -o $DIR/$tdir/$tfile $OSTCOUNT
1741 for i in `seq 0 $OFFSET`; do
1742 [ `$GETSTRIPE $DIR/$tdir/$tfile$i | grep -A 10 obdidx | awk '{print $1}' | grep -w "$OSTIDX"` ] &&
1743 error "OST0 was degraded but new created file still use it"
1745 do_facet ost$((OSTIDX + 1)) lctl set_param -n obdfilter.$OST.degraded 0
1747 run_test 27x "create files while OST0 is degraded"
1750 [[ $OSTCOUNT -lt 2 ]] &&
1751 skip_env "$OSTCOUNT < 2 OSTs -- skipping" && return
1752 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1753 remote_ost_nodsh && skip "remote OST with nodsh" && return
1754 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1756 local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS $FSNAME-OST0000)
1757 local last_id=$(do_facet $SINGLEMDS lctl get_param -n \
1758 osc.$mdtosc.prealloc_last_id)
1759 local next_id=$(do_facet $SINGLEMDS lctl get_param -n \
1760 osc.$mdtosc.prealloc_next_id)
1761 local fcount=$((last_id - next_id))
1762 [[ $fcount -eq 0 ]] && skip "not enough space on OST0" && return
1763 [[ $fcount -gt $OSTCOUNT ]] && fcount=$OSTCOUNT
1765 local MDS_OSCS=$(do_facet $SINGLEMDS lctl dl |
1766 awk '/[oO][sS][cC].*md[ts]/ { print $4 }')
1767 local OST_DEACTIVE_IDX=-1
1772 for OSC in $MDS_OSCS; do
1773 OST=$(osc_to_ost $OSC)
1774 OSTIDX=$(index_from_ostuuid $OST)
1775 if [ $OST_DEACTIVE_IDX == -1 ]; then
1776 OST_DEACTIVE_IDX=$OSTIDX
1778 if [ $OSTIDX != $OST_DEACTIVE_IDX ]; then
1779 echo $OSC "is Deactivated:"
1780 do_facet $SINGLEMDS lctl --device %$OSC deactivate
1784 OSTIDX=$(index_from_ostuuid $OST)
1785 test_mkdir -p $DIR/$tdir
1786 $SETSTRIPE -c 1 $DIR/$tdir # 1 stripe / file
1788 for OSC in $MDS_OSCS; do
1789 OST=$(osc_to_ost $OSC)
1790 OSTIDX=$(index_from_ostuuid $OST)
1791 if [ $OSTIDX == $OST_DEACTIVE_IDX ]; then
1792 echo $OST "is degraded:"
1793 do_facet ost$((OSTIDX+1)) lctl set_param -n \
1794 obdfilter.$OST.degraded=1
1799 createmany -o $DIR/$tdir/$tfile $fcount
1801 for OSC in $MDS_OSCS; do
1802 OST=$(osc_to_ost $OSC)
1803 OSTIDX=$(index_from_ostuuid $OST)
1804 if [ $OSTIDX == $OST_DEACTIVE_IDX ]; then
1805 echo $OST "is recovered from degraded:"
1806 do_facet ost$((OSTIDX+1)) lctl set_param -n \
1807 obdfilter.$OST.degraded=0
1809 do_facet $SINGLEMDS lctl --device %$OSC activate
1813 # all osp devices get activated, hence -1 stripe count restored
1816 # sleep 2*lod_qos_maxage seconds waiting for lod qos to notice osp
1817 # devices get activated.
1819 $SETSTRIPE -c -1 $DIR/$tfile
1820 stripecnt=$($GETSTRIPE -c $DIR/$tfile)
1822 [ $stripecnt -ne $OSTCOUNT ] &&
1823 error "Of $OSTCOUNT OSTs, only $stripecnt is available"
1826 run_test 27y "create files while OST0 is degraded and the rest inactive"
1832 lmm_count=$($GETSTRIPE -c $1)
1833 lmm_seq=$($GETSTRIPE -v $1 | awk '/lmm_seq/ { print $2 }')
1834 lmm_oid=$($GETSTRIPE -v $1 | awk '/lmm_object_id/ { print $2 }')
1836 local old_ifs="$IFS"
1838 fid=($($LFS path2fid $1))
1841 log "FID seq ${fid[1]}, oid ${fid[2]} ver ${fid[3]}"
1842 log "LOV seq $lmm_seq, oid $lmm_oid, count: $lmm_count"
1844 # compare lmm_seq and lu_fid->f_seq
1845 [ $lmm_seq = ${fid[1]} ] || { error "SEQ mismatch"; return 1; }
1846 # compare lmm_object_id and lu_fid->oid
1847 [ $lmm_oid = ${fid[2]} ] || { error "OID mismatch"; return 2; }
1849 # check the trusted.fid attribute of the OST objects of the file
1850 local have_obdidx=false
1852 $GETSTRIPE $1 | while read obdidx oid hex seq; do
1853 # skip lines up to and including "obdidx"
1854 [ -z "$obdidx" ] && break
1855 [ "$obdidx" = "obdidx" ] && have_obdidx=true && continue
1856 $have_obdidx || continue
1858 local ost=$((obdidx + 1))
1859 local dev=$(ostdevname $ost)
1862 log "want: stripe:$stripe_nr ost:$obdidx oid:$oid/$hex seq:$seq"
1864 seq=$(echo $seq | sed -e "s/^0x//g")
1865 if [ $seq == 0 ] || [ $(facet_fstype ost$ost) == zfs ]; then
1866 oid_hex=$(echo $oid)
1868 oid_hex=$(echo $hex | sed -e "s/^0x//g")
1870 local obj_file="O/$seq/d$((oid %32))/$oid_hex"
1874 # Don't unmount/remount the OSTs if we don't need to do that.
1875 # LU-2577 changes filter_fid to be smaller, so debugfs needs
1876 # update too, until that use mount/ll_decode_filter_fid/mount.
1877 # Re-enable when debugfs will understand new filter_fid.
1879 if false && [ $(facet_fstype ost$ost) == ldiskfs ]; then
1880 ff=$(do_facet ost$ost "$DEBUGFS -c -R 'stat $obj_file' \
1881 $dev 2>/dev/null" | grep "parent=")
1884 mount_fstype ost$ost
1885 ff=$(do_facet ost$ost $LL_DECODE_FILTER_FID \
1886 $(facet_mntpt ost$ost)/$obj_file)
1887 unmount_fstype ost$ost
1888 start ost$ost $dev $OST_MOUNT_OPTS
1891 [ -z "$ff" ] && error "$obj_file: no filter_fid info"
1893 echo "$ff" | sed -e 's#.*objid=#got: objid=#'
1895 # /mnt/O/0/d23/23: objid=23 seq=0 parent=[0x200000400:0x1e:0x1]
1896 # fid: objid=23 seq=0 parent=[0x200000400:0x1e:0x0] stripe=1
1897 local ff_parent=$(echo $ff|sed -e 's/.*parent=.//')
1898 local ff_pseq=$(echo $ff_parent | cut -d: -f1)
1899 local ff_poid=$(echo $ff_parent | cut -d: -f2)
1901 if echo $ff_parent | grep -q 'stripe='; then
1902 ff_pstripe=$(echo $ff_parent | sed -e 's/.*stripe=//')
1905 # $LL_DECODE_FILTER_FID does not print "stripe="; look
1906 # into f_ver in this case. See the comment on
1909 ff_pstripe=$(echo $ff_parent | cut -d: -f3 |
1913 # compare lmm_seq and filter_fid->ff_parent.f_seq
1914 [ $ff_pseq = $lmm_seq ] ||
1915 error "FF parent SEQ $ff_pseq != $lmm_seq"
1916 # compare lmm_object_id and filter_fid->ff_parent.f_oid
1917 [ $ff_poid = $lmm_oid ] ||
1918 error "FF parent OID $ff_poid != $lmm_oid"
1919 (($ff_pstripe == $stripe_nr)) ||
1920 error "FF stripe $ff_pstripe != $stripe_nr"
1922 stripe_nr=$((stripe_nr + 1))
1927 remote_ost_nodsh && skip "remote OST with nodsh" && return
1928 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1929 test_mkdir -p $DIR/$tdir
1931 $SETSTRIPE -c 1 -i 0 -S 64k $DIR/$tdir/$tfile-1 ||
1932 { error "setstripe -c -1 failed"; return 1; }
1933 # We need to send a write to every object to get parent FID info set.
1934 # This _should_ also work for setattr, but does not currently.
1935 # touch $DIR/$tdir/$tfile-1 ||
1936 dd if=/dev/zero of=$DIR/$tdir/$tfile-1 bs=1M count=1 ||
1937 { error "dd $tfile-1 failed"; return 2; }
1938 $SETSTRIPE -c -1 -i $((OSTCOUNT - 1)) -S 1M $DIR/$tdir/$tfile-2 ||
1939 { error "setstripe -c -1 failed"; return 3; }
1940 dd if=/dev/zero of=$DIR/$tdir/$tfile-2 bs=1M count=$OSTCOUNT ||
1941 { error "dd $tfile-2 failed"; return 4; }
1943 # make sure write RPCs have been sent to OSTs
1946 check_seq_oid $DIR/$tdir/$tfile-1 || return 5
1947 check_seq_oid $DIR/$tdir/$tfile-2 || return 6
1949 run_test 27z "check SEQ/OID on the MDT and OST filesystems"
1951 test_27A() { # b=19102
1952 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1953 local restore_size=$($GETSTRIPE -S $MOUNT)
1954 local restore_count=$($GETSTRIPE -c $MOUNT)
1955 local restore_offset=$($GETSTRIPE -i $MOUNT)
1956 $SETSTRIPE -c 0 -i -1 -S 0 $MOUNT
1957 wait_update $HOSTNAME "$GETSTRIPE -c $MOUNT | sed 's/ *//g'" "1" 20 ||
1958 error "stripe count $($GETSTRIPE -c $MOUNT) != 1"
1959 local default_size=$($GETSTRIPE -S $MOUNT)
1960 local default_offset=$($GETSTRIPE -i $MOUNT)
1961 local dsize=$((1024 * 1024))
1962 [ $default_size -eq $dsize ] ||
1963 error "stripe size $default_size != $dsize"
1964 [ $default_offset -eq -1 ] ||error "stripe offset $default_offset != -1"
1965 $SETSTRIPE -c $restore_count -i $restore_offset -S $restore_size $MOUNT
1967 run_test 27A "check filesystem-wide default LOV EA values"
1969 test_27B() { # LU-2523
1970 test_mkdir -p $DIR/$tdir
1971 rm -f $DIR/$tdir/f0 $DIR/$tdir/f1
1973 # open f1 with O_LOV_DELAY_CREATE
1975 # call setstripe ioctl on open file descriptor for f1
1977 multiop $DIR/$tdir/f1 oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:nB1c \
1981 # open f1 with O_LOV_DELAY_CREATE
1983 # call setstripe ioctl on open file descriptor for f1
1985 multiop $DIR/$tdir/f1 oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:uB1c
1987 # Allow multiop to fail in imitation of NFS's busted semantics.
1990 run_test 27B "call setstripe on open unlinked file/rename victim"
1992 test_27C() { #LU-2871
1993 [[ $OSTCOUNT -lt 2 ]] && skip "needs >= 2 OSTs" && return
2001 test_mkdir -p $DIR/$tdir
2003 for i in $(seq 0 $((OSTCOUNT - 1))); do
2004 # set stripe across all OSTs starting from OST$i
2005 $SETSTRIPE -i $i -c -1 $tfile$i
2006 # get striping information
2007 ost_idx=($($GETSTRIPE $tfile$i |
2008 tail -n $((OSTCOUNT + 1)) | awk '{print $1}'))
2012 [ ${#ost_idx[@]} -eq $OSTCOUNT ] ||
2013 error "${#ost_idx[@]} != $OSTCOUNT"
2015 for index in $(seq 0 $((OSTCOUNT - 1))); do
2017 for j in $(echo ${ost_idx[@]}); do
2018 if [ $index -eq $j ]; then
2024 error "Can not find $index in ${ost_idx[@]}"
2028 run_test 27C "check full striping across all OSTs"
2031 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs" && return
2032 local POOL=${POOL:-testpool}
2034 local last_ost=$(($OSTCOUNT - 1))
2036 local ost_list=$(seq $first_ost $ost_step $last_ost)
2037 local ost_range="$first_ost $last_ost $ost_step"
2039 test_mkdir -p $DIR/$tdir
2040 pool_add $POOL || error "pool_add failed"
2041 pool_add_targets $POOL $ost_range || error "pool_add_targets failed"
2042 llapi_layout_test -d$DIR/$tdir -p$POOL -o$OSTCOUNT ||
2043 error "llapi_layout_test failed"
2044 cleanup_pools || error "cleanup_pools failed"
2046 run_test 27D "validate llapi_layout API"
2048 # Verify that default_easize is increased from its initial value after
2049 # accessing a widely striped file.
2051 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs" && return
2053 # 72 bytes is the minimum space required to store striping
2054 # information for a file striped across one OST:
2055 # (sizeof(struct lov_user_md_v3) +
2056 # sizeof(struct lov_user_ost_data_v1))
2058 $LCTL set_param -n llite.*.default_easize $min_easize ||
2059 error "lctl set_param failed"
2060 local easize=$($LCTL get_param -n llite.*.default_easize)
2062 [ $easize -eq $min_easize ] ||
2063 error "failed to set default_easize"
2065 $LFS setstripe -c $OSTCOUNT $DIR/$tfile ||
2066 error "setstripe failed"
2070 easize=$($LCTL get_param -n llite.*.default_easize)
2072 [ $easize -gt $min_easize ] ||
2073 error "default_easize not updated"
2075 run_test 27E "check that default extended attribute size properly increases"
2077 # createtest also checks that device nodes are created and
2078 # then visible correctly (#2091)
2079 test_28() { # bug 2091
2081 $CREATETEST $DIR/d28/ct || error
2083 run_test 28 "create/mknod/mkdir with bad file types ============"
2086 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2087 cancel_lru_locks mdc
2093 declare -i LOCKCOUNTORIG=0
2094 for lock_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_count); do
2095 let LOCKCOUNTORIG=$LOCKCOUNTORIG+$lock_count
2097 [ $LOCKCOUNTORIG -eq 0 ] && echo "No mdc lock count" && return 1
2099 declare -i LOCKUNUSEDCOUNTORIG=0
2100 for unused_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_unused_count); do
2101 let LOCKUNUSEDCOUNTORIG=$LOCKUNUSEDCOUNTORIG+$unused_count
2108 declare -i LOCKCOUNTCURRENT=0
2109 for lock_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_count); do
2110 let LOCKCOUNTCURRENT=$LOCKCOUNTCURRENT+$lock_count
2113 declare -i LOCKUNUSEDCOUNTCURRENT=0
2114 for unused_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_unused_count); do
2115 let LOCKUNUSEDCOUNTCURRENT=$LOCKUNUSEDCOUNTCURRENT+$unused_count
2118 if [[ $LOCKCOUNTCURRENT -gt $LOCKCOUNTORIG ]]; then
2119 $LCTL set_param -n ldlm.dump_namespaces ""
2120 error "CURRENT: $LOCKCOUNTCURRENT > $LOCKCOUNTORIG"
2121 $LCTL dk | sort -k4 -t: > $TMP/test_29.dk
2122 log "dumped log to $TMP/test_29.dk (bug 5793)"
2125 if [[ $LOCKUNUSEDCOUNTCURRENT -gt $LOCKUNUSEDCOUNTORIG ]]; then
2126 error "UNUSED: $LOCKUNUSEDCOUNTCURRENT > $LOCKUNUSEDCOUNTORIG"
2127 $LCTL dk | sort -k4 -t: > $TMP/test_29.dk
2128 log "dumped log to $TMP/test_29.dk (bug 5793)"
2132 run_test 29 "IT_GETATTR regression ============================"
2134 test_30a() { # was test_30
2135 cp $(which ls) $DIR || cp /bin/ls $DIR
2139 run_test 30a "execute binary from Lustre (execve) =============="
2142 cp `which ls` $DIR || cp /bin/ls $DIR
2144 $RUNAS $DIR/ls / || error
2147 run_test 30b "execute binary from Lustre as non-root ==========="
2149 test_30c() { # b=22376
2150 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2151 cp `which ls` $DIR || cp /bin/ls $DIR
2153 cancel_lru_locks mdc
2154 cancel_lru_locks osc
2155 $RUNAS $DIR/ls / || error
2158 run_test 30c "execute binary from Lustre without read perms ===="
2161 $OPENUNLINK $DIR/f31 $DIR/f31 || error
2162 $CHECKSTAT -a $DIR/f31 || error
2164 run_test 31a "open-unlink file =================================="
2167 touch $DIR/f31 || error
2168 ln $DIR/f31 $DIR/f31b || error
2169 $MULTIOP $DIR/f31b Ouc || error
2170 $CHECKSTAT -t file $DIR/f31 || error
2172 run_test 31b "unlink file with multiple links while open ======="
2175 touch $DIR/f31 || error
2176 ln $DIR/f31 $DIR/f31c || error
2177 multiop_bg_pause $DIR/f31 O_uc || return 1
2179 $MULTIOP $DIR/f31c Ouc
2180 kill -USR1 $MULTIPID
2183 run_test 31c "open-unlink file with multiple links ============="
2186 opendirunlink $DIR/d31d $DIR/d31d || error
2187 $CHECKSTAT -a $DIR/d31d || error
2189 run_test 31d "remove of open directory ========================="
2191 test_31e() { # bug 2904
2192 openfilleddirunlink $DIR/d31e || error
2194 run_test 31e "remove of open non-empty directory ==============="
2196 test_31f() { # bug 4554
2197 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2199 test_mkdir $DIR/d31f
2200 $SETSTRIPE -S 1048576 -c 1 $DIR/d31f
2201 cp /etc/hosts $DIR/d31f
2203 $GETSTRIPE $DIR/d31f/hosts
2204 multiop_bg_pause $DIR/d31f D_c || return 1
2207 rm -rv $DIR/d31f || error "first of $DIR/d31f"
2208 test_mkdir $DIR/d31f
2209 $SETSTRIPE -S 1048576 -c 1 $DIR/d31f
2210 cp /etc/hosts $DIR/d31f
2212 $GETSTRIPE $DIR/d31f/hosts
2213 multiop_bg_pause $DIR/d31f D_c || return 1
2216 kill -USR1 $MULTIPID || error "first opendir $MULTIPID not running"
2217 wait $MULTIPID || error "first opendir $MULTIPID failed"
2221 kill -USR1 $MULTIPID2 || error "second opendir $MULTIPID not running"
2222 wait $MULTIPID2 || error "second opendir $MULTIPID2 failed"
2225 run_test 31f "remove of open directory with open-unlink file ==="
2228 echo "-- cross directory link --"
2229 test_mkdir -c1 $DIR/${tdir}ga
2230 test_mkdir -c1 $DIR/${tdir}gb
2231 touch $DIR/${tdir}ga/f
2232 ln $DIR/${tdir}ga/f $DIR/${tdir}gb/g
2233 $CHECKSTAT -t file $DIR/${tdir}ga/f || error "source"
2234 [ `stat -c%h $DIR/${tdir}ga/f` == '2' ] || error "source nlink"
2235 $CHECKSTAT -t file $DIR/${tdir}gb/g || error "target"
2236 [ `stat -c%h $DIR/${tdir}gb/g` == '2' ] || error "target nlink"
2238 run_test 31g "cross directory link==============="
2241 echo "-- cross directory link --"
2242 test_mkdir -c1 $DIR/${tdir}
2243 test_mkdir -c1 $DIR/${tdir}/dir
2244 touch $DIR/${tdir}/f
2245 ln $DIR/${tdir}/f $DIR/${tdir}/dir/g
2246 $CHECKSTAT -t file $DIR/${tdir}/f || error "source"
2247 [ `stat -c%h $DIR/${tdir}/f` == '2' ] || error "source nlink"
2248 $CHECKSTAT -t file $DIR/${tdir}/dir/g || error "target"
2249 [ `stat -c%h $DIR/${tdir}/dir/g` == '2' ] || error "target nlink"
2251 run_test 31h "cross directory link under child==============="
2254 echo "-- cross directory link --"
2255 test_mkdir -c1 $DIR/$tdir
2256 test_mkdir -c1 $DIR/$tdir/dir
2257 touch $DIR/$tdir/dir/f
2258 ln $DIR/$tdir/dir/f $DIR/$tdir/g
2259 $CHECKSTAT -t file $DIR/$tdir/dir/f || error "source"
2260 [ `stat -c%h $DIR/$tdir/dir/f` == '2' ] || error "source nlink"
2261 $CHECKSTAT -t file $DIR/$tdir/g || error "target"
2262 [ `stat -c%h $DIR/$tdir/g` == '2' ] || error "target nlink"
2264 run_test 31i "cross directory link under parent==============="
2267 test_mkdir -c1 -p $DIR/$tdir
2268 test_mkdir -c1 -p $DIR/$tdir/dir1
2269 ln $DIR/$tdir/dir1 $DIR/$tdir/dir2 && error "ln for dir"
2270 link $DIR/$tdir/dir1 $DIR/$tdir/dir3 && error "link for dir"
2271 mlink $DIR/$tdir/dir1 $DIR/$tdir/dir4 && error "mlink for dir"
2272 mlink $DIR/$tdir/dir1 $DIR/$tdir/dir1 && error "mlink to the same dir"
2275 run_test 31j "link for directory==============="
2278 test_mkdir -c1 -p $DIR/$tdir
2280 touch $DIR/$tdir/exist
2281 mlink $DIR/$tdir/s $DIR/$tdir/t || error "mlink"
2282 mlink $DIR/$tdir/s $DIR/$tdir/exist && error "mlink to exist file"
2283 mlink $DIR/$tdir/s $DIR/$tdir/s && error "mlink to the same file"
2284 mlink $DIR/$tdir/s $DIR/$tdir && error "mlink to parent dir"
2285 mlink $DIR/$tdir $DIR/$tdir/s && error "mlink parent dir to target"
2286 mlink $DIR/$tdir/not-exist $DIR/$tdir/foo && error "mlink non-existing to new"
2287 mlink $DIR/$tdir/not-exist $DIR/$tdir/s && error "mlink non-existing to exist"
2290 run_test 31k "link to file: the same, non-existing, dir==============="
2296 touch $DIR/d31m2/exist
2297 mlink $DIR/d31m/s $DIR/d31m2/t || error "mlink"
2298 mlink $DIR/d31m/s $DIR/d31m2/exist && error "mlink to exist file"
2299 mlink $DIR/d31m/s $DIR/d31m2 && error "mlink to parent dir"
2300 mlink $DIR/d31m2 $DIR/d31m/s && error "mlink parent dir to target"
2301 mlink $DIR/d31m/not-exist $DIR/d31m2/foo && error "mlink non-existing to new"
2302 mlink $DIR/d31m/not-exist $DIR/d31m2/s && error "mlink non-existing to exist"
2305 run_test 31m "link to file: the same, non-existing, dir==============="
2308 touch $DIR/$tfile || error "cannot create '$DIR/$tfile'"
2309 nlink=$(stat --format=%h $DIR/$tfile)
2310 [ ${nlink:--1} -eq 1 ] || error "nlink is $nlink, expected 1"
2312 local cmd="exec $fd<$DIR/$tfile"
2315 trap "eval $cmd" EXIT
2316 nlink=$(stat --dereference --format=%h /proc/self/fd/$fd)
2317 [ ${nlink:--1} -eq 1 ] || error "nlink is $nlink, expected 1"
2318 rm $DIR/$tfile || error "cannot remove '$DIR/$tfile'"
2319 nlink=$(stat --dereference --format=%h /proc/self/fd/$fd)
2320 [ ${nlink:--1} -eq 0 ] || error "nlink is $nlink, expected 0"
2323 run_test 31n "check link count of unlinked file"
2326 local TEMPNAME=$(mktemp $1_XXXXXX)
2327 mlink $TEMPNAME $1 2> /dev/null &&
2328 echo "$BASHPID: link $TEMPNAME to $1 succeeded"
2332 test_31o() { # LU-2901
2333 test_mkdir -p $DIR/$tdir
2334 for LOOP in $(seq 100); do
2335 rm -f $DIR/$tdir/$tfile*
2336 for THREAD in $(seq 8); do
2337 link_one $DIR/$tdir/$tfile.$LOOP &
2340 local LINKS=$(ls -1 $DIR/$tdir | grep -c $tfile.$LOOP)
2341 [[ $LINKS -gt 1 ]] && ls $DIR/$tdir &&
2342 error "$LINKS duplicate links to $tfile.$LOOP" &&
2346 run_test 31o "duplicate hard links with same filename"
2349 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2351 test_mkdir $DIR/$tdir
2352 $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
2353 $LFS setdirstripe -D -c2 -t all_char $DIR/$tdir/striped_dir
2355 opendirunlink $DIR/$tdir/striped_dir/test1 ||
2356 error "open unlink test1 failed"
2357 opendirunlink $DIR/$tdir/striped_dir/test2 ||
2358 error "open unlink test2 failed"
2360 $CHECKSTAT -a $DIR/$tdir/striped_dir/test1 ||
2361 error "test1 still exists"
2362 $CHECKSTAT -a $DIR/$tdir/striped_dir/test2 ||
2363 error "test2 still exists"
2365 run_test 31p "remove of open striped directory"
2367 cleanup_test32_mount() {
2369 $UMOUNT -d $DIR/$tdir/ext2-mountpoint
2373 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2374 echo "== more mountpoints and symlinks ================="
2375 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2376 trap cleanup_test32_mount EXIT
2377 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2378 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2379 $CHECKSTAT -t dir $DIR/$tdir/ext2-mountpoint/.. || error
2380 cleanup_test32_mount
2382 run_test 32a "stat d32a/ext2-mountpoint/.. ====================="
2385 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2386 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2387 trap cleanup_test32_mount EXIT
2388 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2389 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2390 ls -al $DIR/$tdir/ext2-mountpoint/.. || error
2391 cleanup_test32_mount
2393 run_test 32b "open d32b/ext2-mountpoint/.. ====================="
2396 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2397 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2398 trap cleanup_test32_mount EXIT
2399 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2400 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2401 test_mkdir -p $DIR/$tdir/d2/test_dir
2402 $CHECKSTAT -t dir $DIR/$tdir/ext2-mountpoint/../d2/test_dir || error
2403 cleanup_test32_mount
2405 run_test 32c "stat d32c/ext2-mountpoint/../d2/test_dir ========="
2408 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2409 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2410 trap cleanup_test32_mount EXIT
2411 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2412 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2413 test_mkdir -p $DIR/$tdir/d2/test_dir
2414 ls -al $DIR/$tdir/ext2-mountpoint/../d2/test_dir || error
2415 cleanup_test32_mount
2417 run_test 32d "open d32d/ext2-mountpoint/../d2/test_dir ========="
2420 [ -e $DIR/d32e ] && rm -fr $DIR/d32e
2421 test_mkdir -p $DIR/d32e/tmp
2422 TMP_DIR=$DIR/d32e/tmp
2423 ln -s $DIR/d32e $TMP_DIR/symlink11
2424 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
2425 $CHECKSTAT -t link $DIR/d32e/tmp/symlink11 || error
2426 $CHECKSTAT -t link $DIR/d32e/symlink01 || error
2428 run_test 32e "stat d32e/symlink->tmp/symlink->lustre-subdir ===="
2431 [ -e $DIR/d32f ] && rm -fr $DIR/d32f
2432 test_mkdir -p $DIR/d32f/tmp
2433 TMP_DIR=$DIR/d32f/tmp
2434 ln -s $DIR/d32f $TMP_DIR/symlink11
2435 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
2436 ls $DIR/d32f/tmp/symlink11 || error
2437 ls $DIR/d32f/symlink01 || error
2439 run_test 32f "open d32f/symlink->tmp/symlink->lustre-subdir ===="
2442 TMP_DIR=$DIR/$tdir/tmp
2443 test_mkdir -p $DIR/$tdir/tmp
2444 test_mkdir $DIR/${tdir}2
2445 ln -s $DIR/${tdir}2 $TMP_DIR/symlink12
2446 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
2447 $CHECKSTAT -t link $TMP_DIR/symlink12 || error
2448 $CHECKSTAT -t link $DIR/$tdir/symlink02 || error
2449 $CHECKSTAT -t dir -f $TMP_DIR/symlink12 || error
2450 $CHECKSTAT -t dir -f $DIR/$tdir/symlink02 || error
2452 run_test 32g "stat d32g/symlink->tmp/symlink->lustre-subdir/${tdir}2"
2455 rm -fr $DIR/$tdir $DIR/${tdir}2
2456 TMP_DIR=$DIR/$tdir/tmp
2457 test_mkdir -p $DIR/$tdir/tmp
2458 test_mkdir $DIR/${tdir}2
2459 ln -s $DIR/${tdir}2 $TMP_DIR/symlink12
2460 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
2461 ls $TMP_DIR/symlink12 || error
2462 ls $DIR/$tdir/symlink02 || error
2464 run_test 32h "open d32h/symlink->tmp/symlink->lustre-subdir/${tdir}2"
2467 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2468 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2469 trap cleanup_test32_mount EXIT
2470 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2471 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2472 touch $DIR/$tdir/test_file
2473 $CHECKSTAT -t file $DIR/$tdir/ext2-mountpoint/../test_file || error
2474 cleanup_test32_mount
2476 run_test 32i "stat d32i/ext2-mountpoint/../test_file ==========="
2479 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2480 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2481 trap cleanup_test32_mount EXIT
2482 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2483 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2484 touch $DIR/$tdir/test_file
2485 cat $DIR/$tdir/ext2-mountpoint/../test_file || error
2486 cleanup_test32_mount
2488 run_test 32j "open d32j/ext2-mountpoint/../test_file ==========="
2491 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2493 trap cleanup_test32_mount EXIT
2494 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2495 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint
2496 test_mkdir -p $DIR/$tdir/d2
2497 touch $DIR/$tdir/d2/test_file || error
2498 $CHECKSTAT -t file $DIR/$tdir/ext2-mountpoint/../d2/test_file || error
2499 cleanup_test32_mount
2501 run_test 32k "stat d32k/ext2-mountpoint/../d2/test_file ========"
2504 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2506 trap cleanup_test32_mount EXIT
2507 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2508 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2509 test_mkdir -p $DIR/$tdir/d2
2510 touch $DIR/$tdir/d2/test_file
2511 cat $DIR/$tdir/ext2-mountpoint/../d2/test_file || error
2512 cleanup_test32_mount
2514 run_test 32l "open d32l/ext2-mountpoint/../d2/test_file ========"
2518 test_mkdir -p $DIR/d32m/tmp
2519 TMP_DIR=$DIR/d32m/tmp
2520 ln -s $DIR $TMP_DIR/symlink11
2521 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
2522 $CHECKSTAT -t link $DIR/d32m/tmp/symlink11 || error
2523 $CHECKSTAT -t link $DIR/d32m/symlink01 || error
2525 run_test 32m "stat d32m/symlink->tmp/symlink->lustre-root ======"
2529 test_mkdir -p $DIR/d32n/tmp
2530 TMP_DIR=$DIR/d32n/tmp
2531 ln -s $DIR $TMP_DIR/symlink11
2532 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
2533 ls -l $DIR/d32n/tmp/symlink11 || error
2534 ls -l $DIR/d32n/symlink01 || error
2536 run_test 32n "open d32n/symlink->tmp/symlink->lustre-root ======"
2540 test_mkdir -p $DIR/d32o/tmp
2541 TMP_DIR=$DIR/d32o/tmp
2542 ln -s $DIR/$tfile $TMP_DIR/symlink12
2543 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
2544 $CHECKSTAT -t link $DIR/d32o/tmp/symlink12 || error
2545 $CHECKSTAT -t link $DIR/d32o/symlink02 || error
2546 $CHECKSTAT -t file -f $DIR/d32o/tmp/symlink12 || error
2547 $CHECKSTAT -t file -f $DIR/d32o/symlink02 || error
2549 run_test 32o "stat d32o/symlink->tmp/symlink->lustre-root/$tfile"
2559 test_mkdir -p $DIR/d32p/tmp
2561 TMP_DIR=$DIR/d32p/tmp
2563 ln -s $DIR/$tfile $TMP_DIR/symlink12
2565 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
2567 cat $DIR/d32p/tmp/symlink12 || error
2569 cat $DIR/d32p/symlink02 || error
2572 run_test 32p "open d32p/symlink->tmp/symlink->lustre-root/$tfile"
2574 cleanup_testdir_mount() {
2576 $UMOUNT -d $DIR/$tdir
2580 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2581 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2582 trap cleanup_testdir_mount EXIT
2583 test_mkdir -p $DIR/$tdir
2584 touch $DIR/$tdir/under_the_mount
2585 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir
2586 ls $DIR/$tdir | grep "\<under_the_mount\>" && error
2587 cleanup_testdir_mount
2589 run_test 32q "stat follows mountpoints in Lustre (should return error)"
2592 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2593 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2594 trap cleanup_testdir_mount EXIT
2595 test_mkdir -p $DIR/$tdir
2596 touch $DIR/$tdir/under_the_mount
2597 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir
2598 ls $DIR/$tdir | grep -q under_the_mount && error || true
2599 cleanup_testdir_mount
2601 run_test 32r "opendir follows mountpoints in Lustre (should return error)"
2606 chmod 444 $DIR/$tfile
2607 chown $RUNAS_ID $DIR/$tfile
2609 $RUNAS $OPENFILE -f O_RDWR $DIR/$tfile && error || true
2612 run_test 33aa "write file with mode 444 (should return error) ===="
2616 test_mkdir -p $DIR/d33
2617 chown $RUNAS_ID $DIR/d33
2618 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $DIR/d33/f33|| error "create"
2619 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $DIR/d33/f33 && \
2620 error "open RDWR" || true
2622 run_test 33a "test open file(mode=0444) with O_RDWR (should return error)"
2626 test_mkdir -p $DIR/d33
2627 chown $RUNAS_ID $DIR/d33
2628 $RUNAS $OPENFILE -f 1286739555 $DIR/d33/f33 || true
2630 run_test 33b "test open file with malformed flags (No panic)"
2633 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2639 remote_ost_nodsh && skip "remote OST with nodsh" && return
2642 test_mkdir -p $DIR/d33
2643 # Read: 0, Write: 4, create/destroy: 2/0, stat: 1, punch: 0
2646 for ostnum in $(seq $OSTCOUNT); do
2647 # test-framework's OST numbering is one-based, while Lustre's
2649 ostname=$(printf "$FSNAME-OST%.4x" $((ostnum - 1)))
2650 # Parsing llobdstat's output sucks; we could grep the /proc
2651 # path, but that's likely to not be as portable as using the
2652 # llobdstat utility. So we parse lctl output instead.
2653 write_bytes=$(do_facet ost$ostnum lctl get_param -n \
2654 obdfilter/$ostname/stats |
2655 awk '/^write_bytes/ {print $7}' )
2656 echo "baseline_write_bytes@$OSTnum/$ostname=$write_bytes"
2657 if (( ${write_bytes:-0} > 0 ))
2664 $all_zeros || return 0
2667 echo foo > $DIR/d33/bar
2671 # Total up write_bytes after writing. We'd better find non-zeros.
2672 for ostnum in $(seq $OSTCOUNT); do
2673 ostname=$(printf "$FSNAME-OST%.4x" $((ostnum - 1)))
2674 write_bytes=$(do_facet ost$ostnum lctl get_param -n \
2675 obdfilter/$ostname/stats |
2676 awk '/^write_bytes/ {print $7}' )
2677 echo "write_bytes@$OSTnum/$ostname=$write_bytes"
2678 if (( ${write_bytes:-0} > 0 ))
2687 for ostnum in $(seq $OSTCOUNT); do
2688 ostname=$(printf "$FSNAME-OST%.4x" $((ostnum - 1)))
2689 echo "Check that write_bytes is present in obdfilter/*/stats:"
2690 do_facet ost$ostnum lctl get_param -n \
2691 obdfilter/$ostname/stats
2693 error "OST not keeping write_bytes stats (b22312)"
2696 run_test 33c "test llobdstat and write_bytes"
2699 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 2 MDTs" && return
2700 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2702 local remote_dir=$DIR/$tdir/remote_dir
2704 test_mkdir -p $DIR/$tdir
2705 $LFS mkdir -i $MDTIDX $remote_dir ||
2706 error "create remote directory failed"
2708 touch $remote_dir/$tfile
2709 chmod 444 $remote_dir/$tfile
2710 chown $RUNAS_ID $remote_dir/$tfile
2712 $RUNAS $OPENFILE -f O_RDWR $DIR/$tfile && error || true
2714 chown $RUNAS_ID $remote_dir
2715 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $remote_dir/f33 ||
2716 error "create" || true
2717 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $remote_dir/f33 &&
2718 error "open RDWR" || true
2719 $RUNAS $OPENFILE -f 1286739555 $remote_dir/f33 || true
2721 run_test 33d "openfile with 444 modes and malformed flags under remote dir"
2724 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2728 $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
2729 $LFS setdirstripe -i1 -c2 $DIR/$tdir/striped_dir1
2730 mkdir $DIR/$tdir/local_dir
2732 local s0_mode=$(stat -c%f $DIR/$tdir/striped_dir)
2733 local s1_mode=$(stat -c%f $DIR/$tdir/striped_dir1)
2734 local l_mode=$(stat -c%f $DIR/$tdir/local_dir)
2736 [ "$l_mode" = "$s0_mode" -a "$l_mode" = "$s1_mode" ] ||
2737 error "mkdir $l_mode striped0 $s0_mode striped1 $s1_mode"
2739 rmdir $DIR/$tdir/* || error "rmdir failed"
2742 $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
2743 $LFS setdirstripe -i1 -c2 $DIR/$tdir/striped_dir1
2744 mkdir $DIR/$tdir/local_dir
2746 s0_mode=$(stat -c%f $DIR/$tdir/striped_dir)
2747 s1_mode=$(stat -c%f $DIR/$tdir/striped_dir1)
2748 l_mode=$(stat -c%f $DIR/$tdir/local_dir)
2750 [ "$l_mode" = "$s0_mode" -a "$l_mode" = "$s1_mode" ] ||
2751 error "mkdir $l_mode striped0 $s0_mode striped1 $s1_mode 777"
2753 rmdir $DIR/$tdir/* || error "rmdir(umask 777) failed"
2756 $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
2757 $LFS setdirstripe -i1 -c2 $DIR/$tdir/striped_dir1
2758 mkdir $DIR/$tdir/local_dir
2760 s0_mode=$(stat -c%f $DIR/$tdir/striped_dir)
2761 s1_mode=$(stat -c%f $DIR/$tdir/striped_dir1)
2762 l_mode=$(stat -c%f $DIR/$tdir/local_dir)
2764 [ "$l_mode" = "$s0_mode" -a "$l_mode" = "$s1_mode" ] ||
2765 error "mkdir $l_mode striped0 $s0_mode striped1 $s1_mode 0"
2767 run_test 33e "mkdir and striped directory should have same mode"
2771 do_facet $SINGLEMDS $LCTL set_param mdt.*.enable_remote_dir_gid=0
2775 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2778 chmod go+rwx $DIR/$tdir
2779 do_facet $SINGLEMDS $LCTL set_param mdt.*.enable_remote_dir_gid=-1
2780 trap cleanup_33f EXIT
2782 $RUNAS lfs mkdir -c$MDSCOUNT $DIR/$tdir/striped_dir ||
2783 error "cannot create striped directory"
2785 $RUNAS touch $DIR/$tdir/striped_dir/{0..16} ||
2786 error "cannot create files in striped directory"
2788 $RUNAS rm $DIR/$tdir/striped_dir/{0..16} ||
2789 error "cannot remove files in striped directory"
2791 $RUNAS rmdir $DIR/$tdir/striped_dir ||
2792 error "cannot remove striped directory"
2796 run_test 33f "nonroot user can create, access, and remove a striped directory"
2798 TEST_34_SIZE=${TEST_34_SIZE:-2000000000000}
2801 $MCREATE $DIR/f34 || error
2802 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" || error
2803 $TRUNCATE $DIR/f34 $TEST_34_SIZE || error
2804 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" || error
2805 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2807 run_test 34a "truncate file that has not been opened ==========="
2810 [ ! -f $DIR/f34 ] && test_34a
2811 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2812 $OPENFILE -f O_RDONLY $DIR/f34
2813 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" || error
2814 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2816 run_test 34b "O_RDONLY opening file doesn't create objects ====="
2819 [ ! -f $DIR/f34 ] && test_34a
2820 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2821 $OPENFILE -f O_RDWR $DIR/f34
2822 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" && error
2823 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2825 run_test 34c "O_RDWR opening file-with-size works =============="
2828 [ ! -f $DIR/f34 ] && test_34a
2829 dd if=/dev/zero of=$DIR/f34 conv=notrunc bs=4k count=1 || error
2830 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2833 run_test 34d "write to sparse file ============================="
2837 $MCREATE $DIR/f34e || error
2838 $TRUNCATE $DIR/f34e 1000 || error
2839 $CHECKSTAT -s 1000 $DIR/f34e || error
2840 $OPENFILE -f O_RDWR $DIR/f34e
2841 $CHECKSTAT -s 1000 $DIR/f34e || error
2843 run_test 34e "create objects, some with size and some without =="
2845 test_34f() { # bug 6242, 6243
2846 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2849 $MCREATE $DIR/f34f || error
2850 $TRUNCATE $DIR/f34f $SIZE34F || error "truncating $DIR/f3f to $SIZE34F"
2851 dd if=$DIR/f34f of=$TMP/f34f
2852 $CHECKSTAT -s $SIZE34F $TMP/f34f || error "$TMP/f34f not $SIZE34F bytes"
2853 dd if=/dev/zero of=$TMP/f34fzero bs=$SIZE34F count=1
2854 cmp $DIR/f34f $TMP/f34fzero || error "$DIR/f34f not all zero"
2855 cmp $TMP/f34f $TMP/f34fzero || error "$TMP/f34f not all zero"
2856 rm $TMP/f34f $TMP/f34fzero $DIR/f34f
2858 run_test 34f "read from a file with no objects until EOF ======="
2861 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2862 dd if=/dev/zero of=$DIR/$tfile bs=1 count=100 seek=$TEST_34_SIZE || error
2863 $TRUNCATE $DIR/$tfile $((TEST_34_SIZE / 2))|| error
2864 $CHECKSTAT -s $((TEST_34_SIZE / 2)) $DIR/$tfile || error "truncate failed"
2865 cancel_lru_locks osc
2866 $CHECKSTAT -s $((TEST_34_SIZE / 2)) $DIR/$tfile || \
2867 error "wrong size after lock cancel"
2869 $TRUNCATE $DIR/$tfile $TEST_34_SIZE || error
2870 $CHECKSTAT -s $TEST_34_SIZE $DIR/$tfile || \
2871 error "expanding truncate failed"
2872 cancel_lru_locks osc
2873 $CHECKSTAT -s $TEST_34_SIZE $DIR/$tfile || \
2874 error "wrong expanded size after lock cancel"
2876 run_test 34g "truncate long file ==============================="
2879 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2883 dd if=/dev/zero of=$DIR/$tfile bs=1M count=10 || error
2884 sync # Flush the cache so that multiop below does not block on cache
2885 # flush when getting the group lock
2886 $MULTIOP $DIR/$tfile OG${gid}T${sz}g${gid}c &
2889 # Since just timed wait is not good enough, let's do a sync write
2890 # that way we are sure enough time for a roundtrip + processing
2891 # passed + 2 seconds of extra margin.
2892 dd if=/dev/zero of=$DIR/${tfile}-1 bs=4096 oflag=direct count=1
2896 if [[ `ps h -o comm -p $MULTIPID` == "multiop" ]]; then
2897 error "Multiop blocked on ftruncate, pid=$MULTIPID"
2901 local nsz=`stat -c %s $DIR/$tfile`
2902 [[ $nsz == $sz ]] || error "New size wrong $nsz != $sz"
2904 run_test 34h "ftruncate file under grouplock should not block"
2907 cp /bin/sh $DIR/f35a
2909 chown $RUNAS_ID $DIR/f35a
2910 $RUNAS $DIR/f35a && error || true
2913 run_test 35a "exec file with mode 444 (should return and not leak) ====="
2917 utime $DIR/f36 || error
2919 run_test 36a "MDS utime check (mknod, utime) ==================="
2923 utime $DIR/f36 || error
2925 run_test 36b "OST utime check (open, utime) ===================="
2930 chown $RUNAS_ID $DIR/d36
2931 $RUNAS utime $DIR/d36/f36 || error
2933 run_test 36c "non-root MDS utime check (mknod, utime) =========="
2936 [ ! -d $DIR/d36 ] && test_36c
2937 echo "" > $DIR/d36/f36
2938 $RUNAS utime $DIR/d36/f36 || error
2940 run_test 36d "non-root OST utime check (open, utime) ==========="
2943 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID -- skipping" && return
2944 test_mkdir -p $DIR/$tdir
2945 touch $DIR/$tdir/$tfile
2946 $RUNAS utime $DIR/$tdir/$tfile && \
2947 error "utime worked, expected failure" || true
2949 run_test 36e "utime on non-owned file (should return error) ===="
2953 local LANG_SAVE=$LANG
2954 local LC_LANG_SAVE=$LC_LANG
2955 export LANG=C LC_LANG=C # for date language
2957 DATESTR="Dec 20 2000"
2958 test_mkdir -p $DIR/$tdir
2959 lctl set_param fail_loc=$fl
2961 cp /etc/hosts $DIR/$tdir/$tfile
2962 sync & # write RPC generated with "current" inode timestamp, but delayed
2964 touch --date="$DATESTR" $DIR/$tdir/$tfile # setattr timestamp in past
2965 LS_BEFORE="`ls -l $DIR/$tdir/$tfile`" # old timestamp from client cache
2966 cancel_lru_locks osc
2967 LS_AFTER="`ls -l $DIR/$tdir/$tfile`" # timestamp from OST object
2969 [ "$LS_BEFORE" != "$LS_AFTER" ] && \
2970 echo "BEFORE: $LS_BEFORE" && \
2971 echo "AFTER : $LS_AFTER" && \
2972 echo "WANT : $DATESTR" && \
2973 error "$DIR/$tdir/$tfile timestamps changed" || true
2975 export LANG=$LANG_SAVE LC_LANG=$LC_LANG_SAVE
2979 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2980 #define OBD_FAIL_OST_BRW_PAUSE_BULK 0x214
2981 subr_36fh "0x80000214"
2983 run_test 36f "utime on file racing with OST BRW write =========="
2986 remote_ost_nodsh && skip "remote OST with nodsh" && return
2987 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2992 test_mkdir -p $DIR/$tdir
2993 fmd_max_age=$(do_facet ost1 \
2994 "lctl get_param -n obdfilter.*.client_cache_seconds 2> /dev/null | \
2997 fmd_before=$(do_facet ost1 \
2998 "awk '/ll_fmd_cache/ {print \\\$2}' /proc/slabinfo")
2999 touch $DIR/$tdir/$tfile
3000 sleep $((fmd_max_age + 12))
3001 fmd_after=$(do_facet ost1 \
3002 "awk '/ll_fmd_cache/ {print \\\$2}' /proc/slabinfo")
3004 echo "fmd_before: $fmd_before"
3005 echo "fmd_after: $fmd_after"
3006 [[ $fmd_after -gt $fmd_before ]] &&
3007 echo "AFTER: $fmd_after > BEFORE: $fmd_before" &&
3008 error "fmd didn't expire after ping" || true
3010 run_test 36g "filter mod data cache expiry ====================="
3013 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3014 #define OBD_FAIL_OST_BRW_PAUSE_BULK2 0x227
3015 subr_36fh "0x80000227"
3017 run_test 36h "utime on file racing with OST BRW write =========="
3020 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
3022 test_mkdir $DIR/$tdir
3023 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR/$tdir/striped_dir
3025 local mtime=$(stat -c%Y $DIR/$tdir/striped_dir)
3026 local new_mtime=$((mtime + 200))
3028 #change Modify time of striped dir
3029 touch -m -d @$new_mtime $DIR/$tdir/striped_dir ||
3030 error "change mtime failed"
3032 local got=$(stat -c%Y $DIR/$tdir/striped_dir)
3034 [ "$new_mtime" = "$got" ] || error "expect $new_mtime got $got"
3036 run_test 36i "change mtime on striped directory"
3038 # test_37 - duplicate with tests 32q 32r
3041 local file=$DIR/$tfile
3043 openfile -f O_DIRECTORY $file
3046 [ $RC -eq 0 ] && error "opened file $file with O_DIRECTORY" || true
3047 [ $RC -eq $ENOTDIR ] || error "error $RC should be ENOTDIR ($ENOTDIR)"
3049 run_test 38 "open a regular file with O_DIRECTORY should return -ENOTDIR ==="
3053 touch $DIR/${tfile}2
3054 # ls -l $DIR/$tfile $DIR/${tfile}2
3055 # ls -lu $DIR/$tfile $DIR/${tfile}2
3056 # ls -lc $DIR/$tfile $DIR/${tfile}2
3058 $OPENFILE -f O_CREAT:O_TRUNC:O_WRONLY $DIR/${tfile}2
3059 if [ ! $DIR/${tfile}2 -nt $DIR/$tfile ]; then
3061 ls -l --full-time $DIR/$tfile $DIR/${tfile}2
3063 ls -lu --full-time $DIR/$tfile $DIR/${tfile}2
3065 ls -lc --full-time $DIR/$tfile $DIR/${tfile}2
3066 error "O_TRUNC didn't change timestamps"
3069 run_test 39 "mtime changed on create ==========================="
3072 test_mkdir -p -c1 $DIR/$tdir
3073 cp -p /etc/passwd $DIR/$tdir/fopen
3074 cp -p /etc/passwd $DIR/$tdir/flink
3075 cp -p /etc/passwd $DIR/$tdir/funlink
3076 cp -p /etc/passwd $DIR/$tdir/frename
3077 ln $DIR/$tdir/funlink $DIR/$tdir/funlink2
3080 echo "aaaaaa" >> $DIR/$tdir/fopen
3081 echo "aaaaaa" >> $DIR/$tdir/flink
3082 echo "aaaaaa" >> $DIR/$tdir/funlink
3083 echo "aaaaaa" >> $DIR/$tdir/frename
3085 local open_new=`stat -c %Y $DIR/$tdir/fopen`
3086 local link_new=`stat -c %Y $DIR/$tdir/flink`
3087 local unlink_new=`stat -c %Y $DIR/$tdir/funlink`
3088 local rename_new=`stat -c %Y $DIR/$tdir/frename`
3090 cat $DIR/$tdir/fopen > /dev/null
3091 ln $DIR/$tdir/flink $DIR/$tdir/flink2
3092 rm -f $DIR/$tdir/funlink2
3093 mv -f $DIR/$tdir/frename $DIR/$tdir/frename2
3095 for (( i=0; i < 2; i++ )) ; do
3096 local open_new2=`stat -c %Y $DIR/$tdir/fopen`
3097 local link_new2=`stat -c %Y $DIR/$tdir/flink`
3098 local unlink_new2=`stat -c %Y $DIR/$tdir/funlink`
3099 local rename_new2=`stat -c %Y $DIR/$tdir/frename2`
3101 [ $open_new2 -eq $open_new ] || error "open file reverses mtime"
3102 [ $link_new2 -eq $link_new ] || error "link file reverses mtime"
3103 [ $unlink_new2 -eq $unlink_new ] || error "unlink file reverses mtime"
3104 [ $rename_new2 -eq $rename_new ] || error "rename file reverses mtime"
3106 cancel_lru_locks osc
3107 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3110 run_test 39b "mtime change on open, link, unlink, rename ======"
3112 # this should be set to past
3113 TEST_39_MTIME=`date -d "1 year ago" +%s`
3119 local mtime0=`stat -c %Y $DIR1/$tfile`
3121 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3122 local mtime1=`stat -c %Y $DIR1/$tfile`
3123 [ "$mtime1" = $TEST_39_MTIME ] || \
3124 error "mtime is not set to past: $mtime1, should be $TEST_39_MTIME"
3127 echo hello >> $DIR1/$tfile
3129 local mtime2=`stat -c %Y $DIR1/$tfile`
3130 [ "$mtime2" -ge "$d1" ] && [ "$mtime2" -le "$d2" ] || \
3131 error "mtime is not updated on write: $d1 <= $mtime2 <= $d2"
3133 mv $DIR1/$tfile $DIR1/$tfile-1
3135 for (( i=0; i < 2; i++ )) ; do
3136 local mtime3=`stat -c %Y $DIR1/$tfile-1`
3137 [ "$mtime2" = "$mtime3" ] || \
3138 error "mtime ($mtime2) changed (to $mtime3) on rename"
3140 cancel_lru_locks osc
3141 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3144 run_test 39c "mtime change on rename ==========================="
3148 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3151 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3153 for (( i=0; i < 2; i++ )) ; do
3154 local mtime=`stat -c %Y $DIR1/$tfile`
3155 [ $mtime = $TEST_39_MTIME ] || \
3156 error "mtime($mtime) is not set to $TEST_39_MTIME"
3158 cancel_lru_locks osc
3159 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3162 run_test 39d "create, utime, stat =============================="
3166 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3168 local mtime1=`stat -c %Y $DIR1/$tfile`
3170 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3172 for (( i=0; i < 2; i++ )) ; do
3173 local mtime2=`stat -c %Y $DIR1/$tfile`
3174 [ $mtime2 = $TEST_39_MTIME ] || \
3175 error "mtime($mtime2) is not set to $TEST_39_MTIME"
3177 cancel_lru_locks osc
3178 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3181 run_test 39e "create, stat, utime, stat ========================"
3185 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3187 mtime1=`stat -c %Y $DIR1/$tfile`
3190 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3192 for (( i=0; i < 2; i++ )) ; do
3193 local mtime2=`stat -c %Y $DIR1/$tfile`
3194 [ $mtime2 = $TEST_39_MTIME ] || \
3195 error "mtime($mtime2) is not set to $TEST_39_MTIME"
3197 cancel_lru_locks osc
3198 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3201 run_test 39f "create, stat, sleep, utime, stat ================="
3205 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3206 echo hello >> $DIR1/$tfile
3207 local mtime1=`stat -c %Y $DIR1/$tfile`
3210 chmod o+r $DIR1/$tfile
3212 for (( i=0; i < 2; i++ )) ; do
3213 local mtime2=`stat -c %Y $DIR1/$tfile`
3214 [ "$mtime1" = "$mtime2" ] || \
3215 error "lost mtime: $mtime2, should be $mtime1"
3217 cancel_lru_locks osc
3218 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3221 run_test 39g "write, chmod, stat ==============================="
3225 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3230 echo hello >> $DIR1/$tfile
3231 local mtime1=`stat -c %Y $DIR1/$tfile`
3233 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3235 if [ "$d1" != "$d2" ]; then
3236 echo "write and touch not within one second"
3238 for (( i=0; i < 2; i++ )) ; do
3239 local mtime2=`stat -c %Y $DIR1/$tfile`
3240 [ "$mtime2" = $TEST_39_MTIME ] || \
3241 error "lost mtime: $mtime2, should be $TEST_39_MTIME"
3243 cancel_lru_locks osc
3244 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3248 run_test 39h "write, utime within one second, stat ============="
3251 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3255 echo hello >> $DIR1/$tfile
3256 local mtime1=`stat -c %Y $DIR1/$tfile`
3258 mv $DIR1/$tfile $DIR1/$tfile-1
3260 for (( i=0; i < 2; i++ )) ; do
3261 local mtime2=`stat -c %Y $DIR1/$tfile-1`
3263 [ "$mtime1" = "$mtime2" ] || \
3264 error "lost mtime: $mtime2, should be $mtime1"
3266 cancel_lru_locks osc
3267 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3270 run_test 39i "write, rename, stat =============================="
3273 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3274 start_full_debug_logging
3278 #define OBD_FAIL_OSC_DELAY_SETTIME 0x412
3279 lctl set_param fail_loc=0x80000412
3280 multiop_bg_pause $DIR1/$tfile oO_RDWR:w2097152_c ||
3281 error "multiop failed"
3283 local mtime1=`stat -c %Y $DIR1/$tfile`
3285 mv $DIR1/$tfile $DIR1/$tfile-1
3287 kill -USR1 $multipid
3288 wait $multipid || error "multiop close failed"
3290 for (( i=0; i < 2; i++ )) ; do
3291 local mtime2=`stat -c %Y $DIR1/$tfile-1`
3292 [ "$mtime1" = "$mtime2" ] ||
3293 error "mtime is lost on close: $mtime2, " \
3296 cancel_lru_locks osc
3297 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3299 lctl set_param fail_loc=0
3300 stop_full_debug_logging
3302 run_test 39j "write, rename, close, stat ======================="
3305 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3309 multiop_bg_pause $DIR1/$tfile oO_RDWR:w2097152_c || error "multiop failed"
3311 local mtime1=`stat -c %Y $DIR1/$tfile`
3313 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3315 kill -USR1 $multipid
3316 wait $multipid || error "multiop close failed"
3318 for (( i=0; i < 2; i++ )) ; do
3319 local mtime2=`stat -c %Y $DIR1/$tfile`
3321 [ "$mtime2" = $TEST_39_MTIME ] || \
3322 error "mtime is lost on close: $mtime2, should be $TEST_39_MTIME"
3324 cancel_lru_locks osc
3325 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3328 run_test 39k "write, utime, close, stat ========================"
3330 # this should be set to future
3331 TEST_39_ATIME=`date -d "1 year" +%s`
3334 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3335 remote_mds_nodsh && skip "remote MDS with nodsh" && return
3336 local atime_diff=$(do_facet $SINGLEMDS \
3337 lctl get_param -n mdd.*MDT0000*.atime_diff)
3341 # test setting directory atime to future
3342 touch -a -d @$TEST_39_ATIME $DIR/$tdir
3343 local atime=$(stat -c %X $DIR/$tdir)
3344 [ "$atime" = $TEST_39_ATIME ] || \
3345 error "atime is not set to future: $atime, $TEST_39_ATIME"
3347 # test setting directory atime from future to now
3348 local d1=$(date +%s)
3350 local d2=$(date +%s)
3352 cancel_lru_locks mdc
3353 atime=$(stat -c %X $DIR/$tdir)
3354 [ "$atime" -ge "$d1" -a "$atime" -le "$d2" ] || \
3355 error "atime is not updated from future: $atime, $d1<atime<$d2"
3357 do_facet $SINGLEMDS lctl set_param -n mdd.*MDT0000*.atime_diff=2
3360 # test setting directory atime when now > dir atime + atime_diff
3364 cancel_lru_locks mdc
3365 atime=$(stat -c %X $DIR/$tdir)
3366 [ "$atime" -ge "$d1" -a "$atime" -le "$d2" ] || \
3367 error "atime is not updated : $atime, should be $d2"
3369 do_facet $SINGLEMDS lctl set_param -n mdd.*MDT0000*.atime_diff=60
3372 # test not setting directory atime when now < dir atime + atime_diff
3374 cancel_lru_locks mdc
3375 atime=$(stat -c %X $DIR/$tdir)
3376 [ "$atime" -ge "$d1" -a "$atime" -le "$d2" ] || \
3377 error "atime is updated to $atime, should remain $d1<atime<$d2"
3379 do_facet $SINGLEMDS \
3380 lctl set_param -n mdd.*MDT0000*.atime_diff=$atime_diff
3382 run_test 39l "directory atime update ==========================="
3385 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3388 local far_past_mtime=$(date -d "May 29 1953" +%s)
3389 local far_past_atime=$(date -d "Dec 17 1903" +%s)
3391 touch -m -d @$far_past_mtime $DIR1/$tfile
3392 touch -a -d @$far_past_atime $DIR1/$tfile
3394 for (( i=0; i < 2; i++ )) ; do
3395 local timestamps=$(stat -c "%X %Y" $DIR1/$tfile)
3396 [ "$timestamps" = "$far_past_atime $far_past_mtime" ] || \
3397 error "atime or mtime set incorrectly"
3399 cancel_lru_locks osc
3400 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3403 run_test 39m "test atime and mtime before 1970"
3405 test_39n() { # LU-3832
3406 local atime_diff=$(do_facet $SINGLEMDS \
3407 lctl get_param -n mdd.*MDT0000*.atime_diff)
3412 do_facet $SINGLEMDS lctl set_param -n mdd.*MDT0000*.atime_diff=1
3415 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 status=noxfer
3416 atime0=$(stat -c %X $DIR/$tfile)
3419 $MULTIOP $DIR/$tfile oO_RDONLY:O_NOATIME:r4096c
3420 atime1=$(stat -c %X $DIR/$tfile)
3423 cancel_lru_locks mdc
3424 cancel_lru_locks osc
3425 $MULTIOP $DIR/$tfile oO_RDONLY:O_NOATIME:r4096c
3426 atime2=$(stat -c %X $DIR/$tfile)
3428 do_facet $SINGLEMDS \
3429 lctl set_param -n mdd.*MDT0000*.atime_diff=$atime_diff
3431 [ "$atime0" -eq "$atime1" ] || error "atime0 $atime0 != atime1 $atime1"
3432 [ "$atime1" -eq "$atime2" ] || error "atime0 $atime0 != atime1 $atime1"
3434 run_test 39n "check that O_NOATIME is honored"
3437 TESTDIR=$DIR/$tdir/$tfile
3438 [ -e $TESTDIR ] && rm -rf $TESTDIR
3445 links2=$(stat -c %h .)
3446 [ $(($links1 + 2)) != $links2 ] &&
3447 error "wrong links count $(($links1 + 2)) != $links2"
3449 links3=$(stat -c %h .)
3450 [ $(($links1 + 1)) != $links3 ] &&
3451 error "wrong links count $links1 != $links3"
3454 run_test 39o "directory cached attributes updated after create ========"
3457 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 2 MDTs" && return
3459 TESTDIR=$DIR/$tdir/$tfile
3460 [ -e $TESTDIR ] && rm -rf $TESTDIR
3461 test_mkdir -p $TESTDIR
3465 $LFS mkdir -i $MDTIDX $TESTDIR/remote_dir1
3466 $LFS mkdir -i $MDTIDX $TESTDIR/remote_dir2
3468 links2=$(stat -c %h .)
3469 [ $(($links1 + 2)) != $links2 ] &&
3470 error "wrong links count $(($links1 + 2)) != $links2"
3472 links3=$(stat -c %h .)
3473 [ $(($links1 + 1)) != $links3 ] &&
3474 error "wrong links count $links1 != $links3"
3477 run_test 39p "remote directory cached attributes updated after create ========"
3481 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1
3482 $RUNAS $OPENFILE -f O_WRONLY:O_TRUNC $DIR/$tfile &&
3483 error "openfile O_WRONLY:O_TRUNC $tfile failed"
3484 $CHECKSTAT -t file -s 4096 $DIR/$tfile ||
3485 error "$tfile is not 4096 bytes in size"
3487 run_test 40 "failed open(O_TRUNC) doesn't truncate ============="
3491 small_write $DIR/f41 18
3493 run_test 41 "test small file write + fstat ====================="
3495 count_ost_writes() {
3496 lctl get_param -n osc.*.stats |
3497 awk -vwrites=0 '/ost_write/ { writes += $2 } \
3498 END { printf("%0.0f", writes) }'
3505 BG_DIRTY_RATIO_SAVE=10
3506 MAX_BG_DIRTY_RATIO=25
3510 # in 2.6, restore /proc/sys/vm/dirty_writeback_centisecs,
3511 # dirty_ratio, dirty_background_ratio
3512 if [ -f /proc/sys/vm/dirty_writeback_centisecs ]; then
3513 sysctl -w vm.dirty_writeback_centisecs=$WRITEBACK_SAVE
3514 sysctl -w vm.dirty_background_ratio=$BG_DIRTY_RATIO_SAVE
3515 sysctl -w vm.dirty_ratio=$DIRTY_RATIO_SAVE
3517 # if file not here, we are a 2.4 kernel
3518 kill -CONT `pidof kupdated`
3523 # setup the trap first, so someone cannot exit the test at the
3524 # exact wrong time and mess up a machine
3525 trap start_writeback EXIT
3526 # in 2.6, save and 0 /proc/sys/vm/dirty_writeback_centisecs
3527 if [ -f /proc/sys/vm/dirty_writeback_centisecs ]; then
3528 WRITEBACK_SAVE=`sysctl -n vm.dirty_writeback_centisecs`
3529 sysctl -w vm.dirty_writeback_centisecs=0
3530 sysctl -w vm.dirty_writeback_centisecs=0
3531 # save and increase /proc/sys/vm/dirty_ratio
3532 DIRTY_RATIO_SAVE=`sysctl -n vm.dirty_ratio`
3533 sysctl -w vm.dirty_ratio=$MAX_DIRTY_RATIO
3534 # save and increase /proc/sys/vm/dirty_background_ratio
3535 BG_DIRTY_RATIO_SAVE=`sysctl -n vm.dirty_background_ratio`
3536 sysctl -w vm.dirty_background_ratio=$MAX_BG_DIRTY_RATIO
3538 # if file not here, we are a 2.4 kernel
3539 kill -STOP `pidof kupdated`
3543 # ensure that all stripes have some grant before we test client-side cache
3545 for i in `seq -f $DIR/f42-%g 1 $OSTCOUNT`; do
3546 dd if=/dev/zero of=$i bs=4k count=1
3551 # Tests 42* verify that our behaviour is correct WRT caching, file closure,
3552 # file truncation, and file removal.
3554 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3556 cancel_lru_locks osc
3558 sync; sleep 1; sync # just to be safe
3559 BEFOREWRITES=`count_ost_writes`
3560 lctl get_param -n osc.*[oO][sS][cC][_-]*.cur_grant_bytes | grep "[0-9]"
3561 dd if=/dev/zero of=$DIR/f42a bs=1024 count=100
3562 AFTERWRITES=`count_ost_writes`
3563 [ $BEFOREWRITES -eq $AFTERWRITES ] || \
3564 error "$BEFOREWRITES < $AFTERWRITES"
3567 run_test 42a "ensure that we don't flush on close =============="
3570 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3572 cancel_lru_locks osc
3575 dd if=/dev/zero of=$DIR/f42b bs=1024 count=100
3576 BEFOREWRITES=$(count_ost_writes)
3577 $MUNLINK $DIR/f42b || error "$MUNLINK $DIR/f42b: $?"
3578 AFTERWRITES=$(count_ost_writes)
3579 if [[ $BEFOREWRITES -lt $AFTERWRITES ]]; then
3580 error "$BEFOREWRITES < $AFTERWRITES on unlink"
3582 BEFOREWRITES=$(count_ost_writes)
3583 sync || error "sync: $?"
3584 AFTERWRITES=$(count_ost_writes)
3585 if [[ $BEFOREWRITES -lt $AFTERWRITES ]]; then
3586 error "$BEFOREWRITES < $AFTERWRITES on sync"
3588 dmesg | grep 'error from obd_brw_async' && error 'error writing back'
3592 run_test 42b "test destroy of file with cached dirty data ======"
3594 # if these tests just want to test the effect of truncation,
3595 # they have to be very careful. consider:
3596 # - the first open gets a {0,EOF}PR lock
3597 # - the first write conflicts and gets a {0, count-1}PW
3598 # - the rest of the writes are under {count,EOF}PW
3599 # - the open for truncate tries to match a {0,EOF}PR
3600 # for the filesize and cancels the PWs.
3601 # any number of fixes (don't get {0,EOF} on open, match
3602 # composite locks, do smarter file size management) fix
3603 # this, but for now we want these tests to verify that
3604 # the cancellation with truncate intent works, so we
3605 # start the file with a full-file pw lock to match against
3606 # until the truncate.
3611 cancel_lru_locks osc
3613 # prime the file with 0,EOF PW to match
3617 # now the real test..
3618 dd if=/dev/zero of=$file bs=1024 count=100
3619 BEFOREWRITES=`count_ost_writes`
3620 $TRUNCATE $file $offset
3621 cancel_lru_locks osc
3622 AFTERWRITES=`count_ost_writes`
3627 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3629 [ $BEFOREWRITES -eq $AFTERWRITES ] && \
3630 error "beforewrites $BEFOREWRITES == afterwrites $AFTERWRITES on truncate"
3633 run_test 42c "test partial truncate of file with cached dirty data"
3636 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3638 [ $BEFOREWRITES -eq $AFTERWRITES ] || \
3639 error "beforewrites $BEFOREWRITES != afterwrites $AFTERWRITES on truncate"
3642 run_test 42d "test complete truncate of file with cached dirty data"
3644 test_42e() { # bug22074
3645 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3646 local TDIR=$DIR/${tdir}e
3647 local pagesz=$(page_size)
3648 local pages=16 # hardcoded 16 pages, don't change it.
3649 local files=$((OSTCOUNT * 500)) # hopefully 500 files on each OST
3650 local proc_osc0="osc.${FSNAME}-OST0000-osc-[^MDT]*"
3654 test_mkdir -p $DIR/${tdir}e
3655 $SETSTRIPE -c 1 $TDIR
3656 createmany -o $TDIR/f $files
3658 max_dirty_mb=$($LCTL get_param -n $proc_osc0/max_dirty_mb)
3660 # we assume that with $OSTCOUNT files, at least one of them will
3661 # be allocated on OST0.
3662 warmup_files=$((OSTCOUNT * max_dirty_mb))
3663 createmany -o $TDIR/w $warmup_files
3665 # write a large amount of data into one file and sync, to get good
3666 # avail_grant number from OST.
3667 for ((i=0; i<$warmup_files; i++)); do
3668 idx=$($GETSTRIPE -i $TDIR/w$i)
3669 [ $idx -ne 0 ] && continue
3670 dd if=/dev/zero of=$TDIR/w$i bs="$max_dirty_mb"M count=1
3673 [[ $i -gt $warmup_files ]] && error "OST0 is still cold"
3675 $LCTL get_param $proc_osc0/cur_dirty_bytes
3676 $LCTL get_param $proc_osc0/cur_grant_bytes
3678 # create as much dirty pages as we can while not to trigger the actual
3679 # RPCs directly. but depends on the env, VFS may trigger flush during this
3680 # period, hopefully we are good.
3681 for ((i=0; i<$warmup_files; i++)); do
3682 idx=$($GETSTRIPE -i $TDIR/w$i)
3683 [ $idx -ne 0 ] && continue
3684 dd if=/dev/zero of=$TDIR/w$i bs=1M count=1 2>/dev/null
3686 $LCTL get_param $proc_osc0/cur_dirty_bytes
3687 $LCTL get_param $proc_osc0/cur_grant_bytes
3689 # perform the real test
3690 $LCTL set_param $proc_osc0/rpc_stats 0
3691 for ((;i<$files; i++)); do
3692 [ $($GETSTRIPE -i $TDIR/f$i) -eq 0 ] || continue
3693 dd if=/dev/zero of=$TDIR/f$i bs=$pagesz count=$pages 2>/dev/null
3696 $LCTL get_param $proc_osc0/rpc_stats
3699 local have_ppr=false
3700 $LCTL get_param $proc_osc0/rpc_stats |
3701 while read PPR RRPC RPCT RCUM BAR WRPC WPCT WCUM; do
3702 # skip lines until we are at the RPC histogram data
3703 [ "$PPR" == "pages" ] && have_ppr=true && continue
3704 $have_ppr || continue
3706 # we only want the percent stat for < 16 pages
3707 [[ $(echo $PPR | tr -d ':') -ge $pages ]] && break
3709 percent=$((percent + WPCT))
3710 if [[ $percent -gt 15 ]]; then
3711 error "less than 16-pages write RPCs" \
3718 run_test 42e "verify sub-RPC writes are not done synchronously"
3721 test_mkdir -p $DIR/$tdir
3722 cp -p /bin/ls $DIR/$tdir/$tfile
3723 $MULTIOP $DIR/$tdir/$tfile Ow_c &
3725 # give multiop a chance to open
3728 $DIR/$tdir/$tfile && error || true
3731 run_test 43 "execution of file opened for write should return -ETXTBSY"
3734 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3735 test_mkdir -p $DIR/$tdir
3736 cp -p `which $MULTIOP` $DIR/$tdir/multiop ||
3737 cp -p multiop $DIR/$tdir/multiop
3738 MULTIOP_PROG=$DIR/$tdir/multiop multiop_bg_pause $TMP/$tfile.junk O_c ||
3741 $MULTIOP $DIR/$tdir/multiop Oc && error "expected error, got success"
3742 kill -USR1 $MULTIOP_PID || return 2
3743 wait $MULTIOP_PID || return 3
3744 rm $TMP/$tfile.junk $DIR/$tdir/multiop
3746 run_test 43a "open(RDWR) of file being executed should return -ETXTBSY"
3749 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3750 test_mkdir -p $DIR/$tdir
3751 cp -p `which $MULTIOP` $DIR/$tdir/multiop ||
3752 cp -p multiop $DIR/$tdir/multiop
3753 MULTIOP_PROG=$DIR/$tdir/multiop multiop_bg_pause $TMP/$tfile.junk O_c ||
3756 $TRUNCATE $DIR/$tdir/multiop 0 && error "expected error, got success"
3757 kill -USR1 $MULTIOP_PID || return 2
3758 wait $MULTIOP_PID || return 3
3759 rm $TMP/$tfile.junk $DIR/$tdir/multiop
3761 run_test 43b "truncate of file being executed should return -ETXTBSY"
3764 local testdir="$DIR/$tdir"
3765 test_mkdir -p $DIR/$tdir
3767 ( cd $(dirname $SHELL) && md5sum $(basename $SHELL) ) | \
3768 ( cd $testdir && md5sum -c)
3770 run_test 43c "md5sum of copy into lustre========================"
3773 [[ $OSTCOUNT -lt 2 ]] && skip_env "skipping 2-stripe test" && return
3774 dd if=/dev/zero of=$DIR/f1 bs=4k count=1 seek=1023
3775 dd if=$DIR/f1 bs=4k count=1 > /dev/null
3777 run_test 44 "zero length read from a sparse stripe ============="
3780 local nstripe=$($LCTL lov_getconfig $DIR | grep default_stripe_count: |
3782 [ -z "$nstripe" ] && skip "can't get stripe info" && return
3783 [[ $nstripe -gt $OSTCOUNT ]] &&
3784 skip "Wrong default_stripe_count: $nstripe (OSTCOUNT: $OSTCOUNT)" &&
3786 local stride=$($LCTL lov_getconfig $DIR | grep default_stripe_size: |
3788 if [[ $nstripe -eq 0 || $nstripe -eq -1 ]]; then
3789 nstripe=$($LCTL lov_getconfig $DIR | grep obd_count: |
3793 OFFSETS="0 $((stride/2)) $((stride-1))"
3794 for offset in $OFFSETS; do
3795 for i in $(seq 0 $((nstripe-1))); do
3796 local GLOBALOFFSETS=""
3798 local size=$((((i + 2 * $nstripe )*$stride + $offset)))
3799 local myfn=$DIR/d44a-$size
3800 echo "--------writing $myfn at $size"
3801 ll_sparseness_write $myfn $size ||
3802 error "ll_sparseness_write"
3803 GLOBALOFFSETS="$GLOBALOFFSETS $size"
3804 ll_sparseness_verify $myfn $GLOBALOFFSETS ||
3805 error "ll_sparseness_verify $GLOBALOFFSETS"
3807 for j in $(seq 0 $((nstripe-1))); do
3809 size=$((((j + $nstripe )*$stride + $offset)))
3810 ll_sparseness_write $myfn $size ||
3811 error "ll_sparseness_write"
3812 GLOBALOFFSETS="$GLOBALOFFSETS $size"
3814 ll_sparseness_verify $myfn $GLOBALOFFSETS ||
3815 error "ll_sparseness_verify $GLOBALOFFSETS"
3820 run_test 44a "test sparse pwrite ==============================="
3824 for d in `lctl get_param -n osc.*.cur_dirty_bytes`; do
3830 before=`dirty_osc_total`
3831 echo executing "\"$*\""
3833 after=`dirty_osc_total`
3834 echo before $before, after $after
3837 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3839 # Obtain grants from OST if it supports it
3840 echo blah > ${f}_grant
3843 do_dirty_record "echo blah > $f"
3844 [[ $before -eq $after ]] && error "write wasn't cached"
3845 do_dirty_record "> $f"
3846 [[ $before -gt $after ]] || error "truncate didn't lower dirty count"
3847 do_dirty_record "echo blah > $f"
3848 [[ $before -eq $after ]] && error "write wasn't cached"
3849 do_dirty_record "sync"
3850 [[ $before -gt $after ]] || error "writeback didn't lower dirty count"
3851 do_dirty_record "echo blah > $f"
3852 [[ $before -eq $after ]] && error "write wasn't cached"
3853 do_dirty_record "cancel_lru_locks osc"
3854 [[ $before -gt $after ]] ||
3855 error "lock cancellation didn't lower dirty count"
3858 run_test 45 "osc io page accounting ============================"
3860 # in a 2 stripe file (lov.sh), page 1023 maps to page 511 in its object. this
3861 # test tickles a bug where re-dirtying a page was failing to be mapped to the
3862 # objects offset and an assert hit when an rpc was built with 1023's mapped
3863 # offset 511 and 511's raw 511 offset. it also found general redirtying bugs.
3865 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3869 dd if=/dev/zero of=$f bs=`page_size` seek=511 count=1
3871 dd conv=notrunc if=/dev/zero of=$f bs=`page_size` seek=1023 count=1
3872 dd conv=notrunc if=/dev/zero of=$f bs=`page_size` seek=511 count=1
3876 run_test 46 "dirtying a previously written page ================"
3878 # test_47 is removed "Device nodes check" is moved to test_28
3880 test_48a() { # bug 2399
3881 [ $(facet_fstype $SINGLEMDS) = "zfs" ] &&
3882 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.3.63) ] &&
3883 skip "MDS prior to 2.3.63 handle ZFS dir .. incorrectly" &&
3885 test_mkdir $DIR/$tdir
3887 mv $DIR/$tdir $DIR/$tdir.new || error "move directory failed"
3888 test_mkdir $DIR/$tdir || error "recreate directory failed"
3889 touch foo || error "'touch foo' failed after recreating cwd"
3890 test_mkdir bar || error "'mkdir foo' failed after recreating cwd"
3891 touch .foo || error "'touch .foo' failed after recreating cwd"
3892 test_mkdir .bar || error "'mkdir .foo' failed after recreating cwd"
3893 ls . > /dev/null || error "'ls .' failed after recreating cwd"
3894 ls .. > /dev/null || error "'ls ..' failed after removing cwd"
3895 cd . || error "'cd .' failed after recreating cwd"
3896 test_mkdir . && error "'mkdir .' worked after recreating cwd"
3897 rmdir . && error "'rmdir .' worked after recreating cwd"
3898 ln -s . baz || error "'ln -s .' failed after recreating cwd"
3899 cd .. || error "'cd ..' failed after recreating cwd"
3901 run_test 48a "Access renamed working dir (should return errors)="
3903 test_48b() { # bug 2399
3905 test_mkdir $DIR/$tdir
3907 rmdir $DIR/$tdir || error "remove cwd $DIR/$tdir failed"
3908 touch foo && error "'touch foo' worked after removing cwd"
3909 test_mkdir foo && error "'mkdir foo' worked after removing cwd"
3910 touch .foo && error "'touch .foo' worked after removing cwd"
3911 test_mkdir .foo && error "'mkdir .foo' worked after removing cwd"
3912 ls . > /dev/null && error "'ls .' worked after removing cwd"
3913 ls .. > /dev/null || error "'ls ..' failed after removing cwd"
3914 is_patchless || ( cd . && error "'cd .' worked after removing cwd" )
3915 test_mkdir . && error "'mkdir .' worked after removing cwd"
3916 rmdir . && error "'rmdir .' worked after removing cwd"
3917 ln -s . foo && error "'ln -s .' worked after removing cwd"
3918 cd .. || echo "'cd ..' failed after removing cwd `pwd`" #bug 3517
3920 run_test 48b "Access removed working dir (should return errors)="
3922 test_48c() { # bug 2350
3923 #lctl set_param debug=-1
3926 test_mkdir -p $DIR/$tdir/dir
3928 $TRACE rmdir $DIR/$tdir/dir || error "remove cwd $DIR/$tdir/dir failed"
3929 $TRACE touch foo && error "touch foo worked after removing cwd"
3930 $TRACE test_mkdir foo && error "'mkdir foo' worked after removing cwd"
3931 touch .foo && error "touch .foo worked after removing cwd"
3932 test_mkdir .foo && error "mkdir .foo worked after removing cwd"
3933 $TRACE ls . && error "'ls .' worked after removing cwd"
3934 $TRACE ls .. || error "'ls ..' failed after removing cwd"
3935 is_patchless || ( $TRACE cd . &&
3936 error "'cd .' worked after removing cwd" )
3937 $TRACE test_mkdir . && error "'mkdir .' worked after removing cwd"
3938 $TRACE rmdir . && error "'rmdir .' worked after removing cwd"
3939 $TRACE ln -s . foo && error "'ln -s .' worked after removing cwd"
3940 $TRACE cd .. || echo "'cd ..' failed after removing cwd `pwd`" #bug 3415
3942 run_test 48c "Access removed working subdir (should return errors)"
3944 test_48d() { # bug 2350
3945 #lctl set_param debug=-1
3948 test_mkdir -p $DIR/$tdir/dir
3950 $TRACE rmdir $DIR/$tdir/dir || error "remove cwd $DIR/$tdir/dir failed"
3951 $TRACE rmdir $DIR/$tdir || error "remove parent $DIR/$tdir failed"
3952 $TRACE touch foo && error "'touch foo' worked after removing parent"
3953 $TRACE test_mkdir foo && error "mkdir foo worked after removing parent"
3954 touch .foo && error "'touch .foo' worked after removing parent"
3955 test_mkdir .foo && error "mkdir .foo worked after removing parent"
3956 $TRACE ls . && error "'ls .' worked after removing parent"
3957 $TRACE ls .. && error "'ls ..' worked after removing parent"
3958 is_patchless || ( $TRACE cd . &&
3959 error "'cd .' worked after recreate parent" )
3960 $TRACE test_mkdir . && error "'mkdir .' worked after removing parent"
3961 $TRACE rmdir . && error "'rmdir .' worked after removing parent"
3962 $TRACE ln -s . foo && error "'ln -s .' worked after removing parent"
3963 is_patchless || ( $TRACE cd .. &&
3964 error "'cd ..' worked after removing parent" || true )
3966 run_test 48d "Access removed parent subdir (should return errors)"
3968 test_48e() { # bug 4134
3969 #lctl set_param debug=-1
3972 test_mkdir -p $DIR/$tdir/dir
3974 $TRACE rmdir $DIR/$tdir/dir || error "remove cwd $DIR/$tdir/dir failed"
3975 $TRACE rmdir $DIR/$tdir || error "remove parent $DIR/$tdir failed"
3976 $TRACE touch $DIR/$tdir || error "'touch $DIR/$tdir' failed"
3977 $TRACE chmod +x $DIR/$tdir || error "'chmod +x $DIR/$tdir' failed"
3978 # On a buggy kernel addition of "touch foo" after cd .. will
3979 # produce kernel oops in lookup_hash_it
3980 touch ../foo && error "'cd ..' worked after recreate parent"
3982 $TRACE rm $DIR/$tdir || error "rm '$DIR/$tdir' failed"
3984 run_test 48e "Access to recreated parent subdir (should return errors)"
3986 test_49() { # LU-1030
3987 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3988 # get ost1 size - lustre-OST0000
3989 ost1_size=$(do_facet ost1 $LFS df | grep ${ost1_svc} |
3991 # write 800M at maximum
3992 [[ $ost1_size -lt 2 ]] && ost1_size=2
3993 [[ $ost1_size -gt 819200 ]] && ost1_size=819200
3995 $SETSTRIPE -c 1 -i 0 $DIR/$tfile
3996 dd if=/dev/zero of=$DIR/$tfile bs=4k count=$((ost1_size >> 2)) &
3999 # change max_pages_per_rpc while writing the file
4000 local osc1_mppc=osc.$(get_osc_import_name client ost1).max_pages_per_rpc
4001 local orig_mppc=$($LCTL get_param -n $osc1_mppc)
4002 # loop until dd process exits
4003 while ps ax -opid | grep -wq $dd_pid; do
4004 $LCTL set_param $osc1_mppc=$((RANDOM % 256 + 1))
4005 sleep $((RANDOM % 5 + 1))
4007 # restore original max_pages_per_rpc
4008 $LCTL set_param $osc1_mppc=$orig_mppc
4009 rm $DIR/$tfile || error "rm $DIR/$tfile failed"
4011 run_test 49 "Change max_pages_per_rpc won't break osc extent"
4015 test_mkdir $DIR/$tdir
4017 ls /proc/$$/cwd || error "ls /proc/$$/cwd failed"
4019 run_test 50 "special situations: /proc symlinks ==============="
4021 test_51a() { # was test_51
4022 # bug 1516 - create an empty entry right after ".." then split dir
4023 test_mkdir -c1 $DIR/$tdir
4024 touch $DIR/$tdir/foo
4025 $MCREATE $DIR/$tdir/bar
4027 createmany -m $DIR/$tdir/longfile 201
4029 while [[ $(ls -sd $DIR/$tdir | awk '{ print $1 }') -eq 4 ]]; do
4030 $MCREATE $DIR/$tdir/longfile$FNUM
4035 ls -l $DIR/$tdir > /dev/null || error "ls -l $DIR/$tdir failed"
4037 run_test 51a "special situations: split htree with empty entry =="
4039 export NUMTEST=70000
4041 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4042 local BASE=$DIR/d${base}.${TESTSUITE}
4044 # cleanup the directory
4047 test_mkdir -p -c1 $BASE
4051 local mdtidx=$(printf "%04x" $($LFS getstripe -M $BASE))
4052 local numfree=$(lctl get_param -n mdc.$FSNAME-MDT$mdtidx*.filesfree)
4053 [[ $numfree -lt 21000 ]] &&
4054 skip "not enough free inodes ($numfree) on MDT$mdtidx" &&
4057 [[ $numfree -lt $NUMTEST ]] && NUMTEST=$(($numfree - 50)) &&
4058 echo "reduced count to $NUMTEST due to inodes on MDT$mdtidx"
4060 # need to check free space for the directories as well
4061 local blkfree=$(lctl get_param -n mdc.$FSNAME-MDT$mdtidx*.kbytesavail)
4062 numfree=$((blkfree / 4))
4063 [[ $numfree -lt $NUMTEST ]] && NUMTEST=$((numfree - 50)) &&
4064 echo "reduced count to $NUMTEST due to blocks on MDT$mdtidx"
4066 createmany -d $BASE/d $NUMTEST && echo $NUMTEST > $BASE/fnum ||
4070 echo "failed" > $BASE/fnum
4071 error "failed to create $NUMTEST subdirs in MDT$mdtidx:$BASE"
4074 run_test 51b "exceed 64k subdirectory nlink limit"
4076 test_51ba() { # LU-993
4077 local BASE=$DIR/d${base}.${TESTSUITE}
4078 # unlink all but 100 subdirectories, then check it still works
4080 [ -f $BASE/fnum ] && local NUMPREV=$(cat $BASE/fnum) && rm $BASE/fnum
4082 [ "$NUMPREV" != "failed" ] && NUMTEST=$NUMPREV
4083 local DELETE=$((NUMTEST - LEFT))
4085 # continue on to run this test even if 51b didn't finish,
4086 # just to delete the many subdirectories created.
4087 [ ! -d "${BASE}/d1" ] && skip "test_51b() not run" && return 0
4089 # for ldiskfs the nlink count should be 1, but this is OSD specific
4090 # and so this is listed for informational purposes only
4091 echo "nlink before: $(stat -c %h $BASE), created before: $NUMTEST"
4092 unlinkmany -d $BASE/d $DELETE
4095 if [ $RC -ne 0 ]; then
4096 if [ "$NUMPREV" == "failed" ]; then
4097 skip "previous setup failed"
4100 error "unlink of first $DELETE subdirs failed"
4105 echo "nlink between: $(stat -c %h $BASE)"
4106 # trim the first line of ls output
4107 local FOUND=$(($(ls -l ${BASE} | wc -l) - 1))
4108 [ $FOUND -ne $LEFT ] &&
4109 error "can't find subdirs: found only $FOUND/$LEFT"
4111 unlinkmany -d $BASE/d $DELETE $LEFT ||
4112 error "unlink of second $LEFT subdirs failed"
4113 # regardless of whether the backing filesystem tracks nlink accurately
4114 # or not, the nlink count shouldn't be more than "." and ".." here
4115 local AFTER=$(stat -c %h $BASE)
4116 [[ $AFTER -gt 2 ]] && error "nlink after: $AFTER > 2" ||
4117 echo "nlink after: $AFTER"
4119 run_test 51ba "verify nlink for many subdirectory cleanup"
4122 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4123 [[ $OSTCOUNT -lt 3 ]] &&
4124 skip_env "skipping test with few OSTs" && return
4125 test_mkdir -p $DIR/$tdir
4126 createmany -o $DIR/$tdir/t- 1000
4127 $GETSTRIPE $DIR/$tdir > $TMP/files
4128 for N in $(seq 0 $((OSTCOUNT - 1))); do
4129 OBJS[$N]=$(awk -vobjs=0 '($1 == '$N') { objs += 1 } \
4130 END { printf("%0.0f", objs) }' $TMP/files)
4131 OBJS0[$N]=$(grep -A 1 idx $TMP/files | awk -vobjs=0 \
4132 '($1 == '$N') { objs += 1 } \
4133 END { printf("%0.0f", objs) }')
4134 log "OST$N has ${OBJS[$N]} objects, ${OBJS0[$N]} are index 0"
4136 unlinkmany $DIR/$tdir/t- 1000
4139 for N in $(seq 1 $((OSTCOUNT - 1))); do
4140 [[ ${OBJS[$N]} -lt $((${OBJS[$NLAST]} - 20)) ]] &&
4141 error "OST $N has less objects vs OST $NLAST" \
4142 " (${OBJS[$N]} < ${OBJS[$NLAST]}"
4143 [[ ${OBJS[$N]} -gt $((${OBJS[$NLAST]} + 20)) ]] &&
4144 error "OST $N has less objects vs OST $NLAST" \
4145 " (${OBJS[$N]} < ${OBJS[$NLAST]}"
4147 [[ ${OBJS0[$N]} -lt $((${OBJS0[$NLAST]} - 20)) ]] &&
4148 error "OST $N has less #0 objects vs OST $NLAST" \
4149 " (${OBJS0[$N]} < ${OBJS0[$NLAST]}"
4150 [[ ${OBJS0[$N]} -gt $((${OBJS0[$NLAST]} + 20)) ]] &&
4151 error "OST $N has less #0 objects vs OST $NLAST" \
4152 " (${OBJS0[$N]} < ${OBJS0[$NLAST]}"
4156 run_test 51d "check object distribution ===================="
4159 if [ "$(facet_fstype $SINGLEMDS)" != ldiskfs ]; then
4160 skip "Only applicable to ldiskfs-based MDTs"
4164 test_mkdir -c1 $DIR/$tdir || error "create $tdir failed"
4165 test_mkdir -c1 $DIR/$tdir/d0 || error "create d0 failed"
4167 touch $DIR/$tdir/d0/foo
4168 createmany -l $DIR/$tdir/d0/foo $DIR/$tdir/d0/f- 65001 &&
4169 error "file exceed 65000 nlink limit!"
4170 unlinkmany $DIR/$tdir/d0/f- 65001
4173 run_test 51e "check file nlink limit"
4176 [ -f $DIR/$tdir/foo ] && chattr -a $DIR/$tdir/foo
4177 test_mkdir -p $DIR/$tdir
4178 touch $DIR/$tdir/foo
4179 chattr +a $DIR/$tdir/foo || error "chattr +a failed"
4180 echo bar >> $DIR/$tdir/foo || error "append bar failed"
4181 cp /etc/hosts $DIR/$tdir/foo && error "cp worked"
4182 rm -f $DIR/$tdir/foo 2>/dev/null && error "rm worked"
4183 link $DIR/$tdir/foo $DIR/$tdir/foo_link 2>/dev/null &&
4185 echo foo >> $DIR/$tdir/foo || error "append foo failed"
4186 mrename $DIR/$tdir/foo $DIR/$tdir/foo_ren && error "rename worked"
4187 lsattr $DIR/$tdir/foo | egrep -q "^-+a[-e]+ $DIR/$tdir/foo" ||
4189 chattr -a $DIR/$tdir/foo || error "chattr -a failed"
4190 cp -r $DIR/$tdir /tmp/
4191 rm -fr $DIR/$tdir || error "cleanup rm failed"
4193 run_test 52a "append-only flag test (should return errors) ====="
4196 [ -f $DIR/$tdir/foo ] && chattr -i $DIR/$tdir/foo
4197 test_mkdir -p $DIR/$tdir
4198 touch $DIR/$tdir/foo
4199 chattr +i $DIR/$tdir/foo || error "chattr +i failed"
4200 cat test > $DIR/$tdir/foo && error "cat test worked"
4201 cp /etc/hosts $DIR/$tdir/foo && error "cp worked"
4202 rm -f $DIR/$tdir/foo 2>/dev/null && error "rm worked"
4203 link $DIR/$tdir/foo $DIR/$tdir/foo_link 2>/dev/null &&
4205 echo foo >> $DIR/$tdir/foo && error "echo worked"
4206 mrename $DIR/$tdir/foo $DIR/$tdir/foo_ren && error "rename worked"
4207 [ -f $DIR/$tdir/foo ] || error "$tdir/foo is not a file"
4208 [ -f $DIR/$tdir/foo_ren ] && error "$tdir/foo_ren is not a file"
4209 lsattr $DIR/$tdir/foo | egrep -q "^-+i[-e]+ $DIR/$tdir/foo" ||
4211 chattr -i $DIR/$tdir/foo || error "chattr failed"
4213 rm -fr $DIR/$tdir || error "unable to remove $DIR/$tdir"
4215 run_test 52b "immutable flag test (should return errors) ======="
4218 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4219 remote_mds_nodsh && skip "remote MDS with nodsh" && return
4220 remote_ost_nodsh && skip "remote OST with nodsh" && return
4233 local support_last_seq=true
4235 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.3.60) ]] ||
4236 support_last_seq=false
4239 local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS)
4241 for value in $(do_facet $SINGLEMDS \
4242 $LCTL get_param osc.$mdtosc.prealloc_last_id) ; do
4243 param=$(echo ${value[0]} | cut -d "=" -f1)
4244 ostname=$(echo $param | cut -d "." -f2 | cut -d - -f 1-2)
4246 if $support_last_seq; then
4247 param_seq=$(echo $param |
4248 sed -e s/prealloc_last_id/prealloc_last_seq/g)
4249 mds_last_seq=$(do_facet $SINGLEMDS \
4250 $LCTL get_param -n $param_seq)
4252 mds_last=$(do_facet $SINGLEMDS $LCTL get_param -n $param)
4254 ostnum=$(index_from_ostuuid ${ostname}_UUID)
4255 node=$(facet_active_host ost$((ostnum+1)))
4256 param="obdfilter.$ostname.last_id"
4257 for ost_last in $(do_node $node $LCTL get_param -n $param) ; do
4258 echo "$ostname.last_id=$ost_last; MDS.last_id=$mds_last"
4259 ost_last_id=$ost_last
4261 if $support_last_seq; then
4262 ost_last_id=$(echo $ost_last |
4263 awk -F':' '{print $2}' |
4265 ost_last_seq=$(echo $ost_last |
4266 awk -F':' '{print $1}')
4267 [[ $ost_last_seq = $mds_last_seq ]] || continue
4270 if [[ $ost_last_id != $mds_last ]]; then
4271 error "$ost_last_id != $mds_last"
4278 $found || error "can not match last_seq/last_id for $mdtosc"
4281 run_test 53 "verify that MDS and OSTs agree on pre-creation ===="
4284 $SOCKETSERVER $DIR/socket ||
4285 error "$SOCKETSERVER $DIR/socket failed: $?"
4286 $SOCKETCLIENT $DIR/socket ||
4287 error "$SOCKETCLIENT $DIR/socket failed: $?"
4288 $MUNLINK $DIR/socket || error "$MUNLINK $DIR/socket failed: $?"
4290 run_test 54a "unix domain socket test =========================="
4296 dd if=/dev/zero of=$f bs=$(page_size) count=1
4298 run_test 54b "char device works in lustre ======================"
4301 [ -b /dev/loop/0 ] && LOOPBASE=/dev/loop/
4302 [ -b /dev/loop0 ] && LOOPBASE=/dev/loop
4303 [ -z "$LOOPBASE" ] && echo "/dev/loop/0 and /dev/loop0 gone?" && return
4305 for i in $(seq 3 7); do
4306 losetup $LOOPBASE$i > /dev/null 2>&1 && continue
4314 loopdev="$DIR/loop54c"
4317 $UMOUNT -d $DIR/$tdir || rc=$?
4318 losetup -d $loopdev || true
4319 losetup -d $LOOPDEV || true
4320 rm -rf $loopdev $DIR/$tfile $DIR/$tdir
4325 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4326 loopdev="$DIR/loop54c"
4329 [ -z "$LOOPNUM" ] && echo "couldn't find empty loop device" && return
4330 trap cleanup_54c EXIT
4331 mknod $loopdev b 7 $LOOPNUM
4332 echo "make a loop file system with $DIR/$tfile on $loopdev ($LOOPNUM)."
4333 dd if=/dev/zero of=$DIR/$tfile bs=$(get_page_size client) seek=1024 count=1 > /dev/null
4334 losetup $loopdev $DIR/$tfile ||
4335 error "can't set up $loopdev for $DIR/$tfile"
4336 mkfs.ext2 $loopdev || error "mke2fs on $loopdev"
4337 test_mkdir -p $DIR/$tdir
4338 mount -t ext2 $loopdev $DIR/$tdir ||
4339 error "error mounting $loopdev on $DIR/$tdir"
4340 dd if=/dev/zero of=$DIR/$tdir/tmp bs=$(get_page_size client) count=30 ||
4343 dd if=$DIR/$tdir/tmp of=/dev/zero bs=$(get_page_size client) count=30 ||
4347 run_test 54c "block device works in lustre ====================="
4353 [ "$string" = $(echo $string > $f | cat $f) ] || error "$f != $string"
4355 run_test 54d "fifo device works in lustre ======================"
4360 cp -aL /dev/console $f
4361 echo $string > $f || error "echo $string to $f failed"
4363 run_test 54e "console/tty device works in lustre ======================"
4365 #The test_55 used to be iopen test and it was removed by bz#24037.
4366 #run_test 55 "check iopen_connect_dentry() ======================"
4368 test_56a() { # was test_56
4371 test_mkdir -p $DIR/$tdir/dir
4373 NUMFILESx2=$(($NUMFILES * 2))
4374 for i in $(seq 1 $NUMFILES); do
4375 touch $DIR/$tdir/file$i
4376 touch $DIR/$tdir/dir/file$i
4379 # test lfs getstripe with --recursive
4380 FILENUM=$($GETSTRIPE --recursive $DIR/$tdir | grep -c obdidx)
4381 [[ $FILENUM -eq $NUMFILESx2 ]] ||
4382 error "$GETSTRIPE --recursive: found $FILENUM, not $NUMFILESx2"
4383 FILENUM=$($GETSTRIPE $DIR/$tdir | grep -c obdidx)
4384 [[ $FILENUM -eq $NUMFILES ]] ||
4385 error "$GETSTRIPE $DIR/$tdir: found $FILENUM, not $NUMFILES"
4386 echo "$GETSTRIPE --recursive passed."
4388 # test lfs getstripe with file instead of dir
4389 FILENUM=$($GETSTRIPE $DIR/$tdir/file1 | grep -c obdidx)
4390 [[ $FILENUM -eq 1 ]] ||
4391 error "$GETSTRIPE $DIR/$tdir/file1: found $FILENUM, not 1"
4392 echo "$GETSTRIPE file1 passed."
4394 #test lfs getstripe with --verbose
4395 [[ $($GETSTRIPE --verbose $DIR/$tdir |
4396 grep -c lmm_magic) -eq $NUMFILES ]] ||
4397 error "$GETSTRIPE --verbose $DIR/$tdir: want $NUMFILES"
4398 [[ $($GETSTRIPE $DIR/$tdir | grep -c lmm_magic) -eq 0 ]] ||
4399 rror "$GETSTRIPE $DIR/$tdir: showed lmm_magic"
4400 echo "$GETSTRIPE --verbose passed."
4402 #test lfs getstripe with --obd
4403 $GETSTRIPE --obd wrong_uuid $DIR/$tdir 2>&1 |
4404 grep -q "unknown obduuid" ||
4405 error "$GETSTRIPE --obd wrong_uuid should return error message"
4407 [[ $OSTCOUNT -lt 2 ]] &&
4408 skip_env "skipping other $GETSTRIPE --obd test" && return
4411 OBDUUID=$(ostuuid_from_index $OSTIDX)
4412 FILENUM=$($GETSTRIPE -ir $DIR/$tdir | grep "^$OSTIDX\$" | wc -l)
4413 FOUND=$($GETSTRIPE -r --obd $OBDUUID $DIR/$tdir | grep obdidx | wc -l)
4414 [[ $FOUND -eq $FILENUM ]] ||
4415 error "$GETSTRIPE --obd wrong: found $FOUND, expected $FILENUM"
4416 [[ $($GETSTRIPE -r -v --obd $OBDUUID $DIR/$tdir |
4417 sed '/^[ ]*'${OSTIDX}'[ ]/d' |
4418 sed -n '/^[ ]*[0-9][0-9]*[ ]/p' | wc -l) -eq 0 ]] ||
4419 error "$GETSTRIPE --obd: should not show file on other obd"
4420 echo "$GETSTRIPE --obd passed"
4422 run_test 56a "check $GETSTRIPE"
4427 local LOCAL_NUMFILES="$1"
4428 local LOCAL_NUMDIRS="$2"
4429 local MKDIR_PARAMS="$3"
4430 local DIR_STRIPE_PARAMS="$4"
4432 if [ ! -d "$TDIR" ] ; then
4433 test_mkdir -p $DIR_STRIPE_PARAMS $TDIR
4434 [ "$MKDIR_PARAMS" ] && $SETSTRIPE $MKDIR_PARAMS $TDIR
4435 for i in `seq 1 $LOCAL_NUMFILES` ; do
4438 for i in `seq 1 $LOCAL_NUMDIRS` ; do
4439 test_mkdir $DIR_STRIPE_PARAMS $TDIR/dir$i
4440 for j in `seq 1 $LOCAL_NUMFILES` ; do
4441 touch $TDIR/dir$i/file$j
4447 setup_56_special() {
4451 if [ ! -e "$TDIR/loop1b" ] ; then
4452 for i in `seq 1 $LOCAL_NUMFILES` ; do
4453 mknod $TDIR/loop${i}b b 7 $i
4454 mknod $TDIR/null${i}c c 1 3
4455 ln -s $TDIR/file1 $TDIR/link${i}l
4457 for i in `seq 1 $LOCAL_NUMDIRS` ; do
4458 mknod $TDIR/dir$i/loop${i}b b 7 $i
4459 mknod $TDIR/dir$i/null${i}c c 1 3
4460 ln -s $TDIR/dir$i/file1 $TDIR/dir$i/link${i}l
4469 setup_56 $NUMFILES $NUMDIRS
4471 EXPECTED=$(($NUMDIRS + 2))
4472 # test lfs find with -name
4473 for i in $(seq 1 $NUMFILES) ; do
4474 NUMS=$($LFIND -name "*$i" $TDIR | wc -l)
4475 [ $NUMS -eq $EXPECTED ] ||
4476 error "lfs find -name \"*$i\" $TDIR wrong: "\
4477 "found $NUMS, expected $EXPECTED"
4480 run_test 56g "check lfs find -name ============================="
4486 setup_56 $NUMFILES $NUMDIRS
4488 EXPECTED=$(((NUMDIRS + 1) * (NUMFILES - 1) + NUMFILES))
4489 # test lfs find with ! -name
4490 for i in $(seq 1 $NUMFILES) ; do
4491 NUMS=$($LFIND ! -name "*$i" $TDIR | wc -l)
4492 [ $NUMS -eq $EXPECTED ] ||
4493 error "lfs find ! -name \"*$i\" $TDIR wrong: "\
4494 "found $NUMS, expected $EXPECTED"
4497 run_test 56h "check lfs find ! -name ============================="
4501 test_mkdir -p $DIR/$tdir
4502 UUID=$(ostuuid_from_index 0 $DIR/$tdir)
4503 CMD="$LFIND -ost $UUID $DIR/$tdir"
4505 [ -z "$OUT" ] || error "\"$CMD\" returned directory '$OUT'"
4507 run_test 56i "check 'lfs find -ost UUID' skips directories ======="
4511 setup_56_special $NUMFILES $NUMDIRS
4513 EXPECTED=$((NUMDIRS + 1))
4514 CMD="$LFIND -type d $TDIR"
4515 NUMS=$($CMD | wc -l)
4516 [ $NUMS -eq $EXPECTED ] ||
4517 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4519 run_test 56j "check lfs find -type d ============================="
4523 setup_56_special $NUMFILES $NUMDIRS
4525 EXPECTED=$(((NUMDIRS + 1) * NUMFILES))
4526 CMD="$LFIND -type f $TDIR"
4527 NUMS=$($CMD | wc -l)
4528 [ $NUMS -eq $EXPECTED ] ||
4529 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4531 run_test 56k "check lfs find -type f ============================="
4535 setup_56_special $NUMFILES $NUMDIRS
4537 EXPECTED=$((NUMDIRS + NUMFILES))
4538 CMD="$LFIND -type b $TDIR"
4539 NUMS=$($CMD | wc -l)
4540 [ $NUMS -eq $EXPECTED ] ||
4541 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4543 run_test 56l "check lfs find -type b ============================="
4547 setup_56_special $NUMFILES $NUMDIRS
4549 EXPECTED=$((NUMDIRS + NUMFILES))
4550 CMD="$LFIND -type c $TDIR"
4551 NUMS=$($CMD | wc -l)
4552 [ $NUMS -eq $EXPECTED ] ||
4553 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4555 run_test 56m "check lfs find -type c ============================="
4559 setup_56_special $NUMFILES $NUMDIRS
4561 EXPECTED=$((NUMDIRS + NUMFILES))
4562 CMD="$LFIND -type l $TDIR"
4563 NUMS=$($CMD | wc -l)
4564 [ $NUMS -eq $EXPECTED ] ||
4565 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4567 run_test 56n "check lfs find -type l ============================="
4571 setup_56 $NUMFILES $NUMDIRS
4572 utime $TDIR/file1 > /dev/null || error "utime (1)"
4573 utime $TDIR/file2 > /dev/null || error "utime (2)"
4574 utime $TDIR/dir1 > /dev/null || error "utime (3)"
4575 utime $TDIR/dir2 > /dev/null || error "utime (4)"
4576 utime $TDIR/dir1/file1 > /dev/null || error "utime (5)"
4577 dd if=/dev/zero count=1 >> $TDIR/dir1/file1 && sync
4580 NUMS=`$LFIND -mtime +0 $TDIR | wc -l`
4581 [ $NUMS -eq $EXPECTED ] || \
4582 error "lfs find -mtime +0 $TDIR wrong: found $NUMS, expected $EXPECTED"
4585 CMD="$LFIND -mtime 0 $TDIR"
4586 NUMS=$($CMD | wc -l)
4587 [ $NUMS -eq $EXPECTED ] ||
4588 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4590 run_test 56o "check lfs find -mtime for old files =========================="
4593 [ $RUNAS_ID -eq $UID ] &&
4594 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
4597 setup_56 $NUMFILES $NUMDIRS
4599 chown $RUNAS_ID $TDIR/file* || error "chown $DIR/${tdir}g/file$i failed"
4601 CMD="$LFIND -uid $RUNAS_ID $TDIR"
4602 NUMS=$($CMD | wc -l)
4603 [ $NUMS -eq $EXPECTED ] || \
4604 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4606 EXPECTED=$(((NUMFILES + 1) * NUMDIRS + 1))
4607 CMD="$LFIND ! -uid $RUNAS_ID $TDIR"
4608 NUMS=$($CMD | wc -l)
4609 [ $NUMS -eq $EXPECTED ] || \
4610 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4612 run_test 56p "check lfs find -uid and ! -uid ==============================="
4615 [ $RUNAS_ID -eq $UID ] &&
4616 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
4619 setup_56 $NUMFILES $NUMDIRS
4621 chgrp $RUNAS_GID $TDIR/file* || error "chown $TDIR/file$i failed"
4624 CMD="$LFIND -gid $RUNAS_GID $TDIR"
4625 NUMS=$($CMD | wc -l)
4626 [ $NUMS -eq $EXPECTED ] ||
4627 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4629 EXPECTED=$(( ($NUMFILES+1) * $NUMDIRS + 1))
4630 CMD="$LFIND ! -gid $RUNAS_GID $TDIR"
4631 NUMS=$($CMD | wc -l)
4632 [ $NUMS -eq $EXPECTED ] ||
4633 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4635 run_test 56q "check lfs find -gid and ! -gid ==============================="
4639 setup_56 $NUMFILES $NUMDIRS
4642 CMD="$LFIND -size 0 -type f $TDIR"
4643 NUMS=$($CMD | wc -l)
4644 [ $NUMS -eq $EXPECTED ] ||
4645 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4647 CMD="$LFIND ! -size 0 -type f $TDIR"
4648 NUMS=$($CMD | wc -l)
4649 [ $NUMS -eq $EXPECTED ] ||
4650 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4651 echo "test" > $TDIR/$tfile
4652 echo "test2" > $TDIR/$tfile.2 && sync
4654 CMD="$LFIND -size 5 -type f $TDIR"
4655 NUMS=$($CMD | wc -l)
4656 [ $NUMS -eq $EXPECTED ] ||
4657 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4659 CMD="$LFIND -size +5 -type f $TDIR"
4660 NUMS=$($CMD | wc -l)
4661 [ $NUMS -eq $EXPECTED ] ||
4662 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4664 CMD="$LFIND -size +0 -type f $TDIR"
4665 NUMS=$($CMD | wc -l)
4666 [ $NUMS -eq $EXPECTED ] ||
4667 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4669 CMD="$LFIND ! -size -5 -type f $TDIR"
4670 NUMS=$($CMD | wc -l)
4671 [ $NUMS -eq $EXPECTED ] ||
4672 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4674 CMD="$LFIND -size -5 -type f $TDIR"
4675 NUMS=$($CMD | wc -l)
4676 [ $NUMS -eq $EXPECTED ] ||
4677 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4679 run_test 56r "check lfs find -size works =========================="
4681 test_56s() { # LU-611
4683 setup_56 $NUMFILES $NUMDIRS "-c $OSTCOUNT"
4685 if [[ $OSTCOUNT -gt 1 ]]; then
4686 $SETSTRIPE -c 1 $TDIR/$tfile.{0,1,2,3}
4690 ONESTRIPE=$(((NUMDIRS + 1) * NUMFILES))
4694 EXPECTED=$(((NUMDIRS + 1) * NUMFILES))
4695 CMD="$LFIND -stripe-count $OSTCOUNT -type f $TDIR"
4696 NUMS=$($CMD | wc -l)
4697 [ $NUMS -eq $EXPECTED ] || {
4699 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4702 EXPECTED=$(((NUMDIRS + 1) * NUMFILES + EXTRA))
4703 CMD="$LFIND -stripe-count +0 -type f $TDIR"
4704 NUMS=$($CMD | wc -l)
4705 [ $NUMS -eq $EXPECTED ] || {
4707 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4711 CMD="$LFIND -stripe-count 1 -type f $TDIR"
4712 NUMS=$($CMD | wc -l)
4713 [ $NUMS -eq $EXPECTED ] || {
4715 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4718 CMD="$LFIND -stripe-count -2 -type f $TDIR"
4719 NUMS=$($CMD | wc -l)
4720 [ $NUMS -eq $EXPECTED ] || {
4722 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4726 CMD="$LFIND -stripe-count $((OSTCOUNT + 1)) -type f $TDIR"
4727 NUMS=$($CMD | wc -l)
4728 [ $NUMS -eq $EXPECTED ] || {
4730 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4733 run_test 56s "check lfs find -stripe-count works"
4735 test_56t() { # LU-611
4737 setup_56 $NUMFILES $NUMDIRS "-s 512k"
4739 $SETSTRIPE -S 256k $TDIR/$tfile.{0,1,2,3}
4741 EXPECTED=$(((NUMDIRS + 1) * NUMFILES))
4742 CMD="$LFIND -stripe-size 512k -type f $TDIR"
4743 NUMS=$($CMD | wc -l)
4744 [ $NUMS -eq $EXPECTED ] ||
4745 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4747 CMD="$LFIND -stripe-size +320k -type f $TDIR"
4748 NUMS=$($CMD | wc -l)
4749 [ $NUMS -eq $EXPECTED ] ||
4750 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4752 EXPECTED=$(((NUMDIRS + 1) * NUMFILES + 4))
4753 CMD="$LFIND -stripe-size +200k -type f $TDIR"
4754 NUMS=$($CMD | wc -l)
4755 [ $NUMS -eq $EXPECTED ] ||
4756 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4758 CMD="$LFIND -stripe-size -640k -type f $TDIR"
4759 NUMS=$($CMD | wc -l)
4760 [ $NUMS -eq $EXPECTED ] ||
4761 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4764 CMD="$LFIND -stripe-size 256k -type f $TDIR"
4765 NUMS=$($CMD | wc -l)
4766 [ $NUMS -eq $EXPECTED ] ||
4767 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4769 CMD="$LFIND -stripe-size -320k -type f $TDIR"
4770 NUMS=$($CMD | wc -l)
4771 [ $NUMS -eq $EXPECTED ] ||
4772 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4775 CMD="$LFIND -stripe-size 1024k -type f $TDIR"
4776 NUMS=$($CMD | wc -l)
4777 [ $NUMS -eq $EXPECTED ] ||
4778 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4780 run_test 56t "check lfs find -stripe-size works"
4782 test_56u() { # LU-611
4784 setup_56 $NUMFILES $NUMDIRS "-i 0"
4786 if [[ $OSTCOUNT -gt 1 ]]; then
4787 $SETSTRIPE -i 1 $TDIR/$tfile.{0,1,2,3}
4793 EXPECTED=$(((NUMDIRS + 1) * NUMFILES))
4794 CMD="$LFIND -stripe-index 0 -type f $TDIR"
4795 NUMS=$($CMD | wc -l)
4796 [ $NUMS -eq $EXPECTED ] ||
4797 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4800 CMD="$LFIND -stripe-index 1 -type f $TDIR"
4801 NUMS=$($CMD | wc -l)
4802 [ $NUMS -eq $EXPECTED ] ||
4803 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4805 CMD="$LFIND ! -stripe-index 0 -type f $TDIR"
4806 NUMS=$($CMD | wc -l)
4807 [ $NUMS -eq $EXPECTED ] ||
4808 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4811 # This should produce an error and not return any files
4812 CMD="$LFIND -stripe-index $OSTCOUNT -type f $TDIR"
4813 NUMS=$($CMD 2>/dev/null | wc -l)
4814 [ $NUMS -eq $EXPECTED ] ||
4815 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4817 if [[ $OSTCOUNT -gt 1 ]]; then
4818 EXPECTED=$(((NUMDIRS + 1) * NUMFILES + ONESTRIPE))
4819 CMD="$LFIND -stripe-index 0,1 -type f $TDIR"
4820 NUMS=$($CMD | wc -l)
4821 [ $NUMS -eq $EXPECTED ] ||
4822 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4825 run_test 56u "check lfs find -stripe-index works"
4832 setup_56 $NUMFILES $NUMDIRS
4834 UUID=$(mdtuuid_from_index $MDT_IDX $TDIR)
4835 [ -z "$UUID" ] && error "mdtuuid_from_index cannot find MDT index $MDT_IDX"
4837 for file in $($LFIND -mdt $UUID $TDIR); do
4838 file_mdt_idx=$($GETSTRIPE -M $file)
4839 [ $file_mdt_idx -eq $MDT_IDX ] ||
4840 error "'lfind -mdt $UUID' != 'getstripe -M' ($file_mdt_idx)"
4843 run_test 56v "check 'lfs find -mdt match with lfs getstripe -M' ======="
4846 [[ $OSTCOUNT -lt 2 ]] && skip_env "$OSTCOUNT < 2 OSTs -- skipping" &&
4848 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4851 rm -rf $TDIR || error "remove $TDIR failed"
4852 setup_56 $NUMFILES $NUMDIRS "-c $OSTCOUNT" "-c1"
4855 stripe_size=$($GETSTRIPE -S -d $TDIR) ||
4856 error "$GETSTRIPE -S -d $TDIR failed"
4857 stripe_size=${stripe_size%% *}
4859 local file_size=$((stripe_size * OSTCOUNT))
4860 local file_num=$((NUMDIRS * NUMFILES + NUMFILES))
4861 local required_space=$((file_num * file_size))
4862 local free_space=$($LCTL get_param -n lov.$LOVNAME.kbytesavail)
4863 [[ $free_space -le $((required_space / 1024)) ]] &&
4864 skip_env "need at least $required_space bytes free space," \
4865 "have $free_space kbytes" && return
4868 local dd_count=$((file_size / dd_bs))
4870 # write data into the files
4874 for i in $(seq 1 $NUMFILES); do
4876 yes | dd bs=$dd_bs count=$dd_count of=$file >/dev/null 2>&1 ||
4877 error "write data into $file failed"
4879 for i in $(seq 1 $NUMDIRS); do
4880 for j in $(seq 1 $NUMFILES); do
4881 file=$TDIR/dir$i/file$j
4882 yes | dd bs=$dd_bs count=$dd_count of=$file \
4884 error "write data into $file failed"
4889 [[ $OSTCOUNT -gt 1 ]] && expected=$((OSTCOUNT - 1))
4892 local cmd="$LFS_MIGRATE -y -c $expected $TDIR/file1"
4894 eval $cmd || error "$cmd failed"
4896 check_stripe_count $TDIR/file1 $expected
4898 if [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.6.90) ];
4900 # lfs_migrate file onto OST 0 if it is on OST 1, or onto
4901 # OST 1 if it is on OST 0. This file is small enough to
4902 # be on only one stripe.
4903 file=$TDIR/migr_1_ost
4904 dd bs=$dd_bs count=1 if=/dev/urandom of=$file >/dev/null 2>&1 ||
4905 error "write data into $file failed"
4906 local obdidx=$($LFS getstripe -i $file)
4907 local oldmd5=$(md5sum $file)
4909 [[ $obdidx -eq 0 ]] && newobdidx=1
4910 cmd="$LFS migrate -i $newobdidx $file"
4912 eval $cmd || error "$cmd failed"
4913 local realobdix=$($LFS getstripe -i $file)
4914 local newmd5=$(md5sum $file)
4915 [[ $newobdidx -ne $realobdix ]] &&
4916 error "new OST is different (was=$obdidx, wanted=$newobdidx, got=$realobdix)"
4917 [[ "$oldmd5" != "$newmd5" ]] &&
4918 error "md5sum differ: $oldmd5, $newmd5"
4922 cmd="$LFS_MIGRATE -y -c $expected $TDIR/dir1"
4924 eval $cmd || error "$cmd failed"
4926 for j in $(seq 1 $NUMFILES); do
4927 check_stripe_count $TDIR/dir1/file$j $expected
4930 # lfs_migrate works with lfs find
4931 cmd="$LFIND -stripe_count $OSTCOUNT -type f $TDIR |
4932 $LFS_MIGRATE -y -c $expected"
4934 eval $cmd || error "$cmd failed"
4936 for i in $(seq 2 $NUMFILES); do
4937 check_stripe_count $TDIR/file$i $expected
4939 for i in $(seq 2 $NUMDIRS); do
4940 for j in $(seq 1 $NUMFILES); do
4941 check_stripe_count $TDIR/dir$i/file$j $expected
4945 run_test 56w "check lfs_migrate -c stripe_count works"
4948 check_swap_layouts_support && return 0
4949 [[ $OSTCOUNT -lt 2 ]] &&
4950 skip_env "need 2 OST, skipping test" && return
4952 local dir0=$DIR/$tdir/$testnum
4953 test_mkdir -p $dir0 || error "creating dir $dir0"
4955 local ref1=/etc/passwd
4956 local file1=$dir0/file1
4958 $SETSTRIPE -c 2 $file1
4960 $LFS migrate -c 1 $file1 || error "migrate failed rc = $?"
4961 stripe=$($GETSTRIPE -c $file1)
4962 [[ $stripe == 1 ]] || error "stripe of $file1 is $stripe != 1"
4963 cmp $file1 $ref1 || error "content mismatch $file1 differs from $ref1"
4968 run_test 56x "lfs migration support"
4971 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.53) ] &&
4972 skip "No HSM $(lustre_build_version $SINGLEMDS) MDS < 2.4.53" &&
4976 local dir0=$DIR/$tdir/$testnum
4977 test_mkdir -p $dir0 || error "creating dir $dir0"
4978 local f1=$dir0/file1
4979 local f2=$dir0/file2
4981 touch $f1 || error "creating std file $f1"
4982 $MULTIOP $f2 H2c || error "creating released file $f2"
4984 # a directory can be raid0, so ask only for files
4985 res=$($LFIND $dir0 -L raid0 -type f | wc -l)
4986 [[ $res == 2 ]] || error "search raid0: found $res files != 2"
4988 res=$($LFIND $dir0 \! -L raid0 -type f | wc -l)
4989 [[ $res == 0 ]] || error "search !raid0: found $res files != 0"
4991 # only files can be released, so no need to force file search
4992 res=$($LFIND $dir0 -L released)
4993 [[ $res == $f2 ]] || error "search released: found $res != $f2"
4995 res=$($LFIND $dir0 \! -L released)
4996 [[ $res == $f1 ]] || error "search !released: found $res != $f1"
4999 run_test 56y "lfs find -L raid0|released"
5001 test_56z() { # LU-4824
5002 # This checks to make sure 'lfs find' continues after errors
5003 # There are two classes of errors that should be caught:
5004 # - If multiple paths are provided, all should be searched even if one
5006 # - If errors are encountered during the search, it should not terminate
5009 test_mkdir $DIR/$tdir
5010 for i in d{0..9}; do
5011 test_mkdir $DIR/$tdir/$i
5013 touch $DIR/$tdir/d{0..9}/$tfile
5014 $LFS find $DIR/non_existent_dir $DIR/$tdir &&
5015 error "$LFS find did not return an error"
5016 # Make a directory unsearchable. This should NOT be the last entry in
5017 # directory order. Arbitrarily pick the 6th entry
5018 chmod 700 $($LFS find $DIR/$tdir -type d | sed '6!d')
5019 local count=$($RUNAS $LFS find $DIR/non_existent $DIR/$tdir | wc -l)
5020 # The user should be able to see 10 directories and 9 files
5021 [ $count == 19 ] || error "$LFS find did not continue after error"
5023 run_test 56z "lfs find should continue after an error"
5025 test_56aa() { # LU-5937
5026 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
5029 $LFS setdirstripe -c$MDSCOUNT $DIR/$tdir/striped_dir
5031 createmany -o $DIR/$tdir/striped_dir/${tfile}- 1024
5032 local dirs=$(lfs find --size +8k $DIR/$tdir/)
5034 [ -n "$dirs" ] || error "lfs find --size wrong under striped dir"
5036 run_test 56aa "lfs find --size under striped dir"
5039 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5040 # note test will not do anything if MDS is not local
5041 if [ "$(facet_fstype $SINGLEMDS)" != ldiskfs ]; then
5042 skip "Only applicable to ldiskfs-based MDTs"
5046 remote_mds_nodsh && skip "remote MDS with nodsh" && return
5047 local MNTDEV="osd*.*MDT*.mntdev"
5048 DEV=$(do_facet $SINGLEMDS lctl get_param -n $MNTDEV)
5049 [ -z "$DEV" ] && error "can't access $MNTDEV"
5050 for DEV in $(do_facet $SINGLEMDS lctl get_param -n $MNTDEV); do
5051 do_facet $SINGLEMDS $DUMPE2FS -h $DEV > $TMP/t57a.dump ||
5052 error "can't access $DEV"
5053 DEVISIZE=$(awk '/Inode size:/ { print $3 }' $TMP/t57a.dump)
5054 [[ $DEVISIZE -gt 128 ]] || error "inode size $DEVISIZE"
5058 run_test 57a "verify MDS filesystem created with large inodes =="
5061 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5062 if [ "$(facet_fstype $SINGLEMDS)" != ldiskfs ]; then
5063 skip "Only applicable to ldiskfs-based MDTs"
5067 remote_mds_nodsh && skip "remote MDS with nodsh" && return
5068 local dir=$DIR/$tdir
5072 local FILEN=$dir/f$FILECOUNT
5074 rm -rf $dir || error "removing $dir"
5075 test_mkdir -p -c1 $dir || error "creating $dir"
5076 local mdtidx=$($LFS getstripe -M $dir)
5077 local mdtname=MDT$(printf %04x $mdtidx)
5078 local facet=mds$((mdtidx + 1))
5080 echo "mcreating $FILECOUNT files"
5081 createmany -m $dir/f 1 $FILECOUNT || \
5082 error "creating files in $dir"
5084 # verify that files do not have EAs yet
5085 $GETSTRIPE $FILE1 2>&1 | grep -q "no stripe" || error "$FILE1 has an EA"
5086 $GETSTRIPE $FILEN 2>&1 | grep -q "no stripe" || error "$FILEN has an EA"
5090 df $dir #make sure we get new statfs data
5091 local MDSFREE=$(do_facet $facet \
5092 lctl get_param -n osd*.*$mdtname.kbytesfree)
5093 local MDCFREE=$(lctl get_param -n mdc.*$mdtname-mdc-*.kbytesfree)
5094 echo "opening files to create objects/EAs"
5096 for FILE in `seq -f $dir/f%g 1 $FILECOUNT`; do
5097 $OPENFILE -f O_RDWR $FILE > /dev/null 2>&1 || error "opening $FILE"
5100 # verify that files have EAs now
5101 $GETSTRIPE $FILE1 | grep -q "obdidx" || error "$FILE1 missing EA"
5102 $GETSTRIPE $FILEN | grep -q "obdidx" || error "$FILEN missing EA"
5104 sleep 1 #make sure we get new statfs data
5106 local MDSFREE2=$(do_facet $facet \
5107 lctl get_param -n osd*.*$mdtname.kbytesfree)
5108 local MDCFREE2=$(lctl get_param -n mdc.*$mdtname-mdc-*.kbytesfree)
5109 if [[ $MDCFREE2 -lt $((MDCFREE - 16)) ]]; then
5110 if [ "$MDSFREE" != "$MDSFREE2" ]; then
5111 error "MDC before $MDCFREE != after $MDCFREE2"
5113 echo "MDC before $MDCFREE != after $MDCFREE2"
5114 echo "unable to confirm if MDS has large inodes"
5119 run_test 57b "default LOV EAs are stored inside large inodes ==="
5122 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5123 [ -z "$(which wiretest 2>/dev/null)" ] &&
5124 skip_env "could not find wiretest" && return
5127 run_test 58 "verify cross-platform wire constants =============="
5130 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5131 echo "touch 130 files"
5132 createmany -o $DIR/f59- 130
5134 unlinkmany $DIR/f59- 130
5136 # wait for commitment of removal
5137 wait_delete_completed
5139 run_test 59 "verify cancellation of llog records async ========="
5141 TEST60_HEAD="test_60 run $RANDOM"
5143 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5144 remote_mgs_nodsh && skip "remote MGS with nodsh" && return
5145 do_facet mgs "! which run-llog.sh &> /dev/null" &&
5146 do_facet mgs "! ls run-llog.sh &> /dev/null" &&
5147 skip_env "missing subtest run-llog.sh" && return
5149 log "$TEST60_HEAD - from kernel mode"
5150 do_facet mgs "$LCTL set_param debug=warning; $LCTL dk > /dev/null"
5151 do_facet mgs sh run-llog.sh
5152 do_facet mgs $LCTL dk > $TMP/$tfile
5154 # LU-6388: test llog_reader
5155 local llog_reader=$(do_facet mgs "which llog_reader 2> /dev/null")
5156 llog_reader=${llog_reader:-$LUSTRE/utils/llog_reader}
5157 [ -z $(do_facet mgs ls -d $llog_reader 2> /dev/null) ] &&
5158 skip_env "missing llog_reader" && return
5159 local fstype=$(facet_fstype mgs)
5160 [ $fstype != ldiskfs -a $fstype != zfs ] &&
5161 skip_env "Only for ldiskfs or zfs type mgs" && return
5163 local mntpt=$(facet_mntpt mgs)
5164 local mgsdev=$(mgsdevname 1)
5176 #get fid and record list
5177 fid_list=($(awk '/9_sub.*record/ { print $NF }' /$TMP/$tfile |
5179 rec_list=($(awk '/9_sub.*record/ { print $((NF-3)) }' /$TMP/$tfile |
5181 #remount mgs as ldiskfs or zfs type
5182 stop mgs || error "stop mgs failed"
5183 mount_fstype mgs || error "remount mgs failed"
5184 for ((i = 0; i < ${#fid_list[@]}; i++)); do
5187 seq=$(echo $fid | awk -F ':' '{ print $1 }' | sed -e "s/^0x//g")
5188 oid=$(echo $fid | awk -F ':' '{ print $2 }' | sed -e "s/^0x//g")
5193 obj_file=$mntpt/O/$seq/d$((oid%32))/$oid ;;
5195 obj_file=$mntpt/oi.$(($((16#$seq))&127))/$fid ;;
5197 echo "obj_file is $obj_file"
5198 do_facet mgs $llog_reader $obj_file
5200 rec_type=$(do_facet mgs $llog_reader $obj_file | grep "type=" |
5201 awk '{ print $3 }' | sed -e "s/^type=//g")
5202 if [ $rec_type != $rec ]; then
5203 echo "FAILED test_60a wrong record type $rec_type," \
5209 #check obj path if record type is LLOG_LOGID_MAGIC
5210 if [ "$rec" == "1064553b" ]; then
5211 path=$(do_facet mgs $llog_reader $obj_file |
5212 grep "path=" | awk '{ print $NF }' |
5213 sed -e "s/^path=//g")
5214 if [ $obj_file != $mntpt/$path ]; then
5215 echo "FAILED test_60a wrong obj path" \
5216 "$montpt/$path, should be $obj_file"
5223 #restart mgs before "error", otherwise it will block the next test
5224 stop mgs || error "stop mgs failed"
5225 start mgs $(mgsdevname) $MGS_MOUNT_OPTS || error "start mgs failed"
5226 $pass || error "test failed, see FAILED test_60a messages for specifics"
5228 run_test 60a "llog_test run from kernel module and test llog_reader =========="
5230 test_60b() { # bug 6411
5231 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5233 LLOG_COUNT=`dmesg | awk "/$TEST60_HEAD/{marker = 1; from_marker = 0;}
5245 [[ $LLOG_COUNT -gt 50 ]] &&
5246 error "CDEBUG_LIMIT not limiting messages ($LLOG_COUNT)" || true
5248 run_test 60b "limit repeated messages from CERROR/CWARN ========"
5251 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5252 echo "create 5000 files"
5253 createmany -o $DIR/f60c- 5000
5254 #define OBD_FAIL_MDS_LLOG_CREATE_FAILED 0x137
5255 lctl set_param fail_loc=0x80000137
5256 unlinkmany $DIR/f60c- 5000
5257 lctl set_param fail_loc=0
5259 run_test 60c "unlink file when mds full"
5262 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5263 SAVEPRINTK=$(lctl get_param -n printk)
5265 # verify "lctl mark" is even working"
5266 MESSAGE="test message ID $RANDOM $$"
5267 $LCTL mark "$MESSAGE" || error "$LCTL mark failed"
5268 dmesg | grep -q "$MESSAGE" || error "didn't find debug marker in log"
5270 lctl set_param printk=0 || error "set lnet.printk failed"
5271 lctl get_param -n printk | grep emerg || error "lnet.printk dropped emerg"
5272 MESSAGE="new test message ID $RANDOM $$"
5273 # Assume here that libcfs_debug_mark_buffer() uses D_WARNING
5274 $LCTL mark "$MESSAGE" || error "$LCTL mark failed"
5275 dmesg | grep -q "$MESSAGE" && error "D_WARNING wasn't masked" || true
5277 lctl set_param -n printk="$SAVEPRINTK"
5279 run_test 60d "test printk console message masking"
5282 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5284 dd if=/dev/zero of=$f bs=$(page_size) count=1 || error "dd $f failed"
5285 cancel_lru_locks osc
5286 $MULTIOP $f OSMWUc || error "$MULTIOP $f failed"
5289 run_test 61 "mmap() writes don't make sync hang ================"
5291 # bug 2330 - insufficient obd_match error checking causes LBUG
5293 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5296 cancel_lru_locks osc
5297 lctl set_param fail_loc=0x405
5298 cat $f && error "cat succeeded, expect -EIO"
5299 lctl set_param fail_loc=0
5301 # This test is now irrelevant (as of bug 10718 inclusion), we no longer
5302 # match every page all of the time.
5303 #run_test 62 "verify obd_match failure doesn't LBUG (should -EIO)"
5305 # bug 2319 - oig_wait() interrupted causes crash because of invalid waitq.
5306 # Though this test is irrelevant anymore, it helped to reveal some
5307 # other grant bugs (LU-4482), let's keep it.
5308 test_63a() { # was test_63
5309 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5310 MAX_DIRTY_MB=`lctl get_param -n osc.*.max_dirty_mb | head -n 1`
5311 for i in `seq 10` ; do
5312 dd if=/dev/zero of=$DIR/f63 bs=8k &
5318 rm -f $DIR/f63 || true
5320 run_test 63a "Verify oig_wait interruption does not crash ======="
5322 # bug 2248 - async write errors didn't return to application on sync
5323 # bug 3677 - async write errors left page locked
5325 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5327 lctl set_param debug=-1
5329 # ensure we have a grant to do async writes
5330 dd if=/dev/zero of=$DIR/$tfile bs=4k count=1
5333 sync # sync lest earlier test intercept the fail_loc
5335 #define OBD_FAIL_OSC_BRW_PREP_REQ 0x406
5336 lctl set_param fail_loc=0x80000406
5337 $MULTIOP $DIR/$tfile Owy && \
5338 error "sync didn't return ENOMEM"
5339 sync; sleep 2; sync # do a real sync this time to flush page
5340 lctl get_param -n llite.*.dump_page_cache | grep locked && \
5341 error "locked page left in cache after async error" || true
5344 run_test 63b "async write errors should be returned to fsync ==="
5347 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5349 lctl get_param -n osc.*[oO][sS][cC][_-]*.cur* | grep "[0-9]"
5351 run_test 64a "verify filter grant calculations (in kernel) ====="
5354 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5355 sh oos.sh $MOUNT || error "oos.sh failed: $?"
5357 run_test 64b "check out-of-space detection on client ==========="
5360 $LCTL set_param osc.*OST0000-osc-[^mM]*.cur_grant_bytes=0
5362 run_test 64c "verify grant shrink ========================------"
5364 # bug 1414 - set/get directories' stripe info
5366 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5367 test_mkdir -p $DIR/$tdir
5369 $LVERIFY $DIR/$tdir $DIR/$tdir/f1 || error "lverify failed"
5371 run_test 65a "directory with no stripe info ===================="
5374 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5375 test_mkdir -p $DIR/$tdir
5376 $SETSTRIPE -S $((STRIPESIZE * 2)) -i 0 -c 1 $DIR/$tdir ||
5379 $LVERIFY $DIR/$tdir $DIR/$tdir/f2 || error "lverify failed"
5381 run_test 65b "directory setstripe -S $((STRIPESIZE * 2)) -i 0 -c 1"
5384 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5385 if [[ $OSTCOUNT -gt 1 ]]; then
5386 test_mkdir -p $DIR/$tdir
5387 $SETSTRIPE -S $(($STRIPESIZE * 4)) -i 1 \
5388 -c $(($OSTCOUNT - 1)) $DIR/$tdir || error "setstripe"
5390 $LVERIFY $DIR/$tdir $DIR/$tdir/f3 || error "lverify failed"
5393 run_test 65c "directory setstripe -S $((STRIPESIZE*4)) -i 1 -c $((OSTCOUNT-1))"
5396 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5397 test_mkdir -p $DIR/$tdir
5398 if [[ $STRIPECOUNT -le 0 ]]; then
5400 elif [[ $STRIPECOUNT -gt 2000 ]]; then
5401 #LOV_MAX_STRIPE_COUNT is 2000
5402 [[ $OSTCOUNT -gt 2000 ]] && sc=2000 || sc=$(($OSTCOUNT - 1))
5404 sc=$(($STRIPECOUNT - 1))
5406 $SETSTRIPE -S $STRIPESIZE -c $sc $DIR/$tdir || error "setstripe"
5407 touch $DIR/$tdir/f4 $DIR/$tdir/f5
5408 $LVERIFY $DIR/$tdir $DIR/$tdir/f4 $DIR/$tdir/f5 ||
5409 error "lverify failed"
5411 run_test 65d "directory setstripe -S $STRIPESIZE -c stripe_count"
5414 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5415 test_mkdir -p $DIR/$tdir
5417 $SETSTRIPE $DIR/$tdir || error "setstripe"
5418 $GETSTRIPE -v $DIR/$tdir | grep "Default" ||
5419 error "no stripe info failed"
5421 $LVERIFY $DIR/$tdir $DIR/$tdir/f6 || error "lverify failed"
5423 run_test 65e "directory setstripe defaults ======================="
5426 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5427 test_mkdir -p $DIR/${tdir}f
5428 $RUNAS $SETSTRIPE $DIR/${tdir}f && error "setstripe succeeded" || true
5430 run_test 65f "dir setstripe permission (should return error) ==="
5433 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5434 test_mkdir -p $DIR/$tdir
5435 $SETSTRIPE -S $((STRIPESIZE * 2)) -i 0 -c 1 $DIR/$tdir ||
5437 $SETSTRIPE -d $DIR/$tdir || error "setstripe"
5438 $GETSTRIPE -v $DIR/$tdir | grep "Default" ||
5439 error "delete default stripe failed"
5441 run_test 65g "directory setstripe -d ==========================="
5444 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5445 test_mkdir -p $DIR/$tdir
5446 $SETSTRIPE -S $((STRIPESIZE * 2)) -i 0 -c 1 $DIR/$tdir ||
5448 test_mkdir -p $DIR/$tdir/dd1
5449 [ $($GETSTRIPE -c $DIR/$tdir) == $($GETSTRIPE -c $DIR/$tdir/dd1) ] ||
5450 error "stripe info inherit failed"
5452 run_test 65h "directory stripe info inherit ===================="
5454 test_65i() { # bug6367
5455 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5456 $SETSTRIPE -S 65536 -c -1 $MOUNT
5458 run_test 65i "set non-default striping on root directory (bug 6367)="
5460 test_65ia() { # bug12836
5461 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5462 $GETSTRIPE $MOUNT || error "getstripe $MOUNT failed"
5464 run_test 65ia "getstripe on -1 default directory striping"
5466 test_65ib() { # bug12836
5467 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5468 $GETSTRIPE -v $MOUNT || error "getstripe -v $MOUNT failed"
5470 run_test 65ib "getstripe -v on -1 default directory striping"
5472 test_65ic() { # bug12836
5473 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5474 $LFS find -mtime -1 $MOUNT > /dev/null || error "find $MOUNT failed"
5476 run_test 65ic "new find on -1 default directory striping"
5478 test_65j() { # bug6367
5479 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5481 # if we aren't already remounting for each test, do so for this test
5482 if [ "$CLEANUP" = ":" -a "$I_MOUNTED" = "yes" ]; then
5483 cleanup || error "failed to unmount"
5486 $SETSTRIPE -d $MOUNT || error "setstripe failed"
5488 run_test 65j "set default striping on root directory (bug 6367)="
5490 test_65k() { # bug11679
5491 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5492 [[ $OSTCOUNT -lt 2 ]] && skip_env "too few OSTs" && return
5493 remote_mds_nodsh && skip "remote MDS with nodsh" && return
5495 echo "Check OST status: "
5496 local MDS_OSCS=`do_facet $SINGLEMDS lctl dl |
5497 awk '/[oO][sS][cC].*md[ts]/ { print $4 }'`
5499 for OSC in $MDS_OSCS; do
5500 echo $OSC "is activate"
5501 do_facet $SINGLEMDS lctl --device %$OSC activate
5505 for INACTIVE_OSC in $MDS_OSCS; do
5506 echo "Deactivate: " $INACTIVE_OSC
5507 do_facet $SINGLEMDS lctl --device %$INACTIVE_OSC deactivate
5508 for STRIPE_OSC in $MDS_OSCS; do
5509 OST=`osc_to_ost $STRIPE_OSC`
5510 IDX=`do_facet $SINGLEMDS lctl get_param -n lov.*md*.target_obd |
5511 awk -F: /$OST/'{ print $1 }' | head -n 1`
5513 [ -f $DIR/$tdir/$IDX ] && continue
5514 echo "$SETSTRIPE -i $IDX -c 1 $DIR/$tdir/$IDX"
5515 $SETSTRIPE -i $IDX -c 1 $DIR/$tdir/$IDX
5517 [ $RC -ne 0 ] && error "setstripe should have succeeded"
5520 echo $INACTIVE_OSC "is Activate."
5521 do_facet $SINGLEMDS lctl --device %$INACTIVE_OSC activate
5524 run_test 65k "validate manual striping works properly with deactivated OSCs"
5526 test_65l() { # bug 12836
5527 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5528 test_mkdir -p $DIR/$tdir/test_dir
5529 $SETSTRIPE -c -1 $DIR/$tdir/test_dir
5530 $LFS find -mtime -1 $DIR/$tdir >/dev/null
5532 run_test 65l "lfs find on -1 stripe dir ========================"
5534 # bug 2543 - update blocks count on client
5536 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5538 dd if=/dev/zero of=$DIR/f66 bs=1k count=$COUNT
5539 sync; sync_all_data; sync; sync_all_data
5540 cancel_lru_locks osc
5541 BLOCKS=`ls -s $DIR/f66 | awk '{ print $1 }'`
5542 [ $BLOCKS -ge $COUNT ] || error "$DIR/f66 blocks $BLOCKS < $COUNT"
5544 run_test 66 "update inode blocks count on client ==============="
5549 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5551 if [ ! -z "$LLOOP" ]; then
5552 if swapon -s | grep -q $LLOOP; then
5553 swapoff $LLOOP || error "swapoff failed"
5556 $LCTL blockdev_detach $LLOOP || error "detach failed"
5560 if [ ! -z "$LLITELOOPLOAD" ]; then
5568 awk '($1 == "'$1':") { print $2 }' /proc/meminfo
5572 swapon -s | awk '($1 == "'$1'") { print $4 }'
5575 # test case for lloop driver, basic function
5577 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5578 [ "$UID" != 0 ] && skip_env "must run as root" && return
5579 llite_lloop_enabled || \
5580 { skip_env "llite_lloop module disabled" && return; }
5582 trap cleanup_68 EXIT
5584 if ! module_loaded llite_lloop; then
5585 if load_module llite/llite_lloop; then
5588 skip_env "can't find module llite_lloop"
5593 LLOOP=$TMP/lloop.`date +%s`.`date +%N`
5594 dd if=/dev/zero of=$DIR/f68a bs=4k count=1024
5595 $LCTL blockdev_attach $DIR/f68a $LLOOP || error "attach failed"
5597 directio rdwr $LLOOP 0 1024 4096 || error "direct write failed"
5598 directio rdwr $LLOOP 0 1025 4096 && error "direct write should fail"
5602 run_test 68a "lloop driver - basic test ========================"
5604 # excercise swapping to lustre by adding a high priority swapfile entry
5605 # and then consuming memory until it is used.
5606 test_68b() { # was test_68
5607 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5608 [ "$UID" != 0 ] && skip_env "must run as root" && return
5609 lctl get_param -n devices | grep -q obdfilter && \
5610 skip "local OST" && return
5612 grep -q llite_lloop /proc/modules
5613 [ $? -ne 0 ] && skip "can't find module llite_lloop" && return
5615 [ -z "`$LCTL list_nids | grep -v tcp`" ] && \
5616 skip "can't reliably test swap with TCP" && return
5618 MEMTOTAL=`meminfo MemTotal`
5619 NR_BLOCKS=$((MEMTOTAL>>8))
5620 [[ $NR_BLOCKS -le 2048 ]] && NR_BLOCKS=2048
5622 LLOOP=$TMP/lloop.`date +%s`.`date +%N`
5623 dd if=/dev/zero of=$DIR/f68b bs=64k seek=$NR_BLOCKS count=1
5626 $LCTL blockdev_attach $DIR/f68b $LLOOP || error "attach failed"
5628 trap cleanup_68 EXIT
5630 swapon -p 32767 $LLOOP || error "swapon $LLOOP failed"
5632 echo "before: `swapon -s | grep $LLOOP`"
5633 $MEMHOG $MEMTOTAL || error "error allocating $MEMTOTAL kB"
5634 echo "after: `swapon -s | grep $LLOOP`"
5635 SWAPUSED=`swap_used $LLOOP`
5639 [ $SWAPUSED -eq 0 ] && echo "no swap used???" || true
5641 run_test 68b "support swapping to Lustre ========================"
5643 # bug5265, obdfilter oa2dentry return -ENOENT
5644 # #define OBD_FAIL_OST_ENOENT 0x217
5646 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5647 remote_ost_nodsh && skip "remote OST with nodsh" && return
5650 $SETSTRIPE -c 1 -i 0 $f
5652 $DIRECTIO write ${f}.2 0 1 || error "directio write error"
5654 do_facet ost1 lctl set_param fail_loc=0x217
5655 $TRUNCATE $f 1 # vmtruncate() will ignore truncate() error.
5656 $DIRECTIO write $f 0 2 && error "write succeeded, expect -ENOENT"
5658 do_facet ost1 lctl set_param fail_loc=0
5659 $DIRECTIO write $f 0 2 || error "write error"
5661 cancel_lru_locks osc
5662 $DIRECTIO read $f 0 1 || error "read error"
5664 do_facet ost1 lctl set_param fail_loc=0x217
5665 $DIRECTIO read $f 1 1 && error "read succeeded, expect -ENOENT"
5667 do_facet ost1 lctl set_param fail_loc=0
5670 run_test 69 "verify oa2dentry return -ENOENT doesn't LBUG ======"
5673 test_mkdir -p $DIR/$tdir
5674 $LFS setdirstripe -D -c$MDSCOUNT $DIR/$tdir
5675 sh rundbench -C -D $DIR/$tdir 2 || error "dbench failed!"
5677 run_test 71 "Running dbench on lustre (don't segment fault) ===="
5679 test_72a() { # bug 5695 - Test that on 2.6 remove_suid works properly
5680 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5681 [ "$RUNAS_ID" = "$UID" ] &&
5682 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
5684 # Check that testing environment is properly set up. Skip if not
5685 FAIL_ON_ERROR=false check_runas_id_ret $RUNAS_ID $RUNAS_GID $RUNAS || {
5686 skip_env "User $RUNAS_ID does not exist - skipping"
5690 chmod 777 $DIR/$tfile
5691 chmod ug+s $DIR/$tfile
5692 $RUNAS dd if=/dev/zero of=$DIR/$tfile bs=512 count=1 ||
5693 error "$RUNAS dd $DIR/$tfile failed"
5694 # See if we are still setuid/sgid
5695 test -u $DIR/$tfile -o -g $DIR/$tfile &&
5696 error "S/gid is not dropped on write"
5697 # Now test that MDS is updated too
5698 cancel_lru_locks mdc
5699 test -u $DIR/$tfile -o -g $DIR/$tfile &&
5700 error "S/gid is not dropped on MDS"
5703 run_test 72a "Test that remove suid works properly (bug5695) ===="
5705 test_72b() { # bug 24226 -- keep mode setting when size is not changing
5708 [ "$RUNAS_ID" = "$UID" ] && \
5709 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
5710 [ "$RUNAS_ID" -eq 0 ] && \
5711 skip_env "RUNAS_ID = 0 -- skipping" && return
5713 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5714 # Check that testing environment is properly set up. Skip if not
5715 FAIL_ON_ERROR=false check_runas_id_ret $RUNAS_ID $RUNAS_ID $RUNAS || {
5716 skip_env "User $RUNAS_ID does not exist - skipping"
5719 touch $DIR/${tfile}-f{g,u}
5720 test_mkdir $DIR/${tfile}-dg
5721 test_mkdir $DIR/${tfile}-du
5722 chmod 770 $DIR/${tfile}-{f,d}{g,u}
5723 chmod g+s $DIR/${tfile}-{f,d}g
5724 chmod u+s $DIR/${tfile}-{f,d}u
5725 for perm in 777 2777 4777; do
5726 $RUNAS chmod $perm $DIR/${tfile}-fg && error "S/gid file allowed improper chmod to $perm"
5727 $RUNAS chmod $perm $DIR/${tfile}-fu && error "S/uid file allowed improper chmod to $perm"
5728 $RUNAS chmod $perm $DIR/${tfile}-dg && error "S/gid dir allowed improper chmod to $perm"
5729 $RUNAS chmod $perm $DIR/${tfile}-du && error "S/uid dir allowed improper chmod to $perm"
5733 run_test 72b "Test that we keep mode setting if without file data changed (bug 24226)"
5735 # bug 3462 - multiple simultaneous MDC requests
5737 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5738 test_mkdir $DIR/d73-1
5739 test_mkdir $DIR/d73-2
5740 multiop_bg_pause $DIR/d73-1/f73-1 O_c || return 1
5743 lctl set_param fail_loc=0x80000129
5744 $MULTIOP $DIR/d73-1/f73-2 Oc &
5746 lctl set_param fail_loc=0
5748 $MULTIOP $DIR/d73-2/f73-3 Oc &
5752 wait $pid1 || return 1
5756 $CHECKSTAT -t file $DIR/d73-1/f73-1 || return 4
5757 $CHECKSTAT -t file $DIR/d73-1/f73-2 || return 5
5758 $CHECKSTAT -t file $DIR/d73-2/f73-3 || return 6
5762 run_test 73 "multiple MDC requests (should not deadlock)"
5764 test_74a() { # bug 6149, 6184
5765 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5766 #define OBD_FAIL_LDLM_ENQUEUE_OLD_EXPORT 0x30e
5768 # very important to OR with OBD_FAIL_ONCE (0x80000000) -- otherwise it
5769 # will spin in a tight reconnection loop
5771 $LCTL set_param fail_loc=0x8000030e
5772 # get any lock that won't be difficult - lookup works.
5774 $LCTL set_param fail_loc=0
5778 run_test 74a "ldlm_enqueue freed-export error path, ls (shouldn't LBUG)"
5780 test_74b() { # bug 13310
5781 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5782 #define OBD_FAIL_LDLM_ENQUEUE_OLD_EXPORT 0x30e
5784 # very important to OR with OBD_FAIL_ONCE (0x80000000) -- otherwise it
5785 # will spin in a tight reconnection loop
5786 $LCTL set_param fail_loc=0x8000030e
5787 # get a "difficult" lock
5789 $LCTL set_param fail_loc=0
5793 run_test 74b "ldlm_enqueue freed-export error path, touch (shouldn't LBUG)"
5796 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5797 #define OBD_FAIL_LDLM_NEW_LOCK
5798 $LCTL set_param fail_loc=0x319
5799 touch $DIR/$tfile && error "touch successful"
5800 $LCTL set_param fail_loc=0
5803 run_test 74c "ldlm_lock_create error path, (shouldn't LBUG)"
5806 awk '/lustre_inode_cache/ {print $2; exit}' /proc/slabinfo
5809 get_inode_slab_tunables() {
5810 awk '/lustre_inode_cache/ {print $9," ",$10," ",$11; exit}' /proc/slabinfo
5813 set_inode_slab_tunables() {
5814 echo "lustre_inode_cache $1" > /proc/slabinfo
5817 test_76() { # Now for bug 20433, added originally in bug 1443
5818 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5819 local SLAB_SETTINGS=`get_inode_slab_tunables`
5820 local CPUS=`getconf _NPROCESSORS_ONLN`
5821 # we cannot set limit below 1 which means 1 inode in each
5822 # per-cpu cache is still allowed
5823 set_inode_slab_tunables "1 1 0"
5824 cancel_lru_locks osc
5825 BEFORE_INODES=$(num_inodes)
5826 echo "before inodes: $BEFORE_INODES"
5828 [ "$SLOW" = "no" ] && COUNT=100
5829 for i in $(seq $COUNT); do
5833 cancel_lru_locks osc
5834 AFTER_INODES=$(num_inodes)
5835 echo "after inodes: $AFTER_INODES"
5837 while [[ $((AFTER_INODES-1*CPUS)) -gt $BEFORE_INODES ]]; do
5839 AFTER_INODES=$(num_inodes)
5841 echo "wait $wait seconds inodes: $AFTER_INODES"
5842 if [ $wait -gt 30 ]; then
5843 error "inode slab grew from $BEFORE_INODES to $AFTER_INODES"
5846 set_inode_slab_tunables "$SLAB_SETTINGS"
5848 run_test 76 "confirm clients recycle inodes properly ===="
5854 # Note: in sptlrpc modes which enable its own bulk checksum, the
5855 # original crc32_le bulk checksum will be automatically disabled,
5856 # and the OBD_FAIL_OSC_CHECKSUM_SEND/OBD_FAIL_OSC_CHECKSUM_RECEIVE
5857 # will be checked by sptlrpc code against sptlrpc bulk checksum.
5858 # In this case set_checksums() will not be no-op, because sptlrpc
5859 # bulk checksum will be enabled all through the test.
5861 [ "$ORIG_CSUM" ] || ORIG_CSUM=`lctl get_param -n osc.*.checksums | head -n1`
5862 lctl set_param -n osc.*.checksums $1
5866 export ORIG_CSUM_TYPE="`lctl get_param -n osc.*osc-[^mM]*.checksum_type |
5867 sed 's/.*\[\(.*\)\].*/\1/g' | head -n1`"
5868 CKSUM_TYPES=${CKSUM_TYPES:-"crc32 adler"}
5869 [ "$ORIG_CSUM_TYPE" = "crc32c" ] && CKSUM_TYPES="$CKSUM_TYPES crc32c"
5872 lctl set_param -n osc.*osc-[^mM]*.checksum_type $1
5873 log "set checksum type to $1"
5876 F77_TMP=$TMP/f77-temp
5879 dd if=/dev/urandom of=$F77_TMP bs=1M count=$F77SZ || \
5880 error "error writing to $F77_TMP"
5883 test_77a() { # bug 10889
5884 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5885 $GSS && skip "could not run with gss" && return
5886 [ ! -f $F77_TMP ] && setup_f77
5888 dd if=$F77_TMP of=$DIR/$tfile bs=1M count=$F77SZ || error "dd error"
5892 run_test 77a "normal checksum read/write operation"
5894 test_77b() { # bug 10889
5895 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5896 $GSS && skip "could not run with gss" && return
5897 [ ! -f $F77_TMP ] && setup_f77
5898 #define OBD_FAIL_OSC_CHECKSUM_SEND 0x409
5899 $LCTL set_param fail_loc=0x80000409
5902 dd if=$F77_TMP of=$DIR/$tfile bs=1M count=$F77SZ conv=sync ||
5903 error "dd error: $?"
5904 $LCTL set_param fail_loc=0
5906 for algo in $CKSUM_TYPES; do
5907 cancel_lru_locks osc
5908 set_checksum_type $algo
5909 #define OBD_FAIL_OSC_CHECKSUM_RECEIVE 0x408
5910 $LCTL set_param fail_loc=0x80000408
5911 cmp $F77_TMP $DIR/$tfile || error "file compare failed"
5912 $LCTL set_param fail_loc=0
5915 set_checksum_type $ORIG_CSUM_TYPE
5918 run_test 77b "checksum error on client write, read"
5920 test_77d() { # bug 10889
5921 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5922 $GSS && skip "could not run with gss" && return
5923 #define OBD_FAIL_OSC_CHECKSUM_SEND 0x409
5924 $LCTL set_param fail_loc=0x80000409
5926 $DIRECTIO write $DIR/$tfile 0 $F77SZ $((1024 * 1024)) ||
5927 error "direct write: rc=$?"
5928 $LCTL set_param fail_loc=0
5931 #define OBD_FAIL_OSC_CHECKSUM_RECEIVE 0x408
5932 $LCTL set_param fail_loc=0x80000408
5934 cancel_lru_locks osc
5935 $DIRECTIO read $DIR/$tfile 0 $F77SZ $((1024 * 1024)) ||
5936 error "direct read: rc=$?"
5937 $LCTL set_param fail_loc=0
5940 run_test 77d "checksum error on OST direct write, read"
5942 test_77f() { # bug 10889
5943 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5944 $GSS && skip "could not run with gss" && return
5946 for algo in $CKSUM_TYPES; do
5947 cancel_lru_locks osc
5948 set_checksum_type $algo
5949 #define OBD_FAIL_OSC_CHECKSUM_SEND 0x409
5950 $LCTL set_param fail_loc=0x409
5951 $DIRECTIO write $DIR/$tfile 0 $F77SZ $((1024 * 1024)) &&
5952 error "direct write succeeded"
5953 $LCTL set_param fail_loc=0
5955 set_checksum_type $ORIG_CSUM_TYPE
5958 run_test 77f "repeat checksum error on write (expect error)"
5960 test_77g() { # bug 10889
5961 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5962 $GSS && skip "could not run with gss" && return
5963 remote_ost_nodsh && skip "remote OST with nodsh" && return
5965 [ ! -f $F77_TMP ] && setup_f77
5967 $SETSTRIPE -c 1 -i 0 $DIR/$tfile
5968 #define OBD_FAIL_OST_CHECKSUM_RECEIVE 0x21a
5969 do_facet ost1 lctl set_param fail_loc=0x8000021a
5971 dd if=$F77_TMP of=$DIR/$tfile bs=1M count=$F77SZ ||
5972 error "write error: rc=$?"
5973 do_facet ost1 lctl set_param fail_loc=0
5976 cancel_lru_locks osc
5977 #define OBD_FAIL_OST_CHECKSUM_SEND 0x21b
5978 do_facet ost1 lctl set_param fail_loc=0x8000021b
5980 cmp $F77_TMP $DIR/$tfile || error "file compare failed"
5981 do_facet ost1 lctl set_param fail_loc=0
5984 run_test 77g "checksum error on OST write, read"
5986 test_77i() { # bug 13805
5987 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5988 $GSS && skip "could not run with gss" && return
5989 #define OBD_FAIL_OSC_CONNECT_CKSUM 0x40b
5990 lctl set_param fail_loc=0x40b
5991 remount_client $MOUNT
5992 lctl set_param fail_loc=0
5993 for VALUE in `lctl get_param osc.*osc-[^mM]*.checksum_type`; do
5994 PARAM=`echo ${VALUE[0]} | cut -d "=" -f1`
5995 algo=`lctl get_param -n $PARAM | sed 's/.*\[\(.*\)\].*/\1/g'`
5996 [ "$algo" = "adler" ] || error "algo set to $algo instead of adler"
5998 remount_client $MOUNT
6000 run_test 77i "client not supporting OSD_CONNECT_CKSUM"
6002 test_77j() { # bug 13805
6003 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6004 $GSS && skip "could not run with gss" && return
6005 #define OBD_FAIL_OSC_CKSUM_ADLER_ONLY 0x40c
6006 lctl set_param fail_loc=0x40c
6007 remount_client $MOUNT
6008 lctl set_param fail_loc=0
6009 sleep 2 # wait async osc connect to finish
6010 for VALUE in `lctl get_param osc.*osc-[^mM]*.checksum_type`; do
6011 PARAM=`echo ${VALUE[0]} | cut -d "=" -f1`
6012 algo=`lctl get_param -n $PARAM | sed 's/.*\[\(.*\)\].*/\1/g'`
6013 [ "$algo" = "adler" ] || error "algo set to $algo instead of adler"
6015 remount_client $MOUNT
6017 run_test 77j "client only supporting ADLER32"
6019 [ "$ORIG_CSUM" ] && set_checksums $ORIG_CSUM || true
6023 test_78() { # bug 10901
6024 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6025 remote_ost || { skip_env "local OST" && return; }
6028 F78SIZE=$(($(awk '/MemFree:/ { print $2 }' /proc/meminfo) / 1024))
6029 echo "MemFree: $F78SIZE, Max file size: $MAXFREE"
6030 MEMTOTAL=$(($(awk '/MemTotal:/ { print $2 }' /proc/meminfo) / 1024))
6031 echo "MemTotal: $MEMTOTAL"
6033 # reserve 256MB of memory for the kernel and other running processes,
6034 # and then take 1/2 of the remaining memory for the read/write buffers.
6035 if [ $MEMTOTAL -gt 512 ] ;then
6036 MEMTOTAL=$(((MEMTOTAL - 256 ) / 2))
6038 # for those poor memory-starved high-end clusters...
6039 MEMTOTAL=$((MEMTOTAL / 2))
6041 echo "Mem to use for directio: $MEMTOTAL"
6043 [[ $F78SIZE -gt $MEMTOTAL ]] && F78SIZE=$MEMTOTAL
6044 [[ $F78SIZE -gt 512 ]] && F78SIZE=512
6045 [[ $F78SIZE -gt $((MAXFREE / 1024)) ]] && F78SIZE=$((MAXFREE / 1024))
6046 SMALLESTOST=$($LFS df $DIR | grep OST | awk '{ print $4 }' | sort -n |
6048 echo "Smallest OST: $SMALLESTOST"
6049 [[ $SMALLESTOST -lt 10240 ]] &&
6050 skip "too small OSTSIZE, useless to run large O_DIRECT test" && return 0
6052 [[ $F78SIZE -gt $((SMALLESTOST * $OSTCOUNT / 1024 - 80)) ]] &&
6053 F78SIZE=$((SMALLESTOST * $OSTCOUNT / 1024 - 80))
6055 [ "$SLOW" = "no" ] && NSEQ=1 && [ $F78SIZE -gt 32 ] && F78SIZE=32
6056 echo "File size: $F78SIZE"
6057 $SETSTRIPE -c $OSTCOUNT $DIR/$tfile || error "setstripe failed"
6058 for i in $(seq 1 $NSEQ); do
6059 FSIZE=$(($F78SIZE / ($NSEQ - $i + 1)))
6060 echo directIO rdwr round $i of $NSEQ
6061 $DIRECTIO rdwr $DIR/$tfile 0 $FSIZE 1048576||error "rdwr failed"
6066 run_test 78 "handle large O_DIRECT writes correctly ============"
6068 test_79() { # bug 12743
6069 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6070 wait_delete_completed
6072 BKTOTAL=$(calc_osc_kbytes kbytestotal)
6073 BKFREE=$(calc_osc_kbytes kbytesfree)
6074 BKAVAIL=$(calc_osc_kbytes kbytesavail)
6076 STRING=`df -P $MOUNT | tail -n 1 | awk '{print $2","$3","$4}'`
6077 DFTOTAL=`echo $STRING | cut -d, -f1`
6078 DFUSED=`echo $STRING | cut -d, -f2`
6079 DFAVAIL=`echo $STRING | cut -d, -f3`
6080 DFFREE=$(($DFTOTAL - $DFUSED))
6082 ALLOWANCE=$((64 * $OSTCOUNT))
6084 if [ $DFTOTAL -lt $(($BKTOTAL - $ALLOWANCE)) ] ||
6085 [ $DFTOTAL -gt $(($BKTOTAL + $ALLOWANCE)) ] ; then
6086 error "df total($DFTOTAL) mismatch OST total($BKTOTAL)"
6088 if [ $DFFREE -lt $(($BKFREE - $ALLOWANCE)) ] ||
6089 [ $DFFREE -gt $(($BKFREE + $ALLOWANCE)) ] ; then
6090 error "df free($DFFREE) mismatch OST free($BKFREE)"
6092 if [ $DFAVAIL -lt $(($BKAVAIL - $ALLOWANCE)) ] ||
6093 [ $DFAVAIL -gt $(($BKAVAIL + $ALLOWANCE)) ] ; then
6094 error "df avail($DFAVAIL) mismatch OST avail($BKAVAIL)"
6097 run_test 79 "df report consistency check ======================="
6099 test_80() { # bug 10718
6100 remote_ost_nodsh && skip "remote OST with nodsh" && return
6101 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6102 # relax strong synchronous semantics for slow backends like ZFS
6103 local soc="obdfilter.*.sync_on_lock_cancel"
6104 local soc_old=$(do_facet ost1 lctl get_param -n $soc | head -n1)
6106 if [ "$soc_old" != "never" -a "$(facet_fstype ost1)" != "ldiskfs" ]; then
6107 hosts=$(for host in $(seq -f "ost%g" 1 $OSTCOUNT); do
6108 facet_active_host $host; done | sort -u)
6109 do_nodes $hosts lctl set_param $soc=never
6112 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=1M
6114 local BEFORE=`date +%s`
6115 cancel_lru_locks osc
6116 local AFTER=`date +%s`
6117 local DIFF=$((AFTER-BEFORE))
6118 if [ $DIFF -gt 1 ] ; then
6119 error "elapsed for 1M@1T = $DIFF"
6122 [ -n "$hosts" ] && do_nodes $hosts lctl set_param $soc=$soc_old
6126 run_test 80 "Page eviction is equally fast at high offsets too ===="
6128 test_81a() { # LU-456
6129 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6130 remote_ost_nodsh && skip "remote OST with nodsh" && return
6131 # define OBD_FAIL_OST_MAPBLK_ENOSPC 0x228
6132 # MUST OR with the OBD_FAIL_ONCE (0x80000000)
6133 do_facet ost1 lctl set_param fail_loc=0x80000228
6135 # write should trigger a retry and success
6136 $SETSTRIPE -i 0 -c 1 $DIR/$tfile
6137 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
6139 if [ $RC -ne 0 ] ; then
6140 error "write should success, but failed for $RC"
6143 run_test 81a "OST should retry write when get -ENOSPC ==============="
6145 test_81b() { # LU-456
6146 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6147 remote_ost_nodsh && skip "remote OST with nodsh" && return
6148 # define OBD_FAIL_OST_MAPBLK_ENOSPC 0x228
6149 # Don't OR with the OBD_FAIL_ONCE (0x80000000)
6150 do_facet ost1 lctl set_param fail_loc=0x228
6152 # write should retry several times and return -ENOSPC finally
6153 $SETSTRIPE -i 0 -c 1 $DIR/$tfile
6154 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
6157 if [ $RC -ne $ENOSPC ] ; then
6158 error "dd should fail for -ENOSPC, but succeed."
6161 run_test 81b "OST should return -ENOSPC when retry still fails ======="
6163 test_82() { # LU-1031
6164 dd if=/dev/zero of=$DIR/$tfile bs=1M count=10
6168 multiop_bg_pause $DIR/$tfile OG${gid1}_g${gid1}c || return 1
6170 multiop_bg_pause $DIR/$tfile O_G${gid2}r10g${gid2}c || return 2
6172 kill -USR1 $MULTIPID2
6174 if [[ `ps h -o comm -p $MULTIPID2` == "" ]]; then
6175 error "First grouplock does not block second one"
6177 echo "Second grouplock blocks first one"
6179 kill -USR1 $MULTIPID1
6183 run_test 82 "Basic grouplock test ==============================="
6186 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" &&
6188 test_mkdir -p $DIR/d99cvsroot
6189 chown $RUNAS_ID $DIR/d99cvsroot
6190 local oldPWD=$PWD # bug 13584, use $TMP as working dir
6193 $RUNAS cvs -d $DIR/d99cvsroot init || error "cvs init failed"
6196 run_test 99a "cvs init ========================================="
6199 [ -z "$(which cvs 2>/dev/null)" ] &&
6200 skip_env "could not find cvs" && return
6201 [ ! -d $DIR/d99cvsroot ] && test_99a
6203 # some versions of cvs import exit(1) when asked to import links or
6204 # files they can't read. ignore those files.
6205 TOIGNORE=$(find . -type l -printf '-I %f\n' -o \
6206 ! -perm +4 -printf '-I %f\n')
6207 $RUNAS cvs -d $DIR/d99cvsroot import -m "nomesg" $TOIGNORE \
6208 d99reposname vtag rtag
6210 run_test 99b "cvs import ======================================="
6213 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" && return
6214 [ ! -d $DIR/d99cvsroot ] && test_99b
6216 test_mkdir -p $DIR/d99reposname
6217 chown $RUNAS_ID $DIR/d99reposname
6218 $RUNAS cvs -d $DIR/d99cvsroot co d99reposname
6220 run_test 99c "cvs checkout ====================================="
6223 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" && return
6224 [ ! -d $DIR/d99cvsroot ] && test_99c
6225 cd $DIR/d99reposname
6227 $RUNAS cvs add -m 'addmsg' foo99
6229 run_test 99d "cvs add =========================================="
6232 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" && return
6233 [ ! -d $DIR/d99cvsroot ] && test_99c
6234 cd $DIR/d99reposname
6237 run_test 99e "cvs update ======================================="
6240 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" && return
6241 [ ! -d $DIR/d99cvsroot ] && test_99d
6242 cd $DIR/d99reposname
6243 $RUNAS cvs commit -m 'nomsg' foo99
6244 rm -fr $DIR/d99cvsroot
6246 run_test 99f "cvs commit ======================================="
6249 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6250 [ "$NETTYPE" = tcp ] || \
6251 { skip "TCP secure port test, not useful for NETTYPE=$NETTYPE" && \
6254 remote_ost_nodsh && skip "remote OST with nodsh" && return
6255 remote_mds_nodsh && skip "remote MDS with nodsh" && return
6257 { skip "useless for local single node setup" && return; }
6259 netstat -tna | ( rc=1; while read PROT SND RCV LOCAL REMOTE STAT; do
6260 [ "$PROT" != "tcp" ] && continue
6261 RPORT=$(echo $REMOTE | cut -d: -f2)
6262 [ "$RPORT" != "$ACCEPTOR_PORT" ] && continue
6265 LPORT=`echo $LOCAL | cut -d: -f2`
6266 if [ $LPORT -ge 1024 ]; then
6267 echo "bad: $PROT $SND $RCV $LOCAL $REMOTE $STAT"
6269 error_exit "local: $LPORT > 1024, remote: $RPORT"
6272 [ "$rc" = 0 ] || error_exit "privileged port not found" )
6274 run_test 100 "check local port using privileged port ==========="
6276 function get_named_value()
6285 echo $line | sed "s/^$tag[ ]*//"
6292 export CACHE_MAX=$($LCTL get_param -n llite.*.max_cached_mb |
6293 awk '/^max_cached_mb/ { print $2 }')
6296 $LCTL set_param -n llite.*.max_cached_mb $CACHE_MAX
6301 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6302 [ $MDSCOUNT -ge 2 ] && skip "skip now for >= 2 MDTs" && return #LU-4322
6306 local cache_limit=32
6308 $LCTL set_param -n osc.*-osc*.rpc_stats 0
6309 trap cleanup_101a EXIT
6310 $LCTL set_param -n llite.*.read_ahead_stats 0
6311 $LCTL set_param -n llite.*.max_cached_mb $cache_limit
6314 # randomly read 10000 of 64K chunks from file 3x 32MB in size
6316 echo "nreads: $nreads file size: $((cache_limit * 3))MB"
6317 $READS -f $DIR/$tfile -s$((cache_limit * 3192 * 1024)) -b65536 -C -n$nreads -t 180
6320 for s in $($LCTL get_param -n llite.*.read_ahead_stats |
6321 get_named_value 'read but discarded' | cut -d" " -f1); do
6322 discard=$(($discard + $s))
6326 if [[ $(($discard * 10)) -gt $nreads ]]; then
6327 $LCTL get_param osc.*-osc*.rpc_stats
6328 $LCTL get_param llite.*.read_ahead_stats
6329 error "too many ($discard) discarded pages"
6331 rm -f $DIR/$tfile || true
6333 run_test 101a "check read-ahead for random reads ================"
6336 test_mkdir -p $DIR/$tdir
6337 local STRIPE_SIZE=$1
6338 local FILE_LENGTH=$2
6341 local FILE_SIZE_MB=$((FILE_LENGTH / STRIPE_SIZE))
6343 local list=$(comma_list $(osts_nodes))
6344 set_osd_param $list '' read_cache_enable 0
6345 set_osd_param $list '' writethrough_cache_enable 0
6347 trap cleanup_test101bc EXIT
6348 # prepare the read-ahead file
6349 $SETSTRIPE -S $STRIPE_SIZE -i $STRIPE_OFFSET -c $OSTCOUNT $DIR/$tfile
6351 dd if=/dev/zero of=$DIR/$tfile bs=$STRIPE_SIZE \
6352 count=$FILE_SIZE_MB 2> /dev/null
6356 cleanup_test101bc() {
6361 local list=$(comma_list $(osts_nodes))
6362 set_osd_param $list '' read_cache_enable 1
6363 set_osd_param $list '' writethrough_cache_enable 1
6367 awk 'BEGIN{total=0}; {total+=$1}; END{print total}'
6372 local STRIPE_SIZE=$2
6373 local FILE_LENGTH=$3
6374 local RA_INC=1048576
6375 local STRIDE_LENGTH=$((STRIPE_SIZE/READ_SIZE))
6376 local discard_limit=$((((STRIDE_LENGTH - 1)*3/(STRIDE_LENGTH*OSTCOUNT))* \
6377 (STRIDE_LENGTH*OSTCOUNT - STRIDE_LENGTH)))
6378 DISCARD=$($LCTL get_param -n llite.*.read_ahead_stats |
6379 get_named_value 'read but discarded' |
6380 cut -d" " -f1 | calc_total)
6381 if [[ $DISCARD -gt $discard_limit ]]; then
6382 $LCTL get_param llite.*.read_ahead_stats
6383 error "Too many ($DISCARD) discarded pages with size (${READ_SIZE})"
6385 echo "Read-ahead success for size ${READ_SIZE}"
6390 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6391 [[ $OSTCOUNT -lt 2 ]] &&
6392 skip_env "skipping stride IO stride-ahead test" && return
6393 local STRIPE_SIZE=1048576
6394 local STRIDE_SIZE=$((STRIPE_SIZE*OSTCOUNT))
6395 if [ $SLOW == "yes" ]; then
6396 local FILE_LENGTH=$((STRIDE_SIZE * 64))
6398 local FILE_LENGTH=$((STRIDE_SIZE * 8))
6401 local ITERATION=$((FILE_LENGTH / STRIDE_SIZE))
6403 # prepare the read-ahead file
6404 setup_test101bc $STRIPE_SIZE $FILE_LENGTH
6405 cancel_lru_locks osc
6406 for BIDX in 2 4 8 16 32 64 128 256
6408 local BSIZE=$((BIDX*4096))
6409 local READ_COUNT=$((STRIPE_SIZE/BSIZE))
6410 local STRIDE_LENGTH=$((STRIDE_SIZE/BSIZE))
6411 local OFFSET=$((STRIPE_SIZE/BSIZE*(OSTCOUNT - 1)))
6412 $LCTL set_param -n llite.*.read_ahead_stats 0
6413 $READS -f $DIR/$tfile -l $STRIDE_LENGTH -o $OFFSET \
6414 -s $FILE_LENGTH -b $STRIPE_SIZE -a $READ_COUNT -n $ITERATION
6415 cancel_lru_locks osc
6416 ra_check_101 $BSIZE $STRIPE_SIZE $FILE_LENGTH
6421 run_test 101b "check stride-io mode read-ahead ================="
6424 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6425 local STRIPE_SIZE=1048576
6426 local FILE_LENGTH=$((STRIPE_SIZE*100))
6430 setup_test101bc $STRIPE_SIZE $FILE_LENGTH
6432 cancel_lru_locks osc
6433 $LCTL set_param osc.*.rpc_stats 0
6434 $READS -f $DIR/$tfile -s$FILE_LENGTH -b65536 -n$nreads -t 180
6435 for osc_rpc_stats in $($LCTL get_param -N osc.*.rpc_stats); do
6436 local stats=$($LCTL get_param -n $osc_rpc_stats)
6437 local lines=$(echo "$stats" | awk 'END {print NR;}')
6440 if [ $lines -le 20 ]; then
6443 for size in 1 2 4 8; do
6444 local rpc=$(echo "$stats" |
6445 awk '($1 == "'$size':") {print $2; exit; }')
6447 error "Small $((size*4))k read IO $rpc !"
6449 echo "$osc_rpc_stats check passed!"
6454 run_test 101c "check stripe_size aligned read-ahead ================="
6457 $LCTL get_param -n llite.*.max_read_ahead_mb | head -n 1
6458 $LCTL set_param -n llite.*.max_read_ahead_mb $1 > /dev/null 2>&1
6462 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6463 local file=$DIR/$tfile
6464 local sz_MB=${FILESIZE_101d:-500}
6465 local ra_MB=${READAHEAD_MB:-40}
6467 local free_MB=$(($(df -P $DIR | tail -n 1 | awk '{ print $4 }') / 1024))
6468 [ $free_MB -lt $sz_MB ] &&
6469 skip "Need free space ${sz_MB}M, have ${free_MB}M" && return
6471 echo "Create test file $file size ${sz_MB}M, ${free_MB}M free"
6472 $SETSTRIPE -c -1 $file || error "setstripe failed"
6474 dd if=/dev/zero of=$file bs=1M count=$sz_MB || error "dd failed"
6475 echo Cancel LRU locks on lustre client to flush the client cache
6476 cancel_lru_locks osc
6478 echo Disable read-ahead
6479 local old_READAHEAD=$(set_read_ahead 0)
6481 echo Reading the test file $file with read-ahead disabled
6482 local raOFF=$(do_and_time "dd if=$file of=/dev/null bs=1M count=$sz_MB")
6484 echo Cancel LRU locks on lustre client to flush the client cache
6485 cancel_lru_locks osc
6486 echo Enable read-ahead with ${ra_MB}MB
6487 set_read_ahead $ra_MB
6489 echo Reading the test file $file with read-ahead enabled
6490 local raON=$(do_and_time "dd if=$file of=/dev/null bs=1M count=$sz_MB")
6492 echo "read-ahead disabled time read $raOFF"
6493 echo "read-ahead enabled time read $raON"
6495 set_read_ahead $old_READAHEAD
6497 wait_delete_completed
6499 [ $raOFF -le 1 -o $raON -lt $raOFF ] ||
6500 error "readahead ${raON}s > no-readahead ${raOFF}s ${sz_MB}M"
6502 run_test 101d "file read with and without read-ahead enabled"
6505 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6506 local file=$DIR/$tfile
6507 local size_KB=500 #KB
6511 local free_KB=$(df -P $DIR | tail -n 1 | awk '{ print $4 }')
6512 local need_KB=$((count * size_KB))
6513 [[ $free_KB -le $need_KB ]] &&
6514 skip_env "Need free space $need_KB, have $free_KB" && return
6516 echo "Creating $count ${size_KB}K test files"
6517 for ((i = 0; i < $count; i++)); do
6518 dd if=/dev/zero of=$file.$i bs=$bsize count=$size_KB 2>/dev/null
6521 echo "Cancel LRU locks on lustre client to flush the client cache"
6522 cancel_lru_locks osc
6524 echo "Reset readahead stats"
6525 $LCTL set_param -n llite.*.read_ahead_stats 0
6527 for ((i = 0; i < $count; i++)); do
6528 dd if=$file.$i of=/dev/null bs=$bsize count=$size_KB 2>/dev/null
6531 local miss=$($LCTL get_param -n llite.*.read_ahead_stats |
6532 get_named_value 'misses' | cut -d" " -f1 | calc_total)
6534 for ((i = 0; i < $count; i++)); do
6535 rm -rf $file.$i 2>/dev/null
6538 #10000 means 20% reads are missing in readahead
6539 [[ $miss -lt 10000 ]] || error "misses too much for small reads"
6541 run_test 101e "check read-ahead for small read(1k) for small files(500k)"
6543 cleanup_test101f() {
6545 $LCTL set_param -n llite.*.max_read_ahead_whole_mb $MAX_WHOLE_MB
6546 rm -rf $DIR/$tfile 2>/dev/null
6550 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6551 local file=$DIR/$tfile
6554 MAX_WHOLE_MB=$($LCTL get_param -n llite.*.max_read_ahead_whole_mb)
6555 $LCTL set_param -n llite.*.max_read_ahead_whole_mb 2
6556 dd if=/dev/zero of=${file} bs=2097152 count=1 2>/dev/null
6557 trap cleanup_test101f EXIT
6559 echo Cancel LRU locks on lustre client to flush the client cache
6560 cancel_lru_locks osc
6562 echo Reset readahead stats
6563 $LCTL set_param -n llite.*.read_ahead_stats 0
6564 # Random read in a 2M file, because max_read_ahead_whole_mb = 2M,
6565 # readahead should read in 2M file on second read, so only miss
6567 echo Random 4K reads on 2M file for 1000 times
6568 $READS -f $file -s 2097152 -b 4096 -n $nreads
6570 echo checking missing pages
6571 local miss=$($LCTL get_param -n llite.*.read_ahead_stats |
6572 get_named_value 'misses' | cut -d" " -f1 | calc_total)
6574 [ $miss -lt 3 ] || error "misses too much pages!"
6577 run_test 101f "check read-ahead for max_read_ahead_whole_mb"
6580 test_mkdir -p $DIR/$tdir
6581 chown $RUNAS_ID $DIR/$tdir
6584 STRIPE_COUNT=$OSTCOUNT
6585 [[ $OSTCOUNT -gt 4 ]] && STRIPE_COUNT=4
6587 trap cleanup_test102 EXIT
6589 $1 $SETSTRIPE -S $STRIPE_SIZE -i $STRIPE_OFFSET -c $STRIPE_COUNT $tdir
6591 for num in 1 2 3 4; do
6592 for count in $(seq 1 $STRIPE_COUNT); do
6593 for idx in $(seq 0 $[$STRIPE_COUNT - 1]); do
6594 local size=`expr $STRIPE_SIZE \* $num`
6595 local file=file"$num-$idx-$count"
6596 $1 $SETSTRIPE -S $size -i $idx -c $count $file
6602 $1 $TAR cf $TMP/f102.tar $tdir --xattrs
6608 rm -rf $DIR/d0.sanity/d102
6612 local testfile=$DIR/$tfile
6616 [ "$UID" != 0 ] && skip_env "must run as root" && return
6617 [ -z "$(lctl get_param -n mdc.*-mdc-*.connect_flags | grep xattr)" ] &&
6618 skip_env "must have user_xattr" && return
6620 [ -z "$(which setfattr 2>/dev/null)" ] &&
6621 skip_env "could not find setfattr" && return
6623 echo "set/get xattr..."
6624 setfattr -n trusted.name1 -v value1 $testfile ||
6625 error "setfattr -n trusted.name1=value1 $testfile failed"
6626 getfattr -n trusted.name1 $testfile 2> /dev/null |
6627 grep "trusted.name1=.value1" ||
6628 error "$testfile missing trusted.name1=value1"
6630 setfattr -n user.author1 -v author1 $testfile ||
6631 error "setfattr -n user.author1=author1 $testfile failed"
6632 getfattr -n user.author1 $testfile 2> /dev/null |
6633 grep "user.author1=.author1" ||
6634 error "$testfile missing trusted.author1=author1"
6637 setfattr -n trusted.name2 -v value2 $testfile ||
6638 error "$testfile unable to set trusted.name2"
6639 setfattr -n trusted.name3 -v value3 $testfile ||
6640 error "$testfile unable to set trusted.name3"
6641 [ $(getfattr -d -m "^trusted" $testfile 2> /dev/null |
6642 grep "trusted.name" | wc -l) -eq 3 ] ||
6643 error "$testfile missing 3 trusted.name xattrs"
6645 setfattr -n user.author2 -v author2 $testfile ||
6646 error "$testfile unable to set user.author2"
6647 setfattr -n user.author3 -v author3 $testfile ||
6648 error "$testfile unable to set user.author3"
6649 [ $(getfattr -d -m "^user" $testfile 2> /dev/null |
6650 grep "user.author" | wc -l) -eq 3 ] ||
6651 error "$testfile missing 3 user.author xattrs"
6653 echo "remove xattr..."
6654 setfattr -x trusted.name1 $testfile ||
6655 error "$testfile error deleting trusted.name1"
6656 getfattr -d -m trusted $testfile 2> /dev/null | grep "trusted.name1" &&
6657 error "$testfile did not delete trusted.name1 xattr"
6659 setfattr -x user.author1 $testfile ||
6660 error "$testfile error deleting user.author1"
6661 getfattr -d -m user $testfile 2> /dev/null | grep "user.author1" &&
6662 error "$testfile did not delete trusted.name1 xattr"
6664 # b10667: setting lustre special xattr be silently discarded
6665 echo "set lustre special xattr ..."
6666 setfattr -n "trusted.lov" -v "invalid value" $testfile ||
6667 error "$testfile allowed setting trusted.lov"
6669 run_test 102a "user xattr test =================================="
6672 [ -z "$(which setfattr 2>/dev/null)" ] &&
6673 skip_env "could not find setfattr" && return
6675 # b10930: get/set/list trusted.lov xattr
6676 echo "get/set/list trusted.lov xattr ..."
6677 [[ $OSTCOUNT -lt 2 ]] && skip_env "skipping 2-stripe test" && return
6678 local testfile=$DIR/$tfile
6679 $SETSTRIPE -S 65536 -i 1 -c $OSTCOUNT $testfile ||
6680 error "setstripe failed"
6681 local STRIPECOUNT=$($GETSTRIPE -c $testfile) ||
6682 error "getstripe failed"
6683 getfattr -d -m "^trusted" $testfile 2>/dev/null | grep "trusted.lov" ||
6684 error "can't get trusted.lov from $testfile"
6686 local testfile2=${testfile}2
6687 local value=$(getfattr -n trusted.lov $testfile 2>/dev/null |
6688 grep "trusted.lov" | sed -e 's/[^=]\+=//')
6691 setfattr -n trusted.lov -v $value $testfile2
6692 local stripe_size=$($GETSTRIPE -S $testfile2)
6693 local stripe_count=$($GETSTRIPE -c $testfile2)
6694 [[ $stripe_size -eq 65536 ]] ||
6695 error "stripe size $stripe_size != 65536"
6696 [[ $stripe_count -eq $STRIPECOUNT ]] ||
6697 error "stripe count $stripe_count != $STRIPECOUNT"
6700 run_test 102b "getfattr/setfattr for trusted.lov EAs ============"
6703 [ -z "$(which setfattr 2>/dev/null)" ] &&
6704 skip_env "could not find setfattr" && return
6706 # b10930: get/set/list lustre.lov xattr
6707 echo "get/set/list lustre.lov xattr ..."
6708 [[ $OSTCOUNT -lt 2 ]] && skip_env "skipping 2-stripe test" && return
6709 test_mkdir -p $DIR/$tdir
6710 chown $RUNAS_ID $DIR/$tdir
6711 local testfile=$DIR/$tdir/$tfile
6712 $RUNAS $SETSTRIPE -S 65536 -i 1 -c $OSTCOUNT $testfile ||
6713 error "setstripe failed"
6714 local STRIPECOUNT=$($RUNAS $GETSTRIPE -c $testfile) ||
6715 error "getstripe failed"
6716 $RUNAS getfattr -d -m "^lustre" $testfile 2> /dev/null | \
6717 grep "lustre.lov" || error "can't get lustre.lov from $testfile"
6719 local testfile2=${testfile}2
6720 local value=`getfattr -n lustre.lov $testfile 2> /dev/null | \
6721 grep "lustre.lov" |sed -e 's/[^=]\+=//' `
6723 $RUNAS $MCREATE $testfile2
6724 $RUNAS setfattr -n lustre.lov -v $value $testfile2
6725 local stripe_size=$($RUNAS $GETSTRIPE -S $testfile2)
6726 local stripe_count=$($RUNAS $GETSTRIPE -c $testfile2)
6727 [ $stripe_size -eq 65536 ] || error "stripe size $stripe_size != 65536"
6728 [ $stripe_count -eq $STRIPECOUNT ] ||
6729 error "stripe count $stripe_count != $STRIPECOUNT"
6731 run_test 102c "non-root getfattr/setfattr for lustre.lov EAs ==========="
6733 compare_stripe_info1() {
6734 local stripe_index_all_zero=true
6736 for num in 1 2 3 4; do
6737 for count in $(seq 1 $STRIPE_COUNT); do
6738 for offset in $(seq 0 $[$STRIPE_COUNT - 1]); do
6739 local size=$((STRIPE_SIZE * num))
6740 local file=file"$num-$offset-$count"
6741 stripe_size=$($LFS getstripe -S $PWD/$file)
6742 [[ $stripe_size -ne $size ]] &&
6743 error "$file: size $stripe_size != $size"
6744 stripe_count=$($LFS getstripe -c $PWD/$file)
6745 # allow fewer stripes to be created, ORI-601
6746 [[ $stripe_count -lt $(((3 * count + 3) / 4)) ]] &&
6747 error "$file: count $stripe_count != $count"
6748 stripe_index=$($LFS getstripe -i $PWD/$file)
6749 [[ $stripe_index -ne 0 ]] &&
6750 stripe_index_all_zero=false
6754 $stripe_index_all_zero &&
6755 error "all files are being extracted starting from OST index 0"
6760 [ -n "$(which tar 2>/dev/null)" ] &&
6761 strings $(which tar) | grep -q "lustre" && echo tar
6765 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6766 # b10930: tar test for trusted.lov xattr
6767 TAR=$(find_lustre_tar)
6768 [ -z "$TAR" ] && skip_env "lustre-aware tar is not installed" && return
6769 [[ $OSTCOUNT -lt 2 ]] && skip_env "skipping N-stripe test" && return
6771 test_mkdir -p $DIR/d102d
6772 $TAR xf $TMP/f102.tar -C $DIR/d102d --xattrs
6774 compare_stripe_info1
6776 run_test 102d "tar restore stripe info from tarfile,not keep osts ==========="
6779 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6780 # b10930: tar test for trusted.lov xattr
6781 TAR=$(find_lustre_tar)
6782 [ -z "$TAR" ] && skip_env "lustre-aware tar is not installed" && return
6783 [[ $OSTCOUNT -lt 2 ]] && skip_env "skipping N-stripe test" && return
6785 test_mkdir -p $DIR/d102f
6787 $TAR cf - --xattrs $tdir | $TAR xf - --xattrs -C $DIR/d102f
6789 compare_stripe_info1
6791 run_test 102f "tar copy files, not keep osts ==========="
6794 local xsize=${1:-1024} # in bytes
6795 local file=$DIR/$tfile
6797 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep xattr)" ] &&
6798 skip "must have user_xattr" && return 0
6799 [ -z "$(which setfattr 2>/dev/null)" ] &&
6800 skip_env "could not find setfattr" && return 0
6801 [ -z "$(which getfattr 2>/dev/null)" ] &&
6802 skip_env "could not find getfattr" && return 0
6806 local value="$(generate_string $xsize)"
6808 local xbig=trusted.big
6809 log "save $xbig on $file"
6810 setfattr -n $xbig -v $value $file ||
6811 error "saving $xbig on $file failed"
6813 local orig=$(get_xattr_value $xbig $file)
6814 [[ "$orig" != "$value" ]] && error "$xbig different after saving $xbig"
6816 local xsml=trusted.sml
6817 log "save $xsml on $file"
6818 setfattr -n $xsml -v val $file || error "saving $xsml on $file failed"
6820 local new=$(get_xattr_value $xbig $file)
6821 [[ "$new" != "$orig" ]] && error "$xbig different after saving $xsml"
6823 log "grow $xsml on $file"
6824 setfattr -n $xsml -v "$value" $file ||
6825 error "growing $xsml on $file failed"
6827 new=$(get_xattr_value $xbig $file)
6828 [[ "$new" != "$orig" ]] && error "$xbig different after growing $xsml"
6829 log "$xbig still valid after growing $xsml"
6834 test_102h() { # bug 15777
6837 run_test 102h "grow xattr from inside inode to external block"
6840 large_xattr_enabled || { skip "large_xattr disabled" && return; }
6841 grow_xattr $(max_xattr_size)
6843 run_test 102ha "grow xattr from inside inode to external inode"
6845 test_102i() { # bug 17038
6846 [ -z "$(which getfattr 2>/dev/null)" ] &&
6847 skip "could not find getfattr" && return
6849 ln -s $DIR/$tfile $DIR/${tfile}link
6850 getfattr -n trusted.lov $DIR/$tfile ||
6851 error "lgetxattr on $DIR/$tfile failed"
6852 getfattr -h -n trusted.lov $DIR/${tfile}link 2>&1 |
6853 grep -i "no such attr" ||
6854 error "error for lgetxattr on $DIR/${tfile}link is not ENODATA"
6855 rm -f $DIR/$tfile $DIR/${tfile}link
6857 run_test 102i "lgetxattr test on symbolic link ============"
6860 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6861 TAR=$(find_lustre_tar)
6862 [ -z "$TAR" ] && skip_env "lustre-aware tar is not installed" && return
6863 [[ $OSTCOUNT -lt 2 ]] && skip_env "skipping N-stripe test" && return
6864 setup_test102 "$RUNAS"
6865 test_mkdir -p $DIR/d102j
6866 chown $RUNAS_ID $DIR/d102j
6867 $RUNAS $TAR xf $TMP/f102.tar -C $DIR/d102j --xattrs
6869 compare_stripe_info1 "$RUNAS"
6871 run_test 102j "non-root tar restore stripe info from tarfile, not keep osts ==="
6874 [ -z "$(which setfattr 2>/dev/null)" ] &&
6875 skip "could not find setfattr" && return
6877 # b22187 just check that does not crash for regular file.
6878 setfattr -n trusted.lov $DIR/$tfile
6879 # b22187 'setfattr -n trusted.lov' should work as remove LOV EA for directories
6880 local test_kdir=$DIR/d102k
6881 test_mkdir $test_kdir
6882 local default_size=`$GETSTRIPE -S $test_kdir`
6883 local default_count=`$GETSTRIPE -c $test_kdir`
6884 local default_offset=`$GETSTRIPE -i $test_kdir`
6885 $SETSTRIPE -S 65536 -i 0 -c $OSTCOUNT $test_kdir ||
6886 error 'dir setstripe failed'
6887 setfattr -n trusted.lov $test_kdir
6888 local stripe_size=`$GETSTRIPE -S $test_kdir`
6889 local stripe_count=`$GETSTRIPE -c $test_kdir`
6890 local stripe_offset=`$GETSTRIPE -i $test_kdir`
6891 [ $stripe_size -eq $default_size ] ||
6892 error "stripe size $stripe_size != $default_size"
6893 [ $stripe_count -eq $default_count ] ||
6894 error "stripe count $stripe_count != $default_count"
6895 [ $stripe_offset -eq $default_offset ] ||
6896 error "stripe offset $stripe_offset != $default_offset"
6897 rm -rf $DIR/$tfile $test_kdir
6899 run_test 102k "setfattr without parameter of value shouldn't cause a crash"
6902 [ -z "$(which getfattr 2>/dev/null)" ] &&
6903 skip "could not find getfattr" && return
6905 # LU-532 trusted. xattr is invisible to non-root
6906 local testfile=$DIR/$tfile
6910 echo "listxattr as user..."
6911 chown $RUNAS_ID $testfile
6912 $RUNAS getfattr -d -m '.*' $testfile 2>&1 |
6913 grep -q "trusted" &&
6914 error "$testfile trusted xattrs are user visible"
6918 run_test 102l "listxattr size test =================================="
6920 test_102m() { # LU-3403 llite: error of listxattr when buffer is small
6921 local path=$DIR/$tfile
6924 listxattr_size_check $path || error "listattr_size_check $path failed"
6926 run_test 102m "Ensure listxattr fails on small bufffer ========"
6930 getxattr() { # getxattr path name
6931 # Return the base64 encoding of the value of xattr name on path.
6935 # # getfattr --absolute-names --encoding=base64 --name=trusted.lov $path
6937 # trusted.lov=0s0AvRCwEAAAAGAAAAAAAAAAAEAAACAAAAAAAQAAEAA...AAAAAAAAA=
6939 # We print just 0s0AvRCwEAAAAGAAAAAAAAAAAEAAACAAAAAAAQAAEAA...AAAAAAAAA=
6941 getfattr --absolute-names --encoding=base64 --name=$name $path |
6942 awk -F= -v name=$name '$1 == name {
6943 print substr($0, index($0, "=") + 1);
6947 test_102n() { # LU-4101 mdt: protect internal xattrs
6948 local file0=$DIR/$tfile.0
6949 local file1=$DIR/$tfile.1
6950 local xattr0=$TMP/$tfile.0
6951 local xattr1=$TMP/$tfile.1
6955 [ -z "$(which setfattr 2>/dev/null)" ] &&
6956 skip "could not find setfattr" && return
6958 if [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.5.50) ]
6960 skip "MDT < 2.5.50 allows setxattr on internal trusted xattrs"
6964 rm -rf $file0 $file1 $xattr0 $xattr1
6967 # Get 'before' xattrs of $file1.
6968 getfattr --absolute-names --dump --match=- $file1 > $xattr0
6970 for name in lov lma lmv link fid version som hsm lfsck_namespace; do
6971 # Try to copy xattr from $file0 to $file1.
6972 value=$(getxattr $file0 trusted.$name 2> /dev/null)
6974 setfattr --name=trusted.$name --value="$value" $file1 ||
6975 error "setxattr 'trusted.$name' failed"
6977 # Try to set a garbage xattr.
6978 value=0sVGhlIHF1aWNrIGJyb3duIGZveCBqdW1wcyBvdmVyIGl0c2VsZi4=
6980 setfattr --name=trusted.$name --value="$value" $file1 ||
6981 error "setxattr 'trusted.$name' failed"
6983 # Try to remove the xattr from $file1. We don't care if this
6984 # appears to succeed or fail, we just don't want there to be
6985 # any changes or crashes.
6986 setfattr --remove=$trusted.$name $file1 2> /dev/null
6989 if [ $(lustre_version_code $SINGLEMDS) -gt $(version_code 2.6.50) ]
6992 # Try to copy xattr from $file0 to $file1.
6993 value=$(getxattr $file0 trusted.$name 2> /dev/null)
6995 setfattr --name=trusted.$name --value="$value" $file1 ||
6996 error "setxattr 'trusted.$name' failed"
6998 # Try to set a garbage xattr.
6999 value=0sVGhlIHF1aWNrIGJyb3duIGZveCBqdW1wcyBvdmVyIGl0c2VsZi4=
7001 setfattr --name=trusted.$name --value="$value" $file1 ||
7002 error "setxattr 'trusted.$name' failed"
7004 # Try to remove the xattr from $file1. We don't care if this
7005 # appears to succeed or fail, we just don't want there to be
7006 # any changes or crashes.
7007 setfattr --remove=$trusted.$name $file1 2> /dev/null
7010 # Get 'after' xattrs of file1.
7011 getfattr --absolute-names --dump --match=- $file1 > $xattr1
7013 if ! diff $xattr0 $xattr1; then
7014 error "before and after xattrs of '$file1' differ"
7017 rm -rf $file0 $file1 $xattr0 $xattr1
7021 run_test 102n "silently ignore setxattr on internal trusted xattrs"
7023 test_102p() { # LU-4703 setxattr did not check ownership
7024 local testfile=$DIR/$tfile
7026 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.5.56) ] &&
7027 skip "MDS needs to be at least 2.5.56" && return
7031 echo "setfacl as user..."
7032 $RUNAS setfacl -m "u:$RUNAS_ID:rwx" $testfile
7033 [ $? -ne 0 ] || error "setfacl by $RUNAS_ID was allowed on $testfile"
7035 echo "setfattr as user..."
7036 setfacl -m "u:$RUNAS_ID:---" $testfile
7037 $RUNAS setfattr -x system.posix_acl_access $testfile
7038 [ $? -ne 0 ] || error "setfattr by $RUNAS_ID was allowed on $testfile"
7040 run_test 102p "check setxattr(2) correctly fails without permission"
7043 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.6.92) ] &&
7044 skip "MDS needs to be at least 2.6.92" && return
7045 orphan_linkea_check $DIR/$tfile || error "orphan_linkea_check"
7047 run_test 102q "flistxattr should not return trusted.link EAs for orphans"
7050 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.6.93) ] &&
7051 skip "MDS needs to be at least 2.6.93" && return
7052 touch $DIR/$tfile || error "touch"
7053 setfattr -n user.$(basename $tfile) $DIR/$tfile || error "setfattr"
7054 getfattr -n user.$(basename $tfile) $DIR/$tfile || error "getfattr"
7055 rm $DIR/$tfile || error "rm"
7058 mkdir -p $DIR/$tdir || error "mkdir"
7059 setfattr -n user.$(basename $tdir) $DIR/$tdir || error "setfattr dir"
7060 getfattr -n user.$(basename $tdir) $DIR/$tdir || error "getfattr dir"
7061 setfattr -x user.$(basename $tdir) $DIR/$tdir ||
7062 error "$testfile error deleting user.author1"
7063 getfattr -d -m user.$(basename $tdir) 2> /dev/null |
7064 grep "user.$(basename $tdir)" &&
7065 error "$tdir did not delete user.$(basename $tdir)"
7066 rmdir $DIR/$tdir || error "rmdir"
7069 test_mkdir -p $DIR/$tdir || error "make striped dir"
7070 setfattr -n user.$(basename $tdir) $DIR/$tdir || error "setfattr dir"
7071 getfattr -n user.$(basename $tdir) $DIR/$tdir || error "getfattr dir"
7072 setfattr -x user.$(basename $tdir) $DIR/$tdir ||
7073 error "$testfile error deleting user.author1"
7074 getfattr -d -m user.$(basename $tdir) 2> /dev/null |
7075 grep "user.$(basename $tdir)" &&
7076 error "$tdir did not delete user.$(basename $tdir)"
7077 rmdir $DIR/$tdir || error "rm striped dir"
7079 run_test 102r "set EAs with empty values"
7083 $LUSTRE/tests/acl/run $LUSTRE/tests/acl/$1.test
7088 [ "$UID" != 0 ] && skip_env "must run as root" && return
7089 [ -z "$(lctl get_param -n mdc.*-mdc-*.connect_flags | grep acl)" ] &&
7090 skip "must have acl enabled" && return
7091 [ -z "$(which setfacl 2>/dev/null)" ] &&
7092 skip_env "could not find setfacl" && return
7093 $GSS && skip "could not run under gss" && return
7095 gpasswd -a daemon bin # LU-5641
7096 do_facet $SINGLEMDS gpasswd -a daemon bin # LU-5641
7098 declare -a identity_old
7100 for num in $(seq $MDSCOUNT); do
7101 switch_identity $num true || identity_old[$num]=$?
7108 echo "performing cp ..."
7109 run_acl_subtest cp || error "run_acl_subtest cp failed"
7110 echo "performing getfacl-noacl..."
7111 run_acl_subtest getfacl-noacl || error "getfacl-noacl test failed"
7112 echo "performing misc..."
7113 run_acl_subtest misc || error "misc test failed"
7114 echo "performing permissions..."
7115 run_acl_subtest permissions || error "permissions failed"
7116 echo "performing setfacl..."
7117 run_acl_subtest setfacl || error "setfacl test failed"
7119 # inheritance test got from HP
7120 echo "performing inheritance..."
7121 cp $LUSTRE/tests/acl/make-tree . || error "cannot copy make-tree"
7122 chmod +x make-tree || error "chmod +x failed"
7123 run_acl_subtest inheritance || error "inheritance test failed"
7126 echo "LU-974 ignore umask when acl is enabled..."
7127 run_acl_subtest 974 || error "LU-974 umask test failed"
7128 if [ $MDSCOUNT -ge 2 ]; then
7129 run_acl_subtest 974_remote ||
7130 error "LU-974 umask test failed under remote dir"
7133 echo "LU-2561 newly created file is same size as directory..."
7134 if [ $(facet_fstype $SINGLEMDS) != "zfs" ]; then
7135 run_acl_subtest 2561 || error "LU-2561 test failed"
7137 run_acl_subtest 2561_zfs || error "LU-2561 zfs test failed"
7140 run_acl_subtest 4924 || error "LU-4924 test failed"
7145 for num in $(seq $MDSCOUNT); do
7146 if [ "${identity_old[$num]}" = 1 ]; then
7147 switch_identity $num false || identity_old[$num]=$?
7151 run_test 103a "acl test ========================================="
7155 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
7156 local mountopts=$MDS_MOUNT_OPTS
7158 if [[ "$MDS_MOUNT_OPTS" =~ "noacl" ]]; then
7162 stop $SINGLEMDS || error "failed to stop MDT."
7164 if [ -z "$MDS_MOUNT_OPTS" ]; then
7165 MDS_MOUNT_OPTS="-o noacl"
7167 MDS_MOUNT_OPTS="${MDS_MOUNT_OPTS},noacl"
7169 start $SINGLEMDS $MDT_DEV $MDS_MOUNT_OPTS ||
7170 error "failed to start MDT."
7171 MDS_MOUNT_OPTS=$mountopts
7175 setfacl -m u:bin:rw $DIR/$tfile && error "setfacl should fail"
7179 stop $SINGLEMDS || error "failed to stop MDT."
7181 start $SINGLEMDS $MDT_DEV $MDS_MOUNT_OPTS ||
7182 error "failed to start MDT."
7187 run_test 103b "MDS mount option 'noacl'"
7191 cp -rp $DIR/$tdir $DIR/$tdir.bak
7193 [ -n "$(getfattr -d -m. $DIR/$tdir | grep posix_acl_default)" ] &&
7194 error "$DIR/$tdir shouldn't contain default ACL"
7195 [ -n "$(getfattr -d -m. $DIR/$tdir.bak | grep posix_acl_default)" ] &&
7196 error "$DIR/$tdir.bak shouldn't contain default ACL"
7199 run_test 103c "'cp -rp' won't set empty acl"
7202 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7204 lfs df || error "lfs df failed"
7205 lfs df -ih || error "lfs df -ih failed"
7206 lfs df -h $DIR || error "lfs df -h $DIR failed"
7207 lfs df -i $DIR || error "lfs df -i $DIR failed"
7208 lfs df $DIR/$tfile || error "lfs df $DIR/$tfile failed"
7209 lfs df -ih $DIR/$tfile || error "lfs df -ih $DIR/$tfile failed"
7211 local OSC=$(lctl dl | grep OST0000-osc-[^M] | awk '{ print $4 }')
7212 lctl --device %$OSC deactivate
7213 lfs df || error "lfs df with deactivated OSC failed"
7214 lctl --device %$OSC activate
7215 # wait the osc back to normal
7216 wait_osc_import_state client ost FULL
7218 lfs df || error "lfs df with reactivated OSC failed"
7221 run_test 104a "lfs df [-ih] [path] test ========================="
7224 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7225 [ $RUNAS_ID -eq $UID ] &&
7226 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
7228 denied_cnt=$(($($RUNAS $LFS check servers 2>&1 |
7229 grep "Permission denied" | wc -l)))
7230 if [ $denied_cnt -ne 0 ]; then
7231 error "lfs check servers test failed"
7234 run_test 104b "$RUNAS lfs check servers test ===================="
7237 # doesn't work on 2.4 kernels
7239 if $(flock_is_enabled); then
7240 flocks_test 1 on -f $DIR/$tfile || error "fail flock on"
7242 flocks_test 1 off -f $DIR/$tfile || error "fail flock off"
7246 run_test 105a "flock when mounted without -o flock test ========"
7250 if $(flock_is_enabled); then
7251 flocks_test 1 on -c $DIR/$tfile || error "fail flock on"
7253 flocks_test 1 off -c $DIR/$tfile || error "fail flock off"
7257 run_test 105b "fcntl when mounted without -o flock test ========"
7261 if $(flock_is_enabled); then
7262 flocks_test 1 on -l $DIR/$tfile || error "fail flock on"
7264 flocks_test 1 off -l $DIR/$tfile || error "fail flock off"
7268 run_test 105c "lockf when mounted without -o flock test ========"
7270 test_105d() { # bug 15924
7271 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7272 test_mkdir -p $DIR/$tdir
7273 flock_is_enabled || { skip "mount w/o flock enabled" && return; }
7274 #define OBD_FAIL_LDLM_CP_CB_WAIT 0x315
7275 $LCTL set_param fail_loc=0x80000315
7276 flocks_test 2 $DIR/$tdir
7278 run_test 105d "flock race (should not freeze) ========"
7280 test_105e() { # bug 22660 && 22040
7281 flock_is_enabled || { skip "mount w/o flock enabled" && return; }
7283 flocks_test 3 $DIR/$tfile
7285 run_test 105e "Two conflicting flocks from same process ======="
7287 test_106() { #bug 10921
7288 test_mkdir -p $DIR/$tdir
7289 $DIR/$tdir && error "exec $DIR/$tdir succeeded"
7290 chmod 777 $DIR/$tdir || error "chmod $DIR/$tdir failed"
7292 run_test 106 "attempt exec of dir followed by chown of that dir"
7295 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7302 local save_pattern=$(sysctl -n kernel.core_pattern)
7303 local save_uses_pid=$(sysctl -n kernel.core_uses_pid)
7304 sysctl -w kernel.core_pattern=$file
7305 sysctl -w kernel.core_uses_pid=0
7313 kill -s 11 $SLEEPPID
7315 if [ -e $file ]; then
7316 size=`stat -c%s $file`
7317 [ $size -eq 0 ] && error "Fail to create core file $file"
7319 error "Fail to create core file $file"
7322 sysctl -w kernel.core_pattern=$save_pattern
7323 sysctl -w kernel.core_uses_pid=$save_uses_pid
7326 run_test 107 "Coredump on SIG"
7329 test_mkdir -p $DIR/$tdir
7330 test_mkdir $DIR/$tdir/$(str_repeat 'a' 255) ||
7331 error "mkdir with 255 char failed"
7332 test_mkdir $DIR/$tdir/$(str_repeat 'b' 256) &&
7333 error "mkdir with 256 char should fail, but did not"
7334 touch $DIR/$tdir/$(str_repeat 'x' 255) ||
7335 error "create with 255 char failed"
7336 touch $DIR/$tdir/$(str_repeat 'y' 256) &&
7337 error "create with 256 char should fail, but did not"
7342 run_test 110 "filename length checking"
7345 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7346 OSTIO_pre=$(ps -e | grep ll_ost_io | awk '{ print $4 }'| sort -n |
7347 tail -1 | cut -c11-20)
7348 [ -z "$OSTIO_pre" ] && skip "no OSS threads" && return
7349 echo "Starting with $OSTIO_pre threads"
7352 NUMFREE=$(df -i -P $DIR | tail -n 1 | awk '{ print $4 }')
7353 [[ $NUMFREE -lt $NUMTEST ]] && NUMTEST=$(($NUMFREE - 1000))
7354 echo "$NUMTEST creates/unlinks"
7355 test_mkdir -p $DIR/$tdir
7356 createmany -o $DIR/$tdir/$tfile $NUMTEST
7357 unlinkmany $DIR/$tdir/$tfile $NUMTEST
7359 OSTIO_post=$(ps -e | grep ll_ost_io | awk '{ print $4 }' | sort -n |
7360 tail -1 | cut -c11-20)
7362 # don't return an error
7363 [ $OSTIO_post == $OSTIO_pre ] && echo \
7364 "WARNING: No new ll_ost_io threads were created ($OSTIO_pre)" &&
7365 echo "This may be fine, depending on what ran before this test" &&
7366 echo "and how fast this system is." && return
7368 echo "Started with $OSTIO_pre threads, ended with $OSTIO_post"
7370 run_test 115 "verify dynamic thread creation===================="
7373 wait_delete_completed
7374 AVAIL=($(lctl get_param -n osc.*[oO][sS][cC]-[^M]*.kbytesavail))
7375 echo OST kbytes available: ${AVAIL[@]}
7376 MAXI=0; MAXV=${AVAIL[0]}
7377 MINI=0; MINV=${AVAIL[0]}
7378 for ((i = 0; i < ${#AVAIL[@]}; i++)); do
7379 #echo OST $i: ${AVAIL[i]}kb
7380 if [[ ${AVAIL[i]} -gt $MAXV ]]; then
7381 MAXV=${AVAIL[i]}; MAXI=$i
7383 if [[ ${AVAIL[i]} -lt $MINV ]]; then
7384 MINV=${AVAIL[i]}; MINI=$i
7387 echo Min free space: OST $MINI: $MINV
7388 echo Max free space: OST $MAXI: $MAXV
7391 test_116a() { # was previously test_116()
7392 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7393 remote_mds_nodsh && skip "remote MDS with nodsh" && return
7395 [[ $OSTCOUNT -lt 2 ]] && skip_env "$OSTCOUNT < 2 OSTs" && return
7397 echo -n "Free space priority "
7398 do_facet $SINGLEMDS lctl get_param -n lo*.*-mdtlov.qos_prio_free |
7403 [ $MINV -eq 0 ] && skip "no free space in OST$MINI, skip" && return
7404 [ $MINV -gt 10000000 ] && skip "too much free space in OST$MINI, skip" \
7406 trap simple_cleanup_common EXIT
7409 # Check if we need to generate uneven OSTs
7410 test_mkdir -p $DIR/$tdir/OST${MINI}
7411 local FILL=$(($MINV / 4))
7412 local DIFF=$(($MAXV - $MINV))
7413 local DIFF2=$(($DIFF * 100 / $MINV))
7415 local threshold=$(do_facet $SINGLEMDS \
7416 lctl get_param -n *.*MDT0000-mdtlov.qos_threshold_rr | head -n1)
7417 threshold=${threshold%%%}
7418 echo -n "Check for uneven OSTs: "
7419 echo -n "diff=${DIFF}KB (${DIFF2}%) must be > ${threshold}% ..."
7421 if [[ $DIFF2 -gt $threshold ]]; then
7423 echo "Don't need to fill OST$MINI"
7425 # generate uneven OSTs. Write 2% over the QOS threshold value
7427 DIFF=$(($threshold - $DIFF2 + 2))
7428 DIFF2=$(( ($MINV * $DIFF)/100 ))
7429 echo "Fill ${DIFF}% remaining space in OST${MINI} with ${DIFF2}KB"
7430 $SETSTRIPE -i $MINI -c 1 $DIR/$tdir/OST${MINI} ||
7431 error "setstripe failed"
7432 DIFF=$(($DIFF2 / 2048))
7434 while [ $i -lt $DIFF ]; do
7436 dd if=/dev/zero of=$DIR/$tdir/OST${MINI}/$tfile-$i \
7437 bs=2M count=1 2>/dev/null
7446 DIFF=$(($MAXV - $MINV))
7447 DIFF2=$(($DIFF * 100 / $MINV))
7448 echo -n "diff=${DIFF}=${DIFF2}% must be > ${threshold}% for QOS mode..."
7449 if [[ $DIFF2 -gt $threshold ]]; then
7452 echo "failed - QOS mode won't be used"
7453 skip "QOS imbalance criteria not met"
7454 simple_cleanup_common
7458 MINI1=$MINI; MINV1=$MINV
7459 MAXI1=$MAXI; MAXV1=$MAXV
7461 # now fill using QOS
7462 $SETSTRIPE -c 1 $DIR/$tdir
7463 FILL=$(($FILL / 200))
7464 if [ $FILL -gt 600 ]; then
7467 echo "writing $FILL files to QOS-assigned OSTs"
7469 while [ $i -lt $FILL ]; do
7471 dd if=/dev/zero of=$DIR/$tdir/$tfile-$i bs=200k \
7475 echo "wrote $i 200k files"
7479 echo "Note: free space may not be updated, so measurements might be off"
7481 DIFF2=$(($MAXV - $MINV))
7482 echo "free space delta: orig $DIFF final $DIFF2"
7483 [ $DIFF2 -gt $DIFF ] && echo "delta got worse!"
7484 DIFF=$(($MINV1 - ${AVAIL[$MINI1]}))
7485 echo "Wrote ${DIFF}KB to smaller OST $MINI1"
7486 DIFF2=$(($MAXV1 - ${AVAIL[$MAXI1]}))
7487 echo "Wrote ${DIFF2}KB to larger OST $MAXI1"
7488 FILL=$(($DIFF2 * 100 / $DIFF - 100))
7490 echo "Wrote ${FILL}% more data to larger OST $MAXI1"
7492 # Figure out which files were written where
7493 UUID=$(lctl get_param -n lov.${FSNAME}-clilov-*.target_obd |
7494 awk '/'$MINI1': / {print $2; exit}')
7496 MINC=$($GETSTRIPE --ost $UUID $DIR/$tdir | grep $DIR | wc -l)
7497 echo "$MINC files created on smaller OST $MINI1"
7498 UUID=$(lctl get_param -n lov.${FSNAME}-clilov-*.target_obd |
7499 awk '/'$MAXI1': / {print $2; exit}')
7501 MAXC=$($GETSTRIPE --ost $UUID $DIR/$tdir | grep $DIR | wc -l)
7502 echo "$MAXC files created on larger OST $MAXI1"
7503 FILL=$(($MAXC * 100 / $MINC - 100))
7504 [[ $MINC -gt 0 ]] &&
7505 echo "Wrote ${FILL}% more files to larger OST $MAXI1"
7506 [[ $MAXC -gt $MINC ]] ||
7507 error_ignore LU-9 "stripe QOS didn't balance free space"
7508 simple_cleanup_common
7510 run_test 116a "stripe QOS: free space balance ==================="
7512 test_116b() { # LU-2093
7513 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7514 remote_mds_nodsh && skip "remote MDS with nodsh" && return
7516 #define OBD_FAIL_MDS_OSC_CREATE_FAIL 0x147
7517 local old_rr=$(do_facet $SINGLEMDS lctl get_param -n \
7518 lo*.$FSNAME-MDT0000-mdtlov.qos_threshold_rr | head -1)
7519 [ -z "$old_rr" ] && skip "no QOS" && return 0
7520 do_facet $SINGLEMDS lctl set_param \
7521 lo*.$FSNAME-MDT0000-mdtlov.qos_threshold_rr=0
7523 do_facet $SINGLEMDS lctl set_param fail_loc=0x147
7524 createmany -o $DIR/$tdir/f- 20 || error "can't create"
7525 do_facet $SINGLEMDS lctl set_param fail_loc=0
7527 do_facet $SINGLEMDS lctl set_param \
7528 lo*.$FSNAME-MDT0000-mdtlov.qos_threshold_rr=$old_rr
7530 run_test 116b "QoS shouldn't LBUG if not enough OSTs found on the 2nd pass"
7532 test_117() # bug 10891
7534 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7535 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1
7536 #define OBD_FAIL_OST_SETATTR_CREDITS 0x21e
7537 lctl set_param fail_loc=0x21e
7538 > $DIR/$tfile || error "truncate failed"
7539 lctl set_param fail_loc=0
7540 echo "Truncate succeeded."
7543 run_test 117 "verify osd extend =========="
7545 NO_SLOW_RESENDCOUNT=4
7546 export OLD_RESENDCOUNT=""
7547 set_resend_count () {
7548 local PROC_RESENDCOUNT="osc.${FSNAME}-OST*-osc-*.resend_count"
7549 OLD_RESENDCOUNT=$(lctl get_param -n $PROC_RESENDCOUNT | head -n1)
7550 lctl set_param -n $PROC_RESENDCOUNT $1
7551 echo resend_count is set to $(lctl get_param -n $PROC_RESENDCOUNT)
7554 # for reduce test_118* time (b=14842)
7555 [ "$SLOW" = "no" ] && set_resend_count $NO_SLOW_RESENDCOUNT
7557 # Reset async IO behavior after error case
7559 FILE=$DIR/reset_async
7561 # Ensure all OSCs are cleared
7562 $SETSTRIPE -c -1 $FILE
7563 dd if=/dev/zero of=$FILE bs=64k count=$OSTCOUNT
7568 test_118a() #bug 11710
7570 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7573 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
7574 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
7575 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
7577 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
7578 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
7583 run_test 118a "verify O_SYNC works =========="
7587 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7588 remote_ost_nodsh && skip "remote OST with nodsh" && return
7592 #define OBD_FAIL_OST_ENOENT 0x217
7593 set_nodes_failloc "$(osts_nodes)" 0x217
7594 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
7596 set_nodes_failloc "$(osts_nodes)" 0
7597 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
7598 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
7601 if [[ $RC -eq 0 ]]; then
7602 error "Must return error due to dropped pages, rc=$RC"
7606 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
7607 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
7611 echo "Dirty pages not leaked on ENOENT"
7613 # Due to the above error the OSC will issue all RPCs syncronously
7614 # until a subsequent RPC completes successfully without error.
7615 $MULTIOP $DIR/$tfile Ow4096yc
7620 run_test 118b "Reclaim dirty pages on fatal error =========="
7624 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7626 # for 118c, restore the original resend count, LU-1940
7627 [ "$SLOW" = "no" ] && [ -n "$OLD_RESENDCOUNT" ] &&
7628 set_resend_count $OLD_RESENDCOUNT
7629 remote_ost_nodsh && skip "remote OST with nodsh" && return
7633 #define OBD_FAIL_OST_EROFS 0x216
7634 set_nodes_failloc "$(osts_nodes)" 0x216
7636 # multiop should block due to fsync until pages are written
7637 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
7641 if [[ `ps h -o comm -p $MULTIPID` != "multiop" ]]; then
7642 error "Multiop failed to block on fsync, pid=$MULTIPID"
7645 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
7647 if [[ $WRITEBACK -eq 0 ]]; then
7648 error "No page in writeback, writeback=$WRITEBACK"
7651 set_nodes_failloc "$(osts_nodes)" 0
7654 if [[ $RC -ne 0 ]]; then
7655 error "Multiop fsync failed, rc=$RC"
7658 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
7659 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
7661 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
7662 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
7666 echo "Dirty pages flushed via fsync on EROFS"
7669 run_test 118c "Fsync blocks on EROFS until dirty pages are flushed =========="
7671 # continue to use small resend count to reduce test_118* time (b=14842)
7672 [ "$SLOW" = "no" ] && set_resend_count $NO_SLOW_RESENDCOUNT
7676 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7677 remote_ost_nodsh && skip "remote OST with nodsh" && return
7681 #define OBD_FAIL_OST_BRW_PAUSE_BULK
7682 set_nodes_failloc "$(osts_nodes)" 0x214
7683 # multiop should block due to fsync until pages are written
7684 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
7688 if [[ `ps h -o comm -p $MULTIPID` != "multiop" ]]; then
7689 error "Multiop failed to block on fsync, pid=$MULTIPID"
7692 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
7694 if [[ $WRITEBACK -eq 0 ]]; then
7695 error "No page in writeback, writeback=$WRITEBACK"
7698 wait $MULTIPID || error "Multiop fsync failed, rc=$?"
7699 set_nodes_failloc "$(osts_nodes)" 0
7701 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
7702 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
7704 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
7705 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
7709 echo "Dirty pages gaurenteed flushed via fsync"
7712 run_test 118d "Fsync validation inject a delay of the bulk =========="
7715 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7718 #define OBD_FAIL_OSC_BRW_PREP_REQ2 0x40a
7719 lctl set_param fail_loc=0x8000040a
7721 # Should simulate EINVAL error which is fatal
7722 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
7724 if [[ $RC -eq 0 ]]; then
7725 error "Must return error due to dropped pages, rc=$RC"
7728 lctl set_param fail_loc=0x0
7730 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
7731 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
7732 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
7734 if [[ $LOCKED -ne 0 ]]; then
7735 error "Locked pages remain in cache, locked=$LOCKED"
7738 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
7739 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
7743 echo "No pages locked after fsync"
7748 run_test 118f "Simulate unrecoverable OSC side error =========="
7751 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7754 #define OBD_FAIL_OSC_BRW_PREP_REQ 0x406
7755 lctl set_param fail_loc=0x406
7757 # simulate local -ENOMEM
7758 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
7761 lctl set_param fail_loc=0
7762 if [[ $RC -eq 0 ]]; then
7763 error "Must return error due to dropped pages, rc=$RC"
7766 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
7767 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
7768 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
7770 if [[ $LOCKED -ne 0 ]]; then
7771 error "Locked pages remain in cache, locked=$LOCKED"
7774 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
7775 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
7779 echo "No pages locked after fsync"
7784 run_test 118g "Don't stay in wait if we got local -ENOMEM =========="
7787 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7788 remote_ost_nodsh && skip "remote OST with nodsh" && return
7792 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
7793 set_nodes_failloc "$(osts_nodes)" 0x20e
7794 # Should simulate ENOMEM error which is recoverable and should be handled by timeout
7795 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
7798 set_nodes_failloc "$(osts_nodes)" 0
7799 if [[ $RC -eq 0 ]]; then
7800 error "Must return error due to dropped pages, rc=$RC"
7803 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
7804 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
7805 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
7807 if [[ $LOCKED -ne 0 ]]; then
7808 error "Locked pages remain in cache, locked=$LOCKED"
7811 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
7812 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
7816 echo "No pages locked after fsync"
7820 run_test 118h "Verify timeout in handling recoverables errors =========="
7822 [ "$SLOW" = "no" ] && [ -n "$OLD_RESENDCOUNT" ] && set_resend_count $OLD_RESENDCOUNT
7825 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7826 remote_ost_nodsh && skip "remote OST with nodsh" && return
7830 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
7831 set_nodes_failloc "$(osts_nodes)" 0x20e
7833 # Should simulate ENOMEM error which is recoverable and should be handled by timeout
7834 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
7837 set_nodes_failloc "$(osts_nodes)" 0
7841 if [[ $RC -ne 0 ]]; then
7842 error "got error, but should be not, rc=$RC"
7845 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
7846 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
7847 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
7848 if [[ $LOCKED -ne 0 ]]; then
7849 error "Locked pages remain in cache, locked=$LOCKED"
7852 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
7853 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
7857 echo "No pages locked after fsync"
7861 run_test 118i "Fix error before timeout in recoverable error =========="
7863 [ "$SLOW" = "no" ] && set_resend_count 4
7866 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7867 remote_ost_nodsh && skip "remote OST with nodsh" && return
7871 #define OBD_FAIL_OST_BRW_WRITE_BULK2 0x220
7872 set_nodes_failloc "$(osts_nodes)" 0x220
7874 # return -EIO from OST
7875 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
7877 set_nodes_failloc "$(osts_nodes)" 0x0
7878 if [[ $RC -eq 0 ]]; then
7879 error "Must return error due to dropped pages, rc=$RC"
7882 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
7883 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
7884 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
7885 if [[ $LOCKED -ne 0 ]]; then
7886 error "Locked pages remain in cache, locked=$LOCKED"
7889 # in recoverable error on OST we want resend and stay until it finished
7890 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
7891 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
7895 echo "No pages locked after fsync"
7899 run_test 118j "Simulate unrecoverable OST side error =========="
7903 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7904 remote_ost_nodsh && skip "remote OSTs with nodsh" && return
7906 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
7907 set_nodes_failloc "$(osts_nodes)" 0x20e
7908 test_mkdir -p $DIR/$tdir
7910 for ((i=0;i<10;i++)); do
7911 (dd if=/dev/zero of=$DIR/$tdir/$tfile-$i bs=1M count=10 || \
7912 error "dd to $DIR/$tdir/$tfile-$i failed" )&
7919 set_nodes_failloc "$(osts_nodes)" 0
7922 run_test 118k "bio alloc -ENOMEM and IO TERM handling ========="
7926 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7928 test_mkdir -p $DIR/$tdir
7929 $MULTIOP $DIR/$tdir Dy || error "fsync dir failed"
7932 run_test 118l "fsync dir ========="
7934 test_118m() # LU-3066
7936 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7937 test_mkdir -p $DIR/$tdir
7938 $MULTIOP $DIR/$tdir DY || error "fdatasync dir failed"
7941 run_test 118m "fdatasync dir ========="
7943 [ "$SLOW" = "no" ] && [ -n "$OLD_RESENDCOUNT" ] && set_resend_count $OLD_RESENDCOUNT
7945 test_119a() # bug 11737
7947 BSIZE=$((512 * 1024))
7948 directio write $DIR/$tfile 0 1 $BSIZE
7949 # We ask to read two blocks, which is more than a file size.
7950 # directio will indicate an error when requested and actual
7951 # sizes aren't equeal (a normal situation in this case) and
7952 # print actual read amount.
7953 NOB=`directio read $DIR/$tfile 0 2 $BSIZE | awk '/error/ {print $6}'`
7954 if [ "$NOB" != "$BSIZE" ]; then
7955 error "read $NOB bytes instead of $BSIZE"
7959 run_test 119a "Short directIO read must return actual read amount"
7961 test_119b() # bug 11737
7963 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping 2-stripe test" && return
7965 $SETSTRIPE -c 2 $DIR/$tfile || error "setstripe failed"
7966 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=1 || error "dd failed"
7968 $MULTIOP $DIR/$tfile oO_RDONLY:O_DIRECT:r$((2048 * 1024)) || \
7969 error "direct read failed"
7972 run_test 119b "Sparse directIO read must return actual read amount"
7974 test_119c() # bug 13099
7977 directio write $DIR/$tfile 3 1 $BSIZE || error "direct write failed"
7978 directio readhole $DIR/$tfile 0 2 $BSIZE || error "reading hole failed"
7981 run_test 119c "Testing for direct read hitting hole"
7983 test_119d() # bug 15950
7985 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7986 MAX_RPCS_IN_FLIGHT=`$LCTL get_param -n osc.*OST0000-osc-[^mM]*.max_rpcs_in_flight`
7987 $LCTL set_param -n osc.*OST0000-osc-[^mM]*.max_rpcs_in_flight 1
7989 $SETSTRIPE $DIR/$tfile -i 0 -c 1 || error "setstripe failed"
7990 $DIRECTIO write $DIR/$tfile 0 1 $BSIZE || error "first directio failed"
7991 #define OBD_FAIL_OSC_DIO_PAUSE 0x40d
7992 lctl set_param fail_loc=0x40d
7993 $DIRECTIO write $DIR/$tfile 1 4 $BSIZE &
7996 cat $DIR/$tfile > /dev/null &
7997 lctl set_param fail_loc=0
8000 log "the DIO writes have completed, now wait for the reads (should not block very long)"
8002 [ -n "`ps h -p $pid_reads -o comm`" ] && \
8003 error "the read rpcs have not completed in 2s"
8005 $LCTL set_param -n osc.*OST0000-osc-[^mM]*.max_rpcs_in_flight $MAX_RPCS_IN_FLIGHT
8007 run_test 119d "The DIO path should try to send a new rpc once one is completed"
8010 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8011 test_mkdir -p $DIR/$tdir
8012 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
8013 skip "no early lock cancel on server" && return 0
8015 lru_resize_disable mdc
8016 lru_resize_disable osc
8017 cancel_lru_locks mdc
8018 # asynchronous object destroy at MDT could cause bl ast to client
8019 cancel_lru_locks osc
8021 stat $DIR/$tdir > /dev/null
8022 can1=$(do_facet $SINGLEMDS \
8023 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8024 awk '/ldlm_cancel/ {print $2}')
8025 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8026 awk '/ldlm_bl_callback/ {print $2}')
8027 test_mkdir -c1 $DIR/$tdir/d1
8028 can2=$(do_facet $SINGLEMDS \
8029 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8030 awk '/ldlm_cancel/ {print $2}')
8031 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8032 awk '/ldlm_bl_callback/ {print $2}')
8033 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
8034 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
8035 lru_resize_enable mdc
8036 lru_resize_enable osc
8038 run_test 120a "Early Lock Cancel: mkdir test"
8041 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8042 test_mkdir $DIR/$tdir
8043 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel)" ] && \
8044 skip "no early lock cancel on server" && return 0
8045 lru_resize_disable mdc
8046 lru_resize_disable osc
8047 cancel_lru_locks mdc
8048 stat $DIR/$tdir > /dev/null
8049 can1=$(do_facet $SINGLEMDS \
8050 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8051 awk '/ldlm_cancel/ {print $2}')
8052 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8053 awk '/ldlm_bl_callback/ {print $2}')
8055 can2=$(do_facet $SINGLEMDS \
8056 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8057 awk '/ldlm_cancel/ {print $2}')
8058 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8059 awk '/ldlm_bl_callback/ {print $2}')
8060 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
8061 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
8062 lru_resize_enable mdc
8063 lru_resize_enable osc
8065 run_test 120b "Early Lock Cancel: create test"
8068 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8069 test_mkdir -c1 $DIR/$tdir
8070 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel)" ] && \
8071 skip "no early lock cancel on server" && return 0
8072 lru_resize_disable mdc
8073 lru_resize_disable osc
8074 test_mkdir -p -c1 $DIR/$tdir/d1
8075 test_mkdir -p -c1 $DIR/$tdir/d2
8076 touch $DIR/$tdir/d1/f1
8077 cancel_lru_locks mdc
8078 stat $DIR/$tdir/d1 $DIR/$tdir/d2 $DIR/$tdir/d1/f1 > /dev/null
8079 can1=$(do_facet $SINGLEMDS \
8080 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8081 awk '/ldlm_cancel/ {print $2}')
8082 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8083 awk '/ldlm_bl_callback/ {print $2}')
8084 ln $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2
8085 can2=$(do_facet $SINGLEMDS \
8086 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8087 awk '/ldlm_cancel/ {print $2}')
8088 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8089 awk '/ldlm_bl_callback/ {print $2}')
8090 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
8091 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
8092 lru_resize_enable mdc
8093 lru_resize_enable osc
8095 run_test 120c "Early Lock Cancel: link test"
8098 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8099 test_mkdir -p -c1 $DIR/$tdir
8100 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel)" ] && \
8101 skip "no early lock cancel on server" && return 0
8102 lru_resize_disable mdc
8103 lru_resize_disable osc
8105 cancel_lru_locks mdc
8106 stat $DIR/$tdir > /dev/null
8107 can1=$(do_facet $SINGLEMDS \
8108 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8109 awk '/ldlm_cancel/ {print $2}')
8110 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8111 awk '/ldlm_bl_callback/ {print $2}')
8112 chmod a+x $DIR/$tdir
8113 can2=$(do_facet $SINGLEMDS \
8114 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8115 awk '/ldlm_cancel/ {print $2}')
8116 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8117 awk '/ldlm_bl_callback/ {print $2}')
8118 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
8119 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
8120 lru_resize_enable mdc
8121 lru_resize_enable osc
8123 run_test 120d "Early Lock Cancel: setattr test"
8126 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8127 test_mkdir -p -c1 $DIR/$tdir
8128 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
8129 skip "no early lock cancel on server" && return 0
8130 lru_resize_disable mdc
8131 lru_resize_disable osc
8132 dd if=/dev/zero of=$DIR/$tdir/f1 count=1
8133 cancel_lru_locks mdc
8134 cancel_lru_locks osc
8135 dd if=$DIR/$tdir/f1 of=/dev/null
8136 stat $DIR/$tdir $DIR/$tdir/f1 > /dev/null
8137 # XXX client can not do early lock cancel of OST lock
8138 # during unlink (LU-4206), so cancel osc lock now.
8139 cancel_lru_locks osc
8140 can1=$(do_facet $SINGLEMDS \
8141 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8142 awk '/ldlm_cancel/ {print $2}')
8143 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8144 awk '/ldlm_bl_callback/ {print $2}')
8145 unlink $DIR/$tdir/f1
8147 can2=$(do_facet $SINGLEMDS \
8148 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8149 awk '/ldlm_cancel/ {print $2}')
8150 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8151 awk '/ldlm_bl_callback/ {print $2}')
8152 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
8153 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
8154 lru_resize_enable mdc
8155 lru_resize_enable osc
8157 run_test 120e "Early Lock Cancel: unlink test"
8160 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8161 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
8162 skip "no early lock cancel on server" && return 0
8163 test_mkdir -p -c1 $DIR/$tdir
8164 lru_resize_disable mdc
8165 lru_resize_disable osc
8166 test_mkdir -p -c1 $DIR/$tdir/d1
8167 test_mkdir -p -c1 $DIR/$tdir/d2
8168 dd if=/dev/zero of=$DIR/$tdir/d1/f1 count=1
8169 dd if=/dev/zero of=$DIR/$tdir/d2/f2 count=1
8170 cancel_lru_locks mdc
8171 cancel_lru_locks osc
8172 dd if=$DIR/$tdir/d1/f1 of=/dev/null
8173 dd if=$DIR/$tdir/d2/f2 of=/dev/null
8174 stat $DIR/$tdir/d1 $DIR/$tdir/d2 $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2 > /dev/null
8175 # XXX client can not do early lock cancel of OST lock
8176 # during rename (LU-4206), so cancel osc lock now.
8177 cancel_lru_locks osc
8178 can1=$(do_facet $SINGLEMDS \
8179 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8180 awk '/ldlm_cancel/ {print $2}')
8181 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8182 awk '/ldlm_bl_callback/ {print $2}')
8183 mrename $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2
8185 can2=$(do_facet $SINGLEMDS \
8186 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8187 awk '/ldlm_cancel/ {print $2}')
8188 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8189 awk '/ldlm_bl_callback/ {print $2}')
8190 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
8191 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
8192 lru_resize_enable mdc
8193 lru_resize_enable osc
8195 run_test 120f "Early Lock Cancel: rename test"
8198 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8199 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
8200 skip "no early lock cancel on server" && return 0
8201 lru_resize_disable mdc
8202 lru_resize_disable osc
8204 echo create $count files
8205 test_mkdir -p $DIR/$tdir
8206 cancel_lru_locks mdc
8207 cancel_lru_locks osc
8210 can0=$(do_facet $SINGLEMDS \
8211 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8212 awk '/ldlm_cancel/ {print $2}')
8213 blk0=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8214 awk '/ldlm_bl_callback/ {print $2}')
8215 createmany -o $DIR/$tdir/f $count
8217 can1=$(do_facet $SINGLEMDS \
8218 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8219 awk '/ldlm_cancel/ {print $2}')
8220 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8221 awk '/ldlm_bl_callback/ {print $2}')
8223 echo total: $((can1-can0)) cancels, $((blk1-blk0)) blockings
8224 echo rm $count files
8227 can2=$(do_facet $SINGLEMDS \
8228 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8229 awk '/ldlm_cancel/ {print $2}')
8230 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8231 awk '/ldlm_bl_callback/ {print $2}')
8233 echo total: $count removes in $((t2-t1))
8234 echo total: $((can2-can1)) cancels, $((blk2-blk1)) blockings
8236 # wait for commitment of removal
8237 lru_resize_enable mdc
8238 lru_resize_enable osc
8240 run_test 120g "Early Lock Cancel: performance test"
8242 test_121() { #bug #10589
8243 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8245 writes=$(LANG=C dd if=/dev/zero of=$DIR/$tfile count=1 2>&1 | awk -F '+' '/out$/ {print $1}')
8246 #define OBD_FAIL_LDLM_CANCEL_RACE 0x310
8247 lctl set_param fail_loc=0x310
8248 cancel_lru_locks osc > /dev/null
8249 reads=$(LANG=C dd if=$DIR/$tfile of=/dev/null 2>&1 | awk -F '+' '/in$/ {print $1}')
8250 lctl set_param fail_loc=0
8251 [[ $reads -eq $writes ]] ||
8252 error "read $reads blocks, must be $writes blocks"
8254 run_test 121 "read cancel race ========="
8256 test_123a() { # was test 123, statahead(bug 11401)
8257 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8259 if [ -z "$(grep "processor.*: 1" /proc/cpuinfo)" ]; then
8260 log "testing on UP system. Performance may be not as good as expected."
8265 test_mkdir -p $DIR/$tdir
8266 NUMFREE=$(df -i -P $DIR | tail -n 1 | awk '{ print $4 }')
8267 [[ $NUMFREE -gt 100000 ]] && NUMFREE=100000 || NUMFREE=$((NUMFREE-1000))
8269 for ((i=100, j=0; i<=$NUMFREE; j=$i, i=$((i * MULT)) )); do
8270 createmany -o $DIR/$tdir/$tfile $j $((i - j))
8272 max=`lctl get_param -n llite.*.statahead_max | head -n 1`
8273 lctl set_param -n llite.*.statahead_max 0
8274 lctl get_param llite.*.statahead_max
8275 cancel_lru_locks mdc
8276 cancel_lru_locks osc
8278 time ls -l $DIR/$tdir | wc -l
8280 delta=$((etime - stime))
8281 log "ls $i files without statahead: $delta sec"
8282 lctl set_param llite.*.statahead_max=$max
8284 swrong=`lctl get_param -n llite.*.statahead_stats | grep "statahead wrong:" | awk '{print $3}'`
8285 lctl get_param -n llite.*.statahead_max | grep '[0-9]'
8286 cancel_lru_locks mdc
8287 cancel_lru_locks osc
8289 time ls -l $DIR/$tdir | wc -l
8291 delta_sa=$((etime - stime))
8292 log "ls $i files with statahead: $delta_sa sec"
8293 lctl get_param -n llite.*.statahead_stats
8294 ewrong=`lctl get_param -n llite.*.statahead_stats | grep "statahead wrong:" | awk '{print $3}'`
8296 [[ $swrong -lt $ewrong ]] &&
8297 log "statahead was stopped, maybe too many locks held!"
8298 [[ $delta -eq 0 || $delta_sa -eq 0 ]] && continue
8300 if [ $((delta_sa * 100)) -gt $((delta * 105)) -a $delta_sa -gt $((delta + 2)) ]; then
8301 max=`lctl get_param -n llite.*.statahead_max | head -n 1`
8302 lctl set_param -n llite.*.statahead_max 0
8303 lctl get_param llite.*.statahead_max
8304 cancel_lru_locks mdc
8305 cancel_lru_locks osc
8307 time ls -l $DIR/$tdir | wc -l
8309 delta=$((etime - stime))
8310 log "ls $i files again without statahead: $delta sec"
8311 lctl set_param llite.*.statahead_max=$max
8312 if [ $((delta_sa * 100)) -gt $((delta * 105)) -a $delta_sa -gt $((delta + 2)) ]; then
8313 if [ $SLOWOK -eq 0 ]; then
8314 error "ls $i files is slower with statahead!"
8316 log "ls $i files is slower with statahead!"
8322 [ $delta -gt 20 ] && break
8323 [ $delta -gt 8 ] && MULT=$((50 / delta))
8324 [ "$SLOW" = "no" -a $delta -gt 5 ] && break
8332 delta=$((etime - stime))
8333 log "rm -r $DIR/$tdir/: $delta seconds"
8335 lctl get_param -n llite.*.statahead_stats
8337 run_test 123a "verify statahead work"
8339 test_123b () { # statahead(bug 15027)
8340 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8341 test_mkdir -p $DIR/$tdir
8342 createmany -o $DIR/$tdir/$tfile-%d 1000
8344 cancel_lru_locks mdc
8345 cancel_lru_locks osc
8347 #define OBD_FAIL_MDC_GETATTR_ENQUEUE 0x803
8348 lctl set_param fail_loc=0x80000803
8349 ls -lR $DIR/$tdir > /dev/null
8351 lctl set_param fail_loc=0x0
8352 lctl get_param -n llite.*.statahead_stats
8357 run_test 123b "not panic with network error in statahead enqueue (bug 15027)"
8360 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8361 [ -z "$($LCTL get_param -n mdc.*.connect_flags | grep lru_resize)" ] &&
8362 skip "no lru resize on server" && return 0
8364 test_mkdir -p $DIR/$tdir || error "failed to create $DIR/$tdir"
8366 log "create $NR files at $DIR/$tdir"
8367 createmany -o $DIR/$tdir/f $NR ||
8368 error "failed to create $NR files in $DIR/$tdir"
8370 cancel_lru_locks mdc
8371 ls -l $DIR/$tdir > /dev/null
8375 for VALUE in $($LCTL get_param ldlm.namespaces.*mdc-*.lru_size); do
8376 local PARAM=$(echo ${VALUE[0]} | cut -d "=" -f1)
8377 LRU_SIZE=$($LCTL get_param -n $PARAM)
8378 if [[ $LRU_SIZE -gt $(default_lru_size) ]]; then
8379 NSDIR=$(echo $PARAM | cut -d "." -f1-3)
8381 log "NS=$(basename $NSDIR)"
8386 if [[ -z "$NSDIR" || $LRU_SIZE -lt $(default_lru_size) ]]; then
8387 skip "Not enough cached locks created!"
8394 # We know that lru resize allows one client to hold $LIMIT locks
8395 # for 10h. After that locks begin to be killed by client.
8397 local LIMIT=$($LCTL get_param -n $NSDIR.pool.limit)
8399 if [ $LIMIT -lt $LRU_SIZE ]; then
8400 skip "Limit is too small $LIMIT"
8404 # Make LVF so higher that sleeping for $SLEEP is enough to _start_
8405 # killing locks. Some time was spent for creating locks. This means
8406 # that up to the moment of sleep finish we must have killed some of
8407 # them (10-100 locks). This depends on how fast ther were created.
8408 # Many of them were touched in almost the same moment and thus will
8409 # be killed in groups.
8410 local LVF=$(($MAX_HRS * 60 * 60 / $SLEEP * $LIMIT / $LRU_SIZE))
8412 # Use $LRU_SIZE_B here to take into account real number of locks
8413 # created in the case of CMD, LRU_SIZE_B != $NR in most of cases
8414 local LRU_SIZE_B=$LRU_SIZE
8416 local OLD_LVF=$($LCTL get_param -n $NSDIR.pool.lock_volume_factor)
8417 log "OLD_LVF=$OLD_LVF"
8418 $LCTL set_param -n $NSDIR.pool.lock_volume_factor $LVF
8420 # Let's make sure that we really have some margin. Client checks
8421 # cached locks every 10 sec.
8423 log "Sleep ${SLEEP} sec"
8425 while ((SEC<$SLEEP)); do
8429 LRU_SIZE=$($LCTL get_param -n $NSDIR/lru_size)
8433 $LCTL set_param -n $NSDIR.pool.lock_volume_factor $OLD_LVF
8434 local LRU_SIZE_A=$($LCTL get_param -n $NSDIR.lru_size)
8436 [[ $LRU_SIZE_B -gt $LRU_SIZE_A ]] || {
8437 error "No locks dropped in ${SLEEP}s. LRU size: $LRU_SIZE_A"
8438 unlinkmany $DIR/$tdir/f $NR
8442 log "Dropped "$((LRU_SIZE_B-LRU_SIZE_A))" locks in ${SLEEP}s"
8443 log "unlink $NR files at $DIR/$tdir"
8444 unlinkmany $DIR/$tdir/f $NR
8446 run_test 124a "lru resize ======================================="
8448 get_max_pool_limit()
8450 local limit=$($LCTL get_param \
8451 -n ldlm.namespaces.*-MDT0000-mdc-*.pool.limit)
8454 if [[ $l -gt $max ]]; then
8462 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8463 [ -z "$($LCTL get_param -n mdc.*.connect_flags | grep lru_resize)" ] &&
8464 skip "no lru resize on server" && return 0
8466 LIMIT=$(get_max_pool_limit)
8468 NR=$(($(default_lru_size)*20))
8469 if [[ $NR -gt $LIMIT ]]; then
8470 log "Limit lock number by $LIMIT locks"
8473 lru_resize_disable mdc
8474 test_mkdir -p $DIR/$tdir/disable_lru_resize ||
8475 error "failed to create $DIR/$tdir/disable_lru_resize"
8477 createmany -o $DIR/$tdir/disable_lru_resize/f $NR
8478 log "doing ls -la $DIR/$tdir/disable_lru_resize 3 times"
8479 cancel_lru_locks mdc
8482 ls -la $DIR/$tdir/disable_lru_resize > /dev/null &
8485 ls -la $DIR/$tdir/disable_lru_resize > /dev/null &
8488 ls -la $DIR/$tdir/disable_lru_resize > /dev/null &
8492 nolruresize_delta=$((etime-stime))
8493 log "ls -la time: $nolruresize_delta seconds"
8494 log "lru_size = $(lctl get_param -n ldlm.namespaces.*mdc*.lru_size)"
8495 unlinkmany $DIR/$tdir/disable_lru_resize/f $NR
8497 lru_resize_enable mdc
8498 test_mkdir -p $DIR/$tdir/enable_lru_resize ||
8499 error "failed to create $DIR/$tdir/enable_lru_resize"
8501 createmany -o $DIR/$tdir/enable_lru_resize/f $NR
8502 log "doing ls -la $DIR/$tdir/enable_lru_resize 3 times"
8503 cancel_lru_locks mdc
8506 ls -la $DIR/$tdir/enable_lru_resize > /dev/null &
8509 ls -la $DIR/$tdir/enable_lru_resize > /dev/null &
8512 ls -la $DIR/$tdir/enable_lru_resize > /dev/null &
8516 lruresize_delta=$((etime-stime))
8517 log "ls -la time: $lruresize_delta seconds"
8518 log "lru_size = $(lctl get_param -n ldlm.namespaces.*mdc*.lru_size)"
8520 if [ $lruresize_delta -gt $nolruresize_delta ]; then
8521 log "ls -la is $(((lruresize_delta - $nolruresize_delta) * 100 / $nolruresize_delta))% slower with lru resize enabled"
8522 elif [ $nolruresize_delta -gt $lruresize_delta ]; then
8523 log "ls -la is $(((nolruresize_delta - $lruresize_delta) * 100 / $nolruresize_delta))% faster with lru resize enabled"
8525 log "lru resize performs the same with no lru resize"
8527 unlinkmany $DIR/$tdir/enable_lru_resize/f $NR
8529 run_test 124b "lru resize (performance test) ======================="
8532 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8533 [ -z "$($LCTL get_param -n mdc.*.connect_flags | grep lru_resize)" ] &&
8534 skip "no lru resize on server" && return 0
8536 # cache ununsed locks on client
8538 cancel_lru_locks mdc
8539 test_mkdir -p $DIR/$tdir || error "failed to create $DIR/$tdir"
8540 createmany -o $DIR/$tdir/f $nr ||
8541 error "failed to create $nr files in $DIR/$tdir"
8542 ls -l $DIR/$tdir > /dev/null
8544 local nsdir="ldlm.namespaces.*-MDT0000-mdc-*"
8545 local unused=$($LCTL get_param -n $nsdir.lock_unused_count)
8546 local max_age=$($LCTL get_param -n $nsdir.lru_max_age)
8547 local recalc_p=$($LCTL get_param -n $nsdir.pool.recalc_period)
8548 echo "unused=$unused, max_age=$max_age, recalc_p=$recalc_p"
8550 # set lru_max_age to 1 sec
8551 $LCTL set_param $nsdir.lru_max_age=1000 # jiffies
8552 echo "sleep $((recalc_p * 2)) seconds..."
8553 sleep $((recalc_p * 2))
8555 local remaining=$($LCTL get_param -n $nsdir.lock_unused_count)
8556 # restore lru_max_age
8557 $LCTL set_param -n $nsdir.lru_max_age $max_age
8558 [ $remaining -eq 0 ] || error "$remaining locks are not canceled"
8559 unlinkmany $DIR/$tdir/f $nr
8561 run_test 124c "LRUR cancel very aged locks"
8563 test_125() { # 13358
8564 [ -z "$(lctl get_param -n llite.*.client_type | grep local)" ] && skip "must run as local client" && return
8565 [ -z "$(lctl get_param -n mdc.*-mdc-*.connect_flags | grep acl)" ] && skip "must have acl enabled" && return
8566 [ -z "$(which setfacl)" ] && skip "must have setfacl tool" && return
8567 test_mkdir -p $DIR/d125 || error "mkdir failed"
8568 $SETSTRIPE -S 65536 -c -1 $DIR/d125 || error "setstripe failed"
8569 setfacl -R -m u:bin:rwx $DIR/d125 || error "setfacl $DIR/d125 failed"
8570 ls -ld $DIR/d125 || error "cannot access $DIR/d125"
8572 run_test 125 "don't return EPROTO when a dir has a non-default striping and ACLs"
8574 test_126() { # bug 12829/13455
8575 [ -z "$(lctl get_param -n llite.*.client_type | grep local)" ] && skip "must run as local client" && return
8576 [ "$UID" != 0 ] && skip_env "skipping $TESTNAME (must run as root)" && return
8577 $GSS && skip "must run as gss disabled" && return
8579 $RUNAS -u 0 -g 1 touch $DIR/$tfile || error "touch failed"
8580 gid=`ls -n $DIR/$tfile | awk '{print $4}'`
8582 [ $gid -eq "1" ] || error "gid is set to" $gid "instead of 1"
8584 run_test 126 "check that the fsgid provided by the client is taken into account"
8586 test_127a() { # bug 15521
8587 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8588 $SETSTRIPE -i 0 -c 1 $DIR/$tfile || error "setstripe failed"
8589 $LCTL set_param osc.*.stats=0
8590 FSIZE=$((2048 * 1024))
8591 dd if=/dev/zero of=$DIR/$tfile bs=$FSIZE count=1
8592 cancel_lru_locks osc
8593 dd if=$DIR/$tfile of=/dev/null bs=$FSIZE
8595 $LCTL get_param osc.*0000-osc-*.stats | grep samples > $DIR/${tfile}.tmp
8596 while read NAME COUNT SAMP UNIT MIN MAX SUM SUMSQ; do
8597 echo "got $COUNT $NAME"
8598 [ ! $MIN ] && error "Missing min value for $NAME proc entry"
8599 eval $NAME=$COUNT || error "Wrong proc format"
8602 read_bytes|write_bytes)
8603 [ $MIN -lt 4096 ] && error "min is too small: $MIN"
8604 [ $MIN -gt $FSIZE ] && error "min is too big: $MIN"
8605 [ $MAX -lt 4096 ] && error "max is too small: $MAX"
8606 [ $MAX -gt $FSIZE ] && error "max is too big: $MAX"
8607 [ $SUM -ne $FSIZE ] && error "sum is wrong: $SUM"
8608 [ $SUMSQ -lt $(((FSIZE /4096) * (4096 * 4096))) ] &&
8609 error "sumsquare is too small: $SUMSQ"
8610 [ $SUMSQ -gt $((FSIZE * FSIZE)) ] &&
8611 error "sumsquare is too big: $SUMSQ"
8615 done < $DIR/${tfile}.tmp
8617 #check that we actually got some stats
8618 [ "$read_bytes" ] || error "Missing read_bytes stats"
8619 [ "$write_bytes" ] || error "Missing write_bytes stats"
8620 [ "$read_bytes" != 0 ] || error "no read done"
8621 [ "$write_bytes" != 0 ] || error "no write done"
8623 run_test 127a "verify the client stats are sane"
8625 test_127b() { # bug LU-333
8626 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8627 $LCTL set_param llite.*.stats=0
8628 FSIZE=65536 # sized fixed to match PAGE_SIZE for most clients
8629 # perform 2 reads and writes so MAX is different from SUM.
8630 dd if=/dev/zero of=$DIR/$tfile bs=$FSIZE count=1
8631 dd if=/dev/zero of=$DIR/$tfile bs=$FSIZE count=1
8632 cancel_lru_locks osc
8633 dd if=$DIR/$tfile of=/dev/null bs=$FSIZE count=1
8634 dd if=$DIR/$tfile of=/dev/null bs=$FSIZE count=1
8636 $LCTL get_param llite.*.stats | grep samples > $TMP/${tfile}.tmp
8637 while read NAME COUNT SAMP UNIT MIN MAX SUM SUMSQ; do
8638 echo "got $COUNT $NAME"
8639 eval $NAME=$COUNT || error "Wrong proc format"
8643 [ $COUNT -ne 2 ] && error "count is not 2: $COUNT"
8644 [ $MIN -ne $FSIZE ] && error "min is not $FSIZE: $MIN"
8645 [ $MAX -ne $FSIZE ] && error "max is incorrect: $MAX"
8646 [ $SUM -ne $((FSIZE * 2)) ] && error "sum is wrong: $SUM"
8649 [ $COUNT -ne 2 ] && error "count is not 2: $COUNT"
8650 [ $MIN -ne $FSIZE ] && error "min is not $FSIZE: $MIN"
8651 [ $MAX -ne $FSIZE ] && error "max is incorrect: $MAX"
8652 [ $SUM -ne $((FSIZE * 2)) ] && error "sum is wrong: $SUM"
8656 done < $TMP/${tfile}.tmp
8658 #check that we actually got some stats
8659 [ "$read_bytes" ] || error "Missing read_bytes stats"
8660 [ "$write_bytes" ] || error "Missing write_bytes stats"
8661 [ "$read_bytes" != 0 ] || error "no read done"
8662 [ "$write_bytes" != 0 ] || error "no write done"
8664 run_test 127b "verify the llite client stats are sane"
8666 test_128() { # bug 15212
8668 $LFS 2>&1 <<-EOF | tee $TMP/$tfile.log
8673 result=$(grep error $TMP/$tfile.log)
8675 [ -z "$result" ] || error "consecutive find's under interactive lfs failed"
8677 run_test 128 "interactive lfs for 2 consecutive find's"
8684 local LDPROC=/proc/fs/ldiskfs
8685 local facets=$(get_facets MDS)
8687 for facet in ${facets//,/ }; do
8688 canondev=$(ldiskfs_canon \
8689 *.$(convert_facet2label $facet).mntdev $facet)
8690 do_facet $facet "test -e $LDPROC/$canondev/max_dir_size" ||
8691 LDPROC=/sys/fs/ldiskfs
8692 do_facet $facet "echo $1 >$LDPROC/$canondev/max_dir_size"
8697 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8698 if [ "$(facet_fstype $SINGLEMDS)" != ldiskfs ]; then
8699 skip "Only applicable to ldiskfs-based MDTs"
8702 remote_mds_nodsh && skip "remote MDS with nodsh" && return
8707 test_mkdir -p $DIR/$tdir
8709 # block size of mds1
8710 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
8711 local MDSBLOCKSIZE=$($LCTL get_param -n mdc.*MDT0000*.blocksize)
8712 local MAX=$((MDSBLOCKSIZE * 3))
8714 local I=$(stat -c%s "$DIR/$tdir")
8716 local STRIPE_COUNT=1
8717 [[ $MDSCOUNT -ge 2 ]] && STRIPE_COUNT=$($LFS getdirstripe -c $DIR/$tdir)
8718 MAX=$((MAX*STRIPE_COUNT))
8719 while [[ $I -le $MAX ]]; do
8720 $MULTIOP $DIR/$tdir/$J Oc
8722 #check two errors ENOSPC for new version of ext4 max_dir_size patch
8723 #mainline kernel commit df981d03eeff7971ac7e6ff37000bfa702327ef1
8724 #and EFBIG for previous versions
8725 if [ $rc -eq $EFBIG -o $rc -eq $ENOSPC ]; then
8727 echo "return code $rc received as expected"
8728 multiop $DIR/$tdir/$J Oc ||
8729 error_exit "multiop failed w/o dir size limit"
8731 I=$(stat -c%s "$DIR/$tdir")
8733 if [ $(lustre_version_code $SINGLEMDS) -lt \
8734 $(version_code 2.4.51) ]
8736 [[ $I -eq $MAX ]] && return 0
8738 [[ $I -gt $MAX ]] && return 0
8740 error_exit "current dir size $I, previous limit $MAX"
8741 elif [ $rc -ne 0 ]; then
8743 error_exit "return code $rc received instead of expected " \
8744 "$EFBIG or $ENOSPC, files in dir $I"
8747 I=$(stat -c%s "$DIR/$tdir")
8751 error "exceeded dir size limit $MAX($MDSCOUNT) : $I bytes"
8753 run_test 129 "test directory size limit ========================"
8762 local filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
8763 [ -n "$filefrag_op" ] && skip_env "filefrag does not support FIEMAP" &&
8766 trap cleanup_130 EXIT RETURN
8768 local fm_file=$DIR/$tfile
8769 $SETSTRIPE -S 65536 -c 1 $fm_file || error "setstripe on $fm_file"
8770 dd if=/dev/zero of=$fm_file bs=65536 count=1 ||
8771 error "dd failed for $fm_file"
8773 # LU-1795: test filefrag/FIEMAP once, even if unsupported
8774 filefrag -ves $fm_file
8776 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
8777 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
8778 [ $RC != 0 ] && error "filefrag $fm_file failed"
8780 filefrag_op=$(filefrag -ve $fm_file | grep -A 100 "ext:" |
8781 grep -v "ext:" | grep -v "found")
8782 lun=$($GETSTRIPE -i $fm_file)
8784 start_blk=`echo $filefrag_op | cut -d: -f2 | cut -d. -f1`
8787 for line in $filefrag_op
8789 frag_lun=`echo $line | cut -d: -f5`
8790 ext_len=`echo $line | cut -d: -f4`
8791 if (( $frag_lun != $lun )); then
8793 error "FIEMAP on 1-stripe file($fm_file) failed"
8796 (( tot_len += ext_len ))
8799 if (( lun != frag_lun || start_blk != 0 || tot_len != 64 )); then
8801 error "FIEMAP on 1-stripe file($fm_file) failed;"
8807 echo "FIEMAP on single striped file succeeded"
8809 run_test 130a "FIEMAP (1-stripe file)"
8812 [ "$OSTCOUNT" -lt "2" ] &&
8813 skip_env "skipping FIEMAP on 2-stripe file test" && return
8815 [ "$OSTCOUNT" -ge "10" ] &&
8816 skip_env "skipping FIEMAP with >= 10 OSTs" && return
8818 local filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
8819 [ -n "$filefrag_op" ] && skip_env "filefrag does not support FIEMAP" &&
8822 trap cleanup_130 EXIT RETURN
8824 local fm_file=$DIR/$tfile
8825 $SETSTRIPE -S 65536 -c 2 $fm_file || error "setstripe on $fm_file"
8826 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
8827 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
8829 dd if=/dev/zero of=$fm_file bs=1M count=2 ||
8830 error "dd failed on $fm_file"
8832 filefrag -ves $fm_file || error "filefrag $fm_file failed"
8833 filefrag_op=$(filefrag -ve $fm_file | grep -A 100 "ext:" |
8834 grep -v "ext:" | grep -v "found")
8836 last_lun=$(echo $filefrag_op | cut -d: -f5)
8841 for line in $filefrag_op
8843 frag_lun=`echo $line | cut -d: -f5`
8844 ext_len=`echo $line | cut -d: -f4`
8845 if (( $frag_lun != $last_lun )); then
8846 if (( tot_len != 1024 )); then
8848 error "FIEMAP on $fm_file failed; returned len $tot_len for OST $last_lun instead of 256"
8855 (( tot_len += ext_len ))
8858 if (( num_luns != 2 || tot_len != 1024 )); then
8860 error "FIEMAP on $fm_file failed; returned wrong number of luns or wrong len for OST $last_lun"
8866 echo "FIEMAP on 2-stripe file succeeded"
8868 run_test 130b "FIEMAP (2-stripe file)"
8871 [ "$OSTCOUNT" -lt "2" ] &&
8872 skip_env "skipping FIEMAP on 2-stripe file" && return
8874 [ "$OSTCOUNT" -ge "10" ] &&
8875 skip_env "skipping FIEMAP with >= 10 OSTs" && return
8877 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
8878 [ -n "$filefrag_op" ] && skip "filefrag does not support FIEMAP" &&
8881 trap cleanup_130 EXIT RETURN
8883 local fm_file=$DIR/$tfile
8884 $SETSTRIPE -S 65536 -c 2 $fm_file || error "setstripe on $fm_file"
8885 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
8886 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
8888 dd if=/dev/zero of=$fm_file seek=1 bs=1M count=1 || error "dd failed on $fm_file"
8890 filefrag -ves $fm_file || error "filefrag $fm_file failed"
8891 filefrag_op=`filefrag -ve $fm_file | grep -A 100 "ext:" | grep -v "ext:" | grep -v "found"`
8893 last_lun=`echo $filefrag_op | cut -d: -f5`
8898 for line in $filefrag_op
8900 frag_lun=`echo $line | cut -d: -f5`
8901 ext_len=`echo $line | cut -d: -f4`
8902 if (( $frag_lun != $last_lun )); then
8903 logical=`echo $line | cut -d: -f2 | cut -d. -f1`
8904 if (( logical != 512 )); then
8906 error "FIEMAP on $fm_file failed; returned logical start for lun $logical instead of 512"
8909 if (( tot_len != 512 )); then
8911 error "FIEMAP on $fm_file failed; returned len $tot_len for OST $last_lun instead of 1024"
8918 (( tot_len += ext_len ))
8921 if (( num_luns != 2 || tot_len != 512 )); then
8923 error "FIEMAP on $fm_file failed; returned wrong number of luns or wrong len for OST $last_lun"
8929 echo "FIEMAP on 2-stripe file with hole succeeded"
8931 run_test 130c "FIEMAP (2-stripe file with hole)"
8934 [ "$OSTCOUNT" -lt "3" ] && skip_env "skipping FIEMAP on N-stripe file test" && return
8936 [ "$OSTCOUNT" -ge "10" ] &&
8937 skip_env "skipping FIEMAP with >= 10 OSTs" && return
8939 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
8940 [ -n "$filefrag_op" ] && skip "filefrag does not support FIEMAP" && return
8942 trap cleanup_130 EXIT RETURN
8944 local fm_file=$DIR/$tfile
8945 $SETSTRIPE -S 65536 -c $OSTCOUNT $fm_file||error "setstripe on $fm_file"
8946 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
8947 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
8949 local actual_stripecnt=$($GETSTRIPE -c $fm_file)
8950 dd if=/dev/zero of=$fm_file bs=1M count=$actual_stripecnt ||
8951 error "dd failed on $fm_file"
8953 filefrag -ves $fm_file || error "filefrag $fm_file failed"
8954 filefrag_op=`filefrag -ve $fm_file | grep -A 100 "ext:" |
8955 grep -v "ext:" | grep -v "found"`
8957 last_lun=`echo $filefrag_op | cut -d: -f5`
8962 for line in $filefrag_op
8964 frag_lun=`echo $line | cut -d: -f5`
8965 ext_len=`echo $line | cut -d: -f4`
8966 if (( $frag_lun != $last_lun )); then
8967 if (( tot_len != 1024 )); then
8969 error "FIEMAP on $fm_file failed; returned len $tot_len for OST $last_lun instead of 1024"
8976 (( tot_len += ext_len ))
8979 if (( num_luns != actual_stripecnt || tot_len != 1024 )); then
8981 error "FIEMAP on $fm_file failed; returned wrong number of luns or wrong len for OST $last_lun"
8987 echo "FIEMAP on N-stripe file succeeded"
8989 run_test 130d "FIEMAP (N-stripe file)"
8992 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping continuation FIEMAP test" && return
8994 [ "$OSTCOUNT" -ge "10" ] &&
8995 skip_env "skipping FIEMAP with >= 10 OSTs" && return
8997 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
8998 [ -n "$filefrag_op" ] && skip "filefrag does not support FIEMAP" && return
9000 trap cleanup_130 EXIT RETURN
9002 local fm_file=$DIR/$tfile
9003 $SETSTRIPE -S 131072 -c 2 $fm_file || error "setstripe on $fm_file"
9004 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
9005 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
9008 EXPECTED_LEN=$(( (NUM_BLKS / 2) * 64 ))
9009 for ((i = 0; i < $NUM_BLKS; i++))
9011 dd if=/dev/zero of=$fm_file count=1 bs=64k seek=$((2*$i)) conv=notrunc > /dev/null 2>&1
9014 filefrag -ves $fm_file || error "filefrag $fm_file failed"
9015 filefrag_op=`filefrag -ve $fm_file | grep -A 12000 "ext:" | grep -v "ext:" | grep -v "found"`
9017 last_lun=`echo $filefrag_op | cut -d: -f5`
9022 for line in $filefrag_op
9024 frag_lun=`echo $line | cut -d: -f5`
9025 ext_len=`echo $line | cut -d: -f4`
9026 if (( $frag_lun != $last_lun )); then
9027 if (( tot_len != $EXPECTED_LEN )); then
9029 error "FIEMAP on $fm_file failed; returned len $tot_len for OST $last_lun instead of $EXPECTED_LEN"
9036 (( tot_len += ext_len ))
9039 if (( num_luns != 2 || tot_len != $EXPECTED_LEN )); then
9041 error "FIEMAP on $fm_file failed; returned wrong number of luns or wrong len for OST $last_lun"
9047 echo "FIEMAP with continuation calls succeeded"
9049 run_test 130e "FIEMAP (test continuation FIEMAP calls)"
9051 # Test for writev/readv
9053 rwv -f $DIR/$tfile -w -n 3 524288 1048576 1572864 || \
9054 error "writev test failed"
9055 rwv -f $DIR/$tfile -r -v -n 2 1572864 1048576 || \
9056 error "readv failed"
9059 run_test 131a "test iov's crossing stripe boundary for writev/readv"
9062 rwv -f $DIR/$tfile -w -a -n 3 524288 1048576 1572864 || \
9063 error "append writev test failed"
9064 rwv -f $DIR/$tfile -w -a -n 2 1572864 1048576 || \
9065 error "append writev test failed"
9068 run_test 131b "test append writev"
9071 rwv -f $DIR/$tfile -w -d -n 1 1048576 || return 0
9074 run_test 131c "test read/write on file w/o objects"
9077 rwv -f $DIR/$tfile -w -n 1 1572864
9078 NOB=`rwv -f $DIR/$tfile -r -n 3 524288 524288 1048576 | awk '/error/ {print $6}'`
9079 if [ "$NOB" != 1572864 ]; then
9080 error "Short read filed: read $NOB bytes instead of 1572864"
9084 run_test 131d "test short read"
9087 rwv -f $DIR/$tfile -w -s 1048576 -n 1 1048576
9088 rwv -f $DIR/$tfile -r -z -s 0 -n 1 524288 || \
9089 error "read hitting hole failed"
9092 run_test 131e "test read hitting hole"
9098 $SINGLEMDS) res=`do_facet $SINGLEMDS $LCTL get_param mdt.$FSNAME-MDT0000.md_stats | grep "$2"`
9100 ost) res=`do_facet ost1 $LCTL get_param obdfilter.$FSNAME-OST0000.stats | grep "$2"`
9102 *) error "Wrong argument $1" ;;
9105 [ -z "$res" ] && error "The counter for $2 on $1 was not incremented"
9106 # if the argument $3 is zero, it means any stat increment is ok.
9107 if [[ $3 -gt 0 ]]; then
9108 count=$(echo $res | awk '{ print $2 }')
9109 [[ $count -ne $3 ]] &&
9110 error "The $2 counter on $1 is wrong - expected $3"
9115 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9116 remote_ost_nodsh && skip "remote OST with nodsh" && return
9117 remote_mds_nodsh && skip "remote MDS with nodsh" && return
9119 do_facet $SINGLEMDS $LCTL list_param mdt.*.rename_stats ||
9120 { skip "MDS doesn't support rename stats"; return; }
9121 local testdir=$DIR/${tdir}/stats_testdir
9122 mkdir -p $DIR/${tdir}
9125 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
9126 do_facet ost1 $LCTL set_param obdfilter.*.stats=clear
9128 # verify mdt stats first.
9129 mkdir ${testdir} || error "mkdir failed"
9130 check_stats $SINGLEMDS "mkdir" 1
9131 touch ${testdir}/${tfile} || "touch failed"
9132 check_stats $SINGLEMDS "open" 1
9133 check_stats $SINGLEMDS "close" 1
9134 mknod ${testdir}/${tfile}-pipe p || "mknod failed"
9135 check_stats $SINGLEMDS "mknod" 1
9136 rm -f ${testdir}/${tfile}-pipe || "pipe remove failed"
9137 check_stats $SINGLEMDS "unlink" 1
9138 rm -f ${testdir}/${tfile} || error "file remove failed"
9139 check_stats $SINGLEMDS "unlink" 2
9141 # remove working dir and check mdt stats again.
9142 rmdir ${testdir} || error "rmdir failed"
9143 check_stats $SINGLEMDS "rmdir" 1
9145 local testdir1=$DIR/${tdir}/stats_testdir1
9147 mkdir -p ${testdir1}
9148 touch ${testdir1}/test1
9149 mv ${testdir1}/test1 ${testdir} || error "file crossdir rename"
9150 check_stats $SINGLEMDS "crossdir_rename" 1
9152 mv ${testdir}/test1 ${testdir}/test0 || error "file samedir rename"
9153 check_stats $SINGLEMDS "samedir_rename" 1
9157 run_test 133a "Verifying MDT stats ========================================"
9160 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9161 remote_ost_nodsh && skip "remote OST with nodsh" && return
9162 remote_mds_nodsh && skip "remote MDS with nodsh" && return
9163 local testdir=$DIR/${tdir}/stats_testdir
9164 mkdir -p ${testdir} || error "mkdir failed"
9165 touch ${testdir}/${tfile} || "touch failed"
9166 cancel_lru_locks mdc
9169 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
9170 do_facet ost1 $LCTL set_param obdfilter.*.stats=clear
9172 # extra mdt stats verification.
9173 chmod 444 ${testdir}/${tfile} || error "chmod failed"
9174 check_stats $SINGLEMDS "setattr" 1
9175 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
9176 if [ $(lustre_version_code $SINGLEMDS) -ne $(version_code 2.2.0) ]
9178 ls -l ${testdir}/${tfile} > /dev/null|| error "ls failed"
9179 check_stats $SINGLEMDS "getattr" 1
9181 $LFS df || error "lfs failed"
9182 check_stats $SINGLEMDS "statfs" 1
9186 run_test 133b "Verifying extra MDT stats =================================="
9189 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9190 remote_ost_nodsh && skip "remote OST with nodsh" && return
9191 remote_mds_nodsh && skip "remote MDS with nodsh" && return
9192 local testdir=$DIR/${tdir}/stats_testdir
9193 test_mkdir -p ${testdir} || error "mkdir failed"
9195 # verify obdfilter stats.
9196 $SETSTRIPE -c 1 -i 0 ${testdir}/${tfile}
9198 cancel_lru_locks osc
9199 wait_delete_completed
9202 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
9203 do_facet ost1 $LCTL set_param obdfilter.*.stats=clear
9205 dd if=/dev/zero of=${testdir}/${tfile} conv=notrunc bs=512k count=1 || error "dd failed"
9207 cancel_lru_locks osc
9208 check_stats ost "write" 1
9210 dd if=${testdir}/${tfile} of=/dev/null bs=1k count=1 || error "dd failed"
9211 check_stats ost "read" 1
9213 > ${testdir}/${tfile} || error "truncate failed"
9214 check_stats ost "punch" 1
9216 rm -f ${testdir}/${tfile} || error "file remove failed"
9217 wait_delete_completed
9218 check_stats ost "destroy" 1
9222 run_test 133c "Verifying OST stats ========================================"
9229 while [ $value -ge 2 ]; do
9234 if [ $orig -gt $order ]; then
9242 local size=('K' 'M' 'G' 'T');
9244 local size_string=$value
9246 while [ $value -ge 1024 ]; do
9247 if [ $i -gt 3 ]; then
9248 #T is the biggest unit we get here, if that is bigger,
9250 size_string=${value}T
9253 value=$((value >> 10))
9254 if [ $value -lt 1024 ]; then
9255 size_string=${value}${size[$i]}
9266 local context=${2:-.}
9267 local sample=$(do_facet $SINGLEMDS $LCTL get_param mdt.*.rename_stats |
9269 awk '/ '${size}'/ {print $4}' | sed -e "s/,//g")
9274 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9275 remote_ost_nodsh && skip "remote OST with nodsh" && return
9276 remote_mds_nodsh && skip "remote MDS with nodsh" && return
9277 do_facet $SINGLEMDS $LCTL list_param mdt.*.rename_stats ||
9278 { skip "MDS doesn't support rename stats"; return; }
9280 local testdir1=$DIR/${tdir}/stats_testdir1
9281 local testdir2=$DIR/${tdir}/stats_testdir2
9283 do_facet $SINGLEMDS $LCTL set_param mdt.*.rename_stats=clear
9285 mkdir -p ${testdir1} || error "mkdir failed"
9286 mkdir -p ${testdir2} || error "mkdir failed"
9288 createmany -o $testdir1/test 512 || error "createmany failed"
9290 # check samedir rename size
9291 mv ${testdir1}/test0 ${testdir1}/test_0
9293 local testdir1_size=$(ls -l $DIR/${tdir} |
9294 awk '/stats_testdir1/ {print $5}')
9295 local testdir2_size=$(ls -l $DIR/${tdir} |
9296 awk '/stats_testdir2/ {print $5}')
9298 testdir1_size=$(order_2 $testdir1_size)
9299 testdir2_size=$(order_2 $testdir2_size)
9301 testdir1_size=$(size_in_KMGT $testdir1_size)
9302 testdir2_size=$(size_in_KMGT $testdir2_size)
9304 echo "source rename dir size: ${testdir1_size}"
9305 echo "target rename dir size: ${testdir2_size}"
9307 local cmd="do_facet $SINGLEMDS $LCTL get_param mdt.*.rename_stats"
9308 eval $cmd || error "$cmd failed"
9309 local samedir=$($cmd | grep 'same_dir')
9310 local same_sample=$(get_rename_size $testdir1_size)
9311 [ -z "$samedir" ] && error "samedir_rename_size count error"
9312 [[ $same_sample -eq 1 ]] ||
9313 error "samedir_rename_size error $same_sample"
9314 echo "Check same dir rename stats success"
9316 do_facet $SINGLEMDS $LCTL set_param mdt.*.rename_stats=clear
9318 # check crossdir rename size
9319 mv ${testdir1}/test_0 ${testdir2}/test_0
9321 testdir1_size=$(ls -l $DIR/${tdir} |
9322 awk '/stats_testdir1/ {print $5}')
9323 testdir2_size=$(ls -l $DIR/${tdir} |
9324 awk '/stats_testdir2/ {print $5}')
9326 testdir1_size=$(order_2 $testdir1_size)
9327 testdir2_size=$(order_2 $testdir2_size)
9329 testdir1_size=$(size_in_KMGT $testdir1_size)
9330 testdir2_size=$(size_in_KMGT $testdir2_size)
9332 echo "source rename dir size: ${testdir1_size}"
9333 echo "target rename dir size: ${testdir2_size}"
9335 eval $cmd || error "$cmd failed"
9336 local crossdir=$($cmd | grep 'crossdir')
9337 local src_sample=$(get_rename_size $testdir1_size crossdir_src)
9338 local tgt_sample=$(get_rename_size $testdir2_size crossdir_tgt)
9339 [ -z "$crossdir" ] && error "crossdir_rename_size count error"
9340 [[ $src_sample -eq 1 ]] ||
9341 error "crossdir_rename_size error $src_sample"
9342 [[ $tgt_sample -eq 1 ]] ||
9343 error "crossdir_rename_size error $tgt_sample"
9344 echo "Check cross dir rename stats success"
9347 run_test 133d "Verifying rename_stats ========================================"
9350 remote_mds_nodsh && skip "remote MDS with nodsh" && return
9351 remote_ost_nodsh && skip "remote OST with nodsh" && return
9352 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9353 local testdir=$DIR/${tdir}/stats_testdir
9354 local ctr f0 f1 bs=32768 count=42 sum
9356 mkdir -p ${testdir} || error "mkdir failed"
9358 $SETSTRIPE -c 1 -i 0 ${testdir}/${tfile}
9360 for ctr in {write,read}_bytes; do
9362 cancel_lru_locks osc
9364 do_facet ost1 $LCTL set_param -n \
9365 "obdfilter.*.exports.clear=clear"
9367 if [ $ctr = write_bytes ]; then
9369 f1=${testdir}/${tfile}
9371 f0=${testdir}/${tfile}
9375 dd if=$f0 of=$f1 conv=notrunc bs=$bs count=$count || \
9378 cancel_lru_locks osc
9380 sum=$(do_facet ost1 $LCTL get_param \
9381 "obdfilter.*.exports.*.stats" |
9382 awk -v ctr=$ctr 'BEGIN { sum = 0 }
9383 $1 == ctr { sum += $7 }
9384 END { printf("%0.0f", sum) }')
9386 if ((sum != bs * count)); then
9387 error "Bad $ctr sum, expected $((bs * count)), got $sum"
9393 run_test 133e "Verifying OST {read,write}_bytes nid stats ================="
9398 local dirs="/proc/fs/lustre/ /proc/sys/lnet/ /proc/sys/lustre/ \
9399 /sys/fs/lustre/ /sys/fs/lnet/"
9401 for dir in $dirs; do
9402 if [ -d $dir ]; then
9403 proc_dirs="$proc_dirs $dir"
9409 remote_mds_nodsh && skip "remote MDS with nodsh" && return
9410 remote_ost_nodsh && skip "remote OST with nodsh" && return
9411 # First without trusting modes.
9412 find $proc_dirs -exec cat '{}' \; &> /dev/null
9414 # Second verifying readability.
9417 -exec cat '{}' \; &> /dev/null ||
9418 error "proc file read failed"
9420 for facet in $SINGLEMDS ost1; do
9421 do_facet $facet find $proc_dirs \
9422 ! -name req_history \
9423 -exec cat '{}' \\\; &> /dev/null
9425 do_facet $facet find $proc_dirs \
9426 ! -name req_history \
9428 -exec cat '{}' \\\; &> /dev/null ||
9429 error "proc file read failed"
9432 run_test 133f "Check for LBUGs/Oopses/unreadable files in /proc"
9437 local dirs="/proc/fs/lustre/ /proc/sys/lnet/ /proc/sys/lustre/ \
9438 /sys/fs/lustre/ /sys/fs/lnet/"
9440 for dir in $dirs; do
9441 if [ -d $dir ]; then
9442 proc_dirs="$proc_dirs $dir"
9448 # Second verifying readability.
9451 -not -name force_lbug \
9452 -not -name changelog_mask \
9453 -exec badarea_io '{}' \; &> /dev/null ||
9454 error "find $proc_dirs failed"
9456 [ $(lustre_version_code $SINGLEMDS) -le $(version_code 2.5.54) ] &&
9457 skip "Too old lustre on MDS" && return
9459 [ $(lustre_version_code ost1) -le $(version_code 2.5.54) ] &&
9460 skip "Too old lustre on ost1" && return
9462 for facet in $SINGLEMDS ost1; do
9463 do_facet $facet find $proc_dirs \
9465 -not -name force_lbug \
9466 -not -name changelog_mask \
9467 -exec badarea_io '{}' \\\; &> /dev/null ||
9468 error "$facet find $proc_dirs failed"
9472 # remount the FS in case writes/reads /proc break the FS
9473 cleanup || error "failed to unmount"
9474 setup || error "failed to setup"
9477 run_test 133g "Check for Oopses on bad io area writes/reads in /proc"
9480 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.54) ]] &&
9481 skip "Need MDS version at least 2.7.54" && return
9483 mkdir -p $DIR/$tdir || error "failed to create $DIR/$tdir"
9484 cancel_lru_locks mdc
9486 local nsdir="ldlm.namespaces.*-MDT0000-mdc-*"
9487 local unused=$($LCTL get_param -n $nsdir.lock_unused_count)
9488 [ $unused -eq 0 ] || "$unused locks are not cleared"
9491 createmany -o $DIR/$tdir/f $nr ||
9492 error "failed to create $nr files in $DIR/$tdir"
9493 unused=$($LCTL get_param -n $nsdir.lock_unused_count)
9495 #define OBD_FAIL_LDLM_WATERMARK_LOW 0x327
9496 do_facet mds1 $LCTL set_param fail_loc=0x327
9497 do_facet mds1 $LCTL set_param fail_val=500
9500 echo "sleep 10 seconds ..."
9502 local lck_cnt=$($LCTL get_param -n $nsdir.lock_unused_count)
9504 do_facet mds1 $LCTL set_param fail_loc=0
9505 do_facet mds1 $LCTL set_param fail_val=0
9506 [ $lck_cnt -lt $unused ] ||
9507 error "No locks reclaimed, before:$unused, after:$lck_cnt"
9510 unlinkmany $DIR/$tdir/f $nr
9512 run_test 134a "Server reclaims locks when reaching lock_reclaim_threshold"
9515 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.54) ]] &&
9516 skip "Need MDS version at least 2.7.54" && return
9518 mkdir -p $DIR/$tdir || error "failed to create $DIR/$tdir"
9519 cancel_lru_locks mdc
9521 local low_wm=$(do_facet mds1 $LCTL get_param -n \
9522 ldlm.lock_reclaim_threshold_mb)
9523 # disable reclaim temporarily
9524 do_facet mds1 $LCTL set_param ldlm.lock_reclaim_threshold_mb=0
9526 #define OBD_FAIL_LDLM_WATERMARK_HIGH 0x328
9527 do_facet mds1 $LCTL set_param fail_loc=0x328
9528 do_facet mds1 $LCTL set_param fail_val=500
9530 $LCTL set_param debug=+trace
9533 createmany -o $DIR/$tdir/f $nr &
9536 echo "Sleep $TIMEOUT seconds ..."
9538 if ! ps -p $create_pid > /dev/null 2>&1; then
9539 do_facet mds1 $LCTL set_param fail_loc=0
9540 do_facet mds1 $LCTL set_param fail_val=0
9541 do_facet mds1 $LCTL set_param \
9542 ldlm.lock_reclaim_threshold_mb=${low_wm}m
9543 error "createmany finished incorrectly!"
9545 do_facet mds1 $LCTL set_param fail_loc=0
9546 do_facet mds1 $LCTL set_param fail_val=0
9547 do_facet mds1 $LCTL set_param ldlm.lock_reclaim_threshold_mb=${low_wm}m
9548 wait $create_pid || return 1
9550 unlinkmany $DIR/$tdir/f $nr
9552 run_test 134b "Server rejects lock request when reaching lock_limit_mb"
9554 test_140() { #bug-17379
9555 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9556 test_mkdir -p $DIR/$tdir || error "Creating dir $DIR/$tdir"
9557 cd $DIR/$tdir || error "Changing to $DIR/$tdir"
9558 cp /usr/bin/stat . || error "Copying stat to $DIR/$tdir"
9560 # VFS limits max symlink depth to 5(4KSTACK) or 7(8KSTACK) or 8
9561 # For kernel > 3.5, bellow only tests consecutive symlink (MAX 40)
9563 while i=`expr $i + 1`; do
9564 test_mkdir -p $i || error "Creating dir $i"
9565 cd $i || error "Changing to $i"
9566 ln -s ../stat stat || error "Creating stat symlink"
9567 # Read the symlink until ELOOP present,
9568 # not LBUGing the system is considered success,
9569 # we didn't overrun the stack.
9570 $OPENFILE -f O_RDONLY stat >/dev/null 2>&1; ret=$?
9572 if [ $ret -eq 40 ]; then
9575 error "Open stat symlink"
9581 echo "The symlink depth = $i"
9582 [ $i -eq 5 -o $i -eq 7 -o $i -eq 8 -o $i -eq 40 ] ||
9583 error "Invalid symlink depth"
9585 # Test recursive symlink
9586 ln -s symlink_self symlink_self
9587 $OPENFILE -f O_RDONLY symlink_self >/dev/null 2>&1; ret=$?
9588 echo "open symlink_self returns $ret"
9589 [ $ret -eq 40 ] || error "recursive symlink doesn't return -ELOOP"
9591 run_test 140 "Check reasonable stack depth (shouldn't LBUG) ===="
9594 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9595 local TF="$TMP/$tfile"
9597 dd if=/dev/urandom of=$TF bs=6096 count=1 || error "dd failed"
9599 cancel_lru_locks osc
9600 cmp $TF $DIR/$tfile || error "$TMP/$tfile $DIR/$tfile differ"
9601 remount_client $MOUNT
9603 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (remount)"
9606 $TRUNCATE $DIR/$tfile 6000
9607 cancel_lru_locks osc
9608 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (truncate1)"
9611 echo "12345" >>$DIR/$tfile
9612 cancel_lru_locks osc
9613 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (append1)"
9616 echo "12345" >>$DIR/$tfile
9617 cancel_lru_locks osc
9618 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (append2)"
9623 run_test 150 "truncate/append tests"
9625 #LU-2902 roc_hit was not able to read all values from lproc
9626 function roc_hit_init() {
9627 local list=$(comma_list $(osts_nodes))
9628 local dir=$DIR/$tdir-check
9629 local file=$dir/file
9635 #use setstripe to do a write to every ost
9636 for i in $(seq 0 $((OSTCOUNT-1))); do
9637 $SETSTRIPE -c 1 -i $i $dir || error "$SETSTRIPE $file failed"
9638 dd if=/dev/urandom of=$file bs=4k count=4 2>&1 > /dev/null
9639 idx=$(printf %04x $i)
9640 BEFORE=$(get_osd_param $list *OST*$idx stats |
9641 awk '$1 == "cache_access" {sum += $7}
9642 END { printf("%0.0f", sum) }')
9644 cancel_lru_locks osc
9645 cat $file >/dev/null
9647 AFTER=$(get_osd_param $list *OST*$idx stats |
9648 awk '$1 == "cache_access" {sum += $7}
9649 END { printf("%0.0f", sum) }')
9651 echo BEFORE:$BEFORE AFTER:$AFTER
9652 if ! let "AFTER - BEFORE == 4"; then
9654 error "roc_hit is not safe to use"
9662 function roc_hit() {
9663 local list=$(comma_list $(osts_nodes))
9664 echo $(get_osd_param $list '' stats |
9665 awk '$1 == "cache_hit" {sum += $7}
9666 END { printf("%0.0f", sum) }')
9669 function set_cache() {
9672 if [ "$2" == "off" ]; then
9675 local list=$(comma_list $(osts_nodes))
9676 set_osd_param $list '' $1_cache_enable $on
9678 cancel_lru_locks osc
9682 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9683 remote_ost_nodsh && skip "remote OST with nodsh" && return
9686 local list=$(comma_list $(osts_nodes))
9688 # check whether obdfilter is cache capable at all
9689 if ! get_osd_param $list '' read_cache_enable >/dev/null; then
9690 echo "not cache-capable obdfilter"
9694 # check cache is enabled on all obdfilters
9695 if get_osd_param $list '' read_cache_enable | grep 0; then
9696 echo "oss cache is disabled"
9700 set_osd_param $list '' writethrough_cache_enable 1
9702 # check write cache is enabled on all obdfilters
9703 if get_osd_param $list '' writethrough_cache_enable | grep 0; then
9704 echo "oss write cache is NOT enabled"
9710 #define OBD_FAIL_OBD_NO_LRU 0x609
9711 do_nodes $list $LCTL set_param fail_loc=0x609
9713 # pages should be in the case right after write
9714 dd if=/dev/urandom of=$DIR/$tfile bs=4k count=$CPAGES ||
9717 local BEFORE=$(roc_hit)
9718 cancel_lru_locks osc
9719 cat $DIR/$tfile >/dev/null
9720 local AFTER=$(roc_hit)
9722 do_nodes $list $LCTL set_param fail_loc=0
9724 if ! let "AFTER - BEFORE == CPAGES"; then
9725 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
9728 # the following read invalidates the cache
9729 cancel_lru_locks osc
9730 set_osd_param $list '' read_cache_enable 0
9731 cat $DIR/$tfile >/dev/null
9733 # now data shouldn't be found in the cache
9735 cancel_lru_locks osc
9736 cat $DIR/$tfile >/dev/null
9738 if let "AFTER - BEFORE != 0"; then
9739 error "IN CACHE: before: $BEFORE, after: $AFTER"
9742 set_osd_param $list '' read_cache_enable 1
9745 run_test 151 "test cache on oss and controls ==============================="
9748 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9749 local TF="$TMP/$tfile"
9751 # simulate ENOMEM during write
9752 #define OBD_FAIL_OST_NOMEM 0x226
9753 lctl set_param fail_loc=0x80000226
9754 dd if=/dev/urandom of=$TF bs=6096 count=1 || error "dd failed"
9756 sync || error "sync failed"
9757 lctl set_param fail_loc=0
9759 # discard client's cache
9760 cancel_lru_locks osc
9762 # simulate ENOMEM during read
9763 lctl set_param fail_loc=0x80000226
9764 cmp $TF $DIR/$tfile || error "cmp failed"
9765 lctl set_param fail_loc=0
9769 run_test 152 "test read/write with enomem ============================"
9772 $MULTIOP $DIR/$tfile Ow4096Ycu || error "multiop failed"
9774 run_test 153 "test if fdatasync does not crash ======================="
9776 dot_lustre_fid_permission_check() {
9778 local ffid=$MOUNT/.lustre/fid/$fid
9781 echo "stat fid $fid"
9782 stat $ffid > /dev/null || error "stat $ffid failed."
9783 echo "touch fid $fid"
9784 touch $ffid || error "touch $ffid failed."
9785 echo "write to fid $fid"
9786 cat /etc/hosts > $ffid || error "write $ffid failed."
9787 echo "read fid $fid"
9788 diff /etc/hosts $ffid || error "read $ffid failed."
9789 echo "append write to fid $fid"
9790 cat /etc/hosts >> $ffid || error "append write $ffid failed."
9791 echo "rename fid $fid"
9792 mv $ffid $test_dir/$tfile.1 &&
9793 error "rename $ffid to $tfile.1 should fail."
9794 touch $test_dir/$tfile.1
9795 mv $test_dir/$tfile.1 $ffid &&
9796 error "rename $tfile.1 to $ffid should fail."
9797 rm -f $test_dir/$tfile.1
9798 echo "truncate fid $fid"
9799 $TRUNCATE $ffid 777 || error "truncate $ffid failed."
9800 if [ $MDSCOUNT -lt 2 ]; then #FIXME when cross-MDT hard link is working
9801 echo "link fid $fid"
9802 ln -f $ffid $test_dir/tfile.lnk || error "link $ffid failed."
9804 if [ -n $(lctl get_param -n mdc.*-mdc-*.connect_flags | grep acl) ]; then
9805 echo "setfacl fid $fid"
9806 setfacl -R -m u:bin:rwx $ffid || error "setfacl $ffid failed."
9807 echo "getfacl fid $fid"
9808 getfacl $ffid >/dev/null || error "getfacl $ffid failed."
9810 echo "unlink fid $fid"
9811 unlink $MOUNT/.lustre/fid/$fid && error "unlink $ffid should fail."
9812 echo "mknod fid $fid"
9813 mknod $ffid c 1 3 && error "mknod $ffid should fail."
9815 fid=[0xf00000400:0x1:0x0]
9816 ffid=$MOUNT/.lustre/fid/$fid
9818 echo "stat non-exist fid $fid"
9819 stat $ffid > /dev/null && error "stat non-exist $ffid should fail."
9820 echo "write to non-exist fid $fid"
9821 cat /etc/hosts > $ffid && error "write non-exist $ffid should fail."
9822 echo "link new fid $fid"
9823 ln $test_dir/$tfile $ffid && error "link $ffid should fail."
9825 mkdir -p $test_dir/$tdir
9826 touch $test_dir/$tdir/$tfile
9827 fid=$($LFS path2fid $test_dir/$tdir)
9830 error "error: could not get fid for $test_dir/$dir/$tfile."
9832 ffid=$MOUNT/.lustre/fid/$fid
9835 ls $ffid > /dev/null || error "ls $ffid failed."
9836 echo "touch $fid/$tfile.1"
9837 touch $ffid/$tfile.1 || error "touch $ffid/$tfile.1 failed."
9839 echo "touch $MOUNT/.lustre/fid/$tfile"
9840 touch $MOUNT/.lustre/fid/$tfile && \
9841 error "touch $MOUNT/.lustre/fid/$tfile should fail."
9843 echo "setxattr to $MOUNT/.lustre/fid"
9844 setfattr -n trusted.name1 -v value1 $MOUNT/.lustre/fid
9846 echo "listxattr for $MOUNT/.lustre/fid"
9847 getfattr -d -m "^trusted" $MOUNT/.lustre/fid
9849 echo "delxattr from $MOUNT/.lustre/fid"
9850 setfattr -x trusted.name1 $MOUNT/.lustre/fid
9852 echo "touch invalid fid: $MOUNT/.lustre/fid/[0x200000400:0x2:0x3]"
9853 touch $MOUNT/.lustre/fid/[0x200000400:0x2:0x3] &&
9854 error "touch invalid fid should fail."
9856 echo "touch non-normal fid: $MOUNT/.lustre/fid/[0x1:0x2:0x0]"
9857 touch $MOUNT/.lustre/fid/[0x1:0x2:0x0] &&
9858 error "touch non-normal fid should fail."
9860 echo "rename $tdir to $MOUNT/.lustre/fid"
9861 mrename $test_dir/$tdir $MOUNT/.lustre/fid &&
9862 error "rename to $MOUNT/.lustre/fid should fail."
9864 if [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.3.51) ]
9866 local old_obf_mode=$(stat --format="%a" $DIR/.lustre/fid)
9867 local new_obf_mode=777
9869 echo "change mode of $DIR/.lustre/fid to $new_obf_mode"
9870 chmod $new_obf_mode $DIR/.lustre/fid ||
9871 error "chmod $new_obf_mode $DIR/.lustre/fid failed"
9873 local obf_mode=$(stat --format=%a $DIR/.lustre/fid)
9874 [ $obf_mode -eq $new_obf_mode ] ||
9875 error "stat $DIR/.lustre/fid returned wrong mode $obf_mode"
9877 echo "restore mode of $DIR/.lustre/fid to $old_obf_mode"
9878 chmod $old_obf_mode $DIR/.lustre/fid ||
9879 error "chmod $old_obf_mode $DIR/.lustre/fid failed"
9882 $OPENFILE -f O_LOV_DELAY_CREATE:O_CREAT $test_dir/$tfile-2
9883 fid=$($LFS path2fid $test_dir/$tfile-2)
9885 if [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.6.50) ]
9887 echo "cp /etc/passwd $MOUNT/.lustre/fid/$fid"
9888 cp /etc/passwd $MOUNT/.lustre/fid/$fid ||
9889 error "create lov data thru .lustre failed"
9891 echo "cp /etc/passwd $test_dir/$tfile-2"
9892 cp /etc/passwd $test_dir/$tfile-2 ||
9893 error "copy to $test_dir/$tfile-2 failed."
9894 echo "diff /etc/passwd $MOUNT/.lustre/fid/$fid"
9895 diff /etc/passwd $MOUNT/.lustre/fid/$fid ||
9896 error "diff /etc/passwd $MOUNT/.lustre/fid/$fid failed."
9898 rm -rf $test_dir/tfile.lnk
9899 rm -rf $test_dir/$tfile-2
9903 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.1) ]] &&
9904 skip "Need MDS version at least 2.4.1" && return
9907 local FID=$($LFS path2fid $DIR/$tfile)
9908 [ -z "$FID" ] && error "path2fid unable to get $DIR/$tfile FID"
9910 # check that we get the same pathname back
9911 local FOUND=$($LFS fid2path $MOUNT "$FID")
9912 [ -z "$FOUND" ] && error "fid2path unable to get $FID path"
9913 [ "$FOUND" != "$DIR/$tfile" ] &&
9914 error "fid2path(path2fid($DIR/$tfile)) = $FOUND != $DIR/$tfile"
9918 run_test 154A "lfs path2fid and fid2path basic checks"
9921 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9922 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.51) ]] ||
9923 { skip "Need MDS version at least 2.2.51"; return 0; }
9924 [ -z "$(which setfacl)" ] && skip "must have setfacl tool" && return
9926 cp /etc/hosts $DIR/$tfile
9928 fid=$($LFS path2fid $DIR/$tfile)
9930 [ $rc -ne 0 ] && error "error: could not get fid for $DIR/$tfile."
9932 dot_lustre_fid_permission_check "$fid" $DIR ||
9933 error "dot lustre permission check $fid failed"
9935 rm -rf $MOUNT/.lustre && error ".lustre is not allowed to be unlinked"
9937 touch $MOUNT/.lustre/file &&
9938 error "creation is not allowed under .lustre"
9940 mkdir $MOUNT/.lustre/dir &&
9941 error "mkdir is not allowed under .lustre"
9945 run_test 154a "Open-by-FID"
9948 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9949 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.51) ]] ||
9950 { skip "Need MDS version at least 2.2.51"; return 0; }
9952 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
9954 local remote_dir=$DIR/$tdir/remote_dir
9959 $LFS mkdir -i $MDTIDX $remote_dir ||
9960 error "create remote directory failed"
9962 cp /etc/hosts $remote_dir/$tfile
9964 fid=$($LFS path2fid $remote_dir/$tfile)
9966 [ $rc -ne 0 ] && error "error: could not get fid for $remote_dir/$tfile"
9968 dot_lustre_fid_permission_check "$fid" $remote_dir ||
9969 error "dot lustre permission check $fid failed"
9972 run_test 154b "Open-by-FID for remote directory"
9975 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.1) ]] &&
9976 skip "Need MDS version at least 2.4.1" && return
9978 touch $DIR/$tfile.1 $DIR/$tfile.2 $DIR/$tfile.3
9979 local FID1=$($LFS path2fid $DIR/$tfile.1)
9980 local FID2=$($LFS path2fid $DIR/$tfile.2)
9981 local FID3=$($LFS path2fid $DIR/$tfile.3)
9984 $LFS path2fid $DIR/$tfile.[123] | while read PATHNAME FID; do
9985 [ "$PATHNAME" = "$DIR/$tfile.$N:" ] ||
9986 error "path2fid pathname $PATHNAME != $DIR/$tfile.$N:"
9988 [ "$FID" = "${!want}" ] ||
9989 error "path2fid $PATHNAME FID $FID != FID$N ${!want}"
9993 $LFS fid2path $MOUNT "$FID1" "$FID2" "$FID3" | while read PATHNAME;
9995 [ "$PATHNAME" = "$DIR/$tfile.$N" ] ||
9996 error "fid2path pathname $PATHNAME != $DIR/$tfile.$N:"
10000 run_test 154c "lfs path2fid and fid2path multiple arguments"
10003 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.5.53) ]] &&
10004 skip "Need MDS version at least 2.5.53" && return
10006 if remote_mds; then
10007 nid=$($LCTL list_nids | sed "s/\./\\\./g")
10011 local proc_ofile="mdt.*.exports.'$nid'.open_files"
10018 local fid=$($LFS path2fid $DIR/$tfile)
10021 cmd="exec $fd<$DIR/$tfile"
10023 local fid_list=$(do_facet $SINGLEMDS $LCTL get_param $proc_ofile)
10024 echo "$fid_list" | grep "$fid"
10027 cmd="exec $fd>/dev/null"
10029 if [ $rc -ne 0 ]; then
10030 error "FID $fid not found in open files list $fid_list"
10033 run_test 154d "Verify open file fid"
10037 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.6.50) ]] &&
10038 skip "Need MDS version at least 2.6.50" && return
10040 if ls -a $MOUNT | grep -q '^\.lustre$'; then
10041 error ".lustre returned by readdir"
10044 run_test 154e ".lustre is not returned by readdir"
10047 # create parent directory on a single MDT to avoid cross-MDT hardlinks
10048 test_mkdir -p -c1 $DIR/$tdir/d
10049 # test dirs inherit from its stripe
10050 mkdir -p $DIR/$tdir/d/foo1 || error "mkdir error"
10051 mkdir -p $DIR/$tdir/d/foo2 || error "mkdir error"
10052 cp /etc/hosts $DIR/$tdir/d/foo1/$tfile
10053 ln $DIR/$tdir/d/foo1/$tfile $DIR/$tdir/d/foo2/link
10056 # get fid of parents
10057 local FID0=$($LFS path2fid $DIR/$tdir/d)
10058 local FID1=$($LFS path2fid $DIR/$tdir/d/foo1)
10059 local FID2=$($LFS path2fid $DIR/$tdir/d/foo2)
10060 local FID3=$($LFS path2fid $DIR)
10062 # check that path2fid --parents returns expected <parent_fid>/name
10063 # 1) test for a directory (single parent)
10064 local parent=$($LFS path2fid --parents $DIR/$tdir/d/foo1)
10065 [ "$parent" == "$FID0/foo1" ] ||
10066 error "expected parent: $FID0/foo1, got: $parent"
10068 # 2) test for a file with nlink > 1 (multiple parents)
10069 parent=$($LFS path2fid --parents $DIR/$tdir/d/foo1/$tfile)
10070 echo "$parent" | grep -F "$FID1/$tfile" ||
10071 error "$FID1/$tfile not returned in parent list"
10072 echo "$parent" | grep -F "$FID2/link" ||
10073 error "$FID2/link not returned in parent list"
10075 # 3) get parent by fid
10076 local file_fid=$($LFS path2fid $DIR/$tdir/d/foo1/$tfile)
10077 parent=$($LFS path2fid --parents $MOUNT/.lustre/fid/$file_fid)
10078 echo "$parent" | grep -F "$FID1/$tfile" ||
10079 error "$FID1/$tfile not returned in parent list (by fid)"
10080 echo "$parent" | grep -F "$FID2/link" ||
10081 error "$FID2/link not returned in parent list (by fid)"
10083 # 4) test for entry in root directory
10084 parent=$($LFS path2fid --parents $DIR/f)
10085 echo "$parent" | grep -F "$FID3/f" ||
10086 error "$FID3/f not returned in parent list"
10088 # 5) test it on root directory
10089 [ -z "$($LFS path2fid --parents $MOUNT 2>/dev/null)" ] ||
10090 error "$MOUNT should not have parents"
10092 # enable xattr caching and check that linkea is correctly updated
10093 local save="$TMP/$TESTSUITE-$TESTNAME.parameters"
10094 save_lustre_params client "llite.*.xattr_cache" > $save
10095 lctl set_param llite.*.xattr_cache 1
10097 # 6.1) linkea update on rename
10098 mv $DIR/$tdir/d/foo1/$tfile $DIR/$tdir/d/foo2/$tfile.moved
10100 # get parents by fid
10101 parent=$($LFS path2fid --parents $MOUNT/.lustre/fid/$file_fid)
10102 # foo1 should no longer be returned in parent list
10103 echo "$parent" | grep -F "$FID1" &&
10104 error "$FID1 should no longer be in parent list"
10105 # the new path should appear
10106 echo "$parent" | grep -F "$FID2/$tfile.moved" ||
10107 error "$FID2/$tfile.moved is not in parent list"
10109 # 6.2) linkea update on unlink
10110 rm -f $DIR/$tdir/d/foo2/link
10111 parent=$($LFS path2fid --parents $MOUNT/.lustre/fid/$file_fid)
10112 # foo2/link should no longer be returned in parent list
10113 echo "$parent" | grep -F "$FID2/link" &&
10114 error "$FID2/link should no longer be in parent list"
10118 restore_lustre_params < $save
10120 run_test 154f "get parent fids by reading link ea"
10124 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.6.92) ]] ||
10125 { skip "Need MDS version at least 2.6.92"; return 0; }
10127 mkdir -p $DIR/$tdir
10128 llapi_fid_test -d $DIR/$tdir
10130 run_test 154g "various llapi FID tests"
10132 test_155_small_load() {
10133 local temp=$TMP/$tfile
10134 local file=$DIR/$tfile
10136 dd if=/dev/urandom of=$temp bs=6096 count=1 || \
10137 error "dd of=$temp bs=6096 count=1 failed"
10139 cancel_lru_locks osc
10140 cmp $temp $file || error "$temp $file differ"
10142 $TRUNCATE $temp 6000
10143 $TRUNCATE $file 6000
10144 cmp $temp $file || error "$temp $file differ (truncate1)"
10146 echo "12345" >>$temp
10147 echo "12345" >>$file
10148 cmp $temp $file || error "$temp $file differ (append1)"
10150 echo "12345" >>$temp
10151 echo "12345" >>$file
10152 cmp $temp $file || error "$temp $file differ (append2)"
10158 test_155_big_load() {
10159 remote_ost_nodsh && skip "remote OST with nodsh" && return
10160 local temp=$TMP/$tfile
10161 local file=$DIR/$tfile
10164 local cache_size=$(do_facet ost$((MAXI+1)) \
10165 "awk '/cache/ {sum+=\\\$4} END {print sum}' /proc/cpuinfo")
10166 local large_file_size=$((cache_size * 2))
10168 echo "OSS cache size: $cache_size KB"
10169 echo "Large file size: $large_file_size KB"
10171 [ $MAXV -le $large_file_size ] && \
10172 skip_env "max available OST size needs > $large_file_size KB" && \
10175 $SETSTRIPE $file -c 1 -i $MAXI || error "$SETSTRIPE $file failed"
10177 dd if=/dev/urandom of=$temp bs=$large_file_size count=1k || \
10178 error "dd of=$temp bs=$large_file_size count=1k failed"
10181 cancel_lru_locks osc
10182 cmp $temp $file || error "$temp $file differ"
10189 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10191 set_cache writethrough on
10192 test_155_small_load
10194 run_test 155a "Verify small file correctness: read cache:on write_cache:on"
10197 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10199 set_cache writethrough off
10200 test_155_small_load
10202 run_test 155b "Verify small file correctness: read cache:on write_cache:off"
10205 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10207 set_cache writethrough on
10208 test_155_small_load
10210 run_test 155c "Verify small file correctness: read cache:off write_cache:on"
10213 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10215 set_cache writethrough off
10216 test_155_small_load
10218 run_test 155d "Verify small file correctness: read cache:off write_cache:off"
10221 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10223 set_cache writethrough on
10226 run_test 155e "Verify big file correctness: read cache:on write_cache:on"
10229 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10231 set_cache writethrough off
10234 run_test 155f "Verify big file correctness: read cache:on write_cache:off"
10237 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10239 set_cache writethrough on
10242 run_test 155g "Verify big file correctness: read cache:off write_cache:on"
10245 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10247 set_cache writethrough off
10250 run_test 155h "Verify big file correctness: read cache:off write_cache:off"
10253 remote_ost_nodsh && skip "remote OST with nodsh" && return
10254 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10258 local file="$DIR/$tfile"
10260 [ "$(facet_fstype ost1)" = "zfs" -a \
10261 $(lustre_version_code ost1 -lt $(version_code 2.6.93)) ] &&
10262 skip "LU-1956/LU-2261: stats not implemented on OSD ZFS" &&
10267 log "Turn on read and write cache"
10269 set_cache writethrough on
10271 log "Write data and read it back."
10272 log "Read should be satisfied from the cache."
10273 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
10275 cancel_lru_locks osc
10276 cat $file >/dev/null
10278 if ! let "AFTER - BEFORE == CPAGES"; then
10279 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
10281 log "cache hits:: before: $BEFORE, after: $AFTER"
10284 log "Read again; it should be satisfied from the cache."
10286 cancel_lru_locks osc
10287 cat $file >/dev/null
10289 if ! let "AFTER - BEFORE == CPAGES"; then
10290 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
10292 log "cache hits:: before: $BEFORE, after: $AFTER"
10295 log "Turn off the read cache and turn on the write cache"
10297 set_cache writethrough on
10299 log "Read again; it should be satisfied from the cache."
10301 cancel_lru_locks osc
10302 cat $file >/dev/null
10304 if ! let "AFTER - BEFORE == CPAGES"; then
10305 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
10307 log "cache hits:: before: $BEFORE, after: $AFTER"
10310 log "Read again; it should not be satisfied from the cache."
10312 cancel_lru_locks osc
10313 cat $file >/dev/null
10315 if ! let "AFTER - BEFORE == 0"; then
10316 error "IN CACHE: before: $BEFORE, after: $AFTER"
10318 log "cache hits:: before: $BEFORE, after: $AFTER"
10321 log "Write data and read it back."
10322 log "Read should be satisfied from the cache."
10323 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
10325 cancel_lru_locks osc
10326 cat $file >/dev/null
10328 if ! let "AFTER - BEFORE == CPAGES"; then
10329 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
10331 log "cache hits:: before: $BEFORE, after: $AFTER"
10334 log "Read again; it should not be satisfied from the cache."
10336 cancel_lru_locks osc
10337 cat $file >/dev/null
10339 if ! let "AFTER - BEFORE == 0"; then
10340 error "IN CACHE: before: $BEFORE, after: $AFTER"
10342 log "cache hits:: before: $BEFORE, after: $AFTER"
10345 log "Turn off read and write cache"
10347 set_cache writethrough off
10349 log "Write data and read it back"
10350 log "It should not be satisfied from the cache."
10352 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
10353 cancel_lru_locks osc
10355 cat $file >/dev/null
10357 if ! let "AFTER - BEFORE == 0"; then
10358 error_ignore bz20762 "IN CACHE: before: $BEFORE, after: $AFTER"
10360 log "cache hits:: before: $BEFORE, after: $AFTER"
10363 log "Turn on the read cache and turn off the write cache"
10365 set_cache writethrough off
10367 log "Write data and read it back"
10368 log "It should not be satisfied from the cache."
10370 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
10372 cancel_lru_locks osc
10373 cat $file >/dev/null
10375 if ! let "AFTER - BEFORE == 0"; then
10376 error_ignore bz20762 "IN CACHE: before: $BEFORE, after: $AFTER"
10378 log "cache hits:: before: $BEFORE, after: $AFTER"
10381 log "Read again; it should be satisfied from the cache."
10383 cancel_lru_locks osc
10384 cat $file >/dev/null
10386 if ! let "AFTER - BEFORE == CPAGES"; then
10387 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
10389 log "cache hits:: before: $BEFORE, after: $AFTER"
10394 run_test 156 "Verification of tunables"
10398 if [[ $MDSCOUNT -gt 1 ]]; then
10399 error_ignore bz17935 $*
10407 local CL_MASK_PARAM="mdd.$MDT0.changelog_mask"
10409 MASK=$(do_facet $SINGLEMDS $LCTL get_param $CL_MASK_PARAM| grep -c "$1")
10411 if [ $MASK -eq 1 ]; then
10412 do_facet $SINGLEMDS $LCTL set_param $CL_MASK_PARAM="-$1"
10414 do_facet $SINGLEMDS $LCTL set_param $CL_MASK_PARAM="+$1"
10418 changelog_extract_field() {
10422 local identifier=$4
10424 $LFS changelog $mdt | gawk "/$cltype.*$file$/ {
10425 print gensub(/^.* "$identifier'(\[[^\]]*\]).*$/,"\\1",1)}' |
10430 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10431 remote_mds_nodsh && skip "remote MDS with nodsh" && return
10432 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] ||
10433 { skip "Need MDS version at least 2.2.0"; return; }
10435 local CL_USERS="mdd.$MDT0.changelog_users"
10436 local GET_CL_USERS="do_facet $SINGLEMDS $LCTL get_param -n $CL_USERS"
10437 USER=$(do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_register -n)
10438 echo "Registered as changelog user $USER"
10439 $GET_CL_USERS | grep -q $USER ||
10440 error "User $USER not found in changelog_users"
10443 test_mkdir -p $DIR/$tdir/pics/2008/zachy
10444 touch $DIR/$tdir/pics/2008/zachy/timestamp
10445 cp /etc/hosts $DIR/$tdir/pics/2008/zachy/pic1.jpg
10446 mv $DIR/$tdir/pics/2008/zachy $DIR/$tdir/pics/zach
10447 ln $DIR/$tdir/pics/zach/pic1.jpg $DIR/$tdir/pics/2008/portland.jpg
10448 ln -s $DIR/$tdir/pics/2008/portland.jpg $DIR/$tdir/pics/desktop.jpg
10449 rm $DIR/$tdir/pics/desktop.jpg
10451 $LFS changelog $MDT0 | tail -5
10453 echo "verifying changelog mask"
10454 changelog_chmask "MKDIR"
10455 changelog_chmask "CLOSE"
10457 test_mkdir -p $DIR/$tdir/pics/zach/sofia
10458 echo "zzzzzz" > $DIR/$tdir/pics/zach/file
10460 changelog_chmask "MKDIR"
10461 changelog_chmask "CLOSE"
10463 test_mkdir -p $DIR/$tdir/pics/2008/sofia
10464 echo "zzzzzz" > $DIR/$tdir/pics/zach/file
10466 $LFS changelog $MDT0
10467 MKDIRS=$($LFS changelog $MDT0 | tail -5 | grep -c "MKDIR")
10468 CLOSES=$($LFS changelog $MDT0 | tail -5 | grep -c "CLOSE")
10469 [ $MKDIRS -eq 1 ] || err17935 "MKDIR changelog mask count $DIRS != 1"
10470 [ $CLOSES -eq 1 ] || err17935 "CLOSE changelog mask count $DIRS != 1"
10473 echo "verifying target fid"
10474 fidc=$(changelog_extract_field $MDT0 "CREAT" "timestamp" "t=")
10475 fidf=$($LFS path2fid $DIR/$tdir/pics/zach/timestamp)
10476 [ "$fidc" == "$fidf" ] ||
10477 err17935 "fid in changelog $fidc != file fid $fidf"
10478 echo "verifying parent fid"
10479 fidc=$(changelog_extract_field $MDT0 "CREAT" "timestamp" "p=")
10480 fidf=$($LFS path2fid $DIR/$tdir/pics/zach)
10481 [ "$fidc" == "$fidf" ] ||
10482 err17935 "pfid in changelog $fidc != dir fid $fidf"
10484 USER_REC1=$($GET_CL_USERS | awk "\$1 == \"$USER\" {print \$2}")
10485 $LFS changelog_clear $MDT0 $USER $(($USER_REC1 + 5))
10486 USER_REC2=$($GET_CL_USERS | awk "\$1 == \"$USER\" {print \$2}")
10487 echo "verifying user clear: $(( $USER_REC1 + 5 )) == $USER_REC2"
10488 [ $USER_REC2 == $(($USER_REC1 + 5)) ] ||
10489 err17935 "user index expected $(($USER_REC1 + 5)) is $USER_REC2"
10491 MIN_REC=$($GET_CL_USERS |
10492 awk 'min == "" || $2 < min {min = $2}; END {print min}')
10493 FIRST_REC=$($LFS changelog $MDT0 | head -n1 | awk '{print $1}')
10494 echo "verifying min purge: $(( $MIN_REC + 1 )) == $FIRST_REC"
10495 [ $FIRST_REC == $(($MIN_REC + 1)) ] ||
10496 err17935 "first index should be $(($MIN_REC + 1)) is $FIRST_REC"
10498 # LU-3446 changelog index reset on MDT restart
10499 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
10500 CUR_REC1=$($GET_CL_USERS | head -n1 | cut -f3 -d' ')
10501 $LFS changelog_clear $MDT0 $USER 0
10502 stop $SINGLEMDS || error "Fail to stop MDT."
10503 start $SINGLEMDS $MDT_DEV $MDS_MOUNT_OPTS || error "Fail to start MDT."
10504 CUR_REC2=$($GET_CL_USERS | head -n1 | cut -f3 -d' ')
10505 echo "verifying index survives MDT restart: $CUR_REC1 == $CUR_REC2"
10506 [ $CUR_REC1 == $CUR_REC2 ] ||
10507 err17935 "current index should be $CUR_REC1 is $CUR_REC2"
10509 echo "verifying user deregister"
10510 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister $USER
10511 $GET_CL_USERS | grep -q $USER &&
10512 error "User $USER still in changelog_users"
10514 USERS=$(( $($GET_CL_USERS | wc -l) - 2 ))
10515 if [ $USERS -eq 0 ]; then
10516 LAST_REC1=$($GET_CL_USERS | head -n1 | cut -f3 -d' ')
10517 touch $DIR/$tdir/chloe
10518 LAST_REC2=$($GET_CL_USERS | head -n1 | cut -f3 -d' ')
10519 echo "verify changelogs are off: $LAST_REC1 == $LAST_REC2"
10520 [ $LAST_REC1 == $LAST_REC2 ] || error "changelogs not off"
10522 echo "$USERS other changelog users; can't verify off"
10525 run_test 160a "changelog sanity"
10527 test_160b() { # LU-3587
10528 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10529 remote_mds_nodsh && skip "remote MDS with nodsh" && return
10530 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] ||
10531 { skip "Need MDS version at least 2.2.0"; return; }
10533 local CL_USERS="mdd.$MDT0.changelog_users"
10534 local GET_CL_USERS="do_facet $SINGLEMDS $LCTL get_param -n $CL_USERS"
10535 USER=$(do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_register -n)
10536 echo "Registered as changelog user $USER"
10537 $GET_CL_USERS | grep -q $USER ||
10538 error "User $USER not found in changelog_users"
10540 local LONGNAME1=$(str_repeat a 255)
10541 local LONGNAME2=$(str_repeat b 255)
10544 echo "creating very long named file"
10545 touch $LONGNAME1 || error "create of $LONGNAME1 failed"
10546 echo "moving very long named file"
10547 mv $LONGNAME1 $LONGNAME2
10549 $LFS changelog $MDT0 | grep RENME
10551 echo "deregistering $USER"
10552 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister $USER
10556 run_test 160b "Verify that very long rename doesn't crash in changelog"
10559 remote_mds_nodsh && skip "remote MDS with nodsh" && return
10562 local server_version=$(lustre_version_code $SINGLEMDS)
10564 [[ $server_version -gt $(version_code 2.5.57) ]] ||
10565 [[ $server_version -gt $(version_code 2.5.1) &&
10566 $server_version -lt $(version_code 2.5.50) ]] ||
10567 { skip "Need MDS version at least 2.5.58 or 2.5.2+"; return; }
10568 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10570 # Registration step
10571 local USER=$(do_facet $SINGLEMDS $LCTL --device $MDT0 \
10572 changelog_register -n)
10575 mkdir -p $DIR/$tdir
10576 $MCREATE $DIR/$tdir/foo_160c
10577 changelog_chmask "TRUNC"
10578 $TRUNCATE $DIR/$tdir/foo_160c 200
10579 changelog_chmask "TRUNC"
10580 $TRUNCATE $DIR/$tdir/foo_160c 199
10581 $LFS changelog $MDT0
10582 TRUNCS=$($LFS changelog $MDT0 | tail -5 | grep -c "TRUNC")
10583 [ $TRUNCS -eq 1 ] || err17935 "TRUNC changelog mask count $TRUNCS != 1"
10584 $LFS changelog_clear $MDT0 $USER 0
10586 # Deregistration step
10587 echo "deregistering $USER"
10588 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister $USER
10590 run_test 160c "verify that changelog log catch the truncate event"
10593 remote_mds_nodsh && skip "remote MDS with nodsh" && return
10594 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
10596 local server_version=$(lustre_version_code mds1)
10597 local CL_MASK_PARAM="mdd.$MDT0.changelog_mask"
10599 [[ $server_version -ge $(version_code 2.7.60) ]] ||
10600 { skip "Need MDS version at least 2.7.60+"; return; }
10601 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10603 # Registration step
10604 local USER=$(do_facet mds1 $LCTL --device $MDT0 \
10605 changelog_register -n)
10607 mkdir -p $DIR/$tdir/migrate_dir
10608 $LFS changelog_clear $MDT0 $USER 0
10610 $LFS migrate -m 1 $DIR/$tdir/migrate_dir || error "migrate fails"
10611 $LFS changelog $MDT0
10612 MIGRATES=$($LFS changelog $MDT0 | tail -5 | grep -c "MIGRT")
10613 $LFS changelog_clear $MDT0 $USER 0
10614 [ $MIGRATES -eq 1 ] ||
10615 error "MIGRATE changelog mask count $MIGRATES != 1"
10617 # Deregistration step
10618 do_facet mds1 $LCTL --device $MDT0 changelog_deregister $USER
10620 run_test 160d "verify that changelog log catch the migrate event"
10623 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10624 test_mkdir -p -c1 $DIR/$tdir
10625 cp /etc/hosts $DIR/$tdir/$tfile
10626 test_mkdir -c1 $DIR/$tdir/foo1
10627 test_mkdir -c1 $DIR/$tdir/foo2
10628 ln $DIR/$tdir/$tfile $DIR/$tdir/foo1/sofia
10629 ln $DIR/$tdir/$tfile $DIR/$tdir/foo2/zachary
10630 ln $DIR/$tdir/$tfile $DIR/$tdir/foo1/luna
10631 ln $DIR/$tdir/$tfile $DIR/$tdir/foo2/thor
10632 local FID=$($LFS path2fid $DIR/$tdir/$tfile | tr -d '[]')
10633 if [ "$($LFS fid2path $DIR $FID | wc -l)" != "5" ]; then
10634 $LFS fid2path $DIR $FID
10635 err17935 "bad link ea"
10638 rm $DIR/$tdir/foo2/zachary
10640 rm $DIR/$tdir/foo2/thor
10642 rm $DIR/$tdir/$tfile
10644 mv $DIR/$tdir/foo1/sofia $DIR/$tdir/foo2/maggie
10645 if [ "$($LFS fid2path $FSNAME --link 1 $FID)" != "$tdir/foo2/maggie" ]
10647 $LFS fid2path $DIR $FID
10648 err17935 "bad link rename"
10650 rm $DIR/$tdir/foo2/maggie
10653 local longname=filename_avg_len_is_thirty_two_
10654 createmany -l$DIR/$tdir/foo1/luna $DIR/$tdir/foo2/$longname 1000 ||
10655 error "failed to hardlink many files"
10656 links=$($LFS fid2path $DIR $FID | wc -l)
10657 echo -n "${links}/1000 links in link EA"
10658 [[ $links -gt 60 ]] ||
10659 err17935 "expected at least 60 links in link EA"
10660 unlinkmany $DIR/$tdir/foo2/$longname 1000 ||
10661 error "failed to unlink many hardlinks"
10663 run_test 161a "link ea sanity"
10666 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10667 [ $MDSCOUNT -lt 2 ] &&
10668 skip "skipping remote directory test" && return
10670 local remote_dir=$DIR/$tdir/remote_dir
10672 mkdir -p $DIR/$tdir
10673 $LFS mkdir -i $MDTIDX $remote_dir ||
10674 error "create remote directory failed"
10676 cp /etc/hosts $remote_dir/$tfile
10677 mkdir -p $remote_dir/foo1
10678 mkdir -p $remote_dir/foo2
10679 ln $remote_dir/$tfile $remote_dir/foo1/sofia
10680 ln $remote_dir/$tfile $remote_dir/foo2/zachary
10681 ln $remote_dir/$tfile $remote_dir/foo1/luna
10682 ln $remote_dir/$tfile $remote_dir/foo2/thor
10684 local FID=$($LFS path2fid $remote_dir/$tfile | tr -d '[' |
10686 if [ "$($LFS fid2path $DIR $FID | wc -l)" != "5" ]; then
10687 $LFS fid2path $DIR $FID
10688 err17935 "bad link ea"
10691 rm $remote_dir/foo2/zachary
10693 rm $remote_dir/foo2/thor
10695 rm $remote_dir/$tfile
10697 mv $remote_dir/foo1/sofia $remote_dir/foo2/maggie
10698 local link_path=$($LFS fid2path $FSNAME --link 1 $FID)
10699 if [ "$DIR/$link_path" != "$remote_dir/foo2/maggie" ]; then
10700 $LFS fid2path $DIR $FID
10701 err17935 "bad link rename"
10703 rm $remote_dir/foo2/maggie
10706 local longname=filename_avg_len_is_thirty_two_
10707 createmany -l$remote_dir/foo1/luna $remote_dir/foo2/$longname 1000 ||
10708 error "failed to hardlink many files"
10709 links=$($LFS fid2path $DIR $FID | wc -l)
10710 echo -n "${links}/1000 links in link EA"
10711 [[ ${links} -gt 60 ]] ||
10712 err17935 "expected at least 60 links in link EA"
10713 unlinkmany $remote_dir/foo2/$longname 1000 ||
10714 error "failed to unlink many hardlinks"
10716 run_test 161b "link ea sanity under remote directory"
10719 remote_mds_nodsh && skip "remote MDS with nodsh" && return
10720 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10721 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.1.5) ]] &&
10722 skip "Need MDS version at least 2.1.5" && return
10724 # define CLF_RENAME_LAST 0x0001
10725 # rename overwrite a target having nlink = 1 (changelog flag 0x1)
10726 local USER=$(do_facet $SINGLEMDS $LCTL --device $MDT0 \
10727 changelog_register -n)
10729 mkdir -p $DIR/$tdir
10730 touch $DIR/$tdir/foo_161c
10731 touch $DIR/$tdir/bar_161c
10732 mv -f $DIR/$tdir/foo_161c $DIR/$tdir/bar_161c
10733 $LFS changelog $MDT0 | grep RENME
10734 local flags=$($LFS changelog $MDT0 | grep RENME | tail -1 | \
10736 $LFS changelog_clear $MDT0 $USER 0
10737 if [ x$flags != "x0x1" ]; then
10738 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister \
10740 error "flag $flags is not 0x1"
10742 echo "rename overwrite a target having nlink = 1," \
10743 "changelog record has flags of $flags"
10745 # rename overwrite a target having nlink > 1 (changelog flag 0x0)
10746 touch $DIR/$tdir/foo_161c
10747 touch $DIR/$tdir/bar_161c
10748 ln $DIR/$tdir/bar_161c $DIR/$tdir/foobar_161c
10749 mv -f $DIR/$tdir/foo_161c $DIR/$tdir/bar_161c
10750 $LFS changelog $MDT0 | grep RENME
10751 flags=$($LFS changelog $MDT0 | grep RENME | tail -1 | cut -f5 -d' ')
10752 $LFS changelog_clear $MDT0 $USER 0
10753 if [ x$flags != "x0x0" ]; then
10754 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister \
10756 error "flag $flags is not 0x0"
10758 echo "rename overwrite a target having nlink > 1," \
10759 "changelog record has flags of $flags"
10761 # rename doesn't overwrite a target (changelog flag 0x0)
10762 touch $DIR/$tdir/foo_161c
10763 mv -f $DIR/$tdir/foo_161c $DIR/$tdir/foo2_161c
10764 $LFS changelog $MDT0 | grep RENME
10765 flags=$($LFS changelog $MDT0 | grep RENME | tail -1 | cut -f5 -d' ')
10766 $LFS changelog_clear $MDT0 $USER 0
10767 if [ x$flags != "x0x0" ]; then
10768 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister \
10770 error "flag $flags is not 0x0"
10772 echo "rename doesn't overwrite a target," \
10773 "changelog record has flags of $flags"
10775 # define CLF_UNLINK_LAST 0x0001
10776 # unlink a file having nlink = 1 (changelog flag 0x1)
10777 rm -f $DIR/$tdir/foo2_161c
10778 $LFS changelog $MDT0 | grep UNLNK
10779 flags=$($LFS changelog $MDT0 | grep UNLNK | tail -1 | cut -f5 -d' ')
10780 $LFS changelog_clear $MDT0 $USER 0
10781 if [ x$flags != "x0x1" ]; then
10782 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister \
10784 error "flag $flags is not 0x1"
10786 echo "unlink a file having nlink = 1," \
10787 "changelog record has flags of $flags"
10789 # unlink a file having nlink > 1 (changelog flag 0x0)
10790 ln -f $DIR/$tdir/bar_161c $DIR/$tdir/foobar_161c
10791 rm -f $DIR/$tdir/foobar_161c
10792 $LFS changelog $MDT0 | grep UNLNK
10793 flags=$($LFS changelog $MDT0 | grep UNLNK | tail -1 | cut -f5 -d' ')
10794 $LFS changelog_clear $MDT0 $USER 0
10795 if [ x$flags != "x0x0" ]; then
10796 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister \
10798 error "flag $flags is not 0x0"
10800 echo "unlink a file having nlink > 1," \
10801 "changelog record has flags of $flags"
10802 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister $USER
10804 run_test 161c "check CL_RENME[UNLINK] changelog record flags"
10811 local path=$(${LFS} fid2path $*)
10812 # Remove the '//' indicating a remote directory
10813 path=$(echo $path | sed 's#//#/#g')
10816 if [ $RC -ne 0 ]; then
10817 err17935 "path looked up of $expected failed. Error $RC"
10819 elif [ "${path}" != "${expected}" ]; then
10820 err17935 "path looked up \"${path}\" instead of \"${expected}\""
10823 echo "fid $fid resolves to path $path (expected $expected)"
10826 test_162a() { # was test_162
10827 # Make changes to filesystem
10828 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10829 test_mkdir -p -c1 $DIR/$tdir/d2
10830 touch $DIR/$tdir/d2/$tfile
10831 touch $DIR/$tdir/d2/x1
10832 touch $DIR/$tdir/d2/x2
10833 test_mkdir -p -c1 $DIR/$tdir/d2/a/b/c
10834 test_mkdir -p -c1 $DIR/$tdir/d2/p/q/r
10836 FID=$($LFS path2fid $DIR/$tdir/d2/$tfile | tr -d '[]')
10837 check_path "$tdir/d2/$tfile" $FSNAME $FID --link 0 ||
10838 error "check path $tdir/d2/$tfile failed"
10841 ln -s $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/p/q/r/slink
10842 FID=$($LFS path2fid $DIR/$tdir/d2/p/q/r/slink | tr -d '[]')
10843 check_path "$tdir/d2/p/q/r/slink" $FSNAME $FID --link 0 ||
10844 error "check path $tdir/d2/p/q/r/slink failed"
10846 # softlink to wrong file
10847 ln -s /this/is/garbage $DIR/$tdir/d2/p/q/r/slink.wrong
10848 FID=$($LFS path2fid $DIR/$tdir/d2/p/q/r/slink.wrong | tr -d '[]')
10849 check_path "$tdir/d2/p/q/r/slink.wrong" $FSNAME $FID --link 0 ||
10850 error "check path $tdir/d2/p/q/r/slink.wrong failed"
10853 ln $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/p/q/r/hlink
10854 mv $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/a/b/c/new_file
10855 FID=$($LFS path2fid $DIR/$tdir/d2/a/b/c/new_file | tr -d '[]')
10856 # fid2path dir/fsname should both work
10857 check_path "$tdir/d2/a/b/c/new_file" $FSNAME $FID --link 1 ||
10858 error "check path $tdir/d2/a/b/c/new_file failed"
10859 check_path "$DIR/$tdir/d2/p/q/r/hlink" $DIR $FID --link 0 ||
10860 error "check path $DIR/$tdir/d2/p/q/r/hlink failed"
10862 # hardlink count: check that there are 2 links
10863 # Doesnt work with CMD yet: 17935
10864 ${LFS} fid2path $DIR $FID | wc -l | grep -q 2 || \
10865 err17935 "expected 2 links"
10867 # hardlink indexing: remove the first link
10868 rm $DIR/$tdir/d2/p/q/r/hlink
10869 check_path "$tdir/d2/a/b/c/new_file" $FSNAME $FID --link 0 ||
10870 error "check path $DIR/$tdir/d2/a/b/c/new_file failed"
10874 run_test 162a "path lookup sanity"
10877 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10878 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
10881 $LFS setdirstripe -i0 -c$MDSCOUNT -t all_char $DIR/$tdir/striped_dir ||
10882 error "create striped dir failed"
10884 local FID=$($LFS getdirstripe $DIR/$tdir/striped_dir |
10885 tail -n 1 | awk '{print $2}')
10886 stat $MOUNT/.lustre/fid/$FID && error "sub_stripe can be accessed"
10888 touch $DIR/$tdir/striped_dir/f{0..4} || error "touch f0..4 failed"
10889 mkdir $DIR/$tdir/striped_dir/d{0..4} || error "mkdir d0..4 failed"
10892 for ((i=0;i<5;i++)); do
10893 FID=$($LFS path2fid $DIR/$tdir/striped_dir/f$i | tr -d '[]') ||
10894 error "get fid for f$i failed"
10895 check_path "$tdir/striped_dir/f$i" $FSNAME $FID --link 0 ||
10896 error "check path $tdir/striped_dir/f$i failed"
10898 FID=$($LFS path2fid $DIR/$tdir/striped_dir/d$i | tr -d '[]') ||
10899 error "get fid for d$i failed"
10900 check_path "$tdir/striped_dir/d$i" $FSNAME $FID --link 0 ||
10901 error "check path $tdir/striped_dir/d$i failed"
10906 run_test 162b "striped directory path lookup sanity"
10908 # LU-4239: Verify fid2path works with paths 100 or more directories deep
10910 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.51) ]] &&
10911 skip "Need MDS version at least 2.7.51" && return
10912 test_mkdir $DIR/$tdir.local
10913 test_mkdir $DIR/$tdir.remote
10914 local lpath=$tdir.local
10915 local rpath=$tdir.remote
10917 for ((i = 0; i <= 101; i++)); do
10920 FID=$($LFS path2fid $DIR/$lpath | tr -d '[]') ||
10921 error "get fid for local directory $DIR/$lpath failed"
10922 check_path "$DIR/$lpath" $MOUNT $FID --link 0 ||
10923 error "check path for local directory $DIR/$lpath failed"
10926 test_mkdir $DIR/$rpath
10927 FID=$($LFS path2fid $DIR/$rpath | tr -d '[]') ||
10928 error "get fid for remote directory $DIR/$rpath failed"
10929 check_path "$DIR/$rpath" $MOUNT $FID --link 0 ||
10930 error "check path for remote directory $DIR/$rpath failed"
10935 run_test 162c "fid2path works with paths 100 or more directories deep"
10938 # do directio so as not to populate the page cache
10939 log "creating a 10 Mb file"
10940 $MULTIOP $DIR/$tfile oO_CREAT:O_DIRECT:O_RDWR:w$((10*1048576))c || error "multiop failed while creating a file"
10941 log "starting reads"
10942 dd if=$DIR/$tfile of=/dev/null bs=4096 &
10943 log "truncating the file"
10944 $MULTIOP $DIR/$tfile oO_TRUNC:c || error "multiop failed while truncating the file"
10946 kill %+ || true # reads might have finished
10947 echo "wait until dd is finished"
10949 log "removing the temporary file"
10950 rm -rf $DIR/$tfile || error "tmp file removal failed"
10952 run_test 169 "parallel read and truncate should not deadlock"
10955 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10956 $LCTL clear # bug 18514
10957 $LCTL debug_daemon start $TMP/${tfile}_log_good
10959 $LCTL debug_daemon stop
10960 sed -e "s/^...../a/g" $TMP/${tfile}_log_good > $TMP/${tfile}_log_bad ||
10961 error "sed failed to read log_good"
10963 $LCTL debug_daemon start $TMP/${tfile}_log_good
10965 $LCTL debug_daemon stop
10967 $LCTL df $TMP/${tfile}_log_bad > $TMP/${tfile}_log_bad.out 2>&1 ||
10968 error "lctl df log_bad failed"
10970 local bad_line=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $9}')
10971 local good_line1=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $5}')
10973 $LCTL df $TMP/${tfile}_log_good > $TMP/${tfile}_log_good.out 2>&1
10974 local good_line2=$(tail -n 1 $TMP/${tfile}_log_good.out | awk '{print $5}')
10976 [ "$bad_line" ] && [ "$good_line1" ] && [ "$good_line2" ] ||
10977 error "bad_line good_line1 good_line2 are empty"
10979 cat $TMP/${tfile}_log_good >> $TMP/${tfile}_logs_corrupt
10980 cat $TMP/${tfile}_log_bad >> $TMP/${tfile}_logs_corrupt
10981 cat $TMP/${tfile}_log_good >> $TMP/${tfile}_logs_corrupt
10983 $LCTL df $TMP/${tfile}_logs_corrupt > $TMP/${tfile}_log_bad.out 2>&1
10984 local bad_line_new=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $9}')
10985 local good_line_new=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $5}')
10987 [ "$bad_line_new" ] && [ "$good_line_new" ] ||
10988 error "bad_line_new good_line_new are empty"
10990 local expected_good=$((good_line1 + good_line2*2))
10992 rm -f $TMP/${tfile}*
10993 # LU-231, short malformed line may not be counted into bad lines
10994 if [ $bad_line -ne $bad_line_new ] &&
10995 [ $bad_line -ne $((bad_line_new - 1)) ]; then
10996 error "expected $bad_line bad lines, but got $bad_line_new"
11000 if [ $expected_good -ne $good_line_new ]; then
11001 error "expected $expected_good good lines, but got $good_line_new"
11006 run_test 170 "test lctl df to handle corrupted log ====================="
11008 test_171() { # bug20592
11009 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11010 #define OBD_FAIL_PTLRPC_DUMP_LOG 0x50e
11011 $LCTL set_param fail_loc=0x50e
11012 $LCTL set_param fail_val=3000
11013 multiop_bg_pause $DIR/$tfile O_s || true
11015 kill -USR1 $MULTIPID
11019 if dmesg | grep "recursive fault"; then
11020 error "caught a recursive fault"
11022 $LCTL set_param fail_loc=0
11025 run_test 171 "test libcfs_debug_dumplog_thread stuck in do_exit() ======"
11027 # it would be good to share it with obdfilter-survey/iokit-libecho code
11028 setup_obdecho_osc () {
11031 local obdfilter_name=$2
11032 echo "Creating new osc for $obdfilter_name on $ost_nid"
11033 # make sure we can find loopback nid
11034 $LCTL add_uuid $ost_nid $ost_nid >/dev/null 2>&1
11036 [ $rc -eq 0 ] && { $LCTL attach osc ${obdfilter_name}_osc \
11037 ${obdfilter_name}_osc_UUID || rc=2; }
11038 [ $rc -eq 0 ] && { $LCTL --device ${obdfilter_name}_osc setup \
11039 ${obdfilter_name}_UUID $ost_nid || rc=3; }
11043 cleanup_obdecho_osc () {
11044 local obdfilter_name=$1
11045 $LCTL --device ${obdfilter_name}_osc cleanup >/dev/null
11046 $LCTL --device ${obdfilter_name}_osc detach >/dev/null
11053 local pages=${3:-64}
11058 local obd_size=$(get_obd_size $node $OBD)
11059 local page_size=$(get_page_size $node)
11060 if [[ -n "$obd_size" ]]; then
11061 local new_count=$((obd_size / (pages * page_size / 1024)))
11062 [[ $new_count -ge $count ]] || count=$new_count
11065 do_facet $node "$LCTL attach echo_client ec ec_uuid" || rc=1
11066 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec setup $OBD" ||
11068 if [ $rc -eq 0 ]; then
11069 id=$(do_facet $node "$LCTL --device ec create 1" | awk '/object id/ {print $6}')
11070 [ ${PIPESTATUS[0]} -eq 0 -a -n "$id" ] || rc=3
11072 echo "New object id is $id"
11073 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec getattr $id" ||
11075 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec " \
11076 "test_brw $count w v $pages $id" || rc=4; }
11077 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec destroy $id 1" ||
11079 [ $rc -eq 0 -o $rc -gt 2 ] && { do_facet $node "$LCTL --device ec " \
11080 "cleanup" || rc=5; }
11081 [ $rc -eq 0 -o $rc -gt 1 ] && { do_facet $node "$LCTL --device ec " \
11082 "detach" || rc=6; }
11083 [ $rc -ne 0 ] && echo "obecho_create_test failed: $rc"
11088 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11089 remote_ost_nodsh && skip "remote OST with nodsh" && return
11091 local rmmod_local=0
11093 if ! module_loaded obdecho; then
11094 load_module obdecho/obdecho
11098 local osc=$($LCTL dl | grep -v mdt | awk '$3 == "osc" {print $4; exit}')
11099 local host=$(lctl get_param -n osc.$osc.import |
11100 awk '/current_connection:/ {print $2}' )
11101 local target=$(lctl get_param -n osc.$osc.import |
11102 awk '/target:/ {print $2}' )
11103 target=${target%_UUID}
11105 [[ -n $target ]] && { setup_obdecho_osc $host $target || rc=1; } || rc=1
11106 [ $rc -eq 0 ] && { obdecho_test ${target}_osc client || rc=2; }
11107 [[ -n $target ]] && cleanup_obdecho_osc $target
11108 [ $rmmod_local -eq 1 ] && rmmod obdecho
11111 run_test 180a "test obdecho on osc"
11114 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11115 remote_ost_nodsh && skip "remote OST with nodsh" && return
11117 local rmmod_remote=0
11119 do_facet ost1 "lsmod | grep -q obdecho || " \
11120 "{ insmod ${LUSTRE}/obdecho/obdecho.ko || " \
11121 "modprobe obdecho; }" && rmmod_remote=1
11122 target=$(do_facet ost1 $LCTL dl | awk '/obdfilter/ {print $4;exit}')
11123 [[ -n $target ]] && { obdecho_test $target ost1 || rc=1; }
11124 [ $rmmod_remote -eq 1 ] && do_facet ost1 "rmmod obdecho"
11127 run_test 180b "test obdecho directly on obdfilter"
11129 test_180c() { # LU-2598
11130 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11131 remote_ost_nodsh && skip "remote OST with nodsh" && return
11132 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.0) ]] &&
11133 skip "Need MDS version at least 2.4.0" && return
11136 local rmmod_remote=false
11137 local pages=16384 # 64MB bulk I/O RPC size
11140 do_rpc_nodes $(facet_active_host ost1) load_module obdecho/obdecho &&
11141 rmmod_remote=true || error "failed to load module obdecho"
11143 target=$(do_facet ost1 $LCTL dl | awk '/obdfilter/ { print $4 }' |
11145 if [ -n "$target" ]; then
11146 obdecho_test "$target" ost1 "$pages" || rc=${PIPESTATUS[0]}
11148 echo "there is no obdfilter target on ost1"
11151 $rmmod_remote && do_facet ost1 "rmmod obdecho" || true
11154 run_test 180c "test huge bulk I/O size on obdfilter, don't LASSERT"
11156 test_181() { # bug 22177
11157 test_mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
11158 # create enough files to index the directory
11159 createmany -o $DIR/$tdir/foobar 4000
11160 # print attributes for debug purpose
11163 multiop_bg_pause $DIR/$tdir D_Sc || return 1
11165 # remove the files & current working dir
11166 unlinkmany $DIR/$tdir/foobar 4000
11168 kill -USR1 $MULTIPID
11170 stat $DIR/$tdir && error "open-unlinked dir was not removed!"
11173 run_test 181 "Test open-unlinked dir ========================"
11179 mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
11181 $LCTL set_param mdc.*.rpc_stats=clear
11183 for (( i = 0; i < $tcount; i++ )) ; do
11184 mkdir $DIR/$tdir/$i
11187 for (( i = 0; i < $tcount; i++ )) ; do
11188 createmany -o $DIR/$tdir/$i/f- $fcount &
11192 for (( i = 0; i < $tcount; i++ )) ; do
11193 unlinkmany $DIR/$tdir/$i/f- $fcount &
11197 $LCTL get_param mdc.*.rpc_stats
11201 run_test 182 "Test parallel modify metadata operations ================"
11203 test_183() { # LU-2275
11204 remote_mds_nodsh && skip "remote MDS with nodsh" && return
11205 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.3.56) ]] &&
11206 skip "Need MDS version at least 2.3.56" && return
11208 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11209 mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
11210 echo aaa > $DIR/$tdir/$tfile
11212 #define OBD_FAIL_MDS_NEGATIVE_POSITIVE 0x148
11213 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x148
11215 ls -l $DIR/$tdir && error "ls succeeded, should have failed"
11216 cat $DIR/$tdir/$tfile && error "cat succeeded, should have failed"
11218 do_facet $SINGLEMDS $LCTL set_param fail_loc=0
11220 # Flush negative dentry cache
11221 touch $DIR/$tdir/$tfile
11223 # We are not checking for any leaked references here, they'll
11224 # become evident next time we do cleanup with module unload.
11227 run_test 183 "No crash or request leak in case of strange dispositions ========"
11229 # test suite 184 is for LU-2016, LU-2017
11231 check_swap_layouts_support && return 0
11233 dir0=$DIR/$tdir/$testnum
11234 test_mkdir -p -c1 $dir0 || error "creating dir $dir0"
11239 $SETSTRIPE -c1 $file1
11241 $SETSTRIPE -c2 $file2
11243 gen1=$($GETSTRIPE -g $file1)
11244 gen2=$($GETSTRIPE -g $file2)
11246 $LFS swap_layouts $file1 $file2 || error "swap of file layout failed"
11247 gen=$($GETSTRIPE -g $file1)
11248 [[ $gen1 != $gen ]] ||
11249 "Layout generation on $file1 does not change"
11250 gen=$($GETSTRIPE -g $file2)
11251 [[ $gen2 != $gen ]] ||
11252 "Layout generation on $file2 does not change"
11254 cmp $ref1 $file2 || error "content compare failed ($ref1 != $file2)"
11255 cmp $ref2 $file1 || error "content compare failed ($ref2 != $file1)"
11257 run_test 184a "Basic layout swap"
11260 check_swap_layouts_support && return 0
11262 dir0=$DIR/$tdir/$testnum
11263 mkdir -p $dir0 || error "creating dir $dir0"
11270 $SETSTRIPE -c1 $file1
11271 $SETSTRIPE -c2 $file2
11272 $SETSTRIPE -c1 $file3
11273 chown $RUNAS_ID $file3
11274 gen1=$($GETSTRIPE -g $file1)
11275 gen2=$($GETSTRIPE -g $file2)
11277 $LFS swap_layouts $dir1 $dir2 &&
11278 error "swap of directories layouts should fail"
11279 $LFS swap_layouts $dir1 $file1 &&
11280 error "swap of directory and file layouts should fail"
11281 $RUNAS $LFS swap_layouts $file1 $file2 &&
11282 error "swap of file we cannot write should fail"
11283 $LFS swap_layouts $file1 $file3 &&
11284 error "swap of file with different owner should fail"
11285 /bin/true # to clear error code
11287 run_test 184b "Forbidden layout swap (will generate errors)"
11290 check_swap_layouts_support && return 0
11292 local dir0=$DIR/$tdir/$testnum
11293 mkdir -p $dir0 || error "creating dir $dir0"
11295 local ref1=$dir0/ref1
11296 local ref2=$dir0/ref2
11297 local file1=$dir0/file1
11298 local file2=$dir0/file2
11299 # create a file large enough for the concurrent test
11300 dd if=/dev/urandom of=$ref1 bs=1M count=$((RANDOM % 50 + 20))
11301 dd if=/dev/urandom of=$ref2 bs=1M count=$((RANDOM % 50 + 20))
11302 echo "ref file size: ref1($(stat -c %s $ref1))," \
11303 "ref2($(stat -c %s $ref2))"
11306 dd if=$ref1 of=$file1 bs=16k &
11309 # Make sure dd starts to copy file
11310 while [ ! -f $file1 ]; do sleep 0.1; done
11312 $LFS swap_layouts $file1 $file2
11315 [[ $? == 0 ]] || error "concurrent write on $file1 failed"
11316 [[ $rc == 0 ]] || error "swap of $file1 and $file2 failed"
11318 # how many bytes copied before swapping layout
11319 local copied=$(stat -c %s $file2)
11320 local remaining=$(stat -c %s $ref1)
11321 remaining=$((remaining - copied))
11322 echo "Copied $copied bytes before swapping layout..."
11324 cmp -n $copied $file1 $ref2 | grep differ &&
11325 error "Content mismatch [0, $copied) of ref2 and file1"
11326 cmp -n $copied $file2 $ref1 ||
11327 error "Content mismatch [0, $copied) of ref1 and file2"
11328 cmp -i $copied:$copied -n $remaining $file1 $ref1 ||
11329 error "Content mismatch [$copied, EOF) of ref1 and file1"
11332 rm -f $ref1 $ref2 $file1 $file2
11334 run_test 184c "Concurrent write and layout swap"
11337 check_swap_layouts_support && return 0
11338 [ -z "$(which getfattr 2>/dev/null)" ] &&
11339 skip "no getfattr command" && return 0
11341 local file1=$DIR/$tdir/$tfile-1
11342 local file2=$DIR/$tdir/$tfile-2
11343 local file3=$DIR/$tdir/$tfile-3
11347 mkdir -p $DIR/$tdir
11348 touch $file1 || error "create $file1 failed"
11349 $OPENFILE -f O_CREAT:O_LOV_DELAY_CREATE $file2 ||
11350 error "create $file2 failed"
11351 $OPENFILE -f O_CREAT:O_LOV_DELAY_CREATE $file3 ||
11352 error "create $file3 failed"
11353 lovea1=$($LFS getstripe $file1 | sed 1d)
11355 $LFS swap_layouts $file2 $file3 ||
11356 error "swap $file2 $file3 layouts failed"
11357 $LFS swap_layouts $file1 $file2 ||
11358 error "swap $file1 $file2 layouts failed"
11360 lovea2=$($LFS getstripe $file2 | sed 1d)
11361 [ "$lovea1" == "$lovea2" ] || error "lovea $lovea1 != $lovea2"
11363 lovea1=$(getfattr -n trusted.lov $file1 | grep ^trusted)
11364 [[ -z "$lovea1" ]] || error "$file1 shouldn't have lovea"
11366 run_test 184d "allow stripeless layouts swap"
11369 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.6.94) ]] ||
11370 { skip "Need MDS version at least 2.6.94"; return 0; }
11371 check_swap_layouts_support && return 0
11372 [ -z "$(which getfattr 2>/dev/null)" ] &&
11373 skip "no getfattr command" && return 0
11375 local file1=$DIR/$tdir/$tfile-1
11376 local file2=$DIR/$tdir/$tfile-2
11377 local file3=$DIR/$tdir/$tfile-3
11380 mkdir -p $DIR/$tdir
11381 touch $file1 || error "create $file1 failed"
11382 $OPENFILE -f O_CREAT:O_LOV_DELAY_CREATE $file2 ||
11383 error "create $file2 failed"
11384 $OPENFILE -f O_CREAT:O_LOV_DELAY_CREATE $file3 ||
11385 error "create $file3 failed"
11387 $LFS swap_layouts $file1 $file2 ||
11388 error "swap $file1 $file2 layouts failed"
11390 lovea=$(getfattr -n trusted.lov $file1 | grep ^trusted)
11391 [[ -z "$lovea" ]] || error "$file1 shouldn't have lovea"
11393 echo 123 > $file1 || error "Should be able to write into $file1"
11395 $LFS swap_layouts $file1 $file3 ||
11396 error "swap $file1 $file3 layouts failed"
11398 echo 123 > $file1 || error "Should be able to write into $file1"
11400 rm -rf $file1 $file2 $file3
11402 run_test 184e "Recreate layout after stripeless layout swaps"
11404 test_185() { # LU-2441
11405 # LU-3553 - no volatile file support in old servers
11406 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.3.60) ]] ||
11407 { skip "Need MDS version at least 2.3.60"; return 0; }
11409 mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
11410 touch $DIR/$tdir/spoo
11411 local mtime1=$(stat -c "%Y" $DIR/$tdir)
11412 local fid=$($MULTIOP $DIR/$tdir VFw4096c) ||
11413 error "cannot create/write a volatile file"
11414 $CHECKSTAT -t file $MOUNT/.lustre/fid/$fid 2>/dev/null &&
11415 error "FID is still valid after close"
11417 multiop_bg_pause $DIR/$tdir vVw4096_c
11424 # assume that the next FID for this client is sequential, since stdout
11425 # is unfortunately eaten by multiop_bg_pause
11426 local n=$((${fidv[1]} + 1))
11427 local next_fid="${fidv[0]}:$(printf "0x%x" $n):${fidv[2]}"
11428 $CHECKSTAT -t file $MOUNT/.lustre/fid/$next_fid ||
11429 error "FID is missing before close"
11430 kill -USR1 $multi_pid
11431 # 1 second delay, so if mtime change we will see it
11433 local mtime2=$(stat -c "%Y" $DIR/$tdir)
11434 [[ $mtime1 == $mtime2 ]] || error "mtime has changed"
11436 run_test 185 "Volatile file support"
11439 remote_mds_nodsh && skip "remote MDS with nodsh" && return
11440 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.3.0) ] &&
11441 skip "Need MDS version at least 2.3.0" && return
11443 local dir0=$DIR/$tdir/$testnum
11444 mkdir -p $dir0 || error "creating dir $dir0"
11446 local file=$dir0/file1
11447 dd if=/dev/urandom of=$file count=10 bs=1M conv=fsync
11448 local dv1=$($LFS data_version $file)
11449 dd if=/dev/urandom of=$file seek=10 count=1 bs=1M conv=fsync
11450 local dv2=$($LFS data_version $file)
11451 [[ $dv1 != $dv2 ]] ||
11452 error "data version did not change on write $dv1 == $dv2"
11457 run_test 187a "Test data version change"
11460 remote_mds_nodsh && skip "remote MDS with nodsh" && return
11461 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.3.0) ] &&
11462 skip "Need MDS version at least 2.3.0" && return
11464 local dir0=$DIR/$tdir/$testnum
11465 mkdir -p $dir0 || error "creating dir $dir0"
11467 declare -a DV=$($MULTIOP $dir0 Vw1000xYw1000xY | cut -f3 -d" ")
11468 [[ ${DV[0]} != ${DV[1]} ]] ||
11469 error "data version did not change on write"\
11470 " ${DV[0]} == ${DV[1]}"
11475 run_test 187b "Test data version change on volatile file"
11478 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11479 remote_mgs_nodsh && skip "remote MGS with nodsh" && return
11481 local POOL=${POOL:-cea1}
11482 local POOL_ROOT=${POOL_ROOT:-$DIR/d200.pools}
11483 local POOL_DIR_NAME=${POOL_DIR_NAME:-dir_tst}
11486 local last_ost=$(($OSTCOUNT - 1))
11488 local ost_list=$(seq $first_ost $ost_step $last_ost)
11489 local ost_range="$first_ost $last_ost $ost_step"
11490 local test_path=$POOL_ROOT/$POOL_DIR_NAME
11491 local file_dir=$POOL_ROOT/file_tst
11492 local subdir=$test_path/subdir
11496 # former test_200a test_200b
11497 pool_add $POOL || { rc=$? ; break; }
11498 pool_add_targets $POOL $ost_range || { rc=$? ; break; }
11499 # former test_200c test_200d
11500 mkdir -p $test_path
11501 pool_set_dir $POOL $test_path || { rc=$? ; break; }
11502 pool_check_dir $POOL $test_path || { rc=$? ; break; }
11504 pool_check_dir $POOL $subdir || { rc=$? ; break; }
11505 pool_dir_rel_path $POOL $POOL_DIR_NAME $POOL_ROOT \
11506 || { rc=$? ; break; }
11507 # former test_200e test_200f
11508 local files=$((OSTCOUNT*3))
11509 pool_alloc_files $POOL $test_path $files "$ost_list" \
11510 || { rc=$? ; break; }
11511 pool_create_files $POOL $file_dir $files "$ost_list" \
11512 || { rc=$? ; break; }
11513 # former test_200g test_200h
11514 pool_lfs_df $POOL || { rc=$? ; break; }
11515 pool_file_rel_path $POOL $test_path || { rc=$? ; break; }
11517 # former test_201a test_201b test_201c
11518 pool_remove_first_target $POOL || { rc=$? ; break; }
11520 local f=$test_path/$tfile
11521 pool_remove_all_targets $POOL $f || { rc=$? ; break; }
11522 pool_remove $POOL $f || { rc=$? ; break; }
11529 run_test 200 "OST pools"
11531 # usage: default_attr <count | size | offset>
11533 $LCTL get_param -n lov.$FSNAME-clilov-\*.stripe${1}
11536 # usage: check_default_stripe_attr
11537 check_default_stripe_attr() {
11538 ACTUAL=$($GETSTRIPE $* $DIR/$tdir)
11540 --stripe-count|--count)
11541 [ -n "$2" ] && EXPECTED=0 || EXPECTED=$(default_attr count);;
11542 --stripe-size|--size)
11543 [ -n "$2" ] && EXPECTED=0 || EXPECTED=$(default_attr size);;
11544 --stripe-index|--index)
11547 error "unknown getstripe attr '$1'"
11550 [ $ACTUAL != $EXPECTED ] &&
11551 error "$DIR/$tdir has $1 '$ACTUAL', not '$EXPECTED'"
11555 test_mkdir -p $DIR/$tdir
11556 $SETSTRIPE --stripe-count 0 --stripe-size 0 --stripe-index -1 $DIR/$tdir
11558 check_default_stripe_attr --stripe-count
11559 check_default_stripe_attr --stripe-size
11560 check_default_stripe_attr --stripe-index
11564 run_test 204a "Print default stripe attributes ================="
11567 test_mkdir -p $DIR/$tdir
11568 $SETSTRIPE --stripe-count 1 $DIR/$tdir
11570 check_default_stripe_attr --stripe-size
11571 check_default_stripe_attr --stripe-index
11575 run_test 204b "Print default stripe size and offset ==========="
11578 test_mkdir -p $DIR/$tdir
11579 $SETSTRIPE --stripe-size 65536 $DIR/$tdir
11581 check_default_stripe_attr --stripe-count
11582 check_default_stripe_attr --stripe-index
11586 run_test 204c "Print default stripe count and offset ==========="
11589 test_mkdir -p $DIR/$tdir
11590 $SETSTRIPE --stripe-index 0 $DIR/$tdir
11592 check_default_stripe_attr --stripe-count
11593 check_default_stripe_attr --stripe-size
11597 run_test 204d "Print default stripe count and size ============="
11600 test_mkdir -p $DIR/$tdir
11601 $SETSTRIPE -d $DIR/$tdir
11603 check_default_stripe_attr --stripe-count --raw
11604 check_default_stripe_attr --stripe-size --raw
11605 check_default_stripe_attr --stripe-index --raw
11609 run_test 204e "Print raw stripe attributes ================="
11612 test_mkdir -p $DIR/$tdir
11613 $SETSTRIPE --stripe-count 1 $DIR/$tdir
11615 check_default_stripe_attr --stripe-size --raw
11616 check_default_stripe_attr --stripe-index --raw
11620 run_test 204f "Print raw stripe size and offset ==========="
11623 test_mkdir -p $DIR/$tdir
11624 $SETSTRIPE --stripe-size 65536 $DIR/$tdir
11626 check_default_stripe_attr --stripe-count --raw
11627 check_default_stripe_attr --stripe-index --raw
11631 run_test 204g "Print raw stripe count and offset ==========="
11634 test_mkdir -p $DIR/$tdir
11635 $SETSTRIPE --stripe-index 0 $DIR/$tdir
11637 check_default_stripe_attr --stripe-count --raw
11638 check_default_stripe_attr --stripe-size --raw
11642 run_test 204h "Print raw stripe count and size ============="
11644 # Figure out which job scheduler is being used, if any,
11645 # or use a fake one
11646 if [ -n "$SLURM_JOB_ID" ]; then # SLURM
11647 JOBENV=SLURM_JOB_ID
11648 elif [ -n "$LSB_JOBID" ]; then # Load Sharing Facility
11650 elif [ -n "$PBS_JOBID" ]; then # PBS/Maui/Moab
11652 elif [ -n "$LOADL_STEPID" ]; then # LoadLeveller
11653 JOBENV=LOADL_STEP_ID
11654 elif [ -n "$JOB_ID" ]; then # Sun Grid Engine
11657 $LCTL list_param jobid_name > /dev/null 2>&1
11658 if [ $? -eq 0 ]; then
11665 verify_jobstats() {
11670 # we don't really need to clear the stats for this test to work, since each
11671 # command has a unique jobid, but it makes debugging easier if needed.
11672 # for facet in $facets; do
11673 # local dev=$(convert_facet2label $facet)
11674 # # clear old jobstats
11675 # do_facet $facet lctl set_param *.$dev.job_stats="clear"
11678 # use a new JobID for each test, or we might see an old one
11679 [ "$JOBENV" = "FAKE_JOBID" ] &&
11680 FAKE_JOBID=id.$testnum.$(basename ${cmd[0]}).$RANDOM
11684 [ "$JOBENV" = "nodelocal" ] && {
11685 FAKE_JOBID=id.$testnum.$(basename ${cmd[0]}).$RANDOM
11686 $LCTL set_param jobid_name=$FAKE_JOBID
11690 log "Test: ${cmd[*]}"
11691 log "Using JobID environment variable $JOBENV=$JOBVAL"
11693 if [ $JOBENV = "FAKE_JOBID" ]; then
11694 FAKE_JOBID=$JOBVAL ${cmd[*]}
11699 # all files are created on OST0000
11700 for facet in $facets; do
11701 local stats="*.$(convert_facet2label $facet).job_stats"
11702 if [ $(do_facet $facet lctl get_param $stats |
11703 grep -c $JOBVAL) -ne 1 ]; then
11704 do_facet $facet lctl get_param $stats
11705 error "No jobstats for $JOBVAL found on $facet::$stats"
11712 NEW_JOBENV=${1:-$OLD_JOBENV}
11713 do_facet mgs $LCTL conf_param $FSNAME.sys.jobid_var=$NEW_JOBENV
11714 wait_update $HOSTNAME "$LCTL get_param -n jobid_var" $NEW_JOBENV
11718 do_facet $SINGLEMDS \
11719 $LCTL set_param mdt.*.job_cleanup_interval=$OLD_INTERVAL
11720 [ $OLD_JOBENV != $JOBENV ] && jobstats_set $OLD_JOBENV
11721 do_facet $SINGLEMDS lctl --device $MDT0 changelog_deregister $CL_USER
11724 test_205() { # Job stats
11725 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11726 remote_mgs_nodsh && skip "remote MGS with nodsh" && return
11727 remote_mds_nodsh && skip "remote MDS with nodsh" && return
11728 remote_ost_nodsh && skip "remote OST with nodsh" && return
11730 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep jobstats)" ] &&
11731 skip "Server doesn't support jobstats" && return 0
11732 [[ $JOBID_VAR = disable ]] && skip "jobstats is disabled" && return
11734 OLD_JOBENV=$($LCTL get_param -n jobid_var)
11735 if [ $OLD_JOBENV != $JOBENV ]; then
11736 jobstats_set $JOBENV
11737 trap cleanup_205 EXIT
11740 CL_USER=$(do_facet $SINGLEMDS lctl --device $MDT0 changelog_register -n)
11741 echo "Registered as changelog user $CL_USER"
11743 OLD_INTERVAL=$(do_facet $SINGLEMDS \
11744 lctl get_param -n mdt.*.job_cleanup_interval)
11745 local interval_new=5
11746 do_facet $SINGLEMDS \
11747 $LCTL set_param mdt.*.job_cleanup_interval=$interval_new
11748 local start=$SECONDS
11752 cmd="mkdir $DIR/$tdir"
11753 verify_jobstats "$cmd" "$SINGLEMDS"
11755 cmd="rmdir $DIR/$tdir"
11756 verify_jobstats "$cmd" "$SINGLEMDS"
11757 # mkdir on secondary MDT
11758 if [ $MDSCOUNT -gt 1 ]; then
11759 cmd="lfs mkdir -i 1 $DIR/$tdir.remote"
11760 verify_jobstats "$cmd" "mds2"
11763 cmd="mknod $DIR/$tfile c 1 3"
11764 verify_jobstats "$cmd" "$SINGLEMDS"
11766 cmd="rm -f $DIR/$tfile"
11767 verify_jobstats "$cmd" "$SINGLEMDS"
11768 # create all files on OST0000 so verify_jobstats can find OST stats
11770 cmd="$SETSTRIPE -i 0 -c 1 $DIR/$tfile"
11771 verify_jobstats "$cmd" "$SINGLEMDS"
11773 cmd="touch $DIR/$tfile"
11774 verify_jobstats "$cmd" "$SINGLEMDS ost1"
11776 cmd="dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 oflag=sync"
11777 verify_jobstats "$cmd" "ost1"
11779 cmd="dd if=$DIR/$tfile of=/dev/null bs=1M count=1 iflag=direct"
11780 verify_jobstats "$cmd" "ost1"
11782 cmd="$TRUNCATE $DIR/$tfile 0"
11783 verify_jobstats "$cmd" "$SINGLEMDS ost1"
11785 cmd="mv -f $DIR/$tfile $DIR/$tdir.rename"
11786 verify_jobstats "$cmd" "$SINGLEMDS"
11787 # jobstats expiry - sleep until old stats should be expired
11788 local left=$((interval_new + 2 - (SECONDS - start)))
11789 [ $left -ge 0 ] && echo "sleep $left for expiry" && sleep $((left + 1))
11790 cmd="mkdir $DIR/$tdir.expire"
11791 verify_jobstats "$cmd" "$SINGLEMDS"
11792 [ $(do_facet $SINGLEMDS lctl get_param *.*.job_stats |
11793 grep -c "job_id.*mkdir") -gt 1 ] && error "old jobstats not expired"
11795 # Ensure that jobid are present in changelog (if supported by MDS)
11796 if [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.6.52) ]
11798 $LFS changelog $MDT0 | tail -9
11799 jobids=$($LFS changelog $MDT0 | tail -9 | grep -c "j=")
11800 [ $jobids -eq 9 ] ||
11801 error "Wrong changelog jobid count $jobids != 9"
11805 jobstats_set $JOBENV
11807 $LFS changelog $MDT0 | tail -1
11808 jobids=$($LFS changelog $MDT0 | tail -1 | grep -c "j=")
11809 [ $jobids -eq 0 ] ||
11810 error "Unexpected jobids when jobid_var=$JOBENV"
11815 run_test 205 "Verify job stats"
11817 # LU-1480, LU-1773 and LU-1657
11819 mkdir -p $DIR/$tdir
11820 $SETSTRIPE -c -1 $DIR/$tdir
11821 #define OBD_FAIL_LOV_INIT 0x1403
11822 $LCTL set_param fail_loc=0xa0001403
11823 $LCTL set_param fail_val=1
11824 touch $DIR/$tdir/$tfile || true
11826 run_test 206 "fail lov_init_raid0() doesn't lbug"
11829 dd if=/dev/zero of=$DIR/$tfile bs=4k count=$((RANDOM%10+1))
11830 local fsz=`stat -c %s $DIR/$tfile`
11831 cancel_lru_locks mdc
11833 # do not return layout in getattr intent
11834 #define OBD_FAIL_MDS_NO_LL_GETATTR 0x170
11835 $LCTL set_param fail_loc=0x170
11836 local sz=`stat -c %s $DIR/$tfile`
11838 [ $fsz -eq $sz ] || error "file size expected $fsz, actual $sz"
11842 run_test 207a "can refresh layout at glimpse"
11845 dd if=/dev/zero of=$DIR/$tfile bs=4k count=$((RANDOM%10+1))
11846 local cksum=`md5sum $DIR/$tfile`
11847 local fsz=`stat -c %s $DIR/$tfile`
11848 cancel_lru_locks mdc
11849 cancel_lru_locks osc
11851 # do not return layout in getattr intent
11852 #define OBD_FAIL_MDS_NO_LL_OPEN 0x171
11853 $LCTL set_param fail_loc=0x171
11855 # it will refresh layout after the file is opened but before read issues
11856 echo checksum is "$cksum"
11857 echo "$cksum" |md5sum -c --quiet || error "file differs"
11861 run_test 207b "can refresh layout at open"
11864 # FIXME: in this test suite, only RD lease is used. This is okay
11865 # for now as only exclusive open is supported. After generic lease
11866 # is done, this test suite should be revised. - Jinshan
11868 remote_mds_nodsh && skip "remote MDS with nodsh" && return
11869 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.4.52) ]] ||
11870 { skip "Need MDS version at least 2.4.52"; return 0; }
11872 echo "==== test 1: verify get lease work"
11873 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:eRE+eU || error "get lease error"
11875 echo "==== test 2: verify lease can be broken by upcoming open"
11876 $MULTIOP $DIR/$tfile oO_RDONLY:eR_E-eUc &
11880 $MULTIOP $DIR/$tfile oO_RDONLY:c
11881 kill -USR1 $PID && wait $PID || error "break lease error"
11883 echo "==== test 3: verify lease can't be granted if an open already exists"
11884 $MULTIOP $DIR/$tfile oO_RDONLY:_c &
11888 $MULTIOP $DIR/$tfile oO_RDONLY:eReUc && error "apply lease should fail"
11889 kill -USR1 $PID && wait $PID || error "open file error"
11891 echo "==== test 4: lease can sustain over recovery"
11892 $MULTIOP $DIR/$tfile oO_RDONLY:eR_E+eUc &
11898 kill -USR1 $PID && wait $PID || error "lease broken over recovery"
11900 echo "==== test 5: lease broken can't be regained by replay"
11901 $MULTIOP $DIR/$tfile oO_RDONLY:eR_E-eUc &
11905 # open file to break lease and then recovery
11906 $MULTIOP $DIR/$tfile oO_RDWR:c || error "open file error"
11909 kill -USR1 $PID && wait $PID || error "lease not broken over recovery"
11913 run_test 208 "Exclusive open"
11916 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep disp_stripe)" ] &&
11917 skip_env "must have disp_stripe" && return
11920 sync; sleep 5; sync;
11922 echo 3 > /proc/sys/vm/drop_caches
11923 req_before=$(awk '/ptlrpc_cache / { print $2 }' /proc/slabinfo)
11925 # open/close 500 times
11926 for i in $(seq 500); do
11930 echo 3 > /proc/sys/vm/drop_caches
11931 req_after=$(awk '/ptlrpc_cache / { print $2 }' /proc/slabinfo)
11933 echo "before: $req_before, after: $req_after"
11934 [ $((req_after - req_before)) -ge 300 ] &&
11935 error "open/close requests are not freed"
11938 run_test 209 "read-only open/close requests should be freed promptly"
11942 size=$((size % 8192 + 1))
11943 dd if=/dev/urandom of=$DIR/f212 bs=1k count=$size
11944 sendfile $DIR/f212 $DIR/f212.xyz || error "sendfile wrong"
11945 rm -f $DIR/f212 $DIR/f212.xyz
11947 run_test 212 "Sendfile test ============================================"
11950 dd if=/dev/zero of=$DIR/$tfile bs=4k count=4
11951 cancel_lru_locks osc
11952 lctl set_param fail_loc=0x8000040f
11953 # generate a read lock
11954 cat $DIR/$tfile > /dev/null
11955 # write to the file, it will try to cancel the above read lock.
11956 cat /etc/hosts >> $DIR/$tfile
11958 run_test 213 "OSC lock completion and cancel race don't crash - bug 18829"
11960 test_214() { # for bug 20133
11961 mkdir -p $DIR/$tdir/d214c || error "mkdir $DIR/$tdir/d214c failed"
11962 for (( i=0; i < 340; i++ )) ; do
11963 touch $DIR/$tdir/d214c/a$i
11966 ls -l $DIR/$tdir || error "ls -l $DIR/d214p failed"
11967 mv $DIR/$tdir/d214c $DIR/ || error "mv $DIR/d214p/d214c $DIR/ failed"
11968 ls $DIR/d214c || error "ls $DIR/d214c failed"
11969 rm -rf $DIR/$tdir || error "rm -rf $DIR/d214* failed"
11970 rm -rf $DIR/d214* || error "rm -rf $DIR/d214* failed"
11972 run_test 214 "hash-indexed directory test - bug 20133"
11974 # having "abc" as 1st arg, creates $TMP/lnet_abc.out and $TMP/lnet_abc.sys
11975 create_lnet_proc_files() {
11976 lctl get_param -n $1 >$TMP/lnet_$1.out || error "cannot read lnet.$1"
11977 sysctl lnet.$1 >$TMP/lnet_$1.sys_tmp || error "cannot read lnet.$1"
11979 sed "s/^lnet.$1\ =\ //g" "$TMP/lnet_$1.sys_tmp" >$TMP/lnet_$1.sys
11980 rm -f "$TMP/lnet_$1.sys_tmp"
11983 # counterpart of create_lnet_proc_files
11984 remove_lnet_proc_files() {
11985 rm -f $TMP/lnet_$1.out $TMP/lnet_$1.sys
11988 # uses 1st arg as trailing part of filename, 2nd arg as description for reports,
11989 # 3rd arg as regexp for body
11990 check_lnet_proc_stats() {
11991 local l=$(cat "$TMP/lnet_$1" |wc -l)
11992 [ $l = 1 ] || (cat "$TMP/lnet_$1" && error "$2 is not of 1 line: $l")
11994 grep -E "$3" "$TMP/lnet_$1" || (cat "$TMP/lnet_$1" && error "$2 misformatted")
11997 # uses 1st arg as trailing part of filename, 2nd arg as description for reports,
11998 # 3rd arg as regexp for body, 4th arg as regexp for 1st line, 5th arg is
11999 # optional and can be regexp for 2nd line (lnet.routes case)
12000 check_lnet_proc_entry() {
12001 local blp=2 # blp stands for 'position of 1st line of body'
12002 [ -z "$5" ] || blp=3 # lnet.routes case
12004 local l=$(cat "$TMP/lnet_$1" |wc -l)
12005 # subtracting one from $blp because the body can be empty
12006 [ "$l" -ge "$(($blp - 1))" ] || (cat "$TMP/lnet_$1" && error "$2 is too short: $l")
12008 sed -n '1 p' "$TMP/lnet_$1" |grep -E "$4" >/dev/null ||
12009 (cat "$TMP/lnet_$1" && error "1st line of $2 misformatted")
12011 [ "$5" = "" ] || sed -n '2 p' "$TMP/lnet_$1" |grep -E "$5" >/dev/null ||
12012 (cat "$TMP/lnet_$1" && error "2nd line of $2 misformatted")
12014 # bail out if any unexpected line happened
12015 sed -n "$blp p" "$TMP/lnet_$1" | grep -Ev "$3"
12016 [ "$?" != 0 ] || error "$2 misformatted"
12019 test_215() { # for bugs 18102, 21079, 21517
12020 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12021 local N='(0|[1-9][0-9]*)' # non-negative numeric
12022 local P='[1-9][0-9]*' # positive numeric
12023 local I='(0|-?[1-9][0-9]*|NA)' # any numeric (0 | >0 | <0) or NA if no value
12024 local NET='[a-z][a-z0-9]*' # LNET net like o2ib2
12025 local ADDR='[0-9.]+' # LNET addr like 10.0.0.1
12026 local NID="$ADDR@$NET" # LNET nid like 10.0.0.1@o2ib2
12028 local L1 # regexp for 1st line
12029 local L2 # regexp for 2nd line (optional)
12030 local BR # regexp for the rest (body)
12032 # lnet.stats should look as 11 space-separated non-negative numerics
12033 BR="^$N $N $N $N $N $N $N $N $N $N $N$"
12034 create_lnet_proc_files "stats"
12035 check_lnet_proc_stats "stats.sys" "lnet.stats" "$BR"
12036 remove_lnet_proc_files "stats"
12038 # lnet.routes should look like this:
12039 # Routing disabled/enabled
12040 # net hops priority state router
12041 # where net is a string like tcp0, hops > 0, priority >= 0,
12042 # state is up/down,
12043 # router is a string like 192.168.1.1@tcp2
12044 L1="^Routing (disabled|enabled)$"
12045 L2="^net +hops +priority +state +router$"
12046 BR="^$NET +$N +(0|1) +(up|down) +$NID$"
12047 create_lnet_proc_files "routes"
12048 check_lnet_proc_entry "routes.sys" "lnet.routes" "$BR" "$L1" "$L2"
12049 remove_lnet_proc_files "routes"
12051 # lnet.routers should look like this:
12052 # ref rtr_ref alive_cnt state last_ping ping_sent deadline down_ni router
12053 # where ref > 0, rtr_ref > 0, alive_cnt >= 0, state is up/down,
12054 # last_ping >= 0, ping_sent is boolean (0/1), deadline and down_ni are
12055 # numeric (0 or >0 or <0), router is a string like 192.168.1.1@tcp2
12056 L1="^ref +rtr_ref +alive_cnt +state +last_ping +ping_sent +deadline +down_ni +router$"
12057 BR="^$P +$P +$N +(up|down) +$N +(0|1) +$I +$I +$NID$"
12058 create_lnet_proc_files "routers"
12059 check_lnet_proc_entry "routers.sys" "lnet.routers" "$BR" "$L1"
12060 remove_lnet_proc_files "routers"
12062 # lnet.peers should look like this:
12063 # nid refs state last max rtr min tx min queue
12064 # where nid is a string like 192.168.1.1@tcp2, refs > 0,
12065 # state is up/down/NA, max >= 0. last, rtr, min, tx, min are
12066 # numeric (0 or >0 or <0), queue >= 0.
12067 L1="^nid +refs +state +last +max +rtr +min +tx +min +queue$"
12068 BR="^$NID +$P +(up|down|NA) +$I +$N +$I +$I +$I +$I +$N$"
12069 create_lnet_proc_files "peers"
12070 check_lnet_proc_entry "peers.sys" "lnet.peers" "$BR" "$L1"
12071 remove_lnet_proc_files "peers"
12073 # lnet.buffers should look like this:
12074 # pages count credits min
12075 # where pages >=0, count >=0, credits and min are numeric (0 or >0 or <0)
12076 L1="^pages +count +credits +min$"
12077 BR="^ +$N +$N +$I +$I$"
12078 create_lnet_proc_files "buffers"
12079 check_lnet_proc_entry "buffers.sys" "lnet.buffers" "$BR" "$L1"
12080 remove_lnet_proc_files "buffers"
12082 # lnet.nis should look like this:
12083 # nid status alive refs peer rtr max tx min
12084 # where nid is a string like 192.168.1.1@tcp2, status is up/down,
12085 # alive is numeric (0 or >0 or <0), refs >= 0, peer >= 0,
12086 # rtr >= 0, max >=0, tx and min are numeric (0 or >0 or <0).
12087 L1="^nid +status +alive +refs +peer +rtr +max +tx +min$"
12088 BR="^$NID +(up|down) +$I +$N +$N +$N +$N +$I +$I$"
12089 create_lnet_proc_files "nis"
12090 check_lnet_proc_entry "nis.sys" "lnet.nis" "$BR" "$L1"
12091 remove_lnet_proc_files "nis"
12093 # can we successfully write to lnet.stats?
12094 lctl set_param -n stats=0 || error "cannot write to lnet.stats"
12095 sysctl -w lnet.stats=0 || error "cannot write to lnet.stats"
12097 run_test 215 "lnet exists and has proper content - bugs 18102, 21079, 21517"
12099 test_216() { # bug 20317
12100 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12101 remote_ost_nodsh && skip "remote OST with nodsh" && return
12104 local facets=$(get_facets OST)
12105 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
12107 save_lustre_params client "osc.*.contention_seconds" > $p
12108 save_lustre_params $facets \
12109 "ldlm.namespaces.filter-*.max_nolock_bytes" >> $p
12110 save_lustre_params $facets \
12111 "ldlm.namespaces.filter-*.contended_locks" >> $p
12112 save_lustre_params $facets \
12113 "ldlm.namespaces.filter-*.contention_seconds" >> $p
12116 # agressive lockless i/o settings
12117 for node in $(osts_nodes); do
12118 do_node $node 'lctl set_param -n ldlm.namespaces.filter-*.max_nolock_bytes 2000000; lctl set_param -n ldlm.namespaces.filter-*.contended_locks 0; lctl set_param -n ldlm.namespaces.filter-*.contention_seconds 60'
12120 lctl set_param -n osc.*.contention_seconds 60
12122 $DIRECTIO write $DIR/$tfile 0 10 4096
12123 $CHECKSTAT -s 40960 $DIR/$tfile
12125 # disable lockless i/o
12126 for node in $(osts_nodes); do
12127 do_node $node 'lctl set_param -n ldlm.namespaces.filter-*.max_nolock_bytes 0; lctl set_param -n ldlm.namespaces.filter-*.contended_locks 32; lctl set_param -n ldlm.namespaces.filter-*.contention_seconds 0'
12129 lctl set_param -n osc.*.contention_seconds 0
12132 dd if=/dev/zero of=$DIR/$tfile count=0
12133 $CHECKSTAT -s 0 $DIR/$tfile
12135 restore_lustre_params <$p
12139 run_test 216 "check lockless direct write works and updates file size and kms correctly"
12141 test_217() { # bug 22430
12142 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12146 for node in $(nodes_list); do
12147 nid=$(host_nids_address $node $NETTYPE)
12148 if [[ $nid = *-* ]] ; then
12149 echo "lctl ping $nid@$NETTYPE"
12150 lctl ping $nid@$NETTYPE
12152 echo "skipping $node (no hyphen detected)"
12156 run_test 217 "check lctl ping for hostnames with hiphen ('-')"
12159 # do directio so as not to populate the page cache
12160 log "creating a 10 Mb file"
12161 $MULTIOP $DIR/$tfile oO_CREAT:O_DIRECT:O_RDWR:w$((10*1048576))c || error "multiop failed while creating a file"
12162 log "starting reads"
12163 dd if=$DIR/$tfile of=/dev/null bs=4096 &
12164 log "truncating the file"
12165 $MULTIOP $DIR/$tfile oO_TRUNC:c || error "multiop failed while truncating the file"
12167 kill %+ || true # reads might have finished
12168 echo "wait until dd is finished"
12170 log "removing the temporary file"
12171 rm -rf $DIR/$tfile || error "tmp file removal failed"
12173 run_test 218 "parallel read and truncate should not deadlock ======================="
12176 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12177 # write one partial page
12178 dd if=/dev/zero of=$DIR/$tfile bs=1024 count=1
12179 # set no grant so vvp_io_commit_write will do sync write
12180 $LCTL set_param fail_loc=0x411
12181 # write a full page at the end of file
12182 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 seek=1 conv=notrunc
12184 $LCTL set_param fail_loc=0
12185 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 seek=3
12186 $LCTL set_param fail_loc=0x411
12187 dd if=/dev/zero of=$DIR/$tfile bs=1024 count=1 seek=2 conv=notrunc
12190 dd if=/dev/zero of=$DIR/$tfile-2 bs=1024 count=1
12191 $CHECKSTAT -s 1024 $DIR/$tfile-2 || error "checkstat wrong size"
12193 run_test 219 "LU-394: Write partial won't cause uncontiguous pages vec at LND"
12195 test_220() { #LU-325
12196 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12197 remote_ost_nodsh && skip "remote OST with nodsh" && return
12198 remote_mds_nodsh && skip "remote MDS with nodsh" && return
12199 remote_mgs_nodsh && skip "remote MGS with nodsh" && return
12202 # create on MDT0000 so the last_id and next_id are correct
12204 local OST=$($LFS df $DIR | awk '/OST:'$OSTIDX'/ { print $1 }')
12208 local mdtosc_proc1=$(get_mdtosc_proc_path $SINGLEMDS $OST)
12209 local last_id=$(do_facet $SINGLEMDS lctl get_param -n \
12210 osc.$mdtosc_proc1.prealloc_last_id)
12211 local next_id=$(do_facet $SINGLEMDS lctl get_param -n \
12212 osc.$mdtosc_proc1.prealloc_next_id)
12216 do_facet ost$((OSTIDX + 1)) lctl set_param fail_val=-1
12217 #define OBD_FAIL_OST_ENOINO 0x229
12218 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=0x229
12219 do_facet mgs $LCTL pool_new $FSNAME.$TESTNAME || return 1
12220 do_facet mgs $LCTL pool_add $FSNAME.$TESTNAME $OST || return 2
12222 $SETSTRIPE $DIR/$tdir -i $OSTIDX -c 1 -p $FSNAME.$TESTNAME
12224 MDSOBJS=$((last_id - next_id))
12225 echo "preallocated objects on MDS is $MDSOBJS" "($last_id - $next_id)"
12227 blocks=$($LFS df $MOUNT | awk '($1 == '$OSTIDX') { print $4 }')
12228 echo "OST still has $count kbytes free"
12230 echo "create $MDSOBJS files @next_id..."
12231 createmany -o $DIR/$tdir/f $MDSOBJS || return 3
12233 local last_id2=$(do_facet mds${MDSIDX} lctl get_param -n \
12234 osc.$mdtosc_proc1.prealloc_last_id)
12235 local next_id2=$(do_facet mds${MDSIDX} lctl get_param -n \
12236 osc.$mdtosc_proc1.prealloc_next_id)
12238 echo "after creation, last_id=$last_id2, next_id=$next_id2"
12243 do_facet ost$((OSTIDX + 1)) lctl set_param fail_val=0
12244 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=0
12246 do_facet mgs $LCTL pool_remove $FSNAME.$TESTNAME $OST || return 4
12247 do_facet mgs $LCTL pool_destroy $FSNAME.$TESTNAME || return 5
12248 echo "unlink $MDSOBJS files @$next_id..."
12249 unlinkmany $DIR/$tdir/f $MDSOBJS || return 6
12251 run_test 220 "preallocated MDS objects still used if ENOSPC from OST"
12254 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12255 dd if=`which date` of=$MOUNT/date oflag=sync
12256 chmod +x $MOUNT/date
12258 #define OBD_FAIL_LLITE_FAULT_TRUNC_RACE 0x1401
12259 $LCTL set_param fail_loc=0x80001401
12261 $MOUNT/date > /dev/null
12264 run_test 221 "make sure fault and truncate race to not cause OOM"
12267 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12269 test_mkdir -p $DIR/$tdir
12270 $SETSTRIPE -c 1 -i 0 $DIR/$tdir
12271 createmany -o $DIR/$tdir/$tfile 10
12272 cancel_lru_locks mdc
12273 cancel_lru_locks osc
12274 #define OBD_FAIL_LDLM_AGL_DELAY 0x31a
12275 $LCTL set_param fail_loc=0x31a
12276 ls -l $DIR/$tdir > /dev/null || error "AGL for ls failed"
12277 $LCTL set_param fail_loc=0
12280 run_test 222a "AGL for ls should not trigger CLIO lock failure ================"
12283 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12285 test_mkdir -p $DIR/$tdir
12286 $SETSTRIPE -c 1 -i 0 $DIR/$tdir
12287 createmany -o $DIR/$tdir/$tfile 10
12288 cancel_lru_locks mdc
12289 cancel_lru_locks osc
12290 #define OBD_FAIL_LDLM_AGL_DELAY 0x31a
12291 $LCTL set_param fail_loc=0x31a
12292 rm -r $DIR/$tdir || "AGL for rmdir failed"
12293 $LCTL set_param fail_loc=0
12295 run_test 222b "AGL for rmdir should not trigger CLIO lock failure ============="
12298 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12300 test_mkdir -p $DIR/$tdir
12301 $SETSTRIPE -c 1 -i 0 $DIR/$tdir
12302 createmany -o $DIR/$tdir/$tfile 10
12303 cancel_lru_locks mdc
12304 cancel_lru_locks osc
12305 #define OBD_FAIL_LDLM_AGL_NOLOCK 0x31b
12306 $LCTL set_param fail_loc=0x31b
12307 ls -l $DIR/$tdir > /dev/null || error "reenqueue failed"
12308 $LCTL set_param fail_loc=0
12311 run_test 223 "osc reenqueue if without AGL lock granted ======================="
12313 test_224a() { # LU-1039, MRP-303
12314 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12315 #define OBD_FAIL_PTLRPC_CLIENT_BULK_CB 0x508
12316 $LCTL set_param fail_loc=0x508
12317 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 conv=fsync
12318 $LCTL set_param fail_loc=0
12321 run_test 224a "Don't panic on bulk IO failure"
12323 test_224b() { # LU-1039, MRP-303
12324 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12325 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1
12326 cancel_lru_locks osc
12327 #define OBD_FAIL_PTLRPC_CLIENT_BULK_CB2 0x515
12328 $LCTL set_param fail_loc=0x515
12329 dd of=/dev/null if=$DIR/$tfile bs=4096 count=1
12330 $LCTL set_param fail_loc=0
12333 run_test 224b "Don't panic on bulk IO failure"
12335 test_224c() { # LU-6441
12336 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12337 local pages_per_rpc=$($LCTL get_param \
12338 osc.*.max_pages_per_rpc)
12339 local at_max=$($LCTL get_param -n at_max)
12340 local timeout=$($LCTL get_param -n timeout)
12341 local test_at="$LCTL get_param -n at_max"
12342 local param_at="$FSNAME.sys.at_max"
12343 local test_timeout="$LCTL get_param -n timeout"
12344 local param_timeout="$FSNAME.sys.timeout"
12346 $LCTL set_param -n osc.*.max_pages_per_rpc=1024
12348 set_conf_param_and_check client "$test_at" "$param_at" 0 ||
12349 error "conf_param at_max=0 failed"
12350 set_conf_param_and_check client "$test_timeout" "$param_timeout" 5 ||
12351 error "conf_param timeout=5 failed"
12353 #define OBD_FAIL_PTLRPC_CLIENT_BULK_CB3 0x520
12354 $LCTL set_param fail_loc=0x520
12355 dd if=/dev/zero of=$DIR/$tfile bs=8MB count=1
12357 $LCTL set_param fail_loc=0
12359 set_conf_param_and_check client "$test_at" "$param_at" $at_max ||
12360 error "conf_param at_max=$at_max failed"
12361 set_conf_param_and_check client "$test_timeout" "$param_timeout" \
12362 $timeout || error "conf_param timeout=$timeout failed"
12364 $LCTL set_param -n $pages_per_rpc
12366 run_test 224c "Don't hang if one of md lost during large bulk RPC"
12368 MDSSURVEY=${MDSSURVEY:-$(which mds-survey 2>/dev/null || true)}
12370 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12371 remote_mds_nodsh && skip "remote MDS with nodsh" && return
12372 if [ -z ${MDSSURVEY} ]; then
12373 skip_env "mds-survey not found" && return
12376 [ $MDSCOUNT -ge 2 ] &&
12377 skip "skipping now for more than one MDT" && return
12379 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.51) ] ||
12380 { skip "Need MDS version at least 2.2.51"; return; }
12382 local mds=$(facet_host $SINGLEMDS)
12383 local target=$(do_nodes $mds 'lctl dl' | \
12384 awk "{if (\$2 == \"UP\" && \$3 == \"mdt\") {print \$4}}")
12386 local cmd1="file_count=1000 thrhi=4"
12387 local cmd2="dir_count=2 layer=mdd stripe_count=0"
12388 local cmd3="rslt_loc=${TMP} targets=\"$mds:$target\" $MDSSURVEY"
12389 local cmd="$cmd1 $cmd2 $cmd3"
12391 rm -f ${TMP}/mds_survey*
12393 eval $cmd || error "mds-survey with zero-stripe failed"
12394 cat ${TMP}/mds_survey*
12395 rm -f ${TMP}/mds_survey*
12397 run_test 225a "Metadata survey sanity with zero-stripe"
12400 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12401 remote_mds_nodsh && skip "remote MDS with nodsh" && return
12402 if [ -z ${MDSSURVEY} ]; then
12403 skip_env "mds-survey not found" && return
12405 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.51) ] ||
12406 { skip "Need MDS version at least 2.2.51"; return; }
12408 if [ $($LCTL dl | grep -c osc) -eq 0 ]; then
12409 skip_env "Need to mount OST to test" && return
12412 [ $MDSCOUNT -ge 2 ] &&
12413 skip "skipping now for more than one MDT" && return
12414 local mds=$(facet_host $SINGLEMDS)
12415 local target=$(do_nodes $mds 'lctl dl' | \
12416 awk "{if (\$2 == \"UP\" && \$3 == \"mdt\") {print \$4}}")
12418 local cmd1="file_count=1000 thrhi=4"
12419 local cmd2="dir_count=2 layer=mdd stripe_count=1"
12420 local cmd3="rslt_loc=${TMP} targets=\"$mds:$target\" $MDSSURVEY"
12421 local cmd="$cmd1 $cmd2 $cmd3"
12423 rm -f ${TMP}/mds_survey*
12425 eval $cmd || error "mds-survey with stripe_count failed"
12426 cat ${TMP}/mds_survey*
12427 rm -f ${TMP}/mds_survey*
12429 run_test 225b "Metadata survey sanity with stripe_count = 1"
12431 mcreate_path2fid () {
12437 local path=$DIR/$tdir/$name
12442 $MCREATE --mode=$1 --major=$2 --minor=$3 $path ||
12443 error "cannot create $desc"
12445 fid=$($LFS path2fid $path | tr -d '[' | tr -d ']')
12447 [ $rc -ne 0 ] && error "cannot get fid of a $desc"
12449 fid_path=$($LFS fid2path $MOUNT $fid)
12451 [ $rc -ne 0 ] && error "cannot get path of $desc by $DIR $path $fid"
12453 [ "$path" == "$fid_path" ] ||
12454 error "fid2path returned $fid_path, expected $path"
12456 echo "pass with $path and $fid"
12461 mkdir -p $DIR/$tdir
12463 mcreate_path2fid 0010666 0 0 fifo "FIFO"
12464 mcreate_path2fid 0020666 1 3 null "character special file (null)"
12465 mcreate_path2fid 0020666 1 255 none "character special file (no device)"
12466 mcreate_path2fid 0040666 0 0 dir "directory"
12467 mcreate_path2fid 0060666 7 0 loop0 "block special file (loop)"
12468 mcreate_path2fid 0100666 0 0 file "regular file"
12469 mcreate_path2fid 0120666 0 0 link "symbolic link"
12470 mcreate_path2fid 0140666 0 0 sock "socket"
12472 run_test 226a "call path2fid and fid2path on files of all type"
12475 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
12479 mkdir -p $DIR/$tdir
12480 $LFS setdirstripe -i $MDTIDX $DIR/$tdir/remote_dir ||
12481 error "create remote directory failed"
12482 mcreate_path2fid 0010666 0 0 "remote_dir/fifo" "FIFO"
12483 mcreate_path2fid 0020666 1 3 "remote_dir/null" \
12484 "character special file (null)"
12485 mcreate_path2fid 0020666 1 255 "remote_dir/none" \
12486 "character special file (no device)"
12487 mcreate_path2fid 0040666 0 0 "remote_dir/dir" "directory"
12488 mcreate_path2fid 0060666 7 0 "remote_dir/loop0" \
12489 "block special file (loop)"
12490 mcreate_path2fid 0100666 0 0 "remote_dir/file" "regular file"
12491 mcreate_path2fid 0120666 0 0 "remote_dir/link" "symbolic link"
12492 mcreate_path2fid 0140666 0 0 "remote_dir/sock" "socket"
12494 run_test 226b "call path2fid and fid2path on files of all type under remote dir"
12496 # LU-1299 Executing or running ldd on a truncated executable does not
12497 # cause an out-of-memory condition.
12499 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12500 [ -z "$(which ldd)" ] && skip "should have ldd tool" && return
12501 dd if=$(which date) of=$MOUNT/date bs=1k count=1
12502 chmod +x $MOUNT/date
12504 $MOUNT/date > /dev/null
12505 ldd $MOUNT/date > /dev/null
12508 run_test 227 "running truncated executable does not cause OOM"
12510 # LU-1512 try to reuse idle OI blocks
12512 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12513 remote_mds_nodsh && skip "remote MDS with nodsh" && return
12514 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
12515 skip "non-ldiskfs backend" && return
12517 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
12518 local myDIR=$DIR/$tdir
12521 #define OBD_FAIL_SEQ_EXHAUST 0x1002
12522 $LCTL set_param fail_loc=0x80001002
12523 createmany -o $myDIR/t- 10000
12524 $LCTL set_param fail_loc=0
12525 # The guard is current the largest FID holder
12527 local SEQ=$($LFS path2fid $myDIR/guard | awk -F ':' '{print $1}' |
12529 local IDX=$(($SEQ % 64))
12531 do_facet $SINGLEMDS sync
12532 # Make sure journal flushed.
12534 local blk1=$(do_facet $SINGLEMDS \
12535 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
12536 grep Blockcount | awk '{print $4}')
12538 # Remove old files, some OI blocks will become idle.
12539 unlinkmany $myDIR/t- 10000
12540 # Create new files, idle OI blocks should be reused.
12541 createmany -o $myDIR/t- 2000
12542 do_facet $SINGLEMDS sync
12543 # Make sure journal flushed.
12545 local blk2=$(do_facet $SINGLEMDS \
12546 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
12547 grep Blockcount | awk '{print $4}')
12549 [ $blk1 == $blk2 ] || error "old blk1=$blk1, new blk2=$blk2, unmatched!"
12551 run_test 228a "try to reuse idle OI blocks"
12554 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12555 remote_mds_nodsh && skip "remote MDS with nodsh" && return
12556 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
12557 skip "non-ldiskfs backend" && return
12559 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
12560 local myDIR=$DIR/$tdir
12563 #define OBD_FAIL_SEQ_EXHAUST 0x1002
12564 $LCTL set_param fail_loc=0x80001002
12565 createmany -o $myDIR/t- 10000
12566 $LCTL set_param fail_loc=0
12567 # The guard is current the largest FID holder
12569 local SEQ=$($LFS path2fid $myDIR/guard | awk -F ':' '{print $1}' |
12571 local IDX=$(($SEQ % 64))
12573 do_facet $SINGLEMDS sync
12574 # Make sure journal flushed.
12576 local blk1=$(do_facet $SINGLEMDS \
12577 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
12578 grep Blockcount | awk '{print $4}')
12580 # Remove old files, some OI blocks will become idle.
12581 unlinkmany $myDIR/t- 10000
12584 stop $SINGLEMDS || error "Fail to stop MDT."
12586 start $SINGLEMDS $MDT_DEV $MDS_MOUNT_OPTS || error "Fail to start MDT."
12588 df $MOUNT || error "Fail to df."
12589 # Create new files, idle OI blocks should be reused.
12590 createmany -o $myDIR/t- 2000
12591 do_facet $SINGLEMDS sync
12592 # Make sure journal flushed.
12594 local blk2=$(do_facet $SINGLEMDS \
12595 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
12596 grep Blockcount | awk '{print $4}')
12598 [ $blk1 == $blk2 ] || error "old blk1=$blk1, new blk2=$blk2, unmatched!"
12600 run_test 228b "idle OI blocks can be reused after MDT restart"
12604 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12605 remote_mds_nodsh && skip "remote MDS with nodsh" && return
12606 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
12607 skip "non-ldiskfs backend" && return
12609 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
12610 local myDIR=$DIR/$tdir
12613 #define OBD_FAIL_SEQ_EXHAUST 0x1002
12614 $LCTL set_param fail_loc=0x80001002
12615 # 20000 files can guarantee there are index nodes in the OI file
12616 createmany -o $myDIR/t- 20000
12617 $LCTL set_param fail_loc=0
12618 # The guard is current the largest FID holder
12620 local SEQ=$($LFS path2fid $myDIR/guard | awk -F ':' '{print $1}' |
12622 local IDX=$(($SEQ % 64))
12624 do_facet $SINGLEMDS sync
12625 # Make sure journal flushed.
12627 local blk1=$(do_facet $SINGLEMDS \
12628 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
12629 grep Blockcount | awk '{print $4}')
12631 # Remove old files, some OI blocks will become idle.
12632 unlinkmany $myDIR/t- 20000
12634 # The OI file should become empty now
12636 # Create new files, idle OI blocks should be reused.
12637 createmany -o $myDIR/t- 2000
12638 do_facet $SINGLEMDS sync
12639 # Make sure journal flushed.
12641 local blk2=$(do_facet $SINGLEMDS \
12642 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
12643 grep Blockcount | awk '{print $4}')
12645 [ $blk1 == $blk2 ] || error "old blk1=$blk1, new blk2=$blk2, unmatched!"
12647 run_test 228c "NOT shrink the last entry in OI index node to recycle idle leaf"
12649 test_229() { # LU-2482, LU-3448
12650 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.53) ] &&
12651 skip "No HSM $(lustre_build_version $SINGLEMDS) MDS < 2.4.53" &&
12653 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12654 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs" && return
12658 # Create a file with a released layout and stripe count 2.
12659 $MULTIOP $DIR/$tfile H2c ||
12660 error "failed to create file with released layout"
12662 $GETSTRIPE -v $DIR/$tfile
12664 local pattern=$($GETSTRIPE -L $DIR/$tfile)
12665 [ X"$pattern" = X"80000001" ] || error "pattern error ($pattern)"
12667 local stripe_count=$($GETSTRIPE -c $DIR/$tfile) || error "getstripe"
12668 [ $stripe_count -eq 2 ] || error "stripe count not 2 ($stripe_count)"
12669 stat $DIR/$tfile || error "failed to stat released file"
12671 chown $RUNAS_ID $DIR/$tfile ||
12672 error "chown $RUNAS_ID $DIR/$tfile failed"
12674 chgrp $RUNAS_ID $DIR/$tfile ||
12675 error "chgrp $RUNAS_ID $DIR/$tfile failed"
12677 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
12678 rm $DIR/$tfile || error "failed to remove released file"
12680 run_test 229 "getstripe/stat/rm/attr changes work on released files"
12683 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12684 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
12687 test_mkdir $DIR/$tdir
12688 test_mkdir -i0 -c1 $DIR/$tdir/test_230_local
12689 local mdt_idx=$($GETSTRIPE -M $DIR/$tdir/test_230_local)
12690 [ $mdt_idx -ne 0 ] &&
12691 error "create local directory on wrong MDT $mdt_idx"
12693 $LFS mkdir -i $MDTIDX $DIR/$tdir/test_230 ||
12694 error "create remote directory failed"
12695 local mdt_idx=$($GETSTRIPE -M $DIR/$tdir/test_230)
12696 [ $mdt_idx -ne $MDTIDX ] &&
12697 error "create remote directory on wrong MDT $mdt_idx"
12699 createmany -o $DIR/$tdir/test_230/t- 10 ||
12700 error "create files on remote directory failed"
12701 mdt_idx=$($GETSTRIPE -M $DIR/$tdir/test_230/t-0)
12702 [ $mdt_idx -ne $MDTIDX ] && error "create files on wrong MDT $mdt_idx"
12703 rm -r $DIR/$tdir || error "unlink remote directory failed"
12705 run_test 230a "Create remote directory and files under the remote directory"
12708 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12709 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
12716 local migrate_dir=$DIR/$tdir/migrate_dir
12717 local other_dir=$DIR/$tdir/other_dir
12719 test_mkdir $DIR/$tdir
12720 test_mkdir -i0 -c1 $migrate_dir
12721 test_mkdir -i0 -c1 $other_dir
12722 for ((i=0; i<10; i++)); do
12723 mkdir -p $migrate_dir/dir_${i}
12724 createmany -o $migrate_dir/dir_${i}/f 10 ||
12725 error "create files under remote dir failed $i"
12728 cp /etc/passwd $migrate_dir/$tfile
12729 cp /etc/passwd $other_dir/$tfile
12730 chattr +SAD $migrate_dir
12731 chattr +SAD $migrate_dir/$tfile
12733 local old_dir_flag=$(lsattr -a $migrate_dir | awk '/\/\.$/ {print $1}')
12734 local old_file_flag=$(lsattr $migrate_dir/$tfile | awk '{print $1}')
12735 local old_dir_mode=$(stat -c%f $migrate_dir)
12736 local old_file_mode=$(stat -c%f $migrate_dir/$tfile)
12738 mkdir -p $migrate_dir/dir_default_stripe2
12739 $SETSTRIPE -c 2 $migrate_dir/dir_default_stripe2
12740 $SETSTRIPE -c 2 $migrate_dir/${tfile}_stripe2
12742 mkdir -p $other_dir
12743 ln $migrate_dir/$tfile $other_dir/luna
12744 ln $migrate_dir/$tfile $migrate_dir/sofia
12745 ln $other_dir/$tfile $migrate_dir/david
12746 ln -s $migrate_dir/$tfile $other_dir/zachary
12747 ln -s $migrate_dir/$tfile $migrate_dir/${tfile}_ln
12748 ln -s $other_dir/$tfile $migrate_dir/${tfile}_ln_other
12750 $LFS migrate -m $MDTIDX $migrate_dir ||
12751 error "fails on migrating remote dir to MDT1"
12753 echo "migratate to MDT1, then checking.."
12754 for ((i = 0; i < 10; i++)); do
12755 for file in $(find $migrate_dir/dir_${i}); do
12756 mdt_index=$($LFS getstripe -M $file)
12757 [ $mdt_index == $MDTIDX ] ||
12758 error "$file is not on MDT${MDTIDX}"
12762 # the multiple link file should still in MDT0
12763 mdt_index=$($LFS getstripe -M $migrate_dir/$tfile)
12764 [ $mdt_index == 0 ] ||
12765 error "$file is not on MDT${MDTIDX}"
12767 local new_dir_flag=$(lsattr -a $migrate_dir | awk '/\/\.$/ {print $1}')
12768 [ "$old_dir_flag" = "$new_dir_flag" ] ||
12769 error " expect $old_dir_flag get $new_dir_flag"
12771 local new_file_flag=$(lsattr $migrate_dir/$tfile | awk '{print $1}')
12772 [ "$old_file_flag" = "$new_file_flag" ] ||
12773 error " expect $old_file_flag get $new_file_flag"
12775 local new_dir_mode=$(stat -c%f $migrate_dir)
12776 [ "$old_dir_mode" = "$new_dir_mode" ] ||
12777 error "expect mode $old_dir_mode get $new_dir_mode"
12779 local new_file_mode=$(stat -c%f $migrate_dir/$tfile)
12780 [ "$old_file_mode" = "$new_file_mode" ] ||
12781 error "expect mode $old_file_mode get $new_file_mode"
12783 diff /etc/passwd $migrate_dir/$tfile ||
12784 error "$tfile different after migration"
12786 diff /etc/passwd $other_dir/luna ||
12787 error "luna different after migration"
12789 diff /etc/passwd $migrate_dir/sofia ||
12790 error "sofia different after migration"
12792 diff /etc/passwd $migrate_dir/david ||
12793 error "david different after migration"
12795 diff /etc/passwd $other_dir/zachary ||
12796 error "zachary different after migration"
12798 diff /etc/passwd $migrate_dir/${tfile}_ln ||
12799 error "${tfile}_ln different after migration"
12801 diff /etc/passwd $migrate_dir/${tfile}_ln_other ||
12802 error "${tfile}_ln_other different after migration"
12804 stripe_count=$($LFS getstripe -c $migrate_dir/dir_default_stripe2)
12805 [ $stripe_count = 2 ] ||
12806 error "dir strpe_count $d != 2 after migration."
12808 stripe_count=$($LFS getstripe -c $migrate_dir/${tfile}_stripe2)
12809 [ $stripe_count = 2 ] ||
12810 error "file strpe_count $d != 2 after migration."
12812 #migrate back to MDT0
12815 $LFS migrate -m $MDTIDX $migrate_dir ||
12816 error "fails on migrating remote dir to MDT0"
12818 echo "migrate back to MDT0, checking.."
12819 for file in $(find $migrate_dir); do
12820 mdt_index=$($LFS getstripe -M $file)
12821 [ $mdt_index == $MDTIDX ] ||
12822 error "$file is not on MDT${MDTIDX}"
12825 local new_dir_flag=$(lsattr -a $migrate_dir | awk '/\/\.$/ {print $1}')
12826 [ "$old_dir_flag" = "$new_dir_flag" ] ||
12827 error " expect $old_dir_flag get $new_dir_flag"
12829 local new_file_flag=$(lsattr $migrate_dir/$tfile | awk '{print $1}')
12830 [ "$old_file_flag" = "$new_file_flag" ] ||
12831 error " expect $old_file_flag get $new_file_flag"
12833 local new_dir_mode=$(stat -c%f $migrate_dir)
12834 [ "$old_dir_mode" = "$new_dir_mode" ] ||
12835 error "expect mode $old_dir_mode get $new_dir_mode"
12837 local new_file_mode=$(stat -c%f $migrate_dir/$tfile)
12838 [ "$old_file_mode" = "$new_file_mode" ] ||
12839 error "expect mode $old_file_mode get $new_file_mode"
12841 diff /etc/passwd ${migrate_dir}/$tfile ||
12842 error "$tfile different after migration"
12844 diff /etc/passwd ${other_dir}/luna ||
12845 error "luna different after migration"
12847 diff /etc/passwd ${migrate_dir}/sofia ||
12848 error "sofia different after migration"
12850 diff /etc/passwd ${other_dir}/zachary ||
12851 error "zachary different after migration"
12853 diff /etc/passwd $migrate_dir/${tfile}_ln ||
12854 error "${tfile}_ln different after migration"
12856 diff /etc/passwd $migrate_dir/${tfile}_ln_other ||
12857 error "${tfile}_ln_other different after migration"
12859 stripe_count=$($LFS getstripe -c ${migrate_dir}/dir_default_stripe2)
12860 [ $stripe_count = 2 ] ||
12861 error "dir strpe_count $d != 2 after migration."
12863 stripe_count=$($LFS getstripe -c ${migrate_dir}/${tfile}_stripe2)
12864 [ $stripe_count = 2 ] ||
12865 error "file strpe_count $d != 2 after migration."
12867 rm -rf $DIR/$tdir || error "rm dir failed after migration"
12869 run_test 230b "migrate directory"
12872 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12873 remote_mds_nodsh && skip "remote MDS with nodsh" && return
12874 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
12878 local migrate_dir=$DIR/$tdir/migrate_dir
12880 #If migrating directory fails in the middle, all entries of
12881 #the directory is still accessiable.
12882 test_mkdir $DIR/$tdir
12883 test_mkdir -i0 -c1 $migrate_dir
12885 createmany -o $migrate_dir/f 10 ||
12886 error "create files under ${migrate_dir} failed"
12888 #failed after migrating 5 entries
12889 #OBD_FAIL_MIGRATE_ENTRIES 0x1801
12890 do_facet mds1 lctl set_param fail_loc=0x20001801
12891 do_facet mds1 lctl set_param fail_val=5
12892 local t=$(ls $migrate_dir | wc -l)
12893 $LFS migrate --mdt-index $MDTIDX $migrate_dir &&
12894 error "migrate should fail after 5 entries"
12896 mkdir $migrate_dir/dir &&
12897 error "mkdir succeeds under migrating directory"
12898 touch $migrate_dir/file &&
12899 error "touch file succeeds under migrating directory"
12901 local u=$(ls $migrate_dir | wc -l)
12902 [ "$u" == "$t" ] || error "$u != $t during migration"
12904 for file in $(find $migrate_dir); do
12905 stat $file || error "stat $file failed"
12908 do_facet mds1 lctl set_param fail_loc=0
12909 do_facet mds1 lctl set_param fail_val=0
12911 $LFS migrate -m $MDTIDX $migrate_dir ||
12912 error "migrate open files should failed with open files"
12914 echo "Finish migration, then checking.."
12915 for file in $(find $migrate_dir); do
12916 mdt_index=$($LFS getstripe -M $file)
12917 [ $mdt_index == $MDTIDX ] ||
12918 error "$file is not on MDT${MDTIDX}"
12921 rm -rf $DIR/$tdir || error "rm dir failed after migration"
12923 run_test 230c "check directory accessiblity if migration is failed"
12926 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12927 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
12930 local migrate_dir=$DIR/$tdir/migrate_dir
12934 test_mkdir $DIR/$tdir
12935 test_mkdir -i0 -c1 $migrate_dir
12937 for ((i=0; i<100; i++)); do
12938 test_mkdir -i0 -c1 $migrate_dir/dir_${i}
12939 createmany -o $migrate_dir/dir_${i}/f 100 ||
12940 error "create files under remote dir failed $i"
12943 $LFS migrate -m $MDTIDX $migrate_dir ||
12944 error "migrate remote dir error"
12946 echo "Finish migration, then checking.."
12947 for file in $(find $migrate_dir); do
12948 mdt_index=$($LFS getstripe -M $file)
12949 [ $mdt_index == $MDTIDX ] ||
12950 error "$file is not on MDT${MDTIDX}"
12953 rm -rf $DIR/$tdir || error "rm dir failed after migration"
12955 run_test 230d "check migrate big directory"
12958 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12959 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
12965 mkdir -p $DIR/$tdir
12966 mkdir $DIR/$tdir/migrate_dir
12967 mkdir $DIR/$tdir/other_dir
12968 touch $DIR/$tdir/migrate_dir/a
12969 ln $DIR/$tdir/migrate_dir/a $DIR/$tdir/other_dir/b
12971 $LFS migrate -m 1 $DIR/$tdir/migrate_dir ||
12972 error "migrate dir fails"
12974 mdt_index=$($LFS getstripe -M $DIR/$tdir/migrate_dir)
12975 [ $mdt_index == 1 ] || error "migrate_dir is not on MDT1"
12977 mdt_index=$($LFS getstripe -M $DIR/$tdir/migrate_dir/a)
12978 [ $mdt_index == 0 ] || error "a is not on MDT0"
12980 $LFS migrate -m 1 $DIR/$tdir/other_dir ||
12981 error "migrate dir fails"
12983 mdt_index=$($LFS getstripe -M $DIR/$tdir/other_dir)
12984 [ $mdt_index == 1 ] || error "other_dir is not on MDT1"
12986 mdt_index=$($LFS getstripe -M $DIR/$tdir/migrate_dir/a)
12987 [ $mdt_index == 1 ] || error "a is not on MDT1"
12989 mdt_index=$($LFS getstripe -M $DIR/$tdir/other_dir/b)
12990 [ $mdt_index == 1 ] || error "b is not on MDT1"
12992 a_fid=$($LFS path2fid $DIR/$tdir/migrate_dir/a)
12993 b_fid=$($LFS path2fid $DIR/$tdir/other_dir/b)
12995 [ "$a_fid" = "$b_fid" ] || error "different fid after migration"
12997 rm -rf $DIR/$tdir || error "rm dir failed after migration"
12999 run_test 230e "migrate mulitple local link files"
13002 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13003 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
13007 mkdir -p $DIR/$tdir
13008 mkdir $DIR/$tdir/migrate_dir
13009 $LFS mkdir -i1 $DIR/$tdir/other_dir
13010 touch $DIR/$tdir/migrate_dir/a
13011 ln $DIR/$tdir/migrate_dir/a $DIR/$tdir/other_dir/ln1
13012 ln $DIR/$tdir/migrate_dir/a $DIR/$tdir/other_dir/ln2
13014 # a should be migrated to MDT1, since no other links on MDT0
13015 $LFS migrate -m 1 $DIR/$tdir/migrate_dir ||
13016 error "migrate dir fails"
13017 mdt_index=$($LFS getstripe -M $DIR/$tdir/migrate_dir)
13018 [ $mdt_index == 1 ] || error "migrate_dir is not on MDT1"
13019 mdt_index=$($LFS getstripe -M $DIR/$tdir/migrate_dir/a)
13020 [ $mdt_index == 1 ] || error "a is not on MDT1"
13022 # a should stay on MDT1, because it is a mulitple link file
13023 $LFS migrate -m 0 $DIR/$tdir/migrate_dir ||
13024 error "migrate dir fails"
13025 mdt_index=$($LFS getstripe -M $DIR/$tdir/migrate_dir/a)
13026 [ $mdt_index == 1 ] || error "a is not on MDT1"
13028 $LFS migrate -m 1 $DIR/$tdir/migrate_dir ||
13029 error "migrate dir fails"
13031 a_fid=$($LFS path2fid $DIR/$tdir/migrate_dir/a)
13032 ln_fid=$($LFS path2fid $DIR/$tdir/other_dir/ln1)
13033 [ "$a_fid" = "$ln_fid" ] || error "different fid after migrate to MDT1"
13035 rm -rf $DIR/$tdir/other_dir/ln1 || error "unlink ln1 fails"
13036 rm -rf $DIR/$tdir/other_dir/ln2 || error "unlink ln2 fails"
13038 # a should be migrated to MDT0, since no other links on MDT1
13039 $LFS migrate -m 0 $DIR/$tdir/migrate_dir ||
13040 error "migrate dir fails"
13041 mdt_index=$($LFS getstripe -M $DIR/$tdir/migrate_dir/a)
13042 [ $mdt_index == 0 ] || error "a is not on MDT0"
13044 rm -rf $DIR/$tdir || error "rm dir failed after migration"
13046 run_test 230f "migrate mulitple remote link files"
13050 # For simplicity this test assumes that max_pages_per_rpc
13051 # is the same across all OSCs
13052 local max_pages=$($LCTL get_param -n osc.*.max_pages_per_rpc | head -n1)
13053 local bulk_size=$((max_pages * 4096))
13055 mkdir -p $DIR/$tdir
13057 # clear the OSC stats
13058 $LCTL set_param osc.*.stats=0 &>/dev/null
13060 # Client writes $bulk_size - there must be 1 rpc for $max_pages.
13061 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=$bulk_size count=1 \
13062 oflag=direct &>/dev/null || error "dd failed"
13064 local nrpcs=$($LCTL get_param osc.*.stats |awk '/ost_write/ {print $2}')
13065 if [ x$nrpcs != "x1" ]; then
13066 error "found $nrpc ost_write RPCs, not 1 as expected"
13069 # Drop the OSC cache, otherwise we will read from it
13070 cancel_lru_locks osc
13072 # clear the OSC stats
13073 $LCTL set_param osc.*.stats=0 &>/dev/null
13075 # Client reads $bulk_size.
13076 dd if=$DIR/$tdir/$tfile of=/dev/null bs=$bulk_size count=1 \
13077 iflag=direct &>/dev/null || error "dd failed"
13079 nrpcs=$($LCTL get_param osc.*.stats | awk '/ost_read/ { print $2 }')
13080 if [ x$nrpcs != "x1" ]; then
13081 error "found $nrpc ost_read RPCs, not 1 as expected"
13084 run_test 231a "checking that reading/writing of BRW RPC size results in one RPC"
13087 mkdir -p $DIR/$tdir
13089 for i in {0..1023}; do
13090 dd if=/dev/zero of=$DIR/$tdir/$tfile conv=notrunc \
13091 seek=$((2 * i)) bs=4096 count=1 &>/dev/null ||
13092 error "dd of=$DIR/$tdir/$tfile seek=$((2 * i)) failed"
13096 run_test 231b "must not assert on fully utilized OST request buffer"
13099 mkdir -p $DIR/$tdir
13100 #define OBD_FAIL_LDLM_OST_LVB 0x31c
13101 $LCTL set_param fail_loc=0x31c
13103 # ignore dd failure
13104 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=1 || true
13106 $LCTL set_param fail_loc=0
13107 umount_client $MOUNT || error "umount failed"
13108 mount_client $MOUNT || error "mount failed"
13110 run_test 232 "failed lock should not block umount"
13113 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.3.64) ] ||
13114 { skip "Need MDS version at least 2.3.64"; return; }
13116 local fid=$($LFS path2fid $MOUNT)
13117 stat $MOUNT/.lustre/fid/$fid > /dev/null ||
13118 error "cannot access $MOUNT using its FID '$fid'"
13120 run_test 233a "checking that OBF of the FS root succeeds"
13123 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.5.90) ] ||
13124 { skip "Need MDS version at least 2.5.90"; return; }
13126 local fid=$($LFS path2fid $MOUNT/.lustre)
13127 stat $MOUNT/.lustre/fid/$fid > /dev/null ||
13128 error "cannot access $MOUNT/.lustre using its FID '$fid'"
13130 fid=$($LFS path2fid $MOUNT/.lustre/fid)
13131 stat $MOUNT/.lustre/fid/$fid > /dev/null ||
13132 error "cannot access $MOUNT/.lustre/fid using its FID '$fid'"
13134 run_test 233b "checking that OBF of the FS .lustre succeeds"
13137 local p="$TMP/sanityN-$TESTNAME.parameters"
13138 save_lustre_params client "llite.*.xattr_cache" > $p
13139 lctl set_param llite.*.xattr_cache 1 ||
13140 { skip "xattr cache is not supported"; return 0; }
13142 mkdir -p $DIR/$tdir || error "mkdir failed"
13143 touch $DIR/$tdir/$tfile || error "touch failed"
13144 # OBD_FAIL_LLITE_XATTR_ENOMEM
13145 $LCTL set_param fail_loc=0x1405
13146 # output of the form: attr 2 4 44 3 fc13 x86_64
13147 V=($(IFS=".-" rpm -q attr))
13148 if [[ ${V[1]} > 2 || ${V[2]} > 4 || ${V[3]} > 44 ||
13149 ${V[1]} = 2 && ${V[2]} = 4 && ${V[3]} = 44 && ${V[4]} > 6 ]]; then
13150 # attr pre-2.4.44-7 had a bug with rc
13151 # LU-3703 - SLES 11 and FC13 clients have older attr
13152 getfattr -n user.attr $DIR/$tdir/$tfile &&
13153 error "getfattr should have failed with ENOMEM"
13155 skip "LU-3703: attr version $(getfattr --version) too old"
13157 $LCTL set_param fail_loc=0x0
13160 restore_lustre_params < $p
13163 run_test 234 "xattr cache should not crash on ENOMEM"
13166 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.52) ] &&
13167 skip "Need MDS version at least 2.4.52" && return
13168 flock_deadlock $DIR/$tfile
13173 124) error "process hangs on a deadlock"
13175 *) error "error executing flock_deadlock $DIR/$tfile"
13179 run_test 235 "LU-1715: flock deadlock detection does not work properly"
13183 check_swap_layouts_support && return 0
13184 test_mkdir -p -c1 $DIR/$tdir || error "mkdir $tdir failed"
13186 local ref1=/etc/passwd
13187 local ref2=/etc/group
13188 local file1=$DIR/$tdir/f1
13189 local file2=$DIR/$tdir/f2
13191 $SETSTRIPE -c 1 $file1 || error "cannot setstripe on '$file1': rc = $?"
13192 cp $ref1 $file1 || error "cp $ref1 $file1 failed: rc = $?"
13193 $SETSTRIPE -c 2 $file2 || error "cannot setstripe on '$file2': rc = $?"
13194 cp $ref2 $file2 || error "cp $ref2 $file2 failed: rc = $?"
13195 local fd=$(free_fd)
13196 local cmd="exec $fd<>$file2"
13199 $LFS swap_layouts $file1 /proc/self/fd/${fd} ||
13200 error "cannot swap layouts of '$file1' and /proc/self/fd/${fd}"
13203 cmp $ref2 $file1 || error "content compare failed ($ref2 != $file1)"
13208 run_test 236 "Layout swap on open unlinked file"
13210 # test to verify file handle related system calls
13211 # (name_to_handle_at/open_by_handle_at)
13212 # The new system calls are supported in glibc >= 2.14.
13215 echo "Test file_handle syscalls" > $DIR/$tfile ||
13216 error "write failed"
13217 check_fhandle_syscalls $DIR/$tfile ||
13218 error "check_fhandle_syscalls failed"
13220 run_test 237 "Verify name_to_handle_at/open_by_handle_at syscalls"
13222 # LU-4659 linkea consistency
13224 local server_version=$(lustre_version_code $SINGLEMDS)
13226 [[ $server_version -gt $(version_code 2.5.57) ]] ||
13227 [[ $server_version -gt $(version_code 2.5.1) &&
13228 $server_version -lt $(version_code 2.5.50) ]] ||
13229 { skip "Need MDS version at least 2.5.58 or 2.5.2+"; return; }
13232 ln $DIR/$tfile $DIR/$tfile.lnk
13233 touch $DIR/$tfile.new
13234 mv $DIR/$tfile.new $DIR/$tfile
13235 local fid1=$($LFS path2fid $DIR/$tfile)
13236 local fid2=$($LFS path2fid $DIR/$tfile.lnk)
13237 local path1=$($LFS fid2path $FSNAME "$fid1")
13238 [ $tfile == $path1 ] || error "linkea inconsistent: $tfile $fid1 $path1"
13239 local path2=$($LFS fid2path $FSNAME "$fid2")
13240 [ $tfile.lnk == $path2 ] ||
13241 error "linkea inconsistent: $tfile.lnk $fid2 $path2!"
13244 run_test 238 "Verify linkea consistency"
13247 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.5.60) ] &&
13248 skip "Need MDS version at least 2.5.60" && return
13249 local list=$(comma_list $(mdts_nodes))
13251 mkdir -p $DIR/$tdir
13252 createmany -o $DIR/$tdir/f- 5000
13253 unlinkmany $DIR/$tdir/f- 5000
13254 do_nodes $list "lctl set_param -n osp*.*.sync_changes 1"
13255 changes=$(do_nodes $list "lctl get_param -n osc.*MDT*.sync_changes \
13256 osc.*MDT*.sync_in_flight" | calc_sum)
13257 [ "$changes" -eq 0 ] || error "$changes not synced"
13259 run_test 239 "osp_sync test"
13261 test_239a() { #LU-5297
13263 #define OBD_FAIL_OSP_CHECK_INVALID_REC 0x2100
13264 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x2100
13265 chgrp $RUNAS_GID $DIR/$tfile
13266 wait_delete_completed
13268 run_test 239a "process invalid osp sync record correctly"
13270 test_239b() { #LU-5297
13272 #define OBD_FAIL_OSP_CHECK_ENOMEM 0x2101
13273 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x2101
13274 chgrp $RUNAS_GID $DIR/$tfile1
13275 wait_delete_completed
13276 do_facet $SINGLEMDS $LCTL set_param fail_loc=0
13278 chgrp $RUNAS_GID $DIR/$tfile2
13279 wait_delete_completed
13281 run_test 239b "process osp sync record with ENOMEM error correctly"
13284 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
13286 mkdir -p $DIR/$tdir
13288 $LFS mkdir -i 0 $DIR/$tdir/d0 ||
13289 error "failed to mkdir $DIR/$tdir/d0 on MDT0"
13290 $LFS mkdir -i 1 $DIR/$tdir/d0/d1 ||
13291 error "failed to mkdir $DIR/$tdir/d0/d1 on MDT1"
13293 umount_client $MOUNT || error "umount failed"
13294 #define OBD_FAIL_TGT_DELAY_CONDITIONAL 0x713
13295 do_facet mds2 lctl set_param fail_loc=0x713 fail_val=1
13296 mount_client $MOUNT || error "failed to mount client"
13298 echo "stat $DIR/$tdir/d0/d1, should not fail/ASSERT"
13299 stat $DIR/$tdir/d0/d1 || error "fail to stat $DIR/$tdir/d0/d1"
13301 run_test 240 "race between ldlm enqueue and the connection RPC (no ASSERT)"
13304 for LOOP in $(seq $1); do
13305 dd if=$DIR/$tfile of=/dev/null bs=40960 count=1 2>/dev/null
13306 cancel_lru_locks osc
13311 for LOOP in $(seq $1); do
13312 dd if=$DIR/$tfile of=/dev/null bs=40960 count=1 \
13313 iflag=direct 2>/dev/null
13318 dd if=/dev/zero of=$DIR/$tfile count=1 bs=40960
13320 cancel_lru_locks osc
13321 test_241_bio 1000 &
13326 run_test 241 "bio vs dio"
13329 dd if=/dev/zero of=$DIR/$tfile count=1 bs=40960
13331 test_241_dio 1000 &
13336 run_test 241b "dio vs dio"
13339 mkdir -p $DIR/$tdir
13340 touch $DIR/$tdir/$tfile
13342 #define OBD_FAIL_MDS_READPAGE_PACK 0x105
13343 do_facet mds1 lctl set_param fail_loc=0x105
13344 /bin/ls $DIR/$tdir && error "ls $DIR/$tdir should fail"
13346 do_facet mds1 lctl set_param fail_loc=0
13347 /bin/ls $DIR/$tdir || error "ls $DIR/$tdir failed"
13349 run_test 242 "mdt_readpage failure should not cause directory unreadable"
13353 test_mkdir -p $DIR/$tdir
13354 group_lock_test -d $DIR/$tdir || error "A group lock test failed"
13356 run_test 243 "various group lock tests"
13360 test_mkdir -p $DIR/$tdir
13361 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=35
13362 sendfile_grouplock $DIR/$tdir/$tfile || \
13363 error "sendfile+grouplock failed"
13366 run_test 244 "sendfile with group lock tests"
13369 local flagname="multi_mod_rpcs"
13370 local connect_data_name="max_mod_rpcs"
13373 # check if multiple modify RPCs flag is set
13374 out=$($LCTL get_param mdc.$FSNAME-MDT0000-*.import |
13375 grep "connect_flags:")
13378 echo "$out" | grep -qw $flagname
13379 if [ $? -ne 0 ]; then
13380 echo "connect flag $flagname is not set"
13384 # check if multiple modify RPCs data is set
13385 out=$($LCTL get_param mdc.$FSNAME-MDT0000-*.import)
13388 echo "$out" | grep -qw $connect_data_name ||
13389 error "import should have connect data $connect_data_name"
13391 run_test 245 "check mdc connection flag/data: multiple modify RPCs"
13394 [ "$(facet_fstype ost$(($($GETSTRIPE -i $DIR/$tfile) + 1)))" = "zfs" ] \
13395 && skip "no 16TB file size limit on ZFS" && return
13397 $SETSTRIPE -c 1 $DIR/$tfile
13398 # ldiskfs extent file size limit is (16TB - 4KB - 1) bytes
13399 local size=$((16 * 1024 * 1024 * 1024 * 1024 - 4096 - 1))
13400 $TRUNCATE $DIR/$tfile $size || error "truncate $tfile to $size failed"
13401 dd if=/dev/zero of=$DIR/$tfile bs=10 count=1 oflag=append \
13402 conv=notrunc,fsync && error "append succeeded"
13405 run_test 250 "Write above 16T limit"
13408 $SETSTRIPE -c -1 -S 1048576 $DIR/$tfile
13410 #define OBD_FAIL_LLITE_LOST_LAYOUT 0x1407
13411 #Skip once - writing the first stripe will succeed
13412 $LCTL set_param fail_loc=0xa0001407 fail_val=1
13413 $MULTIOP $DIR/$tfile o:O_RDWR:w2097152c 2>&1 | grep -q "short write" &&
13414 error "short write happened"
13416 $LCTL set_param fail_loc=0xa0001407 fail_val=1
13417 $MULTIOP $DIR/$tfile or2097152c 2>&1 | grep -q "short read" &&
13418 error "short read happened"
13422 run_test 251 "Handling short read and write correctly"
13432 if [ "$(facet_fstype ost1)" != "ldiskfs" -o \
13433 "$(facet_fstype mds1)" != "ldiskfs" ]; then
13434 skip "can only run lr_reader on ldiskfs target"
13438 # check lr_reader on OST0000
13440 dev=$(facet_device $tgt)
13441 out=$(do_facet $tgt $LR_READER $dev)
13442 [ $? -eq 0 ] || error "$LR_READER failed on target $tgt device $dev"
13444 uuid=$(echo "$out" | grep -i uuid | awk '{ print $2 }')
13445 [ "$uuid" == "$(ostuuid_from_index 0)" ] ||
13446 error "Invalid uuid returned by $LR_READER on target $tgt"
13447 echo -e "uuid returned by $LR_READER is '$uuid'\n"
13449 # check lr_reader -c on MDT0000
13451 dev=$(facet_device $tgt)
13452 if ! do_facet $tgt $LR_READER -h | grep -q OPTIONS; then
13453 echo "$LR_READER does not support additional options"
13456 out=$(do_facet $tgt $LR_READER -c $dev)
13457 [ $? -eq 0 ] || error "$LR_READER failed on target $tgt device $dev"
13459 num=$(echo "$out" | grep -c "mdtlov")
13460 [ "$num" -eq $((MDSCOUNT - 1)) ] ||
13461 error "Invalid number of mdtlov clients returned by $LR_READER"
13462 echo -e "Number of mdtlov clients returned by $LR_READER is '$num'\n"
13464 # check lr_reader -cr on MDT0000
13465 out=$(do_facet $tgt $LR_READER -cr $dev)
13466 [ $? -eq 0 ] || error "$LR_READER failed on target $tgt device $dev"
13468 echo "$out" | grep -q "^reply_data:$" ||
13469 error "$LR_READER should have returned 'reply_data' section"
13470 num=$(echo "$out" | grep -c "client_generation")
13471 echo -e "Number of reply data returned by $LR_READER is '$num'\n"
13473 run_test 252 "check lr_reader tool"
13476 cleanup_test_300() {
13480 test_striped_dir() {
13485 mkdir -p $DIR/$tdir
13487 SAVE_UMASK=$(umask)
13488 trap cleanup_test_300 RETURN EXIT
13490 $LFS setdirstripe -i $mdt_index -c 2 -t all_char -m 755 \
13491 $DIR/$tdir/striped_dir ||
13492 error "set striped dir error"
13494 local mode=$(stat -c%a $DIR/$tdir/striped_dir)
13495 [ "$mode" = "755" ] || error "expect 755 got $mode"
13497 $LFS getdirstripe $DIR/$tdir/striped_dir > /dev/null 2>&1 ||
13498 error "getdirstripe failed"
13499 stripe_count=$($LFS getdirstripe -c $DIR/$tdir/striped_dir)
13500 if [ "$stripe_count" != "2" ]; then
13501 error "stripe_count is $stripe_count, expect 2"
13504 stripe_index=$($LFS getdirstripe -i $DIR/$tdir/striped_dir)
13505 if [ "$stripe_index" != "$mdt_index" ]; then
13506 error "stripe_index is $stripe_index, expect $mdt_index"
13509 [ $(stat -c%h $DIR/$tdir/striped_dir) == '2' ] ||
13510 error "nlink error after create striped dir"
13512 mkdir $DIR/$tdir/striped_dir/a
13513 mkdir $DIR/$tdir/striped_dir/b
13515 stat $DIR/$tdir/striped_dir/a ||
13516 error "create dir under striped dir failed"
13517 stat $DIR/$tdir/striped_dir/b ||
13518 error "create dir under striped dir failed"
13520 [ $(stat -c%h $DIR/$tdir/striped_dir) == '4' ] ||
13521 error "nlink error after mkdir"
13523 rmdir $DIR/$tdir/striped_dir/a
13524 [ $(stat -c%h $DIR/$tdir/striped_dir) == '3' ] ||
13525 error "nlink error after rmdir"
13527 rmdir $DIR/$tdir/striped_dir/b
13528 [ $(stat -c%h $DIR/$tdir/striped_dir) == '2' ] ||
13529 error "nlink error after rmdir"
13531 chattr +i $DIR/$tdir/striped_dir
13532 createmany -o $DIR/$tdir/striped_dir/f 10 &&
13533 error "immutable flags not working under striped dir!"
13534 chattr -i $DIR/$tdir/striped_dir
13536 rmdir $DIR/$tdir/striped_dir ||
13537 error "rmdir striped dir error"
13545 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13546 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
13548 test_striped_dir 0 || error "failed on striped dir on MDT0"
13549 test_striped_dir 1 || error "failed on striped dir on MDT0"
13551 run_test 300a "basic striped dir sanity test"
13554 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13555 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
13561 test_mkdir $DIR/$tdir || error "mkdir fail"
13562 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir ||
13563 error "set striped dir error"
13564 for ((i=0; i<10; i++)); do
13565 mtime1=$(stat -c %Y $DIR/$tdir/striped_dir)
13567 touch $DIR/$tdir/striped_dir/file_$i ||
13568 error "touch error $i"
13569 mtime2=$(stat -c %Y $DIR/$tdir/striped_dir)
13570 [ $mtime1 -eq $mtime2 ] &&
13571 error "mtime not change after create"
13573 rm -f $DIR/$tdir/striped_dir/file_$i ||
13574 error "unlink error $i"
13575 mtime3=$(stat -c %Y $DIR/$tdir/striped_dir)
13576 [ $mtime2 -eq $mtime3 ] &&
13577 error "mtime did not change after unlink"
13581 run_test 300b "check ctime/mtime for striped dir"
13584 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13585 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
13588 mkdir -p $DIR/$tdir
13589 $LFS setdirstripe -i 0 -c 2 $DIR/$tdir/striped_dir ||
13590 error "set striped dir error"
13592 chown $RUNAS_ID:$RUNAS_GID $DIR/$tdir/striped_dir ||
13593 error "chown striped dir failed"
13595 $RUNAS createmany -o $DIR/$tdir/striped_dir/f 5000 ||
13596 error "create 5k files failed"
13598 file_count=$(ls $DIR/$tdir/striped_dir | wc -l)
13600 [ "$file_count" = 5000 ] || error "file count $file_count != 5000"
13604 run_test 300c "chown && check ls under striped directory"
13607 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13608 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
13612 mkdir -p $DIR/$tdir
13613 $SETSTRIPE -c 2 $DIR/$tdir
13615 #local striped directory
13616 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir ||
13617 error "set striped dir error"
13618 createmany -o $DIR/$tdir/striped_dir/f 10 ||
13619 error "create 10 files failed"
13621 #remote striped directory
13622 $LFS setdirstripe -i 1 -c 2 $DIR/$tdir/remote_striped_dir ||
13623 error "set striped dir error"
13624 createmany -o $DIR/$tdir/remote_striped_dir/f 10 ||
13625 error "create 10 files failed"
13627 for file in $(find $DIR/$tdir); do
13628 stripe_count=$($GETSTRIPE -c $file)
13629 [ $stripe_count -eq 2 ] ||
13630 error "wrong stripe $stripe_count for $file"
13635 run_test 300d "check default stripe under striped directory"
13638 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
13639 skip "Need MDS version at least 2.7.55" && return
13640 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13641 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
13645 mkdir -p $DIR/$tdir
13647 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir ||
13648 error "set striped dir error"
13650 touch $DIR/$tdir/striped_dir/a
13651 touch $DIR/$tdir/striped_dir/b
13652 touch $DIR/$tdir/striped_dir/c
13654 mkdir $DIR/$tdir/striped_dir/dir_a
13655 mkdir $DIR/$tdir/striped_dir/dir_b
13656 mkdir $DIR/$tdir/striped_dir/dir_c
13658 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir/stp_a ||
13659 error "set striped dir under striped dir error"
13661 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir/stp_b ||
13662 error "set striped dir under striped dir error"
13664 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir/stp_c ||
13665 error "set striped dir under striped dir error"
13667 mrename $DIR/$tdir/striped_dir/dir_a $DIR/$tdir/striped_dir/dir_b ||
13668 error "rename dir under striped dir fails"
13670 mrename $DIR/$tdir/striped_dir/stp_a $DIR/$tdir/striped_dir/stp_b ||
13671 error "rename dir under different stripes fails"
13673 mrename $DIR/$tdir/striped_dir/a $DIR/$tdir/striped_dir/c ||
13674 error "rename file under striped dir should succeed"
13676 mrename $DIR/$tdir/striped_dir/dir_b $DIR/$tdir/striped_dir/dir_c ||
13677 error "rename dir under striped dir should succeed"
13681 run_test 300e "check rename under striped directory"
13684 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
13685 skip "Need MDS version at least 2.7.55" && return
13686 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13687 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
13692 mkdir -p $DIR/$tdir
13694 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir ||
13695 error "set striped dir error"
13697 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir1 ||
13698 error "set striped dir error"
13700 touch $DIR/$tdir/striped_dir/a
13701 mkdir $DIR/$tdir/striped_dir/dir_a
13702 $LFS setdirstripe -i 0 -c 2 $DIR/$tdir/striped_dir/stp_a ||
13703 error "create striped dir under striped dir fails"
13705 touch $DIR/$tdir/striped_dir1/b
13706 mkdir $DIR/$tdir/striped_dir1/dir_b
13707 $LFS setdirstripe -i 0 -c 2 $DIR/$tdir/striped_dir/stp_b ||
13708 error "create striped dir under striped dir fails"
13710 mrename $DIR/$tdir/striped_dir/dir_a $DIR/$tdir/striped_dir1/dir_b ||
13711 error "rename dir under different striped dir should fail"
13713 mrename $DIR/$tdir/striped_dir/stp_a $DIR/$tdir/striped_dir1/stp_b ||
13714 error "rename striped dir under diff striped dir should fail"
13716 mrename $DIR/$tdir/striped_dir/a $DIR/$tdir/striped_dir1/a ||
13717 error "rename file under diff striped dirs fails"
13721 run_test 300f "check rename cross striped directory"
13723 test_300_check_default_striped_dir()
13726 local default_count=$2
13727 local default_index=$3
13730 local dir_stripe_index
13733 echo "checking $dirname $default_count $default_index"
13734 $LFS setdirstripe -D -c $default_count -i $default_index \
13735 -t all_char $DIR/$tdir/$dirname ||
13736 error "set default stripe on striped dir error"
13737 stripe_count=$($LFS getdirstripe -D -c $DIR/$tdir/$dirname)
13738 [ $stripe_count -eq $default_count ] ||
13739 error "expect $default_count get $stripe_count for $dirname"
13741 stripe_index=$($LFS getdirstripe -D -i $DIR/$tdir/$dirname)
13742 [ $stripe_index -eq $default_index ] ||
13743 error "expect $default_index get $stripe_index for $dirname"
13745 mkdir $DIR/$tdir/$dirname/{test1,test2,test3,test4} ||
13746 error "create dirs failed"
13748 createmany -o $DIR/$tdir/$dirname/f- 10 || error "create files failed"
13749 unlinkmany $DIR/$tdir/$dirname/f- 10 || error "unlink files failed"
13750 for dir in $(find $DIR/$tdir/$dirname/*); do
13751 stripe_count=$($LFS getdirstripe -c $dir)
13752 [ $stripe_count -eq $default_count ] ||
13753 [ $stripe_count -eq 0 -o $default_count -eq 1 ] ||
13754 error "stripe count $default_count != $stripe_count for $dir"
13756 stripe_index=$($LFS getdirstripe -i $dir)
13757 [ $default_index -eq -1 -o $stripe_index -eq $default_index ] ||
13758 error "$stripe_index != $default_index for $dir"
13760 #check default stripe
13761 stripe_count=$($LFS getdirstripe -D -c $dir)
13762 [ $stripe_count -eq $default_count ] ||
13763 error "default count $default_count != $stripe_count for $dir"
13765 stripe_index=$($LFS getdirstripe -D -i $dir)
13766 [ $stripe_index -eq $default_index ] ||
13767 error "default index $default_index != $stripe_index for $dir"
13769 rmdir $DIR/$tdir/$dirname/* || error "rmdir failed"
13773 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
13774 skip "Need MDS version at least 2.7.55" && return
13775 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
13781 mkdir $DIR/$tdir/normal_dir
13783 test_300_check_default_striped_dir normal_dir $MDSCOUNT 1
13784 test_300_check_default_striped_dir normal_dir 1 0
13785 test_300_check_default_striped_dir normal_dir 2 1
13786 test_300_check_default_striped_dir normal_dir 2 -1
13788 #delete default stripe information
13789 echo "delete default stripeEA"
13790 $LFS setdirstripe -d $DIR/$tdir/normal_dir ||
13791 error "set default stripe on striped dir error"
13793 mkdir -p $DIR/$tdir/normal_dir/{test1,test2,test3,test4}
13794 for dir in $(find $DIR/$tdir/normal_dir/*); do
13795 stripe_count=$($LFS getdirstripe -c $dir)
13796 [ $stripe_count -eq 0 ] ||
13797 error "expect 1 get $stripe_count for $dir"
13798 stripe_index=$($LFS getdirstripe -i $dir)
13799 [ $stripe_index -eq 0 ] ||
13800 error "expect 0 get $stripe_index for $dir"
13803 run_test 300g "check default striped directory for normal directory"
13806 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
13807 skip "Need MDS version at least 2.7.55" && return
13808 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
13813 $LFS setdirstripe -i 0 -c $MDSCOUNT -t all_char \
13814 $DIR/$tdir/striped_dir ||
13815 error "set striped dir error"
13817 test_300_check_default_striped_dir striped_dir $MDSCOUNT 1
13818 test_300_check_default_striped_dir striped_dir 1 0
13819 test_300_check_default_striped_dir striped_dir 2 1
13820 test_300_check_default_striped_dir striped_dir 2 -1
13822 #delete default stripe information
13823 $LFS setdirstripe -d $DIR/$tdir/striped_dir ||
13824 error "set default stripe on striped dir error"
13826 mkdir -p $DIR/$tdir/striped_dir/{test1,test2,test3,test4}
13827 for dir in $(find $DIR/$tdir/striped_dir/*); do
13828 stripe_count=$($LFS getdirstripe -c $dir)
13829 [ $stripe_count -eq 0 ] ||
13830 error "expect 1 get $stripe_count for $dir"
13833 run_test 300h "check default striped directory for striped directory"
13836 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
13837 skip "Need MDS version at least 2.7.55" && return
13838 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13839 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
13845 $LFS setdirstripe -i 0 -c$MDSCOUNT -t all_char $DIR/$tdir/striped_dir ||
13846 error "set striped dir error"
13848 createmany -o $DIR/$tdir/striped_dir/f- 10 ||
13849 error "create files under striped dir failed"
13851 # unfortunately, we need to umount to clear dir layout cache for now
13852 # once we fully implement dir layout, we can drop this
13853 umount_client $MOUNT || error "umount failed"
13854 mount_client $MOUNT || error "mount failed"
13856 #set the stripe to be unknown hash type
13857 #define OBD_FAIL_UNKNOWN_LMV_STRIPE 0x1901
13858 $LCTL set_param fail_loc=0x1901
13859 for ((i = 0; i < 10; i++)); do
13860 $CHECKSTAT -t file $DIR/$tdir/striped_dir/f-$i ||
13861 error "stat f-$i failed"
13862 rm $DIR/$tdir/striped_dir/f-$i || error "unlink f-$i failed"
13865 touch $DIR/$tdir/striped_dir/f0 &&
13866 error "create under striped dir with unknown hash should fail"
13868 $LCTL set_param fail_loc=0
13870 umount_client $MOUNT || error "umount failed"
13871 mount_client $MOUNT || error "mount failed"
13875 run_test 300i "client handle unknown hash type striped directory"
13878 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13879 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
13880 skip "Need MDS version at least 2.7.55" && return
13881 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
13887 #define OBD_FAIL_SPLIT_UPDATE_REC 0x1702
13888 $LCTL set_param fail_loc=0x1702
13889 $LFS setdirstripe -i 0 -c$MDSCOUNT -t all_char $DIR/$tdir/striped_dir ||
13890 error "set striped dir error"
13892 createmany -o $DIR/$tdir/striped_dir/f- 10 ||
13893 error "create files under striped dir failed"
13895 $LCTL set_param fail_loc=0
13897 rm -rf $DIR/$tdir || error "unlink striped dir fails"
13901 run_test 300j "test large update record"
13904 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
13905 skip "Need MDS version at least 2.7.55" && return
13906 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13907 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
13913 #define OBD_FAIL_LARGE_STRIPE 0x1703
13914 $LCTL set_param fail_loc=0x1703
13915 $LFS setdirstripe -i 0 -c512 $DIR/$tdir/striped_dir ||
13916 error "set striped dir error"
13917 $LCTL set_param fail_loc=0
13919 $LFS getdirstripe $DIR/$tdir/striped_dir ||
13920 error "getstripeddir fails"
13921 rm -rf $DIR/$tdir/striped_dir ||
13922 error "unlink striped dir fails"
13926 run_test 300k "test large striped directory"
13929 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
13930 skip "Need MDS version at least 2.7.55" && return
13931 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13932 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
13935 test_mkdir -p $DIR/$tdir/striped_dir
13936 chown $RUNAS_ID $DIR/$tdir/striped_dir ||
13937 error "chown $RUNAS_ID failed"
13938 $LFS setdirstripe -i 1 -D $DIR/$tdir/striped_dir ||
13939 error "set default striped dir failed"
13941 #define OBD_FAIL_MDS_STALE_DIR_LAYOUT 0x158
13942 $LCTL set_param fail_loc=0x80000158
13943 $RUNAS mkdir $DIR/$tdir/striped_dir/test_dir || error "create dir fails"
13945 stripe_index=$($LFS getdirstripe -i $DIR/$tdir/striped_dir/test_dir)
13946 [ $stripe_index -eq 1 ] ||
13947 error "expect 1 get $stripe_index for $dir"
13949 run_test 300l "non-root user to create dir under striped dir with stale layout"
13952 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
13953 skip "Need MDS version at least 2.7.55" && return
13954 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13955 [ $MDSCOUNT -ge 2 ] && skip "Only for single MDT" && return
13957 mkdir -p $DIR/$tdir/striped_dir
13958 $LFS setdirstripe -D -c 1 $DIR/$tdir/striped_dir ||
13959 error "set default stripes dir error"
13961 mkdir $DIR/$tdir/striped_dir/a || error "mkdir a fails"
13963 stripe_count=$($LFS getdirstripe -c $DIR/$tdir/striped_dir/a)
13964 [ $stripe_count -eq 0 ] ||
13965 error "expect 0 get $stripe_count for a"
13967 $LFS setdirstripe -D -c 2 $DIR/$tdir/striped_dir ||
13968 error "set default stripes dir error"
13970 mkdir $DIR/$tdir/striped_dir/b || error "mkdir b fails"
13972 stripe_count=$($LFS getdirstripe -c $DIR/$tdir/striped_dir/b)
13973 [ $stripe_count -eq 0 ] ||
13974 error "expect 0 get $stripe_count for b"
13976 $LFS setdirstripe -D -c1 -i2 $DIR/$tdir/striped_dir ||
13977 error "set default stripes dir error"
13979 mkdir $DIR/$tdir/striped_dir/c &&
13980 error "default stripe_index is invalid, mkdir c should fails"
13982 rm -rf $DIR/$tdir || error "rmdir fails"
13984 run_test 300m "setstriped directory on single MDT FS"
13987 local list=$(comma_list $(mdts_nodes))
13990 do_nodes $list $LCTL set_param -n mdt.*.enable_remote_dir_gid=0
13994 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
13995 skip "Need MDS version at least 2.7.55" && return
13996 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13997 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
13999 local list=$(comma_list $(mdts_nodes))
14001 trap cleanup_300n RETURN EXIT
14002 mkdir -p $DIR/$tdir
14003 chmod 777 $DIR/$tdir
14004 $RUNAS $LFS setdirstripe -i0 -c$MDSCOUNT \
14005 $DIR/$tdir/striped_dir > /dev/null 2>&1 &&
14006 error "create striped dir succeeds with gid=0"
14008 do_nodes $list $LCTL set_param -n mdt.*.enable_remote_dir_gid=-1
14009 $RUNAS $LFS setdirstripe -i0 -c$MDSCOUNT $DIR/$tdir/striped_dir ||
14010 error "create striped dir fails with gid=-1"
14012 do_nodes $list $LCTL set_param -n mdt.*.enable_remote_dir_gid=0
14013 $RUNAS $LFS setdirstripe -i 1 -c$MDSCOUNT -D \
14014 $DIR/$tdir/striped_dir > /dev/null 2>&1 &&
14015 error "set default striped dir succeeds with gid=0"
14018 do_nodes $list $LCTL set_param -n mdt.*.enable_remote_dir_gid=-1
14019 $RUNAS $LFS setdirstripe -i 1 -c$MDSCOUNT -D $DIR/$tdir/striped_dir ||
14020 error "set default striped dir fails with gid=-1"
14023 do_nodes $list $LCTL set_param -n mdt.*.enable_remote_dir_gid=0
14024 $RUNAS mkdir $DIR/$tdir/striped_dir/test_dir ||
14025 error "create test_dir fails"
14026 $RUNAS mkdir $DIR/$tdir/striped_dir/test_dir1 ||
14027 error "create test_dir1 fails"
14028 $RUNAS mkdir $DIR/$tdir/striped_dir/test_dir2 ||
14029 error "create test_dir2 fails"
14032 run_test 300n "non-root user to create dir under striped dir with default EA"
14035 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
14036 skip "Need MDS version at least 2.7.55" && return
14037 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
14038 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
14042 mkdir -p $DIR/$tdir
14044 numfree1=$(lctl get_param -n mdc.*MDT0000*.filesfree)
14045 numfree2=$(lctl get_param -n mdc.*MDT0001*.filesfree)
14046 if [ $numfree1 -lt 66000 -o $numfree2 -lt 66000 ]; then
14047 skip "not enough free inodes $numfree1 $numfree2"
14051 numfree1=$(lctl get_param -n mdc.*MDT0000-mdc-*.kbytesfree)
14052 numfree2=$(lctl get_param -n mdc.*MDT0001-mdc-*.kbytesfree)
14053 if [ $numfree1 -lt 300000 -o $numfree2 -lt 300000 ]; then
14054 skip "not enough free space $numfree1 $numfree2"
14058 $LFS setdirstripe -c2 $DIR/$tdir/striped_dir ||
14059 error "setdirstripe fails"
14061 createmany -d $DIR/$tdir/striped_dir/d 131000 ||
14062 error "create dirs fails"
14064 $LCTL set_param ldlm.namespaces.*mdc-*.lru_size=0
14065 ls $DIR/$tdir/striped_dir > /dev/null ||
14066 error "ls striped dir fails"
14067 unlinkmany -d $DIR/$tdir/striped_dir/d 131000 ||
14068 error "unlink big striped dir fails"
14070 run_test 300o "unlink big sub stripe(> 65000 subdirs)"
14072 prepare_remote_file() {
14073 mkdir $DIR/$tdir/src_dir ||
14074 error "create remote source failed"
14076 cp /etc/hosts $DIR/$tdir/src_dir/a || error
14077 touch $DIR/$tdir/src_dir/a
14079 $LFS mkdir -i 1 $DIR/$tdir/tgt_dir ||
14080 error "create remote target dir failed"
14082 touch $DIR/$tdir/tgt_dir/b
14084 mrename $DIR/$tdir/src_dir/a $DIR/$tdir/tgt_dir/b ||
14085 error "rename dir cross MDT failed!"
14087 $CHECKSTAT -t file $DIR/$tdir/src_dir/a &&
14088 error "src_child still exists after rename"
14090 $CHECKSTAT -t file $DIR/$tdir/tgt_dir/b ||
14091 error "missing file(a) after rename"
14093 diff /etc/hosts $DIR/$tdir/tgt_dir/b ||
14094 error "diff after rename"
14098 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 4 MDTs" && return
14099 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
14100 local remote_file=$DIR/$tdir/tgt_dir/b
14102 mkdir -p $DIR/$tdir
14104 prepare_remote_file || error "prepare remote file failed"
14107 $OPENUNLINK $remote_file $remote_file || error
14108 $CHECKSTAT -a $remote_file || error
14110 run_test 310a "open unlink remote file"
14113 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 4 MDTs" && return
14114 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
14115 local remote_file=$DIR/$tdir/tgt_dir/b
14117 mkdir -p $DIR/$tdir
14119 prepare_remote_file || error "prepare remote file failed"
14121 ln $remote_file $DIR/$tfile || error "link failed for remote file"
14122 $MULTIOP $DIR/$tfile Ouc || error "mulitop failed"
14123 $CHECKSTAT -t file $remote_file || error "check file failed"
14125 run_test 310b "unlink remote file with multiple links while open"
14128 [[ $MDSCOUNT -lt 4 ]] && skip "needs >= 4 MDTs" && return
14129 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
14130 local remote_file=$DIR/$tdir/tgt_dir/b
14132 mkdir -p $DIR/$tdir
14134 prepare_remote_file || error "prepare remote file failed"
14136 ln $remote_file $DIR/$tfile || error "link failed for remote file"
14137 multiop_bg_pause $remote_file O_uc ||
14138 error "mulitop failed for remote file"
14140 $MULTIOP $DIR/$tfile Ouc
14141 kill -USR1 $MULTIPID
14144 run_test 310c "open-unlink remote file with multiple links"
14146 test_400a() { # LU-1606, was conf-sanity test_74
14147 local extra_flags=''
14148 local out=$TMP/$tfile
14149 local prefix=/usr/include/lustre
14152 if ! which $CC > /dev/null 2>&1; then
14153 skip_env "$CC is not installed"
14157 if ! [[ -d $prefix ]]; then
14158 # Assume we're running in tree and fixup the include path.
14159 extra_flags+=" -I$LUSTRE/../libcfs/include"
14160 extra_flags+=" -I$LUSTRE/include"
14161 extra_flags+=" -L$LUSTRE/utils"
14164 for prog in $LUSTRE_TESTS_API_DIR/*.c; do
14165 $CC -Wall -Werror $extra_flags -llustreapi -o $out $prog ||
14166 error "client api broken"
14169 run_test 400a "Lustre client api program can compile and link"
14171 test_400b() { # LU-1606, LU-5011
14173 local out=$TMP/$tfile
14174 local prefix=/usr/include/lustre
14176 # We use a hard coded prefix so that this test will not fail
14177 # when run in tree. There are headers in lustre/include/lustre/
14178 # that are not packaged (like lustre_idl.h) and have more
14179 # complicated include dependencies (like config.h and lnet/types.h).
14180 # Since this test about correct packaging we just skip them when
14181 # they don't exist (see below) rather than try to fixup cppflags.
14183 if ! which $CC > /dev/null 2>&1; then
14184 skip_env "$CC is not installed"
14188 for header in $prefix/*.h; do
14189 if ! [[ -f "$header" ]]; then
14193 if [[ "$(basename $header)" == liblustreapi.h ]]; then
14194 continue # liblustreapi.h is deprecated.
14197 $CC -Wall -Werror -include $header -c -x c /dev/null -o $out ||
14198 error "cannot compile '$header'"
14201 run_test 400b "packaged headers can be compiled"
14204 # tests that do cleanup/setup should be run at the end
14208 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
14210 #define OBD_FAIL_MGC_PAUSE_PROCESS_LOG 0x903
14211 $LCTL set_param fail_loc=0x903
14213 cancel_lru_locks MGC
14215 FAIL_ON_ERROR=true cleanup
14216 FAIL_ON_ERROR=true setup
14218 run_test 900 "umount should not race with any mgc requeue thread"
14221 [ -f $EXT2_DEV ] && rm $EXT2_DEV || true
14222 check_and_cleanup_lustre
14223 if [ "$I_MOUNTED" != "yes" ]; then
14224 lctl set_param debug="$OLDDEBUG" 2> /dev/null || true