diff --git a/lib/cache/lvmetad.c b/lib/cache/lvmetad.c index e50234a08..8d13a5989 100644 --- a/lib/cache/lvmetad.c +++ b/lib/cache/lvmetad.c @@ -165,6 +165,13 @@ void lvmetad_make_unused(struct cmd_context *cmd) stack; } +int lvmetad_pidfile_present(void) +{ + const char *pidfile = getenv("LVM_LVMETAD_PIDFILE") ?: LVMETAD_PIDFILE; + + return !access(pidfile, F_OK); +} + int lvmetad_socket_present(void) { const char *socket = _lvmetad_socket ?: LVMETAD_SOCKET; diff --git a/lib/cache/lvmetad.h b/lib/cache/lvmetad.h index 699c9a4b4..240610be8 100644 --- a/lib/cache/lvmetad.h +++ b/lib/cache/lvmetad.h @@ -52,6 +52,12 @@ void lvmetad_set_socket(const char *); */ int lvmetad_socket_present(void); +/* + * Check if lvmetad pidfile is present, indicating that the lvmetad + * process is running or not. + */ +int lvmetad_pidfile_present(void); + /* * Set the "lvmetad validity token" (currently only consists of the lvmetad * filter. See lvm.conf. diff --git a/lib/commands/toolcontext.c b/lib/commands/toolcontext.c index 1f8ac4cd1..67d4f99da 100644 --- a/lib/commands/toolcontext.c +++ b/lib/commands/toolcontext.c @@ -1720,7 +1720,7 @@ static int _init_lvmetad(struct cmd_context *cmd) } if (!find_config_tree_bool(cmd, global_use_lvmetad_CFG, NULL)) { - if (lvmetad_socket_present()) + if (lvmetad_pidfile_present()) log_warn("WARNING: Not using lvmetad because config setting use_lvmetad=0."); return 1; }