Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

btrfs: auto-detect device #813

Merged
merged 4 commits into from May 10, 2017

Conversation

AkihiroSuda
Copy link
Member

The device is automatically detected via mountinfo (ported from moby/pkg/mount v17.05.0).

No longer need to set plugins.snapshot-btrfs.device manually.

Signed-off-by: Akihiro Suda suda.akihiro@lab.ntt.co.jp

import github.com/moby/moby/pkg/mount (v17.05.0-ce)

Signed-off-by: Akihiro Suda <suda.akihiro@lab.ntt.co.jp>
Signed-off-by: Akihiro Suda <suda.akihiro@lab.ntt.co.jp>
No longer need to set `plugins.snapshot-btrfs.device` manually

Signed-off-by: Akihiro Suda <suda.akihiro@lab.ntt.co.jp>
@codecov-io
Copy link

codecov-io commented May 6, 2017

Codecov Report

Merging #813 into master will increase coverage by 0.49%.
The diff coverage is 72.72%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #813      +/-   ##
==========================================
+ Coverage   59.26%   59.76%   +0.49%     
==========================================
  Files           5        5              
  Lines         739      753      +14     
==========================================
+ Hits          438      450      +12     
  Misses        198      198              
- Partials      103      105       +2
Impacted Files Coverage Δ
snapshot/btrfs/btrfs.go 55.08% <72.72%> (+2.47%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 5e192fa...8cd2182. Read the comment docs.

@crosbymichael
Copy link
Member

LGTM

Optional string

// Fstype indicates the type of filesystem, such as EXT3.
Fstype string
Copy link
Member

Choose a reason for hiding this comment

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

FSType - make sure to follow Go's style guide.

Source string

// VfsOpts represents per super block options.
VfsOpts string
Copy link
Member

Choose a reason for hiding this comment

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

VFSOpts.

Mountpoint string

// Opts represents mount-specific options.
Opts string
Copy link
Member

Choose a reason for hiding this comment

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

Options.

}

// GetMounts retrieves a list of mounts for the current running process.
func GetMounts() ([]*Info, error) {
Copy link
Member

Choose a reason for hiding this comment

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

No getters in Go. Just use Mounts.

}

// GetMounts retrieves a list of mounts for the current running process.
func GetMounts() ([]*Info, error) {
Copy link
Member

Choose a reason for hiding this comment

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

Returning a slice to pointers to a record type doesn't make sense. Just use []Info.


// Parse /proc/self/mountinfo because comparing Dev and ino does not work from
// bind mounts
func parseMountTable() ([]*Info, error) {
Copy link
Member

Choose a reason for hiding this comment

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

This helper seems redundant.

Opts string

// Optional represents optional fields.
Optional string
Copy link
Member

Choose a reason for hiding this comment

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

What Opts and Optional?

Copy link
Member

Choose a reason for hiding this comment

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

Jeez, this madness is direct from the kernel: https://www.kernel.org/doc/Documentation/filesystems/proc.txt.

// PidMountInfo collects the mounts for a specific process ID. If the process
// ID is unknown, it is better to use `GetMounts` which will inspect
// "/proc/self/mountinfo" instead.
func PidMountInfo(pid int) ([]*Info, error) {
Copy link
Member

Choose a reason for hiding this comment

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

Odd that we would have an exported method that is supported on a single platform. This should just error out for other platforms.

Let's also name this consistently with the other exported function. Like Self and Pid or something like that. Usage will be mountinfo.Pid(pid) and mountinfo.Self().


func parseMountTable() ([]*Info, error) {
// Do NOT return an error!
return nil, nil
Copy link
Member

Choose a reason for hiding this comment

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

This should probably return an error.

)

const (
/* 36 35 98:0 /mnt1 /mnt2 rw,noatime master:1 - ext3 /dev/root rw,errors=continue
Copy link
Member

Choose a reason for hiding this comment

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

Please link to the place you copypasted this from: https://www.kernel.org/doc/Documentation/filesystems/proc.txt.

Also, please be mindful of copy pasting from other sources without attribution.

root string // root provides paths for internal storage.
ms *storage.MetaStore
}

func getBtrfsDevice(root string, mounts []*mountinfo.Info) (string, error) {
device := ""
Copy link
Member

Choose a reason for hiding this comment

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

Should this match on the device id, rather than the path?

Copy link
Member Author

Choose a reason for hiding this comment

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

@AkihiroSuda
Copy link
Member Author

AkihiroSuda commented May 9, 2017

@stevvooe

The mountinfo package is just copy-pasted from moby/pkg/mountinfo.
I didn't vendor because IIUC we don't want to make containerd dependent on Docker,
but on second thought, it might be ok to import "lego blocks" of Moby.

Let me know whether I should fork mountinfo and modify here according to your review, or just vendor the upstream Moby.

@stevvooe
Copy link
Member

stevvooe commented May 9, 2017

Let me know whether I should fork mountinfo and modify here according to your review, or just vendor the upstream Moby.

This is fine and we can even port moby to use the better version here.

@AkihiroSuda
Copy link
Member Author

updated PR

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

LGTM

@stevvooe stevvooe mentioned this pull request May 10, 2017
22 tasks
@crosbymichael
Copy link
Member

LGTM

@crosbymichael crosbymichael merged commit 07fda4b into containerd:master May 10, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants