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
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Use is subject to license terms.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * bitmap_in_use
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * return 1 if in use
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * return 0 if not in use
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * return -1 on error
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char sbm[CFG_MAX_BUF]; /* rdc secondary bitmap */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (-1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (-1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * look into II config to see if this is being used elsewhere
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (i = 0; ; i++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte snprintf(key, sizeof (key), "ii.set%d", setnumber);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (cfg_get_cstring(cfg, key, buf, CFG_MAX_BUF) < 0)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rc = sscanf(buf, "%s %s %s %s %s", mas, sha, bit, mod, ovr);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * got master shadow bitmap, now compare
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "bitmap %s is in use by"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * and last but not least, make sure sndr is not using vol for anything
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (i = 0; ; i++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte snprintf(key, sizeof (key), "sndr.set%d", setnumber);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (cfg_get_cstring(cfg, key, buf, CFG_MAX_BUF) < 0)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * I think this is quicker than
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * having to double dip into the config
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) sscanf(buf, "%s %s %s %s %s %s", host, pri, bit,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "bitmap %s is in use by %s"),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "bitmap %s is in use by %s"),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * read this logic 1000 times and consider
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * multi homed, one to many, many to one (marketing)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * etc, etc, before changing
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte " %s is in use by %s"),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte " %s is in use by %s"),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else { /* self_check(hostp) failed */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte " %s is in use by %s"),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte " %s is in use by %s"),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * check where this disk service is mastered
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "disk service, %s: %s"), dgname, strerror(errno));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (-1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (rc == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "active on node \"%s\"\nPlease re-issue "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (-1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char fromname[MAXHOSTNAMELEN], toname[MAXHOSTNAMELEN];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Check for the special (local) cluster tag
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ctag != NULL && strcmp(rdc->ctag, RDC_LOCAL_TAG) == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!self_check(fromname) && !self_check(toname)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * If we could get a list of logical hosts on this cluster
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * then we could print something intelligent about where
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * the volume is mastered. For now, just print some babble
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * about the fact that we have no idea.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (-1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * If implicit disk group name and no ctag specified by user,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * we set the ctag to it.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * If implicit disk group name, it must match any supplied ctag.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte file_dgname = cfg_dgname(localfile, file_buf, sizeof (file_buf));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (file_dgname != NULL && file_dgname[0] != '\0')
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* errors already set */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (-1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (strlen(ctag) == 0 && file_dgname && strlen(file_dgname))
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * making an exception here for users giving the "local"tag
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * this overrides this error message. (rdc_islocal ! = 1)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (strlen(ctag) != 0 && file_dgname && islocal != 1 &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte strncmp(ctag, file_dgname, MAX_RDC_HOST_SIZE) != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "match disk group name \"%s\" of volume %s"), ctag,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (-1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((file_dgname == NULL) || ((strlen(ctag) == 0) &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * we must have a non-volume managed disk here
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * so ask for a tag and get out
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte " of a disk group,\nplease specify resource ctag\n"),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Local bitmap must also have same ctag.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bmp_dgname = cfg_dgname(localfile, bmp_buf, sizeof (bmp_buf));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* error already set */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (-1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* File is in a real disk group */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((bmp_dgname == NULL) || (strlen(bmp_dgname) == 0)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Bitmap is not in a real disk group */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("bitmap %s is not in disk group \"%s\""),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (-1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (strlen(ctag) != 0 && bmp_dgname && islocal != 1 &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte strncmp(ctag, bmp_dgname, MAX_RDC_HOST_SIZE) != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "match disk group name \"%s\" of bitmap %s"),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (-1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (s = target; i < NSC_MAXPATH && (*s = *device++); i++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (*s == 'r' && rdsk == 0 && strncmp(device, "dsk/", 4) == 0)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Assume the worst, that it is mounted */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((rc = getmntany(mntfp, &mntent, &mntref)) != -1) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* found something before EOF */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte dgettext("librdc", "volumes and bitmaps must not match"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* rdc_error should already be set */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte dgettext("librdc", "%s is not a character device"),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte !bitmap_in_use(RDC_CMD_ENABLE, rdc->phost, rdc->pbmp) : 1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else { /* on the secondary */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte !bitmap_in_use(RDC_CMD_ENABLE, rdc->shost, rdc->sbmp) : 1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (!bitmap_in_use(RDC_CMD_RECONFIG, rdc->phost, bmp));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (!bitmap_in_use(RDC_CMD_RECONFIG, rdc->shost, bmp));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte strncpy(rc->set.phost, rdc->phost, MAX_RDC_HOST_SIZE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte strncpy(rc->set.shost, rdc->shost, MAX_RDC_HOST_SIZE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdc_set_error(NULL, RDC_INTERNAL, 0, "unable to sync %s volume"