Doing some additional experiments to Windows and also to the updated Samba branch from Ralph, I see the directory lease request, and I see that after ls (which will cache the directory contents for about 30 second) we do get a big benefit from the metadata of the directory entries being cached e.g. "ls /mnt ; sleep 10; stat /mnt/file ; sleep 15 stat /mnt/file2 ; sleep 10 /mnt/file" - we only get the roundtrips for the initial ls - the stat calls don't cause any network traffic since the directory is cached. > the client opens a directory with R lease, does a query-info on it and > then opens the directory a second time, without lease, and uses that > second handle for the directory listing. We get two calls from the kernel here for that "ls" That query info is for "revalidate" and the second roundtrip is for the readdir, but it does look like a bug in the querydir not reusing the handle. On Sun, Oct 27, 2024 at 9:16 AM Ralph Boehme <slow@xxxxxxxxx> wrote: > > On 10/27/24 4:24 AM, Steve French wrote: > > I built and installed Samba with your recent directory lease series > > and tried some experiments with cifs.ko to it and I do see directory > > lease requested by the client and held for 30 seconds for the > > directory (or directories) that I do ls on,... > > hm, guess I was not looking close enough, I rechecked and now I can see > the client requesting directory leases and the server granting them. > > Two things seem odd: > > - the client only requests a READ lease without a HANDLE lease, > > - the client opens a directory with R lease, does a query-info on it and > then opens the directory a second time, without lease, and uses that > second handle for the directory listing. > > In my understanding a directory lease without H lease is useless, as it > limits lifetime of the cache to the lifetime of the handle and you can't > defer the close on the directory handle without a H lease. > > Cf the presentation "SMB2.2 Advancements for WAN" from SDC 2011 page 20: > > "Without H leases, the R lease is of no value." > > open_cached_dir() seems to be the function requesting the directory > lease and it requests SMB2_OPLOCK_LEVEL_II which is mapped to > SMB2_LEASE_READ_CACHING_LE. > > Thanks! > -slow -- Thanks, Steve