1
0
mirror of https://github.com/samba-team/samba.git synced 2025-02-02 09:47:23 +03:00

ctdb-locking: Implement active lock requests limit per database

This limit was currently a global limit and not per database.  This
prevents any database freeze lock requests from getting scheduled if
the global limit was reached.

Only individual record requests should be limited and database freeze
requests should always get scheduled.

Signed-off-by: Amitay Isaacs <amitay@gmail.com>
Reviewed-by: Michael Adam <obnox@samba.org>
This commit is contained in:
Amitay Isaacs 2013-11-15 15:58:59 +11:00 committed by Michael Adam
parent 1dcf01f4a6
commit 094f34e9bf
2 changed files with 13 additions and 9 deletions

View File

@ -556,7 +556,6 @@ struct ctdb_context {
struct trbt_tree *child_processes;
/* Used for locking record/db/alldb */
int lock_num_current;
int lock_num_pending;
struct lock_context *lock_current;
struct lock_context *lock_pending;
@ -596,6 +595,8 @@ struct ctdb_db_context {
struct trbt_tree *deferred_fetch;
struct ctdb_db_statistics statistics;
int lock_num_current;
};

View File

@ -279,7 +279,9 @@ static int ctdb_lock_context_destructor(struct lock_context *lock_ctx)
if (lock_ctx->child > 0) {
ctdb_kill(lock_ctx->ctdb, lock_ctx->child, SIGKILL);
DLIST_REMOVE(lock_ctx->ctdb->lock_current, lock_ctx);
lock_ctx->ctdb->lock_num_current--;
if (lock_ctx->ctdb_db) {
lock_ctx->ctdb_db->lock_num_current--;
}
CTDB_DECREMENT_STAT(lock_ctx->ctdb, locks.num_current);
if (lock_ctx->type == LOCK_RECORD || lock_ctx->type == LOCK_DB) {
CTDB_DECREMENT_DB_STAT(lock_ctx->ctdb_db, locks.num_current);
@ -741,10 +743,6 @@ static void ctdb_lock_schedule(struct ctdb_context *ctdb)
CTDB_NO_MEMORY_VOID(ctdb, prog);
}
if (ctdb->lock_num_current >= MAX_LOCK_PROCESSES_PER_DB) {
return;
}
if (ctdb->lock_pending == NULL) {
return;
}
@ -767,8 +765,11 @@ static void ctdb_lock_schedule(struct ctdb_context *ctdb)
lock_ctx->key, lock_ctx->priority,
lock_ctx->type);
if (active_ctx == NULL) {
/* 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
@ -874,7 +875,9 @@ static void ctdb_lock_schedule(struct ctdb_context *ctdb)
DLIST_REMOVE(ctdb->lock_pending, lock_ctx);
ctdb->lock_num_pending--;
DLIST_ADD_END(ctdb->lock_current, lock_ctx, NULL);
ctdb->lock_num_current++;
if (lock_ctx->ctdb_db) {
lock_ctx->ctdb_db->lock_num_current++;
}
}