From 96a7128b7b4c9ce4fb51df8c8b216dfab6340766 Mon Sep 17 00:00:00 2001 From: Andrew Dunstan Date: Wed, 22 Mar 2017 10:00:30 -0400 Subject: 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 --- src/common/file_utils.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'src/common/file_utils.c') 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 @@ -115,6 +115,25 @@ fsync_pgdata(const char *pg_data, walkdir(pg_tblspc, fsync_fname, true, progname); } +/* + * 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). -- cgit v1.2.3