r22072: in order to implement the opendb ctdb backend, I've found that the
authorAndrew Tridgell <tridge@samba.org>
Wed, 4 Apr 2007 06:06:52 +0000 (06:06 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 19:49:47 +0000 (14:49 -0500)
existing ctdb_call() mechanism isn't sufficient. The main problem is
that the operations on the record need to be done with a lock held
while a local posix file operation is happening. We can't use a
ctdb_call callback function to do the actual file opens, renames,
unlinks etc as the callback would run on the wrong node.

So this commit adds the prototypes for two new ctdb API functions
which will make a opendb backend easier. Volker will probably
recognise these functions as they are basically the same as what he
did in his earlier Samba clustering code :-)
(This used to be commit d9a997fd390e4162c015435d1c703fb3a4978f2f)

source4/cluster/ctdb/include/ctdb.h

index c5b6dbc7824fae43fb45b505e82d75036ec4fcf3..51eeaebedb11e0666c8681a01640746e8b6eda41 100644 (file)
@@ -148,4 +148,19 @@ int ctdb_set_message_handler(struct ctdb_context *ctdb, ctdb_message_fn_t handle
 int ctdb_send_message(struct ctdb_context *ctdb, uint32_t vnn,
                      uint32_t srvid, TDB_DATA data);
 
+/* 
+   fetch and lock a ctdb record. Underneath this will force the
+   dmaster for the record to be moved to the local node. 
+
+   The lock is released when is talloc_free() is called on the
+   returned ctdb_record_handle. 
+*/
+struct ctdb_record_handle *ctdb_fetch_lock(struct ctdb_db_context *ctdb_db, TDB_DATA key, TDB_DATA *data);
+
+/*
+  change the data in a record held with a ctdb_record_handle
+  if the new data is zero length, this implies a delete of the record
+ */
+int ctdb_record_store(struct ctdb_record_handle *rec, TDB_DATA data);
+
 #endif