Drizzled Public API Documentation

repository_ms.h

00001 /* Copyright (C) 2008 PrimeBase Technologies GmbH, Germany
00002  *
00003  * PrimeBase Media Stream for MySQL
00004  *
00005  * This program is free software; you can redistribute it and/or modify
00006  * it under the terms of the GNU General Public License as published by
00007  * the Free Software Foundation; either version 2 of the License, or
00008  * (at your option) any later version.
00009  *
00010  * This program is distributed in the hope that it will be useful,
00011  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013  * GNU General Public License for more details.
00014  *
00015  * You should have received a copy of the GNU General Public License
00016  * along with this program; if not, write to the Free Software
00017  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
00018  *
00019  * Original author: Paul McCullagh
00020  * Continued development: Barry Leslie
00021  *
00022  * 2007-06-26
00023  *
00024  * H&G2JCtL
00025  *
00026  * Contains all the information about an open database.
00027  *
00028  */
00029 
00030 #pragma once
00031 #ifndef __REPOSITORY_MS_H__
00032 #define __REPOSITORY_MS_H__
00033 #include <stddef.h>
00034 
00035 #include "cslib/CSDefs.h"
00036 #include "cslib/CSFile.h"
00037 #include "cslib/CSMd5.h"
00038 #include "engine_ms.h"
00039 #include "cloud_ms.h"
00040 #include "pbmslib.h"
00041 
00042 #define MS_BLOB_HEADER_MAGIC    0x9213BA24
00043 #define MS_REPO_FILE_MAGIC      0x5678CDEF
00044 #define MS_REPO_FILE_VERSION    3
00045 #define MS_REPO_FILE_HEAD_SIZE    128
00046 
00047 #ifdef DEBUG
00048 #define MS_REPO_MIN_REF_COUNT   3       // Initial number of references to allow space for:(Table, Delete, Cloud)
00049 #define MS_REPO_MIN_MATADATA    0     
00050 #else
00051 #define MS_REPO_MIN_REF_COUNT   6       // Initial number of references to allow space for.
00052 #define MS_REPO_MIN_MATADATA    128       
00053 #endif
00054 
00055 #define BLOB_IN_REPOSITORY(t) ( t < MS_CLOUD_STORAGE)
00056 #define BLOB_IN_CLOUD(t) ( t == MS_CLOUD_STORAGE)
00057 
00058 // References are marked as committed or uncommitted as an aid when
00059 // doing a backup to indicate which references were added after the
00060 // backup began.
00061 #define COMMIT_MASK(id)   ((id) & 0X7FFFFFFFFFFFFFFFll) // The high bit is used internally to flag uncommitted references.
00062 #define IS_COMMITTED(id)  (((id) & 0X8000000000000000ll) == 0)
00063 #define UNCOMMITTED(id)   ((id) | 0X8000000000000000ll)
00064 
00065 class MSOpenTable;
00066 class MSDatabase;
00067 class MSRepository;
00068 class CSHTTPOutputStream;
00069 
00070 /* Repository file structure:
00071   MSRepoHeadRec:<BLOB_RECORDS>
00072   
00073   BLOB_RECORDS: <BLOB_RECORD> <BLOB_RECORDS>
00074   BLOB_RECORD: MSBlobHeadRec <BLOB_REFERENCES> BlobData
00075   BLOB_REFERENCES:<
00076 
00077 */
00078 
00079 /*
00080  * In theory a database can containg repository records created with different versions of PBMS
00081  * which have different repository header sizes. The reallity though is that this is not really 
00082  * supported yet. If this is ever supported the header data will have to be processed
00083  * after being read from disk before it can be accessed. This will be left until it is actually needed.
00084  */
00085 typedef struct MSRepoHead {
00086   CSDiskValue4      rh_magic_4;             /* Table magic number. */
00087   CSDiskValue2      rh_version_2;           /* The header version. */
00088   CSDiskValue2      rh_repo_head_size_2;        /* The size of this header. */
00089   CSDiskValue2      rh_blob_head_size_2;        /* The size of this header for each blob sizeof(MSBlobHeadRec). */
00090   CSDiskValue2      rh_def_ref_size_2;          /* The default size of references. */
00091   CSDiskValue8      rh_garbage_count_8;
00092 
00093   /* NOTE: Keep the next 5 fields together (and in this order)
00094   * they are written together in syncHead().
00095    */
00096   CSDiskValue8      rh_recovery_offset_8;       /* The last confirmed, flushed offset (start recovery point)! */
00097   CSDiskValue4      rh_last_temp_time_4;        /* Time of the last temp BLOB in this log. */
00098   CSDiskValue4      rh_last_access_4;         /* Last access time (in seconds). */
00099   CSDiskValue4      rh_create_time_4;         /* Last access time (in seconds). */
00100   CSDiskValue4      rh_last_ref_4;            /* Last reference time (in seconds). */
00101 
00102   CSDiskValue4      rh_reserved_4;
00103 } MSRepoHeadRec, *MSRepoHeadPtr;
00104 
00105 #define MS_BLOB_ALLOCATED     1 /* The BLOB exists but is scheduled for deletion. */
00106 #define MS_BLOB_REFERENCED      2 /* The BLOB exists and is referenced. */
00107 #define MS_BLOB_DELETED       3 /* The BLOB has been deleted and can be cleaned up.. */
00108 #define MS_BLOB_MOVED       4 /* The BLOB was moved while a backup was in progress and can be cleaned up when the compactor is resumed. */
00109 // The only difference between MS_BLOB_DELETED and MS_BLOB_MOVED is that the backup process will backup BLOBs that were moved.
00110 
00111 #define VALID_BLOB_STATUS(s) (s >= MS_BLOB_ALLOCATED && s <= MS_BLOB_MOVED)
00112 #define IN_USE_BLOB_STATUS(s) (s >= MS_BLOB_ALLOCATED && s <= MS_BLOB_REFERENCED)
00113 
00114 #define MS_SHORT_AUTH_CODE(ac)    ((uint16_t) (((ac) & 0x0000FFFF) ^ (ac) >> 16))
00115 /*
00116  * BLOB record structure: {
00117    {Blob Header}    (See MSBlobHead below.)
00118    {Blob references}  (An array of rb_ref_count_2 reference records each of size rb_ref_size_1)
00119    {Blob Metadata}  (Null terminated string pairs of the format: <name> <value>)
00120    {The BLOB!}    (Depending on the type of BLOB storage being used this may be the actual blob data or a URL to it.)
00121  }
00122  */
00123 /*
00124  * The blob alias is a special metadata tag that can be used as a key to access the blob.
00125  * For this reason it is handled differently in that an index is defined on it.
00126  */
00127 typedef struct MSBlobHead {
00128   /* 
00129    * Important: rb_last_access_4 and rb_access_count_4 are always updated at the same time 
00130    * and are assumed to be in this order.
00131    */
00132   CSDiskValue4      rb_last_access_4;         /* Last access time (in seconds). */
00133   CSDiskValue4      rb_access_count_4;          /* The number of times the BLOB has been read. */
00134   CSDiskValue4      rb_create_time_4;         /* Creation time (in seconds). */
00135   CSDiskValue4      rd_magic_4;             /* BLOB magic number. */
00136   CSDiskValue1      rb_storage_type_1;          /* The type of BLOB storage being used. */
00137 
00138   CSDiskValue2      rb_ref_count_2;           /* The number of reference slots in the header. They may not all be used. */
00139   CSDiskValue1      rb_ref_size_1;            /* The size of references in this header. */
00140   CSDiskValue4      rb_mod_time_4;            /* Last access modification time (in seconds). */
00141   
00142   /* The header size may be oversize to allow for the addition of references and metadata before    */
00143   /* having to relocate the blob. The references array starts at the top of the variable header space */
00144   /* and grows down while the metadata starts at the bottom and grows up. If the 2 spaces meet then */
00145   /* a new BLOB record must be allocated and the entire BLOB relocated. :(              */
00146   
00147   CSDiskValue2      rb_head_size_2;           /* The size of the entire header. (The offset from the start of the header to the BLOB data.)*/
00148   CSDiskValue6      rb_blob_repo_size_6;        /* The size of the blob data sotred in the repository. For repository BLOBs this is the same as rb_blob_data_size_6 */
00149   CSDiskValue6      rb_blob_data_size_6;        /* The size of the actual blob. */
00150   Md5Digest       rb_blob_checksum_md5d;        /* The MD5 digest of the blob. */
00151 
00152   CSDiskValue4      rb_alias_hash_4;          /* The alias name hash value.*/
00153   CSDiskValue2      rb_alias_offset_2;          /* The offset from the start of the header to the BLOB metadata alias value if it exists.*/
00154   CSDiskValue2      rb_mdata_offset_2;          /* The offset from the start of the header to the BLOB metadata.*/
00155   CSDiskValue2      rb_mdata_size_2;          /* The size of the  metadata.*/
00156 
00157   /* 
00158    * The rb_s3_key_id_4 field is used to generate a database wide
00159    * unique persistent id for the BLOB that can be used as 
00160    * an S3 key.
00161    *
00162    * This is done by combining the  rb_s3_key_id_4 with the rb_create_time_4.
00163    * 
00164    */
00165   CSDiskValue4      rb_s3_key_id_4; 
00166 
00167   /* 
00168    * The rb_s3_cloud_ref_4 field is a reference into the pbms.pbms_cloud 
00169    * table containing S3 storage information. 
00170    */
00171   CSDiskValue4      rb_s3_cloud_ref_4;  
00172 
00173   /* Reserved space to allow for new header fields without 
00174    * having to change the size of this header.
00175    */
00176    CSDiskValue4     rb_unused[2];
00177   
00178   /* These are changed when referencing/dereferencing a BLOB: */
00179   CSDiskValue1      rb_status_1;
00180   CSDiskValue4      rb_backup_id_4;           /* Used with the MS_BLOB_MOVED flag to indicate that a moved BLOB should be backed up. */
00181   CSDiskValue4      rb_last_ref_4;            /* Last reference time (in seconds). */
00182   CSDiskValue4      rb_auth_code_4;           /* Authorisation code. NOTE! Always last 4 bytes of the
00183                                  * header of the header! */
00184   
00185 } MSBlobHeadRec, *MSBlobHeadPtr;
00186 #define MS_METADAT_OFFSET(header_size, current_metadata_size, metadata_size)    (header_size - current_metadata_size - metadata_size)
00187 #define MS_MIN_BLOB_HEAD_SIZE   ((uint16_t)(offsetof(MSBlobHeadRec, rb_auth_code_4) + 4))
00188 
00189 #define MS_VAR_SPACE(bh)      ((int32_t)((CS_GET_DISK_2(bh->rb_head_size_2) - MS_MIN_BLOB_HEAD_SIZE) -(CS_GET_DISK_2(bh->rb_ref_count_2) * CS_GET_DISK_1(bh->rb_ref_size_1)) - CS_GET_DISK_2(bh->rb_mdata_size_2)))
00190 #define MS_CAN_ADD_REFS(bh, n)    (MS_VAR_SPACE(bh) >= (int32_t)(n * CS_GET_DISK_1(bh->rb_ref_size_1)))
00191 #define MS_CAN_ADD_MDATA(bh, l)   (MS_VAR_SPACE(bh) >= (int32_t)l)
00192 
00193 
00194 #define MS_BLOB_STAT_OFFS     offsetof(MSBlobHeadRec, rb_status_1)
00195 #define MS_BLOB_META_OFFS     offsetof(MSBlobHeadRec, rb_alias_offset_2)
00196 
00197 #define MS_BLOB_FREE_REF      0x0000            /* A free reference */
00198 #define MS_BLOB_TABLE_REF     0xFFFF            /* A table reference */
00199 #define MS_BLOB_DELETE_REF      0xFFFE            /* A templog deletion reference */
00200 
00201 #define INVALID_INDEX       0xFFFF
00202 
00203 // This is a generic reference structure that is
00204 // compatable with MSRepoTableRef, MSRepoTempRef, and MSRepoBlobRef
00205 typedef struct MSRepoGenericRef {
00206   CSDiskValue2      rr_type_2;
00207   CSDiskValue2      rr_reserved_2;
00208   uint8_t         er_unused[8];
00209 } MSRepoGenericRefRec, *MSRepoGenericRefPtr;
00210 
00211 // Notes on references stored in the BLOB's repository header:
00212 //
00213 // For every table that has a reference to the BLOB there is
00214 // 1 table ref (MSRepoTableRefRec) in the BLOB's header.
00215 // For every reference to the BLOB from within the database tables
00216 // there is 1 BLOB ref (MSRepoBlobRefRec) in the BLOB's header.
00217 // The BLOB ref points to the BLOB's table ref in the header.
00218 //
00219 // If the same BLOB is referenced more than once from the same table 
00220 // there will only be one MSRepoTableRefRec for all the references but
00221 // each reference will have its own MSRepoBlobRefRec.
00222 //
00223 //
00224 // In addition there may be 1 or more temp log references used for
00225 // performing delayed offline actions on the BLOB such as deleting
00226 // it or moving it to a cloud.
00227 //
00228 // (BLOB aliases should be implimented as another type of reference.)
00229 
00230 /* Points to a reference to the blob from a table. */
00231 typedef struct MSRepoTableRef {
00232   CSDiskValue2      rr_type_2;              /* MS_BLOB_TABLE_REF */
00233   CSDiskValue4      tr_table_id_4;            /* Table ID (non-zero if valid). */
00234   CSDiskValue6      tr_blob_id_6;           /* Blob ID (non-zero if valid). (offset into the table refernce log.)*/
00235 } MSRepoTableRefRec, *MSRepoTableRefPtr;
00236 
00237 /* Points to a reference to the blob from a temp log. */
00238 typedef struct MSRepoTempRef {
00239   CSDiskValue2      rr_type_2;              /* MS_BLOB_DELETE_REF */
00240   CSDiskValue2      tp_del_ref_2;           /* The index of reference to be removed. Index is 1 based.
00241                                  * If set to INVALID_INDEX then this record is not related to a table reference. */ 
00242   CSDiskValue4      tp_log_id_4;            /* Temp log id. */
00243   CSDiskValue4      tp_offset_4;            /* Offset if temp log. */
00244 } MSRepoTempRefRec, *MSRepoTempRefPtr;
00245 
00246 // Barry:
00247 // A blob reference is a backward reference from the BLOB
00248 // back up into the table referencing it.
00249 // 
00250 // Historicly it could have beeen used to access 
00251 // the referencing row via an engine callback. This is no longer supported.
00252 // It is now used to store a unique ID for the BLOB reference. This is used
00253 // to avoid possible multiple BLOB decrement or increment operations during
00254 // recovery. They could also be used to locate the record referencing to the BLOB 
00255 // in the table. 
00256 // 
00257 // There is a 1:1 relationship between the number of blob references in
00258 // a BLOB's header and the number of times that BLOB exists in  tables in the
00259 // database.
00260 typedef struct MSRepoBlobRef {
00261   CSDiskValue2      er_table_2;     /* Index of the table reference (a MS_BLOB_TABLE_REF record) Index is 1 based. Can be -1 */
00262   CSDiskValue2      er_col_index_2;   /* The column index of the BLOB. */
00263   CSDiskValue8      er_blob_ref_id_8; /* The unique ID of the BLOB reference.*/
00264 } MSRepoBlobRefRec, *MSRepoBlobRefPtr;
00265 
00266 typedef union MSRepoPointers {
00267   char          *rp_chars;
00268   uint8_t         *rp_bytes;
00269   MSBlobHeadPtr     rp_head;
00270   MSRepoGenericRefPtr   rp_ref;               
00271   MSRepoTableRefPtr   rp_tab_ref;
00272   MSRepoTempRefPtr    rp_temp_ref;
00273   MSRepoBlobRefPtr    rp_blob_ref;
00274 } MSRepoPointersRec, *MSRepoPointersPtr;
00275 
00276 #define MS_BLOB_KEY_SIZE  17
00277 
00278 class MSRepoFile : public CSFile, public CSPooled {
00279 public:
00280   MSRepository  *myRepo;
00281   bool      isFileInUse;
00282   MSRepoFile    *nextFile;                  /* Next file available in the pool */
00283 
00284   MSRepoFile();
00285   virtual ~MSRepoFile();
00286 
00287   uint64_t readBlobChunk(PBMSBlobIDPtr blob_id, uint64_t rep_offset, uint64_t blob_offset, uint64_t buffer_size, char *buffer);
00288   void writeBlobChunk(PBMSBlobIDPtr blob_id, uint64_t rep_offset, uint64_t blob_offset, uint64_t data_size, char *data);
00289   //void sendBlob(MSOpenTable *otab, uint64_t offset, uint16_t head_size, uint64_t size, CSHTTPOutputStream *stream);
00290   void sendBlob(MSOpenTable *otab, uint64_t offset, uint64_t req_offset, uint64_t req_size, uint32_t auth_code, bool with_auth_code, bool info_only, CSHTTPOutputStream *stream);
00291   void referenceBlob(MSOpenTable *otab, uint64_t offset, uint16_t head_size, uint32_t tab_id, uint64_t blob_id, uint64_t blob_ref_id, uint32_t auth_code, uint16_t col_index);
00292   void setBlobMetaData(MSOpenTable *otab, uint64_t offset, const char *meta_data, uint16_t meta_data_len, bool reset_alias, const char  *alias);
00293   void releaseBlob(MSOpenTable *otab, uint64_t offset, uint16_t head_size, uint32_t tab_id, uint64_t blob_id, uint64_t blob_ref_id, uint32_t auth_code);
00294   void commitBlob(MSOpenTable *otab, uint64_t offset, uint16_t head_size, uint32_t tab_id, uint64_t blob_id, uint64_t blob_ref_id, uint32_t auth_code);
00295 private:
00296   bool getBlobRefSpace(MSOpenTable *otab, uint64_t offset, uint16_t head_size, uint32_t tab_id, uint64_t blob_id, uint64_t blob_ref_id, 
00297             uint32_t auth_code, MSRepoTableRefPtr *tab_ref, MSRepoGenericRefPtr *free_ref, uint16_t *tab_ref_cnt, uint64_t  *blob_size);
00298   void realFreeBlob(MSOpenTable *otab, char *buffer, uint32_t auth_code, uint64_t offset, uint16_t head_size, uint64_t blob_size, size_t ref_size);
00299 public:
00300   void freeTableReference(MSOpenTable *otab, uint64_t offset, uint16_t head_size, uint32_t tab_id, uint64_t blob_id, uint32_t auth_code);
00301   void checkBlob(CSStringBuffer *buffer, uint64_t offset, uint32_t auth_code, uint32_t temp_log_id, uint32_t temp_log_offset);
00302 
00303   void updateAccess(MSBlobHeadPtr blob, uint64_t rep_offset); 
00304   virtual void returnToPool();
00305 
00306   virtual CSObject *getNextLink() { return iNextLink; }
00307   virtual CSObject *getPrevLink() { return iPrevLink; }
00308   virtual void setNextLink(CSObject *link) { iNextLink = link; }
00309   virtual void setPrevLink(CSObject *link) { iPrevLink = link; }
00310 
00311   friend class MSRepository;
00312 
00313 private:
00314   
00315   CSObject    *iNextLink;
00316   CSObject    *iPrevLink;
00317 
00318   void update_blob_header(MSOpenTable *otab, uint64_t offset, uint64_t blob_size, uint16_t head_size, uint16_t new_head_size);
00319   void removeBlob(MSOpenTable *otab, uint32_t tab_id, uint64_t blob_id, uint64_t offset, uint32_t auth_code);
00320   static MSRepoFile *newRepoFile(MSRepository *repo, CSPath *path);
00321   
00322   void updateGarbage(uint64_t size);
00323   
00324 public:
00325   static void getBlobKey(MSBlobHeadPtr blob, CloudKeyPtr key)
00326   {
00327     key->creation_time = CS_GET_DISK_4(blob->rb_create_time_4);
00328     key->ref_index = CS_GET_DISK_4(blob->rb_s3_key_id_4);
00329     key->cloud_ref = CS_GET_DISK_4(blob->rb_s3_cloud_ref_4);
00330   }
00331 
00332 };
00333 
00334 #define CS_REPO_REC_LOCK_COUNT      31
00335 
00336 typedef enum RepoLockStates { // These states are actually bit masks
00337   REPO_UNLOCKED = 0,    // Repository is not locked by anyone.
00338   REPO_COMPACTING = 1,  // Repository is locked by the compactor thread.
00339   REPO_WRITE = 2,     // Repository is locked for writing a new BLOB to it.
00340   REPO_BACKUP = 4     // Repository is locked for backup.
00341   } RepoLockState;
00342 
00343 // The REPO_COMPACTING and REPO_WRITE states are mutualy exclusive but REPO_BACKUP is not.
00344 
00345 
00346 // It is possible that when a repository is scheduled for backup it is already locked by the compactor thread
00347 // or it is locked because a new BLOB is being written to it. In the cases where it is locked by the compactor,
00348 // the compactore is suspended until the repository is backed up. In the case where a BLOB is being written
00349 // to it both threads are allowed access to it and the resetting of the lock state is handled in returnToPool().
00350 // It is safe to allow the backup thread to access the repository at the same time as other threads because
00351 // backup is a read only operation.  
00352 class MSRepository : public CSSharedRefObject, public CSPooled {
00353 public:
00354   uint32_t      myRepoID;
00355   off64_t     myRepoFileSize;
00356   uint32_t      myRepoLockState;  // Bit mask of RepoLockStates           
00357   bool      isRemovingFP;               /* Set to true if the file pool is being removed. */
00358   CSMutex     myRepoLock[CS_REPO_REC_LOCK_COUNT];
00359   CSMutex     myRepoWriteLock;    // Writing requires it's own lock. 
00360   MSDatabase    *myRepoDatabase;
00361   off64_t     myGarbageCount;
00362   size_t      myRepoHeadSize;
00363   int       myRepoDefRefSize;
00364   size_t      myRepoBlobHeadSize;
00365   
00366   off64_t     myRecoveryOffset;             /* The starting point for the next recovery. */
00367   time_t      myLastTempTime;
00368   time_t      myLastAccessTime;
00369   time_t      myLastCreateTime;
00370   time_t      myLastRefTime;
00371   
00372   bool      mustBeDeleted;                /* Set to true if the repository should be deleted when freed. */
00373 
00374   MSRepository(uint32_t id, MSDatabase *db, off64_t file_size);
00375   ~MSRepository();
00376 
00377   /* TODO: Check recovery after crash after each phase below. */
00378   void openRepoFileForWriting(MSOpenTable *otab);
00379   uint64_t receiveBlob(MSOpenTable *otab, uint16_t head_size, uint64_t blob_size, Md5Digest *checksum = NULL, CSInputStream *stream = NULL);
00380   uint64_t copyBlob(MSOpenTable *otab, uint64_t size, CSInputStream *stream); // Makes a copy of the complete BLOB with header.
00381   void writeBlobHead(MSOpenTable *otab, uint64_t offset, uint8_t ref_size, uint16_t head_size, uint64_t size, Md5Digest *checksum, char *metadata, uint16_t metadata_size, uint64_t blob_id, uint32_t auth_code, uint32_t log_id, uint32_t log_offset, uint8_t blob_type, CloudKeyPtr cloud_key);
00382   //void writeBlobHead(MSOpenTable *otab, uint64_t offset, uint32_t access_time, uint32_t create_time, uint8_t ref_size, uint16_t head_size, uint64_t blob_size, Md5Digest *checksum, uint16_t metadata_size, uint64_t blob_id, uint32_t auth_code, uint16_t col_index, PBMSEngineRefPtr eng_ref);
00383   void setRepoFileSize(MSOpenTable *otab, off64_t offset);
00384   void syncHead(MSRepoFile *fh);
00385   MSRepoFile *openRepoFile();
00386 
00387   virtual void returnToPool();
00388 
00389   MSRepoFile *getRepoFile();
00390   void addRepoFile(MSRepoFile *file);
00391   void removeRepoFile(MSRepoFile *file);
00392   void returnRepoFile(MSRepoFile *file);
00393 
00394   bool removeRepoFilesNotInUse();               /* Return true if all files have been removed. */
00395   
00396   uint16_t getDefaultHeaderSize(uint16_t metadata_size) { return myRepoBlobHeadSize + ((metadata_size)?metadata_size:MS_REPO_MIN_MATADATA)  + myRepoDefRefSize * MS_REPO_MIN_REF_COUNT;}
00397   off64_t getRepoFileSize();
00398   size_t getRepoHeadSize();
00399   size_t getRepoBlobHeadSize();
00400   CSMutex *getRepoLock(off64_t offset);
00401   uint32_t getRepoID();
00402   uint32_t getGarbageLevel();
00403 
00404   uint32_t initBackup();
00405   bool lockedForBackup();
00406   void backupCompleted();
00407   bool isRepoLocked() { return myRepoXLock;}
00408   void lockRepo(RepoLockState state);
00409   void unlockRepo(RepoLockState state);
00410   
00411   friend class MSRepoFile;
00412 
00413 private:
00414   bool      myRepoXLock;
00415   /* The read file pool: */
00416   MSRepoFile    *iFilePool;                 /* A list of files currently not in use. THIS LIST DOESN'T COUNT AS A REFERENCE! YUK!!*/
00417   CSLinkedList  iPoolFiles;                 /* A list of all files in this pool */
00418 
00419   CSPath *getRepoFilePath();
00420   void signalCompactor();
00421 
00422 };
00423 
00424 #endif