Merge pull request #44761 from neersighted/btrfs_uapi

graphdriver/btrfs: depend on kernel UAPI instead of libbtrfs
This commit is contained in:
Bjorn Neergaard 2023-01-06 15:20:20 -07:00 committed by GitHub
commit 6834304feb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 8 additions and 62 deletions

View file

@ -535,7 +535,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 \
@ -554,7 +553,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 \

View file

@ -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 \

View file

@ -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 \

View file

@ -5,12 +5,11 @@ 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/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 +149,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", strconv.Itoa(lv)})
}
return status
}
// GetMetadata returns empty metadata for this driver.
@ -241,7 +233,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)))

View file

@ -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)
}

View file

@ -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")
}
}

View file

@ -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.7+; 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