summaryrefslogtreecommitdiff
path: root/libdm/libdm-targets.c
diff options
context:
space:
mode:
authorHeinz Mauelshagen <heinzm@redhat.com>2017-02-24 00:50:00 +0100
committerHeinz Mauelshagen <heinzm@redhat.com>2017-02-24 05:20:58 +0100
commite2354ea344c248ede9faa872c260d46985830c0f (patch)
tree7dca2e33bedcd12aabd34ffba143e658a5fff7cb /libdm/libdm-targets.c
parentffe3ca26e05f9bb10f004bafe6866b189d7ac385 (diff)
downloadlvm2-e2354ea344c248ede9faa872c260d46985830c0f.tar.gz
lvconvert: add infrastructure for RaidLV reshaping support
In order to support striped raid5/6/10 LV reshaping (change of LV type, stripesize or number of legs), this patch introduces infrastructure prerequisites to be used by raid_manip.c extensions in followup patches. This base is needed for allocation of out-of-place reshape space required by the MD raid personalities to avoid writing over data in-place when reading off the current RAID layout or number of legs and writing out the new layout or to a different number of legs (i.e. restripe) Changes: - add members reshape_len to 'struct lv_segment' to store out-of-place reshape length per component rimage - add member data_copies to struct lv_segment to support more than 2 raid10 data copies - make alloc_lv_segment() aware of both reshape_len and data_copies - adjust all alloc_lv_segment() callers to the new API - add functions to retrieve the current data offset (needed for out-of-place reshaping space allocation) and the devices count from the kernel - make libdm deptree code aware of reshape_len - add LV flags for disk add/remove reshaping - support import/export of the new 'struct lv_segment' members - enhance lv_extend/_lv_reduce to cope with reshape_len - add seg_is_*/segtype_is_* macros related to reshaping - add target version check for reshaping - grow rebuilds/writemostly bitmaps to 246 bit to support kernel maximal - enhance libdm deptree code to support data_offset (out-of-place reshaping) and delta_disk (legs add/remove reshaping) target arguments Related: rhbz834579 Related: rhbz1191935 Related: rhbz1191978
Diffstat (limited to 'libdm/libdm-targets.c')
-rw-r--r--libdm/libdm-targets.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/libdm/libdm-targets.c b/libdm/libdm-targets.c
index c94e05753..6b8337234 100644
--- a/libdm/libdm-targets.c
+++ b/libdm/libdm-targets.c
@@ -89,6 +89,8 @@ static unsigned _count_fields(const char *p)
* <raid_type> <#devs> <health_str> <sync_ratio>
* Versions 1.5.0+ (6 fields):
* <raid_type> <#devs> <health_str> <sync_ratio> <sync_action> <mismatch_cnt>
+ * Versions 1.9.0+ (7 fields):
+ * <raid_type> <#devs> <health_str> <sync_ratio> <sync_action> <mismatch_cnt> <data_offset>
*/
int dm_get_status_raid(struct dm_pool *mem, const char *params,
struct dm_status_raid **status)
@@ -147,6 +149,22 @@ int dm_get_status_raid(struct dm_pool *mem, const char *params,
if (sscanf(p, "%s %" PRIu64, s->sync_action, &s->mismatch_count) != 2)
goto_bad;
+ if (num_fields < 7)
+ goto out;
+
+ /*
+ * All pre-1.9.0 version parameters are read. Now we check
+ * for additional 1.9.0+ parameters (i.e. nr_fields at least 7).
+ *
+ * Note that data_offset will be 0 if the
+ * kernel returns a pre-1.9.0 status.
+ */
+ msg_fields = "<data_offset>";
+ if (!(p = _skip_fields(params, 6))) /* skip pre-1.9.0 params */
+ goto bad;
+ if (sscanf(p, "%" PRIu64, &s->data_offset) != 1)
+ goto bad;
+
out:
*status = s;