1
0
mirror of https://github.com/samba-team/samba.git synced 2025-01-22 22:04:08 +03:00

s3:vfs:gpfs convert sharemodes/leases parameter

convert gpfs:sharemodes and gpfs:leases parameters from a global setting
to a per share setting
This commit is contained in:
Christian Ambach 2010-10-08 13:15:57 +02:00 committed by Volker Lendecke
parent 9e4a386d67
commit 22018b8b88
2 changed files with 64 additions and 20 deletions

View 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);

View File

@ -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);
@ -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,