Introduce pg_pwrite_zeros() in fileutils.c

Michael Paquier <michael@paquier.xyz>

Commit: 3bdbdf5d06f2179d4c17926d77ff734ea9e7d525
Author: Michael Paquier <michael@paquier.xyz>
Date: 2022-11-08T03:23:46Z
Releases: 16.0
Introduce pg_pwrite_zeros() in fileutils.c

This routine is designed to write zeros to a file using vectored I/O,
for a size given by its caller, being useful when it comes to
initializing a file with a final size already known.

XLogFileInitInternal() in xlog.c is changed to use this new routine when
initializing WAL segments with zeros (wal_init_zero enabled).  Note that
the aligned buffers used for the vectored I/O writes have a size of
XLOG_BLCKSZ, and not BLCKSZ anymore, as pg_pwrite_zeros() relies on
PGAlignedBlock while xlog.c originally used PGAlignedXLogBlock.

This routine will be used in a follow-up patch to do the pre-padding of
WAL segments for pg_receivewal and pg_basebackup when these are not
compressed.

Author: Bharath Rupireddy
Reviewed-by: Nathan Bossart, Andres Freund, Thomas Munro, Michael
Paquier
Discussion: https://www.postgresql.org/message-id/CALj2ACUq7nAb7%3DbJNbK3yYmp-SZhJcXFR_pLk8un6XgDzDF3OA%40mail.gmail.com

Files

PathChange+/−
src/backend/access/transam/xlog.c modified +5 −28
src/common/file_utils.c modified +73 −0
src/include/common/file_utils.h modified +2 −0

Discussion