ctdb-locking: Schedule the next possible lock based on per-db limit
authorAmitay Isaacs <amitay@gmail.com>
Thu, 29 May 2014 07:27:32 +0000 (17:27 +1000)
committerVolker Lendecke <vl@samba.org>
Mon, 4 Aug 2014 15:59:52 +0000 (17:59 +0200)
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 <amitay@gmail.com>
Reviewed-by: Volker Lendecke <vl@samba.org>
ctdb/server/ctdb_lock.c

index a54f0bc8f6e91915888b5ca51eb27d649485b6b3..ee9c0c15fa5f165edb52ee42b3fbdd0d45fc8897 100644 (file)
@@ -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;
        }