1
0
mirror of git://sourceware.org/git/lvm2.git synced 2024-10-28 20:25:52 +03:00
Commit Graph

9440 Commits

Author SHA1 Message Date
Peter Rajnoha
0d8e94ce2e tests: select: add test for report selection feature 2014-06-17 16:27:21 +02:00
Peter Rajnoha
51a86dc2f8 report: select: add support for percent selection 2014-06-17 16:27:21 +02:00
Peter Rajnoha
cfed0d09e8 report: select: refactor: move percent handling code to libdm for reuse 2014-06-17 16:27:21 +02:00
Peter Rajnoha
35c4e4489c report: select: add support for reserved value recognition in report selection string - add struct dm_report_reserved_value
Make dm_report_init_with_selection to accept an argument with an
array of reserved values where each element contains a triple:

  {dm report field type, reserved value, array of strings representing this value}

When the selection is parsed, we always check whether a string
representation of some reserved value is not hit and if it is,
we use the reserved value assigned for this string instead of
trying to parse it as a value of certain field type.

This makes it possible to define selections like:

   ... --select lv_major=undefined (or -1 or unknown or undef or whatever string representations are registered for this reserved value in the future)
   ... --select lv_read_ahead=auto
   ... --select vg_mda_copies=unmanaged

With this, each time the field value of certain type is hit
and when we compare it with the selection, we use the proper
value for comparison.

For now, register these reserved values that are used at the moment
(also more descriptive names are used for the values):

  const uint64_t _reserved_number_undef_64 = UINT64_MAX;
  const uint64_t _reserved_number_unmanaged_64 = UINT64_MAX - 1;
  const uint64_t _reserved_size_auto_64 = UINT64_MAX;

 {
  {DM_REPORT_FIELD_TYPE_NUMBER, _reserved_number_undef_64, {"-1", "undefined", "undef", "unknown", NULL}},
  {DM_REPORT_FIELD_TYPE_NUMBER, _reserved_number_unmanaged_64, {"unmanaged", NULL}},
  {DM_REPORT_FIELD_TYPE_SIZE, _reserved_size_auto_64, {"auto", NULL}},
  NULL
 }

Same reserved value of different field types do not collide.
All arrays are null-terminated.

The list of reserved values is automatically displayed within
selection help output:

  Selection operands
  ------------------
  ...

  Reserved values
  ---------------
    -1, undefined, undef, unknown   - Reserved value for undefined numeric value. [number]
    unmanaged                       - Reserved value for unmanaged number of metadata copies in VG. [number]
    auto                            - Reserved value for size that is automatically calculated. [size]

  Selection operators
  -------------------
  ...
2014-06-17 16:27:21 +02:00
Peter Rajnoha
a075ec15c4 report: select: show field type in field list if in context of selection
When the field list is displayed as help for constructing selection
criteria, show also the field value type. This is useful for users
to know what set of operators are allowed for the type - the subsequent
"Selection operands" section in the help output summarize all known
types that can be used in selection.
2014-06-17 16:27:21 +02:00
Peter Rajnoha
6d667adeea report: select: add help for creating selections
The "<lvm command> -S/--select help" shows help (including list of fields to match against):

  ...field list here including the field type name...

  Selection operands
  ------------------
    field               - Reporting field.
    number              - Non-negative integer value.
    size                - Floating point value with units specified.
    string              - Characters quoted by ' or " or unquoted.
    string list         - Strings enclosed by [ ] and elements delimited by either
                          "all items must match" or "at least one item must match" operator.
    regular expression  - Characters quoted by ' or " or unquoted.

  Selection operators
  -------------------
    Comparison operators:
        =~  - Matching regular expression.
        !~  - Not matching regular expression.
         =  - Equal to.
        !=  - Not equal to.
        >=  - Greater than or equal to.
         >  - Greater than
        <=  - Less than or equal to.
         <  - Less than.

    Logical and grouping operators:
        &&  - All fields must match
         ,  - All fields must match
        ||  - At least one field must match
         #  - At least one field must match
         !  - Logical negation
         (  - Left parenthesis
         )  - Right parenthesis
         [  - List start
         ]  - List end
