[SCM] Samba Shared Repository - branch master updated

Stefan Metzmacher metze at samba.org
Fri Jun 22 09:11:02 MDT 2012


The branch, master has been updated
       via  4676e7f dbwrap: don't ignore the result of dbwrap_parse_record in dbwrap_fetch_int32()
       via  0f25bd7 dbwrap: intialize state.status in dbwrap_fetch_int32()
       via  d7b9e0d dbwrap: Convert fetch_int32 to dbwrap_parse_record
       via  770d9af s3: Remove reduce_windows_lock_ref_count, used only once
       via  89b2eb1 s3: Make reduce_windows_lock_ref_count static
       via  6658a2f s3: Use dbwrap_util for windows_lock_ref_count
       via  e0abd19 dbwrap: Add dbwrap_fetch_int32
       via  ce7b0b9 dbwrap: Add dbwrap_change_int32_atomic
       via  688cda1 script/autobuild: fix path to random-sleep.sh
      from  ea74131 selftest/knownfail: mark ^samba4.raw.session.expire1 as knownfail

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


- Log -----------------------------------------------------------------
commit 4676e7f65df5e6743ed2319e64d787429c23faf0
Author: Stefan Metzmacher <metze at samba.org>
Date:   Fri Jun 22 15:10:00 2012 +0200

    dbwrap: don't ignore the result of dbwrap_parse_record in dbwrap_fetch_int32()
    
    metze
    
    Autobuild-User(master): Stefan Metzmacher <metze at samba.org>
    Autobuild-Date(master): Fri Jun 22 17:10:52 CEST 2012 on sn-devel-104

commit 0f25bd78ca0ddbeff971d72791687ab25d6b33e4
Author: Stefan Metzmacher <metze at samba.org>
Date:   Fri Jun 22 15:08:22 2012 +0200

    dbwrap: intialize state.status in dbwrap_fetch_int32()
    
    This might not be needed, but it makes it more clear that
    we won't use uninitialized memory, it the callback was not triggered.
    
    metze

commit d7b9e0d19a72783b45610dcf006571817338b50f
Author: Volker Lendecke <vl at samba.org>
Date:   Tue Jun 12 12:58:47 2012 +0200

    dbwrap: Convert fetch_int32 to dbwrap_parse_record
    
    Now dbwrap_fetch_int32 is used in smbd/locking/posix.c is used a
    lot more often than before.
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>

commit 770d9affd721f05c4729d26dbc674cac491fba7c
Author: Volker Lendecke <vl at samba.org>
Date:   Tue Jun 12 12:14:59 2012 +0200

    s3: Remove reduce_windows_lock_ref_count, used only once
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>

commit 89b2eb1d06f543388fce9239bcd209fc367d0cad
Author: Volker Lendecke <vl at samba.org>
Date:   Tue Jun 12 12:13:15 2012 +0200

    s3: Make reduce_windows_lock_ref_count static
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>

commit 6658a2f6ef0e1bd10aa0b4913bb51636fa968586
Author: Volker Lendecke <vl at samba.org>
Date:   Tue Jun 12 12:11:40 2012 +0200

    s3: Use dbwrap_util for windows_lock_ref_count
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>

commit e0abd1938a05185f09ee99e000783320647a744a
Author: Volker Lendecke <vl at samba.org>
Date:   Fri Jun 15 10:52:07 2012 +0200

    dbwrap: Add dbwrap_fetch_int32
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>

commit ce7b0b9906685740e18c599cb3b453f58c8565d1
Author: Volker Lendecke <vl at samba.org>
Date:   Fri Jun 15 10:50:00 2012 +0200

    dbwrap: Add dbwrap_change_int32_atomic
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>

commit 688cda19ba68db8a7557ffe8cbf6e3c79eae74f9
Author: Stefan Metzmacher <metze at samba.org>
Date:   Fri Jun 22 14:58:25 2012 +0200

    script/autobuild: fix path to random-sleep.sh
    
    metze

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

Summary of changes:
 lib/dbwrap/dbwrap.h      |    6 ++
 lib/dbwrap/dbwrap_util.c |   69 +++++++++++++++++++-------
 script/autobuild.py      |   16 +++---
 source3/locking/posix.c  |  122 ++++++++-------------------------------------
 source3/locking/proto.h  |    1 -
 5 files changed, 86 insertions(+), 128 deletions(-)


Changeset truncated at 500 lines:

diff --git a/lib/dbwrap/dbwrap.h b/lib/dbwrap/dbwrap.h
index 30c24fe..5244ff2 100644
--- a/lib/dbwrap/dbwrap.h
+++ b/lib/dbwrap/dbwrap.h
@@ -93,6 +93,8 @@ NTSTATUS dbwrap_store_bystring(struct db_context *db, const char *key,
 NTSTATUS dbwrap_fetch_bystring(struct db_context *db, TALLOC_CTX *mem_ctx,
 			       const char *key, TDB_DATA *value);
 
+NTSTATUS dbwrap_fetch_int32(struct db_context *db, TDB_DATA key,
+			    int32_t *result);
 NTSTATUS dbwrap_fetch_int32_bystring(struct db_context *db, const char *keystr,
 				     int32_t *result);
 NTSTATUS dbwrap_store_int32_bystring(struct db_context *db, const char *keystr,
@@ -109,6 +111,10 @@ NTSTATUS dbwrap_trans_change_uint32_atomic_bystring(struct db_context *db,
 						    const char *keystr,
 						    uint32_t *oldval,
 						    uint32_t change_val);
+NTSTATUS dbwrap_change_int32_atomic(struct db_context *db,
+				    TDB_DATA key,
+				    int32_t *oldval,
+				    int32_t change_val);
 NTSTATUS dbwrap_change_int32_atomic_bystring(struct db_context *db,
 					     const char *keystr,
 					     int32_t *oldval,
diff --git a/lib/dbwrap/dbwrap_util.c b/lib/dbwrap/dbwrap_util.c
index 8e6498d..119c7e1 100644
--- a/lib/dbwrap/dbwrap_util.c
+++ b/lib/dbwrap/dbwrap_util.c
@@ -26,29 +26,52 @@
 #include "dbwrap.h"
 #include "lib/util/util_tdb.h"
 
-NTSTATUS dbwrap_fetch_int32_bystring(struct db_context *db, const char *keystr,
-				     int32_t *result)
+struct dbwrap_fetch_int32_state {
+	NTSTATUS status;
+	int32_t result;
+};
+
+static void dbwrap_fetch_int32_parser(TDB_DATA key, TDB_DATA data,
+				      void *private_data)
 {
-	TDB_DATA dbuf;
+	struct dbwrap_fetch_int32_state *state =
+		(struct dbwrap_fetch_int32_state *)private_data;
+
+	if (data.dsize != sizeof(state->result)) {
+		state->status = NT_STATUS_INTERNAL_DB_CORRUPTION;
+		return;
+	}
+	state->result = IVAL(data.dptr, 0);
+	state->status = NT_STATUS_OK;
+}
+
+NTSTATUS dbwrap_fetch_int32(struct db_context *db, TDB_DATA key,
+			    int32_t *result)
+{
+	struct dbwrap_fetch_int32_state state;
 	NTSTATUS status;
 
 	if (result == NULL) {
 		return NT_STATUS_INVALID_PARAMETER;
 	}
 
-	status = dbwrap_fetch_bystring(db, talloc_tos(), keystr, &dbuf);
+	state.status = NT_STATUS_INTERNAL_ERROR;
+
+	status = dbwrap_parse_record(db, key, dbwrap_fetch_int32_parser, &state);
 	if (!NT_STATUS_IS_OK(status)) {
 		return status;
 	}
 
-	if ((dbuf.dptr == NULL) || (dbuf.dsize != sizeof(int32_t))) {
-		TALLOC_FREE(dbuf.dptr);
-		return NT_STATUS_NOT_FOUND;
+	if (NT_STATUS_IS_OK(state.status)) {
+		*result = state.result;
 	}
+	return state.status;
+}
 
-	*result = IVAL(dbuf.dptr, 0);
-	TALLOC_FREE(dbuf.dptr);
-	return NT_STATUS_OK;
+NTSTATUS dbwrap_fetch_int32_bystring(struct db_context *db, const char *keystr,
+				     int32_t *result)
+{
+	return dbwrap_fetch_int32(db, string_term_tdb_data(keystr), result);
 }
 
 NTSTATUS dbwrap_store_int32_bystring(struct db_context *db, const char *keystr,
@@ -223,7 +246,7 @@ NTSTATUS dbwrap_trans_change_uint32_atomic_bystring(struct db_context *db,
  */
 
 struct dbwrap_change_int32_atomic_context {
-	const char *keystr;
+	TDB_DATA key;
 	int32_t *oldval;
 	int32_t change_val;
 };
@@ -240,8 +263,7 @@ static NTSTATUS dbwrap_change_int32_atomic_action(struct db_context *db,
 
 	state = (struct dbwrap_change_int32_atomic_context *)private_data;
 
-	rec = dbwrap_fetch_locked(db, talloc_tos(),
-				  string_term_tdb_data(state->keystr));
+	rec = dbwrap_fetch_locked(db, talloc_tos(), state->key);
 	if (!rec) {
 		return NT_STATUS_UNSUCCESSFUL;
 	}
@@ -272,15 +294,15 @@ done:
 	return ret;
 }
 
-NTSTATUS dbwrap_change_int32_atomic_bystring(struct db_context *db,
-					     const char *keystr,
-					     int32_t *oldval,
-					     int32_t change_val)
+NTSTATUS dbwrap_change_int32_atomic(struct db_context *db,
+				    TDB_DATA key,
+				    int32_t *oldval,
+				    int32_t change_val)
 {
 	NTSTATUS ret;
 	struct dbwrap_change_int32_atomic_context state;
 
-	state.keystr = keystr;
+	state.key = key;
 	state.oldval = oldval;
 	state.change_val = change_val;
 
@@ -289,6 +311,15 @@ NTSTATUS dbwrap_change_int32_atomic_bystring(struct db_context *db,
 	return ret;
 }
 
+NTSTATUS dbwrap_change_int32_atomic_bystring(struct db_context *db,
+					     const char *keystr,
+					     int32_t *oldval,
+					     int32_t change_val)
+{
+	return dbwrap_change_int32_atomic(db, string_term_tdb_data(keystr),
+					  oldval, change_val);
+}
+
 NTSTATUS dbwrap_trans_change_int32_atomic_bystring(struct db_context *db,
 						   const char *keystr,
 						   int32_t *oldval,
@@ -297,7 +328,7 @@ NTSTATUS dbwrap_trans_change_int32_atomic_bystring(struct db_context *db,
 	NTSTATUS ret;
 	struct dbwrap_change_int32_atomic_context state;
 
-	state.keystr = keystr;
+	state.key = string_term_tdb_data(keystr);
 	state.oldval = oldval;
 	state.change_val = change_val;
 
diff --git a/script/autobuild.py b/script/autobuild.py
index 92fa413..ae58fcd 100755
--- a/script/autobuild.py
+++ b/script/autobuild.py
@@ -52,7 +52,7 @@ tasks = {
                  ("check-clean-tree", "../script/clean-source-tree.sh", "text/plain"),
                  ("clean", "make clean", "text/plain") ],
 
-    "samba3-ctdb" : [ ("random-sleep", "script/random-sleep.sh 60 600", "text/plain"),
+    "samba3-ctdb" : [ ("random-sleep", "../script/random-sleep.sh 60 600", "text/plain"),
                       ("autogen", "./autogen.sh", "text/plain"),
                       ("configure", "./configure.developer ${PREFIX} --with-cluster-support --with-ctdb=../ctdb", "text/plain"),
                       ("make basics", "make basics", "text/plain"),
@@ -110,7 +110,7 @@ tasks = {
                       ("install", "make install", "text/plain")],
 
     "ldb" : [
-              ("random-sleep", "script/random-sleep.sh 60 600", "text/plain"),
+              ("random-sleep", "../../script/random-sleep.sh 60 600", "text/plain"),
               ("configure", "./configure --enable-developer -C ${PREFIX}", "text/plain"),
               ("make", "make", "text/plain"),
               ("install", "make install", "text/plain"),
@@ -120,7 +120,7 @@ tasks = {
               ("clean", "make clean", "text/plain") ],
 
     "tdb" : [
-              ("random-sleep", "script/random-sleep.sh 60 600", "text/plain"),
+              ("random-sleep", "../../script/random-sleep.sh 60 600", "text/plain"),
               ("configure", "./configure --enable-developer -C ${PREFIX}", "text/plain"),
               ("make", "make", "text/plain"),
               ("install", "make install", "text/plain"),
@@ -130,7 +130,7 @@ tasks = {
               ("clean", "make clean", "text/plain") ],
 
     "ntdb" : [
-               ("random-sleep", "script/random-sleep.sh 60 600", "text/plain"),
+               ("random-sleep", "../../script/random-sleep.sh 60 600", "text/plain"),
                ("configure", "./configure --enable-developer -C ${PREFIX}", "text/plain"),
                ("make", "make", "text/plain"),
                ("install", "make install", "text/plain"),
@@ -140,7 +140,7 @@ tasks = {
                ("clean", "make clean", "text/plain") ],
 
     "talloc" : [
-                 ("random-sleep", "script/random-sleep.sh 60 600", "text/plain"),
+                 ("random-sleep", "../../script/random-sleep.sh 60 600", "text/plain"),
                  ("configure", "./configure --enable-developer -C ${PREFIX}", "text/plain"),
                  ("make", "make", "text/plain"),
                  ("install", "make install", "text/plain"),
@@ -150,7 +150,7 @@ tasks = {
                  ("clean", "make clean", "text/plain") ],
 
     "replace" : [
-                  ("random-sleep", "script/random-sleep.sh 60 600", "text/plain"),
+                  ("random-sleep", "../../script/random-sleep.sh 60 600", "text/plain"),
                   ("configure", "./configure --enable-developer -C ${PREFIX}", "text/plain"),
                   ("make", "make", "text/plain"),
                   ("install", "make install", "text/plain"),
@@ -160,7 +160,7 @@ tasks = {
                   ("clean", "make clean", "text/plain") ],
 
     "tevent" : [
-                 ("random-sleep", "script/random-sleep.sh 60 600", "text/plain"),
+                 ("random-sleep", "../../script/random-sleep.sh 60 600", "text/plain"),
                  ("configure", "./configure --enable-developer -C ${PREFIX}", "text/plain"),
                  ("make", "make", "text/plain"),
                  ("install", "make install", "text/plain"),
@@ -170,7 +170,7 @@ tasks = {
                  ("clean", "make clean", "text/plain") ],
 
     "pidl" : [
-               ("random-sleep", "script/random-sleep.sh 60 600", "text/plain"),
+               ("random-sleep", "../script/random-sleep.sh 60 600", "text/plain"),
                ("configure", "perl Makefile.PL PREFIX=${PREFIX_DIR}", "text/plain"),
                ("touch", "touch *.yp", "text/plain"),
                ("make", "make", "text/plain"),
diff --git a/source3/locking/posix.c b/source3/locking/posix.c
index e5320f8..2d89110 100644
--- a/source3/locking/posix.c
+++ b/source3/locking/posix.c
@@ -406,132 +406,61 @@ bool posix_locking_end(void)
 static void increment_windows_lock_ref_count(files_struct *fsp)
 {
 	struct lock_ref_count_key tmp;
-	struct db_record *rec;
-	int lock_ref_count = 0;
+	int32_t lock_ref_count = 0;
 	NTSTATUS status;
-	TDB_DATA value;
-
-	rec = dbwrap_fetch_locked(
-		posix_pending_close_db, talloc_tos(),
-		locking_ref_count_key_fsp(fsp, &tmp));
-
-	SMB_ASSERT(rec != NULL);
 
-	value = dbwrap_record_get_value(rec);
-
-	if (value.dptr != NULL) {
-		SMB_ASSERT(value.dsize == sizeof(lock_ref_count));
-		memcpy(&lock_ref_count, value.dptr,
-		       sizeof(lock_ref_count));
-	}
-
-	lock_ref_count++;
-
-	status = dbwrap_record_store(rec,
-				     make_tdb_data((uint8 *)&lock_ref_count,
-				     sizeof(lock_ref_count)), 0);
+	status = dbwrap_change_int32_atomic(
+		posix_pending_close_db, locking_ref_count_key_fsp(fsp, &tmp),
+		&lock_ref_count, 1);
 
 	SMB_ASSERT(NT_STATUS_IS_OK(status));
-
-	TALLOC_FREE(rec);
+	SMB_ASSERT(lock_ref_count < INT32_MAX);
 
 	DEBUG(10,("increment_windows_lock_ref_count for file now %s = %d\n",
-		  fsp_str_dbg(fsp), lock_ref_count));
+		  fsp_str_dbg(fsp), (int)lock_ref_count));
 }
 
 /****************************************************************************
  Bulk delete - subtract as many locks as we've just deleted.
 ****************************************************************************/
 
-void reduce_windows_lock_ref_count(files_struct *fsp, unsigned int dcount)
+static void decrement_windows_lock_ref_count(files_struct *fsp)
 {
 	struct lock_ref_count_key tmp;
-	struct db_record *rec;
-	int lock_ref_count = 0;
+	int32_t lock_ref_count = 0;
 	NTSTATUS status;
-	TDB_DATA value;
-
-	rec = dbwrap_fetch_locked(
-		posix_pending_close_db, talloc_tos(),
-		locking_ref_count_key_fsp(fsp, &tmp));
-
-	if (rec == NULL) {
-		DEBUG(0, ("reduce_windows_lock_ref_count: rec not found\n"));
-		return;
-	}
-
-	value = dbwrap_record_get_value(rec);
-
-	if ((value.dptr == NULL) ||  (value.dsize != sizeof(lock_ref_count))) {
-		DEBUG(0, ("reduce_windows_lock_ref_count: wrong value\n"));
-		TALLOC_FREE(rec);
-		return;
-	}
-
-	memcpy(&lock_ref_count, value.dptr, sizeof(lock_ref_count));
 
-	SMB_ASSERT(lock_ref_count > 0);
-
-	lock_ref_count -= dcount;
-
-	status = dbwrap_record_store(rec,
-				     make_tdb_data((uint8 *)&lock_ref_count,
-				     sizeof(lock_ref_count)), 0);
+	status = dbwrap_change_int32_atomic(
+		posix_pending_close_db, locking_ref_count_key_fsp(fsp, &tmp),
+		&lock_ref_count, -1);
 
 	SMB_ASSERT(NT_STATUS_IS_OK(status));
-
-	TALLOC_FREE(rec);
+	SMB_ASSERT(lock_ref_count >= 0);
 
 	DEBUG(10,("reduce_windows_lock_ref_count for file now %s = %d\n",
-		  fsp_str_dbg(fsp), lock_ref_count));
-}
-
-static void decrement_windows_lock_ref_count(files_struct *fsp)
-{
-	reduce_windows_lock_ref_count(fsp, 1);
+		  fsp_str_dbg(fsp), (int)lock_ref_count));
 }
 
 /****************************************************************************
  Fetch the lock ref count.
 ****************************************************************************/
 
-static int get_windows_lock_ref_count(files_struct *fsp)
+static int32_t get_windows_lock_ref_count(files_struct *fsp)
 {
 	struct lock_ref_count_key tmp;
-	TDB_DATA dbuf;
 	NTSTATUS status;
-	int lock_ref_count = 0;
+	int32_t lock_ref_count = 0;
 
-	status = dbwrap_fetch(
-		posix_pending_close_db, talloc_tos(),
-		locking_ref_count_key_fsp(fsp, &tmp), &dbuf);
-
-	if (NT_STATUS_EQUAL(status, NT_STATUS_NOT_FOUND)) {
-		goto done;
-	}
+	status = dbwrap_fetch_int32(
+		posix_pending_close_db, locking_ref_count_key_fsp(fsp, &tmp),
+		&lock_ref_count);
 
-	if (!NT_STATUS_IS_OK(status)) {
+	if (!NT_STATUS_IS_OK(status) &&
+	    !NT_STATUS_EQUAL(status, NT_STATUS_NOT_FOUND)) {
 		DEBUG(0, ("get_windows_lock_ref_count: Error fetching "
 			  "lock ref count for file %s: %s\n",
 			  fsp_str_dbg(fsp), nt_errstr(status)));
-		goto done;
 	}
-
-	if (dbuf.dsize != sizeof(lock_ref_count)) {
-		DEBUG(0, ("get_windows_lock_ref_count: invalid entry "
-			  "in lock ref count record for file %s: "
-			  "(invalid data size %u)\n",
-			  fsp_str_dbg(fsp), (unsigned int)dbuf.dsize));
-		goto done;
-	}
-
-	memcpy(&lock_ref_count, dbuf.dptr, sizeof(lock_ref_count));
-	TALLOC_FREE(dbuf.dptr);
-
-done:
-	DEBUG(10,("get_windows_lock_count for file %s = %d\n",
-		  fsp_str_dbg(fsp), lock_ref_count));
-
 	return lock_ref_count;
 }
 
@@ -542,18 +471,11 @@ done:
 static void delete_windows_lock_ref_count(files_struct *fsp)
 {
 	struct lock_ref_count_key tmp;
-	struct db_record *rec;
-
-	rec = dbwrap_fetch_locked(
-		posix_pending_close_db, talloc_tos(),
-		locking_ref_count_key_fsp(fsp, &tmp));
-
-	SMB_ASSERT(rec != NULL);
 
 	/* Not a bug if it doesn't exist - no locks were ever granted. */
 
-	dbwrap_record_delete(rec);
-	TALLOC_FREE(rec);
+	dbwrap_delete(posix_pending_close_db,
+		      locking_ref_count_key_fsp(fsp, &tmp));
 
 	DEBUG(10,("delete_windows_lock_ref_count for file %s\n",
 		  fsp_str_dbg(fsp)));
diff --git a/source3/locking/proto.h b/source3/locking/proto.h
index f6a6f2e..74cf323 100644
--- a/source3/locking/proto.h
+++ b/source3/locking/proto.h
@@ -207,7 +207,6 @@ bool is_posix_locked(files_struct *fsp,
 			enum brl_flavour lock_flav);
 bool posix_locking_init(bool read_only);
 bool posix_locking_end(void);
-void reduce_windows_lock_ref_count(files_struct *fsp, unsigned int dcount);
 int fd_close_posix(struct files_struct *fsp);
 bool set_posix_lock_windows_flavour(files_struct *fsp,
 			uint64_t u_offset,


-- 
Samba Shared Repository


More information about the samba-cvs mailing list