ref: 30a9d5907018a578873bff2f7f1eaccfcc4d5a1f
parent: f5174e6fdf6386a47d610991b449299c9fb392c7
author: mischief <mischief@offblast.org>
date: Sat Sep 19 21:56:56 EDT 2015
pc, pc64: fix sdvirtio descriptor count when sending flush
--- a/sys/src/9/pc/sdvirtio.c
+++ b/sys/src/9/pc/sdvirtio.c
@@ -326,7 +326,7 @@
static int
vioblkreq(Vdev *vd, int typ, void *a, long count, long secsize, uvlong lba)
{
- int free, head;
+ int need, free, head;
Vqueue *q;
Vdesc *d;
@@ -337,7 +337,11 @@
u64int lba;
} req;
- status = 0;
+ need = 2;
+ if(a != nil)
+ need = 3;
+
+ status = -1;
req.typ = typ;
req.prio = 0;
req.lba = lba;
@@ -344,7 +348,7 @@
q = vd->queue[0];
ilock(q);
- while(q->nfree < 3){
+ while(q->nfree < need){
iunlock(q);
if(!waserror())
@@ -361,10 +365,12 @@
d->len = sizeof(req);
d->flags = Next;
- d = &q->desc[free]; free = d->next;
- d->addr = PADDR(a);
- d->len = secsize*count;
- d->flags = typ ? Next : (Write|Next);
+ if(a != nil){
+ d = &q->desc[free]; free = d->next;
+ d->addr = PADDR(a);
+ d->len = secsize*count;
+ d->flags = typ ? Next : (Write|Next);
+ }
d = &q->desc[free]; free = d->next;
d->addr = PADDR(&status);
@@ -372,7 +378,7 @@
d->flags = Write;
q->free = free;
- q->nfree -= 3;
+ q->nfree -= need;
/* queue io, unlock and wait for completion */
vqio(q, head);