Instead of segtype->ops->name() introduce lvseg_name().
This also allows us to leave name() function 'empty' for default
return of segtype->name.
TODO: add functions for rest of ops->
Version 2.02.112 -
=====================================
+ Add internal lvseg_name() function.
Skip trying to file lock virtual internal vg name.
Fix selection on {vg,lv}_permissions fields to properly match selection criteria.
Fix lv_permissions reporting to display read-only{-override} instead of blank.
lv_is_virtual(lv) ? "Virtual" : "Logical",
seg->le, seg->le + seg->len - 1);
- log_print(" Type\t\t%s", seg->segtype->ops->name(seg));
+ log_print(" Type\t\t%s", lvseg_name(seg));
if (seg->segtype->ops->target_monitored)
log_print(" Monitoring\t\t%s",
char *lvseg_segtype_dup(struct dm_pool *mem, const struct lv_segment *seg)
{
- return dm_pool_strdup(mem, seg->segtype->ops->name(seg));
+ return dm_pool_strdup(mem, lvseg_name(seg));
}
char *lvseg_discards_dup(struct dm_pool *mem, const struct lv_segment *seg)
return size;
}
+const char *lvseg_name(const struct lv_segment *seg)
+{
+ /* Support even segtypes without 'ops' */
+ if (seg->segtype->ops &&
+ seg->segtype->ops->name)
+ return seg->segtype->ops->name(seg);
+
+ return seg->segtype->name;
+}
+
uint64_t lvseg_start(const struct lv_segment *seg)
{
return (uint64_t) seg->le * seg->lv->vg->extent_size;
char *lv_parent_dup(struct dm_pool *mem, const struct logical_volume *lv);
char *lv_origin_dup(struct dm_pool *mem, const struct logical_volume *lv);
uint32_t lv_kernel_read_ahead(const struct logical_volume *lv);
+const char *lvseg_name(const struct lv_segment *seg);
uint64_t lvseg_start(const struct lv_segment *seg);
uint64_t lvseg_size(const struct lv_segment *seg);
uint64_t lvseg_chunksize(const struct lv_segment *seg);
else if (seg_is_raid(first_seg(lv)) &&
(lp->stripes != seg_stripes)) {
log_error("Unable to extend \"%s\" segment type with different number of stripes.",
- first_seg(lv)->segtype->ops->name(first_seg(lv)));
+ lvseg_name(first_seg(lv)));
return 0;
}
if (!seg_can_split(seg)) {
log_error("Unable to split the %s segment at LE %" PRIu32
- " in LV %s", seg->segtype->ops->name(seg),
- le, lv->name);
+ " in LV %s", lvseg_name(seg), le, lv->name);
return 0;
}
if (!seg_is_pool(pool_seg)) {
log_error(INTERNAL_ERROR
"Unable to attach pool metadata LV to %s segtype.",
- pool_seg->segtype->ops->name(pool_seg));
+ lvseg_name(pool_seg));
return 0;
}
pool_seg->metadata_lv = metadata_lv;
if (!seg_is_pool(pool_seg)) {
log_error(INTERNAL_ERROR
"Unable to attach pool data LV to %s segtype.",
- pool_seg->segtype->ops->name(pool_seg));
+ lvseg_name(pool_seg));
return 0;
}
if (!seg->pool_lv) {
log_error(INTERNAL_ERROR
"No pool associated with %s LV, %s.",
- seg->segtype->ops->name(seg), seg->lv->name);
+ lvseg_name(seg), seg->lv->name);
return 0;
}
if (!seg_is_mirrored(seg)) {
log_error(INTERNAL_ERROR
"Unable to remove RAID layer from segment type %s",
- seg->segtype->ops->name(seg));
+ lvseg_name(seg));
return 0;
}
dm_list_add(&meta_lvs, &lvl->list);
} else if (!seg_is_raid(seg)) {
log_error("Unable to add RAID images to %s of segment type %s",
- lv->name, seg->segtype->ops->name(seg));
+ lv->name, lvseg_name(seg));
return 0;
}
if (!seg_is_mirrored(first_seg(lv)) ||
!strcmp(first_seg(lv)->segtype->name, SEG_TYPE_NAME_RAID10)) {
log_error("Unable to split logical volume of segment type, %s",
- first_seg(lv)->segtype->ops->name(first_seg(lv)));
+ lvseg_name(first_seg(lv)));
return 0;
}
log_error("Converting the segment type for %s/%s from %s to %s"
" is not yet supported.", lv->vg->name, lv->name,
- seg->segtype->ops->name(seg), new_segtype->name);
+ lvseg_name(seg), new_segtype->name);
return 0;
}
(match_count > raid_seg->segtype->parity_devs)) {
log_error("Unable to replace more than %u PVs from (%s) %s/%s",
raid_seg->segtype->parity_devs,
- raid_seg->segtype->ops->name(raid_seg),
+ lvseg_name(raid_seg),
lv->vg->name, lv->name);
return 0;
} else if (!strcmp(raid_seg->segtype->name, SEG_TYPE_NAME_RAID10)) {
return_0;
log_debug("Attempting to remove missing devices from %s LV, %s",
- seg->segtype->ops->name(seg), lv->name);
+ lvseg_name(seg), lv->name);
/*
* FIXME: Make sure # of compromised components will not affect RAID
(failed_components > raid_seg->segtype->parity_devs)) {
log_verbose("More than %u components from %s %s have failed.",
raid_seg->segtype->parity_devs,
- raid_seg->segtype->ops->name(raid_seg),
+ lvseg_name(raid_seg),
display_lvname(lv));
return 0; /* Insufficient redundancy to activate */
}
char *name;
if (!(name = lvseg_segtype_dup(mem, seg))) {
- log_error("Failed to get segtype.");
+ log_error("Failed to get segtype name.");
return 0;
}
vg_is_clustered(lv->vg) ? "clustered " : "",
(seg->log_lv) ? "disk-logged " :
seg_is_raid(seg) ? "" : "core-logged ",
- seg->segtype->ops->name(seg), lv->name);
+ lvseg_name(seg), lv->name);
/*
* If this mirror has a core log (i.e. !seg->log_lv),
if (arg_count(cmd, mirrors_ARG) &&
!seg_is_mirrored(seg) && !seg_is_linear(seg)) {
log_error("'--mirrors/-m' is not compatible with %s",
- seg->segtype->ops->name(seg));
+ lvseg_name(seg));
return 0;
}
if (!_is_valid_raid_conversion(seg->segtype, lp->segtype)) {
log_error("Unable to convert %s/%s from %s to %s",
lv->vg->name, lv->name,
- seg->segtype->ops->name(seg), lp->segtype->name);
+ lvseg_name(seg), lp->segtype->name);
return 0;
}
lv_is_thin_pool_data(lv) ||
lv_is_thin_pool_metadata(lv)) {
log_error("Can't use %s %s as external origin.",
- first_seg(lv)->segtype->name,
+ lvseg_name(first_seg(lv)),
display_lvname(lv));
return 0;
}
if (arg_count(cmd, use_policies_ARG))
return ECMD_PROCESSED; /* nothing to be done here */
log_error("Can't repair LV \"%s\" of segtype %s.",
- lv->name,
- first_seg(lv)->segtype->ops->name(first_seg(lv)));
+ lv->name, lvseg_name(first_seg(lv)));
return ECMD_FAILED;
}
}