ref: 8279e5159846f8a18cfe7594c6c7a45985809e0e
parent: a566629485f872d51d4d5661d8b4aa32bd45f3e2
author: 9ferno <[email protected]>
date: Sun Oct 16 16:45:08 EDT 2022
removed Iobuf.readonly
--- a/all.h
+++ b/all.h
@@ -78,7 +78,6 @@
u8 *xiobuf; /* "real" buffer pointer */
Content *io; /* cast'able to contents */
};
- u8 readonly;
};
extern u32 nbuckets; /* n hash buckets for i/o */
@@ -132,7 +131,7 @@
int checkname9p2(char*);
void chkqunlock(QLock *q);
void chkrunlock(RWLock *q);
-void chkwunlock(RWLock *q);
+u8 chkwunlock(RWLock *q);
void cmd_user(void);
char* cname(char*);
void consproc(void);
--- a/iobuf.c
+++ b/iobuf.c
@@ -113,21 +113,23 @@
if(freshalloc == 0)
devread(blkno, p->xiobuf, len);
if(readonly){
- chkwunlock(p);
+ if(chkwunlock(p) == 0){
+ showbuf(p);
+ panic("getbuf chkwunlock(p) == 0 called by %#p\n", getcallerpc(&blkno));
+ }
rlock(p);
}
- }else if(readonly == 0){
- wlock(p);
+ }else if(readonly){
if(chatty9p > 4)
- dprint(" after wlock() blkno %llud\n", blkno);
- }else{
- if(chatty9p > 4)
dprint(" in cache iobuf 0x%p has len %llud blkno %llud len %llud .."
" rlock()\n", p, p->len, blkno, len);
rlock(p);
+ }else{
+ wlock(p);
+ if(chatty9p > 4)
+ dprint(" after wlock() blkno %llud\n", blkno);
}
decref(p);
- p->readonly = readonly;
return p;
}
p = p->fore;
@@ -184,7 +186,6 @@
rlock(p);
decref(p);
}
- p->readonly = readonly;
return p;
}
@@ -281,8 +282,7 @@
if(chatty9p > 4)
dprint("putbuf p->blkno %llud\n", p->blkno);
- if(p->readonly){
- p->readonly = 0;
+ if(p->readers){
chkrunlock(p);
if(chatty9p > 4)
dprint(" .. runlock()'ed\n");
@@ -308,7 +308,10 @@
for(i=0; i<Nbkp; i++)
bkp(p, config.root.dest[i], Qproot0+i*3);
}
- chkwunlock(p);
+ if(chkwunlock(p) == 0){
+ showbuf(p);
+ panic("putbuf chkwunlock(p) == 0 called by %#p\n", getcallerpc(&p));
+ }
if(chatty9p > 4)
dprint(" .. wunlock()'ed\n");
}
@@ -347,7 +350,7 @@
void
settag(Iobuf *p, int tagtype, u64 qpath)
{
- if(p->readonly)
+ if(p->readers)
panic("settag %s(%llux) tag/path=%s/%llud: not Bwritable\n",
devfile, (u64)p->blkno, tagnames[tagtype], qpath);
if(p->io == nil)
@@ -404,13 +407,15 @@
p, getcallerpc(&p));
return;
}
- dprint("showbuf p 0x%p blkno %llud len %d\n"
- " fore 0x%p back 0x%p\n"
- " xiobuf 0x%p readonly 0x%x\n"
- " caller %#p\n",
- p, p->blkno, p->len,
+ dprint("showbuf p 0x%p ref %d readers %d writer %d"
+ " blkno %llud len %d"
+ " fore 0x%p back 0x%p"
+ " xiobuf 0x%p"
+ " caller %#p\n",
+ p, p->ref, p->readers, p->writer,
+ p->blkno, p->len,
p->fore, p->back,
- p->xiobuf, p->readonly,
+ p->xiobuf,
getcallerpc(&p));
if(p->io != nil)
showblock((u8*)p->io);
--- a/misc.c
+++ b/misc.c
@@ -13,14 +13,16 @@
runlock(q);
}
-void
+u8
chkwunlock(RWLock *q)
{
- if(q->writer <= 0)
+ if(q->writer <= 0){
print("wunlock(%#p): not locked: pc %#p\n",
q, getcallerpc(&q));
- else
- wunlock(q);
+ return 0;
+ }
+ wunlock(q);
+ return 1;
}
void
--- a/sub.c
+++ b/sub.c
@@ -118,7 +118,7 @@
void
freeblockbuf(Iobuf *buf)
{
- if(buf->readonly)
+ if(buf->readers)
panic("freeblockbuf without Bwritable");
/* clear the buf to avoid leaks on reuse */