From 8e8baf89c0627e8eaacc44713f01a09b84bd0f3e Mon Sep 17 00:00:00 2001 From: Dave Wysochanski Date: Wed, 23 Apr 2008 14:33:06 +0000 Subject: [PATCH] Fix vgsplit internal counting of snapshot LVs. --- WHATS_NEW | 1 + lib/metadata/metadata-exported.h | 18 +++++++++++++++++- tools/vgsplit.c | 2 +- 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/WHATS_NEW b/WHATS_NEW index 0a2a3bb06..dc2d7d471 100644 --- a/WHATS_NEW +++ b/WHATS_NEW @@ -1,5 +1,6 @@ Version 2.02.36 - ================================= + Fix vgsplit internal counting of snapshot LVs. Fix internal snapshot_count when vgmerge with snapshots in source VG. Simply clvmd-openais by using non-async saLckResourceLock. Check lv_count in vg_validate. diff --git a/lib/metadata/metadata-exported.h b/lib/metadata/metadata-exported.h index dd04e5f6c..a3c89f6ae 100644 --- a/lib/metadata/metadata-exported.h +++ b/lib/metadata/metadata-exported.h @@ -202,7 +202,23 @@ struct volume_group { uint32_t pv_count; struct list pvs; - /* logical volumes */ + /* + * logical volumes + * The following relationship should always hold: + * list_size(lvs) = lv_count + 2 * snapshot_count + * + * Snapshots consist of 2 instances of "struct logical_volume": + * - cow (lv_name is visible to the user) + * - snapshot (lv_name is 'snapshotN') + * Neither of these instances is reflected in lv_count, but we + * multiply the snapshot_count by 2. + * + * Mirrors consist of multiple instances of "struct logical_volume": + * - one for the mirror log + * - one for each mirror leg + * - one for the user-visible mirror LV + * all of the instances are reflected in lv_count. + */ uint32_t lv_count; uint32_t snapshot_count; struct list lvs; diff --git a/tools/vgsplit.c b/tools/vgsplit.c index c0cb47632..50999281a 100644 --- a/tools/vgsplit.c +++ b/tools/vgsplit.c @@ -109,7 +109,7 @@ static int _move_one_lv(struct volume_group *vg_from, if (lv->status & SNAPSHOT) { vg_from->snapshot_count--; vg_to->snapshot_count++; - } else { + } else if (!lv_is_cow(lv)) { vg_from->lv_count--; vg_to->lv_count++; }