]> granicus.if.org Git - postgresql/commitdiff
Avoid unnecessary public struct declaration in slru.h
authorAlvaro Herrera <alvherre@alvh.no-ip.org>
Thu, 30 Dec 2010 15:09:17 +0000 (12:09 -0300)
committerAlvaro Herrera <alvherre@alvh.no-ip.org>
Thu, 30 Dec 2010 15:09:17 +0000 (12:09 -0300)
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

src/backend/access/transam/clog.c
src/backend/access/transam/multixact.c
src/backend/access/transam/slru.c
src/backend/access/transam/subtrans.c
src/backend/commands/async.c
src/include/access/slru.h

index 63d0ae6f63f894965505776a44b987321fb3c01e..df401379253269a453888b824cc9bb7a4560da26 100644 (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);
index 9422ef399497897bef6c26633690aa313ecc65cc..7e84444f46e958677f00240a7073ef87bcb4f0f5 100644 (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);
index 95c388fc8310ea137702688a47a5fd9f295f748c..3bf8bb0b33afd382723c5a258591b692e38502c5 100644 (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;
index 44e33b2b94f9f8c2edcf39e34f3febf78f9de5b9..4e266513cb394453aa085f1d5ea4d6db4e2c8ffe 100644 (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);
index a9923341147a32c289a97ad8ced2ba9919234f4f..f12b3a9f1382cbc68b1b92256bebf3df511154ab 100644 (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);
        }
 }
index 710cca70acd67e03e5f3a255b048a719ae4c4709..ede1b428ab382f4222816f0660e11799ad0d4e38 100644 (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);