Bug 13193 - smbd tries to release not leased oplock during oplock II downgrade
smbd tries to release not leased oplock during oplock II downgrade
Status: RESOLVED FIXED
Product: Samba 4.1 and newer
Classification: Unclassified
Component: File services
4.5.10
All Linux
: P5 normal
: ---
Assigned To: Karolin Seeger
Samba QA Contact
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2017-12-17 10:05 UTC by Lev
Modified: 2018-01-10 10:27 UTC (History)
3 users (show)

See Also:


Attachments
Raw (not git) patch for master. (706 bytes, patch)
2017-12-19 22:19 UTC, Jeremy Allison
no flags Details
Updated raw patch for master. (2.15 KB, patch)
2017-12-19 22:48 UTC, Jeremy Allison
no flags Details
Proposed git-am fix for master. (4.11 KB, patch)
2018-01-03 20:12 UTC, Jeremy Allison
vl: review+
Details
Identical fix for 4.7.next, 4.6.next cherry-picked from master. (4.34 KB, patch)
2018-01-04 18:33 UTC, Jeremy Allison
vl: review+
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Lev 2017-12-17 10:05:42 UTC
I have two shares, one with "kernel oplocks = Yes", and another one with "kernel oplocks = No". smb2 leases are disabled.

When server establishes connection with the 1st share, smbd sets sconn->oplocks.kernel_ops in make_connection_snum().
Then, when samba opens file on a 2nd share, it may call set_file_oplock(oplock=0x4), but linux_set_kernel_oplock is not called, because kernel oplocks = No.
But later downgrade_oplock() for the file on the 2nd share can be issued, that in turn will call downgrade_file_oplock(). Here downgrade_file_oplock() checks only if sconn->oplocks.kernel_ops is set, but not "kernel oplocks" flag, and calls linux_release_kernel_oplock, that returns EAGAIN:

[2017/11/27 16:23:24.807595,  0, pid=4325, class=locking] ../source3/smbd/oplock_linux.c:184(linux_release_kernel_oplock)
  linux_release_kernel_oplock: Error when removing kernel oplock 0x4 on file /export/smbOnly:shared_text.txt, file_id = fd16:83:0, gen_id = 1750599511. Error was Resource temporarily unavailable

This issue reminds https://bugzilla.samba.org/show_bug.cgi?id=11400, but now it is about downgrade_file_oplock and not release_file_oplock.
Comment 1 Jeremy Allison 2017-12-19 22:19:34 UTC
Created attachment 13876 [details]
Raw (not git) patch for master.

Can you check this patch and see if it fixes your problem ? It causes downgrade_file_oplock() to use the same logic as release_file_oplock().
Comment 2 Jeremy Allison 2017-12-19 22:48:15 UTC
Created attachment 13877 [details]
Updated raw patch for master.

Corrects the use_kernel logic in all functions in this file. Please test and let me know.
Comment 3 Jeremy Allison 2017-12-22 17:48:27 UTC
Ping ! Lev, can you let me know if this fix solved the problem ?
Comment 4 Lev 2017-12-23 16:43:13 UTC
(In reply to Jeremy Allison from comment #3)
Jeremy, sorry, I'm on vacation now, will be back only in a week.
Lev.
Comment 5 Jeremy Allison 2017-12-24 17:04:12 UTC
OK, no problem. I'm also out over the holiday period. Let me know when you get a chance to test :-). Happy Holidays !
Comment 6 Lev 2018-01-03 15:09:21 UTC
Hi Jeremy,
Yes, I confirm, the patch fixes the issue,
Thanks,
  -Lev.
Comment 7 Jeremy Allison 2018-01-03 20:12:05 UTC
Created attachment 13892 [details]
Proposed git-am fix for master.
Comment 8 Jeremy Allison 2018-01-04 18:33:18 UTC
Created attachment 13893 [details]
Identical fix for 4.7.next, 4.6.next cherry-picked from master.
Comment 9 Karolin Seeger 2018-01-05 08:20:08 UTC
Pushed to autobuild-v4-{7,6}-test.
Comment 10 Karolin Seeger 2018-01-10 10:27:02 UTC
Pushed to both branches.
Closing out bug report.

Thanks!