]> git.ipfire.org Git - thirdparty/postgresql.git/commitdiff
Change Win32 O_SYNC method to O_DSYNC because that is what the method
authorBruce Momjian <bruce@momjian.us>
Thu, 24 Mar 2005 04:37:07 +0000 (04:37 +0000)
committerBruce Momjian <bruce@momjian.us>
Thu, 24 Mar 2005 04:37:07 +0000 (04:37 +0000)
currently does.  This is now the default Win32 wal sync method because
we perfer o_datasync to fsync.

Also, change Win32 fsync to a new wal sync method called
fsync_writethrough because that is the behavior of _commit, which is
what is used for fsync on Win32.

Backpatch to 8.0.X.

doc/src/sgml/runtime.sgml
src/backend/access/transam/xlog.c
src/backend/utils/misc/postgresql.conf.sample
src/include/port/win32.h
src/port/open.c

index 40a7594bbb314238fa84d31b97244cdda041b313..300aaf2c23dcb3cf2bd1d95260c652d7d992e47b 100644 (file)
@@ -1,5 +1,5 @@
 <!--
-$PostgreSQL: pgsql/doc/src/sgml/runtime.sgml,v 1.301.4.3 2005/03/03 16:47:43 tgl Exp $
+$PostgreSQL: pgsql/doc/src/sgml/runtime.sgml,v 1.301.4.4 2005/03/24 04:36:55 momjian Exp $
 -->
 
 <chapter id="runtime">
@@ -1511,6 +1511,7 @@ SET ENABLE_SEQSCAN TO OFF;
         values are
         <literal>fsync</> (call <function>fsync()</> at each commit),
         <literal>fdatasync</> (call <function>fdatasync()</> at each commit),
+        <literal>fsync_writethrough</> (call <function>_commit()</> at each commit on Windows),
         <literal>open_sync</> (write WAL files with <function>open()</> option <symbol>O_SYNC</>), and
         <literal>open_datasync</> (write WAL files with <function>open()</> option <symbol>O_DSYNC</>).
         Not all of these choices are available on all platforms.
index ec00dbd11f560c6ae101391c42dafd02d85720c4..fad0927ac6f803d5b0af95250d1e9850fe723d22 100644 (file)
@@ -7,7 +7,7 @@
  * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- * $PostgreSQL: pgsql/src/backend/access/transam/xlog.c,v 1.180 2004/12/31 21:59:30 pgsql Exp $
+ * $PostgreSQL: pgsql/src/backend/access/transam/xlog.c,v 1.180.4.1 2005/03/24 04:36:57 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
 #endif
 #endif
 
+#if defined(O_DSYNC)
 #if defined(OPEN_SYNC_FLAG)
-#if defined(O_DSYNC) && (O_DSYNC != OPEN_SYNC_FLAG)
+#if O_DSYNC != OPEN_SYNC_FLAG
+#define OPEN_DATASYNC_FLAG       O_DSYNC
+#endif
+#else /* !defined(OPEN_SYNC_FLAG) */
+/* Win32 only has O_DSYNC */
 #define OPEN_DATASYNC_FLAG       O_DSYNC
 #endif
 #endif
 #define DEFAULT_SYNC_METHOD              SYNC_METHOD_FDATASYNC
 #define DEFAULT_SYNC_FLAGBIT     0
 #else
+#ifndef FSYNC_IS_WRITE_THROUGH
 #define DEFAULT_SYNC_METHOD_STR   "fsync"
+#else
+#define DEFAULT_SYNC_METHOD_STR   "fsync_writethrough"
+#endif
 #define DEFAULT_SYNC_METHOD              SYNC_METHOD_FSYNC
 #define DEFAULT_SYNC_FLAGBIT     0
 #endif
@@ -5154,7 +5163,12 @@ assign_xlog_sync_method(const char *method, bool doit, GucSource source)
        int                     new_sync_method;
        int                     new_sync_bit;
 
+#ifndef FSYNC_IS_WRITE_THROUGH
        if (pg_strcasecmp(method, "fsync") == 0)
