Skip to content

Conversation

@fslongjin
Copy link
Member

@fslongjin fslongjin commented Nov 26, 2025

  • 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.;


Note

Adds full mount propagation semantics with peer groups, bind/recursive bind, propagation-type syscalls, namespace propagation, plus docs and tests.

  • Kernel/VFS:
    • Propagation Core: Introduces namespace::propagation with PropagationType, MountPropagation, PropagationGroupId, and global peer registry; implements propagate_mount/propagate_umount.
    • MountFS Integration: Clones propagation on deepcopy; registers/unregisters peers on mount/umount; exposes mount_id.
    • sys_mount Enhancements:
      • Supports MS_BIND and MS_REC (recursive bind) via do_bind_mount/do_recursive_bind_mount.
      • Supports --make-{shared,private,slave,unbindable} (and recursive) via change_mnt_propagation_recursive.
      • Validates unbindable sources for bind.
    • Mount Namespace: Copies mounts with propagation state; registers peers across namespaces during CLONE_NEWNS.
    • Init: Uses new MountPropagation::new_private() for initramfs/root mounts.
  • Docs:
    • Adds docs/kernel/filesystem/vfs/mount_propagation.md and links from index.rst detailing propagation types, peer groups, and flows.
  • Tests:
    • Adds user/apps/c_unitest/test_mount_propagation.c covering 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.

- 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>
@fslongjin fslongjin requested a review from sparkzky November 26, 2025 08:18
@github-actions github-actions bot added enhancement New feature or request documentation Improvements or additions to documentation labels Nov 26, 2025
Copy link

@cursor cursor bot left a 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>
@github-actions github-actions bot removed the documentation Improvements or additions to documentation label Nov 26, 2025
@fslongjin fslongjin merged commit 43263c1 into DragonOS-Community:master Nov 26, 2025
13 checks passed
if let Err(e) = propagate_umount(&self.mount_fs, mountpoint_id) {
log::warn!("do_umount: propagation failed: {:?}", e);
}
}
Copy link

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.

Fix in Cursor Fix in Web

)
} else {
alloc::format!("{}{}", target_base_path, relative_path)
};
Copy link

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.

Fix in Cursor Fix in Web

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants