The branch, master has been updated
       via  bb0fb975621f4962fb7e2438396d94818891151b (commit)
       via  9d798494a90c13d605a52644a1a386a9fb109063 (commit)
       via  094578903184e2702d2a5000bf448a89954acf95 (commit)
      from  f9636b0c01b962d2915895ef7125eed955423ded (commit)

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


- Log -----------------------------------------------------------------
commit bb0fb975621f4962fb7e2438396d94818891151b
Author: Michael Adam <[email protected]>
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 9d798494a90c13d605a52644a1a386a9fb109063
Author: Michael Adam <[email protected]>
Date:   Wed Mar 4 22:02:07 2009 +0100

    s3:smbconf: move smbconf_share_exists checks into backend
    
    Michael

commit 094578903184e2702d2a5000bf448a89954acf95
Author: Michael Adam <[email protected]>
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:
 lib/smbconf/smbconf.c             |   24 ----------------------
 source3/lib/dbwrap_ctdb.c         |   12 +++++-----
 source3/lib/smbconf/smbconf_reg.c |   13 ++++++++---
 source3/utils/net_conf.c          |   39 +++++++++++++++++++++++++++++++-----
 4 files changed, 48 insertions(+), 40 deletions(-)


Changeset truncated at 500 lines:

diff --git a/lib/smbconf/smbconf.c b/lib/smbconf/smbconf.c
index f25ccae..80fe9aa 100644
--- a/lib/smbconf/smbconf.c
+++ b/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/source3/lib/dbwrap_ctdb.c b/source3/lib/dbwrap_ctdb.c
index 03667ff..4a5bf6d 100644
--- a/source3/lib/dbwrap_ctdb.c
+++ b/source3/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/source3/lib/smbconf/smbconf_reg.c 
b/source3/lib/smbconf/smbconf_reg.c
index 5a5c0ea..ae6a411 100644
--- a/source3/lib/smbconf/smbconf_reg.c
+++ b/source3/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/source3/utils/net_conf.c b/source3/utils/net_conf.c
index 05b552c..38a2553 100644
--- a/source3/utils/net_conf.c
+++ b/source3/utils/net_conf.c
@@ -331,12 +331,6 @@ static int net_conf_import(struct net_context *c, 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", win_errstr(werr));
-               goto done;
-       }
-
        if (servicename != NULL) {
                struct smbconf_service *service = NULL;
 
@@ -366,12 +360,45 @@ static int net_conf_import(struct net_context *c, 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",
+                                win_errstr(werr));
+                       goto done;
+               }
+
                for (sidx = 0; sidx < num_shares; sidx++) {
                        werr = import_process_service(c, 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",
+                                        win_errstr(werr));
+                               goto done;
+                       }
+                       werr = smbconf_transaction_start(conf_ctx);
+                       if (!W_ERROR_IS_OK(werr)) {
+                               d_printf("error starting transaction: %s\n",
+                                        win_errstr(werr));
+                               goto done;
+                       }
                }
        }
 


-- 
Samba Shared Repository

Reply via email to