1
0
mirror of https://github.com/postgres/postgres.git synced 2025-09-02 04:21:28 +03:00

Update fsync test to match new O_DIRECT behavior.

Greg Smith
This commit is contained in:
Bruce Momjian
2006-11-23 16:41:11 +00:00
parent eb1fbbe5c4
commit 3455b0a5d5

View File

@@ -14,6 +14,7 @@
#include <time.h> #include <time.h>
#include <sys/time.h> #include <sys/time.h>
#include <unistd.h> #include <unistd.h>
#include <string.h>
#ifdef WIN32 #ifdef WIN32
#define FSYNC_FILENAME "./test_fsync.out" #define FSYNC_FILENAME "./test_fsync.out"
@@ -21,21 +22,34 @@
#define FSYNC_FILENAME "/var/tmp/test_fsync.out" #define FSYNC_FILENAME "/var/tmp/test_fsync.out"
#endif #endif
/* O_SYNC and O_FSYNC are the same */ /* This logic comes from src/backend/access/transam/xlog.c where it's
#if defined(O_SYNC) better documented */
#define OPEN_SYNC_FLAG O_SYNC #ifdef O_DIRECT
#elif defined(O_FSYNC) #define PG_O_DIRECT O_DIRECT
#define OPEN_SYNC_FLAG O_FSYNC #else
#elif defined(O_DSYNC) #define PG_O_DIRECT 0
#define OPEN_DATASYNC_FLAG O_DSYNC
#endif #endif
#if defined(O_SYNC)
#define BARE_OPEN_SYNC_FLAG O_SYNC
#elif defined(O_FSYNC)
#define BARE_OPEN_SYNC_FLAG O_FSYNC
#endif
#ifdef BARE_OPEN_SYNC_FLAG
#define OPEN_SYNC_FLAG (BARE_OPEN_SYNC_FLAG | PG_O_DIRECT)
#endif
#if defined(O_DSYNC)
#if defined(OPEN_SYNC_FLAG) #if defined(OPEN_SYNC_FLAG)
#if defined(O_DSYNC) && (O_DSYNC != OPEN_SYNC_FLAG) #if O_DSYNC != BARE_OPEN_SYNC_FLAG
#define OPEN_DATASYNC_FLAG O_DSYNC #define OPEN_DATASYNC_FLAG (O_DSYNC | PG_O_DIRECT)
#endif
#else
#define OPEN_DATASYNC_FLAG (O_DSYNC | PG_O_DIRECT)
#endif #endif
#endif #endif
#define WAL_FILE_SIZE (16 * 1024 * 1024) #define WAL_FILE_SIZE (16 * 1024 * 1024)
void die(char *str); void die(char *str);