1
0
mirror of git://sourceware.org/git/lvm2.git synced 2025-01-05 13:18:20 +03:00
Commit Graph

487 Commits

Author SHA1 Message Date
Zdenek Kabelac
da7ec2ec0f gcc: cleanup warns from older gcc 2020-10-25 21:56:02 +01:00
Zdenek Kabelac
5ad30c57b3 debug: update messages 2020-10-18 21:28:13 +02:00
Zdenek Kabelac
84f03e2b63 gcc: calc size in compile time 2020-10-18 21:27:51 +02:00
Zdenek Kabelac
03bddd7d41 debug: remove stacktrace on regular path
Here _insert is expected to also fail, so just regular 'return 0'.
2020-10-16 18:09:55 +02:00
Zdenek Kabelac
e8df503885 bcache: use flexible arrays
Cleanup, allocate whole struct with a single malloc call.
2020-10-16 18:09:55 +02:00
Zdenek Kabelac
479f0822ad bcache: support interrupts when waiting on IO
Since lvm2 normally block signals during protected
phase where it does not want to be interrupted.
Support interruptible processing when allowed
in section between sigint_allow() ... sigint_restore())
and let the 'io_getenvents()'  finish with EINTR.
2020-10-16 18:09:55 +02:00
Zdenek Kabelac
5e64aa222b bcache: fix busy loop with too many errors
When bcache tries to write data to a faulty device,
it may get out of caching blocks and then just busy-loops
on a CPU - so this check protects this by checking
if there is already max_io (~64) errored blocks.
2020-10-16 18:09:55 +02:00
Zdenek Kabelac
d32ee355c7 bcache: fix waiting problem for completed IO
Call _wait_all() which does check whether there is still
some pending IO before sleep. Otherwise it may happen
our submitted IO operations have been already dispatched
and this call then endlessly waits for IO which are all done.
This can be reproduced when device returns quickly errors
on write requests.
2020-10-16 18:09:55 +02:00
David Teigland
9345b9cb26 devices: simplify md superblock checking code 2020-10-16 17:07:59 +02:00
David Teigland
57ddaaa47d devices: detect md ddf and imsm superblocks 2020-10-16 17:07:59 +02:00
Zhao Heming
db7aef215a dev-cache: dev->bcache_fd default from 0 to -1
This fix can avoid bcache_fd will mistakenly open/close in later.

Signed-off-by: Zhao Heming <heming.zhao@suse.com>
2020-10-16 17:07:59 +02:00
Zdenek Kabelac
d53456be24 gcc: zero-sized array to fexlible array C99
Switch remaining zero sized struct to flexible arrays to be C99
complient.

These simple rules should apply:

- The incomplete array type must be the last element within the structure.
- There cannot be an array of structures that contain a flexible array member.
- Structures that contain a flexible array member cannot be used as a member of another structure.
- The structure must contain at least one named member in addition to the flexible array member.

Although some of the code pieces should be still improved.
2020-10-16 16:02:06 +02:00
Zdenek Kabelac
90a9a7785e gcc: keep unsigned arithmetic
Avoid conversion to int.
2020-10-16 16:02:05 +02:00
Zdenek Kabelac
e397423c41 bcache: support longer writes
When initiated larger write request, it may have happened, bcache
got out of free chunks - fix the loop, that is supposed to wait
until next free chunk becomes avain available.
2020-10-16 16:02:05 +02:00
David Teigland
1fb7a9d9e5 scanning: optimize by checking text offset and checksum
stable backport of 0c1316cda8
which includes a number of extra supporting functions.

In stable, the optimization is only applied to reporting
and display commands, so this change applies only to those
cases.

After the VG lock is taken for vg_read, reread the mda_header
from disk and compare the metadata text offset and checksum
to what was seen during label scan.  If it is unchanged, then
the metadata has not changed since the label scan, and the
metadata does not need to be reread under the lock for command
processing. If it is changed, then reread the metadata from disk.

This fixes a problem with the original optimization where lvm
reuses cached data from the label_scan phase for vg_read. This
works if the mda_header and metadata text are both read from
cache, or both read from disk, but in some cases the mda_header
could have been dropped from the cache and read from disk, while
the metadata blocks remained in the cache and were not read from
disk. If in addition to this, another concurrent command happened
to update the metadata between the label_scan and vg_read, then
the new mda_header from disk would refer to cached blocks that did
not contain the new metadata text. This would cause the lvm command
report an error about invalid metadata.
2020-06-23 11:32:32 -05:00
Zdenek Kabelac
5f766b32cf container_of: use offsetof from stddef
Use standardized offsetof() macro from stddef.
Helps to build valid code with latest gcc10 with -O2.
2020-04-08 15:22:54 +02:00
Marian Csontos
deaf304ee6 bcache: Fix memory leak in error path 2020-03-04 13:22:10 +01:00
David Teigland
44c460954b Fix rounding writes up to sector size
Do this at two levels, although one would be enough to
fix the problem seen recently:

- Ignore any reported sector size other than 512 of 4096.
  If either sector size (physical or logical) is reported
  as 512, then use 512.  If neither are reported as 512,
  and one or the other is reported as 4096, then use 4096.
  If neither is reported as either 512 or 4096, then use 512.

