mirror of
https://github.com/postgres/postgres.git
synced 2025-10-15 05:46:52 +03:00
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
This commit is contained in:
@@ -66,7 +66,8 @@ typedef struct _parallelReadyList
|
||||
static ArchiveHandle *_allocAH(const char *FileSpec, const ArchiveFormat fmt,
|
||||
const pg_compress_specification compression_spec,
|
||||
bool dosync, ArchiveMode mode,
|
||||
SetupWorkerPtrType setupWorkerPtr);
|
||||
SetupWorkerPtrType setupWorkerPtr,
|
||||
DataDirSyncMethod sync_method);
|
||||
static void _getObjectDescription(PQExpBuffer buf, const TocEntry *te);
|
||||
static void _printTocEntry(ArchiveHandle *AH, TocEntry *te, bool isData);
|
||||
static char *sanitize_line(const char *str, bool want_hyphen);
|
||||
@@ -238,11 +239,12 @@ Archive *
|
||||
CreateArchive(const char *FileSpec, const ArchiveFormat fmt,
|
||||
const pg_compress_specification compression_spec,
|
||||
bool dosync, ArchiveMode mode,
|
||||
SetupWorkerPtrType setupDumpWorker)
|
||||
SetupWorkerPtrType setupDumpWorker,
|
||||
DataDirSyncMethod sync_method)
|
||||
|
||||
{
|
||||
ArchiveHandle *AH = _allocAH(FileSpec, fmt, compression_spec,
|
||||
dosync, mode, setupDumpWorker);
|
||||
dosync, mode, setupDumpWorker, sync_method);
|
||||
|
||||
return (Archive *) AH;
|
||||
}
|
||||
@@ -257,7 +259,8 @@ OpenArchive(const char *FileSpec, const ArchiveFormat fmt)
|
||||
|
||||
compression_spec.algorithm = PG_COMPRESSION_NONE;
|
||||
AH = _allocAH(FileSpec, fmt, compression_spec, true,
|
||||
archModeRead, setupRestoreWorker);
|
||||
archModeRead, setupRestoreWorker,
|
||||
DATA_DIR_SYNC_METHOD_FSYNC);
|
||||
|
||||
return (Archive *) AH;
|
||||
}
|
||||
@@ -2233,7 +2236,7 @@ static ArchiveHandle *
|
||||
_allocAH(const char *FileSpec, const ArchiveFormat fmt,
|
||||
const pg_compress_specification compression_spec,
|
||||
bool dosync, ArchiveMode mode,
|
||||
SetupWorkerPtrType setupWorkerPtr)
|
||||
SetupWorkerPtrType setupWorkerPtr, DataDirSyncMethod sync_method)
|
||||
{
|
||||
ArchiveHandle *AH;
|
||||
CompressFileHandle *CFH;
|
||||
@@ -2287,6 +2290,7 @@ _allocAH(const char *FileSpec, const ArchiveFormat fmt,
|
||||
AH->mode = mode;
|
||||
AH->compression_spec = compression_spec;
|
||||
AH->dosync = dosync;
|
||||
AH->sync_method = sync_method;
|
||||
|
||||
memset(&(AH->sqlparse), 0, sizeof(AH->sqlparse));
|
||||
|
||||
|
Reference in New Issue
Block a user