summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--source4/cluster/ctdb/brlock_ctdb.c90
-rw-r--r--source4/cluster/ctdb/common/ctdb_call.c31
-rw-r--r--source4/cluster/ctdb/include/ctdb.h2
-rw-r--r--source4/cluster/ctdb/include/ctdb_private.h1
4 files changed, 33 insertions, 91 deletions
diff --git a/source4/cluster/ctdb/brlock_ctdb.c b/source4/cluster/ctdb/brlock_ctdb.c
index bc2fbbc03e..e847a6f50c 100644
--- a/source4/cluster/ctdb/brlock_ctdb.c
+++ b/source4/cluster/ctdb/brlock_ctdb.c
@@ -360,17 +360,7 @@ static int brl_ctdb_lock_func(struct ctdb_call_info *call)
}
reply:
- call->reply_data = talloc(call, TDB_DATA);
- if (call->reply_data == NULL) {
- return CTDB_ERR_NOMEM;
- }
-
- call->reply_data->dptr = talloc_size(call, sizeof(NTSTATUS));
- call->reply_data->dsize = sizeof(NTSTATUS);
- if (call->reply_data->dptr == NULL) {
- return CTDB_ERR_NOMEM;
- }
- *(NTSTATUS *)call->reply_data->dptr = status;
+ call->status = NT_STATUS_V(status);
return 0;
}
@@ -392,7 +382,6 @@ static NTSTATUS brl_ctdb_lock(struct brl_context *brl,
{
struct ctdb_lock_req req;
struct ctdb_call call;
- NTSTATUS status;
int ret;
call.call_id = FUNC_BRL_LOCK;
@@ -416,10 +405,7 @@ static NTSTATUS brl_ctdb_lock(struct brl_context *brl,
return NT_STATUS_INTERNAL_DB_CORRUPTION;
}
- status = *(NTSTATUS *)call.reply_data.dptr;
- talloc_free(call.reply_data.dptr);
-
- return status;
+ return NT_STATUS(call.status);
}
#if ENABLE_NOTIFIES
@@ -560,17 +546,7 @@ found:
status = NT_STATUS_RANGE_NOT_LOCKED;
}
- call->reply_data = talloc(call, TDB_DATA);
- if (call->reply_data == NULL) {
- return CTDB_ERR_NOMEM;
- }
-
- call->reply_data->dptr = talloc_size(call, sizeof(NTSTATUS));
- call->reply_data->dsize = sizeof(NTSTATUS);
- if (call->reply_data->dptr == NULL) {
- return CTDB_ERR_NOMEM;
- }
- *(NTSTATUS *)call->reply_data->dptr = status;
+ call->status = NT_STATUS_V(status);
return 0;
}
@@ -586,7 +562,6 @@ static NTSTATUS brl_ctdb_unlock(struct brl_context *brl,
{
struct ctdb_call call;
struct ctdb_unlock_req req;
- NTSTATUS status;
int ret;
call.call_id = FUNC_BRL_UNLOCK;
@@ -609,10 +584,7 @@ static NTSTATUS brl_ctdb_unlock(struct brl_context *brl,
return NT_STATUS_INTERNAL_DB_CORRUPTION;
}
- status = *(NTSTATUS *)call.reply_data.dptr;
- talloc_free(call.reply_data.dptr);
-
- return status;
+ return NT_STATUS(call.status);
}
@@ -669,17 +641,7 @@ static int brl_ctdb_remove_pending_func(struct ctdb_call_info *call)
status = NT_STATUS_RANGE_NOT_LOCKED;
}
- call->reply_data = talloc(call, TDB_DATA);
- if (call->reply_data == NULL) {
- return CTDB_ERR_NOMEM;
- }
-
- call->reply_data->dptr = talloc_size(call, sizeof(NTSTATUS));
- call->reply_data->dsize = sizeof(NTSTATUS);
- if (call->reply_data->dptr == NULL) {
- return CTDB_ERR_NOMEM;
- }
- *(NTSTATUS *)call->reply_data->dptr = status;
+ call->status = NT_STATUS_V(status);
return 0;
}
@@ -690,7 +652,6 @@ static NTSTATUS brl_ctdb_remove_pending(struct brl_context *brl,
{
struct ctdb_call call;
struct ctdb_remove_pending_req req;
- NTSTATUS status;
int ret;
call.call_id = FUNC_BRL_REMOVE_PENDING;
@@ -709,10 +670,7 @@ static NTSTATUS brl_ctdb_remove_pending(struct brl_context *brl,
return NT_STATUS_INTERNAL_DB_CORRUPTION;
}
- status = *(NTSTATUS *)call.reply_data.dptr;
- talloc_free(call.reply_data.dptr);
-
- return status;
+ return NT_STATUS(call.status);
}
@@ -760,17 +718,7 @@ static int brl_ctdb_locktest_func(struct ctdb_call_info *call)
}
}
- call->reply_data = talloc(call, TDB_DATA);
- if (call->reply_data == NULL) {
- return CTDB_ERR_NOMEM;
- }
-
- call->reply_data->dptr = talloc_size(call, sizeof(NTSTATUS));
- call->reply_data->dsize = sizeof(NTSTATUS);
- if (call->reply_data->dptr == NULL) {
- return CTDB_ERR_NOMEM;
- }
- *(NTSTATUS *)call->reply_data->dptr = status;
+ call->status = NT_STATUS_V(status);
return 0;
}
@@ -786,7 +734,6 @@ static NTSTATUS brl_ctdb_locktest(struct brl_context *brl,
{
struct ctdb_call call;
struct ctdb_locktest_req req;
- NTSTATUS status;
int ret;
call.call_id = FUNC_BRL_LOCKTEST;
@@ -810,10 +757,7 @@ static NTSTATUS brl_ctdb_locktest(struct brl_context *brl,
return NT_STATUS_INTERNAL_DB_CORRUPTION;
}
- status = *(NTSTATUS *)call.reply_data.dptr;
- talloc_free(call.reply_data.dptr);
-
- return status;
+ return NT_STATUS(call.status);
}
@@ -874,17 +818,7 @@ static int brl_ctdb_close_func(struct ctdb_call_info *call)
memcpy(call->new_data->dptr, locks, count*sizeof(struct lock_struct));
}
- call->reply_data = talloc(call, TDB_DATA);
- if (call->reply_data == NULL) {
- return CTDB_ERR_NOMEM;
- }
-
- call->reply_data->dptr = talloc_size(call, sizeof(NTSTATUS));
- call->reply_data->dsize = sizeof(NTSTATUS);
- if (call->reply_data->dptr == NULL) {
- return CTDB_ERR_NOMEM;
- }
- *(NTSTATUS *)call->reply_data->dptr = status;
+ call->status = NT_STATUS_V(status);
return 0;
}
@@ -897,7 +831,6 @@ static NTSTATUS brl_ctdb_close(struct brl_context *brl,
{
struct ctdb_call call;
struct ctdb_close_req req;
- NTSTATUS status;
int ret;
call.call_id = FUNC_BRL_CLOSE;
@@ -917,10 +850,7 @@ static NTSTATUS brl_ctdb_close(struct brl_context *brl,
return NT_STATUS_INTERNAL_DB_CORRUPTION;
}
- status = *(NTSTATUS *)call.reply_data.dptr;
- talloc_free(call.reply_data.dptr);
-
- return status;
+ return NT_STATUS(call.status);
}
diff --git a/source4/cluster/ctdb/common/ctdb_call.c b/source4/cluster/ctdb/common/ctdb_call.c
index 3949206a55..0169baf906 100644
--- a/source4/cluster/ctdb/common/ctdb_call.c
+++ b/source4/cluster/ctdb/common/ctdb_call.c
@@ -61,6 +61,7 @@ static int ctdb_call_local(struct ctdb_context *ctdb, struct ctdb_call *call,
CTDB_NO_MEMORY(ctdb, c->record_data.dptr);
c->new_data = NULL;
c->reply_data = NULL;
+ c->status = 0;
for (fn=ctdb->calls;fn;fn=fn->next) {
if (fn->id == call->call_id) break;
@@ -101,6 +102,7 @@ static int ctdb_call_local(struct ctdb_context *ctdb, struct ctdb_call *call,
call->reply_data.dptr = NULL;
call->reply_data.dsize = 0;
}
+ call->status = c->status;
talloc_free(c);
@@ -333,12 +335,15 @@ void ctdb_request_call(struct ctdb_context *ctdb, struct ctdb_req_header *hdr)
r->hdr.destnode = hdr->srcnode;
r->hdr.srcnode = hdr->destnode;
r->hdr.reqid = hdr->reqid;
+ r->status = call.status;
r->datalen = call.reply_data.dsize;
- memcpy(&r->data[0], call.reply_data.dptr, call.reply_data.dsize);
+ if (call.reply_data.dsize) {
+ memcpy(&r->data[0], call.reply_data.dptr, call.reply_data.dsize);
+ talloc_free(call.reply_data.dptr);
+ }
ctdb_queue_packet(ctdb, &r->hdr);
- talloc_free(call.reply_data.dptr);
talloc_free(r);
}
@@ -368,15 +373,13 @@ void ctdb_reply_call(struct ctdb_context *ctdb, struct ctdb_req_header *hdr)
{
struct ctdb_reply_call *c = (struct ctdb_reply_call *)hdr;
struct ctdb_call_state *state;
- TDB_DATA reply_data;
state = idr_find(ctdb->idr, hdr->reqid);
if (state == NULL) return;
- reply_data.dptr = c->data;
- reply_data.dsize = c->datalen;
-
- state->call.reply_data = reply_data;
+ state->call.reply_data.dptr = c->data;
+ state->call.reply_data.dsize = c->datalen;
+ state->call.status = c->status;
talloc_steal(state, c);
@@ -594,10 +597,16 @@ int ctdb_call_recv(struct ctdb_call_state *state, struct ctdb_call *call)
talloc_free(state);
return -1;
}
- call->reply_data.dptr = talloc_memdup(state->node->ctdb,
- state->call.reply_data.dptr,
- state->call.reply_data.dsize);
- call->reply_data.dsize = state->call.reply_data.dsize;
+ if (state->call.reply_data.dsize) {
+ call->reply_data.dptr = talloc_memdup(state->node->ctdb,
+ state->call.reply_data.dptr,
+ state->call.reply_data.dsize);
+ call->reply_data.dsize = state->call.reply_data.dsize;
+ } else {
+ call->reply_data.dptr = NULL;
+ call->reply_data.dsize = 0;
+ }
+ call->status = state->call.status;
talloc_free(state);
return 0;
}
diff --git a/source4/cluster/ctdb/include/ctdb.h b/source4/cluster/ctdb/include/ctdb.h
index 8a2006f678..7eebcb83db 100644
--- a/source4/cluster/ctdb/include/ctdb.h
+++ b/source4/cluster/ctdb/include/ctdb.h
@@ -26,6 +26,7 @@ struct ctdb_call {
TDB_DATA key;
TDB_DATA call_data;
TDB_DATA reply_data;
+ uint32_t status;
};
/*
@@ -37,6 +38,7 @@ struct ctdb_call_info {
TDB_DATA *new_data; /* optionally updated record data */
TDB_DATA *call_data; /* optionally passed from caller */
TDB_DATA *reply_data; /* optionally returned by function */
+ uint32_t status; /* optional reply status - defaults to zero */
};
#define CTDB_ERR_INVALID 1
diff --git a/source4/cluster/ctdb/include/ctdb_private.h b/source4/cluster/ctdb/include/ctdb_private.h
index db7da8fcaf..977206f400 100644
--- a/source4/cluster/ctdb/include/ctdb_private.h
+++ b/source4/cluster/ctdb/include/ctdb_private.h
@@ -162,6 +162,7 @@ struct ctdb_req_call {
struct ctdb_reply_call {
struct ctdb_req_header hdr;
+ uint32_t status;
uint32_t datalen;
uint8_t data[1];
};