diff options
author | dwmalone <dwmalone@FreeBSD.org> | 2016-02-23 15:21:13 +0000 |
---|---|---|
committer | dwmalone <dwmalone@FreeBSD.org> | 2016-02-23 15:21:13 +0000 |
commit | 3d569ff3bef0f758d848427c0ebed038dce6245d (patch) | |
tree | 64aa91f86322c7b4d544cbccff777e912218cfc2 /lib/libc/db | |
parent | 204e226f14aa8626efb796138150a233782799eb (diff) | |
download | FreeBSD-src-3d569ff3bef0f758d848427c0ebed038dce6245d.zip FreeBSD-src-3d569ff3bef0f758d848427c0ebed038dce6245d.tar.gz |
If we close or sync a hash-based db file, make sure to call fsync to
make sure the changes are on disk. The people at pfSense noticed that
it didn't always make it to the disk soon enough with soft updates.
Differential Revision: https://reviews.freebsd.org/D5186
Reviewed by: garga, vangyzen, bapt, se
MFC after: 1 week
Diffstat (limited to 'lib/libc/db')
-rw-r--r-- | lib/libc/db/hash/hash.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/lib/libc/db/hash/hash.c b/lib/libc/db/hash/hash.c index e6da5fe..02503ee 100644 --- a/lib/libc/db/hash/hash.c +++ b/lib/libc/db/hash/hash.c @@ -422,8 +422,10 @@ hdestroy(HTAB *hashp) if (hashp->tmp_buf) free(hashp->tmp_buf); - if (hashp->fp != -1) + if (hashp->fp != -1) { + (void)_fsync(hashp->fp); (void)_close(hashp->fp); + } free(hashp); @@ -458,6 +460,8 @@ hash_sync(const DB *dbp, u_int32_t flags) return (0); if (__buf_free(hashp, 0, 1) || flush_meta(hashp)) return (ERROR); + if (hashp->fp != -1 && _fsync(hashp->fp) != 0) + return (ERROR); hashp->new_file = 0; return (0); } |