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

13400 Commits

Author SHA1 Message Date
Bryn M. Reeves
930b0b4c9e libdm: fix start of file detection in _stats_map_extents() 2016-12-13 20:25:47 +00:00
Bryn M. Reeves
eb65572217 libdm: break up _stats_get_extents_for_file()
Split out the loop that iterates over each batch of FIEMAP
extent data from the function that sets up and calls the ioctl
to reduce nesting and simplify local variable use:

  _stats_get_extents_for_file()
  ->  _stats_map_extents()

The _stats_map_extents() function is responsible for detecting
eof and extent boundaries and adding whole, allocated extents
to the file extent table for region creation.
2016-12-13 20:25:45 +00:00
Bryn M. Reeves
ea9af3e290 libdm: fix dm_stats_foreach_group() macro 2016-12-13 20:01:00 +00:00
Bryn M. Reeves
8e33972828 libdm: check for non-existent region_id values in groups
Check that all region_id values specified in a group bitmap are
actually present: although this should not normally happen when
using the dmstats tool, it is possible as a result of manual
changes (or bugs) for a group descriptor to contain one or more
group_id values that do not exist.

Check for this situation when reading group descriptors, warn
the user the user, and clear these bits in the bitmap when
formatting it for output.
2016-12-13 15:37:48 +00:00
Bryn M. Reeves
99b6d82e2d libdm: fix segfault with invalid group descriptor
If a region has a a DMS_GROUP tag in aux_data where the first
region_id in the bitmap is not the same as the containing region,
dmstats will segfault:

  # '2' is never a valid group bitset list for region_id == 0
  # dmsetup message vg_hex/root 0 "@stats_set_aux 0 DMS_GROUP=img:2#"

  # dmsetup message vg_hex/root 0 "@stats_list"
  0: 45383680+16384 16384 dmstats DMS_GROUP=img:2#
  1: 46071808+32768 32768 dmstats -
  2: 47382528+16384 16384 dmstats -

  # dmstats list
  Segmentation fault (core dumped)

The crash will occur in some arbitrary dm_stats_get_* property
method - this happens while processing the 1st region_id in the
bitset, because the region is marked as grouped, but there is
no group bitmap present at dms->groups[2]->regions.

Fix this by detecting a mismatch between the expected region_id
and dm_bit_get_first() for the parsed bitset during
_parse_aux_data_group().
2016-12-13 14:37:41 +00:00
Bryn M. Reeves
138e4336fd libdm: fix region overlap tests 2016-12-13 09:09:29 +00: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
Heinz Mauelshagen
87117c2b25 lvchange: allow a transiently failed RaidLV to be refreshed
Enhance commit 0b8bf73a63 to refresh the top-level LV correctly
in case of a clustered, remotely activated RaidLV.

Related: rhbz1399844
2016-12-12 22:08:47 +01:00
Zdenek Kabelac
75ec7c8dee tests: update seg_size_pe
Default prepare_vg uses 512K - so update test accordingly
2016-12-12 11:51:50 +01:00
Zdenek Kabelac
3dd6e2c7e1 tests: use prepare_vg more often 2016-12-12 11:22:41 +01:00
Zdenek Kabelac
8c9c6ab660 tests: no left devices check for skipped test 2016-12-12 11:22:10 +01:00
Zdenek Kabelac
48d33e5fb6 cov: use unsigned for single bit values
Avoid using signed int.
2016-12-12 11:21:42 +01:00
Zdenek Kabelac
56e4e2ce2b tests: track leaked devices in tests
When test calls teardown, no devices created by test are expected
to be left in table. Trap such orphans and make the test fail.
2016-12-11 23:24:19 +01:00
Zdenek Kabelac
273ccb1170 tests: remove unwanted exit
Exit seemes slipped in from local testing in:
eb6b2a11e3
2016-12-11 23:24:19 +01:00
Zdenek Kabelac
b902fd08f6 tests: remove some leaking device
These tests leaks devices (known bugs).
Remove them via dmsetup.

TODO: fix actual commands
2016-12-11 23:24:19 +01:00
Zdenek Kabelac
bcf59a1b18 tests: test should clean devices it has created
To be able to detect lvm2 command is not leaking some
'unexpected' device - remove all devices before
test exits by its own command so test teardown
now can check what was 'left' unexpectedly.
2016-12-11 23:24:19 +01:00
Zdenek Kabelac
198f335139 tests: slower device
Some of test machines are too fast, slow raid syncing even more.
2016-12-11 23:24:19 +01:00
Zdenek Kabelac
4a33e4c509 cov: declaration matching 2016-12-11 23:24:19 +01:00
Zdenek Kabelac
b8c729efd0 cov: add internal error for impossible code path 2016-12-11 23:24:19 +01:00
Zdenek Kabelac
794093722c debug: missing stack traces 2016-12-11 23:24:19 +01:00
Zdenek Kabelac
dc7d3dd5ed cleanup: use NAME_LEN stack buffer
Using NAME_LEN we get at least easy max LV name size validation.
Also code gets more simple.
2016-12-11 23:24:19 +01:00
Zdenek Kabelac
6cd68c55dd cleanup: reuse existing function
Call lv_update_and_reload implementation.
2016-12-11 23:24:19 +01: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
Zdenek Kabelac
3903f915f8 pvmove: fix activation order
For proper locking we need to gain lock first for mirror which
needs to be deactivated later to be working in cluster.
2016-12-11 23:22:36 +01:00
Zdenek Kabelac
67f9e6b175 raid: avoid _ at end of name of extracted metadata LV
Do not generate @PREFIX@vg/LV1_rmeta_1_extracted_.
2016-12-11 23:20:51 +01:00
Zdenek Kabelac
55ca8043d4 raid: optimize clearing of lvs
Activate whole list of metadata lvs first before clearing them.
(Similar to commit ada5733c56)

TODO: make this clearing in a single common function.
2016-12-11 23:19:41 +01:00
Zdenek Kabelac
8831a541a8 raid: fix delete on clustered vg
For clustered VG ensure lock is grabbed first,
so later deactivation works.

TODO: fix tree to solve device removal automatically.
2016-12-11 23:18:22 +01:00
Zdenek Kabelac
0c8369099b raid: fix raid1 to mirror conversion
Fix order of operation when converting raid1 into old mirror.
Before any later metadata modification are initiated prepare
mirror_log device with all clearing.
Then directly convert  raid1 into mirror with mirror_log.
This convertion now properly see as precommitted metadata
new 'mirror' and committed old 'raid' and is able to
preload all LVs.
2016-12-11 23:17:22 +01:00
Zdenek Kabelac
31564834db mirror: add prepare_mirror_log
Function prepares new mirror log LV in-sync optionaly.
This is useful to have such device ready when converting
raid1 to mirror.
2016-12-11 23:16:16 +01:00
Bryn M. Reeves
b9f9ce52ec test: add results/ to .gitignore 2016-12-10 18:00:25 +00:00
Bryn M. Reeves
14c20ae217 lvmdbusd: add path.py to .gitignore 2016-12-10 17:59:07 +00:00
Bryn M. Reeves
f9c9772a80 scripts: add systemd unit files to .gitignore
com.redhat.lvmdbus1.service
lvm2_lvmdbusd_systemd_red_hat.service

.gitignore
2016-12-10 17:58:10 +00:00
Bryn M. Reeves
383683ffd3 scripts: add lvmdump.sh to .gitignore 2016-12-10 17:56:56 +00:00
Bryn M. Reeves
b311122a56 libdm: fix filemap cleanup loop condition 2016-12-10 13:31:12 +00: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
Bryn M. Reeves
1de3e106c9 doc: add filemap creation fixes to WHATS_NEW_DM 2016-12-10 12:02:30 +00:00
Bryn M. Reeves
2d1dbb9edd libdm: fix performance of failed filemap cleanup
While cleaning up the table of already created regions during a
failed dm_stats_create_regions_from_fd(), list the handle once,
and call _stats_delete_region() directly. This avoids sending a
@stats_list message for each region deleted, reducing runtime
from 6s to 0.7s when cleaning up ~250 out of ~10000 regions:

  # time dmstats create --filemap b.img
  device-mapper: message ioctl on (253:0) failed: Cannot allocate memory
  Failed to create region 246 of 309 at 9388032.
  Could not create regions from file /root/b.img
  << pauses here >>
  Command failed

  real	0m6.267s
  user	0m3.770s
  sys	0m2.487s

  # time dmstats create --filemap b.img
  device-mapper: message ioctl on (253:0) failed: Cannot allocate memory
  Failed to create region 246 of 309 at 9388032.
  Could not create regions from file /root/b.img
  Command failed

  real	0m0.716s
  user	0m0.034s
  sys	0m0.581s

Testing the error path requires region creation to start to
fail part way through the operation (in order to have regions
to clean up): the simplest way is to ensure the system is
close to the kernel limit of 1/4 RAM or 1/2 vmalloc space
consumed by dmstats data.
2016-12-10 11:59:16 +00:00
Bryn M. Reeves
97c4490cc5 libdm: split off internal _stats_delete_region()
Split dm_stats_delete_region() so that internal callers can manage
the handle state themselves.

dm_stats_delete_region() now just handles checking the state of the
handle, reporting validation errors, and calling dm_stats_list() if
necessary, before calling _stats_delete_region().

The new _stats_delete_region() function performs the actual group
member removal and region deletion, and requires a fully listed
handle to operate.

Callers that repeatedly delete regions can use a single listed
handle for many operations on the same device, avoiding one
message ioctl per region deleted: since @stats_list with many
regions is expensive, this yields large runtime improvements.
2016-12-10 11:57:14 +00:00
David Teigland
c459f23565 lvmetad: fix segfault in daemon_reply_simple
missing NULL termination
2016-12-09 15:22:30 -06:00
Bryn M. Reeves
30ad254d84 libdm: use correct region_id when cleaning up a failed filemap
If we fail to create a region during dm_stats_create_regions_from_fd(),
we must remove all regions that were created to do this to date. This
needs to loop over the table of region_id values that were populated
by _stats_create_file_regions() before the error.

The code for this failure case in the out_remove branch incorrectly
uses the table index as the region_id:

    for (--i; i != DM_STATS_REGION_NOT_PRESENT; i--) {
            if (!dm_stats_delete_region(dms, i))
                    log_error("Could not delete region " FMTu64 ".", i);
    }

This causes the cleanup code to delete a completely unrelated set
of regions (since the index here will always be nr_regions..0).

Fix it to pass the actual region_id stored in regions[i] instead.
2016-12-09 16:04:13 +00:00
Bryn M. Reeves
7fd2fa22dd libdm-stats: clear dms->groups in _stats_groups_destroy() 2016-12-09 16:04:13 +00:00
Bryn M. Reeves
cb8c04760f libdm-stats: clear dms->regions in _stats_regions_destroy() 2016-12-09 16:04:13 +00:00
Zdenek Kabelac
900d203586 tests: fix missing exclusive activation
For cluster conversion  LV for caching needs to be activated
exclusively.
2016-12-09 15:15:02 +01:00
Zdenek Kabelac
c5aeb21015 cleanup: zero baton in struct initilizer 2016-12-09 15:15:02 +01:00
Zdenek Kabelac
f9c6c115d3 cleanup: easier code for raid plugin
Set bits only when then were not yet assigned.
2016-12-09 15:15:02 +01:00
Zdenek Kabelac
15e4ab3e93 cleanup: messages in raid
Use display_lvname and add 'dots'.
Add some missing WARNING and log_debug_metadata.
2016-12-09 15:15:02 +01:00
Bryn M. Reeves
6dd0bd0255 libdm-stats: fix dm_stats_delete_region() performance
Fix a silly bug in dm_stats_delete_region() that hugely inflates
runtimes when deleting a large number of regions.

For ~50,000 regions this change reduces the runtime from 98s to
6s on my test systems (a ~93% reduction).

The bug exists because dm_stats_delete_region() applies a truth
test to the return value of dm_stats_get_nr_areas(); this is
never correct usage - it will walk the entire region table and
calculate area counts for each region (which is roughly O(n^2)
in the number of regions, as dm_stats_delete_region() is being
called inside a region walk).

Although the individual area calculation is not that costly,
uselessly running anything 2,500,000,000 times over gets a bit
slow.

A much cheaper test (which is always true if the areas check is
true) is to just test dm_stats_get_nr_regions() or dms->regions;
if either is true it implies at least one area exists.

Old:

 Performance counter stats for 'dmstats delete --allregions --alldevices':

      98117.791458      task-clock (msec)         #    1.000 CPUs utilized
               127      context-switches          #    0.001 K/sec
                 3      cpu-migrations            #    0.000 K/sec
             6,631      page-faults               #    0.068 K/sec
   307,711,724,562      cycles                    #    3.136 GHz
   544,762,959,577      instructions              #    1.77  insn per cycle
    84,287,824,115      branches                  #  859.047 M/sec
         2,538,875      branch-misses             #    0.00% of all branches

      98.119578733 seconds time elapsed

New:

 Performance counter stats for 'dmstats delete --allregions --alldevices':

       6427.251074      task-clock (msec)         #    1.000 CPUs utilized
                 6      context-switches          #    0.001 K/sec
                 0      cpu-migrations            #    0.000 K/sec
             6,634      page-faults               #    0.001 M/sec
    21,613,018,724      cycles                    #    3.363 GHz
     3,794,755,445      instructions              #    0.18  insn per cycle
       852,974,026      branches                  #  132.712 M/sec
           808,625      branch-misses             #    0.09% of all branches

       6.428953647 seconds time elapsed
2016-12-09 10:55:39 +00:00
Zdenek Kabelac
0ce9ae3cda tests: more snaps
Check lvs reports 'origin' not openned.
2016-12-05 17:12:42 +01:00
Zdenek Kabelac
3f6ade4b0d tests: apostrof 2016-12-05 17:12:42 +01:00
Zdenek Kabelac
022d3af068 tests: check we recognize broken table entry
One (initial) test to recognize we see a mismatching
table entry for cache LV.
2016-12-05 17:12:42 +01:00