XFLAIM changes. Minor changes needed due to FTK updates.

git-svn-id: https://svn.code.sf.net/p/flaim/code/trunk@734 0109f412-320b-0410-ab79-c3e0c5ffbbe6
This commit is contained in:
ahodgkinson
2006-08-03 19:25:44 +00:00
parent 19c68c08bc
commit 2c4c834092
7 changed files with 79 additions and 84 deletions

View File

@@ -213,7 +213,7 @@ RCODE F_DbSystem::copyDb(
goto Exit;
}
if( RC_BAD( rc = pSrcSFileClient->setup( pszSrcDbName, pszSrcDataDir)))
if( RC_BAD( rc = pSrcSFileClient->setup( pszSrcDbName, pszSrcDataDir, 0)))
{
goto Exit;
}
@@ -346,7 +346,7 @@ retry:
goto Exit;
}
if( RC_BAD( rc = pDestSFileClient->setup( pszDestDbName, pszDestDataDir)))
if( RC_BAD( rc = pDestSFileClient->setup( pszDestDbName, pszDestDataDir, 0)))
{
goto Exit;
}

View File

@@ -8460,7 +8460,8 @@ public:
RCODE setup(
const char * pszCFileName,
const char * pszDataDir);
const char * pszDataDir,
FLMUINT uiMaxFileSize);
FLMUINT FLMAPI getFileNumber(
FLMUINT uiBlockAddr);
@@ -8476,6 +8477,8 @@ public:
FLMUINT uiFileNumber,
char * pszPath);
FLMUINT64 FLMAPI getMaxFileSize( void);
static void bldSuperFileExtension(
FLMUINT uiFileNum,
char * pszFileExtension);
@@ -8486,6 +8489,7 @@ private:
char * m_pszDataFileBaseName;
FLMUINT m_uiExtOffset;
FLMUINT m_uiDataExtOffset;
FLMUINT m_uiMaxFileSize;
};
#endif // FLAIMSYS_H

View File

@@ -1086,7 +1086,7 @@ RCODE F_DbSystem::dbRestore(
goto Exit;
}
if( RC_BAD( rc = SFileClient.setup( pszDbPath, pszDataDir)))
if( RC_BAD( rc = SFileClient.setup( pszDbPath, pszDataDir, 0)))
{
goto Exit;
}
@@ -1559,19 +1559,9 @@ FSTATIC RCODE flmRestoreFile(
rc = RC_SET_AND_ASSERT( NE_XFLM_INCONSISTENT_BACKUP);
goto Exit;
}
uiMaxFileSize = (FLMUINT)pDbHdr->ui32MaxFileSize;
// Set the database version number and block size into the
// super file handle. We only do this if the file being restored
// is the full backup. It will always be first in the restore sequence,
// and thus we only need to set these values into the super file handle
// at that time.
if( !bIncremental)
{
pSFile->setBlockSize( uiBlockSize);
}
// Make sure the maximum block file size matches what was read from the
// backup header.

View File

