IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 24539


Ignore:
Timestamp:
Jun 24, 2009, 11:20:15 AM (17 years ago)
Author:
jhoblitt
Message:

start volume handling refactoring

Location:
trunk/Nebulous-Server
Files:
3 edited

Legend:

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

    r24411 r24539  
    6767$retry      ||= $c->get_retry   || 1;
    6868
    69 my $mounts = $c->get_mounts;
     69#my $mounts = $c->get_mounts;
    7070my $poll_interval = $c->get_poll_interval || 5;
    7171
     
    178178    eval {
    179179        my $r_query = $dbh->prepare_cached("REPLACE INTO mount VALUES(?, ?, ?)");
    180         my $d_query = $dbh->prepare_cached("DELETE FROM mount WHERE mountpoint = ?");
    181 
     180        my $d_query = $dbh->prepare_cached("DELETE FROM mount, mountedvol WHERE mountpoint = ?");
     181
     182        # get list of mount points
     183        my $mounts = [];
     184        {
     185            my $query = $dbh->prepared_cached("SELECT mountpoint FROM volume");
     186            $query->execute;
     187            while (my $row = $query->fetchrow_hashref) {
     188                push @$mounts, $row->{'mountpoint'};
     189            }
     190            $query->finish;
     191        }
     192       
    182193        # determine valid mountpoints
    183194        foreach my $mnt (@$mounts) {
     
    212223            }
    213224
     225            # find vol_id(s) for mountpoint
    214226            $r_query->execute($mnt, @$dev_info{qw( blocks used )});
    215227            $log->debug("adding $mnt to db");
  • trunk/Nebulous-Server/lib/Nebulous/Server/SQL.pm

    r24500 r24539  
    517517    name VARCHAR(255) UNIQUE NOT NULL,
    518518    host VARCHAR(255) NOT NULL,
    519     path VARCHAR(255) NOT NULL,
     519    path VARCHAR(255) UNIQUE NOT NULL,
     520    mountpoint VARCHAR(255) NOT NULL,
    520521    allocate BOOLEAN DEFAULT FALSE,
    521522    available BOOLEAN DEFAULT FALSE,
     
    523524    PRIMARY KEY(vol_id),
    524525    KEY(host(16)),
    525     KEY(path(255)),
     526    KEY(mountpoint(255)),
    526527    KEY(allocate),
    527528    KEY(available)
     
    609610
    610611    -- store the okey checking state
    611     SELECT @@FOREIGN_KEY_CHECKS INTO key_checks;
     612--    SELECT @@FOREIGN_KEY_CHECKS INTO key_checks;
    612613    -- disable foregin check checks to prevent deadlocks on the mountedvol table
    613     SET FOREIGN_KEY_CHECKS=0;
     614--    SET FOREIGN_KEY_CHECKS=0;
    614615
    615616    -- make sure the temp table does not already exist... this can happy if the
     
    630631    OPEN cur1;
    631632
    632     DELETE FROM mountedvol;
    633 
    634633    myloop: LOOP
    635634        FETCH cur1 INTO vol_idvar, namevar, hostvar, pathvar, allocatevar, availablevar, xattrvar;
    636635        IF `done` THEN LEAVE myloop; END IF;
    637         INSERT INTO mountedvol
     636        REPLACE INTO mountedvol
    638637            SELECT mountpoint, total, used, vol_idvar, namevar, hostvar, pathvar, allocatevar, availablevar, xattrvar
    639638            FROM
     
    651650
    652651    -- restore the original key checking state
    653     SET @@FOREIGN_KEY_CHECKS = key_checks;
     652--    SET @@FOREIGN_KEY_CHECKS = key_checks;
    654653
    655654    DROP TABLE IF EXISTS myvolume;
    656655
    657     SET FOREIGN_KEY_CHECKS=1;
     656--    SET FOREIGN_KEY_CHECKS=1;
    658657
    659658    COMMIT;
  • trunk/Nebulous-Server/scripts/dirize.pl

    r24521 r24539  
    4444# non-existant value
    4545$db->do("SET FOREIGN_KEY_CHECKS=0");
    46 $db->do("UPDATE storage_object SET dir_id = 0");
     46#$db->do("UPDATE storage_object SET dir_id = 0");
    4747
    4848# completely reset the directory table
    49 $db->do("DELETE FROM directory");
    50 $db->do("ALTER TABLE directory AUTO_INCREMENT = 1");
     49#$db->do("DELETE FROM directory");
     50#$db->do("ALTER TABLE directory AUTO_INCREMENT = 1");
    5151# make sure these duplicates can't happen again
    52 $db->do("alter table directory add unique key(dirname,parent_id)");
     52#$db->do("alter table directory add unique key(dirname,parent_id)");
    5353# seed the root ('/') directory
    54 $db->do("INSERT INTO directory VALUES(1, '/', 1)");
     54#$db->do("INSERT INTO directory VALUES(1, '/', 1)");
    5555
    5656my $i = 0;
Note: See TracChangeset for help on using the changeset viewer.