~ubuntu-branches/ubuntu/quantal/ceph/quantal

« back to all changes in this revision

Viewing changes to src/script/check_cache_dumps.pl

  • Committer: Package Import Robot
  • Author(s): James Page
  • Date: 2012-07-16 09:56:24 UTC
  • mfrom: (0.3.11)
  • mto: This revision was merged to the branch mainline in revision 17.
  • Revision ID: package-import@ubuntu.com-20120716095624-azr2w4hbhei1rxmx
Tags: upstream-0.48
ImportĀ upstreamĀ versionĀ 0.48

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/perl
 
2
 
 
3
my $epoch = shift || die "specify epoch";
 
4
 
 
5
my %auth;    # mds -> id -> replica -> nonce
 
6
my %replica; # mds -> id -> auth -> nonce
 
7
 
 
8
print "reading\n";
 
9
for (my $i=0; -e "cachedump.$epoch.mds$i"; $i++) {
 
10
        open(O,"cachedump.$epoch.mds$i");
 
11
        while (<O>) {
 
12
                my ($name,$s);
 
13
                ($name,$s) = /^\[(inode \d+) \S+ (\S+)/;
 
14
                ($name,$s) = /^\[(dir \d+) \S+ (\S+)/ unless $name;
 
15
                ($name,$s) = /^\[dentry (\S+) (\S+)/ unless $name;
 
16
                if ($name) {
 
17
                        if ($s =~ /^auth/) {
 
18
                                $auth{$i}->{$name} = {};
 
19
                                my ($rl) = $s =~ /\{(.*)\}/;
 
20
                                for my $r (split(/,/,$rl)) {
 
21
                                        my ($who,$nonce) = $r =~ /(\d+)\=(\d+)/;
 
22
                                        $auth{$i}->{$name}->{$who} = $nonce;
 
23
                                        #print "auth $name rep by $who $nonce $s\n";
 
24
                                }
 
25
                        }
 
26
                        else {
 
27
                                my ($a,$b,$n) = $s =~ /rep@(\d+)\,([\-\d]+)\.(\d+)/;
 
28
                                die $_ unless $a >= 0;
 
29
                                $replica{$i}->{$name}->{$a} = $n;
 
30
                                if ($b >= 0) {
 
31
                                        $replica{$i}->{$name}->{$b} = $n;
 
32
                                }
 
33
                        }
 
34
                }
 
35
        }
 
36
}
 
37
 
 
38
print "verifying replicas\n";
 
39
for my $mds (keys %replica) {
 
40
        for my $name (keys %{$replica{$mds}}) {
 
41
                for my $auth (keys %{$replica{$mds}->{$name}}) {
 
42
                        if ($auth{$auth}->{$name}->{$mds}) {
 
43
                                if ($auth{$auth}->{$name}->{$mds} < $replica{$mds}->{$name}->{$auth}) {
 
44
                                        print "problem: mds$mds has $name from mds$auth nonce $replica{$mds}->{$name}->{$auth}, auth has nonce $auth{$auth}->{$name}->{$mds}\n";
 
45
                                } else {
 
46
                                        print "ok: mds$mds has $name from mds$auth nonce $replica{$mds}->{$name}->{$auth}, auth has nonce $auth{$auth}->{$name}->{$mds}\n";
 
47
                                }
 
48
                        } else {
 
49
                                print "??: mds$mds has $name from mds$auth nonce $replica{$mds}->{$name}->{$auth}, auth has no nonce\n";
 
50
                        }
 
51
 
 
52
                }
 
53
        }
 
54
}
 
55
 
 
56