Removing SMB_VFS_STRICT_UNLOCK() ?

Ralph Böhme slow at samba.org
Sun Jul 9 12:39:25 UTC 2017


Hi,

On Thu, Mar 16, 2017 at 10:08:43PM +0100, Ralph Böhme wrote:
> 
> On Thu, Mar 16, 2017 at 11:48:22AM -0700, Jeremy Allison wrote:
> > On Thu, Mar 16, 2017 at 08:56:46AM +0100, Ralph Böhme via samba-technical wrote:
> > > Hi!
> > > 
> > > What abot removing SMB_VFS_STRICT_UNLOCK()? The only VFS that implements it is
> > > vfs_default and it's a noop there.
> > > 
> > > Afaict it makes no sense anyway as per the strict locking specification (and
> > > MS-FSA), SMB_VFS_STRICT_LOCK() only checks locks, it doesn't set any.
> > > 
> > > Thoughts?
> > 
> > Think it might have been added as an Isilon-specific thing.
> > 
> > Happy to lose this for 4.7, but only if you change the name
> > of SMB_VFS_STRICT_LOCK() to SMB_VFS_STRICT_LOCK_CHECK()
> > also, so it's obvious what it really does :-).
> 
> sounds like a plan. :)

...and here's the patchset. I've filed a bug to get this into 4.7.

Please review&push if ok. Thanks!

Cheerio!
-slow
-------------- next part --------------
From 1daa709d13c221a28d49dddd93d14f31ea0332cc Mon Sep 17 00:00:00 2001
From: Ralph Boehme <slow at samba.org>
Date: Sun, 9 Jul 2017 14:21:21 +0200
Subject: [PATCH 1/2] s3/vfs: remove SMB_VFS_STRICT_UNLOCK

It's just a noop, so let's remove it. SMB_VFS_STRICT_LOCK doesn't set
logs, it just checks for the presence of incompatible locks.

Bug: https://bugzilla.samba.org/show_bug.cgi?id=12887

Signed-off-by: Ralph Boehme <slow at samba.org>
---
 examples/VFS/skel_opaque.c        |  8 -----
 examples/VFS/skel_transparent.c   |  8 -----
 source3/include/vfs.h             |  8 +----
 source3/include/vfs_macros.h      |  5 ---
 source3/locking/locking.c         |  4 ---
 source3/locking/proto.h           |  2 --
 source3/modules/vfs_btrfs.c       |  5 ---
 source3/modules/vfs_catia.c       | 18 ----------
 source3/modules/vfs_default.c     | 33 ++++-------------
 source3/modules/vfs_full_audit.c  | 14 --------
 source3/modules/vfs_glusterfs.c   |  1 -
 source3/modules/vfs_time_audit.c  | 18 ----------
 source3/smbd/aio.c                | 20 -----------
 source3/smbd/reply.c              | 75 ++++++++++++---------------------------
 source3/smbd/smb2_ioctl_filesys.c |  3 --
 source3/smbd/smb2_read.c          |  6 ----
 source3/smbd/smb2_write.c         |  2 --
 source3/smbd/vfs.c                |  8 -----
 18 files changed, 30 insertions(+), 208 deletions(-)

diff --git a/examples/VFS/skel_opaque.c b/examples/VFS/skel_opaque.c
index fed9d2f..072ec80 100644
--- a/examples/VFS/skel_opaque.c
+++ b/examples/VFS/skel_opaque.c
@@ -695,13 +695,6 @@ static bool skel_strict_lock(struct vfs_handle_struct *handle,
 	return false;
 }
 
-static void skel_strict_unlock(struct vfs_handle_struct *handle,
-			       struct files_struct *fsp,
-			       struct lock_struct *plock)
-{
-	;
-}
-
 static NTSTATUS skel_translate_name(struct vfs_handle_struct *handle,
 				    const char *mapped_name,
 				    enum vfs_translate_direction direction,
@@ -1023,7 +1016,6 @@ struct vfs_fn_pointers skel_opaque_fns = {
 	.brl_unlock_windows_fn = skel_brl_unlock_windows,
 	.brl_cancel_windows_fn = skel_brl_cancel_windows,
 	.strict_lock_fn = skel_strict_lock,
-	.strict_unlock_fn = skel_strict_unlock,
 	.translate_name_fn = skel_translate_name,
 	.fsctl_fn = skel_fsctl,
 	.readdir_attr_fn = skel_readdir_attr,
diff --git a/examples/VFS/skel_transparent.c b/examples/VFS/skel_transparent.c
index d9123e0..9592c17 100644
--- a/examples/VFS/skel_transparent.c
+++ b/examples/VFS/skel_transparent.c
@@ -863,13 +863,6 @@ static bool skel_strict_lock(struct vfs_handle_struct *handle,
 	return SMB_VFS_NEXT_STRICT_LOCK(handle, fsp, plock);
 }
 
-static void skel_strict_unlock(struct vfs_handle_struct *handle,
-			       struct files_struct *fsp,
-			       struct lock_struct *plock)
-{
-	SMB_VFS_NEXT_STRICT_UNLOCK(handle, fsp, plock);
-}
-
 static NTSTATUS skel_translate_name(struct vfs_handle_struct *handle,
 				    const char *mapped_name,
 				    enum vfs_translate_direction direction,
@@ -1196,7 +1189,6 @@ struct vfs_fn_pointers skel_transparent_fns = {
 	.brl_unlock_windows_fn = skel_brl_unlock_windows,
 	.brl_cancel_windows_fn = skel_brl_cancel_windows,
 	.strict_lock_fn = skel_strict_lock,
-	.strict_unlock_fn = skel_strict_unlock,
 	.translate_name_fn = skel_translate_name,
 	.fsctl_fn = skel_fsctl,
 	.readdir_attr_fn = skel_readdir_attr,
diff --git a/source3/include/vfs.h b/source3/include/vfs.h
index 7b9a6f8..bd00e8f 100644
--- a/source3/include/vfs.h
+++ b/source3/include/vfs.h
@@ -241,6 +241,7 @@
 /* Version 37 - Add SMB_VFS_OFFLOAD_READ_SEND/RECV */
 /* Version 37 - Rename SMB_VFS_COPY_CHUNK_SEND/RECV to
                 SMB_VFS_OFFLOAD_READ_SEND/RECV */
+/* Version 37 - Remove SMB_VFS_STRICT_UNLOCK */
 
 #define SMB_VFS_INTERFACE_VERSION 37
 
@@ -852,10 +853,6 @@ struct vfs_fn_pointers {
 			       struct files_struct *fsp,
 			       struct lock_struct *plock);
 
-	void (*strict_unlock_fn)(struct vfs_handle_struct *handle,
-				 struct files_struct *fsp,
-				 struct lock_struct *plock);
-
 	NTSTATUS (*translate_name_fn)(struct vfs_handle_struct *handle,
 				      const char *name,
 				      enum vfs_translate_direction direction,
@@ -1318,9 +1315,6 @@ bool smb_vfs_call_brl_cancel_windows(struct vfs_handle_struct *handle,
 bool smb_vfs_call_strict_lock(struct vfs_handle_struct *handle,
 			      struct files_struct *fsp,
 			      struct lock_struct *plock);
-void smb_vfs_call_strict_unlock(struct vfs_handle_struct *handle,
-				struct files_struct *fsp,
-				struct lock_struct *plock);
 NTSTATUS smb_vfs_call_translate_name(struct vfs_handle_struct *handle,
 				     const char *name,
 				     enum vfs_translate_direction direction,
diff --git a/source3/include/vfs_macros.h b/source3/include/vfs_macros.h
index 69fa85b..843d626 100644
--- a/source3/include/vfs_macros.h
+++ b/source3/include/vfs_macros.h
@@ -381,11 +381,6 @@
 #define SMB_VFS_NEXT_STRICT_LOCK(handle, fsp, plock) \
 	smb_vfs_call_strict_lock((handle)->next, (fsp), (plock))
 
-#define SMB_VFS_STRICT_UNLOCK(conn, fsp, plock) \
-	smb_vfs_call_strict_unlock((conn)->vfs_handles, (fsp), (plock))
-#define SMB_VFS_NEXT_STRICT_UNLOCK(handle, fsp, plock) \
-	smb_vfs_call_strict_unlock((handle)->next, (fsp), (plock))
-
 #define SMB_VFS_TRANSLATE_NAME(conn, name, direction, mem_ctx, mapped_name) \
 	smb_vfs_call_translate_name((conn)->vfs_handles, (name), (direction), (mem_ctx), (mapped_name))
 #define SMB_VFS_NEXT_TRANSLATE_NAME(handle, name, direction, mem_ctx, mapped_name) \
diff --git a/source3/locking/locking.c b/source3/locking/locking.c
index 037a987..d344731 100644
--- a/source3/locking/locking.c
+++ b/source3/locking/locking.c
@@ -164,10 +164,6 @@ bool strict_lock_default(files_struct *fsp, struct lock_struct *plock)
 	return ret;
 }
 
-void strict_unlock_default(files_struct *fsp, struct lock_struct *plock)
-{
-}
-
 /****************************************************************************
  Find out if a lock could be granted - return who is blocking us if we can't.
 ****************************************************************************/
diff --git a/source3/locking/proto.h b/source3/locking/proto.h
index 6fb2bf2..ebd80f2 100644
--- a/source3/locking/proto.h
+++ b/source3/locking/proto.h
@@ -107,8 +107,6 @@ void init_strict_lock_struct(files_struct *fsp,
 				struct lock_struct *plock);
 bool strict_lock_default(files_struct *fsp,
 				struct lock_struct *plock);
-void strict_unlock_default(files_struct *fsp,
-				struct lock_struct *plock);
 NTSTATUS query_lock(files_struct *fsp,
 			uint64_t *psmblctx,
 			uint64_t *pcount,
diff --git a/source3/modules/vfs_btrfs.c b/source3/modules/vfs_btrfs.c
index 0fd4c6c..a90f583 100644
--- a/source3/modules/vfs_btrfs.c
+++ b/source3/modules/vfs_btrfs.c
@@ -322,7 +322,6 @@ static struct tevent_req *btrfs_offload_write_send(struct vfs_handle_struct *han
 			return tevent_req_post(req, ev);
 		}
 		if (!SMB_VFS_STRICT_LOCK(dest_fsp->conn, dest_fsp, &dest_lck)) {
-			SMB_VFS_STRICT_UNLOCK(src_fsp->conn, src_fsp, &src_lck);
 			tevent_req_nterror(req, NT_STATUS_FILE_LOCK_CONFLICT);
 			return tevent_req_post(req, ev);
 		}
@@ -335,10 +334,6 @@ static struct tevent_req *btrfs_offload_write_send(struct vfs_handle_struct *han
 	cr_args.src_length = (uint64_t)num;
 
 	ret = ioctl(dest_fsp->fh->fd, BTRFS_IOC_CLONE_RANGE, &cr_args);
-	if (do_locking) {
-		SMB_VFS_STRICT_UNLOCK(dest_fsp->conn, dest_fsp, &dest_lck);
-		SMB_VFS_STRICT_UNLOCK(src_fsp->conn, src_fsp, &src_lck);
-	}
 	if (ret < 0) {
 		/*
 		 * BTRFS_IOC_CLONE_RANGE only supports 'sectorsize' aligned
diff --git a/source3/modules/vfs_catia.c b/source3/modules/vfs_catia.c
index 6adf441..6e623bc 100644
--- a/source3/modules/vfs_catia.c
+++ b/source3/modules/vfs_catia.c
@@ -2390,23 +2390,6 @@ static bool catia_strict_lock(struct vfs_handle_struct *handle,
 	return ok;
 }
 
-static void catia_strict_unlock(struct vfs_handle_struct *handle,
-				struct files_struct *fsp,
-				struct lock_struct *plock)
-{
-	struct catia_cache *cc = NULL;
-	int ret;
-
-	ret = CATIA_FETCH_FSP_PRE_NEXT(talloc_tos(), handle, fsp, &cc);
-	if (ret != 0) {
-		smb_panic("CATIA_FETCH_FSP_PRE_NEXT failed\n");
-	}
-
-	SMB_VFS_NEXT_STRICT_UNLOCK(handle, fsp, plock);
-
-	CATIA_FETCH_FSP_POST_NEXT(&cc, fsp);
-}
-
 static NTSTATUS catia_fsctl(struct vfs_handle_struct *handle,
 			    struct files_struct *fsp,
 			    TALLOC_CTX *ctx,
@@ -2624,7 +2607,6 @@ static struct vfs_fn_pointers vfs_catia_fns = {
 	.chflags_fn = catia_chflags,
 	.streaminfo_fn = catia_streaminfo,
 	.strict_lock_fn = catia_strict_lock,
-	.strict_unlock_fn = catia_strict_unlock,
 	.translate_name_fn = catia_translate_name,
 	.fsctl_fn = catia_fsctl,
 	.get_dos_attributes_fn = catia_get_dos_attributes,
diff --git a/source3/modules/vfs_default.c b/source3/modules/vfs_default.c
index 111a0c3..a03fd8d 100644
--- a/source3/modules/vfs_default.c
+++ b/source3/modules/vfs_default.c
@@ -1686,9 +1686,7 @@ struct vfswrap_offload_write_state {
 	struct tevent_context *ev;
 	uint8_t *buf;
 	bool read_lck_locked;
-	struct lock_struct read_lck;
 	bool write_lck_locked;
-	struct lock_struct write_lck;
 	DATA_BLOB *token;
 	struct files_struct *src_fsp;
 	off_t src_off;
@@ -1827,6 +1825,7 @@ static NTSTATUS vfswrap_offload_write_loop(struct tevent_req *req)
 	struct vfswrap_offload_write_state *state = tevent_req_data(
 		req, struct vfswrap_offload_write_state);
 	struct tevent_req *subreq = NULL;
+	struct lock_struct read_lck;
 	bool ok;
 
 	state->next_io_size = MIN(state->remaining, talloc_array_length(state->buf));
@@ -1836,11 +1835,11 @@ static NTSTATUS vfswrap_offload_write_loop(struct tevent_req *req)
 				state->src_off,
 				state->next_io_size,
 				READ_LOCK,
-				&state->read_lck);
+				&read_lck);
 
 	ok = SMB_VFS_STRICT_LOCK(state->src_fsp->conn,
 				 state->src_fsp,
-				 &state->read_lck);
+				 &read_lck);
 	if (!ok) {
 		return NT_STATUS_FILE_LOCK_CONFLICT;
 	}
@@ -1868,14 +1867,10 @@ static void vfswrap_offload_write_read_done(struct tevent_req *subreq)
 	struct vfswrap_offload_write_state *state = tevent_req_data(
 		req, struct vfswrap_offload_write_state);
 	struct vfs_aio_state aio_state;
+	struct lock_struct write_lck;
 	ssize_t nread;
 	bool ok;
 
-	SMB_VFS_STRICT_UNLOCK(state->src_fsp->conn,
-			      state->src_fsp,
-			      &state->read_lck);
-	ZERO_STRUCT(state->read_lck);
-
 	nread = SMB_VFS_PREAD_RECV(subreq, &aio_state);
 	TALLOC_FREE(subreq);
 	if (nread == -1) {
@@ -1897,11 +1892,11 @@ static void vfswrap_offload_write_read_done(struct tevent_req *subreq)
 				state->dst_off,
 				state->next_io_size,
 				WRITE_LOCK,
-				&state->write_lck);
+				&write_lck);
 
 	ok = SMB_VFS_STRICT_LOCK(state->dst_fsp->conn,
 				 state->dst_fsp,
-				 &state->write_lck);
+				 &write_lck);
 	if (!ok) {
 		tevent_req_nterror(req, NT_STATUS_FILE_LOCK_CONFLICT);
 		return;
@@ -1930,11 +1925,6 @@ static void vfswrap_offload_write_write_done(struct tevent_req *subreq)
 	ssize_t nwritten;
 	NTSTATUS status;
 
-	SMB_VFS_STRICT_UNLOCK(state->dst_fsp->conn,
-			      state->dst_fsp,
-			      &state->write_lck);
-	ZERO_STRUCT(state->write_lck);
-
 	nwritten = SMB_VFS_PWRITE_RECV(subreq, &aio_state);
 	TALLOC_FREE(subreq);
 	if (nwritten == -1) {
@@ -2760,16 +2750,6 @@ static bool vfswrap_strict_lock(struct vfs_handle_struct *handle,
 	return strict_lock_default(fsp, plock);
 }
 
-static void vfswrap_strict_unlock(struct vfs_handle_struct *handle,
-				files_struct *fsp,
-				struct lock_struct *plock)
-{
-	SMB_ASSERT(plock->lock_type == READ_LOCK ||
-	    plock->lock_type == WRITE_LOCK);
-
-	strict_unlock_default(fsp, plock);
-}
-
 /* NT ACL operations. */
 
 static NTSTATUS vfswrap_fget_nt_acl(vfs_handle_struct *handle,
@@ -3099,7 +3079,6 @@ static struct vfs_fn_pointers vfs_default_fns = {
 	.brl_unlock_windows_fn = vfswrap_brl_unlock_windows,
 	.brl_cancel_windows_fn = vfswrap_brl_cancel_windows,
 	.strict_lock_fn = vfswrap_strict_lock,
-	.strict_unlock_fn = vfswrap_strict_unlock,
 	.translate_name_fn = vfswrap_translate_name,
 	.fsctl_fn = vfswrap_fsctl,
 	.set_dos_attributes_fn = vfswrap_set_dos_attributes,
diff --git a/source3/modules/vfs_full_audit.c b/source3/modules/vfs_full_audit.c
index bd31fad..af5c2c6 100644
--- a/source3/modules/vfs_full_audit.c
+++ b/source3/modules/vfs_full_audit.c
@@ -165,7 +165,6 @@ typedef enum _vfs_op_type {
 	SMB_VFS_OP_BRL_UNLOCK_WINDOWS,
 	SMB_VFS_OP_BRL_CANCEL_WINDOWS,
 	SMB_VFS_OP_STRICT_LOCK,
-	SMB_VFS_OP_STRICT_UNLOCK,
 	SMB_VFS_OP_TRANSLATE_NAME,
 	SMB_VFS_OP_FSCTL,
 	SMB_VFS_OP_OFFLOAD_READ_SEND,
@@ -309,7 +308,6 @@ static struct {
 	{ SMB_VFS_OP_BRL_UNLOCK_WINDOWS, "brl_unlock_windows" },
 	{ SMB_VFS_OP_BRL_CANCEL_WINDOWS, "brl_cancel_windows" },
 	{ SMB_VFS_OP_STRICT_LOCK, "strict_lock" },
-	{ SMB_VFS_OP_STRICT_UNLOCK, "strict_unlock" },
 	{ SMB_VFS_OP_TRANSLATE_NAME,	"translate_name" },
 	{ SMB_VFS_OP_FSCTL,		"fsctl" },
 	{ SMB_VFS_OP_OFFLOAD_READ_SEND,	"offload_read_send" },
@@ -1849,17 +1847,6 @@ static bool smb_full_audit_strict_lock(struct vfs_handle_struct *handle,
 	return result;
 }
 
-static void smb_full_audit_strict_unlock(struct vfs_handle_struct *handle,
-					 struct files_struct *fsp,
-					 struct lock_struct *plock)
-{
-	SMB_VFS_NEXT_STRICT_UNLOCK(handle, fsp, plock);
-
-	do_log(SMB_VFS_OP_STRICT_UNLOCK, true, handle,
-	    "%s:%llu-%llu:%d", fsp_str_do_log(fsp), plock->start,
-	    plock->size, plock->lock_type);
-}
-
 static NTSTATUS smb_full_audit_translate_name(struct vfs_handle_struct *handle,
 					      const char *name,
 					      enum vfs_translate_direction direction,
@@ -2590,7 +2577,6 @@ static struct vfs_fn_pointers vfs_full_audit_fns = {
 	.brl_unlock_windows_fn = smb_full_audit_brl_unlock_windows,
 	.brl_cancel_windows_fn = smb_full_audit_brl_cancel_windows,
 	.strict_lock_fn = smb_full_audit_strict_lock,
-	.strict_unlock_fn = smb_full_audit_strict_unlock,
 	.translate_name_fn = smb_full_audit_translate_name,
 	.fsctl_fn = smb_full_audit_fsctl,
 	.get_dos_attributes_fn = smb_full_audit_get_dos_attributes,
diff --git a/source3/modules/vfs_glusterfs.c b/source3/modules/vfs_glusterfs.c
index 1dafe8d..662892b 100644
--- a/source3/modules/vfs_glusterfs.c
+++ b/source3/modules/vfs_glusterfs.c
@@ -1481,7 +1481,6 @@ static struct vfs_fn_pointers glusterfs_fns = {
 	.brl_unlock_windows_fn = NULL,
 	.brl_cancel_windows_fn = NULL,
 	.strict_lock_fn = NULL,
-	.strict_unlock_fn = NULL,
 	.translate_name_fn = NULL,
 	.fsctl_fn = NULL,
 
diff --git a/source3/modules/vfs_time_audit.c b/source3/modules/vfs_time_audit.c
index 164f56d..5985394 100644
--- a/source3/modules/vfs_time_audit.c
+++ b/source3/modules/vfs_time_audit.c
@@ -1730,23 +1730,6 @@ static bool smb_time_audit_strict_lock(struct vfs_handle_struct *handle,
 	return result;
 }
 
-static void smb_time_audit_strict_unlock(struct vfs_handle_struct *handle,
-					 struct files_struct *fsp,
-					 struct lock_struct *plock)
-{
-	struct timespec ts1,ts2;
-	double timediff;
-
-	clock_gettime_mono(&ts1);
-	SMB_VFS_NEXT_STRICT_UNLOCK(handle, fsp, plock);
-	clock_gettime_mono(&ts2);
-	timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
-
-	if (timediff > audit_timeout) {
-		smb_time_audit_log_fsp("strict_unlock", timediff, fsp);
-	}
-}
-
 static NTSTATUS smb_time_audit_translate_name(struct vfs_handle_struct *handle,
 					      const char *name,
 					      enum vfs_translate_direction direction,
@@ -2786,7 +2769,6 @@ static struct vfs_fn_pointers vfs_time_audit_fns = {
 	.brl_unlock_windows_fn = smb_time_audit_brl_unlock_windows,
 	.brl_cancel_windows_fn = smb_time_audit_brl_cancel_windows,
 	.strict_lock_fn = smb_time_audit_strict_lock,
-	.strict_unlock_fn = smb_time_audit_strict_unlock,
 	.translate_name_fn = smb_time_audit_translate_name,
 	.fsctl_fn = smb_time_audit_fsctl,
 	.get_dos_attributes_fn = smb_time_get_dos_attributes,
diff --git a/source3/smbd/aio.c b/source3/smbd/aio.c
index ff1be13..a9d6c0a 100644
--- a/source3/smbd/aio.c
+++ b/source3/smbd/aio.c
@@ -242,7 +242,6 @@ NTSTATUS schedule_aio_read_and_X(connection_struct *conn,
 	if (req == NULL) {
 		DEBUG(0,("schedule_aio_read_and_X: aio_read failed. "
 			 "Error %s\n", strerror(errno) ));
-		SMB_VFS_STRICT_UNLOCK(conn, fsp, &aio_ex->lock);
 		TALLOC_FREE(aio_ex);
 		return NT_STATUS_RETRY;
 	}
@@ -250,7 +249,6 @@ NTSTATUS schedule_aio_read_and_X(connection_struct *conn,
 
 	if (!aio_add_req_to_fsp(fsp, req)) {
 		DEBUG(1, ("Could not add req to fsp\n"));
-		SMB_VFS_STRICT_UNLOCK(conn, fsp, &aio_ex->lock);
 		TALLOC_FREE(aio_ex);
 		return NT_STATUS_RETRY;
 	}
@@ -289,9 +287,6 @@ static void aio_pread_smb1_done(struct tevent_req *req)
 		return;
 	}
 
-	/* Unlock now we're done. */
-	SMB_VFS_STRICT_UNLOCK(fsp->conn, fsp, &aio_ex->lock);
-
 	if (nread < 0) {
 		DEBUG( 3, ("handle_aio_read_complete: file %s nread == %d. "
 			   "Error = %s\n", fsp_str_dbg(fsp), (int)nread,
@@ -491,7 +486,6 @@ NTSTATUS schedule_aio_write_and_X(connection_struct *conn,
 	if (req == NULL) {
 		DEBUG(3,("schedule_aio_wrote_and_X: aio_write failed. "
 			 "Error %s\n", strerror(errno) ));
-		SMB_VFS_STRICT_UNLOCK(conn, fsp, &aio_ex->lock);
 		TALLOC_FREE(aio_ex);
 		return NT_STATUS_RETRY;
 	}
@@ -499,7 +493,6 @@ NTSTATUS schedule_aio_write_and_X(connection_struct *conn,
 
 	if (!aio_add_req_to_fsp(fsp, req)) {
 		DEBUG(1, ("Could not add req to fsp\n"));
-		SMB_VFS_STRICT_UNLOCK(conn, fsp, &aio_ex->lock);
 		TALLOC_FREE(aio_ex);
 		return NT_STATUS_RETRY;
 	}
@@ -563,9 +556,6 @@ static void aio_pwrite_smb1_done(struct tevent_req *req)
 		return;
 	}
 
-	/* Unlock now we're done. */
-	SMB_VFS_STRICT_UNLOCK(fsp->conn, fsp, &aio_ex->lock);
-
 	mark_file_modified(fsp);
 
 	if (fsp->aio_write_behind) {
@@ -735,7 +725,6 @@ NTSTATUS schedule_smb2_aio_read(connection_struct *conn,
 	if (req == NULL) {
 		DEBUG(0, ("smb2: SMB_VFS_PREAD_SEND failed. "
 			  "Error %s\n", strerror(errno)));
-		SMB_VFS_STRICT_UNLOCK(conn, fsp, &aio_ex->lock);
 		TALLOC_FREE(aio_ex);
 		return NT_STATUS_RETRY;
 	}
@@ -743,7 +732,6 @@ NTSTATUS schedule_smb2_aio_read(connection_struct *conn,
 
 	if (!aio_add_req_to_fsp(fsp, req)) {
 		DEBUG(1, ("Could not add req to fsp\n"));
-		SMB_VFS_STRICT_UNLOCK(conn, fsp, &aio_ex->lock);
 		TALLOC_FREE(aio_ex);
 		return NT_STATUS_RETRY;
 	}
@@ -785,9 +773,6 @@ static void aio_pread_smb2_done(struct tevent_req *req)
 		return;
 	}
 
-	/* Unlock now we're done. */
-	SMB_VFS_STRICT_UNLOCK(fsp->conn, fsp, &aio_ex->lock);
-
 	/* Common error or success code processing for async or sync
 	   read returns. */
 
@@ -886,7 +871,6 @@ NTSTATUS schedule_aio_smb2_write(connection_struct *conn,
 	if (req == NULL) {
 		DEBUG(3, ("smb2: SMB_VFS_PWRITE_SEND failed. "
 			  "Error %s\n", strerror(errno)));
-		SMB_VFS_STRICT_UNLOCK(conn, fsp, &aio_ex->lock);
 		TALLOC_FREE(aio_ex);
 		return NT_STATUS_RETRY;
 	}
@@ -894,7 +878,6 @@ NTSTATUS schedule_aio_smb2_write(connection_struct *conn,
 
 	if (!aio_add_req_to_fsp(fsp, req)) {
 		DEBUG(1, ("Could not add req to fsp\n"));
-		SMB_VFS_STRICT_UNLOCK(conn, fsp, &aio_ex->lock);
 		TALLOC_FREE(aio_ex);
 		return NT_STATUS_RETRY;
 	}
@@ -951,9 +934,6 @@ static void aio_pwrite_smb2_done(struct tevent_req *req)
 		return;
 	}
 
-	/* Unlock now we're done. */
-	SMB_VFS_STRICT_UNLOCK(fsp->conn, fsp, &aio_ex->lock);
-
 	mark_file_modified(fsp);
 
         status = smb2_write_complete_nosync(subreq, nwritten, err);
diff --git a/source3/smbd/reply.c b/source3/smbd/reply.c
index e430a8e..85d7b5a 100644
--- a/source3/smbd/reply.c
+++ b/source3/smbd/reply.c
@@ -3711,8 +3711,6 @@ void reply_readbraw(struct smb_request *req)
 
 	DEBUG(5,("reply_readbraw finished\n"));
 
-	SMB_VFS_STRICT_UNLOCK(conn, fsp, &lock);
-
 	END_PROFILE(SMBreadbraw);
 	return;
 }
@@ -3903,7 +3901,7 @@ Returning short read of maximum allowed for compatibility with Windows 2000.\n",
 
 	if (nread < 0) {
 		reply_nterror(req, map_nt_error_from_unix(errno));
-		goto strict_unlock;
+		goto out;
 	}
 
 	srv_set_message((char *)req->outbuf, 5, nread+3, False);
@@ -3916,9 +3914,7 @@ Returning short read of maximum allowed for compatibility with Windows 2000.\n",
 	DEBUG(3, ("read %s num=%d nread=%d\n",
 		  fsp_fnum_dbg(fsp), (int)numtoread, (int)nread));
 
-strict_unlock:
-	SMB_VFS_STRICT_UNLOCK(conn, fsp, &lock);
-
+out:
 	END_PROFILE(SMBread);
 	return;
 }
@@ -3991,7 +3987,7 @@ static void send_file_readX(connection_struct *conn, struct smb_request *req,
 
 		if(fsp_stat(fsp) == -1) {
 			reply_nterror(req, map_nt_error_from_unix(errno));
-			goto strict_unlock;
+			goto out;
 		}
 
 		if (!S_ISREG(fsp->fsp_name->st.st_ex_mode) ||
@@ -4053,7 +4049,7 @@ static void send_file_readX(connection_struct *conn, struct smb_request *req,
 				DEBUG(3, ("send_file_readX: fake_sendfile %s max=%d nread=%d\n",
 					  fsp_fnum_dbg(fsp), (int)smb_maxcnt, (int)nread));
 				/* No outbuf here means successful sendfile. */
-				goto strict_unlock;
+				goto out;
 			}
 
 			DEBUG(0,("send_file_readX: sendfile failed for file "
@@ -4094,7 +4090,7 @@ static void send_file_readX(connection_struct *conn, struct smb_request *req,
 		/* No outbuf here means successful sendfile. */
 		SMB_PERFCOUNT_SET_MSGLEN_OUT(&req->pcd, nread);
 		SMB_PERFCOUNT_END(&req->pcd);
-		goto strict_unlock;
+		goto out;
 	}
 
 normal_read:
@@ -4144,7 +4140,7 @@ normal_read:
 			errno = saved_errno;
 			exit_server_cleanly("send_file_readX: fake_sendfile failed");
 		}
-		goto strict_unlock;
+		goto out;
 	}
 
 nosendfile_read:
@@ -4157,8 +4153,6 @@ nosendfile_read:
 			  startpos, smb_maxcnt);
 	saved_errno = errno;
 
-	SMB_VFS_STRICT_UNLOCK(conn, fsp, &lock);
-
 	if (nread < 0) {
 		reply_nterror(req, map_nt_error_from_unix(saved_errno));
 		return;
@@ -4170,8 +4164,7 @@ nosendfile_read:
 		  fsp_fnum_dbg(fsp), (int)smb_maxcnt, (int)nread));
 	return;
 
- strict_unlock:
-	SMB_VFS_STRICT_UNLOCK(conn, fsp, &lock);
+out:
 	TALLOC_FREE(req->outbuf);
 	return;
 }
@@ -4513,7 +4506,7 @@ void reply_writebraw(struct smb_request *req)
 	if (nwritten < (ssize_t)numtowrite)  {
 		reply_nterror(req, NT_STATUS_DISK_FULL);
 		error_to_writebrawerr(req);
-		goto strict_unlock;
+		goto out;
 	}
 
 	total_written = nwritten;
@@ -4523,7 +4516,7 @@ void reply_writebraw(struct smb_request *req)
 	if (!buf) {
 		reply_nterror(req, NT_STATUS_NO_MEMORY);
 		error_to_writebrawerr(req);
-		goto strict_unlock;
+		goto out;
 	}
 
 	/* Return a SMBwritebraw message to the redirector to tell
@@ -4586,7 +4579,7 @@ void reply_writebraw(struct smb_request *req)
 			TALLOC_FREE(buf);
 			reply_nterror(req, map_nt_error_from_unix(errno));
 			error_to_writebrawerr(req);
-			goto strict_unlock;
+			goto out;
 		}
 
 		if (nwritten < (ssize_t)numtowrite) {
@@ -4608,7 +4601,7 @@ void reply_writebraw(struct smb_request *req)
 			 fsp_str_dbg(fsp), nt_errstr(status)));
 		reply_nterror(req, status);
 		error_to_writebrawerr(req);
-		goto strict_unlock;
+		goto out;
 	}
 
 	DEBUG(3,("reply_writebraw: secondart write %s start=%.0f num=%d "
@@ -4616,10 +4609,6 @@ void reply_writebraw(struct smb_request *req)
 		fsp_fnum_dbg(fsp), (double)startpos, (int)numtowrite,
 		(int)total_written));
 
-	if (!fsp->print_file) {
-		SMB_VFS_STRICT_UNLOCK(conn, fsp, &lock);
-	}
-
 	/* We won't return a status if write through is not selected - this
 	 * follows what WfWg does */
 	END_PROFILE(SMBwritebraw);
@@ -4641,11 +4630,7 @@ void reply_writebraw(struct smb_request *req)
 	}
 	return;
 
-strict_unlock:
-	if (!fsp->print_file) {
-		SMB_VFS_STRICT_UNLOCK(conn, fsp, &lock);
-	}
-
+out:
 	END_PROFILE(SMBwritebraw);
 	return;
 }
@@ -4721,17 +4706,17 @@ void reply_writeunlock(struct smb_request *req)
 		DEBUG(5,("reply_writeunlock: sync_file for %s returned %s\n",
 			 fsp_str_dbg(fsp), nt_errstr(status)));
 		reply_nterror(req, status);
-		goto strict_unlock;
+		goto out;
 	}
 
 	if(nwritten < 0) {
 		reply_nterror(req, map_nt_error_from_unix(saved_errno));
-		goto strict_unlock;
+		goto out;
 	}
 
 	if((nwritten < numtowrite) && (numtowrite != 0)) {
 		reply_nterror(req, NT_STATUS_DISK_FULL);
-		goto strict_unlock;
+		goto out;
 	}
 
 	if (numtowrite && !fsp->print_file) {
@@ -4744,7 +4729,7 @@ void reply_writeunlock(struct smb_request *req)
 
 		if (NT_STATUS_V(status)) {
 			reply_nterror(req, status);
-			goto strict_unlock;
+			goto out;
 		}
 	}
 
@@ -4755,11 +4740,7 @@ void reply_writeunlock(struct smb_request *req)
 	DEBUG(3, ("writeunlock %s num=%d wrote=%d\n",
 		  fsp_fnum_dbg(fsp), (int)numtowrite, (int)nwritten));
 
-strict_unlock:
-	if (numtowrite && !fsp->print_file) {
-		SMB_VFS_STRICT_UNLOCK(conn, fsp, &lock);
-	}
-
+out:
 	END_PROFILE(SMBwriteunlock);
 	return;
 }
@@ -4840,12 +4821,12 @@ void reply_write(struct smb_request *req)
 		nwritten = vfs_allocate_file_space(fsp, (off_t)startpos);
 		if (nwritten < 0) {
 			reply_nterror(req, NT_STATUS_DISK_FULL);
-			goto strict_unlock;
+			goto out;
 		}
 		nwritten = vfs_set_filelen(fsp, (off_t)startpos);
 		if (nwritten < 0) {
 			reply_nterror(req, NT_STATUS_DISK_FULL);
-			goto strict_unlock;
+			goto out;
 		}
 		trigger_write_time_update_immediate(fsp);
 	} else {
@@ -4857,17 +4838,17 @@ void reply_write(struct smb_request *req)
 		DEBUG(5,("reply_write: sync_file for %s returned %s\n",
 			 fsp_str_dbg(fsp), nt_errstr(status)));
 		reply_nterror(req, status);
-		goto strict_unlock;
+		goto out;
 	}
 
 	if(nwritten < 0) {
 		reply_nterror(req, map_nt_error_from_unix(saved_errno));
-		goto strict_unlock;
+		goto out;
 	}
 
 	if((nwritten == 0) && (numtowrite != 0)) {
 		reply_nterror(req, NT_STATUS_DISK_FULL);
-		goto strict_unlock;
+		goto out;
 	}
 
 	reply_outbuf(req, 1, 0);
@@ -4881,11 +4862,7 @@ void reply_write(struct smb_request *req)
 
 	DEBUG(3, ("write %s num=%d wrote=%d\n", fsp_fnum_dbg(fsp), (int)numtowrite, (int)nwritten));
 
-strict_unlock:
-	if (!fsp->print_file) {
-		SMB_VFS_STRICT_UNLOCK(conn, fsp, &lock);
-	}
-
+out:
 	END_PROFILE(SMBwrite);
 	return;
 }
@@ -5120,8 +5097,6 @@ void reply_write_and_X(struct smb_request *req)
 
 		nwritten = write_file(req,fsp,data,startpos,numtowrite);
 		saved_errno = errno;
-
-		SMB_VFS_STRICT_UNLOCK(conn, fsp, &lock);
 	}
 
 	if(nwritten < 0) {
@@ -5516,10 +5491,6 @@ void reply_writeclose(struct smb_request *req)
 
 	nwritten = write_file(req,fsp,data,startpos,numtowrite);
 
-	if (fsp->print_file == NULL) {
-		SMB_VFS_STRICT_UNLOCK(conn, fsp, &lock);
-	}
-
 	set_close_write_time(fsp, mtime);
 
 	/*
diff --git a/source3/smbd/smb2_ioctl_filesys.c b/source3/smbd/smb2_ioctl_filesys.c
index 732e3ab..054fd93 100644
--- a/source3/smbd/smb2_ioctl_filesys.c
+++ b/source3/smbd/smb2_ioctl_filesys.c
@@ -503,7 +503,6 @@ static NTSTATUS fsctl_zero_data(TALLOC_CTX *mem_ctx,
 		status = map_nt_error_from_unix_common(errno);
 		DEBUG(2, ("zero-data fallocate(0x%x) failed: %s\n", mode,
 		      strerror(errno)));
-		SMB_VFS_STRICT_UNLOCK(fsp->conn, fsp, &lck);
 		return status;
 	}
 
@@ -522,12 +521,10 @@ static NTSTATUS fsctl_zero_data(TALLOC_CTX *mem_ctx,
 		if (ret == -1)  {
 			status = map_nt_error_from_unix_common(errno);
 			DEBUG(0, ("fallocate failed: %s\n", strerror(errno)));
-			SMB_VFS_STRICT_UNLOCK(fsp->conn, fsp, &lck);
 			return status;
 		}
 	}
 
-	SMB_VFS_STRICT_UNLOCK(fsp->conn, fsp, &lck);
 	return NT_STATUS_OK;
 }
 
diff --git a/source3/smbd/smb2_read.c b/source3/smbd/smb2_read.c
index d639bbf..6aa62cd 100644
--- a/source3/smbd/smb2_read.c
+++ b/source3/smbd/smb2_read.c
@@ -324,8 +324,6 @@ normal_read:
 				READ_LOCK,
 				&lock);
 
-	SMB_VFS_STRICT_UNLOCK(fsp->conn, fsp, &lock);
-
 	*pstatus = NT_STATUS_OK;
 	return 0;
 }
@@ -557,7 +555,6 @@ static struct tevent_req *smbd_smb2_read_send(TALLOC_CTX *mem_ctx,
 		return tevent_req_post(req, ev);
 	} else {
 		if (!NT_STATUS_EQUAL(status, NT_STATUS_RETRY)) {
-			SMB_VFS_STRICT_UNLOCK(conn, fsp, &lock);
 			tevent_req_nterror(req, status);
 			return tevent_req_post(req, ev);
 		}
@@ -566,7 +563,6 @@ static struct tevent_req *smbd_smb2_read_send(TALLOC_CTX *mem_ctx,
 	/* Ok, read into memory. Allocate the out buffer. */
 	state->out_data = data_blob_talloc(state, NULL, in_length);
 	if (in_length > 0 && tevent_req_nomem(state->out_data.data, req)) {
-		SMB_VFS_STRICT_UNLOCK(conn, fsp, &lock);
 		return tevent_req_post(req, ev);
 	}
 
@@ -577,8 +573,6 @@ static struct tevent_req *smbd_smb2_read_send(TALLOC_CTX *mem_ctx,
 
 	saved_errno = errno;
 
-	SMB_VFS_STRICT_UNLOCK(conn, fsp, &lock);
-
 	DEBUG(10,("smbd_smb2_read: file %s, %s, offset=%llu "
 		"len=%llu returned %lld\n",
 		fsp_str_dbg(fsp),
diff --git a/source3/smbd/smb2_write.c b/source3/smbd/smb2_write.c
index da583c9..a8ebac8 100644
--- a/source3/smbd/smb2_write.c
+++ b/source3/smbd/smb2_write.c
@@ -369,8 +369,6 @@ static struct tevent_req *smbd_smb2_write_send(TALLOC_CTX *mem_ctx,
 
 	status = smb2_write_complete(req, nwritten, errno);
 
-	SMB_VFS_STRICT_UNLOCK(conn, fsp, &lock);
-
 	DEBUG(10,("smb2: write on "
 		"file %s, offset %.0f, requested %u, written = %u\n",
 		fsp_str_dbg(fsp),
diff --git a/source3/smbd/vfs.c b/source3/smbd/vfs.c
index 67b79ef..f2861e2 100644
--- a/source3/smbd/vfs.c
+++ b/source3/smbd/vfs.c
@@ -2282,14 +2282,6 @@ bool smb_vfs_call_strict_lock(struct vfs_handle_struct *handle,
 	return handle->fns->strict_lock_fn(handle, fsp, plock);
 }
 
-void smb_vfs_call_strict_unlock(struct vfs_handle_struct *handle,
-				struct files_struct *fsp,
-				struct lock_struct *plock)
-{
-	VFS_FIND(strict_unlock);
-	handle->fns->strict_unlock_fn(handle, fsp, plock);
-}
-
 NTSTATUS smb_vfs_call_translate_name(struct vfs_handle_struct *handle,
 				     const char *name,
 				     enum vfs_translate_direction direction,
-- 
2.9.4


From e0240b04560954e01dcb5dfa7a542702cf5c5887 Mon Sep 17 00:00:00 2001
From: Ralph Boehme <slow at samba.org>
Date: Sun, 9 Jul 2017 14:34:10 +0200
Subject: [PATCH 2/2] s3/vfs: rename SMB_VFS_STRICT_LOCK to
 SMB_VFS_STRICT_LOCK_CHECK

As per MS-SMB2 and MS-FSA and our SMB_VFS_STRICT_LOCK implementation,
we're merely testing for locks, not setting any.

Bug: https://bugzilla.samba.org/show_bug.cgi?id=12887

Signed-off-by: Ralph Boehme <slow at samba.org>
---
 examples/VFS/skel_opaque.c        |  8 ++++----
 examples/VFS/skel_transparent.c   | 10 +++++-----
 source3/include/vfs.h             | 14 ++++++++------
 source3/include/vfs_macros.h      |  8 ++++----
 source3/locking/locking.c         |  2 +-
 source3/locking/proto.h           |  4 ++--
 source3/modules/vfs_btrfs.c       |  4 ++--
 source3/modules/vfs_catia.c       | 10 +++++-----
 source3/modules/vfs_default.c     | 14 +++++++-------
 source3/modules/vfs_full_audit.c  | 16 ++++++++--------
 source3/modules/vfs_glusterfs.c   |  2 +-
 source3/modules/vfs_time_audit.c  | 12 ++++++------
 source3/smbd/aio.c                |  8 ++++----
 source3/smbd/reply.c              | 16 ++++++++--------
 source3/smbd/smb2_ioctl_filesys.c |  2 +-
 source3/smbd/smb2_read.c          |  2 +-
 source3/smbd/smb2_write.c         |  2 +-
 source3/smbd/vfs.c                | 10 +++++-----
 18 files changed, 73 insertions(+), 71 deletions(-)

diff --git a/examples/VFS/skel_opaque.c b/examples/VFS/skel_opaque.c
index 072ec80..614dcff 100644
--- a/examples/VFS/skel_opaque.c
+++ b/examples/VFS/skel_opaque.c
@@ -687,9 +687,9 @@ static bool skel_brl_cancel_windows(struct vfs_handle_struct *handle,
 	return false;
 }
 
-static bool skel_strict_lock(struct vfs_handle_struct *handle,
-			     struct files_struct *fsp,
-			     struct lock_struct *plock)
+static bool skel_strict_lock_check(struct vfs_handle_struct *handle,
+				   struct files_struct *fsp,
+				   struct lock_struct *plock)
 {
 	errno = ENOSYS;
 	return false;
@@ -1015,7 +1015,7 @@ struct vfs_fn_pointers skel_opaque_fns = {
 	.brl_lock_windows_fn = skel_brl_lock_windows,
 	.brl_unlock_windows_fn = skel_brl_unlock_windows,
 	.brl_cancel_windows_fn = skel_brl_cancel_windows,
-	.strict_lock_fn = skel_strict_lock,
+	.strict_lock_check_fn = skel_strict_lock_check,
 	.translate_name_fn = skel_translate_name,
 	.fsctl_fn = skel_fsctl,
 	.readdir_attr_fn = skel_readdir_attr,
diff --git a/examples/VFS/skel_transparent.c b/examples/VFS/skel_transparent.c
index 9592c17..2f59a3d 100644
--- a/examples/VFS/skel_transparent.c
+++ b/examples/VFS/skel_transparent.c
@@ -856,11 +856,11 @@ static bool skel_brl_cancel_windows(struct vfs_handle_struct *handle,
 	return SMB_VFS_NEXT_BRL_CANCEL_WINDOWS(handle, br_lck, plock);
 }
 
-static bool skel_strict_lock(struct vfs_handle_struct *handle,
-			     struct files_struct *fsp,
-			     struct lock_struct *plock)
+static bool skel_strict_lock_check(struct vfs_handle_struct *handle,
+				   struct files_struct *fsp,
+				   struct lock_struct *plock)
 {
-	return SMB_VFS_NEXT_STRICT_LOCK(handle, fsp, plock);
+	return SMB_VFS_NEXT_STRICT_LOCK_CHECK(handle, fsp, plock);
 }
 
 static NTSTATUS skel_translate_name(struct vfs_handle_struct *handle,
@@ -1188,7 +1188,7 @@ struct vfs_fn_pointers skel_transparent_fns = {
 	.brl_lock_windows_fn = skel_brl_lock_windows,
 	.brl_unlock_windows_fn = skel_brl_unlock_windows,
 	.brl_cancel_windows_fn = skel_brl_cancel_windows,
-	.strict_lock_fn = skel_strict_lock,
+	.strict_lock_check_fn = skel_strict_lock_check,
 	.translate_name_fn = skel_translate_name,
 	.fsctl_fn = skel_fsctl,
 	.readdir_attr_fn = skel_readdir_attr,
diff --git a/source3/include/vfs.h b/source3/include/vfs.h
index bd00e8f..d71d7cc 100644
--- a/source3/include/vfs.h
+++ b/source3/include/vfs.h
@@ -242,6 +242,8 @@
 /* Version 37 - Rename SMB_VFS_COPY_CHUNK_SEND/RECV to
                 SMB_VFS_OFFLOAD_READ_SEND/RECV */
 /* Version 37 - Remove SMB_VFS_STRICT_UNLOCK */
+/* Version 37 - Rename SMB_VFS_STRICT_LOCK to
+                SMB_VFS_STRICT_LOCK_CHECK */
 
 #define SMB_VFS_INTERFACE_VERSION 37
 
@@ -849,9 +851,9 @@ struct vfs_fn_pointers {
 				      struct byte_range_lock *br_lck,
 				      struct lock_struct *plock);
 
-	bool (*strict_lock_fn)(struct vfs_handle_struct *handle,
-			       struct files_struct *fsp,
-			       struct lock_struct *plock);
+	bool (*strict_lock_check_fn)(struct vfs_handle_struct *handle,
+				     struct files_struct *fsp,
+				     struct lock_struct *plock);
 
 	NTSTATUS (*translate_name_fn)(struct vfs_handle_struct *handle,
 				      const char *name,
@@ -1312,9 +1314,9 @@ bool smb_vfs_call_brl_unlock_windows(struct vfs_handle_struct *handle,
 bool smb_vfs_call_brl_cancel_windows(struct vfs_handle_struct *handle,
 				     struct byte_range_lock *br_lck,
 				     struct lock_struct *plock);
-bool smb_vfs_call_strict_lock(struct vfs_handle_struct *handle,
-			      struct files_struct *fsp,
-			      struct lock_struct *plock);
+bool smb_vfs_call_strict_lock_check(struct vfs_handle_struct *handle,
+				    struct files_struct *fsp,
+				    struct lock_struct *plock);
 NTSTATUS smb_vfs_call_translate_name(struct vfs_handle_struct *handle,
 				     const char *name,
 				     enum vfs_translate_direction direction,
diff --git a/source3/include/vfs_macros.h b/source3/include/vfs_macros.h
index 843d626..3cce192 100644
--- a/source3/include/vfs_macros.h
+++ b/source3/include/vfs_macros.h
@@ -376,10 +376,10 @@
 #define SMB_VFS_NEXT_BRL_CANCEL_WINDOWS(handle, br_lck, plock) \
 	smb_vfs_call_brl_cancel_windows((handle)->next, (br_lck), (plock))
 
-#define SMB_VFS_STRICT_LOCK(conn, fsp, plock) \
-	smb_vfs_call_strict_lock((conn)->vfs_handles, (fsp), (plock))
-#define SMB_VFS_NEXT_STRICT_LOCK(handle, fsp, plock) \
-	smb_vfs_call_strict_lock((handle)->next, (fsp), (plock))
+#define SMB_VFS_STRICT_LOCK_CHECK(conn, fsp, plock) \
+	smb_vfs_call_strict_lock_check((conn)->vfs_handles, (fsp), (plock))
+#define SMB_VFS_NEXT_STRICT_LOCK_CHECK(handle, fsp, plock) \
+	smb_vfs_call_strict_lock_check((handle)->next, (fsp), (plock))
 
 #define SMB_VFS_TRANSLATE_NAME(conn, name, direction, mem_ctx, mapped_name) \
 	smb_vfs_call_translate_name((conn)->vfs_handles, (name), (direction), (mem_ctx), (mapped_name))
diff --git a/source3/locking/locking.c b/source3/locking/locking.c
index d344731..4e9f1bb 100644
--- a/source3/locking/locking.c
+++ b/source3/locking/locking.c
@@ -104,7 +104,7 @@ void init_strict_lock_struct(files_struct *fsp,
         plock->lock_flav = lp_posix_cifsu_locktype(fsp);
 }
 
-bool strict_lock_default(files_struct *fsp, struct lock_struct *plock)
+bool strict_lock_check_default(files_struct *fsp, struct lock_struct *plock)
 {
 	struct byte_range_lock *br_lck;
 	int strict_locking = lp_strict_locking(fsp->conn->params);
diff --git a/source3/locking/proto.h b/source3/locking/proto.h
index ebd80f2..33184e0 100644
--- a/source3/locking/proto.h
+++ b/source3/locking/proto.h
@@ -105,8 +105,8 @@ void init_strict_lock_struct(files_struct *fsp,
 				br_off size,
 				enum brl_type lock_type,
 				struct lock_struct *plock);
-bool strict_lock_default(files_struct *fsp,
-				struct lock_struct *plock);
+bool strict_lock_check_default(files_struct *fsp,
+			       struct lock_struct *plock);
 NTSTATUS query_lock(files_struct *fsp,
 			uint64_t *psmblctx,
 			uint64_t *pcount,
diff --git a/source3/modules/vfs_btrfs.c b/source3/modules/vfs_btrfs.c
index a90f583..13fd5e3 100644
--- a/source3/modules/vfs_btrfs.c
+++ b/source3/modules/vfs_btrfs.c
@@ -317,11 +317,11 @@ static struct tevent_req *btrfs_offload_write_send(struct vfs_handle_struct *han
 					WRITE_LOCK,
 					&dest_lck);
 
-		if (!SMB_VFS_STRICT_LOCK(src_fsp->conn, src_fsp, &src_lck)) {
+		if (!SMB_VFS_STRICT_LOCK_CHECK(src_fsp->conn, src_fsp, &src_lck)) {
 			tevent_req_nterror(req, NT_STATUS_FILE_LOCK_CONFLICT);
 			return tevent_req_post(req, ev);
 		}
-		if (!SMB_VFS_STRICT_LOCK(dest_fsp->conn, dest_fsp, &dest_lck)) {
+		if (!SMB_VFS_STRICT_LOCK_CHECK(dest_fsp->conn, dest_fsp, &dest_lck)) {
 			tevent_req_nterror(req, NT_STATUS_FILE_LOCK_CONFLICT);
 			return tevent_req_post(req, ev);
 		}
diff --git a/source3/modules/vfs_catia.c b/source3/modules/vfs_catia.c
index 6e623bc..5cf7476 100644
--- a/source3/modules/vfs_catia.c
+++ b/source3/modules/vfs_catia.c
@@ -2370,9 +2370,9 @@ static bool catia_getlock(vfs_handle_struct *handle,
 	return ok;
 }
 
-static bool catia_strict_lock(struct vfs_handle_struct *handle,
-			      struct files_struct *fsp,
-			      struct lock_struct *plock)
+static bool catia_strict_lock_check(struct vfs_handle_struct *handle,
+				    struct files_struct *fsp,
+				    struct lock_struct *plock)
 {
 	struct catia_cache *cc = NULL;
 	int ret;
@@ -2383,7 +2383,7 @@ static bool catia_strict_lock(struct vfs_handle_struct *handle,
 		return -1;
 	}
 
-	ok = SMB_VFS_NEXT_STRICT_LOCK(handle, fsp, plock);
+	ok = SMB_VFS_NEXT_STRICT_LOCK_CHECK(handle, fsp, plock);
 
 	CATIA_FETCH_FSP_POST_NEXT(&cc, fsp);
 
@@ -2606,7 +2606,7 @@ static struct vfs_fn_pointers vfs_catia_fns = {
 	.realpath_fn = catia_realpath,
 	.chflags_fn = catia_chflags,
 	.streaminfo_fn = catia_streaminfo,
-	.strict_lock_fn = catia_strict_lock,
+	.strict_lock_check_fn = catia_strict_lock_check,
 	.translate_name_fn = catia_translate_name,
 	.fsctl_fn = catia_fsctl,
 	.get_dos_attributes_fn = catia_get_dos_attributes,
diff --git a/source3/modules/vfs_default.c b/source3/modules/vfs_default.c
index a03fd8d..bf857b6 100644
--- a/source3/modules/vfs_default.c
+++ b/source3/modules/vfs_default.c
@@ -1837,7 +1837,7 @@ static NTSTATUS vfswrap_offload_write_loop(struct tevent_req *req)
 				READ_LOCK,
 				&read_lck);
 
-	ok = SMB_VFS_STRICT_LOCK(state->src_fsp->conn,
+	ok = SMB_VFS_STRICT_LOCK_CHECK(state->src_fsp->conn,
 				 state->src_fsp,
 				 &read_lck);
 	if (!ok) {
@@ -1894,7 +1894,7 @@ static void vfswrap_offload_write_read_done(struct tevent_req *subreq)
 				WRITE_LOCK,
 				&write_lck);
 
-	ok = SMB_VFS_STRICT_LOCK(state->dst_fsp->conn,
+	ok = SMB_VFS_STRICT_LOCK_CHECK(state->dst_fsp->conn,
 				 state->dst_fsp,
 				 &write_lck);
 	if (!ok) {
@@ -2740,14 +2740,14 @@ static bool vfswrap_brl_cancel_windows(struct vfs_handle_struct *handle,
 	return brl_lock_cancel_default(br_lck, plock);
 }
 
-static bool vfswrap_strict_lock(struct vfs_handle_struct *handle,
-				files_struct *fsp,
-				struct lock_struct *plock)
+static bool vfswrap_strict_lock_check(struct vfs_handle_struct *handle,
+				      files_struct *fsp,
+				      struct lock_struct *plock)
 {
 	SMB_ASSERT(plock->lock_type == READ_LOCK ||
 	    plock->lock_type == WRITE_LOCK);
 
-	return strict_lock_default(fsp, plock);
+	return strict_lock_check_default(fsp, plock);
 }
 
 /* NT ACL operations. */
@@ -3078,7 +3078,7 @@ static struct vfs_fn_pointers vfs_default_fns = {
 	.brl_lock_windows_fn = vfswrap_brl_lock_windows,
 	.brl_unlock_windows_fn = vfswrap_brl_unlock_windows,
 	.brl_cancel_windows_fn = vfswrap_brl_cancel_windows,
-	.strict_lock_fn = vfswrap_strict_lock,
+	.strict_lock_check_fn = vfswrap_strict_lock_check,
 	.translate_name_fn = vfswrap_translate_name,
 	.fsctl_fn = vfswrap_fsctl,
 	.set_dos_attributes_fn = vfswrap_set_dos_attributes,
diff --git a/source3/modules/vfs_full_audit.c b/source3/modules/vfs_full_audit.c
index af5c2c6..a205007 100644
--- a/source3/modules/vfs_full_audit.c
+++ b/source3/modules/vfs_full_audit.c
@@ -164,7 +164,7 @@ typedef enum _vfs_op_type {
 	SMB_VFS_OP_BRL_LOCK_WINDOWS,
 	SMB_VFS_OP_BRL_UNLOCK_WINDOWS,
 	SMB_VFS_OP_BRL_CANCEL_WINDOWS,
-	SMB_VFS_OP_STRICT_LOCK,
+	SMB_VFS_OP_STRICT_LOCK_CHECK,
 	SMB_VFS_OP_TRANSLATE_NAME,
 	SMB_VFS_OP_FSCTL,
 	SMB_VFS_OP_OFFLOAD_READ_SEND,
@@ -307,7 +307,7 @@ static struct {
 	{ SMB_VFS_OP_BRL_LOCK_WINDOWS,  "brl_lock_windows" },
 	{ SMB_VFS_OP_BRL_UNLOCK_WINDOWS, "brl_unlock_windows" },
 	{ SMB_VFS_OP_BRL_CANCEL_WINDOWS, "brl_cancel_windows" },
-	{ SMB_VFS_OP_STRICT_LOCK, "strict_lock" },
+	{ SMB_VFS_OP_STRICT_LOCK_CHECK, "strict_lock_check" },
 	{ SMB_VFS_OP_TRANSLATE_NAME,	"translate_name" },
 	{ SMB_VFS_OP_FSCTL,		"fsctl" },
 	{ SMB_VFS_OP_OFFLOAD_READ_SEND,	"offload_read_send" },
@@ -1832,15 +1832,15 @@ static bool smb_full_audit_brl_cancel_windows(struct vfs_handle_struct *handle,
 	return result;
 }
 
-static bool smb_full_audit_strict_lock(struct vfs_handle_struct *handle,
-				       struct files_struct *fsp,
-				       struct lock_struct *plock)
+static bool smb_full_audit_strict_lock_check(struct vfs_handle_struct *handle,
+					     struct files_struct *fsp,
+					     struct lock_struct *plock)
 {
 	bool result;
 
-	result = SMB_VFS_NEXT_STRICT_LOCK(handle, fsp, plock);
+	result = SMB_VFS_NEXT_STRICT_LOCK_CHECK(handle, fsp, plock);
 
-	do_log(SMB_VFS_OP_STRICT_LOCK, result, handle,
+	do_log(SMB_VFS_OP_STRICT_LOCK_CHECK, result, handle,
 	    "%s:%llu-%llu:%d", fsp_str_do_log(fsp), plock->start,
 	    plock->size, plock->lock_type);
 
@@ -2576,7 +2576,7 @@ static struct vfs_fn_pointers vfs_full_audit_fns = {
 	.brl_lock_windows_fn = smb_full_audit_brl_lock_windows,
 	.brl_unlock_windows_fn = smb_full_audit_brl_unlock_windows,
 	.brl_cancel_windows_fn = smb_full_audit_brl_cancel_windows,
-	.strict_lock_fn = smb_full_audit_strict_lock,
+	.strict_lock_check_fn = smb_full_audit_strict_lock_check,
 	.translate_name_fn = smb_full_audit_translate_name,
 	.fsctl_fn = smb_full_audit_fsctl,
 	.get_dos_attributes_fn = smb_full_audit_get_dos_attributes,
diff --git a/source3/modules/vfs_glusterfs.c b/source3/modules/vfs_glusterfs.c
index 662892b..91cf87f 100644
--- a/source3/modules/vfs_glusterfs.c
+++ b/source3/modules/vfs_glusterfs.c
@@ -1480,7 +1480,7 @@ static struct vfs_fn_pointers glusterfs_fns = {
 	.brl_lock_windows_fn = NULL,
 	.brl_unlock_windows_fn = NULL,
 	.brl_cancel_windows_fn = NULL,
-	.strict_lock_fn = NULL,
+	.strict_lock_check_fn = NULL,
 	.translate_name_fn = NULL,
 	.fsctl_fn = NULL,
 
diff --git a/source3/modules/vfs_time_audit.c b/source3/modules/vfs_time_audit.c
index 5985394..7116796 100644
--- a/source3/modules/vfs_time_audit.c
+++ b/source3/modules/vfs_time_audit.c
@@ -1710,21 +1710,21 @@ static bool smb_time_audit_brl_cancel_windows(struct vfs_handle_struct *handle,
 	return result;
 }
 
-static bool smb_time_audit_strict_lock(struct vfs_handle_struct *handle,
-				       struct files_struct *fsp,
-				       struct lock_struct *plock)
+static bool smb_time_audit_strict_lock_check(struct vfs_handle_struct *handle,
+					     struct files_struct *fsp,
+					     struct lock_struct *plock)
 {
 	bool result;
 	struct timespec ts1,ts2;
 	double timediff;
 
 	clock_gettime_mono(&ts1);
-	result = SMB_VFS_NEXT_STRICT_LOCK(handle, fsp, plock);
+	result = SMB_VFS_NEXT_STRICT_LOCK_CHECK(handle, fsp, plock);
 	clock_gettime_mono(&ts2);
 	timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
 
 	if (timediff > audit_timeout) {
-		smb_time_audit_log_fsp("strict_lock", timediff, fsp);
+		smb_time_audit_log_fsp("strict_lock_check", timediff, fsp);
 	}
 
 	return result;
@@ -2768,7 +2768,7 @@ static struct vfs_fn_pointers vfs_time_audit_fns = {
 	.brl_lock_windows_fn = smb_time_audit_brl_lock_windows,
 	.brl_unlock_windows_fn = smb_time_audit_brl_unlock_windows,
 	.brl_cancel_windows_fn = smb_time_audit_brl_cancel_windows,
-	.strict_lock_fn = smb_time_audit_strict_lock,
+	.strict_lock_check_fn = smb_time_audit_strict_lock_check,
 	.translate_name_fn = smb_time_audit_translate_name,
 	.fsctl_fn = smb_time_audit_fsctl,
 	.get_dos_attributes_fn = smb_time_get_dos_attributes,
diff --git a/source3/smbd/aio.c b/source3/smbd/aio.c
index a9d6c0a..f455d04 100644
--- a/source3/smbd/aio.c
+++ b/source3/smbd/aio.c
@@ -227,7 +227,7 @@ NTSTATUS schedule_aio_read_and_X(connection_struct *conn,
 		&aio_ex->lock);
 
 	/* Take the lock until the AIO completes. */
-	if (!SMB_VFS_STRICT_LOCK(conn, fsp, &aio_ex->lock)) {
+	if (!SMB_VFS_STRICT_LOCK_CHECK(conn, fsp, &aio_ex->lock)) {
 		TALLOC_FREE(aio_ex);
 		return NT_STATUS_FILE_LOCK_CONFLICT;
 	}
@@ -472,7 +472,7 @@ NTSTATUS schedule_aio_write_and_X(connection_struct *conn,
 		&aio_ex->lock);
 
 	/* Take the lock until the AIO completes. */
-	if (!SMB_VFS_STRICT_LOCK(conn, fsp, &aio_ex->lock)) {
+	if (!SMB_VFS_STRICT_LOCK_CHECK(conn, fsp, &aio_ex->lock)) {
 		TALLOC_FREE(aio_ex);
 		return NT_STATUS_FILE_LOCK_CONFLICT;
 	}
@@ -712,7 +712,7 @@ NTSTATUS schedule_smb2_aio_read(connection_struct *conn,
 		&aio_ex->lock);
 
 	/* Take the lock until the AIO completes. */
-	if (!SMB_VFS_STRICT_LOCK(conn, fsp, &aio_ex->lock)) {
+	if (!SMB_VFS_STRICT_LOCK_CHECK(conn, fsp, &aio_ex->lock)) {
 		TALLOC_FREE(aio_ex);
 		return NT_STATUS_FILE_LOCK_CONFLICT;
 	}
@@ -857,7 +857,7 @@ NTSTATUS schedule_aio_smb2_write(connection_struct *conn,
 		&aio_ex->lock);
 
 	/* Take the lock until the AIO completes. */
-	if (!SMB_VFS_STRICT_LOCK(conn, fsp, &aio_ex->lock)) {
+	if (!SMB_VFS_STRICT_LOCK_CHECK(conn, fsp, &aio_ex->lock)) {
 		TALLOC_FREE(aio_ex);
 		return NT_STATUS_FILE_LOCK_CONFLICT;
 	}
diff --git a/source3/smbd/reply.c b/source3/smbd/reply.c
index 85d7b5a..0846aff 100644
--- a/source3/smbd/reply.c
+++ b/source3/smbd/reply.c
@@ -3679,7 +3679,7 @@ void reply_readbraw(struct smb_request *req)
 	    (uint64_t)startpos, (uint64_t)maxcount, READ_LOCK,
 	    &lock);
 
-	if (!SMB_VFS_STRICT_LOCK(conn, fsp, &lock)) {
+	if (!SMB_VFS_STRICT_LOCK_CHECK(conn, fsp, &lock)) {
 		reply_readbraw_error(xconn);
 		END_PROFILE(SMBreadbraw);
 		return;
@@ -3890,7 +3890,7 @@ Returning short read of maximum allowed for compatibility with Windows 2000.\n",
 	    (uint64_t)startpos, (uint64_t)numtoread, READ_LOCK,
 	    &lock);
 
-	if (!SMB_VFS_STRICT_LOCK(conn, fsp, &lock)) {
+	if (!SMB_VFS_STRICT_LOCK_CHECK(conn, fsp, &lock)) {
 		reply_nterror(req, NT_STATUS_FILE_LOCK_CONFLICT);
 		END_PROFILE(SMBread);
 		return;
@@ -3966,7 +3966,7 @@ static void send_file_readX(connection_struct *conn, struct smb_request *req,
 	    (uint64_t)startpos, (uint64_t)smb_maxcnt, READ_LOCK,
 	    &lock);
 
-	if (!SMB_VFS_STRICT_LOCK(conn, fsp, &lock)) {
+	if (!SMB_VFS_STRICT_LOCK_CHECK(conn, fsp, &lock)) {
 		reply_nterror(req, NT_STATUS_FILE_LOCK_CONFLICT);
 		return;
 	}
@@ -4486,7 +4486,7 @@ void reply_writebraw(struct smb_request *req)
 		    (uint64_t)startpos, (uint64_t)tcount, WRITE_LOCK,
 		    &lock);
 
-		if (!SMB_VFS_STRICT_LOCK(conn, fsp, &lock)) {
+		if (!SMB_VFS_STRICT_LOCK_CHECK(conn, fsp, &lock)) {
 			reply_nterror(req, NT_STATUS_FILE_LOCK_CONFLICT);
 			error_to_writebrawerr(req);
 			END_PROFILE(SMBwritebraw);
@@ -4684,7 +4684,7 @@ void reply_writeunlock(struct smb_request *req)
 		    (uint64_t)startpos, (uint64_t)numtowrite, WRITE_LOCK,
 		    &lock);
 
-		if (!SMB_VFS_STRICT_LOCK(conn, fsp, &lock)) {
+		if (!SMB_VFS_STRICT_LOCK_CHECK(conn, fsp, &lock)) {
 			reply_nterror(req, NT_STATUS_FILE_LOCK_CONFLICT);
 			END_PROFILE(SMBwriteunlock);
 			return;
@@ -4801,7 +4801,7 @@ void reply_write(struct smb_request *req)
 			(uint64_t)startpos, (uint64_t)numtowrite, WRITE_LOCK,
 			&lock);
 
-		if (!SMB_VFS_STRICT_LOCK(conn, fsp, &lock)) {
+		if (!SMB_VFS_STRICT_LOCK_CHECK(conn, fsp, &lock)) {
 			reply_nterror(req, NT_STATUS_FILE_LOCK_CONFLICT);
 			END_PROFILE(SMBwrite);
 			return;
@@ -5090,7 +5090,7 @@ void reply_write_and_X(struct smb_request *req)
 		    (uint64_t)startpos, (uint64_t)numtowrite, WRITE_LOCK,
 		    &lock);
 
-		if (!SMB_VFS_STRICT_LOCK(conn, fsp, &lock)) {
+		if (!SMB_VFS_STRICT_LOCK_CHECK(conn, fsp, &lock)) {
 			reply_nterror(req, NT_STATUS_FILE_LOCK_CONFLICT);
 			goto out;
 		}
@@ -5482,7 +5482,7 @@ void reply_writeclose(struct smb_request *req)
 		    (uint64_t)startpos, (uint64_t)numtowrite, WRITE_LOCK,
 		    &lock);
 
-		if (!SMB_VFS_STRICT_LOCK(conn, fsp, &lock)) {
+		if (!SMB_VFS_STRICT_LOCK_CHECK(conn, fsp, &lock)) {
 			reply_nterror(req, NT_STATUS_FILE_LOCK_CONFLICT);
 			END_PROFILE(SMBwriteclose);
 			return;
diff --git a/source3/smbd/smb2_ioctl_filesys.c b/source3/smbd/smb2_ioctl_filesys.c
index 054fd93..79c5021 100644
--- a/source3/smbd/smb2_ioctl_filesys.c
+++ b/source3/smbd/smb2_ioctl_filesys.c
@@ -483,7 +483,7 @@ static NTSTATUS fsctl_zero_data(TALLOC_CTX *mem_ctx,
 				WRITE_LOCK,
 				&lck);
 
-	if (!SMB_VFS_STRICT_LOCK(fsp->conn, fsp, &lck)) {
+	if (!SMB_VFS_STRICT_LOCK_CHECK(fsp->conn, fsp, &lck)) {
 		DEBUG(2, ("failed to lock range for zero-data\n"));
 		return NT_STATUS_FILE_LOCK_CONFLICT;
 	}
diff --git a/source3/smbd/smb2_read.c b/source3/smbd/smb2_read.c
index 6aa62cd..ecedf1e 100644
--- a/source3/smbd/smb2_read.c
+++ b/source3/smbd/smb2_read.c
@@ -543,7 +543,7 @@ static struct tevent_req *smbd_smb2_read_send(TALLOC_CTX *mem_ctx,
 				READ_LOCK,
 				&lock);
 
-	if (!SMB_VFS_STRICT_LOCK(conn, fsp, &lock)) {
+	if (!SMB_VFS_STRICT_LOCK_CHECK(conn, fsp, &lock)) {
 		tevent_req_nterror(req, NT_STATUS_FILE_LOCK_CONFLICT);
 		return tevent_req_post(req, ev);
 	}
diff --git a/source3/smbd/smb2_write.c b/source3/smbd/smb2_write.c
index a8ebac8..5657c66 100644
--- a/source3/smbd/smb2_write.c
+++ b/source3/smbd/smb2_write.c
@@ -354,7 +354,7 @@ static struct tevent_req *smbd_smb2_write_send(TALLOC_CTX *mem_ctx,
 				WRITE_LOCK,
 				&lock);
 
-	if (!SMB_VFS_STRICT_LOCK(conn, fsp, &lock)) {
+	if (!SMB_VFS_STRICT_LOCK_CHECK(conn, fsp, &lock)) {
 		tevent_req_nterror(req, NT_STATUS_FILE_LOCK_CONFLICT);
 		return tevent_req_post(req, ev);
 	}
diff --git a/source3/smbd/vfs.c b/source3/smbd/vfs.c
index f2861e2..dc0d14d 100644
--- a/source3/smbd/vfs.c
+++ b/source3/smbd/vfs.c
@@ -2274,12 +2274,12 @@ const char *smb_vfs_call_connectpath(struct vfs_handle_struct *handle,
 	return handle->fns->connectpath_fn(handle, smb_fname);
 }
 
-bool smb_vfs_call_strict_lock(struct vfs_handle_struct *handle,
-			      struct files_struct *fsp,
-			      struct lock_struct *plock)
+bool smb_vfs_call_strict_lock_check(struct vfs_handle_struct *handle,
+				    struct files_struct *fsp,
+				    struct lock_struct *plock)
 {
-	VFS_FIND(strict_lock);
-	return handle->fns->strict_lock_fn(handle, fsp, plock);
+	VFS_FIND(strict_lock_check);
+	return handle->fns->strict_lock_check_fn(handle, fsp, plock);
 }
 
 NTSTATUS smb_vfs_call_translate_name(struct vfs_handle_struct *handle,
-- 
2.9.4



More information about the samba-technical mailing list