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

818 Commits

Author SHA1 Message Date
Zdenek Kabelac
16241b2dc7 lv_manip: init major minor in alloc_lv
Move initialization of major and minor to alloc_lv().
2024-10-28 20:07:37 +01:00
Zdenek Kabelac
188dd3c357 device_mapper: check for pv before use in error msg 2024-10-25 01:26:39 +02:00
Zdenek Kabelac
21517c2bd5 metadata: use radix tree to find lv_names
Replace usage of dm_hash with radix_tree to quickly find LV name
with a vg and also index PV names with set of available PVs.
This PV index is only needed during the import, but instead
of passing 'radix_tree *' everywhere, just keep this within
a VG struct as well and once the parsing is finished, release
this PV index radix_tree.

This also makes it easier to replace this structure
in the future if needed.

lv_set_name now uses  radix_tree remove+insert to keep lv_names
tree in-sync and usable for  find_lv queries.
2024-10-24 17:38:09 +02:00
Zdenek Kabelac
1825e782cc revert "metadata: use lv_hash in segment-specific metadata parsing"
This reverts commit f42aef4706.

Going to replace dm_hash with radix_tree and use 'find_lv()'
to abstract lookup for LV with VG.
2024-10-24 17:38:09 +02:00
Zdenek Kabelac
c681d4e61a metadata: add lv_set_name
Add function to set lv->name.
Also when creating empty LV, first add this LV
to linked list in a VG and just after that allocate lv name.
2024-10-24 17:38:09 +02:00
Zdenek Kabelac
d62170d646 flags: drop no longer needed header
After code refactoring, this header is not needed here anymore.
2024-10-24 17:35:33 +02:00
Zdenek Kabelac
dd856edaab vgcfgrestore: validate complete VG
Avoid finding problems in vg_validate when restoring
invalid VG metadata as that would lead to internal error.
i.e. adding unsupported METADATA_FLAG to zero segtype
can trigger such thing.
2024-10-23 20:16:14 +02:00
Zdenek Kabelac
2916a8a1f3 read_lvflags: keep flag reading focused on flags
Previous update needed to add handling segtype within flag.c
which somewhat breaks API separition and also had bug in hanlding
actual flags.

So instead keep segtype code in _read_segtype_and_lvflags() within
import_vsn1.c and handle purly flags in read_lvflags() from const
string.
2024-10-23 20:16:14 +02:00
Zdenek Kabelac
1f0530919e export: typo with buffer zeroing
Lost '= 0' in cut & paste.
Also get rid of no longer needed 'goto' section.
2024-10-23 20:15:48 +02:00
Zdenek Kabelac
ea39c58127 export: add missed buffer initialization
Since we reduced emitting to single string list,
we need to make sure empty list are not producing
garbage strings.
2024-10-23 14:38:21 +02:00
Zdenek Kabelac
e0421ee7bf export: change to read_segtype_and_lvflags
Instead of duplicating whole segtype string with flags and
using 2 calls read_segtype_lvflags() + get_segtype_from_string(),
merge the functionality into a single read_segtype_and_lvflags().
This allows to make only a local string copy (no allocs) and eventually
to not copy segtype string at all, when there are no flags.
2024-10-23 14:10:46 +02:00
Zdenek Kabelac
4929c55bc5 export: reduce emit_to_buffer calls
As the 'emit_to_buffer' uses relatively complex
vsnprintf() call inside, try to reduce number
of unnecessary calls and try replace some more
complex string build with a single call instead.
2024-10-23 14:10:46 +02:00
Zdenek Kabelac
c19dfe11a5 debug: use just LV name for debug message
Since we detect 'debug' level after calling 'log_debug()' - all
the arguments are evaluated, so in this case display_lvname() was
preparing a string that is not used in case debugging is not enabled.

So since these string are on 'hot-path' and it's already known
which VG is being worked on, in these few cases just use lv->name.
2024-10-22 19:36:00 +02:00
Zdenek Kabelac
5827c9e337 config: use dm_config_parse_only_section 2024-10-22 19:36:00 +02:00
Zdenek Kabelac
4dc0ee8e56 export: use radix_tree for write formatter
Replace use of dm_hash with radix_tree when making PV index names.

Store just the index number itself and use pv%d for outf() string.

