Oplocks are an important part of the Server Message Block (SMB) protocol. Oplocks allow clients to cache and pre-read data locally, reducing interactions with remote servers and significantly increasing the file access rate. Oplocks help significantly improve performance for single-user file reading and writing and multi-user concurrent access, Internet Information Service (IIS) servers, genomics computing, and shared map applications.
Scenarios
File writes on a single client
When only one client is used to write files, the SMB client uses the write-back mode. Different from the write-through mode which writes small chunks of data to the backend each time, the write-back mode makes full use of the local write cache to reduce network communications, improving the overall write efficiency.
Concurrent file reads on a single or multiple clients
When only file read operations are performed, all SMB clients use the read-ahead mode. Each time a client pre-reads a batch of data to the local read cache, network communications caused by data reads are reduced, improving the overall read efficiency.
Frequent file opening and closing on multiple clients
If multiple clients frequently open and close files, SMB clients use the delayed-close method. This reduces network communications caused by repeated file closing and opening and improves the overall file access efficiency.
Precautions
Data loss risk: Data in the cache may be lost if the client system crashes or power failure occurs before the data is written back to primary storage.
Write latency: Data is written quickly, but the write operations synchronized to the primary storage may be delayed. This may not be applicable in some scenarios that require high data consistency.
Enable the oplock feature
The oplock feature is enabled by default. If you have disabled the oplock feature before, perform the following steps to enable it:
Log on to the NAS console.
In the left-side navigation pane, choose
.In the top navigation bar, select a region.
Find the SMB file system. Click the file system ID, or click Manage in the Actions column.
In the Advanced Options for SMB section on the Basic Information page, turn on oplock.
Disable the oplock feature
Log on to the NAS console.
In the left-side navigation pane, choose
.In the top navigation bar, select a region.
Find the SMB file system. Click the file system ID, or click Manage in the Actions column.
In the Advanced Options for SMB section on the Basic Information page, turn off oplock.