[Samba] file leases and replacing files

Jeremy Allison jra at samba.org
Sat Dec 31 00:35:59 UTC 2022

On Fri, Dec 30, 2022 at 09:30:04AM +0300, Michael Tokarev wrote:
>I thought about it some more now, and think the best would
>be to "notify" all consumers about the changed files (eg,
>to send "oplock break requests" to all involved parties,
>speaking in the old terms).
>When we initially implemented this, we had oplocks=no for
>this share. This made it noticeable slower obviously, but
>there were no issues like this (and windows weren't that
>sophisticated in this area, ditto for samba).
>Maybe turning off share modes will help here as well.
>Though if possible, I'd love to find a way to allow
>share modes, since the update is rare, and 99.9% of
>we can allow caching for sure.
>Can one tell smbd to send an oplock break request

The easiest way to do that is simply to open
each file you want to break the oplock on
via an smb share.

e.g. On a share [foo], directory bar/
to break all leases on files under bar,
do a loopback cifsfs mount (over SMB3)
from the server using: mount.cifs
to share //localhost/foo to mountpoint
/mnt and simply do a:

find /mnt/bar -type f -exec cp {} /dev/null ;

That will open for read all files under [foo]/bar
and cause any read/write/handle leases to get

Might need some tweaking to get the desired
semantics but I'm sure you get the idea.

More information about the samba mailing list