1
0
mirror of git://sourceware.org/git/lvm2.git synced 2024-10-27 18:55:19 +03:00
Commit Graph

375 Commits

Author SHA1 Message Date
Joe Thornber
d5da55ed85 device_mapper: remove dbg_malloc.
I wrote dbg_malloc before we had valgrind.  These days there's just
no need.
2018-06-08 13:40:53 +01:00
Joe Thornber
ccc35e2647 device-mapper: Fork libdm internally.
The device-mapper directory now holds a copy of libdm source.  At
the moment this code is identical to libdm.  Over time code will
migrate out to appropriate places (see doc/refactoring.txt).

The libdm directory still exists, and contains the source for the
libdevmapper shared library, which we will continue to ship (though
not neccessarily update).

All code using libdm should now use the version in device-mapper.
2018-05-16 13:00:50 +01:00
Joe Thornber
7f97c7ea9a build: Don't generate symlinks in include/ dir
As we start refactoring the code to break dependencies (see doc/refactoring.txt),
I want us to use full paths in the includes (eg, #include "base/data-struct/list.h").
This makes it more obvious when we're breaking abstraction boundaries, eg, including a file in
metadata/ from base/
2018-05-14 10:30:20 +01:00
Zdenek Kabelac
a082ce2613 dmstatus: check nr_regions ahead of find call
Prevent call of dm_stats_populate(), when there has been no
stats region detected for a DM device.
Such skip is evaluated as 'correct' visit of stats call and
not causing 'dmstats' command failure.
2018-03-15 10:54:19 +01:00
Zdenek Kabelac
4c925692f5 dmsetup: loop output table as verbose
Resulting loop table line was streamed to 'stderr' stream - assuming this
was not a feature when user used '-v' for more verbose output
and properly show it via  'log_verbose()' on 'stdout'.
2018-03-15 10:50:30 +01:00
Zdenek Kabelac
b1ace8ce19 dmsetup: indent 2018-03-13 12:58:57 +01:00
Zdenek Kabelac
49a8c786d5 dmsetup: report close as debug
Since close() failures are not causing command errors,
issue error via debug log stream only.
2018-03-13 12:58:57 +01:00
Zdenek Kabelac
06c1f71897 dmsetup: use dm_snprintf 2018-03-13 12:58:57 +01:00
Zdenek Kabelac
3f351466f7 dmsetup: update _display_info
Handle error code.
2018-03-13 12:58:57 +01:00
Zdenek Kabelac
7ac7cc0ac8 dmsetup: update messages 2018-03-13 12:58:57 +01:00
Zdenek Kabelac
9476cf8cdc dmsetup: join large fprintf
Concatenate strings and make binary slightly smaller.
2018-03-13 12:58:57 +01:00
Zdenek Kabelac
5f5db7cf41 dmsetup: stderr to log_error 2018-03-13 12:58:57 +01:00
Zdenek Kabelac
f203d4e206 dmsetup: cleanup err usage
Macro err() add '\n'.
2018-03-13 12:58:57 +01:00
Zdenek Kabelac
3b7834af17 dmsetup: use stderr for error output
When dmsetup command returns error, the message goes to stderr.
2018-03-13 12:58:57 +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
Ondrej Kozina
32e747dd31 dmsetup: hide integrity encryption keys on table output 2017-11-10 15:23:00 +01:00
Zdenek Kabelac
e2fce429cf cleanup: gcc const warning 2017-11-07 21:26:11 +01:00
Alasdair G Kergon
4b0f6829f6 dmsetup: Add unknown device error to dmsetup status.
Treat status the same way as info if provided device name doesn't exist.
2017-10-26 17:47:13 +01:00
Alasdair G Kergon
f1cc5b12fd tidy: Add missing underscores to statics. 2017-10-18 15:58:13 +01:00
Alasdair G Kergon
d73eddcdc0 dmsetup: Process -S to filter input device lists.
The following commands now pass the device list through a
--select|-S filter before processing:

suspend resume clear wipe_table remove deps status table
2017-09-14 23:41:17 +01:00
Zdenek Kabelac
962874bfe2 dmsetup: validate strtol reading
Better validation for --mode option.
2017-08-25 14:20:59 +02:00
Zdenek Kabelac
47b7d4a733 dmsetup: add missing -- for option 2017-08-25 14:20:59 +02:00
Alasdair G Kergon
827be01758 dmsetup: Add --concise to dmsetup create.
Add the new concise format to dmsetup create, either as a single
command-line parameter or from stdin.

Based on patches submitted by
Enric Balletbo i Serra <enric.balletbo@collabora.com>.
2017-08-04 19:38:34 +01:00
Alasdair G Kergon
f9f75de3da dmsetup: Add minor number to concise table output format.
When using this new format for input, it'll sometimes help to
be able to specify the minor number.
2017-07-25 12:22:46 +01:00
Alasdair G Kergon
5fd7c0aa33 dmsetup: Add concise table output format.
Create a new table output format that concisely shows multiple devices
on one line.

dmsetup table --concise [device...]

<dev_name>,<uuid>,<flags>[,<table>]*[;<dev_name>,<uuid>,<flags>[,<table>]*]*

Table lines are separated by commas.
Devices are separated by semi-colons.
Flags is currently 'ro' or 'rw' (and might be extended in a
yet-to-be-defined way in future).
Any comma, semi-colon or backslash within a field is quoted by a
preceding backslash.

The format can later be supplied as input to dmsetup or even to the
booting kernel as an alternative way to set up devices.

Based on patches submitted by
Enric Balletbo i Serra <enric.balletbo@collabora.com>.
2017-07-25 01:13:14 +01:00
Zdenek Kabelac
0bf836aa14 tidy: prefer not using else after return
clang-tidy: avoid using  'else' after return - give more readable code,
and also saves indention level.
2017-07-20 11:18:29 +02:00
Zdenek Kabelac
0d0a3397c2 cleanup: add braces in macro 2017-07-20 11:18:29 +02:00
Zdenek Kabelac
e769e3d3bf dmsetup: simplify check of parsed cookie value
Improving parsing error detection for strtoul.
2017-07-20 11:18:16 +02:00
Zdenek Kabelac
ba9820b142 numbers: strtod or strtoul need reset of errno
API for strtod() or strtoul() needs reset of errno, before it's being
called. So add missing resets in missing places and some also some
errno validation for out-of-range numbers.
2017-07-17 12:32:18 +02:00
Bryn M. Reeves
2b46fe5843 dmsetup: replace (f)printf("\n") with putchar/putc 2017-03-30 16:30:50 +01:00
Nir Soffer
b8b2b1efd8 dmsetup: Flush ouptut when using --interval 2017-03-30 10:17:32 +01:00
Bryn M. Reeves
fe0922b8a6 dmsetup: simplify branching in _stats_update_file()
The fallback branch in _stats_update_file() is redundant (since the
branch taken when the daemon starts successfully must jump to the
'out' label anyway): remove it and re-order the conditions to
improve readability.
2017-03-30 09:57:58 +01:00
Bryn M. Reeves
5994ed9df2 dmsetup: always close fd when leaving _stats_update_file() (coverity) 2017-03-29 18:34:57 +01:00
Bryn M. Reeves
11749e7adb dmsetup: do not start dmfilemapd if region creation fails (coverity) 2017-03-29 18:34:51 +01:00
Zdenek Kabelac
e3a3cf01eb cleanup: use more common FMTd64 type
We use 'd' for plain singed integers.
2017-03-27 20:50:19 +02:00
Bryn M. Reeves
c713745314 dmsetup: always initialise 'dms' in _stats_update_file() 2017-03-10 16:44:08 +00:00
Bryn M. Reeves
6a0f597727 dmsetup: always initialise 'mode' in filemap create functions
Older compilers cannot tell that the 'mode' variable is only
used in branches in which it is assigned:

dmsetup.c:5651: warning: "mode" may be used uninitialized in this function
dmsetup.c:5023: warning: "mode" may be used uninitialized in this function

Avoid this by always assigning the variable a value.
2017-03-10 12:17:25 +00:00
Bryn M. Reeves
baa8a9be4a dmstats: start dmfilemapd when creating or updating file maps
Launch an instance of the filemap monitoring daemon when creating,
or updating, a file mapped group, unless the --nomonitor switch is
given.

Unless --foreground is given the daemon will detach from the
terminal and run in the background until it is signaled or the
daemon termination conditions are met.

The --follow={inode|path} switch is added to control the daemon
behaviour when files are moved, unlinked, or renamed while they
are being monitored.

The daemon runs with the same verbosity as the dmstats command
that starts it.
2017-03-09 18:50:15 +00:00
Alasdair G Kergon
d2dbe71fb3 dmsetup: Indicate device repetition in usage summaries. 2017-02-21 11:25:18 +00:00
Ondrej Kozina
035c614c19 dmsetup: do not suppress kernel key descriptions in tables
Kernel 4.10 (dm-crypt v1.15.0) and later supports loading device
tables with crypt segment having key in kernel keyring retention
service.

dmsetup hid key section of tables output. With this patch dmsetup
no longer hides key section if it detects kernel key description
instead of hex byte representation of key itself.
2017-02-10 19:18:49 +01:00
Bryn M. Reeves
b999d5f501 dmstats: allow --filemap groups to be updated
Add a new update_filemap command to dmstats that allows a filemap
group to be updated:

  # dmstats update_filemap --groupid 0 vm.img
  /var/lib/libvirt/images/vm.img: Updated group ID 0 with 137 region(s).

This will update the set of regions mapped to the file to reflect
the current file system allocation.

Currently this needs to be run manually - a future update will add
support for monitoring file maps via a daemon, allowing them to be
automatically updated when the underlying file is modified.
2017-01-25 16:15:21 +00:00
Bryn M. Reeves
c90e9392e4 libdm: add dm_stats_bind_from_fd()
dmsetup already has a version of this function, and dmfilemapd will
need it too: move it to libdevmapper to avoid copying it around.
2016-12-18 20:47:17 +00:00
Bryn M. Reeves
a15f0d181c dmstats: don't declare _start_timestamp if HAVE_SYS_TIMERFD_H
The _start_timestamp is not used by the TIMERFD clock.
2016-12-18 14:08:11 +00:00
Bryn M. Reeves
3e53adf7c0 dmstats: fix TIMERFD _timer_running() test 2016-12-18 14:07:25 +00:00
Bryn M. Reeves
5a4750d76c dmstats: fix interval number reporting with --count=0
When --count=0 interval numbers are miscalculated:

Interval     #18446744069414584325     time delta:    999920887ns
Interval     #18446744069414584325   current err:       -79113ns
End interval #18446744069414584325  duration:    999920887ns

This is because the command line argument is cast through the
uint32_t type, and fixed to UINT32_MAX:

  _count = ((uint32_t)_int_args[COUNT_ARG]) ? : UINT32_MAX;

We also need to handle --count=0 specially when calculating the
interval number: since intervals count from #1, this must account
for the implicit "minus one" when converting from zero to the
UINT64_MAX value used (which is too large to store in _int_args).
2016-12-18 13:03:45 +00:00
Bryn M. Reeves
5635cd3b03 dmstats: separate TIMERFD and useleep() exit conditions
The time management code mixes tests of the _timer_fd value with
code that should be timer agnostic: this causes problems for users
of the usleep() timer, since it cannot properly detect the start
of a new interval:

Beginning first interval
Interval     #18446744069414584348     time delta:   1000000000ns
Interval     #18446744069414584348   current err:            0ns
End interval #18446744069414584348  duration:   1000000000ns
Adjusted sample interval duration:   1000000000ns
[...]
Beginning first interval
Interval     #18446744069414584349     time delta:   1000000000ns
Interval     #18446744069414584349   current err:            0ns
End interval #18446744069414584349  duration:   1000000000ns
Adjusted sample interval duration:   1000000000ns

Separate these out, by defining a _timer_running() call that each
timer implements, and only define _timer_fd if we are compiling
with TIMERFD enabled.
2016-12-18 13:03:44 +00:00
Bryn M. Reeves
886b4f755d dmstats: use better interval estimate for usleep() timer
Although the usleep() interval timer is not used if the Linux
TIMERFD interface is available it should still provide reasonably
good timing.

Instead of trying to estimate the error from the duration of the
last sleep, peg it to the start time of the program, and use the
value of  ((start_time - now) % interval) to correct the current
interval duration.

This always pulls us back into sync at the end of each interval,
rather than relying on trying to incrementally adjust the time
duration at each interval start.

This greatly reduces drift when the usleep() clock is used.
2016-12-18 13:03:44 +00:00
Bryn M. Reeves
68ec42ebaf dmstats: improve tool help output and option coverage 2016-12-18 11:51:13 +00:00
Zdenek Kabelac
1d58074d9f debug: more stacktrace corrections
Continue previous patch dropping some unneeded stack traces
after printed log_error/warn messages.
2016-11-25 14:58:28 +01:00
Heinz Mauelshagen
b11f4f93d7 dmsetup: [v2] return 0 for [--]{version,help}
Leverage 0b1c796420 to cope with "dmsetup SubCommand --{help,version}"
and bail out directly when _report_init() fails.

Related: rhbz1393692
2016-11-10 18:09:37 +01:00