master - cache: Code to allow the create/remove of cache LVs
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=96626f64fa499fb45dfc1afb39b86b70b8d3d9a4 Commit: 96626f64fa499fb45dfc1afb39b86b70b8d3d9a4 Parent: 97be8b3482a0c566d5fa529321bd035526974c96 Author: Jonathan Brassow <[email protected]> AuthorDate: Tue Feb 4 16:50:16 2014 -0600 Committer: Jonathan Brassow <[email protected]> CommitterDate: Tue Feb 4 16:50:16 2014 -0600
cache: Code to allow the create/remove of cache LVs
This patch allows users to create cache LVs with 'lvcreate'. An origin or a cache pool LV must be created first. Then, while supplying the origin or cache pool to the lvcreate command, the cache can be created.
Ex1:
Here the cache pool is created first, followed by the origin which will be cached.
~> lvcreate --type cache_pool -L 500M -n cachepool vg /dev/small_n_fast ~> lvcreate --type cache -L 1G -n lv vg/cachepool /dev/large_n_slow
Ex2:
Here the origin is created first, followed by the cache pool - allowing a cache LV to be created covering the origin.
~> lvcreate -L 1G -n lv vg /dev/large_n_slow
~> lvcreate --type cache -L 500M -n cachepool vg/lv /dev/small_n_fast
The code determines which type of LV was supplied (cache pool or origin) by checking its type. It ensures the right argument was given by ensuring that the origin is larger than the cache pool.
If the user wants to remove just the cache for an LV. They specify the LV's associated cache pool when removing:
~> lvremove vg/cachepool
If the user wishes to remove the origin, but leave the cachepool to be used for another LV, they specify the cache LV.
~> lvremove vg/lv
In order to remove it all, specify both LVs.
This patch also includes tests to create and remove cache pools and cache LVs.
--- lib/activate/dev_manager.c | 11 +++- lib/metadata/lv_manip.c | 130 ++++++++++++++++++++++++++++++++++-- lib/metadata/merge.c | 11 +++ lib/metadata/metadata-exported.h | 1 + test/shell/lvcreate-cache.sh | 135 ++++++++++++++++++++++++++++++++++++++ tools/lvcreate.c | 87 ++++++++++++++++++++++++- 6 files changed, 365 insertions(+), 10 deletions(-)
lib/activate/dev_manager.c +9 -2
@@ -1912,6 +1912,10 @@ static int _add_lv_to_dtree(struct dev_manager *dm, struct dm_tree *dtree, !_add_lv_to_dtree(dm, dtree, seg->pool_lv, 1)) /* stack */ return_0; +if (seg->pool_lv &&lv_is_cache_pool (seg->pool_lv) && + !_add_lv_to_dtree (dm, dtree, seg->pool_lv,0 )) + return_0; +for (s =0 ; s < seg->area_count; s++) {if (seg_type (seg, s) ==AREA_LV &&seg_lv (seg, s) && !_add_lv_to_dtree (dm, dtree,seg_lv (seg, s),0 ))
@@ -2376,15 +2380,18 @@ static int _add_segment_to_dtree(struct dev_manager *dm,if (seg->external_lv && !_add_new_external_lv_to_dtree (dm, dtree, seg->external_lv, laopts)) return_0; +/* Add mirror log */ if (seg->log_lv && !_add_new_lv_to_dtree (dm, dtree, seg->log_lv, laopts,NULL )) return_0; -/* Add thin pool metadata */ + +/* Add pool metadata */ if (seg->metadata_lv && !_add_new_lv_to_dtree (dm, dtree, seg->metadata_lv, laopts,NULL )) return_0; -/* Add thin pool layer */ + +/* Add pool layer */ if (seg->pool_lv && !_add_new_lv_to_dtree (dm, dtree, seg->pool_lv, laopts,lv_layer (seg->pool_lv)))
lib/metadata/lv_manip.c +124 -6
184 lines not on this page · raw message
lib/metadata/merge.c +11 -0
@@ -294,6 +294,17 @@ int check_lv_segments(struct logical_volume *lv, int complete_vg) inc_error_count; } } + }else if (seg_is_cache (seg)) { +if (!lv_is_cache (lv)) { +log_error ("LV %s is missing cache flag for segment %u" , + lv->name, seg_count); + inc_error_count; + } +if (!seg->pool_lv) { +log_error ("LV %s: segment %u is missing cache_pool LV" , + lv->name, seg_count); + inc_error_count; + } }else {if (seg->pool_lv) { log_error("LV %s: segment %u must not have thin pool LV set",
lib/metadata/metadata-exported.h +1 -0
@@ -750,6 +750,7 @@ static inline int is_change_activating(activation_change_t change)/* FIXME: refactor and reduce the size of this struct! */ struct lvcreate_params {/* flags */ +int cache;int snapshot;/* snap */ int thin;/* thin */ int create_pool;/* thin */
test/shell/lvcreate-cache.sh new file +135 -0
135 lines not on this page · raw message
tools/lvcreate.c +85 -2
105 lines not on this page · raw message