Aleksey Fedoseev fedoseev at ru.ibm.com
Thu Nov 2 11:07:26 GMT 2006


> no actual implementation of this yet, but it will at least give you an
> idea of what API I'm now thinking of, and how the fetch and
> conditional_append calls can be combined into a much more general
> ctdb_call() approach.

I guess, combining the calls in one function is not very good idea.
We'll have to implement big switch for multiplexing by the call id. And
what benefits shall we gain from single ctdb_call function?

Btw, we have to use one API of CTDB, but two implementations -- the
first for client side (smbd) and the second for server side (dispatcher).

I would propose this slightly modified original API:

  /* initialise a ctdb context */
  struct ctdb_context *ctdb_init(TALLOC_CTX *mem_ctx);

  /* set the conditional function for a conditional append */
  int ctdb_set_conditional(struct ctdb_context *ctdb,
ctdb_conditional_fn fn, uint32_t condition_id, void *private);

  /* attach to the database */
  int ctdb_attach(struct ctdb_context *ctdb, const char *name, int
tdb_flags, int open_flags, mode_t mode);

  /* fetch a locked record, unlock via talloc_free() */
  struct ctdb_record  *ctdb_fetch_locked(struct ctdb_context *ctdb,
TALLOC_CTX *mem_ctx, TDB_DATA key);
  /* store a record fetched with ctdb_fetch_locked(), and release the
lock */
  int ctdb_store_unlock(struct tdb_context *ctdb, struct ctdb_record *rec);

  /* fetch a record unlocked */
  TDB_DATA ctdb_fetch(struct ctdb_context *ctdb, TALLOC_CTX *mem_ctx,
TDB_DATA key);

  /* conditionally append data to a record */
  int ctdb_conditional_append(struct ctdb_context *ctdb, uint32_t
condition_id, TDB_DATA key, TDB_DATA subkey, TDB_DATA data);

  /* remove a piece of a record, maybe triggering a function */
  int ctdb_remove_and_trigger(struct ctdb_context *ctdb, TDB_DATA key,
TDB_DATA subkey);

Aleksey Fedoseev
Linux Center of Competence, IBM EE/A
IBM Linux Technology Center: Samba Team
Phone: +7495 775-8800 x 2133

More information about the samba-technical mailing list