Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit d2e1508

Browse files
committed
Remove configure probe for fdatasync.
fdatasync() is in SUSv2, and all targeted Unix systems have it. We have a replacement function for Windows. We retain the probe for the function declaration, which allows us to supply the mysteriously missing declaration for macOS, and also for Windows. No need to keep a HAVE_FDATASYNC macro around. Also rename src/port/fdatasync.c to win32fdatasync.c since it's only for Windows. Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us> Reviewed-by: Andres Freund <andres@anarazel.de> Discussion: https://postgr.es/m/CA+hUKGJ3LHeP9w5Fgzdr4G8AnEtJ=z=p6hGDEm4qYGEUX5B6fQ@mail.gmail.com Discussion: https://postgr.es/m/CA%2BhUKGJZJVO%3DiX%2Beb-PXi2_XS9ZRqnn_4URh0NUQOwt6-_51xQ%40mail.gmail.com
1 parent 623cc67 commit d2e1508

File tree

12 files changed

+15
-48
lines changed

12 files changed

+15
-48
lines changed

configure

+7-7
Original file line numberDiff line numberDiff line change
@@ -16039,7 +16039,7 @@ fi
1603916039
LIBS_including_readline="$LIBS"
1604016040
LIBS=`echo "$LIBS" | sed -e 's/-ledit//g' -e 's/-lreadline//g'`
1604116041

16042-
for ac_func in backtrace_symbols copyfile fdatasync getifaddrs getpeerucred inet_pton kqueue mbstowcs_l memset_s posix_fallocate ppoll pthread_is_threaded_np setproctitle setproctitle_fast strchrnul strsignal syncfs sync_file_range uselocale wcstombs_l
16042+
for ac_func in backtrace_symbols copyfile getifaddrs getpeerucred inet_pton kqueue mbstowcs_l memset_s posix_fallocate ppoll pthread_is_threaded_np setproctitle setproctitle_fast strchrnul strsignal syncfs sync_file_range uselocale wcstombs_l
1604316043
do :
1604416044
as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
1604516045
ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"
@@ -16929,12 +16929,6 @@ fi
1692916929
;;
1693016930
esac
1693116931

16932-
case " $LIBOBJS " in
16933-
*" fdatasync.$ac_objext "* ) ;;
16934-
*) LIBOBJS="$LIBOBJS fdatasync.$ac_objext"
16935-
;;
16936-
esac
16937-
1693816932
case " $LIBOBJS " in
1693916933
*" getrusage.$ac_objext "* ) ;;
1694016934
*) LIBOBJS="$LIBOBJS getrusage.$ac_objext"
@@ -16977,6 +16971,12 @@ esac
1697716971
;;
1697816972
esac
1697916973

16974+
case " $LIBOBJS " in
16975+
*" win32fdatasync.$ac_objext "* ) ;;
16976+
*) LIBOBJS="$LIBOBJS win32fdatasync.$ac_objext"
16977+
;;
16978+
esac
16979+
1698016980
case " $LIBOBJS " in
1698116981
*" win32link.$ac_objext "* ) ;;
1698216982
*) LIBOBJS="$LIBOBJS win32link.$ac_objext"

configure.ac