- When rounding up a limited write in bcache to be a multiple
  of the sector size, check that the resulting write size is
  not larger than the bcache block itself.  (This shouldn't
  happen if the sector size is 512 or 4096.)

(cherry picked from commit 7550665ba4)

Conflicts:
	lib/device/dev-io.c
2020-03-04 13:20:36 +01:00
Joe Thornber
019fa6f8ee [bcache] bcache_invalidate_fd, only remove prefixes on success. 2020-01-16 14:58:56 +00:00
Joe Thornber
1e2e12f19c [bcache] reverse earlier patch.
It broke some unit tests, for v. little benefit
2020-01-16 14:58:43 +00:00
Joe Thornber
6370c20d39 [bcache] pass up the error from io_submit rather than using generic -EIO
Author: Heming Zhao
2020-01-16 14:58:28 +00:00
Joe Thornber
232f779db4 [bcache] add bcache_abort()
This gives us a way to cope with write failures.
2020-01-16 14:53:17 +00:00
Joe Thornber
b6e6ea2d65 [bcache] Bring bcache into sync with master branch 2020-01-16 14:20:35 +00:00
Zdenek Kabelac
36b8b9ed5c debug: avoid to slashes in debug message 2019-10-26 00:29:44 +02:00
Marian Csontos
36523a398d cov: Fix a leak 2019-08-27 12:23:13 +02:00
David Teigland
f55b8e387f devices: put ifdef around BLKPBSZGET
BLKPBSZGET is not defined before kernel version 2.6.32
(e.g. rhel5)
2019-08-20 09:32:26 -05:00
David Teigland
7550665ba4 Fix rounding writes up to sector size
Do this at two levels, although one would be enough to
fix the problem seen recently:

- Ignore any reported sector size other than 512 of 4096.
  If either sector size (physical or logical) is reported
  as 512, then use 512.  If neither are reported as 512,
  and one or the other is reported as 4096, then use 4096.
  If neither is reported as either 512 or 4096, then use 512.

- When rounding up a limited write in bcache to be a multiple
  of the sector size, check that the resulting write size is
  not larger than the bcache block itself.  (This shouldn't
  happen if the sector size is 512 or 4096.)
2019-07-25 17:06:43 -05: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
66665f5e42 cov: add stack tracing for error paths
Add missing stack reports on error paths.
2019-06-25 17:33:25 +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
b79f1e176f bcache: Fix memory leak 2019-04-04 10:19:15 +02: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
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
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
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
David Teigland
de2863739f scan: use full md filter when md 1.0 devices are present
The md filter can operate in two native modes:
- normal: reads only the start of each device
- full: reads both the start and end of each device

md 1.0 devices place the superblock at the end of the device,
so components of this version will only be identified and
excluded when lvm uses the full md filter.

Previously, the full md filter was only used in commands
that could write to the device.  Now, the full md filter
is also applied when there is an md 1.0 device present
on the system.  This means the 'pvs' command can avoid
displaying md 1.0 components (at the cost of doubling
the i/o to every device on the system.)

(The md filter can operate in a third mode, using udev,
but this is disabled by default because there have been
problems with reliability of the info returned from udev.)
2018-10-17 13:49:40 -05:00
David Teigland
a991664dec bcache: reduce MAX_IO to 256
This is the number of concurrent async io requests that
the scan layer will submit to the bcache layer.  There
will be an open fd for each of these, so it is best to
keep this well below the default limit for max open files
(1024), otherwise lvm may get EMFILE from open(2) when
there are around 1024 devices to scan on the system.
2018-08-24 14:50:53 -05:00
Zdenek Kabelac
b8a7f6ba3d dev_io: no discard in testmode
When lvm2 command is executed in test mode, discard ioctl is skipped.
This may cause even data-loose in case, issuing discard for released
areas was enabled and user 'tested'  lvreduce.
2018-07-09 00:35:34 +02:00
David Teigland
f7ffba204e devs: use bcache fd for read ahead ioctl
to avoid an unnecessary open of the device in
most cases.
2018-06-26 12:15:43 -05:00
David Teigland
49147cbaa7 bcache.c add missing { 2018-06-26 12:15:43 -05:00
Marian Csontos
69907e0780 bcache: Fix null pointer dereferencing
(cherry picked from commit a14f21bf1d)

Conflicts:
	lib/device/bcache.c
2018-06-26 17:09:58 +02:00
Marian Csontos
acb784e2a8 bcache: fix memory leaks 2018-06-21 10:22:35 +02:00
David Teigland
a30e622279 scan: work around udev problems by avoiding open RDWR
udev creates a train wreck of events if we open devices
with RDWR.  Until we can fix/disable/scrap udev, work around
this by opening RDONLY and then closing/reopening RDWR when
a write is needed.  This invalidates the bcache blocks for
the device before writing so it can trigger unnecessary
rereading.
2018-06-20 12:05:04 -05:00
David Teigland
bfb904af1c bcache: remove extraneous error message
an error from io_submit is already recognized by
the caller like errors during completion.
2018-06-18 11:59:57 -05:00