488
488
if (!lv_add_mirrors(cmd, lv_mirr, 1, 1, 0, 0, log_count,
489
allocatable_pvs, alloc, MIRROR_BY_SEG)) {
489
allocatable_pvs, alloc,
490
(arg_count(cmd, atomic_ARG)) ?
491
MIRROR_BY_SEGMENTED_LV : MIRROR_BY_SEG)) {
490
492
log_error("Failed to convert pvmove LV to mirrored");
520
static int _is_pvmove_image_removable(struct logical_volume *mimage_lv,
523
uint32_t mimage_to_remove = *((uint32_t *)baton);
524
struct lv_segment *mirror_seg;
526
if (!(mirror_seg = get_only_segment_using_this_lv(mimage_lv))) {
527
log_error(INTERNAL_ERROR "%s is not a proper mirror image",
532
if (seg_type(mirror_seg, 0) != AREA_LV) {
533
log_error(INTERNAL_ERROR "%s is not a pvmove mirror of LV-type",
534
mirror_seg->lv->name);
538
if (mimage_to_remove > mirror_seg->area_count) {
539
log_error(INTERNAL_ERROR "Mirror image %" PRIu32 " not found in segment",
544
if (seg_lv(mirror_seg, mimage_to_remove) == mimage_lv)
518
550
static int _detach_pvmove_mirror(struct cmd_context *cmd,
519
551
struct logical_volume *lv_mirr)
553
uint32_t mimage_to_remove = 0;
521
554
struct dm_list lvs_completed;
522
555
struct lv_list *lvl;
524
557
/* Update metadata to remove mirror segments and break dependencies */
525
558
dm_list_init(&lvs_completed);
526
if (!lv_remove_mirrors(cmd, lv_mirr, 1, 0, NULL, NULL, PVMOVE) ||
560
if (arg_is_set(cmd, abort_ARG) &&
561
(seg_type(first_seg(lv_mirr), 0) == AREA_LV))
562
mimage_to_remove = 1; /* remove the second mirror leg */
564
if (!lv_remove_mirrors(cmd, lv_mirr, 1, 0, _is_pvmove_image_removable, &mimage_to_remove, PVMOVE) ||
527
565
!remove_layers_for_segments_all(cmd, lv_mirr, PVMOVE,
528
566
&lvs_completed)) {