summaryrefslogtreecommitdiffstats
path: root/lib/activate
diff options
context:
space:
mode:
authorJonathan Earl Brassow <jbrassow@redhat.com>2011-08-18 19:38:26 +0000
committerJonathan Earl Brassow <jbrassow@redhat.com>2011-08-18 19:38:26 +0000
commit6d04311efabec604e92664da1979176c1167e826 (patch)
treee775ca86c6b079309e82611c08b26377c12ed425 /lib/activate
parenta324baf6a13cb84f46dda81b6f3c7e795820c35d (diff)
downloadlvm2-6d04311efabec604e92664da1979176c1167e826.tar.gz
lvm2-6d04311efabec604e92664da1979176c1167e826.tar.xz
lvm2-6d04311efabec604e92664da1979176c1167e826.zip
Add the ability to split an image from the mirror and track changes.
~> lvconvert --splitmirrors 1 --trackchanges vg/lv The '--trackchanges' option allows a user the ability to use an image of a RAID1 array for the purposes of temporary read-only access. The image can be merged back into the array at a later time and only the blocks that have changed in the array since the split will be resync'ed. This operation can be thought of as a partial split. The image is never completely extracted from the array, in that the array reserves the position the device occupied and tracks the differences between the array and the split image via a bitmap. The image itself is rendered read-only and the name (<LV>_rimage_*) cannot be changed. The user can complete the split (permanently splitting the image from the array) by re-issuing the 'lvconvert' command without the '--trackchanges' argument and specifying the '--name' argument. ~> lvconvert --splitmirrors 1 --name my_split vg/lv Merging the tracked image back into the array is done with the '--merge' option (included in a follow-on patch). ~> lvconvert --merge vg/lv_rimage_<n> The internal mechanics of this are relatively simple. The 'raid' device- mapper target allows for the specification of an empty slot in an array via '- -'. This is what will be used if a partial activation of an array is ever required. (It would also be possible to use 'error' targets in place of the '- -'.) If a RAID image is found to be both read-only and visible, then it is considered separate from the array and '- -' is used to hold it's position in the array. So, all that needs to be done to temporarily split an image from the array /and/ cause the kernel target's bitmap to track (aka "mark") changes made is to make the specified image visible and read-only. To merge the device back into the array, the image needs to be returned to the read/write state of the top-level LV and made invisible.
Diffstat (limited to 'lib/activate')
-rw-r--r--lib/activate/dev_manager.c40
1 files changed, 31 insertions, 9 deletions
diff --git a/lib/activate/dev_manager.c b/lib/activate/dev_manager.c
index 3280fd65..d1195a1f 100644
--- a/lib/activate/dev_manager.c
+++ b/lib/activate/dev_manager.c
@@ -1226,17 +1226,39 @@ int add_areas_line(struct dev_manager *dm, struct lv_segment *seg,
if (!dm_tree_node_add_target_area(node, dev_name(seg_dev(seg, s)), NULL,
(seg_pv(seg, s)->pe_start + (extent_size * seg_pe(seg, s)))))
return_0;
- } else if (seg_type(seg, s) == AREA_LV) {
- if (seg_is_raid(seg)) {
- dlid = build_dm_uuid(dm->mem,
- seg_metalv(seg, s)->lvid.s,
- NULL);
- if (!dlid)
- return_0;
- if (!dm_tree_node_add_target_area(node, NULL, dlid,
- extent_size * seg_metale(seg, s)))
+ } else if (seg_is_raid(seg)) {
+ /*
+ * RAID can handle unassigned areas. It simple puts
+ * '- -' in for the metadata/data device pair. This
+ * is a valid way to indicate to the RAID target that
+ * the device is missing.
+ *
+ * If an image is marked as VISIBLE_LV and !LVM_WRITE,
+ * it means the device has temporarily been extracted
+ * from the array. It may come back at a future date,
+ * so the bitmap must track differences. Again, '- -'
+ * is used in the CTR table.
+ */
+ if ((seg_type(seg, s) == AREA_UNASSIGNED) ||
+ ((seg_lv(seg, s)->status & VISIBLE_LV) &&
+ !(seg_lv(seg, s)->status & LVM_WRITE))) {
+ /* One each for metadata area and data area */
+ if (!dm_tree_node_add_null_area(node, 0) ||
+ !dm_tree_node_add_null_area(node, 0))
return_0;
+ continue;
}
+ if (!(dlid = build_dm_uuid(dm->mem, seg_metalv(seg, s)->lvid.s, NULL)))
+ return_0;
+ if (!dm_tree_node_add_target_area(node, NULL, dlid, extent_size * seg_metale(seg, s)))
+ return_0;
+
+ if (!(dlid = build_dm_uuid(dm->mem, seg_lv(seg, s)->lvid.s, NULL)))
+ return_0;
+ if (!dm_tree_node_add_target_area(node, NULL, dlid, extent_size * seg_le(seg, s)))
+ return_0;
+ } else if (seg_type(seg, s) == AREA_LV) {
+
if (!(dlid = build_dm_uuid(dm->mem, seg_lv(seg, s)->lvid.s, NULL)))
return_0;
if (!dm_tree_node_add_target_area(node, NULL, dlid, extent_size * seg_le(seg, s)))