]> xenbits.xensource.com Git - people/dstodden/blktap.git/commitdiff
CA-44322: Remove AIO threading code.
authorDaniel Stodden <daniel.stodden@citrix.com>
Thu, 14 Oct 2010 10:23:23 +0000 (03:23 -0700)
committerDaniel Stodden <daniel.stodden@citrix.com>
Thu, 14 Oct 2010 10:23:23 +0000 (03:23 -0700)
Reverts 557:68e1b3249623 and later. Kernel side improved since
linux-2.6.32.pq.hg 269:6ddf9e468ff8.

Signed-off-by: Daniel Stodden <daniel.stodden@citrix.comm>
drivers/block-aio.c
drivers/block-vhd.c
drivers/block-vindex.c
drivers/io-optimize.c
drivers/tapdisk-interface.c
drivers/tapdisk-interface.h
drivers/tapdisk-queue.c
drivers/tapdisk-queue.h
include/blktap2.h

index 751df444e078727eeb5db9803f720d0c27b49f4b..1dda2ed21bc3ed77e6f6162dab620ec61a224d1a 100644 (file)
@@ -40,7 +40,6 @@
 #include "tapdisk.h"
 #include "tapdisk-driver.h"
 #include "tapdisk-interface.h"
-#include "tapdisk-storage.h"
 
 #define MAX_AIO_REQS         TAPDISK_DATA_REQUESTS
 
@@ -170,8 +169,6 @@ int tdaio_open(td_driver_t *driver, const char *name, td_flag_t flags)
                goto done;
        }
 
-       driver->storage = tapdisk_storage_type(name);
-
         prv->fd = fd;
 
 done:
@@ -205,7 +202,7 @@ void tdaio_queue_read(td_driver_t *driver, td_request_t treq)
        aio->treq  = treq;
        aio->state = prv;
 
-       td_prep_read(driver, &aio->tiocb, prv->fd, treq.buf,
+       td_prep_read(&aio->tiocb, prv->fd, treq.buf,
                     size, offset, tdaio_complete, aio);
        td_queue_tiocb(driver, &aio->tiocb);
 
@@ -233,7 +230,7 @@ void tdaio_queue_write(td_driver_t *driver, td_request_t treq)
        aio->treq  = treq;
        aio->state = prv;
 
-       td_prep_write(driver, &aio->tiocb, prv->fd, treq.buf,
+       td_prep_write(&aio->tiocb, prv->fd, treq.buf,
                      size, offset, tdaio_complete, aio);
        td_queue_tiocb(driver, &aio->tiocb);
 
index 0054633d289f4b83d7d28fe9fc37989208b23478..59fa5ea8e8775daf2798a6e66e6e7afeb8b578a4 100644 (file)
@@ -1278,7 +1278,7 @@ aio_read(struct vhd_state *s, struct vhd_request *req, uint64_t offset)
 {
        struct tiocb *tiocb = &req->tiocb;
 
-       td_prep_read(s->driver, tiocb, s->vhd.fd, req->treq.buf,
+       td_prep_read(tiocb, s->vhd.fd, req->treq.buf,
                     vhd_sectors_to_bytes(req->treq.secs),
                     offset, vhd_complete, req);
        td_queue_tiocb(s->driver, tiocb);
@@ -1294,7 +1294,7 @@ aio_write(struct vhd_state *s, struct vhd_request *req, uint64_t offset)
 {
        struct tiocb *tiocb = &req->tiocb;
 
-       td_prep_write(s->driver, tiocb, s->vhd.fd, req->treq.buf,
+       td_prep_write(tiocb, s->vhd.fd, req->treq.buf,
                      vhd_sectors_to_bytes(req->treq.secs),
                      offset, vhd_complete, req);
        td_queue_tiocb(s->driver, tiocb);
index 6fe798571a96a6e27fc401d1b00396990a675962..a37b6a0ad805f025e8416d9d87344bc0089fda17 100644 (file)
@@ -627,8 +627,7 @@ vhd_index_schedule_meta_read(vhd_index_t *index, uint32_t blk)
        req->treq.sec  = blk * index->vhdi.spb;
        req->treq.secs = block->table_size >> VHD_SECTOR_SHIFT;
 
-       td_prep_read(index->driver,
-                    &req->tiocb, index->vhdi.fd,
+       td_prep_read(&req->tiocb, index->vhdi.fd,
                     (char *)block->vhdi_block.table, block->table_size,
                     offset, vhd_index_complete_meta_read, req);
        td_queue_tiocb(index->driver, &req->tiocb);
@@ -678,8 +677,7 @@ vhd_index_schedule_data_read(vhd_index_t *index, td_request_t treq)
        req->index = index;
        req->off   = offset;
 
-       td_prep_read(index->driver,
-                    &req->tiocb, file->fd, treq.buf, size, offset,
+       td_prep_read(&req->tiocb, file->fd, treq.buf, size, offset,
                     vhd_index_complete_data_read, req);
        td_queue_tiocb(index->driver, &req->tiocb);
 
index 60927d4d65822c95f083360f64b59087279deef7..9af8f6d1183d651a98ded5d526a98a22316a96fc 100644 (file)
@@ -36,7 +36,6 @@
 #include <inttypes.h>
 
 #include "io-optimize.h"
-#include "tapdisk-queue.h"
 #include "tapdisk-log.h"
 
 #if (!defined(TEST) && defined(DEBUG))
@@ -208,18 +207,12 @@ merge_tail(struct opioctx *ctx, struct iocb *head, struct iocb *io)
 static int
 merge(struct opioctx *ctx, struct iocb *head, struct iocb *io)
 {
-       struct tiocb *tiocb = head->data;
-       size_t limit = tiocb->merge_limit;
-
        if (head->aio_lio_opcode != io->aio_lio_opcode)
                return -EINVAL;
 
        if (!contiguous_iocbs(head, io))
                return -EINVAL;
 
-       if (head->u.c.nbytes + io->u.c.nbytes > limit)
-               return -EINVAL;
-
        return merge_tail(ctx, head, io);               
 }
 
index 0503c75d9dc7e8e4176595c26f24689033826ee2..af3c3150265a86743d5b50449c2b1633c5d076c2 100644 (file)
@@ -235,21 +235,17 @@ td_queue_tiocb(td_driver_t *driver, struct tiocb *tiocb)
 }
 
 void
-td_prep_read(td_driver_t *driver,
-            struct tiocb *tiocb, int fd, char *buf, size_t bytes,
+td_prep_read(struct tiocb *tiocb, int fd, char *buf, size_t bytes,
             long long offset, td_queue_callback_t cb, void *arg)
 {
-       tapdisk_prep_tiocb(tiocb, fd, 0, buf, bytes, offset, driver->storage,
-                          cb, arg);
+       tapdisk_prep_tiocb(tiocb, fd, 0, buf, bytes, offset, cb, arg);
 }
 
 void
-td_prep_write(td_driver_t *driver,
-             struct tiocb *tiocb, int fd, char *buf, size_t bytes,
+td_prep_write(struct tiocb *tiocb, int fd, char *buf, size_t bytes,
              long long offset, td_queue_callback_t cb, void *arg)
 {
-       tapdisk_prep_tiocb(tiocb, fd, 1, buf, bytes, offset, driver->storage,
-                          cb, arg);
+       tapdisk_prep_tiocb(tiocb, fd, 1, buf, bytes, offset, cb, arg);
 }
 
 void
index 7ee72d817fd20bba4a0b220c414f5d61d32727d3..4ee5424d2ceb8594392bd638dba83cce45a15bfc 100644 (file)
@@ -46,9 +46,9 @@ void td_complete_request(td_request_t, int);
 void td_debug(td_image_t *);
 
 void td_queue_tiocb(td_driver_t *, struct tiocb *);
-void td_prep_read(td_driver_t *, struct tiocb *, int, char *, size_t,
+void td_prep_read(struct tiocb *, int, char *, size_t,
                  long long, td_queue_callback_t, void *);
-void td_prep_write(td_driver_t *, struct tiocb *, int, char *, size_t,
+void td_prep_write(struct tiocb *, int, char *, size_t,
                   long long, td_queue_callback_t, void *);
 void td_panic(void) __attribute__((noreturn));
 
index c417e0a4d499062213d46d25cef5ad7a5994a605..1353b10812afe47ac6c400be0b11f72995acf334 100644 (file)
@@ -44,8 +44,6 @@
 #include "tapdisk-utils.h"
 
 #include "libaio-compat.h"
-#include "blktap2.h"
-#include "tapdisk-storage.h"
 #include "atomicio.h"
 
 #define WARN(_f, _a...) tlog_write(TLOG_WARN, _f, ##_a)
  */
 #define REQUEST_ASYNC_FD ((io_context_t)1)
 
-#define for_each_tiocb(_tiocb, _list) \
-       list_for_each_entry(_tiocb, _list, entry)
+static inline void
+queue_tiocb(struct tqueue *queue, struct tiocb *tiocb)
+{
+       struct iocb *iocb = &tiocb->iocb;
+
+       if (queue->queued) {
+               struct tiocb *prev = (struct tiocb *)
+                       queue->iocbs[queue->queued - 1]->data;
+               prev->next = tiocb;
+       }
+
+       queue->iocbs[queue->queued++] = iocb;
+}
+
+static inline int
+deferred_tiocbs(struct tqueue *queue)
+{
+       return (queue->deferred.head != NULL);
+}
+
+static inline void
+defer_tiocb(struct tqueue *queue, struct tiocb *tiocb)
+{
+       struct tlist *list = &queue->deferred;
+
+       if (!list->head)
+               list->head = list->tail = tiocb;
+       else
+               list->tail = list->tail->next = tiocb;
+
+       queue->tiocbs_deferred++;
+       queue->deferrals++;
+}
+
+static inline void
+queue_deferred_tiocb(struct tqueue *queue)
+{
+       struct tlist *list = &queue->deferred;
 
-#define for_each_tiocb_safe(_tiocb, _next, _list) \
-       list_for_each_entry_safe(_tiocb, _next, _list, entry)
+       if (list->head) {
+               struct tiocb *tiocb = list->head;
+
+               list->head = tiocb->next;
+               if (!list->head)
+                       list->tail = NULL;
+
+               queue_tiocb(queue, tiocb);
+               queue->tiocbs_deferred--;
+       }
+}
+
+static inline void
+queue_deferred_tiocbs(struct tqueue *queue)
+{
+       while (!tapdisk_queue_full(queue) && deferred_tiocbs(queue))
+               queue_deferred_tiocb(queue);
+}
 
 /*
  * td_complete may queue more tiocbs
@@ -74,9 +124,6 @@ complete_tiocb(struct tqueue *queue, struct tiocb *tiocb, unsigned long res)
        int err;
        struct iocb *iocb = &tiocb->iocb;
 
-       list_del(&tiocb->entry);
-       pthread_mutex_unlock(&queue->mutex);
-
        if (res == iocb->u.c.nbytes)
                err = 0;
        else if ((int)res < 0)
@@ -85,21 +132,30 @@ complete_tiocb(struct tqueue *queue, struct tiocb *tiocb, unsigned long res)
                err = -EIO;
 
        tiocb->cb(tiocb->arg, tiocb, err);
-
-       pthread_mutex_lock(&queue->mutex);
 }
 
 static int
 cancel_tiocbs(struct tqueue *queue, int err)
 {
-       struct tiocb *tiocb, *next;
-       int queued = queue->queued;
+       int queued;
+       struct tiocb *tiocb;
 
-       for_each_tiocb_safe(tiocb, next, &queue->pending)
-               complete_tiocb(queue, tiocb, err);
+       if (!queue->queued)
+               return 0;
 
+       /* 
+        * td_complete may queue more tiocbs, which
+        * will overwrite the contents of queue->iocbs.
+        * use a private linked list to keep track
+        * of the tiocbs we're cancelling. 
+        */
+       tiocb  = queue->iocbs[0]->data;
+       queued = queue->queued;
        queue->queued = 0;
 
+       for (; tiocb != NULL; tiocb = tiocb->next)
+               complete_tiocb(queue, tiocb, err);
+
        return queued;
 }
 
@@ -189,10 +245,7 @@ tapdisk_rwio_submit(struct tqueue *queue)
                ep      = rwio->aio_events + i;
                iocb    = queue->iocbs[i];
                ep->obj = iocb;
-
-               pthread_mutex_unlock(&queue->mutex);
                ep->res = tapdisk_rwio_rw(iocb);
-               pthread_mutex_lock(&queue->mutex);
        }
 
        split = io_split(&queue->opioctx, rwio->aio_events, merged);
@@ -204,6 +257,8 @@ tapdisk_rwio_submit(struct tqueue *queue)
                complete_tiocb(queue, tiocb, ep->res);
        }
 
+       queue_deferred_tiocbs(queue);
+
        return split;
 }
 
@@ -393,7 +448,6 @@ tapdisk_lio_event(event_id_t id, char mode, void *private)
        struct io_event *ep;
 
        tapdisk_lio_ack_event(queue);
-       pthread_mutex_lock(&queue->mutex);
 
        lio   = queue->tio_data;
        ret   = io_getevents(lio->aio_ctx, 0,
@@ -412,7 +466,7 @@ tapdisk_lio_event(event_id_t id, char mode, void *private)
                complete_tiocb(queue, tiocb, ep->res);
        }
 
-       pthread_mutex_unlock(&queue->mutex);
+       queue_deferred_tiocbs(queue);
 }
 
 static int
@@ -462,10 +516,7 @@ tapdisk_lio_submit(struct tqueue *queue)
        tapdisk_filter_iocbs(queue->filter, queue->iocbs, queue->queued);
        merged    = io_merge(&queue->opioctx, queue->iocbs, queue->queued);
        tapdisk_lio_set_eventfd(queue, merged, queue->iocbs);
-
-       pthread_mutex_unlock(&queue->mutex);
        submitted = io_submit(lio->aio_ctx, merged, queue->iocbs);
-       pthread_mutex_lock(&queue->mutex);
 
        DBG("queued: %d, merged: %d, submitted: %d\n",
            queue->queued, merged, submitted);
@@ -552,125 +603,6 @@ fail:
        return err;
 }
 
-static int
-tapdisk_queue_full(struct tqueue *queue)
-{
-       return queue->tiocbs_pending + queue->queued >= queue->size;
-}
-
-static void
-tapdisk_queue_dequeue_tiocbs(struct tqueue *queue)
-{
-       struct tiocb *tiocb, *next;
-
-       /* NB. queue lock held */
-
-       for_each_tiocb_safe(tiocb, next, &queue->waiting) {
-               if (tapdisk_queue_full(queue))
-                       break;
-
-               list_move_tail(&tiocb->entry, &queue->pending);
-               queue->iocbs[queue->queued++] = &tiocb->iocb;
-       }
-}
-
-/*
- * NB. Dispatcher thread.
- *
- * I/O may block. Not only synchronous I/O, but because I/O takes
- * memory, so even io_submit may block. The funny part about I/O
- * taking memory is that freeing memory typically takes I/O.
- *
- * Blktap makes sure that we're served from a bunch of private memory
- * pools to solve the general deadlock hazard. Unfortunately such
- * pools are not big enough to cover all tapdev I/O in flight.
- *
- * The consequence is that, once pools are exhausted, I/O submission
- * still blocks. It will immediately wake again once the pools are
- * refilled, but refilling them typically takes I/O completion.
- *
- * We run I/O completion from the main event loop. But submission
- * therefore must go separate.
- */
-
-static void*
-tapdisk_queue_thread_run(void *arg)
-{
-       struct tqueue *queue = arg;
-
-       pthread_mutex_lock(&queue->mutex);
-       do {
-               do {
-                       if (queue->closing)
-                               goto out;
-
-                       if (tapdisk_queue_full(queue))
-                               goto wait;
-
-                       if (!list_empty(&queue->waiting))
-                               break;
-
-               wait:
-                       pthread_cond_wait(&queue->cond, &queue->mutex);
-               } while (1);
-
-               tapdisk_queue_dequeue_tiocbs(queue);
-
-               queue->tio->tio_submit(queue);
-       } while (1);
-
-out:
-       pthread_mutex_unlock(&queue->mutex);
-       return NULL;
-}
-
-static int
-tapdisk_queue_thread_start(struct tqueue *queue)
-{
-       pthread_attr_t attr;
-       int err;
-
-       err = pthread_mutex_init(&queue->mutex, NULL);
-       if (err)
-               return -err;
-
-       err = pthread_cond_init(&queue->cond, NULL);
-       if (err)
-               return -err;
-
-       queue->closing = 0;
-
-       pthread_attr_init(&attr);
-       pthread_attr_setstacksize(&attr, 32<<10);
-
-       err = pthread_create(&queue->thread, &attr,
-                            tapdisk_queue_thread_run, queue);
-       if (err)
-               return -err;
-
-       return 0;
-}
-
-static void
-tapdisk_queue_thread_kick(struct tqueue *queue)
-{
-       pthread_mutex_lock(&queue->mutex);
-       pthread_cond_signal(&queue->cond);
-       pthread_mutex_unlock(&queue->mutex);
-}
-
-static void
-tapdisk_queue_thread_exit(struct tqueue *queue)
-{
-       if (queue->thread) {
-               queue->closing = 1;
-               tapdisk_queue_thread_kick(queue);
-
-               pthread_join(queue->thread, NULL);
-               queue->thread = 0;
-       }
-}
-
 int
 tapdisk_init_queue(struct tqueue *queue, int size,
                   int drv, struct tfilter *filter)
@@ -681,8 +613,6 @@ tapdisk_init_queue(struct tqueue *queue, int size,
 
        queue->size   = size;
        queue->filter = filter;
-       INIT_LIST_HEAD(&queue->waiting);
-       INIT_LIST_HEAD(&queue->pending);
 
        if (!size)
                return 0;
@@ -701,10 +631,6 @@ tapdisk_init_queue(struct tqueue *queue, int size,
        if (err)
                goto fail;
 
-       err = tapdisk_queue_thread_start(queue);
-       if (err)
-               goto fail;
-
        return 0;
 
  fail:
@@ -717,8 +643,6 @@ tapdisk_free_queue(struct tqueue *queue)
 {
        tapdisk_queue_free_io(queue);
 
-       tapdisk_queue_thread_exit(queue);
-
        free(queue->iocbs);
        queue->iocbs = NULL;
 
@@ -728,40 +652,29 @@ tapdisk_free_queue(struct tqueue *queue)
 void 
 tapdisk_debug_queue(struct tqueue *queue)
 {
-       struct tiocb *tiocb;
+       struct tiocb *tiocb = queue->deferred.head;
 
        WARN("TAPDISK QUEUE:\n");
        WARN("size: %d, tio: %s, queued: %d, iocbs_pending: %d, "
-            "tiocbs_pending: %d\n",
+            "tiocbs_pending: %d, tiocbs_deferred: %d, deferrals: %llx\n",
             queue->size, queue->tio->name, queue->queued, queue->iocbs_pending,
-            queue->tiocbs_pending);
-
-       pthread_mutex_lock(&queue->mutex);
-
-       WARN("pending:\n");
-       for_each_tiocb(tiocb, &queue->pending) {
-               struct iocb *io = &tiocb->iocb;
-               WARN("%s of %lu bytes at %lld\n",
-                    (io->aio_lio_opcode == IO_CMD_PWRITE ?
-                     "write" : "read"),
-                    io->u.c.nbytes, io->u.c.offset);
-       }
-
-       WARN("deferred:\n");
-       for_each_tiocb(tiocb, &queue->waiting) {
-               struct iocb *io = &tiocb->iocb;
-               WARN("%s of %lu bytes at %lld\n",
-                    (io->aio_lio_opcode == IO_CMD_PWRITE ?
-                     "write" : "read"),
-                    io->u.c.nbytes, io->u.c.offset);
+            queue->tiocbs_pending, queue->tiocbs_deferred, queue->deferrals);
+
+       if (tiocb) {
+               WARN("deferred:\n");
+               for (; tiocb != NULL; tiocb = tiocb->next) {
+                       struct iocb *io = &tiocb->iocb;
+                       WARN("%s of %lu bytes at %lld\n",
+                            (io->aio_lio_opcode == IO_CMD_PWRITE ?
+                             "write" : "read"),
+                            io->u.c.nbytes, io->u.c.offset);
+               }
        }
-
-       pthread_mutex_unlock(&queue->mutex);
 }
 
 void
 tapdisk_prep_tiocb(struct tiocb *tiocb, int fd, int rw, char *buf, size_t size,
-                  long long offset, int storage, td_queue_callback_t cb, void *arg)
+                  long long offset, td_queue_callback_t cb, void *arg)
 {
        struct iocb *iocb = &tiocb->iocb;
 
@@ -773,27 +686,57 @@ tapdisk_prep_tiocb(struct tiocb *tiocb, int fd, int rw, char *buf, size_t size,
        iocb->data  = tiocb;
        tiocb->cb   = cb;
        tiocb->arg  = arg;
-
-       if (storage == TAPDISK_STORAGE_TYPE_EXT) {
-               size_t block_size = 4<<10; /* should query the fs */
-               tiocb->merge_limit = BLKTAP2_BIO_POOL_SIZE * block_size;
-       } else
-               /* contiguous storage:
-                  BLKTAP2_BIO_POOL_SIZE * BIO_MAX_PAGES * PAGE_SIZE */
-               tiocb->merge_limit = SIZE_MAX;
+       tiocb->next = NULL;
 }
 
 void
 tapdisk_queue_tiocb(struct tqueue *queue, struct tiocb *tiocb)
 {
-       pthread_mutex_lock(&queue->mutex);
-       list_add_tail(&tiocb->entry, &queue->waiting);
-       pthread_mutex_unlock(&queue->mutex);
+       if (!tapdisk_queue_full(queue))
+               queue_tiocb(queue, tiocb);
+       else
+               defer_tiocb(queue, tiocb);
 }
 
-void
+
+/*
+ * fail_tiocbs may queue more tiocbs
+ */
+int
+tapdisk_submit_tiocbs(struct tqueue *queue)
+{
+       return queue->tio->tio_submit(queue);
+}
+
+int
 tapdisk_submit_all_tiocbs(struct tqueue *queue)
 {
-       if (!list_empty(&queue->waiting))
-               tapdisk_queue_thread_kick(queue);
+       int submitted = 0;
+
+       do {
+               submitted += tapdisk_submit_tiocbs(queue);
+       } while (!tapdisk_queue_empty(queue));
+
+       return submitted;
+}
+
+/*
+ * cancel_tiocbs may queue more tiocbs
+ */
+int
+tapdisk_cancel_tiocbs(struct tqueue *queue)
+{
+       return cancel_tiocbs(queue, -EIO);
+}
+
+int
+tapdisk_cancel_all_tiocbs(struct tqueue *queue)
+{
+       int cancelled = 0;
+
+       do {
+               cancelled += tapdisk_cancel_tiocbs(queue);
+       } while (!tapdisk_queue_empty(queue));
+
+       return cancelled;
 }
index dfb69d1e40eeb84ef84cef67f470245d26e28694..9892c0dceb3182b8dc5207d8fa9f47ffbf8c5a50 100644 (file)
@@ -6,7 +6,6 @@
 #define TAPDISK_QUEUE_H
 
 #include <libaio.h>
-#include <pthread.h>
 
 #include "io-optimize.h"
 #include "scheduler.h"
@@ -16,14 +15,18 @@ struct tfilter;
 
 typedef void (*td_queue_callback_t)(void *arg, struct tiocb *, int err);
 
+
 struct tiocb {
        td_queue_callback_t   cb;
        void                 *arg;
 
        struct iocb           iocb;
-       size_t                merge_limit;
+       struct tiocb         *next;
+};
 
-       struct list_head      entry;
+struct tlist {
+       struct tiocb         *head;
+       struct tiocb         *tail;
 };
 
 struct tqueue {
@@ -34,24 +37,27 @@ struct tqueue {
 
        struct opioctx        opioctx;
 
-       struct iocb         **iocbs;
        int                   queued;
+       struct iocb         **iocbs;
 
-       struct list_head      waiting; /* tiocbs deferred */
-       struct list_head      pending; /* tiocbs submitted */
-
-       /* iocbs <= tiocbs pending, due to coalescing */
+       /* number of iocbs pending in the aio layer */
        int                   iocbs_pending;
+
+       /* number of tiocbs pending in the queue -- 
+        * this is likely to be larger than iocbs_pending 
+        * due to request coalescing */
        int                   tiocbs_pending;
 
+       /* iocbs may be deferred if the aio ring is full.
+        * tapdisk_queue_complete will ensure deferred
+        * iocbs are queued as slots become available. */
+       struct tlist          deferred;
+       int                   tiocbs_deferred;
+
        /* optional tapdisk filter */
        struct tfilter       *filter;
 
-       /* tio_submit thread */
-       pthread_t             thread;
-       pthread_cond_t        cond;
-       pthread_mutex_t       mutex;
-       int                   closing;
+       uint64_t              deferrals;
 };
 
 struct tio {
@@ -77,15 +83,19 @@ enum {
  * The *_all_tiocbs variants will handle the first two cases;
  * be sure to call submit after calling complete in the third case.
  */
+#define tapdisk_queue_count(q) ((q)->queued)
+#define tapdisk_queue_empty(q) ((q)->queued == 0)
+#define tapdisk_queue_full(q)  \
+       (((q)->tiocbs_pending + (q)->queued) >= (q)->size)
 int tapdisk_init_queue(struct tqueue *, int size, int drv, struct tfilter *);
 void tapdisk_free_queue(struct tqueue *);
 void tapdisk_debug_queue(struct tqueue *);
 void tapdisk_queue_tiocb(struct tqueue *, struct tiocb *);
 int tapdisk_submit_tiocbs(struct tqueue *);
-void tapdisk_submit_all_tiocbs(struct tqueue *);
+int tapdisk_submit_all_tiocbs(struct tqueue *);
 int tapdisk_cancel_tiocbs(struct tqueue *);
 int tapdisk_cancel_all_tiocbs(struct tqueue *);
 void tapdisk_prep_tiocb(struct tiocb *, int, int, char *, size_t,
-                       long long, int, td_queue_callback_t, void *);
+                       long long, td_queue_callback_t, void *);
 
 #endif
index 4d6375d5ea8af849afa4694902bb55075698e1ba..3756e44a5b2c3f6e053f5b05bb369ede2aefe1e3 100644 (file)
@@ -56,8 +56,6 @@
 #define BLKTAP2_IO_DEVICE              BLKTAP2_DIRECTORY"/tapdev"
 #define BLKTAP2_ENOSPC_SIGNAL_FILE     "/var/run/tapdisk-enospc"
 
-#define BLKTAP2_BIO_POOL_SIZE          12
-
 struct blktap2_handle {
        unsigned int                   ring;
        unsigned int                   device;