master - cache: function for min metadata size estimation
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=00dfca034c7478...
Commit: 00dfca034c7478b88874d43bc36633e3176d1866
Parent: 7c1e6011644abd00dac7f71baf330f69bd076381
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Thu Apr 28 18:08:36 2016 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Thu May 5 23:30:02 2016 +0200
cache: function for min metadata size estimation
Move min code into reusable function.
---
lib/metadata/cache_manip.c | 28 +++++++++++++++++++---------
1 files changed, 19 insertions(+), 9 deletions(-)
diff --git a/lib/metadata/cache_manip.c b/lib/metadata/cache_manip.c
index e998670..a514828 100644
--- a/lib/metadata/cache_manip.c
+++ b/lib/metadata/cache_manip.c
@@ -120,6 +120,23 @@ void cache_check_for_warns(const struct lv_segment *seg)
"resized and require manual uncache before resize!");
}
+/*
+ * Returns minimum size of cache metadata volume for give data and chunk size
+ * (all values in sector)
+ * Default meta size is: (Overhead + mapping size + hint size)
+ */
+static uint64_t _cache_min_metadata_size(uint64_t data_size, uint32_t chunk_size)
+{
+ uint64_t min_meta_size;
+
+ min_meta_size = data_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);
+
+ return min_meta_size;
+}
+
int update_cache_pool_params(const struct segment_type *segtype,
struct volume_group *vg, unsigned attr,
int passed_args, uint32_t pool_data_extents,
@@ -128,7 +145,7 @@ int update_cache_pool_params(const struct segment_type *segtype,
{
uint64_t min_meta_size;
uint32_t extent_size = vg->extent_size;
- uint64_t pool_metadata_size = (uint64_t) *pool_metadata_extents * vg->extent_size;
+ uint64_t pool_metadata_size = (uint64_t) *pool_metadata_extents * extent_size;
if (!(passed_args & PASS_ARG_CHUNK_SIZE))
*chunk_size = DEFAULT_CACHE_POOL_CHUNK_SIZE * 2;
@@ -136,14 +153,7 @@ int update_cache_pool_params(const struct segment_type *segtype,
if (!validate_pool_chunk_size(vg->cmd, segtype, *chunk_size))
return_0;
- /*
- * Default meta size is:
- * (Overhead + mapping size + hint size)
- */
- 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);
+ min_meta_size = _cache_min_metadata_size((uint64_t) pool_data_extents * extent_size, *chunk_size);
/* Round up to extent size */
if (min_meta_size % extent_size)
7 years, 12 months
master - pvcreate: improve debug message
by David Teigland
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=7c1e6011644abd...
Commit: 7c1e6011644abd00dac7f71baf330f69bd076381
Parent: 1df6769acabd99fe062ebac1c8290da1ef1020f7
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Wed May 4 12:11:13 2016 -0500
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Wed May 4 12:11:13 2016 -0500
pvcreate: improve debug message
state what the printed UUID is.
---
tools/toollib.c | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/tools/toollib.c b/tools/toollib.c
index c86900a..f1fe5b1 100644
--- a/tools/toollib.c
+++ b/tools/toollib.c
@@ -3818,8 +3818,8 @@ static int _pvcreate_check_single(struct cmd_context *cmd,
if (!found)
return 1;
- log_debug("Checking device %s for pvcreate %.32s.",
- pv_dev_name(pv), pv->dev->pvid[0] ? pv->dev->pvid : "");
+ log_debug("Checking pvcreate arg %s which has existing PVID: %.32s.",
+ pv_dev_name(pv), pv->dev->pvid[0] ? pv->dev->pvid : "<none>");
/*
* This test will fail if the device belongs to an MD array.
7 years, 12 months
master - pvcreate, pvremove: translate arg name to device once
by David Teigland
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=1df6769acabd99...
Commit: 1df6769acabd99fe062ebac1c8290da1ef1020f7
Parent: 795e47cec572b13329eecbcfbbc0aa70f0bccc16
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Wed May 4 11:28:28 2016 -0500
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Wed May 4 11:28:28 2016 -0500
pvcreate, pvremove: translate arg name to device once
Rather than doing repeated translations from name to
device when comparing args to existing PVs, do one
translation of the arg names and saving the device,
before checking existing PVs.
---
tools/toollib.c | 24 ++++++++----------------
1 files changed, 8 insertions(+), 16 deletions(-)
diff --git a/tools/toollib.c b/tools/toollib.c
index ac2a57a..c86900a 100644
--- a/tools/toollib.c
+++ b/tools/toollib.c
@@ -3787,7 +3787,6 @@ static int _pvcreate_check_single(struct cmd_context *cmd,
struct pvcreate_params *pp = (struct pvcreate_params *) handle->custom_handle;
struct pvcreate_device *pd;
struct pvcreate_prompt *prompt;
- struct device *dev;
int found = 0;
if (!pv->dev)
@@ -3796,21 +3795,11 @@ static int _pvcreate_check_single(struct cmd_context *cmd,
/*
* Check if one of the command args in arg_devices
* matches this device.
- *
- * (Possible optimization: the first time this _single
- * function is called, we could iterate through all
- * arg_devices entries, do the name to dev lookup
- * with dev_cache_get() and set the pd->dev fields.
- * Subsequent _single calls would just compare devs
- * and not do any dev_cache_get(). This would avoid
- * repeating dev_cache_get() for arg_devices entries.)
*/
dm_list_iterate_items(pd, &pp->arg_devices) {
- dev = dev_cache_get(pd->name, cmd->full_filter);
- if (dev != pv->dev)
+ if (pd->dev != pv->dev)
continue;
- pd->dev = pv->dev;
if (pv->dev->pvid[0])
strncpy(pd->pvid, pv->dev->pvid, ID_LEN);
found = 1;
@@ -4015,7 +4004,6 @@ static int _pvremove_check_single(struct cmd_context *cmd,
struct pvcreate_device *pd;
struct pvcreate_prompt *prompt;
struct label *label;
- struct device *dev;
int found = 0;
if (!pv->dev)
@@ -4026,11 +4014,9 @@ static int _pvremove_check_single(struct cmd_context *cmd,
* matches this device.
*/
dm_list_iterate_items(pd, &pp->arg_devices) {
- dev = dev_cache_get(pd->name, cmd->full_filter);
- if (dev != pv->dev)
+ if (pd->dev != pv->dev)
continue;
- pd->dev = pv->dev;
if (pv->dev->pvid[0])
strncpy(pd->pvid, pv->dev->pvid, ID_LEN);
found = 1;
@@ -4240,6 +4226,12 @@ int pvcreate_each_device(struct cmd_context *cmd,
dev_cache_full_scan(cmd->full_filter);
/*
+ * Translate arg names into struct device's.
+ */
+ dm_list_iterate_items(pd, &pp->arg_devices)
+ pd->dev = dev_cache_get(pd->name, cmd->full_filter);
+
+ /*
* Use process_each_pv to search all existing PVs and devices.
*
* This is a slightly different way to use process_each_pv, because the
7 years, 12 months