Implement SMB Oplocks Phase 4+6
Some checks failed
Test / test (push) Has been cancelled
Test / build (push) Has been cancelled

Phase 4: CREATE Handler dynamic oplock granting
- Use OplockManager.can_grant() to determine oplock level
- Register OplockEntry if oplock granted
- Support ShareAccess compatibility checking
- Grant Level II if exclusive/batch oplock exists

Phase 6: CLOSE Handler oplock cleanup
- Unregister from OplockManager when file closed
- Only unregister if oplock_level > 0

All 229 tests pass.
This commit is contained in:
Warren
2026-06-21 00:19:51 +08:00
parent 27707bbe0e
commit 54ce0d6916
2 changed files with 36 additions and 5 deletions

View File

@@ -15,7 +15,7 @@ use crate::server::ServerState;
const FLAG_POSTQUERY_ATTRIB: u16 = 0x0001;
pub async fn handle(
_server: &Arc<ServerState>,
server: &Arc<ServerState>,
conn: &Arc<Connection>,
hdr: &Smb2Header,
body: &[u8],
@@ -43,9 +43,15 @@ pub async fn handle(
let handle = open.handle.take();
let path = open.last_path.clone();
let delete_on_close = open.delete_on_close;
let oplock_level = open.oplock_level;
let want_attrs = req.flags & FLAG_POSTQUERY_ATTRIB != 0;
drop(open);
// Phase 6: Unregister from OplockManager if oplock was granted
if oplock_level > 0 {
server.oplock_manager.unregister(&path, &req.file_id).await;
}
// Stat before closing if needed.
let info_before_close = if want_attrs {
if let Some(h) = handle.as_ref() {