mirror of
https://github.com/ostreedev/ostree.git
synced 2025-01-18 10:04:17 +03:00
lib/repo: Cleanup current boot's staging dir min-free-space-* checks are hit
min-free-space-* act as a gating condition whether to we want hold onto caches in repo/tmp. If it is found that the free-disk space is going below this threshold, we flag it as an error and cleanup current boot's staging directory. Closes: #1602 Approved by: jlebon
This commit is contained in:
parent
1074668ede
commit
d686056254
@ -522,6 +522,7 @@ _ostree_repo_bare_content_commit (OstreeRepo *self,
|
||||
const fsblkcnt_t object_blocks = (st_buf.st_size / self->txn.blocksize) + 1;
|
||||
if (object_blocks > self->txn.max_blocks)
|
||||
{
|
||||
self->cleanup_stagedir = TRUE;
|
||||
g_mutex_unlock (&self->txn_lock);
|
||||
g_autofree char *formatted_required = g_format_size (st_buf.st_size);
|
||||
if (self->min_free_space_percent > 0)
|
||||
@ -924,6 +925,7 @@ write_content_object (OstreeRepo *self,
|
||||
if (object_blocks > self->txn.max_blocks)
|
||||
{
|
||||
guint64 bytes_required = (guint64)object_blocks * self->txn.blocksize;
|
||||
self->cleanup_stagedir = TRUE;
|
||||
g_mutex_unlock (&self->txn_lock);
|
||||
g_autofree char *formatted_required = g_format_size (bytes_required);
|
||||
if (self->min_free_space_percent > 0)
|
||||
@ -1623,6 +1625,7 @@ ostree_repo_prepare_transaction (OstreeRepo *self,
|
||||
return FALSE;
|
||||
|
||||
self->in_transaction = TRUE;
|
||||
self->cleanup_stagedir = FALSE;
|
||||
if (self->min_free_space_percent >= 0 || self->min_free_space_mb >= 0)
|
||||
{
|
||||
struct statvfs stvfsbuf;
|
||||
@ -1638,6 +1641,7 @@ ostree_repo_prepare_transaction (OstreeRepo *self,
|
||||
else
|
||||
{
|
||||
guint64 bytes_required = bfree * self->txn.blocksize;
|
||||
self->cleanup_stagedir = TRUE;
|
||||
g_mutex_unlock (&self->txn_lock);
|
||||
g_autofree char *formatted_free = g_format_size (bytes_required);
|
||||
if (self->min_free_space_percent > 0)
|
||||
@ -1783,9 +1787,10 @@ cleanup_txn_dir (OstreeRepo *self,
|
||||
|
||||
/* If however this is the staging directory for the *current*
|
||||
* boot, then don't delete it now - we may end up reusing it, as
|
||||
* is the point.
|
||||
* is the point. Delete *only if* we have hit min-free-space* checks
|
||||
* as we don't want to hold onto caches in that case.
|
||||
*/
|
||||
if (g_str_has_prefix (path, self->stagedir_prefix))
|
||||
if (g_str_has_prefix (path, self->stagedir_prefix) && !self->cleanup_stagedir)
|
||||
return TRUE; /* Note early return */
|
||||
|
||||
/* But, crucially we can now clean up staging directories
|
||||
|
@ -152,6 +152,7 @@ struct OstreeRepo {
|
||||
gid_t target_owner_gid;
|
||||
guint min_free_space_percent; /* See the min-free-space-percent config option */
|
||||
guint64 min_free_space_mb; /* See the min-free-space-size config option */
|
||||
gboolean cleanup_stagedir;
|
||||
|
||||
guint test_error_flags; /* OstreeRepoTestErrorFlags */
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user