Skip to content

Commit 3455b0a

Browse files
committed
Update fsync test to match new O_DIRECT behavior.
Greg Smith
1 parent eb1fbbe commit 3455b0a

File tree

1 file changed

+21
-7
lines changed

1 file changed

+21
-7
lines changed

src/tools/fsync/test_fsync.c

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,28 +14,42 @@
1414
#include <time.h>
1515
#include <sys/time.h>
1616
#include <unistd.h>
17+
#include <string.h>
1718

1819
#ifdef WIN32
1920
#define FSYNC_FILENAME "./test_fsync.out"
2021
#else
2122
#define FSYNC_FILENAME "/var/tmp/test_fsync.out"
2223
#endif
2324

24-
/* O_SYNC and O_FSYNC are the same */
25+
/* This logic comes from src/backend/access/transam/xlog.c where it's
26+
better documented */
27+
#ifdef O_DIRECT
28+
#define PG_O_DIRECT O_DIRECT
29+
#else
30+
#define PG_O_DIRECT 0
31+
#endif
32+
2533
#if defined(O_SYNC)
26-
#define OPEN_SYNC_FLAG O_SYNC
34+
#define BARE_OPEN_SYNC_FLAG O_SYNC
2735
#elif defined(O_FSYNC)
28-
#define OPEN_SYNC_FLAG O_FSYNC
29-
#elif defined(O_DSYNC)
30-
#define OPEN_DATASYNC_FLAG O_DSYNC
36+
#define BARE_OPEN_SYNC_FLAG O_FSYNC
37+
#endif
38+
#ifdef BARE_OPEN_SYNC_FLAG
39+
#define OPEN_SYNC_FLAG (BARE_OPEN_SYNC_FLAG | PG_O_DIRECT)
3140
#endif
3241

42+
#if defined(O_DSYNC)
3343
#if defined(OPEN_SYNC_FLAG)
34-
#if defined(O_DSYNC) && (O_DSYNC != OPEN_SYNC_FLAG)
35-
#define OPEN_DATASYNC_FLAG O_DSYNC
44+
#if O_DSYNC != BARE_OPEN_SYNC_FLAG
45+
#define OPEN_DATASYNC_FLAG (O_DSYNC | PG_O_DIRECT)
46+
#endif
47+
#else
48+
#define OPEN_DATASYNC_FLAG (O_DSYNC | PG_O_DIRECT)
3649
#endif
3750
#endif
3851

52+
3953
#define WAL_FILE_SIZE (16 * 1024 * 1024)
4054

4155
void die(char *str);

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy