summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMagnus Hagander <magnus@hagander.net>2016-10-25 18:56:21 +0200
committerMagnus Hagander <magnus@hagander.net>2016-10-25 19:00:01 +0200
commit8c46f0c9ce4695db7d68188e08e5e6be1c329645 (patch)
tree990b6b6270b3189dec3810c02ae4aa898d65346e /src
parent10c064ce4dad088ba2d8b978bff6009b9f22dc3a (diff)
Don't fsync() files when --no-sync is specified
Michael Paquier
Diffstat (limited to 'src')
-rw-r--r--src/bin/pg_basebackup/walmethods.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/bin/pg_basebackup/walmethods.c b/src/bin/pg_basebackup/walmethods.c
index b0b3d435c36..632e095c4e8 100644
--- a/src/bin/pg_basebackup/walmethods.c
+++ b/src/bin/pg_basebackup/walmethods.c
@@ -611,6 +611,9 @@ tar_sync(Walfile f)
Assert(f != NULL);
tar_clear_error();
+ if (!tar_data->sync)
+ return 0;
+
/*
* Always sync the whole tarfile, because that's all we can do. This makes
* no sense on compressed files, so just ignore those.
@@ -842,7 +845,8 @@ tar_finish(void)
#endif
/* sync the empty blocks as well, since they're after the last file */
- fsync(tar_data->fd);
+ if (tar_data->sync)
+ fsync(tar_data->fd);
if (close(tar_data->fd) != 0)
return false;