Bug 15130 - Failed to download file that is write locked: NT_STATUS_FILE_LOCK_CONFLICT
Summary: Failed to download file that is write locked: NT_STATUS_FILE_LOCK_CONFLICT
Alias: None
Product: Samba 4.1 and newer
Classification: Unclassified
Component: libsmbclient (show other bugs)
Version: 4.13.17
Hardware: All All
: P5 normal (vote)
Target Milestone: ---
Assignee: Samba QA Contact
QA Contact: Samba QA Contact
Depends on:
Reported: 2022-07-26 09:39 UTC by wangrong
Modified: 2022-08-18 05:56 UTC (History)
0 users

See Also:


Note You need to log in before you can comment on or make changes to this bug.
Description wangrong 2022-07-26 09:39:38 UTC
Problem recurrence:
    On the server side, a process opens a file in a shared directory and adds a POSIX write lock. For example, use WPS to open 123.xls.
    On the client side, an error (NT_STATUS_FILE_LOCK_CONFLICT) will be reported when using smbclient or libsmbclient to download an opened file.

But opened files can be downloaded normally through CIFS. 

The preliminary test found that the file download can be completed after completing the following modifications:
    Change the initial value of the flags variable in the functions SMBC_server_internal and do_connect to CLI_FULL_CONNECTION_OPLOCKS.

What I want to ask is:
    Is there any risk to this modification.
    Is there a configuration to control oplock behavior on the client side.

Looking forward to your reply, thanks!
Comment 1 Jeremy Allison 2022-08-17 17:37:48 UTC
This is dependent on the server locking settings.

To make clients ignore server-side POSIX write locks, set:

posix locking = no

on the share definition in your smb.conf. When you say:

"But opened files can be downloaded normally through CIFS."

I'm assuming you mean the Linux kernel cifsfs client. That also depends on settings on the mount.

oplocks are nothing to do with server-side byte range locks.
Comment 2 wangrong 2022-08-18 05:42:24 UTC
Thanks for your reply.

The man page says setting "posix locking = no" is not a good idea.
With the server using the default settings ("posix locking = yes"), cifsfs can access files opened on the server because its oplock is Lease (0xff), which is the same as Win11, but smbclient cannot access files opened on the server because Its oplock is always No oplock (0x00).
cifsfs will use lease oplock by default unless the mount option nolease is used.

Does smbclient support oplock related configuration, similar to the nolease mount option of cifsfs?
Comment 3 Jeremy Allison 2022-08-18 05:56:05 UTC
Please do not re-open bugs I have closed due to mis-understandings. If you re-open again I will have your account removed from the bugzilla.

oplocks have *NOTHING* to do with byte range locks. The two are completely disjoint.

Please do some research on the difference between oplocks/leases and byte range locks. It isn't my job to educate you on this bugzilla.

I'll be happy to answer any questions you may have on the samba mailing list, but our bug tracking database isn't the place for questions like this.