Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
L
lxc
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Chen Yisong
lxc
Commits
3ef1df7c
Unverified
Commit
3ef1df7c
authored
Jul 25, 2017
by
Christian Brauner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
zfs: rework zfs storage driver
Signed-off-by:
Christian Brauner
<
christian.brauner@ubuntu.com
>
parent
f83dd99e
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
56 additions
and
49 deletions
+56
-49
bdev.c
src/lxc/bdev/bdev.c
+36
-23
bdev.h
src/lxc/bdev/bdev.h
+4
-4
lxczfs.c
src/lxc/bdev/lxczfs.c
+0
-0
lxczfs.h
src/lxc/bdev/lxczfs.h
+16
-22
No files found.
src/lxc/bdev/bdev.c
View file @
3ef1df7c
...
...
@@ -82,8 +82,8 @@ static const struct bdev_ops aufs_ops = {
.
clone_paths
=
&
aufs_clonepaths
,
.
destroy
=
&
aufs_destroy
,
.
create
=
&
aufs_create
,
.
c
reate_clone
=
NULL
,
.
create_
snapshot
=
NULL
,
.
c
opy
=
NULL
,
.
snapshot
=
NULL
,
.
can_snapshot
=
true
,
.
can_backup
=
true
,
};
...
...
@@ -96,8 +96,8 @@ static const struct bdev_ops btrfs_ops = {
.
clone_paths
=
&
btrfs_clonepaths
,
.
destroy
=
&
btrfs_destroy
,
.
create
=
&
btrfs_create
,
.
c
reate_clone
=
&
btrfs_create_clone
,
.
create_
snapshot
=
&
btrfs_create_snapshot
,
.
c
opy
=
&
btrfs_create_clone
,
.
snapshot
=
&
btrfs_create_snapshot
,
.
can_snapshot
=
true
,
.
can_backup
=
true
,
};
...
...
@@ -110,8 +110,8 @@ static const struct bdev_ops dir_ops = {
.
clone_paths
=
&
dir_clonepaths
,
.
destroy
=
&
dir_destroy
,
.
create
=
&
dir_create
,
.
c
reate_clone
=
NULL
,
.
create_
snapshot
=
NULL
,
.
c
opy
=
NULL
,
.
snapshot
=
NULL
,
.
can_snapshot
=
false
,
.
can_backup
=
true
,
};
...
...
@@ -124,8 +124,8 @@ static const struct bdev_ops loop_ops = {
.
clone_paths
=
&
loop_clonepaths
,
.
destroy
=
&
loop_destroy
,
.
create
=
&
loop_create
,
.
c
reate_clone
=
NULL
,
.
create_
snapshot
=
NULL
,
.
c
opy
=
NULL
,
.
snapshot
=
NULL
,
.
can_snapshot
=
false
,
.
can_backup
=
true
,
};
...
...
@@ -138,8 +138,8 @@ static const struct bdev_ops lvm_ops = {
.
clone_paths
=
&
lvm_clonepaths
,
.
destroy
=
&
lvm_destroy
,
.
create
=
&
lvm_create
,
.
c
reate_clone
=
&
lvm_create_clone
,
.
create_
snapshot
=
&
lvm_create_snapshot
,
.
c
opy
=
&
lvm_create_clone
,
.
snapshot
=
&
lvm_create_snapshot
,
.
can_snapshot
=
true
,
.
can_backup
=
false
,
};
...
...
@@ -152,8 +152,8 @@ const struct bdev_ops nbd_ops = {
.
clone_paths
=
&
nbd_clonepaths
,
.
destroy
=
&
nbd_destroy
,
.
create
=
&
nbd_create
,
.
c
reate_clone
=
NULL
,
.
create_
snapshot
=
NULL
,
.
c
opy
=
NULL
,
.
snapshot
=
NULL
,
.
can_snapshot
=
true
,
.
can_backup
=
false
,
};
...
...
@@ -166,8 +166,8 @@ static const struct bdev_ops ovl_ops = {
.
clone_paths
=
&
ovl_clonepaths
,
.
destroy
=
&
ovl_destroy
,
.
create
=
&
ovl_create
,
.
c
reate_clone
=
NULL
,
.
create_
snapshot
=
NULL
,
.
c
opy
=
NULL
,
.
snapshot
=
NULL
,
.
can_snapshot
=
true
,
.
can_backup
=
true
,
};
...
...
@@ -180,8 +180,8 @@ static const struct bdev_ops rbd_ops = {
.
clone_paths
=
&
rbd_clonepaths
,
.
destroy
=
&
rbd_destroy
,
.
create
=
&
rbd_create
,
.
c
reate_clone
=
NULL
,
.
create_
snapshot
=
NULL
,
.
c
opy
=
NULL
,
.
snapshot
=
NULL
,
.
can_snapshot
=
false
,
.
can_backup
=
false
,
};
...
...
@@ -194,8 +194,8 @@ static const struct bdev_ops zfs_ops = {
.
clone_paths
=
&
zfs_clonepaths
,
.
destroy
=
&
zfs_destroy
,
.
create
=
&
zfs_create
,
.
c
reate_clone
=
NULL
,
.
create_snapshot
=
NULL
,
.
c
opy
=
&
zfs_copy
,
.
snapshot
=
&
zfs_snapshot
,
.
can_snapshot
=
true
,
.
can_backup
=
true
,
};
...
...
@@ -436,9 +436,9 @@ struct bdev *bdev_copy(struct lxc_container *c0, const char *cname,
if
(
!
strcmp
(
orig
->
type
,
"btrfs"
)
&&
!
strcmp
(
new
->
type
,
"btrfs"
))
{
bool
bret
=
false
;
if
(
snap
||
btrfs_same_fs
(
orig
->
dest
,
new
->
dest
)
==
0
)
bret
=
new
->
ops
->
create_
snapshot
(
c0
->
lxc_conf
,
orig
,
new
,
0
);
bret
=
new
->
ops
->
snapshot
(
c0
->
lxc_conf
,
orig
,
new
,
0
);
else
bret
=
new
->
ops
->
c
reate_clone
(
c0
->
lxc_conf
,
orig
,
new
,
0
);
bret
=
new
->
ops
->
c
opy
(
c0
->
lxc_conf
,
orig
,
new
,
0
);
if
(
!
bret
)
return
NULL
;
return
new
;
...
...
@@ -448,11 +448,24 @@ struct bdev *bdev_copy(struct lxc_container *c0, const char *cname,
if
(
!
strcmp
(
orig
->
type
,
"lvm"
)
&&
!
strcmp
(
new
->
type
,
"lvm"
))
{
bool
bret
=
false
;
if
(
snap
)
bret
=
new
->
ops
->
create_
snapshot
(
c0
->
lxc_conf
,
orig
,
bret
=
new
->
ops
->
snapshot
(
c0
->
lxc_conf
,
orig
,
new
,
newsize
);
else
bret
=
new
->
ops
->
create_clone
(
c0
->
lxc_conf
,
orig
,
new
,
newsize
);
bret
=
new
->
ops
->
copy
(
c0
->
lxc_conf
,
orig
,
new
,
newsize
);
if
(
!
bret
)
return
NULL
;
return
new
;
}
/* zfs */
if
(
!
strcmp
(
orig
->
type
,
"zfs"
)
&&
!
strcmp
(
new
->
type
,
"zfs"
))
{
bool
bret
=
false
;
if
(
snap
)
bret
=
new
->
ops
->
snapshot
(
c0
->
lxc_conf
,
orig
,
new
,
newsize
);
else
bret
=
new
->
ops
->
copy
(
c0
->
lxc_conf
,
orig
,
new
,
newsize
);
if
(
!
bret
)
return
NULL
;
return
new
;
...
...
src/lxc/bdev/bdev.h
View file @
3ef1df7c
...
...
@@ -73,10 +73,10 @@ struct bdev_ops {
const
char
*
oldname
,
const
char
*
cname
,
const
char
*
oldpath
,
const
char
*
lxcpath
,
int
snap
,
uint64_t
newsize
,
struct
lxc_conf
*
conf
);
bool
(
*
c
reate_clone
)(
struct
lxc_conf
*
conf
,
struct
bdev
*
orig
,
struct
bdev
*
new
,
uint64_t
newsize
);
bool
(
*
create_
snapshot
)(
struct
lxc_conf
*
conf
,
struct
bdev
*
orig
,
struct
bdev
*
new
,
uint64_t
newsize
);
bool
(
*
c
opy
)(
struct
lxc_conf
*
conf
,
struct
bdev
*
orig
,
struct
bdev
*
new
,
uint64_t
newsize
);
bool
(
*
snapshot
)(
struct
lxc_conf
*
conf
,
struct
bdev
*
orig
,
struct
bdev
*
new
,
uint64_t
newsize
);
bool
can_snapshot
;
bool
can_backup
;
};
...
...
src/lxc/bdev/lxczfs.c
View file @
3ef1df7c
This diff is collapsed.
Click to expand it.
src/lxc/bdev/lxczfs.h
View file @
3ef1df7c
...
...
@@ -25,36 +25,30 @@
#define __LXC_ZFS_H
#define _GNU_SOURCE
#include <stdbool.h>
#include <stdio.h>
#include <stdint.h>
/* defined in bdev.h */
struct
bdev
;
/* defined in lxccontainer.h */
struct
bdev_specs
;
/* defined conf.h */
struct
lxc_conf
;
/*
* Functions associated with an zfs bdev struct.
*/
int
zfs_clone
(
const
char
*
opath
,
const
char
*
npath
,
const
char
*
oname
,
const
char
*
nname
,
const
char
*
lxcpath
,
int
snapshot
);
int
zfs_clonepaths
(
struct
bdev
*
orig
,
struct
bdev
*
new
,
const
char
*
oldname
,
const
char
*
cname
,
const
char
*
oldpath
,
const
char
*
lxcpath
,
int
snap
,
uint64_t
newsize
,
struct
lxc_conf
*
conf
);
int
zfs_create
(
struct
bdev
*
bdev
,
const
char
*
dest
,
const
char
*
n
,
struct
bdev_specs
*
specs
);
/*
* TODO: detect whether this was a clone, and if so then also delete the
* snapshot it was based on, so that we don't hold the original
* container busy.
*/
int
zfs_destroy
(
struct
bdev
*
orig
);
bool
zfs_detect
(
const
char
*
path
);
int
zfs_mount
(
struct
bdev
*
bdev
);
int
zfs_umount
(
struct
bdev
*
bdev
);
extern
int
zfs_clonepaths
(
struct
bdev
*
orig
,
struct
bdev
*
new
,
const
char
*
oldname
,
const
char
*
cname
,
const
char
*
oldpath
,
const
char
*
lxcpath
,
int
snap
,
uint64_t
newsize
,
struct
lxc_conf
*
conf
);
extern
int
zfs_create
(
struct
bdev
*
bdev
,
const
char
*
dest
,
const
char
*
n
,
struct
bdev_specs
*
specs
);
extern
int
zfs_destroy
(
struct
bdev
*
orig
);
extern
bool
zfs_detect
(
const
char
*
path
);
extern
int
zfs_mount
(
struct
bdev
*
bdev
);
extern
int
zfs_umount
(
struct
bdev
*
bdev
);
extern
bool
zfs_copy
(
struct
lxc_conf
*
conf
,
struct
bdev
*
orig
,
struct
bdev
*
new
,
uint64_t
newsize
);
extern
bool
zfs_snapshot
(
struct
lxc_conf
*
conf
,
struct
bdev
*
orig
,
struct
bdev
*
new
,
uint64_t
newsize
);
#endif
/* __LXC_ZFS_H */
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment