From 053fef110990c704eb19373f502c47ebd9a803d6 Mon Sep 17 00:00:00 2001 From: Peter Eisentraut Date: Wed, 16 Sep 2026 09:21:56 +0200 Subject: [PATCH v4 1/5] Rename PGAlignedXLogBlock to PGIOAlignedXLogBlock Before commit faeedbcefd4, PGAlignedXLogBlock was MAXALIGNed and a sibling of PGAlignedBlock. That commit introduced PGIOAlignedBlock that was aligned as PG_IO_ALIGN_SIZE and *changed* PGAlignedXLogBlock to also be aligned as PG_IO_ALIGN_SIZE. This creates an inconsistent naming, as there would now be no room for a MAXALIGNed block of size XLOG_BLCKSZ. To improve this, rename PGAlignedXLogBlock to PGIOAlignedXLogBlock, which now correctly reflects its purpose. A MAXALIGNed PGAlignedXLogBlock could be re-introduced later. --- src/backend/access/transam/xlog.c | 4 ++-- src/bin/pg_basebackup/walmethods.c | 2 +- src/bin/pg_resetwal/pg_resetwal.c | 2 +- src/bin/pg_test_fsync/pg_test_fsync.c | 2 +- src/bin/pg_waldump/pg_waldump.c | 2 +- src/include/c.h | 6 +++--- src/tools/pgindent/typedefs.list | 2 +- 7 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c index 8636ad9ab2c..0ebf0810ece 100644 --- a/src/backend/access/transam/xlog.c +++ b/src/backend/access/transam/xlog.c @@ -3539,7 +3539,7 @@ XLogFileCopy(TimeLineID destTLI, XLogSegNo destsegno, { char path[MAXPGPATH]; char tmppath[MAXPGPATH]; - PGAlignedXLogBlock buffer; + PGIOAlignedXLogBlock buffer; int srcfd; int fd; int nbytes; @@ -5691,7 +5691,7 @@ void BootStrapXLOG(uint32 data_checksum_version) { CheckPoint checkPoint; - PGAlignedXLogBlock buffer; + PGIOAlignedXLogBlock buffer; XLogPageHeader page; XLogLongPageHeader longpage; XLogRecord *record; diff --git a/src/bin/pg_basebackup/walmethods.c b/src/bin/pg_basebackup/walmethods.c index 3a6b3b5f45b..44cacaf97ea 100644 --- a/src/bin/pg_basebackup/walmethods.c +++ b/src/bin/pg_basebackup/walmethods.c @@ -804,7 +804,7 @@ tar_write(Walfile *f, const void *buf, size_t count) static bool tar_write_padding_data(TarMethodFile *f, size_t bytes) { - PGAlignedXLogBlock zerobuf; + PGIOAlignedXLogBlock zerobuf; size_t bytesleft = bytes; memset(zerobuf.data, 0, XLOG_BLCKSZ); diff --git a/src/bin/pg_resetwal/pg_resetwal.c b/src/bin/pg_resetwal/pg_resetwal.c index 634d966da9e..67e4154b168 100644 --- a/src/bin/pg_resetwal/pg_resetwal.c +++ b/src/bin/pg_resetwal/pg_resetwal.c @@ -1139,7 +1139,7 @@ KillExistingWALSummaries(void) static void WriteEmptyXLOG(void) { - PGAlignedXLogBlock buffer; + PGIOAlignedXLogBlock buffer; XLogPageHeader page; XLogLongPageHeader longpage; XLogRecord *record; diff --git a/src/bin/pg_test_fsync/pg_test_fsync.c b/src/bin/pg_test_fsync/pg_test_fsync.c index 5732d4c0de3..945e4bfc322 100644 --- a/src/bin/pg_test_fsync/pg_test_fsync.c +++ b/src/bin/pg_test_fsync/pg_test_fsync.c @@ -71,7 +71,7 @@ static const char *progname; static unsigned int secs_per_test = 5; static int needs_unlink = 0; -alignas(PGAlignedXLogBlock) static char buf[DEFAULT_XLOG_SEG_SIZE]; +alignas(PGIOAlignedXLogBlock) static char buf[DEFAULT_XLOG_SEG_SIZE]; static char *filename = FSYNC_FILENAME; static struct timeval start_t, stop_t; diff --git a/src/bin/pg_waldump/pg_waldump.c b/src/bin/pg_waldump/pg_waldump.c index 6f0574a8764..908a2080411 100644 --- a/src/bin/pg_waldump/pg_waldump.c +++ b/src/bin/pg_waldump/pg_waldump.c @@ -236,7 +236,7 @@ search_directory(const char *directory, const char *fname, int *WalSegSz) /* set WalSegSz if file is successfully opened */ if (fd >= 0) { - PGAlignedXLogBlock buf; + PGIOAlignedXLogBlock buf; ssize_t r; r = read(fd, buf.data, XLOG_BLCKSZ); diff --git a/src/include/c.h b/src/include/c.h index 367b32c5b6f..926824c6dbe 100644 --- a/src/include/c.h +++ b/src/include/c.h @@ -1318,16 +1318,16 @@ typedef struct PGIOAlignedBlock } PGIOAlignedBlock; /* Same, but for an XLOG_BLCKSZ-sized buffer */ -typedef struct PGAlignedXLogBlock +typedef struct PGIOAlignedXLogBlock { alignas(PG_IO_ALIGN_SIZE) char data[XLOG_BLCKSZ]; -} PGAlignedXLogBlock; +} PGIOAlignedXLogBlock; #else /* (g++ < 9) */ /* Allow these types to be used as abstract types when using old g++ */ typedef struct PGIOAlignedBlock PGIOAlignedBlock; -typedef struct PGAlignedXLogBlock PGAlignedXLogBlock; +typedef struct PGIOAlignedXLogBlock PGIOAlignedXLogBlock; #endif /* !(g++ < 9) */ diff --git a/src/tools/pgindent/typedefs.list b/src/tools/pgindent/typedefs.list index a7a8dbdd23f..741ccc4bd91 100644 --- a/src/tools/pgindent/typedefs.list +++ b/src/tools/pgindent/typedefs.list @@ -1912,7 +1912,6 @@ PERL_CONTEXT PERL_SI PFN PGAlignedBlock -PGAlignedXLogBlock PGAsyncStatusType PGCALL2 PGCRYPTO_SHA_t @@ -1931,6 +1930,7 @@ PGFInfoFunction PGFileType PGFunction PGIOAlignedBlock +PGIOAlignedXLogBlock PGLZ_HistEntry PGLZ_Strategy PGLoadBalanceType base-commit: e355089a57d6f480cffc2820c46fcf0b5e371cf6 -- 2.56.0