fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * CDDL HEADER START
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * The contents of this file are subject to the terms of the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Common Development and Distribution License (the "License").
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * You may not use this file except in compliance with the License.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * or http://www.opensolaris.org/os/licensing.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * See the License for the specific language governing permissions
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * and limitations under the License.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * When distributing Covered Code, include this CDDL HEADER in each
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * If applicable, add the following below this CDDL HEADER, with the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * fields enclosed by brackets "[]" replaced with your own identifying
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * information: Portions Copyright [yyyy] [name of copyright owner]
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * CDDL HEADER END
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Use is subject to license terms.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <sys/types.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <stdio.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <errno.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <strings.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <stdlib.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <unistd.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <netdb.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <sys/stream.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <sys/socket.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <netinet/in.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <arpa/inet.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <ctype.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <thread.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <pthread.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <sys/unistat/spcs_s.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <sys/unistat/spcs_s_u.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <sys/unistat/spcs_s_impl.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <sys/unistat/spcs_errors.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <sys/nsctl/rdc_io.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <sys/nsctl/rdc_ioctl.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <sys/nsctl/rdc_prot.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <sys/nsctl/librdc.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <sys/nsctl/rdcrules.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <sys/nsctl/rdcerr.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <sys/nsctl/cfg.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <sys/unistat/spcs_dtrinkets.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <sys/unistat/spcs_etrinkets.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <sys/socket.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <netinet/in.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <arpa/inet.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <netinet/tcp.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <rpc/rpc_com.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <rpc/rpc.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestruct netbuf svaddr, *svp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestruct netconfig nconf, *conf;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestruct knetconfig knconf;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * libdscfg type stuff here
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern int sv_enable(CFGFILE *cfg, rdcconfig_t *rdc);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern int add_to_rdc_cfg(rdcconfig_t *rdcs);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern int remove_from_rdc_cfg(rdcconfig_t *rdcs);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern int replace_cfgfield(rdcconfig_t *rdcs, char *field, char *value);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern int reverse_in_cfg(rdcconfig_t *rdcs);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forterdcconfig_t *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forterdc_dup_config(rdcconfig_t *orig)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdcconfig_t *rc;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rc = (rdcconfig_t *)calloc(1, sizeof (*rc));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!rc) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdc_set_error(NULL, RDC_OS, RDC_FATAL, NULL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (NULL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *rc = *orig;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rc->next = NULL; /* don't want to hook into wrong chaing */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (rc);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * takes in a chain of rdcconfig_t's and a chain
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * of rdc_rc_t's, checks for success in the rdc_rc_t,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * then adds the corresponding rdcconfig_t to the return
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * chain.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forterdcconfig_t *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortechain_successful(rdcconfig_t *rdcs, rdc_rc_t *rcs)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdc_rc_t *rcp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdcconfig_t *rdcp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdcconfig_t *ret = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdcconfig_t *retp = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rcp = rcs;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdcp = rdcs;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while (rcp) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (rcp->rc == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((ret == NULL) && (rdcp->persist)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte retp = ret = rdc_dup_config(rdcp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if ((ret) && (rdcp->persist)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte retp->next = rdc_dup_config(rdcp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte retp = retp->next;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rcp = rcp->next;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdcp = rdcp->next;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ret);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forterdc_set_t
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteconfig2set(rdcconfig_t *rdc)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdc_set_t urdc;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bzero(&urdc, sizeof (rdc_set_t));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte strncpy(urdc.primary.intf, rdc->phost, MAX_RDC_HOST_SIZE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte strncpy(urdc.primary.file, rdc->pfile, NSC_MAXPATH);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte strncpy(urdc.primary.bitmap, rdc->pbmp, NSC_MAXPATH);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte strncpy(urdc.secondary.intf, rdc->shost, MAX_RDC_HOST_SIZE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte strncpy(urdc.secondary.file, rdc->sfile, NSC_MAXPATH);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte strncpy(urdc.secondary.bitmap, rdc->sbmp, NSC_MAXPATH);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte strncpy(urdc.group_name, rdc->group, NSC_MAXPATH);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (urdc);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forterdc_rc_t *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortenew_rc()
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdc_rc_t *rc;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rc = (rdc_rc_t *)calloc(1, sizeof (*rc));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (rc == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdc_set_error(NULL, RDC_OS, RDC_FATAL, NULL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (NULL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (rc);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forterdc_rc_t
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forterdc_config(rdc_config_t *rdccfg)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdc_rc_t rc;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdc_set_t *set;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte spcs_s_info_t ustatus;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bzero(&rc, sizeof (rc));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ustatus = spcs_s_ucreate();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (self_check(rdccfg->rdc_set->primary.intf)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdccfg->options |= RDC_OPT_PRIMARY;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* this needs changin if we do campus */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdccfg->rdc_set->direct_file[0] = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdccfg->options |= RDC_OPT_SECONDARY;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* set up return stuff.. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte set = &rdccfg->rdc_set[0];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte strncpy(rc.set.phost, set->primary.intf, MAX_RDC_HOST_SIZE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte strncpy(rc.set.pfile, set->primary.file, NSC_MAXPATH);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte strncpy(rc.set.shost, set->secondary.intf, MAX_RDC_HOST_SIZE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte strncpy(rc.set.sfile, set->secondary.file, NSC_MAXPATH);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rc.rc = RDC_IOCTL(RDC_CONFIG, rdccfg, NULL, 0, 0, 0, ustatus);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (rc.rc < 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdc_set_error(&ustatus, RDC_SPCS, 0, 0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte strncpy(rc.msg, rdc_error(NULL), RDC_ERR_SIZE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (rc);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortevoid *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forterdc_mtconfig(void *rdc)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdc_rc_t *rc[1];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdc_set_t *set;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte spcs_s_info_t ustatus;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdc_config_t *rdccfg = (rdc_config_t *)rdc;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ustatus = spcs_s_ucreate();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (self_check(rdccfg->rdc_set->primary.intf)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdccfg->options |= RDC_OPT_PRIMARY;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* this needs changin if we do campus */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdccfg->rdc_set->direct_file[0] = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdccfg->options |= RDC_OPT_SECONDARY;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte set = &rdccfg->rdc_set[0];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *rc = new_rc();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte strncpy(rc[0]->set.phost, set->primary.intf, MAX_RDC_HOST_SIZE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte strncpy(rc[0]->set.pfile, set->primary.file, NSC_MAXPATH);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte strncpy(rc[0]->set.pbmp, set->primary.bitmap, NSC_MAXPATH);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte strncpy(rc[0]->set.shost, set->secondary.intf, MAX_RDC_HOST_SIZE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte strncpy(rc[0]->set.sfile, set->secondary.file, NSC_MAXPATH);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte strncpy(rc[0]->set.sbmp, set->secondary.bitmap, NSC_MAXPATH);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rc[0]->rc = RDC_IOCTL(RDC_CONFIG, rdccfg, NULL, 0, 0, 0, ustatus);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (rc[0]->rc < 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdc_set_error(&ustatus, RDC_SPCS, 0, 0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte strncpy(rc[0]->msg, rdc_error(NULL), RDC_ERR_SIZE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sleep(1); /* give thr_join a chance to be called */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte free(rdccfg);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte thr_exit((void **) *rc);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (NULL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortepopulate_addrs(rdc_set_t *urdc, int isenable)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte struct t_info tinfo;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte struct hostent *hp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char toname[MAX_RDC_HOST_SIZE];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char fromname[MAX_RDC_HOST_SIZE];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte strncpy(fromname, urdc->primary.intf, MAX_RDC_HOST_SIZE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte strncpy(toname, urdc->secondary.intf, MAX_RDC_HOST_SIZE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((fromname[0] == '\0') || (fromname[0] == '\0')) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdc_set_error(NULL, RDC_INTERNAL, RDC_FATAL,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "NULL hostname recieved");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (-1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte hp = gethost_byname(fromname);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte strncpy(fromname, hp->h_name, MAX_RDC_HOST_SIZE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte hp = gethost_byname(toname);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte strncpy(toname, hp->h_name, MAX_RDC_HOST_SIZE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (self_check(fromname) && self_check(toname)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdc_set_error(NULL, RDC_INTERNAL, RDC_FATAL, "");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (isenable) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte svp = get_addr(toname, RDC_PROGRAM, RDC_VERS_MIN,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte &conf, NULL, "rdc", &tinfo, 0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (svp == NULL)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (-1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte svaddr = *svp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bzero(&svaddr, sizeof (svaddr));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte urdc->secondary.addr.len = svaddr.len;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte urdc->secondary.addr.maxlen = svaddr.maxlen;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte urdc->secondary.addr.buf = (void*)svaddr.buf;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (isenable) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte svp = get_addr(fromname, RDC_PROGRAM, RDC_VERS_MIN,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte &conf, NULL, "rdc", &tinfo, 0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (svp == NULL)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (-1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte svaddr = *svp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bzero(&svaddr, sizeof (svaddr));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte urdc->primary.addr.len = svaddr.len;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte urdc->primary.addr.maxlen = svaddr.maxlen;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte urdc->primary.addr.buf = (void*)svaddr.buf;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (isenable) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte convert_nconf_to_knconf(conf, &knconf);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte urdc->netconfig = &knconf;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte urdc->netconfig = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte urdc->syshostid = (int32_t)gethostid();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortevoid
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forterdc_free_config(rdcconfig_t *rdc, int all)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdcconfig_t *rdcp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdcconfig_t *rdcq;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdcp = rdc;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (all == RDC_FREEONE) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte free(rdcp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else while (rdcp) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdcq = rdcp->next;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte free(rdcp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdcp = rdcq;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdc = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortevoid
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forterdc_free_rclist(rdc_rc_t *rc) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdc_rc_t *rcp, *rcq;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rcp = rc;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while (rcp) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rcq = rcp->next;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte free(rcp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rcp = rcq;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*ARGSUSED*/
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forterdcconfig_t *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forterdc_alloc_config(const char *phost, const char *pfile,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte const char *pbmp, const char *shost, const char *sfile, const char *sbmp,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte const char *mode, const char *group, const char *ctag, const char *options,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int persist)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdcconfig_t *rc;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rc = (rdcconfig_t *)calloc(1, sizeof (*rc));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!rc) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdc_set_error(NULL, RDC_OS, RDC_FATAL, NULL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (NULL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (phost)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte strncpy(rc->phost, phost, NSC_MAXPATH);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (pfile)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte strncpy(rc->pfile, pfile, NSC_MAXPATH);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (pbmp)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte strncpy(rc->pbmp, pbmp, NSC_MAXPATH);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (shost)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte strncpy(rc->shost, shost, NSC_MAXPATH);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (sfile)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte strncpy(rc->sfile, sfile, NSC_MAXPATH);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (sbmp)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte strncpy(rc->sbmp, sbmp, NSC_MAXPATH);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte strncpy(rc->direct, "ip", 2);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (mode)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte strncpy(rc->mode, mode, NSC_MAXPATH);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ctag)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte strncpy(rc->ctag, ctag, NSC_MAXPATH);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (options)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte strncpy(rc->options, options, NSC_MAXPATH);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rc->persist = persist;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rc->next = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (rc);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortevoid
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortepopulate_rc(rdc_rc_t *rcp, rdcconfig_t *rdcp)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rcp->rc = -1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte strncpy(rcp->msg, rdc_error(NULL), RDC_ERR_SIZE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte strncpy(rcp->set.phost, rdcp->phost, NSC_MAXPATH);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte strncpy(rcp->set.pfile, rdcp->pfile, NSC_MAXPATH);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte strncpy(rcp->set.shost, rdcp->shost, NSC_MAXPATH);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte strncpy(rcp->set.sfile, rdcp->sfile, NSC_MAXPATH);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * rdc_enable
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * return values
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * NULL on error
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * pointer to rdc_rc_t list of return values
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forterdc_rc_t *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forterdc_enable(rdcconfig_t *rdc)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdc_config_t rdccfg;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdcconfig_t *rdcp = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdcconfig_t *cfg_rdcs = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdc_rc_t *rc = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdc_rc_t *rcp = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdcp = rdc;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rc = new_rc();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!rc) { /* error already set */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (NULL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rcp = rc;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while (rdcp) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!rdcp->mode) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdc_set_error(NULL, RDC_INTERNAL, RDC_NONFATAL,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte RDC_EINVAL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (NULL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bzero(&rdccfg, sizeof (rdc_config_t));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdccfg.rdc_set[0] = config2set(rdcp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdccfg.command = RDC_CMD_ENABLE;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdccfg.options = RDC_OPT_SETBMP;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (strncmp(rdcp->mode, "sync", NSC_MAXPATH) == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdccfg.options |= RDC_OPT_SYNC;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if (strncmp(rdc->mode, "async", NSC_MAXPATH) == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdccfg.options |= RDC_OPT_ASYNC;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdc_set_error(NULL, RDC_INTERNAL, RDC_NONFATAL,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte RDC_EINVAL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (NULL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte populate_addrs(&rdccfg.rdc_set[0], 1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (can_enable(rdcp)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* do the operation */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *rcp = rdc_config(&rdccfg);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else { /* set up what rdc_config would've set up */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte populate_rc(rcp, rdcp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((rcp->rc == 0) && (!rdcp->persist)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * if we are not persisting, do this now,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * otherwise we will do it when
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * we have a lock on the cfg in add_to_rdc_cfg
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sv_enable(NULL, rdcp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdcp = rdcp->next;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!rdcp)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rcp->next = new_rc();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rcp = rcp->next;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!rcp) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* dont free here, return what you have */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * travel the rc chain and rdc chain checking results,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * building a new chain, and updating dscfg
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rcp = rc;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdcp = rdc;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cfg_rdcs = chain_successful(rdcp, rcp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (add_to_rdc_cfg(cfg_rdcs) < 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* XXX should disable or something here */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (rc);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdc_free_config(cfg_rdcs, RDC_FREEALL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (rc);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forterdc_rc_t *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forterdc_enable_clrbmp(rdcconfig_t *rdc)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdc_config_t rdccfg;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdcconfig_t *rdcp = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdcconfig_t *cfg_rdcs = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdc_rc_t *rc = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdc_rc_t *rcp = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdcp = rdc;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rc = (rdc_rc_t *)calloc(1, sizeof (rdc_rc_t));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!rc) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdc_set_error(NULL, RDC_OS, RDC_FATAL, NULL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (NULL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rcp = rc;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while (rdcp) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!rdcp->mode) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdc_set_error(NULL, RDC_INTERNAL, RDC_NONFATAL,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte RDC_EINVAL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (NULL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bzero(&rdccfg, sizeof (rdc_config_t));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdccfg.rdc_set[0] = config2set(rdcp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdccfg.command = RDC_CMD_ENABLE;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdccfg.options = RDC_OPT_CLRBMP;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (strncmp(rdcp->mode, "sync", NSC_MAXPATH) == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdccfg.options |= RDC_OPT_SYNC;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if (strncmp(rdc->mode, "async", NSC_MAXPATH) == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdccfg.options |= RDC_OPT_ASYNC;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdc_set_error(NULL, RDC_INTERNAL, RDC_NONFATAL,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte RDC_EINVAL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (NULL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte populate_addrs(&rdccfg.rdc_set[0], 1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (can_enable(rdcp)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* do the operation */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *rcp = rdc_config(&rdccfg);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else { /* set up what rdc_config would've set up */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte populate_rc(rcp, rdcp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdcp = rdcp->next;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!rdcp)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rcp->next = (rdc_rc_t *)calloc(1, sizeof (rdc_rc_t));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rcp = rcp->next;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!rcp)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * travel the rc chain and rdc chain checking results,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * building a new chain, and updating dscfg
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rcp = rc;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdcp = rdc;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cfg_rdcs = chain_successful(rdcp, rcp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (add_to_rdc_cfg(cfg_rdcs) < 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* XXX should disable or something here */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (rc);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdc_free_config(cfg_rdcs, RDC_FREEALL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (rc);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forterdc_rc_t *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forterdc_disable(rdcconfig_t *rdc)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdc_config_t rdccfg;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdcconfig_t *rdcp = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdcconfig_t *cfg_rdcs = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdc_rc_t *rc = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdc_rc_t *rcp = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdcp = rdc;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rc = new_rc();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!rc) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (NULL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rcp = rc;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while (rdcp) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bzero(&rdccfg, sizeof (rdc_config_t));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdccfg.rdc_set[0] = config2set(rdcp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdccfg.command = RDC_CMD_DISABLE;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte populate_addrs(&rdccfg.rdc_set[0], 0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *rcp = rdc_config(&rdccfg);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdcp = rdcp->next;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!rdcp)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rcp->next = new_rc();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rcp = rcp->next;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!rcp)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (rc);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rcp = rc;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdcp = rdc;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cfg_rdcs = chain_successful(rdcp, rcp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte remove_from_rdc_cfg(cfg_rdcs);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdc_free_config(cfg_rdcs, RDC_FREEALL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (rc);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forterdc_rc_t *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forterdc_log(rdcconfig_t *rdc)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdc_config_t rdccfg;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdcconfig_t *rdcp = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdc_rc_t *rc = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdc_rc_t *rcp = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdcp = rdc;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rc = new_rc();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!rc) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (NULL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rcp = rc;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while (rdcp) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bzero(&rdccfg, sizeof (rdc_config_t));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdccfg.rdc_set[0] = config2set(rdcp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdccfg.command = RDC_CMD_LOG;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte populate_addrs(&rdccfg.rdc_set[0], 0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *rcp = rdc_config(&rdccfg);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdcp = rdcp->next;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!rdcp)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rcp->next = new_rc();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rcp = rcp->next;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!rcp)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (rc);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forterdc_rc_t *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forterdc_usync(rdcconfig_t *rdc)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdc_config_t *rdccfg;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdcconfig_t *rdcp = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdc_rc_t *rc = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdc_rc_t *rcp = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdc_rc_t *tmprc;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int trc;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdcp = rdc;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while (rdcp) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* freed in rdc_mtconfig */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdccfg = (rdc_config_t *)calloc(1, sizeof (rdc_config_t));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdccfg->rdc_set[0] = config2set(rdcp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdccfg->command = RDC_CMD_COPY;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdccfg->options = RDC_OPT_UPDATE|RDC_OPT_FORWARD;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte populate_addrs(&rdccfg->rdc_set[0], 0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte trc = thr_create(NULL, 0, rdc_mtconfig,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void **) rdccfg, THR_BOUND, NULL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdcp = rdcp->next;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!rdcp)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * collect status here from thr_join-status,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * and add to rdc_rc_t chain ?
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * this will block, but caller could always thread too
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while (thr_join(NULL, NULL, (void**) &tmprc) == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (rc == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rcp = rc = (rdc_rc_t *)tmprc;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rcp->next = (rdc_rc_t *)tmprc;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rcp = rcp->next;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (rc);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forterdc_rc_t *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forterdc_fsync(rdcconfig_t *rdc)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdc_config_t *rdccfg;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdcconfig_t *rdcp = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdc_rc_t *rc = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdc_rc_t *rcp = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdc_rc_t *tmprc = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int trc;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdcp = rdc;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rc = new_rc();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!rc) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (NULL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rcp = rc;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while (rdcp) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* freed in rdc_mtconfig */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdccfg = (rdc_config_t *)calloc(1, sizeof (rdc_config_t));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdccfg->rdc_set[0] = config2set(rdcp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdccfg->command = RDC_CMD_COPY;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdccfg->options = RDC_OPT_FULL|RDC_OPT_FORWARD;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte populate_addrs(&rdccfg->rdc_set[0], 0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte trc = thr_create(NULL, 0, rdc_mtconfig,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void **) rdccfg, THR_BOUND, NULL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdcp = rdcp->next;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!rdcp)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * collect status here from thr_join-status,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * and add to rdc_rc_t chain ?
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * this will block, but caller could always thread too
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while (thr_join(NULL, NULL, (void**) &tmprc) == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (rc == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rcp = rc = (rdc_rc_t *)tmprc;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rcp->next = (rdc_rc_t *)tmprc;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rcp = rcp->next;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (rc);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forterdc_rc_t *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forterdc_rsync(rdcconfig_t *rdc)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdc_config_t *rdccfg;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdcconfig_t *rdcp = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdc_rc_t *rc = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdc_rc_t *rcp = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdc_rc_t *tmprc = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int trc;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdcp = rdc;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rc = new_rc();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!rc) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (NULL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rcp = rc;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while (rdcp) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte tmprc = cant_rsync(rdcp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (tmprc != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (rc == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rcp = rc = tmprc;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rcp->next = tmprc;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rcp = rcp->next;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte goto next;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* freed in rdc_mtconfig */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdccfg = (rdc_config_t *)calloc(1, sizeof (rdc_config_t));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdccfg->rdc_set[0] = config2set(rdcp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdccfg->command = RDC_CMD_COPY;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdccfg->options = RDC_OPT_REVERSE|RDC_OPT_FULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte populate_addrs(&rdccfg->rdc_set[0], 0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte trc = thr_create(NULL, 0, rdc_mtconfig,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void **) rdccfg, THR_BOUND, NULL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortenext:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdcp = rdcp->next;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!rdcp)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * collect status here from thr_join-status,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * and add to rdc_rc_t chain ?
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * this will block, but caller could always thread too
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while (thr_join(NULL, NULL, (void**) &tmprc) == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (rc == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rcp = rc = (rdc_rc_t *)tmprc;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rcp->next = (rdc_rc_t *)tmprc;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rcp = rcp->next;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (rc);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forterdc_rc_t *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forterdc_ursync(rdcconfig_t *rdc)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdc_config_t *rdccfg;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdcconfig_t *rdcp = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdc_rc_t *rc = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdc_rc_t *rcp = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdc_rc_t *tmprc = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int trc;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdcp = rdc;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while (rdcp) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte tmprc = cant_rsync(rdcp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (tmprc != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (rc == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rcp = rc = tmprc;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rcp->next = tmprc;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rcp = rcp->next;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte goto next;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* freed in rdc_mtconfig */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdccfg = (rdc_config_t *)calloc(1, sizeof (rdc_config_t));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdccfg->rdc_set[0] = config2set(rdcp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdccfg->command = RDC_CMD_COPY;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdccfg->options = RDC_OPT_REVERSE | RDC_OPT_UPDATE;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte populate_addrs(&rdccfg->rdc_set[0], 0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte trc = thr_create(NULL, 0, rdc_mtconfig,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void **) rdccfg, THR_BOUND, NULL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortenext:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdcp = rdcp->next;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!rdcp)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * collect status here from thr_join-status,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * and add to rdc_rc_t chain ?
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * this will block, but caller could always thread too
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while (thr_join(NULL, NULL, (void**) &tmprc) == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (rc == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rcp = rc = (rdc_rc_t *)tmprc;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rcp->next = (rdc_rc_t *)tmprc;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rcp = rcp->next;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (rc);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forterdc_rc_t *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forterdc_wait(rdcconfig_t *rdc)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdc_config_t rdccfg;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdcconfig_t *rdcp = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdc_rc_t *rc = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdc_rc_t *rcp = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdcp = rdc;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rc = new_rc();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!rc) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (NULL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rcp = rc;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while (rdcp) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bzero(&rdccfg, sizeof (rdc_config_t));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdccfg.rdc_set[0] = config2set(rdcp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdccfg.command = RDC_CMD_WAIT;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte populate_addrs(&rdccfg.rdc_set[0], 0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *rcp = rdc_config(&rdccfg);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdcp = rdcp->next;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!rdcp)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rcp->next = new_rc();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rcp = rcp->next;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!rcp)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (rc);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forterdc_rc_t *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forterdc_set_autosync(rdcconfig_t *rdc, int autosync)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdc_config_t rdccfg;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdcconfig_t *rdcp = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdc_rc_t *rc = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdc_rc_t *rcp = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdcp = rdc;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rc = new_rc();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!rc) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (NULL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rcp = rc;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while (rdcp) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bzero(&rdccfg, sizeof (rdc_config_t));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdccfg.rdc_set[0] = config2set(rdcp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdccfg.command = RDC_CMD_TUNABLE;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdccfg.rdc_set[0].autosync = autosync;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdccfg.rdc_set[0].maxqitems = -1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdccfg.rdc_set[0].maxqfbas = -1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte populate_addrs(&rdccfg.rdc_set[0], 0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *rcp = rdc_config(&rdccfg);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdcp = rdcp->next;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!rdcp)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rcp->next = new_rc();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rcp = rcp->next;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!rcp)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (rc);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forterdc_rc_t *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forterdc_set_maxqfbas(rdcconfig_t *rdc, int maxqfbas)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdc_config_t rdccfg;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdcconfig_t *rdcp = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdc_rc_t *rc = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdc_rc_t *rcp = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdcp = rdc;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rc = new_rc();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!rc) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (NULL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rcp = rc;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while (rdcp) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bzero(&rdccfg, sizeof (rdc_config_t));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdccfg.rdc_set[0] = config2set(rdcp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdccfg.command = RDC_CMD_TUNABLE;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdccfg.rdc_set[0].autosync = -1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdccfg.rdc_set[0].maxqitems = -1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdccfg.rdc_set[0].maxqfbas = maxqfbas;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte populate_addrs(&rdccfg.rdc_set[0], 0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *rcp = rdc_config(&rdccfg);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdcp = rdcp->next;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!rdcp)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rcp->next = new_rc();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rcp = rcp->next;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!rcp)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (rc);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forterdc_rc_t *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forterdc_set_maxqitems(rdcconfig_t *rdc, int maxqitems)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdc_config_t rdccfg;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdcconfig_t *rdcp = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdc_rc_t *rc = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdc_rc_t *rcp = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdcp = rdc;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rc = new_rc();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!rc) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (NULL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rcp = rc;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while (rdcp) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bzero(&rdccfg, sizeof (rdc_config_t));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdccfg.rdc_set[0] = config2set(rdc);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdccfg.command = RDC_CMD_TUNABLE;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdccfg.rdc_set[0].autosync = -1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdccfg.rdc_set[0].maxqitems = maxqitems;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdccfg.rdc_set[0].maxqfbas = -1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte populate_addrs(&rdccfg.rdc_set[0], 0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *rcp = rdc_config(&rdccfg);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdcp = rdcp->next;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!rdcp)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rcp->next = new_rc();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rcp = rcp->next;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!rcp)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (rc);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forterdc_set_t
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forterdc_status(rdcconfig_t *rdc)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdc_config_t rdccfg;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bzero(&rdccfg, sizeof (rdc_config_t));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdccfg.rdc_set[0] = config2set(rdc);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdccfg.command = RDC_CMD_STATUS;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte populate_addrs(&rdccfg.rdc_set[0], 0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdc_config(&rdccfg);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (rdccfg.rdc_set[0]);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forterdc_get_autosync(rdcconfig_t *rdc)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdc_set_t rdcset;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdcset = rdc_status(rdc);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (rdcset.autosync);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forterdc_get_maxqfbas(rdcconfig_t *rdc)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdc_set_t rdcset;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdcset = rdc_status(rdc);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (rdcset.maxqfbas);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forterdc_get_maxqitems(rdcconfig_t *rdc)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdc_set_t rdcset;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdcset = rdc_status(rdc);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (rdcset.maxqitems);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteset_mode(rdcconfig_t *rdc)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (strcmp(rdc->mode, "async") == 0)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (RDC_OPT_ASYNC);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte else
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (RDC_OPT_SYNC);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * reconfig bitmaps are single set only ops
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * for obvious reasons
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forterdc_rc_t *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forterdc_reconfig_pbmp(rdcconfig_t *rdc, char *pbmp)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdc_config_t rdccfg;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdc_rc_t *rc;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rc = new_rc();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((!rc) || (!pbmp))
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (NULL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bzero(&rdccfg, sizeof (rdc_config_t));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdccfg.rdc_set[0] = config2set(rdc);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte strncpy(rdccfg.rdc_set[0].primary.bitmap, pbmp, NSC_MAXPATH);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdccfg.command = RDC_CMD_RECONFIG;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdccfg.options |= set_mode(rdc);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte populate_addrs(&rdccfg.rdc_set[0], 0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (can_reconfig_pbmp(rdc, pbmp))
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *rc = rdc_config(&rdccfg);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte else
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte populate_rc(rc, rdc);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((rc->rc == 0) && (rdc->persist))
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (replace_cfgfield(rdc, "pbitmap", pbmp) < 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rc->rc = -1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte strncpy(rc->msg, rdc_error(NULL), RDC_ERR_SIZE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (rc);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forterdc_rc_t *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forterdc_reconfig_sbmp(rdcconfig_t *rdc, char *sbmp)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdc_config_t rdccfg;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdc_rc_t *rc;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rc = new_rc();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!rc)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (NULL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bzero(&rdccfg, sizeof (rdc_config_t));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdccfg.rdc_set[0] = config2set(rdc);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte strncpy(rdccfg.rdc_set[0].secondary.bitmap, sbmp, NSC_MAXPATH);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdccfg.command = RDC_CMD_RECONFIG;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdccfg.options |= set_mode(rdc);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte populate_addrs(&rdccfg.rdc_set[0], 0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (can_reconfig_sbmp(rdc, sbmp))
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *rc = rdc_config(&rdccfg);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte else
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte populate_rc(rc, rdc);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((rc->rc == 0) && (rdc->persist))
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte replace_cfgfield(rdc, "sbitmap", sbmp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (rc);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forterdc_rc_t *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forterdc_reconfig_group(rdcconfig_t *rdc, char *group)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdc_config_t rdccfg;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdcconfig_t *rdcp = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdcconfig_t *cfg_rdcs = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdc_rc_t *rc = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdc_rc_t *rcp = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdcp = rdc;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rc = new_rc();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!rc) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (NULL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rcp = rc;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while (rdcp) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bzero(&rdccfg, sizeof (rdc_config_t));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* just in case */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte strncpy(rdcp->group, group, NSC_MAXPATH);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdccfg.rdc_set[0] = config2set(rdcp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdccfg.command = RDC_CMD_RECONFIG;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdccfg.options |= set_mode(rdcp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte populate_addrs(&rdccfg.rdc_set[0], 0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* reconfig group rules enforced in kernel */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *rcp = rdc_config(&rdccfg);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdcp = rdcp->next;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!rdcp)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rcp->next = new_rc();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rcp = rcp->next;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!rcp)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rcp = rc;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdcp = rdc;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cfg_rdcs = chain_successful(rdcp, rcp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte replace_cfgfield(cfg_rdcs, "group", group);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdc_free_config(cfg_rdcs, RDC_FREEALL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (rc);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*ARGSUSED*/
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forterdc_rc_t *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forterdc_reconfig_ctag(rdcconfig_t *rdc, char *ctag)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (NULL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forterdc_rc_t *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forterdc_set_sync(rdcconfig_t *rdc)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdc_config_t rdccfg;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdcconfig_t *rdcp = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdcconfig_t *cfg_rdcs = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdc_rc_t *rc = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdc_rc_t *rcp = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdcp = rdc;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rc = new_rc();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!rc) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (NULL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rcp = rc;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while (rdcp) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bzero(&rdccfg, sizeof (rdc_config_t));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdccfg.rdc_set[0] = config2set(rdc);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdccfg.command = RDC_CMD_RECONFIG;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdccfg.options |= RDC_OPT_SYNC;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte populate_addrs(&rdccfg.rdc_set[0], 0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *rcp = rdc_config(&rdccfg);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdcp = rdcp->next;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!rdcp)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rcp->next = new_rc();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rcp = rcp->next;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!rcp)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rcp = rc;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdcp = rdc;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cfg_rdcs = chain_successful(rdcp, rcp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte replace_cfgfield(cfg_rdcs, "mode", "sync");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdc_free_config(cfg_rdcs, RDC_FREEALL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (rc);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forterdc_rc_t *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forterdc_set_async(rdcconfig_t *rdc)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdc_config_t rdccfg;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdcconfig_t *rdcp = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdcconfig_t *cfg_rdcs = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdc_rc_t *rc = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdc_rc_t *rcp = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdcp = rdc;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rc = new_rc();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!rc) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (NULL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rcp = rc;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while (rdcp) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bzero(&rdccfg, sizeof (rdc_config_t));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdccfg.rdc_set[0] = config2set(rdcp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdccfg.command = RDC_CMD_RECONFIG;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdccfg.options |= RDC_OPT_ASYNC;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte populate_addrs(&rdccfg.rdc_set[0], 0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *rcp = rdc_config(&rdccfg);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdcp = rdcp->next;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!rdcp)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rcp->next = new_rc();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rcp = rcp->next;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!rcp)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rcp = rc;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdcp = rdc;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cfg_rdcs = chain_successful(rdcp, rcp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte replace_cfgfield(cfg_rdcs, "mode", "async");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdc_free_config(cfg_rdcs, RDC_FREEALL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (rc);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forterdc_rc_t *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forterdc_health(rdcconfig_t *rdc)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdc_config_t rdccfg;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdcconfig_t *rdcp = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdc_rc_t *rc = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdc_rc_t *rcp = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdcp = rdc;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rc = new_rc();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!rc) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (NULL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rcp = rc;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while (rdcp) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bzero(&rdccfg, sizeof (rdc_config_t));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdccfg.rdc_set[0] = config2set(rdcp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdccfg.command = RDC_CMD_HEALTH;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte populate_addrs(&rdccfg.rdc_set[0], 0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *rcp = rdc_config(&rdccfg);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdcp = rdcp->next;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!rdcp)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rcp->next = new_rc();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rcp = rcp->next;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!rcp)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (rc);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forterdc_rc_t *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forterdc_reverse_role(rdcconfig_t *rdc)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdc_config_t rdccfg;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdcconfig_t *rdcp = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdcconfig_t *cfg_rdcs = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdc_rc_t *rc = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdc_rc_t *rcp = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdcp = rdc;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rc = new_rc();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!rc) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (NULL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rcp = rc;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while (rdcp) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bzero(&rdccfg, sizeof (rdc_config_t));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdccfg.rdc_set[0] = config2set(rdcp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdccfg.command = RDC_CMD_RECONFIG;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdccfg.options |= RDC_OPT_REVERSE_ROLE;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdccfg.options |= set_mode(rdcp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte populate_addrs(&rdccfg.rdc_set[0], 0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *rcp = rdc_config(&rdccfg);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdcp = rdcp->next;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!rdcp)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rcp->next = new_rc();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rcp = rcp->next;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!rcp)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rcp = rc;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdcp = rdc;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cfg_rdcs = chain_successful(rdcp, rcp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte reverse_in_cfg(cfg_rdcs);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdc_free_config(cfg_rdcs, RDC_FREEALL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (rc);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}