The branch, master has been updated via e2ebfd8 docs/kerneloplocks: drop Irix references via 7f1de9f s3: smbd: SGI IRIX is officially dead. Remove the kernel oplock code for IRIX. from 1e78cb5 s3: vfs: bump to version 40, Samba 4.10 will ship with that
https://git.samba.org/?p=samba.git;a=shortlog;h=master - Log ----------------------------------------------------------------- commit e2ebfd8e082fef59791947a24d61bfc50eec8596 Author: David Disseldorp <dd...@samba.org> Date: Wed Jul 25 00:33:09 2018 +0200 docs/kerneloplocks: drop Irix references Signed-off-by: David Disseldorp <dd...@samba.org> Reviewed-by: Jeremy Allison <j...@samba.org> Autobuild-User(master): Jeremy Allison <j...@samba.org> Autobuild-Date(master): Wed Jul 25 06:28:21 CEST 2018 on sn-devel-144 commit 7f1de9ff09b819a07dbee4945499b1f00217970b Author: Jeremy Allison <j...@samba.org> Date: Tue Jul 24 10:56:30 2018 -0700 s3: smbd: SGI IRIX is officially dead. Remove the kernel oplock code for IRIX. Signed-off-by: Jeremy Allison <j...@samba.org> Reviewed-by: David Disseldorp <dd...@samba.org> ----------------------------------------------------------------------- Summary of changes: docs-xml/smbdotconf/locking/kerneloplocks.xml | 15 +- source3/smbd/oplock.c | 4 +- source3/smbd/oplock_irix.c | 348 -------------------------- source3/smbd/proto.h | 4 - source3/wscript | 5 - source3/wscript_build | 1 - 6 files changed, 8 insertions(+), 369 deletions(-) delete mode 100644 source3/smbd/oplock_irix.c Changeset truncated at 500 lines: diff --git a/docs-xml/smbdotconf/locking/kerneloplocks.xml b/docs-xml/smbdotconf/locking/kerneloplocks.xml index a22cdf2..ff237ec 100644 --- a/docs-xml/smbdotconf/locking/kerneloplocks.xml +++ b/docs-xml/smbdotconf/locking/kerneloplocks.xml @@ -4,19 +4,18 @@ xmlns:samba="http://www.samba.org/samba/DTD/samba-doc"> <description> <para>For UNIXes that support kernel based <smbconfoption name="oplocks"/> - (currently only IRIX and the Linux 2.4 kernel), this parameter - allows the use of them to be turned on or off. However, this disables - Level II oplocks for clients as the Linux and IRIX kernels do not - support them properly.</para> + (currently only Linux), this parameter allows the use of them to be + turned on or off. However, this disables Level II oplocks for clients as + the Linux kernel does not support them properly.</para> <para>Kernel oplocks support allows Samba <parameter moreinfo="none">oplocks - </parameter> to be broken whenever a local UNIX process or NFS operation + </parameter> to be broken whenever a local UNIX process or NFS operation accesses a file that <citerefentry><refentrytitle>smbd</refentrytitle> - <manvolnum>8</manvolnum></citerefentry> has oplocked. This allows complete - data consistency between SMB/CIFS, NFS and local file access (and is + <manvolnum>8</manvolnum></citerefentry> has oplocked. This allows complete + data consistency between SMB/CIFS, NFS and local file access (and is a <emphasis>very</emphasis> cool feature :-).</para> <para>If you do not need this interaction, you should disable the - parameter on Linux and IRIX to get Level II oplocks and the associated + parameter on Linux to get Level II oplocks and the associated performance benefit.</para> <para>This parameter defaults to <constant>no</constant> and is translated diff --git a/source3/smbd/oplock.c b/source3/smbd/oplock.c index 34bebc6..6362329 100644 --- a/source3/smbd/oplock.c +++ b/source3/smbd/oplock.c @@ -1401,9 +1401,7 @@ void init_kernel_oplocks(struct smbd_server_connection *sconn) /* only initialize once */ if (koplocks == NULL) { -#if HAVE_KERNEL_OPLOCKS_IRIX - koplocks = irix_init_kernel_oplocks(sconn); -#elif HAVE_KERNEL_OPLOCKS_LINUX +#if HAVE_KERNEL_OPLOCKS_LINUX koplocks = linux_init_kernel_oplocks(sconn); #endif sconn->oplocks.kernel_ops = koplocks; diff --git a/source3/smbd/oplock_irix.c b/source3/smbd/oplock_irix.c deleted file mode 100644 index 75f34df..0000000 --- a/source3/smbd/oplock_irix.c +++ /dev/null @@ -1,348 +0,0 @@ -/* - Unix SMB/CIFS implementation. - IRIX kernel oplock processing - Copyright (C) Andrew Tridgell 1992-1998 - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. -*/ - -#define DBGC_CLASS DBGC_LOCKING -#include "includes.h" -#include "system/filesys.h" -#include "smbd/smbd.h" -#include "smbd/globals.h" - -#if HAVE_KERNEL_OPLOCKS_IRIX - -struct irix_oplocks_context { - struct kernel_oplocks *ctx; - struct smbd_server_connection *sconn; - int write_fd; - int read_fd; - struct tevent_fd *read_fde; - bool pending; -}; - -/**************************************************************************** - Test to see if IRIX kernel oplocks work. -****************************************************************************/ - -static bool irix_oplocks_available(void) -{ - int fd; - int pfd[2]; - TALLOC_CTX *ctx = talloc_stackframe(); - char *tmpname = NULL; - - set_effective_capability(KERNEL_OPLOCK_CAPABILITY); - - tmpname = talloc_asprintf(ctx, - "%s/koplock.%d", - lp_lock_directory(), - (int)getpid()); - if (!tmpname) { - TALLOC_FREE(ctx); - return False; - } - - if(pipe(pfd) != 0) { - DEBUG(0,("check_kernel_oplocks: Unable to create pipe. Error " - "was %s\n", - strerror(errno) )); - TALLOC_FREE(ctx); - return False; - } - - if((fd = open(tmpname, O_RDWR|O_CREAT|O_EXCL|O_TRUNC, 0600)) < 0) { - DEBUG(0,("check_kernel_oplocks: Unable to open temp test file " - "%s. Error was %s\n", - tmpname, strerror(errno) )); - unlink( tmpname ); - close(pfd[0]); - close(pfd[1]); - TALLOC_FREE(ctx); - return False; - } - - unlink(tmpname); - - TALLOC_FREE(ctx); - - if(sys_fcntl_long(fd, F_OPLKREG, pfd[1]) == -1) { - DEBUG(0,("check_kernel_oplocks: Kernel oplocks are not " - "available on this machine. Disabling kernel oplock " - "support.\n" )); - close(pfd[0]); - close(pfd[1]); - close(fd); - return False; - } - - if(sys_fcntl_long(fd, F_OPLKACK, OP_REVOKE) < 0 ) { - DEBUG(0,("check_kernel_oplocks: Error when removing kernel " - "oplock. Error was %s. Disabling kernel oplock " - "support.\n", strerror(errno) )); - close(pfd[0]); - close(pfd[1]); - close(fd); - return False; - } - - close(pfd[0]); - close(pfd[1]); - close(fd); - - return True; -} - -/* - * This is bad because the file_id should always be created through the vfs - * layer! Unfortunately, a conn struct isn't available here. - */ -static struct file_id file_id_create_dev(SMB_DEV_T dev, SMB_INO_T inode) -{ - struct file_id key; - - /* the ZERO_STRUCT ensures padding doesn't break using the key as a - * blob */ - ZERO_STRUCT(key); - - key.devid = dev; - key.inode = inode; - - return key; -} - -/**************************************************************************** - * Deal with the IRIX kernel <--> smbd - * oplock break protocol. -****************************************************************************/ - -static files_struct *irix_oplock_receive_message(struct kernel_oplocks *_ctx) -{ - struct irix_oplocks_context *ctx = talloc_get_type(_ctx->private_data, - struct irix_oplocks_context); - oplock_stat_t os; - char dummy; - struct file_id fileid; - files_struct *fsp; - - /* - * TODO: is it correct to assume we only get one - * oplock break, for each byte we read from the pipe? - */ - ctx->pending = false; - - /* - * Read one byte of zero to clear the - * kernel break notify message. - */ - - if(read(ctx->read_fd, &dummy, 1) != 1) { - DEBUG(0,("irix_oplock_receive_message: read of kernel " - "notification failed. Error was %s.\n", - strerror(errno) )); - return NULL; - } - - /* - * Do a query to get the - * device and inode of the file that has the break - * request outstanding. - */ - - if(sys_fcntl_ptr(ctx->read_fd, F_OPLKSTAT, &os) < 0) { - DEBUG(0,("irix_oplock_receive_message: fcntl of kernel " - "notification failed. Error was %s.\n", - strerror(errno) )); - if(errno == EAGAIN) { - /* - * Duplicate kernel break message - ignore. - */ - return NULL; - } - return NULL; - } - - /* - * We only have device and inode info here - we have to guess that this - * is the first fsp open with this dev,ino pair. - * - * NOTE: this doesn't work if any VFS modules overloads - * the file_id_create() hook! - */ - - fileid = file_id_create_dev((SMB_DEV_T)os.os_dev, - (SMB_INO_T)os.os_ino); - if ((fsp = file_find_di_first(ctx->sconn, fileid)) == NULL) { - DEBUG(0,("irix_oplock_receive_message: unable to find open " - "file with dev = %x, inode = %.0f\n", - (unsigned int)os.os_dev, (double)os.os_ino )); - return NULL; - } - - DEBUG(5,("irix_oplock_receive_message: kernel oplock break request " - "received for file_id %s gen_id = %ul", - file_id_string_tos(&fsp->file_id), - fsp->fh->gen_id )); - - return fsp; -} - -/**************************************************************************** - Attempt to set an kernel oplock on a file. -****************************************************************************/ - -static bool irix_set_kernel_oplock(struct kernel_oplocks *_ctx, - files_struct *fsp, int oplock_type) -{ - struct irix_oplocks_context *ctx = talloc_get_type(_ctx->private_data, - struct irix_oplocks_context); - - if (sys_fcntl_long(fsp->fh->fd, F_OPLKREG, ctx->write_fd) == -1) { - if(errno != EAGAIN) { - DEBUG(0,("irix_set_kernel_oplock: Unable to get " - "kernel oplock on file %s, file_id %s " - "gen_id = %ul. Error was %s\n", - fsp_str_dbg(fsp), - file_id_string_tos(&fsp->file_id), - fsp->fh->gen_id, - strerror(errno) )); - } else { - DEBUG(5,("irix_set_kernel_oplock: Refused oplock on " - "file %s, fd = %d, file_id = %s, " - "gen_id = %ul. Another process had the file " - "open.\n", - fsp_str_dbg(fsp), fsp->fh->fd, - file_id_string_tos(&fsp->file_id), - fsp->fh->gen_id )); - } - return False; - } - - DEBUG(10,("irix_set_kernel_oplock: got kernel oplock on file %s, file_id = %s " - "gen_id = %ul\n", - fsp_str_dbg(fsp), file_id_string_tos(&fsp->file_id), - fsp->fh->gen_id)); - - return True; -} - -/**************************************************************************** - Release a kernel oplock on a file. -****************************************************************************/ - -static void irix_release_kernel_oplock(struct kernel_oplocks *_ctx, - files_struct *fsp, int oplock_type) -{ - if (DEBUGLVL(10)) { - /* - * Check and print out the current kernel - * oplock state of this file. - */ - int state = sys_fcntl_long(fsp->fh->fd, F_OPLKACK, -1); - dbgtext("irix_release_kernel_oplock: file %s, file_id = %s" - "gen_id = %ul, has kernel oplock state " - "of %x.\n", fsp_str_dbg(fsp), - file_id_string_tos(&fsp->file_id), - fsp->fh->gen_id, state ); - } - - /* - * Remove the kernel oplock on this file. - */ - if(sys_fcntl_long(fsp->fh->fd, F_OPLKACK, OP_REVOKE) < 0) { - if( DEBUGLVL( 0 )) { - dbgtext("irix_release_kernel_oplock: Error when " - "removing kernel oplock on file " ); - dbgtext("%s, file_id = %s gen_id = %ul. " - "Error was %s\n", - fsp_str_dbg(fsp), - file_id_string_tos(&fsp->file_id), - fsp->fh->gen_id, - strerror(errno) ); - } - } -} - -static void irix_oplocks_read_fde_handler(struct tevent_context *ev, - struct tevent_fd *fde, - uint16_t flags, - void *private_data) -{ - struct irix_oplocks_context *ctx = talloc_get_type(private_data, - struct irix_oplocks_context); - files_struct *fsp; - - fsp = irix_oplock_receive_message(ctx->ctx); - break_kernel_oplock(ctx->sconn->msg_ctx, fsp); -} - -/**************************************************************************** - Setup kernel oplocks. -****************************************************************************/ - -static const struct kernel_oplocks_ops irix_koplocks = { - .set_oplock = irix_set_kernel_oplock, - .release_oplock = irix_release_kernel_oplock, - .contend_level2_oplocks_begin = NULL, - .contend_level2_oplocks_end = NULL, -}; - -struct kernel_oplocks *irix_init_kernel_oplocks(struct smbd_server_connection *sconn) -{ - struct kernel_oplocks *_ctx; - struct irix_oplocks_context *ctx; - int pfd[2]; - - if (!irix_oplocks_available()) - return NULL; - - _ctx = talloc_zero(sconn, struct kernel_oplocks); - if (!_ctx) { - return NULL; - } - - ctx = talloc_zero(_ctx, struct irix_oplocks_context); - if (!ctx) { - talloc_free(_ctx); - return NULL; - } - _ctx->ops = &irix_koplocks; - _ctx->private_data = ctx; - ctx->ctx = _ctx; - ctx->sconn = sconn; - - if(pipe(pfd) != 0) { - talloc_free(_ctx); - DEBUG(0,("setup_kernel_oplock_pipe: Unable to create pipe. " - "Error was %s\n", strerror(errno) )); - return False; - } - - ctx->read_fd = pfd[0]; - ctx->write_fd = pfd[1]; - - ctx->read_fde = tevent_add_fd(sconn->ev_ctx, - ctx, - ctx->read_fd, - TEVENT_FD_READ, - irix_oplocks_read_fde_handler, - ctx); - return _ctx; -} -#else - void oplock_irix_dummy(void); - void oplock_irix_dummy(void) {} -#endif /* HAVE_KERNEL_OPLOCKS_IRIX */ diff --git a/source3/smbd/proto.h b/source3/smbd/proto.h index 29121d5..f1a2812 100644 --- a/source3/smbd/proto.h +++ b/source3/smbd/proto.h @@ -731,10 +731,6 @@ void message_to_share_mode_entry(struct file_id *id, bool init_oplocks(struct smbd_server_connection *sconn); void init_kernel_oplocks(struct smbd_server_connection *sconn); -/* The following definitions come from smbd/oplock_irix.c */ - -struct kernel_oplocks *irix_init_kernel_oplocks(struct smbd_server_connection *sconn); - /* The following definitions come from smbd/oplock_linux.c */ void linux_set_lease_capability(void); diff --git a/source3/wscript b/source3/wscript index 8409e77..70d81ad 100644 --- a/source3/wscript +++ b/source3/wscript @@ -167,11 +167,6 @@ main() { }''', 'HAVE_KERNEL_OPLOCKS_LINUX', addmain=False, execute=True, msg="Checking for Linux kernel oplocks") - # Check for IRIX kernel oplock types - conf.CHECK_CODE('oplock_stat_t t; t.os_state = OP_REVOKE; t.os_dev = 1; t.os_ino = 1;', - 'HAVE_KERNEL_OPLOCKS_IRIX', headers='fcntl.h', - msg="Checking for IRIX kernel oplock types") - # Check for kernel share modes conf.CHECK_CODE(''' #include <sys/types.h> diff --git a/source3/wscript_build b/source3/wscript_build index becaffe..b510829 100644 --- a/source3/wscript_build +++ b/source3/wscript_build @@ -705,7 +705,6 @@ bld.SAMBA3_LIBRARY('smbd_base', smbd/mangle_hash.c smbd/mangle_hash2.c smbd/oplock.c - smbd/oplock_irix.c smbd/oplock_linux.c smbd/notify.c smbd/notify_msg.c -- Samba Shared Repository