summaryrefslogtreecommitdiffstats
path: root/lib/metadata/lv_manip.c
diff options
context:
space:
mode:
authorJonathan Earl Brassow <jbrassow@redhat.com>2012-02-23 17:36:35 +0000
committerJonathan Earl Brassow <jbrassow@redhat.com>2012-02-23 17:36:35 +0000
commit870762d8e3a585ffe501b74e22abab66965fca55 (patch)
tree7d3e6e9ef0f559171d8c665cff8eded38a350a3a /lib/metadata/lv_manip.c
parentd4836062ff55800080de0279bac491291ab75621 (diff)
downloadlvm2-870762d8e3a585ffe501b74e22abab66965fca55.tar.gz
lvm2-870762d8e3a585ffe501b74e22abab66965fca55.tar.xz
lvm2-870762d8e3a585ffe501b74e22abab66965fca55.zip
Require number of stripes to be greater than parity devices in higher RAID.
Also, add some comments to code that I recently added that may be unclear otherwise.
Diffstat (limited to 'lib/metadata/lv_manip.c')
-rw-r--r--lib/metadata/lv_manip.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/lib/metadata/lv_manip.c b/lib/metadata/lv_manip.c
index a743c075..fef26451 100644
--- a/lib/metadata/lv_manip.c
+++ b/lib/metadata/lv_manip.c
@@ -752,6 +752,22 @@ static struct alloc_handle *_alloc_init(struct cmd_context *cmd,
area_count = stripes;
size = sizeof(*ah);
+
+ /*
+ * It is a requirement that RAID 4/5/6 are created with a number of
+ * stripes that is greater than the number of parity devices. (e.g
+ * RAID4/5 must have at least 2 stripes and RAID6 must have at least
+ * 3.) It is also a constraint that, when replacing individual devices
+ * in a RAID 4/5/6 array, no more devices can be replaced than
+ * there are parity devices. (Otherwise, there would not be enough
+ * redundancy to maintain the array.) Understanding these two
+ * constraints allows us to infer whether the caller of this function
+ * is intending to allocate an entire array or just replacement
+ * component devices. In the former case, we must account for the
+ * necessary parity_count. In the later case, we do not need to
+ * account for the extra parity devices because the array already
+ * exists and they only want replacement drives.
+ */
parity_count = (area_count <= segtype->parity_devs) ? 0 :
segtype->parity_devs;
alloc_count = area_count + parity_count;