PostgreSQL Source Code
git master
|
#include "postgres.h"
#include "pgstat.h"
#include "port/atomics.h"
#include "storage/buf_internals.h"
#include "storage/bufmgr.h"
#include "storage/proc.h"
Go to the source code of this file.
Data Structures | |
struct | BufferStrategyControl |
struct | BufferAccessStrategyData |
Macros | |
#define | INT_ACCESS_ONCE(var) ((int)(*((volatile int *)&(var)))) |
Typedefs | |
typedef struct BufferAccessStrategyData | BufferAccessStrategyData |
Variables | |
static BufferStrategyControl * | StrategyControl = NULL |
#define INT_ACCESS_ONCE | ( | var | ) | ((int)(*((volatile int *)&(var)))) |
Definition at line 24 of file freelist.c.
typedef struct BufferAccessStrategyData BufferAccessStrategyData |
|
static |
Definition at line 748 of file freelist.c.
References buf, BufferDescriptorGetBuffer(), BufferAccessStrategyData::buffers, and BufferAccessStrategyData::current.
Referenced by StrategyGetBuffer().
|
inlinestatic |
Definition at line 108 of file freelist.c.
References BufferStrategyControl::buffer_strategy_lock, BufferStrategyControl::completePasses, NBuffers, BufferStrategyControl::nextVictimBuffer, pg_atomic_compare_exchange_u32(), pg_atomic_fetch_add_u32(), SpinLockAcquire, SpinLockRelease, StrategyControl, and success.
Referenced by StrategyGetBuffer().
void FreeAccessStrategy | ( | BufferAccessStrategy | strategy | ) |
Definition at line 681 of file freelist.c.
References pfree().
Referenced by blgetbitmap(), FreeBulkInsertState(), heap_endscan(), initscan(), parallel_vacuum_main(), and RelationCopyStorageUsingBuffer().
BufferAccessStrategy GetAccessStrategy | ( | BufferAccessStrategyType | btype | ) |
Definition at line 541 of file freelist.c.
References BAS_BULKREAD, BAS_BULKWRITE, BAS_NORMAL, BAS_VACUUM, elog, ERROR, and GetAccessStrategyWithSize().
Referenced by blgetbitmap(), bt_check_every_level(), collect_corrupt_items(), collect_visibility_data(), GetBulkInsertState(), initscan(), pgstat_index(), pgstathashindex(), pgstatindex_impl(), RelationCopyStorageUsingBuffer(), ScanSourceDatabasePgClass(), statapprox_heap(), and verify_heapam().
int GetAccessStrategyBufferCount | ( | BufferAccessStrategy | strategy | ) |
Definition at line 624 of file freelist.c.
References BufferAccessStrategyData::nbuffers.
Referenced by parallel_vacuum_init().
int GetAccessStrategyPinLimit | ( | BufferAccessStrategy | strategy | ) |
Definition at line 647 of file freelist.c.
References BAS_BULKREAD, BufferAccessStrategyData::btype, BufferAccessStrategyData::nbuffers, and NBuffers.
Referenced by read_stream_begin_impl().
BufferAccessStrategy GetAccessStrategyWithSize | ( | BufferAccessStrategyType | btype, |
int | ring_size_kb | ||
) |
Definition at line 584 of file freelist.c.
References Assert, BufferAccessStrategyData::btype, Min, BufferAccessStrategyData::nbuffers, NBuffers, and palloc0().
Referenced by do_autovacuum(), ExecVacuum(), GetAccessStrategy(), and parallel_vacuum_main().
|
static |
Definition at line 695 of file freelist.c.
References buf, BUF_STATE_GET_REFCOUNT, BUF_STATE_GET_USAGECOUNT, BufferAccessStrategyData::buffers, BufferAccessStrategyData::current, GetBufferDescriptor(), InvalidBuffer, LockBufHdr(), BufferAccessStrategyData::nbuffers, and UnlockBufHdr().
Referenced by StrategyGetBuffer().
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().
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 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().
|
static |
Definition at line 65 of file freelist.c.
Referenced by ClockSweepTick(), have_free_buffer(), StrategyFreeBuffer(), StrategyGetBuffer(), StrategyInitialize(), StrategyNotifyBgWriter(), and StrategySyncStart().