For lookup up a PV - use just the PV pointer itself, it's faster then
converint for it's ID to UUID format.
2024-10-22 19:36:00 +02:00
Zdenek Kabelac
7c5cca600c check_lv_segment: split into incomplete complete
Split single check_lv_segments() into 2 separate
versions so they can be called independently.
This allow to 'skip' already checked segment
check after it's been imported to VG and also
avoid another repeated checking when validating
segment with complete vg.

**
check_lv_segments_incomplete_vg()

this check just basic LV segment properties and does not
validate those requiring full VG.

**
check_lv_segments_complete_vg()

Remaining check that expects complete VG is present.
2024-10-22 19:36:00 +02:00
Zdenek Kabelac
b4156bb4de export: limit generation of comment strings
Generate comment string only for formatter with comments.
2024-10-22 19:36:00 +02:00
Zdenek Kabelac
0179f00e0c import: check fixup mirror only when needed
Track whether import has even seen segment of LV with log_lv,
and call fixup mirror only in this case.

Also avoid repeated lookup of get_segtype_from_string for
SEG_TYPE_NAME_MIRROR.
2024-10-22 19:36:00 +02:00
David Teigland
f42aef4706 metadata: use lv_hash in segment-specific metadata parsing
The lv_hash wasn't being passed to the seg-specific text import
functions, so they were doing many find_lv() calls which consumes
a lot of time when there are many LVs in the metadata.
2024-09-10 11:51:15 -05:00
Zdenek Kabelac
39b7d1ba8f cleanup: typos in comments
Collection of typos in code comments.
Should have no runtime effect.
2024-08-30 16:51:15 +02:00
Zdenek Kabelac
7da47cea35 cleanup: typos in logging
Fixes various typos in printed/logged messages.
2024-08-30 16:51:15 +02:00
David Teigland
57e9083c90 config_file: remove unused code
config_file_read() is only used for regular files, not devices.
2024-07-02 16:24:12 -05:00
Zdenek Kabelac
64ccbc4b52 gcc: check cv pointer when needed
As 'cv' was already dereferenced, check for NULL with do {} while();
loop.
2024-06-19 14:28:02 +02:00
Zdenek Kabelac
a98beb8ee3 gcc: ensure all fmt struct element are initialized 2024-06-19 14:28:02 +02:00
Zdenek Kabelac
45c06025da cleanup: some typos
Collection of some typos or invalid uppercase or doublespace cases.
2024-05-27 15:35:57 +02:00
Zdenek Kabelac
e3dff2cba2 gcc: same signess 2024-05-14 17:59:26 +02:00
Zdenek Kabelac
ffdceeb982 cleanup: some missed public symbols static 2024-05-13 12:58:19 +02:00
Zdenek Kabelac
3e91823b3e cov: enum correct prototype
Cleanup enum usage.
2024-05-08 01:55:21 +02:00
Zdenek Kabelac
0bcf2c6514 const: use arrays of strings
Such string is stored directly in '.rodata' section.
2024-05-04 01:01:57 +02:00
Zdenek Kabelac
ff699eab24 const: _ops text_vg_version 2024-05-04 01:01:57 +02:00
Zdenek Kabelac
41ffa8c74d const: _ops labeler _text_ops 2024-05-04 01:01:57 +02:00
Zdenek Kabelac
effafa8fc8 const: _ops text handler
Making sure these structures ends in '.data.rel.ro' section.
(instead of plain '.data' section).
2024-05-04 01:01:42 +02:00
Zdenek Kabelac
db6bb6e90b cleanup: unlink passes with ENOENT 2024-05-01 10:55:17 +02:00
Zdenek Kabelac
995ff58903 refactor: remove (void) from dm_strncpy usage
Start to use dm_strncpy() as unchecked version within source tree.
2024-04-04 19:38:21 +02:00
Zdenek Kabelac
0dbd90d74e gcc: match signed integers 2024-03-27 01:11:00 +01:00
Ranjith ML
1c3ae2b678 archiving: Fix doubled filename in vgcfgrestore 2024-01-24 14:11:19 +01:00
Zdenek Kabelac
c451d7925d cleanup: correcting some log_print
Correcting to log_print_unless_silent(),
so -qq can do some work.
2023-05-06 20:38:49 +02:00
Zdenek Kabelac
7bc5c8ac3d cov: avoid using strcpy
Coverity is complaining about unchecked strcpy here, which is
irelevant as we preallocate buffer to fit in copied string,
however we could actually reuse these size and use just memcpy().
So lets make some simple conversions.
2023-02-17 00:00:04 +01:00
Zdenek Kabelac
f89c369a01 archive: update message
Better suggesting message as suggested by RHBZ 2123151.
2023-02-01 11:47:30 +01:00
Wu Guanghao
ce58e9d5b3 _vg_read_raw_area: fix segfault caused by using null pointer
When we tested lvm2, the kernel injected various random faults.

