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

2050 Commits

Author SHA1 Message Date
Zdenek Kabelac
d46588c2d7 cleanup: add dot to lvchange message 2013-06-25 13:47:39 +02:00
Zdenek Kabelac
19b064a309 cleanup: move mirror check code closer
Group a bit more code related to mirrors.
2013-06-25 13:47:39 +02:00
Zdenek Kabelac
09dc590b67 cleanup: code swap
Use easier to read positive query and indent line.
2013-06-25 13:47:39 +02:00
Jonathan Brassow
88288ab433 cleanup: Remove message used for development
Failed to clean out all messages used during development.
2013-06-24 06:16:39 -05:00
Jonathan Brassow
a6d13308ec RAID/MIRROR: Honor mirror_segtype_default when upconverting linear LVs
If the user would upconvert a linear LV to a mirror without specifying
the segment type ("--type mirror" vs "--type raid1"), the "mirror"
segment type would be chosen without consulting the 'default_mirror_segtype'
setting in lvm.conf.  This is now used as the basis for determining
which should be used if left unspecified.
2013-06-19 17:50:10 -05:00
Zdenek Kabelac
4d2aa6a7aa cleanup: use parsed yes_no_arg
Do not parse yes_no_arg inside tools code and use already
available result as uint.
2013-06-18 22:13:42 +02:00
Zdenek Kabelac
450ac7be42 cleanup: move string in the use-place 2013-06-16 00:07:33 +02:00
Zdenek Kabelac
036d4f2982 cleanup: tab 2013-06-13 14:51:02 +02:00
Zdenek Kabelac
fe22089edf thin: vgsplit support for thins
Support vgsplit for VGs with thin pools and thin volumes.
In case the thin data and thin metadata volumes are moved to a new VG,
move there also all related thin volumes and check that external origins
are also present in this new VG.
2013-06-13 14:51:00 +02:00
Zdenek Kabelac
bb70b38021 lvresize: improve poolmetadatasize
Fix the usecase when only PV list is specified.
With --poolmetadatasize PV list is used for metadata extents.
Without --poolmetadatasize PV list is used for 100% extension of LV.
Handle the case, when nothing could be resized (i.e. in dmeventd)
2013-06-11 19:46:42 +02:00
Zdenek Kabelac
6ff8b6d754 lvresize: fix pvh handling
Fix bug in previous patch - if only PVs are specified -
it's like if user would have specified size.
2013-06-11 14:55:32 +02:00
Zdenek Kabelac
c888c925b8 thin: enable resize for thin pool metadata LV
Support 'clasic' way of resizing of metadata LV.
Normally we disallow to work with internal 'invisible' devices.
But in this case we can make an exception and if user has some
special needs how to extend thin pool metadata LV - support it.

After resize of metadata LV, the pool will be suspended and resumed,
to be notified of this change.
2013-06-11 14:07:51 +02:00
Zdenek Kabelac
87aca628d6 thin: lvresize supports pool metadata resize
Add support for lvresize of thin pool metadata device.

lvresize --poolmetadatasize +20   vgname/thinpool_lv

or

lvresize -L +20 vgname/thinpool_lv_tmeta

Where the second one allows all the args for resize (striping...)
and the first option resizes accoding to the last metadata lv segment.
2013-06-11 14:05:20 +02:00
Zdenek Kabelac
272f5ae208 snapshots: check for active state
Fix testing if the snapshot could be resized and use lv_is_active()
to get correct answer in cluster.
2013-06-11 13:57:18 +02:00
Zdenek Kabelac
1cdb6ca2b2 cleanup: skip test if already tested for SIGN_PLUS 2013-06-11 13:55:26 +02:00
Zdenek Kabelac
d0def236d6 cleanup: move lv assignment
Use shorter  lv->.
2013-06-11 13:55:26 +02:00
Petr Rockai
f65dd341a5 locking: Make it possible to pass down an LV to activation code.
Previously, we have relied on UUIDs alone, and on lvmcache to make getting a
"new copy" of VG metadata fast. If the code which triggers the activation has
the correct VG metadata at hand (the version which is currently on disk), it can
now hand it to the activation code directly.
2013-06-10 17:26:38 +02:00
Zdenek Kabelac
e5baaf4ac9 lvcreate: update thin validation
Merge duplicate code that was validating lvcreate args
for creation of thin and snapshot.

Keep most of thin checks in _check_thin_parameters().

Update couple error messages.
2013-05-31 21:40:07 +02:00
Zdenek Kabelac
e01fbd9d8d lvcreate: update snapshot test
With last commit, there has been missing test for valid setting
of extents - there is no need to test max size when creating
thin snapshots.
2013-05-31 21:30:44 +02:00
Jonathan Brassow
562c678ee2 DM RAID: Add ability to throttle sync operations for RAID LVs.
This patch adds the ability to set the minimum and maximum I/O rate for
sync operations in RAID LVs.  The options are available for 'lvcreate' and
'lvchange' and are as follows:
  --minrecoveryrate <Rate> [bBsSkKmMgG]
  --maxrecoveryrate <Rate> [bBsSkKmMgG]
The rate is specified in size/sec/device.  If a suffix is not given,
kiB/sec/device is assumed.  Setting the rate to 0 removes the preference.
2013-05-31 11:25:52 -05:00
Zdenek Kabelac
6f9366696c cleanup: fix tabs 2013-05-30 17:56:41 +02:00
Zdenek Kabelac
b08c346489 lvresize: drop monitoring of 100% covered origin 2013-05-30 17:35:23 +02:00
Zdenek Kabelac
3ced1bf694 lvresize: check for max snapshot size
As for lvcreate, lvresize also doesn't need to grow bigger then needed.
2013-05-30 17:35:23 +02:00
Zdenek Kabelac
bd3ece0128 lvcreate: reduce too large cow
Detect maximum usable size of snapshot COW device,
and do not waste more space for such LV then needed.
2013-05-30 17:35:14 +02:00
Zdenek Kabelac
56779c32c5 snapshot: fix resize of 100% full cow
When the COW area is using all the available space (100%) it can be still
a valid snapshot which may need a resize. So support it.
2013-05-30 17:26:20 +02:00
Zdenek Kabelac
99f0483580 args: do not accept >=16EiB sizes
Instead of seeing wierd overflows inside the lvm code,
giving false error messages, kill the user experiment in the begining.

Who needs to use more then 16EiB with lvm2 and 64bit anyway...
2013-05-30 17:23:51 +02:00
Peter Rajnoha
732859d21f refactor: rename embedding area -> bootloader area 2013-05-28 12:37:22 +02:00
Zdenek Kabelac
3ba3bc0d66 cleanup: drop backtrace
After log_error/log_warn there is no point to show <backtrace>
in debug log trace from the next code line.
2013-05-27 10:28:32 +02:00
Zdenek Kabelac
58a2e5e2df cleanup: use last_seg
Use function to obtain last segment type.
2013-05-27 10:28:32 +02:00
Zdenek Kabelac
2ada982e73 vgchange: check for mounted fs
Check for mounted fs also for vgchange command, not just lvchange.

NOTE: Code is using lv_info() just like lvs_in_vg_opened().
It should be probably converted into  lv_is_active_locally().
2013-05-20 16:47:33 +02:00
Jonathan Brassow
06ac797f42 Clean-up: Replace 'lv_is_active' with more correct/specific variants
There are places where 'lv_is_active' was being used where it was
more correct to use 'lv_is_active_locally'.  For example, when checking
for the existance of a kernel instance before asking for its status.
Most of the time these would work correctly.  (RAID is only allowed on
non-clustered VGs at the moment, which means that 'lv_is_active' and
'lv_is_active_locally' would give the same result.)  However, it is
more correct to use the proper variant and it helps with future
scenarios where targets might be allowed exclusively (or clustered) in
a cluster VG.
2013-05-16 10:36:56 -05:00
Peter Rajnoha
4777eb6872 lvconvert: check for snapshot-merge support before merge init 2013-05-16 08:21:57 +02:00
Alasdair G Kergon
c6cf2ed7fd commands: accept --yes globally
Accept --yes on all commands, even ones that don't today have prompts,
so that test scripts that don't care about interactive prompts no
longer need to deal with them.

But continue to mention --yes only in the command prototypes that
actually use it.
2013-05-14 18:45:37 +01:00
Zdenek Kabelac
6fc67f5509 thin: limited support for -l%FREE allocation
This is just a temporary fix to support allocation of -l%FREE.

The number of free extent serves to calculate estimated metadata
size. This value is then substracted twice to keep some
free space for recover.
2013-05-13 13:13:22 +02:00
Zdenek Kabelac
deb3c93a19 cleanup: simplify
Use simplier sprintf.
2013-05-03 15:44:14 +02:00
Zdenek Kabelac
986a50e4a1 cleanup: improve previous patch
Make the test earlier, before any dereference of 'argv' pointer.
2013-05-03 15:44:14 +02:00
Zdenek Kabelac
d2d71330c3 lv: add lv_active_change
Make a separate /lib function for the change of activation state
of the LV.

(in release update)
2013-05-03 15:43:19 +02:00
Zdenek Kabelac
dacc340cc8 pvscan: missing test for id_read_format
(in release fix)
2013-05-03 15:42:44 +02:00
Zdenek Kabelac
c1eb17ab07 lvchange: use vg mempool
Using vg mempool for vg related data. Since we have VG in write mode,
prefer to use this mempool instead of cmd mempool.
2013-04-25 17:33:24 +02:00
Zdenek Kabelac
68ef288901 raid: remove wrong pool free
No, we cannot free pool members here.
2013-04-23 14:06:40 +02:00
Zdenek Kabelac
5a751ad703 cleanup: use proper activation_change_t 2013-04-21 23:14:57 +02:00
Zdenek Kabelac
dfca5dac9c cleanup: explicit check for nonnull pointer
Since execvp requires nonnull args - add explicit check.
2013-04-21 23:14:05 +02:00
Zdenek Kabelac
17a6915054 thin: explicitly avoid pvmove operation
So far we do not support pvmove for thin volumes
and thin pools.
2013-04-21 23:09:11 +02:00
Zdenek Kabelac
9e24d563c6 raid: read segment only for known LV
Avoid reading first_seg() on unknown LV and find it only when needed.
2013-04-21 23:07:00 +02:00
Jonathan Brassow
2e0740f7ef RAID: Add writemostly/writebehind support for RAID1
'lvchange' is used to alter a RAID 1 logical volume's write-mostly and
write-behind characteristics.  The '--writemostly' parameter takes a
PV as an argument with an optional trailing character to specify whether
to set ('y'), unset ('n'), or toggle ('t') the value.  If no trailing
character is given, it will set the flag.
Synopsis:
        lvchange [--writemostly <PV>:{t|y|n}] [--writebehind <count>] vg/lv
Example:
        lvchange --writemostly /dev/sdb1:y --writebehind 512 vg/raid1_lv

The last character in the 'lv_attr' field is used to show whether a device
has the WriteMostly flag set.  It is signified with a 'w'.  If the device
has failed, the 'p'artial flag has priority.

Example ("nosync" raid1 with mismatch_cnt and writemostly):
[~]# lvs -a --segment vg
  LV                VG   Attr      #Str Type   SSize
  raid1             vg   Rwi---r-m    2 raid1  500.00m
  [raid1_rimage_0]  vg   Iwi---r--    1 linear 500.00m
  [raid1_rimage_1]  vg   Iwi---r-w    1 linear 500.00m
  [raid1_rmeta_0]   vg   ewi---r--    1 linear   4.00m
  [raid1_rmeta_1]   vg   ewi---r--    1 linear   4.00m

Example (raid1 with mismatch_cnt, writemostly - but failed drive):
[~]# lvs -a --segment vg
  LV                VG   Attr      #Str Type   SSize
  raid1             vg   rwi---r-p    2 raid1  500.00m
  [raid1_rimage_0]  vg   Iwi---r--    1 linear 500.00m
  [raid1_rimage_1]  vg   Iwi---r-p    1 linear 500.00m
  [raid1_rmeta_0]   vg   ewi---r--    1 linear   4.00m
  [raid1_rmeta_1]   vg   ewi---r-p    1 linear   4.00m

A new reportable field has been added for writebehind as well.  If
write-behind has not been set or the LV is not RAID1, the field will
be blank.
Example (writebehind is set):
[~]# lvs -a -o name,attr,writebehind vg
  LV            Attr      WBehind
  lv            rwi-a-r--     512
  [lv_rimage_0] iwi-aor-w
  [lv_rimage_1] iwi-aor--
  [lv_rmeta_0]  ewi-aor--
  [lv_rmeta_1]  ewi-aor--

Example (writebehind is not set):
[~]# lvs -a -o name,attr,writebehind vg
  LV            Attr      WBehind
  lv            rwi-a-r--
  [lv_rimage_0] iwi-aor-w
  [lv_rimage_1] iwi-aor--
  [lv_rmeta_0]  ewi-aor--
  [lv_rmeta_1]  ewi-aor--
2013-04-15 13:59:46 -05:00
Alasdair G Kergon
9495a3d807 Revert "cleanup: simplify option matching function"
This reverts commit 0396ade38b.

The original code also handled len==1, which the new code doesn't.
Press <TAB> in the lvm shell to get a list of the possible
flag completions for a single hyphen.
2013-04-13 02:26:37 +01:00
Zdenek Kabelac
58734d2538 dmsetup: check for strncpy
Test whether device name fits into a given buffer.
2013-04-12 11:30:47 +02:00
Zdenek Kabelac
a81a2406f1 tools: add common lv_change_activate
Move common code for changing activation state from
vgchange and lvchange to one function.

Fix the order of checks - so we always implicitelly
activate snapshots and thin volumes in exclusive mode,
and we do not allow local deactivation for them.
2013-04-12 11:30:07 +02:00
Jonathan Brassow
ff64e3500f RAID: Add scrubbing support for RAID LVs
New options to 'lvchange' allow users to scrub their RAID LVs.
Synopsis:
	lvchange --syncaction {check|repair} vg/raid_lv

RAID scrubbing is the process of reading all the data and parity blocks in
an array and checking to see whether they are coherent.  'lvchange' can
now initaite the two scrubbing operations: "check" and "repair".  "check"
will go over the array and recored the number of discrepancies but not
repair them.  "repair" will correct the discrepancies as it finds them.

'lvchange --syncaction repair vg/raid_lv' is not to be confused with
'lvconvert --repair vg/raid_lv'.  The former initiates a background
synchronization operation on the array, while the latter is designed to
repair/replace failed devices in a mirror or RAID logical volume.

Additional reporting has been added for 'lvs' to support the new
operations.  Two new printable fields (which are not printed by
default) have been added: "syncaction" and "mismatches".  These
can be accessed using the '-o' option to 'lvs', like:
	lvs -o +syncaction,mismatches vg/lv
"syncaction" will print the current synchronization operation that the
RAID volume is performing.  It can be one of the following:
        - idle:   All sync operations complete (doing nothing)
        - resync: Initializing an array or recovering after a machine failure
        - recover: Replacing a device in the array
        - check: Looking for array inconsistencies
        - repair: Looking for and repairing inconsistencies
The "mismatches" field with print the number of descrepancies found during
a check or repair operation.

The 'Cpy%Sync' field already available to 'lvs' will print the progress
of any of the above syncactions, including check and repair.

Finally, the lv_attr field has changed to accomadate the scrubbing operations
as well.  The role of the 'p'artial character in the lv_attr report field
as expanded.  "Partial" is really an indicator for the health of a
logical volume and it makes sense to extend this include other health
indicators as well, specifically:
        'm'ismatches:  Indicates that there are discrepancies in a RAID
                       LV.  This character is shown after a scrubbing
                       operation has detected that portions of the RAID
                       are not coherent.
        'r'efresh   :  Indicates that a device in a RAID array has suffered
                       a failure and the kernel regards it as failed -
                       even though LVM can read the device label and
                       considers the device to be ok.  The LV should be
                       'r'efreshed to notify the kernel that the device is
                       now available, or the device should be 'r'eplaced
                       if it is suspected of failing.
2013-04-11 15:33:59 -05:00
Jonathan Brassow
cbcbb67731 mirror: Fix overly-concerning warning on mirror up-convert failure.
Attempting to up-convert an inactive mirror when there is insufficient
space leads to the following message:
  Unable to allocate extents for mirror(s).
  ABORTING: Failed to remove temporary mirror layer inactive_mimagetmp_3.
  Manual cleanup with vgcfgrestore and dmsetup may be required.
This is caused by a failure to execute the 'deactivate_lv' function in
the error condition.  The deactivate returns an error because the LV is
already inactive.  This patch checks if the LV is activate and calls
deactivate_lv only if it is.  This allows the error cleanup code to work
properly in this condition.

It wasn't that big of a deal anyway, since there was no previous vg_commit
that needed to be reverted.  IOW, no harm was done if the allocation failed.
The message was scary and useless.
2013-04-10 16:47:04 -05:00
Zdenek Kabelac
d24c01a414 thin: lvcreate external origin snapshot support 2013-04-02 15:17:31 +02:00
Zdenek Kabelac
b57b394ebb cmdline: add arg_long_option_name
Add simple function to return long_name string option for given arg.
2013-04-02 15:16:53 +02:00
Peter Rajnoha
32ae07cef1 pv_write: clean up non-orphan format1 PV write
...to not pollute the common and format-independent code in the
abstraction layer above.

The format1 pv_write has common code for writing metadata and
PV header by calling the "write_disks" fn and when rewriting
the header itself only (e.g. just for the purpose of changing
the PV UUID) during the pvchange operation, we had to tweak
this functionality for the format1 case and we had to assign
the PV the orphan state temporarily.

This patch removes the need for this format1 tweak and it calls
the write_disks with appropriate flag indicating whether this is
a PV write call or a VG write call, allowing for metatada update
for the latter one.

Also, a side effect of the former tweak was that it effectively
invalidated the cache (even for the non-format1 PVs) as we
assigned it the orphan state temporarily just for the format1
PV write to pass.

Also, that tweak made it difficult to directly detect whether
a PV was part of a VG or not because the state was incorrect.

Also, it's not necessary to backup and restore some PV fields
when doing a PV write:

  orig_pe_size = pv_pe_size(pv);
  orig_pe_start = pv_pe_start(pv);
  orig_pe_count = pv_pe_count(pv);
  ...
  pv_write(pv)
  ...
  pv->pe_size = orig_pe_size;
  pv->pe_start = orig_pe_start;
  pv->pe_count = orig_pe_count;

...this is already done by the layer below itself (the _format1_pv_write fn).

So let's have this cleaned up so we don't need to be bothered
about any 'format1 special case for pv_write' anymore.
2013-03-25 15:08:26 +01:00
Peter Rajnoha
59878d0129 metadata: add 'allow_orphan' arg to find_pv_by_name fn
Before, the find_pv_by_name call always failed if the PV found was orphan.
However, we might use this function even for a PV that is not part of any VG.
This patch adds 'allow_orphan' arg to find_pv_by_name fn that allows that.
2013-03-19 14:57:31 +01:00
Zdenek Kabelac
562ad293fd thin: rework lvconvert
Usage of layer was not the best plan here - for proper devices stack
we have to keep correct reference in volume_group structure and
make the new thin pool LV appear as a new volume.
2013-03-13 15:13:54 +01:00
Zdenek Kabelac
9cf00666b3 thin: cannot use snapshot merge with thinpool 2013-03-13 15:13:54 +01:00
Zdenek Kabelac
0191d99906 thin: assign through structure
Just simplify code.
2013-03-13 15:13:54 +01:00
Zdenek Kabelac
f572bf987e thin: read paramaters in front
Fill paramaters into lvconvert_params -
so we could use it independently on args()
2013-03-13 15:13:54 +01:00
Zdenek Kabelac
82eee72019 thin: lvconvert read params sooner
Move code for reading stripesize and readahead to the
_read_params function.
2013-03-13 15:13:54 +01:00
Zdenek Kabelac
b36a776a7f thin: move update_pool_params
Now we may recongnize preset arguments, move
the code for updating thin pool related values
into /lib portion of the code.
2013-03-13 15:13:54 +01:00
Zdenek Kabelac
f06dd8725a thin: mark passed args
Keep the flag whether given thin pool argument has been given on command
line or it's been 'estimated'

Call of update_pool_params() must not change cmdline given args and
needs to know this info.

Since there is a need to move this update function into /lib, we cannot
use arg_count().

FIXME: we need some generic mechanism here.
2013-03-13 15:13:54 +01:00
Peter Rajnoha
521a0a3323 dmsetup: fix 'splitname -o' to not fail if used without '-c'
This was a regression introduced with e33fd978a8
(libdm v1.02.68/lvm2 v2.02.89) with the introduction of new output
fields blkdevname and blkdevs_used for ls and deps dmsetup commands.

A new common '_process_options' fn was added with that commit, but the
fn was called prematurely which then broke processing of
'dmsetup splitname -o' which should implicitly use '-c' option
and this was failing after the commit:

  alatyr/~ $ dmsetup splitname -o lv_name /dev/mapper/vg_data-test
  Option not recognised: lv_name
  Couldn't process command line.

The '-c' had to be used for correct operation:

  alatyr/~ $ dmsetup splitname -c -o lv_name /dev/mapper/vg_data-test
  LV
  test

Now fixed to work as it did before:

  alatyr/~ $ dmsetup splitname -o lv_name /dev/mapper/vg_data-test
  LV
  test
2013-03-12 13:01:57 +01:00
Peter Rajnoha
6b777ccbb5 cleanup: get rid of compiler's warning about possible unitialized variable 2013-03-06 12:53:27 +01:00
Peter Rajnoha
7d6991e900 dumpconfig: add --ignoreadvanced and --ignoreunsupported switch
lvm dumpconfig [--ignoreadvanced] [--ignoreunsupported]

--ignoreadvanced causes the advanced configuration options to be left
out on dumpconfig output

--ignoreunsupported causes the options that are not officially supported
to be lef out on dumpconfig output
2013-03-06 10:46:36 +01:00
Peter Rajnoha
088d88cfe2 dumpconfig: add --withcomments and --withversions switch
lvm dumpconfig [--withcomments] [--withversions]

The --withcomments causes the comments to appear on output before each
config node (if they were defined in config_settings.h).

The --withversions causes a one line extra comment to appear on output
before each config node with the version information in which the
configuration setting first appeared.
2013-03-06 10:46:36 +01:00
Peter Rajnoha
34350963d1 dumpconfig: add --type, --atversion and --validate arg
lvm dumpconfig [--type {current|default|missing|new}] [--atversion] [--validate]

This patch adds above-mentioned args to lvm dumpconfig and it maps them
to creation and writing out a configuration tree of a specific type
(see also previous commit):

  - current maps to CFG_TYPE_CURRENT
  - default maps to CFG_TYPE_DEFAULT
  - missing maps to CFG_TYPE_MISSING
  - new maps to CFG_TYPE_NEW

If --type is not defined, dumpconfig defaults to "--type current"
which is the original behaviour of dumpconfig before all these changes.

The --validate option just validates current configuration tree
(lvm.conf/--config) and it writes a simple status message:

  "LVM configuration valid" or "LVM configuration invalid"
2013-03-06 10:46:36 +01:00
Peter Rajnoha
386886f71c config: refer to config nodes using assigned IDs
For example, the old call and reference:

  find_config_tree_str(cmd, "devices/dir", DEFAULT_DEV_DIR)

...now becomes:

  find_config_tree_str(cmd, devices_dir_CFG)

So we're referring to the named configuration ID instead
of passing the configuration path and the default value
is taken from central config definition in config_settings.h
automatically.
2013-03-06 10:14:33 +01:00
Peter Rajnoha
86f65a3f2b tools: add embeddingareasize arg to pvcreate and vgconvert
To create an Embedding Area during PV creation (pvcreate or as part of
the vgconvert operation), we need to define the Embedding Area size.
The Embedding Area start will be calculated automatically by the tools.

This patch adds --embeddingareasize argument to pvcreate and vgconvert.
2013-02-26 14:46:41 +01:00
Peter Rajnoha
b778653f03 pv_header_extension: add support for writing PV header extension (flags & Embedding Area)
The PV header extension information (PV header extension version, flags
and list of Embedding Area locations) is stored just beyond the PV header base.

When calculating the Embedding Area start value (ea_start), the same logic is
used as when calculating the pe_start value for Data Area - the value must
follow exactly the same alignment restrictions for its start value
(the alignment detected automatically or provided via command line using
the --dataalignment and --dataalignmentoffset arguments).

The Embedding Area is placed at the very start of the PV, starting at
ea_start. The Data Area starting at pe_start is placed next. The pe_start is
still properly aligned. Due to the pe_start alignment, it's possible that the
resulting Embedding Area size (ea_size) ends up bigger in size than requested
(but never less than requested).
2013-02-26 11:28:00 +01:00
Peter Rajnoha
9dbe25709e pv_header_extension: add support for reading PV header extension (flags & Embedding Area)
New tools with PV header extension support will read the extension
if it exists and it's not an error if it does not exist (so old PVs
will still work seamlessly with new tools).

Old tools without PV header extension support will just ignore any
extension.

As for the Embedding Area location information (its start and size),
there are actually two places where this is stored:
  - PV header extension
  - VG metadata

The VG metadata contains a copy of what's written in the PV header
extension about the Embedding Area location (NULL value is not copied):

    physical_volumes {
        pv0 {
          id = "AkSSRf-difg-fCCZ-NjAN-qP49-1zzg-S0Fd4T"
          device = "/dev/sda"     # Hint only

          status = ["ALLOCATABLE"]
          flags = []
          dev_size = 262144       # 128 Megabytes
          pe_start = 67584
          pe_count = 23   # 92 Megabytes
          ea_start = 2048
          ea_size = 65536 # 32 Megabytes
        }
    }

The new metadata fields are "ea_start" and "ea_size".
This is mostly useful when restoring the PV by using existing
metadata backups (e.g. pvcreate --restorefile ...).

New tools does not require these two fields to exist in VG metadata,
they're not compulsory. Therefore, reading old VG metadata which doesn't
contain any Embedding Area information will not end up with any kind
of error but only a debug message that the ea_start and ea_size values
were not found.

Old tools just ignore these extra fields in VG metadata.
2013-02-26 11:27:23 +01:00
Peter Rajnoha
6d8de3638c cleanup: use struct pvcreate_restorable_params throughout 2013-02-26 11:25:11 +01:00
Peter Rajnoha
6692b17777 cleanup: add struct pvcreate_restorable_params and move relevant items from pvcreate_params
Extract restorable PV creation parameters from struct pvcreate_params into
a separate struct pvcreate_restorable_params for clarity and also for better
maintainability when adding any new items later.
2013-02-26 11:24:38 +01:00
Zdenek Kabelac
b73de73151 thin: lvconvert support for external origin
Add basic support for converting LV into an external origin volume.

Syntax:

lvconvert --thinpool vg/pool  --originname renamed_origin -T origin

It will convert volume  'origin' into a thin volume, which will
use 'renamed_origin' as an external read-only origin.
All read/write into origin will go via 'pool'.

renamed_origin volume is read-only volume, that could be activated
only in read-only mode, and cannot be modified.
2013-02-23 10:38:20 +01:00
Zdenek Kabelac
386f3d5a5e thin: external origin cannot be changed
Do not allow conversion of external origin into writeable LV,
and prohibit changing the external origin size.

If the snapshot origin is also external origin, merge is prohibited.
2013-02-23 10:37:01 +01:00
Jonathan Brassow
3ab46449f4 vgimport: Allow '--force' to import VGs with missing PVs.
When there are missing PVs in a volume group, most operations that alter
the LVM metadata are disallowed.  It turns out that 'vgimport' is one of
those disallowed operations.  This is bad because it creates a circular
dependency.  'vgimport' will complain that the VG is inconsistent and that
'vgreduce --removemissing' must be run.  However, 'vgreduce' cannot be run
because it has not been imported.  Therefore, 'vgimport' must be one of
the operations allowed to change the metadata when PVs are missing.  The
'--force' option is the way to make 'vgimport' happen in spite of the
missing PVs.
2013-02-20 16:37:41 -06:00
Jonathan Brassow
70f57996b3 RAID: Add new 'raid10_segtype_default' setting in lvm.conf
If '--mirrors/-m' and '--stripes/-i' are used together when creating
a logical volume, mirrors-over-stripes is currently chosen.  The user
can override this by using the '--type raid10' option on creation.
However, we want a place where we can set the default behavior to
'raid10' explicitly - similar to the "mirror" and "raid1" tunable,
mirror_segtype_default.

A follow-on patch should use this new setting to change the default
from "mirror" to "raid10", as this is the preferred segment type.
2013-02-20 15:10:04 -06:00
Jonathan Brassow
845852d6b4 RAID: Make 'vgreduce --removemissing' work with RAID LVs
Currently it is impossible to remove a failed PV which has a RAID LV
on it.  This patch fixes the issue by replacing the failed PV with an
'error' segment within the affected sub-LVs.  Once there is no longer
a RAID LV using the PV, it can be removed.

Most often, it is better to replace a failed RAID device with a spare.
(You can use 'lvconvert --repair <vg>/<LV>' to accomplish that.)
However, if there are no spares in the volume group and none will be
added, it is useful to be able to removed the failed device.

Following patches address the ability to perform 'lvconvert' operations
on RAID LVs that contain sub-LVs composed of 'error' segments.
2013-02-20 14:52:46 -06:00
Jonathan Brassow
0e4ffd9d3b clean-up: Rename lvm.conf setting 'mirror_region_size' to 'raid_region_size'
We have been using 'mirror_region_size' in lvm.conf as the default region
size for RAID logical volumes as well as mirror logical volumes.  Since,
"raid" is more inclusive and representative than "mirror", I have changed
the name of this setting.  We must still check for the old setting and warn
the user if we are overriding it with the new setting if both happen to be
present.
2013-02-20 14:40:17 -06:00
Zdenek Kabelac
7910b6c0ba thin: update pool_is_active
Change it to take LV and move it to exported header - seems
to be a better fit for usability from tools/ directory.
2013-02-05 16:54:11 +01:00
Zdenek Kabelac
a5b9b4bf02 thin: fix forbidden discards checks
Instead of check for lv_is_active() for thin pool LV,
query the whole pool via new  pool_is_active().

Fixes a problem when we cannot change discards settings
for active pool device where the actual layer for pool
device was inactive, but thin volumes using thin pool
have been active.
2013-02-05 14:38:16 +01:00
Zdenek Kabelac
15115b61c0 lvconvert: update error path
Update the error path after problems with suspend_lv or vg_commit.
It's not exactly well defined what should happen, and this
code seems to appear in many different instancies<F2> in the
whole source code tree - we should probably pick the best version.
2013-02-05 14:31:34 +01:00
Zdenek Kabelac
be5ad90703 lvconvert: fix accepting second lv name
Do not allow to accept second LV name on lvconvert --thinpool
command line.
2013-02-05 14:31:17 +01:00
Zdenek Kabelac
7cd25062ac cleanup: avoid overflow warning
Even we do not expect to support chunks bigger then 2GB.
2013-02-05 14:27:25 +01:00
Zdenek Kabelac
d7ea12f222 cleanup: remove extra braces 2013-02-05 14:27:24 +01:00
Alasdair G Kergon
06abb2dd4c logging: classify log_debug messages
Place most log_debug() messages into a class.
2013-01-07 22:30:29 +00:00
Alasdair G Kergon
6d760b2c63 lvmetad: improve client logging when connecting
Rename lvmetad_warning() to lvmetad_connect_or_warn().

Log all connection attempts on the client side, whether successful or not.

Reduce some nesting and remove a redundant assertion.
2013-01-04 23:22:30 +00:00
Alasdair G Kergon
a527a3b8c2 lvmetad: lvm depends on libdaemonclient.a
Rebuild lvm binary if libdaemonclient.a changes.
2013-01-04 23:10:38 +00:00
Peter Rajnoha
ad85b0c526 pvscan: synchronize with udev if pvscan --cache is used.
We need to call sync_local_dev_names directly as pvscan uses
VG_GLOBAL lock and this one *does not* cause the synchronization
(sync_dev_names) to be called on unlock (VG_GLOBAL is not a real VG):

define unlock_vg(cmd, vol)
  do { \
    if (is_real_vg(vol)) \
      sync_dev_names(cmd); \
    (void) lock_vol(cmd, vol, LCK_VG_UNLOCK); \
  } while (0)

Without this fix, we end up without udev synchronization for the
pvscan --cache (mainly for -aay that causes the VGs/LVs to be
autoactivated) and also udev synchronization cookies are then left
in the system since they're not managed properly (code before sets
up udev sync cookies, but we have to call dm_udev_wait at least once
after that to do the wait and cleanup).
2012-12-21 11:15:46 +01:00
Jonathan Brassow
970dfbcd69 RAID: Limit replacement of devices when array is not in-sync.
If a RAID array is not in-sync, replacing devices should not be allowed
as a general rule.  This is because the contents used to populate the
incoming device may be undefined because the devices being read where
not in-sync.  The kernel enforces this rule unless overridden by not
allowing the creation of an array that is not in-sync and includes a
devices that needs to be rebuilt.

Since we cannot know the sync state of an LV if it is inactive, we must
also enforce the rule that an array must be active to replace devices.

That leaves us with the following conditions:
1) never allow replacement or repair of devices if the LV is in-active
2) never allow replacement if the LV is not in-sync
3) allow repair if the LV is not in-sync, but warn that contents may
   not be recoverable.

In the case where a user is performing the repair on the command line via
'lvconvert --repair', the warning is printed before the user is prompted
if they would like to replace the device(s).  If the repair is automated
(i.e. via dmeventd and policy is "allocate"), then the device is replaced
if possible and the warning is printed.
2012-12-18 14:40:42 -06:00
Zdenek Kabelac
0396ade38b cleanup: simplify option matching function
Avoid using sprintf and strncmp call, when
we really want to compare just one character.
2012-12-15 14:57:40 +01:00
Zdenek Kabelac
8b8065a870 cleanup: drop unused header
This header does not resolve any symbols here.
2012-12-15 14:57:40 +01:00
Zdenek Kabelac
03be45ac0a cleanup: convert to 32bit
Chunk sizes fits into 4G range, so keep it in 32bit range.
2012-12-15 14:57:39 +01:00
Peter Rajnoha
e8025aa67a lvconvert: also allow --type with --stripes
We can also use this for conversion between different mirror segment
types. Each new segment type converter then needs to check itself
whether the --stripes is applicable.
2012-12-13 11:19:11 +01:00
Petr Rockai
b19f840af8 toollib: Avoid a global lock in process_each_pv if lvmetad is used.
The motivation to grab the global lock is to avoid a scan and metadata parsing
for each PV, but the cost of obtaining metadata is _mostly_ mitigated by having
lvmetad around. Not taking the global lock improves throughput when multiple pvs
or related commands are running in parallel, like in RHEV.
2012-12-12 14:44:03 +01:00
Peter Rajnoha
e5709a32be lvmetad: fix compiler warning and add WHATS_NEW line for previous commit 2012-12-12 13:27:25 +01:00
Petr Rockai
f14f2d4378 lvmetad: Fix autoactivation for MDA-less PVs.
Calling pvscan --cache with -aay on a PV without an MDA would spuriously fail
with an internal error, because of an incorrect assumption that a parsed VG
structure was always available. This is not true and the autoactivation handler
needs to call vg_read to obtain metadata in cases where the PV had no MDAs to
parse. Therefore, we pass vgid into the handler instead of the (possibly NULL)
VG coming from the PV's MDA.
2012-12-12 13:19:04 +01:00
Peter Rajnoha
cad22be394 lvconvert: allow lvconvert --stripes/stripesize only with -mirrors/--repair/--thinpool
Also, update lvconvert man page to reflect this and make clear that
the --stripes/stripesize is applied to newly allocated space only.
2012-12-11 15:50:25 +01:00
Zdenek Kabelac
ed65860861 thin: remove detection for thin discard support
Remove no longer needed warning for unsuppoted discards
for non-power-2 lvcreate commands.

(Missed from the patch for the same update in lvchange made
by commit dde5a6c52b)
2012-12-11 11:24:45 +01:00
Peter Rajnoha
f942ae4a7a lvconvert: do not ignore -f in lvconvert --repair -y -f 2012-12-11 09:52:54 +01:00
Jonathan Brassow
3835755259 pvmove/RAID: Disallow pvmove on RAID LVs until properly handled
Attempting pvmove on RAID LVs replaces the kernel RAID target with
a temporary pvmove target, ultimately destroying the RAID LV.  pvmove
must be prevented on RAID LVs for now.

Use 'lvconvert --replace old_pv vg/lv new_pv' if you want to move
an image of the RAID LV.
2012-12-04 17:47:47 -06:00
Zdenek Kabelac
99018b37ee thin: lvconvert supports swapping metadata device
Support swapping of metadata device if the thin pool already
exists. This way it's easy to i.e. resize metadata or their
repair operation.

User may create some empty LV, replace existing metadata
or dump and restore them into bigger LV.
2012-12-02 18:01:27 +01:00
Zdenek Kabelac
ade2f47829 thin: deactivate subvolumes
Do not leave active thin data and metadata volumes
if activation of thin pool fails.
2012-12-02 17:56:44 +01:00
Zdenek Kabelac
dde5a6c52b thin: lvchange may change discards freely 2012-12-02 17:56:44 +01:00
Zdenek Kabelac
f0da2842cf thin: shuffle code
Reorder code lines for next patch.
2012-12-02 17:56:44 +01:00
Zdenek Kabelac
0be8a9126f thin: lvconvert update messages 2012-12-02 17:56:44 +01:00
Peter Rajnoha
fb8cc7c63f udev: do not verify udev operations for --noudevsync
If udev synchronization is disabled by means of --noudevsync
option, we should disable just the synchronization and nothing else.
The udev fallback (verifying udev operations and fixing the
nodes/symlinks if found incorrect) is orthogonal and controlled
by a separate activation/verify_udev_operations configuration option.
2012-11-29 13:59:12 +01:00
Zdenek Kabelac
09b7ceea95 thin: allow restore with --force
Allow restoring metadata with thin pool volumes.
No validation is done for this case within vgcfgrestore tool -
thus incorrect metadata may lead to destruction of pool content.
2012-11-27 14:08:24 +01:00
Zdenek Kabelac
c7a7fd0a12 thin: fix attrs for unloaded driver
If the driver is not loaded, set all 'features' ON
instead of all of them being OFF.
2012-11-27 11:29:47 +01:00
Zdenek Kabelac
1ef9831018 thin: support configurable thin pool defaults
Configurable settings for thin pool create
if they are not specified on command line.

New supported lvm.conf options are:
  allocation/thin_pool_chunk_size
  allocation/thin_pool_discards
  allocation/thin_pool_zero
2012-11-26 12:16:47 +01:00
Zdenek Kabelac
953080e4fc thin: add more unsupporte options for merge
Hmm, we need some smarter way to detect unsupported command
line options for various commands.
2012-11-26 12:15:32 +01:00
Jonathan Brassow
b3e9a09abe RAID: If no stripes argument is given for RAID10 create, default to 2
Similar to the way the 'mirror', 'raid1' and 'raid10' segment types set
the number of mirrors to 2 ('-m 1') if the argument is not specified,
here we set the number of stripes to 2 if not given on the command line
when creating a RAID10 LV.
2012-11-21 18:46:52 -06:00
Zdenek Kabelac
999952c5b9 thin: update recent patchset
Parse pool params only for creation of thin pools.
2012-11-19 16:28:00 +01:00
Zdenek Kabelac
1794f777f4 thin: lvcreate use common functions
Use common functions from toollib and eliminate code from here.
2012-11-19 14:38:17 +01:00
Zdenek Kabelac
b21d3e3592 thin: lvconvert update
Use common function from toollib and support allocation
of metadata LV with give thin pool data LV.
2012-11-19 14:38:17 +01:00
Zdenek Kabelac
b786096863 thin: add alloc_pool_metadata
Since our api call is not yet powerfull enough,
use this wrapper to preset options.
2012-11-19 14:38:17 +01:00
Zdenek Kabelac
f4137640f6 thin: add common pool functions
Move common functions for lvcreate and lvconvert.

get_pool_params() - read thin pool args.
update_pool_params() - updates/validates some thin args.

It is getting complicated and even few more things will be
implemented, so to avoid reimplementing things differently
in lvcreate and lvconvert  code has been splitted
into 2 common functions that allow some future extension.
2012-11-19 14:38:17 +01:00
Zdenek Kabelac
cf5242a670 lvconvert: store target attributes
Target tells us its version, and we may allow different set of options
to be supported with different version of driver.

Idea is to provide individual feature flags and later be
able to query for them.
2012-11-19 14:17:10 +01:00
Zdenek Kabelac
2c3bbf0a6c cleanup: move setting of parameter zero
Since we may need to use different default value,
move read of zero_ARG prior processing of parameters.
2012-11-19 14:15:43 +01:00
Jonathan Brassow
54c73b7723 mirror: Mirrored log should be fixed before mirror when double fault occurs
This patch is intended to fix bug 825323 - FS turns read-only during a double
fault of a mirror leg and mirrored log's leg at the same time.  It only
affects a 2-way mirror with a mirrored log.  3+-way mirrors and mirrors
without a mirrored log are not affected.

The problem resulted from the fact that the top level mirror was not
using 'noflush' when suspending before its "down-convert".  When a
mirror image fails, the bios are queue until a suspend is recieved.  If
it is a 'noflush' suspend, the bios can be safely requeued in the DM
core.  If 'noflush' is not used, the bios must be pushed through the
target and if a device is failed for a mirror, that means issuing an
error.  When an error is received by a file system, it results in it
turning read-only (depending on the FS).

Part of the problem was is due to the nature of the stacking involved in
using a mirror as a mirror's log.  When an image in each fail, the top
level mirror stalls because it is waiting for a log flush.  The other
stalls waiting for corrective action.  When the repair command is issued,
the entire stacked arrangement is collapsed to a linear LV.  The log
flush then fails (somewhat uncleanly) and the top-level mirror is suspended
without 'noflush' because it is a linear device.

This patch allows the log to be repaired first, which in turn allows the
top-level mirror's log flush to complete cleanly.  The top-level mirror
is then secondarily reduced to a linear device - at which time this mirror
is suspended properly with 'noflush'.
2012-11-14 14:58:47 -06:00
Peter Rajnoha
fc2644ae71 pvscan: exit --cache immediately if locking_type=3 || use_lvmetad=0 2012-11-09 15:56:57 +01:00
Zdenek Kabelac
5f5a5d1f53 lvchange: support --yes option for --persistent
Support using command: lvchange --yes --persistent
to skip y|n prompt.
2012-10-19 15:33:46 +02:00
Zdenek Kabelac
bc7d3b74f1 cleanup: fix typo in error message
yes -> yet
2012-10-19 15:32:27 +02:00
Zdenek Kabelac
c7c53ad41d pvcreate: fix leak on error path
Missing vg release on error path.
Add tests for few more error cases.
2012-10-19 15:32:21 +02:00
Zdenek Kabelac
f260f99d57 cleanup: switch log_error to log_warn
Use log_warn to print non-fatal warning messages.

Use of log_error would confuse checker for testing
whether proper error has been reported for some real error.
2012-10-17 15:41:35 +02:00
Zdenek Kabelac
b89963a7c3 cleanup: swap return values
Use lvm standard return code for success/fail  1/0.
2012-10-17 15:37:26 +02:00
Alasdair G Kergon
ea6a8078b4 release: prepare for release 2012-10-15 15:19:32 +01:00
Zdenek Kabelac
4573877186 lvchange: resync returns error on usupported volumes 2012-10-15 14:09:37 +02:00
Zdenek Kabelac
b3899056d9 thin: disable conversion of thin-pool to read-only
This change is not yet supported.
2012-10-15 14:09:11 +02:00
Zdenek Kabelac
2fc1fc3a93 thin: allow to create read-only thin-volumes
Useful for i.e. read-only thin snapshots.
2012-10-15 14:07:03 +02:00
Zdenek Kabelac
9bb210192d cleanup: readable test to check for 32bit overflow
also swap return value 0 - fail, 1 - success.
2012-10-14 23:19:27 +02:00
Zdenek Kabelac
16060b101b thin: lvextend will fail is autoextend is 0%
Since extending by 0% will not increase the size of pool,
return failure.
2012-10-14 23:17:30 +02:00
Zdenek Kabelac
31d8c3ee85 debug: do not play with fds with valgring
When valgrind usage is desired by user (--enable-valgrind-pool)
skip playing/closing/reopenning with descriptors - it makes
valgridng useless.

Make sleep delay for clvmd start longer.
2012-10-12 17:02:30 +02:00
Zdenek Kabelac
3058f662cf thin: prohibit lvcreate --thinpool with mirrors
Disable --thinpool to be used with mirror on lvcreate.
2012-10-12 12:21:45 +02:00
Petr Rockai
28776b9526 lvmetad: Make --sysinit suppress connection failure warnings. 2012-10-12 10:58:04 +02:00
Zdenek Kabelac
ca09c9ab4c thin: support non power of 2 chunk size
Support thin chunk size with multiple of 64KiB if user has
thin-pool target version at least 1.2.
2012-10-10 21:21:00 +02:00
Jonathan Brassow
3501f17fd0 [lv|vg]change: Allow limited metadata changes when PVs are missing
A while back, the behavior of LVM changed from allowing metadata changes
when PVs were missing to not allowing changes.  Until recently, this
change was tolerated by HA-LVM by forcing a 'vgreduce --removemissing'
before trying (again) to add tags to an LV and then activate it.  LVM
mirroring requires that failed devices are removed anyway, so this was
largely harmless.  However, RAID LVs do not require devices to be removed
from the array in order to be activated.  In fact, in an HA-LVM
environment this would be very undesirable.  Device failures in such an
environment can often be transient and it would be much better to restore
the device to the array than synchronize an entirely new device.

There are two methods that can be used to setup an HA-LVM environment:
"clvm" or "tagging".  For RAID LVs, "clvm" is out of the question because
RAID LVs are not supported in clustered VGs - not even in an exclusively
activated manner.  That leaves "tagging".  HA-LVM uses tagging - coupled
with 'volume_list' - to ensure that only one machine can have an LV active
at a time.  If updates are not allowed when a PV is missing, it is
impossible to add or remove tags to allow for activation.  This removes
one of the most basic functionalities of HA-LVM - site redundancy.  If
mirroring or RAID is used to replicate the storage in two data centers
and one of them goes down, a server and a storage device are lost.  When
the service fails-over to the alternate site, the VG will be "partial".
Unable to add a tag to the VG/LV, the RAID device will be unable to
activate.

The solution is to allow vgchange and lvchange to alter the LVM metadata
for a limited set of options - --[add|del]tag included.  The set of
allowable options are ones that do not cause changes to the DM kernel
target (like --resync would) or could alter the structure of the LV
(like allocation or conversion).
2012-10-10 11:33:10 -05:00
Peter Rajnoha
470d1a2f54 dmsetup: also apply 'mangle' command for UUIDs
Compared to names, UUIDs can't be renamed once they are created
for a device. The 'mangle' command will just issue an error message
about a need for manual intervention in this case - reactivating the
device (remove + create) does the job as the defualt mangling mode
used is "auto" and that will assign a correct mangled form the UUID.
2012-10-10 17:16:15 +02:00
Peter Rajnoha
788b7a6a2b dmsetup: add mangled/unmangled_uuid to for info -c
Following the same logic already used for name mangling.
2012-10-10 17:16:15 +02:00
Zdenek Kabelac
cdb7502e54 lvchange: do not start dmevent for resyn
If monitoring is disabled in lvm.conf, avoid its starting and preserve
DMEVENTD_MONITOR_IGNORE settings internally.
2012-10-09 12:22:26 +02:00
Zdenek Kabelac
5b07bd3f91 lvconvert: disable convertion of thin to mirrors
For now this convertions is not supported, thus disabled.
The only supported conversion for now is to create mirrored thin pools
from mirrored devices.
2012-10-08 12:16:53 +02:00
Zdenek Kabelac
a27650cc98 thin: lvconvert
Update code for lvconvert.
Change the lvconvert user interface a bit - now we require 2 specifiers
--thinpool   takes LV name for data device (and makes the name)
--poolmetadata  takes LV name for metadata device.

Fix type in thin help text -z -> -Z.

Supported is also new flag --discards for thinpools.
2012-10-03 15:13:33 +02:00
Zdenek Kabelac
e9f83147d5 thin: lvchange allows to change perms of thin snap
Thin snapshots are individual thin volumes so they can have its own
control for rw permissions.
2012-10-03 15:13:32 +02:00
Zdenek Kabelac
4648d33d07 cleanup: add proper cast for force_t 2012-10-03 15:06:17 +02:00
Zdenek Kabelac
739092e64a liblvm2cmd: ensure standard descriptors are ready
Check if FDs 0,1,2 are available, and in case they are missing,
use /dev/null for them.
2012-10-03 15:02:26 +02:00
Zdenek Kabelac
1f30e048bd liblvm2cmd: add return code for _close_stray_fds
Close fds via /proc/self/fd parsing
Return error code if _close_stray_fds fails and quit application
if system is in some nonstandard state.
2012-10-03 15:01:23 +02:00
Petr Rockai
3124840185 lvremove: Revert to allowing removal of partial LVs. 2012-09-26 17:26:23 +02:00
Petr Rockai
e7d3553906 lvmetad: Make vgscan --cache an alias to pvscan --cache. 2012-09-26 17:26:23 +02:00
Petr Rockai
ca0c8673b2 lib/cache/lvmetad: s/pvscan_lvmetad/lvmetad_pvscan/ in the API 2012-09-26 17:26:23 +02:00
Petr Rockai
c7b17836ea Implement devices/global_filter.
The global filter is applied first, and is also applied in pvscan --cache (which
is called from udev rules to keep lvmetad updated). Cf. example.conf.
2012-09-26 14:49:15 +02:00
Marian Csontos
17901569da cleanup: remove unused variable 2012-09-20 07:40:11 +02:00
Jonathan Brassow
2e04681248 mirror: 'lvconvert --resync' should reset LV_NOTSYNCED on corelog mirror
When reformatting the 'lvchange_resync' code in commit
05131f5853, a '!' should have been removed
from the condition that checks for the LV_NOTSYNCED flag on a corelog
mirror LV.  The presence of this '!' caused the LV_NOTSYNCED flag to be
cleared when it wasn't present and left when it was present.

It is not allowed to add images to a 'mirror' or 'raid1' LV if the
LV_NOTSYNCED flag is set.  We add some up-convert tests to ensure this
behavior is being enforced and that the LV_NOTSYNCED flag is being
properly cleared by 'lvchange --resync'.

