ctdb-locking: Add DB lock requests to head of the pending queue
authorAmitay Isaacs <amitay@gmail.com>
Tue, 15 Jul 2014 04:13:25 +0000 (14:13 +1000)
committerVolker Lendecke <vl@samba.org>
Mon, 4 Aug 2014 15:59:52 +0000 (17:59 +0200)
This allows to schedule DB locks quickly without having to scan through
the pending lock requests.

Signed-off-by: Amitay Isaacs <amitay@gmail.com>
Reviewed-by: Volker Lendecke <vl@samba.org>
ctdb/server/ctdb_lock.c

index b9740857c1da7a9a7550f694b2ddb25f448739f7..1100c7c17abb31be42c6167299a135a3a0f993c5 100644 (file)
@@ -858,7 +858,14 @@ static struct lock_request *ctdb_lock_internal(struct ctdb_context *ctdb,
        lock_ctx->request = request;
        lock_ctx->child = -1;
 
-       DLIST_ADD_END(ctdb->lock_pending, lock_ctx, NULL);
+       /* Non-record locks are required by recovery and should be scheduled
+        * immediately, so keep them at the head of the pending queue.
+        */
+       if (lock_ctx->type == LOCK_RECORD) {
+               DLIST_ADD_END(ctdb->lock_pending, lock_ctx, NULL);
+       } else {
+               DLIST_ADD(ctdb->lock_pending, lock_ctx);
+       }
        CTDB_INCREMENT_STAT(ctdb, locks.num_pending);
        if (ctdb_db) {
                CTDB_INCREMENT_DB_STAT(ctdb_db, locks.num_pending);