|
7 | 7 | * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group
|
8 | 8 | * Portions Copyright (c) 1994, Regents of the University of California
|
9 | 9 | *
|
10 |
| - * $PostgreSQL: pgsql/src/backend/access/transam/xlog.c,v 1.208 2005/07/08 04:07:26 tgl Exp $ |
| 10 | + * $PostgreSQL: pgsql/src/backend/access/transam/xlog.c,v 1.209 2005/07/23 15:29:47 momjian Exp $ |
11 | 11 | *
|
12 | 12 | *-------------------------------------------------------------------------
|
13 | 13 | */
|
|
47 | 47 | #include "utils/relcache.h"
|
48 | 48 |
|
49 | 49 |
|
| 50 | +/* |
| 51 | + * Becauase O_DIRECT bypasses the kernel buffers, and because we never |
| 52 | + * read those buffers except during crash recovery, it seems like |
| 53 | + * a win to use it in all cases. |
| 54 | + */ |
| 55 | +#ifdef O_DIRECT |
| 56 | +#define PG_O_DIRECT O_DIR(enableFsync ? (open_sync_bit | O_DIRECT) : 0) |
| 57 | +#else |
| 58 | + |
50 | 59 | /*
|
51 | 60 | * This chunk of hackery attempts to determine which file sync methods
|
52 | 61 | * are available on the current platform, and to choose an appropriate
|
53 | 62 | * default method. We assume that fsync() is always available, and that
|
54 | 63 | * configure determined whether fdatasync() is.
|
55 | 64 | */
|
56 | 65 | #if defined(O_SYNC)
|
57 |
| -#define OPEN_SYNC_FLAG O_SYNC |
| 66 | +#define OPEN_SYNC_FLAG O_SYNC |
58 | 67 | #else
|
59 | 68 | #if defined(O_FSYNC)
|
60 |
| -#define OPEN_SYNC_FLAG O_FSYNC |
| 69 | +#define OPEN_SYNC_FLAG O_FSYNC |
61 | 70 | #endif
|
62 | 71 | #endif
|
63 | 72 |
|
64 | 73 | #if defined(O_DSYNC)
|
65 | 74 | #if defined(OPEN_SYNC_FLAG)
|
66 | 75 | #if O_DSYNC != OPEN_SYNC_FLAG
|
67 |
| -#define OPEN_DATASYNC_FLAG O_DSYNC |
| 76 | +#define OPEN_DATASYNC_FLAG O_DSYNC |
68 | 77 | #endif
|
69 | 78 | #else /* !defined(OPEN_SYNC_FLAG) */
|
70 | 79 | /* Win32 only has O_DSYNC */
|
71 |
| -#define OPEN_DATASYNC_FLAG O_DSYNC |
| 80 | +#define OPEN_DATASYNC_FLAG O_DSYNC |
72 | 81 | #endif
|
73 | 82 | #endif
|
74 | 83 |
|
75 | 84 | #if defined(OPEN_DATASYNC_FLAG)
|
76 |
| -#define DEFAULT_SYNC_METHOD_STR "open_datasync" |
77 |
| -#define DEFAULT_SYNC_METHOD SYNC_METHOD_OPEN |
78 |
| -#define DEFAULT_SYNC_FLAGBIT OPEN_DATASYNC_FLAG |
| 85 | +#define DEFAULT_SYNC_METHOD_STR "open_datasync" |
| 86 | +#define DEFAULT_SYNC_METHOD SYNC_METHOD_OPEN |
| 87 | +#define DEFAULT_SYNC_FLAGBIT OPEN_DATASYNC_FLAG |
79 | 88 | #elif defined(HAVE_FDATASYNC)
|
80 |
| -#define DEFAULT_SYNC_METHOD_STR "fdatasync" |
81 |
| -#define DEFAULT_SYNC_METHOD SYNC_METHOD_FDATASYNC |
82 |
| -#define DEFAULT_SYNC_FLAGBIT 0 |
| 89 | +#define DEFAULT_SYNC_METHOD_STR "fdatasync" |
| 90 | +#define DEFAULT_SYNC_METHOD SYNC_METHOD_FDATASYNC |
| 91 | +#define DEFAULT_SYNC_FLAGBIT 0 |
83 | 92 | #elif !defined(HAVE_FSYNC_WRITETHROUGH_ONLY)
|
84 |
| -#define DEFAULT_SYNC_METHOD_STR "fsync" |
85 |
| -#define DEFAULT_SYNC_METHOD SYNC_METHOD_FSYNC |
86 |
| -#define DEFAULT_SYNC_FLAGBIT 0 |
| 93 | +#define DEFAULT_SYNC_METHOD_STR "fsync" |
| 94 | +#define DEFAULT_SYNC_METHOD SYNC_METHOD_FSYNC |
| 95 | +#define DEFAULT_SYNC_FLAGBIT 0 |
87 | 96 | #else
|
88 |
| -#define DEFAULT_SYNC_METHOD_STR "fsync_writethrough" |
89 |
| -#define DEFAULT_SYNC_METHOD SYNC_METHOD_FSYNC_WRITETHROUGH |
90 |
| -#define DEFAULT_SYNC_FLAGBIT 0 |
| 97 | +#define DEFAULT_SYNC_METHOD_STR "fsync_writethrough" |
| 98 | +#define DEFAULT_SYNC_METHOD SYNC_METHOD_FSYNC_WRITETHROUGH |
| 99 | +#define DEFAULT_SYNC_FLAGBIT 0 |
91 | 100 | #endif
|
92 | 101 |
|
93 | 102 |
|
|
0 commit comments