(gdb) bt
...
(gdb) p vg
$1 = (struct volume_group *) 0x0
(gdb) p use_previous_vg
$2 = (unsigned int *) 0x0

Signed-off-by: Wu Guanghao <wuguanghao3@huawei.com>
2022-08-15 09:39:02 -05:00
Zdenek Kabelac
f83b3962c1 asan: fix some reports from libasan
When compiled and used with:

CFLAGS="-fsanitize=address -g -O0"
ASAN_OPTIONS=strict_string_checks=1:detect_stack_use_after_return=1:check_initialization_order=1:strict_init_order=1

we have few reported issue - they where not normally spotted, since
we were still accessing our own memory - but ouf of buffer-range.

TODO: there is still something to enhance with handling of #orphan vgids
2022-02-07 20:02:11 +01:00
David Teigland
114e1cfee5 fix spelling of pruning 2021-11-19 12:02:35 -06:00
Zdenek Kabelac
2779830a06 cov: avoid using NULL info
Check lvmcache info exists before calling lvmcache_del_save_bad_mda().
2021-10-15 23:36:22 +02:00
Zdenek Kabelac
14cf579263 gcc: archive reoder struct vars
Easier for automatic struct initialization = { 0 } without warns
from older gcc.
2021-10-15 00:09:07 +02:00
Zdenek Kabelac
8784211958 debug: reduce some debugging noise
Resolve event_activation configure option just once.

Do not print debug_devs about 'bad' filtering, when
actually filter already printed reason for skipping

Do not trace more then once about backup being disabled.

No debug when unlinked file does not exists in pvscan.
2021-10-14 23:34:11 +02:00
Zdenek Kabelac
af0ce203e9 debug: better error message
Add more details about size difference.
2021-10-14 23:34:11 +02:00
Zdenek Kabelac
7e346ee2a5 archiving: update refactoring
Commit 5ea426e656 handled case with
file path without '/' incorrectly - there is valid use-case so
switch 'log_error()' to valid code branch.
2021-10-14 23:33:26 +02:00
Zdenek Kabelac
197f6aaad7 cleanup: skip zeroing buffer overwritten by memcpy
Since the buffer is going to be overwritten by memcpy, reset only last
char to 0.

Also more use of DM_LIST_INIT list.h macro.
2021-10-06 15:43:31 +02:00
Zdenek Kabelac
5ea426e656 archiving: refactor code to allocate less memory
Do not store full path with each archived name reduces memory usage if
the directory has thousands of entries and just add 'dir' path when
needed.

Also emit info print message to a user if the total size of archived
files for a VG is more then 128MiB or 8192 files.

TODO: Consider wheather adding a new 'lvm.conf  archive{option}' to support
trimming these wild archive sizes can make situation better.
We already support retain_min && retain_days  - but if user is
generating too many and too large archives with minutes - maybe archiving
should be disabled by a user - as it's not producing anything largely usable
and just slows-down command ??
If we add 'retain_max & retain_max_size' the condition will go against
each other and we need to chose priorities.

mm
2021-10-06 15:42:53 +02:00
David Teigland
939b4bc587 handle bad metadata text in vg_read path
Corrupt metadata text (with good mda header) was being handled
in the label_scan phase, but not in the vg_read phase.  This
was sufficient because metadata areas would always be read and
checksummed during label_scan (metadata parsing was skipped
previously as an optimization.)

This changed with the optimization in
commit 61a6f9905e
"metadata: optimize reading metadata copies in scan"

Now, some metadata areas will not be read and checksummed
at all during the label_scan phase, only during the vg_read
phase.  This means that bad metadata text may first be detected
in the vg_read phase.  So, add equivalent bad metadata handling
to the vg_read path to match the label_scan path.
2021-09-28 15:17:43 -05:00