Skip to content

mount.RecursiveUnmount: add a fast path#26

Merged
AkihiroSuda merged 2 commits intomoby:masterfrom
kolyshkin:opt-rec-umnt
Aug 31, 2020
Merged

mount.RecursiveUnmount: add a fast path#26
AkihiroSuda merged 2 commits intomoby:masterfrom
kolyshkin:opt-rec-umnt

Conversation

@kolyshkin
Copy link
Copy Markdown
Collaborator

In many cases, this is called with an argument that is a mount point
itself. In such case, if we're on Linux, MNT_DETACH ensures that the
umount is recursive (which is its nice, but a little known feature).
For other platforms, if the mount does not have any submounts
underneath and is not busy, it will be unmounted.

In the above case, we no longer have to parse mountinfo and perform
the unmounts one-by-one.

IOW this should speed up RecursiveUnmount() for some cases, without
breaking the compatibility.

While at it

  • fix a typo in doc;
  • add that the argument does not have to be a mount point;
  • improve mount.Unmount doc.

Fixes: #21

In many cases, this is called with an argument that is a mount point
itself. In such case, if we're on Linux, MNT_DETACH ensures that the
umount is recursive (which is its nice, but a little known feature).
For other platforms, if the mount does not have any submounts
underneath and is not busy, it will be unmounted.

In the above case, we no longer have to parse mountinfo and perform
the unmounts one-by-one.

IOW this should speed up RecursiveUnmount() for some cases, without
breaking the compatibility.

While at it
 - fix a typo in doc;
 - add that the argument does not have to be a mount point.

Signed-off-by: Kir Kolyshkin <[email protected]>
Signed-off-by: Kir Kolyshkin <[email protected]>
@kolyshkin
Copy link
Copy Markdown
Collaborator Author

@cpuguy83 PTAL

Copy link
Copy Markdown
Member

@cpuguy83 cpuguy83 left a comment

Choose a reason for hiding this comment

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

LGTM

@AkihiroSuda
Copy link
Copy Markdown
Member

Will this introduce a risk of having orphan mounts on error?

@kolyshkin
Copy link
Copy Markdown
Collaborator Author

Will this introduce a risk of having orphan mounts on error?

If your concern is about MNT_DETACH, we use this flag anyway, so AFAIU we're not making anything worse. Please see a longer discussion in #21.

If it is something different, please explain your concern in more details.

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.

is RecursiveUnmount needed?

3 participants