[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-devel] [PATCH 02 of 21] blktap3/drivers: Introduce I/O optimisation routines



This patch copies files io-optimize.[ch] from blktap2 (with changes coming from
blktap2.5). I haven't looked thoroughly into them, they seem to contain
functionality for optimising the processing of I/O requests, e.g. merging of
requests etc.

Signed-off-by: Thanos Makatos <thanos.makatos@xxxxxxxxxx>

diff --git a/tools/blktap2/drivers/io-optimize.c 
b/tools/blktap3/drivers/io-optimize.c
copy from tools/blktap2/drivers/io-optimize.c
copy to tools/blktap3/drivers/io-optimize.c
--- a/tools/blktap2/drivers/io-optimize.c
+++ b/tools/blktap3/drivers/io-optimize.c
@@ -1,5 +1,7 @@
 /* 
- * Copyright (c) 2008, XenSource Inc.
+ * Copyright (c) 2007, XenSource Inc.
+ * Copyright (c) 2010, Citrix Systems, Inc.
+ *
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -44,11 +46,7 @@
 #define DBG(ctx, f, a...) ((void)0)
 #endif
 
-static void print_merged_iocbs(struct opioctx *ctx, 
-                              struct iocb **iocbs, int num_iocbs);
-
-void
-opio_free(struct opioctx *ctx)
+void opio_free(struct opioctx *ctx)
 {
        free(ctx->opios);
        ctx->opios = NULL;
@@ -214,12 +212,48 @@ merge(struct opioctx *ctx, struct iocb *
        return merge_tail(ctx, head, io);               
 }
 
-int
-io_merge(struct opioctx *ctx, struct iocb **queue, int num)
+#if (defined(TEST) || defined(DEBUG))
+static void
+print_optimized_iocbs(struct opioctx *ctx, struct opio *op, int *cnt)
+{
+    char pref[10];
+
+    while (op) {
+        snprintf(pref, 10, "  %d: ", (*cnt)++);
+        __print_iocb(ctx, op->iocb, pref);
+        op = op->next;
+    }
+}
+
+static void
+print_merged_iocbs(struct opioctx *ctx, struct iocb **iocbs, int num_iocbs)
+{
+    int i, cnt;
+    char pref[10];
+    struct iocb *io;
+    struct opio *op;
+
+    DBG(ctx, "merged iocbs:\n");
+    for (i = 0, cnt = 0; i < num_iocbs; i++) {
+        io = iocbs[i];
+        snprintf(pref, 10, "%d: ", cnt++);
+        __print_iocb(ctx, io, pref);
+
+        if (iocb_optimized(ctx, io)) {
+            op = (struct opio *) io->data;
+            print_optimized_iocbs(ctx, op->next, &cnt);
+        }
+    }
+}
+#else
+#define print_optimized_iocbs(...)
+#define print_merged_iocbs(...)
+#endif
+
+int io_merge(struct opioctx *ctx, struct iocb **queue, int num)
 {
        int i, on_queue;
        struct iocb *io, **q;
-       struct opio *ophead;
        
        if (!num)
                return 0;
@@ -234,9 +268,7 @@ io_merge(struct opioctx *ctx, struct ioc
                        queue[++on_queue] = io;
        }
 
-#if (defined(TEST) || defined(DEBUG))
        print_merged_iocbs(ctx, queue, on_queue + 1);
-#endif
 
        return ++on_queue;
 }
@@ -346,80 +378,20 @@ io_split(struct opioctx *ctx, struct io_
 debug print functions
 ******************************************************************************/
 static inline void
-__print_iocb(struct opioctx *ctx, struct iocb *io, char *prefix)
+__print_iocb(struct opioctx *ctx __attribute__((unused)),
+        struct iocb *io __attribute__((unused)),
+        char *prefix __attribute__((unused)))
 {
-       char *type;
-
-       type = (io->aio_lio_opcode == IO_CMD_PREAD ? "read" : "write");
-
-       DBG(ctx, "%soff: %08llx, nbytes: %04lx, buf: %p, type: %s, data: %08lx,"
+    DBG(ctx,
+        "%soff: %08llx, nbytes: %04lx, buf: %p, type: %s, data: %08lx,"
            " optimized: %d\n", prefix, io->u.c.offset, io->u.c.nbytes, 
-           io->u.c.buf, type, (unsigned long)io->data, 
-           iocb_optimized(ctx, io));
+        io->u.c.buf,
+        (io->aio_lio_opcode == IO_CMD_PREAD ? "read" : "write"),
+        (unsigned long) io->data, iocb_optimized(ctx, io));
 }
 
-static char *null_prefix = "";
-#define print_iocb(ctx, io) __print_iocb(ctx, io, null_prefix)
+#define print_iocb(ctx, io) __print_iocb(ctx, io, "")
 
-static void
-print_iocbs(struct opioctx *ctx, struct iocb **iocbs, int num_iocbs)
-{
-       int i;
-       char pref[10];
-       struct iocb *io;
-
-       DBG(ctx, "iocbs:\n");
-       for (i = 0; i < num_iocbs; i++) {
-               io = iocbs[i];
-               snprintf(pref, 10, "%d: ", i);
-               __print_iocb(ctx, io, pref);
-       }
-}
-
-static void
-print_optimized_iocbs(struct opioctx *ctx, struct opio *op, int *cnt)
-{
-       char pref[10];
-
-       while (op) {
-               snprintf(pref, 10, "  %d: ", (*cnt)++);
-               __print_iocb(ctx, op->iocb, pref);
-               op = op->next;
-       }
-}
-
-static void
-print_merged_iocbs(struct opioctx *ctx, struct iocb **iocbs, int num_iocbs)
-{
-       int i, cnt;
-       char pref[10];
-       struct iocb *io;
-       struct opio *op;
-
-       DBG(ctx, "merged iocbs:\n");
-       for (i = 0, cnt = 0; i < num_iocbs; i++) {
-               io = iocbs[i];
-               snprintf(pref, 10, "%d: ", cnt++);
-               __print_iocb(ctx, io, pref);
-
-               if (iocb_optimized(ctx, io)) {
-                       op = (struct opio *)io->data;
-                       print_optimized_iocbs(ctx, op->next, &cnt);
-               }
-       }
-}
-
-static void
-print_events(struct opioctx *ctx, struct io_event *events, int num_events)
-{
-       int i;
-       struct iocb *io;
-
-       for (i = 0; i < num_events; i++) {
-               io = events[i].obj;
-               print_iocb(ctx, io);
-       }
-}
 /******************************************************************************
 end debug print functions
 ******************************************************************************/
@@ -571,8 +543,34 @@ init_optest(struct iocb *iocb_list,
                iocbs[i]  = &iocb_list[i];
 }
 
-int
-main(int argc, char **argv)
+static void
+print_iocbs(struct opioctx *ctx, struct iocb **iocbs, int num_iocbs)
+{
+    int i;
+    char pref[10];
+    struct iocb *io;
+
+    DBG(ctx, "iocbs:\n");
+    for (i = 0; i < num_iocbs; i++) {
+        io = iocbs[i];
+        snprintf(pref, 10, "%d: ", i);
+        __print_iocb(ctx, io, pref);
+    }
+}
+
+static void
+print_events(struct opioctx *ctx, struct io_event *events, int num_events)
+{
+    int i;
+    struct iocb *io;
+
+    for (i = 0; i < num_events; i++) {
+        io = events[i].obj;
+        print_iocb(ctx, io);
+    }
+}
+
+int main(int argc, char **argv)
 {
        uint64_t num_secs;
        struct opioctx ctx;

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.