@@ -480,7 +480,7 @@ Retry:
goto Exit;
}
if( RC_BAD( rc = SFileClient.setup( pszSourceDbPath, pszSourceDataDir)))
if( RC_BAD( rc = SFileClient.setup( pszSourceDbPath, pszSourceDataDir, 0)))
{
goto Exit;
}
@@ -633,8 +633,6 @@ Retry:
pCreateOpts->uiBlockSize = m_dbHdr.ui16BlockSize;
}
m_pSFileHdl->setBlockSize( m_dbHdr.ui16BlockSize);
// Create the destination database
if( RC_BAD( rc = gv_pXFlmDbSystem->dbCreate( pszDestDbPath, pszDestDataDir,

View File

@@ -131,13 +131,17 @@ RCODE FLMAPI F_DbSystem::dbCreate(
{
goto Exit;
}
bNewDatabase = TRUE;
pDatabase->m_uiMaxFileSize = gv_XFlmSysData.uiMaxFileSize;
// Link the F_Db object to the F_Database object.
rc = pDb->linkToDatabase( pDatabase);
f_mutexUnlock( gv_XFlmSysData.hShareMutex);
bMutexLocked = FALSE;
if (RC_BAD( rc))
{
goto Exit;
@@ -145,18 +149,6 @@ RCODE FLMAPI F_DbSystem::dbCreate(
// If the database has not already been created, do so now.
// Determine what to set file block size to.
if (pCreateOpts != NULL)
{
pDb->m_pSFileHdl->setBlockSize(
flmAdjustBlkSize( pCreateOpts->uiBlockSize));
}
else
{
pDb->m_pSFileHdl->setBlockSize( XFLM_DEFAULT_BLKSIZ);
}
if (RC_OK( gv_XFlmSysData.pFileSystem->doesFileExist( pszFilePath)))
{
rc = RC_SET( NE_XFLM_FILE_EXISTS);
@@ -167,6 +159,7 @@ RCODE FLMAPI F_DbSystem::dbCreate(
pDb->m_pSFileHdl->setMaxAutoExtendSize( gv_XFlmSysData.uiMaxFileSize);
pDb->m_pSFileHdl->setExtendSize( pDb->m_pDatabase->m_uiFileExtendSize);
if (RC_BAD( rc = pDb->m_pSFileHdl->createFile( 0)))
{
goto Exit;

View File

@@ -290,11 +290,11 @@ RCODE F_DbSystem::openDatabase(
IF_FileHdl * pLockFileHdl,
IF_Db ** ppDb)
{
RCODE rc = NE_XFLM_OK;
FLMBOOL bNewDatabase = FALSE;
FLMBOOL bMutexLocked = FALSE;
F_Db * pDb = NULL;
FLMBOOL bNeedToOpen = FALSE;
RCODE rc = NE_XFLM_OK;
FLMBOOL bNewDatabase = FALSE;
FLMBOOL bMutexLocked = FALSE;
F_Db * pDb = NULL;
FLMBOOL bNeedToOpen = FALSE;
// Allocate and initialize an F_Db object.
@@ -723,8 +723,6 @@ RCODE F_Database::physOpen(
}
}
pDb->m_pSFileHdl->setBlockSize( m_uiBlockSize);
// We must have exclusive access. Create a lock file for that
// purpose, if there is not already a lock file.
@@ -1526,6 +1524,7 @@ RCODE F_Database::readDbHdr(
{
f_free( &m_pszDbPasswd);
}
if ( RC_BAD( rc = f_alloc(
(f_strlen( (const char *)pszPassword) + 1), &m_pszDbPasswd)))
{
@@ -1546,15 +1545,17 @@ RCODE F_Database::readDbHdr(
// If the key was encrypted in a password, then the pszPassword parameter better
// be the key used to encrypt it. If the key was not encrypted in a password,
// then pszPassword parameter should be NULL.
rc = m_pWrappingKey->setKeyFromStore(
m_lastCommittedDbHdr.DbKey,
pszPassword, NULL);
}
if (RC_BAD( rc))
if( RC_BAD( rc))
{
// NE_XFLM_UNSUPPORTED_FEATURE is returned when we've been compiled
// without NICI support
if ((rc == NE_XFLM_UNSUPPORTED_FEATURE) || bAllowLimited)
{
m_bInLimitedMode = TRUE;
@@ -1565,6 +1566,7 @@ RCODE F_Database::readDbHdr(
goto Exit;
}
}
// Note that we might still end up in limited mode if we can't verify all the keys
// that are stored in the dictionary.
@@ -1650,7 +1652,8 @@ RCODE F_Database::startCPThread( void)
goto Exit;
}
if( RC_BAD( rc = pSFileClient->setup( m_pszDbPath, m_pszDataDir)))
if( RC_BAD( rc = pSFileClient->setup( m_pszDbPath, m_pszDataDir,
m_uiMaxFileSize)))
{
goto Exit;
}
@@ -1664,11 +1667,6 @@ RCODE F_Database::startCPThread( void)
goto Exit;
}
if (m_lastCommittedDbHdr.ui32DbVersion)
{
pCPInfo->pSFileHdl->setBlockSize( m_uiBlockSize);
}
f_memset( &pCPInfo->Stats, 0, sizeof( XFLM_STATS));
pCPInfo->bStatsInitialized = TRUE;

View File

@@ -47,6 +47,9 @@
#define FLM_MAX_CACHE_SIZE (~((FLMUINT)0))
#endif
#define DEFAULT_OPEN_THRESHOLD 100 // 100 file handles to cache
#define DEFAULT_MAX_AVAIL_TIME 900 // 15 minutes
static FLMATOMIC gv_flmSysSpinLock = 0;
static FLMBOOL gv_bFlmStarted = FALSE;
static FLMBOOL gv_bToolkitStarted = FALSE;
@@ -643,6 +646,7 @@ RCODE F_Db::linkToDatabase(
F_Database * pDatabase)
{
RCODE rc = NE_XFLM_OK;
IF_FileHdl * pTmpFileHdl = NULL;
F_SuperFileClient * pSFileClient = NULL;
// If the use count on the file used to be zero, unlink it from the
@@ -678,9 +682,32 @@ RCODE F_Db::linkToDatabase(
rc = RC_SET( NE_XFLM_MEM);
goto Exit;
}
if( !pDatabase->m_uiMaxFileSize)
{
XFLM_DB_HDR tmpDbHdr;
if( RC_BAD( rc = gv_XFlmSysData.pFileSystem->openFile(
pDatabase->m_pszDbPath, gv_XFlmSysData.uiFileOpenFlags,
&pTmpFileHdl)))
{
goto Exit;
}
if( RC_BAD( rc = flmReadAndVerifyHdrInfo( NULL,
pTmpFileHdl, &tmpDbHdr)))
{
goto Exit;
}
pDatabase->m_uiMaxFileSize = tmpDbHdr.ui32MaxFileSize;
pTmpFileHdl->Release();
pTmpFileHdl = NULL;
}
if( RC_BAD( rc = pSFileClient->setup(
pDatabase->m_pszDbPath, pDatabase->m_pszDataDir)))
pDatabase->m_pszDbPath, pDatabase->m_pszDataDir,
pDatabase->m_uiMaxFileSize)))
{
goto Exit;
}
@@ -691,11 +718,6 @@ RCODE F_Db::linkToDatabase(
{
goto Exit;
}
if( pDatabase->m_lastCommittedDbHdr.ui32DbVersion)
{
m_pSFileHdl->setBlockSize( pDatabase->m_uiBlockSize);
}
}
Exit:
@@ -705,6 +727,11 @@ Exit:
pSFileClient->Release();
}
if( pTmpFileHdl)
{
pTmpFileHdl->Release();
}
return( rc);
}
@@ -1230,9 +1257,9 @@ RCODE F_DbSystem::init( void)
}
// Set up a file handle cache
// VISIT
if( RC_BAD( rc = gv_XFlmSysData.pFileSystem->allocFileHandleCache( 32, 120,
if( RC_BAD( rc = gv_XFlmSysData.pFileSystem->allocFileHandleCache(
DEFAULT_OPEN_THRESHOLD, DEFAULT_MAX_AVAIL_TIME,
&gv_XFlmSysData.pFileHdlCache)))
{
goto Exit;
@@ -1925,40 +1952,12 @@ Desc: Close all files in the file handle cache that have not been
RCODE FLMAPI F_DbSystem::closeUnusedFiles(
FLMUINT uiSeconds)
{
RCODE rc = NE_XFLM_OK;
FLMUINT uiValue;
FLMUINT uiCurrTime;
FLMUINT uiSave;
// Convert seconds to timer units
uiValue = FLM_SECS_TO_TIMER_UNITS( uiSeconds);
// Free any other unused structures that have not been used for the
// specified amount of time.
uiCurrTime = (FLMUINT)FLM_GET_TIMER();
f_mutexLock( gv_XFlmSysData.hShareMutex);
// Temporarily set the maximum unused seconds in the FLMSYSDATA structure
// to the value that was passed in to Value1. Restore it after
// calling checkNotUsedObject.
uiSave = gv_XFlmSysData.uiMaxUnusedTime;
gv_XFlmSysData.uiMaxUnusedTime = uiValue;
// May unlock and re-lock the global mutex.
gv_XFlmSysData.uiMaxUnusedTime = uiSave;
f_mutexUnlock( gv_XFlmSysData.hShareMutex);
if( gv_XFlmSysData.pFileHdlCache)
{
// VISIT: check timeout value
gv_XFlmSysData.pFileHdlCache->closeUnusedFiles();
gv_XFlmSysData.pFileHdlCache->closeUnusedFiles( uiSeconds);
}
return( rc);
return( NE_XFLM_OK);
}
/****************************************************************************
@@ -3443,6 +3442,7 @@ F_SuperFileClient::F_SuperFileClient()
m_pszDataFileBaseName = NULL;
m_uiExtOffset = 0;
m_uiDataExtOffset = 0;
m_uiMaxFileSize = 0;
}
/****************************************************************************
@@ -3461,7 +3461,8 @@ Desc:
****************************************************************************/
RCODE F_SuperFileClient::setup(
const char * pszCFileName,
const char * pszDataDir)
const char * pszDataDir,
FLMUINT uiMaxFileSize)
{
RCODE rc = NE_XFLM_OK;
FLMUINT uiNameLen;
@@ -3515,6 +3516,8 @@ RCODE F_SuperFileClient::setup(
m_pszCFileName, &m_uiDataExtOffset);
m_uiExtOffset = m_uiDataExtOffset;
}
m_uiMaxFileSize = uiMaxFileSize;
Exit:
@@ -3549,6 +3552,15 @@ FLMUINT FLMAPI F_SuperFileClient::getBlockAddress(
return( FSBlkAddress( uiFileNumber, uiFileOffset));
}
/****************************************************************************
Desc:
****************************************************************************/
FLMUINT64 FLMAPI F_SuperFileClient::getMaxFileSize( void)
{
f_assert( m_uiMaxFileSize);
return( m_uiMaxFileSize);
}
/****************************************************************************
Desc:
****************************************************************************/