diff --git a/flaim/Makefile b/flaim/Makefile index e58a437..e8176a9 100644 --- a/flaim/Makefile +++ b/flaim/Makefile @@ -833,7 +833,7 @@ ifdef win_target # Libraries that our various components need to link against - lib_link_libs = imagehlp.lib user32.lib rpcrt4.lib wsock32.lib + lib_link_libs = imagehlp.lib user32.lib rpcrt4.lib wsock32.lib advapi32.lib exe_link_libs = $(lib_link_libs) # Convert the list of defines into a proper set of command-line params @@ -1582,7 +1582,7 @@ endif # -- checkdb -- .PHONY : checkdb -checkdb: status clean dircheck libs $(checkdb_exe) +checkdb: status clean dircheck $(flaim_static_lib) $(checkdb_exe) $(checkdb_exe): $(checkdb_obj) $(flaim_static_lib) $(ec)$(gprintf) "Linking $@ ...\n" $(call flm_exe_link_cmd,$(util_dir),checkdb,$(checkdb_obj)) @@ -1590,7 +1590,7 @@ $(checkdb_exe): $(checkdb_obj) $(flaim_static_lib) # -- gigatest -- .PHONY : gigatest -gigatest: status clean dircheck libs $(gigatest_exe) +gigatest: status clean dircheck $(flaim_static_lib) $(gigatest_exe) $(gigatest_exe): $(gigatest_obj) $(flaim_static_lib) $(ec)$(gprintf) "Linking $@ ...\n" $(call flm_exe_link_cmd,$(util_dir),gigatest,$(gigatest_obj)) @@ -1598,7 +1598,7 @@ $(gigatest_exe): $(gigatest_obj) $(flaim_static_lib) # -- rebuild -- .PHONY : rebuild -rebuild: status clean dircheck libs $(rebuild_exe) +rebuild: status clean dircheck $(flaim_static_lib) $(rebuild_exe) $(rebuild_exe): $(rebuild_obj) $(flaim_static_lib) $(ec)$(gprintf) "Linking $@ ...\n" $(call flm_exe_link_cmd,$(util_dir),rebuild,$(rebuild_obj)) @@ -1606,7 +1606,7 @@ $(rebuild_exe): $(rebuild_obj) $(flaim_static_lib) # -- view -- .PHONY : view -view: status clean dircheck libs $(view_exe) +view: status clean dircheck $(flaim_static_lib) $(view_exe) $(view_exe): $(view_obj) $(flaim_static_lib) $(ec)$(gprintf) "Linking $@ ...\n" $(call flm_exe_link_cmd,$(util_dir),view,$(view_obj)) @@ -1614,7 +1614,7 @@ $(view_exe): $(view_obj) $(flaim_static_lib) # -- dbshell -- .PHONY : dbshell -dbshell: status clean dircheck libs $(dbshell_exe) +dbshell: status clean dircheck $(flaim_static_lib) $(dbshell_exe) $(dbshell_exe): $(dbshell_obj) $(flaim_static_lib) $(ec)$(gprintf) "Linking $@ ...\n" $(call flm_exe_link_cmd,$(util_dir),dbshell,$(dbshell_obj)) @@ -1623,7 +1623,7 @@ $(dbshell_exe): $(dbshell_obj) $(flaim_static_lib) .PHONY : sample ifndef netware_target -sample: status clean dircheck libs $(sample_exe) +sample: status clean dircheck $(flaim_static_lib) $(sample_exe) $(sample_exe): $(sample_obj) $(flaim_static_lib) $(ec)$(gprintf) "Linking $@ ...\n" $(call flm_exe_link_cmd,$(sample_dir),sample,$(sample_obj)) diff --git a/flaim/src/flcreate.cpp b/flaim/src/flcreate.cpp index e727b45..9932f40 100644 --- a/flaim/src/flcreate.cpp +++ b/flaim/src/flcreate.cpp @@ -279,8 +279,9 @@ RCODE flmCreateNewFile( } if( RC_BAD( rc = pDb->pSFileHdl->setup( pSFileClient, - gv_FlmSysData.pFileHdlCache, gv_FlmSysData.uiFileOpenFlags, - gv_FlmSysData.uiFileCreateFlags))) + gv_FlmSysData.pFileHdlCache, + gv_FlmSysData.uiFileOpenFlags | FLM_IO_NO_MISALIGNED, + gv_FlmSysData.uiFileCreateFlags | FLM_IO_NO_MISALIGNED))) { goto Exit; } diff --git a/flaim/src/fldbglog.cpp b/flaim/src/fldbglog.cpp index 76e57bd..99ac148 100644 --- a/flaim/src/fldbglog.cpp +++ b/flaim/src/fldbglog.cpp @@ -337,13 +337,13 @@ void _flmDbgOutputMsg( } } -#endif // #ifdef FLM_DBG_LOG +#else // #ifdef FLM_DBG_LOG /**************************************************************************** Desc: ****************************************************************************/ -#if( (defined( FLM_NLM) && !defined( __MWERKS__)) || defined( FLM_OSX)) void gv_fldbglog() { } + #endif diff --git a/flaim/src/flopen.cpp b/flaim/src/flopen.cpp index 83bf394..4b3729e 100644 --- a/flaim/src/flopen.cpp +++ b/flaim/src/flopen.cpp @@ -639,8 +639,9 @@ RCODE flmOpenFile( } if( RC_BAD( rc = pDb->pSFileHdl->setup( pSFileClient, - gv_FlmSysData.pFileHdlCache, gv_FlmSysData.uiFileOpenFlags, - gv_FlmSysData.uiFileCreateFlags))) + gv_FlmSysData.pFileHdlCache, + gv_FlmSysData.uiFileOpenFlags | FLM_IO_NO_MISALIGNED, + gv_FlmSysData.uiFileCreateFlags | FLM_IO_NO_MISALIGNED))) { goto Exit; } @@ -1021,8 +1022,9 @@ FSTATIC RCODE flmPhysFileOpen( } if( RC_BAD( rc = pDb->pSFileHdl->setup( pSFileClient, - gv_FlmSysData.pFileHdlCache, gv_FlmSysData.uiFileOpenFlags, - gv_FlmSysData.uiFileCreateFlags))) + gv_FlmSysData.pFileHdlCache, + gv_FlmSysData.uiFileOpenFlags | FLM_IO_NO_MISALIGNED, + gv_FlmSysData.uiFileCreateFlags | FLM_IO_NO_MISALIGNED))) { goto Exit; } @@ -1381,7 +1383,7 @@ FSTATIC RCODE flmReadFileHdr( // Read and verify the file and log headers. if( RC_BAD( rc = gv_FlmSysData.pFileSystem->openFile( pszDbPath, - gv_FlmSysData.uiFileOpenFlags, &pFileHdl))) + gv_FlmSysData.uiFileOpenFlags | FLM_IO_NO_MISALIGNED, &pFileHdl))) { goto Exit; } @@ -1563,8 +1565,9 @@ RCODE flmStartCPThread( } if( RC_BAD( rc = pCPInfo->pSFileHdl->setup( pSFileClient, - gv_FlmSysData.pFileHdlCache, gv_FlmSysData.uiFileOpenFlags, - gv_FlmSysData.uiFileCreateFlags))) + gv_FlmSysData.pFileHdlCache, + gv_FlmSysData.uiFileOpenFlags | FLM_IO_NO_MISALIGNED, + gv_FlmSysData.uiFileCreateFlags | FLM_IO_NO_MISALIGNED))) { goto Exit; } diff --git a/flaim/src/fstructs.h b/flaim/src/fstructs.h index 448250b..84ea34d 100644 --- a/flaim/src/fstructs.h +++ b/flaim/src/fstructs.h @@ -527,7 +527,9 @@ typedef struct SCACHE_MGR FLMUINT uiHashTblBits; // Number of bits that are significant // for the hash table size. - IF_FixedAlloc * pAllocators[ 2]; + IF_FixedAlloc * pSCacheAllocator; + // Fixed size allocator for SCACHE structures + IF_BlockAlloc * pBlockAllocators[ 2]; // Fixed size allocators for cache blocks // We only support 4K and 8K blocks diff --git a/flaim/src/scache.cpp b/flaim/src/scache.cpp index d5ab6b9..566059f 100644 --- a/flaim/src/scache.cpp +++ b/flaim/src/scache.cpp @@ -327,6 +327,35 @@ public: void * pvOldAlloc); }; +/**************************************************************************** +Desc: +****************************************************************************/ +class F_BlockRelocator : public IF_Relocator +{ +public: + + F_BlockRelocator( FLMUINT uiBlockSize) + { + m_uiSigBitsInBlkSize = flmGetSigBits( uiBlockSize); + } + + virtual ~F_BlockRelocator() + { + } + + SCACHE * getSCachePtr( + void * pvAlloc); + + void FLMAPI relocate( + void * pvOldAlloc, + void * pvNewAlloc); + + FLMBOOL FLMAPI canRelocate( + void * pvOldAlloc); + + FLMUINT m_uiSigBitsInBlkSize; +}; + /*************************************************************************** Desc: *****************************************************************************/ @@ -1512,8 +1541,10 @@ FSTATIC void ScaFree( } gv_FlmSysData.SCacheMgr.Usage.uiCount--; - gv_FlmSysData.SCacheMgr.pAllocators[ - pSCache->ui16BlkSize == 4096 ? 0 : 1]->freeCell( pSCache); + gv_FlmSysData.SCacheMgr.pBlockAllocators[ + pSCache->ui16BlkSize == 4096 ? 0 : 1]->freeBlock( + (void **)&pSCache->pucBlk); + gv_FlmSysData.SCacheMgr.pSCacheAllocator->freeCell( pSCache); pSCache = NULL; } @@ -2852,8 +2883,9 @@ void ScaCleanupCache( // Defrag cache memory - gv_FlmSysData.SCacheMgr.pAllocators[ 0]->defragmentMemory(); - gv_FlmSysData.SCacheMgr.pAllocators[ 1]->defragmentMemory(); + gv_FlmSysData.SCacheMgr.pBlockAllocators[ 0]->defragmentMemory(); + gv_FlmSysData.SCacheMgr.pBlockAllocators[ 1]->defragmentMemory(); + gv_FlmSysData.SCacheMgr.pSCacheAllocator->defragmentMemory(); f_mutexUnlock( gv_FlmSysData.hShareMutex); } @@ -3153,17 +3185,23 @@ FSTATIC RCODE scaAllocCacheBlock( SCACHE * pSCache; f_assertMutexLocked( gv_FlmSysData.hShareMutex); - - if( (pSCache = (SCACHE *)gv_FlmSysData.SCacheMgr.pAllocators[ - uiBlockSize == 4096 ? 0 : 1]->allocCell( NULL, NULL)) == NULL) + + if( (pSCache = (SCACHE *)gv_FlmSysData.SCacheMgr.pSCacheAllocator->allocCell( + NULL, NULL)) == NULL) { rc = RC_SET( FERR_MEM); goto Exit; } - + f_memset( pSCache, 0, sizeof( SCACHE)); - pSCache->pucBlk = (FLMBYTE *)(&pSCache[ 1]); - + + if( RC_BAD( rc = gv_FlmSysData.SCacheMgr.pBlockAllocators[ + uiBlockSize == 4096 ? 0 : 1]->allocBlock( (void **)&pSCache->pucBlk))) + { + gv_FlmSysData.SCacheMgr.pSCacheAllocator->freeCell( pSCache); + goto Exit; + } + // Set the block size. pSCache->ui16BlkSize = (FLMUINT16)uiBlockSize; @@ -3343,14 +3381,13 @@ FSTATIC RCODE ScaReadTheBlock( FLMUINT uiFilePos, FLMUINT uiBlkAddress) { - RCODE rc = FERR_OK; - FLMUINT uiBytesRead; - FFILE * pFile = pDb->pFile; - FLMUINT uiBlkSize = pFile->FileHdr.uiBlockSize; - DB_STATS * pDbStats = pDb->pDbStats; - F_TMSTAMP StartTime; - FLMUINT64 ui64ElapMilli; - FLMUINT uiEncryptSize; + RCODE rc = FERR_OK; + FLMUINT uiBytesRead; + FFILE * pFile = pDb->pFile; + FLMUINT uiBlkSize = pFile->FileHdr.uiBlockSize; + DB_STATS * pDbStats = pDb->pDbStats; + F_TMSTAMP StartTime; + FLMUINT64 ui64ElapMilli; // We should NEVER be attempting to read a block address that is // beyond the current logical end of file. @@ -3386,55 +3423,20 @@ FSTATIC RCODE ScaReadTheBlock( f_timeGetTimeStamp( &StartTime); } - if( pDb->pSFileHdl->canDoDirectIO()) + if( RC_BAD( rc = pDb->pSFileHdl->readBlock( uiFilePos, + uiBlkSize, pucBlk, &uiBytesRead))) { - if( RC_BAD( rc = pDb->pSFileHdl->readBlock( uiFilePos, - uiBlkSize, pDb->pucAlignedReadBuf, &uiBytesRead))) + if (pDbStats) { - if (pDbStats) - { - pDbStats->uiReadErrors++; - } - - if (rc == FERR_IO_END_OF_FILE) - { - // Should only be possible when reading a root block, - // because the root block address in the LFILE may be - // a block that was just created by an update - // transaction. - - flmAssert( pDb->uiKilledTime); - rc = RC_SET( FERR_OLD_VIEW); - } - goto Exit; + pDbStats->uiReadErrors++; } - - uiEncryptSize = (FLMUINT)getEncryptSize( pDb->pucAlignedReadBuf); - if( uiEncryptSize < BH_OVHD || uiEncryptSize > uiBlkSize) + + if (rc == FERR_IO_END_OF_FILE) { - rc = RC_SET_AND_ASSERT( FERR_DATA_ERROR); - goto Exit; - } - - f_memcpy( pucBlk, pDb->pucAlignedReadBuf, uiEncryptSize); - } - else - { - if( RC_BAD( rc = pDb->pSFileHdl->readBlock( uiFilePos, - uiBlkSize, pucBlk, &uiBytesRead))) - { - if (pDbStats) - { - pDbStats->uiReadErrors++; - } - - if (rc == FERR_IO_END_OF_FILE) - { - flmAssert( pDb->uiKilledTime); - rc = RC_SET( FERR_OLD_VIEW); - } - goto Exit; + flmAssert( pDb->uiKilledTime); + rc = RC_SET( FERR_OLD_VIEW); } + goto Exit; } #ifdef FLM_DBG_LOG @@ -7028,6 +7030,7 @@ RCODE ScaInit( FLMUINT uiLoop; FLMUINT uiBlockSize; F_SCacheRelocator * pSCacheRelocator = NULL; + F_BlockRelocator * pBlockRelocator = NULL; f_memset( &gv_FlmSysData.SCacheMgr, 0, sizeof( SCACHE_MGR)); gv_FlmSysData.SCacheMgr.Usage.uiMaxBytes = uiMaxSharedCache; @@ -7039,34 +7042,58 @@ RCODE ScaInit( goto Exit; } - // Allocate a re-locator object + // Allocate the SCACHE re-locator object if( (pSCacheRelocator = f_new F_SCacheRelocator) == NULL) { rc = RC_SET( FERR_MEM); goto Exit; } - + + // Initialize the SCACHE allocator + + if( RC_BAD( rc = FlmAllocFixedAllocator( + &gv_FlmSysData.SCacheMgr.pSCacheAllocator))) + { + goto Exit; + } + + if( RC_BAD( rc = gv_FlmSysData.SCacheMgr.pSCacheAllocator->setup( + FALSE, gv_FlmSysData.pSlabManager, pSCacheRelocator, sizeof( SCACHE), + &gv_FlmSysData.SCacheMgr.Usage.SlabUsage, + &gv_FlmSysData.SCacheMgr.Usage.uiTotalBytesAllocated))) + { + goto Exit; + } + // Initialize the cache block allocators for( uiLoop = 0, uiBlockSize = 4096; uiLoop < 2; uiLoop++, uiBlockSize *= 2) { - if( RC_BAD( rc = FlmAllocFixedAllocator( - &gv_FlmSysData.SCacheMgr.pAllocators[ uiLoop]))) + if( RC_BAD( rc = FlmAllocBlockAllocator( + &gv_FlmSysData.SCacheMgr.pBlockAllocators[ uiLoop]))) { goto Exit; } - if( RC_BAD( rc = gv_FlmSysData.SCacheMgr.pAllocators[ uiLoop]->setup( - FALSE, gv_FlmSysData.pSlabManager, pSCacheRelocator, - sizeof( SCACHE) + uiBlockSize, + if( (pBlockRelocator = f_new F_BlockRelocator( uiBlockSize)) == NULL) + { + rc = RC_SET( FERR_MEM); + goto Exit; + } + + if( RC_BAD( rc = gv_FlmSysData.SCacheMgr.pBlockAllocators[ uiLoop]->setup( + FALSE, gv_FlmSysData.pSlabManager, pBlockRelocator, uiBlockSize, &gv_FlmSysData.SCacheMgr.Usage.SlabUsage, &gv_FlmSysData.SCacheMgr.Usage.uiTotalBytesAllocated))) { goto Exit; } + + pBlockRelocator->Release(); + pBlockRelocator = NULL; } Exit: @@ -7075,6 +7102,11 @@ Exit: { pSCacheRelocator->Release(); } + + if( pBlockRelocator) + { + pBlockRelocator->Release(); + } return( rc); } @@ -7377,16 +7409,25 @@ void ScaExit( void) // released. scaReduceFreeCache( TRUE); + + // Free all of the cache structs and the allocator + + if( gv_FlmSysData.SCacheMgr.pSCacheAllocator) + { + gv_FlmSysData.SCacheMgr.pSCacheAllocator->freeAll(); + gv_FlmSysData.SCacheMgr.pSCacheAllocator->Release(); + gv_FlmSysData.SCacheMgr.pSCacheAllocator = NULL; + } // Free all of the cache blocks and allocators for( uiLoop = 0; uiLoop < 2; uiLoop++) { - if( gv_FlmSysData.SCacheMgr.pAllocators[ uiLoop]) + if( gv_FlmSysData.SCacheMgr.pBlockAllocators[ uiLoop]) { - gv_FlmSysData.SCacheMgr.pAllocators[ uiLoop]->freeAll(); - gv_FlmSysData.SCacheMgr.pAllocators[ uiLoop]->Release(); - gv_FlmSysData.SCacheMgr.pAllocators[ uiLoop] = NULL; + gv_FlmSysData.SCacheMgr.pBlockAllocators[ uiLoop]->freeAll(); + gv_FlmSysData.SCacheMgr.pBlockAllocators[ uiLoop]->Release(); + gv_FlmSysData.SCacheMgr.pBlockAllocators[ uiLoop] = NULL; } } @@ -8252,7 +8293,7 @@ RCODE ScaDoCheckpoint( } f_mutexUnlock( gv_FlmSysData.hShareMutex); - + // Write out log blocks first. bWroteAll = TRUE; @@ -8337,7 +8378,6 @@ Exit: /**************************************************************************** Desc: -Notes: This routine assumes the global mutex is locked ****************************************************************************/ FLMBOOL F_SCacheRelocator::canRelocate( void * pvAlloc) @@ -8346,8 +8386,6 @@ FLMBOOL F_SCacheRelocator::canRelocate( if( pSCache->uiUseCount) { - // The block cannot be moved because it has a use count - return( FALSE); } @@ -8357,7 +8395,6 @@ FLMBOOL F_SCacheRelocator::canRelocate( /**************************************************************************** Desc: Fixes up all pointers needed to allow an SCACHE struct to be moved to a different location in memory -Notes: This routine assumes the global mutex is locked ****************************************************************************/ void F_SCacheRelocator::relocate( void * pvOldAlloc, @@ -8500,13 +8537,108 @@ void F_SCacheRelocator::relocate( pSCacheMgr->pLastFree = pNewSCache; } - pNewSCache->pucBlk = (FLMBYTE *)&pNewSCache[ 1]; - #ifdef FLM_DEBUG f_memset( pOldSCache, 0, sizeof( SCACHE)); #endif } +/**************************************************************************** +Desc: +****************************************************************************/ +SCACHE * F_BlockRelocator::getSCachePtr( + void * pvAlloc) +{ + FLMBYTE * pucBlock = (FLMBYTE *)pvAlloc; + FLMUINT uiBlockAddr; + SCACHE * pSCache; + SCACHE ** ppSCacheBucket; + + // Determine the block address and find the block in cache + + uiBlockAddr = GET_BH_ADDR( pucBlock); + ppSCacheBucket = ScaHash( m_uiSigBitsInBlkSize, uiBlockAddr); + + // Search down the linked list of SCACHE structures off of the bucket + // looking for the correct cache block. + + pSCache = *ppSCacheBucket; + while( pSCache) + { + if( pSCache->uiBlkAddress == uiBlockAddr) + { + if( pSCache->pucBlk == pucBlock) + { + break; + } + else + { + SCACHE * pTmpSCache; + + // Search the version list + + pTmpSCache = pSCache->pPrevInVersionList; + while( pTmpSCache) + { + if( pTmpSCache->pucBlk == pucBlock) + { + pSCache = pTmpSCache; + break; + } + + pTmpSCache = pTmpSCache->pPrevInVersionList; + } + + pTmpSCache = pSCache->pNextInVersionList; + while( pTmpSCache) + { + if( pTmpSCache->pucBlk == pucBlock) + { + pSCache = pTmpSCache; + break; + } + + pTmpSCache = pTmpSCache->pNextInVersionList; + } + } + } + + pSCache = pSCache->pNextInHashBucket; + } + + return( pSCache); +} + +/**************************************************************************** +Desc: +****************************************************************************/ +FLMBOOL F_BlockRelocator::canRelocate( + void * pvAlloc) +{ + SCACHE * pSCache = getSCachePtr( pvAlloc); + + if( !pSCache || pSCache->uiUseCount) + { + return( FALSE); + } + + return( TRUE); +} + +/**************************************************************************** +Desc: +****************************************************************************/ +void F_BlockRelocator::relocate( + void * pvOldAlloc, + void * pvNewAlloc) +{ + SCACHE * pSCache = getSCachePtr( pvOldAlloc); + + flmAssert( pSCache); + flmAssert( pSCache->pucBlk == pvOldAlloc); + + pSCache->pucBlk = (FLMBYTE *)pvNewAlloc; +} + /**************************************************************************** Desc: This function will encrypt the block of data passed in. It will also fill the rest of the block with random data. This function assumes diff --git a/flaim/util/basic_test.cpp b/flaim/util/basic_test.cpp index 976abd8..09a66c6 100644 --- a/flaim/util/basic_test.cpp +++ b/flaim/util/basic_test.cpp @@ -95,7 +95,7 @@ public: RCODE addRecordTest( FLMUINT * puiDrn); - + RCODE largeFieldTest( void); RCODE modifyRecordTest( @@ -466,8 +466,7 @@ Exit: Desc: ****************************************************************************/ RCODE IFlmTestImpl::addRecordTest( - FLMUINT * puiDrn - ) + FLMUINT * puiDrn) { RCODE rc = FERR_OK; FlmRecord * pRec = NULL; @@ -558,7 +557,8 @@ RCODE IFlmTestImpl::addRecordTest( // Reserve the next DRN - so it should not be used. - if (RC_BAD( rc = FlmReserveNextDrn( m_hDb, FLM_DATA_CONTAINER, &uiReserveDrn))) + if (RC_BAD( rc = FlmReserveNextDrn( m_hDb, + FLM_DATA_CONTAINER, &uiReserveDrn))) { MAKE_ERROR_STRING( "calling FlmReserveNextDrn", rc, m_szFailInfo); goto Exit; @@ -592,6 +592,7 @@ RCODE IFlmTestImpl::addRecordTest( MAKE_ERROR_STRING( "calling FlmRecordAdd", rc, m_szFailInfo); goto Exit; } + if (*puiDrn <= uiReserveDrn) { rc = RC_SET( FERR_FAILURE); @@ -612,28 +613,38 @@ RCODE IFlmTestImpl::addRecordTest( MAKE_ERROR_STRING( "calling FlmRecord->copy()", rc, m_szFailInfo); goto Exit; } - if ((pvField = pCopyRec->find( pCopyRec->root(), FIRST_NAME_TAG)) == NULL) + + if ((pvField = pCopyRec->find( + pCopyRec->root(), FIRST_NAME_TAG)) == NULL) { rc = RC_SET( FERR_DATA_ERROR); - MAKE_ERROR_STRING( "corruption calling FlmRecord->copy()", rc, m_szFailInfo); + MAKE_ERROR_STRING( "corruption calling FlmRecord->copy()", + rc, m_szFailInfo); goto Exit; } - if( RC_BAD( rc = pCopyRec->setNative( pvField, gv_pszGivenNames [uiLoop2]))) + + if( RC_BAD( rc = pCopyRec->setNative( pvField, + gv_pszGivenNames [uiLoop2]))) { MAKE_ERROR_STRING( "calling setNative", rc, m_szFailInfo); goto Exit; } + if ((pvField = pCopyRec->find( pCopyRec->root(), LAST_NAME_TAG)) == NULL) { rc = RC_SET( FERR_DATA_ERROR); - MAKE_ERROR_STRING( "corruption calling FlmRecord->copy()", rc, m_szFailInfo); + MAKE_ERROR_STRING( "corruption calling FlmRecord->copy()", + rc, m_szFailInfo); goto Exit; } - if( RC_BAD( rc = pCopyRec->setNative( pvField, gv_pszFamilyNames [uiLoop]))) + + if( RC_BAD( rc = pCopyRec->setNative( pvField, + gv_pszFamilyNames [uiLoop]))) { MAKE_ERROR_STRING( "calling setNative", rc, m_szFailInfo); goto Exit; } + uiDrn2 = 0; if( RC_BAD( rc = FlmRecordAdd( m_hDb, FLM_DATA_CONTAINER, &uiDrn2, pCopyRec, 0))) @@ -641,6 +652,7 @@ RCODE IFlmTestImpl::addRecordTest( MAKE_ERROR_STRING( "calling FlmRecordAdd", rc, m_szFailInfo); goto Exit; } + if (uiDrn2 <= uiLastDrn) { rc = RC_SET( FERR_FAILURE); @@ -649,6 +661,7 @@ RCODE IFlmTestImpl::addRecordTest( (unsigned)uiDrn2, (unsigned)uiLastDrn); goto Exit; } + uiLastDrn = uiDrn2; pCopyRec->Release(); pCopyRec = NULL; @@ -656,6 +669,7 @@ RCODE IFlmTestImpl::addRecordTest( } // Commit the transaction + // // If FlmDbTransCommit returns without an error, the changes made // above will be durable even if the system crashes. @@ -665,7 +679,6 @@ RCODE IFlmTestImpl::addRecordTest( goto Exit; } bTransActive = FALSE; - bPassed = TRUE; Exit: @@ -1144,19 +1157,22 @@ RCODE IFlmTestImpl::keyRetrieveTest( if ((pvField = pFoundKey->find( pFoundKey->root(), LAST_NAME_TAG)) == NULL) { rc = RC_SET( FERR_DATA_ERROR); - MAKE_ERROR_STRING( "corruption calling FlmRecord->find()", rc, m_szFailInfo); + MAKE_ERROR_STRING( "corruption calling FlmRecord->find()", + rc, m_szFailInfo); goto Exit; } uiLen = sizeof( szCurrLastName); if (RC_BAD( rc = pFoundKey->getNative( pvField, szCurrLastName, &uiLen))) { - MAKE_ERROR_STRING( "calling FlmRecord->getNative()", rc, m_szFailInfo); + MAKE_ERROR_STRING( "calling FlmRecord->getNative()", + rc, m_szFailInfo); goto Exit; } if ((pvField = pFoundKey->find( pFoundKey->root(), FIRST_NAME_TAG)) == NULL) { rc = RC_SET( FERR_DATA_ERROR); - MAKE_ERROR_STRING( "corruption calling FlmRecord->find()", rc, m_szFailInfo); + MAKE_ERROR_STRING( "corruption calling FlmRecord->find()", + rc, m_szFailInfo); goto Exit; } uiLen = sizeof( szCurrFirstName); @@ -1854,7 +1870,8 @@ RCODE IFlmTestImpl::deleteFieldTest( if (pDictRec->getFieldID( pDictRec->root()) != FLM_FIELD_TAG) { rc = RC_SET( FERR_FAILURE); - f_sprintf( m_szFailInfo, "Dictionary record %u, is not a field definition!", + f_sprintf( m_szFailInfo, + "Dictionary record %u, is not a field definition!", (unsigned)uiFieldNum); goto Exit; } @@ -1905,7 +1922,8 @@ RCODE IFlmTestImpl::deleteFieldTest( else { rc = RC_SET( FERR_FAILURE); - f_sprintf( m_szFailInfo, "Should not be able to set field %'s state to unused!", + f_sprintf( m_szFailInfo, + "Should not be able to set field %'s state to unused!", (unsigned)uiFieldNum); goto Exit; } @@ -1974,7 +1992,8 @@ RCODE IFlmTestImpl::deleteFieldTest( if (pDictRec->getFieldID( pDictRec->root()) != FLM_FIELD_TAG) { rc = RC_SET( FERR_FAILURE); - f_sprintf( m_szFailInfo, "Dictionary record %u, is not a field definition!", + f_sprintf( m_szFailInfo, + "Dictionary record %u, is not a field definition!", (unsigned)uiFieldNum); goto Exit; } @@ -2015,8 +2034,9 @@ RCODE IFlmTestImpl::deleteFieldTest( if (f_strnicmp( szState, "acti", 4) != 0) { rc = RC_SET( FERR_FAILURE); - f_sprintf( m_szFailInfo, "Dictionary record %u's state should be active!", - (unsigned)uiFieldNum); + f_sprintf( m_szFailInfo, + "Dictionary record %u's state should be active!", + (unsigned)uiFieldNum); goto Exit; } } @@ -2044,7 +2064,8 @@ RCODE IFlmTestImpl::deleteFieldTest( bTransActive = TRUE; - if( RC_BAD( rc = FlmDbSweep( m_hDb, SWEEP_PURGED_FLDS, EACH_CHANGE, NULL, NULL))) + if( RC_BAD( rc = FlmDbSweep( m_hDb, SWEEP_PURGED_FLDS, + EACH_CHANGE, NULL, NULL))) { MAKE_ERROR_STRING( "calling FlmDbSweep", rc, m_szFailInfo); goto Exit; @@ -2407,7 +2428,8 @@ RCODE IFlmTestImpl::sortedFieldsTest( if (!pvDataField) { rc = RC_SET( FERR_FAILURE); - f_sprintf( m_szFailInfo, "Could not find next level one after field #%u", + f_sprintf( m_szFailInfo, + "Could not find next level one after field #%u", (unsigned)uiFieldId); goto Exit; } @@ -2418,7 +2440,8 @@ RCODE IFlmTestImpl::sortedFieldsTest( if (uiTmp != uiFieldId + 1) { rc = RC_SET( FERR_FAILURE); - f_sprintf( m_szFailInfo, "Incorrect field ID (%u) returned from level one field #%u (incl)", + f_sprintf( m_szFailInfo, + "Incorrect field ID (%u) returned from level one field #%u (incl)", (unsigned)uiTmp, (unsigned)(uiFieldId + 1)); goto Exit; } @@ -2462,8 +2485,9 @@ RCODE IFlmTestImpl::sortedFieldsTest( if (uiCount > 3) { rc = RC_SET( FERR_FAILURE); - f_sprintf( m_szFailInfo, "Too many instances of level one fields with ID #%u", - (unsigned)(uiFieldId + 1)); + f_sprintf( m_szFailInfo, + "Too many instances of level one fields with ID #%u", + (unsigned)(uiFieldId + 1)); goto Exit; } @@ -2473,7 +2497,8 @@ RCODE IFlmTestImpl::sortedFieldsTest( if (uiTmp != uiFieldId + 1) { rc = RC_SET( FERR_FAILURE); - f_sprintf( m_szFailInfo, "Incorrect field ID (%u) returned from instance #%u of level one field #%u", + f_sprintf( m_szFailInfo, + "Incorrect field ID (%u) returned from instance #%u of level one field #%u", (unsigned)uiTmp, (unsigned)uiCount, (unsigned)(uiFieldId + 1)); goto Exit; } @@ -2488,7 +2513,8 @@ RCODE IFlmTestImpl::sortedFieldsTest( if (uiTmp != uiFieldId + 1) { rc = RC_SET( FERR_FAILURE); - f_sprintf( m_szFailInfo, "Incorrect value (%u) returned from instance #%u of level one field #%u", + f_sprintf( m_szFailInfo, + "Incorrect value (%u) returned from instance #%u of level one field #%u", (unsigned)uiTmp, (unsigned)uiCount, (unsigned)(uiFieldId + 1)); goto Exit; } @@ -2522,7 +2548,8 @@ RCODE IFlmTestImpl::sortedFieldsTest( if (!pvDataField) { rc = RC_SET( FERR_FAILURE); - f_sprintf( m_szFailInfo, "Could not find instance #%u of level one field #%u", + f_sprintf( m_szFailInfo, + "Could not find instance #%u of level one field #%u", (unsigned)uiCount, (unsigned)uiFieldId); goto Exit; } @@ -2533,7 +2560,8 @@ RCODE IFlmTestImpl::sortedFieldsTest( if (uiTmp != uiFieldId) { rc = RC_SET( FERR_FAILURE); - f_sprintf( m_szFailInfo, "Incorrect field ID (%u) returned from instance #%u of level one field #%u", + f_sprintf( m_szFailInfo, + "Incorrect field ID (%u) returned from instance #%u of level one field #%u", (unsigned)uiTmp, (unsigned)uiCount, (unsigned)uiFieldId); goto Exit; } @@ -2545,10 +2573,12 @@ RCODE IFlmTestImpl::sortedFieldsTest( MAKE_ERROR_STRING( "calling getUINT", rc, m_szFailInfo); goto Exit; } + if (uiTmp != uiFieldId) { rc = RC_SET( FERR_FAILURE); - f_sprintf( m_szFailInfo, "Incorrect value (%u) returned from instance #%u of level one field #%u", + f_sprintf( m_szFailInfo, + "Incorrect value (%u) returned from instance #%u of level one field #%u", (unsigned)uiTmp, (unsigned)uiCount, (unsigned)uiFieldId); goto Exit; } @@ -2830,7 +2860,8 @@ RCODE IFlmTestImpl::compareRecords( &uiLevel2, &uiDataType2, &uiDataLength2, &uiEncLength2, &uiEncId2))) { - MAKE_ERROR_STRING( "calling FlmRecord->getFieldInfo", rc, m_szFailInfo); + MAKE_ERROR_STRING( "calling FlmRecord->getFieldInfo", + rc, m_szFailInfo); goto Exit; } @@ -2846,7 +2877,8 @@ RCODE IFlmTestImpl::compareRecords( if (uiLevel1 != uiLevel2) { rc = RC_SET( FERR_FAILURE); - f_sprintf( m_szFailInfo, "Field Level mismatch in %s, Fld: %u, %s: %u, %s: %u", + f_sprintf( m_szFailInfo, + "Field Level mismatch in %s, Fld: %u, %s: %u, %s: %u", pszWhat, (unsigned)uiFieldNum1, pszDb1, (unsigned)uiLevel1, pszDb2, (unsigned)uiLevel2); @@ -2855,7 +2887,8 @@ RCODE IFlmTestImpl::compareRecords( if (uiDataLength1 != uiDataLength2) { rc = RC_SET( FERR_FAILURE); - f_sprintf( m_szFailInfo, "Field Length mismatch in %s, Fld: %u, %s: %u, %s: %u", + f_sprintf( m_szFailInfo, + "Field Length mismatch in %s, Fld: %u, %s: %u, %s: %u", pszWhat, (unsigned)uiFieldNum1, pszDb1, (unsigned)uiDataLength1, pszDb2, (unsigned)uiDataLength2); @@ -3800,14 +3833,17 @@ RCODE IFlmTestImpl::execute( void) { goto Exit; } + if (RC_BAD( rc = removeDbTest( DB_NAME_STR))) { goto Exit; } + if (RC_BAD( rc = removeDbTest( DB_RESTORE_NAME_STR))) { goto Exit; } + if (RC_BAD( rc = removeDbTest( DB_REBUILD_NAME_STR))) { goto Exit; @@ -3816,7 +3852,5 @@ RCODE IFlmTestImpl::execute( void) Exit: FlmShutdown(); - return( rc); } - diff --git a/flaim/util/gigatest.cpp b/flaim/util/gigatest.cpp index 2220348..d07f524 100644 --- a/flaim/util/gigatest.cpp +++ b/flaim/util/gigatest.cpp @@ -33,7 +33,8 @@ #define MAX_CACHE_ROW 1 #define USED_CACHE_ROW (MAX_CACHE_ROW + 1) -#define DIRTY_CACHE_ROW (USED_CACHE_ROW + 1) +#define ITEMS_CACHED_ROW (USED_CACHE_ROW + 1) +#define DIRTY_CACHE_ROW (ITEMS_CACHED_ROW + 1) #define LOG_CACHE_ROW (DIRTY_CACHE_ROW + 1) #define FREE_CACHE_ROW (LOG_CACHE_ROW + 1) #define CP_STATE_ROW (FREE_CACHE_ROW + 1) @@ -833,24 +834,31 @@ void gigaUpdateMemInfo( void) char szBuf [50]; FlmGetMemoryInfo( &MemInfo); - f_sprintf( (char *)szBuf, "Blk: %-10u Rec: %-10u", + + f_sprintf( (char *)szBuf, "Blk: %-10u Record: %-10u", (unsigned)MemInfo.BlockCache.uiMaxBytes, (unsigned)MemInfo.RecordCache.uiMaxBytes); gigaOutputStr( MAX_CACHE_ROW, szBuf); - f_sprintf( (char *)szBuf, "Blk: %-10u Rec: %-10u", + + f_sprintf( (char *)szBuf, "Blk: %-10u Record: %-10u", (unsigned)MemInfo.BlockCache.uiTotalBytesAllocated, (unsigned)MemInfo.RecordCache.uiTotalBytesAllocated); gigaOutputStr( USED_CACHE_ROW, szBuf); - f_sprintf( (char *)szBuf, "Cnt: %-10u Bytes: %-10u", + f_sprintf( (char *)szBuf, "Blk: %-10u Record: %-10u", + (unsigned)MemInfo.BlockCache.uiCount, + (unsigned)MemInfo.RecordCache.uiCount); + gigaOutputStr( ITEMS_CACHED_ROW, szBuf); + + f_sprintf( (char *)szBuf, "Cnt: %-10u Bytes : %-10u", (unsigned)MemInfo.uiDirtyCount, (unsigned)MemInfo.uiDirtyBytes); gigaOutputStr( DIRTY_CACHE_ROW, szBuf); - f_sprintf( (char *)szBuf, "Cnt: %-10u Bytes: %-10u", + f_sprintf( (char *)szBuf, "Cnt: %-10u Bytes : %-10u", (unsigned)MemInfo.uiLogCount, (unsigned)MemInfo.uiLogBytes); gigaOutputStr( LOG_CACHE_ROW, szBuf); - f_sprintf( (char *)szBuf, "Cnt: %-10u Bytes: %-10u", + f_sprintf( (char *)szBuf, "Cnt: %-10u Bytes : %-10u", (unsigned)MemInfo.uiFreeCount, (unsigned)MemInfo.uiFreeBytes); gigaOutputStr( FREE_CACHE_ROW, szBuf); @@ -1062,6 +1070,7 @@ RCODE gigaLoadDatabase( void) gigaOutputLabel( MAX_CACHE_ROW, "Maximum Cache Size (bytes)"); gigaOutputLabel( USED_CACHE_ROW, "Cache Used (bytes)"); + gigaOutputLabel( ITEMS_CACHED_ROW, "Cache Used (items)"); gigaOutputLabel( DIRTY_CACHE_ROW, "Dirty Cache (bytes)"); gigaOutputLabel( LOG_CACHE_ROW, "Log Cache (bytes)"); gigaOutputLabel( FREE_CACHE_ROW, "Free Cache (bytes)");