master - segtype: better get_monitor_dso_path api
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=27399755fd1b1292cc93f6469162c0855b7231c2 Commit: 27399755fd1b1292cc93f6469162c0855b7231c2 Parent: e113df129ebc4c2b4fca2a973ac6e06630e1a470 Author: Zdenek Kabelac <[email protected]> AuthorDate: Sat Feb 10 20:22:32 2018 +0100 Committer: Zdenek Kabelac <[email protected]> CommitterDate: Mon Feb 12 22:15:03 2018 +0100
segtype: better get_monitor_dso_path api
Instead of allocating always 4K for dso path, use only real needed size. Also simplify API call and move common functionality into function itself.
--- lib/activate/activate.c | 14 +++++--------- lib/activate/activate.h | 2 +- lib/mirror/mirrored.c | 3 +-- lib/raid/raid.c | 3 +-- lib/snapshot/snapshot.c | 3 +-- lib/thin/thin.c | 3 +-- 6 files changed, 10 insertions(+), 18 deletions(-)
lib/activate/activate.c +5 -9
@@ -1685,18 +1685,14 @@ bad:return NULL ; } -char *get_monitor_dso_path (struct cmd_context *cmd,const char *libpath) +char *get_monitor_dso_path (struct cmd_context *cmd,int id) { -char *path; - -if (!(path =dm_pool_alloc (cmd->mem,PATH_MAX ))) { -log_error ("Failed to allocate dmeventd library path." ); -return NULL ; - } +const char *libpath =find_config_tree_str (cmd, id,NULL ); +char path[PATH_MAX ]; -get_shared_library_path (cmd, libpath, path,PATH_MAX ); +get_shared_library_path (cmd, libpath, path,sizeof (path)); -return path; +return dm_pool_strdup (cmd->mem, path); }static char *_build_target_uuid (struct cmd_context *cmd,const struct logical_volume *lv)
lib/activate/activate.h +1 -1
@@ -206,7 +206,7 @@ int monitor_dev_for_events(struct cmd_context *cmd, const struct logical_volume#ifdef DMEVENTD # include "libdevmapper-event.h" -char *get_monitor_dso_path (struct cmd_context *cmd,const char *libpath); +char *get_monitor_dso_path (struct cmd_context *cmd,int id);int target_registered_with_dmeventd (struct cmd_context *cmd,const char *dso,const struct logical_volume *lv,int *pending,int *monitored); int target_register_events(struct cmd_context *cmd, const char *dso, const struct logical_volume *lv,
lib/mirror/mirrored.c +1 -2
@@ -572,8 +572,7 @@ struct segment_type *init_segtype(struct cmd_context *cmd)#ifdef DEVMAPPER_SUPPORT # ifdef DMEVENTD - segtype->dso =get_monitor_dso_path (cmd, -find_config_tree_str (cmd, dmeventd_mirror_library_CFG,NULL )); + segtype->dso =get_monitor_dso_path (cmd, dmeventd_mirror_library_CFG);if (segtype->dso) segtype->flags |=SEG_MONITORED ;
lib/raid/raid.c +1 -2
@@ -656,8 +656,7 @@ int init_multiple_segtypes(struct cmd_context *cmd, struct segtype_library *segl#ifdef DEVMAPPER_SUPPORT # ifdef DMEVENTD - dso =get_monitor_dso_path (cmd, -find_config_tree_str (cmd, dmeventd_raid_library_CFG,NULL )); + dso =get_monitor_dso_path (cmd, dmeventd_raid_library_CFG);if (dso) monitored =SEG_MONITORED ;
lib/snapshot/snapshot.c +1 -2
@@ -263,8 +263,7 @@ struct segment_type *init_segtype(struct cmd_context *cmd)#ifdef DEVMAPPER_SUPPORT # ifdef DMEVENTD - segtype->dso =get_monitor_dso_path (cmd, -find_config_tree_str (cmd, dmeventd_snapshot_library_CFG,NULL )); + segtype->dso =get_monitor_dso_path (cmd, dmeventd_snapshot_library_CFG);if (segtype->dso) segtype->flags |=SEG_MONITORED ;
lib/thin/thin.c +1 -2
@@ -816,8 +816,7 @@ 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 )); + segtype->dso =get_monitor_dso_path (cmd, dmeventd_thin_library_CFG);if ((reg_segtypes[i].flags &SEG_THIN_POOL ) && segtype->dso)