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

[Xen-changelog] [linux-2.6.18-xen] blkfront: module exit handling adjustments



# HG changeset patch
# User Jan Beulich <jbeulich@xxxxxxxx>
# Date 1331126934 -3600
# Node ID 99dc6737898bb6f83bcaa78db18aa0253fc08c24
# Parent  504cb8e1146656ef83a7cccfe6c2bcbf24bb2e34
blkfront: module exit handling adjustments

blkdev majors and minor tracking data must be released upon exit, or
else the module can't attach to devices using the same majors upon
being loaded again.

Also replace the literal uses of 202 for the Xen VBD major with the
upstream manifest constant.

Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx>
---


diff -r 504cb8e11466 -r 99dc6737898b drivers/xen/blkfront/blkfront.c
--- a/drivers/xen/blkfront/blkfront.c   Wed Mar 07 14:27:43 2012 +0100
+++ b/drivers/xen/blkfront/blkfront.c   Wed Mar 07 14:28:54 2012 +0100
@@ -962,7 +962,8 @@
 
 static void __exit xlblk_exit(void)
 {
-       return xenbus_unregister_driver(&blkfront_driver);
+       xenbus_unregister_driver(&blkfront_driver);
+       xlbd_release_major_info();
 }
 module_exit(xlblk_exit);
 
diff -r 504cb8e11466 -r 99dc6737898b drivers/xen/blkfront/block.h
--- a/drivers/xen/blkfront/block.h      Wed Mar 07 14:27:43 2012 +0100
+++ b/drivers/xen/blkfront/block.h      Wed Mar 07 14:28:54 2012 +0100
@@ -156,4 +156,6 @@
 }
 #endif
 
+void xlbd_release_major_info(void);
+
 #endif /* __XEN_DRIVERS_BLOCK_H__ */
diff -r 504cb8e11466 -r 99dc6737898b drivers/xen/blkfront/vbd.c
--- a/drivers/xen/blkfront/vbd.c        Wed Mar 07 14:27:43 2012 +0100
+++ b/drivers/xen/blkfront/vbd.c        Wed Mar 07 14:28:54 2012 +0100
@@ -40,6 +40,10 @@
 #include <xen/platform-compat.h>
 #endif
 
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,23)
+#define XENVBD_MAJOR 202
+#endif
+
 #define BLKIF_MAJOR(dev) ((dev)>>8)
 #define BLKIF_MINOR(dev) ((dev) & 0xff)
 
@@ -163,7 +167,7 @@
                        ptr->type = &xlbd_vbd_type_ext;
 
                /* 
-                * if someone already registered block major 202,
+                * if someone already registered block major XENVBD_MAJOR,
                 * don't try to register it again
                 */
                if (major_info[XLBD_MAJOR_VBD_ALT(index)] != NULL) {
@@ -238,6 +242,32 @@
        /* XXX: release major if 0 */
 }
 
+void __exit
+xlbd_release_major_info(void)
+{
+       unsigned int i;
+       int vbd_done = 0;
+
+       for (i = 0; i < ARRAY_SIZE(major_info); ++i) {
+               struct xlbd_major_info *mi = major_info[i];
+
+               if (!mi)
+                       continue;
+               if (mi->usage)
+                       printk(KERN_WARNING
+                              "vbd: major %u still in use (%u times)\n",
+                              mi->major, mi->usage);
+               if (mi->major != XENVBD_MAJOR || !vbd_done) {
+                       unregister_blkdev(mi->major, mi->type->devname);
+                       kfree(mi->minors->bitmap);
+                       kfree(mi->minors);
+               }
+               if (mi->major == XENVBD_MAJOR)
+                       vbd_done = 1;
+               kfree(mi);
+       }
+}
+
 static int
 xlbd_reserve_minors(struct xlbd_major_info *mi, unsigned int minor,
                    unsigned int nr_minors)
@@ -443,7 +473,7 @@
                minor = BLKIF_MINOR(vdevice);
        }
        else {
-               major = 202;
+               major = XENVBD_MAJOR;
                minor = BLKIF_MINOR_EXT(vdevice);
        }
 

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


 


Rackspace

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