-
-
Notifications
You must be signed in to change notification settings - Fork 168
feat(vfs): Implement mount propagation mechanism in VFS #1410
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
feat(vfs): Implement mount propagation mechanism in VFS #1410
Conversation
- Added support for mount propagation types: Shared, Private, Slave, and Unbindable. - Introduced a new module for managing mount propagation semantics, including peer group registration and event propagation. - Updated existing mount functions to handle propagation logic during mount and unmount operations. - Enhanced documentation to include details on the new mount propagation features and their usage. - Added unit tests to verify the correctness of mount propagation behavior across different scenarios. This implementation aligns with Linux semantics for mount propagation, ensuring compatibility and expected behavior in containerized environments.; Signed-off-by: longjin <longjin@DragonOS.org>
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.
This PR is being reviewed by Cursor Bugbot
Details
You are on the Bugbot Free tier. On this plan, Bugbot will review limited PRs each billing cycle.
To receive Bugbot reviews on all of your PRs, visit the Cursor dashboard to activate Pro and start your 14-day free trial.
- Replace ID allocator with atomic counter for propagation groups - Refactor peer group registry into structured class with better APIs - Remove verbose debug logs to reduce noise Signed-off-by: longjin <longjin@DragonOS.org>
- Fix peer group registration when changing propagation type from shared - Ensure propagated mounts join source child's peer group instead of target parent's group - Add proper peer group cleanup when transitioning from shared propagation Signed-off-by: longjin <longjin@DragonOS.org>
- Add recursive bind mount functionality with MS_BIND | MS_REC flags - Implement BFS traversal for copying submounts in do_recursive_bind_mount - Fix mount registration order to prevent dangling registrations on failure - Add comprehensive test cases for recursive and non-recursive bind mounts Signed-off-by: longjin <longjin@DragonOS.org>
| if let Err(e) = propagate_umount(&self.mount_fs, mountpoint_id) { | ||
| log::warn!("do_umount: propagation failed: {:?}", e); | ||
| } | ||
| } |
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.
Bug: Child mount unregistered before propagation can fail
The child mount is unregistered from its peer group at line 551 before propagate_umount is called at line 558. If propagation fails (which only logs a warning), the source child is unregistered while peer children remain registered in the same peer group, creating an inconsistent state. The unregistration should happen after successful propagation, or the unregistration at line 551 should be removed since propagate_umount already handles unregistering children at all peers via umount_at_peer.
| ) | ||
| } else { | ||
| alloc::format!("{}{}", target_base_path, relative_path) | ||
| }; |
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.
Bug: Missing slash in recursive bind mount paths
Path construction for recursive bind mounts can produce invalid paths. When target_base_path doesn't end with '/' and relative_path doesn't start with '/' (which occurs when source_base_path ends with '/'), line 499 concatenates them without a separator, producing paths like /targetchild instead of /target/child. The code should ensure a single '/' separator between the base path and relative path regardless of trailing/leading slashes.
This implementation aligns with Linux semantics for mount propagation, ensuring compatibility and expected behavior in containerized environments.;
Note
Adds full mount propagation semantics with peer groups, bind/recursive bind, propagation-type syscalls, namespace propagation, plus docs and tests.
namespace::propagationwithPropagationType,MountPropagation,PropagationGroupId, and global peer registry; implementspropagate_mount/propagate_umount.mount_id.MS_BINDandMS_REC(recursive bind) viado_bind_mount/do_recursive_bind_mount.--make-{shared,private,slave,unbindable}(and recursive) viachange_mnt_propagation_recursive.CLONE_NEWNS.MountPropagation::new_private()for initramfs/root mounts.docs/kernel/filesystem/vfs/mount_propagation.mdand links fromindex.rstdetailing propagation types, peer groups, and flows.user/apps/c_unitest/test_mount_propagation.ccovering API flags, shared/private/slave/unbindable behavior, recursive bind, and namespace propagation/umount.Written by Cursor Bugbot for commit b2f5f31. This will update automatically on new commits. Configure here.