Opportunistic locking (oplock) is a core feature of the SMB protocol that allows a client to cache data locally and perform read-ahead operations. This reduces network round-trips to the server and improves file read and write performance.
Use cases
-
Single-client writes
When a single client writes to a file, the SMB client uses the write-back technique. It accumulates write operations in the local cache before flushing them to the server in batches. This reduces network traffic from small write operations and increases overall write throughput.
-
Concurrent reads by a single client or multiple clients
When clients read a file, the SMB client uses the read-ahead technique to proactively load data into the local cache in batches. This reduces network round-trips and improves read throughput.
-
Frequent file opening and closing by multiple clients
For applications that frequently open and close files, the SMB client uses the delayed-close technique to consolidate repetitive open and close requests, which reduces the associated network traffic. This feature significantly benefits applications such as Internet Information Services (IIS), genomics computing, and shared map services.
Usage notes
Data loss risk: If a client system crashes or experiences a power failure before cached data is written back to primary storage, the data in the local cache may be lost.
Write latency: Write operations may appear to complete instantly on the client, but the actual write to primary storage might be delayed. This behavior may not be suitable for applications that require strict data consistency.
If multiple clients access the same file simultaneously, disable oplock to prevent data conflicts from cache inconsistencies. For single-client access, enabling oplock provides the best performance benefits.
Enable oplock
Oplock is enabled by default. If you have previously disabled it, follow these steps to re-enable it.
Log on to the NAS console.
In the left-side navigation pane, choose .
At the top of the page, select the resource group and region of the target file system.
Find the target file system that uses the SMB protocol and click its file system ID, or click Actions in the Manage 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 .
At the top of the page, select the resource group and region of the target file system.
Find the target file system that uses the SMB protocol and click its file system ID, or click Actions in the Manage column.
On the Basic Information tab, in the Advanced Options for SMB section, turn off the oplock switch.