📄 sanity.sh
字号:
error "$BEFOREWRITES < $AFTERWRITES" start_writeback}run_test 42a "ensure that we don't flush on close =============="test_42b() { setup_test42 cancel_lru_locks osc stop_writeback sync dd if=/dev/zero of=$DIR/f42b bs=1024 count=100 BEFOREWRITES=`count_ost_writes` $MUNLINK $DIR/f42b || error "$MUNLINK $DIR/f42b: $?" AFTERWRITES=`count_ost_writes` if [ $BEFOREWRITES -lt $AFTERWRITES ]; then error "$BEFOREWRITES < $AFTERWRITES on unlink" fi BEFOREWRITES=`count_ost_writes` sync || error "sync: $?" AFTERWRITES=`count_ost_writes` if [ $BEFOREWRITES -lt $AFTERWRITES ]; then error "$BEFOREWRITES < $AFTERWRITES on sync" fi dmesg | grep 'error from obd_brw_async' && error 'error writing back' start_writeback return 0}run_test 42b "test destroy of file with cached dirty data ======"# if these tests just want to test the effect of truncation,# they have to be very careful. consider:# - the first open gets a {0,EOF}PR lock# - the first write conflicts and gets a {0, count-1}PW# - the rest of the writes are under {count,EOF}PW# - the open for truncate tries to match a {0,EOF}PR# for the filesize and cancels the PWs.# any number of fixes (don't get {0,EOF} on open, match# composite locks, do smarter file size management) fix# this, but for now we want these tests to verify that# the cancellation with truncate intent works, so we# start the file with a full-file pw lock to match against# until the truncate.trunc_test() { test=$1 file=$DIR/$test offset=$2 cancel_lru_locks osc stop_writeback # prime the file with 0,EOF PW to match touch $file $TRUNCATE $file 0 sync; sync # now the real test.. dd if=/dev/zero of=$file bs=1024 count=100 BEFOREWRITES=`count_ost_writes` $TRUNCATE $file $offset cancel_lru_locks osc AFTERWRITES=`count_ost_writes` start_writeback}test_42c() { trunc_test 42c 1024 [ $BEFOREWRITES -eq $AFTERWRITES ] && \ error "beforewrites $BEFOREWRITES == afterwrites $AFTERWRITES on truncate" rm $file}run_test 42c "test partial truncate of file with cached dirty data"test_42d() { trunc_test 42d 0 [ $BEFOREWRITES -eq $AFTERWRITES ] || \ error "beforewrites $BEFOREWRITES != afterwrites $AFTERWRITES on truncate" rm $file}run_test 42d "test complete truncate of file with cached dirty data"test_43() { cp -p /bin/ls $DIR/$tdir/$tfile multiop $DIR/$tdir/$tfile Ow_c & pid=$! # give multiop a chance to open sleep 1 $DIR/$tdir/$tfile && error || true kill -USR1 $pid}run_test 43 "execution of file opened for write should return -ETXTBSY"test_43a() { mkdir -p $DIR/d43 cp -p `which multiop` $DIR/d43/multiop MULTIOP_PROG=$DIR/d43/multiop multiop_bg_pause $TMP/test43.junk O_c || return 1 MULTIOP_PID=$! multiop $DIR/d43/multiop Oc && error "expected error, got success" kill -USR1 $MULTIOP_PID || return 2 wait $MULTIOP_PID || return 3 rm $TMP/test43.junk}run_test 43a "open(RDWR) of file being executed should return -ETXTBSY"test_43b() { mkdir -p $DIR/d43 cp -p `which multiop` $DIR/d43/multiop MULTIOP_PROG=$DIR/d43/multiop multiop_bg_pause $TMP/test43.junk O_c || return 1 MULTIOP_PID=$! truncate $DIR/d43/multiop 0 && error "expected error, got success" kill -USR1 $MULTIOP_PID || return 2 wait $MULTIOP_PID || return 3 rm $TMP/test43.junk}run_test 43b "truncate of file being executed should return -ETXTBSY"test_43c() { local testdir="$DIR/d43c" mkdir -p $testdir cp $SHELL $testdir/ ( cd $(dirname $SHELL) && md5sum $(basename $SHELL) ) | \ ( cd $testdir && md5sum -c)}run_test 43c "md5sum of copy into lustre========================"test_44() { [ "$OSTCOUNT" -lt "2" ] && skip "skipping 2-stripe test" && return dd if=/dev/zero of=$DIR/f1 bs=4k count=1 seek=1023 dd if=$DIR/f1 of=/dev/null bs=4k count=1}run_test 44 "zero length read from a sparse stripe ============="test_44a() { local nstripe=`$LCTL lov_getconfig $DIR | grep default_stripe_count: | \ awk '{print $2}'` [ -z "$nstripe" ] && skip "can't get stripe info" && return [ "$nstripe" -gt "$OSTCOUNT" ] && skip "Wrong default_stripe_count: $nstripe (OSTCOUNT: $OSTCOUNT)" && return local stride=`$LCTL lov_getconfig $DIR | grep default_stripe_size: | \ awk '{print $2}'` if [ $nstripe -eq 0 -o $nstripe -eq -1 ] ; then nstripe=`$LCTL lov_getconfig $DIR | grep obd_count: | awk '{print $2}'` fi OFFSETS="0 $((stride/2)) $((stride-1))" for offset in $OFFSETS ; do for i in `seq 0 $((nstripe-1))`; do rm -f $DIR/d44a local GLOBALOFFSETS="" local size=$((((i + 2 * $nstripe )*$stride + $offset))) # Bytes ll_sparseness_write $DIR/d44a $size || error "ll_sparseness_write" GLOBALOFFSETS="$GLOBALOFFSETS $size" ll_sparseness_verify $DIR/d44a $GLOBALOFFSETS \ || error "ll_sparseness_verify $GLOBALOFFSETS" for j in `seq 0 $((nstripe-1))`; do size=$((((j + $nstripe )*$stride + $offset))) # Bytes ll_sparseness_write $DIR/d44a $size || error "ll_sparseness_write" GLOBALOFFSETS="$GLOBALOFFSETS $size" done ll_sparseness_verify $DIR/d44a $GLOBALOFFSETS \ || error "ll_sparseness_verify $GLOBALOFFSETS" done done}run_test 44a "test sparse pwrite ==============================="dirty_osc_total() { tot=0 for d in `lctl get_param -n osc.*.cur_dirty_bytes`; do tot=$(($tot + d)) done echo $tot}do_dirty_record() { before=`dirty_osc_total` echo executing "\"$*\"" eval $* after=`dirty_osc_total` echo before $before, after $after}test_45() { f="$DIR/f45" # Obtain grants from OST if it supports it echo blah > ${f}_grant stop_writeback sync do_dirty_record "echo blah > $f" [ $before -eq $after ] && error "write wasn't cached" do_dirty_record "> $f" [ $before -gt $after ] || error "truncate didn't lower dirty count" do_dirty_record "echo blah > $f" [ $before -eq $after ] && error "write wasn't cached" do_dirty_record "sync" [ $before -gt $after ] || error "writeback didn't lower dirty count" do_dirty_record "echo blah > $f" [ $before -eq $after ] && error "write wasn't cached" do_dirty_record "cancel_lru_locks osc" [ $before -gt $after ] || error "lock cancellation didn't lower dirty count" start_writeback}run_test 45 "osc io page accounting ============================"page_size() { getconf PAGE_SIZE}# in a 2 stripe file (lov.sh), page 1023 maps to page 511 in its object. this# test tickles a bug where re-dirtying a page was failing to be mapped to the# objects offset and an assert hit when an rpc was built with 1023's mapped # offset 511 and 511's raw 511 offset. it also found general redirtying bugs.test_46() { f="$DIR/f46" stop_writeback sync dd if=/dev/zero of=$f bs=`page_size` seek=511 count=1 sync dd conv=notrunc if=/dev/zero of=$f bs=`page_size` seek=1023 count=1 dd conv=notrunc if=/dev/zero of=$f bs=`page_size` seek=511 count=1 sync start_writeback}run_test 46 "dirtying a previously written page ================"# Check that device nodes are created and then visible correctly (#2091)test_47() { cmknod $DIR/test_47_node || error}run_test 47 "Device nodes check ================================"test_48a() { # bug 2399 check_kernel_version 34 || return 0 mkdir -p $DIR/d48a cd $DIR/d48a mv $DIR/d48a $DIR/d48.new || error "move directory failed" mkdir $DIR/d48a || error "recreate directory failed" touch foo || error "'touch foo' failed after recreating cwd" mkdir bar || error "'mkdir foo' failed after recreating cwd" if check_kernel_version 44; then touch .foo || error "'touch .foo' failed after recreating cwd" mkdir .bar || error "'mkdir .foo' failed after recreating cwd" fi ls . > /dev/null || error "'ls .' failed after recreating cwd" ls .. > /dev/null || error "'ls ..' failed after removing cwd" cd . || error "'cd .' failed after recreating cwd" mkdir . && error "'mkdir .' worked after recreating cwd" rmdir . && error "'rmdir .' worked after recreating cwd" ln -s . baz || error "'ln -s .' failed after recreating cwd" cd .. || error "'cd ..' failed after recreating cwd"}run_test 48a "Access renamed working dir (should return errors)="test_48b() { # bug 2399 check_kernel_version 34 || return 0 mkdir -p $DIR/d48b cd $DIR/d48b rmdir $DIR/d48b || error "remove cwd $DIR/d48b failed" touch foo && error "'touch foo' worked after removing cwd" mkdir foo && error "'mkdir foo' worked after removing cwd" if check_kernel_version 44; then touch .foo && error "'touch .foo' worked after removing cwd" mkdir .foo && error "'mkdir .foo' worked after removing cwd" fi ls . > /dev/null && error "'ls .' worked after removing cwd" ls .. > /dev/null || error "'ls ..' failed after removing cwd" is_patchless || ( cd . && error "'cd .' worked after removing cwd" ) mkdir . && error "'mkdir .' worked after removing cwd" rmdir . && error "'rmdir .' worked after removing cwd" ln -s . foo && error "'ln -s .' worked after removing cwd" cd .. || echo "'cd ..' failed after removing cwd `pwd`" #bug 3517}run_test 48b "Access removed working dir (should return errors)="test_48c() { # bug 2350 check_kernel_version 36 || return 0 #sysctl -w lnet.debug=-1 #set -vx mkdir -p $DIR/d48c/dir cd $DIR/d48c/dir $TRACE rmdir $DIR/d48c/dir || error "remove cwd $DIR/d48c/dir failed" $TRACE touch foo && error "'touch foo' worked after removing cwd" $TRACE mkdir foo && error "'mkdir foo' worked after removing cwd" if check_kernel_version 44; then touch .foo && error "'touch .foo' worked after removing cwd" mkdir .foo && error "'mkdir .foo' worked after removing cwd" fi $TRACE ls . && error "'ls .' worked after removing cwd" $TRACE ls .. || error "'ls ..' failed after removing cwd" is_patchless || ( $TRACE cd . && error "'cd .' worked after removing cwd" ) $TRACE mkdir . && error "'mkdir .' worked after removing cwd" $TRACE rmdir . && error "'rmdir .' worked after removing cwd" $TRACE ln -s . foo && error "'ln -s .' worked after removing cwd" $TRACE cd .. || echo "'cd ..' failed after removing cwd `pwd`" #bug 3415}run_test 48c "Access removed working subdir (should return errors)"test_48d() { # bug 2350 check_kernel_version 36 || return 0 #sysctl -w lnet.debug=-1 #set -vx mkdir -p $DIR/d48d/dir cd $DIR/d48d/dir $TRACE rmdir $DIR/d48d/dir || error "remove cwd $DIR/d48d/dir failed" $TRACE rmdir $DIR/d48d || error "remove parent $DIR/d48d failed" $TRACE touch foo && error "'touch foo' worked after removing parent" $TRACE mkdir foo && error "'mkdir foo' worked after removing parent" if check_kernel_version 44; then touch .foo && error "'touch .foo' worked after removing parent" mkdir .foo && error "'mkdir .foo' worked after removing parent" fi $TRACE ls . && error "'ls .' worked after removing parent" $TRACE ls .. && error "'ls ..' worked after removing parent" is_patchless || ( $TRACE cd . && error "'cd .' worked after recreate parent" ) $TRACE mkdir . && error "'mkdir .' worked after removing parent" $TRACE rmdir . && error "'rmdir .' worked after removing parent" $TRACE ln -s . foo && error "'ln -s .' worked after removing parent" is_patchless || ( $TRACE cd .. && error "'cd ..' worked after removing parent" || true )}run_test 48d "Access removed parent subdir (should return errors)"test_48e() { # bug 4134 check_kernel_version 41 || return 0 #sysctl -w lnet.debug=-1 #set -vx mkdir -p $DIR/d48e/dir cd $DIR/d48e/dir $TRACE rmdir $DIR/d48e/dir || error "remove cwd $DIR/d48e/dir failed" $TRACE rmdir $DIR/d48e || error "remove parent $DIR/d48e failed" $TRACE touch $DIR/d48e || error "'touch $DIR/d48e' failed" $TRACE chmod +x $DIR/d48e || error "'chmod +x $DIR/d48e' failed" # On a buggy kernel addition of "touch foo" after cd .. will # produce kernel oops in lookup_hash_it touch ../foo && error "'cd ..' worked after recreate parent" cd $DIR $TRACE rm $DIR/d48e || error "rm '$DIR/d48e' failed"}run_test 48e "Access to recreated parent subdir (should return errors)"test_50() { # bug 1485 mkdir $DIR/d50 cd $DIR/d50 ls /proc/$$/cwd || error}run_test 50 "special situations: /proc symlinks ==============="test_51() { # bug 1516 - create an empty entry right after ".." then split dir mkdir $DIR/d51 touch $DIR/d51/foo $MCREATE $DIR/d51/bar rm $DIR/d51/foo createmany -m $DIR/d51/longfile 201 FNUM=202 while [ `ls -sd $DIR/d51 | awk '{ print $1 }'` -eq 4 ]; do $MCREATE $DIR/d51/longfile$FNUM FNUM=$(($FNUM + 1)) echo -n "+" done echo ls -l $DIR/d51 > /dev/null || error}run_test 51 "special situations: split htree with empty entry =="export NUMTEST=70000test_51b() { NUMFREE=`df -i -P $DIR | tail -n 1 | awk '{ print $4 }'` [ $NUMFREE -lt 21000 ] && \ skip "not enough free inodes ($NUMFREE)" && \ return check_kernel_version 40 || NUMTEST=31000 [ $NUMFREE -lt $NUMTEST ] && NUMTEST=$(($NUMFREE - 50)) mkdir -p $DIR/d51b createmany -d $DIR/d51b/t- $NUMTEST}run_test 51b "mkdir .../t-0 --- .../t-$NUMTEST ===================="test_51c() { [ ! -d $DIR/d51b ] && skip "$DIR/51b missing" && \ return unlinkmany -d $DIR/d51b/t- $NUMTEST}run_test 51c "rmdir .../t-0 --- .../t-$NUMTEST ===================="test_51d() { [ "$OSTCOUNT" -lt "3" ] && skip "skipping test with few OSTs" && return mkdir -p $DIR/d51d createmany -o $DIR/d51d/t- 1000 $LFS getstripe $DIR/d51d > $TMP/files for N in `seq 0 $((OSTCOUNT - 1))`; do OBJS[$N]=`awk -vobjs=0 '($1 == '$N') { objs += 1 } END { print objs;}' $TMP/files` OBJS0[$N]=`grep -A 1 idx $TMP/files | awk -vobjs=0 '($1 == '$N') { objs += 1 } END { print objs;}'` log "OST$N has ${OBJS[$N]} objects, ${OBJS0[$N]} are index 0" done unlinkmany $DIR/d51d/t- 1000 NLAST=0 for N in `seq 1 $((OSTCOUNT - 1))`; do [ ${OBJS[$N]} -lt $((${OBJS[$NLAST]} - 20)) ] && \ error "OST $N has less objects vs OST $NLAST (${OBJS[$N]} < ${OBJS[$NLAST]}" [ ${OBJS[$N]} -gt $((${OBJS[$NLAST]} + 20)) ] && \ error "OST $N has less objects vs OST $NLAST (${OBJS[$N]} < ${OBJS[$NLAST]}" [ ${OBJS0[$N]} -lt $((${OBJS0[$NLAST]} - 20)) ] && \ error "OST $N has less #0 objects vs OST $NLAST (${OBJS0[$N]} < ${OBJS0[$NLAST]}" [ ${OBJS0[$N]} -gt $((${OBJS0[$NLAST]} + 20)) ] && \ error "OST $N has less #0 objects vs OST $NLAST (${OBJS0[$N]} < ${OBJS0[$NLAST]}" NLAST=$N done}run_test 51d "check object distribution ===================="test_52a() { [ -f $DIR/d52a/foo ] && chattr -a $DIR/d52a/foo mkdir -p $DIR/d52a touch $DIR/d52a/foo chattr =a $DIR/d52a/foo || error "chattr =a failed" echo bar >> $DIR/d52a/foo || error "append bar failed" cp /etc/hosts $DIR/d52a/foo && error "cp worked" rm -f $DIR/d52a/foo 2>/dev/null && error "rm worked" link $DIR/d52a/foo $DIR/d52a/foo_link 2>/dev/null && error "link worked" echo foo >> $DIR/d52a/foo || error "append foo failed" mrename $DIR/d52a/foo $DIR/d52a/foo_ren
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -