int messagesize = 8192+IOHDRSZ; /* good start */
-enum{
- DEBUG = 0
-};
-
Dirtab dirtab[]=
{
{ ".", QTDIR, Qdir, 0500|DMDIR },
close(fd);
}
fs->user = estrdup(buf);
+ fs->csyncflush = chancreate(sizeof(int), 0);
+ if(fs->csyncflush == nil)
+ error("chancreate syncflush");
fs->cxfidalloc = cxfidalloc;
pid = getpid();
x->buf = buf;
if(convM2S(buf, n, x) != n)
error("convert error in convM2S");
- if(DEBUG)
+ if(debug)
fprint(2, "rio:<-%F\n", &x->Fcall);
if(fcall[x->type] == nil)
x = filsysrespond(fs, x, &t, Ebadfcall);
error("convert error in convS2M");
if(write(fs->sfd, x->buf, n) != n)
error("write error in respond");
- if(DEBUG)
+ if(debug)
fprint(2, "rio:->%F\n", t);
free(x->buf);
x->buf = nil;
{
Fcall t;
- return filsysrespond(fs, x, &t, "rio: authentication not required");
+ return filsysrespond(fs, x, &t, "rio: authentication not required");
}
static
Xfid*
-filsysflush(Filsys*, Xfid *x, Fid*)
+filsysflush(Filsys *fs, Xfid *x, Fid*)
{
sendp(x->c, xfidflush);
+
+ /*
+ * flushes need to be replied in order. xfidflush() will
+ * awaken us when the flush has been queued.
+ */
+ recv(fs->csyncflush, nil);
+
return nil;
}
for(xf=xfid; xf; xf=xf->next)
if(xf->flushtag == x->oldtag){
- xf->flushtag = -1;
- xf->flushing = TRUE;
incref(xf); /* to hold data structures up at tail of synchronization */
if(xf->ref == 1)
error("ref 1 in flush");
- if(canqlock(&xf->active)){
- qunlock(&xf->active);
- sendul(xf->flushc, 0);
- }else{
- qlock(&xf->active); /* wait for him to finish */
- qunlock(&xf->active);
- }
- xf->flushing = FALSE;
- if(decref(xf) == 0)
- sendp(cxfidfree, xf);
+ /* take over flushtag so follow up flushes wait for us */
+ x->flushtag = x->oldtag;
+ xf->flushtag = -1;
break;
}
+
+ /*
+ * wakeup filsysflush() in the filsysproc so the next
+ * flush can come in.
+ */
+ sendul(x->fs->csyncflush, 0);
+
+ if(xf){
+ qlock(&xf->active);
+ if(xf->buf){ /* not responded yet? */
+ xf->flushing = TRUE;
+ qunlock(&xf->active);
+ sendul(xf->flushc, 0);
+ xf->flushing = FALSE;
+ }else{
+ qunlock(&xf->active);
+ }
+ if(decref(xf) == 0)
+ sendp(cxfidfree, xf);
+ }
+
+ qlock(&x->active);
+ if(x->flushing){
+ qunlock(&x->active);
+ recv(x->flushc, nil); /* wakeup flushing xfid */
+ filsyscancel(x);
+ return;
+ }
filsysrespond(x->fs, x, &t, nil);
+ qunlock(&x->active);
}
void