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

4651 Commits

Author SHA1 Message Date
David Teigland
634bf8c953 lockd: fix rescanning VG metadata
One host changes a VG, making the cached VG on another
host invalid.  The other host then rereads the VG from
disk to get the latest copy.  If the first host removed
a PV from the VG, the second host attempts to reread the
VG from old PV when rescanning.  Reading the VG from the
removed PV fails, causing vg_read to return "VG not found".
The fix is to simply not fail when a VG is not found while
rereading a PV and continue without it.

(This doesn't happen if the second host happens to first
run a command like 'vgs' that triggers a global revalidation
of metadata.)
2015-09-29 11:28:48 -05:00
Heinz Mauelshagen
be393f6722 raid: Introduce DEFAULT_RAID_MAX_IMAGES
Prepare to allow for the number of images in a raid set to be
larger than the limit for old-style dm raid1.
2015-09-28 21:38:40 +01:00
Alasdair G Kergon
d94ff20927 raid: Fail if kernel status denominator is zero. 2015-09-28 20:45:44 +01:00
Heinz Mauelshagen
9d815e5f5a raid: Use loop for text uint32_t parameter import.
Plus some other tidying up of the same file.
2015-09-28 14:28:03 +01:00
Heinz Mauelshagen
eab099b221 segtypes: Use flags in raid segtype macros. 2015-09-24 20:43:18 +01:00
Heinz Mauelshagen
3036620b48 raid: Add a segtype flag for each raid type. 2015-09-24 20:17:57 +01:00
David Teigland
d40830a2b1 lockd: fix changing lock type on VG with pool
vgchange --lock-type iterates through LVs to ensure
no LVs are active before changing the lock type of
the VG, but the loop was not checking that an LV
actually has a lock before trying it, so it would
fail if the VG had any LVs that don't use locks,
e.g it would fail on a tmeta LV from a pool.
2015-09-24 14:03:20 -05:00
Heinz Mauelshagen
028715b0f0 raid: Detect whether or not kernel supports raid0. 2015-09-24 19:59:29 +01:00
Alasdair G Kergon
4a74e19f80 alloc: Move _calc_area_multiple. 2015-09-24 17:56:19 +01:00
Alasdair G Kergon
e773e71910 stripes: Introduce _round_to_stripe_boundary. 2015-09-24 17:50:53 +01:00
Alasdair G Kergon
39a97d86f0 segtypes: Add and use new segtype macros.
Includes fixing an inverted raid10 segtype check in _raid_add_target_line.
2015-09-24 14:59:07 +01:00
Alasdair G Kergon
41fe225b0d style: lv_manip.c changes 2015-09-24 13:43:58 +01:00
Heinz Mauelshagen
192d9ad977 style: Miscellaneous tidying up of metadata/lv* 2015-09-23 14:37:52 +01:00
Alasdair G Kergon
28aff5d240 segtypes: Make constants ULL. 2015-09-22 21:10:46 +01:00
Alasdair G Kergon
214e2cddf6 segtypes: Use SEG_TYPE_NAME_ string constants. 2015-09-22 19:04:12 +01:00
Heinz Mauelshagen
0ce150280e segtypes: Extend flags to 64 bits. 2015-09-22 18:03:33 +01:00
Peter Rajnoha
2081071bee wiping: warn if use_blkid_wiping=1 is set and LVM not compiled with blkid_wiping support 2015-09-22 11:11:26 +02:00
Alasdair G Kergon
ce80d73684 lvmcache: Remove verbose msg when rescanning dev. 2015-09-21 19:51:15 +01:00
Peter Rajnoha
a54b4bba35 report: add lv_convert_lv_uuid field 2015-09-21 14:22:23 +02:00
Peter Rajnoha
0a01c5aa36 report: add lv_move_pv_uuid field 2015-09-21 14:22:03 +02:00
Peter Rajnoha
f01b7afa19 pv: add 'mem' arg for pv_uuid_dup and pv_name_dup 2015-09-21 14:21:42 +02:00
Peter Rajnoha
ffa7b37b28 report: add lv_mirror_log_uuid field 2015-09-21 14:21:39 +02:00
Peter Rajnoha
f61a394be4 report: add lv_data_lv_uuid field 2015-09-21 14:21:21 +02:00
Peter Rajnoha
c2ea5b3dee report: add lv_metadata_lv_uuid field 2015-09-21 14:20:58 +02:00
Peter Rajnoha
199697accf report: add lv_origin_uuid field 2015-09-21 14:20:36 +02:00
Peter Rajnoha
cb8f29d147 report: add lv_pool_lv_uuid field 2015-09-21 14:20:12 +02:00
Peter Rajnoha
0e3042f488 lv: add 'mem' arg for lv_uuid_dup 2015-09-21 12:25:31 +02:00
Peter Rajnoha
f644431346 cleanup: report: reuse existing _uuid_disp fn to report pv_uuid field 2015-09-21 12:13:01 +02:00
Heinz Mauelshagen
90ad817a43 uuid: Report invalid character. 2015-09-18 14:19:32 +01:00
Peter Rajnoha
fcfca57e2e format-text: label: fix missing dev assignment for struct label in _text_pv_write
When using lvm shell, some structures which are cached in memory may be
reused. This happens for the struct label (a part of lvmcache_info
structure) when lvmetad is used in which case the PV scan is not
done that would normally overwrite these label structures in memory
and making them up-to-date.

This is all consequence of the fact that struct lvmcache_info and
struct label are not always assigned in the same part of the code.
For example, if lvmetad *is not* used, parts of the struct label are
reassigned in label_read fn while struct lvmcache_info is created
elsewhere. No part of the code reused struct label (and its "dev"
field) before calling label_read fn. That's why the real bug is
hidden when using lvm shell without lvmetad.

However, with lvmetad and lvm shell, the situation is a bit different.
The label_read fn is not called if lvmetad *is* used, hence the
struct label may have ended up not initialized properly.

There was missing assignment for the dev field in struct label
in _text_pv_write fn which caused this problem to appear in
lvm shell with lvmetad, for example:

Before this patch:

lvm> pvcreate /dev/sda
  Physical volume "/dev/sda" successfully created
lvm> pvs /dev/sda
  PV             VG     Fmt  Attr PSize   PFree
  unknown device        lvm2 ---  128.00m 128.00m

With this patch applied:

lvm> pvcreate /dev/sda
  Physical volume "/dev/sda" successfully created
lvm> pvs /dev/sda
  PV         VG   Fmt  Attr PSize   PFree
  /dev/sda        lvm2 ---  128.00m 128.00m

Also, this problem had not appeared before changes introduced
by commits e1a63905d1 through
3a6f91d713 which, among other
things, added proper label field type reporting. Before, label
reporting was the same as using struct physical_volume which
has its own dev field assigned and so this problem was not exposed.
2015-09-15 18:07:32 +02:00
David Teigland
2ce8ee0214 vgcreate: initialize new PVs only in first vg_write
When a command does a sequence of
vg_write + vg_commit + vg_write + vg_commit,

initialization of non-PV devices happens during the
first vg_write, and does not need to be repeated by
the second vg_write.

When creating a lockd VG, this sequence occurs because
the VG is first created, then the lockd data is created,
then the lockd data is then written to the VG metadata.
2015-09-14 13:22:22 -05:00
Zdenek Kabelac
ffeeb5c1e7 thin: show message on error path
Add missing log_error and show proper reason for failure
when autoextend is set to 0.

Add missing log_error when checked LV is not locally active.
2015-09-14 20:18:54 +02:00
Zdenek Kabelac
729b035edd pool: validate pool_metadata has proper suffix 2015-09-11 21:52:27 +02:00
David Teigland
6bc3d72a65 lvmlockd: prevent vgremove of dlm VG while lockspace is used
This applies the same rule/logic to dlm VGs that has always
existed for sanlock VGs.  Allowing a dlm VG to be removed
while its lockspace was still running on other hosts largely
worked, but there were difficult problems if another VG with
the same name was recreated.  Forcing the VG lockspace to
be stopped, gives both sanlock and dlm VGs the same behavior.
2015-09-11 14:12:13 -05:00
David Teigland
0a26c20b88 lockd: fix rescanning VG metadata
The code was expecting the wrong return value from
compare_config, which returns 0 when equal.

This is a problem for a lockd VG using multiple PVs
when the VG needs to be rescanned.
2015-09-11 13:10:48 -05:00
Zdenek Kabelac
5911fa1d91 cache: warn if caching causes troubles
Certain stacks of cached LVs may have unexpected consequences.
So add a warning function called when LV is cached to detect
such caces and WARN user about them - the best we could do ATM.
2015-09-10 17:27:30 +02:00
Zdenek Kabelac
e1edb5676e lib: when moving segtypes, move LV bits
When we insert layer we also move status flag-bits for certain LV types,
so internal volume_group structure remains consistent.
(Perhaps it's misuse of 'insert_layer' function and we should have
another similar function for this.)

Basically we aim to maintain the same state as after reading fresh
metadata out of volume group.

Currently we when i.e. cache  'raid' LV - this should transfer 'raidLV' flag
to  _corigin LV and cache is no longer a raid.

TODO: bits for stacked devices needs more exact rules.
2015-09-10 17:25:28 +02:00
David Teigland
36d16fed1f lockd: add start_init arg to lockd_start_vg
Add a new arg to lockd_start_vg() that indicates
it is being called for a new lockd VG, so that
lvmlockd knows the lockspace being started is new.
(Will be used by a following commit.)
2015-09-10 09:47:26 -05:00
Zdenek Kabelac
8ff43c3705 makefiles: ensure no old .h are left
Ensure make clean  cleans any left-over file from their previous
location so they are not in conflict with new ones.

Also hide error message when .commands file is not present.
2015-09-08 15:41:33 +02:00
Peter Rajnoha
b77497cbd8 filters: make sure regex filter is evaluated before any filter that needs disk access
The regex filter (controlled by devices/filter lvm.conf setting) was
evaluated as the very last filter. However, this is not optimal when
it comes to restricting disk access - users define devices/filter
as well as devices/global_filter to avoid this.

