summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Teigland <teigland@redhat.com>2017-02-07 11:52:13 -0600
committerDavid Teigland <teigland@redhat.com>2017-02-10 11:07:41 -0600
commitc025c8b46ff9ae3881baf8eb734d6d9d447630ce (patch)
tree4b9bf4fae660559d80255c3c91e8977971d83163
parent2baabc823fffd0a29a083af6ba2fb5155d6fb789 (diff)
downloadlvm2-c025c8b46ff9ae3881baf8eb734d6d9d447630ce.tar.gz
lvconvert: add command to change region size of a raid LV
-rw-r--r--lib/metadata/metadata-exported.h2
-rw-r--r--lib/metadata/raid_manip.c6
-rw-r--r--test/shell/lvconvert-raid-regionsize.sh2
-rw-r--r--tools/command-lines.in7
-rw-r--r--tools/lvconvert.c15
-rw-r--r--tools/lvmcmdline.c1
-rw-r--r--tools/tools.h1
7 files changed, 33 insertions, 1 deletions
diff --git a/lib/metadata/metadata-exported.h b/lib/metadata/metadata-exported.h
index 235f634a2..88ccb0be4 100644
--- a/lib/metadata/metadata-exported.h
+++ b/lib/metadata/metadata-exported.h
@@ -1224,6 +1224,8 @@ int lv_raid_replace(struct logical_volume *lv, int force,
struct dm_list *remove_pvs, struct dm_list *allocate_pvs);
int lv_raid_remove_missing(struct logical_volume *lv);
int partial_raid_lv_supports_degraded_activation(const struct logical_volume *lv);
+int lv_raid_change_region_size(struct logical_volume *lv,
+ int yes, int force, uint32_t new_region_size);
/* -- metadata/raid_manip.c */
/* ++ metadata/cache_manip.c */
diff --git a/lib/metadata/raid_manip.c b/lib/metadata/raid_manip.c
index 6efbc5cbe..f543f2591 100644
--- a/lib/metadata/raid_manip.c
+++ b/lib/metadata/raid_manip.c
@@ -4092,6 +4092,12 @@ int lv_raid_convert(struct logical_volume *lv,
new_region_size, allocate_pvs);
}
+int lv_raid_change_region_size(struct logical_volume *lv,
+ int yes, int force, uint32_t new_region_size)
+{
+ return _region_size_change_requested(lv, yes, new_region_size);
+}
+
static int _remove_partial_multi_segment_image(struct logical_volume *lv,
struct dm_list *remove_pvs)
{
diff --git a/test/shell/lvconvert-raid-regionsize.sh b/test/shell/lvconvert-raid-regionsize.sh
index 4f0e90da7..f025d1828 100644
--- a/test/shell/lvconvert-raid-regionsize.sh
+++ b/test/shell/lvconvert-raid-regionsize.sh
@@ -26,7 +26,7 @@ function _test_regionsize
local vg=$4
local lv=$5
- lvconvert --type $type --yes -R $regionsize $vg/$lv
+ lvconvert --yes -R $regionsize $vg/$lv
[ $? -ne 0 ] && return 1
check lv_field $vg/$lv regionsize "$regionsize_str"
fsck -fn /dev/mapper/$vg-$lv
diff --git a/tools/command-lines.in b/tools/command-lines.in
index ca5259feb..6743b7989 100644
--- a/tools/command-lines.in
+++ b/tools/command-lines.in
@@ -364,6 +364,13 @@ ID: lvconvert_raid_types
DESC: Convert LV to raid1 or mirror, or change number of mirror images.
RULE: all not lv_is_locked lv_is_pvmove
+lvconvert --regionsize SizeMB LV_raid
+OO: OO_LVCONVERT
+ID: lvconvert_change_region_size
+DESC: Change the region size of an LV.
+RULE: all not lv_is_locked lv_is_pvmove
+RULE: all not LV_raid0
+
---
# lvconvert raid-related utilities
diff --git a/tools/lvconvert.c b/tools/lvconvert.c
index 75bdcb97e..4e86698f4 100644
--- a/tools/lvconvert.c
+++ b/tools/lvconvert.c
@@ -4397,6 +4397,21 @@ out:
return ret;
}
+static int _lvconvert_change_region_size_single(struct cmd_context *cmd, struct logical_volume *lv,
+ struct processing_handle *handle)
+{
+ if (!lv_raid_change_region_size(lv, arg_is_set(cmd, yes_ARG), arg_count(cmd, force_ARG),
+ arg_int_value(cmd, regionsize_ARG, 0)))
+ return ECMD_FAILED;
+ return ECMD_PROCESSED;
+}
+
+int lvconvert_change_region_size_cmd(struct cmd_context * cmd, int argc, char **argv)
+{
+ return process_each_lv(cmd, 1, cmd->position_argv, NULL, NULL, READ_FOR_UPDATE,
+ NULL, &_lvconvert_visible_check, &_lvconvert_change_region_size_single);
+}
+
/*
* split mirror images
*/
diff --git a/tools/lvmcmdline.c b/tools/lvmcmdline.c
index 121a9dd43..4fda35606 100644
--- a/tools/lvmcmdline.c
+++ b/tools/lvmcmdline.c
@@ -152,6 +152,7 @@ struct command_function command_functions[CMD_COUNT] = {
{ lvconvert_split_mirror_images_CMD, lvconvert_split_mirror_images_cmd},
{ lvconvert_change_mirrorlog_CMD, lvconvert_change_mirrorlog_cmd },
{ lvconvert_merge_mirror_images_CMD, lvconvert_merge_mirror_images_cmd },
+ { lvconvert_change_region_size_CMD, lvconvert_change_region_size_cmd },
/* redirected to merge_snapshot/merge_thin/merge_mirrors */
{ lvconvert_merge_CMD, lvconvert_merge_cmd },
diff --git a/tools/tools.h b/tools/tools.h
index 4e1d87f01..00476d106 100644
--- a/tools/tools.h
+++ b/tools/tools.h
@@ -284,6 +284,7 @@ int lvconvert_raid_types_cmd(struct cmd_context * cmd, int argc, char **argv);
int lvconvert_split_mirror_images_cmd(struct cmd_context * cmd, int argc, char **argv);
int lvconvert_merge_mirror_images_cmd(struct cmd_context *cmd, int argc, char **argv);
int lvconvert_change_mirrorlog_cmd(struct cmd_context * cmd, int argc, char **argv);
+int lvconvert_change_region_size_cmd(struct cmd_context * cmd, int argc, char **argv);
int lvconvert_merge_cmd(struct cmd_context *cmd, int argc, char **argv);