libct: close the mount source fd ASAP!#5177
libct: close the mount source fd ASAP!#5177lifubang wants to merge 3 commits intoopencontainers:mainfrom
Conversation
There was a problem hiding this comment.
Pull request overview
Close mount source file descriptors as soon as they are no longer needed during rootfs setup, reducing peak FD usage in runc (especially under high mount counts / concurrency).
Changes:
- Refactors mount source-fd acquisition logic into a new
initMountEntryhelper. - Moves lifetime management of the mount source FD into
mountToRootfsto close it immediately after each mount is processed.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
rata
left a comment
There was a problem hiding this comment.
Just curious, are you seeing a lot fds and is causing issues for you?
0d45db9 to
7244287
Compare
This can fail under a restrictive |
|
Guess you'd want 1.5 backport @lifubang ? |
Yes, it looks like a small bug. |
rata
left a comment
There was a problem hiding this comment.
Thanks! Let's tune the error handling and simplify a little bit the code
Signed-off-by: lifubang <lifubang@acmcoder.com>
1c3f36f to
1334297
Compare
kolyshkin
left a comment
There was a problem hiding this comment.
For review purposes, it would be nice to split the second commit into two
- Factor out setupAndMountToRootfs.
- Implement the fix.
Otherwise it is harder to review what exactly are you changing since you also move the code around.
Still LGTM though
|
Yeah I agree @kolyshkin, it took me a couple of read-throughs to see what was being changed. |
This commit factors out setupAndMountToRootfs without changing any logic. Use "Hide whitespace changes" during review to focus on the actual changes. The refactor ensures the mount source file descriptor is closed via defer in each loop iteration, reducing the total number of open FDs in runc. This helps avoid hitting the file descriptor limit under high concurrency or when handling many mounts. Signed-off-by: lifubang <lifubang@acmcoder.com>
Signed-off-by: lifubang <lifubang@acmcoder.com>
1334297 to
7fdab1c
Compare
In fact, no second fix is needed. As @rata suggested, factoring out You can use “Hide whitespace changes” to make the review easier. |
Thank you for clarification! Still LGTM ) |
This commit factors out setupAndMountToRootfs without changing any
logic. Use "Hide whitespace changes" during review to focus on the
actual changes.
The refactor ensures the mount source file descriptor is closed via
defer in each loop iteration, reducing the total number of open FDs
in runc. This helps avoid hitting the file descriptor limit under
high concurrency or when handling many mounts.