]> git.baikalelectronics.ru Git - kernel.git/commitdiff
xen-blkback: allow module to be cleanly unloaded
authorPaul Durrant <pdurrant@amazon.com>
Mon, 2 Dec 2019 11:41:17 +0000 (11:41 +0000)
committerJuergen Gross <jgross@suse.com>
Wed, 4 Dec 2019 10:35:35 +0000 (11:35 +0100)
Add a module_exit() to perform the necessary clean-up.

Signed-off-by: Paul Durrant <pdurrant@amazon.com>
Reviewed-by: "Roger Pau Monné" <roger.pau@citrix.com>
Reviewed-by: Juergen Gross <jgross@suse.com>
Signed-off-by: Juergen Gross <jgross@suse.com>
drivers/block/xen-blkback/blkback.c
drivers/block/xen-blkback/common.h
drivers/block/xen-blkback/xenbus.c

index fd1e19f1a49f5803ca6dd5d939ec41ec592af077..e562a7e20c3c0cd94ad48624a5c20c9220701052 100644 (file)
@@ -1504,5 +1504,13 @@ static int __init xen_blkif_init(void)
 
 module_init(xen_blkif_init);
 
+static void __exit xen_blkif_fini(void)
+{
+       xen_blkif_xenbus_fini();
+       xen_blkif_interface_fini();
+}
+
+module_exit(xen_blkif_fini);
+
 MODULE_LICENSE("Dual BSD/GPL");
 MODULE_ALIAS("xen-backend:vbd");
index 1d3002d773f7adb151dcf79adf18f919e461290a..49132b0adbbecf7e567d356e113b2ec393e68edf 100644 (file)
@@ -375,9 +375,12 @@ struct phys_req {
        struct block_device     *bdev;
        blkif_sector_t          sector_number;
 };
+
 int xen_blkif_interface_init(void);
+void xen_blkif_interface_fini(void);
 
 int xen_blkif_xenbus_init(void);
+void xen_blkif_xenbus_fini(void);
 
 irqreturn_t xen_blkif_be_int(int irq, void *dev_id);
 int xen_blkif_schedule(void *arg);
index b90dbcd99c03e9c4e1ae0bc5f22180b80c5903e1..e8c5c54e1d2657a1394dde3bdee52b443d32b2e3 100644 (file)
@@ -333,6 +333,12 @@ int __init xen_blkif_interface_init(void)
        return 0;
 }
 
+void xen_blkif_interface_fini(void)
+{
+       kmem_cache_destroy(xen_blkif_cachep);
+       xen_blkif_cachep = NULL;
+}
+
 /*
  *  sysfs interface for VBD I/O requests
  */
@@ -1122,3 +1128,8 @@ int xen_blkif_xenbus_init(void)
 {
        return xenbus_register_backend(&xen_blkbk_driver);
 }
+
+void xen_blkif_xenbus_fini(void)
+{
+       xenbus_unregister_driver(&xen_blkbk_driver);
+}