The devices/global_filter is already positioned at the beginning of the
filter chain. We need to do the same for devices/filter.

Filter chains before this patch:

  A: when lvmetad is not used:
       persistent_filter -> sysfs_filter -> global_regex_filter ->
       type_filter -> usable->filter -> mpath_component_filter ->
       partition_filter -> md_component_filter -> fw_raid_filter ->
       regex_filter

  B: when lvmetad is used:

    B1: to update lvmetad:
      sysfs_filter -> global_regex_filter -> type_filter ->
      usable_filter -> mpath_component_filter -> partition_filter ->
      md_component_filter -> fw_raid_filter

    B2: to retrieve info from lvmetad:
      persistent_filter -> usable_filter -> regex_filter

From the chain list above we can see that particularly in case when
lvmetad is not used, the regex filter is the very last one that is
processed. If lvmetad is used, it doesn't matter much as there's
the global_regex_filter which is used instead when updating lvmetad
and when retrieving info from lvmetad, putting regex_filter in front
of usable_filter wouldn't change much since usabled_filter is not
reading disks directly.

This patch puts the regex filter to the front even in case lvmetad
is not used, hence reinstating the state as it was before commit
a7be3b12df (which moved the regex_filter
position in the chain). Still, the arguments for the commit
a7be3b12df still apply and they're
still satisfied since component filters (MD, mpath...) are evaluated
first just before updating lvmetad.

So with this patch, we end up with:

  A: when lvmetad is not used:
       persistent_filter -> sysfs_filter -> global_regex_filter ->
       regex_filter -> type_filter -> usable->filter ->
       mpath_component_filter -> partition_filter ->
       md_component_filter -> fw_raid_filter

  B: when lvmetad is used:

    B1: to update lvmetad:
      sysfs_filter -> global_regex_filter -> type_filter ->
      usable_filter -> mpath_component_filter -> partition_filter ->
      md_component_filter -> fw_raid_filter

    B2: to retrieve info from lvmetad:
      persistent_filter -> regex_filter -> usable_filter

This way, specifying the regex_filter in non-lvmetad case causes
the devices to be filtered based on regex first before processing
any other filters which can access disks (like md_component_filter).

This patch also streamlines the code for better readability.
2015-09-08 15:28:10 +02:00
Zdenek Kabelac
ffbf12504d cleanup: assign seg_name once 2015-09-07 17:44:08 +02:00
Zdenek Kabelac
9403edbb93 configure: relocate generated headers
Relocate generated configure.h and lvm-version.h outside
of compilable .c source tree.

The reason is behind - when compiling in builddir != srcdir
the generated file in lib/misc/configure.h was used for all compiled
source file except ones located in lib/misc dir - those would have used
configure.h file located in this dir - if there have existed one (i.e.
from some other build)

This problem was only visible, when srcdir == buildir was used before
trying to use  srcdri != builddir  (as configure.h appeared then in
srcdir).
2015-09-07 17:40:58 +02:00
Alasdair G Kergon
fb12308416 style: Standardise some error paths. 2015-09-05 23:56:30 +01:00
Peter Rajnoha
55c13f3de4 dev-cache: fix use of uninitialized device status if reading outdated .cache record
As part of fix that came with cf700151eb,
I forgot to add the check whether the result of stat was successful or
not. This bug caused uninitialized buffer to be used for entries
from .cache file which are no longer valid.

This bug may have caused these uninitialized values to be used further,
for example (see the unreal (2567,590944) representing major:minor
pair):

$ pvs
  /dev/abc: stat failed: No such file or directory
  Path /dev/abc no longer valid for device(2567,590944)
  PV               VG   Fmt  Attr PSize   PFree
  /dev/mapper/test      lvm2 ---  104.00m 104.00m
  /dev/vda2        rhel lvm2 a--    9.51g      0
2015-09-04 18:00:29 +02:00
David Teigland
9e8b3d4a98 lockd: check for unlock failure in all cases
This suppresses an unwanted error message.
2015-09-03 16:47:54 -05:00
Zdenek Kabelac
ee8200f1c6 cleanup: use just 2 decimal digits 2015-09-03 23:34:37 +02:00
Zdenek Kabelac
32d6ca9196 cleanup: show error message
Add error message on error path.
2015-09-03 23:34:36 +02:00
Zdenek Kabelac
872ea3b987 thin: do not flush when quering for thin percent
Since we may easily get blocked when checking for percentage
of thin-pool - do not flush and just show current values.
This avoids holding VG locked when pool is overfilled.
2015-09-03 23:34:36 +02:00
Zdenek Kabelac
df110bccbe thin: validate mapped size of thin volume
Never show we map more then 100% for a volume.
But show warning when there could be some consistency problems.
2015-09-03 23:34:36 +02:00
Zdenek Kabelac
a01eb9c451 thin: detect unusable thins
Try to detect thin-pool which my block lvm2 command from furher
processing (i.e. lvextend).

Check if pool is read-only or out-of-space and in this case thins
will skipped from being scanned (so user may miss some PVs located
on thin volumes).
2015-09-03 23:34:36 +02:00