diff options
author | Nathan Bossart | 2023-09-06 23:27:00 +0000 |
---|---|---|
committer | Nathan Bossart | 2023-09-06 23:27:00 +0000 |
commit | cccc6cdeb32f010f1cf777a9e9a85344a4317ab8 (patch) | |
tree | 989510ddcfe04a8503da11931e5c043dee189cfc /src/bin/initdb/initdb.c | |
parent | 3ed19567198ddb34ab32be6ebdf132148287abdf (diff) |
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
Diffstat (limited to 'src/bin/initdb/initdb.c')
-rw-r--r-- | src/bin/initdb/initdb.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/src/bin/initdb/initdb.c b/src/bin/initdb/initdb.c index 905b979947f..51198e66655 100644 --- a/src/bin/initdb/initdb.c +++ b/src/bin/initdb/initdb.c @@ -165,6 +165,7 @@ static bool show_setting = false; static bool data_checksums = false; static char *xlog_dir = NULL; static int wal_segment_size_mb = (DEFAULT_XLOG_SEG_SIZE) / (1024 * 1024); +static DataDirSyncMethod sync_method = DATA_DIR_SYNC_METHOD_FSYNC; /* internal vars */ @@ -3322,7 +3323,7 @@ main(int argc, char *argv[]) atexit(cleanup_directories_atexit); - /* If we only need to fsync, just do it and exit */ + /* If we only need to sync, just do it and exit */ if (sync_only) { setup_pgdata(); @@ -3333,7 +3334,7 @@ main(int argc, char *argv[]) fputs(_("syncing data to disk ... "), stdout); fflush(stdout); - fsync_pgdata(pg_data, PG_VERSION_NUM); + sync_pgdata(pg_data, PG_VERSION_NUM, sync_method); check_ok(); return 0; } @@ -3396,7 +3397,7 @@ main(int argc, char *argv[]) { fputs(_("syncing data to disk ... "), stdout); fflush(stdout); - fsync_pgdata(pg_data, PG_VERSION_NUM); + sync_pgdata(pg_data, PG_VERSION_NUM, sync_method); check_ok(); } else |