2014-06-17 16:27:21 +02:00
Peter Rajnoha
03a3f6078d report: select: add support for comparing string lists with selection defined 2014-06-17 16:27:20 +02:00
Peter Rajnoha
8faa4ded9c report: select: add support for processing string lists in selection
Selection list items are enclosed in '[' and ']' (if there's only
one item, the '[' and ']' can be omitted). Each element of the list
is a string (either quoted or unquoted, like the usual string operand
used in selection) and each element is delimited either by conjunction
(meaining "match all") or disjunction operator (meaning "match any").

For example, if "," is the conjuction operator and "/" is the
disjunction operator then:

  lv_tags=[a,b,c]

...will match all fields where tags contain *all* a, b and c.

  lv_tags=[a/b/c]

...will match all fields where tags contain *any* of a, b, or c.

Mixing operators within the list is not supported:

  lv_tags=[a,b/c]

...will give an error.

The order in which items are defined in the selection do not matter.

This patch enhances the selection parsing functionality to recognize
such lists.
2014-06-17 16:27:20 +02:00
Peter Rajnoha
a6694cfc29 report: select: add DM_REPORT_FIELD_TYPE_STRING_LIST to make a difference between STRING and STRING_LIST
The {pv,vg,lv,seg}_tags and lv_modules fields are reported as string
lists using the new dm_report_field_string_list - so we just pass
the list to the fn that takes care of reporting and item sorting itself.
2014-06-17 16:27:20 +02:00
Peter Rajnoha
76467bdcfd report: select: add dm_report_field_string_list to libdm
Add a separate dm_report_field_string_list fn to libdevmapper to
support reporting string lists. Before, the code used libdevmappers's
dm_report_field_string fn which required formatting the list to a
single string. This functionality is now moved to libdevmapper
and the code that needs to report the string list just needs
to pass the list itself and libdevmapper will take care of this.
This also enhances code reuse.

The dm_report_field_string_list also accepts an argument to define
custom delimiter to use. If not defined, a default "," (comma) is
used as item delimiter in the string list reported.

The dm_report_field_string_list automatically sorts the items in
the list before formatting it to a final string. It also encodes
the position and length within the final string where each element
can be found. This can be used to support checking against each
list item reported since since when formatted as a single string
for the actual report, we would lose this information otherwise
(we don't want to copy each item, the position and length within
the final string is enough for us to get the original items back).

When such lists are checked against the selection tree, we can check
each item individually this way and we can support operators like
"match any" and "match all".
2014-06-17 16:27:20 +02:00
Peter Rajnoha
5abdb52fdc report: select: refactor: move str_list to libdm
The list of strings is used quite frequently and we'd like to reuse
this simple structure for report selection support too. Make it part
of libdevmapper for general reuse throughout the code.

This also simplifies the LVM code a bit since we don't need to
include and manage lvm-types.h anymore (the string list was the
only structure defined there).
2014-06-17 16:27:20 +02:00
Peter Rajnoha
fe952e735a report: select: add --select arg to pvdisplay, vgdisplay and lvdisplay 2014-06-17 16:27:20 +02:00
Peter Rajnoha
5b734a0ea1 report: select: add --select arg to pvs, vgs and lvs 2014-06-17 16:27:20 +02:00
Peter Rajnoha
3a1c7e5d78 report: select: add --select arg to dmsetup 2014-06-17 16:27:20 +02:00
Peter Rajnoha
bc6458de87 report: select: use _check_report_selection in dm_report_object to report only objects that satisfy the report selection
This is rebased and edited version of the original design and
patch proposed by Jun'ichi Nomura:
  http://www.redhat.com/archives/dm-devel/2007-April/msg00025.html

This activates the actual selection process in dm_report_object.
2014-06-17 16:27:20 +02:00
Peter Rajnoha
d33280a978 report: select: add _check_selection fn to support checking fields against given selections
This is rebased and edited versions of the original design and
patch proposed by Jun'ichi Nomura:
  http://www.redhat.com/archives/dm-devel/2007-April/msg00025.html

The _check_selection implements the actual field checking against the
selection tree.
2014-06-17 16:27:20 +02:00
Peter Rajnoha
0103738ef5 report: select: add dm_report_init_with_selection to libdm
This is rebased and edited version of the original design and
patch proposed by Jun'ichi Nomura:
  http://www.redhat.com/archives/dm-devel/2007-April/msg00025.html

The dm_report_init_with_selection is the same as dm_report_init
but it contains an additional argument to set the selection
in the form of a string that contains field names to check against and
selection operators. The selection string is parsend and a selection
tree is composed for use in the checks against individual fields when
the report is processed. The parsed selection tree is stored in dm_report
structure as "selection_root".
2014-06-17 16:27:20 +02:00
Peter Rajnoha
2c3e84a68d report: select: add supporting infrastucture for token parsing in report selections
This is rebased and edited version of the original design and
patch proposed by Jun'ichi Nomura:
  http://www.redhat.com/archives/dm-devel/2007-April/msg00025.html

Add support for parsing numbers, strings (quoted or unquoted), regexes
and operators amogst these operands in selection condition supplied.
2014-06-17 16:27:20 +02:00
Peter Rajnoha
4118dd8da3 report: select: add structs for report selection
This is rebased and edited version of the original design and
patch proposed by Jun'ichi Nomura:
  http://www.redhat.com/archives/dm-devel/2007-April/msg00025.html

This patch defines operators and structures that will be used
to store the report selection against which the actual values
reported will be checked.

  Selection operators
  -------------------
    Comparison operators:
        =~  - Matching regular expression.
        !~  - Not matching regular expression.
         =  - Equal to.
        !=  - Not equal to.
        >=  - Greater than or equal to.
         >  - Greater than
        <=  - Less than or equal to.
         <  - Less than.

    Logical and grouping operators:
        &&  - All fields must match
         ,  - All fields must match
        ||  - At least one field must match
         #  - At least one field must match
         !  - Logical negation
         (  - Left parenthesis
         )  - Right parenthesis
2014-06-17 16:27:20 +02:00
Peter Rajnoha
7dbbc05a69 report: select: add DM_REPORT_FIELD_TYPE_SIZE to make a difference between NUMBER and SIZE
This makes it easier to check against the fields (following patches for
report selection) and check whether size units are allowed or not
with the field value.
2014-06-17 16:27:20 +02:00
Zdenek Kabelac
378fa9d158 tests: check new snapshot skills 2014-06-17 13:43:05 +02:00
Zdenek Kabelac
8403bbd4ad tests: detect version of thin_restore command
Skip test when missing.
2014-06-17 13:43:05 +02:00
Zdenek Kabelac
6fb19f37fe tests: wait for udev
Before test exits, wait for udev.
2014-06-17 13:43:04 +02:00
Zdenek Kabelac
0558b1a086 cleanup: we already know max device name size
Use NAME_LEN constant to simplify creation of device name.
Since the max size should be already tested in validation,
throw INTERNAL_ERROR if the size of vg/lv is bigger then NAME_LEN.
2014-06-17 13:43:04 +02:00
Zdenek Kabelac
7aef45f9bb cleanup: use stack for small buffer
Avoid error checking of allocation error when just few bytes are needed
for short string and use stack.
Stacktrace lvmetad_pv_gone() fail path.
2014-06-17 13:42:45 +02:00
Zdenek Kabelac
494db11004 snapshot: %ORIGIN is relative to data size
Let's use the size of origin as the real base for percenta calculation,
and 'silenly' add needed metadata space for snapshot.

So now command   'lvcreate -s -l100%ORIGIN vg/lv' should always create a
snapshot to handle full device overwrite.
2014-06-17 13:41:01 +02:00
Zdenek Kabelac
cd6d6fc24e snapshot: report proper error message
Expresing -lXX%LV is not valid for snapshot, but error message for
snapshost case was not complete and missed %ORIGIN.
Also document correct settings for in manpage properly where
it missed %PVS.
2014-06-17 13:36:33 +02:00
Zdenek Kabelac
15e7066fe3 snapshot: do not spawn when origin is not active
Since the code is not doing anything when origin is not active,
avoid spawning polling thread.
2014-06-17 13:36:07 +02:00
Zdenek Kabelac
c46d4a745d snapshot: check snapshot exists
Return 0 if the LV is not even snapshot.
2014-06-17 13:36:07 +02:00
Zdenek Kabelac
435c82f8f6 snapshot: check it's still snapshot
While polling for snapshot, detect first the snapshot still
exits.  It's valid to have multiple polling threads watching
for the same thing and just 1 can 'win' the finish part.
All others should nicely 'fail'.
2014-06-17 13:36:07 +02:00
Jonathan Brassow
a20de8af20 poll_daemon: Cleanly exit polling if the LV is no longer active
If the we are polling an LV due to some sort of conversion and it
becomes inactive, a rather worrisome message is produced, e.g.:
"  ABORTING: Mirror percentage check failed."

