ctdb-client: ctdb_fetch_lock should check for readonly delegations
authorAmitay Isaacs <amitay@gmail.com>
Thu, 27 Mar 2014 04:06:58 +0000 (15:06 +1100)
committerAmitay Isaacs <amitay@samba.org>
Fri, 28 Mar 2014 04:55:13 +0000 (05:55 +0100)
When readonly delegations were added, ctdb_fetch_lock code should have
been modified to include the check for readonly flags.

Signed-off-by: Amitay Isaacs <amitay@gmail.com>
Reviewed-by: Martin Schwenke <martin@meltin.net>
ctdb/client/ctdb_client.c

index 885dbfdfb4656fd57f77695eb36ad6bc8e4bb9ab..756011525dbf7f63ea12c2877762010c9296e90c 100644 (file)
@@ -709,6 +709,21 @@ again:
                goto again;
        }
 
+       /* if this is a request for read/write and we have delegations
+          we have to revoke all delegations first
+       */
+       if ((h->header.dmaster == ctdb_db->ctdb->pnn) &&
+           (h->header.flags & CTDB_REC_RO_HAVE_DELEGATIONS)) {
+               ctdb_ltdb_unlock(ctdb_db, key);
+               ret = ctdb_client_force_migration(ctdb_db, key);
+               if (ret != 0) {
+                       DEBUG(DEBUG_DEBUG,("ctdb_fetch_readonly_lock: force_migration failed\n"));
+                       talloc_free(h);
+                       return NULL;
+               }
+               goto again;
+       }
+
        DEBUG(DEBUG_DEBUG,("ctdb_fetch_lock: we are dmaster - done\n"));
        return h;
 }