+#else
+       /* Win32 fsync() == _commit(0, which writes through a write cache */
+       if (pg_strcasecmp(method, "fsync_writethrough") == 0)
+#endif
        {
                new_sync_method = SYNC_METHOD_FSYNC;
                new_sync_bit = 0;
index 86640efa7da7b2ec818f7b815f808c89d77dcdda..6a3a699c1cc77756fb41b6dfa4864f0b3d18c264 100644 (file)
 
 #fsync = true                  # turns forced synchronization on or off
 #wal_sync_method = fsync       # the default varies across platforms:
-                               # fsync, fdatasync, open_sync, or open_datasync
+                               # fsync, fdatasync, fsync_writethrough,
+                               # open_sync, open_datasync
 #wal_buffers = 8               # min 4, 8KB each
 #commit_delay = 0              # range 0-100000, in microseconds
 #commit_siblings = 5           # range 1-1000
index f93058edc0703231b395d56c0516379f17d3ba5e..3a5df0eac84df8c03f55c1bd5f7e8098ece1afcc 100644 (file)
@@ -1,4 +1,4 @@
-/* $PostgreSQL: pgsql/src/include/port/win32.h,v 1.42.4.1 2005/03/17 17:28:59 momjian Exp $ */
+/* $PostgreSQL: pgsql/src/include/port/win32.h,v 1.42.4.2 2005/03/24 04:37:01 momjian Exp $ */
 
 /* undefine and redefine after #include */
 #undef mkdir
@@ -17,6 +17,7 @@
 
 
 #define fsync(a)       _commit(a)
+#define FSYNC_IS_WRITE_THROUGH
 #define ftruncate(a,b) chsize(a,b)
 
 #define USES_WINSOCK
@@ -189,7 +190,7 @@ typedef int pid_t;
  * to ensure that we don't collide with a future definition. It means
  * we cannot use _O_NOINHERIT ourselves.
  */
-#define O_SYNC 0x0080
+#define O_DSYNC 0x0080
 
 /*
  * Supplement to <errno.h>.
index 3ff6b0e2ddaaeb2e03e5759dcddcf90b875bf989..fcf35ce2604ed1f62810654d644e3692bb139545 100644 (file)
@@ -6,7 +6,7 @@
  *
  * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group
  *
- * $PostgreSQL: pgsql/src/port/open.c,v 1.7.4.1 2005/03/17 17:28:59 momjian Exp $
+ * $PostgreSQL: pgsql/src/port/open.c,v 1.7.4.2 2005/03/24 04:37:07 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -63,7 +63,7 @@ win32_open(const char *fileName, int fileFlags,...)
        /* Check that we can handle the request */
        assert((fileFlags & ((O_RDONLY | O_WRONLY | O_RDWR) | O_APPEND |
                                                 (O_RANDOM | O_SEQUENTIAL | O_TEMPORARY) |
-                                                _O_SHORT_LIVED | O_SYNC |
+                                                _O_SHORT_LIVED | O_DSYNC |
          (O_CREAT | O_TRUNC | O_EXCL) | (O_TEXT | O_BINARY))) == fileFlags);
 
        sa.nLength = sizeof(sa);
@@ -83,7 +83,7 @@ win32_open(const char *fileName, int fileFlags,...)
                   ((fileFlags & O_SEQUENTIAL) ? FILE_FLAG_SEQUENTIAL_SCAN : 0) |
                  ((fileFlags & _O_SHORT_LIVED) ? FILE_ATTRIBUTE_TEMPORARY : 0) |
                         ((fileFlags & O_TEMPORARY) ? FILE_FLAG_DELETE_ON_CLOSE : 0)|
-                                       ((fileFlags & O_SYNC) ? FILE_FLAG_WRITE_THROUGH : 0),
+                                       ((fileFlags & O_DSYNC) ? FILE_FLAG_WRITE_THROUGH : 0),
                                                NULL)) == INVALID_HANDLE_VALUE)
        {
                switch (GetLastError())