lib: Remove ctdb_serverids_exist
authorVolker Lendecke <vl@samba.org>
Tue, 29 Sep 2015 23:27:00 +0000 (01:27 +0200)
committerJeremy Allison <jra@samba.org>
Wed, 30 Sep 2015 21:51:13 +0000 (23:51 +0200)
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
source3/include/ctdbd_conn.h
source3/lib/ctdb_dummy.c
source3/lib/ctdbd_conn.c
source3/lib/serverid.c

index b60a0e5de567f5f520bc6939d8562de4cc935b8d..9f7ec9f44eb26e4fefd015ccb7ad39e67119931f 100644 (file)
@@ -47,10 +47,6 @@ bool ctdbd_process_exists(struct ctdbd_connection *conn, uint32_t vnn,
 bool ctdb_processes_exist(struct ctdbd_connection *conn,
                          const struct server_id *pids, int num_pids,
                          bool *results);
-bool ctdb_serverids_exist_supported(struct ctdbd_connection *conn);
-bool ctdb_serverids_exist(struct ctdbd_connection *conn,
-                         const struct server_id *pids, unsigned num_pids,
-                         bool *results);
 
 char *ctdbd_dbpath(struct ctdbd_connection *conn,
                   TALLOC_CTX *mem_ctx, uint32_t db_id);
index 2d9d296a53c2fe6cf141127d0b4d5378ea04a053..2d1f6deefb9a8ca68c4f1a0c40f737d5da0d4d5a 100644 (file)
@@ -63,18 +63,6 @@ const char *lp_ctdbd_socket(void)
        return "";
 }
 
-bool ctdb_serverids_exist_supported(struct ctdbd_connection *conn)
-{
-       return false;
-}
-
-bool ctdb_serverids_exist(struct ctdbd_connection *conn,
-                         const struct server_id *pids, unsigned num_pids,
-                         bool *results)
-{
-       return false;
-}
-
 bool ctdb_processes_exist(struct ctdbd_connection *conn,
                          const struct server_id *pids, int num_pids,
                          bool *results)
index 1acce1284422acfb27df354543d27c34ab59a532..9aec517840050983209e2516c4b13c0be99c9eac 100644 (file)
@@ -856,249 +856,6 @@ fail:
        return result;
 }
 
-struct ctdb_vnn_list {
-       uint32_t vnn;
-       uint32_t reqid;
-       unsigned num_srvids;
-       unsigned num_filled;
-       uint64_t *srvids;
-       unsigned *pid_indexes;
-};
-
-/*
- * Get a list of all vnns mentioned in a list of
- * server_ids. vnn_indexes tells where in the vnns array we have to
- * place the pids.
- */
-static bool ctdb_collect_vnns(TALLOC_CTX *mem_ctx,
-                             const struct server_id *pids, unsigned num_pids,
-                             struct ctdb_vnn_list **pvnns,
-                             unsigned *pnum_vnns)
-{
-       struct ctdb_vnn_list *vnns = NULL;
-       unsigned *vnn_indexes = NULL;
-       unsigned i, num_vnns = 0;
-
-       vnn_indexes = talloc_array(mem_ctx, unsigned, num_pids);
-       if (vnn_indexes == NULL) {
-               DEBUG(1, ("talloc_array failed\n"));
-               goto fail;
-       }
-
-       for (i=0; i<num_pids; i++) {
-               unsigned j;
-               uint32_t vnn = pids[i].vnn;
-
-               for (j=0; j<num_vnns; j++) {
-                       if (vnn == vnns[j].vnn) {
-                               break;
-                       }
-               }
-               vnn_indexes[i] = j;
-
-               if (j < num_vnns) {
-                       /*
-                        * Already in the array
-                        */
-                       vnns[j].num_srvids += 1;
-                       continue;
-               }
-               vnns = talloc_realloc(mem_ctx, vnns, struct ctdb_vnn_list,
-                                     num_vnns+1);
-               if (vnns == NULL) {
-                       DEBUG(1, ("talloc_realloc failed\n"));
-                       goto fail;
-               }
-               vnns[num_vnns].vnn = vnn;
-               vnns[num_vnns].num_srvids = 1;
-               vnns[num_vnns].num_filled = 0;
-               num_vnns += 1;
-       }
-       for (i=0; i<num_vnns; i++) {
-               struct ctdb_vnn_list *vnn = &vnns[i];
-
-               vnn->srvids = talloc_array(vnns, uint64_t, vnn->num_srvids);
-               if (vnn->srvids == NULL) {
-                       DEBUG(1, ("talloc_array failed\n"));
-                       goto fail;
-               }
-               vnn->pid_indexes = talloc_array(vnns, unsigned,
-                                               vnn->num_srvids);
-               if (vnn->pid_indexes == NULL) {
-                       DEBUG(1, ("talloc_array failed\n"));
-                       goto fail;
-               }
-       }
-       for (i=0; i<num_pids; i++) {
-               struct ctdb_vnn_list *vnn = &vnns[vnn_indexes[i]];
-               vnn->srvids[vnn->num_filled] = pids[i].unique_id;
-               vnn->pid_indexes[vnn->num_filled] = i;
-               vnn->num_filled += 1;
-       }
-
-       TALLOC_FREE(vnn_indexes);
-       *pvnns = vnns;
-       *pnum_vnns = num_vnns;
-       return true;
-fail:
-       TALLOC_FREE(vnns);
-       TALLOC_FREE(vnn_indexes);
-       return false;
-}
-
-bool ctdb_serverids_exist_supported(struct ctdbd_connection *conn)
-{
-       return true;
-}
-
-bool ctdb_serverids_exist(struct ctdbd_connection *conn,
-                         const struct server_id *pids, unsigned num_pids,
-                         bool *results)
-{
-       unsigned i, num_received;
-       struct ctdb_vnn_list *vnns = NULL;
-       unsigned num_vnns;
-
-       if (!ctdb_collect_vnns(talloc_tos(), pids, num_pids,
-                              &vnns, &num_vnns)) {
-               DEBUG(1, ("ctdb_collect_vnns failed\n"));
-               goto fail;
-       }
-
-       for (i=0; i<num_vnns; i++) {
-               struct ctdb_vnn_list *vnn = &vnns[i];
-               struct ctdb_req_control req;
-               struct iovec iov[2];
-               ssize_t nwritten;
-
-               vnn->reqid = ctdbd_next_reqid(conn);
-
-               ZERO_STRUCT(req);
-
-               DEBUG(10, ("Requesting VNN %d, reqid=%d, num_srvids=%u\n",
-                          (int)vnn->vnn, (int)vnn->reqid, vnn->num_srvids));
-
-               req.hdr.length = offsetof(struct ctdb_req_control, data);
-               req.hdr.ctdb_magic   = CTDB_MAGIC;
-               req.hdr.ctdb_version = CTDB_PROTOCOL;
-               req.hdr.operation    = CTDB_REQ_CONTROL;
-               req.hdr.reqid        = vnn->reqid;
-               req.hdr.destnode     = vnn->vnn;
-               req.opcode           = CTDB_CONTROL_CHECK_SRVIDS;
-               req.srvid            = 0;
-               req.datalen          = sizeof(uint64_t) * vnn->num_srvids;
-               req.hdr.length      += req.datalen;
-               req.flags            = 0;
-
-               DEBUG(10, ("ctdbd_control: Sending ctdb packet\n"));
-               ctdb_packet_dump(&req.hdr);
-
-               iov[0].iov_base = &req;
-               iov[0].iov_len = offsetof(struct ctdb_req_control, data);
-               iov[1].iov_base = vnn->srvids;
-               iov[1].iov_len = req.datalen;
-
-               nwritten = write_data_iov(conn->fd, iov, ARRAY_SIZE(iov));
-               if (nwritten == -1) {
-                       DEBUG(10, ("write_data_iov failed: %s\n",
-                                  strerror(errno)));
-                       goto fail;
-               }
-       }
-
-       num_received = 0;
-
-       while (num_received < num_vnns) {
-               struct ctdb_req_header *hdr;
-               struct ctdb_reply_control *reply;
-               struct ctdb_vnn_list *vnn;
-               uint32_t reqid;
-               uint8_t *reply_data;
-               int ret;
-
-               ret = ctdb_read_req(conn, 0, talloc_tos(), &hdr);
-               if (ret != 0) {
-                       DEBUG(10, ("ctdb_read_req failed: %s\n",
-                                  strerror(ret)));
-                       goto fail;
-               }
-
-               if (hdr->operation != CTDB_REPLY_CONTROL) {
-                       DEBUG(1, ("Received invalid reply %u\n",
-                                 (unsigned)hdr->operation));
-                       goto fail;
-               }
-               reply = (struct ctdb_reply_control *)hdr;
-
-               reqid = reply->hdr.reqid;
-
-               DEBUG(10, ("Received reqid %d\n", (int)reqid));
-
-               for (i=0; i<num_vnns; i++) {
-                       if (reqid == vnns[i].reqid) {
-                               break;
-                       }
-               }
-               if (i == num_vnns) {
-                       DEBUG(1, ("Received unknown reqid number %u\n",
-                                 (unsigned)reqid));
-                       goto fail;
-               }
-
-               DEBUG(10, ("Found index %u\n", i));
-
-               vnn = &vnns[i];
-
-               DEBUG(10, ("Received vnn %u, vnn->num_srvids %u, datalen %u\n",
-                          (unsigned)vnn->vnn, vnn->num_srvids,
-                          (unsigned)reply->datalen));
-
-               if (reply->datalen >= ((vnn->num_srvids+7)/8)) {
-                       /*
-                        * Got a real reply
-                        */
-                       reply_data = reply->data;
-               } else {
-                       /*
-                        * Got an error reply
-                        */
-                       DEBUG(5, ("Received short reply len %d, status %u, "
-                                 "errorlen %u\n",
-                                 (unsigned)reply->datalen,
-                                 (unsigned)reply->status,
-                                 (unsigned)reply->errorlen));
-                       dump_data(5, reply->data, reply->errorlen);
-
-                       /*
-                        * This will trigger everything set to false
-                        */
-                       reply_data = NULL;
-               }
-
-               for (i=0; i<vnn->num_srvids; i++) {
-                       int idx = vnn->pid_indexes[i];
-
-                       if (pids[i].unique_id ==
-                           SERVERID_UNIQUE_ID_NOT_TO_VERIFY) {
-                               results[idx] = true;
-                               continue;
-                       }
-                       results[idx] =
-                               (reply_data != NULL) &&
-                               ((reply_data[i/8] & (1<<(i%8))) != 0);
-               }
-
-               TALLOC_FREE(reply);
-               num_received += 1;
-       }
-
-       TALLOC_FREE(vnns);
-       return true;
-fail:
-       cluster_fatal("serverids_exist failed");
-       return false;
-}
-
 /*
  * Get a db path
  */
index 4938bbaa02b8d3694f0a93057ed675da8706194c..c219d21178f00f49ead3f2d7924e32d3412fa304 100644 (file)
@@ -121,9 +121,7 @@ bool serverid_register(const struct server_id id, uint32_t msg_flags)
                goto done;
        }
 
-       if (lp_clustering() &&
-           ctdb_serverids_exist_supported(messaging_ctdbd_connection()))
-       {
+       if (lp_clustering()) {
                register_with_ctdbd(messaging_ctdbd_connection(), id.unique_id,
                                    NULL, NULL);
        }