1
0
mirror of git://sourceware.org/git/lvm2.git synced 2024-12-21 13:34:40 +03:00

libdm: rename dm_stats name, devno and uuid members

The device-mapper name, device numbers and uuid stored in the
dm_stats handle are used only to bind the handle to a specific
device in order to issue ioctls.

Rename them to "bind_*" to reflect this usage in preparation
for caching the device-mapper name of the bound device in the
dm_stats handle.

This will be used to allow optional aliases to be set for
dmstats groups.
This commit is contained in:
Bryn M. Reeves 2016-03-10 16:51:02 +00:00
parent 81fad9e853
commit 4a66f02f88

View File

@ -76,10 +76,10 @@ struct dm_stats_region {
struct dm_stats { struct dm_stats {
/* device binding */ /* device binding */
int major; /* device major that this dm_stats object is bound to */ int bind_major; /* device major that this dm_stats object is bound to */
int minor; /* device minor that this dm_stats object is bound to */ int bind_minor; /* device minor that this dm_stats object is bound to */
char *name; /* device-mapper device name */ char *bind_name; /* device-mapper device name */
char *uuid; /* device-mapper UUID */ char *bind_uuid; /* device-mapper UUID */
char *program_id; /* default program_id for this handle */ char *program_id; /* default program_id for this handle */
struct dm_pool *mem; /* memory pool for region and counter tables */ struct dm_pool *mem; /* memory pool for region and counter tables */
struct dm_pool *hist_mem; /* separate pool for histogram tables */ struct dm_pool *hist_mem; /* separate pool for histogram tables */
@ -162,10 +162,10 @@ struct dm_stats *dm_stats_create(const char *program_id)
goto bad; goto bad;
} }
dms->major = -1; dms->bind_major = -1;
dms->minor = -1; dms->bind_minor = -1;
dms->name = NULL; dms->bind_name = NULL;
dms->uuid = NULL; dms->bind_uuid = NULL;
/* by default all regions use msec precision */ /* by default all regions use msec precision */
dms->timescale = NSEC_PER_MSEC; dms->timescale = NSEC_PER_MSEC;
@ -242,19 +242,19 @@ static void _stats_regions_destroy(struct dm_stats *dms)
static int _set_stats_device(struct dm_stats *dms, struct dm_task *dmt) static int _set_stats_device(struct dm_stats *dms, struct dm_task *dmt)
{ {
if (dms->name) if (dms->bind_name)
return dm_task_set_name(dmt, dms->name); return dm_task_set_name(dmt, dms->bind_name);
if (dms->uuid) if (dms->bind_uuid)
return dm_task_set_uuid(dmt, dms->uuid); return dm_task_set_uuid(dmt, dms->bind_uuid);
if (dms->major > 0) if (dms->bind_major > 0)
return dm_task_set_major(dmt, dms->major) return dm_task_set_major(dmt, dms->bind_major)
&& dm_task_set_minor(dmt, dms->minor); && dm_task_set_minor(dmt, dms->bind_minor);
return_0; return_0;
} }
static int _stats_bound(struct dm_stats *dms) static int _stats_bound(struct dm_stats *dms)
{ {
if (dms->major > 0 || dms->name || dms->uuid) if (dms->bind_major > 0 || dms->bind_name || dms->bind_uuid)
return 1; return 1;
/* %p format specifier expects a void pointer. */ /* %p format specifier expects a void pointer. */
log_debug("Stats handle at %p is not bound.", (void *) dms); log_debug("Stats handle at %p is not bound.", (void *) dms);
@ -263,13 +263,13 @@ static int _stats_bound(struct dm_stats *dms)
static void _stats_clear_binding(struct dm_stats *dms) static void _stats_clear_binding(struct dm_stats *dms)
{ {
if (dms->name) if (dms->bind_name)
dm_pool_free(dms->mem, dms->name); dm_pool_free(dms->mem, dms->bind_name);
if (dms->uuid) if (dms->bind_uuid)
dm_pool_free(dms->mem, dms->uuid); dm_pool_free(dms->mem, dms->bind_uuid);
dms->name = dms->uuid = NULL; dms->bind_name = dms->bind_uuid = NULL;
dms->major = dms->minor = -1; dms->bind_major = dms->bind_minor = -1;
} }
int dm_stats_bind_devno(struct dm_stats *dms, int major, int minor) int dm_stats_bind_devno(struct dm_stats *dms, int major, int minor)
@ -277,8 +277,8 @@ int dm_stats_bind_devno(struct dm_stats *dms, int major, int minor)
_stats_clear_binding(dms); _stats_clear_binding(dms);
_stats_regions_destroy(dms); _stats_regions_destroy(dms);
dms->major = major; dms->bind_major = major;
dms->minor = minor; dms->bind_minor = minor;
return 1; return 1;
} }
@ -288,7 +288,7 @@ int dm_stats_bind_name(struct dm_stats *dms, const char *name)
_stats_clear_binding(dms); _stats_clear_binding(dms);
_stats_regions_destroy(dms); _stats_regions_destroy(dms);
if (!(dms->name = dm_pool_strdup(dms->mem, name))) if (!(dms->bind_name = dm_pool_strdup(dms->mem, name)))
return_0; return_0;
return 1; return 1;
@ -299,7 +299,7 @@ int dm_stats_bind_uuid(struct dm_stats *dms, const char *uuid)
_stats_clear_binding(dms); _stats_clear_binding(dms);
_stats_regions_destroy(dms); _stats_regions_destroy(dms);
if (!(dms->uuid = dm_pool_strdup(dms->mem, uuid))) if (!(dms->bind_uuid = dm_pool_strdup(dms->mem, uuid)))
return_0; return_0;
return 1; return 1;