The branch, master has been updated
       via  4ff13c01746 vfs_gpfs: Update message for requesting sharemode on 
stream
       via  5c20ef88ab0 vfs_gpfs: Log failed gpfs_set_share call as error
       via  47a2c6707b2 vfs_gpfs: Print message when share modes are disabled 
in file system
       via  191e375d207 vfs_gpfs: Explicitly log when share mode has been denied
       via  a64978e0dc0 vfs_gpfs: Use early return in sharemode function
       via  03705f4c2fb vfs_gpfs: Switch share mode helper function to return 
int
       via  f03c4485a2e vfs_gpfs: Remove logging for unsupported file system
       via  ef52a907fe8 vfs_gpfs: Only clear sharemode on close when sharemode 
has been taken
       via  c993480eeff vfs_gpfs: Log error if clearing of sharemode fails on 
close
       via  d9128955901 vfs_gpfs: Add comment explaining why sharemode is 
dropped in close call.
       via  56cf9b15f0a vfs_gpfs: Remove unncessary check from close function
       via  5d5763ea8ce vfs_gpfs: Cleanup debug message file system share mode
       via  eff66787c64 vfs_gpfs: Cleanup clearing file system share mode
       via  79a50e75b24 vfs_gpfs: Move mapping to sharemode deny to helper 
function
       via  05c54b72c5a vfs_gpfs: Move mapping from access mask to sharemode 
allow to helper function
       via  208007b86c4 vfs_gpfs: Remove check for open file in share mode 
function
       via  00fb46c7f2f vfs_time_audit: Rename argument of flock function
       via  b306a7361e9 vfs_streams_xattr: Rename argument of flock function
       via  86c2578a555 vfs_gpfs: Rename argument of flock function
       via  0d5794f6f92 vfs_glusterfs: Rename argument of flock function
       via  4667399457f vfs_full_audit: Rename argument of flock function
       via  83f59ac00e9 vfs_ceph: Rename argument for flock function
       via  537d226ed93 vfs_catia: Rename argument for flock function
       via  974aae418f6 vfs_not_implemented: Rename argument for flock function
       via  e8d9a21435a vfs: Rename argument for kernel_flock function
       via  ad8e6863c37 system: Rename argument for kernel_flock function
      from  7f75dec8652 auth: Simplify struct auth4_context

https://git.samba.org/?p=samba.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit 4ff13c0174605e45d7d3b26fbb4226d9613b1c98
Author: Christof Schmitt <[email protected]>
Date:   Mon Jan 6 16:08:56 2020 -0700

    vfs_gpfs: Update message for requesting sharemode on stream
    
    User newer debug macro and print full path to affected file.
    
    Signed-off-by: Christof Schmitt <[email protected]>
    Reviewed-by: Jeremy Allison <[email protected]>
    
    Autobuild-User(master): Jeremy Allison <[email protected]>
    Autobuild-Date(master): Wed Jan  8 01:26:46 UTC 2020 on sn-devel-184

commit 5c20ef88ab07f52b7354668873c5d51b58748d12
Author: Christof Schmitt <[email protected]>
Date:   Mon Jan 6 14:52:14 2020 -0700

    vfs_gpfs: Log failed gpfs_set_share call as error
    
    Any other error code from gpfs_set_share should never happen. Print a
    error message in case this is ever encountered.
    
    Signed-off-by: Christof Schmitt <[email protected]>
    Reviewed-by: Jeremy Allison <[email protected]>

commit 47a2c6707b2f9a9c42673629b82640122c53a609
Author: Christof Schmitt <[email protected]>
Date:   Mon Jan 6 14:49:39 2020 -0700

    vfs_gpfs: Print message when share modes are disabled in file system
    
    GPFS file systems can be configured without support for share modes. As
    this results in an unique error code, print a message explaining this
    situation and the required config changes.
    
    Signed-off-by: Christof Schmitt <[email protected]>
    Reviewed-by: Jeremy Allison <[email protected]>

commit 191e375d2071de5e44110155230da7e0c4b64d54
Author: Christof Schmitt <[email protected]>
Date:   Mon Jan 6 14:42:05 2020 -0700

    vfs_gpfs: Explicitly log when share mode has been denied
    
    As this denies access to a file, provide a better error message for
    easier troubleshooting.
    
    Signed-off-by: Christof Schmitt <[email protected]>
    Reviewed-by: Jeremy Allison <[email protected]>

commit a64978e0dc006b9b14541c60379d61e170355468
Author: Christof Schmitt <[email protected]>
Date:   Mon Jan 6 14:40:07 2020 -0700

    vfs_gpfs: Use early return in sharemode function
    
    This removes one level of indentation.
    
    Signed-off-by: Christof Schmitt <[email protected]>
    Reviewed-by: Jeremy Allison <[email protected]>

commit 03705f4c2fbac6534a925d7511749d4daa378b2e
Author: Christof Schmitt <[email protected]>
Date:   Mon Jan 6 14:25:22 2020 -0700

    vfs_gpfs: Switch share mode helper function to return int
    
    Follow the convention to return 0 on success and -1 when hitting an
    error.
    
    Signed-off-by: Christof Schmitt <[email protected]>
    Reviewed-by: Jeremy Allison <[email protected]>

commit f03c4485a2e50d496875fb157d5405e2afa7a0f5
Author: Christof Schmitt <[email protected]>
Date:   Mon Jan 6 14:23:41 2020 -0700

    vfs_gpfs: Remove logging for unsupported file system
    
    The gpfs_set_share API call has been around for a long time and
    definitely all supported GPFS versions have it. Remove the check and
    fallback for old versions without this API.
    
    Signed-off-by: Christof Schmitt <[email protected]>
    Reviewed-by: Jeremy Allison <[email protected]>

commit ef52a907fe80fdb1cd199a21a68126a7bf9b33cb
Author: Christof Schmitt <[email protected]>
Date:   Mon Jan 6 14:14:17 2020 -0700

    vfs_gpfs: Only clear sharemode on close when sharemode has been taken
    
    This avoids a redundant error message in case the call to acquire the
    sharemode had failed before.
    
    Signed-off-by: Christof Schmitt <[email protected]>
    Reviewed-by: Jeremy Allison <[email protected]>

commit c993480eeff7ff6aee7c4f90f103dcb8d1cd3c6f
Author: Christof Schmitt <[email protected]>
Date:   Mon Jan 6 14:07:29 2020 -0700

    vfs_gpfs: Log error if clearing of sharemode fails on close
    
    Signed-off-by: Christof Schmitt <[email protected]>
    Reviewed-by: Jeremy Allison <[email protected]>

commit d912895590170bdd8c720304c664a2259d6a9228
Author: Christof Schmitt <[email protected]>
Date:   Mon Jan 6 14:00:32 2020 -0700

    vfs_gpfs: Add comment explaining why sharemode is dropped in close call.
    
    Signed-off-by: Christof Schmitt <[email protected]>
    Reviewed-by: Jeremy Allison <[email protected]>

commit 56cf9b15f0a42323d94a407a4de7fae9b039a326
Author: Christof Schmitt <[email protected]>
Date:   Mon Jan 6 13:53:13 2020 -0700

    vfs_gpfs: Remove unncessary check from close function
    
    The fsp has a valid file descriptor when this function is called. No
    need for the additional check.
    
    Signed-off-by: Christof Schmitt <[email protected]>
    Reviewed-by: Jeremy Allison <[email protected]>

commit 5d5763ea8ce14f81107462e7f2dff09b6aec1fbc
Author: Christof Schmitt <[email protected]>
Date:   Fri Jan 3 12:56:07 2020 -0700

    vfs_gpfs: Cleanup debug message file system share mode
    
    Use the newer debug macro and the full variable names.
    
    Signed-off-by: Christof Schmitt <[email protected]>
    Reviewed-by: Jeremy Allison <[email protected]>

commit eff66787c646e6ce6375929f7d61e9f1b5a0e202
Author: Christof Schmitt <[email protected]>
Date:   Fri Jan 3 11:40:50 2020 -0700

    vfs_gpfs: Cleanup clearing file system share mode
    
    The VFS flock function is called with a zero access_mask to indicate
    that the share mode should be cleared. Adjust the check to directly
    check the access_mask and provide a better message to indicate this
    case.
    
    Signed-off-by: Christof Schmitt <[email protected]>
    Reviewed-by: Jeremy Allison <[email protected]>

commit 79a50e75b24e7c236f7a5422c7676d45bbe93365
Author: Christof Schmitt <[email protected]>
Date:   Mon Dec 30 15:39:43 2019 -0700

    vfs_gpfs: Move mapping to sharemode deny to helper function
    
    Signed-off-by: Christof Schmitt <[email protected]>
    Reviewed-by: Jeremy Allison <[email protected]>

commit 05c54b72c5ad3c8bce18f9a38413032e5224e644
Author: Christof Schmitt <[email protected]>
Date:   Mon Dec 30 15:33:03 2019 -0700

    vfs_gpfs: Move mapping from access mask to sharemode allow to helper 
function
    
    Signed-off-by: Christof Schmitt <[email protected]>
    Reviewed-by: Jeremy Allison <[email protected]>

commit 208007b86c407e98a796dfae30affade05abe4f7
Author: Christof Schmitt <[email protected]>
Date:   Mon Dec 30 15:20:05 2019 -0700

    vfs_gpfs: Remove check for open file in share mode function
    
    The calling code already ensures that the file is open with a valid file
    descriptor.
    
    Signed-off-by: Christof Schmitt <[email protected]>
    Reviewed-by: Jeremy Allison <[email protected]>

commit 00fb46c7f2f678aa601e4def2b53702d6fabf2e5
Author: Christof Schmitt <[email protected]>
Date:   Fri Jan 3 12:52:48 2020 -0700

    vfs_time_audit: Rename argument of flock function
    
    MS-SMB2 and the smbd code refer to this field as share_access. Use the
    same name in the function argument.
    
    Signed-off-by: Christof Schmitt <[email protected]>
    Reviewed-by: Jeremy Allison <[email protected]>

commit b306a7361e9d8e2f50f87e8904fc622da799864e
Author: Christof Schmitt <[email protected]>
Date:   Fri Jan 3 12:51:17 2020 -0700

    vfs_streams_xattr: Rename argument of flock function
    
    MS-SMB2 and the smbd code refer to this field as share_access. Use the
    same name in the function argument.
    
    Signed-off-by: Christof Schmitt <[email protected]>
    Reviewed-by: Jeremy Allison <[email protected]>

commit 86c2578a55507804f7ccd7d3a9656ceaa90fb302
Author: Christof Schmitt <[email protected]>
Date:   Fri Jan 3 12:45:06 2020 -0700

    vfs_gpfs: Rename argument of flock function
    
    MS-SMB2 and the smbd code refer to this field as share_access. Use the
    same name in the function argument.
    
    Signed-off-by: Christof Schmitt <[email protected]>
    Reviewed-by: Jeremy Allison <[email protected]>

commit 0d5794f6f92dbfc2400b73ed3a0376a050b28b50
Author: Christof Schmitt <[email protected]>
Date:   Fri Jan 3 12:41:00 2020 -0700

    vfs_glusterfs: Rename argument of flock function
    
    MS-SMB2 and the smbd code refer to this field as share_access. Use the
    same name in the function argument.
    
    Signed-off-by: Christof Schmitt <[email protected]>
    Reviewed-by: Jeremy Allison <[email protected]>

commit 4667399457fee5b49c931c81cb963c6771f03a8d
Author: Christof Schmitt <[email protected]>
Date:   Fri Jan 3 12:38:00 2020 -0700

    vfs_full_audit: Rename argument of flock function
    
    MS-SMB2 and the smbd code refer to this field as share_access. Use the
    same name in the function argument.
    
    Signed-off-by: Christof Schmitt <[email protected]>
    Reviewed-by: Jeremy Allison <[email protected]>

commit 83f59ac00e965a63b81873026e0e8d1c5a72f939
Author: Christof Schmitt <[email protected]>
Date:   Fri Jan 3 12:09:23 2020 -0700

    vfs_ceph: Rename argument for flock function
    
    MS-SMB2 and the smbd code refer to this field as share_access. Use the
    same name in the function argument.
    
    Signed-off-by: Christof Schmitt <[email protected]>
    Reviewed-by: Jeremy Allison <[email protected]>

commit 537d226ed93fdbccf236b7f79bb32802254a2356
Author: Christof Schmitt <[email protected]>
Date:   Fri Jan 3 12:08:38 2020 -0700

    vfs_catia: Rename argument for flock function
    
    MS-SMB2 and the smbd code refer to this field as share_access. Use the
    same name in the function argument.
    
    Signed-off-by: Christof Schmitt <[email protected]>
    Reviewed-by: Jeremy Allison <[email protected]>

commit 974aae418f68e7dac1e9277d8b8df4b41f0cfa8c
Author: Christof Schmitt <[email protected]>
Date:   Fri Jan 3 12:06:40 2020 -0700

    vfs_not_implemented: Rename argument for flock function
    
    MS-SMB2 and the smbd code refer to this field as share_access. Use the
    same name in the function argument.
    
    Signed-off-by: Christof Schmitt <[email protected]>
    Reviewed-by: Jeremy Allison <[email protected]>

commit e8d9a21435ae4266093e355feda1c9bac6f9956e
Author: Christof Schmitt <[email protected]>
Date:   Fri Jan 3 12:05:57 2020 -0700

    vfs: Rename argument for kernel_flock function
    
    MS-SMB2 and the smbd code refer to this field as share_access. Use the
    same name in the function argument.
    
    Signed-off-by: Christof Schmitt <[email protected]>
    Reviewed-by: Jeremy Allison <[email protected]>

