LVM2 ./WHATS_NEW doc/example.conf.in lib/activ ...
CVSROOT: /cvs/lvm2
Module name: LVM2
Changes by: agk at sourceware.org 2010-11-09 12:34:44
Modified files:
. : WHATS_NEW doc : example.conf.in lib/activate : activate.c
lib/datastruct : str_list.c str_list.h
lib/display : display.c
lib/metadata : lv_manip.c metadata.c mirror.c vg.h
man : lvm.conf.5.in
tools : toollib.c
Log message:
Extend cling allocation policy to recognise PV tags (cling_by_tags). Add allocation/cling_tag_list to lvm.conf.
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.1792&r2=1.1793
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/doc/example.conf.in.diff?cvsroot=lvm2&r1=1.16&r2=1.17
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/activate/activate.c.diff?cvsroot=lvm2&r1=1.179&r2=1.180
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/datastruct/str_list.c.diff?cvsroot=lvm2&r1=1.12&r2=1.13
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/datastruct/str_list.h.diff?cvsroot=lvm2&r1=1.9&r2=1.10
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/display/display.c.diff?cvsroot=lvm2&r1=1.113&r2=1.114
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/lv_manip.c.diff?cvsroot=lvm2&r1=1.235&r2=1.236
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.c.diff?cvsroot=lvm2&r1=1.408&r2=1.409
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/mirror.c.diff?cvsroot=lvm2&r1=1.136&r2=1.137
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/vg.h.diff?cvsroot=lvm2&r1=1.7&r2=1.8
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/man/lvm.conf.5.in.diff?cvsroot=lvm2&r1=1.15&r2=1.16
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/toollib.c.diff?cvsroot=lvm2&r1=1.210&r2=1.211
WHATS_NEW +2 -0
@@ -1,5 +1,7 @@ Version 2.02.77 - =================================== + Extend cling allocation policy to recognise PV tags (cling_by_tags). + Add allocation/cling_tag_list to lvm.conf. Regenerate configure with 'autoreconf' for --enable-ocf. (2.02.76) Version 2.02.76 - 8th November 2010
doc/example.conf.in +19 -0
@@ -146,6 +146,25 @@ require_restorefile_with_uuid = 1 } +# This section allows you to configure the way in which LVM selects +# free space for its Logical Volumes. +#allocation { +# When searching for free space to extend an LV, the "cling" +# allocation policy will choose space on the same PVs as the last +# segment of the existing LV. If there is insufficient space and a +# list of tags is defined here, it will check whether any of them are +# attached to the PVs concerned and then seek to match those PV tags +# between existing extents and new extents. +# Use the special tag "@*" as a wildcard to match any PV tag. +# +# Example: LVs are mirrored between two sites within a single VG. +# PVs are tagged with either @site1 or @site2 to indicate where +# they are situated. +# +# cling_tag_list = [ "@site1", "@site2" ] +# cling_tag_list = [ "@*" ] +#} + # This section that allows you to configure the nature of the # information that LVM2 reports. log {
lib/activate/activate.c +4 -4
@@ -275,8 +275,8 @@return 1 ;/* If any host tag matches any LV or VG tag, activate */ -if (str_list_match_list (&cmd->tags, &lv->tags) || -str_list_match_list (&cmd->tags, &lv->vg->tags)) +if (str_list_match_list (&cmd->tags, &lv->tags,NULL ) || +str_list_match_list (&cmd->tags, &lv->vg->tags,NULL ))return 1 ; log_verbose("No host tag matches %s/%s",
@@ -314,9 +314,9 @@ }/* If any host tag matches any LV or VG tag, activate */ if (!strcmp (str,"*" )) { -if (str_list_match_list (&cmd->tags, &lv->tags) +if (str_list_match_list (&cmd->tags, &lv->tags,NULL ) ||str_list_match_list (&cmd->tags, - &lv->vg->tags)) + &lv->vg->tags,NULL ))return 1 ;else continue ;
lib/datastruct/str_list.c +7 -3
@@ -93,14 +93,18 @@/* * Is at least one item on both lists? +* If tag_matched is non-NULL, it is set to the tag that matched. */ -int str_list_match_list (const struct dm_list *sll,const struct dm_list *sll2) +int str_list_match_list (const struct dm_list *sll,const struct dm_list *sll2,char **tag_matched) {struct str_list *sl; dm_list_iterate_items(sl, sll) -if (str_list_match_item (sll2, sl->str)) -return 1 ; +if (str_list_match_item (sll2, sl->str)) { +if (tag_matched) + *tag_matched = sl->str; +return 1 ; + }return 0 ; }
lib/datastruct/str_list.h +1 -1
@@ -20,7 +20,7 @@int str_list_add (struct dm_pool *mem,struct dm_list *sll,const char *str);int str_list_del (struct dm_list *sll,const char *str);int str_list_match_item (const struct dm_list *sll,const char *str); -int str_list_match_list (const struct dm_list *sll,const struct dm_list *sll2); +int str_list_match_list (const struct dm_list *sll,const struct dm_list *sll2,char **tag_matched);int str_list_lists_equal (const struct dm_list *sll,const struct dm_list *sll2);int str_list_dup (struct dm_pool *mem,struct dm_list *sllnew,const struct dm_list *sllold);
lib/display/display.c +7 -2
@@ -26,12 +26,13 @@static const struct {alloc_policy_t alloc; -const char str[12 ];/* must be changed when size extends 11 chars */ +const char str[14 ];/* must be changed when size extends 13 chars */ const char repchar; } _policies[] = { {ALLOC_CONTIGUOUS ,"contiguous" ,'c' }, {ALLOC_CLING ,"cling" ,'l' }, { +ALLOC_CLING_BY_TAGS ,"cling_by_tags" ,'t' }, {/* Only used in log mesgs */ ALLOC_NORMAL ,"normal" ,'n' }, {ALLOC_ANYWHERE ,"anywhere" ,'a' }, {ALLOC_INHERIT ,"inherit" ,'i' }
@@ -147,12 +148,16 @@ {int i; +/* cling_by_tags is part of cling */ +if (!strcmp ("cling_by_tags" , str)) +return ALLOC_CLING ; +for (i =0 ; i < _num_policies; i++)if (!strcmp (_policies[i].str, str))return _policies[i].alloc;/* Special case for old metadata */ -if (!strcmp ("next free" , str)) +if (!strcmp ("next free" , str))return ALLOC_NORMAL ;log_error ("Unrecognised allocation policy %s" , str);
lib/metadata/lv_manip.c +96 -13
210 lines not on this page · raw message
lib/metadata/metadata.c +12 -0
@@ -2164,6 +2164,12 @@uint32_t num_snapshots =0 ;uint32_t loop_counter1, loop_counter2; +if (vg->alloc ==ALLOC_CLING_BY_TAGS ) { +log_error (INTERNAL_ERROR "VG %s allocation policy set to invalid cling_by_tags." , + vg->name); + r =0 ; + } +/* FIXME Also check there's no data/metadata overlap */ dm_list_iterate_items(pvl, &vg->pvs) {if (++pv_count > vg->pv_count) {
@@ -2233,6 +2239,12 @@ r =0 ; } +if (lvl->lv->alloc ==ALLOC_CLING_BY_TAGS ) { +log_error (INTERNAL_ERROR "LV %s allocation policy set to invalid cling_by_tags." , + lvl->lv->name); + r =0 ; + } +if (lvl->lv->status &VISIBLE_LV )continue ;
lib/metadata/mirror.c +1 -1
@@ -400,7 +400,7 @@struct str_list *sl;/* Inherit tags - maybe needed for activation */ -if (!str_list_match_list (&mirror_lv->tags, &lv->tags)) { +if (!str_list_match_list (&mirror_lv->tags, &lv->tags,NULL )) { dm_list_iterate_items(sl, &mirror_lv->tags)if (!str_list_add (cmd->mem, &lv->tags, sl->str)) {log_error ("Aborting. Unable to tag." );
lib/metadata/vg.h +1 -0
@@ -25,6 +25,7 @@ALLOC_INVALID ,ALLOC_CONTIGUOUS ,ALLOC_CLING , +ALLOC_CLING_BY_TAGS ,/* Internal - never written or displayed. */ ALLOC_NORMAL ,ALLOC_ANYWHERE ,ALLOC_INHERIT
man/lvm.conf.5.in +22 -0
@@ -172,6 +172,28 @@ the respective operation. Setting the parameter to 0 disables the counters altogether. .TP +\fBallocation\fP \(em Space allocation policies +.IP +\fBcling_tag_list\fP \(em List of PV tags matched by the \fBcling\fP allocation policy. +.IP +When searching for free space to extend an LV, the \fBcling\fP +allocation policy will choose space on the same PVs as the last +segment of the existing LV. If there is insufficient space and a +list of tags is defined here, it will check whether any of them are +attached to the PVs concerned and then seek to match those PV tags +between existing extents and new extents. +.IP +The @ prefix for tags is required. +Use the special tag "@*" as a wildcard to match any PV tag and so use +all PV tags for this purpose. +.IP +For example, LVs are mirrored between two sites within a single VG. +PVs are tagged with either @site1 or @site2 to indicate where +they are situated and these two PV tags are selected for use with this +allocation policy: +.IP +cling_tag_list = [ "@site1", "@site2" ] +.TP \fBlog\fP \(em Default log settings .IP \fBfile\fP \(em Location of log file. If this entry is not present, no
tools/toollib.c +4 -4
@@ -115,7 +115,7 @@/* Or if VG tags match */ if (!process_lv && tags_supplied && -str_list_match_list (tags, &vg->tags)) { +str_list_match_list (tags, &vg->tags,NULL )) { process_all =1 ; }
@@ -141,7 +141,7 @@/* LV tag match? */ if (!process_lv && tags_supplied && -str_list_match_list (tags, &lvl->lv->tags)) { +str_list_match_list (tags, &lvl->lv->tags,NULL )) { process_lv =1 ; }
@@ -487,7 +487,7 @@if (!dm_list_empty (tags) &&/* Only process if a tag matches or it's on arg_vgnames */ !str_list_match_item (arg_vgnames, vg_name) && - !str_list_match_list (tags, &cvl_vg->vg->tags)) + !str_list_match_list (tags, &cvl_vg->vg->tags,NULL ))break ; ret =process_single_vg (cmd, vg_name, cvl_vg->vg, handle);
@@ -606,7 +606,7 @@ dm_list_iterate_items(pvl, &vg->pvs) {if (tags && !dm_list_empty (tags) && - !str_list_match_list (tags, &pvl->pv->tags)) { + !str_list_match_list (tags, &pvl->pv->tags,NULL )) {continue ; }if ((ret =process_single_pv (cmd, vg, pvl->pv, handle)) > ret_max)