diff options
author | Amitay Isaacs <amitay@gmail.com> | 2013-04-30 14:12:40 +1000 |
---|---|---|
committer | Amitay Isaacs <amitay@gmail.com> | 2013-05-24 09:06:39 +1000 |
commit | a5133d16e7275e76cfdd2fe8c790d137311cfc9a (patch) | |
tree | 32e8772082b7300fbc37aa221787060c67194841 /ctdb/server/ctdb_lock.c | |
parent | ed359bb1ead0bcd35963ff1bf55442f0ef5783cc (diff) | |
download | samba-a5133d16e7275e76cfdd2fe8c790d137311cfc9a.tar.gz samba-a5133d16e7275e76cfdd2fe8c790d137311cfc9a.tar.xz samba-a5133d16e7275e76cfdd2fe8c790d137311cfc9a.zip |
locking: Use database iterator for marking databases
Signed-off-by: Amitay Isaacs <amitay@gmail.com>
(This used to be ctdb commit e8ea65b2713417db4a618a9f4633991cfaa93fe6)
Diffstat (limited to 'ctdb/server/ctdb_lock.c')
-rw-r--r-- | ctdb/server/ctdb_lock.c | 41 |
1 files changed, 2 insertions, 39 deletions
diff --git a/ctdb/server/ctdb_lock.c b/ctdb/server/ctdb_lock.c index 68409e7c85d..6bc1a100ceb 100644 --- a/ctdb/server/ctdb_lock.c +++ b/ctdb/server/ctdb_lock.c @@ -267,9 +267,6 @@ static int db_lock_mark_handler(struct ctdb_db_context *ctdb_db, uint32_t priori int ctdb_lockall_mark_prio(struct ctdb_context *ctdb, uint32_t priority) { - struct ctdb_db_context *ctdb_db; - int tdb_transaction_write_lock_mark(struct tdb_context *); - /* * This function is only used by the main dameon during recovery. * At this stage, the databases have already been locked, by a @@ -282,41 +279,7 @@ int ctdb_lockall_mark_prio(struct ctdb_context *ctdb, uint32_t priority) return -1; } - for (ctdb_db = ctdb->db_list; ctdb_db; ctdb_db = ctdb_db->next) { - if (ctdb_db->priority != priority) { - continue; - } - if (later_db(ctdb, ctdb_db->db_name)) { - continue; - } - if (tdb_transaction_write_lock_mark(ctdb_db->ltdb->tdb) != 0) { - return -1; - } - if (tdb_lockall_mark(ctdb_db->ltdb->tdb) != 0) { - /* FIXME: Shouldn't we unmark here? */ - return -1; - } - } - - /* If priority != 1, later_db check is not required and can return */ - if (priority != 1) { - return 0; - } - - for (ctdb_db = ctdb->db_list; ctdb_db; ctdb_db = ctdb_db->next) { - if (!later_db(ctdb, ctdb_db->db_name)) { - continue; - } - if (tdb_transaction_write_lock_mark(ctdb_db->ltdb->tdb) != 0) { - return -1; - } - if (tdb_lockall_mark(ctdb_db->ltdb->tdb) != 0) { - /* FIXME: Shouldn't we unmark here? */ - return -1; - } - } - - return 0; + return ctdb_db_iterator(ctdb, priority, db_lock_mark_handler, NULL); } static int ctdb_lockall_mark(struct ctdb_context *ctdb) @@ -324,7 +287,7 @@ static int ctdb_lockall_mark(struct ctdb_context *ctdb) uint32_t priority; for (priority=1; priority<=NUM_DB_PRIORITIES; priority++) { - if (ctdb_lockall_mark_prio(ctdb, priority) != 0) { + if (ctdb_db_iterator(ctdb, priority, db_lock_mark_handler, NULL) != 0) { return -1; } } |