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/machine/machined-dbus.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'src/machine/machined-dbus.c') diff --git a/src/machine/machined-dbus.c b/src/machine/machined-dbus.c index 5ab40b0410..adba8122f3 100644 --- a/src/machine/machined-dbus.c +++ b/src/machine/machined-dbus.c @@ -805,14 +805,16 @@ static int method_set_pool_limit(sd_bus *bus, sd_bus_message *message, void *use if (r < 0) return r; - r = btrfs_resize_loopback("/var/lib/machines", limit); - if (r < 0 && r != -ENODEV) + r = btrfs_resize_loopback("/var/lib/machines", limit, false); + if (r == -ENOTTY) + return sd_bus_error_setf(error, SD_BUS_ERROR_NOT_SUPPORTED, "Quota is only supported on btrfs."); + if (r < 0 && r != -ENODEV) /* ignore ENODEV, as that's what is returned if the file system is not on loopback */ return sd_bus_error_set_errnof(error, r, "Failed to adjust loopback limit: %m"); r = btrfs_quota_limit("/var/lib/machines", limit); if (r == -ENOTTY) return sd_bus_error_setf(error, SD_BUS_ERROR_NOT_SUPPORTED, "Quota is only supported on btrfs."); - else if (r < 0) + if (r < 0) return sd_bus_error_set_errnof(error, r, "Failed to adjust quota limit: %m"); return sd_bus_reply_method_return(message, NULL); -- cgit v1.2.3-54-g00ecf