Oplock is a Server Message Block (SMB) protocol feature that lets clients cache data locally and perform read-ahead operations, reducing round trips to the remote server. This improves file access performance for single-client writes, concurrent reads, and applications with frequent file open and close operations.
Use cases
Single-client writes
When only one client writes to a file, the SMB client uses the write-back technique to batch writes in the local cache before flushing to the server. This reduces network traffic from small, frequent write operations and improves overall write throughput.
Concurrent reads by single or multiple clients
When clients read files, the SMB client uses the read-ahead technique to prefetch data into the local cache. This reduces network round trips and improves read throughput.
Frequent file open and close operations by multiple clients
For applications that repeatedly open and close files, the SMB client uses the delayed-close technique to batch these requests. This reduces network traffic from redundant open and close operations, which is especially beneficial for applications such as Internet Information Services (IIS) servers, genomics computing, and shared mapping.
Risks and limitations
Data loss risk: If a client crashes or loses power before cached data is written back to primary storage, that data may be lost.
Write latency: Write operations may appear to complete immediately, but the actual synchronization to primary storage may be delayed. This behavior may not be suitable for applications that require high data consistency.
Enable oplock
Oplock is enabled by default. If you previously disabled it, follow these steps to re-enable it.
Log on to the NAS console.
In the left-side navigation pane, choose .
In the upper-left corner of the page, select the region and resource group where your target file system is located.
Find the target file system that uses the SMB protocol and click its file system ID, or click Manage in the Actions column.
On the Basic Information tab, in the Advanced Options for SMB section, turn on the oplock switch.
Disable oplock
Log on to the NAS console.
In the left-side navigation pane, choose .
In the upper-left corner of the page, select the region and resource group where your target file system is located.
Find the target file system that uses the SMB protocol and click its file system ID, or click Manage in the Actions column.
On the Basic Information tab, in the Advanced Options for SMB section, turn off the oplock switch.