]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
merge from tridge
authorRonnie Sahlberg <sahlberg@ronnie>
Sun, 29 Apr 2007 13:49:27 +0000 (23:49 +1000)
committerRonnie Sahlberg <sahlberg@ronnie>
Sun, 29 Apr 2007 13:49:27 +0000 (23:49 +1000)
(This used to be ctdb commit a84e9b47a87fc7d4756b4a179aa2ea0bc7c54c78)

1  2 
ctdb/Makefile.in
ctdb/common/ctdb.c
ctdb/common/ctdb_client.c
ctdb/common/ctdb_control.c
ctdb/include/ctdb.h
ctdb/include/ctdb_private.h
ctdb/tools/ctdb_control.c

index a80908c638c60a9c8bc14944aa54b07650bb431e,81cf72516d877cc80c1cd11e22242ab1b0c9cb8e..ff53535c904b4d3878bdb644688e110bff24fee2
@@@ -108,15 -108,15 +108,21 @@@ distclean: clea
  install: all
        mkdir -p $(bindir)
        mkdir -p $(includedir)
-       cp $(BINS) $(bindir)
-       cp $(srcdir)/include/ctdb.h $(includedir)
+       rsync $(BINS) $(bindir)
+       rsync $(srcdir)/include/ctdb.h $(includedir)
+ test:
+       tests/run_tests.sh
+ valgrindtest:
+       VALGRIND="valgrind -q --trace-children=yes" tests/run_tests.sh
  
 +test:
 +      tests/run_tests.sh
 +
 +valgrindtest:
 +      VALGRIND="valgrind -q --trace-children=yes" tests/run_tests.sh
 +
  
  realdistclean: distclean
        rm -f configure config.h.in
Simple merge
index d7dc7be54d72c6ff9817157de024aa0656687203,075f8553ae421aa83669236dc64d2472b643273b..d11bab6fc402aa9d7c512e03bb0c9fe6b8435078
@@@ -943,147 -892,8 +939,147 @@@ int ctdb_setvnnmap(struct ctdb_context 
        return 0;
  }
  
 +/*
 +  get all keys for a specific database
 + */
 +int ctdb_getkeys(struct ctdb_context *ctdb, uint32_t destnode, uint32_t dbid, TALLOC_CTX *mem_ctx, struct ctdb_key_list *keys)
 +{
 +      int i, ret;
 +      TDB_DATA indata, outdata;
 +      int32_t res;
 +      unsigned char *ptr;
 +
 +      indata.dsize = sizeof(uint32_t);
 +      indata.dptr = (unsigned char *)&dbid;
 +
 +      ret = ctdb_control(ctdb, destnode, 0, 
 +                         CTDB_CONTROL_GET_KEYS, indata, 
 +                         mem_ctx, &outdata, &res);
 +      if (ret != 0 || res != 0) {
 +              DEBUG(0,(__location__ " ctdb_control for getkeys failed\n"));
 +              return -1;
 +      }
 +
 +
 +      keys->num= *((uint32_t *)(&outdata.dptr[0]));
 +      keys->keys=talloc_array(mem_ctx, TDB_DATA, keys->num);
 +      keys->headers=talloc_array(mem_ctx, struct ctdb_ltdb_header, keys->num);
 +      keys->lmasters=talloc_array(mem_ctx, uint32_t, keys->num);
 +      keys->data=talloc_array(mem_ctx, TDB_DATA, keys->num);
 +
 +      /* loop over all key/data pairs */
 +      ptr=&outdata.dptr[4];
 +      for(i=0;i<keys->num;i++){
 +              uint32_t len;
 +              TDB_DATA *key, *data;
 +
 +              keys->lmasters[i]= *((uint32_t *)ptr);
 +              ptr+=4;
 +
 +              key=&keys->keys[i];
 +              key->dsize= *((uint32_t *)ptr);
 +              ptr+=4;
 +              key->dptr=talloc_size(mem_ctx, key->dsize);
 +              memcpy(key->dptr, ptr, key->dsize);
 +              len = (key->dsize+CTDB_DS_ALIGNMENT-1)& ~(CTDB_DS_ALIGNMENT-1);
 +              ptr+=len;
 +
 +              memcpy(&keys->headers[i], ptr, sizeof(struct ctdb_ltdb_header));
 +              len = (sizeof(struct ctdb_ltdb_header)+CTDB_DS_ALIGNMENT-1)& ~(CTDB_DS_ALIGNMENT-1);
 +              ptr+=len;
 +
 +              data=&keys->data[i];
 +              data->dsize= *((uint32_t *)ptr);
 +              ptr+=4;
 +              data->dptr=talloc_size(mem_ctx, data->dsize);
 +              memcpy(data->dptr, ptr, data->dsize);
 +              len = (data->dsize+CTDB_DS_ALIGNMENT-1)& ~(CTDB_DS_ALIGNMENT-1);
 +              ptr+=len;
 +
 +      }
 +
 +      return 0;
 +}
 +
 +/*
 +  change dmaster for all keys in the database to the new value
 + */
 +int ctdb_setdmaster(struct ctdb_context *ctdb, uint32_t destnode, TALLOC_CTX *mem_ctx, uint32_t dbid, uint32_t dmaster)
 +{
 +      int ret;
 +      TDB_DATA indata, outdata;
 +      int32_t res;
 +
 +      indata.dsize = 2*sizeof(uint32_t);
 +      indata.dptr = (unsigned char *)talloc_array(mem_ctx, uint32_t, 2);
 +
 +      ((uint32_t *)(&indata.dptr[0]))[0] = dbid;
 +      ((uint32_t *)(&indata.dptr[0]))[1] = dmaster;
 +
 +      ret = ctdb_control(ctdb, destnode, 0, 
 +                         CTDB_CONTROL_SET_DMASTER, indata, 
 +                         mem_ctx, &outdata, &res);
 +      if (ret != 0 || res != 0) {
 +              DEBUG(0,(__location__ " ctdb_control for setdmaster failed\n"));
 +              return -1;
 +      }
 +
 +      return 0;
 +}
 +
 +/*
 +  delete all records from a tdb
 + */
 +int ctdb_cleardb(struct ctdb_context *ctdb, uint32_t destnode, TALLOC_CTX *mem_ctx, uint32_t dbid)
 +{
 +      int ret;
 +      TDB_DATA indata, outdata;
 +      int32_t res;
 +
 +      indata.dsize = sizeof(uint32_t);
 +      indata.dptr = (unsigned char *)talloc_array(mem_ctx, uint32_t, 1);
 +
 +      ((uint32_t *)(&indata.dptr[0]))[0] = dbid;
 +
 +      ret = ctdb_control(ctdb, destnode, 0, 
 +                         CTDB_CONTROL_CLEAR_DB, indata, 
 +                         mem_ctx, &outdata, &res);
 +      if (ret != 0 || res != 0) {
 +              DEBUG(0,(__location__ " ctdb_control for cleardb failed\n"));
 +              return -1;
 +      }
 +
 +      return 0;
 +}
 +
 +/*
 +  pull a db from a remote node
 + */
 +int ctdb_pulldb(struct ctdb_context *ctdb, uint32_t destnode, TALLOC_CTX *mem_ctx, uint32_t dbid, uint32_t from_vnn)
 +{
 +      int ret;
 +      TDB_DATA indata, outdata;
 +      int32_t res;
 +
 +      indata.dsize = 2*sizeof(uint32_t);
 +      indata.dptr = (unsigned char *)talloc_array(mem_ctx, uint32_t, 2);
 +
 +      ((uint32_t *)(&indata.dptr[0]))[0] = dbid;
 +      ((uint32_t *)(&indata.dptr[0]))[1] = from_vnn;
 +
 +      ret = ctdb_control(ctdb, destnode, 0, 
 +                         CTDB_CONTROL_PULL_DB, indata, 
 +                         mem_ctx, &outdata, &res);
 +      if (ret != 0 || res != 0) {
 +              DEBUG(0,(__location__ " ctdb_control for pulldb failed\n"));
 +              return -1;
 +      }
 +
 +      return 0;
 +}
 +
  /*
-   ping a node
+   ping a node, return number of clients connected
   */
  int ctdb_ping(struct ctdb_context *ctdb, uint32_t destnode)
  {
Simple merge
index aa2f31fa34c5a15a3071b1f63b4b2cd5df942d8e,d9e53d30a94113b4361980ce7128d309045a6325..1e382b4b8c114c772eba5d48fa7b1b2a60c54532
@@@ -239,17 -239,9 +239,18 @@@ struct ctdb_node_map 
        uint32_t num;
        struct ctdb_node_and_flags *nodes;
  };