(Not updating WHATS_NEW because this is intrarelease.)
2012-09-19 11:16:45 -05:00
Alasdair G Kergon
b737ff01e4 discards: skip when removing LVs on missing PVs
Don't try to issue discards to a missing PV to avoid segfault.
Prevent lvremove from removing LVs that have any part missing.

https://bugzilla.redhat.com/857554
2012-09-19 12:48:56 +01:00
Peter Rajnoha
3127160626 vgchange: fix -aay to activate proper volumes
Using 'activation/auto_activation_volume_list = [ "vg/lvol1" ]'.

Before this patch:
  3 logical volume(s) in volume group "vg" now active
  LV    VG   Attr     LSize Pool Origin Data%  Move Log Copy%  Convert
  lvol0 vg   -wi----- 4.00m
  lvol1 vg   -wi-a--- 4.00m
  lvol2 vg   -wi-a--- 4.00m
  lvol3 vg   -wi-a--- 4.00m

(vg/lvol1 activated as it passes the list and all subsequent volumes too - wrong!)

With this patch:
  1 logical volume(s) in volume group "vg" now active
  LV    VG   Attr     LSize Pool Origin Data%  Move Log Copy%  Convert
  lvol0 vg   -wi----- 4.00m
  lvol1 vg   -wi-a--- 4.00m
  lvol2 vg   -wi----- 4.00m
  lvol3 vg   -wi----- 4.00m

(only vg/lvol1 activated as it passes the list and no other - correct!)
2012-09-12 09:47:40 +02:00
Jonathan Brassow
4ededc698f RAID: Properly handle resync of RAID LVs
Issuing a 'lvchange --resync <VG>/<RAID_LV>' had no effect.  This is
because the code to handle RAID LVs was not present.  This patch adds
the code that will clear the metadata areas of RAID LVs - causing them
to resync upon activation.
2012-09-11 13:09:35 -05:00
Jonathan Brassow
a2d9b1a7e9 cleanup: Restructure code that handles mirror resyncing
When an LV is to be resynced, the metadata areas are cleared and the
LV is reactivated.  This is true for mirroring and will also be true
for RAID LVs.  We restructure the code in lvchange_resync() so that we
keep all the common steps necessary (validation of ability to resync,
deactivation, activation of meta/log devices, clearing of those devices,
etc) and place the code that will be divergent in separate functions:
	detach_metadata_devices()
	attach_metadata_devices()

The common steps will be processed on lists of metadata devices.  Before
RAID capability is added, this will simply be the mirror log device (if
found).

This patch lays the ground-work for adding resync of RAID LVs.
2012-09-11 13:01:05 -05:00
Jonathan Brassow
05131f5853 cleanup: Reduce indentation by short-circuiting function
By changing the conditional for resyncing mirrors with core-logs a
bit, we can short-circuit the rest of the function for that case
and reduce the amount of indenting in the rest of the function.

This cleanup will simplify future patches aimed at properly handling
the resync of RAID LVs.
2012-09-11 12:55:17 -05:00
Jonathan Brassow
c3eb3a7687 cleanup: Use segtype->ops->name() instead of segtype->name where applicable
When printing a message for the user and the lv_segment pointer is available,
use segtype->ops->name() instead of segtype->name.  This gives a better
user-readable name for the segment.  This is especially true for the
'striped' segment type, which prints "linear" if there is an area_count of
one.
2012-09-05 11:35:54 -05:00
Peter Rajnoha
c68c157573 setvbuf: reopen only valid fd
We should check whether the fd is opened before trying to reopen it.
For example, the stdin is closed in test/lib/harness.c causing the
test suite to fail.
2012-08-27 13:07:07 +02:00
Alasdair G Kergon
438e0050df config: add silent mode
Accept -q as the short form of --quiet.
Suppress non-essential standard output if -q is given twice.
Treat log/silent in lvm.conf as equivalent to -qq.
Review all log_print messages and change some to
log_print_unless_silent.

When silent, the following commands still produce output:
dumpconfig, lvdisplay, lvmdiskscan, lvs, pvck, pvdisplay,
pvs, version, vgcfgrestore -l, vgdisplay, vgs.
[Needs checking.]

Non-essential messages are shifted from log level 4 to log level 5
for syslog and lvm2_log_fn purposes.
2012-08-25 20:35:48 +01:00
Jonathan Brassow
4047e4dfb1 RAID: Add support for RAID10
This patch adds support for RAID10.  It is not the default at this
stage.  The user needs to specify '--type raid10' if they would like
RAID10 instead of stacked mirror over stripe.
2012-08-24 15:34:19 -05:00
Zdenek Kabelac
109b3bb49b thin: discard 2012-08-23 14:38:48 +02:00
Zdenek Kabelac
57c0f72b1d lvconvert: use _reload_lv on more places
Use common subroutine.
2012-08-23 14:38:45 +02:00
Zdenek Kabelac
4698fb0543 lvconvert: move _reload_lv()
Just move in front
2012-08-23 14:37:52 +02:00
Zdenek Kabelac
fd417db274 check: add internal errors for unexpected paths
Adding couple INTERNAL_ERROR reports for unwanted parameters:

Ensure the 'top' metadata node cannot be NULL for lvmetad.

Make obvious vginfo2 cannot be NULL.

Report internal error if handler and vg is undefined.

Check for handle in poll_vg().

Ensure seg is not NULL in dev_manager_transient().

Report missing read_ahead for _lv_read_ahead_single().

Check for report handler in dm_report_object().

Check missing VG in _vgreduce_single().
2012-08-23 14:37:52 +02:00
Zdenek Kabelac
195fe03075 cleanup: use proper activation_change_t 2012-08-23 14:37:38 +02:00
Zdenek Kabelac
90191e6ff2 cleanup: cast to matching type 2012-08-23 14:37:38 +02:00
Zdenek Kabelac
bd67a3151a cleanup: uint64_t casts 2012-08-23 14:37:21 +02:00
Zdenek Kabelac
ff86c6ed00 cleanup: keep MKNOD type cast clean
Setup major already a dev_t type before it gets shifted.
2012-08-23 14:37:21 +02:00
Zdenek Kabelac
286cd2006b cleanup: drop unneeded included header files
This headers were not resolving anything used for compiled .c files.
Remove unused util.c file.
2012-08-23 14:37:20 +02:00
Zdenek Kabelac
b1640df5e6 dmsetup: check if new_name is non NULL 2012-08-23 14:37:18 +02:00
Zdenek Kabelac
b9ae22d758 dmsetup: fix udev warning message
Configure option is --enable-udev_sync.
2012-08-23 14:36:12 +02:00
Zdenek Kabelac
7e318dad42 dmsetup: fix memleak in _get_split_name
Free allocated buffer in _get_split_name error path.
2012-08-23 14:36:10 +02:00
Zdenek Kabelac
54c24193f5 thin: lvcreate --discards 2012-08-09 16:25:52 +02:00
Jonathan Brassow
de3b1c4506 RAID: Improve RAID argument handling.
Disallow '-m' for RAID types that have no mirror component and disallow
'-i' argument for RAID types that have no stripe component.
2012-08-08 12:32:27 -05:00
Alasdair G Kergon
701b4a8363 thin: use discards as plural rather than singular
Global change from --discard to --discards, as that feels more natural.
2012-08-07 21:24:41 +01:00
Alasdair G Kergon
1ca813083f thin: tidy commands.h arg lists
args are listed alphabetically.
lvconvert -T is covered in the second section not the first.
It could be tidied further or split out.
2012-08-07 20:10:06 +01:00
Alasdair G Kergon
b51241a346 thin: mention discard/zero in lvchange errmsg 2012-08-07 20:08:14 +01:00
Peter Rajnoha
6e55201144 args: increase major:minor limit to 4095:1048575
Remove the limit for major and minor number arguments used while specifying
persistent numbers via -My --major <major> --minor <minor> option which
was set to 255 before. Follow the kernel limit instead which is 12 bits
for major and 20 bits for minor number (kernel >= 2.6 and LVM formats
that does not have FMT_RESTRICTED_LVIDS - so still keep the old limit
of 255 for lvm1 format).
2012-08-06 18:01:01 +02:00
Alasdair G Kergon
25ae0b39b7 dmsetup: allow --noflush with status/wait for thin
Allow --noflush with dmsetup status and wait (for thin target 1.3.0 /
ioctl 4.23.0).
2012-07-27 20:03:07 +01:00
Jonathan Brassow
186a2772e8 vgextend: Allow PVs to be added to VGs that have PVs missing
Allowing people to add devices to a VG that has PVs missing helps
people avoid the inability to repair RAID LVs in certain cases.
For example, if a user creates a RAID 4/5/6 LV using all of the
available devices in a VG, there will be no spare devices to
repair the LV with if a device should fail.  Further, because the
VG is missing a device, new devices cannot be added to allow the
repair.  If 'vgreduce --removemissing' were attempted, the
"MISSING" PV could not be removed without also destroying the RAID
LV.

Allowing vgextend to operate solves the circular dependency.

When the PV is added by a vgextend operation, the sequence number is
incremented and the 'MISSING' flag is put on the PVs which are missing.
2012-07-26 17:06:06 -05:00
Zdenek Kabelac
48367c5be9 thin: add lvchange for discard and zero change
Update lvchange to allow change of 'zero' flag for thinpool.
Add support for changing discard handling.

N.B.  from/to  ignore could be only changed for inactive pool.
2012-07-18 14:38:34 +02:00
Zdenek Kabelac
ebbf7d8e68 thin: add discard support for thin pool
Add arg support for discard.
Add discard ignore, nopassdown, passdown (=default) support.
Flags could be set per pool.

lvcreate [--discard {ignore|no_passdown|passdown}]  vg/thinlv
2012-07-18 14:36:57 +02:00
Peter Rajnoha
07e4ac7b00 lvconvert: count % upwards when merging a snapshot
Before:
  # lvconvert --merge -i 1 vg/lvol1
  Merging of volume lvol1 started.
  lvol0: Merged: 36.7%
  lvol0: Merged: 21.3%
  lvol0: Merged: 5.8%
  lvol0: Merged: 0.0%
  Merge of snapshot into logical volume lvol0 has finished.
  Logical volume "lvol1" successfully removed

After:
  # lvconvert --merge -i 1 vg/lvol1
  Merging of volume lvol1 started.
  lvol0: Merged: 61.4%
  lvol0: Merged: 73.0%
  lvol0: Merged: 88.4%
  lvol0: Merged: 100.0%
  Merge of snapshot into logical volume lvol0 has finished.
  Logical volume "lvol1" successfully removed
2012-07-10 15:30:18 +02:00
Peter Rajnoha
cd8ea8b437 activate: skip manual activation for --sysinit -aay
When --sysinit -a ay is used with vg/lvchange and lvmetad is up and running,
we should skip manual activation as that would be a useless step - all volumes
are autoactivated once all the PVs for a VG are present.

If lvmetad is not active at the time of the vgchange --sysinit -a ay
call, the activation proceeds in standard 'manual' way.

This way, we can still have vg/lvchange --sysinit -a ay called
unconditionally in system initialization scripts no matter if lvmetad
is used or not.
2012-07-10 14:01:33 +02:00
Jonathan Brassow
8767435ef8 RAID: Fix extending size of RAID 4/5/6 logical volumes.
Reducing a RAID 4/5/6 LV or extending it with a different number of
stripes is still not implemented.  This patch covers the "simple" case
where the LV is extended with the same number of stripes as the orginal.
2012-06-26 09:44:54 -05:00
Alasdair G Kergon
1d0a2b919f toollib: fix ignored_mdas process_each_pv rescan
In process_each_pv() if we haven't yet scanned and the PV appears
to be an orphan, we must scan the other PVs looking for mdas that
reference it to find out what VG it is in.

1. If the PV has no mdas, we must scan.
2. If the PV has an mda that is not ignored we do not need to scan.
3. If the PV has an mda that is ignored, we do need to scan.

This patch fixes case 3.

> pvs -o +mda_count,vg_mda_count /dev/loop[0123]
  PV         VG   Fmt  Attr PSize  PFree  #PMda #VMda
  /dev/loop0 vg3  lvm2 a-   96.00m 96.00m     0     1
  /dev/loop1 vg3  lvm2 a-   96.00m 96.00m     1     1
  /dev/loop2 vg2  lvm2 a-   96.00m 96.00m     1     2
  /dev/loop3 vg2  lvm2 a-   28.00m 28.00m     1     2

Before:
> pvs /dev/loop2 /dev/loop3 /dev/loop0 /dev/loop1 --unbuffered
  PV         VG   Fmt  Attr PSize   PFree
  /dev/loop2      lvm2 a--  100.00m 100.00m
  /dev/loop3 vg2  lvm2 a--   28.00m  28.00m
  /dev/loop0      lvm2 a--  100.00m 100.00m
  /dev/loop1 vg3  lvm2 a--   96.00m  96.00m

After:
> pvs /dev/loop2 /dev/loop3 /dev/loop0 /dev/loop1 --unbuffered
  PV         VG   Fmt  Attr PSize  PFree
  /dev/loop2 vg2  lvm2 a--  96.00m 96.00m
  /dev/loop3 vg2  lvm2 a--  28.00m 28.00m
  /dev/loop0 vg3  lvm2 a--  96.00m 96.00m
  /dev/loop1 vg3  lvm2 a--  96.00m 96.00m
2012-06-29 21:22:09 +01:00
Peter Rajnoha
a2f4ccd839 lvcreate: add --activate ay (autoactivate)
One can use "lvcreate --aay" to have the newly created volume
activated or not activated based on the activation/auto_activation_volume_list
this way.

Note: -Z/--zero is not compatible with -aay, zeroing is not used in this case!
When using lvcreate -aay, a default warning message is also issued that zeroing
is not done.
2012-06-28 09:44:07 -04:00
Peter Rajnoha
c9b9077b44 lvchange: add --activate ay (autoactivate)
The same as for vgchange...
2012-06-28 09:44:07 -04:00
Peter Rajnoha
d2df8dddc8 pvscan: add --activate ay option (autoactivate)
Define auto_activation_handler that activates VGs/LVs automatically
based on the activation/auto_activation_volume_list (activating all
volumes by default if the list is not defined).

The autoactivation is done within the pvscan call in 69-dm-lvmetad.rules
that watches for udev events (device appearance/removal).

For now, this works for non-clustered and complete VGs only.
2012-06-28 09:44:03 -04:00
Peter Rajnoha
215a314f19 vgchange: add --activate ay option (autoactivate)
Normally, the 'vgchange -ay' activates all volume groups (that pass
the activation/volume_list filter if set).

