Unverified Commit 9a534c22 by Christian Brauner Committed by Stéphane Graber

storage: rework lvm backend

parent a3e85dae
...@@ -138,8 +138,8 @@ static const struct bdev_ops lvm_ops = { ...@@ -138,8 +138,8 @@ static const struct bdev_ops lvm_ops = {
.clone_paths = &lvm_clonepaths, .clone_paths = &lvm_clonepaths,
.destroy = &lvm_destroy, .destroy = &lvm_destroy,
.create = &lvm_create, .create = &lvm_create,
.create_clone = NULL, .create_clone = &lvm_create_clone,
.create_snapshot = NULL, .create_snapshot = &lvm_create_snapshot,
.can_snapshot = true, .can_snapshot = true,
.can_backup = false, .can_backup = false,
}; };
...@@ -444,6 +444,19 @@ struct bdev *bdev_copy(struct lxc_container *c0, const char *cname, ...@@ -444,6 +444,19 @@ struct bdev *bdev_copy(struct lxc_container *c0, const char *cname,
return new; return new;
} }
if (!strcmp(orig->type, "lvm") && !strcmp(new->type, "lvm")) {
bool bret = false;
if (snap)
bret = new->ops->create_snapshot(c0->lxc_conf, orig,
new, newsize);
else
bret = new->ops->create_clone(c0->lxc_conf, orig, new,
newsize);
if (!bret)
return NULL;
return new;
}
if (strcmp(bdevtype, "btrfs")) { if (strcmp(bdevtype, "btrfs")) {
if (!strcmp(new->type, "overlay") || if (!strcmp(new->type, "overlay") ||
!strcmp(new->type, "overlayfs")) !strcmp(new->type, "overlayfs"))
......
...@@ -25,6 +25,7 @@ ...@@ -25,6 +25,7 @@
#define __LXC_LVM_H #define __LXC_LVM_H
#define _GNU_SOURCE #define _GNU_SOURCE
#include <stdbool.h>
#include <stdint.h> #include <stdint.h>
/* defined in bdev.h */ /* defined in bdev.h */
...@@ -52,5 +53,9 @@ int lvm_clonepaths(struct bdev *orig, struct bdev *new, const char *oldname, ...@@ -52,5 +53,9 @@ int lvm_clonepaths(struct bdev *orig, struct bdev *new, const char *oldname,
int lvm_destroy(struct bdev *orig); int lvm_destroy(struct bdev *orig);
int lvm_create(struct bdev *bdev, const char *dest, const char *n, int lvm_create(struct bdev *bdev, const char *dest, const char *n,
struct bdev_specs *specs); struct bdev_specs *specs);
bool lvm_create_clone(struct lxc_conf *conf, struct bdev *orig,
struct bdev *new, uint64_t newsize);
bool lvm_create_snapshot(struct lxc_conf *conf, struct bdev *orig,
struct bdev *new, uint64_t newsize);
#endif /* __LXC_LVM_H */ #endif /* __LXC_LVM_H */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment