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

1146 Commits

Author SHA1 Message Date
Marian Csontos
91f91b80f1 post-release 2019-11-30 14:46:56 +01:00
Marian Csontos
3d7f755674 pre-release 2019-11-30 14:45:51 +01:00
Marian Csontos
c8b01f33a6 post-release 2019-10-23 09:51:55 +02:00
Marian Csontos
b9391b1b9f pre-release 2019-10-23 09:51:55 +02:00
Marian Csontos
3e01ff2783 dm: fix compilation of dmsetup
Fix: 889c88e9da
Use correct enum DM_DEVICE_GET_TARGET_VERSION.
2019-10-22 13:39:45 +02:00
Zdenek Kabelac
414f903cdc WHATS_NEW: update 2019-10-04 17:31:55 +02:00
Zdenek Kabelac
a18f562913 dmsetup: debug print
Udev debugging is a bit tricky, so to more easily pair cookie ID,
which is the lowest 16 bit - print cookie as hexa number.
This simplify pairing of processed cookies while the 'higher bit flags'
are changed for the same cookie.
2019-08-20 12:50:44 +02:00
Zdenek Kabelac
2f5ea9e61a 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-09 12:57:07 +02:00
Marian Csontos
1d1741b23a post-release 2019-06-15 09:23:03 +02:00
Marian Csontos
60bd9e8406 pre-release 2019-06-15 09:21:47 +02:00
Marian Csontos
dbc5543cbb post-release 2019-06-10 17:04:30 +02:00
Marian Csontos
f1b4aeba66 pre-release 2019-06-10 16:59:49 +02:00
Marian Csontos
4d11bf8d50 post-release 2019-06-07 17:24:51 +02:00
Marian Csontos
cb6277aa8a pre-release 2019-06-07 17:24:51 +02:00
Zdenek Kabelac
e3c4ab0cc7 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:48:41 +02:00
Zdenek Kabelac
74ae1c5bc1 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.
2019-01-21 12:52:16 +01:00
Zdenek Kabelac
3c37764333 libdm: use libdm header
User libdm header file.
2018-12-14 15:08:34 +01:00
Zdenek Kabelac
43f8da7699 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.
2018-11-17 00:30:50 +01:00
Zdenek Kabelac
1ae5bf2b83 libdm: add DM_DEVICE_ARM_POLL
Expose DM_DEVICE_ARM_POLL via standard API enum.
2018-11-17 00:30:50 +01:00
Zdenek Kabelac
10e191fd12 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-11-17 00:30:50 +01:00
Marian Csontos
420af27f08 post-release 2018-10-31 15:56:41 +01:00
Marian Csontos
913c28917e pre-release 2018-10-31 15:39:50 +01:00
Marian Csontos
9ed869cce1 post-release 2018-10-10 13:27:16 +02:00
Marian Csontos
f8462cff92 pre-release 2018-10-10 11:26:53 +02:00
Zdenek Kabelac
80e6097ea6 dmeventd: base vdo plugin
Introduce VDO plugin for monitoring VDO devices.

This plugin can be used also by other users, as plugin checks
for UUID prefix 'LVM-' and run  lvm actions only on those
devices.

Non LVM- device are only monitored and log warnings
when usage threshold reaches 80%.
2018-07-09 15:28:32 +02:00
Marian Csontos
264077907e post-release 2018-05-24 15:23:08 +02:00
Marian Csontos
adae8ee1c2 pre-release 2018-05-24 15:13:10 +02: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
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
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
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
9be086fbee thin: pass environment to scripts
When dmeventd thin plugin forks a configurable script, switch to use
execvp to pass whole environment present to dmeventd - so all configured
paths present at dmeventd startup are visible to script.

This was likely not a problem for common user enviroment,
however in test suite case variable like LVM_SYSTEM_DIR were
not actually used from test itself but rather from
a system present lvm.conf and this may have cause strange
behavior of a testing script.
2018-03-06 15:35:04 +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
ea96381534 libdm: Introduce dm_malloc_aligned 2018-01-10 15:48:03 +00:00
Alasdair G Kergon
81be333e9f post-release 2017-12-18 20:43:09 +00:00
Alasdair G Kergon
a1f7a48325 pre-release 2017-12-18 20:36:10 +00: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
e447d7ca5e libdm: support for replicator target is dropped
Replicator never really existed in upstream kernel and its support
got deprecated.

Also its support never got finished so no code is supposed to be
using it anyway.

Libdm symbols are remaining, just the implementation will always
return failure - so any user of:

dm_tree_node_add_replicator_dev_target()
dm_tree_node_add_replicator_target().

will now always recieve error message.
2017-12-04 15:38:50 +01:00
Zdenek Kabelac
63368a5064 libdm: watch for failing _info_by_dev
Separate handling of error code from _info_by_dev.
This error can only happeng when we are running out of memory.
In such case there is urgent need to stop any futher proceeding
of command and run to error ASAP.
2017-12-04 15:38:50 +01:00
Zdenek Kabelac
aa68b898ff libdm: preload propagates delayed resume
Propagate delayed resume at least for preload case in a simple way.
Currently  PVMOVE depends on internal logic where 'mirror' with
corelog is 'possible' PVMOVE. In such case resume of 'created'
node is 'delayed'.

This is mostly an ugly internal hack - but for the moment being when we
add propagation for preload - it does work reasonable.

TODO: provide standard API and avoid this internal 'guessing'.
2017-11-24 16:05:21 +01:00
Ondrej Kozina
32e747dd31 dmsetup: hide integrity encryption keys on table output 2017-11-10 15:23:00 +01:00
Alasdair G Kergon
1b6dfd4802 post-release 2017-11-03 04:42:54 +00:00
Alasdair G Kergon
29300e72ee pre-release 2017-11-03 02:28:55 +00:00
Bastian Blank
58b763c99c systemd: remove Install sections from socket-activated services
We always preferred and recommended socket activation for our services
so remove the Install section in related .service units which are unused
in this case and keep only the Install section in associated .socket
units.

Signed-off-by: Bastian Blank <waldi@debian.org>
2017-11-01 15:37:19 +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
Zdenek Kabelac
327d9d59be libdm: fix typo in libdevmapper.pc
Fixing name for RT libraries and using RT_LIBS.
2017-10-18 00:04:06 +02:00
Alasdair G Kergon
a994fc5e50 post-release 2017-10-06 22:16:58 +01:00
Alasdair G Kergon
73b72b8331 pre-release 2017-10-06 22:10:48 +01:00
Zdenek Kabelac
9940c2f754 dmeventd: schedule exit on break
When dmeventd receives SIGTERM/INT/HUP/QUIT it validates if exit is possible.
If there was any device still monitored, such exit request used to
be ignored/refused. This 'usually' worked reasonably well, however if there
is very short time period between last device is unmonitored and signal
reception - there was possibility such EXIT was ignored, as dmeventd has
not yet got into idle state even commands like 'vgchange -an' has already
finished.

This patch changes logic towards scheduling EXIT to the nearest
point when there is no monitored device.

EXIT is never forgotten.

NOTE: if there is only a single monitored device and someone sends
SIGTERM and later someone uses i.e. 'lvchange --refresh' after
unmonitoring dmeventd will exit and new instance needs to be
started.
2017-10-05 10:19:21 +02:00
Peter Rajnoha
096fcb5a6e blkdeactivate: also try to unmount /boot on blkdeactivate -u if on top of supported device
There's nothing special about /boot other than it's used during boot.
But when blkdeactivate is called either on all devices or including a
device where the /boot is on top, we should also include this mount
point when doing unmount before deactivation of supported devices.
2017-09-21 17:15:48 +02:00
Peter Rajnoha
584b4ae38b blk-availability: use blkdeactivate -r wait in blk-availability systemd service/initscript 2017-09-21 17:10:15 +02:00
Peter Rajnoha
95087c8f96 blkdeactivate: add blkdeactivate -r wait option to wait for MD resync/recovery/reshape
The new blkdeactivate -r|mdraidoption wait causes blkdeactivate to wait
for any resync/recovery/reshape that is currently in progress before
deactivating the device.

If this option is used, blkdeactivate calls mdadm -W|--wait before
mdadm -S|--stop.
2017-09-21 17:10:15 +02:00
Peter Rajnoha
7fa0d52262 blkdeactivate: fix blkdeactivate regression with failing DM/MD devs deactivation
Revert dc50f2f4a0.

We're canonicalizing/escaping the names here and we're reusing the
variable name so the code doesn't need to use extra variables and
further assignments that may confuse us. Let's keep the code simple.

The

   local name=(...$name)

is not the same as

   local name
   name=(...$name)

(I know various code-checking tools fuss about this and recommend
the 2nd way, but let's ignore those tools' nitpicking here please.)
2017-09-21 17:10:15 +02:00
Peter Rajnoha
9f34125d5d blkdeactivate: fix --{dm,lvm,mpath}options option name recognition
There was a typo in blkdeactivate --dmoption/--lvmoption/mpathoption,
it had missing "s" at the end and it was not recognized properly, only
short names for the options (-d/-l/-m).
2017-09-21 17:08:44 +02:00
Zdenek Kabelac
a02db1c45a libdm: fix parentheses in assignment + comparison
As reported, fix incorrect placement of parentheses.
TODO: add testing code.
2017-09-20 15:14:16 +02: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
Alasdair G Kergon
71dbe0fe26 post-release 2017-09-13 20:46:25 +01:00
Alasdair G Kergon
918f0a92da pre-release 2017-09-13 20:38:29 +01:00
Zdenek Kabelac
0e42b31dc3 libdm: fix errpath for control node creation
When control node failure happens, umask was not restored.
Fix it by using common exit path.
2017-08-22 10:23:29 +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
e6afe9e782 ioctl: Allow minor without major.
There's no need to insist on a major number being supplied when the
code's going to override it if it's wrong anyway.
2017-08-04 14:45:20 +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
Alasdair G Kergon
8e0c5d0cb6 post-release 2017-07-20 17:19:09 +01:00
Alasdair G Kergon
88f1565937 pre-release 2017-07-20 16:57:27 +01:00
Peter Rajnoha
c48149cf80 udev: also create /dev/disk/by-part{label,uuid} and gpt-auto-root symlinks
The blkid we call in 13-dm-disk.rules also returns identifiers for
partitions based on which the /dev/disk/by-part{uuid,label} and
gpt-auto-root symlinks should be created in the same manner as we
already create symlinks for filesystem labels and uuids.

This is because we handle blkid calls and symlink creation under
/dev/disk ourselves in our 13-dm-disk.rules for device-mapper devices
for us to have more control over this process.

See also https://lists.freedesktop.org/archives/systemd-devel/2017-July/039220.html
and original report http://tracker.ceph.com/issues/19489 for
the exact case where these symlinks were missing.
2017-07-10 12:36:39 +02:00
Alasdair G Kergon
0021d707fb post-release 2017-06-28 17:00:49 +01:00
Alasdair G Kergon
08ce545449 pre-release 2017-06-28 16:38:46 +01:00
Zdenek Kabelac
4e4067dd94 libdm: fix initialization of head for reused structure
Dmeventd reuses  'dm_task' struct for some STATUS operation, but due to
missing reinitization of dm_task target list, it has caused misprocesing
of recieved events as the parsed target has been simply added to the
list of existing status and cause multiple actions being called for
single event.
2017-06-26 19:45:11 +02:00
Zdenek Kabelac
2ef8da61eb libdm: implement dm_percent_to_round_float
Add function to adjust printing of percent values in better way.
Rounding here is going along following rules:

0% & 100% are always clearly reported with  .0 decimal points.

Values slightly above 0% we make sure a nearest bigger
non zero value with given precission is printed
(i.e. 0.01  for  %.2f  will be shown)

For values closely approaching 100% we again detect and adjust value
that is less then 100 when printed.
(i.e. 99.99  for %.2f will be shown).

For other values we are leaving them with standard rounding mechanism
since we care mainly about corner values 0 & 100 which need to be
printed precisely.
2017-06-24 17:44:40 +02:00
Zdenek Kabelac
0016b79c8b dmeventd: improve more raid status reporting
When we want to report primary leg failure, check for intial 'a',
since otherwice 'Aa idle' is normally visible.

Also reset array of bit flags marking dead devices, once
plugin detects raid is in sync.
2017-06-24 00:06:12 +02:00
Zdenek Kabelac
653bdedb83 raid: plugin does not to use --config
Functionality of ignore suspend devices is already granted by:

lvm2_disable_dmeventd_monitoring() -> init_run_by_dmeventd() ->
init_ignore_suspended_devices().

In fact plugins should never use --config because it has
some unpleasant technical issues.
2017-06-23 23:32:40 +02:00
Zdenek Kabelac
529dcaf6a3 libdm: workarounds reported raid status info
Current existing kernels reports status sometimes in weird form.

Instead of showing what is the exact progress, we need to estimate
this in-sync state from several surrounding states.

Main reason here is to never report 100% sync state for a raid device
which will be undergoing i.e. recovery.
2017-06-16 17:04:00 +02:00
Bryn M. Reeves
744f2920db libdm: allow truncated files in dm_stats_update_regions_from_fd()
It's not an error to attempt to update regions from an fd that has
been truncated (or otherwise no longer has any allocated extents):
in this case, the call should remove all regions corresponding to
the group, and return an empty region table.
2017-06-13 19:45:50 +01:00
Zdenek Kabelac
455a4de090 dmeventd: restore multiple warnings
With recent updates for thin pool monitoring in version 169
we lost multiple WARNINGs to be printed in syslog, when
pool crossed  80%, 85%, 90%, 95%, 100%.

Restore this logic as we want to keep user informed more
then just once when 80% boundary is passed.
2017-05-10 15:39:36 +02:00
Alasdair G Kergon
a946327bb7 post-release 2017-05-03 11:26:58 +01:00
Alasdair G Kergon
fb4bf1f4ea pre-release 2017-05-03 11:23:31 +01:00
Alasdair G Kergon
658d524d26 configure: Fix notify-dbus and dmfilemapd options. 2017-04-18 20:37:53 +01:00
Alasdair G Kergon
ae7f696d53 post-release 2017-04-13 01:47:47 +01:00
Alasdair G Kergon
b9a16fe73b pre-release 2017-04-13 00:43:31 +01:00
Zdenek Kabelac
635e7e0c92 libdm: set min,maj
Reset derefered pointers instead of pointers.
2017-04-12 21:33:47 +02:00
Bryn M. Reeves
f5b0697c05 WHATS_NEW_DM: add recent dmsetup and dmfilemapd entries 2017-04-12 17:41:29 +01:00
Alasdair G Kergon
0c2f7ed49a post-release 2017-03-28 16:14:03 +01:00
Alasdair G Kergon
396377bc03 pre-release
Removing some unused new lines and changing some incorrect "can't
release until this is fixed" comments.  Rename license.txt to make
it clear its merely an included file, not itself a licence.
2017-03-28 16:11:35 +01:00
Zdenek Kabelac
bb20fac4ab libdm: maintain binary interface for new FEATURE flag
Older library version was not detecting unknown 'feature' bits
and could let start target without needed option.

New versioned symbol now checks for supported feature bits.
_Base version keeps accepting only previously known features and
mask/ignores unknown bits.

NB: if the older binary passed in 'random' bits, it will not get
metadata2 by chance. New linked binary get new validation function.
Library user is required to not pass 'trash' for unsupported bits,
as such calls will be rejected.
2017-03-10 19:33:01 +01:00
Zdenek Kabelac
ddd5a76801 libdm: support cache metadata2 feature flag
Dm cache target version 1.10 introduces new cache metadata format
(upstream kernel >=4.11).

New format is enable by passing new target feature flag metadata2.
Interace side on libdm uses DM_CACHE_FEATURE_METADATA2.
This feature bit is now also recognized on status
and set in 'feature_flags' field of dm_status_cache structure.

Code also adds check for 'highest' supported feature flag bit.
So it rejects properly any 'unknown' feature bit set by application.
2017-03-10 19:33:01 +01:00
Zdenek Kabelac
bf79fb1a33 libdm: better code to enforce writethrough
Better code to enforce writethrough caching for cleaner policy.
Only check for cleaner when DM_CACHE_FEATURE_PASSTHROUGH or
DM_CACHE_FEATURE_WRITEBACK is set.
2017-03-10 19:33:01 +01:00
Zdenek Kabelac
edf5e43f9a libdm: passthrough checks traling space char
When checking for passthrough length, check also for extra ' ' char
just like with other feature strings.
2017-03-10 19:33:01 +01:00
Zdenek Kabelac
2a9eda1229 mem: add extra mem pages for pthread stack
Some archs can use even 64K pages and then lvm2 runs into trouble if
the stack is 'too small' to fit extra page capturing stack overwrite.

So when lvm2 limits stack - add extra mem page - be it 4K or 64K.

Relates to ppc64le bug: https://bugzilla.redhat.com/1387279
2017-02-11 18:23:15 +01:00
Zdenek Kabelac
c908a8b131 libdm: avoid resume if preloaded device is smaller
When we preload device with smaller size, we avoid its resume,
so later suspend/resume of full device tree my process all
existing in flight bios.

Also update comment and avoid using confusing opposite meaning.
2017-02-10 20:29:11 +01: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
Zdenek Kabelac
85dab3963f dmeventd_thin: enable support for external command
With this commit we start to support configurable action
from thin-pool monitoring via  'dmeventd/thin_command'
2017-01-21 00:01:05 +01:00
Zdenek Kabelac
f8234d6e5f libdm: add human R|readable units
When showing sizes with 'H|human' units we do use standard rounding.
This however is confusing users from time to time,
when the printed number uses some biger units i.e. GiB and there is just
tiny fraction of space missing.

So here is some real-life example with new 'r' unit.

$lvs

  LV    VG Attr       LSize  Pool Origin
  lvol0 vg -wi-a-----  1.99g
  lvol1 vg -wi-a----- <2.00g
  lvol2 vg -wi-a----- <2.01g

Meaning is - lvol1 has 'slightly' less then 2.00g - from sign '<' user
can be aware the LV doesn't have full 2.00GiB in size so he
will be less surpriced allocation of 2G volume will not succeed.

$ vgs
  VG #PV #LV #SN Attr   VSize  VFree
  vg   2   2   0 wz--n- <6,00g <2,01g

For uses needing  'old'  undecorated human unit simply will continue
to use 'H|h' units.

The new R|r  may further change when we would recongnize some
other way how to improve readability.
2017-01-20 23:52:17 +01:00
Zdenek Kabelac
dd19b56985 thin: refresh status when error processing fails
When thin-pool processes event and 'lvextend --use-policies' fails
rather capture up-to-date new info as the fullness percentage may
have jumped noticable. This way we could use 'more' correct numbers
when checking for thresholds.
2016-12-22 23:37:07 +01: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
Zdenek Kabelac
954c59779d libdm: drop callback on revert path
The system is likely in some very inconsisten state.
Do not try to make it even more problematic with trying
to invoke tools like thin_check via callback.
2016-12-18 19:29:08 +01:00
Bryn M. Reeves
93f420caf4 libdm: fix _stats_get_extents_for_file()
Handle files that contain multiple logical extents in a single
physical extent properly:

  - In FIEMAP terms a logical extent is a contiguous range of
    sectors in the file's address space.

  - One or more physically adjacent logical extents comprise a
    physical extent: these are the disk areas that will be mapped
    to regions.

  - An extent boundary occurs when the start sector of extent
    n+1 is not equal to (n.start + n.length).

This requires that we accumulate the length values of extents
returned by FIEMAP until a discontinuity is found (since each
struct fiemap_extent returned by FIEMAP only represents a single
logical extent, which may be contiguous with other logical
extents on-disk).

This avoids creating large numbers of regions for physically
adjacent (logical) extents and fixes the earlier behaviour which
would only map the first logical extent of the physical extent,
leaving gaps in the region table for these files.
2016-12-13 09:09:25 +00:00
Zdenek Kabelac
6f84d3c69c libdm: validate vsnprintf
Avoid using buffer when no output has been generated.
Missed in ee13f265f0.
2016-12-11 23:24:17 +01:00
Bryn M. Reeves
d8ba8ee9ae libdm: use a private pool for filemap extent table
When mapping regions to a file descriptor, a temporary table of
extent descriptors is built using the dm_pool object building
interface.

Previously this use borrowed the dms->mem region and counter
table pool (since nothing can interleave with the allocation
while the caller is still in dm_stats_create_regions_from_fd()).

This turns out to be problematic for error recovery. When a
region creation operation fails partway through file mapping,
we need to roll back the set of already created regions and
this requires a listed handle: the dm_stats_list() will then
allocate from the same pool as the extents; we either have
to throw away valid list data, or leak the extent table, to
return the handle in a valid state.

Avoid this problem by creating a new, temporary mem pool in
_stats_create_file_regions() to hold the extent data, and
discarding it on exit from the function.
2016-12-10 13:31:12 +00:00