Refactoring lvconvert mirror
cover Refactoring lvconvert mirror
Hi,
This patchset refactors lvconvert mirror.
The patches are applicable on top of the pvmove refactoring patches.
https://www.redhat.com/archives/lvm-devel/2007-December/msg00020.html
I would like to know whether this changes are acceptable. I guess there might be other needs for layer insertion/removal APIs. Comments are welcome.
If they looks ok, I'll convert add-mirror-to-mirror patches based on this.
The patches add following APIs:
- lv_add_mirrors(), lv_remove_mirrors()
Generic APIs for lvconvert mirror.
Having 2 modes of conversion: MIRROR_BY_SEG and MIRROR_BY_LV. MIRROR_BY_LV is for the current version of lvconvert, i.e. mirroring by mimage LVs.
MIRROR_BY_SEG is for the current version of pvmove, i.e. mirroring segment by segment.
- add_mirror_images()
Add mirrors (mimage LVs) to LV.
The counter part of existing remove_mirror_images(). Wrapped by lv_add_mirrors().
- add_mirror_log(), remove_mirror_log()
Simplified version of the APIs specific to add/remove disk log.
- lv_mirror_count()
Returns the number of mirrors
- insert_layer_for_lv(), remove_layer_from_lv()
Insert a layer on top of the LV and remove it.
Then, lvconvert, lvcreate and pvmove are converted to use them.
The patchset also includes an experimental patch to allow
- lvcreate/lvconvert to create segment-by-segment mirrored LV
- pvmove to use disk log
[1/6] add insert_layer_for_lv() / remove_layer_from_lv() [2/6] add add_mirror_images(), {add,remove}_mirror_log() [3/6] change lvconvert to use the new APIs
[4/6] change lvcreate to use the new APIs
[5/6] remove unused mirror functions
[6/6] add and convert tools to use lv_{add,remove}_mirrors() [Appendix] experimental: pvmove with disk log and seg-by-seg mirror LV
Thanks,
Signature · 1 line
Jun'ichi Nomura, NEC Corporation of America
PATCH 1/6 Add insert_layer_for_lv() / remove_layer_from_lv()
Add insert_layer_for_lv() / remove_layer_from_lv().
insert_layer_for_lv() simply creates an layer LV with specified suffix, move all segments of the LV to the layer LV ,then maps linearly from the LV to the layer LV.
remove_layer_from_lv() removes the top-level layer from the LV. This might be too simple.
Thanks,
Signature · 8 lines
Jun'ichi Nomura, NEC Corporation of America -------------- next part -------------- A non-text attachment was scrubbed... Name: lvm2-insert-layer-lv.patch Type: text/x-patch Size: 4851 bytes Desc: not available URL: <http://listman.redhat.com/archives/lvm-devel/attachments/20071213/2acab1c1/attachment.bin>
PATCH 2/6 Add add_mirror_images() / {add, remove}_mirror_log()
In reply to Jun'ichi NomuraAdd functions to support LV conversion to mirror as whole-lv
- add_mirror_images()
- {add,remove}_mirror_log()
write_log_header() and set_lv() are moved/copied from toollib.
Thanks,
Signature · 8 lines
Jun'ichi Nomura, NEC Corporation of America -------------- next part -------------- A non-text attachment was scrubbed... Name: lvm2-convert-lv-mirrored.patch Type: text/x-patch Size: 15937 bytes Desc: not available URL: <http://listman.redhat.com/archives/lvm-devel/attachments/20071213/273e4730/attachment.bin>
PATCH 3/6 Change lvconvert to use the new mirror APIs
In reply to Jun'ichi NomuraChange lvconvert to use add_mirror_images() and {add,remove}_mirror_log().
There should be no change in functionality.
Thanks,
Signature · 8 lines
Jun'ichi Nomura, NEC Corporation of America -------------- next part -------------- A non-text attachment was scrubbed... Name: lvm2-lvconvert-use-new-mirror-api.patch Type: text/x-patch Size: 3330 bytes Desc: not available URL: <http://listman.redhat.com/archives/lvm-devel/attachments/20071213/89c4ad28/attachment.bin>
PATCH 4/6 Change lvcreate to use the new mirror APIs
In reply to Jun'ichi NomuraChange lvconvert to use add_mirror_images().
The patch simplifies the lvcreate code and we no longer need to export allocate_extents() directly to tools.
However, this patch slightly changes the allocation logic. Original code allocated all mirrors at once.
OTOH, this code creates a linear LV first then adds mirrors to it. It's better to allocate all at once because otherwise the allocation code may make worse choice at the first attempt.
To do that, we have to be able to create an empty mirror layers.
Thanks,
Signature · 8 lines
Jun'ichi Nomura, NEC Corporation of America -------------- next part -------------- A non-text attachment was scrubbed... Name: lvm2-lvcreate-use-new-mirror-api.patch Type: text/x-patch Size: 3257 bytes Desc: not available URL: <http://listman.redhat.com/archives/lvm-devel/attachments/20071213/174fcfbb/attachment.bin>
PATCH 5/6 Remove unused mirror functions
In reply to Jun'ichi NomuraThis patch removes:
- lv_add_mirror_segment()
Replaced by lv_add_mirror_lvs()
- lv_add_more_mirrored_areas()
- add_mirror_layers()
These functions were not used.
- create_mirror_layers()
Replaced by add_mirror_images()
- generate_log_name_format()
"_mlog" hard coding is moved to lib. ("_mimage" has been there.)
- create_mirror_log()
Replaced by add_mirror_log()
- _write_log_header()
Moved to lib
and renames:
- _create_layers_for_mirror() -> _create_mimage_lvs()
This function doesn't create layers but just creates mimage LVs.
Signature · 8 lines
Jun'ichi Nomura, NEC Corporation of America -------------- next part -------------- A non-text attachment was scrubbed... Name: lvm2-remove-unused-mirror-functions.patch Type: text/x-patch Size: 14528 bytes Desc: not available URL: <http://listman.redhat.com/archives/lvm-devel/attachments/20071213/bbbfae2c/attachment.bin>
PATCH 6/6 Add lv_{add,remove}_mirrors()
In reply to Jun'ichi NomuraThis patch adds generic wrappers for mirror addition / removal and changes lvcreate, lvconvert and pvmove to use them.
Mirror addition has 2 modes: MIRROR_BY_SEG and MIRROR_BY_LV.
Thanks,
Signature · 8 lines
Jun'ichi Nomura, NEC Corporation of America -------------- next part -------------- A non-text attachment was scrubbed... Name: lvm2-generic-lv-add-remove-mirrors.patch Type: text/x-patch Size: 7395 bytes Desc: not available URL: <http://listman.redhat.com/archives/lvm-devel/attachments/20071213/7094a477/attachment.bin>
PATCH 1/1 Experimental: pvmove with disk log and seg-by-seg mirrored LV
In reply to Jun'ichi NomuraThis patch is experimental and just a proof-of-concept of new APIs. (Some changes in lib were needed for adding pvmove support.)
Examples of commands and 'dmsetup ls --tree':
("/dev/mapper/d*" are PVs)
Normal pvmove:
# pvmove /dev/mapper/d1 /dev/mapper/d3
testvg-lvol2 (254:11)
|-d2 (254:2)
`-testvg-pvmove0 (254:13)
|-d3 (254:3)
`-d1 (254:1)
testvg-lvol1 (254:10)
`-testvg-pvmove0 (254:13)
|-d3 (254:3)
`-d1 (254:1)Disklog pvmove:
# pvmove --mirrorlog disk /dev/mapper/d1 /dev/mapper/d3 /dev/mapper/d5:0-0
testvg-lvol2 (254:11)
|-d2 (254:2)
`-testvg-pvmove0 (254:16)
|-testvg-pvmove0_mimage_1 (254:15)
| `-d3 (254:3)
|-testvg-pvmove0_mimage_0 (254:14)
| `-d1 (254:1)
`-testvg-pvmove0_mlog (254:13)
`-d5 (254:5)
testvg-lvol1 (254:10)
`-testvg-pvmove0 (254:16)
|-testvg-pvmove0_mimage_1 (254:15)
| `-d3 (254:3)
|-testvg-pvmove0_mimage_0 (254:14)
| `-d1 (254:1)
`-testvg-pvmove0_mlog (254:13)
`-d5 (254:5)Normal corelog mirror LV:
# lvcreate -m1 -l1 --mirrorlog core testvg
testvg-lvol0 (254:11)
|-testvg-lvol0_mimage_1 (254:10)
| `-d2 (254:2)
`-testvg-lvol0_mimage_0 (254:9)
`-d1 (254:1)Seg-by-seg corelog mirror LV:
# lvcreate -m1 -l1 --mirrorlog seg testvg
testvg-lvol0 (254:9)
|-d2 (254:2)
`-d1 (254:1)Thanks,
Signature · 8 lines
Jun'ichi Nomura, NEC Corporation of America -------------- next part -------------- A non-text attachment was scrubbed... Name: pvmove-disklog-option.patch Type: text/x-patch Size: 9942 bytes Desc: not available URL: <http://listman.redhat.com/archives/lvm-devel/attachments/20071213/95d64619/attachment.bin>