[prev in list] [next in list] [prev in thread] [next in thread] 

List:       intermezzo-devel
Subject:    Re: bad lstat debug log
From:       andreas.koenig () anima ! de (Andreas J !  Koenig)
Date:       2000-03-31 18:01:28
[Download RAW message or body]

>>>>> On Fri, 31 Mar 2000 10:16:38 -0700 (MST), "Peter J. Braam" <braam@cs.cmu.edu> said:

 > Hi Andreas,
 > My strong suspicion for this bug is that sync is broken.  There is no
 > mention of the affected directory before the lstat happened, which
 > almost certainly means it wasn't synced in the first place.

If that is the case, you might like to use the small filesystem
verification tool that I used while testing. I include it as a
sharfile below. As it was never intended for publication, it looks a
bit scary, but that should be OK on a devel list;)

I've included a README.

-- 
andreas


#!/bin/sh
# This is a shell archive (produced by GNU sharutils 4.2).
# To extract the files from this archive, save it to some FILE, remove
# everything before the `!/bin/sh' line above, then type `sh FILE'.
#
# Made on 2000-03-31 19:58 CEST by <k@ak-71.mind.de>.
# Source directory was `/home/k/test'.
#
# Existing files will *not* be overwritten unless `-c' is specified.
#
# This shar contains:
# length mode       name
# ------ ---------- ------------------------------------------
#   1882 -rw-rw-r-- disk-stress/wildcontrol.pl
#    866 -rw-rw-r-- disk-stress/README
#   1403 -rw-rw-r-- disk-stress/wildcreate.pl
#
save_IFS="${IFS}"
IFS="${IFS}:"
gettext_dir=FAILED
locale_dir=FAILED
first_param="$1"
for dir in $PATH
do
  if test "$gettext_dir" = FAILED && test -f $dir/gettext \
     && ($dir/gettext --version >/dev/null 2>&1)
  then
    set `$dir/gettext --version 2>&1`
    if test "$3" = GNU
    then
      gettext_dir=$dir
    fi
  fi
  if test "$locale_dir" = FAILED && test -f $dir/shar \
     && ($dir/shar --print-text-domain-dir >/dev/null 2>&1)
  then
    locale_dir=`$dir/shar --print-text-domain-dir`
  fi
done
IFS="$save_IFS"
if test "$locale_dir" = FAILED || test "$gettext_dir" = FAILED
then
  echo=echo
else
  TEXTDOMAINDIR=$locale_dir
  export TEXTDOMAINDIR
  TEXTDOMAIN=sharutils
  export TEXTDOMAIN
  echo="$gettext_dir/gettext -s"
fi
touch -am 1231235999 $$.touch >/dev/null 2>&1
if test ! -f 1231235999 && test -f $$.touch; then
  shar_touch=touch
else
  shar_touch=:
  echo
  $echo 'WARNING: not restoring timestamps.  Consider getting and'
  $echo "installing GNU \`touch', distributed in GNU File Utilities..."
  echo
fi
rm -f 1231235999 $$.touch
#
if mkdir _sh10035; then
  $echo 'x -' 'creating lock directory'
else
  $echo 'failed to create lock directory'
  exit 1
fi
# ============= disk-stress/wildcontrol.pl ==============
if test ! -d 'disk-stress'; then
  $echo 'x -' 'creating directory' 'disk-stress'
  mkdir 'disk-stress'
fi
if test -f 'disk-stress/wildcontrol.pl' && test "$first_param" != -c; then
  $echo 'x -' SKIPPING 'disk-stress/wildcontrol.pl' '(file already exists)'
else
  $echo 'x -' extracting 'disk-stress/wildcontrol.pl' '(text)'
  sed 's/^X//' << 'SHAR_EOF' > 'disk-stress/wildcontrol.pl' &&
