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

3900 Commits

Author SHA1 Message Date
Jonathan Brassow
d34d2068dd lvconvert: Don't require a 'force' option during RAID repair.
Previously, we were treating non-RAID to RAID up-converts as a "resync"
operation.  (The most common example being 'linear -> RAID1'.)  RAID to
RAID up-converts or rebuilds of specific RAID images are properly treated
as a "recover" operation.

Since we were treating some up-convert operations as "resync", it was
possible to have scenarios where data corruption or data loss were
possibilities if the RAID hadn't been able to sync completely before a
loss of the primary source devices.  In order to ensure that the user took
the proper precautions in such scenarios, we required a '--force' option
to be present.  Unfortuneately, the force option was rendered useless
because there was no way to distiguish the failure state of a potentially
destructive repair from a nominal one - making the '--force' option a
requirement for any RAID1 repair!

We now treat non-RAID to RAID up-converts properly as "recover" operations.
This eliminates the scenarios that can potentially cause data loss or
data corruption; and this eliminates the need for the '--force' requirement.
This patch removes the requirement to specify '--force' for RAID repairs.
2017-06-14 08:39:07 -05:00
Jonathan Brassow
c87907dcd5 lvconvert: linear -> raid1 upconvert should cause "recover" not "resync"
Two of the sync actions performed by the kernel (aka MD runtime) are
"resync" and "recover".  The "resync" refers to when an entirely new array
is going through the process of initializing (or resynchronizing after an
unexpected shutdown).  The "recover" is the process of initializing a new
member device to the array.  So, a brand new array with all new devices
will undergo "resync".  An array with replaced or added sub-LVs will undergo
"recover".

These two states are treated very differently when failures happen.  If any
device is lost or replaced while "resync", there are no worries.  This is
because any writes created from the inception of the array have occurred to
all the devices and can be safely recovered.  Even though non-initialized
portions will still be resync'ed with uninitialized data, it is ok.  However,
if a pre-existing device is lost (aka, the original linear device in a
linear -> raid1 convert) during a "recover", data loss can be the result.
Thus, writes are errored by the kernel and recovery is halted.  The failed
device must be restored or removed.  This is the correct behavior.

Unfortunately, we were treating an up-convert from linear as a "resync"
when we should have been treating it as a "recover".  This patch
removes the special case for linear upconvert.  It allows each new image
sub-LV to be marked with a rebuild flag and treats the array as 'in-sync'.
This has the correct effect of causing the upconvert to be treated as a
"recover" rather than a "resync".  There is no need to flag these two states
differently in LVM metadata, because they are already considered differently
by the kernel RAID metadata.  (Any activation/deactivation will properly
resume the "recover" process and not a "resync" process.)

We make this behavior change based on the presense of dm-raid target
version 1.9.0+.
2017-06-14 08:35:22 -05:00
Zdenek Kabelac
b3ef051e06 cache: lvcreate --cachepool checks for cache pool
Code path missed validation of lvcreate --cachepool argument.
If the non cache-pool LV was passed in, code has still continued
further work and failed later on internal error.  Validate this
condition at right place now.
2017-06-09 10:59:37 +02:00
Zdenek Kabelac
48ffb996c5 thin: disallow creation of too big thin pools
When a combination of thin-pool chunk size and thin-pool data size
goes beyond addressable limit, such volume creation is directly
prohibited.

Maximum usable thin-pool size is calculated with use of maximal support
metadata size (even when it's created smaller) and given chunk-size.
If the value data size is found to be too big, the command reports
error and operation fails.

Previously thin-pool was created however lots of thin-pool data LV was
not usable and this space in VG has been wasted.
2017-06-08 11:58:36 +02:00
David Teigland
c98a25aab1 print warning about in-use orphans
Warn about a PV that has the in-use flag set, but appears in
the orphan VG (no VG was found referencing it.)

There are a number of conditions that could lead to this:

. The PV was created with no mdas and is used in a VG with
  other PVs (with metadata) that have not yet appeared on
  the system.  So, no VG metadata is found by lvm which
  references the in-use PV with no mdas.

. vgremove could have failed after clearing mdas but
  before clearing the in-use flag.  In this case, the
  in-use flag needs to be manually cleared on the PV.

. The PV may have damanged/unrecognized VG metadata
  that lvm could not read.

. The PV may have no mdas, and the PVs with the metadata
  may have damaged/unrecognized metadata.
2017-06-01 11:18:42 -05:00
David Teigland
f3c90e90f8 disable repairing in-use flag on orphan PVs
A PV holding VG metadata that lvm can't understand
(e.g. damaged, checksum error, unrecognized flag)
will appear as an in-use orphan, and will be cleared
by this repair code.  Disable this repair until the
code can keep track of these problematic PVs, and
distinguish them from actual in-use orphans.
2017-06-01 09:53:14 -05:00
Zdenek Kabelac
4141409eb0 flags: add segtype flag support
Switch METADATA_FORMAT flag usage to be stored via segtype
instead of 'status' flag which appeared to cause major
incompatibility troubles.

For backward compatiblity segtype flags are still accepted also
via 'status' bits which were used from version 2.02.169 so metadata
saved by this newer lvm2 version should still work nicely, although
new save version will no longer work on this older lvm2 version.
2017-05-29 14:52:56 +02:00
Zdenek Kabelac
0299a7af1e flags: add read and print of segtype flag
Allow storing LV status bits with segment type name field.
Switching to this since this field has better support for compatibility
with older version of lvm2 - since such unknown segtype will not cause
complete invisiblity of metadata from older lvm2 code - just the
particular LV will become unusable with unknown type of segment.
2017-05-29 14:49:41 +02:00
Zdenek Kabelac
1fe4f80e45 fsadm: avoid hidden --yes
When 'fsadm' was running without terminal (i.e. pipe), it's been
automatically working like in '--yes'.

Detect terminal and only accept empty "" input in this mode.
2017-05-23 14:02:41 +02:00
Zdenek Kabelac
9e04e0483f fsadm: enhance detection of already mounted volumes
Add more validation to catch mainly renamed devices, where
filesystem utils are not able to handle devices properly,
as they are not addressed by major:minor by rather via some
symbolic path names which can change over time via rename operation.
2017-05-22 15:11:21 +02:00
Heinz Mauelshagen
5fe07d3574 lvconvert: enhance automatic settings of possible (raid) LV types
Offer possible interim LV types and display their aliases
(e.g. raid5 and raid5_ls) for all conversions between
striped and any raid LVs in case user requests a type
not suitable to direct conversion.

E.g. running "lvconvert --type raid5 LV" on a striped
LV will replace raid5 aka raid5_ls (rotating parity)
with raid5_n (dedicated parity on last image).
User is asked to repeat the lvconvert command to get to the
requested LV type (raid5 aka raid5_ls in this example)
when such replacement occurs.

Resolves: rhbz1439403
2017-05-18 00:18:15 +02:00
David Teigland
5406191cb9 lvchange: allow changing properties on thin pool data lv
Add an exception to not allowing lvchange to change properties
on hidden LVs.  When a thin pool data LV is a cache LV, we
need to allow changing cache properties on the tdata sublv of
the thin pool.
2017-05-15 10:59:48 -05:00
Alasdair G Kergon
cf73f6cf61 lvcreate: Fix mirror percentage size calculations.
Trap cases where the percentage calculation currently leads to an empty
LV and the message:

  Internal error: Unable to create new logical volume with no extents

Additionally convert the calculated number of extents from physical to
logical when creating a mirror using a percentage that is based on
Physical Extents.  Otherwise a command like 'lvcreate -m3 -l80%FREE'
can never leave any free space.

This brings the behaviour closer to that of lvresize.
(A further patch is needed to cover all the raid types.)
2017-05-12 02:31:35 +01:00
Alasdair G Kergon
80900dcf76 metadata: Fix metadata repair when devs still missing.
_check_reappeared_pv() incorrectly clears the MISSING_PV flags of
PVs with unknown devices.
While one caller avoids passing such PVs into the function, the other
doesn't.  Move the check inside the function so it's not forgotten.

Without this patch, if the normal VG reading code tries to repair
inconsistent metadata while there is an unknown PV, it incorrectly
considers the missing PVs no longer to be missing and produces
incorrect 'pvs' output omitting the missing PV, for example.

Easy reproducer:
Create a VG with 3 PVs pv1, pv2, pv3.
Hide pv2.
Run vgreduce --removemissing.
Reinstate the hidden PV pv2 and at the same time hide a different PV
pv3.
Run 'pvs' - incorrect output.
Run 'pvs' again - correct output.

See https://bugzilla.redhat.com/1434054
2017-05-11 02:17:34 +01:00
Zdenek Kabelac
1107d483a2 fsadm: fix test of subshell return value
Subshell is not returning error code value upward thus
error results in this case were actually ignored.
Also add dots to moved error messages.
2017-05-10 15:40:29 +02:00
David Teigland
97d5e192fe WHATS_NEW: cache pool options 2017-05-05 10:02:54 -05:00
Alasdair G Kergon
a946327bb7 post-release 2017-05-03 11:26:58 +01:00
Alasdair G Kergon
fb4bf1f4ea pre-release 2017-05-03 11:23:31 +01:00
David Teigland
54726a4950 fix running commands from a script file
Using any arg with a command name in a script file
would cause the command to fail.

The name of the script file being executed was being passed
to lvm_register_commands() and define_commands(), which
prevented command defs from being defined (simple commands
were still being defined only by name which was enough for those
to still work when run trivially with no args).
2017-04-28 16:51:04 -05:00
David Teigland
c73b9f062c WHATS_NEW: pvcreate prompt 2017-04-28 09:06:41 -05:00
Alasdair G Kergon
1764524b06 WHATS_NEW: pvcreate --setphysicalvolumesize 2017-04-28 14:34:26 +01:00
Heinz Mauelshagen
0516447978 lvconvert: preserve region size on raid1 image count changes (v2)
Unless a change of the regionsize is requested via "lvconvert -R N ...",
keep the region size when the number of images changes in a raid1 LV.

Related: rhbz1443705
2017-04-27 15:52:25 +02:00
Heinz Mauelshagen
af47ec9f51 Revert "lvconvert: preserve region size on raid1 image count changes"
This reverts commit 8333d5a969.
2017-04-27 15:29:03 +02:00
Alasdair G Kergon
cbc69f8c69 pvresize: Prompt when non-default size supplied.
Seek confirmation before changing the PV size to one that differs
from the underlying block device.
2017-04-27 02:36:34 +01:00
Heinz Mauelshagen
8333d5a969 lvconvert: preserve region size on raid1 image count changes
Unless a change of the regionsize is requested via "lvconvert -R N ...",
keep the region size when the number of images changes in a raid1 LV.

Resolves: rhbz1443705
2017-04-22 02:04:49 +02:00
Alasdair G Kergon
658d524d26 configure: Fix notify-dbus and dmfilemapd options. 2017-04-18 20:37:53 +01:00
David Teigland
2d9097e9ca WHATS_NEW: configure option enable-lvmlockd 2017-04-18 12:58:18 -05:00
Heinz Mauelshagen
b81b4aad24 WHATS_NEW: raise region_size default 2017-04-13 17:49:58 +02:00
Alasdair G Kergon
4547218a7d conf: Add missing prefix to installation directory.
Our Makefiles also support systems that set the installation prefix
at configuration time - the use of DESTDIR is not required.
2017-04-13 02:17:27 +01:00
Alasdair G Kergon
ae7f696d53 post-release 2017-04-13 01:47:47 +01:00
Alasdair G Kergon
b9a16fe73b pre-release 2017-04-13 00:43:31 +01:00
Zdenek Kabelac
3018cdcaa7 fsadm: support configurable full path
Just like with other tools lvm2 is using allow to define
fully configurable path.

Default is selected by $PREFIX/sbin/fsadm
2017-04-12 21:34:08 +02:00
Zdenek Kabelac
1095322901 thin: properly check for status for max sizes metadata
When metadata LV size was over DM_THIN_MAX_METADATA_SIZE sectors,
the info() routine was incorrectly trying to match bigger size,
while we do never pass any bigger device.

Fixing a case, where lvs should be displaying status for metadata
LV with 16GB size.
2017-04-12 21:34:08 +02:00
David Teigland
4b121a1f6f WHATS_NEW: add items since last release 2017-04-12 13:45:37 -05:00
Heinz Mauelshagen
19e6c338d3 WHATS_NEW: add recent RAID entries 2017-04-12 19:41:55 +02:00
Peter Rajnoha
448bf9491a lvmconf: fix systemd unit existence check for lvmconf --services --startstopservices
We have to unset the LoadState variable from previous use when we check
for systemd unit state. We use this variable to check if systemd services
are loaded or not and if it is loaded, we issue systemctl commands to
enable/disable and start/stop the service. We don't issue these commands
if the unit is not loaded to avoid error messages which may confuse users.
2017-04-05 11:06:56 +02:00
Zdenek Kabelac
dfdd6ccf3b vgrename: use long enough buffer for path
Use PATH_MAX when creating buffers for rename.
2017-03-30 00:38:41 +02:00
Alasdair G Kergon
0c2f7ed49a post-release 2017-03-28 16:14:03 +01:00
Alasdair G Kergon
396377bc03 pre-release
Removing some unused new lines and changing some incorrect "can't
release until this is fixed" comments.  Rename license.txt to make
it clear its merely an included file, not itself a licence.
2017-03-28 16:11:35 +01:00
Heinz Mauelshagen
e9433a9de9 WHATS_NEW: man-generator escape '-' 2017-03-24 14:31:19 +01:00
Alasdair G Kergon
e8362b4cb7 tools: Show configuration command line in lvm version.
Also update configure.in with some items recently added to the tree.
2017-03-23 01:01:35 +00:00
Heinz Mauelshagen
1810162b51 WHATS_NEW: adjust to misordered raid parameters 2017-03-21 18:18:58 +01:00
Heinz Mauelshagen
6ebf39da91 WHATS_NEW: conditionally reject raid convert 2017-03-17 14:51:10 +01:00
Heinz Mauelshagen
4a3e30d102 WHATS_NEW: ensure raid6 upconversion restrictions 2017-03-16 22:33:08 +01:00
Heinz Mauelshagen
b917b12e2c WHATS_NEW: adjust mirror+raid DSOs to lvconvert --repair 2017-03-16 22:27:30 +01:00
David Teigland
c8719d4e94 WHATS_NEW: disable lvmetad for repair 2017-03-16 11:56:19 -05:00
Alasdair G Kergon
4f86519845 lvmchange: Move to a built-in command.
Has been obsolete since LVM1 and it's clear we'll never implement this.
2017-03-16 01:09:29 +00:00
Zdenek Kabelac
52935b5834 cache: enhance lvdisplay for cache volumes
Better support for lvdisplay.
By default info about running (in kernel) cache status is printed.
To get 'segtype' info, user runs: 'lvdisplay -m',  example:

  --- Logical volume ---
  LV Path                /dev/vg/lvol0
  LV Name                lvol0
  VG Name                vg
  LV UUID                Y4uWuN-TBGk-duer-aPWl-yBWn-iFFR-RU1gg1
  LV Write Access        read/write
  LV Creation host, time linux, 2017-03-01 20:52:39 +0100
  LV Cache pool name     lvol2
  LV Cache origin name   lvol0_corig
  LV Status              available
  # open                 0
  LV Size                12,00 MiB
  Cache used blocks      10,42%
  Cache metadata blocks  0,49%
  Cache dirty blocks     0,00%
  Cache read hits/misses 112 / 34
  Cache wrt hits/misses  133 / 0
  Cache demotions        0
  Cache promotions       20
  Current LE             3
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:0

  --- Segments ---
  Logical extents 0 to 2:
    Type		cache
    Chunk size		64,00 KiB
    Metadata format	1
    Mode		writethrough
    Policy		smq
      Setting		migration_threshold=100000
2017-03-10 19:33:01 +01:00
Zdenek Kabelac
4d2b1a0660 cache: enable usage of --cachemetadataformat
lvcreate and lvconvert may select cache metadata format when caching LV.
By default lvm2 picks best available format.
2017-03-10 19:33:01 +01:00
Zdenek Kabelac
518b814cdb cache: LV supports cache segs with metadata format
Cache pool read/writes metadata_format within its segment type..

For CachePoolLV unselected metadata format is NOT stored in metadata.

For CacheLV when metadata format is not present/selected in lvm2 metadata,
it's automatically assumed to be the version 1 (backward compatible).

To ensure older lvm2 will not 'miss-read' metadata with new version 2,
such LV is marked with METADATA_FORMAT status flag (segment is
specifying metadata format). So when cache uses metadata format 2,
it will become inaccesible on older system without such support.
(kernel dm cache < 1.10,  lvm2 < 2.02.169).
2017-03-10 19:33:01 +01:00