mirror of
git://sourceware.org/git/lvm2.git
synced 2024-12-21 13:34:40 +03:00
Add CLVMD_FLAG_REMOTE to skip processing on local node.
This commit is contained in:
parent
f5bfc8b10d
commit
cab1c8ade1
@ -36,16 +36,17 @@ struct clvm_header {
|
||||
char node[1]; /* Actually a NUL-terminated string, node name.
|
||||
If this is empty then the command is
|
||||
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
|
||||
node name, This member is only
|
||||
valid if the node name is empty */
|
||||
} __attribute__ ((packed));
|
||||
|
||||
/* Flags */
|
||||
#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_NODEERRS 4 /* Reply has errors in node-specific portion */
|
||||
#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_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 */
|
||||
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_RESTART 44
|
||||
#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
|
||||
|
@ -1396,7 +1396,10 @@ static int distribute_command(struct local_client *thisfd)
|
||||
int len = thisfd->bits.localsock.cmd_len;
|
||||
|
||||
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 */
|
||||
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.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);
|
||||
|
||||
DEBUGLOG("Sending message to all cluster nodes\n");
|
||||
@ -1735,8 +1742,12 @@ static int process_local_command(struct clvm_header *msg, int msglen,
|
||||
if (replybuf == NULL)
|
||||
return -1;
|
||||
|
||||
/* FIXME: usage of init_test() is unprotected */
|
||||
status = do_command(client, msg, msglen, &replybuf, buflen, &replylen);
|
||||
/* 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 */
|
||||
status = do_command(client, msg, msglen, &replybuf, buflen, &replylen);
|
||||
|
||||
if (status)
|
||||
client->bits.localsock.all_success = 0;
|
||||
|
@ -13,6 +13,8 @@
|
||||
* 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
|
||||
*/
|
||||
@ -164,21 +166,16 @@ static void _build_header(struct clvm_header *head, int cmd, const char *node,
|
||||
*head->args = '\0';
|
||||
}
|
||||
|
||||
if (node) {
|
||||
/*
|
||||
* Allow a couple of special node names:
|
||||
* "*" for all nodes,
|
||||
* "." for the local node only
|
||||
*/
|
||||
if (strcmp(node, "*") == 0) {
|
||||
head->node[0] = '\0';
|
||||
} else if (strcmp(node, ".") == 0) {
|
||||
head->node[0] = '\0';
|
||||
head->flags = CLVMD_FLAG_LOCAL;
|
||||
} else
|
||||
strcpy(head->node, node);
|
||||
} else
|
||||
/*
|
||||
* Translate special node names.
|
||||
*/
|
||||
if (!node || !strcmp(node, NODE_ALL))
|
||||
head->node[0] = '\0';
|
||||
else if (!strcmp(node, NODE_LOCAL)) {
|
||||
head->node[0] = '\0';
|
||||
head->flags = CLVMD_FLAG_LOCAL;
|
||||
} else
|
||||
strcpy(head->node, node);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -298,7 +295,7 @@ int refresh_clvmd(int all_nodes)
|
||||
int status;
|
||||
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 */
|
||||
for (i = 0; i < num_responses; i++) {
|
||||
@ -329,7 +326,7 @@ int restart_clvmd(int all_nodes)
|
||||
{
|
||||
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.
|
||||
@ -356,9 +353,9 @@ int debug_clvmd(int level, int clusterwide)
|
||||
|
||||
args[0] = level;
|
||||
if (clusterwide)
|
||||
nodes = "*";
|
||||
nodes = NODE_ALL;
|
||||
else
|
||||
nodes = ".";
|
||||
nodes = NODE_LOCAL;
|
||||
|
||||
status = _cluster_request(CLVMD_CMD_SET_DEBUG, nodes, args, 1, &response, &num_responses, 0);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user