Skip to content

Commit

Permalink
deploy: Log calculated needed space
Browse files Browse the repository at this point in the history
To aid debugging issues like coreos/fedora-coreos-tracker#1637

If we're hitting this path where we think we have enough space,
let's log what we calculated here to aid in diagnosing why we
may later fail with ENOSPC.
  • Loading branch information
cgwalters committed Dec 19, 2023
1 parent 41c56b3 commit 39235bb
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions src/libostree/ostree-sysroot-deploy.c
Original file line number Diff line number Diff line change
Expand Up @@ -2657,6 +2657,7 @@ auto_early_prune_old_deployments (OstreeSysroot *self, GPtrArray *new_deployment
/* it wasn't in current_bootcsums; add */
net_new_bootcsum_dirs_total_size += bootdir_size;
}
g_autofree char *net_new_formatted = g_format_size (net_new_bootcsum_dirs_total_size);

{
gboolean bootfs_has_space = FALSE;
Expand All @@ -2667,9 +2668,13 @@ auto_early_prune_old_deployments (OstreeSysroot *self, GPtrArray *new_deployment
/* does the bootfs have enough free space for temporarily holding both the new
* and old bootdirs? */
if (bootfs_has_space)
return TRUE; /* nothing to do! */
{
g_printerr ("bootfs is sufficient for calculated new size: %s\n", net_new_formatted);
return TRUE; /* nothing to do! */
}
}

g_printerr ("bootfs requires additional space: %s\n", net_new_formatted);
/* OK, we would fail if we tried to write the new bootdirs. Is it salvageable?
* First, calculate how much space we could save with the bootcsums scheduled
* for removal. */
Expand All @@ -2680,14 +2685,17 @@ auto_early_prune_old_deployments (OstreeSysroot *self, GPtrArray *new_deployment
bootcsum_dirs_to_remove_total_size += GPOINTER_TO_UINT (sizep);
}

{
g_autofree char *to_remove_formated = g_format_size (bootcsum_dirs_to_remove_total_size);
g_printerr ("Size to prune from bootfs: %s\n", to_remove_formated);
}

if (net_new_bootcsum_dirs_total_size > bootcsum_dirs_to_remove_total_size)
{
/* Check whether if we did early prune, we'd have enough space to write
* the new bootcsum dirs. */
gboolean bootfs_has_space = FALSE;
if (!dfd_fallocate_check (
self->boot_fd, net_new_bootcsum_dirs_total_size - bootcsum_dirs_to_remove_total_size,
&bootfs_has_space, error))
if (!dfd_fallocate_check (self->boot_fd, required_new_space, &bootfs_has_space, error))
return glnx_prefix_error (error, "Checking if prune would give bootfs sufficient space");

if (!bootfs_has_space)
Expand Down

0 comments on commit 39235bb

Please sign in to comment.