1
0
mirror of git://sourceware.org/git/lvm2.git synced 2024-12-21 13:34:40 +03:00

pvmove: tidy

This commit is contained in:
Alasdair G Kergon 2014-06-19 13:40:47 +01:00
parent bc0a1ca83d
commit b33091cb11
5 changed files with 16 additions and 21 deletions

View File

@ -6,7 +6,7 @@ Version 2.02.107 -
Add -S/--select to pvs,vgs,lvs and {pv,vg,lv}display -C for report selection. Add -S/--select to pvs,vgs,lvs and {pv,vg,lv}display -C for report selection.
Use dm_report_init_with_selection now, implicit "selected" field appears. Use dm_report_init_with_selection now, implicit "selected" field appears.
Make use of libdm's DM_REPORT_FIELD_TYPE{SIZE,PERCENT,STRING_LIST} for fields. Make use of libdm's DM_REPORT_FIELD_TYPE{SIZE,PERCENT,STRING_LIST} for fields.
Add support for all-or-nothing (atomic) pvmove. Support all-or-nothing pvmove --atomic.
Automatically add snapshot metadata size for -l %ORIGIN calculation. Automatically add snapshot metadata size for -l %ORIGIN calculation.
When converting RAID origin to cache LV, properly rename sub-LVs. When converting RAID origin to cache LV, properly rename sub-LVs.
Use RemoveOnStop for lvm2-lvmetad.socket systemd unit. Use RemoveOnStop for lvm2-lvmetad.socket systemd unit.

View File

@ -133,10 +133,8 @@
/* Mirror conversion type flags */ /* Mirror conversion type flags */
#define MIRROR_BY_SEG 0x00000001U /* segment-by-segment mirror */ #define MIRROR_BY_SEG 0x00000001U /* segment-by-segment mirror */
#define MIRROR_BY_LV 0x00000002U /* mirror using whole mimage LVs */ #define MIRROR_BY_LV 0x00000002U /* mirror using whole mimage LVs */
#define MIRROR_BY_SEGMENTED_LV 0x00000004U /* mirror using whole mimage #define MIRROR_BY_SEGMENTED_LV 0x00000004U /* mirror using whole mimage LVs that
* LVs, but preserve the * preserve the segment structure */
* segment layout templated by
* the primary mimage */
#define MIRROR_SKIP_INIT_SYNC 0x00000010U /* skip initial sync */ #define MIRROR_SKIP_INIT_SYNC 0x00000010U /* skip initial sync */
/* vg_read and vg_read_for_update flags */ /* vg_read and vg_read_for_update flags */

View File

@ -17,7 +17,6 @@
* Put all long args that don't have a corresponding short option first. * Put all long args that don't have a corresponding short option first.
*/ */
/* *INDENT-OFF* */ /* *INDENT-OFF* */
arg(atomic_ARG, '\0', "atomic", NULL, 0)
arg(version_ARG, '\0', "version", NULL, 0) arg(version_ARG, '\0', "version", NULL, 0)
arg(physicalvolumesize_ARG, '\0', "setphysicalvolumesize", size_mb_arg, 0) arg(physicalvolumesize_ARG, '\0', "setphysicalvolumesize", size_mb_arg, 0)
arg(ignorelockingfailure_ARG, '\0', "ignorelockingfailure", NULL, 0) arg(ignorelockingfailure_ARG, '\0', "ignorelockingfailure", NULL, 0)
@ -108,6 +107,7 @@ arg(mergedconfig_ARG, '\0', "mergedconfig", NULL, 0)
arg(ignoreskippedcluster_ARG, '\0', "ignoreskippedcluster", NULL, 0) arg(ignoreskippedcluster_ARG, '\0', "ignoreskippedcluster", NULL, 0)
arg(splitsnapshot_ARG, '\0', "splitsnapshot", NULL, 0) arg(splitsnapshot_ARG, '\0', "splitsnapshot", NULL, 0)
arg(readonly_ARG, '\0', "readonly", NULL, 0) arg(readonly_ARG, '\0', "readonly", NULL, 0)
arg(atomic_ARG, '\0', "atomic", NULL, 0)
/* Allow some variations */ /* Allow some variations */
arg(resizable_ARG, '\0', "resizable", yes_no_arg, 0) arg(resizable_ARG, '\0', "resizable", yes_no_arg, 0)

View File

