svn commit: samba r20945 - in branches/SAMBA_4_0/source/cluster/ctdb: . common include

tridge at samba.org tridge at samba.org
Mon Jan 22 09:35:27 GMT 2007


Author: tridge
Date: 2007-01-22 09:35:26 +0000 (Mon, 22 Jan 2007)
New Revision: 20945

WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=20945

Log:

fixed the bug causing locktest to fail with the ctdb backend after a
couple of hundred opertations. Also removed a lot of the debug code I
was using to track this down.

Modified:
   branches/SAMBA_4_0/source/cluster/ctdb/brlock_ctdb.c
   branches/SAMBA_4_0/source/cluster/ctdb/common/ctdb.c
   branches/SAMBA_4_0/source/cluster/ctdb/common/ctdb_call.c
   branches/SAMBA_4_0/source/cluster/ctdb/common/ctdb_ltdb.c
   branches/SAMBA_4_0/source/cluster/ctdb/include/ctdb_private.h


Changeset:
Modified: branches/SAMBA_4_0/source/cluster/ctdb/brlock_ctdb.c
===================================================================
--- branches/SAMBA_4_0/source/cluster/ctdb/brlock_ctdb.c	2007-01-22 04:04:36 UTC (rev 20944)
+++ branches/SAMBA_4_0/source/cluster/ctdb/brlock_ctdb.c	2007-01-22 09:35:26 UTC (rev 20945)
@@ -101,8 +101,6 @@
 	brl->server = server;
 	brl->messaging_ctx = messaging_ctx;
 
-	DEBUG(0,("brl_ctdb_init: brl=%p\n", brl));
-
 	return brl;
 }
 
@@ -116,9 +114,6 @@
 		return NULL;
 	}
 
-	DEBUG(0,("file_key\n"));
-	dump_data(0,file_key->data, file_key->length);
-
 	brlh->key = *file_key;
 	brlh->ntvfs = ntvfs;
 	ZERO_STRUCT(brlh->last_lock);
@@ -261,23 +256,6 @@
 	return NT_STATUS_LOCK_NOT_GRANTED;
 }
 
-
-static void show_locks(const char *op, struct lock_struct *locks, int count)
-{
-	int i;
-	DEBUG(0,("OP: %s\n", op));
-	for (i=0;i<count;i++) {
-		DEBUG(0,("%2d: %4d %4d %d.%d.%d %p %p\n",
-			 i, (int)locks[i].start, (int)locks[i].size, 
-			 locks[i].context.server.node,
-			 locks[i].context.server.id,
-			 locks[i].context.smbpid,
-			 locks[i].context.ctx,
-			 locks[i].ntvfs));
-	}
-}
-
-
 struct ctdb_lock_req {
 	uint16_t smbpid;
 	uint64_t start;
@@ -333,23 +311,11 @@
 	lock.lock_type = req->lock_type;
 	lock.notify_ptr = req->notify_ptr;
 
-	{
-		int xlen = sizeof(lock);
-		uint8_t *xx = &lock;
-		int ii, fd = open("/dev/null", O_WRONLY);
-		for (ii=0;ii<xlen;ii++) {
-			write(fd, &xx[ii], 1);
-		}
-		close(fd);
-	}
-
 	if (dbuf.dptr) {
 		/* there are existing locks - make sure they don't conflict */
 		locks = (struct lock_struct *)dbuf.dptr;
 		count = dbuf.dsize / sizeof(*locks);
 
-		show_locks("lock", locks, count);
-
 		for (i=0; i<count; i++) {
 			if (brl_ctdb_conflict(&locks[i], &lock)) {
 				status = NT_STATUS_LOCK_NOT_GRANTED;
@@ -375,8 +341,6 @@
 		status = NT_STATUS_LOCK_NOT_GRANTED;
 	}
 
-	DEBUG(0,("lock: size now %d\n", call->new_data->dsize));
-
 reply:
 	call->reply_data = talloc(call, TDB_DATA);
 	if (call->reply_data == NULL) {
@@ -428,10 +392,9 @@
 	req.server = brl->server;
 	req.brl = brl;
 	req.ntvfs = brlh->ntvfs;
-		
+
 	ret = ctdb_call(brl->ctdb, kbuf, FUNC_BRL_LOCK, &rbuf, &sbuf);
 	if (ret == -1) {
-		DEBUG(0,("ctdb_call failed - %s\n", __location__));
 		return NT_STATUS_INTERNAL_DB_CORRUPTION;
 	}
 
@@ -523,8 +486,6 @@
 	locks = (struct lock_struct *)dbuf.dptr;
 	count = dbuf.dsize / sizeof(*locks);
 
-	show_locks("unlock", locks, count);
-
 	for (i=0; i<count; i++) {
 		struct lock_struct *lock = &locks[i];
 		
@@ -561,10 +522,6 @@
 		}
 	}
 
-	if (call->new_data) {
-		DEBUG(0,("unlock: size now %d\n", call->new_data->dsize));
-	}
-	
 	if (i == count) {
 		/* we didn't find it */
 		status = NT_STATUS_RANGE_NOT_LOCKED;
@@ -650,8 +607,6 @@
 	locks = (struct lock_struct *)dbuf.dptr;
 	count = dbuf.dsize / sizeof(*locks);
 
-	show_locks("remove_pending", locks, count);
-
 	for (i=0; i<count; i++) {
 		struct lock_struct *lock = &locks[i];
 		
@@ -676,10 +631,6 @@
 		}
 	}
 	
-	if (call->new_data) {
-		DEBUG(0,("remove_pending: size now %d\n", call->new_data->dsize));
-	}
-
 	if (i == count) {
 		/* we didn't find it */
 		status = NT_STATUS_RANGE_NOT_LOCKED;
@@ -769,8 +720,6 @@
 	locks = (struct lock_struct *)dbuf.dptr;
 	count = dbuf.dsize / sizeof(*locks);
 
-	show_locks("locktest", locks, count);
-
 	for (i=0; i<count; i++) {
 		if (brl_ctdb_conflict_other(&locks[i], &lock)) {
 			status = NT_STATUS_FILE_LOCK_CONFLICT;
@@ -860,11 +809,6 @@
 	locks = (struct lock_struct *)dbuf.dptr;
 	count = dbuf.dsize / sizeof(*locks);
 
-	show_locks("close", locks, count);
-
-	DEBUG(0,("closing ctx=%p server=%d.%d ntvfs=%p\n",
-		 req->brl, req->server.node, req->server.id, req->ntvfs));
-
 	for (i=0; i<count; i++) {
 		struct lock_struct *lock = &locks[i];
 
@@ -897,12 +841,6 @@
 		memcpy(call->new_data->dptr, locks, count*sizeof(struct lock_struct));
 	}
 
-	if (call->new_data) {
-		DEBUG(0,("close: size now %d\n", call->new_data->dsize));
-	}
-
-	DEBUG(0,("brl_ctdb_close_func dcount=%d count=%d\n", dcount, count));
-	
 	call->reply_data = talloc(call, TDB_DATA);
 	if (call->reply_data == NULL) {
 		return CTDB_ERR_NOMEM;
@@ -940,8 +878,6 @@
 	req.server = brl->server;
 	req.ntvfs = brlh->ntvfs;
 
-	DEBUG(0,("brl_ctdb_close %u.%u %p\n", req.server.node, req.server.id, brl));
-
 	ret = ctdb_call(brl->ctdb, kbuf, FUNC_BRL_CLOSE, &rbuf, &sbuf);
 	if (ret == -1) {
 		DEBUG(0,("ctdb_call failed - %s\n", __location__));

Modified: branches/SAMBA_4_0/source/cluster/ctdb/common/ctdb.c
===================================================================
--- branches/SAMBA_4_0/source/cluster/ctdb/common/ctdb.c	2007-01-22 04:04:36 UTC (rev 20944)
+++ branches/SAMBA_4_0/source/cluster/ctdb/common/ctdb.c	2007-01-22 09:35:26 UTC (rev 20945)
@@ -186,8 +186,6 @@
 		return;
 	}
 
-	DEBUG(0,("got ctdb op %d reqid %d\n", hdr->operation, hdr->reqid));
-
 	switch (hdr->operation) {
 	case CTDB_REQ_CALL:
 		ctdb_request_call(ctdb, hdr);

Modified: branches/SAMBA_4_0/source/cluster/ctdb/common/ctdb_call.c
===================================================================
--- branches/SAMBA_4_0/source/cluster/ctdb/common/ctdb_call.c	2007-01-22 04:04:36 UTC (rev 20944)
+++ branches/SAMBA_4_0/source/cluster/ctdb/common/ctdb_call.c	2007-01-22 09:35:26 UTC (rev 20945)
@@ -28,14 +28,12 @@
 #include "system/filesys.h"
 #include "cluster/ctdb/include/ctdb_private.h"
 
-
 /*
   queue a packet or die
 */
 static void ctdb_queue_packet(struct ctdb_context *ctdb, struct ctdb_req_header *hdr)
 {
 	struct ctdb_node *node;
-	DEBUG(0,("queueing destnode=%u srcnode=%u\n", hdr->destnode, hdr->srcnode));
 	node = ctdb->nodes[hdr->destnode];
 	if (ctdb->methods->queue_pkt(node, (uint8_t *)hdr, hdr->length) != 0) {
 		ctdb_fatal(ctdb, "Unable to queue packet\n");
@@ -210,7 +208,6 @@
 
 	if (r->hdr.destnode == ctdb->vnn) {
 		/* we are the lmaster - don't send to ourselves */
-		DEBUG(0,("XXXX local ctdb_req_dmaster\n"));
 		ctdb_request_dmaster(ctdb, &r->hdr);
 	} else {
 		ctdb_queue_packet(ctdb, &r->hdr);
@@ -234,7 +231,7 @@
 {
 	struct ctdb_req_dmaster *c = (struct ctdb_req_dmaster *)hdr;
 	struct ctdb_reply_dmaster *r;
-	TDB_DATA key, data;
+	TDB_DATA key, data, data2;
 	struct ctdb_ltdb_header header;
 	int ret, len;
 
@@ -243,13 +240,8 @@
 	data.dptr = c->data + c->keylen;
 	data.dsize = c->datalen;
 
-	DEBUG(0,("request dmaster reqid=%d\n", hdr->reqid));
-
-	DEBUG(0,("change dmaster: stage 2 - new dmaster will be %d\n",
-		 c->dmaster));
-
 	/* fetch the current record */
-	ret = ctdb_ltdb_fetch(ctdb, key, &header, &data);
+	ret = ctdb_ltdb_fetch(ctdb, key, &header, &data2);
 	if (ret != 0) {
 		ctdb_fatal(ctdb, "ctdb_req_dmaster failed to fetch record");
 		return;
@@ -261,8 +253,6 @@
 		return;
 	}
 
-	DEBUG(0,("request dmaster reqid=%d %s\n", hdr->reqid, __location__));
-
 	header.dmaster = c->dmaster;
 	if (ctdb_ltdb_store(ctdb, key, &header, data) != 0) {
 		ctdb_fatal(ctdb, "ctdb_req_dmaster unable to update dmaster");
@@ -281,13 +271,10 @@
 	r->datalen       = data.dsize;
 	memcpy(&r->data[0], data.dptr, data.dsize);
 
-	DEBUG(0,("request dmaster reqid=%d %s\n", hdr->reqid, __location__));
-
 	if (r->hdr.destnode == r->hdr.srcnode) {
 		ctdb_reply_dmaster(ctdb, &r->hdr);
 	} else {
 		ctdb_queue_packet(ctdb, &r->hdr);
-		DEBUG(0,("request dmaster reqid=%d %s\n", hdr->reqid, __location__));
 	}
 
 	talloc_free(r);
@@ -331,8 +318,6 @@
 	   then give them the record */
 	if (header.laccessor == c->hdr.srcnode &&
 	    header.lacount >= ctdb->max_lacount) {
-		DEBUG(0,("change dmaster: stage 1 - new dmaster will be %d\n",
-			 header.laccessor));
 		ctdb_call_send_dmaster(ctdb, c, &header, &key, &data);
 		talloc_free(data.dptr);
 		return;
@@ -423,9 +408,6 @@
 
 	talloc_steal(state, c);
 
-	DEBUG(0,("change dmaster: stage 3 - new dmaster is %d\n",
-		 ctdb->vnn));
-
 	/* we're now the dmaster - update our local ltdb with new header
 	   and data */
 	state->header.dmaster = ctdb->vnn;
@@ -494,7 +476,7 @@
 */
 static int ctdb_call_destructor(struct ctdb_call_state *state)
 {
-//	idr_remove(state->node->ctdb->idr, state->c->hdr.reqid);
+	idr_remove(state->node->ctdb->idr, state->c->hdr.reqid);
 	return 0;
 }
 
@@ -582,7 +564,6 @@
 	state->c->hdr.srcnode   = ctdb->vnn;
 	/* this limits us to 16k outstanding messages - not unreasonable */
 	state->c->hdr.reqid     = idr_get_new(ctdb->idr, state, 0xFFFF);
-	DEBUG(0,("Allocate reqid %u\n", state->c->hdr.reqid));
 	state->c->callid        = call_id;
 	state->c->keylen        = key.dsize;
 	state->c->calldatalen   = call_data?call_data->dsize:0;

Modified: branches/SAMBA_4_0/source/cluster/ctdb/common/ctdb_ltdb.c
===================================================================
--- branches/SAMBA_4_0/source/cluster/ctdb/common/ctdb_ltdb.c	2007-01-22 04:04:36 UTC (rev 20944)
+++ branches/SAMBA_4_0/source/cluster/ctdb/common/ctdb_ltdb.c	2007-01-22 09:35:26 UTC (rev 20945)
@@ -24,7 +24,9 @@
 #include "system/network.h"
 #include "system/filesys.h"
 #include "cluster/ctdb/include/ctdb_private.h"
+#include "db_wrap.h"
 
+
 /*
   attach to a specific database
 */
@@ -34,7 +36,7 @@
 	/* when we have a separate daemon this will need to be a real
 	   file, not a TDB_INTERNAL, so the parent can access it to
 	   for ltdb bypass */
-	ctdb->ltdb = tdb_open(name, 0, /* tdb_flags */ TDB_INTERNAL, open_flags, mode);
+	ctdb->ltdb = tdb_wrap_open(ctdb, name, 0, TDB_INTERNAL, open_flags, mode);
 	if (ctdb->ltdb == NULL) {
 		ctdb_set_error(ctdb, "Failed to open tdb %s\n", name);
 		return -1;
@@ -76,7 +78,7 @@
 {
 	TDB_DATA rec;
 
-	rec = tdb_fetch(ctdb->ltdb, key);
+	rec = tdb_fetch(ctdb->ltdb->tdb, key);
 	if (rec.dsize < sizeof(*header)) {
 		/* return an initial header */
 		free(rec.dptr);
@@ -116,7 +118,7 @@
 	memcpy(rec.dptr, header, sizeof(*header));
 	memcpy(rec.dptr + sizeof(*header), data.dptr, data.dsize);
 
-	ret = tdb_store(ctdb->ltdb, key, rec, TDB_REPLACE);
+	ret = tdb_store(ctdb->ltdb->tdb, key, rec, TDB_REPLACE);
 	talloc_free(rec.dptr);
 
 	return ret;

Modified: branches/SAMBA_4_0/source/cluster/ctdb/include/ctdb_private.h
===================================================================
--- branches/SAMBA_4_0/source/cluster/ctdb/include/ctdb_private.h	2007-01-22 04:04:36 UTC (rev 20944)
+++ branches/SAMBA_4_0/source/cluster/ctdb/include/ctdb_private.h	2007-01-22 09:35:26 UTC (rev 20945)
@@ -89,7 +89,7 @@
 	struct ctdb_node **nodes; /* array of nodes in the cluster - indexed by vnn */
 	struct ctdb_registered_call *calls; /* list of registered calls */
 	char *err_msg;
-	struct tdb_context *ltdb;
+	struct tdb_wrap *ltdb;
 	const struct ctdb_methods *methods; /* transport methods */
 	const struct ctdb_upcalls *upcalls; /* transport upcalls */
 	void *private; /* private to transport */



More information about the samba-cvs mailing list