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:
Alvaro Herrera 2010-12-30 12:09:17 -03:00
parent 0be88f8739
commit 55573990ca
6 changed files with 28 additions and 17 deletions

View File

@ -445,7 +445,7 @@ BootStrapCLOG(void)
slotno = ZeroCLOGPage(0, false);
/* Make sure it's written out */
SimpleLruWritePage(ClogCtl, slotno, NULL);
SimpleLruWritePage(ClogCtl, slotno);
Assert(!ClogCtl->shared->page_dirty[slotno]);
LWLockRelease(CLogControlLock);
@ -698,7 +698,7 @@ clog_redo(XLogRecPtr lsn, XLogRecord *record)
LWLockAcquire(CLogControlLock, LW_EXCLUSIVE);
slotno = ZeroCLOGPage(pageno, false);
SimpleLruWritePage(ClogCtl, slotno, NULL);
SimpleLruWritePage(ClogCtl, slotno);
Assert(!ClogCtl->shared->page_dirty[slotno]);
LWLockRelease(CLogControlLock);

View File

@ -1454,7 +1454,7 @@ BootStrapMultiXact(void)
slotno = ZeroMultiXactOffsetPage(0, false);
/* Make sure it's written out */
SimpleLruWritePage(MultiXactOffsetCtl, slotno, NULL);
SimpleLruWritePage(MultiXactOffsetCtl, slotno);
Assert(!MultiXactOffsetCtl->shared->page_dirty[slotno]);
LWLockRelease(MultiXactOffsetControlLock);
@ -1465,7 +1465,7 @@ BootStrapMultiXact(void)
slotno = ZeroMultiXactMemberPage(0, false);
/* Make sure it's written out */
SimpleLruWritePage(MultiXactMemberCtl, slotno, NULL);
SimpleLruWritePage(MultiXactMemberCtl, slotno);
Assert(!MultiXactMemberCtl->shared->page_dirty[slotno]);
LWLockRelease(MultiXactMemberControlLock);
@ -1986,7 +1986,7 @@ multixact_redo(XLogRecPtr lsn, XLogRecord *record)
LWLockAcquire(MultiXactOffsetControlLock, LW_EXCLUSIVE);
slotno = ZeroMultiXactOffsetPage(pageno, false);
SimpleLruWritePage(MultiXactOffsetCtl, slotno, NULL);
SimpleLruWritePage(MultiXactOffsetCtl, slotno);
Assert(!MultiXactOffsetCtl->shared->page_dirty[slotno]);
LWLockRelease(MultiXactOffsetControlLock);
@ -2001,7 +2001,7 @@ multixact_redo(XLogRecPtr lsn, XLogRecord *record)
LWLockAcquire(MultiXactMemberControlLock, LW_EXCLUSIVE);
slotno = ZeroMultiXactMemberPage(pageno, false);
SimpleLruWritePage(MultiXactMemberCtl, slotno, NULL);
SimpleLruWritePage(MultiXactMemberCtl, slotno);
Assert(!MultiXactMemberCtl->shared->page_dirty[slotno]);
LWLockRelease(MultiXactMemberControlLock);

View File

@ -78,6 +78,8 @@ typedef struct SlruFlushData
int segno[MAX_FLUSH_BUFFERS]; /* their log seg#s */
} SlruFlushData;
typedef struct SlruFlushData *SlruFlush;
/*
* Macro to mark a buffer slot "most recently used". Note multiple evaluation
* of arguments!
@ -123,6 +125,7 @@ static int slru_errno;
static void SimpleLruZeroLSNs(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 SlruPhysicalWritePage(SlruCtl ctl, int pageno, int slotno,
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.
*/
void
SimpleLruWritePage(SlruCtl ctl, int slotno, SlruFlush fdata)
static void
SlruInternalWritePage(SlruCtl ctl, int slotno, SlruFlush fdata)
{
SlruShared shared = ctl->shared;
int pageno = shared->page_number[slotno];
@ -552,6 +555,17 @@ SimpleLruWritePage(SlruCtl ctl, int slotno, SlruFlush fdata)
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
*
@ -975,7 +989,7 @@ SlruSelectLRUPage(SlruCtl ctl, int pageno)
* we wait for the existing I/O to complete.
*/
if (shared->page_status[bestslot] == SLRU_PAGE_VALID)
SimpleLruWritePage(ctl, bestslot, NULL);
SlruInternalWritePage(ctl, bestslot, NULL);
else
SimpleLruWaitIO(ctl, bestslot);
@ -1009,7 +1023,7 @@ SimpleLruFlush(SlruCtl ctl, bool checkpoint)
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
@ -1114,7 +1128,7 @@ restart:;
* keep the logic the same as it was.)
*/
if (shared->page_status[slotno] == SLRU_PAGE_VALID)
SimpleLruWritePage(ctl, slotno, NULL);
SlruInternalWritePage(ctl, slotno, NULL);
else
SimpleLruWaitIO(ctl, slotno);
goto restart;

View File

@ -205,7 +205,7 @@ BootStrapSUBTRANS(void)
slotno = ZeroSUBTRANSPage(0);
/* Make sure it's written out */
SimpleLruWritePage(SubTransCtl, slotno, NULL);
SimpleLruWritePage(SubTransCtl, slotno);
Assert(!SubTransCtl->shared->page_dirty[slotno]);
LWLockRelease(SubtransControlLock);

View File

@ -507,7 +507,7 @@ AsyncShmemInit(void)
LWLockAcquire(AsyncCtlLock, LW_EXCLUSIVE);
slotno = SimpleLruZeroPage(AsyncCtl, QUEUE_POS_PAGE(QUEUE_HEAD));
/* This write is just to verify that pg_notify/ is writable */
SimpleLruWritePage(AsyncCtl, slotno, NULL);
SimpleLruWritePage(AsyncCtl, slotno);
LWLockRelease(AsyncCtlLock);
}
}

View File

@ -133,9 +133,6 @@ typedef struct SlruCtlData
typedef SlruCtlData *SlruCtl;
/* Opaque struct known only in slru.c */
typedef struct SlruFlushData *SlruFlush;
extern Size SimpleLruShmemSize(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);
extern int SimpleLruReadPage_ReadOnly(SlruCtl ctl, int pageno,
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 SimpleLruTruncate(SlruCtl ctl, int cutoffPage);
extern bool SlruScanDirectory(SlruCtl ctl, int cutoffPage, bool doDeletions);