The branch, master has been updated
       via  cae4105... s3: Remove unused bitmap_[allocate|free]
       via  59d09cb... s3: Use bitmap_talloc in vfs_full_audit.c
       via  d3c6f4a... s3: Use bitmap_talloc for smb1 server tcons
       via  c67e498... s3: Use bitmap_talloc in init_dptrs
       via  30c708b... s3: Use bitmap_talloc in files.c
       via  0205633... s3: Use bitmap_talloc in loadparm
       via  48f90be... s3: A NULL context might be perfectly valid for 
bitmap_talloc
       via  2356c22... s3: Fix a memleak in bitmap_talloc
       via  8a43679... s3: Use TALLOC_ZERO_ARRAY in bitmap_talloc
       via  ed5a65d... s3: Fix the memory hierarchy in bitmap_talloc
       via  d77a1fb... s3: Slightly simplify logic in conv_str_size
       via  ea0f937... s3: Fix indentation in conv_str_size
       via  e541013... s3: Fix some nonempty blank lines
       via  4d8a974... s3: Use tdb_transaction_start_nonblock in 
gencache_stabilize
       via  d5fd1f2... Revert "s3: Optimize gencache for smbd exit"
       via  3caaca9... s3: Fix typos in a debug message in vfs_init_custom
      from  09a676a... s4-selftest: use CONFIG_H environment variable to find 
config.h

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


- Log -----------------------------------------------------------------
commit cae4105c9232c4d11a13fe21c139b99e803a0282
Author: Volker Lendecke <v...@samba.org>
Date:   Sun Mar 28 14:32:47 2010 +0200

    s3: Remove unused bitmap_[allocate|free]

commit 59d09cbed8e6fde867b88dce4408b64132e4ca6d
Author: Volker Lendecke <v...@samba.org>
Date:   Sun Mar 28 14:26:53 2010 +0200

    s3: Use bitmap_talloc in vfs_full_audit.c
    
    This also simplifies the calling convention for init_bitmap() slightly

commit d3c6f4ae17d1311f90d549bd8d7e22e802e0be1a
Author: Volker Lendecke <v...@samba.org>
Date:   Sun Mar 28 14:19:17 2010 +0200

    s3: Use bitmap_talloc for smb1 server tcons

commit c67e498ae863bb5f25dcb36162c473ede46400be
Author: Volker Lendecke <v...@samba.org>
Date:   Sun Mar 28 14:16:55 2010 +0200

    s3: Use bitmap_talloc in init_dptrs

commit 30c708b902b6945e2cbcb7e1de40d475ce00eaad
Author: Volker Lendecke <v...@samba.org>
Date:   Sun Mar 28 14:14:48 2010 +0200

    s3: Use bitmap_talloc in files.c

commit 0205633ed94a19d8723c3f2f252daf1b96729375
Author: Volker Lendecke <v...@samba.org>
Date:   Sun Mar 28 14:13:48 2010 +0200

    s3: Use bitmap_talloc in loadparm

commit 48f90be7b9560258054486dce6514476b669ebfb
Author: Volker Lendecke <v...@samba.org>
Date:   Sun Mar 28 14:05:55 2010 +0200

    s3: A NULL context might be perfectly valid for bitmap_talloc

commit 2356c22825de020ebf4ae8cb664fea96dc981749
Author: Volker Lendecke <v...@samba.org>
Date:   Sun Mar 28 14:03:57 2010 +0200

    s3: Fix a memleak in bitmap_talloc

commit 8a43679cea769b3f568def53006690ef23c083c6
Author: Volker Lendecke <v...@samba.org>
Date:   Sun Mar 28 14:03:31 2010 +0200

    s3: Use TALLOC_ZERO_ARRAY in bitmap_talloc

commit ed5a65d7a0f6a3e9697184b4e32081a77b65f78b
Author: Volker Lendecke <v...@samba.org>
Date:   Sun Mar 28 14:02:47 2010 +0200

    s3: Fix the memory hierarchy in bitmap_talloc

commit d77a1fb272d06e9fa4f4b1cbe9b151625334ca9f
Author: Volker Lendecke <v...@samba.org>
Date:   Sun Mar 28 13:16:58 2010 +0200

    s3: Slightly simplify logic in conv_str_size

commit ea0f9378a02ed3b64ab3b4f71862bfcb449d2b42
Author: Volker Lendecke <v...@samba.org>
Date:   Sun Mar 28 13:16:18 2010 +0200

    s3: Fix indentation in conv_str_size

commit e541013e20572c96f7fe12814742b6f9eb3084db
Author: Volker Lendecke <v...@samba.org>
Date:   Sun Mar 28 13:13:03 2010 +0200

    s3: Fix some nonempty blank lines

commit 4d8a974ddc1333a1e3c6ddf4a0e215a5e41e1074
Author: Volker Lendecke <v...@samba.org>
Date:   Fri Mar 26 13:18:52 2010 +0100

    s3: Use tdb_transaction_start_nonblock in gencache_stabilize
    
    This avoids the thundering herd problem when 5000 smbds exit simultaneously
    because the network went down.

commit d5fd1f207757b4f15d15b8744db0c9380fe63cab
Author: Volker Lendecke <v...@samba.org>
Date:   Fri Mar 26 13:15:53 2010 +0100

    Revert "s3: Optimize gencache for smbd exit"
    
    This reverts commit 5ca63676dc59e83ffd9560fdcfa26063f267f283.
    
    That does not fully fix the problem, adding a 
tdb_transaction_start_nonblock to fix it.

commit 3caaca90219c1fd8f7f9d668d3a537f6368b9417
Author: Volker Lendecke <v...@samba.org>
Date:   Sun Mar 28 14:21:49 2010 +0200

    s3: Fix typos in a debug message in vfs_init_custom

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

Summary of changes:
 source3/include/proto.h          |    2 -
 source3/lib/bitmap.c             |   44 +----------------
 source3/lib/gencache.c           |  100 +++++++++-----------------------------
 source3/lib/util_str.c           |   66 +++++++++++++------------
 source3/modules/vfs_full_audit.c |   60 ++++++++---------------
 source3/modules/vfs_recycle.c    |   39 +++++++--------
 source3/param/loadparm.c         |   11 ++--
 source3/smbd/conn.c              |    6 +-
 source3/smbd/dir.c               |    3 +-
 source3/smbd/files.c             |    3 +-
 source3/smbd/vfs.c               |    3 +-
 11 files changed, 115 insertions(+), 222 deletions(-)


Changeset truncated at 500 lines:

diff --git a/source3/include/proto.h b/source3/include/proto.h
index 7cc211b..c270a1d 100644
--- a/source3/include/proto.h
+++ b/source3/include/proto.h
@@ -334,8 +334,6 @@ const char *audit_policy_str(TALLOC_CTX *mem_ctx, uint32 
policy);
 
 /* The following definitions come from lib/bitmap.c  */
 
-struct bitmap *bitmap_allocate(int n);
-void bitmap_free(struct bitmap *bm);
 struct bitmap *bitmap_talloc(TALLOC_CTX *mem_ctx, int n);
 int bitmap_copy(struct bitmap * const dst, const struct bitmap * const src);
 bool bitmap_set(struct bitmap *bm, unsigned i);
diff --git a/source3/lib/bitmap.c b/source3/lib/bitmap.c
index f753ffd..bd56b4a 100644
--- a/source3/lib/bitmap.c
+++ b/source3/lib/bitmap.c
@@ -23,62 +23,22 @@
    pool without repetition */
 
 /****************************************************************************
-allocate a bitmap of the specified size
-****************************************************************************/
-struct bitmap *bitmap_allocate(int n)
-{
-       struct bitmap *bm;
-
-       bm = SMB_MALLOC_P(struct bitmap);
-
-       if (!bm) return NULL;
-
-       bm->n = n;
-       bm->b = SMB_MALLOC_ARRAY(uint32, (n+31)/32);
-       if (!bm->b) {
-               SAFE_FREE(bm);
-               return NULL;
-       }
-
-       memset(bm->b, 0, sizeof(uint32)*((n+31)/32));
-
-       return bm;
-}
-
-/****************************************************************************
-free a bitmap.
-****************************************************************************/
-
-void bitmap_free(struct bitmap *bm)
-{
-       if (!bm)
-               return;
-
-       SAFE_FREE(bm->b);
-       SAFE_FREE(bm);
-}
-
-/****************************************************************************
 talloc a bitmap
 ****************************************************************************/
 struct bitmap *bitmap_talloc(TALLOC_CTX *mem_ctx, int n)
 {
        struct bitmap *bm;
 
-       if (!mem_ctx) return NULL;
-
        bm = TALLOC_P(mem_ctx, struct bitmap);
 
        if (!bm) return NULL;
 
        bm->n = n;
-       bm->b = TALLOC_ARRAY(mem_ctx, uint32, (n+31)/32);
+       bm->b = TALLOC_ZERO_ARRAY(bm, uint32, (n+31)/32);
        if (!bm->b) {
+               TALLOC_FREE(bm);
                return NULL;
        }
-
-       memset(bm->b, 0, sizeof(uint32)*((n+31)/32));
-
        return bm;
 }
 
