On my Fedora 42 Linux system, I have an ext4 file system named /pictures, which is exported as a Samba share. It is mounted on a Windows 10 system. When this is updated on the Linux side (mass renames, etc.), the changes are not reflected in the Windows File Explorer, even after a "Refresh" command. This seems to be new (or severely worsened?) since I upgraded from F41 to F42.
-
can you mention the specific samba rpm version this is happening with?ron– ron2025-08-13 11:34:08 +00:00Commented Aug 13 at 11:34
-
samba-4.22.3-2.fc42.x86_64Lars Poulsen– Lars Poulsen2025-08-14 00:03:36 +00:00Commented Aug 14 at 0:03
1 Answer
Samba now issues directory leases, i.e. promises to the client that nothing has changed and the directory listing can be safely cached client-side without the need to re-check (until there is a change and the server recalls the lease). This is mostly equivalent to "directory delegations" in NFSv4.
The advantage is that instead of clients caching metadata for a fixed period of time (which needs to be balanced between too long and/or too short), leases allow caching indefinitely by providing instant cache flush on change.
But Samba doesn't support monitoring for external changes, so the only time leases get recalled is when the change is made through the same SMB (by some other client). Without smbd monitoring the filesystem for changes, after you rename something the client still holds the lease and (by design) assumes that it doesn't need to refresh the cached contents.
Configure smb3 directory leases = no to disable this feature.
If you frequently edit SMB-shared files directly, see also the description of the kernel oplocks option.
-
1+1. I wonder if, after changing or renaming files etc in linux, it's possible to
toucha dummy file (made with mktemp or similar) in the share directory, then usesmbclient ... rm $dummy_fileto make samba expire any leases for a given directory. A bit ugly, too bad there isn't a touch command in smbclient which could be used to touch the directory itself.cas– cas2025-08-13 05:57:00 +00:00Commented Aug 13 at 5:57 -
1Not sure if that's really worth the effort, unless keeping the directory caching is critical. SMB is still perfectly usable without directory leases, even across WAN, and you'd probably be spending more time manually poking the server via smbclient than you'd avoid being annoyed by any slowness.grawity– grawity2025-08-13 07:17:57 +00:00Commented Aug 13 at 7:17
-
This is great to know. I will disable directory leases on this server right away.Lars Poulsen– Lars Poulsen2025-08-13 23:59:53 +00:00Commented Aug 13 at 23:59
-
Yeah, not something I'd want to do routinely but for once-off or occasional use for a mass rename or whatever, it's easier than getting all the windows users to logout & reconnect to the samba server or whatever it takes to get windows to refresh a lease. And IMO preferable to disabling a useful feature just for an occasional file maintenance task. If for some reason I did have to do it routinely, at least smbclient is scriptable.cas– cas2025-08-14 09:52:22 +00:00Commented Aug 14 at 9:52
-
@cas In that case it'd be easier to systemctl restart smbd for the same result.grawity– grawity2025-08-14 09:55:05 +00:00Commented Aug 14 at 9:55