master - select: add support for range reserved values and flagging named-only values
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=d8996a17d1a0605cebfcf926a7a8d0e6b7fc1fcc Commit: d8996a17d1a0605cebfcf926a7a8d0e6b7fc1fcc Parent: 77f0e7a450dc2bc3e42bb4854e1032873d661c58 Author: Peter Rajnoha <[email protected]> AuthorDate: Tue Jun 30 10:13:35 2015 +0200 Committer: Peter Rajnoha <[email protected]> CommitterDate: Tue Jun 30 10:47:50 2015 +0200
select: add support for range reserved values and flagging named-only values
This patch allows for registration and recognition of reserved values which are ranges, so they're composed of two values actually to denote the lower and upper bound for the range (stored as an array with exactly two items to define the boundaries).
Also, this patch allows for flagging reserved values as named-only which means that such values are not strictly reserved. The strictly reserved values are reserved values as used before this patch.
Distinction between strictly-reserved and named-only values is clearly visible with comparisons. Normally, strictly reserved value is not accounted for if we do "greater than" or "lower than" comparisons, for example:
1 2 3 ....
|
abc
- we have "abc" as reserved value for field with value "2"
- the value reported for the field is "abc" (or "2", it doesn't matter here)
- the selection we're processing is -S 'field < abc'
- the result of the selection gives nothing as "abc" is strictly reserved value (bound to "2") and there's no order defined for it and it would only match if we directly compared the value
(so -S 'field = abc' would match)
With named-only values, the "abc" is named-only value for "2", so selection -S 'field < abc" is the same as using -S 'field < 2'. The "abc" is just an alias for some value so the value or its assigned name can be used equally in selection criteria.
--- WHATS_NEW_DM | 2 + lib/report/report.c | 32 +++-- lib/report/values.h | 32 +++--- libdm/libdevmapper.h | 29 +++-- libdm/libdm-report.c | 348 ++++++++++++++++++++++++++++++++++++-------------- 5 files changed, 304 insertions(+), 139 deletions(-)
WHATS_NEW_DM +2 -0
@@ -1,5 +1,7 @@ Version 1.02.100 - ================================ + Support report reserved value ranges: DM_REPORT_FIELD_RESERVED_VALUE_RANGE. + Support report reserved value names: DM_REPORT_FIELD_RESERVED_VALUE_NAMED. Add DM_CONFIG_VALUE_FMT_{INT_OCTAL,STRING_NO_QUOTES} config value format flag. Add DM_CONFIG_VALUE_FMT_COMMON_{ARRAY,EXTRA_SPACE} config value format flag. Add dm_config_value_{get,set}_format_flags to get and set config value format.
lib/report/report.c +20 -12
@@ -96,24 +96,28 @@ static const int32_t _reserved_num_undef_32 = INT32_C(-1);* - 'reserved_value_id_n' (for 0) */ #define NUM uint64_t -#define SIZ double +#define NOFLAG 0 +#define NAMED DM_REPORT_FIELD_RESERVED_VALUE_NAMED +#define RANGE DM_REPORT_FIELD_RESERVED_VALUE_RANGE -#define TYPE_RESERVED_VALUE (type, id, desc, value, ...) \ +#define TYPE_RESERVED_VALUE (type, flags, id, desc, value, ...) \ static const char *_reserved_ ## id ## _names[] = { __VA_ARGS__, NULL}; \ static const type _reserved_ ## id = value; -#define FIELD_RESERVED_VALUE (field_id, id, desc, value, ...) \ +#define FIELD_RESERVED_VALUE (flags, field_id, id, desc, value, ...) \ static const char *_reserved_ ## id ## _names[] = { __VA_ARGS__ , NULL}; \ static const struct dm_report_field_reserved_value _reserved_ ## id = {field_ ## field_id, value};#define FIELD_RESERVED_BINARY_VALUE (field_id, id, desc, ...) \ - FIELD_RESERVED_VALUE(field_id, id ## _y, desc, &_one64, __VA_ARGS__, _str_yes) \ - FIELD_RESERVED_VALUE(field_id, id ## _n, desc, &_zero64, __VA_ARGS__, _str_no) + FIELD_RESERVED_VALUE(NAMED, field_id, id ## _y, desc, &_one64, __VA_ARGS__, _str_yes) \ + FIELD_RESERVED_VALUE(NAMED, field_id, id ## _n, desc, &_zero64, __VA_ARGS__, _str_no)#include "values.h" #undef NUM -#undef SIZ +#undef NOFLAG +#undef NAMED +#undef RANGE#undef TYPE_RESERVED_VALUE#undef FIELD_RESERVED_VALUE#undef FIELD_RESERVED_BINARY_VALUE
@@ -126,15 +130,17 @@ static const int32_t _reserved_num_undef_32 = INT32_C(-1);*/ #define NUM DM_REPORT_FIELD_TYPE_NUMBER -#define SIZ DM_REPORT_FIELD_TYPE_SIZE +#define NOFLAG 0 +#define NAMED DM_REPORT_FIELD_RESERVED_VALUE_NAMED +#define RANGE DM_REPORT_FIELD_RESERVED_VALUE_RANGE -#define TYPE_RESERVED_VALUE (type, id, desc, value, ...) {type, &_reserved_ ## id, _reserved_ ## id ## _names, desc}, +#define TYPE_RESERVED_VALUE (type, flags, id, desc, value, ...) {type | flags, &_reserved_ ## id, _reserved_ ## id ## _names, desc}, -#define FIELD_RESERVED_VALUE (field_id, id, desc, value, ...) {DM_REPORT_FIELD_TYPE_NONE, &_reserved_ ## id, _reserved_ ## id ## _names, desc}, +#define FIELD_RESERVED_VALUE (flags, field_id, id, desc, value, ...) {DM_REPORT_FIELD_TYPE_NONE | flags, &_reserved_ ## id, _reserved_ ## id ## _names, desc},#define FIELD_RESERVED_BINARY_VALUE (field_id, id, desc, ...) \ - FIELD_RESERVED_VALUE(field_id, id ## _y, desc, &_one64, __VA_ARGS__) \ - FIELD_RESERVED_VALUE(field_id, id ## _n, desc, &_zero64, __VA_ARGS__) + FIELD_RESERVED_VALUE(NAMED, field_id, id ## _y, desc, &_one64, __VA_ARGS__) \ + FIELD_RESERVED_VALUE(NAMED, field_id, id ## _n, desc, &_zero64, __VA_ARGS__)static const struct dm_report_reserved_value _report_reserved_values[] = { #include "values.h"
@@ -142,7 +148,9 @@ static const struct dm_report_reserved_value _report_reserved_values[] = { };#undef NUM -#undef SIZ +#undef NOFLAG +#undef NAMED +#undef RANGE#undef TYPE_RESERVED_VALUE#undef FIELD_RESERVED_VALUE#undef FIELD_RESERVED_BINARY_VALUE
lib/report/values.h +16 -16
@@ -38,15 +38,15 @@*/ /* -* TYPE_RESERVED_VALUE(type, reserved_value_id, description, value, reserved_name, ...) -* FIELD_RESERVED_VALUE(field_id, reserved_value_id, description, value, reserved_name, ...) +* TYPE_RESERVED_VALUE(type, flags, reserved_value_id, description, value, reserved_name, ...) +* FIELD_RESERVED_VALUE(field_id, flags, reserved_value_id, description, value, reserved_name, ...) * FIELD_BINARY_RESERVED_VALUE(field_id, reserved_value_id, description, reserved_name for 1, ...) */ /* *INDENT-OFF* */ /* Per-type reserved values usable for all fields of certain type. */ -TYPE_RESERVED_VALUE (NUM , num_undef_64,"Reserved value for undefined numeric value." ,UINT64_C (-1 ),"-1" ,"unknown" ,"undefined" ,"undef" ) +TYPE_RESERVED_VALUE (NUM ,NOFLAG , num_undef_64,"Reserved value for undefined numeric value." ,UINT64_C (-1 ),"-1" ,"unknown" ,"undefined" ,"undef" ) /* Reserved values for PV fields */FIELD_RESERVED_BINARY_VALUE (pv_allocatable, pv_allocatable,"" ,"allocatable" )
@@ -58,9 +58,9 @@ FIELD_RESERVED_BINARY_VALUE(vg_extendable, vg_extendable, "", "extendable") FIELD_RESERVED_BINARY_VALUE(vg_exported, vg_exported, "", "exported") FIELD_RESERVED_BINARY_VALUE(vg_partial, vg_partial, "", "partial") FIELD_RESERVED_BINARY_VALUE(vg_clustered, vg_clustered, "", "clustered") -FIELD_RESERVED_VALUE(vg_permissions, vg_permissions_rw, "", "writeable", "writeable", "rw", "read-write") -FIELD_RESERVED_VALUE(vg_permissions, vg_permissions_r, "", "read-only", "read-only", "r", "ro") -FIELD_RESERVED_VALUE (vg_mda_copies, vg_mda_copies_unmanaged,"" , &GET_TYPE_RESERVED_VALUE (num_undef_64),"unmanaged" ) +FIELD_RESERVED_VALUE(NAMED, vg_permissions, vg_permissions_rw, "", "writeable", "writeable", "rw", "read-write") +FIELD_RESERVED_VALUE(NAMED, vg_permissions, vg_permissions_r, "", "read-only", "read-only", "r", "ro") +FIELD_RESERVED_VALUE (NOFLAG , vg_mda_copies, vg_mda_copies_unmanaged,"" , &GET_TYPE_RESERVED_VALUE (num_undef_64),"unmanaged" ) /* Reserved values for LV fields */FIELD_RESERVED_BINARY_VALUE (lv_initial_image_sync, lv_initial_image_sync,"" ,"initial image sync" ,"sync" )
@@ -80,18 +80,18 @@ FIELD_RESERVED_BINARY_VALUE(lv_inactive_table, lv_inactive_table, "", "inactive FIELD_RESERVED_BINARY_VALUE(lv_device_open, lv_device_open, "", "open") FIELD_RESERVED_BINARY_VALUE(lv_skip_activation, lv_skip_activation, "", "skip activation", "skip") FIELD_RESERVED_BINARY_VALUE(zero, zero, "", "zero") -FIELD_RESERVED_VALUE(lv_permissions, lv_permissions_rw, "", "writeable", "writeable", "rw", "read-write") -FIELD_RESERVED_VALUE(lv_permissions, lv_permissions_r, "", "read-only", "read-only", "r", "ro") -FIELD_RESERVED_VALUE(lv_permissions, lv_permissions_r_override, "", "read-only-override", "read-only-override", "ro-override", "r-override", "R") -FIELD_RESERVED_VALUE(lv_read_ahead, lv_read_ahead_auto, "", &_siz_max, "auto") -FIELD_RESERVED_VALUE(lv_when_full, lv_when_full_error, "", "error", "error", "error when full", "error if no space") -FIELD_RESERVED_VALUE(lv_when_full, lv_when_full_queue, "", "queue", "queue", "queue when full", "queue if no space") -FIELD_RESERVED_VALUE (lv_when_full, lv_when_full_undef,"" ,"" ,"" ,"undefined" ) +FIELD_RESERVED_VALUE(NAMED, lv_permissions, lv_permissions_rw, "", "writeable", "writeable", "rw", "read-write") +FIELD_RESERVED_VALUE(NAMED, lv_permissions, lv_permissions_r, "", "read-only", "read-only", "r", "ro") +FIELD_RESERVED_VALUE(NAMED, lv_permissions, lv_permissions_r_override, "", "read-only-override", "read-only-override", "ro-override", "r-override", "R") +FIELD_RESERVED_VALUE(NOFLAG, lv_read_ahead, lv_read_ahead_auto, "", &_siz_max, "auto") +FIELD_RESERVED_VALUE(NAMED, lv_when_full, lv_when_full_error, "", "error", "error", "error when full", "error if no space") +FIELD_RESERVED_VALUE(NAMED, lv_when_full, lv_when_full_queue, "", "queue", "queue", "queue when full", "queue if no space") +FIELD_RESERVED_VALUE (NOFLAG , lv_when_full, lv_when_full_undef,"" ,"" ,"" ,"undefined" ) /* Reserved values for SEG fields */ -FIELD_RESERVED_VALUE(cache_policy, cache_policy_undef, "", "", "", "undefined") -FIELD_RESERVED_VALUE(seg_monitor, seg_monitor_undef, "", "", "", "undefined") -FIELD_RESERVED_VALUE (lv_health_status, health_undef,"" ,"" ,"" ,"undefined" ) +FIELD_RESERVED_VALUE(NOFLAG, cache_policy, cache_policy_undef, "", "", "", "undefined") +FIELD_RESERVED_VALUE(NOFLAG, seg_monitor, seg_monitor_undef, "", "", "", "undefined") +FIELD_RESERVED_VALUE (NOFLAG , lv_health_status, health_undef,"" ,"" ,"" ,"undefined" )/* TODO the following 2 need STR_LIST support for reserved values FIELD_RESERVED_VALUE(cache_settings, cache_settings_default, "", "default", "default") FIELD_RESERVED_VALUE(cache_settings, cache_settings_undef, "", "undefined", "undefined") */
libdm/libdevmapper.h +17 -12
@@ -1671,17 +1671,22 @@ struct dm_report_field;/* * dm_report_field_type flags */ -#define DM_REPORT_FIELD_MASK 0x00000FFF -#define DM_REPORT_FIELD_ALIGN_MASK 0x0000000F -#define DM_REPORT_FIELD_ALIGN_LEFT 0x00000001 -#define DM_REPORT_FIELD_ALIGN_RIGHT 0x00000002 -#define DM_REPORT_FIELD_TYPE_MASK 0x00000FF0 -#define DM_REPORT_FIELD_TYPE_NONE 0x00000000 -#define DM_REPORT_FIELD_TYPE_STRING 0x00000010 -#define DM_REPORT_FIELD_TYPE_NUMBER 0x00000020 -#define DM_REPORT_FIELD_TYPE_SIZE 0x00000040 -#define DM_REPORT_FIELD_TYPE_PERCENT 0x00000080 -#define DM_REPORT_FIELD_TYPE_STRING_LIST 0x00000100 +#define DM_REPORT_FIELD_MASK 0x00000FFF +#define DM_REPORT_FIELD_ALIGN_MASK 0x0000000F +#define DM_REPORT_FIELD_ALIGN_LEFT 0x00000001 +#define DM_REPORT_FIELD_ALIGN_RIGHT 0x00000002 +#define DM_REPORT_FIELD_TYPE_MASK 0x00000FF0 +#define DM_REPORT_FIELD_TYPE_NONE 0x00000000 +#define DM_REPORT_FIELD_TYPE_STRING 0x00000010 +#define DM_REPORT_FIELD_TYPE_NUMBER 0x00000020 +#define DM_REPORT_FIELD_TYPE_SIZE 0x00000040 +#define DM_REPORT_FIELD_TYPE_PERCENT 0x00000080 +#define DM_REPORT_FIELD_TYPE_STRING_LIST 0x00000100 + +/* For use with reserved values only! */ +#define DM_REPORT_FIELD_RESERVED_VALUE_MASK 0x0000000F +#define DM_REPORT_FIELD_RESERVED_VALUE_NAMED 0x00000001/* only named value, less strict form of reservation */ +#define DM_REPORT_FIELD_RESERVED_VALUE_RANGE 0x00000002/* value is range - low and high value defined */ #define DM_REPORT_FIELD_TYPE_ID_LEN 32#define DM_REPORT_FIELD_TYPE_HEADING_LEN 32
@@ -1728,7 +1733,7 @@ struct dm_report_field_reserved_value {* selection enabled (see also dm_report_init_with_selection function). */ struct dm_report_reserved_value { -const unsigned type;/* DM_REPORT_FIELD_TYPE_* */ +const uint32_t type;/* DM_REPORT_FIELD_RESERVED_VALUE_* and DM_REPORT_FIELD_TYPE_* */ const void *value;/* reserved value: struct dm_report_field_reserved_value for DM_REPORT_FIELD_TYPE_NONE uint64_t for DM_REPORT_FIELD_TYPE_NUMBER
libdm/libdm-report.c +249 -99
579 lines not on this page · raw message