smbd: Don't try to release a kernel oplock for a leased file
authorVolker Lendecke <vl@samba.org>
Fri, 14 Dec 2018 12:05:50 +0000 (13:05 +0100)
committerJeremy Allison <jra@samba.org>
Tue, 18 Dec 2018 01:00:44 +0000 (02:00 +0100)
commitb77fae3281a06a99a7e298378a68d273ee28355c
treedadcd3539993c80aab6060494f95c9f021d5b96e
parent1cff50febecfb3c0443a17da29a047eea2e09e61
smbd: Don't try to release a kernel oplock for a leased file

If we have

[global]
  smb2 leases = yes
  kernel oplocks = no
[share]
  kernel oplocks = yes

for clients requesting leases we don't even try to acquire kernel
oplocks, because the kernel API is not compatible. Kernel oplocks are
per fd, leases are roughly "per inode".

We don't however special-case the LEASE_OPLOCK case in
release_file_oplock, leading to nasty error messages like "bad file
descriptor" on the fcntl(fd,F_SETLEASE,F_UNLCK) call. They are
harmless, but they raise eyebrows.

To simplify the if-condition, I factored out the kernel call and
applied early returns.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
Autobuild-User(master): Jeremy Allison <jra@samba.org>
Autobuild-Date(master): Tue Dec 18 02:00:44 CET 2018 on sn-devel-144
source3/smbd/oplock.c