From 4413d05bd742f879a6af71206265791ff76070bb Mon Sep 17 00:00:00 2001 From: Christian Ambach Date: Fri, 8 Oct 2010 13:15:57 +0200 Subject: [PATCH] s3:vfs:gpfs convert sharemodes/leases parameter convert gpfs:sharemodes and gpfs:leases parameters from a global setting to a per share setting cherry-picked from 22018b8b887c2677d30bbb4589f800197edf0e98 --- source3/modules/gpfs.c | 12 -------- source3/modules/vfs_gpfs.c | 72 ++++++++++++++++++++++++++++++++++++++++------ 2 files changed, 64 insertions(+), 20 deletions(-) diff --git a/source3/modules/gpfs.c b/source3/modules/gpfs.c index e05980888b8..c8fb88d92ee 100644 --- a/source3/modules/gpfs.c +++ b/source3/modules/gpfs.c @@ -24,8 +24,6 @@ #include "gpfs_gpl.h" #include "vfs_gpfs.h" -static bool gpfs_share_modes; -static bool gpfs_leases; static bool gpfs_getrealfilename; static bool gpfs_winattr; @@ -47,10 +45,6 @@ bool set_gpfs_sharemode(files_struct *fsp, uint32 access_mask, unsigned int deny = GPFS_DENY_NONE; int result; - if (!gpfs_share_modes) { - return True; - } - if (gpfs_set_share_fn == NULL) { return False; } @@ -96,10 +90,6 @@ int set_gpfs_lease(int fd, int leasetype) { int gpfs_type = GPFS_LEASE_NONE; - if (!gpfs_leases) { - return True; - } - if (gpfs_set_lease_fn == NULL) { errno = EINVAL; return -1; @@ -249,8 +239,6 @@ void init_gpfs(void) init_gpfs_function(&gpfs_get_winattrs_fn,"gpfs_get_winattrs"); - gpfs_share_modes = lp_parm_bool(-1, "gpfs", "sharemodes", True); - gpfs_leases = lp_parm_bool(-1, "gpfs", "leases", True); gpfs_getrealfilename = lp_parm_bool(-1, "gpfs", "getrealfilename", True); gpfs_winattr = lp_parm_bool(-1, "gpfs", "winattr", False); diff --git a/source3/modules/vfs_gpfs.c b/source3/modules/vfs_gpfs.c index 0c28408448d..6ae562feade 100644 --- a/source3/modules/vfs_gpfs.c +++ b/source3/modules/vfs_gpfs.c @@ -30,18 +30,29 @@ #include "nfs4_acls.h" #include "vfs_gpfs.h" +struct gpfs_config_data { + bool sharemodes; + bool leases; +}; + + static int vfs_gpfs_kernel_flock(vfs_handle_struct *handle, files_struct *fsp, uint32 share_mode, uint32 access_mask) { + struct gpfs_config_data *config; + + SMB_VFS_HANDLE_GET_DATA(handle, config, + struct gpfs_config_data, + return -1); + START_PROFILE(syscall_kernel_flock); kernel_flock(fsp->fh->fd, share_mode, access_mask); - if (!set_gpfs_sharemode(fsp, access_mask, fsp->share_access)) { - + if (config->sharemodes + && !set_gpfs_sharemode(fsp, access_mask, fsp->share_access)) { return -1; - } END_PROFILE(syscall_kernel_flock); @@ -51,7 +62,14 @@ static int vfs_gpfs_kernel_flock(vfs_handle_struct *handle, files_struct *fsp, static int vfs_gpfs_close(vfs_handle_struct *handle, files_struct *fsp) { - if ((fsp->fh != NULL) && (fsp->fh->fd != -1)) { + + struct gpfs_config_data *config; + + SMB_VFS_HANDLE_GET_DATA(handle, config, + struct gpfs_config_data, + return -1); + + if (config->sharemodes && (fsp->fh != NULL) && (fsp->fh->fd != -1)) { set_gpfs_sharemode(fsp, 0, 0); } @@ -61,16 +79,23 @@ static int vfs_gpfs_close(vfs_handle_struct *handle, files_struct *fsp) static int vfs_gpfs_setlease(vfs_handle_struct *handle, files_struct *fsp, int leasetype) { - int ret; + struct gpfs_config_data *config; + int ret=0; + + SMB_VFS_HANDLE_GET_DATA(handle, config, + struct gpfs_config_data, + return -1); START_PROFILE(syscall_linux_setlease); - if ( linux_set_lease_sighandler(fsp->fh->fd) == -1) + if (linux_set_lease_sighandler(fsp->fh->fd) == -1) return -1; - ret = set_gpfs_lease(fsp->fh->fd,leasetype); + if (config->leases) { + ret = set_gpfs_lease(fsp->fh->fd,leasetype); + } - if ( ret < 0 ) { + if (ret < 0) { /* This must have come from GPFS not being available */ /* or some other error, hence call the default */ ret = linux_setlease(fsp->fh->fd, leasetype); @@ -1116,7 +1141,38 @@ static int vfs_gpfs_ntimes(struct vfs_handle_struct *handle, } +int vfs_gpfs_connect(struct vfs_handle_struct *handle, const char *service, + const char *user) +{ + struct gpfs_config_data *config; + int ret = SMB_VFS_NEXT_CONNECT(handle, service, user); + + if (ret < 0) { + return ret; + } + + config = talloc_zero(handle->conn, struct gpfs_config_data); + if (!config) { + SMB_VFS_NEXT_DISCONNECT(handle); + DEBUG(0, ("talloc_zero() failed\n")); return -1; + } + + config->sharemodes = lp_parm_bool(SNUM(handle->conn), "gpfs", + "sharemodes", true); + + config->leases = lp_parm_bool(SNUM(handle->conn), "gpfs", + "leases", true); + + SMB_VFS_HANDLE_SET_DATA(handle, config, + NULL, struct syncops_config_data, + return -1); + + return 0; +} + + static struct vfs_fn_pointers vfs_gpfs_fns = { + .connect_fn = vfs_gpfs_connect, .kernel_flock = vfs_gpfs_kernel_flock, .linux_setlease = vfs_gpfs_setlease, .get_real_filename = vfs_gpfs_get_real_filename, -- 2.11.4.GIT