Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitffb4e27

Browse files
committed
pg_rewind: Move syncTargetDirectory() to file_ops.c
For consistency. All the other low-level functions that operate on thetarget directory are in file_ops.c.Reviewed-by: Michael PaquierDiscussion:https://www.postgresql.org/message-id/0c5b3783-af52-3ee5-f8fa-6e794061f70d%40iki.fi
1 parentac22929 commitffb4e27

File tree

4 files changed

+22
-21
lines changed

4 files changed

+22
-21
lines changed

‎src/bin/pg_rewind/file_ops.c

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#include<unistd.h>
2020

2121
#include"common/file_perm.h"
22+
#include"common/file_utils.h"
2223
#include"file_ops.h"
2324
#include"filemap.h"
2425
#include"pg_rewind.h"
@@ -266,6 +267,24 @@ remove_target_symlink(const char *path)
266267
dstpath);
267268
}
268269

270+
/*
271+
* Sync target data directory to ensure that modifications are safely on disk.
272+
*
273+
* We do this once, for the whole data directory, for performance reasons. At
274+
* the end of pg_rewind's run, the kernel is likely to already have flushed
275+
* most dirty buffers to disk. Additionally fsync_pgdata uses a two-pass
276+
* approach (only initiating writeback in the first pass), which often reduces
277+
* the overall amount of IO noticeably.
278+
*/
279+
void
280+
sync_target_dir(void)
281+
{
282+
if (!do_sync||dry_run)
283+
return;
284+
285+
fsync_pgdata(datadir_target,PG_VERSION_NUM);
286+
}
287+
269288

270289
/*
271290
* Read a file into memory. The file to be read is <datadir>/<path>.

‎src/bin/pg_rewind/file_ops.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ extern void remove_target_file(const char *path, bool missing_ok);
1919
externvoidtruncate_target_file(constchar*path,off_tnewsize);
2020
externvoidcreate_target(file_entry_t*t);
2121
externvoidremove_target(file_entry_t*t);
22+
externvoidsync_target_dir(void);
2223

2324
externchar*slurpFile(constchar*datadir,constchar*path,size_t*filesize);
2425

‎src/bin/pg_rewind/pg_rewind.c

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
#include"catalog/pg_control.h"
2121
#include"common/controldata_utils.h"
2222
#include"common/file_perm.h"
23-
#include"common/file_utils.h"
2423
#include"common/restricted_token.h"
2524
#include"common/string.h"
2625
#include"fe_utils/recovery_gen.h"
@@ -38,7 +37,6 @@ static void createBackupLabel(XLogRecPtr startpoint, TimeLineID starttli,
3837

3938
staticvoiddigestControlFile(ControlFileData*ControlFile,char*source,
4039
size_tsize);
41-
staticvoidsyncTargetDirectory(void);
4240
staticvoidgetRestoreCommand(constchar*argv0);
4341
staticvoidsanityChecks(void);
4442
staticvoidfindCommonAncestorTimeline(XLogRecPtr*recptr,int*tliIndex);
@@ -455,7 +453,7 @@ main(int argc, char **argv)
455453

456454
if (showprogress)
457455
pg_log_info("syncing target data directory");
458-
syncTargetDirectory();
456+
sync_target_dir();
459457

460458
if (writerecoveryconf&& !dry_run)
461459
WriteRecoveryConfig(conn,datadir_target,
@@ -803,24 +801,6 @@ digestControlFile(ControlFileData *ControlFile, char *src, size_t size)
803801
checkControlFile(ControlFile);
804802
}
805803

806-
/*
807-
* Sync target data directory to ensure that modifications are safely on disk.
808-
*
809-
* We do this once, for the whole data directory, for performance reasons. At
810-
* the end of pg_rewind's run, the kernel is likely to already have flushed
811-
* most dirty buffers to disk. Additionally fsync_pgdata uses a two-pass
812-
* approach (only initiating writeback in the first pass), which often reduces
813-
* the overall amount of IO noticeably.
814-
*/
815-
staticvoid
816-
syncTargetDirectory(void)
817-
{
818-
if (!do_sync||dry_run)
819-
return;
820-
821-
fsync_pgdata(datadir_target,PG_VERSION_NUM);
822-
}
823-
824804
/*
825805
* Get value of GUC parameter restore_command from the target cluster.
826806
*

‎src/bin/pg_rewind/pg_rewind.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ extern char *datadir_source;
2424
externchar*connstr_source;
2525
externboolshowprogress;
2626
externbooldry_run;
27+
externbooldo_sync;
2728
externintWalSegSz;
2829

2930
/* Target history */

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp