diff options
author | Bryn M. Reeves <bmr@redhat.com> | 2016-12-11 12:53:04 +0000 |
---|---|---|
committer | Bryn M. Reeves <bmr@redhat.com> | 2017-01-25 16:15:21 +0000 |
commit | e0d19feb85ce8e143c7f107d7bf1c668d667a57c (patch) | |
tree | c1bdf92e49755754abeea139afd0fcaa553fbe6e /libdm/libdevmapper.h | |
parent | 1c00bb5da3a53152c5f9e0c9d3382afdec1b2455 (diff) | |
download | lvm2-e0d19feb85ce8e143c7f107d7bf1c668d667a57c.tar.gz |
libdm: add dm_stats_update_regions_from_fd()
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.
Diffstat (limited to 'libdm/libdevmapper.h')
-rw-r--r-- | libdm/libdevmapper.h | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/libdm/libdevmapper.h b/libdm/libdevmapper.h index 3c96bd9c8..9a1025202 100644 --- a/libdm/libdevmapper.h +++ b/libdm/libdevmapper.h @@ -1335,6 +1335,38 @@ 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); +/* + * Update a group of regions that correspond to the extents of a file + * in the filesystem, adding and removing regions to account for + * allocation changes in the underlying file. + * + * 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_update_regions_from_fd(). + * + * On success the function returns a pointer to an array of uint64_t + * containing the IDs of the updated regions (including any existing + * regions that were not modified by the call). + * + * The region_id array is terminated by the special value + * DM_STATS_REGION_NOT_PRESENT and should be freed using dm_free() + * when no longer required. + * + * On error NULL is returned. + * + * Following a call to dm_stats_update_regions_from_fd() the handle + * is guaranteed to be in a listed state, and to contain any region + * and group identifiers created by the operation. + * + * This function cannot be used with file mapped regions that are + * not members of a group: either group the regions, or remove them + * and re-map them with dm_stats_create_regions_from_fd(). + */ +uint64_t *dm_stats_update_regions_from_fd(struct dm_stats *dms, int fd, + uint64_t group_id); /* * Call this to actually run the ioctl. |