Beispiel #1
0
static int
send_command_to_evmgr(cmd_uid_t uid, const AdmCommand *adm_cmd,
                      const exa_uuid_t *cluster_uuid,
		      const void *data, size_t data_size)
{
  Examsg msg;
  command_t *cmd = (command_t *)msg.payload;
  size_t payload_size;
  int s;

  /* Message to trigger the command execution on thread thr_nb */
  msg.any.type = EXAMSG_ADM_CLUSTER_CMD;

  payload_size = data_size + sizeof(command_t);

  if (payload_size >= EXAMSG_PAYLOAD_MAX)
    {
      exalog_error("Command %s parameter structure is too big to fit in "
          "a message. %zu > %zu", adm_cmd->msg, payload_size, EXAMSG_PAYLOAD_MAX);
      return -E2BIG;
    }

  cmd->code = adm_cmd->code;
  cmd->uid  = uid;
  memcpy(cmd->data, data, data_size);
  cmd->data_size = data_size;
  uuid_copy(&cmd->cluster_uuid, cluster_uuid);

  exalog_debug("Scheduling command '%s', uid=%d", adm_cmd->msg, cmd->uid);

  s = examsgSend(cli_mh, EXAMSG_ADMIND_EVMGR_ID, EXAMSG_LOCALHOST,
                 &msg, sizeof(ExamsgAny) + payload_size);
  if (s != sizeof(ExamsgAny) + payload_size)
    return s;

  return 0;
}
Beispiel #2
0
static void disk_checking_thread(void *dummy)
{
  exalog_as(EXAMSG_RDEV_ID);

  while (!quit)
  {
    int rdev_need_check = false;
    struct adm_disk *disk;

    adm_node_lock_disk_removal();

    adm_node_for_each_disk(adm_myself(), disk)
    {
      if (disk->local->rdev_req != NULL)
      {
        int state, last_state;

	last_state = disk->local->state;

        state = exa_rdev_test(disk->local->rdev_req,
                              rdev_check_buffer, RDEV_SUPERBLOCK_SIZE);

	/* if exa_rdev_test returns an error, the disk is considered in failure
	 * as we have no mean to know what really happened. */
	if (state < 0)
	{
	    exalog_error("testing rdev '%s' " UUID_FMT " failed: %s (%d)",
			 disk->path, UUID_VAL(&disk->uuid),
			 exa_error_msg(state), state);
	    state = EXA_RDEV_STATUS_FAIL;
	}

	if (state != last_state)
	{
	    if (state == EXA_RDEV_STATUS_FAIL)
		rdev_need_check = true;
	    disk->local->state = state;
	}
      }
    }

    adm_node_unlock_disk_removal();

    if (quit)
	break;

    if (rdev_need_check)
    {
      instance_event_msg_t msg;
      int ret;

      msg.any.type = EXAMSG_EVMGR_INST_EVENT;
      msg.event.id = EXAMSG_RDEV_ID;
      msg.event.state = INSTANCE_CHECK_DOWN;
      msg.event.node_id = adm_myself()->id;

      exalog_info("... broadcasting action: rdev check down");

      ret = examsgSend(mh, EXAMSG_ADMIND_EVMGR_ID,
                       EXAMSG_ALLHOSTS, &msg, sizeof(msg));
      EXA_ASSERT(ret == sizeof(msg));
    }

    os_sleep(DISK_CHECK_INTERVAL);
  }
}