[SCM] SAMBA-CTDB repository - branch v3-2-ctdb updated - build_3.2.7_ctdb.54-201-g352fca6

Michael Adam obnox at samba.org
Wed Mar 4 21:50:21 GMT 2009


The branch, v3-2-ctdb has been updated
       via  352fca67a831e061ed3c126d7513611aa4c1fcf3 (commit)
       via  7ef193f9d367372a11e665505cd0c4b53b7d0cca (commit)
       via  d69c3db9d44ad5d9fd1f5d7a9499f3bd79ecfb47 (commit)
      from  a679d210f8ce750a11fdf7006d56a4934203e087 (commit)

http://gitweb.samba.org/?p=obnox/samba-ctdb.git;a=shortlog;h=v3-2-ctdb


- Log -----------------------------------------------------------------
commit 352fca67a831e061ed3c126d7513611aa4c1fcf3
Author: Michael Adam <obnox at samba.org>
Date:   Wed Mar 4 22:05:17 2009 +0100

    s3:dbwrap_ctdb_marshall_add: don't leak the ctdb_rec_data to the outside
    
    Michael

commit 7ef193f9d367372a11e665505cd0c4b53b7d0cca
Author: Michael Adam <obnox at samba.org>
Date:   Wed Mar 4 22:02:07 2009 +0100

    s3:smbconf: move smbconf_share_exists checks into backend
    
    Michael

commit d69c3db9d44ad5d9fd1f5d7a9499f3bd79ecfb47
Author: Michael Adam <obnox at samba.org>
Date:   Wed Mar 4 21:46:32 2009 +0100

    s3:net conf: reduce memory usage of "net conf import".
    
    "net conf import" was wrapped in one big transaction.
    This lead to MAX_TALLOC_SIZE being exceeded at roughly
    1500 shares. This patch resolves that problem by
    limiting the top level transactions in "net conf import"
    to 100 shares.
    
    Michael

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

Summary of changes:
 source/lib/dbwrap_ctdb.c         |   12 +++++-----
 source/lib/smbconf/smbconf.c     |   24 -----------------------
 source/lib/smbconf/smbconf_reg.c |   13 ++++++++---
 source/utils/net_conf.c          |   39 ++++++++++++++++++++++++++++++++-----
 4 files changed, 48 insertions(+), 40 deletions(-)


Changeset truncated at 500 lines:

diff --git a/source/lib/dbwrap_ctdb.c b/source/lib/dbwrap_ctdb.c
index 816b522..60dc857 100644
--- a/source/lib/dbwrap_ctdb.c
+++ b/source/lib/dbwrap_ctdb.c
@@ -121,9 +121,9 @@ static struct ctdb_marshall_buffer *db_ctdb_marshall_add(TALLOC_CTX *mem_ctx,
 {
 	struct ctdb_rec_data *r;
 	size_t m_size, r_size;
-	struct ctdb_marshall_buffer *m2;
+	struct ctdb_marshall_buffer *m2 = NULL;
 
-	r = db_ctdb_marshall_record(mem_ctx, reqid, key, header, data);
+	r = db_ctdb_marshall_record(talloc_tos(), reqid, key, header, data);
 	if (r == NULL) {
 		talloc_free(m);
 		return NULL;
@@ -133,7 +133,7 @@ static struct ctdb_marshall_buffer *db_ctdb_marshall_add(TALLOC_CTX *mem_ctx,
 		m = (struct ctdb_marshall_buffer *)talloc_zero_size(
 			mem_ctx, offsetof(struct ctdb_marshall_buffer, data));
 		if (m == NULL) {
-			return NULL;
+			goto done;
 		}
 		m->db_id = db_id;
 	}
@@ -145,15 +145,15 @@ static struct ctdb_marshall_buffer *db_ctdb_marshall_add(TALLOC_CTX *mem_ctx,
 		mem_ctx, m,  m_size + r_size);
 	if (m2 == NULL) {
 		talloc_free(m);
-		return NULL;
+		goto done;
 	}
 
 	memcpy(m_size + (uint8_t *)m2, r, r_size);
 
-	talloc_free(r);
-
 	m2->count++;
 
+done:
+	talloc_free(r);
 	return m2;
 }
 
diff --git a/source/lib/smbconf/smbconf.c b/source/lib/smbconf/smbconf.c
index 3290198..01557a7 100644
--- a/source/lib/smbconf/smbconf.c
+++ b/source/lib/smbconf/smbconf.c
@@ -226,10 +226,6 @@ WERROR smbconf_set_parameter(struct smbconf_ctx *ctx,
 			     const char *param,
 			     const char *valstr)
 {
-	if (!smbconf_share_exists(ctx, service)) {
-		return WERR_NO_SUCH_SERVICE;
-	}
-
 	return ctx->ops->set_parameter(ctx, service, param, valstr);
 }
 
@@ -265,10 +261,6 @@ WERROR smbconf_get_parameter(struct smbconf_ctx *ctx,
 		return WERR_INVALID_PARAM;
 	}
 
-	if (!smbconf_share_exists(ctx, service)) {
-		return WERR_NO_SUCH_SERVICE;
-	}
-
 	return ctx->ops->get_parameter(ctx, mem_ctx, service, param, valstr);
 }
 
@@ -299,10 +291,6 @@ WERROR smbconf_get_global_parameter(struct smbconf_ctx *ctx,
 WERROR smbconf_delete_parameter(struct smbconf_ctx *ctx,
 				const char *service, const char *param)
 {
-	if (!smbconf_share_exists(ctx, service)) {
-		return WERR_NO_SUCH_SERVICE;
-	}
-
 	return ctx->ops->delete_parameter(ctx, service, param);
 }
 
@@ -329,10 +317,6 @@ WERROR smbconf_get_includes(struct smbconf_ctx *ctx,
 			    const char *service,
 			    uint32_t *num_includes, char ***includes)
 {
-	if (!smbconf_share_exists(ctx, service)) {
-		return WERR_NO_SUCH_SERVICE;
-	}
-
 	return ctx->ops->get_includes(ctx, mem_ctx, service, num_includes,
 				      includes);
 }
@@ -356,10 +340,6 @@ WERROR smbconf_set_includes(struct smbconf_ctx *ctx,
 			    const char *service,
 			    uint32_t num_includes, const char **includes)
 {
-	if (!smbconf_share_exists(ctx, service)) {
-		return WERR_NO_SUCH_SERVICE;
-	}
-
 	return ctx->ops->set_includes(ctx, service, num_includes, includes);
 }
 
@@ -381,10 +361,6 @@ WERROR smbconf_set_global_includes(struct smbconf_ctx *ctx,
 
 WERROR smbconf_delete_includes(struct smbconf_ctx *ctx, const char *service)
 {
-	if (!smbconf_share_exists(ctx, service)) {
-		return WERR_NO_SUCH_SERVICE;
-	}
-
 	return ctx->ops->delete_includes(ctx, service);
 }
 
diff --git a/source/lib/smbconf/smbconf_reg.c b/source/lib/smbconf/smbconf_reg.c
index 59f7b62..9a78692 100644
--- a/source/lib/smbconf/smbconf_reg.c
+++ b/source/lib/smbconf/smbconf_reg.c
@@ -80,12 +80,20 @@ static WERROR smbconf_reg_open_service_key(TALLOC_CTX *mem_ctx,
 					   uint32 desired_access,
 					   struct registry_key **key)
 {
+	WERROR werr;
+
 	if (servicename == NULL) {
 		*key = rpd(ctx)->base_key;
 		return WERR_OK;
 	}
-	return reg_openkey(mem_ctx, rpd(ctx)->base_key, servicename,
+	werr = reg_openkey(mem_ctx, rpd(ctx)->base_key, servicename,
 			   desired_access, key);
+
+	if (W_ERROR_EQUAL(werr, WERR_BADFILE)) {
+		werr = WERR_NO_SUCH_SERVICE;
+	}
+
+	return werr;
 }
 
 /**
@@ -828,9 +836,6 @@ static WERROR smbconf_reg_get_share(struct smbconf_ctx *ctx,
 	werr = smbconf_reg_open_service_key(tmp_ctx, ctx, servicename,
 					    REG_KEY_READ, &key);
 	if (!W_ERROR_IS_OK(werr)) {
-		if (W_ERROR_EQUAL(werr, WERR_BADFILE)) {
-			werr = WERR_NO_SUCH_SERVICE;
-		}
 		goto done;
 	}
 
diff --git a/source/utils/net_conf.c b/source/utils/net_conf.c
index 4f4ad85..9867a4a 100644
--- a/source/utils/net_conf.c
+++ b/source/utils/net_conf.c
@@ -314,12 +314,6 @@ static int net_conf_import(struct smbconf_ctx *conf_ctx,
 			 "would import the following configuration:\n\n");
 	}
 
-	werr = smbconf_transaction_start(conf_ctx);
-	if (!W_ERROR_IS_OK(werr)) {
-		d_printf("error starting transaction: %s\n", dos_errstr(werr));
-		goto done;
-	}
-
 	if (servicename != NULL) {
 		struct smbconf_service *service = NULL;
 
@@ -349,11 +343,44 @@ static int net_conf_import(struct smbconf_ctx *conf_ctx,
 				goto cancel;
 			}
 		}
+
+		/*
+		 * Wrap the importing of shares into a transaction,
+		 * but only 100 at a time, in order to serve memory.
+		 * The allocated memory accumulates across the actions
+		 * within the transaction, and for me, some 1500
+		 * imported shares, the MAX_TALLOC_SIZE of 256 MB
+		 * was exceeded.
+		 */
+		werr = smbconf_transaction_start(conf_ctx);
+		if (!W_ERROR_IS_OK(werr)) {
+			d_printf("error starting transaction: %s\n",
+				 dos_errstr(werr));
+			goto done;
+		}
+
 		for (sidx = 0; sidx < num_shares; sidx++) {
 			werr = import_process_service(conf_ctx, services[sidx]);
 			if (!W_ERROR_IS_OK(werr)) {
 				goto cancel;
 			}
+
+			if (sidx % 100) {
+				continue;
+			}
+
+			werr = smbconf_transaction_commit(conf_ctx);
+			if (!W_ERROR_IS_OK(werr)) {
+				d_printf("error committing transaction: %s\n",
+					 dos_errstr(werr));
+				goto done;
+			}
+			werr = smbconf_transaction_start(conf_ctx);
+			if (!W_ERROR_IS_OK(werr)) {
+				d_printf("error starting transaction: %s\n",
+					 dos_errstr(werr));
+				goto done;
+			}
 		}
 	}
 


-- 
SAMBA-CTDB repository


More information about the samba-cvs mailing list