From 23177b8aadc42c08d0c30420bc0b4ae08ca430d9 Mon Sep 17 00:00:00 2001 From: Zdenek Kabelac Date: Fri, 28 Oct 2011 20:31:01 +0000 Subject: [PATCH] Thin pool resize support for data LV Support for extension of pool data LV. TODO: figure out thin volume for suspend/resume in cluster. --- lib/metadata/lv_manip.c | 10 +++++++--- tools/lvresize.c | 25 ++++++++++++++++++++++++- 2 files changed, 31 insertions(+), 4 deletions(-) diff --git a/lib/metadata/lv_manip.c b/lib/metadata/lv_manip.c index c3f0b8f1d..2431751dd 100644 --- a/lib/metadata/lv_manip.c +++ b/lib/metadata/lv_manip.c @@ -2557,19 +2557,23 @@ int lv_extend(struct logical_volume *lv, if (segtype_is_virtual(segtype)) return lv_add_virtual_segment(lv, 0u, extents, segtype, thin_pool_name); - if (segtype_is_thin_pool(segtype)) + if (!lv->le_count && segtype_is_thin_pool(segtype)) + /* Thin pool allocation treats its metadata device like a mirror log. */ log_count = 1; else if (segtype_is_raid(segtype) && !lv->le_count) log_count = mirrors * stripes; - /* Thin pool allocation treats its metadata device like a mirror log. */ if (!(ah = allocate_extents(lv->vg, lv, segtype, stripes, mirrors, log_count, region_size, extents, allocatable_pvs, alloc, NULL))) return_0; if (segtype_is_thin_pool(segtype)) { - if (!(r = extend_pool(lv, segtype, ah))) + if (!lv->le_count) { + if (!(r = extend_pool(lv, segtype, ah))) + stack; + } else if (!(r = _lv_extend_layered_lv(ah, lv, extents, 0, + stripes, stripe_size))) stack; } else if (!segtype_is_mirrored(segtype) && !segtype_is_raid(segtype)) { if (!(r = lv_add_segment(ah, 0, ah->area_count, lv, segtype, diff --git a/tools/lvresize.c b/tools/lvresize.c index f4b81da34..96305525c 100644 --- a/tools/lvresize.c +++ b/tools/lvresize.c @@ -1,6 +1,6 @@ /* * Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved. - * Copyright (C) 2004-2009 Red Hat, Inc. All rights reserved. + * Copyright (C) 2004-2011 Red Hat, Inc. All rights reserved. * * This file is part of LVM2. * @@ -669,6 +669,25 @@ static int _lvresize(struct cmd_context *cmd, struct volume_group *vg, } } + if (lv_is_thin_pool(lv)) { + if (lp->resize == LV_REDUCE) { + log_error("Thin pool volumes cannot be reduced in size yet."); + return ECMD_FAILED; + } + + if (lp->resizefs) { + log_warn("Thin pool volumes do not have filesystem."); + lp->resizefs = 0; + } + + if (!lp->stripes) { + /* Try to use the same strip settings for underlying pool data LV */ + lp->stripes = last_seg(seg_lv(first_seg(lv), 0))->area_count; + if (!lp->stripe_size) + lp->stripe_size = last_seg(seg_lv(first_seg(lv), 0))->stripe_size; + } + } + if ((lp->resize == LV_REDUCE) && lp->argc) log_warn("Ignoring PVs on command line when reducing"); @@ -730,6 +749,10 @@ static int _lvresize(struct cmd_context *cmd, struct volume_group *vg, /* If snapshot, must suspend all associated devices */ if (lv_is_cow(lv)) lock_lv = origin_from_cow(lv); + else if (lv_is_used_thin_pool(lv)) + // FIXME: what to pick here - maybe an active thin? + // but it still seems to be racy in cluster + lock_lv = lv; else lock_lv = lv;