1
0
mirror of git://sourceware.org/git/lvm2.git synced 2025-01-19 14:04:17 +03:00

raid_manip:

duplication namespace adjustments; step 2
	introduce struct lv_raid_convert_params to pass on arguments to lv_raid_convert()
	cleanup
This commit is contained in:
Heinz Mauelshagen 2015-12-16 23:09:30 +01:00
parent be0251c498
commit 5d2728f24b
5 changed files with 322 additions and 309 deletions

View File

@ -2842,24 +2842,17 @@ static int _add_new_lv_to_dtree(struct dev_manager *dm, struct dm_tree *dtree,
uint32_t read_ahead_flags = UINT32_C(0);
int save_pending_delete = dm->track_pending_delete;
PFLA("lv=%s delete=%d", lv->name, lv_is_pending_delete(lv));
/* LV with pending delete is never put new into a table */
if (lv_is_pending_delete(lv) && !_cached_dm_info(dm->mem, dtree, lv, NULL))
{
PFL();
return 1; /* Replace with error only when already exists */
}
if (lv_is_cache_pool(lv) &&
!dm_list_empty(&lv->segs_using_this_lv)) {
PFL();
/* cache pool is 'meta' LV and does not have a real device node */
if (!_add_new_lv_to_dtree(dm, dtree, seg_lv(first_seg(lv), 0), laopts, NULL))
return_0;
PFL();
if (!_add_new_lv_to_dtree(dm, dtree, first_seg(lv)->metadata_lv, laopts, NULL))
return_0;
PFL();
return 1;
}
@ -2887,7 +2880,6 @@ PFL();
laopts->no_merging = 1;
}
}
PFL();
if (!(name = dm_build_dm_name(dm->mem, lv->vg->name, lv->name, layer)))
return_0;
@ -2921,7 +2913,6 @@ PFL();
/* FIXME Move the clear from here until later, so we can leave
* identical inactive tables untouched. (For pvmove.)
*/
PFL();
if (!(dnode = dm_tree_add_new_dev_with_udev_flags(dtree, name, dlid,
layer ? UINT32_C(0) : (uint32_t) lv->major,
layer ? UINT32_C(0) : (uint32_t) lv->minor,
@ -2937,39 +2928,32 @@ PFL();
/* Create table */
dm->pvmove_mirror_count = 0u;
PFL();
if (lv_is_pending_delete(lv))
/* Handle LVs with pending delete */
/* Fow now used only by cache segtype, TODO snapshots */
dm->track_pending_delete = 1;
PFL();
/* This is unused cache-pool - make metadata accessible */
if (lv_is_cache_pool(lv))
lv = first_seg(lv)->metadata_lv;
PFL();
/* If this is a snapshot origin, add real LV */
/* If this is a snapshot origin + merging snapshot, add cow + real LV */
/* Snapshot origin could be also external origin */
if (lv_is_origin(lv) && !layer) {
PFL();
if (!_add_new_lv_to_dtree(dm, dtree, lv, laopts, "real"))
return_0;
if (!laopts->no_merging && lv_is_merging_origin(lv)) {
PFL();
if (!_add_new_lv_to_dtree(dm, dtree,
find_snapshot(lv)->cow, laopts, "cow"))
return_0;
PFL();
/*
* Must also add "real" LV for use when
* snapshot-merge target is added
*/
if (!_add_snapshot_merge_target_to_dtree(dm, dnode, lv))
return_0;
PFL();
} else if (!_add_origin_target_to_dtree(dm, dnode, lv))
return_0;
@ -2981,13 +2965,11 @@ PFL();
laopts, NULL))
return_0;
} else if (lv_is_cow(lv) && !layer) {
PFL();
if (!_add_new_lv_to_dtree(dm, dtree, lv, laopts, "cow"))
return_0;
if (!_add_snapshot_target_to_dtree(dm, dnode, lv, laopts))
return_0;
PFL();
} else if (!layer && ((lv_is_thin_pool(lv) && !lv_is_new_thin_pool(lv)) ||
lv_is_external_origin(lv))) {
/* External origin or 'used' Thin pool is using layer */
@ -2996,7 +2978,6 @@ PFL();
if (!_add_layer_target_to_dtree(dm, dnode, lv))
return_0;
} else {
PFL();
/* Add 'real' segments for LVs */
dm_list_iterate_items(seg, &lv->segments) {
if (!_add_segment_to_dtree(dm, dtree, dnode, seg, laopts, layer))
@ -3004,7 +2985,6 @@ PFL();
if (max_stripe_size < seg->stripe_size * seg->area_count)
max_stripe_size = seg->stripe_size * seg->area_count;
}
PFL();
}
/* Setup thin pool callback */
@ -3027,7 +3007,6 @@ PFL();
dm_tree_node_set_read_ahead(dnode, read_ahead, read_ahead_flags);
PFL();
/* Add any LVs referencing a PVMOVE LV unless told not to */
if (dm->track_pvmove_deps && lv_is_pvmove(lv))
dm_list_iterate_items(sl, &lv->segs_using_this_lv)
@ -3041,7 +3020,6 @@ PFL();
#endif
dm->track_pending_delete = save_pending_delete; /* restore */
PFL();
return 1;
}

View File

@ -7349,7 +7349,7 @@ int insert_layer_for_segments_on_pv(struct cmd_context *cmd,
}
/*
* Initialize the LV with 'value'.
* Initialize the LV with @wp.zero_value, length wp.zero_sectors or 4KiB default if 0
*/
int wipe_lv(struct logical_volume *lv, struct wipe_params wp)
{

View File

@ -864,6 +864,21 @@ static inline int is_change_activating(activation_change_t change)
return ((change != CHANGE_AN) && (change != CHANGE_ALN));
}
struct lv_raid_convert_params {
struct segment_type *segtype;
int yes;
int force;
int duplicate;
int unduplicate;
const int data_copies; /* to be able to detect -m0; -1 if no data copy change requested */
const unsigned region_size;
const int region_size_arg;
const unsigned stripes;
const unsigned stripe_size;
const char *lv_name; /* sub-lv name to unduplicate or pool LV name to create a duplicated thin LV */
struct dm_list *allocate_pvs;
};
/* FIXME: refactor and reduce the size of this struct! */
struct lvcreate_params {
/* flags */
@ -1145,22 +1160,15 @@ uint32_t raid_rmeta_extents_delta(struct cmd_context *cmd,
uint32_t region_size, uint32_t extent_size);
int lv_is_raid_with_tracking(const struct logical_volume *lv);
uint32_t lv_raid_image_count(const struct logical_volume *lv);
int lv_raid_split(struct logical_volume *lv, const char *split_name,
int lv_raid_split(struct logical_volume *lv, int yes, const char *split_name,
uint32_t new_count, struct dm_list *splittable_pvs);
int lv_raid_split_and_track(struct logical_volume *lv,
int yes,
const char *sub_lv_name,
struct dm_list *splittable_pvs);
int lv_raid_merge(struct logical_volume *lv);
int lv_raid_convert(struct logical_volume *lv,
struct segment_type *new_segtype,
int yes, int force,
int duplicate, int unduplicate,
const int data_copies,
const unsigned region_size,
const unsigned stripes,
const unsigned stripe_size,
const char *sub_lv_name,
struct dm_list *allocate_pvs);
struct lv_raid_convert_params p);
int lv_raid_replace(struct logical_volume *lv, int yes,
struct dm_list *remove_pvs,
struct dm_list *allocate_pvs);
@ -1169,7 +1177,8 @@ int partial_raid_lv_supports_degraded_activation(const struct logical_volume *lv
int lv_raid10_far_reorder_segments(struct logical_volume *lv, uint32_t extents, int extend);
uint32_t raid_rimage_extents(const struct segment_type *segtype, uint32_t extents, uint32_t stripes, uint32_t data_copies);
uint32_t raid_total_extents(const struct segment_type *segtype, uint32_t extents, uint32_t stripes, uint32_t data_copies);
int lv_create_raid01(struct logical_volume *lv, const struct segment_type *segtype,
int lv_create_raid01(struct logical_volume *lv,
const struct segment_type *segtype,
unsigned mirrors, unsigned stripes,
unsigned stripe_size, unsigned region_size,
unsigned extents,

File diff suppressed because it is too large Load Diff

View File

@ -1772,10 +1772,10 @@ PFLA("image_count=%u\n", image_count);
return lv_raid_merge(lv);
if (arg_count(cmd, trackchanges_ARG))
return lv_raid_split_and_track(lv, lp->lv_split_name, lp->pvh);
return lv_raid_split_and_track(lv, lp->yes, lp->lv_split_name, lp->pvh);
if (arg_count(cmd, splitmirrors_ARG))
return lv_raid_split(lv, lp->lv_split_name, image_count, lp->pvh);
return lv_raid_split(lv, lp->yes, lp->lv_split_name, image_count, lp->pvh);
if ((seg_is_linear(seg) || seg_is_striped(seg) || seg_is_mirror(seg) || seg_is_raid(seg)) &&
(arg_count(cmd, type_ARG) ||
@ -1846,12 +1846,19 @@ PFLA("image_count=%u\n", image_count);
PFLA("lp->region_size=%u", lp->region_size);
PFLA("lp->pool_data_name=%s lp->lv_split_name=%s lp->lv_name=%s", lp->pool_data_name, lp->lv_split_name, lp->lv_name);
return lv_raid_convert(lv, arg_count(cmd, type_ARG) ? (struct segment_type *) lp->segtype : NULL,
lp->yes, lp->force,
arg_is_set(cmd, duplicate_ARG), arg_is_set(cmd, unduplicate_ARG),
data_copies, lp->region_size,
stripes, stripe_size,
lp->pool_data_name ?: lp->lv_split_name, lp->pvh);
return lv_raid_convert(lv, (struct lv_raid_convert_params)
{ .segtype = arg_count(cmd, type_ARG) ? (struct segment_type *) lp->segtype : NULL,
.yes = lp->yes,
.force = lp->force,
.duplicate = arg_is_set(cmd, duplicate_ARG),
.unduplicate = arg_is_set(cmd, unduplicate_ARG),
.data_copies = data_copies,
.region_size = lp->region_size,
.region_size_arg = arg_count(cmd, regionsize_ARG),
.stripes = stripes,
.stripe_size = stripe_size,
.lv_name = lp->pool_data_name ?: lp->lv_split_name,
.allocate_pvs= lp->pvh } );
}
if (arg_count(cmd, replace_ARG))