commit ad8e6863c3791e50bc80418bc94f4970ed6b0e68
Author: Christof Schmitt <[email protected]>
Date:   Fri Jan 3 11:58:38 2020 -0700

    system: Rename argument for kernel_flock function
    
    MS-SMB2 and the smbd code refer to this field as share_access. Use the
    same name in the function argument.
    
    Signed-off-by: Christof Schmitt <[email protected]>
    Reviewed-by: Jeremy Allison <[email protected]>

-----------------------------------------------------------------------

Summary of changes:
 source3/include/proto.h               |   2 +-
 source3/include/vfs.h                 |   6 +-
 source3/include/vfs_macros.h          |   8 +--
 source3/lib/system.c                  |   8 +--
 source3/modules/vfs_catia.c           |   4 +-
 source3/modules/vfs_ceph.c            |   6 +-
 source3/modules/vfs_default.c         |   4 +-
 source3/modules/vfs_full_audit.c      |   8 ++-
 source3/modules/vfs_glusterfs.c       |   2 +-
 source3/modules/vfs_gpfs.c            | 128 +++++++++++++++++++++-------------
 source3/modules/vfs_not_implemented.c |   2 +-
 source3/modules/vfs_streams_xattr.c   |   4 +-
 source3/modules/vfs_time_audit.c      |   5 +-
 13 files changed, 114 insertions(+), 73 deletions(-)


Changeset truncated at 500 lines:

diff --git a/source3/include/proto.h b/source3/include/proto.h
index d543dc66955..72ac69e72f2 100644
--- a/source3/include/proto.h
+++ b/source3/include/proto.h
@@ -235,7 +235,7 @@ int sys_lstat(const char *fname,SMB_STRUCT_STAT *sbuf,
              bool fake_dir_create_times);
 int sys_posix_fallocate(int fd, off_t offset, off_t len);
 int sys_fallocate(int fd, uint32_t mode, off_t offset, off_t len);
-void kernel_flock(int fd, uint32_t share_mode, uint32_t access_mask);
+void kernel_flock(int fd, uint32_t share_access, uint32_t access_mask);
 DIR *sys_fdopendir(int fd);
 int sys_mknod(const char *path, mode_t mode, SMB_DEV_T dev);
 int sys_mknodat(int dirfd, const char *path, mode_t mode, SMB_DEV_T dev);
diff --git a/source3/include/vfs.h b/source3/include/vfs.h
index 28a3ce60543..e4881d4940b 100644
--- a/source3/include/vfs.h
+++ b/source3/include/vfs.h
@@ -808,7 +808,7 @@ struct vfs_fn_pointers {
                            off_t len);
        bool (*lock_fn)(struct vfs_handle_struct *handle, struct files_struct 
*fsp, int op, off_t offset, off_t count, int type);
        int (*kernel_flock_fn)(struct vfs_handle_struct *handle, struct 
files_struct *fsp,
-                              uint32_t share_mode, uint32_t access_mask);
+                              uint32_t share_access, uint32_t access_mask);
        int (*fcntl_fn)(struct vfs_handle_struct *handle,
                        struct files_struct *fsp, int cmd, va_list cmd_arg);
        int (*linux_setlease_fn)(struct vfs_handle_struct *handle, struct 
files_struct *fsp, int leasetype);
@@ -1338,7 +1338,7 @@ bool smb_vfs_call_lock(struct vfs_handle_struct *handle,
                       struct files_struct *fsp, int op, off_t offset,
                       off_t count, int type);
 int smb_vfs_call_kernel_flock(struct vfs_handle_struct *handle,
-                             struct files_struct *fsp, uint32_t share_mode,
+                             struct files_struct *fsp, uint32_t share_access,
                              uint32_t access_mask);
 int smb_vfs_call_fcntl(struct vfs_handle_struct *handle,
                       struct files_struct *fsp, int cmd, ...);
