master - raid: use feature attributes for raid10
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=95fe823eba5432bc395847076fbf187889c55cb1 Commit: 95fe823eba5432bc395847076fbf187889c55cb1 Parent: 23c069d16f40adb9c59caa686904bb3f23ab6fca Author: Zdenek Kabelac <[email protected]> AuthorDate: Mon Feb 24 13:15:40 2014 +0100 Committer: Zdenek Kabelac <[email protected]> CommitterDate: Mon Feb 24 21:10:13 2014 +0100
raid: use feature attributes for raid10
Test raid10 availability as a target feature (instead of doing it in all the places where raid10 should be checked).
TODO: activation needs runtime validation - so metadata with raid10 are skipped from activation in user-friendly way in lvm2.
--- WHATS_NEW | 1 + lib/activate/activate.h | 5 +++++ lib/raid/raid.c | 36 +++++++++++++++++++++++++++++++++--- tools/lvcreate.c | 19 ++++++++----------- 4 files changed, 47 insertions(+), 14 deletions(-)
WHATS_NEW +1 -0
@@ -1,5 +1,6 @@ Version 2.02.106 - ==================================== + Enhance raid code with feature flags, for now checks for raid10. Move parsing of VG metadata from vg_commit() back to vg_write() (2.02.99) Avoid a PV label scan while in a critical section. Remove (always 0) skip argument from lv_activation_skip().
lib/activate/activate.h +5 -0
@@ -67,6 +67,11 @@ enum { THIN_FEATURE_EXTERNAL_ORIGIN_EXTEND = (1 << 6), }; +/* raid target attribute flags */ +enum { +RAID_FEATURE_RAID10 = (1 <<0 ),/* version 1.3 */ +}; +void set_activation (int activation);int activation (void );
lib/raid/raid.c +33 -3
@@ -326,15 +326,45 @@ static int _raid_target_percent(void **target_state,static int _raid_target_present (struct cmd_context *cmd,const struct lv_segment *seg __attribute__((unused)), -unsigned *attributes __attribute__((unused))) +unsigned *attributes) { +/* List of features with their kernel target version */ +static const struct feature { +uint32_t maj; +uint32_t min; +unsigned raid_feature; +const char *feature; + }const _features[] = { + {1 ,3 ,RAID_FEATURE_RAID10 ,"raid10" }, + }; +static int _raid_checked =0 ;static int _raid_present =0 ; +static int _raid_attrs =0 ; +uint32_t maj, min, patchlevel; +unsigned i; -if (!_raid_checked) +if (!_raid_checked) { _raid_present =target_present (cmd,"raid" ,1 ); - _raid_checked =1 ; +if (!target_version ("raid" , &maj, &min, &patchlevel)) { +log_error ("Cannot read target version of RAID kernel module." ); +return 0 ; + } + +for (i =0 ; i <sizeof (_features)/sizeof (*_features); i++) +if ((maj > _features[i].maj) || + (maj == _features[i].maj && min >= _features[i].min)) + _raid_attrs |= _features[i].raid_feature; +else +log_very_verbose ("Target raid does not support %s." , + _features[i].feature); + + _raid_checked =1 ; + } + +if (attributes) + *attributes = _raid_attrs;return _raid_present; }
tools/lvcreate.c +8 -11
@@ -977,19 +977,16 @@ static int _lvcreate_params(struct lvcreate_params *lp, } } -if (activation () && lp->segtype->ops->target_present && - !lp->segtype->ops->target_present (cmd,NULL , &lp->target_attr)) { -log_error ("%s: Required device-mapper target(s) not " -"detected in your kernel" , lp->segtype->name); -return 0 ; - }else if (!strcmp (lp->segtype->name,"raid10" )) { -uint32_t maj, min, patchlevel; -if (!target_version ("raid" , &maj, &min, &patchlevel)) { -log_error ("Failed to determine version of RAID kernel module" ); +if (activation () && lp->segtype->ops->target_present) { +if (!lp->segtype->ops->target_present (cmd,NULL , &lp->target_attr)) { +log_error ("%s: Required device-mapper target(s) not detected in your kernel." , + lp->segtype->name);return 0 ; } -if ((maj !=1 ) || (min <3 )) { -log_error ("RAID module does not support RAID10" ); + +if ((strcmp (lp->segtype->name,"raid10" ) ==0 ) && + !(lp->target_attr &RAID_FEATURE_RAID10 )) { +log_error ("RAID module does not support RAID10." );return 0 ; } }