1
0
mirror of git://sourceware.org/git/lvm2.git synced 2024-10-27 01:55:10 +03:00

cleanup: decode dso path just once

Build dso plugin name during  segtype initialisation and just
use the string during command life-time.

Also slightlt update message verbosity and make it very_verbose
when operation is going to be made and 'verbose' when it's done.
This commit is contained in:
Zdenek Kabelac 2018-02-09 23:40:37 +01:00
parent 6dff5dc653
commit e113df129e
6 changed files with 37 additions and 44 deletions

View File

@ -1831,7 +1831,7 @@ int target_register_events(struct cmd_context *cmd, const char *dso, const struc
if (!r)
return_0;
log_very_verbose("%s %s for events", set ? "Monitored" : "Unmonitored", uuid);
log_verbose("%s %s for events", set ? "Monitored" : "Unmonitored", uuid);
return 1;
}
@ -2016,7 +2016,9 @@ int monitor_dev_for_events(struct cmd_context *cmd, const struct logical_volume
if (monitored)
log_verbose("%s already monitored.", display_lvname(lv));
else if (seg->segtype->ops->target_monitor_events) {
log_verbose("Monitoring %s%s", display_lvname(lv), test_mode() ? " [Test mode: skipping this]" : "");
log_very_verbose("Monitoring %s with %s.%s", display_lvname(lv),
seg->segtype->dso,
test_mode() ? " [Test mode: skipping this]" : "");
monitor_fn = seg->segtype->ops->target_monitor_events;
}
} else {

View File

@ -217,6 +217,7 @@ struct segment_type {
struct segtype_handler *ops;
const char *name;
const char *dso;
void *library; /* lvm_register_segtype() sets this. */
void *private; /* For the segtype handler to use. */

View File

@ -480,22 +480,17 @@ static int _mirrored_target_present(struct cmd_context *cmd,
}
# ifdef DMEVENTD
static const char *_get_mirror_dso_path(struct cmd_context *cmd)
{
return get_monitor_dso_path(cmd, find_config_tree_str(cmd, dmeventd_mirror_library_CFG, NULL));
}
/* FIXME Cache this */
static int _target_registered(struct lv_segment *seg, int *pending, int *monitored)
{
return target_registered_with_dmeventd(seg->lv->vg->cmd, _get_mirror_dso_path(seg->lv->vg->cmd),
return target_registered_with_dmeventd(seg->lv->vg->cmd, seg->segtype->dso,
seg->lv, pending, monitored);
}
/* FIXME This gets run while suspended and performs banned operations. */
static int _target_set_events(struct lv_segment *seg, int evmask, int set)
{
return target_register_events(seg->lv->vg->cmd, _get_mirror_dso_path(seg->lv->vg->cmd),
return target_register_events(seg->lv->vg->cmd, seg->segtype->dso,
seg->lv, evmask, set, 0);
}
@ -577,7 +572,10 @@ struct segment_type *init_segtype(struct cmd_context *cmd)
#ifdef DEVMAPPER_SUPPORT
# ifdef DMEVENTD
if (_get_mirror_dso_path(cmd))
segtype->dso = get_monitor_dso_path(cmd,
find_config_tree_str(cmd, dmeventd_mirror_library_CFG, NULL));
if (segtype->dso)
segtype->flags |= SEG_MONITORED;
# endif /* DMEVENTD */
#endif

View File

@ -538,26 +538,16 @@ static int _raid_modules_needed(struct dm_pool *mem,
}
# ifdef DMEVENTD
static const char *_get_raid_dso_path(struct cmd_context *cmd)
{
const char *config_str = find_config_tree_str(cmd, dmeventd_raid_library_CFG, NULL);
return get_monitor_dso_path(cmd, config_str);
}
static int _raid_target_monitored(struct lv_segment *seg, int *pending, int *monitored)
{
struct cmd_context *cmd = seg->lv->vg->cmd;
const char *dso_path = _get_raid_dso_path(cmd);
return target_registered_with_dmeventd(cmd, dso_path, seg->lv, pending, monitored);
return target_registered_with_dmeventd(seg->lv->vg->cmd, seg->segtype->dso,
seg->lv, pending, monitored);
}
static int _raid_set_events(struct lv_segment *seg, int evmask, int set)
{
struct cmd_context *cmd = seg->lv->vg->cmd;
const char *dso_path = _get_raid_dso_path(cmd);
return target_register_events(cmd, dso_path, seg->lv, evmask, set, 0);
return target_register_events(seg->lv->vg->cmd, seg->segtype->dso,
seg->lv, evmask, set, 0);
}
static int _raid_target_monitor_events(struct lv_segment *seg, int events)
@ -623,6 +613,7 @@ static const struct raid_type {
static struct segment_type *_init_raid_segtype(struct cmd_context *cmd,
const struct raid_type *rt,
const char *dso,
uint64_t monitored)
{
struct segment_type *segtype = dm_zalloc(sizeof(*segtype));
@ -638,8 +629,10 @@ static struct segment_type *_init_raid_segtype(struct cmd_context *cmd,
segtype->flags = SEG_RAID | SEG_ONLY_EXCLUSIVE | rt->extra_flags;
/* Never monitor raid0 or raid0_meta LVs */
if (!segtype_is_any_raid0(segtype))
if (!segtype_is_any_raid0(segtype)) {
segtype->dso = dso;
segtype->flags |= monitored;
}
segtype->parity_devs = rt->parity;
@ -657,18 +650,22 @@ int init_multiple_segtypes(struct cmd_context *cmd, struct segtype_library *segl
#endif
{
struct segment_type *segtype;
const char *dso;
unsigned i;
uint64_t monitored = 0;
#ifdef DEVMAPPER_SUPPORT
# ifdef DMEVENTD
if (_get_raid_dso_path(cmd))
dso = get_monitor_dso_path(cmd,
find_config_tree_str(cmd, dmeventd_raid_library_CFG, NULL));
if (dso)
monitored = SEG_MONITORED;
# endif
#endif
for (i = 0; i < DM_ARRAY_SIZE(_raid_types); ++i)
if ((segtype = _init_raid_segtype(cmd, &_raid_types[i], monitored)) &&
if ((segtype = _init_raid_segtype(cmd, &_raid_types[i], dso, monitored)) &&
!lvm_register_segtype(seglib, segtype))
/* segtype is already destroyed */
return_0;

View File

@ -179,17 +179,11 @@ static int _snap_target_present(struct cmd_context *cmd,
}
# ifdef DMEVENTD
static const char *_get_snapshot_dso_path(struct cmd_context *cmd)
{
return get_monitor_dso_path(cmd, find_config_tree_str(cmd, dmeventd_snapshot_library_CFG, NULL));
}
/* FIXME Cache this */
static int _target_registered(struct lv_segment *seg, int *pending, int *monitored)
{
return target_registered_with_dmeventd(seg->lv->vg->cmd,
_get_snapshot_dso_path(seg->lv->vg->cmd),
seg->segtype->dso,
seg->cow, pending, monitored);
}
@ -197,7 +191,7 @@ static int _target_registered(struct lv_segment *seg, int *pending, int *monitor
static int _target_set_events(struct lv_segment *seg, int evmask, int set)
{
/* FIXME Make timeout (10) configurable */
return target_register_events(seg->lv->vg->cmd, _get_snapshot_dso_path(seg->lv->vg->cmd),
return target_register_events(seg->lv->vg->cmd, seg->segtype->dso,
seg->cow, evmask, set, 10);
}
@ -269,7 +263,10 @@ struct segment_type *init_segtype(struct cmd_context *cmd)
#ifdef DEVMAPPER_SUPPORT
# ifdef DMEVENTD
if (_get_snapshot_dso_path(cmd))
segtype->dso = get_monitor_dso_path(cmd,
find_config_tree_str(cmd, dmeventd_snapshot_library_CFG, NULL));
if (segtype->dso)
segtype->flags |= SEG_MONITORED;
# endif /* DMEVENTD */
#endif

View File

@ -431,16 +431,11 @@ static int _thin_pool_target_percent(void **target_state __attribute__((unused))
}
# ifdef DMEVENTD
static const char *_get_thin_dso_path(struct cmd_context *cmd)
{
return get_monitor_dso_path(cmd, find_config_tree_str(cmd, dmeventd_thin_library_CFG, NULL));
}
/* FIXME Cache this */
static int _target_registered(struct lv_segment *seg, int *pending, int *monitored)
{
return target_registered_with_dmeventd(seg->lv->vg->cmd,
_get_thin_dso_path(seg->lv->vg->cmd),
seg->segtype->dso,
seg->lv, pending, monitored);
}
@ -449,7 +444,7 @@ static int _target_set_events(struct lv_segment *seg, int evmask, int set)
{
/* FIXME Make timeout (10) configurable */
return target_register_events(seg->lv->vg->cmd,
_get_thin_dso_path(seg->lv->vg->cmd),
seg->segtype->dso,
seg->lv, evmask, set, 10);
}
@ -821,8 +816,11 @@ int init_multiple_segtypes(struct cmd_context *cmd, struct segtype_library *segl
#ifdef DEVMAPPER_SUPPORT
# ifdef DMEVENTD
segtype->dso = get_monitor_dso_path(cmd,
find_config_tree_str(cmd, dmeventd_thin_library_CFG, NULL));
if ((reg_segtypes[i].flags & SEG_THIN_POOL) &&
_get_thin_dso_path(cmd))
segtype->dso)
segtype->flags |= SEG_MONITORED;
# endif /* DMEVENTD */
#endif