Directory Leasing feature in Samba smbd

Krishna Harathi krishna.harathi at
Wed Sep 2 17:18:05 UTC 2020


Thanks for the insightful response on how to start on directory leasing feature.

After reading more into Microsoft SMB2/3 directory leasing, in our customer case, looks like the windows client is taking advantage of the granted directory lease and maintaining a directory cache.

I am attempting to setup the following even before writing test cases.

  1. Using directory lease capable Windows Server 2012R2 (or later), setup a shared folder/directory with a set of files/folders in it.
  2. On a Windows client capable of using directory lease , map the shared folder to a local drive letter. 
  3.  Start capturing tcpip packets on either client or server.
  4. Browse the shared folder on the client multiple times. 
  5. The tcpip dump should show only a single directory scan set (SMB2_FIND_BOTH_DIRECTORY_INFO requests/responses)

Is my assumption and approach correct? Is there a better/direct way to monitor the directory lease and cache in the client? 

Only information I found on Windows is the global configuration values of "DirectoryCacheEntriesMax" and "DirectoryCacheEntrySizeMax" shown with powershell "get-smbclientconfiguration". Are there any stats to monitor to determine that the directory cache is active with entries from the mapped drive that has the directory leased?

Once this setup is done and confirmed working, I will have a better understanding on what to expect and I will start adding test cases to smb torture.


Krishna Harathi

On 8/26/20, 10:32 AM, "Jeremy Allison" <jra at> wrote:

    ***EXTERNAL SENDER. Only open links and attachments from known senders. DO NOT provide your username or password.***

    On Mon, Aug 24, 2020 at 06:58:45PM +0000, Krishna Harathi via samba-technical wrote:
    > A more dominant issue of lack of directory lease support in smbd surfaced while looking into UNC vs mapped drive performance.
    > As per Samba Wiki, this directory leasing feature is not planned anytime soon. Let me know otherwise.
    > I may be able to spend some time working on this feature, once I get a better idea of what it takes to implement.
    > I have read the high-level notes at
    > I appreciate any comments on this topic at this time, mostly checking to see the forum's interest to chart out the next level of details.

    Hi Krishna,

    The best way to proceed on this is to add additional
    smbtorture tests inside source4/torture/smb2/lease.c
    that pass against a Windows server to explore the exact
    behavior we'll need to reproduce to correctly implement
    directory leases.

    You can mark the additional tests as knownfail inside
    a file in the selftest/knownfail.d/ directory.

    Once we have a comprehensive set of tests we'll be
    able to better evaluate what server changes we'll
    need to start passing them.

    Thanks a *LOT* for looking at this, it's much
    appreciated !


More information about the samba-technical mailing list