1
0
mirror of git://sourceware.org/git/lvm2.git synced 2024-12-21 13:34:40 +03:00
Commit Graph

10958 Commits

Author SHA1 Message Date
Peter Rajnoha
d8996a17d1 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.
2015-06-30 10:47:50 +02:00
Peter Rajnoha
77f0e7a450 cleanup: time: error out on incorrect time_format and indentation in config_settings.h 2015-06-29 16:17:33 +02:00
Peter Rajnoha
621398ebb7 lv: time: increase buffer to 4k in lv_time_dup 2015-06-29 15:24:00 +02:00
Peter Rajnoha
1587236089 toolcontext: use proper set of chars to check time format against 2015-06-29 14:45:53 +02:00
Peter Rajnoha
125cd06698 conf: make time format configurable
Make it possible to define format for time that is displayed.
The way the format is defined is equal to the way that is used
for strftime function, although not all formatting options as
used in strftime are available for LVM2 - the set is restricted
(e.g. we do not allow newline to be printed). The lvm.conf
comments contain the whole list that LVM2 accepts for time format
together with brief description (copied from strftime man page).

For example:
(defaults used - the format is the same as used before this patch)
$ lvs -o+time vg/lvol0 vg/lvol1
  LV    VG   Attr       LSize Time
  lvol0 vg   -wi-a----- 4.00m 2015-06-25 16:18:34 +0200
  lvol1 vg   -wi-a----- 4.00m 2015-06-29 09:17:11 +0200

(using 'time_format = "@%s"' in lvm.conf - number of seconds
since the Epoch)
$ lvs -o+time vg/lvol0 vg/lvol1
  LV    VG   Attr       LSize Time
  lvol0 vg   -wi-a----- 4.00m @1435241914
  lvol1 vg   -wi-a----- 4.00m @1435562231
2015-06-29 14:30:35 +02:00
Peter Rajnoha
6f793d34ca config: regenerate lvm.conf.in and lvmlocal.conf.in 2015-06-29 13:43:28 +02:00
Peter Rajnoha
7b45a1fc60 refactor: rename _out_tags fn to _out_list and use it for string lists in general 2015-06-29 09:43:55 +02:00
Peter Rajnoha
f143ad3a93 cleanup: remove unused tags.c file 2015-06-29 09:43:47 +02:00
Peter Rajnoha
e29d4773f4 refactor: rename alloc_printed_tags fn to _alloc_printed_str_list and use it for string lists in general 2015-06-29 09:43:41 +02:00
Peter Rajnoha
77c2d11657 refactor: rename read_tags fn to _read_str_list and use it for string lists in general 2015-06-29 09:43:32 +02:00
Zdenek Kabelac
02767c5eb1 tests: tests needs pre 1.13 thin-pool extorg
This test is testing older style, so disable feature when present.
2015-06-26 22:16:01 +02:00
Zdenek Kabelac
03c4fee5a7 tests: deactivate before remove
Testing if this avoids udev race with removal of snapshot on some
test machines.
See: https://bugzilla.redhat.com/show_bug.cgi?id=1217819
2015-06-26 22:11:46 +02:00
Ferenc Wágner
a62cd64db6 makefiles: avoid bash == operator syntax, use = instead
Commit e587b0677b broke the build on
systems where /bin/sh is Dash, for example.

Origin patch by Ferenc Wágner <wferi@niif.hu>  changed later to
avoid using shell call, so makefile add 'server' target when
one of  metad or polld daemon is requested.
2015-06-26 22:11:45 +02:00
Peter Rajnoha
844707067b lvmconfig: do not display settings with undefined default values
Do not display settings with undefined default values, but do display
these settings in case the value is defined directly in any part of
the existing config cascade.

For example, the lvmconfig --type current always displays these settings
(as it's somewhere in "current" configuration cascade that makes it defined).
The lvmconfig --type full displays these settings only if it's defined
somewhere in the cascade, but not if default value is used instead
The lvmconfig --type default never displays these settings...

More concrete example - let's have activation/volume_list directly
set in lvm.conf and activation/read_only_volume_list not set.
Both of these settings have *undefined default* values.

  $lvmconfig --type full activation/volume_list activation/read_only_volume_list
  volume_list="/dev/vg/lv"

(...only volume_list is defined, hence it's printed)

However, the comments will display more info (see also previous commit):

  $lvmconfig --type full activation/volume_list activation/read_only_volume_list --withsummary

  # Configuration option activation/volume_list.
  # Only LVs selected by this list are activated.
  # This configuration option does not have a default value defined.
  # Value defined in existing configuration has been used for this setting.
  volume_list="/dev/vg/lv"

  # Configuration option activation/read_only_volume_list.
  # LVs in this list are activated in read-only mode.
  # This configuration option does not have a default value defined.
2015-06-25 13:51:55 +02:00
Peter Rajnoha
07a34184db lvmconfig: display comment about value from existing config being used
Display comment abour value from existing config being used. For example:

$ lvmconfig --type full --withsummary report/compact_output report/buffered

 # Configuration option report/compact_output.
 # Do not print empty report fields.
 # Value defined in existing configuration has been used for this setting.
 compact_output=1

 # Configuration option report/buffered.
 # Buffer report output.
 buffered=1
2015-06-25 13:51:54 +02:00
Peter Rajnoha
c794c163b5 lvmconfig: add --type full to display full tree of settings
The lvmconfig --type full is actually a combination of --type current
and --type missing together with --mergedconfig options used.

The overall outcome is a configuration tree with settings as LVM sees
it when it looks for the values - that means, if the setting is defined
in some config source (lvm.conf, --config, lvmlocal.conf or any profile
that is used), the setting is used. Otherwise, if the setting is not
defined in any part of the config cascade, the defaults are used.

The --type full displays exactly this final tree with all the values
defined, either coming from configuration tree or from defaults.
2015-06-25 13:33:52 +02:00
Peter Rajnoha
f6de196c21 config: also clone associated id when cloning node using dm_config_clone_node{_with_mem} 2015-06-25 10:21:07 +02:00
Alasdair G Kergon
110a0745cd man: Add missing env vars to lvm man page. 2015-06-24 20:43:35 +01:00
David Teigland
7760665fb8 libdaemon: add comment about using main and init 2015-06-24 12:16:26 -05:00
Zdenek Kabelac
44c7bc0262 tests: workaround udev problem
If udev has not removed 'dir' entry - just issue TEST WARNING, clear
dir, but do not fail whole rest of test.
2015-06-24 15:19:53 +02:00
Zdenek Kabelac
e217873ed6 snapshot: add synchronization point
Synchronize with udev logic before reusing device as snapshot.

This patch tries to fix the problem with udev, where we manage
to 'active' LV for clearing, then we deactivate such device and
active again as member of 'origin&snapshot' tree all in 1 step.

There needs to be a sync point where udev has time to remove all links,
otherwise we race with scans and we may end-up with mysterious 'free'
links in the system pointing to wrong dm names.

This patch tries to fix failing topology cluster tests..
2015-06-24 15:18:49 +02:00
Peter Rajnoha
cf189a572a commands: --withspaces also for config and lvmconfig cmd aliases 2015-06-24 13:28:40 +02:00
Peter Rajnoha
7559d871fb make: use lvmconfig ... --withspaces when generating lvm.conf and lvmlocal.conf 2015-06-24 13:20:38 +02:00
Peter Rajnoha
a4724350e4 lvmconfig: add --withspaces option
We shouldn't be adding spaces by default in output as that
may be be used already in scripts and especially for the eval
in shell scripts where spaces are not allowed between key
and value!

Add --withspaces option to lvmconfig for pretty output with
more space in for readability.
2015-06-24 13:19:23 +02:00
Peter Rajnoha
a25d92c88b WHATS_NEW: recent commits - config value format flags 2015-06-24 11:34:02 +02:00
Peter Rajnoha
982cf44ff0 config: regenerate configure.in to accomodate all recent changes
Hopefully closer to the ideal.
2015-06-24 11:24:10 +02:00
Peter Rajnoha
63c5aaaaf2 config: devices/filter and devices/global_filter setting have 'a/.*/' as default value 2015-06-24 11:23:54 +02:00
Peter Rajnoha
c725648f6c config: allow empty values for {thin,cache}_{check,repair}_options
It's not an error to define empty values for
{thin,cache}_{check,repair}_options - such empty value means no
options are passed when these external commands are called.
2015-06-24 11:13:38 +02:00
Peter Rajnoha
20e336f21c configure: add DEFAULT_USE_BLKID_WIPING
If blkid wiping is possible, than set use_blkid_wiping=1 and
use_blkid_wiping=0 otherwise for its default value. If blkid wiping
is disabled during configure and use_blkid_wiping=1 is set by chance,
it's simply ignored - this patch is just a cleanup that makes it more
obvious for the user (we use similar logic for use_lvmetad and
use_lvmpolld settings).
2015-06-24 11:13:38 +02:00
Peter Rajnoha
6575122c63 config: display global/umask in octal form 2015-06-24 11:13:38 +02:00
Peter Rajnoha
74bf75a2f5 config: use proper unconfigured default values for use_lvmetad and use_lvmpolld settings
Default value for lvmetad and lvmpolld has hooks in configure script,
the "lvmconfig --type default --unconfigured" should display:

   use_lvmetad = @DEFAULT_USE_LVMETAD@
   use_lvmpolld = @DEFAULT_USE_LVMPOLLD@

Note that these settings are not of string type. Recent change (the
DM_CONFIG_VALUE_FMT_STRING_NO_QUOTES formatting flag) makes it
possible to recognize that the setting is not of string type and if
there's unconfigured value defined for it, the enclosing " " is
automatically removed on output.
2015-06-24 11:13:38 +02:00
Peter Rajnoha
1545ebf938 config: cleanup default values for some configuration settings with array values
Do not use "#S" (blank string) as default value as that ends up with
'key = [ "" ]' to be generated which is not what we want in most cases.

Also, fix default values for global/{thin,cache}_{check,repair}_options
and avoid assigning blank values. For example, the thin_check_options
had this set as default value previously:

  "#S" DEFAULT_THIN_CHECK_OPTION1 "#S" DEFAULT_THIN_CHECK_OPTION2

If any (or both) of DEFAULT_THIN_CHECK_OPTION* variables was set
to "", we ended up with clumsy default value generated like:

  thin_check_options = [ "-q", "" ]

With this patch, we end up with correct:

  thin_check_options = [ "-q" ]

or, if all options are undefined:

  thin_check_options = [ ]

Which is the correct way to express this.
2015-06-24 11:13:38 +02:00
Peter Rajnoha
9465963faf config: add support for config value formatting flags
There are two basic groups of formatting flags (32 bits):
  - common ones applicable for all config value types (lower 16 bits)
  - type-related formatting flags (higher 16 bits)

With this patch, we initially support four new flags that
modify the the way the config value is displayed:

  Common flags:
  =============

  DM_CONFIG_VALUE_FMT_COMMON_ARRAY - causes array config values
    to be enclosed in "[ ]" even if there's only one item
    (previously, there was no way to recognize an array with one
     item and scalar value, hence array values with one member
     were always displayed without "[ ]" which libdm accepted
     when reading, but it may have been misleading for users)

  DM_CONFIG_VALUE_FMT_COMMON_EXTRA_SPACE - causes extra spaces to
    be inserted in "key = value" (or key = [ value, value, ... ] in
    case of arrays), compared to "key=value" seen on output before.
    This makes the output more readable for users.

  Type-related flags:
  ===================

  DM_CONFIG_VALUE_FMT_INT_OCTAL - prints integers in octal form with
    "0" as a prefix (libdm's config reading code can handle this via
    strtol just fine so it's properly recognized as number in octal
    form already if there's "0" used as prefix)

  DM_CONFIG_VALUE_FMT_STRING_NO_QUOTES - makes it possible to print
    strings without enclosing " "

This patch also adds dm_config_value_set_format_flags and
dm_config_value_get_format_flags functions to set and get
these formatting flags.
2015-06-24 11:13:37 +02:00
David Teigland
c5ba60827e libdaemon: allow main processing function to be specified 2015-06-23 16:55:45 -05:00
David Teigland
ba2b701f2c doc: mention new invalid states in lvmetad_design 2015-06-23 16:48:28 -05:00
David Teigland
c23e7ff2a0 Reread global state the lvmetad copy is stale
This is the client side handling of the global_invalid state
added to lvmetad in commit c595b50cec8a6b95c6ac4988912d1412f3cc0237.

The function added here:
. checks if the global state in lvmetad is invalid
. if so, scans disks to update the state in lvmetad
. clears the global_invalid flag in lvmetad
. updates the local udev db to reflect any changes
2015-06-23 16:36:40 -05:00
David Teigland
679b6b5b29 Reread a VG if the lvmetad copy is stale
and update the lvmetad copy after it is reread from disk.

This is the client side handling of the vg_invalid state
added to lvmetad in commit c595b50cec8a6b95c6ac4988912d1412f3cc0237.
2015-06-23 16:36:40 -05:00
David Teigland
bf77f71711 lvmetad: add invalidation method
Add the ability to invalidate global or individual VG metadata.
The invalid state is returned to lvm commands along with the metadata.
This allows lvm commands to detect stale metadata from the cache and
reread the latest metadata from disk (in a subsequent patch.)

These changes do not change the protocol or compatibility between
lvm commands and lvmetad.

Global information
------------------

Global information refers to metadata that is not isolated
to a single VG , e.g. the list of vg names, or the list of pvs.

When an external system, e.g. a locking system, detects that global
information has been changed from another host (e.g. a new vg has been
created) it sends lvmetad the message: set_global_info: global_invalid=1.
lvmetad sets the global invalid flag to indicate that its cached data is
stale.

When lvm commands request information from lvmetad, lvmetad returns the
cached information, along with an additional top-level config node called
"global_invalid".  This new info tells the lvm command that the cached
information is stale.

When an lvm command sees global_invalid from lvmated, it knows it should
rescan devices and update lvmetad with the latest information.  When this
is complete, it sends lvmetad the message: set_global_info:
global_invalid=0, and lvmetad clears the global invalid flag.  Further lvm
commands will use the lvmetad cache until it is invalidated again.

The most common commands that cause global invalidation are vgcreate and
vgextend.  These are uncommon compared to commands that report global
information, e.g. vgs.  So, the percentage of lvmetad replies containing
global_invalid should be very small.

VG information
--------------

VG information refers to metadata that is isolated to a single VG,
e.g. an LV or the size of an LV.

When an external system determines that VG information has been changed
from another host (e.g. an lvcreate or lvresize), it sends lvmetad the
message: set_vg_info: uuid=X version=N.  X is the VG uuid, and N is the
latest VG seqno that was written.  lvmetad checks the seqno of its cached
VG, and if the version from the message is newer, it sets an invalid flag
for the cached VG.  The invalid flag, along with the newer seqno are saved
in a new vg_info struct.

When lvm commands request VG metadata from lvmetad, lvmetad includes the
invalid flag along with the VG metadata.  The lvm command checks for this
flag, and rereads the VG from disk if set.  The VG read from disk is sent
to lvmetad.  lvmetad sees that the seqno in the new version matches the
seqno from the last set_vg_info message, and clears the vg invalid flag.
Further lvm commands will use the VG metadata from lvmetad until it is
next invalidated.
2015-06-23 16:36:33 -05:00
Zdenek Kabelac
4c6b3f5ec3 tests: use vgscan after enable_dev
Since our test environment runs also in non-real-udev world,
it's using  /etc/.cache file with scanned files.

So in this case it is mandatory the user runs 'vgscan'
after a device reappears in the system.

This 'first' lvm2 command then fixes metadata (just like vgs did).
2015-06-23 13:39:57 +02:00
Zdenek Kabelac
ae76e8f0d0 tests: skip when snapshot does not work
Some older kernel (i.e. 3.11.10 on fc20) do not work properly.
Skip the test if snapshot does not meet 50%.
2015-06-23 13:25:09 +02:00
Zdenek Kabelac
7ee3ccd826 tests: newer version needed for ext-orig 2015-06-23 11:56:42 +02:00
Zdenek Kabelac
9c86d33e68 cleanup: avoid printing gcc warning
Casting to (void) with gcc doesn't remove unused_result warning.
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=25509
2015-06-23 11:06:02 +02:00
Alasdair G Kergon
50d70eff35 post-release 2015-06-20 01:05:21 +01:00
Alasdair G Kergon
134b727b4f pre-release 2015-06-20 00:57:35 +01:00
Zdenek Kabelac
b45e9183bc tests: external origin updates
Update test for recent updates to support unalligned sizes
and extension of reduced volume.
2015-06-19 16:33:29 +02:00
Zdenek Kabelac
00d028fd77 log: flush stdout before print to stderr
Keep logging readable and fflush stdout before printing to stderr.
2015-06-19 16:33:20 +02:00
Zdenek Kabelac
3173442984 lvm: move hyphen mangling code
Relocate hyphen code from lvm main into lvm_run_command()
so all command and library user will have it.

Update WHATS_NEW with missing changes.
2015-06-19 09:51:48 +02:00
Zdenek Kabelac
438a65dfdb display: drop allocation from display_lvname
Use of display_lvname() in plain log_debug() may accumulate memory in
command context mempool. Use instead small ringbuffer which allows to
store cuple (10 ATM) names so upto 10 full names can be used at one.

We are not keeping full VG/LV names as it may eventually consume larger
amount of RAM resouces if vgname is longer and lots of LVs are in use.

Note: if there would be ever needed for displaing more names at once,
the limit should be raised (e.g. log_debug() would need to print more
then 10 LVs on a single line).
2015-06-18 18:50:37 +02:00
Zdenek Kabelac
a3e0d830bd thin: support unaligned size of external origin and thin pool
With thin-pool kernel target module 1.13 it's now support usage of
external origin with sizes which are not 'alligned' with chunk size
of thin-pool.

Enable lvm2 support for this and also fix reporting of data_percent
usage for case sizes are not alligned.
2015-06-18 18:50:36 +02:00
Zdenek Kabelac
6f2a617c31 thin: drop limitation for extension of reduced thin volume
Drop check which has prevented resize of reduce thin volume with
external origin. User is supposed to use 'zeroing' to get 'clean'
chunks.
2015-06-18 18:48:59 +02:00