[PATCH] ctdb-server: Introduce mem pool

Swen Schillig swen at vnet.ibm.com
Fri Mar 16 10:55:54 UTC 2018


Hey Martin
On Fri, 2018-03-16 at 18:54 +1100, Martin Schwenke via samba-technical
wrote:
> On Fri, 16 Mar 2018 08:27:14 +0100, Swen Schillig <swen at vnet.ibm.com>
> wrote:
> 
> > On Fri, 2018-03-16 at 16:35 +1100, Martin Schwenke via samba-
> > technical
> > wrote:
> > > On Fri, 09 Mar 2018 09:09:23 +0100, Swen Schillig via samba-
> > > technical
> > > <samba-technical at lists.samba.org> wrote:
> > >   
> > > > Please review and push if OK.  
> > > 
> > > -	if ((rev_hdl = talloc_zero(ctdb_db, struct
> > > revokechild_handle)) == NULL) {
> > > +	rev_hdl = talloc_pooled_object(ctdb_db, struct
> > > revokechild_handle, 2,
> > > +				       data.dsize + key.dsize);
> > > 
> > > I don't see where this function does an allocation of size
> > > data.dsize.  :-(
> > > 
> > > peace & happiness,
> > > martin
> > >   
> > 
> > you're right, I guess this got "fixed" in the last run.
> > 
> > But now, really fixed.
> 
> EWRONGPATCH?  Or does this previous patch need fixing to get the
> "Introduce mem pool" one to work properly?

Sorry, I'm totally out of my mind it seems, urgently need the weekend.

Here it is.

Thanks in advance for reviewing.

Cheers Swen.
-------------- next part --------------
From 0b3358dd0aba2bbed576bf55d00e40fd3f0d6316 Mon Sep 17 00:00:00 2001
From: Swen Schillig <swen at vnet.ibm.com>
Date: Thu, 8 Feb 2018 11:46:03 +0100
Subject: [PATCH] ctdb-server: Introduce mem pool

The three conesecutive calls to memory allocating functions are predicitve
in their size requirements and therefore it is worthwhile to introduce
a memory pool.

Signed-off-by: Swen Schillig <swen at vnet.ibm.com>
---
 ctdb/server/ctdb_call.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/ctdb/server/ctdb_call.c b/ctdb/server/ctdb_call.c
index 5dfa19c77f7..e21e24bd21e 100644
--- a/ctdb/server/ctdb_call.c
+++ b/ctdb/server/ctdb_call.c
@@ -1822,12 +1822,15 @@ int ctdb_start_revoke_ro_record(struct ctdb_context *ctdb, struct ctdb_db_contex
 	header->flags |= CTDB_REC_FLAG_MIGRATED_WITH_DATA;
 	header->rsn   -= 1;
 
-	if ((rev_hdl = talloc_zero(ctdb_db, struct revokechild_handle)) == NULL) {
+	tdata = tdb_fetch(ctdb_db->rottdb, key);
+	rev_hdl = talloc_pooled_object(ctdb_db, struct revokechild_handle, 2,
+				       tdata.dsize + key.dsize);
+
+	if (rev_hdl == NULL) {
 		DEBUG(DEBUG_ERR,("Failed to allocate revokechild_handle\n"));
 		return -1;
 	}
 
-	tdata = tdb_fetch(ctdb_db->rottdb, key);
 	if (tdata.dsize > 0) {
 		uint8_t *tmp;
 
-- 
2.14.3



More information about the samba-technical mailing list