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

Parallezing do_unmount #662

Open
anthonyryan1 opened this issue Oct 17, 2023 · 6 comments · May be fixed by #698
Open

Parallezing do_unmount #662

anthonyryan1 opened this issue Oct 17, 2023 · 6 comments · May be fixed by #698

Comments

@anthonyryan1
Copy link

I've been exploring shutdown times on some OpenRC servers with up to 100 hard drives connected to each machine.

I found that one of the primary bottlenecks is the sequential nature of do_unmount in rc-mount.sh. On a machine with hundreds of mount points, it will iterate through them sequentially one after another.

My first idea was to run each unmount command in the background with &. But that would break assumptions about unmount order, potentially creating unmount errors for people with filesystems mounted inside racing their parent to unmount.

I'm thinking the correct way to make do_unmount run in parallel would be to use fstabinfo --passno '' to get all the pass numbers, then iterate from the largest passno down to 0 using fstabinfo --passno =N to decide which drives can be unmounted in parallel during each batch.

I'm currently looking for feedback and concerns before creating a pull request.

@vapier
Copy link
Member

vapier commented Oct 18, 2023

i don't think passno works. that assumes all mounts are in fstab to begin with, and that's def not a requirement.

this should be a compiled program so that it can actually build a graph and then process it as such using threads.

i could see there being a benefit to tickling the underlying devices in parallel in case they went to sleep -- waking back up to unmount is def slow. i'm not sure how much overhead there actually is though if all the drives are active and we just ran umount syscall on them in serial.

@Tommimon
Copy link

Tommimon commented Dec 6, 2023

I'd like to give this a try and implement a c program that uses mountinfo output to build a dependency graph. The program output will contain a dependency list for each mount point, those lists can of course be nested. The shell script will then run the unmount operation in parallel starting from the leaves lists and proceeding to other elements when all dependencies are met.

Do you think there's a better suitable approach for this specific issue?

@vapier
Copy link
Member

vapier commented Dec 6, 2023

the entire tool should be written in C, not a mix of C & shell

@Tommimon
Copy link

Tommimon commented Dec 7, 2023

To be sure I understood correctly, you suggest a unmount_all.c which, when executed once, will do:

  1. retrieve data from mountinfo.c.
  2. create a dependency graph on all the mount points present.
  3. unmount them in parallel when possible.

If this is what you suggest, I think is a good Idea to avoid mixing C with shell when is not required.

@vapier
Copy link
Member

vapier commented Dec 7, 2023

correct

@Tommimon Tommimon linked a pull request Mar 26, 2024 that will close this issue
@doot-64
Copy link

doot-64 commented Apr 25, 2024

We have a proposed solution here if anyone wants to take a look.

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 a pull request may close this issue.

4 participants