From 63368983189e6ea552fcaa0d867c9d7fe5e9c111 Mon Sep 17 00:00:00 2001 From: Zdenek Kabelac Date: Thu, 19 Jan 2012 15:25:37 +0000 Subject: [PATCH] Thin updated support for thin pool percent Support to check also for metadata percent (By checking whether seg pointer is set) --- lib/activate/activate.c | 9 ++++++--- lib/activate/activate.h | 3 ++- lib/activate/dev_manager.c | 6 +++--- lib/activate/dev_manager.h | 2 +- tools/lvresize.c | 13 +++++++++++-- 5 files changed, 23 insertions(+), 10 deletions(-) diff --git a/lib/activate/activate.c b/lib/activate/activate.c index a7eba268b..56dc37c2a 100644 --- a/lib/activate/activate.c +++ b/lib/activate/activate.c @@ -710,9 +710,11 @@ int lv_raid_percent(const struct logical_volume *lv, percent_t *percent) } /* + * Returns data or metadata percent usage, depends on metadata 0/1. * Returns 1 if percent set, else 0 on failure. */ -int lv_thin_pool_percent(const struct logical_volume *lv, percent_t *percent) +int lv_thin_pool_percent(const struct logical_volume *lv, int metadata, + percent_t *percent) { int r; struct dev_manager *dm; @@ -720,12 +722,13 @@ int lv_thin_pool_percent(const struct logical_volume *lv, percent_t *percent) if (!activation()) return 0; - log_debug("Checking thin pool percent for LV %s/%s", lv->vg->name, lv->name); + log_debug("Checking thin %sdata percent for LV %s/%s", + (metadata) ? "meta" : "", lv->vg->name, lv->name); if (!(dm = dev_manager_create(lv->vg->cmd, lv->vg->name, 1))) return_0; - if (!(r = dev_manager_thin_pool_percent(dm, lv, percent))) + if (!(r = dev_manager_thin_pool_percent(dm, lv, metadata, percent))) stack; dev_manager_destroy(dm); diff --git a/lib/activate/activate.h b/lib/activate/activate.h index 480c05d1f..64f2ecbee 100644 --- a/lib/activate/activate.h +++ b/lib/activate/activate.h @@ -101,7 +101,8 @@ int lv_snapshot_percent(const struct logical_volume *lv, percent_t *percent); int lv_mirror_percent(struct cmd_context *cmd, const struct logical_volume *lv, int wait, percent_t *percent, uint32_t *event_nr); int lv_raid_percent(const struct logical_volume *lv, percent_t *percent); -int lv_thin_pool_percent(const struct logical_volume *lv, percent_t *percent); +int lv_thin_pool_percent(const struct logical_volume *lv, int metadata, + percent_t *percent); /* * Return number of LVs in the VG that are active. diff --git a/lib/activate/dev_manager.c b/lib/activate/dev_manager.c index b853ebc2c..c04da5e31 100644 --- a/lib/activate/dev_manager.c +++ b/lib/activate/dev_manager.c @@ -874,7 +874,7 @@ static int _belong_to_vg(const char *vgname, const char *name) int dev_manager_thin_pool_percent(struct dev_manager *dm, const struct logical_volume *lv, - percent_t *percent) + int metadata, percent_t *percent) { char *name; const char *dlid; @@ -888,8 +888,8 @@ int dev_manager_thin_pool_percent(struct dev_manager *dm, return_0; log_debug("Getting device status percentage for %s", name); - if (!(_percent(dm, name, dlid, "thin-pool", 0, NULL, percent, - NULL, 1))) + if (!(_percent(dm, name, dlid, "thin-pool", 0, + (metadata) ? lv : NULL, percent, NULL, 1))) return_0; return 1; diff --git a/lib/activate/dev_manager.h b/lib/activate/dev_manager.h index 025131eaa..417981bd9 100644 --- a/lib/activate/dev_manager.h +++ b/lib/activate/dev_manager.h @@ -56,7 +56,7 @@ int dev_manager_mirror_percent(struct dev_manager *dm, percent_t *percent, uint32_t *event_nr); int dev_manager_thin_pool_percent(struct dev_manager *dm, const struct logical_volume *lv, - percent_t *percent); + int metadata, percent_t *percent); int dev_manager_suspend(struct dev_manager *dm, struct logical_volume *lv, struct lv_activate_opts *laopts, int lockfs, int flush_required); int dev_manager_activate(struct dev_manager *dm, struct logical_volume *lv, diff --git a/tools/lvresize.c b/tools/lvresize.c index 170a342bb..14637bf46 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-2011 Red Hat, Inc. All rights reserved. + * Copyright (C) 2004-2012 Red Hat, Inc. All rights reserved. * * This file is part of LVM2. * @@ -305,7 +305,16 @@ static int _adjust_policy_params(struct cmd_context *cmd, return 1; /* nothing to do */ if (lv_is_thin_pool(lv)) { - if (!lv_thin_pool_percent(lv, &percent)) + if (!lv_thin_pool_percent(lv, 1, &percent)) + return_0; + if (percent > policy_threshold) { + /* FIXME: metadata resize support missing */ + log_error("Resize for %s/%s is not yet supported.", + lp->vg_name, lp->lv_name); + return ECMD_FAILED; + } + + if (!lv_thin_pool_percent(lv, 0, &percent)) return_0; if (!(PERCENT_0 < percent && percent <= PERCENT_100) || percent <= policy_threshold)