11

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.

2
  • can you mention the specific samba rpm version this is happening with? Commented Aug 13 at 11:34
  • samba-4.22.3-2.fc42.x86_64 Commented Aug 14 at 0:03

1 Answer 1

15

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.

6
  • 1
    +1. I wonder if, after changing or renaming files etc in linux, it's possible to touch a dummy file (made with mktemp or similar) in the share directory, then use smbclient ... rm $dummy_file to 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. Commented Aug 13 at 5:57
  • 1
    Not 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. Commented Aug 13 at 7:17
  • This is great to know. I will disable directory leases on this server right away. Commented 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. Commented Aug 14 at 9:52
  • @cas In that case it'd be easier to systemctl restart smbd for the same result. Commented Aug 14 at 9:55

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.