1
0
mirror of git://sourceware.org/git/lvm2.git synced 2025-01-11 09:18:25 +03:00
Commit Graph

6191 Commits

Author SHA1 Message Date
Zdenek Kabelac
721a172edf cov: avoid recursive self-inclusion
Include: toolcontext.h -> dev-type.h -> label.h -> toolcontext.h
Replace with struct predeclaration.
2019-07-06 01:24:28 +02:00
Zdenek Kabelac
23478d9d21 cov: release iterator on error path
Another missed release on error path.
2019-07-06 01:24:28 +02:00
Zdenek Kabelac
b0e1019add gcc: clean uninitialized var warning
Some older gcc versions shows this (FP) warning:
label/label.c:360: warning: â€sector’ may be used uninitialized in this function
2019-07-06 01:24:28 +02:00
Zdenek Kabelac
9aedf68c32 gcc: cleanup warning of shawhing a global dclr
misc/lvm-globals.c:76: warning: declaration of â€use_aio’ shadows a global declaration
misc/lvm-globals.h:63: warning: shadowed declaration is here
2019-07-06 01:24:28 +02:00
Zdenek Kabelac
b62c0787de cov: remove unused headers 2019-06-25 17:34:56 +02:00
Zdenek Kabelac
7232458b6c cov: validate pagesize is not negative
As _init_free_list() cannot accept negative numbers
2019-06-25 17:33:47 +02:00
Zdenek Kabelac
8bea252a63 cov: clearer condition check
Make the code more obvious.
2019-06-25 17:33:47 +02:00
Zdenek Kabelac
66665f5e42 cov: add stack tracing for error paths
Add missing stack reports on error paths.
2019-06-25 17:33:25 +02:00
Zdenek Kabelac
2cd6cd3439 cov: check lv_info
Use lv_info results only when valid.
2019-06-25 17:32:44 +02:00
Zdenek Kabelac
82e7426028 cov: check result of dev_get_block_size 2019-06-25 17:32:44 +02:00
Zdenek Kabelac
862899cc88 cov: check result of dev_read_bytes 2019-06-25 17:32:44 +02:00
Zdenek Kabelac
09aafb61e3 cov: release iterator on error path 2019-06-25 17:32:44 +02:00
Zdenek Kabelac
d6bce03615 mirror: fix monitoring change
Commit a8921be641 was supposedly a fix
for unwanted table reload - however before final commit, the tiny
change has been made that was believed to be an enhancment
of original prepared patch. Unfortunatelly the function
locking_is_clustered is not meant to be an equivalent test
of original function.  Drop this change and using
original patch.
2019-06-19 13:33:53 +02:00
David Teigland
c31e6b0aca lvmcache: remove unused_duplicate_devs list from cmd
Save the previous duplicate PVs in a global list instead
of a list on the cmd struct.  dmeventd reuses the cmd struct
for multiple commands, and the list entries between commands
were being freed (apparently), causing a segfault in dmeventd
when it tried to use items in cmd->unused_duplicate_devs
that had been saved there by the previous command.
2019-06-06 14:12:19 -05:00
Zdenek Kabelac
adf9bf80a3 cache: support no_discard_passdown
Recent kernel version from kernel commit:
de7180ff908b2bc0342e832dbdaa9a5f1ecaa33a
started to report in cache status line new flag:
no_discard_passdown

Whenever lvm spots unknown status it reports:
Unknown feature in status:

So add reconginzing this feature flag and also report this with

'lvs -o+kernel_discards'

When no_discard_passdown is found in status 'nopassdown' gets reported
for this field  (roughly matching what we report for thin-pools).
2019-06-05 15:54:58 +02:00
David Teigland
3669c33af4 lvmlockd: do not allow mirror LV to be activated shared
This reverts 518a8e8cfb
  "lvmlockd: activate mirror LVs in shared mode with cmirrord"

because while activating a mirror LV with cmirrord worked,
changes to the active cmirror did not work.
2019-05-21 15:06:37 -05:00
Zdenek Kabelac
a8921be641 monitoring: fix monitoring change for cluster
Fix bug in table reload for clustered VG.
Function used in lv/vgchange --monitor y|n is using 'somewhat' hackish
shortcut and accesses activation function monitor_dev_for_events()
directly rather through full device refresh to avoid table reload
in case user want to only change monitoring state of device.
However since with old 'mirrors' there is table change dropping
handle_error there was in some cases needed table update.

