Add --disable-fsync option to pull-local, and API to repo
This will be used by guestmount - it's WAY faster. We only take disks as a unit, so it's safe. If the process fails halfway through, we just start over from scratch the next time anyways.
This commit is contained in:
parent
2313bdcb62
commit
234ae70b4c
|
|
@ -157,10 +157,13 @@ commit_loose_object_trusted (OstreeRepo *self,
|
||||||
/* Ensure that in case of a power cut, these files have the data we
|
/* Ensure that in case of a power cut, these files have the data we
|
||||||
* want. See http://lwn.net/Articles/322823/
|
* want. See http://lwn.net/Articles/322823/
|
||||||
*/
|
*/
|
||||||
if (fsync (fd) == -1)
|
if (!self->disable_fsync)
|
||||||
{
|
{
|
||||||
ot_util_set_error_from_errno (error, errno);
|
if (fsync (fd) == -1)
|
||||||
goto out;
|
{
|
||||||
|
ot_util_set_error_from_errno (error, errno);
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!g_output_stream_close (temp_out, cancellable, error))
|
if (!g_output_stream_close (temp_out, cancellable, error))
|
||||||
|
|
|
||||||
|
|
@ -57,6 +57,7 @@ struct OstreeRepo {
|
||||||
|
|
||||||
gboolean inited;
|
gboolean inited;
|
||||||
gboolean in_transaction;
|
gboolean in_transaction;
|
||||||
|
gboolean disable_fsync;
|
||||||
GHashTable *loose_object_devino_hash;
|
GHashTable *loose_object_devino_hash;
|
||||||
GHashTable *updated_uncompressed_dirs;
|
GHashTable *updated_uncompressed_dirs;
|
||||||
GHashTable *object_sizes;
|
GHashTable *object_sizes;
|
||||||
|
|
|
||||||
|
|
@ -552,6 +552,24 @@ ostree_repo_open (OstreeRepo *self,
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ostree_repo_set_disable_fsync:
|
||||||
|
* @self: An #OstreeRepo
|
||||||
|
* @disable_fsync: If %TRUE, do not fsync
|
||||||
|
*
|
||||||
|
* Disable requests to fsync() to stable storage during commits. This
|
||||||
|
* option should only be used by build system tools which are creating
|
||||||
|
* disposable virtual machines, or have higher level mechanisms for
|
||||||
|
* ensuring data consistency.
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
ostree_repo_set_disable_fsync (OstreeRepo *self,
|
||||||
|
gboolean disable_fsync)
|
||||||
|
{
|
||||||
|
self->disable_fsync = disable_fsync;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ostree_repo_get_path:
|
* ostree_repo_get_path:
|
||||||
* @self:
|
* @self:
|
||||||
|
|
|
||||||
|
|
@ -48,6 +48,9 @@ gboolean ostree_repo_open (OstreeRepo *self,
|
||||||
GCancellable *cancellable,
|
GCancellable *cancellable,
|
||||||
GError **error);
|
GError **error);
|
||||||
|
|
||||||
|
void ostree_repo_set_disable_fsync (OstreeRepo *self,
|
||||||
|
gboolean disable_fsync);
|
||||||
|
|
||||||
gboolean ostree_repo_create (OstreeRepo *self,
|
gboolean ostree_repo_create (OstreeRepo *self,
|
||||||
OstreeRepoMode mode,
|
OstreeRepoMode mode,
|
||||||
GCancellable *cancellable,
|
GCancellable *cancellable,
|
||||||
|
|
|
||||||
|
|
@ -30,9 +30,11 @@
|
||||||
#include "otutil.h"
|
#include "otutil.h"
|
||||||
|
|
||||||
static char *opt_remote;
|
static char *opt_remote;
|
||||||
|
static gboolean opt_disable_fsync;
|
||||||
|
|
||||||
static GOptionEntry options[] = {
|
static GOptionEntry options[] = {
|
||||||
{ "remote", 0, 0, G_OPTION_ARG_STRING, &opt_remote, "Add REMOTE to refspec", "REMOTE" },
|
{ "remote", 0, 0, G_OPTION_ARG_STRING, &opt_remote, "Add REMOTE to refspec", "REMOTE" },
|
||||||
|
{ "disable-fsync", 0, 0, G_OPTION_ARG_NONE, &opt_disable_fsync, "Do not invoke fsync()", NULL },
|
||||||
{ NULL }
|
{ NULL }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -206,6 +208,9 @@ ostree_builtin_pull_local (int argc, char **argv, OstreeRepo *repo, GCancellable
|
||||||
if (!ostree_repo_open (data->src_repo, cancellable, error))
|
if (!ostree_repo_open (data->src_repo, cancellable, error))
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
|
if (opt_disable_fsync)
|
||||||
|
ostree_repo_set_disable_fsync (data->dest_repo, TRUE);
|
||||||
|
|
||||||
data->threadpool = ot_thread_pool_new_nproc (import_one_object_thread, data);
|
data->threadpool = ot_thread_pool_new_nproc (import_one_object_thread, data);
|
||||||
|
|
||||||
src_repo_dir = g_object_ref (ostree_repo_get_path (data->src_repo));
|
src_repo_dir = g_object_ref (ostree_repo_get_path (data->src_repo));
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue