s3: VFS: Map process-associated lock operation to open file description lock operation.
authorJeremy Allison <jra@samba.org>
Thu, 12 May 2016 19:17:21 +0000 (21:17 +0200)
committerJeremy Allison <jra@samba.org>
Fri, 20 May 2016 23:28:28 +0000 (01:28 +0200)
Only in the default VFS. Gpfs, Ceph, Gluster and other modern
backend VFS filesystems might want to do the same.

Allow tuneable "smbd:force process locks = true" to turn
off OFD locks if in use and the kernel doesn't support them.

Display debug message showing admins what to do in this case.

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Jeff Layton <jlayton@samba.org>
source3/locking/posix.c
source3/modules/vfs_default.c

index f3a89fdf508cf47c5f0f15c6a9eff040ed48d34a..432637a3dfe228766ea6725791296857195c31a0 100644 (file)
@@ -198,12 +198,22 @@ static bool posix_fcntl_lock(files_struct *fsp, int op, off_t offset, off_t coun
 
        if (!ret && ((errno == EFBIG) || (errno == ENOLCK) || (errno ==  EINVAL))) {
 
-               DEBUG(0, ("posix_fcntl_lock: WARNING: lock request at offset "
+               if ((errno == EINVAL) &&
+                               (op != F_GETLK &&
+                                op != F_SETLK &&
+                                op != F_SETLKW)) {
+                       DEBUG(0,("WARNING: OFD locks in use and no kernel "
+                               "support. Try setting "
+                               "'smbd:force process locks = true' "
+                               "in smb.conf\n"));
+               } else {
+                       DEBUG(0, ("WARNING: lock request at offset "
                          "%ju, length %ju returned\n",
                          (uintmax_t)offset, (uintmax_t)count));
-               DEBUGADD(0, ("an %s error. This can happen when using 64 bit "
+                       DEBUGADD(0, ("an %s error. This can happen when using 64 bit "
                             "lock offsets\n", strerror(errno)));
-               DEBUGADD(0, ("on 32 bit NFS mounted file systems.\n"));
+                       DEBUGADD(0, ("on 32 bit NFS mounted file systems.\n"));
+               }
 
                /*
                 * If the offset is > 0x7FFFFFFF then this will cause problems on
index 087fb446feb13ff93ad97ad8ffa5ba260aaa7f27..de5a4a3dd5571e76d88f064cb639c1a2c31a7d1f 100644 (file)
@@ -2102,6 +2102,14 @@ static bool vfswrap_lock(vfs_handle_struct *handle, files_struct *fsp, int op, o
        bool result;
 
        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);
+       }
+
        result =  fcntl_lock(fsp->fh->fd, op, offset, count, type);
        END_PROFILE(syscall_fcntl_lock);
        return result;
@@ -2122,6 +2130,14 @@ static bool vfswrap_getlock(vfs_handle_struct *handle, files_struct *fsp, off_t
        int op = F_GETLK;
 
        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);
+       }
+
        result = fcntl_getlock(fsp->fh->fd, op, poffset, pcount, ptype, ppid);
        END_PROFILE(syscall_fcntl_getlock);
        return result;