BootStrapXLOG(uint32 data_checksum_version)
{
CheckPoint checkPoint;
- char *buffer;
+ PGAlignedXLogBlock buffer;
XLogPageHeader page;
XLogLongPageHeader longpage;
XLogRecord *record;
sysidentifier |= ((uint64) tv.tv_usec) << 12;
sysidentifier |= getpid() & 0xFFF;
- /* page buffer must be aligned suitably for O_DIRECT */
- buffer = (char *) palloc(XLOG_BLCKSZ + XLOG_BLCKSZ);
- page = (XLogPageHeader) TYPEALIGN(XLOG_BLCKSZ, buffer);
- memset(page, 0, XLOG_BLCKSZ);
+ memset(&buffer, 0, sizeof buffer);
+ page = (XLogPageHeader) &buffer;
/*
* Set up information for the initial checkpoint record
/* Write the first page with the initial record */
errno = 0;
pgstat_report_wait_start(WAIT_EVENT_WAL_BOOTSTRAP_WRITE);
- if (write(openLogFile, page, XLOG_BLCKSZ) != XLOG_BLCKSZ)
+ if (write(openLogFile, &buffer, XLOG_BLCKSZ) != XLOG_BLCKSZ)
{
/* if write didn't set errno, assume problem is no disk space */
if (errno == 0)
BootStrapSUBTRANS();
BootStrapMultiXact();
- pfree(buffer);
-
/*
* Force control file to be read - in contrast to normal processing we'd
* otherwise never run the checks and GUC related initializations therein.
static unsigned int secs_per_test = 5;
static int needs_unlink = 0;
-static char full_buf[DEFAULT_XLOG_SEG_SIZE],
- *buf,
- *filename = FSYNC_FILENAME;
+alignas(PGAlignedXLogBlock) static char buf[DEFAULT_XLOG_SEG_SIZE];
+static char *filename = FSYNC_FILENAME;
static struct timeval start_t,
stop_t;
static sig_atomic_t alarm_triggered = false;
/* write random data into buffer */
for (ops = 0; ops < DEFAULT_XLOG_SEG_SIZE; ops++)
- full_buf[ops] = (char) pg_prng_int32(&pg_global_prng_state);
-
- buf = (char *) TYPEALIGN(XLOG_BLCKSZ, full_buf);
+ buf[ops] = (char) pg_prng_int32(&pg_global_prng_state);
}
static void
if ((tmpfile = open(filename, O_RDWR | O_CREAT | PG_BINARY, S_IRUSR | S_IWUSR)) == -1)
die("could not open output file");
needs_unlink = 1;
- if (write(tmpfile, full_buf, DEFAULT_XLOG_SEG_SIZE) !=
+ if (write(tmpfile, buf, DEFAULT_XLOG_SEG_SIZE) !=
DEFAULT_XLOG_SEG_SIZE)
die("write failed");