Commit 2a5ad7d0 by Edward Thomson

fsync: call it "synchronous" object writing

Rename `GIT_OPT_ENABLE_SYNCHRONIZED_OBJECT_CREATION` ->
`GIT_OPT_ENABLE_SYNCHRONOUS_OBJECT_CREATION`.
parent 1229e1c4
...@@ -179,7 +179,7 @@ typedef enum { ...@@ -179,7 +179,7 @@ typedef enum {
GIT_OPT_SET_SSL_CIPHERS, GIT_OPT_SET_SSL_CIPHERS,
GIT_OPT_GET_USER_AGENT, GIT_OPT_GET_USER_AGENT,
GIT_OPT_ENABLE_OFS_DELTA, GIT_OPT_ENABLE_OFS_DELTA,
GIT_OPT_ENABLE_SYNCHRONIZED_OBJECT_CREATION, GIT_OPT_ENABLE_SYNCHRONOUS_OBJECT_CREATION,
} git_libgit2_opt_t; } git_libgit2_opt_t;
/** /**
...@@ -317,7 +317,7 @@ typedef enum { ...@@ -317,7 +317,7 @@ typedef enum {
* > Packfiles containing offset deltas can still be read. * > Packfiles containing offset deltas can still be read.
* > This defaults to enabled. * > This defaults to enabled.
* *
* * opts(GIT_OPT_ENABLE_SYNCHRONIZED_OBJECT_CREATION, int enabled) * * opts(GIT_OPT_ENABLE_SYNCHRONOUS_OBJECT_CREATION, int enabled)
* *
* > Enable synchronized writes of new objects using `fsync` * > Enable synchronized writes of new objects using `fsync`
* > (or the platform equivalent) to ensure that new object data * > (or the platform equivalent) to ensure that new object data
......
...@@ -991,7 +991,7 @@ int git_indexer_commit(git_indexer *idx, git_transfer_progress *stats) ...@@ -991,7 +991,7 @@ int git_indexer_commit(git_indexer *idx, git_transfer_progress *stats)
if (git_filebuf_open(&index_file, filename.ptr, if (git_filebuf_open(&index_file, filename.ptr,
GIT_FILEBUF_HASH_CONTENTS | GIT_FILEBUF_HASH_CONTENTS |
(git_object__synchronized_writing ? GIT_FILEBUF_FSYNC : 0), (git_object__synchronous_writing ? GIT_FILEBUF_FSYNC : 0),
idx->mode) < 0) idx->mode) < 0)
goto on_error; goto on_error;
...@@ -1069,7 +1069,7 @@ int git_indexer_commit(git_indexer *idx, git_transfer_progress *stats) ...@@ -1069,7 +1069,7 @@ int git_indexer_commit(git_indexer *idx, git_transfer_progress *stats)
return -1; return -1;
} }
if (git_object__synchronized_writing && p_fsync(idx->pack->mwf.fd) < 0) { if (git_object__synchronous_writing && p_fsync(idx->pack->mwf.fd) < 0) {
giterr_set(GITERR_OS, "failed to fsync packfile"); giterr_set(GITERR_OS, "failed to fsync packfile");
goto on_error; goto on_error;
} }
...@@ -1090,7 +1090,7 @@ int git_indexer_commit(git_indexer *idx, git_transfer_progress *stats) ...@@ -1090,7 +1090,7 @@ int git_indexer_commit(git_indexer *idx, git_transfer_progress *stats)
goto on_error; goto on_error;
/* And fsync the parent directory if we're asked to. */ /* And fsync the parent directory if we're asked to. */
if (git_object__synchronized_writing && if (git_object__synchronous_writing &&
git_futils_fsync_parent(git_buf_cstr(&filename)) < 0) git_futils_fsync_parent(git_buf_cstr(&filename)) < 0)
goto on_error; goto on_error;
......
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
#include "tag.h" #include "tag.h"
bool git_object__strict_input_validation = true; bool git_object__strict_input_validation = true;
bool git_object__synchronized_writing = false; bool git_object__synchronous_writing = false;
typedef struct { typedef struct {
const char *str; /* type name string */ const char *str; /* type name string */
......
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
#include "repository.h" #include "repository.h"
extern bool git_object__strict_input_validation; extern bool git_object__strict_input_validation;
extern bool git_object__synchronized_writing; extern bool git_object__synchronous_writing;
/** Base git object for inheritance */ /** Base git object for inheritance */
struct git_object { struct git_object {
......
...@@ -844,7 +844,7 @@ static int filebuf_flags(loose_backend *backend) ...@@ -844,7 +844,7 @@ static int filebuf_flags(loose_backend *backend)
int flags = GIT_FILEBUF_TEMPORARY | int flags = GIT_FILEBUF_TEMPORARY |
(backend->object_zlib_level << GIT_FILEBUF_DEFLATE_SHIFT); (backend->object_zlib_level << GIT_FILEBUF_DEFLATE_SHIFT);
if (backend->fsync_object_files || git_object__synchronized_writing) if (backend->fsync_object_files || git_object__synchronous_writing)
flags |= GIT_FILEBUF_FSYNC; flags |= GIT_FILEBUF_FSYNC;
return flags; return flags;
......
...@@ -756,7 +756,7 @@ static int loose_lock(git_filebuf *file, refdb_fs_backend *backend, const char * ...@@ -756,7 +756,7 @@ static int loose_lock(git_filebuf *file, refdb_fs_backend *backend, const char *
return -1; return -1;
filebuf_flags = GIT_FILEBUF_FORCE; filebuf_flags = GIT_FILEBUF_FORCE;
if (git_object__synchronized_writing) if (git_object__synchronous_writing)
filebuf_flags |= GIT_FILEBUF_FSYNC; filebuf_flags |= GIT_FILEBUF_FSYNC;
error = git_filebuf_open(file, ref_path.ptr, filebuf_flags, GIT_REFS_FILE_MODE); error = git_filebuf_open(file, ref_path.ptr, filebuf_flags, GIT_REFS_FILE_MODE);
...@@ -1001,7 +1001,7 @@ static int packed_write(refdb_fs_backend *backend) ...@@ -1001,7 +1001,7 @@ static int packed_write(refdb_fs_backend *backend)
if ((error = git_sortedcache_wlock(refcache)) < 0) if ((error = git_sortedcache_wlock(refcache)) < 0)
return error; return error;
if (git_object__synchronized_writing) if (git_object__synchronous_writing)
open_flags = GIT_FILEBUF_FSYNC; open_flags = GIT_FILEBUF_FSYNC;
/* Open the file! */ /* Open the file! */
...@@ -1861,7 +1861,7 @@ static int reflog_append(refdb_fs_backend *backend, const git_reference *ref, co ...@@ -1861,7 +1861,7 @@ static int reflog_append(refdb_fs_backend *backend, const git_reference *ref, co
open_flags = O_WRONLY | O_CREAT | O_APPEND; open_flags = O_WRONLY | O_CREAT | O_APPEND;
if (git_object__synchronized_writing) if (git_object__synchronous_writing)
open_flags |= O_FSYNC; open_flags |= O_FSYNC;
error = git_futils_writebuffer(&buf, git_buf_cstr(&path), open_flags, GIT_REFLOG_FILE_MODE); error = git_futils_writebuffer(&buf, git_buf_cstr(&path), open_flags, GIT_REFLOG_FILE_MODE);
......
...@@ -227,8 +227,8 @@ int git_libgit2_opts(int key, ...) ...@@ -227,8 +227,8 @@ int git_libgit2_opts(int key, ...)
git_smart__ofs_delta_enabled = (va_arg(ap, int) != 0); git_smart__ofs_delta_enabled = (va_arg(ap, int) != 0);
break; break;
case GIT_OPT_ENABLE_SYNCHRONIZED_OBJECT_CREATION: case GIT_OPT_ENABLE_SYNCHRONOUS_OBJECT_CREATION:
git_object__synchronized_writing = (va_arg(ap, int) != 0); git_object__synchronous_writing = (va_arg(ap, int) != 0);
break; break;
default: default:
......
...@@ -62,7 +62,7 @@ void test_odb_loose__initialize(void) ...@@ -62,7 +62,7 @@ void test_odb_loose__initialize(void)
void test_odb_loose__cleanup(void) void test_odb_loose__cleanup(void)
{ {
cl_git_pass(git_libgit2_opts(GIT_OPT_ENABLE_SYNCHRONIZED_OBJECT_CREATION, 0)); cl_git_pass(git_libgit2_opts(GIT_OPT_ENABLE_SYNCHRONOUS_OBJECT_CREATION, 0));
cl_fixture_cleanup("test-objects"); cl_fixture_cleanup("test-objects");
} }
...@@ -180,7 +180,7 @@ void test_odb_loose__fsync_obeys_odb_option(void) ...@@ -180,7 +180,7 @@ void test_odb_loose__fsync_obeys_odb_option(void)
void test_odb_loose__fsync_obeys_global_setting(void) void test_odb_loose__fsync_obeys_global_setting(void)
{ {
cl_git_pass(git_libgit2_opts(GIT_OPT_ENABLE_SYNCHRONIZED_OBJECT_CREATION, 1)); cl_git_pass(git_libgit2_opts(GIT_OPT_ENABLE_SYNCHRONOUS_OBJECT_CREATION, 1));
write_object_to_loose_odb(0); write_object_to_loose_odb(0);
cl_assert(p_fsync__cnt > 0); cl_assert(p_fsync__cnt > 0);
} }
...@@ -31,7 +31,7 @@ void test_pack_packbuilder__cleanup(void) ...@@ -31,7 +31,7 @@ void test_pack_packbuilder__cleanup(void)
git_oid *o; git_oid *o;
unsigned int i; unsigned int i;
cl_git_pass(git_libgit2_opts(GIT_OPT_ENABLE_SYNCHRONIZED_OBJECT_CREATION, 0)); cl_git_pass(git_libgit2_opts(GIT_OPT_ENABLE_SYNCHRONOUS_OBJECT_CREATION, 0));
if (_commits_is_initialized) { if (_commits_is_initialized) {
_commits_is_initialized = 0; _commits_is_initialized = 0;
...@@ -200,7 +200,7 @@ void test_pack_packbuilder__does_not_fsync_by_default(void) ...@@ -200,7 +200,7 @@ void test_pack_packbuilder__does_not_fsync_by_default(void)
void test_pack_packbuilder__fsync_when_asked(void) void test_pack_packbuilder__fsync_when_asked(void)
{ {
cl_git_pass(git_libgit2_opts(GIT_OPT_ENABLE_SYNCHRONIZED_OBJECT_CREATION, 1)); cl_git_pass(git_libgit2_opts(GIT_OPT_ENABLE_SYNCHRONOUS_OBJECT_CREATION, 1));
p_fsync__cnt = 0; p_fsync__cnt = 0;
seed_packbuilder(); seed_packbuilder();
git_packbuilder_write(_packbuilder, ".", 0666, NULL, NULL); git_packbuilder_write(_packbuilder, ".", 0666, NULL, NULL);
......
...@@ -22,7 +22,7 @@ void test_refs_create__cleanup(void) ...@@ -22,7 +22,7 @@ void test_refs_create__cleanup(void)
cl_git_pass(git_libgit2_opts(GIT_OPT_ENABLE_STRICT_OBJECT_CREATION, 1)); cl_git_pass(git_libgit2_opts(GIT_OPT_ENABLE_STRICT_OBJECT_CREATION, 1));
cl_git_pass(git_libgit2_opts(GIT_OPT_ENABLE_STRICT_SYMBOLIC_REF_CREATION, 1)); cl_git_pass(git_libgit2_opts(GIT_OPT_ENABLE_STRICT_SYMBOLIC_REF_CREATION, 1));
cl_git_pass(git_libgit2_opts(GIT_OPT_ENABLE_SYNCHRONIZED_OBJECT_CREATION, 0)); cl_git_pass(git_libgit2_opts(GIT_OPT_ENABLE_SYNCHRONOUS_OBJECT_CREATION, 0));
} }
void test_refs_create__symbolic(void) void test_refs_create__symbolic(void)
...@@ -323,7 +323,7 @@ void test_refs_create__fsyncs_when_requested(void) ...@@ -323,7 +323,7 @@ void test_refs_create__fsyncs_when_requested(void)
git_refdb *refdb; git_refdb *refdb;
git_oid id; git_oid id;
cl_git_pass(git_libgit2_opts(GIT_OPT_ENABLE_SYNCHRONIZED_OBJECT_CREATION, 1)); cl_git_pass(git_libgit2_opts(GIT_OPT_ENABLE_SYNCHRONOUS_OBJECT_CREATION, 1));
p_fsync__cnt = 0; p_fsync__cnt = 0;
git_oid_fromstr(&id, current_master_tip); git_oid_fromstr(&id, current_master_tip);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment