qio: Rename qnoblock -> qdropoverflow
authorBarret Rhoden <brho@cs.berkeley.edu>
Thu, 16 Jul 2015 16:17:22 +0000 (12:17 -0400)
committerBarret Rhoden <brho@cs.berkeley.edu>
Fri, 24 Jul 2015 07:05:13 +0000 (03:05 -0400)
"No block" would not block, but unlike other non-blocking I/O, it
doesn't just return, it drops the overflowed block.  It also doesn't
work for reads.

kern/drivers/dev/cons.c
kern/drivers/dev/ether.c
kern/include/ns.h
kern/src/ns/qio.c
kern/src/oprofile/cpu_buffer.c
scripts/spatch/plan9.cocci

index 1f4ba4a..0135436 100644 (file)
@@ -84,7 +84,7 @@ void printinit(void)
        lineq = qopen(2 * 1024, 0, NULL, NULL);
        if (lineq == NULL)
                panic("printinit");
-       qnoblock(lineq, 1);
+       qdropoverflow(lineq, 1);
 #endif
 }
 
@@ -642,7 +642,7 @@ static struct chan *consopen(struct chan *c, int omode)
                                        wunlock(&(&kprintq)->rwlock);
                                        error(Enomem);
                                }
-                               qnoblock(kprintq.q, 1);
+                               qdropoverflow(kprintq.q, 1);
                                wunlock(&(&kprintq)->rwlock);
                                c->iounit = qiomaxatomic;
                        }
index 99921bb..1e0e926 100644 (file)
@@ -439,7 +439,7 @@ static long etherwrite(struct chan *chan, void *buf, long n, int64_t unused)
                        else
                                onoff = atoi(cb->f[1]);
                        if (ether->oq != NULL)
-                               qnoblock(ether->oq, onoff);
+                               qdropoverflow(ether->oq, onoff);
                        kfree(cb);
                        goto out;
                }
index 797d895..7052970 100644 (file)
@@ -815,7 +815,7 @@ void qhangup(struct queue *, char *unused_char_p_t);
 int qisclosed(struct queue *);
 int qiwrite(struct queue *, void *, int);
 int qlen(struct queue *);
-void qnoblock(struct queue *, int);
+void qdropoverflow(struct queue *, bool);
 struct queue *qopen(int unused_int, int, void (*)(void *), void *);
 int qpass(struct queue *, struct block *);
 int qpassnolim(struct queue *, struct block *);
index 3b5428b..54a776d 100644 (file)
@@ -1885,9 +1885,9 @@ void qsetlimit(struct queue *q, int limit)
 }
 
 /*
- *  set blocking/nonblocking
+ *  set whether writes drop overflowing blocks, or if we sleep
  */
-void qnoblock(struct queue *q, int onoff)
+void qdropoverflow(struct queue *q, bool onoff)
 {
        q->noblock = onoff;
 }
index cf06381..45f6e93 100644 (file)
@@ -143,7 +143,7 @@ int alloc_cpu_buffers(void)
                goto fail;
 
        /* we *really* don't want to block. Losing data is better. */
-       qnoblock(opq, 1);
+       qdropoverflow(opq, 1);
        if (!op_cpu_buffer) {
                op_cpu_buffer =
                        kzmalloc(sizeof(*op_cpu_buffer) * num_cores, KMALLOC_WAIT);
index 7fd63ca..599fc13 100644 (file)
 +sysread(
 ...)
 
+@ qnoblock@
+@@
+-qnoblock(
++qdropoverflow(
+...)
+
 @ channel @
 identifier d;
 @@