mirror of
https://github.com/postgres/postgres.git
synced 2025-07-31 22:04:40 +03:00
Avoid unnecessary public struct declaration in slru.h
Instead, declare a public wrapper of the sole function using it for external callers, so that they don't have to always pass a NULL argument. Author: Kevin Grittner
This commit is contained in:
@ -445,7 +445,7 @@ BootStrapCLOG(void)
|
|||||||
slotno = ZeroCLOGPage(0, false);
|
slotno = ZeroCLOGPage(0, false);
|
||||||
|
|
||||||
/* Make sure it's written out */
|
/* Make sure it's written out */
|
||||||
SimpleLruWritePage(ClogCtl, slotno, NULL);
|
SimpleLruWritePage(ClogCtl, slotno);
|
||||||
Assert(!ClogCtl->shared->page_dirty[slotno]);
|
Assert(!ClogCtl->shared->page_dirty[slotno]);
|
||||||
|
|
||||||
LWLockRelease(CLogControlLock);
|
LWLockRelease(CLogControlLock);
|
||||||
@ -698,7 +698,7 @@ clog_redo(XLogRecPtr lsn, XLogRecord *record)
|
|||||||
LWLockAcquire(CLogControlLock, LW_EXCLUSIVE);
|
LWLockAcquire(CLogControlLock, LW_EXCLUSIVE);
|
||||||
|
|
||||||
slotno = ZeroCLOGPage(pageno, false);
|
slotno = ZeroCLOGPage(pageno, false);
|
||||||
SimpleLruWritePage(ClogCtl, slotno, NULL);
|
SimpleLruWritePage(ClogCtl, slotno);
|
||||||
Assert(!ClogCtl->shared->page_dirty[slotno]);
|
Assert(!ClogCtl->shared->page_dirty[slotno]);
|
||||||
|
|
||||||
LWLockRelease(CLogControlLock);
|
LWLockRelease(CLogControlLock);
|
||||||
|
@ -1454,7 +1454,7 @@ BootStrapMultiXact(void)
|
|||||||
slotno = ZeroMultiXactOffsetPage(0, false);
|
slotno = ZeroMultiXactOffsetPage(0, false);
|
||||||
|
|
||||||
/* Make sure it's written out */
|
/* Make sure it's written out */
|
||||||
SimpleLruWritePage(MultiXactOffsetCtl, slotno, NULL);
|
SimpleLruWritePage(MultiXactOffsetCtl, slotno);
|
||||||
Assert(!MultiXactOffsetCtl->shared->page_dirty[slotno]);
|
Assert(!MultiXactOffsetCtl->shared->page_dirty[slotno]);
|
||||||
|
|
||||||
LWLockRelease(MultiXactOffsetControlLock);
|
LWLockRelease(MultiXactOffsetControlLock);
|
||||||
@ -1465,7 +1465,7 @@ BootStrapMultiXact(void)
|
|||||||
slotno = ZeroMultiXactMemberPage(0, false);
|
slotno = ZeroMultiXactMemberPage(0, false);
|
||||||
|
|
||||||
/* Make sure it's written out */
|
/* Make sure it's written out */
|
||||||
SimpleLruWritePage(MultiXactMemberCtl, slotno, NULL);
|
SimpleLruWritePage(MultiXactMemberCtl, slotno);
|
||||||
Assert(!MultiXactMemberCtl->shared->page_dirty[slotno]);
|
Assert(!MultiXactMemberCtl->shared->page_dirty[slotno]);
|
||||||
|
|
||||||
LWLockRelease(MultiXactMemberControlLock);
|
LWLockRelease(MultiXactMemberControlLock);
|
||||||
@ -1986,7 +1986,7 @@ multixact_redo(XLogRecPtr lsn, XLogRecord *record)
|
|||||||
LWLockAcquire(MultiXactOffsetControlLock, LW_EXCLUSIVE);
|
LWLockAcquire(MultiXactOffsetControlLock, LW_EXCLUSIVE);
|
||||||
|
|
||||||
slotno = ZeroMultiXactOffsetPage(pageno, false);
|
slotno = ZeroMultiXactOffsetPage(pageno, false);
|
||||||
SimpleLruWritePage(MultiXactOffsetCtl, slotno, NULL);
|
SimpleLruWritePage(MultiXactOffsetCtl, slotno);
|
||||||
Assert(!MultiXactOffsetCtl->shared->page_dirty[slotno]);
|
Assert(!MultiXactOffsetCtl->shared->page_dirty[slotno]);
|
||||||
|
|
||||||
LWLockRelease(MultiXactOffsetControlLock);
|
LWLockRelease(MultiXactOffsetControlLock);
|
||||||
@ -2001,7 +2001,7 @@ multixact_redo(XLogRecPtr lsn, XLogRecord *record)
|
|||||||
LWLockAcquire(MultiXactMemberControlLock, LW_EXCLUSIVE);
|
LWLockAcquire(MultiXactMemberControlLock, LW_EXCLUSIVE);
|
||||||
|
|
||||||
slotno = ZeroMultiXactMemberPage(pageno, false);
|
slotno = ZeroMultiXactMemberPage(pageno, false);
|
||||||
SimpleLruWritePage(MultiXactMemberCtl, slotno, NULL);
|
SimpleLruWritePage(MultiXactMemberCtl, slotno);
|
||||||
Assert(!MultiXactMemberCtl->shared->page_dirty[slotno]);
|
Assert(!MultiXactMemberCtl->shared->page_dirty[slotno]);
|
||||||
|
|
||||||
LWLockRelease(MultiXactMemberControlLock);
|
LWLockRelease(MultiXactMemberControlLock);
|
||||||
|
@ -78,6 +78,8 @@ typedef struct SlruFlushData
|
|||||||
int segno[MAX_FLUSH_BUFFERS]; /* their log seg#s */
|
int segno[MAX_FLUSH_BUFFERS]; /* their log seg#s */
|
||||||
} SlruFlushData;
|
} SlruFlushData;
|
||||||
|
|
||||||
|
typedef struct SlruFlushData *SlruFlush;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Macro to mark a buffer slot "most recently used". Note multiple evaluation
|
* Macro to mark a buffer slot "most recently used". Note multiple evaluation
|
||||||
* of arguments!
|
* of arguments!
|
||||||
@ -123,6 +125,7 @@ static int slru_errno;
|
|||||||
|
|
||||||
static void SimpleLruZeroLSNs(SlruCtl ctl, int slotno);
|
static void SimpleLruZeroLSNs(SlruCtl ctl, int slotno);
|
||||||
static void SimpleLruWaitIO(SlruCtl ctl, int slotno);
|
static void SimpleLruWaitIO(SlruCtl ctl, int slotno);
|
||||||
|
static void SlruInternalWritePage(SlruCtl ctl, int slotno, SlruFlush fdata);
|
||||||
static bool SlruPhysicalReadPage(SlruCtl ctl, int pageno, int slotno);
|
static bool SlruPhysicalReadPage(SlruCtl ctl, int pageno, int slotno);
|
||||||
static bool SlruPhysicalWritePage(SlruCtl ctl, int pageno, int slotno,
|
static bool SlruPhysicalWritePage(SlruCtl ctl, int pageno, int slotno,
|
||||||
SlruFlush fdata);
|
SlruFlush fdata);
|
||||||
@ -485,8 +488,8 @@ SimpleLruReadPage_ReadOnly(SlruCtl ctl, int pageno, TransactionId xid)
|
|||||||
*
|
*
|
||||||
* Control lock must be held at entry, and will be held at exit.
|
* Control lock must be held at entry, and will be held at exit.
|
||||||
*/
|
*/
|
||||||
void
|
static void
|
||||||
SimpleLruWritePage(SlruCtl ctl, int slotno, SlruFlush fdata)
|
SlruInternalWritePage(SlruCtl ctl, int slotno, SlruFlush fdata)
|
||||||
{
|
{
|
||||||
SlruShared shared = ctl->shared;
|
SlruShared shared = ctl->shared;
|
||||||
int pageno = shared->page_number[slotno];
|
int pageno = shared->page_number[slotno];
|
||||||
@ -552,6 +555,17 @@ SimpleLruWritePage(SlruCtl ctl, int slotno, SlruFlush fdata)
|
|||||||
SlruReportIOError(ctl, pageno, InvalidTransactionId);
|
SlruReportIOError(ctl, pageno, InvalidTransactionId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Wrapper of SlruInternalWritePage, for external callers.
|
||||||
|
* fdata is always passed a NULL here.
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
SimpleLruWritePage(SlruCtl ctl, int slotno)
|
||||||
|
{
|
||||||
|
SlruInternalWritePage(ctl, slotno, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Physical read of a (previously existing) page into a buffer slot
|
* Physical read of a (previously existing) page into a buffer slot
|
||||||
*
|
*
|
||||||
@ -975,7 +989,7 @@ SlruSelectLRUPage(SlruCtl ctl, int pageno)
|
|||||||
* we wait for the existing I/O to complete.
|
* we wait for the existing I/O to complete.
|
||||||
*/
|
*/
|
||||||
if (shared->page_status[bestslot] == SLRU_PAGE_VALID)
|
if (shared->page_status[bestslot] == SLRU_PAGE_VALID)
|
||||||
SimpleLruWritePage(ctl, bestslot, NULL);
|
SlruInternalWritePage(ctl, bestslot, NULL);
|
||||||
else
|
else
|
||||||
SimpleLruWaitIO(ctl, bestslot);
|
SimpleLruWaitIO(ctl, bestslot);
|
||||||
|
|
||||||
@ -1009,7 +1023,7 @@ SimpleLruFlush(SlruCtl ctl, bool checkpoint)
|
|||||||
|
|
||||||
for (slotno = 0; slotno < shared->num_slots; slotno++)
|
for (slotno = 0; slotno < shared->num_slots; slotno++)
|
||||||
{
|
{
|
||||||
SimpleLruWritePage(ctl, slotno, &fdata);
|
SlruInternalWritePage(ctl, slotno, &fdata);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* When called during a checkpoint, we cannot assert that the slot is
|
* When called during a checkpoint, we cannot assert that the slot is
|
||||||
@ -1114,7 +1128,7 @@ restart:;
|
|||||||
* keep the logic the same as it was.)
|
* keep the logic the same as it was.)
|
||||||
*/
|
*/
|
||||||
if (shared->page_status[slotno] == SLRU_PAGE_VALID)
|
if (shared->page_status[slotno] == SLRU_PAGE_VALID)
|
||||||
SimpleLruWritePage(ctl, slotno, NULL);
|
SlruInternalWritePage(ctl, slotno, NULL);
|
||||||
else
|
else
|
||||||
SimpleLruWaitIO(ctl, slotno);
|
SimpleLruWaitIO(ctl, slotno);
|
||||||
goto restart;
|
goto restart;
|
||||||
|
@ -205,7 +205,7 @@ BootStrapSUBTRANS(void)
|
|||||||
slotno = ZeroSUBTRANSPage(0);
|
slotno = ZeroSUBTRANSPage(0);
|
||||||
|
|
||||||
/* Make sure it's written out */
|
/* Make sure it's written out */
|
||||||
SimpleLruWritePage(SubTransCtl, slotno, NULL);
|
SimpleLruWritePage(SubTransCtl, slotno);
|
||||||
Assert(!SubTransCtl->shared->page_dirty[slotno]);
|
Assert(!SubTransCtl->shared->page_dirty[slotno]);
|
||||||
|
|
||||||
LWLockRelease(SubtransControlLock);
|
LWLockRelease(SubtransControlLock);
|
||||||
|
@ -507,7 +507,7 @@ AsyncShmemInit(void)
|
|||||||
LWLockAcquire(AsyncCtlLock, LW_EXCLUSIVE);
|
LWLockAcquire(AsyncCtlLock, LW_EXCLUSIVE);
|
||||||
slotno = SimpleLruZeroPage(AsyncCtl, QUEUE_POS_PAGE(QUEUE_HEAD));
|
slotno = SimpleLruZeroPage(AsyncCtl, QUEUE_POS_PAGE(QUEUE_HEAD));
|
||||||
/* This write is just to verify that pg_notify/ is writable */
|
/* This write is just to verify that pg_notify/ is writable */
|
||||||
SimpleLruWritePage(AsyncCtl, slotno, NULL);
|
SimpleLruWritePage(AsyncCtl, slotno);
|
||||||
LWLockRelease(AsyncCtlLock);
|
LWLockRelease(AsyncCtlLock);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -133,9 +133,6 @@ typedef struct SlruCtlData
|
|||||||
|
|
||||||
typedef SlruCtlData *SlruCtl;
|
typedef SlruCtlData *SlruCtl;
|
||||||
|
|
||||||
/* Opaque struct known only in slru.c */
|
|
||||||
typedef struct SlruFlushData *SlruFlush;
|
|
||||||
|
|
||||||
|
|
||||||
extern Size SimpleLruShmemSize(int nslots, int nlsns);
|
extern Size SimpleLruShmemSize(int nslots, int nlsns);
|
||||||
extern void SimpleLruInit(SlruCtl ctl, const char *name, int nslots, int nlsns,
|
extern void SimpleLruInit(SlruCtl ctl, const char *name, int nslots, int nlsns,
|
||||||
@ -145,7 +142,7 @@ extern int SimpleLruReadPage(SlruCtl ctl, int pageno, bool write_ok,
|
|||||||
TransactionId xid);
|
TransactionId xid);
|
||||||
extern int SimpleLruReadPage_ReadOnly(SlruCtl ctl, int pageno,
|
extern int SimpleLruReadPage_ReadOnly(SlruCtl ctl, int pageno,
|
||||||
TransactionId xid);
|
TransactionId xid);
|
||||||
extern void SimpleLruWritePage(SlruCtl ctl, int slotno, SlruFlush fdata);
|
extern void SimpleLruWritePage(SlruCtl ctl, int slotno);
|
||||||
extern void SimpleLruFlush(SlruCtl ctl, bool checkpoint);
|
extern void SimpleLruFlush(SlruCtl ctl, bool checkpoint);
|
||||||
extern void SimpleLruTruncate(SlruCtl ctl, int cutoffPage);
|
extern void SimpleLruTruncate(SlruCtl ctl, int cutoffPage);
|
||||||
extern bool SlruScanDirectory(SlruCtl ctl, int cutoffPage, bool doDeletions);
|
extern bool SlruScanDirectory(SlruCtl ctl, int cutoffPage, bool doDeletions);
|
||||||
|
Reference in New Issue
Block a user