From bd4b840879307292793a811f2f2388b5125751d8 Mon Sep 17 00:00:00 2001 From: Zdenek Kabelac Date: Fri, 28 Oct 2011 20:12:54 +0000 Subject: [PATCH] Add last_seg Implement a function to return the last segment in a LV. Signed-off-by: Mikulas Patocka --- WHATS_NEW | 1 + lib/metadata/metadata-exported.h | 1 + lib/metadata/metadata.c | 10 ++++++++++ 3 files changed, 12 insertions(+) diff --git a/WHATS_NEW b/WHATS_NEW index 92d331992..02ef70098 100644 --- a/WHATS_NEW +++ b/WHATS_NEW @@ -1,5 +1,6 @@ Version 2.02.89 - ================================== + Add last_seg(lv) internal function. Support empty string for log/prefix. Fix regression that allowed mirrored logs for cluster mirrors. Don't print char type[8] as a plain string in pvck PV type. diff --git a/lib/metadata/metadata-exported.h b/lib/metadata/metadata-exported.h index c65fc8466..734cd061d 100644 --- a/lib/metadata/metadata-exported.h +++ b/lib/metadata/metadata-exported.h @@ -660,6 +660,7 @@ const char *find_vgname_from_pvid(struct cmd_context *cmd, const char *pvid); /* Find LV segment containing given LE */ struct lv_segment *first_seg(const struct logical_volume *lv); +struct lv_segment *last_seg(const struct logical_volume *lv); /* diff --git a/lib/metadata/metadata.c b/lib/metadata/metadata.c index bfdde8f52..21ff001ba 100644 --- a/lib/metadata/metadata.c +++ b/lib/metadata/metadata.c @@ -1906,6 +1906,16 @@ struct lv_segment *first_seg(const struct logical_volume *lv) return NULL; } +struct lv_segment *last_seg(const struct logical_volume *lv) +{ + struct lv_segment *seg; + + dm_list_iterate_back_items(seg, &lv->segments) + return seg; + + return NULL; +} + int vg_remove_mdas(struct volume_group *vg) { struct metadata_area *mda;