PostgreSQL Source Code
git master
|
#include "postgres.h"
#include "access/parallel.h"
#include "executor/instrument.h"
#include "pgstat.h"
#include "storage/buf_internals.h"
#include "storage/bufmgr.h"
#include "storage/fd.h"
#include "utils/guc_hooks.h"
#include "utils/memutils.h"
#include "utils/resowner.h"
Go to the source code of this file.
Data Structures | |
struct | LocalBufferLookupEnt |
Macros | |
#define | LocalBufHdrGetBlock(bufHdr) LocalBufferBlockPointers[-((bufHdr)->buf_id + 2)] |
Variables | |
int | NLocBuffer = 0 |
BufferDesc * | LocalBufferDescriptors = NULL |
Block * | LocalBufferBlockPointers = NULL |
int32 * | LocalRefCount = NULL |
static int | nextFreeLocalBufId = 0 |
static HTAB * | LocalBufHash = NULL |
static int | NLocalPinnedBuffers = 0 |
#define LocalBufHdrGetBlock | ( | bufHdr | ) | LocalBufferBlockPointers[-((bufHdr)->buf_id + 2)] |
Definition at line 39 of file localbuf.c.
void AtEOXact_LocalBuffers | ( | bool | isCommit | ) |
Definition at line 819 of file localbuf.c.
References CheckForLocalBufferLeaks().
Referenced by AtEOXact_Buffers().
void AtProcExit_LocalBuffers | ( | void | ) |
Definition at line 830 of file localbuf.c.
References CheckForLocalBufferLeaks().
Referenced by AtProcExit_Buffers().
bool check_temp_buffers | ( | int * | newval, |
void ** | extra, | ||
GucSource | source | ||
) |
Definition at line 704 of file localbuf.c.
References GUC_check_errdetail, newval, NLocBuffer, PGC_S_TEST, and source.
|
static |
Definition at line 786 of file localbuf.c.
References Assert, b, DebugPrintBufferRefcount(), elog, i, LocalRefCount, NLocBuffer, pfree(), and WARNING.
Referenced by AtEOXact_LocalBuffers(), and AtProcExit_LocalBuffers().
void DropRelationAllLocalBuffers | ( | RelFileLocator | rlocator | ) |
Definition at line 537 of file localbuf.c.
References buftag::blockNum, BM_TAG_VALID, BUF_FLAG_MASK, BUF_USAGECOUNT_MASK, BufTagGetForkNum(), BufTagGetRelFileLocator(), BufTagMatchesRelFileLocator(), ClearBufferTag(), elog, ERROR, GetLocalBufferDescriptor(), HASH_REMOVE, hash_search(), i, LocalBufHash, LocalRefCount, MyProcNumber, NLocBuffer, pg_atomic_read_u32(), pg_atomic_unlocked_write_u32(), relpathbackend, BufferDesc::state, and BufferDesc::tag.
Referenced by DropRelationsAllBuffers().
void DropRelationLocalBuffers | ( | RelFileLocator | rlocator, |
ForkNumber | forkNum, | ||
BlockNumber | firstDelBlock | ||
) |
Definition at line 489 of file localbuf.c.
References buftag::blockNum, BM_TAG_VALID, BUF_FLAG_MASK, BUF_USAGECOUNT_MASK, BufTagGetForkNum(), BufTagGetRelFileLocator(), BufTagMatchesRelFileLocator(), ClearBufferTag(), elog, ERROR, GetLocalBufferDescriptor(), HASH_REMOVE, hash_search(), i, LocalBufHash, LocalRefCount, MyProcNumber, NLocBuffer, pg_atomic_read_u32(), pg_atomic_unlocked_write_u32(), relpathbackend, BufferDesc::state, and BufferDesc::tag.
Referenced by DropRelationBuffers().
BlockNumber ExtendBufferedRelLocal | ( | BufferManagerRelation | bmr, |
ForkNumber | fork, | ||
uint32 | flags, | ||
uint32 | extend_by, | ||
BlockNumber | extend_upto, | ||
Buffer * | buffers, | ||
uint32 * | extended_by | ||
) |
Definition at line 313 of file localbuf.c.
References Assert, BM_DIRTY, BM_JUST_DIRTIED, BM_TAG_VALID, BM_VALID, buf, BUF_USAGECOUNT_ONE, BufferDescriptorGetBuffer(), CurrentResourceOwner, ereport, errcode(), errmsg(), ERROR, GetLocalBufferDescriptor(), GetLocalVictimBuffer(), HASH_ENTER, hash_search(), i, LocalBufferLookupEnt::id, InitBufferTag(), InitLocalBuffers(), InvalidBlockNumber, IOCONTEXT_NORMAL, IOOBJECT_TEMP_RELATION, IOOP_EXTEND, LimitAdditionalLocalPins(), BufferUsage::local_blks_written, LocalBufHash, LocalBufHdrGetBlock, RelFileLocatorBackend::locator, MaxBlockNumber, MemSet, pg_atomic_read_u32(), pg_atomic_unlocked_write_u32(), pgBufferUsage, pgstat_count_io_op_time(), pgstat_prepare_io_time(), PinLocalBuffer(), relpath, ResourceOwnerEnlarge(), BufferManagerRelation::smgr, SMgrRelationData::smgr_rlocator, smgrnblocks(), smgrzeroextend(), BufferDesc::state, BufferDesc::tag, track_io_timing, and UnpinLocalBuffer().
Referenced by ExtendBufferedRelCommon().
|
static |
Definition at line 728 of file localbuf.c.
References ALLOCSET_DEFAULT_SIZES, AllocSetContextCreate, Assert, Max, MaxAllocSize, MemoryContextAlloc(), Min, NLocBuffer, PG_IO_ALIGN_SIZE, TopMemoryContext, and TYPEALIGN.
Referenced by GetLocalVictimBuffer().
|
static |
Definition at line 177 of file localbuf.c.
References buftag::blockNum, BM_DIRTY, BM_TAG_VALID, BUF_FLAG_MASK, BUF_STATE_GET_USAGECOUNT, BUF_USAGECOUNT_MASK, BUF_USAGECOUNT_ONE, BufferDescriptorGetBuffer(), BufTagGetForkNum(), BufTagGetRelFileLocator(), ClearBufferTag(), CurrentResourceOwner, elog, ereport, errcode(), errmsg(), ERROR, GetLocalBufferDescriptor(), GetLocalBufferStorage(), HASH_REMOVE, hash_search(), IOCONTEXT_NORMAL, IOOBJECT_TEMP_RELATION, IOOP_EVICT, IOOP_WRITE, BufferUsage::local_blks_written, LocalBufHash, LocalBufHdrGetBlock, LocalRefCount, MyProcNumber, nextFreeLocalBufId, NLocBuffer, PageSetChecksumInplace(), pg_atomic_read_u32(), pg_atomic_unlocked_write_u32(), pgBufferUsage, pgstat_count_io_op(), pgstat_count_io_op_time(), pgstat_prepare_io_time(), PinLocalBuffer(), ResourceOwnerEnlarge(), smgropen(), smgrwrite(), BufferDesc::state, BufferDesc::tag, and track_io_timing.
Referenced by ExtendBufferedRelLocal(), and LocalBufferAlloc().
|
static |
Definition at line 580 of file localbuf.c.
References buf, calloc, elog, HASHCTL::entrysize, ereport, errcode(), errmsg(), ERROR, FATAL, GetLocalBufferDescriptor(), HASH_BLOBS, hash_create(), HASH_ELEM, i, IsParallelWorker, HASHCTL::keysize, LocalBufferBlockPointers, LocalBufferDescriptors, LocalBufHash, LocalRefCount, nextFreeLocalBufId, NLocBuffer, and num_temp_buffers.
Referenced by ExtendBufferedRelLocal(), LocalBufferAlloc(), and PrefetchLocalBuffer().
void LimitAdditionalLocalPins | ( | uint32 * | additional_pins | ) |
Definition at line 290 of file localbuf.c.
References NLocalPinnedBuffers, and num_temp_buffers.
Referenced by ExtendBufferedRelLocal(), and read_stream_begin_impl().
BufferDesc* LocalBufferAlloc | ( | SMgrRelation | smgr, |
ForkNumber | forkNum, | ||
BlockNumber | blockNum, | ||
bool * | foundPtr | ||
) |
Definition at line 116 of file localbuf.c.
References Assert, BM_TAG_VALID, BUF_FLAG_MASK, BUF_USAGECOUNT_MASK, BUF_USAGECOUNT_ONE, BufferTagsEqual(), CurrentResourceOwner, elog, ERROR, GetLocalBufferDescriptor(), GetLocalVictimBuffer(), HASH_ENTER, HASH_FIND, hash_search(), LocalBufferLookupEnt::id, InitBufferTag(), InitLocalBuffers(), LocalBufHash, RelFileLocatorBackend::locator, pg_atomic_read_u32(), pg_atomic_unlocked_write_u32(), PinLocalBuffer(), ResourceOwnerEnlarge(), SMgrRelationData::smgr_rlocator, BufferDesc::state, and BufferDesc::tag.
Referenced by PinBufferForBlock().
void MarkLocalBufferDirty | ( | Buffer | buffer | ) |
Definition at line 449 of file localbuf.c.
References Assert, BM_DIRTY, BufferIsLocal, fprintf, GetLocalBufferDescriptor(), BufferUsage::local_blks_dirtied, LocalRefCount, pg_atomic_read_u32(), pg_atomic_unlocked_write_u32(), pgBufferUsage, and BufferDesc::state.
Referenced by MarkBufferDirty(), and MarkBufferDirtyHint().
bool PinLocalBuffer | ( | BufferDesc * | buf_hdr, |
bool | adjust_usagecount | ||
) |
Definition at line 655 of file localbuf.c.
References BM_MAX_USAGE_COUNT, BM_VALID, BUF_STATE_GET_USAGECOUNT, BUF_USAGECOUNT_ONE, BufferDescriptorGetBuffer(), CurrentResourceOwner, LocalRefCount, NLocalPinnedBuffers, pg_atomic_read_u32(), pg_atomic_unlocked_write_u32(), ResourceOwnerRememberBuffer(), and BufferDesc::state.
Referenced by ExtendBufferedRelLocal(), GetLocalVictimBuffer(), LocalBufferAlloc(), and ReadRecentBuffer().
PrefetchBufferResult PrefetchLocalBuffer | ( | SMgrRelation | smgr, |
ForkNumber | forkNum, | ||
BlockNumber | blockNum | ||
) |
Definition at line 69 of file localbuf.c.
References HASH_FIND, hash_search(), LocalBufferLookupEnt::id, InitBufferTag(), PrefetchBufferResult::initiated_io, InitLocalBuffers(), InvalidBuffer, IO_DIRECT_DATA, io_direct_flags, LocalBufHash, RelFileLocatorBackend::locator, PrefetchBufferResult::recent_buffer, SMgrRelationData::smgr_rlocator, and smgrprefetch().
Referenced by PrefetchBuffer().
void UnpinLocalBuffer | ( | Buffer | buffer | ) |
Definition at line 681 of file localbuf.c.
References CurrentResourceOwner, ResourceOwnerForgetBuffer(), and UnpinLocalBufferNoOwner().
Referenced by ExtendBufferedRelLocal(), ReleaseAndReadBuffer(), and ReleaseBuffer().
void UnpinLocalBufferNoOwner | ( | Buffer | buffer | ) |
Definition at line 688 of file localbuf.c.
References Assert, BufferIsLocal, LocalRefCount, and NLocalPinnedBuffers.
Referenced by ResOwnerReleaseBufferPin(), and UnpinLocalBuffer().
Block* LocalBufferBlockPointers = NULL |
Definition at line 45 of file localbuf.c.
Referenced by BufferGetBlock(), and InitLocalBuffers().
BufferDesc* LocalBufferDescriptors = NULL |
Definition at line 44 of file localbuf.c.
Referenced by GetLocalBufferDescriptor(), and InitLocalBuffers().
|
static |
Definition at line 50 of file localbuf.c.
Referenced by DropRelationAllLocalBuffers(), DropRelationLocalBuffers(), ExtendBufferedRelLocal(), GetLocalVictimBuffer(), InitLocalBuffers(), LocalBufferAlloc(), and PrefetchLocalBuffer().
int32* LocalRefCount = NULL |
Definition at line 46 of file localbuf.c.
Referenced by CheckBufferIsPinnedOnce(), CheckForLocalBufferLeaks(), ConditionalLockBufferForCleanup(), DebugPrintBufferRefcount(), DropRelationAllLocalBuffers(), DropRelationLocalBuffers(), GetLocalVictimBuffer(), IncrBufferRefCount(), InitLocalBuffers(), IsBufferCleanupOK(), MarkLocalBufferDirty(), PinLocalBuffer(), and UnpinLocalBufferNoOwner().
|
static |
Definition at line 48 of file localbuf.c.
Referenced by GetLocalVictimBuffer(), and InitLocalBuffers().
|
static |
Definition at line 53 of file localbuf.c.
Referenced by LimitAdditionalLocalPins(), PinLocalBuffer(), and UnpinLocalBufferNoOwner().
int NLocBuffer = 0 |
Definition at line 42 of file localbuf.c.
Referenced by BufferIsValid(), check_temp_buffers(), CheckForLocalBufferLeaks(), DropRelationAllLocalBuffers(), DropRelationLocalBuffers(), FlushRelationBuffers(), GetLocalBufferStorage(), GetLocalVictimBuffer(), hashbuild(), and InitLocalBuffers().