summaryrefslogtreecommitdiff
path: root/libdm/libdevmapper.h
Commit message (Collapse)AuthorAgeFilesLines
* libdm: report: add DM_REPORT_GROUP_JSON_STD groupPeter Rajnoha2022-08-111-1/+2
| | | | | | | The original JSON formatting will be still available using the original DM_REPORT_GROUP_JSON identifier. Subsequent patches will add enhancements to JSON formatting code so that it adheres more to JSON standard - this will be identified by new DM_REPORT_GROUP_JSON_STD identifier.
* libdm: dmsetup measure support for IMAAlasdair G Kergon2021-09-231-0/+1
| | | | | | | Add support for DM_IMA_MEASUREMENT_FLAG with DM_TABLE_STATUS_CMD. This feature requires DM version 4.45 (5.15+ kernels)
* libdm: eliminate some abi-dumper errorsZdenek Kabelac2021-04-061-19/+19
| | | | | | | | | ABI dumper does not like missing enum/union/struct names, so add them with _e, _u suffix. Usage reference: https://doc.dpdk.org/guides-16.04/contributing/versioning.html
* libdm: add dm_tree_node_add_thin_pool_target_v1Zdenek Kabelac2021-02-011-3/+13
| | | | Supports thin-pool without crop.
* gcc: keep using unsigned typeZdenek Kabelac2020-09-011-1/+1
|
* gcc: zero-sized array to fexlible array C99Zdenek Kabelac2020-09-011-3/+3
| | | | | | | | | | | | | | 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.
* container_of: drop needless const converionZdenek Kabelac2020-08-281-1/+1
|
* libdm: fix dm_list pointer arithmentic for new gcc 10 optimizationZdenek Kabelac2020-03-051-2/+3
|
* dm: fix compilation of dmsetupMarian Csontos2019-10-221-1/+1
| | | | | Fix: 889c88e9dab33195efc4dc0400a4b0aaa3383948 Use correct enum DM_DEVICE_GET_TARGET_VERSION.
* dm: introduce DM_GET_TARGET_VERSIONMikulas Patocka2019-10-041-1/+3
| | | | | | | | 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>
* cache: support no_discard_passdownZdenek Kabelac2019-06-051-0/+1
| | | | | | | | | | | | | | | | | 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).
* libdm: add DM_DEVICE_ARM_POLLZdenek Kabelac2018-11-171-1/+3
| | | | Expose DM_DEVICE_ARM_POLL via standard API enum.
* libdm: Introduce dm_malloc_alignedAlasdair G Kergon2018-01-101-0/+3
|
* libdm: implement dm_percent_to_round_floatZdenek Kabelac2017-06-241-0/+10
| | | | | | | | | | | | | | | | | | | 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.
* Revert "raid: adjust to misordered raid table line output"Heinz Mauelshagen2017-03-231-10/+0
| | | | | | | This reverts commit 1e4462dbfbd2bbe3590936df24b3ccd83110b158 in favour of an enhanced solution avoiding changes in liblvm completetly by checking the target versions in libdm and emitting the respective parameter lines.
* raid: adjust to misordered raid table line outputHeinz Mauelshagen2017-03-211-0/+10
| | | | | | | | | | | | | | | | The libdevmapper interface compares existing table line retrieved from the kernel to new table line created to decide if it can suppress a reload. Any difference between input and output of the table line is taken to be a change thus causing a table reload. The dm-raid target started to misorder the raid parameters (e.g. 'raid10_copies') starting with dm-raid target version 1.9.0 up to (excluding) 1.11.0. This causes runtime failures (limited to raid10 as of tests) and needs to be reversed to allow e.g. old lvm2 uspace to run properly. Check for the aforementioned version range and adjust creation of the table line to the respective (mis)ordered sequence inside and correct order outside the range (as described for the raid target in the kernels Documentation/device-mapper/dm-raid.txt).
* dmfilemapd: ensure path argument is absoluteBryn M. Reeves2017-03-131-0/+4
| | | | | | | | Require that the path argument to dmfilemapd be an absolute path and document this in tool output, libdevmapper.h and dmfilemapd.8. The check is also enforced by dm_stats_start_filemapd() to avoid forking a new process with an invalid path argument.
* libdm: support cache metadata2 feature flagZdenek Kabelac2017-03-101-1/+2
| | | | | | | | | | | | | 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.
* daemons: add dmfilemapdBryn M. Reeves2017-03-091-0/+63
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Add a daemon that can be launched to monitor a group of regions corresponding to the extents of a file, and to update the regions as the file's allocation changes. The daemon is intended to be started from a library interface, but can also be run from the command line: dmfilemapd <fd> <group_id> <path> <mode> [<foreground>[<log_level>]] Where fd is a file descriptor open on the mapped file, group_id is the group identifier of the mapped group and mode is either "inode" or "path". E.g.: # dmfilemapd 3 0 vm.img inode 1 3 3<vm.img ... If foreground is non-zero, the daemon will not fork to run in the background. If verbose is non-zero, libdm and daemon log messages will be printed. It is possible for the group identifier to change when regions are re-mapped: this occurs when the group leader is deleted (regroup=1 in dm_stats_update_regions_from_fd()), and another region is created before the daemon has a chance to recreate the leader region. The operation is inherently racey since there is currently no way to atomically move or resize a dm_stats region while retaining its region_id. Detect this condition and update the group_id value stored in the filemap monitor. A function is also provided in the the stats API to launch the filemap monitoring daemon: int dm_stats_start_filemapd(int fd, uint64_t group_id, const char *path, dm_filemapd_mode_t mode, unsigned foreground, unsigned verbose); This carries out the first fork and execs dmfilemapd with the arguments specified. A dm_filemapd_mode_t value is specified by the mode argument: either DM_FILEMAPD_FOLLOW_INODE, or DM_FILEMAPD_FOLLOW_PATH. A helper function, dm_filemapd_mode_from_string(), is provided to parse a string containing a valid mode name into the appropriate dm_filemapd_mode_t value.
* lvconvert: libdm RAID API compatibility versioning; remove new functionHeinz Mauelshagen2017-03-011-9/+0
| | | | | | | | | | | Commit 80a6de616a19 versioned the dm_tree_node_add_raid_target_with_params() and dm_tree_node_add_raid_target() APIs for compatibility reasons. There's no user of the latter function, remove it. Related: rhbz834579 Related: rhbz1191935 Related: rhbz1191978
* lvconvert: libdm RAID API compatibility versioningHeinz Mauelshagen2017-02-281-10/+53
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Commit 27384c52cf6a lowered the maximum number of devices back to 64 for compatibility. Because more members have been added to the API in 'struct dm_tree_node_raid_params *', we have to version the public libdm RAID API to not break any existing users. Changes: - keep the previous 'struct dm_tree_node_raid_params' and dm_tree_node_add_raid_target_with_params()/dm_tree_node_add_raid_target() in order to expose the already released public RAID API - introduce 'struct dm_tree_node_raid_params_v2' and additional functions dm_tree_node_add_raid_target_with_params_v2()/dm_tree_node_add_raid_target_v2() to be used by the new lvm2 lib reshape extentions With this new API, the bitfields for rebuild/writemostly legs in 'struct dm_tree_node_raid_params_v2' can be raised to 256 bits again (253 legs maximum supported in MD kernel). Mind that we can limit the maximum usable number via the DEFAULT_RAID{1}_MAX_IMAGES definition in defaults.h. Related: rhbz834579 Related: rhbz1191935 Related: rhbz1191978
* lvconvert: limit libdm to maximum of 64 RAID devicesHeinz Mauelshagen2017-02-271-1/+10
| | | | | | | | | | | | | | | | | Commit 64a2fad5d6c6 raised the maximum number of RAID devices to 64. Commit e2354ea344c2 introduced RAID_BITMAP_SIZE as 4 to have 256 bits (4 * 64 bit array members), thus changing the libdm API unnecessarilly for the time being. To not change the API, reduce RAID_BITMAP_SIZE to 1. Remove an unneeded definition of it from libdm-common.h. If we ever decide to raise past 64, we'll version the API. Related: rhbz834579 Related: rhbz1191935 Related: rhbz1191978
* lvconvert: add infrastructure for RaidLV reshaping supportHeinz Mauelshagen2017-02-241-6/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In order to support striped raid5/6/10 LV reshaping (change of LV type, stripesize or number of legs), this patch introduces infrastructure prerequisites to be used by raid_manip.c extensions in followup patches. This base is needed for allocation of out-of-place reshape space required by the MD raid personalities to avoid writing over data in-place when reading off the current RAID layout or number of legs and writing out the new layout or to a different number of legs (i.e. restripe) Changes: - add members reshape_len to 'struct lv_segment' to store out-of-place reshape length per component rimage - add member data_copies to struct lv_segment to support more than 2 raid10 data copies - make alloc_lv_segment() aware of both reshape_len and data_copies - adjust all alloc_lv_segment() callers to the new API - add functions to retrieve the current data offset (needed for out-of-place reshaping space allocation) and the devices count from the kernel - make libdm deptree code aware of reshape_len - add LV flags for disk add/remove reshaping - support import/export of the new 'struct lv_segment' members - enhance lv_extend/_lv_reduce to cope with reshape_len - add seg_is_*/segtype_is_* macros related to reshaping - add target version check for reshaping - grow rebuilds/writemostly bitmaps to 246 bit to support kernel maximal - enhance libdm deptree code to support data_offset (out-of-place reshaping) and delta_disk (legs add/remove reshaping) target arguments Related: rhbz834579 Related: rhbz1191935 Related: rhbz1191978
* libdm: add dm_stats_update_regions_from_fd()Bryn M. Reeves2017-01-251-0/+32
| | | | | | | | | | | | | | | | | | | | | | | Add a call to update the regions corresponding to a file mapped group of regions. The regions to be updated must be grouped, to allow us to correctly identify extents that have been deallocated since the map was created. Tables are built of the file extents, and the extents currently mapped to dmstats regions: if a region no longer has a matching file extent, it is deleted, and new regions are created for any file extents without a matching region. The FIEMAP call returns extents that are currently in-memory (or journaled) and awaiting allocation in the file system. These have the FIEMAP_EXTENT_UNKNOWN | FIEMAP_EXTENT_DELALLOC flag bits set in the fe_flags field - these extents are skipped until they have a known disk location. Since it is possile for the 0th extent of the file to have been deallocated this must also handle the possible deletion and re-creation of the group leader: if no other region allocation is taking place the group identifier will not change.
* libdm: fix stats comment formatting in libdevmapper.hBryn M. Reeves2017-01-241-3/+3
|
* libdm: add dm_stats_bind_from_fd()Bryn M. Reeves2016-12-181-0/+10
| | | | | dmsetup already has a version of this function, and dmfilemapd will need it too: move it to libdevmapper to avoid copying it around.
* libdm: use destination size as limit in dm_bit_copy()Bryn M. Reeves2016-12-141-1/+1
| | | | | | | | | | | | | | | | | | | | | The dm_bit_copy() macro uses the source (bs1) bitset size as the limit for memcpy: memcpy((bs1) + 1, (bs2) + 1, ((*(bs1) / DM_BITS_PER_INT) + 1)..) This is safe if the destination bitset is smaller than the source, or if the two bitsets are of the same size. With a destination that is larger (e.g. when resizing a bitmap to add more capacity), the memcpy will overrun the source bitset and set garbage bits in the destination. There are nine uses of the macro currently (8 in libdm/regex, and 1 in daemons/cmirrord): in each case the two bitsets are always of equal size so the behaviour is unchanged. Fix the macro to use bs2's size to simplify resizing bitsets and avoid the need for another copy macro.
* libdm: add min_num_bits to dm_bitset_parse_list()Bryn M. Reeves2016-12-131-1/+2
| | | | | | | | | It's useful to be able to specify a minimum number of bits for a new bitmap parsed from a list, for e.g. to allow for expansing a group without needing to copy/reallocate the bitmap. Add a backwards compatible symbol for programs linked against old versions of the library.
* libdm: add dm_bit_get_last()/dm_bit_get_prev()Bryn M. Reeves2016-12-131-0/+2
| | | | | | | | | | | | It is sometimes convenient to iterate over the set bits in a dm bitset in reverse order (from the highest set bit toward zero), or to quickly find the last set bit. Add dm_bit_get_last() and dm_bit_get_prev(), mirroring the existing dm_bit_get_first() and dm_bit_get_next(). dm_bit_get_prev() uses __builtin_clz when available to efficiently test the bitset in reverse.
* libdm: fix dm_stats_foreach_group() macroBryn M. Reeves2016-12-131-3/+3
|
* libdm: fix performance of failed filemap cleanupBryn M. Reeves2016-12-101-8/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* cleanup: add doc for raid status statesZdenek Kabelac2016-11-231-0/+2
| | | | Show possible values for raid fields user may get ATM.
* libdm: add dm_config_parse_without_dup_node_checkPeter Rajnoha2016-09-211-0/+1
| | | | | Introduce function for config parsing tree without checking for duplicate nodes.
* libdm: add some comments about DM_UDEV_DISABLE_LIBRARY_FALLBACK flagPeter Rajnoha2016-08-231-1/+13
|
* libdm: report: add dm_report_group_output_and_pop_allPeter Rajnoha2016-08-091-0/+1
| | | | | | | | | | | | The dm_report_group_output_and_pop_all calls dm_report_output and dm_report_group_pop for all the items that are currently in report group. This is just a shortcut that makes it easier to output and pop group's content so the group handle can be reused again without a need to initialize and configure it again. The functionality of dm_report_group_output_and_pop_all is the same as dm_report_destroy but without destroying the report group handle.
* libdm: report: add dm_report_destroy_rowsPeter Rajnoha2016-08-091-0/+5
| | | | | | | | | | | | | Calling dm_report_destroy_rows makes it possible to destroy any report content we have but at the same time it doesn't destroy the report handle itself, thus it's possible to reuse that handle again for new report content. Functionally, this is the same as calling dm_report_output with the report handle but omitting the output iself. This functionality may be useful if we, for whatever reason, need to discard the report content and start a fresh new one but with the same report configuration and initialization and thus we can just reuse the existing handle.
* libdm: document use of dm_free() with histogram boundsBryn M. Reeves2016-07-181-0/+4
|
* libdm: add dm_stats_create_regions_from_fd()Bryn M. Reeves2016-07-081-0/+29
| | | | | | | | | | | | | | | | | Add a call to create dmstats regions that correspond to the extents present in a file descriptor open on a file in a local file system. The file must reside on a file system type that correctly supports physical extent location data in the FIEMAP ioctl. Regions are optionally placed into a group with a user-defined alias. File systems that do not support physical offsets in FIEMAP (btrfs currently) are detected via fstatfs() - although attempting to map a --filemap group on btrfs will fail anyway with the generic error "Not on a device-mapper device" this is confusing; the file system mount is on a device-mapper device, but btrfs' volume layer masks this in the returned st_dev field since the returned logical file extents may span multiple physical devices.
* libdm: enclose dm_stats_walk_do/while() body in do..whileBryn M. Reeves2016-07-081-3/+5
| | | | | | | The call to dm_stats_walk_start() before the do statement makes dm_stats_walk_do() behave inconsistently depending on context; wrap them in an additional do { } while (0) so that the macro always expands to a valid statement.
* libdm: ensure flags constants have ULL suffixBryn M. Reeves2016-07-051-5/+5
| | | | | | The walk flags used by libdm-stats use the upper portion of a 64b value: use the ULL suffix to ensure the compiler knows the expected size.
* libdm: clarify library's use of aux_dataBryn M. Reeves2016-07-051-12/+46
| | | | | | | | Make it clear in libdevmapper.h, and in function argument names, that libdm-stats uses the aux_data field internally and that any values set for user_data are appended to the library values before being stored with a region, and similarly, that internal data fields will be stripped prior to returning any previously stored user_data.
* libdm: allow deleting regions with dm_stats_delete_group()Bryn M. Reeves2016-07-051-2/+5
| | | | | Add a flag to dm_stats_delete_group() to allow optional deletion of all regions belonging to the group being removed.
* libdm: add stats group and region iterators and propertiesBryn M. Reeves2016-07-051-17/+110
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Add support do dm_stats_walk*() to walk over the set of available groups using the cursor embedded in the dm_stats handle, and to obtain the type of the object at the current stats cursor location. A set of flags is introduced to control which objects are visited: DM_STATS_WALK_AREA DM_STATS_WALK_REGION DM_STATS_WALK_GROUP DM_STATS_WALK_ALL A final flag suppresses visits to regions that contain only a single area - since the aggregate of such a region is idential to the area it contains this allows these duplicates to be filtered out: DM_STATS_WALK_SKIP_SINGLE_AREA If flags are not initialised before beginning a walk the default set matches the behaviour of previous versions of the library. Also accept group identifiers as immediate arguments to the counter, metric, and property functions by adding control flags to the region and area identifiers passed in. Region and area properties are mapped to their equivalents for the group (for example: group size is reported as the sum of all regions contained in the group). Counter and metric values are aggregated for the region or group.
* libdm: add statistics groupsBryn M. Reeves2016-07-051-0/+74
| | | | | | | | | | | | | | | | | | | | | | | | Add a grouping facility to the libdm-stats library that allows the user to bind several regions together as a group. Groups may be used to aggregate data from several regions for reporting, or to select and sort among large sets of regions. A textual descriptor ("group tag") is associated with each group and is stored in the first group member's aux_data field. The tag contains the group member list and an optional alias for the group, allowing the user to assign meaningful names to groups of regions. These descriptors are parsed in @stats_list message responses and populate the resulting region and area tables with the group structure. Groups with overlapping regions are permitted but since this will result in some events being counted more than once a warning is printed in this case. Nested and overlapping groups are not currently supported and attempting to create these configurations results in error.
* libdm: add enum based counter and metric callsBryn M. Reeves2016-07-051-0/+48
| | | | | | | | | | | | | | | | | | Add a new enum based interface for accessing counter and metric values that uses a single function for each: uint64_t dm_stats_get_counter(const struct dm_stats *dms, dm_stats_counter_t counter uint64_t region_id, uint64_t area_id); int dm_stats_get_metric(const struct dm_stats *dms, int metric, uint64_t region_id, uint64_t area_id, double *value); This simplifies the implementation of value aggregation for groups of regions. The named function interface now calls the enum interface internally so that all new functionality is available regardless of the method used to retrieve values.
* libdm: add dm_bitset_parse_list()Bryn M. Reeves2016-07-051-0/+10
| | | | | | | | | | | | Add a function to parse a list of integer values and ranges into a dm_bitset representation. Individual values signify that that bit is set in the resulting mask and ranges are given as a pair of start and end values, M-N, such that M and N are the first and last members of the range (inclusive). The implementation is based on the kernel's __bitmap_parselist() that is used for cpumasks and other set configuration passed in string form from user space.
* libdm: report: add dm_report_set_selectionPeter Rajnoha2016-06-201-0/+2
| | | | | Since we can do repeated dm_report_output calls now, we also like to be able to set selection for each of these outputs.
* libdm: report: add DM_REPORT_OUTPUT_MULTIPLE_TIMES report flag to keep ↵Peter Rajnoha2016-06-201-0/+1
| | | | | | | | | report data even after output is done The DM_REPORT_OUTPUT_MULTIPLE_TIMES instructs reporting code to keep rows even after dm_report_output call - the rows are not destroyed in this case which makes it possible to call dm_report_output multiple times.
* libdm: report: implement DM_REPORT_GROUP_JSON for JSON report outputPeter Rajnoha2016-06-201-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch introduces DM_REPORT_GROUP_JSON report group type. When using this group type and when pushing a report to such a group, these flags are automatically unset: DM_REPORT_OUTPUT_ALIGNED DM_REPORT_OUTPUT_HEADINGS DM_REPORT_OUTPUT_COLUMNS_AS_ROWS ...and this flag is set: DM_REPORT_OUTPUT_BUFFERED The whole group is encapsulated in { } for the outermost JSON object and then each report is reported on output as array of objects where each object is the row from report: { "report_name1": [ {field1="value", field2="value",...}, {field1="value", field2="value",...} ... ], "report_name2": [ {field1="value", field2="value",...}, {field1="value", field2="value",...} ... ] ... }
* libdm: report: implement DM_REPORT_GROUP_BASIC for extended report outputPeter Rajnoha2016-06-201-0/+1
| | | | | | | | | | | | | | | | | | | | This patch introduces DM_REPORT_GROUP_BASIC report group type. This type has exactly the classical output format as we know from before introduction of report groups. However, in addition to that, it allows to put several reports into a group - this is the very basic grouping scheme that doesn't change the output format itself: Report: report1_name Header1 Header2 ... value value ... value value ... ... ... ... Report: report2_name Header1 Header2 ... value value ... value value ... ... ... ...