1
0
mirror of https://github.com/systemd/systemd.git synced 2025-01-27 18:04:05 +03:00

import: set up btrfs qgroups on correct hierarchy

Also, simplify import_assign_pool_quota_and_warn(), don't do the same
thing twice. Let's just allow the caller call this twice.
This commit is contained in:
Lennart Poettering 2021-01-22 18:49:44 +01:00
parent 2ab214eac1
commit 052ba0ebae
4 changed files with 8 additions and 11 deletions

View 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) {

View 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)

View 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)

View 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) {