From 4fe70bcee2ec8515f123d8c826631b54bbf793e7 Mon Sep 17 00:00:00 2001 From: Jim McDonough Date: Thu, 9 Nov 2006 20:29:31 +0000 Subject: r19647: Add some GPFS support in a vfs mod. Also adds the kernel flock op to the vfs layer, since gpfs supports it. Thanks to Volker, Christian, Mathias, Chetan, and Peter. (This used to be commit 0620658890fa9c68a9848538728023192319c81a) --- source3/modules/gpfs.c | 231 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 231 insertions(+) create mode 100644 source3/modules/gpfs.c (limited to 'source3/modules/gpfs.c') diff --git a/source3/modules/gpfs.c b/source3/modules/gpfs.c new file mode 100644 index 0000000000..f63a85294b --- /dev/null +++ b/source3/modules/gpfs.c @@ -0,0 +1,231 @@ +/* + * Unix SMB/CIFS implementation. + * Provide a connection to GPFS specific features + * Copyright (C) Volker Lendecke 2005 + * + * 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 2 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, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#include "includes.h" + +#ifdef HAVE_GPFS + +#include "gpfs_gpl.h" + +static void *libgpfs_handle = NULL; + +static int (*gpfs_set_share_fn)(int fd, unsigned int allow, unsigned int deny); +static int (*gpfs_set_lease_fn)(int fd, unsigned int leaseType); +static int (*gpfs_getacl_fn)(char *pathname, int flags, void *acl); +static int (*gpfs_putacl_fn)(char *pathname, int flags, void *acl); + + +BOOL set_gpfs_sharemode(files_struct *fsp, uint32 access_mask, + uint32 share_access) +{ + unsigned int allow = GPFS_SHARE_NONE; + unsigned int deny = GPFS_DENY_NONE; + int result; + + if (gpfs_set_share_fn == NULL) { + return False; + } + + if ((fsp == NULL) || (fsp->fh == NULL) || (fsp->fh->fd < 0)) { + /* No real file, don't disturb */ + return True; + } + + allow |= (access_mask & (FILE_WRITE_DATA|FILE_APPEND_DATA| + DELETE_ACCESS)) ? GPFS_SHARE_WRITE : 0; + allow |= (access_mask & (FILE_READ_DATA|FILE_EXECUTE)) ? + GPFS_SHARE_READ : 0; + deny |= (share_access & (FILE_SHARE_WRITE|FILE_SHARE_DELETE)) ? + 0 : GPFS_DENY_WRITE; + deny |= (share_access & (FILE_SHARE_READ)) ? + 0 : GPFS_DENY_READ; + + DEBUG(10, ("am=%x, allow=%d, sa=%x, deny=%d\n", + access_mask, allow, share_access, deny)); + + result = gpfs_set_share_fn(fsp->fh->fd, allow, deny); + if (result != 0) { + if (errno == ENOSYS) { + DEBUG(5, ("VFS module vfs_gpfs loaded, but no gpfs " + "support has been compiled into Samba. Allowing access\n")); + return True; + } else { + DEBUG(10, ("gpfs_set_share failed: %s\n", + strerror(errno))); + } + } + + return (result == 0); +} + +int set_gpfs_lease(int fd, int leasetype) +{ + int gpfs_type = GPFS_LEASE_NONE; + + if (gpfs_set_lease_fn == NULL) { + errno = EINVAL; + return -1; + } + + if (leasetype == F_RDLCK) { + gpfs_type = GPFS_LEASE_READ; + } + if (leasetype == F_WRLCK) { + gpfs_type = GPFS_LEASE_WRITE; + } + return gpfs_set_lease_fn(fd, gpfs_type); +} + +int smbd_gpfs_getacl(char *pathname, int flags, void *acl) +{ + if (gpfs_getacl_fn == NULL) { + errno = ENOSYS; + return -1; + } + + return gpfs_getacl_fn(pathname, flags, acl); +} + +int smbd_gpfs_putacl(char *pathname, int flags, void *acl) +{ + if (gpfs_putacl_fn == NULL) { + errno = ENOSYS; + return -1; + } + + return gpfs_putacl_fn(pathname, flags, acl); +} + +void init_gpfs(void) +{ + if (libgpfs_handle != NULL) { + return; + } + + libgpfs_handle = sys_dlopen("libgpfs_gpl.so", RTLD_LAZY); + + if (libgpfs_handle == NULL) { + DEBUG(10, ("sys_dlopen for libgpfs_gpl failed: %s\n", + strerror(errno))); + return; + } + + DEBUG(10, ("libgpfs_gpl.so loaded\n")); + + gpfs_set_share_fn = sys_dlsym(libgpfs_handle, "gpfs_set_share"); + if (gpfs_set_share_fn == NULL) { + DEBUG(3, ("libgpfs_gpl.so does not contain the symbol " + "'gpfs_set_share'\n")); + sys_dlclose(libgpfs_handle); + + /* leave libgpfs_handle != NULL around, no point + in trying twice */ + gpfs_set_share_fn = NULL; + gpfs_set_lease_fn = NULL; + gpfs_getacl_fn = NULL; + gpfs_putacl_fn = NULL; + return; + } + + gpfs_set_lease_fn = sys_dlsym(libgpfs_handle, "gpfs_set_lease"); + if (gpfs_set_lease_fn == NULL) { + DEBUG(3, ("libgpfs_gpl.so does not contain the symbol " + "'gpfs_set_lease'\n")); + sys_dlclose(libgpfs_handle); + + /* leave libgpfs_handle != NULL around, no point + in trying twice */ + gpfs_set_share_fn = NULL; + gpfs_set_lease_fn = NULL; + gpfs_getacl_fn = NULL; + gpfs_putacl_fn = NULL; + return; + } + + gpfs_getacl_fn = sys_dlsym(libgpfs_handle, "gpfs_getacl"); + if (gpfs_getacl_fn == NULL) { + DEBUG(3, ("libgpfs_gpl.so does not contain the symbol " + "'gpfs_getacl'\n")); + sys_dlclose(libgpfs_handle); + + /* leave libgpfs_handle != NULL around, no point + in trying twice */ + gpfs_set_share_fn = NULL; + gpfs_set_lease_fn = NULL; + gpfs_getacl_fn = NULL; + gpfs_putacl_fn = NULL; + return; + } + + gpfs_putacl_fn = sys_dlsym(libgpfs_handle, "gpfs_putacl"); + if (gpfs_putacl_fn == NULL) { + DEBUG(3, ("libgpfs_gpl.so does not contain the symbol " + "'gpfs_putacl'\n")); + sys_dlclose(libgpfs_handle); + + /* leave libgpfs_handle != NULL around, no point + in trying twice */ + gpfs_set_share_fn = NULL; + gpfs_set_lease_fn = NULL; + gpfs_getacl_fn = NULL; + gpfs_putacl_fn = NULL; + return; + } + +} + +#else + +int set_gpfs_lease(int snum, int leasetype) +{ + DEBUG(0, ("'VFS module smbgpfs loaded, without gpfs support compiled\n")); + + /* We need to indicate that no GPFS is around by returning ENOSYS, so + * that the normal linux kernel oplock code is called. */ + errno = ENOSYS; + return -1; +} + +BOOL set_gpfs_sharemode(files_struct *fsp, uint32 access_mask, + uint32 share_access) +{ + DEBUG(0, ("VFS module - smbgpfs.so loaded, without gpfs support compiled\n")); + /* Don't disturb but complain */ + return True; +} + +int smbd_gpfs_getacl(char *pathname, int flags, void *acl) +{ + errno = ENOSYS; + return -1; +} + +int smbd_gpfs_putacl(char *pathname, int flags, void *acl) +{ + errno = ENOSYS; + return -1; +} + +void init_gpfs(void) +{ + return; +} + +#endif /* HAVE_GPFS */ -- cgit From 700c3ab1c94fcd0ff422afa0e0e3faf419b3c5af Mon Sep 17 00:00:00 2001 From: Jim McDonough Date: Fri, 12 Jan 2007 21:56:25 +0000 Subject: r20717: Merge sharemode patch from Mathias Dietz . The patch fixes the behaviour of GPFS sharemodes when the access mask is no_access. (This used to be commit 799967c66879b4d6e28f1af6ba27c67f0b1deaeb) --- source3/modules/gpfs.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'source3/modules/gpfs.c') diff --git a/source3/modules/gpfs.c b/source3/modules/gpfs.c index f63a85294b..3fec7a479d 100644 --- a/source3/modules/gpfs.c +++ b/source3/modules/gpfs.c @@ -52,11 +52,16 @@ BOOL set_gpfs_sharemode(files_struct *fsp, uint32 access_mask, DELETE_ACCESS)) ? GPFS_SHARE_WRITE : 0; allow |= (access_mask & (FILE_READ_DATA|FILE_EXECUTE)) ? GPFS_SHARE_READ : 0; - deny |= (share_access & (FILE_SHARE_WRITE|FILE_SHARE_DELETE)) ? - 0 : GPFS_DENY_WRITE; - deny |= (share_access & (FILE_SHARE_READ)) ? - 0 : GPFS_DENY_READ; + if (allow == GPFS_SHARE_NONE) { + DEBUG(10, ("special case am=no_access:%x\n",access_mask)); + } + else { + deny |= (share_access & (FILE_SHARE_WRITE|FILE_SHARE_DELETE)) ? + 0 : GPFS_DENY_WRITE; + deny |= (share_access & (FILE_SHARE_READ)) ? + 0 : GPFS_DENY_READ; + } DEBUG(10, ("am=%x, allow=%d, sa=%x, deny=%d\n", access_mask, allow, share_access, deny)); -- cgit From 3f70efd4f97235272680bdb80dc3e52d0e56501b Mon Sep 17 00:00:00 2001 From: Jim McDonough Date: Wed, 24 Jan 2007 15:29:58 +0000 Subject: r21004: Patch from Mathias Dietz to fix multi-node sharemodes in gpfs. (This used to be commit 61841b225c2a09dcdb4b1242cb0ad0429ec1948e) --- source3/modules/gpfs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/modules/gpfs.c') diff --git a/source3/modules/gpfs.c b/source3/modules/gpfs.c index 3fec7a479d..19050ad3ca 100644 --- a/source3/modules/gpfs.c +++ b/source3/modules/gpfs.c @@ -57,7 +57,7 @@ BOOL set_gpfs_sharemode(files_struct *fsp, uint32 access_mask, DEBUG(10, ("special case am=no_access:%x\n",access_mask)); } else { - deny |= (share_access & (FILE_SHARE_WRITE|FILE_SHARE_DELETE)) ? + deny |= (share_access & FILE_SHARE_WRITE) ? 0 : GPFS_DENY_WRITE; deny |= (share_access & (FILE_SHARE_READ)) ? 0 : GPFS_DENY_READ; -- cgit From 00959280b2801d21a2e637023c8b3006c3d24ffd Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Tue, 29 May 2007 19:54:26 +0000 Subject: r23228: Merge cleanup to the gpfs module from Tridge. Also potentially disable gpfs share modes in special situations. This might be split up in several modules later. (This used to be commit 553fe9245165ce4a14902daa722935c94ff32d61) --- source3/modules/gpfs.c | 61 +++++++++++++++++++++++--------------------------- 1 file changed, 28 insertions(+), 33 deletions(-) (limited to 'source3/modules/gpfs.c') diff --git a/source3/modules/gpfs.c b/source3/modules/gpfs.c index 19050ad3ca..d274984ec7 100644 --- a/source3/modules/gpfs.c +++ b/source3/modules/gpfs.c @@ -25,6 +25,7 @@ #include "gpfs_gpl.h" static void *libgpfs_handle = NULL; +static BOOL gpfs_share_modes; static int (*gpfs_set_share_fn)(int fd, unsigned int allow, unsigned int deny); static int (*gpfs_set_lease_fn)(int fd, unsigned int leaseType); @@ -39,6 +40,10 @@ 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; } @@ -84,6 +89,10 @@ int set_gpfs_lease(int fd, int leasetype) { int gpfs_type = GPFS_LEASE_NONE; + if (!gpfs_share_modes) { + return True; + } + if (gpfs_set_lease_fn == NULL) { errno = EINVAL; return -1; @@ -138,15 +147,7 @@ void init_gpfs(void) if (gpfs_set_share_fn == NULL) { DEBUG(3, ("libgpfs_gpl.so does not contain the symbol " "'gpfs_set_share'\n")); - sys_dlclose(libgpfs_handle); - - /* leave libgpfs_handle != NULL around, no point - in trying twice */ - gpfs_set_share_fn = NULL; - gpfs_set_lease_fn = NULL; - gpfs_getacl_fn = NULL; - gpfs_putacl_fn = NULL; - return; + goto failed; } gpfs_set_lease_fn = sys_dlsym(libgpfs_handle, "gpfs_set_lease"); @@ -155,45 +156,39 @@ void init_gpfs(void) "'gpfs_set_lease'\n")); sys_dlclose(libgpfs_handle); - /* leave libgpfs_handle != NULL around, no point - in trying twice */ - gpfs_set_share_fn = NULL; - gpfs_set_lease_fn = NULL; - gpfs_getacl_fn = NULL; - gpfs_putacl_fn = NULL; - return; + goto failed; } gpfs_getacl_fn = sys_dlsym(libgpfs_handle, "gpfs_getacl"); if (gpfs_getacl_fn == NULL) { DEBUG(3, ("libgpfs_gpl.so does not contain the symbol " "'gpfs_getacl'\n")); - sys_dlclose(libgpfs_handle); - - /* leave libgpfs_handle != NULL around, no point - in trying twice */ - gpfs_set_share_fn = NULL; - gpfs_set_lease_fn = NULL; - gpfs_getacl_fn = NULL; - gpfs_putacl_fn = NULL; - return; + goto failed; } gpfs_putacl_fn = sys_dlsym(libgpfs_handle, "gpfs_putacl"); if (gpfs_putacl_fn == NULL) { DEBUG(3, ("libgpfs_gpl.so does not contain the symbol " "'gpfs_putacl'\n")); - sys_dlclose(libgpfs_handle); + goto failed; + } - /* leave libgpfs_handle != NULL around, no point - in trying twice */ - gpfs_set_share_fn = NULL; - gpfs_set_lease_fn = NULL; - gpfs_getacl_fn = NULL; - gpfs_putacl_fn = NULL; - return; + if (lp_parm_bool(-1, "gpfs", "sharemodes", True)) { + gpfs_share_modes = True; + } else { + gpfs_share_modes = False; } + return; + +failed: + sys_dlclose(libgpfs_handle); + /* leave libgpfs_handle != NULL around, no point + in trying twice */ + gpfs_set_share_fn = NULL; + gpfs_set_lease_fn = NULL; + gpfs_getacl_fn = NULL; + gpfs_putacl_fn = NULL; } #else -- cgit From d824b98f80ba186030cbb70b3a1e5daf80469ecd Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Mon, 9 Jul 2007 19:25:36 +0000 Subject: r23779: Change from v2 or later to v3 or later. Jeremy. (This used to be commit 407e6e695b8366369b7c76af1ff76869b45347b3) --- source3/modules/gpfs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/modules/gpfs.c') diff --git a/source3/modules/gpfs.c b/source3/modules/gpfs.c index d274984ec7..90be778260 100644 --- a/source3/modules/gpfs.c +++ b/source3/modules/gpfs.c @@ -5,7 +5,7 @@ * * 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 2 of the License, or + * 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, -- cgit From 153cfb9c83534b09f15cc16205d7adb19b394928 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 10 Jul 2007 05:23:25 +0000 Subject: r23801: The FSF has moved around a lot. This fixes their Mass Ave address. (This used to be commit 87c91e4362c51819032bfbebbb273c52e203b227) --- source3/modules/gpfs.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'source3/modules/gpfs.c') diff --git a/source3/modules/gpfs.c b/source3/modules/gpfs.c index 90be778260..86ba2d81a6 100644 --- a/source3/modules/gpfs.c +++ b/source3/modules/gpfs.c @@ -14,8 +14,7 @@ * 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, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * along with this program; if not, see . */ #include "includes.h" -- cgit From 30191d1a5704ad2b158386b511558972d539ce47 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Thu, 18 Oct 2007 17:40:25 -0700 Subject: RIP BOOL. Convert BOOL -> bool. I found a few interesting bugs in various places whilst doing this (places that assumed BOOL == int). I also need to fix the Samba4 pidl generation (next checkin). Jeremy. (This used to be commit f35a266b3cbb3e5fa6a86be60f34fe340a3ca71f) --- source3/modules/gpfs.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'source3/modules/gpfs.c') diff --git a/source3/modules/gpfs.c b/source3/modules/gpfs.c index 86ba2d81a6..300e90fa69 100644 --- a/source3/modules/gpfs.c +++ b/source3/modules/gpfs.c @@ -24,7 +24,7 @@ #include "gpfs_gpl.h" static void *libgpfs_handle = NULL; -static BOOL gpfs_share_modes; +static bool gpfs_share_modes; static int (*gpfs_set_share_fn)(int fd, unsigned int allow, unsigned int deny); static int (*gpfs_set_lease_fn)(int fd, unsigned int leaseType); @@ -32,7 +32,7 @@ static int (*gpfs_getacl_fn)(char *pathname, int flags, void *acl); static int (*gpfs_putacl_fn)(char *pathname, int flags, void *acl); -BOOL set_gpfs_sharemode(files_struct *fsp, uint32 access_mask, +bool set_gpfs_sharemode(files_struct *fsp, uint32 access_mask, uint32 share_access) { unsigned int allow = GPFS_SHARE_NONE; @@ -202,7 +202,7 @@ int set_gpfs_lease(int snum, int leasetype) return -1; } -BOOL set_gpfs_sharemode(files_struct *fsp, uint32 access_mask, +bool set_gpfs_sharemode(files_struct *fsp, uint32 access_mask, uint32 share_access) { DEBUG(0, ("VFS module - smbgpfs.so loaded, without gpfs support compiled\n")); -- cgit From 313f7d10b884d083ef9488db739465c54c3f6515 Mon Sep 17 00:00:00 2001 From: Alexander Bokovoy Date: Wed, 16 Jan 2008 12:18:57 +0300 Subject: Merge latest fixes to vfs_gpfs and NFS4 ACLs from Samba 3.0 CTDB branch (from http://samba.org/~tridge/3_0-ctdb) Signed-off-by: Alexander Bokovoy (This used to be commit 1daad835cbfb4615a8fe7a241f4d578f7e69f214) --- source3/modules/gpfs.c | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) (limited to 'source3/modules/gpfs.c') diff --git a/source3/modules/gpfs.c b/source3/modules/gpfs.c index 300e90fa69..590dbac26f 100644 --- a/source3/modules/gpfs.c +++ b/source3/modules/gpfs.c @@ -22,9 +22,11 @@ #ifdef HAVE_GPFS #include "gpfs_gpl.h" +#include "vfs_gpfs.h" static void *libgpfs_handle = NULL; static bool gpfs_share_modes; +static bool gpfs_leases; static int (*gpfs_set_share_fn)(int fd, unsigned int allow, unsigned int deny); static int (*gpfs_set_lease_fn)(int fd, unsigned int leaseType); @@ -42,7 +44,7 @@ bool set_gpfs_sharemode(files_struct *fsp, uint32 access_mask, if (!gpfs_share_modes) { return True; } - + if (gpfs_set_share_fn == NULL) { return False; } @@ -88,7 +90,7 @@ int set_gpfs_lease(int fd, int leasetype) { int gpfs_type = GPFS_LEASE_NONE; - if (!gpfs_share_modes) { + if (!gpfs_leases) { return True; } @@ -103,6 +105,13 @@ int set_gpfs_lease(int fd, int leasetype) if (leasetype == F_WRLCK) { gpfs_type = GPFS_LEASE_WRITE; } + + /* we unconditionally set CAP_LEASE, rather than looking for + -1/EACCES as there is a bug in some versions of + libgpfs_gpl.so which results in a leaked fd on /dev/ss0 + each time we try this with the wrong capabilities set + */ + linux_set_lease_capability(); return gpfs_set_lease_fn(fd, gpfs_type); } @@ -172,11 +181,8 @@ void init_gpfs(void) goto failed; } - if (lp_parm_bool(-1, "gpfs", "sharemodes", True)) { - gpfs_share_modes = True; - } else { - gpfs_share_modes = False; - } + gpfs_share_modes = lp_parm_bool(-1, "gpfs", "sharemodes", True); + gpfs_leases = lp_parm_bool(-1, "gpfs", "leases", True); return; -- cgit