master - pool: drop duplicated sign test
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=8c72878cf2f53811cf5...
Commit: 8c72878cf2f53811cf5ae6fc9b7c787feb74e0c6
Parent: acfc82ae29eea2b107fb97e4d6fd350b3347f925
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Thu Mar 9 17:09:31 2017 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Fri Mar 10 19:33:00 2017 +0100
pool: drop duplicated sign test
Avoid duplicate testing of '-' sign.
Already checked with arg_from_list_is_negative().
---
tools/toollib.c | 5 -----
1 files changed, 0 insertions(+), 5 deletions(-)
diff --git a/tools/toollib.c b/tools/toollib.c
index f2951a7..c10f5ca 100644
--- a/tools/toollib.c
+++ b/tools/toollib.c
@@ -1243,11 +1243,6 @@ int get_pool_params(struct cmd_context *cmd,
}
if (arg_is_set(cmd, poolmetadatasize_ARG)) {
- if (arg_sign_value(cmd, poolmetadatasize_ARG, SIGN_NONE) == SIGN_MINUS) {
- log_error("Negative pool metadata size is invalid.");
- return 0;
- }
-
if (arg_is_set(cmd, poolmetadata_ARG)) {
log_error("Please specify either metadata logical volume or its size.");
return 0;
7 years, 2 months
master - pool: split chunk size validation
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=acfc82ae29eea2b107f...
Commit: acfc82ae29eea2b107fb97e4d6fd350b3347f925
Parent: 375e4bb3dae71bad55359f22aec6061c0b5f4296
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Sun Mar 5 17:41:16 2017 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Fri Mar 10 19:33:00 2017 +0100
pool: split chunk size validation
Move cache and thin bits into their respective manipulation files.
When possible directly call respective chunk_size validator.
---
lib/metadata/cache_manip.c | 26 +++++++++++++++++++++++++-
lib/metadata/merge.c | 8 +++++---
lib/metadata/metadata-exported.h | 2 ++
lib/metadata/pool_manip.c | 36 +++---------------------------------
lib/metadata/thin_manip.c | 26 +++++++++++++++++++++++++-
5 files changed, 60 insertions(+), 38 deletions(-)
diff --git a/lib/metadata/cache_manip.c b/lib/metadata/cache_manip.c
index 19008e3..5779f2d 100644
--- a/lib/metadata/cache_manip.c
+++ b/lib/metadata/cache_manip.c
@@ -196,7 +196,7 @@ int update_cache_pool_params(const struct segment_type *segtype,
return 0;
}
- if (!validate_pool_chunk_size(vg->cmd, segtype, *chunk_size))
+ if (!validate_cache_chunk_size(vg->cmd, *chunk_size))
return_0;
min_meta_size = _cache_min_metadata_size((uint64_t) pool_data_extents * extent_size, *chunk_size);
@@ -333,6 +333,30 @@ int validate_lv_cache_create_origin(const struct logical_volume *origin_lv)
return 1;
}
+int validate_cache_chunk_size(struct cmd_context *cmd, uint32_t chunk_size)
+{
+ const uint32_t min_size = DM_CACHE_MIN_DATA_BLOCK_SIZE;
+ const uint32_t max_size = DM_CACHE_MAX_DATA_BLOCK_SIZE;
+ int r = 1;
+
+ if ((chunk_size < min_size) || (chunk_size > max_size)) {
+ log_error("Cache chunk size %s is not in the range %s to %s.",
+ display_size(cmd, chunk_size),
+ display_size(cmd, min_size),
+ display_size(cmd, max_size));
+ r = 0;
+ }
+
+ if (chunk_size & (min_size - 1)) {
+ log_error("Cache chunk size %s must be a multiple of %s.",
+ display_size(cmd, chunk_size),
+ display_size(cmd, min_size));
+ r = 0;
+ }
+
+ return r;
+}
+
/*
* lv_cache_create
* @pool
diff --git a/lib/metadata/merge.c b/lib/metadata/merge.c
index f82e1e7..b600bc4 100644
--- a/lib/metadata/merge.c
+++ b/lib/metadata/merge.c
@@ -339,6 +339,8 @@ static void _check_lv_segment(struct logical_volume *lv, struct lv_segment *seg,
if (!seg->policy_name)
seg_error("is missing cache policy name");
}
+ if (!validate_cache_chunk_size(lv->vg->cmd, seg->chunk_size))
+ seg_error("has invalid chunk size.");
} else { /* !cache_pool */
if (seg->cache_mode)
seg_error("sets cache mode");
@@ -380,9 +382,6 @@ static void _check_lv_segment(struct logical_volume *lv, struct lv_segment *seg,
seg_error("is missing a pool metadata LV");
} else if (!(seg2 = first_seg(seg->metadata_lv)) || (find_pool_seg(seg2) != seg))
seg_error("metadata LV does not refer back to pool LV");
-
- if (!validate_pool_chunk_size(lv->vg->cmd, seg->segtype, seg->chunk_size))
- seg_error("has invalid chunk size.");
} else { /* !thin_pool && !cache_pool */
if (seg->metadata_lv)
seg_error("must not have pool metadata LV set");
@@ -394,6 +393,9 @@ static void _check_lv_segment(struct logical_volume *lv, struct lv_segment *seg,
if (lv_is_thin_volume(lv))
seg_error("is a thin volume that must not contain thin pool segment");
+
+ if (!validate_thin_pool_chunk_size(lv->vg->cmd, seg->chunk_size))
+ seg_error("has invalid chunk size.");
} else { /* !thin_pool */
if (seg->zero_new_blocks)
seg_error("sets zero_new_blocks");
diff --git a/lib/metadata/metadata-exported.h b/lib/metadata/metadata-exported.h
index dce2d44..c80a3c5 100644
--- a/lib/metadata/metadata-exported.h
+++ b/lib/metadata/metadata-exported.h
@@ -847,6 +847,8 @@ int thin_pool_feature_supported(const struct logical_volume *pool_lv, int featur
int recalculate_pool_chunk_size_with_dev_hints(struct logical_volume *pool_lv,
int passed_args,
int chunk_size_calc_policy);
+int validate_cache_chunk_size(struct cmd_context *cmd, uint32_t chunk_size);
+int validate_thin_pool_chunk_size(struct cmd_context *cmd, uint32_t chunk_size);
int validate_pool_chunk_size(struct cmd_context *cmd, const struct segment_type *segtype, uint32_t chunk_size);
int update_pool_lv(struct logical_volume *lv, int activate);
int update_pool_params(const struct segment_type *segtype,
diff --git a/lib/metadata/pool_manip.c b/lib/metadata/pool_manip.c
index a0fe11c..aea11b6 100644
--- a/lib/metadata/pool_manip.c
+++ b/lib/metadata/pool_manip.c
@@ -394,40 +394,10 @@ int validate_pool_chunk_size(struct cmd_context *cmd,
const struct segment_type *segtype,
uint32_t chunk_size)
{
- uint32_t min_size, max_size;
- const char *name;
- int r = 1;
-
- if (segtype_is_cache(segtype) || segtype_is_cache_pool(segtype)) {
- min_size = DM_CACHE_MIN_DATA_BLOCK_SIZE;
- max_size = DM_CACHE_MAX_DATA_BLOCK_SIZE;
- name = "Cache";
- } else if (segtype_is_thin(segtype)) {
- min_size = DM_THIN_MIN_DATA_BLOCK_SIZE;
- max_size = DM_THIN_MAX_DATA_BLOCK_SIZE;
- name = "Thin";
- } else {
- log_error(INTERNAL_ERROR "Cannot validate chunk size of "
- "%s segtype.", segtype->name);
- return 0;
- }
-
- if ((chunk_size < min_size) || (chunk_size > max_size)) {
- log_error("%s pool chunk size %s is not in the range %s to %s.",
- name, display_size(cmd, chunk_size),
- display_size(cmd, min_size),
- display_size(cmd, max_size));
- r = 0;
- }
-
- if (chunk_size & (min_size - 1)) {
- log_error("%s pool chunk size %s must be a multiple of %s.",
- name, display_size(cmd, chunk_size),
- display_size(cmd, min_size));
- r = 0;
- }
+ if (segtype_is_cache(segtype) || segtype_is_cache_pool(segtype))
+ return validate_cache_chunk_size(cmd, chunk_size);
- return r;
+ return validate_thin_pool_chunk_size(cmd, chunk_size);
}
int recalculate_pool_chunk_size_with_dev_hints(struct logical_volume *pool_lv,
diff --git a/lib/metadata/thin_manip.c b/lib/metadata/thin_manip.c
index 27daf6a..7748cd3 100644
--- a/lib/metadata/thin_manip.c
+++ b/lib/metadata/thin_manip.c
@@ -622,7 +622,7 @@ int update_thin_pool_params(const struct segment_type *segtype,
}
}
- if (!validate_pool_chunk_size(cmd, segtype, *chunk_size))
+ if (!validate_thin_pool_chunk_size(cmd, *chunk_size))
return_0;
if (!(passed_args & PASS_ARG_DISCARDS)) {
@@ -830,3 +830,27 @@ int check_new_thin_pool(const struct logical_volume *pool_lv)
return 1;
}
+
+int validate_thin_pool_chunk_size(struct cmd_context *cmd, uint32_t chunk_size)
+{
+ const uint32_t min_size = DM_THIN_MIN_DATA_BLOCK_SIZE;
+ const uint32_t max_size = DM_THIN_MAX_DATA_BLOCK_SIZE;
+ int r = 1;
+
+ if ((chunk_size < min_size) || (chunk_size > max_size)) {
+ log_error("Thin pool chunk size %s is not in the range %s to %s.",
+ display_size(cmd, chunk_size),
+ display_size(cmd, min_size),
+ display_size(cmd, max_size));
+ r = 0;
+ }
+
+ if (chunk_size & (min_size - 1)) {
+ log_error("Thin pool chunk size %s must be a multiple of %s.",
+ display_size(cmd, chunk_size),
+ display_size(cmd, min_size));
+ r = 0;
+ }
+
+ return r;
+}
7 years, 2 months
master - thin: getting default chunk_size from single place
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=375e4bb3dae71bad553...
Commit: 375e4bb3dae71bad55359f22aec6061c0b5f4296
Parent: 50441f243387bb5fb0e27ebc7a859f5bdcbc4c60
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Wed Mar 1 11:23:26 2017 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Fri Mar 10 19:33:00 2017 +0100
thin: getting default chunk_size from single place
Basically code moving operation to have a single place resolving
thin_pool_chunk_size_policy.
Supported are generic & performance profiles.
Function is now shared between thin manipulation code and configuration
_CFG logic to obtain defaults and handle correct reporting upward coding
stack.
---
lib/config/config.c | 16 +++-----------
lib/metadata/metadata-exported.h | 2 +
lib/metadata/thin_manip.c | 40 +++++++++++++++++++++++++------------
3 files changed, 33 insertions(+), 25 deletions(-)
diff --git a/lib/config/config.c b/lib/config/config.c
index 3e30951..c62b4c3 100644
--- a/lib/config/config.c
+++ b/lib/config/config.c
@@ -2442,21 +2442,13 @@ const char *get_default_activation_mirror_image_fault_policy_CFG(struct cmd_cont
int get_default_allocation_thin_pool_chunk_size_CFG(struct cmd_context *cmd, struct profile *profile)
{
- const char *str;
uint32_t chunk_size;
+ int chunk_size_calc_method;
- if (!(str = find_config_tree_str(cmd, allocation_thin_pool_chunk_size_policy_CFG, profile))) {
- log_error(INTERNAL_ERROR "Cannot find configuration.");
- return 0;
- }
-
- if (!strcasecmp(str, "generic"))
+ if (!get_default_allocation_thin_pool_chunk_size(cmd, profile, &chunk_size,
+ &chunk_size_calc_method)) {
+ stack; /* Ignore this error, never happens... */
chunk_size = DEFAULT_THIN_POOL_CHUNK_SIZE * 2;
- else if (!strcasecmp(str, "performance"))
- chunk_size = DEFAULT_THIN_POOL_CHUNK_SIZE_PERFORMANCE * 2;
- else {
- log_error("Thin pool chunk size calculation policy \"%s\" is unrecognised.", str);
- return 0;
}
return (int) chunk_size;
diff --git a/lib/metadata/metadata-exported.h b/lib/metadata/metadata-exported.h
index 9e1f4b6..dce2d44 100644
--- a/lib/metadata/metadata-exported.h
+++ b/lib/metadata/metadata-exported.h
@@ -859,6 +859,8 @@ int update_profilable_pool_params(struct cmd_context *cmd, struct profile *profi
int passed_args, int *chunk_size_calc_method,
uint32_t *chunk_size, thin_discards_t *discards,
int *zero);
+int get_default_allocation_thin_pool_chunk_size(struct cmd_context *cmd, struct profile *profile,
+ uint32_t *chunk_size, int *chunk_size_calc_method);
int update_thin_pool_params(const struct segment_type *segtype,
struct volume_group *vg, unsigned attr,
int passed_args, uint32_t pool_data_extents,
diff --git a/lib/metadata/thin_manip.c b/lib/metadata/thin_manip.c
index 3e2a185..27daf6a 100644
--- a/lib/metadata/thin_manip.c
+++ b/lib/metadata/thin_manip.c
@@ -574,6 +574,30 @@ static size_t _estimate_chunk_size(uint64_t data_size, uint64_t metadata_size, i
return chunk_size;
}
+int get_default_allocation_thin_pool_chunk_size(struct cmd_context *cmd, struct profile *profile,
+ uint32_t *chunk_size, int *chunk_size_calc_method)
+{
+ const char *str;
+
+ if (!(str = find_config_tree_str(cmd, allocation_thin_pool_chunk_size_policy_CFG, profile))) {
+ log_error(INTERNAL_ERROR "Cannot find configuration.");
+ return 0;
+ }
+
+ if (!strcasecmp(str, "generic")) {
+ *chunk_size = DEFAULT_THIN_POOL_CHUNK_SIZE * 2;
+ *chunk_size_calc_method = THIN_CHUNK_SIZE_CALC_METHOD_GENERIC;
+ } else if (!strcasecmp(str, "performance")) {
+ *chunk_size = DEFAULT_THIN_POOL_CHUNK_SIZE_PERFORMANCE * 2;
+ *chunk_size_calc_method = THIN_CHUNK_SIZE_CALC_METHOD_PERFORMANCE;
+ } else {
+ log_error("Thin pool chunk size calculation policy \"%s\" is unrecognised.", str);
+ return 0;
+ }
+
+ return 1;
+}
+
int update_thin_pool_params(const struct segment_type *segtype,
struct volume_group *vg,
unsigned attr, int passed_args,
@@ -591,19 +615,9 @@ int update_thin_pool_params(const struct segment_type *segtype,
if (!(passed_args & PASS_ARG_CHUNK_SIZE)) {
if (!(*chunk_size = find_config_tree_int(cmd, allocation_thin_pool_chunk_size_CFG, profile) * 2)) {
- if (!(str = find_config_tree_str(cmd, allocation_thin_pool_chunk_size_policy_CFG, profile))) {
- log_error(INTERNAL_ERROR "Could not find configuration.");
- return 0;
- }
- if (!strcasecmp(str, "generic"))
- *chunk_size_calc_method = THIN_CHUNK_SIZE_CALC_METHOD_GENERIC;
- else if (!strcasecmp(str, "performance"))
- *chunk_size_calc_method = THIN_CHUNK_SIZE_CALC_METHOD_PERFORMANCE;
- else {
- log_error("Thin pool chunk size calculation policy \"%s\" is unrecognised.", str);
- return 0;
- }
- if (!(*chunk_size = get_default_allocation_thin_pool_chunk_size_CFG(cmd, profile)))
+ if (!get_default_allocation_thin_pool_chunk_size(cmd, profile,
+ chunk_size,
+ chunk_size_calc_method))
return_0;
}
}
7 years, 2 months
master - cache: properly translate DM_THIN_DISCARDS
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=50441f243387bb5fb0e...
Commit: 50441f243387bb5fb0e27ebc7a859f5bdcbc4c60
Parent: f221ba97c99c4369714755d636093aa9c6276791
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Tue Mar 7 23:55:08 2017 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Fri Mar 10 19:33:00 2017 +0100
cache: properly translate DM_THIN_DISCARDS
DM status uses DM defines which need to be translated to LVM enum.
---
lib/metadata/lv.c | 17 ++++++++++++++---
1 files changed, 14 insertions(+), 3 deletions(-)
diff --git a/lib/metadata/lv.c b/lib/metadata/lv.c
index a7e1dcd..8c33a5e 100644
--- a/lib/metadata/lv.c
+++ b/lib/metadata/lv.c
@@ -227,12 +227,23 @@ char *lvseg_kernel_discards_dup_with_info_and_seg_status(struct dm_pool *mem, co
{
const char *s = "";
char *ret;
+ thin_discards_t d;
- if (lvdm->seg_status.type == SEG_STATUS_THIN_POOL)
- s = get_pool_discards_name(lvdm->seg_status.thin_pool->discards);
+ if (lvdm->seg_status.type == SEG_STATUS_THIN_POOL) {
+ switch (lvdm->seg_status.thin_pool->discards) {
+ case DM_THIN_DISCARDS_IGNORE: d = THIN_DISCARDS_IGNORE; break;
+ case DM_THIN_DISCARDS_NO_PASSDOWN: d = THIN_DISCARDS_NO_PASSDOWN; break;
+ case DM_THIN_DISCARDS_PASSDOWN: d = THIN_DISCARDS_PASSDOWN; break;
+ default:
+ log_error("Kernel reports unknown discards status %u.",
+ lvdm->seg_status.thin_pool->discards);
+ return 0;
+ }
+ s = get_pool_discards_name(d);
+ }
if (!(ret = dm_pool_strdup(mem, s))) {
- log_error("lvseg_kernel_discards_dup_with_info_and_seg_status: dm_pool_strdup failed");
+ log_error("lvseg_kernel_discards_dup_with_info_and_seg_status: dm_pool_strdup failed.");
return NULL;
}
7 years, 2 months
master - lvcreate: avoid rejecting --metadataprofile
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=f221ba97c99c4369714...
Commit: f221ba97c99c4369714755d636093aa9c6276791
Parent: fb38426d289ab010d2083a394dca685eed13e7ff
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Thu Mar 2 23:02:28 2017 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Fri Mar 10 19:33:00 2017 +0100
lvcreate: avoid rejecting --metadataprofile
Likely user normaly have used 'shortcut' --profile option which
is (for lvcreate) decoded as metadataprofile.
However full option was rejected.
---
tools/lvcreate.c | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)
diff --git a/tools/lvcreate.c b/tools/lvcreate.c
index ed56757..206a10b 100644
--- a/tools/lvcreate.c
+++ b/tools/lvcreate.c
@@ -762,6 +762,7 @@ static int _lvcreate_params(struct cmd_context *cmd,
contiguous_ARG,\
ignoreactivationskip_ARG,\
ignoremonitoring_ARG,\
+ metadataprofile_ARG,\
monitor_ARG,\
mirrors_ARG,\
name_ARG,\
7 years, 2 months
master - lvconvert: validate name before prompt
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=fb38426d289ab010d20...
Commit: fb38426d289ab010d2083a394dca685eed13e7ff
Parent: 7ad57d55aff1f5647aed707fe22d2ff0d309d09d
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Fri Feb 24 12:56:40 2017 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Fri Mar 10 19:33:00 2017 +0100
lvconvert: validate name before prompt
Before prompting make sure name fits.
---
tools/lvconvert.c | 21 ++++++++++-----------
1 files changed, 10 insertions(+), 11 deletions(-)
diff --git a/tools/lvconvert.c b/tools/lvconvert.c
index 4e8dbc8..3d7259e 100644
--- a/tools/lvconvert.c
+++ b/tools/lvconvert.c
@@ -2719,6 +2719,16 @@ static int _lvconvert_to_pool(struct cmd_context *cmd,
}
/*
+ * The internal LV names for pool data/meta LVs.
+ */
+
+ if ((dm_snprintf(meta_name, sizeof(meta_name), "%s%s", lv->name, to_cachepool ? "_cmeta" : "_tmeta") < 0) ||
+ (dm_snprintf(data_name, sizeof(data_name), "%s%s", lv->name, to_cachepool ? "_cdata" : "_tdata") < 0)) {
+ log_error("Failed to create internal lv names, pool name is too long.");
+ return 0;
+ }
+
+ /*
* If an existing LV is to be used as the metadata LV,
* verify that it's in a usable state. These checks are
* not done by command def rules because this LV is not
@@ -2842,7 +2852,6 @@ static int _lvconvert_to_pool(struct cmd_context *cmd,
log_verbose("Pool metadata extents %u chunk_size %u", meta_extents, chunk_size);
-
/*
* Verify that user wants to use these LVs.
*/
@@ -2870,16 +2879,6 @@ static int _lvconvert_to_pool(struct cmd_context *cmd,
}
/*
- * The internal LV names for pool data/meta LVs.
- */
-
- if ((dm_snprintf(meta_name, sizeof(meta_name), "%s%s", lv->name, to_cachepool ? "_cmeta" : "_tmeta") < 0) ||
- (dm_snprintf(data_name, sizeof(data_name), "%s%s", lv->name, to_cachepool ? "_cdata" : "_tdata") < 0)) {
- log_error("Failed to create internal lv names, pool name is too long.");
- return 0;
- }
-
- /*
* If a new metadata LV needs to be created, collect the settings for
* the new LV and create it.
*
7 years, 2 months
master - lvconvert: indent and code simplification
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=7ad57d55aff1f5647ae...
Commit: 7ad57d55aff1f5647aed707fe22d2ff0d309d09d
Parent: dd2881f277ab1ecb6510520b1504e17ad73c486c
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Fri Feb 24 12:52:19 2017 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Fri Mar 10 19:33:00 2017 +0100
lvconvert: indent and code simplification
Simple modifications to existing _lvconvert_to_pool().
---
lib/metadata/cache_manip.c | 2 +-
tools/lvconvert.c | 24 ++++++++++--------------
2 files changed, 11 insertions(+), 15 deletions(-)
diff --git a/lib/metadata/cache_manip.c b/lib/metadata/cache_manip.c
index aee3db8..19008e3 100644
--- a/lib/metadata/cache_manip.c
+++ b/lib/metadata/cache_manip.c
@@ -292,7 +292,7 @@ int validate_lv_cache_create_pool(const struct logical_volume *pool_lv)
if (!dm_list_empty(&pool_lv->segs_using_this_lv)) {
seg = get_only_segment_using_this_lv(pool_lv);
- log_error("Logical volume %s is already in use by %s",
+ log_error("Logical volume %s is already in use by %s.",
display_lvname(pool_lv),
seg ? display_lvname(seg->lv) : "another LV");
return 0;
diff --git a/tools/lvconvert.c b/tools/lvconvert.c
index d5c8d49..4e8dbc8 100644
--- a/tools/lvconvert.c
+++ b/tools/lvconvert.c
@@ -2689,6 +2689,7 @@ static int _lvconvert_to_pool(struct cmd_context *cmd,
char *lockd_meta_name = NULL;
struct id lockd_data_id;
struct id lockd_meta_id;
+ const char *str_seg_type = to_cachepool ? SEG_TYPE_NAME_CACHE_POOL : SEG_TYPE_NAME_THIN_POOL;
if (lv_is_thin_pool(lv) || lv_is_cache_pool(lv)) {
@@ -2696,11 +2697,11 @@ static int _lvconvert_to_pool(struct cmd_context *cmd,
return 0;
}
- pool_segtype = to_cachepool ? get_segtype_from_string(cmd, SEG_TYPE_NAME_CACHE_POOL) :
- get_segtype_from_string(cmd, SEG_TYPE_NAME_THIN_POOL);
+ pool_segtype = get_segtype_from_string(cmd, str_seg_type);
if (!pool_segtype->ops->target_present(cmd, NULL, &target_attr)) {
- log_error("%s: Required device-mapper target(s) not detected in your kernel.", pool_segtype->name);
+ log_error("%s: Required device-mapper target(s) not detected in your kernel.",
+ pool_segtype->name);
return 0;
}
@@ -2708,7 +2709,7 @@ static int _lvconvert_to_pool(struct cmd_context *cmd,
activate_pool = to_thinpool && lv_is_active(lv);
/* Wipe metadata_lv by default, but allow skipping this for cache pools. */
- zero_metadata = to_cachepool ? arg_int_value(cmd, zero_ARG, 1) : 1;
+ zero_metadata = (to_cachepool) ? arg_int_value(cmd, zero_ARG, 1) : 1;
/* An existing LV needs to have its lock freed once it becomes a data LV. */
if (is_lockd_type(vg->lock_type) && lv->lock_args) {
@@ -2787,10 +2788,8 @@ static int _lvconvert_to_pool(struct cmd_context *cmd,
chunk_size = arg_uint_value(cmd, chunksize_ARG, 0);
if (!validate_pool_chunk_size(cmd, pool_segtype, chunk_size))
return_0;
- } else {
- /* A default will be chosen by the "update" function. */
+ } else /* A default will be chosen by the "update" function. */
chunk_size = 0;
- }
if (arg_is_set(cmd, poolmetadatasize_ARG)) {
meta_size = arg_uint64_value(cmd, poolmetadatasize_ARG, UINT64_C(0));
@@ -2799,10 +2798,8 @@ static int _lvconvert_to_pool(struct cmd_context *cmd,
} else if (metadata_lv) {
meta_extents = metadata_lv->le_count;
passed_args |= PASS_ARG_POOL_METADATA_SIZE;
- } else {
- /* A default will be chosen by the "update" function. */
+ } else /* A default will be chosen by the "update" function. */
meta_extents = 0;
- }
/* Tell the "update" function to ignore these, they are handled below. */
passed_args |= PASS_ARG_DISCARDS | PASS_ARG_ZERO;
@@ -2935,6 +2932,7 @@ static int _lvconvert_to_pool(struct cmd_context *cmd,
log_error("Aborting. Failed to activate metadata lv.");
return 0;
}
+ metadata_lv->status &= ~LV_TEMPORARY;
if (!wipe_lv(metadata_lv, (struct wipe_params) { .do_zero = 1 })) {
log_error("Aborting. Failed to wipe metadata lv.");
@@ -3171,8 +3169,8 @@ revert_new_lv:
}
static int _lvconvert_to_cache_vol(struct cmd_context *cmd,
- struct logical_volume *lv,
- struct logical_volume *cachepool_lv)
+ struct logical_volume *lv,
+ struct logical_volume *cachepool_lv)
{
struct logical_volume *cache_lv;
cache_mode_t cache_mode = 0;
@@ -3894,7 +3892,6 @@ static int _lvconvert_to_cache_vol_single(struct cmd_context *cmd,
log_warn("WARNING: Reusing cache pool metadata %s for volume caching.",
display_lvname(cachepool_lv));
}
-
}
/* When the lv arg is a thinpool, redirect command to data sub lv. */
@@ -4582,4 +4579,3 @@ int lvconvert(struct cmd_context *cmd, int argc, char **argv)
cmd->command->command_index, cmd->command->command_id);
return ECMD_FAILED;
}
-
7 years, 2 months
master - raid: enhance lv_raid_convert() header relative to reshaping
by Heinz Mauelshagen
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=dd2881f277ab1ecb651...
Commit: dd2881f277ab1ecb6510520b1504e17ad73c486c
Parent: 2fcbe34fe85fa57e1e2835dfba95fa21387377b6
Author: Heinz Mauelshagen <heinzm(a)redhat.com>
AuthorDate: Fri Mar 10 19:26:02 2017 +0100
Committer: Heinz Mauelshagen <heinzm(a)redhat.com>
CommitterDate: Fri Mar 10 19:26:02 2017 +0100
raid: enhance lv_raid_convert() header relative to reshaping
---
lib/metadata/raid_manip.c | 25 ++++++++++++++++++++++++-
1 files changed, 24 insertions(+), 1 deletions(-)
diff --git a/lib/metadata/raid_manip.c b/lib/metadata/raid_manip.c
index 2e31bf7..9954133 100644
--- a/lib/metadata/raid_manip.c
+++ b/lib/metadata/raid_manip.c
@@ -5910,10 +5910,33 @@ static int _conversion_options_allowed(const struct lv_segment *seg_from,
* Convert lv from one RAID type (or striped/mirror segtype) to new_segtype,
* or add/remove LVs to/from a RAID LV.
*
- * Non dm-raid changes e.g. mirror/striped functions are also called from here.
+ * Non RAID (i.e. dm-raid target relative) changes e.g. mirror/striped
+ * functions are also called from here. This supports e.g. conversions
+ * from existing striped LVs to raid4/5/6/10 and vice versa.
*
* Takeover is defined as a switch from one raid level to another, potentially
* involving the addition of one or more image component pairs and rebuild.
+ *
+ * Complementing takeover, reshaping is defined as changing properties of
+ * a RaidLV keeping the RAID level. These properties are the RAID layout
+ * algorithm (e.g. raid5_ls vs. raid5_ra), the stripe size (e.g. 64K vs. 128K)
+ * and the number of images.
+ *
+ * RAID level specific MD kernel constraints apply to reshaping:
+ *
+ * raid4/5/6 can vary all aforementioned properties within their respective
+ * redundancy * constraints (raid4/5 minimum of 3 images and raid6 minimum
+ * of 4 images; the latter is enforced to be 5 by lvm2.
+ *
+ * raid10 doesn't support the removal of images at all. It can only add them.
+ *
+ * For all levels raid4/5/6/10, the stripe size
+ * may not be larger than the region size.
+ *
+ * The maximum supported image count the MD kernel supports is 253;
+ * lvm2 may enforce smaller numbers via
+ * DEFAULT_RAID_MAX_IMAGES and DEFAULT_RAID1_MAX_IMAGES.
+ *
*/
int lv_raid_convert(struct logical_volume *lv,
const struct segment_type *new_segtype,
7 years, 2 months
master - raid: enhance lv_convert_raid() header relative to reshaping
by Heinz Mauelshagen
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=d9849f84b7c599953f5...
Commit: d9849f84b7c599953f54824bf66a8a168447e048
Parent: 2fcbe34fe85fa57e1e2835dfba95fa21387377b6
Author: Heinz Mauelshagen <heinzm(a)redhat.com>
AuthorDate: Fri Mar 10 19:24:46 2017 +0100
Committer: Heinz Mauelshagen <heinzm(a)redhat.com>
CommitterDate: Fri Mar 10 19:24:46 2017 +0100
raid: enhance lv_convert_raid() header relative to reshaping
---
lib/metadata/raid_manip.c | 25 ++++++++++++++++++++++++-
1 files changed, 24 insertions(+), 1 deletions(-)
diff --git a/lib/metadata/raid_manip.c b/lib/metadata/raid_manip.c
index 2e31bf7..9954133 100644
--- a/lib/metadata/raid_manip.c
+++ b/lib/metadata/raid_manip.c
@@ -5910,10 +5910,33 @@ static int _conversion_options_allowed(const struct lv_segment *seg_from,
* Convert lv from one RAID type (or striped/mirror segtype) to new_segtype,
* or add/remove LVs to/from a RAID LV.
*
- * Non dm-raid changes e.g. mirror/striped functions are also called from here.
+ * Non RAID (i.e. dm-raid target relative) changes e.g. mirror/striped
+ * functions are also called from here. This supports e.g. conversions
+ * from existing striped LVs to raid4/5/6/10 and vice versa.
*
* Takeover is defined as a switch from one raid level to another, potentially
* involving the addition of one or more image component pairs and rebuild.
+ *
+ * Complementing takeover, reshaping is defined as changing properties of
+ * a RaidLV keeping the RAID level. These properties are the RAID layout
+ * algorithm (e.g. raid5_ls vs. raid5_ra), the stripe size (e.g. 64K vs. 128K)
+ * and the number of images.
+ *
+ * RAID level specific MD kernel constraints apply to reshaping:
+ *
+ * raid4/5/6 can vary all aforementioned properties within their respective
+ * redundancy * constraints (raid4/5 minimum of 3 images and raid6 minimum
+ * of 4 images; the latter is enforced to be 5 by lvm2.
+ *
+ * raid10 doesn't support the removal of images at all. It can only add them.
+ *
+ * For all levels raid4/5/6/10, the stripe size
+ * may not be larger than the region size.
+ *
+ * The maximum supported image count the MD kernel supports is 253;
+ * lvm2 may enforce smaller numbers via
+ * DEFAULT_RAID_MAX_IMAGES and DEFAULT_RAID1_MAX_IMAGES.
+ *
*/
int lv_raid_convert(struct logical_volume *lv,
const struct segment_type *new_segtype,
7 years, 2 months
master - lvcreate: fix "striped" limit
by Heinz Mauelshagen
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=2fcbe34fe85fa57e1e2...
Commit: 2fcbe34fe85fa57e1e2835dfba95fa21387377b6
Parent: 43388f12208be07191b80a5ed328a87790ecd64a
Author: Heinz Mauelshagen <heinzm(a)redhat.com>
AuthorDate: Fri Mar 10 18:57:06 2017 +0100
Committer: Heinz Mauelshagen <heinzm(a)redhat.com>
CommitterDate: Fri Mar 10 18:57:06 2017 +0100
lvcreate: fix "striped" limit
Fix regression limiting number of stripes to 8.
Raise back to 128 as before.
Resolves: rhbz1389546
---
tools/lvcreate.c | 4 +++-
1 files changed, 3 insertions(+), 1 deletions(-)
diff --git a/tools/lvcreate.c b/tools/lvcreate.c
index cd31c99..ed56757 100644
--- a/tools/lvcreate.c
+++ b/tools/lvcreate.c
@@ -558,8 +558,10 @@ static int _read_mirror_and_raid_params(struct cmd_context *cmd,
else if (seg_is_any_raid6(lp))
max_images -= 2;
}
- } else
+ } else if (seg_is_mirrored(lp))
max_images = DEFAULT_MIRROR_MAX_IMAGES;
+ else
+ max_images = MAX_STRIPES;
/* Common mirror and raid params */
if (arg_is_set(cmd, mirrors_ARG)) {
7 years, 2 months