Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 23 Feb 2016 15:21:13 +0000 (UTC)
From:      David Malone <dwmalone@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r295924 - head/lib/libc/db/hash
Message-ID:  <201602231521.u1NFLDIU029758@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: dwmalone
Date: Tue Feb 23 15:21:13 2016
New Revision: 295924
URL: https://svnweb.freebsd.org/changeset/base/295924

Log:
  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

Modified:
  head/lib/libc/db/hash/hash.c

Modified: head/lib/libc/db/hash/hash.c
==============================================================================
--- head/lib/libc/db/hash/hash.c	Tue Feb 23 14:58:20 2016	(r295923)
+++ head/lib/libc/db/hash/hash.c	Tue Feb 23 15:21:13 2016	(r295924)
@@ -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);
 }



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201602231521.u1NFLDIU029758>