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
btrfs: auto-detect device #813
Conversation
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>
4881aa9
to
d5707d3
Compare
Codecov Report
@@ 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
Continue to review full report at Codecov.
|
LGTM |
mountinfo/mountinfo.go
Outdated
Optional string | ||
|
||
// Fstype indicates the type of filesystem, such as EXT3. | ||
Fstype string |
There was a problem hiding this comment.
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.
mountinfo/mountinfo.go
Outdated
Source string | ||
|
||
// VfsOpts represents per super block options. | ||
VfsOpts string |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
VFSOpts
.
mountinfo/mountinfo.go
Outdated
Mountpoint string | ||
|
||
// Opts represents mount-specific options. | ||
Opts string |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Options
.
mountinfo/mountinfo.go
Outdated
} | ||
|
||
// GetMounts retrieves a list of mounts for the current running process. | ||
func GetMounts() ([]*Info, error) { |
There was a problem hiding this comment.
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
.
mountinfo/mountinfo.go
Outdated
} | ||
|
||
// GetMounts retrieves a list of mounts for the current running process. | ||
func GetMounts() ([]*Info, error) { |
There was a problem hiding this comment.
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
.
mountinfo/mountinfo_linux.go
Outdated
|
||
// Parse /proc/self/mountinfo because comparing Dev and ino does not work from | ||
// bind mounts | ||
func parseMountTable() ([]*Info, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This helper seems redundant.
mountinfo/mountinfo.go
Outdated
Opts string | ||
|
||
// Optional represents optional fields. | ||
Optional string |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What Opts
and Optional
?
There was a problem hiding this comment.
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.
mountinfo/mountinfo_linux.go
Outdated
// 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) { |
There was a problem hiding this comment.
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()
.
mountinfo/mountinfo_windows.go
Outdated
|
||
func parseMountTable() ([]*Info, error) { | ||
// Do NOT return an error! | ||
return nil, nil |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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.
snapshot/btrfs/btrfs.go
Outdated
root string // root provides paths for internal storage. | ||
ms *storage.MetaStore | ||
} | ||
|
||
func getBtrfsDevice(root string, mounts []*mountinfo.Info) (string, error) { | ||
device := "" |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
device id is unreliable on btrfs
https://www.spinics.net/lists/linux-btrfs/msg58908.html
The Let me know whether I should fork |
This is fine and we can even port moby to use the better version here. |
updated PR |
Signed-off-by: Akihiro Suda <suda.akihiro@lab.ntt.co.jp>
6570735
to
8cd2182
Compare
LGTM |
LGTM |
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