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

Commita1b5609

Browse files
committed
Remove O_FSYNC and associated macros.
O_FSYNC was a pre-POSIX way of spelling O_SYNC, supported since commit9d645fd for non-conforming operating systems of the time. It's notneeded on any modern system. We can just use standard O_SYNC directlyif it exists (= all targeted systems except Windows), and get rid of ourOPEN_SYNC_FLAG macro.Similarly for standard O_DSYNC, we can just use that directly if itexists (= all targeted systems except DragonFlyBSD), and get rid of ourOPEN_DATASYNC_FLAG macro.We still avoid choosing open_datasync as a default value forwal_sync_method if O_DSYNC has the same value as O_SYNC (= onlyOpenBSD), so there is no change in default behavior.Discussion:https://postgr.es/m/CA%2BhUKGJE7y92NY7FG2ftUbZUaqohBU65_Ys_7xF5mUHo4wirTQ%40mail.gmail.com
1 parent4f1f5a7 commita1b5609

File tree

3 files changed

+19
-35
lines changed

3 files changed

+19
-35
lines changed

‎src/backend/access/transam/xlog.c

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -171,10 +171,10 @@ const struct config_enum_entry sync_method_options[] = {
171171
#ifdefHAVE_FDATASYNC
172172
{"fdatasync",SYNC_METHOD_FDATASYNC, false},
173173
#endif
174-
#ifdefOPEN_SYNC_FLAG
174+
#ifdefO_SYNC
175175
{"open_sync",SYNC_METHOD_OPEN, false},
176176
#endif
177-
#ifdefOPEN_DATASYNC_FLAG
177+
#ifdefO_DSYNC
178178
{"open_datasync",SYNC_METHOD_OPEN_DSYNC, false},
179179
#endif
180180
{NULL,0, false}
@@ -7894,10 +7894,10 @@ get_sync_bit(int method)
78947894

78957895
/*
78967896
* Optimize writes by bypassing kernel cache with O_DIRECT when using
7897-
* O_SYNC/O_FSYNC and O_DSYNC. But only if archiving and streaming are
7898-
*disabled,otherwise the archive command or walsender process will read
7899-
*the WALsoon after writing it, which is guaranteed to cause a physical
7900-
*read ifwe bypassed the kernel cache. We also skip the
7897+
* O_SYNC and O_DSYNC. But only if archiving and streaming are disabled,
7898+
* otherwise the archive command or walsender process will read the WAL
7899+
* soon after writing it, which is guaranteed to cause a physical read if
7900+
* we bypassed the kernel cache. We also skip the
79017901
* posix_fadvise(POSIX_FADV_DONTNEED) call in XLogFileClose() for the same
79027902
* reason.
79037903
*
@@ -7921,13 +7921,13 @@ get_sync_bit(int method)
79217921
caseSYNC_METHOD_FSYNC_WRITETHROUGH:
79227922
caseSYNC_METHOD_FDATASYNC:
79237923
return0;
7924-
#ifdefOPEN_SYNC_FLAG
7924+
#ifdefO_SYNC
79257925
caseSYNC_METHOD_OPEN:
7926-
returnOPEN_SYNC_FLAG |o_direct_flag;
7926+
returnO_SYNC |o_direct_flag;
79277927
#endif
7928-
#ifdefOPEN_DATASYNC_FLAG
7928+
#ifdefO_DSYNC
79297929
caseSYNC_METHOD_OPEN_DSYNC:
7930-
returnOPEN_DATASYNC_FLAG |o_direct_flag;
7930+
returnO_DSYNC |o_direct_flag;
79317931
#endif
79327932
default:
79337933
/* can't happen (unless we are out of sync with option array) */

‎src/bin/pg_test_fsync/pg_test_fsync.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,7 @@ test_sync(int writes_per_op)
300300
printf(LABEL_FORMAT,"open_datasync");
301301
fflush(stdout);
302302

303-
#ifdefOPEN_DATASYNC_FLAG
303+
#ifdefO_DSYNC
304304
if ((tmpfile=open_direct(filename,O_RDWR |O_DSYNC |PG_BINARY,0))==-1)
305305
{
306306
printf(NA_FORMAT,_("n/a*"));
@@ -407,8 +407,8 @@ test_sync(int writes_per_op)
407407
printf(LABEL_FORMAT,"open_sync");
408408
fflush(stdout);
409409

410-
#ifdefOPEN_SYNC_FLAG
411-
if ((tmpfile=open_direct(filename,O_RDWR |OPEN_SYNC_FLAG |PG_BINARY,0))==-1)
410+
#ifdefO_SYNC
411+
if ((tmpfile=open_direct(filename,O_RDWR |O_SYNC |PG_BINARY,0))==-1)
412412
{
413413
printf(NA_FORMAT,_("n/a*"));
414414
fs_warning= true;
@@ -466,7 +466,7 @@ test_open_syncs(void)
466466
staticvoid
467467
test_open_sync(constchar*msg,intwrites_size)
468468
{
469-
#ifdefOPEN_SYNC_FLAG
469+
#ifdefO_SYNC
470470
inttmpfile,
471471
ops,
472472
writes;
@@ -475,8 +475,8 @@ test_open_sync(const char *msg, int writes_size)
475475
printf(LABEL_FORMAT,msg);
476476
fflush(stdout);
477477

478-
#ifdefOPEN_SYNC_FLAG
479-
if ((tmpfile=open_direct(filename,O_RDWR |OPEN_SYNC_FLAG |PG_BINARY,0))==-1)
478+
#ifdefO_SYNC
479+
if ((tmpfile=open_direct(filename,O_RDWR |O_SYNC |PG_BINARY,0))==-1)
480480
printf(NA_FORMAT,_("n/a*"));
481481
else
482482
{

‎src/include/access/xlogdefs.h

Lines changed: 3 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -69,28 +69,12 @@ typedef uint16 RepOriginId;
6969
* are available on the current platform, and to choose an appropriate
7070
* default method. We assume that fsync() is always available, and that
7171
* configure determined whether fdatasync() is.
72+
*
73+
* Note that we define our own O_DSYNC on Windows, but not O_SYNC.
7274
*/
73-
#if defined(O_SYNC)
74-
#defineOPEN_SYNC_FLAGO_SYNC
75-
#elif defined(O_FSYNC)
76-
#defineOPEN_SYNC_FLAGO_FSYNC
77-
#endif
78-
79-
#if defined(O_DSYNC)
80-
#if defined(OPEN_SYNC_FLAG)
81-
/* O_DSYNC is distinct? */
82-
#ifO_DSYNC!=OPEN_SYNC_FLAG
83-
#defineOPEN_DATASYNC_FLAGO_DSYNC
84-
#endif
85-
#else/* !defined(OPEN_SYNC_FLAG) */
86-
/* Win32 only has O_DSYNC */
87-
#defineOPEN_DATASYNC_FLAGO_DSYNC
88-
#endif
89-
#endif
90-
9175
#if defined(PLATFORM_DEFAULT_SYNC_METHOD)
9276
#defineDEFAULT_SYNC_METHODPLATFORM_DEFAULT_SYNC_METHOD
93-
#elif defined(OPEN_DATASYNC_FLAG)
77+
#elif defined(O_DSYNC)&& (!defined(O_SYNC)||O_DSYNC!=O_SYNC)
9478
#defineDEFAULT_SYNC_METHODSYNC_METHOD_OPEN_DSYNC
9579
#elif defined(HAVE_FDATASYNC)
9680
#defineDEFAULT_SYNC_METHODSYNC_METHOD_FDATASYNC

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp