Changeset 372

Show
Ignore:
Timestamp:
08/24/06 22:54:07 (2 years ago)
Author:
marksmith
Message:

* make this do readable vs writeable and throw errors

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/server-newrepl/mogilefsd

    r370 r372  
    239239    my %opts = ( @_ ); 
    240240 
     241    # validate we're getting called with known parameters 
     242    my %valid_keys = map { $_ => 1 } qw( random min_free_space weight_by_free max_disk_age not_on_hosts must_be_writeable must_be_readable );  
     243    warn "invalid key $_ in call to find_deviceid\n" 
     244        foreach grep { ! $valid_keys{$_} } keys %opts; 
     245 
    241246    # copy down global minimum free space if not specified 
    242247    $opts{min_free_space} ||= MogileFS->config("min_free_space"); 
     
    245250        $opts{max_disk_age} = time() - ($opts{max_disk_age} * 60); 
    246251    } 
    247     $opts{must_be_alive} = 1 unless defined $opts{must_be_alive}; 
     252    $opts{must_be_alive} = 1 unless defined $opts{must_be_alive}; 
    248253 
    249254    # setup for iterating over devices 
     
    268273        next if $opts{min_free_space} && $dev->{mb_total} && 
    269274                $dev->{mb_free} < $opts{min_free_space}; 
    270         next if $opts{must_be_alive} && 
     275        next if $opts{must_be_writeable} && 
    271276            (MogileFS->observed_state("host", $dev->{hostid}) ne "reachable" || 
    272277             MogileFS->observed_state("device", $dev->{devid}) ne "writeable"); 
     278        next if $opts{must_be_readable} && 
     279            (MogileFS->observed_state("host", $dev->{hostid}) ne "reachable" || 
     280             MogileFS->observed_state("device", $dev->{devid}) ne "readable"); 
    273281 
    274282        # we get here, this is a suitable device