Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit5557399

Browse files
committed
Avoid unnecessary public struct declaration in slru.h
Instead, declare a public wrapper of the sole function using it forexternal callers, so that they don't have to always pass a NULLargument.Author: Kevin Grittner
1 parent0be88f8 commit5557399

File tree

6 files changed

+28
-17
lines changed

6 files changed

+28
-17
lines changed

‎src/backend/access/transam/clog.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -445,7 +445,7 @@ BootStrapCLOG(void)
445445
slotno=ZeroCLOGPage(0, false);
446446

447447
/* Make sure it's written out */
448-
SimpleLruWritePage(ClogCtl,slotno,NULL);
448+
SimpleLruWritePage(ClogCtl,slotno);
449449
Assert(!ClogCtl->shared->page_dirty[slotno]);
450450

451451
LWLockRelease(CLogControlLock);
@@ -698,7 +698,7 @@ clog_redo(XLogRecPtr lsn, XLogRecord *record)
698698
LWLockAcquire(CLogControlLock,LW_EXCLUSIVE);
699699

700700
slotno=ZeroCLOGPage(pageno, false);
701-
SimpleLruWritePage(ClogCtl,slotno,NULL);
701+
SimpleLruWritePage(ClogCtl,slotno);
702702
Assert(!ClogCtl->shared->page_dirty[slotno]);
703703

704704
LWLockRelease(CLogControlLock);

‎src/backend/access/transam/multixact.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1454,7 +1454,7 @@ BootStrapMultiXact(void)
14541454
slotno=ZeroMultiXactOffsetPage(0, false);
14551455

14561456
/* Make sure it's written out */
1457-
SimpleLruWritePage(MultiXactOffsetCtl,slotno,NULL);
1457+
SimpleLruWritePage(MultiXactOffsetCtl,slotno);
14581458
Assert(!MultiXactOffsetCtl->shared->page_dirty[slotno]);
14591459

14601460
LWLockRelease(MultiXactOffsetControlLock);
@@ -1465,7 +1465,7 @@ BootStrapMultiXact(void)
14651465
slotno=ZeroMultiXactMemberPage(0, false);
14661466

14671467
/* Make sure it's written out */
1468-
SimpleLruWritePage(MultiXactMemberCtl,slotno,NULL);
1468+
SimpleLruWritePage(MultiXactMemberCtl,slotno);
14691469
Assert(!MultiXactMemberCtl->shared->page_dirty[slotno]);
14701470

14711471
LWLockRelease(MultiXactMemberControlLock);
@@ -1986,7 +1986,7 @@ multixact_redo(XLogRecPtr lsn, XLogRecord *record)
19861986
LWLockAcquire(MultiXactOffsetControlLock,LW_EXCLUSIVE);
19871987

19881988
slotno=ZeroMultiXactOffsetPage(pageno, false);
1989-
SimpleLruWritePage(MultiXactOffsetCtl,slotno,NULL);
1989+
SimpleLruWritePage(MultiXactOffsetCtl,slotno);
19901990
Assert(!MultiXactOffsetCtl->shared->page_dirty[slotno]);
19911991

19921992
LWLockRelease(MultiXactOffsetControlLock);
@@ -2001,7 +2001,7 @@ multixact_redo(XLogRecPtr lsn, XLogRecord *record)
20012001
LWLockAcquire(MultiXactMemberControlLock,LW_EXCLUSIVE);
20022002

20032003
slotno=ZeroMultiXactMemberPage(pageno, false);
2004-
SimpleLruWritePage(MultiXactMemberCtl,slotno,NULL);
2004+
SimpleLruWritePage(MultiXactMemberCtl,slotno);
20052005
Assert(!MultiXactMemberCtl->shared->page_dirty[slotno]);
20062006

20072007
LWLockRelease(MultiXactMemberControlLock);

‎src/backend/access/transam/slru.c

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,8 @@ typedef struct SlruFlushData
7878
intsegno[MAX_FLUSH_BUFFERS];/* their log seg#s */
7979
}SlruFlushData;
8080

81+
typedefstructSlruFlushData*SlruFlush;
82+
8183
/*
8284
* Macro to mark a buffer slot "most recently used". Note multiple evaluation
8385
* of arguments!
@@ -123,6 +125,7 @@ static intslru_errno;
123125

124126
staticvoidSimpleLruZeroLSNs(SlruCtlctl,intslotno);
125127
staticvoidSimpleLruWaitIO(SlruCtlctl,intslotno);
128+
staticvoidSlruInternalWritePage(SlruCtlctl,intslotno,SlruFlushfdata);
126129
staticboolSlruPhysicalReadPage(SlruCtlctl,intpageno,intslotno);
127130
staticboolSlruPhysicalWritePage(SlruCtlctl,intpageno,intslotno,
128131
SlruFlushfdata);
@@ -485,8 +488,8 @@ SimpleLruReadPage_ReadOnly(SlruCtl ctl, int pageno, TransactionId xid)
485488
*
486489
* Control lock must be held at entry, and will be held at exit.
487490
*/
488-
void
489-
SimpleLruWritePage(SlruCtlctl,intslotno,SlruFlushfdata)
491+
staticvoid
492+
SlruInternalWritePage(SlruCtlctl,intslotno,SlruFlushfdata)
490493
{
491494
SlruSharedshared=ctl->shared;
492495
intpageno=shared->page_number[slotno];
@@ -552,6 +555,17 @@ SimpleLruWritePage(SlruCtl ctl, int slotno, SlruFlush fdata)
552555
SlruReportIOError(ctl,pageno,InvalidTransactionId);
553556
}
554557

