From 26166c88e0b47b83972f32b5057ecbffe06bf904 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Tue, 3 Mar 2015 00:13:12 +0100 Subject: 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%). --- src/import/import-raw.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src/import/import-raw.c') diff --git a/src/import/import-raw.c b/src/import/import-raw.c index 8d99f1085c..89c064cb3d 100644 --- a/src/import/import-raw.c +++ b/src/import/import-raw.c @@ -31,6 +31,7 @@ #include "util.h" #include "macro.h" #include "mkdir.h" +#include "path-util.h" #include "import-util.h" #include "curl-util.h" #include "qcow2-util.h" @@ -61,6 +62,7 @@ struct RawImport { char *local; bool force_local; + bool grow_machine_directory; char *temp_path; char *final_path; @@ -115,6 +117,8 @@ int raw_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 { @@ -480,6 +484,7 @@ int raw_import_pull(RawImport *i, const char *url, const char *local, bool force i->raw_job->on_open_disk = raw_import_job_on_open_disk; i->raw_job->on_progress = raw_import_job_on_progress; i->raw_job->calc_checksum = verify != IMPORT_VERIFY_NO; + i->raw_job->grow_machine_directory = i->grow_machine_directory; r = import_find_old_etags(url, i->image_root, DT_REG, ".raw-", ".raw", &i->raw_job->old_etags); if (r < 0) -- cgit v1.2.3-54-g00ecf