-
Notifications
You must be signed in to change notification settings - Fork 157
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
Remove inodes from their parent in forget
#380
Conversation
The parent directory still holds onto an `Inode` (an `Arc<InodeInner>`), so right now our `forget` is leaking the actual inode. We need to remove it from its parent at `forget` time. Also updated the tests to check that the inode is in fact free'd. I tested this by listing a directory with 2M objects on an instance with 1GiB of memory, and saw constant memory usage. Signed-off-by: James Bornholt <bornholt@amazon.com>
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.
Great follow up to forget!
mountpoint-s3/src/inode.rs
Outdated
let InodeKindData::Directory { children, writing_children, .. } = &mut parent_state.kind_data else { | ||
unreachable!("parent is always a directory"); | ||
}; | ||
children.remove(inode.name()); |
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 we check that we are in fact removing the same inode? vs a new child with the same name?
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.
It should be possible to write a test for this scenario, e.g.:
- unlink child
- mknod new child with same name
- forget original child
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.
Nice catch. I wrote a slightly different test with the same idea -- the child changes from a file to a directory and so gets recreated, forgetting the original child.
Signed-off-by: James Bornholt <bornholt@amazon.com>
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.
LGTM
Description of change
The parent directory still holds onto an
Inode
(anArc<InodeInner>
), so right now ourforget
is leaking the actual inode. We need to remove it from its parent atforget
time. Also updated the tests to check that the inode is in fact free'd.I tested this by listing a directory with 2M objects on an instance with 1GiB of memory, and saw constant memory usage.
Does this change impact existing behavior?
No.
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license and I agree to the terms of the Developer Certificate of Origin (DCO).