diff options
Diffstat (limited to 'lib/commands/toolcontext.c')
-rw-r--r-- | lib/commands/toolcontext.c | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/lib/commands/toolcontext.c b/lib/commands/toolcontext.c index 2a372c2c7..b6b212597 100644 --- a/lib/commands/toolcontext.c +++ b/lib/commands/toolcontext.c @@ -29,6 +29,7 @@ #include "segtype.h" #include "lvmcache.h" #include "lvmetad.h" +#include "lvmlockd.h" #include "archiver.h" #ifdef HAVE_LIBDL @@ -396,7 +397,10 @@ static int _process_config(struct cmd_context *cmd) const struct dm_config_value *cv; int64_t pv_min_kb; const char *lvmetad_socket; + const char *lvmlockd_socket; int udev_disabled = 0; + int locking_type; + int use_lvmlockd; char sysfs_dir[PATH_MAX]; if (!_check_config(cmd)) @@ -552,6 +556,32 @@ static int _process_config(struct cmd_context *cmd) lvmetad_init(cmd); + /* + * clvmd and lvmlockd cannot be used concurrently, it is + * one or the other. + * global/locking_type=3 is the clvmd configuration. + * global/use_lvmlockd=1 is the lvmlockd configuration. + * + * use_lvmlockd should be combined with locking_type 1 (local). + */ + + locking_type = find_config_tree_int(cmd, global_locking_type_CFG, NULL); + use_lvmlockd = find_config_tree_bool(cmd, global_use_lvmlockd_CFG, NULL); + + if (locking_type == 3 && use_lvmlockd) { + log_error("ERROR: configuration setting use_lvmlockd cannot be used with locking_type 3."); + return 0; + } + + lvmlockd_disconnect(); + lvmlockd_socket = getenv("LVM_LVMLOCKD_SOCKET"); + if (!lvmlockd_socket) + lvmlockd_socket = DEFAULT_RUN_DIR "/lvmlockd.socket"; + + lvmlockd_set_socket(lvmlockd_socket); + lvmlockd_set_active(!!use_lvmlockd); + lvmlockd_init(cmd); + return 1; } @@ -1990,6 +2020,7 @@ void destroy_toolcontext(struct cmd_context *cmd) #endif dm_free(cmd); + lvmlockd_disconnect(); lvmetad_release_token(); lvmetad_disconnect(); |