summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2016-05-12 21:17:21 +0200
committerJeremy Allison <jra@samba.org>2016-05-21 01:28:28 +0200
commite39436e770b5f6fe9e6615bc70bda627a3a1bd58 (patch)
tree7d23741a1314bfce806428ae56adbd874989942b
parent598538316786188f2d91c6e2c343c8051e27fd68 (diff)
downloadsamba-e39436e770b5f6fe9e6615bc70bda627a3a1bd58.tar.gz
s3: VFS: Map process-associated lock operation to open file description lock operation.
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>
-rw-r--r--source3/locking/posix.c16
-rw-r--r--source3/modules/vfs_default.c16
2 files changed, 29 insertions, 3 deletions
diff --git a/source3/locking/posix.c b/source3/locking/posix.c
index f3a89fdf508..432637a3dfe 100644
--- a/source3/locking/posix.c
+++ b/source3/locking/posix.c
@@ -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
diff --git a/source3/modules/vfs_default.c b/source3/modules/vfs_default.c
index 087fb446feb..de5a4a3dd55 100644
--- a/source3/modules/vfs_default.c
+++ b/source3/modules/vfs_default.c
@@ -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;