Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

containerd/btrfs/v2 (CGO-less implementation from dennwc/btrfs) #34

Closed
wants to merge 38 commits into from

Conversation

AkihiroSuda
Copy link
Member

@AkihiroSuda AkihiroSuda commented Jul 1, 2021

🟡 waiting for cncf/foundation#174 to be approved (License exception for GPL-2.0 WITH Linux-syscall-note file in containerd/btrfs)


Migrate dennwc/btrfs@90a0320a to this repo as containerd/btrfs/v2.
The existing implementation can be still maintained in v1 branch.

Thanks to @dennwc for donating the code (containerd/containerd#5658 (comment))

License

The repo is licensed under the terms of Apache License 2.0.

It should be noted that btrfs_tree_hc.go is machine-generated from btrfs_tree.h which is licensed under the terms of GPL-2.0 WITH Linux-syscall-note.

   NOTE! This copyright does *not* cover user programs that use kernel
 services by normal system calls - this is merely considered normal use
 of the kernel, and does *not* fall under the heading of "derived work".
 Also note that the GPL below is copyrighted by the Free Software
 Foundation, but the instance of code that it refers to (the Linux
 kernel) is copyrighted by me and others who actually wrote it.

 Also note that the only valid version of the GPL as far as the kernel
 is concerned is _this_ particular version of the license (ie v2, not
 v2.2 or v3.x or whatever), unless explicitly otherwise stated.

			Linus Torvalds

containerd/btrfs shall be considered as user programs that use kernel services by normal system calls mentioned in the note above, and does *not* fall under the heading of "derived work" of the GPL-2.0 code. (IANAL)

Change on project status

The status of this repo is going to be changed from "core" to "non-core", to invite @dennwc as a non-core committer.


Close #7

MAINTAINERS Outdated Show resolved Hide resolved
@@ -34,10 +34,12 @@ jobs:

- name: Project checks
uses: containerd/project-checks@v1
# Disabled during repo migration
if: false
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This TODO can be worked out after merging this PR

@@ -178,15 +178,15 @@
APPENDIX: How to apply the Apache License to your work.

To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "{}"
boilerplate notice, with the fields enclosed by brackets "[]"
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lol

In the next batch of commits, the content of the repo
will be replaced with the content of github.com/dennwc/btrfs

Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
@AkihiroSuda AkihiroSuda force-pushed the import-dennwc-btrfs branch 2 times, most recently from 1376856 to c0def28 Compare July 1, 2021 07:30
dennwc added 19 commits July 1, 2021 16:31
(cherry picked from commit dennwc/btrfs@2d0abe4)
Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
…receive.

* better code generator

* regenerate btrfs_tree.h constants

* implement subvolume create, delete and snapshot create commands

* exec-based snapshot send and receive

(cherry picked from commit dennwc/btrfs@b300237)
Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
(cherry picked from commit dennwc/btrfs@f03fa74)
Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
(cherry picked from commit dennwc/btrfs@6a4b966)
Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
(cherry picked from commit dennwc/btrfs@4363265)
Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
(cherry picked from commit dennwc/btrfs@41809ca)
Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
(cherry picked from commit dennwc/btrfs@7eae92f)
Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
(cherry picked from commit dennwc/btrfs@8f48d3e)
Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
(cherry picked from commit dennwc/btrfs@14de038)
Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
(cherry picked from commit dennwc/btrfs@b56d643)
Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
(cherry picked from commit dennwc/btrfs@3343324)
Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
(cherry picked from commit dennwc/btrfs@6f59d60)
Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
(cherry picked from commit dennwc/btrfs@94acb6e)
Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
(cherry picked from commit dennwc/btrfs@4ac498b)
Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
(cherry picked from commit dennwc/btrfs@08f5a6b)
Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
(cherry picked from commit dennwc/btrfs@54573d1)
Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
(cherry picked from commit dennwc/btrfs@3b69894)
Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
(cherry picked from commit dennwc/btrfs@51976ca)
Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
(cherry picked from commit dennwc/btrfs@00defaf)
Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
dennwc and others added 3 commits July 1, 2021 16:31
(cherry picked from commit dennwc/btrfs@d917b30)
Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
Fix containerd#1

Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
(cherry picked from commit dennwc/btrfs@ee67271)
Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
(cherry picked from commit dennwc/btrfs@90a0320)
Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
@AkihiroSuda AkihiroSuda force-pushed the import-dennwc-btrfs branch 2 times, most recently from 3a0330c to 031f9b7 Compare July 1, 2021 08:59
go.mod Outdated Show resolved Hide resolved
go.mod Outdated Show resolved Hide resolved
Temporarily delete cmd/gbtrfs/go.mod
(added back in a separate commit)

Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
Reran `go generate` with btrfs_tree.h from kernel 5.13

https://github.com/torvalds/linux/blob/v5.13/include/uapi/linux/btrfs_tree.h

btrfs_tree.h is licensed under the terms of "GPL-2.0 WITH Linux-syscall-note":
https://github.com/torvalds/linux/blob/v5.13/LICENSES/exceptions/Linux-syscall-note

containerd/btrfs (dennwc/btrfs) shall be considered as "user programs
that use kernel services by normal system calls" mentioned in the note
above, and "does *not* fall under the heading of \"derived work\"" of
the GPL-2.0 code.

Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
@AkihiroSuda AkihiroSuda force-pushed the import-dennwc-btrfs branch 2 times, most recently from 92aed35 to e9c9e41 Compare July 1, 2021 12:46
Copy link
Member

@dmcgowan dmcgowan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

README.md Outdated Show resolved Hide resolved
We would like to invite dennwc as a maintainer of this repo,
so the status of the repo is now changed from core to non-core.

Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
Import dennwc/ioctl@0178042

Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
Copy link
Member

@thaJeztah thaJeztah left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't have enough knowledge about the BTRFs things, so did not review the implementation.

containerd/btrfs shall be considered as user programs that use kernel services by normal system calls mentioned in the note above, and does not fall under the heading of "derived work" of the GPL-2.0 code. (IANAL)

Does someone know if we can get assistance / review on this from the CNCF? e.g. should this repository have a NOTICE file, which also mentions this?

(Thinking out loud); to deal with go modules;

  • looks like no relevant changes were merged after v1.0.0 (v1.0.0...main)
  • for CI, we probably should create that release/1.x branch (from the v1.0.0 tag or from "main"), and update GitHub actions to also run on PRs and merged on that branch
  • after merging this PR, perhaps tag main as v2.0.0-alpha.0 (e.g.) so that go modules will generate sensible pseudo versions (otherwise it will create pseudo-versions based on v1.0.0)


type blockGroup uint64

// SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note (see headers.go)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would love to have someone check/verify if this is sufficient (see my other comment)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, this is the correct designation, and along the lines with what @AkihiroSuda said, this is just more explicit now that the "header" is in our codebase. We were always linking against GPLv2 code (libbtrfs and the requisite headers) and were already depending on this exception, which is stated as:

This exception is used together with one of the above SPDX-Licenses
  to mark user space API (uapi) header files so they can be included
  into non GPL compliant user space application code.

Comment on lines +2 to +3
Copyright The containerd Authors.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should the headers in this project be updated to preserve the old copyright? Or do we consider "The containerd authors" to cover this?

Suggested change
Copyright The containerd Authors.
Copyright The containerd Authors.
Copyright 2016-2021 Denys Smirnov.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That will not pass the CI 😅

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh 🤦 we use a single set of templates for all project 😞

@AkihiroSuda
Copy link
Member Author

Does someone know if we can get assistance / review on this from the CNCF? e.g. should this repository have a NOTICE file, which also mentions this?

Same may apply to v1, as v1 imports consts from GPL2 headers as well kdave/btrfs-progs#380

Copy link
Member

@estesp estesp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@Conan-Kudo
Copy link

The status of this repo is going to be changed from "core" to "non-core", to invite @dennwc as a non-core committer.

This is a weird thing to do. My reading of switching to "non-core" also implies that containerd would no longer gate or officially support this, and that containerd tarballs would no longer contain this code. That would be very problematic to me.

To me, this sounds like the governance is not flexible enough. It doesn't make sense to transition this to "non-core" status if there's at least one "core" member involved in here.

@AkihiroSuda
Copy link
Member Author

AkihiroSuda commented Jul 14, 2021

The btrfs plugin for containerd is maintained in the core repo, and will remain in the core repo, and will remain as a built-in official core plugin for the foreseeable future (until containerd v2.0 at least, and containerd v2.x will probably keep btrfs built-in.)

https://github.com/containerd/containerd/blob/main/snapshots/btrfs/btrfs.go

The underlying low-level btrfs library in this repo is going to be a non-core, but we core committers will continue to maintain this repo too.

@stevvooe
Copy link
Member

What are the API changes package users need to do to use v2? We should probably document them.

@AkihiroSuda AkihiroSuda marked this pull request as draft July 15, 2021 02:48
@AkihiroSuda
Copy link
Member Author

Current status: waiting for cncf/foundation#174 to be approved (License exception for GPL-2.0 WITH Linux-syscall-note file in containerd/btrfs)

@stevvooe
Copy link
Member

Not LGTM.

We had a conversation on this matter in slack and I thought we were in agreement that we wouldn't break the interface. All that needs to be done to remove cgo is replace the struct unpacking in https://github.com/containerd/btrfs/pull/34/files#diff-37cee27ecb051878390f4745b46e50e69389589a620a6714441f7d14dd058179L24.

While I appreciate the contributions from @dennwc, I think we can do a more careful merge to get the same result without breaking the interface. We can bring in a lot of the definitions from https://github.com/dennwc/btrfs/blob/90a0320aae50c617db7a9c9d90072c37d1a81907/ioctl_h.go#L131. For root_item, where I was struggling with layout the most, the implementation is in https://github.com/dennwc/btrfs/blob/90a0320aae50c617db7a9c9d90072c37d1a81907/btrfs_tree.go#L241.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Remove necessity to link against C package
7 participants