+1-2
Original file line numberDiff line numberDiff line change
@@ -1792,7 +1792,6 @@ LIBS=`echo "$LIBS" | sed -e 's/-ledit//g' -e 's/-lreadline//g'`
17921792
AC_CHECK_FUNCS(m4_normalize([
17931793
backtrace_symbols
17941794
copyfile
1795-
fdatasync
17961795
getifaddrs
17971796
getpeerucred
17981797
inet_pton
@@ -1928,14 +1927,14 @@ if test "$PORTNAME" = "win32"; then
19281927
AC_CHECK_FUNCS(_configthreadlocale)
19291928
AC_REPLACE_FUNCS(gettimeofday)
19301929
AC_LIBOBJ(dirmod)
1931-
AC_LIBOBJ(fdatasync)
19321930
AC_LIBOBJ(getrusage)
19331931
AC_LIBOBJ(kill)
19341932
AC_LIBOBJ(open)
19351933
AC_LIBOBJ(system)
19361934
AC_LIBOBJ(win32dlopen)
19371935
AC_LIBOBJ(win32env)
19381936
AC_LIBOBJ(win32error)
1937+
AC_LIBOBJ(win32fdatasync)
19391938
AC_LIBOBJ(win32link)
19401939
AC_LIBOBJ(win32ntdll)
19411940
AC_LIBOBJ(win32pread)

src/backend/access/transam/xlog.c

-4
Original file line numberDiff line numberDiff line change
@@ -168,9 +168,7 @@ const struct config_enum_entry sync_method_options[] = {
168168
#ifdef HAVE_FSYNC_WRITETHROUGH
169169
{"fsync_writethrough", SYNC_METHOD_FSYNC_WRITETHROUGH, false},
170170
#endif
171-
#ifdef HAVE_FDATASYNC
172171
{"fdatasync", SYNC_METHOD_FDATASYNC, false},
173-
#endif
174172
#ifdef O_SYNC
175173
{"open_sync", SYNC_METHOD_OPEN, false},
176174
#endif
@@ -8015,12 +8013,10 @@ issue_xlog_fsync(int fd, XLogSegNo segno, TimeLineID tli)
80158013
msg = _("could not fsync write-through file \"%s\": %m");
80168014
break;
80178015
#endif
8018-
#ifdef HAVE_FDATASYNC
80198016
case SYNC_METHOD_FDATASYNC:
80208017
if (pg_fdatasync(fd) != 0)
80218018
msg = _("could not fdatasync file \"%s\": %m");
80228019
break;
8023-
#endif
80248020
case SYNC_METHOD_OPEN:
80258021
case SYNC_METHOD_OPEN_DSYNC:
80268022
/* not reachable */

src/backend/storage/file/fd.c

-8
Original file line numberDiff line numberDiff line change
@@ -442,20 +442,12 @@ pg_fsync_writethrough(int fd)
442442

443443
/*
444444
* pg_fdatasync --- same as fdatasync except does nothing if enableFsync is off
445-
*
446-
* Not all platforms have fdatasync; treat as fsync if not available.
447445
*/
448446
int
449447
pg_fdatasync(int fd)
450448
{
451449
if (enableFsync)
452-
{
453-
#ifdef HAVE_FDATASYNC
454450
return fdatasync(fd);
455-
#else
456-
return fsync(fd);
457-
#endif
458-
}
459451
else
460452
return 0;
461453
}

src/bin/pg_test_fsync/pg_test_fsync.c

-4
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,6 @@ test_sync(int writes_per_op)
331331
printf(LABEL_FORMAT, "fdatasync");
332332
fflush(stdout);
333333

334-
#ifdef HAVE_FDATASYNC
335334
if ((tmpfile = open(filename, O_RDWR | PG_BINARY, 0)) == -1)
336335
die("could not open output file");
337336
START_TIMER;
@@ -347,9 +346,6 @@ test_sync(int writes_per_op)
347346
}
348347
STOP_TIMER;
349348
close(tmpfile);
350-
#else
351-
printf(NA_FORMAT, _("n/a"));
352-
#endif
353349

354350
/*
355351
* Test fsync

src/include/access/xlogdefs.h

+2-5
Original file line numberDiff line numberDiff line change
@@ -67,19 +67,16 @@ typedef uint16 RepOriginId;
6767
/*
6868
* This chunk of hackery attempts to determine which file sync methods
6969
* are available on the current platform, and to choose an appropriate
70-
* default method. We assume that fsync() is always available, and that
71-
* configure determined whether fdatasync() is.
70+
* default method.
7271
*
7372
* Note that we define our own O_DSYNC on Windows, but not O_SYNC.
7473
*/
7574
#if defined(PLATFORM_DEFAULT_SYNC_METHOD)
7675
#define DEFAULT_SYNC_METHOD PLATFORM_DEFAULT_SYNC_METHOD
7776
#elif defined(O_DSYNC) && (!defined(O_SYNC) || O_DSYNC != O_SYNC)
7877
#define DEFAULT_SYNC_METHOD SYNC_METHOD_OPEN_DSYNC
79-
#elif defined(HAVE_FDATASYNC)
80-
#define DEFAULT_SYNC_METHOD SYNC_METHOD_FDATASYNC
8178
#else
82-
#define DEFAULT_SYNC_METHOD SYNC_METHOD_FSYNC
79+
#define DEFAULT_SYNC_METHOD SYNC_METHOD_FDATASYNC
8380
#endif
8481

8582
#endif /* XLOG_DEFS_H */

src/include/pg_config.h.in

-3
Original file line numberDiff line numberDiff line change
@@ -170,9 +170,6 @@
170170
/* Define to 1 if you have the `explicit_bzero' function. */
171171
#undef HAVE_EXPLICIT_BZERO
172172

173-
/* Define to 1 if you have the `fdatasync' function. */
174-
#undef HAVE_FDATASYNC
175-
176173
/* Define to 1 if fseeko (and presumably ftello) exists and is declared. */
177174
#undef HAVE_FSEEKO
178175

src/include/port/freebsd.h

-2
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,4 @@
55
* would prefer open_datasync on FreeBSD 13+, but that is not a good choice on
66
* many systems.
77
*/
8-
#ifdef HAVE_FDATASYNC
98
#define PLATFORM_DEFAULT_SYNC_METHOD SYNC_METHOD_FDATASYNC
10-
#endif

src/include/port/win32_port.h

-8
Original file line numberDiff line numberDiff line change
@@ -83,14 +83,6 @@
8383
#define HAVE_FSYNC_WRITETHROUGH
8484
#define FSYNC_WRITETHROUGH_IS_FSYNC
8585

86-
/*
87-
* We have a replacement for fdatasync() in src/port/fdatasync.c, which is
88-
* unconditionally used by MSVC and Mingw builds.
89-
*/
90-
#ifndef HAVE_FDATASYNC
91-
#define HAVE_FDATASYNC
92-
#endif
93-
9486
#define USES_WINSOCK
9587

9688
/*

src/port/fdatasync.c renamed to src/port/win32fdatasync.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
/*-------------------------------------------------------------------------
22
*
3-
* fdatasync.c
3+
* win32fdatasync.c
44
* Win32 fdatasync() replacement
55
*
66
*
7-
* Portions Copyright (c) 1996-2021, PostgreSQL Global Development Group
7+
* Portions Copyright (c) 1996-2022, PostgreSQL Global Development Group
88
*
9-
* src/port/fdatasync.c
9+
* src/port/win32fdatasync.c
1010
*
1111
*-------------------------------------------------------------------------
1212
*/

src/tools/msvc/Mkvcbuild.pm

+2-1
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ sub mkvcbuild
9999
$solution = CreateSolution($vsVersion, $config);
100100

101101
our @pgportfiles = qw(
102-
chklocale.c explicit_bzero.c fdatasync.c
102+
chklocale.c explicit_bzero.c
103103
getpeereid.c getrusage.c inet_aton.c
104104
getaddrinfo.c gettimeofday.c inet_net_ntop.c kill.c open.c
105105
snprintf.c strlcat.c strlcpy.c dirmod.c noblock.c path.c
@@ -110,6 +110,7 @@ sub mkvcbuild
110110
strerror.c tar.c
111111
win32dlopen.c
112112
win32env.c win32error.c
113+
win32fdatasync.c
113114
win32link.c
114115
win32pread.c
115116
win32pwrite.c

src/tools/msvc/Solution.pm

-1
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,6 @@ sub GenerateFiles
252252
HAVE_EDITLINE_READLINE_H => undef,
253253
HAVE_EXECINFO_H => undef,
254254
HAVE_EXPLICIT_BZERO => undef,
255-
HAVE_FDATASYNC => 1,
256255
HAVE_FSEEKO => 1,
257256
HAVE_FUNCNAME__FUNC => undef,
258257
HAVE_FUNCNAME__FUNCTION => 1,

0 commit comments

Comments
 (0)