#include "postgres.h"#include "storage/bufmgr.h"#include "storage/buf_internals.h"
Go to the source code of this file.
Functions | |
| void | InitBufferPool (void) |
| void | InitBufferPoolAccess (void) |
| Size | BufferShmemSize (void) |
Variables | |
| BufferDesc * | BufferDescriptors |
| char * | BufferBlocks |
| int32 * | PrivateRefCount |
| Size BufferShmemSize | ( | void | ) |
Definition at line 164 of file buf_init.c.
References add_size(), mul_size(), NBuffers, and StrategyShmemSize().
Referenced by CreateSharedMemoryAndSemaphores().
{
Size size = 0;
/* size of buffer descriptors */
size = add_size(size, mul_size(NBuffers, sizeof(BufferDesc)));
/* size of data pages */
size = add_size(size, mul_size(NBuffers, BLCKSZ));
/* size of stuff controlled by freelist.c */
size = add_size(size, StrategyShmemSize());
return size;
}
| void InitBufferPool | ( | void | ) |
Definition at line 73 of file buf_init.c.
References Assert, buf, sbufdesc::buf_hdr_lock, sbufdesc::buf_id, BufferBlocks, CLEAR_BUFFERTAG, sbufdesc::content_lock, sbufdesc::flags, sbufdesc::freeNext, i, sbufdesc::io_in_progress_lock, LWLockAssign(), NBuffers, sbufdesc::refcount, ShmemInitStruct(), SpinLockInit, StrategyInitialize(), sbufdesc::tag, sbufdesc::usage_count, and sbufdesc::wait_backend_pid.
Referenced by CreateSharedMemoryAndSemaphores().
{
bool foundBufs,
foundDescs;
BufferDescriptors = (BufferDesc *)
ShmemInitStruct("Buffer Descriptors",
NBuffers * sizeof(BufferDesc), &foundDescs);
BufferBlocks = (char *)
ShmemInitStruct("Buffer Blocks",
NBuffers * (Size) BLCKSZ, &foundBufs);
if (foundDescs || foundBufs)
{
/* both should be present or neither */
Assert(foundDescs && foundBufs);
/* note: this path is only taken in EXEC_BACKEND case */
}
else
{
BufferDesc *buf;
int i;
buf = BufferDescriptors;
/*
* Initialize all the buffer headers.
*/
for (i = 0; i < NBuffers; buf++, i++)
{
CLEAR_BUFFERTAG(buf->tag);
buf->flags = 0;
buf->usage_count = 0;
buf->refcount = 0;
buf->wait_backend_pid = 0;
SpinLockInit(&buf->buf_hdr_lock);
buf->buf_id = i;
/*
* Initially link all the buffers together as unused. Subsequent
* management of this list is done by freelist.c.
*/
buf->freeNext = i + 1;
buf->io_in_progress_lock = LWLockAssign();
buf->content_lock = LWLockAssign();
}
/* Correct last entry of linked list */
BufferDescriptors[NBuffers - 1].freeNext = FREENEXT_END_OF_LIST;
}
/* Init other shared buffer-management stuff */
StrategyInitialize(!foundDescs);
}
| void InitBufferPoolAccess | ( | void | ) |
Definition at line 145 of file buf_init.c.
References calloc, ereport, errcode(), errmsg(), FATAL, NBuffers, and PrivateRefCount.
Referenced by BaseInit().
{
/*
* Allocate and zero local arrays of per-buffer info.
*/
PrivateRefCount = (int32 *) calloc(NBuffers, sizeof(int32));
if (!PrivateRefCount)
ereport(FATAL,
(errcode(ERRCODE_OUT_OF_MEMORY),
errmsg("out of memory")));
}
| char* BufferBlocks |
Definition at line 22 of file buf_init.c.
Referenced by InitBufferPool().
Definition at line 21 of file buf_init.c.
Referenced by BufferAlloc(), BufferGetBlockNumber(), BufferGetLSNAtomic(), BufferGetTag(), BufferIsPermanent(), BufferSync(), ConditionalLockBuffer(), ConditionalLockBufferForCleanup(), DropDatabaseBuffers(), DropRelFileNodeBuffers(), DropRelFileNodesAllBuffers(), FlushDatabaseBuffers(), FlushRelationBuffers(), GetBufferFromRing(), LockBuffer(), LockBufferForCleanup(), MarkBufferDirty(), MarkBufferDirtyHint(), pg_buffercache_pages(), PrintBufferLeakWarning(), ReleaseAndReadBuffer(), ReleaseBuffer(), StrategyGetBuffer(), and SyncOneBuffer().
Definition at line 23 of file buf_init.c.
Referenced by AtEOXact_Buffers(), AtProcExit_Buffers(), ConditionalLockBufferForCleanup(), HoldingBufferPinThatDelaysRecovery(), IncrBufferRefCount(), InitBufferPoolAccess(), InvalidateBuffer(), LockBufferForCleanup(), MarkBufferDirty(), MarkBufferDirtyHint(), PinBuffer(), PinBuffer_Locked(), PrintBufferLeakWarning(), ReleaseAndReadBuffer(), ReleaseBuffer(), and UnpinBuffer().
1.7.1