Age Owner Branch data TLA Line data Source code
1 : : /*
2 : : * slru_io.h
3 : : *
4 : : * Copyright (c) 2025, PostgreSQL Global Development Group
5 : : * src/bin/pg_upgrade/slru_io.h
6 : : */
7 : :
8 : : #ifndef SLRU_IO_H
9 : : #define SLRU_IO_H
10 : :
11 : : /*
12 : : * State for reading or writing an SLRU, with a one page buffer.
13 : : */
14 : : typedef struct SlruSegState
15 : : {
16 : : bool writing;
17 : : bool long_segment_names;
18 : :
19 : : char *dir;
20 : : char *fn;
21 : : int fd;
22 : : int64 segno;
23 : : uint64 pageno;
24 : :
25 : : PGAlignedBlock buf;
26 : : } SlruSegState;
27 : :
28 : : extern SlruSegState *AllocSlruRead(const char *dir, bool long_segment_names);
29 : : extern char *SlruReadSwitchPageSlow(SlruSegState *state, uint64 pageno);
30 : : extern void FreeSlruRead(SlruSegState *state);
31 : :
32 : : static inline char *
7 heikki.linnakangas@i 33 :UNC 0 : SlruReadSwitchPage(SlruSegState *state, uint64 pageno)
34 : : {
35 [ # # # # ]: 0 : if (state->segno != -1 && pageno == state->pageno)
36 : 0 : return state->buf.data;
37 : 0 : return SlruReadSwitchPageSlow(state, pageno);
38 : : }
39 : :
40 : : extern SlruSegState *AllocSlruWrite(const char *dir, bool long_segment_names);
41 : : extern char *SlruWriteSwitchPageSlow(SlruSegState *state, uint64 pageno);
42 : : extern void FreeSlruWrite(SlruSegState *state);
43 : :
44 : : static inline char *
45 : 0 : SlruWriteSwitchPage(SlruSegState *state, uint64 pageno)
46 : : {
47 [ # # # # ]: 0 : if (state->segno != -1 && pageno == state->pageno)
48 : 0 : return state->buf.data;
49 : 0 : return SlruWriteSwitchPageSlow(state, pageno);
50 : : }
51 : :
52 : : #endif /* SLRU_IO_H */
|