1
0
mirror of git://sourceware.org/git/lvm2.git synced 2024-12-21 13:34:40 +03:00
lvm2/libdm
Peter Rajnoha 31cd8346ae libdm: report: enhance the way string list is stored internally
Before, we stored only the report string itself for a string list
in field->report_string. The field->report_string has either
sorted items or not, depending on what we need for a field -
some report fields have sorted output, some don't...

The field->sort_value.value then contains pointer to the exact
field->report_string. The field->sort_value.items ALWAYS keeps
sorted array of individual items, represented as '[position,length]'
pairs pointing to the field->sort_value.value string.

This approach was fine as far as we didn't need to apply further
formatting to field->report_string. However, if we need to apply
further formatting to field->report_string content, taking into
account individual items, we also need to know where each item
starts and what is its length. Before, we only knew this when
items in report string were sorted, but not in the unsorted version.

We can't rely on the delimiter (default ",") only to separate items
back out of report string, because that delimiter can be contained
in the item value itself.

So this patch enhances the field->report_string for a string list so
it also contains '[position,length]' pairs for each individual item
inside field->report_string. We store this array right beyond the
string itself and we encode it in the same manner we already did for
field->sort_value.items before.

If field->report_string has sorted items, the field->sort_value.items
just points to the array of items we store beyond the report string.
If field->report_string has unsorted items, we store separate array
of items for both field->report_string and field->sort_value.

This patch also cleans up the _report_field_string_list function a bit
so it's easier and more straightforward to follow than the original
version.

Example. If we have "abc", "xy", "defgh" as list on input with ","
as delimiter, then:

  - field->report_string will have:

    - if we need field->report_string unsorted:

        abc,xy,defgh\0{[3,12],[0,3],[4,2],[7,5]}
        |____________||________________________|
           string      array of [pos,len] pairs
                       |____||________________|
                       #items      items

    - if we need field->report_string sorted:

                 repstr_extra
                      |
                      V
        abc,defgh,xy\0{[3,12],[0,3],[4,5],[10,2]}
        |____________||________________________|
           string      array of [pos,len] pairs
                       |____||________________|
                       #items      items

  - field->sort_value will have:

    - if field->report_string is unsorted:

        field->sort_value.value = field->report_string
        field->sort_value.items = {[0,3],[0,3],[7,5],[4,2]}
                                    (that is 'abc,defgh,xy')

    - if field->report_string is sorted already:

        field->sort_value.value = field->report_string
        field->sort_value.items = repstr_extra
                                  (that is also 'abc,defgh,xy')
2022-08-11 11:10:11 +02:00
..
datastruct gcc: use more zero length arrays 2021-09-22 17:18:50 +02:00
dm-tools cov: validate subcommand existance 2021-10-15 23:39:25 +02:00
ioctl libdm: unmangling UUID for DM_DEVICE_LIST 2021-12-20 16:13:28 +01:00
misc libdm: dmsetup measure support for IMA 2021-09-23 16:49:28 +02:00
mm gcc: use apropriate type for reading and printing values 2020-08-28 21:43:03 +02:00
regex build: Don't generate symlinks in include/ dir 2018-05-14 10:30:20 +01:00
.exported_symbols libdm: Use wrappers for all malloc functions. 2015-07-22 23:11:48 +01:00
.exported_symbols.Base symver: restore and uncomment some symbols 2021-04-06 21:26:57 +02:00
.exported_symbols.DM_1_02_97 libdm: new dm_task_get_info with internal_suspend 2015-05-15 16:48:22 +02:00
.exported_symbols.DM_1_02_98 libdm: Add dm_task_get_errno to return ioctl errno. 2015-05-26 15:13:49 +01:00
.exported_symbols.DM_1_02_99 libdm: add dm_tree_node_set_thin_pool_read_only 2015-06-18 15:15:39 +02:00
.exported_symbols.DM_1_02_100 symver: sorting 2021-04-06 21:26:57 +02:00
.exported_symbols.DM_1_02_101 symver: sorting 2021-04-06 21:26:57 +02:00
.exported_symbols.DM_1_02_103 libdm: Use wrappers for all malloc functions. 2015-07-22 23:11:48 +01:00
.exported_symbols.DM_1_02_104 symver: sorting 2021-04-06 21:26:57 +02:00
.exported_symbols.DM_1_02_105 pre-release 2015-08-17 17:20:14 +01:00
.exported_symbols.DM_1_02_106 symver: restore and uncomment some symbols 2021-04-06 21:26:57 +02:00
.exported_symbols.DM_1_02_107 libdm: add latency histogram support 2015-09-02 20:48:59 +01:00
.exported_symbols.DM_1_02_110 symver: sorting 2021-04-06 21:26:57 +02:00
.exported_symbols.DM_1_02_113 libdm: introduce dm_get_status_mirror 2015-12-01 13:00:43 +01:00
.exported_symbols.DM_1_02_124 libdm: Add dm_udev_wait_immediate. 2016-04-28 00:54:27 +01:00
.exported_symbols.DM_1_02_128 symver: sorting 2021-04-06 21:26:57 +02:00
.exported_symbols.DM_1_02_129 symver: restore and uncomment some symbols 2021-04-06 21:26:57 +02:00
.exported_symbols.DM_1_02_131 libdm: add dm_stats_create_regions_from_fd() 2016-07-08 14:34:41 +01:00
.exported_symbols.DM_1_02_133 libdm: report: add dm_report_group_output_and_pop_all 2016-08-09 18:24:45 +02:00
.exported_symbols.DM_1_02_135 libdm: add dm_config_parse_without_dup_node_check 2016-09-21 18:15:18 +02:00
.exported_symbols.DM_1_02_138 symver: sorting 2021-04-06 21:26:57 +02:00
.exported_symbols.DM_1_02_141 libdm: implement dm_percent_to_round_float 2017-06-24 17:44:40 +02:00
.exported_symbols.DM_1_02_147 libdm: Introduce dm_malloc_aligned 2018-01-10 15:48:03 +00:00
.exported_symbols.DM_1_02_172 libdm: add dm_tree_node_add_thin_pool_target_v1 2021-02-01 14:52:32 +01:00
.exported_symbols.DM_1_02_181 libdm: dmsetup measure support for IMA 2021-09-23 16:49:28 +02:00
libdevmapper.h libdm: report: add DM_REPORT_GROUP_JSON_STD group 2022-08-11 11:10:11 +02:00
libdevmapper.pc.in libdm: fix typo in libdevmapper.pc 2017-10-18 00:04:06 +02:00
libdm-common.c libdm: dmsetup measure support for IMA 2021-09-23 16:49:28 +02:00
libdm-common.h build: Don't generate symlinks in include/ dir 2018-05-14 10:30:20 +01:00
libdm-config.c metadata: allow reading metadata with invalid creation_time 2019-05-10 14:40:11 +02:00
libdm-deptree.c cov: remove unused headers 2022-07-11 01:18:24 +02:00
libdm-file.c debug: change sys_error to sys_debug 2021-03-10 01:11:52 +01:00
libdm-report.c libdm: report: enhance the way string list is stored internally 2022-08-11 11:10:11 +02:00
libdm-stats.c gcc: avoid warns on missing braces with older version 2021-09-20 16:11:49 +02:00
libdm-string.c build: Don't generate symlinks in include/ dir 2018-05-14 10:30:20 +01:00
libdm-targets.c cache: support no_discard_passdown 2019-06-05 15:48:41 +02:00
libdm-timestamp.c build: Don't generate symlinks in include/ dir 2018-05-14 10:30:20 +01:00
make.tmpl.in makefiles: deps also for cxx 2021-04-12 09:54:16 +02:00
Makefile.in makefiles: static linking enhancements 2021-04-12 09:54:15 +02:00