PostgreSQL Source Code
git master
|
#include "pgstat.h"
#include "port/atomics.h"
#include "storage/buf.h"
#include "storage/bufmgr.h"
#include "storage/condition_variable.h"
#include "storage/lwlock.h"
#include "storage/shmem.h"
#include "storage/smgr.h"
#include "storage/spin.h"
#include "utils/relcache.h"
#include "utils/resowner.h"
Go to the source code of this file.
Data Structures | |
struct | buftag |
struct | BufferDesc |
union | BufferDescPadded |
struct | PendingWriteback |
struct | WritebackContext |
struct | CkptSortItem |
Macros | |
#define | BUF_REFCOUNT_ONE 1 |
#define | BUF_REFCOUNT_MASK ((1U << 18) - 1) |
#define | BUF_USAGECOUNT_MASK 0x003C0000U |
#define | BUF_USAGECOUNT_ONE (1U << 18) |
#define | BUF_USAGECOUNT_SHIFT 18 |
#define | BUF_FLAG_MASK 0xFFC00000U |
#define | BUF_STATE_GET_REFCOUNT(state) ((state) & BUF_REFCOUNT_MASK) |
#define | BUF_STATE_GET_USAGECOUNT(state) (((state) & BUF_USAGECOUNT_MASK) >> BUF_USAGECOUNT_SHIFT) |
#define | BM_LOCKED (1U << 22) /* buffer header is locked */ |
#define | BM_DIRTY (1U << 23) /* data needs writing */ |
#define | BM_VALID (1U << 24) /* data is valid */ |
#define | BM_TAG_VALID (1U << 25) /* tag is assigned */ |
#define | BM_IO_IN_PROGRESS (1U << 26) /* read or write in progress */ |
#define | BM_IO_ERROR (1U << 27) /* previous I/O failed */ |
#define | BM_JUST_DIRTIED (1U << 28) /* dirtied since write started */ |
#define | BM_PIN_COUNT_WAITER (1U << 29) /* have waiter for sole pin */ |
#define | BM_CHECKPOINT_NEEDED (1U << 30) /* must write for checkpoint */ |
#define | BM_PERMANENT |
#define | BM_MAX_USAGE_COUNT 5 |
#define | BUFFERDESC_PAD_TO_SIZE (SIZEOF_VOID_P == 8 ? 64 : 1) |
#define | FREENEXT_END_OF_LIST (-1) |
#define | FREENEXT_NOT_IN_LIST (-2) |
Typedefs | |
typedef struct buftag | BufferTag |
typedef struct BufferDesc | BufferDesc |
typedef union BufferDescPadded | BufferDescPadded |
typedef struct PendingWriteback | PendingWriteback |
typedef struct WritebackContext | WritebackContext |
typedef struct CkptSortItem | CkptSortItem |
Definition at line 67 of file buf_internals.h.
#define BM_DIRTY (1U << 23) /* data needs writing */ |
Definition at line 60 of file buf_internals.h.
#define BM_IO_ERROR (1U << 27) /* previous I/O failed */ |
Definition at line 64 of file buf_internals.h.
Definition at line 63 of file buf_internals.h.
#define BM_JUST_DIRTIED (1U << 28) /* dirtied since write started */ |
Definition at line 65 of file buf_internals.h.
#define BM_LOCKED (1U << 22) /* buffer header is locked */ |
Definition at line 59 of file buf_internals.h.
#define BM_MAX_USAGE_COUNT 5 |
Definition at line 77 of file buf_internals.h.
#define BM_PERMANENT |
Definition at line 68 of file buf_internals.h.
#define BM_PIN_COUNT_WAITER (1U << 29) /* have waiter for sole pin */ |
Definition at line 66 of file buf_internals.h.
#define BM_TAG_VALID (1U << 25) /* tag is assigned */ |
Definition at line 62 of file buf_internals.h.
#define BM_VALID (1U << 24) /* data is valid */ |
Definition at line 61 of file buf_internals.h.
#define BUF_FLAG_MASK 0xFFC00000U |
Definition at line 47 of file buf_internals.h.
#define BUF_REFCOUNT_MASK ((1U << 18) - 1) |
Definition at line 43 of file buf_internals.h.
#define BUF_REFCOUNT_ONE 1 |
Definition at line 42 of file buf_internals.h.
#define BUF_STATE_GET_REFCOUNT | ( | state | ) | ((state) & BUF_REFCOUNT_MASK) |
Definition at line 50 of file buf_internals.h.
#define BUF_STATE_GET_USAGECOUNT | ( | state | ) | (((state) & BUF_USAGECOUNT_MASK) >> BUF_USAGECOUNT_SHIFT) |
Definition at line 51 of file buf_internals.h.
#define BUF_USAGECOUNT_MASK 0x003C0000U |
Definition at line 44 of file buf_internals.h.
#define BUF_USAGECOUNT_ONE (1U << 18) |
Definition at line 45 of file buf_internals.h.
#define BUF_USAGECOUNT_SHIFT 18 |
Definition at line 46 of file buf_internals.h.
#define BUFFERDESC_PAD_TO_SIZE (SIZEOF_VOID_P == 8 ? 64 : 1) |
Definition at line 276 of file buf_internals.h.
#define FREENEXT_END_OF_LIST (-1) |
Definition at line 350 of file buf_internals.h.
#define FREENEXT_NOT_IN_LIST (-2) |
Definition at line 351 of file buf_internals.h.
typedef struct BufferDesc BufferDesc |
typedef union BufferDescPadded BufferDescPadded |
typedef struct CkptSortItem CkptSortItem |
typedef struct PendingWriteback PendingWriteback |
typedef struct WritebackContext WritebackContext |
void AtEOXact_LocalBuffers | ( | bool | isCommit | ) |
Definition at line 819 of file localbuf.c.
References CheckForLocalBufferLeaks().
Referenced by AtEOXact_Buffers().
|
inlinestatic |
Definition at line 329 of file buf_internals.h.
References BufferDesc::buf_id.
Referenced by AddBufferToRing(), ExtendBufferedRelLocal(), ExtendBufferedRelShared(), GetLocalVictimBuffer(), GetVictimBuffer(), InvalidateBuffer(), InvalidateVictimBuffer(), LockBufHdr(), pg_buffercache_pages(), PinBuffer(), PinBuffer_Locked(), PinBufferForBlock(), PinLocalBuffer(), StartBufferIO(), StrategyRejectBuffer(), TerminateBufferIO(), UnpinBuffer(), and UnpinBufferNoOwner().
|
inlinestatic |
Definition at line 341 of file buf_internals.h.
References BufferDesc::content_lock.
Referenced by BufferIsDirty(), BufferIsExclusiveLocked(), BufferManagerShmemInit(), ConditionalLockBuffer(), EvictUnpinnedBuffer(), ExtendBufferedRelShared(), FlushDatabaseBuffers(), FlushOneBuffer(), FlushRelationBuffers(), FlushRelationsAllBuffers(), GetVictimBuffer(), IsBufferCleanupOK(), LockBuffer(), MarkBufferDirty(), MarkBufferDirtyHint(), SyncOneBuffer(), UnpinBufferNoOwner(), and ZeroAndLockBuffer().
|
inlinestatic |
Definition at line 335 of file buf_internals.h.
References BufferDesc::buf_id, and BufferIOCVArray.
Referenced by BufferManagerShmemInit(), TerminateBufferIO(), and WaitIO().
Definition at line 152 of file buf_internals.h.
References buftag::blockNum, buftag::dbOid, buftag::forkNum, buftag::relNumber, and buftag::spcOid.
Referenced by InvalidateBuffer(), InvalidateVictimBuffer(), LocalBufferAlloc(), and ReadRecentBuffer().
Definition at line 184 of file buf_internals.h.
References BUFFER_MAPPING_LWLOCK_OFFSET, BufTableHashPartition(), LWLockPadded::lock, and MainLWLockArray.
Referenced by BufferAlloc(), ExtendBufferedRelShared(), FindAndDropRelationBuffers(), InvalidateBuffer(), InvalidateVictimBuffer(), and PrefetchSharedBuffer().
Definition at line 191 of file buf_internals.h.
References BUFFER_MAPPING_LWLOCK_OFFSET, LWLockPadded::lock, and MainLWLockArray.
Definition at line 148 of file buf_table.c.
References elog, ERROR, HASH_REMOVE, hash_search_with_hash_value(), and SharedBufHash.
Referenced by InvalidateBuffer(), and InvalidateVictimBuffer().
Definition at line 78 of file buf_table.c.
References get_hash_value(), and SharedBufHash.
Referenced by BufferAlloc(), ExtendBufferedRelShared(), FindAndDropRelationBuffers(), InvalidateBuffer(), InvalidateVictimBuffer(), and PrefetchSharedBuffer().
Definition at line 178 of file buf_internals.h.
References NUM_BUFFER_PARTITIONS.
Referenced by BufMappingPartitionLock().
Definition at line 118 of file buf_table.c.
References Assert, buftag::blockNum, HASH_ENTER, hash_search_with_hash_value(), BufferLookupEnt::id, P_NEW, and SharedBufHash.
Referenced by BufferAlloc(), and ExtendBufferedRelShared().
Definition at line 90 of file buf_table.c.
References HASH_FIND, hash_search_with_hash_value(), BufferLookupEnt::id, and SharedBufHash.
Referenced by BufferAlloc(), FindAndDropRelationBuffers(), and PrefetchSharedBuffer().
Size BufTableShmemSize | ( | int | size | ) |
Definition at line 41 of file buf_table.c.
References hash_estimate_size(), and size.
Referenced by StrategyShmemSize().
|
inlinestatic |
Definition at line 107 of file buf_internals.h.
References buftag::forkNum.
Referenced by AbortBufferIO(), apw_dump_now(), BufferGetTag(), BufferSync(), buffertag_comparator(), DebugPrintBufferRefcount(), DropRelationAllLocalBuffers(), DropRelationBuffers(), DropRelationLocalBuffers(), FindAndDropRelationBuffers(), FlushBuffer(), FlushRelationBuffers(), GetLocalVictimBuffer(), IssuePendingWritebacks(), local_buffer_write_error_callback(), pg_buffercache_pages(), ReleaseAndReadBuffer(), and shared_buffer_write_error_callback().
|
inlinestatic |
Definition at line 121 of file buf_internals.h.
References BufTagGetRelNumber(), buftag::dbOid, RelFileLocator::dbOid, RelFileLocator::relNumber, buftag::spcOid, and RelFileLocator::spcOid.
Referenced by AbortBufferIO(), BufferGetTag(), buffertag_comparator(), DebugPrintBufferRefcount(), DropRelationAllLocalBuffers(), DropRelationLocalBuffers(), DropRelationsAllBuffers(), FlushBuffer(), FlushRelationsAllBuffers(), GetLocalVictimBuffer(), IssuePendingWritebacks(), local_buffer_write_error_callback(), MarkBufferDirtyHint(), and shared_buffer_write_error_callback().
|
inlinestatic |
Definition at line 101 of file buf_internals.h.
References buftag::relNumber.
Referenced by apw_dump_now(), BufferSync(), BufTagGetRelFileLocator(), BufTagMatchesRelFileLocator(), and pg_buffercache_pages().
|
inlinestatic |
Definition at line 162 of file buf_internals.h.
References BufTagGetRelNumber(), buftag::dbOid, RelFileLocator::dbOid, RelFileLocator::relNumber, buftag::spcOid, and RelFileLocator::spcOid.
Referenced by DropRelationAllLocalBuffers(), DropRelationBuffers(), DropRelationLocalBuffers(), DropRelationsAllBuffers(), FindAndDropRelationBuffers(), FlushRelationBuffers(), FlushRelationsAllBuffers(), and ReleaseAndReadBuffer().
|
inlinestatic |
Definition at line 113 of file buf_internals.h.
References buftag::forkNum, and buftag::relNumber.
Referenced by ClearBufferTag(), and InitBufferTag().
|
inlinestatic |
Definition at line 133 of file buf_internals.h.
References buftag::blockNum, BufTagSetRelForkDetails(), buftag::dbOid, InvalidBlockNumber, InvalidForkNumber, InvalidOid, InvalidRelFileNumber, and buftag::spcOid.
Referenced by BufferManagerShmemInit(), DropRelationAllLocalBuffers(), DropRelationLocalBuffers(), GetLocalVictimBuffer(), InvalidateBuffer(), and InvalidateVictimBuffer().
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().
|
inlinestatic |
Definition at line 317 of file buf_internals.h.
References BufferDescriptors.
Referenced by AbortBufferIO(), apw_dump_now(), BufferAlloc(), BufferGetBlockNumber(), BufferGetLSNAtomic(), BufferGetTag(), BufferIsDirty(), BufferIsExclusiveLocked(), BufferIsPermanent(), BufferManagerShmemInit(), BufferSync(), ConditionalLockBuffer(), ConditionalLockBufferForCleanup(), DebugPrintBufferRefcount(), DropDatabaseBuffers(), DropRelationBuffers(), DropRelationsAllBuffers(), EvictUnpinnedBuffer(), ExtendBufferedRelShared(), FindAndDropRelationBuffers(), FlushDatabaseBuffers(), FlushOneBuffer(), FlushRelationBuffers(), FlushRelationsAllBuffers(), GetBufferFromRing(), IsBufferCleanupOK(), LockBuffer(), LockBufferForCleanup(), MarkBufferDirty(), MarkBufferDirtyHint(), pg_buffercache_pages(), pg_buffercache_summary(), ReadRecentBuffer(), ReleaseAndReadBuffer(), ReleaseBuffer(), ResOwnerReleaseBufferPin(), StrategyGetBuffer(), SyncOneBuffer(), WaitReadBuffers(), WaitReadBuffersCanStartIO(), and ZeroAndLockBuffer().
|
inlinestatic |
Definition at line 323 of file buf_internals.h.
References LocalBufferDescriptors.
Referenced by BufferGetBlockNumber(), BufferGetTag(), BufferIsDirty(), BufferIsExclusiveLocked(), DebugPrintBufferRefcount(), DropRelationAllLocalBuffers(), DropRelationLocalBuffers(), ExtendBufferedRelLocal(), FlushRelationBuffers(), GetLocalVictimBuffer(), InitLocalBuffers(), LocalBufferAlloc(), MarkLocalBufferDirty(), ReadRecentBuffer(), ReleaseAndReadBuffer(), WaitReadBuffers(), WaitReadBuffersCanStartIO(), and ZeroAndLockBuffer().
bool have_free_buffer | ( | void | ) |
Definition at line 175 of file freelist.c.
References BufferStrategyControl::firstFreeBuffer, and StrategyControl.
Referenced by apw_load_buffers(), and autoprewarm_database_main().
|
inlinestatic |
Definition at line 142 of file buf_internals.h.
References buftag::blockNum, BufTagSetRelForkDetails(), buftag::dbOid, RelFileLocator::dbOid, RelFileLocator::relNumber, buftag::spcOid, and RelFileLocator::spcOid.
Referenced by BufferAlloc(), ExtendBufferedRelLocal(), ExtendBufferedRelShared(), FindAndDropRelationBuffers(), LocalBufferAlloc(), PrefetchLocalBuffer(), PrefetchSharedBuffer(), and ReadRecentBuffer().
void InitBufTable | ( | int | size | ) |
Definition at line 51 of file buf_table.c.
References HASHCTL::entrysize, HASH_BLOBS, HASH_ELEM, HASH_PARTITION, HASHCTL::keysize, NUM_BUFFER_PARTITIONS, HASHCTL::num_partitions, SharedBufHash, ShmemInitHash(), and size.
Referenced by StrategyInitialize().
IOContext IOContextForStrategy | ( | BufferAccessStrategy | strategy | ) |
Definition at line 758 of file freelist.c.
References BAS_BULKREAD, BAS_BULKWRITE, BAS_NORMAL, BAS_VACUUM, BufferAccessStrategyData::btype, elog, ERROR, IOCONTEXT_BULKREAD, IOCONTEXT_BULKWRITE, IOCONTEXT_NORMAL, IOCONTEXT_VACUUM, and pg_unreachable.
Referenced by ExtendBufferedRelShared(), PinBufferForBlock(), and WaitReadBuffers().
void IssuePendingWritebacks | ( | WritebackContext * | wb_context, |
IOContext | io_context | ||
) |
Definition at line 5965 of file bufmgr.c.
References buftag::blockNum, BufTagGetForkNum(), BufTagGetRelFileLocator(), cur, i, INVALID_PROC_NUMBER, IOOBJECT_RELATION, IOOP_WRITEBACK, next, WritebackContext::nr_pending, WritebackContext::pending_writebacks, pgstat_count_io_op_time(), pgstat_prepare_io_time(), RelFileLocatorEquals, smgropen(), smgrwriteback(), and track_io_timing.
Referenced by BufferSync(), and ScheduleBufferTagForWriteback().
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().
uint32 LockBufHdr | ( | BufferDesc * | desc | ) |
Definition at line 5761 of file bufmgr.c.
References Assert, BM_LOCKED, BufferDescriptorGetBuffer(), BufferIsLocal, finish_spin_delay(), init_local_spin_delay, perform_spin_delay(), pg_atomic_fetch_or_u32(), and BufferDesc::state.
Referenced by AbortBufferIO(), apw_dump_now(), BufferAlloc(), BufferGetLSNAtomic(), BufferSync(), ConditionalLockBufferForCleanup(), DropDatabaseBuffers(), DropRelationBuffers(), DropRelationsAllBuffers(), EvictUnpinnedBuffer(), ExtendBufferedRelShared(), FindAndDropRelationBuffers(), FlushBuffer(), FlushDatabaseBuffers(), FlushRelationBuffers(), FlushRelationsAllBuffers(), GetBufferFromRing(), GetVictimBuffer(), InvalidateBuffer(), InvalidateVictimBuffer(), IsBufferCleanupOK(), LockBufferForCleanup(), MarkBufferDirtyHint(), pg_buffercache_pages(), ReadRecentBuffer(), StartBufferIO(), StrategyGetBuffer(), SyncOneBuffer(), TerminateBufferIO(), UnlockBuffers(), UnpinBufferNoOwner(), and WaitIO().
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().
|
inlinestatic |
Definition at line 396 of file buf_internals.h.
References buffer_pin_resowner_desc, Int32GetDatum(), and ResourceOwnerForget().
Referenced by UnpinBuffer(), and UnpinLocalBuffer().
|
inlinestatic |
Definition at line 406 of file buf_internals.h.
References buffer_io_resowner_desc, Int32GetDatum(), and ResourceOwnerForget().
Referenced by TerminateBufferIO().
|
inlinestatic |
Definition at line 391 of file buf_internals.h.
References buffer_pin_resowner_desc, Int32GetDatum(), and ResourceOwnerRemember().
Referenced by IncrBufferRefCount(), PinBuffer(), PinBuffer_Locked(), and PinLocalBuffer().
|
inlinestatic |
Definition at line 401 of file buf_internals.h.
References buffer_io_resowner_desc, Int32GetDatum(), and ResourceOwnerRemember().
Referenced by StartBufferIO().
void ScheduleBufferTagForWriteback | ( | WritebackContext * | wb_context, |
IOContext | io_context, | ||
BufferTag * | tag | ||
) |
Definition at line 5915 of file bufmgr.c.
References Assert, enableFsync, IO_DIRECT_DATA, io_direct_flags, IssuePendingWritebacks(), WritebackContext::max_pending, WritebackContext::nr_pending, WritebackContext::pending_writebacks, PendingWriteback::tag, and WRITEBACK_MAX_PENDING_FLUSHES.
Referenced by GetVictimBuffer(), and SyncOneBuffer().
void StrategyFreeBuffer | ( | BufferDesc * | buf | ) |
Definition at line 363 of file freelist.c.
References buf, BufferStrategyControl::buffer_strategy_lock, BufferStrategyControl::firstFreeBuffer, FREENEXT_NOT_IN_LIST, BufferStrategyControl::lastFreeBuffer, SpinLockAcquire, SpinLockRelease, and StrategyControl.
Referenced by BufferAlloc(), ExtendBufferedRelShared(), and InvalidateBuffer().
BufferDesc* StrategyGetBuffer | ( | BufferAccessStrategy | strategy, |
uint32 * | buf_state, | ||
bool * | from_ring | ||
) |
Definition at line 196 of file freelist.c.
References AddBufferToRing(), PROC_HDR::allProcs, Assert, BufferStrategyControl::bgwprocno, buf, BUF_STATE_GET_REFCOUNT, BUF_STATE_GET_USAGECOUNT, BUF_USAGECOUNT_ONE, BufferStrategyControl::buffer_strategy_lock, ClockSweepTick(), elog, ERROR, BufferStrategyControl::firstFreeBuffer, FREENEXT_NOT_IN_LIST, GetBufferDescriptor(), GetBufferFromRing(), INT_ACCESS_ONCE, LockBufHdr(), NBuffers, BufferStrategyControl::numBufferAllocs, pg_atomic_fetch_add_u32(), ProcGlobal, PGPROC::procLatch, SetLatch(), SpinLockAcquire, SpinLockRelease, StrategyControl, and UnlockBufHdr().
Referenced by GetVictimBuffer().
void StrategyInitialize | ( | bool | init | ) |
Definition at line 474 of file freelist.c.
References Assert, BufferStrategyControl::bgwprocno, BufferStrategyControl::buffer_strategy_lock, BufferStrategyControl::completePasses, BufferStrategyControl::firstFreeBuffer, init, InitBufTable(), BufferStrategyControl::lastFreeBuffer, NBuffers, BufferStrategyControl::nextVictimBuffer, NUM_BUFFER_PARTITIONS, BufferStrategyControl::numBufferAllocs, pg_atomic_init_u32(), ShmemInitStruct(), SpinLockInit, and StrategyControl.
Referenced by BufferManagerShmemInit().
void StrategyNotifyBgWriter | ( | int | bgwprocno | ) |
Definition at line 431 of file freelist.c.
References BufferStrategyControl::bgwprocno, BufferStrategyControl::buffer_strategy_lock, SpinLockAcquire, SpinLockRelease, and StrategyControl.
Referenced by BackgroundWriterMain().
bool StrategyRejectBuffer | ( | BufferAccessStrategy | strategy, |
BufferDesc * | buf, | ||
bool | from_ring | ||
) |
Definition at line 798 of file freelist.c.
References BAS_BULKREAD, BufferAccessStrategyData::btype, buf, BufferDescriptorGetBuffer(), BufferAccessStrategyData::buffers, BufferAccessStrategyData::current, and InvalidBuffer.
Referenced by GetVictimBuffer().
Size StrategyShmemSize | ( | void | ) |
Definition at line 453 of file freelist.c.
References add_size(), BufTableShmemSize(), MAXALIGN, NBuffers, NUM_BUFFER_PARTITIONS, and size.
Referenced by BufferManagerShmemSize().
Definition at line 394 of file freelist.c.
References BufferStrategyControl::buffer_strategy_lock, BufferStrategyControl::completePasses, NBuffers, BufferStrategyControl::nextVictimBuffer, BufferStrategyControl::numBufferAllocs, pg_atomic_exchange_u32(), pg_atomic_read_u32(), SpinLockAcquire, SpinLockRelease, and StrategyControl.
Referenced by BgBufferSync().
|
inlinestatic |
Definition at line 360 of file buf_internals.h.
References BM_LOCKED, pg_atomic_write_u32(), pg_write_barrier, and BufferDesc::state.
Referenced by AbortBufferIO(), apw_dump_now(), BufferAlloc(), BufferGetLSNAtomic(), BufferSync(), ConditionalLockBufferForCleanup(), DropDatabaseBuffers(), DropRelationBuffers(), DropRelationsAllBuffers(), EvictUnpinnedBuffer(), ExtendBufferedRelShared(), FindAndDropRelationBuffers(), FlushBuffer(), FlushDatabaseBuffers(), FlushRelationBuffers(), FlushRelationsAllBuffers(), GetBufferFromRing(), GetVictimBuffer(), InvalidateBuffer(), InvalidateVictimBuffer(), IsBufferCleanupOK(), LockBufferForCleanup(), MarkBufferDirtyHint(), pg_buffercache_pages(), PinBuffer_Locked(), ReadRecentBuffer(), StartBufferIO(), StrategyGetBuffer(), SyncOneBuffer(), TerminateBufferIO(), UnlockBuffers(), UnpinBufferNoOwner(), and WaitIO().
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().
void WritebackContextInit | ( | WritebackContext * | context, |
int * | max_pending | ||
) |
Definition at line 5903 of file bufmgr.c.
References Assert, context, and WRITEBACK_MAX_PENDING_FLUSHES.
Referenced by BackgroundWriterMain(), BufferManagerShmemInit(), and BufferSync().
|
extern |
Definition at line 23 of file buf_init.c.
Referenced by BufferManagerShmemInit(), and GetVictimBuffer().
|
extern |
Definition at line 226 of file bufmgr.c.
Referenced by ResourceOwnerForgetBufferIO(), and ResourceOwnerRememberBufferIO().
|
extern |
Definition at line 235 of file bufmgr.c.
Referenced by ResourceOwnerForgetBuffer(), and ResourceOwnerRememberBuffer().
|
extern |
Definition at line 20 of file buf_init.c.
Referenced by BufferManagerShmemInit(), and GetBufferDescriptor().
|
extern |
Definition at line 22 of file buf_init.c.
Referenced by BufferDescriptorGetIOCV(), and BufferManagerShmemInit().
|
extern |
Definition at line 24 of file buf_init.c.
Referenced by BufferManagerShmemInit(), and BufferSync().
|
extern |
Definition at line 44 of file localbuf.c.
Referenced by GetLocalBufferDescriptor(), and InitLocalBuffers().