X-Git-Url: https://git.ozlabs.org/?a=blobdiff_plain;f=ccan%2Ftdb2%2Ffree.c;h=c5a0c40e54167c7fd44605d96763b75125c7ce87;hb=06a5b1a852c207a5172922e39d8effab0dd17b91;hp=df2792ecf19da0841e732bb764cdfd40bafa1880;hpb=56ea2c52a18a41a88ceaed72aef56c10de85ce93;p=ccan diff --git a/ccan/tdb2/free.c b/ccan/tdb2/free.c index df2792ec..c5a0c40e 100644 --- a/ccan/tdb2/free.c +++ b/ccan/tdb2/free.c @@ -347,7 +347,17 @@ static int coalesce(struct tdb_context *tdb, if (remove_from_list(tdb, b_off, off, r) == -1) goto err; - /* We have to drop this to avoid deadlocks. */ + r = tdb_access_write(tdb, off, sizeof(*r), true); + if (!r) + goto err; + + /* We have to drop this to avoid deadlocks, so make sure record + * doesn't get coalesced by someone else! */ + r->magic_and_meta = TDB_COALESCING_MAGIC | zone_bits; + r->data_len = end - off - sizeof(struct tdb_used_record); + if (tdb_access_commit(tdb, r) != 0) + goto err; + tdb_unlock_free_bucket(tdb, b_off); if (add_free_record(tdb, zone_bits, off, end - off) == -1)