1
0
mirror of git://sourceware.org/git/lvm2.git synced 2024-12-22 17:35:59 +03:00
Commit Graph

1337 Commits

Author SHA1 Message Date
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
Zhao Heming
87769c5713 gcc: change zero-sized array to fexlible array
this patch makes gcc happy with compiling option: [-Wstringop-overflow=]

Signed-off-by: Zhao Heming <heming.zhao@suse.com>
2020-10-16 16:02:06 +02:00
Zdenek Kabelac
f7b4b127e9 gcc: do not use return with void function
Follow C norm and do not use 'return' in void function to call other
functions.
2020-10-16 16:02:06 +02:00
Zdenek Kabelac
55a8b1bd37 gcc: use apropriate type for reading and printing values 2020-10-16 16:02:05 +02:00
Zdenek Kabelac
950a9bbde9 container_of: drop needless const converion 2020-10-16 16:02:05 +02:00
Zdenek Kabelac
8f3d2d5e11 libdm: fix dm_list pointer arithmentic for new gcc 10 optimization 2020-04-08 15:22:54 +02:00
Marian Csontos
c65f3fd8df dm: Fix compilation of dmsetup
Fix: 889c88e9da
2019-10-22 10:37:40 +02:00
Marian Csontos
c24fa7b7b7 cov: Clarify the control flow
Return need a clean up but it is not bailing out due to an error.

Fix: 402b41f58d
2019-10-21 15:32:09 +02:00
Zdenek Kabelac
3fe2610cff debug: drop some unneeded backtraces
(cherry picked from commit 88faf5a53b)

Conflicts:
	lib/format_text/export.c
	tools/lvconvert.c
2019-10-21 15:26:11 +02:00
Mikulas Patocka
889c88e9da dm: introduce DM_GET_TARGET_VERSION
Adds support for the DM_GET_TARGET_VERSION to dmsetup.
It introduces a new comman "target-version" that will accept list
of targets and print their version.

Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
(cherry picked from commit 667b33dd3b)

Conflicts:
	device_mapper/all.h
	device_mapper/ioctl/libdm-iface.c
	device_mapper/misc/dm-ioctl.h
2019-10-21 15:21:29 +02:00
Marian Csontos
402b41f58d cov: Fix memory leak 2019-08-28 14:47:23 +02:00
Zdenek Kabelac
4a3e1ac740 exported_symbols: comment old symbols
Fix versioning for updated symbols dm_stats_create_region
and dm_stats_create_region.

Only the latest symbol should have global entry.

Since I'm not sure what is currenlty the best option for
old symbols - we added support for easy commenting of them
(so we do not lose information when the symbol appeared
for the first time.)

Note: some old already deleted symbols should have been
restored as comments.
2019-08-07 15:28:55 +02:00
Zdenek Kabelac
ea036ecfd3 libdm: implement search for device names for older kernels
Kernels <2.6.27 don't have /sys/dev dir - add code for looking
out device name via longre seach in /sys/block

This makes commands like 'dmsetup dep -o blkdevname' working.
2019-07-06 01:24:28 +02: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
Zdenek Kabelac
a397b69ce3 metadata: allow reading metadata with invalid creation_time
lvm2 till version 2.02.169 (commit 78d004efa8)
was printing invalid creation_time argument into metadata on 32bit arch.

However with commit ba9820b142 we started
to properly validate all input numbers and thus we refused to accept
invalid metadata with 'garbage' string - but this results in the
situation where metadata produced on older lvm2 on 32 bit architecture
will become unreadable after upgrade.

To fix this case - extend libdm parser in a way, that whenever we
find error integer value, we also check if the parsed value is not for
creation_time node and in this case we let the metadata pass through
with made-up date 2018-05-24 (release date of 2.02.169).
2019-05-10 15:07:15 +02:00
Zdenek Kabelac
bc6ae7030a dm: migration_threshold for old linked tools
Just like with precending  lvm2 device_mapper patch, ensure
that old users of libdm will also get fixed migration threshold
for caches.

(cherry picked from commit 74ae1c5bc1)

Conflicts:
	WHATS_NEW_DM
2019-03-05 13:01:19 +01:00
Zdenek Kabelac
167aa34926 stats: initilize regions to NULL
Commit 3750b0cff5 used bad: error
path in more occasions thus it now needs regions defined as NULL.

(cherry picked from commit 83c6f7e7e6)
2019-03-05 12:57:50 +01:00
Zdenek Kabelac
8fc64c5ee6 stats: fix error path when region is NULL
We should not call _stats_cleanup_region_ids() when regions
are NULL.
Also add backtracing for  goto.

