]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
import: set up btrfs qgroups on correct hierarchy
authorLennart Poettering <lennart@poettering.net>
Fri, 22 Jan 2021 17:49:44 +0000 (18:49 +0100)
committerLennart Poettering <lennart@poettering.net>
Fri, 22 Jan 2021 19:54:51 +0000 (20:54 +0100)
Also, simplify import_assign_pool_quota_and_warn(), don't do the same
thing twice. Let's just allow the caller call this twice.

src/import/import-fs.c
src/import/import-tar.c
src/import/pull-tar.c
src/shared/import-util.c

index a36ab24fb8e7bf2c796849147e69a7619c5d2709..1fe5a257dbd66b720b2b86b1e4a31494e719b000 100644 (file)
@@ -196,6 +196,7 @@ static int import_fs(int argc, char *argv[], void *userdata) {
         if (r < 0)
                 goto finish;
 
+        (void) import_assign_pool_quota_and_warn(arg_image_root);
         (void) import_assign_pool_quota_and_warn(temp_path);
 
         if (arg_read_only) {
index cc86bebb0e95dbde5f24f653ec4e33e9b4f322e2..6baa2f43abffdb535d2c0d2d0702c20702dffad7 100644 (file)
@@ -222,8 +222,10 @@ static int tar_import_fork_tar(TarImport *i) {
         r = btrfs_subvol_make_fallback(i->temp_path, 0755);
         if (r < 0)
                 return log_error_errno(r, "Failed to create directory/subvolume %s: %m", i->temp_path);
-        if (r > 0) /* actually btrfs subvol */
+        if (r > 0) { /* actually btrfs subvol */
+                (void) import_assign_pool_quota_and_warn(i->image_root);
                 (void) import_assign_pool_quota_and_warn(i->temp_path);
+        }
 
         i->tar_fd = import_fork_tar_x(i->temp_path, &i->tar_pid);
         if (i->tar_fd < 0)
index b52569d20c5a998a9b7d879fa69f90cce74a6c60..90f439f998dd1e5bef78592d04bc0bf6e0e42bce 100644 (file)
@@ -424,8 +424,10 @@ static int tar_pull_job_on_open_disk_tar(PullJob *j) {
         r = btrfs_subvol_make_fallback(i->temp_path, 0755);
         if (r < 0)
                 return log_error_errno(r, "Failed to create directory/subvolume %s: %m", i->temp_path);
-        if (r > 0) /* actually btrfs subvol */
+        if (r > 0) { /* actually btrfs subvol */
+                (void) import_assign_pool_quota_and_warn(i->image_root);
                 (void) import_assign_pool_quota_and_warn(i->temp_path);
+        }
 
         j->disk_fd = import_fork_tar_x(i->temp_path, &i->tar_pid);
         if (j->disk_fd < 0)
index 298c066dffd857c9a1a77150346469a37228c7dd..2a30e40686f4d58b1d2dfc1bf9aaaa20cda5b671 100644 (file)
@@ -143,15 +143,7 @@ int raw_strip_suffixes(const char *p, char **ret) {
 int import_assign_pool_quota_and_warn(const char *path) {
         int r;
 
-        r = btrfs_subvol_auto_qgroup("/var/lib/machines", 0, true);
-        if (r == -ENOTTY)  {
-                log_debug_errno(r, "Failed to set up default quota hierarchy for /var/lib/machines, as directory is not on btrfs or not a subvolume. Ignoring.");
-                return 0;
-        }
-        if (r < 0)
-                return log_error_errno(r, "Failed to set up default quota hierarchy for /var/lib/machines: %m");
-        if (r > 0)
-                log_info("Set up default quota hierarchy for /var/lib/machines.");
+        assert(path);
 
         r = btrfs_subvol_auto_qgroup(path, 0, true);
         if (r == -ENOTTY) {