Changeset 2717


Ignore:
Timestamp:
28/08/2010 10:01:16 (18 months ago)
Author:
chris
Message:

Remove QDBM, and switch BackupClientInodeToIDMap to use the bundled TDB
instead.

Location:
box/trunk
Files:
1 deleted
8 edited

Legend:

Unmodified
Added
Removed
  • box/trunk/bin/bbackupd/BackupClientInodeToIDMap.cpp

    r2631 r2717  
    1111 
    1212#include <stdlib.h> 
    13 #include <depot.h> 
     13 
     14#define _PUBLIC_ 
     15#include "tdb.h" 
    1416 
    1517#define BACKIPCLIENTINODETOIDMAP_IMPLEMENTATION 
     
    2729} IDBRecord; 
    2830 
    29 #define BOX_DBM_MESSAGE(stuff) stuff << " (qdbm): " << dperrmsg(dpecode) 
     31#define BOX_DBM_MESSAGE(stuff) stuff << " (tdb): " << tdb_error(mpContext) 
    3032 
    3133#define BOX_LOG_DBM_ERROR(stuff) \ 
     
    3739                BOX_DBM_MESSAGE(message << ": " << filename)); 
    3840 
    39 #define ASSERT_DBM_OK(operation, message, filename, exception, subtype) \ 
    40         if(!(operation)) \ 
     41#define ASSERT_DBM(success, message, exception, subtype) \ 
     42        if(!(success)) \ 
    4143        { \ 
    42                 THROW_DBM_ERROR(message, filename, exception, subtype); \ 
     44                THROW_DBM_ERROR(message, mFilename, exception, subtype); \ 
    4345        } 
    4446 
    4547#define ASSERT_DBM_OPEN() \ 
    46         if(mpDepot == 0) \ 
     48        if(mpContext == 0) \ 
    4749        { \ 
    4850                THROW_EXCEPTION_MESSAGE(BackupStoreException, InodeMapNotOpen, \ 
     
    5153 
    5254#define ASSERT_DBM_CLOSED() \ 
    53         if(mpDepot != 0) \ 
     55        if(mpContext != 0) \ 
    5456        { \ 
    5557                THROW_EXCEPTION_MESSAGE(CommonException, Internal, \ 
     
    6870        : mReadOnly(true), 
    6971          mEmpty(false), 
    70           mpDepot(0) 
     72          mpContext(NULL) 
    7173{ 
    7274} 
     
    8284BackupClientInodeToIDMap::~BackupClientInodeToIDMap() 
    8385{ 
    84         if(mpDepot != 0) 
     86        if(mpContext != NULL) 
    8587        { 
    8688                Close(); 
     
    109111         
    110112        // Open the database file 
    111         int mode = ReadOnly ? DP_OREADER : DP_OWRITER; 
     113        int mode = ReadOnly ? O_RDONLY : O_RDWR; 
    112114        if(CreateNew) 
    113115        { 
    114                 mode |= DP_OCREAT; 
    115         } 
    116          
    117         mpDepot = dpopen(Filename, mode, 0); 
    118          
    119         ASSERT_DBM_OK(mpDepot, "Failed to open inode database", mFilename, 
     116                mode |= O_CREAT; 
     117        } 
     118         
     119        mpContext = tdb_open(Filename, 0, 0, mode, 0700); 
     120         
     121        ASSERT_DBM(mpContext != NULL, "Failed to open inode database", 
    120122                BackupStoreException, BerkelyDBFailure); 
    121123         
     
    138140{ 
    139141        ASSERT_DBM_CLOSED(); 
    140         ASSERT(mpDepot == 0); 
     142        ASSERT(mpContext == NULL); 
    141143        mEmpty = true; 
    142144        mReadOnly = true; 
     
    154156{ 
    155157        ASSERT_DBM_OPEN(); 
    156         ASSERT_DBM_OK(dpclose(mpDepot), "Failed to close inode database", 
    157                 mFilename, BackupStoreException, BerkelyDBFailure); 
    158         mpDepot = 0; 
    159 } 
     158        ASSERT_DBM(tdb_close(mpContext) == 0, "Failed to close inode database", 
     159                BackupStoreException, BerkelyDBFailure); 
     160        mpContext = NULL; 
     161} 
     162 
     163static TDB_DATA GetDatum(void* dptr, size_t dsize) 
     164{ 
     165        TDB_DATA datum; 
     166        datum.dptr = (unsigned char *)dptr; 
     167        datum.dsize = dsize; 
     168        return datum; 
     169} 
     170 
     171#define GET_STRUCT_DATUM(structure) \ 
     172        GetDatum(&structure, sizeof(structure)) 
    160173 
    161174// -------------------------------------------------------------------------- 
     
    177190        } 
    178191 
    179         if(mpDepot == 0) 
     192        if(mpContext == 0) 
    180193        { 
    181194                THROW_EXCEPTION(BackupStoreException, InodeMapNotOpen); 
     
    189202        rec.mInDirectory = InDirectory; 
    190203 
    191         ASSERT_DBM_OK(dpput(mpDepot, (const char *)&InodeRef, sizeof(InodeRef), 
    192                 (const char *)&rec, sizeof(rec), DP_DOVER), 
    193                 "Failed to add record to inode database", mFilename, 
     204        ASSERT_DBM(tdb_store(mpContext, GET_STRUCT_DATUM(InodeRef), 
     205                GET_STRUCT_DATUM(rec), 0) == 0, 
     206                "Failed to add record to inode database", 
    194207                BackupStoreException, BerkelyDBFailure); 
    195208} 
     
    215228        } 
    216229 
    217         if(mpDepot == 0) 
     230        if(mpContext == 0) 
    218231        { 
    219232                THROW_EXCEPTION(BackupStoreException, InodeMapNotOpen); 
     
    222235        ASSERT_DBM_OPEN(); 
    223236 
    224         IDBRecord rec; 
    225          
    226         if(dpgetwb(mpDepot, (const char *)&InodeRef, sizeof(InodeRef), 
    227                 0, sizeof(IDBRecord), (char *)&rec) == -1) 
     237        TDB_DATA datum = tdb_fetch(mpContext, GET_STRUCT_DATUM(InodeRef)); 
     238        if(datum.dptr == NULL) 
    228239        { 
    229240                // key not in file 
    230241                return false; 
    231242        } 
     243 
     244        IDBRecord rec; 
     245        if(datum.dsize != sizeof(rec)) 
     246        { 
     247                THROW_EXCEPTION_MESSAGE(CommonException, Internal, 
     248                        "Failed to get inode database entry: " 
     249                        "record has wrong size: expected " << 
     250                        sizeof(rec) << " but was " << datum.dsize << 
     251                        " in " << mFilename); 
     252        } 
    232253                 
     254        rec = *(IDBRecord *)datum.dptr; 
     255        free(datum.dptr); 
     256         
    233257        // Return data 
    234258        rObjectIDOut = rec.mObjectID; 
  • box/trunk/bin/bbackupd/BackupClientInodeToIDMap.h

    r2631 r2717  
    1818// avoid having to include the DB files when not necessary 
    1919#ifndef BACKIPCLIENTINODETOIDMAP_IMPLEMENTATION 
    20         class DEPOT; 
     20        struct TDB_CONTEXT; 
     21        struct TDB_DATUM; 
    2122#endif 
    2223 
     
    5051        bool mEmpty; 
    5152        std::string mFilename; 
    52         DEPOT *mpDepot; 
     53        TDB_CONTEXT *mpContext; 
    5354}; 
    5455 
  • box/trunk/bootstrap

    r217 r2717  
    11#!/bin/sh 
     2 
     3set -e 
    24 
    35aclocal -I infrastructure/m4 
    46autoheader 
    57autoconf 
     8( cd bundled/tdb; ./autogen.sh; ) 
  • box/trunk/configure.ac

    r2628 r2717  
    385385 
    386386cat parcels.txt | sed -e 's/#.*//' | while read cmd subdir configure_args; do 
    387         if test "$cmd" = "subdir"; then 
     387        if test "$cmd" = "configure"; then 
    388388                echo 
    389389                export CC CXX CXXFLAGS LDFLAGS LIBS 
  • box/trunk/infrastructure/makebuildenv.pl.in

    r2640 r2717  
    253253        # check directory exists 
    254254        die "Module $mod can't be found\n" unless -d $mod; 
     255 
     256        # skip bundled libraries with their own Makefile process         
     257        next if ($mod =~ m|^bundled/|); 
    255258         
    256259        # and put in lists 
     
    511514        }        
    512515         
    513  
    514516        # make include path 
    515         my $include_paths = join(' ',map {'-I../../'.$_} @all_deps_for_module); 
     517        my $include_paths = ""; 
     518 
     519        foreach my $mod (@all_deps_for_module) 
     520        { 
     521                if ($mod =~ m|^bundled/| and -d "$mod/include") 
     522                { 
     523                        $include_paths .= "-I../../$mod/include "; 
     524                } 
     525                else 
     526                { 
     527                        $include_paths .= "-I../../$mod "; 
     528                } 
     529        } 
    516530 
    517531        # is target a library? 
     
    775789                                $dep_target = "\$(OUTBASE)/$dep/$1.a"; 
    776790                        } 
    777                         elsif ($dep =~ m|^.*/(.*)|) 
     791                        elsif ($dep =~ m|^bundled/(.*)|) 
     792                        { 
     793                                $dep_target = "lib$1.a"; 
     794                        } 
     795                        elsif ($dep =~ m|^bin/(.*)|) 
    778796                        { 
    779797                                $dep_target = "\$(OUTBASE)/$dep/$1$platform_exe_ext"; 
     
    781799                        else 
    782800                        { 
    783                                 $dep_target = "lib$dep.a"; 
     801                                die "Don't know how to add compile-time " . 
     802                                        "dependency on $dep"; 
    784803                        } 
    785804 
     
    802821        foreach my $dep (reverse @all_deps_for_module) 
    803822        { 
    804                 if ($dep =~ m|^lib\/(.+)$|) 
     823                if ($dep =~ m|^lib/(.+)$|) 
    805824                { 
    806825                        push @lib_files, "\$(OUTBASE)/$dep/$1.a"; 
    807826                } 
    808                 elsif ($dep =~ m|^([^/]+)$|) 
     827                elsif ($dep =~ m|^bundled/(.+)$|) 
    809828                { 
    810829                        push @lib_files, "../../$dep/lib$1.a"; 
  • box/trunk/infrastructure/makeparcels.pl.in

    r2680 r2717  
    243243                        push @parcel_deps, "$dir/docs/${name}.html"; 
    244244                } 
    245                 elsif ($type eq 'subdir') 
     245                elsif ($type eq 'configure') 
    246246                { 
    247247                        shift @args; 
     
    255255$name-clean: 
    256256        cd $name; \$(MAKE) clean 
     257 
    257258EOF 
    258259                        push @parcel_deps, "$name-build"; 
  • box/trunk/modules.txt

    r2624 r2717  
    2727 
    2828lib/backupclient        lib/server      lib/crypto      lib/compress 
    29 lib/backupstore         lib/server      lib/raidfile    lib/backupclient 
     29lib/backupstore         lib/server      lib/raidfile    lib/backupclient                bundled/tdb 
    3030 
    3131bin/bbackupobjdump      lib/backupclient lib/backupstore 
    32 bin/bbstored            lib/raidfile    lib/server      lib/backupstore lib/backupclient 
     32bin/bbstored            lib/raidfile    lib/server      lib/backupstore lib/backupclient        bundled/tdb 
    3333bin/bbstoreaccounts     lib/raidfile    lib/backupstore 
    34 bin/bbackupd            lib/server      lib/backupclient        qdbm 
     34bin/bbackupd            lib/server      lib/backupclient        bundled/tdb 
    3535bin/bbackupquery        lib/server      lib/backupclient 
    3636bin/bbackupctl          lib/server      lib/backupclient 
  • box/trunk/parcels.txt

    r2644 r2717  
    1919        html bbackupd.conf 
    2020 
    21         subdir qdbm libqdbm.a 
    2221 
    2322EXCEPT:mingw32,mingw32msvc 
     
    6766        html raidfile.conf 
    6867 
     68        configure bundled/tdb 
     69 
    6970EXCEPT:mingw32,mingw32msvc 
    7071        man bbstored.8 
Note: See TracChangeset for help on using the changeset viewer.