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
874a329c
Unverified
Commit
874a329c
authored
Jul 15, 2017
by
Christian Brauner
Committed by
Stéphane Graber
Aug 14, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
btrfs: simplify + bugfix
Closes #1698. Closes #1703. Signed-off-by:
Christian Brauner
<
christian.brauner@ubuntu.com
>
parent
92c2183c
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
22 deletions
+10
-22
bdev.c
src/lxc/bdev/bdev.c
+2
-1
lxcbtrfs.c
src/lxc/bdev/lxcbtrfs.c
+8
-21
No files found.
src/lxc/bdev/bdev.c
View file @
874a329c
...
@@ -392,7 +392,7 @@ struct bdev *bdev_copy(struct lxc_container *c0, const char *cname,
...
@@ -392,7 +392,7 @@ struct bdev *bdev_copy(struct lxc_container *c0, const char *cname,
*
needs_rdep
=
1
;
*
needs_rdep
=
1
;
}
}
if
(
strcmp
(
oldpath
,
lxcpath
)
&&
!
bdevtype
)
if
(
strcmp
(
oldpath
,
lxcpath
)
&&
!
bdevtype
&&
!
snap
)
bdevtype
=
"dir"
;
bdevtype
=
"dir"
;
else
if
(
!
bdevtype
)
else
if
(
!
bdevtype
)
bdevtype
=
orig
->
type
;
bdevtype
=
orig
->
type
;
...
@@ -403,6 +403,7 @@ struct bdev *bdev_copy(struct lxc_container *c0, const char *cname,
...
@@ -403,6 +403,7 @@ struct bdev *bdev_copy(struct lxc_container *c0, const char *cname,
bdev_put
(
orig
);
bdev_put
(
orig
);
return
NULL
;
return
NULL
;
}
}
TRACE
(
"Detected
\"
%s
\"
storage driver"
,
new
->
type
);
if
(
new
->
ops
->
clone_paths
(
orig
,
new
,
oldname
,
cname
,
oldpath
,
lxcpath
,
if
(
new
->
ops
->
clone_paths
(
orig
,
new
,
oldname
,
cname
,
oldpath
,
lxcpath
,
snap
,
newsize
,
c0
->
lxc_conf
)
<
0
)
{
snap
,
newsize
,
c0
->
lxc_conf
)
<
0
)
{
...
...
src/lxc/bdev/lxcbtrfs.c
View file @
874a329c
...
@@ -32,6 +32,7 @@
...
@@ -32,6 +32,7 @@
#include <unistd.h>
#include <unistd.h>
#include <sys/ioctl.h>
#include <sys/ioctl.h>
#include <sys/stat.h>
#include <sys/stat.h>
#include <sys/wait.h>
#include <sys/types.h>
#include <sys/types.h>
#include <sys/vfs.h>
#include <sys/vfs.h>
...
@@ -39,14 +40,10 @@
...
@@ -39,14 +40,10 @@
#include "log.h"
#include "log.h"
#include "lxcbtrfs.h"
#include "lxcbtrfs.h"
#include "lxcrsync.h"
#include "lxcrsync.h"
#include "utils.h"
#include "
../
utils.h"
lxc_log_define
(
lxcbtrfs
,
lxc
);
lxc_log_define
(
lxcbtrfs
,
lxc
);
/* defined in lxccontainer.c: needs to become common helper */
extern
char
*
dir_new_path
(
char
*
src
,
const
char
*
oldname
,
const
char
*
name
,
const
char
*
oldpath
,
const
char
*
lxcpath
);
/*
/*
* Return the full path of objid under dirid. Let's say dirid is
* Return the full path of objid under dirid. Let's say dirid is
* /lxc/c1/rootfs, and objid is /lxc/c1/rootfs/a/b/c. Then we will
* /lxc/c1/rootfs, and objid is /lxc/c1/rootfs/a/b/c. Then we will
...
@@ -377,30 +374,20 @@ int btrfs_clonepaths(struct bdev *orig, struct bdev *new, const char *oldname,
...
@@ -377,30 +374,20 @@ int btrfs_clonepaths(struct bdev *orig, struct bdev *new, const char *oldname,
if
(
!
orig
->
dest
||
!
orig
->
src
)
if
(
!
orig
->
dest
||
!
orig
->
src
)
return
-
1
;
return
-
1
;
if
(
strcmp
(
orig
->
type
,
"btrfs"
))
{
if
(
strcmp
(
orig
->
type
,
"btrfs"
)
&&
snap
)
{
int
len
,
ret
;
if
(
snap
)
{
ERROR
(
"btrfs snapshot from %s backing store is not supported"
,
ERROR
(
"btrfs snapshot from %s backing store is not supported"
,
orig
->
type
);
orig
->
type
);
return
-
1
;
return
-
1
;
}
}
len
=
strlen
(
lxcpath
)
+
strlen
(
cname
)
+
strlen
(
"rootfs"
)
+
6
+
3
;
new
->
src
=
lxc_string_join
(
new
->
src
=
malloc
(
len
);
"/"
,
(
const
char
*
[]){
"btrfs:"
,
*
lxcpath
!=
'/'
?
lxcpath
:
++
lxcpath
,
cname
,
"rootfs"
,
NULL
},
false
);
if
(
!
new
->
src
)
if
(
!
new
->
src
)
return
-
1
;
return
-
1
;
ret
=
snprintf
(
new
->
src
,
len
,
"btrfs:%s/%s/rootfs"
,
lxcpath
,
cname
);
if
(
ret
<
0
||
ret
>=
len
)
return
-
1
;
}
else
{
/* In case rootfs is in custom path, reuse it. */
new
->
src
=
dir_new_path
(
orig
->
src
,
oldname
,
cname
,
oldpath
,
lxcpath
);
if
(
!
new
->
src
)
return
-
1
;
}
src
=
lxc_storage_get_path
(
new
->
src
,
"btrfs"
);
src
=
lxc_storage_get_path
(
new
->
src
,
"btrfs"
);
new
->
dest
=
strdup
(
src
);
new
->
dest
=
strdup
(
src
);
if
(
!
new
->
dest
)
if
(
!
new
->
dest
)
...
...
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