From: Dave Wysochanski Date: Tue, 12 Oct 2010 16:12:02 +0000 (+0000) Subject: Refactor and add code for (lv) 'move_pv' get function. X-Git-Tag: v2_02_91~1494 X-Git-Url: https://sourceware.org/git/?a=commitdiff_plain;h=af579eccc34be2943ef2be7de712a8a7f09b3df4;p=lvm2.git Refactor and add code for (lv) 'move_pv' get function. Signed-off-by: Dave Wysochanski Reviewed-By: Petr Rockai --- diff --git a/lib/metadata/lv.c b/lib/metadata/lv.c index 48707ff84..4ceb7136f 100644 --- a/lib/metadata/lv.c +++ b/lib/metadata/lv.c @@ -18,6 +18,17 @@ #include "activate.h" #include "toolcontext.h" +char *lv_move_pv_dup(struct dm_pool *mem, const struct logical_volume *lv) +{ + struct lv_segment *seg; + + dm_list_iterate_items(seg, &lv->segments) { + if (seg->status & PVMOVE) + return dm_pool_strdup(mem, dev_name(seg_dev(seg, 0))); + } + return NULL; +} + uint64_t lv_origin_size(const struct logical_volume *lv) { if (lv_is_cow(lv)) diff --git a/lib/metadata/lv.h b/lib/metadata/lv.h index 69c4077ac..bfb38f943 100644 --- a/lib/metadata/lv.h +++ b/lib/metadata/lv.h @@ -54,5 +54,6 @@ char *lv_uuid_dup(const struct logical_volume *lv); char *lv_tags_dup(const struct logical_volume *lv); char *lv_path_dup(struct dm_pool *mem, const struct logical_volume *lv); uint64_t lv_origin_size(const struct logical_volume *lv); +char *lv_move_pv_dup(struct dm_pool *mem, const struct logical_volume *lv); #endif diff --git a/lib/report/properties.c b/lib/report/properties.c index 27503a95f..bcec0c848 100644 --- a/lib/report/properties.c +++ b/lib/report/properties.c @@ -129,7 +129,7 @@ GET_LV_NUM_PROPERTY_FN(origin_size, lv_origin_size(lv)) #define _snap_percent_set _not_implemented_set #define _copy_percent_get _not_implemented_get #define _copy_percent_set _not_implemented_set -#define _move_pv_get _not_implemented_get +GET_LV_STR_PROPERTY_FN(move_pv, lv_move_pv_dup(lv->vg->vgmem, lv)) #define _move_pv_set _not_implemented_set #define _convert_lv_get _not_implemented_get #define _convert_lv_set _not_implemented_set diff --git a/lib/report/report.c b/lib/report/report.c index 83216b28a..26ff87951 100644 --- a/lib/report/report.c +++ b/lib/report/report.c @@ -378,16 +378,11 @@ static int _movepv_disp(struct dm_report *rh, struct dm_pool *mem __attribute__( { const struct logical_volume *lv = (const struct logical_volume *) data; const char *name; - struct lv_segment *seg; - dm_list_iterate_items(seg, &lv->segments) { - if (!(seg->status & PVMOVE)) - continue; - name = dev_name(seg_dev(seg, 0)); + if (!(name = lv_move_pv_dup(mem, lv))) + dm_report_field_set_value(field, "", NULL); + else return dm_report_field_string(rh, field, &name); - } - - dm_report_field_set_value(field, "", NULL); return 1; }