silly cache hack, also fix vtfilewritebefore not to be so aggressive.
This commit is contained in:
parent
7cb748941e
commit
a1882dc1d0
2 changed files with 25 additions and 6 deletions
|
|
@ -39,6 +39,7 @@ struct VtCache
|
||||||
int nblock;
|
int nblock;
|
||||||
uchar *mem; /* memory for all blocks and data */
|
uchar *mem; /* memory for all blocks and data */
|
||||||
int mode;
|
int mode;
|
||||||
|
int (*write)(VtConn*, uchar[VtScoreSize], uint, uchar*, int);
|
||||||
};
|
};
|
||||||
|
|
||||||
static void cachecheck(VtCache*);
|
static void cachecheck(VtCache*);
|
||||||
|
|
@ -56,13 +57,13 @@ vtcachealloc(VtConn *z, int blocksize, ulong nblock, int mode)
|
||||||
c->z = z;
|
c->z = z;
|
||||||
c->blocksize = (blocksize + 127) & ~127;
|
c->blocksize = (blocksize + 127) & ~127;
|
||||||
c->nblock = nblock;
|
c->nblock = nblock;
|
||||||
|
|
||||||
c->nhash = nblock;
|
c->nhash = nblock;
|
||||||
c->hash = vtmallocz(nblock*sizeof(VtBlock*));
|
c->hash = vtmallocz(nblock*sizeof(VtBlock*));
|
||||||
c->heap = vtmallocz(nblock*sizeof(VtBlock*));
|
c->heap = vtmallocz(nblock*sizeof(VtBlock*));
|
||||||
c->block = vtmallocz(nblock*sizeof(VtBlock));
|
c->block = vtmallocz(nblock*sizeof(VtBlock));
|
||||||
c->mem = vtmallocz(nblock*c->blocksize);
|
c->mem = vtmallocz(nblock*c->blocksize);
|
||||||
c->mode = mode;
|
c->mode = mode;
|
||||||
|
c->write = vtwrite;
|
||||||
|
|
||||||
p = c->mem;
|
p = c->mem;
|
||||||
for(i=0; i<nblock; i++){
|
for(i=0; i<nblock; i++){
|
||||||
|
|
@ -79,6 +80,19 @@ vtcachealloc(VtConn *z, int blocksize, ulong nblock, int mode)
|
||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* BUG This is here so that vbackup can override it and do some
|
||||||
|
* pipelining of writes. Arguably vtwrite or vtwritepacket or the
|
||||||
|
* cache itself should be providing this functionality.
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
vtcachesetwrite(VtCache *c, int (*write)(VtConn*, uchar[VtScoreSize], uint, uchar*, int))
|
||||||
|
{
|
||||||
|
if(write == nil)
|
||||||
|
write = vtwrite;
|
||||||
|
c->write = write;
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
vtcachefree(VtCache *c)
|
vtcachefree(VtCache *c)
|
||||||
{
|
{
|
||||||
|
|
@ -405,6 +419,8 @@ vtcacheglobal(VtCache *c, uchar score[VtScoreSize], int type)
|
||||||
|
|
||||||
n = vtread(c->z, score, type, b->data, c->blocksize);
|
n = vtread(c->z, score, type, b->data, c->blocksize);
|
||||||
if(n < 0){
|
if(n < 0){
|
||||||
|
werrstr("vtread %V: %r", score);
|
||||||
|
abort();
|
||||||
b->iostate = BioVentiError;
|
b->iostate = BioVentiError;
|
||||||
vtblockput(b);
|
vtblockput(b);
|
||||||
return nil;
|
return nil;
|
||||||
|
|
@ -494,7 +510,7 @@ vtblockwrite(VtBlock *b)
|
||||||
|
|
||||||
c = b->c;
|
c = b->c;
|
||||||
n = vtzerotruncate(b->type, b->data, c->blocksize);
|
n = vtzerotruncate(b->type, b->data, c->blocksize);
|
||||||
if(vtwrite(c->z, score, b->type, b->data, n) < 0)
|
if(c->write(c->z, score, b->type, b->data, n) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
memmove(b->score, score, VtScoreSize);
|
memmove(b->score, score, VtScoreSize);
|
||||||
|
|
|
||||||
|
|
@ -1222,11 +1222,14 @@ vtfileflushbefore(VtFile *r, u64int offset)
|
||||||
* if the rest of the block is already flushed,
|
* if the rest of the block is already flushed,
|
||||||
* we can flush the whole block.
|
* we can flush the whole block.
|
||||||
*/
|
*/
|
||||||
|
ok = 0;
|
||||||
|
if(index[i] != index1[i]){
|
||||||
ok = 1;
|
ok = 1;
|
||||||
for(; j<ppb; j++)
|
for(; j<ppb; j++)
|
||||||
if(vtglobaltolocal(b->data+j*VtScoreSize) != NilBlock)
|
if(vtglobaltolocal(b->data+j*VtScoreSize) != NilBlock)
|
||||||
ok = 0;
|
ok = 0;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if(ok){
|
if(ok){
|
||||||
if(i == depth)
|
if(i == depth)
|
||||||
score = e.score;
|
score = e.score;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue