fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * CDDL HEADER START
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 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * See the License for the specific language governing permissions
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * and limitations under the License.
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 * CDDL HEADER END
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Use is subject to license terms.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define UNLOCKCFG() (void) mutex_unlock(&cfglock);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern char *basename(char *);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("host list not initialized, cannot run"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdc_err(NULL, gettext("host list not initialized, cannot run"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) mutex_init(&host_list->hosts_mutex, USYNC_THREAD, NULL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* ARGSUSED */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* NOTREACHED */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("incorrect Solaris release (requires %s)\n"),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* NOTREACHED */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdc_err(NULL, gettext("unable to ascertain environment"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("%s: unable to get maxsets value from kernel"),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("unable to get maxsets value from kernel"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte size = sizeof (rdc_status_t) + (sizeof (rdc_set_t) * (rdc_maxsets - 1));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Fork off a child that becomes the daemon.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte else if (pid < 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * In child - become daemon.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (i = 0; i < 3; i++)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* launch a thread to wait for sync start and sync stop events */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((trc = thr_create(NULL, 0, wait_sync_event, NULL,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("%s: unable to create thread wait_sync_event"),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("%s unable to create thread wait_sync_event"),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("%s: thread wait_sync_event started"), program);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (RDC_IOCTL(RDC_STATUS, rdc_info, 0, 0, 0, 0, ustatus)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cleanup_hostlist(rdc_info); /* remove non-existent hosts */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Check all enabled sets to see if a new remote host has
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (i = 0; i < rdc_maxsets; i++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* spawn a new thread for each new host found */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (isnewhost(rdc_info->rdc_set[i].secondary.intf)) {
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 * this is a daemon, afterall. its got time
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "%s create new autosync "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "%s create new autosync "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* NOTREACHED */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * The kernel wakes up this function every time it detects the link to the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * specified host has dropped.
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki (void) strncpy(tmphost, host, MAX_RDC_HOST_SIZE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Never give up */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (RDC_IOCTL(RDC_LINK_DOWN, host, 0, 0, 0, 0, ustatus)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* LINTED */
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 * Get all sndr entries with shost matching tohost, and save the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * details in an array.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (i = 0; i < rdc_maxsets; i++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) snprintf(key, sizeof (key), "sndr.set%d.shost",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (cfg_get_cstring(cfg, key, buf, CFG_MAX_BUF) < 0) {
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki (void) strncpy(rdc_set[sets].secondary.intf, buf,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Got a matching entry */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) snprintf(key, sizeof (key), "sndr.set%d.phost",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (cfg_get_cstring(cfg, key, buf, CFG_MAX_BUF) < 0)
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki (void) strncpy(rdc_set[sets].primary.intf, buf,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) snprintf(key, sizeof (key), "sndr.set%d.primary",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (cfg_get_cstring(cfg, key, buf, CFG_MAX_BUF) < 0)
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki (void) strncpy(rdc_set[sets].primary.file, buf, NSC_MAXPATH);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) snprintf(key, sizeof (key), "sndr.set%d.secondary",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (cfg_get_cstring(cfg, key, buf, CFG_MAX_BUF) < 0)
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki (void) strncpy(rdc_set[sets].secondary.file, buf, NSC_MAXPATH);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bcopy((void *)(&rdc_set[sets]), (void *)(&parms.rdc_set[0]),
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 if (RDC_IOCTL(RDC_CONFIG, &parms, NULL, 0, 0, 0, ustatus) < 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Found a suitable set with autosync on, in logging mode */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("%s: no sets requiring autosync found for %s"),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Keep issuing rdcadm -u commands until they have all completed */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Issue rdcadm -u commands for all remaining sets */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (i = 0; i < sets; i++) {
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 (void *)(&parms.rdc_set[0]), sizeof (rdc_set_t));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "status not available for %s:%s, stopping "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte spcs_log("sndr", NULL, gettext("%s: autosync disabled during sleep, "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "stopping attempt for set %s:%s"), program, tohost,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) sprintf(cmd, "%s -un %s:%s", RDCADM, tohost,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Issue rdcadm -w commands to wait for updates to finish */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (i = 0; i < sets; i++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) sprintf(cmd, "%s -wn %s:%s", RDCADM, tohost,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void *)(&parms.rdc_set[0]), sizeof (rdc_set_t));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "%s:%s, stopping this autosync attempt"),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Check if completed OK, failed or autosync off */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break; /* All completed OK */
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 * Wait for notification by the kernel of a sync start or a sync completed OK
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Never give up */
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 * If target is mounted at the start of a sync or reverse sync,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * return a negative ack.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((state == RDC_SYNC_START || state == RDC_RSYNC_START) &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* LINTED */
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 /* get ndr_ii entries until a match is found */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (i = 0; ; i++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) snprintf(key, sizeof (key), "ndr_ii.set%d.secondary",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (cfg_get_cstring(cfg, key, buf, CFG_MAX_BUF) < 0)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Found the matching entry */
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 (void) snprintf(key, sizeof (key), "ndr_ii.set%d.state",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((cfg_put_cstring(cfg, key, UPDATE, strlen(UPDATE)) < 0) ||
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "in configuration storage: %s"),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "in configuration storage: %s"),
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 /* get ndr_ii entries until a match is found */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (i = 0; ; i++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) snprintf(key, sizeof (key), "ndr_ii.set%d.secondary",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (cfg_get_cstring(cfg, key, buf, CFG_MAX_BUF) < 0)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Got a matching entry */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) snprintf(key, sizeof (key), "ndr_ii.set%d.shadow",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (cfg_get_cstring(cfg, key, buf, CFG_MAX_BUF) < 0)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) snprintf(key, sizeof (key), "ndr_ii.set%d.bitmap",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (cfg_get_cstring(cfg, key, buf, CFG_MAX_BUF) < 0)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) snprintf(key, sizeof (key), "ndr_ii.set%d.state",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (cfg_get_cstring(cfg, key, buf, CFG_MAX_BUF) < 0)
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 /* get ii entries until a match is found */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (i = 0; ; i++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) snprintf(key, sizeof (key), "ii.set%d.shadow",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (cfg_get_cstring(cfg, key, buf, CFG_MAX_BUF) < 0)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Matching shadow found, so ii already enabled */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Already PIT enabled, so just take a snapshot */
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 (void) sprintf(cmd, "%s %s -u s %s", IIADM, ctag, shadow);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * If clustered, need to enable PIT Copy sets in the same
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * cluster as the Remote Mirror set
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Find a RM set with master as the local volume */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (i = 0; i < rdc_maxsets; i++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Get cluster tag of matching entry */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Not already enabled, so enable a dependent */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) sprintf(cmd, "%s -C %s -e dep %s %s %s", IIADM,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) sprintf(cmd, "%s -e dep %s %s %s", IIADM, master,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("Point-in-Time Copy snapshot failed for %s %s %s."
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte " Please check validity of ndr_ii entry"),
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 /* get ndr_ii entries until a match is found */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (i = 0; ; i++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) snprintf(key, sizeof (key), "ndr_ii.set%d.shadow",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (cfg_get_cstring(cfg, key, buf, CFG_MAX_BUF) < 0)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Found the matching entry */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) snprintf(key, sizeof (key), "ndr_ii.set%d.state",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte strlen(NOUPDATE)) < 0) || (cfg_commit(cfg) < 0)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "in configuration storage: %s"),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "in configuration storage: %s"),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int i, j, k;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * this set is not in the kernel, so remove from list
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte host_list->hosts[k] = k < host_list->numhosts - 1 ?
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 /* why bother? */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (strcmp(host, host_list->hosts[i]) == 0) { /* found it */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte host_list->hosts[k] = k < host_list->numhosts - 1 ?
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Check to see if this host isn't in our list, so needs a new rdcsyncd proc
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (i = 0; i < MAXHOSTS; i++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Look for a matching volume name in our remembered list.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortevolume_match(char *buf, char **volume_list, int volumes)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (i = 0; i < volumes; i++) {
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 * If all members of this group are replicating
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * set ii_ndr state to "update". Otherwise leave them alone.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* get all RM entries, with a matching group, that are replicating */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (i = 0; i < rdc_maxsets; i++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (cfg_get_cstring(cfg, key, buf, CFG_MAX_BUF) < 0)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Found a matching entry */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (cfg_get_cstring(cfg, key, primary, sizeof (primary)) < 0)
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki (void) strcpy(parms.rdc_set->primary.file, primary);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (cfg_get_cstring(cfg, key, phost, sizeof (phost)) < 0)
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki (void) strcpy(parms.rdc_set->primary.intf, phost);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sizeof (secondary)) < 0)
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki (void) strcpy(parms.rdc_set->secondary.file, secondary);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (cfg_get_cstring(cfg, key, shost, sizeof (shost)) < 0)
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki (void) strcpy(parms.rdc_set->secondary.intf, shost);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (RDC_IOCTL(RDC_CONFIG, &parms, NULL, 0, 0, 0, ustatus) < 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* We found a matching set */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* We remember all replicating sets */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break; /* Not all replicating, so done */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* All replicating, so update ndr_ii state fields */
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 for (i = 0; ; i++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) snprintf(key, sizeof (key), "ndr_ii.set%d.secondary",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (cfg_get_cstring(cfg, key, buf, CFG_MAX_BUF) < 0)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Got a matching entry */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((cfg_put_cstring(cfg, key, UPDATE, strlen(UPDATE)) < 0) ||
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "in configuration storage: %s"),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "in configuration storage: %s"),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (i = 0; i < replicating; i++)
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 /* Now get all Remote Mirror entries with a matching group */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (i = 0; i < rdc_maxsets; i++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (cfg_get_cstring(cfg, key, buf, CFG_MAX_BUF) < 0)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Found a matching entry */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (cfg_get_cstring(cfg, key, buf, sizeof (buf)) < 0)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) snprintf(key, sizeof (key), "sndr.set%d.primary",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (cfg_get_cstring(cfg, key, buf, sizeof (buf)) < 0)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Get cluster tag of matching entry */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) snprintf(key, sizeof (key), "sndr.set%d.cnode",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (cfg_get_cstring(cfg, key, buf, CFG_MAX_BUF) >= 0)
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 for (i = 0; ; i++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) snprintf(key, sizeof (key), "ndr_ii.set%d.secondary",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (cfg_get_cstring(cfg, key, buf, CFG_MAX_BUF) < 0)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Got a matching entry */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) snprintf(key, sizeof (key), "ndr_ii.set%d.shadow",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (cfg_get_cstring(cfg, key, buf, CFG_MAX_BUF) < 0)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) snprintf(key, sizeof (key), "ndr_ii.set%d.bitmap",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (cfg_get_cstring(cfg, key, buf, CFG_MAX_BUF) < 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) snprintf(key, sizeof (key), "ndr_ii.set%d.state",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (cfg_get_cstring(cfg, key, buf, CFG_MAX_BUF) < 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("%s: group sync: no Point-in-Time Copy snapshot "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* All RM sets in the group have an ndr_ii entry in "update" state */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Issue PIT Copy snapshot commands for all sets in the group */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (j = 0; j < sndr_sets; j++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* get ii entries until a match is found */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (i = 0; ; i++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) snprintf(key, sizeof (key), "ii.set%d.shadow",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (cfg_get_cstring(cfg, key, buf, CFG_MAX_BUF) < 0)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Matching shadow found, so ii already enabled */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) sprintf(cmd, "%s -u s %s", IIADM, shadows[j]);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte " snapshot failed for %s"),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* PIT enable or update was fine, so update the ndr_ii entry */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* get ndr_ii entries until a match is found */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (i = 0; ; i++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (cfg_get_cstring(cfg, key, buf, CFG_MAX_BUF) < 0)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Found the matching entry */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) snprintf(key, sizeof (key), "ndr_ii.set%d.state",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "in configuration storage: %s"),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "in configuration storage: %s"),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("%s: group sync: Point-in-Time Copy snapshots completed "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (i = 0; i < sndr_sets; i++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (i = 0; i < update_needed; i++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (i = 0; i < update_needed; i++) {