From c9664b4b17660c03ed96072a9f5392dbb0800f2c Mon Sep 17 00:00:00 2001 From: Amitay Isaacs Date: Thu, 29 May 2014 17:27:32 +1000 Subject: ctdb-locking: Schedule the next possible lock based on per-db limit This prevents searching through active lock requests for every pending lock request to check if the pending lock request can be scheduled or not. The locks are scheduled in strict first-in-first-out order. Signed-off-by: Amitay Isaacs Reviewed-by: Volker Lendecke --- ctdb/server/ctdb_lock.c | 20 +++++--------------- 1 file changed, 5 insertions(+), 15 deletions(-) diff --git a/ctdb/server/ctdb_lock.c b/ctdb/server/ctdb_lock.c index a54f0bc8f6..ee9c0c15fa 100644 --- a/ctdb/server/ctdb_lock.c +++ b/ctdb/server/ctdb_lock.c @@ -715,7 +715,7 @@ done: */ static void ctdb_lock_schedule(struct ctdb_context *ctdb) { - struct lock_context *lock_ctx, *next_ctx, *active_ctx; + struct lock_context *lock_ctx, *next_ctx; int ret; TALLOC_CTX *tmp_ctx; const char *helper = BINDIR "/ctdb_lock_helper"; @@ -752,21 +752,11 @@ static void ctdb_lock_schedule(struct ctdb_context *ctdb) } talloc_free(lock_ctx); } else { - active_ctx = find_lock_context(ctdb->lock_current, lock_ctx->ctdb_db, - lock_ctx->key, lock_ctx->priority, - lock_ctx->type, lock_ctx->key_hash); - if (active_ctx == NULL) { - if (lock_ctx->ctdb_db == NULL || - lock_ctx->ctdb_db->lock_num_current < MAX_LOCK_PROCESSES_PER_DB) { - /* Found a lock context with lock requests */ - break; - } + if (lock_ctx->ctdb_db == NULL || + lock_ctx->ctdb_db->lock_num_current < MAX_LOCK_PROCESSES_PER_DB) { + /* Found a lock context with lock requests */ + break; } - - /* There is already a child waiting for the - * same key. So don't schedule another child - * just yet. - */ } lock_ctx = next_ctx; } -- cgit