1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-23 17:34:34 +03:00

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
This commit is contained in:
Volker Lendecke 2018-12-14 13:05:50 +01:00 committed by Jeremy Allison
parent 1cff50febe
commit b77fae3281

View File

@ -87,6 +87,32 @@ NTSTATUS set_file_oplock(files_struct *fsp)
return NT_STATUS_OK;
}
static void release_fsp_kernel_oplock(files_struct *fsp)
{
struct smbd_server_connection *sconn = fsp->conn->sconn;
struct kernel_oplocks *koplocks = sconn->oplocks.kernel_ops;
bool use_kernel;
if (koplocks == NULL) {
return;
}
use_kernel = lp_kernel_oplocks(SNUM(fsp->conn));
if (!use_kernel) {
return;
}
if (fsp->oplock_type == NO_OPLOCK) {
return;
}
if (fsp->oplock_type == LEASE_OPLOCK) {
/*
* For leases we don't touch kernel oplocks at all
*/
return;
}
koplocks->ops->release_oplock(koplocks, fsp, NO_OPLOCK);
}
/****************************************************************************
Attempt to release an oplock on a file. Decrements oplock count.
****************************************************************************/
@ -94,14 +120,8 @@ NTSTATUS set_file_oplock(files_struct *fsp)
static void release_file_oplock(files_struct *fsp)
{
struct smbd_server_connection *sconn = fsp->conn->sconn;
struct kernel_oplocks *koplocks = sconn->oplocks.kernel_ops;
bool use_kernel = lp_kernel_oplocks(SNUM(fsp->conn)) &&
(koplocks != NULL);
if ((fsp->oplock_type != NO_OPLOCK) &&
use_kernel) {
koplocks->ops->release_oplock(koplocks, fsp, NO_OPLOCK);
}
release_fsp_kernel_oplock(fsp);
if (fsp->oplock_type == LEVEL_II_OPLOCK) {
sconn->oplocks.level_II_open--;