summaryrefslogtreecommitdiff
path: root/src/backend/access/transam/slru.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/backend/access/transam/slru.c')
-rw-r--r--src/backend/access/transam/slru.c24
1 files changed, 19 insertions, 5 deletions
diff --git a/src/backend/access/transam/slru.c b/src/backend/access/transam/slru.c
index 95c388fc831..3bf8bb0b33a 100644
--- a/src/backend/access/transam/slru.c
+++ b/src/backend/access/transam/slru.c
@@ -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];
@@ -553,6 +556,17 @@ SimpleLruWritePage(SlruCtl ctl, int slotno, SlruFlush fdata)
}
/*
+ * 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
*
* On failure, we cannot just ereport(ERROR) since caller has put state in
@@ -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;