|
PostgreSQL Source Code git master
|
#include "postgres.h"#include "access/parallel.h"#include "executor/instrument.h"#include "pgstat.h"#include "storage/aio.h"#include "storage/buf_internals.h"#include "storage/bufmgr.h"#include "storage/fd.h"#include "utils/guc_hooks.h"#include "utils/memdebug.h"#include "utils/memutils.h"#include "utils/rel.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 42 of file localbuf.c.
Definition at line 1003 of file localbuf.c.
References CheckForLocalBufferLeaks().
Referenced by AtEOXact_Buffers().
Definition at line 1014 of file localbuf.c.
References CheckForLocalBufferLeaks().
Referenced by AtProcExit_Buffers().
Definition at line 877 of file localbuf.c.
References GUC_check_errdetail, newval, NLocBuffer, PGC_S_TEST, and source.
Definition at line 970 of file localbuf.c.
References Assert, b, DebugPrintBufferRefcount(), elog, fb(), i, LocalRefCount, NLocBuffer, pfree(), and WARNING.
Referenced by AtEOXact_LocalBuffers(), and AtProcExit_LocalBuffers().
| void DropRelationAllLocalBuffers | ( | RelFileLocator | rlocator | ) |
Definition at line 702 of file localbuf.c.
References BM_TAG_VALID, BufTagMatchesRelFileLocator(), fb(), GetLocalBufferDescriptor(), i, InvalidateLocalBuffer(), NLocBuffer, and pg_atomic_read_u64().
Referenced by DropRelationsAllBuffers().
| void DropRelationLocalBuffers | ( | RelFileLocator | rlocator, |
| ForkNumber * | forkNum, | ||
| int | nforks, | ||
| BlockNumber * | firstDelBlock | ||
| ) |
Definition at line 665 of file localbuf.c.
References BM_TAG_VALID, BufTagGetForkNum(), BufTagMatchesRelFileLocator(), fb(), GetLocalBufferDescriptor(), i, InvalidateLocalBuffer(), j, NLocBuffer, and pg_atomic_read_u64().
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 346 of file localbuf.c.
References Assert, BM_DIRTY, BM_JUST_DIRTIED, BM_TAG_VALID, BM_VALID, BMR_GET_SMGR, buf, BUF_USAGECOUNT_ONE, BufferDescriptorGetBuffer(), CurrentResourceOwner, ereport, errcode(), errmsg(), ERROR, fb(), GetLocalBufferDescriptor(), GetLocalVictimBuffer(), HASH_ENTER, hash_search(), i, InitBufferTag(), InitLocalBuffers(), InvalidBlockNumber, IOCONTEXT_NORMAL, IOOBJECT_TEMP_RELATION, IOOP_EXTEND, LimitAdditionalLocalPins(), BufferUsage::local_blks_written, LocalBufHash, LocalBufHdrGetBlock, MaxBlockNumber, MemSet, pg_atomic_read_u64(), pg_atomic_unlocked_write_u64(), pgBufferUsage, pgstat_count_io_op_time(), pgstat_prepare_io_time(), PinLocalBuffer(), relpath, ResourceOwnerEnlarge(), smgrnblocks(), smgrzeroextend(), StartLocalBufferIO(), str, track_io_timing, and UnpinLocalBuffer().
Referenced by ExtendBufferedRelCommon().
| void FlushLocalBuffer | ( | BufferDesc * | bufHdr, |
| SMgrRelation | reln | ||
| ) |
Definition at line 183 of file localbuf.c.
References Assert, BufferDescriptorGetBuffer(), BufTagGetForkNum(), BufTagGetRelFileLocator(), elog, ERROR, fb(), IOCONTEXT_NORMAL, IOOBJECT_TEMP_RELATION, IOOP_WRITE, BufferUsage::local_blks_written, LocalBufHdrGetBlock, LocalRefCount, MyProcNumber, PageSetChecksumInplace(), pgBufferUsage, pgstat_count_io_op_time(), pgstat_prepare_io_time(), smgropen(), smgrwrite(), StartLocalBufferIO(), TerminateLocalBufferIO(), and track_io_timing.
Referenced by FlushRelationBuffers(), GetLocalVictimBuffer(), and invalidate_rel_block().
Definition at line 315 of file localbuf.c.
References Assert, NLocalPinnedBuffers, and num_temp_buffers.
Referenced by read_stream_start_pending_read().
Definition at line 901 of file localbuf.c.
References ALLOCSET_DEFAULT_SIZES, AllocSetContextCreate, Assert, fb(), Max, MaxAllocSize, MemoryContextAllocAligned(), Min, NLocBuffer, PG_IO_ALIGN_SIZE, TopMemoryContext, and VALGRIND_MAKE_MEM_DEFINED.
Referenced by GetLocalVictimBuffer().
Definition at line 307 of file localbuf.c.
References num_temp_buffers.
Referenced by read_stream_begin_impl().
Definition at line 224 of file localbuf.c.
References BM_DIRTY, BM_TAG_VALID, BUF_STATE_GET_REFCOUNT, BUF_STATE_GET_USAGECOUNT, BUF_USAGECOUNT_ONE, BufferDescriptorGetBuffer(), CurrentResourceOwner, ereport, errcode(), errmsg(), ERROR, fb(), FlushLocalBuffer(), GetLocalBufferDescriptor(), GetLocalBufferStorage(), InvalidateLocalBuffer(), IOCONTEXT_NORMAL, IOOBJECT_TEMP_RELATION, IOOP_EVICT, LocalBufHdrGetBlock, LocalRefCount, nextFreeLocalBufId, NLocBuffer, pg_atomic_read_u64(), pg_atomic_unlocked_write_u64(), pgstat_count_io_op(), PinLocalBuffer(), and ResourceOwnerEnlarge().
Referenced by ExtendBufferedRelLocal(), and LocalBufferAlloc().
Definition at line 728 of file localbuf.c.
References buf, calloc, elog, HASHCTL::entrysize, ereport, errcode(), errmsg(), ERROR, FATAL, fb(), GetLocalBufferDescriptor(), HASH_BLOBS, hash_create(), HASH_ELEM, i, IsParallelWorker, HASHCTL::keysize, LocalBufferBlockPointers, LocalBufferDescriptors, LocalBufHash, LocalRefCount, nextFreeLocalBufId, NLocBuffer, num_temp_buffers, and pgaio_wref_clear().
Referenced by ExtendBufferedRelLocal(), LocalBufferAlloc(), and PrefetchLocalBuffer().
| void InvalidateLocalBuffer | ( | BufferDesc * | bufHdr, |
| bool | check_unreferenced | ||
| ) |
Definition at line 605 of file localbuf.c.
References Assert, BUF_STATE_GET_REFCOUNT, BufferDescriptorGetBuffer(), BufTagGetForkNum(), BufTagGetRelFileLocator(), ClearBufferTag(), elog, ERROR, fb(), HASH_REMOVE, hash_search(), LocalBufHash, LocalRefCount, MyProcNumber, pg_atomic_read_u64(), pg_atomic_unlocked_write_u64(), pgaio_wref_valid(), pgaio_wref_wait(), and relpathbackend.
Referenced by DropRelationAllLocalBuffers(), DropRelationLocalBuffers(), GetLocalVictimBuffer(), invalidate_rel_block(), and modify_rel_block().
Definition at line 323 of file localbuf.c.
References fb(), NLocalPinnedBuffers, and num_temp_buffers.
Referenced by ExtendBufferedRelLocal().
| BufferDesc * LocalBufferAlloc | ( | SMgrRelation | smgr, |
| ForkNumber | forkNum, | ||
| BlockNumber | blockNum, | ||
| bool * | foundPtr | ||
| ) |
Definition at line 119 of file localbuf.c.
References Assert, BM_TAG_VALID, BUF_FLAG_MASK, BUF_USAGECOUNT_MASK, BUF_USAGECOUNT_ONE, BufferTagsEqual(), CurrentResourceOwner, elog, ERROR, fb(), GetLocalBufferDescriptor(), GetLocalVictimBuffer(), HASH_ENTER, HASH_FIND, hash_search(), InitBufferTag(), InitLocalBuffers(), LocalBufHash, RelFileLocatorBackend::locator, pg_atomic_read_u64(), pg_atomic_unlocked_write_u64(), PinLocalBuffer(), ResourceOwnerEnlarge(), and SMgrRelationData::smgr_rlocator.
Referenced by PinBufferForBlock().
Definition at line 491 of file localbuf.c.
References Assert, BM_DIRTY, BufferIsLocal, fb(), fprintf, GetLocalBufferDescriptor(), BufferUsage::local_blks_dirtied, LocalRefCount, pg_atomic_read_u64(), pg_atomic_unlocked_write_u64(), and pgBufferUsage.
Referenced by MarkBufferDirty(), and MarkBufferDirtyHint().
| bool PinLocalBuffer | ( | BufferDesc * | buf_hdr, |
| bool | adjust_usagecount | ||
| ) |
Definition at line 805 of file localbuf.c.
References BM_MAX_USAGE_COUNT, BM_VALID, BUF_REFCOUNT_ONE, BUF_STATE_GET_USAGECOUNT, BUF_USAGECOUNT_ONE, BufferDescriptorGetBuffer(), CurrentResourceOwner, fb(), LocalBufHdrGetBlock, LocalRefCount, NLocalPinnedBuffers, pg_atomic_read_u64(), pg_atomic_unlocked_write_u64(), ResourceOwnerRememberBuffer(), and VALGRIND_MAKE_MEM_DEFINED.
Referenced by ExtendBufferedRelLocal(), FlushRelationBuffers(), GetLocalVictimBuffer(), LocalBufferAlloc(), and ReadRecentBuffer().
| PrefetchBufferResult PrefetchLocalBuffer | ( | SMgrRelation | smgr, |
| ForkNumber | forkNum, | ||
| BlockNumber | blockNum | ||
| ) |
Definition at line 72 of file localbuf.c.
References fb(), HASH_FIND, hash_search(), 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().
| bool StartLocalBufferIO | ( | BufferDesc * | bufHdr, |
| bool | forInput, | ||
| bool | nowait | ||
| ) |
Definition at line 523 of file localbuf.c.
References BM_DIRTY, BM_VALID, fb(), pg_atomic_read_u64(), pgaio_wref_valid(), and pgaio_wref_wait().
Referenced by buffer_call_start_io(), ExtendBufferedRelLocal(), FlushLocalBuffer(), read_rel_block_ll(), ReadBuffersCanStartIOOnce(), and ZeroAndLockBuffer().
| void TerminateLocalBufferIO | ( | BufferDesc * | bufHdr, |
| bool | clear_dirty, | ||
| uint64 | set_flag_bits, | ||
| bool | release_aio | ||
| ) |
Definition at line 562 of file localbuf.c.
References Assert, BUF_REFCOUNT_ONE, BUF_STATE_GET_REFCOUNT, fb(), pg_atomic_read_u64(), pg_atomic_unlocked_write_u64(), and pgaio_wref_clear().
Referenced by buffer_call_terminate_io(), buffer_readv_complete_one(), FlushLocalBuffer(), and ZeroAndLockBuffer().
Definition at line 841 of file localbuf.c.
References CurrentResourceOwner, ResourceOwnerForgetBuffer(), and UnpinLocalBufferNoOwner().
Referenced by ExtendBufferedRelLocal(), FlushRelationBuffers(), ReleaseAndReadBuffer(), and ReleaseBuffer().
Definition at line 848 of file localbuf.c.
References Assert, BUF_REFCOUNT_ONE, BUF_STATE_GET_REFCOUNT, BufferIsLocal, fb(), GetLocalBufferDescriptor(), LocalBufHdrGetBlock, LocalRefCount, NLocalPinnedBuffers, pg_atomic_read_u64(), pg_atomic_unlocked_write_u64(), and VALGRIND_MAKE_MEM_NOACCESS.
Referenced by ResOwnerReleaseBuffer(), and UnpinLocalBuffer().
Definition at line 48 of file localbuf.c.
Referenced by BufferGetBlock(), and InitLocalBuffers().
| BufferDesc* LocalBufferDescriptors = NULL |
Definition at line 47 of file localbuf.c.
Referenced by GetLocalBufferDescriptor(), and InitLocalBuffers().
Definition at line 53 of file localbuf.c.
Referenced by ExtendBufferedRelLocal(), InitLocalBuffers(), InvalidateLocalBuffer(), LocalBufferAlloc(), and PrefetchLocalBuffer().
Definition at line 49 of file localbuf.c.
Referenced by CheckBufferIsPinnedOnce(), CheckForLocalBufferLeaks(), ConditionalLockBufferForCleanup(), DebugPrintBufferRefcount(), FlushLocalBuffer(), GetLocalVictimBuffer(), IncrBufferRefCount(), InitLocalBuffers(), InvalidateLocalBuffer(), IsBufferCleanupOK(), MarkLocalBufferDirty(), PinLocalBuffer(), and UnpinLocalBufferNoOwner().
|
static |
Definition at line 51 of file localbuf.c.
Referenced by GetLocalVictimBuffer(), and InitLocalBuffers().
|
static |
Definition at line 56 of file localbuf.c.
Referenced by GetAdditionalLocalPinLimit(), LimitAdditionalLocalPins(), PinLocalBuffer(), and UnpinLocalBufferNoOwner().
| int NLocBuffer = 0 |
Definition at line 45 of file localbuf.c.
Referenced by BufferIsValid(), check_temp_buffers(), CheckForLocalBufferLeaks(), DropRelationAllLocalBuffers(), DropRelationLocalBuffers(), FlushRelationBuffers(), GetLocalBufferStorage(), GetLocalVictimBuffer(), hashbuild(), and InitLocalBuffers().