WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

[Xen-devel] [PATCH][1/4][IOMGR] I/O request Manager body

To: <xen-devel@xxxxxxxxxxxxxxxxxxx>
Subject: [Xen-devel] [PATCH][1/4][IOMGR] I/O request Manager body
From: "Satoshi Uchida" <s-uchida@xxxxxxxxxxxxx>
Date: Mon, 30 Jul 2007 17:50:51 +0900
Delivery-date: Mon, 30 Jul 2007 01:48:41 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
Thread-index: AcfFC3TXP9gKKQU1SUWaN2l2benbxAIDnZRw
This patch provides a I/O request management framework.

This framework can control virtual block device threads at 7 places :
  * deciding that virtual block devices(threads) is ether going or waiting,
  * before allocating pending_request variables,
  * after allocated pending_request variables,
  * after allocated no pending_request variables (Namely, out of request),
  * after freed pending_request variables and
  * starting/stopping virtual block devices(threads).

And, iomgr provides the total number of pending requests in blkback and blktap.

 --------------------------------------------------
 Satoshi UCHIDA 
    NEC Corporation, Japan


# HG changeset patch
# User s-uchida@xxxxxxxxxxxxx
# Date 1184302359 -32400
# Node ID aee77a9230c1b19873e60761d080af517bbfb189
# Parent  e64625df946b81ac1a5f8be7c5d0ae2aad618d7c
[IOMGR] Add I/O request management framework.
  This is body for I/O request management.

  Signed-by-off  Satoshi UCHIDA <s-uchida@xxxxxxxxxxxxx>

diff -r e64625df946b -r aee77a9230c1 drivers/xen/Kconfig
--- a/drivers/xen/Kconfig       Fri Jun 15 13:33:47 2007 -0600
+++ b/drivers/xen/Kconfig       Fri Jul 13 13:45:30 2007 +0900
@@ -65,6 +65,15 @@ config XEN_BLKDEV_TAP
           high-performance block backends, where disk images may be implemented
           as files, in memory, or on other hosts across the network.  This 
          driver can safely coexist with the existing blockback driver.
+
+config XEN_IOMGR
+       tristate "Backend I/O request manager framework"
+       depends on XEN_BACKEND || XEN_BLKDEV_TAP
+       default y
+       help
+         The Backend I/O request manager framework provides interface
+         which makes backend driver to control I/O requests by I/O 
+         control modules
 
 config XEN_NETDEV_BACKEND
        tristate "Network-device backend driver"
diff -r e64625df946b -r aee77a9230c1 drivers/xen/Makefile
--- a/drivers/xen/Makefile      Fri Jun 15 13:33:47 2007 -0600
+++ b/drivers/xen/Makefile      Fri Jul 13 13:45:30 2007 +0900
@@ -10,6 +10,7 @@ obj-y += util.o
 obj-y  += util.o
 obj-$(CONFIG_XEN_BLKDEV_BACKEND)       += blkback/
 obj-$(CONFIG_XEN_BLKDEV_TAP)           += blktap/
+obj-$(CONFIG_XEN_IOMGR)                        += iomgr/
 obj-$(CONFIG_XEN_NETDEV_BACKEND)       += netback/
 obj-$(CONFIG_XEN_TPMDEV_BACKEND)       += tpmback/
 obj-$(CONFIG_XEN_BLKDEV_FRONTEND)      += blkfront/
