46 if (
state->long_segment_names)
66 state->writing =
false;
67 state->long_segment_names = long_segment_names;
93 if (
state->segno != -1 && pageno ==
state->pageno)
94 return state->buf.data;
98 if (segno !=
state->segno)
100 if (
state->segno != -1)
114 state->segno = segno;
119 while (bytes_read < BLCKSZ)
124 &
state->buf.data + bytes_read,
136 pg_log(
PG_WARNING,
"unexpected EOF reading file \"%s\" at offset %u, reading as zeros",
137 state->fn, (
unsigned int) offset);
138 memset(&
state->buf.data + bytes_read, 0, BLCKSZ - bytes_read);
144 state->pageno = pageno;
146 return state->buf.data;
170 state->writing =
true;
171 state->long_segment_names = long_segment_names;
194 if (
state->segno != -1 && pageno ==
state->pageno)
195 return state->buf.data;
201 memset(
state->buf.data, 0, BLCKSZ);
203 if (segno !=
state->segno)
205 if (
state->segno != -1)
224 state->segno = segno;
233 state->pageno = pageno;
235 return state->buf.data;
241 struct iovec iovec = {
242 .iov_base = &
state->buf,
247 if (
state->segno == -1)
void * pg_malloc(size_t size)
ssize_t pg_pwritev_with_retry(int fd, const struct iovec *iov, int iovcnt, pgoff_t offset)
ssize_t pg_pwrite_zeros(int fd, size_t size, pgoff_t offset)
Assert(PointerIsAligned(start, uint64))
char * pstrdup(const char *in)
#define SLRU_PAGES_PER_SEGMENT
void void pg_log(eLogType type, const char *fmt,...) pg_attribute_printf(2
char * psprintf(const char *fmt,...)
char * SlruWriteSwitchPageSlow(SlruSegState *state, uint64 pageno)
static void SlruFlush(SlruSegState *state)
void FreeSlruWrite(SlruSegState *state)
static char * SlruFileName(SlruSegState *state, int64 segno)
static SlruSegState * AllocSlruSegState(const char *dir)
SlruSegState * AllocSlruWrite(const char *dir, bool long_segment_names)
char * SlruReadSwitchPageSlow(SlruSegState *state, uint64 pageno)
SlruSegState * AllocSlruRead(const char *dir, bool long_segment_names)
void FreeSlruRead(SlruSegState *state)