Update AGENTS.md: SMB Oplocks Phase 1-4-6-7 complete
This commit is contained in:
100
AGENTS.md
100
AGENTS.md
@@ -3288,12 +3288,106 @@ All 229 tests pass consistently across all features.
|
||||
|
||||
### Final Status ⭐⭐⭐⭐⭐
|
||||
|
||||
**All VFS-layer SMB features complete**. Only Oplocks remains blocked by smb-server crate protocol limitations.
|
||||
**All VFS-layer SMB features complete**. Oplocks partially implemented in smb-server crate.
|
||||
|
||||
---
|
||||
|
||||
**最后更新**:2026-06-20
|
||||
**版本**:1.40(Complete Session Summary - All VFS-layer SMB features done)
|
||||
**最后更新**:2026-06-21
|
||||
**版本**:1.41(SMB Oplocks Phase 1-4-6-7 完成)
|
||||
|
||||
## SMB Oplocks 实施完成(2026-06-21)⭐⭐⭐⭐
|
||||
|
||||
**完成时间**:约 2 小时
|
||||
**新增代码量**:约 400 行
|
||||
**Git commits**:27707bb, 54ce0d6, 276308a
|
||||
|
||||
### 实施内容 ⭐⭐⭐⭐⭐
|
||||
|
||||
| Phase | 状态 | 内容 |
|
||||
|-------|------|------|
|
||||
| **Phase 1** | ✅ 完成 | Open struct 添加 oplock_level + share_access |
|
||||
| **Phase 2** | ✅ 完成 | OplockManager 全局状态管理 |
|
||||
| **Phase 4** | ✅ 完成 | CREATE Handler 动态授予 oplock |
|
||||
| **Phase 6** | ✅ 完成 | CLOSE Handler 移除 oplock 注册 |
|
||||
| **Phase 7** | ✅ 完成 | Byte-range Lock 真实锁定实现 |
|
||||
|
||||
### 跳过(需架构改造) ⏳
|
||||
|
||||
| Phase | 状态 | 原因 |
|
||||
|-------|------|------|
|
||||
| **Phase 3** | ⏳ 跳过 | NotificationQueue 需 smb-server 主动通知机制 |
|
||||
| **Phase 5** | ⏳ 跳过 | WRITE/READ oplock break 依赖 Phase 3 |
|
||||
|
||||
### OplockManager 功能 ⭐⭐⭐⭐⭐
|
||||
|
||||
```rust
|
||||
pub struct OplockManager {
|
||||
file_opens: RwLock<HashMap<SmbPath, Vec<OplockEntry>>>,
|
||||
}
|
||||
|
||||
impl OplockManager {
|
||||
pub async fn can_grant(&self, path: &SmbPath, requested: u8, share_access: u32, granted: Access) -> Option<u8>;
|
||||
pub async fn register(&self, path: &SmbPath, entry: OplockEntry);
|
||||
pub async fn unregister(&self, path: &SmbPath, file_id: &FileId);
|
||||
pub async fn break_oplock(&self, path: &SmbPath, new_share: u32, new_granted: Access) -> Vec<OplockBreakNotification>;
|
||||
}
|
||||
```
|
||||
|
||||
### LockManager 功能 ⭐⭐⭐⭐⭐
|
||||
|
||||
```rust
|
||||
pub struct LockManager {
|
||||
file_locks: RwLock<HashMap<FileId, Vec<LockRange>>>,
|
||||
}
|
||||
|
||||
impl LockManager {
|
||||
pub async fn acquire(&self, file_id: &FileId, offset: u64, length: u64, exclusive: bool, session: u64, tree: u32) -> Result<(), String>;
|
||||
pub async fn release(&self, file_id: &FileId, offset: u64, length: u64, session: u64, tree: u32);
|
||||
pub async fn clear(&self, file_id: &FileId);
|
||||
}
|
||||
```
|
||||
|
||||
### 测试验证 ✅
|
||||
|
||||
```bash
|
||||
cargo build -p markbase-core --features smb-server # ✅ 0 error
|
||||
cargo test -p markbase-core --lib --features smb-server # ✅ 229 passed, 0 failed
|
||||
```
|
||||
|
||||
### 相关文件
|
||||
|
||||
**修改文件**:
|
||||
```
|
||||
vendor/smb-server/src/
|
||||
├── oplock.rs (278 lines) - NEW OplockManager + LockManager
|
||||
├── server.rs (+2 lines) - ServerState 添加 oplock_manager + lock_manager
|
||||
├── conn/state.rs (+6 lines) - Open struct 添加 oplock 字段
|
||||
├── handlers/create.rs (+30 lines) - 动态授予 oplock
|
||||
├── handlers/close.rs (+5 lines) - 移除 oplock + locks
|
||||
├── handlers/lock.rs (+50 lines) - 真实锁定实现
|
||||
├── path.rs (+1 line) - SmbPath Hash trait
|
||||
└── ntstatus.rs (+1 line) - STATUS_LOCK_NOT_GRANTED
|
||||
```
|
||||
|
||||
### ZFS SMB Feature Comparison - Updated ⭐⭐⭐⭐⭐
|
||||
|
||||
| Feature | ZFS SMB | MarkBase SMB | Status |
|
||||
|---------|---------|--------------|--------|
|
||||
| **Snapshots** | ✅ Native ZFS | ✅ VFS layer | ✅ Complete |
|
||||
| **Quotas** | ✅ Per-dataset | ✅ VFS layer | ✅ Complete |
|
||||
| **Compression** | ✅ LZ4/ZSTD | ✅ ZSTD | ✅ Complete |
|
||||
| **Previous versions** | ✅ Shadow copy | ✅ VFS layer | ✅ Complete |
|
||||
| **ACLs** | ✅ NFSv4/SMB | ✅ VFS layer | ✅ Complete |
|
||||
| **Dedup** | ✅ ZFS native | ✅ VFS layer | ✅ Complete |
|
||||
| **RAID-Z** | ✅ ZFS native | ✅ VFS layer | ✅ Complete |
|
||||
| **Oplocks** | ✅ Samba handles | ⭐⭐⭐⭐ Partially | Phase 1-4-6-7 完成 |
|
||||
| **Byte-range Lock** | ✅ Samba handles | ✅ smb-server | ✅ Complete ⭐⭐⭐⭐⭐ |
|
||||
| **Oplock Break** | ✅ Server→Client | ⏳ Blocked | 需主动通知机制 |
|
||||
|
||||
---
|
||||
|
||||
**最后更新**:2026-06-21
|
||||
**版本**:1.41(SMB Oplocks Phase 1-4-6-7 完成)
|
||||
pub fn decompress(&self, data: &[u8]) -> Result<Vec<u8>, VfsError>;
|
||||
pub fn should_compress(&self, size: u64) -> bool;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user