[Samba] Defining OutputBufferLength for SMB2_FIND_BOTH_DIRECTORY_INFO

Stefan Koehler contact at soocs.de
Tue Nov 18 09:13:00 UTC 2025


Hello,
I have a third-party Windows application (which cannot be changed) that accesses files located on an SMB share. The problem is that the application issues searches on the SMB share, which results in several SMB2_FIND_BOTH_DIRECTORY_INFO requests. These requests generate a large number of SMB2_FIND_BOTH_DIRECTORY_INFO responses (search pattern "*" is used) until the “Error: STATUS_NO_MORE_FILES” condition is reached.

The SMB2 service response time statistics reflect the problem, as the Find procedure - with roughly 13,000 calls - dominates the total SRT by far (resulting in a lot of network round trips).

I already researched the SMB protocol definitions and found this:
https://winprotocoldocs-bhdugrdyduf5h2e4.b02.azurefd.net/MS-SMB2/%5bMS-SMB2%5d.pdf
MaxTransactSize (4 bytes): The maximum size, in bytes, of the buffer that can be used for QUERY_INFO, QUERY_DIRECTORY, SET_INFO and CHANGE_NOTIFY operations. This field is
applicable only for buffers sent by the client in SET_INFO requests, or returned from the server in QUERY_INFO, QUERY_DIRECTORY, and CHANGE_NOTIFY responses.<27>
<27> Section 2.2.4: Windows clients do not enforce the MaxTransactSize value.

https://learn.microsoft.com/en-us/openspecs/windows_protocols/ms-smb2/10906442-294c-46d3-8515-c277efe1f752
2.2.33 SMB2 QUERY_DIRECTORY Request
OutputBufferLength (4 bytes): The maximum number of bytes the server is allowed to return in the SMB2 QUERY_DIRECTORY Response.

If I check the OutputBufferLength in the SMB2_FIND_BOTH_DIRECTORY_INFO request, it shows “Output Buffer Length: 4096”, which also matches the “Blob Length: 4070” in the SMB2_FIND_BOTH_DIRECTORY_INFO responses.

My question is: How can I increase the OutputBufferLength to 16 KB (or maybe even higher) to reduce the network round trips for the SMB2_FIND_BOTH_DIRECTORY_INFO requests? No matter if I have to set an option/parameter on server or client side.

Server Debian 6.12.33
Server Samba version 4.22.5
Client Windows 10

testparm -sv | grep -i smb2
client min protocol = SMB2_02
server min protocol = SMB2_02
smb2 disable lock sequence checking = No
smb2 disable oplock break retry = No
smb2 leases = Yes
smb2 max credits = 8192
smb2 max read = 8388608
smb2 max trans = 8388608
smb2 max write = 8388608

Thank you.

Best Regards
Stefan



More information about the samba mailing list