[Samba] file leases and replacing files

Jeremy Allison jra at samba.org
Tue Dec 27 18:09:41 UTC 2022

On Tue, Dec 27, 2022 at 10:17:01AM +0000, Rowland Penny via samba wrote:
>>What are windows file leases (displayed in smbstatus when
>>smbd grants one to a client) and how they work?  I bet
>>there's some documentation about this, but so far I
>>can't find it.
>>The problem is that when one replaces or modifies a file on linux
>>which is "leased" on windows, windows client start acting in a
>>weird way, for example it can start claiming the file does not
>>exist anymore when trying to open it, - up to client reboot.
>>This happens not just with executable files which are run from
>>the samba shares, but also for regular text files too, sometimes.
>>I can think that samba does not "notify" windows about the file
>>change "properly" in this case (I'm not saying it "should" here).
>>And I also can think that by using smbclient to modify these files
>>instead of direct open/write/close calls against the filesystem,
>>this problem can be eliminated, - this way, the modifications is
>>seen by samba immediately and it can break the leases.
>>Is there something I can read about that?
>Leases are a Windows thing, perhaps reading this might help to 
>understand them:
>As far as I am aware, altering or deleting a file (that has a Windows 
>lease on it) directly on Linux, isn't recommended, Linux has no 
>concept of 'leases'.
>My feelings are, if a file is in a directory shared by Samba, then do 
>not touch them directly on the server.

100% correct Rowland, thanks ! For Samba to break
client leases when local processes modify files
requires kernel support, which isn't fully
functional on Linux (or anywhere else on UNIXes
to my knowledge).

Accessing via smbclient is OK, as this is just
another SMB access and will allow Samba to
properly revoke leases.

More information about the samba mailing list