slock_t buf_hdr_lock; /* protects the above fields */
int buf_id; /* buffer's index number (from 0) */
int freeNext; /* link in freelist chain */
LWLockId io_in_progress_lock; /* to wait for I/O to complete */
LWLockId content_lock; /* to lock access to buffer contents */
}BufferDesc;
/*
* The sharedfreelist control information.
*/
typedef struct
{
/* Clock sweep hand: index of next buffer to considergrabbing */
int nextVictimBuffer;
int firstFreeBuffer; /* Head of list ofunused buffers */
int lastFreeBuffer;/* Tail of list of unused buffers */
/*
* NOTE: lastFreeBuffer is undefined whenfirstFreeBuffer is -1 (that is,
* when the list is empty)
*/
/*
* Statistics. These counters should be wide enough that they can't
* overflow during a single bgwriter cycle.
*/
uint32 completePasses; /* Complete cycles of the clock sweep*/
uint32 numBufferAllocs; /* Buffers allocated since last reset*/
} BufferStrategyControl;
/* Pointers to shared state */
static BufferStrategyControl *StrategyControl = NULL;
static HTAB *SharedBufHash;
typedef struct buftag
{
RelFileNodernode; /* physical relationidentifier */
ForkNumberforkNum;
BlockNumberblockNum; /* blknum relative tobegin of reln */
} BufferTag;
typedef struct
{
BufferTag key; /* Tag of a disk page */
int id; /*Associated buffer ID */
} BufferLookupEnt;
初始化完BufferPool相关结构的内存结构图

BufferPool哈希表索引“Shared Buffer Lookup Table”

BufferPool相关结构和策略控制结构图
上图中左面是BufferPool和策略控制结构图,根据shared_buffer的设置,有25600和BufferDesc数组和25600个bufferblock数组,还有一个BufferStrategyControl结构。右面是25600和BufferDesc数组中每个BufferDesc的成员的初始化值。已经体现了一个bufferblock两个轻量锁以及和磁盘上的数据文件的对应情况
摘自 BeiiGang的专栏