diff options
| author | Thomas Munro <tmunro@postgresql.org> | 2022-07-20 13:50:57 +1200 |
|---|---|---|
| committer | Thomas Munro <tmunro@postgresql.org> | 2022-07-20 13:55:52 +1200 |
| commit | 9430fb407bb64cc842e56fb5844265a9343dafba (patch) | |
| tree | a241a5a72a450498c746d8b2a0e8d8f25f741b4b /src/include | |
| parent | b24b2be119c4cccceae838b62a3519a6d70b9476 (diff) | |
Add wal_sync_method=fdatasync for Windows.
Windows 10 gained support for flushing NTFS files with fdatasync()
semantics. The main advantage over open_datasync (in Windows API terms
FILE_FLAG_WRITE_THROUGH) is that the latter does not flush SATA drive
caches. The default setting is not changed, so users have to opt in to
this.
Discussion: https://postgr.es/m/CA%2BhUKGJZJVO%3DiX%2Beb-PXi2_XS9ZRqnn_4URh0NUQOwt6-_51xQ%40mail.gmail.com
Diffstat (limited to 'src/include')
| -rw-r--r-- | src/include/c.h | 2 | ||||
| -rw-r--r-- | src/include/port/win32_port.h | 6 | ||||
| -rw-r--r-- | src/include/port/win32ntdll.h | 10 |
3 files changed, 16 insertions, 2 deletions
diff --git a/src/include/c.h b/src/include/c.h index 2cc2784750e..d35405f191a 100644 --- a/src/include/c.h +++ b/src/include/c.h @@ -1290,7 +1290,7 @@ typedef union PGAlignedXLogBlock * standard C library. */ -#if defined(HAVE_FDATASYNC) && !HAVE_DECL_FDATASYNC +#if !HAVE_DECL_FDATASYNC extern int fdatasync(int fildes); #endif diff --git a/src/include/port/win32_port.h b/src/include/port/win32_port.h index 5121c0c626e..5ea66528fad 100644 --- a/src/include/port/win32_port.h +++ b/src/include/port/win32_port.h @@ -83,6 +83,12 @@ #define HAVE_FSYNC_WRITETHROUGH #define FSYNC_WRITETHROUGH_IS_FSYNC +/* + * We have a replacement for fdatasync() in src/port/fdatasync.c, which is + * unconditionally used by MSVC and Mingw builds. + */ +#define HAVE_FDATASYNC + #define USES_WINSOCK /* diff --git a/src/include/port/win32ntdll.h b/src/include/port/win32ntdll.h index 291b067ea4f..34cebddd542 100644 --- a/src/include/port/win32ntdll.h +++ b/src/include/port/win32ntdll.h @@ -23,9 +23,17 @@ #include <ntstatus.h> #include <winternl.h> -typedef NTSTATUS (__stdcall * RtlGetLastNtStatus_t) (void); +#ifndef FLUSH_FLAGS_FILE_DATA_SYNC_ONLY +#define FLUSH_FLAGS_FILE_DATA_SYNC_ONLY 0x4 +#endif + +typedef NTSTATUS (__stdcall *RtlGetLastNtStatus_t) (void); +typedef ULONG (__stdcall *RtlNtStatusToDosError_t) (NTSTATUS); +typedef NTSTATUS (__stdcall *NtFlushBuffersFileEx_t) (HANDLE, ULONG, PVOID, ULONG, PIO_STATUS_BLOCK); extern PGDLLIMPORT RtlGetLastNtStatus_t pg_RtlGetLastNtStatus; +extern PGDLLIMPORT RtlNtStatusToDosError_t pg_RtlNtStatusToDosError; +extern PGDLLIMPORT NtFlushBuffersFileEx_t pg_NtFlushBuffersFileEx; extern int initialize_ntdll(void); |
