FLAIM changes. Changes to use FTK notify lists and the FDB hWaitSem.

git-svn-id: https://svn.code.sf.net/p/flaim/code/trunk@677 0109f412-320b-0410-ab79-c3e0c5ffbbe6
This commit is contained in:
ahodgkinson
2006-07-19 18:27:22 +00:00
parent 9600908d36
commit 6f0bdb05c5
7 changed files with 143 additions and 334 deletions

View File

@@ -1085,11 +1085,6 @@ F_BKGND_IX * flmBackgroundIndexGet(
FLMBOOL bMutexLocked,
FLMUINT * puiThreadId = NULL);
RCODE flmWaitNotifyReq(
F_MUTEX hMutex,
FNOTIFY ** ppNotifyListRV,
void * UserData);
RCODE flmLinkFileToBucket(
FFILE * pFile);
@@ -1142,9 +1137,10 @@ RCODE flmRcaConfig(
void flmRcaExit( void);
void flmRcaFindRec(
FFILE * pFile,
F_SEM hWaitSem,
FLMUINT uiContainer,
FLMUINT uiDrn,
FFILE * pFile,
FLMUINT uiVersionNeeded,
FLMBOOL bDontPoisonCache,
FLMUINT * puiNumLooks,

View File

@@ -710,11 +710,10 @@ Desc: This routine checks to see if it is OK for another FDB to use a file.
****************************************************************************/
RCODE flmVerifyFileUse(
F_MUTEX hMutex,
FFILE ** ppFileRV
)
FFILE ** ppFileRV)
{
RCODE rc = FERR_OK;
FFILE * pFile = *ppFileRV;
RCODE rc = FERR_OK;
FFILE * pFile = *ppFileRV;
// Can't open the file if it is being closed by someone else.
@@ -727,13 +726,12 @@ RCODE flmVerifyFileUse(
// If the file is in the process of being opened by another
// thread, wait for the open to complete.
if (pFile->uiFlags & DBF_BEING_OPENED)
if( pFile->uiFlags & DBF_BEING_OPENED)
{
if (RC_BAD( rc = flmWaitNotifyReq( hMutex,
&pFile->pOpenNotifies,
(void *)0)))
if( RC_BAD( rc = f_notifyWait( hMutex, F_SEM_NULL,
NULL, &pFile->pOpenNotifies)))
{
// GW Bug #24307. If flmWaitNotifyReq returns a bad RC, assume that
// If f_notifyWait returns a bad RC, assume that
// the other thread will unlock and free the pFile structure. This
// routine should only unlock the pFile if an error occurs at some
// other point. See flmVerifyFileUse.
@@ -866,11 +864,11 @@ RCODE flmGetExclAccess(
{
// If the file is in the process of being locked by another
// thread, wait for the lock to complete. NOTE: flmWaitNotifyReq will
// thread, wait for the lock to complete. NOTE: f_notifyWait will
// re-lock the mutex before returning.
rc = flmWaitNotifyReq( gv_FlmSysData.hShareMutex, &pFile->pLockNotifies,
(void *)0);
rc = f_notifyWait( gv_FlmSysData.hShareMutex, F_SEM_NULL, NULL,
&pFile->pLockNotifies);
goto Exit;
}
else
@@ -896,7 +894,7 @@ Exit:
if (bNotifyWaiters)
{
FNOTIFY * pNotify;
F_NOTIFY * pNotify;
F_SEM hSem;
// Notify any thread waiting on the lock what its status is
@@ -1073,7 +1071,7 @@ RCODE flmNewFileFinish(
FFILE * pFile,
RCODE OpenRc)
{
FNOTIFY * pNotify;
F_NOTIFY * pNotify;
F_SEM hSem;
if (!pFile)
@@ -1097,7 +1095,7 @@ RCODE flmNewFileFinish(
Exit:
return OpenRc;
return( OpenRc);
}
/****************************************************************************
@@ -1210,9 +1208,8 @@ Retry:
// Put ourselves into the notify list and then re-try
// the lookup when we wake up
if (RC_BAD( rc = flmWaitNotifyReq( gv_FlmSysData.hShareMutex,
&pFile->pCloseNotifies,
(void *)0)))
if (RC_BAD( rc = f_notifyWait(
gv_FlmSysData.hShareMutex, F_SEM_NULL, NULL, &pFile->pCloseNotifies)))
{
goto Exit;
}

View File

@@ -26,7 +26,6 @@
#define FSTRUCTS_H
struct FFILE;
struct FNOTIFY;
struct QUERY_HDR;
struct CDL;
struct FDICT;
@@ -355,7 +354,7 @@ typedef struct SCACHE
// just different versions of the same
// block. The next block is an older
// version of the block.
FNOTIFY * pNotifyList; // This is a pointer to a list of threads
F_NOTIFY * pNotifyList; // This is a pointer to a list of threads
// that want to be notified when a pending
// I/O is complete. This pointer is only
// non-null if the block is currently being
@@ -572,7 +571,7 @@ typedef struct RCACHE
// memory was allocated on the heap
RCACHE * pNextInHeapList; // Next in the list of records whose
// memory was allocated on the heap
FNOTIFY * pNotifyList; // This is a pointer to a list of
F_NOTIFY * pNotifyList; // This is a pointer to a list of
// threads that want to be notified
// when a pending I/O is complete.
// This pointer is only non-null if the
@@ -1422,14 +1421,14 @@ typedef struct FFILE
// belonging to this file that need
// to be logged to the rollback log
// for the current transaction.
FNOTIFY * pOpenNotifies; // Pointer to a list of notifies to
F_NOTIFY * pOpenNotifies; // Pointer to a list of notifies to
// perform when this file is finally
// opened (points to a linked list of
// FNOTIFY structures).
FNOTIFY * pCloseNotifies; // Pointer to a list of notifies to
// F_NOTIFY structures).
F_NOTIFY * pCloseNotifies; // Pointer to a list of notifies to
// perform when this file is finally
// closed (points to a linked list of
// FNOTIFY structures).
// F_NOTIFY structures).
FDICT * pDictList; // Pointer to linked list of
// dictionaries currently being used
// for this file. The linked list
@@ -1522,10 +1521,10 @@ typedef struct FFILE
IF_LockObject * pFileLockObj; // Object for locking the file.
IF_LockObject * pWriteLockObj; // Object for locking to do writing.
IF_FileHdl * pLockFileHdl; // Lock file handle for 3.x databases.
FNOTIFY * pLockNotifies; // Pointer to a list of notifies to
F_NOTIFY * pLockNotifies; // Pointer to a list of notifies to
// perform when this file is finally
// locked (points to a linked list of
// FNOTIFY structures).
// F_NOTIFY structures).
FLMBOOL bBeingLocked; // Flag indicating whether or not this
// file is in the process of being
// locked for exclusive access.
@@ -1580,26 +1579,6 @@ typedef struct FFILE
FLMUINT64 ui64RflDiskUsage; // Current RFL disk space usage estimate (used only if keeping RFL files)
} FFILE;
/***************************************************************************
Desc: This is the notify request structure. Notify requests are linked
off of open requests for files or read requests for files so that
when an operation is complete that multiple threads are waiting
on, all of them will be notified.
***************************************************************************/
typedef struct FNOTIFY
{
FNOTIFY * pNext; // Pointer to next FNOTIFY structure in list.
FLMUINT uiThreadId; // ID of thread requesting the notify
RCODE * pRc; // Pointer to a return code variable that is to
// be filled in when the operation is completed.
// The thread requesting notification supplies
// the return code variable to be filled in.
void * UserData; // Other user data that the notifier might use
// to transfer other information to the waiter.
F_SEM hSem; // Semaphore that will be signaled when the
// operation is complete.
} FNOTIFY;
/****************************************************************************
Desc: Structure used to pass information to the checkpoint thread for 3.x
databases.
@@ -1891,7 +1870,7 @@ private:
FLMUINT m_uiThreadId;
FLMUINT m_uiThreadLockCount;
F_MUTEX m_hMutex;
FNOTIFY * m_pNotifyList;
F_NOTIFY * m_pNotifyList;
F_NameTable * m_pNameTable;
FLMUINT m_uiDictSeqNum;
FLMUINT m_uiNameTableFFileId;

View File

@@ -92,26 +92,6 @@ FSTATIC RCODE flmRegisterHttpCallback(
FSTATIC RCODE flmDeregisterHttpCallback( void);
/****************************************************************************
Desc: This routine frees all of the notify requests in a list of requests.
****************************************************************************/
FINLINE void flmFreeNotifyList(
FNOTIFY ** ppNotifyRV)
{
FNOTIFY * pTmp;
FNOTIFY * pNotify = *ppNotifyRV;
while (pNotify)
{
f_semDestroy( &pNotify->hSem);
pTmp = pNotify;
pNotify = pNotify->pNext;
(void)f_free( &pTmp);
}
*ppNotifyRV = NULL;
}
/****************************************************************************
Desc: Sets the path for all temporary files that come into use within a
FLAIM share structure. The share mutex should be locked when
@@ -849,18 +829,16 @@ Retry:
// If the file is in the process of being opened by another
// thread, wait for the open to complete.
if (pFile->uiFlags & DBF_BEING_OPENED)
if( pFile->uiFlags & DBF_BEING_OPENED)
{
if (RC_BAD( rc = flmWaitNotifyReq( gv_FlmSysData.hShareMutex,
&pFile->pOpenNotifies,
(void *)0)))
if( RC_BAD( rc = f_notifyWait(
gv_FlmSysData.hShareMutex, F_SEM_NULL, NULL, &pFile->pOpenNotifies)))
{
// GW Bug #24307. If flmWaitNotifyReq returns a bad RC, assume that
// the other thread will unlock and free the pFile structure. This
// routine should only unlock the pFile if an error occurs at some
// other point. See flmVerifyFileUse.
// If f_notifyWait returns a bad RC, assume that the other thread
// will unlock and free the pFile structure. This routine should
// only unlock the pFile if an error occurs at some other point.
// See flmVerifyFileUse.
// *ppFileRV is set to NULL at Exit.
goto Exit;
}
@@ -2027,9 +2005,9 @@ Notes: The global mutex is assumed to be locked when entering the
exits, however.
****************************************************************************/
void flmFreeFile(
FFILE * pFile) // File to be freed.
FFILE * pFile)
{
FNOTIFY * pCloseNotifies;
F_NOTIFY * pCloseNotifies;
// See if another thread is in the process of closing
// this FFILE. It is possible for this to happen, since
@@ -2108,12 +2086,9 @@ void flmFreeFile(
pFile->pRfl = NULL;
}
// Free any open notify requests associated with the file.
// We shouldn't have any open notifies at this point, but
// we'll be nice and clean up any resources anyway.
// We shouldn't have any open notifies at this point
flmAssert( pFile->pOpenNotifies == NULL);
flmFreeNotifyList( &pFile->pOpenNotifies);
// Save pCloseNotifies -- we will notify any waiters once the
// FFILE has been freed.
@@ -2497,75 +2472,6 @@ FLMEXP void FLMAPI FlmShutdown( void)
flmUnlockSysData();
}
/****************************************************************************
Desc: This routine links a notify request into a notification list and
then waits to be notified that the event has occurred.
Notes:
This routine assumes that the shared mutex is locked and that
it is supposed to unlock it.
****************************************************************************/
RCODE flmWaitNotifyReq(
F_MUTEX hMutex,
FNOTIFY ** ppNotifyListRV,
void * UserData)
{
FNOTIFY * pNotify = NULL;
RCODE TempRc;
RCODE rc = FERR_OK;
F_SEM hSem;
// First create a notify request and link it into the list
if (RC_OK( rc = f_calloc( (FLMUINT)(sizeof( FNOTIFY)), &pNotify)))
{
// Allocate a semaphore for the notify request
pNotify->uiThreadId = f_threadId();
pNotify->hSem = F_SEM_NULL;
rc = f_semCreate( &pNotify->hSem);
}
if (RC_BAD( rc))
{
if (pNotify)
{
if (pNotify->hSem != F_SEM_NULL)
{
f_semDestroy( &pNotify->hSem);
}
f_free( &pNotify);
}
goto Exit;
}
pNotify->pRc = &rc;
pNotify->UserData = UserData;
pNotify->pNext = *ppNotifyListRV;
*ppNotifyListRV = pNotify;
hSem = pNotify->hSem;
// Unlock the mutex and wait on the semaphore
f_mutexUnlock( hMutex);
if (RC_BAD( TempRc = f_semWait( hSem, F_SEM_WAITFOREVER)))
{
rc = TempRc;
}
// Free the semaphore and the notify structure
f_semDestroy( &hSem);
f_free( &pNotify);
// Relock the mutex
f_mutexLock( hMutex);
Exit:
return( rc);
}
/****************************************************************************
Desc: This routine links an FFILE structure to its name hash bucket.
NOTE: This function assumes that the global mutex has been
@@ -3678,7 +3584,8 @@ RCODE F_Session::lockSession(
goto Exit;
}
if( RC_BAD( rc = flmWaitNotifyReq( m_hMutex, &m_pNotifyList, NULL)))
if( RC_BAD( rc = f_notifyWait( m_hMutex, F_SEM_NULL, NULL,
&m_pNotifyList)))
{
goto Exit;
}

View File

@@ -640,15 +640,8 @@ RCODE F_RCachePage::display(
f_mutexLock( gv_FlmSysData.RCacheMgr.hMutex);
bRCLocked = TRUE;
flmRcaFindRec(uiContainer,
uiDrn,
pFile,
uiVersion,
TRUE,
0,
&pRCache,
&pNewerRCache,
&pOlderRCache);
flmRcaFindRec( pFile, F_SEM_NULL, uiContainer, uiDrn, uiVersion, TRUE,
0, &pRCache, &pNewerRCache, &pOlderRCache);
// We want to hold the RCache and pFile in memory while we render this page.
if (pRCache)
@@ -1224,15 +1217,8 @@ RCODE F_RecordPage::display(
f_mutexLock( gv_FlmSysData.hShareMutex);
f_mutexLock( gv_FlmSysData.RCacheMgr.hMutex);
flmRcaFindRec( uiContainer,
uiDrn,
pFile,
uiVersion,
TRUE,
0,
&pRCache,
&pNewerRCache,
&pOlderRCache);
flmRcaFindRec( pFile, F_SEM_NULL, uiContainer, uiDrn, uiVersion,
TRUE, 0, &pRCache, &pNewerRCache, &pOlderRCache);
if (pRCache)
{

View File

@@ -174,11 +174,8 @@ FSTATIC RCODE flmRcaRehash( void);
FSTATIC RCODE flmRcaSetMemLimit(
FLMUINT uiMaxCacheBytes);
FSTATIC RCODE flmRcaWaitNotify(
FNOTIFY ** ppNotifyListRV);
FSTATIC void flmRcaNotify(
FNOTIFY * pNotify,
F_NOTIFY * pNotify,
RCACHE * pUseRCache,
RCODE NotifyRc);
@@ -1181,81 +1178,13 @@ void flmRcaExit( void)
f_memset( &gv_FlmSysData.RCacheMgr, 0, sizeof( RCACHE_MGR));
}
/****************************************************************************
Desc: This routine links a notify request into a notification list and
then waits to be notified that the event has occurred.
NOTE: This routine assumes that the record cache mutex is locked and that
it is supposed to unlock it. It will relock the mutex on its way out.
****************************************************************************/
FSTATIC RCODE flmRcaWaitNotify(
FNOTIFY ** ppNotifyListRV)
{
FNOTIFY * pNotify = NULL;
RCODE TempRc;
RCODE rc = FERR_OK;
F_SEM hSem;
// First create a notify request and link it into the list.
if (RC_OK( rc = f_calloc( (FLMUINT)(sizeof( FNOTIFY)), &pNotify)))
{
// Allocate a semaphore for the notify request.
pNotify->uiThreadId = f_threadId();
pNotify->hSem = F_SEM_NULL;
rc = f_semCreate( &pNotify->hSem);
}
if (RC_BAD( rc))
{
if (pNotify)
{
if (pNotify->hSem != F_SEM_NULL)
{
f_semDestroy( &pNotify->hSem);
}
f_free( &pNotify);
}
goto Exit;
}
pNotify->pRc = &rc;
pNotify->UserData = NULL;
pNotify->pNext = *ppNotifyListRV;
*ppNotifyListRV = pNotify;
hSem = pNotify->hSem;
// Unlock the mutex and wait on the semaphore.
f_mutexUnlock( gv_FlmSysData.RCacheMgr.hMutex);
if (RC_BAD( TempRc = f_semWait( hSem, F_SEM_WAITFOREVER)))
{
rc = TempRc;
}
// Free the semaphore and the notify structure.
f_semDestroy( &hSem);
f_free( &pNotify);
// Relock the record cache mutex
f_mutexLock( gv_FlmSysData.RCacheMgr.hMutex);
Exit:
return( rc);
}
/****************************************************************************
Desc: This routine notifies threads waiting for a pending read to complete.
NOTE: This routine assumes that the record cache mutex is already
locked.
****************************************************************************/
FSTATIC void flmRcaNotify(
FNOTIFY * pNotify,
F_NOTIFY * pNotify,
RCACHE * pUseRCache,
RCODE NotifyRc)
{
@@ -1558,9 +1487,10 @@ Desc: This routine finds a record in the record cache. If it cannot
has been locked.
****************************************************************************/
void flmRcaFindRec(
FFILE * pFile,
F_SEM hWaitSem,
FLMUINT uiContainer,
FLMUINT uiDrn,
FFILE * pFile,
FLMUINT uiVersionNeeded,
FLMBOOL bDontPoisonCache,
FLMUINT * puiNumLooks,
@@ -1568,11 +1498,11 @@ void flmRcaFindRec(
RCACHE ** ppNewerRCache,
RCACHE ** ppOlderRCache)
{
RCACHE * pRCache;
FLMUINT uiNumLooks = 0;
FLMBOOL bFound;
RCACHE * pNewerRCache;
RCACHE * pOlderRCache;
RCACHE * pRCache;
FLMUINT uiNumLooks = 0;
FLMBOOL bFound;
RCACHE * pNewerRCache;
RCACHE * pOlderRCache;
// Search down the hash bucket for the matching item.
@@ -1620,7 +1550,8 @@ Start_Find:
// in a version that satisfies our request.
gv_FlmSysData.RCacheMgr.uiIoWaits++;
if (RC_BAD( flmRcaWaitNotify( &pRCache->pNotifyList)))
if( RC_BAD( f_notifyWait( gv_FlmSysData.RCacheMgr.hMutex,
hWaitSem, NULL, &pRCache->pNotifyList)))
{
// Don't care what error the other thread had reading
@@ -2012,14 +1943,14 @@ FSTATIC void flmRcaLinkToFFILE(
Desc: This routine retrieves a record from the record cache.
****************************************************************************/
RCODE flmRcaRetrieveRec(
FDB * pDb,
FLMBOOL * pbTransStarted,
FLMUINT uiContainer, // Container record is in.
FLMUINT uiDrn, // DRN of record.
FLMBOOL bOkToGetFromDisk, // If not in cache, OK to get from disk?
BTSK * pStack, // Use stack to retrieve, if NON-NULL.
LFILE * pLFile, // LFILE to use, if retrieving with stack
FlmRecord ** ppRecord)
FDB * pDb,
FLMBOOL * pbTransStarted,
FLMUINT uiContainer, // Container record is in.
FLMUINT uiDrn, // DRN of record.
FLMBOOL bOkToGetFromDisk, // If not in cache, OK to get from disk?
BTSK * pStack, // Use stack to retrieve, if NON-NULL.
LFILE * pLFile, // LFILE to use, if retrieving with stack
FlmRecord ** ppRecord)
{
RCODE rc = FERR_OK;
FLMBOOL bRCacheMutexLocked = FALSE;
@@ -2034,7 +1965,7 @@ RCODE flmRcaRetrieveRec(
FLMUINT uiLowTransId;
FLMBOOL bMostCurrent;
FLMUINT uiCurrTransId;
FNOTIFY * pNotify;
F_NOTIFY * pNotify;
FLMUINT uiNumLooks;
FLMBOOL bInitializedFdb = FALSE;
FLMBOOL bDontPoisonCache = pDb->uiFlags & FDB_DONT_POISON_CACHE
@@ -2094,10 +2025,9 @@ RCODE flmRcaRetrieveRec(
Start_Find:
flmRcaFindRec( uiContainer, uiDrn, pFile,
uiCurrTransId, bDontPoisonCache,
&uiNumLooks, &pRCache,
&pNewerRCache, &pOlderRCache);
flmRcaFindRec( pFile, pDb->hWaitSem, uiContainer, uiDrn,
uiCurrTransId, bDontPoisonCache, &uiNumLooks, &pRCache,
&pNewerRCache, &pOlderRCache);
if (pRCache)
{
@@ -2384,7 +2314,7 @@ RCODE flmRcaInsertRec(
// See if we can find the record in cache
flmRcaFindRec( uiContainer, uiDrn, pFile,
flmRcaFindRec( pFile, pDb->hWaitSem, uiContainer, uiDrn,
pDb->LogHdr.uiCurrTransID, bDontPoisonCache, NULL, &pRCache,
&pNewerRCache, &pOlderRCache);
@@ -2543,12 +2473,12 @@ RCODE flmRcaRemoveRec(
FLMUINT uiContainer,
FLMUINT uiDrn)
{
RCODE rc = FERR_OK;
FLMBOOL bMutexLocked = FALSE;
RCACHE * pRCache;
RCACHE * pNewerRCache;
RCACHE * pOlderRCache;
FFILE * pFile = pDb->pFile;
RCODE rc = FERR_OK;
FLMBOOL bMutexLocked = FALSE;
RCACHE * pRCache;
RCACHE * pNewerRCache;
RCACHE * pOlderRCache;
FFILE * pFile = pDb->pFile;
flmAssert( uiDrn != 0);
@@ -2572,7 +2502,7 @@ RCODE flmRcaRemoveRec(
// See if we can find the record in cache
flmRcaFindRec( uiContainer, uiDrn, pFile,
flmRcaFindRec( pFile, pDb->hWaitSem, uiContainer, uiDrn,
pDb->LogHdr.uiCurrTransID, FALSE, NULL, &pRCache,
&pNewerRCache, &pOlderRCache);

View File

@@ -92,7 +92,7 @@ FSTATIC void _ScaDbgReleaseForThread(
#endif
FSTATIC void ScaNotify(
FNOTIFY * pNotify,
F_NOTIFY * pNotify,
SCACHE * pUseSCache,
RCODE NotifyRc);
@@ -1334,27 +1334,29 @@ Desc: This routine notifies threads waiting for a pending read or write
locked.
****************************************************************************/
FSTATIC void ScaNotify(
FNOTIFY * pNotify,
F_NOTIFY * pNotify,
SCACHE * pUseSCache,
RCODE NotifyRc
)
RCODE NotifyRc)
{
while (pNotify)
while( pNotify)
{
F_SEM hSem;
*(pNotify->pRc) = NotifyRc;
if (RC_OK( NotifyRc))
if( RC_OK( NotifyRc))
{
if (pNotify->UserData)
if( pNotify->pvData)
{
*((SCACHE **)pNotify->UserData) = pUseSCache;
*((SCACHE **)pNotify->pvData) = pUseSCache;
}
if (pUseSCache)
{
ScaUseForThread( pUseSCache, &(pNotify->uiThreadId));
}
}
hSem = pNotify->hSem;
pNotify = pNotify->pNext;
f_semSignal( hSem);
@@ -1368,8 +1370,7 @@ Desc: This routine logs information about changes to a cache block's flags
FSTATIC void scaLogFlgChange(
SCACHE * pSCache,
FLMUINT16 ui16OldFlags,
char cPlace
)
char cPlace)
{
char szBuf [60];
char * pszTmp;
@@ -1524,8 +1525,7 @@ Desc: This routine unlinks a cache block from all of its lists and then
FSTATIC void ScaUnlinkCache(
SCACHE * pSCache,
FLMBOOL bFreeIt,
RCODE NotifyRc
)
RCODE NotifyRc)
{
#ifdef FLM_DEBUG
SCACHE_USE * pUse;
@@ -3338,14 +3338,10 @@ Desc: This routine attempts to read a block from disk. It will
FSTATIC RCODE ScaReadTheBlock(
FDB * pDb,
LFILE * pLFile,
TMP_READ_STATS * pTmpReadStats, // READ statistics.
FLMBYTE * pucBlk, // Pointer to buffer where block is
// to be read into.
FLMUINT uiFilePos, // File position to be read from. If
// file position != block address, we
// are reading from the log.
FLMUINT uiBlkAddress // Block address that is to be read.
)
TMP_READ_STATS * pTmpReadStats,
FLMBYTE * pucBlk,
FLMUINT uiFilePos,
FLMUINT uiBlkAddress)
{
RCODE rc = FERR_OK;
FLMUINT uiBytesRead;
@@ -3384,44 +3380,63 @@ FSTATIC RCODE ScaReadTheBlock(
else
{
pTmpReadStats->BlockReads.ui64Count++;
pTmpReadStats->BlockReads.ui64TotalBytes +=
uiBlkSize;
pTmpReadStats->BlockReads.ui64TotalBytes += uiBlkSize;
}
ui64ElapMilli = 0;
f_timeGetTimeStamp( &StartTime);
}
if( RC_BAD( rc = pDb->pSFileHdl->readBlock( uiFilePos,
uiBlkSize, pDb->pucAlignedReadBuf, &uiBytesRead)))
if( pDb->pSFileHdl->canDoDirectIO())
{
if (pDbStats)
if( RC_BAD( rc = pDb->pSFileHdl->readBlock( uiFilePos,
uiBlkSize, pDb->pucAlignedReadBuf, &uiBytesRead)))
{
pDbStats->uiReadErrors++;
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;
}
if (rc == FERR_IO_END_OF_FILE)
uiEncryptSize = (FLMUINT)getEncryptSize( pDb->pucAlignedReadBuf);
if( uiEncryptSize < BH_OVHD || uiEncryptSize > uiBlkSize)
{
// 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);
rc = RC_SET_AND_ASSERT( FERR_DATA_ERROR);
goto Exit;
}
goto Exit;
f_memcpy( pucBlk, pDb->pucAlignedReadBuf, uiEncryptSize);
}
uiEncryptSize = (FLMUINT)getEncryptSize( pDb->pucAlignedReadBuf);
if( uiEncryptSize < BH_OVHD || uiEncryptSize > uiBlkSize)
else
{
rc = RC_SET_AND_ASSERT( FERR_DATA_ERROR);
goto Exit;
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;
}
}
f_memcpy( pucBlk, pDb->pucAlignedReadBuf, uiEncryptSize);
#ifdef FLM_DBG_LOG
if (uiFilePos != uiBlkAddress)
{
@@ -3993,9 +4008,8 @@ Get_Next_Block:
if (pNextSCache->ui16Flags & CA_READ_PENDING)
{
gv_FlmSysData.SCacheMgr.uiIoWaits++;
if (RC_BAD( rc = flmWaitNotifyReq( gv_FlmSysData.hShareMutex,
&pNextSCache->pNotifyList,
(void *)&pNextSCache)))
if (RC_BAD( rc = f_notifyWait( gv_FlmSysData.hShareMutex,
pDb->hWaitSem, (void *)&pNextSCache, &pNextSCache->pNotifyList)))
{
goto Exit;
}
@@ -4519,7 +4533,7 @@ FSTATIC RCODE ScaReadIntoCache(
RCODE rc = FERR_OK;
SCACHE * pSCache;
SCACHE * pTmpSCache;
FNOTIFY * pNotify;
F_NOTIFY * pNotify;
FLMUINT uiFilePos;
FLMUINT uiNewerBlkLowTransID = 0;
FLMUINT uiExpectedLowTransID = 0;
@@ -6136,18 +6150,17 @@ RCODE ScaGetBlock(
pSBlkVerCache = pSCache;
uiBlkVersion = pDb->LogHdr.uiCurrTransID;
for (;;)
for( ;;)
{
// If the block is being read into memory, wait for the read
// to complete so we can see what it is.
if (pSCache && (pSCache->ui16Flags & CA_READ_PENDING))
if( pSCache && (pSCache->ui16Flags & CA_READ_PENDING))
{
gv_FlmSysData.SCacheMgr.uiIoWaits++;
if (RC_BAD( rc = flmWaitNotifyReq( gv_FlmSysData.hShareMutex,
&pSCache->pNotifyList,
(void *)&pSCache)))
if( RC_BAD( rc = f_notifyWait( gv_FlmSysData.hShareMutex,
pDb->hWaitSem, (void *)&pSCache, &pSCache->pNotifyList)))
{
goto Exit;
}
@@ -6171,9 +6184,10 @@ RCODE ScaGetBlock(
pSMoreRecentVerCache = NULL;
continue;
}
if (!pSCache || uiBlkVersion > pSCache->uiHighTransID)
if( !pSCache || uiBlkVersion > pSCache->uiHighTransID)
{
if (puiNumLooksRV)
if( puiNumLooksRV)
{
*puiNumLooksRV = uiNumLooks;
*ppSCacheRV = NULL;