1
0
mirror of git://sourceware.org/git/lvm2.git synced 2024-12-22 17:35:59 +03:00

Fix clvmd startup bug introduced in cman/gulm amalgamation. bz#145729

Improve reporting of node-specific locking errors so you'll get
somthing a little more helpfiul than "host is down" - it will now tell
you /which/ host it thinks is down.
This commit is contained in:
Patrick Caulfield 2005-01-21 11:35:24 +00:00
parent d43f7180dc
commit 32e175752c
6 changed files with 41 additions and 26 deletions

View File

@ -6,6 +6,8 @@ Version 2.01.02 -
Split out pool sptype_names to avoid unused const.
Always fail if random id generation fails.
Recognise gnbd devices.
Fix clvmd startup bug introduced in cman/gulm amalgamation.
Improve reporting of node-specific locking errors.
Version 2.01.01 - 19th January 2005
===================================

View File

@ -43,6 +43,7 @@ struct clvm_header {
/* 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 */
/* Name of the local socket to communicate between libclvm and clvmd */
//static const char CLVMD_SOCKNAME[]="/var/run/clvmd";

View File

@ -104,6 +104,11 @@ static int _init_cluster(void)
return 0;
}
static void _cluster_init_completed(void)
{
clvmd_cluster_init_completed();
}
static int _get_main_cluster_fd()
{
return cluster_sock;
@ -507,7 +512,7 @@ static int _sync_unlock(const char *resource /* UNUSED */, int lockid)
}
static struct cluster_ops _cluster_cman_ops = {
.cluster_init_completed = NULL,
.cluster_init_completed = _cluster_init_completed,
.cluster_send_message = _cluster_send_message,
.name_from_csid = _name_from_csid,
.csid_from_name = _csid_from_name,

View File

@ -913,11 +913,6 @@ static int get_all_cluster_nodes()
return 0;
}
static void _cluster_init_completed(void)
{
clvmd_cluster_init_completed();
}
static int _get_main_cluster_fd(void)
{
return get_main_gulm_cluster_fd();
@ -934,7 +929,7 @@ static int _cluster_send_message(void *buf, int msglen, char *csid, const char *
}
static struct cluster_ops _cluster_gulm_ops = {
.cluster_init_completed = _cluster_init_completed,
.cluster_init_completed = NULL,
.cluster_send_message = _cluster_send_message,
.name_from_csid = gulm_name_from_csid,
.csid_from_name = _csid_from_name,

View File

@ -785,7 +785,7 @@ static int read_from_local_sock(struct local_client *thisfd)
if (thisfd->bits.localsock.in_progress) {
struct clvm_header reply;
reply.cmd = CLVMD_CMD_REPLY;
reply.status = -EBUSY;
reply.status = EBUSY;
reply.arglen = 0;
reply.flags = 0;
send_message(&reply, sizeof(reply), our_csid,
@ -808,7 +808,7 @@ static int read_from_local_sock(struct local_client *thisfd)
if (!thisfd->bits.localsock.cmd) {
struct clvm_header reply;
reply.cmd = CLVMD_CMD_REPLY;
reply.status = -ENOMEM;
reply.status = ENOMEM;
reply.arglen = 0;
reply.flags = 0;
send_message(&reply, sizeof(reply), our_csid,
@ -855,7 +855,7 @@ static int read_from_local_sock(struct local_client *thisfd)
DEBUGLOG("Unknown node: '%s'\n", inheader->node);
reply.cmd = CLVMD_CMD_REPLY;
reply.status = -ENOENT;
reply.status = ENOENT;
reply.flags = 0;
reply.arglen = 0;
send_message(&reply, sizeof(reply), our_csid,
@ -886,7 +886,7 @@ static int read_from_local_sock(struct local_client *thisfd)
close(comms_pipe[1]);
reply.cmd = CLVMD_CMD_REPLY;
reply.status = -ENOMEM;
reply.status = ENOMEM;
reply.arglen = 0;
reply.flags = 0;
send_message(&reply, sizeof(reply), our_csid,
@ -1076,7 +1076,7 @@ void process_remote_command(struct clvm_header *msg, int msglen, int fd,
/* Return a failure response */
head.cmd = CLVMD_CMD_REPLY;
head.status = -EFBIG;
head.status = EFBIG;
head.flags = 0;
head.clientid = msg->clientid;
head.arglen = 0;
@ -1093,7 +1093,7 @@ void process_remote_command(struct clvm_header *msg, int msglen, int fd,
msg->arglen);
/* Return a failure response */
head.cmd = CLVMD_CMD_REPLY;
head.status = -ENOMEM;
head.status = ENOMEM;
head.flags = 0;
head.clientid = msg->clientid;
head.arglen = 0;
@ -1156,7 +1156,7 @@ void process_remote_command(struct clvm_header *msg, int msglen, int fd,
do_command(NULL, msg, msglen, &replyargs, buflen,
&replylen);
} else {
status = -ENOMEM;
status = ENOMEM;
}
/* If it wasn't a reply, then reply */
@ -1191,7 +1191,7 @@ void process_remote_command(struct clvm_header *msg, int msglen, int fd,
(aggreply,
replylen + sizeof(struct clvm_header)) < 0
&& replylen > 0)
agghead->status = -EFBIG;
agghead->status = EFBIG;
send_message(agghead,
sizeof(struct clvm_header), csid,
@ -1216,7 +1216,7 @@ void process_remote_command(struct clvm_header *msg, int msglen, int fd,
DEBUGLOG("Error attempting to realloc return buffer\n");
/* Return a failure response */
head.cmd = CLVMD_CMD_REPLY;
head.status = -ENOMEM;
head.status = ENOMEM;
head.flags = 0;
head.clientid = msg->clientid;
head.arglen = 0;
@ -1254,7 +1254,7 @@ static void add_reply_to_list(struct local_client *client, int status,
if (len > 0) {
reply->replymsg = malloc(len);
if (!reply->replymsg) {
reply->status = -ENOMEM;
reply->status = ENOMEM;
} else {
memcpy(reply->replymsg, buf, len);
}
@ -1445,9 +1445,10 @@ static void send_local_reply(struct local_client *client, int status, int fd)
replybuf = malloc(message_len);
clientreply = (struct clvm_header *) replybuf;
clientreply->status = -status;
clientreply->status = status;
clientreply->cmd = CLVMD_CMD_REPLY;
clientreply->node[0] = '\0';
clientreply->flags = 0;
ptr = clientreply->args;
@ -1459,6 +1460,9 @@ static void send_local_reply(struct local_client *client, int status, int fd)
strcpy(ptr, thisreply->node);
ptr += strlen(thisreply->node) + 1;
if (thisreply->status)
clientreply->flags |= CLVMD_FLAG_NODEERRS;
*(int *) ptr = thisreply->status;
ptr += sizeof(int);
@ -1627,7 +1631,7 @@ static int add_to_lvmqueue(struct local_client *client, struct clvm_header *msg,
cmd = malloc(sizeof(struct lvm_thread_cmd));
if (!cmd)
return -ENOMEM;
return ENOMEM;
cmd->msg = malloc(msglen);
if (!cmd->msg) {
@ -1709,7 +1713,7 @@ static void check_all_callback(struct local_client *client, char *csid,
int node_up)
{
if (!node_up)
add_reply_to_list(client, -EHOSTDOWN, csid, "CLVMD not running",
add_reply_to_list(client, EHOSTDOWN, csid, "CLVMD not running",
18);
}

View File

@ -147,10 +147,16 @@ static int _send_request(char *inbuf, int inlen, char **retbuf)
}
/* Was it an error ? */
if (outheader->status < 0) {
errno = -outheader->status;
log_error("cluster request failed: %s", strerror(errno));
return 0;
if (outheader->status != 0) {
errno = outheader->status;
/* Only return an error here if there are no node-specific
errors present in the message that might have more detail */
if (!(outheader->flags & CLVMD_FLAG_NODEERRS)) {
log_error("cluster request failed: %s", strerror(errno));
return 0;
}
}
return 1;
@ -328,7 +334,7 @@ static int _lock_for_cluster(unsigned char cmd, unsigned int flags, char *name)
* VG locks are just that: locks, and have no side effects
* so we only need to do them on the local node because all
* locks are cluster-wide.
* Also, if the lock is exclusive it makes no sense to try to
* Also, if the lock is exclusive it makes no sense to try to
* acquire it on all nodes, so just do that on the local node too.
*/
if (cmd == CLVMD_CMD_LOCK_VG ||
@ -341,10 +347,11 @@ static int _lock_for_cluster(unsigned char cmd, unsigned int flags, char *name)
/* If any nodes were down then display them and return an error */
for (i = 0; i < num_responses; i++) {
if (response[i].status == -EHOSTDOWN) {
if (response[i].status == EHOSTDOWN) {
log_error("clvmd not running on node %s",
response[i].node);
status = 0;
errno = response[i].status;
} else if (response[i].status) {
log_error("Error locking on node %s: %s",
response[i].node,
@ -352,6 +359,7 @@ static int _lock_for_cluster(unsigned char cmd, unsigned int flags, char *name)
response[i].response :
strerror(response[i].status));
status = 0;
errno = response[i].status;
}
}