PostgreSQL Source Code
git master
|
#include "postgres.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 |
Functions | |
static BufferDesc * | GetBufferFromRing (BufferAccessStrategy strategy, uint32 *buf_state) |
static void | AddBufferToRing (BufferAccessStrategy strategy, BufferDesc *buf) |
static uint32 | ClockSweepTick (void) |
bool | have_free_buffer (void) |
BufferDesc * | StrategyGetBuffer (BufferAccessStrategy strategy, uint32 *buf_state) |
void | StrategyFreeBuffer (BufferDesc *buf) |
int | StrategySyncStart (uint32 *complete_passes, uint32 *num_buf_alloc) |
void | StrategyNotifyBgWriter (int bgwprocno) |
Size | StrategyShmemSize (void) |
void | StrategyInitialize (bool init) |
BufferAccessStrategy | GetAccessStrategy (BufferAccessStrategyType btype) |
void | FreeAccessStrategy (BufferAccessStrategy strategy) |
bool | StrategyRejectBuffer (BufferAccessStrategy strategy, BufferDesc *buf) |
Variables | |
static BufferStrategyControl * | StrategyControl = NULL |
#define INT_ACCESS_ONCE | ( | var | ) | ((int)(*((volatile int *)&(var)))) |
Definition at line 23 of file freelist.c.
Referenced by StrategyGetBuffer().
typedef struct BufferAccessStrategyData BufferAccessStrategyData |
|
static |
Definition at line 669 of file freelist.c.
References BufferDescriptorGetBuffer, BufferAccessStrategyData::buffers, and BufferAccessStrategyData::current.
Referenced by StrategyGetBuffer().
|
inlinestatic |
Definition at line 113 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, and success.
Referenced by StrategyGetBuffer().
void FreeAccessStrategy | ( | BufferAccessStrategy | strategy | ) |
Definition at line 597 of file freelist.c.
References pfree().
Referenced by blgetbitmap(), FreeBulkInsertState(), heap_endscan(), and initscan().
BufferAccessStrategy GetAccessStrategy | ( | BufferAccessStrategyType | btype | ) |
Definition at line 542 of file freelist.c.
References BAS_BULKREAD, BAS_BULKWRITE, BAS_NORMAL, BAS_VACUUM, BufferAccessStrategyData::btype, BufferAccessStrategyData::buffers, elog, ERROR, Min, NBuffers, offsetof, palloc0(), and BufferAccessStrategyData::ring_size.
Referenced by blgetbitmap(), bt_check_every_level(), collect_corrupt_items(), collect_visibility_data(), do_autovacuum(), GetBulkInsertState(), initscan(), pgstat_index(), pgstathashindex(), pgstatindex_impl(), statapprox_heap(), vacuum(), and verify_heapam().
|
static |
Definition at line 611 of file freelist.c.
References buf, BUF_STATE_GET_REFCOUNT, BUF_STATE_GET_USAGECOUNT, BufferAccessStrategyData::buffers, BufferAccessStrategyData::current, BufferAccessStrategyData::current_was_in_ring, GetBufferDescriptor, InvalidBuffer, LockBufHdr(), BufferAccessStrategyData::ring_size, and UnlockBufHdr.
Referenced by StrategyGetBuffer().
bool have_free_buffer | ( | void | ) |
Definition at line 180 of file freelist.c.
References BufferStrategyControl::firstFreeBuffer.
Referenced by apw_load_buffers(), and autoprewarm_database_main().
void StrategyFreeBuffer | ( | BufferDesc * | buf | ) |
Definition at line 364 of file freelist.c.
References BufferDesc::buf_id, BufferStrategyControl::buffer_strategy_lock, BufferStrategyControl::firstFreeBuffer, BufferDesc::freeNext, FREENEXT_NOT_IN_LIST, BufferStrategyControl::lastFreeBuffer, SpinLockAcquire, and SpinLockRelease.
Referenced by InvalidateBuffer().
BufferDesc* StrategyGetBuffer | ( | BufferAccessStrategy | strategy, |
uint32 * | buf_state | ||
) |
Definition at line 201 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, BufferDesc::freeNext, FREENEXT_NOT_IN_LIST, GetBufferDescriptor, GetBufferFromRing(), INT_ACCESS_ONCE, LockBufHdr(), NBuffers, BufferStrategyControl::numBufferAllocs, pg_atomic_fetch_add_u32(), ProcGlobal, PGPROC::procLatch, SetLatch(), SpinLockAcquire, SpinLockRelease, and UnlockBufHdr.
Referenced by BufferAlloc().
void StrategyInitialize | ( | bool | init | ) |
Definition at line 475 of file freelist.c.
References Assert, BufferStrategyControl::bgwprocno, BufferStrategyControl::buffer_strategy_lock, BufferStrategyControl::completePasses, BufferStrategyControl::firstFreeBuffer, InitBufTable(), BufferStrategyControl::lastFreeBuffer, NBuffers, BufferStrategyControl::nextVictimBuffer, NUM_BUFFER_PARTITIONS, BufferStrategyControl::numBufferAllocs, pg_atomic_init_u32(), ShmemInitStruct(), and SpinLockInit.
Referenced by InitBufferPool().
void StrategyNotifyBgWriter | ( | int | bgwprocno | ) |
Definition at line 432 of file freelist.c.
References BufferStrategyControl::bgwprocno, BufferStrategyControl::buffer_strategy_lock, SpinLockAcquire, and SpinLockRelease.
Referenced by BackgroundWriterMain().
bool StrategyRejectBuffer | ( | BufferAccessStrategy | strategy, |
BufferDesc * | buf | ||
) |
Definition at line 686 of file freelist.c.
References BAS_BULKREAD, BufferAccessStrategyData::btype, BufferDescriptorGetBuffer, BufferAccessStrategyData::buffers, BufferAccessStrategyData::current, BufferAccessStrategyData::current_was_in_ring, and InvalidBuffer.
Referenced by BufferAlloc().
Size StrategyShmemSize | ( | void | ) |
Definition at line 454 of file freelist.c.
References add_size(), BufTableShmemSize(), MAXALIGN, NBuffers, and NUM_BUFFER_PARTITIONS.
Referenced by BufferShmemSize().
Definition at line 395 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, and SpinLockRelease.
Referenced by BgBufferSync().
|
static |
Definition at line 64 of file freelist.c.