Merge pull request #44776 from thaJeztah/23.0_backport_btrfs_uapi
[23.0 backport] graphdriver/btrfs: depend on kernel UAPI instead of libbtrfs
This commit is contained in:
commit
fc690c56b5
10 changed files with 21 additions and 67 deletions
|
@ -537,7 +537,6 @@ RUN --mount=type=cache,sharing=locked,id=moby-dev-aptlib,target=/var/lib/apt \
|
|||
pkg-config \
|
||||
dpkg-dev \
|
||||
libapparmor-dev \
|
||||
libbtrfs-dev \
|
||||
libdevmapper-dev \
|
||||
libseccomp-dev \
|
||||
libsecret-1-dev \
|
||||
|
@ -556,7 +555,6 @@ RUN --mount=type=cache,sharing=locked,id=moby-build-aptlib,target=/var/lib/apt \
|
|||
xx-apt-get install --no-install-recommends -y \
|
||||
gcc \
|
||||
libapparmor-dev \
|
||||
libbtrfs-dev \
|
||||
libc6-dev \
|
||||
libdevmapper-dev \
|
||||
libseccomp-dev \
|
||||
|
|
|
@ -4,7 +4,6 @@ FROM golang:${GO_VERSION}-alpine AS base
|
|||
ENV GO111MODULE=off
|
||||
RUN apk --no-cache add \
|
||||
bash \
|
||||
btrfs-progs-dev \
|
||||
build-base \
|
||||
curl \
|
||||
lvm2-dev \
|
||||
|
|
|
@ -24,10 +24,8 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
|
|||
build-essential \
|
||||
curl \
|
||||
cmake \
|
||||
gcc \
|
||||
git \
|
||||
libapparmor-dev \
|
||||
libbtrfs-dev \
|
||||
libdevmapper-dev \
|
||||
libseccomp-dev \
|
||||
ca-certificates \
|
||||
|
|
|
@ -32,6 +32,7 @@ import (
|
|||
"os/exec"
|
||||
"path"
|
||||
"path/filepath"
|
||||
"strconv"
|
||||
"strings"
|
||||
"sync"
|
||||
|
||||
|
@ -209,8 +210,8 @@ func (a *Driver) Status() [][2]string {
|
|||
return [][2]string{
|
||||
{"Root Dir", a.rootPath()},
|
||||
{"Backing Filesystem", backingFs},
|
||||
{"Dirs", fmt.Sprintf("%d", len(ids))},
|
||||
{"Dirperm1 Supported", fmt.Sprintf("%v", useDirperm())},
|
||||
{"Dirs", strconv.Itoa(len(ids))},
|
||||
{"Dirperm1 Supported", strconv.FormatBool(useDirperm())},
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -10,6 +10,7 @@ import (
|
|||
"os"
|
||||
"path"
|
||||
"path/filepath"
|
||||
"strconv"
|
||||
"sync"
|
||||
"testing"
|
||||
|
||||
|
@ -659,8 +660,8 @@ func testMountMoreThan42Layers(t *testing.T, mountPath string) {
|
|||
for i := 1; i < 127; i++ {
|
||||
expected++
|
||||
var (
|
||||
parent = fmt.Sprintf("%d", i-1)
|
||||
current = fmt.Sprintf("%d", i)
|
||||
parent = strconv.Itoa(i - 1)
|
||||
current = strconv.Itoa(i)
|
||||
)
|
||||
|
||||
if parent == "0" {
|
||||
|
|
|
@ -5,12 +5,17 @@ package btrfs // import "github.com/docker/docker/daemon/graphdriver/btrfs"
|
|||
|
||||
/*
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <dirent.h>
|
||||
|
||||
// keep struct field name compatible with btrfs-progs < 6.1.
|
||||
#define max_referenced max_rfer
|
||||
#include <btrfs/ioctl.h>
|
||||
#include <btrfs/ctree.h>
|
||||
#include <linux/version.h>
|
||||
#if LINUX_VERSION_CODE < KERNEL_VERSION(4,12,0)
|
||||
#error "Headers from kernel >= 4.12 are required to build with Btrfs support."
|
||||
#error "HINT: Set 'DOCKER_BUILDTAGS=exclude_graphdriver_btrfs' to build without Btrfs."
|
||||
#endif
|
||||
|
||||
#include <linux/btrfs.h>
|
||||
#include <linux/btrfs_tree.h>
|
||||
|
||||
static void set_name_btrfs_ioctl_vol_args_v2(struct btrfs_ioctl_vol_args_v2* btrfs_struct, const char* value) {
|
||||
snprintf(btrfs_struct->name, BTRFS_SUBVOL_NAME_MAX, "%s", value);
|
||||
|
@ -150,18 +155,11 @@ func (d *Driver) String() string {
|
|||
return "btrfs"
|
||||
}
|
||||
|
||||
// Status returns current driver information in a two dimensional string array.
|
||||
// Output contains "Build Version" and "Library Version" of the btrfs libraries used.
|
||||
// Version information can be used to check compatibility with your kernel.
|
||||
// Status returns the status of the driver.
|
||||
func (d *Driver) Status() [][2]string {
|
||||
status := [][2]string{}
|
||||
if bv := btrfsBuildVersion(); bv != "-" {
|
||||
status = append(status, [2]string{"Build Version", bv})
|
||||
return [][2]string{
|
||||
{"Btrfs", ""},
|
||||
}
|
||||
if lv := btrfsLibVersion(); lv != -1 {
|
||||
status = append(status, [2]string{"Library Version", fmt.Sprintf("%d", lv)})
|
||||
}
|
||||
return status
|
||||
}
|
||||
|
||||
// GetMetadata returns empty metadata for this driver.
|
||||
|
@ -241,7 +239,7 @@ func subvolSnapshot(src, dest, name string) error {
|
|||
|
||||
var cs = C.CString(name)
|
||||
C.set_name_btrfs_ioctl_vol_args_v2(&args, cs)
|
||||
C.free(unsafe.Pointer(cs))
|
||||
free(cs)
|
||||
|
||||
_, _, errno := unix.Syscall(unix.SYS_IOCTL, getDirFd(destDir), C.BTRFS_IOC_SNAP_CREATE_V2,
|
||||
uintptr(unsafe.Pointer(&args)))
|
||||
|
|
|
@ -1,27 +0,0 @@
|
|||
//go:build linux
|
||||
// +build linux
|
||||
|
||||
package btrfs // import "github.com/docker/docker/daemon/graphdriver/btrfs"
|
||||
|
||||
/*
|
||||
#include <btrfs/version.h>
|
||||
|
||||
// around version 3.16, they did not define lib version yet
|
||||
#ifndef BTRFS_LIB_VERSION
|
||||
#define BTRFS_LIB_VERSION -1
|
||||
#endif
|
||||
|
||||
// upstream had removed it, but now it will be coming back
|
||||
#ifndef BTRFS_BUILD_VERSION
|
||||
#define BTRFS_BUILD_VERSION "-"
|
||||
#endif
|
||||
*/
|
||||
import "C"
|
||||
|
||||
func btrfsBuildVersion() string {
|
||||
return string(C.BTRFS_BUILD_VERSION)
|
||||
}
|
||||
|
||||
func btrfsLibVersion() int {
|
||||
return int(C.BTRFS_LIB_VERSION)
|
||||
}
|
|
@ -1,14 +0,0 @@
|
|||
//go:build linux
|
||||
// +build linux
|
||||
|
||||
package btrfs // import "github.com/docker/docker/daemon/graphdriver/btrfs"
|
||||
|
||||
import (
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestLibVersion(t *testing.T) {
|
||||
if btrfsLibVersion() <= 0 {
|
||||
t.Error("expected output from btrfs lib version > 0")
|
||||
}
|
||||
}
|
|
@ -232,7 +232,7 @@ func (d *Driver) GetMetadata(id string) (map[string]string, error) {
|
|||
}
|
||||
|
||||
func (d *Driver) cloneFilesystem(name, parentName string) error {
|
||||
snapshotName := fmt.Sprintf("%d", time.Now().Nanosecond())
|
||||
snapshotName := strconv.Itoa(time.Now().Nanosecond())
|
||||
parentDataset := zfs.Dataset{Name: parentName}
|
||||
snapshot, err := parentDataset.Snapshot(snapshotName /*recursive */, false)
|
||||
if err != nil {
|
||||
|
|
|
@ -139,7 +139,7 @@ by having support for them in the kernel or userspace. A few examples include:
|
|||
|
||||
* AUFS graph driver (requires AUFS patches/support enabled in the kernel, and at
|
||||
least the "auplink" utility from aufs-tools)
|
||||
* BTRFS graph driver (requires BTRFS support enabled in the kernel)
|
||||
* BTRFS graph driver (requires suitable kernel headers: `linux/btrfs.h` and `linux/btrfs_tree.h`, present in 4.12+; and BTRFS support enabled in the kernel)
|
||||
* ZFS graph driver (requires userspace zfs-utils and a corresponding kernel module)
|
||||
* Libseccomp to allow running seccomp profiles with containers
|
||||
|
||||
|
|
Loading…
Reference in a new issue