aboutsummaryrefslogtreecommitdiff
path: root/src/backend
diff options
context:
space:
mode:
Diffstat (limited to 'src/backend')
-rw-r--r--src/backend/storage/file/fd.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/backend/storage/file/fd.c b/src/backend/storage/file/fd.c
index f79f4c6a36e..9724f481dc0 100644
--- a/src/backend/storage/file/fd.c
+++ b/src/backend/storage/file/fd.c
@@ -336,12 +336,15 @@ pg_fdatasync(int fd)
/*
* pg_flush_data --- advise OS that the data described won't be needed soon
*
- * Not all platforms have posix_fadvise; treat as noop if not available.
+ * Not all platforms have sync_file_range or posix_fadvise; treat as no-op
+ * if not available.
*/
int
pg_flush_data(int fd, off_t offset, off_t amount)
{
-#if defined(USE_POSIX_FADVISE) && defined(POSIX_FADV_DONTNEED)
+#if defined(HAVE_SYNC_FILE_RANGE)
+ return sync_file_range(fd, offset, amount, SYNC_FILE_RANGE_WRITE);
+#elif defined(USE_POSIX_FADVISE) && defined(POSIX_FADV_DONTNEED)
return posix_fadvise(fd, offset, amount, POSIX_FADV_DONTNEED);
#else
return 0;