Skip to content
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

Merged
merged 2 commits into from
Jul 17, 2023

Conversation

jamesbornholt
Copy link
Member

Description of change

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.

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).

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>
@jamesbornholt jamesbornholt temporarily deployed to PR integration tests July 14, 2023 19:20 — with GitHub Actions Inactive
@jamesbornholt jamesbornholt temporarily deployed to PR integration tests July 14, 2023 19:20 — with GitHub Actions Inactive
@jamesbornholt jamesbornholt temporarily deployed to PR integration tests July 14, 2023 19:20 — with GitHub Actions Inactive
@jamesbornholt jamesbornholt temporarily deployed to PR integration tests July 14, 2023 19:20 — with GitHub Actions Inactive
Copy link
Contributor

@passaro passaro left a 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 Show resolved Hide resolved
let InodeKindData::Directory { children, writing_children, .. } = &mut parent_state.kind_data else {
unreachable!("parent is always a directory");
};
children.remove(inode.name());
Copy link
Contributor

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?

Copy link
Contributor

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

Copy link
Member Author

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>
@jamesbornholt jamesbornholt temporarily deployed to PR integration tests July 17, 2023 18:23 — with GitHub Actions Inactive
@jamesbornholt jamesbornholt temporarily deployed to PR integration tests July 17, 2023 18:23 — with GitHub Actions Inactive
@jamesbornholt jamesbornholt temporarily deployed to PR integration tests July 17, 2023 18:23 — with GitHub Actions Inactive
@jamesbornholt jamesbornholt temporarily deployed to PR integration tests July 17, 2023 18:23 — with GitHub Actions Inactive
Copy link
Contributor

@passaro passaro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@jamesbornholt jamesbornholt merged commit 839ccfd into awslabs:main Jul 17, 2023
16 checks passed
@jamesbornholt jamesbornholt deleted the forget-parent branch July 17, 2023 22:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants