summaryrefslogtreecommitdiff
path: root/src/import
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2015-10-21 19:38:21 +0200
committerLennart Poettering <lennart@poettering.net>2015-10-22 01:59:25 +0200
commit5bcd08db289cd02aad8a89b37b2a46244a7bd473 (patch)
treea34bbcc4df2824efe169bf041572b0f78dc2620a /src/import
parent16597ac3903ddb68d5ef75e6aaa37e43866a376d (diff)
btrfs: beef-up btrfs support with a limited understanding of quota
With this change we understand more than just leaf quota groups for btrfs file systems. Specifically: - When we create a subvolume we can now optionally add the new subvolume to all qgroups its parent subvolume was member of too. Alternatively it is also possible to insert an intermediary quota group between the parent's qgroups and the subvolume's leaf qgroup, which is useful for a concept of "subtree" qgroups, that contain a subvolume and all its children. - The remove logic for subvolumes has been updated to optionally remove any leaf qgroups or "subtree" qgroups, following the logic above. - The snapshot logic for subvolumes has been updated to replicate the original qgroup setup of the source, if it follows the "subtree" design described above. It will not cover qgroup setups that introduce arbitrary qgroups, especially those orthogonal to the subvolume hierarchy. This also tries to be more graceful when setting up /var/lib/machines as btrfs. For example, if mkfs.btrfs is missing we don't even try to set it up as loopback device. Fixes #1559 Fixes #1129
Diffstat (limited to 'src/import')
-rw-r--r--src/import/export-tar.c4
-rw-r--r--src/import/pull-common.c2
-rw-r--r--src/import/pull-dkr.c14
3 files changed, 13 insertions, 7 deletions
diff --git a/src/import/export-tar.c b/src/import/export-tar.c
index 43fa9d1b03..a623745f5f 100644
--- a/src/import/export-tar.c
+++ b/src/import/export-tar.c
@@ -78,7 +78,7 @@ TarExport *tar_export_unref(TarExport *e) {
}
if (e->temp_path) {
- (void) btrfs_subvol_remove(e->temp_path, false);
+ (void) btrfs_subvol_remove(e->temp_path, BTRFS_REMOVE_QUOTA);
free(e->temp_path);
}
@@ -283,7 +283,7 @@ int tar_export_start(TarExport *e, const char *path, int fd, ImportCompressType
if (e->st.st_ino == 256) { /* might be a btrfs subvolume? */
BtrfsQuotaInfo q;
- r = btrfs_subvol_get_quota_fd(sfd, &q);
+ r = btrfs_subvol_get_subtree_quota_fd(sfd, 0, &q);
if (r >= 0)
e->quota_referenced = q.referenced;
diff --git a/src/import/pull-common.c b/src/import/pull-common.c
index 1ddb48e03f..90d28f04d9 100644
--- a/src/import/pull-common.c
+++ b/src/import/pull-common.c
@@ -138,7 +138,7 @@ int pull_make_local_copy(const char *final, const char *image_root, const char *
if (force_local)
(void) rm_rf(p, REMOVE_ROOT|REMOVE_PHYSICAL|REMOVE_SUBVOLUME);
- r = btrfs_subvol_snapshot(final, p, 0);
+ r = btrfs_subvol_snapshot(final, p, BTRFS_SNAPSHOT_QUOTA);
if (r == -ENOTTY) {
r = copy_tree(final, p, false);
if (r < 0)
diff --git a/src/import/pull-dkr.c b/src/import/pull-dkr.c
index 0dab184af1..b77f3e47f1 100644
--- a/src/import/pull-dkr.c
+++ b/src/import/pull-dkr.c
@@ -490,10 +490,16 @@ static int dkr_pull_make_local_copy(DkrPull *i, DkrPullVersion version) {
return r;
if (version == DKR_PULL_V2) {
- char **k = NULL;
+ char **k;
+
STRV_FOREACH(k, i->ancestry) {
- _cleanup_free_ char *d = strjoin(i->image_root, "/.dkr-", *k, NULL);
- r = btrfs_subvol_remove(d, false);
+ _cleanup_free_ char *d;
+
+ d = strjoin(i->image_root, "/.dkr-", *k, NULL);
+ if (!d)
+ return -ENOMEM;
+
+ r = btrfs_subvol_remove(d, BTRFS_REMOVE_QUOTA);
if (r < 0)
return r;
}
@@ -531,7 +537,7 @@ static int dkr_pull_job_on_open_disk(PullJob *j) {
const char *base_path;
base_path = strjoina(i->image_root, "/.dkr-", base);
- r = btrfs_subvol_snapshot(base_path, i->temp_path, BTRFS_SNAPSHOT_FALLBACK_COPY);
+ r = btrfs_subvol_snapshot(base_path, i->temp_path, BTRFS_SNAPSHOT_FALLBACK_COPY|BTRFS_SNAPSHOT_QUOTA);
} else
r = btrfs_subvol_make(i->temp_path);
if (r < 0)