Skip to content

Commit 0160337

Browse files
author
Konstantin Knizhnik
committed
Determine SLRU kind in extension
1 parent ec25365 commit 0160337

File tree

4 files changed

+5
-26
lines changed

4 files changed

+5
-26
lines changed

src/backend/access/transam/slru.c

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -267,15 +267,6 @@ SimpleLruInit(SlruCtl ctl, const char *name, int nslots, int nlsns,
267267
ctl->shared = shared;
268268
ctl->sync_handler = sync_handler;
269269
strlcpy(ctl->Dir, subdir, sizeof(ctl->Dir));
270-
271-
if (strcmp(subdir, "pg_xact") == 0)
272-
ctl->kind = SLRU_CLOG;
273-
else if (strcmp(subdir, "pg_multixact/members") == 0)
274-
ctl->kind = SLRU_MULTIXACT_MEMBERS;
275-
else if (strcmp(subdir, "pg_multixact/offsets") == 0)
276-
ctl->kind = SLRU_MULTIXACT_OFFSETS;
277-
else
278-
ctl->kind = SLRU_OTHER;
279270
}
280271

281272
/*
@@ -637,9 +628,6 @@ SimpleLruDownloadSegment(SlruCtl ctl, int pageno, char const* path)
637628

638629
static SMgrRelationData dummy_smgr_rel = {0};
639630

640-
if (ctl->kind == SLRU_OTHER) /* Only CLOG/multixact can be downloaded from page server */
641-
return -1;
642-
643631
/* If page is beyond latest written page, then do not try to download segment from server */
644632
if (pageno > ctl->shared->latest_page_number)
645633
return -1;
@@ -652,7 +640,7 @@ SimpleLruDownloadSegment(SlruCtl ctl, int pageno, char const* path)
652640
segno = pageno / SLRU_PAGES_PER_SEGMENT;
653641

654642
buffer = palloc(BLCKSZ * SLRU_PAGES_PER_SEGMENT);
655-
n_blocks = smgr_read_slru_segment(&dummy_smgr_rel, ctl->kind, segno, buffer);
643+
n_blocks = smgr_read_slru_segment(&dummy_smgr_rel, path, segno, buffer);
656644
if (n_blocks > 0)
657645
{
658646
fd = OpenTransientFile(path, O_RDWR | O_CREAT | PG_BINARY);

src/backend/storage/smgr/smgr.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -539,9 +539,9 @@ smgrwrite(SMgrRelation reln, ForkNumber forknum, BlockNumber blocknum,
539539
}
540540

541541
int
542-
smgr_read_slru_segment(SMgrRelation reln, SlruKind kind, int segno, void* buffer)
542+
smgr_read_slru_segment(SMgrRelation reln, const char* path, int segno, void* buffer)
543543
{
544-
return (*reln->smgr).smgr_read_slru_segment ? (*reln->smgr).smgr_read_slru_segment(reln, kind, segno, buffer) : 0;
544+
return (*reln->smgr).smgr_read_slru_segment ? (*reln->smgr).smgr_read_slru_segment(reln, path, segno, buffer) : 0;
545545
}
546546

547547

src/include/access/slru.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
#include "access/xlogdefs.h"
1717
#include "storage/lwlock.h"
1818
#include "storage/sync.h"
19-
#include "storage/smgr.h"
2019

2120

2221
/*
@@ -135,7 +134,6 @@ typedef struct SlruCtlData
135134
* it's always the same, it doesn't need to be in shared memory.
136135
*/
137136
char Dir[64];
138-
SlruKind kind;
139137
} SlruCtlData;
140138

141139
typedef SlruCtlData *SlruCtl;

src/include/storage/smgr.h

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -88,13 +88,6 @@ typedef SMgrRelationData *SMgrRelation;
8888
#define SmgrIsTemp(smgr) \
8989
RelFileNodeBackendIsTemp((smgr)->smgr_rnode)
9090

91-
typedef enum {
92-
SLRU_CLOG,
93-
SLRU_MULTIXACT_MEMBERS,
94-
SLRU_MULTIXACT_OFFSETS,
95-
SLRU_OTHER
96-
} SlruKind;
97-
9891
/*
9992
* This struct of function pointers defines the API between smgr.c and
10093
* any individual storage manager module. Note that smgr subfunctions are
@@ -136,7 +129,7 @@ typedef struct f_smgr
136129
void (*smgr_finish_unlogged_build_phase_1) (SMgrRelation reln);
137130
void (*smgr_end_unlogged_build) (SMgrRelation reln);
138131

139-
int (*smgr_read_slru_segment) (SMgrRelation reln, SlruKind kind, int segno, void* buffer);
132+
int (*smgr_read_slru_segment) (SMgrRelation reln, const char *path, int segno, void* buffer);
140133
} f_smgr;
141134

142135
typedef void (*smgr_init_hook_type) (void);
@@ -188,6 +181,6 @@ extern void smgr_start_unlogged_build(SMgrRelation reln);
188181
extern void smgr_finish_unlogged_build_phase_1(SMgrRelation reln);
189182
extern void smgr_end_unlogged_build(SMgrRelation reln);
190183

191-
extern int smgr_read_slru_segment(SMgrRelation reln, SlruKind kind, int segno, void* buffer);
184+
extern int smgr_read_slru_segment(SMgrRelation reln, const char *path, int segno, void* buffer);
192185

193186
#endif /* SMGR_H */

0 commit comments

Comments
 (0)