1
0
mirror of git://sourceware.org/git/lvm2.git synced 2025-01-03 05:18:29 +03:00

segments: introduce lvseg_name

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->
This commit is contained in:
Zdenek Kabelac 2014-10-20 18:40:39 +02:00
parent ab94045693
commit 9411c19b31
11 changed files with 32 additions and 22 deletions

View File

@ -1,5 +1,6 @@
Version 2.02.112 - Version 2.02.112 -
===================================== =====================================
Add internal lvseg_name() function.
Skip trying to file lock virtual internal vg name. Skip trying to file lock virtual internal vg name.
Fix selection on {vg,lv}_permissions fields to properly match selection criteria. Fix selection on {vg,lv}_permissions fields to properly match selection criteria.
Fix lv_permissions reporting to display read-only{-override} instead of blank. Fix lv_permissions reporting to display read-only{-override} instead of blank.

View File

@ -667,7 +667,7 @@ int lvdisplay_segments(const struct logical_volume *lv)
lv_is_virtual(lv) ? "Virtual" : "Logical", lv_is_virtual(lv) ? "Virtual" : "Logical",
seg->le, seg->le + seg->len - 1); 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) if (seg->segtype->ops->target_monitored)
log_print(" Monitoring\t\t%s", log_print(" Monitoring\t\t%s",

View File

@ -120,7 +120,7 @@ char *lvseg_tags_dup(const struct lv_segment *seg)
char *lvseg_segtype_dup(struct dm_pool *mem, const struct lv_segment *seg) 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) char *lvseg_discards_dup(struct dm_pool *mem, const struct lv_segment *seg)
@ -183,6 +183,16 @@ uint64_t lvseg_chunksize(const struct lv_segment *seg)
return size; 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) uint64_t lvseg_start(const struct lv_segment *seg)
{ {
return (uint64_t) seg->le * seg->lv->vg->extent_size; return (uint64_t) seg->le * seg->lv->vg->extent_size;

View File

@ -77,6 +77,7 @@ struct logical_volume *lv_parent(const struct logical_volume *lv);
char *lv_parent_dup(struct dm_pool *mem, const struct logical_volume *lv); 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); char *lv_origin_dup(struct dm_pool *mem, const struct logical_volume *lv);
uint32_t lv_kernel_read_ahead(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_start(const struct lv_segment *seg);
uint64_t lvseg_size(const struct lv_segment *seg); uint64_t lvseg_size(const struct lv_segment *seg);
uint64_t lvseg_chunksize(const struct lv_segment *seg); uint64_t lvseg_chunksize(const struct lv_segment *seg);

View File

@ -4617,7 +4617,7 @@ static int _lvresize_adjust_extents(struct cmd_context *cmd, struct logical_volu
else if (seg_is_raid(first_seg(lv)) && else if (seg_is_raid(first_seg(lv)) &&
(lp->stripes != seg_stripes)) { (lp->stripes != seg_stripes)) {
log_error("Unable to extend \"%s\" segment type with different number of 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; return 0;
} }

View File

@ -481,8 +481,7 @@ static int _lv_split_segment(struct logical_volume *lv, struct lv_segment *seg,
if (!seg_can_split(seg)) { if (!seg_can_split(seg)) {
log_error("Unable to split the %s segment at LE %" PRIu32 log_error("Unable to split the %s segment at LE %" PRIu32
" in LV %s", seg->segtype->ops->name(seg), " in LV %s", lvseg_name(seg), le, lv->name);
le, lv->name);
return 0; return 0;
} }

View File

@ -33,7 +33,7 @@ int attach_pool_metadata_lv(struct lv_segment *pool_seg,
if (!seg_is_pool(pool_seg)) { if (!seg_is_pool(pool_seg)) {
log_error(INTERNAL_ERROR log_error(INTERNAL_ERROR
"Unable to attach pool metadata LV to %s segtype.", "Unable to attach pool metadata LV to %s segtype.",
pool_seg->segtype->ops->name(pool_seg)); lvseg_name(pool_seg));
return 0; return 0;
} }
pool_seg->metadata_lv = metadata_lv; pool_seg->metadata_lv = metadata_lv;
@ -70,7 +70,7 @@ int attach_pool_data_lv(struct lv_segment *pool_seg,
if (!seg_is_pool(pool_seg)) { if (!seg_is_pool(pool_seg)) {
log_error(INTERNAL_ERROR log_error(INTERNAL_ERROR
"Unable to attach pool data LV to %s segtype.", "Unable to attach pool data LV to %s segtype.",
pool_seg->segtype->ops->name(pool_seg)); lvseg_name(pool_seg));
return 0; return 0;
} }
@ -129,7 +129,7 @@ int detach_pool_lv(struct lv_segment *seg)
if (!seg->pool_lv) { if (!seg->pool_lv) {
log_error(INTERNAL_ERROR log_error(INTERNAL_ERROR
"No pool associated with %s LV, %s.", "No pool associated with %s LV, %s.",
seg->segtype->ops->name(seg), seg->lv->name); lvseg_name(seg), seg->lv->name);
return 0; return 0;
} }

View File

@ -117,7 +117,7 @@ static int _raid_remove_top_layer(struct logical_volume *lv,
if (!seg_is_mirrored(seg)) { if (!seg_is_mirrored(seg)) {
log_error(INTERNAL_ERROR log_error(INTERNAL_ERROR
"Unable to remove RAID layer from segment type %s", "Unable to remove RAID layer from segment type %s",
seg->segtype->ops->name(seg)); lvseg_name(seg));
return 0; return 0;
} }
@ -579,7 +579,7 @@ static int _raid_add_images(struct logical_volume *lv,
dm_list_add(&meta_lvs, &lvl->list); dm_list_add(&meta_lvs, &lvl->list);
} else if (!seg_is_raid(seg)) { } else if (!seg_is_raid(seg)) {
log_error("Unable to add RAID images to %s of segment type %s", 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; return 0;
} }
@ -1075,7 +1075,7 @@ int lv_raid_split(struct logical_volume *lv, const char *split_name,
if (!seg_is_mirrored(first_seg(lv)) || if (!seg_is_mirrored(first_seg(lv)) ||
!strcmp(first_seg(lv)->segtype->name, SEG_TYPE_NAME_RAID10)) { !strcmp(first_seg(lv)->segtype->name, SEG_TYPE_NAME_RAID10)) {
log_error("Unable to split logical volume of segment type, %s", 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; return 0;
} }
@ -1445,7 +1445,7 @@ int lv_raid_reshape(struct logical_volume *lv,
log_error("Converting the segment type for %s/%s from %s to %s" log_error("Converting the segment type for %s/%s from %s to %s"
" is not yet supported.", lv->vg->name, lv->name, " 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; return 0;
} }
@ -1601,7 +1601,7 @@ int lv_raid_replace(struct logical_volume *lv,
(match_count > raid_seg->segtype->parity_devs)) { (match_count > raid_seg->segtype->parity_devs)) {
log_error("Unable to replace more than %u PVs from (%s) %s/%s", log_error("Unable to replace more than %u PVs from (%s) %s/%s",
raid_seg->segtype->parity_devs, raid_seg->segtype->parity_devs,
raid_seg->segtype->ops->name(raid_seg), lvseg_name(raid_seg),
lv->vg->name, lv->name); lv->vg->name, lv->name);
return 0; return 0;
} else if (!strcmp(raid_seg->segtype->name, SEG_TYPE_NAME_RAID10)) { } else if (!strcmp(raid_seg->segtype->name, SEG_TYPE_NAME_RAID10)) {
@ -1790,7 +1790,7 @@ int lv_raid_remove_missing(struct logical_volume *lv)
return_0; return_0;
log_debug("Attempting to remove missing devices from %s LV, %s", 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 * FIXME: Make sure # of compromised components will not affect RAID
@ -1870,7 +1870,7 @@ static int _partial_raid_lv_is_redundant(const struct logical_volume *lv)
(failed_components > raid_seg->segtype->parity_devs)) { (failed_components > raid_seg->segtype->parity_devs)) {
log_verbose("More than %u components from %s %s have failed.", log_verbose("More than %u components from %s %s have failed.",
raid_seg->segtype->parity_devs, raid_seg->segtype->parity_devs,
raid_seg->segtype->ops->name(raid_seg), lvseg_name(raid_seg),
display_lvname(lv)); display_lvname(lv));
return 0; /* Insufficient redundancy to activate */ return 0; /* Insufficient redundancy to activate */
} }

View File

@ -366,7 +366,7 @@ static int _segtype_disp(struct dm_report *rh __attribute__((unused)),
char *name; char *name;
if (!(name = lvseg_segtype_dup(mem, seg))) { if (!(name = lvseg_segtype_dup(mem, seg))) {
log_error("Failed to get segtype."); log_error("Failed to get segtype name.");
return 0; return 0;
} }

View File

@ -355,7 +355,7 @@ static int lvchange_resync(struct cmd_context *cmd, struct logical_volume *lv)
vg_is_clustered(lv->vg) ? "clustered " : "", vg_is_clustered(lv->vg) ? "clustered " : "",
(seg->log_lv) ? "disk-logged " : (seg->log_lv) ? "disk-logged " :
seg_is_raid(seg) ? "" : "core-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 this mirror has a core log (i.e. !seg->log_lv),

View File

@ -1850,7 +1850,7 @@ static int _lvconvert_raid(struct logical_volume *lv, struct lvconvert_params *l
if (arg_count(cmd, mirrors_ARG) && if (arg_count(cmd, mirrors_ARG) &&
!seg_is_mirrored(seg) && !seg_is_linear(seg)) { !seg_is_mirrored(seg) && !seg_is_linear(seg)) {
log_error("'--mirrors/-m' is not compatible with %s", log_error("'--mirrors/-m' is not compatible with %s",
seg->segtype->ops->name(seg)); lvseg_name(seg));
return 0; return 0;
} }
@ -1860,7 +1860,7 @@ static int _lvconvert_raid(struct logical_volume *lv, struct lvconvert_params *l
if (!_is_valid_raid_conversion(seg->segtype, lp->segtype)) { if (!_is_valid_raid_conversion(seg->segtype, lp->segtype)) {
log_error("Unable to convert %s/%s from %s to %s", log_error("Unable to convert %s/%s from %s to %s",
lv->vg->name, lv->name, lv->vg->name, lv->name,
seg->segtype->ops->name(seg), lp->segtype->name); lvseg_name(seg), lp->segtype->name);
return 0; return 0;
} }
@ -2672,7 +2672,7 @@ static int _lvconvert_thin(struct cmd_context *cmd,
lv_is_thin_pool_data(lv) || lv_is_thin_pool_data(lv) ||
lv_is_thin_pool_metadata(lv)) { lv_is_thin_pool_metadata(lv)) {
log_error("Can't use %s %s as external origin.", log_error("Can't use %s %s as external origin.",
first_seg(lv)->segtype->name, lvseg_name(first_seg(lv)),
display_lvname(lv)); display_lvname(lv));
return 0; return 0;
} }
@ -3294,8 +3294,7 @@ static int _lvconvert_single(struct cmd_context *cmd, struct logical_volume *lv,
if (arg_count(cmd, use_policies_ARG)) if (arg_count(cmd, use_policies_ARG))
return ECMD_PROCESSED; /* nothing to be done here */ return ECMD_PROCESSED; /* nothing to be done here */
log_error("Can't repair LV \"%s\" of segtype %s.", log_error("Can't repair LV \"%s\" of segtype %s.",
lv->name, lv->name, lvseg_name(first_seg(lv)));
first_seg(lv)->segtype->ops->name(first_seg(lv)));
return ECMD_FAILED; return ECMD_FAILED;
} }
} }