s3:vfs: Correctly check if OFD locks should be enabled or not
authorAndreas Schneider <asn@samba.org>
Wed, 30 Jan 2019 17:45:34 +0000 (18:45 +0100)
committerJeremy Allison <jra@samba.org>
Sat, 9 Feb 2019 02:43:50 +0000 (03:43 +0100)
Also the smb.conf options should only be checked once and a reload of
the config should not switch to a different locking mode.

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
Autobuild-User(master): Jeremy Allison <jra@samba.org>
Autobuild-Date(master): Sat Feb  9 03:43:50 CET 2019 on sn-devel-144

source3/include/proto.h
source3/lib/util.c
source3/modules/vfs_default.c
source3/smbd/files.c

index 715bc56e2861ab42db299316c200c19dcd36ca0f..9d6192967ba92b4d42f93364e3f905a4d3e3b217 100644 (file)
@@ -360,7 +360,7 @@ void set_namearray(name_compare_entry **ppname_array, const char *namelist);
 void free_namearray(name_compare_entry *name_array);
 bool fcntl_lock(int fd, int op, off_t offset, off_t count, int type);
 bool fcntl_getlock(int fd, int op, off_t *poffset, off_t *pcount, int *ptype, pid_t *ppid);
-int map_process_lock_to_ofd_lock(int op, bool *use_ofd_locks);
+int map_process_lock_to_ofd_lock(int op);
 bool is_myname(const char *s);
 void ra_lanman_string( const char *native_lanman );
 const char *get_remote_arch_str(void);
index 5dbd67349faf8f45abeb82c5d8ca91500cd24b66..7530ea6797301e474e54b496b79dc66640f1b8c6 100644 (file)
@@ -1079,7 +1079,7 @@ bool fcntl_getlock(int fd, int op, off_t *poffset, off_t *pcount, int *ptype, pi
 }
 
 #if defined(HAVE_OFD_LOCKS)
-int map_process_lock_to_ofd_lock(int op, bool *use_ofd_locks)
+int map_process_lock_to_ofd_lock(int op)
 {
        switch (op) {
        case F_GETLK:
@@ -1095,16 +1095,13 @@ int map_process_lock_to_ofd_lock(int op, bool *use_ofd_locks)
                op = F_OFD_SETLKW;
                break;
        default:
-               *use_ofd_locks = false;
                return -1;
        }
-       *use_ofd_locks = true;
        return op;
 }
 #else /* HAVE_OFD_LOCKS */
-int map_process_lock_to_ofd_lock(int op, bool *use_ofd_locks)
+int map_process_lock_to_ofd_lock(int op)
 {
-       *use_ofd_locks = false;
        return op;
 }
 #endif /* HAVE_OFD_LOCKS */
index a27d33a6bead6b2c5d1a275b8716c5e5cd84d5d9..cb5537e096e6cbe07c2edfe07ec37b3fa5160585 100644 (file)
@@ -2553,11 +2553,8 @@ static bool vfswrap_lock(vfs_handle_struct *handle, files_struct *fsp, int op, o
 
        START_PROFILE(syscall_fcntl_lock);
 
-       if (fsp->use_ofd_locks || !lp_parm_bool(SNUM(fsp->conn),
-                                               "smbd",
-                                               "force process locks",
-                                               false)) {
-               op = map_process_lock_to_ofd_lock(op, &fsp->use_ofd_locks);
+       if (fsp->use_ofd_locks) {
+               op = map_process_lock_to_ofd_lock(op);
        }
 
        result =  fcntl_lock(fsp->fh->fd, op, offset, count, type);
@@ -2581,11 +2578,8 @@ static bool vfswrap_getlock(vfs_handle_struct *handle, files_struct *fsp, off_t
 
        START_PROFILE(syscall_fcntl_getlock);
 
-       if (fsp->use_ofd_locks || !lp_parm_bool(SNUM(fsp->conn),
-                                               "smbd",
-                                               "force process locks",
-                                               false)) {
-               op = map_process_lock_to_ofd_lock(op, &fsp->use_ofd_locks);
+       if (fsp->use_ofd_locks) {
+               op = map_process_lock_to_ofd_lock(op);
        }
 
        result = fcntl_getlock(fsp->fh->fd, op, poffset, pcount, ptype, ppid);
index 397baea84cbf01543ee6fb303daec94ee42cd091..99b4937c99b4a892c55a95613d682c1bd84e1438 100644 (file)
@@ -51,6 +51,15 @@ NTSTATUS fsp_new(struct connection_struct *conn, TALLOC_CTX *mem_ctx,
                goto fail;
        }
 
+#if defined(HAVE_OFD_LOCKS)
+       fsp->use_ofd_locks = true;
+       if (lp_parm_bool(SNUM(conn),
+                        "smbd",
+                        "force process locks",
+                        false)) {
+               fsp->use_ofd_locks = false;
+       }
+#endif
        fsp->fh->ref_count = 1;
        fsp->fh->fd = -1;