From 4c81b03e30d13dbc93ea7071438ef2da0acd4189 Mon Sep 17 00:00:00 2001 From: Linus Torvalds Date: Fri, 30 May 2008 08:42:16 -0700 Subject: Make pack creation always fsync() the result This means that we can depend on packs always being stable on disk, simplifying a lot of the object serialization worries. And unlike loose objects, serializing pack creation IO isn't going to be a performance killer. Signed-off-by: Linus Torvalds Signed-off-by: Junio C Hamano --- write_or_die.c | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'write_or_die.c') diff --git a/write_or_die.c b/write_or_die.c index 32f991402..630be4cb9 100644 --- a/write_or_die.c +++ b/write_or_die.c @@ -78,6 +78,13 @@ ssize_t write_in_full(int fd, const void *buf, size_t count) return total; } +void fsync_or_die(int fd, const char *msg) +{ + if (fsync(fd) < 0) { + die("%s: fsync error (%s)", msg, strerror(errno)); + } +} + void write_or_die(int fd, const void *buf, size_t count) { if (write_in_full(fd, buf, count) < 0) { -- cgit v1.2.1