s3:vfs:gpfs convert sharemodes/leases parameter
authorChristian Ambach <christian.ambach@de.ibm.com>
Fri, 8 Oct 2010 11:15:57 +0000 (13:15 +0200)
committerVolker Lendecke <vlendec@samba.org>
Wed, 13 Oct 2010 12:53:16 +0000 (12:53 +0000)
convert gpfs:sharemodes and gpfs:leases parameters from a global setting
to a per share setting

source3/modules/gpfs.c
source3/modules/vfs_gpfs.c

index e05980888b81529b16e034fd5479ae3989bd4252..c8fb88d92eee59c96bda5df1219f04773c3a747d 100644 (file)
@@ -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);
index 5fdcef94dbf599feb14f88a0e97da0bea5d7a775..be035a83bc9c601020a89520a51d7db06b952340 100644 (file)
 #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);
@@ -1103,7 +1128,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,