1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-09 22:41:56 +03:00

pg_rewind: Move syncTargetDirectory() to file_ops.c

For consistency. All the other low-level functions that operate on the
target directory are in file_ops.c.

Reviewed-by: Michael Paquier
Discussion: https://www.postgresql.org/message-id/0c5b3783-af52-3ee5-f8fa-6e794061f70d%40iki.fi
This commit is contained in:
Heikki Linnakangas
2020-11-04 10:38:39 +02:00
parent ac22929a26
commit ffb4e27e9c
4 changed files with 22 additions and 21 deletions

View File

@ -19,6 +19,7 @@
#include <unistd.h>
#include "common/file_perm.h"
#include "common/file_utils.h"
#include "file_ops.h"
#include "filemap.h"
#include "pg_rewind.h"
@ -266,6 +267,24 @@ remove_target_symlink(const char *path)
dstpath);
}
/*
* Sync target data directory to ensure that modifications are safely on disk.
*
* We do this once, for the whole data directory, for performance reasons. At
* the end of pg_rewind's run, the kernel is likely to already have flushed
* most dirty buffers to disk. Additionally fsync_pgdata uses a two-pass
* approach (only initiating writeback in the first pass), which often reduces
* the overall amount of IO noticeably.
*/
void
sync_target_dir(void)
{
if (!do_sync || dry_run)
return;
fsync_pgdata(datadir_target, PG_VERSION_NUM);
}
/*
* Read a file into memory. The file to be read is <datadir>/<path>.