Support sparsefiles Copy in blockfile snapshotter#10197
Conversation
Signed-off-by: Zhao Jizhuang <571130360@qq.com>
|
Hi @zhaojizhuang. Thanks for your PR. I'm waiting for a containerd member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
|
Can we stat each file after the copy to see if the block usage differs? The expectation right now is blockfile snapshotter is not very efficient when copy file range is not used. Are the sparse file properties preserved when it doesn't go through a full read/write copy of the file? |
|
@dmcgowan We use the command "fallocate -d copy.img" to make the snapshot blockfile sparse. here is the test demo,using nginxt,which has 7 layers AfterAfter 7 snapshots (18~24) were sparsified, the results are as follows: du -h du -h --apparent-size stat beforebefore 7 snapshots (18~24) were sparsified, the results are as follows: du -h du -h --apparent-size stat |
|
gently ping ... @dmcgowan |
|
|
||
| // fallocate can make existing files sparse on supported file systems. | ||
| func fallocate(file string) error { | ||
| cmd := exec.Command("fallocate", "-d", file) |
There was a problem hiding this comment.
Can we just seek(); write(); close(); instead of introducing a dependency on an external command?
There was a problem hiding this comment.
+1. it sounds that's the best thing to also from perf perspective if io.Copy first creates a full file which gets holes added afterwards.
fidencio
left a comment
There was a problem hiding this comment.
Not a maintainer here, but it does improve a lot the usability of the blockfile snapshotter.
| // mountOptions are the base options added to the mount (defaults to ["loop"]) | ||
| mountOptions []string | ||
|
|
||
| // copySparse determine whether sparse files when copy (defaults to true,equivalent to "cp --sparse=always xxx") |
There was a problem hiding this comment.
Where is this defaulting to true? We also would not want this to be the default since it is not necessary on all file systems.
| // on initialization of the plugin instead of using an existing. | ||
| RecreateScratch bool `toml:"recreate_scratch"` | ||
|
|
||
| // CopySparse create sparse files when copy when is 'false' |
There was a problem hiding this comment.
This comment is a bit confusing, when what is false?
|
carried |
Adds the ability to copy sparse files and can be configured in the config.
In the Go language,
io.Copyis equivalent tocp --sparse=never xxx, so even if the initial scratch file is a sparse file, it is still a non-sparse file after go io.copy. Each snapshot block file will occupy the full block file size by default.