From 30c13eff3766eb49f925acabf836470b63d05903 Mon Sep 17 00:00:00 2001 From: Zdenek Kabelac Date: Tue, 15 Jan 2013 15:16:16 +0100 Subject: [PATCH] thin: report external origin Use the field 'origin' for reporting external origin lv name. For thin volumes with external origin, report the size of external origin size via: lvs -o+origin_size --- lib/display/display.c | 3 +++ lib/metadata/lv.c | 7 ++++++- lib/report/report.c | 3 +++ 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/lib/display/display.c b/lib/display/display.c index b15ff71c8..c0d0cd9c6 100644 --- a/lib/display/display.c +++ b/lib/display/display.c @@ -594,6 +594,9 @@ int lvdisplay_full(struct cmd_context *cmd, if (seg->origin) log_print("LV Thin origin name %s", seg->origin->name); + if (seg->external_lv) + log_print("LV External origin name %s", + seg->origin->name); if (inkernel) thin_active = lv_thin_percent(lv, 0, &thin_percent); } else if (lv_is_thin_pool(lv)) { diff --git a/lib/metadata/lv.c b/lib/metadata/lv.c index 9f6b3279d..f1c79be82 100644 --- a/lib/metadata/lv.c +++ b/lib/metadata/lv.c @@ -1,6 +1,6 @@ /* * Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved. - * Copyright (C) 2004-2012 Red Hat, Inc. All rights reserved. + * Copyright (C) 2004-2013 Red Hat, Inc. All rights reserved. * * This file is part of LVM2. * @@ -169,6 +169,9 @@ char *lv_origin_dup(struct dm_pool *mem, const struct logical_volume *lv) if (lv_is_thin_volume(lv) && first_seg(lv)->origin) return lv_name_dup(mem, first_seg(lv)->origin); + if (lv_is_thin_volume(lv) && first_seg(lv)->external_lv) + return lv_name_dup(mem, first_seg(lv)->external_lv); + return NULL; } @@ -282,6 +285,8 @@ uint64_t lv_origin_size(const struct logical_volume *lv) { if (lv_is_cow(lv)) return (uint64_t) find_cow(lv)->len * lv->vg->extent_size; + if (lv_is_thin_volume(lv) && first_seg(lv)->external_lv) + return first_seg(lv)->external_lv->size; if (lv_is_origin(lv)) return lv->size; return 0; diff --git a/lib/report/report.c b/lib/report/report.c index 5a4e4dfe6..633dfe4ad 100644 --- a/lib/report/report.c +++ b/lib/report/report.c @@ -343,6 +343,9 @@ static int _origin_disp(struct dm_report *rh, struct dm_pool *mem, if (lv_is_thin_volume(lv) && first_seg(lv)->origin) return _lvname_disp(rh, mem, field, first_seg(lv)->origin, private); + if (lv_is_thin_volume(lv) && first_seg(lv)->external_lv) + return _lvname_disp(rh, mem, field, first_seg(lv)->external_lv, private); + dm_report_field_set_value(field, "", NULL); return 1; }