diff options
author | Christof Schmitt <cs@samba.org> | 2014-01-14 14:17:32 -0700 |
---|---|---|
committer | Volker Lendecke <vl@samba.org> | 2014-01-16 09:18:45 +0100 |
commit | 32f232d9ad05d476933641a72cc5899d49cbb220 (patch) | |
tree | 092e365893893f366c7e737c9f23f197a60454ae | |
parent | ef239302ed8e190fe8cb5cee1a4791f7a9959980 (diff) | |
download | samba-32f232d9ad05d476933641a72cc5899d49cbb220.tar.gz samba-32f232d9ad05d476933641a72cc5899d49cbb220.tar.xz samba-32f232d9ad05d476933641a72cc5899d49cbb220.zip |
s3:dbwrap: Store warning thresholds in db_ctdb_ctx
Avoid the parameter lookup for the warning thresholds in the hot code
path by reading them in db_open_ctdb and storing them in the
db_ctdb_ctx.
Signed-off-by: Christof Schmitt <cs@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
-rw-r--r-- | source3/lib/dbwrap/dbwrap_ctdb.c | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/source3/lib/dbwrap/dbwrap_ctdb.c b/source3/lib/dbwrap/dbwrap_ctdb.c index 3db26900dc8..a81b97aeb52 100644 --- a/source3/lib/dbwrap/dbwrap_ctdb.c +++ b/source3/lib/dbwrap/dbwrap_ctdb.c @@ -73,6 +73,12 @@ struct db_ctdb_ctx { uint32_t db_id; struct db_ctdb_transaction_handle *transaction; struct g_lock_ctx *lock_ctx; + + /* thresholds for warning messages */ + int warn_unlock_msecs; + int warn_migrate_msecs; + int warn_migrate_attempts; + int warn_locktime_msecs; }; struct db_ctdb_rec { @@ -962,7 +968,7 @@ static int db_ctdb_record_destr(struct db_record* data) timediff = timeval_elapsed(&before); timediff *= 1000; /* get us milliseconds */ - if (timediff > lp_parm_int(-1, "ctdb", "unlock_warn_threshold", 5)) { + if (timediff > crec->ctdb_ctx->warn_unlock_msecs) { char *key; key = hex_encode_talloc(talloc_tos(), (unsigned char *)data->key.dptr, @@ -978,7 +984,7 @@ static int db_ctdb_record_destr(struct db_record* data) return -1; } - threshold = lp_ctdb_locktime_warn_threshold(); + threshold = crec->ctdb_ctx->warn_locktime_msecs; if (threshold != 0) { timediff = timeval_elapsed(&crec->lock_time); if ((timediff * 1000) > threshold) { @@ -1161,8 +1167,8 @@ again: duration_msecs = duration * 1000; } - if ((migrate_attempts > lp_parm_int(-1, "ctdb", "migrate_attempts", 10)) || - (duration_msecs > lp_parm_int(-1, "ctdb", "migrate_duration", 5000))) { + if ((migrate_attempts > ctx->warn_migrate_attempts) || + (duration_msecs > ctx->warn_migrate_msecs)) { int chain = 0; if (tdb_get_flags(ctx->wtdb->tdb) & TDB_INCOMPATIBLE_HASH) { @@ -1663,6 +1669,14 @@ struct db_context *db_open_ctdb(TALLOC_CTX *mem_ctx, } } + db_ctdb->warn_unlock_msecs = lp_parm_int(-1, "ctdb", + "unlock_warn_threshold", 5); + db_ctdb->warn_migrate_attempts = lp_parm_int(-1, "ctdb", + "migrate_attempts", 10); + db_ctdb->warn_migrate_msecs = lp_parm_int(-1, "ctdb", + "migrate_duration", 5000); + db_ctdb->warn_locktime_msecs = lp_ctdb_locktime_warn_threshold(); + result->private_data = (void *)db_ctdb; result->fetch_locked = db_ctdb_fetch_locked; result->try_fetch_locked = db_ctdb_try_fetch_locked; |