Change the naming scheme for the snapshot sibling object. Base it on the parent object name, since the child object could be renamed without us knowing about it. Apply with: cd /usr/src/evms-2.2.0 patch -p1 < snapshot.patch --- evms-2.2.0a/plugins/snapshot/snap_create.c 15 Oct 2003 16:24:39 -0000 +++ evms-2.2.0b/plugins/snapshot/snap_create.c 5 Dec 2003 21:49:28 -0000 @@ -128,6 +128,44 @@ } /** + * check_sibling_state + * + * This check was added when the naming-scheme for the snapshot sibling was + * changed. If anyone had an active snapshot at the time they upgraded their + * version of EVMS to this new scheme, some naming problems would arise, and + * at the very least create an orphaned kernel device. This check attempts to + * remedy this situation by trying to rename from the old naming scheme to + * the new one. + **/ +static void check_sibling_state(snapshot_volume_t * snap_volume) +{ + char old_name[EVMS_NAME_SIZE]; + int rc; + + LOG_ENTRY(); + + if (!(snap_volume->sibling->flags & SOFLAG_ACTIVE)) { + strncpy(old_name, snap_volume->child->name, EVMS_NAME_SIZE); + strncat(old_name, "#snap#", EVMS_NAME_SIZE-strlen(old_name)); + + /* Lie about the active bit to fool dm_rename. The subsequent + * call to dm_update_status will correct it if necessary. + */ + snap_volume->sibling->flags |= SOFLAG_ACTIVE; + + rc = EngFncs->dm_rename(snap_volume->sibling, old_name, + snap_volume->sibling->name); + if (rc) { + LOG_ERROR("Unable to rename sibling for snapshot %s\n", + snap_volume->parent->name); + } + EngFncs->dm_update_status(snap_volume->sibling); + } + + LOG_EXIT_VOID(); +} + +/** * get_snapshot_state * * Get Device-Mapper's state for this snapshot. If the device is active, @@ -149,6 +187,8 @@ } if (is_active(snap_volume)) { + check_sibling_state(snap_volume); + rc = EngFncs->dm_get_info(snap_parent, &info); if (!rc) { if (sscanf(info, "%"SCNu64"/%"SCNu64, @@ -317,8 +357,8 @@ snap_sibling->plugin = my_plugin_record; snap_sibling->size = snap_child->feature_header->feature_data1_start_lsn; snap_sibling->disk_group = snap_parent->disk_group; - strncpy(snap_sibling->name, snap_child->name, EVMS_NAME_SIZE); - strncat(snap_sibling->name, "#snap#", + strncpy(snap_sibling->name, name, EVMS_NAME_SIZE); + strncat(snap_sibling->name, "#sibling#", EVMS_NAME_SIZE-strlen(snap_sibling->name)); out: