mirror of
git://sourceware.org/git/lvm2.git
synced 2025-01-03 05:18:29 +03:00
Add CLVMD_FLAG_REMOTE to skip processing on local node.
This commit is contained in:
parent
f5bfc8b10d
commit
cab1c8ade1
@ -36,7 +36,7 @@ struct clvm_header {
|
|||||||
char node[1]; /* Actually a NUL-terminated string, node name.
|
char node[1]; /* Actually a NUL-terminated string, node name.
|
||||||
If this is empty then the command is
|
If this is empty then the command is
|
||||||
forwarded to all cluster nodes unless
|
forwarded to all cluster nodes unless
|
||||||
FLAG_LOCAL is also set. */
|
FLAG_LOCAL or FLAG_REMOTE is also set. */
|
||||||
char args[1]; /* Arguments for the command follow the
|
char args[1]; /* Arguments for the command follow the
|
||||||
node name, This member is only
|
node name, This member is only
|
||||||
valid if the node name is empty */
|
valid if the node name is empty */
|
||||||
@ -46,6 +46,7 @@ struct clvm_header {
|
|||||||
#define CLVMD_FLAG_LOCAL 1 /* Only do this on the local node */
|
#define CLVMD_FLAG_LOCAL 1 /* Only do this on the local node */
|
||||||
#define CLVMD_FLAG_SYSTEMLV 2 /* Data in system LV under my node name */
|
#define CLVMD_FLAG_SYSTEMLV 2 /* Data in system LV under my node name */
|
||||||
#define CLVMD_FLAG_NODEERRS 4 /* Reply has errors in node-specific portion */
|
#define CLVMD_FLAG_NODEERRS 4 /* Reply has errors in node-specific portion */
|
||||||
|
#define CLVMD_FLAG_REMOTE 8 /* Do this on all nodes except for the local node */
|
||||||
|
|
||||||
/* Name of the local socket to communicate between lvm and clvmd */
|
/* Name of the local socket to communicate between lvm and clvmd */
|
||||||
static const char CLVMD_SOCKNAME[]= DEFAULT_RUN_DIR "/clvmd.sock";
|
static const char CLVMD_SOCKNAME[]= DEFAULT_RUN_DIR "/clvmd.sock";
|
||||||
@ -72,4 +73,10 @@ static const char CLVMD_SOCKNAME[]= DEFAULT_RUN_DIR "/clvmd.sock";
|
|||||||
#define CLVMD_CMD_VG_BACKUP 43
|
#define CLVMD_CMD_VG_BACKUP 43
|
||||||
#define CLVMD_CMD_RESTART 44
|
#define CLVMD_CMD_RESTART 44
|
||||||
#define CLVMD_CMD_SYNC_NAMES 45
|
#define CLVMD_CMD_SYNC_NAMES 45
|
||||||
|
|
||||||
|
/* Used internally by some callers, but not part of the protocol.*/
|
||||||
|
#define NODE_ALL "*"
|
||||||
|
#define NODE_LOCAL "."
|
||||||
|
#define NODE_REMOTE "^"
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -1396,7 +1396,10 @@ static int distribute_command(struct local_client *thisfd)
|
|||||||
int len = thisfd->bits.localsock.cmd_len;
|
int len = thisfd->bits.localsock.cmd_len;
|
||||||
|
|
||||||
thisfd->xid = global_xid++;
|
thisfd->xid = global_xid++;
|
||||||
DEBUGLOG("distribute command: XID = %d\n", thisfd->xid);
|
DEBUGLOG("distribute command: XID = %d, flags=0x%x (%s%s)\n",
|
||||||
|
thisfd->xid, inheader->flags,
|
||||||
|
(inheader->flags & CLVMD_FLAG_LOCAL) ? "LOCAL" : "",
|
||||||
|
(inheader->flags & CLVMD_FLAG_REMOTE) ? "REMOTE" : "");
|
||||||
|
|
||||||
/* Forward it to other nodes in the cluster if needed */
|
/* Forward it to other nodes in the cluster if needed */
|
||||||
if (!(inheader->flags & CLVMD_FLAG_LOCAL)) {
|
if (!(inheader->flags & CLVMD_FLAG_LOCAL)) {
|
||||||
@ -1409,7 +1412,11 @@ static int distribute_command(struct local_client *thisfd)
|
|||||||
thisfd->bits.localsock.in_progress = TRUE;
|
thisfd->bits.localsock.in_progress = TRUE;
|
||||||
thisfd->bits.localsock.sent_out = TRUE;
|
thisfd->bits.localsock.sent_out = TRUE;
|
||||||
|
|
||||||
/* Do it here first */
|
/*
|
||||||
|
* Send to local node first, even if CLVMD_FLAG_REMOTE
|
||||||
|
* is set so we still get a reply if this is the
|
||||||
|
* only node.
|
||||||
|
*/
|
||||||
add_to_lvmqueue(thisfd, inheader, len, NULL);
|
add_to_lvmqueue(thisfd, inheader, len, NULL);
|
||||||
|
|
||||||
DEBUGLOG("Sending message to all cluster nodes\n");
|
DEBUGLOG("Sending message to all cluster nodes\n");
|
||||||
@ -1735,6 +1742,10 @@ static int process_local_command(struct clvm_header *msg, int msglen,
|
|||||||
if (replybuf == NULL)
|
if (replybuf == NULL)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
|
/* If remote flag is set, just set a successful status code. */
|
||||||
|
if (msg->flags & CLVMD_FLAG_REMOTE)
|
||||||
|
status = 0;
|
||||||
|
else
|
||||||
/* FIXME: usage of init_test() is unprotected */
|
/* FIXME: usage of init_test() is unprotected */
|
||||||
status = do_command(client, msg, msglen, &replybuf, buflen, &replylen);
|
status = do_command(client, msg, msglen, &replybuf, buflen, &replylen);
|
||||||
|
|
||||||
|
@ -13,6 +13,8 @@
|
|||||||
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/* FIXME Remove duplicated functions from this file. */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Send a command to a running clvmd from the command-line
|
* Send a command to a running clvmd from the command-line
|
||||||
*/
|
*/
|
||||||
@ -164,21 +166,16 @@ static void _build_header(struct clvm_header *head, int cmd, const char *node,
|
|||||||
*head->args = '\0';
|
*head->args = '\0';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (node) {
|
|
||||||
/*
|
/*
|
||||||
* Allow a couple of special node names:
|
* Translate special node names.
|
||||||
* "*" for all nodes,
|
|
||||||
* "." for the local node only
|
|
||||||
*/
|
*/
|
||||||
if (strcmp(node, "*") == 0) {
|
if (!node || !strcmp(node, NODE_ALL))
|
||||||
head->node[0] = '\0';
|
head->node[0] = '\0';
|
||||||
} else if (strcmp(node, ".") == 0) {
|
else if (!strcmp(node, NODE_LOCAL)) {
|
||||||
head->node[0] = '\0';
|
head->node[0] = '\0';
|
||||||
head->flags = CLVMD_FLAG_LOCAL;
|
head->flags = CLVMD_FLAG_LOCAL;
|
||||||
} else
|
} else
|
||||||
strcpy(head->node, node);
|
strcpy(head->node, node);
|
||||||
} else
|
|
||||||
head->node[0] = '\0';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -298,7 +295,7 @@ int refresh_clvmd(int all_nodes)
|
|||||||
int status;
|
int status;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
status = _cluster_request(CLVMD_CMD_REFRESH, all_nodes?"*":".", args, 0, &response, &num_responses, 0);
|
status = _cluster_request(CLVMD_CMD_REFRESH, all_nodes ? NODE_ALL : NODE_LOCAL, args, 0, &response, &num_responses, 0);
|
||||||
|
|
||||||
/* If any nodes were down then display them and return an error */
|
/* If any nodes were down then display them and return an error */
|
||||||
for (i = 0; i < num_responses; i++) {
|
for (i = 0; i < num_responses; i++) {
|
||||||
@ -329,7 +326,7 @@ int restart_clvmd(int all_nodes)
|
|||||||
{
|
{
|
||||||
int dummy, status;
|
int dummy, status;
|
||||||
|
|
||||||
status = _cluster_request(CLVMD_CMD_RESTART, all_nodes?"*":".", NULL, 0, NULL, &dummy, 1);
|
status = _cluster_request(CLVMD_CMD_RESTART, all_nodes ? NODE_ALL : NODE_LOCAL, NULL, 0, NULL, &dummy, 1);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* FIXME: we cannot receive response, clvmd re-exec before it.
|
* FIXME: we cannot receive response, clvmd re-exec before it.
|
||||||
@ -356,9 +353,9 @@ int debug_clvmd(int level, int clusterwide)
|
|||||||
|
|
||||||
args[0] = level;
|
args[0] = level;
|
||||||
if (clusterwide)
|
if (clusterwide)
|
||||||
nodes = "*";
|
nodes = NODE_ALL;
|
||||||
else
|
else
|
||||||
nodes = ".";
|
nodes = NODE_LOCAL;
|
||||||
|
|
||||||
status = _cluster_request(CLVMD_CMD_SET_DEBUG, nodes, args, 1, &response, &num_responses, 0);
|
status = _cluster_request(CLVMD_CMD_SET_DEBUG, nodes, args, 1, &response, &num_responses, 0);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user