Implement SMB Oplocks Phase 1-2
Some checks failed
Test / test (push) Has been cancelled
Test / build (push) Has been cancelled

Phase 1: Data structures
- Add oplock_level and share_access fields to Open struct
- Update Open::new() signature with new parameters
- Update handlers/create.rs to pass oplock params

Phase 2: OplockManager
- Create oplock.rs with OplockManager struct
- OplockEntry for tracking per-client oplock state
- can_grant() - check ShareAccess compatibility
- register() / unregister() - lifecycle management
- break_oplock() - generate OPLOCK_BREAK_NOTIFICATION
- Add OplockManager to ServerState
- Add Hash trait to SmbPath for HashMap key

All 229 tests pass.
This commit is contained in:
Warren
2026-06-21 00:17:24 +08:00
parent 487b4450f8
commit 27707bbe0e
6 changed files with 195 additions and 2 deletions

View File

@@ -153,6 +153,10 @@ pub async fn handle(
// Allocate FileId, register Open.
let tree = tree_arc.write().await;
let file_id = tree.alloc_file_id();
// Phase 4: Oplock support - determine oplock level
let granted_oplock = 0; // Phase 1 placeholder (will be dynamic in Phase 4)
let open = Open::new(
file_id,
handle,
@@ -160,6 +164,8 @@ pub async fn handle(
path,
info.is_directory,
delete_on_close,
granted_oplock, // oplock_level
req.share_access, // share_access
);
let open_arc = Arc::new(tokio::sync::RwLock::new(open));
tree.opens.write().await.insert(file_id, open_arc);
@@ -172,7 +178,7 @@ pub async fn handle(
};
let resp = CreateResponse {
structure_size: 89,
oplock_level: 0,
oplock_level: granted_oplock, // Phase 4: will be dynamic
flags: 0,
create_action,
creation_time: info.creation_time,