|
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 1019 of file localbuf.c.
References CheckForLocalBufferLeaks().
Referenced by AtEOXact_Buffers().
Definition at line 1030 of file localbuf.c.
References CheckForLocalBufferLeaks().
Referenced by AtProcExit_Buffers().
Definition at line 893 of file localbuf.c.
References GUC_check_errdetail, newval, NLocBuffer, PGC_S_TEST, and source.
Definition at line 986 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 718 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 681 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 347 of file localbuf.c.
References Assert, BM_DIRTY, 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, BUFFER_IO_READY_FOR_IO, BufferDescriptorGetBuffer(), BufTagGetForkNum(), BufTagGetRelFileLocator(), elog, ERROR, fb(), IOCONTEXT_NORMAL, IOOBJECT_TEMP_RELATION, IOOP_WRITE, BufferUsage::local_blks_written, LocalBufHdrGetBlock, LocalRefCount, MyProcNumber, PageSetChecksum(), pgBufferUsage, pgstat_count_io_op_time(), pgstat_prepare_io_time(), smgropen(), smgrwrite(), StartLocalBufferIO(), TerminateLocalBufferIO(), and track_io_timing.
Referenced by FlushRelationBuffers(), GetLocalVictimBuffer(), and invalidate_one_block().
Definition at line 316 of file localbuf.c.
References Assert, NLocalPinnedBuffers, and num_temp_buffers.
Referenced by read_stream_start_pending_read().
Definition at line 917 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 308 of file localbuf.c.
References num_temp_buffers.
Referenced by read_stream_begin_impl().
Definition at line 225 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 744 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 621 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_one_block(), and modify_rel_block().
Definition at line 324 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 492 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 BufferSetHintBits16(), MarkBufferDirty(), and MarkBufferDirtyHint().
| bool PinLocalBuffer | ( | BufferDesc * | buf_hdr, |
| bool | adjust_usagecount | ||
| ) |
Definition at line 821 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(), InitLocalBuffers(), InvalidBuffer, IO_DIRECT_DATA, io_direct_flags, LocalBufHash, RelFileLocatorBackend::locator, result, SMgrRelationData::smgr_rlocator, and smgrprefetch().
Referenced by PrefetchBuffer().
| StartBufferIOResult StartLocalBufferIO | ( | BufferDesc * | bufHdr, |
| bool | forInput, | ||
| bool | wait, | ||
| PgAioWaitRef * | io_wref | ||
| ) |
Definition at line 524 of file localbuf.c.
References Assert, BM_DIRTY, BM_VALID, BUFFER_IO_ALREADY_DONE, BUFFER_IO_IN_PROGRESS, BUFFER_IO_READY_FOR_IO, fb(), pg_atomic_read_u64(), pgaio_have_staged(), pgaio_wref_valid(), and pgaio_wref_wait().
Referenced by buffer_call_start_io(), ExtendBufferedRelLocal(), FlushLocalBuffer(), read_rel_block_ll(), StartBufferIO(), and ZeroAndLockBuffer().
| void TerminateLocalBufferIO | ( | BufferDesc * | bufHdr, |
| bool | clear_dirty, | ||
| uint64 | set_flag_bits, | ||
| bool | release_aio | ||
| ) |
Definition at line 578 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 857 of file localbuf.c.
References CurrentResourceOwner, ResourceOwnerForgetBuffer(), and UnpinLocalBufferNoOwner().
Referenced by ExtendBufferedRelLocal(), FlushRelationBuffers(), ReleaseAndReadBuffer(), ReleaseBuffer(), and UnlockReleaseBuffer().
Definition at line 864 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().