diff --git a/contrib/Makefile b/contrib/Makefile
index cc60d680fca9c927e5b9d9aeebed2322da6eecf3..9ca1ed707a00d1f67463b518a772aa2ca85e8dac 100644
--- a/contrib/Makefile
+++ b/contrib/Makefile
@@ -33,7 +33,6 @@ SUBDIRS = \
 		pg_prewarm	\
 		pg_standby	\
 		pg_stat_statements \
-		pg_test_fsync	\
 		pg_test_timing	\
 		pg_trgm		\
 		pgcrypto	\
diff --git a/contrib/pg_test_fsync/Makefile b/contrib/pg_test_fsync/Makefile
deleted file mode 100644
index 15afba768299d0f99c92d25311227398a9d8c111..0000000000000000000000000000000000000000
--- a/contrib/pg_test_fsync/Makefile
+++ /dev/null
@@ -1,18 +0,0 @@
-# contrib/pg_test_fsync/Makefile
-
-PGFILEDESC = "pg_test_fsync - test various disk sync methods"
-PGAPPICON = win32
-
-PROGRAM  = pg_test_fsync
-OBJS = pg_test_fsync.o $(WIN32RES)
-
-ifdef USE_PGXS
-PG_CONFIG = pg_config
-PGXS := $(shell $(PG_CONFIG) --pgxs)
-include $(PGXS)
-else
-subdir = contrib/pg_test_fsync
-top_builddir = ../..
-include $(top_builddir)/src/Makefile.global
-include $(top_srcdir)/contrib/contrib-global.mk
-endif
diff --git a/doc/src/sgml/contrib.sgml b/doc/src/sgml/contrib.sgml
index adc21843db23b0df341f4e3b1f618004b91bd2cc..b25d18b344ad170980b6e0a0cd24923a6c42bc60 100644
--- a/doc/src/sgml/contrib.sgml
+++ b/doc/src/sgml/contrib.sgml
@@ -202,7 +202,6 @@ pages.
   </para>
 
  &pgstandby;
- &pgtestfsync;
  &pgtesttiming;
  &pgxlogdump;
  </sect1>
diff --git a/doc/src/sgml/filelist.sgml b/doc/src/sgml/filelist.sgml
index 2d7514c3ea17de45d5c14e4bff87be722bc2101b..5095e0fce2aaa88ce29ad239eec38c36afcb81b9 100644
--- a/doc/src/sgml/filelist.sgml
+++ b/doc/src/sgml/filelist.sgml
@@ -133,7 +133,6 @@
 <!ENTITY pgstandby       SYSTEM "pgstandby.sgml">
 <!ENTITY pgstatstatements SYSTEM "pgstatstatements.sgml">
 <!ENTITY pgstattuple     SYSTEM "pgstattuple.sgml">
-<!ENTITY pgtestfsync     SYSTEM "pgtestfsync.sgml">
 <!ENTITY pgtesttiming    SYSTEM "pgtesttiming.sgml">
 <!ENTITY pgtrgm          SYSTEM "pgtrgm.sgml">
 <!ENTITY pgxlogdump      SYSTEM "pg_xlogdump.sgml">
diff --git a/doc/src/sgml/ref/allfiles.sgml b/doc/src/sgml/ref/allfiles.sgml
index 211a3c42bd5d2d485b8291727ac2bb6f8ca4012e..e940153540ee6179a12af27466be1b27b0e022f8 100644
--- a/doc/src/sgml/ref/allfiles.sgml
+++ b/doc/src/sgml/ref/allfiles.sgml
@@ -193,6 +193,7 @@ Complete list of usable sgml source files in this directory.
 <!ENTITY pgResetxlog        SYSTEM "pg_resetxlog.sgml">
 <!ENTITY pgRestore          SYSTEM "pg_restore.sgml">
 <!ENTITY pgRewind           SYSTEM "pg_rewind.sgml">
+<!ENTITY pgtestfsync        SYSTEM "pgtestfsync.sgml">
 <!ENTITY pgupgrade          SYSTEM "pgupgrade.sgml">
 <!ENTITY postgres           SYSTEM "postgres-ref.sgml">
 <!ENTITY postmaster         SYSTEM "postmaster.sgml">
diff --git a/doc/src/sgml/pgtestfsync.sgml b/doc/src/sgml/ref/pgtestfsync.sgml
similarity index 95%
rename from doc/src/sgml/pgtestfsync.sgml
rename to doc/src/sgml/ref/pgtestfsync.sgml
index c4b4014b1a0a72a49d8824a8a269f5139d99e548..5dcabe4b77d8c2e939e3d8f980b0c77aae3d2746 100644
--- a/doc/src/sgml/pgtestfsync.sgml
+++ b/doc/src/sgml/ref/pgtestfsync.sgml
@@ -1,4 +1,4 @@
-<!-- doc/src/sgml/pgtestfsync.sgml -->
+<!-- doc/src/sgml/ref/pgtestfsync.sgml -->
 
 <refentry id="pgtestfsync">
  <indexterm zone="pgtestfsync">
@@ -103,14 +103,6 @@
 
  </refsect1>
 
