diff options
author | Volker Lendecke <vl@samba.org> | 2012-11-12 13:42:23 +0100 |
---|---|---|
committer | Michael Adam <obnox@samba.org> | 2012-11-29 18:18:49 +0100 |
commit | 343ce16e0b52acd3d109eb619f60e394c1e04abb (patch) | |
tree | f1cce78f4f29a2aad455fdf51297718caab141ce /source3 | |
parent | 6b8a37f5ca83c45e2cac262f4d9eee5c7750c283 (diff) | |
download | samba-343ce16e0b52acd3d109eb619f60e394c1e04abb.tar.gz samba-343ce16e0b52acd3d109eb619f60e394c1e04abb.tar.bz2 samba-343ce16e0b52acd3d109eb619f60e394c1e04abb.zip |
s3: Remove db_ctdb_fetch
Note that this also makes the request for read only copies
much more explicity visible in the code.
Reviewed-by: Michael Adam <obnox@samba.org>
Diffstat (limited to 'source3')
-rw-r--r-- | source3/lib/dbwrap/dbwrap_ctdb.c | 66 |
1 files changed, 11 insertions, 55 deletions
diff --git a/source3/lib/dbwrap/dbwrap_ctdb.c b/source3/lib/dbwrap/dbwrap_ctdb.c index 624840e746..c96dda29fc 100644 --- a/source3/lib/dbwrap/dbwrap_ctdb.c +++ b/source3/lib/dbwrap/dbwrap_ctdb.c @@ -1167,63 +1167,10 @@ static struct db_record *db_ctdb_try_fetch_locked(struct db_context *db, return fetch_locked_internal(ctx, mem_ctx, key, true); } -/* - fetch (unlocked, no migration) operation on ctdb - */ -static NTSTATUS db_ctdb_fetch(struct db_context *db, TALLOC_CTX *mem_ctx, - TDB_DATA key, TDB_DATA *data) -{ - struct db_ctdb_ctx *ctx = talloc_get_type_abort(db->private_data, - struct db_ctdb_ctx); - NTSTATUS status; - TDB_DATA ctdb_data; - - /* try a direct fetch */ - ctdb_data = tdb_fetch_compat(ctx->wtdb->tdb, key); - - /* - * See if we have a valid record and we are the dmaster. If so, we can - * take the shortcut and just return it. - * we bypass the dmaster check for persistent databases - */ - if (db_ctdb_can_use_local_copy(ctdb_data, true)) { - /* - * We have a valid local copy - avoid the ctdb protocol op - */ - data->dsize = ctdb_data.dsize - sizeof(struct ctdb_ltdb_header); - - data->dptr = (uint8_t *)talloc_memdup( - mem_ctx, ctdb_data.dptr+sizeof(struct ctdb_ltdb_header), - data->dsize); - - SAFE_FREE(ctdb_data.dptr); - - if (data->dptr == NULL) { - return NT_STATUS_NO_MEMORY; - } - return NT_STATUS_OK; - } - - SAFE_FREE(ctdb_data.dptr); - - /* - * We weren't able to get it locally - ask ctdb to fetch it for us. - * If we already had *something*, it's probably worth making a local - * read-only copy. - */ - status = ctdbd_fetch(messaging_ctdbd_connection(), ctx->db_id, key, - mem_ctx, data, - ctdb_data.dsize >= sizeof(struct ctdb_ltdb_header)); - if (!NT_STATUS_IS_OK(status)) { - DEBUG(5, ("ctdbd_fetch failed: %s\n", nt_errstr(status))); - } - - return status; -} - struct db_ctdb_parse_record_state { void (*parser)(TDB_DATA key, TDB_DATA data, void *private_data); void *private_data; + bool ask_for_readonly_copy; bool done; }; @@ -1246,6 +1193,13 @@ static void db_ctdb_parse_record_parser_nonpersistent( if (db_ctdb_can_use_local_hdr(header, true)) { state->parser(key, data, state->private_data); state->done = true; + } else { + /* + * We found something in the db, so it seems that this record, + * while not usable locally right now, is popular. Ask for a + * R/O copy. + */ + state->ask_for_readonly_copy = true; } } @@ -1289,6 +1243,7 @@ static NTSTATUS db_ctdb_parse_record(struct db_context *db, TDB_DATA key, } state.done = false; + state.ask_for_readonly_copy = false; status = db_ctdb_ltdb_parse( ctx, key, db_ctdb_parse_record_parser_nonpersistent, &state); @@ -1296,7 +1251,8 @@ static NTSTATUS db_ctdb_parse_record(struct db_context *db, TDB_DATA key, return NT_STATUS_OK; } - status = db_ctdb_fetch(db, talloc_tos(), key, &data); + status = ctdbd_fetch(messaging_ctdbd_connection(), ctx->db_id, key, + talloc_tos(), &data, state.ask_for_readonly_copy); if (!NT_STATUS_IS_OK(status)) { return status; } |