[PATCH] tdb: recycle dead records always at chain top

Jeremy Allison jra at samba.org
Wed Apr 2 12:28:46 MDT 2014


On Tue, Apr 01, 2014 at 01:49:45PM +0200, Michael Adam wrote:
> Hi,
> 
> based on Volker's patches from a couple of days ago,
> here is a patch that simplifies the code a bit
> (removes an almost-duplication). It changes the
> semantics in that when recycling a record from the
> chain to which the record-to-be-stored belongs,
> we do not leave it in place and more but put it
> to the top of the chain too (as with freelist records
> and records recycled from other chains).
> 
> This may give an advantage when trying to find the record
> again soon, but a disadvantage are the two
> additional tdb_ofs_write calls.
> 
> Thoughts?

I have gone over this code really carefully :-).

Thanks.

The only change I'd make is to split out this
change:

> diff --git a/lib/tdb/common/freelist.c b/lib/tdb/common/freelist.c
> index 6f8f812..2aeeb1c 100644
> --- a/lib/tdb/common/freelist.c
> +++ b/lib/tdb/common/freelist.c
> @@ -404,22 +404,10 @@ tdb_off_t tdb_allocate(struct tdb_context *tdb, int hash, tdb_len_t length,
>  	 * hash chains, something which is pretty bad normally)
>  	 */
>  
> -	for (i=1; i<tdb->hash_size; i++) {
> +	for (i=0; i<tdb->hash_size; i++) {

The change from starting from i=1, to i=0
needs a separate explaination. I (think :-)
I understand it, but as it's a change in
code behavior I'd like to see it as a
separate commit with an explaination
of why it was done.

Other than that +1 from me - nice cleanup !

Jeremy.


More information about the samba-technical mailing list