aboutsummaryrefslogtreecommitdiff
path: root/src/common/file_utils.c
diff options
context:
space:
mode:
authorAndrew Dunstan <andrew@dunslane.net>2017-03-22 10:00:30 -0400
committerAndrew Dunstan <andrew@dunslane.net>2017-03-22 10:20:13 -0400
commit96a7128b7b4c9ce4fb51df8c8b216dfab6340766 (patch)
tree900964e96eebe58df9033f698506293056a49530 /src/common/file_utils.c
parent9b013dc238cefa2860b384a3fa016ad1ceb062e4 (diff)
downloadpostgresql-96a7128b7b4c9ce4fb51df8c8b216dfab6340766.tar.gz
postgresql-96a7128b7b4c9ce4fb51df8c8b216dfab6340766.zip
Sync pg_dump and pg_dumpall output
Before exiting any files are fsync'ed. A --no-sync option is also provided for a faster exit if desired. Michael Paquier. Reviewed by Albe Laurenz Discussion: https://postgr.es/m/CAB7nPqS1uZ=Ov+UruW6jr3vB-S_DLVMPc0dQpV-fTDjmm0ZQMg@mail.gmail.com
Diffstat (limited to 'src/common/file_utils.c')
-rw-r--r--src/common/file_utils.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/common/file_utils.c b/src/common/file_utils.c
index a978e64f5a1..72b0565c710 100644
--- a/src/common/file_utils.c
+++ b/src/common/file_utils.c
@@ -116,6 +116,25 @@ fsync_pgdata(const char *pg_data,
}
/*
+ * Issue fsync recursively on the given directory and all its contents.
+ *
+ * This is a convenient wrapper on top of walkdir().
+ */
+void
+fsync_dir_recurse(const char *dir, const char *progname)
+{
+ /*
+ * If possible, hint to the kernel that we're soon going to fsync the data
+ * directory and its contents.
+ */
+#ifdef PG_FLUSH_DATA_WORKS
+ walkdir(dir, pre_sync_fname, false, progname);
+#endif
+
+ walkdir(dir, fsync_fname, false, progname);
+}
+
+/*
* walkdir: recursively walk a directory, applying the action to each
* regular file and directory (including the named directory itself).
*