Add support for syncfs() in frontend support functions.
authorNathan Bossart <nathan@postgresql.org>
Wed, 6 Sep 2023 23:27:00 +0000 (16:27 -0700)
committerNathan Bossart <nathan@postgresql.org>
Wed, 6 Sep 2023 23:27:00 +0000 (16:27 -0700)
commitcccc6cdeb32f010f1cf777a9e9a85344a4317ab8
tree989510ddcfe04a8503da11931e5c043dee189cfc
parent3ed19567198ddb34ab32be6ebdf132148287abdf
Add support for syncfs() in frontend support functions.

This commit adds support for using syncfs() in fsync_pgdata() and
fsync_dir_recurse() (which have been renamed to sync_pgdata() and
sync_dir_recurse()).  Like recovery_init_sync_method,
sync_pgdata() calls syncfs() for the data directory, each
tablespace, and pg_wal (if it is a symlink).  For now, all of the
frontend utilities that use these support functions are hard-coded
to use fsync(), but a follow-up commit will allow specifying
syncfs().

Co-authored-by: Justin Pryzby
Reviewed-by: Michael Paquier
Discussion: https://postgr.es/m/20210930004340.GM831%40telsasoft.com
13 files changed:
src/bin/initdb/initdb.c
src/bin/pg_basebackup/pg_basebackup.c
src/bin/pg_checksums/pg_checksums.c
src/bin/pg_dump/pg_backup.h
src/bin/pg_dump/pg_backup_archiver.c
src/bin/pg_dump/pg_backup_archiver.h
src/bin/pg_dump/pg_backup_directory.c
src/bin/pg_dump/pg_dump.c
src/bin/pg_rewind/file_ops.c
src/bin/pg_rewind/pg_rewind.c
src/bin/pg_rewind/pg_rewind.h
src/common/file_utils.c
src/include/common/file_utils.h