We can cleanly exit if we do a simple check to see if the LV is
active before performing the check.  This eliminates the scary
message.
2014-06-16 18:56:32 -05:00
Jonathan Brassow
962a40b981 cache: Properly rename origin LV tree when adding "_corig"
When creating a cache LV with a RAID origin, we need to ensure that
the sub-LVs of that origin properly change their names to include
the "_corig" extention of the top-level LV.  We do this by first
performing a 'lv_rename_update' before making the call to
'insert_layer_for_lv'.
2014-06-16 18:15:39 -05:00
Peter Rajnoha
fea8abe56a systemd: use RemoveOnStop for dm-event.socket and lvm2-lvmetad.socket
Systemd version 214 introduced new "RemoveOnStop" option for socket
units to remove the socket/FIFO when the particular unit is stopped.

Also https://bugzilla.redhat.com/show_bug.cgi?id=802748.
2014-06-13 15:45:25 +02:00
Peter Rajnoha
4c9fbe048f spec: new thin-generic.profile 2014-06-13 10:01:34 +02:00
Peter Rajnoha
8e0687ca69 profile: add thin-generic.profile
The thin-generic.profile contains settings for thin/thin pool volumes
suitable for generic environment/use containing default settings.
This allows users to change the global lvm.conf settings at will
and still keep the original settings for volumes that have this
thin profile assigned already.
2014-06-13 09:56:29 +02:00
Zdenek Kabelac
cf4d5ead02 test: pvs bz1108394 2014-06-12 11:56:06 +02:00
Zdenek Kabelac
eb316fec33 libdm: dm_report_object report error for no data
NULL data would cause problems....
2014-06-12 11:56:06 +02:00
Zdenek Kabelac
3d9737442b libdm: dm_report_object avoid duplicat strlen call
Remember strlen result.
2014-06-12 11:56:06 +02:00
Zdenek Kabelac
922f884abe report: avoid passing NULL label
Internal reporting function cannot handle NULL reporting value,
so ensure there is at least dummy label.

So move dummy_lable from tools/reporter.c and use it for all
report_object() calls in lib/report/report.c.
(Fixes RHBZ 1108394)

Simlify lvm_report_object initialization.
2014-06-12 11:55:58 +02:00
Zdenek Kabelac
c230ae95ab tests: change to inittest 2014-06-11 17:46:55 +02:00
Zdenek Kabelac
3f81b7c55c tests: update vgchange -c
Vgchange now detects runnig clvmd - so update test to reflect this.
2014-06-11 11:11:10 +02:00
Zdenek Kabelac
f845afe7cf man: dmsetup manglename
More updates to manglename option.
Add reference to LVM2 resource page, since for a long time,
this is the right places for sources for libdevmapper....
2014-06-11 11:11:10 +02:00
Zdenek Kabelac
4db71422a2 man: kiB uppercase 2014-06-11 11:10:56 +02:00
Zdenek Kabelac
d13efac51b man: update lvmthin
Improve graphics form of page and use shorter correct and suggested
forms of thin pool manipulation commands.
2014-06-11 11:10:55 +02:00
Zdenek Kabelac
e156837636 man: more compliant 2014-06-11 11:10:55 +02:00
Zdenek Kabelac
0896987633 man: properly escape -
Dash should be using '\' to be typographically correct.
2014-06-11 11:10:55 +02:00
Zdenek Kabelac
4956091027 man: use bullets 2014-06-11 11:10:55 +02:00
Zdenek Kabelac
d2b60c6e35 man: advertise lvmcache, lvmthin
Add references to new man pages so they get known.
2014-06-11 11:10:54 +02:00
Peter Rajnoha
6766cdc8a1 tests: some more renames lib/test -> lib/inittest 2014-06-11 11:07:32 +02:00
Zdenek Kabelac
5c5177c37c tests: rename test to inittest
We are getting into problem when we use 'test' for commands like
should/not/...

So avoid overloading test name and change it to inittest.
2014-06-10 10:51:27 +02:00