@@ -1770,7 +1770,7 @@ bool vfs_not_implemented_lock(vfs_handle_struct *handle, 
files_struct *fsp, int
                              off_t offset, off_t count, int type);
 int vfs_not_implemented_kernel_flock(struct vfs_handle_struct *handle,
                                     struct files_struct *fsp,
-                                    uint32_t share_mode, uint32_t access_mask);
+                                    uint32_t share_access, uint32_t 
access_mask);
 int vfs_not_implemented_fcntl(struct vfs_handle_struct *handle,
                              struct files_struct *fsp, int cmd, va_list 
cmd_arg);
 int vfs_not_implemented_linux_setlease(struct vfs_handle_struct *handle,
diff --git a/source3/include/vfs_macros.h b/source3/include/vfs_macros.h
index 6a7cbf2275d..cec8f6f204d 100644
--- a/source3/include/vfs_macros.h
+++ b/source3/include/vfs_macros.h
@@ -271,10 +271,10 @@
 #define SMB_VFS_NEXT_LOCK(handle, fsp, op, offset, count, type) \
        smb_vfs_call_lock((handle)->next, (fsp), (op), (offset), (count), 
(type))
 
-#define SMB_VFS_KERNEL_FLOCK(fsp, share_mode, access_mask) \
-       smb_vfs_call_kernel_flock((fsp)->conn->vfs_handles, (fsp), 
(share_mode), (access_mask))
-#define SMB_VFS_NEXT_KERNEL_FLOCK(handle, fsp, share_mode, access_mask)        
\
-       smb_vfs_call_kernel_flock((handle)->next, (fsp), (share_mode), 
(access_mask))
+#define SMB_VFS_KERNEL_FLOCK(fsp, share_access, access_mask) \
+       smb_vfs_call_kernel_flock((fsp)->conn->vfs_handles, (fsp), 
(share_access), (access_mask))
+#define SMB_VFS_NEXT_KERNEL_FLOCK(handle, fsp, share_access, access_mask)      
\
+       smb_vfs_call_kernel_flock((handle)->next, (fsp), (share_access), 
(access_mask))
 
 #define SMB_VFS_FCNTL(fsp, cmd, ...) \
        smb_vfs_call_fcntl((fsp)->conn->vfs_handles, (fsp), (cmd), 
(__VA_ARGS__))
diff --git a/source3/lib/system.c b/source3/lib/system.c
index 679332255c0..f1265e0c43f 100644
--- a/source3/lib/system.c
+++ b/source3/lib/system.c
@@ -575,15 +575,15 @@ int sys_fallocate(int fd, uint32_t mode, off_t offset, 
off_t len)
  A flock() wrapper that will perform the kernel flock.
 ********************************************************************/
 
-void kernel_flock(int fd, uint32_t share_mode, uint32_t access_mask)
+void kernel_flock(int fd, uint32_t share_access, uint32_t access_mask)
 {
 #ifdef HAVE_KERNEL_SHARE_MODES
        int kernel_mode = 0;
-       if (share_mode == FILE_SHARE_WRITE) {
+       if (share_access == FILE_SHARE_WRITE) {
                kernel_mode = LOCK_MAND|LOCK_WRITE;
-       } else if (share_mode == FILE_SHARE_READ) {
+       } else if (share_access == FILE_SHARE_READ) {
                kernel_mode = LOCK_MAND|LOCK_READ;
-       } else if (share_mode == FILE_SHARE_NONE) {
+       } else if (share_access == FILE_SHARE_NONE) {
                kernel_mode = LOCK_MAND;
        }
        if (kernel_mode) {
diff --git a/source3/modules/vfs_catia.c b/source3/modules/vfs_catia.c
index 3880f16b10c..23246c72be2 100644
--- a/source3/modules/vfs_catia.c
+++ b/source3/modules/vfs_catia.c
@@ -2072,7 +2072,7 @@ static bool catia_lock(vfs_handle_struct *handle,
 
 static int catia_kernel_flock(struct vfs_handle_struct *handle,
                              struct files_struct *fsp,
-                             uint32_t share_mode,
+                             uint32_t share_access,
                              uint32_t access_mask)
 {
        struct catia_cache *cc = NULL;
@@ -2083,7 +2083,7 @@ static int catia_kernel_flock(struct vfs_handle_struct 
*handle,
                return -1;
        }
 
-       ret = SMB_VFS_NEXT_KERNEL_FLOCK(handle, fsp, share_mode, access_mask);
+       ret = SMB_VFS_NEXT_KERNEL_FLOCK(handle, fsp, share_access, access_mask);
 
        CATIA_FETCH_FSP_POST_NEXT(&cc, fsp);
 
diff --git a/source3/modules/vfs_ceph.c b/source3/modules/vfs_ceph.c
index 82bcb154f77..70059db0c01 100644
--- a/source3/modules/vfs_ceph.c
+++ b/source3/modules/vfs_ceph.c
@@ -1085,8 +1085,10 @@ static bool cephwrap_lock(struct vfs_handle_struct 
*handle, files_struct *fsp, i
        return true;
 }
 
-static int cephwrap_kernel_flock(struct vfs_handle_struct *handle, 
files_struct *fsp,
-                               uint32_t share_mode, uint32_t access_mask)
+static int cephwrap_kernel_flock(struct vfs_handle_struct *handle,
+                                files_struct *fsp,
+                                uint32_t share_access,
+                                uint32_t access_mask)
 {
        DBG_ERR("[CEPH] flock unsupported! Consider setting "
                "\"kernel share modes = no\"\n");
diff --git a/source3/modules/vfs_default.c b/source3/modules/vfs_default.c
index 30efccbafa7..5bf76716164 100644
--- a/source3/modules/vfs_default.c
+++ b/source3/modules/vfs_default.c
@@ -2587,10 +2587,10 @@ static bool vfswrap_lock(vfs_handle_struct *handle, 
files_struct *fsp, int op, o
 }
 
 static int vfswrap_kernel_flock(vfs_handle_struct *handle, files_struct *fsp,
-                               uint32_t share_mode, uint32_t access_mask)
+                               uint32_t share_access, uint32_t access_mask)
 {
        START_PROFILE(syscall_kernel_flock);
-       kernel_flock(fsp->fh->fd, share_mode, access_mask);
+       kernel_flock(fsp->fh->fd, share_access, access_mask);
        END_PROFILE(syscall_kernel_flock);
        return 0;
 }
diff --git a/source3/modules/vfs_full_audit.c b/source3/modules/vfs_full_audit.c
index ea16443a05d..415be388fca 100644
--- a/source3/modules/vfs_full_audit.c
+++ b/source3/modules/vfs_full_audit.c
@@ -1693,11 +1693,15 @@ static bool smb_full_audit_lock(vfs_handle_struct 
*handle, files_struct *fsp,
 
 static int smb_full_audit_kernel_flock(struct vfs_handle_struct *handle,
                                       struct files_struct *fsp,
-                                      uint32_t share_mode, uint32_t 
access_mask)
+                                      uint32_t share_access,
+                                      uint32_t access_mask)
 {
        int result;
 
-       result = SMB_VFS_NEXT_KERNEL_FLOCK(handle, fsp, share_mode, 
access_mask);
+       result = SMB_VFS_NEXT_KERNEL_FLOCK(handle,
+                                          fsp,
+                                          share_access,
+                                          access_mask);
 
        do_log(SMB_VFS_OP_KERNEL_FLOCK, (result >= 0), handle, "%s",
               fsp_str_do_log(fsp));
diff --git a/source3/modules/vfs_glusterfs.c b/source3/modules/vfs_glusterfs.c
index d7a1ec4d334..e8bd64be9e6 100644
--- a/source3/modules/vfs_glusterfs.c
+++ b/source3/modules/vfs_glusterfs.c
@@ -1604,7 +1604,7 @@ out:
 }
 
 static int vfs_gluster_kernel_flock(struct vfs_handle_struct *handle,
-                                   files_struct *fsp, uint32_t share_mode,
+                                   files_struct *fsp, uint32_t share_access,
                                    uint32_t access_mask)
 {
        errno = ENOSYS;
diff --git a/source3/modules/vfs_gpfs.c b/source3/modules/vfs_gpfs.c
index 25df3266902..de18d32ac23 100644
--- a/source3/modules/vfs_gpfs.c
+++ b/source3/modules/vfs_gpfs.c
@@ -77,62 +77,84 @@ static inline gpfs_ace_v4_t *gpfs_ace_ptr(gpfs_acl_t *gacl, 
unsigned int i)
        return &gacl->ace_v4[i];
 }
 
-static bool set_gpfs_sharemode(files_struct *fsp, uint32_t access_mask,
-                              uint32_t share_access)
+static unsigned int vfs_gpfs_access_mask_to_allow(uint32_t access_mask)
 {
        unsigned int allow = GPFS_SHARE_NONE;
-       unsigned int deny = GPFS_DENY_NONE;
-       int result;
 
-       if ((fsp == NULL) || (fsp->fh == NULL) || (fsp->fh->fd < 0)) {
-               /* No real file, don't disturb */
-               return True;
+       if (access_mask & (FILE_WRITE_DATA|FILE_APPEND_DATA)) {
+               allow |= GPFS_SHARE_WRITE;
+       }
+       if (access_mask & (FILE_READ_DATA|FILE_EXECUTE)) {
+               allow |= GPFS_SHARE_READ;
        }
 
-       allow |= (access_mask & (FILE_WRITE_DATA|FILE_APPEND_DATA)) ?
-               GPFS_SHARE_WRITE : 0;
-       allow |= (access_mask & (FILE_READ_DATA|FILE_EXECUTE)) ?
-               GPFS_SHARE_READ : 0;
+       return allow;
+}
+
+static unsigned int vfs_gpfs_share_access_to_deny(uint32_t share_access)
+{
+       unsigned int deny = GPFS_DENY_NONE;
 
-       if (allow == GPFS_SHARE_NONE) {
-               DEBUG(10, ("special case am=no_access:%x\n",access_mask));
+       if (!(share_access & FILE_SHARE_WRITE)) {
+               deny |= GPFS_DENY_WRITE;
+       }
+       if (!(share_access & FILE_SHARE_READ)) {
+               deny |= GPFS_DENY_READ;
        }
-       else {
-               deny |= (share_access & FILE_SHARE_WRITE) ?
-                       0 : GPFS_DENY_WRITE;
-               deny |= (share_access & (FILE_SHARE_READ)) ?
-                       0 : GPFS_DENY_READ;
 
-               /*
-                * GPFS_DENY_DELETE can only be set together with either
-                * GPFS_DENY_WRITE or GPFS_DENY_READ.
-                */
-               if (deny & (GPFS_DENY_WRITE|GPFS_DENY_READ)) {
-                       deny |= (share_access & (FILE_SHARE_DELETE)) ?
-                               0 : GPFS_DENY_DELETE;
-               }
+       /*
+        * GPFS_DENY_DELETE can only be set together with either
+        * GPFS_DENY_WRITE or GPFS_DENY_READ.
+        */
+       if ((deny & (GPFS_DENY_WRITE|GPFS_DENY_READ)) &&
+           !(share_access & FILE_SHARE_DELETE)) {
+               deny |= GPFS_DENY_DELETE;
        }
-       DEBUG(10, ("am=%x, allow=%d, sa=%x, deny=%d\n",
-                  access_mask, allow, share_access, deny));
+
+       return deny;
+}
+
+static int set_gpfs_sharemode(files_struct *fsp, uint32_t access_mask,
+                             uint32_t share_access)
+{
+       unsigned int allow = GPFS_SHARE_NONE;
+       unsigned int deny = GPFS_DENY_NONE;
+       int result;
+
+       if (access_mask == 0) {
+               DBG_DEBUG("Clearing file system share mode.\n");
+       } else {
+               allow = vfs_gpfs_access_mask_to_allow(access_mask);
+               deny = vfs_gpfs_share_access_to_deny(share_access);
+       }
+       DBG_DEBUG("access_mask=0x%x, allow=0x%x, share_access=0x%x, "
+                 "deny=0x%x\n", access_mask, allow, share_access, deny);
 
        result = gpfswrap_set_share(fsp->fh->fd, allow, deny);
-       if (result != 0) {
-               if (errno == ENOSYS) {
-                       DEBUG(5, ("VFS module vfs_gpfs loaded, but gpfs "
-                                 "set_share function support not available. "
-                                 "Allowing access\n"));
-                       return True;
-               } else {
-                       DEBUG(10, ("gpfs_set_share failed: %s\n",
-                                  strerror(errno)));
-               }
+       if (result == 0) {
+               return 0;
+       }
+
+       if (errno == EACCES) {
+               DBG_NOTICE("GPFS share mode denied for %s/%s.\n",
+                          fsp->conn->connectpath,
+                          fsp->fsp_name->base_name);
+       } else if (errno == EPERM) {
+               DBG_ERR("Samba requested GPFS sharemode for %s/%s, but the "
+                       "GPFS file system is not configured accordingly. "
+                       "Configure file system with mmchfs -D nfs4 or "
+                       "set gpfs:sharemodes=no in Samba.\n",
+                       fsp->conn->connectpath,
+                       fsp->fsp_name->base_name);
+       } else {
+               DBG_ERR("gpfs_set_share failed: %s\n", strerror(errno));
        }
 
-       return (result == 0);
+       return result;
 }
 
 static int vfs_gpfs_kernel_flock(vfs_handle_struct *handle, files_struct *fsp,
-                                uint32_t share_mode, uint32_t access_mask)
+                                uint32_t share_access, uint32_t access_mask)
 {
 
        struct gpfs_config_data *config;
@@ -154,15 +176,15 @@ static int vfs_gpfs_kernel_flock(vfs_handle_struct 
*handle, files_struct *fsp,
         * kernel_flock and set_gpfs_sharemode for stream.
         */
        if (is_named_stream(fsp->fsp_name)) {
-               DEBUG(2,("%s: kernel_flock on stream\n", fsp_str_dbg(fsp)));
+               DBG_NOTICE("Not requesting GPFS sharemode on stream: %s/%s\n",
+                          fsp->conn->connectpath,
+                          fsp_str_dbg(fsp));
                return 0;
        }
 
-       kernel_flock(fsp->fh->fd, share_mode, access_mask);
+       kernel_flock(fsp->fh->fd, share_access, access_mask);
 
-       if (!set_gpfs_sharemode(fsp, access_mask, share_mode)) {
-               ret = -1;
-       }
+       ret = set_gpfs_sharemode(fsp, access_mask, share_access);
 
        END_PROFILE(syscall_kernel_flock);
 
@@ -178,8 +200,20 @@ static int vfs_gpfs_close(vfs_handle_struct *handle, 
files_struct *fsp)
                                struct gpfs_config_data,
                                return -1);
 
-       if (config->sharemodes && (fsp->fh != NULL) && (fsp->fh->fd != -1)) {
-               set_gpfs_sharemode(fsp, 0, 0);
+       if (config->sharemodes && fsp->kernel_share_modes_taken) {
+               /*
+                * Always clear GPFS sharemode in case the actual
+                * close gets deferred due to outstanding POSIX locks
+                * (see fd_close_posix)
+                */
+               int ret = gpfswrap_set_share(fsp->fh->fd, 0, 0);
+               if (ret != 0) {
+                       DBG_ERR("Clearing GPFS sharemode on close failed for "
+                               " %s/%s: %s\n",
+                               fsp->conn->connectpath,
+                               fsp->fsp_name->base_name,
+                               strerror(errno));
+               }
        }
 
        return SMB_VFS_NEXT_CLOSE(handle, fsp);
diff --git a/source3/modules/vfs_not_implemented.c 
b/source3/modules/vfs_not_implemented.c
index b68b9e2e8b9..dc4ac25b035 100644
--- a/source3/modules/vfs_not_implemented.c
+++ b/source3/modules/vfs_not_implemented.c
@@ -420,7 +420,7 @@ bool vfs_not_implemented_lock(vfs_handle_struct *handle, 
files_struct *fsp, int
 
 int vfs_not_implemented_kernel_flock(struct vfs_handle_struct *handle,
                                     struct files_struct *fsp,
-                                    uint32_t share_mode, uint32_t access_mask)
+                                    uint32_t share_access, uint32_t 
access_mask)
 {
        errno = ENOSYS;
        return -1;
diff --git a/source3/modules/vfs_streams_xattr.c 
b/source3/modules/vfs_streams_xattr.c
index fa54fe26435..85efe2bcc37 100644
--- a/source3/modules/vfs_streams_xattr.c
+++ b/source3/modules/vfs_streams_xattr.c
@@ -1585,7 +1585,7 @@ static bool streams_xattr_getlock(vfs_handle_struct 
*handle,
 
 static int streams_xattr_kernel_flock(vfs_handle_struct *handle,
                                      files_struct *fsp,
-                                     uint32_t share_mode,
+                                     uint32_t share_access,
                                      uint32_t access_mask)
 {
        struct stream_io *sio =
@@ -1593,7 +1593,7 @@ static int streams_xattr_kernel_flock(vfs_handle_struct 
*handle,
 
        if (sio == NULL) {
                return SMB_VFS_NEXT_KERNEL_FLOCK(handle, fsp,
-                                                share_mode, access_mask);
+                                                share_access, access_mask);
        }
 
        return 0;
diff --git a/source3/modules/vfs_time_audit.c b/source3/modules/vfs_time_audit.c
index 70efa30b914..da99a06ce3a 100644
--- a/source3/modules/vfs_time_audit.c
+++ b/source3/modules/vfs_time_audit.c
@@ -1281,14 +1281,15 @@ static bool smb_time_audit_lock(vfs_handle_struct 
*handle, files_struct *fsp,
 
 static int smb_time_audit_kernel_flock(struct vfs_handle_struct *handle,
                                       struct files_struct *fsp,
-                                      uint32_t share_mode, uint32_t 
access_mask)
+                                      uint32_t share_access,
+                                      uint32_t access_mask)
 {
        int result;
        struct timespec ts1,ts2;
        double timediff;
 
        clock_gettime_mono(&ts1);
-       result = SMB_VFS_NEXT_KERNEL_FLOCK(handle, fsp, share_mode,
+       result = SMB_VFS_NEXT_KERNEL_FLOCK(handle, fsp, share_access,
                                           access_mask);
        clock_gettime_mono(&ts2);
        timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;


-- 
Samba Shared Repository

Reply via email to