master - cleanup: use unsigned with EPOCH printf format
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=673d4f745322d6...
Commit: 673d4f745322d6d9ca274697148267114058beec
Parent: ed9162cd882426109fba14413ff2840edfd99341
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Tue May 3 21:24:12 2016 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Thu May 5 23:55:20 2016 +0200
cleanup: use unsigned with EPOCH printf format
---
lib/log/log.c | 2 +-
man/lvm.8.in | 3 ++-
2 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/lib/log/log.c b/lib/log/log.c
index d939b9d..7b0026f 100644
--- a/lib/log/log.c
+++ b/lib/log/log.c
@@ -90,7 +90,7 @@ void init_log_file(const char *log_file, int append)
log_warn("WARNING: Cannot parse content of %s.", statfile);
} else {
if (dm_snprintf(_log_file_path, sizeof(_log_file_path),
- "%s_%s_%d_%lld", log_file, env, pid, starttime) < 0) {
+ "%s_%s_%d_%llu", log_file, env, pid, starttime) < 0) {
log_warn("WARNING: Debug log file path is too long for epoch.");
_log_file_path[0] = '\0';
} else {
diff --git a/man/lvm.8.in b/man/lvm.8.in
index d2da72c..f8400cf 100644
--- a/man/lvm.8.in
+++ b/man/lvm.8.in
@@ -764,7 +764,8 @@ Path to the socket used to communicate with lvmpolld..
.TP
.B LVM_LOG_FILE_EPOCH
A string of up to 32 letters appended to the log filename and
-followed by the process ID and a timestamp. When set, each process logs to a
+followed by the process ID and a startup timestamp using
+this format string "_%s_%d_%llu". When set, each process logs to a
separate file.
.TP
.B LVM_EXPECTED_EXIT_STATUS
6 years, 10 months
master - cleanup: enhance warning message
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=ed9162cd882426...
Commit: ed9162cd882426109fba14413ff2840edfd99341
Parent: f6575ec824964ee2f830746e12b12a887c95e7f7
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Thu May 5 21:13:41 2016 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Thu May 5 23:55:18 2016 +0200
cleanup: enhance warning message
Add WARNING: for log_warn.
Show device name which is marked missing.
---
lib/metadata/metadata.c | 10 ++++++----
1 files changed, 6 insertions(+), 4 deletions(-)
diff --git a/lib/metadata/metadata.c b/lib/metadata/metadata.c
index c8237d5..c7d3fcf 100644
--- a/lib/metadata/metadata.c
+++ b/lib/metadata/metadata.c
@@ -691,7 +691,7 @@ static int _check_pv_dev_sizes(struct volume_group *vg)
size = pv_size(pvl->pv);
if (dev_size < size) {
- log_warn("Device %s has size of %" PRIu64 " sectors which "
+ log_warn("WARNING: Device %s has size of %" PRIu64 " sectors which "
"is smaller than corresponding PV size of %" PRIu64
" sectors. Was device resized?",
pv_dev_name(pvl->pv), dev_size, size);
@@ -3890,7 +3890,7 @@ static int _check_reappeared_pv(struct volume_group *correct_vg,
dm_list_iterate_items(pvl, &correct_vg->pvs)
if (pv->dev == pvl->pv->dev && is_missing_pv(pvl->pv)) {
if (act)
- log_warn("Missing device %s reappeared, updating "
+ log_warn("WARNING: Missing device %s reappeared, updating "
"metadata for VG %s to version %u.",
pv_dev_name(pvl->pv), pv_vg_name(pvl->pv),
correct_vg->seqno);
@@ -3901,9 +3901,11 @@ static int _check_reappeared_pv(struct volume_group *correct_vg,
}
++ rv;
} else if (act)
- log_warn("Device still marked missing because of allocated data "
- "on it, remove volumes and consider vgreduce --removemissing.");
+ log_warn("WARNING: Device %s still marked missing because of allocated data "
+ "on it, remove volumes and consider vgreduce --removemissing.",
+ pv_dev_name(pvl->pv));
}
+
return rv;
}
6 years, 10 months
master - cleanup: just switch error path
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=f6575ec824964e...
Commit: f6575ec824964ee2f830746e12b12a887c95e7f7
Parent: d1ecbfa52d3f35c8702ca50f30577daa8c324eb9
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Thu May 5 23:12:30 2016 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Thu May 5 23:52:06 2016 +0200
cleanup: just switch error path
Check for error case in if() like we normally do.
Let code continue on success.
---
lib/metadata/lv_manip.c | 16 ++++++++--------
1 files changed, 8 insertions(+), 8 deletions(-)
diff --git a/lib/metadata/lv_manip.c b/lib/metadata/lv_manip.c
index 45dd1f5..9bfef45 100644
--- a/lib/metadata/lv_manip.c
+++ b/lib/metadata/lv_manip.c
@@ -7771,16 +7771,16 @@ struct logical_volume *lv_create_single(struct volume_group *vg,
if (!(lv = _lv_create_an_lv(vg, lp, lp->pool_name)))
return_NULL;
- if (lv_is_cache(lv)) {
- /* Here it's been converted via lvcreate */
- log_print_unless_silent("Logical volume %s is now cached.",
- display_lvname(lv));
- return lv;
+ if (!lv_is_cache(lv)) {
+ log_error(INTERNAL_ERROR "Logical volume is not cache %s.",
+ display_lvname(lv));
+ return NULL;
}
- log_error(INTERNAL_ERROR "Logical volume is not cache %s.",
- display_lvname(lv));
- return NULL;
+ /* Convertion via lvcreate */
+ log_print_unless_silent("Logical volume %s is now cached.",
+ display_lvname(lv));
+ return lv;
} else {
log_error(INTERNAL_ERROR "Creation of pool for unsupported segment type %s.",
lp->segtype->name);
6 years, 10 months
master - lvcreate: improve --chunksize support for cached volume.
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=d1ecbfa52d3f35...
Commit: d1ecbfa52d3f35c8702ca50f30577daa8c324eb9
Parent: d3b15674df99a2dd17b5205b850606d80a155df7
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Thu May 5 21:34:21 2016 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Thu May 5 23:50:10 2016 +0200
lvcreate: improve --chunksize support for cached volume.
Support parsing --chunksize option also when converting.
Now user can use cache pool created with i.e. 32K chunksize,
while in caching user can select 512K blocks.
Tool is supposed to validate cache metadata size is big enough
to support such chunk size. Otherwise error is shown.
---
WHATS_NEW | 1 +
lib/metadata/lv_manip.c | 43 ++++++++++++++++++++-----------------------
man/lvcreate.8.in | 2 ++
3 files changed, 23 insertions(+), 23 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index d0943f5..eb442df 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.153 -
==================================
+ Support --chunksize option also when caching LV when possible.
Add function to check for target presence and version via 1 ioctl.
Version 2.02.152 - 30th April 2016
diff --git a/lib/metadata/lv_manip.c b/lib/metadata/lv_manip.c
index 2969d2a..45dd1f5 100644
--- a/lib/metadata/lv_manip.c
+++ b/lib/metadata/lv_manip.c
@@ -7166,9 +7166,17 @@ static struct logical_volume *_lv_create_an_lv(struct volume_group *vg,
return NULL;
}
+ if (seg_is_cache(lp)) {
+ /* validate metadata size */
+ if (!validate_lv_cache_chunk_size(pool_lv, lp->chunk_size))
+ return_0;
+
+ first_seg(pool_lv)->chunk_size = lp->chunk_size;
+ }
+
/* Validate volume size to to aling on chunk for small extents */
/* Cache chunk size is always set */
- size = seg_is_cache(lp) ? lp->chunk_size : first_seg(pool_lv)->chunk_size;
+ size = first_seg(pool_lv)->chunk_size;
if (size > vg->extent_size) {
/* Align extents on chunk boundary size */
size = ((uint64_t)vg->extent_size * lp->extents + size - 1) /
@@ -7427,27 +7435,15 @@ static struct logical_volume *_lv_create_an_lv(struct volume_group *vg,
/* Unlock memory if possible */
memlock_unlock(vg->cmd);
- if (lv_is_cache_pool(lv) || lv_is_cache(lv)) {
- if (!cache_set_mode(first_seg(lv), lp->cache_mode)) {
- stack;
- goto revert_new_lv;
- }
-
- if (!cache_set_policy(first_seg(lv), lp->policy_name, lp->policy_settings)) {
+ if (lv_is_cache_pool(lv)) {
+ if (!cache_set_params(first_seg(lv),
+ lp->cache_mode,
+ lp->policy_name,
+ lp->policy_settings,
+ lp->chunk_size)) {
stack;
goto revert_new_lv;
}
-
- pool_lv = pool_lv ? : lv;
- if (lp->chunk_size) {
- first_seg(pool_lv)->chunk_size = lp->chunk_size;
- /* TODO: some calc_policy solution for cache ? */
- if (!recalculate_pool_chunk_size_with_dev_hints(pool_lv, lp->passed_args,
- THIN_CHUNK_SIZE_CALC_METHOD_GENERIC)) {
- stack;
- goto revert_new_lv;
- }
- }
} else if (lv_is_raid(lv)) {
first_seg(lv)->min_recovery_rate = lp->min_recovery_rate;
first_seg(lv)->max_recovery_rate = lp->max_recovery_rate;
@@ -7649,10 +7645,11 @@ static struct logical_volume *_lv_create_an_lv(struct volume_group *vg,
}
lv = tmp_lv;
- if (!cache_set_mode(first_seg(lv), lp->cache_mode))
- return_NULL; /* revert? */
-
- if (!cache_set_policy(first_seg(lv), lp->policy_name, lp->policy_settings))
+ if (!cache_set_params(first_seg(lv),
+ lp->cache_mode,
+ lp->policy_name,
+ lp->policy_settings,
+ (lp->passed_args & PASS_ARG_CHUNK_SIZE) ? lp->chunk_size : 0))
return_NULL; /* revert? */
cache_check_for_warns(first_seg(lv));
diff --git a/man/lvcreate.8.in b/man/lvcreate.8.in
index fd8b3a7..e008b58 100644
--- a/man/lvcreate.8.in
+++ b/man/lvcreate.8.in
@@ -260,6 +260,8 @@ and the default value is 4KiB.
.br
For cache pools the value must a multiple of 32KiB
between 32KiB and 1GiB. The default is 64KiB.
+When the size is specified with volume caching, it may not be smaller
+then cache pool creation chunk size was.
.br
For thin pools the value must be a multiple of 64KiB
between 64KiB and 1GiB.
6 years, 10 months
master - lvcreate: check for lv type and created segtype
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=d3b15674df99a2...
Commit: d3b15674df99a2dd17b5205b850606d80a155df7
Parent: d0111563c2ffd4026ea45dc38c97d4210d903889
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Wed Apr 27 15:02:54 2016 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Thu May 5 23:34:35 2016 +0200
lvcreate: check for lv type and created segtype
When creating LV - in some case we change created segment type
(ATM for cache and snapshot) and we then manipulate with
lv segment according to 'lp' segtype.
Fix this by checking for proper type before accessing segment members.
This makes command like:
lvcreate --type cache-pool -L10 vg/cpool
lvcreate -H -L10 --cachesettings migtation_threshold=10000 vg/cpool
to pass since now tool correctly selects default cache policy.
---
lib/metadata/lv_manip.c | 18 +++++++++---------
1 files changed, 9 insertions(+), 9 deletions(-)
diff --git a/lib/metadata/lv_manip.c b/lib/metadata/lv_manip.c
index cd0a78c..2969d2a 100644
--- a/lib/metadata/lv_manip.c
+++ b/lib/metadata/lv_manip.c
@@ -7370,7 +7370,7 @@ static struct logical_volume *_lv_create_an_lv(struct volume_group *vg,
lp->wipe_signatures = 0;
}
- if (!seg_is_virtual(lp) && !lp->approx_alloc &&
+ if (!segtype_is_virtual(create_segtype) && !lp->approx_alloc &&
(vg->free_count < lp->extents)) {
log_error("Volume group \"%s\" has insufficient free space "
"(%u extents): %u required.",
@@ -7382,7 +7382,7 @@ static struct logical_volume *_lv_create_an_lv(struct volume_group *vg,
return_NULL;
- if (pool_lv && seg_is_thin_volume(lp)) {
+ if (pool_lv && segtype_is_thin_volume(create_segtype)) {
/* Ensure all stacked messages are submitted */
if ((pool_is_active(pool_lv) || is_change_activating(lp->activate)) &&
!update_pool_lv(pool_lv, 1))
@@ -7398,7 +7398,7 @@ static struct logical_volume *_lv_create_an_lv(struct volume_group *vg,
log_debug_metadata("Setting read ahead sectors %u.", lv->read_ahead);
}
- if (!seg_is_pool(lp) && lp->minor >= 0) {
+ if (!segtype_is_pool(create_segtype) && lp->minor >= 0) {
lv->major = lp->major;
lv->minor = lp->minor;
lv->status |= FIXED_MINOR;
@@ -7419,15 +7419,15 @@ static struct logical_volume *_lv_create_an_lv(struct volume_group *vg,
if (!lv_extend(lv, create_segtype,
lp->stripes, lp->stripe_size,
lp->mirrors,
- seg_is_pool(lp) ? lp->pool_metadata_extents : lp->region_size,
- seg_is_thin_volume(lp) ? lp->virtual_extents : lp->extents,
+ segtype_is_pool(create_segtype) ? lp->pool_metadata_extents : lp->region_size,
+ segtype_is_thin_volume(create_segtype) ? lp->virtual_extents : lp->extents,
lp->pvh, lp->alloc, lp->approx_alloc))
return_NULL;
/* Unlock memory if possible */
memlock_unlock(vg->cmd);
- if (seg_is_cache_pool(lp) || seg_is_cache(lp)) {
+ if (lv_is_cache_pool(lv) || lv_is_cache(lv)) {
if (!cache_set_mode(first_seg(lv), lp->cache_mode)) {
stack;
goto revert_new_lv;
@@ -7448,10 +7448,10 @@ static struct logical_volume *_lv_create_an_lv(struct volume_group *vg,
goto revert_new_lv;
}
}
- } else if (seg_is_raid(lp)) {
+ } else if (lv_is_raid(lv)) {
first_seg(lv)->min_recovery_rate = lp->min_recovery_rate;
first_seg(lv)->max_recovery_rate = lp->max_recovery_rate;
- } else if (seg_is_thin_pool(lp)) {
+ } else if (lv_is_thin_pool(lv)) {
first_seg(lv)->chunk_size = lp->chunk_size;
first_seg(lv)->zero_new_blocks = lp->zero ? 1 : 0;
first_seg(lv)->discards = lp->discards;
@@ -7462,7 +7462,7 @@ static struct logical_volume *_lv_create_an_lv(struct volume_group *vg,
}
if (lp->error_when_full)
lv->status |= LV_ERROR_WHEN_FULL;
- } else if (pool_lv && seg_is_thin_volume(lp)) {
+ } else if (pool_lv && lv_is_virtual(lv)) { /* going to be a thin volume */
seg = first_seg(lv);
pool_seg = first_seg(pool_lv);
if (!(seg->device_id = get_free_pool_device_id(pool_seg)))
6 years, 10 months
master - debug: enhance debug msg for cache
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=d0111563c2ffd4...
Commit: d0111563c2ffd4026ea45dc38c97d4210d903889
Parent: fd79027cae16be4f7fcae98568c2063ac37c9e3a
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Wed Apr 27 12:55:52 2016 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Thu May 5 23:34:35 2016 +0200
debug: enhance debug msg for cache
---
lib/cache_segtype/cache.c | 20 ++++++++++++--------
1 files changed, 12 insertions(+), 8 deletions(-)
diff --git a/lib/cache_segtype/cache.c b/lib/cache_segtype/cache.c
index b3edff8..0cbb993 100644
--- a/lib/cache_segtype/cache.c
+++ b/lib/cache_segtype/cache.c
@@ -211,8 +211,11 @@ static int _target_present(struct cmd_context *cmd,
unsigned cache_alias;
const char feature[12];
const char module[12]; /* check dm-%s */
+ const char *aliasing;
} _features[] = {
- { 1, 9, 0, CACHE_FEATURE_POLICY_MQ, "policy_smq", "cache-smq" },
+ /* Assumption: cache >=1.9 always aliases MQ policy */
+ { 1, 9, CACHE_FEATURE_POLICY_SMQ, CACHE_FEATURE_POLICY_MQ, "policy_smq", "cache-smq",
+ " and aliases cache-mq" },
{ 1, 8, CACHE_FEATURE_POLICY_SMQ, 0, "policy_smq", "cache-smq" },
{ 1, 3, CACHE_FEATURE_POLICY_MQ, 0, "policy_mq", "cache-mq" },
};
@@ -245,16 +248,17 @@ static int _target_present(struct cmd_context *cmd,
return 0;
}
-
for (i = 0; i < DM_ARRAY_SIZE(_features); ++i) {
+ if (_attrs & _features[i].cache_feature)
+ continue; /* already present */
if (((maj > _features[i].maj) ||
(maj == _features[i].maj && min >= _features[i].min)) &&
- (!_features[i].module[0] ||
- (_attrs & _features[i].cache_feature) || /* already present */
- module_present(cmd, _features[i].module)))
- _attrs |= _features[i].cache_feature |
- _features[i].cache_alias;
- else
+ module_present(cmd, _features[i].module)) {
+ log_debug_activation("Cache policy %s is available%s.",
+ _features[i].module,
+ _features[i].aliasing ? : "");
+ _attrs |= (_features[i].cache_feature | _features[i].cache_alias);
+ } else if (!_features[i].cache_alias)
log_very_verbose("Target %s does not support %s.",
_cache_module, _features[i].feature);
}
6 years, 10 months
master - cache: use target_present_version
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=fd79027cae16be...
Commit: fd79027cae16be4f7fcae98568c2063ac37c9e3a
Parent: 4d116d7a28974648183623c46014b9dcff48748d
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Wed Apr 27 11:13:36 2016 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Thu May 5 23:34:35 2016 +0200
cache: use target_present_version
Using new function.
Also add trace for error path.
---
lib/cache_segtype/cache.c | 8 +++-----
1 files changed, 3 insertions(+), 5 deletions(-)
diff --git a/lib/cache_segtype/cache.c b/lib/cache_segtype/cache.c
index 199bda6..b3edff8 100644
--- a/lib/cache_segtype/cache.c
+++ b/lib/cache_segtype/cache.c
@@ -227,15 +227,13 @@ static int _target_present(struct cmd_context *cmd,
const char *str;
if (!activation())
- return 0;
+ return_0;
if (!_cache_checked) {
_cache_checked = 1;
- if (!(_cache_present = target_present(cmd, TARGET_NAME_CACHE, 1)))
- return 0;
-
- if (!target_version(TARGET_NAME_CACHE, &maj, &min, &patchlevel))
+ if (!(_cache_present = target_present_version(cmd, TARGET_NAME_CACHE, 1,
+ &maj, &min, &patchlevel)))
return_0;
if ((maj < 1) ||
6 years, 10 months
master - cleanup: gather version info with single check
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=4d116d7a289746...
Commit: 4d116d7a28974648183623c46014b9dcff48748d
Parent: def65507e6beab7d1830622492772cc89abe4ccb
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Wed Apr 27 11:11:58 2016 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Thu May 5 23:34:30 2016 +0200
cleanup: gather version info with single check
As we already collect version info anyway, allow to use it through
a single call (can makes logs shorter and saves ioctl).
---
WHATS_NEW | 1 +
lib/activate/activate.c | 21 ++++++++++++++-------
lib/activate/activate.h | 3 +++
3 files changed, 18 insertions(+), 7 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index 7291482..d0943f5 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.153 -
==================================
+ Add function to check for target presence and version via 1 ioctl.
Version 2.02.152 - 30th April 2016
==================================
diff --git a/lib/activate/activate.c b/lib/activate/activate.c
index 5a7e99e..712f86c 100644
--- a/lib/activate/activate.c
+++ b/lib/activate/activate.c
@@ -632,25 +632,32 @@ int module_present(struct cmd_context *cmd, const char *target_name)
return ret;
}
-int target_present(struct cmd_context *cmd, const char *target_name,
- int use_modprobe)
+int target_present_version(struct cmd_context *cmd, const char *target_name,
+ int use_modprobe,
+ uint32_t *maj, uint32_t *min, uint32_t *patchlevel)
{
- uint32_t maj, min, patchlevel;
-
if (!activation())
- return 0;
+ return_0;
#ifdef MODPROBE_CMD
if (use_modprobe) {
- if (target_version(target_name, &maj, &min, &patchlevel))
+ if (target_version(target_name, maj, min, patchlevel))
return 1;
if (!module_present(cmd, target_name))
return_0;
}
#endif
+ return target_version(target_name, maj, min, patchlevel);
+}
+
+int target_present(struct cmd_context *cmd, const char *target_name,
+ int use_modprobe)
+{
+ uint32_t maj, min, patchlevel;
- return target_version(target_name, &maj, &min, &patchlevel);
+ return target_present_version(cmd, target_name, use_modprobe,
+ &maj, &min, &patchlevel);
}
static int _lv_info(struct cmd_context *cmd, const struct logical_volume *lv,
diff --git a/lib/activate/activate.h b/lib/activate/activate.h
index 089355d..1e8d7a8 100644
--- a/lib/activate/activate.h
+++ b/lib/activate/activate.h
@@ -92,6 +92,9 @@ int library_version(char *version, size_t size);
int lvm1_present(struct cmd_context *cmd);
int module_present(struct cmd_context *cmd, const char *target_name);
+int target_present_version(struct cmd_context *cmd, const char *target_name,
+ int use_modprobe, uint32_t *maj,
+ uint32_t *min, uint32_t *patchlevel);
int target_present(struct cmd_context *cmd, const char *target_name,
int use_modprobe);
int target_version(const char *target_name, uint32_t *maj,
6 years, 10 months
master - cache: add cache_set_params function
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=def65507e6beab...
Commit: def65507e6beab7d1830622492772cc89abe4ccb
Parent: ae805eea50b1033115a18b8a0c9931c2c917b8b2
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Thu May 5 21:30:15 2016 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Thu May 5 23:30:49 2016 +0200
cache: add cache_set_params function
Wrapping function to handle setup of various cache related params.
Reusable with lvcreate & lvconvert.
---
lib/metadata/cache_manip.c | 34 ++++++++++++++++++++++++++++++++++
lib/metadata/metadata-exported.h | 5 +++++
2 files changed, 39 insertions(+), 0 deletions(-)
diff --git a/lib/metadata/cache_manip.c b/lib/metadata/cache_manip.c
index 5ecfbe2..27a716a 100644
--- a/lib/metadata/cache_manip.c
+++ b/lib/metadata/cache_manip.c
@@ -632,6 +632,40 @@ out:
}
/*
+ * Universal 'wrapper' function do-it-all
+ * to update all commonly specified cache parameters
+ */
+int cache_set_params(struct lv_segment *seg,
+ const char *cache_mode,
+ const char *policy_name,
+ const struct dm_config_tree *policy_settings,
+ uint32_t chunk_size)
+{
+ struct lv_segment *pool_seg;
+
+ if (!cache_set_mode(seg, cache_mode))
+ return_0;
+
+ if (!cache_set_policy(seg, policy_name, policy_settings))
+ return_0;
+
+ pool_seg = seg_is_cache(seg) ? first_seg(seg->pool_lv) : seg;
+
+ if (chunk_size) {
+ if (!validate_lv_cache_chunk_size(pool_seg->lv, chunk_size))
+ return_0;
+ pool_seg->chunk_size = chunk_size;
+ } else {
+ /* TODO: some calc_policy solution for cache ? */
+ if (!recalculate_pool_chunk_size_with_dev_hints(pool_seg->lv, 0,
+ THIN_CHUNK_SIZE_CALC_METHOD_GENERIC))
+ return_0;
+ }
+
+ return 1;
+}
+
+/*
* Wipe cache pool metadata area before use.
*
* Activates metadata volume as 'cache-pool' so regular wiping
diff --git a/lib/metadata/metadata-exported.h b/lib/metadata/metadata-exported.h
index 54c2668..b3f450a 100644
--- a/lib/metadata/metadata-exported.h
+++ b/lib/metadata/metadata-exported.h
@@ -1216,6 +1216,11 @@ int cache_mode_is_set(const struct lv_segment *seg);
int cache_set_mode(struct lv_segment *cache_seg, const char *str);
int cache_set_policy(struct lv_segment *cache_seg, const char *name,
const struct dm_config_tree *settings);
+int cache_set_params(struct lv_segment *seg,
+ const char *cache_mode,
+ const char *policy_name,
+ const struct dm_config_tree *policy_settings,
+ uint32_t chunk_size);
void cache_check_for_warns(const struct lv_segment *seg);
int update_cache_pool_params(const struct segment_type *segtype,
struct volume_group *vg, unsigned attr,
6 years, 10 months
master - cache: add validate_lv_cache_chunk_size
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=ae805eea50b103...
Commit: ae805eea50b1033115a18b8a0c9931c2c917b8b2
Parent: 00dfca034c7478b88874d43bc36633e3176d1866
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Tue May 3 21:50:04 2016 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Thu May 5 23:30:49 2016 +0200
cache: add validate_lv_cache_chunk_size
---
lib/metadata/cache_manip.c | 19 +++++++++++++++++++
lib/metadata/metadata-exported.h | 1 +
2 files changed, 20 insertions(+), 0 deletions(-)
diff --git a/lib/metadata/cache_manip.c b/lib/metadata/cache_manip.c
index a514828..5ecfbe2 100644
--- a/lib/metadata/cache_manip.c
+++ b/lib/metadata/cache_manip.c
@@ -184,6 +184,25 @@ int update_cache_pool_params(const struct segment_type *segtype,
}
/*
+ * Validate if existing cache-pool can be used with given chunk size
+ * i.e. cache-pool metadata size fits all info.
+ */
+int validate_lv_cache_chunk_size(struct logical_volume *pool_lv, uint32_t chunk_size)
+{
+ uint64_t min_size = _cache_min_metadata_size(pool_lv->size, chunk_size);
+
+ if (min_size > first_seg(pool_lv)->metadata_lv->size) {
+ log_error("Cannot use chunk size %s with cache pool %s. "
+ "Minimal required size for metadata is %s.",
+ display_size(pool_lv->vg->cmd, chunk_size),
+ display_lvname(pool_lv),
+ display_size(pool_lv->vg->cmd, min_size));
+ return 0;
+ }
+
+ return 1;
+}
+/*
* Validate arguments for converting origin into cached volume with given cache pool.
*
* Always validates origin_lv, and when it is known also cache pool_lv
diff --git a/lib/metadata/metadata-exported.h b/lib/metadata/metadata-exported.h
index 8c4dfc3..54c2668 100644
--- a/lib/metadata/metadata-exported.h
+++ b/lib/metadata/metadata-exported.h
@@ -1222,6 +1222,7 @@ int update_cache_pool_params(const struct segment_type *segtype,
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_chunk_size(struct logical_volume *pool_lv, 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);
struct logical_volume *lv_cache_create(struct logical_volume *pool,
6 years, 10 months