- int ctdb_getnodemap(struct ctdb_context *ctdb, uint32_t destnode, struct ctdb_node_map *nodemap);
+ int ctdb_getnodemap(struct ctdb_context *ctdb, uint32_t destnode, 
+                   TALLOC_CTX *mem_ctx, struct ctdb_node_map *nodemap);
  
 +struct ctdb_key_list {
 +      uint32_t num;
 +      TDB_DATA *keys;
 +      struct ctdb_ltdb_header *headers;
 +      uint32_t *lmasters;
 +      TDB_DATA *data;
 +};
 +int ctdb_getkeys(struct ctdb_context *ctdb, uint32_t destnode, uint32_t dbid, TALLOC_CTX *mem_ctx, struct ctdb_key_list *keys);
 +
  int ctdb_getdbpath(struct ctdb_context *ctdb, uint32_t dbid, TALLOC_CTX *mem_ctx, const char **path);
  
  int ctdb_process_exists(struct ctdb_context *ctdb, uint32_t destnode, pid_t pid);
@@@ -261,31 -253,9 +262,36 @@@ int ctdb_get_config(struct ctdb_contex
  int ctdb_get_debuglevel(struct ctdb_context *ctdb, uint32_t destnode, uint32_t *level);
  int ctdb_set_debuglevel(struct ctdb_context *ctdb, uint32_t destnode, uint32_t level);
  
 +/*
 +  change dmaster for all keys in the database to the new value
 + */
 +int ctdb_setdmaster(struct ctdb_context *ctdb, uint32_t destnode, TALLOC_CTX *mem_ctx, uint32_t dbid, uint32_t dmaster);
 +
 +/*
 +  delete all records from a tdb
 + */
 +int ctdb_cleardb(struct ctdb_context *ctdb, uint32_t destnode, TALLOC_CTX *mem_ctx, uint32_t dbid);
 +
 +/*
 +  pull a db from a remote node
 + */
 +int ctdb_pulldb(struct ctdb_context *ctdb, uint32_t destnode, TALLOC_CTX *mem_ctx, uint32_t dbid, uint32_t from_vnn);
 +
 +
 +#define CTDB_RECOVERY_NORMAL          0
 +#define CTDB_RECOVERY_ACTIVE          1
 +/*
 +  get the recovery mode of a remote node
 + */
 +int ctdb_getrecmode(struct ctdb_context *ctdb, uint32_t destnode, uint32_t *recmode);
 +/*
 +  set the recovery mode of a remote node
 + */
 +int ctdb_setrecmode(struct ctdb_context *ctdb, uint32_t destnode, uint32_t recmode);
 +
+ uint32_t *ctdb_get_connected_nodes(struct ctdb_context *ctdb, TALLOC_CTX *mem_ctx,
+                                  uint32_t *num_nodes);
+ int ctdb_status_reset(struct ctdb_context *ctdb, uint32_t destnode);
  #endif
index 73de824f33c6dc4dfa4f057ca8d3949a673e91b8,f9b869c4b20d0e55f5a3c72a72a37c67ed284a66..e3b33ff6bfdb240af9eefc8343871d66c9a1061c
@@@ -256,12 -252,7 +253,13 @@@ enum ctdb_controls {CTDB_CONTROL_PROCES
                    CTDB_CONTROL_SET_DEBUG,
                    CTDB_CONTROL_GET_DBMAP,
                    CTDB_CONTROL_GET_NODEMAP,
-                   CTDB_CONTROL_SET_RECMODE};
 +                  CTDB_CONTROL_GET_KEYS,
 +                  CTDB_CONTROL_SET_DMASTER,
 +                  CTDB_CONTROL_CLEAR_DB,
 +                  CTDB_CONTROL_PULL_DB,
 +                  CTDB_CONTROL_GET_RECMODE,
++                  CTDB_CONTROL_SET_RECMODE,
+                   CTDB_CONTROL_STATUS_RESET};
  
  enum call_state {CTDB_CALL_WAIT, CTDB_CALL_DONE, CTDB_CALL_ERROR};
  
Simple merge