mirror of
git://sourceware.org/git/lvm2.git
synced 2024-12-21 13:34:40 +03:00
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.
This commit is contained in:
parent
c459f23565
commit
97c4490cc5
@ -2018,10 +2018,34 @@ static int _stats_remove_region_id_from_group(struct dm_stats *dms,
|
|||||||
return _stats_set_aux(dms, group_id, dms->regions[group_id].aux_data);
|
return _stats_set_aux(dms, group_id, dms->regions[group_id].aux_data);
|
||||||
}
|
}
|
||||||
|
|
||||||
int dm_stats_delete_region(struct dm_stats *dms, uint64_t region_id)
|
static int _stats_delete_region(struct dm_stats *dms, uint64_t region_id)
|
||||||
{
|
{
|
||||||
char msg[STATS_MSG_BUF_LEN];
|
char msg[STATS_MSG_BUF_LEN];
|
||||||
struct dm_task *dmt;
|
struct dm_task *dmt;
|
||||||
|
|
||||||
|
if (_stats_region_is_grouped(dms, region_id))
|
||||||
|
if (!_stats_remove_region_id_from_group(dms, region_id)) {
|
||||||
|
log_error("Could not remove region ID " FMTu64 " from "
|
||||||
|
"group ID " FMTu64,
|
||||||
|
region_id, dms->regions[region_id].group_id);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!dm_snprintf(msg, sizeof(msg), "@stats_delete " FMTu64, region_id)) {
|
||||||
|
log_error("Could not prepare @stats_delete message.");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
dmt = _stats_send_message(dms, msg);
|
||||||
|
if (!dmt)
|
||||||
|
return_0;
|
||||||
|
dm_task_destroy(dmt);
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int dm_stats_delete_region(struct dm_stats *dms, uint64_t region_id)
|
||||||
|
{
|
||||||
int listed = 0;
|
int listed = 0;
|
||||||
|
|
||||||
if (!_stats_bound(dms))
|
if (!_stats_bound(dms))
|
||||||
@ -2065,23 +2089,8 @@ int dm_stats_delete_region(struct dm_stats *dms, uint64_t region_id)
|
|||||||
goto bad;
|
goto bad;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(_stats_region_is_grouped(dms, region_id))
|
if (!_stats_delete_region(dms, region_id))
|
||||||
if (!_stats_remove_region_id_from_group(dms, region_id)) {
|
|
||||||
log_error("Could not remove region ID " FMTu64 " from "
|
|
||||||
"group ID " FMTu64,
|
|
||||||
region_id, dms->regions[region_id].group_id);
|
|
||||||
goto bad;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!dm_snprintf(msg, sizeof(msg), "@stats_delete " FMTu64, region_id)) {
|
|
||||||
log_error("Could not prepare @stats_delete message.");
|
|
||||||
goto bad;
|
goto bad;
|
||||||
}
|
|
||||||
|
|
||||||
dmt = _stats_send_message(dms, msg);
|
|
||||||
if (!dmt)
|
|
||||||
return_0;
|
|
||||||
dm_task_destroy(dmt);
|
|
||||||
|
|
||||||
if (!listed)
|
if (!listed)
|
||||||
/* wipe region and mark as not present */
|
/* wipe region and mark as not present */
|
||||||
|
Loading…
Reference in New Issue
Block a user