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
15a90a10
Commit
15a90a10
authored
Jan 11, 2016
by
Serge Hallyn
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
copy_storage: try to use snapshot for btrfs
Signed-off-by:
Serge Hallyn
<
serge.hallyn@ubuntu.com
>
parent
c7ec3de8
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
0 deletions
+22
-0
lxccontainer.c
src/lxc/lxccontainer.c
+22
-0
No files found.
src/lxc/lxccontainer.c
View file @
15a90a10
...
@@ -41,6 +41,7 @@
...
@@ -41,6 +41,7 @@
#include "attach.h"
#include "attach.h"
#include "bdev/bdev.h"
#include "bdev/bdev.h"
#include "bdev/lxcoverlay.h"
#include "bdev/lxcoverlay.h"
#include "bdev/lxcbtrfs.h"
#include "cgroup.h"
#include "cgroup.h"
#include "conf.h"
#include "conf.h"
#include "config.h"
#include "config.h"
...
@@ -2817,12 +2818,33 @@ static bool add_rdepends(struct lxc_container *c, struct lxc_container *c0)
...
@@ -2817,12 +2818,33 @@ static bool add_rdepends(struct lxc_container *c, struct lxc_container *c0)
return
bret
;
return
bret
;
}
}
/*
* If the fs natively supports snapshot clones with no penalty,
* then default to those even if not requested.
* Currently we only do this for btrfs.
*/
bool
should_default_to_snapshot
(
struct
lxc_container
*
c0
,
struct
lxc_container
*
c1
)
{
size_t
l0
=
strlen
(
c0
->
config_path
)
+
strlen
(
c0
->
name
)
+
2
;
size_t
l1
=
strlen
(
c1
->
config_path
)
+
strlen
(
c1
->
name
)
+
2
;
char
*
p0
=
alloca
(
l0
+
1
);
char
*
p1
=
alloca
(
l1
+
1
);
snprintf
(
p0
,
l0
,
"%s/%s"
,
c0
->
config_path
,
c0
->
name
);
snprintf
(
p1
,
l1
,
"%s/%s"
,
c1
->
config_path
,
c1
->
name
);
return
btrfs_same_fs
(
p0
,
p1
)
==
0
;
}
static
int
copy_storage
(
struct
lxc_container
*
c0
,
struct
lxc_container
*
c
,
static
int
copy_storage
(
struct
lxc_container
*
c0
,
struct
lxc_container
*
c
,
const
char
*
newtype
,
int
flags
,
const
char
*
bdevdata
,
uint64_t
newsize
)
const
char
*
newtype
,
int
flags
,
const
char
*
bdevdata
,
uint64_t
newsize
)
{
{
struct
bdev
*
bdev
;
struct
bdev
*
bdev
;
int
need_rdep
;
int
need_rdep
;
if
(
should_default_to_snapshot
(
c0
,
c
))
flags
|=
LXC_CLONE_SNAPSHOT
;
bdev
=
bdev_copy
(
c0
,
c
->
name
,
c
->
config_path
,
newtype
,
flags
,
bdev
=
bdev_copy
(
c0
,
c
->
name
,
c
->
config_path
,
newtype
,
flags
,
bdevdata
,
newsize
,
&
need_rdep
);
bdevdata
,
newsize
,
&
need_rdep
);
if
(
!
bdev
)
{
if
(
!
bdev
)
{
...
...
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