passthrough: reduce the memory footprint of file handle #102
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.
File handles used by name_to_handle_at(2) are allocated with fixed max bytes, which results in unnecessary memory pressure.
Per the manual of open_by_handle_at(2),
"The caller can discover the required size for the file_handle structure by making a call in which handle->handle_bytes is zero; in this case, the call fails with the error EOVERFLOW and handle->handle_bytes is set to indicate the required size; the caller can then use this information to allocate a structure of the correct size (see EXAMPLES below)."
This follows the description and allocates the needed bytes.
With this,
sizeof:: drops from 136 bytes to 16 bytes.
sizeof:: drops from 328 bytes to 120 bytes.
Also there is no need to make CFileHandle public.
Signed-off-by: Liu Bo [email protected]
Test has been done with
passthrough::tests::test_passthroughfs_inode_file_handles
(with the following changes and tempdir is on ext4 which supports file handle feature),