added a builtin fetch function to support samba3 unlocked fetch
authorAndrew Tridgell <tridge@samba.org>
Wed, 2 May 2007 05:11:11 +0000 (15:11 +1000)
committerAndrew Tridgell <tridge@samba.org>
Wed, 2 May 2007 05:11:11 +0000 (15:11 +1000)
common/ctdb_ltdb.c
include/ctdb.h
include/ctdb_private.h
tools/ctdb_control.c

index 979d506b0b3e41cc743c18e647c23947e1cece03..f8141180f2f3655c6a7babdbe01309f10d5d9d22 100644 (file)
@@ -50,6 +50,15 @@ static int ctdb_null_func(struct ctdb_call_info *call)
        return 0;
 }
 
+/*
+  this is a plain fetch procedure that all databases support
+*/
+static int ctdb_fetch_func(struct ctdb_call_info *call)
+{
+       call->reply_data = &call->record_data;
+       return 0;
+}
+
 
 /*
   return the lmaster given a key
@@ -366,6 +375,17 @@ int32_t ctdb_control_db_attach(struct ctdb_context *ctdb, TDB_DATA indata,
                talloc_free(ctdb_db);
                return -1;
        }
+
+       /* 
+          all databases support the "fetch" function. we need this
+          for efficient Samba3 ctdb fetch
+       */
+       ret = ctdb_daemon_set_call(ctdb, ctdb_db->db_id, ctdb_fetch_func, CTDB_FETCH_FUNC);
+       if (ret != 0) {
+               DEBUG(0,("Failed to setup fetch function for '%s'\n", ctdb_db->db_name));
+               talloc_free(ctdb_db);
+               return -1;
+       }
        
        /* tell all the other nodes about this database */
        ctdb_daemon_send_control(ctdb, CTDB_BROADCAST_VNN, 0,
index cb4f73615a08b71f35a5983e8854464f17537e80..16d3c403c096050433e1e751575e8ed9da9aa183 100644 (file)
@@ -180,25 +180,10 @@ int ctdb_send_message(struct ctdb_context *ctdb, uint32_t vnn,
    Fetch a ctdb record from a remote node
  . Underneath this will force the
    dmaster for the record to be moved to the local node. 
-
 */
 struct ctdb_record_handle *ctdb_fetch_lock(struct ctdb_db_context *ctdb_db, TALLOC_CTX *mem_ctx, 
                                           TDB_DATA key, TDB_DATA *data);
 
-
-/*
-  do a fetch lock from a client to the local daemon
-*/
-#define FETCH_LOCK_SUCCESS             0
-#define FETCH_LOCK_LOCKFAILED          1
-#define FETCH_LOCK_FETCHFAILED         2
-#define FETCH_LOCK_DMASTERFAILED       3
-
-int ctdb_client_fetch_lock(struct ctdb_db_context *ctdb_db, 
-                                                 TALLOC_CTX *mem_ctx, 
-                                                 TDB_DATA key, TDB_DATA *data);
-
-
 int ctdb_record_store(struct ctdb_record_handle *h, TDB_DATA data);
 
 int ctdb_register_message_handler(struct ctdb_context *ctdb, 
index 30f1607c6697ec009f5b1757653f83a5e0395702..0807a37a480f8d21c47ffd72a0dbd00b16f13e73 100644 (file)
@@ -30,7 +30,8 @@
 #define CTDB_DS_ALIGNMENT 8
 
 
-#define CTDB_NULL_FUNC     0xF0000001
+#define CTDB_NULL_FUNC      0xFF000001
+#define CTDB_FETCH_FUNC     0xFF000002
 
 #define CTDB_CURRENT_NODE  0xF0000001
 #define CTDB_BROADCAST_VNN 0xF0000002
index ee5420a0f4d73cd2141451c8689c0b7265d27846..6f41d3f73d3c0b70bd7e49493f021908473e1ca4 100644 (file)
@@ -50,7 +50,8 @@ static void usage(void)
                "  cleardb <vnn> <dbid>               deletes all records in a db\n"
                "  getrecmode <vnn>                   get recovery mode\n"
                "  setrecmode <vnn> <mode>            set recovery mode\n"
-               "  recover <vnn>                      recover the cluster\n");
+               "  recover <vnn>                      recover the cluster\n"
+               "  attach <dbname>                    attach a database\n");
        exit(1);
 }