The Samba-Bugzilla – Attachment 7003 Details for
Bug 8527
db_ctdb_traverse fails to traverse records created within the current transaction
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Patches for v3-6-test
tmp36.diff (text/plain), 8.33 KB, created by
Stefan Metzmacher
on 2011-10-15 08:47:37 UTC
(
hide
)
Description:
Patches for v3-6-test
Filename:
MIME Type:
Creator:
Stefan Metzmacher
Created:
2011-10-15 08:47:37 UTC
Size:
8.33 KB
patch
obsolete
>From 65a037f75f3ab36cfbaf90c0b60d76cd8e2edfce Mon Sep 17 00:00:00 2001 >From: Michael Adam <obnox@samba.org> >Date: Fri, 14 Oct 2011 16:33:00 +0200 >Subject: [PATCH 1/4] s3:dbwrap: change the dbwrap_traverse() wrapper to return the count in an additional parameter > (similar to commit 8f098a635f713652c4846d71e24c0a199c25b8b7) > >Signed-off-by: Stefan Metzmacher <metze@samba.org> >--- > source3/include/dbwrap.h | 3 ++- > source3/lib/dbwrap_util.c | 13 ++++++++++--- > source3/utils/net_idmap_check.c | 6 +++--- > 3 files changed, 15 insertions(+), 7 deletions(-) > >diff --git a/source3/include/dbwrap.h b/source3/include/dbwrap.h >index d657ee7..8938880 100644 >--- a/source3/include/dbwrap.h >+++ b/source3/include/dbwrap.h >@@ -134,7 +134,8 @@ NTSTATUS dbwrap_trans_traverse(struct db_context *db, > void *private_data); > NTSTATUS dbwrap_traverse(struct db_context *db, > int (*f)(struct db_record*, void*), >- void *private_data); >+ void *private_data, >+ int *count); > > NTSTATUS dbwrap_delete_bystring_upper(struct db_context *db, const char *key); > NTSTATUS dbwrap_store_bystring_upper(struct db_context *db, const char *key, >diff --git a/source3/lib/dbwrap_util.c b/source3/lib/dbwrap_util.c >index 365f0a0..1e28f84 100644 >--- a/source3/lib/dbwrap_util.c >+++ b/source3/lib/dbwrap_util.c >@@ -446,14 +446,21 @@ NTSTATUS dbwrap_trans_traverse(struct db_context *db, > > NTSTATUS dbwrap_traverse(struct db_context *db, > int (*f)(struct db_record*, void*), >- void *private_data) >+ void *private_data, >+ int *count) > { > int ret = db->traverse(db, f, private_data); >- return (ret == -1) ? NT_STATUS_INTERNAL_DB_CORRUPTION : NT_STATUS_OK; >-} > >+ if (ret < 0) { >+ return NT_STATUS_INTERNAL_DB_CORRUPTION; >+ } > >+ if (count != NULL) { >+ *count = ret; >+ } > >+ return NT_STATUS_OK; >+} > > NTSTATUS dbwrap_delete_bystring_upper(struct db_context *db, const char *key) > { >diff --git a/source3/utils/net_idmap_check.c b/source3/utils/net_idmap_check.c >index e406a65..25997b1 100644 >--- a/source3/utils/net_idmap_check.c >+++ b/source3/utils/net_idmap_check.c >@@ -890,7 +890,7 @@ static bool check_do_checks(struct check_ctx* ctx) > return false; > } > >- status = dbwrap_traverse(ctx->db, traverse_check, ctx); >+ status = dbwrap_traverse(ctx->db, traverse_check, ctx, NULL); > > if (!NT_STATUS_IS_OK(status)) { > DEBUG(0, ("failed to traverse %s\n", ctx->name)); >@@ -927,7 +927,7 @@ static bool check_transaction_cancel(struct check_ctx* ctx) { > > > static void check_diff_list(struct check_ctx* ctx) { >- NTSTATUS status = dbwrap_traverse(ctx->diff, traverse_print_diff, ctx); >+ NTSTATUS status = dbwrap_traverse(ctx->diff, traverse_print_diff, ctx, NULL); > > if (!NT_STATUS_IS_OK(status)) { > DEBUG(0, ("failed to traverse diff\n")); >@@ -963,7 +963,7 @@ static bool check_commit(struct check_ctx* ctx) > return false; > } > >- status = dbwrap_traverse(ctx->diff, traverse_commit, ctx); >+ status = dbwrap_traverse(ctx->diff, traverse_commit, ctx, NULL); > > if (!NT_STATUS_IS_OK(status)) { > check_transaction_cancel(ctx); >-- >1.7.4.1 > > >From f51dc3c853b4700161a9fbedddb0db8e45ddf6c7 Mon Sep 17 00:00:00 2001 >From: Gregor Beck <gbeck@sernet.de> >Date: Thu, 22 Sep 2011 13:58:24 +0200 >Subject: [PATCH 2/4] s3:dbwrap: traverse records created within this transaction. > >Signed-off-by: Michael Adam <obnox@samba.org> >(cherry picked from commit a6cd71da858062a66f83775cf655b79b6c8d75e7) >--- > source3/lib/dbwrap_ctdb.c | 40 +++++++++++++++++++++++++++++++++++++++- > 1 files changed, 39 insertions(+), 1 deletions(-) > >diff --git a/source3/lib/dbwrap_ctdb.c b/source3/lib/dbwrap_ctdb.c >index 468a74f..463af54 100644 >--- a/source3/lib/dbwrap_ctdb.c >+++ b/source3/lib/dbwrap_ctdb.c >@@ -1246,6 +1246,13 @@ static int traverse_persistent_callback(TDB_CONTEXT *tdb, TDB_DATA kbuf, TDB_DAT > return ret; > } > >+/* wrapper to use traverse_persistent_callback with dbwrap */ >+static int traverse_persistent_callback_dbwrap(struct db_record *rec, void* data) >+{ >+ return traverse_persistent_callback(NULL, rec->key, rec->value, data); >+} >+ >+ > static int db_ctdb_traverse(struct db_context *db, > int (*fn)(struct db_record *rec, > void *private_data), >@@ -1260,9 +1267,40 @@ static int db_ctdb_traverse(struct db_context *db, > state.private_data = private_data; > > if (db->persistent) { >+ struct tdb_context *ltdb = ctx->wtdb->tdb; >+ int ret; >+ > /* for persistent databases we don't need to do a ctdb traverse, > we can do a faster local traverse */ >- return tdb_traverse(ctx->wtdb->tdb, traverse_persistent_callback, &state); >+ ret = tdb_traverse(ltdb, traverse_persistent_callback, &state); >+ if (ret < 0) { >+ return ret; >+ } >+ if (ctx->transaction && ctx->transaction->m_write) { >+ /* we now have to handle keys not yet present at transaction start */ >+ struct db_context *newkeys = db_open_rbt(talloc_tos()); >+ struct ctdb_marshall_buffer *mbuf = ctx->transaction->m_write; >+ struct ctdb_rec_data *rec=NULL; >+ NTSTATUS status; >+ int i; >+ for (i=0; i<mbuf->count; i++) { >+ TDB_DATA key; >+ rec =db_ctdb_marshall_loop_next(mbuf, rec, >+ NULL, NULL, >+ &key, NULL); >+ SMB_ASSERT(rec != NULL); >+ >+ if (!tdb_exists(ltdb, key)) { >+ dbwrap_store(newkeys, key, tdb_null, 0); >+ } >+ } >+ status = dbwrap_traverse(newkeys, >+ traverse_persistent_callback_dbwrap, >+ &state); >+ ret = NT_STATUS_IS_OK(status) ? 0 : -1; >+ talloc_free(newkeys); >+ } >+ return ret; > } > > >-- >1.7.4.1 > > >From af3872c9e153c425f9d3eaa9029c5bfc18145532 Mon Sep 17 00:00:00 2001 >From: =?UTF-8?q?G=C3=BCnther=20Deschner?= <gd@samba.org> >Date: Wed, 12 Oct 2011 11:48:55 +0200 >Subject: [PATCH 3/4] s3-dbwrap_ctdb: fix the build. >MIME-Version: 1.0 >Content-Type: text/plain; charset=UTF-8 >Content-Transfer-Encoding: 8bit > >Michael, please check. > >Guenther > >Autobuild-User: Günther Deschner <gd@samba.org> >Autobuild-Date: Wed Oct 12 15:25:56 CEST 2011 on sn-devel-104 >(cherry picked from commit fc320551d84508371ab1c082752515d538648f49) >--- > source3/lib/dbwrap_ctdb.c | 4 +++- > 1 files changed, 3 insertions(+), 1 deletions(-) > >diff --git a/source3/lib/dbwrap_ctdb.c b/source3/lib/dbwrap_ctdb.c >index 463af54..7481d88 100644 >--- a/source3/lib/dbwrap_ctdb.c >+++ b/source3/lib/dbwrap_ctdb.c >@@ -22,6 +22,7 @@ > #include "system/filesys.h" > #include "lib/util/tdb_wrap.h" > #include "util_tdb.h" >+ > #ifdef CLUSTER_SUPPORT > #include "ctdb.h" > #include "ctdb_private.h" >@@ -1296,7 +1297,8 @@ static int db_ctdb_traverse(struct db_context *db, > } > status = dbwrap_traverse(newkeys, > traverse_persistent_callback_dbwrap, >- &state); >+ &state, >+ NULL); > ret = NT_STATUS_IS_OK(status) ? 0 : -1; > talloc_free(newkeys); > } >-- >1.7.4.1 > > >From 860f45c481e4611f1f724e643f7ea8e512b05d68 Mon Sep 17 00:00:00 2001 >From: Stefan Metzmacher <metze@samba.org> >Date: Fri, 14 Oct 2011 16:11:06 +0200 >Subject: [PATCH 4/4] s3:dbwrap_ctdb: return the number of records in db_ctdb_traverse() for persistent dbs > >metze > >Autobuild-User: Stefan Metzmacher <metze@samba.org> >Autobuild-Date: Fri Oct 14 20:59:37 CEST 2011 on sn-devel-104 >(cherry picked from commit 15b8efeae3b0133ae60a8ce582e4ca4d4dbe6bb1) >--- > source3/lib/dbwrap_ctdb.c | 18 +++++++++++++++--- > 1 files changed, 15 insertions(+), 3 deletions(-) > >diff --git a/source3/lib/dbwrap_ctdb.c b/source3/lib/dbwrap_ctdb.c >index 7481d88..2c68f21 100644 >--- a/source3/lib/dbwrap_ctdb.c >+++ b/source3/lib/dbwrap_ctdb.c >@@ -1278,12 +1278,21 @@ static int db_ctdb_traverse(struct db_context *db, > return ret; > } > if (ctx->transaction && ctx->transaction->m_write) { >- /* we now have to handle keys not yet present at transaction start */ >+ /* >+ * we now have to handle keys not yet >+ * present at transaction start >+ */ > struct db_context *newkeys = db_open_rbt(talloc_tos()); > struct ctdb_marshall_buffer *mbuf = ctx->transaction->m_write; > struct ctdb_rec_data *rec=NULL; > NTSTATUS status; > int i; >+ int count = 0; >+ >+ if (newkeys == NULL) { >+ return -1; >+ } >+ > for (i=0; i<mbuf->count; i++) { > TDB_DATA key; > rec =db_ctdb_marshall_loop_next(mbuf, rec, >@@ -1298,9 +1307,12 @@ static int db_ctdb_traverse(struct db_context *db, > status = dbwrap_traverse(newkeys, > traverse_persistent_callback_dbwrap, > &state, >- NULL); >- ret = NT_STATUS_IS_OK(status) ? 0 : -1; >+ &count); > talloc_free(newkeys); >+ if (!NT_STATUS_IS_OK(status)) { >+ return -1; >+ } >+ ret += count; > } > return ret; > } >-- >1.7.4.1 >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Flags:
obnox
:
review+
Actions:
View
Attachments on
bug 8527
:
6999
| 7003