IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 19871


Ignore:
Timestamp:
Oct 2, 2008, 2:41:55 PM (18 years ago)
Author:
jhoblitt
Message:

remove unused fix_disk_stats()
rework mountpoint polling so that statfs() is called as quickly as possible to avoid the automounter unmounting the volume first.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Nebulous-Server/bin/nebdiskd

    r19796 r19871  
    33# Copyright (C) 2007  Joshua Hoblitt
    44#
    5 # $Id: nebdiskd,v 1.8 2008-10-01 20:42:31 jhoblitt Exp $
     5# $Id: nebdiskd,v 1.9 2008-10-03 00:41:55 jhoblitt Exp $
    66
    77use strict;
     
    106106
    107107        eval {
    108             my @valid_mounts;
     108            # empty the mount table
     109            $dbh->do("DELETE FROM mount");
     110            print "flushed mount table\n" if $debug;
     111
     112            # repopulate the mount table with all valid mounts that we are
     113            # supposed to be watching
     114            my $query = $dbh->prepare_cached("INSERT INTO mount VALUES(?, ?, ?)");
    109115
    110116            # determine valid mountpoints
     
    123129                    next;
    124130                }
    125                 push @valid_mounts, $mnt;
    126             }
    127             # empty the mount table
    128             $dbh->do("DELETE FROM mount");
    129             print "flushed mount table\n" if $debug;
    130 
    131             # repopulate the mount table with all valid mounts that we are
    132             # supposed to be watching
    133             my $query = $dbh->prepare_cached("INSERT INTO mount VALUES(?, ?, ?)");
    134             # get stats on all currently mounted volumes
    135             # this has to be done AFTER we determine what the valid mountpoints
    136             # are incase is_mountpoint() invokes the automounter
    137             foreach my $mnt (@valid_mounts) {
     131
     132                # fetch stats on the mounted device.  this has to be done AFTER
     133                # we determine if it's a valid mountpoint incase
     134                # is_mountpoint() invokes the automounter
    138135                my $dev_info = df($mnt, 1024);
    139136                unless (defined $dev_info) {
     
    141138                    next;
    142139                }
     140
    143141                $query->execute($mnt, @$dev_info{qw( blocks used )});
    144142                print "adding $mnt to db\n" if $debug;
     143
    145144            }
    146145
     
    281280
    282281
    283 sub fix_disk_stats
    284 {
    285     my $stats = shift;
    286 
    287     # take the hash returned by Sys::Statistics::Linux::DiskUsage->new->get and
    288     # replace the keynames with those of the mountpoint for each device
    289     my %new_stats;
    290     foreach my $key (keys %$stats) {
    291         my $disk = $stats->{$key};
    292         $new_stats{$disk->{mountpoint}} = $disk;
    293     }
    294 
    295     return \%new_stats;
    296 }
    297 
    298282__END__
    299283
Note: See TracChangeset for help on using the changeset viewer.