Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 3ed1956

Browse files
Make enum for sync methods available to frontend code.
This commit renames RecoveryInitSyncMethod to DataDirSyncMethod and moves it to common/file_utils.h. This is preparatory work for a follow-up commit that will allow specifying the synchronization method in frontend utilities such as pg_upgrade and pg_basebackup. Reviewed-by: Michael Paquier Discussion: https://postgr.es/m/ZN2ZB4afQ2JbR9TA%40paquier.xyz
1 parent 059e4ee commit 3ed1956

File tree

5 files changed

+13
-11
lines changed

5 files changed

+13
-11
lines changed

src/backend/storage/file/fd.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ int max_safe_fds = FD_MINFREE; /* default if not changed */
162162
bool data_sync_retry = false;
163163

164164
/* How SyncDataDirectory() should do its job. */
165-
int recovery_init_sync_method = RECOVERY_INIT_SYNC_METHOD_FSYNC;
165+
int recovery_init_sync_method = DATA_DIR_SYNC_METHOD_FSYNC;
166166

167167
/* Which kinds of files should be opened with PG_O_DIRECT. */
168168
int io_direct_flags;
@@ -3513,7 +3513,7 @@ SyncDataDirectory(void)
35133513
}
35143514

35153515
#ifdef HAVE_SYNCFS
3516-
if (recovery_init_sync_method == RECOVERY_INIT_SYNC_METHOD_SYNCFS)
3516+
if (recovery_init_sync_method == DATA_DIR_SYNC_METHOD_SYNCFS)
35173517
{
35183518
DIR *dir;
35193519
struct dirent *de;

src/backend/utils/misc/guc_tables.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
#include "commands/trigger.h"
4242
#include "commands/user.h"
4343
#include "commands/vacuum.h"
44+
#include "common/file_utils.h"
4445
#include "common/scram-common.h"
4546
#include "jit/jit.h"
4647
#include "libpq/auth.h"
@@ -430,9 +431,9 @@ StaticAssertDecl(lengthof(ssl_protocol_versions_info) == (PG_TLS1_3_VERSION + 2)
430431
"array length mismatch");
431432

432433
static const struct config_enum_entry recovery_init_sync_method_options[] = {
433-
{"fsync", RECOVERY_INIT_SYNC_METHOD_FSYNC, false},
434+
{"fsync", DATA_DIR_SYNC_METHOD_FSYNC, false},
434435
#ifdef HAVE_SYNCFS
435-
{"syncfs", RECOVERY_INIT_SYNC_METHOD_SYNCFS, false},
436+
{"syncfs", DATA_DIR_SYNC_METHOD_SYNCFS, false},
436437
#endif
437438
{NULL, 0, false}
438439
};
@@ -4953,7 +4954,7 @@ struct config_enum ConfigureNamesEnum[] =
49534954
gettext_noop("Sets the method for synchronizing the data directory before crash recovery."),
49544955
},
49554956
&recovery_init_sync_method,
4956-
RECOVERY_INIT_SYNC_METHOD_FSYNC, recovery_init_sync_method_options,
4957+
DATA_DIR_SYNC_METHOD_FSYNC, recovery_init_sync_method_options,
49574958
NULL, NULL, NULL
49584959
},
49594960

src/include/common/file_utils.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,12 @@ typedef enum PGFileType
2424
PGFILETYPE_LNK
2525
} PGFileType;
2626

27+
typedef enum DataDirSyncMethod
28+
{
29+
DATA_DIR_SYNC_METHOD_FSYNC,
30+
DATA_DIR_SYNC_METHOD_SYNCFS
31+
} DataDirSyncMethod;
32+
2733
struct iovec; /* avoid including port/pg_iovec.h here */
2834

2935
#ifdef FRONTEND

src/include/storage/fd.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,6 @@
4646
#include <dirent.h>
4747
#include <fcntl.h>
4848

49-
typedef enum RecoveryInitSyncMethod
50-
{
51-
RECOVERY_INIT_SYNC_METHOD_FSYNC,
52-
RECOVERY_INIT_SYNC_METHOD_SYNCFS
53-
} RecoveryInitSyncMethod;
54-
5549
typedef int File;
5650

5751

src/tools/pgindent/typedefs.list

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -545,6 +545,7 @@ DR_printtup
545545
DR_sqlfunction
546546
DR_transientrel
547547
DWORD
548+
DataDirSyncMethod
548549
DataDumperPtr
549550
DataPageDeleteStack
550551
DatabaseInfo

0 commit comments

Comments
 (0)