This call can appear in two scenarios:
 - system boot (so activation within a script in general)
 - manual call on command line (so activaton on user's direct request)

For the former one, we would like to select which VGs should be actually
activated. One can define the list of VGs directly to do that. But that
would require the same list to be provided in all the scripts.

The 'vgchange -aay' will check for the activation/auto_activation_volume_list
in adition and it will activate only those VGs/LVs that pass this
filter (assuming all to be activated if the list is not defined - the
same logic we already have for activation/volume_list).

Init/boot scripts should use this form of activation primarily
(which, anyway, becomes only a fallback now with autoactivation done
on PV appearance in tandem with lvmetad in place).
2012-06-28 09:42:48 -04:00
Peter Rajnoha
95ced7a7be activate: add autoactivation hooks
Define an 'activation_handler' that gets called automatically on
PV appearance/disappearance while processing the lvmetad_pv_found
and lvmetad_pv_gone functions that are supposed to update the
lvmetad state based on PV availability state. For now, the actual
support is for PV appearance only, leaving room for PV disappearance
support as well (which is a more complex problem to solve as this
needs to count with possible device stack).

Add a new activation change mode - CHANGE_AAY exposed as
'--activate ay/-aay' argument ('activate automatically').

Factor out the vgchange activation functionality for use in other
tools (like pvscan...).
2012-06-28 09:42:47 -04:00
Peter Rajnoha
2729720fd3 args: add --activate synonym for --available arg
We're refererring to 'activation' all over the code and we're talking
about 'LVs being activated' all the time so let's use 'activation/activate'
everywhere for clarity and consistency (still providing the old
'available' keyword as a synonym for backward compatibility with
existing environments).
2012-06-28 09:42:44 -04:00
Zdenek Kabelac
6bd3864b41 thin: fix lvconvert error path NULL dereference
For printing the name, use given command line parameter.
2012-06-22 13:50:21 +02:00
Zdenek Kabelac
6f3cd63551 cleanup: replace memset with struct initilization
Simplifies the code, properly detects too long socket paths,
drops unused parameter.
2012-06-22 13:23:03 +02:00
Zdenek Kabelac
ba222c6e35 cleanup: use struct initializers instead of memset
No need to call memset if we the language can do that.
2012-06-20 14:47:54 +02:00
Alasdair G Kergon
a2a37f8fee More .gitignore files for an in-source-tree build.
Tell git to ignore files generated by a build inside the source tree.
2012-06-08 16:34:43 +01:00
Alasdair G Kergon
d644d4e14e Add .gitignore files for an in-source-tree build.
Tell git to ignore files generated by a build inside the source tree.
2012-06-08 16:26:21 +01:00
Peter Rajnoha
06738cac05 Remove unsupported udev_get_dev_path libudev call used for checking udev dir.
With latest changes in the udev, some deprecated functions were removed
from libudev amongst which there was the "udev_get_dev_path" function
we used to compare a device directory used in udev and directore set in
libdevmapper. The "/dev" is hardcoded in udev now (udev version >= 183).

Amongst other changes and from packager's point of view, it's also
important to note that the libudev development library ("libudev-devel")
could now be a part of the systemd development library ("systemd-devel")
because of the udev + systemd merge.
2012-05-29 08:09:10 +00:00
Zdenek Kabelac
0a9f894ff0 Initial support for lvconvert for thin pool volumes.
Support has many limitations and lots of FIXMEs inside,
however it makes initial task when user creates a separate LV for
thin pool data and thin metadata already usable, so let's enable
it for testing.

Easiest API:

lvconvert --chunksize XX --thinpool data_lv  metadata_lv

More functionality extensions will follow up.

TODO: Code needs some rework since a lot of same code is getting copied.
2012-05-09 12:17:06 +00:00
Peter Rajnoha
d13f356bf5 Also rename DevNos header to DevNosUsed in dmsetup info -c output. 2012-04-24 08:24:36 +00:00
Peter Rajnoha
0be6c87a56 Rename (Blk)DevNames header to (Blk)DevNamesUsed in dmsetup info -c output.
Just to make it clearer since there is the "dmsetup info -c -o blkdevname"
as well that shows the "block device name for this mapping", having a
"BlkDevName" header on output.

It's a bit confusing then if the "dmsetup info -c -o devs_used,blkdevs_used"
is named with a plural "DevNames"/"BlkDevNames" but at the same time having
a totally different meaning than the singular form "BlkDevName".

  DevNames --> DevNamesUsed
  BlkDevNames --> BlkDevNamesUsed

...makes it much more comprehensible.
2012-04-24 08:00:55 +00:00
Jonathan Earl Brassow
1a53400723 Fix for bug 807776: invalid lvconvert --merge output should mention raid1 now
s/snapshot/mergeable volume/
2012-04-19 21:50:37 +00:00
Alasdair Kergon
e38e9e588e Remove 'up' from rounding message that sometimes rounds down.
Detect reduction of 0 after rounding for stripes and avoid warning of potential data loss.
2012-04-12 15:11:21 +00:00
Alasdair Kergon
1c1487659e spacing 2012-04-11 12:49:10 +00:00
Zdenek Kabelac
5dc27b75eb Fix lvresize for thin pool
When resizing thin pool - we need to use strip info from  _tdata volume.
In future more generic solution will be necessary once we start to support
lvconvert (resize of stacked devices and stay properly aligned).
For now we just allow striped or linear LV so this code will work.
2012-04-11 12:40:03 +00:00
Zdenek Kabelac
6fc1f948c2 Lvresize rounds upward
When given lvresize new size - round upward for stripes - unless we use % and
we are at the border of free extents.

This patch is not a complete fix and few more cases will need special care.
2012-04-11 12:36:37 +00:00
Zdenek Kabelac
c6f3701a71 Support rounding downward for lvcreate and %
If specifying size with % and we are reaching number
of free extents - round downward with stripes.
2012-04-11 12:33:34 +00:00
Zdenek Kabelac
9bdff1ee5c Move check for min strip size
and remove few asigns that are not needed.
2012-04-11 12:30:48 +00:00
Zdenek Kabelac
6e826bb6a4 Fix unlocking in error path of vgreduce
When vg_read fails, it internally unlocks VG if it's been locked,
so in error path we should skip unlock_vg for this case.
(user would see ugly internal warning)
2012-03-30 14:59:35 +00:00
Peter Rajnoha
543eaed88c Detect VG name being part of the LV name in lvconvert --splitmirrors -n.
Before:
devel/~ # lvconvert --splitmirrors 1 -n vg/splitted_one vg/mirrored_one
  Internal error: LV name vg/splitted_one has invalid form.
  Intermediate VG metadata write failed.

After:
devel/~ # lvconvert --splitmirrors 1 -n vg/splitted_one vg/mirrored_one
  Logical volume mirrored_one converted.

devel/~ # lvconvert --splitmirrors 1 -n abc/splitted_one vg/mirrored_one
  Please use a single volume group name ("vg" or "abc")
  Run `lvconvert --help' for more information.
2012-03-30 08:58:02 +00:00
Milan Broz
be36c0ec49 Fail early if cmirror is not detected and pvmove requires it. 2012-03-27 12:01:22 +00:00
Milan Broz
3d5d5196d0 Also skip pvmove for remotely active LVs. 2012-03-27 11:43:32 +00:00
Peter Rajnoha
3be9089cd3 Add 'vgscan --cache' functionality for consistency with 'pvscan --cache'.
Calling vgscan alone should reuse information from the lvmetad (if running).
The --cache option should initiate direct device scan and update lvmetad
appropriately (if running).

This is mainly for vgscan to behave consistently compared to pvscan.
2012-03-27 11:04:46 +00:00
Milan Broz
ddb31b62e5 Keep exclusive activation in pvmove if LV is already active.
Pvmove should never try to downgrade exclusive lock
for LVs.

This allows pvmove to work again for exclusive activated LVs.
2012-03-26 20:33:40 +00:00
Milan Broz
dcd90bc501 Do not allow pvmove if some affected LVs are activated
locally or on more nodes while others are activated exclusively.

Current pvmove code can either use local mirror (for exclusive
activation) or cmirror (for clustered LVs).

Because the whole intenal pvmove LV is just segmented LV containing
segments of several top-level LVs, code cannot properly handle
situation if some segment need to be activated exclusively.

Previously, it wrongly activated exclusive LV on all nodes
(locing code allowed it) but now this is no lnger possible.

If there is exclusively activated LV, pvmove is only
possible if all affected LVs are aslo activated exclusively.

(Note that in non-exclusive mode pvmove still activates LVs
on other nodes during move.)

# lvchange -aly vg_test/lv1
# lvchange -aey vg_test/lv2
# pvmove -i 1 /dev/sdc
   Error locking on node bar-01: Device or resource busy
   Error locking on node bar-03: Volume is busy on another node
...
   Failed to activate lv2
2012-03-26 20:32:58 +00:00
Milan Broz
3366541aab Use new flag PVMOVE_EXCLUSIVE in update_metatada call.
There is no real functional change in this patch except it
avoids checking cluster cmirror module twice.

(Flag used in following patch.)
2012-03-26 20:31:01 +00:00
Zdenek Kabelac
2caa558e7c Update and fix monitoring of thin pool devices
Code adds better support for monitoring of thin pool devices.
update_pool_lv uses DMEVENTD_MONITOR_IGNORE to not manipulate with monitoring.
vgchange & lvchange are checking real thin pool device for existance
as we are using   _tpool  real device and visible LV pool device might not
be even active (_tpool is activated implicitely for any thin volume).
monitor_dev_for_events is another _lv_postorder like code it might be worth
to think about reusing it here - for now update the code to properly
monitory thin volume deps.
For unmonitoring add extra code to check the usage of thin pool - in case it's in use
unmonitoring of thin volume is skipped.
2012-03-23 09:58:04 +00:00
Petr Rockai
7720ed7037 Fix a regression in handling --major/--minor arguments to lvcreate & lvchange,
by allowing arg_int_value to be used with groupable options.
2012-03-16 10:43:52 +00:00
Alasdair Kergon
bba1e4d11f Fix error message when pvmove LV activation fails with name already in use. 2012-03-13 20:21:26 +00:00
Zdenek Kabelac
f6632c1ef4 Fix error path for create_toolcontext
Never return unfinished toolcontext - since error path is hit on
various stages of initialization we cannot leave it partially uninitialized,
since we would need to spread many more test across the code for config_valid.
Instead return NULL and properly release udev library resources as well.
2012-03-12 14:15:04 +00:00
Zdenek Kabelac
34a45b0029 Fix warn message and update man page
Fix regression in man page. The chunk size is in kilobyte units on command line
input though in the source code we work with sector size unit
so make it clear in the man page.

Update chunksize for thin pool in man page - it's max value is 1024M == 1G.

Fix warning range message to show proper max value.
2012-03-06 09:22:02 +00:00
Alasdair Kergon
fa25bdc3ef close ] 2012-03-06 03:11:13 +00:00
Alasdair Kergon
ea44a7d759 Adjust wording 2012-03-06 02:42:31 +00:00
Alasdair Kergon
b343d75a5a Switch pvscan --cache major:minor to --major --minor. 2012-03-06 02:30:49 +00:00
Zdenek Kabelac
aeaec150c0 Some more missing supposedly 64bit operations.
Avoid use 32bit math for extent_size.
2012-03-05 15:05:24 +00:00
Zdenek Kabelac
90423c1200 Fit thin pool metadata into 128MB
If the lvcreate may decide some automagical values for a user,
try to keep the pool metadata size into 128MB range for optimal
perfomance (as suggested by Joe).

So if the pool metadata size and chunk_size were not specified,
try to select such values they would fit into 128MB size.
2012-03-05 14:19:13 +00:00
Peter Rajnoha
ba428469e6 Check for multiple mangled names in auto mangling mode.
Auto mode can't deal with multiple mangled names. We can do that while working
in hex mode, but in auto mode, this would lead to device name ambiguity.
2012-03-05 12:48:12 +00:00
Zdenek Kabelac
98c92abf4e Add FIXMEs
Processing loop needs some thinking
2012-03-04 15:58:31 +00:00
Alasdair Kergon
35216ca66c Scan all devices for lvmetad if 'pvscan --cache' used without device list. 2012-03-03 18:32:53 +00:00
Alasdair Kergon
59a5361fc4 Obtain VG list from lvmetad before relying on get_vgs, otherwise PVs in VGs
don't appear.
2012-03-03 17:12:21 +00:00
Alasdair Kergon
113f2a0113 Reinstate accidentally-deleted line. 2012-03-03 17:03:20 +00:00
Zdenek Kabelac
79c42c6600 Merge metadata size checking
Move the code for poolmetadatasize operation into one place.
Report override for minimum and maximum size.
Drop _read_thin_params function its error reporting is handled elsewhere.
2012-03-02 20:18:25 +00:00
Alasdair Kergon
d742cdf327 Change pvscan --lvmetad to pvscan --cache. 2012-03-02 18:09:46 +00:00
Zdenek Kabelac
1babf24949 Fix estimation of pool metadata device size
If no size was give the later added minimal size check efectively
disable this code. Also the argument for size now must be kept
in sector_size, so adding division by SECTOR_SIZE (moved into
a const expression)
2012-03-02 17:25:21 +00:00
Alasdair Kergon
d06f64dd29 Allow multiple device names with pvscan --lvmetad.
Hold global lock in pvscan --lvmetad.  (This might need refinement.)
Add PV name to "PV gone" messages.
Adjust some log message severities.  (More changes needed.)
2012-03-02 16:58:41 +00:00
Alasdair Kergon
b804340f01 Reinstate error if e.g. daemon comms fails. 2012-03-02 02:55:45 +00:00
Zdenek Kabelac
6ddce3b6a7 Check for error from dup2
Do not take correct fd as error result.
2012-03-01 23:20:45 +00:00
Zdenek Kabelac
d2ebc1dfa0 Add some more pointer validation
Ensure _display_name() and _add_dep() would not deref NULL names.
Switch to use internal dm_basename().
2012-03-01 21:56:44 +00:00
Zdenek Kabelac
52f76a7682 Test alloc fail 2012-03-01 21:49:32 +00:00
Zdenek Kabelac
0ab5e0e280 Replace goto with just log_debug
FIXME: temporal quick hack to make things green
There might be a better reaction.
2012-03-01 21:46:31 +00:00
Zdenek Kabelac
1281a5e3d5 Check for alloc error
Simplify segtype_str usage and check for NULL segtype.
2012-03-01 21:21:54 +00:00
Zdenek Kabelac
bead3fc2c0 Log sys errors 2012-03-01 21:17:29 +00:00
Zdenek Kabelac
de3692152f Backtrace for failing drop_cached_metadata 2012-03-01 21:16:44 +00:00
Zdenek Kabelac
f3c177312f Correct enum type
Using debug_t and some forgetten alloc_policy_t, force_t from past commit.
2012-03-01 21:14:43 +00:00
Zdenek Kabelac
c452307543 Few more close and dev_close trace
Adding (void) where we cannot really report an error.
2012-03-01 21:12:37 +00:00
Alasdair Kergon
7126d8c21b Reflect new file locations, include file updates etc. 2012-02-28 18:35:04 +00:00
Alasdair Kergon
dc9ef7a028 Check return values after calling new lvmetad fns
(Haven't checked error path handling though)
2012-02-28 18:08:08 +00:00
Zdenek Kabelac
fbf6b89a84 Using enum types for enums
alloc_policy_t, dm_string_mangling_t, percent_range_t, sign_t
2012-02-28 14:24:57 +00:00
Zdenek Kabelac
6f8bd07b40 Duplicate standard in/out descriptors for daemon
Addressing somewhat tricky bug here.
Since stdin,stdout,stderr were closed it's been occasionally possible to
see some unexpected messages to be flowing into a clvmd and generating some
randomly sized allocation of many megabytes. Since the message was not
being generated by standard send_message() construction, after some more
testing it apperead to be a debug log message - thus something has flown
to local socket opened on strandard out descriptor.

To fix the issue - use standard file descriptor duplication code for daemons.

For making easier debugging of polling daemon - developer might want to recompile
without modifition of standard file descriptors.
2012-02-28 10:06:53 +00:00
Zdenek Kabelac
8918bf2430 Add some log_sys_errors to close() call 2012-02-27 11:28:47 +00:00