mirror of
git://sourceware.org/git/lvm2.git
synced 2025-01-02 01:18:26 +03:00
libdm: add dm_stats_get_{current_}area_offset()
Add a method to retrieve the offset of an area within the containing region (rather than the offset within the containing device returned by dm_stats_get_area_start()). Although users of the library can calculate this themselves it is better to provide this through a method call to avoid users making assumptions about the structure of regions and areas.
This commit is contained in:
parent
77fae3d852
commit
00ed523659
@ -1 +1,3 @@
|
|||||||
dm_report_is_empty
|
dm_report_is_empty
|
||||||
|
dm_stats_get_area_offset
|
||||||
|
dm_stats_get_current_area_offset
|
||||||
|
@ -705,19 +705,27 @@ uint64_t dm_stats_get_region_area_len(const struct dm_stats *dms,
|
|||||||
uint64_t *area_len, uint64_t region_id);
|
uint64_t *area_len, uint64_t region_id);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Area properties: start and length.
|
* Area properties: start, offset and length.
|
||||||
*
|
*
|
||||||
* The area length is always equal to the area length of the region
|
* The area length is always equal to the area length of the region
|
||||||
* that contains it and is obtained from dm_stats_get_region_area_len().
|
* that contains it and is obtained from dm_stats_get_region_area_len().
|
||||||
*
|
*
|
||||||
* The start offset of an area is a function of the area_id and the
|
* The start of an area is a function of the area_id and the containing
|
||||||
* containing region's start and area length.
|
* region's start and area length: it gives the absolute offset into the
|
||||||
|
* containing device of the beginning of the area.
|
||||||
|
*
|
||||||
|
* The offset expresses the area's relative offset into the current
|
||||||
|
* region. I.e. the area start minus the start offset of the containing
|
||||||
|
* region.
|
||||||
*
|
*
|
||||||
* All values are returned in units of 512b sectors.
|
* All values are returned in units of 512b sectors.
|
||||||
*/
|
*/
|
||||||
uint64_t dm_stats_get_area_start(const struct dm_stats *dms, uint64_t *start,
|
uint64_t dm_stats_get_area_start(const struct dm_stats *dms, uint64_t *start,
|
||||||
uint64_t region_id, uint64_t area_id);
|
uint64_t region_id, uint64_t area_id);
|
||||||
|
|
||||||
|
uint64_t dm_stats_get_area_offset(const struct dm_stats *dms, uint64_t *offset,
|
||||||
|
uint64_t region_id, uint64_t area_id);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Retrieve program_id and aux_data for a specific region. Only valid
|
* Retrieve program_id and aux_data for a specific region. Only valid
|
||||||
* following a call to dm_stats_list(). The returned pointer does not
|
* following a call to dm_stats_list(). The returned pointer does not
|
||||||
@ -876,6 +884,9 @@ uint64_t dm_stats_get_current_region_area_len(const struct dm_stats *dms,
|
|||||||
uint64_t dm_stats_get_current_area_start(const struct dm_stats *dms,
|
uint64_t dm_stats_get_current_area_start(const struct dm_stats *dms,
|
||||||
uint64_t *start);
|
uint64_t *start);
|
||||||
|
|
||||||
|
uint64_t dm_stats_get_current_area_offset(const struct dm_stats *dms,
|
||||||
|
uint64_t *offset);
|
||||||
|
|
||||||
uint64_t dm_stats_get_current_area_len(const struct dm_stats *dms,
|
uint64_t dm_stats_get_current_area_len(const struct dm_stats *dms,
|
||||||
uint64_t *start);
|
uint64_t *start);
|
||||||
|
|
||||||
|
@ -1335,6 +1335,14 @@ uint64_t dm_stats_get_area_start(const struct dm_stats *dms, uint64_t *start,
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint64_t dm_stats_get_area_offset(const struct dm_stats *dms, uint64_t *offset,
|
||||||
|
uint64_t region_id, uint64_t area_id)
|
||||||
|
{
|
||||||
|
if (!dms || !dms->regions)
|
||||||
|
return_0;
|
||||||
|
*offset = dms->regions[region_id].step * area_id;
|
||||||
|
}
|
||||||
|
|
||||||
uint64_t dm_stats_get_current_area_start(const struct dm_stats *dms,
|
uint64_t dm_stats_get_current_area_start(const struct dm_stats *dms,
|
||||||
uint64_t *start)
|
uint64_t *start)
|
||||||
{
|
{
|
||||||
@ -1342,6 +1350,13 @@ uint64_t dm_stats_get_current_area_start(const struct dm_stats *dms,
|
|||||||
dms->cur_region, dms->cur_area);
|
dms->cur_region, dms->cur_area);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint64_t dm_stats_get_current_area_offset(const struct dm_stats *dms,
|
||||||
|
uint64_t *offset)
|
||||||
|
{
|
||||||
|
return dm_stats_get_area_offset(dms, offset,
|
||||||
|
dms->cur_region, dms->cur_area);
|
||||||
|
}
|
||||||
|
|
||||||
uint64_t dm_stats_get_current_area_len(const struct dm_stats *dms,
|
uint64_t dm_stats_get_current_area_len(const struct dm_stats *dms,
|
||||||
uint64_t *len)
|
uint64_t *len)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user