mirror of
git://sourceware.org/git/lvm2.git
synced 2025-01-03 05:18:29 +03:00
Remove old thin code from _lv_insert_empty_sublvs
Since thin is not able to use _lv_insert_empty_sublvs, remove its appearence from this function. Start to use extend_pool() function for desired functionality and modify lv_extend() for this.
This commit is contained in:
parent
c35bcc8bdf
commit
aef13649ea
@ -2369,9 +2369,6 @@ static int _lv_insert_empty_sublvs(struct logical_volume *lv,
|
||||
lv->status |= MIRRORED;
|
||||
sub_lv_status = MIRROR_IMAGE;
|
||||
layer_name = "mimage";
|
||||
} else if (segtype_is_thin_pool(segtype)) {
|
||||
lv->status |= THIN_POOL;
|
||||
layer_name = "tpool";
|
||||
} else
|
||||
return_0;
|
||||
|
||||
@ -2406,19 +2403,13 @@ static int _lv_insert_empty_sublvs(struct logical_volume *lv,
|
||||
lv->alloc, lv->vg)))
|
||||
return_0;
|
||||
|
||||
if (segtype_is_thin_pool(segtype)) {
|
||||
if (!attach_pool_data_lv(mapseg, sub_lv))
|
||||
return_0;
|
||||
} else if (!set_lv_segment_area_lv(mapseg, i, sub_lv, 0, sub_lv_status))
|
||||
if (!set_lv_segment_area_lv(mapseg, i, sub_lv, 0, sub_lv_status))
|
||||
return_0;
|
||||
|
||||
/* Metadata LVs for raid or thin pool */
|
||||
/* Metadata LVs for raid */
|
||||
if (segtype_is_raid(segtype)) {
|
||||
if (dm_snprintf(img_name, len, "%s_rmeta_%u", lv->name, i) < 0)
|
||||
return_0;
|
||||
} else if (segtype_is_thin_pool(segtype)) {
|
||||
if (dm_snprintf(img_name, len, "%s_tmeta", lv->name) < 0)
|
||||
return_0;
|
||||
} else
|
||||
continue;
|
||||
|
||||
@ -2428,12 +2419,10 @@ static int _lv_insert_empty_sublvs(struct logical_volume *lv,
|
||||
lv->alloc, lv->vg)))
|
||||
return_0;
|
||||
|
||||
if (segtype_is_thin_pool(segtype)) {
|
||||
if (!attach_pool_metadata_lv(mapseg, sub_lv))
|
||||
return_0;
|
||||
} else if (!set_lv_segment_area_lv(mapseg, i, sub_lv, 0, RAID_META))
|
||||
if (!set_lv_segment_area_lv(mapseg, i, sub_lv, 0, RAID_META))
|
||||
return_0;
|
||||
}
|
||||
|
||||
dm_list_add(&lv->segments, &mapseg->list);
|
||||
|
||||
return 1;
|
||||
@ -2562,6 +2551,29 @@ int lv_extend(struct logical_volume *lv,
|
||||
struct alloc_handle *ah;
|
||||
uint32_t sub_lv_count;
|
||||
|
||||
log_very_verbose("Extending segment type, %s", segtype->name);
|
||||
|
||||
if (segtype_is_virtual(segtype))
|
||||
return lv_add_virtual_segment(lv, 0u, extents, segtype, thin_pool_name);
|
||||
|
||||
if (segtype_is_thin_pool(segtype))
|
||||
log_count = 1;
|
||||
else if (segtype_is_raid(segtype) && !lv->le_count)
|
||||
log_count = mirrors * stripes;
|
||||
|
||||
/* Thin pool allocation treats its metadata device like a mirror log. */
|
||||
if (!(ah = allocate_extents(lv->vg, lv, segtype, stripes, mirrors,
|
||||
log_count, region_size, extents,
|
||||
allocatable_pvs, alloc, NULL)))
|
||||
return_0;
|
||||
|
||||
if (segtype_is_thin_pool(segtype)) {
|
||||
if (!(r = extend_pool(lv, segtype, ah)))
|
||||
stack;
|
||||
} else if (!segtype_is_mirrored(segtype) && !segtype_is_raid(segtype))
|
||||
r = lv_add_segment(ah, 0, ah->area_count, lv, segtype,
|
||||
stripe_size, 0u, 0);
|
||||
else {
|
||||
/*
|
||||
* For RAID, all the devices are AREA_LV.
|
||||
* However, for 'mirror on stripe' using non-RAID targets,
|
||||
@ -2570,32 +2582,9 @@ int lv_extend(struct logical_volume *lv,
|
||||
*/
|
||||
if (segtype_is_raid(segtype))
|
||||
sub_lv_count = mirrors * stripes + segtype->parity_devs;
|
||||
else if (segtype_is_thin_pool(segtype))
|
||||
sub_lv_count = 1;
|
||||
else
|
||||
sub_lv_count = mirrors;
|
||||
|
||||
log_very_verbose("Extending segment type, %s", segtype->name);
|
||||
|
||||
if (segtype_is_virtual(segtype))
|
||||
return lv_add_virtual_segment(lv, 0u, extents, segtype, thin_pool_name);
|
||||
|
||||
if (segtype_is_raid(segtype) && !lv->le_count)
|
||||
log_count = mirrors * stripes;
|
||||
|
||||
if (segtype_is_thin_pool(segtype))
|
||||
log_count = 1;
|
||||
|
||||
/* Thin pool allocation treats its metadata device like a mirror log. */
|
||||
if (!(ah = allocate_extents(lv->vg, lv, segtype, stripes, mirrors,
|
||||
log_count, region_size, extents,
|
||||
allocatable_pvs, alloc, NULL)))
|
||||
return_0;
|
||||
|
||||
if (!segtype_is_mirrored(segtype) && !segtype_is_raid(segtype) && !segtype_is_thin_pool(segtype))
|
||||
r = lv_add_segment(ah, 0, ah->area_count, lv, segtype,
|
||||
stripe_size, 0u, 0);
|
||||
else {
|
||||
if (!lv->le_count &&
|
||||
!_lv_insert_empty_sublvs(lv, segtype, stripe_size,
|
||||
region_size, sub_lv_count)) {
|
||||
@ -4202,34 +4191,12 @@ static struct logical_volume *_lv_create_an_lv(struct volume_group *vg, struct l
|
||||
|
||||
init_dmeventd_monitor(lp->activation_monitoring);
|
||||
|
||||
if (seg_is_thin_pool(lp)) {
|
||||
/* FIXME: skipping in test mode is not going work */
|
||||
if (!activate_lv_excl(cmd, first_seg(lv)->pool_metadata_lv) ||
|
||||
/* Clear 4KB of metadata device for new thin-pool. */
|
||||
// FIXME: maybe -zero n should allow to recreate same thin pool
|
||||
// and different option should be used for zero_new_blocks
|
||||
!set_lv(cmd, first_seg(lv)->pool_metadata_lv, UINT64_C(0), 0)) {
|
||||
log_error("Aborting. Failed to wipe pool metadata %s.",
|
||||
lv->name);
|
||||
goto revert_new_lv;
|
||||
}
|
||||
/* FIXME: we may postpone finish of the pool creation to the
|
||||
* moment of the first activation - but this needs more changes
|
||||
* so we would update metadata with vgchange -ay
|
||||
*
|
||||
* For now always activate.
|
||||
*/
|
||||
if (seg_is_thin_pool(lp) || seg_is_thin(lp)) {
|
||||
if (!activate_lv_excl(cmd, lv)) {
|
||||
log_error("Aborting. Could not to activate thin pool %s.",
|
||||
log_error("Aborting. Failed to activate thin %s.",
|
||||
lv->name);
|
||||
goto revert_new_lv;
|
||||
}
|
||||
} else if (seg_is_thin(lp)) {
|
||||
/* FIXME: same as with thin pool - add lazy creation support */
|
||||
if (!activate_lv_excl(cmd, lv)) {
|
||||
log_error("Aborting. Failed to activate thin %s.", lv->name);
|
||||
goto revert_new_lv;
|
||||
}
|
||||
} else if (lp->snapshot) {
|
||||
if (!activate_lv_excl(cmd, lv)) {
|
||||
log_error("Aborting. Failed to activate snapshot "
|
||||
|
Loading…
Reference in New Issue
Block a user