diff -r e64625df946b -r aee77a9230c1 drivers/xen/iomgr/Makefile
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/drivers/xen/iomgr/Makefile        Fri Jul 13 13:52:39 2007 +0900
@@ -0,0 +1,4 @@
+obj-$(CONFIG_XEN_IOMGR) := xeniomgr.o
+
+xeniomgr-y := iomgr.o
+
diff -r e64625df946b -r aee77a9230c1 drivers/xen/iomgr/iomgr.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/drivers/xen/iomgr/iomgr.c Fri Jul 13 13:52:39 2007 +0900
@@ -0,0 +1,188 @@
+/*****************************************************************************
+ * iomgr.c
+ *
+ *  Management interface for I/O request.
+ *
+ * Copyright(c) 2007, Satoshi UCHIDA, NEC Corporation
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License version 2
+ * as published by the Free Software Foundation; or, when distributed
+ * separately from the Linux kernel or incorporated into other
+ * software packages, subject to the following license:
+ * 
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this source file (the "Software"), to deal in the Software without
+ * restriction, including without limitation the rights to use, copy, modify,
+ * merge, publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ * 
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ * 
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ */
+
+#include <linux/module.h>
+#include <linux/stddef.h>
+#include <xen/iomgr.h>
+#include <asm/atomic.h>
+
+/* Current manager. */
+struct iomgr *mgr;
+
+/*
+ *  Default Manager.
+ *  Non Management for I/O request.
+ */
+static struct iomgr nomgr = {
+       .ops = {
+               .iomgr_waiting_request_fn = NULL,
+               .iomgr_allow_request_fn = NULL,
+               .iomgr_alloc_request_fn = NULL,
+               .iomgr_oo_abort_request_fn = NULL,
+               .iomgr_free_request_fn = NULL,
+               .iomgr_dev_start_fn = NULL,
+               .iomgr_dev_stop_fn = NULL,
+       },
+       .iomgr_name = "none",
+};
+
+/*
+ *  Counter for pending request.
+ */
+atomic_t pending_req = ATOMIC_INIT(0);
+
+
+/*
+ *  Functions which apply iomgr operations
+ */
+
+/*
+ *  Management for original waiting condition within VBD/TAP thread.
+ */
+int do_iomgr_waiting_request(struct xenbus_device *dev)
+{
+       if (mgr->ops.iomgr_waiting_request_fn != NULL)
+               return mgr->ops.iomgr_waiting_request_fn(dev);
+       else
+               return 0;
+}
+
+/*
+ *  Management when new request for VBD/TAP thread is securing.
+ */
+int do_iomgr_allow_request(struct xenbus_device *dev)
+{
+       if (mgr->ops.iomgr_allow_request_fn != NULL)
+               return mgr->ops.iomgr_allow_request_fn(dev);
+       else
+               return 0;
+}
+
+/* Management of allocating new request for VBD/TAP thread. */
+int do_iomgr_alloc_request(struct xenbus_device *dev)
+{
+       atomic_inc(&pending_req);
+       if (mgr->ops.iomgr_alloc_request_fn != NULL)
+               return mgr->ops.iomgr_alloc_request_fn(dev);
+       else
+               return 0;
+}
+
+/*
+ *  Management when it is failure to allocating new request
+ *  for VBD/TAP thread.
+ */
+int do_iomgr_oo_abort_request(struct xenbus_device *dev)
+{
+       if (mgr->ops.iomgr_oo_abort_request_fn != NULL)
+               return mgr->ops.iomgr_oo_abort_request_fn(dev);
+       else
+               return 0;
+}
+
+/*
+ *  Management when request for VBD/TAP thread finishes.
+ */
+void do_iomgr_free_request(struct xenbus_device *dev)
+{
+       atomic_dec(&pending_req);
+       if (mgr->ops.iomgr_free_request_fn != NULL)
+               mgr->ops.iomgr_free_request_fn(dev);
+}
+
+/*
+ *  Management when new VBD/TAP thread start.
+ */
+int do_iomgr_dev_start(struct xenbus_device *dev)
+{
+       if (mgr->ops.iomgr_dev_start_fn != NULL)
+               return mgr->ops.iomgr_dev_start_fn(dev);
+       return 0;
+}
+
+/*
+ *  Management when VBD/TAP thread stops.
+ */
+void do_iomgr_dev_stop(struct xenbus_device *dev)
+{
+       if (mgr->ops.iomgr_dev_stop_fn != NULL)
+               mgr->ops.iomgr_dev_stop_fn(dev);
+}
+
+
+/* Access to counter for pending requests. */
+atomic_t *num_pending_req(void)
+{
+       return &pending_req;
+}
+EXPORT_SYMBOL(num_pending_req);
+
+
+/*
+ *  Registration function for I/O manager.
+ */
+
+/* Registration of I/O Manager.*/
+int xen_iomgr_register(struct iomgr *newmgr)
+{
+       mgr = newmgr;
+
+       return 0;
+}
+EXPORT_SYMBOL_GPL(xen_iomgr_register);
+
+/*
+ * Unregistration of I/O Manager.
+ * Change to No operation manager.
+ */
+void xen_iomgr_unregister(struct iomgr *removemgr)
+{
+       if (mgr == removemgr)
+               mgr = &nomgr;
+}
+EXPORT_SYMBOL_GPL(xen_iomgr_unregister);
+
+
+/* Initializing function */
+static int iomgr_init(void)
+{
+       mgr = &nomgr;
+
+       return 0;
+}
+
+
+module_init(iomgr_init);
+
+MODULE_AUTHOR("Satoshi UCHIDA");
+MODULE_LICENSE("Dual BSD/GPL");
+MODULE_DESCRIPTION("Xen IO Manager");
diff -r e64625df946b -r aee77a9230c1 include/xen/iomgr.h
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/include/xen/iomgr.h       Fri Jul 13 13:52:39 2007 +0900
@@ -0,0 +1,100 @@
+/*****************************************************************************
+ * iomgr.h
+ *
+ *  Management interface for I/O request.
+ *
+ * Copyright(c) 2007, Satoshi UCHIDA, NEC Corporation
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License version 2
+ * as published by the Free Software Foundation; or, when distributed
+ * separately from the Linux kernel or incorporated into other
+ * software packages, subject to the following license:
+ * 
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this source file (the "Software"), to deal in the Software without
+ * restriction, including without limitation the rights to use, copy, modify,
+ * merge, publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ * 
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ * 
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ */
+
+#ifndef _XEN_IOMER_H
+#define _XEN_IOMER_H
+
+#include <asm/atomic.h>
+
+#define IOMGR_ALLOW_NG  1
+
+struct xenbus_device;
+
+/*
+ * Definition of iomgr function.
+ */
+typedef int (iomgr_waiting_request_fn) (struct xenbus_device *);
+typedef int (iomgr_allow_request_fn) (struct xenbus_device *);
+typedef int (iomgr_alloc_request_fn) (struct xenbus_device *);
+typedef int (iomgr_oo_abort_request_fn) (struct xenbus_device *);
+typedef void (iomgr_free_request_fn) (struct xenbus_device *);
+typedef int (iomgr_dev_start_fn) (struct xenbus_device *);
+typedef void (iomgr_dev_stop_fn) (struct xenbus_device *);
+
+
+/* iomgr operations */
+struct iomgr_ops
+{
+       iomgr_waiting_request_fn   *iomgr_waiting_request_fn;
+       iomgr_allow_request_fn     *iomgr_allow_request_fn;
+       iomgr_alloc_request_fn     *iomgr_alloc_request_fn;
+       iomgr_oo_abort_request_fn  *iomgr_oo_abort_request_fn;
+       iomgr_free_request_fn      *iomgr_free_request_fn;
+       iomgr_dev_start_fn         *iomgr_dev_start_fn;
+       iomgr_dev_stop_fn          *iomgr_dev_stop_fn;
+};
+
+#define IOMGR_NAME_MAX    (16)
+
+
+/* iomgr scheduler structure */
+struct iomgr
+{
+       struct iomgr_ops ops;
+       char iomgr_name[IOMGR_NAME_MAX];
+};
+
+
+/*
+ *  functions which apply iomgr operations
+ */
+int do_iomgr_waiting_request(struct xenbus_device *dev);
+int do_iomgr_allow_request(struct xenbus_device *dev);
+int do_iomgr_alloc_request(struct xenbus_device *dev);
+int do_iomgr_oo_abort_request(struct xenbus_device *dev);
+void do_iomgr_free_request(struct xenbus_device *dev);
+int do_iomgr_dev_start(struct xenbus_device *dev);
+void do_iomgr_dev_stop(struct xenbus_device *dev);
+
+/*
+ *  pending rezuest counter
+ */ 
+atomic_t *num_pending_req(void);
+
+
+/*
+ * Xen I/O scheduler registration
+ */
+extern int xen_iomgr_register(struct iomgr *);
+extern void xen_iomgr_unregister(struct iomgr *);
+       
+#endif


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-devel] [PATCH][1/4][IOMGR] I/O request Manager body, Satoshi Uchida <=