~ubuntu-branches/debian/sid/lvm2/sid

« back to all changes in this revision

Viewing changes to tools/pvmove.c

  • Committer: Package Import Robot
  • Author(s): Bastian Blank
  • Date: 2014-08-19 15:37:06 UTC
  • mfrom: (1.1.18)
  • Revision ID: package-import@ubuntu.com-20140819153706-i1gaio8lg534dara
Tags: 2.02.109-1
New upstream version.

Show diffs side-by-side

added added

removed removed

Lines of Context:
486
486
        }
487
487
 
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");
491
493
                return_NULL;
492
494
        }
515
517
        return r;
516
518
}
517
519
 
 
520
static int _is_pvmove_image_removable(struct logical_volume *mimage_lv,
 
521
                                      void *baton)
 
522
{
 
523
        uint32_t mimage_to_remove = *((uint32_t *)baton);
 
524
        struct lv_segment *mirror_seg;
 
525
 
 
526
        if (!(mirror_seg = get_only_segment_using_this_lv(mimage_lv))) {
 
527
                log_error(INTERNAL_ERROR "%s is not a proper mirror image",
 
528
                          mimage_lv->name);
 
529
                return 0;
 
530
        }
 
531
 
 
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);
 
535
                return 0;
 
536
        }
 
537
 
 
538
        if (mimage_to_remove > mirror_seg->area_count) {
 
539
                log_error(INTERNAL_ERROR "Mirror image %" PRIu32 " not found in segment",
 
540
                          mimage_to_remove);
 
541
                return 0;
 
542
        }
 
543
 
 
544
        if (seg_lv(mirror_seg, mimage_to_remove) == mimage_lv)
 
545
                return 1;
 
546
 
 
547
        return 0;
 
548
}
 
549
 
518
550
static int _detach_pvmove_mirror(struct cmd_context *cmd,
519
551
                                 struct logical_volume *lv_mirr)
520
552
{
 
553
        uint32_t mimage_to_remove = 0;
521
554
        struct dm_list lvs_completed;
522
555
        struct lv_list *lvl;
523
556
 
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) ||
 
559
 
 
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 */
 
563
 
 
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)) {
529
567
                return 0;