Conversation
pgier
left a comment
There was a problem hiding this comment.
Thanks for the contribution, looks good! Just had a few in-line questions/comments.
| // Package btrfs provides access to statistics exposed by Btrfs filesystems. | ||
| package btrfs | ||
|
|
||
| // Stats contains statistics for a single Btrfs filesystem. |
There was a problem hiding this comment.
Can you add a link to the docs defining the data structure?
There was a problem hiding this comment.
There is no proper documentation for this outside of fs/btrfs/sysfs.c, I have added that.
btrfs/get.go
Outdated
| r := &reader{path: uuidPath} | ||
| s := r.readFilesystemStats() | ||
|
|
||
| return s, r.err |
There was a problem hiding this comment.
It would probably be preferable to return a nil Stats here if the error is not nil, to be consistent with the rest of the API.
btrfs/get.go
Outdated
|
|
||
| // readLayout reads the Btrfs layout statistics for an allocation layout. | ||
| func (r *reader) readLayout(p string) (l *LayoutUsage) { | ||
| if !r.exists(p) { |
There was a problem hiding this comment.
Just wondering about the reasoning for the existence checks. Is it expected that the directory structure will change often, and that this directory may no longer exist when we try to read it?
There was a problem hiding this comment.
It's a leftover from the first quick-and-dirty implementation, where I would loop over the options (single, raid0, etc).
Theoretically it could change while trying to read it (during a balance from one layout to another). But in that case the concern remains the same for the values that are read, so this check doesn't really add anything. I have removed it, and the exists function as it is now unused.
Signed-off-by: Silke Hofstra <silke@slxh.eu>
Signed-off-by: Silke Hofstra <silke@slxh.eu>
23a94dc to
4e1611e
Compare
This PR adds rudimentary Btrfs support. It is mainly a strict representation of the content that can be retrieved from
/sys/fs/btrfswith the addition of a data ratio calculation (which is useful for calculating required disk space).