Update fsync test to match new O_DIRECT behavior.
authorBruce Momjian
Thu, 23 Nov 2006 16:41:11 +0000 (16:41 +0000)
committerBruce Momjian
Thu, 23 Nov 2006 16:41:11 +0000 (16:41 +0000)
Greg Smith

src/tools/fsync/test_fsync.c

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