Skip to content

filesystem: 将自旋锁替换为 UP 单核同步原语

StellaOS requested to merge feature/fs_up_sync into main

将 filesystem crate 中所有 spin::Mutex / spin::RwLock 替换为轻量的 UP 专用同步类型,消除对 spin crate 的直接依赖。

新增:

  • sync.rs: UPIntrFreeCell(RefCell + 关中断),用于全局共享数据
  • sync.rs: UPSafeCellRaw(UnsafeCell),用于单持有者数据

锁替换策略:

  • 全局缓存/注册表(PAGE_CACHE/DENTRY_CACHE/BLOCK_DEVICES/FILE_SYSTEMS/ ROOT_DENTRY)→ UPIntrFreeCell,保持关中断语义,防止定时器抢占导致 RefCell double-borrow panic
  • Dentry.op_lock → 删除。UP 协作式调度下 VFS 命名空间操作路径不会 yield, 无 TOCTOU 风险
  • Dentry.inner / File.offset / Pipe/Console/Tty buffer / RamInode.inode_type → UPSafeCellRaw,单核下天然互斥,零开销
  • 中断开关通过 extern "C" 符号注入(stella_intr_disable/enable/enabled), 内核侧委托给 polyhal::IRQ,filesystem 不依赖任何架构 crate

Merge request reports