OS X not releasing locks on SAMBA share?

Status
Not open for further replies.

tobiasbp

Patron
Joined
Dec 2, 2015
Messages
238
Some OS X clients (10.11.* and up tested) do not release the locks on my FreeNAS once they close the file. The locks will only be released once the client logs off the SAMBA share.

SMB service is set up with the maximum SMB version 3_11. No minimum version specified.

Enabled VFS objects on the share are:
streams_xattr
aio_pthread
catio
fruit

Installing SMBup (Replaces Apples client with Samba one) on the clients SEEMS to solve the problem: Closing a file from the share, releases the lock.

Is there anything I could to to fix this on the serverside? It loks like an Apple problem to me.

Thanks,
Tobias
 
Last edited:

m0nkey_

MVP
Joined
Oct 27, 2015
Messages
2,739
You can disable oplocks in Samba. You need to set oplocks = False in the auxiliary parameters of the share.
 

tobiasbp

Patron
Joined
Dec 2, 2015
Messages
238
You can disable oplocks in Samba.

Thank you for the suggestion. However, it did not resolve the problem. Locks are not released by the latest version of OS X (10.13.1). Earlier versions (10.12.6, 10.11.6 tested), do release the locks as expected.
 

tobiasbp

Patron
Joined
Dec 2, 2015
Messages
238
I think I have made sense of it: In OS X 10.13.1 the Preview application & preview functionality in the Finder, does not release locks (DENY_NONE) on files it has previewed from a (Samba) file server. This appears to be new behaviour to OS X 10.13.1.

Why is this a problem?:
Some users have a workflow, were they overwrite entire folder structures on the Samba server. If there are any locks on files/folders below the top folder, the request can not be completed, and the Finder (OS X) does not inform the user. To the users, it looks like the operation was completed, but it was not. Often none of the user's data actually gets uploaded to the server (But they think it has been). So, the real problem, is the Finder's lack of response to the user, but locks not getting released, makes the problem much worse.


How to test:
1: Disable all preview functionality in the Finder.
2: Browse to a PDF on you Samba fileserver.
3. Open it with something other than Preview (The default). Confirm there is a lock on the Samba server with "smbstatus --locks".
4: Close the application (not Preview) with the PDF file open. Confirm that the lock has been released on the Samba server (smbstatus --locks").
5: Open the pdf from the Samba server with the default Preview application. Confirm there is a lock on the file on the fileserver.
6: Close the Preview application viewing the pdf file. Confirm, that the lock has NOT been released.

Can anyone else confirm this behaviour on OS X 10.13.1?
Can anyone else confirm that this is NOT behaviour on versions of OS X older than 10.13.1?
 
Last edited:

anodos

Sambassador
iXsystems
Joined
Mar 6, 2014
Messages
9,546
I'm currently investigating the issue. I believe it's exposing a bug in samba wrt smb2 lease handling on alternate data streams. Samba isn't properly clearing smb2 leases on AFP_Resource streams after finder opens/ closes them in some (but not all) situations. Possibly a race condition in the locking code.

The other share mode deny_none locks in smbstatus output may exist because of the locks on the file's xattr.

I haven't gotten too far into debugging yet, but it appears in my limited testing that you can currently work around the issue by one of the following:

1) disable oplocks on share
2) disable smb2 leases globally
3) veto oplocks for file types that are having problems.

Tested in FN 11.1-RC1 with vfs_fruit, with aux parameters to store afp_metadata and resource forks in streams.

Once I gather enough I gather enough collateral, I'll make a bug report and we'll try to get this fixed.
 
Last edited:

anodos

Sambassador
iXsystems
Joined
Mar 6, 2014
Messages
9,546
Thank you for the suggestion. However, it did not resolve the problem. Locks are not released by the latest version of OS X (10.13.1). Earlier versions (10.12.6, 10.11.6 tested), do release the locks as expected.

You will have to establish a new SMB session after changing these parameters. This means cycling the SMB service off and on, typing "service samba_server restart" from the CLI, or unmounting the share client-side then remounting it.
 

diedrichg

Wizard
Joined
Dec 4, 2012
Messages
1,319
Quick hijack... What SMB version must be set in FreeNAS to work with 10.12.6?
 

tobiasbp

Patron
Joined
Dec 2, 2015
Messages
238
You will have to establish a new SMB session after changing these parameters. This means cycling the SMB service off and on, typing "service samba_server restart" from the CLI, or unmounting the share client-side then remounting it.

I did, but setting oplocks = False did not change anything regarding the locks not beeing released by OS X 10.13.1.
 
Status
Not open for further replies.
Top