- <refsect1>
-  <title>Author</title>
-
-  <para>
-   Bruce Momjian <email>bruce@momjian.us</email>
-  </para>
- </refsect1>
-
  <refsect1>
   <title>See Also</title>
 
diff --git a/doc/src/sgml/reference.sgml b/doc/src/sgml/reference.sgml
index fb18d94ea0974a37ab75e58e4019bae0ee645f11..666493cd64010fad06a5c6325ac28ec6758647f1 100644
--- a/doc/src/sgml/reference.sgml
+++ b/doc/src/sgml/reference.sgml
@@ -263,6 +263,7 @@
    &pgCtl;
    &pgResetxlog;
    &pgRewind;
+   &pgtestfsync;
    &pgupgrade;
    &postgres;
    &postmaster;
diff --git a/src/bin/Makefile b/src/bin/Makefile
index cc78798fba7c339b07066f676a0985297c1a8c82..06a0ab75b6b120fb56257c848b6a2b79f00ec4a0 100644
--- a/src/bin/Makefile
+++ b/src/bin/Makefile
@@ -23,6 +23,7 @@ SUBDIRS = \
 	pg_dump \
 	pg_resetxlog \
 	pg_rewind \
+	pg_test_fsync \
 	pg_upgrade \
 	pgbench \
 	psql \
diff --git a/contrib/pg_test_fsync/.gitignore b/src/bin/pg_test_fsync/.gitignore
similarity index 100%
rename from contrib/pg_test_fsync/.gitignore
rename to src/bin/pg_test_fsync/.gitignore
diff --git a/src/bin/pg_test_fsync/Makefile b/src/bin/pg_test_fsync/Makefile
new file mode 100644
index 0000000000000000000000000000000000000000..90496df566d17cfcca0098c8e6f78fbd6b26e346
--- /dev/null
+++ b/src/bin/pg_test_fsync/Makefile
@@ -0,0 +1,27 @@
+# src/bin/pg_test_fsync/Makefile
+
+PGFILEDESC = "pg_test_fsync - test various disk sync methods"
+PGAPPICON = win32
+
+subdir = src/bin/pg_test_fsync
+top_builddir = ../../..
+include $(top_builddir)/src/Makefile.global
+
+OBJS = pg_test_fsync.o $(WIN32RES)
+
+all: pg_test_fsync
+
+pg_test_fsync: $(OBJS) | submake-libpgport
+	$(CC) $(CFLAGS) $^ $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@$(X)
+
+install: all installdirs
+	$(INSTALL_PROGRAM) pg_test_fsync$(X) '$(DESTDIR)$(bindir)/pg_test_fsync$(X)'
+
+installdirs:
+	$(MKDIR_P) '$(DESTDIR)$(bindir)'
+
+uninstall:
+	rm -f '$(DESTDIR)$(bindir)/pg_test_fsync$(X)'
+
+clean distclean maintainer-clean:
+	rm -f pg_test_fsync$(X) $(OBJS)
diff --git a/contrib/pg_test_fsync/pg_test_fsync.c b/src/bin/pg_test_fsync/pg_test_fsync.c
similarity index 100%
rename from contrib/pg_test_fsync/pg_test_fsync.c
rename to src/bin/pg_test_fsync/pg_test_fsync.c
diff --git a/src/tools/msvc/Mkvcbuild.pm b/src/tools/msvc/Mkvcbuild.pm
index 986f3b3794c9799bbe6032e1782a9d9cddc6e4d8..5b86c805ae6ad29bba13cf0971b3b7001dbafa9f 100644
--- a/src/tools/msvc/Mkvcbuild.pm
+++ b/src/tools/msvc/Mkvcbuild.pm
@@ -35,13 +35,13 @@ my @contrib_uselibpq =
 my @contrib_uselibpgport = (
 	'oid2name',
 	'pg_standby',
-	'pg_test_fsync', 'pg_test_timing',
+	'pg_test_timing',
 	'pg_xlogdump',
 	'vacuumlo');
 my @contrib_uselibpgcommon = (
 	'oid2name',
 	'pg_standby',
-	'pg_test_fsync', 'pg_test_timing',
+	'pg_test_timing',
 	'pg_xlogdump',
 	'vacuumlo');
 my $contrib_extralibs = undef;
@@ -55,8 +55,8 @@ my @contrib_excludes = ('pgcrypto', 'commit_ts', 'intagg', 'sepgsql');
 # Set of variables for frontend modules
 my $frontend_defines = { 'initdb' => 'FRONTEND' };
 my @frontend_uselibpq = ('pg_ctl', 'pg_upgrade', 'pgbench', 'psql');
-my @frontend_uselibpgport = ( 'pg_archivecleanup', 'pg_upgrade', 'pgbench' );
-my @frontend_uselibpgcommon = ( 'pg_archivecleanup', 'pg_upgrade', 'pgbench' );
+my @frontend_uselibpgport = ( 'pg_archivecleanup', 'pg_test_fsync', 'pg_upgrade', 'pgbench' );
+my @frontend_uselibpgcommon = ( 'pg_archivecleanup', 'pg_test_fsync', 'pg_upgrade', 'pgbench' );
 my $frontend_extralibs = {
 	'initdb'     => ['ws2_32.lib'],
 	'pg_restore' => ['ws2_32.lib'],