diff --git a/source3/lib/gencache.c b/source3/lib/gencache.c
index 577ff12..a78e60a 100644
--- a/source3/lib/gencache.c
+++ b/source3/lib/gencache.c
@@ -40,13 +40,6 @@ static struct tdb_context *cache_notrans;
  * @brief Generic, persistent and shared between processes cache mechanism
  *        for use by various parts of the Samba code
  *
- * We have two cache files, one with transactions (gencache.tdb) and
- * one without (gencache_notrans.tdb) that is CLEAR_IF_FIRST. Normal
- * writes go to the gencache_notrans.tdb to be fast. Every 100 writes
- * to the gencache (settable with gencache:stabilize_count) or every 5
- * minutes (settable with gencache:stabilize_interval) we stabilize
- * gencache_notrans.tdb with one transaction to gencache.tdb.
- *
  **/
 
 
@@ -114,8 +107,7 @@ again:
 
        DEBUG(5, ("Opening cache file at %s\n", cache_fname));
 
-       cache_notrans = tdb_open_log(cache_fname, 0,
-                                    TDB_CLEAR_IF_FIRST | TDB_SEQNUM,
+       cache_notrans = tdb_open_log(cache_fname, 0, TDB_CLEAR_IF_FIRST,
                                     open_flags, 0644);
        if (cache_notrans == NULL) {
                DEBUG(5, ("Opening %s failed: %s\n", cache_fname,
@@ -136,51 +128,6 @@ static TDB_DATA last_stabilize_key(void)
        return result;
 }
 
-struct gencache_parse_last_stabilize_state {
-       bool found;
-       int last_time;
-       int last_seqnum;
-};
-
-static int gencache_parse_last_stabilize_fn(TDB_DATA key, TDB_DATA data,
-                                           void *private_data)
-{
-       struct gencache_parse_last_stabilize_state *state =
-               (struct gencache_parse_last_stabilize_state *)private_data;
-
-       if ((data.dptr == NULL) || (data.dsize == 0) ||
-           (data.dptr[data.dsize-1] != '\0')) {
-               return -1;
-       }
-
-       if (sscanf((char *)data.dptr, "%d/%d", &state->last_time,
-                  &state->last_seqnum) != 2) {
-               return -1;
-       }
-
-       state->found = true;
-       return 0;
-}
-
-static bool gencache_parse_last_stabilize(time_t *last_time, int *last_seqnum)
-{
-       struct gencache_parse_last_stabilize_state state;
-
-       state.found = false;
-
-       if (tdb_parse_record(cache_notrans, last_stabilize_key(),
-                            gencache_parse_last_stabilize_fn,
-                            &state) == -1) {
-               return false;
-       }
-       if (!state.found) {
-               return false;
-       }
-       *last_time = state.last_time;
-       *last_seqnum = state.last_seqnum;
-       return true;
-}
-
 /**
  * Set an entry in the cache file. If there's no such
  * one, then add it.
@@ -197,9 +144,9 @@ bool gencache_set_data_blob(const char *keystr, const 
DATA_BLOB *blob,
                            time_t timeout)
 {
        int ret;
+       TDB_DATA databuf;
        char* val;
        time_t last_stabilize;
-       int last_seqnum;
        static int writecount;
 
        if (tdb_data_cmp(string_term_tdb_data(keystr),
@@ -259,15 +206,17 @@ bool gencache_set_data_blob(const char *keystr, const 
DATA_BLOB *blob,
         * gencache_notrans.tdb too large.
         */
 
-       if (gencache_parse_last_stabilize(&last_stabilize, &last_seqnum)) {
-               time_t next;
-
-               next = last_stabilize + lp_parm_int(
-                       -1, "gencache", "stabilize_interval", 300);
-
-               if (next < time(NULL)) {
-                       gencache_stabilize();
-               }
+       last_stabilize = 0;
+       databuf = tdb_fetch(cache_notrans, last_stabilize_key());
+       if ((databuf.dptr != NULL)
+           && (databuf.dptr[databuf.dsize-1] == '\0')) {
+               last_stabilize = atoi((char *)databuf.dptr);
+               SAFE_FREE(databuf.dptr);
+       }
+       if ((last_stabilize
+            + lp_parm_int(-1, "gencache", "stabilize_interval", 300))
+           < time(NULL)) {
+               gencache_stabilize();
        }
 
 done:
@@ -462,21 +411,22 @@ bool gencache_stabilize(void)
        struct stabilize_state state;
        int res;
        char *now;
-       time_t last_time;
-       int last_seqnum;
 
        if (!gencache_init()) {
                return false;
        }
 
-       if (gencache_parse_last_stabilize(&last_time, &last_seqnum)
-           && (last_seqnum == tdb_get_seqnum(cache_notrans))) {
-               /* Nothing changed */
-               return true;
-       }
-
-       res = tdb_transaction_start(cache);
+       res = tdb_transaction_start_nonblock(cache);
        if (res == -1) {
+
+               if (tdb_error(cache) == TDB_ERR_NOLOCK) {
+                       /*
+                        * Someone else already does the stabilize,
+                        * this does not have to be done twice
+                        */
+                       return true;
+               }
+
                DEBUG(10, ("Could not start transaction on gencache.tdb: "
                           "%s\n", tdb_errorstr(cache)));
                return false;
@@ -527,9 +477,7 @@ bool gencache_stabilize(void)
                return false;
        }
 
-       now = talloc_asprintf(talloc_tos(), "%d/%d",
-                             (int)time(NULL),
-                             tdb_get_seqnum(cache_notrans)+1);
+       now = talloc_asprintf(talloc_tos(), "%d", (int)time(NULL));
        if (now != NULL) {
                tdb_store(cache_notrans, last_stabilize_key(),
                          string_term_tdb_data(now), 0);
diff --git a/source3/lib/util_str.c b/source3/lib/util_str.c
index 9a0b12a..3247682 100644
--- a/source3/lib/util_str.c
+++ b/source3/lib/util_str.c
@@ -2003,6 +2003,7 @@ uint64_t STR_TO_SMB_BIG_UINT(const char *nptr, const char 
**entptr)
  */
 SMB_OFF_T conv_str_size(const char * str)
 {
+       SMB_OFF_T lval_orig;
         SMB_OFF_T lval;
        char * end;
 
@@ -2012,9 +2013,9 @@ SMB_OFF_T conv_str_size(const char * str)
 
 #ifdef HAVE_STRTOULL
        if (sizeof(SMB_OFF_T) == 8) {
-           lval = strtoull(str, &end, 10 /* base */);
+               lval = strtoull(str, &end, 10 /* base */);
        } else {
-           lval = strtoul(str, &end, 10 /* base */);
+               lval = strtoul(str, &end, 10 /* base */);
        }
 #else
        lval = strtoul(str, &end, 10 /* base */);
@@ -2024,35 +2025,38 @@ SMB_OFF_T conv_str_size(const char * str)
                 return 0;
         }
 
-        if (*end) {
-               SMB_OFF_T lval_orig = lval;
-
-                if (strwicmp(end, "K") == 0) {
-                        lval *= (SMB_OFF_T)1024;
-                } else if (strwicmp(end, "M") == 0) {
-                        lval *= ((SMB_OFF_T)1024 * (SMB_OFF_T)1024);
-                } else if (strwicmp(end, "G") == 0) {
-                        lval *= ((SMB_OFF_T)1024 * (SMB_OFF_T)1024 *
-                               (SMB_OFF_T)1024);
-                } else if (strwicmp(end, "T") == 0) {
-                        lval *= ((SMB_OFF_T)1024 * (SMB_OFF_T)1024 *
-                               (SMB_OFF_T)1024 * (SMB_OFF_T)1024);
-                } else if (strwicmp(end, "P") == 0) {
-                        lval *= ((SMB_OFF_T)1024 * (SMB_OFF_T)1024 *
-                               (SMB_OFF_T)1024 * (SMB_OFF_T)1024 *
-                               (SMB_OFF_T)1024);
-                } else {
-                        return 0;
-                }
-
-               /* Primitive attempt to detect wrapping on platforms with
-                * 4-byte SMB_OFF_T. It's better to let the caller handle
-                * a failure than some random number.
-                */
-               if (lval_orig <= lval) {
-                       return 0;
-               }
-        }
+        if (*end == '\0') {
+               return lval;
+       }
+
+       lval_orig = lval;
+
+       if (strwicmp(end, "K") == 0) {
+               lval *= (SMB_OFF_T)1024;
+       } else if (strwicmp(end, "M") == 0) {
+               lval *= ((SMB_OFF_T)1024 * (SMB_OFF_T)1024);
+       } else if (strwicmp(end, "G") == 0) {
+               lval *= ((SMB_OFF_T)1024 * (SMB_OFF_T)1024 *
+                        (SMB_OFF_T)1024);
+       } else if (strwicmp(end, "T") == 0) {
+               lval *= ((SMB_OFF_T)1024 * (SMB_OFF_T)1024 *
+                        (SMB_OFF_T)1024 * (SMB_OFF_T)1024);
+       } else if (strwicmp(end, "P") == 0) {
+               lval *= ((SMB_OFF_T)1024 * (SMB_OFF_T)1024 *
+                        (SMB_OFF_T)1024 * (SMB_OFF_T)1024 *
+                        (SMB_OFF_T)1024);
+       } else {
+               return 0;
+       }
+
+       /*
+        * Primitive attempt to detect wrapping on platforms with
+        * 4-byte SMB_OFF_T. It's better to let the caller handle a
+        * failure than some random number.
+        */
+       if (lval_orig <= lval) {
+               return 0;
+       }
 
        return lval;
 }
diff --git a/source3/modules/vfs_full_audit.c b/source3/modules/vfs_full_audit.c
index 7e7a4f4..6986a86 100644
--- a/source3/modules/vfs_full_audit.c
+++ b/source3/modules/vfs_full_audit.c
@@ -431,22 +431,19 @@ static bool log_failure(vfs_handle_struct *handle, 
vfs_op_type op)
        return bitmap_query(pd->failure_ops, op);
 }
 
-static void init_bitmap(struct bitmap **bm, const char **ops)
+static struct bitmap *init_bitmap(TALLOC_CTX *mem_ctx, const char **ops)
 {
-       if (*bm != NULL) {
-               return;
-       }
+       struct bitmap *bm;
 
        if (ops == NULL) {
-               *bm = NULL;
-               return;
+               return NULL;
        }
 
-       *bm = bitmap_allocate(SMB_VFS_OP_LAST);
-       if (*bm == NULL) {
+       bm = bitmap_talloc(mem_ctx, SMB_VFS_OP_LAST);
+       if (bm == NULL) {
                DEBUG(0, ("Could not alloc bitmap -- "
                          "defaulting to logging everything\n"));
-               return;
+               return NULL;
        }
 
        for (; *ops != NULL; ops += 1) {
@@ -456,7 +453,7 @@ static void init_bitmap(struct bitmap **bm, const char 
**ops)
 
                if (strequal(*ops, "all")) {
                        for (i=0; i<SMB_VFS_OP_LAST; i++) {
-                               bitmap_set(*bm, i);
+                               bitmap_set(bm, i);
                        }
                        continue;
                }
@@ -478,9 +475,9 @@ static void init_bitmap(struct bitmap **bm, const char 
**ops)
                        }
                        if (strequal(op, vfs_op_names[i].name)) {
                                if (neg) {
-                                       bitmap_clear(*bm, i);
+                                       bitmap_clear(bm, i);
                                } else {
-                                       bitmap_set(*bm, i);
+                                       bitmap_set(bm, i);
                                }
                                break;
                        }
@@ -488,11 +485,11 @@ static void init_bitmap(struct bitmap **bm, const char 
**ops)
                if (i == SMB_VFS_OP_LAST) {
                        DEBUG(0, ("Could not find opname %s, logging all\n",
                                  *ops));
-                       bitmap_free(*bm);
-                       *bm = NULL;
-                       break;
+                       TALLOC_FREE(bm);
+                       return NULL;
                }
        }
+       return bm;
 }
 
 static const char *audit_opname(vfs_op_type op)
@@ -588,22 +585,6 @@ static const char *fsp_str_do_log(const struct 
files_struct *fsp)
        return smb_fname_str_do_log(fsp->fsp_name);
 }
 
-/* Free function for the private data. */
-
-static void free_private_data(void **p_data)
-{
-       struct vfs_full_audit_private_data *pd = *(struct 
vfs_full_audit_private_data **)p_data;
-
-       if (pd->success_ops) {
-               bitmap_free(pd->success_ops);
-       }
-       if (pd->failure_ops) {
-               bitmap_free(pd->failure_ops);
-       }
-       SAFE_FREE(pd);
-       *p_data = NULL;
-}
-
 /* Implementation of vfs_ops.  Pass everything on to the default
    operation but log event first. */
 
@@ -618,26 +599,25 @@ static int smb_full_audit_connect(vfs_handle_struct 
*handle,
                return result;
        }
 
-       pd = SMB_MALLOC_P(struct vfs_full_audit_private_data);
+       pd = TALLOC_ZERO_P(handle, struct vfs_full_audit_private_data);
        if (!pd) {
                SMB_VFS_NEXT_DISCONNECT(handle);
                return -1;
        }
-       ZERO_STRUCTP(pd);
 
 #ifndef WITH_SYSLOG
        openlog("smbd_audit", 0, audit_syslog_facility(handle));
 #endif
 
-       init_bitmap(&pd->success_ops,
-                   lp_parm_string_list(SNUM(handle->conn), "full_audit", 
"success",
-                                       NULL));
-       init_bitmap(&pd->failure_ops,
-                   lp_parm_string_list(SNUM(handle->conn), "full_audit", 
"failure",
-                                       NULL));
+       pd->success_ops = init_bitmap(
+               pd, lp_parm_string_list(SNUM(handle->conn), "full_audit",
+                                       "success", NULL));
+       pd->failure_ops = init_bitmap(
+               pd, lp_parm_string_list(SNUM(handle->conn), "full_audit",
+                                       "failure", NULL));
 
        /* Store the private data. */
-       SMB_VFS_HANDLE_SET_DATA(handle, pd, free_private_data,
+       SMB_VFS_HANDLE_SET_DATA(handle, pd, NULL,
                                struct vfs_full_audit_private_data, return -1);
 
        do_log(SMB_VFS_OP_CONNECT, True, handle,
diff --git a/source3/modules/vfs_recycle.c b/source3/modules/vfs_recycle.c
index 6674427..fb009a1 100644
--- a/source3/modules/vfs_recycle.c
+++ b/source3/modules/vfs_recycle.c
@@ -61,23 +61,22 @@ static void recycle_disconnect(vfs_handle_struct *handle)
 static const char *recycle_repository(vfs_handle_struct *handle)
 {
        const char *tmp_str = NULL;
-       
 
        tmp_str = lp_parm_const_string(SNUM(handle->conn), "recycle", 
"repository",".recycle");
 
        DEBUG(10, ("recycle: repository = %s\n", tmp_str));
-       
+
        return tmp_str;
 }
 
 static bool recycle_keep_dir_tree(vfs_handle_struct *handle)
 {
        bool ret;
-       
+
        ret = lp_parm_bool(SNUM(handle->conn), "recycle", "keeptree", False);
 
        DEBUG(10, ("recycle_bin: keeptree = %s\n", ret?"True":"False"));
-       
+
        return ret;
 }
 
@@ -88,7 +87,7 @@ static bool recycle_versions(vfs_handle_struct *handle)
        ret = lp_parm_bool(SNUM(handle->conn), "recycle", "versions", False);
 
        DEBUG(10, ("recycle: versions = %s\n", ret?"True":"False"));
-       
+
        return ret;


-- 
Samba Shared Repository

Reply via email to