Xuse File::Find;
Xuse strict;
X
Xmy $i;
X$|=1;
Xuse vars qw($Havewarned);
X
Xwhile (){
X  my $randfile;
X  unless (defined($randfile = randfile("t"))) {
X    unless ($Havewarned) {
X      warn "Could not find any file";
X      $Havewarned++;
X    }
X    sleep 1;
X    next;
X  }
X  my $mtime = (stat $randfile)[9];
X  next if $mtime > time - 5; # we want the file is complete
X  printf "\r%4d %s%s", ++$i, $randfile, " " x (75-length($randfile));
X  while (not conforms($randfile)){
X    warn "randfile[$randfile] does not conform";
X    sleep 1;
X  }
X  sleep 1;
X}
X
Xsub randfile {
X    my($dir) = shift || ".";
X    local *DIR;
X    unless (opendir DIR, $dir){
X      unless ($Havewarned) {
X	warn "Could not opendir $dir: $!";
X        $Havewarned++;
X      }
X      return;
X    }
X    my @dirent = readdir DIR;
X    closedir DIR;
X    while (@dirent){
X	my $rand = int rand @dirent;
X	if ($dirent[$rand] eq "."
X	    ||
X	    $dirent[$rand] eq ".."
X            ||
X            $dirent[$rand] =~ /^.file/   # XXX how does this escaping
X                                         # work exactly?
X           ){
X	    splice @dirent, $rand, 1;
X	    next;
X	}
X	my $path = "$dir/$dirent[$rand]";
X	stat $path;
X	if ( -d _ ){
X	    if (defined(my $rf = randfile($path))){
X		return $rf;
X	    } else {
X		splice @dirent, $rand, 1;
X		next;
X	    }
X	} elsif ( -f _ ){
X	    return $path;
X	} else {
X	    splice @dirent, $rand, 1;
X	}
X    }
X    return;
X}
X
X# returns 2 if it conforms ans 1 if file doesn't exist
Xsub conforms {
X    my $file = shift;
X    local *FH;
X    unless (open FH, "./$file\0"){
X      if (-f $file) {
X        die "File exists but I could not open it. File[$file]: $!";
X      } else {
X	return 1;
X      }
X    }
X    my $t = "." . substr($file,1);
X    while (<FH>){
X	chomp;
X	unless ($_ eq $t){
X	    if (s|/.?.?/|/|){
X		$t = $_;
X		next;
X	    }
X	    warn "saw[$_]file[$file]";
X	    return;
X	}
X    }
X    close FH && return 2;
X}
X
X
X
X
SHAR_EOF
  $shar_touch -am 03181658100 'disk-stress/wildcontrol.pl' &&
  chmod 0664 'disk-stress/wildcontrol.pl' ||
  $echo 'restore of' 'disk-stress/wildcontrol.pl' 'failed'
  if ( md5sum --help 2>&1 | grep 'sage: md5sum \[' ) >/dev/null 2>&1 \
  && ( md5sum --version 2>&1 | grep -v 'textutils 1.12' ) >/dev/null; then
    md5sum -c << SHAR_EOF >/dev/null 2>&1 \
    || $echo 'disk-stress/wildcontrol.pl:' 'MD5 check failed'
3355cf955c2b6faa4176edef0c95fcfe  disk-stress/wildcontrol.pl
SHAR_EOF
  else
    shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < 'disk-stress/wildcontrol.pl'`"
    test 1882 -eq "$shar_count" ||
    $echo 'disk-stress/wildcontrol.pl:' 'original size' '1882,' 'current size' "$shar_count!"
  fi
fi
# ============= disk-stress/README ==============
if test -f 'disk-stress/README' && test "$first_param" != -c; then
  $echo 'x -' SKIPPING 'disk-stress/README' '(file already exists)'
else
  $echo 'x -' extracting 'disk-stress/README' '(text)'
  sed 's/^X//' << 'SHAR_EOF' > 'disk-stress/README' &&
XA small, slow and steady tool to check the integrity of a permanently
Xchanging filesystem. Slow, so that we can use the system while testing.
XSteady, so that we can expect it to never die.
X
Xwildcreate.pl
X-------------
Xcreates a subdirectory ./t/ and fills it with files and subdirectories
Xuntil the filesystem reaches a certain fullness. It then deletes the
Xwhole tree and starts from the beginning. The clue is that we try to
Xwrite files with random but predictable content.
X
Xwildcontrol.pl
X--------------
Xreads random files below ./t/ and verifies that they conform.
X
XIn a testing scenario, both programs are run simultaneously from the
Xsame directory (or as in the case of InterMezzo, on the source and the
Xthe replicated host). Both files are just a few lines perl, so no
Xoptions are implemented, as everything can be done by editing the
Xsource.
X
Xandreas koenig
SHAR_EOF
  $shar_touch -am 03311954100 'disk-stress/README' &&
  chmod 0664 'disk-stress/README' ||
  $echo 'restore of' 'disk-stress/README' 'failed'
  if ( md5sum --help 2>&1 | grep 'sage: md5sum \[' ) >/dev/null 2>&1 \
  && ( md5sum --version 2>&1 | grep -v 'textutils 1.12' ) >/dev/null; then
    md5sum -c << SHAR_EOF >/dev/null 2>&1 \
    || $echo 'disk-stress/README:' 'MD5 check failed'
639284bc21a45eb7a7da4bb0e3f68c0c  disk-stress/README
SHAR_EOF
  else
    shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < 'disk-stress/README'`"
    test 866 -eq "$shar_count" ||
    $echo 'disk-stress/README:' 'original size' '866,' 'current size' "$shar_count!"
  fi
