[SCM] Samba Shared Repository - branch master updated

Jeremy Allison jra at samba.org
Thu Aug 11 21:50:05 UTC 2016


The branch, master has been updated
       via  e001dce ldb: Fix some signed/unsigned hickups
       via  df83b17 s3: oplock: Fix race condition when closing an oplocked file.
       via  cb394ab smbd: oplock: Factor out internals of remove_oplock() into new remove_oplock_under_lock().
       via  de71801 smbd: oplock: Fixup debug messages inside remove_oplock().
      from  98d289d script/autobuild.py: include the branch name in the output

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


- Log -----------------------------------------------------------------
commit e001dceadf20ca5bbc2597571d1caefe77deef77
Author: Volker Lendecke <vl at samba.org>
Date:   Thu Aug 11 15:46:49 2016 +0200

    ldb: Fix some signed/unsigned hickups
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Stefan Metzmacher <metze at samba.org>
    
    Autobuild-User(master): Jeremy Allison <jra at samba.org>
    Autobuild-Date(master): Thu Aug 11 23:49:38 CEST 2016 on sn-devel-144

commit df83b17c60a08a27a7ddd1d88dc125e15b3ee06d
Author: Jeremy Allison <jra at samba.org>
Date:   Wed Aug 10 14:42:07 2016 -0700

    s3: oplock: Fix race condition when closing an oplocked file.
    
    We must send the 'oplock released' message whilst the lock
    is held in the close path. Otherwise the messaged smbd can
    race with the share mode delete.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=12139
    
    Signed-off-by: Jeremy Allison <jra at samba.org>
    Reviewed-by: Volker Lendecke <vl at samba.org>

commit cb394abe5206dd8ad8a68f157427991b259129a7
Author: Jeremy Allison <jra at samba.org>
Date:   Wed Aug 10 14:39:52 2016 -0700

    smbd: oplock: Factor out internals of remove_oplock() into new remove_oplock_under_lock().
    
    Allows this to be called elsewhere.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=12139
    
    Signed-off-by: Jeremy Allison <jra at samba.org>
    Reviewed-by: Volker Lendecke <vl at samba.org>

commit de7180151fc99893c4763882fecd9d2a623cd061
Author: Jeremy Allison <jra at samba.org>
Date:   Wed Aug 10 14:35:42 2016 -0700

    smbd: oplock: Fixup debug messages inside remove_oplock().
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=12139
    
    Signed-off-by: Jeremy Allison <jra at samba.org>
    Reviewed-by: Volker Lendecke <vl at samba.org>

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

Summary of changes:
 lib/ldb/common/ldb_pack.c |  5 ++---
 source3/smbd/close.c      | 10 ++++-----
 source3/smbd/oplock.c     | 54 +++++++++++++++++++++++++++++------------------
 source3/smbd/proto.h      |  1 +
 4 files changed, 41 insertions(+), 29 deletions(-)


Changeset truncated at 500 lines:

diff --git a/lib/ldb/common/ldb_pack.c b/lib/ldb/common/ldb_pack.c
index cc3a552..7e6dd2d 100644
--- a/lib/ldb/common/ldb_pack.c
+++ b/lib/ldb/common/ldb_pack.c
@@ -185,8 +185,7 @@ static bool ldb_consume_element_data(uint8_t **pp, size_t *premaining)
 	unsigned int remaining = *premaining;
 	uint8_t *p = *pp;
 	uint32_t num_values = pull_uint32(p, 0);
-	uint32_t len;
-	int j;
+	uint32_t j, len;
 
 	p += 4;
 	if (remaining < 4) {
@@ -348,7 +347,7 @@ int ldb_unpack_data_only_attr_list_flags(struct ldb_context *ldb,
 		 */
 		if (list_size != 0) {
 			bool keep = false;
-			int h;
+			unsigned int h;
 
 			/*
 			 * We know that p has a \0 terminator before the
diff --git a/source3/smbd/close.c b/source3/smbd/close.c
index 3c4b9b1..22bd361 100644
--- a/source3/smbd/close.c
+++ b/source3/smbd/close.c
@@ -273,6 +273,11 @@ static NTSTATUS close_remove_share_mode(files_struct *fsp,
 		return NT_STATUS_INVALID_PARAMETER;
 	}
 
+	/* Remove the oplock before potentially deleting the file. */
+	if(fsp->oplock_type) {
+		remove_oplock_under_lock(fsp, lck);
+	}
+
 	if (fsp->write_time_forced) {
 		DEBUG(10,("close_remove_share_mode: write time forced "
 			"for file %s\n",
@@ -741,11 +746,6 @@ static NTSTATUS close_normal_file(struct smb_request *req, files_struct *fsp,
 		return NT_STATUS_OK;
 	}
 
-	/* Remove the oplock before potentially deleting the file. */
-	if(fsp->oplock_type) {
-		remove_oplock(fsp);
-	}
-
 	/* If this is an old DOS or FCB open and we have multiple opens on
 	   the same handle we only have one share mode. Ensure we only remove
 	   the share mode on the last close. */
diff --git a/source3/smbd/oplock.c b/source3/smbd/oplock.c
index be20dee..ff87d9e 100644
--- a/source3/smbd/oplock.c
+++ b/source3/smbd/oplock.c
@@ -223,6 +223,34 @@ bool update_num_read_oplocks(files_struct *fsp, struct share_mode_lock *lck)
 }
 
 /****************************************************************************
+ Remove a file oplock with lock already held. Copes with level II and exclusive.
+****************************************************************************/
+
+bool remove_oplock_under_lock(files_struct *fsp, struct share_mode_lock *lck)
+{
+	bool ret;
+
+	ret = remove_share_oplock(lck, fsp);
+	if (!ret) {
+		DBG_ERR("failed to remove share oplock for "
+			"file %s, %s, %s\n",
+			fsp_str_dbg(fsp), fsp_fnum_dbg(fsp),
+			file_id_string_tos(&fsp->file_id));
+	}
+	release_file_oplock(fsp);
+
+	ret = update_num_read_oplocks(fsp, lck);
+	if (!ret) {
+		DBG_ERR("update_num_read_oplocks failed for "
+			"file %s, %s, %s\n",
+			fsp_str_dbg(fsp), fsp_fnum_dbg(fsp),
+			file_id_string_tos(&fsp->file_id));
+	}
+
+	return ret;
+}
+
+/****************************************************************************
  Remove a file oplock. Copes with level II and exclusive.
  Locks then unlocks the share mode lock. Client can decide to go directly
  to none even if a "break-to-level II" was sent.
@@ -233,33 +261,17 @@ bool remove_oplock(files_struct *fsp)
 	bool ret;
 	struct share_mode_lock *lck;
 
-	DEBUG(10, ("remove_oplock called for %s\n",
-		   fsp_str_dbg(fsp)));
+	DBG_DEBUG("remove_oplock called for %s\n", fsp_str_dbg(fsp));
 
 	/* Remove the oplock flag from the sharemode. */
 	lck = get_existing_share_mode_lock(talloc_tos(), fsp->file_id);
 	if (lck == NULL) {
-		DEBUG(0,("remove_oplock: failed to lock share entry for "
-			 "file %s\n", fsp_str_dbg(fsp)));
-		return False;
-	}
-
-	ret = remove_share_oplock(lck, fsp);
-	if (!ret) {
-		DEBUG(0,("remove_oplock: failed to remove share oplock for "
-			 "file %s, %s, %s\n",
-			 fsp_str_dbg(fsp), fsp_fnum_dbg(fsp),
-			 file_id_string_tos(&fsp->file_id)));
+		DBG_ERR("failed to lock share entry for "
+			 "file %s\n", fsp_str_dbg(fsp));
+		return false;
 	}
-	release_file_oplock(fsp);
 
-	ret = update_num_read_oplocks(fsp, lck);
-	if (!ret) {
-		DEBUG(0, ("%s: update_num_read_oplocks failed for "
-			 "file %s, %s, %s\n",
-			  __func__, fsp_str_dbg(fsp), fsp_fnum_dbg(fsp),
-			 file_id_string_tos(&fsp->file_id)));
-	}
+	ret = remove_oplock_under_lock(fsp, lck);
 
 	TALLOC_FREE(lck);
 	return ret;
diff --git a/source3/smbd/proto.h b/source3/smbd/proto.h
index 26fec95..97fe577 100644
--- a/source3/smbd/proto.h
+++ b/source3/smbd/proto.h
@@ -708,6 +708,7 @@ bool update_num_read_oplocks(files_struct *fsp, struct share_mode_lock *lck);
 
 void break_kernel_oplock(struct messaging_context *msg_ctx, files_struct *fsp);
 NTSTATUS set_file_oplock(files_struct *fsp);
+bool remove_oplock_under_lock(files_struct *fsp, struct share_mode_lock *lck);
 bool remove_oplock(files_struct *fsp);
 bool downgrade_oplock(files_struct *fsp);
 bool fsp_lease_update(struct share_mode_lock *lck,


-- 
Samba Shared Repository



More information about the samba-cvs mailing list