Get the correct size for block devices #207
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The function
Size()
ofFileInfo
returns the length in bytes forregular files. However if we use a block device,
Size()
will return alength of zero.
To chunk a file, we use the size to split the expected work in even
parts.
For this reason, when we wanted to generate an index from a block
device, due to the incorrect reported zero size, the whole task was
carried out by a single Goroutine.
With this commit we use the ioctl
BLKGETSIZE64
to get the correct sizefor block devices.
In a test environment the
make
operation against a block device took 2minutes and 20 seconds to complete with the current master branch and
only 24 seconds with this patch.