Subversion Repositories zfs_utils

Rev

Rev 20 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 20 Rev 21
Line 114... Line 114...
114
   my ($config,$pattern) = @_;
114
   my ($config,$pattern) = @_;
115
   my %return;
115
   my %return;
116
   # actual command to run to get all snapshots, recursively, of the dataset
116
   # actual command to run to get all snapshots, recursively, of the dataset
117
   my $command = 'zfs list -r -t snap ' . $config->{'dataset'};
117
   my $command = 'zfs list -r -t snap ' . $config->{'dataset'};
118
   $command = "ssh $config->{server} '$command'" if $config->{'server'};
118
   $command = "ssh $config->{server} '$command'" if $config->{'server'};
119
   #die "$command\n";
-
 
120
   my ($error, $output ) = &run( $command );
119
   my ($error, $output ) = &run( $command );
121
   #die "Error running $command with output\n$output" if $error;
120
   die "Error running $command with output [$output]\nMisconfigured Dataset?\n" if $error;
122
   my @snaps = split( "\n", $output );
121
   my @snaps = split( "\n", $output );
123
   chomp @snaps;
122
   chomp @snaps;
124
   for (my $i = 0; $i < @snaps; $i++ ) {
123
   for (my $i = 0; $i < @snaps; $i++ ) {
125
      # parse out the space delmited fields
124
      # parse out the space delmited fields
126
      my ($fullname, $used, $avail, $refer, $mount) = split( /\s+/, $snaps[$i] );
125
      my ($fullname, $used, $avail, $refer, $mount) = split( /\s+/, $snaps[$i] );
Line 243... Line 242...
243
 
242
 
244
# Checks if all child datasets have all the snapshots the parent has.
243
# Checks if all child datasets have all the snapshots the parent has.
245
# If not, returns a list of datasets to replicate individually.
244
# If not, returns a list of datasets to replicate individually.
246
sub check_child_snap_consistency {
245
sub check_child_snap_consistency {
247
    my ($config, $side) = @_;
246
    my ($config, $side) = @_;
-
 
247
    #print Dumper( $config ) . "\n"; die;
248
    my $snaps = $config->{$side}{'snapshots'};
248
    my $snaps = $config->{$side}->{'snapshots'};
-
 
249
    #print Dumper( $snaps ) . "\n"; die;
249
    my @datasets = keys %$snaps;
250
    my @datasets = keys %$snaps;
-
 
251
    #die Dumper( \@datasets ) . "\n";
250
    return @datasets if @datasets == 1; # Only parent, nothing to check
252
    return @datasets if @datasets == 1; # Only parent, nothing to check
251
 
253
 
252
    my $parent = (sort @datasets)[0]; # Assume parent is first (no / in name or shortest)
254
    my $parent = (sort @datasets)[0]; # Assume parent is first (no / in name or shortest)
-
 
255
    #die Dumper( \@datasets ) . "\n";
253
    my %parent_snaps = %{ $snaps->{$parent}{'snaps'} };
256
    my %parent_snaps = %{ $snaps->{$parent}{'snaps'} };
254
 
257
 
255
    my @inconsistent;
258
    my @inconsistent;
256
    foreach my $child (@datasets) {
259
    foreach my $child (@datasets) {
257
        next if $child eq $parent;
260
        next if $child eq $parent;