sysroot: Drop an fsync for origin file when writing deployments
More fsync pruning. Since we have a public API for writing the origin file and it did a fsync before, let's preserve that. But when writing deployments as part of a full transaction, we rely on the global `syncfs()`, so add an internal function for origin file writing that doesn't. Closes: #509 Approved by: giuseppe
This commit is contained in:
parent
fcffb73280
commit
4f736ac33e
|
|
@ -894,24 +894,13 @@ merge_configuration (OstreeSysroot *sysroot,
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
static gboolean
|
||||||
* ostree_sysroot_write_origin_file:
|
write_origin_file_internal (OstreeSysroot *sysroot,
|
||||||
* @sysroot: System root
|
OstreeDeployment *deployment,
|
||||||
* @deployment: Deployment
|
GKeyFile *new_origin,
|
||||||
* @new_origin: (allow-none): Origin content
|
GLnxFileReplaceFlags flags,
|
||||||
* @cancellable: Cancellable
|
GCancellable *cancellable,
|
||||||
* @error: Error
|
GError **error)
|
||||||
*
|
|
||||||
* Immediately replace the origin file of the referenced @deployment
|
|
||||||
* with the contents of @new_origin. If @new_origin is %NULL,
|
|
||||||
* this function will write the current origin of @deployment.
|
|
||||||
*/
|
|
||||||
gboolean
|
|
||||||
ostree_sysroot_write_origin_file (OstreeSysroot *sysroot,
|
|
||||||
OstreeDeployment *deployment,
|
|
||||||
GKeyFile *new_origin,
|
|
||||||
GCancellable *cancellable,
|
|
||||||
GError **error)
|
|
||||||
{
|
{
|
||||||
GKeyFile *origin =
|
GKeyFile *origin =
|
||||||
new_origin ? new_origin : ostree_deployment_get_origin (deployment);
|
new_origin ? new_origin : ostree_deployment_get_origin (deployment);
|
||||||
|
|
@ -933,7 +922,7 @@ ostree_sysroot_write_origin_file (OstreeSysroot *sysroot,
|
||||||
|
|
||||||
if (!glnx_file_replace_contents_at (sysroot->sysroot_fd,
|
if (!glnx_file_replace_contents_at (sysroot->sysroot_fd,
|
||||||
origin_path, (guint8*)contents, len,
|
origin_path, (guint8*)contents, len,
|
||||||
GLNX_FILE_REPLACE_DATASYNC_NEW,
|
flags,
|
||||||
cancellable, error))
|
cancellable, error))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
@ -941,6 +930,30 @@ ostree_sysroot_write_origin_file (OstreeSysroot *sysroot,
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ostree_sysroot_write_origin_file:
|
||||||
|
* @sysroot: System root
|
||||||
|
* @deployment: Deployment
|
||||||
|
* @new_origin: (allow-none): Origin content
|
||||||
|
* @cancellable: Cancellable
|
||||||
|
* @error: Error
|
||||||
|
*
|
||||||
|
* Immediately replace the origin file of the referenced @deployment
|
||||||
|
* with the contents of @new_origin. If @new_origin is %NULL,
|
||||||
|
* this function will write the current origin of @deployment.
|
||||||
|
*/
|
||||||
|
gboolean
|
||||||
|
ostree_sysroot_write_origin_file (OstreeSysroot *sysroot,
|
||||||
|
OstreeDeployment *deployment,
|
||||||
|
GKeyFile *new_origin,
|
||||||
|
GCancellable *cancellable,
|
||||||
|
GError **error)
|
||||||
|
{
|
||||||
|
return write_origin_file_internal (sysroot, deployment, new_origin,
|
||||||
|
GLNX_FILE_REPLACE_DATASYNC_NEW,
|
||||||
|
cancellable, error);
|
||||||
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
get_kernel_from_tree (int deployment_dfd,
|
get_kernel_from_tree (int deployment_dfd,
|
||||||
int *out_boot_dfd,
|
int *out_boot_dfd,
|
||||||
|
|
@ -2152,8 +2165,12 @@ ostree_sysroot_deploy_tree (OstreeSysroot *self,
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!ostree_sysroot_write_origin_file (self, new_deployment, NULL,
|
/* Don't fsync here, as we assume that's all done in
|
||||||
cancellable, error))
|
* ostree_sysroot_write_deployments().
|
||||||
|
*/
|
||||||
|
if (!write_origin_file_internal (self, new_deployment, NULL,
|
||||||
|
GLNX_FILE_REPLACE_NODATASYNC,
|
||||||
|
cancellable, error))
|
||||||
{
|
{
|
||||||
g_prefix_error (error, "Writing out origin file: ");
|
g_prefix_error (error, "Writing out origin file: ");
|
||||||
goto out;
|
goto out;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue