locking: Add handler function for marking a database
authorAmitay Isaacs <amitay@gmail.com>
Tue, 30 Apr 2013 04:07:11 +0000 (14:07 +1000)
committerAmitay Isaacs <amitay@gmail.com>
Thu, 23 May 2013 23:06:39 +0000 (09:06 +1000)
Signed-off-by: Amitay Isaacs <amitay@gmail.com>
server/ctdb_lock.c

index f6220e02033a0bb8cff30d9aade4b77a381abc66..68409e7c85d61653fa032901b6ae32d25b12e74f 100644 (file)
@@ -242,6 +242,29 @@ static int ctdb_unlockall(struct ctdb_context *ctdb)
 /*
  * lock all databases - mark only
  */
+static int db_lock_mark_handler(struct ctdb_db_context *ctdb_db, uint32_t priority,
+                               void *private_data)
+{
+       int tdb_transaction_write_lock_mark(struct tdb_context *);
+
+       DEBUG(DEBUG_INFO, ("marking locked database %s, priority:%u\n",
+                          ctdb_db->db_name, priority));
+
+       if (tdb_transaction_write_lock_mark(ctdb_db->ltdb->tdb) != 0) {
+               DEBUG(DEBUG_ERR, ("Failed to mark (transaction lock) database %s\n",
+                                 ctdb_db->db_name));
+               return -1;
+       }
+
+       if (tdb_lockall_mark(ctdb_db->ltdb->tdb) != 0) {
+               DEBUG(DEBUG_ERR, ("Failed to mark (all lock) database %s\n",
+                                 ctdb_db->db_name));
+               return -1;
+       }
+
+       return 0;
+}
+
 int ctdb_lockall_mark_prio(struct ctdb_context *ctdb, uint32_t priority)
 {
        struct ctdb_db_context *ctdb_db;