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 */
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Use is subject to license terms.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <sys/types.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <sys/wait.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <stdio.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <errno.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <limits.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <fcntl.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <strings.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <stdlib.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <unistd.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <pthread.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <thread.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <locale.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <langinfo.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <libintl.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <stdarg.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
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <sys/nsctl/cfg.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_errors.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <sys/nsctl/librdc.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include "rdcadm.h"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define RDCADM "/usr/sbin/sndradm"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define IIADM "/usr/sbin/iiadm"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define UPDATE "update"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define NOUPDATE "noupdate"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define RESYNC_SLEEP (3 * 60) /* Three minutes */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define MAIN_SLEEP (5 * 60) /* Five minutes */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define CFG_WAIT_SLEEP (5) /* 5 sec */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define MAXHOSTS 1024
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortemutex_t cfglock = DEFAULTMUTEX;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define LOCKCFG() (void) mutex_lock(&cfglock);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define UNLOCKCFG() (void) mutex_unlock(&cfglock);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortetypedef struct host_list_s {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char *hosts[MAXHOSTS];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int numhosts;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int configured[MAXHOSTS];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mutex_t hosts_mutex;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte} host_list_t;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortehost_list_t *host_list;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern char *basename(char *);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint rdc_maxsets;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortechar *program;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int clustered = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint isnewhost(char *host);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortevoid *wait_sync_event();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortevoid *wait_link_down(void *host);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortevoid rdc_sync(char *tohost);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortevoid remove_from_hostlist(char *host);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortevoid sync_start(char *master);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortevoid sync_complete(char *master);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortevoid cleanup_hostlist();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortevoid group_start(char *group);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortevoid group_complete(char *group);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortevoid
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteinit_host_list(void)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte host_list = calloc(1, sizeof (host_list_t));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (host_list == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte spcs_log("sndr", NULL,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("host list not initialized, cannot run"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdc_err(NULL, gettext("host list not initialized, cannot run"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) mutex_init(&host_list->hosts_mutex, USYNC_THREAD, NULL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* ARGSUSED */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#ifdef lint
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortevoid
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortesndrsyncd_lintmain(argc, argv)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#else
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortemain(argc, argv)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint argc;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortechar **argv;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdc_status_t *rdc_info;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int size;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int i;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pid_t pid;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte spcs_s_info_t ustatus;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int rc, trc;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int first = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char *required;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) setlocale(LC_ALL, "");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) textdomain("rdc");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ustatus = spcs_s_ucreate();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte program = basename(argv[0]);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte init_host_list();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rc = rdc_check_release(&required);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (rc < 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdc_err(NULL,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("unable to determine the current "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "Solaris release: %s\n"), strerror(errno));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* NOTREACHED */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if (rc == FALSE) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdc_err(NULL,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("incorrect Solaris release (requires %s)\n"),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte required);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* NOTREACHED */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte clustered = cfg_iscluster();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (clustered < 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdc_err(NULL, gettext("unable to ascertain environment"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdc_maxsets = rdc_get_maxsets();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (rdc_maxsets == -1) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte spcs_log("sndr", NULL,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("%s: unable to get maxsets value from kernel"),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte program);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdc_err(NULL,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("unable to get maxsets value from kernel"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte size = sizeof (rdc_status_t) + (sizeof (rdc_set_t) * (rdc_maxsets - 1));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdc_info = malloc(size);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (rdc_info == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte spcs_log("sndr", NULL,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("%s: unable to allocate %ld bytes"),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte program, size);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdc_err(NULL,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("unable to allocate %ld bytes"), size);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bzero(rdc_info, size);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdc_info->nset = rdc_maxsets;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Fork off a child that becomes the daemon.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((pid = fork()) > 0)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte exit(0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte else if (pid < 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte spcs_log("sndr", NULL,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("%s: cannot fork: %s"),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte program, strerror(errno));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdc_err(NULL, gettext("cannot fork: %s\n"),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte strerror(errno));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * In child - become daemon.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (i = 0; i < 3; i++)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) close(i);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) open("/dev/console", O_WRONLY|O_APPEND);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) dup(0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) dup(0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) close(0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) setpgrp();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) setlocale(LC_ALL, "");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) textdomain("rdc");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* launch a thread to wait for sync start and sync stop events */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((trc = thr_create(NULL, 0, wait_sync_event, NULL,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte THR_BOUND|THR_DETACHED, NULL)) != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte spcs_log("sndr", NULL,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("%s: unable to create thread wait_sync_event"),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte program);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdc_warn(NULL,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("%s unable to create thread wait_sync_event"),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte program);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#ifdef DEBUG
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte spcs_log("sndr", NULL,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("%s: thread wait_sync_event started"), program);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (;;) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!first) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte first++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) sleep(15);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) sleep(MAIN_SLEEP);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bzero(rdc_info, size);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdc_info->nset = rdc_maxsets;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (RDC_IOCTL(RDC_STATUS, rdc_info, 0, 0, 0, 0, ustatus)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte != SPCS_S_OK) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte spcs_log("sndr", &ustatus,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("%s: status ioctl"),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte program);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdc_warn(&ustatus, gettext("status ioctl"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte continue;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cleanup_hostlist(rdc_info); /* remove non-existent hosts */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Check all enabled sets to see if a new remote host has
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * appeared.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (i = 0; i < rdc_maxsets; i++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!(rdc_info->rdc_set[i].flags & RDC_ENABLED))
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte continue;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* spawn a new thread for each new host found */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (isnewhost(rdc_info->rdc_set[i].secondary.intf)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * right now, we could be here before
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * the database did the write for this set
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * I could check the lock on the database
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * but I am just going to give up some time here
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * instead. Why do the allocations etc, etc
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * if the set is enabled in the kernel and not
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * in the config, we know that this set has the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * lock. Why bother adding more contention to
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * the lock.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * this is a daemon, afterall. its got time
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) sleep(CFG_WAIT_SLEEP);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte spcs_log("sndr", NULL,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("%s: new host found (%s) starting "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "its autosync thread"), program,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdc_info->rdc_set[i].secondary.intf);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte trc = thr_create(NULL, 0, wait_link_down,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void *) rdc_info->rdc_set[i].\
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortesecondary.intf, THR_BOUND|THR_DETACHED, NULL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (trc != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte spcs_log("sndr", NULL,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "%s create new autosync "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "thread failed"), program);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdc_warn(NULL, gettext(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "%s create new autosync "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "thread failed"), program);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* NOTREACHED */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * The kernel wakes up this function every time it detects the link to the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * specified host has dropped.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortevoid *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortewait_link_down(void *thehost)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char *host = (char *)thehost;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char tmphost[MAX_RDC_HOST_SIZE] = { '\0' };
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte spcs_s_info_t ustatus;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (host)
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki (void) strncpy(tmphost, host, MAX_RDC_HOST_SIZE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ustatus = spcs_s_ucreate();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Never give up */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (;;) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#ifdef DEBUG
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte spcs_log("sndr", NULL,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("%s: awaiting link down ioctl for %s"),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte program, host[0] == '\0' ? tmphost : host);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (RDC_IOCTL(RDC_LINK_DOWN, host, 0, 0, 0, 0, ustatus)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte != SPCS_S_OK) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte spcs_log("sndr", &ustatus,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("%s: link down ioctl"),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte program);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdc_warn(&ustatus, gettext("link down ioctl"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte continue;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#ifdef DEBUG
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte spcs_log("sndr", NULL,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("%s: received link down ioctl for %s"),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte program, host[0] == '\0' ? tmphost : host);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdc_sync(host[0] == '\0' ? tmphost : host);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* LINTED */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Called when the link to the specified host has dropped.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * For all Remote Mirror sets using the link that have autosync on,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * issue rdcadm -u commands until they complete successfully.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortevoid
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forterdc_sync(char *tohost)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdc_set_t *rdc_set = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int *sync_done = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int sets = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int syncs_done = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char cmd[256];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdc_config_t parms = { 0 };
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte spcs_s_info_t ustatus;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int i;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int setnumber;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int numfound = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char buf[CFG_MAX_BUF];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char key[CFG_MAX_KEY];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte CFGFILE *cfg = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int size;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int first = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int death = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int cfglocked = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ustatus = spcs_s_ucreate();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte size = sizeof (rdc_set_t) * rdc_maxsets;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdc_set = malloc(size);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (rdc_set == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte spcs_log("sndr", NULL,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("%s: unable to allocate %ld bytes"),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte program, size);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdc_warn(NULL,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("unable to allocate %ld bytes"), size);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte goto done;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bzero(rdc_set, size);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte size = sizeof (int) * rdc_maxsets;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sync_done = malloc(size);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (sync_done == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte spcs_log("sndr", NULL,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("%s: unable to allocate %ld bytes"),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte program, size);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdc_warn(NULL,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("unable to allocate %ld bytes"), size);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte goto done;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bzero(sync_done, size);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Get all sndr entries with shost matching tohost, and save the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * details in an array.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (i = 0; i < rdc_maxsets; i++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte setnumber = i + 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bzero(buf, sizeof (buf));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bzero(key, sizeof (key));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) snprintf(key, sizeof (key), "sndr.set%d.shost",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte setnumber);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!cfglocked) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte LOCKCFG();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((cfg = cfg_open(NULL)) == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte spcs_log("sndr", NULL,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("%s: error opening config"),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte program);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdc_warn(NULL,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("error opening config"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte UNLOCKCFG();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte goto done;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!cfg_lock(cfg, CFG_RDLOCK)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte spcs_log("sndr", NULL,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("%s: error locking config"),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte program);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdc_warn(NULL, gettext("error locking config"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte goto done;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cfglocked = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (cfg_get_cstring(cfg, key, buf, CFG_MAX_BUF) < 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (numfound == 0) /* no matching hosts */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte death = 1; /* thread will exit */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (strcmp(buf, tohost) != 0)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte continue;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte numfound++;
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki (void) strncpy(rdc_set[sets].secondary.intf, buf,
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki MAX_RDC_HOST_SIZE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Got a matching entry */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) snprintf(key, sizeof (key), "sndr.set%d.phost",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte setnumber);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (cfg_get_cstring(cfg, key, buf, CFG_MAX_BUF) < 0)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki (void) strncpy(rdc_set[sets].primary.intf, buf,
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki MAX_RDC_HOST_SIZE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) snprintf(key, sizeof (key), "sndr.set%d.primary",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte setnumber);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (cfg_get_cstring(cfg, key, buf, CFG_MAX_BUF) < 0)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki (void) strncpy(rdc_set[sets].primary.file, buf, NSC_MAXPATH);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) snprintf(key, sizeof (key), "sndr.set%d.secondary",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte setnumber);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (cfg_get_cstring(cfg, key, buf, CFG_MAX_BUF) < 0)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki (void) strncpy(rdc_set[sets].secondary.file, buf, NSC_MAXPATH);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte parms.command = RDC_CMD_STATUS;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bcopy((void *)(&rdc_set[sets]), (void *)(&parms.rdc_set[0]),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sizeof (rdc_set_t));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * release cfg before diving into the kernel
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * this prevents a possible deadlock when doing
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * a reverse sync whick will wake up the sync_event
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * thread which will try and iiadm -c and hang
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * because we still have the cfg_lock. the timed
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * wait cv in the kernel will fail the sync and things
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * will undeadlock.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cfg_close(cfg);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cfg = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cfglocked = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte UNLOCKCFG();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (RDC_IOCTL(RDC_CONFIG, &parms, NULL, 0, 0, 0, ustatus) < 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte continue;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((parms.rdc_set[0].autosync == 0) ||
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (!(parms.rdc_set[0].flags & RDC_LOGGING))) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte continue;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Found a suitable set with autosync on, in logging mode */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sets++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (cfg) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cfg_close(cfg);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cfg = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte UNLOCKCFG();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (sets == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#ifdef DEBUG
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte spcs_log("sndr", NULL,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("%s: no sets requiring autosync found for %s"),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte program, tohost);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (death) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte spcs_log("sndr", NULL,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("%s: autosync thread stopping for %s "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "(host deconfigured)"), program, tohost);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte goto done;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Keep issuing rdcadm -u commands until they have all completed */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (;;) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!first)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte first++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte else
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) sleep(RESYNC_SLEEP);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Issue rdcadm -u commands for all remaining sets */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (i = 0; i < sets; i++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (sync_done[i])
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte continue;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Need to check if autosync was turned off for a set
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * while we were sleeping. We could have the case where
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * an update sync failed and autosync was disabled
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * while we were sleeping and didn't detect the disable.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * See BugID 4814213.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte parms.command = RDC_CMD_STATUS;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bcopy((void *)(&rdc_set[i]),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void *)(&parms.rdc_set[0]), sizeof (rdc_set_t));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (RDC_IOCTL(RDC_CONFIG, &parms, NULL, 0, 0, 0,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ustatus) < 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte spcs_log("sndr", &ustatus, gettext("%s: "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "status not available for %s:%s, stopping "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "this autosync attempt"), program, tohost,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdc_set[i].secondary.file);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sync_done[i] = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte syncs_done++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte continue;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!(parms.rdc_set[0].autosync)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#ifdef DEBUG
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte spcs_log("sndr", NULL, gettext("%s: autosync disabled during sleep, "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "stopping attempt for set %s:%s"), program, tohost,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdc_set[i].secondary.file);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sync_done[i] = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte syncs_done++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte continue;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) sprintf(cmd, "%s -un %s:%s", RDCADM, tohost,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdc_set[i].secondary.file);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte spcs_log("sndr", NULL,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("%s: issuing update sync for %s:%s"),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte program, tohost, rdc_set[i].secondary.file);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) system(cmd);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Issue rdcadm -w commands to wait for updates to finish */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (i = 0; i < sets; i++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (sync_done[i])
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte continue;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) sprintf(cmd, "%s -wn %s:%s", RDCADM, tohost,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdc_set[i].secondary.file);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte spcs_log("sndr", NULL,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("%s: issuing wait for %s:%s"),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte program, tohost, rdc_set[i].secondary.file);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) system(cmd);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte parms.command = RDC_CMD_STATUS;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bcopy((void *)(&rdc_set[i]),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void *)(&parms.rdc_set[0]), sizeof (rdc_set_t));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (RDC_IOCTL(RDC_CONFIG, &parms, NULL, 0, 0, 0,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ustatus) < 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte spcs_log("sndr", &ustatus,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("%s: status not available for "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "%s:%s, stopping this autosync attempt"),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte program, tohost, rdc_set[i].secondary.file);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sync_done[i] = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte syncs_done++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte continue;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Check if completed OK, failed or autosync off */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!(parms.rdc_set[0].autosync) ||
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte !(parms.rdc_set[0].flags & RDC_LOGGING) &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte !(parms.rdc_set[0].flags & RDC_SYNCING)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sync_done[i] = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte syncs_done++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (syncs_done == sets)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break; /* All completed OK */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortedone:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (cfg) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cfg_close(cfg);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte UNLOCKCFG();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte spcs_s_ufree(&ustatus);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (sync_done)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte free(sync_done);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (rdc_set)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte free(rdc_set);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (death) { /* bye bye */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * if perhaps we lost some race, lets remove this entry from
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * the list. Then, if something did go wrong, and we did kill
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * a valid thread, it will be detected on the next go around
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * of the thread who is looking for new hosts to spawn threads
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte remove_from_hostlist(tohost);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte thr_exit(0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) sleep(RESYNC_SLEEP);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Wait for notification by the kernel of a sync start or a sync completed OK
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortevoid *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortewait_sync_event()
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte spcs_s_info_t ustatus;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char master[NSC_MAXPATH];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char group[NSC_MAXPATH];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int state;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ustatus = spcs_s_ucreate();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte master[0] = '\0';
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte group[0] = '\0';
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Never give up */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (;;) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Kernel tells us which volume and group the event is for */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte state = RDC_IOCTL(RDC_SYNC_EVENT, master, group, 0, 0, 0,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ustatus);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (state < SPCS_S_OK) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (errno != EAGAIN) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte spcs_log("sndr", &ustatus,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("%s: update ioctl"),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte program);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdc_warn(&ustatus, gettext("update ioctl"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte continue;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte master[0] = '\0';
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte continue;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * If target is mounted at the start of a sync or reverse sync,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * return a negative ack.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((state == RDC_SYNC_START || state == RDC_RSYNC_START) &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mounted(master)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte spcs_log("sndr", NULL,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("%s: %s has a file system mounted"),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte program, master);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdc_warn(NULL,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("%s has a file system mounted"),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte master);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte master[0] = '\0'; /* negative ack */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte continue;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte switch (state) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case RDC_SYNC_START:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (group[0])
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte group_start(group);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte else
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sync_start(master);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case RDC_SYNC_DONE:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (group[0])
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte group_complete(group);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte else
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sync_complete(master);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte default:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* LINTED */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * A sync has completed OK to a volume not belonging to a group.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Set the state of the ndr_ii config entry to "update".
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortevoid
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortesync_complete(char *master)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte CFGFILE *cfg = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char buf[CFG_MAX_BUF];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char key[CFG_MAX_KEY];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int i;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int setnumber;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int sev;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte LOCKCFG();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((cfg = cfg_open(NULL)) == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte spcs_log("sndr", NULL,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("%s: error opening config"),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte program);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdc_warn(NULL, gettext("error opening config"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte UNLOCKCFG();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!cfg_lock(cfg, CFG_WRLOCK)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte spcs_log("sndr", NULL,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("%s: error locking config"),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte program);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdc_warn(NULL, gettext("error locking config"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cfg_close(cfg);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte UNLOCKCFG();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* get ndr_ii entries until a match is found */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (i = 0; ; i++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte setnumber = i + 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) snprintf(key, sizeof (key), "ndr_ii.set%d.secondary",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte setnumber);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (cfg_get_cstring(cfg, key, buf, CFG_MAX_BUF) < 0)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (strcmp(buf, master) != 0)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte continue;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Found the matching entry */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Set state to "update" so that starting another sync will
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * cause a new Point-in-Time Copy snapshot to be taken.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) snprintf(key, sizeof (key), "ndr_ii.set%d.state",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte setnumber);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((cfg_put_cstring(cfg, key, UPDATE, strlen(UPDATE)) < 0) ||
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (cfg_commit(cfg) < 0)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte spcs_log("sndr", NULL,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("%s: unable to update \"%s\" "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "in configuration storage: %s"),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte program, buf, cfg_error(&sev));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdc_warn(NULL,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("unable to update \"%s\" "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "in configuration storage: %s"),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte buf, cfg_error(&sev));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cfg_close(cfg);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte UNLOCKCFG();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Starting a sync to the specified master volume.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Check the ndr_ii config entries to see if a Point-in-Time Copy
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * snapshot should be taken.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortevoid
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortesync_start(char *master)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char cmd[256];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char buf[CFG_MAX_BUF];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char key[CFG_MAX_KEY];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte CFGFILE *cfg = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int i;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int setnumber;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int found;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int sev;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char shadow[NSC_MAXPATH];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char bitmap[NSC_MAXPATH];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char *ctag = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte LOCKCFG();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((cfg = cfg_open(NULL)) == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte spcs_log("sndr", NULL,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("%s: error opening config"),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte program);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdc_warn(NULL,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("error opening config"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte UNLOCKCFG();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!cfg_lock(cfg, CFG_RDLOCK)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte spcs_log("sndr", NULL,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("%s: error locking config"),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte program);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdc_warn(NULL, gettext("error locking config"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cfg_close(cfg);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte UNLOCKCFG();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte found = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* get ndr_ii entries until a match is found */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (i = 0; ; i++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte setnumber = i + 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) snprintf(key, sizeof (key), "ndr_ii.set%d.secondary",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte setnumber);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (cfg_get_cstring(cfg, key, buf, CFG_MAX_BUF) < 0)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (strcmp(buf, master) != 0)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte continue;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Got a matching entry */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) snprintf(key, sizeof (key), "ndr_ii.set%d.shadow",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte setnumber);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (cfg_get_cstring(cfg, key, buf, CFG_MAX_BUF) < 0)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki (void) strncpy(shadow, buf, NSC_MAXPATH);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) snprintf(key, sizeof (key), "ndr_ii.set%d.bitmap",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte setnumber);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (cfg_get_cstring(cfg, key, buf, CFG_MAX_BUF) < 0)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki (void) strncpy(bitmap, buf, NSC_MAXPATH);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) snprintf(key, sizeof (key), "ndr_ii.set%d.state",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte setnumber);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (cfg_get_cstring(cfg, key, buf, CFG_MAX_BUF) < 0)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * If an PIT snapshot has already been taken, and syncing did
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * not complete, the state will be "noupdate", to indicate we
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * should not take another one at this point.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (strcmp(buf, NOUPDATE) != 0)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte found = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!found) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cfg_close(cfg);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte UNLOCKCFG();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte found = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* get ii entries until a match is found */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (i = 0; ; i++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte setnumber = i + 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) snprintf(key, sizeof (key), "ii.set%d.shadow",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte setnumber);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (cfg_get_cstring(cfg, key, buf, CFG_MAX_BUF) < 0)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (strcmp(buf, shadow) != 0)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte continue;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Matching shadow found, so ii already enabled */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte found = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (found) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Already PIT enabled, so just take a snapshot */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Get cluster tag of matching entry */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) snprintf(key, sizeof (key), "ii.set%d.cnode", setnumber);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (cfg_get_cstring(cfg, key, buf, CFG_MAX_BUF) >= 0)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((strlen(buf) == 0) || (buf[0] == '-'))
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ctag = "-C local";
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte else
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ctag = "";
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) sprintf(cmd, "%s %s -u s %s", IIADM, ctag, shadow);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * If clustered, need to enable PIT Copy sets in the same
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * cluster as the Remote Mirror set
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (clustered) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Find a RM set with master as the local volume */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (i = 0; i < rdc_maxsets; i++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte setnumber = i + 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) snprintf(key, sizeof (key),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "sndr.set%d.phost", setnumber);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (cfg_get_cstring(cfg, key, buf,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte CFG_MAX_BUF) < 0)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (self_check(buf))
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) snprintf(key, sizeof (key),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "sndr.set%d.primary", setnumber);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte else
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) snprintf(key, sizeof (key),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "sndr.set%d.secondary", setnumber);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (cfg_get_cstring(cfg, key, buf,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte CFG_MAX_BUF) < 0)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (strcmp(buf, master) != 0)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte continue;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Get cluster tag of matching entry */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) snprintf(key, sizeof (key),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "sndr.set%d.cnode", setnumber);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (cfg_get_cstring(cfg, key, buf,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte CFG_MAX_BUF) < 0)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((strlen(buf) == 0) || (buf[0] == '-'))
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ctag = strdup("local");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte else
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ctag = strdup(buf);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Not already enabled, so enable a dependent */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ctag) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) sprintf(cmd, "%s -C %s -e dep %s %s %s", IIADM,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ctag, master, shadow, bitmap);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte free(ctag);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) sprintf(cmd, "%s -e dep %s %s %s", IIADM, master,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte shadow, bitmap);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cfg_close(cfg);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (system(cmd) != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte spcs_log("sndr", NULL,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("Point-in-Time Copy snapshot failed for %s %s %s."
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte " Please check validity of ndr_ii entry"),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte master, shadow, bitmap);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cfg_close(cfg);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte UNLOCKCFG();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * PIT Copy enable or update was fine, so update the ndr_ii entry
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * to "noupdate", to prevent invalid point in time copies.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((cfg = cfg_open(NULL)) == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte spcs_log("sndr", NULL,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("%s: error opening config"),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte program);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdc_warn(NULL,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("error opening config"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte UNLOCKCFG();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!cfg_lock(cfg, CFG_WRLOCK)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte spcs_log("sndr", NULL,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("%s: error locking config"),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte program);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdc_warn(NULL, gettext("error locking config"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cfg_close(cfg);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte UNLOCKCFG();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* get ndr_ii entries until a match is found */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (i = 0; ; i++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte setnumber = i + 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) snprintf(key, sizeof (key), "ndr_ii.set%d.shadow",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte setnumber);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (cfg_get_cstring(cfg, key, buf, CFG_MAX_BUF) < 0)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (strcmp(buf, shadow) != 0)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte continue;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Found the matching entry */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) snprintf(key, sizeof (key), "ndr_ii.set%d.state",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte setnumber);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((cfg_put_cstring(cfg, key, NOUPDATE,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte strlen(NOUPDATE)) < 0) || (cfg_commit(cfg) < 0)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte spcs_log("sndr", NULL,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("%s: unable to update \"%s\" "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "in configuration storage: %s"),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte program, buf, cfg_error(&sev));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdc_warn(NULL,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("unable to update \"%s\" "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "in configuration storage: %s"),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte buf, cfg_error(&sev));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cfg_close(cfg);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte UNLOCKCFG();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortevoid
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortecleanup_hostlist(rdc_status_t *rdc_info)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int i, j, k;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char *host, *exhost;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) mutex_lock(&host_list->hosts_mutex);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (i = 0; i < host_list->numhosts; i++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int found = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (j = 0; (j < rdc_maxsets) && !found; j++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!rdc_info->rdc_set[j].flags & RDC_ENABLED)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte continue;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((!host_list->configured[i]) ||
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (host_list->hosts[i] == '\0')) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) mutex_unlock(&host_list->hosts_mutex);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte host = rdc_info->rdc_set[j].secondary.intf;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (strcmp(host_list->hosts[i], host) == 0)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte found++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (j == rdc_maxsets) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * this set is not in the kernel, so remove from list
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte exhost = host_list->hosts[i];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (exhost) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte free(exhost);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte exhost = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte k = i;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while (k < host_list->numhosts) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte host_list->hosts[k] = k < host_list->numhosts - 1 ?
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte host_list->hosts[k+1] : NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte k++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte host_list->numhosts--;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bcopy(&host_list->configured[i+1],
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte &host_list->configured[i],
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (MAXHOSTS - i + 1) * sizeof (int));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte host_list->configured[MAXHOSTS - 1] = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) mutex_unlock(&host_list->hosts_mutex);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * explicity remove a host from the host list
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * also update the configured array
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * called in rdc_sync, just before exiting a thread.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortevoid
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteremove_from_hostlist(char *host)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int i, k;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char *exhost;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* why bother? */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((!host) || (host[0] == '\0'))
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) mutex_lock(&host_list->hosts_mutex);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (i = 0; i < host_list->numhosts; i++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (strcmp(host, host_list->hosts[i]) == 0) { /* found it */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte exhost = host_list->hosts[i];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (exhost) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte free(exhost);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte exhost = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte k = i;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while (k < host_list->numhosts) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte host_list->hosts[k] = k < host_list->numhosts - 1 ?
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte host_list->hosts[k+1] : NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte k++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte host_list->numhosts--;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bcopy(&host_list->configured[i+1],
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte &host_list->configured[i],
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (MAXHOSTS - i + 1) * sizeof (int));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte host_list->configured[MAXHOSTS - 1] = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) mutex_unlock(&host_list->hosts_mutex);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Check to see if this host isn't in our list, so needs a new rdcsyncd proc
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteisnewhost(char *host)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int i;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int new;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (self_check(host)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) mutex_lock(&host_list->hosts_mutex);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte new = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (i = 0; i < MAXHOSTS; i++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (host_list->configured[i] == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte host_list->configured[i] = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte host_list->hosts[i] = strdup(host);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte host_list->numhosts++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (strcmp(host, host_list->hosts[i]) == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte new = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) mutex_unlock(&host_list->hosts_mutex);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (i == MAXHOSTS)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte new = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (new);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Look for a matching volume name in our remembered list.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortevolume_match(char *buf, char **volume_list, int volumes)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int i;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char *vol;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (i = 0; i < volumes; i++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte vol = volume_list[i];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (strcmp(buf, vol) == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * A sync has completed to a group. We can only update the ndr_ii entries
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * if all the members of the group have completed their syncs OK.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * It would be bad to allow some members of the group to have PIT Copy snapshots
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * taken and others not, as they need to be consistent.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortevoid
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortegroup_complete(char *group)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char **volumes = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte spcs_s_info_t ustatus;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdc_config_t parms = { 0 };
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char buf[CFG_MAX_BUF];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char key[CFG_MAX_KEY];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte CFGFILE *cfg = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int i;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int setnumber;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int found;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int replicating = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char primary[NSC_MAXPATH];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char secondary[NSC_MAXPATH];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char phost[MAX_RDC_HOST_SIZE];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char shost[MAX_RDC_HOST_SIZE];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdc_set_t *rdc_set;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int sev;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char *local_file;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int size;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ustatus = spcs_s_ucreate();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte size = sizeof (char *) * rdc_maxsets;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte volumes = malloc(size);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (volumes == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte spcs_log("sndr", NULL,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("%s: unable to allocate %ld bytes"),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte program, size);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdc_warn(NULL,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("unable to allocate %ld bytes"), size);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte goto done;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bzero(volumes, size);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * If all members of this group are replicating
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * set ii_ndr state to "update". Otherwise leave them alone.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte LOCKCFG();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((cfg = cfg_open(NULL)) == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte spcs_log("sndr", NULL,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("%s: error opening lconfig"),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte program);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdc_warn(NULL, gettext("error opening config"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte UNLOCKCFG();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte goto done;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!cfg_lock(cfg, CFG_RDLOCK)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte spcs_log("sndr", NULL,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("%s: error locking config"),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte program);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdc_warn(NULL, gettext("error locking config"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte goto done;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte found = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* get all RM entries, with a matching group, that are replicating */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (i = 0; i < rdc_maxsets; i++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte setnumber = i + 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) snprintf(key, sizeof (key),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "sndr.set%d.group", setnumber);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (cfg_get_cstring(cfg, key, buf, CFG_MAX_BUF) < 0)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (strcmp(buf, group) != 0)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte continue;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Found a matching entry */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) snprintf(key, sizeof (key),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "sndr.set%d.primary", setnumber);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (cfg_get_cstring(cfg, key, primary, sizeof (primary)) < 0)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki (void) strcpy(parms.rdc_set->primary.file, primary);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) snprintf(key, sizeof (key),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "sndr.set%d.phost", setnumber);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (cfg_get_cstring(cfg, key, phost, sizeof (phost)) < 0)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki (void) strcpy(parms.rdc_set->primary.intf, phost);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) snprintf(key, sizeof (key),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "sndr.set%d.secondary", setnumber);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (cfg_get_cstring(cfg, key, secondary,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sizeof (secondary)) < 0)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki (void) strcpy(parms.rdc_set->secondary.file, secondary);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) snprintf(key, sizeof (key),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "sndr.set%d.shost", setnumber);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (cfg_get_cstring(cfg, key, shost, sizeof (shost)) < 0)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki (void) strcpy(parms.rdc_set->secondary.intf, shost);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte parms.command = RDC_CMD_STATUS;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (RDC_IOCTL(RDC_CONFIG, &parms, NULL, 0, 0, 0, ustatus) < 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte continue;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* We found a matching set */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte found++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (self_check(phost))
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte local_file = primary;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte else
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte local_file = secondary;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdc_set = &parms.rdc_set[0];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!(rdc_set->flags & RDC_LOGGING) &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte !(rdc_set->flags & RDC_SYNCING)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte volumes[replicating] = strdup(local_file);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (volumes[replicating] == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte size = strlen(local_file);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte spcs_log("sndr", NULL,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("%s: unable to allocate %ld bytes"),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte program, size);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdc_warn(NULL,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("unable to allocate %ld bytes"),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte size);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte goto done;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* We remember all replicating sets */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte replicating++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break; /* Not all replicating, so done */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (found != replicating)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte goto done;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* All replicating, so update ndr_ii state fields */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cfg_unlock(cfg);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!cfg_lock(cfg, CFG_WRLOCK)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte spcs_log("sndr", NULL,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("%s: error locking lconfig"),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte program);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdc_warn(NULL, gettext("error locking config"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte goto done;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Search through the ndr_ii entries for entries
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * that match the saved secondary volume names.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Set state to "update".
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (i = 0; ; i++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte setnumber = i + 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) snprintf(key, sizeof (key), "ndr_ii.set%d.secondary",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte setnumber);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (cfg_get_cstring(cfg, key, buf, CFG_MAX_BUF) < 0)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!volume_match(buf, volumes, found)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte continue;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Got a matching entry */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) snprintf(key, sizeof (key),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "ndr_ii.set%d.state", setnumber);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((cfg_put_cstring(cfg, key, UPDATE, strlen(UPDATE)) < 0) ||
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (cfg_commit(cfg) < 0)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte spcs_log("sndr", NULL,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("%s: unable to update \"%s\" "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "in configuration storage: %s"),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte program, buf, cfg_error(&sev));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdc_warn(NULL,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("unable to update \"%s\" "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "in configuration storage: %s"),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte buf, cfg_error(&sev));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortedone:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (cfg) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cfg_close(cfg);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte UNLOCKCFG();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte spcs_s_ufree(&ustatus);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (volumes) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (i = 0; i < replicating; i++)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte free(volumes[i]);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte free(volumes);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Sync started to a member of a group.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * If all members of the group are in ndr_ii state "update" then take an PIT
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * snapshot on all of them. This will provide a consistent point-in-time
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * copy until whatever syncs take place are all completed.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortevoid
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortegroup_start(char *group)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char **masters = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char **shadows = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char **bitmaps = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char cmd[256];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char buf[CFG_MAX_BUF];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char key[CFG_MAX_KEY];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte CFGFILE *cfg = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int i;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int j;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int setnumber;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int found;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int sndr_sets = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int update_needed = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int sev;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char *ctag = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int commit = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int size;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte size = sizeof (char *) * rdc_maxsets;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte masters = malloc(size);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (masters == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte spcs_log("sndr", NULL,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("%s: unable to allocate %ld bytes"),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte program, size);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdc_warn(NULL,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("unable to allocate %ld bytes"), size);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte goto done;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bzero(masters, size);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte shadows = malloc(size);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (shadows == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte spcs_log("sndr", NULL,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("%s: unable to allocate %ld bytes"),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte program, size);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdc_warn(NULL,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("unable to allocate %ld bytes"), size);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte goto done;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bzero(shadows, size);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bitmaps = malloc(size);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (bitmaps == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte spcs_log("sndr", NULL,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("%s: unable to allocate %ld bytes"),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte program, size);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdc_warn(NULL,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("unable to allocate %ld bytes"), size);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte goto done;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bzero(bitmaps, size);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte LOCKCFG();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((cfg = cfg_open(NULL)) == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte spcs_log("sndr", NULL,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("%s: error opening config"),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte program);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdc_warn(NULL,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("error opening config"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte UNLOCKCFG();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte goto done;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!cfg_lock(cfg, CFG_WRLOCK)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte spcs_log("sndr", NULL,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("%s: error locking config"),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte program);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdc_warn(NULL, gettext("error locking config"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte goto done;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Now get all Remote Mirror entries with a matching group */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (i = 0; i < rdc_maxsets; i++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte setnumber = i + 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) snprintf(key, sizeof (key),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "sndr.set%d.group", setnumber);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (cfg_get_cstring(cfg, key, buf, CFG_MAX_BUF) < 0)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (strcmp(buf, group) != 0)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte continue;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Found a matching entry */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) snprintf(key, sizeof (key),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "sndr.set%d.phost", setnumber);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (cfg_get_cstring(cfg, key, buf, sizeof (buf)) < 0)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (self_check(buf)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) snprintf(key, sizeof (key), "sndr.set%d.primary",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte setnumber);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) snprintf(key, sizeof (key),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "sndr.set%d.secondary", setnumber);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (cfg_get_cstring(cfg, key, buf, sizeof (buf)) < 0)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte masters[sndr_sets] = strdup(buf);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (masters[sndr_sets] == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte size = strlen(buf);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte spcs_log("sndr", NULL,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("%s: unable to allocate %ld bytes"),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte program, size);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdc_warn(NULL,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("unable to allocate %ld bytes"), size);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte goto done;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sndr_sets++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ctag == NULL && clustered) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Get cluster tag of matching entry */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) snprintf(key, sizeof (key), "sndr.set%d.cnode",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte setnumber);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (cfg_get_cstring(cfg, key, buf, CFG_MAX_BUF) >= 0)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ctag = strdup(buf);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Search through the ndr_ii entries for entries
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * that match the saved local volume names and are in "update" state.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte update_needed = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (i = 0; ; i++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte setnumber = i + 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) snprintf(key, sizeof (key), "ndr_ii.set%d.secondary",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte setnumber);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (cfg_get_cstring(cfg, key, buf, CFG_MAX_BUF) < 0)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!volume_match(buf, masters, sndr_sets))
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte continue;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Got a matching entry */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) snprintf(key, sizeof (key), "ndr_ii.set%d.shadow",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte setnumber);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (cfg_get_cstring(cfg, key, buf, CFG_MAX_BUF) < 0)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte shadows[update_needed] = strdup(buf);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (shadows[update_needed] == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte size = strlen(buf);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte spcs_log("sndr", NULL,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("%s: unable to allocate %ld bytes"),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte program, size);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdc_warn(NULL,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("unable to allocate %ld bytes"), size);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte goto done;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) snprintf(key, sizeof (key), "ndr_ii.set%d.bitmap",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte setnumber);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (cfg_get_cstring(cfg, key, buf, CFG_MAX_BUF) < 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bitmaps[update_needed] = strdup(buf);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (bitmaps[update_needed] == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte size = strlen(buf);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte spcs_log("sndr", NULL,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("%s: unable to allocate %ld bytes"),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte program, size);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdc_warn(NULL,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("unable to allocate %ld bytes"), size);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte goto done;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) snprintf(key, sizeof (key), "ndr_ii.set%d.state",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte setnumber);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (cfg_get_cstring(cfg, key, buf, CFG_MAX_BUF) < 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (strcmp(buf, UPDATE) != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte update_needed++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (update_needed != sndr_sets) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#ifdef DEBUG
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte spcs_log("sndr", NULL,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("%s: group sync: no Point-in-Time Copy snapshot "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "for %s"), program, group);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte goto done;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* All RM sets in the group have an ndr_ii entry in "update" state */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Issue PIT Copy snapshot commands for all sets in the group */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (j = 0; j < sndr_sets; j++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte found = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* get ii entries until a match is found */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (i = 0; ; i++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte setnumber = i + 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) snprintf(key, sizeof (key), "ii.set%d.shadow",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte setnumber);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (cfg_get_cstring(cfg, key, buf, CFG_MAX_BUF) < 0)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (strcmp(buf, shadows[j]) != 0)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte continue;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Matching shadow found, so ii already enabled */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte found = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (commit)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (cfg_commit(cfg) < 0)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdc_warn(NULL, gettext("commit config error"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cfg_close(cfg);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (found) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) sprintf(cmd, "%s -u s %s", IIADM, shadows[j]);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ctag) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) sprintf(cmd, "%s -C %s -e dep %s %s %s",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte IIADM, ctag, masters[j], shadows[j],
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bitmaps[j]);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte free(ctag);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ctag = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) sprintf(cmd, "%s -e dep %s %s %s", IIADM,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte masters[j], shadows[j], bitmaps[j]);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (system(cmd) != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte spcs_log("sndr", NULL,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("%s: group sync: Point-in-Time Copy"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte " snapshot failed for %s"),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte program, masters[j]);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte goto done;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((cfg = cfg_open(NULL)) == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte spcs_log("sndr", NULL,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("%s: error opening config"),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte program);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdc_warn(NULL,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("error opening config"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte goto done;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!cfg_lock(cfg, CFG_WRLOCK)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte spcs_log("sndr", NULL,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("%s: error locking config"),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte program);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdc_warn(NULL, gettext("error locking config"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte goto done;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte commit = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* PIT enable or update was fine, so update the ndr_ii entry */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* get ndr_ii entries until a match is found */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (i = 0; ; i++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte setnumber = i + 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) snprintf(key, sizeof (key),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "ndr_ii.set%d.shadow", setnumber);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (cfg_get_cstring(cfg, key, buf, CFG_MAX_BUF) < 0)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (strcmp(buf, shadows[j]) != 0)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte continue;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Found the matching entry */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) snprintf(key, sizeof (key), "ndr_ii.set%d.state",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte setnumber);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (cfg_put_cstring(cfg, key, NOUPDATE,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte strlen(NOUPDATE)) < 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte spcs_log("sndr", NULL,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("%s: unable to update \"%s\" "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "in configuration storage: %s"),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte program, buf, cfg_error(&sev));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdc_warn(NULL,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("unable to update \"%s\" "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "in configuration storage: %s"),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte buf, cfg_error(&sev));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte commit = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (commit)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (cfg_commit(cfg) < 0)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdc_warn(NULL, gettext("commit config error"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte spcs_log("sndr", NULL,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("%s: group sync: Point-in-Time Copy snapshots completed "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "for %s"), program, group);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortedone:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ctag)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte free(ctag);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (cfg) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cfg_close(cfg);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte UNLOCKCFG();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (masters) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (i = 0; i < sndr_sets; i++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (masters[i])
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte free(masters[i]);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte free(masters);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (shadows) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (i = 0; i < update_needed; i++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (shadows[i])
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte free(shadows[i]);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte free(shadows);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (bitmaps) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (i = 0; i < update_needed; i++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (bitmaps[i])
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte free(bitmaps[i]);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte free(bitmaps);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}