(cherry picked from commit 3750b0cff5)
2019-03-05 12:57:40 +01:00
Zdenek Kabelac
8d44cd3e47 libdm: add memory barrier
Just for case ensure compiler is not able to optimize
memset() away for resources that are released.

This idea of using memory barrier is taken from openssl.

Other options would be to check for 'explicit_bzero' function.

(cherry picked from commit 55a8d6c86b)

Conflicts:
	device_mapper/ioctl/libdm-iface.c
2019-03-05 12:48:15 +01:00
Zdenek Kabelac
40f57155a3 libdm: print params only for ioctls using them
When preparing ioctl buffer and flatting all parameters,
add table parameters only to ioctl that do process them.

Note: list of ioctl should be kept in sync with kernel code.
(cherry picked from commit 43f8da7699)

Conflicts:
	WHATS_NEW_DM
	device_mapper/ioctl/libdm-iface.c
2019-03-05 12:47:50 +01:00
Zdenek Kabelac
1bef4dfab3 libdm: add DM_DEVICE_ARM_POLL
Expose DM_DEVICE_ARM_POLL via standard API enum.

(cherry picked from commit 1ae5bf2b83)

Conflicts:
	WHATS_NEW_DM
	device_mapper/all.h
	device_mapper/ioctl/libdm-iface.c
2019-03-05 12:46:21 +01: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
93ac80037a cov: mark warning as expected one
(cherry picked from commit 9238b972c5)

Conflicts:
	base/data-struct/radix-tree-adaptive.c
	device_mapper/libdm-file.c
2019-03-05 12:16:33 +01:00
Zdenek Kabelac
c9e5e6800c cov: split check for type assignment
Check that type is always defined, if not make it explicit internal
error (although logged as debug - so catched only with proper lvm.conf
setting).
This ensures later type being NULL can't be dereferenced with coredump.

(cherry picked from commit 79879bd201)
2019-03-05 12:16:07 +01:00
Zdenek Kabelac
f0f68791f3 cov: shutdown warning
Since previous patch reverted coverity patch as this case is intentional,
provide override this coverity warning.

(cherry picked from commit 05b5774827)
2019-03-05 12:15:40 +01:00
Zdenek Kabelac
b39c26ddc3 revert "cov: dm stats missed terminating null"
This reverts commit 20971f7034
as the parsing of 'dmstatus' started to fail on present \0 char.

(cherry picked from commit 6179cab877)
2019-03-05 12:15:16 +01:00
Zdenek Kabelac
d1ae1455b4 cov: ensure vars are set
Make sure, tmp_begin and tmp_end are always set, even for blind
coverity.

(cherry picked from commit 2513661467)

Conflicts:
	device_mapper/libdm-report.c
2019-03-05 12:14:43 +01:00
Zdenek Kabelac
ece117ee10 cov: dm stats missed terminating null
Coverity noticed allocating insufficient memory
for the terminating null of the string.

(cherry picked from commit 20971f7034)
2019-03-05 12:10:36 +01:00
Zdenek Kabelac
d5234e1b7e libdm: do not add params for resume and remove
DM_DEVICE_CREATE with table is doing several ioctl operations,
however only some of then takes parameters.
Since _create_and_load_v4() reused already existing dm task from
DM_DEVICE_RELOAD it has also kept passing its table parameters
to DM_DEVICE_RESUME ioctl - but this ioctl is supposed to not take
any argument and thus there is no wiping of passed data - and
since kernel returns buffer and shortens dmi->data_size accordingly,
anything past returned data size remained uncleared in zfree()
function.

This has problem if the user used dm_task_secure_data (i.e. cryptsetup),
as in this case binary expact secured data are erased from main memory
after use, but they may have been left in place.

This patch is also closing the possible hole for error path,
which also reuse same dm task structure for DM_DEVICE_REMOVE.
2018-12-06 17:46:51 +01:00
Bryn M. Reeves
813a83b2d6 libdm-stats: move no regions warning after dm_stats_list()
It doesn't make sense to test or warn about the region count until
the stats handle has been listed: at this point it may or may not
contain valid information (but is guaranteed to be correct after
the list).
2018-11-01 16:47:56 +00:00
Marian Csontos
8a0af1bec8 libdm: fix buffer overflow 2018-06-21 10:22:24 +02:00
David Teigland
9b6a62f944 lvmcache: simplify
Recent changes allow some major simplification of the way
lvmcache works and is used.  lvmcache_label_scan is now
called in a controlled fashion at the start of commands,
and not via various unpredictable side effects.  Remove
various calls to it from other places.  lvmcache_label_scan
should not be called from anywhere during a command, because
it produces an incorrect representation of PVs with no MDAs,
and misclassifies them as orphans.  This has been a long
standing problem.  The invalid flag and rescanning based on
that is no longer used and removed.  The 'force' variation is
no longer needed and removed.
2018-04-20 11:22:48 -05:00
Zdenek Kabelac
1287edf626 cleanup: call uname once
Call uname() once and keep result for mirror use-case.
2018-04-20 12:16:58 +02:00
Zdenek Kabelac
30975a3328 libdm: enhance mounted fs detection
btrfs is using fake major:minor device numbers.
try to be smarter and detect used node via DM device name.

This shortens delays, where i.e. lvm2 is asked to deactivate
volume with mounted btrfs as such operation is not retryed
and user is informed about device being in use.
2018-03-23 17:24:58 +01:00
Zdenek Kabelac
c82ab92d04 cleanup: use zalloc
Replace malloc() + memset()   with zalloc().
2018-03-17 23:33:58 +01:00
Zdenek Kabelac
043f58452a libdm-stats: fix error messages
When function dm_stats_populate() returns 0 it's an error and needs
log_error() message -  function can't have 'success' returning 0 or
error without reasons.
2018-03-15 10:56:31 +01:00
Zdenek Kabelac
2b3b486a37 libdm: support for DM_DEBUG_WITH_LINE_NUMBERS
For any libdm tool using default debugging function allow
to show source filename and code line number when this
functionality is available.
2018-03-15 10:49:24 +01:00
Zdenek Kabelac
7239a45b79 clean: drop unneeded -1 for snprintf
man gives:
snprintf() and vsnprintf() write at most size bytes
(including the terminating null byte ('\0')) to str.
2018-02-12 22:14:25 +01:00
Zdenek Kabelac
60b61f2db3 libdm-stats: correct checking of dm_snprintf error
Function dm_snprintf returns -1 on error, while 0 is still
considered valid result code so correcting error path testing.
2018-02-12 22:13:57 +01:00
Zdenek Kabelac
4d4d5bf323 libdm: accept mirror status with userspace word in the line
Just making sure the parser will not stop - although greater level of
support needs to be added (Describing doc seems to be missing however).
2018-02-01 21:56:07 +01:00
Alasdair G Kergon
e4e2abc8bc libdm: Fix a size_t in _dm_malloc_aligned_aux message. 2018-01-12 00:42:53 +00:00
Alasdair G Kergon
ea96381534 libdm: Introduce dm_malloc_aligned 2018-01-10 15:48:03 +00:00
Zdenek Kabelac
4c88c4626d debug: update debug msg
Use _node_name.
2017-12-07 21:00:39 +01:00
Zdenek Kabelac
717714b24f cleanup: use log_warn 2017-12-07 21:00:39 +01:00
Zdenek Kabelac
820b1b98fc libdm: drop extra structure copy
When doing resume, directly pass location where new updated info
needs to be stored.

_resume_node() ensures the info is ONLY updated when the function
is successful and never changes it on error path.
2017-12-07 21:00:39 +01:00
Zdenek Kabelac
82ae02bc6a libdm: use delay_resume_if_extended
Update the logic towards more explicit logic.

Preload tree normally does not want to resume, only
in certain cases of extension or new loaded nodes can be
resumed. So introduce new internal variable delay_resume_if_extended
controlable by target.

Patch itself is not changing current existing behaviour,
and rather documents existing problem in more readable way.

lvm2 needs to introduce explicit mechanism how to support more
fain-grained (and safe) logic to i.e. resize thin-pool which
can be sitting on cached raid volume.
2017-12-07 21:00:39 +01:00
Zdenek Kabelac
297d5915c3 libdm: avoid checking status on activation
Variable props.send_messages has 3 states and was not used properly
here.  Activation in this moment does not need to verify thin-pool status
as that has been already checked on preload.
So only if there are some real messages (value 2) call function
for sending them.
2017-12-07 21:00:36 +01:00
Zdenek Kabelac
4a4ea47f70 libdm: add help func _get_last_load_segment
Share code for same functionality.
2017-12-07 20:59:37 +01:00
Zdenek Kabelac
c3e224ad0e thin: missing type is error 2017-12-07 20:59:37 +01:00
Zdenek Kabelac
2208ebfe16 thin: always clear memory before parsing status
Ensure there cannot be 'reused' any data from some previous call.
2017-12-07 20:59:28 +01:00