mirror of
https://github.com/9fans/plan9port.git
synced 2025-01-12 11:10:07 +00:00
fix problem in cache.
This commit is contained in:
parent
39ef727f46
commit
0c148046ed
4 changed files with 21 additions and 21 deletions
|
@ -262,7 +262,6 @@ vtcachebumpblock(VtCache *c)
|
||||||
*/
|
*/
|
||||||
if(c->nheap == 0){
|
if(c->nheap == 0){
|
||||||
vtcachedump(c);
|
vtcachedump(c);
|
||||||
abort();
|
|
||||||
sysfatal("vtcachebumpblock: no free blocks in vtCache");
|
sysfatal("vtcachebumpblock: no free blocks in vtCache");
|
||||||
}
|
}
|
||||||
b = c->heap[0];
|
b = c->heap[0];
|
||||||
|
@ -305,17 +304,10 @@ vtcachelocal(VtCache *c, u32int addr, int type)
|
||||||
|
|
||||||
b = &c->block[addr];
|
b = &c->block[addr];
|
||||||
if(b->addr == NilBlock || b->iostate != BioLocal)
|
if(b->addr == NilBlock || b->iostate != BioLocal)
|
||||||
{
|
|
||||||
abort();
|
|
||||||
sysfatal("vtcachelocal: block is not local");
|
sysfatal("vtcachelocal: block is not local");
|
||||||
}
|
|
||||||
|
|
||||||
if(b->type != type)
|
if(b->type != type)
|
||||||
{
|
|
||||||
print("%d != %d\n", b->type, type);
|
|
||||||
abort();
|
|
||||||
sysfatal("vtcachelocal: block has wrong type %d != %d", b->type, type);
|
sysfatal("vtcachelocal: block has wrong type %d != %d", b->type, type);
|
||||||
}
|
|
||||||
|
|
||||||
qlock(&c->lk);
|
qlock(&c->lk);
|
||||||
b->ref++;
|
b->ref++;
|
||||||
|
@ -331,9 +323,6 @@ vtcacheallocblock(VtCache *c, int type)
|
||||||
{
|
{
|
||||||
VtBlock *b;
|
VtBlock *b;
|
||||||
|
|
||||||
if(type >= VtMaxType)
|
|
||||||
abort();
|
|
||||||
|
|
||||||
qlock(&c->lk);
|
qlock(&c->lk);
|
||||||
b = vtcachebumpblock(c);
|
b = vtcachebumpblock(c);
|
||||||
b->iostate = BioLocal;
|
b->iostate = BioLocal;
|
||||||
|
@ -379,6 +368,11 @@ vtcacheglobal(VtCache *c, uchar score[VtScoreSize], int type)
|
||||||
qunlock(&c->lk);
|
qunlock(&c->lk);
|
||||||
qlock(&b->lk);
|
qlock(&b->lk);
|
||||||
b->nlock = 1;
|
b->nlock = 1;
|
||||||
|
if(b->iostate == BioVentiError){
|
||||||
|
werrstr("venti i/o error");
|
||||||
|
vtblockput(b);
|
||||||
|
return nil;
|
||||||
|
}
|
||||||
return b;
|
return b;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -410,7 +404,6 @@ 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){
|
||||||
fprint(2, "vtread: %r\n");
|
|
||||||
b->iostate = BioVentiError;
|
b->iostate = BioVentiError;
|
||||||
vtblockput(b);
|
vtblockput(b);
|
||||||
return nil;
|
return nil;
|
||||||
|
@ -494,8 +487,8 @@ vtblockwrite(VtBlock *b)
|
||||||
int n;
|
int n;
|
||||||
|
|
||||||
if(b->iostate != BioLocal){
|
if(b->iostate != BioLocal){
|
||||||
abort();
|
werrstr("vtblockwrite: not a local block");
|
||||||
sysfatal("vtBlockWrite: not a local block");
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
c = b->c;
|
c = b->c;
|
||||||
|
@ -562,6 +555,7 @@ vtglobaltolocal(uchar score[VtScoreSize])
|
||||||
int
|
int
|
||||||
vtblockdirty(VtBlock *b)
|
vtblockdirty(VtBlock *b)
|
||||||
{
|
{
|
||||||
|
USED(b);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -661,9 +661,7 @@ static int
|
||||||
mkindices(VtEntry *e, u32int bn, int *index)
|
mkindices(VtEntry *e, u32int bn, int *index)
|
||||||
{
|
{
|
||||||
int i, np;
|
int i, np;
|
||||||
u32int obn;
|
|
||||||
|
|
||||||
obn = bn;
|
|
||||||
memset(index, 0, VtPointerDepth*sizeof(int));
|
memset(index, 0, VtPointerDepth*sizeof(int));
|
||||||
|
|
||||||
np = e->psize/VtScoreSize;
|
np = e->psize/VtScoreSize;
|
||||||
|
@ -772,7 +770,6 @@ vtfileblockscore(VtFile *r, u32int bn, uchar score[VtScoreSize])
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
Err:
|
Err:
|
||||||
fprint(2, "vtfileblockhash: %r\n");
|
|
||||||
vtblockput(b);
|
vtblockput(b);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,7 +44,7 @@ vtrootunpack(VtRoot *r, uchar *p)
|
||||||
vers = U16GET(p);
|
vers = U16GET(p);
|
||||||
if(vers != VtRootVersion) {
|
if(vers != VtRootVersion) {
|
||||||
werrstr("unknown root version");
|
werrstr("unknown root version");
|
||||||
return 0;
|
return -1;
|
||||||
}
|
}
|
||||||
p += 2;
|
p += 2;
|
||||||
memmove(r->name, p, sizeof(r->name));
|
memmove(r->name, p, sizeof(r->name));
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
#include <u.h>
|
#include <u.h>
|
||||||
#include <errno.h>
|
|
||||||
#include <libc.h>
|
#include <libc.h>
|
||||||
#include <venti.h>
|
#include <venti.h>
|
||||||
#include "queue.h"
|
#include "queue.h"
|
||||||
|
@ -47,6 +46,16 @@ _vtsend(VtConn *z, Packet *p)
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
interrupted(void)
|
||||||
|
{
|
||||||
|
char e[ERRMAX];
|
||||||
|
|
||||||
|
rerrstr(e, sizeof e);
|
||||||
|
return strstr(e, "interrupted") != nil;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static Packet*
|
static Packet*
|
||||||
_vtrecv(VtConn *z)
|
_vtrecv(VtConn *z)
|
||||||
{
|
{
|
||||||
|
@ -69,7 +78,7 @@ _vtrecv(VtConn *z)
|
||||||
if(0) fprint(2, "%d read hdr\n", getpid());
|
if(0) fprint(2, "%d read hdr\n", getpid());
|
||||||
n = read(z->infd, b, MaxFragSize);
|
n = read(z->infd, b, MaxFragSize);
|
||||||
if(0) fprint(2, "%d got %d (%r)\n", getpid(), n);
|
if(0) fprint(2, "%d got %d (%r)\n", getpid(), n);
|
||||||
if(n==0 || (n<0 && errno!=EINTR))
|
if(n==0 || (n<0 && !interrupted()))
|
||||||
goto Err;
|
goto Err;
|
||||||
size += n;
|
size += n;
|
||||||
packettrim(p, 0, size);
|
packettrim(p, 0, size);
|
||||||
|
@ -91,7 +100,7 @@ _vtrecv(VtConn *z)
|
||||||
if(n > 0)
|
if(n > 0)
|
||||||
size += n;
|
size += n;
|
||||||
packettrim(p, 0, size);
|
packettrim(p, 0, size);
|
||||||
if(n==0 || (n<0 && errno!=EINTR))
|
if(n==0 || (n<0 && !interrupted()))
|
||||||
goto Err;
|
goto Err;
|
||||||
}
|
}
|
||||||
ventirecvbytes += len;
|
ventirecvbytes += len;
|
||||||
|
|
Loading…
Reference in a new issue