master - cleanup: add arg to _setup_task
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=13e6369d7f3b44...
Commit: 13e6369d7f3b44b50e583e48868fb075a9f31757
Parent: cb931eed72e8618cfeefacaa3be1a4a2d5679d99
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Sun Nov 2 17:22:32 2014 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Mon Nov 3 14:19:33 2014 +0100
cleanup: add arg to _setup_task
Add init of no_open_count into _setup_task().
Report problem as warning (cannot happen anyway).
Also drop some duplicated debug messages - we have already
printed the info about operation so make log a bit shorter.
---
lib/activate/dev_manager.c | 67 +++++++++++--------------------------------
1 files changed, 17 insertions(+), 50 deletions(-)
diff --git a/lib/activate/dev_manager.c b/lib/activate/dev_manager.c
index 9956fd4..b7e496e 100644
--- a/lib/activate/dev_manager.c
+++ b/lib/activate/dev_manager.c
@@ -74,7 +74,8 @@ int read_only_lv(const struct logical_volume *lv, const struct lv_activate_opts
*/
static struct dm_task *_setup_task(const char *name, const char *uuid,
uint32_t *event_nr, int task,
- uint32_t major, uint32_t minor)
+ uint32_t major, uint32_t minor,
+ int with_open_count)
{
struct dm_task *dmt;
@@ -95,7 +96,10 @@ static struct dm_task *_setup_task(const char *name, const char *uuid,
if (activation_checks() && !dm_task_enable_checks(dmt))
goto_out;
-
+
+ if (!with_open_count && !dm_task_no_open_count(dmt))
+ log_warn("WARNING: Failed to disable open_count.");
+
return dmt;
out:
dm_task_destroy(dmt);
@@ -112,13 +116,10 @@ static int _info_run(const char *name, const char *dlid, struct dm_info *info,
dmtask = mknodes ? DM_DEVICE_MKNODES : DM_DEVICE_INFO;
- if (!(dmt = _setup_task(mknodes ? name : NULL, dlid, 0, dmtask, major, minor)))
+ if (!(dmt = _setup_task(mknodes ? name : NULL, dlid, 0, dmtask, major, minor,
+ with_open_count)))
return_0;
- if (!with_open_count &&
- !dm_task_no_open_count(dmt))
- log_warn("WARNING: Failed to disable open_count.");
-
if (!dm_task_run(dmt))
goto_out;
@@ -586,12 +587,9 @@ static int _status_run(const char *name, const char *uuid,
char *type = NULL;
char *params = NULL;
- if (!(dmt = _setup_task(name, uuid, 0, DM_DEVICE_STATUS, 0, 0)))
+ if (!(dmt = _setup_task(name, uuid, 0, DM_DEVICE_STATUS, 0, 0, 0)))
return_0;
- if (!dm_task_no_open_count(dmt))
- log_error("Failed to disable open_count");
-
if (!dm_task_run(dmt))
goto_out;
@@ -667,13 +665,9 @@ int lv_has_target_type(struct dm_pool *mem, const struct logical_volume *lv,
if (!(dlid = build_dm_uuid(mem, lv, layer)))
return_0;
- if (!(dmt = _setup_task(NULL, dlid, 0,
- DM_DEVICE_STATUS, 0, 0)))
+ if (!(dmt = _setup_task(NULL, dlid, 0, DM_DEVICE_STATUS, 0, 0, 0)))
goto_bad;
- if (!dm_task_no_open_count(dmt))
- log_error("Failed to disable open_count");
-
if (!dm_task_run(dmt))
goto_out;
@@ -777,12 +771,9 @@ static int _percent_run(struct dev_manager *dm, const char *name,
*overall_percent = percent;
if (!(dmt = _setup_task(name, dlid, event_nr,
- wait ? DM_DEVICE_WAITEVENT : DM_DEVICE_STATUS, 0, 0)))
+ wait ? DM_DEVICE_WAITEVENT : DM_DEVICE_STATUS, 0, 0, 0)))
return_0;
- if (!dm_task_no_open_count(dmt))
- log_error("Failed to disable open_count");
-
if (!dm_task_run(dmt))
goto_out;
@@ -898,12 +889,9 @@ int dev_manager_transient(struct dev_manager *dm, const struct logical_volume *l
if (!(dlid = build_dm_uuid(dm->mem, lv, layer)))
return_0;
- if (!(dmt = _setup_task(0, dlid, NULL, DM_DEVICE_STATUS, 0, 0)))
+ if (!(dmt = _setup_task(0, dlid, NULL, DM_DEVICE_STATUS, 0, 0, 0)))
return_0;
- if (!dm_task_no_open_count(dmt))
- log_error("Failed to disable open_count");
-
if (!dm_task_run(dmt))
goto_out;
@@ -1044,7 +1032,6 @@ int dev_manager_snapshot_percent(struct dev_manager *dm,
/*
* Try and get some info on this device.
*/
- log_debug_activation("Getting device status percentage for %s", name);
if (!_percent(dm, name, dlid, "snapshot", 0, NULL, percent,
NULL, fail_if_percent_unsupported))
return_0;
@@ -1100,14 +1087,9 @@ int dev_manager_raid_status(struct dev_manager *dm,
if (!(dlid = build_dm_uuid(dm->mem, lv, layer)))
return_0;
- log_debug_activation("Getting raid device status for %s.", lv->name);
-
- if (!(dmt = _setup_task(NULL, dlid, 0, DM_DEVICE_STATUS, 0, 0)))
+ if (!(dmt = _setup_task(NULL, dlid, 0, DM_DEVICE_STATUS, 0, 0, 0)))
return_0;
- if (!dm_task_no_open_count(dmt))
- log_error("Failed to disable open_count.");
-
if (!dm_task_run(dmt))
goto_out;
@@ -1164,12 +1146,9 @@ int dev_manager_raid_message(struct dev_manager *dm,
if (!(dlid = build_dm_uuid(dm->mem, lv, layer)))
return_0;
- if (!(dmt = _setup_task(NULL, dlid, 0, DM_DEVICE_TARGET_MSG, 0, 0)))
+ if (!(dmt = _setup_task(NULL, dlid, 0, DM_DEVICE_TARGET_MSG, 0, 0, 0)))
return_0;
- if (!dm_task_no_open_count(dmt))
- log_error("Failed to disable open_count.");
-
if (!dm_task_set_message(dmt, msg))
goto_out;
@@ -1199,14 +1178,9 @@ int dev_manager_cache_status(struct dev_manager *dm,
if (!(dlid = build_dm_uuid(dm->mem, lv, layer)))
return_0;
- log_debug_activation("Getting cache device status for %s.", lv->name);
-
- if (!(dmt = _setup_task(NULL, dlid, 0, DM_DEVICE_STATUS, 0, 0)))
+ if (!(dmt = _setup_task(NULL, dlid, 0, DM_DEVICE_STATUS, 0, 0, 0)))
return_0;
- if (!dm_task_no_open_count(dmt))
- log_error("Failed to disable open_count.");
-
if (!dm_task_run(dmt))
goto_out;
@@ -1308,14 +1282,9 @@ int dev_manager_thin_pool_status(struct dev_manager *dm,
if (!(dlid = build_dm_uuid(dm->mem, lv, lv_layer(lv))))
return_0;
- log_debug_activation("Getting thin pool device status for %s.", lv->name);
-
- if (!(dmt = _setup_task(NULL, dlid, 0, DM_DEVICE_STATUS, 0, 0)))
+ if (!(dmt = _setup_task(NULL, dlid, 0, DM_DEVICE_STATUS, 0, 0, 0)))
return_0;
- if (!dm_task_no_open_count(dmt))
- log_error("Failed to disable open_count.");
-
if (noflush && !dm_task_no_flush(dmt))
log_warn("Can't set no_flush.");
@@ -1400,9 +1369,7 @@ int dev_manager_thin_device_id(struct dev_manager *dm,
if (!(dlid = build_dm_uuid(dm->mem, lv, lv_layer(lv))))
return_0;
- log_debug_activation("Getting device id for %s.", dlid);
-
- if (!(dmt = _setup_task(NULL, dlid, 0, DM_DEVICE_TABLE, 0, 0)))
+ if (!(dmt = _setup_task(NULL, dlid, 0, DM_DEVICE_TABLE, 0, 0, 0)))
return_0;
if (!dm_task_run(dmt))
9 years, 4 months
master - cleanup: rename virtual_extents
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=cb931eed72e861...
Commit: cb931eed72e8618cfeefacaa3be1a4a2d5679d99
Parent: 913f025d3e481fc4ffe6ab7b29f7e7b27c0f1b19
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Fri Oct 31 11:33:19 2014 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Mon Nov 3 14:19:33 2014 +0100
cleanup: rename virtual_extents
Use standard 'virtual_extents' naming.
Move virtual_size into 'lcp' struct out of lvcreate_params.
---
lib/metadata/lv_manip.c | 12 ++++++------
lib/metadata/metadata-exported.h | 3 +--
liblvm/lvm_lv.c | 35 ++++++++++++++++-------------------
tools/lvconvert.c | 3 +--
tools/lvcreate.c | 7 ++++---
5 files changed, 28 insertions(+), 32 deletions(-)
diff --git a/lib/metadata/lv_manip.c b/lib/metadata/lv_manip.c
index e5b36df..a42a7f5 100644
--- a/lib/metadata/lv_manip.c
+++ b/lib/metadata/lv_manip.c
@@ -6745,7 +6745,7 @@ static struct logical_volume *_lv_create_an_lv(struct volume_group *vg,
return NULL;
}
- lp->voriginextents = origin_lv->le_count;
+ lp->virtual_extents = origin_lv->le_count;
/*
* Check if using 'external origin' or the 'normal' snapshot
@@ -6765,7 +6765,7 @@ static struct logical_volume *_lv_create_an_lv(struct volume_group *vg,
}
}
} else if (lp->snapshot) {
- if (!lp->voriginsize) {
+ if (!lp->virtual_extents) {
if (!origin_lv) {
log_error("Couldn't find origin volume '%s'.",
lp->origin_name);
@@ -6868,7 +6868,7 @@ static struct logical_volume *_lv_create_an_lv(struct volume_group *vg,
lp->stripes, lp->stripe_size,
lp->mirrors,
seg_is_pool(lp) ? lp->pool_metadata_extents : lp->region_size,
- seg_is_thin_volume(lp) ? lp->voriginextents : lp->extents,
+ seg_is_thin_volume(lp) ? lp->virtual_extents : lp->extents,
lp->pvh, lp->alloc, lp->approx_alloc))
return_NULL;
@@ -7080,7 +7080,7 @@ static struct logical_volume *_lv_create_an_lv(struct volume_group *vg,
* if origin is real (not virtual) inactive device.
*/
if ((vg_is_clustered(vg) ||
- (!lp->voriginsize && !lv_is_active(origin_lv))) &&
+ (!lp->virtual_extents && !lv_is_active(origin_lv))) &&
!deactivate_lv(cmd, lv)) {
log_error("Aborting. Couldn't deactivate snapshot COW area. "
"Manual intervention required.");
@@ -7088,10 +7088,10 @@ static struct logical_volume *_lv_create_an_lv(struct volume_group *vg,
}
/* A virtual origin must be activated explicitly. */
- if (lp->voriginsize) {
+ if (lp->virtual_extents) {
if (!(origin_lv = _create_virtual_origin(cmd, vg, lv->name,
lp->permission,
- lp->voriginextents))) {
+ lp->virtual_extents))) {
stack;
goto deactivate_and_revert_new_lv;
}
diff --git a/lib/metadata/metadata-exported.h b/lib/metadata/metadata-exported.h
index ecab56e..39d91a1 100644
--- a/lib/metadata/metadata-exported.h
+++ b/lib/metadata/metadata-exported.h
@@ -857,12 +857,11 @@ struct lvcreate_params {
/* size */
uint32_t extents; /* all */
- uint32_t voriginextents; /* snapshot */
- uint64_t voriginsize; /* snapshot */
uint32_t pool_metadata_extents; /* pools */
uint64_t pool_metadata_size; /* pools */
uint32_t pool_data_extents; /* pools */
uint64_t pool_data_size; /* pools */
+ uint32_t virtual_extents; /* snapshots, thins */
struct dm_list *pvh; /* all */
uint64_t permission; /* all */
diff --git a/liblvm/lvm_lv.c b/liblvm/lvm_lv.c
index 49737d5..33af348 100644
--- a/liblvm/lvm_lv.c
+++ b/liblvm/lvm_lv.c
@@ -498,6 +498,8 @@ static int _lv_set_pool_params(struct lvcreate_params *lp,
vg_t vg, const char *pool_name,
uint64_t extents, uint64_t meta_size)
{
+ uint64_t pool_metadata_size;
+
_lv_set_default_params(lp, vg, pool_name, extents);
lp->create_pool = 1;
@@ -505,23 +507,23 @@ static int _lv_set_pool_params(struct lvcreate_params *lp,
lp->stripes = 1;
if (!meta_size) {
- lp->pool_metadata_size = extents * vg->extent_size /
+ pool_metadata_size = extents * vg->extent_size /
(lp->chunk_size * (SECTOR_SIZE / 64));
- while ((lp->pool_metadata_size >
+ while ((pool_metadata_size >
(2 * DEFAULT_THIN_POOL_OPTIMAL_SIZE / SECTOR_SIZE)) &&
lp->chunk_size < DM_THIN_MAX_DATA_BLOCK_SIZE) {
lp->chunk_size <<= 1;
- lp->pool_metadata_size >>= 1;
+ pool_metadata_size >>= 1;
}
} else
- lp->pool_metadata_size = meta_size;
+ pool_metadata_size = meta_size;
- if (lp->pool_metadata_size % vg->extent_size)
- lp->pool_metadata_size +=
- vg->extent_size - lp->pool_metadata_size % vg->extent_size;
+ if (pool_metadata_size % vg->extent_size)
+ pool_metadata_size +=
+ vg->extent_size - pool_metadata_size % vg->extent_size;
if (!(lp->pool_metadata_extents =
- extents_from_size(vg->cmd, lp->pool_metadata_size / SECTOR_SIZE,
+ extents_from_size(vg->cmd, pool_metadata_size / SECTOR_SIZE,
vg->extent_size)))
return_0;
@@ -602,20 +604,15 @@ lv_create_params_t lvm_lv_params_create_thin_pool(vg_t vg,
/* Set defaults for thin LV specific parameters */
static int _lv_set_thin_params(struct lvcreate_params *lp,
- vg_t vg, const char *pool_name,
- const char *lvname,
- uint64_t extents)
+ vg_t vg, const char *pool_name,
+ const char *lvname,
+ uint32_t extents)
{
- _lv_set_default_params(lp, vg, lvname, extents);
+ _lv_set_default_params(lp, vg, lvname, 0);
lp->pool_name = pool_name;
lp->segtype = get_segtype_from_string(vg->cmd, "thin");
-
- lp->voriginsize = extents * vg->extent_size;
- if (!(lp->voriginextents = extents_from_size(vg->cmd, lp->voriginsize,
- vg->extent_size)))
- return_0;
-
+ lp->virtual_extents = extents;
lp->stripes = 1;
return 1;
@@ -698,7 +695,7 @@ static lv_create_params_t _lvm_lv_params_create_thin(const vg_t vg,
const char *lvname, uint64_t size)
{
struct lvm_lv_create_params *lvcp = NULL;
- uint64_t extents = 0;
+ uint32_t extents = 0;
/* precondition checks */
if (vg_read_error(vg))
diff --git a/tools/lvconvert.c b/tools/lvconvert.c
index fbd8b04..f2eb5f5 100644
--- a/tools/lvconvert.c
+++ b/tools/lvconvert.c
@@ -2640,8 +2640,7 @@ static int _lvconvert_thin(struct cmd_context *cmd,
.pvh = &vg->pvs,
.read_ahead = DM_READ_AHEAD_AUTO,
.stripes = 1,
- .voriginextents = lv->le_count,
- .voriginsize = lv->size,
+ .virtual_extents = lv->le_count,
};
if (lv == pool_lv) {
diff --git a/tools/lvcreate.c b/tools/lvcreate.c
index 2e01561..2cbfbe5 100644
--- a/tools/lvcreate.c
+++ b/tools/lvcreate.c
@@ -20,6 +20,7 @@
struct lvcreate_cmdline_params {
percent_type_t percent;
uint64_t size;
+ uint64_t virtual_size; /* snapshot, thin */
char **pvs;
uint32_t pv_count;
};
@@ -251,8 +252,8 @@ static int _update_extents_params(struct volume_group *vg,
vg->extent_size)))
return_0;
- if (lp->voriginsize &&
- !(lp->voriginextents = extents_from_size(vg->cmd, lp->voriginsize,
+ if (lcp->virtual_size &&
+ !(lp->virtual_extents = extents_from_size(vg->cmd, lcp->virtual_size,
vg->extent_size)))
return_0;
@@ -406,7 +407,7 @@ static int _read_size_params(struct cmd_context *cmd,
-1))
return_0;
- lp->voriginsize = arg_uint64_value(cmd, virtualsize_ARG, UINT64_C(0));
+ lcp->virtual_size = arg_uint64_value(cmd, virtualsize_ARG, UINT64_C(0));
if (arg_count(cmd, extents_ARG)) {
if (arg_count(cmd, size_ARG)) {
9 years, 4 months
master - cleanup: use extents to pass size to /lib
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=913f025d3e481f...
Commit: 913f025d3e481fc4ffe6ab7b29f7e7b27c0f1b19
Parent: d2e9802ba7eb48af8d78cee2420897201d57c406
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Thu Oct 30 13:04:06 2014 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Mon Nov 3 14:19:33 2014 +0100
cleanup: use extents to pass size to /lib
Lib takes sizes in extens - do the same for pool_metadata.
---
lib/metadata/cache_manip.c | 27 +++++++++++++---------
lib/metadata/metadata-exported.h | 14 ++++++------
lib/metadata/pool_manip.c | 19 +++++++---------
lib/metadata/thin_manip.c | 44 +++++++++++++++++++++----------------
tools/lvconvert.c | 10 +++++++-
tools/lvcreate.c | 10 +++++---
6 files changed, 70 insertions(+), 54 deletions(-)
diff --git a/lib/metadata/cache_manip.c b/lib/metadata/cache_manip.c
index bff64a3..eba7a50 100644
--- a/lib/metadata/cache_manip.c
+++ b/lib/metadata/cache_manip.c
@@ -41,12 +41,13 @@ const char *get_cachepool_cachemode_name(const struct lv_segment *seg)
int update_cache_pool_params(const struct segment_type *segtype,
struct volume_group *vg, unsigned attr,
- int passed_args, uint32_t data_extents,
- uint64_t *pool_metadata_size,
+ int passed_args, uint32_t pool_data_extents,
+ uint32_t *pool_metadata_extents,
int *chunk_size_calc_method, uint32_t *chunk_size)
{
uint64_t min_meta_size;
uint32_t extent_size = vg->extent_size;
+ uint64_t pool_metadata_size = *pool_metadata_extents * vg->extent_size;
if (!(passed_args & PASS_ARG_CHUNK_SIZE))
*chunk_size = DEFAULT_CACHE_POOL_CHUNK_SIZE * 2;
@@ -58,7 +59,7 @@ int update_cache_pool_params(const struct segment_type *segtype,
* Default meta size is:
* (Overhead + mapping size + hint size)
*/
- min_meta_size = (uint64_t) data_extents * extent_size / *chunk_size; /* nr_chunks */
+ min_meta_size = (uint64_t) pool_data_extents * extent_size / *chunk_size; /* nr_chunks */
min_meta_size *= (DM_BYTES_PER_BLOCK + DM_MAX_HINT_WIDTH + DM_HINT_OVERHEAD_PER_BLOCK);
min_meta_size = (min_meta_size + (SECTOR_SIZE - 1)) >> SECTOR_SHIFT; /* in sectors */
min_meta_size += DM_TRANSACTION_OVERHEAD * (1024 >> SECTOR_SHIFT);
@@ -67,23 +68,27 @@ int update_cache_pool_params(const struct segment_type *segtype,
if (min_meta_size % extent_size)
min_meta_size += extent_size - min_meta_size % extent_size;
- if (!*pool_metadata_size)
- *pool_metadata_size = min_meta_size;
+ if (!pool_metadata_size)
+ pool_metadata_size = min_meta_size;
- if (*pool_metadata_size > (2 * DEFAULT_CACHE_POOL_MAX_METADATA_SIZE)) {
- *pool_metadata_size = 2 * DEFAULT_CACHE_POOL_MAX_METADATA_SIZE;
+ if (pool_metadata_size > (2 * DEFAULT_CACHE_POOL_MAX_METADATA_SIZE)) {
+ pool_metadata_size = 2 * DEFAULT_CACHE_POOL_MAX_METADATA_SIZE;
if (passed_args & PASS_ARG_POOL_METADATA_SIZE)
log_warn("WARNING: Maximum supported pool metadata size is %s.",
- display_size(vg->cmd, *pool_metadata_size));
- } else if (*pool_metadata_size < min_meta_size) {
+ display_size(vg->cmd, pool_metadata_size));
+ } else if (pool_metadata_size < min_meta_size) {
if (passed_args & PASS_ARG_POOL_METADATA_SIZE)
log_warn("WARNING: Minimum required pool metadata size is %s "
"(needs extra %s).",
display_size(vg->cmd, min_meta_size),
- display_size(vg->cmd, min_meta_size - *pool_metadata_size));
- *pool_metadata_size = min_meta_size;
+ display_size(vg->cmd, min_meta_size - pool_metadata_size));
+ pool_metadata_size = min_meta_size;
}
+ if (!(*pool_metadata_extents =
+ extents_from_size(vg->cmd, pool_metadata_size, extent_size)))
+ return_0;
+
return 1;
}
diff --git a/lib/metadata/metadata-exported.h b/lib/metadata/metadata-exported.h
index 723a9c1..ecab56e 100644
--- a/lib/metadata/metadata-exported.h
+++ b/lib/metadata/metadata-exported.h
@@ -748,8 +748,8 @@ int validate_pool_chunk_size(struct cmd_context *cmd, const struct segment_type
int update_pool_lv(struct logical_volume *lv, int activate);
int update_pool_params(const struct segment_type *segtype,
struct volume_group *vg, unsigned target_attr,
- int passed_args, uint32_t data_extents,
- uint64_t *pool_metadata_size,
+ int passed_args, uint32_t pool_data_extents,
+ uint32_t *pool_metadata_extents,
int *chunk_size_calc_policy, uint32_t *chunk_size,
thin_discards_t *discards, int *zero);
int update_profilable_pool_params(struct cmd_context *cmd, struct profile *profile,
@@ -758,8 +758,8 @@ int update_profilable_pool_params(struct cmd_context *cmd, struct profile *profi
int *zero);
int update_thin_pool_params(const struct segment_type *segtype,
struct volume_group *vg, unsigned attr,
- int passed_args, uint32_t data_extents,
- uint64_t *pool_metadata_size,
+ int passed_args, uint32_t pool_data_extents,
+ uint32_t *pool_metadata_extents,
int *chunk_size_calc_method, uint32_t *chunk_size,
thin_discards_t *discards, int *zero);
int get_pool_discards(const char *str, thin_discards_t *discards);
@@ -767,7 +767,7 @@ const char *get_pool_discards_name(thin_discards_t discards);
struct logical_volume *alloc_pool_metadata(struct logical_volume *pool_lv,
const char *name, uint32_t read_ahead,
uint32_t stripes, uint32_t stripe_size,
- uint64_t size, alloc_policy_t alloc,
+ uint32_t extents, alloc_policy_t alloc,
struct dm_list *pvh);
int handle_pool_metadata_spare(struct volume_group *vg, uint32_t extents,
struct dm_list *pvh, int poolmetadataspare);
@@ -1090,8 +1090,8 @@ int partial_raid_lv_supports_degraded_activation(const struct logical_volume *lv
const char *get_cachepool_cachemode_name(const struct lv_segment *seg);
int update_cache_pool_params(const struct segment_type *segtype,
struct volume_group *vg, unsigned attr,
- int passed_args, uint32_t data_extents,
- uint64_t *pool_metadata_size,
+ int passed_args, uint32_t pool_data_extents,
+ uint32_t *pool_metadata_extents,
int *chunk_size_calc_method, uint32_t *chunk_size);
int validate_lv_cache_create_pool(const struct logical_volume *pool_lv);
int validate_lv_cache_create_origin(const struct logical_volume *origin_lv);
diff --git a/lib/metadata/pool_manip.c b/lib/metadata/pool_manip.c
index c7c07e5..7152c51 100644
--- a/lib/metadata/pool_manip.c
+++ b/lib/metadata/pool_manip.c
@@ -363,30 +363,30 @@ int recalculate_pool_chunk_size_with_dev_hints(struct logical_volume *pool_lv,
int update_pool_params(const struct segment_type *segtype,
struct volume_group *vg, unsigned target_attr,
- int passed_args, uint32_t data_extents,
- uint64_t *pool_metadata_size,
+ int passed_args, uint32_t pool_data_extents,
+ uint32_t *pool_metadata_extents,
int *chunk_size_calc_policy, uint32_t *chunk_size,
thin_discards_t *discards, int *zero)
{
if (segtype_is_cache_pool(segtype) || segtype_is_cache(segtype)) {
if (!update_cache_pool_params(segtype, vg, target_attr, passed_args,
- data_extents, pool_metadata_size,
+ pool_data_extents, pool_metadata_extents,
chunk_size_calc_policy, chunk_size))
return_0;
} else if (!update_thin_pool_params(segtype, vg, target_attr, passed_args,
- data_extents, pool_metadata_size,
+ pool_data_extents, pool_metadata_extents,
chunk_size_calc_policy, chunk_size,
discards, zero)) /* thin-pool */
return_0;
- if ((uint64_t) *chunk_size > (uint64_t) data_extents * vg->extent_size) {
+ if ((uint64_t) *chunk_size > (uint64_t) pool_data_extents * vg->extent_size) {
log_error("Size of %s data volume cannot be smaller then chunk size %s.",
segtype->name, display_size(vg->cmd, *chunk_size));
return 0;
}
log_verbose("Using pool metadata size %s.",
- display_size(vg->cmd, *pool_metadata_size));
+ display_size(vg->cmd, (uint64_t)*pool_metadata_extents * vg->extent_size));
return 1;
}
@@ -518,7 +518,7 @@ bad:
struct logical_volume *alloc_pool_metadata(struct logical_volume *pool_lv,
const char *name, uint32_t read_ahead,
uint32_t stripes, uint32_t stripe_size,
- uint64_t size, alloc_policy_t alloc,
+ uint32_t extents, alloc_policy_t alloc,
struct dm_list *pvh)
{
struct logical_volume *metadata_lv;
@@ -526,6 +526,7 @@ struct logical_volume *alloc_pool_metadata(struct logical_volume *pool_lv,
struct lvcreate_params lvc = {
.activate = CHANGE_ALY,
.alloc = alloc,
+ .extents = extents,
.major = -1,
.minor = -1,
.permission = LVM_READ | LVM_WRITE,
@@ -538,10 +539,6 @@ struct logical_volume *alloc_pool_metadata(struct logical_volume *pool_lv,
.zero = 1,
};
- if (!(lvc.extents = extents_from_size(pool_lv->vg->cmd, size,
- pool_lv->vg->extent_size)))
- return_0;
-
if (!(lvc.segtype = get_segtype_from_string(pool_lv->vg->cmd, "striped")))
return_0;
diff --git a/lib/metadata/thin_manip.c b/lib/metadata/thin_manip.c
index b830350..8569ac1 100644
--- a/lib/metadata/thin_manip.c
+++ b/lib/metadata/thin_manip.c
@@ -396,14 +396,16 @@ int update_pool_lv(struct logical_volume *lv, int activate)
int update_thin_pool_params(const struct segment_type *segtype,
struct volume_group *vg,
- unsigned attr, int passed_args, uint32_t data_extents,
- uint64_t *pool_metadata_size,
+ unsigned attr, int passed_args,
+ uint32_t pool_data_extents,
+ uint32_t *pool_metadata_extents,
int *chunk_size_calc_method, uint32_t *chunk_size,
thin_discards_t *discards, int *zero)
{
struct cmd_context *cmd = vg->cmd;
struct profile *profile = vg->profile;
uint32_t extent_size = vg->extent_size;
+ uint64_t pool_metadata_size = (uint64_t) *pool_metadata_extents * extent_size;
size_t estimate_chunk_size;
const char *str;
@@ -447,34 +449,34 @@ int update_thin_pool_params(const struct segment_type *segtype,
return 0;
}
- if (!*pool_metadata_size) {
+ if (!pool_metadata_size) {
/* Defaults to nr_pool_blocks * 64b converted to size in sectors */
- *pool_metadata_size = (uint64_t) data_extents * extent_size /
+ pool_metadata_size = (uint64_t) pool_data_extents * extent_size /
(*chunk_size * (SECTOR_SIZE / UINT64_C(64)));
/* Check if we could eventually use bigger chunk size */
if (!(passed_args & PASS_ARG_CHUNK_SIZE)) {
- while ((*pool_metadata_size >
+ while ((pool_metadata_size >
(DEFAULT_THIN_POOL_OPTIMAL_SIZE / SECTOR_SIZE)) &&
(*chunk_size < DM_THIN_MAX_DATA_BLOCK_SIZE)) {
*chunk_size <<= 1;
- *pool_metadata_size >>= 1;
+ pool_metadata_size >>= 1;
}
log_verbose("Setting chunk size to %s.",
display_size(cmd, *chunk_size));
- } else if (*pool_metadata_size > (DEFAULT_THIN_POOL_MAX_METADATA_SIZE * 2)) {
+ } else if (pool_metadata_size > (DEFAULT_THIN_POOL_MAX_METADATA_SIZE * 2)) {
/* Suggest bigger chunk size */
- estimate_chunk_size = (uint64_t) data_extents * extent_size /
+ estimate_chunk_size = (uint64_t) pool_data_extents * extent_size /
(DEFAULT_THIN_POOL_MAX_METADATA_SIZE * 2 * (SECTOR_SIZE / UINT64_C(64)));
log_warn("WARNING: Chunk size is too small for pool, suggested minimum is %s.",
display_size(cmd, UINT64_C(1) << (ffs(estimate_chunk_size) + 1)));
}
- /* Round up to extent size */
- if (*pool_metadata_size % extent_size)
- *pool_metadata_size += extent_size - *pool_metadata_size % extent_size;
+ /* Round up to extent size silently */
+ if (pool_metadata_size % extent_size)
+ pool_metadata_size += extent_size - pool_metadata_size % extent_size;
} else {
- estimate_chunk_size = (uint64_t) data_extents * extent_size /
- (*pool_metadata_size * (SECTOR_SIZE / UINT64_C(64)));
+ estimate_chunk_size = (uint64_t) pool_data_extents * extent_size /
+ (pool_metadata_size * (SECTOR_SIZE / UINT64_C(64)));
if (estimate_chunk_size < DM_THIN_MIN_DATA_BLOCK_SIZE)
estimate_chunk_size = DM_THIN_MIN_DATA_BLOCK_SIZE;
else if (estimate_chunk_size > DM_THIN_MAX_DATA_BLOCK_SIZE)
@@ -491,18 +493,22 @@ int update_thin_pool_params(const struct segment_type *segtype,
}
}
- if (*pool_metadata_size > (2 * DEFAULT_THIN_POOL_MAX_METADATA_SIZE)) {
- *pool_metadata_size = 2 * DEFAULT_THIN_POOL_MAX_METADATA_SIZE;
+ if (pool_metadata_size > (2 * DEFAULT_THIN_POOL_MAX_METADATA_SIZE)) {
+ pool_metadata_size = 2 * DEFAULT_THIN_POOL_MAX_METADATA_SIZE;
if (passed_args & PASS_ARG_POOL_METADATA_SIZE)
log_warn("WARNING: Maximum supported pool metadata size is %s.",
- display_size(cmd, *pool_metadata_size));
- } else if (*pool_metadata_size < (2 * DEFAULT_THIN_POOL_MIN_METADATA_SIZE)) {
- *pool_metadata_size = 2 * DEFAULT_THIN_POOL_MIN_METADATA_SIZE;
+ display_size(cmd, pool_metadata_size));
+ } else if (pool_metadata_size < (2 * DEFAULT_THIN_POOL_MIN_METADATA_SIZE)) {
+ pool_metadata_size = 2 * DEFAULT_THIN_POOL_MIN_METADATA_SIZE;
if (passed_args & PASS_ARG_POOL_METADATA_SIZE)
log_warn("WARNING: Minimum supported pool metadata size is %s.",
- display_size(cmd, *pool_metadata_size));
+ display_size(cmd, pool_metadata_size));
}
+ if (!(*pool_metadata_extents =
+ extents_from_size(vg->cmd, pool_metadata_size, extent_size)))
+ return_0;
+
return 1;
}
diff --git a/tools/lvconvert.c b/tools/lvconvert.c
index a512709..fbd8b04 100644
--- a/tools/lvconvert.c
+++ b/tools/lvconvert.c
@@ -65,6 +65,7 @@ struct lvconvert_params {
struct logical_volume *lv_to_poll;
+ uint32_t pool_metadata_extents;
int passed_args;
uint64_t pool_metadata_size;
const char *origin_name;
@@ -2743,12 +2744,17 @@ revert_new_lv:
static int _lvconvert_update_pool_params(struct logical_volume *pool_lv,
struct lvconvert_params *lp)
{
+ if (lp->pool_metadata_size &&
+ !(lp->pool_metadata_extents =
+ extents_from_size(pool_lv->vg->cmd, lp->pool_metadata_size, pool_lv->vg->extent_size)))
+ return_0;
+
return update_pool_params(lp->segtype,
pool_lv->vg,
lp->target_attr,
lp->passed_args,
pool_lv->le_count,
- &lp->pool_metadata_size,
+ &lp->pool_metadata_extents,
&lp->thin_chunk_size_calc_policy,
&lp->chunk_size,
&lp->discards,
@@ -3014,7 +3020,7 @@ static int _lvconvert_pool(struct cmd_context *cmd,
if (!(metadata_lv = alloc_pool_metadata(pool_lv, metadata_name,
lp->read_ahead, lp->stripes,
lp->stripe_size,
- lp->pool_metadata_size,
+ lp->pool_metadata_extents,
lp->alloc, lp->pvh)))
return_0;
} else {
diff --git a/tools/lvcreate.c b/tools/lvcreate.c
index b6768ba..2e01561 100644
--- a/tools/lvcreate.c
+++ b/tools/lvcreate.c
@@ -350,16 +350,18 @@ static int _update_extents_params(struct volume_group *vg,
}
if (lp->create_pool) {
+ if (lp->pool_metadata_size &&
+ !(lp->pool_metadata_extents =
+ extents_from_size(vg->cmd, lp->pool_metadata_size, vg->extent_size)))
+ return_0;
+
if (!update_pool_params(lp->segtype, vg, lp->target_attr,
lp->passed_args, lp->extents,
- &lp->pool_metadata_size,
+ &lp->pool_metadata_extents,
&lp->thin_chunk_size_calc_policy, &lp->chunk_size,
&lp->discards, &lp->zero))
return_0;
- if (!(lp->pool_metadata_extents =
- extents_from_size(vg->cmd, lp->pool_metadata_size, vg->extent_size)))
- return_0;
if (lcp->percent == PERCENT_FREE) {
if (lp->extents <= (2 * lp->pool_metadata_extents)) {
log_error("Not enough space for thin pool creation.");
9 years, 4 months
master - cache: add wipe_cache_pool
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=d2e9802ba7eb48...
Commit: d2e9802ba7eb48af8d78cee2420897201d57c406
Parent: 0b7335f84717743bf9c3f9ea9cafff279dff8672
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Sun Nov 2 18:36:41 2014 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Mon Nov 3 14:19:33 2014 +0100
cache: add wipe_cache_pool
Add function for wiping cache pool volume.
Only unused cache-pool could be wiped.
---
lib/metadata/cache_manip.c | 41 ++++++++++++++++++++++++++++++++++++++
lib/metadata/metadata-exported.h | 1 +
2 files changed, 42 insertions(+), 0 deletions(-)
diff --git a/lib/metadata/cache_manip.c b/lib/metadata/cache_manip.c
index e59a32f..bff64a3 100644
--- a/lib/metadata/cache_manip.c
+++ b/lib/metadata/cache_manip.c
@@ -369,3 +369,44 @@ int lv_is_cache_origin(const struct logical_volume *lv)
seg = get_only_segment_using_this_lv(lv);
return seg && lv_is_cache(seg->lv) && (seg_lv(seg, 0) == lv);
}
+
+/*
+ * Wipe cache pool metadata area before use.
+ *
+ * Activates metadata volume as 'cache-pool' so regular wiping
+ * of existing visible volume may proceed.
+ */
+int wipe_cache_pool(struct logical_volume *cache_pool_lv)
+{
+ int r;
+
+ /* Only unused cache-pool could be activated and wiped */
+ if (!lv_is_cache_pool(cache_pool_lv) ||
+ !dm_list_empty(&cache_pool_lv->segs_using_this_lv)) {
+ log_error(INTERNAL_ERROR "Failed to wipe cache pool for volume %s.",
+ display_lvname(cache_pool_lv));
+ return 0;
+ }
+
+ cache_pool_lv->status |= LV_TEMPORARY;
+ if (!activate_lv_local(cache_pool_lv->vg->cmd, cache_pool_lv)) {
+ log_error("Aborting. Failed to activate cache pool %s.",
+ display_lvname(cache_pool_lv));
+ return 0;
+ }
+ cache_pool_lv->status &= ~LV_TEMPORARY;
+ if (!(r = wipe_lv(cache_pool_lv, (struct wipe_params) { .do_zero = 1 }))) {
+ log_error("Aborting. Failed to wipe cache pool %s.",
+ display_lvname(cache_pool_lv));
+ /* Delay return of error after deactivation */
+ }
+
+ /* Deactivate cleared cache-pool metadata */
+ if (!deactivate_lv(cache_pool_lv->vg->cmd, cache_pool_lv)) {
+ log_error("Aborting. Could not deactivate cache pool %s.",
+ display_lvname(cache_pool_lv));
+ r = 0;
+ }
+
+ return r;
+}
diff --git a/lib/metadata/metadata-exported.h b/lib/metadata/metadata-exported.h
index 013da16..723a9c1 100644
--- a/lib/metadata/metadata-exported.h
+++ b/lib/metadata/metadata-exported.h
@@ -1099,6 +1099,7 @@ struct logical_volume *lv_cache_create(struct logical_volume *pool,
struct logical_volume *origin);
int lv_cache_remove(struct logical_volume *cache_lv);
int get_cache_mode(const char *str, uint32_t *flags);
+int wipe_cache_pool(struct logical_volume *cache_pool_lv);
/* -- metadata/cache_manip.c */
struct cmd_vg *cmd_vg_add(struct dm_pool *mem, struct dm_list *cmd_vgs,
9 years, 4 months
master - cache: allow deactivation of empty pool
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=0b7335f8471774...
Commit: 0b7335f84717743bf9c3f9ea9cafff279dff8672
Parent: 969ab6bbf02c11bf989ccc3105910a205448507b
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Sun Nov 2 17:48:21 2014 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Mon Nov 3 14:19:33 2014 +0100
cache: allow deactivation of empty pool
Tool will use internal activation of unused cache pool to
clear metadata area before next use of cache-pool.
So allow to deactivation unused pool in case some error
case happend and we were not able to deactivation pool
right after metadata wipe.
---
tools/lvchange.c | 5 +----
tools/toollib.c | 17 +++++++++++++++++
tools/vgchange.c | 4 ----
3 files changed, 18 insertions(+), 8 deletions(-)
diff --git a/tools/lvchange.c b/tools/lvchange.c
index 6697905..99dba82 100644
--- a/tools/lvchange.c
+++ b/tools/lvchange.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-2014 Red Hat, Inc. All rights reserved.
*
* This file is part of LVM2.
*
@@ -170,9 +170,6 @@ static int _lvchange_activate(struct cmd_context *cmd, struct logical_volume *lv
activate = (activation_change_t) arg_uint_value(cmd, activate_ARG, CHANGE_AY);
- if (lv_is_cache_pool(lv))
- return 1;
-
if (lv_activation_skip(lv, activate, arg_count(cmd, ignoreactivationskip_ARG)))
return 1;
diff --git a/tools/toollib.c b/tools/toollib.c
index e87fd30..0472597 100644
--- a/tools/toollib.c
+++ b/tools/toollib.c
@@ -688,6 +688,23 @@ int lv_change_activate(struct cmd_context *cmd, struct logical_volume *lv,
{
int r = 1;
+ if (lv_is_cache_pool(lv)) {
+ if (is_change_activating(activate)) {
+ log_verbose("Skipping activation of cache pool %s.",
+ display_lvname(lv));
+ return 1;
+ }
+ if (!dm_list_empty(&lv->segs_using_this_lv)) {
+ log_verbose("Skipping deactivation of used cache pool %s.",
+ display_lvname(lv));
+ return 1;
+ }
+ /*
+ * Allow to pass only deactivation of unused cache pool.
+ * Useful only for recovery of failed zeroing of metadata LV.
+ */
+ }
+
if (lv_is_merging_origin(lv)) {
/*
* For merging origin, its snapshot must be inactive.
diff --git a/tools/vgchange.c b/tools/vgchange.c
index af59f3a..e5d700d 100644
--- a/tools/vgchange.c
+++ b/tools/vgchange.c
@@ -97,10 +97,6 @@ static int _activate_lvs_in_vg(struct cmd_context *cmd, struct volume_group *vg,
if (!lv_is_visible(lv))
continue;
- /* Cache pool cannot be activated */
- if (lv_is_cache_pool(lv))
- continue;
-
/* If LV is sparse, activate origin instead */
if (lv_is_cow(lv) && lv_is_virtual_origin(origin_from_cow(lv)))
lv = origin_from_cow(lv);
9 years, 4 months
master - cache: convert thin-pool
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=969ab6bbf02c11...
Commit: 969ab6bbf02c11bf989ccc3105910a205448507b
Parent: 127cf4895a8531e1ffcae06ce472c9ecf3b94f2c
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Sun Nov 2 17:03:14 2014 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Mon Nov 3 14:19:33 2014 +0100
cache: convert thin-pool
Support caching of thin-pool.
lvresize needs to be resolved - so far, user
has to manually drop cache-pool before resizing.
---
lib/metadata/cache_manip.c | 5 ++++-
tools/lvconvert.c | 13 +++++--------
2 files changed, 9 insertions(+), 9 deletions(-)
diff --git a/lib/metadata/cache_manip.c b/lib/metadata/cache_manip.c
index 44d1bd8..e59a32f 100644
--- a/lib/metadata/cache_manip.c
+++ b/lib/metadata/cache_manip.c
@@ -171,9 +171,12 @@ struct logical_volume *lv_cache_create(struct logical_volume *pool_lv,
struct lv_segment *seg;
if (!validate_lv_cache_create_pool(pool_lv) ||
- !validate_lv_cache_create_origin(origin_lv))
+ !validate_lv_cache_create_origin(cache_lv))
return_NULL;
+ if (lv_is_thin_pool(cache_lv))
+ cache_lv = seg_lv(first_seg(cache_lv), 0); /* cache _tdata */
+
if (!(segtype = get_segtype_from_string(cmd, "cache")))
return_NULL;
diff --git a/tools/lvconvert.c b/tools/lvconvert.c
index f37a7a8..a512709 100644
--- a/tools/lvconvert.c
+++ b/tools/lvconvert.c
@@ -3188,8 +3188,7 @@ static int _lvconvert_cache(struct cmd_context *cmd,
struct logical_volume *pool_lv = lp->pool_data_lv;
struct logical_volume *cache_lv;
- if (!validate_lv_cache_create_pool(pool_lv) ||
- !validate_lv_cache_create_origin(origin_lv))
+ if (!validate_lv_cache_create_pool(pool_lv))
return_0;
if (!archive(origin_lv->vg))
@@ -3254,12 +3253,10 @@ static int _lvconvert_single(struct cmd_context *cmd, struct logical_volume *lv,
return ECMD_PROCESSED;
}
- if (lp->cache) {
- if (lv_is_thin_pool(lv))
- lv = seg_lv(first_seg(lv), 0); /* cache _tdata */
- if (!validate_lv_cache_create_origin(lv))
- return_ECMD_FAILED;
- }
+ /* Validate origin prior we start conversion of pool */
+ if (lp->cache &&
+ !validate_lv_cache_create_origin(lv))
+ return_ECMD_FAILED;
if (lp->thin) {
if (lv_is_cache_type(lv) ||
9 years, 4 months
master - thin: allow to convert chunksize of empty pool
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=127cf4895a8531...
Commit: 127cf4895a8531e1ffcae06ce472c9ecf3b94f2c
Parent: 7f35d42a99db9dedc3f2f6fb9f65873704a241ef
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Mon Nov 3 14:00:09 2014 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Mon Nov 3 14:19:33 2014 +0100
thin: allow to convert chunksize of empty pool
When pool is not used, allow to change its chunksize.
---
tools/lvconvert.c | 3 ++-
1 files changed, 2 insertions(+), 1 deletions(-)
diff --git a/tools/lvconvert.c b/tools/lvconvert.c
index f22c84b..f37a7a8 100644
--- a/tools/lvconvert.c
+++ b/tools/lvconvert.c
@@ -2923,7 +2923,8 @@ static int _lvconvert_pool(struct cmd_context *cmd,
/* Normally do NOT change chunk size when swapping */
if (arg_count(cmd, chunksize_ARG) &&
- (lp->chunk_size != seg->chunk_size)) {
+ (lp->chunk_size != seg->chunk_size) &&
+ !dm_list_empty(&pool_lv->segs_using_this_lv)) {
if (lp->force == PROMPT) {
log_error("Chunk size can be only changed with --force. Conversion aborted.");
return 0;
9 years, 4 months
master - thin: reporting of thin volumes simplified
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=7f35d42a99db9d...
Commit: 7f35d42a99db9dedc3f2f6fb9f65873704a241ef
Parent: 897b09157922a510d6c9f5556eea4fc243b84702
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Mon Nov 3 12:38:24 2014 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Mon Nov 3 14:19:32 2014 +0100
thin: reporting of thin volumes simplified
Simplify reporting of percentage.
Allows easier support for more types.
Move testing of device availability into activate.c
---
lib/activate/activate.c | 8 ++++----
lib/report/report.c | 38 +++++++++-----------------------------
2 files changed, 13 insertions(+), 33 deletions(-)
diff --git a/lib/activate/activate.c b/lib/activate/activate.c
index 6ba4712..69011f7 100644
--- a/lib/activate/activate.c
+++ b/lib/activate/activate.c
@@ -1134,7 +1134,7 @@ int lv_thin_pool_percent(const struct logical_volume *lv, int metadata,
int r;
struct dev_manager *dm;
- if (!activation())
+ if (!lv_info(lv->vg->cmd, lv, 1, NULL, 0, 0))
return 0;
log_debug_activation("Checking thin %sdata percent for LV %s/%s",
@@ -1160,7 +1160,7 @@ int lv_thin_percent(const struct logical_volume *lv,
int r;
struct dev_manager *dm;
- if (!activation())
+ if (!lv_info(lv->vg->cmd, lv, 0, NULL, 0, 0))
return 0;
log_debug_activation("Checking thin percent for LV %s/%s",
@@ -1187,7 +1187,7 @@ int lv_thin_pool_transaction_id(const struct logical_volume *lv,
struct dev_manager *dm;
struct dm_status_thin_pool *status;
- if (!activation())
+ if (!lv_info(lv->vg->cmd, lv, 1, NULL, 0, 0))
return 0;
log_debug_activation("Checking thin percent for LV %s/%s",
@@ -1211,7 +1211,7 @@ int lv_thin_device_id(const struct logical_volume *lv, uint32_t *device_id)
int r;
struct dev_manager *dm;
- if (!activation())
+ if (!lv_info(lv->vg->cmd, lv, 0, NULL, 0, 0))
return 0;
log_debug_activation("Checking device id for LV %s/%s",
diff --git a/lib/report/report.c b/lib/report/report.c
index ebf3b3f..f2ed0ae 100644
--- a/lib/report/report.c
+++ b/lib/report/report.c
@@ -1143,30 +1143,6 @@ static int _raidmaxrecoveryrate_disp(struct dm_report *rh __attribute__((unused)
return _field_set_value(field, "", &RESERVED(number_undef_64));
}
-/* Called only with lv_is_thin_pool/volume */
-static int _dtpercent_disp(int metadata, struct dm_report *rh,
- struct dm_report_field *field,
- const void *data, void *private)
-{
- const struct logical_volume *lv = (const struct logical_volume *) data;
- dm_percent_t percent = DM_PERCENT_INVALID;
-
- /* Suppress data percent if not using driver */
- /* cannot use lv_is_active_locally - need to check for layer -tpool */
- if (!lv_info(lv->vg->cmd, lv, 1, NULL, 0, 0))
- return dm_report_field_percent(rh, field, &percent);
-
- if (lv_is_thin_pool(lv)) {
- if (!lv_thin_pool_percent(lv, metadata, &percent))
- return_0;
- } else { /* thin_volume */
- if (!lv_thin_percent(lv, 0, &percent))
- return_0;
- }
-
- return dm_report_field_percent(rh, field, &percent);
-}
-
static int _datapercent_disp(struct dm_report *rh, struct dm_pool *mem,
struct dm_report_field *field,
const void *data, void *private)
@@ -1176,9 +1152,10 @@ static int _datapercent_disp(struct dm_report *rh, struct dm_pool *mem,
if (lv_is_cow(lv))
return _snpercent_disp(rh, mem, field, data, private);
-
- if (lv_is_thin_pool(lv) || lv_is_thin_volume(lv))
- return _dtpercent_disp(0, rh, field, data, private);
+ else if (lv_is_thin_pool(lv))
+ (void) lv_thin_pool_percent(lv, 0, &percent);
+ else if (lv_is_thin_volume(lv))
+ (void) lv_thin_percent(lv, 0, &percent);
return dm_report_field_percent(rh, field, &percent);
}
@@ -1189,11 +1166,14 @@ static int _metadatapercent_disp(struct dm_report *rh,
const void *data, void *private)
{
const struct logical_volume *lv = (const struct logical_volume *) data;
+ dm_percent_t percent = DM_PERCENT_INVALID;
if (lv_is_thin_pool(lv))
- return _dtpercent_disp(1, rh, field, data, private);
+ (void) lv_thin_pool_percent(lv, 1, &percent);
+ else if (lv_is_thin_volume(lv))
+ (void) lv_thin_percent(lv, 1, &percent);
- return _field_set_value(field, "", &RESERVED(number_undef_64));
+ return dm_report_field_percent(rh, field, &percent);
}
static int _lvmetadatasize_disp(struct dm_report *rh, struct dm_pool *mem,
9 years, 4 months
master - pool: validate sizes
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=897b09157922a5...
Commit: 897b09157922a510d6c9f5556eea4fc243b84702
Parent: dc11dcf11d90f24c8d37988f3029e29cc6a45441
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Fri Oct 31 11:41:49 2014 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Mon Nov 3 14:19:32 2014 +0100
pool: validate sizes
0 size are not supported as well as negative.
---
tools/toollib.c | 19 ++++++++++++++-----
1 files changed, 14 insertions(+), 5 deletions(-)
diff --git a/tools/toollib.c b/tools/toollib.c
index dd09811..e87fd30 100644
--- a/tools/toollib.c
+++ b/tools/toollib.c
@@ -975,12 +975,21 @@ int get_pool_params(struct cmd_context *cmd,
}
}
- if (arg_count(cmd, chunksize_ARG)) {
- if (arg_sign_value(cmd, chunksize_ARG, SIGN_NONE) == SIGN_MINUS) {
- log_error("Negative chunk size is invalid.");
- return 0;
- }
+ if (arg_from_list_is_negative(cmd, "may not be negative",
+ chunksize_ARG,
+ pooldatasize_ARG,
+ poolmetadatasize_ARG,
+ -1))
+ return_0;
+
+ if (arg_from_list_is_zero(cmd, "may not be zero",
+ chunksize_ARG,
+ pooldatasize_ARG,
+ poolmetadatasize_ARG,
+ -1))
+ return_0;
+ if (arg_is_set(cmd, chunksize_ARG)) {
*passed_args |= PASS_ARG_CHUNK_SIZE;
*chunk_size = arg_uint_value(cmd, chunksize_ARG, 0);
9 years, 4 months
master - filters: change return code
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=dc11dcf11d90f2...
Commit: dc11dcf11d90f24c8d37988f3029e29cc6a45441
Parent: c1ee6d4ffc7d520e015a8e44f50392510fb85167
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Fri Oct 31 20:25:25 2014 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Mon Nov 3 14:19:32 2014 +0100
filters: change return code
No data for writing should be seen as 'dump' success.
(reduces one <bactrace> in the log) - it has no other
effect.
---
lib/filters/filter-persistent.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/lib/filters/filter-persistent.c b/lib/filters/filter-persistent.c
index 600fa38..3c1701b 100644
--- a/lib/filters/filter-persistent.c
+++ b/lib/filters/filter-persistent.c
@@ -193,7 +193,7 @@ static int _persistent_filter_dump(struct dev_filter *f, int merge_existing)
if (!dm_hash_get_num_entries(pf->devices)) {
log_very_verbose("Internal persistent device cache empty "
"- not writing to %s", pf->file);
- return 0;
+ return 1;
}
if (!dev_cache_has_scanned()) {
log_very_verbose("Device cache incomplete - not writing "
9 years, 4 months