master - libdm: add dm_stats_create_regions_from_fd()
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=e1048259165b09a35c45170cefbbccb4d43a9834 Commit: e1048259165b09a35c45170cefbbccb4d43a9834 Parent: 12ecd95965321af194c3d446c0b5205d90994522 Author: Bryn M. Reeves <[email protected]> AuthorDate: Thu Jun 30 21:46:43 2016 +0100 Committer: Bryn M. Reeves <[email protected]> CommitterDate: Fri Jul 8 14:34:41 2016 +0100
libdm: add dm_stats_create_regions_from_fd()
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/.exported_symbols.DM_1_02_131 | 1 + libdm/libdevmapper.h | 29 ++++ libdm/libdm-stats.c | 302 ++++++++++++++++++++++++++++++++++- 3 files changed, 331 insertions(+), 1 deletions(-)
libdm/.exported_symbols.DM_1_02_131 new file +1 -0
@@ -0,0 +1 @@ +dm_stats_create_regions_from_fd
libdm/libdevmapper.h +29 -0
@@ -1286,6 +1286,35 @@ int dm_stats_get_group_descriptor(const struct dm_stats *dms, uint64_t group_id, char **buf);/* +* Create regions that correspond to the extents of a file in the +* filesystem and optionally place them into a group. +* +* File descriptor fd must reference a regular file, open for reading, +* in a local file system that supports the FIEMAP ioctl and that +* returns data describing the physical location of extents. +* +* The file descriptor can be closed by the caller following the call +* to dm_stats_create_regions_from_fd(). +* +* The function returns a pointer to an array of uint64_t containing +* the IDs of the newly created regions. The array is terminated by the +* value DM_STATS_REGIONS_ALL and should be freed using dm_free() when +* no longer required. +* +* Unless nogroup is non-zero the regions will be placed into a group +* and the group alias is set to the value supplied. +* +* The group_id for the new group is equal to the region_id value in +* the first array element. +* +* File mapped histograms will be supported in a future version. +*/ +uint64_t *dm_stats_create_regions_from_fd (struct dm_stats *dms,int fd, +int group,int precise, +struct dm_histogram *bounds, +const char *alias); + +/* * Call this to actually run the ioctl. */ int dm_task_run (struct dm_task *dmt);
libdm/libdm-stats.c +301 -1
318 lines not on this page · raw message