This was put into monitor_dev_for_events() with assumption
vg_write_lock_held() could be used to decide if the actual monitoring
change comes from read-only lock-holding commands lvchange/vgchange.
However the clustered locking part (clvmd) actually doesn't differentiate
about this concept of having VG openned in read-only or write mode.
So it caused unwanted reloads of mirror tables even in commands like lvconvert.

Thus for clustered locking there is full table reload put into the code and
shortcut applies only for non-clustered locking.

Also the patch tries to avoid calling repeated LV refresh in case the
lv/vgchange uses  --refresh & --monitor.
2019-05-06 15:57:52 +02:00
Zdenek Kabelac
e79e092f8b lv_manip: better work with PERCENT_VG modifier
When using 'lvcreate -l100%VG' and there is big disproportion between
real available space and requested setting - automatically fallback
to 100%FREE.

Difference can be seen when VG is big and already most space was
allocated, so the requestion 100%VG can end (and by spec for % modifier
it's correct) as LV with size of 1%VG.  Usually this is not a big
problem - buit in some cases - like cache-pool allocation, this
can result a big difference for chunksize selection.

With this patch it's more closely match common-sense logic without
the need of reitteration of too big changes in lvm2 core ATM.

TODO: in the future there should be allocator solving all allocations
in a single call.
2019-04-30 12:24:53 +02:00
Zdenek Kabelac
4729b4af0b thin: select chunk size as power of 2
Whenever thin-pool chunk size is unspecified and left for lvm calculation
try to select the size as nearest highest power-of-2 instead of
just being a multiple of 64KiB. When multiple is bigger then 1MiB,
keep using 1MiB multiple.
2019-04-30 12:11:50 +02:00
Zdenek Kabelac
f3be66c002 lv_manip: insert remove layer skips pools
Fixing renaming of subLVs when removing and inserting layers - this
got visible when using stacked VDO pools.
2019-04-30 12:08:36 +02:00
Zdenek Kabelac
2047d405af activation: synchronize before removing devices
Udev is running udev-rule action upon 'resume'.

However lvm2 in special case is doing replacement of
'soon-to-be-removed' device with 'error' target for resuming
and then follows actual removal - the sequence is usually quick,
so when udev start action - it can result in 'strange' error
message in kernel log like:

Process '/usr/sbin/dmsetup info -j 253 -m 17 -c --nameprefixes --noheadings --rows -o name,uuid,suspended' failed with exit code 1.

To avoid this - we need to ensure there is synchronization wait for udev
between 'resume'  and 'remove' part of this process.

However existing code put strict requirement to avoid synchronizing with
udev inside critical section - but this originally came from requirement
to not do anything special while there could be devices in
suspend-state. Now we are able to see differnce between critical section
with or without suspended devices.  For udev synchronization only
suspended devices are prohibited to be there - so slightly relax
condition and allow calling and using 'fs_sync()' even inside critical
section - but there must not be any suspended device.
2019-04-30 12:07:42 +02:00
Zdenek Kabelac
f38cfd09c4 thin: fix maintenance of _pmspare
When metadata grows lvm2 may need to extend also _pmspare volume.
2019-04-30 12:02:49 +02:00
Zdenek Kabelac
515867bbad thin: resize metadata with data
When data are growing, adapt also size of metadata.
As we get way too many reports from users doing huge growths of
data portion while keep metadata small and avoiding using monitoring.

So to enhance the user-experience in case user requests grown of
thin-pool (without passing PV list for growth) - lvm2 will automaticaly
grown also the metadata part of thin-pool (if possible).
2019-04-30 12:02:49 +02:00
Zdenek Kabelac
bcf1aa99e6 thin: introduce estimate_thin_pool_metadata_size
Add function for estimation of thin-pool metadata size for given size of
data. Function is using already existing internal API so it can
be reused for resize of thin-pool data.
2019-04-30 12:02:49 +02:00
David Teigland
559cf0cd1e devices: drop open error message
This open error is being printed in more common,
non-error circumstances than expected.  After a
number of complaints make it only a debug message.
2019-04-23 09:42:25 -05:00
Marian Csontos
f5d1f4f086 Wiping require exclusive actvation
The master branch uses activate_lv only, but on the stable branch
activate_lv_excl_local was used. This patch restores the constraints.

Fix regression from bad cherry pick: 9b04851fc5
2019-04-16 08:26:34 +02:00
Zdenek Kabelac
6064b9f1b2 gcc: cleanup const warning 2019-04-10 13:30:34 +02:00
Marian Csontos
b79f1e176f bcache: Fix memory leak 2019-04-04 10:19:15 +02:00
Heinz Mauelshagen
9b04851fc5 raid: fix (de)activation of RaidLVs with visible SubLVs
There's a small window during creation of a new RaidLV when
rmeta SubLVs are made visible to wipe them in order to prevent
erroneous discovery of stale RAID metadata.  In case a crash
prevents the SubLVs from being committed hidden after such
wiping, the RaidLV can still be activated with the SubLVs visible.
During deactivation though, a deadlock occurs because the visible
SubLVs are deactivated before the RaidLV.

The patch adds _check_raid_sublvs to the raid validation in merge.c,
an activation check to activate.c (paranoid, because the merge.c check
will prevent activation in case of visible SubLVs) and shares the
existing wiping function _clear_lvs in raid_manip.c moved to lv_manip.c
and renamed to activate_and_wipe_lvlist to remove code duplication.
Whilst on it, introduce activate_and_wipe_lv to share with
(lvconvert|lvchange).c.

Resolves: rhbz1633167
(cherry picked from commit dd5716ddf2)

Conflicts:
	WHATS_NEW
	lib/activate/activate.c
	lib/metadata/lv_manip.c
	lib/metadata/raid_manip.c
	tools/lvchange.c
	tools/lvconvert.c
2019-03-21 08:05:23 +01:00
David Teigland
dcf8f3111a pvscan: lvmetad init should set updating before scanning
When pvscan needs to initialize lvmetad (e.g. lvmetad has just
started and is empty), it should set the lvmetad state to "updating"
before it scans any devices.  Otherwise, many parallel pvscans
will try to initialize lvmetad, and in some cases earlier pvscans
with fewer devices information may replace newer pvscans with
more recent information.
2019-03-07 11:07:27 -06:00
David Teigland
ece0b131e5 config: improve scan_lvs description 2019-03-06 13:38:33 -06:00
Zdenek Kabelac
e974f6866a cleanup: move cast to det_t into MKDEV macro
(cherry picked from commit aa8b2d6a0f)

Conflicts:
	daemons/clvmd/clvmd-common.h
	device_mapper/ioctl/libdm-iface.c
	device_mapper/libdm-common.c
	device_mapper/libdm-deptree.c
2019-03-05 12:39:17 +01:00
Zdenek Kabelac
a93699ece9 cov: remove unused assigns
(cherry picked from commit 70e3d0a613)

Conflicts:
	tools/pvscan.c
	tools/vgchange.c
2019-03-05 12:28:31 +01:00
David Teigland
590a1ebcf7 io: increase the default io memory from 4 to 8 MiB
This is the default bcache size that is created at the
start of the command.  It needs to be large enough to
hold a single copy of metadata for a given VG, or the
VG cannot be read or written (since the entire VG would
not fit into available memory.)

Increasing the default reduces the chances of anyone
needing to increase the default to use their VG.

The size can be set in lvm.conf global/io_memory_size;
the lower limit is 4 MiB and the upper limit is 128 MiB.
2019-03-04 11:18:34 -06:00
David Teigland
863a2e693e io: warn when metadata size approaches io memory size
When a single copy of metadata gets within 1MB of the
current io_memory_size value, begin printing a warning
that the io_memory_size should be increased.
2019-03-04 10:57:52 -06:00
David Teigland
8dbfdb5b73 config: add new setting io_memory_size
which defines the amount of memory that lvm will allocate
for bcache.  Increasing this setting is required if it is
smaller than a single copy of VG metadata.
2019-03-04 10:31:47 -06:00
David Teigland
427e8ba3e3 config: change scan_lvs default to 0
so that lvm does not scan LVs for PVs by default.
2019-02-20 14:31:03 -06:00
David Teigland
6a5575e959 filter: add config setting to skip scanning LVs
devices/scan_lvs (default 1) determines whether lvm
will scan LVs for layered PVs.  The lvm behavior has
always been to scan LVs, but it's rare for LVs to have
layered PVs, and much more common for there to be many
LVs that substantially slow down scanning with no benefit.

This is implemented in the usable filter, and has the
same effect as listing all LVs in the global_filter.
2019-02-20 14:30:24 -06:00
David Teigland
57cde6063f apply obtain_device_list_from_udev to all libudev usage
udev_dev_is_md_component and udev_dev_is_mpath_component
are not used for obtaining the device list, but they still
use libudev for device info.  When there are problems with
udev, these functions can get stuck. So, use the existing
obtain_device_list_from_udev config setting to also control
whether these "is component" functions are used, which gives
us a way to avoid using libudev entirely when it's causing
problems.
2019-02-05 10:20:24 -06:00
David Teigland
d0cb672466 lvmlockd: fix make lockstart wait
when building without lvmlockd
2019-01-31 09:56:29 -06:00
David Teigland
75886f59e4 lvmlockd: make lockstart wait for existing start
If there are two independent scripts doing:
  vgchange --lockstart vg
  lvchange -ay vg/lv

The first vgchange to do the lockstart will wait for
the lockstart to complete before returning.
The second vgchange to do the lockstart will see that
the start is already in progress (from the first) and
will do nothing.  This means the second does not wait
for any lockstart to complete, and moves on to the
lvchange which may find the lockspace still starting
and fail.

To fix this, make the vgchange lockstart command
wait for any lockstart's in progress to complete.
2019-01-31 09:38:50 -06:00
Ming-Hung Tsai
df0797db8c lvmanip: uninitialized members in struct pv_list (#10)
Scenario: Given an existed LV `lvol0`, I want to create another LV
on the PVs used by `lvol0`.

I use `build_parallel_areas_from_lv()` to obtain the `pv_list` of each segments.
However, the returned `pv_list` is not properly initialized, which causes
segfault in subsequent operations.

(cherry picked from commit 859feb81e5)
(cherry picked from commit 219ba4f54a)

Conflicts:
	WHATS_NEW
2018-12-19 09:18:25 +01:00
David Teigland
a188b1e513 pvscan lvmetad: use udev info to improve md component detection
When no md devs are started, pvscan will only scan the start of
an md component, and if it has a superblock at the end may not
exclude it.  udev may already have info identifying it as an
md component, so use that.
2018-12-03 11:05:35 -06:00
David Teigland
9764ee0b3f lvmetad: fix disabling in previous commit
it broke the case where a connection already exists.
2018-11-30 15:49:03 -06:00
David Teigland
322d4ed05e lvmetad: only disable if repair will do something
lvconvert --repair would disable lvmetad at the start of
the command.  This would leave lvmetad disabled even if the
command did nothing.  Move the step to disable lvmetad until
later, just before some actual repair is done.  There are
now numerous cases where nothing is actually done and lvmetad
is not disabled.
2018-11-30 14:54:19 -06:00
Peter Rajnoha
0e42ebd6d4 scan: md metadata version 0.90 is at the end of disk
commit de28637
  scan: use full md filter when md 1.0 devices are present

missed the fact that md superblock version 0.90 also puts
metadata at the end of the device, so the full md filter
needs to be used when either 0.90 or 1.0 is present.
2018-11-29 12:16:37 -06:00
David Teigland
cb5405ded8 bcache: sync io fixes
fix lseek error check
fix read/write error checks
handle zero return from read and write
don't return an error for short io
fix partial read/write loop
2018-11-20 09:04:37 -06:00
David Teigland
f8ce9bf3bc io: use sync io if aio fails
io_setup() for aio may fail if a system has reached the
aio request limit.  In this case, fall back to using
sync io.  Also, lvm use of aio can be disabled entirely
with config setting global/use_aio=0.

The system limit for aio requests can be seen from
  /proc/sys/fs/aio-max-nr

The current usage of aio requests can be seen from
  /proc/sys/fs/aio-nr

The system limit for aio requests can be increased by
setting fs.aio-max-nr using sysctl.

Also add last-byte limit to the sync io code.
2018-11-20 09:00:26 -06:00
David Teigland
9799c8da07 devices: reuse bcache fd when getting block size
This avoids an unnecessary open() on the device.
2018-11-06 16:41:04 -06:00
David Teigland
ab27d5dc2a metadata: prevent writing beyond metadata area
lvm uses a bcache block size of 128K.  A bcache block
at the end of the metadata area will overlap the PEs
from which LVs are allocated.  How much depends on
alignments.  When lvm reads and writes one of these
bcache blocks to update VG metadata, it can also be
reading and writing PEs that belong to an LV.

If these overlapping PEs are being written to by the
LV user (e.g. filesystem) at the same time that lvm
is modifying VG metadata in the overlapping bcache
block, then the user's updates to the PEs can be lost.

This patch is a quick hack to prevent lvm from writing
past the end of the metadata area.
2018-10-29 16:46:03 -05:00