Author: jmcd Date: 2006-11-10 15:40:48 +0000 (Fri, 10 Nov 2006) New Revision: 19654
WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=19654 Log: merge GPFS vfs support from 3.0, including adding kernel_flock vfs op. Modified: branches/SAMBA_3_0_24/source/Makefile.in branches/SAMBA_3_0_24/source/configure.in branches/SAMBA_3_0_24/source/include/smbprofile.h branches/SAMBA_3_0_24/source/include/vfs.h branches/SAMBA_3_0_24/source/include/vfs_macros.h branches/SAMBA_3_0_24/source/lib/system.c branches/SAMBA_3_0_24/source/smbd/open.c branches/SAMBA_3_0_24/source/smbd/vfs-wrap.c branches/SAMBA_3_0_24/source/smbd/vfs.c Changeset: Modified: branches/SAMBA_3_0_24/source/Makefile.in =================================================================== --- branches/SAMBA_3_0_24/source/Makefile.in 2006-11-10 15:28:44 UTC (rev 19653) +++ branches/SAMBA_3_0_24/source/Makefile.in 2006-11-10 15:40:48 UTC (rev 19654) @@ -374,6 +374,7 @@ VFS_SHADOW_COPY_OBJ = modules/vfs_shadow_copy.o VFS_AFSACL_OBJ = modules/vfs_afsacl.o VFS_CATIA_OBJ = modules/vfs_catia.o +VFS_GPFS_OBJ = modules/vfs_gpfs.o modules/gpfs.o PLAINTEXT_AUTH_OBJ = auth/pampass.o auth/pass_check.o @@ -1373,6 +1374,10 @@ @$(SHLD) $(LDSHFLAGS) -o $@ $(VFS_CATIA_OBJ:[EMAIL PROTECTED]@) \ @[EMAIL PROTECTED] [EMAIL PROTECTED] +bin/[EMAIL PROTECTED]@: $(VFS_GPFS_OBJ) + @echo "Building plugin $@" + @$(SHLD) $(LDSHFLAGS) -o $@ $(VFS_GPFS_OBJ) \ + @[EMAIL PROTECTED] [EMAIL PROTECTED] bin/[EMAIL PROTECTED]@: $(WBINFO_OBJ) @BUILD_POPT@ bin/.dummy @echo Linking $@ Modified: branches/SAMBA_3_0_24/source/configure.in =================================================================== --- branches/SAMBA_3_0_24/source/configure.in 2006-11-10 15:28:44 UTC (rev 19653) +++ branches/SAMBA_3_0_24/source/configure.in 2006-11-10 15:40:48 UTC (rev 19654) @@ -1286,6 +1286,20 @@ AC_CHECK_FUNCS(backtrace_symbols) AC_CHECK_LIB(exc, trace_back_stack) +echo -n "checking for GPFS GPL libs... " +save_LIBS="$LIBS" +LIBS="$LIBS -lgpfs_gpl" +AC_TRY_LINK([#include <gpfs_gpl.h>], + [gpfs_set_share(0,GPFS_SHARE_READ,GPFS_DENY_NONE)], + samba_cv_HAVE_GPFS=yes, + samba_cv_HAVE_GPFS=no) +echo $samba_cv_HAVE_GPFS +if test x"$samba_cv_HAVE_GPFS" = x"yes"; then + AC_DEFINE(HAVE_GPFS,1,[Whether GPFS GPL libs are available]) + default_shared_modules="$default_shared_modules vfs_gpfs" +fi +LIBS="$save_LIBS" + # Note that all the libunwind symbols in the API are defined to internal # platform-specific version, so we must include libunwind.h before checking # any of them. @@ -5598,6 +5612,7 @@ SMB_MODULE(vfs_shadow_copy, \$(VFS_SHADOW_COPY_OBJ), "bin/shadow_copy.$SHLIBEXT", VFS) SMB_MODULE(vfs_afsacl, \$(VFS_AFSACL_OBJ), "bin/afsacl.$SHLIBEXT", VFS) SMB_MODULE(vfs_catia, \$(VFS_CATIA_OBJ), "bin/catia.$SHLIBEXT", VFS) +SMB_MODULE(vfs_gpfs, \$(VFS_GPFS_OBJ), "bin/gpfs.$SHLIBEXT", VFS) SMB_SUBSYSTEM(VFS,smbd/vfs.o) AC_DEFINE_UNQUOTED(STRING_STATIC_MODULES, "$string_static_modules", [String list of builtin modules]) Modified: branches/SAMBA_3_0_24/source/include/smbprofile.h =================================================================== --- branches/SAMBA_3_0_24/source/include/smbprofile.h 2006-11-10 15:28:44 UTC (rev 19653) +++ branches/SAMBA_3_0_24/source/include/smbprofile.h 2006-11-10 15:40:48 UTC (rev 19654) @@ -101,6 +101,8 @@ unsigned syscall_ftruncate_count; unsigned syscall_ftruncate_time; unsigned syscall_fcntl_lock_count; + unsigned syscall_kernel_flock_count; + unsigned syscall_kernel_flock_time; unsigned syscall_fcntl_lock_time; unsigned syscall_fcntl_getlock_count; unsigned syscall_fcntl_getlock_time; Modified: branches/SAMBA_3_0_24/source/include/vfs.h =================================================================== --- branches/SAMBA_3_0_24/source/include/vfs.h 2006-11-10 15:28:44 UTC (rev 19653) +++ branches/SAMBA_3_0_24/source/include/vfs.h 2006-11-10 15:40:48 UTC (rev 19654) @@ -142,6 +142,7 @@ SMB_VFS_OP_UTIME, SMB_VFS_OP_FTRUNCATE, SMB_VFS_OP_LOCK, + SMB_VFS_OP_KERNEL_FLOCK, SMB_VFS_OP_GETLOCK, SMB_VFS_OP_SYMLINK, SMB_VFS_OP_READLINK, @@ -264,6 +265,7 @@ int (*utime)(struct vfs_handle_struct *handle, struct connection_struct *conn, const char *path, struct utimbuf *times); int (*ftruncate)(struct vfs_handle_struct *handle, struct files_struct *fsp, int fd, SMB_OFF_T offset); BOOL (*lock)(struct vfs_handle_struct *handle, struct files_struct *fsp, int fd, int op, SMB_OFF_T offset, SMB_OFF_T count, int type); + int (*kernel_flock)(struct vfs_handle_struct *handle, struct files_struct *fsp, int fd, uint32 share_mode); BOOL (*getlock)(struct vfs_handle_struct *handle, struct files_struct *fsp, int fd, SMB_OFF_T *poffset, SMB_OFF_T *pcount, int *ptype, pid_t *ppid); int (*symlink)(struct vfs_handle_struct *handle, struct connection_struct *conn, const char *oldpath, const char *newpath); int (*readlink)(struct vfs_handle_struct *handle, struct connection_struct *conn, const char *path, char *buf, size_t bufsiz); @@ -378,6 +380,7 @@ struct vfs_handle_struct *utime; struct vfs_handle_struct *ftruncate; struct vfs_handle_struct *lock; + struct vfs_handle_struct *kernel_flock; struct vfs_handle_struct *getlock; struct vfs_handle_struct *symlink; struct vfs_handle_struct *readlink; Modified: branches/SAMBA_3_0_24/source/include/vfs_macros.h =================================================================== --- branches/SAMBA_3_0_24/source/include/vfs_macros.h 2006-11-10 15:28:44 UTC (rev 19653) +++ branches/SAMBA_3_0_24/source/include/vfs_macros.h 2006-11-10 15:40:48 UTC (rev 19654) @@ -70,6 +70,7 @@ #define SMB_VFS_UTIME(conn, path, times) ((conn)->vfs.ops.utime((conn)->vfs.handles.utime, (conn), (path), (times))) #define SMB_VFS_FTRUNCATE(fsp, fd, offset) ((fsp)->conn->vfs.ops.ftruncate((fsp)->conn->vfs.handles.ftruncate, (fsp), (fd), (offset))) #define SMB_VFS_LOCK(fsp, fd, op, offset, count, type) ((fsp)->conn->vfs.ops.lock((fsp)->conn->vfs.handles.lock, (fsp), (fd) ,(op), (offset), (count), (type))) +#define SMB_VFS_KERNEL_FLOCK(fsp, fd, share_mode) ((fsp)->conn->vfs.ops.kernel_flock((fsp)->conn->vfs.handles.kernel_flock, (fsp), (fd), (share_mode))) #define SMB_VFS_GETLOCK(fsp, fd, poffset, pcount, ptype, ppid) ((fsp)->conn->vfs.ops.getlock((fsp)->conn->vfs.handles.getlock, (fsp), (fd) ,(poffset), (pcount), (ptype), (ppid))) #define SMB_VFS_SYMLINK(conn, oldpath, newpath) ((conn)->vfs.ops.symlink((conn)->vfs.handles.symlink, (conn), (oldpath), (newpath))) #define SMB_VFS_READLINK(conn, path, buf, bufsiz) ((conn)->vfs.ops.readlink((conn)->vfs.handles.readlink, (conn), (path), (buf), (bufsiz))) @@ -182,6 +183,7 @@ #define SMB_VFS_OPAQUE_UTIME(conn, path, times) ((conn)->vfs_opaque.ops.utime((conn)->vfs_opaque.handles.utime, (conn), (path), (times))) #define SMB_VFS_OPAQUE_FTRUNCATE(fsp, fd, offset) ((fsp)->conn->vfs_opaque.ops.ftruncate((fsp)->conn->vfs_opaque.handles.ftruncate, (fsp), (fd), (offset))) #define SMB_VFS_OPAQUE_LOCK(fsp, fd, op, offset, count, type) ((fsp)->conn->vfs_opaque.ops.lock((fsp)->conn->vfs_opaque.handles.lock, (fsp), (fd) ,(op), (offset), (count), (type))) +#define SMB_VFS_OPAQUE_FLOCK(fsp, fd, share_mode) ((fsp)->conn->vfs_opaque.ops.lock((fsp)->conn->vfs_opaque.handles.kernel_flock, (fsp), (fd), (share_mode))) #define SMB_VFS_OPAQUE_GETLOCK(fsp, fd, poffset, pcount, ptype, ppid) ((fsp)->conn->vfs_opaque.ops.getlock((fsp)->conn->vfs_opaque.handles.getlock, (fsp), (fd), (poffset), (pcount), (ptype), (ppid))) #define SMB_VFS_OPAQUE_SYMLINK(conn, oldpath, newpath) ((conn)->vfs_opaque.ops.symlink((conn)->vfs_opaque.handles.symlink, (conn), (oldpath), (newpath))) #define SMB_VFS_OPAQUE_READLINK(conn, path, buf, bufsiz) ((conn)->vfs_opaque.ops.readlink((conn)->vfs_opaque.handles.readlink, (conn), (path), (buf), (bufsiz))) @@ -295,6 +297,7 @@ #define SMB_VFS_NEXT_UTIME(handle, conn, path, times) ((handle)->vfs_next.ops.utime((handle)->vfs_next.handles.utime, (conn), (path), (times))) #define SMB_VFS_NEXT_FTRUNCATE(handle, fsp, fd, offset) ((handle)->vfs_next.ops.ftruncate((handle)->vfs_next.handles.ftruncate, (fsp), (fd), (offset))) #define SMB_VFS_NEXT_LOCK(handle, fsp, fd, op, offset, count, type) ((handle)->vfs_next.ops.lock((handle)->vfs_next.handles.lock, (fsp), (fd) ,(op), (offset), (count), (type))) +#define SMB_VFS_NEXT_KERNEL_FLOCK(handle, fsp, fd, share_mode)((handle)->vfs_next.ops.lock((handle)->vfs_next.handles.kernel_flock, (fsp), (fd), (share_mode))) #define SMB_VFS_NEXT_GETLOCK(handle, fsp, fd, poffset, pcount, ptype, ppid) ((handle)->vfs_next.ops.getlock((handle)->vfs_next.handles.getlock, (fsp), (fd), (poffset), (pcount), (ptype), (ppid))) #define SMB_VFS_NEXT_SYMLINK(handle, conn, oldpath, newpath) ((handle)->vfs_next.ops.symlink((handle)->vfs_next.handles.symlink, (conn), (oldpath), (newpath))) #define SMB_VFS_NEXT_READLINK(handle, conn, path, buf, bufsiz) ((handle)->vfs_next.ops.readlink((handle)->vfs_next.handles.readlink, (conn), (path), (buf), (bufsiz))) Modified: branches/SAMBA_3_0_24/source/lib/system.c =================================================================== --- branches/SAMBA_3_0_24/source/lib/system.c 2006-11-10 15:28:44 UTC (rev 19653) +++ branches/SAMBA_3_0_24/source/lib/system.c 2006-11-10 15:40:48 UTC (rev 19654) @@ -367,6 +367,28 @@ } /******************************************************************* + A flock() wrapper that will perform the kernel flock. +********************************************************************/ + +void kernel_flock(int fd, uint32 share_mode) +{ +#if HAVE_KERNEL_SHARE_MODES + int kernel_mode = 0; + if (share_mode == FILE_SHARE_WRITE) { + kernel_mode = LOCK_MAND|LOCK_WRITE; + } else if (share_mode == FILE_SHARE_READ) { + kernel_mode = LOCK_MAND|LOCK_READ; + } else if (share_mode == FILE_SHARE_NONE) { + kernel_mode = LOCK_MAND; + } + if (kernel_mode) { + flock(fd, kernel_mode); + } +#endif + ; +} + +/******************************************************************* An opendir wrapper that will deal with 64 bit filesizes. ********************************************************************/ Modified: branches/SAMBA_3_0_24/source/smbd/open.c =================================================================== --- branches/SAMBA_3_0_24/source/smbd/open.c 2006-11-10 15:28:44 UTC (rev 19653) +++ branches/SAMBA_3_0_24/source/smbd/open.c 2006-11-10 15:40:48 UTC (rev 19654) @@ -774,29 +774,6 @@ } /**************************************************************************** - Set a kernel flock on a file for NFS interoperability. - This requires a patch to Linux. -****************************************************************************/ - -static void kernel_flock(files_struct *fsp, uint32 share_mode) -{ -#if HAVE_KERNEL_SHARE_MODES - int kernel_mode = 0; - if (share_mode == FILE_SHARE_WRITE) { - kernel_mode = LOCK_MAND|LOCK_WRITE; - } else if (share_mode == FILE_SHARE_READ) { - kernel_mode = LOCK_MAND|LOCK_READ; - } else if (share_mode == FILE_SHARE_NONE) { - kernel_mode = LOCK_MAND; - } - if (kernel_mode) { - flock(fsp->fh->fd, kernel_mode); - } -#endif - ; -} - -/**************************************************************************** On overwrite open ensure that the attributes match. ****************************************************************************/ @@ -1115,7 +1092,9 @@ struct share_mode_lock *lck = NULL; uint32 open_access_mask = access_mask; NTSTATUS status; + int ret_flock; + if (conn->printer) { /* * Printers are handled completely differently. @@ -1631,10 +1610,21 @@ these only read them. Nobody but Samba can ever set a deny mode and we have already checked our more authoritative locking database for permission to set this deny mode. If - the kernel refuses the operations then the kernel is wrong */ + the kernel refuses the operations then the kernel is wrong. + note that GPFS supports it as well - jmcd */ - kernel_flock(fsp, share_access); + ret_flock = SMB_VFS_KERNEL_FLOCK(fsp, fsp->fh->fd, share_access); + if(ret_flock == -1 ){ + talloc_free(lck); + fd_close(conn, fsp); + file_free(fsp); + + set_saved_ntstatus(NT_STATUS_SHARING_VIOLATION); + return NULL; + } + + /* * At this point onwards, we can guarentee that the share entry * is locked, whether we created the file or not, and that the Modified: branches/SAMBA_3_0_24/source/smbd/vfs-wrap.c =================================================================== --- branches/SAMBA_3_0_24/source/smbd/vfs-wrap.c 2006-11-10 15:28:44 UTC (rev 19653) +++ branches/SAMBA_3_0_24/source/smbd/vfs-wrap.c 2006-11-10 15:40:48 UTC (rev 19654) @@ -764,6 +764,15 @@ return result; } +int vfswrap_kernel_flock(vfs_handle_struct *handle, files_struct *fsp, + int fd, uint32 share_mode) +{ + START_PROFILE(syscall_kernel_flock); + kernel_flock(fd, share_mode); + END_PROFILE(syscall_kernel_flock); + return 0; +} + BOOL vfswrap_getlock(vfs_handle_struct *handle, files_struct *fsp, int fd, SMB_OFF_T *poffset, SMB_OFF_T *pcount, int *ptype, pid_t *ppid) { BOOL result; Modified: branches/SAMBA_3_0_24/source/smbd/vfs.c =================================================================== --- branches/SAMBA_3_0_24/source/smbd/vfs.c 2006-11-10 15:28:44 UTC (rev 19653) +++ branches/SAMBA_3_0_24/source/smbd/vfs.c 2006-11-10 15:40:48 UTC (rev 19654) @@ -97,6 +97,7 @@ vfswrap_utime, vfswrap_ftruncate, vfswrap_lock, + vfswrap_kernel_flock, vfswrap_getlock, vfswrap_symlink, vfswrap_readlink,