@ -764,9 +764,9 @@ xx(pvmove,
0, 0,
"pvmove " "\n" "pvmove " "\n"
"\t[--abort]\n" "\t[--abort]\n"
"\t[--alloc AllocationPolicy]\n"
"\t[--atomic]\n" "\t[--atomic]\n"
"\t[-A|--autobackup {y|n}]\n" "\t[-A|--autobackup {y|n}]\n"
"\t[--alloc AllocationPolicy]\n"
"\t[-b|--background]\n" "\t[-b|--background]\n"
"\t[--commandprofile ProfileName]\n" "\t[--commandprofile ProfileName]\n"
"\t[-d|--debug]\n " "\t[-d|--debug]\n "
@ -781,7 +781,7 @@ xx(pvmove,
"\tSourcePhysicalVolume[:PhysicalExtent[-PhysicalExtent]...]}\n" "\tSourcePhysicalVolume[:PhysicalExtent[-PhysicalExtent]...]}\n"
"\t[DestinationPhysicalVolume[:PhysicalExtent[-PhysicalExtent]...]...]\n", "\t[DestinationPhysicalVolume[:PhysicalExtent[-PhysicalExtent]...]...]\n",
abort_ARG, atomic_ARG, alloc_ARG, autobackup_ARG, background_ARG, abort_ARG, alloc_ARG, atomic_ARG, autobackup_ARG, background_ARG,
interval_ARG, name_ARG, noudevsync_ARG, test_ARG) interval_ARG, name_ARG, noudevsync_ARG, test_ARG)
xx(pvremove, xx(pvremove,

View File

@ -520,30 +520,28 @@ static int _activate_lv(struct cmd_context *cmd, struct logical_volume *lv_mirr,
static int _is_pvmove_image_removable(struct logical_volume *mimage_lv, static int _is_pvmove_image_removable(struct logical_volume *mimage_lv,
void *baton) void *baton)
{ {
uint32_t s = *((uint32_t *)baton); uint32_t mimage_to_remove = *((uint32_t *)baton);
struct lv_segment *mirror_seg; struct lv_segment *mirror_seg;
if (!(mirror_seg = get_only_segment_using_this_lv(mimage_lv))) { if (!(mirror_seg = get_only_segment_using_this_lv(mimage_lv))) {
log_error(INTERNAL_ERROR log_error(INTERNAL_ERROR "%s is not a proper mirror image",
"%s is not a proper mirror image",
mimage_lv->name); mimage_lv->name);
return 0; return 0;
} }
if (seg_type(mirror_seg, 0) != AREA_LV) { if (seg_type(mirror_seg, 0) != AREA_LV) {
log_error(INTERNAL_ERROR log_error(INTERNAL_ERROR "%s is not a pvmove mirror of LV-type",
"%s is not a pvmove mirror of LV-type",
mirror_seg->lv->name); mirror_seg->lv->name);
return 0; return 0;
} }
if (s > mirror_seg->area_count) { if (mimage_to_remove > mirror_seg->area_count) {
log_error(INTERNAL_ERROR log_error(INTERNAL_ERROR "Mirror image %" PRIu32 " not found in segment",
"Invalid segment number"); mimage_to_remove);
return 0; return 0;
} }
if (seg_lv(mirror_seg, s) == mimage_lv) if (seg_lv(mirror_seg, mimage_to_remove) == mimage_lv)
return 1; return 1;
return 0; return 0;
@ -552,7 +550,7 @@ static int _is_pvmove_image_removable(struct logical_volume *mimage_lv,
static int _detach_pvmove_mirror(struct cmd_context *cmd, static int _detach_pvmove_mirror(struct cmd_context *cmd,
struct logical_volume *lv_mirr) struct logical_volume *lv_mirr)
{ {
uint32_t s = 0; uint32_t mimage_to_remove = 0;
struct dm_list lvs_completed; struct dm_list lvs_completed;
struct lv_list *lvl; struct lv_list *lvl;
@ -561,10 +559,9 @@ static int _detach_pvmove_mirror(struct cmd_context *cmd,
if (arg_is_set(cmd, abort_ARG) && if (arg_is_set(cmd, abort_ARG) &&
(seg_type(first_seg(lv_mirr), 0) == AREA_LV)) (seg_type(first_seg(lv_mirr), 0) == AREA_LV))
s = 1; /* remove the second mirror leg */ mimage_to_remove = 1; /* remove the second mirror leg */
if (!lv_remove_mirrors(cmd, lv_mirr, 1, 0, if (!lv_remove_mirrors(cmd, lv_mirr, 1, 0, _is_pvmove_image_removable, &mimage_to_remove, PVMOVE) ||
_is_pvmove_image_removable, &s, PVMOVE) ||
!remove_layers_for_segments_all(cmd, lv_mirr, PVMOVE, !remove_layers_for_segments_all(cmd, lv_mirr, PVMOVE,
&lvs_completed)) { &lvs_completed)) {
return 0; return 0;