diff options
author | Christine Caulfield <ccaulfie@redhat.com> | 2010-04-20 14:07:37 +0000 |
---|---|---|
committer | Christine Caulfield <ccaulfie@redhat.com> | 2010-04-20 14:07:37 +0000 |
commit | c407d2bd11c6a8e364cfd6a5190bea7d7456db93 (patch) | |
tree | 0c913357163f6df3e9aff1f161f2c71848c49cc6 /daemons/clvmd/clvmd-command.c | |
parent | 49ada7a2c3f664aa2c3e17e2adf4abaf2a04d17d (diff) | |
download | lvm2-c407d2bd11c6a8e364cfd6a5190bea7d7456db93.tar.gz lvm2-c407d2bd11c6a8e364cfd6a5190bea7d7456db93.tar.xz lvm2-c407d2bd11c6a8e364cfd6a5190bea7d7456db93.zip |
Add -S command to clvmd, so it can restart itself and still
preserve exlusive LV locks.
Diffstat (limited to 'daemons/clvmd/clvmd-command.c')
-rw-r--r-- | daemons/clvmd/clvmd-command.c | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/daemons/clvmd/clvmd-command.c b/daemons/clvmd/clvmd-command.c index 0d9d09f8..091232e4 100644 --- a/daemons/clvmd/clvmd-command.c +++ b/daemons/clvmd/clvmd-command.c @@ -80,6 +80,7 @@ extern debug_t debug; extern struct cluster_ops *clops; +static int restart_clvmd(void); /* This is where all the real work happens: NOTE: client will be NULL when this is executed on a remote node */ @@ -158,6 +159,10 @@ int do_command(struct local_client *client, struct clvm_header *msg, int msglen, debug = args[0]; break; + case CLVMD_CMD_RESTART: + restart_clvmd(); + break; + case CLVMD_CMD_GET_CLUSTERNAME: status = clops->get_cluster_name(*buf, buflen); if (!status) @@ -285,6 +290,7 @@ int do_pre_command(struct local_client *client) case CLVMD_CMD_SET_DEBUG: case CLVMD_CMD_VG_BACKUP: case CLVMD_CMD_LOCK_QUERY: + case CLVMD_CMD_RESTART: break; default: @@ -351,3 +357,50 @@ void cmd_client_cleanup(struct local_client *client) client->bits.localsock.private = 0; } } + + +static int restart_clvmd(void) +{ + char *argv[1024]; + int argc = 1; + struct dm_hash_node *hn = NULL; + char *lv_name; + + DEBUGLOG("clvmd restart requested\n"); + + /* + * Build the command-line + */ + argv[0] = strdup("clvmd"); + + /* Propogate debug options */ + if (debug) { + char debug_level[16]; + + sprintf(debug_level, "-d%d", debug); + argv[argc++] = strdup(debug_level); + } + + /* Now add the exclusively-open LVs */ + do { + hn = get_next_excl_lock(hn, &lv_name); + if (lv_name) { + argv[argc++] = strdup("-E"); + argv[argc++] = strdup(lv_name); + + DEBUGLOG("excl lock: %s\n", lv_name); + hn = get_next_excl_lock(hn, &lv_name); + } + } while (hn && *lv_name); + argv[argc++] = NULL; + + /* Tidy up */ + destroy_lvm(); + + /* Exec new clvmd */ + /* NOTE: This will fail when downgrading! */ + execve("clvmd", argv, NULL); + + /* We failed */ + return 0; +} |