summaryrefslogtreecommitdiff
path: root/src/import/import-tar.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2015-03-03 00:13:12 +0100
committerLennart Poettering <lennart@poettering.net>2015-03-03 00:13:12 +0100
commit26166c88e0b47b83972f32b5057ecbffe06bf904 (patch)
treeafff66bbc1b717d9202c16ff1c1b131fa307c272 /src/import/import-tar.c
parenta68188812290cb9ec9f3f8a17b65e64549a4fd65 (diff)
importd: automatically grow /var/lib/machines/ loopback filesystem during downloads
If /var/lib/machines is mounted as btrfs loopback file system in /var/lib/machines.raw with this change we automatically grow the file system as it fills up. After each 10M we write to it during imports, we check the free disk space, and if the fill level grows beyond 66% we increase the size of the file system to 3x the fill level (thus lowering it to 33%).
Diffstat (limited to 'src/import/import-tar.c')
-rw-r--r--src/import/import-tar.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/import/import-tar.c b/src/import/import-tar.c
index 493252a132..472e336247 100644
--- a/src/import/import-tar.c
+++ b/src/import/import-tar.c
@@ -30,6 +30,7 @@
#include "util.h"
#include "macro.h"
#include "mkdir.h"
+#include "path-util.h"
#include "import-util.h"
#include "curl-util.h"
#include "import-job.h"
@@ -58,6 +59,7 @@ struct TarImport {
char *local;
bool force_local;
+ bool grow_machine_directory;
pid_t tar_pid;
@@ -121,6 +123,8 @@ int tar_import_new(
if (!i->image_root)
return -ENOMEM;
+ i->grow_machine_directory = path_startswith(i->image_root, "/var/lib/machines");
+
if (event)
i->event = sd_event_ref(event);
else {
@@ -376,6 +380,7 @@ int tar_import_pull(TarImport *i, const char *url, const char *local, bool force
i->tar_job->on_open_disk = tar_import_job_on_open_disk;
i->tar_job->on_progress = tar_import_job_on_progress;
i->tar_job->calc_checksum = verify != IMPORT_VERIFY_NO;
+ i->tar_job->grow_machine_directory = i->grow_machine_directory;
r = import_find_old_etags(url, i->image_root, DT_DIR, ".tar-", NULL, &i->tar_job->old_etags);
if (r < 0)