mirror of
git://sourceware.org/git/lvm2.git
synced 2025-01-02 01:18:26 +03:00
Clvmd restart cleanup
Patch fixes Clang warnings about possible access via lv_name NULL pointer. Replaces allocation of memory (strdup) with just pointer assignment (since execve is being called anyway). Checks for !*lv_name only when lv_name is defined. (and as I'm not quite sure what state this really is - putting a FIXME around - as this rather looks suspicios ??). Add debug print of passed clvmd args.
This commit is contained in:
parent
f1f42ab732
commit
f79f7250ce
@ -1,5 +1,6 @@
|
|||||||
Version 2.02.89 -
|
Version 2.02.89 -
|
||||||
==================================
|
==================================
|
||||||
|
Cleanup restart clvmd code (no memory allocation, debug print passed args).
|
||||||
Add all exclusive locks to clvmd restart option args.
|
Add all exclusive locks to clvmd restart option args.
|
||||||
Always send the whole clvmd packet header in refresh commands.
|
Always send the whole clvmd packet header in refresh commands.
|
||||||
Add missing error checks for some system calls in cmirrord.
|
Add missing error checks for some system calls in cmirrord.
|
||||||
|
@ -361,39 +361,38 @@ void cmd_client_cleanup(struct local_client *client)
|
|||||||
|
|
||||||
static int restart_clvmd(void)
|
static int restart_clvmd(void)
|
||||||
{
|
{
|
||||||
char **argv = NULL;
|
const char **argv;
|
||||||
char *debug_arg = NULL, *lv_name;
|
char *lv_name;
|
||||||
int i, argc = 0, max_locks = 0;
|
int argc = 0, max_locks = 0;
|
||||||
struct dm_hash_node *hn = NULL;
|
struct dm_hash_node *hn = NULL;
|
||||||
|
char debug_arg[16];
|
||||||
|
|
||||||
DEBUGLOG("clvmd restart requested\n");
|
DEBUGLOG("clvmd restart requested\n");
|
||||||
|
|
||||||
/* Count exclusively-open LVs */
|
/* Count exclusively-open LVs */
|
||||||
do {
|
do {
|
||||||
hn = get_next_excl_lock(hn, &lv_name);
|
hn = get_next_excl_lock(hn, &lv_name);
|
||||||
if (lv_name)
|
if (lv_name) {
|
||||||
max_locks++;
|
max_locks++;
|
||||||
} while (hn && *lv_name);
|
if (!*lv_name)
|
||||||
|
break; /* FIXME: Is this error ? */
|
||||||
|
}
|
||||||
|
} while (hn);
|
||||||
|
|
||||||
/* clvmd + locks (-E uuid) + debug (-d X) + NULL */
|
/* clvmd + locks (-E uuid) + debug (-d X) + NULL */
|
||||||
argv = malloc((max_locks * 2 + 4) * sizeof(*argv));
|
if (!(argv = malloc((max_locks * 2 + 4) * sizeof(*argv))))
|
||||||
if (!argv)
|
|
||||||
goto_out;
|
goto_out;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Build the command-line
|
* Build the command-line
|
||||||
*/
|
*/
|
||||||
argv[argc++] = strdup("clvmd");
|
argv[argc++] = "clvmd";
|
||||||
if (!argv[0])
|
|
||||||
goto_out;
|
|
||||||
|
|
||||||
/* Propogate debug options */
|
/* Propogate debug options */
|
||||||
if (clvmd_get_debug()) {
|
if (clvmd_get_debug()) {
|
||||||
if (!(debug_arg = malloc(16)) ||
|
if (dm_snprintf(debug_arg, sizeof(debug_arg), "-d%u", clvmd_get_debug()) < 0)
|
||||||
dm_snprintf(debug_arg, 16, "-d%u", clvmd_get_debug()) < 0)
|
|
||||||
goto_out;
|
goto_out;
|
||||||
argv[argc++] = debug_arg;
|
argv[argc++] = debug_arg;
|
||||||
debug_arg = NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -406,30 +405,26 @@ static int restart_clvmd(void)
|
|||||||
do {
|
do {
|
||||||
hn = get_next_excl_lock(hn, &lv_name);
|
hn = get_next_excl_lock(hn, &lv_name);
|
||||||
if (lv_name) {
|
if (lv_name) {
|
||||||
argv[argc] = strdup("-E");
|
if (!*lv_name)
|
||||||
if (!argv[argc++])
|
break; /* FIXME: Is this error ? */
|
||||||
goto_out;
|
argv[argc++] = "-E";
|
||||||
argv[argc] = strdup(lv_name);
|
argv[argc++] = lv_name;
|
||||||
if (!argv[argc++])
|
|
||||||
goto_out;
|
|
||||||
|
|
||||||
DEBUGLOG("excl lock: %s\n", lv_name);
|
DEBUGLOG("excl lock: %s\n", lv_name);
|
||||||
}
|
}
|
||||||
} while (hn && *lv_name);
|
} while (hn);
|
||||||
argv[argc++] = NULL;
|
argv[argc] = NULL;
|
||||||
|
|
||||||
/* Exec new clvmd */
|
/* Exec new clvmd */
|
||||||
DEBUGLOG("--- Restarting %s ---\n", CLVMD_PATH);
|
DEBUGLOG("--- Restarting %s ---\n", CLVMD_PATH);
|
||||||
|
for (argc = 1; argv[argc]; argc++) DEBUGLOG("--- %d: %s\n", argc, argv[argc]);
|
||||||
|
|
||||||
/* NOTE: This will fail when downgrading! */
|
/* NOTE: This will fail when downgrading! */
|
||||||
execve(CLVMD_PATH, argv, NULL);
|
execve(CLVMD_PATH, (char **)argv, NULL);
|
||||||
out:
|
out:
|
||||||
/* We failed */
|
/* We failed */
|
||||||
DEBUGLOG("Restart of clvmd failed.\n");
|
DEBUGLOG("Restart of clvmd failed.\n");
|
||||||
|
|
||||||
for (i = 0; i < argc && argv[i]; i++)
|
|
||||||
free(argv[i]);
|
|
||||||
free(argv);
|
free(argv);
|
||||||
free(debug_arg);
|
|
||||||
|
|
||||||
return EIO;
|
return EIO;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user