558+
/*
559+
* Wrapper of SlruInternalWritePage, for external callers.
560+
* fdata is always passed a NULL here.
561+
*/
562+
void
563+
SimpleLruWritePage(SlruCtlctl,intslotno)
564+
{
565+
SlruInternalWritePage(ctl,slotno,NULL);
566+
}
567+
568+
555569
/*
556570
* Physical read of a (previously existing) page into a buffer slot
557571
*
@@ -975,7 +989,7 @@ SlruSelectLRUPage(SlruCtl ctl, int pageno)
975989
* we wait for the existing I/O to complete.
976990
*/
977991
if (shared->page_status[bestslot]==SLRU_PAGE_VALID)
978-
SimpleLruWritePage(ctl,bestslot,NULL);
992+
SlruInternalWritePage(ctl,bestslot,NULL);
979993
else
980994
SimpleLruWaitIO(ctl,bestslot);
981995

@@ -1009,7 +1023,7 @@ SimpleLruFlush(SlruCtl ctl, bool checkpoint)
10091023

10101024
for (slotno=0;slotno<shared->num_slots;slotno++)
10111025
{
1012-
SimpleLruWritePage(ctl,slotno,&fdata);
1026+
SlruInternalWritePage(ctl,slotno,&fdata);
10131027

10141028
/*
10151029
* When called during a checkpoint, we cannot assert that the slot is
@@ -1114,7 +1128,7 @@ restart:;
11141128
* keep the logic the same as it was.)
11151129
*/
11161130
if (shared->page_status[slotno]==SLRU_PAGE_VALID)
1117-
SimpleLruWritePage(ctl,slotno,NULL);
1131+
SlruInternalWritePage(ctl,slotno,NULL);
11181132
else
11191133
SimpleLruWaitIO(ctl,slotno);
11201134
gotorestart;

‎src/backend/access/transam/subtrans.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ BootStrapSUBTRANS(void)
205205
slotno=ZeroSUBTRANSPage(0);
206206

207207
/* Make sure it's written out */
208-
SimpleLruWritePage(SubTransCtl,slotno,NULL);
208+
SimpleLruWritePage(SubTransCtl,slotno);
209209
Assert(!SubTransCtl->shared->page_dirty[slotno]);
210210

211211
LWLockRelease(SubtransControlLock);

‎src/backend/commands/async.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -507,7 +507,7 @@ AsyncShmemInit(void)
507507
LWLockAcquire(AsyncCtlLock,LW_EXCLUSIVE);
508508
slotno=SimpleLruZeroPage(AsyncCtl,QUEUE_POS_PAGE(QUEUE_HEAD));
509509
/* This write is just to verify that pg_notify/ is writable */
510-
SimpleLruWritePage(AsyncCtl,slotno,NULL);
510+
SimpleLruWritePage(AsyncCtl,slotno);
511511
LWLockRelease(AsyncCtlLock);
512512
}
513513
}

‎src/include/access/slru.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -133,9 +133,6 @@ typedef struct SlruCtlData
133133

134134
typedefSlruCtlData*SlruCtl;
135135

136-
/* Opaque struct known only in slru.c */
137-
typedefstructSlruFlushData*SlruFlush;
138-
139136

140137
externSizeSimpleLruShmemSize(intnslots,intnlsns);
141138
externvoidSimpleLruInit(SlruCtlctl,constchar*name,intnslots,intnlsns,
@@ -145,7 +142,7 @@ extern int SimpleLruReadPage(SlruCtl ctl, int pageno, bool write_ok,
145142
TransactionIdxid);
146143
externintSimpleLruReadPage_ReadOnly(SlruCtlctl,intpageno,
147144
TransactionIdxid);
148-
externvoidSimpleLruWritePage(SlruCtlctl,intslotno,SlruFlushfdata);
145+
externvoidSimpleLruWritePage(SlruCtlctl,intslotno);
149146
externvoidSimpleLruFlush(SlruCtlctl,boolcheckpoint);
150147
externvoidSimpleLruTruncate(SlruCtlctl,intcutoffPage);
151148
externboolSlruScanDirectory(SlruCtlctl,intcutoffPage,booldoDeletions);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp