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-changelog

[Xen-changelog] [linux-2.6.18-xen] Use module use count on accel plugin

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] [linux-2.6.18-xen] Use module use count on accel plugin to prevent premature unload.
From: "Xen patchbot-linux-2.6.18-xen" <patchbot-linux-2.6.18-xen@xxxxxxxxxxxxxxxxxxx>
Date: Thu, 04 Oct 2007 17:42:19 -0700
Delivery-date: Thu, 04 Oct 2007 18:30:46 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-changelog-request@lists.xensource.com?subject=help>
List-id: BK change log <xen-changelog.lists.xensource.com>
List-post: <mailto:xen-changelog@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=unsubscribe>
Reply-to: xen-devel@xxxxxxxxxxxxxxxxxxx
Sender: xen-changelog-bounces@xxxxxxxxxxxxxxxxxxx
# HG changeset patch
# User Keir Fraser <keir@xxxxxxxxxxxxx>
# Date 1191420127 -3600
# Node ID d4f9453a3de751296bbab1438f337becfd115b8a
# Parent  e7a3f045cb60f2db1e38f65d9cca5934e4234f53
Use module use count on accel plugin to prevent premature unload.
Signed-off-by: Kieran Mansley <kmansley@xxxxxxxxxxxxxx>
---
 drivers/xen/netback/accel.c  |   10 ++++++----
 drivers/xen/netback/common.h |    1 +
 2 files changed, 7 insertions(+), 4 deletions(-)

diff -r e7a3f045cb60 -r d4f9453a3de7 drivers/xen/netback/accel.c
--- a/drivers/xen/netback/accel.c       Wed Oct 03 15:01:30 2007 +0100
+++ b/drivers/xen/netback/accel.c       Wed Oct 03 15:02:07 2007 +0100
@@ -187,8 +187,8 @@ static int netback_accelerator_cleanup_b
  *
  * This should only be allowed when there are no remaining users -
  * i.e. it is not necessary to go through and clear all the hooks, as
- * they should have already been removed.  This is enforced through a
- * usage count and BUG_ON(use!=0), but should be made more user-friendly
+ * they should have already been removed.  This is enforced by taking
+ * a module reference to the plugin while the interfaces are in use
  */
 void netback_disconnect_accelerator(int id, const char *eth_name)
 {
@@ -227,7 +227,8 @@ void netback_probe_accelerators(struct b
         */
        spin_lock_irqsave(&accelerators_lock, flags);
        list_for_each_entry(accelerator, &accelerators_list, link) { 
-               if (match_accelerator(dev, be, accelerator)) {
+               if (match_accelerator(dev, be, accelerator) &&
+                   try_module_get(accelerator->hooks->owner)) {
                        be->accelerator = accelerator;
                        atomic_inc(&be->accelerator->use_count);
                        be->accelerator->hooks->probe(dev);
@@ -242,9 +243,10 @@ void netback_remove_accelerators(struct 
                                 struct xenbus_device *dev)
 {
        /* Notify the accelerator (if any) of this device's removal */
-       if ( be->accelerator ) {
+       if (be->accelerator) {
                be->accelerator->hooks->remove(dev);
                atomic_dec(&be->accelerator->use_count);
+               module_put(be->accelerator->hooks->owner);
        }
        be->accelerator = NULL;
 }
diff -r e7a3f045cb60 -r d4f9453a3de7 drivers/xen/netback/common.h
--- a/drivers/xen/netback/common.h      Wed Oct 03 15:01:30 2007 +0100
+++ b/drivers/xen/netback/common.h      Wed Oct 03 15:02:07 2007 +0100
@@ -125,6 +125,7 @@ extern int netbk_copy_skb_mode;
 
 /* Function pointers into netback accelerator plugin modules */
 struct netback_accel_hooks {
+       struct module *owner;
        int  (*probe)(struct xenbus_device *dev);
        int (*remove)(struct xenbus_device *dev);
 };

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

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-changelog] [linux-2.6.18-xen] Use module use count on accel plugin to prevent premature unload., Xen patchbot-linux-2.6.18-xen <=