The fix should be to edit the bottom of
/sys/src/cmd/fossil/cache.c:/^doRemoveLink
changing

        l.epochClose = p->epoch;
        blockSetLabel(b, &l, 0);

to

        l.epochClose = p->epoch;
        if(l.epochClose == l.epoch){
                vtLock(c->fl->lk);
                if(l.epoch == c->fl->epochlow)
                        c->fl->nused--;
                blockSetLabel(b, &l, 0);
                vtUnlock(c->fl->lk);
        }else
                blockSetLabel(b, &l, 0);

Untested.

Treating l.epoch == l.epochClose as meaning the block is free
is an optimization that allows fossil to reclaim space allocated
and then discarded in the same snapshot.  The nused tracking
code was not changed when the optimization got added, 
causing the misreported use numbers.

Also, you can delete u32int nfree; from struct FreeList.
It is never accessed.

Russ

Reply via email to