fi
# ============= disk-stress/wildcreate.pl ==============
if test -f 'disk-stress/wildcreate.pl' && test "$first_param" != -c; then
  $echo 'x -' SKIPPING 'disk-stress/wildcreate.pl' '(file already exists)'
else
  $echo 'x -' extracting 'disk-stress/wildcreate.pl' '(text)'
  sed 's/^X//' << 'SHAR_EOF' > 'disk-stress/wildcreate.pl' &&
Xuse strict;
Xuse vars qw( $Debug $Signal $Fs_size $Lim );
X
X$Signal = 0;
X$SIG{TERM} = $SIG{KILL} = sub { $Signal++ };
X######## use File::Df ('df');
Xuse File::Path;
Xuse File::Basename qw/dirname/;
X
X$|=1;
Xmy $i = 0;
Xmy $bytes = 0;
Xwhile (){
X    my $x="./";
X    while (length($x)<(rand(96)+24)){
X	$x = $x . (rand(4)<1 ? "/" : chr( rand(26) + 44 )); # make
X                                                            # subdirs
X                                                            # often
X    }
X    1 while $x =~ s|/.?.?/|/|;
X    $x =~ s|/+$||;
X    eval {mkpath dirname "t/$x";};
X    if ($@){
X	# e.g. File exists
X	warn "x[$x]\@[$@]![$!]";
X	next;
X    }
X    open F, ">t/$x" or next;
X    my $loop = rand(50000);
X    print F "$x\n" x $loop;
X    close F;
X    last if $Signal;
X
X    $i++;
X    $bytes += ($x+1)*$loop;
X
X    open P, "df t|" or die "Dieing[$!]";
X    my(@df) = <P>;
X    ######## my($fs_type, $fs_desc, $used, $avail, $fused, $favail) = df("t");
X    close P;
X#    print "$du\n";
X    my @fs = split " ", $df[1];
X    my $avail = $fs[3];
X    $Fs_size ||= $fs[1];
X    $Lim ||= $Fs_size < 50000 ? $Fs_size/10 : 50000;
X
X    printf "\ravail %d files %d bytes %d", $avail, $i, $bytes; # if $Debug;
X    sleep 1; # unless $i % 3;
X    if ($avail < $Lim){
X        print "\nRMing at ", scalar localtime, "\n";
X        rmtree "t";
X        print "\nfilling at ", scalar localtime, "\n";
X	$i = $bytes = 0;
X    }
X}
X
SHAR_EOF
  $shar_touch -am 03181229100 'disk-stress/wildcreate.pl' &&
  chmod 0664 'disk-stress/wildcreate.pl' ||
  $echo 'restore of' 'disk-stress/wildcreate.pl' 'failed'
  if ( md5sum --help 2>&1 | grep 'sage: md5sum \[' ) >/dev/null 2>&1 \
  && ( md5sum --version 2>&1 | grep -v 'textutils 1.12' ) >/dev/null; then
    md5sum -c << SHAR_EOF >/dev/null 2>&1 \
    || $echo 'disk-stress/wildcreate.pl:' 'MD5 check failed'
78be81a6092dc510de5dba900e81c13c  disk-stress/wildcreate.pl
SHAR_EOF
  else
    shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < 'disk-stress/wildcreate.pl'`"
    test 1403 -eq "$shar_count" ||
    $echo 'disk-stress/wildcreate.pl:' 'original size' '1403,' 'current size' "$shar_count!"
  fi
fi
rm -fr _sh10035
exit 0

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic