diff options
Diffstat (limited to 'src/include')
| -rw-r--r-- | src/include/access/xlogdefs.h | 15 | ||||
| -rw-r--r-- | src/include/storage/fd.h | 16 |
2 files changed, 16 insertions, 15 deletions
diff --git a/src/include/access/xlogdefs.h b/src/include/access/xlogdefs.h index 0940b64ca6b..60348d18509 100644 --- a/src/include/access/xlogdefs.h +++ b/src/include/access/xlogdefs.h @@ -65,21 +65,6 @@ typedef uint32 TimeLineID; typedef uint16 RepOriginId; /* - * Because O_DIRECT bypasses the kernel buffers, and because we never - * read those buffers except during crash recovery or if wal_level != minimal, - * it is a win to use it in all cases where we sync on each write(). We could - * allow O_DIRECT with fsync(), but it is unclear if fsync() could process - * writes not buffered in the kernel. Also, O_DIRECT is never enough to force - * data to the drives, it merely tries to bypass the kernel cache, so we still - * need O_SYNC/O_DSYNC. - */ -#ifdef O_DIRECT -#define PG_O_DIRECT O_DIRECT -#else -#define PG_O_DIRECT 0 -#endif - -/* * This chunk of hackery attempts to determine which file sync methods * are available on the current platform, and to choose an appropriate * default method. We assume that fsync() is always available, and that diff --git a/src/include/storage/fd.h b/src/include/storage/fd.h index 5b3c280dd7a..2d843eb9929 100644 --- a/src/include/storage/fd.h +++ b/src/include/storage/fd.h @@ -80,6 +80,22 @@ extern int max_safe_fds; #endif /* + * O_DIRECT is not standard, but almost every Unix has it. We translate it + * to the appropriate Windows flag in src/port/open.c. We simulate it with + * fcntl(F_NOCACHE) on macOS inside fd.c's open() wrapper. We use the name + * PG_O_DIRECT rather than defining O_DIRECT in that case (probably not a good + * idea on a Unix). + */ +#if defined(O_DIRECT) +#define PG_O_DIRECT O_DIRECT +#elif defined(F_NOCACHE) +#define PG_O_DIRECT 0x80000000 +#define PG_O_DIRECT_USE_F_NOCACHE +#else +#define PG_O_DIRECT 0 +#endif + +/* * prototypes for functions in fd.c */ |
